@bagelink/vue 0.0.1169 → 0.0.1174

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,117 +1,26 @@
1
- import { BglFormSchemaFnT, BtnOptions } from '..';
2
- type __VLS_Props = {
3
- side?: boolean;
4
- title?: string;
5
- width?: string;
6
- dismissable?: boolean;
7
- actions?: BtnOptions[];
8
- schema: BglFormSchemaFnT<any>;
9
- onSubmit?: (formData: any) => Promise<void>;
10
- onDelete?: (id: string) => void;
11
- visible?: boolean;
12
- onError?: (err: any) => void;
13
- modelValue?: {
14
- [key: string]: any;
15
- };
16
- };
17
- declare function setFormValues(values: {
1
+ import { ModalFormOptions } from '../plugins/modalTypes';
2
+ declare const _default: <T extends {
18
3
  [key: string]: any;
19
- }): void;
20
- type __VLS_PublicProps = {
21
- 'modelValue'?: {
22
- [key: string]: any;
23
- };
24
- } & __VLS_Props;
25
- declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {
26
- setFormValues: typeof setFormValues;
27
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
28
- "update:visible": (...args: any[]) => void;
29
- "update:modelValue": (value: {
30
- [key: string]: any;
31
- }) => void;
32
- }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
33
- "onUpdate:modelValue"?: ((value: {
34
- [key: string]: any;
35
- }) => any) | undefined;
36
- "onUpdate:visible"?: ((...args: any[]) => any) | undefined;
37
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
38
- modal: ({
39
- $: import('vue').ComponentInternalInstance;
40
- $data: {};
41
- $props: {
42
- readonly side?: boolean | undefined;
43
- readonly title?: string | undefined;
44
- readonly width?: string | undefined;
45
- readonly dismissable?: boolean | undefined;
46
- readonly actions?: BtnOptions[] | undefined;
47
- readonly visible?: boolean | undefined;
48
- readonly "onUpdate:visible"?: ((...args: any[]) => any) | undefined;
49
- } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps;
50
- $attrs: {
51
- [x: string]: unknown;
52
- };
53
- $refs: {
54
- [x: string]: unknown;
55
- };
56
- $slots: Readonly<{
57
- [name: string]: import('vue').Slot<any> | undefined;
58
- }>;
59
- $root: import('vue').ComponentPublicInstance | null;
60
- $parent: import('vue').ComponentPublicInstance | null;
61
- $host: Element | null;
62
- $emit: (event: "update:visible", ...args: any[]) => void;
63
- $el: HTMLDivElement;
64
- $options: import('vue').ComponentOptionsBase<Readonly<{
65
- side?: boolean;
66
- title?: string;
67
- width?: string;
68
- dismissable?: boolean;
69
- actions?: BtnOptions[];
70
- visible?: boolean;
71
- }> & Readonly<{
72
- "onUpdate:visible"?: ((...args: any[]) => any) | undefined;
73
- }>, {
74
- closeModal: () => void;
75
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
76
- "update:visible": (...args: any[]) => void;
77
- }, string, {}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & {
78
- beforeCreate?: (() => void) | (() => void)[];
79
- created?: (() => void) | (() => void)[];
80
- beforeMount?: (() => void) | (() => void)[];
81
- mounted?: (() => void) | (() => void)[];
82
- beforeUpdate?: (() => void) | (() => void)[];
83
- updated?: (() => void) | (() => void)[];
84
- activated?: (() => void) | (() => void)[];
85
- deactivated?: (() => void) | (() => void)[];
86
- beforeDestroy?: (() => void) | (() => void)[];
87
- beforeUnmount?: (() => void) | (() => void)[];
88
- destroyed?: (() => void) | (() => void)[];
89
- unmounted?: (() => void) | (() => void)[];
90
- renderTracked?: ((e: import('vue').DebuggerEvent) => void) | ((e: import('vue').DebuggerEvent) => void)[];
91
- renderTriggered?: ((e: import('vue').DebuggerEvent) => void) | ((e: import('vue').DebuggerEvent) => void)[];
92
- errorCaptured?: ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void)[];
93
- };
94
- $forceUpdate: () => void;
95
- $nextTick: typeof import('vue').nextTick;
96
- $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import('@vue/reactivity').OnCleanup]) => any : (...args: [any, any, import('@vue/reactivity').OnCleanup]) => any, options?: import('vue').WatchOptions): import('vue').WatchStopHandle;
97
- } & Readonly<{}> & Omit<Readonly<{
98
- side?: boolean;
99
- title?: string;
100
- width?: string;
101
- dismissable?: boolean;
102
- actions?: BtnOptions[];
103
- visible?: boolean;
104
- }> & Readonly<{
105
- "onUpdate:visible"?: ((...args: any[]) => any) | undefined;
106
- }>, "closeModal"> & import('vue').ShallowUnwrapRef<{
107
- closeModal: () => void;
108
- }> & {} & import('vue').ComponentCustomProperties & {} & {
109
- $slots: {
110
- toolbar?(_: {}): any;
111
- default?(_: {}): any;
112
- footer?(_: {}): any;
113
- };
114
- }) | null;
115
- }, HTMLDivElement>;
4
+ }>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
5
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
6
+ readonly "onUpdate:modelValue"?: ((...args: unknown[]) => any) | undefined;
7
+ readonly "onUpdate:visible"?: ((value: boolean) => any) | undefined;
8
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:modelValue" | "onUpdate:visible"> & ({
9
+ modelValue?: T;
10
+ } & ModalFormOptions<T>) & Partial<{}>> & import('vue').PublicProps;
11
+ expose(exposed: import('vue').ShallowUnwrapRef<{
12
+ setFormValues: (values: {
13
+ [key: string]: any;
14
+ }) => void;
15
+ }>): void;
16
+ attrs: any;
17
+ slots: {};
18
+ emit: (((evt: "update:modelValue", value: T) => void) & ((evt: "update:visible", value: boolean) => void)) & ((evt: "update:modelValue", value: T) => void);
19
+ }>) => import('vue').VNode & {
20
+ __ctx?: Awaited<typeof __VLS_setup>;
21
+ };
116
22
  export default _default;
23
+ type __VLS_PrettifyLocal<T> = {
24
+ [K in keyof T]: T[K];
25
+ } & {};
117
26
  //# sourceMappingURL=ModalForm.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModalForm.vue.d.ts","sourceRoot":"","sources":["../../src/components/ModalForm.vue"],"names":[],"mappings":"AAqHA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAa,MAAM,eAAe,CAAA;AAG5E,KAAK,WAAW,GAAG;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;IACtB,MAAM,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAA;IAE7B,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAE3C,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IAE/B,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;IAE5B,UAAU,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;CACnC,CAAC;AAyCF,iBAAS,aAAa,CAAC,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,QAEpD;AASD,KAAK,iBAAiB,GAAG;IACzB,YAAY,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACrC,GAAG,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAuMkpc,GAAG,8CAA8C,GAAG,yBAAyB,GAAG,6DAAmC,GAAG;;;;;;;;;;;;;;;;;;;;AArBxxc,wBAaG"}
