suprform 1.1.4 → 1.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/LICENSE +1 -1
- package/README.md +1316 -202
- package/dist/components/FormControl.d.ts +1 -1
- package/dist/components/FormControl.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 +695 -669
- package/dist/suprform.es.js.map +1 -1
- package/dist/type.d.ts +4 -0
- package/dist/type.d.ts.map +1 -1
- package/dist/util.d.ts.map +1 -1
- package/package.json +6 -3
package/dist/suprform.es.js
CHANGED
|
@@ -1,40 +1,39 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
var ve = (t) => t.type === "checkbox",
|
|
4
|
-
const
|
|
5
|
-
var
|
|
1
|
+
import { jsx as te, jsxs as Le, Fragment as Qt } from "react/jsx-runtime";
|
|
2
|
+
import F, { createContext as zt, useContext as Kt, useMemo as ye, 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, Q = (t) => t == null;
|
|
4
|
+
const pt = (t) => typeof t == "object";
|
|
5
|
+
var H = (t) => !Q(t) && !Array.isArray(t) && pt(t) && !oe(t), xt = (t) => H(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
|
|
8
|
-
},
|
|
9
|
-
function
|
|
10
|
-
let r;
|
|
11
|
-
const e = Array.isArray(t), s = typeof FileList < "u" ? t instanceof FileList : !1;
|
|
7
|
+
return H(r) && r.hasOwnProperty("isPrototypeOf");
|
|
8
|
+
}, Ke = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
9
|
+
function M(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 (Ke && (t instanceof Blob || r))
|
|
21
14
|
return t;
|
|
22
|
-
|
|
15
|
+
const e = Array.isArray(t);
|
|
16
|
+
if (!e && !(H(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] = M(t[u]));
|
|
21
|
+
return s;
|
|
23
22
|
}
|
|
24
|
-
var Ee = (t) => /^\w*$/.test(t),
|
|
25
|
-
if (!r || !
|
|
23
|
+
var Ee = (t) => /^\w*$/.test(t), N = (t) => t === void 0, we = (t) => Array.isArray(t) ? t.filter(Boolean) : [], Ye = (t) => we(t.replace(/["|']|\]/g, "").split(/\.|\[/)), m = (t, r, e) => {
|
|
24
|
+
if (!r || !H(t))
|
|
26
25
|
return e;
|
|
27
|
-
const s = (Ee(r) ? [r] :
|
|
28
|
-
return
|
|
29
|
-
},
|
|
26
|
+
const s = (Ee(r) ? [r] : Ye(r)).reduce((u, i) => Q(u) ? u : u[i], t);
|
|
27
|
+
return N(s) || s === t ? N(t[r]) ? e : t[r] : s;
|
|
28
|
+
}, J = (t) => typeof t == "boolean", G = (t) => typeof t == "function", O = (t, r, e) => {
|
|
30
29
|
let s = -1;
|
|
31
|
-
const u = Ee(r) ? [r] :
|
|
30
|
+
const u = Ee(r) ? [r] : Ye(r), i = u.length, c = i - 1;
|
|
32
31
|
for (; ++s < i; ) {
|
|
33
32
|
const l = u[s];
|
|
34
33
|
let V = e;
|
|
35
34
|
if (s !== c) {
|
|
36
|
-
const
|
|
37
|
-
V =
|
|
35
|
+
const h = t[l];
|
|
36
|
+
V = H(h) || Array.isArray(h) ? h : 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
|
+
}, re = {
|
|
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
|
-
},
|
|
63
|
-
|
|
64
|
-
const Ve = () =>
|
|
61
|
+
}, Je = F.createContext(null);
|
|
62
|
+
Je.displayName = "HookFormContext";
|
|
63
|
+
const Ve = () => F.useContext(Je), tr = (t) => {
|
|
65
64
|
const { children: r, ...e } = t;
|
|
66
|
-
return
|
|
65
|
+
return F.createElement(Je.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] !== re.all && (r._proxyFormState[c] = !s || re.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,
|
|
@@ -94,21 +93,21 @@ function tr(t) {
|
|
|
94
93
|
name: u,
|
|
95
94
|
formState: V.current,
|
|
96
95
|
exact: i,
|
|
97
|
-
callback: (
|
|
96
|
+
callback: (h) => {
|
|
98
97
|
!s && l({
|
|
99
98
|
...e._formState,
|
|
100
|
-
...
|
|
99
|
+
...h
|
|
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
|
|
109
|
-
if (
|
|
106
|
+
var X = (t) => typeof t == "string", qe = (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), je = (t) => Q(t) || !pt(t);
|
|
107
|
+
function ae(t, r, e = /* @__PURE__ */ new WeakSet()) {
|
|
108
|
+
if (je(t) || je(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) || H(c) && H(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
|
-
function
|
|
132
|
-
const r = Ve(), { control: e = r.control, name: s, defaultValue: u, disabled: i, exact: c, compute: l } = t || {}, V =
|
|
133
|
-
|
|
134
|
-
const [
|
|
130
|
+
function Xe(t) {
|
|
131
|
+
const r = Ve(), { control: e = r.control, name: s, defaultValue: u, disabled: i, exact: c, compute: l } = t || {}, V = F.useRef(u), h = F.useRef(l), k = F.useRef(void 0), g = F.useRef(e), S = F.useRef(s);
|
|
132
|
+
h.current = l;
|
|
133
|
+
const [p, I] = F.useState(() => {
|
|
135
134
|
const f = e._getWatch(s, V.current);
|
|
136
|
-
return
|
|
137
|
-
}),
|
|
138
|
-
const d =
|
|
139
|
-
return
|
|
140
|
-
}, [e._formValues, e._names, s]),
|
|
135
|
+
return h.current ? h.current(f) : f;
|
|
136
|
+
}), R = F.useCallback((f) => {
|
|
137
|
+
const d = qe(s, e._names, f || e._formValues, !1, V.current);
|
|
138
|
+
return h.current ? h.current(d) : d;
|
|
139
|
+
}, [e._formValues, e._names, s]), T = F.useCallback((f) => {
|
|
141
140
|
if (!i) {
|
|
142
|
-
const d =
|
|
143
|
-
if (
|
|
144
|
-
const
|
|
145
|
-
|
|
141
|
+
const d = qe(s, e._names, f || e._formValues, !1, V.current);
|
|
142
|
+
if (h.current) {
|
|
143
|
+
const A = h.current(d);
|
|
144
|
+
ae(A, k.current) || (I(A), k.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, T()), 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
|
+
T(f.values);
|
|
158
157
|
}
|
|
159
|
-
})), [e, c, s,
|
|
160
|
-
const
|
|
158
|
+
})), [e, c, s, T]), F.useEffect(() => e._removeUnmounted());
|
|
159
|
+
const U = g.current !== e, x = S.current, B = F.useMemo(() => {
|
|
161
160
|
if (i)
|
|
162
161
|
return null;
|
|
163
|
-
const f = !
|
|
164
|
-
return
|
|
165
|
-
}, [i,
|
|
166
|
-
return
|
|
162
|
+
const f = !U && !ae(x, s);
|
|
163
|
+
return U || f ? R() : null;
|
|
164
|
+
}, [i, U, s, x, R]);
|
|
165
|
+
return B !== null ? B : 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), h = F.useMemo(() => m(u._formValues, e, m(u._defaultValues, e, c)), [u, e, c]), k = Xe({
|
|
170
169
|
control: u,
|
|
171
170
|
name: e,
|
|
172
|
-
defaultValue:
|
|
171
|
+
defaultValue: h,
|
|
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: k,
|
|
180
|
+
...J(t.disabled) ? { disabled: t.disabled } : {}
|
|
182
181
|
}));
|
|
183
|
-
|
|
184
|
-
const
|
|
182
|
+
S.current = t;
|
|
183
|
+
const R = 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]), T = 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]), U = 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: () => G(f.focus) && f.focus(),
|
|
220
|
+
select: () => G(f.select) && f.select(),
|
|
221
|
+
setCustomValidity: (A) => G(f.setCustomValidity) && f.setCustomValidity(A),
|
|
222
|
+
reportValidity: () => G(f.reportValidity) && f.reportValidity()
|
|
224
223
|
});
|
|
225
|
-
}, [u._fields, e]),
|
|
224
|
+
}, [u._fields, e]), B = 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: k,
|
|
227
|
+
...J(s) || g.disabled ? { disabled: g.disabled || s } : {},
|
|
228
|
+
onChange: T,
|
|
229
|
+
onBlur: U,
|
|
230
|
+
ref: x
|
|
231
|
+
}), [e, s, g.disabled, T, U, x, k]);
|
|
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 = (w, W) => {
|
|
239
|
+
const K = m(u._fields, w);
|
|
240
|
+
K && K._f && (K._f.mount = W);
|
|
242
241
|
};
|
|
243
|
-
if (
|
|
244
|
-
const
|
|
245
|
-
|
|
242
|
+
if (A(e, !0), f) {
|
|
243
|
+
const w = M(m(u._options.defaultValues, e, S.current.defaultValue));
|
|
244
|
+
O(u._defaultValues, e, w), N(m(u._formValues, e)) && O(u._formValues, e, w);
|
|
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: B,
|
|
257
256
|
formState: g,
|
|
258
|
-
fieldState:
|
|
259
|
-
}), [
|
|
257
|
+
fieldState: R
|
|
258
|
+
}), [B, g, R]);
|
|
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 && H(u) && i) {
|
|
293
|
+
const c = wt(u, i);
|
|
294
|
+
H(c) && (e[s] = c);
|
|
296
295
|
} else t[s] && (e[s] = i);
|
|
297
296
|
}
|
|
298
297
|
return e;
|
|
299
298
|
}
|
|
300
|
-
var
|
|
301
|
-
if (!
|
|
299
|
+
var j = (t) => H(t) && !Object.keys(t).length, Ze = (t) => t.type === "file", xe = (t) => {
|
|
300
|
+
if (!Ke)
|
|
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", et = (t) => t.type === "radio", ir = (t) => et(t) || ve(t), Ne = (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 = N(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) && !N(t[r]))
|
|
316
315
|
return !1;
|
|
317
316
|
return !0;
|
|
318
317
|
}
|
|
319
|
-
function
|
|
320
|
-
const e = Array.isArray(r) ? r : Ee(r) ? [r] :
|
|
321
|
-
return s && delete s[i], u !== 0 && (
|
|
318
|
+
function P(t, r) {
|
|
319
|
+
const e = Array.isArray(r) ? r : Ee(r) ? [r] : Ye(r), s = e.length === 1 ? t : ur(t, e), u = e.length - 1, i = e[u];
|
|
320
|
+
return s && delete s[i], u !== 0 && (H(s) && j(s) || Array.isArray(s) && or(s)) && P(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 (G(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) || H(t) && !lr(t);
|
|
331
330
|
}
|
|
332
|
-
function
|
|
331
|
+
function Ge(t, r = {}) {
|
|
333
332
|
for (const e in t) {
|
|
334
333
|
const s = t[e];
|
|
335
|
-
|
|
334
|
+
Ct(s) ? (r[e] = Array.isArray(s) ? [] : {}, Ge(s, r[e])) : N(s) || (r[e] = !0);
|
|
336
335
|
}
|
|
337
336
|
return r;
|
|
338
337
|
}
|
|
339
|
-
function
|
|
340
|
-
e || (e =
|
|
338
|
+
function ce(t, r, e) {
|
|
339
|
+
e || (e = Ge(r));
|
|
341
340
|
for (const s in t) {
|
|
342
341
|
const u = t[s];
|
|
343
|
-
if (
|
|
344
|
-
|
|
342
|
+
if (Ct(u))
|
|
343
|
+
N(r) || je(e[s]) ? e[s] = Ge(u, Array.isArray(u) ? [] : {}) : ce(u, Q(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,28 +360,28 @@ 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 && !N(t[0].attributes.value) ? N(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
|
+
}, Tt = (t, { valueAsNumber: r, valueAsDate: e, setValueAs: s }) => N(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 Ot = (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
|
|
378
|
+
return Ze(r) ? r.files : et(r) ? Ot(t.refs).value : kt(r) ? [...r.selectedOptions].map(({ value: e }) => e) : ve(r) ? Dt(t.refs).value : Tt(N(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);
|
|
385
|
-
c &&
|
|
384
|
+
c && O(u, i, c._f);
|
|
386
385
|
}
|
|
387
386
|
return {
|
|
388
387
|
criteriaMode: e,
|
|
@@ -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,
|
|
394
|
-
isOnSubmit: !t || t ===
|
|
395
|
-
isOnBlur: t ===
|
|
396
|
-
isOnChange: t ===
|
|
397
|
-
isOnAll: t ===
|
|
398
|
-
isOnTouch: t ===
|
|
392
|
+
}, Se = (t) => t instanceof RegExp, he = (t) => N(t) ? t : Se(t) ? t.source : H(t) ? Se(t.value) ? t.value.source : t.value : t, de = (t) => ({
|
|
393
|
+
isOnSubmit: !t || t === re.onSubmit,
|
|
394
|
+
isOnBlur: t === re.onBlur,
|
|
395
|
+
isOnChange: t === re.onChange,
|
|
396
|
+
isOnAll: t === re.all,
|
|
397
|
+
isOnTouch: t === re.onTouched
|
|
399
398
|
});
|
|
400
|
-
const
|
|
401
|
-
var
|
|
402
|
-
const
|
|
399
|
+
const vt = "AsyncFunction";
|
|
400
|
+
var dr = (t) => !!t && !!t.validate && !!(G(t.validate) && t.validate.constructor.name === vt || H(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 (H(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
|
|
451
|
-
},
|
|
449
|
+
return j(i) || Object.keys(i).length >= Object.keys(r).length || Object.keys(i).find((c) => r[c] === (!s || re.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 && P(t, r), Rt = (t, r, e) => {
|
|
452
451
|
const s = z(m(t, e));
|
|
453
|
-
return
|
|
452
|
+
return O(s, "root", r[e]), O(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) => H(t) && !Se(t) ? t : {
|
|
464
463
|
value: t,
|
|
465
464
|
message: ""
|
|
466
|
-
},
|
|
467
|
-
const { ref: c, refs: l, required: V, maxLength:
|
|
468
|
-
if (!
|
|
465
|
+
}, ze = async (t, r, e, s, u, i) => {
|
|
466
|
+
const { ref: c, refs: l, required: V, maxLength: h, minLength: k, min: g, max: S, pattern: p, validate: I, name: R, valueAsNumber: T, mount: U } = t._f, x = m(e, R);
|
|
467
|
+
if (!U || r.has(R))
|
|
469
468
|
return {};
|
|
470
|
-
const
|
|
471
|
-
u &&
|
|
472
|
-
}, d = {},
|
|
473
|
-
const
|
|
474
|
-
d[
|
|
475
|
-
type:
|
|
476
|
-
message:
|
|
469
|
+
const B = l ? l[0] : c, f = (E) => {
|
|
470
|
+
u && B.reportValidity && (B.setCustomValidity(J(E) ? "" : E || ""), B.reportValidity());
|
|
471
|
+
}, d = {}, A = et(c), w = ve(c), W = A || w, K = (T || Ze(c)) && N(c.value) && N(x) || xe(c) && c.value === "" || x === "" || Array.isArray(x) && !x.length, Z = nr.bind(null, R, s, d), Fe = (E, C, $, q = ne.maxLength, se = ne.minLength) => {
|
|
472
|
+
const Y = E ? C : $;
|
|
473
|
+
d[R] = {
|
|
474
|
+
type: E ? q : se,
|
|
475
|
+
message: Y,
|
|
477
476
|
ref: c,
|
|
478
|
-
...
|
|
477
|
+
...Z(E ? q : se, Y)
|
|
479
478
|
};
|
|
480
479
|
};
|
|
481
|
-
if (i ? !Array.isArray(
|
|
482
|
-
const { value:
|
|
483
|
-
if (
|
|
480
|
+
if (i ? !Array.isArray(x) || !x.length : V && (!W && (K || Q(x)) || J(x) && !x || w && !Dt(l).isValid || A && !Ot(l).isValid)) {
|
|
481
|
+
const { value: E, message: C } = X(V) ? { value: !!V, message: V } : le(V);
|
|
482
|
+
if (E && (d[R] = {
|
|
484
483
|
type: ne.required,
|
|
485
|
-
message:
|
|
486
|
-
ref:
|
|
487
|
-
...
|
|
484
|
+
message: C,
|
|
485
|
+
ref: B,
|
|
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 (!
|
|
495
|
-
const
|
|
496
|
-
|
|
490
|
+
if (!K && (!Q(g) || !Q(S))) {
|
|
491
|
+
let E, C;
|
|
492
|
+
const $ = le(S), q = le(g);
|
|
493
|
+
if (!Q(x) && !isNaN(x)) {
|
|
494
|
+
const se = c.valueAsNumber || x && +x;
|
|
495
|
+
Q($.value) || (E = se > $.value), Q(q.value) || (C = se < q.value);
|
|
497
496
|
} else {
|
|
498
|
-
const
|
|
499
|
-
|
|
497
|
+
const se = c.valueAsDate || new Date(x), Y = (ge) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + ge), me = c.type == "time", _e = c.type == "week";
|
|
498
|
+
X($.value) && x && (E = me ? Y(x) > Y($.value) : _e ? x > $.value : se > new Date($.value)), X(q.value) && x && (C = me ? Y(x) < Y(q.value) : _e ? x < q.value : se < new Date(q.value));
|
|
500
499
|
}
|
|
501
|
-
if ((
|
|
502
|
-
return f(d[
|
|
500
|
+
if ((E || C) && (Fe(!!E, $.message, q.message, ne.max, ne.min), !s))
|
|
501
|
+
return f(d[R].message), d;
|
|
503
502
|
}
|
|
504
|
-
if ((
|
|
505
|
-
const
|
|
506
|
-
if ((
|
|
507
|
-
return f(d[
|
|
503
|
+
if ((h || k) && !K && (X(x) || i && Array.isArray(x))) {
|
|
504
|
+
const E = le(h), C = le(k), $ = !Q(E.value) && x.length > +E.value, q = !Q(C.value) && x.length < +C.value;
|
|
505
|
+
if (($ || q) && (Fe($, E.message, C.message), !s))
|
|
506
|
+
return f(d[R].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[R] = {
|
|
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 (G(I)) {
|
|
520
|
+
const E = await I(x, e), C = Ft(E, B);
|
|
521
|
+
if (C && (d[R] = {
|
|
522
|
+
...C,
|
|
523
|
+
...Z(ne.validate, C.message)
|
|
525
524
|
}, !s))
|
|
526
|
-
return f(
|
|
527
|
-
} else if (
|
|
528
|
-
let
|
|
529
|
-
for (const
|
|
530
|
-
if (!
|
|
525
|
+
return f(C.message), d;
|
|
526
|
+
} else if (H(I)) {
|
|
527
|
+
let E = {};
|
|
528
|
+
for (const C in I) {
|
|
529
|
+
if (!j(E) && !s)
|
|
531
530
|
break;
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
...
|
|
536
|
-
}, f(
|
|
531
|
+
const $ = Ft(await I[C](x, e), B, C);
|
|
532
|
+
$ && (E = {
|
|
533
|
+
...$,
|
|
534
|
+
...Z(C, $.message)
|
|
535
|
+
}, f($.message), s && (d[R] = E));
|
|
537
536
|
}
|
|
538
|
-
if (!
|
|
539
|
-
ref:
|
|
540
|
-
...
|
|
537
|
+
if (!j(E) && (d[R] = {
|
|
538
|
+
ref: B,
|
|
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: re.onSubmit,
|
|
548
|
+
reValidateMode: re.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: G(r.defaultValues),
|
|
561
560
|
isValidating: !1,
|
|
562
561
|
isSubmitted: !1,
|
|
563
562
|
isSubmitting: !1,
|
|
@@ -568,18 +567,19 @@ function hr(t = {}) {
|
|
|
568
567
|
validatingFields: {},
|
|
569
568
|
errors: r.errors || {},
|
|
570
569
|
disabled: r.disabled || !1
|
|
571
|
-
}, s = {}, u =
|
|
570
|
+
}, s = {}, u = H(r.defaultValues) || H(r.values) ? M(r.defaultValues || r.values) || {} : {}, i = r.shouldUnregister ? {} : M(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(),
|
|
578
578
|
unMount: /* @__PURE__ */ new Set(),
|
|
579
579
|
array: /* @__PURE__ */ new Set(),
|
|
580
580
|
watch: /* @__PURE__ */ new Set()
|
|
581
|
-
}, V,
|
|
582
|
-
const
|
|
581
|
+
}, V, h = 0;
|
|
582
|
+
const k = {
|
|
583
583
|
isDirty: !1,
|
|
584
584
|
dirtyFields: !1,
|
|
585
585
|
validatingFields: !1,
|
|
@@ -587,277 +587,278 @@ function hr(t = {}) {
|
|
|
587
587
|
isValidating: !1,
|
|
588
588
|
isValid: !1,
|
|
589
589
|
errors: !1
|
|
590
|
+
}, g = {
|
|
591
|
+
...k
|
|
590
592
|
};
|
|
591
|
-
let
|
|
592
|
-
...
|
|
593
|
+
let S = {
|
|
594
|
+
...g
|
|
593
595
|
};
|
|
594
|
-
const
|
|
595
|
-
array:
|
|
596
|
-
state:
|
|
597
|
-
},
|
|
598
|
-
clearTimeout(
|
|
599
|
-
},
|
|
600
|
-
if (!r.disabled && (
|
|
601
|
-
|
|
602
|
-
n !== e.isValid &&
|
|
596
|
+
const p = {
|
|
597
|
+
array: yt(),
|
|
598
|
+
state: yt()
|
|
599
|
+
}, I = r.criteriaMode === re.all, R = (a) => (n) => {
|
|
600
|
+
clearTimeout(h), h = setTimeout(a, n);
|
|
601
|
+
}, T = async (a) => {
|
|
602
|
+
if (!c.keepIsValid && !r.disabled && (g.isValid || S.isValid || a)) {
|
|
603
|
+
let n;
|
|
604
|
+
r.resolver ? (n = j((await W()).errors), U()) : n = await Z(s, !0), n !== e.isValid && p.state.next({
|
|
603
605
|
isValid: n
|
|
604
606
|
});
|
|
605
607
|
}
|
|
606
|
-
},
|
|
607
|
-
!r.disabled && (
|
|
608
|
-
o && (n ?
|
|
609
|
-
}),
|
|
608
|
+
}, U = (a, n) => {
|
|
609
|
+
!r.disabled && (g.isValidating || g.validatingFields || S.isValidating || S.validatingFields) && ((a || Array.from(l.mount)).forEach((o) => {
|
|
610
|
+
o && (n ? O(e.validatingFields, o, n) : P(e.validatingFields, o));
|
|
611
|
+
}), p.state.next({
|
|
610
612
|
validatingFields: e.validatingFields,
|
|
611
|
-
isValidating: !
|
|
613
|
+
isValidating: !j(e.validatingFields)
|
|
612
614
|
}));
|
|
613
|
-
},
|
|
614
|
-
if (
|
|
615
|
+
}, x = (a, n = [], o, v, _ = !0, y = !0) => {
|
|
616
|
+
if (v && o && !r.disabled) {
|
|
615
617
|
if (c.action = !0, y && Array.isArray(m(s, a))) {
|
|
616
|
-
const
|
|
617
|
-
_ &&
|
|
618
|
+
const b = o(m(s, a), v.argA, v.argB);
|
|
619
|
+
_ && O(s, a, b);
|
|
618
620
|
}
|
|
619
621
|
if (y && Array.isArray(m(e.errors, a))) {
|
|
620
|
-
const
|
|
621
|
-
_ &&
|
|
622
|
+
const b = o(m(e.errors, a), v.argA, v.argB);
|
|
623
|
+
_ && O(e.errors, a, b), gr(e.errors, a);
|
|
622
624
|
}
|
|
623
|
-
if ((
|
|
624
|
-
const
|
|
625
|
-
_ &&
|
|
625
|
+
if ((g.touchedFields || S.touchedFields) && y && Array.isArray(m(e.touchedFields, a))) {
|
|
626
|
+
const b = o(m(e.touchedFields, a), v.argA, v.argB);
|
|
627
|
+
_ && O(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
|
-
|
|
636
|
-
},
|
|
637
|
-
|
|
637
|
+
O(i, a, n);
|
|
638
|
+
}, B = (a, n) => {
|
|
639
|
+
O(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, v) => {
|
|
646
648
|
const _ = m(s, a);
|
|
647
649
|
if (_) {
|
|
648
|
-
const y = m(i, a,
|
|
649
|
-
|
|
650
|
+
const y = m(i, a, N(o) ? m(u, a) : o);
|
|
651
|
+
N(y) || v && v.defaultChecked || n ? O(i, a, n ? y : ht(_._f)) : q(a, y), c.mount && !c.action && T();
|
|
650
652
|
}
|
|
651
|
-
},
|
|
652
|
-
let y = !1,
|
|
653
|
-
const
|
|
653
|
+
}, A = (a, n, o, v, _) => {
|
|
654
|
+
let y = !1, b = !1;
|
|
655
|
+
const D = {
|
|
654
656
|
name: a
|
|
655
657
|
};
|
|
656
658
|
if (!r.disabled) {
|
|
657
|
-
if (!o ||
|
|
658
|
-
(
|
|
659
|
-
const
|
|
660
|
-
|
|
659
|
+
if (!o || v) {
|
|
660
|
+
(g.isDirty || S.isDirty) && (b = e.isDirty, e.isDirty = D.isDirty = E(), y = b !== D.isDirty);
|
|
661
|
+
const L = ae(m(u, a), n);
|
|
662
|
+
b = !!m(e.dirtyFields, a), L ? P(e.dirtyFields, a) : O(e.dirtyFields, a, !0), D.dirtyFields = e.dirtyFields, y = y || (g.dirtyFields || S.dirtyFields) && b !== !L;
|
|
661
663
|
}
|
|
662
664
|
if (o) {
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
+
const L = m(e.touchedFields, a);
|
|
666
|
+
L || (O(e.touchedFields, a, o), D.touchedFields = e.touchedFields, y = y || (g.touchedFields || S.touchedFields) && L !== 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
|
|
673
|
-
...
|
|
674
|
-
...y &&
|
|
670
|
+
return y ? D : {};
|
|
671
|
+
}, w = (a, n, o, v) => {
|
|
672
|
+
const _ = m(e.errors, a), y = (g.isValid || S.isValid) && J(n) && e.isValid !== n;
|
|
673
|
+
if (r.delayError && o ? (V = R(() => B(a, o)), V(r.delayError)) : (clearTimeout(h), V = null, o ? O(e.errors, a, o) : P(e.errors, a)), (o ? !ae(_, o) : _) || !j(v) || y) {
|
|
674
|
+
const b = {
|
|
675
|
+
...v,
|
|
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
|
+
}, W = async (a) => (U(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 W(a);
|
|
687
|
+
if (U(a), a)
|
|
690
688
|
for (const o of a) {
|
|
691
|
-
const
|
|
692
|
-
|
|
689
|
+
const v = m(n, o);
|
|
690
|
+
v ? O(e.errors, o, v) : P(e.errors, o);
|
|
693
691
|
}
|
|
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
|
-
for (const
|
|
701
|
-
const _ = a[
|
|
698
|
+
for (const v in a) {
|
|
699
|
+
const _ = a[v];
|
|
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), L = _._f && dr(_._f);
|
|
704
|
+
L && g.validatingFields && U([y.name], !0);
|
|
705
|
+
const ee = await ze(_, l.disabled, i, I, r.shouldUseNativeValidation && !n, D);
|
|
706
|
+
if (L && g.validatingFields && U([y.name]), ee[y.name] && (o.valid = !1, n))
|
|
709
707
|
break;
|
|
710
|
-
!n && (m(
|
|
708
|
+
!n && (m(ee, y.name) ? D ? Rt(e.errors, ee, y.name) : O(e.errors, y.name, ee[y.name]) : P(e.errors, y.name));
|
|
711
709
|
}
|
|
712
|
-
!
|
|
710
|
+
!j(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
|
-
n && (n._f.refs ? n._f.refs.every((o) => !
|
|
717
|
+
n && (n._f.refs ? n._f.refs.every((o) => !Ne(o)) : !Ne(n._f.ref)) && Ce(a);
|
|
720
718
|
}
|
|
721
719
|
l.unMount = /* @__PURE__ */ new Set();
|
|
722
|
-
},
|
|
723
|
-
...c.mount ? i :
|
|
724
|
-
}, o, n),
|
|
725
|
-
const
|
|
720
|
+
}, E = (a, n) => !r.disabled && (a && n && O(i, a, n), !ae(rt(), u)), C = (a, n, o) => qe(a, l, {
|
|
721
|
+
...c.mount ? i : N(n) ? u : X(a) ? { [a]: n } : n
|
|
722
|
+
}, o, n), $ = (a) => we(m(c.mount ? i : u, a, r.shouldUnregister ? m(u, a, []) : [])), q = (a, n, o = {}) => {
|
|
723
|
+
const v = m(s, a);
|
|
726
724
|
let _ = n;
|
|
727
|
-
if (
|
|
728
|
-
const y =
|
|
729
|
-
y && (!y.disabled &&
|
|
730
|
-
(!
|
|
731
|
-
}) : y.refs.forEach((
|
|
725
|
+
if (v) {
|
|
726
|
+
const y = v._f;
|
|
727
|
+
y && (!y.disabled && O(i, a, Tt(n, y)), _ = xe(y.ref) && Q(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 === _) : Ze(y.ref) ? y.ref.value = "" : (y.ref.value = _, y.ref.type || p.state.next({
|
|
732
730
|
name: a,
|
|
733
|
-
values:
|
|
731
|
+
values: M(i)
|
|
734
732
|
})));
|
|
735
733
|
}
|
|
736
|
-
(o.shouldDirty || o.shouldTouch) &&
|
|
737
|
-
},
|
|
738
|
-
for (const
|
|
739
|
-
if (!n.hasOwnProperty(
|
|
734
|
+
(o.shouldDirty || o.shouldTouch) && A(a, _, o.shouldTouch, o.shouldDirty, !0), o.shouldValidate && ge(a);
|
|
735
|
+
}, se = (a, n, o) => {
|
|
736
|
+
for (const v in n) {
|
|
737
|
+
if (!n.hasOwnProperty(v))
|
|
740
738
|
return;
|
|
741
|
-
const _ = n[
|
|
742
|
-
(l.array.has(a) ||
|
|
739
|
+
const _ = n[v], y = a + "." + v, b = m(s, y);
|
|
740
|
+
(l.array.has(a) || H(_) || b && !b._f) && !oe(_) ? se(y, _, o) : q(y, _, o);
|
|
743
741
|
}
|
|
744
|
-
},
|
|
745
|
-
const
|
|
746
|
-
|
|
742
|
+
}, Y = (a, n, o = {}) => {
|
|
743
|
+
const v = m(s, a), _ = l.array.has(a), y = M(n);
|
|
744
|
+
O(i, a, y), _ ? (p.array.next({
|
|
747
745
|
name: a,
|
|
748
|
-
values:
|
|
749
|
-
}), (
|
|
746
|
+
values: M(i)
|
|
747
|
+
}), (g.isDirty || g.dirtyFields || S.isDirty || S.dirtyFields) && o.shouldDirty && p.state.next({
|
|
750
748
|
name: a,
|
|
751
|
-
dirtyFields:
|
|
752
|
-
isDirty:
|
|
753
|
-
})) :
|
|
749
|
+
dirtyFields: ce(u, i),
|
|
750
|
+
isDirty: E(a, y)
|
|
751
|
+
})) : v && !v._f && !Q(y) ? se(a, y, o) : q(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: M(i)
|
|
756
754
|
});
|
|
757
|
-
},
|
|
755
|
+
}, me = async (a) => {
|
|
758
756
|
c.mount = !0;
|
|
759
757
|
const n = a.target;
|
|
760
|
-
let o = n.name,
|
|
761
|
-
const _ = m(s, o), y = (
|
|
762
|
-
|
|
763
|
-
},
|
|
758
|
+
let o = n.name, v = !0;
|
|
759
|
+
const _ = m(s, o), y = (L) => {
|
|
760
|
+
v = Number.isNaN(L) || oe(L) && isNaN(L.getTime()) || ae(L, m(i, o, L));
|
|
761
|
+
}, b = de(r.mode), D = de(r.reValidateMode);
|
|
764
762
|
if (_) {
|
|
765
|
-
let
|
|
766
|
-
const be = n.type ?
|
|
767
|
-
|
|
768
|
-
const
|
|
769
|
-
if (!ie &&
|
|
763
|
+
let L, 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), Oe = Qe(o, l, ie);
|
|
765
|
+
O(i, o, be), ie ? (!n || !n.readOnly) && (_._f.onBlur && _._f.onBlur(a), V && V(0)) : _._f.onChange && _._f.onChange(a);
|
|
766
|
+
const Re = A(o, be, ie), jt = !j(Re) || Oe;
|
|
767
|
+
if (!ie && p.state.next({
|
|
770
768
|
name: o,
|
|
771
769
|
type: a.type,
|
|
772
|
-
values:
|
|
773
|
-
}),
|
|
774
|
-
return (
|
|
775
|
-
if (!ie &&
|
|
776
|
-
const { errors:
|
|
777
|
-
if (y(be),
|
|
778
|
-
const
|
|
779
|
-
|
|
770
|
+
values: M(i)
|
|
771
|
+
}), qt)
|
|
772
|
+
return (g.isValid || S.isValid) && (r.mode === "onBlur" ? ie && T() : ie || T()), jt && p.state.next({ name: o, ...Oe ? {} : Re });
|
|
773
|
+
if (!ie && Oe && p.state.next({ ...e }), r.resolver) {
|
|
774
|
+
const { errors: dt } = await W([o]);
|
|
775
|
+
if (U([o]), y(be), v) {
|
|
776
|
+
const Gt = Vt(e.errors, s, o), ft = Vt(dt, s, Gt.name || o);
|
|
777
|
+
L = ft.error, o = ft.name, ee = j(dt);
|
|
780
778
|
}
|
|
781
779
|
} else
|
|
782
|
-
|
|
783
|
-
|
|
780
|
+
U([o], !0), L = (await ze(_, l.disabled, i, I, r.shouldUseNativeValidation))[o], U([o]), y(be), v && (L ? ee = !1 : (g.isValid || S.isValid) && (ee = await Z(s, !0)));
|
|
781
|
+
v && (_._f.deps && (!Array.isArray(_._f.deps) || _._f.deps.length > 0) && ge(_._f.deps), w(o, ee, L, Re));
|
|
784
782
|
}
|
|
785
783
|
}, _e = (a, n) => {
|
|
786
784
|
if (m(e.errors, n) && a.focus)
|
|
787
785
|
return a.focus(), 1;
|
|
788
|
-
},
|
|
789
|
-
let o,
|
|
786
|
+
}, ge = async (a, n = {}) => {
|
|
787
|
+
let o, v;
|
|
790
788
|
const _ = z(a);
|
|
791
789
|
if (r.resolver) {
|
|
792
|
-
const y = await
|
|
793
|
-
o =
|
|
794
|
-
} else a ? (
|
|
795
|
-
const
|
|
796
|
-
return await
|
|
797
|
-
}))).every(Boolean), !(!
|
|
798
|
-
return
|
|
799
|
-
...!
|
|
790
|
+
const y = await K(N(a) ? a : _);
|
|
791
|
+
o = j(y), v = a ? !_.some((b) => m(y, b)) : o;
|
|
792
|
+
} else a ? (v = (await Promise.all(_.map(async (y) => {
|
|
793
|
+
const b = m(s, y);
|
|
794
|
+
return await Z(b && b._f ? { [y]: b } : b);
|
|
795
|
+
}))).every(Boolean), !(!v && !e.isValid) && T()) : v = 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 && !
|
|
803
|
-
},
|
|
800
|
+
}), n.shouldFocus && !v && fe(s, _e, a ? _ : l.mount), v;
|
|
801
|
+
}, rt = (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)), N(a) ? o : X(a) ? m(o, a) : a.map((v) => m(o, v));
|
|
806
|
+
}, st = (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) =>
|
|
812
|
+
}), Mt = (a) => {
|
|
813
|
+
a && z(a).forEach((n) => P(e.errors, n)), p.state.next({
|
|
816
814
|
errors: a ? e.errors : {}
|
|
817
815
|
});
|
|
818
|
-
},
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
...
|
|
816
|
+
}, at = (a, n, o) => {
|
|
817
|
+
const v = (m(s, a, { _f: {} })._f || {}).ref, _ = m(e.errors, a) || {}, { ref: y, message: b, type: D, ...L } = _;
|
|
818
|
+
O(e.errors, a, {
|
|
819
|
+
...L,
|
|
822
820
|
...n,
|
|
823
|
-
ref:
|
|
824
|
-
}),
|
|
821
|
+
ref: v
|
|
822
|
+
}), p.state.next({
|
|
825
823
|
name: a,
|
|
826
824
|
errors: e.errors,
|
|
827
825
|
isValid: !1
|
|
828
|
-
}), o && o.shouldFocus &&
|
|
829
|
-
},
|
|
830
|
-
next: (o) => "values" in o && a(
|
|
831
|
-
}) :
|
|
826
|
+
}), o && o.shouldFocus && v && v.focus && v.focus();
|
|
827
|
+
}, It = (a, n) => G(a) ? p.state.subscribe({
|
|
828
|
+
next: (o) => "values" in o && a(C(void 0, n), o)
|
|
829
|
+
}) : C(a, n, !0), nt = (a) => p.state.subscribe({
|
|
832
830
|
next: (n) => {
|
|
833
|
-
|
|
831
|
+
mr(a.name, n.name, a.exact) && yr(n, a.formState || g, $t, 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, Bt = (a) => (c.mount = !0, S = {
|
|
839
|
+
...S,
|
|
842
840
|
...a.formState
|
|
843
|
-
},
|
|
841
|
+
}, nt({
|
|
844
842
|
...a,
|
|
845
|
-
formState:
|
|
843
|
+
formState: {
|
|
844
|
+
...k,
|
|
845
|
+
...a.formState
|
|
846
|
+
}
|
|
846
847
|
})), Ce = (a, n = {}) => {
|
|
847
848
|
for (const o of a ? z(a) : l.mount)
|
|
848
|
-
l.mount.delete(o), l.array.delete(o), n.keepValue || (
|
|
849
|
-
|
|
850
|
-
values:
|
|
851
|
-
}),
|
|
849
|
+
l.mount.delete(o), l.array.delete(o), n.keepValue || (P(s, o), P(i, o)), !n.keepError && P(e.errors, o), !n.keepDirty && P(e.dirtyFields, o), !n.keepTouched && P(e.touchedFields, o), !n.keepIsValidating && P(e.validatingFields, o), !r.shouldUnregister && !n.keepDefaultValue && P(u, o);
|
|
850
|
+
p.state.next({
|
|
851
|
+
values: M(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 && T();
|
|
856
|
+
}, it = ({ 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
|
|
860
|
-
return
|
|
860
|
+
const v = J(n.disabled) || J(r.disabled);
|
|
861
|
+
return O(s, a, {
|
|
861
862
|
...o || {},
|
|
862
863
|
_f: {
|
|
863
864
|
...o && o._f ? o._f : { ref: { name: a } },
|
|
@@ -865,121 +866,121 @@ 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 ? it({
|
|
870
|
+
disabled: J(n.disabled) ? n.disabled : r.disabled,
|
|
870
871
|
name: a
|
|
871
|
-
}) :
|
|
872
|
-
...
|
|
872
|
+
}) : d(a, !0, n.value), {
|
|
873
|
+
...v ? { disabled: n.disabled || r.disabled } : {},
|
|
873
874
|
...r.progressive ? {
|
|
874
875
|
required: !!n.required,
|
|
875
|
-
min:
|
|
876
|
-
max:
|
|
877
|
-
minLength:
|
|
878
|
-
maxLength:
|
|
879
|
-
pattern:
|
|
876
|
+
min: he(n.min),
|
|
877
|
+
max: he(n.max),
|
|
878
|
+
minLength: he(n.minLength),
|
|
879
|
+
maxLength: he(n.maxLength),
|
|
880
|
+
pattern: he(n.pattern)
|
|
880
881
|
} : {},
|
|
881
882
|
name: a,
|
|
882
|
-
onChange:
|
|
883
|
-
onBlur:
|
|
883
|
+
onChange: me,
|
|
884
|
+
onBlur: me,
|
|
884
885
|
ref: (_) => {
|
|
885
886
|
if (_) {
|
|
886
887
|
De(a, n), o = m(s, a);
|
|
887
|
-
const y =
|
|
888
|
-
if (
|
|
888
|
+
const y = N(_.value) && _.querySelectorAll && _.querySelectorAll("input,select,textarea")[0] || _, b = ir(y), D = o._f.refs || [];
|
|
889
|
+
if (b ? D.find((L) => L === y) : y === o._f.ref)
|
|
889
890
|
return;
|
|
890
|
-
|
|
891
|
+
O(s, a, {
|
|
891
892
|
_f: {
|
|
892
893
|
...o._f,
|
|
893
|
-
...
|
|
894
|
+
...b ? {
|
|
894
895
|
refs: [
|
|
895
|
-
...
|
|
896
|
+
...D.filter(Ne),
|
|
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
|
-
},
|
|
908
|
-
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
_.disabled =
|
|
908
|
+
}, Te = () => r.shouldFocusError && fe(s, _e, l.mount), Pt = (a) => {
|
|
909
|
+
J(a) && (p.state.next({ disabled: a }), fe(s, (n, o) => {
|
|
910
|
+
const v = m(s, o);
|
|
911
|
+
v && (n.disabled = v._f.disabled || a, Array.isArray(v._f.refs) && v._f.refs.forEach((_) => {
|
|
912
|
+
_.disabled = v._f.disabled || a;
|
|
912
913
|
}));
|
|
913
914
|
}, 0, !1));
|
|
914
|
-
},
|
|
915
|
-
let
|
|
915
|
+
}, ut = (a, n) => async (o) => {
|
|
916
|
+
let v;
|
|
916
917
|
o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
|
|
917
|
-
let _ =
|
|
918
|
-
if (
|
|
918
|
+
let _ = M(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 W();
|
|
923
|
+
U(), e.errors = y, _ = M(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
|
-
if (
|
|
929
|
-
|
|
928
|
+
P(_, y);
|
|
929
|
+
if (P(e.errors, "root"), j(e.errors)) {
|
|
930
|
+
p.state.next({
|
|
930
931
|
errors: {}
|
|
931
932
|
});
|
|
932
933
|
try {
|
|
933
934
|
await a(_, o);
|
|
934
935
|
} catch (y) {
|
|
935
|
-
|
|
936
|
+
v = y;
|
|
936
937
|
}
|
|
937
938
|
} else
|
|
938
|
-
n && await n({ ...e.errors }, o),
|
|
939
|
-
if (
|
|
939
|
+
n && await n({ ...e.errors }, o), Te(), setTimeout(Te);
|
|
940
|
+
if (p.state.next({
|
|
940
941
|
isSubmitted: !0,
|
|
941
942
|
isSubmitting: !1,
|
|
942
|
-
isSubmitSuccessful:
|
|
943
|
+
isSubmitSuccessful: j(e.errors) && !v,
|
|
943
944
|
submitCount: e.submitCount + 1,
|
|
944
945
|
errors: e.errors
|
|
945
|
-
}),
|
|
946
|
-
throw
|
|
947
|
-
},
|
|
948
|
-
m(s, a) && (
|
|
949
|
-
},
|
|
950
|
-
const o = a ?
|
|
946
|
+
}), v)
|
|
947
|
+
throw v;
|
|
948
|
+
}, Wt = (a, n = {}) => {
|
|
949
|
+
m(s, a) && (N(n.defaultValue) ? Y(a, M(m(u, a))) : (Y(a, n.defaultValue), O(u, a, M(n.defaultValue))), n.keepTouched || P(e.touchedFields, a), n.keepDirty || (P(e.dirtyFields, a), e.isDirty = n.defaultValue ? E(a, M(m(u, a))) : E()), n.keepError || (P(e.errors, a), g.isValid && T()), p.state.next({ ...e }));
|
|
950
|
+
}, ot = (a, n = {}) => {
|
|
951
|
+
const o = a ? M(a) : u, v = M(o), _ = j(a), y = _ ? u : v;
|
|
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) ? O(y, D, m(i, D)) : Y(D, m(y, D));
|
|
959
960
|
} else {
|
|
960
|
-
if (
|
|
961
|
-
for (const
|
|
962
|
-
const
|
|
963
|
-
if (
|
|
964
|
-
const
|
|
965
|
-
if (xe(
|
|
966
|
-
const
|
|
967
|
-
if (
|
|
968
|
-
|
|
961
|
+
if (Ke && N(a))
|
|
962
|
+
for (const b of l.mount) {
|
|
963
|
+
const D = m(s, b);
|
|
964
|
+
if (D && D._f) {
|
|
965
|
+
const L = Array.isArray(D._f.refs) ? D._f.refs[0] : D._f.ref;
|
|
966
|
+
if (xe(L)) {
|
|
967
|
+
const ee = L.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 ? M(u) : {} : M(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 && !j(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
|
-
const o = m(s, a),
|
|
1007
|
-
if (
|
|
1008
|
-
const _ =
|
|
1009
|
-
_.focus && (
|
|
1006
|
+
}, lt = (a, n) => ot(G(a) ? a(i) : a, { ...r.resetOptions, ...n }), Ht = (a, n = {}) => {
|
|
1007
|
+
const o = m(s, a), v = o && o._f;
|
|
1008
|
+
if (v) {
|
|
1009
|
+
const _ = v.refs ? v.refs[0] : v.ref;
|
|
1010
|
+
_.focus && setTimeout(() => {
|
|
1011
|
+
_.focus(), n.shouldSelect && G(_.select) && _.select();
|
|
1012
|
+
});
|
|
1010
1013
|
}
|
|
1011
1014
|
}, $t = (a) => {
|
|
1012
1015
|
e = {
|
|
1013
1016
|
...e,
|
|
1014
1017
|
...a
|
|
1015
1018
|
};
|
|
1016
|
-
},
|
|
1019
|
+
}, ct = {
|
|
1017
1020
|
control: {
|
|
1018
1021
|
register: De,
|
|
1019
1022
|
unregister: Ce,
|
|
1020
|
-
getFieldState:
|
|
1021
|
-
handleSubmit:
|
|
1022
|
-
setError:
|
|
1023
|
-
_subscribe:
|
|
1024
|
-
_runSchema:
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1023
|
+
getFieldState: st,
|
|
1024
|
+
handleSubmit: ut,
|
|
1025
|
+
setError: at,
|
|
1026
|
+
_subscribe: nt,
|
|
1027
|
+
_runSchema: W,
|
|
1028
|
+
_updateIsValidating: U,
|
|
1029
|
+
_focusError: Te,
|
|
1030
|
+
_getWatch: C,
|
|
1031
|
+
_getDirty: E,
|
|
1032
|
+
_setValid: T,
|
|
1033
|
+
_setFieldArray: x,
|
|
1034
|
+
_setDisabledField: it,
|
|
1035
|
+
_setErrors: f,
|
|
1036
|
+
_getFieldArray: $,
|
|
1037
|
+
_reset: ot,
|
|
1038
|
+
_resetDefaultValues: () => G(r.defaultValues) && r.defaultValues().then((a) => {
|
|
1039
|
+
lt(a, r.resetOptions), p.state.next({
|
|
1036
1040
|
isLoading: !1
|
|
1037
1041
|
});
|
|
1038
1042
|
}),
|
|
1039
|
-
_removeUnmounted:
|
|
1040
|
-
_disableForm:
|
|
1041
|
-
_subjects:
|
|
1042
|
-
_proxyFormState:
|
|
1043
|
+
_removeUnmounted: Fe,
|
|
1044
|
+
_disableForm: Pt,
|
|
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: Bt,
|
|
1082
|
+
trigger: ge,
|
|
1079
1083
|
register: De,
|
|
1080
|
-
handleSubmit:
|
|
1081
|
-
watch:
|
|
1082
|
-
setValue:
|
|
1083
|
-
getValues:
|
|
1084
|
-
reset:
|
|
1085
|
-
resetField:
|
|
1086
|
-
clearErrors:
|
|
1084
|
+
handleSubmit: ut,
|
|
1085
|
+
watch: It,
|
|
1086
|
+
setValue: Y,
|
|
1087
|
+
getValues: rt,
|
|
1088
|
+
reset: lt,
|
|
1089
|
+
resetField: Wt,
|
|
1090
|
+
clearErrors: Mt,
|
|
1087
1091
|
unregister: Ce,
|
|
1088
|
-
setError:
|
|
1089
|
-
setFocus:
|
|
1090
|
-
getFieldState:
|
|
1092
|
+
setError: at,
|
|
1093
|
+
setFocus: Ht,
|
|
1094
|
+
getFieldState: st
|
|
1091
1095
|
};
|
|
1092
1096
|
return {
|
|
1093
|
-
...
|
|
1094
|
-
formControl:
|
|
1097
|
+
...ct,
|
|
1098
|
+
formControl: ct
|
|
1095
1099
|
};
|
|
1096
1100
|
}
|
|
1097
1101
|
var ue = () => {
|
|
@@ -1102,137 +1106,138 @@ 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
|
-
},
|
|
1109
|
+
}, Ue = (t, r, e = {}) => e.shouldFocus || N(e.shouldFocus) ? e.focusName || `${t}.${N(e.focusIndex) ? r : e.focusIndex}.` : "", Me = (t, r) => [
|
|
1106
1110
|
...t,
|
|
1107
1111
|
...z(r)
|
|
1108
|
-
],
|
|
1112
|
+
], Ie = (t) => Array.isArray(t) ? t.map(() => {
|
|
1109
1113
|
}) : void 0;
|
|
1110
|
-
function
|
|
1114
|
+
function Be(t, r, e) {
|
|
1111
1115
|
return [
|
|
1112
1116
|
...t.slice(0, r),
|
|
1113
1117
|
...z(e),
|
|
1114
1118
|
...t.slice(r)
|
|
1115
1119
|
];
|
|
1116
1120
|
}
|
|
1117
|
-
var
|
|
1121
|
+
var Pe = (t, r, e) => Array.isArray(t) ? (N(t[e]) && (t[e] = void 0), t.splice(e, 0, t.splice(r, 1)[0]), t) : [], We = (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
|
|
1132
|
+
var He = (t, r) => N(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)), h = F.useRef(e._getFieldArray(s).map(ue)), k = 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), h.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 =
|
|
1146
|
-
argA:
|
|
1145
|
+
const g = F.useCallback((f) => {
|
|
1146
|
+
k.current = !0, e._setFieldArray(s, f);
|
|
1147
|
+
}, [e, s]), S = (f, d) => {
|
|
1148
|
+
const A = z(M(f)), w = Me(e._getFieldArray(s), A);
|
|
1149
|
+
e._names.focus = Ue(s, w.length - 1, d), h.current = Me(h.current, A.map(ue)), g(w), V(w), e._setFieldArray(s, w, Me, {
|
|
1150
|
+
argA: Ie(f)
|
|
1147
1151
|
});
|
|
1148
|
-
},
|
|
1149
|
-
const
|
|
1150
|
-
e._names.focus =
|
|
1151
|
-
argA:
|
|
1152
|
+
}, p = (f, d) => {
|
|
1153
|
+
const A = z(M(f)), w = We(e._getFieldArray(s), A);
|
|
1154
|
+
e._names.focus = Ue(s, 0, d), h.current = We(h.current, A.map(ue)), g(w), V(w), e._setFieldArray(s, w, We, {
|
|
1155
|
+
argA: Ie(f)
|
|
1152
1156
|
});
|
|
1153
|
-
},
|
|
1154
|
-
const d =
|
|
1155
|
-
|
|
1157
|
+
}, I = (f) => {
|
|
1158
|
+
const d = He(e._getFieldArray(s), f);
|
|
1159
|
+
h.current = He(h.current, f), g(d), V(d), !Array.isArray(m(e._fields, s)) && O(e._fields, s, void 0), e._setFieldArray(s, d, He, {
|
|
1156
1160
|
argA: f
|
|
1157
1161
|
});
|
|
1158
|
-
},
|
|
1159
|
-
const
|
|
1160
|
-
e._names.focus =
|
|
1162
|
+
}, R = (f, d, A) => {
|
|
1163
|
+
const w = z(M(d)), W = Be(e._getFieldArray(s), f, w);
|
|
1164
|
+
e._names.focus = Ue(s, f, A), h.current = Be(h.current, f, w.map(ue)), g(W), V(W), e._setFieldArray(s, W, Be, {
|
|
1161
1165
|
argA: f,
|
|
1162
|
-
argB:
|
|
1166
|
+
argB: Ie(d)
|
|
1163
1167
|
});
|
|
1164
|
-
},
|
|
1165
|
-
const
|
|
1166
|
-
$e(
|
|
1168
|
+
}, T = (f, d) => {
|
|
1169
|
+
const A = e._getFieldArray(s);
|
|
1170
|
+
$e(A, f, d), $e(h.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
|
+
}, U = (f, d) => {
|
|
1175
|
+
const A = e._getFieldArray(s);
|
|
1176
|
+
Pe(A, f, d), Pe(h.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
|
-
|
|
1180
|
+
}, x = (f, d) => {
|
|
1181
|
+
const A = M(d), w = bt(e._getFieldArray(s), f, A);
|
|
1182
|
+
h.current = [...w].map((W, K) => !W || K === f ? ue() : h.current[K]), g(w), V([...w]), e._setFieldArray(s, w, bt, {
|
|
1179
1183
|
argA: f,
|
|
1180
|
-
argB:
|
|
1184
|
+
argB: A
|
|
1181
1185
|
}, !0, !1);
|
|
1182
|
-
},
|
|
1183
|
-
const d = z(
|
|
1184
|
-
|
|
1186
|
+
}, B = (f) => {
|
|
1187
|
+
const d = z(M(f));
|
|
1188
|
+
h.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
|
+
}), k.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 ? O(e._formState.errors, s, d) : P(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) && ze(f, e._names.disabled, e._formValues, e._options.criteriaMode === re.all, e._options.shouldUseNativeValidation, !0).then((d) => !j(d) && e._subjects.state.next({
|
|
1205
|
+
errors: Rt(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: M(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(), k.current = !1;
|
|
1215
|
+
}, [l, s, e]), F.useEffect(() => (!m(e._formValues, s) && e._setFieldArray(s), () => {
|
|
1216
|
+
const f = (d, A) => {
|
|
1217
|
+
const w = m(e._fields, d);
|
|
1218
|
+
w && w._f && (w._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(T, [g, s, e]),
|
|
1223
|
+
move: F.useCallback(U, [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(R, [g, s, e]),
|
|
1228
|
+
update: F.useCallback(x, [g, s, e]),
|
|
1229
|
+
replace: F.useCallback(B, [g, s, e]),
|
|
1230
|
+
fields: F.useMemo(() => l.map((f, d) => ({
|
|
1226
1231
|
...f,
|
|
1227
|
-
[u]:
|
|
1232
|
+
[u]: h.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: G(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: G(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 && !G(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,39 +1275,39 @@ 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 Lt = zt(void 0), Ar = ({ showAsterisk: t, children: r }) => /* @__PURE__ */ te(Lt.Provider, { value: { showAsterisk: t }, children: r }), pr = () => {
|
|
1304
|
+
const t = Kt(Lt);
|
|
1300
1305
|
if (!t)
|
|
1301
1306
|
throw new Error("useSuprFormContext must be used within a SuprFormProvider");
|
|
1302
1307
|
return t;
|
|
1303
1308
|
};
|
|
1304
|
-
function
|
|
1305
|
-
const { conditions: s, operator: u } = e, i = t.reduce((l, V,
|
|
1309
|
+
function Nt(t, r, e) {
|
|
1310
|
+
const { conditions: s, operator: u } = e, i = t.reduce((l, V, h) => (l[V] = r[h], l), {}), c = s.map((l) => {
|
|
1306
1311
|
const V = i[l.name];
|
|
1307
1312
|
switch (l.operator) {
|
|
1308
1313
|
case "EQUALS":
|
|
@@ -1331,19 +1336,19 @@ 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
|
-
const e =
|
|
1339
|
-
return
|
|
1340
|
-
},
|
|
1343
|
+
const e = ye(() => typeof r == "boolean" ? [] : (r == null ? void 0 : r.conditions.map((i) => i.name)) || [], [r]), s = Xe({ name: e });
|
|
1344
|
+
return ye(() => 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 =
|
|
1349
|
+
const e = ye(() => typeof r == "boolean" ? [] : (r == null ? void 0 : r.conditions.map((i) => i.name)) || [], [r]), s = Xe({ name: e }), u = ye(() => 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
|
-
},
|
|
1351
|
+
}, tt = ({
|
|
1347
1352
|
children: t,
|
|
1348
1353
|
name: r,
|
|
1349
1354
|
rules: e,
|
|
@@ -1352,53 +1357,74 @@ const pr = ({
|
|
|
1352
1357
|
id: i,
|
|
1353
1358
|
disabled: c,
|
|
1354
1359
|
shouldUnregister: l,
|
|
1355
|
-
visibility: V
|
|
1360
|
+
visibility: V,
|
|
1361
|
+
description: h
|
|
1356
1362
|
}) => {
|
|
1357
|
-
const { control:
|
|
1358
|
-
|
|
1359
|
-
|
|
1363
|
+
const { control: k } = Ve(), g = t.props.value ?? "", { showAsterisk: S } = pr(), p = t.props.onChange, I = t.props.onBlur, R = ye(() => i || crypto.randomUUID(), []), T = ye(() => {
|
|
1364
|
+
if (h)
|
|
1365
|
+
return typeof h == "string" ? { position: "LABEL_BOTTOM", text: h } : h;
|
|
1366
|
+
}, [h]);
|
|
1367
|
+
return /* @__PURE__ */ te(xr, { visibility: V, children: /* @__PURE__ */ te(Sr, { disabled: c, children: /* @__PURE__ */ te(
|
|
1368
|
+
ar,
|
|
1360
1369
|
{
|
|
1361
|
-
control:
|
|
1370
|
+
control: k,
|
|
1362
1371
|
name: r,
|
|
1363
1372
|
rules: e,
|
|
1364
|
-
defaultValue:
|
|
1373
|
+
defaultValue: g,
|
|
1365
1374
|
shouldUnregister: l,
|
|
1366
1375
|
render: ({
|
|
1367
|
-
field: { name:
|
|
1368
|
-
fieldState: { error:
|
|
1369
|
-
}) => /* @__PURE__ */
|
|
1376
|
+
field: { name: U, onBlur: x, value: B, onChange: f, ref: d, disabled: A },
|
|
1377
|
+
fieldState: { error: w }
|
|
1378
|
+
}) => /* @__PURE__ */ Le(
|
|
1370
1379
|
"div",
|
|
1371
1380
|
{
|
|
1372
1381
|
className: `controlled-field ${s}`,
|
|
1373
1382
|
style: { display: "flex", flexDirection: "column", gap: "5px" },
|
|
1374
1383
|
children: [
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1384
|
+
/* @__PURE__ */ Le(
|
|
1385
|
+
"div",
|
|
1386
|
+
{
|
|
1387
|
+
className: "controlled-field-description",
|
|
1388
|
+
style: {
|
|
1389
|
+
display: "inline-flex",
|
|
1390
|
+
...T && {
|
|
1391
|
+
gap: "2px",
|
|
1392
|
+
alignItems: "center",
|
|
1393
|
+
flexDirection: T.position === "LABEL_RIGHT" ? "row" : "column"
|
|
1394
|
+
}
|
|
1395
|
+
},
|
|
1396
|
+
children: [
|
|
1397
|
+
u && /* @__PURE__ */ Le("label", { htmlFor: R, className: "controlled-field-label", children: [
|
|
1398
|
+
u,
|
|
1399
|
+
S && !!e && /* @__PURE__ */ te("span", { style: { color: "red" }, children: " *" })
|
|
1400
|
+
] }),
|
|
1401
|
+
T && T.position !== "CONTROL_BOTTOM" && /* @__PURE__ */ te("span", { style: { color: "#a1a1a1", fontSize: 12 }, children: T.text })
|
|
1402
|
+
]
|
|
1403
|
+
}
|
|
1404
|
+
),
|
|
1379
1405
|
Ae(t, {
|
|
1380
1406
|
...t.props,
|
|
1381
|
-
id:
|
|
1382
|
-
name:
|
|
1383
|
-
disabled:
|
|
1384
|
-
onChange: (...
|
|
1385
|
-
|
|
1407
|
+
id: R,
|
|
1408
|
+
name: U,
|
|
1409
|
+
disabled: A,
|
|
1410
|
+
onChange: (...W) => {
|
|
1411
|
+
f(...W), p == null || p(...W);
|
|
1386
1412
|
},
|
|
1387
|
-
value:
|
|
1388
|
-
onBlur: (...
|
|
1389
|
-
|
|
1413
|
+
value: B,
|
|
1414
|
+
onBlur: (...W) => {
|
|
1415
|
+
x(), I == null || I(...W);
|
|
1390
1416
|
},
|
|
1391
|
-
ref:
|
|
1417
|
+
ref: d
|
|
1392
1418
|
}),
|
|
1393
|
-
|
|
1419
|
+
w && /* @__PURE__ */ te("div", { style: { color: "red", fontSize: 13 }, className: "controlled-field-error", children: w.message })
|
|
1394
1420
|
]
|
|
1395
1421
|
}
|
|
1396
1422
|
)
|
|
1397
1423
|
}
|
|
1398
1424
|
) }) });
|
|
1399
1425
|
};
|
|
1400
|
-
|
|
1401
|
-
const
|
|
1426
|
+
tt.displayName = "SuprFormControl";
|
|
1427
|
+
const Er = ({
|
|
1402
1428
|
name: t,
|
|
1403
1429
|
rules: r,
|
|
1404
1430
|
ref: e,
|
|
@@ -1406,56 +1432,56 @@ const Sr = ({
|
|
|
1406
1432
|
visibility: u,
|
|
1407
1433
|
disabled: i
|
|
1408
1434
|
}) => {
|
|
1409
|
-
const c =
|
|
1435
|
+
const c = Fr({
|
|
1410
1436
|
name: t,
|
|
1411
1437
|
rules: r
|
|
1412
1438
|
});
|
|
1413
|
-
|
|
1414
|
-
const l = (V,
|
|
1415
|
-
var
|
|
1416
|
-
if (!
|
|
1417
|
-
return
|
|
1418
|
-
const g =
|
|
1419
|
-
if (((
|
|
1420
|
-
const
|
|
1421
|
-
...
|
|
1422
|
-
conditions: ((
|
|
1439
|
+
At(e, () => c, [c]);
|
|
1440
|
+
const l = (V, h) => Yt.map(V, (k) => {
|
|
1441
|
+
var I, R;
|
|
1442
|
+
if (!Jt(k))
|
|
1443
|
+
return k;
|
|
1444
|
+
const g = k.props, S = k.type;
|
|
1445
|
+
if (((S == null ? void 0 : S.displayName) === "SuprFormControl" || S === tt || g.name !== void 0 && typeof S != "string") && g.name !== void 0) {
|
|
1446
|
+
const T = u ? u[g.name] : void 0, U = T ? {
|
|
1447
|
+
...T,
|
|
1448
|
+
conditions: ((I = T.conditions) == null ? void 0 : I.map((d) => ({
|
|
1423
1449
|
...d,
|
|
1424
|
-
name: `${
|
|
1450
|
+
name: `${h}${d.name}`
|
|
1425
1451
|
}))) || []
|
|
1426
|
-
} : void 0,
|
|
1427
|
-
...
|
|
1428
|
-
conditions: ((
|
|
1452
|
+
} : void 0, x = i ? i[g.name] : void 0, B = x ? {
|
|
1453
|
+
...x,
|
|
1454
|
+
conditions: ((R = x.conditions) == null ? void 0 : R.map((d) => ({
|
|
1429
1455
|
...d,
|
|
1430
|
-
name: `${
|
|
1456
|
+
name: `${h}${d.name}`
|
|
1431
1457
|
}))) || []
|
|
1432
1458
|
} : void 0, f = {
|
|
1433
1459
|
...g,
|
|
1434
|
-
name: `${
|
|
1435
|
-
visibility:
|
|
1436
|
-
disabled:
|
|
1460
|
+
name: `${h}${g.name}`,
|
|
1461
|
+
visibility: U,
|
|
1462
|
+
disabled: B
|
|
1437
1463
|
};
|
|
1438
|
-
return g.id !== void 0 && (f.id = `${
|
|
1464
|
+
return g.id !== void 0 && (f.id = `${h}${g.id}`), Ae(k, f);
|
|
1439
1465
|
}
|
|
1440
|
-
return g.children ? Ae(
|
|
1466
|
+
return g.children ? Ae(k, {
|
|
1441
1467
|
...g,
|
|
1442
|
-
children: l(g.children,
|
|
1443
|
-
}) :
|
|
1468
|
+
children: l(g.children, h)
|
|
1469
|
+
}) : k;
|
|
1444
1470
|
});
|
|
1445
|
-
return /* @__PURE__ */
|
|
1446
|
-
const
|
|
1447
|
-
return /* @__PURE__ */
|
|
1471
|
+
return /* @__PURE__ */ te(Qt, { children: c.fields.map((V, h) => {
|
|
1472
|
+
const k = `${t}.${h}.`;
|
|
1473
|
+
return /* @__PURE__ */ te(
|
|
1448
1474
|
"div",
|
|
1449
1475
|
{
|
|
1450
|
-
"data-index":
|
|
1476
|
+
"data-index": h,
|
|
1451
1477
|
style: { display: "contents" },
|
|
1452
1478
|
id: "field-array-item",
|
|
1453
|
-
children: l(s,
|
|
1479
|
+
children: l(s, k)
|
|
1454
1480
|
},
|
|
1455
|
-
|
|
1481
|
+
k
|
|
1456
1482
|
);
|
|
1457
1483
|
}) });
|
|
1458
|
-
},
|
|
1484
|
+
}, Ut = ({
|
|
1459
1485
|
children: t,
|
|
1460
1486
|
onSubmit: r = () => {
|
|
1461
1487
|
},
|
|
@@ -1468,47 +1494,47 @@ const Sr = ({
|
|
|
1468
1494
|
ref: l,
|
|
1469
1495
|
onChange: V
|
|
1470
1496
|
}) => {
|
|
1471
|
-
const
|
|
1497
|
+
const h = br({
|
|
1472
1498
|
mode: "onSubmit",
|
|
1473
1499
|
reValidateMode: "onChange",
|
|
1474
1500
|
shouldFocusError: !0,
|
|
1475
1501
|
...i
|
|
1476
1502
|
});
|
|
1477
|
-
return
|
|
1503
|
+
return At(
|
|
1478
1504
|
l,
|
|
1479
1505
|
() => ({
|
|
1480
|
-
setValue:
|
|
1481
|
-
setError:
|
|
1482
|
-
clearErrors:
|
|
1483
|
-
getValues:
|
|
1484
|
-
reset:
|
|
1485
|
-
setFocus:
|
|
1486
|
-
resetField:
|
|
1487
|
-
trigger:
|
|
1488
|
-
unregister:
|
|
1489
|
-
watch:
|
|
1490
|
-
handleSubmit:
|
|
1506
|
+
setValue: h.setValue,
|
|
1507
|
+
setError: h.setError,
|
|
1508
|
+
clearErrors: h.clearErrors,
|
|
1509
|
+
getValues: h.getValues,
|
|
1510
|
+
reset: h.reset,
|
|
1511
|
+
setFocus: h.setFocus,
|
|
1512
|
+
resetField: h.resetField,
|
|
1513
|
+
trigger: h.trigger,
|
|
1514
|
+
unregister: h.unregister,
|
|
1515
|
+
watch: h.watch,
|
|
1516
|
+
handleSubmit: h.handleSubmit
|
|
1491
1517
|
}),
|
|
1492
|
-
[
|
|
1493
|
-
),
|
|
1494
|
-
const
|
|
1518
|
+
[h]
|
|
1519
|
+
), Xt(() => {
|
|
1520
|
+
const k = h.watch((g) => {
|
|
1495
1521
|
V == null || V(g);
|
|
1496
1522
|
});
|
|
1497
|
-
return () =>
|
|
1498
|
-
}, [
|
|
1523
|
+
return () => k.unsubscribe();
|
|
1524
|
+
}, [h.watch]), /* @__PURE__ */ te(Ar, { showAsterisk: c, children: /* @__PURE__ */ te(tr, { ...h, children: /* @__PURE__ */ te(
|
|
1499
1525
|
"form",
|
|
1500
1526
|
{
|
|
1501
1527
|
noValidate: !0,
|
|
1502
|
-
onSubmit:
|
|
1528
|
+
onSubmit: h.handleSubmit(r, e),
|
|
1503
1529
|
style: s,
|
|
1504
1530
|
className: u,
|
|
1505
1531
|
children: t
|
|
1506
1532
|
}
|
|
1507
1533
|
) }) });
|
|
1508
1534
|
};
|
|
1509
|
-
|
|
1510
|
-
|
|
1535
|
+
Ut.Control = tt;
|
|
1536
|
+
Ut.ControlArray = Er;
|
|
1511
1537
|
export {
|
|
1512
|
-
|
|
1538
|
+
Ut as SuprForm
|
|
1513
1539
|
};
|
|
1514
1540
|
//# sourceMappingURL=suprform.es.js.map
|