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