1
+ {"version":3,"file":"ModalForm.vue.d.ts","sourceRoot":"","sources":["../../src/components/ModalForm.vue"],"names":[],"mappings":"AAsHA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;yBAG5C,CAAC,SAAS;IAAC,CAAC,GAAG,EAAC,MAAM,GAAE,GAAG,CAAA;CAAC,eAC/B,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;WA0S1D,mBAAmB,CAAC;;;;qBAtOb,CAAC;0CAsO8E,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB;gCAxPhB;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE;MAwPgB,GAAG,IAAI;WACpE,GAAG;;UAEJ,qJAAoC;OAG/B,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AApTzE,wBAoT4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -1,47 +1,40 @@
1
1
  import { BglFormSchemaFnT } from '../..';
2
- interface Props {
3
- modelValue?: Record<string, any>;
4
- schema?: BglFormSchemaFnT;
2
+ export interface BagelFormProps<T extends {
3
+ [key: string]: any;
4
+ }> {
5
+ modelValue?: T;
6
+ schema?: BglFormSchemaFnT<T>;
5
7
  }
6
- declare function handleSubmit(): void;
7
- declare function validateForm(): boolean;
8
- declare function __VLS_template(): {
9
- attrs: Partial<{}>;
8
+ declare const _default: <T extends {
9
+ [key: string]: any;
10
+ }>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
11
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
12
+ readonly onSubmit?: ((value: T) => any) | undefined;
13
+ readonly "onUpdate:modelValue"?: ((value: T) => any) | undefined;
14
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onSubmit" | "onUpdate:modelValue"> & BagelFormProps<T> & Partial<{}>> & import('vue').PublicProps;
15
+ expose(exposed: import('vue').ShallowUnwrapRef<{
16
+ form: import('vue').Ref<HTMLFormElement | undefined, HTMLFormElement | undefined>;
17
+ isDirty: import('@vue-macros/reactivity-transform/macros.js').ComputedVariable<false> | import('@vue-macros/reactivity-transform/macros.js').ComputedVariable<true>;
18
+ validateForm: () => boolean;
19
+ }>): void;
20
+ attrs: any;
10
21
  slots: {
11
22
  default?(_: {}): any;
12
23
  submit?(_: {
13
- submit: typeof handleSubmit;
24
+ submit: () => void;
14
25
  isDirty: import('@vue-macros/reactivity-transform/macros.js').ComputedVariable<false> | import('@vue-macros/reactivity-transform/macros.js').ComputedVariable<true>;
15
- validateForm: typeof validateForm;
26
+ validateForm: () => boolean;
16
27
  }): any;
17
28
  };
18
- refs: {
19
- form: HTMLFormElement;
29
+ emit: {
30
+ (e: "update:modelValue", value: T): void;
31
+ (e: "submit", value: T): void;
20
32
  };
21
- rootEl: HTMLFormElement;
33
+ }>) => import('vue').VNode & {
34
+ __ctx?: Awaited<typeof __VLS_setup>;
22
35
  };
23
- type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
24
- declare const __VLS_component: import('vue').DefineComponent<Props, {
25
- form: import('@vue-macros/reactivity-transform/macros.js').ReactiveVariable<HTMLFormElement> | undefined;
26
- isDirty: import('@vue-macros/reactivity-transform/macros.js').ComputedVariable<false> | import('@vue-macros/reactivity-transform/macros.js').ComputedVariable<true>;
27
- validateForm: typeof validateForm;
28
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
29
- submit: (value: Record<string, any>) => any;
30
- "update:modelValue": (value: Record<string, any>) => any;
31
- }, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
32
- onSubmit?: ((value: Record<string, any>) => any) | undefined;
33
- "onUpdate:modelValue"?: ((value: Record<string, any>) => any) | undefined;
34
- }>, {
35
- schema: BglFormSchemaFnT;
36
- modelValue: Record<string, any>;
37
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
38
- form: HTMLFormElement;
39
- }, HTMLFormElement>;
40
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
41
36
  export default _default;
42
- type __VLS_WithTemplateSlots<T, S> = T & {
43
- new (): {
44
- $slots: S;
45
- };
46
- };
37
+ type __VLS_PrettifyLocal<T> = {
38
+ [K in keyof T]: T[K];
39
+ } & {};
47
40
  //# sourceMappingURL=BagelForm.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BagelForm.vue.d.ts","sourceRoot":"","sources":["../../../src/components/form/BagelForm.vue"],"names":[],"mappings":"AAoGA,OAAO,KAAK,EAAkB,gBAAgB,EAAS,MAAM,eAAe,CAAA;AAK5E,UAAU,KAAK;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAChC,MAAM,CAAC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CAAC,CAAC,QAAQ,CAAC;WAqK1D,mBAAmB,CAAC;;;0LAAkE,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB;;;;MAAsB,GAAG,IAAI;WACpE,GAAG;;yBArCkB,GAAG;;;;;YACJ,GAAG;;;YA1H1B,mBAAmB,SAAS,CAAC,GAAG,IAAI;YACpC,QAAQ,SAAS,CAAC,GAAG,IAAI;;OAkKlB,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AA/KzE,wBA+K4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -76,18 +76,13 @@ export declare function useEditor(): {
76
76
  showModal: (options: import('../../../../..').ModalOptions, slots?: {
77
77
  [key: string]: any;
78
78
  }) => import('../../../../..').ModalComponentProps | undefined;
79
- showModalForm: (options: import('../../../../..').ModalFormOptions, slots?: {
79
+ showModalForm: <T extends {
80
80
  [key: string]: any;
81
- }) => import('../../../../../plugins/modal').ModalFormComponentProps | undefined;
81
+ }>(options: import('../../../../../plugins/modalTypes').ModalFormOptions<T>, slots?: {
82
+ [key: string]: any;
83
+ }) => import('../../../../../plugins/modalTypes').ModalFormComponentProps<T> | undefined;
82
84
  hideModal: (index?: number) => void;
83
- confirmModal: (options: string | {
84
- title: string;
85
- message: string;
86
- confirmText?: string;
87
- cancelText?: string;
88
- confirmBtnColor?: string;
89
- cancelBtnColor?: string;
90
- }) => Promise<boolean>;
85
+ confirmModal: (options: import('../../../../../plugins/modalTypes').ConfirmModalUserOptions) => Promise<boolean>;
91
86
  };
92
87
  };
93
88
  init: (doc: Document) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"useEditor.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/composables/useEditor.ts"],"names":[],"mappings":"AAuBA,wBAAgB,SAAS;;iBAff,MAAM;aACV,QAAQ,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAGX,OAAO;qBACR,OAAO;oBACR,OAAO;iBACV,OAAO;mBACL,MAAM,EAAE;mBACR,MAAM,EAAE;oBACP,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EA6DR,CAAC;;;oFAG4B,CAAC;;;6BAMvB,CAAA;;;;;;;;;;;gBA4GE,QAAQ;kCAmCU,MAAM,UAAU,MAAM;4BAhK5B,MAAM,GAAG,MAAM;;;;;;;8BAwQjB,MAAM,UAAU,MAAM;0CACV,MAAM;;EAkB/C"}
