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