suprform 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +536 -499
- package/dist/components/FormControl.d.ts +7 -0
- package/dist/components/FormControl.d.ts.map +1 -0
- package/dist/components/FormControlArray.d.ts +4 -0
- package/dist/components/FormControlArray.d.ts.map +1 -0
- 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 +611 -605
- package/dist/suprform.es.js.map +1 -1
- package/package.json +6 -3
package/dist/suprform.es.js
CHANGED
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
var ve = (t) => t.type === "checkbox",
|
|
4
|
-
const
|
|
5
|
-
var
|
|
1
|
+
import { jsx as se, jsxs as ft, Fragment as Gt } from "react/jsx-runtime";
|
|
2
|
+
import F, { createContext as zt, useContext as Kt, useMemo as he, cloneElement as Ae, useImperativeHandle as At, Children as Yt, isValidElement as Jt, useEffect as Xt } from "react";
|
|
3
|
+
var ve = (t) => t.type === "checkbox", oe = (t) => t instanceof Date, G = (t) => t == null;
|
|
4
|
+
const pt = (t) => typeof t == "object";
|
|
5
|
+
var W = (t) => !G(t) && !Array.isArray(t) && pt(t) && !oe(t), xt = (t) => W(t) && t.target ? ve(t.target) ? t.target.checked : t.target.value : t, Zt = (t) => t.substring(0, t.search(/\.\d+(\.|$)/)) || t, St = (t, r) => t.has(Zt(r)), er = (t) => {
|
|
6
6
|
const r = t.constructor && t.constructor.prototype;
|
|
7
|
-
return
|
|
7
|
+
return W(r) && r.hasOwnProperty("isPrototypeOf");
|
|
8
8
|
}, ze = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
9
|
-
function
|
|
10
|
-
let r;
|
|
11
|
-
const e = Array.isArray(t), s = typeof FileList < "u" ? t instanceof FileList : !1;
|
|
9
|
+
function L(t) {
|
|
12
10
|
if (t instanceof Date)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
r = t;
|
|
17
|
-
else
|
|
18
|
-
for (const u in t)
|
|
19
|
-
t.hasOwnProperty(u) && (r[u] = U(t[u]));
|
|
20
|
-
else
|
|
11
|
+
return new Date(t);
|
|
12
|
+
const r = typeof FileList < "u" && t instanceof FileList;
|
|
13
|
+
if (ze && (t instanceof Blob || r))
|
|
21
14
|
return t;
|
|
22
|
-
|
|
15
|
+
const e = Array.isArray(t);
|
|
16
|
+
if (!e && !(W(t) && er(t)))
|
|
17
|
+
return t;
|
|
18
|
+
const s = e ? [] : Object.create(Object.getPrototypeOf(t));
|
|
19
|
+
for (const u in t)
|
|
20
|
+
Object.prototype.hasOwnProperty.call(t, u) && (s[u] = L(t[u]));
|
|
21
|
+
return s;
|
|
23
22
|
}
|
|
24
|
-
var Ee = (t) => /^\w*$/.test(t),
|
|
25
|
-
if (!r || !
|
|
23
|
+
var Ee = (t) => /^\w*$/.test(t), U = (t) => t === void 0, we = (t) => Array.isArray(t) ? t.filter(Boolean) : [], Ke = (t) => we(t.replace(/["|']|\]/g, "").split(/\.|\[/)), m = (t, r, e) => {
|
|
24
|
+
if (!r || !W(t))
|
|
26
25
|
return e;
|
|
27
26
|
const s = (Ee(r) ? [r] : Ke(r)).reduce((u, i) => G(u) ? u : u[i], t);
|
|
28
|
-
return
|
|
29
|
-
},
|
|
27
|
+
return U(s) || s === t ? U(t[r]) ? e : t[r] : s;
|
|
28
|
+
}, J = (t) => typeof t == "boolean", Q = (t) => typeof t == "function", R = (t, r, e) => {
|
|
30
29
|
let s = -1;
|
|
31
30
|
const u = Ee(r) ? [r] : Ke(r), i = u.length, c = i - 1;
|
|
32
31
|
for (; ++s < i; ) {
|
|
@@ -34,7 +33,7 @@ var Ee = (t) => /^\w*$/.test(t), O = (t) => t === void 0, we = (t) => Array.isAr
|
|
|
34
33
|
let V = e;
|
|
35
34
|
if (s !== c) {
|
|
36
35
|
const v = t[l];
|
|
37
|
-
V =
|
|
36
|
+
V = W(v) || Array.isArray(v) ? v : isNaN(+u[s + 1]) ? {} : [];
|
|
38
37
|
}
|
|
39
38
|
if (l === "__proto__" || l === "constructor" || l === "prototype")
|
|
40
39
|
return;
|
|
@@ -45,7 +44,7 @@ const pe = {
|
|
|
45
44
|
BLUR: "blur",
|
|
46
45
|
FOCUS_OUT: "focusout",
|
|
47
46
|
CHANGE: "change"
|
|
48
|
-
},
|
|
47
|
+
}, te = {
|
|
49
48
|
onBlur: "onBlur",
|
|
50
49
|
onChange: "onChange",
|
|
51
50
|
onSubmit: "onSubmit",
|
|
@@ -59,13 +58,13 @@ const pe = {
|
|
|
59
58
|
pattern: "pattern",
|
|
60
59
|
required: "required",
|
|
61
60
|
validate: "validate"
|
|
62
|
-
}, Ye =
|
|
61
|
+
}, Ye = F.createContext(null);
|
|
63
62
|
Ye.displayName = "HookFormContext";
|
|
64
|
-
const Ve = () =>
|
|
63
|
+
const Ve = () => F.useContext(Ye), tr = (t) => {
|
|
65
64
|
const { children: r, ...e } = t;
|
|
66
|
-
return
|
|
65
|
+
return F.createElement(Ye.Provider, { value: e }, r);
|
|
67
66
|
};
|
|
68
|
-
var
|
|
67
|
+
var Et = (t, r, e, s = !0) => {
|
|
69
68
|
const u = {
|
|
70
69
|
defaultValues: r._defaultValues
|
|
71
70
|
};
|
|
@@ -73,14 +72,14 @@ var St = (t, r, e, s = !0) => {
|
|
|
73
72
|
Object.defineProperty(u, i, {
|
|
74
73
|
get: () => {
|
|
75
74
|
const c = i;
|
|
76
|
-
return r._proxyFormState[c] !==
|
|
75
|
+
return r._proxyFormState[c] !== te.all && (r._proxyFormState[c] = !s || te.all), e && (e[c] = !0), t[c];
|
|
77
76
|
}
|
|
78
77
|
});
|
|
79
78
|
return u;
|
|
80
79
|
};
|
|
81
|
-
const ke = typeof window < "u" ?
|
|
82
|
-
function
|
|
83
|
-
const r = Ve(), { control: e = r.control, disabled: s, name: u, exact: i } = t || {}, [c, l] =
|
|
80
|
+
const ke = typeof window < "u" ? F.useLayoutEffect : F.useEffect;
|
|
81
|
+
function rr(t) {
|
|
82
|
+
const r = Ve(), { control: e = r.control, disabled: s, name: u, exact: i } = t || {}, [c, l] = F.useState(e._formState), V = F.useRef({
|
|
84
83
|
isDirty: !1,
|
|
85
84
|
isLoading: !1,
|
|
86
85
|
dirtyFields: !1,
|
|
@@ -100,15 +99,15 @@ function tr(t) {
|
|
|
100
99
|
...v
|
|
101
100
|
});
|
|
102
101
|
}
|
|
103
|
-
}), [u, s, i]),
|
|
102
|
+
}), [u, s, i]), F.useEffect(() => {
|
|
104
103
|
V.current.isValid && e._setValid(!0);
|
|
105
|
-
}, [e]),
|
|
104
|
+
}, [e]), F.useMemo(() => Et(c, e, V.current, !1), [c, e]);
|
|
106
105
|
}
|
|
107
|
-
var
|
|
108
|
-
function
|
|
106
|
+
var X = (t) => typeof t == "string", He = (t, r, e, s, u) => X(t) ? (s && r.watch.add(t), m(e, t, u)) : Array.isArray(t) ? t.map((i) => (s && r.watch.add(i), m(e, i))) : (s && (r.watchAll = !0), e), qe = (t) => G(t) || !pt(t);
|
|
107
|
+
function ae(t, r, e = /* @__PURE__ */ new WeakSet()) {
|
|
109
108
|
if (qe(t) || qe(r))
|
|
110
109
|
return Object.is(t, r);
|
|
111
|
-
if (
|
|
110
|
+
if (oe(t) && oe(r))
|
|
112
111
|
return t.getTime() === r.getTime();
|
|
113
112
|
const s = Object.keys(t), u = Object.keys(r);
|
|
114
113
|
if (s.length !== u.length)
|
|
@@ -122,66 +121,66 @@ function te(t, r, e = /* @__PURE__ */ new WeakSet()) {
|
|
|
122
121
|
return !1;
|
|
123
122
|
if (i !== "ref") {
|
|
124
123
|
const l = r[i];
|
|
125
|
-
if (
|
|
124
|
+
if (oe(c) && oe(l) || W(c) && W(l) || Array.isArray(c) && Array.isArray(l) ? !ae(c, l, e) : !Object.is(c, l))
|
|
126
125
|
return !1;
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
return !0;
|
|
130
129
|
}
|
|
131
130
|
function Je(t) {
|
|
132
|
-
const r = Ve(), { control: e = r.control, name: s, defaultValue: u, disabled: i, exact: c, compute: l } = t || {}, V =
|
|
131
|
+
const r = Ve(), { control: e = r.control, name: s, defaultValue: u, disabled: i, exact: c, compute: l } = t || {}, V = F.useRef(u), v = F.useRef(l), w = F.useRef(void 0), g = F.useRef(e), S = F.useRef(s);
|
|
133
132
|
v.current = l;
|
|
134
|
-
const [
|
|
133
|
+
const [p, I] = F.useState(() => {
|
|
135
134
|
const f = e._getWatch(s, V.current);
|
|
136
135
|
return v.current ? v.current(f) : f;
|
|
137
|
-
}),
|
|
136
|
+
}), T = F.useCallback((f) => {
|
|
138
137
|
const d = He(s, e._names, f || e._formValues, !1, V.current);
|
|
139
138
|
return v.current ? v.current(d) : d;
|
|
140
|
-
}, [e._formValues, e._names, s]),
|
|
139
|
+
}, [e._formValues, e._names, s]), M = F.useCallback((f) => {
|
|
141
140
|
if (!i) {
|
|
142
141
|
const d = He(s, e._names, f || e._formValues, !1, V.current);
|
|
143
142
|
if (v.current) {
|
|
144
|
-
const
|
|
145
|
-
|
|
143
|
+
const A = v.current(d);
|
|
144
|
+
ae(A, w.current) || (I(A), w.current = A);
|
|
146
145
|
} else
|
|
147
|
-
|
|
146
|
+
I(d);
|
|
148
147
|
}
|
|
149
148
|
}, [e._formValues, e._names, i, s]);
|
|
150
|
-
ke(() => ((g.current !== e || !
|
|
149
|
+
ke(() => ((g.current !== e || !ae(S.current, s)) && (g.current = e, S.current = s, M()), e._subscribe({
|
|
151
150
|
name: s,
|
|
152
151
|
formState: {
|
|
153
152
|
values: !0
|
|
154
153
|
},
|
|
155
154
|
exact: c,
|
|
156
155
|
callback: (f) => {
|
|
157
|
-
|
|
156
|
+
M(f.values);
|
|
158
157
|
}
|
|
159
|
-
})), [e, c, s,
|
|
160
|
-
const
|
|
158
|
+
})), [e, c, s, M]), F.useEffect(() => e._removeUnmounted());
|
|
159
|
+
const N = g.current !== e, x = S.current, P = F.useMemo(() => {
|
|
161
160
|
if (i)
|
|
162
161
|
return null;
|
|
163
|
-
const f = !
|
|
164
|
-
return
|
|
165
|
-
}, [i,
|
|
166
|
-
return
|
|
162
|
+
const f = !N && !ae(x, s);
|
|
163
|
+
return N || f ? T() : null;
|
|
164
|
+
}, [i, N, s, x, T]);
|
|
165
|
+
return P !== null ? P : p;
|
|
167
166
|
}
|
|
168
|
-
function
|
|
169
|
-
const r = Ve(), { name: e, disabled: s, control: u = r.control, shouldUnregister: i, defaultValue: c, exact: l = !0 } = t, V =
|
|
167
|
+
function sr(t) {
|
|
168
|
+
const r = Ve(), { name: e, disabled: s, control: u = r.control, shouldUnregister: i, defaultValue: c, exact: l = !0 } = t, V = St(u._names.array, e), v = F.useMemo(() => m(u._formValues, e, m(u._defaultValues, e, c)), [u, e, c]), w = Je({
|
|
170
169
|
control: u,
|
|
171
170
|
name: e,
|
|
172
171
|
defaultValue: v,
|
|
173
172
|
exact: l
|
|
174
|
-
}), g =
|
|
173
|
+
}), g = rr({
|
|
175
174
|
control: u,
|
|
176
175
|
name: e,
|
|
177
176
|
exact: l
|
|
178
|
-
}),
|
|
177
|
+
}), S = F.useRef(t), p = F.useRef(void 0), I = F.useRef(u.register(e, {
|
|
179
178
|
...t.rules,
|
|
180
|
-
value:
|
|
181
|
-
...
|
|
179
|
+
value: w,
|
|
180
|
+
...J(t.disabled) ? { disabled: t.disabled } : {}
|
|
182
181
|
}));
|
|
183
|
-
|
|
184
|
-
const
|
|
182
|
+
S.current = t;
|
|
183
|
+
const T = F.useMemo(() => Object.defineProperties({}, {
|
|
185
184
|
invalid: {
|
|
186
185
|
enumerable: !0,
|
|
187
186
|
get: () => !!m(g.errors, e)
|
|
@@ -202,70 +201,70 @@ function rr(t) {
|
|
|
202
201
|
enumerable: !0,
|
|
203
202
|
get: () => m(g.errors, e)
|
|
204
203
|
}
|
|
205
|
-
}), [g, e]),
|
|
204
|
+
}), [g, e]), M = F.useCallback((f) => I.current.onChange({
|
|
206
205
|
target: {
|
|
207
|
-
value:
|
|
206
|
+
value: xt(f),
|
|
208
207
|
name: e
|
|
209
208
|
},
|
|
210
209
|
type: pe.CHANGE
|
|
211
|
-
}), [e]),
|
|
210
|
+
}), [e]), N = F.useCallback(() => I.current.onBlur({
|
|
212
211
|
target: {
|
|
213
212
|
value: m(u._formValues, e),
|
|
214
213
|
name: e
|
|
215
214
|
},
|
|
216
215
|
type: pe.BLUR
|
|
217
|
-
}), [e, u._formValues]),
|
|
216
|
+
}), [e, u._formValues]), x = F.useCallback((f) => {
|
|
218
217
|
const d = m(u._fields, e);
|
|
219
|
-
d && f && (d._f.ref = {
|
|
220
|
-
focus: () => f.focus && f.focus(),
|
|
221
|
-
select: () => f.select && f.select(),
|
|
222
|
-
setCustomValidity: (
|
|
223
|
-
reportValidity: () => f.reportValidity()
|
|
218
|
+
d && d._f && f && (d._f.ref = {
|
|
219
|
+
focus: () => Q(f.focus) && f.focus(),
|
|
220
|
+
select: () => Q(f.select) && f.select(),
|
|
221
|
+
setCustomValidity: (A) => Q(f.setCustomValidity) && f.setCustomValidity(A),
|
|
222
|
+
reportValidity: () => Q(f.reportValidity) && f.reportValidity()
|
|
224
223
|
});
|
|
225
|
-
}, [u._fields, e]),
|
|
224
|
+
}, [u._fields, e]), P = F.useMemo(() => ({
|
|
226
225
|
name: e,
|
|
227
|
-
value:
|
|
228
|
-
...
|
|
229
|
-
onChange:
|
|
230
|
-
onBlur:
|
|
231
|
-
ref:
|
|
232
|
-
}), [e, s, g.disabled,
|
|
233
|
-
return
|
|
234
|
-
const f = u._options.shouldUnregister || i, d =
|
|
226
|
+
value: w,
|
|
227
|
+
...J(s) || g.disabled ? { disabled: g.disabled || s } : {},
|
|
228
|
+
onChange: M,
|
|
229
|
+
onBlur: N,
|
|
230
|
+
ref: x
|
|
231
|
+
}), [e, s, g.disabled, M, N, x, w]);
|
|
232
|
+
return F.useEffect(() => {
|
|
233
|
+
const f = u._options.shouldUnregister || i, d = p.current;
|
|
235
234
|
d && d !== e && !V && u.unregister(d), u.register(e, {
|
|
236
|
-
...
|
|
237
|
-
...
|
|
235
|
+
...S.current.rules,
|
|
236
|
+
...J(S.current.disabled) ? { disabled: S.current.disabled } : {}
|
|
238
237
|
});
|
|
239
|
-
const
|
|
240
|
-
const
|
|
241
|
-
|
|
238
|
+
const A = (k, j) => {
|
|
239
|
+
const K = m(u._fields, k);
|
|
240
|
+
K && K._f && (K._f.mount = j);
|
|
242
241
|
};
|
|
243
|
-
if (
|
|
244
|
-
const
|
|
245
|
-
R(u._defaultValues, e,
|
|
242
|
+
if (A(e, !0), f) {
|
|
243
|
+
const k = L(m(u._options.defaultValues, e, S.current.defaultValue));
|
|
244
|
+
R(u._defaultValues, e, k), U(m(u._formValues, e)) && R(u._formValues, e, k);
|
|
246
245
|
}
|
|
247
|
-
return !V && u.register(e),
|
|
248
|
-
(V ? f && !u._state.action : f) ? u.unregister(e) :
|
|
246
|
+
return !V && u.register(e), p.current = e, () => {
|
|
247
|
+
(V ? f && !u._state.action : f) ? u.unregister(e) : A(e, !1);
|
|
249
248
|
};
|
|
250
|
-
}, [e, u, V, i]),
|
|
249
|
+
}, [e, u, V, i]), F.useEffect(() => {
|
|
251
250
|
u._setDisabledField({
|
|
252
251
|
disabled: s,
|
|
253
252
|
name: e
|
|
254
253
|
});
|
|
255
|
-
}, [s, e, u]),
|
|
256
|
-
field:
|
|
254
|
+
}, [s, e, u]), F.useMemo(() => ({
|
|
255
|
+
field: P,
|
|
257
256
|
formState: g,
|
|
258
|
-
fieldState:
|
|
259
|
-
}), [
|
|
257
|
+
fieldState: T
|
|
258
|
+
}), [P, g, T]);
|
|
260
259
|
}
|
|
261
|
-
const
|
|
262
|
-
var
|
|
260
|
+
const ar = (t) => t.render(sr(t));
|
|
261
|
+
var nr = (t, r, e, s, u) => r ? {
|
|
263
262
|
...e[t],
|
|
264
263
|
types: {
|
|
265
264
|
...e[t] && e[t].types ? e[t].types : {},
|
|
266
265
|
[s]: u || !0
|
|
267
266
|
}
|
|
268
|
-
} : {}, z = (t) => Array.isArray(t) ? t : [t],
|
|
267
|
+
} : {}, z = (t) => Array.isArray(t) ? t : [t], yt = () => {
|
|
269
268
|
let t = [];
|
|
270
269
|
return {
|
|
271
270
|
get observers() {
|
|
@@ -285,75 +284,75 @@ var ar = (t, r, e, s, u) => r ? {
|
|
|
285
284
|
}
|
|
286
285
|
};
|
|
287
286
|
};
|
|
288
|
-
function
|
|
287
|
+
function wt(t, r) {
|
|
289
288
|
const e = {};
|
|
290
289
|
for (const s in t)
|
|
291
290
|
if (t.hasOwnProperty(s)) {
|
|
292
291
|
const u = t[s], i = r[s];
|
|
293
|
-
if (u &&
|
|
294
|
-
const c =
|
|
295
|
-
|
|
292
|
+
if (u && W(u) && i) {
|
|
293
|
+
const c = wt(u, i);
|
|
294
|
+
W(c) && (e[s] = c);
|
|
296
295
|
} else t[s] && (e[s] = i);
|
|
297
296
|
}
|
|
298
297
|
return e;
|
|
299
298
|
}
|
|
300
|
-
var q = (t) =>
|
|
299
|
+
var q = (t) => W(t) && !Object.keys(t).length, Xe = (t) => t.type === "file", xe = (t) => {
|
|
301
300
|
if (!ze)
|
|
302
301
|
return !1;
|
|
303
302
|
const r = t ? t.ownerDocument : 0;
|
|
304
303
|
return t instanceof (r && r.defaultView ? r.defaultView.HTMLElement : HTMLElement);
|
|
305
|
-
},
|
|
306
|
-
function
|
|
304
|
+
}, kt = (t) => t.type === "select-multiple", Ze = (t) => t.type === "radio", ir = (t) => Ze(t) || ve(t), Ue = (t) => xe(t) && t.isConnected;
|
|
305
|
+
function ur(t, r) {
|
|
307
306
|
const e = r.slice(0, -1).length;
|
|
308
307
|
let s = 0;
|
|
309
308
|
for (; s < e; )
|
|
310
|
-
t =
|
|
309
|
+
t = U(t) ? s++ : t[r[s++]];
|
|
311
310
|
return t;
|
|
312
311
|
}
|
|
313
|
-
function
|
|
312
|
+
function or(t) {
|
|
314
313
|
for (const r in t)
|
|
315
|
-
if (t.hasOwnProperty(r) && !
|
|
314
|
+
if (t.hasOwnProperty(r) && !U(t[r]))
|
|
316
315
|
return !1;
|
|
317
316
|
return !0;
|
|
318
317
|
}
|
|
319
318
|
function B(t, r) {
|
|
320
|
-
const e = Array.isArray(r) ? r : Ee(r) ? [r] : Ke(r), s = e.length === 1 ? t :
|
|
321
|
-
return s && delete s[i], u !== 0 && (
|
|
319
|
+
const e = Array.isArray(r) ? r : Ee(r) ? [r] : Ke(r), s = e.length === 1 ? t : ur(t, e), u = e.length - 1, i = e[u];
|
|
320
|
+
return s && delete s[i], u !== 0 && (W(s) && q(s) || Array.isArray(s) && or(s)) && B(t, e.slice(0, -1)), t;
|
|
322
321
|
}
|
|
323
|
-
var
|
|
322
|
+
var lr = (t) => {
|
|
324
323
|
for (const r in t)
|
|
325
|
-
if (
|
|
324
|
+
if (Q(t[r]))
|
|
326
325
|
return !0;
|
|
327
326
|
return !1;
|
|
328
327
|
};
|
|
329
|
-
function
|
|
330
|
-
return Array.isArray(t) ||
|
|
328
|
+
function Ct(t) {
|
|
329
|
+
return Array.isArray(t) || W(t) && !lr(t);
|
|
331
330
|
}
|
|
332
331
|
function je(t, r = {}) {
|
|
333
332
|
for (const e in t) {
|
|
334
333
|
const s = t[e];
|
|
335
|
-
|
|
334
|
+
Ct(s) ? (r[e] = Array.isArray(s) ? [] : {}, je(s, r[e])) : U(s) || (r[e] = !0);
|
|
336
335
|
}
|
|
337
336
|
return r;
|
|
338
337
|
}
|
|
339
|
-
function
|
|
338
|
+
function ce(t, r, e) {
|
|
340
339
|
e || (e = je(r));
|
|
341
340
|
for (const s in t) {
|
|
342
341
|
const u = t[s];
|
|
343
|
-
if (
|
|
344
|
-
|
|
342
|
+
if (Ct(u))
|
|
343
|
+
U(r) || qe(e[s]) ? e[s] = je(u, Array.isArray(u) ? [] : {}) : ce(u, G(r) ? {} : r[s], e[s]);
|
|
345
344
|
else {
|
|
346
345
|
const i = r[s];
|
|
347
|
-
e[s] = !
|
|
346
|
+
e[s] = !ae(u, i);
|
|
348
347
|
}
|
|
349
348
|
}
|
|
350
349
|
return e;
|
|
351
350
|
}
|
|
352
|
-
const
|
|
351
|
+
const mt = {
|
|
353
352
|
value: !1,
|
|
354
353
|
isValid: !1
|
|
355
|
-
},
|
|
356
|
-
var
|
|
354
|
+
}, _t = { value: !0, isValid: !0 };
|
|
355
|
+
var Dt = (t) => {
|
|
357
356
|
if (Array.isArray(t)) {
|
|
358
357
|
if (t.length > 1) {
|
|
359
358
|
const r = t.filter((e) => e && e.checked && !e.disabled).map((e) => e.value);
|
|
@@ -361,24 +360,24 @@ var Ct = (t) => {
|
|
|
361
360
|
}
|
|
362
361
|
return t[0].checked && !t[0].disabled ? (
|
|
363
362
|
// @ts-expect-error expected to work in the browser
|
|
364
|
-
t[0].attributes && !
|
|
365
|
-
) :
|
|
363
|
+
t[0].attributes && !U(t[0].attributes.value) ? U(t[0].value) || t[0].value === "" ? _t : { value: t[0].value, isValid: !0 } : _t
|
|
364
|
+
) : mt;
|
|
366
365
|
}
|
|
367
|
-
return
|
|
368
|
-
},
|
|
369
|
-
const
|
|
366
|
+
return mt;
|
|
367
|
+
}, Rt = (t, { valueAsNumber: r, valueAsDate: e, setValueAs: s }) => U(t) ? t : r ? t === "" ? NaN : t && +t : e && X(t) ? new Date(t) : s ? s(t) : t;
|
|
368
|
+
const gt = {
|
|
370
369
|
isValid: !1,
|
|
371
370
|
value: null
|
|
372
371
|
};
|
|
373
|
-
var
|
|
372
|
+
var Tt = (t) => Array.isArray(t) ? t.reduce((r, e) => e && e.checked && !e.disabled ? {
|
|
374
373
|
isValid: !0,
|
|
375
374
|
value: e.value
|
|
376
|
-
} : r,
|
|
377
|
-
function
|
|
375
|
+
} : r, gt) : gt;
|
|
376
|
+
function ht(t) {
|
|
378
377
|
const r = t.ref;
|
|
379
|
-
return Xe(r) ? r.files : Ze(r) ?
|
|
378
|
+
return Xe(r) ? r.files : Ze(r) ? Tt(t.refs).value : kt(r) ? [...r.selectedOptions].map(({ value: e }) => e) : ve(r) ? Dt(t.refs).value : Rt(U(r.value) ? t.ref.value : r.value, t);
|
|
380
379
|
}
|
|
381
|
-
var
|
|
380
|
+
var cr = (t, r, e, s) => {
|
|
382
381
|
const u = {};
|
|
383
382
|
for (const i of t) {
|
|
384
383
|
const c = m(r, i);
|
|
@@ -390,16 +389,16 @@ var lr = (t, r, e, s) => {
|
|
|
390
389
|
fields: u,
|
|
391
390
|
shouldUseNativeValidation: s
|
|
392
391
|
};
|
|
393
|
-
}, Se = (t) => t instanceof RegExp, ge = (t) =>
|
|
394
|
-
isOnSubmit: !t || t ===
|
|
395
|
-
isOnBlur: t ===
|
|
396
|
-
isOnChange: t ===
|
|
397
|
-
isOnAll: t ===
|
|
398
|
-
isOnTouch: t ===
|
|
392
|
+
}, Se = (t) => t instanceof RegExp, ge = (t) => U(t) ? t : Se(t) ? t.source : W(t) ? Se(t.value) ? t.value.source : t.value : t, de = (t) => ({
|
|
393
|
+
isOnSubmit: !t || t === te.onSubmit,
|
|
394
|
+
isOnBlur: t === te.onBlur,
|
|
395
|
+
isOnChange: t === te.onChange,
|
|
396
|
+
isOnAll: t === te.all,
|
|
397
|
+
isOnTouch: t === te.onTouched
|
|
399
398
|
});
|
|
400
|
-
const
|
|
401
|
-
var
|
|
402
|
-
const
|
|
399
|
+
const vt = "AsyncFunction";
|
|
400
|
+
var dr = (t) => !!t && !!t.validate && !!(Q(t.validate) && t.validate.constructor.name === vt || W(t.validate) && Object.values(t.validate).find((r) => r.constructor.name === vt)), fr = (t) => t.mount && (t.required || t.min || t.max || t.maxLength || t.minLength || t.pattern || t.validate), Qe = (t, r, e) => !e && (r.watchAll || r.watch.has(t) || [...r.watch].some((s) => t.startsWith(s) && /^\.\w+/.test(t.slice(s.length))));
|
|
401
|
+
const fe = (t, r, e, s) => {
|
|
403
402
|
for (const u of e || Object.keys(t)) {
|
|
404
403
|
const i = m(t, u);
|
|
405
404
|
if (i) {
|
|
@@ -409,14 +408,14 @@ const me = (t, r, e, s) => {
|
|
|
409
408
|
return !0;
|
|
410
409
|
if (c.ref && r(c.ref, c.name) && !s)
|
|
411
410
|
return !0;
|
|
412
|
-
if (
|
|
411
|
+
if (fe(l, r))
|
|
413
412
|
break;
|
|
414
|
-
} else if (
|
|
413
|
+
} else if (W(l) && fe(l, r))
|
|
415
414
|
break;
|
|
416
415
|
}
|
|
417
416
|
}
|
|
418
417
|
};
|
|
419
|
-
function
|
|
418
|
+
function Vt(t, r, e) {
|
|
420
419
|
const s = m(t, e);
|
|
421
420
|
if (s || Ee(e))
|
|
422
421
|
return {
|
|
@@ -444,120 +443,120 @@ function vt(t, r, e) {
|
|
|
444
443
|
name: e
|
|
445
444
|
};
|
|
446
445
|
}
|
|
447
|
-
var
|
|
446
|
+
var yr = (t, r, e, s) => {
|
|
448
447
|
e(t);
|
|
449
448
|
const { name: u, ...i } = t;
|
|
450
|
-
return q(i) || Object.keys(i).length >= Object.keys(r).length || Object.keys(i).find((c) => r[c] === (!s ||
|
|
451
|
-
},
|
|
449
|
+
return q(i) || Object.keys(i).length >= Object.keys(r).length || Object.keys(i).find((c) => r[c] === (!s || te.all));
|
|
450
|
+
}, mr = (t, r, e) => !t || !r || t === r || z(t).some((s) => s && (e ? s === r : s.startsWith(r) || r.startsWith(s))), _r = (t, r, e, s, u) => u.isOnAll ? !1 : !e && u.isOnTouch ? !(r || t) : (e ? s.isOnBlur : u.isOnBlur) ? !t : (e ? s.isOnChange : u.isOnChange) ? t : !0, gr = (t, r) => !we(m(t, r)).length && B(t, r), Ot = (t, r, e) => {
|
|
452
451
|
const s = z(m(t, e));
|
|
453
452
|
return R(s, "root", r[e]), R(t, e, s), t;
|
|
454
453
|
};
|
|
455
|
-
function
|
|
456
|
-
if (
|
|
454
|
+
function Ft(t, r, e = "validate") {
|
|
455
|
+
if (X(t) || Array.isArray(t) && t.every(X) || J(t) && !t)
|
|
457
456
|
return {
|
|
458
457
|
type: e,
|
|
459
|
-
message:
|
|
458
|
+
message: X(t) ? t : "",
|
|
460
459
|
ref: r
|
|
461
460
|
};
|
|
462
461
|
}
|
|
463
|
-
var
|
|
462
|
+
var le = (t) => W(t) && !Se(t) ? t : {
|
|
464
463
|
value: t,
|
|
465
464
|
message: ""
|
|
466
465
|
}, Ge = async (t, r, e, s, u, i) => {
|
|
467
|
-
const { ref: c, refs: l, required: V, maxLength: v, minLength:
|
|
468
|
-
if (!
|
|
466
|
+
const { ref: c, refs: l, required: V, maxLength: v, minLength: w, min: g, max: S, pattern: p, validate: I, name: T, valueAsNumber: M, mount: N } = t._f, x = m(e, T);
|
|
467
|
+
if (!N || r.has(T))
|
|
469
468
|
return {};
|
|
470
|
-
const
|
|
471
|
-
u &&
|
|
472
|
-
}, d = {},
|
|
473
|
-
const
|
|
474
|
-
d[
|
|
475
|
-
type:
|
|
476
|
-
message:
|
|
469
|
+
const P = l ? l[0] : c, f = (E) => {
|
|
470
|
+
u && P.reportValidity && (P.setCustomValidity(J(E) ? "" : E || ""), P.reportValidity());
|
|
471
|
+
}, d = {}, A = Ze(c), k = ve(c), j = A || k, K = (M || Xe(c)) && U(c.value) && U(x) || xe(c) && c.value === "" || x === "" || Array.isArray(x) && !x.length, Z = nr.bind(null, T, s, d), Fe = (E, C, $, H = ne.maxLength, re = ne.minLength) => {
|
|
472
|
+
const Y = E ? C : $;
|
|
473
|
+
d[T] = {
|
|
474
|
+
type: E ? H : re,
|
|
475
|
+
message: Y,
|
|
477
476
|
ref: c,
|
|
478
|
-
...
|
|
477
|
+
...Z(E ? H : re, Y)
|
|
479
478
|
};
|
|
480
479
|
};
|
|
481
|
-
if (i ? !Array.isArray(
|
|
482
|
-
const { value:
|
|
483
|
-
if (
|
|
480
|
+
if (i ? !Array.isArray(x) || !x.length : V && (!j && (K || G(x)) || J(x) && !x || k && !Dt(l).isValid || A && !Tt(l).isValid)) {
|
|
481
|
+
const { value: E, message: C } = X(V) ? { value: !!V, message: V } : le(V);
|
|
482
|
+
if (E && (d[T] = {
|
|
484
483
|
type: ne.required,
|
|
485
|
-
message:
|
|
486
|
-
ref:
|
|
487
|
-
...
|
|
484
|
+
message: C,
|
|
485
|
+
ref: P,
|
|
486
|
+
...Z(ne.required, C)
|
|
488
487
|
}, !s))
|
|
489
|
-
return f(
|
|
488
|
+
return f(C), d;
|
|
490
489
|
}
|
|
491
|
-
if (!
|
|
492
|
-
let
|
|
493
|
-
const
|
|
494
|
-
if (!G(
|
|
495
|
-
const
|
|
496
|
-
G(
|
|
490
|
+
if (!K && (!G(g) || !G(S))) {
|
|
491
|
+
let E, C;
|
|
492
|
+
const $ = le(S), H = le(g);
|
|
493
|
+
if (!G(x) && !isNaN(x)) {
|
|
494
|
+
const re = c.valueAsNumber || x && +x;
|
|
495
|
+
G($.value) || (E = re > $.value), G(H.value) || (C = re < H.value);
|
|
497
496
|
} else {
|
|
498
|
-
const
|
|
499
|
-
|
|
497
|
+
const re = c.valueAsDate || new Date(x), Y = (_e) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + _e), ye = c.type == "time", me = c.type == "week";
|
|
498
|
+
X($.value) && x && (E = ye ? Y(x) > Y($.value) : me ? x > $.value : re > new Date($.value)), X(H.value) && x && (C = ye ? Y(x) < Y(H.value) : me ? x < H.value : re < new Date(H.value));
|
|
500
499
|
}
|
|
501
|
-
if ((
|
|
502
|
-
return f(d[
|
|
500
|
+
if ((E || C) && (Fe(!!E, $.message, H.message, ne.max, ne.min), !s))
|
|
501
|
+
return f(d[T].message), d;
|
|
503
502
|
}
|
|
504
|
-
if ((v ||
|
|
505
|
-
const
|
|
506
|
-
if ((
|
|
507
|
-
return f(d[
|
|
503
|
+
if ((v || w) && !K && (X(x) || i && Array.isArray(x))) {
|
|
504
|
+
const E = le(v), C = le(w), $ = !G(E.value) && x.length > +E.value, H = !G(C.value) && x.length < +C.value;
|
|
505
|
+
if (($ || H) && (Fe($, E.message, C.message), !s))
|
|
506
|
+
return f(d[T].message), d;
|
|
508
507
|
}
|
|
509
|
-
if (
|
|
510
|
-
const { value:
|
|
511
|
-
if (Se(
|
|
508
|
+
if (p && !K && X(x)) {
|
|
509
|
+
const { value: E, message: C } = le(p);
|
|
510
|
+
if (Se(E) && !x.match(E) && (d[T] = {
|
|
512
511
|
type: ne.pattern,
|
|
513
|
-
message:
|
|
512
|
+
message: C,
|
|
514
513
|
ref: c,
|
|
515
|
-
...
|
|
514
|
+
...Z(ne.pattern, C)
|
|
516
515
|
}, !s))
|
|
517
|
-
return f(
|
|
516
|
+
return f(C), d;
|
|
518
517
|
}
|
|
519
|
-
if (
|
|
520
|
-
if (
|
|
521
|
-
const
|
|
522
|
-
if (
|
|
523
|
-
...
|
|
524
|
-
...
|
|
518
|
+
if (I) {
|
|
519
|
+
if (Q(I)) {
|
|
520
|
+
const E = await I(x, e), C = Ft(E, P);
|
|
521
|
+
if (C && (d[T] = {
|
|
522
|
+
...C,
|
|
523
|
+
...Z(ne.validate, C.message)
|
|
525
524
|
}, !s))
|
|
526
|
-
return f(
|
|
527
|
-
} else if (
|
|
528
|
-
let
|
|
529
|
-
for (const
|
|
530
|
-
if (!q(
|
|
525
|
+
return f(C.message), d;
|
|
526
|
+
} else if (W(I)) {
|
|
527
|
+
let E = {};
|
|
528
|
+
for (const C in I) {
|
|
529
|
+
if (!q(E) && !s)
|
|
531
530
|
break;
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
...
|
|
536
|
-
}, f(
|
|
531
|
+
const $ = Ft(await I[C](x, e), P, C);
|
|
532
|
+
$ && (E = {
|
|
533
|
+
...$,
|
|
534
|
+
...Z(C, $.message)
|
|
535
|
+
}, f($.message), s && (d[T] = E));
|
|
537
536
|
}
|
|
538
|
-
if (!q(
|
|
539
|
-
ref:
|
|
540
|
-
...
|
|
537
|
+
if (!q(E) && (d[T] = {
|
|
538
|
+
ref: P,
|
|
539
|
+
...E
|
|
541
540
|
}, !s))
|
|
542
541
|
return d;
|
|
543
542
|
}
|
|
544
543
|
}
|
|
545
544
|
return f(!0), d;
|
|
546
545
|
};
|
|
547
|
-
const
|
|
548
|
-
mode:
|
|
549
|
-
reValidateMode:
|
|
546
|
+
const hr = {
|
|
547
|
+
mode: te.onSubmit,
|
|
548
|
+
reValidateMode: te.onChange,
|
|
550
549
|
shouldFocusError: !0
|
|
551
550
|
};
|
|
552
|
-
function
|
|
551
|
+
function vr(t = {}) {
|
|
553
552
|
let r = {
|
|
554
|
-
...
|
|
553
|
+
...hr,
|
|
555
554
|
...t
|
|
556
555
|
}, e = {
|
|
557
556
|
submitCount: 0,
|
|
558
557
|
isDirty: !1,
|
|
559
558
|
isReady: !1,
|
|
560
|
-
isLoading:
|
|
559
|
+
isLoading: Q(r.defaultValues),
|
|
561
560
|
isValidating: !1,
|
|
562
561
|
isSubmitted: !1,
|
|
563
562
|
isSubmitting: !1,
|
|
@@ -568,10 +567,11 @@ function hr(t = {}) {
|
|
|
568
567
|
validatingFields: {},
|
|
569
568
|
errors: r.errors || {},
|
|
570
569
|
disabled: r.disabled || !1
|
|
571
|
-
}, s = {}, u =
|
|
570
|
+
}, s = {}, u = W(r.defaultValues) || W(r.values) ? L(r.defaultValues || r.values) || {} : {}, i = r.shouldUnregister ? {} : L(u), c = {
|
|
572
571
|
action: !1,
|
|
573
572
|
mount: !1,
|
|
574
|
-
watch: !1
|
|
573
|
+
watch: !1,
|
|
574
|
+
keepIsValid: !1
|
|
575
575
|
}, l = {
|
|
576
576
|
mount: /* @__PURE__ */ new Set(),
|
|
577
577
|
disabled: /* @__PURE__ */ new Set(),
|
|
@@ -579,7 +579,7 @@ function hr(t = {}) {
|
|
|
579
579
|
array: /* @__PURE__ */ new Set(),
|
|
580
580
|
watch: /* @__PURE__ */ new Set()
|
|
581
581
|
}, V, v = 0;
|
|
582
|
-
const
|
|
582
|
+
const w = {
|
|
583
583
|
isDirty: !1,
|
|
584
584
|
dirtyFields: !1,
|
|
585
585
|
validatingFields: !1,
|
|
@@ -587,106 +587,104 @@ function hr(t = {}) {
|
|
|
587
587
|
isValidating: !1,
|
|
588
588
|
isValid: !1,
|
|
589
589
|
errors: !1
|
|
590
|
+
}, g = {
|
|
591
|
+
...w
|
|
590
592
|
};
|
|
591
|
-
let
|
|
592
|
-
...
|
|
593
|
+
let S = {
|
|
594
|
+
...g
|
|
593
595
|
};
|
|
594
|
-
const
|
|
595
|
-
array:
|
|
596
|
-
state:
|
|
597
|
-
},
|
|
596
|
+
const p = {
|
|
597
|
+
array: yt(),
|
|
598
|
+
state: yt()
|
|
599
|
+
}, I = r.criteriaMode === te.all, T = (a) => (n) => {
|
|
598
600
|
clearTimeout(v), v = setTimeout(a, n);
|
|
599
|
-
},
|
|
600
|
-
if (!r.disabled && (
|
|
601
|
-
|
|
602
|
-
n !== e.isValid &&
|
|
601
|
+
}, M = async (a) => {
|
|
602
|
+
if (!c.keepIsValid && !r.disabled && (g.isValid || S.isValid || a)) {
|
|
603
|
+
let n;
|
|
604
|
+
r.resolver ? (n = q((await j()).errors), N()) : n = await Z(s, !0), n !== e.isValid && p.state.next({
|
|
603
605
|
isValid: n
|
|
604
606
|
});
|
|
605
607
|
}
|
|
606
608
|
}, N = (a, n) => {
|
|
607
|
-
!r.disabled && (
|
|
609
|
+
!r.disabled && (g.isValidating || g.validatingFields || S.isValidating || S.validatingFields) && ((a || Array.from(l.mount)).forEach((o) => {
|
|
608
610
|
o && (n ? R(e.validatingFields, o, n) : B(e.validatingFields, o));
|
|
609
|
-
}),
|
|
611
|
+
}), p.state.next({
|
|
610
612
|
validatingFields: e.validatingFields,
|
|
611
613
|
isValidating: !q(e.validatingFields)
|
|
612
614
|
}));
|
|
613
|
-
},
|
|
615
|
+
}, x = (a, n = [], o, h, _ = !0, y = !0) => {
|
|
614
616
|
if (h && o && !r.disabled) {
|
|
615
617
|
if (c.action = !0, y && Array.isArray(m(s, a))) {
|
|
616
|
-
const
|
|
617
|
-
_ && R(s, a,
|
|
618
|
+
const b = o(m(s, a), h.argA, h.argB);
|
|
619
|
+
_ && R(s, a, b);
|
|
618
620
|
}
|
|
619
621
|
if (y && Array.isArray(m(e.errors, a))) {
|
|
620
|
-
const
|
|
621
|
-
_ && R(e.errors, a,
|
|
622
|
+
const b = o(m(e.errors, a), h.argA, h.argB);
|
|
623
|
+
_ && R(e.errors, a, b), gr(e.errors, a);
|
|
622
624
|
}
|
|
623
|
-
if ((
|
|
624
|
-
const
|
|
625
|
-
_ && R(e.touchedFields, a,
|
|
625
|
+
if ((g.touchedFields || S.touchedFields) && y && Array.isArray(m(e.touchedFields, a))) {
|
|
626
|
+
const b = o(m(e.touchedFields, a), h.argA, h.argB);
|
|
627
|
+
_ && R(e.touchedFields, a, b);
|
|
626
628
|
}
|
|
627
|
-
(
|
|
629
|
+
(g.dirtyFields || S.dirtyFields) && (e.dirtyFields = ce(u, i)), p.state.next({
|
|
628
630
|
name: a,
|
|
629
|
-
isDirty:
|
|
631
|
+
isDirty: E(a, n),
|
|
630
632
|
dirtyFields: e.dirtyFields,
|
|
631
633
|
errors: e.errors,
|
|
632
634
|
isValid: e.isValid
|
|
633
635
|
});
|
|
634
636
|
} else
|
|
635
637
|
R(i, a, n);
|
|
636
|
-
},
|
|
637
|
-
R(e.errors, a, n),
|
|
638
|
+
}, P = (a, n) => {
|
|
639
|
+
R(e.errors, a, n), p.state.next({
|
|
638
640
|
errors: e.errors
|
|
639
641
|
});
|
|
640
|
-
},
|
|
641
|
-
e.errors = a,
|
|
642
|
+
}, f = (a) => {
|
|
643
|
+
e.errors = a, p.state.next({
|
|
642
644
|
errors: e.errors,
|
|
643
645
|
isValid: !1
|
|
644
646
|
});
|
|
645
|
-
},
|
|
647
|
+
}, d = (a, n, o, h) => {
|
|
646
648
|
const _ = m(s, a);
|
|
647
649
|
if (_) {
|
|
648
|
-
const y = m(i, a,
|
|
649
|
-
|
|
650
|
+
const y = m(i, a, U(o) ? m(u, a) : o);
|
|
651
|
+
U(y) || h && h.defaultChecked || n ? R(i, a, n ? y : ht(_._f)) : H(a, y), c.mount && !c.action && M();
|
|
650
652
|
}
|
|
651
|
-
},
|
|
652
|
-
let y = !1,
|
|
653
|
-
const
|
|
653
|
+
}, A = (a, n, o, h, _) => {
|
|
654
|
+
let y = !1, b = !1;
|
|
655
|
+
const D = {
|
|
654
656
|
name: a
|
|
655
657
|
};
|
|
656
658
|
if (!r.disabled) {
|
|
657
659
|
if (!o || h) {
|
|
658
|
-
(
|
|
659
|
-
const
|
|
660
|
-
|
|
660
|
+
(g.isDirty || S.isDirty) && (b = e.isDirty, e.isDirty = D.isDirty = E(), y = b !== D.isDirty);
|
|
661
|
+
const O = ae(m(u, a), n);
|
|
662
|
+
b = !!m(e.dirtyFields, a), O ? B(e.dirtyFields, a) : R(e.dirtyFields, a, !0), D.dirtyFields = e.dirtyFields, y = y || (g.dirtyFields || S.dirtyFields) && b !== !O;
|
|
661
663
|
}
|
|
662
664
|
if (o) {
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
+
const O = m(e.touchedFields, a);
|
|
666
|
+
O || (R(e.touchedFields, a, o), D.touchedFields = e.touchedFields, y = y || (g.touchedFields || S.touchedFields) && O !== o);
|
|
665
667
|
}
|
|
666
|
-
y && _ &&
|
|
668
|
+
y && _ && p.state.next(D);
|
|
667
669
|
}
|
|
668
|
-
return y ?
|
|
669
|
-
},
|
|
670
|
-
const _ = m(e.errors, a), y = (
|
|
671
|
-
if (r.delayError && o ? (V =
|
|
672
|
-
const
|
|
670
|
+
return y ? D : {};
|
|
671
|
+
}, k = (a, n, o, h) => {
|
|
672
|
+
const _ = m(e.errors, a), y = (g.isValid || S.isValid) && J(n) && e.isValid !== n;
|
|
673
|
+
if (r.delayError && o ? (V = T(() => P(a, o)), V(r.delayError)) : (clearTimeout(v), V = null, o ? R(e.errors, a, o) : B(e.errors, a)), (o ? !ae(_, o) : _) || !q(h) || y) {
|
|
674
|
+
const b = {
|
|
673
675
|
...h,
|
|
674
|
-
...y &&
|
|
676
|
+
...y && J(n) ? { isValid: n } : {},
|
|
675
677
|
errors: e.errors,
|
|
676
678
|
name: a
|
|
677
679
|
};
|
|
678
680
|
e = {
|
|
679
681
|
...e,
|
|
680
|
-
...
|
|
681
|
-
},
|
|
682
|
+
...b
|
|
683
|
+
}, p.state.next(b);
|
|
682
684
|
}
|
|
683
|
-
},
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
return N(a), n;
|
|
687
|
-
}, Z = async (a) => {
|
|
688
|
-
const { errors: n } = await E(a);
|
|
689
|
-
if (a)
|
|
685
|
+
}, j = async (a) => (N(a, !0), await r.resolver(i, r.context, cr(a || l.mount, s, r.criteriaMode, r.shouldUseNativeValidation))), K = async (a) => {
|
|
686
|
+
const { errors: n } = await j(a);
|
|
687
|
+
if (N(a), a)
|
|
690
688
|
for (const o of a) {
|
|
691
689
|
const h = m(n, o);
|
|
692
690
|
h ? R(e.errors, o, h) : B(e.errors, o);
|
|
@@ -694,169 +692,172 @@ function hr(t = {}) {
|
|
|
694
692
|
else
|
|
695
693
|
e.errors = n;
|
|
696
694
|
return n;
|
|
697
|
-
},
|
|
695
|
+
}, Z = async (a, n, o = {
|
|
698
696
|
valid: !0
|
|
699
697
|
}) => {
|
|
700
698
|
for (const h in a) {
|
|
701
699
|
const _ = a[h];
|
|
702
700
|
if (_) {
|
|
703
|
-
const { _f: y, ...
|
|
701
|
+
const { _f: y, ...b } = _;
|
|
704
702
|
if (y) {
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
const
|
|
708
|
-
if (
|
|
703
|
+
const D = l.array.has(y.name), O = _._f && dr(_._f);
|
|
704
|
+
O && g.validatingFields && N([y.name], !0);
|
|
705
|
+
const ee = await Ge(_, l.disabled, i, I, r.shouldUseNativeValidation && !n, D);
|
|
706
|
+
if (O && g.validatingFields && N([y.name]), ee[y.name] && (o.valid = !1, n))
|
|
709
707
|
break;
|
|
710
|
-
!n && (m(
|
|
708
|
+
!n && (m(ee, y.name) ? D ? Ot(e.errors, ee, y.name) : R(e.errors, y.name, ee[y.name]) : B(e.errors, y.name));
|
|
711
709
|
}
|
|
712
|
-
!q(
|
|
710
|
+
!q(b) && await Z(b, n, o);
|
|
713
711
|
}
|
|
714
712
|
}
|
|
715
713
|
return o.valid;
|
|
716
|
-
},
|
|
714
|
+
}, Fe = () => {
|
|
717
715
|
for (const a of l.unMount) {
|
|
718
716
|
const n = m(s, a);
|
|
719
717
|
n && (n._f.refs ? n._f.refs.every((o) => !Ue(o)) : !Ue(n._f.ref)) && Ce(a);
|
|
720
718
|
}
|
|
721
719
|
l.unMount = /* @__PURE__ */ new Set();
|
|
722
|
-
},
|
|
723
|
-
...c.mount ? i :
|
|
724
|
-
}, o, n),
|
|
720
|
+
}, E = (a, n) => !r.disabled && (a && n && R(i, a, n), !ae(tt(), u)), C = (a, n, o) => He(a, l, {
|
|
721
|
+
...c.mount ? i : U(n) ? u : X(a) ? { [a]: n } : n
|
|
722
|
+
}, o, n), $ = (a) => we(m(c.mount ? i : u, a, r.shouldUnregister ? m(u, a, []) : [])), H = (a, n, o = {}) => {
|
|
725
723
|
const h = m(s, a);
|
|
726
724
|
let _ = n;
|
|
727
725
|
if (h) {
|
|
728
726
|
const y = h._f;
|
|
729
|
-
y && (!y.disabled && R(i, a,
|
|
730
|
-
(!
|
|
731
|
-
}) : y.refs.forEach((
|
|
727
|
+
y && (!y.disabled && R(i, a, Rt(n, y)), _ = xe(y.ref) && G(n) ? "" : n, kt(y.ref) ? [...y.ref.options].forEach((b) => b.selected = _.includes(b.value)) : y.refs ? ve(y.ref) ? y.refs.forEach((b) => {
|
|
728
|
+
(!b.defaultChecked || !b.disabled) && (Array.isArray(_) ? b.checked = !!_.find((D) => D === b.value) : b.checked = _ === b.value || !!_);
|
|
729
|
+
}) : y.refs.forEach((b) => b.checked = b.value === _) : Xe(y.ref) ? y.ref.value = "" : (y.ref.value = _, y.ref.type || p.state.next({
|
|
732
730
|
name: a,
|
|
733
|
-
values:
|
|
731
|
+
values: L(i)
|
|
734
732
|
})));
|
|
735
733
|
}
|
|
736
|
-
(o.shouldDirty || o.shouldTouch) &&
|
|
737
|
-
},
|
|
734
|
+
(o.shouldDirty || o.shouldTouch) && A(a, _, o.shouldTouch, o.shouldDirty, !0), o.shouldValidate && _e(a);
|
|
735
|
+
}, re = (a, n, o) => {
|
|
738
736
|
for (const h in n) {
|
|
739
737
|
if (!n.hasOwnProperty(h))
|
|
740
738
|
return;
|
|
741
|
-
const _ = n[h], y = a + "." + h,
|
|
742
|
-
(l.array.has(a) ||
|
|
739
|
+
const _ = n[h], y = a + "." + h, b = m(s, y);
|
|
740
|
+
(l.array.has(a) || W(_) || b && !b._f) && !oe(_) ? re(y, _, o) : H(y, _, o);
|
|
743
741
|
}
|
|
744
|
-
},
|
|
745
|
-
const h = m(s, a), _ = l.array.has(a), y =
|
|
746
|
-
R(i, a, y), _ ? (
|
|
742
|
+
}, Y = (a, n, o = {}) => {
|
|
743
|
+
const h = m(s, a), _ = l.array.has(a), y = L(n);
|
|
744
|
+
R(i, a, y), _ ? (p.array.next({
|
|
747
745
|
name: a,
|
|
748
|
-
values:
|
|
749
|
-
}), (
|
|
746
|
+
values: L(i)
|
|
747
|
+
}), (g.isDirty || g.dirtyFields || S.isDirty || S.dirtyFields) && o.shouldDirty && p.state.next({
|
|
750
748
|
name: a,
|
|
751
|
-
dirtyFields:
|
|
752
|
-
isDirty:
|
|
753
|
-
})) : h && !h._f && !G(y) ?
|
|
749
|
+
dirtyFields: ce(u, i),
|
|
750
|
+
isDirty: E(a, y)
|
|
751
|
+
})) : h && !h._f && !G(y) ? re(a, y, o) : H(a, y, o), Qe(a, l) && p.state.next({ ...e, name: a }), p.state.next({
|
|
754
752
|
name: c.mount ? a : void 0,
|
|
755
|
-
values:
|
|
753
|
+
values: L(i)
|
|
756
754
|
});
|
|
757
|
-
},
|
|
755
|
+
}, ye = async (a) => {
|
|
758
756
|
c.mount = !0;
|
|
759
757
|
const n = a.target;
|
|
760
758
|
let o = n.name, h = !0;
|
|
761
|
-
const _ = m(s, o), y = (
|
|
762
|
-
h = Number.isNaN(
|
|
763
|
-
},
|
|
759
|
+
const _ = m(s, o), y = (O) => {
|
|
760
|
+
h = Number.isNaN(O) || oe(O) && isNaN(O.getTime()) || ae(O, m(i, o, O));
|
|
761
|
+
}, b = de(r.mode), D = de(r.reValidateMode);
|
|
764
762
|
if (_) {
|
|
765
|
-
let
|
|
766
|
-
const be = n.type ?
|
|
763
|
+
let O, ee;
|
|
764
|
+
const be = n.type ? ht(_._f) : xt(a), ie = a.type === pe.BLUR || a.type === pe.FOCUS_OUT, qt = !fr(_._f) && !r.resolver && !m(e.errors, o) && !_._f.deps || _r(ie, m(e.touchedFields, o), e.isSubmitted, D, b), Te = Qe(o, l, ie);
|
|
767
765
|
R(i, o, be), ie ? (!n || !n.readOnly) && (_._f.onBlur && _._f.onBlur(a), V && V(0)) : _._f.onChange && _._f.onChange(a);
|
|
768
|
-
const Oe =
|
|
769
|
-
if (!ie &&
|
|
766
|
+
const Oe = A(o, be, ie), jt = !q(Oe) || Te;
|
|
767
|
+
if (!ie && p.state.next({
|
|
770
768
|
name: o,
|
|
771
769
|
type: a.type,
|
|
772
|
-
values:
|
|
773
|
-
}),
|
|
774
|
-
return (
|
|
775
|
-
if (!ie && Te &&
|
|
776
|
-
const { errors:
|
|
777
|
-
if (y(be), h) {
|
|
778
|
-
const
|
|
779
|
-
|
|
770
|
+
values: L(i)
|
|
771
|
+
}), qt)
|
|
772
|
+
return (g.isValid || S.isValid) && (r.mode === "onBlur" ? ie && M() : ie || M()), jt && p.state.next({ name: o, ...Te ? {} : Oe });
|
|
773
|
+
if (!ie && Te && p.state.next({ ...e }), r.resolver) {
|
|
774
|
+
const { errors: ct } = await j([o]);
|
|
775
|
+
if (N([o]), y(be), h) {
|
|
776
|
+
const Qt = Vt(e.errors, s, o), dt = Vt(ct, s, Qt.name || o);
|
|
777
|
+
O = dt.error, o = dt.name, ee = q(ct);
|
|
780
778
|
}
|
|
781
779
|
} else
|
|
782
|
-
N([o], !0),
|
|
783
|
-
h && (_._f.deps && (!Array.isArray(_._f.deps) || _._f.deps.length > 0) &&
|
|
780
|
+
N([o], !0), O = (await Ge(_, l.disabled, i, I, r.shouldUseNativeValidation))[o], N([o]), y(be), h && (O ? ee = !1 : (g.isValid || S.isValid) && (ee = await Z(s, !0)));
|
|
781
|
+
h && (_._f.deps && (!Array.isArray(_._f.deps) || _._f.deps.length > 0) && _e(_._f.deps), k(o, ee, O, Oe));
|
|
784
782
|
}
|
|
785
|
-
},
|
|
783
|
+
}, me = (a, n) => {
|
|
786
784
|
if (m(e.errors, n) && a.focus)
|
|
787
785
|
return a.focus(), 1;
|
|
788
|
-
},
|
|
786
|
+
}, _e = async (a, n = {}) => {
|
|
789
787
|
let o, h;
|
|
790
788
|
const _ = z(a);
|
|
791
789
|
if (r.resolver) {
|
|
792
|
-
const y = await
|
|
793
|
-
o = q(y), h = a ? !_.some((
|
|
790
|
+
const y = await K(U(a) ? a : _);
|
|
791
|
+
o = q(y), h = a ? !_.some((b) => m(y, b)) : o;
|
|
794
792
|
} else a ? (h = (await Promise.all(_.map(async (y) => {
|
|
795
|
-
const
|
|
796
|
-
return await
|
|
797
|
-
}))).every(Boolean), !(!h && !e.isValid) &&
|
|
798
|
-
return
|
|
799
|
-
...!
|
|
793
|
+
const b = m(s, y);
|
|
794
|
+
return await Z(b && b._f ? { [y]: b } : b);
|
|
795
|
+
}))).every(Boolean), !(!h && !e.isValid) && M()) : h = o = await Z(s);
|
|
796
|
+
return p.state.next({
|
|
797
|
+
...!X(a) || (g.isValid || S.isValid) && o !== e.isValid ? {} : { name: a },
|
|
800
798
|
...r.resolver || !a ? { isValid: o } : {},
|
|
801
799
|
errors: e.errors
|
|
802
|
-
}), n.shouldFocus && !h &&
|
|
803
|
-
},
|
|
800
|
+
}), n.shouldFocus && !h && fe(s, me, a ? _ : l.mount), h;
|
|
801
|
+
}, tt = (a, n) => {
|
|
804
802
|
let o = {
|
|
805
803
|
...c.mount ? i : u
|
|
806
804
|
};
|
|
807
|
-
return n && (o =
|
|
808
|
-
},
|
|
805
|
+
return n && (o = wt(n.dirtyFields ? e.dirtyFields : e.touchedFields, o)), U(a) ? o : X(a) ? m(o, a) : a.map((h) => m(o, h));
|
|
806
|
+
}, rt = (a, n) => ({
|
|
809
807
|
invalid: !!m((n || e).errors, a),
|
|
810
808
|
isDirty: !!m((n || e).dirtyFields, a),
|
|
811
809
|
error: m((n || e).errors, a),
|
|
812
810
|
isValidating: !!m(e.validatingFields, a),
|
|
813
811
|
isTouched: !!m((n || e).touchedFields, a)
|
|
814
|
-
}),
|
|
815
|
-
a && z(a).forEach((n) => B(e.errors, n)),
|
|
812
|
+
}), Mt = (a) => {
|
|
813
|
+
a && z(a).forEach((n) => B(e.errors, n)), p.state.next({
|
|
816
814
|
errors: a ? e.errors : {}
|
|
817
815
|
});
|
|
818
|
-
},
|
|
819
|
-
const h = (m(s, a, { _f: {} })._f || {}).ref, _ = m(e.errors, a) || {}, { ref: y, message:
|
|
816
|
+
}, st = (a, n, o) => {
|
|
817
|
+
const h = (m(s, a, { _f: {} })._f || {}).ref, _ = m(e.errors, a) || {}, { ref: y, message: b, type: D, ...O } = _;
|
|
820
818
|
R(e.errors, a, {
|
|
821
|
-
...
|
|
819
|
+
...O,
|
|
822
820
|
...n,
|
|
823
821
|
ref: h
|
|
824
|
-
}),
|
|
822
|
+
}), p.state.next({
|
|
825
823
|
name: a,
|
|
826
824
|
errors: e.errors,
|
|
827
825
|
isValid: !1
|
|
828
826
|
}), o && o.shouldFocus && h && h.focus && h.focus();
|
|
829
|
-
},
|
|
830
|
-
next: (o) => "values" in o && a(
|
|
831
|
-
}) :
|
|
827
|
+
}, It = (a, n) => Q(a) ? p.state.subscribe({
|
|
828
|
+
next: (o) => "values" in o && a(C(void 0, n), o)
|
|
829
|
+
}) : C(a, n, !0), at = (a) => p.state.subscribe({
|
|
832
830
|
next: (n) => {
|
|
833
|
-
|
|
831
|
+
mr(a.name, n.name, a.exact) && yr(n, a.formState || g, Ht, a.reRenderRoot) && a.callback({
|
|
834
832
|
values: { ...i },
|
|
835
833
|
...e,
|
|
836
834
|
...n,
|
|
837
835
|
defaultValues: u
|
|
838
836
|
});
|
|
839
837
|
}
|
|
840
|
-
}).unsubscribe,
|
|
841
|
-
...
|
|
838
|
+
}).unsubscribe, Pt = (a) => (c.mount = !0, S = {
|
|
839
|
+
...S,
|
|
842
840
|
...a.formState
|
|
843
|
-
},
|
|
841
|
+
}, at({
|
|
844
842
|
...a,
|
|
845
|
-
formState:
|
|
843
|
+
formState: {
|
|
844
|
+
...w,
|
|
845
|
+
...a.formState
|
|
846
|
+
}
|
|
846
847
|
})), Ce = (a, n = {}) => {
|
|
847
848
|
for (const o of a ? z(a) : l.mount)
|
|
848
849
|
l.mount.delete(o), l.array.delete(o), n.keepValue || (B(s, o), B(i, o)), !n.keepError && B(e.errors, o), !n.keepDirty && B(e.dirtyFields, o), !n.keepTouched && B(e.touchedFields, o), !n.keepIsValidating && B(e.validatingFields, o), !r.shouldUnregister && !n.keepDefaultValue && B(u, o);
|
|
849
|
-
|
|
850
|
-
values:
|
|
851
|
-
}),
|
|
850
|
+
p.state.next({
|
|
851
|
+
values: L(i)
|
|
852
|
+
}), p.state.next({
|
|
852
853
|
...e,
|
|
853
|
-
...n.keepDirty ? { isDirty:
|
|
854
|
-
}), !n.keepIsValid &&
|
|
855
|
-
},
|
|
856
|
-
(
|
|
854
|
+
...n.keepDirty ? { isDirty: E() } : {}
|
|
855
|
+
}), !n.keepIsValid && M();
|
|
856
|
+
}, nt = ({ disabled: a, name: n }) => {
|
|
857
|
+
(J(a) && c.mount || a || l.disabled.has(n)) && (a ? l.disabled.add(n) : l.disabled.delete(n));
|
|
857
858
|
}, De = (a, n = {}) => {
|
|
858
859
|
let o = m(s, a);
|
|
859
|
-
const h =
|
|
860
|
+
const h = J(n.disabled) || J(r.disabled);
|
|
860
861
|
return R(s, a, {
|
|
861
862
|
...o || {},
|
|
862
863
|
_f: {
|
|
@@ -865,10 +866,10 @@ function hr(t = {}) {
|
|
|
865
866
|
mount: !0,
|
|
866
867
|
...n
|
|
867
868
|
}
|
|
868
|
-
}), l.mount.add(a), o ?
|
|
869
|
-
disabled:
|
|
869
|
+
}), l.mount.add(a), o ? nt({
|
|
870
|
+
disabled: J(n.disabled) ? n.disabled : r.disabled,
|
|
870
871
|
name: a
|
|
871
|
-
}) :
|
|
872
|
+
}) : d(a, !0, n.value), {
|
|
872
873
|
...h ? { disabled: n.disabled || r.disabled } : {},
|
|
873
874
|
...r.progressive ? {
|
|
874
875
|
required: !!n.required,
|
|
@@ -879,54 +880,54 @@ function hr(t = {}) {
|
|
|
879
880
|
pattern: ge(n.pattern)
|
|
880
881
|
} : {},
|
|
881
882
|
name: a,
|
|
882
|
-
onChange:
|
|
883
|
-
onBlur:
|
|
883
|
+
onChange: ye,
|
|
884
|
+
onBlur: ye,
|
|
884
885
|
ref: (_) => {
|
|
885
886
|
if (_) {
|
|
886
887
|
De(a, n), o = m(s, a);
|
|
887
|
-
const y =
|
|
888
|
-
if (
|
|
888
|
+
const y = U(_.value) && _.querySelectorAll && _.querySelectorAll("input,select,textarea")[0] || _, b = ir(y), D = o._f.refs || [];
|
|
889
|
+
if (b ? D.find((O) => O === y) : y === o._f.ref)
|
|
889
890
|
return;
|
|
890
891
|
R(s, a, {
|
|
891
892
|
_f: {
|
|
892
893
|
...o._f,
|
|
893
|
-
...
|
|
894
|
+
...b ? {
|
|
894
895
|
refs: [
|
|
895
|
-
...
|
|
896
|
+
...D.filter(Ue),
|
|
896
897
|
y,
|
|
897
898
|
...Array.isArray(m(u, a)) ? [{}] : []
|
|
898
899
|
],
|
|
899
900
|
ref: { type: y.type, name: a }
|
|
900
901
|
} : { ref: y }
|
|
901
902
|
}
|
|
902
|
-
}),
|
|
903
|
+
}), d(a, !1, void 0, y);
|
|
903
904
|
} else
|
|
904
|
-
o = m(s, a, {}), o._f && (o._f.mount = !1), (r.shouldUnregister || n.shouldUnregister) && !(
|
|
905
|
+
o = m(s, a, {}), o._f && (o._f.mount = !1), (r.shouldUnregister || n.shouldUnregister) && !(St(l.array, a) && c.action) && l.unMount.add(a);
|
|
905
906
|
}
|
|
906
907
|
};
|
|
907
|
-
}, Re = () => r.shouldFocusError &&
|
|
908
|
-
|
|
908
|
+
}, Re = () => r.shouldFocusError && fe(s, me, l.mount), Bt = (a) => {
|
|
909
|
+
J(a) && (p.state.next({ disabled: a }), fe(s, (n, o) => {
|
|
909
910
|
const h = m(s, o);
|
|
910
911
|
h && (n.disabled = h._f.disabled || a, Array.isArray(h._f.refs) && h._f.refs.forEach((_) => {
|
|
911
912
|
_.disabled = h._f.disabled || a;
|
|
912
913
|
}));
|
|
913
914
|
}, 0, !1));
|
|
914
|
-
},
|
|
915
|
+
}, it = (a, n) => async (o) => {
|
|
915
916
|
let h;
|
|
916
917
|
o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
|
|
917
|
-
let _ =
|
|
918
|
-
if (
|
|
918
|
+
let _ = L(i);
|
|
919
|
+
if (p.state.next({
|
|
919
920
|
isSubmitting: !0
|
|
920
921
|
}), r.resolver) {
|
|
921
|
-
const { errors: y, values:
|
|
922
|
-
e.errors = y, _ =
|
|
922
|
+
const { errors: y, values: b } = await j();
|
|
923
|
+
N(), e.errors = y, _ = L(b);
|
|
923
924
|
} else
|
|
924
|
-
await
|
|
925
|
+
await Z(s);
|
|
925
926
|
if (l.disabled.size)
|
|
926
927
|
for (const y of l.disabled)
|
|
927
928
|
B(_, y);
|
|
928
929
|
if (B(e.errors, "root"), q(e.errors)) {
|
|
929
|
-
|
|
930
|
+
p.state.next({
|
|
930
931
|
errors: {}
|
|
931
932
|
});
|
|
932
933
|
try {
|
|
@@ -936,7 +937,7 @@ function hr(t = {}) {
|
|
|
936
937
|
}
|
|
937
938
|
} else
|
|
938
939
|
n && await n({ ...e.errors }, o), Re(), setTimeout(Re);
|
|
939
|
-
if (
|
|
940
|
+
if (p.state.next({
|
|
940
941
|
isSubmitted: !0,
|
|
941
942
|
isSubmitting: !1,
|
|
942
943
|
isSubmitSuccessful: q(e.errors) && !h,
|
|
@@ -944,42 +945,42 @@ function hr(t = {}) {
|
|
|
944
945
|
errors: e.errors
|
|
945
946
|
}), h)
|
|
946
947
|
throw h;
|
|
947
|
-
},
|
|
948
|
-
m(s, a) && (
|
|
949
|
-
},
|
|
950
|
-
const o = a ?
|
|
948
|
+
}, Wt = (a, n = {}) => {
|
|
949
|
+
m(s, a) && (U(n.defaultValue) ? Y(a, L(m(u, a))) : (Y(a, n.defaultValue), R(u, a, L(n.defaultValue))), n.keepTouched || B(e.touchedFields, a), n.keepDirty || (B(e.dirtyFields, a), e.isDirty = n.defaultValue ? E(a, L(m(u, a))) : E()), n.keepError || (B(e.errors, a), g.isValid && M()), p.state.next({ ...e }));
|
|
950
|
+
}, ut = (a, n = {}) => {
|
|
951
|
+
const o = a ? L(a) : u, h = L(o), _ = q(a), y = _ ? u : h;
|
|
951
952
|
if (n.keepDefaultValues || (u = o), !n.keepValues) {
|
|
952
953
|
if (n.keepDirtyValues) {
|
|
953
|
-
const
|
|
954
|
+
const b = /* @__PURE__ */ new Set([
|
|
954
955
|
...l.mount,
|
|
955
|
-
...Object.keys(
|
|
956
|
+
...Object.keys(ce(u, i))
|
|
956
957
|
]);
|
|
957
|
-
for (const
|
|
958
|
-
m(e.dirtyFields,
|
|
958
|
+
for (const D of Array.from(b))
|
|
959
|
+
m(e.dirtyFields, D) ? R(y, D, m(i, D)) : Y(D, m(y, D));
|
|
959
960
|
} else {
|
|
960
|
-
if (ze &&
|
|
961
|
-
for (const
|
|
962
|
-
const
|
|
963
|
-
if (
|
|
964
|
-
const
|
|
965
|
-
if (xe(
|
|
966
|
-
const
|
|
967
|
-
if (
|
|
968
|
-
|
|
961
|
+
if (ze && U(a))
|
|
962
|
+
for (const b of l.mount) {
|
|
963
|
+
const D = m(s, b);
|
|
964
|
+
if (D && D._f) {
|
|
965
|
+
const O = Array.isArray(D._f.refs) ? D._f.refs[0] : D._f.ref;
|
|
966
|
+
if (xe(O)) {
|
|
967
|
+
const ee = O.closest("form");
|
|
968
|
+
if (ee) {
|
|
969
|
+
ee.reset();
|
|
969
970
|
break;
|
|
970
971
|
}
|
|
971
972
|
}
|
|
972
973
|
}
|
|
973
974
|
}
|
|
974
975
|
if (n.keepFieldsRef)
|
|
975
|
-
for (const
|
|
976
|
-
|
|
976
|
+
for (const b of l.mount)
|
|
977
|
+
Y(b, m(y, b));
|
|
977
978
|
else
|
|
978
979
|
s = {};
|
|
979
980
|
}
|
|
980
|
-
i = r.shouldUnregister ? n.keepDefaultValues ?
|
|
981
|
+
i = r.shouldUnregister ? n.keepDefaultValues ? L(u) : {} : L(y), p.array.next({
|
|
981
982
|
values: { ...y }
|
|
982
|
-
}),
|
|
983
|
+
}), p.state.next({
|
|
983
984
|
values: { ...y }
|
|
984
985
|
});
|
|
985
986
|
}
|
|
@@ -991,55 +992,58 @@ function hr(t = {}) {
|
|
|
991
992
|
watch: /* @__PURE__ */ new Set(),
|
|
992
993
|
watchAll: !1,
|
|
993
994
|
focus: ""
|
|
994
|
-
}, c.mount = !
|
|
995
|
+
}, c.mount = !g.isValid || !!n.keepIsValid || !!n.keepDirtyValues || !r.shouldUnregister && !q(y), c.watch = !!r.shouldUnregister, c.keepIsValid = !!n.keepIsValid, c.action = !1, n.keepErrors || (e.errors = {}), p.state.next({
|
|
995
996
|
submitCount: n.keepSubmitCount ? e.submitCount : 0,
|
|
996
|
-
isDirty: _ ? !1 : n.keepDirty ? e.isDirty : !!(n.keepDefaultValues && !
|
|
997
|
+
isDirty: _ ? !1 : n.keepDirty ? e.isDirty : !!(n.keepDefaultValues && !ae(a, u)),
|
|
997
998
|
isSubmitted: n.keepIsSubmitted ? e.isSubmitted : !1,
|
|
998
|
-
dirtyFields: _ ? {} : n.keepDirtyValues ? n.keepDefaultValues && i ?
|
|
999
|
+
dirtyFields: _ ? {} : n.keepDirtyValues ? n.keepDefaultValues && i ? ce(u, i) : e.dirtyFields : n.keepDefaultValues && a ? ce(u, a) : n.keepDirty ? e.dirtyFields : {},
|
|
999
1000
|
touchedFields: n.keepTouched ? e.touchedFields : {},
|
|
1000
1001
|
errors: n.keepErrors ? e.errors : {},
|
|
1001
1002
|
isSubmitSuccessful: n.keepIsSubmitSuccessful ? e.isSubmitSuccessful : !1,
|
|
1002
1003
|
isSubmitting: !1,
|
|
1003
1004
|
defaultValues: u
|
|
1004
1005
|
});
|
|
1005
|
-
},
|
|
1006
|
+
}, ot = (a, n) => ut(Q(a) ? a(i) : a, { ...r.resetOptions, ...n }), $t = (a, n = {}) => {
|
|
1006
1007
|
const o = m(s, a), h = o && o._f;
|
|
1007
1008
|
if (h) {
|
|
1008
1009
|
const _ = h.refs ? h.refs[0] : h.ref;
|
|
1009
|
-
_.focus && (
|
|
1010
|
+
_.focus && setTimeout(() => {
|
|
1011
|
+
_.focus(), n.shouldSelect && Q(_.select) && _.select();
|
|
1012
|
+
});
|
|
1010
1013
|
}
|
|
1011
|
-
},
|
|
1014
|
+
}, Ht = (a) => {
|
|
1012
1015
|
e = {
|
|
1013
1016
|
...e,
|
|
1014
1017
|
...a
|
|
1015
1018
|
};
|
|
1016
|
-
},
|
|
1019
|
+
}, lt = {
|
|
1017
1020
|
control: {
|
|
1018
1021
|
register: De,
|
|
1019
1022
|
unregister: Ce,
|
|
1020
|
-
getFieldState:
|
|
1021
|
-
handleSubmit:
|
|
1022
|
-
setError:
|
|
1023
|
-
_subscribe:
|
|
1024
|
-
_runSchema:
|
|
1023
|
+
getFieldState: rt,
|
|
1024
|
+
handleSubmit: it,
|
|
1025
|
+
setError: st,
|
|
1026
|
+
_subscribe: at,
|
|
1027
|
+
_runSchema: j,
|
|
1028
|
+
_updateIsValidating: N,
|
|
1025
1029
|
_focusError: Re,
|
|
1026
|
-
_getWatch:
|
|
1027
|
-
_getDirty:
|
|
1028
|
-
_setValid:
|
|
1029
|
-
_setFieldArray:
|
|
1030
|
-
_setDisabledField:
|
|
1031
|
-
_setErrors:
|
|
1032
|
-
_getFieldArray:
|
|
1033
|
-
_reset:
|
|
1034
|
-
_resetDefaultValues: () =>
|
|
1035
|
-
|
|
1030
|
+
_getWatch: C,
|
|
1031
|
+
_getDirty: E,
|
|
1032
|
+
_setValid: M,
|
|
1033
|
+
_setFieldArray: x,
|
|
1034
|
+
_setDisabledField: nt,
|
|
1035
|
+
_setErrors: f,
|
|
1036
|
+
_getFieldArray: $,
|
|
1037
|
+
_reset: ut,
|
|
1038
|
+
_resetDefaultValues: () => Q(r.defaultValues) && r.defaultValues().then((a) => {
|
|
1039
|
+
ot(a, r.resetOptions), p.state.next({
|
|
1036
1040
|
isLoading: !1
|
|
1037
1041
|
});
|
|
1038
1042
|
}),
|
|
1039
|
-
_removeUnmounted:
|
|
1043
|
+
_removeUnmounted: Fe,
|
|
1040
1044
|
_disableForm: Bt,
|
|
1041
|
-
_subjects:
|
|
1042
|
-
_proxyFormState:
|
|
1045
|
+
_subjects: p,
|
|
1046
|
+
_proxyFormState: g,
|
|
1043
1047
|
get _fields() {
|
|
1044
1048
|
return s;
|
|
1045
1049
|
},
|
|
@@ -1074,24 +1078,24 @@ function hr(t = {}) {
|
|
|
1074
1078
|
};
|
|
1075
1079
|
}
|
|
1076
1080
|
},
|
|
1077
|
-
subscribe:
|
|
1078
|
-
trigger:
|
|
1081
|
+
subscribe: Pt,
|
|
1082
|
+
trigger: _e,
|
|
1079
1083
|
register: De,
|
|
1080
|
-
handleSubmit:
|
|
1081
|
-
watch:
|
|
1082
|
-
setValue:
|
|
1083
|
-
getValues:
|
|
1084
|
-
reset:
|
|
1085
|
-
resetField:
|
|
1086
|
-
clearErrors:
|
|
1084
|
+
handleSubmit: it,
|
|
1085
|
+
watch: It,
|
|
1086
|
+
setValue: Y,
|
|
1087
|
+
getValues: tt,
|
|
1088
|
+
reset: ot,
|
|
1089
|
+
resetField: Wt,
|
|
1090
|
+
clearErrors: Mt,
|
|
1087
1091
|
unregister: Ce,
|
|
1088
|
-
setError:
|
|
1089
|
-
setFocus:
|
|
1090
|
-
getFieldState:
|
|
1092
|
+
setError: st,
|
|
1093
|
+
setFocus: $t,
|
|
1094
|
+
getFieldState: rt
|
|
1091
1095
|
};
|
|
1092
1096
|
return {
|
|
1093
|
-
...
|
|
1094
|
-
formControl:
|
|
1097
|
+
...lt,
|
|
1098
|
+
formControl: lt
|
|
1095
1099
|
};
|
|
1096
1100
|
}
|
|
1097
1101
|
var ue = () => {
|
|
@@ -1102,7 +1106,7 @@ var ue = () => {
|
|
|
1102
1106
|
const e = (Math.random() * 16 + t) % 16 | 0;
|
|
1103
1107
|
return (r == "x" ? e : e & 3 | 8).toString(16);
|
|
1104
1108
|
});
|
|
1105
|
-
}, Ne = (t, r, e = {}) => e.shouldFocus ||
|
|
1109
|
+
}, Ne = (t, r, e = {}) => e.shouldFocus || U(e.shouldFocus) ? e.focusName || `${t}.${U(e.focusIndex) ? r : e.focusIndex}.` : "", Le = (t, r) => [
|
|
1106
1110
|
...t,
|
|
1107
1111
|
...z(r)
|
|
1108
1112
|
], Me = (t) => Array.isArray(t) ? t.map(() => {
|
|
@@ -1114,125 +1118,126 @@ function Ie(t, r, e) {
|
|
|
1114
1118
|
...t.slice(r)
|
|
1115
1119
|
];
|
|
1116
1120
|
}
|
|
1117
|
-
var
|
|
1121
|
+
var Pe = (t, r, e) => Array.isArray(t) ? (U(t[e]) && (t[e] = void 0), t.splice(e, 0, t.splice(r, 1)[0]), t) : [], Be = (t, r) => [
|
|
1118
1122
|
...z(r),
|
|
1119
1123
|
...z(t)
|
|
1120
1124
|
];
|
|
1121
|
-
function
|
|
1125
|
+
function Vr(t, r) {
|
|
1122
1126
|
let e = 0;
|
|
1123
1127
|
const s = [...t];
|
|
1124
1128
|
for (const u of r)
|
|
1125
1129
|
s.splice(u - e, 1), e++;
|
|
1126
1130
|
return we(s).length ? s : [];
|
|
1127
1131
|
}
|
|
1128
|
-
var We = (t, r) =>
|
|
1132
|
+
var We = (t, r) => U(r) ? [] : Vr(t, z(r).sort((e, s) => e - s)), $e = (t, r, e) => {
|
|
1129
1133
|
[t[r], t[e]] = [t[e], t[r]];
|
|
1130
|
-
},
|
|
1131
|
-
function
|
|
1132
|
-
const r = Ve(), { control: e = r.control, name: s, keyName: u = "id", shouldUnregister: i, rules: c } = t, [l, V] =
|
|
1133
|
-
e._names.array.add(s),
|
|
1134
|
+
}, bt = (t, r, e) => (t[r] = e, t);
|
|
1135
|
+
function Fr(t) {
|
|
1136
|
+
const r = Ve(), { control: e = r.control, name: s, keyName: u = "id", shouldUnregister: i, rules: c } = t, [l, V] = F.useState(e._getFieldArray(s)), v = F.useRef(e._getFieldArray(s).map(ue)), w = F.useRef(!1);
|
|
1137
|
+
e._names.array.add(s), F.useMemo(() => c && l.length >= 0 && e.register(s, c), [e, s, l.length, c]), ke(() => e._subjects.array.subscribe({
|
|
1134
1138
|
next: ({ values: f, name: d }) => {
|
|
1135
1139
|
if (d === s || !d) {
|
|
1136
|
-
const
|
|
1137
|
-
Array.isArray(
|
|
1140
|
+
const A = m(f, s);
|
|
1141
|
+
Array.isArray(A) && (V(A), v.current = A.map(ue));
|
|
1138
1142
|
}
|
|
1139
1143
|
}
|
|
1140
1144
|
}).unsubscribe, [e, s]);
|
|
1141
|
-
const g =
|
|
1142
|
-
|
|
1143
|
-
}, [e, s]),
|
|
1144
|
-
const
|
|
1145
|
-
e._names.focus = Ne(s,
|
|
1145
|
+
const g = F.useCallback((f) => {
|
|
1146
|
+
w.current = !0, e._setFieldArray(s, f);
|
|
1147
|
+
}, [e, s]), S = (f, d) => {
|
|
1148
|
+
const A = z(L(f)), k = Le(e._getFieldArray(s), A);
|
|
1149
|
+
e._names.focus = Ne(s, k.length - 1, d), v.current = Le(v.current, A.map(ue)), g(k), V(k), e._setFieldArray(s, k, Le, {
|
|
1146
1150
|
argA: Me(f)
|
|
1147
1151
|
});
|
|
1148
|
-
},
|
|
1149
|
-
const
|
|
1150
|
-
e._names.focus = Ne(s, 0, d), v.current =
|
|
1152
|
+
}, p = (f, d) => {
|
|
1153
|
+
const A = z(L(f)), k = Be(e._getFieldArray(s), A);
|
|
1154
|
+
e._names.focus = Ne(s, 0, d), v.current = Be(v.current, A.map(ue)), g(k), V(k), e._setFieldArray(s, k, Be, {
|
|
1151
1155
|
argA: Me(f)
|
|
1152
1156
|
});
|
|
1153
|
-
},
|
|
1157
|
+
}, I = (f) => {
|
|
1154
1158
|
const d = We(e._getFieldArray(s), f);
|
|
1155
1159
|
v.current = We(v.current, f), g(d), V(d), !Array.isArray(m(e._fields, s)) && R(e._fields, s, void 0), e._setFieldArray(s, d, We, {
|
|
1156
1160
|
argA: f
|
|
1157
1161
|
});
|
|
1158
|
-
},
|
|
1159
|
-
const
|
|
1160
|
-
e._names.focus = Ne(s, f,
|
|
1162
|
+
}, T = (f, d, A) => {
|
|
1163
|
+
const k = z(L(d)), j = Ie(e._getFieldArray(s), f, k);
|
|
1164
|
+
e._names.focus = Ne(s, f, A), v.current = Ie(v.current, f, k.map(ue)), g(j), V(j), e._setFieldArray(s, j, Ie, {
|
|
1161
1165
|
argA: f,
|
|
1162
1166
|
argB: Me(d)
|
|
1163
1167
|
});
|
|
1164
|
-
},
|
|
1165
|
-
const
|
|
1166
|
-
$e(
|
|
1168
|
+
}, M = (f, d) => {
|
|
1169
|
+
const A = e._getFieldArray(s);
|
|
1170
|
+
$e(A, f, d), $e(v.current, f, d), g(A), V(A), e._setFieldArray(s, A, $e, {
|
|
1167
1171
|
argA: f,
|
|
1168
1172
|
argB: d
|
|
1169
1173
|
}, !1);
|
|
1170
|
-
},
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1174
|
+
}, N = (f, d) => {
|
|
1175
|
+
const A = e._getFieldArray(s);
|
|
1176
|
+
Pe(A, f, d), Pe(v.current, f, d), g(A), V(A), e._setFieldArray(s, A, Pe, {
|
|
1173
1177
|
argA: f,
|
|
1174
1178
|
argB: d
|
|
1175
1179
|
}, !1);
|
|
1176
|
-
},
|
|
1177
|
-
const
|
|
1178
|
-
v.current = [...
|
|
1180
|
+
}, x = (f, d) => {
|
|
1181
|
+
const A = L(d), k = bt(e._getFieldArray(s), f, A);
|
|
1182
|
+
v.current = [...k].map((j, K) => !j || K === f ? ue() : v.current[K]), g(k), V([...k]), e._setFieldArray(s, k, bt, {
|
|
1179
1183
|
argA: f,
|
|
1180
|
-
argB:
|
|
1184
|
+
argB: A
|
|
1181
1185
|
}, !0, !1);
|
|
1182
|
-
},
|
|
1183
|
-
const d = z(
|
|
1184
|
-
v.current = d.map(ue), g([...d]), V([...d]), e._setFieldArray(s, [...d], (
|
|
1186
|
+
}, P = (f) => {
|
|
1187
|
+
const d = z(L(f));
|
|
1188
|
+
v.current = d.map(ue), g([...d]), V([...d]), e._setFieldArray(s, [...d], (A) => A, {}, !0, !1);
|
|
1185
1189
|
};
|
|
1186
|
-
return
|
|
1190
|
+
return F.useEffect(() => {
|
|
1187
1191
|
if (e._state.action = !1, Qe(s, e._names) && e._subjects.state.next({
|
|
1188
1192
|
...e._formState
|
|
1189
|
-
}),
|
|
1193
|
+
}), w.current && (!de(e._options.mode).isOnSubmit || e._formState.isSubmitted) && !de(e._options.reValidateMode).isOnSubmit)
|
|
1190
1194
|
if (e._options.resolver)
|
|
1191
1195
|
e._runSchema([s]).then((f) => {
|
|
1192
|
-
|
|
1193
|
-
|
|
1196
|
+
e._updateIsValidating([s]);
|
|
1197
|
+
const d = m(f.errors, s), A = m(e._formState.errors, s);
|
|
1198
|
+
(A ? !d && A.type || d && (A.type !== d.type || A.message !== d.message) : d && d.type) && (d ? R(e._formState.errors, s, d) : B(e._formState.errors, s), e._subjects.state.next({
|
|
1194
1199
|
errors: e._formState.errors
|
|
1195
1200
|
}));
|
|
1196
1201
|
});
|
|
1197
1202
|
else {
|
|
1198
1203
|
const f = m(e._fields, s);
|
|
1199
|
-
f && f._f && !(
|
|
1200
|
-
errors:
|
|
1204
|
+
f && f._f && !(de(e._options.reValidateMode).isOnSubmit && de(e._options.mode).isOnSubmit) && Ge(f, e._names.disabled, e._formValues, e._options.criteriaMode === te.all, e._options.shouldUseNativeValidation, !0).then((d) => !q(d) && e._subjects.state.next({
|
|
1205
|
+
errors: Ot(e._formState.errors, d, s)
|
|
1201
1206
|
}));
|
|
1202
1207
|
}
|
|
1203
1208
|
e._subjects.state.next({
|
|
1204
1209
|
name: s,
|
|
1205
|
-
values:
|
|
1206
|
-
}), e._names.focus &&
|
|
1210
|
+
values: L(e._formValues)
|
|
1211
|
+
}), e._names.focus && fe(e._fields, (f, d) => {
|
|
1207
1212
|
if (e._names.focus && d.startsWith(e._names.focus) && f.focus)
|
|
1208
1213
|
return f.focus(), 1;
|
|
1209
|
-
}), e._names.focus = "", e._setValid(),
|
|
1210
|
-
}, [l, s, e]),
|
|
1211
|
-
const f = (d,
|
|
1212
|
-
const
|
|
1213
|
-
|
|
1214
|
+
}), e._names.focus = "", e._setValid(), w.current = !1;
|
|
1215
|
+
}, [l, s, e]), F.useEffect(() => (!m(e._formValues, s) && e._setFieldArray(s), () => {
|
|
1216
|
+
const f = (d, A) => {
|
|
1217
|
+
const k = m(e._fields, d);
|
|
1218
|
+
k && k._f && (k._f.mount = A);
|
|
1214
1219
|
};
|
|
1215
1220
|
e._options.shouldUnregister || i ? e.unregister(s) : f(s, !1);
|
|
1216
1221
|
}), [s, e, u, i]), {
|
|
1217
|
-
swap:
|
|
1218
|
-
move:
|
|
1219
|
-
prepend:
|
|
1220
|
-
append:
|
|
1221
|
-
remove:
|
|
1222
|
-
insert:
|
|
1223
|
-
update:
|
|
1224
|
-
replace:
|
|
1225
|
-
fields:
|
|
1222
|
+
swap: F.useCallback(M, [g, s, e]),
|
|
1223
|
+
move: F.useCallback(N, [g, s, e]),
|
|
1224
|
+
prepend: F.useCallback(p, [g, s, e]),
|
|
1225
|
+
append: F.useCallback(S, [g, s, e]),
|
|
1226
|
+
remove: F.useCallback(I, [g, s, e]),
|
|
1227
|
+
insert: F.useCallback(T, [g, s, e]),
|
|
1228
|
+
update: F.useCallback(x, [g, s, e]),
|
|
1229
|
+
replace: F.useCallback(P, [g, s, e]),
|
|
1230
|
+
fields: F.useMemo(() => l.map((f, d) => ({
|
|
1226
1231
|
...f,
|
|
1227
1232
|
[u]: v.current[d] || ue()
|
|
1228
1233
|
})), [l, u])
|
|
1229
1234
|
};
|
|
1230
1235
|
}
|
|
1231
|
-
function
|
|
1232
|
-
const r =
|
|
1236
|
+
function br(t = {}) {
|
|
1237
|
+
const r = F.useRef(void 0), e = F.useRef(void 0), [s, u] = F.useState({
|
|
1233
1238
|
isDirty: !1,
|
|
1234
1239
|
isValidating: !1,
|
|
1235
|
-
isLoading:
|
|
1240
|
+
isLoading: Q(t.defaultValues),
|
|
1236
1241
|
isSubmitted: !1,
|
|
1237
1242
|
isSubmitting: !1,
|
|
1238
1243
|
isSubmitSuccessful: !1,
|
|
@@ -1244,16 +1249,16 @@ function Fr(t = {}) {
|
|
|
1244
1249
|
errors: t.errors || {},
|
|
1245
1250
|
disabled: t.disabled || !1,
|
|
1246
1251
|
isReady: !1,
|
|
1247
|
-
defaultValues:
|
|
1252
|
+
defaultValues: Q(t.defaultValues) ? void 0 : t.defaultValues
|
|
1248
1253
|
});
|
|
1249
1254
|
if (!r.current)
|
|
1250
1255
|
if (t.formControl)
|
|
1251
1256
|
r.current = {
|
|
1252
1257
|
...t.formControl,
|
|
1253
1258
|
formState: s
|
|
1254
|
-
}, t.defaultValues && !
|
|
1259
|
+
}, t.defaultValues && !Q(t.defaultValues) && t.formControl.reset(t.defaultValues, t.resetOptions);
|
|
1255
1260
|
else {
|
|
1256
|
-
const { formControl: c, ...l } =
|
|
1261
|
+
const { formControl: c, ...l } = vr(t);
|
|
1257
1262
|
r.current = {
|
|
1258
1263
|
...l,
|
|
1259
1264
|
formState: s
|
|
@@ -1270,38 +1275,38 @@ function Fr(t = {}) {
|
|
|
1270
1275
|
...l,
|
|
1271
1276
|
isReady: !0
|
|
1272
1277
|
})), i._formState.isReady = !0, c;
|
|
1273
|
-
}, [i]),
|
|
1278
|
+
}, [i]), F.useEffect(() => i._disableForm(t.disabled), [i, t.disabled]), F.useEffect(() => {
|
|
1274
1279
|
t.mode && (i._options.mode = t.mode), t.reValidateMode && (i._options.reValidateMode = t.reValidateMode);
|
|
1275
|
-
}, [i, t.mode, t.reValidateMode]),
|
|
1280
|
+
}, [i, t.mode, t.reValidateMode]), F.useEffect(() => {
|
|
1276
1281
|
t.errors && (i._setErrors(t.errors), i._focusError());
|
|
1277
|
-
}, [i, t.errors]),
|
|
1282
|
+
}, [i, t.errors]), F.useEffect(() => {
|
|
1278
1283
|
t.shouldUnregister && i._subjects.state.next({
|
|
1279
1284
|
values: i._getWatch()
|
|
1280
1285
|
});
|
|
1281
|
-
}, [i, t.shouldUnregister]),
|
|
1286
|
+
}, [i, t.shouldUnregister]), F.useEffect(() => {
|
|
1282
1287
|
if (i._proxyFormState.isDirty) {
|
|
1283
1288
|
const c = i._getDirty();
|
|
1284
1289
|
c !== s.isDirty && i._subjects.state.next({
|
|
1285
1290
|
isDirty: c
|
|
1286
1291
|
});
|
|
1287
1292
|
}
|
|
1288
|
-
}, [i, s.isDirty]),
|
|
1293
|
+
}, [i, s.isDirty]), F.useEffect(() => {
|
|
1289
1294
|
var c;
|
|
1290
|
-
t.values && !
|
|
1295
|
+
t.values && !ae(t.values, e.current) ? (i._reset(t.values, {
|
|
1291
1296
|
keepFieldsRef: !0,
|
|
1292
1297
|
...i._options.resetOptions
|
|
1293
1298
|
}), !((c = i._options.resetOptions) === null || c === void 0) && c.keepIsValid || i._setValid(), e.current = t.values, u((l) => ({ ...l }))) : i._resetDefaultValues();
|
|
1294
|
-
}, [i, t.values]),
|
|
1299
|
+
}, [i, t.values]), F.useEffect(() => {
|
|
1295
1300
|
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
|
-
}), r.current.formState =
|
|
1301
|
+
}), r.current.formState = Et(s, i), r.current;
|
|
1297
1302
|
}
|
|
1298
|
-
const
|
|
1299
|
-
const t =
|
|
1303
|
+
const Ut = zt(void 0), Ar = ({ showAsterisk: t, children: r }) => /* @__PURE__ */ se(Ut.Provider, { value: { showAsterisk: t }, children: r }), pr = () => {
|
|
1304
|
+
const t = Kt(Ut);
|
|
1300
1305
|
if (!t)
|
|
1301
1306
|
throw new Error("useSuprFormContext must be used within a SuprFormProvider");
|
|
1302
1307
|
return t;
|
|
1303
1308
|
};
|
|
1304
|
-
function
|
|
1309
|
+
function Nt(t, r, e) {
|
|
1305
1310
|
const { conditions: s, operator: u } = e, i = t.reduce((l, V, v) => (l[V] = r[v], l), {}), c = s.map((l) => {
|
|
1306
1311
|
const V = i[l.name];
|
|
1307
1312
|
switch (l.operator) {
|
|
@@ -1331,68 +1336,18 @@ function Ut(t, r, e) {
|
|
|
1331
1336
|
});
|
|
1332
1337
|
return u === "AND" ? c.every(Boolean) : c.some(Boolean);
|
|
1333
1338
|
}
|
|
1334
|
-
const
|
|
1339
|
+
const xr = ({
|
|
1335
1340
|
children: t,
|
|
1336
1341
|
visibility: r
|
|
1337
1342
|
}) => {
|
|
1338
1343
|
const e = he(() => typeof r == "boolean" ? [] : (r == null ? void 0 : r.conditions.map((i) => i.name)) || [], [r]), s = Je({ name: e });
|
|
1339
|
-
return he(() => typeof r == "boolean" ? r : !r || (r == null ? void 0 : r.conditions.length) === 0 ? !0 :
|
|
1340
|
-
},
|
|
1344
|
+
return he(() => typeof r == "boolean" ? r : !r || (r == null ? void 0 : r.conditions.length) === 0 ? !0 : Nt(e, s, r), [r, e, s]) ? t : null;
|
|
1345
|
+
}, Sr = ({
|
|
1341
1346
|
children: t,
|
|
1342
1347
|
disabled: r
|
|
1343
1348
|
}) => {
|
|
1344
|
-
const e = he(() => typeof r == "boolean" ? [] : (r == null ? void 0 : r.conditions.map((i) => i.name)) || [], [r]), s = Je({ name: e }), u = he(() => typeof r == "boolean" ? r : !r || (r == null ? void 0 : r.conditions.length) === 0 ? !1 :
|
|
1349
|
+
const e = he(() => typeof r == "boolean" ? [] : (r == null ? void 0 : r.conditions.map((i) => i.name)) || [], [r]), s = Je({ name: e }), u = he(() => typeof r == "boolean" ? r : !r || (r == null ? void 0 : r.conditions.length) === 0 ? !1 : Nt(e, s, r), [r, e, s]);
|
|
1345
1350
|
return Ae(t, { ...t.props, disabled: u });
|
|
1346
|
-
}, Nt = ({
|
|
1347
|
-
children: t,
|
|
1348
|
-
onSubmit: r = () => {
|
|
1349
|
-
},
|
|
1350
|
-
onError: e = () => {
|
|
1351
|
-
},
|
|
1352
|
-
style: s = {},
|
|
1353
|
-
className: u = "",
|
|
1354
|
-
formOptions: i,
|
|
1355
|
-
showAsterisk: c,
|
|
1356
|
-
ref: l,
|
|
1357
|
-
onChange: V
|
|
1358
|
-
}) => {
|
|
1359
|
-
const v = Fr({
|
|
1360
|
-
mode: "onSubmit",
|
|
1361
|
-
reValidateMode: "onChange",
|
|
1362
|
-
shouldFocusError: !0,
|
|
1363
|
-
...i
|
|
1364
|
-
});
|
|
1365
|
-
return bt(
|
|
1366
|
-
l,
|
|
1367
|
-
() => ({
|
|
1368
|
-
setValue: v.setValue,
|
|
1369
|
-
setError: v.setError,
|
|
1370
|
-
clearErrors: v.clearErrors,
|
|
1371
|
-
getValues: v.getValues,
|
|
1372
|
-
reset: v.reset,
|
|
1373
|
-
setFocus: v.setFocus,
|
|
1374
|
-
resetField: v.resetField,
|
|
1375
|
-
trigger: v.trigger,
|
|
1376
|
-
unregister: v.unregister,
|
|
1377
|
-
watch: v.watch,
|
|
1378
|
-
handleSubmit: v.handleSubmit
|
|
1379
|
-
}),
|
|
1380
|
-
[v]
|
|
1381
|
-
), Kt(() => {
|
|
1382
|
-
const x = v.watch((g) => {
|
|
1383
|
-
V == null || V(g);
|
|
1384
|
-
});
|
|
1385
|
-
return () => x.unsubscribe();
|
|
1386
|
-
}, [v.watch]), /* @__PURE__ */ ee(br, { showAsterisk: c, children: /* @__PURE__ */ ee(er, { ...v, children: /* @__PURE__ */ ee(
|
|
1387
|
-
"form",
|
|
1388
|
-
{
|
|
1389
|
-
noValidate: !0,
|
|
1390
|
-
onSubmit: v.handleSubmit(r, e),
|
|
1391
|
-
style: s,
|
|
1392
|
-
className: u,
|
|
1393
|
-
children: t
|
|
1394
|
-
}
|
|
1395
|
-
) }) });
|
|
1396
1351
|
}, et = ({
|
|
1397
1352
|
children: t,
|
|
1398
1353
|
name: r,
|
|
@@ -1404,49 +1359,51 @@ const pr = ({
|
|
|
1404
1359
|
shouldUnregister: l,
|
|
1405
1360
|
visibility: V
|
|
1406
1361
|
}) => {
|
|
1407
|
-
const { control: v } = Ve(),
|
|
1408
|
-
return /* @__PURE__ */
|
|
1409
|
-
|
|
1362
|
+
const { control: v } = Ve(), w = t.props.value ?? "", { showAsterisk: g } = pr(), S = t.props.onChange, p = t.props.onBlur, I = he(() => i || crypto.randomUUID(), []);
|
|
1363
|
+
return /* @__PURE__ */ se(xr, { visibility: V, children: /* @__PURE__ */ se(Sr, { disabled: c, children: /* @__PURE__ */ se(
|
|
1364
|
+
ar,
|
|
1410
1365
|
{
|
|
1411
1366
|
control: v,
|
|
1412
1367
|
name: r,
|
|
1413
1368
|
rules: e,
|
|
1414
|
-
defaultValue:
|
|
1369
|
+
defaultValue: w,
|
|
1415
1370
|
shouldUnregister: l,
|
|
1416
1371
|
render: ({
|
|
1417
|
-
field: { name:
|
|
1372
|
+
field: { name: T, onBlur: M, value: N, onChange: x, ref: P, disabled: f },
|
|
1418
1373
|
fieldState: { error: d }
|
|
1419
|
-
}) => /* @__PURE__ */
|
|
1374
|
+
}) => /* @__PURE__ */ ft(
|
|
1420
1375
|
"div",
|
|
1421
1376
|
{
|
|
1422
1377
|
className: `controlled-field ${s}`,
|
|
1423
1378
|
style: { display: "flex", flexDirection: "column", gap: "5px" },
|
|
1424
1379
|
children: [
|
|
1425
|
-
u && /* @__PURE__ */
|
|
1380
|
+
u && /* @__PURE__ */ ft("label", { htmlFor: I, className: "controlled-field-label", children: [
|
|
1426
1381
|
u,
|
|
1427
|
-
g && !!e && /* @__PURE__ */
|
|
1382
|
+
g && !!e && /* @__PURE__ */ se("span", { style: { color: "red" }, children: " *" })
|
|
1428
1383
|
] }),
|
|
1429
1384
|
Ae(t, {
|
|
1430
1385
|
...t.props,
|
|
1431
|
-
id:
|
|
1432
|
-
name:
|
|
1386
|
+
id: I,
|
|
1387
|
+
name: T,
|
|
1433
1388
|
disabled: f,
|
|
1434
|
-
onChange: (...
|
|
1435
|
-
|
|
1389
|
+
onChange: (...A) => {
|
|
1390
|
+
x(...A), S == null || S(...A);
|
|
1436
1391
|
},
|
|
1437
|
-
value:
|
|
1438
|
-
onBlur: (...
|
|
1439
|
-
|
|
1392
|
+
value: N,
|
|
1393
|
+
onBlur: (...A) => {
|
|
1394
|
+
M(), p == null || p(...A);
|
|
1440
1395
|
},
|
|
1441
|
-
ref:
|
|
1396
|
+
ref: P
|
|
1442
1397
|
}),
|
|
1443
|
-
d && /* @__PURE__ */
|
|
1398
|
+
d && /* @__PURE__ */ se("div", { style: { color: "red", fontSize: 13 }, className: "controlled-field-error", children: d.message })
|
|
1444
1399
|
]
|
|
1445
1400
|
}
|
|
1446
1401
|
)
|
|
1447
1402
|
}
|
|
1448
1403
|
) }) });
|
|
1449
|
-
}
|
|
1404
|
+
};
|
|
1405
|
+
et.displayName = "SuprFormControl";
|
|
1406
|
+
const Er = ({
|
|
1450
1407
|
name: t,
|
|
1451
1408
|
rules: r,
|
|
1452
1409
|
ref: e,
|
|
@@ -1454,60 +1411,109 @@ const pr = ({
|
|
|
1454
1411
|
visibility: u,
|
|
1455
1412
|
disabled: i
|
|
1456
1413
|
}) => {
|
|
1457
|
-
const c =
|
|
1414
|
+
const c = Fr({
|
|
1458
1415
|
name: t,
|
|
1459
1416
|
rules: r
|
|
1460
1417
|
});
|
|
1461
|
-
|
|
1462
|
-
const l = (V, v) => Yt.map(V, (
|
|
1463
|
-
var
|
|
1464
|
-
if (!Jt(
|
|
1465
|
-
return
|
|
1466
|
-
const g =
|
|
1467
|
-
if (((
|
|
1468
|
-
const
|
|
1469
|
-
...
|
|
1470
|
-
conditions: ((
|
|
1418
|
+
At(e, () => c, [c]);
|
|
1419
|
+
const l = (V, v) => Yt.map(V, (w) => {
|
|
1420
|
+
var I, T;
|
|
1421
|
+
if (!Jt(w))
|
|
1422
|
+
return w;
|
|
1423
|
+
const g = w.props, S = w.type;
|
|
1424
|
+
if (((S == null ? void 0 : S.displayName) === "SuprFormControl" || S === et || g.name !== void 0 && typeof S != "string") && g.name !== void 0) {
|
|
1425
|
+
const M = u ? u[g.name] : void 0, N = M ? {
|
|
1426
|
+
...M,
|
|
1427
|
+
conditions: ((I = M.conditions) == null ? void 0 : I.map((d) => ({
|
|
1471
1428
|
...d,
|
|
1472
1429
|
name: `${v}${d.name}`
|
|
1473
1430
|
}))) || []
|
|
1474
|
-
} : void 0,
|
|
1475
|
-
...
|
|
1476
|
-
conditions: ((
|
|
1431
|
+
} : void 0, x = i ? i[g.name] : void 0, P = x ? {
|
|
1432
|
+
...x,
|
|
1433
|
+
conditions: ((T = x.conditions) == null ? void 0 : T.map((d) => ({
|
|
1477
1434
|
...d,
|
|
1478
1435
|
name: `${v}${d.name}`
|
|
1479
1436
|
}))) || []
|
|
1480
1437
|
} : void 0, f = {
|
|
1481
1438
|
...g,
|
|
1482
1439
|
name: `${v}${g.name}`,
|
|
1483
|
-
visibility:
|
|
1484
|
-
disabled:
|
|
1440
|
+
visibility: N,
|
|
1441
|
+
disabled: P
|
|
1485
1442
|
};
|
|
1486
|
-
return g.id !== void 0 && (f.id = `${v}${g.id}`), Ae(
|
|
1443
|
+
return g.id !== void 0 && (f.id = `${v}${g.id}`), Ae(w, f);
|
|
1487
1444
|
}
|
|
1488
|
-
return g.children ? Ae(
|
|
1445
|
+
return g.children ? Ae(w, {
|
|
1489
1446
|
...g,
|
|
1490
1447
|
children: l(g.children, v)
|
|
1491
|
-
}) :
|
|
1448
|
+
}) : w;
|
|
1492
1449
|
});
|
|
1493
|
-
return /* @__PURE__ */
|
|
1494
|
-
const
|
|
1495
|
-
return /* @__PURE__ */
|
|
1450
|
+
return /* @__PURE__ */ se(Gt, { children: c.fields.map((V, v) => {
|
|
1451
|
+
const w = `${t}.${v}.`;
|
|
1452
|
+
return /* @__PURE__ */ se(
|
|
1496
1453
|
"div",
|
|
1497
1454
|
{
|
|
1498
1455
|
"data-index": v,
|
|
1499
1456
|
style: { display: "contents" },
|
|
1500
1457
|
id: "field-array-item",
|
|
1501
|
-
children: l(s,
|
|
1458
|
+
children: l(s, w)
|
|
1502
1459
|
},
|
|
1503
|
-
|
|
1460
|
+
w
|
|
1504
1461
|
);
|
|
1505
1462
|
}) });
|
|
1463
|
+
}, Lt = ({
|
|
1464
|
+
children: t,
|
|
1465
|
+
onSubmit: r = () => {
|
|
1466
|
+
},
|
|
1467
|
+
onError: e = () => {
|
|
1468
|
+
},
|
|
1469
|
+
style: s = {},
|
|
1470
|
+
className: u = "",
|
|
1471
|
+
formOptions: i,
|
|
1472
|
+
showAsterisk: c,
|
|
1473
|
+
ref: l,
|
|
1474
|
+
onChange: V
|
|
1475
|
+
}) => {
|
|
1476
|
+
const v = br({
|
|
1477
|
+
mode: "onSubmit",
|
|
1478
|
+
reValidateMode: "onChange",
|
|
1479
|
+
shouldFocusError: !0,
|
|
1480
|
+
...i
|
|
1481
|
+
});
|
|
1482
|
+
return At(
|
|
1483
|
+
l,
|
|
1484
|
+
() => ({
|
|
1485
|
+
setValue: v.setValue,
|
|
1486
|
+
setError: v.setError,
|
|
1487
|
+
clearErrors: v.clearErrors,
|
|
1488
|
+
getValues: v.getValues,
|
|
1489
|
+
reset: v.reset,
|
|
1490
|
+
setFocus: v.setFocus,
|
|
1491
|
+
resetField: v.resetField,
|
|
1492
|
+
trigger: v.trigger,
|
|
1493
|
+
unregister: v.unregister,
|
|
1494
|
+
watch: v.watch,
|
|
1495
|
+
handleSubmit: v.handleSubmit
|
|
1496
|
+
}),
|
|
1497
|
+
[v]
|
|
1498
|
+
), Xt(() => {
|
|
1499
|
+
const w = v.watch((g) => {
|
|
1500
|
+
V == null || V(g);
|
|
1501
|
+
});
|
|
1502
|
+
return () => w.unsubscribe();
|
|
1503
|
+
}, [v.watch]), /* @__PURE__ */ se(Ar, { showAsterisk: c, children: /* @__PURE__ */ se(tr, { ...v, children: /* @__PURE__ */ se(
|
|
1504
|
+
"form",
|
|
1505
|
+
{
|
|
1506
|
+
noValidate: !0,
|
|
1507
|
+
onSubmit: v.handleSubmit(r, e),
|
|
1508
|
+
style: s,
|
|
1509
|
+
className: u,
|
|
1510
|
+
children: t
|
|
1511
|
+
}
|
|
1512
|
+
) }) });
|
|
1506
1513
|
};
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
Nt.ControlArray = Sr;
|
|
1514
|
+
Lt.Control = et;
|
|
1515
|
+
Lt.ControlArray = Er;
|
|
1510
1516
|
export {
|
|
1511
|
-
|
|
1517
|
+
Lt as SuprForm
|
|
1512
1518
|
};
|
|
1513
1519
|
//# sourceMappingURL=suprform.es.js.map
|