1
+ {"version":3,"file":"useEditor.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/inputs/RichText/composables/useEditor.ts"],"names":[],"mappings":"AAuBA,wBAAgB,SAAS;;iBAff,MAAM;aACV,QAAQ,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAGX,OAAO;qBACR,OAAO;oBACR,OAAO;iBACV,OAAO;mBACL,MAAM,EAAE;mBACR,MAAM,EAAE;oBACP,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EAVf,CAAC;;;;;8FAMA,CAAC;;;6BAIK,CAAC;;;;gBAkLQ,QAAQ;kCAmCU,MAAM,UAAU,MAAM;4BAhK5B,MAAM,GAAG,MAAM;;;;;;;8BAwQjB,MAAM,UAAU,MAAM;0CACV,MAAM;;EAkB/C"}
package/dist/index.cjs CHANGED
@@ -11575,11 +11575,16 @@ const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
11575
11575
  const props2 = __props;
11576
11576
  const emit2 = __emit;
11577
11577
  const form = vue.ref();
11578
- let formData = vue.ref(props2.modelValue ? { ...props2.modelValue } : {});
11579
- let initialFormData = vue.ref(props2.modelValue ? { ...props2.modelValue } : {});
11578
+ const formData = vue.ref(structuredClone(props2.modelValue ?? {}));
11579
+ const initialFormData = vue.ref(structuredClone(props2.modelValue ?? {}));
11580
+ vue.onMounted(() => {
11581
+ if (props2.modelValue) {
11582
+ initialFormData.value = structuredClone(props2.modelValue);
11583
+ }
11584
+ });
11580
11585
  vue.watch(() => props2.modelValue, (newValue) => {
11581
11586
  if (newValue !== void 0) {
11582
- formData.value = { ...newValue };
11587
+ formData.value = structuredClone(newValue);
11583
11588
  }
11584
11589
  }, { immediate: true, deep: true });
11585
11590
  const resolvedSchema = vue.computed(() => {
@@ -11600,7 +11605,7 @@ const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
11600
11605
  }
11601
11606
  function handleSubmit() {
11602
11607
  emit2("submit", formData.value);
11603
- initialFormData.value = { ...formData.value };
11608
+ initialFormData.value = structuredClone(formData.value);
11604
11609
  }
11605
11610
  function shouldRenderField(field) {
11606
11611
  const condition = field.vIf ?? field["v-if"];
@@ -11625,7 +11630,7 @@ const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
11625
11630
  if (!shouldRenderField(field)) return null;
11626
11631
  return renderField(field);
11627
11632
  }
11628
- __expose({ form: form.value, isDirty: isDirty.value, validateForm });
11633
+ __expose({ form, isDirty: isDirty.value, validateForm });
11629
11634
  return (_ctx, _cache) => {
11630
11635
  return vue.openBlock(), vue.createElementBlock("form", {
11631
11636
  ref_key: "form",
@@ -38185,38 +38190,36 @@ const _hoisted_2$4 = { class: "flex gap-05" };
38185
38190
  const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
38186
38191
  __name: "ModalForm",
38187
38192
  props: /* @__PURE__ */ vue.mergeModels({
38188
- side: { type: Boolean },
38189
- title: {},
38190
- width: {},
38191
- dismissable: { type: Boolean },
38192
- actions: {},
38193
38193
  schema: {},
38194
+ modelValue: {},
38195
+ "onUpdate:modelValue": { type: Function },
38194
38196
  onSubmit: { type: Function },
38197
+ onDelete: { type: Function },
38195
38198
  onDuplicate: { type: Function },
38196
38199
  submitText: {},
38197
38200
  cancelText: {},
38198
38201
  deleteText: {},
38199
38202
  duplicateText: {},
38200
- onDelete: { type: Function },
38201
- visible: { type: Boolean },
38202
38203
  onError: { type: Function },
38203
- modelValue: {}
38204
+ side: { type: Boolean },
38205
+ title: {},
38206
+ width: {},
38207
+ dismissable: { type: Boolean },
38208
+ visible: { type: Boolean },
38209
+ actions: {},
38210
+ class: {}
38204
38211
  }, {
38205
38212
  "modelValue": {
38206
38213
  default: {}
38207
38214
  },
38208
38215
  "modelModifiers": {}
38209
38216
  }),
38210
- emits: /* @__PURE__ */ vue.mergeModels(["update:visible"], ["update:modelValue"]),
38217
+ emits: /* @__PURE__ */ vue.mergeModels(["update:modelValue", "update:visible"], ["update:modelValue"]),
38211
38218
  setup(__props, { expose: __expose, emit: __emit }) {
38212
38219
  const props2 = __props;
38213
38220
  const emit2 = __emit;
38214
38221
  const bagel = useBagel();
38215
38222
  const modal = vue.ref();
38216
- const computedFormSchema = vue.computed(() => {
38217
- if (typeof props2.schema === "function") return props2.schema();
38218
- return props2.schema;
38219
- });
38220
38223
  const formData = vue.useModel(__props, "modelValue");
38221
38224
  const form = vue.ref();
38222
38225
  const closeModal = () => {
@@ -38256,7 +38259,7 @@ const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
38256
38259
  visible: _ctx.visible,
38257
38260
  dismissable: _ctx.dismissable,
38258
38261
  title: _ctx.title,
38259
- "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => emit2("update:visible", $event))
38262
+ "onUpdate:visible": _cache[3] || (_cache[3] = ($event) => emit2("update:visible", $event))
38260
38263
  }, vue.createSlots({
38261
38264
  default: vue.withCtx(() => [
38262
38265
  _ctx.visible ? (vue.openBlock(), vue.createBlock(vue.unref(_sfc_main$R), {
@@ -38264,8 +38267,11 @@ const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
38264
38267
  ref_key: "form",
38265
38268
  ref: form,
38266
38269
  modelValue: formData.value,
38267
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => formData.value = $event),
38268
- schema: computedFormSchema.value,
38270
+ "onUpdate:modelValue": [
38271
+ _cache[0] || (_cache[0] = ($event) => formData.value = $event),
38272
+ _cache[1] || (_cache[1] = ($event) => emit2("update:modelValue", $event))
38273
+ ],
38274
+ schema: _ctx.schema,
38269
38275
  onSubmit: runSubmit
38270
38276
  }, null, 8, ["modelValue", "schema"])) : vue.createCommentVNode("", true)
38271
38277
  ]),
@@ -38299,8 +38305,11 @@ const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
38299
38305
  icon: "copy_all",
38300
38306
  flat: "",
38301
38307
  value: _ctx.duplicateText || "Duplicate",
38302
- onClick: _ctx.onDuplicate
38303
- }, null, 8, ["value", "onClick"])) : vue.createCommentVNode("", true),
38308
+ onClick: _cache[2] || (_cache[2] = ($event) => {
38309
+ var _a2;
38310
+ return (_a2 = _ctx.onDuplicate) == null ? void 0 : _a2.call(_ctx, formData.value);
38311
+ })
38312
+ }, null, 8, ["value"])) : vue.createCommentVNode("", true),
38304
38313
  _ctx.onSubmit ? (vue.openBlock(), vue.createBlock(vue.unref(Btn), {
38305
38314
  key: 1,
38306
38315
  value: _ctx.submitText || "Submit",
@@ -38314,7 +38323,7 @@ const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
38314
38323
  };
38315
38324
  }
38316
38325
  });
