@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.
Files changed (51) hide show
  1. package/README.md +697 -410
  2. package/dist/MaskEngine-BqJQYybS.js +233 -0
  3. package/dist/MaskEngine-BwAs2Zb0.cjs +1 -0
  4. package/dist/__tests__/phase3.test.d.ts +2 -0
  5. package/dist/__tests__/phase3.test.d.ts.map +1 -0
  6. package/dist/__tests__/phase4.test.d.ts +2 -0
  7. package/dist/__tests__/phase4.test.d.ts.map +1 -0
  8. package/dist/__tests__/useFieldArray.test.d.ts +2 -0
  9. package/dist/__tests__/useFieldArray.test.d.ts.map +1 -0
  10. package/dist/__tests__/useMultiStepForm.test.d.ts +2 -0
  11. package/dist/__tests__/useMultiStepForm.test.d.ts.map +1 -0
  12. package/dist/core/ConditionEvaluator.d.ts +1 -1
  13. package/dist/core/ConditionEvaluator.d.ts.map +1 -1
  14. package/dist/core/ValidationEngine.d.ts +3 -1
  15. package/dist/core/ValidationEngine.d.ts.map +1 -1
  16. package/dist/core/inferTypes.d.ts +39 -0
  17. package/dist/core/inferTypes.d.ts.map +1 -0
  18. package/dist/core/registry.d.ts +17 -0
  19. package/dist/core/registry.d.ts.map +1 -0
  20. package/dist/core/schemaUtils.d.ts +20 -0
  21. package/dist/core/schemaUtils.d.ts.map +1 -0
  22. package/dist/core/types.d.ts +43 -3
  23. package/dist/core/types.d.ts.map +1 -1
  24. package/dist/core/useFieldArray.d.ts +21 -0
  25. package/dist/core/useFieldArray.d.ts.map +1 -0
  26. package/dist/core/useForm.d.ts.map +1 -1
  27. package/dist/core/useFormDebug.d.ts +29 -0
  28. package/dist/core/useFormDebug.d.ts.map +1 -0
  29. package/dist/core/useFormField.d.ts +18 -0
  30. package/dist/core/useFormField.d.ts.map +1 -0
  31. package/dist/core/useMultiStepForm.d.ts +30 -0
  32. package/dist/core/useMultiStepForm.d.ts.map +1 -0
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.d.ts +14 -2
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +386 -196
  37. package/dist/parsers/valibot.d.ts +20 -0
  38. package/dist/parsers/valibot.d.ts.map +1 -0
  39. package/dist/ui/index.d.ts +2 -0
  40. package/dist/ui/index.d.ts.map +1 -1
  41. package/dist/ui.cjs +1 -1
  42. package/dist/ui.d.ts +114 -18
  43. package/dist/ui.js +360 -193
  44. package/dist/valibot.cjs +1 -0
  45. package/dist/valibot.d.ts +84 -0
  46. package/dist/valibot.js +43 -0
  47. package/dist/yup.d.ts +26 -2
  48. package/dist/zod.d.ts +26 -2
  49. package/package.json +21 -4
  50. package/dist/MaskEngine-D22m29OM.js +0 -157
  51. package/dist/MaskEngine-hd5xHed7.cjs +0 -1
