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