@macrulez/vue-form-schema 0.1.1 → 0.1.6
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 +708 -412
- package/dist/MaskEngine-BqJQYybS.js +233 -0
- package/dist/MaskEngine-BwAs2Zb0.cjs +1 -0
- package/dist/__tests__/phase3.test.d.ts +2 -0
- package/dist/__tests__/phase3.test.d.ts.map +1 -0
- package/dist/__tests__/phase4.test.d.ts +2 -0
- package/dist/__tests__/phase4.test.d.ts.map +1 -0
- package/dist/__tests__/useFieldArray.test.d.ts +2 -0
- package/dist/__tests__/useFieldArray.test.d.ts.map +1 -0
- package/dist/__tests__/useMultiStepForm.test.d.ts +2 -0
- package/dist/__tests__/useMultiStepForm.test.d.ts.map +1 -0
- package/dist/core/ConditionEvaluator.d.ts +1 -1
- package/dist/core/ConditionEvaluator.d.ts.map +1 -1
- package/dist/core/ValidationEngine.d.ts +3 -1
- package/dist/core/ValidationEngine.d.ts.map +1 -1
- package/dist/core/inferTypes.d.ts +39 -0
- package/dist/core/inferTypes.d.ts.map +1 -0
- package/dist/core/registry.d.ts +17 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/schemaUtils.d.ts +20 -0
- package/dist/core/schemaUtils.d.ts.map +1 -0
- package/dist/core/types.d.ts +43 -3
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/useFieldArray.d.ts +21 -0
- package/dist/core/useFieldArray.d.ts.map +1 -0
- package/dist/core/useForm.d.ts.map +1 -1
- package/dist/core/useFormDebug.d.ts +29 -0
- package/dist/core/useFormDebug.d.ts.map +1 -0
- package/dist/core/useFormField.d.ts +18 -0
- package/dist/core/useFormField.d.ts.map +1 -0
- package/dist/core/useMultiStepForm.d.ts +30 -0
- package/dist/core/useMultiStepForm.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +386 -196
- package/dist/parsers/valibot.d.ts +20 -0
- package/dist/parsers/valibot.d.ts.map +1 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.ts +114 -18
- package/dist/ui.js +360 -193
- package/dist/valibot.cjs +1 -0
- package/dist/valibot.d.ts +84 -0
- package/dist/valibot.js +43 -0
- package/dist/yup.d.ts +26 -2
- package/dist/zod.d.ts +26 -2
- package/package.json +21 -4
- package/dist/MaskEngine-D22m29OM.js +0 -157
- package/dist/MaskEngine-hd5xHed7.cjs +0 -1
package/dist/ui.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { b as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as x, openBlock as t, createElementBlock as d, normalizeClass as A, createTextVNode as D, toDisplayString as v, createCommentVNode as k, renderSlot as q, Fragment as S, renderList as C, ref as K, onMounted as O, onUnmounted as Q, createBlock as V, withCtx as g, createElementVNode as b, computed as U, createVNode as p, unref as w, resolveDynamicComponent as E, resolveComponent as W, createSlots as X } from "vue";
|
|
2
|
+
import { b as Y, n as I, l as Z, g as M } from "./MaskEngine-BqJQYybS.js";
|
|
3
|
+
const _ = ["for"], ee = {
|
|
4
4
|
key: 0,
|
|
5
5
|
class: "vfs-field__required",
|
|
6
6
|
"aria-hidden": "true"
|
|
7
|
-
},
|
|
8
|
-
key: 1,
|
|
9
|
-
class: "vfs-field__errors",
|
|
10
|
-
role: "alert"
|
|
11
|
-
}, k = /* @__PURE__ */ h({
|
|
7
|
+
}, te = ["id"], F = /* @__PURE__ */ x({
|
|
12
8
|
__name: "BaseField",
|
|
13
9
|
props: {
|
|
14
10
|
field: {},
|
|
@@ -16,31 +12,37 @@ const G = ["for"], H = {
|
|
|
16
12
|
touched: { type: Boolean }
|
|
17
13
|
},
|
|
18
14
|
setup(e) {
|
|
19
|
-
const
|
|
20
|
-
return (
|
|
21
|
-
var
|
|
22
|
-
return
|
|
23
|
-
class:
|
|
15
|
+
const r = e;
|
|
16
|
+
return (a, s) => {
|
|
17
|
+
var n, o;
|
|
18
|
+
return t(), d("div", {
|
|
19
|
+
class: A(["vfs-field", [`vfs-field--${r.field.type}`, { "vfs-field--error": e.touched && ((n = e.error) == null ? void 0 : n.length) }]])
|
|
24
20
|
}, [
|
|
25
|
-
|
|
21
|
+
r.field.label ? (t(), d("label", {
|
|
26
22
|
key: 0,
|
|
27
|
-
for:
|
|
23
|
+
for: r.field.name,
|
|
28
24
|
class: "vfs-field__label"
|
|
29
25
|
}, [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
], 8,
|
|
33
|
-
|
|
34
|
-
e.touched && ((
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
D(v(r.field.label) + " ", 1),
|
|
27
|
+
r.field.required ? (t(), d("span", ee, "*")) : k("", !0)
|
|
28
|
+
], 8, _)) : k("", !0),
|
|
29
|
+
q(a.$slots, "default"),
|
|
30
|
+
e.touched && ((o = e.error) != null && o.length) ? (t(), d("ul", {
|
|
31
|
+
key: 1,
|
|
32
|
+
id: `${r.field.name}-error`,
|
|
33
|
+
class: "vfs-field__errors",
|
|
34
|
+
role: "alert",
|
|
35
|
+
"aria-live": "polite"
|
|
36
|
+
}, [
|
|
37
|
+
(t(!0), d(S, null, C(e.error, (h, m) => (t(), d("li", {
|
|
38
|
+
key: m,
|
|
37
39
|
class: "vfs-field__error"
|
|
38
|
-
},
|
|
39
|
-
])) :
|
|
40
|
+
}, v(h), 1))), 128))
|
|
41
|
+
], 8, te)) : k("", !0)
|
|
40
42
|
], 2);
|
|
41
43
|
};
|
|
42
44
|
}
|
|
43
|
-
}),
|
|
45
|
+
}), le = ["id", "type", "name", "value", "placeholder", "disabled", "required"], N = /* @__PURE__ */ x({
|
|
44
46
|
__name: "TextField",
|
|
45
47
|
props: {
|
|
46
48
|
field: {},
|
|
@@ -49,25 +51,25 @@ const G = ["for"], H = {
|
|
|
49
51
|
touched: { type: Boolean }
|
|
50
52
|
},
|
|
51
53
|
emits: ["update:modelValue", "blur"],
|
|
52
|
-
setup(e, { emit:
|
|
53
|
-
const
|
|
54
|
-
let
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}),
|
|
58
|
-
function
|
|
59
|
-
|
|
54
|
+
setup(e, { emit: r }) {
|
|
55
|
+
const a = e, s = r, n = K(null);
|
|
56
|
+
let o = null;
|
|
57
|
+
O(() => {
|
|
58
|
+
n.value && a.field.mask && (o = Y(n.value, a.field.mask));
|
|
59
|
+
}), Q(() => o == null ? void 0 : o());
|
|
60
|
+
function h(m) {
|
|
61
|
+
s("update:modelValue", m.target.value);
|
|
60
62
|
}
|
|
61
|
-
return (
|
|
63
|
+
return (m, i) => (t(), V(F, {
|
|
62
64
|
field: e.field,
|
|
63
65
|
error: e.error,
|
|
64
66
|
touched: e.touched
|
|
65
67
|
}, {
|
|
66
|
-
default:
|
|
67
|
-
|
|
68
|
+
default: g(() => [
|
|
69
|
+
b("input", {
|
|
68
70
|
id: e.field.name,
|
|
69
71
|
ref_key: "inputRef",
|
|
70
|
-
ref:
|
|
72
|
+
ref: n,
|
|
71
73
|
type: e.field.type === "email" ? "email" : "text",
|
|
72
74
|
name: e.field.name,
|
|
73
75
|
value: e.modelValue,
|
|
@@ -75,14 +77,14 @@ const G = ["for"], H = {
|
|
|
75
77
|
disabled: e.field.disabled === !0,
|
|
76
78
|
required: e.field.required,
|
|
77
79
|
class: "vfs-input",
|
|
78
|
-
onInput:
|
|
79
|
-
onBlur:
|
|
80
|
-
}, null, 40,
|
|
80
|
+
onInput: h,
|
|
81
|
+
onBlur: i[0] || (i[0] = ($) => s("blur"))
|
|
82
|
+
}, null, 40, le)
|
|
81
83
|
]),
|
|
82
84
|
_: 1
|
|
83
85
|
}, 8, ["field", "error", "touched"]));
|
|
84
86
|
}
|
|
85
|
-
}),
|
|
87
|
+
}), ne = ["id", "name", "value", "placeholder", "disabled", "required"], z = /* @__PURE__ */ x({
|
|
86
88
|
__name: "NumberField",
|
|
87
89
|
props: {
|
|
88
90
|
field: {},
|
|
@@ -91,19 +93,19 @@ const G = ["for"], H = {
|
|
|
91
93
|
touched: { type: Boolean }
|
|
92
94
|
},
|
|
93
95
|
emits: ["update:modelValue", "blur"],
|
|
94
|
-
setup(e, { emit:
|
|
95
|
-
const
|
|
96
|
-
function
|
|
97
|
-
const
|
|
98
|
-
|
|
96
|
+
setup(e, { emit: r }) {
|
|
97
|
+
const a = r;
|
|
98
|
+
function s(n) {
|
|
99
|
+
const o = n.target.value;
|
|
100
|
+
a("update:modelValue", o === "" ? null : Number(o));
|
|
99
101
|
}
|
|
100
|
-
return (
|
|
102
|
+
return (n, o) => (t(), V(F, {
|
|
101
103
|
field: e.field,
|
|
102
104
|
error: e.error,
|
|
103
105
|
touched: e.touched
|
|
104
106
|
}, {
|
|
105
|
-
default:
|
|
106
|
-
|
|
107
|
+
default: g(() => [
|
|
108
|
+
b("input", {
|
|
107
109
|
id: e.field.name,
|
|
108
110
|
type: "number",
|
|
109
111
|
name: e.field.name,
|
|
@@ -112,14 +114,14 @@ const G = ["for"], H = {
|
|
|
112
114
|
disabled: e.field.disabled === !0,
|
|
113
115
|
required: e.field.required,
|
|
114
116
|
class: "vfs-input",
|
|
115
|
-
onInput:
|
|
116
|
-
onBlur:
|
|
117
|
-
}, null, 40,
|
|
117
|
+
onInput: s,
|
|
118
|
+
onBlur: o[0] || (o[0] = (h) => a("blur"))
|
|
119
|
+
}, null, 40, ne)
|
|
118
120
|
]),
|
|
119
121
|
_: 1
|
|
120
122
|
}, 8, ["field", "error", "touched"]));
|
|
121
123
|
}
|
|
122
|
-
}),
|
|
124
|
+
}), ae = ["id", "name", "value", "placeholder", "disabled", "required"], P = /* @__PURE__ */ x({
|
|
123
125
|
__name: "TextareaField",
|
|
124
126
|
props: {
|
|
125
127
|
field: {},
|
|
@@ -128,15 +130,15 @@ const G = ["for"], H = {
|
|
|
128
130
|
touched: { type: Boolean }
|
|
129
131
|
},
|
|
130
132
|
emits: ["update:modelValue", "blur"],
|
|
131
|
-
setup(e, { emit:
|
|
132
|
-
const
|
|
133
|
-
return (
|
|
133
|
+
setup(e, { emit: r }) {
|
|
134
|
+
const a = r;
|
|
135
|
+
return (s, n) => (t(), V(F, {
|
|
134
136
|
field: e.field,
|
|
135
137
|
error: e.error,
|
|
136
138
|
touched: e.touched
|
|
137
139
|
}, {
|
|
138
|
-
default:
|
|
139
|
-
|
|
140
|
+
default: g(() => [
|
|
141
|
+
b("textarea", {
|
|
140
142
|
id: e.field.name,
|
|
141
143
|
name: e.field.name,
|
|
142
144
|
value: e.modelValue,
|
|
@@ -144,14 +146,17 @@ const G = ["for"], H = {
|
|
|
144
146
|
disabled: e.field.disabled === !0,
|
|
145
147
|
required: e.field.required,
|
|
146
148
|
class: "vfs-textarea",
|
|
147
|
-
onInput:
|
|
148
|
-
onBlur:
|
|
149
|
-
}, null, 40,
|
|
149
|
+
onInput: n[0] || (n[0] = (o) => a("update:modelValue", o.target.value)),
|
|
150
|
+
onBlur: n[1] || (n[1] = (o) => a("blur"))
|
|
151
|
+
}, null, 40, ae)
|
|
150
152
|
]),
|
|
151
153
|
_: 1
|
|
152
154
|
}, 8, ["field", "error", "touched"]));
|
|
153
155
|
}
|
|
154
|
-
}),
|
|
156
|
+
}), oe = {
|
|
157
|
+
key: 0,
|
|
158
|
+
class: "vfs-select-loading"
|
|
159
|
+
}, re = ["id", "name", "disabled", "required"], ue = ["selected"], de = ["value", "selected"], j = /* @__PURE__ */ x({
|
|
155
160
|
__name: "SelectField",
|
|
156
161
|
props: {
|
|
157
162
|
field: {},
|
|
@@ -160,47 +165,49 @@ const G = ["for"], H = {
|
|
|
160
165
|
touched: { type: Boolean }
|
|
161
166
|
},
|
|
162
167
|
emits: ["update:modelValue", "blur"],
|
|
163
|
-
setup(e, { emit:
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
m
|
|
168
|
+
setup(e, { emit: r }) {
|
|
169
|
+
const a = e, s = r, n = U(
|
|
170
|
+
() => Array.isArray(a.field.options) ? a.field.options : []
|
|
171
|
+
);
|
|
172
|
+
function o(h) {
|
|
173
|
+
const m = h.target, i = n.value.find(($) => String($.value) === m.value);
|
|
174
|
+
s("update:modelValue", (i == null ? void 0 : i.value) ?? m.value);
|
|
169
175
|
}
|
|
170
|
-
return (
|
|
176
|
+
return (h, m) => (t(), V(F, {
|
|
171
177
|
field: e.field,
|
|
172
178
|
error: e.error,
|
|
173
179
|
touched: e.touched
|
|
174
180
|
}, {
|
|
175
|
-
default:
|
|
176
|
-
|
|
181
|
+
default: g(() => [
|
|
182
|
+
e.field.optionsLoading ? (t(), d("div", oe, "Loading…")) : (t(), d("select", {
|
|
183
|
+
key: 1,
|
|
177
184
|
id: e.field.name,
|
|
178
185
|
name: e.field.name,
|
|
179
|
-
disabled: e.field.disabled === !0,
|
|
186
|
+
disabled: e.field.disabled === !0 || e.field.optionsLoading,
|
|
180
187
|
required: e.field.required,
|
|
181
188
|
class: "vfs-select",
|
|
182
|
-
onChange:
|
|
183
|
-
onBlur:
|
|
189
|
+
onChange: o,
|
|
190
|
+
onBlur: m[0] || (m[0] = (i) => s("blur"))
|
|
184
191
|
}, [
|
|
185
|
-
|
|
192
|
+
b("option", {
|
|
186
193
|
value: "",
|
|
187
194
|
disabled: "",
|
|
188
195
|
selected: e.modelValue === null || e.modelValue === void 0 || e.modelValue === ""
|
|
189
|
-
},
|
|
190
|
-
(
|
|
191
|
-
key: String(
|
|
192
|
-
value: String(
|
|
193
|
-
selected: e.modelValue ===
|
|
194
|
-
},
|
|
195
|
-
], 40,
|
|
196
|
+
}, v(e.field.placeholder ?? "Select an option"), 9, ue),
|
|
197
|
+
(t(!0), d(S, null, C(n.value, (i) => (t(), d("option", {
|
|
198
|
+
key: String(i.value),
|
|
199
|
+
value: String(i.value),
|
|
200
|
+
selected: e.modelValue === i.value
|
|
201
|
+
}, v(i.label), 9, de))), 128))
|
|
202
|
+
], 40, re))
|
|
196
203
|
]),
|
|
197
204
|
_: 1
|
|
198
205
|
}, 8, ["field", "error", "touched"]));
|
|
199
206
|
}
|
|
200
|
-
}),
|
|
207
|
+
}), ie = { class: "vfs-checkbox-label" }, se = ["id", "name", "checked", "disabled", "required"], me = {
|
|
201
208
|
key: 0,
|
|
202
209
|
class: "vfs-checkbox-text"
|
|
203
|
-
},
|
|
210
|
+
}, G = /* @__PURE__ */ x({
|
|
204
211
|
__name: "CheckboxField",
|
|
205
212
|
props: {
|
|
206
213
|
field: {},
|
|
@@ -209,16 +216,16 @@ const G = ["for"], H = {
|
|
|
209
216
|
touched: { type: Boolean }
|
|
210
217
|
},
|
|
211
218
|
emits: ["update:modelValue", "blur"],
|
|
212
|
-
setup(e, { emit:
|
|
213
|
-
const
|
|
214
|
-
return (
|
|
219
|
+
setup(e, { emit: r }) {
|
|
220
|
+
const a = r;
|
|
221
|
+
return (s, n) => (t(), V(F, {
|
|
215
222
|
field: { ...e.field, label: void 0 },
|
|
216
223
|
error: e.error,
|
|
217
224
|
touched: e.touched
|
|
218
225
|
}, {
|
|
219
|
-
default:
|
|
220
|
-
|
|
221
|
-
|
|
226
|
+
default: g(() => [
|
|
227
|
+
b("label", ie, [
|
|
228
|
+
b("input", {
|
|
222
229
|
id: e.field.name,
|
|
223
230
|
type: "checkbox",
|
|
224
231
|
name: e.field.name,
|
|
@@ -226,16 +233,16 @@ const G = ["for"], H = {
|
|
|
226
233
|
disabled: e.field.disabled === !0,
|
|
227
234
|
required: e.field.required,
|
|
228
235
|
class: "vfs-checkbox",
|
|
229
|
-
onChange:
|
|
230
|
-
onBlur:
|
|
231
|
-
}, null, 40,
|
|
232
|
-
e.field.label ? (
|
|
236
|
+
onChange: n[0] || (n[0] = (o) => a("update:modelValue", o.target.checked)),
|
|
237
|
+
onBlur: n[1] || (n[1] = (o) => a("blur"))
|
|
238
|
+
}, null, 40, se),
|
|
239
|
+
e.field.label ? (t(), d("span", me, v(e.field.label), 1)) : k("", !0)
|
|
233
240
|
])
|
|
234
241
|
]),
|
|
235
242
|
_: 1
|
|
236
243
|
}, 8, ["field", "error", "touched"]));
|
|
237
244
|
}
|
|
238
|
-
}),
|
|
245
|
+
}), ce = ["aria-labelledby"], fe = ["name", "value", "checked", "disabled", "onChange"], H = /* @__PURE__ */ x({
|
|
239
246
|
__name: "RadioField",
|
|
240
247
|
props: {
|
|
241
248
|
field: {},
|
|
@@ -244,41 +251,41 @@ const G = ["for"], H = {
|
|
|
244
251
|
touched: { type: Boolean }
|
|
245
252
|
},
|
|
246
253
|
emits: ["update:modelValue", "blur"],
|
|
247
|
-
setup(e, { emit:
|
|
248
|
-
const
|
|
249
|
-
return (
|
|
254
|
+
setup(e, { emit: r }) {
|
|
255
|
+
const a = r;
|
|
256
|
+
return (s, n) => (t(), V(F, {
|
|
250
257
|
field: e.field,
|
|
251
258
|
error: e.error,
|
|
252
259
|
touched: e.touched
|
|
253
260
|
}, {
|
|
254
|
-
default:
|
|
255
|
-
|
|
261
|
+
default: g(() => [
|
|
262
|
+
b("div", {
|
|
256
263
|
class: "vfs-radio-group",
|
|
257
264
|
role: "radiogroup",
|
|
258
265
|
"aria-labelledby": e.field.name + "-label"
|
|
259
266
|
}, [
|
|
260
|
-
(
|
|
261
|
-
key: String(
|
|
267
|
+
(t(!0), d(S, null, C(e.field.options, (o) => (t(), d("label", {
|
|
268
|
+
key: String(o.value),
|
|
262
269
|
class: "vfs-radio-label"
|
|
263
270
|
}, [
|
|
264
|
-
|
|
271
|
+
b("input", {
|
|
265
272
|
type: "radio",
|
|
266
273
|
name: e.field.name,
|
|
267
|
-
value: String(
|
|
268
|
-
checked: e.modelValue ===
|
|
274
|
+
value: String(o.value),
|
|
275
|
+
checked: e.modelValue === o.value,
|
|
269
276
|
disabled: e.field.disabled === !0,
|
|
270
277
|
class: "vfs-radio",
|
|
271
|
-
onChange: (
|
|
272
|
-
onBlur:
|
|
273
|
-
}, null, 40,
|
|
274
|
-
|
|
278
|
+
onChange: (h) => a("update:modelValue", o.value),
|
|
279
|
+
onBlur: n[0] || (n[0] = (h) => a("blur"))
|
|
280
|
+
}, null, 40, fe),
|
|
281
|
+
D(" " + v(o.label), 1)
|
|
275
282
|
]))), 128))
|
|
276
|
-
], 8,
|
|
283
|
+
], 8, ce)
|
|
277
284
|
]),
|
|
278
285
|
_: 1
|
|
279
286
|
}, 8, ["field", "error", "touched"]));
|
|
280
287
|
}
|
|
281
|
-
}),
|
|
288
|
+
}), ve = ["id", "name", "value", "disabled", "required"], J = /* @__PURE__ */ x({
|
|
282
289
|
__name: "DateField",
|
|
283
290
|
props: {
|
|
284
291
|
field: {},
|
|
@@ -287,15 +294,15 @@ const G = ["for"], H = {
|
|
|
287
294
|
touched: { type: Boolean }
|
|
288
295
|
},
|
|
289
296
|
emits: ["update:modelValue", "blur"],
|
|
290
|
-
setup(e, { emit:
|
|
291
|
-
const
|
|
292
|
-
return (
|
|
297
|
+
setup(e, { emit: r }) {
|
|
298
|
+
const a = r;
|
|
299
|
+
return (s, n) => (t(), V(F, {
|
|
293
300
|
field: e.field,
|
|
294
301
|
error: e.error,
|
|
295
302
|
touched: e.touched
|
|
296
303
|
}, {
|
|
297
|
-
default:
|
|
298
|
-
|
|
304
|
+
default: g(() => [
|
|
305
|
+
b("input", {
|
|
299
306
|
id: e.field.name,
|
|
300
307
|
type: "date",
|
|
301
308
|
name: e.field.name,
|
|
@@ -303,17 +310,101 @@ const G = ["for"], H = {
|
|
|
303
310
|
disabled: e.field.disabled === !0,
|
|
304
311
|
required: e.field.required,
|
|
305
312
|
class: "vfs-input",
|
|
306
|
-
onInput:
|
|
307
|
-
onBlur:
|
|
308
|
-
}, null, 40,
|
|
313
|
+
onInput: n[0] || (n[0] = (o) => a("update:modelValue", o.target.value)),
|
|
314
|
+
onBlur: n[1] || (n[1] = (o) => a("blur"))
|
|
315
|
+
}, null, 40, ve)
|
|
309
316
|
]),
|
|
310
317
|
_: 1
|
|
311
318
|
}, 8, ["field", "error", "touched"]));
|
|
312
319
|
}
|
|
313
|
-
}),
|
|
320
|
+
}), be = { class: "vfs-array" }, he = {
|
|
321
|
+
key: 0,
|
|
322
|
+
class: "vfs-field__label"
|
|
323
|
+
}, ye = ["onClick"], $e = /* @__PURE__ */ x({
|
|
324
|
+
__name: "ArrayField",
|
|
325
|
+
props: {
|
|
326
|
+
field: {},
|
|
327
|
+
form: {},
|
|
328
|
+
components: {}
|
|
329
|
+
},
|
|
330
|
+
setup(e) {
|
|
331
|
+
const r = e, a = I(), s = {
|
|
332
|
+
text: N,
|
|
333
|
+
email: N,
|
|
334
|
+
number: z,
|
|
335
|
+
textarea: P,
|
|
336
|
+
select: j,
|
|
337
|
+
checkbox: G,
|
|
338
|
+
radio: H,
|
|
339
|
+
date: J
|
|
340
|
+
};
|
|
341
|
+
function n(c) {
|
|
342
|
+
var l;
|
|
343
|
+
return c.component ? c.component : ((l = r.components) == null ? void 0 : l[c.type]) ?? a[c.type] ?? s[c.type] ?? null;
|
|
344
|
+
}
|
|
345
|
+
const { rows: o, append: h, remove: m } = Z(r.form, r.field.name);
|
|
346
|
+
function i(c) {
|
|
347
|
+
return M(r.form.values.value, c.name);
|
|
348
|
+
}
|
|
349
|
+
function $(c, l) {
|
|
350
|
+
r.form.setField(c.name, l);
|
|
351
|
+
}
|
|
352
|
+
function B(c) {
|
|
353
|
+
var f;
|
|
354
|
+
const l = r.form;
|
|
355
|
+
(f = l.touchField) == null || f.call(l, c.name);
|
|
356
|
+
}
|
|
357
|
+
function L(c) {
|
|
358
|
+
return r.form.errors.value[c.name] ?? [];
|
|
359
|
+
}
|
|
360
|
+
function T(c) {
|
|
361
|
+
return r.form.touched.value[c.name] ?? !1;
|
|
362
|
+
}
|
|
363
|
+
return (c, l) => (t(), d("div", be, [
|
|
364
|
+
p(F, {
|
|
365
|
+
field: { ...e.field, label: void 0 },
|
|
366
|
+
error: [],
|
|
367
|
+
touched: !1
|
|
368
|
+
}, {
|
|
369
|
+
default: g(() => [
|
|
370
|
+
e.field.label ? (t(), d("div", he, v(e.field.label), 1)) : k("", !0),
|
|
371
|
+
(t(!0), d(S, null, C(w(o), (f) => (t(), d("div", {
|
|
372
|
+
key: f.key,
|
|
373
|
+
class: "vfs-array__row"
|
|
374
|
+
}, [
|
|
375
|
+
(t(!0), d(S, null, C(f.fields, (y) => (t(), d(S, {
|
|
376
|
+
key: y.name
|
|
377
|
+
}, [
|
|
378
|
+
n(y) ? (t(), V(E(n(y)), {
|
|
379
|
+
key: 0,
|
|
380
|
+
field: y,
|
|
381
|
+
"model-value": i(y),
|
|
382
|
+
error: L(y),
|
|
383
|
+
touched: T(y),
|
|
384
|
+
"onUpdate:modelValue": (u) => $(y, u),
|
|
385
|
+
onBlur: (u) => B(y)
|
|
386
|
+
}, null, 40, ["field", "model-value", "error", "touched", "onUpdate:modelValue", "onBlur"])) : k("", !0)
|
|
387
|
+
], 64))), 128)),
|
|
388
|
+
b("button", {
|
|
389
|
+
type: "button",
|
|
390
|
+
class: "vfs-array__remove",
|
|
391
|
+
onClick: (y) => w(m)(f.index)
|
|
392
|
+
}, " Remove ", 8, ye)
|
|
393
|
+
]))), 128)),
|
|
394
|
+
b("button", {
|
|
395
|
+
type: "button",
|
|
396
|
+
class: "vfs-array__add",
|
|
397
|
+
onClick: l[0] || (l[0] = (f) => w(h)())
|
|
398
|
+
}, " + Add row ")
|
|
399
|
+
]),
|
|
400
|
+
_: 1
|
|
401
|
+
}, 8, ["field"])
|
|
402
|
+
]));
|
|
403
|
+
}
|
|
404
|
+
}), ke = {
|
|
314
405
|
key: 1,
|
|
315
406
|
class: "vfs-group"
|
|
316
|
-
},
|
|
407
|
+
}, Ve = { key: 0 }, ge = ["disabled"], xe = /* @__PURE__ */ x({
|
|
317
408
|
__name: "FormRenderer",
|
|
318
409
|
props: {
|
|
319
410
|
form: {},
|
|
@@ -321,118 +412,194 @@ const G = ["for"], H = {
|
|
|
321
412
|
submitLabel: {}
|
|
322
413
|
},
|
|
323
414
|
emits: ["submit"],
|
|
324
|
-
setup(e, { emit:
|
|
325
|
-
const
|
|
326
|
-
text:
|
|
327
|
-
email:
|
|
328
|
-
number:
|
|
329
|
-
textarea:
|
|
330
|
-
select:
|
|
331
|
-
checkbox:
|
|
332
|
-
radio:
|
|
333
|
-
date:
|
|
415
|
+
setup(e, { emit: r }) {
|
|
416
|
+
const a = e, s = I(), n = r, o = {
|
|
417
|
+
text: N,
|
|
418
|
+
email: N,
|
|
419
|
+
number: z,
|
|
420
|
+
textarea: P,
|
|
421
|
+
select: j,
|
|
422
|
+
checkbox: G,
|
|
423
|
+
radio: H,
|
|
424
|
+
date: J
|
|
334
425
|
};
|
|
335
|
-
function l
|
|
426
|
+
function h(l) {
|
|
336
427
|
var f;
|
|
337
|
-
return ((f =
|
|
428
|
+
return l.component ? l.component : ((f = a.components) == null ? void 0 : f[l.type]) ?? s[l.type] ?? o[l.type] ?? null;
|
|
338
429
|
}
|
|
339
|
-
function
|
|
340
|
-
return
|
|
430
|
+
function m(l) {
|
|
431
|
+
return M(a.form.values.value, l.name);
|
|
341
432
|
}
|
|
342
|
-
function
|
|
343
|
-
|
|
433
|
+
function i(l, f) {
|
|
434
|
+
a.form.setField(l.name, f);
|
|
344
435
|
}
|
|
345
|
-
function $(
|
|
346
|
-
var
|
|
347
|
-
const f =
|
|
348
|
-
(
|
|
436
|
+
function $(l) {
|
|
437
|
+
var y;
|
|
438
|
+
const f = a.form;
|
|
439
|
+
(y = f.touchField) == null || y.call(f, l.name);
|
|
349
440
|
}
|
|
350
|
-
function
|
|
351
|
-
return
|
|
441
|
+
function B(l) {
|
|
442
|
+
return a.form.errors.value[l.name] ?? [];
|
|
352
443
|
}
|
|
353
|
-
function
|
|
354
|
-
return
|
|
444
|
+
function L(l) {
|
|
445
|
+
return a.form.touched.value[l.name] ?? !1;
|
|
355
446
|
}
|
|
356
447
|
const T = U(
|
|
357
|
-
() =>
|
|
448
|
+
() => a.form.fields.value.filter((l) => l.visible !== !1)
|
|
358
449
|
);
|
|
359
|
-
async function
|
|
360
|
-
|
|
450
|
+
async function c(l) {
|
|
451
|
+
l.preventDefault(), await a.form.submit(), n("submit");
|
|
361
452
|
}
|
|
362
|
-
return (
|
|
363
|
-
const
|
|
364
|
-
return
|
|
453
|
+
return (l, f) => {
|
|
454
|
+
const y = W("FormRenderer", !0);
|
|
455
|
+
return t(), d("form", {
|
|
365
456
|
class: "vfs-form",
|
|
366
457
|
novalidate: "",
|
|
367
|
-
onSubmit:
|
|
458
|
+
onSubmit: c
|
|
368
459
|
}, [
|
|
369
|
-
(
|
|
370
|
-
key:
|
|
460
|
+
(t(!0), d(S, null, C(T.value, (u) => (t(), d(S, {
|
|
461
|
+
key: u.name
|
|
371
462
|
}, [
|
|
372
|
-
|
|
463
|
+
l.$slots[`field-${u.name}`] ? q(l.$slots, `field-${u.name}`, {
|
|
373
464
|
key: 0,
|
|
374
|
-
field:
|
|
375
|
-
value:
|
|
376
|
-
error:
|
|
377
|
-
touched:
|
|
378
|
-
setValue: (
|
|
379
|
-
touch: () => $(
|
|
380
|
-
}) :
|
|
381
|
-
|
|
382
|
-
|
|
465
|
+
field: u,
|
|
466
|
+
value: m(u),
|
|
467
|
+
error: B(u),
|
|
468
|
+
touched: L(u),
|
|
469
|
+
setValue: (R) => i(u, R),
|
|
470
|
+
touch: () => $(u)
|
|
471
|
+
}) : u.type === "group" ? (t(), d("fieldset", ke, [
|
|
472
|
+
u.label ? (t(), d("legend", Ve, v(u.label), 1)) : k("", !0),
|
|
473
|
+
u.fields ? (t(), V(y, {
|
|
383
474
|
key: 1,
|
|
384
475
|
form: e.form,
|
|
385
476
|
components: e.components
|
|
386
|
-
}, null, 8, ["form", "components"])) :
|
|
387
|
-
])) :
|
|
477
|
+
}, null, 8, ["form", "components"])) : k("", !0)
|
|
478
|
+
])) : u.type === "array" ? (t(), V($e, {
|
|
388
479
|
key: 2,
|
|
389
|
-
field:
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
u
|
|
480
|
+
field: u,
|
|
481
|
+
form: e.form,
|
|
482
|
+
components: e.components
|
|
483
|
+
}, null, 8, ["field", "form", "components"])) : h(u) ? (t(), V(E(h(u)), {
|
|
484
|
+
key: 3,
|
|
485
|
+
field: u,
|
|
486
|
+
"model-value": m(u),
|
|
487
|
+
error: B(u),
|
|
488
|
+
touched: L(u),
|
|
489
|
+
"onUpdate:modelValue": (R) => i(u, R),
|
|
490
|
+
onBlur: (R) => $(u)
|
|
491
|
+
}, X({ _: 2 }, [
|
|
492
|
+
l.$slots[`label-${u.name}`] ? {
|
|
397
493
|
name: "label",
|
|
398
|
-
fn:
|
|
399
|
-
|
|
494
|
+
fn: g(() => [
|
|
495
|
+
q(l.$slots, `label-${u.name}`, { field: u })
|
|
400
496
|
]),
|
|
401
497
|
key: "0"
|
|
402
498
|
} : void 0,
|
|
403
|
-
|
|
499
|
+
l.$slots[`error-${u.name}`] ? {
|
|
404
500
|
name: "error",
|
|
405
|
-
fn:
|
|
406
|
-
|
|
407
|
-
field:
|
|
408
|
-
error:
|
|
501
|
+
fn: g(() => [
|
|
502
|
+
q(l.$slots, `error-${u.name}`, {
|
|
503
|
+
field: u,
|
|
504
|
+
error: B(u)
|
|
409
505
|
})
|
|
410
506
|
]),
|
|
411
507
|
key: "1"
|
|
412
508
|
} : void 0
|
|
413
|
-
]), 1064, ["field", "model-value", "error", "touched", "onUpdate:modelValue", "onBlur"])) :
|
|
509
|
+
]), 1064, ["field", "model-value", "error", "touched", "onUpdate:modelValue", "onBlur"])) : k("", !0)
|
|
414
510
|
], 64))), 128)),
|
|
415
|
-
|
|
511
|
+
q(l.$slots, "submit", {
|
|
416
512
|
isSubmitting: e.form.isSubmitting.value,
|
|
417
513
|
isValid: e.form.isValid.value
|
|
418
514
|
}, () => [
|
|
419
|
-
|
|
515
|
+
b("button", {
|
|
420
516
|
type: "submit",
|
|
421
517
|
disabled: e.form.isSubmitting.value,
|
|
422
518
|
class: "vfs-submit"
|
|
423
|
-
},
|
|
519
|
+
}, v(e.submitLabel ?? "Submit"), 9, ge)
|
|
424
520
|
])
|
|
425
521
|
], 32);
|
|
426
522
|
};
|
|
427
523
|
}
|
|
524
|
+
}), Se = { class: "vfs-multistep" }, Be = { class: "vfs-multistep__steps" }, Fe = { class: "vfs-multistep__step-number" }, Ce = {
|
|
525
|
+
key: 0,
|
|
526
|
+
class: "vfs-multistep__step-label"
|
|
527
|
+
}, qe = { class: "vfs-multistep__progress" }, Le = { class: "vfs-multistep__nav" }, Re = ["disabled"], we = /* @__PURE__ */ x({
|
|
528
|
+
__name: "MultiStepFormRenderer",
|
|
529
|
+
props: {
|
|
530
|
+
form: {},
|
|
531
|
+
components: {},
|
|
532
|
+
submitLabel: {},
|
|
533
|
+
nextLabel: {},
|
|
534
|
+
backLabel: {},
|
|
535
|
+
stepLabels: {}
|
|
536
|
+
},
|
|
537
|
+
emits: ["submit"],
|
|
538
|
+
setup(e, { emit: r }) {
|
|
539
|
+
const a = e, s = r;
|
|
540
|
+
async function n() {
|
|
541
|
+
await a.form.next();
|
|
542
|
+
}
|
|
543
|
+
async function o() {
|
|
544
|
+
await a.form.submit(), s("submit");
|
|
545
|
+
}
|
|
546
|
+
return (h, m) => (t(), d("div", Se, [
|
|
547
|
+
b("div", Be, [
|
|
548
|
+
(t(!0), d(S, null, C(e.form.steps, (i, $) => {
|
|
549
|
+
var B;
|
|
550
|
+
return t(), d("div", {
|
|
551
|
+
key: $,
|
|
552
|
+
class: A(["vfs-multistep__step", {
|
|
553
|
+
"vfs-multistep__step--active": $ === e.form.currentStep.value,
|
|
554
|
+
"vfs-multistep__step--done": $ < e.form.currentStep.value
|
|
555
|
+
}])
|
|
556
|
+
}, [
|
|
557
|
+
b("span", Fe, v($ + 1), 1),
|
|
558
|
+
(B = e.stepLabels) != null && B[$] ? (t(), d("span", Ce, v(e.stepLabels[$]), 1)) : k("", !0)
|
|
559
|
+
], 2);
|
|
560
|
+
}), 128))
|
|
561
|
+
]),
|
|
562
|
+
b("div", qe, " Step " + v(e.form.currentStep.value + 1) + " of " + v(e.form.totalSteps), 1),
|
|
563
|
+
p(xe, {
|
|
564
|
+
form: e.form.form.value,
|
|
565
|
+
components: e.components
|
|
566
|
+
}, {
|
|
567
|
+
submit: g(() => [
|
|
568
|
+
b("div", Le, [
|
|
569
|
+
e.form.isFirstStep.value ? k("", !0) : (t(), d("button", {
|
|
570
|
+
key: 0,
|
|
571
|
+
type: "button",
|
|
572
|
+
class: "vfs-multistep__back",
|
|
573
|
+
onClick: m[0] || (m[0] = (i) => e.form.back())
|
|
574
|
+
}, v(e.backLabel ?? "← Back"), 1)),
|
|
575
|
+
e.form.isLastStep.value ? (t(), d("button", {
|
|
576
|
+
key: 2,
|
|
577
|
+
type: "button",
|
|
578
|
+
class: "vfs-submit",
|
|
579
|
+
disabled: e.form.isSubmitting.value,
|
|
580
|
+
onClick: o
|
|
581
|
+
}, v(e.submitLabel ?? "Submit"), 9, Re)) : (t(), d("button", {
|
|
582
|
+
key: 1,
|
|
583
|
+
type: "button",
|
|
584
|
+
class: "vfs-multistep__next",
|
|
585
|
+
onClick: n
|
|
586
|
+
}, v(e.nextLabel ?? "Next →"), 1))
|
|
587
|
+
])
|
|
588
|
+
]),
|
|
589
|
+
_: 1
|
|
590
|
+
}, 8, ["form", "components"])
|
|
591
|
+
]));
|
|
592
|
+
}
|
|
428
593
|
});
|
|
429
594
|
export {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
595
|
+
$e as ArrayField,
|
|
596
|
+
G as CheckboxField,
|
|
597
|
+
J as DateField,
|
|
598
|
+
xe as FormRenderer,
|
|
599
|
+
we as MultiStepFormRenderer,
|
|
600
|
+
z as NumberField,
|
|
601
|
+
H as RadioField,
|
|
602
|
+
j as SelectField,
|
|
603
|
+
N as TextField,
|
|
604
|
+
P as TextareaField
|
|
438
605
|
};
|