package/dist/index.js CHANGED
@@ -1,17 +1,23 @@
1
- import { watchEffect as T, ref as y, computed as V, onUnmounted as C } from "vue";
2
- import { g as h, s as x, u as F, e as O, p as D, m as U, d as I, c as W, f as X, h as k, V as _ } from "./MaskEngine-D22m29OM.js";
3
- import { a as se, b as re, r as ie } from "./MaskEngine-D22m29OM.js";
4
- const z = /^[\w\s\d.'"[\]()!<>=&|?:+\-*/%]+$/;
5
- function G(l, n) {
6
- if (!z.test(l))
7
- return console.warn(`[vue-form-schema] Blocked unsafe expression: "${l}"`), !0;
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 (${l})`)(n);
15
+ return !!new Function("values", `"use strict"; return (${n})`)(s);
10
16
  } catch {
11
17
  return !0;
12
18
  }
13
19
  }
14
- class H {
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(n, e, t, a) {
23
- this.stopHandle = T(() => {
24
- const f = e.value, u = t.value, i = this.evaluateFields(n, f);
25
- a && this.clearHiddenValues(n, i, f, e, u), t.value = i;
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 n;
30
- (n = this.stopHandle) == null || n.call(this), this.stopHandle = null;
35
+ var s;
36
+ (s = this.stopHandle) == null || s.call(this), this.stopHandle = null;
31
37
  }
32
- /** Recursively evaluate visible/disabled/required for each field */
33
- evaluateFields(n, e) {
34
- return n.map((t) => {
35
- const a = this.resolveBoolean(t.visible, e, !0), f = this.resolveBoolean(t.disabled, e, !1);
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
- ...t,
38
- visible: a,
39
- disabled: f,
40
- fields: t.fields ? this.evaluateFields(t.fields, e) : void 0
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(n, e, t) {
45
- return n === void 0 ? t : typeof n == "boolean" ? n : typeof n == "function" ? n(e) : typeof n == "string" ? G(n, e) : t;
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(n, e, t, a, f) {
48
- for (let u = 0; u < n.length; u++) {
49
- const i = n[u], p = e[u], r = this.wasVisible(f, i.name), o = p.visible;
50
- if (r && !o) {
51
- const m = h(t, i.name), b = i.defaultValue ?? null;
52
- m !== b && (a.value = x(a.value, i.name, b));
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
- i.fields && p.fields && this.clearHiddenValues(i.fields, p.fields, t, a, f);
67
+ c.fields && m.fields && this.clearHiddenValues(c.fields, m.fields, e, r, d);
55
68
  }
56
69
  }
57
- wasVisible(n, e) {
58
- const t = n.find((a) => a.name === e);
59
- return t ? t.visible !== !1 : !0;
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 te(l, n) {
63
- return new H().evaluateFields(l, n);
75
+ function be(n, s) {
76
+ return new T().evaluateFields(n, s);
64
77
  }
65
- function K(l, n, e) {
66
- switch (l) {
78
+ function fe(n, s, t) {
79
+ switch (n) {
67
80
  case "required":
68
- return e ? (t, a) => k(t) ? e : null : k;
81
+ return t ? (e, r) => I(e) ? t : null : I;
69
82
  case "minLength":
70
- return X(Number(n), e);
83
+ return ae(Number(s), t);
71
84
  case "maxLength":
72
- return W(Number(n), e);
85
+ return se(Number(s), t);
73
86
  case "min":
74
- return I(Number(n), e);
87
+ return ne(Number(s), t);
75
88
  case "max":
76
- return U(Number(n), e);
89
+ return te(Number(s), t);
77
90
  case "pattern":
78
- return D(new RegExp(String(n)), e);
91
+ return ee(new RegExp(String(s)), t);
79
92
  case "email":
80
- return e ? (t, a) => O(t) ? e : null : O;
93
+ return t ? (e, r) => $(e) ? t : null : $;
81
94
  case "url":
82
- return e ? (t, a) => F(t) ? e : null : F;
95
+ return t ? (e, r) => q(e) ? t : null : q;
83
96
  default:
84
- return console.warn(`[vue-form-schema] Unknown validator rule: "${l}"`), null;
97
+ return console.warn(`[vue-form-schema] Unknown validator rule: "${n}"`), null;
85
98
  }
86
99
  }
87
- function N(l) {
88
- const n = [];
89
- for (const e of l.validators ?? []) {
90
- const t = K(e.rule, e.value, e.message);
91
- t && n.push(t);
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: l.type,
95
- name: l.name,
96
- label: l.label,
97
- placeholder: l.placeholder,
98
- defaultValue: l.default,
99
- required: l.required,
100
- disabled: l.disabled,
101
- visible: l.visible,
102
- mask: l.mask,
103
- options: l.options,
104
- validators: n.length ? n : void 0,
105
- fields: l.fields ? l.fields.map(N) : void 0
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 Q(l) {
109
- return l.map(N);
121
+ function ve(n) {
122
+ return n.map(C);
110
123
  }
111
- function R(l) {
112
- if (!Array.isArray(l) || l.length === 0) return !1;
113
- for (const n of l) {
114
- const e = n.validators;
115
- if (Array.isArray(e) && e.some((t) => typeof t == "function"))
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 l.some((n) => {
119
- const e = n;
120
- if ("default" in e) return !0;
121
- const t = e.validators;
122
- return Array.isArray(t) && t.length > 0 && typeof t[0] == "object" && t[0] !== null && "rule" in t[0];
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 Y(l) {
126
- return R(l) ? Q(l) : l;
138
+ function me(n) {
139
+ return de(n) ? ve(n) : n;
127
140
  }
128
- function g(l, n = {}) {
129
- const e = {};
130
- for (const t of l)
131
- if (t.type === "group" && t.fields) {
132
- const a = g(t.fields, n);
133
- Object.assign(e, a);
134
- } else if (t.type === "array") {
135
- const a = h(n, t.name);
136
- e[t.name] = a ?? t.defaultValue ?? [];
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 a = h(n, t.name);
139
- e[t.name] = a !== void 0 ? a : t.defaultValue ?? null;
151
+ const r = S(s, e.name);
152
+ t[e.name] = r !== void 0 ? r : e.defaultValue ?? null;
140
153
  }
141
- for (const [t, a] of Object.entries(n))
142
- t in e || (e[t] = a);
143
- return e;
154
+ for (const [e, r] of Object.entries(s))
155
+ e in t || (t[e] = r);
156
+ return t;
144
157
  }
145
- function ne(l) {
158
+ function pe(n) {
159
+ var M;
146
160
  const {
147
- schema: n,
148
- initialValues: e = {},
149
- validateOn: t = "blur",
150
- clearOnHide: a = !1,
151
- onSubmit: f
152
- } = l, u = Y(n), i = new _(), p = new H(), r = y(
153
- g(u, e)
154
- ), o = y({}), m = y({}), b = y(!1), v = y(u);
155
- p.start(u, r, v, a ?? !1);
156
- const S = V(() => v.value), L = V(() => {
157
- const s = g(u, e);
158
- return JSON.stringify(r.value) !== JSON.stringify(s);
159
- }), j = V(() => {
160
- const s = i.validateAll(v.value, r.value);
161
- return Object.values(s).every((c) => c.length === 0);
162
- });
163
- function E(s) {
164
- if (s) {
165
- const c = i.validateField(
166
- s,
167
- h(r.value, s.name),
168
- r.value
169
- );
170
- o.value = { ...o.value, [s.name]: c }, i.validateAsync(
171
- s,
172
- h(r.value, s.name),
173
- r.value,
174
- (d, P) => {
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
- [d]: [...o.value[d] ?? [], ...P]
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
- o.value = i.validateAll(
183
- v.value,
184
- r.value
266
+ f.value = h.validateAll(
267
+ y.value,
268
+ o.value
185
269
  );
186
270
  }
187
- function q(s, c) {
188
- if (r.value = x(
189
- r.value,
190
- s,
191
- c
192
- ), t === "input") {
193
- const d = A(v.value, s);
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 J(s) {
198
- return h(r.value, s);
279
+ function G(a) {
280
+ return S(o.value, a);
199
281
  }
200
- function $(s) {
201
- if (m.value = { ...m.value, [s]: !0 }, t === "blur") {
202
- const c = A(v.value, s);
203
- c && E(c);
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 w() {
207
- const s = {};
208
- for (const d of v.value) B(d, s);
209
- if (m.value = s, o.value = i.validateAll(
210
- v.value,
211
- r.value
212
- ), !Object.values(o.value).some((d) => d.length > 0)) {
213
- b.value = !0;
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
- await (f == null ? void 0 : f(r.value));
297
+ const l = U(y.value, o.value);
298
+ await (u == null ? void 0 : u(l));
216
299
  } finally {
217
- b.value = !1;
300
+ A.value = !1;
218
301
  }
219
302
  }
220
303
  }
221
- function M(s) {
222
- const c = s ?? e;
223
- r.value = g(
224
- u,
225
- c ?? {}
226
- ), o.value = {}, m.value = {}, b.value = !1;
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 C(() => {
229
- p.stop(), i.destroy();
314
+ return le(() => {
315
+ F.stop(), h.destroy();
230
316
  }), {
231
- fields: S,
232
- values: r,
233
- errors: o,
234
- touched: m,
235
- isDirty: L,
236
- isValid: j,
237
- isSubmitting: b,
238
- submit: w,
239
- reset: M,
240
- setField: q,
241
- getField: J,
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 A(l, n) {
248
- for (const e of l) {
249
- if (e.name === n) return e;
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 t = A(e.fields, n);
252
- if (t) return t;
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 B(l, n = {}) {
257
- return n[l.name] = !0, l.fields && l.fields.forEach((e) => B(e, n)), n;
433
+ function Ae(n) {
434
+ return n;
258
435
  }
259
436
  export {
260
- H as ConditionEvaluator,
261
- _ as ValidationEngine,
262
- se as applyMask,
263
- re as bindMask,
264
- O as email,
265
- te as evaluateFieldConditions,
266
- h as getByPath,
267
- U as max,
268
- W as maxLength,
269
- I as min,
270
- X as minLength,
271
- Q as parseJSON,
272
- D as pattern,
273
- ie as removeMask,
274
- k as required,
275
- x as setByPath,
276
- F as url,
277
- ne as useForm
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
  };