suprform 1.2.0 → 1.2.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/components/SuprForm.d.ts.map +1 -1
- package/dist/suprform.cjs.js +1 -1
- package/dist/suprform.cjs.js.map +1 -1
- package/dist/suprform.es.js +114 -113
- package/dist/suprform.es.js.map +1 -1
- package/package.json +1 -1
package/dist/suprform.es.js
CHANGED
|
@@ -32,8 +32,8 @@ var Ee = (t) => /^\w*$/.test(t), N = (t) => t === void 0, we = (t) => Array.isAr
|
|
|
32
32
|
const l = u[s];
|
|
33
33
|
let V = e;
|
|
34
34
|
if (s !== c) {
|
|
35
|
-
const
|
|
36
|
-
V = H(
|
|
35
|
+
const g = t[l];
|
|
36
|
+
V = H(g) || Array.isArray(g) ? g : isNaN(+u[s + 1]) ? {} : [];
|
|
37
37
|
}
|
|
38
38
|
if (l === "__proto__" || l === "constructor" || l === "prototype")
|
|
39
39
|
return;
|
|
@@ -93,10 +93,10 @@ function rr(t) {
|
|
|
93
93
|
name: u,
|
|
94
94
|
formState: V.current,
|
|
95
95
|
exact: i,
|
|
96
|
-
callback: (
|
|
96
|
+
callback: (g) => {
|
|
97
97
|
!s && l({
|
|
98
98
|
...e._formState,
|
|
99
|
-
...
|
|
99
|
+
...g
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
}), [u, s, i]), F.useEffect(() => {
|
|
@@ -128,25 +128,25 @@ function ae(t, r, e = /* @__PURE__ */ new WeakSet()) {
|
|
|
128
128
|
return !0;
|
|
129
129
|
}
|
|
130
130
|
function Xe(t) {
|
|
131
|
-
const r = Ve(), { control: e = r.control, name: s, defaultValue: u, disabled: i, exact: c, compute: l } = t || {}, V = F.useRef(u),
|
|
132
|
-
|
|
131
|
+
const r = Ve(), { control: e = r.control, name: s, defaultValue: u, disabled: i, exact: c, compute: l } = t || {}, V = F.useRef(u), g = F.useRef(l), k = F.useRef(void 0), h = F.useRef(e), S = F.useRef(s);
|
|
132
|
+
g.current = l;
|
|
133
133
|
const [p, I] = F.useState(() => {
|
|
134
134
|
const f = e._getWatch(s, V.current);
|
|
135
|
-
return
|
|
135
|
+
return g.current ? g.current(f) : f;
|
|
136
136
|
}), R = F.useCallback((f) => {
|
|
137
137
|
const d = qe(s, e._names, f || e._formValues, !1, V.current);
|
|
138
|
-
return
|
|
138
|
+
return g.current ? g.current(d) : d;
|
|
139
139
|
}, [e._formValues, e._names, s]), T = F.useCallback((f) => {
|
|
140
140
|
if (!i) {
|
|
141
141
|
const d = qe(s, e._names, f || e._formValues, !1, V.current);
|
|
142
|
-
if (
|
|
143
|
-
const A =
|
|
142
|
+
if (g.current) {
|
|
143
|
+
const A = g.current(d);
|
|
144
144
|
ae(A, k.current) || (I(A), k.current = A);
|
|
145
145
|
} else
|
|
146
146
|
I(d);
|
|
147
147
|
}
|
|
148
148
|
}, [e._formValues, e._names, i, s]);
|
|
149
|
-
ke(() => ((
|
|
149
|
+
ke(() => ((h.current !== e || !ae(S.current, s)) && (h.current = e, S.current = s, T()), e._subscribe({
|
|
150
150
|
name: s,
|
|
151
151
|
formState: {
|
|
152
152
|
values: !0
|
|
@@ -156,7 +156,7 @@ function Xe(t) {
|
|
|
156
156
|
T(f.values);
|
|
157
157
|
}
|
|
158
158
|
})), [e, c, s, T]), F.useEffect(() => e._removeUnmounted());
|
|
159
|
-
const U =
|
|
159
|
+
const U = h.current !== e, x = S.current, B = F.useMemo(() => {
|
|
160
160
|
if (i)
|
|
161
161
|
return null;
|
|
162
162
|
const f = !U && !ae(x, s);
|
|
@@ -165,12 +165,12 @@ function Xe(t) {
|
|
|
165
165
|
return B !== null ? B : p;
|
|
166
166
|
}
|
|
167
167
|
function sr(t) {
|
|
168
|
-
const r = Ve(), { name: e, disabled: s, control: u = r.control, shouldUnregister: i, defaultValue: c, exact: l = !0 } = t, V = St(u._names.array, e),
|
|
168
|
+
const r = Ve(), { name: e, disabled: s, control: u = r.control, shouldUnregister: i, defaultValue: c, exact: l = !0 } = t, V = St(u._names.array, e), g = F.useMemo(() => m(u._formValues, e, m(u._defaultValues, e, c)), [u, e, c]), k = Xe({
|
|
169
169
|
control: u,
|
|
170
170
|
name: e,
|
|
171
|
-
defaultValue:
|
|
171
|
+
defaultValue: g,
|
|
172
172
|
exact: l
|
|
173
|
-
}),
|
|
173
|
+
}), h = rr({
|
|
174
174
|
control: u,
|
|
175
175
|
name: e,
|
|
176
176
|
exact: l
|
|
@@ -183,25 +183,25 @@ function sr(t) {
|
|
|
183
183
|
const R = F.useMemo(() => Object.defineProperties({}, {
|
|
184
184
|
invalid: {
|
|
185
185
|
enumerable: !0,
|
|
186
|
-
get: () => !!m(
|
|
186
|
+
get: () => !!m(h.errors, e)
|
|
187
187
|
},
|
|
188
188
|
isDirty: {
|
|
189
189
|
enumerable: !0,
|
|
190
|
-
get: () => !!m(
|
|
190
|
+
get: () => !!m(h.dirtyFields, e)
|
|
191
191
|
},
|
|
192
192
|
isTouched: {
|
|
193
193
|
enumerable: !0,
|
|
194
|
-
get: () => !!m(
|
|
194
|
+
get: () => !!m(h.touchedFields, e)
|
|
195
195
|
},
|
|
196
196
|
isValidating: {
|
|
197
197
|
enumerable: !0,
|
|
198
|
-
get: () => !!m(
|
|
198
|
+
get: () => !!m(h.validatingFields, e)
|
|
199
199
|
},
|
|
200
200
|
error: {
|
|
201
201
|
enumerable: !0,
|
|
202
|
-
get: () => m(
|
|
202
|
+
get: () => m(h.errors, e)
|
|
203
203
|
}
|
|
204
|
-
}), [
|
|
204
|
+
}), [h, e]), T = F.useCallback((f) => I.current.onChange({
|
|
205
205
|
target: {
|
|
206
206
|
value: xt(f),
|
|
207
207
|
name: e
|
|
@@ -224,11 +224,11 @@ function sr(t) {
|
|
|
224
224
|
}, [u._fields, e]), B = F.useMemo(() => ({
|
|
225
225
|
name: e,
|
|
226
226
|
value: k,
|
|
227
|
-
...J(s) ||
|
|
227
|
+
...J(s) || h.disabled ? { disabled: h.disabled || s } : {},
|
|
228
228
|
onChange: T,
|
|
229
229
|
onBlur: U,
|
|
230
230
|
ref: x
|
|
231
|
-
}), [e, s,
|
|
231
|
+
}), [e, s, h.disabled, T, U, x, k]);
|
|
232
232
|
return F.useEffect(() => {
|
|
233
233
|
const f = u._options.shouldUnregister || i, d = p.current;
|
|
234
234
|
d && d !== e && !V && u.unregister(d), u.register(e, {
|
|
@@ -253,9 +253,9 @@ function sr(t) {
|
|
|
253
253
|
});
|
|
254
254
|
}, [s, e, u]), F.useMemo(() => ({
|
|
255
255
|
field: B,
|
|
256
|
-
formState:
|
|
256
|
+
formState: h,
|
|
257
257
|
fieldState: R
|
|
258
|
-
}), [B,
|
|
258
|
+
}), [B, h, R]);
|
|
259
259
|
}
|
|
260
260
|
const ar = (t) => t.render(sr(t));
|
|
261
261
|
var nr = (t, r, e, s, u) => r ? {
|
|
@@ -463,7 +463,7 @@ var le = (t) => H(t) && !Se(t) ? t : {
|
|
|
463
463
|
value: t,
|
|
464
464
|
message: ""
|
|
465
465
|
}, ze = async (t, r, e, s, u, i) => {
|
|
466
|
-
const { ref: c, refs: l, required: V, maxLength:
|
|
466
|
+
const { ref: c, refs: l, required: V, maxLength: g, minLength: k, min: h, max: S, pattern: p, validate: I, name: R, valueAsNumber: T, mount: U } = t._f, x = m(e, R);
|
|
467
467
|
if (!U || r.has(R))
|
|
468
468
|
return {};
|
|
469
469
|
const B = l ? l[0] : c, f = (E) => {
|
|
@@ -487,9 +487,9 @@ var le = (t) => H(t) && !Se(t) ? t : {
|
|
|
487
487
|
}, !s))
|
|
488
488
|
return f(C), d;
|
|
489
489
|
}
|
|
490
|
-
if (!K && (!Q(
|
|
490
|
+
if (!K && (!Q(h) || !Q(S))) {
|
|
491
491
|
let E, C;
|
|
492
|
-
const $ = le(S), q = le(
|
|
492
|
+
const $ = le(S), q = le(h);
|
|
493
493
|
if (!Q(x) && !isNaN(x)) {
|
|
494
494
|
const se = c.valueAsNumber || x && +x;
|
|
495
495
|
Q($.value) || (E = se > $.value), Q(q.value) || (C = se < q.value);
|
|
@@ -500,8 +500,8 @@ var le = (t) => H(t) && !Se(t) ? t : {
|
|
|
500
500
|
if ((E || C) && (Fe(!!E, $.message, q.message, ne.max, ne.min), !s))
|
|
501
501
|
return f(d[R].message), d;
|
|
502
502
|
}
|
|
503
|
-
if ((
|
|
504
|
-
const E = le(
|
|
503
|
+
if ((g || k) && !K && (X(x) || i && Array.isArray(x))) {
|
|
504
|
+
const E = le(g), C = le(k), $ = !Q(E.value) && x.length > +E.value, q = !Q(C.value) && x.length < +C.value;
|
|
505
505
|
if (($ || q) && (Fe($, E.message, C.message), !s))
|
|
506
506
|
return f(d[R].message), d;
|
|
507
507
|
}
|
|
@@ -578,7 +578,7 @@ function vr(t = {}) {
|
|
|
578
578
|
unMount: /* @__PURE__ */ new Set(),
|
|
579
579
|
array: /* @__PURE__ */ new Set(),
|
|
580
580
|
watch: /* @__PURE__ */ new Set()
|
|
581
|
-
}, V,
|
|
581
|
+
}, V, g = 0;
|
|
582
582
|
const k = {
|
|
583
583
|
isDirty: !1,
|
|
584
584
|
dirtyFields: !1,
|
|
@@ -587,26 +587,26 @@ function vr(t = {}) {
|
|
|
587
587
|
isValidating: !1,
|
|
588
588
|
isValid: !1,
|
|
589
589
|
errors: !1
|
|
590
|
-
},
|
|
590
|
+
}, h = {
|
|
591
591
|
...k
|
|
592
592
|
};
|
|
593
593
|
let S = {
|
|
594
|
-
...
|
|
594
|
+
...h
|
|
595
595
|
};
|
|
596
596
|
const p = {
|
|
597
597
|
array: yt(),
|
|
598
598
|
state: yt()
|
|
599
599
|
}, I = r.criteriaMode === re.all, R = (a) => (n) => {
|
|
600
|
-
clearTimeout(
|
|
600
|
+
clearTimeout(g), g = setTimeout(a, n);
|
|
601
601
|
}, T = async (a) => {
|
|
602
|
-
if (!c.keepIsValid && !r.disabled && (
|
|
602
|
+
if (!c.keepIsValid && !r.disabled && (h.isValid || S.isValid || a)) {
|
|
603
603
|
let n;
|
|
604
604
|
r.resolver ? (n = j((await W()).errors), U()) : n = await Z(s, !0), n !== e.isValid && p.state.next({
|
|
605
605
|
isValid: n
|
|
606
606
|
});
|
|
607
607
|
}
|
|
608
608
|
}, U = (a, n) => {
|
|
609
|
-
!r.disabled && (
|
|
609
|
+
!r.disabled && (h.isValidating || h.validatingFields || S.isValidating || S.validatingFields) && ((a || Array.from(l.mount)).forEach((o) => {
|
|
610
610
|
o && (n ? O(e.validatingFields, o, n) : P(e.validatingFields, o));
|
|
611
611
|
}), p.state.next({
|
|
612
612
|
validatingFields: e.validatingFields,
|
|
@@ -622,11 +622,11 @@ function vr(t = {}) {
|
|
|
622
622
|
const b = o(m(e.errors, a), v.argA, v.argB);
|
|
623
623
|
_ && O(e.errors, a, b), gr(e.errors, a);
|
|
624
624
|
}
|
|
625
|
-
if ((
|
|
625
|
+
if ((h.touchedFields || S.touchedFields) && y && Array.isArray(m(e.touchedFields, a))) {
|
|
626
626
|
const b = o(m(e.touchedFields, a), v.argA, v.argB);
|
|
627
627
|
_ && O(e.touchedFields, a, b);
|
|
628
628
|
}
|
|
629
|
-
(
|
|
629
|
+
(h.dirtyFields || S.dirtyFields) && (e.dirtyFields = ce(u, i)), p.state.next({
|
|
630
630
|
name: a,
|
|
631
631
|
isDirty: E(a, n),
|
|
632
632
|
dirtyFields: e.dirtyFields,
|
|
@@ -657,20 +657,20 @@ function vr(t = {}) {
|
|
|
657
657
|
};
|
|
658
658
|
if (!r.disabled) {
|
|
659
659
|
if (!o || v) {
|
|
660
|
-
(
|
|
660
|
+
(h.isDirty || S.isDirty) && (b = e.isDirty, e.isDirty = D.isDirty = E(), y = b !== D.isDirty);
|
|
661
661
|
const L = ae(m(u, a), n);
|
|
662
|
-
b = !!m(e.dirtyFields, a), L ? P(e.dirtyFields, a) : O(e.dirtyFields, a, !0), D.dirtyFields = e.dirtyFields, y = y || (
|
|
662
|
+
b = !!m(e.dirtyFields, a), L ? P(e.dirtyFields, a) : O(e.dirtyFields, a, !0), D.dirtyFields = e.dirtyFields, y = y || (h.dirtyFields || S.dirtyFields) && b !== !L;
|
|
663
663
|
}
|
|
664
664
|
if (o) {
|
|
665
665
|
const L = m(e.touchedFields, a);
|
|
666
|
-
L || (O(e.touchedFields, a, o), D.touchedFields = e.touchedFields, y = y || (
|
|
666
|
+
L || (O(e.touchedFields, a, o), D.touchedFields = e.touchedFields, y = y || (h.touchedFields || S.touchedFields) && L !== o);
|
|
667
667
|
}
|
|
668
668
|
y && _ && p.state.next(D);
|
|
669
669
|
}
|
|
670
670
|
return y ? D : {};
|
|
671
671
|
}, w = (a, n, o, v) => {
|
|
672
|
-
const _ = m(e.errors, a), y = (
|
|
673
|
-
if (r.delayError && o ? (V = R(() => B(a, o)), V(r.delayError)) : (clearTimeout(
|
|
672
|
+
const _ = m(e.errors, a), y = (h.isValid || S.isValid) && J(n) && e.isValid !== n;
|
|
673
|
+
if (r.delayError && o ? (V = R(() => B(a, o)), V(r.delayError)) : (clearTimeout(g), V = null, o ? O(e.errors, a, o) : P(e.errors, a)), (o ? !ae(_, o) : _) || !j(v) || y) {
|
|
674
674
|
const b = {
|
|
675
675
|
...v,
|
|
676
676
|
...y && J(n) ? { isValid: n } : {},
|
|
@@ -701,9 +701,9 @@ function vr(t = {}) {
|
|
|
701
701
|
const { _f: y, ...b } = _;
|
|
702
702
|
if (y) {
|
|
703
703
|
const D = l.array.has(y.name), L = _._f && dr(_._f);
|
|
704
|
-
L &&
|
|
704
|
+
L && h.validatingFields && U([y.name], !0);
|
|
705
705
|
const ee = await ze(_, l.disabled, i, I, r.shouldUseNativeValidation && !n, D);
|
|
706
|
-
if (L &&
|
|
706
|
+
if (L && h.validatingFields && U([y.name]), ee[y.name] && (o.valid = !1, n))
|
|
707
707
|
break;
|
|
708
708
|
!n && (m(ee, y.name) ? D ? Rt(e.errors, ee, y.name) : O(e.errors, y.name, ee[y.name]) : P(e.errors, y.name));
|
|
709
709
|
}
|
|
@@ -744,7 +744,7 @@ function vr(t = {}) {
|
|
|
744
744
|
O(i, a, y), _ ? (p.array.next({
|
|
745
745
|
name: a,
|
|
746
746
|
values: M(i)
|
|
747
|
-
}), (
|
|
747
|
+
}), (h.isDirty || h.dirtyFields || S.isDirty || S.dirtyFields) && o.shouldDirty && p.state.next({
|
|
748
748
|
name: a,
|
|
749
749
|
dirtyFields: ce(u, i),
|
|
750
750
|
isDirty: E(a, y)
|
|
@@ -769,7 +769,7 @@ function vr(t = {}) {
|
|
|
769
769
|
type: a.type,
|
|
770
770
|
values: M(i)
|
|
771
771
|
}), qt)
|
|
772
|
-
return (
|
|
772
|
+
return (h.isValid || S.isValid) && (r.mode === "onBlur" ? ie && T() : ie || T()), jt && p.state.next({ name: o, ...Oe ? {} : Re });
|
|
773
773
|
if (!ie && Oe && p.state.next({ ...e }), r.resolver) {
|
|
774
774
|
const { errors: dt } = await W([o]);
|
|
775
775
|
if (U([o]), y(be), v) {
|
|
@@ -777,7 +777,7 @@ function vr(t = {}) {
|
|
|
777
777
|
L = ft.error, o = ft.name, ee = j(dt);
|
|
778
778
|
}
|
|
779
779
|
} else
|
|
780
|
-
U([o], !0), L = (await ze(_, l.disabled, i, I, r.shouldUseNativeValidation))[o], U([o]), y(be), v && (L ? ee = !1 : (
|
|
780
|
+
U([o], !0), L = (await ze(_, l.disabled, i, I, r.shouldUseNativeValidation))[o], U([o]), y(be), v && (L ? ee = !1 : (h.isValid || S.isValid) && (ee = await Z(s, !0)));
|
|
781
781
|
v && (_._f.deps && (!Array.isArray(_._f.deps) || _._f.deps.length > 0) && ge(_._f.deps), w(o, ee, L, Re));
|
|
782
782
|
}
|
|
783
783
|
}, _e = (a, n) => {
|
|
@@ -794,7 +794,7 @@ function vr(t = {}) {
|
|
|
794
794
|
return await Z(b && b._f ? { [y]: b } : b);
|
|
795
795
|
}))).every(Boolean), !(!v && !e.isValid) && T()) : v = o = await Z(s);
|
|
796
796
|
return p.state.next({
|
|
797
|
-
...!X(a) || (
|
|
797
|
+
...!X(a) || (h.isValid || S.isValid) && o !== e.isValid ? {} : { name: a },
|
|
798
798
|
...r.resolver || !a ? { isValid: o } : {},
|
|
799
799
|
errors: e.errors
|
|
800
800
|
}), n.shouldFocus && !v && fe(s, _e, a ? _ : l.mount), v;
|
|
@@ -828,7 +828,7 @@ function vr(t = {}) {
|
|
|
828
828
|
next: (o) => "values" in o && a(C(void 0, n), o)
|
|
829
829
|
}) : C(a, n, !0), nt = (a) => p.state.subscribe({
|
|
830
830
|
next: (n) => {
|
|
831
|
-
mr(a.name, n.name, a.exact) && yr(n, a.formState ||
|
|
831
|
+
mr(a.name, n.name, a.exact) && yr(n, a.formState || h, $t, a.reRenderRoot) && a.callback({
|
|
832
832
|
values: { ...i },
|
|
833
833
|
...e,
|
|
834
834
|
...n,
|
|
@@ -946,7 +946,7 @@ function vr(t = {}) {
|
|
|
946
946
|
}), v)
|
|
947
947
|
throw v;
|
|
948
948
|
}, Wt = (a, n = {}) => {
|
|
949
|
-
m(s, a) && (N(n.defaultValue) ? Y(a, M(m(u, a))) : (Y(a, n.defaultValue), O(u, a, M(n.defaultValue))), n.keepTouched || P(e.touchedFields, a), n.keepDirty || (P(e.dirtyFields, a), e.isDirty = n.defaultValue ? E(a, M(m(u, a))) : E()), n.keepError || (P(e.errors, a),
|
|
949
|
+
m(s, a) && (N(n.defaultValue) ? Y(a, M(m(u, a))) : (Y(a, n.defaultValue), O(u, a, M(n.defaultValue))), n.keepTouched || P(e.touchedFields, a), n.keepDirty || (P(e.dirtyFields, a), e.isDirty = n.defaultValue ? E(a, M(m(u, a))) : E()), n.keepError || (P(e.errors, a), h.isValid && T()), p.state.next({ ...e }));
|
|
950
950
|
}, ot = (a, n = {}) => {
|
|
951
951
|
const o = a ? M(a) : u, v = M(o), _ = j(a), y = _ ? u : v;
|
|
952
952
|
if (n.keepDefaultValues || (u = o), !n.keepValues) {
|
|
@@ -992,7 +992,7 @@ function vr(t = {}) {
|
|
|
992
992
|
watch: /* @__PURE__ */ new Set(),
|
|
993
993
|
watchAll: !1,
|
|
994
994
|
focus: ""
|
|
995
|
-
}, c.mount = !
|
|
995
|
+
}, c.mount = !h.isValid || !!n.keepIsValid || !!n.keepDirtyValues || !r.shouldUnregister && !j(y), c.watch = !!r.shouldUnregister, c.keepIsValid = !!n.keepIsValid, c.action = !1, n.keepErrors || (e.errors = {}), p.state.next({
|
|
996
996
|
submitCount: n.keepSubmitCount ? e.submitCount : 0,
|
|
997
997
|
isDirty: _ ? !1 : n.keepDirty ? e.isDirty : !!(n.keepDefaultValues && !ae(a, u)),
|
|
998
998
|
isSubmitted: n.keepIsSubmitted ? e.isSubmitted : !1,
|
|
@@ -1043,7 +1043,7 @@ function vr(t = {}) {
|
|
|
1043
1043
|
_removeUnmounted: Fe,
|
|
1044
1044
|
_disableForm: Pt,
|
|
1045
1045
|
_subjects: p,
|
|
1046
|
-
_proxyFormState:
|
|
1046
|
+
_proxyFormState: h,
|
|
1047
1047
|
get _fields() {
|
|
1048
1048
|
return s;
|
|
1049
1049
|
},
|
|
@@ -1133,59 +1133,59 @@ var He = (t, r) => N(r) ? [] : Vr(t, z(r).sort((e, s) => e - s)), $e = (t, r, e)
|
|
|
1133
1133
|
[t[r], t[e]] = [t[e], t[r]];
|
|
1134
1134
|
}, bt = (t, r, e) => (t[r] = e, t);
|
|
1135
1135
|
function Fr(t) {
|
|
1136
|
-
const r = Ve(), { control: e = r.control, name: s, keyName: u = "id", shouldUnregister: i, rules: c } = t, [l, V] = F.useState(e._getFieldArray(s)),
|
|
1136
|
+
const r = Ve(), { control: e = r.control, name: s, keyName: u = "id", shouldUnregister: i, rules: c } = t, [l, V] = F.useState(e._getFieldArray(s)), g = F.useRef(e._getFieldArray(s).map(ue)), k = F.useRef(!1);
|
|
1137
1137
|
e._names.array.add(s), F.useMemo(() => c && l.length >= 0 && e.register(s, c), [e, s, l.length, c]), ke(() => e._subjects.array.subscribe({
|
|
1138
1138
|
next: ({ values: f, name: d }) => {
|
|
1139
1139
|
if (d === s || !d) {
|
|
1140
1140
|
const A = m(f, s);
|
|
1141
|
-
Array.isArray(A) && (V(A),
|
|
1141
|
+
Array.isArray(A) && (V(A), g.current = A.map(ue));
|
|
1142
1142
|
}
|
|
1143
1143
|
}
|
|
1144
1144
|
}).unsubscribe, [e, s]);
|
|
1145
|
-
const
|
|
1145
|
+
const h = F.useCallback((f) => {
|
|
1146
1146
|
k.current = !0, e._setFieldArray(s, f);
|
|
1147
1147
|
}, [e, s]), S = (f, d) => {
|
|
1148
1148
|
const A = z(M(f)), w = Me(e._getFieldArray(s), A);
|
|
1149
|
-
e._names.focus = Ue(s, w.length - 1, d),
|
|
1149
|
+
e._names.focus = Ue(s, w.length - 1, d), g.current = Me(g.current, A.map(ue)), h(w), V(w), e._setFieldArray(s, w, Me, {
|
|
1150
1150
|
argA: Ie(f)
|
|
1151
1151
|
});
|
|
1152
1152
|
}, p = (f, d) => {
|
|
1153
1153
|
const A = z(M(f)), w = We(e._getFieldArray(s), A);
|
|
1154
|
-
e._names.focus = Ue(s, 0, d),
|
|
1154
|
+
e._names.focus = Ue(s, 0, d), g.current = We(g.current, A.map(ue)), h(w), V(w), e._setFieldArray(s, w, We, {
|
|
1155
1155
|
argA: Ie(f)
|
|
1156
1156
|
});
|
|
1157
1157
|
}, I = (f) => {
|
|
1158
1158
|
const d = He(e._getFieldArray(s), f);
|
|
1159
|
-
|
|
1159
|
+
g.current = He(g.current, f), h(d), V(d), !Array.isArray(m(e._fields, s)) && O(e._fields, s, void 0), e._setFieldArray(s, d, He, {
|
|
1160
1160
|
argA: f
|
|
1161
1161
|
});
|
|
1162
1162
|
}, R = (f, d, A) => {
|
|
1163
1163
|
const w = z(M(d)), W = Be(e._getFieldArray(s), f, w);
|
|
1164
|
-
e._names.focus = Ue(s, f, A),
|
|
1164
|
+
e._names.focus = Ue(s, f, A), g.current = Be(g.current, f, w.map(ue)), h(W), V(W), e._setFieldArray(s, W, Be, {
|
|
1165
1165
|
argA: f,
|
|
1166
1166
|
argB: Ie(d)
|
|
1167
1167
|
});
|
|
1168
1168
|
}, T = (f, d) => {
|
|
1169
1169
|
const A = e._getFieldArray(s);
|
|
1170
|
-
$e(A, f, d), $e(
|
|
1170
|
+
$e(A, f, d), $e(g.current, f, d), h(A), V(A), e._setFieldArray(s, A, $e, {
|
|
1171
1171
|
argA: f,
|
|
1172
1172
|
argB: d
|
|
1173
1173
|
}, !1);
|
|
1174
1174
|
}, U = (f, d) => {
|
|
1175
1175
|
const A = e._getFieldArray(s);
|
|
1176
|
-
Pe(A, f, d), Pe(
|
|
1176
|
+
Pe(A, f, d), Pe(g.current, f, d), h(A), V(A), e._setFieldArray(s, A, Pe, {
|
|
1177
1177
|
argA: f,
|
|
1178
1178
|
argB: d
|
|
1179
1179
|
}, !1);
|
|
1180
1180
|
}, x = (f, d) => {
|
|
1181
1181
|
const A = M(d), w = bt(e._getFieldArray(s), f, A);
|
|
1182
|
-
|
|
1182
|
+
g.current = [...w].map((W, K) => !W || K === f ? ue() : g.current[K]), h(w), V([...w]), e._setFieldArray(s, w, bt, {
|
|
1183
1183
|
argA: f,
|
|
1184
1184
|
argB: A
|
|
1185
1185
|
}, !0, !1);
|
|
1186
1186
|
}, B = (f) => {
|
|
1187
1187
|
const d = z(M(f));
|
|
1188
|
-
|
|
1188
|
+
g.current = d.map(ue), h([...d]), V([...d]), e._setFieldArray(s, [...d], (A) => A, {}, !0, !1);
|
|
1189
1189
|
};
|
|
1190
1190
|
return F.useEffect(() => {
|
|
1191
1191
|
if (e._state.action = !1, Qe(s, e._names) && e._subjects.state.next({
|
|
@@ -1219,17 +1219,17 @@ function Fr(t) {
|
|
|
1219
1219
|
};
|
|
1220
1220
|
e._options.shouldUnregister || i ? e.unregister(s) : f(s, !1);
|
|
1221
1221
|
}), [s, e, u, i]), {
|
|
1222
|
-
swap: F.useCallback(T, [
|
|
1223
|
-
move: F.useCallback(U, [
|
|
1224
|
-
prepend: F.useCallback(p, [
|
|
1225
|
-
append: F.useCallback(S, [
|
|
1226
|
-
remove: F.useCallback(I, [
|
|
1227
|
-
insert: F.useCallback(R, [
|
|
1228
|
-
update: F.useCallback(x, [
|
|
1229
|
-
replace: F.useCallback(B, [
|
|
1222
|
+
swap: F.useCallback(T, [h, s, e]),
|
|
1223
|
+
move: F.useCallback(U, [h, s, e]),
|
|
1224
|
+
prepend: F.useCallback(p, [h, s, e]),
|
|
1225
|
+
append: F.useCallback(S, [h, s, e]),
|
|
1226
|
+
remove: F.useCallback(I, [h, s, e]),
|
|
1227
|
+
insert: F.useCallback(R, [h, s, e]),
|
|
1228
|
+
update: F.useCallback(x, [h, s, e]),
|
|
1229
|
+
replace: F.useCallback(B, [h, s, e]),
|
|
1230
1230
|
fields: F.useMemo(() => l.map((f, d) => ({
|
|
1231
1231
|
...f,
|
|
1232
|
-
[u]:
|
|
1232
|
+
[u]: g.current[d] || ue()
|
|
1233
1233
|
})), [l, u])
|
|
1234
1234
|
};
|
|
1235
1235
|
}
|
|
@@ -1307,7 +1307,7 @@ const Lt = zt(void 0), Ar = ({ showAsterisk: t, children: r }) => /* @__PURE__ *
|
|
|
1307
1307
|
return t;
|
|
1308
1308
|
};
|
|
1309
1309
|
function Nt(t, r, e) {
|
|
1310
|
-
const { conditions: s, operator: u } = e, i = t.reduce((l, V,
|
|
1310
|
+
const { conditions: s, operator: u } = e, i = t.reduce((l, V, g) => (l[V] = r[g], l), {}), c = s.map((l) => {
|
|
1311
1311
|
const V = i[l.name];
|
|
1312
1312
|
switch (l.operator) {
|
|
1313
1313
|
case "EQUALS":
|
|
@@ -1358,19 +1358,19 @@ const xr = ({
|
|
|
1358
1358
|
disabled: c,
|
|
1359
1359
|
shouldUnregister: l,
|
|
1360
1360
|
visibility: V,
|
|
1361
|
-
description:
|
|
1361
|
+
description: g
|
|
1362
1362
|
}) => {
|
|
1363
|
-
const { control: k } = Ve(),
|
|
1364
|
-
if (
|
|
1365
|
-
return typeof
|
|
1366
|
-
}, [
|
|
1363
|
+
const { control: k } = Ve(), h = t.props.value ?? "", { showAsterisk: S } = pr(), p = t.props.onChange, I = t.props.onBlur, R = ye(() => i || crypto.randomUUID(), []), T = ye(() => {
|
|
1364
|
+
if (g)
|
|
1365
|
+
return typeof g == "string" ? { position: "LABEL_BOTTOM", text: g } : g;
|
|
1366
|
+
}, [g]);
|
|
1367
1367
|
return /* @__PURE__ */ te(xr, { visibility: V, children: /* @__PURE__ */ te(Sr, { disabled: c, children: /* @__PURE__ */ te(
|
|
1368
1368
|
ar,
|
|
1369
1369
|
{
|
|
1370
1370
|
control: k,
|
|
1371
1371
|
name: r,
|
|
1372
1372
|
rules: e,
|
|
1373
|
-
defaultValue:
|
|
1373
|
+
defaultValue: h,
|
|
1374
1374
|
shouldUnregister: l,
|
|
1375
1375
|
render: ({
|
|
1376
1376
|
field: { name: U, onBlur: x, value: B, onChange: f, ref: d, disabled: A },
|
|
@@ -1437,43 +1437,43 @@ const Er = ({
|
|
|
1437
1437
|
rules: r
|
|
1438
1438
|
});
|
|
1439
1439
|
At(e, () => c, [c]);
|
|
1440
|
-
const l = (V,
|
|
1440
|
+
const l = (V, g) => Yt.map(V, (k) => {
|
|
1441
1441
|
var I, R;
|
|
1442
1442
|
if (!Jt(k))
|
|
1443
1443
|
return k;
|
|
1444
|
-
const
|
|
1445
|
-
if (((S == null ? void 0 : S.displayName) === "SuprFormControl" || S === tt ||
|
|
1446
|
-
const T = u ? u[
|
|
1444
|
+
const h = k.props, S = k.type;
|
|
1445
|
+
if (((S == null ? void 0 : S.displayName) === "SuprFormControl" || S === tt || h.name !== void 0 && typeof S != "string") && h.name !== void 0) {
|
|
1446
|
+
const T = u ? u[h.name] : void 0, U = T ? {
|
|
1447
1447
|
...T,
|
|
1448
1448
|
conditions: ((I = T.conditions) == null ? void 0 : I.map((d) => ({
|
|
1449
1449
|
...d,
|
|
1450
|
-
name: `${
|
|
1450
|
+
name: `${g}${d.name}`
|
|
1451
1451
|
}))) || []
|
|
1452
|
-
} : void 0, x = i ? i[
|
|
1452
|
+
} : void 0, x = i ? i[h.name] : void 0, B = x ? {
|
|
1453
1453
|
...x,
|
|
1454
1454
|
conditions: ((R = x.conditions) == null ? void 0 : R.map((d) => ({
|
|
1455
1455
|
...d,
|
|
1456
|
-
name: `${
|
|
1456
|
+
name: `${g}${d.name}`
|
|
1457
1457
|
}))) || []
|
|
1458
1458
|
} : void 0, f = {
|
|
1459
|
-
...
|
|
1460
|
-
name: `${
|
|
1459
|
+
...h,
|
|
1460
|
+
name: `${g}${h.name}`,
|
|
1461
1461
|
visibility: U,
|
|
1462
1462
|
disabled: B
|
|
1463
1463
|
};
|
|
1464
|
-
return
|
|
1464
|
+
return h.id !== void 0 && (f.id = `${g}${h.id}`), Ae(k, f);
|
|
1465
1465
|
}
|
|
1466
|
-
return
|
|
1467
|
-
...
|
|
1468
|
-
children: l(
|
|
1466
|
+
return h.children ? Ae(k, {
|
|
1467
|
+
...h,
|
|
1468
|
+
children: l(h.children, g)
|
|
1469
1469
|
}) : k;
|
|
1470
1470
|
});
|
|
1471
|
-
return /* @__PURE__ */ te(Qt, { children: c.fields.map((V,
|
|
1472
|
-
const k = `${t}.${
|
|
1471
|
+
return /* @__PURE__ */ te(Qt, { children: c.fields.map((V, g) => {
|
|
1472
|
+
const k = `${t}.${g}.`;
|
|
1473
1473
|
return /* @__PURE__ */ te(
|
|
1474
1474
|
"div",
|
|
1475
1475
|
{
|
|
1476
|
-
"data-index":
|
|
1476
|
+
"data-index": g,
|
|
1477
1477
|
style: { display: "contents" },
|
|
1478
1478
|
id: "field-array-item",
|
|
1479
1479
|
children: l(s, k)
|
|
@@ -1494,7 +1494,7 @@ const Er = ({
|
|
|
1494
1494
|
ref: l,
|
|
1495
1495
|
onChange: V
|
|
1496
1496
|
}) => {
|
|
1497
|
-
const
|
|
1497
|
+
const g = br({
|
|
1498
1498
|
mode: "onSubmit",
|
|
1499
1499
|
reValidateMode: "onChange",
|
|
1500
1500
|
shouldFocusError: !0,
|
|
@@ -1503,29 +1503,30 @@ const Er = ({
|
|
|
1503
1503
|
return At(
|
|
1504
1504
|
l,
|
|
1505
1505
|
() => ({
|
|
1506
|
-
setValue:
|
|
1507
|
-
setError:
|
|
1508
|
-
clearErrors:
|
|
1509
|
-
getValues:
|
|
1510
|
-
reset:
|
|
1511
|
-
setFocus:
|
|
1512
|
-
resetField:
|
|
1513
|
-
trigger:
|
|
1514
|
-
unregister:
|
|
1515
|
-
watch:
|
|
1516
|
-
handleSubmit:
|
|
1506
|
+
setValue: g.setValue,
|
|
1507
|
+
setError: g.setError,
|
|
1508
|
+
clearErrors: g.clearErrors,
|
|
1509
|
+
getValues: g.getValues,
|
|
1510
|
+
reset: g.reset,
|
|
1511
|
+
setFocus: g.setFocus,
|
|
1512
|
+
resetField: g.resetField,
|
|
1513
|
+
trigger: g.trigger,
|
|
1514
|
+
unregister: g.unregister,
|
|
1515
|
+
watch: g.watch,
|
|
1516
|
+
handleSubmit: g.handleSubmit,
|
|
1517
|
+
formState: g.formState
|
|
1517
1518
|
}),
|
|
1518
|
-
[
|
|
1519
|
+
[g]
|
|
1519
1520
|
), Xt(() => {
|
|
1520
|
-
const k =
|
|
1521
|
-
V == null || V(
|
|
1521
|
+
const k = g.watch((h) => {
|
|
1522
|
+
V == null || V(h);
|
|
1522
1523
|
});
|
|
1523
1524
|
return () => k.unsubscribe();
|
|
1524
|
-
}, [
|
|
1525
|
+
}, [g.watch]), /* @__PURE__ */ te(Ar, { showAsterisk: c, children: /* @__PURE__ */ te(tr, { ...g, children: /* @__PURE__ */ te(
|
|
1525
1526
|
"form",
|
|
1526
1527
|
{
|
|
1527
1528
|
noValidate: !0,
|
|
1528
|
-
onSubmit:
|
|
1529
|
+
onSubmit: g.handleSubmit(r, e),
|
|
1529
1530
|
style: s,
|
|
1530
1531
|
className: u,
|
|
1531
1532
|
children: t
|