@bach.software/vue-dynamic-form 0.3.0 → 0.4.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/README.md +163 -163
- package/dist/examples.cjs.js +4 -4
- package/dist/examples.cjs.js.map +1 -1
- package/dist/examples.es.js +235 -209
- package/dist/examples.es.js.map +1 -1
- package/dist/src/components/DynamicForm.vue.d.ts +3 -0
- package/dist/src/components/DynamicFormItem.vue.d.ts +3 -0
- package/dist/src/components/DynamicFormItemArray.vue.d.ts +2 -0
- package/dist/src/components/DynamicFormItemChoice.vue.d.ts +2 -0
- package/dist/src/components/DynamicFormTemplate.vue.d.ts +5 -0
- package/dist/src/core/defineMetadata.d.ts +21 -10
- package/dist/src/core/useDynamicForm.d.ts +8 -0
- package/dist/src/core/useFieldArrayExtended.d.ts +2 -1
- package/dist/src/core/useValidatePartialForm.d.ts +8 -0
- package/dist/src/core/validation.d.ts +1 -0
- package/dist/src/examples/TestForm.vue.d.ts +1 -2
- package/dist/src/examples/TestFormTemplate.vue.d.ts +5 -0
- package/dist/src/examples/__tests__/TestFormTemplate.testcases.d.ts +1 -2
- package/dist/src/index.d.ts +1 -1
- package/dist/src/types/DynamicFormItemProps.d.ts +1 -4
- package/dist/src/types/DynamicFormSettings.d.ts +3 -3
- package/dist/src/types/GetDynamicFormSettingsType.d.ts +3 -0
- package/dist/src/types/MetadataConfiguration.d.ts +1 -0
- package/dist/src/utils/__tests__/mapEachMetadataItem.test.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useDynamicForm-B3VHKage.js +735 -0
- package/dist/useDynamicForm-B3VHKage.js.map +1 -0
- package/dist/useDynamicForm-CIS8GwHy.cjs +6 -0
- package/dist/useDynamicForm-CIS8GwHy.cjs.map +1 -0
- package/dist/vue-dynamic-form.cjs.js +1 -1
- package/dist/vue-dynamic-form.es.js +7 -9
- package/package.json +1 -1
- package/dist/src/examples/__tests__/DynamicForm.test.d.ts +0 -1
- package/dist/src/types/KeyValue.d.ts +0 -3
- package/dist/useDynamicForm-C6-0mGw4.js +0 -737
- package/dist/useDynamicForm-C6-0mGw4.js.map +0 -1
- package/dist/useDynamicForm-SHyV1lLH.cjs +0 -6
- package/dist/useDynamicForm-SHyV1lLH.cjs.map +0 -1
package/dist/examples.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as B, createElementBlock as l, openBlock as t, normalizeClass as
|
|
2
|
-
import { d as z, e as G, u as H, _ as J,
|
|
3
|
-
function
|
|
4
|
-
return !h || !
|
|
1
|
+
import { defineComponent as B, createElementBlock as l, openBlock as t, normalizeClass as y, createCommentVNode as s, createElementVNode as r, createBlock as O, unref as k, withCtx as x, withDirectives as W, vModelText as I, vModelCheckbox as R, Fragment as F, renderList as T, toDisplayString as u, vModelSelect as A, renderSlot as v, createTextVNode as w, createVNode as q, ref as V, computed as L, withModifiers as U, markRaw as j, h as P } from "vue";
|
|
2
|
+
import { d as z, e as G, u as H, _ as J, h as Y } from "./useDynamicForm-B3VHKage.js";
|
|
3
|
+
function S(h, f) {
|
|
4
|
+
return !h || !f || (h = f?.({ ...h }), h.children = h?.children?.map((c) => S(c, f)), h.choice = h?.choice?.map((c) => S(c, f))), h;
|
|
5
5
|
}
|
|
6
6
|
const Q = {
|
|
7
7
|
key: 0,
|
|
@@ -19,7 +19,7 @@ const Q = {
|
|
|
19
19
|
"stroke-width": "1.5",
|
|
20
20
|
stroke: "currentColor",
|
|
21
21
|
class: "size-3"
|
|
22
|
-
},
|
|
22
|
+
}, C = /* @__PURE__ */ B({
|
|
23
23
|
__name: "IconButton",
|
|
24
24
|
props: {
|
|
25
25
|
icon: {},
|
|
@@ -27,342 +27,368 @@ const Q = {
|
|
|
27
27
|
},
|
|
28
28
|
emits: ["click"],
|
|
29
29
|
setup(h) {
|
|
30
|
-
return (
|
|
30
|
+
return (f, c) => (t(), l("button", {
|
|
31
31
|
type: "button",
|
|
32
|
-
class:
|
|
33
|
-
"bg-blue-200 hover:bg-blue-300":
|
|
34
|
-
"bg-red-200 hover:bg-red-300":
|
|
32
|
+
class: y(["cursor-pointer inline-flex items-center justify-center rounded-full size-5 text-white-800 cursor-pointer", {
|
|
33
|
+
"bg-blue-200 hover:bg-blue-300": f.color === "blue",
|
|
34
|
+
"bg-red-200 hover:bg-red-300": f.color === "red"
|
|
35
35
|
}]),
|
|
36
|
-
onClick:
|
|
36
|
+
onClick: c[0] || (c[0] = (N) => f.$emit("click"))
|
|
37
37
|
}, [
|
|
38
|
-
|
|
38
|
+
f.icon === "plus" ? (t(), l("svg", Q, c[1] || (c[1] = [
|
|
39
39
|
r("path", {
|
|
40
40
|
"stroke-linecap": "round",
|
|
41
41
|
"stroke-linejoin": "round",
|
|
42
42
|
d: "M12 4.5v15m7.5-7.5h-15"
|
|
43
43
|
}, null, -1)
|
|
44
|
-
]))) :
|
|
45
|
-
|
|
44
|
+
]))) : s("", !0),
|
|
45
|
+
f.icon === "minus" ? (t(), l("svg", X, c[2] || (c[2] = [
|
|
46
46
|
r("path", {
|
|
47
47
|
"stroke-linecap": "round",
|
|
48
48
|
"stroke-linejoin": "round",
|
|
49
49
|
d: "M5 12h14"
|
|
50
50
|
}, null, -1)
|
|
51
|
-
]))) :
|
|
51
|
+
]))) : s("", !0)
|
|
52
52
|
], 2));
|
|
53
53
|
}
|
|
54
|
-
}), Z = { class: "text-sm whitespace-pre-wrap" }, K = ["data-testid"], M = { class: "grid grid-cols-1 md:grid-cols-2 gap-6" }, ee = {
|
|
54
|
+
}), Z = { class: "text-sm whitespace-pre-wrap" }, K = ["data-testid"], M = { class: "grid grid-cols-1 md:grid-cols-2 gap-6" }, ee = {
|
|
55
55
|
key: 0,
|
|
56
|
-
class: "-
|
|
57
|
-
},
|
|
56
|
+
class: "text-red-500 dark:text-rose-400"
|
|
57
|
+
}, te = {
|
|
58
|
+
key: 1,
|
|
59
|
+
class: "text-sm text-gray-400"
|
|
60
|
+
}, le = { class: "grid grid-cols-1 md:grid-cols-2 gap-6 ms-6" }, se = { class: "text-sm whitespace-pre-wrap" }, ie = ["data-testid"], ne = ["for"], oe = {
|
|
58
61
|
key: 0,
|
|
59
|
-
class: "-
|
|
60
|
-
},
|
|
62
|
+
class: "text-red-500 dark:text-rose-400"
|
|
63
|
+
}, de = {
|
|
64
|
+
key: 1,
|
|
65
|
+
class: "text-sm text-gray-400"
|
|
66
|
+
}, ae = { class: "text-sm whitespace-pre-wrap" }, re = ["data-testid"], ue = ["for"], ce = {
|
|
61
67
|
key: 0,
|
|
62
|
-
class: "-
|
|
63
|
-
},
|
|
68
|
+
class: "text-red-500 dark:text-rose-400"
|
|
69
|
+
}, pe = {
|
|
70
|
+
key: 1,
|
|
71
|
+
class: "text-sm text-gray-400"
|
|
72
|
+
}, he = { class: "flex gap-2 items-center" }, me = { class: "flex flex-col grow" }, fe = { class: "text-sm whitespace-pre-wrap" }, be = ["data-testid"], ge = {
|
|
73
|
+
key: 0,
|
|
74
|
+
class: "text-red-500 dark:text-rose-400"
|
|
75
|
+
}, ye = {
|
|
76
|
+
key: 1,
|
|
77
|
+
class: "text-sm text-gray-400"
|
|
78
|
+
}, xe = { class: "grid grid-cols-1 md:grid-cols-2 gap-6 ms-6" }, ve = { class: "text-sm whitespace-pre-wrap" }, ke = ["data-testid"], _e = {
|
|
64
79
|
key: 0,
|
|
65
|
-
class: "-
|
|
66
|
-
},
|
|
80
|
+
class: "text-red-500 dark:text-rose-400"
|
|
81
|
+
}, Oe = {
|
|
82
|
+
key: 1,
|
|
83
|
+
class: "text-sm text-gray-400"
|
|
84
|
+
}, Ce = { class: "grid grid-cols-1 md:grid-cols-2 gap-6 ms-6" }, we = { class: "text-sm whitespace-pre-wrap" }, $e = ["data-testid"], Ne = ["id", "value", "disabled", "onChange", "onBlur"], Fe = ["value"], Be = ["id", "onUpdate:modelValue", "disabled", "onBlur"], We = ["value"], Ve = ["id", "checked", "disabled", "onChange", "onBlur"], Te = ["id", "onUpdate:modelValue", "disabled", "onBlur"], Se = ["id", "onUpdate:modelValue", "disabled", "onBlur"], Ee = ["id", "value", "disabled", "onInput", "onBlur"], Le = /* @__PURE__ */ B({
|
|
67
85
|
__name: "TestFormTemplate",
|
|
68
86
|
setup(h) {
|
|
69
|
-
const
|
|
70
|
-
return (
|
|
71
|
-
heading: x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label:
|
|
72
|
-
e.hidden ?
|
|
87
|
+
const f = G();
|
|
88
|
+
return (c, N) => (t(), O(z, { "metadata-configuration": k(f) }, {
|
|
89
|
+
heading: x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled: d, canAddItems: o, addItem: p, canRemoveItems: b, removeItem: m, slotProps: a }) => [
|
|
90
|
+
e.hidden ? s("", !0) : (t(), l("div", {
|
|
73
91
|
key: 0,
|
|
74
|
-
class:
|
|
92
|
+
class: y(["mt-4", { "md:col-span-2": e.fullWidth }])
|
|
75
93
|
}, [
|
|
76
|
-
|
|
94
|
+
n ? (t(), l("h3", {
|
|
77
95
|
key: 0,
|
|
78
|
-
class:
|
|
96
|
+
class: y(["flex text-xl font-bold gap-2 items-center mb-2", { "text-gray-500": e.disabled || d }])
|
|
79
97
|
}, [
|
|
80
|
-
|
|
81
|
-
o ? (t(),
|
|
98
|
+
w(u(n) + " ", 1),
|
|
99
|
+
o ? (t(), O(C, {
|
|
82
100
|
key: 0,
|
|
83
101
|
icon: "plus",
|
|
84
102
|
tabindex: "-1",
|
|
85
103
|
"data-testid": `${e.path}-add-button`,
|
|
86
104
|
onClick: p
|
|
87
|
-
}, null, 8, ["data-testid", "onClick"])) :
|
|
88
|
-
|
|
105
|
+
}, null, 8, ["data-testid", "onClick"])) : s("", !0),
|
|
106
|
+
b ? (t(), O(C, {
|
|
89
107
|
key: 1,
|
|
90
108
|
icon: "minus",
|
|
91
109
|
tabindex: "-1",
|
|
92
110
|
color: "red",
|
|
93
111
|
"data-testid": `${e.path}-remove-button`,
|
|
94
|
-
onClick:
|
|
95
|
-
}, null, 8, ["data-testid", "onClick"])) :
|
|
96
|
-
], 2)) :
|
|
97
|
-
r("pre", Z,
|
|
112
|
+
onClick: m
|
|
113
|
+
}, null, 8, ["data-testid", "onClick"])) : s("", !0)
|
|
114
|
+
], 2)) : s("", !0),
|
|
115
|
+
r("pre", Z, u(e.description), 1),
|
|
98
116
|
i.value ? (t(), l("span", {
|
|
99
117
|
key: 1,
|
|
100
118
|
class: "text-red-600 text-sm",
|
|
101
119
|
"data-testid": `${e.path}-error-message`
|
|
102
|
-
},
|
|
120
|
+
}, u(i.value), 9, K)) : s("", !0),
|
|
103
121
|
r("div", M, [
|
|
104
|
-
v(
|
|
105
|
-
level: (
|
|
122
|
+
v(c.$slots, "default", {
|
|
123
|
+
level: (a?.level ?? 0) + 1
|
|
106
124
|
})
|
|
107
125
|
])
|
|
108
126
|
], 2))
|
|
109
127
|
]),
|
|
110
128
|
"heading-array": x(() => [
|
|
111
|
-
v(
|
|
129
|
+
v(c.$slots, "default")
|
|
112
130
|
]),
|
|
113
|
-
"default-choice": x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label:
|
|
114
|
-
e.hidden ?
|
|
131
|
+
"default-choice": x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled: d, required: o, slotProps: p, settings: { showOptionalInsteadOfRequired: b } }) => [
|
|
132
|
+
e.hidden ? s("", !0) : (t(), l("div", {
|
|
115
133
|
key: 0,
|
|
116
|
-
class:
|
|
134
|
+
class: y(["flex flex-col gap-2", { "md:col-span-2": e.fullWidth }])
|
|
117
135
|
}, [
|
|
118
136
|
r("span", {
|
|
119
|
-
class:
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
|
|
137
|
+
class: y(["flex gap-2 items-center", { "text-gray-500": d }])
|
|
138
|
+
}, [
|
|
139
|
+
w(u(n) + " ", 1),
|
|
140
|
+
o && !b ? (t(), l("span", ee, "*")) : s("", !0),
|
|
141
|
+
!o && b ? (t(), l("span", te, "(optional)")) : s("", !0)
|
|
142
|
+
], 2),
|
|
143
|
+
r("div", le, [
|
|
144
|
+
v(c.$slots, "default", {
|
|
123
145
|
level: (p?.level ?? 0) + 1,
|
|
124
146
|
belowChoiceField: !0
|
|
125
147
|
})
|
|
126
148
|
]),
|
|
127
|
-
r("pre",
|
|
149
|
+
r("pre", se, u(e.description), 1),
|
|
128
150
|
i.value ? (t(), l("span", {
|
|
129
151
|
key: 0,
|
|
130
152
|
class: "text-red-600 text-sm",
|
|
131
153
|
"data-testid": `${e.path}-error-message`
|
|
132
|
-
},
|
|
154
|
+
}, u(i.value), 9, ie)) : s("", !0)
|
|
133
155
|
], 2))
|
|
134
156
|
]),
|
|
135
|
-
"default-array": x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label:
|
|
136
|
-
e.hidden ?
|
|
157
|
+
"default-array": x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled: d, required: o, canAddItems: p, addItem: b, settings: { showOptionalInsteadOfRequired: m } }) => [
|
|
158
|
+
e.hidden ? s("", !0) : (t(), l("div", {
|
|
137
159
|
key: 0,
|
|
138
|
-
class:
|
|
160
|
+
class: y(["flex flex-col gap-2", { "md:col-span-2": e.fullWidth }])
|
|
139
161
|
}, [
|
|
140
162
|
r("label", {
|
|
141
163
|
for: `${e.path}[0]`,
|
|
142
|
-
class:
|
|
164
|
+
class: y([{ "text-gray-500": e.disabled || d }, "flex gap-2 items-center"])
|
|
143
165
|
}, [
|
|
144
|
-
|
|
145
|
-
o ? (t(), l("span",
|
|
146
|
-
|
|
147
|
-
|
|
166
|
+
w(u(n) + " ", 1),
|
|
167
|
+
o && !m ? (t(), l("span", oe, "*")) : s("", !0),
|
|
168
|
+
!o && m ? (t(), l("span", de, "(optional)")) : s("", !0),
|
|
169
|
+
p ? (t(), O(C, {
|
|
170
|
+
key: 2,
|
|
148
171
|
icon: "plus",
|
|
149
172
|
tabindex: "-1",
|
|
150
173
|
"data-testid": `${e.path}-add-button`,
|
|
151
|
-
onClick:
|
|
152
|
-
}, null, 8, ["data-testid", "onClick"])) :
|
|
153
|
-
], 10,
|
|
154
|
-
v(
|
|
155
|
-
r("pre",
|
|
174
|
+
onClick: b
|
|
175
|
+
}, null, 8, ["data-testid", "onClick"])) : s("", !0)
|
|
176
|
+
], 10, ne),
|
|
177
|
+
v(c.$slots, "default", { hideLabel: !0 }),
|
|
178
|
+
r("pre", ae, u(e.description), 1),
|
|
156
179
|
i.value ? (t(), l("span", {
|
|
157
180
|
key: 0,
|
|
158
181
|
class: "text-red-600 text-sm",
|
|
159
182
|
"data-testid": `${e.path}-error-message`
|
|
160
|
-
},
|
|
183
|
+
}, u(i.value), 9, re)) : s("", !0)
|
|
161
184
|
], 2))
|
|
162
185
|
]),
|
|
163
|
-
default: x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label:
|
|
164
|
-
e.hidden ?
|
|
186
|
+
default: x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled: d, required: o, canRemoveItems: p, removeItem: b, slotProps: m, settings: { showOptionalInsteadOfRequired: a } }) => [
|
|
187
|
+
e.hidden ? s("", !0) : (t(), l("div", {
|
|
165
188
|
key: 0,
|
|
166
|
-
class:
|
|
189
|
+
class: y(["flex flex-col gap-2", { "md:col-span-2": e.fullWidth }])
|
|
167
190
|
}, [
|
|
168
|
-
|
|
191
|
+
m?.hideLabel ? s("", !0) : (t(), l("label", {
|
|
169
192
|
key: 0,
|
|
170
193
|
for: e.path,
|
|
171
|
-
class:
|
|
194
|
+
class: y([{ "text-gray-500": e.disabled || d }, "flex gap-1 items-center"])
|
|
172
195
|
}, [
|
|
173
|
-
|
|
174
|
-
o ? (t(), l("span",
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
196
|
+
w(u(n) + " ", 1),
|
|
197
|
+
o && !a ? (t(), l("span", ce, "*")) : s("", !0),
|
|
198
|
+
!o && a ? (t(), l("span", pe, "(optional)")) : s("", !0)
|
|
199
|
+
], 10, ue)),
|
|
200
|
+
r("div", he, [
|
|
201
|
+
r("div", me, [
|
|
202
|
+
v(c.$slots, "default")
|
|
179
203
|
]),
|
|
180
|
-
|
|
181
|
-
class:
|
|
204
|
+
q(C, {
|
|
205
|
+
class: y({ invisible: !p }),
|
|
182
206
|
icon: "minus",
|
|
183
207
|
tabindex: "-1",
|
|
184
208
|
color: "red",
|
|
185
209
|
"data-testid": `${e.path}-remove-button`,
|
|
186
|
-
onClick:
|
|
210
|
+
onClick: b
|
|
187
211
|
}, null, 8, ["class", "data-testid", "onClick"])
|
|
188
212
|
]),
|
|
189
|
-
r("pre",
|
|
213
|
+
r("pre", fe, u(e.description), 1),
|
|
190
214
|
i.value ? (t(), l("span", {
|
|
191
215
|
key: 1,
|
|
192
216
|
class: "text-red-600 text-sm",
|
|
193
217
|
"data-testid": `${e.path}-error-message`
|
|
194
|
-
},
|
|
218
|
+
}, u(i.value), 9, be)) : s("", !0)
|
|
195
219
|
], 2)),
|
|
196
|
-
v(
|
|
220
|
+
v(c.$slots, "attributes")
|
|
197
221
|
]),
|
|
198
|
-
"group-array": x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label:
|
|
199
|
-
e.hidden ? (t(), l(F, { key: 0 }, [], 64)) :
|
|
222
|
+
"group-array": x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled: d, required: o, canAddItems: p, addItem: b, slotProps: m, settings: { showOptionalInsteadOfRequired: a } }) => [
|
|
223
|
+
e.hidden ? (t(), l(F, { key: 0 }, [], 64)) : m?.belowChoiceField ? (t(), l("div", {
|
|
200
224
|
key: 1,
|
|
201
|
-
class:
|
|
225
|
+
class: y({ "md:col-span-2": e.fullWidth })
|
|
202
226
|
}, [
|
|
203
227
|
r("span", {
|
|
204
|
-
class:
|
|
228
|
+
class: y(["flex gap-2 items-center mb-2", { "text-gray-500": e.disabled || d }])
|
|
205
229
|
}, [
|
|
206
|
-
|
|
207
|
-
o ? (t(), l("span",
|
|
208
|
-
|
|
209
|
-
|
|
230
|
+
w(u(n) + " ", 1),
|
|
231
|
+
o && !a ? (t(), l("span", ge, "*")) : s("", !0),
|
|
232
|
+
!o && a ? (t(), l("span", ye, "(optional)")) : s("", !0),
|
|
233
|
+
p ? (t(), O(C, {
|
|
234
|
+
key: 2,
|
|
210
235
|
icon: "plus",
|
|
211
236
|
tabindex: "-1",
|
|
212
237
|
"data-testid": `${e.path}-add-button`,
|
|
213
|
-
onClick:
|
|
214
|
-
}, null, 8, ["data-testid", "onClick"])) :
|
|
238
|
+
onClick: b
|
|
239
|
+
}, null, 8, ["data-testid", "onClick"])) : s("", !0)
|
|
215
240
|
], 2),
|
|
216
|
-
r("div",
|
|
217
|
-
v(
|
|
218
|
-
level: (
|
|
241
|
+
r("div", xe, [
|
|
242
|
+
v(c.$slots, "default", {
|
|
243
|
+
level: (m?.level ?? 0) + 1
|
|
219
244
|
})
|
|
220
245
|
]),
|
|
221
|
-
r("pre",
|
|
246
|
+
r("pre", ve, u(e.description), 1),
|
|
222
247
|
i.value ? (t(), l("span", {
|
|
223
248
|
key: 0,
|
|
224
249
|
class: "text-red-600 text-sm",
|
|
225
250
|
"data-testid": `${e.path}-error-message`
|
|
226
|
-
},
|
|
227
|
-
], 2)) : v(
|
|
251
|
+
}, u(i.value), 9, ke)) : s("", !0)
|
|
252
|
+
], 2)) : v(c.$slots, "default", { key: 2 })
|
|
228
253
|
]),
|
|
229
|
-
group: x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label:
|
|
230
|
-
e.hidden ?
|
|
254
|
+
group: x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled: d, required: o, canAddItems: p, canRemoveItems: b, addItem: m, removeItem: a, slotProps: g, settings: { showOptionalInsteadOfRequired: _ } }) => [
|
|
255
|
+
e.hidden ? s("", !0) : (t(), l("div", {
|
|
231
256
|
key: 0,
|
|
232
|
-
class:
|
|
257
|
+
class: y({ "md:col-span-2": e.fullWidth })
|
|
233
258
|
}, [
|
|
234
|
-
|
|
259
|
+
g?.hideLabel ? s("", !0) : (t(), l("span", {
|
|
235
260
|
key: 0,
|
|
236
|
-
class:
|
|
261
|
+
class: y(["flex gap-2 items-center mb-2", { "text-gray-500": e.disabled || d }])
|
|
237
262
|
}, [
|
|
238
|
-
|
|
239
|
-
o ? (t(), l("span",
|
|
240
|
-
|
|
241
|
-
|
|
263
|
+
w(u(n) + " ", 1),
|
|
264
|
+
o && !_ ? (t(), l("span", _e, "*")) : s("", !0),
|
|
265
|
+
!o && _ ? (t(), l("span", Oe, "(optional)")) : s("", !0),
|
|
266
|
+
p ? (t(), O(C, {
|
|
267
|
+
key: 2,
|
|
242
268
|
icon: "plus",
|
|
243
269
|
tabindex: "-1",
|
|
244
270
|
"data-testid": `${e.path}-add-button`,
|
|
245
|
-
onClick:
|
|
246
|
-
}, null, 8, ["data-testid", "onClick"])) :
|
|
247
|
-
|
|
248
|
-
key:
|
|
271
|
+
onClick: m
|
|
272
|
+
}, null, 8, ["data-testid", "onClick"])) : s("", !0),
|
|
273
|
+
b ? (t(), O(C, {
|
|
274
|
+
key: 3,
|
|
249
275
|
icon: "minus",
|
|
250
276
|
tabindex: "-1",
|
|
251
277
|
"data-testid": `${e.path}-remove-button`,
|
|
252
278
|
color: "red",
|
|
253
|
-
onClick:
|
|
254
|
-
}, null, 8, ["data-testid", "onClick"])) :
|
|
279
|
+
onClick: a
|
|
280
|
+
}, null, 8, ["data-testid", "onClick"])) : s("", !0)
|
|
255
281
|
], 2)),
|
|
256
|
-
r("div",
|
|
257
|
-
v(
|
|
258
|
-
level: (
|
|
282
|
+
r("div", Ce, [
|
|
283
|
+
v(c.$slots, "default", {
|
|
284
|
+
level: (g?.level ?? 0) + 1
|
|
259
285
|
})
|
|
260
286
|
]),
|
|
261
|
-
r("pre",
|
|
287
|
+
r("pre", we, u(e.description), 1),
|
|
262
288
|
i.value ? (t(), l("span", {
|
|
263
289
|
key: 1,
|
|
264
290
|
class: "text-red-600 text-sm",
|
|
265
291
|
"data-testid": `${e.path}-error-message`
|
|
266
|
-
},
|
|
292
|
+
}, u(i.value), 9, $e)) : s("", !0)
|
|
267
293
|
], 2)),
|
|
268
|
-
v(
|
|
294
|
+
v(c.$slots, "attributes")
|
|
269
295
|
]),
|
|
270
|
-
"select-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur:
|
|
296
|
+
"select-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n, handleChange: d }, disabled: o }) => [
|
|
271
297
|
r("select", {
|
|
272
298
|
id: e.path,
|
|
273
299
|
value: i.value,
|
|
274
300
|
disabled: e.disabled || o,
|
|
275
301
|
class: "h-9 bg-gray-100 border-gray-200 border rounded px-3 text-sm",
|
|
276
|
-
onChange:
|
|
277
|
-
onBlur:
|
|
302
|
+
onChange: d,
|
|
303
|
+
onBlur: n
|
|
278
304
|
}, [
|
|
279
|
-
(t(!0), l(F, null, T(e.options, ({ key: p, value:
|
|
305
|
+
(t(!0), l(F, null, T(e.options, ({ key: p, value: b }) => (t(), l("option", {
|
|
280
306
|
key: p,
|
|
281
307
|
value: p
|
|
282
|
-
},
|
|
283
|
-
], 40,
|
|
308
|
+
}, u(b), 9, Fe))), 128))
|
|
309
|
+
], 40, Ne)
|
|
284
310
|
]),
|
|
285
|
-
"selectBoundByVModel-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur:
|
|
311
|
+
"selectBoundByVModel-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n }, disabled: d }) => [
|
|
286
312
|
W(r("select", {
|
|
287
313
|
id: e.path,
|
|
288
314
|
"onUpdate:modelValue": (o) => i.value = o,
|
|
289
|
-
disabled: e.disabled ||
|
|
315
|
+
disabled: e.disabled || d,
|
|
290
316
|
class: "h-9 bg-gray-100 border-gray-200 border rounded px-3 text-sm",
|
|
291
|
-
onBlur:
|
|
317
|
+
onBlur: n
|
|
292
318
|
}, [
|
|
293
319
|
(t(!0), l(F, null, T(e.options, ({ key: o, value: p }) => (t(), l("option", {
|
|
294
320
|
key: o,
|
|
295
321
|
value: o
|
|
296
|
-
},
|
|
297
|
-
], 40,
|
|
322
|
+
}, u(p), 9, We))), 128))
|
|
323
|
+
], 40, Be), [
|
|
298
324
|
[A, i.value]
|
|
299
325
|
])
|
|
300
326
|
]),
|
|
301
|
-
"checkbox-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur:
|
|
327
|
+
"checkbox-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n, handleChange: d }, disabled: o }) => [
|
|
302
328
|
r("input", {
|
|
303
329
|
id: e.path,
|
|
304
330
|
checked: i.value,
|
|
305
331
|
disabled: e.disabled || o,
|
|
306
332
|
type: "checkbox",
|
|
307
333
|
class: "h-6 bg-gray-100 border-gray-200 border rounded px-3 text-sm",
|
|
308
|
-
onChange: (p) =>
|
|
309
|
-
onBlur:
|
|
310
|
-
}, null, 40,
|
|
334
|
+
onChange: (p) => d(p.target.checked),
|
|
335
|
+
onBlur: n
|
|
336
|
+
}, null, 40, Ve)
|
|
311
337
|
]),
|
|
312
|
-
"checkboxBoundByVModel-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur:
|
|
338
|
+
"checkboxBoundByVModel-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n }, disabled: d }) => [
|
|
313
339
|
W(r("input", {
|
|
314
340
|
id: e.path,
|
|
315
341
|
"onUpdate:modelValue": (o) => i.value = o,
|
|
316
|
-
disabled: e.disabled ||
|
|
342
|
+
disabled: e.disabled || d,
|
|
317
343
|
type: "checkbox",
|
|
318
344
|
class: "h-6 bg-gray-100 border-gray-200 border rounded px-3 text-sm",
|
|
319
|
-
onBlur:
|
|
320
|
-
}, null, 40,
|
|
321
|
-
[
|
|
345
|
+
onBlur: n
|
|
346
|
+
}, null, 40, Te), [
|
|
347
|
+
[R, i.value]
|
|
322
348
|
])
|
|
323
349
|
]),
|
|
324
|
-
"textBoundByVModel-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur:
|
|
350
|
+
"textBoundByVModel-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n }, disabled: d }) => [
|
|
325
351
|
W(r("input", {
|
|
326
352
|
id: e.path,
|
|
327
353
|
"onUpdate:modelValue": (o) => i.value = o,
|
|
328
|
-
disabled: e.disabled ||
|
|
354
|
+
disabled: e.disabled || d,
|
|
329
355
|
type: "text",
|
|
330
356
|
class: "h-9 bg-gray-100 border-gray-200 border rounded px-3 text-sm",
|
|
331
|
-
onBlur:
|
|
332
|
-
}, null, 40,
|
|
333
|
-
[
|
|
357
|
+
onBlur: n
|
|
358
|
+
}, null, 40, Se), [
|
|
359
|
+
[I, i.value]
|
|
334
360
|
])
|
|
335
361
|
]),
|
|
336
|
-
"default-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur:
|
|
362
|
+
"default-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n, handleChange: d }, disabled: o }) => [
|
|
337
363
|
r("input", {
|
|
338
364
|
id: e.path,
|
|
339
365
|
value: i.value,
|
|
340
366
|
disabled: e.disabled || o,
|
|
341
367
|
type: "text",
|
|
342
368
|
class: "h-9 bg-gray-100 border-gray-200 border rounded px-3 text-sm",
|
|
343
|
-
onInput:
|
|
344
|
-
onBlur:
|
|
345
|
-
}, null, 40,
|
|
369
|
+
onInput: d,
|
|
370
|
+
onBlur: n
|
|
371
|
+
}, null, 40, Ee)
|
|
346
372
|
]),
|
|
347
373
|
_: 3
|
|
348
374
|
}, 8, ["metadata-configuration"]));
|
|
349
375
|
}
|
|
350
|
-
}),
|
|
376
|
+
}), qe = { class: "flex justify-end gap-2" }, De = {
|
|
351
377
|
key: 1,
|
|
352
378
|
type: "submit",
|
|
353
379
|
class: "cursor-pointer mt-4 bg-blue-500 text-white px-4 py-2 rounded",
|
|
354
380
|
"data-testid": "submit"
|
|
355
|
-
},
|
|
381
|
+
}, Ie = {
|
|
356
382
|
key: 0,
|
|
357
383
|
"data-testid": "errors",
|
|
358
384
|
class: "col-12 text-red-600"
|
|
359
|
-
},
|
|
385
|
+
}, Re = ["innerHTML"], Ae = {
|
|
360
386
|
key: 1,
|
|
361
387
|
"data-testid": "isSubmitted"
|
|
362
|
-
},
|
|
388
|
+
}, Ue = {
|
|
363
389
|
key: 2,
|
|
364
390
|
class: "bg-gray-100 p-4 rounded-lg text-sm overflow-auto"
|
|
365
|
-
},
|
|
391
|
+
}, je = /* @__PURE__ */ B({
|
|
366
392
|
__name: "TestForm",
|
|
367
393
|
props: {
|
|
368
394
|
metadata: {},
|
|
@@ -373,15 +399,15 @@ const Q = {
|
|
|
373
399
|
initialValues: {}
|
|
374
400
|
},
|
|
375
401
|
setup(h) {
|
|
376
|
-
const { values:
|
|
402
|
+
const { values: f, handleSubmit: c, errors: N, meta: e } = H({
|
|
377
403
|
initialValues: h.initialValues
|
|
378
|
-
}), i = V(),
|
|
379
|
-
|
|
380
|
-
}), h.hideFieldsWithoutValue && (
|
|
381
|
-
!
|
|
382
|
-
}),
|
|
383
|
-
!
|
|
384
|
-
})),
|
|
404
|
+
}), i = V(), n = V(h.initialEdit), d = V(!1), o = L(() => h.metadata?.map((m) => S(m, (a) => (a.computedProps = a.computedProps ?? [], a.computedProps.push((g) => {
|
|
405
|
+
n.value || (g.disabled = !0);
|
|
406
|
+
}), h.hideFieldsWithoutValue && (a.computedProps.push((g, _) => {
|
|
407
|
+
!n.value && !Y(_.value) && (g.hidden = !0);
|
|
408
|
+
}), a.computedProps.push((g, _, E) => {
|
|
409
|
+
!n.value && E.value.length > 0 && E.value.every((D) => D.hidden) && (g.hidden = !0);
|
|
410
|
+
})), a)))), p = L(() => ({
|
|
385
411
|
analytics: !0,
|
|
386
412
|
messages: {
|
|
387
413
|
required: "{field} is required",
|
|
@@ -402,69 +428,69 @@ const Q = {
|
|
|
402
428
|
},
|
|
403
429
|
...h.settings ?? {}
|
|
404
430
|
}));
|
|
405
|
-
function
|
|
406
|
-
|
|
407
|
-
(
|
|
408
|
-
|
|
431
|
+
function b(m) {
|
|
432
|
+
c(
|
|
433
|
+
(a) => {
|
|
434
|
+
d.value = !0, n.value = !1;
|
|
409
435
|
},
|
|
410
|
-
({ errors:
|
|
411
|
-
|
|
436
|
+
({ errors: a }) => {
|
|
437
|
+
d.value = !1;
|
|
412
438
|
}
|
|
413
|
-
)(
|
|
439
|
+
)(m);
|
|
414
440
|
}
|
|
415
|
-
return (
|
|
416
|
-
onSubmit: U(
|
|
441
|
+
return (m, a) => (t(), l("form", {
|
|
442
|
+
onSubmit: U(b, ["prevent"])
|
|
417
443
|
}, [
|
|
418
|
-
r("div",
|
|
419
|
-
|
|
444
|
+
r("div", qe, [
|
|
445
|
+
n.value ? s("", !0) : (t(), l("button", {
|
|
420
446
|
key: 0,
|
|
421
447
|
type: "button",
|
|
422
448
|
class: "cursor-pointer mt-4 bg-blue-500 text-white px-4 py-2 rounded",
|
|
423
449
|
"data-testid": "submit",
|
|
424
|
-
onClick:
|
|
450
|
+
onClick: a[0] || (a[0] = (g) => n.value = !0)
|
|
425
451
|
}, " Edit ")),
|
|
426
|
-
|
|
427
|
-
|
|
452
|
+
n.value ? (t(), l("button", De, " Submit ")) : s("", !0),
|
|
453
|
+
n.value ? (t(), l("button", {
|
|
428
454
|
key: 2,
|
|
429
455
|
type: "button",
|
|
430
456
|
class: "cursor-pointer mt-4 bg-gray-200 text-black px-4 py-2 rounded",
|
|
431
457
|
"data-testid": "cancel",
|
|
432
|
-
onClick:
|
|
433
|
-
}, " Cancel ")) :
|
|
458
|
+
onClick: a[1] || (a[1] = (g) => n.value = !1)
|
|
459
|
+
}, " Cancel ")) : s("", !0)
|
|
434
460
|
]),
|
|
435
|
-
Object.values(
|
|
436
|
-
|
|
461
|
+
Object.values(k(N)).length ? (t(), l("div", Ie, [
|
|
462
|
+
a[3] || (a[3] = w(" Errors: ", -1)),
|
|
437
463
|
r("ul", null, [
|
|
438
|
-
(t(!0), l(F, null, T(
|
|
439
|
-
r("span", { innerHTML:
|
|
464
|
+
(t(!0), l(F, null, T(k(N), (g, _) => (t(), l("li", { key: _ }, [
|
|
465
|
+
r("span", { innerHTML: g }, null, 8, Re)
|
|
440
466
|
]))), 128))
|
|
441
467
|
])
|
|
442
|
-
])) :
|
|
443
|
-
|
|
444
|
-
template:
|
|
468
|
+
])) : s("", !0),
|
|
469
|
+
q(J, {
|
|
470
|
+
template: Le,
|
|
445
471
|
metadata: o.value,
|
|
446
472
|
settings: p.value,
|
|
447
|
-
"onUpdate:modelValue":
|
|
473
|
+
"onUpdate:modelValue": a[2] || (a[2] = (g) => i.value = g)
|
|
448
474
|
}, null, 8, ["metadata", "settings"]),
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
Pending: ` +
|
|
452
|
-
Touched: ` +
|
|
453
|
-
Valid: ` +
|
|
454
|
-
Submitted: ` +
|
|
475
|
+
d.value ? (t(), l("span", Ae)) : s("", !0),
|
|
476
|
+
m.showDebugState ? (t(), l("pre", Ue, "IsDirty: " + u(k(e).dirty) + `
|
|
477
|
+
Pending: ` + u(k(e).pending) + `
|
|
478
|
+
Touched: ` + u(k(e).touched) + `
|
|
479
|
+
Valid: ` + u(k(e).valid) + `
|
|
480
|
+
Submitted: ` + u(d.value) + `
|
|
455
481
|
|
|
456
482
|
// form values:
|
|
457
|
-
` +
|
|
458
|
-
`, 1)) :
|
|
483
|
+
` + u(JSON.stringify(k(f), null, 2)) + `
|
|
484
|
+
`, 1)) : s("", !0)
|
|
459
485
|
], 32));
|
|
460
486
|
}
|
|
461
|
-
}),
|
|
487
|
+
}), Ge = $([{
|
|
462
488
|
name: "text",
|
|
463
489
|
type: "text",
|
|
464
490
|
fieldOptions: { label: "Text Input" },
|
|
465
491
|
path: "with.custom.structure",
|
|
466
492
|
restriction: { maxLength: 10 }
|
|
467
|
-
}]),
|
|
493
|
+
}]), He = $([{
|
|
468
494
|
fieldOptions: { label: "Array Fields" },
|
|
469
495
|
type: "heading",
|
|
470
496
|
children: [
|
|
@@ -481,7 +507,7 @@ Submitted: ` + a(n.value) + `
|
|
|
481
507
|
{ fieldOptions: { label: "Nested field 3" }, type: "checkbox" }
|
|
482
508
|
] }
|
|
483
509
|
]
|
|
484
|
-
}]),
|
|
510
|
+
}]), Je = $([{
|
|
485
511
|
fieldOptions: { label: "Grouped Fields" },
|
|
486
512
|
type: "heading",
|
|
487
513
|
children: [
|
|
@@ -509,7 +535,7 @@ You can test it by filling in one of the fields.`, children: [
|
|
|
509
535
|
{ fieldOptions: { label: "Required Nested field 2" } }
|
|
510
536
|
] }
|
|
511
537
|
]
|
|
512
|
-
}]),
|
|
538
|
+
}]), Ye = $([
|
|
513
539
|
{
|
|
514
540
|
fieldOptions: { label: "Choice Fields (minOccurs 1, maxOccurs 1)" },
|
|
515
541
|
type: "heading",
|
|
@@ -546,7 +572,7 @@ You can test it by filling in one of the fields.`, children: [
|
|
|
546
572
|
] }
|
|
547
573
|
]
|
|
548
574
|
}
|
|
549
|
-
]),
|
|
575
|
+
]), Qe = $([
|
|
550
576
|
{
|
|
551
577
|
fieldOptions: { label: "Personal Info" },
|
|
552
578
|
type: "heading",
|
|
@@ -579,7 +605,7 @@ You can test it by filling in one of the fields.`, children: [
|
|
|
579
605
|
lastName: "Smit"
|
|
580
606
|
}
|
|
581
607
|
}
|
|
582
|
-
}),
|
|
608
|
+
}), Xe = $(
|
|
583
609
|
[{
|
|
584
610
|
name: "items",
|
|
585
611
|
type: "text",
|
|
@@ -594,19 +620,19 @@ You can test it by filling in one of the fields.`, children: [
|
|
|
594
620
|
// validateOnBlur: true,
|
|
595
621
|
}
|
|
596
622
|
);
|
|
597
|
-
function
|
|
623
|
+
function $(h, f, c = {}) {
|
|
598
624
|
return j(B({
|
|
599
|
-
render: () => P(
|
|
625
|
+
render: () => P(je, { ...c, metadata: h, settings: f, showDebugState: !0 })
|
|
600
626
|
}));
|
|
601
627
|
}
|
|
602
628
|
export {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
629
|
+
Le as TestFormTemplate,
|
|
630
|
+
He as arrayTestCase,
|
|
631
|
+
Qe as childFieldsTestCase,
|
|
632
|
+
Ye as choiceTestCase,
|
|
633
|
+
$ as createTestCase,
|
|
634
|
+
Ge as defaultTestCase,
|
|
635
|
+
Je as groupTestCase,
|
|
636
|
+
Xe as individualTestCase
|
|
611
637
|
};
|
|
612
638
|
//# sourceMappingURL=examples.es.js.map
|