@bach.software/vue-dynamic-form 0.2.0 → 0.3.0
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/examples.cjs.js +4 -4
- package/dist/examples.cjs.js.map +1 -1
- package/dist/examples.es.js +325 -265
- package/dist/examples.es.js.map +1 -1
- package/dist/src/components/DynamicFormItem.vue.d.ts +3 -1
- package/dist/src/components/DynamicFormItemArray.vue.d.ts +3 -1
- package/dist/src/components/DynamicFormItemChoice.vue.d.ts +3 -1
- package/dist/src/components/DynamicFormTemplate.vue.d.ts +30 -37
- package/dist/src/core/__tests__/validation.test.d.ts +1 -0
- package/dist/src/core/defineMetadata.d.ts +3 -2
- package/dist/src/core/useDynamicForm.d.ts +2 -0
- package/dist/src/core/useValidatePartialForm.d.ts +4 -0
- package/dist/src/examples/TestForm.vue.d.ts +4 -0
- package/dist/src/examples/TestFormTemplate.vue.d.ts +28 -27
- package/dist/src/examples/{TestFormTemplate.testcases.d.ts → __tests__/TestFormTemplate.testcases.d.ts} +9 -3
- package/dist/src/examples/index.d.ts +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/types/FieldMetadata.d.ts +24 -2
- package/dist/src/types/InternalFieldMetadata.d.ts +7 -1
- package/dist/src/types/MetadataConfiguration.d.ts +1 -0
- package/dist/src/utils/__tests__/createValidation.test.d.ts +1 -0
- package/dist/src/utils/__tests__/mapEachMetadataItem.test.d.ts +16 -0
- package/dist/src/utils/__tests__/splitValidationFunctions.test.d.ts +1 -0
- package/dist/src/utils/hashField.d.ts +7 -0
- package/dist/src/utils/mapEachMetadataItem.d.ts +10 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useDynamicForm-C6-0mGw4.js +737 -0
- package/dist/useDynamicForm-C6-0mGw4.js.map +1 -0
- package/dist/useDynamicForm-SHyV1lLH.cjs +6 -0
- package/dist/useDynamicForm-SHyV1lLH.cjs.map +1 -0
- package/dist/vue-dynamic-form.cjs.js +1 -1
- package/dist/vue-dynamic-form.es.js +6 -6
- package/package.json +1 -1
- package/dist/src/core/validation.test.d.ts +0 -1
- package/dist/src/utils/createValidation.test.d.ts +0 -1
- package/dist/useDynamicForm-3E1RNkVq.cjs +0 -6
- package/dist/useDynamicForm-3E1RNkVq.cjs.map +0 -1
- package/dist/useDynamicForm-B6YN35Qb.js +0 -684
- package/dist/useDynamicForm-B6YN35Qb.js.map +0 -1
- /package/dist/src/components/{DynamicForm.test.d.ts → __tests__/DynamicForm.test.d.ts} +0 -0
- /package/dist/src/components/{DynamicFormItem.analytics.test.d.ts → __tests__/DynamicFormItem.analytics.test.d.ts} +0 -0
- /package/dist/src/components/{DynamicFormItem.logic.test.d.ts → __tests__/DynamicFormItem.logic.test.d.ts} +0 -0
- /package/dist/src/components/{DynamicFormItem.test-helpers.d.ts → __tests__/DynamicFormItem.test-helpers.d.ts} +0 -0
- /package/dist/src/components/{DynamicFormItem.validation.test.d.ts → __tests__/DynamicFormItem.validation.test.d.ts} +0 -0
- /package/dist/src/components/{DynamicFormItemArray.logic.test.d.ts → __tests__/DynamicFormItemArray.logic.test.d.ts} +0 -0
- /package/dist/src/components/{DynamicFormItemArray.validation.test.d.ts → __tests__/DynamicFormItemArray.validation.test.d.ts} +0 -0
- /package/dist/src/components/{DynamicFormItemChoice.logic.test.d.ts → __tests__/DynamicFormItemChoice.logic.test.d.ts} +0 -0
- /package/dist/src/components/{DynamicFormItemChoice.validation.test.d.ts → __tests__/DynamicFormItemChoice.validation.test.d.ts} +0 -0
- /package/dist/src/{examples/DynamicForm.test.d.ts → core/__tests__/useValidatePartialForm.test.d.ts} +0 -0
- /package/dist/src/{test-setup.d.ts → examples/__tests__/DynamicForm.test.d.ts} +0 -0
- /package/dist/src/{utils/checkTreeHasValue.test.d.ts → tests/test-setup.d.ts} +0 -0
- /package/dist/src/utils/{normalizePath.test.d.ts → __tests__/checkTreeHasValue.test.d.ts} +0 -0
- /package/dist/src/utils/{overridePath.test.d.ts → __tests__/normalizePath.test.d.ts} +0 -0
- /package/dist/src/utils/{resolveMessage.test.d.ts → __tests__/overridePath.test.d.ts} +0 -0
- /package/dist/src/utils/{setInPath.test.d.ts → __tests__/resolveMessage.test.d.ts} +0 -0
- /package/dist/src/utils/{splitValidationFunctions.test.d.ts → __tests__/setInPath.test.d.ts} +0 -0
|
@@ -0,0 +1,737 @@
|
|
|
1
|
+
import { computed as u, defineComponent as le, inject as me, ref as J, watch as ae, watchEffect as Ve, createElementBlock as w, openBlock as x, Fragment as W, withDirectives as Fe, createCommentVNode as ie, createBlock as $, unref as Y, createElementVNode as Ie, toDisplayString as Se, isRef as Ue, vShow as Ee, resolveDynamicComponent as se, withCtx as ce, renderList as ue, onMounted as Le, onBeforeUnmount as ke, resolveComponent as Te, mergeProps as ne, createSlots as qe, provide as We, useSlots as ze, useAttrs as Re, renderSlot as fe, normalizeProps as he, getCurrentInstance as He } from "vue";
|
|
2
|
+
import { useFieldArray as Ke, defineRule as I, validate as ye, useValidateField as Je, useField as xe, useSubmitCount as Pe, FormContextKey as Oe, useForm as Xe, useFieldValue as Ge } from "vee-validate";
|
|
3
|
+
function Qe(e) {
|
|
4
|
+
const { fields: r, ...t } = Ke(e), n = u(() => r.value.map(({ value: l }) => l));
|
|
5
|
+
return {
|
|
6
|
+
fields: r,
|
|
7
|
+
values: n,
|
|
8
|
+
...t
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const ve = Symbol("dynamicFormSettings");
|
|
12
|
+
/**
|
|
13
|
+
* vee-validate v4.15.1
|
|
14
|
+
* (c) 2025 Abdelrahman Awad
|
|
15
|
+
* @license MIT
|
|
16
|
+
*/
|
|
17
|
+
function oe(e, r) {
|
|
18
|
+
return Array.isArray(e) ? e[0] : e[r];
|
|
19
|
+
}
|
|
20
|
+
function Z(e) {
|
|
21
|
+
return !!(e == null || e === "" || Array.isArray(e) && e.length === 0);
|
|
22
|
+
}
|
|
23
|
+
const Me = (e, r) => {
|
|
24
|
+
if (Z(e))
|
|
25
|
+
return !0;
|
|
26
|
+
const t = oe(r, "length");
|
|
27
|
+
return Array.isArray(e) ? e.every((n) => Me(n, { length: t })) : [...String(e)].length <= Number(t);
|
|
28
|
+
}, Ne = (e, r) => {
|
|
29
|
+
if (Z(e))
|
|
30
|
+
return !0;
|
|
31
|
+
const t = oe(r, "max");
|
|
32
|
+
return Array.isArray(e) ? e.length > 0 && e.every((n) => Ne(n, { max: t })) : Number(e) <= Number(t);
|
|
33
|
+
}, $e = (e, r) => {
|
|
34
|
+
if (Z(e))
|
|
35
|
+
return !0;
|
|
36
|
+
const t = oe(r, "length");
|
|
37
|
+
return Array.isArray(e) ? e.every((n) => $e(n, { length: t })) : [...String(e)].length >= Number(t);
|
|
38
|
+
}, De = (e, r) => {
|
|
39
|
+
if (Z(e))
|
|
40
|
+
return !0;
|
|
41
|
+
const t = oe(r, "min");
|
|
42
|
+
return Array.isArray(e) ? e.length > 0 && e.every((n) => De(n, { min: t })) : Number(e) >= Number(t);
|
|
43
|
+
}, we = (e, r) => Z(e) ? !0 : Array.isArray(e) ? e.every((t) => we(t, r)) : Array.from(r).some((t) => t == e), Be = (e, r) => {
|
|
44
|
+
if (Z(e))
|
|
45
|
+
return !0;
|
|
46
|
+
let t = oe(r, "regex");
|
|
47
|
+
return typeof t == "string" && (t = new RegExp(t)), Array.isArray(e) ? e.every((n) => Be(n, { regex: t })) : t.test(String(e));
|
|
48
|
+
};
|
|
49
|
+
function Ye(e) {
|
|
50
|
+
return e == null;
|
|
51
|
+
}
|
|
52
|
+
function Ze(e) {
|
|
53
|
+
return Array.isArray(e) && e.length === 0;
|
|
54
|
+
}
|
|
55
|
+
const et = (e) => Ye(e) || Ze(e) || e === !1 ? !1 : !!String(e).trim().length;
|
|
56
|
+
function q(e) {
|
|
57
|
+
return e == null ? !1 : Array.isArray(e) ? e.some((r) => q(r)) : typeof e == "object" ? Object.values(e).some((r) => q(r)) : !0;
|
|
58
|
+
}
|
|
59
|
+
function tt(e, r, t) {
|
|
60
|
+
return typeof e == "function" ? e(r) : e.replace(/\{(\w+)\}/g, (n, l) => {
|
|
61
|
+
if (l in r)
|
|
62
|
+
return String(r[l]);
|
|
63
|
+
if (t && !Array.isArray(t) && l in t)
|
|
64
|
+
return String(t[l]);
|
|
65
|
+
const i = Number(l);
|
|
66
|
+
return Number.isNaN(i) ? r.rule?.params && !Array.isArray(r.rule.params) ? String(r.rule.params[l] ?? `{${l}}`) : `{${l}}` : Array.isArray(t) && t[i] !== void 0 ? String(t[i]) : String(r.rule?.params?.[i] ?? `{${l}}`);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
I("xsd_required", et);
|
|
70
|
+
I("xsd_minOccurs", (e, [r]) => Array.isArray(e) ? e.filter(q).length >= Number(r) : Number(r) <= 0);
|
|
71
|
+
I("xsd_choiceMinOccurs", () => !1);
|
|
72
|
+
I("xsd_minLength", $e);
|
|
73
|
+
I("xsd_maxLength", Me);
|
|
74
|
+
I("xsd_length", (e, [r]) => e == null || e === "" ? !0 : String(e).length === Number(r));
|
|
75
|
+
I("xsd_pattern", Be);
|
|
76
|
+
I("xsd_minInclusive", De);
|
|
77
|
+
I("xsd_maxInclusive", Ne);
|
|
78
|
+
I("xsd_minExclusive", (e, [r]) => e == null || e === "" ? !0 : Number(e) > Number(r));
|
|
79
|
+
I("xsd_maxExclusive", (e, [r]) => e == null || e === "" ? !0 : Number(e) < Number(r));
|
|
80
|
+
I("xsd_enumeration", we);
|
|
81
|
+
I("xsd_whiteSpace", (e, [r]) => {
|
|
82
|
+
if (e == null || e === "")
|
|
83
|
+
return !0;
|
|
84
|
+
const t = String(e);
|
|
85
|
+
return r === "replace" ? !/[\t\n\r]/.test(t) : r === "collapse" ? t === t.trim() && !/\s{2,}/.test(t) : !0;
|
|
86
|
+
});
|
|
87
|
+
I("xsd_fractionDigits", (e, [r]) => {
|
|
88
|
+
if (e == null || e === "")
|
|
89
|
+
return !0;
|
|
90
|
+
const t = String(e).indexOf(".");
|
|
91
|
+
return t === -1 ? !0 : String(e).length - t - 1 <= Number(r);
|
|
92
|
+
});
|
|
93
|
+
I("xsd_totalDigits", (e, [r]) => e == null || e === "" ? !0 : (String(e).replace(/^-/, "").replace(".", "").replace(/^0+/, "") || "0").length <= Number(r));
|
|
94
|
+
const rt = {
|
|
95
|
+
xsd_minOccurs: "min",
|
|
96
|
+
xsd_choiceMinOccurs: "min",
|
|
97
|
+
xsd_minLength: "length",
|
|
98
|
+
xsd_maxLength: "length",
|
|
99
|
+
xsd_length: "length",
|
|
100
|
+
xsd_pattern: "pattern",
|
|
101
|
+
xsd_minInclusive: "min",
|
|
102
|
+
xsd_maxInclusive: "max",
|
|
103
|
+
xsd_minExclusive: "min",
|
|
104
|
+
xsd_maxExclusive: "max",
|
|
105
|
+
xsd_whiteSpace: "mode",
|
|
106
|
+
xsd_fractionDigits: "digits",
|
|
107
|
+
xsd_totalDigits: "digits"
|
|
108
|
+
};
|
|
109
|
+
function ge(e) {
|
|
110
|
+
return e.label ?? e.field ?? e.name ?? "";
|
|
111
|
+
}
|
|
112
|
+
function F(e, r, t) {
|
|
113
|
+
const n = rt[e], l = r !== void 0 ? { 0: r, ...n ? { [n]: r } : {} } : {};
|
|
114
|
+
return async (i, s) => {
|
|
115
|
+
const c = ge(s), O = c ? { name: c } : void 0, v = c && s.field !== c ? { ...s, field: c } : s, b = await ye(
|
|
116
|
+
i,
|
|
117
|
+
r !== void 0 ? { [e]: r } : e,
|
|
118
|
+
O
|
|
119
|
+
);
|
|
120
|
+
return b.valid ? !0 : t ? tt(t, v, l) : b.errors[0];
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function _e(e) {
|
|
124
|
+
return e?.replaceAll(/\[[`'"](.*?)[`'"]\]/g, ".$1") ?? "";
|
|
125
|
+
}
|
|
126
|
+
function Ae(e, r) {
|
|
127
|
+
if (!e || !r)
|
|
128
|
+
return e;
|
|
129
|
+
const t = r.split(".") ?? [], n = e.split(".") ?? [];
|
|
130
|
+
for (let l = 0; l < t.length; l++)
|
|
131
|
+
n[l] = t[l];
|
|
132
|
+
return n.join(".");
|
|
133
|
+
}
|
|
134
|
+
function Ce(e) {
|
|
135
|
+
return e ? typeof e == "function" ? [e] : Array.isArray(e) ? e.flatMap(Ce) : typeof e == "string" ? e.split("|").map((r) => async (t, n) => {
|
|
136
|
+
const l = ge(n), i = await ye(t, r, l ? { name: l } : void 0);
|
|
137
|
+
return i.valid ? !0 : i.errors[0];
|
|
138
|
+
}) : Object.entries(e).map(([r, t]) => async (n, l) => {
|
|
139
|
+
const i = ge(l), s = await ye(n, { [r]: t }, i ? { name: i } : void 0);
|
|
140
|
+
return s.valid ? !0 : s.errors[0];
|
|
141
|
+
}) : [];
|
|
142
|
+
}
|
|
143
|
+
const at = { key: 0 }, it = ["data-testid"], nt = /* @__PURE__ */ le({
|
|
144
|
+
__name: "DynamicFormItemArray",
|
|
145
|
+
props: {
|
|
146
|
+
template: {},
|
|
147
|
+
fieldMetadata: {},
|
|
148
|
+
pathOverride: {},
|
|
149
|
+
minOccursOverride: {},
|
|
150
|
+
maxOccursOverride: {},
|
|
151
|
+
partOfArrayField: { type: Boolean },
|
|
152
|
+
partOfChoiceField: { type: Boolean },
|
|
153
|
+
isArrayOverride: {},
|
|
154
|
+
index: {},
|
|
155
|
+
canAddItems: { type: Boolean },
|
|
156
|
+
canRemoveItems: { type: Boolean },
|
|
157
|
+
addItem: { type: Function },
|
|
158
|
+
removeItem: { type: Function },
|
|
159
|
+
slotProps: {}
|
|
160
|
+
},
|
|
161
|
+
emits: ["update:modelValue", "update:computedField"],
|
|
162
|
+
setup(e, { emit: r }) {
|
|
163
|
+
const t = e, n = r, l = me(ve);
|
|
164
|
+
let i = 0;
|
|
165
|
+
const s = u(() => t.fieldMetadata), c = u(() => s.value?.path ? Ae(s.value.path, t.pathOverride) : ""), O = u(() => _e(c.value)), v = Je(O), { remove: b, push: S, fields: _, update: E, values: U, replace: P } = Qe(O), A = u(
|
|
166
|
+
() => t.minOccursOverride !== void 0 ? t.minOccursOverride : s.value?.minOccurs ?? 1
|
|
167
|
+
), g = u(
|
|
168
|
+
() => t.maxOccursOverride !== void 0 ? t.maxOccursOverride : s.value?.maxOccurs ?? 1
|
|
169
|
+
), k = u(() => g.value === 0), X = u(() => A.value >= 1 && !k.value), z = u(
|
|
170
|
+
() => g.value === 0 ? 0 : 1
|
|
171
|
+
), R = u(() => g.value > _.value?.length), H = u(() => t.partOfChoiceField || s.value?.autoAddMinOccurs === !1 ? _.value?.length > 0 : _.value?.length > A.value && _.value?.length > 1), G = u(() => {
|
|
172
|
+
const h = [], M = l?.value?.messages;
|
|
173
|
+
return X.value && h.push(F("xsd_minOccurs", A.value, M?.minOccurs)), s.value?.validation && h.push(...Ce(s.value?.validation)), h;
|
|
174
|
+
}), { label: T, errors: d, errorMessage: y, handleBlur: p } = xe(O, G, {
|
|
175
|
+
...s.value?.fieldOptions ?? {},
|
|
176
|
+
validateOnValueUpdate: !1
|
|
177
|
+
// validation timing is owned by this component
|
|
178
|
+
}), f = { label: T, errors: d, errorMessage: y, value: U }, m = Pe(), V = J(!1), N = u(() => {
|
|
179
|
+
if (!V.value)
|
|
180
|
+
return;
|
|
181
|
+
const h = l?.value?.validateOnValueUpdateAfterSubmit === !0 ? m.value > 0 && l?.value?.validateOnValueUpdateAfterSubmit : void 0, M = l?.value?.validateWhenInError && f?.errors.value?.length > 0 ? !0 : void 0;
|
|
182
|
+
return s.value?.fieldOptions?.validateOnValueUpdate ?? M ?? h ?? l?.value?.validateOnValueUpdate;
|
|
183
|
+
});
|
|
184
|
+
ae(
|
|
185
|
+
U,
|
|
186
|
+
(h) => {
|
|
187
|
+
N.value && v(), n("update:modelValue", h);
|
|
188
|
+
},
|
|
189
|
+
{ immediate: !0 }
|
|
190
|
+
), Ve(() => {
|
|
191
|
+
t.partOfChoiceField || s.value?.autoAddMinOccurs !== !1 && (_.value?.length < 1 || _.value?.length < A.value) && B();
|
|
192
|
+
});
|
|
193
|
+
function B() {
|
|
194
|
+
S(null), n("update:modelValue", U.value);
|
|
195
|
+
}
|
|
196
|
+
function K(h) {
|
|
197
|
+
H.value ? b(h ?? _.value.length - 1) : P(U.value?.map((M, ee) => ee === h ? null : M)), n("update:modelValue", U.value);
|
|
198
|
+
}
|
|
199
|
+
function D(h, M) {
|
|
200
|
+
V.value || (V.value = !0, N.value && v()), h === void 0 && M >= 0 && E(M, void 0), n("update:modelValue", U.value);
|
|
201
|
+
}
|
|
202
|
+
return (h, M) => (x(), w(W, null, [
|
|
203
|
+
Y(l)?.analytics ? Fe((x(), w("div", at, [
|
|
204
|
+
Ie("span", {
|
|
205
|
+
"data-testid": `${c.value}-analytics-render-count`
|
|
206
|
+
}, Se(Ue(i) ? ++i.value : ++i), 9, it)
|
|
207
|
+
], 512)), [
|
|
208
|
+
[Ee, !1]
|
|
209
|
+
]) : ie("", !0),
|
|
210
|
+
(x(), $(se(h.template), {
|
|
211
|
+
type: `${h.fieldMetadata.type}-array`,
|
|
212
|
+
"field-metadata": h.fieldMetadata,
|
|
213
|
+
"field-context": f,
|
|
214
|
+
required: X.value,
|
|
215
|
+
disabled: k.value,
|
|
216
|
+
index: h.index,
|
|
217
|
+
"slot-props": h.slotProps,
|
|
218
|
+
"can-add-items": R.value,
|
|
219
|
+
"can-remove-items": H.value,
|
|
220
|
+
"add-item": B,
|
|
221
|
+
"remove-item": K
|
|
222
|
+
}, {
|
|
223
|
+
default: ce((ee) => [
|
|
224
|
+
(x(!0), w(W, null, ue(Y(_) ?? [], ({ key: te }, j) => (x(), $(de, {
|
|
225
|
+
key: te,
|
|
226
|
+
"field-metadata": h.fieldMetadata,
|
|
227
|
+
"path-override": `${c.value}[${j}]`,
|
|
228
|
+
index: j,
|
|
229
|
+
template: h.template,
|
|
230
|
+
"slot-props": ee,
|
|
231
|
+
"max-occurs-override": z.value,
|
|
232
|
+
"can-add-items": R.value,
|
|
233
|
+
"can-remove-items": H.value,
|
|
234
|
+
"add-item": B,
|
|
235
|
+
"remove-item": () => K(j),
|
|
236
|
+
"part-of-array-field": "",
|
|
237
|
+
"is-array-override": "single",
|
|
238
|
+
"onUpdate:modelValue": (L) => D(L, j),
|
|
239
|
+
"onUpdate:computedField": M[0] || (M[0] = (L) => n("update:computedField", L)),
|
|
240
|
+
onBlur: Y(p)
|
|
241
|
+
}, null, 8, ["field-metadata", "path-override", "index", "template", "slot-props", "max-occurs-override", "can-add-items", "can-remove-items", "remove-item", "onUpdate:modelValue", "onBlur"]))), 128))
|
|
242
|
+
]),
|
|
243
|
+
_: 1
|
|
244
|
+
}, 8, ["type", "field-metadata", "required", "disabled", "index", "slot-props", "can-add-items", "can-remove-items"]))
|
|
245
|
+
], 64));
|
|
246
|
+
}
|
|
247
|
+
}), ut = /* @__PURE__ */ le({
|
|
248
|
+
__name: "DynamicFormItemChoice",
|
|
249
|
+
props: {
|
|
250
|
+
template: {},
|
|
251
|
+
fieldMetadata: {},
|
|
252
|
+
pathOverride: {},
|
|
253
|
+
minOccursOverride: {},
|
|
254
|
+
maxOccursOverride: {},
|
|
255
|
+
partOfArrayField: { type: Boolean },
|
|
256
|
+
partOfChoiceField: { type: Boolean },
|
|
257
|
+
isArrayOverride: {},
|
|
258
|
+
index: {},
|
|
259
|
+
canAddItems: { type: Boolean },
|
|
260
|
+
canRemoveItems: { type: Boolean },
|
|
261
|
+
addItem: { type: Function },
|
|
262
|
+
removeItem: { type: Function },
|
|
263
|
+
slotProps: {}
|
|
264
|
+
},
|
|
265
|
+
emits: ["update:modelValue", "update:computedField"],
|
|
266
|
+
setup(e, { emit: r }) {
|
|
267
|
+
const t = e, n = r, l = me(ve), i = u(() => t.fieldMetadata), s = u(() => Ae(i.value.path ?? "", t.pathOverride)), c = u(() => _e(s.value)), O = u(
|
|
268
|
+
() => t.minOccursOverride !== void 0 ? t.minOccursOverride : i.value?.minOccurs ?? 1
|
|
269
|
+
), v = u(
|
|
270
|
+
() => t.maxOccursOverride !== void 0 ? t.maxOccursOverride : i.value?.maxOccurs ?? 1
|
|
271
|
+
), b = u(() => v.value === 0), S = u(() => O.value >= 1 && !b.value), _ = u(
|
|
272
|
+
() => O.value === 0 ? 0 : void 0
|
|
273
|
+
), E = u(
|
|
274
|
+
() => v.value === 0 ? 0 : void 0
|
|
275
|
+
), U = u(() => i.value?.maxOccurs > 1 ? "array" : void 0), P = J({}), A = u(() => Object.values(P.value).map((d) => d.value)), g = u(
|
|
276
|
+
() => i.value?.choice?.length === 1 ? i.value?.choice[0] : void 0
|
|
277
|
+
), k = u(() => {
|
|
278
|
+
const d = {};
|
|
279
|
+
i.value?.choice?.forEach((f, m) => {
|
|
280
|
+
d[m] = {
|
|
281
|
+
childValuesCount: 0,
|
|
282
|
+
childOccurrences: 0,
|
|
283
|
+
childMaxOccurrences: 1,
|
|
284
|
+
choiceValuesCount: 0,
|
|
285
|
+
choiceOccurrences: 0,
|
|
286
|
+
overrideChildMaxOccurrences: void 0,
|
|
287
|
+
overrideChildMinOccurrences: 0
|
|
288
|
+
// children are optional by default inside a choice
|
|
289
|
+
};
|
|
290
|
+
});
|
|
291
|
+
const y = v.value ?? 1;
|
|
292
|
+
if (y === 0)
|
|
293
|
+
return i.value?.choice?.forEach((f, m) => {
|
|
294
|
+
d[m].overrideChildMaxOccurrences = 0, d[m].overrideChildMinOccurrences = 0;
|
|
295
|
+
}), d;
|
|
296
|
+
for (const [f, m] of Object.entries(P.value ?? {})) {
|
|
297
|
+
let V = Math.ceil(m.occurrences / m.maxOccurrences);
|
|
298
|
+
const N = Math.ceil(m.valuesCount / m.maxOccurrences);
|
|
299
|
+
y * m.maxOccurrences === 1 && (V = N), d[f] = {
|
|
300
|
+
childValuesCount: m.valuesCount,
|
|
301
|
+
childOccurrences: m.occurrences,
|
|
302
|
+
childMaxOccurrences: m.maxOccurrences,
|
|
303
|
+
choiceOccurrences: V,
|
|
304
|
+
choiceValuesCount: N,
|
|
305
|
+
overrideChildMinOccurrences: m.valuesCount === 0 ? 0 : void 0,
|
|
306
|
+
// optional when empty
|
|
307
|
+
overrideChildMaxOccurrences: void 0
|
|
308
|
+
// calculated in pass 2
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
const p = Object.values(d).reduce(
|
|
312
|
+
(f, m) => f + m.choiceOccurrences,
|
|
313
|
+
0
|
|
314
|
+
);
|
|
315
|
+
return Object.values(d).forEach((f) => {
|
|
316
|
+
const V = (p - f.choiceOccurrences) * f.childMaxOccurrences, N = y * f.childMaxOccurrences;
|
|
317
|
+
f.overrideChildMaxOccurrences = N - V;
|
|
318
|
+
}), d;
|
|
319
|
+
}), X = u(
|
|
320
|
+
() => Object.values(k.value).reduce(
|
|
321
|
+
(d, y) => d + y.choiceValuesCount,
|
|
322
|
+
0
|
|
323
|
+
)
|
|
324
|
+
), z = u(() => {
|
|
325
|
+
if (g.value || b.value || X.value >= O.value)
|
|
326
|
+
return;
|
|
327
|
+
const d = l?.value?.messages;
|
|
328
|
+
return [F("xsd_choiceMinOccurs", O.value, d?.choiceMinOccurs)];
|
|
329
|
+
}), { errors: R, errorMessage: H } = xe(c, z, i.value?.fieldOptions), G = { label: i.value?.fieldOptions?.label, errors: R, errorMessage: H, value: A };
|
|
330
|
+
ae(i, (d) => {
|
|
331
|
+
d && d.choice?.forEach((y, p) => {
|
|
332
|
+
p in P.value || T(void 0, p, y.maxOccurs);
|
|
333
|
+
});
|
|
334
|
+
}, { immediate: !0 });
|
|
335
|
+
function T(d, y, p = 1, f = !1) {
|
|
336
|
+
if (f) {
|
|
337
|
+
n("update:modelValue", A.value);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (y === void 0)
|
|
341
|
+
return;
|
|
342
|
+
let m = Array.isArray(d) ? d : [d];
|
|
343
|
+
(v.value ?? 1) * p === 1 && (m = m.filter((h) => h !== void 0));
|
|
344
|
+
const B = m.length, K = m.filter((h) => q(h)).length, D = P.value[y] ?? {};
|
|
345
|
+
D.value = d, D.occurrences = B, D.valuesCount = K, D.maxOccurrences = p, P.value[y] || (P.value[y] = D), n("update:modelValue", A.value);
|
|
346
|
+
}
|
|
347
|
+
return (d, y) => (x(), $(se(d.template), {
|
|
348
|
+
type: `${d.fieldMetadata.type}-choice`,
|
|
349
|
+
"field-metadata": d.fieldMetadata,
|
|
350
|
+
"field-context": G,
|
|
351
|
+
required: S.value,
|
|
352
|
+
index: d.index,
|
|
353
|
+
disabled: b.value,
|
|
354
|
+
"slot-props": d.slotProps,
|
|
355
|
+
"can-add-items": d.canAddItems,
|
|
356
|
+
"can-remove-items": d.canRemoveItems,
|
|
357
|
+
"add-item": d.addItem,
|
|
358
|
+
"remove-item": d.removeItem
|
|
359
|
+
}, {
|
|
360
|
+
default: ce((p) => [
|
|
361
|
+
g.value ? (x(), $(de, {
|
|
362
|
+
key: 0,
|
|
363
|
+
"field-metadata": g.value,
|
|
364
|
+
"path-override": d.pathOverride,
|
|
365
|
+
template: d.template,
|
|
366
|
+
"slot-props": p,
|
|
367
|
+
"min-occurs-override": _.value,
|
|
368
|
+
"max-occurs-override": E.value,
|
|
369
|
+
"part-of-choice-field": "",
|
|
370
|
+
"onUpdate:modelValue": y[0] || (y[0] = (f) => T(f, 0, g.value.maxOccurs, !0)),
|
|
371
|
+
"onUpdate:computedField": y[1] || (y[1] = (f) => n("update:computedField", f))
|
|
372
|
+
}, null, 8, ["field-metadata", "path-override", "template", "slot-props", "min-occurs-override", "max-occurs-override"])) : (x(!0), w(W, { key: 1 }, ue(i.value.choice, (f, m) => (x(), $(de, {
|
|
373
|
+
key: f.name,
|
|
374
|
+
"field-metadata": f,
|
|
375
|
+
"path-override": d.pathOverride,
|
|
376
|
+
index: m,
|
|
377
|
+
template: d.template,
|
|
378
|
+
"slot-props": p,
|
|
379
|
+
"min-occurs-override": k.value[m]?.overrideChildMinOccurrences,
|
|
380
|
+
"max-occurs-override": k.value[m]?.overrideChildMaxOccurrences,
|
|
381
|
+
"is-array-override": U.value,
|
|
382
|
+
"part-of-choice-field": "",
|
|
383
|
+
"onUpdate:modelValue": (V) => T(V, m, f.maxOccurs),
|
|
384
|
+
"onUpdate:computedField": y[2] || (y[2] = (V) => n("update:computedField", V))
|
|
385
|
+
}, null, 8, ["field-metadata", "path-override", "index", "template", "slot-props", "min-occurs-override", "max-occurs-override", "is-array-override", "onUpdate:modelValue"]))), 128))
|
|
386
|
+
]),
|
|
387
|
+
_: 1
|
|
388
|
+
}, 8, ["type", "field-metadata", "required", "index", "disabled", "slot-props", "can-add-items", "can-remove-items", "add-item", "remove-item"]));
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
function lt(e) {
|
|
392
|
+
const {
|
|
393
|
+
name: r,
|
|
394
|
+
path: t,
|
|
395
|
+
children: n,
|
|
396
|
+
choice: l,
|
|
397
|
+
attributes: i,
|
|
398
|
+
fieldOptions: s,
|
|
399
|
+
computedProps: c,
|
|
400
|
+
maxOccurs: O,
|
|
401
|
+
_hash: v,
|
|
402
|
+
parent: b,
|
|
403
|
+
isComplexType: S,
|
|
404
|
+
computeOnChildValueChange: _,
|
|
405
|
+
...E
|
|
406
|
+
} = e, U = Object.fromEntries(
|
|
407
|
+
Object.entries(E).sort(([P], [A]) => P.localeCompare(A))
|
|
408
|
+
);
|
|
409
|
+
return JSON.stringify(U);
|
|
410
|
+
}
|
|
411
|
+
const ot = { key: 0 }, st = ["data-testid"], be = 10, de = /* @__PURE__ */ le({
|
|
412
|
+
__name: "DynamicFormItem",
|
|
413
|
+
props: {
|
|
414
|
+
template: {},
|
|
415
|
+
fieldMetadata: {},
|
|
416
|
+
pathOverride: {},
|
|
417
|
+
minOccursOverride: {},
|
|
418
|
+
maxOccursOverride: {},
|
|
419
|
+
partOfArrayField: { type: Boolean },
|
|
420
|
+
partOfChoiceField: { type: Boolean },
|
|
421
|
+
isArrayOverride: {},
|
|
422
|
+
index: {},
|
|
423
|
+
canAddItems: { type: Boolean },
|
|
424
|
+
canRemoveItems: { type: Boolean },
|
|
425
|
+
addItem: { type: Function },
|
|
426
|
+
removeItem: { type: Function },
|
|
427
|
+
slotProps: {}
|
|
428
|
+
},
|
|
429
|
+
emits: ["update:modelValue", "blur", "update:computedField"],
|
|
430
|
+
setup(e, { emit: r }) {
|
|
431
|
+
const t = e, n = r, l = me(ve);
|
|
432
|
+
let i = 0, s = 0, c;
|
|
433
|
+
function O(a) {
|
|
434
|
+
if (s++, c == null && (c = setTimeout(() => {
|
|
435
|
+
s = 0, c = void 0;
|
|
436
|
+
}, 0)), s > be)
|
|
437
|
+
throw new Error(
|
|
438
|
+
`[DynamicFormItem] Possible infinite loop detected in computedProps for field "${a}". computedProps recomputed more than ${be} times synchronously. Ensure value writes inside computedProps are idempotent (the same input always produces the same output).`
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
const v = u(() => t.fieldMetadata), b = u(() => v.value?.path ? Ae(v.value.path, t.pathOverride) : ""), S = u(() => v.value?.isComplexType || v.value?.attributes?.length), _ = u(() => {
|
|
442
|
+
let a = b.value;
|
|
443
|
+
if (S.value && a) {
|
|
444
|
+
const o = l?.value?.complexTypeValueProperty ?? "value";
|
|
445
|
+
a = `${a}['${o}']`;
|
|
446
|
+
}
|
|
447
|
+
return a;
|
|
448
|
+
}), E = u(() => _e(_.value)), U = u(() => t.isArrayOverride === "array" ? !0 : t.isArrayOverride === "single" ? !1 : (v.value?.maxOccurs ?? 1) > 1), P = J([]), A = U.value ? { value: J(void 0) } : xe(E, P, {
|
|
449
|
+
...v.value?.fieldOptions ?? {},
|
|
450
|
+
validateOnValueUpdate: !1
|
|
451
|
+
// validation timing is owned by this component
|
|
452
|
+
}), g = A.value;
|
|
453
|
+
A.hasValue = u(() => q(g.value));
|
|
454
|
+
const k = A.handleBlur;
|
|
455
|
+
A.handleBlur = function(a, o) {
|
|
456
|
+
o = o ?? l?.value?.validateOnBlur, k(a, o), n("blur", a, o);
|
|
457
|
+
};
|
|
458
|
+
const X = A.handleChange;
|
|
459
|
+
A.handleChange = function(a, o) {
|
|
460
|
+
X(a, o === !0);
|
|
461
|
+
};
|
|
462
|
+
const z = u(() => !!v.value?.children?.length), R = u(() => !!v.value?.choice?.length), H = u(() => !U.value && !R.value && !z.value), G = J(!0), T = J(0), d = J({}), y = u(() => Object.values(d.value)), p = u(() => {
|
|
463
|
+
O(b.value), v.value?.computeOnChildValueChange === !0 && T.value;
|
|
464
|
+
const o = (v.value?.computedProps ?? []).reduce(
|
|
465
|
+
(C, Q) => (Q(C, g, y), C),
|
|
466
|
+
{ ...v.value, path: b.value }
|
|
467
|
+
);
|
|
468
|
+
return o.path = b.value, o._hash = lt(o), o;
|
|
469
|
+
}), f = u(() => t.minOccursOverride !== void 0 ? t.minOccursOverride : t.partOfArrayField ? 0 : p.value?.minOccurs ?? 1), m = u(
|
|
470
|
+
() => t.maxOccursOverride !== void 0 ? t.maxOccursOverride : p.value?.maxOccurs ?? 1
|
|
471
|
+
), V = u(() => m.value === 0), N = u(() => f.value >= 1 && !V.value), B = u(() => {
|
|
472
|
+
if (t.minOccursOverride === 0)
|
|
473
|
+
return t.minOccursOverride;
|
|
474
|
+
if (!(f.value > 0) && !q(g.value))
|
|
475
|
+
return 0;
|
|
476
|
+
}), K = u(
|
|
477
|
+
() => m.value === 0 ? 0 : void 0
|
|
478
|
+
), D = u(() => t.partOfArrayField && q(g.value) ? !0 : t.canRemoveItems), h = Pe(), M = u(() => {
|
|
479
|
+
const a = l?.value?.validateOnValueUpdateAfterSubmit === !0 ? h.value > 0 && l?.value?.validateOnValueUpdateAfterSubmit : void 0, o = l?.value?.validateWhenInError && A?.errors.value?.length > 0 ? !0 : void 0;
|
|
480
|
+
return v.value?.fieldOptions?.validateOnValueUpdate ?? o ?? a ?? l?.value?.validateOnValueUpdate;
|
|
481
|
+
}), ee = u(
|
|
482
|
+
() => v.value?.attributes?.length && q(g.value)
|
|
483
|
+
);
|
|
484
|
+
Ve(() => {
|
|
485
|
+
const a = [], o = v.value.restriction ?? {}, C = l?.value?.messages;
|
|
486
|
+
N.value && a.push(F("xsd_required", void 0, C?.required)), o.minLength != null && a.push(F("xsd_minLength", o.minLength, C?.minLength)), o.maxLength != null && a.push(F("xsd_maxLength", o.maxLength, C?.maxLength)), o.length != null && a.push(F("xsd_length", o.length, C?.length)), o.pattern != null && a.push(F("xsd_pattern", o.pattern, C?.pattern)), o.minInclusive != null && a.push(F("xsd_minInclusive", o.minInclusive, C?.minInclusive)), o.maxInclusive != null && a.push(F("xsd_maxInclusive", o.maxInclusive, C?.maxInclusive)), o.minExclusive != null && a.push(F("xsd_minExclusive", o.minExclusive, C?.minExclusive)), o.maxExclusive != null && a.push(F("xsd_maxExclusive", o.maxExclusive, C?.maxExclusive)), o.enumeration != null && a.push(F("xsd_enumeration", o.enumeration, C?.enumeration)), o.whiteSpace != null && a.push(F("xsd_whiteSpace", o.whiteSpace, C?.whiteSpace)), o.fractionDigits != null && a.push(F("xsd_fractionDigits", o.fractionDigits, C?.fractionDigits)), o.totalDigits != null && a.push(F("xsd_totalDigits", o.totalDigits, C?.totalDigits)), v.value?.validation && a.push(...Ce(v.value?.validation)), P.value = a;
|
|
487
|
+
});
|
|
488
|
+
let te = !1;
|
|
489
|
+
ae(g, (a) => {
|
|
490
|
+
te || (te = !0, a === "" && (g.value = t.partOfArrayField ? null : void 0), te = !1);
|
|
491
|
+
}, {
|
|
492
|
+
flush: "sync"
|
|
493
|
+
}), ae(
|
|
494
|
+
g,
|
|
495
|
+
(a) => {
|
|
496
|
+
H.value && ((!G.value || a) && (L(), M.value && A?.validate()), G.value = !1);
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
immediate: !0
|
|
500
|
+
}
|
|
501
|
+
), Le(() => {
|
|
502
|
+
n("update:computedField", p.value), ae(() => p.value._hash, (a, o) => {
|
|
503
|
+
a !== o && n("update:computedField", p.value);
|
|
504
|
+
});
|
|
505
|
+
}), ke(() => {
|
|
506
|
+
c != null && clearTimeout(c), !t.partOfArrayField && g.value !== void 0 && (g.value = void 0, L());
|
|
507
|
+
});
|
|
508
|
+
function j(a) {
|
|
509
|
+
!a.path || d.value[a.path]?._hash === a._hash || (d.value[a.path] = a);
|
|
510
|
+
}
|
|
511
|
+
function L() {
|
|
512
|
+
T.value++, n("update:modelValue", g.value);
|
|
513
|
+
}
|
|
514
|
+
function je(a) {
|
|
515
|
+
g.value = a, n("update:modelValue", g.value);
|
|
516
|
+
}
|
|
517
|
+
return (a, o) => {
|
|
518
|
+
const C = Te("DynamicFormItem", !0);
|
|
519
|
+
return x(), w(W, null, [
|
|
520
|
+
Y(l)?.analytics ? Fe((x(), w("div", ot, [
|
|
521
|
+
Ie("span", {
|
|
522
|
+
"data-testid": `${b.value}-analytics-render-count`
|
|
523
|
+
}, Se(Ue(i) ? ++i.value : ++i), 9, st)
|
|
524
|
+
], 512)), [
|
|
525
|
+
[Ee, !1]
|
|
526
|
+
]) : ie("", !0),
|
|
527
|
+
R.value ? (x(), $(ut, ne({ key: 1 }, t, {
|
|
528
|
+
"field-metadata": p.value,
|
|
529
|
+
"onUpdate:modelValue": L,
|
|
530
|
+
"onUpdate:computedField": j
|
|
531
|
+
}), null, 16, ["field-metadata"])) : U.value ? (x(), $(nt, ne({ key: 2 }, t, {
|
|
532
|
+
"part-of-choice-field": a.partOfChoiceField,
|
|
533
|
+
"field-metadata": p.value,
|
|
534
|
+
"onUpdate:modelValue": je,
|
|
535
|
+
"onUpdate:computedField": j
|
|
536
|
+
}), null, 16, ["part-of-choice-field", "field-metadata"])) : (x(), $(se(a.template), {
|
|
537
|
+
key: 3,
|
|
538
|
+
type: a.partOfArrayField ? `${p.value.type}-array-item` : p.value.type,
|
|
539
|
+
"field-metadata": p.value,
|
|
540
|
+
"field-context": Y(A),
|
|
541
|
+
"slot-props": a.slotProps,
|
|
542
|
+
required: N.value,
|
|
543
|
+
disabled: V.value,
|
|
544
|
+
index: a.index,
|
|
545
|
+
"can-add-items": a.canAddItems,
|
|
546
|
+
"can-remove-items": D.value,
|
|
547
|
+
"add-item": a.addItem,
|
|
548
|
+
"remove-item": a.removeItem
|
|
549
|
+
}, qe({
|
|
550
|
+
default: ce((Q) => [
|
|
551
|
+
z.value ? (x(!0), w(W, { key: 0 }, ue(p.value.children, (re, pe) => (x(), $(C, {
|
|
552
|
+
key: re.path,
|
|
553
|
+
"field-metadata": re,
|
|
554
|
+
"path-override": _.value,
|
|
555
|
+
index: pe,
|
|
556
|
+
template: a.template,
|
|
557
|
+
"slot-props": Q,
|
|
558
|
+
"min-occurs-override": B.value,
|
|
559
|
+
"max-occurs-override": K.value,
|
|
560
|
+
"onUpdate:modelValue": L,
|
|
561
|
+
"onUpdate:computedField": j
|
|
562
|
+
}, null, 8, ["field-metadata", "path-override", "index", "template", "slot-props", "min-occurs-override", "max-occurs-override"]))), 128)) : ie("", !0),
|
|
563
|
+
z.value ? ie("", !0) : (x(), $(se(a.template), {
|
|
564
|
+
key: 1,
|
|
565
|
+
type: `${p.value.type}-input`,
|
|
566
|
+
"field-metadata": p.value,
|
|
567
|
+
"field-context": Y(A),
|
|
568
|
+
"slot-props": Q,
|
|
569
|
+
required: N.value,
|
|
570
|
+
disabled: V.value,
|
|
571
|
+
index: a.index,
|
|
572
|
+
"can-add-items": a.canAddItems,
|
|
573
|
+
"can-remove-items": D.value,
|
|
574
|
+
"add-item": a.addItem,
|
|
575
|
+
"remove-item": a.removeItem
|
|
576
|
+
}, null, 8, ["type", "field-metadata", "field-context", "slot-props", "required", "disabled", "index", "can-add-items", "can-remove-items", "add-item", "remove-item"]))
|
|
577
|
+
]),
|
|
578
|
+
_: 2
|
|
579
|
+
}, [
|
|
580
|
+
ee.value ? {
|
|
581
|
+
name: "attributes",
|
|
582
|
+
fn: ce((Q) => [
|
|
583
|
+
(x(!0), w(W, null, ue(p.value.attributes, (re, pe) => (x(), $(C, {
|
|
584
|
+
key: re.path,
|
|
585
|
+
"field-metadata": re,
|
|
586
|
+
"path-override": b.value,
|
|
587
|
+
index: pe,
|
|
588
|
+
template: a.template,
|
|
589
|
+
"slot-props": Q,
|
|
590
|
+
"min-occurs-override": B.value,
|
|
591
|
+
"max-occurs-override": K.value,
|
|
592
|
+
"onUpdate:modelValue": L,
|
|
593
|
+
"onUpdate:computedField": j
|
|
594
|
+
}, null, 8, ["field-metadata", "path-override", "index", "template", "slot-props", "min-occurs-override", "max-occurs-override"]))), 128))
|
|
595
|
+
]),
|
|
596
|
+
key: "0"
|
|
597
|
+
} : void 0
|
|
598
|
+
]), 1032, ["type", "field-metadata", "field-context", "slot-props", "required", "disabled", "index", "can-add-items", "can-remove-items", "add-item", "remove-item"]))
|
|
599
|
+
], 64);
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
}), Ot = /* @__PURE__ */ le({
|
|
603
|
+
name: "DynamicForm",
|
|
604
|
+
inheritAttrs: !1,
|
|
605
|
+
__name: "DynamicForm",
|
|
606
|
+
props: {
|
|
607
|
+
metadata: {},
|
|
608
|
+
template: {},
|
|
609
|
+
settings: {}
|
|
610
|
+
},
|
|
611
|
+
setup(e) {
|
|
612
|
+
const r = u(() => ({
|
|
613
|
+
validateOnValueUpdate: !0,
|
|
614
|
+
validateWhenInError: !0,
|
|
615
|
+
...e.settings ?? {}
|
|
616
|
+
}));
|
|
617
|
+
We(ve, r);
|
|
618
|
+
const t = u(
|
|
619
|
+
() => Array.isArray(e.metadata) ? e.metadata : [e.metadata]
|
|
620
|
+
), n = u(
|
|
621
|
+
() => t.value?.map((s, c) => i(s, c)) ?? []
|
|
622
|
+
), l = u(
|
|
623
|
+
() => e.template
|
|
624
|
+
);
|
|
625
|
+
function i(s, c, O) {
|
|
626
|
+
if (!s)
|
|
627
|
+
return s;
|
|
628
|
+
const v = s.name ?? `field-${c}`, b = s.path ?? [O?.path, v].filter(Boolean).join("."), S = {
|
|
629
|
+
name: v,
|
|
630
|
+
path: b,
|
|
631
|
+
type: "text",
|
|
632
|
+
minOccurs: 1,
|
|
633
|
+
maxOccurs: 1,
|
|
634
|
+
...s,
|
|
635
|
+
computedProps: [...s.computedProps ?? []],
|
|
636
|
+
parent: O
|
|
637
|
+
};
|
|
638
|
+
return S.children = (s.children ?? []).map(
|
|
639
|
+
(_, E) => i(_, E, S)
|
|
640
|
+
), S.choice = (s.choice ?? []).map(
|
|
641
|
+
(_, E) => i(_, E, S)
|
|
642
|
+
), S.attributes = (s.attributes ?? []).map(
|
|
643
|
+
(_, E) => i(_, E, S)
|
|
644
|
+
), S;
|
|
645
|
+
}
|
|
646
|
+
return (s, c) => (x(!0), w(W, null, ue(n.value, (O) => (x(), $(de, {
|
|
647
|
+
key: O.name,
|
|
648
|
+
template: l.value,
|
|
649
|
+
"field-metadata": O
|
|
650
|
+
}, null, 8, ["template", "field-metadata"]))), 128));
|
|
651
|
+
}
|
|
652
|
+
}), ct = /-\w/g, dt = mt(
|
|
653
|
+
(e) => e.replace(ct, (r) => r.slice(1).toUpperCase())
|
|
654
|
+
);
|
|
655
|
+
function mt(e) {
|
|
656
|
+
const r = /* @__PURE__ */ Object.create(null);
|
|
657
|
+
return ((t) => r[t] || (r[t] = e(t)));
|
|
658
|
+
}
|
|
659
|
+
const yt = /* @__PURE__ */ le({
|
|
660
|
+
name: "DynamicFormTemplate",
|
|
661
|
+
inheritAttrs: !1,
|
|
662
|
+
__name: "DynamicFormTemplate",
|
|
663
|
+
props: {
|
|
664
|
+
metadataConfiguration: {}
|
|
665
|
+
},
|
|
666
|
+
setup(e) {
|
|
667
|
+
const r = ze(), t = Re(), n = u(() => {
|
|
668
|
+
const i = {};
|
|
669
|
+
for (const [s, c] of Object.entries(t))
|
|
670
|
+
i[dt(s)] = c;
|
|
671
|
+
return i;
|
|
672
|
+
}), l = u(() => {
|
|
673
|
+
const i = n.value.type;
|
|
674
|
+
return i && r[i] ? i : i?.endsWith("-input") ? r["default-input"] ? "default-input" : "default" : i?.endsWith("-array") ? r["default-array"] ? "default-array" : "default" : i?.endsWith("-array-item") ? r["default-array-item"] ? "default-array-item" : "default" : i?.endsWith("-choice") && r["default-choice"] ? "default-choice" : "default";
|
|
675
|
+
});
|
|
676
|
+
return (i, s) => n.value.fieldMetadata ? (x(), w(W, { key: 0 }, [
|
|
677
|
+
n.value.type?.endsWith("-array") ? fe(i.$slots, l.value, he(ne({ key: 0 }, n.value))) : n.value.type?.endsWith("-choice") ? fe(i.$slots, l.value, he(ne({ key: 1 }, n.value))) : fe(i.$slots, l.value, he(ne({ key: 2 }, n.value)))
|
|
678
|
+
], 64)) : ie("", !0);
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
function gt() {
|
|
682
|
+
return {
|
|
683
|
+
fieldTypes: Object.keys({}),
|
|
684
|
+
extendedProperties: {},
|
|
685
|
+
slotProperties: {},
|
|
686
|
+
valueTypes: {}
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
function vt() {
|
|
690
|
+
const r = He()?.provides;
|
|
691
|
+
return r && Oe in r ? r[Oe] : me(Oe);
|
|
692
|
+
}
|
|
693
|
+
function pt() {
|
|
694
|
+
const e = vt();
|
|
695
|
+
async function r(t) {
|
|
696
|
+
const n = e.getAllPathStates().map((c) => c.path).filter((c) => c === t || c.startsWith(`${t}.`) || c.startsWith(`${t}[`)), l = await Promise.all(
|
|
697
|
+
n.map(async (c) => ({
|
|
698
|
+
path: c,
|
|
699
|
+
result: await e.validateField(c)
|
|
700
|
+
}))
|
|
701
|
+
), i = Object.fromEntries(
|
|
702
|
+
l.map(({ path: c, result: O }) => [c, O])
|
|
703
|
+
), s = Object.fromEntries(
|
|
704
|
+
l.filter(({ result: c }) => !c.valid).map(({ path: c, result: O }) => [c, O.errors[0] ?? ""])
|
|
705
|
+
);
|
|
706
|
+
return {
|
|
707
|
+
valid: l.every(({ result: c }) => c.valid),
|
|
708
|
+
results: i,
|
|
709
|
+
errors: s,
|
|
710
|
+
source: "fields"
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
return { validateSection: r };
|
|
714
|
+
}
|
|
715
|
+
function xt(e) {
|
|
716
|
+
const r = (l) => Ge(l), t = Xe(e), { validateSection: n } = pt();
|
|
717
|
+
return {
|
|
718
|
+
...t,
|
|
719
|
+
useFieldValue: r,
|
|
720
|
+
validateSection: n
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
export {
|
|
724
|
+
Ot as _,
|
|
725
|
+
de as a,
|
|
726
|
+
nt as b,
|
|
727
|
+
ut as c,
|
|
728
|
+
yt as d,
|
|
729
|
+
gt as e,
|
|
730
|
+
pt as f,
|
|
731
|
+
tt as g,
|
|
732
|
+
ve as h,
|
|
733
|
+
q as i,
|
|
734
|
+
rt as r,
|
|
735
|
+
xt as u
|
|
736
|
+
};
|
|
737
|
+
//# sourceMappingURL=useDynamicForm-C6-0mGw4.js.map
|