suprform 1.0.11 → 1.0.12
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 +208 -194
- package/dist/suprform.es.js.map +1 -1
- package/dist/type.d.ts +15 -10
- package/dist/type.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/suprform.es.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsx as ae, Fragment as jr, jsxs as cr } from "react/jsx-runtime";
|
|
2
|
-
import b, { createContext as Qr, useContext as Gr, useMemo as We, useImperativeHandle as
|
|
2
|
+
import b, { createContext as Qr, useContext as Gr, useMemo as We, useImperativeHandle as br, useEffect as zr, cloneElement as He, Children as Kr, isValidElement as Yr } from "react";
|
|
3
3
|
var ve = (e) => e.type === "checkbox", le = (e) => e instanceof Date, G = (e) => e == null;
|
|
4
|
-
const
|
|
5
|
-
var
|
|
4
|
+
const Fr = (e) => typeof e == "object";
|
|
5
|
+
var B = (e) => !G(e) && !Array.isArray(e) && Fr(e) && !le(e), Ar = (e) => B(e) && e.target ? ve(e.target) ? e.target.checked : e.target.value : e, Jr = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, pr = (e, t) => e.has(Jr(t)), Xr = (e) => {
|
|
6
6
|
const t = e.constructor && e.constructor.prototype;
|
|
7
|
-
return
|
|
7
|
+
return B(t) && t.hasOwnProperty("isPrototypeOf");
|
|
8
8
|
}, ze = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
9
9
|
function U(e) {
|
|
10
10
|
let t;
|
|
11
11
|
const r = Array.isArray(e), s = typeof FileList < "u" ? e instanceof FileList : !1;
|
|
12
12
|
if (e instanceof Date)
|
|
13
13
|
t = new Date(e);
|
|
14
|
-
else if (!(ze && (e instanceof Blob || s)) && (r ||
|
|
14
|
+
else if (!(ze && (e instanceof Blob || s)) && (r || B(e)))
|
|
15
15
|
if (t = r ? [] : Object.create(Object.getPrototypeOf(e)), !r && !Xr(e))
|
|
16
16
|
t = e;
|
|
17
17
|
else
|
|
@@ -22,7 +22,7 @@ function U(e) {
|
|
|
22
22
|
return t;
|
|
23
23
|
}
|
|
24
24
|
var xe = (e) => /^\w*$/.test(e), T = (e) => e === void 0, Se = (e) => Array.isArray(e) ? e.filter(Boolean) : [], Ke = (e) => Se(e.replace(/["|']|\]/g, "").split(/\.|\[/)), m = (e, t, r) => {
|
|
25
|
-
if (!t || !
|
|
25
|
+
if (!t || !B(e))
|
|
26
26
|
return r;
|
|
27
27
|
const s = (xe(t) ? [t] : Ke(t)).reduce((u, i) => G(u) ? u : u[i], e);
|
|
28
28
|
return T(s) || s === e ? T(e[t]) ? r : e[t] : s;
|
|
@@ -34,14 +34,14 @@ var xe = (e) => /^\w*$/.test(e), T = (e) => e === void 0, Se = (e) => Array.isAr
|
|
|
34
34
|
let F = r;
|
|
35
35
|
if (s !== l) {
|
|
36
36
|
const h = e[c];
|
|
37
|
-
F =
|
|
37
|
+
F = B(h) || Array.isArray(h) ? h : isNaN(+u[s + 1]) ? {} : [];
|
|
38
38
|
}
|
|
39
39
|
if (c === "__proto__" || c === "constructor" || c === "prototype")
|
|
40
40
|
return;
|
|
41
41
|
e[c] = F, e = e[c];
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
const
|
|
44
|
+
const Fe = {
|
|
45
45
|
BLUR: "blur",
|
|
46
46
|
FOCUS_OUT: "focusout",
|
|
47
47
|
CHANGE: "change"
|
|
@@ -104,7 +104,7 @@ function et(e) {
|
|
|
104
104
|
F.current.isValid && r._setValid(!0);
|
|
105
105
|
}, [r]), b.useMemo(() => xr(l, r, F.current, !1), [l, r]);
|
|
106
106
|
}
|
|
107
|
-
var Y = (e) => typeof e == "string", $e = (e, t, r, s, u) => Y(e) ? (s && t.watch.add(e), m(r, e, u)) : Array.isArray(e) ? e.map((i) => (s && t.watch.add(i), m(r, i))) : (s && (t.watchAll = !0), r), qe = (e) => G(e) || !
|
|
107
|
+
var Y = (e) => typeof e == "string", $e = (e, t, r, s, u) => Y(e) ? (s && t.watch.add(e), m(r, e, u)) : Array.isArray(e) ? e.map((i) => (s && t.watch.add(i), m(r, i))) : (s && (t.watchAll = !0), r), qe = (e) => G(e) || !Fr(e);
|
|
108
108
|
function ee(e, t, r = /* @__PURE__ */ new WeakSet()) {
|
|
109
109
|
if (qe(e) || qe(t))
|
|
110
110
|
return Object.is(e, t);
|
|
@@ -122,7 +122,7 @@ function ee(e, t, r = /* @__PURE__ */ new WeakSet()) {
|
|
|
122
122
|
return !1;
|
|
123
123
|
if (i !== "ref") {
|
|
124
124
|
const c = t[i];
|
|
125
|
-
if (le(l) && le(c) ||
|
|
125
|
+
if (le(l) && le(c) || B(l) && B(c) || Array.isArray(l) && Array.isArray(c) ? !ee(l, c, r) : !Object.is(l, c))
|
|
126
126
|
return !1;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -131,39 +131,39 @@ function ee(e, t, r = /* @__PURE__ */ new WeakSet()) {
|
|
|
131
131
|
function Sr(e) {
|
|
132
132
|
const t = _e(), { control: r = t.control, name: s, defaultValue: u, disabled: i, exact: l, compute: c } = e || {}, F = b.useRef(u), h = b.useRef(c), V = b.useRef(void 0), g = b.useRef(r), A = b.useRef(s);
|
|
133
133
|
h.current = c;
|
|
134
|
-
const [
|
|
134
|
+
const [P, N] = b.useState(() => {
|
|
135
135
|
const f = r._getWatch(s, F.current);
|
|
136
136
|
return h.current ? h.current(f) : f;
|
|
137
|
-
}),
|
|
137
|
+
}), w = b.useCallback((f) => {
|
|
138
138
|
const y = $e(s, r._names, f || r._formValues, !1, F.current);
|
|
139
139
|
return h.current ? h.current(y) : y;
|
|
140
|
-
}, [r._formValues, r._names, s]),
|
|
140
|
+
}, [r._formValues, r._names, s]), L = b.useCallback((f) => {
|
|
141
141
|
if (!i) {
|
|
142
142
|
const y = $e(s, r._names, f || r._formValues, !1, F.current);
|
|
143
143
|
if (h.current) {
|
|
144
144
|
const x = h.current(y);
|
|
145
|
-
ee(x, V.current) || (
|
|
145
|
+
ee(x, V.current) || (N(x), V.current = x);
|
|
146
146
|
} else
|
|
147
|
-
|
|
147
|
+
N(y);
|
|
148
148
|
}
|
|
149
149
|
}, [r._formValues, r._names, i, s]);
|
|
150
|
-
Ee(() => ((g.current !== r || !ee(A.current, s)) && (g.current = r, A.current = s,
|
|
150
|
+
Ee(() => ((g.current !== r || !ee(A.current, s)) && (g.current = r, A.current = s, L()), r._subscribe({
|
|
151
151
|
name: s,
|
|
152
152
|
formState: {
|
|
153
153
|
values: !0
|
|
154
154
|
},
|
|
155
155
|
exact: l,
|
|
156
156
|
callback: (f) => {
|
|
157
|
-
|
|
157
|
+
L(f.values);
|
|
158
158
|
}
|
|
159
|
-
})), [r, l, s,
|
|
160
|
-
const
|
|
159
|
+
})), [r, l, s, L]), b.useEffect(() => r._removeUnmounted());
|
|
160
|
+
const $ = g.current !== r, S = A.current, W = b.useMemo(() => {
|
|
161
161
|
if (i)
|
|
162
162
|
return null;
|
|
163
|
-
const f =
|
|
164
|
-
return
|
|
165
|
-
}, [i,
|
|
166
|
-
return
|
|
163
|
+
const f = !$ && !ee(S, s);
|
|
164
|
+
return $ || f ? w() : null;
|
|
165
|
+
}, [i, $, s, S, w]);
|
|
166
|
+
return W !== null ? W : P;
|
|
167
167
|
}
|
|
168
168
|
function rt(e) {
|
|
169
169
|
const t = _e(), { name: r, disabled: s, control: u = t.control, shouldUnregister: i, defaultValue: l, exact: c = !0 } = e, F = pr(u._names.array, r), h = b.useMemo(() => m(u._formValues, r, m(u._defaultValues, r, l)), [u, r, l]), V = Sr({
|
|
@@ -175,13 +175,13 @@ function rt(e) {
|
|
|
175
175
|
control: u,
|
|
176
176
|
name: r,
|
|
177
177
|
exact: c
|
|
178
|
-
}), A = b.useRef(e),
|
|
178
|
+
}), A = b.useRef(e), P = b.useRef(void 0), N = b.useRef(u.register(r, {
|
|
179
179
|
...e.rules,
|
|
180
180
|
value: V,
|
|
181
181
|
...K(e.disabled) ? { disabled: e.disabled } : {}
|
|
182
182
|
}));
|
|
183
183
|
A.current = e;
|
|
184
|
-
const
|
|
184
|
+
const w = b.useMemo(() => Object.defineProperties({}, {
|
|
185
185
|
invalid: {
|
|
186
186
|
enumerable: !0,
|
|
187
187
|
get: () => !!m(g.errors, r)
|
|
@@ -202,18 +202,18 @@ function rt(e) {
|
|
|
202
202
|
enumerable: !0,
|
|
203
203
|
get: () => m(g.errors, r)
|
|
204
204
|
}
|
|
205
|
-
}), [g, r]),
|
|
205
|
+
}), [g, r]), L = b.useCallback((f) => N.current.onChange({
|
|
206
206
|
target: {
|
|
207
207
|
value: Ar(f),
|
|
208
208
|
name: r
|
|
209
209
|
},
|
|
210
|
-
type:
|
|
211
|
-
}), [r]),
|
|
210
|
+
type: Fe.CHANGE
|
|
211
|
+
}), [r]), $ = b.useCallback(() => N.current.onBlur({
|
|
212
212
|
target: {
|
|
213
213
|
value: m(u._formValues, r),
|
|
214
214
|
name: r
|
|
215
215
|
},
|
|
216
|
-
type:
|
|
216
|
+
type: Fe.BLUR
|
|
217
217
|
}), [r, u._formValues]), S = b.useCallback((f) => {
|
|
218
218
|
const y = m(u._fields, r);
|
|
219
219
|
y && f && (y._f.ref = {
|
|
@@ -222,29 +222,29 @@ function rt(e) {
|
|
|
222
222
|
setCustomValidity: (x) => f.setCustomValidity(x),
|
|
223
223
|
reportValidity: () => f.reportValidity()
|
|
224
224
|
});
|
|
225
|
-
}, [u._fields, r]),
|
|
225
|
+
}, [u._fields, r]), W = b.useMemo(() => ({
|
|
226
226
|
name: r,
|
|
227
227
|
value: V,
|
|
228
228
|
...K(s) || g.disabled ? { disabled: g.disabled || s } : {},
|
|
229
|
-
onChange:
|
|
230
|
-
onBlur:
|
|
229
|
+
onChange: L,
|
|
230
|
+
onBlur: $,
|
|
231
231
|
ref: S
|
|
232
|
-
}), [r, s, g.disabled,
|
|
232
|
+
}), [r, s, g.disabled, L, $, S, V]);
|
|
233
233
|
return b.useEffect(() => {
|
|
234
|
-
const f = u._options.shouldUnregister || i, y =
|
|
234
|
+
const f = u._options.shouldUnregister || i, y = P.current;
|
|
235
235
|
y && y !== r && !F && u.unregister(y), u.register(r, {
|
|
236
236
|
...A.current.rules,
|
|
237
237
|
...K(A.current.disabled) ? { disabled: A.current.disabled } : {}
|
|
238
238
|
});
|
|
239
239
|
const x = (E, Z) => {
|
|
240
|
-
const
|
|
241
|
-
|
|
240
|
+
const H = m(u._fields, E);
|
|
241
|
+
H && H._f && (H._f.mount = Z);
|
|
242
242
|
};
|
|
243
243
|
if (x(r, !0), f) {
|
|
244
244
|
const E = U(m(u._options.defaultValues, r, A.current.defaultValue));
|
|
245
245
|
R(u._defaultValues, r, E), T(m(u._formValues, r)) && R(u._formValues, r, E);
|
|
246
246
|
}
|
|
247
|
-
return !F && u.register(r),
|
|
247
|
+
return !F && u.register(r), P.current = r, () => {
|
|
248
248
|
(F ? f && !u._state.action : f) ? u.unregister(r) : x(r, !1);
|
|
249
249
|
};
|
|
250
250
|
}, [r, u, F, i]), b.useEffect(() => {
|
|
@@ -253,10 +253,10 @@ function rt(e) {
|
|
|
253
253
|
name: r
|
|
254
254
|
});
|
|
255
255
|
}, [s, r, u]), b.useMemo(() => ({
|
|
256
|
-
field:
|
|
256
|
+
field: W,
|
|
257
257
|
formState: g,
|
|
258
|
-
fieldState:
|
|
259
|
-
}), [
|
|
258
|
+
fieldState: w
|
|
259
|
+
}), [W, g, w]);
|
|
260
260
|
}
|
|
261
261
|
const tt = (e) => e.render(rt(e));
|
|
262
262
|
var st = (e, t, r, s, u) => t ? {
|
|
@@ -290,14 +290,14 @@ function Er(e, t) {
|
|
|
290
290
|
for (const s in e)
|
|
291
291
|
if (e.hasOwnProperty(s)) {
|
|
292
292
|
const u = e[s], i = t[s];
|
|
293
|
-
if (u &&
|
|
293
|
+
if (u && B(u) && i) {
|
|
294
294
|
const l = Er(u, i);
|
|
295
|
-
|
|
295
|
+
B(l) && (r[s] = l);
|
|
296
296
|
} else e[s] && (r[s] = i);
|
|
297
297
|
}
|
|
298
298
|
return r;
|
|
299
299
|
}
|
|
300
|
-
var
|
|
300
|
+
var q = (e) => B(e) && !Object.keys(e).length, Je = (e) => e.type === "file", re = (e) => typeof e == "function", Ae = (e) => {
|
|
301
301
|
if (!ze)
|
|
302
302
|
return !1;
|
|
303
303
|
const t = e ? e.ownerDocument : 0;
|
|
@@ -316,9 +316,9 @@ function it(e) {
|
|
|
316
316
|
return !1;
|
|
317
317
|
return !0;
|
|
318
318
|
}
|
|
319
|
-
function
|
|
319
|
+
function I(e, t) {
|
|
320
320
|
const r = Array.isArray(t) ? t : xe(t) ? [t] : Ke(t), s = r.length === 1 ? e : nt(e, r), u = r.length - 1, i = r[u];
|
|
321
|
-
return s && delete s[i], u !== 0 && (
|
|
321
|
+
return s && delete s[i], u !== 0 && (B(s) && q(s) || Array.isArray(s) && it(s)) && I(e, r.slice(0, -1)), e;
|
|
322
322
|
}
|
|
323
323
|
var ut = (e) => {
|
|
324
324
|
for (const t in e)
|
|
@@ -327,7 +327,7 @@ var ut = (e) => {
|
|
|
327
327
|
return !1;
|
|
328
328
|
};
|
|
329
329
|
function kr(e) {
|
|
330
|
-
return Array.isArray(e) ||
|
|
330
|
+
return Array.isArray(e) || B(e) && !ut(e);
|
|
331
331
|
}
|
|
332
332
|
function je(e, t = {}) {
|
|
333
333
|
for (const r in e) {
|
|
@@ -390,7 +390,7 @@ var ot = (e, t, r, s) => {
|
|
|
390
390
|
fields: u,
|
|
391
391
|
shouldUseNativeValidation: s
|
|
392
392
|
};
|
|
393
|
-
}, pe = (e) => e instanceof RegExp, he = (e) => T(e) ? e : pe(e) ? e.source :
|
|
393
|
+
}, pe = (e) => e instanceof RegExp, he = (e) => T(e) ? e : pe(e) ? e.source : B(e) ? pe(e.value) ? e.value.source : e.value : e, ye = (e) => ({
|
|
394
394
|
isOnSubmit: !e || e === X.onSubmit,
|
|
395
395
|
isOnBlur: e === X.onBlur,
|
|
396
396
|
isOnChange: e === X.onChange,
|
|
@@ -398,7 +398,7 @@ var ot = (e, t, r, s) => {
|
|
|
398
398
|
isOnTouch: e === X.onTouched
|
|
399
399
|
});
|
|
400
400
|
const gr = "AsyncFunction";
|
|
401
|
-
var lt = (e) => !!e && !!e.validate && !!(re(e.validate) && e.validate.constructor.name === gr ||
|
|
401
|
+
var lt = (e) => !!e && !!e.validate && !!(re(e.validate) && e.validate.constructor.name === gr || B(e.validate) && Object.values(e.validate).find((t) => t.constructor.name === gr)), ct = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), Qe = (e, t, r) => !r && (t.watchAll || t.watch.has(e) || [...t.watch].some((s) => e.startsWith(s) && /^\.\w+/.test(e.slice(s.length))));
|
|
402
402
|
const me = (e, t, r, s) => {
|
|
403
403
|
for (const u of r || Object.keys(e)) {
|
|
404
404
|
const i = m(e, u);
|
|
@@ -411,7 +411,7 @@ const me = (e, t, r, s) => {
|
|
|
411
411
|
return !0;
|
|
412
412
|
if (me(c, t))
|
|
413
413
|
break;
|
|
414
|
-
} else if (
|
|
414
|
+
} else if (B(c) && me(c, t))
|
|
415
415
|
break;
|
|
416
416
|
}
|
|
417
417
|
}
|
|
@@ -447,8 +447,8 @@ function hr(e, t, r) {
|
|
|
447
447
|
var dt = (e, t, r, s) => {
|
|
448
448
|
r(e);
|
|
449
449
|
const { name: u, ...i } = e;
|
|
450
|
-
return
|
|
451
|
-
}, ft = (e, t, r) => !e || !t || e === t || z(e).some((s) => s && (r ? s === t : s.startsWith(t) || t.startsWith(s))), yt = (e, t, r, s, u) => u.isOnAll ? !1 : !r && u.isOnTouch ? !(t || e) : (r ? s.isOnBlur : u.isOnBlur) ? !e : (r ? s.isOnChange : u.isOnChange) ? e : !0, mt = (e, t) => !Se(m(e, t)).length &&
|
|
450
|
+
return q(i) || Object.keys(i).length >= Object.keys(t).length || Object.keys(i).find((l) => t[l] === (!s || X.all));
|
|
451
|
+
}, ft = (e, t, r) => !e || !t || e === t || z(e).some((s) => s && (r ? s === t : s.startsWith(t) || t.startsWith(s))), yt = (e, t, r, s, u) => u.isOnAll ? !1 : !r && u.isOnTouch ? !(t || e) : (r ? s.isOnBlur : u.isOnBlur) ? !e : (r ? s.isOnChange : u.isOnChange) ? e : !0, mt = (e, t) => !Se(m(e, t)).length && I(e, t), Or = (e, t, r) => {
|
|
452
452
|
const s = z(m(e, r));
|
|
453
453
|
return R(s, "root", t[r]), R(e, r, s), e;
|
|
454
454
|
};
|
|
@@ -460,55 +460,55 @@ function vr(e, t, r = "validate") {
|
|
|
460
460
|
ref: t
|
|
461
461
|
};
|
|
462
462
|
}
|
|
463
|
-
var de = (e) =>
|
|
463
|
+
var de = (e) => B(e) && !pe(e) ? e : {
|
|
464
464
|
value: e,
|
|
465
465
|
message: ""
|
|
466
466
|
}, Ge = async (e, t, r, s, u, i) => {
|
|
467
|
-
const { ref: l, refs: c, required: F, maxLength: h, minLength: V, min: g, max: A, pattern:
|
|
468
|
-
if (
|
|
467
|
+
const { ref: l, refs: c, required: F, maxLength: h, minLength: V, min: g, max: A, pattern: P, validate: N, name: w, valueAsNumber: L, mount: $ } = e._f, S = m(r, w);
|
|
468
|
+
if (!$ || t.has(w))
|
|
469
469
|
return {};
|
|
470
|
-
const
|
|
471
|
-
u &&
|
|
472
|
-
}, y = {}, x = Xe(l), E = ve(l), Z = x || E,
|
|
473
|
-
const se =
|
|
474
|
-
y[
|
|
475
|
-
type:
|
|
470
|
+
const W = c ? c[0] : l, f = (k) => {
|
|
471
|
+
u && W.reportValidity && (W.setCustomValidity(K(k) ? "" : k || ""), W.reportValidity());
|
|
472
|
+
}, y = {}, x = Xe(l), E = ve(l), Z = x || E, H = (L || Je(l)) && T(l.value) && T(S) || Ae(l) && l.value === "" || S === "" || Array.isArray(S) && !S.length, oe = st.bind(null, w, s, y), te = (k, D, M, j = ne.maxLength, Q = ne.minLength) => {
|
|
473
|
+
const se = k ? D : M;
|
|
474
|
+
y[w] = {
|
|
475
|
+
type: k ? j : Q,
|
|
476
476
|
message: se,
|
|
477
477
|
ref: l,
|
|
478
|
-
...oe(
|
|
478
|
+
...oe(k ? j : Q, se)
|
|
479
479
|
};
|
|
480
480
|
};
|
|
481
|
-
if (i ? !Array.isArray(S) || !S.length : F && (!Z && (
|
|
482
|
-
const { value:
|
|
483
|
-
if (
|
|
481
|
+
if (i ? !Array.isArray(S) || !S.length : F && (!Z && (H || G(S)) || K(S) && !S || E && !Cr(c).isValid || x && !Rr(c).isValid)) {
|
|
482
|
+
const { value: k, message: D } = Y(F) ? { value: !!F, message: F } : de(F);
|
|
483
|
+
if (k && (y[w] = {
|
|
484
484
|
type: ne.required,
|
|
485
485
|
message: D,
|
|
486
|
-
ref:
|
|
486
|
+
ref: W,
|
|
487
487
|
...oe(ne.required, D)
|
|
488
488
|
}, !s))
|
|
489
489
|
return f(D), y;
|
|
490
490
|
}
|
|
491
|
-
if (!
|
|
492
|
-
let
|
|
493
|
-
const
|
|
491
|
+
if (!H && (!G(g) || !G(A))) {
|
|
492
|
+
let k, D;
|
|
493
|
+
const M = de(A), j = de(g);
|
|
494
494
|
if (!G(S) && !isNaN(S)) {
|
|
495
495
|
const Q = l.valueAsNumber || S && +S;
|
|
496
|
-
G(
|
|
496
|
+
G(M.value) || (k = Q > M.value), G(j.value) || (D = Q < j.value);
|
|
497
497
|
} else {
|
|
498
498
|
const Q = l.valueAsDate || new Date(S), se = (Ve) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + Ve), ge = l.type == "time", ce = l.type == "week";
|
|
499
|
-
Y(
|
|
499
|
+
Y(M.value) && S && (k = ge ? se(S) > se(M.value) : ce ? S > M.value : Q > new Date(M.value)), Y(j.value) && S && (D = ge ? se(S) < se(j.value) : ce ? S < j.value : Q < new Date(j.value));
|
|
500
500
|
}
|
|
501
|
-
if ((
|
|
502
|
-
return f(y[
|
|
501
|
+
if ((k || D) && (te(!!k, M.message, j.message, ne.max, ne.min), !s))
|
|
502
|
+
return f(y[w].message), y;
|
|
503
503
|
}
|
|
504
|
-
if ((h || V) && !
|
|
505
|
-
const
|
|
506
|
-
if ((
|
|
507
|
-
return f(y[
|
|
504
|
+
if ((h || V) && !H && (Y(S) || i && Array.isArray(S))) {
|
|
505
|
+
const k = de(h), D = de(V), M = !G(k.value) && S.length > +k.value, j = !G(D.value) && S.length < +D.value;
|
|
506
|
+
if ((M || j) && (te(M, k.message, D.message), !s))
|
|
507
|
+
return f(y[w].message), y;
|
|
508
508
|
}
|
|
509
|
-
if (
|
|
510
|
-
const { value:
|
|
511
|
-
if (pe(
|
|
509
|
+
if (P && !H && Y(S)) {
|
|
510
|
+
const { value: k, message: D } = de(P);
|
|
511
|
+
if (pe(k) && !S.match(k) && (y[w] = {
|
|
512
512
|
type: ne.pattern,
|
|
513
513
|
message: D,
|
|
514
514
|
ref: l,
|
|
@@ -516,28 +516,28 @@ var de = (e) => M(e) && !pe(e) ? e : {
|
|
|
516
516
|
}, !s))
|
|
517
517
|
return f(D), y;
|
|
518
518
|
}
|
|
519
|
-
if (
|
|
520
|
-
if (re(
|
|
521
|
-
const
|
|
522
|
-
if (D && (y[
|
|
519
|
+
if (N) {
|
|
520
|
+
if (re(N)) {
|
|
521
|
+
const k = await N(S, r), D = vr(k, W);
|
|
522
|
+
if (D && (y[w] = {
|
|
523
523
|
...D,
|
|
524
524
|
...oe(ne.validate, D.message)
|
|
525
525
|
}, !s))
|
|
526
526
|
return f(D.message), y;
|
|
527
|
-
} else if (
|
|
528
|
-
let
|
|
529
|
-
for (const D in
|
|
530
|
-
if (
|
|
527
|
+
} else if (B(N)) {
|
|
528
|
+
let k = {};
|
|
529
|
+
for (const D in N) {
|
|
530
|
+
if (!q(k) && !s)
|
|
531
531
|
break;
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
...
|
|
535
|
-
...oe(D,
|
|
536
|
-
}, f(
|
|
532
|
+
const M = vr(await N[D](S, r), W, D);
|
|
533
|
+
M && (k = {
|
|
534
|
+
...M,
|
|
535
|
+
...oe(D, M.message)
|
|
536
|
+
}, f(M.message), s && (y[w] = k));
|
|
537
537
|
}
|
|
538
|
-
if (
|
|
539
|
-
ref:
|
|
540
|
-
...
|
|
538
|
+
if (!q(k) && (y[w] = {
|
|
539
|
+
ref: W,
|
|
540
|
+
...k
|
|
541
541
|
}, !s))
|
|
542
542
|
return y;
|
|
543
543
|
}
|
|
@@ -568,7 +568,7 @@ function gt(e = {}) {
|
|
|
568
568
|
validatingFields: {},
|
|
569
569
|
errors: t.errors || {},
|
|
570
570
|
disabled: t.disabled || !1
|
|
571
|
-
}, s = {}, u =
|
|
571
|
+
}, s = {}, u = B(t.defaultValues) || B(t.values) ? U(t.defaultValues || t.values) || {} : {}, i = t.shouldUnregister ? {} : U(u), l = {
|
|
572
572
|
action: !1,
|
|
573
573
|
mount: !1,
|
|
574
574
|
watch: !1
|
|
@@ -594,23 +594,23 @@ function gt(e = {}) {
|
|
|
594
594
|
const A = {
|
|
595
595
|
array: dr(),
|
|
596
596
|
state: dr()
|
|
597
|
-
},
|
|
597
|
+
}, P = t.criteriaMode === X.all, N = (a) => (n) => {
|
|
598
598
|
clearTimeout(h), h = setTimeout(a, n);
|
|
599
|
-
},
|
|
599
|
+
}, w = async (a) => {
|
|
600
600
|
if (!t.disabled && (V.isValid || g.isValid || a)) {
|
|
601
|
-
const n = t.resolver ?
|
|
601
|
+
const n = t.resolver ? q((await E()).errors) : await H(s, !0);
|
|
602
602
|
n !== r.isValid && A.state.next({
|
|
603
603
|
isValid: n
|
|
604
604
|
});
|
|
605
605
|
}
|
|
606
|
-
},
|
|
606
|
+
}, L = (a, n) => {
|
|
607
607
|
!t.disabled && (V.isValidating || V.validatingFields || g.isValidating || g.validatingFields) && ((a || Array.from(c.mount)).forEach((o) => {
|
|
608
|
-
o && (n ? R(r.validatingFields, o, n) :
|
|
608
|
+
o && (n ? R(r.validatingFields, o, n) : I(r.validatingFields, o));
|
|
609
609
|
}), A.state.next({
|
|
610
610
|
validatingFields: r.validatingFields,
|
|
611
|
-
isValidating:
|
|
611
|
+
isValidating: !q(r.validatingFields)
|
|
612
612
|
}));
|
|
613
|
-
},
|
|
613
|
+
}, $ = (a, n = [], o, v, _ = !0, d = !0) => {
|
|
614
614
|
if (v && o && !t.disabled) {
|
|
615
615
|
if (l.action = !0, d && Array.isArray(m(s, a))) {
|
|
616
616
|
const p = o(m(s, a), v.argA, v.argB);
|
|
@@ -637,7 +637,7 @@ function gt(e = {}) {
|
|
|
637
637
|
R(r.errors, a, n), A.state.next({
|
|
638
638
|
errors: r.errors
|
|
639
639
|
});
|
|
640
|
-
},
|
|
640
|
+
}, W = (a) => {
|
|
641
641
|
r.errors = a, A.state.next({
|
|
642
642
|
errors: r.errors,
|
|
643
643
|
isValid: !1
|
|
@@ -646,7 +646,7 @@ function gt(e = {}) {
|
|
|
646
646
|
const _ = m(s, a);
|
|
647
647
|
if (_) {
|
|
648
648
|
const d = m(i, a, T(o) ? m(u, a) : o);
|
|
649
|
-
T(d) || v && v.defaultChecked || n ? R(i, a, n ? d : _r(_._f)) :
|
|
649
|
+
T(d) || v && v.defaultChecked || n ? R(i, a, n ? d : _r(_._f)) : M(a, d), l.mount && !l.action && w();
|
|
650
650
|
}
|
|
651
651
|
}, y = (a, n, o, v, _) => {
|
|
652
652
|
let d = !1, p = !1;
|
|
@@ -657,7 +657,7 @@ function gt(e = {}) {
|
|
|
657
657
|
if (!o || v) {
|
|
658
658
|
(V.isDirty || g.isDirty) && (p = r.isDirty, r.isDirty = C.isDirty = te(), d = p !== C.isDirty);
|
|
659
659
|
const O = ee(m(u, a), n);
|
|
660
|
-
p = !!m(r.dirtyFields, a), O ?
|
|
660
|
+
p = !!m(r.dirtyFields, a), O ? I(r.dirtyFields, a) : R(r.dirtyFields, a, !0), C.dirtyFields = r.dirtyFields, d = d || (V.dirtyFields || g.dirtyFields) && p !== !O;
|
|
661
661
|
}
|
|
662
662
|
if (o) {
|
|
663
663
|
const O = m(r.touchedFields, a);
|
|
@@ -668,7 +668,7 @@ function gt(e = {}) {
|
|
|
668
668
|
return d ? C : {};
|
|
669
669
|
}, x = (a, n, o, v) => {
|
|
670
670
|
const _ = m(r.errors, a), d = (V.isValid || g.isValid) && K(n) && r.isValid !== n;
|
|
671
|
-
if (t.delayError && o ? (F =
|
|
671
|
+
if (t.delayError && o ? (F = N(() => S(a, o)), F(t.delayError)) : (clearTimeout(h), F = null, o ? R(r.errors, a, o) : I(r.errors, a)), (o ? !ee(_, o) : _) || !q(v) || d) {
|
|
672
672
|
const p = {
|
|
673
673
|
...v,
|
|
674
674
|
...d && K(n) ? { isValid: n } : {},
|
|
@@ -681,20 +681,20 @@ function gt(e = {}) {
|
|
|
681
681
|
}, A.state.next(p);
|
|
682
682
|
}
|
|
683
683
|
}, E = async (a) => {
|
|
684
|
-
|
|
684
|
+
L(a, !0);
|
|
685
685
|
const n = await t.resolver(i, t.context, ot(a || c.mount, s, t.criteriaMode, t.shouldUseNativeValidation));
|
|
686
|
-
return
|
|
686
|
+
return L(a), n;
|
|
687
687
|
}, Z = async (a) => {
|
|
688
688
|
const { errors: n } = await E(a);
|
|
689
689
|
if (a)
|
|
690
690
|
for (const o of a) {
|
|
691
691
|
const v = m(n, o);
|
|
692
|
-
v ? R(r.errors, o, v) :
|
|
692
|
+
v ? R(r.errors, o, v) : I(r.errors, o);
|
|
693
693
|
}
|
|
694
694
|
else
|
|
695
695
|
r.errors = n;
|
|
696
696
|
return n;
|
|
697
|
-
},
|
|
697
|
+
}, H = async (a, n, o = {
|
|
698
698
|
valid: !0
|
|
699
699
|
}) => {
|
|
700
700
|
for (const v in a) {
|
|
@@ -703,13 +703,13 @@ function gt(e = {}) {
|
|
|
703
703
|
const { _f: d, ...p } = _;
|
|
704
704
|
if (d) {
|
|
705
705
|
const C = c.array.has(d.name), O = _._f && lt(_._f);
|
|
706
|
-
O && V.validatingFields &&
|
|
707
|
-
const J = await Ge(_, c.disabled, i,
|
|
708
|
-
if (O && V.validatingFields &&
|
|
706
|
+
O && V.validatingFields && L([d.name], !0);
|
|
707
|
+
const J = await Ge(_, c.disabled, i, P, t.shouldUseNativeValidation && !n, C);
|
|
708
|
+
if (O && V.validatingFields && L([d.name]), J[d.name] && (o.valid = !1, n))
|
|
709
709
|
break;
|
|
710
|
-
!n && (m(J, d.name) ? C ? Or(r.errors, J, d.name) : R(r.errors, d.name, J[d.name]) :
|
|
710
|
+
!n && (m(J, d.name) ? C ? Or(r.errors, J, d.name) : R(r.errors, d.name, J[d.name]) : I(r.errors, d.name));
|
|
711
711
|
}
|
|
712
|
-
|
|
712
|
+
!q(p) && await H(p, n, o);
|
|
713
713
|
}
|
|
714
714
|
}
|
|
715
715
|
return o.valid;
|
|
@@ -719,9 +719,9 @@ function gt(e = {}) {
|
|
|
719
719
|
n && (n._f.refs ? n._f.refs.every((o) => !Oe(o)) : !Oe(n._f.ref)) && we(a);
|
|
720
720
|
}
|
|
721
721
|
c.unMount = /* @__PURE__ */ new Set();
|
|
722
|
-
}, te = (a, n) => !t.disabled && (a && n && R(i, a, n), !ee(Ve(), u)),
|
|
722
|
+
}, te = (a, n) => !t.disabled && (a && n && R(i, a, n), !ee(Ve(), u)), k = (a, n, o) => $e(a, c, {
|
|
723
723
|
...l.mount ? i : T(n) ? u : Y(a) ? { [a]: n } : n
|
|
724
|
-
}, o, n), D = (a) => Se(m(l.mount ? i : u, a, t.shouldUnregister ? m(u, a, []) : [])),
|
|
724
|
+
}, o, n), D = (a) => Se(m(l.mount ? i : u, a, t.shouldUnregister ? m(u, a, []) : [])), M = (a, n, o = {}) => {
|
|
725
725
|
const v = m(s, a);
|
|
726
726
|
let _ = n;
|
|
727
727
|
if (v) {
|
|
@@ -734,12 +734,12 @@ function gt(e = {}) {
|
|
|
734
734
|
})));
|
|
735
735
|
}
|
|
736
736
|
(o.shouldDirty || o.shouldTouch) && y(a, _, o.shouldTouch, o.shouldDirty, !0), o.shouldValidate && ce(a);
|
|
737
|
-
},
|
|
737
|
+
}, j = (a, n, o) => {
|
|
738
738
|
for (const v in n) {
|
|
739
739
|
if (!n.hasOwnProperty(v))
|
|
740
740
|
return;
|
|
741
741
|
const _ = n[v], d = a + "." + v, p = m(s, d);
|
|
742
|
-
(c.array.has(a) ||
|
|
742
|
+
(c.array.has(a) || B(_) || p && !p._f) && !le(_) ? j(d, _, o) : M(d, _, o);
|
|
743
743
|
}
|
|
744
744
|
}, Q = (a, n, o = {}) => {
|
|
745
745
|
const v = m(s, a), _ = c.array.has(a), d = U(n);
|
|
@@ -750,7 +750,7 @@ function gt(e = {}) {
|
|
|
750
750
|
name: a,
|
|
751
751
|
dirtyFields: fe(u, i),
|
|
752
752
|
isDirty: te(a, d)
|
|
753
|
-
})) : v && !v._f && !G(d) ?
|
|
753
|
+
})) : v && !v._f && !G(d) ? j(a, d, o) : M(a, d, o), Qe(a, c) && A.state.next({ ...r, name: a }), A.state.next({
|
|
754
754
|
name: l.mount ? a : void 0,
|
|
755
755
|
values: U(i)
|
|
756
756
|
});
|
|
@@ -763,23 +763,23 @@ function gt(e = {}) {
|
|
|
763
763
|
}, p = ye(t.mode), C = ye(t.reValidateMode);
|
|
764
764
|
if (_) {
|
|
765
765
|
let O, J;
|
|
766
|
-
const
|
|
767
|
-
R(i, o,
|
|
768
|
-
const Re = y(o,
|
|
766
|
+
const be = n.type ? _r(_._f) : Ar(a), ie = a.type === Fe.BLUR || a.type === Fe.FOCUS_OUT, Hr = !ct(_._f) && !t.resolver && !m(r.errors, o) && !_._f.deps || yt(ie, m(r.touchedFields, o), r.isSubmitted, C, p), De = Qe(o, c, ie);
|
|
767
|
+
R(i, o, be), ie ? (!n || !n.readOnly) && (_._f.onBlur && _._f.onBlur(a), F && F(0)) : _._f.onChange && _._f.onChange(a);
|
|
768
|
+
const Re = y(o, be, ie), $r = !q(Re) || De;
|
|
769
769
|
if (!ie && A.state.next({
|
|
770
770
|
name: o,
|
|
771
771
|
type: a.type,
|
|
772
772
|
values: U(i)
|
|
773
773
|
}), Hr)
|
|
774
|
-
return (V.isValid || g.isValid) && (t.mode === "onBlur" ? ie &&
|
|
774
|
+
return (V.isValid || g.isValid) && (t.mode === "onBlur" ? ie && w() : ie || w()), $r && A.state.next({ name: o, ...De ? {} : Re });
|
|
775
775
|
if (!ie && De && A.state.next({ ...r }), t.resolver) {
|
|
776
776
|
const { errors: or } = await E([o]);
|
|
777
|
-
if (d(
|
|
777
|
+
if (d(be), v) {
|
|
778
778
|
const qr = hr(r.errors, s, o), lr = hr(or, s, qr.name || o);
|
|
779
|
-
O = lr.error, o = lr.name, J =
|
|
779
|
+
O = lr.error, o = lr.name, J = q(or);
|
|
780
780
|
}
|
|
781
781
|
} else
|
|
782
|
-
|
|
782
|
+
L([o], !0), O = (await Ge(_, c.disabled, i, P, t.shouldUseNativeValidation))[o], L([o]), d(be), v && (O ? J = !1 : (V.isValid || g.isValid) && (J = await H(s, !0)));
|
|
783
783
|
v && (_._f.deps && (!Array.isArray(_._f.deps) || _._f.deps.length > 0) && ce(_._f.deps), x(o, J, O, Re));
|
|
784
784
|
}
|
|
785
785
|
}, ge = (a, n) => {
|
|
@@ -790,11 +790,11 @@ function gt(e = {}) {
|
|
|
790
790
|
const _ = z(a);
|
|
791
791
|
if (t.resolver) {
|
|
792
792
|
const d = await Z(T(a) ? a : _);
|
|
793
|
-
o =
|
|
793
|
+
o = q(d), v = a ? !_.some((p) => m(d, p)) : o;
|
|
794
794
|
} else a ? (v = (await Promise.all(_.map(async (d) => {
|
|
795
795
|
const p = m(s, d);
|
|
796
|
-
return await
|
|
797
|
-
}))).every(Boolean), !(!v && !r.isValid) &&
|
|
796
|
+
return await H(p && p._f ? { [d]: p } : p);
|
|
797
|
+
}))).every(Boolean), !(!v && !r.isValid) && w()) : v = o = await H(s);
|
|
798
798
|
return A.state.next({
|
|
799
799
|
...!Y(a) || (V.isValid || g.isValid) && o !== r.isValid ? {} : { name: a },
|
|
800
800
|
...t.resolver || !a ? { isValid: o } : {},
|
|
@@ -812,7 +812,7 @@ function gt(e = {}) {
|
|
|
812
812
|
isValidating: !!m(r.validatingFields, a),
|
|
813
813
|
isTouched: !!m((n || r).touchedFields, a)
|
|
814
814
|
}), Nr = (a) => {
|
|
815
|
-
a && z(a).forEach((n) =>
|
|
815
|
+
a && z(a).forEach((n) => I(r.errors, n)), A.state.next({
|
|
816
816
|
errors: a ? r.errors : {}
|
|
817
817
|
});
|
|
818
818
|
}, rr = (a, n, o) => {
|
|
@@ -827,8 +827,8 @@ function gt(e = {}) {
|
|
|
827
827
|
isValid: !1
|
|
828
828
|
}), o && o.shouldFocus && v && v.focus && v.focus();
|
|
829
829
|
}, Lr = (a, n) => re(a) ? A.state.subscribe({
|
|
830
|
-
next: (o) => "values" in o && a(
|
|
831
|
-
}) :
|
|
830
|
+
next: (o) => "values" in o && a(k(void 0, n), o)
|
|
831
|
+
}) : k(a, n, !0), tr = (a) => A.state.subscribe({
|
|
832
832
|
next: (n) => {
|
|
833
833
|
ft(a.name, n.name, a.exact) && dt(n, a.formState || V, Wr, a.reRenderRoot) && a.callback({
|
|
834
834
|
values: { ...i },
|
|
@@ -845,13 +845,13 @@ function gt(e = {}) {
|
|
|
845
845
|
formState: g
|
|
846
846
|
})), we = (a, n = {}) => {
|
|
847
847
|
for (const o of a ? z(a) : c.mount)
|
|
848
|
-
c.mount.delete(o), c.array.delete(o), n.keepValue || (
|
|
848
|
+
c.mount.delete(o), c.array.delete(o), n.keepValue || (I(s, o), I(i, o)), !n.keepError && I(r.errors, o), !n.keepDirty && I(r.dirtyFields, o), !n.keepTouched && I(r.touchedFields, o), !n.keepIsValidating && I(r.validatingFields, o), !t.shouldUnregister && !n.keepDefaultValue && I(u, o);
|
|
849
849
|
A.state.next({
|
|
850
850
|
values: U(i)
|
|
851
851
|
}), A.state.next({
|
|
852
852
|
...r,
|
|
853
853
|
...n.keepDirty ? { isDirty: te() } : {}
|
|
854
|
-
}), !n.keepIsValid &&
|
|
854
|
+
}), !n.keepIsValid && w();
|
|
855
855
|
}, sr = ({ disabled: a, name: n }) => {
|
|
856
856
|
(K(a) && l.mount || a || c.disabled.has(n)) && (a ? c.disabled.add(n) : c.disabled.delete(n));
|
|
857
857
|
}, ke = (a, n = {}) => {
|
|
@@ -921,11 +921,11 @@ function gt(e = {}) {
|
|
|
921
921
|
const { errors: d, values: p } = await E();
|
|
922
922
|
r.errors = d, _ = U(p);
|
|
923
923
|
} else
|
|
924
|
-
await
|
|
924
|
+
await H(s);
|
|
925
925
|
if (c.disabled.size)
|
|
926
926
|
for (const d of c.disabled)
|
|
927
|
-
|
|
928
|
-
if (
|
|
927
|
+
I(_, d);
|
|
928
|
+
if (I(r.errors, "root"), q(r.errors)) {
|
|
929
929
|
A.state.next({
|
|
930
930
|
errors: {}
|
|
931
931
|
});
|
|
@@ -939,15 +939,15 @@ function gt(e = {}) {
|
|
|
939
939
|
if (A.state.next({
|
|
940
940
|
isSubmitted: !0,
|
|
941
941
|
isSubmitting: !1,
|
|
942
|
-
isSubmitSuccessful:
|
|
942
|
+
isSubmitSuccessful: q(r.errors) && !v,
|
|
943
943
|
submitCount: r.submitCount + 1,
|
|
944
944
|
errors: r.errors
|
|
945
945
|
}), v)
|
|
946
946
|
throw v;
|
|
947
947
|
}, Br = (a, n = {}) => {
|
|
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 ||
|
|
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 || I(r.touchedFields, a), n.keepDirty || (I(r.dirtyFields, a), r.isDirty = n.defaultValue ? te(a, U(m(u, a))) : te()), n.keepError || (I(r.errors, a), V.isValid && w()), A.state.next({ ...r }));
|
|
949
949
|
}, nr = (a, n = {}) => {
|
|
950
|
-
const o = a ? U(a) : u, v = U(o), _ =
|
|
950
|
+
const o = a ? U(a) : u, v = U(o), _ = q(a), d = _ ? u : v;
|
|
951
951
|
if (n.keepDefaultValues || (u = o), !n.keepValues) {
|
|
952
952
|
if (n.keepDirtyValues) {
|
|
953
953
|
const p = /* @__PURE__ */ new Set([
|
|
@@ -991,7 +991,7 @@ function gt(e = {}) {
|
|
|
991
991
|
watch: /* @__PURE__ */ new Set(),
|
|
992
992
|
watchAll: !1,
|
|
993
993
|
focus: ""
|
|
994
|
-
}, l.mount = !V.isValid || !!n.keepIsValid || !!n.keepDirtyValues || !t.shouldUnregister &&
|
|
994
|
+
}, l.mount = !V.isValid || !!n.keepIsValid || !!n.keepDirtyValues || !t.shouldUnregister && !q(d), l.watch = !!t.shouldUnregister, l.action = !1, n.keepErrors || (r.errors = {}), A.state.next({
|
|
995
995
|
submitCount: n.keepSubmitCount ? r.submitCount : 0,
|
|
996
996
|
isDirty: _ ? !1 : n.keepDirty ? r.isDirty : !!(n.keepDefaultValues && !ee(a, u)),
|
|
997
997
|
isSubmitted: n.keepIsSubmitted ? r.isSubmitted : !1,
|
|
@@ -1023,12 +1023,12 @@ function gt(e = {}) {
|
|
|
1023
1023
|
_subscribe: tr,
|
|
1024
1024
|
_runSchema: E,
|
|
1025
1025
|
_focusError: Ce,
|
|
1026
|
-
_getWatch:
|
|
1026
|
+
_getWatch: k,
|
|
1027
1027
|
_getDirty: te,
|
|
1028
|
-
_setValid:
|
|
1029
|
-
_setFieldArray:
|
|
1028
|
+
_setValid: w,
|
|
1029
|
+
_setFieldArray: $,
|
|
1030
1030
|
_setDisabledField: sr,
|
|
1031
|
-
_setErrors:
|
|
1031
|
+
_setErrors: W,
|
|
1032
1032
|
_getFieldArray: D,
|
|
1033
1033
|
_reset: nr,
|
|
1034
1034
|
_resetDefaultValues: () => re(t.defaultValues) && t.defaultValues().then((a) => {
|
|
@@ -1145,29 +1145,29 @@ function vt(e) {
|
|
|
1145
1145
|
r._names.focus = Te(s, E.length - 1, y), h.current = Ue(h.current, x.map(ue)), g(E), F(E), r._setFieldArray(s, E, Ue, {
|
|
1146
1146
|
argA: Ne(f)
|
|
1147
1147
|
});
|
|
1148
|
-
},
|
|
1148
|
+
}, P = (f, y) => {
|
|
1149
1149
|
const x = z(U(f)), E = Ie(r._getFieldArray(s), x);
|
|
1150
1150
|
r._names.focus = Te(s, 0, y), h.current = Ie(h.current, x.map(ue)), g(E), F(E), r._setFieldArray(s, E, Ie, {
|
|
1151
1151
|
argA: Ne(f)
|
|
1152
1152
|
});
|
|
1153
|
-
},
|
|
1153
|
+
}, N = (f) => {
|
|
1154
1154
|
const y = Be(r._getFieldArray(s), f);
|
|
1155
1155
|
h.current = Be(h.current, f), g(y), F(y), !Array.isArray(m(r._fields, s)) && R(r._fields, s, void 0), r._setFieldArray(s, y, Be, {
|
|
1156
1156
|
argA: f
|
|
1157
1157
|
});
|
|
1158
|
-
},
|
|
1158
|
+
}, w = (f, y, x) => {
|
|
1159
1159
|
const E = z(U(y)), Z = Le(r._getFieldArray(s), f, E);
|
|
1160
1160
|
r._names.focus = Te(s, f, x), h.current = Le(h.current, f, E.map(ue)), g(Z), F(Z), r._setFieldArray(s, Z, Le, {
|
|
1161
1161
|
argA: f,
|
|
1162
1162
|
argB: Ne(y)
|
|
1163
1163
|
});
|
|
1164
|
-
},
|
|
1164
|
+
}, L = (f, y) => {
|
|
1165
1165
|
const x = r._getFieldArray(s);
|
|
1166
1166
|
Pe(x, f, y), Pe(h.current, f, y), g(x), F(x), r._setFieldArray(s, x, Pe, {
|
|
1167
1167
|
argA: f,
|
|
1168
1168
|
argB: y
|
|
1169
1169
|
}, !1);
|
|
1170
|
-
},
|
|
1170
|
+
}, $ = (f, y) => {
|
|
1171
1171
|
const x = r._getFieldArray(s);
|
|
1172
1172
|
Me(x, f, y), Me(h.current, f, y), g(x), F(x), r._setFieldArray(s, x, Me, {
|
|
1173
1173
|
argA: f,
|
|
@@ -1175,11 +1175,11 @@ function vt(e) {
|
|
|
1175
1175
|
}, !1);
|
|
1176
1176
|
}, S = (f, y) => {
|
|
1177
1177
|
const x = U(y), E = Vr(r._getFieldArray(s), f, x);
|
|
1178
|
-
h.current = [...E].map((Z,
|
|
1178
|
+
h.current = [...E].map((Z, H) => !Z || H === f ? ue() : h.current[H]), g(E), F([...E]), r._setFieldArray(s, E, Vr, {
|
|
1179
1179
|
argA: f,
|
|
1180
1180
|
argB: x
|
|
1181
1181
|
}, !0, !1);
|
|
1182
|
-
},
|
|
1182
|
+
}, W = (f) => {
|
|
1183
1183
|
const y = z(U(f));
|
|
1184
1184
|
h.current = y.map(ue), g([...y]), F([...y]), r._setFieldArray(s, [...y], (x) => x, {}, !0, !1);
|
|
1185
1185
|
};
|
|
@@ -1190,13 +1190,13 @@ function vt(e) {
|
|
|
1190
1190
|
if (r._options.resolver)
|
|
1191
1191
|
r._runSchema([s]).then((f) => {
|
|
1192
1192
|
const y = m(f.errors, s), x = m(r._formState.errors, s);
|
|
1193
|
-
(x ? !y && x.type || y && (x.type !== y.type || x.message !== y.message) : y && y.type) && (y ? R(r._formState.errors, s, y) :
|
|
1193
|
+
(x ? !y && x.type || y && (x.type !== y.type || x.message !== y.message) : y && y.type) && (y ? R(r._formState.errors, s, y) : I(r._formState.errors, s), r._subjects.state.next({
|
|
1194
1194
|
errors: r._formState.errors
|
|
1195
1195
|
}));
|
|
1196
1196
|
});
|
|
1197
1197
|
else {
|
|
1198
1198
|
const f = m(r._fields, s);
|
|
1199
|
-
f && f._f && !(ye(r._options.reValidateMode).isOnSubmit && ye(r._options.mode).isOnSubmit) && Ge(f, r._names.disabled, r._formValues, r._options.criteriaMode === X.all, r._options.shouldUseNativeValidation, !0).then((y) =>
|
|
1199
|
+
f && f._f && !(ye(r._options.reValidateMode).isOnSubmit && ye(r._options.mode).isOnSubmit) && Ge(f, r._names.disabled, r._formValues, r._options.criteriaMode === X.all, r._options.shouldUseNativeValidation, !0).then((y) => !q(y) && r._subjects.state.next({
|
|
1200
1200
|
errors: Or(r._formState.errors, y, s)
|
|
1201
1201
|
}));
|
|
1202
1202
|
}
|
|
@@ -1214,14 +1214,14 @@ function vt(e) {
|
|
|
1214
1214
|
};
|
|
1215
1215
|
r._options.shouldUnregister || i ? r.unregister(s) : f(s, !1);
|
|
1216
1216
|
}), [s, r, u, i]), {
|
|
1217
|
-
swap: b.useCallback(
|
|
1218
|
-
move: b.useCallback(
|
|
1219
|
-
prepend: b.useCallback(
|
|
1217
|
+
swap: b.useCallback(L, [g, s, r]),
|
|
1218
|
+
move: b.useCallback($, [g, s, r]),
|
|
1219
|
+
prepend: b.useCallback(P, [g, s, r]),
|
|
1220
1220
|
append: b.useCallback(A, [g, s, r]),
|
|
1221
|
-
remove: b.useCallback(
|
|
1222
|
-
insert: b.useCallback(
|
|
1221
|
+
remove: b.useCallback(N, [g, s, r]),
|
|
1222
|
+
insert: b.useCallback(w, [g, s, r]),
|
|
1223
1223
|
update: b.useCallback(S, [g, s, r]),
|
|
1224
|
-
replace: b.useCallback(
|
|
1224
|
+
replace: b.useCallback(W, [g, s, r]),
|
|
1225
1225
|
fields: b.useMemo(() => c.map((f, y) => ({
|
|
1226
1226
|
...f,
|
|
1227
1227
|
[u]: h.current[y] || ue()
|
|
@@ -1295,7 +1295,7 @@ function Vt(e = {}) {
|
|
|
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
|
}), t.current.formState = xr(s, i), t.current;
|
|
1297
1297
|
}
|
|
1298
|
-
const Tr = Qr(void 0),
|
|
1298
|
+
const Tr = Qr(void 0), bt = ({ showAsterisk: e, children: t }) => /* @__PURE__ */ ae(Tr.Provider, { value: { showAsterisk: e }, children: t }), Ft = () => {
|
|
1299
1299
|
const e = Gr(Tr);
|
|
1300
1300
|
if (!e)
|
|
1301
1301
|
throw new Error("useSuprFormContext must be used within a SuprFormProvider");
|
|
@@ -1356,7 +1356,7 @@ const Tr = Qr(void 0), Ft = ({ showAsterisk: e, children: t }) => /* @__PURE__ *
|
|
|
1356
1356
|
shouldFocusError: !0,
|
|
1357
1357
|
...i
|
|
1358
1358
|
});
|
|
1359
|
-
return
|
|
1359
|
+
return br(
|
|
1360
1360
|
c,
|
|
1361
1361
|
() => ({
|
|
1362
1362
|
setValue: h.setValue,
|
|
@@ -1377,7 +1377,7 @@ const Tr = Qr(void 0), Ft = ({ showAsterisk: e, children: t }) => /* @__PURE__ *
|
|
|
1377
1377
|
F == null || F(g);
|
|
1378
1378
|
});
|
|
1379
1379
|
return () => V.unsubscribe();
|
|
1380
|
-
}, [h.watch]), /* @__PURE__ */ ae(
|
|
1380
|
+
}, [h.watch]), /* @__PURE__ */ ae(bt, { showAsterisk: l, children: /* @__PURE__ */ ae(Zr, { ...h, children: /* @__PURE__ */ ae(
|
|
1381
1381
|
"form",
|
|
1382
1382
|
{
|
|
1383
1383
|
noValidate: !0,
|
|
@@ -1398,7 +1398,7 @@ const Tr = Qr(void 0), Ft = ({ showAsterisk: e, children: t }) => /* @__PURE__ *
|
|
|
1398
1398
|
shouldUnregister: c,
|
|
1399
1399
|
visibility: F
|
|
1400
1400
|
}) => {
|
|
1401
|
-
const { control: h } = _e(), V = e.props.value ?? "", { showAsterisk: g } =
|
|
1401
|
+
const { control: h } = _e(), V = e.props.value ?? "", { showAsterisk: g } = Ft(), A = e.props.onChange, P = e.props.onBlur, N = We(() => i || crypto.randomUUID(), []), w = /* @__PURE__ */ ae(
|
|
1402
1402
|
tt,
|
|
1403
1403
|
{
|
|
1404
1404
|
control: h,
|
|
@@ -1407,27 +1407,27 @@ const Tr = Qr(void 0), Ft = ({ showAsterisk: e, children: t }) => /* @__PURE__ *
|
|
|
1407
1407
|
defaultValue: V,
|
|
1408
1408
|
disabled: l,
|
|
1409
1409
|
shouldUnregister: c,
|
|
1410
|
-
render: ({ field: { name:
|
|
1410
|
+
render: ({ field: { name: L, onBlur: $, value: S, onChange: W, ref: f }, fieldState: { error: y } }) => /* @__PURE__ */ cr(
|
|
1411
1411
|
"div",
|
|
1412
1412
|
{
|
|
1413
1413
|
className: `controlled-field ${s}`,
|
|
1414
1414
|
style: { display: "flex", flexDirection: "column", gap: "5px" },
|
|
1415
1415
|
children: [
|
|
1416
|
-
u && /* @__PURE__ */ cr("label", { htmlFor:
|
|
1416
|
+
u && /* @__PURE__ */ cr("label", { htmlFor: N, className: "controlled-field-label", children: [
|
|
1417
1417
|
u,
|
|
1418
1418
|
g && !!r && /* @__PURE__ */ ae("span", { style: { color: "red" }, children: " *" })
|
|
1419
1419
|
] }),
|
|
1420
1420
|
He(e, {
|
|
1421
1421
|
...e.props,
|
|
1422
|
-
id:
|
|
1423
|
-
name:
|
|
1422
|
+
id: N,
|
|
1423
|
+
name: L,
|
|
1424
1424
|
disabled: l,
|
|
1425
1425
|
onChange: (...x) => {
|
|
1426
|
-
|
|
1426
|
+
W(...x), A == null || A(...x);
|
|
1427
1427
|
},
|
|
1428
1428
|
value: S,
|
|
1429
1429
|
onBlur: (...x) => {
|
|
1430
|
-
|
|
1430
|
+
$(), P == null || P(...x);
|
|
1431
1431
|
},
|
|
1432
1432
|
ref: f
|
|
1433
1433
|
}),
|
|
@@ -1437,40 +1437,54 @@ const Tr = Qr(void 0), Ft = ({ showAsterisk: e, children: t }) => /* @__PURE__ *
|
|
|
1437
1437
|
)
|
|
1438
1438
|
}
|
|
1439
1439
|
);
|
|
1440
|
-
return F ? /* @__PURE__ */ ae(At, { visibility: F, children:
|
|
1441
|
-
}, pt = ({
|
|
1442
|
-
|
|
1440
|
+
return F ? /* @__PURE__ */ ae(At, { visibility: F, children: w }) : w;
|
|
1441
|
+
}, pt = ({
|
|
1442
|
+
name: e,
|
|
1443
|
+
rules: t,
|
|
1444
|
+
ref: r,
|
|
1445
|
+
children: s,
|
|
1446
|
+
visibility: u
|
|
1447
|
+
}) => {
|
|
1448
|
+
const i = vt({
|
|
1443
1449
|
name: e,
|
|
1444
1450
|
rules: t
|
|
1445
1451
|
});
|
|
1446
|
-
|
|
1447
|
-
const
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1452
|
+
br(r, () => i, [i]);
|
|
1453
|
+
const l = (c, F) => Kr.map(c, (h) => {
|
|
1454
|
+
var P;
|
|
1455
|
+
if (!Yr(h))
|
|
1456
|
+
return h;
|
|
1457
|
+
const V = h.props, g = h.type;
|
|
1458
|
+
if (((g == null ? void 0 : g.displayName) === "SuprFormControl" || g === Ze || V.name !== void 0 && typeof g != "string") && V.name !== void 0) {
|
|
1459
|
+
const N = u ? u[V.name] : void 0, w = N ? {
|
|
1460
|
+
...N,
|
|
1461
|
+
conditions: ((P = N.conditions) == null ? void 0 : P.map(($) => ({
|
|
1462
|
+
...$,
|
|
1463
|
+
name: `${F}${$.name}`
|
|
1464
|
+
}))) || []
|
|
1465
|
+
} : void 0, L = {
|
|
1466
|
+
...V,
|
|
1467
|
+
name: `${F}${V.name}`,
|
|
1468
|
+
visibility: w
|
|
1455
1469
|
};
|
|
1456
|
-
return
|
|
1470
|
+
return V.id !== void 0 && (L.id = `${F}${V.id}`), He(h, L);
|
|
1457
1471
|
}
|
|
1458
|
-
return
|
|
1459
|
-
...
|
|
1460
|
-
children:
|
|
1461
|
-
}) :
|
|
1472
|
+
return V.children ? He(h, {
|
|
1473
|
+
...V,
|
|
1474
|
+
children: l(V.children, F)
|
|
1475
|
+
}) : h;
|
|
1462
1476
|
});
|
|
1463
|
-
return /* @__PURE__ */ ae(jr, { children:
|
|
1464
|
-
const
|
|
1477
|
+
return /* @__PURE__ */ ae(jr, { children: i.fields.map((c, F) => {
|
|
1478
|
+
const h = `${e}.${F}.`;
|
|
1465
1479
|
return /* @__PURE__ */ ae(
|
|
1466
1480
|
"div",
|
|
1467
1481
|
{
|
|
1468
|
-
"data-index":
|
|
1482
|
+
"data-index": F,
|
|
1469
1483
|
style: { display: "contents" },
|
|
1470
1484
|
id: "field-array-item",
|
|
1471
|
-
children:
|
|
1485
|
+
children: l(s, h)
|
|
1472
1486
|
},
|
|
1473
|
-
|
|
1487
|
+
h
|
|
1474
1488
|
);
|
|
1475
1489
|
}) });
|
|
1476
1490
|
};
|