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