Major overhaul to the theme and now functioning.
This commit is contained in:
1 parent
5823ca3c39
commit
a475dfeab6
5218 files changed
+1643729
-13229
No files matched your search
Generated
Vendored
+203
@@ -0,0 +1,203 @@
|
||||
// Types
|
||||
import type { PropType, Ref, VNode } from 'vue';
|
||||
import type { GenericProps } from '../../util/index.js';
|
||||
export type VConfirmEditSlots<T> = {
|
||||
default: {
|
||||
model: Ref<T>;
|
||||
save: () => void;
|
||||
cancel: () => void;
|
||||
isPristine: boolean;
|
||||
get actions(): (props?: {}) => VNode;
|
||||
};
|
||||
};
|
||||
export declare const makeVConfirmEditProps: <Defaults extends {
|
||||
modelValue?: unknown;
|
||||
color?: unknown;
|
||||
cancelText?: unknown;
|
||||
okText?: unknown;
|
||||
disabled?: unknown;
|
||||
hideActions?: unknown;
|
||||
} = {}>(defaults?: Defaults | undefined) => {
|
||||
modelValue: unknown extends Defaults["modelValue"] ? null : {
|
||||
type: PropType<unknown extends Defaults["modelValue"] ? any : any>;
|
||||
default: unknown extends Defaults["modelValue"] ? any : any;
|
||||
};
|
||||
color: unknown extends Defaults["color"] ? StringConstructor : {
|
||||
type: PropType<unknown extends Defaults["color"] ? string : string | Defaults["color"]>;
|
||||
default: unknown extends Defaults["color"] ? string : string | Defaults["color"];
|
||||
};
|
||||
cancelText: unknown extends Defaults["cancelText"] ? {
|
||||
type: StringConstructor;
|
||||
default: string;
|
||||
} : Omit<{
|
||||
type: StringConstructor;
|
||||
default: string;
|
||||
}, "default" | "type"> & {
|
||||
type: PropType<unknown extends Defaults["cancelText"] ? string : string | Defaults["cancelText"]>;
|
||||
default: unknown extends Defaults["cancelText"] ? string : string | Defaults["cancelText"];
|
||||
};
|
||||
okText: unknown extends Defaults["okText"] ? {
|
||||
type: StringConstructor;
|
||||
default: string;
|
||||
} : Omit<{
|
||||
type: StringConstructor;
|
||||
default: string;
|
||||
}, "default" | "type"> & {
|
||||
type: PropType<unknown extends Defaults["okText"] ? string : string | Defaults["okText"]>;
|
||||
default: unknown extends Defaults["okText"] ? string : string | Defaults["okText"];
|
||||
};
|
||||
disabled: unknown extends Defaults["disabled"] ? {
|
||||
type: PropType<boolean | ("cancel" | "save")[]>;
|
||||
default: undefined;
|
||||
} : Omit<{
|
||||
type: PropType<boolean | ("cancel" | "save")[]>;
|
||||
default: undefined;
|
||||
}, "default" | "type"> & {
|
||||
type: PropType<unknown extends Defaults["disabled"] ? boolean | ("cancel" | "save")[] : boolean | ("cancel" | "save")[] | Defaults["disabled"]>;
|
||||
default: unknown extends Defaults["disabled"] ? boolean | ("cancel" | "save")[] : Defaults["disabled"] | NonNullable<boolean | ("cancel" | "save")[]>;
|
||||
};
|
||||
hideActions: unknown extends Defaults["hideActions"] ? BooleanConstructor : {
|
||||
type: PropType<unknown extends Defaults["hideActions"] ? boolean : boolean | Defaults["hideActions"]>;
|
||||
default: unknown extends Defaults["hideActions"] ? boolean : boolean | Defaults["hideActions"];
|
||||
};
|
||||
};
|
||||
export declare const VConfirmEdit: {
|
||||
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<{
|
||||
cancelText: string;
|
||||
okText: string;
|
||||
hideActions: boolean;
|
||||
} & {
|
||||
color?: string | undefined;
|
||||
disabled?: boolean | ("cancel" | "save")[] | undefined;
|
||||
} & {
|
||||
onCancel?: (() => any) | undefined;
|
||||
}, {
|
||||
save: () => void;
|
||||
cancel: () => void;
|
||||
isPristine: import("vue").ComputedRef<boolean>;
|
||||
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Omit<{
|
||||
cancel: () => true;
|
||||
save: (value: any) => true;
|
||||
"update:modelValue": (value: any) => true;
|
||||
}, "$children" | "modelValue" | "save" | "update:modelValue" | "v-slot:default" | "v-slots">, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, {
|
||||
cancelText: string;
|
||||
okText: string;
|
||||
disabled: boolean | ("cancel" | "save")[];
|
||||
hideActions: boolean;
|
||||
}, true, {}, import("vue").SlotsType<Partial<{
|
||||
default: (arg: {
|
||||
model: Ref<unknown, unknown>;
|
||||
save: () => void;
|
||||
cancel: () => void;
|
||||
isPristine: boolean;
|
||||
readonly actions: (props?: {} | undefined) => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>;
|
||||
}) => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>[];
|
||||
}>>, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
||||
P: {};
|
||||
B: {};
|
||||
D: {};
|
||||
C: {};
|
||||
M: {};
|
||||
Defaults: {};
|
||||
}, {
|
||||
cancelText: string;
|
||||
okText: string;
|
||||
hideActions: boolean;
|
||||
} & {
|
||||
color?: string | undefined;
|
||||
disabled?: boolean | ("cancel" | "save")[] | undefined;
|
||||
} & {
|
||||
onCancel?: (() => any) | undefined;
|
||||
}, {
|
||||
save: () => void;
|
||||
cancel: () => void;
|
||||
isPristine: import("vue").ComputedRef<boolean>;
|
||||
}, {}, {}, {}, {
|
||||
cancelText: string;
|
||||
okText: string;
|
||||
disabled: boolean | ("cancel" | "save")[];
|
||||
hideActions: boolean;
|
||||
}>;
|
||||
__isFragment?: undefined;
|
||||
__isTeleport?: undefined;
|
||||
__isSuspense?: undefined;
|
||||
} & import("vue").ComponentOptionsBase<{
|
||||
cancelText: string;
|
||||
okText: string;
|
||||
hideActions: boolean;
|
||||
} & {
|
||||
color?: string | undefined;
|
||||
disabled?: boolean | ("cancel" | "save")[] | undefined;
|
||||
} & {
|
||||
onCancel?: (() => any) | undefined;
|
||||
}, {
|
||||
save: () => void;
|
||||
cancel: () => void;
|
||||
isPristine: import("vue").ComputedRef<boolean>;
|
||||
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Omit<{
|
||||
cancel: () => true;
|
||||
save: (value: any) => true;
|
||||
"update:modelValue": (value: any) => true;
|
||||
}, "$children" | "modelValue" | "save" | "update:modelValue" | "v-slot:default" | "v-slots">, string, {
|
||||
cancelText: string;
|
||||
okText: string;
|
||||
disabled: boolean | ("cancel" | "save")[];
|
||||
hideActions: boolean;
|
||||
}, {}, string, import("vue").SlotsType<Partial<{
|
||||
default: (arg: {
|
||||
model: Ref<unknown, unknown>;
|
||||
save: () => void;
|
||||
cancel: () => void;
|
||||
isPristine: boolean;
|
||||
readonly actions: (props?: {} | undefined) => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>;
|
||||
}) => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>[];
|
||||
}>>, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new <T>(props: {
|
||||
modelValue?: T | undefined;
|
||||
"onUpdate:modelValue"?: ((value: T) => void) | undefined;
|
||||
onSave?: ((value: T) => void) | undefined;
|
||||
}, slots: VConfirmEditSlots<T>) => GenericProps<{
|
||||
modelValue?: T | undefined;
|
||||
"onUpdate:modelValue"?: ((value: T) => void) | undefined;
|
||||
onSave?: ((value: T) => void) | undefined;
|
||||
}, VConfirmEditSlots<T>>) & import("../../util/index.js").FilterPropsOptions<{
|
||||
modelValue: null;
|
||||
color: StringConstructor;
|
||||
cancelText: {
|
||||
type: StringConstructor;
|
||||
default: string;
|
||||
};
|
||||
okText: {
|
||||
type: StringConstructor;
|
||||
default: string;
|
||||
};
|
||||
disabled: {
|
||||
type: PropType<boolean | ("cancel" | "save")[]>;
|
||||
default: undefined;
|
||||
};
|
||||
hideActions: BooleanConstructor;
|
||||
}, import("vue").ExtractPropTypes<{
|
||||
modelValue: null;
|
||||
color: StringConstructor;
|
||||
cancelText: {
|
||||
type: StringConstructor;
|
||||
default: string;
|
||||
};
|
||||
okText: {
|
||||
type: StringConstructor;
|
||||
default: string;
|
||||
};
|
||||
disabled: {
|
||||
type: PropType<boolean | ("cancel" | "save")[]>;
|
||||
default: undefined;
|
||||
};
|
||||
hideActions: BooleanConstructor;
|
||||
}>>;
|
||||
export type VConfirmEdit = InstanceType<typeof VConfirmEdit>;
|
||||
Generated
Vendored
+103
@@ -0,0 +1,103 @@
|
||||
import { Fragment as _Fragment, mergeProps as _mergeProps, createVNode as _createVNode, createElementVNode as _createElementVNode } from "vue";
|
||||
// Components
|
||||
import { VBtn } from "../VBtn/index.js"; // Composables
|
||||
import { useLocale } from "../../composables/locale.js";
|
||||
import { useProxiedModel } from "../../composables/proxiedModel.js"; // Utilities
|
||||
import { computed, ref, watchEffect } from 'vue';
|
||||
import { deepEqual, deepToRaw, genericComponent, propsFactory, useRender } from "../../util/index.js"; // Types
|
||||
export const makeVConfirmEditProps = propsFactory({
|
||||
modelValue: null,
|
||||
color: String,
|
||||
cancelText: {
|
||||
type: String,
|
||||
default: '$vuetify.confirmEdit.cancel'
|
||||
},
|
||||
okText: {
|
||||
type: String,
|
||||
default: '$vuetify.confirmEdit.ok'
|
||||
},
|
||||
disabled: {
|
||||
type: [Boolean, Array],
|
||||
default: undefined
|
||||
},
|
||||
hideActions: Boolean
|
||||
}, 'VConfirmEdit');
|
||||
export const VConfirmEdit = genericComponent()({
|
||||
name: 'VConfirmEdit',
|
||||
props: makeVConfirmEditProps(),
|
||||
emits: {
|
||||
cancel: () => true,
|
||||
save: value => true,
|
||||
'update:modelValue': value => true
|
||||
},
|
||||
setup(props, _ref) {
|
||||
let {
|
||||
emit,
|
||||
slots
|
||||
} = _ref;
|
||||
const model = useProxiedModel(props, 'modelValue');
|
||||
const internalModel = ref();
|
||||
watchEffect(() => {
|
||||
internalModel.value = structuredClone(deepToRaw(model.value));
|
||||
});
|
||||
const {
|
||||
t
|
||||
} = useLocale();
|
||||
const isPristine = computed(() => {
|
||||
return deepEqual(model.value, internalModel.value);
|
||||
});
|
||||
function isActionDisabled(action) {
|
||||
if (typeof props.disabled === 'boolean') {
|
||||
return props.disabled;
|
||||
}
|
||||
if (Array.isArray(props.disabled)) {
|
||||
return props.disabled.includes(action);
|
||||
}
|
||||
return isPristine.value;
|
||||
}
|
||||
const isSaveDisabled = computed(() => isActionDisabled('save'));
|
||||
const isCancelDisabled = computed(() => isActionDisabled('cancel'));
|
||||
function save() {
|
||||
model.value = internalModel.value;
|
||||
emit('save', internalModel.value);
|
||||
}
|
||||
function cancel() {
|
||||
internalModel.value = structuredClone(deepToRaw(model.value));
|
||||
emit('cancel');
|
||||
}
|
||||
function actions(actionsProps) {
|
||||
return _createElementVNode(_Fragment, null, [_createVNode(VBtn, _mergeProps({
|
||||
"disabled": isCancelDisabled.value,
|
||||
"variant": "text",
|
||||
"color": props.color,
|
||||
"onClick": cancel,
|
||||
"text": t(props.cancelText)
|
||||
}, actionsProps), null), _createVNode(VBtn, _mergeProps({
|
||||
"disabled": isSaveDisabled.value,
|
||||
"variant": "text",
|
||||
"color": props.color,
|
||||
"onClick": save,
|
||||
"text": t(props.okText)
|
||||
}, actionsProps), null)]);
|
||||
}
|
||||
let actionsUsed = false;
|
||||
useRender(() => {
|
||||
return _createElementVNode(_Fragment, null, [slots.default?.({
|
||||
model: internalModel,
|
||||
save,
|
||||
cancel,
|
||||
isPristine: isPristine.value,
|
||||
get actions() {
|
||||
actionsUsed = true;
|
||||
return actions;
|
||||
}
|
||||
}), !props.hideActions && !actionsUsed && actions()]);
|
||||
});
|
||||
return {
|
||||
save,
|
||||
cancel,
|
||||
isPristine
|
||||
};
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=VConfirmEdit.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"VConfirmEdit.js","names":["VBtn","useLocale","useProxiedModel","computed","ref","watchEffect","deepEqual","deepToRaw","genericComponent","propsFactory","useRender","makeVConfirmEditProps","modelValue","color","String","cancelText","type","default","okText","disabled","Boolean","Array","undefined","hideActions","VConfirmEdit","name","props","emits","cancel","save","value","setup","_ref","emit","slots","model","internalModel","structuredClone","t","isPristine","isActionDisabled","action","isArray","includes","isSaveDisabled","isCancelDisabled","actions","actionsProps","_createElementVNode","_Fragment","_createVNode","_mergeProps","actionsUsed"],"sources":["../../../src/components/VConfirmEdit/VConfirmEdit.tsx"],"sourcesContent":["// Components\nimport { VBtn } from '@/components/VBtn'\n\n// Composables\nimport { useLocale } from '@/composables/locale'\nimport { useProxiedModel } from '@/composables/proxiedModel'\n\n// Utilities\nimport { computed, ref, watchEffect } from 'vue'\nimport { deepEqual, deepToRaw, genericComponent, propsFactory, useRender } from '@/util'\n\n// Types\nimport type { PropType, Ref, VNode } from 'vue'\nimport type { GenericProps } from '@/util'\n\nexport type VConfirmEditSlots<T> = {\n default: {\n model: Ref<T>\n save: () => void\n cancel: () => void\n isPristine: boolean\n get actions (): (props?: {}) => VNode\n }\n}\n\nexport const makeVConfirmEditProps = propsFactory({\n modelValue: null,\n color: String,\n cancelText: {\n type: String,\n default: '$vuetify.confirmEdit.cancel',\n },\n okText: {\n type: String,\n default: '$vuetify.confirmEdit.ok',\n },\n disabled: {\n type: [Boolean, Array] as PropType<boolean | ('save' | 'cancel')[]>,\n default: undefined,\n },\n hideActions: Boolean,\n}, 'VConfirmEdit')\n\nexport const VConfirmEdit = genericComponent<new <T> (\n props: {\n modelValue?: T\n 'onUpdate:modelValue'?: (value: T) => void\n 'onSave'?: (value: T) => void\n },\n slots: VConfirmEditSlots<T>\n) => GenericProps<typeof props, typeof slots>>()({\n name: 'VConfirmEdit',\n\n props: makeVConfirmEditProps(),\n\n emits: {\n cancel: () => true,\n save: (value: any) => true,\n 'update:modelValue': (value: any) => true,\n },\n\n setup (props, { emit, slots }) {\n const model = useProxiedModel(props, 'modelValue')\n const internalModel = ref()\n watchEffect(() => {\n internalModel.value = structuredClone(deepToRaw(model.value))\n })\n\n const { t } = useLocale()\n\n const isPristine = computed(() => {\n return deepEqual(model.value, internalModel.value)\n })\n\n function isActionDisabled (action: 'save' | 'cancel') {\n if (typeof props.disabled === 'boolean') {\n return props.disabled\n }\n\n if (Array.isArray(props.disabled)) {\n return props.disabled.includes(action)\n }\n\n return isPristine.value\n }\n\n const isSaveDisabled = computed(() => isActionDisabled('save'))\n const isCancelDisabled = computed(() => isActionDisabled('cancel'))\n\n function save () {\n model.value = internalModel.value\n emit('save', internalModel.value)\n }\n\n function cancel () {\n internalModel.value = structuredClone(deepToRaw(model.value))\n emit('cancel')\n }\n\n function actions (actionsProps?: {}) {\n return (\n <>\n <VBtn\n disabled={ isCancelDisabled.value }\n variant=\"text\"\n color={ props.color }\n onClick={ cancel }\n text={ t(props.cancelText) }\n { ...actionsProps }\n />\n\n <VBtn\n disabled={ isSaveDisabled.value }\n variant=\"text\"\n color={ props.color }\n onClick={ save }\n text={ t(props.okText) }\n { ...actionsProps }\n />\n </>\n )\n }\n\n let actionsUsed = false\n useRender(() => {\n return (\n <>\n {\n slots.default?.({\n model: internalModel,\n save,\n cancel,\n isPristine: isPristine.value,\n get actions () {\n actionsUsed = true\n return actions\n },\n })\n }\n\n { !props.hideActions && !actionsUsed && actions() }\n </>\n )\n })\n\n return {\n save,\n cancel,\n isPristine,\n }\n },\n})\n\nexport type VConfirmEdit = InstanceType<typeof VConfirmEdit>\n"],"mappings":";AAAA;AAAA,SACSA,IAAI,4BAEb;AAAA,SACSC,SAAS;AAAA,SACTC,eAAe,6CAExB;AACA,SAASC,QAAQ,EAAEC,GAAG,EAAEC,WAAW,QAAQ,KAAK;AAAA,SACvCC,SAAS,EAAEC,SAAS,EAAEC,gBAAgB,EAAEC,YAAY,EAAEC,SAAS,+BAExE;AAcA,OAAO,MAAMC,qBAAqB,GAAGF,YAAY,CAAC;EAChDG,UAAU,EAAE,IAAI;EAChBC,KAAK,EAAEC,MAAM;EACbC,UAAU,EAAE;IACVC,IAAI,EAAEF,MAAM;IACZG,OAAO,EAAE;EACX,CAAC;EACDC,MAAM,EAAE;IACNF,IAAI,EAAEF,MAAM;IACZG,OAAO,EAAE;EACX,CAAC;EACDE,QAAQ,EAAE;IACLine truncated
|
||||
Generated
Vendored
+87
@@ -0,0 +1,87 @@
|
||||
import { createElementVNode as _createElementVNode, createVNode as _createVNode, Fragment as _Fragment, createTextVNode as _createTextVNode } from "vue";
|
||||
// Components
|
||||
import { VConfirmEdit } from "../index.js"; // Utilities
|
||||
import { render, screen, userEvent } from '@test';
|
||||
import { nextTick, shallowRef } from 'vue';
|
||||
describe('VConfirmEdit', () => {
|
||||
it('mirrors external updates', async () => {
|
||||
const externalModel = shallowRef('foo');
|
||||
render(() => _createVNode(VConfirmEdit, {
|
||||
"modelValue": externalModel.value
|
||||
}, {
|
||||
default: _ref => {
|
||||
let {
|
||||
model
|
||||
} = _ref;
|
||||
return _createElementVNode("p", null, [model.value]);
|
||||
}
|
||||
}));
|
||||
expect(screen.getByText('foo')).toBeVisible();
|
||||
externalModel.value = 'bar';
|
||||
await nextTick();
|
||||
expect(screen.getByText('bar')).toBeVisible();
|
||||
});
|
||||
it("doesn't mutate the original value", async () => {
|
||||
const externalModel = shallowRef(['foo']);
|
||||
render(() => _createVNode(VConfirmEdit, {
|
||||
"modelValue": externalModel.value,
|
||||
"onUpdate:modelValue": $event => externalModel.value = $event
|
||||
}, {
|
||||
default: _ref2 => {
|
||||
let {
|
||||
model
|
||||
} = _ref2;
|
||||
return _createElementVNode(_Fragment, null, [_createElementVNode("p", null, [model.value.join(',')]), _createElementVNode("button", {
|
||||
"data-testid": "push",
|
||||
"onClick": () => model.value.push('bar')
|
||||
}, [_createTextVNode("Push")])]);
|
||||
}
|
||||
}));
|
||||
expect(screen.getByText('foo')).toBeVisible();
|
||||
await userEvent.click(screen.getByTestId('push'));
|
||||
expect(screen.getByText('foo,bar')).toBeVisible();
|
||||
expect(externalModel.value).toEqual(['foo']);
|
||||
await userEvent.click(screen.getByText('OK'));
|
||||
expect(externalModel.value).toEqual(['foo', 'bar']);
|
||||
});
|
||||
describe('hides actions if used from the slot', () => {
|
||||
it('nothing', () => {
|
||||
render(() => _createVNode(VConfirmEdit, null, null));
|
||||
expect(screen.getAllByCSS('button')).toHaveLength(2);
|
||||
});
|
||||
it('consume model', () => {
|
||||
render(() => _createVNode(VConfirmEdit, null, {
|
||||
default: _ref3 => {
|
||||
let {
|
||||
model
|
||||
} = _ref3;
|
||||
void model;
|
||||
}
|
||||
}));
|
||||
expect(screen.getAllByCSS('button')).toHaveLength(2);
|
||||
});
|
||||
it('consume actions', () => {
|
||||
render(() => _createVNode(VConfirmEdit, null, {
|
||||
default: _ref4 => {
|
||||
let {
|
||||
actions
|
||||
} = _ref4;
|
||||
void actions;
|
||||
}
|
||||
}));
|
||||
expect(screen.queryAllByCSS('button')).toHaveLength(0);
|
||||
});
|
||||
it('render actions', () => {
|
||||
render(() => _createVNode(VConfirmEdit, null, {
|
||||
default: _ref5 => {
|
||||
let {
|
||||
actions
|
||||
} = _ref5;
|
||||
return actions();
|
||||
}
|
||||
}));
|
||||
expect(screen.getAllByCSS('button')).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=VConfirmEdit.spec.browser.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"VConfirmEdit.spec.browser.js","names":["VConfirmEdit","render","screen","userEvent","nextTick","shallowRef","describe","it","externalModel","_createVNode","value","default","_ref","model","_createElementVNode","expect","getByText","toBeVisible","$event","_ref2","_Fragment","join","onClick","push","_createTextVNode","click","getByTestId","toEqual","getAllByCSS","toHaveLength","_ref3","_ref4","actions","queryAllByCSS","_ref5"],"sources":["../../../../src/components/VConfirmEdit/__test__/VConfirmEdit.spec.browser.tsx"],"sourcesContent":["// Components\nimport { VConfirmEdit } from '../'\n\n// Utilities\nimport { render, screen, userEvent } from '@test'\nimport { nextTick, shallowRef } from 'vue'\n\ndescribe('VConfirmEdit', () => {\n it('mirrors external updates', async () => {\n const externalModel = shallowRef('foo')\n\n render(() => (\n <VConfirmEdit modelValue={ externalModel.value }>\n { ({ model }) => (\n <p>{ model.value }</p>\n )}\n </VConfirmEdit>\n ))\n\n expect(screen.getByText('foo')).toBeVisible()\n\n externalModel.value = 'bar'\n await nextTick()\n expect(screen.getByText('bar')).toBeVisible()\n })\n\n it(\"doesn't mutate the original value\", async () => {\n const externalModel = shallowRef(['foo'])\n\n render(() => (\n <VConfirmEdit v-model={ externalModel.value } modelValue={ externalModel.value }>\n { ({ model }) => (\n <>\n <p>{ model.value.join(',') }</p>\n <button data-testid=\"push\" onClick={ () => model.value.push('bar') }>Push</button>\n </>\n )}\n </VConfirmEdit>\n ))\n\n expect(screen.getByText('foo')).toBeVisible()\n\n await userEvent.click(screen.getByTestId('push'))\n expect(screen.getByText('foo,bar')).toBeVisible()\n expect(externalModel.value).toEqual(['foo'])\n\n await userEvent.click(screen.getByText('OK'))\n expect(externalModel.value).toEqual(['foo', 'bar'])\n })\n\n describe('hides actions if used from the slot', () => {\n it('nothing', () => {\n render(() => <VConfirmEdit />)\n expect(screen.getAllByCSS('button')).toHaveLength(2)\n })\n\n it('consume model', () => {\n render(() => (\n <VConfirmEdit>\n { ({ model }) => {\n void model\n }}\n </VConfirmEdit>\n ))\n expect(screen.getAllByCSS('button')).toHaveLength(2)\n })\n\n it('consume actions', () => {\n render(() => (\n <VConfirmEdit>\n { ({ actions }) => {\n void actions\n }}\n </VConfirmEdit>\n ))\n expect(screen.queryAllByCSS('button')).toHaveLength(0)\n })\n\n it('render actions', () => {\n render(() => (\n <VConfirmEdit>\n { ({ actions }) => actions() }\n </VConfirmEdit>\n ))\n expect(screen.getAllByCSS('button')).toHaveLength(2)\n })\n })\n})\n"],"mappings":"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 truncated
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export { VConfirmEdit } from './VConfirmEdit.js';
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
export { VConfirmEdit } from "./VConfirmEdit.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["VConfirmEdit"],"sources":["../../../src/components/VConfirmEdit/index.ts"],"sourcesContent":["export { VConfirmEdit } from './VConfirmEdit'\n"],"mappings":"SAASA,YAAY","ignoreList":[]}
|
||||
Reference in new issue
Block a user