@macrulez/vue-form-schema 0.1.1 → 0.1.5
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 +697 -410
- 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/index.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { g as S, k as R, u as q, e as $, p as ee, m as te, f as ne, d as se, h as ae, j as I, V as oe } from "./MaskEngine-BqJQYybS.js";
|
|
2
|
+
import { a as xe, b as Le, c as je, i as Je, r as Pe, s as Be, l as De, n as He } from "./MaskEngine-BqJQYybS.js";
|
|
3
|
+
import { computed as v, watchEffect as re, ref as b, onMounted as ie, watch as j, onUnmounted as le } from "vue";
|
|
4
|
+
function ge(n) {
|
|
5
|
+
const s = v(() => n.touched && n.error.length > 0), t = v(() => s.value ? n.error[0] : null), e = v(() => n.touched ? n.error : []), r = v(() => n.field.required ?? !1), d = v(
|
|
6
|
+
() => typeof n.field.disabled == "boolean" ? n.field.disabled : !1
|
|
7
|
+
);
|
|
8
|
+
return { hasError: s, errorMessage: t, allErrors: e, isRequired: r, isDisabled: d };
|
|
9
|
+
}
|
|
10
|
+
const ue = /^[\w\s\d.'"[\]()!<>=&|?:+\-*/%]+$/;
|
|
11
|
+
function ce(n, s) {
|
|
12
|
+
if (!ue.test(n))
|
|
13
|
+
return console.warn(`[vue-form-schema] Blocked unsafe expression: "${n}"`), !0;
|
|
8
14
|
try {
|
|
9
|
-
return !!new Function("values", `"use strict"; return (${
|
|
15
|
+
return !!new Function("values", `"use strict"; return (${n})`)(s);
|
|
10
16
|
} catch {
|
|
11
17
|
return !0;
|
|
12
18
|
}
|
|
13
19
|
}
|
|
14
|
-
class
|
|
20
|
+
class T {
|
|
15
21
|
constructor() {
|
|
16
22
|
this.stopHandle = null;
|
|
17
23
|
}
|
|
@@ -19,260 +25,444 @@ class H {
|
|
|
19
25
|
* Start reactively watching values and writing evaluated fields into
|
|
20
26
|
* `resolvedFields`. Also handles clearOnHide side effect.
|
|
21
27
|
*/
|
|
22
|
-
start(
|
|
23
|
-
this.stopHandle =
|
|
24
|
-
const
|
|
25
|
-
|
|
28
|
+
start(s, t, e, r) {
|
|
29
|
+
this.stopHandle = re(() => {
|
|
30
|
+
const d = t.value, u = e.value, c = this.evaluateFields(s, d);
|
|
31
|
+
r && this.clearHiddenValues(s, c, d, t, u), e.value = c;
|
|
26
32
|
});
|
|
27
33
|
}
|
|
28
34
|
stop() {
|
|
29
|
-
var
|
|
30
|
-
(
|
|
35
|
+
var s;
|
|
36
|
+
(s = this.stopHandle) == null || s.call(this), this.stopHandle = null;
|
|
31
37
|
}
|
|
32
|
-
/** Recursively evaluate visible/disabled/
|
|
33
|
-
evaluateFields(
|
|
34
|
-
return
|
|
35
|
-
const
|
|
38
|
+
/** Recursively evaluate visible/disabled/options for each field */
|
|
39
|
+
evaluateFields(s, t) {
|
|
40
|
+
return s.map((e) => {
|
|
41
|
+
const r = this.resolveBoolean(e.visible, t, !0), d = this.resolveBoolean(e.disabled, t, !1);
|
|
42
|
+
let u;
|
|
43
|
+
if (typeof e.options == "function") {
|
|
44
|
+
const m = e.options(t);
|
|
45
|
+
u = m instanceof Promise ? void 0 : m;
|
|
46
|
+
} else
|
|
47
|
+
u = e.options;
|
|
36
48
|
return {
|
|
37
|
-
...
|
|
38
|
-
visible:
|
|
39
|
-
disabled:
|
|
40
|
-
|
|
49
|
+
...e,
|
|
50
|
+
visible: r,
|
|
51
|
+
disabled: d,
|
|
52
|
+
options: u,
|
|
53
|
+
fields: e.fields ? this.evaluateFields(e.fields, t) : void 0
|
|
41
54
|
};
|
|
42
55
|
});
|
|
43
56
|
}
|
|
44
|
-
resolveBoolean(
|
|
45
|
-
return
|
|
57
|
+
resolveBoolean(s, t, e) {
|
|
58
|
+
return s === void 0 ? e : typeof s == "boolean" ? s : typeof s == "function" ? s(t) : typeof s == "string" ? ce(s, t) : e;
|
|
46
59
|
}
|
|
47
|
-
clearHiddenValues(
|
|
48
|
-
for (let u = 0; u <
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
const
|
|
52
|
-
|
|
60
|
+
clearHiddenValues(s, t, e, r, d) {
|
|
61
|
+
for (let u = 0; u < s.length; u++) {
|
|
62
|
+
const c = s[u], m = t[u], w = this.wasVisible(d, c.name), p = m.visible;
|
|
63
|
+
if (w && !p) {
|
|
64
|
+
const h = S(e, c.name), F = c.defaultValue ?? null;
|
|
65
|
+
h !== F && (r.value = R(r.value, c.name, F));
|
|
53
66
|
}
|
|
54
|
-
|
|
67
|
+
c.fields && m.fields && this.clearHiddenValues(c.fields, m.fields, e, r, d);
|
|
55
68
|
}
|
|
56
69
|
}
|
|
57
|
-
wasVisible(
|
|
58
|
-
const
|
|
59
|
-
return
|
|
70
|
+
wasVisible(s, t) {
|
|
71
|
+
const e = s.find((r) => r.name === t);
|
|
72
|
+
return e ? e.visible !== !1 : !0;
|
|
60
73
|
}
|
|
61
74
|
}
|
|
62
|
-
function
|
|
63
|
-
return new
|
|
75
|
+
function be(n, s) {
|
|
76
|
+
return new T().evaluateFields(n, s);
|
|
64
77
|
}
|
|
65
|
-
function
|
|
66
|
-
switch (
|
|
78
|
+
function fe(n, s, t) {
|
|
79
|
+
switch (n) {
|
|
67
80
|
case "required":
|
|
68
|
-
return
|
|
81
|
+
return t ? (e, r) => I(e) ? t : null : I;
|
|
69
82
|
case "minLength":
|
|
70
|
-
return
|
|
83
|
+
return ae(Number(s), t);
|
|
71
84
|
case "maxLength":
|
|
72
|
-
return
|
|
85
|
+
return se(Number(s), t);
|
|
73
86
|
case "min":
|
|
74
|
-
return
|
|
87
|
+
return ne(Number(s), t);
|
|
75
88
|
case "max":
|
|
76
|
-
return
|
|
89
|
+
return te(Number(s), t);
|
|
77
90
|
case "pattern":
|
|
78
|
-
return
|
|
91
|
+
return ee(new RegExp(String(s)), t);
|
|
79
92
|
case "email":
|
|
80
|
-
return
|
|
93
|
+
return t ? (e, r) => $(e) ? t : null : $;
|
|
81
94
|
case "url":
|
|
82
|
-
return
|
|
95
|
+
return t ? (e, r) => q(e) ? t : null : q;
|
|
83
96
|
default:
|
|
84
|
-
return console.warn(`[vue-form-schema] Unknown validator rule: "${
|
|
97
|
+
return console.warn(`[vue-form-schema] Unknown validator rule: "${n}"`), null;
|
|
85
98
|
}
|
|
86
99
|
}
|
|
87
|
-
function
|
|
88
|
-
const
|
|
89
|
-
for (const
|
|
90
|
-
const
|
|
91
|
-
|
|
100
|
+
function C(n) {
|
|
101
|
+
const s = [];
|
|
102
|
+
for (const t of n.validators ?? []) {
|
|
103
|
+
const e = fe(t.rule, t.value, t.message);
|
|
104
|
+
e && s.push(e);
|
|
92
105
|
}
|
|
93
106
|
return {
|
|
94
|
-
type:
|
|
95
|
-
name:
|
|
96
|
-
label:
|
|
97
|
-
placeholder:
|
|
98
|
-
defaultValue:
|
|
99
|
-
required:
|
|
100
|
-
disabled:
|
|
101
|
-
visible:
|
|
102
|
-
mask:
|
|
103
|
-
options:
|
|
104
|
-
validators:
|
|
105
|
-
fields:
|
|
107
|
+
type: n.type,
|
|
108
|
+
name: n.name,
|
|
109
|
+
label: n.label,
|
|
110
|
+
placeholder: n.placeholder,
|
|
111
|
+
defaultValue: n.default,
|
|
112
|
+
required: n.required,
|
|
113
|
+
disabled: n.disabled,
|
|
114
|
+
visible: n.visible,
|
|
115
|
+
mask: n.mask,
|
|
116
|
+
options: n.options,
|
|
117
|
+
validators: s.length ? s : void 0,
|
|
118
|
+
fields: n.fields ? n.fields.map(C) : void 0
|
|
106
119
|
};
|
|
107
120
|
}
|
|
108
|
-
function
|
|
109
|
-
return
|
|
121
|
+
function ve(n) {
|
|
122
|
+
return n.map(C);
|
|
110
123
|
}
|
|
111
|
-
function
|
|
112
|
-
if (!Array.isArray(
|
|
113
|
-
for (const
|
|
114
|
-
const
|
|
115
|
-
if (Array.isArray(
|
|
124
|
+
function de(n) {
|
|
125
|
+
if (!Array.isArray(n) || n.length === 0) return !1;
|
|
126
|
+
for (const s of n) {
|
|
127
|
+
const t = s.validators;
|
|
128
|
+
if (Array.isArray(t) && t.some((e) => typeof e == "function"))
|
|
116
129
|
return !1;
|
|
117
130
|
}
|
|
118
|
-
return
|
|
119
|
-
const
|
|
120
|
-
if ("default" in
|
|
121
|
-
const
|
|
122
|
-
return Array.isArray(
|
|
131
|
+
return n.some((s) => {
|
|
132
|
+
const t = s;
|
|
133
|
+
if ("default" in t) return !0;
|
|
134
|
+
const e = t.validators;
|
|
135
|
+
return Array.isArray(e) && e.length > 0 && typeof e[0] == "object" && e[0] !== null && "rule" in e[0];
|
|
123
136
|
});
|
|
124
137
|
}
|
|
125
|
-
function
|
|
126
|
-
return
|
|
138
|
+
function me(n) {
|
|
139
|
+
return de(n) ? ve(n) : n;
|
|
127
140
|
}
|
|
128
|
-
function
|
|
129
|
-
const
|
|
130
|
-
for (const
|
|
131
|
-
if (
|
|
132
|
-
const
|
|
133
|
-
Object.assign(
|
|
134
|
-
} else if (
|
|
135
|
-
const
|
|
136
|
-
e
|
|
141
|
+
function N(n, s = {}) {
|
|
142
|
+
const t = {};
|
|
143
|
+
for (const e of n)
|
|
144
|
+
if (e.type === "group" && e.fields) {
|
|
145
|
+
const r = N(e.fields, s);
|
|
146
|
+
Object.assign(t, r);
|
|
147
|
+
} else if (e.type === "array") {
|
|
148
|
+
const r = S(s, e.name);
|
|
149
|
+
t[e.name] = r ?? e.defaultValue ?? [];
|
|
137
150
|
} else {
|
|
138
|
-
const
|
|
139
|
-
e
|
|
151
|
+
const r = S(s, e.name);
|
|
152
|
+
t[e.name] = r !== void 0 ? r : e.defaultValue ?? null;
|
|
140
153
|
}
|
|
141
|
-
for (const [
|
|
142
|
-
|
|
143
|
-
return
|
|
154
|
+
for (const [e, r] of Object.entries(s))
|
|
155
|
+
e in t || (t[e] = r);
|
|
156
|
+
return t;
|
|
144
157
|
}
|
|
145
|
-
function
|
|
158
|
+
function pe(n) {
|
|
159
|
+
var M;
|
|
146
160
|
const {
|
|
147
|
-
schema:
|
|
148
|
-
initialValues:
|
|
149
|
-
validateOn:
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
(
|
|
161
|
+
schema: s,
|
|
162
|
+
initialValues: t = {},
|
|
163
|
+
validateOn: e = "blur",
|
|
164
|
+
validateMode: r = "first",
|
|
165
|
+
clearOnHide: d = !1,
|
|
166
|
+
onSubmit: u,
|
|
167
|
+
persist: c = !1,
|
|
168
|
+
persistKey: m,
|
|
169
|
+
debug: w = !1
|
|
170
|
+
} = n, p = me(s), h = new oe(300, r), F = new T(), V = m ?? `vfs:${p.map((a) => a.name).join(",")}`;
|
|
171
|
+
function E() {
|
|
172
|
+
return typeof window > "u" || !c ? null : c === "local" ? window.localStorage : window.sessionStorage;
|
|
173
|
+
}
|
|
174
|
+
const o = b(
|
|
175
|
+
N(p, t)
|
|
176
|
+
), f = b({}), g = b({}), A = b(!1), y = b(p), O = b({}), k = b({}), P = /* @__PURE__ */ new Set();
|
|
177
|
+
let x = !1;
|
|
178
|
+
F.start(p, o, y, d ?? !1);
|
|
179
|
+
async function B(a) {
|
|
180
|
+
if (typeof a.options != "function") return;
|
|
181
|
+
const i = a.options(o.value);
|
|
182
|
+
if (i instanceof Promise) {
|
|
183
|
+
O.value = { ...O.value, [a.name]: !0 };
|
|
184
|
+
try {
|
|
185
|
+
const l = await i;
|
|
186
|
+
k.value = { ...k.value, [a.name]: l };
|
|
187
|
+
} catch (l) {
|
|
188
|
+
console.warn(`[vue-form-schema] Failed to load options for "${a.name}"`, l);
|
|
189
|
+
} finally {
|
|
190
|
+
O.value = { ...O.value, [a.name]: !1 };
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const D = p.filter((a) => typeof a.options == "function");
|
|
195
|
+
ie(async () => {
|
|
196
|
+
const a = E();
|
|
197
|
+
if (a)
|
|
198
|
+
try {
|
|
199
|
+
const i = a.getItem(V);
|
|
200
|
+
if (i) {
|
|
201
|
+
const l = JSON.parse(i);
|
|
175
202
|
o.value = {
|
|
176
203
|
...o.value,
|
|
177
|
-
|
|
204
|
+
...l
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
} catch {
|
|
208
|
+
}
|
|
209
|
+
await Promise.all(D.map((i) => B(i)));
|
|
210
|
+
}), c && j(
|
|
211
|
+
o,
|
|
212
|
+
(a) => {
|
|
213
|
+
var i;
|
|
214
|
+
if (!x)
|
|
215
|
+
try {
|
|
216
|
+
(i = E()) == null || i.setItem(V, JSON.stringify(a));
|
|
217
|
+
} catch {
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
{ deep: !0 }
|
|
221
|
+
);
|
|
222
|
+
for (const a of D)
|
|
223
|
+
(M = a.optionsDeps) != null && M.length && j(
|
|
224
|
+
() => a.optionsDeps.map((i) => S(o.value, i)),
|
|
225
|
+
() => B(a)
|
|
226
|
+
);
|
|
227
|
+
w && j(
|
|
228
|
+
o,
|
|
229
|
+
(a) => {
|
|
230
|
+
console.group("[vue-form-schema] values changed"), console.log("values:", JSON.parse(JSON.stringify(a))), console.log("errors:", f.value), console.log("touched:", g.value), console.groupEnd();
|
|
231
|
+
},
|
|
232
|
+
{ deep: !0 }
|
|
233
|
+
);
|
|
234
|
+
const W = v(
|
|
235
|
+
() => y.value.map((a) => ({
|
|
236
|
+
...a,
|
|
237
|
+
options: k.value[a.name] ?? a.options,
|
|
238
|
+
optionsLoading: O.value[a.name] ?? !1
|
|
239
|
+
}))
|
|
240
|
+
), X = v(() => {
|
|
241
|
+
const a = N(p, t);
|
|
242
|
+
return JSON.stringify(o.value) !== JSON.stringify(a);
|
|
243
|
+
}), _ = v(() => {
|
|
244
|
+
const a = h.validateAll(y.value, o.value);
|
|
245
|
+
return Object.values(a).every((i) => i.length === 0);
|
|
246
|
+
});
|
|
247
|
+
function H(a) {
|
|
248
|
+
if (a) {
|
|
249
|
+
const i = h.validateField(
|
|
250
|
+
a,
|
|
251
|
+
S(o.value, a.name),
|
|
252
|
+
o.value
|
|
253
|
+
);
|
|
254
|
+
f.value = { ...f.value, [a.name]: i }, h.validateAsync(
|
|
255
|
+
a,
|
|
256
|
+
S(o.value, a.name),
|
|
257
|
+
o.value,
|
|
258
|
+
(l, L) => {
|
|
259
|
+
f.value = {
|
|
260
|
+
...f.value,
|
|
261
|
+
[l]: [...f.value[l] ?? [], ...L]
|
|
178
262
|
};
|
|
179
263
|
}
|
|
180
264
|
);
|
|
181
265
|
} else
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
266
|
+
f.value = h.validateAll(
|
|
267
|
+
y.value,
|
|
268
|
+
o.value
|
|
185
269
|
);
|
|
186
270
|
}
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
d && E(d);
|
|
195
|
-
}
|
|
271
|
+
function z(a, i) {
|
|
272
|
+
const l = J(y.value, a), L = l != null && l.transform ? l.transform(i, o.value) : i;
|
|
273
|
+
o.value = R(
|
|
274
|
+
o.value,
|
|
275
|
+
a,
|
|
276
|
+
L
|
|
277
|
+
), (e === "input" || e === "eager" && P.has(a)) && l && H(l);
|
|
196
278
|
}
|
|
197
|
-
function
|
|
198
|
-
return
|
|
279
|
+
function G(a) {
|
|
280
|
+
return S(o.value, a);
|
|
199
281
|
}
|
|
200
|
-
function
|
|
201
|
-
if (
|
|
202
|
-
const
|
|
203
|
-
|
|
282
|
+
function Q(a) {
|
|
283
|
+
if (g.value = { ...g.value, [a]: !0 }, P.add(a), e === "blur" || e === "eager") {
|
|
284
|
+
const i = J(y.value, a);
|
|
285
|
+
i && H(i);
|
|
204
286
|
}
|
|
205
287
|
}
|
|
206
|
-
async function
|
|
207
|
-
const
|
|
208
|
-
for (const
|
|
209
|
-
if (
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
), !Object.values(
|
|
213
|
-
|
|
288
|
+
async function Y() {
|
|
289
|
+
const a = {};
|
|
290
|
+
for (const l of y.value) K(l, a);
|
|
291
|
+
if (g.value = a, f.value = h.validateAll(
|
|
292
|
+
y.value,
|
|
293
|
+
o.value
|
|
294
|
+
), !Object.values(f.value).some((l) => l.length > 0)) {
|
|
295
|
+
A.value = !0;
|
|
214
296
|
try {
|
|
215
|
-
|
|
297
|
+
const l = U(y.value, o.value);
|
|
298
|
+
await (u == null ? void 0 : u(l));
|
|
216
299
|
} finally {
|
|
217
|
-
|
|
300
|
+
A.value = !1;
|
|
218
301
|
}
|
|
219
302
|
}
|
|
220
303
|
}
|
|
221
|
-
function
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
304
|
+
function Z(a) {
|
|
305
|
+
var l;
|
|
306
|
+
const i = a ?? t;
|
|
307
|
+
o.value = N(
|
|
308
|
+
p,
|
|
309
|
+
i ?? {}
|
|
310
|
+
), f.value = {}, g.value = {}, A.value = !1, x = !0, (l = E()) == null || l.removeItem(V), Promise.resolve().then(() => {
|
|
311
|
+
x = !1;
|
|
312
|
+
});
|
|
227
313
|
}
|
|
228
|
-
return
|
|
229
|
-
|
|
314
|
+
return le(() => {
|
|
315
|
+
F.stop(), h.destroy();
|
|
230
316
|
}), {
|
|
231
|
-
fields:
|
|
232
|
-
values:
|
|
233
|
-
errors:
|
|
234
|
-
touched:
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
317
|
+
fields: W,
|
|
318
|
+
values: o,
|
|
319
|
+
errors: f,
|
|
320
|
+
touched: g,
|
|
321
|
+
optionsLoading: O,
|
|
322
|
+
isDirty: X,
|
|
323
|
+
isValid: _,
|
|
324
|
+
isSubmitting: A,
|
|
325
|
+
submit: Y,
|
|
326
|
+
reset: Z,
|
|
327
|
+
setField: z,
|
|
328
|
+
getField: G,
|
|
242
329
|
// expose touch for FormRenderer
|
|
243
330
|
// @ts-expect-error - internal
|
|
244
|
-
touchField:
|
|
331
|
+
touchField: Q
|
|
245
332
|
};
|
|
246
333
|
}
|
|
247
|
-
function
|
|
248
|
-
for (const
|
|
249
|
-
if (
|
|
334
|
+
function J(n, s) {
|
|
335
|
+
for (const t of n) {
|
|
336
|
+
if (t.name === s) return t;
|
|
337
|
+
if (t.fields) {
|
|
338
|
+
const e = J(t.fields, s);
|
|
339
|
+
if (e) return e;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function K(n, s = {}) {
|
|
344
|
+
return s[n.name] = !0, n.fields && n.fields.forEach((t) => K(t, s)), s;
|
|
345
|
+
}
|
|
346
|
+
function U(n, s) {
|
|
347
|
+
const t = { ...s };
|
|
348
|
+
for (const e of n) {
|
|
349
|
+
if (e.parse) {
|
|
350
|
+
const r = S(t, e.name);
|
|
351
|
+
t[e.name] = e.parse(r);
|
|
352
|
+
}
|
|
250
353
|
if (e.fields) {
|
|
251
|
-
const
|
|
252
|
-
|
|
354
|
+
const r = U(e.fields, t);
|
|
355
|
+
Object.assign(t, r);
|
|
253
356
|
}
|
|
254
357
|
}
|
|
358
|
+
return t;
|
|
359
|
+
}
|
|
360
|
+
function Se(n, s) {
|
|
361
|
+
const t = n.map((o) => pe(o)), e = b(0), r = t.length, d = v(() => e.value === 0), u = v(() => e.value === r - 1), c = v(() => t[e.value]), m = v(
|
|
362
|
+
() => t.reduce(
|
|
363
|
+
(o, f) => ({ ...o, ...f.values.value }),
|
|
364
|
+
{}
|
|
365
|
+
)
|
|
366
|
+
), w = v(() => t.every((o) => o.isValid.value)), p = v(() => t.some((o) => o.isSubmitting.value));
|
|
367
|
+
async function h() {
|
|
368
|
+
return await t[e.value].submit(), Object.values(t[e.value].errors.value).some(
|
|
369
|
+
(f) => f.length > 0
|
|
370
|
+
) ? !1 : (u.value || e.value++, !0);
|
|
371
|
+
}
|
|
372
|
+
function F() {
|
|
373
|
+
d.value || e.value--;
|
|
374
|
+
}
|
|
375
|
+
function V(o) {
|
|
376
|
+
o >= 0 && o < r && (e.value = o);
|
|
377
|
+
}
|
|
378
|
+
async function E() {
|
|
379
|
+
for (const o of t)
|
|
380
|
+
if (await o.submit(), Object.values(o.errors.value).some((g) => g.length > 0)) return;
|
|
381
|
+
await (s == null ? void 0 : s(m.value));
|
|
382
|
+
}
|
|
383
|
+
return {
|
|
384
|
+
currentStep: e,
|
|
385
|
+
totalSteps: r,
|
|
386
|
+
isFirstStep: d,
|
|
387
|
+
isLastStep: u,
|
|
388
|
+
form: c,
|
|
389
|
+
steps: t,
|
|
390
|
+
values: m,
|
|
391
|
+
isValid: w,
|
|
392
|
+
isSubmitting: p,
|
|
393
|
+
next: h,
|
|
394
|
+
back: F,
|
|
395
|
+
goTo: V,
|
|
396
|
+
submit: E
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
function Fe(n) {
|
|
400
|
+
return { snapshot: v(() => ({
|
|
401
|
+
values: JSON.parse(JSON.stringify(n.values.value)),
|
|
402
|
+
errors: n.errors.value,
|
|
403
|
+
touched: n.touched.value,
|
|
404
|
+
isDirty: n.isDirty.value,
|
|
405
|
+
isValid: n.isValid.value,
|
|
406
|
+
isSubmitting: n.isSubmitting.value,
|
|
407
|
+
optionsLoading: n.optionsLoading.value,
|
|
408
|
+
fields: n.fields.value.map((t) => ({
|
|
409
|
+
name: t.name,
|
|
410
|
+
visible: t.visible,
|
|
411
|
+
disabled: t.disabled
|
|
412
|
+
}))
|
|
413
|
+
})) };
|
|
414
|
+
}
|
|
415
|
+
function Oe(...n) {
|
|
416
|
+
const s = /* @__PURE__ */ new Map();
|
|
417
|
+
for (const t of n)
|
|
418
|
+
for (const e of t)
|
|
419
|
+
s.set(e.name, e);
|
|
420
|
+
return Array.from(s.values());
|
|
421
|
+
}
|
|
422
|
+
function we(n, s) {
|
|
423
|
+
const t = new Set(s);
|
|
424
|
+
return n.filter((e) => !t.has(e.name));
|
|
425
|
+
}
|
|
426
|
+
function Ve(n, s) {
|
|
427
|
+
const t = new Set(s);
|
|
428
|
+
return n.filter((e) => t.has(e.name));
|
|
429
|
+
}
|
|
430
|
+
function Ee(n, s, t) {
|
|
431
|
+
return n.map((e) => e.name === s ? { ...e, ...t } : e);
|
|
255
432
|
}
|
|
256
|
-
function
|
|
257
|
-
return n
|
|
433
|
+
function Ae(n) {
|
|
434
|
+
return n;
|
|
258
435
|
}
|
|
259
436
|
export {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
437
|
+
T as ConditionEvaluator,
|
|
438
|
+
oe as ValidationEngine,
|
|
439
|
+
xe as applyMask,
|
|
440
|
+
Le as bindMask,
|
|
441
|
+
je as createFormRegistry,
|
|
442
|
+
Ae as defineSchema,
|
|
443
|
+
$ as email,
|
|
444
|
+
be as evaluateFieldConditions,
|
|
445
|
+
Ee as extendField,
|
|
446
|
+
S as getByPath,
|
|
447
|
+
te as max,
|
|
448
|
+
se as maxLength,
|
|
449
|
+
Oe as mergeSchemas,
|
|
450
|
+
ne as min,
|
|
451
|
+
ae as minLength,
|
|
452
|
+
we as omitFields,
|
|
453
|
+
ve as parseJSON,
|
|
454
|
+
ee as pattern,
|
|
455
|
+
Ve as pickFields,
|
|
456
|
+
Je as provideRegistry,
|
|
457
|
+
Pe as removeMask,
|
|
458
|
+
I as required,
|
|
459
|
+
Be as sameAs,
|
|
460
|
+
R as setByPath,
|
|
461
|
+
q as url,
|
|
462
|
+
De as useFieldArray,
|
|
463
|
+
pe as useForm,
|
|
464
|
+
Fe as useFormDebug,
|
|
465
|
+
ge as useFormField,
|
|
466
|
+
Se as useMultiStepForm,
|
|
467
|
+
He as useRegistry
|
|
278
468
|
};
|