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