@bach.software/vue-dynamic-form 0.4.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 +56 -49
- package/dist/examples.cjs.js +4 -4
- package/dist/examples.cjs.js.map +1 -1
- package/dist/examples.es.js +130 -133
- 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/core/useDynamicForm.d.ts +2 -3
- package/dist/src/index.d.ts +4 -0
- package/dist/src/utils/__tests__/isNullOrUndefined.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 +52 -10
- package/dist/vue-dynamic-form.es.js.map +1 -1
- package/package.json +6 -7
- package/dist/useDynamicForm-B3VHKage.js +0 -735
- package/dist/useDynamicForm-B3VHKage.js.map +0 -1
- package/dist/useDynamicForm-CIS8GwHy.cjs +0 -6
- package/dist/useDynamicForm-CIS8GwHy.cjs.map +0 -1
package/dist/examples.es.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { defineComponent as B, createElementBlock as l, openBlock as t, normalizeClass as
|
|
2
|
-
import { d as
|
|
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
|
-
}
|
|
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",
|
|
@@ -26,29 +23,29 @@ const Q = {
|
|
|
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
|
-
class:
|
|
33
|
-
"bg-blue-200 hover:bg-blue-300":
|
|
34
|
-
"bg-red-200 hover:bg-red-300":
|
|
29
|
+
class: g(["cursor-pointer inline-flex items-center justify-center rounded-full size-5 text-white-800 cursor-pointer", {
|
|
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: c[0] || (c[0] = (N) =>
|
|
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
|
-
]))) : s("", !0),
|
|
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
|
-
]))) : s("", !0)
|
|
48
|
+
])])) : s("", !0)
|
|
52
49
|
], 2));
|
|
53
50
|
}
|
|
54
51
|
}), Z = { class: "text-sm whitespace-pre-wrap" }, K = ["data-testid"], M = { class: "grid grid-cols-1 md:grid-cols-2 gap-6" }, ee = {
|
|
@@ -57,10 +54,10 @@ const Q = {
|
|
|
57
54
|
}, te = {
|
|
58
55
|
key: 1,
|
|
59
56
|
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"],
|
|
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 = {
|
|
61
58
|
key: 0,
|
|
62
59
|
class: "text-red-500 dark:text-rose-400"
|
|
63
|
-
},
|
|
60
|
+
}, oe = {
|
|
64
61
|
key: 1,
|
|
65
62
|
class: "text-sm text-gray-400"
|
|
66
63
|
}, ae = { class: "text-sm whitespace-pre-wrap" }, re = ["data-testid"], ue = ["for"], ce = {
|
|
@@ -69,13 +66,13 @@ const Q = {
|
|
|
69
66
|
}, pe = {
|
|
70
67
|
key: 1,
|
|
71
68
|
class: "text-sm text-gray-400"
|
|
72
|
-
}, he = { class: "flex gap-2 items-center" }, me = { class: "flex flex-col grow" },
|
|
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 = {
|
|
73
70
|
key: 0,
|
|
74
71
|
class: "text-red-500 dark:text-rose-400"
|
|
75
|
-
},
|
|
72
|
+
}, xe = {
|
|
76
73
|
key: 1,
|
|
77
74
|
class: "text-sm text-gray-400"
|
|
78
|
-
},
|
|
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 = {
|
|
79
76
|
key: 0,
|
|
80
77
|
class: "text-red-500 dark:text-rose-400"
|
|
81
78
|
}, Oe = {
|
|
@@ -83,27 +80,27 @@ const Q = {
|
|
|
83
80
|
class: "text-sm text-gray-400"
|
|
84
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({
|
|
85
82
|
__name: "TestFormTemplate",
|
|
86
|
-
setup(
|
|
87
|
-
const
|
|
88
|
-
return (c, N) => (t(), O(
|
|
89
|
-
heading: x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled:
|
|
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 }) => [
|
|
90
87
|
e.hidden ? s("", !0) : (t(), l("div", {
|
|
91
88
|
key: 0,
|
|
92
|
-
class:
|
|
89
|
+
class: g(["mt-4", { "md:col-span-2": e.fullWidth }])
|
|
93
90
|
}, [
|
|
94
91
|
n ? (t(), l("h3", {
|
|
95
92
|
key: 0,
|
|
96
|
-
class:
|
|
93
|
+
class: g(["flex text-xl font-bold gap-2 items-center mb-2", { "text-gray-500": e.disabled || o }])
|
|
97
94
|
}, [
|
|
98
95
|
w(u(n) + " ", 1),
|
|
99
|
-
|
|
96
|
+
d ? (t(), O(C, {
|
|
100
97
|
key: 0,
|
|
101
98
|
icon: "plus",
|
|
102
99
|
tabindex: "-1",
|
|
103
100
|
"data-testid": `${e.path}-add-button`,
|
|
104
101
|
onClick: p
|
|
105
102
|
}, null, 8, ["data-testid", "onClick"])) : s("", !0),
|
|
106
|
-
|
|
103
|
+
h ? (t(), O(C, {
|
|
107
104
|
key: 1,
|
|
108
105
|
icon: "minus",
|
|
109
106
|
tabindex: "-1",
|
|
@@ -119,29 +116,29 @@ const Q = {
|
|
|
119
116
|
"data-testid": `${e.path}-error-message`
|
|
120
117
|
}, u(i.value), 9, K)) : s("", !0),
|
|
121
118
|
r("div", M, [
|
|
122
|
-
|
|
119
|
+
y(c.$slots, "default", {
|
|
123
120
|
level: (a?.level ?? 0) + 1
|
|
124
121
|
})
|
|
125
122
|
])
|
|
126
123
|
], 2))
|
|
127
124
|
]),
|
|
128
125
|
"heading-array": x(() => [
|
|
129
|
-
|
|
126
|
+
y(c.$slots, "default")
|
|
130
127
|
]),
|
|
131
|
-
"default-choice": x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled:
|
|
128
|
+
"default-choice": x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled: o, required: d, slotProps: p, settings: { showOptionalInsteadOfRequired: h } }) => [
|
|
132
129
|
e.hidden ? s("", !0) : (t(), l("div", {
|
|
133
130
|
key: 0,
|
|
134
|
-
class:
|
|
131
|
+
class: g(["flex flex-col gap-2", { "md:col-span-2": e.fullWidth }])
|
|
135
132
|
}, [
|
|
136
133
|
r("span", {
|
|
137
|
-
class:
|
|
134
|
+
class: g(["flex gap-2 items-center", { "text-gray-500": o }])
|
|
138
135
|
}, [
|
|
139
136
|
w(u(n) + " ", 1),
|
|
140
|
-
|
|
141
|
-
!
|
|
137
|
+
d && !h ? (t(), l("span", ee, "*")) : s("", !0),
|
|
138
|
+
!d && h ? (t(), l("span", te, "(optional)")) : s("", !0)
|
|
142
139
|
], 2),
|
|
143
140
|
r("div", le, [
|
|
144
|
-
|
|
141
|
+
y(c.$slots, "default", {
|
|
145
142
|
level: (p?.level ?? 0) + 1,
|
|
146
143
|
belowChoiceField: !0
|
|
147
144
|
})
|
|
@@ -154,27 +151,27 @@ const Q = {
|
|
|
154
151
|
}, u(i.value), 9, ie)) : s("", !0)
|
|
155
152
|
], 2))
|
|
156
153
|
]),
|
|
157
|
-
"default-array": x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled:
|
|
154
|
+
"default-array": x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled: o, required: d, canAddItems: p, addItem: h, settings: { showOptionalInsteadOfRequired: m } }) => [
|
|
158
155
|
e.hidden ? s("", !0) : (t(), l("div", {
|
|
159
156
|
key: 0,
|
|
160
|
-
class:
|
|
157
|
+
class: g(["flex flex-col gap-2", { "md:col-span-2": e.fullWidth }])
|
|
161
158
|
}, [
|
|
162
159
|
r("label", {
|
|
163
160
|
for: `${e.path}[0]`,
|
|
164
|
-
class:
|
|
161
|
+
class: g([{ "text-gray-500": e.disabled || o }, "flex gap-2 items-center"])
|
|
165
162
|
}, [
|
|
166
163
|
w(u(n) + " ", 1),
|
|
167
|
-
|
|
168
|
-
!
|
|
164
|
+
d && !m ? (t(), l("span", de, "*")) : s("", !0),
|
|
165
|
+
!d && m ? (t(), l("span", oe, "(optional)")) : s("", !0),
|
|
169
166
|
p ? (t(), O(C, {
|
|
170
167
|
key: 2,
|
|
171
168
|
icon: "plus",
|
|
172
169
|
tabindex: "-1",
|
|
173
170
|
"data-testid": `${e.path}-add-button`,
|
|
174
|
-
onClick:
|
|
171
|
+
onClick: h
|
|
175
172
|
}, null, 8, ["data-testid", "onClick"])) : s("", !0)
|
|
176
173
|
], 10, ne),
|
|
177
|
-
|
|
174
|
+
y(c.$slots, "default", { hideLabel: !0 }),
|
|
178
175
|
r("pre", ae, u(e.description), 1),
|
|
179
176
|
i.value ? (t(), l("span", {
|
|
180
177
|
key: 0,
|
|
@@ -183,63 +180,63 @@ const Q = {
|
|
|
183
180
|
}, u(i.value), 9, re)) : s("", !0)
|
|
184
181
|
], 2))
|
|
185
182
|
]),
|
|
186
|
-
default: x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled:
|
|
183
|
+
default: x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled: o, required: d, canRemoveItems: p, removeItem: h, slotProps: m, settings: { showOptionalInsteadOfRequired: a } }) => [
|
|
187
184
|
e.hidden ? s("", !0) : (t(), l("div", {
|
|
188
185
|
key: 0,
|
|
189
|
-
class:
|
|
186
|
+
class: g(["flex flex-col gap-2", { "md:col-span-2": e.fullWidth }])
|
|
190
187
|
}, [
|
|
191
188
|
m?.hideLabel ? s("", !0) : (t(), l("label", {
|
|
192
189
|
key: 0,
|
|
193
190
|
for: e.path,
|
|
194
|
-
class:
|
|
191
|
+
class: g([{ "text-gray-500": e.disabled || o }, "flex gap-1 items-center"])
|
|
195
192
|
}, [
|
|
196
193
|
w(u(n) + " ", 1),
|
|
197
|
-
|
|
198
|
-
!
|
|
194
|
+
d && !a ? (t(), l("span", ce, "*")) : s("", !0),
|
|
195
|
+
!d && a ? (t(), l("span", pe, "(optional)")) : s("", !0)
|
|
199
196
|
], 10, ue)),
|
|
200
197
|
r("div", he, [
|
|
201
198
|
r("div", me, [
|
|
202
|
-
|
|
199
|
+
y(c.$slots, "default")
|
|
203
200
|
]),
|
|
204
|
-
|
|
205
|
-
class:
|
|
201
|
+
L(C, {
|
|
202
|
+
class: g({ invisible: !p }),
|
|
206
203
|
icon: "minus",
|
|
207
204
|
tabindex: "-1",
|
|
208
205
|
color: "red",
|
|
209
206
|
"data-testid": `${e.path}-remove-button`,
|
|
210
|
-
onClick:
|
|
207
|
+
onClick: h
|
|
211
208
|
}, null, 8, ["class", "data-testid", "onClick"])
|
|
212
209
|
]),
|
|
213
|
-
r("pre",
|
|
210
|
+
r("pre", be, u(e.description), 1),
|
|
214
211
|
i.value ? (t(), l("span", {
|
|
215
212
|
key: 1,
|
|
216
213
|
class: "text-red-600 text-sm",
|
|
217
214
|
"data-testid": `${e.path}-error-message`
|
|
218
|
-
}, u(i.value), 9,
|
|
215
|
+
}, u(i.value), 9, fe)) : s("", !0)
|
|
219
216
|
], 2)),
|
|
220
|
-
|
|
217
|
+
y(c.$slots, "attributes")
|
|
221
218
|
]),
|
|
222
|
-
"group-array": x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled:
|
|
219
|
+
"group-array": x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled: o, required: d, canAddItems: p, addItem: h, slotProps: m, settings: { showOptionalInsteadOfRequired: a } }) => [
|
|
223
220
|
e.hidden ? (t(), l(F, { key: 0 }, [], 64)) : m?.belowChoiceField ? (t(), l("div", {
|
|
224
221
|
key: 1,
|
|
225
|
-
class:
|
|
222
|
+
class: g({ "md:col-span-2": e.fullWidth })
|
|
226
223
|
}, [
|
|
227
224
|
r("span", {
|
|
228
|
-
class:
|
|
225
|
+
class: g(["flex gap-2 items-center mb-2", { "text-gray-500": e.disabled || o }])
|
|
229
226
|
}, [
|
|
230
227
|
w(u(n) + " ", 1),
|
|
231
|
-
|
|
232
|
-
!
|
|
228
|
+
d && !a ? (t(), l("span", ge, "*")) : s("", !0),
|
|
229
|
+
!d && a ? (t(), l("span", xe, "(optional)")) : s("", !0),
|
|
233
230
|
p ? (t(), O(C, {
|
|
234
231
|
key: 2,
|
|
235
232
|
icon: "plus",
|
|
236
233
|
tabindex: "-1",
|
|
237
234
|
"data-testid": `${e.path}-add-button`,
|
|
238
|
-
onClick:
|
|
235
|
+
onClick: h
|
|
239
236
|
}, null, 8, ["data-testid", "onClick"])) : s("", !0)
|
|
240
237
|
], 2),
|
|
241
|
-
r("div",
|
|
242
|
-
|
|
238
|
+
r("div", ye, [
|
|
239
|
+
y(c.$slots, "default", {
|
|
243
240
|
level: (m?.level ?? 0) + 1
|
|
244
241
|
})
|
|
245
242
|
]),
|
|
@@ -249,20 +246,20 @@ const Q = {
|
|
|
249
246
|
class: "text-red-600 text-sm",
|
|
250
247
|
"data-testid": `${e.path}-error-message`
|
|
251
248
|
}, u(i.value), 9, ke)) : s("", !0)
|
|
252
|
-
], 2)) :
|
|
249
|
+
], 2)) : y(c.$slots, "default", { key: 2 })
|
|
253
250
|
]),
|
|
254
|
-
group: x(({ fieldMetadata: e, fieldContext: { errorMessage: i, label: n }, disabled:
|
|
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: _ } }) => [
|
|
255
252
|
e.hidden ? s("", !0) : (t(), l("div", {
|
|
256
253
|
key: 0,
|
|
257
|
-
class:
|
|
254
|
+
class: g({ "md:col-span-2": e.fullWidth })
|
|
258
255
|
}, [
|
|
259
|
-
|
|
256
|
+
f?.hideLabel ? s("", !0) : (t(), l("span", {
|
|
260
257
|
key: 0,
|
|
261
|
-
class:
|
|
258
|
+
class: g(["flex gap-2 items-center mb-2", { "text-gray-500": e.disabled || o }])
|
|
262
259
|
}, [
|
|
263
260
|
w(u(n) + " ", 1),
|
|
264
|
-
|
|
265
|
-
!
|
|
261
|
+
d && !_ ? (t(), l("span", _e, "*")) : s("", !0),
|
|
262
|
+
!d && _ ? (t(), l("span", Oe, "(optional)")) : s("", !0),
|
|
266
263
|
p ? (t(), O(C, {
|
|
267
264
|
key: 2,
|
|
268
265
|
icon: "plus",
|
|
@@ -270,7 +267,7 @@ const Q = {
|
|
|
270
267
|
"data-testid": `${e.path}-add-button`,
|
|
271
268
|
onClick: m
|
|
272
269
|
}, null, 8, ["data-testid", "onClick"])) : s("", !0),
|
|
273
|
-
|
|
270
|
+
h ? (t(), O(C, {
|
|
274
271
|
key: 3,
|
|
275
272
|
icon: "minus",
|
|
276
273
|
tabindex: "-1",
|
|
@@ -280,8 +277,8 @@ const Q = {
|
|
|
280
277
|
}, null, 8, ["data-testid", "onClick"])) : s("", !0)
|
|
281
278
|
], 2)),
|
|
282
279
|
r("div", Ce, [
|
|
283
|
-
|
|
284
|
-
level: (
|
|
280
|
+
y(c.$slots, "default", {
|
|
281
|
+
level: (f?.level ?? 0) + 1
|
|
285
282
|
})
|
|
286
283
|
]),
|
|
287
284
|
r("pre", we, u(e.description), 1),
|
|
@@ -291,82 +288,82 @@ const Q = {
|
|
|
291
288
|
"data-testid": `${e.path}-error-message`
|
|
292
289
|
}, u(i.value), 9, $e)) : s("", !0)
|
|
293
290
|
], 2)),
|
|
294
|
-
|
|
291
|
+
y(c.$slots, "attributes")
|
|
295
292
|
]),
|
|
296
|
-
"select-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n, handleChange:
|
|
293
|
+
"select-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n, handleChange: o }, disabled: d }) => [
|
|
297
294
|
r("select", {
|
|
298
295
|
id: e.path,
|
|
299
296
|
value: i.value,
|
|
300
|
-
disabled: e.disabled ||
|
|
297
|
+
disabled: e.disabled || d,
|
|
301
298
|
class: "h-9 bg-gray-100 border-gray-200 border rounded px-3 text-sm",
|
|
302
|
-
onChange:
|
|
299
|
+
onChange: o,
|
|
303
300
|
onBlur: n
|
|
304
301
|
}, [
|
|
305
|
-
(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", {
|
|
306
303
|
key: p,
|
|
307
304
|
value: p
|
|
308
|
-
}, u(
|
|
305
|
+
}, u(h), 9, Fe))), 128))
|
|
309
306
|
], 40, Ne)
|
|
310
307
|
]),
|
|
311
|
-
"selectBoundByVModel-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n }, disabled:
|
|
308
|
+
"selectBoundByVModel-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n }, disabled: o }) => [
|
|
312
309
|
W(r("select", {
|
|
313
310
|
id: e.path,
|
|
314
|
-
"onUpdate:modelValue": (
|
|
315
|
-
disabled: e.disabled ||
|
|
311
|
+
"onUpdate:modelValue": (d) => i.value = d,
|
|
312
|
+
disabled: e.disabled || o,
|
|
316
313
|
class: "h-9 bg-gray-100 border-gray-200 border rounded px-3 text-sm",
|
|
317
314
|
onBlur: n
|
|
318
315
|
}, [
|
|
319
|
-
(t(!0), l(F, null, T(e.options, ({ key:
|
|
320
|
-
key:
|
|
321
|
-
value:
|
|
316
|
+
(t(!0), l(F, null, T(e.options, ({ key: d, value: p }) => (t(), l("option", {
|
|
317
|
+
key: d,
|
|
318
|
+
value: d
|
|
322
319
|
}, u(p), 9, We))), 128))
|
|
323
320
|
], 40, Be), [
|
|
324
|
-
[
|
|
321
|
+
[R, i.value]
|
|
325
322
|
])
|
|
326
323
|
]),
|
|
327
|
-
"checkbox-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n, handleChange:
|
|
324
|
+
"checkbox-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n, handleChange: o }, disabled: d }) => [
|
|
328
325
|
r("input", {
|
|
329
326
|
id: e.path,
|
|
330
327
|
checked: i.value,
|
|
331
|
-
disabled: e.disabled ||
|
|
328
|
+
disabled: e.disabled || d,
|
|
332
329
|
type: "checkbox",
|
|
333
330
|
class: "h-6 bg-gray-100 border-gray-200 border rounded px-3 text-sm",
|
|
334
|
-
onChange: (p) =>
|
|
331
|
+
onChange: (p) => o(p.target.checked),
|
|
335
332
|
onBlur: n
|
|
336
333
|
}, null, 40, Ve)
|
|
337
334
|
]),
|
|
338
|
-
"checkboxBoundByVModel-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n }, disabled:
|
|
335
|
+
"checkboxBoundByVModel-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n }, disabled: o }) => [
|
|
339
336
|
W(r("input", {
|
|
340
337
|
id: e.path,
|
|
341
|
-
"onUpdate:modelValue": (
|
|
342
|
-
disabled: e.disabled ||
|
|
338
|
+
"onUpdate:modelValue": (d) => i.value = d,
|
|
339
|
+
disabled: e.disabled || o,
|
|
343
340
|
type: "checkbox",
|
|
344
341
|
class: "h-6 bg-gray-100 border-gray-200 border rounded px-3 text-sm",
|
|
345
342
|
onBlur: n
|
|
346
343
|
}, null, 40, Te), [
|
|
347
|
-
[
|
|
344
|
+
[I, i.value]
|
|
348
345
|
])
|
|
349
346
|
]),
|
|
350
|
-
"textBoundByVModel-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n }, disabled:
|
|
347
|
+
"textBoundByVModel-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n }, disabled: o }) => [
|
|
351
348
|
W(r("input", {
|
|
352
349
|
id: e.path,
|
|
353
|
-
"onUpdate:modelValue": (
|
|
354
|
-
disabled: e.disabled ||
|
|
350
|
+
"onUpdate:modelValue": (d) => i.value = d,
|
|
351
|
+
disabled: e.disabled || o,
|
|
355
352
|
type: "text",
|
|
356
353
|
class: "h-9 bg-gray-100 border-gray-200 border rounded px-3 text-sm",
|
|
357
354
|
onBlur: n
|
|
358
355
|
}, null, 40, Se), [
|
|
359
|
-
[
|
|
356
|
+
[D, i.value]
|
|
360
357
|
])
|
|
361
358
|
]),
|
|
362
|
-
"default-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n, handleChange:
|
|
359
|
+
"default-input": x(({ fieldMetadata: e, fieldContext: { value: i, handleBlur: n, handleChange: o }, disabled: d }) => [
|
|
363
360
|
r("input", {
|
|
364
361
|
id: e.path,
|
|
365
362
|
value: i.value,
|
|
366
|
-
disabled: e.disabled ||
|
|
363
|
+
disabled: e.disabled || d,
|
|
367
364
|
type: "text",
|
|
368
365
|
class: "h-9 bg-gray-100 border-gray-200 border rounded px-3 text-sm",
|
|
369
|
-
onInput:
|
|
366
|
+
onInput: o,
|
|
370
367
|
onBlur: n
|
|
371
368
|
}, null, 40, Ee)
|
|
372
369
|
]),
|
|
@@ -398,16 +395,16 @@ const Q = {
|
|
|
398
395
|
hideFieldsWithoutValue: { type: Boolean, default: !1 },
|
|
399
396
|
initialValues: {}
|
|
400
397
|
},
|
|
401
|
-
setup(
|
|
402
|
-
const { values:
|
|
403
|
-
initialValues:
|
|
404
|
-
}), i = V(), n = V(
|
|
405
|
-
n.value || (
|
|
406
|
-
}),
|
|
407
|
-
!n.value && !Y(_.value) && (
|
|
408
|
-
}), a.computedProps.push((
|
|
409
|
-
!n.value &&
|
|
410
|
-
})), a)))), p =
|
|
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(() => ({
|
|
411
408
|
analytics: !0,
|
|
412
409
|
messages: {
|
|
413
410
|
required: "{field} is required",
|
|
@@ -426,20 +423,20 @@ const Q = {
|
|
|
426
423
|
fractionDigits: "{field} may have at most {digits} decimal place(s)",
|
|
427
424
|
totalDigits: "{field} may have at most {digits} significant digit(s)"
|
|
428
425
|
},
|
|
429
|
-
...
|
|
426
|
+
...b.settings ?? {}
|
|
430
427
|
}));
|
|
431
|
-
function
|
|
428
|
+
function h(m) {
|
|
432
429
|
c(
|
|
433
430
|
(a) => {
|
|
434
|
-
|
|
431
|
+
o.value = !0, n.value = !1;
|
|
435
432
|
},
|
|
436
433
|
({ errors: a }) => {
|
|
437
|
-
|
|
434
|
+
o.value = !1;
|
|
438
435
|
}
|
|
439
436
|
)(m);
|
|
440
437
|
}
|
|
441
438
|
return (m, a) => (t(), l("form", {
|
|
442
|
-
onSubmit:
|
|
439
|
+
onSubmit: A(h, ["prevent"])
|
|
443
440
|
}, [
|
|
444
441
|
r("div", qe, [
|
|
445
442
|
n.value ? s("", !0) : (t(), l("button", {
|
|
@@ -447,7 +444,7 @@ const Q = {
|
|
|
447
444
|
type: "button",
|
|
448
445
|
class: "cursor-pointer mt-4 bg-blue-500 text-white px-4 py-2 rounded",
|
|
449
446
|
"data-testid": "submit",
|
|
450
|
-
onClick: a[0] || (a[0] = (
|
|
447
|
+
onClick: a[0] || (a[0] = (f) => n.value = !0)
|
|
451
448
|
}, " Edit ")),
|
|
452
449
|
n.value ? (t(), l("button", De, " Submit ")) : s("", !0),
|
|
453
450
|
n.value ? (t(), l("button", {
|
|
@@ -455,32 +452,32 @@ const Q = {
|
|
|
455
452
|
type: "button",
|
|
456
453
|
class: "cursor-pointer mt-4 bg-gray-200 text-black px-4 py-2 rounded",
|
|
457
454
|
"data-testid": "cancel",
|
|
458
|
-
onClick: a[1] || (a[1] = (
|
|
455
|
+
onClick: a[1] || (a[1] = (f) => n.value = !1)
|
|
459
456
|
}, " Cancel ")) : s("", !0)
|
|
460
457
|
]),
|
|
461
|
-
Object.values(
|
|
458
|
+
Object.values(v(N)).length ? (t(), l("div", Ie, [
|
|
462
459
|
a[3] || (a[3] = w(" Errors: ", -1)),
|
|
463
460
|
r("ul", null, [
|
|
464
|
-
(t(!0), l(F, null, T(
|
|
465
|
-
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)
|
|
466
463
|
]))), 128))
|
|
467
464
|
])
|
|
468
465
|
])) : s("", !0),
|
|
469
|
-
|
|
466
|
+
L(J, {
|
|
470
467
|
template: Le,
|
|
471
|
-
metadata:
|
|
468
|
+
metadata: d.value,
|
|
472
469
|
settings: p.value,
|
|
473
|
-
"onUpdate:modelValue": a[2] || (a[2] = (
|
|
470
|
+
"onUpdate:modelValue": a[2] || (a[2] = (f) => i.value = f)
|
|
474
471
|
}, null, 8, ["metadata", "settings"]),
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
Pending: ` + u(
|
|
478
|
-
Touched: ` + u(
|
|
479
|
-
Valid: ` + u(
|
|
480
|
-
Submitted: ` + u(
|
|
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) + `
|
|
481
478
|
|
|
482
479
|
// form values:
|
|
483
|
-
` + u(JSON.stringify(k
|
|
480
|
+
` + u(JSON.stringify(v(k), null, 2)) + `
|
|
484
481
|
`, 1)) : s("", !0)
|
|
485
482
|
], 32));
|
|
486
483
|
}
|
|
@@ -620,9 +617,9 @@ You can test it by filling in one of the fields.`, children: [
|
|
|
620
617
|
// validateOnBlur: true,
|
|
621
618
|
}
|
|
622
619
|
);
|
|
623
|
-
function $(
|
|
624
|
-
return
|
|
625
|
-
render: () =>
|
|
620
|
+
function $(b, k, c = {}) {
|
|
621
|
+
return U(B({
|
|
622
|
+
render: () => j(je, { ...c, metadata: b, settings: k, showDebugState: !0 })
|
|
626
623
|
}));
|
|
627
624
|
}
|
|
628
625
|
export {
|