autoforma 2.0.0 → 2.2.0
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/autoform/context/AutoFormRenderContext.d.ts +5 -5
- package/dist/autoform/context/useAutoFormRenderContext.d.ts +1 -1
- package/dist/autoform/core/AutoForm.d.ts +1 -1
- package/dist/autoform/fields/DefaultInput.d.ts +1 -1
- package/dist/autoform/fields/DefaultSelect.d.ts +1 -1
- package/dist/autoform/layouts/FieldLayout.d.ts +1 -1
- package/dist/autoform/render/FieldRenderer.d.ts +1 -1
- package/dist/autoform/render/UnWatchedField.d.ts +1 -1
- package/dist/autoform/render/WatchedField.d.ts +1 -1
- package/dist/autoform/render/Watcher.d.ts +1 -1
- package/dist/autoform/types.d.ts +25 -23
- package/dist/autoform/utils/generateInitialValues.d.ts +1 -1
- package/dist/autoform/utils/getDefaultValueForField.d.ts +1 -1
- package/dist/autoform/utils/makeSchemaReadOnly.d.ts +1 -1
- package/dist/autoform/utils/renderSchema.d.ts +1 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +365 -349
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import V, { useMemo as
|
|
1
|
+
import V, { useMemo as Oe, createContext as Zr, useContext as Qr, useState as Kr, useEffect as Pe, useRef as et, useImperativeHandle as rt } from "react";
|
|
2
2
|
var je = { exports: {} }, Re = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
@@ -9,10 +9,10 @@ var je = { exports: {} }, Re = {};
|
|
|
9
9
|
* This source code is licensed under the MIT license found in the
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/
|
|
12
|
-
var
|
|
12
|
+
var gr;
|
|
13
13
|
function tt() {
|
|
14
|
-
if (
|
|
15
|
-
|
|
14
|
+
if (gr) return Re;
|
|
15
|
+
gr = 1;
|
|
16
16
|
var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
|
|
17
17
|
function r(s, o, a) {
|
|
18
18
|
var l = null;
|
|
@@ -41,16 +41,16 @@ var Se = {};
|
|
|
41
41
|
* This source code is licensed under the MIT license found in the
|
|
42
42
|
* LICENSE file in the root directory of this source tree.
|
|
43
43
|
*/
|
|
44
|
-
var
|
|
44
|
+
var hr;
|
|
45
45
|
function st() {
|
|
46
|
-
return
|
|
46
|
+
return hr || (hr = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
47
47
|
function e(c) {
|
|
48
48
|
if (c == null) return null;
|
|
49
49
|
if (typeof c == "function")
|
|
50
50
|
return c.$$typeof === be ? null : c.displayName || c.name || null;
|
|
51
51
|
if (typeof c == "string") return c;
|
|
52
52
|
switch (c) {
|
|
53
|
-
case
|
|
53
|
+
case W:
|
|
54
54
|
return "Fragment";
|
|
55
55
|
case w:
|
|
56
56
|
return "Profiler";
|
|
@@ -67,11 +67,11 @@ function st() {
|
|
|
67
67
|
switch (typeof c.tag == "number" && console.error(
|
|
68
68
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
69
|
), c.$$typeof) {
|
|
70
|
-
case
|
|
70
|
+
case $:
|
|
71
71
|
return "Portal";
|
|
72
72
|
case _:
|
|
73
73
|
return c.displayName || "Context";
|
|
74
|
-
case
|
|
74
|
+
case D:
|
|
75
75
|
return (c._context.displayName || "Context") + ".Consumer";
|
|
76
76
|
case m:
|
|
77
77
|
var E = c.render;
|
|
@@ -108,7 +108,7 @@ function st() {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
function s(c) {
|
|
111
|
-
if (c ===
|
|
111
|
+
if (c === W) return "<>";
|
|
112
112
|
if (typeof c == "object" && c !== null && c.$$typeof === se)
|
|
113
113
|
return "<...>";
|
|
114
114
|
try {
|
|
@@ -153,7 +153,7 @@ function st() {
|
|
|
153
153
|
function p(c, E, L, Y, xe, pe) {
|
|
154
154
|
var z = L.ref;
|
|
155
155
|
return c = {
|
|
156
|
-
$$typeof:
|
|
156
|
+
$$typeof: M,
|
|
157
157
|
type: c,
|
|
158
158
|
key: E,
|
|
159
159
|
props: L,
|
|
@@ -235,21 +235,21 @@ React keys must be passed directly to JSX without using spread:
|
|
|
235
235
|
R(c) ? c._store && (c._store.validated = 1) : typeof c == "object" && c !== null && c.$$typeof === se && (c._payload.status === "fulfilled" ? R(c._payload.value) && c._payload.value._store && (c._payload.value._store.validated = 1) : c._store && (c._store.validated = 1));
|
|
236
236
|
}
|
|
237
237
|
function R(c) {
|
|
238
|
-
return typeof c == "object" && c !== null && c.$$typeof ===
|
|
238
|
+
return typeof c == "object" && c !== null && c.$$typeof === M;
|
|
239
239
|
}
|
|
240
|
-
var
|
|
240
|
+
var h = V, M = Symbol.for("react.transitional.element"), $ = Symbol.for("react.portal"), W = Symbol.for("react.fragment"), B = Symbol.for("react.strict_mode"), w = Symbol.for("react.profiler"), D = Symbol.for("react.consumer"), _ = Symbol.for("react.context"), m = Symbol.for("react.forward_ref"), F = Symbol.for("react.suspense"), C = Symbol.for("react.suspense_list"), Q = Symbol.for("react.memo"), se = Symbol.for("react.lazy"), K = Symbol.for("react.activity"), be = Symbol.for("react.client.reference"), k = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, S = Object.prototype.hasOwnProperty, q = Array.isArray, J = console.createTask ? console.createTask : function() {
|
|
241
241
|
return null;
|
|
242
242
|
};
|
|
243
|
-
|
|
243
|
+
h = {
|
|
244
244
|
react_stack_bottom_frame: function(c) {
|
|
245
245
|
return c();
|
|
246
246
|
}
|
|
247
247
|
};
|
|
248
|
-
var ee, X = {}, fe =
|
|
249
|
-
|
|
248
|
+
var ee, X = {}, fe = h.react_stack_bottom_frame.bind(
|
|
249
|
+
h,
|
|
250
250
|
a
|
|
251
251
|
)(), ye = J(s(a)), me = {};
|
|
252
|
-
Se.Fragment =
|
|
252
|
+
Se.Fragment = W, Se.jsx = function(c, E, L) {
|
|
253
253
|
var Y = 1e4 > k.recentlyCreatedOwnerStacks++;
|
|
254
254
|
return I(
|
|
255
255
|
c,
|
|
@@ -276,13 +276,13 @@ var br;
|
|
|
276
276
|
function nt() {
|
|
277
277
|
return br || (br = 1, process.env.NODE_ENV === "production" ? je.exports = tt() : je.exports = st()), je.exports;
|
|
278
278
|
}
|
|
279
|
-
var
|
|
280
|
-
const
|
|
281
|
-
var G = (e) => !re(e) && !Array.isArray(e) &&
|
|
279
|
+
var T = nt(), De = (e) => e.type === "checkbox", he = (e) => e instanceof Date, re = (e) => e == null;
|
|
280
|
+
const Tr = (e) => typeof e == "object";
|
|
281
|
+
var G = (e) => !re(e) && !Array.isArray(e) && Tr(e) && !he(e), at = (e) => G(e) && e.target ? De(e.target) ? e.target.checked : e.target.value : e, it = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, ot = (e, t) => e.has(it(t)), ut = (e) => {
|
|
282
282
|
const t = e.constructor && e.constructor.prototype;
|
|
283
283
|
return G(t) && t.hasOwnProperty("isPrototypeOf");
|
|
284
284
|
}, nr = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
285
|
-
function
|
|
285
|
+
function U(e) {
|
|
286
286
|
if (e instanceof Date)
|
|
287
287
|
return new Date(e);
|
|
288
288
|
const t = typeof FileList < "u" && e instanceof FileList;
|
|
@@ -293,17 +293,17 @@ function M(e) {
|
|
|
293
293
|
return e;
|
|
294
294
|
const s = r ? [] : Object.create(Object.getPrototypeOf(e));
|
|
295
295
|
for (const o in e)
|
|
296
|
-
Object.prototype.hasOwnProperty.call(e, o) && (s[o] =
|
|
296
|
+
Object.prototype.hasOwnProperty.call(e, o) && (s[o] = U(e[o]));
|
|
297
297
|
return s;
|
|
298
298
|
}
|
|
299
|
-
var
|
|
299
|
+
var Ue = (e) => /^\w*$/.test(e), N = (e) => e === void 0, Me = (e) => Array.isArray(e) ? e.filter(Boolean) : [], ar = (e) => Me(e.replace(/["|']|\]/g, "").split(/\.|\[/)), g = (e, t, r) => {
|
|
300
300
|
if (!t || !G(e))
|
|
301
301
|
return r;
|
|
302
|
-
const s = (
|
|
302
|
+
const s = (Ue(t) ? [t] : ar(t)).reduce((o, a) => re(o) ? o : o[a], e);
|
|
303
303
|
return N(s) || s === e ? N(e[t]) ? r : e[t] : s;
|
|
304
304
|
}, ce = (e) => typeof e == "boolean", oe = (e) => typeof e == "function", P = (e, t, r) => {
|
|
305
305
|
let s = -1;
|
|
306
|
-
const o =
|
|
306
|
+
const o = Ue(t) ? [t] : ar(t), a = o.length, l = a - 1;
|
|
307
307
|
for (; ++s < a; ) {
|
|
308
308
|
const d = o[s];
|
|
309
309
|
let A = r;
|
|
@@ -335,7 +335,7 @@ const xr = {
|
|
|
335
335
|
validate: "validate"
|
|
336
336
|
}, ir = V.createContext(null);
|
|
337
337
|
ir.displayName = "HookFormContext";
|
|
338
|
-
const
|
|
338
|
+
const ge = () => V.useContext(ir), lt = (e) => {
|
|
339
339
|
const { children: t, ...r } = e;
|
|
340
340
|
return V.createElement(ir.Provider, { value: r }, t);
|
|
341
341
|
};
|
|
@@ -353,11 +353,11 @@ var ct = (e, t, r, s = !0) => {
|
|
|
353
353
|
return o;
|
|
354
354
|
};
|
|
355
355
|
const or = typeof window < "u" ? V.useLayoutEffect : V.useEffect;
|
|
356
|
-
var ne = (e) => typeof e == "string", Ke = (e, t, r, s, o) => ne(e) ? (s && t.watch.add(e),
|
|
356
|
+
var ne = (e) => typeof e == "string", Ke = (e, t, r, s, o) => ne(e) ? (s && t.watch.add(e), g(r, e, o)) : Array.isArray(e) ? e.map((a) => (s && t.watch.add(a), g(r, a))) : (s && (t.watchAll = !0), r), er = (e) => re(e) || !Tr(e);
|
|
357
357
|
function ue(e, t, r = /* @__PURE__ */ new WeakSet()) {
|
|
358
358
|
if (er(e) || er(t))
|
|
359
359
|
return Object.is(e, t);
|
|
360
|
-
if (
|
|
360
|
+
if (he(e) && he(t))
|
|
361
361
|
return e.getTime() === t.getTime();
|
|
362
362
|
const s = Object.keys(e), o = Object.keys(t);
|
|
363
363
|
if (s.length !== o.length)
|
|
@@ -371,48 +371,48 @@ function ue(e, t, r = /* @__PURE__ */ new WeakSet()) {
|
|
|
371
371
|
return !1;
|
|
372
372
|
if (a !== "ref") {
|
|
373
373
|
const d = t[a];
|
|
374
|
-
if (
|
|
374
|
+
if (he(l) && he(d) || G(l) && G(d) || Array.isArray(l) && Array.isArray(d) ? !ue(l, d, r) : !Object.is(l, d))
|
|
375
375
|
return !1;
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
return !0;
|
|
379
379
|
}
|
|
380
|
-
function
|
|
381
|
-
const t =
|
|
380
|
+
function Or(e) {
|
|
381
|
+
const t = ge(), { control: r = t.control, name: s, defaultValue: o, disabled: a, exact: l, compute: d } = e || {}, A = V.useRef(o), p = V.useRef(d), I = V.useRef(void 0), x = V.useRef(r), R = V.useRef(s);
|
|
382
382
|
p.current = d;
|
|
383
|
-
const [
|
|
383
|
+
const [h, M] = V.useState(() => {
|
|
384
384
|
const _ = r._getWatch(s, A.current);
|
|
385
385
|
return p.current ? p.current(_) : _;
|
|
386
|
-
}),
|
|
386
|
+
}), $ = V.useCallback((_) => {
|
|
387
387
|
const m = Ke(s, r._names, _ || r._formValues, !1, A.current);
|
|
388
388
|
return p.current ? p.current(m) : m;
|
|
389
|
-
}, [r._formValues, r._names, s]),
|
|
389
|
+
}, [r._formValues, r._names, s]), W = V.useCallback((_) => {
|
|
390
390
|
if (!a) {
|
|
391
391
|
const m = Ke(s, r._names, _ || r._formValues, !1, A.current);
|
|
392
392
|
if (p.current) {
|
|
393
393
|
const F = p.current(m);
|
|
394
|
-
ue(F, I.current) || (
|
|
394
|
+
ue(F, I.current) || (M(F), I.current = F);
|
|
395
395
|
} else
|
|
396
|
-
|
|
396
|
+
M(m);
|
|
397
397
|
}
|
|
398
398
|
}, [r._formValues, r._names, a, s]);
|
|
399
|
-
or(() => ((x.current !== r || !ue(R.current, s)) && (x.current = r, R.current = s,
|
|
399
|
+
or(() => ((x.current !== r || !ue(R.current, s)) && (x.current = r, R.current = s, W()), r._subscribe({
|
|
400
400
|
name: s,
|
|
401
401
|
formState: {
|
|
402
402
|
values: !0
|
|
403
403
|
},
|
|
404
404
|
exact: l,
|
|
405
405
|
callback: (_) => {
|
|
406
|
-
|
|
406
|
+
W(_.values);
|
|
407
407
|
}
|
|
408
|
-
})), [r, l, s,
|
|
409
|
-
const B = x.current !== r, w = R.current,
|
|
408
|
+
})), [r, l, s, W]), V.useEffect(() => r._removeUnmounted());
|
|
409
|
+
const B = x.current !== r, w = R.current, D = V.useMemo(() => {
|
|
410
410
|
if (a)
|
|
411
411
|
return null;
|
|
412
412
|
const _ = !B && !ue(w, s);
|
|
413
|
-
return B || _ ?
|
|
414
|
-
}, [a, B, s, w,
|
|
415
|
-
return
|
|
413
|
+
return B || _ ? $() : null;
|
|
414
|
+
}, [a, B, s, w, $]);
|
|
415
|
+
return D !== null ? D : h;
|
|
416
416
|
}
|
|
417
417
|
var dt = (e, t, r, s, o) => t ? {
|
|
418
418
|
...r[e],
|
|
@@ -472,7 +472,7 @@ function mt(e) {
|
|
|
472
472
|
return !0;
|
|
473
473
|
}
|
|
474
474
|
function H(e, t) {
|
|
475
|
-
const r = Array.isArray(t) ? t :
|
|
475
|
+
const r = Array.isArray(t) ? t : Ue(t) ? [t] : ar(t), s = r.length === 1 ? e : yt(e, r), o = r.length - 1, a = r[o];
|
|
476
476
|
return s && delete s[a], o !== 0 && (G(s) && Z(s) || Array.isArray(s) && mt(s)) && H(e, r.slice(0, -1)), e;
|
|
477
477
|
}
|
|
478
478
|
var _t = (e) => {
|
|
@@ -536,7 +536,7 @@ function Er(e) {
|
|
|
536
536
|
var vt = (e, t, r, s) => {
|
|
537
537
|
const o = {};
|
|
538
538
|
for (const a of e) {
|
|
539
|
-
const l =
|
|
539
|
+
const l = g(t, a);
|
|
540
540
|
l && P(o, a, l._f);
|
|
541
541
|
}
|
|
542
542
|
return {
|
|
@@ -545,7 +545,7 @@ var vt = (e, t, r, s) => {
|
|
|
545
545
|
fields: o,
|
|
546
546
|
shouldUseNativeValidation: s
|
|
547
547
|
};
|
|
548
|
-
}, Ie = (e) => e instanceof RegExp,
|
|
548
|
+
}, Ie = (e) => e instanceof RegExp, Te = (e) => N(e) ? e : Ie(e) ? e.source : G(e) ? Ie(e.value) ? e.value.source : e.value : e, Ee = (e) => ({
|
|
549
549
|
isOnSubmit: !e || e === ie.onSubmit,
|
|
550
550
|
isOnBlur: e === ie.onBlur,
|
|
551
551
|
isOnChange: e === ie.onChange,
|
|
@@ -553,10 +553,10 @@ var vt = (e, t, r, s) => {
|
|
|
553
553
|
isOnTouch: e === ie.onTouched
|
|
554
554
|
});
|
|
555
555
|
const wr = "AsyncFunction";
|
|
556
|
-
var
|
|
556
|
+
var gt = (e) => !!e && !!e.validate && !!(oe(e.validate) && e.validate.constructor.name === wr || G(e.validate) && Object.values(e.validate).find((t) => t.constructor.name === wr)), ht = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), tr = (e, t, r) => !r && (t.watchAll || t.watch.has(e) || [...t.watch].some((s) => e.startsWith(s) && /^\.\w+/.test(e.slice(s.length))));
|
|
557
557
|
const we = (e, t, r, s) => {
|
|
558
558
|
for (const o of r || Object.keys(e)) {
|
|
559
|
-
const a =
|
|
559
|
+
const a = g(e, o);
|
|
560
560
|
if (a) {
|
|
561
561
|
const { _f: l, ...d } = a;
|
|
562
562
|
if (l) {
|
|
@@ -572,15 +572,15 @@ const we = (e, t, r, s) => {
|
|
|
572
572
|
}
|
|
573
573
|
};
|
|
574
574
|
function kr(e, t, r) {
|
|
575
|
-
const s =
|
|
576
|
-
if (s ||
|
|
575
|
+
const s = g(e, r);
|
|
576
|
+
if (s || Ue(r))
|
|
577
577
|
return {
|
|
578
578
|
error: s,
|
|
579
579
|
name: r
|
|
580
580
|
};
|
|
581
581
|
const o = r.split(".");
|
|
582
582
|
for (; o.length; ) {
|
|
583
|
-
const a = o.join("."), l =
|
|
583
|
+
const a = o.join("."), l = g(t, a), d = g(e, a);
|
|
584
584
|
if (l && !Array.isArray(l) && r !== a)
|
|
585
585
|
return { name: r };
|
|
586
586
|
if (d && d.type)
|
|
@@ -603,8 +603,8 @@ var bt = (e, t, r, s) => {
|
|
|
603
603
|
r(e);
|
|
604
604
|
const { name: o, ...a } = e;
|
|
605
605
|
return Z(a) || Object.keys(a).length >= Object.keys(t).length || Object.keys(a).find((l) => t[l] === (!s || ie.all));
|
|
606
|
-
}, xt = (e, t, r) => !e || !t || e === t || te(e).some((s) => s && (r ? s === t : s.startsWith(t) || t.startsWith(s))), pt = (e, t, r, s, o) => o.isOnAll ? !1 : !r && o.isOnTouch ? !(t || e) : (r ? s.isOnBlur : o.isOnBlur) ? !e : (r ? s.isOnChange : o.isOnChange) ? e : !0, At = (e, t) => !
|
|
607
|
-
const s = te(
|
|
606
|
+
}, xt = (e, t, r) => !e || !t || e === t || te(e).some((s) => s && (r ? s === t : s.startsWith(t) || t.startsWith(s))), pt = (e, t, r, s, o) => o.isOnAll ? !1 : !r && o.isOnTouch ? !(t || e) : (r ? s.isOnBlur : o.isOnBlur) ? !e : (r ? s.isOnChange : o.isOnChange) ? e : !0, At = (e, t) => !Me(g(e, t)).length && H(e, t), Lr = (e, t, r) => {
|
|
607
|
+
const s = te(g(e, r));
|
|
608
608
|
return P(s, "root", t[r]), P(e, r, s), e;
|
|
609
609
|
};
|
|
610
610
|
function Rr(e, t, r = "validate") {
|
|
@@ -619,14 +619,14 @@ var Fe = (e) => G(e) && !Ie(e) ? e : {
|
|
|
619
619
|
value: e,
|
|
620
620
|
message: ""
|
|
621
621
|
}, sr = async (e, t, r, s, o, a) => {
|
|
622
|
-
const { ref: l, refs: d, required: A, maxLength: p, minLength: I, min: x, max: R, pattern:
|
|
623
|
-
if (!B || t.has(
|
|
622
|
+
const { ref: l, refs: d, required: A, maxLength: p, minLength: I, min: x, max: R, pattern: h, validate: M, name: $, valueAsNumber: W, mount: B } = e._f, w = g(r, $);
|
|
623
|
+
if (!B || t.has($))
|
|
624
624
|
return {};
|
|
625
|
-
const
|
|
626
|
-
o &&
|
|
627
|
-
}, m = {}, F = lr(l), C = De(l), Q = F || C, se = (
|
|
625
|
+
const D = d ? d[0] : l, _ = (k) => {
|
|
626
|
+
o && D.reportValidity && (D.setCustomValidity(ce(k) ? "" : k || ""), D.reportValidity());
|
|
627
|
+
}, m = {}, F = lr(l), C = De(l), Q = F || C, se = (W || ur(l)) && N(l.value) && N(w) || Ne(l) && l.value === "" || w === "" || Array.isArray(w) && !w.length, K = dt.bind(null, $, s, m), be = (k, S, q, J = de.maxLength, ee = de.minLength) => {
|
|
628
628
|
const X = k ? S : q;
|
|
629
|
-
m[
|
|
629
|
+
m[$] = {
|
|
630
630
|
type: k ? J : ee,
|
|
631
631
|
message: X,
|
|
632
632
|
ref: l,
|
|
@@ -635,10 +635,10 @@ var Fe = (e) => G(e) && !Ie(e) ? e : {
|
|
|
635
635
|
};
|
|
636
636
|
if (a ? !Array.isArray(w) || !w.length : A && (!Q && (se || re(w)) || ce(w) && !w || C && !Pr(d).isValid || F && !Ir(d).isValid)) {
|
|
637
637
|
const { value: k, message: S } = ne(A) ? { value: !!A, message: A } : Fe(A);
|
|
638
|
-
if (k && (m[
|
|
638
|
+
if (k && (m[$] = {
|
|
639
639
|
type: de.required,
|
|
640
640
|
message: S,
|
|
641
|
-
ref:
|
|
641
|
+
ref: D,
|
|
642
642
|
...K(de.required, S)
|
|
643
643
|
}, !s))
|
|
644
644
|
return _(S), m;
|
|
@@ -654,16 +654,16 @@ var Fe = (e) => G(e) && !Ie(e) ? e : {
|
|
|
654
654
|
ne(q.value) && w && (k = fe ? X(w) > X(q.value) : ye ? w > q.value : ee > new Date(q.value)), ne(J.value) && w && (S = fe ? X(w) < X(J.value) : ye ? w < J.value : ee < new Date(J.value));
|
|
655
655
|
}
|
|
656
656
|
if ((k || S) && (be(!!k, q.message, J.message, de.max, de.min), !s))
|
|
657
|
-
return _(m[
|
|
657
|
+
return _(m[$].message), m;
|
|
658
658
|
}
|
|
659
659
|
if ((p || I) && !se && (ne(w) || a && Array.isArray(w))) {
|
|
660
660
|
const k = Fe(p), S = Fe(I), q = !re(k.value) && w.length > +k.value, J = !re(S.value) && w.length < +S.value;
|
|
661
661
|
if ((q || J) && (be(q, k.message, S.message), !s))
|
|
662
|
-
return _(m[
|
|
662
|
+
return _(m[$].message), m;
|
|
663
663
|
}
|
|
664
|
-
if (
|
|
665
|
-
const { value: k, message: S } = Fe(
|
|
666
|
-
if (Ie(k) && !w.match(k) && (m[
|
|
664
|
+
if (h && !se && ne(w)) {
|
|
665
|
+
const { value: k, message: S } = Fe(h);
|
|
666
|
+
if (Ie(k) && !w.match(k) && (m[$] = {
|
|
667
667
|
type: de.pattern,
|
|
668
668
|
message: S,
|
|
669
669
|
ref: l,
|
|
@@ -671,27 +671,27 @@ var Fe = (e) => G(e) && !Ie(e) ? e : {
|
|
|
671
671
|
}, !s))
|
|
672
672
|
return _(S), m;
|
|
673
673
|
}
|
|
674
|
-
if (
|
|
675
|
-
if (oe(
|
|
676
|
-
const k = await
|
|
677
|
-
if (S && (m[
|
|
674
|
+
if (M) {
|
|
675
|
+
if (oe(M)) {
|
|
676
|
+
const k = await M(w, r), S = Rr(k, D);
|
|
677
|
+
if (S && (m[$] = {
|
|
678
678
|
...S,
|
|
679
679
|
...K(de.validate, S.message)
|
|
680
680
|
}, !s))
|
|
681
681
|
return _(S.message), m;
|
|
682
|
-
} else if (G(
|
|
682
|
+
} else if (G(M)) {
|
|
683
683
|
let k = {};
|
|
684
|
-
for (const S in
|
|
684
|
+
for (const S in M) {
|
|
685
685
|
if (!Z(k) && !s)
|
|
686
686
|
break;
|
|
687
|
-
const q = Rr(await
|
|
687
|
+
const q = Rr(await M[S](w, r), D, S);
|
|
688
688
|
q && (k = {
|
|
689
689
|
...q,
|
|
690
690
|
...K(S, q.message)
|
|
691
|
-
}, _(q.message), s && (m[
|
|
691
|
+
}, _(q.message), s && (m[$] = k));
|
|
692
692
|
}
|
|
693
|
-
if (!Z(k) && (m[
|
|
694
|
-
ref:
|
|
693
|
+
if (!Z(k) && (m[$] = {
|
|
694
|
+
ref: D,
|
|
695
695
|
...k
|
|
696
696
|
}, !s))
|
|
697
697
|
return m;
|
|
@@ -723,7 +723,7 @@ function Vt(e = {}) {
|
|
|
723
723
|
validatingFields: {},
|
|
724
724
|
errors: t.errors || {},
|
|
725
725
|
disabled: t.disabled || !1
|
|
726
|
-
}, s = {}, o = G(t.defaultValues) || G(t.values) ?
|
|
726
|
+
}, s = {}, o = G(t.defaultValues) || G(t.values) ? U(t.defaultValues || t.values) || {} : {}, a = t.shouldUnregister ? {} : U(o), l = {
|
|
727
727
|
action: !1,
|
|
728
728
|
mount: !1,
|
|
729
729
|
watch: !1,
|
|
@@ -749,40 +749,40 @@ function Vt(e = {}) {
|
|
|
749
749
|
let R = {
|
|
750
750
|
...x
|
|
751
751
|
};
|
|
752
|
-
const
|
|
752
|
+
const h = {
|
|
753
753
|
array: pr(),
|
|
754
754
|
state: pr()
|
|
755
|
-
},
|
|
755
|
+
}, M = t.criteriaMode === ie.all, $ = (n) => (i) => {
|
|
756
756
|
clearTimeout(p), p = setTimeout(n, i);
|
|
757
|
-
},
|
|
757
|
+
}, W = async (n) => {
|
|
758
758
|
if (!l.keepIsValid && !t.disabled && (x.isValid || R.isValid || n)) {
|
|
759
759
|
let i;
|
|
760
|
-
t.resolver ? (i = Z((await Q()).errors), B()) : i = await K(s, !0), i !== r.isValid &&
|
|
760
|
+
t.resolver ? (i = Z((await Q()).errors), B()) : i = await K(s, !0), i !== r.isValid && h.state.next({
|
|
761
761
|
isValid: i
|
|
762
762
|
});
|
|
763
763
|
}
|
|
764
764
|
}, B = (n, i) => {
|
|
765
765
|
!t.disabled && (x.isValidating || x.validatingFields || R.isValidating || R.validatingFields) && ((n || Array.from(d.mount)).forEach((u) => {
|
|
766
766
|
u && (i ? P(r.validatingFields, u, i) : H(r.validatingFields, u));
|
|
767
|
-
}),
|
|
767
|
+
}), h.state.next({
|
|
768
768
|
validatingFields: r.validatingFields,
|
|
769
769
|
isValidating: !Z(r.validatingFields)
|
|
770
770
|
}));
|
|
771
771
|
}, w = (n, i = [], u, v, y = !0, f = !0) => {
|
|
772
772
|
if (v && u && !t.disabled) {
|
|
773
|
-
if (l.action = !0, f && Array.isArray(
|
|
774
|
-
const b = u(
|
|
773
|
+
if (l.action = !0, f && Array.isArray(g(s, n))) {
|
|
774
|
+
const b = u(g(s, n), v.argA, v.argB);
|
|
775
775
|
y && P(s, n, b);
|
|
776
776
|
}
|
|
777
|
-
if (f && Array.isArray(
|
|
778
|
-
const b = u(
|
|
777
|
+
if (f && Array.isArray(g(r.errors, n))) {
|
|
778
|
+
const b = u(g(r.errors, n), v.argA, v.argB);
|
|
779
779
|
y && P(r.errors, n, b), At(r.errors, n);
|
|
780
780
|
}
|
|
781
|
-
if ((x.touchedFields || R.touchedFields) && f && Array.isArray(
|
|
782
|
-
const b = u(
|
|
781
|
+
if ((x.touchedFields || R.touchedFields) && f && Array.isArray(g(r.touchedFields, n))) {
|
|
782
|
+
const b = u(g(r.touchedFields, n), v.argA, v.argB);
|
|
783
783
|
y && P(r.touchedFields, n, b);
|
|
784
784
|
}
|
|
785
|
-
(x.dirtyFields || R.dirtyFields) && (r.dirtyFields = Ve(o, a)),
|
|
785
|
+
(x.dirtyFields || R.dirtyFields) && (r.dirtyFields = Ve(o, a)), h.state.next({
|
|
786
786
|
name: n,
|
|
787
787
|
isDirty: k(n, i),
|
|
788
788
|
dirtyFields: r.dirtyFields,
|
|
@@ -791,42 +791,42 @@ function Vt(e = {}) {
|
|
|
791
791
|
});
|
|
792
792
|
} else
|
|
793
793
|
P(a, n, i);
|
|
794
|
-
},
|
|
795
|
-
P(r.errors, n, i),
|
|
794
|
+
}, D = (n, i) => {
|
|
795
|
+
P(r.errors, n, i), h.state.next({
|
|
796
796
|
errors: r.errors
|
|
797
797
|
});
|
|
798
798
|
}, _ = (n) => {
|
|
799
|
-
r.errors = n,
|
|
799
|
+
r.errors = n, h.state.next({
|
|
800
800
|
errors: r.errors,
|
|
801
801
|
isValid: !1
|
|
802
802
|
});
|
|
803
803
|
}, m = (n, i, u, v) => {
|
|
804
|
-
const y =
|
|
804
|
+
const y = g(s, n);
|
|
805
805
|
if (y) {
|
|
806
|
-
const f =
|
|
807
|
-
N(f) || v && v.defaultChecked || i ? P(a, n, i ? f : Er(y._f)) : J(n, f), l.mount && !l.action &&
|
|
806
|
+
const f = g(a, n, N(u) ? g(o, n) : u);
|
|
807
|
+
N(f) || v && v.defaultChecked || i ? P(a, n, i ? f : Er(y._f)) : J(n, f), l.mount && !l.action && W();
|
|
808
808
|
}
|
|
809
809
|
}, F = (n, i, u, v, y) => {
|
|
810
810
|
let f = !1, b = !1;
|
|
811
|
-
const
|
|
811
|
+
const O = {
|
|
812
812
|
name: n
|
|
813
813
|
};
|
|
814
814
|
if (!t.disabled) {
|
|
815
815
|
if (!u || v) {
|
|
816
|
-
(x.isDirty || R.isDirty) && (b = r.isDirty, r.isDirty =
|
|
817
|
-
const j = ue(
|
|
818
|
-
b = !!
|
|
816
|
+
(x.isDirty || R.isDirty) && (b = r.isDirty, r.isDirty = O.isDirty = k(), f = b !== O.isDirty);
|
|
817
|
+
const j = ue(g(o, n), i);
|
|
818
|
+
b = !!g(r.dirtyFields, n), j ? H(r.dirtyFields, n) : P(r.dirtyFields, n, !0), O.dirtyFields = r.dirtyFields, f = f || (x.dirtyFields || R.dirtyFields) && b !== !j;
|
|
819
819
|
}
|
|
820
820
|
if (u) {
|
|
821
|
-
const j =
|
|
822
|
-
j || (P(r.touchedFields, n, u),
|
|
821
|
+
const j = g(r.touchedFields, n);
|
|
822
|
+
j || (P(r.touchedFields, n, u), O.touchedFields = r.touchedFields, f = f || (x.touchedFields || R.touchedFields) && j !== u);
|
|
823
823
|
}
|
|
824
|
-
f && y &&
|
|
824
|
+
f && y && h.state.next(O);
|
|
825
825
|
}
|
|
826
|
-
return f ?
|
|
826
|
+
return f ? O : {};
|
|
827
827
|
}, C = (n, i, u, v) => {
|
|
828
|
-
const y =
|
|
829
|
-
if (t.delayError && u ? (A =
|
|
828
|
+
const y = g(r.errors, n), f = (x.isValid || R.isValid) && ce(i) && r.isValid !== i;
|
|
829
|
+
if (t.delayError && u ? (A = $(() => D(n, u)), A(t.delayError)) : (clearTimeout(p), A = null, u ? P(r.errors, n, u) : H(r.errors, n)), (u ? !ue(y, u) : y) || !Z(v) || f) {
|
|
830
830
|
const b = {
|
|
831
831
|
...v,
|
|
832
832
|
...f && ce(i) ? { isValid: i } : {},
|
|
@@ -836,13 +836,13 @@ function Vt(e = {}) {
|
|
|
836
836
|
r = {
|
|
837
837
|
...r,
|
|
838
838
|
...b
|
|
839
|
-
},
|
|
839
|
+
}, h.state.next(b);
|
|
840
840
|
}
|
|
841
841
|
}, Q = async (n) => (B(n, !0), await t.resolver(a, t.context, vt(n || d.mount, s, t.criteriaMode, t.shouldUseNativeValidation))), se = async (n) => {
|
|
842
842
|
const { errors: i } = await Q(n);
|
|
843
843
|
if (B(n), n)
|
|
844
844
|
for (const u of n) {
|
|
845
|
-
const v =
|
|
845
|
+
const v = g(i, u);
|
|
846
846
|
v ? P(r.errors, u, v) : H(r.errors, u);
|
|
847
847
|
}
|
|
848
848
|
else
|
|
@@ -856,12 +856,12 @@ function Vt(e = {}) {
|
|
|
856
856
|
if (y) {
|
|
857
857
|
const { _f: f, ...b } = y;
|
|
858
858
|
if (f) {
|
|
859
|
-
const
|
|
859
|
+
const O = d.array.has(f.name), j = y._f && gt(y._f);
|
|
860
860
|
j && x.validatingFields && B([f.name], !0);
|
|
861
|
-
const ae = await sr(y, d.disabled, a,
|
|
861
|
+
const ae = await sr(y, d.disabled, a, M, t.shouldUseNativeValidation && !i, O);
|
|
862
862
|
if (j && x.validatingFields && B([f.name]), ae[f.name] && (u.valid = !1, i))
|
|
863
863
|
break;
|
|
864
|
-
!i && (
|
|
864
|
+
!i && (g(ae, f.name) ? O ? Lr(r.errors, ae, f.name) : P(r.errors, f.name, ae[f.name]) : H(r.errors, f.name));
|
|
865
865
|
}
|
|
866
866
|
!Z(b) && await K(b, i, u);
|
|
867
867
|
}
|
|
@@ -869,22 +869,22 @@ function Vt(e = {}) {
|
|
|
869
869
|
return u.valid;
|
|
870
870
|
}, be = () => {
|
|
871
871
|
for (const n of d.unMount) {
|
|
872
|
-
const i =
|
|
872
|
+
const i = g(s, n);
|
|
873
873
|
i && (i._f.refs ? i._f.refs.every((u) => !Ye(u)) : !Ye(i._f.ref)) && le(n);
|
|
874
874
|
}
|
|
875
875
|
d.unMount = /* @__PURE__ */ new Set();
|
|
876
876
|
}, k = (n, i) => !t.disabled && (n && i && P(a, n, i), !ue(c(), o)), S = (n, i, u) => Ke(n, d, {
|
|
877
877
|
...l.mount ? a : N(i) ? o : ne(n) ? { [n]: i } : i
|
|
878
|
-
}, u, i), q = (n) =>
|
|
879
|
-
const v =
|
|
878
|
+
}, u, i), q = (n) => Me(g(l.mount ? a : o, n, t.shouldUnregister ? g(o, n, []) : [])), J = (n, i, u = {}) => {
|
|
879
|
+
const v = g(s, n);
|
|
880
880
|
let y = i;
|
|
881
881
|
if (v) {
|
|
882
882
|
const f = v._f;
|
|
883
883
|
f && (!f.disabled && P(a, n, Nr(i, f)), y = Ne(f.ref) && re(i) ? "" : i, Cr(f.ref) ? [...f.ref.options].forEach((b) => b.selected = y.includes(b.value)) : f.refs ? De(f.ref) ? f.refs.forEach((b) => {
|
|
884
|
-
(!b.defaultChecked || !b.disabled) && (Array.isArray(y) ? b.checked = !!y.find((
|
|
885
|
-
}) : f.refs.forEach((b) => b.checked = b.value === y) : ur(f.ref) ? f.ref.value = "" : (f.ref.value = y, f.ref.type ||
|
|
884
|
+
(!b.defaultChecked || !b.disabled) && (Array.isArray(y) ? b.checked = !!y.find((O) => O === b.value) : b.checked = y === b.value || !!y);
|
|
885
|
+
}) : f.refs.forEach((b) => b.checked = b.value === y) : ur(f.ref) ? f.ref.value = "" : (f.ref.value = y, f.ref.type || h.state.next({
|
|
886
886
|
name: n,
|
|
887
|
-
values:
|
|
887
|
+
values: U(a)
|
|
888
888
|
})));
|
|
889
889
|
}
|
|
890
890
|
(u.shouldDirty || u.shouldTouch) && F(n, y, u.shouldTouch, u.shouldDirty, !0), u.shouldValidate && me(n);
|
|
@@ -892,64 +892,64 @@ function Vt(e = {}) {
|
|
|
892
892
|
for (const v in i) {
|
|
893
893
|
if (!i.hasOwnProperty(v))
|
|
894
894
|
return;
|
|
895
|
-
const y = i[v], f = n + "." + v, b =
|
|
896
|
-
(d.array.has(n) || G(y) || b && !b._f) && !
|
|
895
|
+
const y = i[v], f = n + "." + v, b = g(s, f);
|
|
896
|
+
(d.array.has(n) || G(y) || b && !b._f) && !he(y) ? ee(f, y, u) : J(f, y, u);
|
|
897
897
|
}
|
|
898
898
|
}, X = (n, i, u = {}) => {
|
|
899
|
-
const v =
|
|
900
|
-
P(a, n, f), y ? (
|
|
899
|
+
const v = g(s, n), y = d.array.has(n), f = U(i);
|
|
900
|
+
P(a, n, f), y ? (h.array.next({
|
|
901
901
|
name: n,
|
|
902
|
-
values:
|
|
903
|
-
}), (x.isDirty || x.dirtyFields || R.isDirty || R.dirtyFields) && u.shouldDirty &&
|
|
902
|
+
values: U(a)
|
|
903
|
+
}), (x.isDirty || x.dirtyFields || R.isDirty || R.dirtyFields) && u.shouldDirty && h.state.next({
|
|
904
904
|
name: n,
|
|
905
905
|
dirtyFields: Ve(o, a),
|
|
906
906
|
isDirty: k(n, f)
|
|
907
|
-
})) : v && !v._f && !re(f) ? ee(n, f, u) : J(n, f, u), tr(n, d) &&
|
|
907
|
+
})) : v && !v._f && !re(f) ? ee(n, f, u) : J(n, f, u), tr(n, d) && h.state.next({ ...r, name: n }), h.state.next({
|
|
908
908
|
name: l.mount ? n : void 0,
|
|
909
|
-
values:
|
|
909
|
+
values: U(a)
|
|
910
910
|
});
|
|
911
911
|
}, fe = async (n) => {
|
|
912
912
|
l.mount = !0;
|
|
913
913
|
const i = n.target;
|
|
914
914
|
let u = i.name, v = !0;
|
|
915
|
-
const y =
|
|
916
|
-
v = Number.isNaN(j) ||
|
|
917
|
-
}, b = Ee(t.mode),
|
|
915
|
+
const y = g(s, u), f = (j) => {
|
|
916
|
+
v = Number.isNaN(j) || he(j) && isNaN(j.getTime()) || ue(j, g(a, u, j));
|
|
917
|
+
}, b = Ee(t.mode), O = Ee(t.reValidateMode);
|
|
918
918
|
if (y) {
|
|
919
919
|
let j, ae;
|
|
920
|
-
const Ce = i.type ? Er(y._f) : at(n), _e = n.type === xr.BLUR || n.type === xr.FOCUS_OUT, Jr = !
|
|
920
|
+
const Ce = i.type ? Er(y._f) : at(n), _e = n.type === xr.BLUR || n.type === xr.FOCUS_OUT, Jr = !ht(y._f) && !t.resolver && !g(r.errors, u) && !y._f.deps || pt(_e, g(r.touchedFields, u), r.isSubmitted, O, b), $e = tr(u, d, _e);
|
|
921
921
|
P(a, u, Ce), _e ? (!i || !i.readOnly) && (y._f.onBlur && y._f.onBlur(n), A && A(0)) : y._f.onChange && y._f.onChange(n);
|
|
922
|
-
const
|
|
923
|
-
if (!_e &&
|
|
922
|
+
const We = F(u, Ce, _e), Gr = !Z(We) || $e;
|
|
923
|
+
if (!_e && h.state.next({
|
|
924
924
|
name: u,
|
|
925
925
|
type: n.type,
|
|
926
|
-
values:
|
|
926
|
+
values: U(a)
|
|
927
927
|
}), Jr)
|
|
928
|
-
return (x.isValid || R.isValid) && (t.mode === "onBlur" ? _e &&
|
|
929
|
-
if (!_e &&
|
|
928
|
+
return (x.isValid || R.isValid) && (t.mode === "onBlur" ? _e && W() : _e || W()), Gr && h.state.next({ name: u, ...$e ? {} : We });
|
|
929
|
+
if (!_e && $e && h.state.next({ ...r }), t.resolver) {
|
|
930
930
|
const { errors: _r } = await Q([u]);
|
|
931
931
|
if (B([u]), f(Ce), v) {
|
|
932
932
|
const Xr = kr(r.errors, s, u), vr = kr(_r, s, Xr.name || u);
|
|
933
933
|
j = vr.error, u = vr.name, ae = Z(_r);
|
|
934
934
|
}
|
|
935
935
|
} else
|
|
936
|
-
B([u], !0), j = (await sr(y, d.disabled, a,
|
|
937
|
-
v && (y._f.deps && (!Array.isArray(y._f.deps) || y._f.deps.length > 0) && me(y._f.deps), C(u, ae, j,
|
|
936
|
+
B([u], !0), j = (await sr(y, d.disabled, a, M, t.shouldUseNativeValidation))[u], B([u]), f(Ce), v && (j ? ae = !1 : (x.isValid || R.isValid) && (ae = await K(s, !0)));
|
|
937
|
+
v && (y._f.deps && (!Array.isArray(y._f.deps) || y._f.deps.length > 0) && me(y._f.deps), C(u, ae, j, We));
|
|
938
938
|
}
|
|
939
939
|
}, ye = (n, i) => {
|
|
940
|
-
if (
|
|
940
|
+
if (g(r.errors, i) && n.focus)
|
|
941
941
|
return n.focus(), 1;
|
|
942
942
|
}, me = async (n, i = {}) => {
|
|
943
943
|
let u, v;
|
|
944
944
|
const y = te(n);
|
|
945
945
|
if (t.resolver) {
|
|
946
946
|
const f = await se(N(n) ? n : y);
|
|
947
|
-
u = Z(f), v = n ? !y.some((b) =>
|
|
947
|
+
u = Z(f), v = n ? !y.some((b) => g(f, b)) : u;
|
|
948
948
|
} else n ? (v = (await Promise.all(y.map(async (f) => {
|
|
949
|
-
const b =
|
|
949
|
+
const b = g(s, f);
|
|
950
950
|
return await K(b && b._f ? { [f]: b } : b);
|
|
951
|
-
}))).every(Boolean), !(!v && !r.isValid) &&
|
|
952
|
-
return
|
|
951
|
+
}))).every(Boolean), !(!v && !r.isValid) && W()) : v = u = await K(s);
|
|
952
|
+
return h.state.next({
|
|
953
953
|
...!ne(n) || (x.isValid || R.isValid) && u !== r.isValid ? {} : { name: n },
|
|
954
954
|
...t.resolver || !n ? { isValid: u } : {},
|
|
955
955
|
errors: r.errors
|
|
@@ -958,31 +958,31 @@ function Vt(e = {}) {
|
|
|
958
958
|
let u = {
|
|
959
959
|
...l.mount ? a : o
|
|
960
960
|
};
|
|
961
|
-
return i && (u = Dr(i.dirtyFields ? r.dirtyFields : r.touchedFields, u)), N(n) ? u : ne(n) ?
|
|
961
|
+
return i && (u = Dr(i.dirtyFields ? r.dirtyFields : r.touchedFields, u)), N(n) ? u : ne(n) ? g(u, n) : n.map((v) => g(u, v));
|
|
962
962
|
}, E = (n, i) => ({
|
|
963
|
-
invalid: !!
|
|
964
|
-
isDirty: !!
|
|
965
|
-
error:
|
|
966
|
-
isValidating: !!
|
|
967
|
-
isTouched: !!
|
|
963
|
+
invalid: !!g((i || r).errors, n),
|
|
964
|
+
isDirty: !!g((i || r).dirtyFields, n),
|
|
965
|
+
error: g((i || r).errors, n),
|
|
966
|
+
isValidating: !!g(r.validatingFields, n),
|
|
967
|
+
isTouched: !!g((i || r).touchedFields, n)
|
|
968
968
|
}), L = (n) => {
|
|
969
|
-
n && te(n).forEach((i) => H(r.errors, i)),
|
|
969
|
+
n && te(n).forEach((i) => H(r.errors, i)), h.state.next({
|
|
970
970
|
errors: n ? r.errors : {}
|
|
971
971
|
});
|
|
972
972
|
}, Y = (n, i, u) => {
|
|
973
|
-
const v = (
|
|
973
|
+
const v = (g(s, n, { _f: {} })._f || {}).ref, y = g(r.errors, n) || {}, { ref: f, message: b, type: O, ...j } = y;
|
|
974
974
|
P(r.errors, n, {
|
|
975
975
|
...j,
|
|
976
976
|
...i,
|
|
977
977
|
ref: v
|
|
978
|
-
}),
|
|
978
|
+
}), h.state.next({
|
|
979
979
|
name: n,
|
|
980
980
|
errors: r.errors,
|
|
981
981
|
isValid: !1
|
|
982
982
|
}), u && u.shouldFocus && v && v.focus && v.focus();
|
|
983
|
-
}, xe = (n, i) => oe(n) ?
|
|
983
|
+
}, xe = (n, i) => oe(n) ? h.state.subscribe({
|
|
984
984
|
next: (u) => "values" in u && n(S(void 0, i), u)
|
|
985
|
-
}) : S(n, i, !0), pe = (n) =>
|
|
985
|
+
}) : S(n, i, !0), pe = (n) => h.state.subscribe({
|
|
986
986
|
next: (i) => {
|
|
987
987
|
xt(n.name, i.name, n.exact) && bt(i, n.formState || x, Hr, n.reRenderRoot) && n.callback({
|
|
988
988
|
values: { ...a },
|
|
@@ -1003,16 +1003,16 @@ function Vt(e = {}) {
|
|
|
1003
1003
|
})), le = (n, i = {}) => {
|
|
1004
1004
|
for (const u of n ? te(n) : d.mount)
|
|
1005
1005
|
d.mount.delete(u), d.array.delete(u), i.keepValue || (H(s, u), H(a, u)), !i.keepError && H(r.errors, u), !i.keepDirty && H(r.dirtyFields, u), !i.keepTouched && H(r.touchedFields, u), !i.keepIsValidating && H(r.validatingFields, u), !t.shouldUnregister && !i.keepDefaultValue && H(o, u);
|
|
1006
|
-
|
|
1007
|
-
values:
|
|
1008
|
-
}),
|
|
1006
|
+
h.state.next({
|
|
1007
|
+
values: U(a)
|
|
1008
|
+
}), h.state.next({
|
|
1009
1009
|
...r,
|
|
1010
1010
|
...i.keepDirty ? { isDirty: k() } : {}
|
|
1011
|
-
}), !i.keepIsValid &&
|
|
1011
|
+
}), !i.keepIsValid && W();
|
|
1012
1012
|
}, Ae = ({ disabled: n, name: i }) => {
|
|
1013
1013
|
(ce(n) && l.mount || n || d.disabled.has(i)) && (n ? d.disabled.add(i) : d.disabled.delete(i));
|
|
1014
1014
|
}, ke = (n, i = {}) => {
|
|
1015
|
-
let u =
|
|
1015
|
+
let u = g(s, n);
|
|
1016
1016
|
const v = ce(i.disabled) || ce(t.disabled);
|
|
1017
1017
|
return P(s, n, {
|
|
1018
1018
|
...u || {},
|
|
@@ -1029,41 +1029,41 @@ function Vt(e = {}) {
|
|
|
1029
1029
|
...v ? { disabled: i.disabled || t.disabled } : {},
|
|
1030
1030
|
...t.progressive ? {
|
|
1031
1031
|
required: !!i.required,
|
|
1032
|
-
min:
|
|
1033
|
-
max:
|
|
1034
|
-
minLength:
|
|
1035
|
-
maxLength:
|
|
1036
|
-
pattern:
|
|
1032
|
+
min: Te(i.min),
|
|
1033
|
+
max: Te(i.max),
|
|
1034
|
+
minLength: Te(i.minLength),
|
|
1035
|
+
maxLength: Te(i.maxLength),
|
|
1036
|
+
pattern: Te(i.pattern)
|
|
1037
1037
|
} : {},
|
|
1038
1038
|
name: n,
|
|
1039
1039
|
onChange: fe,
|
|
1040
1040
|
onBlur: fe,
|
|
1041
1041
|
ref: (y) => {
|
|
1042
1042
|
if (y) {
|
|
1043
|
-
ke(n, i), u =
|
|
1044
|
-
const f = N(y.value) && y.querySelectorAll && y.querySelectorAll("input,select,textarea")[0] || y, b = ft(f),
|
|
1045
|
-
if (b ?
|
|
1043
|
+
ke(n, i), u = g(s, n);
|
|
1044
|
+
const f = N(y.value) && y.querySelectorAll && y.querySelectorAll("input,select,textarea")[0] || y, b = ft(f), O = u._f.refs || [];
|
|
1045
|
+
if (b ? O.find((j) => j === f) : f === u._f.ref)
|
|
1046
1046
|
return;
|
|
1047
1047
|
P(s, n, {
|
|
1048
1048
|
_f: {
|
|
1049
1049
|
...u._f,
|
|
1050
1050
|
...b ? {
|
|
1051
1051
|
refs: [
|
|
1052
|
-
...
|
|
1052
|
+
...O.filter(Ye),
|
|
1053
1053
|
f,
|
|
1054
|
-
...Array.isArray(
|
|
1054
|
+
...Array.isArray(g(o, n)) ? [{}] : []
|
|
1055
1055
|
],
|
|
1056
1056
|
ref: { type: f.type, name: n }
|
|
1057
1057
|
} : { ref: f }
|
|
1058
1058
|
}
|
|
1059
1059
|
}), m(n, !1, void 0, f);
|
|
1060
1060
|
} else
|
|
1061
|
-
u =
|
|
1061
|
+
u = g(s, n, {}), u._f && (u._f.mount = !1), (t.shouldUnregister || i.shouldUnregister) && !(ot(d.array, n) && l.action) && d.unMount.add(n);
|
|
1062
1062
|
}
|
|
1063
1063
|
};
|
|
1064
1064
|
}, Be = () => t.shouldFocusError && we(s, ye, d.mount), Yr = (n) => {
|
|
1065
|
-
ce(n) && (
|
|
1066
|
-
const v =
|
|
1065
|
+
ce(n) && (h.state.next({ disabled: n }), we(s, (i, u) => {
|
|
1066
|
+
const v = g(s, u);
|
|
1067
1067
|
v && (i.disabled = v._f.disabled || n, Array.isArray(v._f.refs) && v._f.refs.forEach((y) => {
|
|
1068
1068
|
y.disabled = v._f.disabled || n;
|
|
1069
1069
|
}));
|
|
@@ -1071,19 +1071,19 @@ function Vt(e = {}) {
|
|
|
1071
1071
|
}, dr = (n, i) => async (u) => {
|
|
1072
1072
|
let v;
|
|
1073
1073
|
u && (u.preventDefault && u.preventDefault(), u.persist && u.persist());
|
|
1074
|
-
let y =
|
|
1075
|
-
if (
|
|
1074
|
+
let y = U(a);
|
|
1075
|
+
if (h.state.next({
|
|
1076
1076
|
isSubmitting: !0
|
|
1077
1077
|
}), t.resolver) {
|
|
1078
1078
|
const { errors: f, values: b } = await Q();
|
|
1079
|
-
B(), r.errors = f, y =
|
|
1079
|
+
B(), r.errors = f, y = U(b);
|
|
1080
1080
|
} else
|
|
1081
1081
|
await K(s);
|
|
1082
1082
|
if (d.disabled.size)
|
|
1083
1083
|
for (const f of d.disabled)
|
|
1084
1084
|
H(y, f);
|
|
1085
1085
|
if (H(r.errors, "root"), Z(r.errors)) {
|
|
1086
|
-
|
|
1086
|
+
h.state.next({
|
|
1087
1087
|
errors: {}
|
|
1088
1088
|
});
|
|
1089
1089
|
try {
|
|
@@ -1093,7 +1093,7 @@ function Vt(e = {}) {
|
|
|
1093
1093
|
}
|
|
1094
1094
|
} else
|
|
1095
1095
|
i && await i({ ...r.errors }, u), Be(), setTimeout(Be);
|
|
1096
|
-
if (
|
|
1096
|
+
if (h.state.next({
|
|
1097
1097
|
isSubmitted: !0,
|
|
1098
1098
|
isSubmitting: !1,
|
|
1099
1099
|
isSubmitSuccessful: Z(r.errors) && !v,
|
|
@@ -1102,23 +1102,23 @@ function Vt(e = {}) {
|
|
|
1102
1102
|
}), v)
|
|
1103
1103
|
throw v;
|
|
1104
1104
|
}, qr = (n, i = {}) => {
|
|
1105
|
-
|
|
1105
|
+
g(s, n) && (N(i.defaultValue) ? X(n, U(g(o, n))) : (X(n, i.defaultValue), P(o, n, U(i.defaultValue))), i.keepTouched || H(r.touchedFields, n), i.keepDirty || (H(r.dirtyFields, n), r.isDirty = i.defaultValue ? k(n, U(g(o, n))) : k()), i.keepError || (H(r.errors, n), x.isValid && W()), h.state.next({ ...r }));
|
|
1106
1106
|
}, fr = (n, i = {}) => {
|
|
1107
|
-
const u = n ?
|
|
1107
|
+
const u = n ? U(n) : o, v = U(u), y = Z(n), f = y ? o : v;
|
|
1108
1108
|
if (i.keepDefaultValues || (o = u), !i.keepValues) {
|
|
1109
1109
|
if (i.keepDirtyValues) {
|
|
1110
1110
|
const b = /* @__PURE__ */ new Set([
|
|
1111
1111
|
...d.mount,
|
|
1112
1112
|
...Object.keys(Ve(o, a))
|
|
1113
1113
|
]);
|
|
1114
|
-
for (const
|
|
1115
|
-
|
|
1114
|
+
for (const O of Array.from(b))
|
|
1115
|
+
g(r.dirtyFields, O) ? P(f, O, g(a, O)) : X(O, g(f, O));
|
|
1116
1116
|
} else {
|
|
1117
1117
|
if (nr && N(n))
|
|
1118
1118
|
for (const b of d.mount) {
|
|
1119
|
-
const
|
|
1120
|
-
if (
|
|
1121
|
-
const j = Array.isArray(
|
|
1119
|
+
const O = g(s, b);
|
|
1120
|
+
if (O && O._f) {
|
|
1121
|
+
const j = Array.isArray(O._f.refs) ? O._f.refs[0] : O._f.ref;
|
|
1122
1122
|
if (Ne(j)) {
|
|
1123
1123
|
const ae = j.closest("form");
|
|
1124
1124
|
if (ae) {
|
|
@@ -1130,13 +1130,13 @@ function Vt(e = {}) {
|
|
|
1130
1130
|
}
|
|
1131
1131
|
if (i.keepFieldsRef)
|
|
1132
1132
|
for (const b of d.mount)
|
|
1133
|
-
X(b,
|
|
1133
|
+
X(b, g(f, b));
|
|
1134
1134
|
else
|
|
1135
1135
|
s = {};
|
|
1136
1136
|
}
|
|
1137
|
-
a = t.shouldUnregister ? i.keepDefaultValues ?
|
|
1137
|
+
a = t.shouldUnregister ? i.keepDefaultValues ? U(o) : {} : U(f), h.array.next({
|
|
1138
1138
|
values: { ...f }
|
|
1139
|
-
}),
|
|
1139
|
+
}), h.state.next({
|
|
1140
1140
|
values: { ...f }
|
|
1141
1141
|
});
|
|
1142
1142
|
}
|
|
@@ -1148,7 +1148,7 @@ function Vt(e = {}) {
|
|
|
1148
1148
|
watch: /* @__PURE__ */ new Set(),
|
|
1149
1149
|
watchAll: !1,
|
|
1150
1150
|
focus: ""
|
|
1151
|
-
}, l.mount = !x.isValid || !!i.keepIsValid || !!i.keepDirtyValues || !t.shouldUnregister && !Z(f), l.watch = !!t.shouldUnregister, l.keepIsValid = !!i.keepIsValid, l.action = !1, i.keepErrors || (r.errors = {}),
|
|
1151
|
+
}, l.mount = !x.isValid || !!i.keepIsValid || !!i.keepDirtyValues || !t.shouldUnregister && !Z(f), l.watch = !!t.shouldUnregister, l.keepIsValid = !!i.keepIsValid, l.action = !1, i.keepErrors || (r.errors = {}), h.state.next({
|
|
1152
1152
|
submitCount: i.keepSubmitCount ? r.submitCount : 0,
|
|
1153
1153
|
isDirty: y ? !1 : i.keepDirty ? r.isDirty : !!(i.keepDefaultValues && !ue(n, o)),
|
|
1154
1154
|
isSubmitted: i.keepIsSubmitted ? r.isSubmitted : !1,
|
|
@@ -1160,7 +1160,7 @@ function Vt(e = {}) {
|
|
|
1160
1160
|
defaultValues: o
|
|
1161
1161
|
});
|
|
1162
1162
|
}, yr = (n, i) => fr(oe(n) ? n(a) : n, { ...t.resetOptions, ...i }), zr = (n, i = {}) => {
|
|
1163
|
-
const u =
|
|
1163
|
+
const u = g(s, n), v = u && u._f;
|
|
1164
1164
|
if (v) {
|
|
1165
1165
|
const y = v.refs ? v.refs[0] : v.ref;
|
|
1166
1166
|
y.focus && setTimeout(() => {
|
|
@@ -1185,20 +1185,20 @@ function Vt(e = {}) {
|
|
|
1185
1185
|
_focusError: Be,
|
|
1186
1186
|
_getWatch: S,
|
|
1187
1187
|
_getDirty: k,
|
|
1188
|
-
_setValid:
|
|
1188
|
+
_setValid: W,
|
|
1189
1189
|
_setFieldArray: w,
|
|
1190
1190
|
_setDisabledField: Ae,
|
|
1191
1191
|
_setErrors: _,
|
|
1192
1192
|
_getFieldArray: q,
|
|
1193
1193
|
_reset: fr,
|
|
1194
1194
|
_resetDefaultValues: () => oe(t.defaultValues) && t.defaultValues().then((n) => {
|
|
1195
|
-
yr(n, t.resetOptions),
|
|
1195
|
+
yr(n, t.resetOptions), h.state.next({
|
|
1196
1196
|
isLoading: !1
|
|
1197
1197
|
});
|
|
1198
1198
|
}),
|
|
1199
1199
|
_removeUnmounted: be,
|
|
1200
1200
|
_disableForm: Yr,
|
|
1201
|
-
_subjects:
|
|
1201
|
+
_subjects: h,
|
|
1202
1202
|
_proxyFormState: x,
|
|
1203
1203
|
get _fields() {
|
|
1204
1204
|
return s;
|
|
@@ -1283,17 +1283,17 @@ function Et(e, t) {
|
|
|
1283
1283
|
const s = [...e];
|
|
1284
1284
|
for (const o of t)
|
|
1285
1285
|
s.splice(o - r, 1), r++;
|
|
1286
|
-
return
|
|
1286
|
+
return Me(s).length ? s : [];
|
|
1287
1287
|
}
|
|
1288
1288
|
var Ze = (e, t) => N(t) ? [] : Et(e, te(t).sort((r, s) => r - s)), Qe = (e, t, r) => {
|
|
1289
1289
|
[e[t], e[r]] = [e[r], e[t]];
|
|
1290
1290
|
}, Sr = (e, t, r) => (e[t] = r, e);
|
|
1291
1291
|
function wt(e) {
|
|
1292
|
-
const t =
|
|
1292
|
+
const t = ge(), { control: r = t.control, name: s, keyName: o = "id", shouldUnregister: a, rules: l } = e, [d, A] = V.useState(r._getFieldArray(s)), p = V.useRef(r._getFieldArray(s).map(ve)), I = V.useRef(!1);
|
|
1293
1293
|
r._names.array.add(s), V.useMemo(() => l && d.length >= 0 && r.register(s, l), [r, s, d.length, l]), or(() => r._subjects.array.subscribe({
|
|
1294
1294
|
next: ({ values: _, name: m }) => {
|
|
1295
1295
|
if (m === s || !m) {
|
|
1296
|
-
const F =
|
|
1296
|
+
const F = g(_, s);
|
|
1297
1297
|
Array.isArray(F) && (A(F), p.current = F.map(ve));
|
|
1298
1298
|
}
|
|
1299
1299
|
}
|
|
@@ -1301,27 +1301,27 @@ function wt(e) {
|
|
|
1301
1301
|
const x = V.useCallback((_) => {
|
|
1302
1302
|
I.current = !0, r._setFieldArray(s, _);
|
|
1303
1303
|
}, [r, s]), R = (_, m) => {
|
|
1304
|
-
const F = te(
|
|
1304
|
+
const F = te(U(_)), C = ze(r._getFieldArray(s), F);
|
|
1305
1305
|
r._names.focus = qe(s, C.length - 1, m), p.current = ze(p.current, F.map(ve)), x(C), A(C), r._setFieldArray(s, C, ze, {
|
|
1306
1306
|
argA: He(_)
|
|
1307
1307
|
});
|
|
1308
|
-
},
|
|
1309
|
-
const F = te(
|
|
1308
|
+
}, h = (_, m) => {
|
|
1309
|
+
const F = te(U(_)), C = Xe(r._getFieldArray(s), F);
|
|
1310
1310
|
r._names.focus = qe(s, 0, m), p.current = Xe(p.current, F.map(ve)), x(C), A(C), r._setFieldArray(s, C, Xe, {
|
|
1311
1311
|
argA: He(_)
|
|
1312
1312
|
});
|
|
1313
|
-
},
|
|
1313
|
+
}, M = (_) => {
|
|
1314
1314
|
const m = Ze(r._getFieldArray(s), _);
|
|
1315
|
-
p.current = Ze(p.current, _), x(m), A(m), !Array.isArray(
|
|
1315
|
+
p.current = Ze(p.current, _), x(m), A(m), !Array.isArray(g(r._fields, s)) && P(r._fields, s, void 0), r._setFieldArray(s, m, Ze, {
|
|
1316
1316
|
argA: _
|
|
1317
1317
|
});
|
|
1318
|
-
},
|
|
1319
|
-
const C = te(
|
|
1318
|
+
}, $ = (_, m, F) => {
|
|
1319
|
+
const C = te(U(m)), Q = Je(r._getFieldArray(s), _, C);
|
|
1320
1320
|
r._names.focus = qe(s, _, F), p.current = Je(p.current, _, C.map(ve)), x(Q), A(Q), r._setFieldArray(s, Q, Je, {
|
|
1321
1321
|
argA: _,
|
|
1322
1322
|
argB: He(m)
|
|
1323
1323
|
});
|
|
1324
|
-
},
|
|
1324
|
+
}, W = (_, m) => {
|
|
1325
1325
|
const F = r._getFieldArray(s);
|
|
1326
1326
|
Qe(F, _, m), Qe(p.current, _, m), x(F), A(F), r._setFieldArray(s, F, Qe, {
|
|
1327
1327
|
argA: _,
|
|
@@ -1334,13 +1334,13 @@ function wt(e) {
|
|
|
1334
1334
|
argB: m
|
|
1335
1335
|
}, !1);
|
|
1336
1336
|
}, w = (_, m) => {
|
|
1337
|
-
const F =
|
|
1337
|
+
const F = U(m), C = Sr(r._getFieldArray(s), _, F);
|
|
1338
1338
|
p.current = [...C].map((Q, se) => !Q || se === _ ? ve() : p.current[se]), x(C), A([...C]), r._setFieldArray(s, C, Sr, {
|
|
1339
1339
|
argA: _,
|
|
1340
1340
|
argB: F
|
|
1341
1341
|
}, !0, !1);
|
|
1342
|
-
},
|
|
1343
|
-
const m = te(
|
|
1342
|
+
}, D = (_) => {
|
|
1343
|
+
const m = te(U(_));
|
|
1344
1344
|
p.current = m.map(ve), x([...m]), A([...m]), r._setFieldArray(s, [...m], (F) => F, {}, !0, !1);
|
|
1345
1345
|
};
|
|
1346
1346
|
return V.useEffect(() => {
|
|
@@ -1350,39 +1350,39 @@ function wt(e) {
|
|
|
1350
1350
|
if (r._options.resolver)
|
|
1351
1351
|
r._runSchema([s]).then((_) => {
|
|
1352
1352
|
r._updateIsValidating([s]);
|
|
1353
|
-
const m =
|
|
1353
|
+
const m = g(_.errors, s), F = g(r._formState.errors, s);
|
|
1354
1354
|
(F ? !m && F.type || m && (F.type !== m.type || F.message !== m.message) : m && m.type) && (m ? P(r._formState.errors, s, m) : H(r._formState.errors, s), r._subjects.state.next({
|
|
1355
1355
|
errors: r._formState.errors
|
|
1356
1356
|
}));
|
|
1357
1357
|
});
|
|
1358
1358
|
else {
|
|
1359
|
-
const _ =
|
|
1359
|
+
const _ = g(r._fields, s);
|
|
1360
1360
|
_ && _._f && !(Ee(r._options.reValidateMode).isOnSubmit && Ee(r._options.mode).isOnSubmit) && sr(_, r._names.disabled, r._formValues, r._options.criteriaMode === ie.all, r._options.shouldUseNativeValidation, !0).then((m) => !Z(m) && r._subjects.state.next({
|
|
1361
1361
|
errors: Lr(r._formState.errors, m, s)
|
|
1362
1362
|
}));
|
|
1363
1363
|
}
|
|
1364
1364
|
r._subjects.state.next({
|
|
1365
1365
|
name: s,
|
|
1366
|
-
values:
|
|
1366
|
+
values: U(r._formValues)
|
|
1367
1367
|
}), r._names.focus && we(r._fields, (_, m) => {
|
|
1368
1368
|
if (r._names.focus && m.startsWith(r._names.focus) && _.focus)
|
|
1369
1369
|
return _.focus(), 1;
|
|
1370
1370
|
}), r._names.focus = "", r._setValid(), I.current = !1;
|
|
1371
|
-
}, [d, s, r]), V.useEffect(() => (!
|
|
1371
|
+
}, [d, s, r]), V.useEffect(() => (!g(r._formValues, s) && r._setFieldArray(s), () => {
|
|
1372
1372
|
const _ = (m, F) => {
|
|
1373
|
-
const C =
|
|
1373
|
+
const C = g(r._fields, m);
|
|
1374
1374
|
C && C._f && (C._f.mount = F);
|
|
1375
1375
|
};
|
|
1376
1376
|
r._options.shouldUnregister || a ? r.unregister(s) : _(s, !1);
|
|
1377
1377
|
}), [s, r, o, a]), {
|
|
1378
|
-
swap: V.useCallback(
|
|
1378
|
+
swap: V.useCallback(W, [x, s, r]),
|
|
1379
1379
|
move: V.useCallback(B, [x, s, r]),
|
|
1380
|
-
prepend: V.useCallback(
|
|
1380
|
+
prepend: V.useCallback(h, [x, s, r]),
|
|
1381
1381
|
append: V.useCallback(R, [x, s, r]),
|
|
1382
|
-
remove: V.useCallback(
|
|
1383
|
-
insert: V.useCallback(
|
|
1382
|
+
remove: V.useCallback(M, [x, s, r]),
|
|
1383
|
+
insert: V.useCallback($, [x, s, r]),
|
|
1384
1384
|
update: V.useCallback(w, [x, s, r]),
|
|
1385
|
-
replace: V.useCallback(
|
|
1385
|
+
replace: V.useCallback(D, [x, s, r]),
|
|
1386
1386
|
fields: V.useMemo(() => d.map((_, m) => ({
|
|
1387
1387
|
..._,
|
|
1388
1388
|
[o]: p.current[m] || ve()
|
|
@@ -1467,7 +1467,7 @@ function Rt(e, t) {
|
|
|
1467
1467
|
});
|
|
1468
1468
|
}), r;
|
|
1469
1469
|
}
|
|
1470
|
-
|
|
1470
|
+
function St(e) {
|
|
1471
1471
|
switch (e) {
|
|
1472
1472
|
case "text":
|
|
1473
1473
|
return "";
|
|
@@ -1490,11 +1490,11 @@ const St = (e) => {
|
|
|
1490
1490
|
default:
|
|
1491
1491
|
return "";
|
|
1492
1492
|
}
|
|
1493
|
-
}
|
|
1494
|
-
function
|
|
1493
|
+
}
|
|
1494
|
+
function Ur(e) {
|
|
1495
1495
|
return e.replace(/\.\d+\./g, ".");
|
|
1496
1496
|
}
|
|
1497
|
-
function
|
|
1497
|
+
function Tt(e, t) {
|
|
1498
1498
|
const r = e.split("."), s = [];
|
|
1499
1499
|
return r.forEach((o, a) => {
|
|
1500
1500
|
isNaN(Number(o)) || s.push({ pos: a, value: o });
|
|
@@ -1518,38 +1518,36 @@ function Le(e, t = {}) {
|
|
|
1518
1518
|
r[s.name] = (t == null ? void 0 : t[s.name]) ?? s.initialValue ?? St(s.type);
|
|
1519
1519
|
return r;
|
|
1520
1520
|
}
|
|
1521
|
-
const
|
|
1522
|
-
const { fieldSchema: t } = e, r = t.fields, { control: s } =
|
|
1521
|
+
const Ot = (e) => {
|
|
1522
|
+
const { fieldSchema: t } = e, r = t.fields, { control: s } = ge(), { fields: o, append: a } = wt({
|
|
1523
1523
|
name: t.name,
|
|
1524
1524
|
control: s
|
|
1525
1525
|
}), l = () => {
|
|
1526
1526
|
a(Le(r));
|
|
1527
1527
|
};
|
|
1528
|
-
return /* @__PURE__ */
|
|
1528
|
+
return /* @__PURE__ */ T.jsxs("div", { children: [
|
|
1529
1529
|
o.map((d, A) => {
|
|
1530
1530
|
const p = r.map((I) => ({
|
|
1531
1531
|
...I,
|
|
1532
1532
|
name: `${t.name}.${A}.${I.name}`
|
|
1533
1533
|
}));
|
|
1534
|
-
return /* @__PURE__ */
|
|
1535
|
-
/* @__PURE__ */
|
|
1534
|
+
return /* @__PURE__ */ T.jsxs(V.Fragment, { children: [
|
|
1535
|
+
/* @__PURE__ */ T.jsxs("div", { children: [
|
|
1536
1536
|
"row ",
|
|
1537
1537
|
A
|
|
1538
1538
|
] }),
|
|
1539
1539
|
cr(p)
|
|
1540
1540
|
] }, d.id);
|
|
1541
1541
|
}),
|
|
1542
|
-
t.readonly !== !0 && /* @__PURE__ */
|
|
1542
|
+
t.readonly !== !0 && /* @__PURE__ */ T.jsx("button", { onClick: l, children: "Add Row" })
|
|
1543
1543
|
] });
|
|
1544
|
-
},
|
|
1545
|
-
null
|
|
1546
|
-
), Dt = ({
|
|
1544
|
+
}, Mr = Zr(null), Dt = ({
|
|
1547
1545
|
children: e,
|
|
1548
1546
|
layout: t = "vertical",
|
|
1549
1547
|
uiConfig: r,
|
|
1550
1548
|
updateFieldSchema: s
|
|
1551
1549
|
}) => {
|
|
1552
|
-
const o =
|
|
1550
|
+
const o = Oe(
|
|
1553
1551
|
() => ({
|
|
1554
1552
|
layout: t,
|
|
1555
1553
|
uiConfig: r,
|
|
@@ -1557,41 +1555,57 @@ const Tt = (e) => {
|
|
|
1557
1555
|
}),
|
|
1558
1556
|
[t, r, s]
|
|
1559
1557
|
);
|
|
1560
|
-
return /* @__PURE__ */
|
|
1558
|
+
return /* @__PURE__ */ T.jsx(Mr.Provider, { value: o, children: e });
|
|
1561
1559
|
}, Br = () => {
|
|
1562
|
-
const e = Qr(
|
|
1560
|
+
const e = Qr(Mr);
|
|
1563
1561
|
if (!e)
|
|
1564
1562
|
throw new Error(
|
|
1565
1563
|
"useAutoFormRenderContext must be used within AutoFormRenderContextProvider"
|
|
1566
1564
|
);
|
|
1567
1565
|
return e;
|
|
1568
1566
|
}, Ct = (e) => {
|
|
1569
|
-
const { fieldSchema: t } = e, { register: r } =
|
|
1570
|
-
return /* @__PURE__ */
|
|
1571
|
-
/* @__PURE__ */
|
|
1572
|
-
/* @__PURE__ */
|
|
1567
|
+
const { fieldSchema: t } = e, { register: r } = ge(), s = r(t.name);
|
|
1568
|
+
return /* @__PURE__ */ T.jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
|
|
1569
|
+
/* @__PURE__ */ T.jsx("label", { children: t.label }),
|
|
1570
|
+
/* @__PURE__ */ T.jsx("input", { type: t.type, ...s, readOnly: t.readonly })
|
|
1573
1571
|
] });
|
|
1574
|
-
}, jt =
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1572
|
+
}, jt = [
|
|
1573
|
+
"text",
|
|
1574
|
+
"number",
|
|
1575
|
+
"checkbox",
|
|
1576
|
+
"select",
|
|
1577
|
+
"date",
|
|
1578
|
+
"datetime-local",
|
|
1579
|
+
"time",
|
|
1580
|
+
"array",
|
|
1581
|
+
"object"
|
|
1582
|
+
], Pt = (e) => {
|
|
1583
|
+
const { fieldSchema: t } = e, { register: r } = ge(), s = r(t.name), o = t.options;
|
|
1584
|
+
return /* @__PURE__ */ T.jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
|
|
1585
|
+
/* @__PURE__ */ T.jsx("label", { children: t.label }),
|
|
1586
|
+
/* @__PURE__ */ T.jsx("select", { ...s, disabled: t.readonly, children: o.map((a) => /* @__PURE__ */ T.jsx("option", { value: a.value, children: a.label }, a.value)) })
|
|
1579
1587
|
] });
|
|
1580
|
-
},
|
|
1588
|
+
}, $r = ({ fieldSchema: e }) => {
|
|
1581
1589
|
var A, p;
|
|
1582
|
-
const r = Br().uiConfig, { register: s } =
|
|
1590
|
+
const r = Br().uiConfig, { register: s } = ge(), o = Ur(e.name), a = s(e.name);
|
|
1583
1591
|
if (e.visible === !1)
|
|
1584
1592
|
return;
|
|
1585
1593
|
const l = (A = r == null ? void 0 : r.renderersByName) == null ? void 0 : A[o];
|
|
1586
1594
|
if (l)
|
|
1587
|
-
return /* @__PURE__ */
|
|
1595
|
+
return /* @__PURE__ */ T.jsx(l, { fieldSchema: e, register: a });
|
|
1588
1596
|
const d = (p = r == null ? void 0 : r.renderersByType) == null ? void 0 : p[e.type];
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
()
|
|
1597
|
+
if (d)
|
|
1598
|
+
return /* @__PURE__ */ T.jsx(d, { fieldSchema: e, register: a });
|
|
1599
|
+
if (jt.includes(e.type))
|
|
1600
|
+
return e.type === "select" ? /* @__PURE__ */ T.jsx(Pt, { fieldSchema: e }) : /* @__PURE__ */ T.jsx(Ct, { fieldSchema: e });
|
|
1601
|
+
throw new Error(
|
|
1602
|
+
`AutoForm: No renderer found for field "${e.name}" with type "${e.type}". If this is a custom field type, make sure to register a renderer via uiConfig.renderersByType.`
|
|
1603
|
+
);
|
|
1604
|
+
}, Nt = ({ fieldSchema: e }) => /* @__PURE__ */ T.jsx($r, { fieldSchema: e }), It = ({ fieldSchema: e }) => {
|
|
1605
|
+
const { control: t } = ge(), r = Br(), s = e.dependsOn ?? [], o = Oe(
|
|
1606
|
+
() => Tt(e.name, s),
|
|
1593
1607
|
[e.name, s]
|
|
1594
|
-
), a =
|
|
1608
|
+
), a = Or({
|
|
1595
1609
|
control: t,
|
|
1596
1610
|
name: o
|
|
1597
1611
|
}), [l, d] = Kr(e);
|
|
@@ -1599,49 +1613,49 @@ const Tt = (e) => {
|
|
|
1599
1613
|
if (!s.length) return;
|
|
1600
1614
|
let A = !1;
|
|
1601
1615
|
return (async () => {
|
|
1602
|
-
var
|
|
1603
|
-
const I =
|
|
1616
|
+
var M;
|
|
1617
|
+
const I = Ur(e.name), x = Rt(
|
|
1604
1618
|
o,
|
|
1605
1619
|
a ?? []
|
|
1606
|
-
), R = (
|
|
1620
|
+
), R = (M = r == null ? void 0 : r.updateFieldSchema) == null ? void 0 : M[I];
|
|
1607
1621
|
if (!R) return;
|
|
1608
|
-
const
|
|
1609
|
-
!A &&
|
|
1622
|
+
const h = await R(e.name, e, x);
|
|
1623
|
+
!A && h && d({
|
|
1610
1624
|
...e,
|
|
1611
|
-
...
|
|
1625
|
+
...h
|
|
1612
1626
|
});
|
|
1613
1627
|
})(), () => {
|
|
1614
1628
|
A = !0;
|
|
1615
1629
|
};
|
|
1616
|
-
}, [a]), /* @__PURE__ */
|
|
1617
|
-
},
|
|
1630
|
+
}, [a]), /* @__PURE__ */ T.jsx($r, { fieldSchema: l });
|
|
1631
|
+
}, Lt = (e) => {
|
|
1618
1632
|
var r;
|
|
1619
1633
|
const { fieldSchema: t } = e;
|
|
1620
|
-
return (r = t.dependsOn) != null && r.length ? /* @__PURE__ */
|
|
1621
|
-
},
|
|
1634
|
+
return (r = t.dependsOn) != null && r.length ? /* @__PURE__ */ T.jsx(It, { fieldSchema: t }) : /* @__PURE__ */ T.jsx(Nt, { fieldSchema: t });
|
|
1635
|
+
}, Ut = (e) => {
|
|
1622
1636
|
const { fieldSchema: t } = e;
|
|
1623
|
-
return /* @__PURE__ */
|
|
1637
|
+
return /* @__PURE__ */ T.jsx(Lt, { fieldSchema: t });
|
|
1624
1638
|
}, Mt = (e) => {
|
|
1625
1639
|
const { fieldSchema: t } = e;
|
|
1626
|
-
let r =
|
|
1640
|
+
let r = Oe(() => t.fields.map((s) => ({
|
|
1627
1641
|
...s,
|
|
1628
1642
|
name: `${t.name}.${s.name}`
|
|
1629
1643
|
})), [t.fields]);
|
|
1630
|
-
return /* @__PURE__ */
|
|
1644
|
+
return /* @__PURE__ */ T.jsx(T.Fragment, { children: cr(r) });
|
|
1631
1645
|
};
|
|
1632
1646
|
function cr(e) {
|
|
1633
1647
|
return e.map((t) => {
|
|
1634
1648
|
switch (t.type) {
|
|
1635
1649
|
case "array":
|
|
1636
|
-
return /* @__PURE__ */
|
|
1637
|
-
|
|
1650
|
+
return /* @__PURE__ */ T.jsx(
|
|
1651
|
+
Ot,
|
|
1638
1652
|
{
|
|
1639
1653
|
fieldSchema: t
|
|
1640
1654
|
},
|
|
1641
1655
|
t.name
|
|
1642
1656
|
);
|
|
1643
1657
|
case "object":
|
|
1644
|
-
return /* @__PURE__ */
|
|
1658
|
+
return /* @__PURE__ */ T.jsx(
|
|
1645
1659
|
Mt,
|
|
1646
1660
|
{
|
|
1647
1661
|
fieldSchema: t
|
|
@@ -1649,18 +1663,18 @@ function cr(e) {
|
|
|
1649
1663
|
t.name
|
|
1650
1664
|
);
|
|
1651
1665
|
default:
|
|
1652
|
-
return /* @__PURE__ */
|
|
1666
|
+
return /* @__PURE__ */ T.jsx(Ut, { fieldSchema: t }, t.name);
|
|
1653
1667
|
}
|
|
1654
1668
|
});
|
|
1655
1669
|
}
|
|
1656
|
-
function
|
|
1670
|
+
function Wr(e) {
|
|
1657
1671
|
return e.map((t) => {
|
|
1658
1672
|
if (["object", "array"].includes(t.type)) {
|
|
1659
1673
|
const r = t.fields;
|
|
1660
1674
|
return {
|
|
1661
1675
|
...t,
|
|
1662
1676
|
readonly: !0,
|
|
1663
|
-
fields:
|
|
1677
|
+
fields: Wr(r)
|
|
1664
1678
|
};
|
|
1665
1679
|
}
|
|
1666
1680
|
return {
|
|
@@ -1669,8 +1683,8 @@ function $r(e) {
|
|
|
1669
1683
|
};
|
|
1670
1684
|
});
|
|
1671
1685
|
}
|
|
1672
|
-
const
|
|
1673
|
-
const { onDirtyChange: t, onValuesChange: r } = e, { formState: s, control: o } =
|
|
1686
|
+
const Bt = (e) => {
|
|
1687
|
+
const { onDirtyChange: t, onValuesChange: r } = e, { formState: s, control: o } = ge(), a = Or({
|
|
1674
1688
|
control: o
|
|
1675
1689
|
});
|
|
1676
1690
|
return Pe(() => {
|
|
@@ -1678,92 +1692,94 @@ const Ut = (e) => {
|
|
|
1678
1692
|
}, [a]), Pe(() => {
|
|
1679
1693
|
t(s.isDirty);
|
|
1680
1694
|
}, [s.isDirty]), null;
|
|
1681
|
-
},
|
|
1695
|
+
}, $t = ({
|
|
1682
1696
|
onValuesChange: e,
|
|
1683
1697
|
onDirtyChange: t
|
|
1684
|
-
}) => (
|
|
1698
|
+
}) => (Bt({
|
|
1685
1699
|
onDirtyChange: t,
|
|
1686
1700
|
onValuesChange: e
|
|
1687
|
-
}), null),
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
}));
|
|
1734
|
-
const B = Te(() => cr($), [$]), w = A || R;
|
|
1735
|
-
return /* @__PURE__ */ O.jsxs(lt, { ...g, children: [
|
|
1736
|
-
/* @__PURE__ */ O.jsx(
|
|
1737
|
-
Bt,
|
|
1738
|
-
{
|
|
1739
|
-
onDirtyChange: p,
|
|
1740
|
-
onValuesChange: I
|
|
1741
|
-
}
|
|
1742
|
-
),
|
|
1743
|
-
/* @__PURE__ */ O.jsxs(
|
|
1744
|
-
Dt,
|
|
1745
|
-
{
|
|
1746
|
-
layout: l,
|
|
1747
|
-
uiConfig: o,
|
|
1748
|
-
updateFieldSchema: a,
|
|
1749
|
-
children: [
|
|
1750
|
-
["vertical", "horizontal"].includes(l) && /* @__PURE__ */ O.jsx(
|
|
1751
|
-
"div",
|
|
1752
|
-
{
|
|
1753
|
-
style: {
|
|
1754
|
-
display: "flex",
|
|
1755
|
-
flexDirection: l === "vertical" ? "column" : "row"
|
|
1756
|
-
},
|
|
1757
|
-
children: B
|
|
1758
|
-
}
|
|
1759
|
-
),
|
|
1760
|
-
l === "custom" && B,
|
|
1761
|
-
!w && /* @__PURE__ */ O.jsx("button", { style: { marginTop: "1rem" }, onClick: W, children: "Submit" })
|
|
1762
|
-
]
|
|
1701
|
+
}), null), qt = V.forwardRef(
|
|
1702
|
+
(e, t) => {
|
|
1703
|
+
const {
|
|
1704
|
+
schema: r,
|
|
1705
|
+
onSubmit: s,
|
|
1706
|
+
uiConfig: o = {
|
|
1707
|
+
renderersByName: {},
|
|
1708
|
+
renderersByType: {}
|
|
1709
|
+
},
|
|
1710
|
+
updateFieldSchema: a = {},
|
|
1711
|
+
layout: l = "vertical",
|
|
1712
|
+
values: d = () => ({}),
|
|
1713
|
+
hideSubmit: A = !1,
|
|
1714
|
+
onDirtyChange: p = () => {
|
|
1715
|
+
},
|
|
1716
|
+
onValuesChange: I = () => {
|
|
1717
|
+
},
|
|
1718
|
+
resolver: x,
|
|
1719
|
+
readonly: R
|
|
1720
|
+
} = e, h = kt({
|
|
1721
|
+
reValidateMode: "onSubmit",
|
|
1722
|
+
criteriaMode: "all",
|
|
1723
|
+
resolver: x
|
|
1724
|
+
}), M = et(!1), $ = h.handleSubmit(s), W = Oe(() => {
|
|
1725
|
+
let D = r;
|
|
1726
|
+
return R && (D = Wr(D)), D;
|
|
1727
|
+
}, [R, r]);
|
|
1728
|
+
Pe(() => {
|
|
1729
|
+
if (M.current) return;
|
|
1730
|
+
let D = !1;
|
|
1731
|
+
return (async () => {
|
|
1732
|
+
const m = await d();
|
|
1733
|
+
D || (h.reset(Le(r, m)), M.current = !0);
|
|
1734
|
+
})(), () => {
|
|
1735
|
+
D = !0;
|
|
1736
|
+
};
|
|
1737
|
+
}, [d, r]), rt(t, () => ({
|
|
1738
|
+
submit: async () => {
|
|
1739
|
+
await h.handleSubmit(s)();
|
|
1740
|
+
},
|
|
1741
|
+
reset: (D) => {
|
|
1742
|
+
h.reset(D ? Le(r, D) : void 0);
|
|
1743
|
+
},
|
|
1744
|
+
getValues: () => h.getValues(),
|
|
1745
|
+
setValue: (D, _) => {
|
|
1746
|
+
h.setValue(D, _);
|
|
1763
1747
|
}
|
|
1764
|
-
)
|
|
1765
|
-
|
|
1766
|
-
|
|
1748
|
+
}));
|
|
1749
|
+
const B = Oe(() => cr(W), [W]), w = A || R;
|
|
1750
|
+
return /* @__PURE__ */ T.jsxs(lt, { ...h, children: [
|
|
1751
|
+
/* @__PURE__ */ T.jsx(
|
|
1752
|
+
$t,
|
|
1753
|
+
{
|
|
1754
|
+
onDirtyChange: p,
|
|
1755
|
+
onValuesChange: I
|
|
1756
|
+
}
|
|
1757
|
+
),
|
|
1758
|
+
/* @__PURE__ */ T.jsxs(
|
|
1759
|
+
Dt,
|
|
1760
|
+
{
|
|
1761
|
+
layout: l,
|
|
1762
|
+
uiConfig: o,
|
|
1763
|
+
updateFieldSchema: a,
|
|
1764
|
+
children: [
|
|
1765
|
+
["vertical", "horizontal"].includes(l) && /* @__PURE__ */ T.jsx(
|
|
1766
|
+
"div",
|
|
1767
|
+
{
|
|
1768
|
+
style: {
|
|
1769
|
+
display: "flex",
|
|
1770
|
+
flexDirection: l === "vertical" ? "column" : "row"
|
|
1771
|
+
},
|
|
1772
|
+
children: B
|
|
1773
|
+
}
|
|
1774
|
+
),
|
|
1775
|
+
l === "custom" && B,
|
|
1776
|
+
!w && /* @__PURE__ */ T.jsx("button", { style: { marginTop: "1rem" }, onClick: $, children: "Submit" })
|
|
1777
|
+
]
|
|
1778
|
+
}
|
|
1779
|
+
)
|
|
1780
|
+
] });
|
|
1781
|
+
}
|
|
1782
|
+
);
|
|
1767
1783
|
export {
|
|
1768
|
-
|
|
1784
|
+
qt as AutoForm
|
|
1769
1785
|
};
|