38317
- const ModalForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-7a736620"]]);
38326
+ const ModalForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-1c0f6894"]]);
38318
38327
  const _hoisted_1$5 = { class: "full-nav" };
38319
38328
  const _hoisted_2$3 = { class: "nav-scroll" };
38320
38329
  const _hoisted_3$2 = { class: "nav-links-wrapper" };
package/dist/index.mjs CHANGED
@@ -11573,11 +11573,16 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
11573
11573
  const props2 = __props;
11574
11574
  const emit2 = __emit;
11575
11575
  const form = ref();
11576
- let formData = ref(props2.modelValue ? { ...props2.modelValue } : {});
11577
- let initialFormData = ref(props2.modelValue ? { ...props2.modelValue } : {});
11576
+ const formData = ref(structuredClone(props2.modelValue ?? {}));
11577
+ const initialFormData = ref(structuredClone(props2.modelValue ?? {}));
11578
+ onMounted(() => {
11579
+ if (props2.modelValue) {
11580
+ initialFormData.value = structuredClone(props2.modelValue);
11581
+ }
11582
+ });
11578
11583
  watch(() => props2.modelValue, (newValue) => {
11579
11584
  if (newValue !== void 0) {
11580
- formData.value = { ...newValue };
11585
+ formData.value = structuredClone(newValue);
11581
11586
  }
11582
11587
  }, { immediate: true, deep: true });
