@bach.software/vue-dynamic-form 0.6.0 → 0.8.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 +5 -5
- package/dist/examples.cjs.js.map +1 -1
- package/dist/examples.es.js +709 -492
- package/dist/examples.es.js.map +1 -1
- package/dist/mapEachMetadataItem-CZmoxEoA.js +1234 -0
- package/dist/mapEachMetadataItem-CZmoxEoA.js.map +1 -0
- package/dist/mapEachMetadataItem-Dw1U9jf2.cjs +2 -0
- package/dist/mapEachMetadataItem-Dw1U9jf2.cjs.map +1 -0
- package/dist/src/components/__tests__/DynamicFormItem.formApi.test.d.ts +1 -0
- package/dist/src/components/__tests__/DynamicFormItem.test-helpers.d.ts +8 -0
- package/dist/src/components/__tests__/DynamicFormItemArray.formApi.test.d.ts +1 -0
- package/dist/src/components/__tests__/DynamicFormItemArray.test-helpers.d.ts +2 -0
- package/dist/src/components/__tests__/DynamicFormItemChoice.formApi.test.d.ts +1 -0
- package/dist/src/components/__tests__/DynamicFormItemChoice.test-helpers.d.ts +9 -0
- package/dist/src/components/__tests__/DynamicFormItemWizard.formApi.test.d.ts +1 -0
- package/dist/src/core/__tests__/useIsResetPending.test.d.ts +1 -0
- package/dist/src/core/__tests__/useIsValidationSuppressed.test.d.ts +1 -0
- package/dist/src/core/useIsResetPending.d.ts +13 -0
- package/dist/src/core/useIsValidationSuppressed.d.ts +20 -0
- package/dist/src/examples/ProgrammaticWritesTestCase.vue.d.ts +2 -0
- package/dist/src/examples/TestForm.vue.d.ts +6 -1
- package/dist/src/examples/__tests__/TestFormTemplate.testcases.d.ts +270 -37
- package/dist/src/examples/index.d.ts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/types/FieldMetadata.d.ts +32 -1
- package/dist/src/utils/__tests__/deepEqual.test.d.ts +1 -0
- package/dist/src/utils/__tests__/hashField.test.d.ts +1 -0
- package/dist/src/utils/__tests__/isPathInSection.test.d.ts +1 -0
- package/dist/src/utils/buildRestrictionValidations.d.ts +11 -0
- package/dist/src/utils/deepEqual.d.ts +9 -0
- package/dist/src/utils/isPathInSection.d.ts +9 -0
- package/dist/src/utils/removeNullValues.d.ts +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/vue-dynamic-form.cjs.js +1 -1
- package/dist/vue-dynamic-form.cjs.js.map +1 -1
- package/dist/vue-dynamic-form.es.js +22 -21
- package/dist/vue-dynamic-form.es.js.map +1 -1
- package/package.json +4 -3
- package/dist/mapEachMetadataItem-Cxfn86Z2.cjs +0 -2
- package/dist/mapEachMetadataItem-Cxfn86Z2.cjs.map +0 -1
- package/dist/mapEachMetadataItem-Dvf3R5jd.js +0 -1159
- package/dist/mapEachMetadataItem-Dvf3R5jd.js.map +0 -1
|
@@ -0,0 +1,1234 @@
|
|
|
1
|
+
import { computed as o, toValue as ct, nextTick as st, defineComponent as Me, inject as Be, ref as ee, watch as de, watchEffect as dt, createElementBlock as H, openBlock as V, Fragment as ie, withDirectives as vt, createCommentVNode as we, createBlock as _, unref as W, createElementVNode as mt, toDisplayString as ft, isRef as pt, vShow as ht, resolveDynamicComponent as Ie, withCtx as Se, renderList as ye, getCurrentInstance as Bt, createVNode as Nt, onMounted as Tt, onBeforeUnmount as jt, resolveComponent as kt, mergeProps as Je, provide as _t, useSlots as Dt, useAttrs as zt, renderSlot as Ve, normalizeProps as Ce, guardReactiveProps as Ae } from "vue";
|
|
2
|
+
import { useFieldArray as Kt, useFormContext as Ne, defineRule as T, validate as Ge, useValidateField as Wt, useField as ze, useSubmitCount as Ot, useFieldValue as Ye, FormContextKey as He, useForm as Rt } from "vee-validate";
|
|
3
|
+
function yt(e) {
|
|
4
|
+
const { fields: r, ...t } = Kt(e), i = o(() => r.value.map(({ value: l }) => l));
|
|
5
|
+
return {
|
|
6
|
+
fields: r,
|
|
7
|
+
values: i,
|
|
8
|
+
...t
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function xt(e) {
|
|
12
|
+
const r = Ne();
|
|
13
|
+
return () => r?.getPathState?.(ct(e))?.__flags?.pendingReset === !0;
|
|
14
|
+
}
|
|
15
|
+
const Xe = /* @__PURE__ */ new WeakSet(), it = /* @__PURE__ */ new WeakSet();
|
|
16
|
+
function nt(e) {
|
|
17
|
+
Xe.add(e), st(() => Xe.delete(e));
|
|
18
|
+
}
|
|
19
|
+
function gt(e) {
|
|
20
|
+
if (!e || typeof e != "object" || it.has(e))
|
|
21
|
+
return;
|
|
22
|
+
it.add(e);
|
|
23
|
+
const r = e, t = r.setFieldValue?.bind(r);
|
|
24
|
+
t && (r.setFieldValue = (l, u, s = !0) => {
|
|
25
|
+
t(l, u, s), s || nt(e);
|
|
26
|
+
});
|
|
27
|
+
const i = r.setValues?.bind(r);
|
|
28
|
+
i && (r.setValues = (l, u = !0) => {
|
|
29
|
+
i(l, u), u || nt(e);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function bt(e) {
|
|
33
|
+
const r = xt(e), t = Ne();
|
|
34
|
+
return () => r() || !!t && Xe.has(t);
|
|
35
|
+
}
|
|
36
|
+
const Te = /* @__PURE__ */ Symbol("dynamicFormSettings");
|
|
37
|
+
function je(e, r) {
|
|
38
|
+
return Array.isArray(e) ? e[0] : e[r];
|
|
39
|
+
}
|
|
40
|
+
function Pe(e) {
|
|
41
|
+
return !!(e == null || e === "" || Array.isArray(e) && e.length === 0);
|
|
42
|
+
}
|
|
43
|
+
const Ft = (e, r) => {
|
|
44
|
+
if (Pe(e))
|
|
45
|
+
return !0;
|
|
46
|
+
const t = je(r, "length");
|
|
47
|
+
return Array.isArray(e) ? e.every((i) => Ft(i, { length: t })) : [...String(e)].length <= Number(t);
|
|
48
|
+
}, Vt = (e, r) => {
|
|
49
|
+
if (Pe(e))
|
|
50
|
+
return !0;
|
|
51
|
+
const t = je(r, "max");
|
|
52
|
+
return Array.isArray(e) ? e.length > 0 && e.every((i) => Vt(i, { max: t })) : Number(e) <= Number(t);
|
|
53
|
+
}, Ct = (e, r) => {
|
|
54
|
+
if (Pe(e))
|
|
55
|
+
return !0;
|
|
56
|
+
const t = je(r, "length");
|
|
57
|
+
return Array.isArray(e) ? e.every((i) => Ct(i, { length: t })) : [...String(e)].length >= Number(t);
|
|
58
|
+
}, At = (e, r) => {
|
|
59
|
+
if (Pe(e))
|
|
60
|
+
return !0;
|
|
61
|
+
const t = je(r, "min");
|
|
62
|
+
return Array.isArray(e) ? e.length > 0 && e.every((i) => At(i, { min: t })) : Number(e) >= Number(t);
|
|
63
|
+
}, wt = (e, r) => Pe(e) ? !0 : Array.isArray(e) ? e.every((t) => wt(t, r)) : Array.from(r).some((t) => t == e), It = (e, r) => {
|
|
64
|
+
if (Pe(e))
|
|
65
|
+
return !0;
|
|
66
|
+
let t = je(r, "regex");
|
|
67
|
+
return typeof t == "string" && (t = new RegExp(t)), Array.isArray(e) ? e.every((i) => It(i, { regex: t })) : t.test(String(e));
|
|
68
|
+
};
|
|
69
|
+
function ae(e) {
|
|
70
|
+
return e == null ? !1 : Array.isArray(e) ? e.some((r) => ae(r)) : typeof e == "object" ? Object.values(e).some((r) => ae(r)) : !0;
|
|
71
|
+
}
|
|
72
|
+
function qt(e, r, t) {
|
|
73
|
+
return typeof e == "function" ? e(r) : e.replace(/\{(\w+)\}/g, (i, l) => {
|
|
74
|
+
if (l in r)
|
|
75
|
+
return String(r[l]);
|
|
76
|
+
if (t && !Array.isArray(t) && l in t)
|
|
77
|
+
return String(t[l]);
|
|
78
|
+
const u = Number(l);
|
|
79
|
+
return Number.isNaN(u) ? r.rule?.params && !Array.isArray(r.rule.params) ? String(r.rule.params[l] ?? `{${l}}`) : `{${l}}` : Array.isArray(t) && t[u] !== void 0 ? String(t[u]) : String(r.rule?.params?.[u] ?? `{${l}}`);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
T("xsd_required", (e) => e != null && e !== "");
|
|
83
|
+
T("xsd_minOccurs", (e, [r]) => Array.isArray(e) ? e.filter(ae).length >= Number(r) : Number(r) <= 0);
|
|
84
|
+
T("xsd_maxOccurs", (e, [r]) => Array.isArray(e) ? e.length <= Number(r) : !0);
|
|
85
|
+
const Ze = () => !1;
|
|
86
|
+
T("xsd_choiceMinOccurs", Ze);
|
|
87
|
+
T("xsd_choiceMaxOccurs", Ze);
|
|
88
|
+
T("vdf_maxOccursTotal", Ze);
|
|
89
|
+
T("xsd_minLength", Ct);
|
|
90
|
+
T("xsd_maxLength", Ft);
|
|
91
|
+
T("xsd_length", (e, [r]) => e == null || e === "" ? !0 : String(e).length === Number(r));
|
|
92
|
+
T("xsd_pattern", It);
|
|
93
|
+
T("xsd_minInclusive", At);
|
|
94
|
+
T("xsd_maxInclusive", Vt);
|
|
95
|
+
T("xsd_minExclusive", (e, [r]) => e == null || e === "" ? !0 : Number(e) > Number(r));
|
|
96
|
+
T("xsd_maxExclusive", (e, [r]) => e == null || e === "" ? !0 : Number(e) < Number(r));
|
|
97
|
+
T("xsd_enumeration", wt);
|
|
98
|
+
T("xsd_whiteSpace", (e, [r]) => {
|
|
99
|
+
if (e == null || e === "")
|
|
100
|
+
return !0;
|
|
101
|
+
const t = String(e);
|
|
102
|
+
return r === "replace" ? !/[\t\n\r]/.test(t) : r === "collapse" ? t === t.trim() && !/\s{2,}/.test(t) : !0;
|
|
103
|
+
});
|
|
104
|
+
T("xsd_fractionDigits", (e, [r]) => {
|
|
105
|
+
if (e == null || e === "")
|
|
106
|
+
return !0;
|
|
107
|
+
const t = String(e).indexOf(".");
|
|
108
|
+
return t === -1 ? !0 : String(e).length - t - 1 <= Number(r);
|
|
109
|
+
});
|
|
110
|
+
T("xsd_totalDigits", (e, [r]) => e == null || e === "" ? !0 : (String(e).replace(/^-/, "").replace(".", "").replace(/^0+/, "") || "0").length <= Number(r));
|
|
111
|
+
const Lt = {
|
|
112
|
+
xsd_minOccurs: "min",
|
|
113
|
+
xsd_maxOccurs: "max",
|
|
114
|
+
xsd_choiceMinOccurs: "min",
|
|
115
|
+
xsd_choiceMaxOccurs: "max",
|
|
116
|
+
vdf_maxOccursTotal: "max",
|
|
117
|
+
xsd_minLength: "length",
|
|
118
|
+
xsd_maxLength: "length",
|
|
119
|
+
xsd_length: "length",
|
|
120
|
+
xsd_pattern: "pattern",
|
|
121
|
+
xsd_minInclusive: "min",
|
|
122
|
+
xsd_maxInclusive: "max",
|
|
123
|
+
xsd_minExclusive: "min",
|
|
124
|
+
xsd_maxExclusive: "max",
|
|
125
|
+
xsd_whiteSpace: "mode",
|
|
126
|
+
xsd_fractionDigits: "digits",
|
|
127
|
+
xsd_totalDigits: "digits"
|
|
128
|
+
};
|
|
129
|
+
function Qe(e) {
|
|
130
|
+
return e.label ?? e.field ?? e.name ?? "";
|
|
131
|
+
}
|
|
132
|
+
const ut = /* @__PURE__ */ new Map();
|
|
133
|
+
function N(e, r, t) {
|
|
134
|
+
let i = ut.get(e);
|
|
135
|
+
i || ut.set(e, i = /* @__PURE__ */ new Map());
|
|
136
|
+
let l = i.get(r);
|
|
137
|
+
l || i.set(r, l = /* @__PURE__ */ new Map());
|
|
138
|
+
let u = l.get(t);
|
|
139
|
+
return u || l.set(t, u = Jt(e, r, t)), u;
|
|
140
|
+
}
|
|
141
|
+
function Jt(e, r, t) {
|
|
142
|
+
const i = Lt[e], l = r !== void 0 ? { 0: r, ...i ? { [i]: r } : {} } : {};
|
|
143
|
+
return async (u, s) => {
|
|
144
|
+
const m = Qe(s), p = m ? { name: m } : void 0, y = m && s.field !== m ? { ...s, field: m } : s, E = await Ge(
|
|
145
|
+
u,
|
|
146
|
+
r !== void 0 ? { [e]: r } : e,
|
|
147
|
+
p
|
|
148
|
+
);
|
|
149
|
+
return E.valid ? !0 : t ? qt(t, y, l) : E.errors[0];
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function $e(e) {
|
|
153
|
+
return e?.replaceAll(/\[[`'"](.*?)[`'"]\]/g, ".$1") ?? "";
|
|
154
|
+
}
|
|
155
|
+
function se(e, r) {
|
|
156
|
+
if (!e || !r)
|
|
157
|
+
return e;
|
|
158
|
+
const t = r.split(".") ?? [], i = e.split(".") ?? [];
|
|
159
|
+
for (let l = 0; l < t.length; l++)
|
|
160
|
+
i[l] = t[l];
|
|
161
|
+
return i.join(".");
|
|
162
|
+
}
|
|
163
|
+
function et(e) {
|
|
164
|
+
return e ? typeof e == "function" ? [e] : Array.isArray(e) ? e.flatMap(et) : typeof e == "string" ? e.split("|").map((r) => async (t, i) => {
|
|
165
|
+
const l = Qe(i), u = await Ge(t, r, l ? { name: l } : void 0);
|
|
166
|
+
return u.valid ? !0 : u.errors[0];
|
|
167
|
+
}) : Object.entries(e).map(([r, t]) => async (i, l) => {
|
|
168
|
+
const u = Qe(l), s = await Ge(i, { [r]: t }, u ? { name: u } : void 0);
|
|
169
|
+
return s.valid ? !0 : s.errors[0];
|
|
170
|
+
}) : [];
|
|
171
|
+
}
|
|
172
|
+
const Ht = { key: 0 }, Gt = ["data-testid"], Xt = /* @__PURE__ */ Me({
|
|
173
|
+
__name: "DynamicFormItemArray",
|
|
174
|
+
props: {
|
|
175
|
+
template: { type: [Object, Function] },
|
|
176
|
+
fieldMetadata: {},
|
|
177
|
+
pathOverride: {},
|
|
178
|
+
minOccursOverride: {},
|
|
179
|
+
maxOccursOverride: {},
|
|
180
|
+
partOfArrayField: { type: Boolean },
|
|
181
|
+
partOfAttributeField: { type: Boolean },
|
|
182
|
+
attributeOwnerHasValue: { type: Function },
|
|
183
|
+
partOfChoiceField: { type: Boolean },
|
|
184
|
+
isArrayOverride: {},
|
|
185
|
+
branchKey: {},
|
|
186
|
+
globalIndex: {},
|
|
187
|
+
insertionOrder: {},
|
|
188
|
+
index: {},
|
|
189
|
+
canAddItems: { type: Boolean },
|
|
190
|
+
canRemoveItems: { type: Boolean },
|
|
191
|
+
addItem: { type: Function },
|
|
192
|
+
removeItem: { type: Function },
|
|
193
|
+
slotProps: {}
|
|
194
|
+
},
|
|
195
|
+
emits: ["update:modelValue", "update:computedField"],
|
|
196
|
+
setup(e, { emit: r }) {
|
|
197
|
+
const t = e, i = r, l = Be(Te);
|
|
198
|
+
let u = 0;
|
|
199
|
+
const s = o(() => t.fieldMetadata), m = o(() => s.value?.path ? se(s.value.path, t.pathOverride) : ""), p = o(() => $e(m.value)), y = Wt(p), { remove: E, push: D, fields: M, update: P, values: A, replace: $ } = yt(p), F = bt(p), j = o(
|
|
200
|
+
() => t.minOccursOverride !== void 0 ? t.minOccursOverride : s.value?.minOccurs ?? 1
|
|
201
|
+
), U = o(
|
|
202
|
+
() => t.maxOccursOverride !== void 0 ? t.maxOccursOverride : s.value?.maxOccurs ?? 1
|
|
203
|
+
), w = o(() => U.value === 0), ne = o(() => j.value >= 1 && !w.value), B = o(
|
|
204
|
+
() => U.value === 0 ? 0 : 1
|
|
205
|
+
), G = o(() => U.value > M.value?.length), S = o(() => t.partOfChoiceField || s.value?.autoAddMinOccurs === !1 ? M.value?.length > 0 : M.value?.length > j.value && M.value?.length > 1), X = o(() => {
|
|
206
|
+
const x = [], O = l?.value?.messages;
|
|
207
|
+
return ne.value && x.push(N("xsd_minOccurs", j.value, O?.minOccurs)), !w.value && U.value >= j.value && x.push(N("xsd_maxOccurs", U.value, O?.maxOccurs)), s.value?.validation && x.push(...et(s.value?.validation)), x;
|
|
208
|
+
}), ue = ze(p, X, {
|
|
209
|
+
...s.value?.fieldOptions ?? {},
|
|
210
|
+
validateOnValueUpdate: !1
|
|
211
|
+
// validation timing is owned by this component
|
|
212
|
+
}), { label: ve, errors: Q, errorMessage: te, handleBlur: le } = ue, z = { label: ve, errors: Q, errorMessage: te, value: A }, I = Ot(), R = ee(!1), oe = o(() => {
|
|
213
|
+
if (!R.value)
|
|
214
|
+
return;
|
|
215
|
+
const x = l?.value?.validateOnValueUpdateAfterSubmit === !0 ? I.value > 0 && l?.value?.validateOnValueUpdateAfterSubmit : void 0, O = l?.value?.validateWhenInError && z?.errors.value?.length > 0 ? !0 : void 0;
|
|
216
|
+
return s.value?.fieldOptions?.validateOnValueUpdate ?? O ?? x ?? l?.value?.validateOnValueUpdate;
|
|
217
|
+
});
|
|
218
|
+
de(
|
|
219
|
+
A,
|
|
220
|
+
(x) => {
|
|
221
|
+
F() || (oe.value ? y() : ue.validate({ mode: "silent" })), i("update:modelValue", x);
|
|
222
|
+
},
|
|
223
|
+
{ immediate: !0 }
|
|
224
|
+
), dt(() => {
|
|
225
|
+
t.partOfChoiceField || s.value?.autoAddMinOccurs !== !1 && (M.value?.length < 1 || M.value?.length < j.value) && q();
|
|
226
|
+
});
|
|
227
|
+
function q() {
|
|
228
|
+
D(null), i("update:modelValue", A.value);
|
|
229
|
+
}
|
|
230
|
+
function h(x) {
|
|
231
|
+
S.value ? E(x ?? M.value.length - 1) : $(A.value?.map((O, K) => K === x ? null : O)), i("update:modelValue", A.value);
|
|
232
|
+
}
|
|
233
|
+
function g(x, O) {
|
|
234
|
+
R.value || (R.value = !0, oe.value && !F() && y()), x === void 0 && O >= 0 && P(O, void 0), i("update:modelValue", A.value);
|
|
235
|
+
}
|
|
236
|
+
return (x, O) => (V(), H(ie, null, [
|
|
237
|
+
W(l)?.analytics ? vt((V(), H("div", Ht, [
|
|
238
|
+
mt("span", {
|
|
239
|
+
"data-testid": `${m.value}-analytics-render-count`
|
|
240
|
+
}, ft(pt(u) ? ++u.value : ++u), 9, Gt)
|
|
241
|
+
], 512)), [
|
|
242
|
+
[ht, !1]
|
|
243
|
+
]) : we("", !0),
|
|
244
|
+
(V(), _(Ie(e.template), {
|
|
245
|
+
type: `${e.fieldMetadata.type}-array`,
|
|
246
|
+
"field-metadata": e.fieldMetadata,
|
|
247
|
+
"field-context": z,
|
|
248
|
+
"slot-props": e.slotProps,
|
|
249
|
+
settings: W(l),
|
|
250
|
+
required: ne.value,
|
|
251
|
+
disabled: w.value,
|
|
252
|
+
index: e.index,
|
|
253
|
+
"can-add-items": G.value,
|
|
254
|
+
"can-remove-items": S.value,
|
|
255
|
+
"add-item": q,
|
|
256
|
+
"remove-item": h
|
|
257
|
+
}, {
|
|
258
|
+
default: Se((K) => [
|
|
259
|
+
(V(!0), H(ie, null, ye(W(M) ?? [], ({ key: me }, ce) => (V(), _(be, {
|
|
260
|
+
key: me,
|
|
261
|
+
"field-metadata": e.fieldMetadata,
|
|
262
|
+
"path-override": `${m.value}[${ce}]`,
|
|
263
|
+
index: ce,
|
|
264
|
+
template: e.template,
|
|
265
|
+
"slot-props": K,
|
|
266
|
+
"max-occurs-override": B.value,
|
|
267
|
+
"can-add-items": G.value,
|
|
268
|
+
"can-remove-items": S.value,
|
|
269
|
+
"add-item": q,
|
|
270
|
+
"remove-item": () => h(ce),
|
|
271
|
+
"part-of-array-field": "",
|
|
272
|
+
"is-array-override": "single",
|
|
273
|
+
"onUpdate:modelValue": (he) => g(he, ce),
|
|
274
|
+
"onUpdate:computedField": O[0] || (O[0] = (he) => i("update:computedField", he)),
|
|
275
|
+
onBlur: W(le)
|
|
276
|
+
}, 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))
|
|
277
|
+
]),
|
|
278
|
+
_: 1
|
|
279
|
+
}, 8, ["type", "field-metadata", "slot-props", "settings", "required", "disabled", "index", "can-add-items", "can-remove-items"]))
|
|
280
|
+
], 64));
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
function St(e, r, t) {
|
|
284
|
+
const i = e ?? {}, l = [];
|
|
285
|
+
return i.minLength != null && l.push(N("xsd_minLength", i.minLength, t?.minLength)), i.maxLength != null && l.push(N("xsd_maxLength", i.maxLength, t?.maxLength)), i.length != null && l.push(N("xsd_length", i.length, t?.length)), i.pattern != null && l.push(N("xsd_pattern", i.pattern, t?.pattern)), i.minInclusive != null && l.push(N("xsd_minInclusive", i.minInclusive, t?.minInclusive)), i.maxInclusive != null && l.push(N("xsd_maxInclusive", i.maxInclusive, t?.maxInclusive)), i.minExclusive != null && l.push(N("xsd_minExclusive", i.minExclusive, t?.minExclusive)), i.maxExclusive != null && l.push(N("xsd_maxExclusive", i.maxExclusive, t?.maxExclusive)), i.enumeration != null && l.push(N("xsd_enumeration", i.enumeration, t?.enumeration)), i.whiteSpace != null && l.push(N("xsd_whiteSpace", i.whiteSpace, t?.whiteSpace)), i.fractionDigits != null && l.push(N("xsd_fractionDigits", i.fractionDigits, t?.fractionDigits)), i.totalDigits != null && l.push(N("xsd_totalDigits", i.totalDigits, t?.totalDigits)), r && l.push(...et(r)), l;
|
|
286
|
+
}
|
|
287
|
+
function Ee(e) {
|
|
288
|
+
if (e === null || typeof e != "object")
|
|
289
|
+
return e;
|
|
290
|
+
if (e instanceof Date)
|
|
291
|
+
return new Date(e);
|
|
292
|
+
if (Array.isArray(e))
|
|
293
|
+
return e.map((t) => Ee(t));
|
|
294
|
+
const r = {};
|
|
295
|
+
for (const t of Object.keys(e))
|
|
296
|
+
r[t] = Ee(e[t]);
|
|
297
|
+
return r;
|
|
298
|
+
}
|
|
299
|
+
const Qt = /* @__PURE__ */ Me({
|
|
300
|
+
__name: "DynamicFormItemChoice",
|
|
301
|
+
props: {
|
|
302
|
+
template: { type: [Object, Function] },
|
|
303
|
+
fieldMetadata: {},
|
|
304
|
+
pathOverride: {},
|
|
305
|
+
minOccursOverride: {},
|
|
306
|
+
maxOccursOverride: {},
|
|
307
|
+
partOfArrayField: { type: Boolean },
|
|
308
|
+
partOfAttributeField: { type: Boolean },
|
|
309
|
+
attributeOwnerHasValue: { type: Function },
|
|
310
|
+
partOfChoiceField: { type: Boolean },
|
|
311
|
+
isArrayOverride: {},
|
|
312
|
+
branchKey: {},
|
|
313
|
+
globalIndex: {},
|
|
314
|
+
insertionOrder: {},
|
|
315
|
+
index: {},
|
|
316
|
+
canAddItems: { type: Boolean },
|
|
317
|
+
canRemoveItems: { type: Boolean },
|
|
318
|
+
addItem: { type: Function },
|
|
319
|
+
removeItem: { type: Function },
|
|
320
|
+
slotProps: {}
|
|
321
|
+
},
|
|
322
|
+
emits: ["update:modelValue", "update:computedField"],
|
|
323
|
+
setup(e, { emit: r }) {
|
|
324
|
+
const t = e, i = r, l = Be(Te), u = o(() => t.fieldMetadata), s = o(() => se(u.value.path ?? "", t.pathOverride)), m = o(() => $e(s.value)), p = t.fieldMetadata?.explicitChoiceSelection === !0, y = o(() => u.value?.preserveOnSwitch === !0), E = o(() => u.value?.displayOrder === "added"), D = o(() => u.value?.preserveOrder === !0), M = (u.value?.choice ?? []).every((a) => (a.children?.length ?? 0) > 0), P = o(() => D.value && M), A = Ne(), $ = ee(null), F = ee({}), j = ee(/* @__PURE__ */ new Map());
|
|
325
|
+
let U = 0;
|
|
326
|
+
const w = (u.value?.choice ?? []).map(
|
|
327
|
+
(a) => Ye(() => a.path ? se(a.path, t.pathOverride) : "")
|
|
328
|
+
), ne = (u.value?.choice ?? []).map((a) => o(() => a.path ? $e(se(a.path, t.pathOverride)) : "")), B = ne.map((a) => yt(a)), G = o(
|
|
329
|
+
() => t.minOccursOverride !== void 0 ? t.minOccursOverride : u.value?.minOccurs ?? 1
|
|
330
|
+
), S = o(
|
|
331
|
+
() => t.maxOccursOverride !== void 0 ? t.maxOccursOverride : u.value?.maxOccurs ?? 1
|
|
332
|
+
), X = o(() => S.value === 0), ue = o(() => G.value >= 1 && !X.value), ve = o(
|
|
333
|
+
() => G.value === 0 ? 0 : void 0
|
|
334
|
+
), Q = o(
|
|
335
|
+
() => S.value === 0 ? 0 : void 0
|
|
336
|
+
), te = o(() => u.value?.maxOccurs > 1 ? "array" : void 0), le = o(() => `${u.value?.type}${u.value?.maxOccurs > 1 ? "-choice-array" : "-choice"}`), z = ee({}), I = o(() => Object.values(z.value).map((a) => a.value)), R = o(
|
|
337
|
+
() => !p && u.value?.choice?.length === 1 ? u.value?.choice[0] : void 0
|
|
338
|
+
), oe = o(() => {
|
|
339
|
+
if (Q.value === 0)
|
|
340
|
+
return 0;
|
|
341
|
+
const a = R.value;
|
|
342
|
+
return a?.maxOccursTotal === void 0 ? Q.value : Math.min(a.maxOccursTotal, a.maxOccurs ?? 1);
|
|
343
|
+
}), q = o(() => {
|
|
344
|
+
const a = {};
|
|
345
|
+
u.value?.choice?.forEach((c, d) => {
|
|
346
|
+
a[d] = {
|
|
347
|
+
childValuesCount: 0,
|
|
348
|
+
childOccurrences: 0,
|
|
349
|
+
childMaxOccurrences: 1,
|
|
350
|
+
choiceValuesCount: 0,
|
|
351
|
+
choiceOccurrences: 0,
|
|
352
|
+
overrideChildMaxOccurrences: void 0,
|
|
353
|
+
overrideChildMinOccurrences: 0,
|
|
354
|
+
// children are optional by default inside a choice
|
|
355
|
+
maxOccursTotal: c.maxOccursTotal
|
|
356
|
+
};
|
|
357
|
+
});
|
|
358
|
+
const n = S.value ?? 1;
|
|
359
|
+
if (n === 0)
|
|
360
|
+
return u.value?.choice?.forEach((c, d) => {
|
|
361
|
+
a[d].overrideChildMaxOccurrences = 0, a[d].overrideChildMinOccurrences = 0;
|
|
362
|
+
}), a;
|
|
363
|
+
for (const [c, d] of Object.entries(z.value ?? {})) {
|
|
364
|
+
let b = Math.ceil(d.occurrences / d.maxOccurrences);
|
|
365
|
+
const k = Math.ceil(d.valuesCount / d.maxOccurrences);
|
|
366
|
+
n * d.maxOccurrences === 1 && (b = k), a[c] = {
|
|
367
|
+
childValuesCount: d.valuesCount,
|
|
368
|
+
childOccurrences: d.occurrences,
|
|
369
|
+
childMaxOccurrences: d.maxOccurrences,
|
|
370
|
+
choiceOccurrences: b,
|
|
371
|
+
choiceValuesCount: k,
|
|
372
|
+
overrideChildMinOccurrences: d.valuesCount === 0 ? 0 : void 0,
|
|
373
|
+
// optional when empty
|
|
374
|
+
overrideChildMaxOccurrences: void 0,
|
|
375
|
+
// calculated in pass 2
|
|
376
|
+
maxOccursTotal: u.value?.choice?.[Number(c)]?.maxOccursTotal
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
const v = Object.values(a).reduce(
|
|
380
|
+
(c, d) => c + d.choiceOccurrences,
|
|
381
|
+
0
|
|
382
|
+
);
|
|
383
|
+
return Object.values(a).forEach((c) => {
|
|
384
|
+
const b = (v - c.choiceOccurrences) * c.childMaxOccurrences, k = n * c.childMaxOccurrences;
|
|
385
|
+
let pe = Math.max(
|
|
386
|
+
k - b,
|
|
387
|
+
c.childValuesCount
|
|
388
|
+
);
|
|
389
|
+
c.maxOccursTotal !== void 0 && (pe = Math.min(pe, c.maxOccursTotal)), c.overrideChildMaxOccurrences = pe;
|
|
390
|
+
}), a;
|
|
391
|
+
}), h = o(
|
|
392
|
+
() => Object.values(q.value).reduce(
|
|
393
|
+
(a, n) => a + n.choiceValuesCount,
|
|
394
|
+
0
|
|
395
|
+
)
|
|
396
|
+
), g = o(() => {
|
|
397
|
+
const a = [];
|
|
398
|
+
return u.value?.choice?.forEach((n, v) => {
|
|
399
|
+
if (p && S.value > 1) {
|
|
400
|
+
(B[v]?.fields.value ?? []).forEach((at, ge) => {
|
|
401
|
+
a.push({ branchKey: n.name, index: ge });
|
|
402
|
+
});
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
const c = p && (n.children?.length ?? 0) === 0 && n.presenceValue !== void 0, d = w[v]?.value, b = c ? d !== void 0 : ae(d), k = p && $.value === n.name;
|
|
406
|
+
(b || k) && a.push({ branchKey: n.name, index: 0 });
|
|
407
|
+
}), a;
|
|
408
|
+
}), x = o(() => {
|
|
409
|
+
if (!E.value)
|
|
410
|
+
return g.value;
|
|
411
|
+
function a(n) {
|
|
412
|
+
return P.value ? Re(n)?.order : j.value.get(xe(n));
|
|
413
|
+
}
|
|
414
|
+
return g.value.map((n) => ({ occurrence: n, sortKey: a(n) })).sort((n, v) => {
|
|
415
|
+
const c = n.sortKey !== void 0, d = v.sortKey !== void 0;
|
|
416
|
+
return c !== d ? c ? 1 : -1 : c ? n.sortKey - v.sortKey : 0;
|
|
417
|
+
}).map((n) => n.occurrence);
|
|
418
|
+
}), O = o(() => X.value ? 0 : p && S.value > 1 ? B.reduce((a, n, v) => {
|
|
419
|
+
const c = u.value.choice[v].maxOccurs;
|
|
420
|
+
return a + Math.ceil(n.fields.value.length / c);
|
|
421
|
+
}, 0) : p ? g.value.length : h.value), K = o(() => p && S.value === 1 ? Math.max(h.value, g.value.length) : p && S.value > 1 ? Math.max(h.value, O.value) : h.value), me = o(
|
|
422
|
+
() => Object.values(q.value).find((a) => a.maxOccursTotal !== void 0 && a.childOccurrences > a.maxOccursTotal)?.maxOccursTotal
|
|
423
|
+
), ce = o(() => {
|
|
424
|
+
const a = l?.value?.messages, n = St(u.value?.restriction, u.value?.validation, a);
|
|
425
|
+
return R.value || X.value || (K.value < G.value && n.push(N("xsd_choiceMinOccurs", G.value, a?.choiceMinOccurs)), O.value > S.value && n.push(N("xsd_choiceMaxOccurs", S.value, a?.choiceMaxOccurs)), me.value !== void 0 && n.push(N("vdf_maxOccursTotal", me.value, a?.maxOccursTotal))), n.length ? n : void 0;
|
|
426
|
+
}), { errors: he, errorMessage: ke } = ze(m, ce, u.value?.fieldOptions), _e = { label: u.value?.fieldOptions?.label, errors: he, errorMessage: ke, value: I };
|
|
427
|
+
if (de(u, (a) => {
|
|
428
|
+
a && a.choice?.forEach((n, v) => {
|
|
429
|
+
v in z.value || Oe(void 0, v, n.maxOccurs);
|
|
430
|
+
});
|
|
431
|
+
}, { immediate: !0 }), p) {
|
|
432
|
+
const a = xt(m);
|
|
433
|
+
de(a, (n) => {
|
|
434
|
+
n && ($.value = null, F.value = {});
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
p && de(
|
|
438
|
+
() => B.map((a) => a.values.value),
|
|
439
|
+
(a) => {
|
|
440
|
+
S.value <= 1 || a.forEach((n, v) => {
|
|
441
|
+
const c = u.value.choice[v].maxOccurs;
|
|
442
|
+
Oe(n, v, c);
|
|
443
|
+
});
|
|
444
|
+
},
|
|
445
|
+
{ immediate: !0 }
|
|
446
|
+
);
|
|
447
|
+
function Oe(a, n, v = 1, c = !1) {
|
|
448
|
+
if (c) {
|
|
449
|
+
i("update:modelValue", I.value);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
if (n === void 0)
|
|
453
|
+
return;
|
|
454
|
+
let d = Array.isArray(a) ? a : [a];
|
|
455
|
+
(S.value ?? 1) * v === 1 && (d = d.filter((Le) => Le !== void 0));
|
|
456
|
+
const pe = d.length, at = d.filter((Le) => ae(Le)).length, ge = z.value[n] ?? {};
|
|
457
|
+
ge.value = a, ge.occurrences = pe, ge.valuesCount = at, ge.maxOccurrences = v, z.value[n] || (z.value[n] = ge), i("update:modelValue", I.value);
|
|
458
|
+
}
|
|
459
|
+
function J(a) {
|
|
460
|
+
return u.value?.choice?.findIndex((n) => n.name === a) ?? -1;
|
|
461
|
+
}
|
|
462
|
+
function Ue(a) {
|
|
463
|
+
if (Q.value === 0)
|
|
464
|
+
return 0;
|
|
465
|
+
const n = re(a);
|
|
466
|
+
return n?.maxOccursTotal === void 0 ? Q.value : Math.min(n.maxOccursTotal, n.maxOccurs ?? 1);
|
|
467
|
+
}
|
|
468
|
+
function re(a) {
|
|
469
|
+
const n = J(a);
|
|
470
|
+
return n >= 0 ? u.value?.choice?.[n] : void 0;
|
|
471
|
+
}
|
|
472
|
+
function fe(a, n = {}) {
|
|
473
|
+
const v = J(a);
|
|
474
|
+
if (v < 0)
|
|
475
|
+
return;
|
|
476
|
+
const c = u.value?.choice?.[v], d = c?.path ? se(c.path, t.pathOverride) : void 0;
|
|
477
|
+
n.stash ? F.value[a] = Ee(w[v]?.value ?? void 0) : a in F.value && delete F.value[a], d && A?.setFieldValue(d, void 0, !1);
|
|
478
|
+
const b = z.value[v];
|
|
479
|
+
b && (b.value = void 0, b.occurrences = 0, b.valuesCount = 0);
|
|
480
|
+
}
|
|
481
|
+
function Ke(a) {
|
|
482
|
+
if (!y.value || !(a in F.value))
|
|
483
|
+
return;
|
|
484
|
+
const n = J(a), v = se(u.value.choice[n].path, t.pathOverride);
|
|
485
|
+
A?.setFieldValue(v, F.value[a], !1);
|
|
486
|
+
}
|
|
487
|
+
function f(a) {
|
|
488
|
+
if (!L(a))
|
|
489
|
+
return;
|
|
490
|
+
const n = J(a);
|
|
491
|
+
if (S.value > 1) {
|
|
492
|
+
const v = B[n]?.fields.value.length ?? 0, c = g.value.length;
|
|
493
|
+
P.value ? B[n]?.push({ order: c + 1 }) : B[n]?.push(null), j.value.set(xe({ branchKey: a, index: v }), ++U);
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
if ($.value !== a) {
|
|
497
|
+
for (const v of g.value)
|
|
498
|
+
v.branchKey !== a && fe(v.branchKey, { stash: y.value });
|
|
499
|
+
Ke(a), C(a), $.value = a;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function C(a) {
|
|
503
|
+
const n = re(a);
|
|
504
|
+
if (!n || n.presenceValue === void 0 || (n.children?.length ?? 0) > 0)
|
|
505
|
+
return;
|
|
506
|
+
const v = J(a);
|
|
507
|
+
if (w[v]?.value !== void 0)
|
|
508
|
+
return;
|
|
509
|
+
const c = n.path ? se(n.path, t.pathOverride) : void 0;
|
|
510
|
+
c && (A?.setFieldValue(c, n.presenceValue, !1), st(() => {
|
|
511
|
+
const d = A?.setFieldInitialValue;
|
|
512
|
+
d?.(c, void 0, !0);
|
|
513
|
+
}));
|
|
514
|
+
}
|
|
515
|
+
function Y(a, n) {
|
|
516
|
+
const v = J(a);
|
|
517
|
+
if (v < 0)
|
|
518
|
+
return;
|
|
519
|
+
if (S.value > 1) {
|
|
520
|
+
const d = B[v]?.fields.value.length ?? 0, b = n ?? d - 1;
|
|
521
|
+
if (b < 0 || b >= d)
|
|
522
|
+
return;
|
|
523
|
+
const k = xe({ branchKey: a, index: b });
|
|
524
|
+
B[v]?.remove(b), j.value.delete(k), P.value && tt();
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
g.value.some((d) => d.branchKey === a) && (fe(a), $.value === a && ($.value = null));
|
|
528
|
+
}
|
|
529
|
+
function L(a) {
|
|
530
|
+
if (X.value)
|
|
531
|
+
return !1;
|
|
532
|
+
const n = J(a);
|
|
533
|
+
if (n < 0)
|
|
534
|
+
return !1;
|
|
535
|
+
if (S.value <= 1)
|
|
536
|
+
return !0;
|
|
537
|
+
const v = B[n].fields.value.length, c = q.value[n]?.overrideChildMaxOccurrences;
|
|
538
|
+
return c === void 0 || v < c;
|
|
539
|
+
}
|
|
540
|
+
function Z(a) {
|
|
541
|
+
return B[J(a)];
|
|
542
|
+
}
|
|
543
|
+
function Fe(a) {
|
|
544
|
+
return Z(a.branchKey).fields.value[a.index].key;
|
|
545
|
+
}
|
|
546
|
+
function xe(a) {
|
|
547
|
+
return `${a.branchKey}:${Fe(a)}`;
|
|
548
|
+
}
|
|
549
|
+
function We(a) {
|
|
550
|
+
return `${ne[J(a.branchKey)].value}[${a.index}]`;
|
|
551
|
+
}
|
|
552
|
+
function Re(a) {
|
|
553
|
+
return Z(a.branchKey).fields.value[a.index].value;
|
|
554
|
+
}
|
|
555
|
+
function tt() {
|
|
556
|
+
const a = g.value, n = a.length;
|
|
557
|
+
a.map((c, d) => {
|
|
558
|
+
const b = Re(c)?.order, k = j.value.get(xe(c)), pe = b ?? (k !== void 0 ? n + k : d + 1);
|
|
559
|
+
return { occurrence: c, currentOrder: b, sortKey: pe };
|
|
560
|
+
}).sort((c, d) => c.sortKey - d.sortKey).forEach(({ occurrence: c, currentOrder: d }, b) => {
|
|
561
|
+
const k = b + 1;
|
|
562
|
+
d !== k && A?.setFieldValue(`${We(c)}.order`, k, !1);
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
function Pt() {
|
|
566
|
+
g.value.forEach((a) => {
|
|
567
|
+
const n = Re(a);
|
|
568
|
+
n && typeof n == "object" && "order" in n && A?.setFieldValue(`${We(a)}.order`, void 0, !1);
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
const qe = /* @__PURE__ */ new Map();
|
|
572
|
+
function Ut(a) {
|
|
573
|
+
const n = xe(a), v = qe.get(n);
|
|
574
|
+
if (v)
|
|
575
|
+
return v;
|
|
576
|
+
const c = Fe(a), d = () => {
|
|
577
|
+
const b = Z(a.branchKey).fields.value.findIndex((k) => k.key === c);
|
|
578
|
+
b >= 0 && Y(a.branchKey, b), qe.delete(n);
|
|
579
|
+
};
|
|
580
|
+
return qe.set(n, d), d;
|
|
581
|
+
}
|
|
582
|
+
const rt = /* @__PURE__ */ new Map();
|
|
583
|
+
function $t(a) {
|
|
584
|
+
let n = rt.get(a);
|
|
585
|
+
return n || (n = () => f(a), rt.set(a, n)), n;
|
|
586
|
+
}
|
|
587
|
+
const Et = o(() => P.value && p && S.value > 1);
|
|
588
|
+
return de(Et, (a) => {
|
|
589
|
+
a && tt();
|
|
590
|
+
}, { immediate: !0 }), de(P, (a, n) => {
|
|
591
|
+
!p || S.value <= 1 || !a && n && Pt();
|
|
592
|
+
}), (a, n) => (V(), _(Ie(e.template), {
|
|
593
|
+
type: le.value,
|
|
594
|
+
"field-metadata": e.fieldMetadata,
|
|
595
|
+
"field-context": _e,
|
|
596
|
+
"slot-props": e.slotProps,
|
|
597
|
+
settings: W(l),
|
|
598
|
+
required: ue.value,
|
|
599
|
+
index: e.index,
|
|
600
|
+
disabled: X.value,
|
|
601
|
+
"can-add-items": e.canAddItems,
|
|
602
|
+
"can-remove-items": e.canRemoveItems,
|
|
603
|
+
"add-item": e.addItem,
|
|
604
|
+
"remove-item": e.removeItem,
|
|
605
|
+
"add-choice-occurrence": f,
|
|
606
|
+
"remove-choice-occurrence": Y,
|
|
607
|
+
"can-add-choice-occurrence": L,
|
|
608
|
+
"active-choice-occurrences": g.value,
|
|
609
|
+
"used-choice-occurrences": O.value
|
|
610
|
+
}, {
|
|
611
|
+
default: Se((v) => [
|
|
612
|
+
R.value ? (V(), _(be, {
|
|
613
|
+
key: 0,
|
|
614
|
+
"field-metadata": R.value,
|
|
615
|
+
"path-override": e.pathOverride,
|
|
616
|
+
template: e.template,
|
|
617
|
+
"slot-props": v,
|
|
618
|
+
"min-occurs-override": ve.value,
|
|
619
|
+
"max-occurs-override": oe.value,
|
|
620
|
+
"part-of-choice-field": "",
|
|
621
|
+
"onUpdate:modelValue": n[0] || (n[0] = (c) => Oe(c, 0, R.value.maxOccurs, !0)),
|
|
622
|
+
"onUpdate:computedField": n[1] || (n[1] = (c) => i("update:computedField", c))
|
|
623
|
+
}, null, 8, ["field-metadata", "path-override", "template", "slot-props", "min-occurs-override", "max-occurs-override"])) : p && S.value === 1 ? (V(!0), H(ie, { key: 1 }, ye(g.value, (c) => (V(), _(be, {
|
|
624
|
+
key: c.branchKey,
|
|
625
|
+
"field-metadata": re(c.branchKey),
|
|
626
|
+
"path-override": e.pathOverride,
|
|
627
|
+
index: J(c.branchKey),
|
|
628
|
+
template: e.template,
|
|
629
|
+
"slot-props": v,
|
|
630
|
+
"min-occurs-override": ve.value,
|
|
631
|
+
"max-occurs-override": Ue(c.branchKey),
|
|
632
|
+
"is-array-override": te.value,
|
|
633
|
+
"part-of-choice-field": "",
|
|
634
|
+
"onUpdate:modelValue": (d) => Oe(d, J(c.branchKey), re(c.branchKey).maxOccurs),
|
|
635
|
+
"onUpdate:computedField": n[2] || (n[2] = (d) => i("update:computedField", d))
|
|
636
|
+
}, null, 8, ["field-metadata", "path-override", "index", "template", "slot-props", "min-occurs-override", "max-occurs-override", "is-array-override", "onUpdate:modelValue"]))), 128)) : p ? (V(!0), H(ie, { key: 2 }, ye(x.value, (c, d) => (V(), _(be, {
|
|
637
|
+
key: xe(c),
|
|
638
|
+
"field-metadata": re(c.branchKey),
|
|
639
|
+
"path-override": We(c),
|
|
640
|
+
index: c.index,
|
|
641
|
+
template: e.template,
|
|
642
|
+
"slot-props": v,
|
|
643
|
+
"max-occurs-override": 1,
|
|
644
|
+
"is-array-override": "single",
|
|
645
|
+
"part-of-array-field": "",
|
|
646
|
+
"part-of-choice-field": "",
|
|
647
|
+
"branch-key": c.branchKey,
|
|
648
|
+
"global-index": d,
|
|
649
|
+
"insertion-order": j.value.get(xe(c)),
|
|
650
|
+
"can-add-items": L(c.branchKey),
|
|
651
|
+
"add-item": $t(c.branchKey),
|
|
652
|
+
"can-remove-items": !0,
|
|
653
|
+
"remove-item": Ut(c),
|
|
654
|
+
"onUpdate:computedField": n[3] || (n[3] = (b) => i("update:computedField", b))
|
|
655
|
+
}, null, 8, ["field-metadata", "path-override", "index", "template", "slot-props", "branch-key", "global-index", "insertion-order", "can-add-items", "add-item", "remove-item"]))), 128)) : (V(!0), H(ie, { key: 3 }, ye(u.value.choice, (c, d) => (V(), _(be, {
|
|
656
|
+
key: c.name,
|
|
657
|
+
"field-metadata": c,
|
|
658
|
+
"path-override": e.pathOverride,
|
|
659
|
+
index: d,
|
|
660
|
+
template: e.template,
|
|
661
|
+
"slot-props": v,
|
|
662
|
+
"min-occurs-override": q.value[d]?.overrideChildMinOccurrences,
|
|
663
|
+
"max-occurs-override": q.value[d]?.overrideChildMaxOccurrences,
|
|
664
|
+
"is-array-override": te.value,
|
|
665
|
+
"part-of-choice-field": "",
|
|
666
|
+
"onUpdate:modelValue": (b) => Oe(b, d, c.maxOccurs),
|
|
667
|
+
"onUpdate:computedField": n[4] || (n[4] = (b) => i("update:computedField", b))
|
|
668
|
+
}, null, 8, ["field-metadata", "path-override", "index", "template", "slot-props", "min-occurs-override", "max-occurs-override", "is-array-override", "onUpdate:modelValue"]))), 128))
|
|
669
|
+
]),
|
|
670
|
+
_: 1
|
|
671
|
+
}, 8, ["type", "field-metadata", "slot-props", "settings", "required", "index", "disabled", "can-add-items", "can-remove-items", "add-item", "remove-item", "active-choice-occurrences", "used-choice-occurrences"]));
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
function Yt(e, r) {
|
|
675
|
+
return e === r || e.startsWith(`${r}.`) || e.startsWith(`${r}[`);
|
|
676
|
+
}
|
|
677
|
+
function Zt() {
|
|
678
|
+
const r = Bt()?.provides;
|
|
679
|
+
return r && He in r ? r[He] : Be(He);
|
|
680
|
+
}
|
|
681
|
+
function Mt() {
|
|
682
|
+
const e = Zt();
|
|
683
|
+
async function r(t) {
|
|
684
|
+
const i = e.getAllPathStates().map((m) => m.path).filter((m) => Yt(m, t)), l = await Promise.all(
|
|
685
|
+
i.map(async (m) => ({
|
|
686
|
+
path: m,
|
|
687
|
+
result: await e.validateField(m)
|
|
688
|
+
}))
|
|
689
|
+
), u = Object.fromEntries(
|
|
690
|
+
l.map(({ path: m, result: p }) => [m, p])
|
|
691
|
+
), s = Object.fromEntries(
|
|
692
|
+
l.filter(({ result: m }) => !m.valid).map(({ path: m, result: p }) => [m, p.errors[0] ?? ""])
|
|
693
|
+
);
|
|
694
|
+
return {
|
|
695
|
+
valid: l.every(({ result: m }) => m.valid),
|
|
696
|
+
results: u,
|
|
697
|
+
errors: s,
|
|
698
|
+
source: "fields"
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
return { validateSection: r };
|
|
702
|
+
}
|
|
703
|
+
const er = /* @__PURE__ */ Me({
|
|
704
|
+
__name: "DynamicFormItemWizard",
|
|
705
|
+
props: {
|
|
706
|
+
template: { type: [Object, Function] },
|
|
707
|
+
fieldMetadata: {},
|
|
708
|
+
pathOverride: {},
|
|
709
|
+
minOccursOverride: {},
|
|
710
|
+
maxOccursOverride: {},
|
|
711
|
+
partOfArrayField: { type: Boolean },
|
|
712
|
+
partOfAttributeField: { type: Boolean },
|
|
713
|
+
attributeOwnerHasValue: { type: Function },
|
|
714
|
+
partOfChoiceField: { type: Boolean },
|
|
715
|
+
isArrayOverride: {},
|
|
716
|
+
branchKey: {},
|
|
717
|
+
globalIndex: {},
|
|
718
|
+
insertionOrder: {},
|
|
719
|
+
index: {},
|
|
720
|
+
canAddItems: { type: Boolean },
|
|
721
|
+
canRemoveItems: { type: Boolean },
|
|
722
|
+
addItem: { type: Function },
|
|
723
|
+
removeItem: { type: Function },
|
|
724
|
+
slotProps: {}
|
|
725
|
+
},
|
|
726
|
+
emits: ["update:modelValue", "update:computedField"],
|
|
727
|
+
setup(e, { emit: r }) {
|
|
728
|
+
const t = e, i = r, l = Be(Te), { validateSection: u } = Mt(), s = o(() => t.fieldMetadata), m = o(() => se(s.value?.path ?? "", t.pathOverride)), p = o(() => $e(m.value)), { errors: y, errorMessage: E, value: D } = ze(p, void 0, s.value?.fieldOptions), M = { label: s.value?.fieldOptions?.label, errors: y, errorMessage: E, value: o(() => {
|
|
729
|
+
}) };
|
|
730
|
+
(s.value?.maxOccurs ?? 1) > 1 && console.warn(`[DynamicFormItemWizard] "${s.value.path}": "maxOccurs" is ignored on a wizard node; wizard pages come from "children" only.`);
|
|
731
|
+
const P = o(() => s.value?.children ?? []), A = o(() => P.value.length), $ = (() => {
|
|
732
|
+
const h = t.fieldMetadata?.wizard, g = typeof h == "object" && h !== null ? h : {};
|
|
733
|
+
return {
|
|
734
|
+
allowForwardJump: g.allowForwardJump === !0,
|
|
735
|
+
// Defaults on: forward movement runs validation so page errors surface. `false` opts into a
|
|
736
|
+
// silent jump. Only meaningful when the move does not block (non-linear mode or a jump);
|
|
737
|
+
// linear `next` always validates because it needs the result to decide whether to block.
|
|
738
|
+
validateOnJump: g.validateOnJump !== !1
|
|
739
|
+
};
|
|
740
|
+
})(), F = ee(0), j = ee(!1), U = o(() => F.value === 0), w = o(() => A.value === 0 ? !0 : F.value === A.value - 1), ne = o(() => t.minOccursOverride !== void 0 ? t.minOccursOverride : s.value?.minOccurs ?? 1), B = o(() => t.maxOccursOverride !== void 0 ? t.maxOccursOverride : s.value?.maxOccurs ?? 1), G = o(() => B.value === 0), S = o(() => ne.value >= 1 && !G.value), X = o(() => {
|
|
741
|
+
if (t.minOccursOverride === 0)
|
|
742
|
+
return 0;
|
|
743
|
+
if (!(ne.value > 0))
|
|
744
|
+
return ae(D.value) ? void 0 : 0;
|
|
745
|
+
}), ue = o(
|
|
746
|
+
() => B.value === 0 ? 0 : void 0
|
|
747
|
+
);
|
|
748
|
+
function ve() {
|
|
749
|
+
const h = P.value[F.value];
|
|
750
|
+
return h?.path ? se(h.path, t.pathOverride) : void 0;
|
|
751
|
+
}
|
|
752
|
+
async function Q() {
|
|
753
|
+
const h = ve();
|
|
754
|
+
if (!h)
|
|
755
|
+
return !0;
|
|
756
|
+
j.value = !0;
|
|
757
|
+
try {
|
|
758
|
+
return (await u(h)).valid;
|
|
759
|
+
} finally {
|
|
760
|
+
j.value = !1;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
async function te() {
|
|
764
|
+
if (A.value === 0 || w.value)
|
|
765
|
+
return;
|
|
766
|
+
if ($.allowForwardJump)
|
|
767
|
+
return z(F.value + 1);
|
|
768
|
+
const h = F.value;
|
|
769
|
+
await Q() && F.value === h && (F.value = h + 1);
|
|
770
|
+
}
|
|
771
|
+
function le() {
|
|
772
|
+
A.value === 0 || F.value === 0 || F.value--;
|
|
773
|
+
}
|
|
774
|
+
async function z(h, g) {
|
|
775
|
+
if (A.value === 0)
|
|
776
|
+
return;
|
|
777
|
+
const x = Math.min(Math.max(h, 0), A.value - 1), O = F.value;
|
|
778
|
+
x !== O && (x > O && (!(g?.allowForwardJump ?? $.allowForwardJump) || (g?.validateOnJump ?? $.validateOnJump) && (await Q(), F.value !== O)) || (F.value = x));
|
|
779
|
+
}
|
|
780
|
+
function I(h) {
|
|
781
|
+
i("update:computedField", h);
|
|
782
|
+
}
|
|
783
|
+
const R = /* @__PURE__ */ new Map();
|
|
784
|
+
function oe(h, g) {
|
|
785
|
+
const x = g ?? {}, O = R.get(h);
|
|
786
|
+
return O && q(O, x) ? O : (R.set(h, x), x);
|
|
787
|
+
}
|
|
788
|
+
function q(h, g) {
|
|
789
|
+
const x = Object.keys(h), O = Object.keys(g);
|
|
790
|
+
return x.length === O.length && x.every((K) => Object.is(h[K], g[K]));
|
|
791
|
+
}
|
|
792
|
+
return (h, g) => (V(), _(Ie(e.template), {
|
|
793
|
+
type: `${e.fieldMetadata.type}-wizard`,
|
|
794
|
+
"field-metadata": e.fieldMetadata,
|
|
795
|
+
"field-context": M,
|
|
796
|
+
"slot-props": e.slotProps,
|
|
797
|
+
settings: W(l),
|
|
798
|
+
required: S.value,
|
|
799
|
+
disabled: G.value,
|
|
800
|
+
index: e.index,
|
|
801
|
+
"can-add-items": e.canAddItems,
|
|
802
|
+
"can-remove-items": e.canRemoveItems,
|
|
803
|
+
"add-item": e.addItem,
|
|
804
|
+
"remove-item": e.removeItem,
|
|
805
|
+
"current-step-index": F.value,
|
|
806
|
+
pages: P.value,
|
|
807
|
+
"page-count": A.value,
|
|
808
|
+
"is-first": U.value,
|
|
809
|
+
"is-last": w.value,
|
|
810
|
+
"is-validating": j.value,
|
|
811
|
+
"wizard-config": W($),
|
|
812
|
+
next: te,
|
|
813
|
+
prev: le,
|
|
814
|
+
"goto-step": z
|
|
815
|
+
}, {
|
|
816
|
+
default: Se((x) => [
|
|
817
|
+
(V(!0), H(ie, null, ye(P.value, (O, K) => (V(), _(Ie(e.template), {
|
|
818
|
+
key: O.path,
|
|
819
|
+
type: `${O.type}-wizard-page`,
|
|
820
|
+
"field-metadata": O,
|
|
821
|
+
"field-context": M,
|
|
822
|
+
"slot-props": oe("wizard", x),
|
|
823
|
+
settings: W(l),
|
|
824
|
+
required: !1,
|
|
825
|
+
disabled: !1,
|
|
826
|
+
index: K,
|
|
827
|
+
"is-current": K === F.value,
|
|
828
|
+
"page-index": K,
|
|
829
|
+
"current-step-index": F.value,
|
|
830
|
+
"is-first": U.value,
|
|
831
|
+
"is-last": w.value,
|
|
832
|
+
"wizard-config": W($),
|
|
833
|
+
next: te,
|
|
834
|
+
prev: le,
|
|
835
|
+
"goto-step": z
|
|
836
|
+
}, {
|
|
837
|
+
default: Se((me) => [
|
|
838
|
+
Nt(be, {
|
|
839
|
+
"field-metadata": O,
|
|
840
|
+
"path-override": e.pathOverride,
|
|
841
|
+
index: K,
|
|
842
|
+
template: e.template,
|
|
843
|
+
"slot-props": oe(`page:${O.path}`, me),
|
|
844
|
+
"min-occurs-override": X.value,
|
|
845
|
+
"max-occurs-override": ue.value,
|
|
846
|
+
"onUpdate:modelValue": g[0] || (g[0] = (ce) => i("update:modelValue", ce)),
|
|
847
|
+
"onUpdate:computedField": I
|
|
848
|
+
}, null, 8, ["field-metadata", "path-override", "index", "template", "slot-props", "min-occurs-override", "max-occurs-override"])
|
|
849
|
+
]),
|
|
850
|
+
_: 2
|
|
851
|
+
}, 1032, ["type", "field-metadata", "slot-props", "settings", "index", "is-current", "page-index", "current-step-index", "is-first", "is-last", "wizard-config"]))), 128))
|
|
852
|
+
]),
|
|
853
|
+
_: 1
|
|
854
|
+
}, 8, ["type", "field-metadata", "slot-props", "settings", "required", "disabled", "index", "can-add-items", "can-remove-items", "add-item", "remove-item", "current-step-index", "pages", "page-count", "is-first", "is-last", "is-validating", "wizard-config"]));
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
function De(e, r) {
|
|
858
|
+
if (e === r || Number.isNaN(e) && Number.isNaN(r))
|
|
859
|
+
return !0;
|
|
860
|
+
if (typeof e != "object" || typeof r != "object" || e === null || r === null)
|
|
861
|
+
return !1;
|
|
862
|
+
if (e instanceof Date || r instanceof Date)
|
|
863
|
+
return e instanceof Date && r instanceof Date && e.getTime() === r.getTime();
|
|
864
|
+
if (Array.isArray(e) || Array.isArray(r))
|
|
865
|
+
return Array.isArray(e) && Array.isArray(r) && e.length === r.length && e.every((u, s) => De(u, r[s]));
|
|
866
|
+
const t = e, i = r, l = Object.keys(t);
|
|
867
|
+
return l.length === Object.keys(i).length && l.every((u) => u in i && De(t[u], i[u]));
|
|
868
|
+
}
|
|
869
|
+
function tr(e) {
|
|
870
|
+
const {
|
|
871
|
+
name: r,
|
|
872
|
+
path: t,
|
|
873
|
+
children: i,
|
|
874
|
+
choice: l,
|
|
875
|
+
attributes: u,
|
|
876
|
+
fieldOptions: s,
|
|
877
|
+
computedProps: m,
|
|
878
|
+
maxOccurs: p,
|
|
879
|
+
_hash: y,
|
|
880
|
+
parent: E,
|
|
881
|
+
isComplexType: D,
|
|
882
|
+
computeOnChildValueChange: M,
|
|
883
|
+
...P
|
|
884
|
+
} = e, A = Object.fromEntries(
|
|
885
|
+
Object.entries(P).sort(([$], [F]) => $.localeCompare(F))
|
|
886
|
+
);
|
|
887
|
+
return JSON.stringify(A);
|
|
888
|
+
}
|
|
889
|
+
const rr = { key: 0 }, ar = ["data-testid"], lt = 100, be = /* @__PURE__ */ Me({
|
|
890
|
+
__name: "DynamicFormItem",
|
|
891
|
+
props: {
|
|
892
|
+
template: { type: [Object, Function] },
|
|
893
|
+
fieldMetadata: {},
|
|
894
|
+
pathOverride: {},
|
|
895
|
+
minOccursOverride: {},
|
|
896
|
+
maxOccursOverride: {},
|
|
897
|
+
partOfArrayField: { type: Boolean },
|
|
898
|
+
partOfAttributeField: { type: Boolean },
|
|
899
|
+
attributeOwnerHasValue: { type: Function },
|
|
900
|
+
partOfChoiceField: { type: Boolean },
|
|
901
|
+
isArrayOverride: {},
|
|
902
|
+
branchKey: {},
|
|
903
|
+
globalIndex: {},
|
|
904
|
+
insertionOrder: {},
|
|
905
|
+
index: {},
|
|
906
|
+
canAddItems: { type: Boolean },
|
|
907
|
+
canRemoveItems: { type: Boolean },
|
|
908
|
+
addItem: { type: Function },
|
|
909
|
+
removeItem: { type: Function },
|
|
910
|
+
slotProps: {}
|
|
911
|
+
},
|
|
912
|
+
emits: ["update:modelValue", "blur", "update:computedField"],
|
|
913
|
+
setup(e, { emit: r }) {
|
|
914
|
+
const t = e, i = r, l = Be(Te);
|
|
915
|
+
let u = 0, s = 0, m;
|
|
916
|
+
function p(f) {
|
|
917
|
+
if (s++, m == null && (m = setTimeout(() => {
|
|
918
|
+
s = 0, m = void 0;
|
|
919
|
+
}, 0)), s > lt)
|
|
920
|
+
throw new Error(
|
|
921
|
+
`[DynamicFormItem] Possible infinite loop detected in computedProps for field "${f}". computedProps recomputed more than ${lt} times without the event loop turning. Ensure value writes inside computedProps are idempotent (the same input always produces the same output).`
|
|
922
|
+
);
|
|
923
|
+
}
|
|
924
|
+
const y = o(() => t.fieldMetadata), E = o(() => y.value?.path ? se(y.value.path, t.pathOverride) : ""), D = o(() => y.value?.isComplexType || y.value?.attributes?.length), M = o(() => {
|
|
925
|
+
let f = E.value;
|
|
926
|
+
if (D.value && f) {
|
|
927
|
+
const C = l?.value?.complexTypeValueProperty ?? "value";
|
|
928
|
+
f = `${f}['${C}']`;
|
|
929
|
+
}
|
|
930
|
+
return f;
|
|
931
|
+
}), P = o(() => $e(M.value)), A = o(() => t.isArrayOverride === "array" ? !0 : t.isArrayOverride === "single" ? !1 : (y.value?.maxOccurs ?? 1) > 1), $ = o(() => !!y.value?.choice?.length), F = ee([]);
|
|
932
|
+
function j() {
|
|
933
|
+
return $.value ? { value: Ye(P) } : A.value ? { value: ee(void 0) } : ze(P, F, {
|
|
934
|
+
...y.value?.fieldOptions ?? {},
|
|
935
|
+
validateOnValueUpdate: !1
|
|
936
|
+
// validation timing is owned by this component
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
const U = j(), w = U.value, ne = Ne(), B = bt(P);
|
|
940
|
+
U.hasValue = o(() => ae(w.value));
|
|
941
|
+
const G = U.handleBlur;
|
|
942
|
+
U.handleBlur = function(f, C) {
|
|
943
|
+
C = C ?? l?.value?.validateOnBlur, G(f, C), i("blur", f, C);
|
|
944
|
+
};
|
|
945
|
+
const S = U.handleChange;
|
|
946
|
+
U.handleChange = function(f, C) {
|
|
947
|
+
S(f, C === !0);
|
|
948
|
+
};
|
|
949
|
+
const X = o(() => !!y.value?.wizard), ue = o(() => !!y.value?.children?.length), ve = o(() => !A.value && !$.value && !ue.value && !X.value), Q = ee(!0), te = ee(0), le = ee({}), z = o(() => Object.values(le.value)), I = o(() => {
|
|
950
|
+
p(E.value), y.value?.computeOnChildValueChange === !0 && te.value;
|
|
951
|
+
const C = (y.value?.computedProps ?? []).reduce(
|
|
952
|
+
(Y, L) => (L(Y, w, z), Y),
|
|
953
|
+
{ ...y.value, path: E.value }
|
|
954
|
+
);
|
|
955
|
+
return C.path = E.value, C.explicitChoiceSelection = y.value?.explicitChoiceSelection, C.preserveOnSwitch = y.value?.preserveOnSwitch, C.wizard = y.value?.wizard, C._hash = tr(C), C;
|
|
956
|
+
}), R = o(() => t.minOccursOverride !== void 0 ? t.minOccursOverride : t.partOfArrayField ? 0 : I.value?.minOccurs ?? 1), oe = o(
|
|
957
|
+
() => t.maxOccursOverride !== void 0 ? t.maxOccursOverride : I.value?.maxOccurs ?? 1
|
|
958
|
+
), q = o(() => oe.value === 0), h = o(() => R.value >= 1 && !q.value), g = o(() => {
|
|
959
|
+
if (t.minOccursOverride === 0)
|
|
960
|
+
return t.minOccursOverride;
|
|
961
|
+
if (!(R.value > 0) && !ae(w.value))
|
|
962
|
+
return 0;
|
|
963
|
+
}), x = o(
|
|
964
|
+
() => oe.value === 0 ? 0 : void 0
|
|
965
|
+
), O = o(() => t.partOfArrayField && ae(w.value) ? !0 : t.canRemoveItems), K = Ot(), me = o(() => {
|
|
966
|
+
const f = l?.value?.validateOnValueUpdateAfterSubmit === !0 ? K.value > 0 && l?.value?.validateOnValueUpdateAfterSubmit : void 0, C = l?.value?.validateWhenInError && U?.errors.value?.length > 0 ? !0 : void 0;
|
|
967
|
+
return y.value?.fieldOptions?.validateOnValueUpdate ?? C ?? f ?? l?.value?.validateOnValueUpdate;
|
|
968
|
+
}), ce = o(
|
|
969
|
+
() => y.value?.attributes?.length && ae(w.value)
|
|
970
|
+
);
|
|
971
|
+
let he = !1, ke = {}, _e, Oe = !1, J;
|
|
972
|
+
dt(() => {
|
|
973
|
+
const f = I.value.restriction ?? {}, C = I.value.validation, Y = h.value, L = l?.value?.messages;
|
|
974
|
+
if (he && De(f, ke) && De(C, _e) && Y === Oe && L === J)
|
|
975
|
+
return;
|
|
976
|
+
he = !0, ke = Ee(f), _e = Ee(C), Oe = Y, J = L;
|
|
977
|
+
const Z = St(f, C, L);
|
|
978
|
+
Y && Z.unshift(N("xsd_required", void 0, L?.required)), F.value = Z;
|
|
979
|
+
});
|
|
980
|
+
let Ue = !1;
|
|
981
|
+
de(w, (f) => {
|
|
982
|
+
Ue || (Ue = !0, f === "" && (w.value = t.partOfArrayField ? null : void 0), Ue = !1);
|
|
983
|
+
}, {
|
|
984
|
+
flush: "sync"
|
|
985
|
+
}), de(
|
|
986
|
+
w,
|
|
987
|
+
(f) => {
|
|
988
|
+
ve.value && ((!Q.value || f) && (fe(), me.value && !B() && U?.validate()), Q.value = !1);
|
|
989
|
+
},
|
|
990
|
+
{
|
|
991
|
+
immediate: !0
|
|
992
|
+
}
|
|
993
|
+
), ve.value || de(te, () => {
|
|
994
|
+
B() || U.validate?.({ mode: "silent" });
|
|
995
|
+
}), Tt(() => {
|
|
996
|
+
i("update:computedField", I.value), de(() => I.value._hash, (f, C) => {
|
|
997
|
+
f !== C && i("update:computedField", I.value);
|
|
998
|
+
});
|
|
999
|
+
}), jt(() => {
|
|
1000
|
+
m != null && clearTimeout(m), !(t.partOfArrayField || $.value || !(t.partOfAttributeField && !t.attributeOwnerHasValue?.()) && (y.value?.fieldOptions?.keepValueOnUnmount ?? ct(ne?.keepValuesOnUnmount))) && w.value !== void 0 && (w.value = void 0, fe());
|
|
1001
|
+
});
|
|
1002
|
+
function re(f) {
|
|
1003
|
+
!f.path || le.value[f.path]?._hash === f._hash || (le.value[f.path] = f);
|
|
1004
|
+
}
|
|
1005
|
+
function fe() {
|
|
1006
|
+
te.value++, i("update:modelValue", w.value);
|
|
1007
|
+
}
|
|
1008
|
+
function Ke(f) {
|
|
1009
|
+
w.value = f, i("update:modelValue", w.value);
|
|
1010
|
+
}
|
|
1011
|
+
return (f, C) => {
|
|
1012
|
+
const Y = kt("DynamicFormItem", !0);
|
|
1013
|
+
return V(), H(ie, null, [
|
|
1014
|
+
W(l)?.analytics ? vt((V(), H("div", rr, [
|
|
1015
|
+
mt("span", {
|
|
1016
|
+
"data-testid": `${E.value}-analytics-render-count`
|
|
1017
|
+
}, ft(pt(u) ? ++u.value : ++u), 9, ar)
|
|
1018
|
+
], 512)), [
|
|
1019
|
+
[ht, !1]
|
|
1020
|
+
]) : we("", !0),
|
|
1021
|
+
X.value ? (V(), _(er, Je({ key: 1 }, t, {
|
|
1022
|
+
"field-metadata": I.value,
|
|
1023
|
+
"onUpdate:modelValue": fe,
|
|
1024
|
+
"onUpdate:computedField": re
|
|
1025
|
+
}), null, 16, ["field-metadata"])) : $.value ? (V(), _(Qt, Je({ key: 2 }, t, {
|
|
1026
|
+
"field-metadata": I.value,
|
|
1027
|
+
"onUpdate:modelValue": fe,
|
|
1028
|
+
"onUpdate:computedField": re
|
|
1029
|
+
}), null, 16, ["field-metadata"])) : A.value ? (V(), _(Xt, Je({ key: 3 }, t, {
|
|
1030
|
+
"part-of-choice-field": e.partOfChoiceField,
|
|
1031
|
+
"field-metadata": I.value,
|
|
1032
|
+
"onUpdate:modelValue": Ke,
|
|
1033
|
+
"onUpdate:computedField": re
|
|
1034
|
+
}), null, 16, ["part-of-choice-field", "field-metadata"])) : (V(), _(Ie(e.template), {
|
|
1035
|
+
key: 4,
|
|
1036
|
+
type: e.branchKey !== void 0 ? `${I.value.type}-choice-array-item` : e.partOfArrayField ? `${I.value.type}-array-item` : I.value.type,
|
|
1037
|
+
"field-metadata": I.value,
|
|
1038
|
+
"field-context": W(U),
|
|
1039
|
+
"slot-props": e.slotProps,
|
|
1040
|
+
settings: W(l),
|
|
1041
|
+
required: h.value,
|
|
1042
|
+
disabled: q.value,
|
|
1043
|
+
index: e.index,
|
|
1044
|
+
"can-add-items": e.canAddItems,
|
|
1045
|
+
"can-remove-items": O.value,
|
|
1046
|
+
"add-item": e.addItem,
|
|
1047
|
+
"remove-item": e.removeItem,
|
|
1048
|
+
"branch-key": e.branchKey,
|
|
1049
|
+
"global-index": e.globalIndex,
|
|
1050
|
+
"insertion-order": e.insertionOrder
|
|
1051
|
+
}, {
|
|
1052
|
+
default: Se((L) => [
|
|
1053
|
+
ue.value ? (V(!0), H(ie, { key: 0 }, ye(I.value.children, (Z, Fe) => (V(), _(Y, {
|
|
1054
|
+
key: Z.path,
|
|
1055
|
+
"field-metadata": Z,
|
|
1056
|
+
"path-override": M.value,
|
|
1057
|
+
index: Fe,
|
|
1058
|
+
template: e.template,
|
|
1059
|
+
"slot-props": L,
|
|
1060
|
+
"min-occurs-override": g.value,
|
|
1061
|
+
"max-occurs-override": x.value,
|
|
1062
|
+
"onUpdate:modelValue": fe,
|
|
1063
|
+
"onUpdate:computedField": re
|
|
1064
|
+
}, null, 8, ["field-metadata", "path-override", "index", "template", "slot-props", "min-occurs-override", "max-occurs-override"]))), 128)) : we("", !0),
|
|
1065
|
+
ue.value ? we("", !0) : (V(), _(Ie(e.template), {
|
|
1066
|
+
key: 1,
|
|
1067
|
+
type: `${I.value.type}-input`,
|
|
1068
|
+
"field-metadata": I.value,
|
|
1069
|
+
"field-context": W(U),
|
|
1070
|
+
"slot-props": L,
|
|
1071
|
+
settings: W(l),
|
|
1072
|
+
required: h.value,
|
|
1073
|
+
disabled: q.value,
|
|
1074
|
+
index: e.index,
|
|
1075
|
+
"can-add-items": e.canAddItems,
|
|
1076
|
+
"can-remove-items": O.value,
|
|
1077
|
+
"add-item": e.addItem,
|
|
1078
|
+
"remove-item": e.removeItem
|
|
1079
|
+
}, null, 8, ["type", "field-metadata", "field-context", "slot-props", "settings", "required", "disabled", "index", "can-add-items", "can-remove-items", "add-item", "remove-item"]))
|
|
1080
|
+
]),
|
|
1081
|
+
attributes: Se((L) => [
|
|
1082
|
+
ce.value ? (V(!0), H(ie, { key: 0 }, ye(I.value.attributes, (Z, Fe) => (V(), _(Y, {
|
|
1083
|
+
key: Z.path,
|
|
1084
|
+
"field-metadata": Z,
|
|
1085
|
+
"path-override": E.value,
|
|
1086
|
+
index: Fe,
|
|
1087
|
+
template: e.template,
|
|
1088
|
+
"slot-props": L,
|
|
1089
|
+
"min-occurs-override": g.value,
|
|
1090
|
+
"max-occurs-override": x.value,
|
|
1091
|
+
"part-of-attribute-field": !0,
|
|
1092
|
+
"attribute-owner-has-value": () => W(ae)(W(w)),
|
|
1093
|
+
"onUpdate:modelValue": fe,
|
|
1094
|
+
"onUpdate:computedField": re
|
|
1095
|
+
}, null, 8, ["field-metadata", "path-override", "index", "template", "slot-props", "min-occurs-override", "max-occurs-override", "attribute-owner-has-value"]))), 128)) : we("", !0)
|
|
1096
|
+
]),
|
|
1097
|
+
_: 1
|
|
1098
|
+
}, 8, ["type", "field-metadata", "field-context", "slot-props", "settings", "required", "disabled", "index", "can-add-items", "can-remove-items", "add-item", "remove-item", "branch-key", "global-index", "insertion-order"]))
|
|
1099
|
+
], 64);
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
}), cr = /* @__PURE__ */ Me({
|
|
1103
|
+
name: "DynamicForm",
|
|
1104
|
+
inheritAttrs: !1,
|
|
1105
|
+
__name: "DynamicForm",
|
|
1106
|
+
props: {
|
|
1107
|
+
metadata: {},
|
|
1108
|
+
template: { type: [Object, Function] },
|
|
1109
|
+
settings: {}
|
|
1110
|
+
},
|
|
1111
|
+
setup(e) {
|
|
1112
|
+
const r = o(() => ({
|
|
1113
|
+
validateOnValueUpdate: !0,
|
|
1114
|
+
validateWhenInError: !0,
|
|
1115
|
+
...e.settings ?? {}
|
|
1116
|
+
}));
|
|
1117
|
+
_t(Te, r), gt(Ne());
|
|
1118
|
+
const t = o(
|
|
1119
|
+
() => Array.isArray(e.metadata) ? e.metadata : [e.metadata]
|
|
1120
|
+
), i = o(
|
|
1121
|
+
() => t.value?.map((s, m) => u(s, m)) ?? []
|
|
1122
|
+
), l = o(
|
|
1123
|
+
() => e.template
|
|
1124
|
+
);
|
|
1125
|
+
function u(s, m, p) {
|
|
1126
|
+
if (!s)
|
|
1127
|
+
return s;
|
|
1128
|
+
const y = s.name ?? `field-${m}`, E = s.path ?? [p?.path, y].filter(Boolean).join("."), D = {
|
|
1129
|
+
name: y,
|
|
1130
|
+
path: E,
|
|
1131
|
+
type: "text",
|
|
1132
|
+
minOccurs: 1,
|
|
1133
|
+
maxOccurs: 1,
|
|
1134
|
+
...s,
|
|
1135
|
+
computedProps: [...s.computedProps ?? []],
|
|
1136
|
+
parent: p
|
|
1137
|
+
};
|
|
1138
|
+
return D.children = (s.children ?? []).map(
|
|
1139
|
+
(M, P) => u(M, P, D)
|
|
1140
|
+
), D.choice = (s.choice ?? []).map(
|
|
1141
|
+
(M, P) => u(M, P, D)
|
|
1142
|
+
), D.attributes = (s.attributes ?? []).map(
|
|
1143
|
+
(M, P) => u(M, P, D)
|
|
1144
|
+
), D;
|
|
1145
|
+
}
|
|
1146
|
+
return (s, m) => (V(!0), H(ie, null, ye(i.value, (p) => (V(), _(be, {
|
|
1147
|
+
key: p.name,
|
|
1148
|
+
template: l.value,
|
|
1149
|
+
"field-metadata": p
|
|
1150
|
+
}, null, 8, ["template", "field-metadata"]))), 128));
|
|
1151
|
+
}
|
|
1152
|
+
}), ir = /-\w/g, nr = ur(
|
|
1153
|
+
(e) => e.replace(ir, (r) => r.slice(1).toUpperCase())
|
|
1154
|
+
);
|
|
1155
|
+
function ur(e) {
|
|
1156
|
+
const r = /* @__PURE__ */ Object.create(null);
|
|
1157
|
+
return ((t) => r[t] || (r[t] = e(t)));
|
|
1158
|
+
}
|
|
1159
|
+
const sr = /* @__PURE__ */ Me({
|
|
1160
|
+
name: "DynamicFormTemplate",
|
|
1161
|
+
inheritAttrs: !1,
|
|
1162
|
+
__name: "DynamicFormTemplate",
|
|
1163
|
+
props: {
|
|
1164
|
+
metadataConfiguration: {}
|
|
1165
|
+
},
|
|
1166
|
+
setup(e) {
|
|
1167
|
+
const r = Dt(), t = zt(), i = o(() => {
|
|
1168
|
+
const u = {};
|
|
1169
|
+
for (const [s, m] of Object.entries(t))
|
|
1170
|
+
u[nr(s)] = m;
|
|
1171
|
+
return u;
|
|
1172
|
+
}), l = o(() => {
|
|
1173
|
+
const u = i.value.type;
|
|
1174
|
+
if (u && r[u])
|
|
1175
|
+
return u;
|
|
1176
|
+
if (u?.endsWith("-input"))
|
|
1177
|
+
return r["default-input"] ? "default-input" : "default";
|
|
1178
|
+
if (u?.endsWith("-choice-array-item")) {
|
|
1179
|
+
if (r["default-choice-array-item"])
|
|
1180
|
+
return "default-choice-array-item";
|
|
1181
|
+
const s = `${u.slice(0, -18)}-array-item`;
|
|
1182
|
+
return r[s] ? s : r["default-array-item"] ? "default-array-item" : "default";
|
|
1183
|
+
}
|
|
1184
|
+
if (u?.endsWith("-choice-array")) {
|
|
1185
|
+
if (r["default-choice-array"])
|
|
1186
|
+
return "default-choice-array";
|
|
1187
|
+
const s = `${u.slice(0, -13)}-choice`;
|
|
1188
|
+
return r[s] ? s : r["default-choice"] ? "default-choice" : "default";
|
|
1189
|
+
}
|
|
1190
|
+
return u?.endsWith("-array") ? r["default-array"] ? "default-array" : "default" : u?.endsWith("-array-item") ? r["default-array-item"] ? "default-array-item" : "default" : u?.endsWith("-choice") ? r["default-choice"] ? "default-choice" : "default" : u?.endsWith("-wizard-page") ? r["default-wizard-page"] ? "default-wizard-page" : "default" : u?.endsWith("-wizard") && r["default-wizard"] ? "default-wizard" : "default";
|
|
1191
|
+
});
|
|
1192
|
+
return (u, s) => i.value.fieldMetadata ? (V(), H(ie, { key: 0 }, [
|
|
1193
|
+
i.value.type?.endsWith("-choice-array") ? Ve(u.$slots, l.value, Ce(Ae(i.value)), void 0, void 0, 0) : i.value.type?.endsWith("-array") ? Ve(u.$slots, l.value, Ce(Ae(i.value)), void 0, void 0, 1) : i.value.type?.endsWith("-choice") ? Ve(u.$slots, l.value, Ce(Ae(i.value)), void 0, void 0, 2) : i.value.type?.endsWith("-wizard-page") ? Ve(u.$slots, l.value, Ce(Ae(i.value)), void 0, void 0, 3) : i.value.type?.endsWith("-wizard") ? Ve(u.$slots, l.value, Ce(Ae(i.value)), void 0, void 0, 4) : Ve(u.$slots, l.value, Ce(Ae(i.value)), void 0, void 0, 5)
|
|
1194
|
+
], 64)) : we("", !0);
|
|
1195
|
+
}
|
|
1196
|
+
});
|
|
1197
|
+
function dr() {
|
|
1198
|
+
return {
|
|
1199
|
+
fieldTypes: Object.keys({}),
|
|
1200
|
+
extendedProperties: {},
|
|
1201
|
+
slotProperties: {},
|
|
1202
|
+
extendedSettingsProperties: {},
|
|
1203
|
+
valueTypes: {}
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
function vr(e) {
|
|
1207
|
+
const r = (l) => Ye(l), t = Rt(e);
|
|
1208
|
+
gt(t);
|
|
1209
|
+
const { validateSection: i } = Mt();
|
|
1210
|
+
return {
|
|
1211
|
+
...t,
|
|
1212
|
+
useFieldValue: r,
|
|
1213
|
+
validateSection: i
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
function ot(e, r) {
|
|
1217
|
+
return !e || !r || (e = r?.({ ...e }), e.children = e?.children?.map((t) => ot(t, r)), e.choice = e?.choice?.map((t) => ot(t, r))), e;
|
|
1218
|
+
}
|
|
1219
|
+
export {
|
|
1220
|
+
cr as _,
|
|
1221
|
+
be as a,
|
|
1222
|
+
Xt as b,
|
|
1223
|
+
Qt as c,
|
|
1224
|
+
er as d,
|
|
1225
|
+
sr as e,
|
|
1226
|
+
dr as f,
|
|
1227
|
+
Mt as g,
|
|
1228
|
+
Te as h,
|
|
1229
|
+
ae as i,
|
|
1230
|
+
Yt as j,
|
|
1231
|
+
ot as m,
|
|
1232
|
+
vr as u
|
|
1233
|
+
};
|
|
1234
|
+
//# sourceMappingURL=mapEachMetadataItem-CZmoxEoA.js.map
|