suprform 1.1.0 → 1.1.1
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/dist/suprform.cjs.js +1 -1
- package/dist/suprform.cjs.js.map +1 -1
- package/dist/suprform.es.js +103 -103
- package/dist/suprform.es.js.map +1 -1
- package/dist/util.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/suprform.es.js
CHANGED
|
@@ -21,11 +21,11 @@ function U(t) {
|
|
|
21
21
|
return t;
|
|
22
22
|
return r;
|
|
23
23
|
}
|
|
24
|
-
var Ee = (t) => /^\w*$/.test(t),
|
|
24
|
+
var Ee = (t) => /^\w*$/.test(t), T = (t) => t === void 0, we = (t) => Array.isArray(t) ? t.filter(Boolean) : [], Ke = (t) => we(t.replace(/["|']|\]/g, "").split(/\.|\[/)), m = (t, r, e) => {
|
|
25
25
|
if (!r || !P(t))
|
|
26
26
|
return e;
|
|
27
27
|
const s = (Ee(r) ? [r] : Ke(r)).reduce((u, i) => G(u) ? u : u[i], t);
|
|
28
|
-
return
|
|
28
|
+
return T(s) || s === t ? T(t[r]) ? e : t[r] : s;
|
|
29
29
|
}, K = (t) => typeof t == "boolean", R = (t, r, e) => {
|
|
30
30
|
let s = -1;
|
|
31
31
|
const u = Ee(r) ? [r] : Ke(r), i = u.length, c = i - 1;
|
|
@@ -78,7 +78,7 @@ var St = (t, r, e, s = !0) => {
|
|
|
78
78
|
});
|
|
79
79
|
return u;
|
|
80
80
|
};
|
|
81
|
-
const
|
|
81
|
+
const Ce = typeof window < "u" ? b.useLayoutEffect : b.useEffect;
|
|
82
82
|
function tr(t) {
|
|
83
83
|
const r = Ve(), { control: e = r.control, disabled: s, name: u, exact: i } = t || {}, [c, l] = b.useState(e._formState), V = b.useRef({
|
|
84
84
|
isDirty: !1,
|
|
@@ -90,7 +90,7 @@ function tr(t) {
|
|
|
90
90
|
isValid: !1,
|
|
91
91
|
errors: !1
|
|
92
92
|
});
|
|
93
|
-
return
|
|
93
|
+
return Ce(() => e._subscribe({
|
|
94
94
|
name: u,
|
|
95
95
|
formState: V.current,
|
|
96
96
|
exact: i,
|
|
@@ -147,7 +147,7 @@ function Je(t) {
|
|
|
147
147
|
L(d);
|
|
148
148
|
}
|
|
149
149
|
}, [e._formValues, e._names, i, s]);
|
|
150
|
-
|
|
150
|
+
Ce(() => ((g.current !== e || !te(F.current, s)) && (g.current = e, F.current = s, N()), e._subscribe({
|
|
151
151
|
name: s,
|
|
152
152
|
formState: {
|
|
153
153
|
values: !0
|
|
@@ -242,7 +242,7 @@ function rr(t) {
|
|
|
242
242
|
};
|
|
243
243
|
if (p(e, !0), f) {
|
|
244
244
|
const E = U(m(u._options.defaultValues, e, F.current.defaultValue));
|
|
245
|
-
R(u._defaultValues, e, E),
|
|
245
|
+
R(u._defaultValues, e, E), T(m(u._formValues, e)) && R(u._formValues, e, E);
|
|
246
246
|
}
|
|
247
247
|
return !V && u.register(e), $.current = e, () => {
|
|
248
248
|
(V ? f && !u._state.action : f) ? u.unregister(e) : p(e, !1);
|
|
@@ -307,12 +307,12 @@ function ir(t, r) {
|
|
|
307
307
|
const e = r.slice(0, -1).length;
|
|
308
308
|
let s = 0;
|
|
309
309
|
for (; s < e; )
|
|
310
|
-
t =
|
|
310
|
+
t = T(t) ? s++ : t[r[s++]];
|
|
311
311
|
return t;
|
|
312
312
|
}
|
|
313
313
|
function ur(t) {
|
|
314
314
|
for (const r in t)
|
|
315
|
-
if (t.hasOwnProperty(r) && !
|
|
315
|
+
if (t.hasOwnProperty(r) && !T(t[r]))
|
|
316
316
|
return !1;
|
|
317
317
|
return !0;
|
|
318
318
|
}
|
|
@@ -326,13 +326,13 @@ var or = (t) => {
|
|
|
326
326
|
return !0;
|
|
327
327
|
return !1;
|
|
328
328
|
};
|
|
329
|
-
function
|
|
329
|
+
function Ct(t) {
|
|
330
330
|
return Array.isArray(t) || P(t) && !or(t);
|
|
331
331
|
}
|
|
332
332
|
function je(t, r = {}) {
|
|
333
333
|
for (const e in t) {
|
|
334
334
|
const s = t[e];
|
|
335
|
-
|
|
335
|
+
Ct(s) ? (r[e] = Array.isArray(s) ? [] : {}, je(s, r[e])) : T(s) || (r[e] = !0);
|
|
336
336
|
}
|
|
337
337
|
return r;
|
|
338
338
|
}
|
|
@@ -340,8 +340,8 @@ function fe(t, r, e) {
|
|
|
340
340
|
e || (e = je(r));
|
|
341
341
|
for (const s in t) {
|
|
342
342
|
const u = t[s];
|
|
343
|
-
if (
|
|
344
|
-
|
|
343
|
+
if (Ct(u))
|
|
344
|
+
T(r) || qe(e[s]) ? e[s] = je(u, Array.isArray(u) ? [] : {}) : fe(u, G(r) ? {} : r[s], e[s]);
|
|
345
345
|
else {
|
|
346
346
|
const i = r[s];
|
|
347
347
|
e[s] = !te(u, i);
|
|
@@ -353,7 +353,7 @@ const yt = {
|
|
|
353
353
|
value: !1,
|
|
354
354
|
isValid: !1
|
|
355
355
|
}, mt = { value: !0, isValid: !0 };
|
|
356
|
-
var
|
|
356
|
+
var kt = (t) => {
|
|
357
357
|
if (Array.isArray(t)) {
|
|
358
358
|
if (t.length > 1) {
|
|
359
359
|
const r = t.filter((e) => e && e.checked && !e.disabled).map((e) => e.value);
|
|
@@ -361,11 +361,11 @@ var Ct = (t) => {
|
|
|
361
361
|
}
|
|
362
362
|
return t[0].checked && !t[0].disabled ? (
|
|
363
363
|
// @ts-expect-error expected to work in the browser
|
|
364
|
-
t[0].attributes && !
|
|
364
|
+
t[0].attributes && !T(t[0].attributes.value) ? T(t[0].value) || t[0].value === "" ? mt : { value: t[0].value, isValid: !0 } : mt
|
|
365
365
|
) : yt;
|
|
366
366
|
}
|
|
367
367
|
return yt;
|
|
368
|
-
}, Dt = (t, { valueAsNumber: r, valueAsDate: e, setValueAs: s }) =>
|
|
368
|
+
}, Dt = (t, { valueAsNumber: r, valueAsDate: e, setValueAs: s }) => T(t) ? t : r ? t === "" ? NaN : t && +t : e && Y(t) ? new Date(t) : s ? s(t) : t;
|
|
369
369
|
const _t = {
|
|
370
370
|
isValid: !1,
|
|
371
371
|
value: null
|
|
@@ -376,7 +376,7 @@ var Rt = (t) => Array.isArray(t) ? t.reduce((r, e) => e && e.checked && !e.disab
|
|
|
376
376
|
} : r, _t) : _t;
|
|
377
377
|
function gt(t) {
|
|
378
378
|
const r = t.ref;
|
|
379
|
-
return Xe(r) ? r.files : Ze(r) ? Rt(t.refs).value : wt(r) ? [...r.selectedOptions].map(({ value: e }) => e) : ve(r) ?
|
|
379
|
+
return Xe(r) ? r.files : Ze(r) ? Rt(t.refs).value : wt(r) ? [...r.selectedOptions].map(({ value: e }) => e) : ve(r) ? kt(t.refs).value : Dt(T(r.value) ? t.ref.value : r.value, t);
|
|
380
380
|
}
|
|
381
381
|
var lr = (t, r, e, s) => {
|
|
382
382
|
const u = {};
|
|
@@ -390,7 +390,7 @@ var lr = (t, r, e, s) => {
|
|
|
390
390
|
fields: u,
|
|
391
391
|
shouldUseNativeValidation: s
|
|
392
392
|
};
|
|
393
|
-
}, Se = (t) => t instanceof RegExp, ge = (t) =>
|
|
393
|
+
}, Se = (t) => t instanceof RegExp, ge = (t) => T(t) ? t : Se(t) ? t.source : P(t) ? Se(t.value) ? t.value.source : t.value : t, ye = (t) => ({
|
|
394
394
|
isOnSubmit: !t || t === X.onSubmit,
|
|
395
395
|
isOnBlur: t === X.onBlur,
|
|
396
396
|
isOnChange: t === X.onChange,
|
|
@@ -448,7 +448,7 @@ var fr = (t, r, e, s) => {
|
|
|
448
448
|
e(t);
|
|
449
449
|
const { name: u, ...i } = t;
|
|
450
450
|
return q(i) || Object.keys(i).length >= Object.keys(r).length || Object.keys(i).find((c) => r[c] === (!s || X.all));
|
|
451
|
-
}, yr = (t, r, e) => !t || !r || t === r || z(t).some((s) => s && (e ? s === r : s.startsWith(r) || r.startsWith(s))), mr = (t, r, e, s, u) => u.isOnAll ? !1 : !e && u.isOnTouch ? !(r || t) : (e ? s.isOnBlur : u.isOnBlur) ? !t : (e ? s.isOnChange : u.isOnChange) ? t : !0, _r = (t, r) => !we(m(t, r)).length && B(t, r),
|
|
451
|
+
}, yr = (t, r, e) => !t || !r || t === r || z(t).some((s) => s && (e ? s === r : s.startsWith(r) || r.startsWith(s))), mr = (t, r, e, s, u) => u.isOnAll ? !1 : !e && u.isOnTouch ? !(r || t) : (e ? s.isOnBlur : u.isOnBlur) ? !t : (e ? s.isOnChange : u.isOnChange) ? t : !0, _r = (t, r) => !we(m(t, r)).length && B(t, r), Ot = (t, r, e) => {
|
|
452
452
|
const s = z(m(t, e));
|
|
453
453
|
return R(s, "root", r[e]), R(t, e, s), t;
|
|
454
454
|
};
|
|
@@ -467,20 +467,20 @@ var de = (t) => P(t) && !Se(t) ? t : {
|
|
|
467
467
|
const { ref: c, refs: l, required: V, maxLength: v, minLength: x, min: g, max: F, pattern: $, validate: L, name: w, valueAsNumber: N, mount: H } = t._f, S = m(e, w);
|
|
468
468
|
if (!H || r.has(w))
|
|
469
469
|
return {};
|
|
470
|
-
const M = l ? l[0] : c, f = (
|
|
471
|
-
u && M.reportValidity && (M.setCustomValidity(K(
|
|
472
|
-
}, d = {}, p = Ze(c), E = ve(c), Z = p || E, W = (N || Xe(c)) &&
|
|
473
|
-
const ae =
|
|
470
|
+
const M = l ? l[0] : c, f = (C) => {
|
|
471
|
+
u && M.reportValidity && (M.setCustomValidity(K(C) ? "" : C || ""), M.reportValidity());
|
|
472
|
+
}, d = {}, p = Ze(c), E = ve(c), Z = p || E, W = (N || Xe(c)) && T(c.value) && T(S) || xe(c) && c.value === "" || S === "" || Array.isArray(S) && !S.length, oe = ar.bind(null, w, s, d), se = (C, D, I, j = ne.maxLength, Q = ne.minLength) => {
|
|
473
|
+
const ae = C ? D : I;
|
|
474
474
|
d[w] = {
|
|
475
|
-
type:
|
|
475
|
+
type: C ? j : Q,
|
|
476
476
|
message: ae,
|
|
477
477
|
ref: c,
|
|
478
|
-
...oe(
|
|
478
|
+
...oe(C ? j : Q, ae)
|
|
479
479
|
};
|
|
480
480
|
};
|
|
481
|
-
if (i ? !Array.isArray(S) || !S.length : V && (!Z && (W || G(S)) || K(S) && !S || E && !
|
|
482
|
-
const { value:
|
|
483
|
-
if (
|
|
481
|
+
if (i ? !Array.isArray(S) || !S.length : V && (!Z && (W || G(S)) || K(S) && !S || E && !kt(l).isValid || p && !Rt(l).isValid)) {
|
|
482
|
+
const { value: C, message: D } = Y(V) ? { value: !!V, message: V } : de(V);
|
|
483
|
+
if (C && (d[w] = {
|
|
484
484
|
type: ne.required,
|
|
485
485
|
message: D,
|
|
486
486
|
ref: M,
|
|
@@ -489,26 +489,26 @@ var de = (t) => P(t) && !Se(t) ? t : {
|
|
|
489
489
|
return f(D), d;
|
|
490
490
|
}
|
|
491
491
|
if (!W && (!G(g) || !G(F))) {
|
|
492
|
-
let
|
|
492
|
+
let C, D;
|
|
493
493
|
const I = de(F), j = de(g);
|
|
494
494
|
if (!G(S) && !isNaN(S)) {
|
|
495
495
|
const Q = c.valueAsNumber || S && +S;
|
|
496
|
-
G(I.value) || (
|
|
496
|
+
G(I.value) || (C = Q > I.value), G(j.value) || (D = Q < j.value);
|
|
497
497
|
} else {
|
|
498
498
|
const Q = c.valueAsDate || new Date(S), ae = (Fe) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + Fe), _e = c.type == "time", ce = c.type == "week";
|
|
499
|
-
Y(I.value) && S && (
|
|
499
|
+
Y(I.value) && S && (C = _e ? ae(S) > ae(I.value) : ce ? S > I.value : Q > new Date(I.value)), Y(j.value) && S && (D = _e ? ae(S) < ae(j.value) : ce ? S < j.value : Q < new Date(j.value));
|
|
500
500
|
}
|
|
501
|
-
if ((
|
|
501
|
+
if ((C || D) && (se(!!C, I.message, j.message, ne.max, ne.min), !s))
|
|
502
502
|
return f(d[w].message), d;
|
|
503
503
|
}
|
|
504
504
|
if ((v || x) && !W && (Y(S) || i && Array.isArray(S))) {
|
|
505
|
-
const
|
|
506
|
-
if ((I || j) && (se(I,
|
|
505
|
+
const C = de(v), D = de(x), I = !G(C.value) && S.length > +C.value, j = !G(D.value) && S.length < +D.value;
|
|
506
|
+
if ((I || j) && (se(I, C.message, D.message), !s))
|
|
507
507
|
return f(d[w].message), d;
|
|
508
508
|
}
|
|
509
509
|
if ($ && !W && Y(S)) {
|
|
510
|
-
const { value:
|
|
511
|
-
if (Se(
|
|
510
|
+
const { value: C, message: D } = de($);
|
|
511
|
+
if (Se(C) && !S.match(C) && (d[w] = {
|
|
512
512
|
type: ne.pattern,
|
|
513
513
|
message: D,
|
|
514
514
|
ref: c,
|
|
@@ -518,26 +518,26 @@ var de = (t) => P(t) && !Se(t) ? t : {
|
|
|
518
518
|
}
|
|
519
519
|
if (L) {
|
|
520
520
|
if (re(L)) {
|
|
521
|
-
const
|
|
521
|
+
const C = await L(S, e), D = Vt(C, M);
|
|
522
522
|
if (D && (d[w] = {
|
|
523
523
|
...D,
|
|
524
524
|
...oe(ne.validate, D.message)
|
|
525
525
|
}, !s))
|
|
526
526
|
return f(D.message), d;
|
|
527
527
|
} else if (P(L)) {
|
|
528
|
-
let
|
|
528
|
+
let C = {};
|
|
529
529
|
for (const D in L) {
|
|
530
|
-
if (!q(
|
|
530
|
+
if (!q(C) && !s)
|
|
531
531
|
break;
|
|
532
532
|
const I = Vt(await L[D](S, e), M, D);
|
|
533
|
-
I && (
|
|
533
|
+
I && (C = {
|
|
534
534
|
...I,
|
|
535
535
|
...oe(D, I.message)
|
|
536
|
-
}, f(I.message), s && (d[w] =
|
|
536
|
+
}, f(I.message), s && (d[w] = C));
|
|
537
537
|
}
|
|
538
|
-
if (!q(
|
|
538
|
+
if (!q(C) && (d[w] = {
|
|
539
539
|
ref: M,
|
|
540
|
-
...
|
|
540
|
+
...C
|
|
541
541
|
}, !s))
|
|
542
542
|
return d;
|
|
543
543
|
}
|
|
@@ -645,27 +645,27 @@ function hr(t = {}) {
|
|
|
645
645
|
}, f = (a, n, o, h) => {
|
|
646
646
|
const _ = m(s, a);
|
|
647
647
|
if (_) {
|
|
648
|
-
const y = m(i, a,
|
|
649
|
-
|
|
648
|
+
const y = m(i, a, T(o) ? m(u, a) : o);
|
|
649
|
+
T(y) || h && h.defaultChecked || n ? R(i, a, n ? y : gt(_._f)) : I(a, y), c.mount && !c.action && w();
|
|
650
650
|
}
|
|
651
651
|
}, d = (a, n, o, h, _) => {
|
|
652
652
|
let y = !1, A = !1;
|
|
653
|
-
const
|
|
653
|
+
const k = {
|
|
654
654
|
name: a
|
|
655
655
|
};
|
|
656
656
|
if (!r.disabled) {
|
|
657
657
|
if (!o || h) {
|
|
658
|
-
(x.isDirty || g.isDirty) && (A = e.isDirty, e.isDirty =
|
|
659
|
-
const
|
|
660
|
-
A = !!m(e.dirtyFields, a),
|
|
658
|
+
(x.isDirty || g.isDirty) && (A = e.isDirty, e.isDirty = k.isDirty = se(), y = A !== k.isDirty);
|
|
659
|
+
const O = te(m(u, a), n);
|
|
660
|
+
A = !!m(e.dirtyFields, a), O ? B(e.dirtyFields, a) : R(e.dirtyFields, a, !0), k.dirtyFields = e.dirtyFields, y = y || (x.dirtyFields || g.dirtyFields) && A !== !O;
|
|
661
661
|
}
|
|
662
662
|
if (o) {
|
|
663
|
-
const
|
|
664
|
-
|
|
663
|
+
const O = m(e.touchedFields, a);
|
|
664
|
+
O || (R(e.touchedFields, a, o), k.touchedFields = e.touchedFields, y = y || (x.touchedFields || g.touchedFields) && O !== o);
|
|
665
665
|
}
|
|
666
|
-
y && _ && F.state.next(
|
|
666
|
+
y && _ && F.state.next(k);
|
|
667
667
|
}
|
|
668
|
-
return y ?
|
|
668
|
+
return y ? k : {};
|
|
669
669
|
}, p = (a, n, o, h) => {
|
|
670
670
|
const _ = m(e.errors, a), y = (x.isValid || g.isValid) && K(n) && e.isValid !== n;
|
|
671
671
|
if (r.delayError && o ? (V = L(() => S(a, o)), V(r.delayError)) : (clearTimeout(v), V = null, o ? R(e.errors, a, o) : B(e.errors, a)), (o ? !te(_, o) : _) || !q(h) || y) {
|
|
@@ -702,12 +702,12 @@ function hr(t = {}) {
|
|
|
702
702
|
if (_) {
|
|
703
703
|
const { _f: y, ...A } = _;
|
|
704
704
|
if (y) {
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
const J = await Ge(_, l.disabled, i, $, r.shouldUseNativeValidation && !n,
|
|
708
|
-
if (
|
|
705
|
+
const k = l.array.has(y.name), O = _._f && cr(_._f);
|
|
706
|
+
O && x.validatingFields && N([y.name], !0);
|
|
707
|
+
const J = await Ge(_, l.disabled, i, $, r.shouldUseNativeValidation && !n, k);
|
|
708
|
+
if (O && x.validatingFields && N([y.name]), J[y.name] && (o.valid = !1, n))
|
|
709
709
|
break;
|
|
710
|
-
!n && (m(J, y.name) ?
|
|
710
|
+
!n && (m(J, y.name) ? k ? Ot(e.errors, J, y.name) : R(e.errors, y.name, J[y.name]) : B(e.errors, y.name));
|
|
711
711
|
}
|
|
712
712
|
!q(A) && await W(A, n, o);
|
|
713
713
|
}
|
|
@@ -716,18 +716,18 @@ function hr(t = {}) {
|
|
|
716
716
|
}, oe = () => {
|
|
717
717
|
for (const a of l.unMount) {
|
|
718
718
|
const n = m(s, a);
|
|
719
|
-
n && (n._f.refs ? n._f.refs.every((o) => !Ue(o)) : !Ue(n._f.ref)) &&
|
|
719
|
+
n && (n._f.refs ? n._f.refs.every((o) => !Ue(o)) : !Ue(n._f.ref)) && ke(a);
|
|
720
720
|
}
|
|
721
721
|
l.unMount = /* @__PURE__ */ new Set();
|
|
722
|
-
}, se = (a, n) => !r.disabled && (a && n && R(i, a, n), !te(Fe(), u)),
|
|
723
|
-
...c.mount ? i :
|
|
722
|
+
}, se = (a, n) => !r.disabled && (a && n && R(i, a, n), !te(Fe(), u)), C = (a, n, o) => He(a, l, {
|
|
723
|
+
...c.mount ? i : T(n) ? u : Y(a) ? { [a]: n } : n
|
|
724
724
|
}, o, n), D = (a) => we(m(c.mount ? i : u, a, r.shouldUnregister ? m(u, a, []) : [])), I = (a, n, o = {}) => {
|
|
725
725
|
const h = m(s, a);
|
|
726
726
|
let _ = n;
|
|
727
727
|
if (h) {
|
|
728
728
|
const y = h._f;
|
|
729
729
|
y && (!y.disabled && R(i, a, Dt(n, y)), _ = xe(y.ref) && G(n) ? "" : n, wt(y.ref) ? [...y.ref.options].forEach((A) => A.selected = _.includes(A.value)) : y.refs ? ve(y.ref) ? y.refs.forEach((A) => {
|
|
730
|
-
(!A.defaultChecked || !A.disabled) && (Array.isArray(_) ? A.checked = !!_.find((
|
|
730
|
+
(!A.defaultChecked || !A.disabled) && (Array.isArray(_) ? A.checked = !!_.find((k) => k === A.value) : A.checked = _ === A.value || !!_);
|
|
731
731
|
}) : y.refs.forEach((A) => A.checked = A.value === _) : Xe(y.ref) ? y.ref.value = "" : (y.ref.value = _, y.ref.type || F.state.next({
|
|
732
732
|
name: a,
|
|
733
733
|
values: U(i)
|
|
@@ -758,29 +758,29 @@ function hr(t = {}) {
|
|
|
758
758
|
c.mount = !0;
|
|
759
759
|
const n = a.target;
|
|
760
760
|
let o = n.name, h = !0;
|
|
761
|
-
const _ = m(s, o), y = (
|
|
762
|
-
h = Number.isNaN(
|
|
763
|
-
}, A = ye(r.mode),
|
|
761
|
+
const _ = m(s, o), y = (O) => {
|
|
762
|
+
h = Number.isNaN(O) || le(O) && isNaN(O.getTime()) || te(O, m(i, o, O));
|
|
763
|
+
}, A = ye(r.mode), k = ye(r.reValidateMode);
|
|
764
764
|
if (_) {
|
|
765
|
-
let
|
|
766
|
-
const be = n.type ? gt(_._f) : pt(a), ie = a.type === pe.BLUR || a.type === pe.FOCUS_OUT, Ht = !dr(_._f) && !r.resolver && !m(e.errors, o) && !_._f.deps || mr(ie, m(e.touchedFields, o), e.isSubmitted,
|
|
765
|
+
let O, J;
|
|
766
|
+
const be = n.type ? gt(_._f) : pt(a), ie = a.type === pe.BLUR || a.type === pe.FOCUS_OUT, Ht = !dr(_._f) && !r.resolver && !m(e.errors, o) && !_._f.deps || mr(ie, m(e.touchedFields, o), e.isSubmitted, k, A), Oe = Qe(o, l, ie);
|
|
767
767
|
R(i, o, be), ie ? (!n || !n.readOnly) && (_._f.onBlur && _._f.onBlur(a), V && V(0)) : _._f.onChange && _._f.onChange(a);
|
|
768
|
-
const
|
|
768
|
+
const Te = d(o, be, ie), qt = !q(Te) || Oe;
|
|
769
769
|
if (!ie && F.state.next({
|
|
770
770
|
name: o,
|
|
771
771
|
type: a.type,
|
|
772
772
|
values: U(i)
|
|
773
773
|
}), Ht)
|
|
774
|
-
return (x.isValid || g.isValid) && (r.mode === "onBlur" ? ie && w() : ie || w()), qt && F.state.next({ name: o, ...
|
|
775
|
-
if (!ie &&
|
|
774
|
+
return (x.isValid || g.isValid) && (r.mode === "onBlur" ? ie && w() : ie || w()), qt && F.state.next({ name: o, ...Oe ? {} : Te });
|
|
775
|
+
if (!ie && Oe && F.state.next({ ...e }), r.resolver) {
|
|
776
776
|
const { errors: lt } = await E([o]);
|
|
777
777
|
if (y(be), h) {
|
|
778
778
|
const jt = vt(e.errors, s, o), ct = vt(lt, s, jt.name || o);
|
|
779
|
-
|
|
779
|
+
O = ct.error, o = ct.name, J = q(lt);
|
|
780
780
|
}
|
|
781
781
|
} else
|
|
782
|
-
N([o], !0),
|
|
783
|
-
h && (_._f.deps && (!Array.isArray(_._f.deps) || _._f.deps.length > 0) && ce(_._f.deps), p(o, J,
|
|
782
|
+
N([o], !0), O = (await Ge(_, l.disabled, i, $, r.shouldUseNativeValidation))[o], N([o]), y(be), h && (O ? J = !1 : (x.isValid || g.isValid) && (J = await W(s, !0)));
|
|
783
|
+
h && (_._f.deps && (!Array.isArray(_._f.deps) || _._f.deps.length > 0) && ce(_._f.deps), p(o, J, O, Te));
|
|
784
784
|
}
|
|
785
785
|
}, _e = (a, n) => {
|
|
786
786
|
if (m(e.errors, n) && a.focus)
|
|
@@ -789,7 +789,7 @@ function hr(t = {}) {
|
|
|
789
789
|
let o, h;
|
|
790
790
|
const _ = z(a);
|
|
791
791
|
if (r.resolver) {
|
|
792
|
-
const y = await Z(
|
|
792
|
+
const y = await Z(T(a) ? a : _);
|
|
793
793
|
o = q(y), h = a ? !_.some((A) => m(y, A)) : o;
|
|
794
794
|
} else a ? (h = (await Promise.all(_.map(async (y) => {
|
|
795
795
|
const A = m(s, y);
|
|
@@ -804,7 +804,7 @@ function hr(t = {}) {
|
|
|
804
804
|
let o = {
|
|
805
805
|
...c.mount ? i : u
|
|
806
806
|
};
|
|
807
|
-
return n && (o = Et(n.dirtyFields ? e.dirtyFields : e.touchedFields, o)),
|
|
807
|
+
return n && (o = Et(n.dirtyFields ? e.dirtyFields : e.touchedFields, o)), T(a) ? o : Y(a) ? m(o, a) : a.map((h) => m(o, h));
|
|
808
808
|
}, tt = (a, n) => ({
|
|
809
809
|
invalid: !!m((n || e).errors, a),
|
|
810
810
|
isDirty: !!m((n || e).dirtyFields, a),
|
|
@@ -816,9 +816,9 @@ function hr(t = {}) {
|
|
|
816
816
|
errors: a ? e.errors : {}
|
|
817
817
|
});
|
|
818
818
|
}, rt = (a, n, o) => {
|
|
819
|
-
const h = (m(s, a, { _f: {} })._f || {}).ref, _ = m(e.errors, a) || {}, { ref: y, message: A, type:
|
|
819
|
+
const h = (m(s, a, { _f: {} })._f || {}).ref, _ = m(e.errors, a) || {}, { ref: y, message: A, type: k, ...O } = _;
|
|
820
820
|
R(e.errors, a, {
|
|
821
|
-
...
|
|
821
|
+
...O,
|
|
822
822
|
...n,
|
|
823
823
|
ref: h
|
|
824
824
|
}), F.state.next({
|
|
@@ -827,8 +827,8 @@ function hr(t = {}) {
|
|
|
827
827
|
isValid: !1
|
|
828
828
|
}), o && o.shouldFocus && h && h.focus && h.focus();
|
|
829
829
|
}, Mt = (a, n) => re(a) ? F.state.subscribe({
|
|
830
|
-
next: (o) => "values" in o && a(
|
|
831
|
-
}) :
|
|
830
|
+
next: (o) => "values" in o && a(C(void 0, n), o)
|
|
831
|
+
}) : C(a, n, !0), st = (a) => F.state.subscribe({
|
|
832
832
|
next: (n) => {
|
|
833
833
|
yr(a.name, n.name, a.exact) && fr(n, a.formState || x, $t, a.reRenderRoot) && a.callback({
|
|
834
834
|
values: { ...i },
|
|
@@ -843,7 +843,7 @@ function hr(t = {}) {
|
|
|
843
843
|
}, st({
|
|
844
844
|
...a,
|
|
845
845
|
formState: g
|
|
846
|
-
})),
|
|
846
|
+
})), ke = (a, n = {}) => {
|
|
847
847
|
for (const o of a ? z(a) : l.mount)
|
|
848
848
|
l.mount.delete(o), l.array.delete(o), n.keepValue || (B(s, o), B(i, o)), !n.keepError && B(e.errors, o), !n.keepDirty && B(e.dirtyFields, o), !n.keepTouched && B(e.touchedFields, o), !n.keepIsValidating && B(e.validatingFields, o), !r.shouldUnregister && !n.keepDefaultValue && B(u, o);
|
|
849
849
|
F.state.next({
|
|
@@ -884,15 +884,15 @@ function hr(t = {}) {
|
|
|
884
884
|
ref: (_) => {
|
|
885
885
|
if (_) {
|
|
886
886
|
De(a, n), o = m(s, a);
|
|
887
|
-
const y =
|
|
888
|
-
if (A ?
|
|
887
|
+
const y = T(_.value) && _.querySelectorAll && _.querySelectorAll("input,select,textarea")[0] || _, A = nr(y), k = o._f.refs || [];
|
|
888
|
+
if (A ? k.find((O) => O === y) : y === o._f.ref)
|
|
889
889
|
return;
|
|
890
890
|
R(s, a, {
|
|
891
891
|
_f: {
|
|
892
892
|
...o._f,
|
|
893
893
|
...A ? {
|
|
894
894
|
refs: [
|
|
895
|
-
...
|
|
895
|
+
...k.filter(Ue),
|
|
896
896
|
y,
|
|
897
897
|
...Array.isArray(m(u, a)) ? [{}] : []
|
|
898
898
|
],
|
|
@@ -945,7 +945,7 @@ function hr(t = {}) {
|
|
|
945
945
|
}), h)
|
|
946
946
|
throw h;
|
|
947
947
|
}, Pt = (a, n = {}) => {
|
|
948
|
-
m(s, a) && (
|
|
948
|
+
m(s, a) && (T(n.defaultValue) ? Q(a, U(m(u, a))) : (Q(a, n.defaultValue), R(u, a, U(n.defaultValue))), n.keepTouched || B(e.touchedFields, a), n.keepDirty || (B(e.dirtyFields, a), e.isDirty = n.defaultValue ? se(a, U(m(u, a))) : se()), n.keepError || (B(e.errors, a), x.isValid && w()), F.state.next({ ...e }));
|
|
949
949
|
}, it = (a, n = {}) => {
|
|
950
950
|
const o = a ? U(a) : u, h = U(o), _ = q(a), y = _ ? u : h;
|
|
951
951
|
if (n.keepDefaultValues || (u = o), !n.keepValues) {
|
|
@@ -954,16 +954,16 @@ function hr(t = {}) {
|
|
|
954
954
|
...l.mount,
|
|
955
955
|
...Object.keys(fe(u, i))
|
|
956
956
|
]);
|
|
957
|
-
for (const
|
|
958
|
-
m(e.dirtyFields,
|
|
957
|
+
for (const k of Array.from(A))
|
|
958
|
+
m(e.dirtyFields, k) ? R(y, k, m(i, k)) : Q(k, m(y, k));
|
|
959
959
|
} else {
|
|
960
|
-
if (ze &&
|
|
960
|
+
if (ze && T(a))
|
|
961
961
|
for (const A of l.mount) {
|
|
962
|
-
const
|
|
963
|
-
if (
|
|
964
|
-
const
|
|
965
|
-
if (xe(
|
|
966
|
-
const J =
|
|
962
|
+
const k = m(s, A);
|
|
963
|
+
if (k && k._f) {
|
|
964
|
+
const O = Array.isArray(k._f.refs) ? k._f.refs[0] : k._f.ref;
|
|
965
|
+
if (xe(O)) {
|
|
966
|
+
const J = O.closest("form");
|
|
967
967
|
if (J) {
|
|
968
968
|
J.reset();
|
|
969
969
|
break;
|
|
@@ -1016,14 +1016,14 @@ function hr(t = {}) {
|
|
|
1016
1016
|
}, ot = {
|
|
1017
1017
|
control: {
|
|
1018
1018
|
register: De,
|
|
1019
|
-
unregister:
|
|
1019
|
+
unregister: ke,
|
|
1020
1020
|
getFieldState: tt,
|
|
1021
1021
|
handleSubmit: nt,
|
|
1022
1022
|
setError: rt,
|
|
1023
1023
|
_subscribe: st,
|
|
1024
1024
|
_runSchema: E,
|
|
1025
1025
|
_focusError: Re,
|
|
1026
|
-
_getWatch:
|
|
1026
|
+
_getWatch: C,
|
|
1027
1027
|
_getDirty: se,
|
|
1028
1028
|
_setValid: w,
|
|
1029
1029
|
_setFieldArray: H,
|
|
@@ -1084,7 +1084,7 @@ function hr(t = {}) {
|
|
|
1084
1084
|
reset: ut,
|
|
1085
1085
|
resetField: Pt,
|
|
1086
1086
|
clearErrors: Lt,
|
|
1087
|
-
unregister:
|
|
1087
|
+
unregister: ke,
|
|
1088
1088
|
setError: rt,
|
|
1089
1089
|
setFocus: Wt,
|
|
1090
1090
|
getFieldState: tt
|
|
@@ -1102,7 +1102,7 @@ var ue = () => {
|
|
|
1102
1102
|
const e = (Math.random() * 16 + t) % 16 | 0;
|
|
1103
1103
|
return (r == "x" ? e : e & 3 | 8).toString(16);
|
|
1104
1104
|
});
|
|
1105
|
-
}, Ne = (t, r, e = {}) => e.shouldFocus ||
|
|
1105
|
+
}, Ne = (t, r, e = {}) => e.shouldFocus || T(e.shouldFocus) ? e.focusName || `${t}.${T(e.focusIndex) ? r : e.focusIndex}.` : "", Le = (t, r) => [
|
|
1106
1106
|
...t,
|
|
1107
1107
|
...z(r)
|
|
1108
1108
|
], Me = (t) => Array.isArray(t) ? t.map(() => {
|
|
@@ -1114,7 +1114,7 @@ function Ie(t, r, e) {
|
|
|
1114
1114
|
...t.slice(r)
|
|
1115
1115
|
];
|
|
1116
1116
|
}
|
|
1117
|
-
var Be = (t, r, e) => Array.isArray(t) ? (
|
|
1117
|
+
var Be = (t, r, e) => Array.isArray(t) ? (T(t[e]) && (t[e] = void 0), t.splice(e, 0, t.splice(r, 1)[0]), t) : [], Pe = (t, r) => [
|
|
1118
1118
|
...z(r),
|
|
1119
1119
|
...z(t)
|
|
1120
1120
|
];
|
|
@@ -1125,12 +1125,12 @@ function vr(t, r) {
|
|
|
1125
1125
|
s.splice(u - e, 1), e++;
|
|
1126
1126
|
return we(s).length ? s : [];
|
|
1127
1127
|
}
|
|
1128
|
-
var We = (t, r) =>
|
|
1128
|
+
var We = (t, r) => T(r) ? [] : vr(t, z(r).sort((e, s) => e - s)), $e = (t, r, e) => {
|
|
1129
1129
|
[t[r], t[e]] = [t[e], t[r]];
|
|
1130
1130
|
}, Ft = (t, r, e) => (t[r] = e, t);
|
|
1131
1131
|
function Vr(t) {
|
|
1132
1132
|
const r = Ve(), { control: e = r.control, name: s, keyName: u = "id", shouldUnregister: i, rules: c } = t, [l, V] = b.useState(e._getFieldArray(s)), v = b.useRef(e._getFieldArray(s).map(ue)), x = b.useRef(!1);
|
|
1133
|
-
e._names.array.add(s), b.useMemo(() => c && l.length >= 0 && e.register(s, c), [e, s, l.length, c]),
|
|
1133
|
+
e._names.array.add(s), b.useMemo(() => c && l.length >= 0 && e.register(s, c), [e, s, l.length, c]), Ce(() => e._subjects.array.subscribe({
|
|
1134
1134
|
next: ({ values: f, name: d }) => {
|
|
1135
1135
|
if (d === s || !d) {
|
|
1136
1136
|
const p = m(f, s);
|
|
@@ -1197,7 +1197,7 @@ function Vr(t) {
|
|
|
1197
1197
|
else {
|
|
1198
1198
|
const f = m(e._fields, s);
|
|
1199
1199
|
f && f._f && !(ye(e._options.reValidateMode).isOnSubmit && ye(e._options.mode).isOnSubmit) && Ge(f, e._names.disabled, e._formValues, e._options.criteriaMode === X.all, e._options.shouldUseNativeValidation, !0).then((d) => !q(d) && e._subjects.state.next({
|
|
1200
|
-
errors:
|
|
1200
|
+
errors: Ot(e._formState.errors, d, s)
|
|
1201
1201
|
}));
|
|
1202
1202
|
}
|
|
1203
1203
|
e._subjects.state.next({
|
|
@@ -1260,7 +1260,7 @@ function Fr(t = {}) {
|
|
|
1260
1260
|
};
|
|
1261
1261
|
}
|
|
1262
1262
|
const i = r.current.control;
|
|
1263
|
-
return i._options = t,
|
|
1263
|
+
return i._options = t, Ce(() => {
|
|
1264
1264
|
const c = i._subscribe({
|
|
1265
1265
|
formState: i._proxyFormState,
|
|
1266
1266
|
callback: () => u({ ...i._formState }),
|
|
@@ -1295,8 +1295,8 @@ function Fr(t = {}) {
|
|
|
1295
1295
|
i._state.mount || (i._setValid(), i._state.mount = !0), i._state.watch && (i._state.watch = !1, i._subjects.state.next({ ...i._formState })), i._removeUnmounted();
|
|
1296
1296
|
}), r.current.formState = St(s, i), r.current;
|
|
1297
1297
|
}
|
|
1298
|
-
const
|
|
1299
|
-
const t = zt(
|
|
1298
|
+
const Tt = Gt(void 0), br = ({ showAsterisk: t, children: r }) => /* @__PURE__ */ ee(Tt.Provider, { value: { showAsterisk: t }, children: r }), Ar = () => {
|
|
1299
|
+
const t = zt(Tt);
|
|
1300
1300
|
if (!t)
|
|
1301
1301
|
throw new Error("useSuprFormContext must be used within a SuprFormProvider");
|
|
1302
1302
|
return t;
|
|
@@ -1329,7 +1329,7 @@ function Ut(t, r, e) {
|
|
|
1329
1329
|
return !1;
|
|
1330
1330
|
}
|
|
1331
1331
|
});
|
|
1332
|
-
return u === "AND" ? c.every(Boolean) : c.some(Boolean);
|
|
1332
|
+
return console.log("Condition results:", c, "Operator:", u), u === "AND" ? c.every(Boolean) : c.some(Boolean);
|
|
1333
1333
|
}
|
|
1334
1334
|
const pr = ({
|
|
1335
1335
|
children: t,
|