@iress-oss/ids-components 6.0.0-alpha.3 → 6.0.0-alpha.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/dist/constants.js +1 -1
- package/dist/index.esm-BiUTGNH8.js +1080 -0
- package/dist/patterns/Form/Form.js +8 -11
- package/dist/patterns/Form/FormField/FormField.js +33 -27
- package/dist/patterns/Form/FormField/FormFieldset.js +5 -5
- package/dist/patterns/Form/HookForm/HookForm.js +54 -56
- package/dist/patterns/Form/components/LongForm.js +5 -5
- package/dist/patterns/Form/components/ShortForm.js +5 -5
- package/dist/patterns/Shadow/Shadow.js +82 -423
- package/dist/src/patterns/Form/Form.d.ts +2 -4
- package/dist/src/patterns/Form/FormField/FormField.d.ts +15 -2
- package/dist/src/patterns/Form/HookForm/HookForm.d.ts +2 -34
- package/dist/style.css +1 -1
- package/package.json +25 -9
- package/dist/index.esm-B6vzbp0e.js +0 -1215
|
@@ -1,1215 +0,0 @@
|
|
|
1
|
-
import v from "react";
|
|
2
|
-
var ge = (e) => e.type === "checkbox", ue = (e) => e instanceof Date, j = (e) => e == null;
|
|
3
|
-
const ft = (e) => typeof e == "object";
|
|
4
|
-
var U = (e) => !j(e) && !Array.isArray(e) && ft(e) && !ue(e), yt = (e) => U(e) && e.target ? ge(e.target) ? e.target.checked : e.target.value : e, Mt = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, _t = (e, s) => e.has(Mt(s)), Nt = (e) => {
|
|
5
|
-
const s = e.constructor && e.constructor.prototype;
|
|
6
|
-
return U(s) && s.hasOwnProperty("isPrototypeOf");
|
|
7
|
-
}, We = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
8
|
-
function T(e) {
|
|
9
|
-
let s;
|
|
10
|
-
const t = Array.isArray(e), i = typeof FileList < "u" ? e instanceof FileList : !1;
|
|
11
|
-
if (e instanceof Date)
|
|
12
|
-
s = new Date(e);
|
|
13
|
-
else if (e instanceof Set)
|
|
14
|
-
s = new Set(e);
|
|
15
|
-
else if (!(We && (e instanceof Blob || i)) && (t || U(e)))
|
|
16
|
-
if (s = t ? [] : {}, !t && !Nt(e))
|
|
17
|
-
s = e;
|
|
18
|
-
else
|
|
19
|
-
for (const n in e)
|
|
20
|
-
e.hasOwnProperty(n) && (s[n] = T(e[n]));
|
|
21
|
-
else
|
|
22
|
-
return e;
|
|
23
|
-
return s;
|
|
24
|
-
}
|
|
25
|
-
var he = (e) => Array.isArray(e) ? e.filter(Boolean) : [], O = (e) => e === void 0, c = (e, s, t) => {
|
|
26
|
-
if (!s || !U(e))
|
|
27
|
-
return t;
|
|
28
|
-
const i = he(s.split(/[,[\].]+?/)).reduce((n, u) => j(n) ? n : n[u], e);
|
|
29
|
-
return O(i) || i === e ? O(e[s]) ? t : e[s] : i;
|
|
30
|
-
}, Q = (e) => typeof e == "boolean", qe = (e) => /^\w*$/.test(e), gt = (e) => he(e.replace(/["|']|\]/g, "").split(/\.|\[/)), C = (e, s, t) => {
|
|
31
|
-
let i = -1;
|
|
32
|
-
const n = qe(s) ? [s] : gt(s), u = n.length, f = u - 1;
|
|
33
|
-
for (; ++i < u; ) {
|
|
34
|
-
const y = n[i];
|
|
35
|
-
let F = t;
|
|
36
|
-
if (i !== f) {
|
|
37
|
-
const x = e[y];
|
|
38
|
-
F = U(x) || Array.isArray(x) ? x : isNaN(+n[i + 1]) ? {} : [];
|
|
39
|
-
}
|
|
40
|
-
if (y === "__proto__" || y === "constructor" || y === "prototype")
|
|
41
|
-
return;
|
|
42
|
-
e[y] = F, e = e[y];
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const me = {
|
|
46
|
-
BLUR: "blur",
|
|
47
|
-
FOCUS_OUT: "focusout",
|
|
48
|
-
CHANGE: "change"
|
|
49
|
-
}, ee = {
|
|
50
|
-
onBlur: "onBlur",
|
|
51
|
-
onChange: "onChange",
|
|
52
|
-
onSubmit: "onSubmit",
|
|
53
|
-
onTouched: "onTouched",
|
|
54
|
-
all: "all"
|
|
55
|
-
}, ie = {
|
|
56
|
-
max: "max",
|
|
57
|
-
min: "min",
|
|
58
|
-
maxLength: "maxLength",
|
|
59
|
-
minLength: "minLength",
|
|
60
|
-
pattern: "pattern",
|
|
61
|
-
required: "required",
|
|
62
|
-
validate: "validate"
|
|
63
|
-
}, ht = v.createContext(null), xe = () => v.useContext(ht), rr = (e) => {
|
|
64
|
-
const { children: s, ...t } = e;
|
|
65
|
-
return v.createElement(ht.Provider, { value: t }, s);
|
|
66
|
-
};
|
|
67
|
-
var vt = (e, s, t, i = !0) => {
|
|
68
|
-
const n = {
|
|
69
|
-
defaultValues: s._defaultValues
|
|
70
|
-
};
|
|
71
|
-
for (const u in e)
|
|
72
|
-
Object.defineProperty(n, u, {
|
|
73
|
-
get: () => {
|
|
74
|
-
const f = u;
|
|
75
|
-
return s._proxyFormState[f] !== ee.all && (s._proxyFormState[f] = !i || ee.all), t && (t[f] = !0), e[f];
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
return n;
|
|
79
|
-
};
|
|
80
|
-
function Bt(e) {
|
|
81
|
-
const s = xe(), { control: t = s.control, disabled: i, name: n, exact: u } = e || {}, [f, y] = v.useState(t._formState), F = v.useRef({
|
|
82
|
-
isDirty: !1,
|
|
83
|
-
isLoading: !1,
|
|
84
|
-
dirtyFields: !1,
|
|
85
|
-
touchedFields: !1,
|
|
86
|
-
validatingFields: !1,
|
|
87
|
-
isValidating: !1,
|
|
88
|
-
isValid: !1,
|
|
89
|
-
errors: !1
|
|
90
|
-
}), x = v.useRef(n);
|
|
91
|
-
return x.current = n, v.useEffect(() => t._subscribe({
|
|
92
|
-
name: x.current,
|
|
93
|
-
formState: F.current,
|
|
94
|
-
exact: u,
|
|
95
|
-
callback: (w) => {
|
|
96
|
-
!i && y({
|
|
97
|
-
...t._formState,
|
|
98
|
-
...w
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}), [t, i, u]), v.useEffect(() => {
|
|
102
|
-
F.current.isValid && t._setValid(!0);
|
|
103
|
-
}, [t]), v.useMemo(() => vt(f, t, F.current, !1), [f, t]);
|
|
104
|
-
}
|
|
105
|
-
var se = (e) => typeof e == "string", bt = (e, s, t, i, n) => se(e) ? (i && s.watch.add(e), c(t, e, n)) : Array.isArray(e) ? e.map((u) => (i && s.watch.add(u), c(t, u))) : (i && (s.watchAll = !0), t);
|
|
106
|
-
function It(e) {
|
|
107
|
-
const s = xe(), { control: t = s.control, name: i, defaultValue: n, disabled: u, exact: f } = e || {}, y = v.useRef(i), F = v.useRef(n);
|
|
108
|
-
y.current = i, v.useEffect(() => t._subscribe({
|
|
109
|
-
name: y.current,
|
|
110
|
-
formState: {
|
|
111
|
-
values: !0
|
|
112
|
-
},
|
|
113
|
-
exact: f,
|
|
114
|
-
callback: (E) => !u && w(bt(y.current, t._names, E.values || t._formValues, !1, F.current))
|
|
115
|
-
}), [t, u, f]);
|
|
116
|
-
const [x, w] = v.useState(t._getWatch(i, n));
|
|
117
|
-
return v.useEffect(() => t._removeUnmounted()), x;
|
|
118
|
-
}
|
|
119
|
-
function sr(e) {
|
|
120
|
-
const s = xe(), { name: t, disabled: i, control: n = s.control, shouldUnregister: u } = e, f = _t(n._names.array, t), y = It({
|
|
121
|
-
control: n,
|
|
122
|
-
name: t,
|
|
123
|
-
defaultValue: c(n._formValues, t, c(n._defaultValues, t, e.defaultValue)),
|
|
124
|
-
exact: !0
|
|
125
|
-
}), F = Bt({
|
|
126
|
-
control: n,
|
|
127
|
-
name: t,
|
|
128
|
-
exact: !0
|
|
129
|
-
}), x = v.useRef(e), w = v.useRef(n.register(t, {
|
|
130
|
-
...e.rules,
|
|
131
|
-
value: y,
|
|
132
|
-
...Q(e.disabled) ? { disabled: e.disabled } : {}
|
|
133
|
-
})), E = v.useMemo(() => Object.defineProperties({}, {
|
|
134
|
-
invalid: {
|
|
135
|
-
enumerable: !0,
|
|
136
|
-
get: () => !!c(F.errors, t)
|
|
137
|
-
},
|
|
138
|
-
isDirty: {
|
|
139
|
-
enumerable: !0,
|
|
140
|
-
get: () => !!c(F.dirtyFields, t)
|
|
141
|
-
},
|
|
142
|
-
isTouched: {
|
|
143
|
-
enumerable: !0,
|
|
144
|
-
get: () => !!c(F.touchedFields, t)
|
|
145
|
-
},
|
|
146
|
-
isValidating: {
|
|
147
|
-
enumerable: !0,
|
|
148
|
-
get: () => !!c(F.validatingFields, t)
|
|
149
|
-
},
|
|
150
|
-
error: {
|
|
151
|
-
enumerable: !0,
|
|
152
|
-
get: () => c(F.errors, t)
|
|
153
|
-
}
|
|
154
|
-
}), [F, t]), A = v.useCallback((P) => w.current.onChange({
|
|
155
|
-
target: {
|
|
156
|
-
value: yt(P),
|
|
157
|
-
name: t
|
|
158
|
-
},
|
|
159
|
-
type: me.CHANGE
|
|
160
|
-
}), [t]), R = v.useCallback(() => w.current.onBlur({
|
|
161
|
-
target: {
|
|
162
|
-
value: c(n._formValues, t),
|
|
163
|
-
name: t
|
|
164
|
-
},
|
|
165
|
-
type: me.BLUR
|
|
166
|
-
}), [t, n._formValues]), G = v.useCallback((P) => {
|
|
167
|
-
const W = c(n._fields, t);
|
|
168
|
-
W && P && (W._f.ref = {
|
|
169
|
-
focus: () => P.focus(),
|
|
170
|
-
select: () => P.select(),
|
|
171
|
-
setCustomValidity: (m) => P.setCustomValidity(m),
|
|
172
|
-
reportValidity: () => P.reportValidity()
|
|
173
|
-
});
|
|
174
|
-
}, [n._fields, t]), I = v.useMemo(() => ({
|
|
175
|
-
name: t,
|
|
176
|
-
value: y,
|
|
177
|
-
...Q(i) || F.disabled ? { disabled: F.disabled || i } : {},
|
|
178
|
-
onChange: A,
|
|
179
|
-
onBlur: R,
|
|
180
|
-
ref: G
|
|
181
|
-
}), [t, i, F.disabled, A, R, G, y]);
|
|
182
|
-
return v.useEffect(() => {
|
|
183
|
-
const P = n._options.shouldUnregister || u;
|
|
184
|
-
n.register(t, {
|
|
185
|
-
...x.current.rules,
|
|
186
|
-
...Q(x.current.disabled) ? { disabled: x.current.disabled } : {}
|
|
187
|
-
});
|
|
188
|
-
const W = (m, Y) => {
|
|
189
|
-
const $ = c(n._fields, m);
|
|
190
|
-
$ && $._f && ($._f.mount = Y);
|
|
191
|
-
};
|
|
192
|
-
if (W(t, !0), P) {
|
|
193
|
-
const m = T(c(n._options.defaultValues, t));
|
|
194
|
-
C(n._defaultValues, t, m), O(c(n._formValues, t)) && C(n._formValues, t, m);
|
|
195
|
-
}
|
|
196
|
-
return !f && n.register(t), () => {
|
|
197
|
-
(f ? P && !n._state.action : P) ? n.unregister(t) : W(t, !1);
|
|
198
|
-
};
|
|
199
|
-
}, [t, n, f, u]), v.useEffect(() => {
|
|
200
|
-
n._setDisabledField({
|
|
201
|
-
disabled: i,
|
|
202
|
-
name: t
|
|
203
|
-
});
|
|
204
|
-
}, [i, t, n]), v.useMemo(() => ({
|
|
205
|
-
field: I,
|
|
206
|
-
formState: F,
|
|
207
|
-
fieldState: E
|
|
208
|
-
}), [I, F, E]);
|
|
209
|
-
}
|
|
210
|
-
var Pt = (e, s, t, i, n) => s ? {
|
|
211
|
-
...t[e],
|
|
212
|
-
types: {
|
|
213
|
-
...t[e] && t[e].types ? t[e].types : {},
|
|
214
|
-
[i]: n || !0
|
|
215
|
-
}
|
|
216
|
-
} : {}, z = (e) => Array.isArray(e) ? e : [e], st = () => {
|
|
217
|
-
let e = [];
|
|
218
|
-
return {
|
|
219
|
-
get observers() {
|
|
220
|
-
return e;
|
|
221
|
-
},
|
|
222
|
-
next: (n) => {
|
|
223
|
-
for (const u of e)
|
|
224
|
-
u.next && u.next(n);
|
|
225
|
-
},
|
|
226
|
-
subscribe: (n) => (e.push(n), {
|
|
227
|
-
unsubscribe: () => {
|
|
228
|
-
e = e.filter((u) => u !== n);
|
|
229
|
-
}
|
|
230
|
-
}),
|
|
231
|
-
unsubscribe: () => {
|
|
232
|
-
e = [];
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
}, Be = (e) => j(e) || !ft(e);
|
|
236
|
-
function le(e, s) {
|
|
237
|
-
if (Be(e) || Be(s))
|
|
238
|
-
return e === s;
|
|
239
|
-
if (ue(e) && ue(s))
|
|
240
|
-
return e.getTime() === s.getTime();
|
|
241
|
-
const t = Object.keys(e), i = Object.keys(s);
|
|
242
|
-
if (t.length !== i.length)
|
|
243
|
-
return !1;
|
|
244
|
-
for (const n of t) {
|
|
245
|
-
const u = e[n];
|
|
246
|
-
if (!i.includes(n))
|
|
247
|
-
return !1;
|
|
248
|
-
if (n !== "ref") {
|
|
249
|
-
const f = s[n];
|
|
250
|
-
if (ue(u) && ue(f) || U(u) && U(f) || Array.isArray(u) && Array.isArray(f) ? !le(u, f) : u !== f)
|
|
251
|
-
return !1;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
return !0;
|
|
255
|
-
}
|
|
256
|
-
var H = (e) => U(e) && !Object.keys(e).length, He = (e) => e.type === "file", te = (e) => typeof e == "function", Fe = (e) => {
|
|
257
|
-
if (!We)
|
|
258
|
-
return !1;
|
|
259
|
-
const s = e ? e.ownerDocument : 0;
|
|
260
|
-
return e instanceof (s && s.defaultView ? s.defaultView.HTMLElement : HTMLElement);
|
|
261
|
-
}, mt = (e) => e.type === "select-multiple", $e = (e) => e.type === "radio", Wt = (e) => $e(e) || ge(e), Ee = (e) => Fe(e) && e.isConnected;
|
|
262
|
-
function qt(e, s) {
|
|
263
|
-
const t = s.slice(0, -1).length;
|
|
264
|
-
let i = 0;
|
|
265
|
-
for (; i < t; )
|
|
266
|
-
e = O(e) ? i++ : e[s[i++]];
|
|
267
|
-
return e;
|
|
268
|
-
}
|
|
269
|
-
function Ht(e) {
|
|
270
|
-
for (const s in e)
|
|
271
|
-
if (e.hasOwnProperty(s) && !O(e[s]))
|
|
272
|
-
return !1;
|
|
273
|
-
return !0;
|
|
274
|
-
}
|
|
275
|
-
function B(e, s) {
|
|
276
|
-
const t = Array.isArray(s) ? s : qe(s) ? [s] : gt(s), i = t.length === 1 ? e : qt(e, t), n = t.length - 1, u = t[n];
|
|
277
|
-
return i && delete i[u], n !== 0 && (U(i) && H(i) || Array.isArray(i) && Ht(i)) && B(e, t.slice(0, -1)), e;
|
|
278
|
-
}
|
|
279
|
-
var Ft = (e) => {
|
|
280
|
-
for (const s in e)
|
|
281
|
-
if (te(e[s]))
|
|
282
|
-
return !0;
|
|
283
|
-
return !1;
|
|
284
|
-
};
|
|
285
|
-
function Ae(e, s = {}) {
|
|
286
|
-
const t = Array.isArray(e);
|
|
287
|
-
if (U(e) || t)
|
|
288
|
-
for (const i in e)
|
|
289
|
-
Array.isArray(e[i]) || U(e[i]) && !Ft(e[i]) ? (s[i] = Array.isArray(e[i]) ? [] : {}, Ae(e[i], s[i])) : j(e[i]) || (s[i] = !0);
|
|
290
|
-
return s;
|
|
291
|
-
}
|
|
292
|
-
function At(e, s, t) {
|
|
293
|
-
const i = Array.isArray(e);
|
|
294
|
-
if (U(e) || i)
|
|
295
|
-
for (const n in e)
|
|
296
|
-
Array.isArray(e[n]) || U(e[n]) && !Ft(e[n]) ? O(s) || Be(t[n]) ? t[n] = Array.isArray(e[n]) ? Ae(e[n], []) : { ...Ae(e[n]) } : At(e[n], j(s) ? {} : s[n], t[n]) : t[n] = !le(e[n], s[n]);
|
|
297
|
-
return t;
|
|
298
|
-
}
|
|
299
|
-
var ye = (e, s) => At(e, s, Ae(s));
|
|
300
|
-
const it = {
|
|
301
|
-
value: !1,
|
|
302
|
-
isValid: !1
|
|
303
|
-
}, at = { value: !0, isValid: !0 };
|
|
304
|
-
var Vt = (e) => {
|
|
305
|
-
if (Array.isArray(e)) {
|
|
306
|
-
if (e.length > 1) {
|
|
307
|
-
const s = e.filter((t) => t && t.checked && !t.disabled).map((t) => t.value);
|
|
308
|
-
return { value: s, isValid: !!s.length };
|
|
309
|
-
}
|
|
310
|
-
return e[0].checked && !e[0].disabled ? (
|
|
311
|
-
// @ts-expect-error expected to work in the browser
|
|
312
|
-
e[0].attributes && !O(e[0].attributes.value) ? O(e[0].value) || e[0].value === "" ? at : { value: e[0].value, isValid: !0 } : at
|
|
313
|
-
) : it;
|
|
314
|
-
}
|
|
315
|
-
return it;
|
|
316
|
-
}, xt = (e, { valueAsNumber: s, valueAsDate: t, setValueAs: i }) => O(e) ? e : s ? e === "" ? NaN : e && +e : t && se(e) ? new Date(e) : i ? i(e) : e;
|
|
317
|
-
const nt = {
|
|
318
|
-
isValid: !1,
|
|
319
|
-
value: null
|
|
320
|
-
};
|
|
321
|
-
var St = (e) => Array.isArray(e) ? e.reduce((s, t) => t && t.checked && !t.disabled ? {
|
|
322
|
-
isValid: !0,
|
|
323
|
-
value: t.value
|
|
324
|
-
} : s, nt) : nt;
|
|
325
|
-
function lt(e) {
|
|
326
|
-
const s = e.ref;
|
|
327
|
-
return He(s) ? s.files : $e(s) ? St(e.refs).value : mt(s) ? [...s.selectedOptions].map(({ value: t }) => t) : ge(s) ? Vt(e.refs).value : xt(O(s.value) ? e.ref.value : s.value, e);
|
|
328
|
-
}
|
|
329
|
-
var $t = (e, s, t, i) => {
|
|
330
|
-
const n = {};
|
|
331
|
-
for (const u of e) {
|
|
332
|
-
const f = c(s, u);
|
|
333
|
-
f && C(n, u, f._f);
|
|
334
|
-
}
|
|
335
|
-
return {
|
|
336
|
-
criteriaMode: t,
|
|
337
|
-
names: [...e],
|
|
338
|
-
fields: n,
|
|
339
|
-
shouldUseNativeValidation: i
|
|
340
|
-
};
|
|
341
|
-
}, Ve = (e) => e instanceof RegExp, _e = (e) => O(e) ? e : Ve(e) ? e.source : U(e) ? Ve(e.value) ? e.value.source : e.value : e, ce = (e) => ({
|
|
342
|
-
isOnSubmit: !e || e === ee.onSubmit,
|
|
343
|
-
isOnBlur: e === ee.onBlur,
|
|
344
|
-
isOnChange: e === ee.onChange,
|
|
345
|
-
isOnAll: e === ee.all,
|
|
346
|
-
isOnTouch: e === ee.onTouched
|
|
347
|
-
});
|
|
348
|
-
const ut = "AsyncFunction";
|
|
349
|
-
var jt = (e) => !!e && !!e.validate && !!(te(e.validate) && e.validate.constructor.name === ut || U(e.validate) && Object.values(e.validate).find((s) => s.constructor.name === ut)), Kt = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), Ie = (e, s, t) => !t && (s.watchAll || s.watch.has(e) || [...s.watch].some((i) => e.startsWith(i) && /^\.\w+/.test(e.slice(i.length))));
|
|
350
|
-
const de = (e, s, t, i) => {
|
|
351
|
-
for (const n of t || Object.keys(e)) {
|
|
352
|
-
const u = c(e, n);
|
|
353
|
-
if (u) {
|
|
354
|
-
const { _f: f, ...y } = u;
|
|
355
|
-
if (f) {
|
|
356
|
-
if (f.refs && f.refs[0] && s(f.refs[0], n) && !i)
|
|
357
|
-
return !0;
|
|
358
|
-
if (f.ref && s(f.ref, f.name) && !i)
|
|
359
|
-
return !0;
|
|
360
|
-
if (de(y, s))
|
|
361
|
-
break;
|
|
362
|
-
} else if (U(y) && de(y, s))
|
|
363
|
-
break;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
function ot(e, s, t) {
|
|
368
|
-
const i = c(e, t);
|
|
369
|
-
if (i || qe(t))
|
|
370
|
-
return {
|
|
371
|
-
error: i,
|
|
372
|
-
name: t
|
|
373
|
-
};
|
|
374
|
-
const n = t.split(".");
|
|
375
|
-
for (; n.length; ) {
|
|
376
|
-
const u = n.join("."), f = c(s, u), y = c(e, u);
|
|
377
|
-
if (f && !Array.isArray(f) && t !== u)
|
|
378
|
-
return { name: t };
|
|
379
|
-
if (y && y.type)
|
|
380
|
-
return {
|
|
381
|
-
name: u,
|
|
382
|
-
error: y
|
|
383
|
-
};
|
|
384
|
-
n.pop();
|
|
385
|
-
}
|
|
386
|
-
return {
|
|
387
|
-
name: t
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
var zt = (e, s, t, i) => {
|
|
391
|
-
t(e);
|
|
392
|
-
const { name: n, ...u } = e;
|
|
393
|
-
return H(u) || Object.keys(u).length >= Object.keys(s).length || Object.keys(u).find((f) => s[f] === (!i || ee.all));
|
|
394
|
-
}, Gt = (e, s, t) => !e || !s || e === s || z(e).some((i) => i && (t ? i === s : i.startsWith(s) || s.startsWith(i))), Yt = (e, s, t, i, n) => n.isOnAll ? !1 : !t && n.isOnTouch ? !(s || e) : (t ? i.isOnBlur : n.isOnBlur) ? !e : (t ? i.isOnChange : n.isOnChange) ? e : !0, Jt = (e, s) => !he(c(e, s)).length && B(e, s), wt = (e, s, t) => {
|
|
395
|
-
const i = z(c(e, t));
|
|
396
|
-
return C(i, "root", s[t]), C(e, t, i), e;
|
|
397
|
-
}, be = (e) => se(e);
|
|
398
|
-
function ct(e, s, t = "validate") {
|
|
399
|
-
if (be(e) || Array.isArray(e) && e.every(be) || Q(e) && !e)
|
|
400
|
-
return {
|
|
401
|
-
type: t,
|
|
402
|
-
message: be(e) ? e : "",
|
|
403
|
-
ref: s
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
var oe = (e) => U(e) && !Ve(e) ? e : {
|
|
407
|
-
value: e,
|
|
408
|
-
message: ""
|
|
409
|
-
}, Pe = async (e, s, t, i, n, u) => {
|
|
410
|
-
const { ref: f, refs: y, required: F, maxLength: x, minLength: w, min: E, max: A, pattern: R, validate: G, name: I, valueAsNumber: P, mount: W } = e._f, m = c(t, I);
|
|
411
|
-
if (!W || s.has(I))
|
|
412
|
-
return {};
|
|
413
|
-
const Y = y ? y[0] : f, $ = (p) => {
|
|
414
|
-
n && Y.reportValidity && (Y.setCustomValidity(Q(p) ? "" : p || ""), Y.reportValidity());
|
|
415
|
-
}, M = {}, b = $e(f), h = ge(f), V = b || h, D = (P || He(f)) && O(f.value) && O(m) || Fe(f) && f.value === "" || m === "" || Array.isArray(m) && !m.length, J = Pt.bind(null, I, i, M), X = (p, S, L, K = ie.maxLength, Z = ie.minLength) => {
|
|
416
|
-
const re = p ? S : L;
|
|
417
|
-
M[I] = {
|
|
418
|
-
type: p ? K : Z,
|
|
419
|
-
message: re,
|
|
420
|
-
ref: f,
|
|
421
|
-
...J(p ? K : Z, re)
|
|
422
|
-
};
|
|
423
|
-
};
|
|
424
|
-
if (u ? !Array.isArray(m) || !m.length : F && (!V && (D || j(m)) || Q(m) && !m || h && !Vt(y).isValid || b && !St(y).isValid)) {
|
|
425
|
-
const { value: p, message: S } = be(F) ? { value: !!F, message: F } : oe(F);
|
|
426
|
-
if (p && (M[I] = {
|
|
427
|
-
type: ie.required,
|
|
428
|
-
message: S,
|
|
429
|
-
ref: Y,
|
|
430
|
-
...J(ie.required, S)
|
|
431
|
-
}, !i))
|
|
432
|
-
return $(S), M;
|
|
433
|
-
}
|
|
434
|
-
if (!D && (!j(E) || !j(A))) {
|
|
435
|
-
let p, S;
|
|
436
|
-
const L = oe(A), K = oe(E);
|
|
437
|
-
if (!j(m) && !isNaN(m)) {
|
|
438
|
-
const Z = f.valueAsNumber || m && +m;
|
|
439
|
-
j(L.value) || (p = Z > L.value), j(K.value) || (S = Z < K.value);
|
|
440
|
-
} else {
|
|
441
|
-
const Z = f.valueAsDate || new Date(m), re = (ve) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + ve), ae = f.type == "time", fe = f.type == "week";
|
|
442
|
-
se(L.value) && m && (p = ae ? re(m) > re(L.value) : fe ? m > L.value : Z > new Date(L.value)), se(K.value) && m && (S = ae ? re(m) < re(K.value) : fe ? m < K.value : Z < new Date(K.value));
|
|
443
|
-
}
|
|
444
|
-
if ((p || S) && (X(!!p, L.message, K.message, ie.max, ie.min), !i))
|
|
445
|
-
return $(M[I].message), M;
|
|
446
|
-
}
|
|
447
|
-
if ((x || w) && !D && (se(m) || u && Array.isArray(m))) {
|
|
448
|
-
const p = oe(x), S = oe(w), L = !j(p.value) && m.length > +p.value, K = !j(S.value) && m.length < +S.value;
|
|
449
|
-
if ((L || K) && (X(L, p.message, S.message), !i))
|
|
450
|
-
return $(M[I].message), M;
|
|
451
|
-
}
|
|
452
|
-
if (R && !D && se(m)) {
|
|
453
|
-
const { value: p, message: S } = oe(R);
|
|
454
|
-
if (Ve(p) && !m.match(p) && (M[I] = {
|
|
455
|
-
type: ie.pattern,
|
|
456
|
-
message: S,
|
|
457
|
-
ref: f,
|
|
458
|
-
...J(ie.pattern, S)
|
|
459
|
-
}, !i))
|
|
460
|
-
return $(S), M;
|
|
461
|
-
}
|
|
462
|
-
if (G) {
|
|
463
|
-
if (te(G)) {
|
|
464
|
-
const p = await G(m, t), S = ct(p, Y);
|
|
465
|
-
if (S && (M[I] = {
|
|
466
|
-
...S,
|
|
467
|
-
...J(ie.validate, S.message)
|
|
468
|
-
}, !i))
|
|
469
|
-
return $(S.message), M;
|
|
470
|
-
} else if (U(G)) {
|
|
471
|
-
let p = {};
|
|
472
|
-
for (const S in G) {
|
|
473
|
-
if (!H(p) && !i)
|
|
474
|
-
break;
|
|
475
|
-
const L = ct(await G[S](m, t), Y, S);
|
|
476
|
-
L && (p = {
|
|
477
|
-
...L,
|
|
478
|
-
...J(S, L.message)
|
|
479
|
-
}, $(L.message), i && (M[I] = p));
|
|
480
|
-
}
|
|
481
|
-
if (!H(p) && (M[I] = {
|
|
482
|
-
ref: Y,
|
|
483
|
-
...p
|
|
484
|
-
}, !i))
|
|
485
|
-
return M;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
return $(!0), M;
|
|
489
|
-
};
|
|
490
|
-
const Qt = {
|
|
491
|
-
mode: ee.onSubmit,
|
|
492
|
-
reValidateMode: ee.onChange,
|
|
493
|
-
shouldFocusError: !0
|
|
494
|
-
};
|
|
495
|
-
function Xt(e = {}) {
|
|
496
|
-
let s = {
|
|
497
|
-
...Qt,
|
|
498
|
-
...e
|
|
499
|
-
}, t = {
|
|
500
|
-
submitCount: 0,
|
|
501
|
-
isDirty: !1,
|
|
502
|
-
isLoading: te(s.defaultValues),
|
|
503
|
-
isValidating: !1,
|
|
504
|
-
isSubmitted: !1,
|
|
505
|
-
isSubmitting: !1,
|
|
506
|
-
isSubmitSuccessful: !1,
|
|
507
|
-
isValid: !1,
|
|
508
|
-
touchedFields: {},
|
|
509
|
-
dirtyFields: {},
|
|
510
|
-
validatingFields: {},
|
|
511
|
-
errors: s.errors || {},
|
|
512
|
-
disabled: s.disabled || !1
|
|
513
|
-
};
|
|
514
|
-
const i = {};
|
|
515
|
-
let n = U(s.defaultValues) || U(s.values) ? T(s.values || s.defaultValues) || {} : {}, u = s.shouldUnregister ? {} : T(n), f = {
|
|
516
|
-
action: !1,
|
|
517
|
-
mount: !1,
|
|
518
|
-
watch: !1
|
|
519
|
-
}, y = {
|
|
520
|
-
mount: /* @__PURE__ */ new Set(),
|
|
521
|
-
disabled: /* @__PURE__ */ new Set(),
|
|
522
|
-
unMount: /* @__PURE__ */ new Set(),
|
|
523
|
-
array: /* @__PURE__ */ new Set(),
|
|
524
|
-
watch: /* @__PURE__ */ new Set()
|
|
525
|
-
}, F, x = 0;
|
|
526
|
-
const w = {
|
|
527
|
-
isDirty: !1,
|
|
528
|
-
dirtyFields: !1,
|
|
529
|
-
validatingFields: !1,
|
|
530
|
-
touchedFields: !1,
|
|
531
|
-
isValidating: !1,
|
|
532
|
-
isValid: !1,
|
|
533
|
-
errors: !1
|
|
534
|
-
};
|
|
535
|
-
let E = {
|
|
536
|
-
...w
|
|
537
|
-
};
|
|
538
|
-
const A = {
|
|
539
|
-
array: st(),
|
|
540
|
-
state: st()
|
|
541
|
-
}, R = ce(s.mode), G = ce(s.reValidateMode), I = s.criteriaMode === ee.all, P = (r) => (a) => {
|
|
542
|
-
clearTimeout(x), x = setTimeout(r, a);
|
|
543
|
-
}, W = async (r) => {
|
|
544
|
-
if (!s.disabled && (w.isValid || E.isValid || r)) {
|
|
545
|
-
const a = s.resolver ? H((await D()).errors) : await X(i, !0);
|
|
546
|
-
a !== t.isValid && A.state.next({
|
|
547
|
-
isValid: a
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
}, m = (r, a) => {
|
|
551
|
-
!s.disabled && (w.isValidating || w.validatingFields || E.isValidating || E.validatingFields) && ((r || Array.from(y.mount)).forEach((l) => {
|
|
552
|
-
l && (a ? C(t.validatingFields, l, a) : B(t.validatingFields, l));
|
|
553
|
-
}), A.state.next({
|
|
554
|
-
validatingFields: t.validatingFields,
|
|
555
|
-
isValidating: !H(t.validatingFields)
|
|
556
|
-
}));
|
|
557
|
-
}, Y = (r, a = [], l, _, d = !0, o = !0) => {
|
|
558
|
-
if (_ && l && !s.disabled) {
|
|
559
|
-
if (f.action = !0, o && Array.isArray(c(i, r))) {
|
|
560
|
-
const g = l(c(i, r), _.argA, _.argB);
|
|
561
|
-
d && C(i, r, g);
|
|
562
|
-
}
|
|
563
|
-
if (o && Array.isArray(c(t.errors, r))) {
|
|
564
|
-
const g = l(c(t.errors, r), _.argA, _.argB);
|
|
565
|
-
d && C(t.errors, r, g), Jt(t.errors, r);
|
|
566
|
-
}
|
|
567
|
-
if ((w.touchedFields || E.touchedFields) && o && Array.isArray(c(t.touchedFields, r))) {
|
|
568
|
-
const g = l(c(t.touchedFields, r), _.argA, _.argB);
|
|
569
|
-
d && C(t.touchedFields, r, g);
|
|
570
|
-
}
|
|
571
|
-
(w.dirtyFields || E.dirtyFields) && (t.dirtyFields = ye(n, u)), A.state.next({
|
|
572
|
-
name: r,
|
|
573
|
-
isDirty: S(r, a),
|
|
574
|
-
dirtyFields: t.dirtyFields,
|
|
575
|
-
errors: t.errors,
|
|
576
|
-
isValid: t.isValid
|
|
577
|
-
});
|
|
578
|
-
} else
|
|
579
|
-
C(u, r, a);
|
|
580
|
-
}, $ = (r, a) => {
|
|
581
|
-
C(t.errors, r, a), A.state.next({
|
|
582
|
-
errors: t.errors
|
|
583
|
-
});
|
|
584
|
-
}, M = (r) => {
|
|
585
|
-
t.errors = r, A.state.next({
|
|
586
|
-
errors: t.errors,
|
|
587
|
-
isValid: !1
|
|
588
|
-
});
|
|
589
|
-
}, b = (r, a, l, _) => {
|
|
590
|
-
const d = c(i, r);
|
|
591
|
-
if (d) {
|
|
592
|
-
const o = c(u, r, O(l) ? c(n, r) : l);
|
|
593
|
-
O(o) || _ && _.defaultChecked || a ? C(u, r, a ? o : lt(d._f)) : Z(r, o), f.mount && W();
|
|
594
|
-
}
|
|
595
|
-
}, h = (r, a, l, _, d) => {
|
|
596
|
-
let o = !1, g = !1;
|
|
597
|
-
const k = {
|
|
598
|
-
name: r
|
|
599
|
-
};
|
|
600
|
-
if (!s.disabled) {
|
|
601
|
-
if (!l || _) {
|
|
602
|
-
(w.isDirty || E.isDirty) && (g = t.isDirty, t.isDirty = k.isDirty = S(), o = g !== k.isDirty);
|
|
603
|
-
const N = le(c(n, r), a);
|
|
604
|
-
g = !!c(t.dirtyFields, r), N ? B(t.dirtyFields, r) : C(t.dirtyFields, r, !0), k.dirtyFields = t.dirtyFields, o = o || (w.dirtyFields || E.dirtyFields) && g !== !N;
|
|
605
|
-
}
|
|
606
|
-
if (l) {
|
|
607
|
-
const N = c(t.touchedFields, r);
|
|
608
|
-
N || (C(t.touchedFields, r, l), k.touchedFields = t.touchedFields, o = o || (w.touchedFields || E.touchedFields) && N !== l);
|
|
609
|
-
}
|
|
610
|
-
o && d && A.state.next(k);
|
|
611
|
-
}
|
|
612
|
-
return o ? k : {};
|
|
613
|
-
}, V = (r, a, l, _) => {
|
|
614
|
-
const d = c(t.errors, r), o = (w.isValid || E.isValid) && Q(a) && t.isValid !== a;
|
|
615
|
-
if (s.delayError && l ? (F = P(() => $(r, l)), F(s.delayError)) : (clearTimeout(x), F = null, l ? C(t.errors, r, l) : B(t.errors, r)), (l ? !le(d, l) : d) || !H(_) || o) {
|
|
616
|
-
const g = {
|
|
617
|
-
..._,
|
|
618
|
-
...o && Q(a) ? { isValid: a } : {},
|
|
619
|
-
errors: t.errors,
|
|
620
|
-
name: r
|
|
621
|
-
};
|
|
622
|
-
t = {
|
|
623
|
-
...t,
|
|
624
|
-
...g
|
|
625
|
-
}, A.state.next(g);
|
|
626
|
-
}
|
|
627
|
-
}, D = async (r) => {
|
|
628
|
-
m(r, !0);
|
|
629
|
-
const a = await s.resolver(u, s.context, $t(r || y.mount, i, s.criteriaMode, s.shouldUseNativeValidation));
|
|
630
|
-
return m(r), a;
|
|
631
|
-
}, J = async (r) => {
|
|
632
|
-
const { errors: a } = await D(r);
|
|
633
|
-
if (r)
|
|
634
|
-
for (const l of r) {
|
|
635
|
-
const _ = c(a, l);
|
|
636
|
-
_ ? C(t.errors, l, _) : B(t.errors, l);
|
|
637
|
-
}
|
|
638
|
-
else
|
|
639
|
-
t.errors = a;
|
|
640
|
-
return a;
|
|
641
|
-
}, X = async (r, a, l = {
|
|
642
|
-
valid: !0
|
|
643
|
-
}) => {
|
|
644
|
-
for (const _ in r) {
|
|
645
|
-
const d = r[_];
|
|
646
|
-
if (d) {
|
|
647
|
-
const { _f: o, ...g } = d;
|
|
648
|
-
if (o) {
|
|
649
|
-
const k = y.array.has(o.name), N = d._f && jt(d._f);
|
|
650
|
-
N && w.validatingFields && m([_], !0);
|
|
651
|
-
const q = await Pe(d, y.disabled, u, I, s.shouldUseNativeValidation && !a, k);
|
|
652
|
-
if (N && w.validatingFields && m([_]), q[o.name] && (l.valid = !1, a))
|
|
653
|
-
break;
|
|
654
|
-
!a && (c(q, o.name) ? k ? wt(t.errors, q, o.name) : C(t.errors, o.name, q[o.name]) : B(t.errors, o.name));
|
|
655
|
-
}
|
|
656
|
-
!H(g) && await X(g, a, l);
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
return l.valid;
|
|
660
|
-
}, p = () => {
|
|
661
|
-
for (const r of y.unMount) {
|
|
662
|
-
const a = c(i, r);
|
|
663
|
-
a && (a._f.refs ? a._f.refs.every((l) => !Ee(l)) : !Ee(a._f.ref)) && we(r);
|
|
664
|
-
}
|
|
665
|
-
y.unMount = /* @__PURE__ */ new Set();
|
|
666
|
-
}, S = (r, a) => !s.disabled && (r && a && C(u, r, a), !le(je(), n)), L = (r, a, l) => bt(r, y, {
|
|
667
|
-
...f.mount ? u : O(a) ? n : se(r) ? { [r]: a } : a
|
|
668
|
-
}, l, a), K = (r) => he(c(f.mount ? u : n, r, s.shouldUnregister ? c(n, r, []) : [])), Z = (r, a, l = {}) => {
|
|
669
|
-
const _ = c(i, r);
|
|
670
|
-
let d = a;
|
|
671
|
-
if (_) {
|
|
672
|
-
const o = _._f;
|
|
673
|
-
o && (!o.disabled && C(u, r, xt(a, o)), d = Fe(o.ref) && j(a) ? "" : a, mt(o.ref) ? [...o.ref.options].forEach((g) => g.selected = d.includes(g.value)) : o.refs ? ge(o.ref) ? o.refs.length > 1 ? o.refs.forEach((g) => (!g.defaultChecked || !g.disabled) && (g.checked = Array.isArray(d) ? !!d.find((k) => k === g.value) : d === g.value)) : o.refs[0] && (o.refs[0].checked = !!d) : o.refs.forEach((g) => g.checked = g.value === d) : He(o.ref) ? o.ref.value = "" : (o.ref.value = d, o.ref.type || A.state.next({
|
|
674
|
-
name: r,
|
|
675
|
-
values: T(u)
|
|
676
|
-
})));
|
|
677
|
-
}
|
|
678
|
-
(l.shouldDirty || l.shouldTouch) && h(r, d, l.shouldTouch, l.shouldDirty, !0), l.shouldValidate && Se(r);
|
|
679
|
-
}, re = (r, a, l) => {
|
|
680
|
-
for (const _ in a) {
|
|
681
|
-
const d = a[_], o = `${r}.${_}`, g = c(i, o);
|
|
682
|
-
(y.array.has(r) || U(d) || g && !g._f) && !ue(d) ? re(o, d, l) : Z(o, d, l);
|
|
683
|
-
}
|
|
684
|
-
}, ae = (r, a, l = {}) => {
|
|
685
|
-
const _ = c(i, r), d = y.array.has(r), o = T(a);
|
|
686
|
-
C(u, r, o), d ? (A.array.next({
|
|
687
|
-
name: r,
|
|
688
|
-
values: T(u)
|
|
689
|
-
}), (w.isDirty || w.dirtyFields || E.isDirty || E.dirtyFields) && l.shouldDirty && A.state.next({
|
|
690
|
-
name: r,
|
|
691
|
-
dirtyFields: ye(n, u),
|
|
692
|
-
isDirty: S(r, o)
|
|
693
|
-
})) : _ && !_._f && !j(o) ? re(r, o, l) : Z(r, o, l), Ie(r, y) && A.state.next({ ...t }), A.state.next({
|
|
694
|
-
name: f.mount ? r : void 0,
|
|
695
|
-
values: T(u)
|
|
696
|
-
});
|
|
697
|
-
}, fe = async (r) => {
|
|
698
|
-
f.mount = !0;
|
|
699
|
-
const a = r.target;
|
|
700
|
-
let l = a.name, _ = !0;
|
|
701
|
-
const d = c(i, l), o = (g) => {
|
|
702
|
-
_ = Number.isNaN(g) || ue(g) && isNaN(g.getTime()) || le(g, c(u, l, g));
|
|
703
|
-
};
|
|
704
|
-
if (d) {
|
|
705
|
-
let g, k;
|
|
706
|
-
const N = a.type ? lt(d._f) : yt(r), q = r.type === me.BLUR || r.type === me.FOCUS_OUT, Tt = !Kt(d._f) && !s.resolver && !c(t.errors, l) && !d._f.deps || Yt(q, c(t.touchedFields, l), t.isSubmitted, G, R), De = Ie(l, y, q);
|
|
707
|
-
C(u, l, N), q ? (d._f.onBlur && d._f.onBlur(r), F && F(0)) : d._f.onChange && d._f.onChange(r);
|
|
708
|
-
const pe = h(l, N, q), Lt = !H(pe) || De;
|
|
709
|
-
if (!q && A.state.next({
|
|
710
|
-
name: l,
|
|
711
|
-
type: r.type,
|
|
712
|
-
values: T(u)
|
|
713
|
-
}), Tt)
|
|
714
|
-
return (w.isValid || E.isValid) && (s.mode === "onBlur" ? q && W() : q || W()), Lt && A.state.next({ name: l, ...De ? {} : pe });
|
|
715
|
-
if (!q && De && A.state.next({ ...t }), s.resolver) {
|
|
716
|
-
const { errors: tt } = await D([l]);
|
|
717
|
-
if (o(N), _) {
|
|
718
|
-
const Ut = ot(t.errors, i, l), rt = ot(tt, i, Ut.name || l);
|
|
719
|
-
g = rt.error, l = rt.name, k = H(tt);
|
|
720
|
-
}
|
|
721
|
-
} else
|
|
722
|
-
m([l], !0), g = (await Pe(d, y.disabled, u, I, s.shouldUseNativeValidation))[l], m([l]), o(N), _ && (g ? k = !1 : (w.isValid || E.isValid) && (k = await X(i, !0)));
|
|
723
|
-
_ && (d._f.deps && Se(d._f.deps), V(l, k, g, pe));
|
|
724
|
-
}
|
|
725
|
-
}, ve = (r, a) => {
|
|
726
|
-
if (c(t.errors, a) && r.focus)
|
|
727
|
-
return r.focus(), 1;
|
|
728
|
-
}, Se = async (r, a = {}) => {
|
|
729
|
-
let l, _;
|
|
730
|
-
const d = z(r);
|
|
731
|
-
if (s.resolver) {
|
|
732
|
-
const o = await J(O(r) ? r : d);
|
|
733
|
-
l = H(o), _ = r ? !d.some((g) => c(o, g)) : l;
|
|
734
|
-
} else r ? (_ = (await Promise.all(d.map(async (o) => {
|
|
735
|
-
const g = c(i, o);
|
|
736
|
-
return await X(g && g._f ? { [o]: g } : g);
|
|
737
|
-
}))).every(Boolean), !(!_ && !t.isValid) && W()) : _ = l = await X(i);
|
|
738
|
-
return A.state.next({
|
|
739
|
-
...!se(r) || (w.isValid || E.isValid) && l !== t.isValid ? {} : { name: r },
|
|
740
|
-
...s.resolver || !r ? { isValid: l } : {},
|
|
741
|
-
errors: t.errors
|
|
742
|
-
}), a.shouldFocus && !_ && de(i, ve, r ? d : y.mount), _;
|
|
743
|
-
}, je = (r) => {
|
|
744
|
-
const a = {
|
|
745
|
-
...f.mount ? u : n
|
|
746
|
-
};
|
|
747
|
-
return O(r) ? a : se(r) ? c(a, r) : r.map((l) => c(a, l));
|
|
748
|
-
}, Ke = (r, a) => ({
|
|
749
|
-
invalid: !!c((a || t).errors, r),
|
|
750
|
-
isDirty: !!c((a || t).dirtyFields, r),
|
|
751
|
-
error: c((a || t).errors, r),
|
|
752
|
-
isValidating: !!c(t.validatingFields, r),
|
|
753
|
-
isTouched: !!c((a || t).touchedFields, r)
|
|
754
|
-
}), kt = (r) => {
|
|
755
|
-
r && z(r).forEach((a) => B(t.errors, a)), A.state.next({
|
|
756
|
-
errors: r ? t.errors : {}
|
|
757
|
-
});
|
|
758
|
-
}, ze = (r, a, l) => {
|
|
759
|
-
const _ = (c(i, r, { _f: {} })._f || {}).ref, d = c(t.errors, r) || {}, { ref: o, message: g, type: k, ...N } = d;
|
|
760
|
-
C(t.errors, r, {
|
|
761
|
-
...N,
|
|
762
|
-
...a,
|
|
763
|
-
ref: _
|
|
764
|
-
}), A.state.next({
|
|
765
|
-
name: r,
|
|
766
|
-
errors: t.errors,
|
|
767
|
-
isValid: !1
|
|
768
|
-
}), l && l.shouldFocus && _ && _.focus && _.focus();
|
|
769
|
-
}, Dt = (r, a) => te(r) ? A.state.subscribe({
|
|
770
|
-
next: (l) => r(L(void 0, a), l)
|
|
771
|
-
}) : L(r, a, !0), Ge = (r) => A.state.subscribe({
|
|
772
|
-
next: (a) => {
|
|
773
|
-
Gt(r.name, a.name, r.exact) && zt(a, r.formState || w, Rt, r.reRenderRoot) && r.callback({
|
|
774
|
-
values: { ...u },
|
|
775
|
-
...t,
|
|
776
|
-
...a
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
}).unsubscribe, pt = (r) => (f.mount = !0, E = {
|
|
780
|
-
...E,
|
|
781
|
-
...r.formState
|
|
782
|
-
}, Ge({
|
|
783
|
-
...r,
|
|
784
|
-
formState: E
|
|
785
|
-
})), we = (r, a = {}) => {
|
|
786
|
-
for (const l of r ? z(r) : y.mount)
|
|
787
|
-
y.mount.delete(l), y.array.delete(l), a.keepValue || (B(i, l), B(u, l)), !a.keepError && B(t.errors, l), !a.keepDirty && B(t.dirtyFields, l), !a.keepTouched && B(t.touchedFields, l), !a.keepIsValidating && B(t.validatingFields, l), !s.shouldUnregister && !a.keepDefaultValue && B(n, l);
|
|
788
|
-
A.state.next({
|
|
789
|
-
values: T(u)
|
|
790
|
-
}), A.state.next({
|
|
791
|
-
...t,
|
|
792
|
-
...a.keepDirty ? { isDirty: S() } : {}
|
|
793
|
-
}), !a.keepIsValid && W();
|
|
794
|
-
}, Ye = ({ disabled: r, name: a }) => {
|
|
795
|
-
(Q(r) && f.mount || r || y.disabled.has(a)) && (r ? y.disabled.add(a) : y.disabled.delete(a));
|
|
796
|
-
}, ke = (r, a = {}) => {
|
|
797
|
-
let l = c(i, r);
|
|
798
|
-
const _ = Q(a.disabled) || Q(s.disabled);
|
|
799
|
-
return C(i, r, {
|
|
800
|
-
...l || {},
|
|
801
|
-
_f: {
|
|
802
|
-
...l && l._f ? l._f : { ref: { name: r } },
|
|
803
|
-
name: r,
|
|
804
|
-
mount: !0,
|
|
805
|
-
...a
|
|
806
|
-
}
|
|
807
|
-
}), y.mount.add(r), l ? Ye({
|
|
808
|
-
disabled: Q(a.disabled) ? a.disabled : s.disabled,
|
|
809
|
-
name: r
|
|
810
|
-
}) : b(r, !0, a.value), {
|
|
811
|
-
..._ ? { disabled: a.disabled || s.disabled } : {},
|
|
812
|
-
...s.progressive ? {
|
|
813
|
-
required: !!a.required,
|
|
814
|
-
min: _e(a.min),
|
|
815
|
-
max: _e(a.max),
|
|
816
|
-
minLength: _e(a.minLength),
|
|
817
|
-
maxLength: _e(a.maxLength),
|
|
818
|
-
pattern: _e(a.pattern)
|
|
819
|
-
} : {},
|
|
820
|
-
name: r,
|
|
821
|
-
onChange: fe,
|
|
822
|
-
onBlur: fe,
|
|
823
|
-
ref: (d) => {
|
|
824
|
-
if (d) {
|
|
825
|
-
ke(r, a), l = c(i, r);
|
|
826
|
-
const o = O(d.value) && d.querySelectorAll && d.querySelectorAll("input,select,textarea")[0] || d, g = Wt(o), k = l._f.refs || [];
|
|
827
|
-
if (g ? k.find((N) => N === o) : o === l._f.ref)
|
|
828
|
-
return;
|
|
829
|
-
C(i, r, {
|
|
830
|
-
_f: {
|
|
831
|
-
...l._f,
|
|
832
|
-
...g ? {
|
|
833
|
-
refs: [
|
|
834
|
-
...k.filter(Ee),
|
|
835
|
-
o,
|
|
836
|
-
...Array.isArray(c(n, r)) ? [{}] : []
|
|
837
|
-
],
|
|
838
|
-
ref: { type: o.type, name: r }
|
|
839
|
-
} : { ref: o }
|
|
840
|
-
}
|
|
841
|
-
}), b(r, !1, void 0, o);
|
|
842
|
-
} else
|
|
843
|
-
l = c(i, r, {}), l._f && (l._f.mount = !1), (s.shouldUnregister || a.shouldUnregister) && !(_t(y.array, r) && f.action) && y.unMount.add(r);
|
|
844
|
-
}
|
|
845
|
-
};
|
|
846
|
-
}, Je = () => s.shouldFocusError && de(i, ve, y.mount), Et = (r) => {
|
|
847
|
-
Q(r) && (A.state.next({ disabled: r }), de(i, (a, l) => {
|
|
848
|
-
const _ = c(i, l);
|
|
849
|
-
_ && (a.disabled = _._f.disabled || r, Array.isArray(_._f.refs) && _._f.refs.forEach((d) => {
|
|
850
|
-
d.disabled = _._f.disabled || r;
|
|
851
|
-
}));
|
|
852
|
-
}, 0, !1));
|
|
853
|
-
}, Qe = (r, a) => async (l) => {
|
|
854
|
-
let _;
|
|
855
|
-
l && (l.preventDefault && l.preventDefault(), l.persist && l.persist());
|
|
856
|
-
let d = T(u);
|
|
857
|
-
if (A.state.next({
|
|
858
|
-
isSubmitting: !0
|
|
859
|
-
}), s.resolver) {
|
|
860
|
-
const { errors: o, values: g } = await D();
|
|
861
|
-
t.errors = o, d = g;
|
|
862
|
-
} else
|
|
863
|
-
await X(i);
|
|
864
|
-
if (y.disabled.size)
|
|
865
|
-
for (const o of y.disabled)
|
|
866
|
-
C(d, o, void 0);
|
|
867
|
-
if (B(t.errors, "root"), H(t.errors)) {
|
|
868
|
-
A.state.next({
|
|
869
|
-
errors: {}
|
|
870
|
-
});
|
|
871
|
-
try {
|
|
872
|
-
await r(d, l);
|
|
873
|
-
} catch (o) {
|
|
874
|
-
_ = o;
|
|
875
|
-
}
|
|
876
|
-
} else
|
|
877
|
-
a && await a({ ...t.errors }, l), Je(), setTimeout(Je);
|
|
878
|
-
if (A.state.next({
|
|
879
|
-
isSubmitted: !0,
|
|
880
|
-
isSubmitting: !1,
|
|
881
|
-
isSubmitSuccessful: H(t.errors) && !_,
|
|
882
|
-
submitCount: t.submitCount + 1,
|
|
883
|
-
errors: t.errors
|
|
884
|
-
}), _)
|
|
885
|
-
throw _;
|
|
886
|
-
}, Ct = (r, a = {}) => {
|
|
887
|
-
c(i, r) && (O(a.defaultValue) ? ae(r, T(c(n, r))) : (ae(r, a.defaultValue), C(n, r, T(a.defaultValue))), a.keepTouched || B(t.touchedFields, r), a.keepDirty || (B(t.dirtyFields, r), t.isDirty = a.defaultValue ? S(r, T(c(n, r))) : S()), a.keepError || (B(t.errors, r), w.isValid && W()), A.state.next({ ...t }));
|
|
888
|
-
}, Xe = (r, a = {}) => {
|
|
889
|
-
const l = r ? T(r) : n, _ = T(l), d = H(r), o = d ? n : _;
|
|
890
|
-
if (a.keepDefaultValues || (n = l), !a.keepValues) {
|
|
891
|
-
if (a.keepDirtyValues) {
|
|
892
|
-
const g = /* @__PURE__ */ new Set([
|
|
893
|
-
...y.mount,
|
|
894
|
-
...Object.keys(ye(n, u))
|
|
895
|
-
]);
|
|
896
|
-
for (const k of Array.from(g))
|
|
897
|
-
c(t.dirtyFields, k) ? C(o, k, c(u, k)) : ae(k, c(o, k));
|
|
898
|
-
} else {
|
|
899
|
-
if (We && O(r))
|
|
900
|
-
for (const g of y.mount) {
|
|
901
|
-
const k = c(i, g);
|
|
902
|
-
if (k && k._f) {
|
|
903
|
-
const N = Array.isArray(k._f.refs) ? k._f.refs[0] : k._f.ref;
|
|
904
|
-
if (Fe(N)) {
|
|
905
|
-
const q = N.closest("form");
|
|
906
|
-
if (q) {
|
|
907
|
-
q.reset();
|
|
908
|
-
break;
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
for (const g of y.mount)
|
|
914
|
-
ae(g, c(o, g));
|
|
915
|
-
}
|
|
916
|
-
u = T(o), A.array.next({
|
|
917
|
-
values: { ...o }
|
|
918
|
-
}), A.state.next({
|
|
919
|
-
values: { ...o }
|
|
920
|
-
});
|
|
921
|
-
}
|
|
922
|
-
y = {
|
|
923
|
-
mount: a.keepDirtyValues ? y.mount : /* @__PURE__ */ new Set(),
|
|
924
|
-
unMount: /* @__PURE__ */ new Set(),
|
|
925
|
-
array: /* @__PURE__ */ new Set(),
|
|
926
|
-
disabled: /* @__PURE__ */ new Set(),
|
|
927
|
-
watch: /* @__PURE__ */ new Set(),
|
|
928
|
-
watchAll: !1,
|
|
929
|
-
focus: ""
|
|
930
|
-
}, f.mount = !w.isValid || !!a.keepIsValid || !!a.keepDirtyValues, f.watch = !!s.shouldUnregister, A.state.next({
|
|
931
|
-
submitCount: a.keepSubmitCount ? t.submitCount : 0,
|
|
932
|
-
isDirty: d ? !1 : a.keepDirty ? t.isDirty : !!(a.keepDefaultValues && !le(r, n)),
|
|
933
|
-
isSubmitted: a.keepIsSubmitted ? t.isSubmitted : !1,
|
|
934
|
-
dirtyFields: d ? {} : a.keepDirtyValues ? a.keepDefaultValues && u ? ye(n, u) : t.dirtyFields : a.keepDefaultValues && r ? ye(n, r) : a.keepDirty ? t.dirtyFields : {},
|
|
935
|
-
touchedFields: a.keepTouched ? t.touchedFields : {},
|
|
936
|
-
errors: a.keepErrors ? t.errors : {},
|
|
937
|
-
isSubmitSuccessful: a.keepIsSubmitSuccessful ? t.isSubmitSuccessful : !1,
|
|
938
|
-
isSubmitting: !1
|
|
939
|
-
});
|
|
940
|
-
}, Ze = (r, a) => Xe(te(r) ? r(u) : r, a), Ot = (r, a = {}) => {
|
|
941
|
-
const l = c(i, r), _ = l && l._f;
|
|
942
|
-
if (_) {
|
|
943
|
-
const d = _.refs ? _.refs[0] : _.ref;
|
|
944
|
-
d.focus && (d.focus(), a.shouldSelect && te(d.select) && d.select());
|
|
945
|
-
}
|
|
946
|
-
}, Rt = (r) => {
|
|
947
|
-
t = {
|
|
948
|
-
...t,
|
|
949
|
-
...r
|
|
950
|
-
};
|
|
951
|
-
}, et = {
|
|
952
|
-
control: {
|
|
953
|
-
register: ke,
|
|
954
|
-
unregister: we,
|
|
955
|
-
getFieldState: Ke,
|
|
956
|
-
handleSubmit: Qe,
|
|
957
|
-
setError: ze,
|
|
958
|
-
_subscribe: Ge,
|
|
959
|
-
_runSchema: D,
|
|
960
|
-
_getWatch: L,
|
|
961
|
-
_getDirty: S,
|
|
962
|
-
_setValid: W,
|
|
963
|
-
_setFieldArray: Y,
|
|
964
|
-
_setDisabledField: Ye,
|
|
965
|
-
_setErrors: M,
|
|
966
|
-
_getFieldArray: K,
|
|
967
|
-
_reset: Xe,
|
|
968
|
-
_resetDefaultValues: () => te(s.defaultValues) && s.defaultValues().then((r) => {
|
|
969
|
-
Ze(r, s.resetOptions), A.state.next({
|
|
970
|
-
isLoading: !1
|
|
971
|
-
});
|
|
972
|
-
}),
|
|
973
|
-
_removeUnmounted: p,
|
|
974
|
-
_disableForm: Et,
|
|
975
|
-
_subjects: A,
|
|
976
|
-
_proxyFormState: w,
|
|
977
|
-
get _fields() {
|
|
978
|
-
return i;
|
|
979
|
-
},
|
|
980
|
-
get _formValues() {
|
|
981
|
-
return u;
|
|
982
|
-
},
|
|
983
|
-
get _state() {
|
|
984
|
-
return f;
|
|
985
|
-
},
|
|
986
|
-
set _state(r) {
|
|
987
|
-
f = r;
|
|
988
|
-
},
|
|
989
|
-
get _defaultValues() {
|
|
990
|
-
return n;
|
|
991
|
-
},
|
|
992
|
-
get _names() {
|
|
993
|
-
return y;
|
|
994
|
-
},
|
|
995
|
-
set _names(r) {
|
|
996
|
-
y = r;
|
|
997
|
-
},
|
|
998
|
-
get _formState() {
|
|
999
|
-
return t;
|
|
1000
|
-
},
|
|
1001
|
-
get _options() {
|
|
1002
|
-
return s;
|
|
1003
|
-
},
|
|
1004
|
-
set _options(r) {
|
|
1005
|
-
s = {
|
|
1006
|
-
...s,
|
|
1007
|
-
...r
|
|
1008
|
-
};
|
|
1009
|
-
}
|
|
1010
|
-
},
|
|
1011
|
-
subscribe: pt,
|
|
1012
|
-
trigger: Se,
|
|
1013
|
-
register: ke,
|
|
1014
|
-
handleSubmit: Qe,
|
|
1015
|
-
watch: Dt,
|
|
1016
|
-
setValue: ae,
|
|
1017
|
-
getValues: je,
|
|
1018
|
-
reset: Ze,
|
|
1019
|
-
resetField: Ct,
|
|
1020
|
-
clearErrors: kt,
|
|
1021
|
-
unregister: we,
|
|
1022
|
-
setError: ze,
|
|
1023
|
-
setFocus: Ot,
|
|
1024
|
-
getFieldState: Ke
|
|
1025
|
-
};
|
|
1026
|
-
return {
|
|
1027
|
-
...et,
|
|
1028
|
-
formControl: et
|
|
1029
|
-
};
|
|
1030
|
-
}
|
|
1031
|
-
var ne = () => {
|
|
1032
|
-
const e = typeof performance > "u" ? Date.now() : performance.now() * 1e3;
|
|
1033
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (s) => {
|
|
1034
|
-
const t = (Math.random() * 16 + e) % 16 | 0;
|
|
1035
|
-
return (s == "x" ? t : t & 3 | 8).toString(16);
|
|
1036
|
-
});
|
|
1037
|
-
}, Ce = (e, s, t = {}) => t.shouldFocus || O(t.shouldFocus) ? t.focusName || `${e}.${O(t.focusIndex) ? s : t.focusIndex}.` : "", Oe = (e, s) => [
|
|
1038
|
-
...e,
|
|
1039
|
-
...z(s)
|
|
1040
|
-
], Re = (e) => Array.isArray(e) ? e.map(() => {
|
|
1041
|
-
}) : void 0;
|
|
1042
|
-
function Te(e, s, t) {
|
|
1043
|
-
return [
|
|
1044
|
-
...e.slice(0, s),
|
|
1045
|
-
...z(t),
|
|
1046
|
-
...e.slice(s)
|
|
1047
|
-
];
|
|
1048
|
-
}
|
|
1049
|
-
var Le = (e, s, t) => Array.isArray(e) ? (O(e[t]) && (e[t] = void 0), e.splice(t, 0, e.splice(s, 1)[0]), e) : [], Ue = (e, s) => [
|
|
1050
|
-
...z(s),
|
|
1051
|
-
...z(e)
|
|
1052
|
-
];
|
|
1053
|
-
function Zt(e, s) {
|
|
1054
|
-
let t = 0;
|
|
1055
|
-
const i = [...e];
|
|
1056
|
-
for (const n of s)
|
|
1057
|
-
i.splice(n - t, 1), t++;
|
|
1058
|
-
return he(i).length ? i : [];
|
|
1059
|
-
}
|
|
1060
|
-
var Me = (e, s) => O(s) ? [] : Zt(e, z(s).sort((t, i) => t - i)), Ne = (e, s, t) => {
|
|
1061
|
-
[e[s], e[t]] = [e[t], e[s]];
|
|
1062
|
-
}, dt = (e, s, t) => (e[s] = t, e);
|
|
1063
|
-
function ir(e) {
|
|
1064
|
-
const s = xe(), { control: t = s.control, name: i, keyName: n = "id", shouldUnregister: u, rules: f } = e, [y, F] = v.useState(t._getFieldArray(i)), x = v.useRef(t._getFieldArray(i).map(ne)), w = v.useRef(y), E = v.useRef(i), A = v.useRef(!1);
|
|
1065
|
-
E.current = i, w.current = y, t._names.array.add(i), f && t.register(i, f), v.useEffect(() => t._subjects.array.subscribe({
|
|
1066
|
-
next: ({ values: b, name: h }) => {
|
|
1067
|
-
if (h === E.current || !h) {
|
|
1068
|
-
const V = c(b, E.current);
|
|
1069
|
-
Array.isArray(V) && (F(V), x.current = V.map(ne));
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
}).unsubscribe, [t]);
|
|
1073
|
-
const R = v.useCallback((b) => {
|
|
1074
|
-
A.current = !0, t._setFieldArray(i, b);
|
|
1075
|
-
}, [t, i]), G = (b, h) => {
|
|
1076
|
-
const V = z(T(b)), D = Oe(t._getFieldArray(i), V);
|
|
1077
|
-
t._names.focus = Ce(i, D.length - 1, h), x.current = Oe(x.current, V.map(ne)), R(D), F(D), t._setFieldArray(i, D, Oe, {
|
|
1078
|
-
argA: Re(b)
|
|
1079
|
-
});
|
|
1080
|
-
}, I = (b, h) => {
|
|
1081
|
-
const V = z(T(b)), D = Ue(t._getFieldArray(i), V);
|
|
1082
|
-
t._names.focus = Ce(i, 0, h), x.current = Ue(x.current, V.map(ne)), R(D), F(D), t._setFieldArray(i, D, Ue, {
|
|
1083
|
-
argA: Re(b)
|
|
1084
|
-
});
|
|
1085
|
-
}, P = (b) => {
|
|
1086
|
-
const h = Me(t._getFieldArray(i), b);
|
|
1087
|
-
x.current = Me(x.current, b), R(h), F(h), !Array.isArray(c(t._fields, i)) && C(t._fields, i, void 0), t._setFieldArray(i, h, Me, {
|
|
1088
|
-
argA: b
|
|
1089
|
-
});
|
|
1090
|
-
}, W = (b, h, V) => {
|
|
1091
|
-
const D = z(T(h)), J = Te(t._getFieldArray(i), b, D);
|
|
1092
|
-
t._names.focus = Ce(i, b, V), x.current = Te(x.current, b, D.map(ne)), R(J), F(J), t._setFieldArray(i, J, Te, {
|
|
1093
|
-
argA: b,
|
|
1094
|
-
argB: Re(h)
|
|
1095
|
-
});
|
|
1096
|
-
}, m = (b, h) => {
|
|
1097
|
-
const V = t._getFieldArray(i);
|
|
1098
|
-
Ne(V, b, h), Ne(x.current, b, h), R(V), F(V), t._setFieldArray(i, V, Ne, {
|
|
1099
|
-
argA: b,
|
|
1100
|
-
argB: h
|
|
1101
|
-
}, !1);
|
|
1102
|
-
}, Y = (b, h) => {
|
|
1103
|
-
const V = t._getFieldArray(i);
|
|
1104
|
-
Le(V, b, h), Le(x.current, b, h), R(V), F(V), t._setFieldArray(i, V, Le, {
|
|
1105
|
-
argA: b,
|
|
1106
|
-
argB: h
|
|
1107
|
-
}, !1);
|
|
1108
|
-
}, $ = (b, h) => {
|
|
1109
|
-
const V = T(h), D = dt(t._getFieldArray(i), b, V);
|
|
1110
|
-
x.current = [...D].map((J, X) => !J || X === b ? ne() : x.current[X]), R(D), F([...D]), t._setFieldArray(i, D, dt, {
|
|
1111
|
-
argA: b,
|
|
1112
|
-
argB: V
|
|
1113
|
-
}, !0, !1);
|
|
1114
|
-
}, M = (b) => {
|
|
1115
|
-
const h = z(T(b));
|
|
1116
|
-
x.current = h.map(ne), R([...h]), F([...h]), t._setFieldArray(i, [...h], (V) => V, {}, !0, !1);
|
|
1117
|
-
};
|
|
1118
|
-
return v.useEffect(() => {
|
|
1119
|
-
if (t._state.action = !1, Ie(i, t._names) && t._subjects.state.next({
|
|
1120
|
-
...t._formState
|
|
1121
|
-
}), A.current && (!ce(t._options.mode).isOnSubmit || t._formState.isSubmitted) && !ce(t._options.reValidateMode).isOnSubmit)
|
|
1122
|
-
if (t._options.resolver)
|
|
1123
|
-
t._runSchema([i]).then((b) => {
|
|
1124
|
-
const h = c(b.errors, i), V = c(t._formState.errors, i);
|
|
1125
|
-
(V ? !h && V.type || h && (V.type !== h.type || V.message !== h.message) : h && h.type) && (h ? C(t._formState.errors, i, h) : B(t._formState.errors, i), t._subjects.state.next({
|
|
1126
|
-
errors: t._formState.errors
|
|
1127
|
-
}));
|
|
1128
|
-
});
|
|
1129
|
-
else {
|
|
1130
|
-
const b = c(t._fields, i);
|
|
1131
|
-
b && b._f && !(ce(t._options.reValidateMode).isOnSubmit && ce(t._options.mode).isOnSubmit) && Pe(b, t._names.disabled, t._formValues, t._options.criteriaMode === ee.all, t._options.shouldUseNativeValidation, !0).then((h) => !H(h) && t._subjects.state.next({
|
|
1132
|
-
errors: wt(t._formState.errors, h, i)
|
|
1133
|
-
}));
|
|
1134
|
-
}
|
|
1135
|
-
t._subjects.state.next({
|
|
1136
|
-
name: i,
|
|
1137
|
-
values: T(t._formValues)
|
|
1138
|
-
}), t._names.focus && de(t._fields, (b, h) => {
|
|
1139
|
-
if (t._names.focus && h.startsWith(t._names.focus) && b.focus)
|
|
1140
|
-
return b.focus(), 1;
|
|
1141
|
-
}), t._names.focus = "", t._setValid(), A.current = !1;
|
|
1142
|
-
}, [y, i, t]), v.useEffect(() => (!c(t._formValues, i) && t._setFieldArray(i), () => {
|
|
1143
|
-
const b = (h, V) => {
|
|
1144
|
-
const D = c(t._fields, h);
|
|
1145
|
-
D && D._f && (D._f.mount = V);
|
|
1146
|
-
};
|
|
1147
|
-
t._options.shouldUnregister || u ? t.unregister(i) : b(i, !1);
|
|
1148
|
-
}), [i, t, n, u]), {
|
|
1149
|
-
swap: v.useCallback(m, [R, i, t]),
|
|
1150
|
-
move: v.useCallback(Y, [R, i, t]),
|
|
1151
|
-
prepend: v.useCallback(I, [R, i, t]),
|
|
1152
|
-
append: v.useCallback(G, [R, i, t]),
|
|
1153
|
-
remove: v.useCallback(P, [R, i, t]),
|
|
1154
|
-
insert: v.useCallback(W, [R, i, t]),
|
|
1155
|
-
update: v.useCallback($, [R, i, t]),
|
|
1156
|
-
replace: v.useCallback(M, [R, i, t]),
|
|
1157
|
-
fields: v.useMemo(() => y.map((b, h) => ({
|
|
1158
|
-
...b,
|
|
1159
|
-
[n]: x.current[h] || ne()
|
|
1160
|
-
})), [y, n])
|
|
1161
|
-
};
|
|
1162
|
-
}
|
|
1163
|
-
function ar(e = {}) {
|
|
1164
|
-
const s = v.useRef(void 0), t = v.useRef(void 0), [i, n] = v.useState({
|
|
1165
|
-
isDirty: !1,
|
|
1166
|
-
isValidating: !1,
|
|
1167
|
-
isLoading: te(e.defaultValues),
|
|
1168
|
-
isSubmitted: !1,
|
|
1169
|
-
isSubmitting: !1,
|
|
1170
|
-
isSubmitSuccessful: !1,
|
|
1171
|
-
isValid: !1,
|
|
1172
|
-
submitCount: 0,
|
|
1173
|
-
dirtyFields: {},
|
|
1174
|
-
touchedFields: {},
|
|
1175
|
-
validatingFields: {},
|
|
1176
|
-
errors: e.errors || {},
|
|
1177
|
-
disabled: e.disabled || !1,
|
|
1178
|
-
defaultValues: te(e.defaultValues) ? void 0 : e.defaultValues
|
|
1179
|
-
});
|
|
1180
|
-
s.current || (s.current = {
|
|
1181
|
-
...e.formControl ? e.formControl : Xt(e),
|
|
1182
|
-
formState: i
|
|
1183
|
-
}, e.formControl && e.defaultValues && !te(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions));
|
|
1184
|
-
const u = s.current.control;
|
|
1185
|
-
return u._options = e, v.useLayoutEffect(() => u._subscribe({
|
|
1186
|
-
formState: u._proxyFormState,
|
|
1187
|
-
callback: () => n({ ...u._formState }),
|
|
1188
|
-
reRenderRoot: !0
|
|
1189
|
-
}), [u]), v.useEffect(() => u._disableForm(e.disabled), [u, e.disabled]), v.useEffect(() => {
|
|
1190
|
-
if (u._proxyFormState.isDirty) {
|
|
1191
|
-
const f = u._getDirty();
|
|
1192
|
-
f !== i.isDirty && u._subjects.state.next({
|
|
1193
|
-
isDirty: f
|
|
1194
|
-
});
|
|
1195
|
-
}
|
|
1196
|
-
}, [u, i.isDirty]), v.useEffect(() => {
|
|
1197
|
-
e.values && !le(e.values, t.current) ? (u._reset(e.values, u._options.resetOptions), t.current = e.values, n((f) => ({ ...f }))) : u._resetDefaultValues();
|
|
1198
|
-
}, [e.values, u]), v.useEffect(() => {
|
|
1199
|
-
e.errors && !H(e.errors) && u._setErrors(e.errors);
|
|
1200
|
-
}, [e.errors, u]), v.useEffect(() => {
|
|
1201
|
-
u._state.mount || (u._setValid(), u._state.mount = !0), u._state.watch && (u._state.watch = !1, u._subjects.state.next({ ...u._formState })), u._removeUnmounted();
|
|
1202
|
-
}), v.useEffect(() => {
|
|
1203
|
-
e.shouldUnregister && u._subjects.state.next({
|
|
1204
|
-
values: u._getWatch()
|
|
1205
|
-
});
|
|
1206
|
-
}, [e.shouldUnregister, u]), s.current.formState = vt(i, u), s.current;
|
|
1207
|
-
}
|
|
1208
|
-
export {
|
|
1209
|
-
rr as F,
|
|
1210
|
-
ar as a,
|
|
1211
|
-
xe as b,
|
|
1212
|
-
It as c,
|
|
1213
|
-
sr as d,
|
|
1214
|
-
ir as u
|
|
1215
|
-
};
|