@bagelink/vue 0.0.1188 → 0.0.1194
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.
- package/dist/components/form/BagelForm.vue.d.ts +9 -14
- package/dist/components/form/BagelForm.vue.d.ts.map +1 -1
- package/dist/composables/useSchemaField.d.ts +3 -1
- package/dist/composables/useSchemaField.d.ts.map +1 -1
- package/dist/index.cjs +16 -8
- package/dist/index.mjs +16 -8
- package/package.json +5 -4
- package/src/components/form/BagelForm.vue +16 -10
- package/src/components/form/BglMultiStepForm.vue +9 -7
- package/src/components/form/inputs/DateInput.vue +6 -2
- package/src/composables/useSchemaField.ts +2 -2
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { BglFormSchemaFnT } from '../..';
|
|
2
|
-
export interface BagelFormProps<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
modelValue?: T;
|
|
6
|
-
schema?: BglFormSchemaFnT<T>;
|
|
2
|
+
export interface BagelFormProps<_T> {
|
|
3
|
+
modelValue?: _T;
|
|
4
|
+
schema?: BglFormSchemaFnT<_T>;
|
|
7
5
|
tag?: 'form' | 'template';
|
|
6
|
+
onSubmit?: (data: _T) => Promise<void>;
|
|
8
7
|
}
|
|
9
8
|
declare const _default: <T extends {
|
|
10
9
|
[key: string]: any;
|
|
11
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<{
|
|
12
11
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
13
|
-
readonly onSubmit?: ((value: T) => any) | undefined;
|
|
14
12
|
readonly "onUpdate:modelValue"?: ((value: T) => any) | undefined;
|
|
15
|
-
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "
|
|
13
|
+
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:modelValue"> & BagelFormProps<T> & Partial<{}>> & import('vue').PublicProps;
|
|
16
14
|
expose(exposed: import('vue').ShallowUnwrapRef<{
|
|
17
15
|
form: import('vue').Ref<HTMLFormElement | undefined, HTMLFormElement | undefined>;
|
|
18
16
|
isDirty: import('@vue-macros/reactivity-transform/macros.js').ComputedVariable<false> | import('@vue-macros/reactivity-transform/macros.js').ComputedVariable<true>;
|
|
@@ -21,18 +19,15 @@ declare const _default: <T extends {
|
|
|
21
19
|
attrs: any;
|
|
22
20
|
slots: {
|
|
23
21
|
default?(_: {}): any;
|
|
24
|
-
success?(_: {}): any;
|
|
25
|
-
error?(_: {}): any;
|
|
26
22
|
submit?(_: {
|
|
27
|
-
submit: () => void
|
|
23
|
+
submit: () => Promise<void>;
|
|
28
24
|
isDirty: import('@vue-macros/reactivity-transform/macros.js').ComputedVariable<false> | import('@vue-macros/reactivity-transform/macros.js').ComputedVariable<true>;
|
|
29
25
|
validateForm: () => boolean;
|
|
30
26
|
}): any;
|
|
27
|
+
success?(_: {}): any;
|
|
28
|
+
error?(_: {}): any;
|
|
31
29
|
};
|
|
32
|
-
emit:
|
|
33
|
-
(e: "update:modelValue", value: T): void;
|
|
34
|
-
(e: "submit", value: T): void;
|
|
35
|
-
};
|
|
30
|
+
emit: (e: "update:modelValue", value: T) => void;
|
|
36
31
|
}>) => import('vue').VNode & {
|
|
37
32
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
38
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BagelForm.vue.d.ts","sourceRoot":"","sources":["../../../src/components/form/BagelForm.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BagelForm.vue.d.ts","sourceRoot":"","sources":["../../../src/components/form/BagelForm.vue"],"names":[],"mappings":"AAyHA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,eAAe,CAAA;AAK5D,MAAM,WAAW,cAAc,CAAC,EAAE;IACjC,UAAU,CAAC,EAAE,EAAE,CAAA;IACf,MAAM,CAAC,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAA;IAC7B,GAAG,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IACzB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACtC;yBAEgB,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;WAmM1D,mBAAmB,CAAC;;6KAAkE,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB;;;;MAAsB,GAAG,IAAI;WACpE,GAAG;;yBAxCkB,GAAG;;;;;YACJ,GAAG;yBACF,GAAG;uBACL,GAAG;;cAtJzB,mBAAmB,SAAS,CAAC,KAAG,IAAI;OAgM7B,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AA7MzE,wBA6M4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
|
|
@@ -5,7 +5,9 @@ export interface UseSchemaFieldOptions<T> {
|
|
|
5
5
|
getRowData?: () => T;
|
|
6
6
|
onUpdate?: (field: BaseBagelField<T>, value: any) => void;
|
|
7
7
|
}
|
|
8
|
-
export declare function useSchemaField<T extends
|
|
8
|
+
export declare function useSchemaField<T extends {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}>(options: UseSchemaFieldOptions<T>): {
|
|
9
11
|
renderField: (field: BaseBagelField<T>, slots?: Record<string, (props: {
|
|
10
12
|
row: T;
|
|
11
13
|
field: BaseBagelField<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSchemaField.d.ts","sourceRoot":"","sources":["../../src/composables/useSchemaField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAwBxD,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACvC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAA;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAA;IACpB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;CACzD;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"useSchemaField.d.ts","sourceRoot":"","sources":["../../src/composables/useSchemaField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAwBxD,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACvC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAA;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAA;IACpB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;CACzD;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC;yBA4BzF,cAAc,CAAC,CAAC,CAAC,UAChB,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;QAAE,GAAG,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAA;KAAE,KAAK,GAAG,CAAC,KAC1E,KAAK,GAAG,IAAI;0BA3Bc,cAAc,CAAC,CAAC,CAAC;EAkK9C"}
|
package/dist/index.cjs
CHANGED
|
@@ -11579,9 +11579,10 @@ const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
|
|
|
11579
11579
|
props: {
|
|
11580
11580
|
modelValue: { default: void 0 },
|
|
11581
11581
|
schema: { default: void 0 },
|
|
11582
|
-
tag: { default: "form" }
|
|
11582
|
+
tag: { default: "form" },
|
|
11583
|
+
onSubmit: {}
|
|
11583
11584
|
},
|
|
11584
|
-
emits: ["update:modelValue"
|
|
11585
|
+
emits: ["update:modelValue"],
|
|
11585
11586
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
11586
11587
|
const props2 = __props;
|
|
11587
11588
|
const emit2 = __emit;
|
|
@@ -11593,6 +11594,7 @@ const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
|
|
|
11593
11594
|
initialFormData.value = JSON.parse(JSON.stringify(props2.modelValue));
|
|
11594
11595
|
}
|
|
11595
11596
|
});
|
|
11597
|
+
const formState = vue.ref("idle");
|
|
11596
11598
|
vue.watch(() => props2.modelValue, (newValue) => {
|
|
11597
11599
|
if (newValue !== void 0) {
|
|
11598
11600
|
formData.value = JSON.parse(JSON.stringify(newValue));
|
|
@@ -11614,9 +11616,15 @@ const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
|
|
|
11614
11616
|
};
|
|
11615
11617
|
emit2("update:modelValue", formData.value);
|
|
11616
11618
|
}
|
|
11617
|
-
function handleSubmit() {
|
|
11618
|
-
|
|
11619
|
-
|
|
11619
|
+
async function handleSubmit() {
|
|
11620
|
+
var _a2;
|
|
11621
|
+
try {
|
|
11622
|
+
await ((_a2 = props2.onSubmit) == null ? void 0 : _a2.call(props2, formData.value));
|
|
11623
|
+
initialFormData.value = structuredClone(formData.value);
|
|
11624
|
+
formState.value = "success";
|
|
11625
|
+
} catch (error) {
|
|
11626
|
+
formState.value = "error";
|
|
11627
|
+
}
|
|
11620
11628
|
}
|
|
11621
11629
|
function shouldRenderField(field) {
|
|
11622
11630
|
const condition = field.vIf ?? field["v-if"];
|
|
@@ -11654,13 +11662,13 @@ const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
|
|
|
11654
11662
|
key: field.id
|
|
11655
11663
|
});
|
|
11656
11664
|
}), 128)) : vue.renderSlot(_ctx.$slots, "default", { key: 1 }),
|
|
11657
|
-
vue.renderSlot(_ctx.$slots, "success"),
|
|
11658
|
-
vue.renderSlot(_ctx.$slots, "error"),
|
|
11659
11665
|
vue.renderSlot(_ctx.$slots, "submit", {
|
|
11660
11666
|
submit: handleSubmit,
|
|
11661
11667
|
isDirty: isDirty.value,
|
|
11662
11668
|
validateForm
|
|
11663
|
-
})
|
|
11669
|
+
}),
|
|
11670
|
+
formState.value === "success" ? vue.renderSlot(_ctx.$slots, "success", { key: 2 }) : vue.createCommentVNode("", true),
|
|
11671
|
+
formState.value === "error" ? vue.renderSlot(_ctx.$slots, "error", { key: 3 }) : vue.createCommentVNode("", true)
|
|
11664
11672
|
], 544)) : (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 1 }, vue.renderList(resolvedSchema.value, (field) => {
|
|
11665
11673
|
return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(renderSchemaField(field)), {
|
|
11666
11674
|
key: field.id
|
package/dist/index.mjs
CHANGED
|
@@ -11577,9 +11577,10 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
|
|
|
11577
11577
|
props: {
|
|
11578
11578
|
modelValue: { default: void 0 },
|
|
11579
11579
|
schema: { default: void 0 },
|
|
11580
|
-
tag: { default: "form" }
|
|
11580
|
+
tag: { default: "form" },
|
|
11581
|
+
onSubmit: {}
|
|
11581
11582
|
},
|
|
11582
|
-
emits: ["update:modelValue"
|
|
11583
|
+
emits: ["update:modelValue"],
|
|
11583
11584
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
11584
11585
|
const props2 = __props;
|
|
11585
11586
|
const emit2 = __emit;
|
|
@@ -11591,6 +11592,7 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
|
|
|
11591
11592
|
initialFormData.value = JSON.parse(JSON.stringify(props2.modelValue));
|
|
11592
11593
|
}
|
|
11593
11594
|
});
|
|
11595
|
+
const formState = ref("idle");
|
|
11594
11596
|
watch(() => props2.modelValue, (newValue) => {
|
|
11595
11597
|
if (newValue !== void 0) {
|
|
11596
11598
|
formData.value = JSON.parse(JSON.stringify(newValue));
|
|
@@ -11612,9 +11614,15 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
|
|
|
11612
11614
|
};
|
|
11613
11615
|
emit2("update:modelValue", formData.value);
|
|
11614
11616
|
}
|
|
11615
|
-
function handleSubmit() {
|
|
11616
|
-
|
|
11617
|
-
|
|
11617
|
+
async function handleSubmit() {
|
|
11618
|
+
var _a2;
|
|
11619
|
+
try {
|
|
11620
|
+
await ((_a2 = props2.onSubmit) == null ? void 0 : _a2.call(props2, formData.value));
|
|
11621
|
+
initialFormData.value = structuredClone(formData.value);
|
|
11622
|
+
formState.value = "success";
|
|
11623
|
+
} catch (error) {
|
|
11624
|
+
formState.value = "error";
|
|
11625
|
+
}
|
|
11618
11626
|
}
|
|
11619
11627
|
function shouldRenderField(field) {
|
|
11620
11628
|
const condition = field.vIf ?? field["v-if"];
|
|
@@ -11652,13 +11660,13 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
|
|
|
11652
11660
|
key: field.id
|
|
11653
11661
|
});
|
|
11654
11662
|
}), 128)) : renderSlot(_ctx.$slots, "default", { key: 1 }),
|
|
11655
|
-
renderSlot(_ctx.$slots, "success"),
|
|
11656
|
-
renderSlot(_ctx.$slots, "error"),
|
|
11657
11663
|
renderSlot(_ctx.$slots, "submit", {
|
|
11658
11664
|
submit: handleSubmit,
|
|
11659
11665
|
isDirty: isDirty.value,
|
|
11660
11666
|
validateForm
|
|
11661
|
-
})
|
|
11667
|
+
}),
|
|
11668
|
+
formState.value === "success" ? renderSlot(_ctx.$slots, "success", { key: 2 }) : createCommentVNode("", true),
|
|
11669
|
+
formState.value === "error" ? renderSlot(_ctx.$slots, "error", { key: 3 }) : createCommentVNode("", true)
|
|
11662
11670
|
], 544)) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(resolvedSchema.value, (field) => {
|
|
11663
11671
|
return openBlock(), createBlock(resolveDynamicComponent(renderSchemaField(field)), {
|
|
11664
11672
|
key: field.id
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bagelink/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.1194",
|
|
5
5
|
"description": "Bagel core sdk packages",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Neveh Allon",
|
|
@@ -55,15 +55,16 @@
|
|
|
55
55
|
"@types/leaflet": "^1.9.16",
|
|
56
56
|
"@types/signature_pad": "^2.3.6",
|
|
57
57
|
"@vue-macros/reactivity-transform": "^1.1.6",
|
|
58
|
-
"vue": "^3.5.13"
|
|
58
|
+
"vue": "^3.5.13",
|
|
59
|
+
"vue-component-type-helpers": "^2.2.0"
|
|
59
60
|
},
|
|
60
61
|
"peerDependencies": {
|
|
61
62
|
"@bagelink/sdk": "*",
|
|
63
|
+
"@vuepic/vue-datepicker": "^8.8.1",
|
|
62
64
|
"vue": "*",
|
|
63
65
|
"vue-draggable-next": "^2.2.1",
|
|
64
66
|
"vue-router": "*",
|
|
65
|
-
"vue3-charts": "^1.1.33"
|
|
66
|
-
"@vuepic/vue-datepicker": "^8.8.1"
|
|
67
|
+
"vue3-charts": "^1.1.33"
|
|
67
68
|
},
|
|
68
69
|
"peerDependenciesMeta": {
|
|
69
70
|
"@vuepic/vue-datepicker": {
|
|
@@ -4,10 +4,11 @@ import type { VNode } from 'vue'
|
|
|
4
4
|
import { onMounted, watch, ref } from 'vue'
|
|
5
5
|
import { useSchemaField } from '../../composables/useSchemaField'
|
|
6
6
|
|
|
7
|
-
export interface BagelFormProps<
|
|
8
|
-
modelValue?:
|
|
9
|
-
schema?: BglFormSchemaFnT<
|
|
7
|
+
export interface BagelFormProps<_T> {
|
|
8
|
+
modelValue?: _T
|
|
9
|
+
schema?: BglFormSchemaFnT<_T>
|
|
10
10
|
tag?: 'form' | 'template'
|
|
11
|
+
onSubmit?: (data: _T) => Promise<void>
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const props = withDefaults(defineProps<BagelFormProps<T>>(), {
|
|
@@ -18,7 +19,6 @@ const props = withDefaults(defineProps<BagelFormProps<T>>(), {
|
|
|
18
19
|
|
|
19
20
|
const emit = defineEmits<{
|
|
20
21
|
(e: 'update:modelValue', value: T): void
|
|
21
|
-
(e: 'submit', value: T): void
|
|
22
22
|
}>()
|
|
23
23
|
|
|
24
24
|
const form = ref<HTMLFormElement>()
|
|
@@ -31,7 +31,8 @@ onMounted(() => {
|
|
|
31
31
|
}
|
|
32
32
|
})
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
const formState = ref<'success' | 'error' | 'idle'>('idle')
|
|
35
|
+
|
|
35
36
|
watch(() => props.modelValue, (newValue) => {
|
|
36
37
|
if (newValue !== undefined) {
|
|
37
38
|
formData.value = JSON.parse(JSON.stringify(newValue))
|
|
@@ -57,9 +58,14 @@ function updateFormData(fieldId: string, value: any) {
|
|
|
57
58
|
emit('update:modelValue', formData.value)
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
function handleSubmit() {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
async function handleSubmit() {
|
|
62
|
+
try {
|
|
63
|
+
await props.onSubmit?.(formData.value)
|
|
64
|
+
initialFormData.value = structuredClone(formData.value)
|
|
65
|
+
formState.value = 'success'
|
|
66
|
+
} catch (error) {
|
|
67
|
+
formState.value = 'error'
|
|
68
|
+
}
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
function shouldRenderField(field: Field): boolean {
|
|
@@ -101,9 +107,9 @@ defineExpose({ form, isDirty, validateForm })
|
|
|
101
107
|
</template>
|
|
102
108
|
</template>
|
|
103
109
|
<slot v-else />
|
|
104
|
-
<slot name="success" />
|
|
105
|
-
<slot name="error" />
|
|
106
110
|
<slot name="submit" :submit="handleSubmit" :isDirty="isDirty" :validateForm="validateForm" />
|
|
111
|
+
<slot v-if="formState === 'success'" name="success" />
|
|
112
|
+
<slot v-if="formState === 'error'" name="error" />
|
|
107
113
|
</form>
|
|
108
114
|
<template v-else>
|
|
109
115
|
<template v-for="field in (resolvedSchema as Field[])" :key="field.id">
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<script setup lang="ts" generic="T extends
|
|
1
|
+
<script setup lang="ts" generic="T extends {[key:string]:any}">
|
|
2
2
|
import type { BglFormSchemaFnT } from '@bagelink/vue'
|
|
3
|
+
|
|
4
|
+
import type { ComponentExposed, ComponentProps } from 'vue-component-type-helpers'
|
|
3
5
|
import { BagelForm, Btn, useBglSchema } from '@bagelink/vue'
|
|
4
6
|
import { watch } from 'vue'
|
|
5
7
|
|
|
6
|
-
type BagelFormT = InstanceType<typeof BagelForm>
|
|
7
|
-
|
|
8
8
|
const props = withDefaults(
|
|
9
9
|
defineProps<{
|
|
10
10
|
bagelFormProps?: Omit<
|
|
11
|
-
|
|
11
|
+
ComponentProps<typeof BagelForm<T>>,
|
|
12
12
|
(
|
|
13
13
|
'schema' | `${string}modelValue` | `ref${string}` | `onVnode${string}` | 'onSubmit'
|
|
14
14
|
)
|
|
@@ -22,7 +22,9 @@ const props = withDefaults(
|
|
|
22
22
|
|
|
23
23
|
const emits = defineEmits(['submit'])
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
type BagelFormT = ComponentExposed<typeof BagelForm<T>>
|
|
26
|
+
|
|
27
|
+
const formRef = $ref<BagelFormT>()
|
|
26
28
|
|
|
27
29
|
const formData = defineModel<T>(
|
|
28
30
|
'modelValue',
|
|
@@ -72,9 +74,9 @@ function handleSubmit() {
|
|
|
72
74
|
defineExpose({
|
|
73
75
|
submit: handleSubmit,
|
|
74
76
|
validateForm: formRef?.validateForm,
|
|
75
|
-
deleteItem: formRef?.deleteItem,
|
|
77
|
+
// deleteItem: formRef?.deleteItem, // ! TODO: if (does not exist) remove!()
|
|
76
78
|
isDirty: formRef?.isDirty,
|
|
77
|
-
clearForm: formRef?.clearForm,
|
|
79
|
+
// clearForm: formRef?.clearForm, // ! TODO: if (does not exist) remove!()
|
|
78
80
|
})
|
|
79
81
|
</script>
|
|
80
82
|
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { VueDatePickerProps } from '@vuepic/vue-datepicker'
|
|
3
|
+
import type { ComponentExposed } from 'vue-component-type-helpers'
|
|
3
4
|
import VDatepicker from '@vuepic/vue-datepicker'
|
|
4
5
|
import { onMounted } from 'vue'
|
|
6
|
+
|
|
5
7
|
import '@vuepic/vue-datepicker/dist/main.css'
|
|
6
8
|
|
|
9
|
+
export type DatePickerInstance = ComponentExposed<typeof VDatepicker>
|
|
10
|
+
|
|
7
11
|
const props = withDefaults(
|
|
8
12
|
defineProps<{
|
|
9
13
|
required?: boolean
|
|
@@ -13,7 +17,7 @@ const props = withDefaults(
|
|
|
13
17
|
enableTime?: boolean
|
|
14
18
|
modelValue?: string | Date
|
|
15
19
|
defaultValue?: string | Date
|
|
16
|
-
extraProps?: VueDatePickerProps
|
|
20
|
+
extraProps?: Omit<VueDatePickerProps, 'Slots' | 'InternalTime'>
|
|
17
21
|
allowedDates?: string[] | Date[]
|
|
18
22
|
timePickerInline?: boolean
|
|
19
23
|
minutesIncrement?: string | number
|
|
@@ -29,7 +29,7 @@ export interface UseSchemaFieldOptions<T> {
|
|
|
29
29
|
onUpdate?: (field: BaseBagelField<T>, value: any) => void
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export function useSchemaField<T extends
|
|
32
|
+
export function useSchemaField<T extends { [key: string]: any }>(options: UseSchemaFieldOptions<T>) {
|
|
33
33
|
const { mode = 'form', getRowData, onUpdate } = options
|
|
34
34
|
|
|
35
35
|
function getComponent(field: BaseBagelField<T>) {
|
|
@@ -92,7 +92,7 @@ export function useSchemaField<T extends Record<string, any>>(options: UseSchema
|
|
|
92
92
|
// Check if this component should receive value as src
|
|
93
93
|
const isSrcValueComponent = typeof Component === 'string' && SRC_VALUE_COMPONENTS.has(Component)
|
|
94
94
|
|
|
95
|
-
const props:
|
|
95
|
+
const props: { [key: string]: any } = {
|
|
96
96
|
...boundFieldProps,
|
|
97
97
|
required,
|
|
98
98
|
label,
|