11583
11588
  const resolvedSchema = computed(() => {
@@ -11598,7 +11603,7 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
11598
11603
  }
11599
11604
  function handleSubmit() {
11600
11605
  emit2("submit", formData.value);
11601
- initialFormData.value = { ...formData.value };
11606
+ initialFormData.value = structuredClone(formData.value);
11602
11607
  }
11603
11608
  function shouldRenderField(field) {
11604
11609
  const condition = field.vIf ?? field["v-if"];
@@ -11623,7 +11628,7 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
11623
11628
  if (!shouldRenderField(field)) return null;
11624
11629
  return renderField(field);
11625
11630
  }
11626
- __expose({ form: form.value, isDirty: isDirty.value, validateForm });
11631
+ __expose({ form, isDirty: isDirty.value, validateForm });
11627
11632
  return (_ctx, _cache) => {
11628
11633
  return openBlock(), createElementBlock("form", {
11629
11634
  ref_key: "form",
@@ -38183,38 +38188,36 @@ const _hoisted_2$4 = { class: "flex gap-05" };
38183
38188
  const _sfc_main$9 = /* @__PURE__ */ defineComponent({
38184
38189
  __name: "ModalForm",
38185
38190
  props: /* @__PURE__ */ mergeModels({
38186
- side: { type: Boolean },
38187
- title: {},
38188
- width: {},
38189
- dismissable: { type: Boolean },
38190
- actions: {},
38191
38191
  schema: {},
38192
+ modelValue: {},
38193
+ "onUpdate:modelValue": { type: Function },
38192
38194
  onSubmit: { type: Function },
38195
+ onDelete: { type: Function },
38193
38196
  onDuplicate: { type: Function },
38194
38197
  submitText: {},
38195
38198
  cancelText: {},
38196
38199
  deleteText: {},
38197
38200
  duplicateText: {},
38198
- onDelete: { type: Function },
38199
- visible: { type: Boolean },
38200
38201
  onError: { type: Function },
38201
- modelValue: {}
38202
+ side: { type: Boolean },
38203
+ title: {},
38204
+ width: {},
38205
+ dismissable: { type: Boolean },
38206
+ visible: { type: Boolean },
38207
+ actions: {},
38208
+ class: {}
38202
38209
  }, {
38203
38210
  "modelValue": {
38204
38211
  default: {}
38205
38212
  },
38206
38213
  "modelModifiers": {}
38207
38214
  }),
38208
- emits: /* @__PURE__ */ mergeModels(["update:visible"], ["update:modelValue"]),
38215
+ emits: /* @__PURE__ */ mergeModels(["update:modelValue", "update:visible"], ["update:modelValue"]),
38209
38216
  setup(__props, { expose: __expose, emit: __emit }) {
38210
38217
  const props2 = __props;
38211
38218
  const emit2 = __emit;
38212
38219
  const bagel = useBagel();
38213
38220
  const modal = ref();
38214
- const computedFormSchema = computed(() => {
38215
- if (typeof props2.schema === "function") return props2.schema();
38216
- return props2.schema;
38217
- });
38218
38221
  const formData = useModel(__props, "modelValue");
38219
38222
  const form = ref();
38220
38223
  const closeModal = () => {
@@ -38254,7 +38257,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
38254
38257
  visible: _ctx.visible,
38255
38258
  dismissable: _ctx.dismissable,
38256
38259
  title: _ctx.title,
38257
- "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => emit2("update:visible", $event))
38260
+ "onUpdate:visible": _cache[3] || (_cache[3] = ($event) => emit2("update:visible", $event))
38258
38261
  }, createSlots({
38259
38262
  default: withCtx(() => [
38260
38263
  _ctx.visible ? (openBlock(), createBlock(unref(_sfc_main$R), {
@@ -38262,8 +38265,11 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
38262
38265
  ref_key: "form",
38263
38266
  ref: form,
38264
38267
  modelValue: formData.value,
38265
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => formData.value = $event),
38266
- schema: computedFormSchema.value,
38268
+ "onUpdate:modelValue": [
38269
+ _cache[0] || (_cache[0] = ($event) => formData.value = $event),
38270
+ _cache[1] || (_cache[1] = ($event) => emit2("update:modelValue", $event))
38271
+ ],
38272
+ schema: _ctx.schema,
38267
38273
  onSubmit: runSubmit
38268
38274
  }, null, 8, ["modelValue", "schema"])) : createCommentVNode("", true)
38269
38275
  ]),
@@ -38297,8 +38303,11 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
38297
38303
  icon: "copy_all",
38298
38304
  flat: "",
38299
38305
  value: _ctx.duplicateText || "Duplicate",
38300
- onClick: _ctx.onDuplicate
38301
- }, null, 8, ["value", "onClick"])) : createCommentVNode("", true),
38306
+ onClick: _cache[2] || (_cache[2] = ($event) => {
38307
+ var _a2;
38308
+ return (_a2 = _ctx.onDuplicate) == null ? void 0 : _a2.call(_ctx, formData.value);
38309
+ })
38310
+ }, null, 8, ["value"])) : createCommentVNode("", true),
38302
38311
  _ctx.onSubmit ? (openBlock(), createBlock(unref(Btn), {
38303
38312
  key: 1,
38304
38313
  value: _ctx.submitText || "Submit",
@@ -38312,7 +38321,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
38312
38321
  };
38313
38322
  }
38314
38323
  });
38315
- const ModalForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-7a736620"]]);
38324
+ const ModalForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-1c0f6894"]]);
38316
38325
  const _hoisted_1$5 = { class: "full-nav" };
38317
38326
  const _hoisted_2$3 = { class: "nav-scroll" };
38318
38327
  const _hoisted_3$2 = { class: "nav-links-wrapper" };
@@ -1,72 +1,18 @@
1
- import { BglFormSchemaFnT, BtnOptions, ThemeType } from '..';
2
1
  import { InjectionKey, Plugin } from 'vue';
3
- export interface ModalOptions {
4
- title?: string;
5
- dismissable?: boolean;
6
- side?: boolean;
7
- width?: string;
8
- actions?: BtnOptions[];
9
- class?: string;
10
- visible?: boolean;
11
- }
12
- export interface ModalFormOptions extends ModalOptions {
13
- 'schema': BglFormSchemaFnT<any>;
14
- 'onSubmit'?: (formData: any) => any;
15
- 'submitText'?: string;
16
- 'cancelText'?: string;
17
- 'deleteText'?: string;
18
- 'duplicateText'?: string;
19
- 'onDelete'?: (formData: any) => Promise<void>;
20
- 'onDuplicate'?: (formData: any) => Promise<void>;
21
- 'onError'?: (err: any) => void;
22
- 'modelValue'?: {
23
- [key: string]: any;
24
- };
25
- 'onUpdate:modelValue'?: (val: any) => void;
26
- }
27
- export interface ModalConfirmOptions {
28
- 'title': string;
29
- 'message': string;
30
- 'confirmText'?: string;
31
- 'confirmBtnColor'?: ThemeType;
32
- 'cancelText'?: string;
33
- 'cancelBtnColor'?: ThemeType;
34
- 'resolve': (val: boolean) => void;
35
- 'onUpdate:visible': () => void;
36
- 'visible': boolean;
37
- }
38
- type ModalType = 'modal' | 'modalForm' | 'confirmModal';
39
- type ConfirmModalUserOptions = string | {
40
- title: string;
41
- message: string;
42
- confirmText?: string;
43
- cancelText?: string;
44
- confirmBtnColor?: string;
45
- cancelBtnColor?: string;
46
- };
47
- export interface ModalComponentProps {
48
- componentSlots: {
49
- [key: string]: any;
50
- };
51
- modalType: ModalType;
52
- modalOptions: ModalOptions | ModalFormOptions | ModalConfirmOptions;
53
- }
54
- export interface ModalFormComponentProps extends ModalComponentProps {
55
- modalType: 'modalForm';
56
- modalOptions: ModalFormOptions;
57
- }
2
+ import { ConfirmModalUserOptions, ModalComponentProps, ModalFormComponentProps, ModalFormOptions, ModalOptions } from './modalTypes';
58
3
  export interface ModalApi {
59
4
  showModal: (options: ModalOptions, slots?: {
60
5
  [key: string]: any;
61
6
  }) => ModalComponentProps | undefined;
62
- showModalForm: (options: ModalFormOptions, slots?: {
7
+ showModalForm: <T extends {
8
+ [key: string]: any;
9
+ }>(options: ModalFormOptions<T>, slots?: {
63
10
  [key: string]: any;
64
- }) => ModalFormComponentProps | undefined;
11
+ }) => ModalFormComponentProps<T> | undefined;
65
12
  hideModal: (index?: number) => void;
66
13
  confirmModal: (options: ConfirmModalUserOptions) => Promise<boolean>;
67
14
  }
68
15
  export declare const ModalSymbol: InjectionKey<ModalApi>;
69
16
  export declare function useModal(): ModalApi;
70
17
  export declare const ModalPlugin: Plugin;
71
- export {};
72
18
  //# sourceMappingURL=modal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../src/plugins/modal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,KAAK,CAAA;AAK/C,MAAM,WAAW,YAAY;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACrD,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAA;IAC/B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,GAAG,CAAA;IACnC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7C,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAChD,SAAS,CAAC,EAAE,CAA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AAA;KAAE,KAAK,uBAAuB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;IACzJ,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,YAAY,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CACpE;AAED,eAAO,MAAM,WAAW,EAAE,YAAY,CAAC,QAAQ,CAAmB,CAAA;AAElE,wBAAgB,QAAQ,IAAI,QAAQ,CAInC;AAED,eAAO,MAAM,WAAW,EAAE,MAsEzB,CAAA"}
@@ -0,0 +1,66 @@
1
+ import { BglFormSchemaFnT, BtnOptions, ThemeType } from '..';
2
+ export interface ModalOptions {
3
+ title?: string;
4
+ dismissable?: boolean;
5
+ side?: boolean;
6
+ width?: string;
7
+ actions?: BtnOptions[];
8
+ class?: string;
9
+ visible?: boolean;
10
+ }
11
+ export interface ModalConfirmOptions {
12
+ 'title': string;
13
+ 'message': string;
14
+ 'confirmText'?: string;
15
+ 'confirmBtnColor'?: ThemeType;
16
+ 'cancelText'?: string;
17
+ 'cancelBtnColor'?: ThemeType;
18
+ 'resolve': (val: boolean) => void;
19
+ 'onUpdate:visible': () => void;
20
+ 'visible': boolean;
21
+ }
22
+ export type ModalType = 'modal' | 'modalForm' | 'confirmModal';
23
+ export type ConfirmModalUserOptions = string | {
24
+ title: string;
25
+ message: string;
26
+ confirmText?: string;
27
+ cancelText?: string;
28
+ confirmBtnColor?: string;
29
+ cancelBtnColor?: string;
30
+ };
31
+ export interface ModalComponentProps {
32
+ componentSlots: {
33
+ [key: string]: any;
34
+ };
35
+ modalType: ModalType;
36
+ modalOptions: ModalOptions | ModalFormOptions | ModalConfirmOptions;
37
+ }
38
+ export interface ModalFormComponentProps<T extends {
39
+ [key: string]: any;
40
+ } = any> extends ModalComponentProps {
41
+ modalType: 'modalForm';
42
+ modalOptions: ModalFormOptions<T>;
43
+ }
44
+ export interface ModalFormOptions<T extends {
45
+ [key: string]: any;
46
+ } = any> {
47
+ 'schema': BglFormSchemaFnT<T>;
48
+ 'modelValue'?: T;
49
+ 'onUpdate:modelValue'?: (val: T) => void;
50
+ 'onSubmit'?: (formData: T) => any;
51
+ 'onDelete'?: (formData: T) => Promise<void>;
52
+ 'onDuplicate'?: (formData: T) => Promise<void>;
53
+ 'submitText'?: string;
54
+ 'cancelText'?: string;
55
+ 'deleteText'?: string;
56
+ 'duplicateText'?: string;
57
+ 'onError'?: (err: any) => void;
58
+ 'side'?: boolean;
59
+ 'title'?: string;
60
+ 'width'?: string;
61
+ 'dismissable'?: boolean;
62
+ 'visible'?: boolean;
63
+ 'actions'?: BtnOptions[];
64
+ 'class'?: string;
65
+ }
66
+ //# sourceMappingURL=modalTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modalTypes.d.ts","sourceRoot":"","sources":["../../src/plugins/modalTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE5E,MAAM,WAAW,YAAY;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iBAAiB,CAAC,EAAE,SAAS,CAAA;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,SAAS,CAAA;IAC5B,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;IACj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,CAAA;IAC3C,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,UAAU,EAAE,CAAA;IACxB,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB"}
package/dist/style.css CHANGED
@@ -3437,11 +3437,11 @@ body:has(.bg-dark.is-active) {
3437
3437
  border-radius: var(--card-border-radius);
3438
3438
  }
3439
3439
 
3440
- .modal-title[data-v-7a736620] {
3440
+ .modal-title[data-v-1c0f6894] {
3441
3441
  margin-top: 0.5rem;
3442
3442
  }
3443
3443
  @media screen and (max-width: 910px) {
3444
- .modal-title[data-v-7a736620] {
3444
+ .modal-title[data-v-1c0f6894] {
3445
3445
  margin-top: 1rem;
3446
3446
  }
3447
3447
  }
@@ -1,5 +1,5 @@
1
1
  import { IconType, MaterialIcons } from '../components/Icon/types';
2
- export type { ModalApi, ModalComponentProps, ModalComponentProps as ModalFormComponentProps, ModalFormOptions, ModalOptions, } from '../plugins/modal';
2
+ export type { ModalComponentProps, ModalComponentProps as ModalFormComponentProps, ModalOptions, } from '../plugins/modalTypes';
3
3
  export type { IconType, MaterialIcons };
4
4
  export * from './BagelForm';
5
5
  export * from './BtnOptions';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index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AAY,GACZ,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAEvE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAA;AAEvC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAEzC,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACxC,YAAY,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAE/D,MAAM,MAAM,GAAG,GAAG;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,QAAQ,CAAA;CACf,GAAG,MAAM,CAAA;AAEV,MAAM,MAAM,SAAS,GACpB,OAAO,GACL,OAAO,GACP,KAAK,GACL,MAAM,GACN,YAAY,GACZ,OAAO,GACP,OAAO,GACP,QAAQ,GACR,SAAS,GACT,MAAM,CAAA;AAET,MAAM,MAAM,MAAM,GACf,MAAM,GACN,MAAM,GACN;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GACtB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAA;AAE5C,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA"}
@@ -29,7 +29,9 @@ interface NumFieldOptions extends InputOptions {
29
29
  center?: boolean;
30
30
  }
31
31
  type RichTextOptions = InputOptions;
32
- export declare function getBaseField<T>(id?: string, labelOrRest?: string | Partial<Field<T>>, rest?: Partial<Field<T>>): Field<T>;
32
+ export declare function getBaseField<T extends {
33
+ [key: string]: any;
34
+ }>(id?: keyof T extends string ? keyof T : string, labelOrRest?: string | Partial<Field<T>>, rest?: Partial<Field<T>>): Field<T>;
33
35
  export declare function richText(id: string, label?: string, options?: RichTextOptions): {
34
36
  $el: string;
35
37
  class: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"BagelFormUtils.d.ts","sourceRoot":"","sources":["../../src/utils/BagelFormUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAIlE,UAAU,YAAY;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,CAAA;CAClD;AAED,KAAK,WAAW,GAAG,YAAY,CAAA;AAE/B,UAAU,gBAAiB,SAAQ,YAAY;IAC9C,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,CAAA;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,UAAU,gBAAiB,SAAQ,YAAY;IAC9C,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,GAAG,CAAA;CAClC;AAED,UAAU,eAAgB,SAAQ,YAAY;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MA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;;;2BA1O9E,GAAG,OAAO,GAAG,KAAK,OAAO;;gBAsOxC,OAAO;aACV,OAAO;mBA7OF,OAAO;sBACJ,MAAM;gBACZ,MAAM;uBACC,MAAM;mBACV,OAAO;mBACP,MAAM;cACX,OAAO,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC;;;EAkPlD"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "0.0.1169",
4
+ "version": "0.0.1174",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Neveh Allon",
@@ -1,42 +1,31 @@
1
- <script lang="ts" setup>
2
- import type { BglFormSchemaFnT, BtnOptions } from '@bagelink/vue'
1
+ <script lang="ts" setup generic="T extends {[key:string]:any}">
2
+ import type { ModalFormOptions } from '../plugins/modalTypes'
3
3
  import { Btn, Modal, useBagel, BagelForm } from '@bagelink/vue'
4
4
 
5
- const props = defineProps<{
6
- side?: boolean
7
- title?: string
8
- width?: string
9
- dismissable?: boolean
10
- actions?: BtnOptions[]
11
- schema: BglFormSchemaFnT<any>
5
+ // eslint-disable-next-line vue/prop-name-casing
6
+ const props = defineProps<ModalFormOptions<T>>()
12
7
 
13
- onSubmit?: (formData: any) => Promise<void>
14
- onDuplicate?: (formData: any) => Promise<void>
15
- submitText?: string
16
- cancelText?: string
17
- deleteText?: string
18
- duplicateText?: string
19
- onDelete?: (formData: any) => void
20
- visible?: boolean
21
- onError?: (err: any) => void
22
- modelValue?: { [key: string]: any }
8
+ const emit = defineEmits<{
9
+ 'update:modelValue': [value: T]
10
+ 'update:visible': [value: boolean]
23
11
  }>()
24
12
 
25
- const emit = defineEmits(['update:visible'])
26
-
27
13
  const bagel = useBagel()
28
14
 
29
15
  const modal = $ref<InstanceType<typeof Modal>>()
30
16
 
31
- const computedFormSchema = $computed(() => {
32
- if (typeof props.schema === 'function') return props.schema()
33
- return props.schema
17
+ const formData = defineModel<T>('modelValue', {
18
+ default: {} as Partial<T>,
34
19
  })
35
20
 
36
- const formData = defineModel<{ [key: string]: any }>('modelValue', {
37
- default: {},
38
- })
39
- const form = $ref<InstanceType<typeof BagelForm>>()
21
+ interface BagelFormInstance<T> {
22
+ validateForm: () => boolean
23
+ deleteItem?: () => void
24
+ isDirty?: boolean
25
+ clearForm?: () => void
26
+ }
27
+
28
+ const form = $ref<BagelFormInstance<T>>()
40
29
  const closeModal = () => modal?.closeModal()
41
30
 
42
31
  let submitting = $ref(false)
@@ -81,7 +70,8 @@ defineExpose({ setFormValues })
81
70
  v-if="visible"
82
71
  ref="form"
83
72
  v-model="formData"
84
- :schema="computedFormSchema"
73
+ :schema="schema"
74
+ @update:modelValue="emit('update:modelValue', $event)"
85
75
  @submit="runSubmit"
86
76
  />
87
77
  <template v-if="onDelete || onSubmit" #footer>
@@ -105,7 +95,7 @@ defineExpose({ setFormValues })
105
95
  icon="copy_all"
106
96
  flat
107
97
  :value="duplicateText || 'Duplicate'"
108
- @click="onDuplicate"
98
+ @click="onDuplicate?.(formData)"
109
99
  />
110
100
  <Btn v-if="onSubmit" :value="submitText || 'Submit'" @click="runSubmit" />
111
101
  </div>
@@ -1,79 +1,85 @@
1
- <script setup lang="ts">
2
- import type { BglFormSchemaT, BglFormSchemaFnT, Field } from '@bagelink/vue'
1
+ <script setup lang="ts" generic="T extends {[key:string]:any}">
2
+ import type { BglFormSchemaFnT, Field } from '@bagelink/vue'
3
3
  import type { VNode } from 'vue'
4
- import { watch } from 'vue'
4
+ import { onMounted, watch, ref } from 'vue'
5
5
  import { useSchemaField } from '../../composables/useSchemaField'
6
6
 
7
- interface Props {
8
- modelValue?: Record<string, any>
9
- schema?: BglFormSchemaFnT
7
+ export interface BagelFormProps<T extends { [key: string]: any }> {
8
+ modelValue?: T
9
+ schema?: BglFormSchemaFnT<T>
10
10
  }
11
11
 
12
- const props = withDefaults(defineProps<Props>(), {
12
+ const props = withDefaults(defineProps<BagelFormProps<T>>(), {
13
13
  modelValue: undefined,
14
14
  schema: undefined
15
15
  })
16
16
 
17
17
  const emit = defineEmits<{
18
- (e: 'update:modelValue', value: Record<string, any>): void
19
- (e: 'submit', value: Record<string, any>): void
18
+ (e: 'update:modelValue', value: T): void
19
+ (e: 'submit', value: T): void
20
20
  }>()
21
21
 
22
- const form = $ref<HTMLFormElement>()
23
- let formData = $ref(props.modelValue ? { ...props.modelValue } : {})
24
- let initialFormData = $ref(props.modelValue ? { ...props.modelValue } : {})
22
+ const form = ref<HTMLFormElement>()
23
+ const formData = ref<T>(structuredClone(props.modelValue ?? {} as T))
24
+ const initialFormData = ref<T>(structuredClone(props.modelValue ?? {} as T))
25
+
26
+ onMounted(() => {
27
+ if (props.modelValue) {
28
+ initialFormData.value = structuredClone(props.modelValue)
29
+ }
30
+ })
25
31
 
26
32
  // Keep formData in sync with modelValue prop only if it's provided
27
33
  watch(() => props.modelValue, (newValue) => {
28
34
  if (newValue !== undefined) {
29
- formData = { ...newValue }
35
+ formData.value = structuredClone(newValue)
30
36
  }
31
37
  }, { immediate: true, deep: true })
32
38
 
33
- const resolvedSchema = $computed<BglFormSchemaT | undefined>(() => {
39
+ const resolvedSchema = $computed<BglFormSchemaFnT<T> | undefined>(() => {
34
40
  if (!props.schema) return undefined
35
41
  return typeof props.schema === 'function' ? props.schema() : props.schema
36
42
  })
37
43
 
38
44
  const isDirty = $computed(() => {
39
- const current = JSON.stringify(formData)
40
- const initial = JSON.stringify(initialFormData)
45
+ const current = JSON.stringify(formData.value)
46
+ const initial = JSON.stringify(initialFormData.value)
41
47
  return current !== initial
42
48
  })
43
49
 
44
50
  function updateFormData(fieldId: string, value: any) {
45
- formData = {
46
- ...formData,
51
+ formData.value = {
52
+ ...formData.value,
47
53
  [fieldId]: value
48
54
  }
49
- emit('update:modelValue', formData)
55
+ emit('update:modelValue', formData.value)
50
56
  }
51
57
 
52
58
  function handleSubmit() {
53
- emit('submit', formData)
54
- initialFormData = { ...formData }
59
+ emit('submit', formData.value)
60
+ initialFormData.value = structuredClone(formData.value)
55
61
  }
56
62
 
57
63
  function shouldRenderField(field: Field): boolean {
58
64
  const condition = field.vIf ?? field['v-if']
59
65
  if (condition === undefined) return true
60
66
  return typeof condition === 'function'
61
- ? condition(formData[field.id as string], formData)
67
+ ? condition(formData.value[field.id as keyof T], formData.value)
62
68
  : !!condition
63
69
  }
64
70
 
65
71
  function validateForm() {
66
- if (!form) return false
67
- return form.reportValidity()
72
+ if (!form.value) return false
73
+ return form.value.reportValidity()
68
74
  }
69
75
 
70
- const { renderField } = useSchemaField<Record<string, any>>({
76
+ const { renderField } = useSchemaField<T>({
71
77
  mode: 'form',
72
- getRowData: () => formData,
78
+ getRowData: () => formData.value,
73
79
  onUpdate: (field, value) => {
74
80
  if (!field.id) return
75
81
  updateFormData(field.id, value)
76
- field.onUpdate?.(value, formData)
82
+ field.onUpdate?.(value, formData.value)
77
83
  }
78
84
  })
79
85
 
@@ -88,7 +94,7 @@ defineExpose({ form, isDirty, validateForm })
88
94
  <template>
89
95
  <form ref="form" @submit.prevent="handleSubmit">
90
96
  <template v-if="resolvedSchema">
91
- <template v-for="(field) in resolvedSchema" :key="field.id">
97
+ <template v-for="field in (resolvedSchema as Field[])" :key="field.id">
92
98
  <component :is="renderSchemaField(field)" />
93
99
  </template>
94
100
  </template>
@@ -1,62 +1,11 @@
1
- import type { BglFormSchemaFnT, BtnOptions, ThemeType } from '@bagelink/vue'
2
1
  import type { InjectionKey, Plugin } from 'vue'
2
+ import type { ConfirmModalUserOptions, ModalComponentProps, ModalConfirmOptions, ModalFormComponentProps, ModalFormOptions, ModalOptions, ModalType } from './modalTypes'
3
3
  import { Modal, ModalConfirm, ModalForm } from '@bagelink/vue'
4
4
  import { defineComponent, h, inject } from 'vue'
5
5
 
6
- // Interface Definitions
7
- export interface ModalOptions {
8
- title?: string
9
- dismissable?: boolean
10
- side?: boolean
11
- width?: string
12
- actions?: BtnOptions[]
13
- class?: string
14
- visible?: boolean
15
- }
16
-
17
- export interface ModalFormOptions extends ModalOptions {
18
- 'schema': BglFormSchemaFnT<any>
19
- 'onSubmit'?: (formData: any) => any
20
- 'submitText'?: string
21
- 'cancelText'?: string
22
- 'deleteText'?: string
23
- 'duplicateText'?: string
24
- 'onDelete'?: (formData: any) => Promise<void>
25
- 'onDuplicate'?: (formData: any) => Promise<void>
26
- 'onError'?: (err: any) => void
27
- 'modelValue'?: { [key: string]: any }
28
- 'onUpdate:modelValue'?: (val: any) => void
29
- }
30
-
31
- export interface ModalConfirmOptions {
32
- 'title': string
33
- 'message': string
34
- 'confirmText'?: string
35
- 'confirmBtnColor'?: ThemeType
36
- 'cancelText'?: string
37
- 'cancelBtnColor'?: ThemeType
38
- 'resolve': (val: boolean) => void
39
- 'onUpdate:visible': () => void
40
- 'visible': boolean
41
- }
42
-
43
- type ModalType = 'modal' | 'modalForm' | 'confirmModal'
44
- type ConfirmModalUserOptions = string | { title: string, message: string, confirmText?: string, cancelText?: string, confirmBtnColor?: string, cancelBtnColor?: string }
45
-
46
- export interface ModalComponentProps {
47
- componentSlots: { [key: string]: any }
48
- modalType: ModalType
49
- modalOptions: ModalOptions | ModalFormOptions | ModalConfirmOptions
50
- }
51
-
52
- export interface ModalFormComponentProps extends ModalComponentProps {
53
- modalType: 'modalForm'
54
- modalOptions: ModalFormOptions
55
- }
56
-
57
6
  export interface ModalApi {
58
7
  showModal: (options: ModalOptions, slots?: { [key: string]: any }) => ModalComponentProps | undefined
59
- showModalForm: (options: ModalFormOptions, slots?: { [key: string]: any }) => ModalFormComponentProps | undefined
8
+ showModalForm: <T extends { [key: string]: any }>(options: ModalFormOptions<T>, slots?: { [key: string]: any }) => ModalFormComponentProps<T> | undefined
60
9
  hideModal: (index?: number) => void
61
10
  confirmModal: (options: ConfirmModalUserOptions) => Promise<boolean>
62
11
  }
@@ -88,11 +37,11 @@ export const ModalPlugin: Plugin = {
88
37
  })
89
38
  }
90
39
 
91
- const showModal = (
40
+ const showModal = <T extends { [key: string]: any } = any>(
92
41
  modalType: ModalType,
93
- options: ModalOptions | ModalFormOptions,
42
+ options: ModalOptions | ModalFormOptions<T>,
94
43
  slots: { [key: string]: any } = {}
95
- ): ModalComponentProps | ModalFormComponentProps | undefined => {
44
+ ): ModalComponentProps | ModalFormComponentProps<T> | undefined => {
96
45
  const modalComponent = {
97
46
  modalOptions: options,
98
47
  modalType,
@@ -101,7 +50,7 @@ export const ModalPlugin: Plugin = {
101
50
  modalStack.push(modalComponent)
102
51
 
103
52
  if (modalType === 'modalForm') {
104
- return modalComponent as ModalFormComponentProps
53
+ return modalComponent as ModalFormComponentProps<T>
105
54
  }
106
55
  return modalComponent
107
56
  }
@@ -109,7 +58,7 @@ export const ModalPlugin: Plugin = {
109
58
  app.provide(ModalSymbol, {
110
59
  showModal: (options: ModalOptions, slots?: { [key: string]: any }) => showModal('modal', options, slots),
111
60
 
112
- showModalForm: (options: ModalFormOptions, slots?: { [key: string]: any }) => showModal('modalForm', options, slots) as ModalFormComponentProps,
61
+ showModalForm: <T extends { [key: string]: any }>(options: ModalFormOptions<T>, slots?: { [key: string]: any }) => showModal<T>('modalForm', options, slots) as ModalFormComponentProps<T>,
113
62
 
114
63
  confirmModal: (options: ConfirmModalUserOptions) => confirmModal(options),
115
64
 
@@ -137,7 +86,6 @@ export const ModalPlugin: Plugin = {
137
86
  })
138
87
  },
139
88
  })
140
-
141
89
  app.component('ModalContainer', ModalComponent)
142
90
  },
143
91
  }
@@ -0,0 +1,58 @@
1
+ import type { BglFormSchemaFnT, BtnOptions, ThemeType } from '@bagelink/vue'
2
+
3
+ export interface ModalOptions {
4
+ title?: string
5
+ dismissable?: boolean
6
+ side?: boolean
7
+ width?: string
8
+ actions?: BtnOptions[]
9
+ class?: string
10
+ visible?: boolean
11
+ }
12
+
13
+ export interface ModalConfirmOptions {
14
+ 'title': string
15
+ 'message': string
16
+ 'confirmText'?: string
17
+ 'confirmBtnColor'?: ThemeType
18
+ 'cancelText'?: string
19
+ 'cancelBtnColor'?: ThemeType
20
+ 'resolve': (val: boolean) => void
21
+ 'onUpdate:visible': () => void
22
+ 'visible': boolean
23
+ }
24
+
25
+ export type ModalType = 'modal' | 'modalForm' | 'confirmModal'
26
+ export type ConfirmModalUserOptions = string | { title: string, message: string, confirmText?: string, cancelText?: string, confirmBtnColor?: string, cancelBtnColor?: string }
27
+
28
+ export interface ModalComponentProps {
29
+ componentSlots: { [key: string]: any }
30
+ modalType: ModalType
31
+ modalOptions: ModalOptions | ModalFormOptions | ModalConfirmOptions
32
+ }
33
+
34
+ export interface ModalFormComponentProps<T extends { [key: string]: any } = any> extends ModalComponentProps {
35
+ modalType: 'modalForm'
36
+ modalOptions: ModalFormOptions<T>
37
+ }
38
+
39
+ export interface ModalFormOptions<T extends { [key: string]: any } = any> {
40
+ 'schema': BglFormSchemaFnT<T>
41
+ 'modelValue'?: T
42
+ 'onUpdate:modelValue'?: (val: T) => void
43
+ 'onSubmit'?: (formData: T) => any
44
+ 'onDelete'?: (formData: T) => Promise<void>
45
+ 'onDuplicate'?: (formData: T) => Promise<void>
46
+ 'submitText'?: string
47
+ 'cancelText'?: string
48
+ 'deleteText'?: string
49
+ 'duplicateText'?: string
50
+ 'onError'?: (err: any) => void
51
+ 'side'?: boolean
52
+ 'title'?: string
53
+ 'width'?: string
54
+ 'dismissable'?: boolean
55
+ 'visible'?: boolean
56
+ 'actions'?: BtnOptions[]
57
+ 'class'?: string
58
+ }
@@ -1,10 +1,8 @@
1
1
  export type {
2
- ModalApi,
3
2
  ModalComponentProps,
4
3
  ModalComponentProps as ModalFormComponentProps,
5
- ModalFormOptions,
6
4
  ModalOptions,
7
- } from '../plugins/modal'
5
+ } from '../plugins/modalTypes'
8
6
 
9
7
  import type { IconType, MaterialIcons } from '../components/Icon/types'
10
8
 
@@ -38,9 +38,12 @@ interface NumFieldOptions extends InputOptions {
38
38
 
39
39
  type RichTextOptions = InputOptions
40
40
 
41
- export function getBaseField<T>(id?: string, labelOrRest: string | Partial<Field<T>> = {}, rest: Partial<Field<T>> = {}): Field<T> {
41
+ export function getBaseField<T extends { [key: string]: any }>(
42
+ id?: keyof T extends string ? keyof T : string,
43
+ labelOrRest: string | Partial<Field<T>> = {},
44
+ rest: Partial<Field<T>> = {}
45
+ ): Field<T> {
42
46
  if (typeof labelOrRest === 'object') return { id, ...labelOrRest }
43
-
44
47
  return { id, label: labelOrRest, ...rest }
45
48
  }
46
49