@scbt-ecom/ui 0.86.1 → 0.87.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-Bz84dAoh.js → index-B6tiFtIj.js} +4 -4
- package/dist/{index-Bz84dAoh.js.map → index-B6tiFtIj.js.map} +1 -1
- package/dist/{index-BO81H324.js → index-Bu5RfW_Z.js} +3 -3
- package/dist/{index-BO81H324.js.map → index-Bu5RfW_Z.js.map} +1 -1
- package/dist/lib/shared/ui/formElements/controlled/editor/ui/Editor.d.ts +3 -0
- package/dist/lib/shared/utils/typeGuards.d.ts +1 -0
- package/dist/lib/widgets/footer/model/types.d.ts +2 -0
- package/dist/lib/widgets/seoHeader/model/types.d.ts +1 -0
- package/dist/{renderImage-D1GvKq_K.js → renderImage-ViVSYcgG.js} +2 -2
- package/dist/{renderImage-D1GvKq_K.js.map → renderImage-ViVSYcgG.js.map} +1 -1
- package/dist/{typeGuards-CSiImkUY.js → typeGuards-BHbj394R.js} +4 -1
- package/dist/{typeGuards-CSiImkUY.js.map → typeGuards-BHbj394R.js.map} +1 -1
- package/dist/ui.js +5 -5
- package/dist/{useDebounce-CEu2ysPk.js → useDebounce-5MeprqTX.js} +250 -239
- package/dist/useDebounce-5MeprqTX.js.map +1 -0
- package/dist/{useFieldsProgress-DvWCpALA.js → useFieldsProgress-CUlFPv4E.js} +2 -2
- package/dist/{useFieldsProgress-DvWCpALA.js.map → useFieldsProgress-CUlFPv4E.js.map} +1 -1
- package/dist/{utils-CnDzHNQ6.js → utils-BAhmwXLC.js} +2 -2
- package/dist/{utils-CnDzHNQ6.js.map → utils-BAhmwXLC.js.map} +1 -1
- package/dist/utils.js +3 -3
- package/dist/validation.js +2 -2
- package/dist/widget.js +15 -12
- package/dist/widget.js.map +1 -1
- package/package.json +1 -1
- package/dist/useDebounce-CEu2ysPk.js.map +0 -1
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import * as ne from "react";
|
|
2
|
-
import A, { useCallback as
|
|
2
|
+
import A, { useCallback as Ye, useSyncExternalStore as $e } from "react";
|
|
3
3
|
import { i as Ot } from "./isClient-C9aZtt2Q.js";
|
|
4
|
-
const
|
|
5
|
-
const e = "(max-width: 1187px)", r = "(min-width: 1188px)", t =
|
|
4
|
+
const Je = () => !1, or = () => {
|
|
5
|
+
const e = "(max-width: 1187px)", r = "(min-width: 1188px)", t = Ye(
|
|
6
6
|
(u) => {
|
|
7
|
-
const
|
|
8
|
-
return
|
|
9
|
-
|
|
7
|
+
const c = globalThis.matchMedia(e);
|
|
8
|
+
return c.addEventListener("change", u), () => {
|
|
9
|
+
c.removeEventListener("change", u);
|
|
10
10
|
};
|
|
11
11
|
},
|
|
12
12
|
[e]
|
|
13
|
-
), i =
|
|
13
|
+
), i = Ye(
|
|
14
14
|
(u) => {
|
|
15
|
-
const
|
|
16
|
-
return
|
|
17
|
-
|
|
15
|
+
const c = globalThis.matchMedia(r);
|
|
16
|
+
return c.addEventListener("change", u), () => {
|
|
17
|
+
c.removeEventListener("change", u);
|
|
18
18
|
};
|
|
19
19
|
},
|
|
20
20
|
[r]
|
|
21
21
|
), a = () => globalThis.matchMedia(e).matches, o = () => globalThis.matchMedia(r).matches;
|
|
22
22
|
return {
|
|
23
|
-
isMobile:
|
|
24
|
-
isDesktop:
|
|
23
|
+
isMobile: $e(t, a, Je),
|
|
24
|
+
isDesktop: $e(i, o, Je)
|
|
25
25
|
};
|
|
26
26
|
}, lr = (e, r) => {
|
|
27
27
|
const t = (i) => {
|
|
@@ -36,8 +36,8 @@ const Ye = () => !1, or = () => {
|
|
|
36
36
|
}, [e, r]);
|
|
37
37
|
};
|
|
38
38
|
var ye = (e) => e.type === "checkbox", ie = (e) => e instanceof Date, P = (e) => e == null;
|
|
39
|
-
const
|
|
40
|
-
var L = (e) => !P(e) && !Array.isArray(e) &&
|
|
39
|
+
const ct = (e) => typeof e == "object";
|
|
40
|
+
var L = (e) => !P(e) && !Array.isArray(e) && ct(e) && !ie(e), dt = (e) => L(e) && e.target ? ye(e.target) ? e.target.checked : e.target.value : e, Rt = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, ft = (e, r) => e.has(Rt(r)), Ut = (e) => {
|
|
41
41
|
const r = e.constructor && e.constructor.prototype;
|
|
42
42
|
return L(r) && r.hasOwnProperty("isPrototypeOf");
|
|
43
43
|
}, Me = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
@@ -58,27 +58,27 @@ function U(e) {
|
|
|
58
58
|
return e;
|
|
59
59
|
return r;
|
|
60
60
|
}
|
|
61
|
-
var Ae = (e) => Array.isArray(e) ? e.filter(Boolean) : [],
|
|
61
|
+
var Ae = (e) => /^\w*$/.test(e), M = (e) => e === void 0, Le = (e) => Array.isArray(e) ? e.filter(Boolean) : [], Oe = (e) => Le(e.replace(/["|']|\]/g, "").split(/\.|\[/)), y = (e, r, t) => {
|
|
62
62
|
if (!r || !L(e))
|
|
63
63
|
return t;
|
|
64
|
-
const i = Ae(r
|
|
64
|
+
const i = (Ae(r) ? [r] : Oe(r)).reduce((a, o) => P(a) ? a : a[o], e);
|
|
65
65
|
return M(i) || i === e ? M(e[r]) ? t : e[r] : i;
|
|
66
|
-
}, W = (e) => typeof e == "boolean",
|
|
66
|
+
}, W = (e) => typeof e == "boolean", F = (e, r, t) => {
|
|
67
67
|
let i = -1;
|
|
68
|
-
const a =
|
|
68
|
+
const a = Ae(r) ? [r] : Oe(r), o = a.length, u = o - 1;
|
|
69
69
|
for (; ++i < o; ) {
|
|
70
|
-
const
|
|
70
|
+
const c = a[i];
|
|
71
71
|
let v = t;
|
|
72
72
|
if (i !== u) {
|
|
73
|
-
const D = e[
|
|
73
|
+
const D = e[c];
|
|
74
74
|
v = L(D) || Array.isArray(D) ? D : isNaN(+a[i + 1]) ? {} : [];
|
|
75
75
|
}
|
|
76
|
-
if (
|
|
76
|
+
if (c === "__proto__" || c === "constructor" || c === "prototype")
|
|
77
77
|
return;
|
|
78
|
-
e[
|
|
78
|
+
e[c] = v, e = e[c];
|
|
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,11 @@ const _e = {
|
|
|
96
96
|
pattern: "pattern",
|
|
97
97
|
required: "required",
|
|
98
98
|
validate: "validate"
|
|
99
|
-
},
|
|
99
|
+
}, Re = A.createContext(null);
|
|
100
|
+
Re.displayName = "HookFormContext";
|
|
101
|
+
const Ue = () => A.useContext(Re), ur = (e) => {
|
|
100
102
|
const { children: r, ...t } = e;
|
|
101
|
-
return A.createElement(
|
|
103
|
+
return A.createElement(Re.Provider, { value: t }, r);
|
|
102
104
|
};
|
|
103
105
|
var yt = (e, r, t, i = !0) => {
|
|
104
106
|
const a = {
|
|
@@ -113,9 +115,9 @@ var yt = (e, r, t, i = !0) => {
|
|
|
113
115
|
});
|
|
114
116
|
return a;
|
|
115
117
|
};
|
|
116
|
-
const
|
|
118
|
+
const Ne = typeof window < "u" ? ne.useLayoutEffect : ne.useEffect;
|
|
117
119
|
function Nt(e) {
|
|
118
|
-
const r =
|
|
120
|
+
const r = Ue(), { control: t = r.control, disabled: i, name: a, exact: o } = e || {}, [u, c] = A.useState(t._formState), v = A.useRef({
|
|
119
121
|
isDirty: !1,
|
|
120
122
|
isLoading: !1,
|
|
121
123
|
dirtyFields: !1,
|
|
@@ -125,12 +127,12 @@ function Nt(e) {
|
|
|
125
127
|
isValid: !1,
|
|
126
128
|
errors: !1
|
|
127
129
|
});
|
|
128
|
-
return
|
|
130
|
+
return Ne(() => t._subscribe({
|
|
129
131
|
name: a,
|
|
130
132
|
formState: v.current,
|
|
131
133
|
exact: o,
|
|
132
134
|
callback: (D) => {
|
|
133
|
-
!i &&
|
|
135
|
+
!i && c({
|
|
134
136
|
...t._formState,
|
|
135
137
|
...D
|
|
136
138
|
});
|
|
@@ -141,18 +143,18 @@ function Nt(e) {
|
|
|
141
143
|
}
|
|
142
144
|
var $ = (e) => typeof e == "string", ht = (e, r, t, i, a) => $(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
145
|
function Pt(e) {
|
|
144
|
-
const r =
|
|
145
|
-
return
|
|
146
|
+
const r = Ue(), { control: t = r.control, name: i, defaultValue: a, disabled: o, exact: u } = e || {}, c = A.useRef(a), [v, D] = A.useState(t._getWatch(i, c.current));
|
|
147
|
+
return Ne(() => t._subscribe({
|
|
146
148
|
name: i,
|
|
147
149
|
formState: {
|
|
148
150
|
values: !0
|
|
149
151
|
},
|
|
150
152
|
exact: u,
|
|
151
|
-
callback: (V) => !o && D(ht(i, t._names, V.values || t._formValues, !1,
|
|
153
|
+
callback: (V) => !o && D(ht(i, t._names, V.values || t._formValues, !1, c.current))
|
|
152
154
|
}), [i, t, o, u]), A.useEffect(() => t._removeUnmounted()), v;
|
|
153
155
|
}
|
|
154
156
|
function cr(e) {
|
|
155
|
-
const r =
|
|
157
|
+
const r = Ue(), { name: t, disabled: i, control: a = r.control, shouldUnregister: o } = e, u = ft(a._names.array, t), c = Pt({
|
|
156
158
|
control: a,
|
|
157
159
|
name: t,
|
|
158
160
|
defaultValue: y(a._formValues, t, y(a._defaultValues, t, e.defaultValue)),
|
|
@@ -163,7 +165,7 @@ function cr(e) {
|
|
|
163
165
|
exact: !0
|
|
164
166
|
}), D = A.useRef(e), V = A.useRef(a.register(t, {
|
|
165
167
|
...e.rules,
|
|
166
|
-
value:
|
|
168
|
+
value: c,
|
|
167
169
|
...W(e.disabled) ? { disabled: e.disabled } : {}
|
|
168
170
|
})), S = A.useMemo(() => Object.defineProperties({}, {
|
|
169
171
|
invalid: {
|
|
@@ -188,45 +190,45 @@ function cr(e) {
|
|
|
188
190
|
}
|
|
189
191
|
}), [v, t]), b = A.useCallback((C) => V.current.onChange({
|
|
190
192
|
target: {
|
|
191
|
-
value:
|
|
193
|
+
value: dt(C),
|
|
192
194
|
name: t
|
|
193
195
|
},
|
|
194
|
-
type:
|
|
196
|
+
type: me.CHANGE
|
|
195
197
|
}), [t]), Z = A.useCallback(() => V.current.onBlur({
|
|
196
198
|
target: {
|
|
197
199
|
value: y(a._formValues, t),
|
|
198
200
|
name: t
|
|
199
201
|
},
|
|
200
|
-
type:
|
|
202
|
+
type: me.BLUR
|
|
201
203
|
}), [t, a._formValues]), H = A.useCallback((C) => {
|
|
202
204
|
const J = y(a._fields, t);
|
|
203
205
|
J && C && (J._f.ref = {
|
|
204
206
|
focus: () => C.focus && C.focus(),
|
|
205
207
|
select: () => C.select && C.select(),
|
|
206
|
-
setCustomValidity: (
|
|
208
|
+
setCustomValidity: (m) => C.setCustomValidity(m),
|
|
207
209
|
reportValidity: () => C.reportValidity()
|
|
208
210
|
});
|
|
209
211
|
}, [a._fields, t]), k = A.useMemo(() => ({
|
|
210
212
|
name: t,
|
|
211
|
-
value:
|
|
213
|
+
value: c,
|
|
212
214
|
...W(i) || v.disabled ? { disabled: v.disabled || i } : {},
|
|
213
215
|
onChange: b,
|
|
214
216
|
onBlur: Z,
|
|
215
217
|
ref: H
|
|
216
|
-
}), [t, i, v.disabled, b, Z, H,
|
|
218
|
+
}), [t, i, v.disabled, b, Z, H, c]);
|
|
217
219
|
return A.useEffect(() => {
|
|
218
220
|
const C = a._options.shouldUnregister || o;
|
|
219
221
|
a.register(t, {
|
|
220
222
|
...D.current.rules,
|
|
221
223
|
...W(D.current.disabled) ? { disabled: D.current.disabled } : {}
|
|
222
224
|
});
|
|
223
|
-
const J = (
|
|
224
|
-
const p = y(a._fields,
|
|
225
|
+
const J = (m, j) => {
|
|
226
|
+
const p = y(a._fields, m);
|
|
225
227
|
p && p._f && (p._f.mount = j);
|
|
226
228
|
};
|
|
227
229
|
if (J(t, !0), C) {
|
|
228
|
-
const
|
|
229
|
-
F(a._defaultValues, t,
|
|
230
|
+
const m = U(y(a._options.defaultValues, t));
|
|
231
|
+
F(a._defaultValues, t, m), M(y(a._formValues, t)) && F(a._formValues, t, m);
|
|
230
232
|
}
|
|
231
233
|
return !u && a.register(t), () => {
|
|
232
234
|
(u ? C && !a._state.action : C) ? a.unregister(t) : J(t, !1);
|
|
@@ -248,7 +250,7 @@ var gt = (e, r, t, i, a) => r ? {
|
|
|
248
250
|
...t[e] && t[e].types ? t[e].types : {},
|
|
249
251
|
[i]: a || !0
|
|
250
252
|
}
|
|
251
|
-
} : {}, de = (e) => Array.isArray(e) ? e : [e],
|
|
253
|
+
} : {}, de = (e) => Array.isArray(e) ? e : [e], Xe = () => {
|
|
252
254
|
let e = [];
|
|
253
255
|
return {
|
|
254
256
|
get observers() {
|
|
@@ -267,7 +269,7 @@ var gt = (e, r, t, i, a) => r ? {
|
|
|
267
269
|
e = [];
|
|
268
270
|
}
|
|
269
271
|
};
|
|
270
|
-
}, Te = (e) => P(e) || !
|
|
272
|
+
}, Te = (e) => P(e) || !ct(e);
|
|
271
273
|
function re(e, r) {
|
|
272
274
|
if (Te(e) || Te(r))
|
|
273
275
|
return e === r;
|
|
@@ -288,12 +290,12 @@ function re(e, r) {
|
|
|
288
290
|
}
|
|
289
291
|
return !0;
|
|
290
292
|
}
|
|
291
|
-
var I = (e) => L(e) && !Object.keys(e).length,
|
|
293
|
+
var I = (e) => L(e) && !Object.keys(e).length, Pe = (e) => e.type === "file", z = (e) => typeof e == "function", _e = (e) => {
|
|
292
294
|
if (!Me)
|
|
293
295
|
return !1;
|
|
294
296
|
const r = e ? e.ownerDocument : 0;
|
|
295
297
|
return e instanceof (r && r.defaultView ? r.defaultView.HTMLElement : HTMLElement);
|
|
296
|
-
}, vt = (e) => e.type === "select-multiple",
|
|
298
|
+
}, vt = (e) => e.type === "select-multiple", pe = (e) => e.type === "radio", pt = (e) => pe(e) || ye(e), Ce = (e) => _e(e) && e.isConnected;
|
|
297
299
|
function Bt(e, r) {
|
|
298
300
|
const t = r.slice(0, -1).length;
|
|
299
301
|
let i = 0;
|
|
@@ -308,7 +310,7 @@ function It(e) {
|
|
|
308
310
|
return !0;
|
|
309
311
|
}
|
|
310
312
|
function R(e, r) {
|
|
311
|
-
const t = Array.isArray(r) ? r :
|
|
313
|
+
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];
|
|
312
314
|
return i && delete i[o], a !== 0 && (L(i) && I(i) || Array.isArray(i) && It(i)) && R(e, t.slice(0, -1)), e;
|
|
313
315
|
}
|
|
314
316
|
var bt = (e) => {
|
|
@@ -324,19 +326,19 @@ function Ve(e, r = {}) {
|
|
|
324
326
|
Array.isArray(e[i]) || L(e[i]) && !bt(e[i]) ? (r[i] = Array.isArray(e[i]) ? [] : {}, Ve(e[i], r[i])) : P(e[i]) || (r[i] = !0);
|
|
325
327
|
return r;
|
|
326
328
|
}
|
|
327
|
-
function
|
|
329
|
+
function mt(e, r, t) {
|
|
328
330
|
const i = Array.isArray(e);
|
|
329
331
|
if (L(e) || i)
|
|
330
332
|
for (const a in e)
|
|
331
|
-
Array.isArray(e[a]) || L(e[a]) && !bt(e[a]) ? M(r) || Te(t[a]) ? t[a] = Array.isArray(e[a]) ? Ve(e[a], []) : { ...Ve(e[a]) } :
|
|
333
|
+
Array.isArray(e[a]) || L(e[a]) && !bt(e[a]) ? M(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]);
|
|
332
334
|
return t;
|
|
333
335
|
}
|
|
334
|
-
var ue = (e, r) =>
|
|
335
|
-
const
|
|
336
|
+
var ue = (e, r) => mt(e, r, Ve(r));
|
|
337
|
+
const Ze = {
|
|
336
338
|
value: !1,
|
|
337
339
|
isValid: !1
|
|
338
|
-
},
|
|
339
|
-
var
|
|
340
|
+
}, et = { value: !0, isValid: !0 };
|
|
341
|
+
var _t = (e) => {
|
|
340
342
|
if (Array.isArray(e)) {
|
|
341
343
|
if (e.length > 1) {
|
|
342
344
|
const r = e.filter((t) => t && t.checked && !t.disabled).map((t) => t.value);
|
|
@@ -344,22 +346,22 @@ var mt = (e) => {
|
|
|
344
346
|
}
|
|
345
347
|
return e[0].checked && !e[0].disabled ? (
|
|
346
348
|
// @ts-expect-error expected to work in the browser
|
|
347
|
-
e[0].attributes && !M(e[0].attributes.value) ? M(e[0].value) || e[0].value === "" ?
|
|
348
|
-
) :
|
|
349
|
+
e[0].attributes && !M(e[0].attributes.value) ? M(e[0].value) || e[0].value === "" ? et : { value: e[0].value, isValid: !0 } : et
|
|
350
|
+
) : Ze;
|
|
349
351
|
}
|
|
350
|
-
return
|
|
352
|
+
return Ze;
|
|
351
353
|
}, Vt = (e, { valueAsNumber: r, valueAsDate: t, setValueAs: i }) => M(e) ? e : r ? e === "" ? NaN : e && +e : t && $(e) ? new Date(e) : i ? i(e) : e;
|
|
352
|
-
const
|
|
354
|
+
const tt = {
|
|
353
355
|
isValid: !1,
|
|
354
356
|
value: null
|
|
355
357
|
};
|
|
356
358
|
var Ft = (e) => Array.isArray(e) ? e.reduce((r, t) => t && t.checked && !t.disabled ? {
|
|
357
359
|
isValid: !0,
|
|
358
360
|
value: t.value
|
|
359
|
-
} : r,
|
|
360
|
-
function
|
|
361
|
+
} : r, tt) : tt;
|
|
362
|
+
function rt(e) {
|
|
361
363
|
const r = e.ref;
|
|
362
|
-
return
|
|
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(M(r.value) ? e.ref.value : r.value, e);
|
|
363
365
|
}
|
|
364
366
|
var Wt = (e, r, t, i) => {
|
|
365
367
|
const a = {};
|
|
@@ -373,53 +375,53 @@ var Wt = (e, r, t, i) => {
|
|
|
373
375
|
fields: a,
|
|
374
376
|
shouldUseNativeValidation: i
|
|
375
377
|
};
|
|
376
|
-
}, Fe = (e) => e instanceof RegExp, ce = (e) => M(e) ? e : Fe(e) ? e.source : L(e) ? Fe(e.value) ? e.value.source : e.value : e,
|
|
378
|
+
}, Fe = (e) => e instanceof RegExp, ce = (e) => M(e) ? e : Fe(e) ? e.source : L(e) ? Fe(e.value) ? e.value.source : e.value : e, st = (e) => ({
|
|
377
379
|
isOnSubmit: !e || e === Q.onSubmit,
|
|
378
380
|
isOnBlur: e === Q.onBlur,
|
|
379
381
|
isOnChange: e === Q.onChange,
|
|
380
382
|
isOnAll: e === Q.all,
|
|
381
383
|
isOnTouch: e === Q.onTouched
|
|
382
384
|
});
|
|
383
|
-
const
|
|
384
|
-
var qt = (e) => !!e && !!e.validate && !!(z(e.validate) && e.validate.constructor.name ===
|
|
385
|
+
const it = "AsyncFunction";
|
|
386
|
+
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))));
|
|
385
387
|
const fe = (e, r, t, i) => {
|
|
386
388
|
for (const a of t || Object.keys(e)) {
|
|
387
389
|
const o = y(e, a);
|
|
388
390
|
if (o) {
|
|
389
|
-
const { _f: u, ...
|
|
391
|
+
const { _f: u, ...c } = o;
|
|
390
392
|
if (u) {
|
|
391
393
|
if (u.refs && u.refs[0] && r(u.refs[0], a) && !i)
|
|
392
394
|
return !0;
|
|
393
395
|
if (u.ref && r(u.ref, u.name) && !i)
|
|
394
396
|
return !0;
|
|
395
|
-
if (fe(
|
|
397
|
+
if (fe(c, r))
|
|
396
398
|
break;
|
|
397
|
-
} else if (L(
|
|
399
|
+
} else if (L(c) && fe(c, r))
|
|
398
400
|
break;
|
|
399
401
|
}
|
|
400
402
|
}
|
|
401
403
|
};
|
|
402
|
-
function
|
|
404
|
+
function at(e, r, t) {
|
|
403
405
|
const i = y(e, t);
|
|
404
|
-
if (i ||
|
|
406
|
+
if (i || Ae(t))
|
|
405
407
|
return {
|
|
406
408
|
error: i,
|
|
407
409
|
name: t
|
|
408
410
|
};
|
|
409
411
|
const a = t.split(".");
|
|
410
412
|
for (; a.length; ) {
|
|
411
|
-
const o = a.join("."), u = y(r, o),
|
|
413
|
+
const o = a.join("."), u = y(r, o), c = y(e, o);
|
|
412
414
|
if (u && !Array.isArray(u) && t !== o)
|
|
413
415
|
return { name: t };
|
|
414
|
-
if (
|
|
416
|
+
if (c && c.type)
|
|
415
417
|
return {
|
|
416
418
|
name: o,
|
|
417
|
-
error:
|
|
419
|
+
error: c
|
|
418
420
|
};
|
|
419
|
-
if (
|
|
421
|
+
if (c && c.root && c.root.type)
|
|
420
422
|
return {
|
|
421
423
|
name: `${o}.root`,
|
|
422
|
-
error:
|
|
424
|
+
error: c.root
|
|
423
425
|
};
|
|
424
426
|
a.pop();
|
|
425
427
|
}
|
|
@@ -431,11 +433,11 @@ var jt = (e, r, t, i) => {
|
|
|
431
433
|
t(e);
|
|
432
434
|
const { name: a, ...o } = e;
|
|
433
435
|
return I(o) || Object.keys(o).length >= Object.keys(r).length || Object.keys(o).find((u) => r[u] === (!i || Q.all));
|
|
434
|
-
}, 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) => !
|
|
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(y(e, r)).length && R(e, r), Gt = (e, r, t) => {
|
|
435
437
|
const i = de(y(e, t));
|
|
436
438
|
return F(i, "root", r[t]), F(e, t, i), e;
|
|
437
439
|
}, be = (e) => $(e);
|
|
438
|
-
function
|
|
440
|
+
function ot(e, r, t = "validate") {
|
|
439
441
|
if (be(e) || Array.isArray(e) && e.every(be) || W(e) && !e)
|
|
440
442
|
return {
|
|
441
443
|
type: t,
|
|
@@ -446,24 +448,24 @@ function nt(e, r, t = "validate") {
|
|
|
446
448
|
var oe = (e) => L(e) && !Fe(e) ? e : {
|
|
447
449
|
value: e,
|
|
448
450
|
message: ""
|
|
449
|
-
},
|
|
450
|
-
const { ref: u, refs:
|
|
451
|
+
}, lt = async (e, r, t, i, a, o) => {
|
|
452
|
+
const { ref: u, refs: c, required: v, maxLength: D, minLength: V, min: S, max: b, pattern: Z, validate: H, name: k, valueAsNumber: C, mount: J } = e._f, m = y(t, k);
|
|
451
453
|
if (!J || r.has(k))
|
|
452
454
|
return {};
|
|
453
|
-
const j =
|
|
454
|
-
a && j.reportValidity && (j.setCustomValidity(W(
|
|
455
|
-
}, O = {}, he =
|
|
456
|
-
const Y =
|
|
455
|
+
const j = c ? c[0] : u, p = (_) => {
|
|
456
|
+
a && j.reportValidity && (j.setCustomValidity(W(_) ? "" : _ || ""), j.reportValidity());
|
|
457
|
+
}, O = {}, he = pe(u), ee = ye(u), xe = he || ee, K = (C || Pe(u)) && M(u.value) && M(m) || _e(u) && u.value === "" || m === "" || Array.isArray(m) && !m.length, se = gt.bind(null, k, i, O), G = (_, E, T, N = X.maxLength, B = X.minLength) => {
|
|
458
|
+
const Y = _ ? E : T;
|
|
457
459
|
O[k] = {
|
|
458
|
-
type:
|
|
460
|
+
type: _ ? N : B,
|
|
459
461
|
message: Y,
|
|
460
462
|
ref: u,
|
|
461
|
-
...se(
|
|
463
|
+
...se(_ ? N : B, Y)
|
|
462
464
|
};
|
|
463
465
|
};
|
|
464
|
-
if (o ? !Array.isArray(
|
|
465
|
-
const { value:
|
|
466
|
-
if (
|
|
466
|
+
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: E } = be(v) ? { value: !!v, message: v } : oe(v);
|
|
468
|
+
if (_ && (O[k] = {
|
|
467
469
|
type: X.required,
|
|
468
470
|
message: E,
|
|
469
471
|
ref: j,
|
|
@@ -472,26 +474,26 @@ var oe = (e) => L(e) && !Fe(e) ? e : {
|
|
|
472
474
|
return p(E), O;
|
|
473
475
|
}
|
|
474
476
|
if (!K && (!P(S) || !P(b))) {
|
|
475
|
-
let
|
|
477
|
+
let _, E;
|
|
476
478
|
const T = oe(b), N = oe(S);
|
|
477
|
-
if (!P(
|
|
478
|
-
const B = u.valueAsNumber ||
|
|
479
|
-
P(T.value) || (
|
|
479
|
+
if (!P(m) && !isNaN(m)) {
|
|
480
|
+
const B = u.valueAsNumber || m && +m;
|
|
481
|
+
P(T.value) || (_ = B > T.value), P(N.value) || (E = B < N.value);
|
|
480
482
|
} else {
|
|
481
|
-
const B = u.valueAsDate || new Date(
|
|
482
|
-
$(T.value) &&
|
|
483
|
+
const B = u.valueAsDate || new Date(m), Y = (ge) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + ge), le = u.type == "time", ae = u.type == "week";
|
|
484
|
+
$(T.value) && m && (_ = le ? Y(m) > Y(T.value) : ae ? m > T.value : B > new Date(T.value)), $(N.value) && m && (E = le ? Y(m) < Y(N.value) : ae ? m < N.value : B < new Date(N.value));
|
|
483
485
|
}
|
|
484
|
-
if ((
|
|
486
|
+
if ((_ || E) && (G(!!_, T.message, N.message, X.max, X.min), !i))
|
|
485
487
|
return p(O[k].message), O;
|
|
486
488
|
}
|
|
487
|
-
if ((D || V) && !K && ($(
|
|
488
|
-
const
|
|
489
|
-
if ((T || N) && (G(T,
|
|
489
|
+
if ((D || V) && !K && ($(m) || o && Array.isArray(m))) {
|
|
490
|
+
const _ = oe(D), E = oe(V), T = !P(_.value) && m.length > +_.value, N = !P(E.value) && m.length < +E.value;
|
|
491
|
+
if ((T || N) && (G(T, _.message, E.message), !i))
|
|
490
492
|
return p(O[k].message), O;
|
|
491
493
|
}
|
|
492
|
-
if (Z && !K && $(
|
|
493
|
-
const { value:
|
|
494
|
-
if (Fe(
|
|
494
|
+
if (Z && !K && $(m)) {
|
|
495
|
+
const { value: _, message: E } = oe(Z);
|
|
496
|
+
if (Fe(_) && !m.match(_) && (O[k] = {
|
|
495
497
|
type: X.pattern,
|
|
496
498
|
message: E,
|
|
497
499
|
ref: u,
|
|
@@ -501,26 +503,26 @@ var oe = (e) => L(e) && !Fe(e) ? e : {
|
|
|
501
503
|
}
|
|
502
504
|
if (H) {
|
|
503
505
|
if (z(H)) {
|
|
504
|
-
const
|
|
506
|
+
const _ = await H(m, t), E = ot(_, j);
|
|
505
507
|
if (E && (O[k] = {
|
|
506
508
|
...E,
|
|
507
509
|
...se(X.validate, E.message)
|
|
508
510
|
}, !i))
|
|
509
511
|
return p(E.message), O;
|
|
510
512
|
} else if (L(H)) {
|
|
511
|
-
let
|
|
513
|
+
let _ = {};
|
|
512
514
|
for (const E in H) {
|
|
513
|
-
if (!I(
|
|
515
|
+
if (!I(_) && !i)
|
|
514
516
|
break;
|
|
515
|
-
const T =
|
|
516
|
-
T && (
|
|
517
|
+
const T = ot(await H[E](m, t), j, E);
|
|
518
|
+
T && (_ = {
|
|
517
519
|
...T,
|
|
518
520
|
...se(E, T.message)
|
|
519
|
-
}, p(T.message), i && (O[k] =
|
|
521
|
+
}, p(T.message), i && (O[k] = _));
|
|
520
522
|
}
|
|
521
|
-
if (!I(
|
|
523
|
+
if (!I(_) && (O[k] = {
|
|
522
524
|
ref: j,
|
|
523
|
-
...
|
|
525
|
+
..._
|
|
524
526
|
}, !i))
|
|
525
527
|
return O;
|
|
526
528
|
}
|
|
@@ -557,7 +559,7 @@ function $t(e = {}) {
|
|
|
557
559
|
action: !1,
|
|
558
560
|
mount: !1,
|
|
559
561
|
watch: !1
|
|
560
|
-
},
|
|
562
|
+
}, c = {
|
|
561
563
|
mount: /* @__PURE__ */ new Set(),
|
|
562
564
|
disabled: /* @__PURE__ */ new Set(),
|
|
563
565
|
unMount: /* @__PURE__ */ new Set(),
|
|
@@ -577,8 +579,8 @@ function $t(e = {}) {
|
|
|
577
579
|
...V
|
|
578
580
|
};
|
|
579
581
|
const b = {
|
|
580
|
-
array:
|
|
581
|
-
state:
|
|
582
|
+
array: Xe(),
|
|
583
|
+
state: Xe()
|
|
582
584
|
}, Z = r.criteriaMode === Q.all, H = (s) => (n) => {
|
|
583
585
|
clearTimeout(D), D = setTimeout(s, n);
|
|
584
586
|
}, k = async (s) => {
|
|
@@ -589,23 +591,23 @@ function $t(e = {}) {
|
|
|
589
591
|
});
|
|
590
592
|
}
|
|
591
593
|
}, C = (s, n) => {
|
|
592
|
-
!r.disabled && (V.isValidating || V.validatingFields || S.isValidating || S.validatingFields) && ((s || Array.from(
|
|
594
|
+
!r.disabled && (V.isValidating || V.validatingFields || S.isValidating || S.validatingFields) && ((s || Array.from(c.mount)).forEach((l) => {
|
|
593
595
|
l && (n ? F(t.validatingFields, l, n) : R(t.validatingFields, l));
|
|
594
596
|
}), b.state.next({
|
|
595
597
|
validatingFields: t.validatingFields,
|
|
596
598
|
isValidating: !I(t.validatingFields)
|
|
597
599
|
}));
|
|
598
|
-
}, J = (s, n = [], l, h, f = !0,
|
|
600
|
+
}, J = (s, n = [], l, h, f = !0, d = !0) => {
|
|
599
601
|
if (h && l && !r.disabled) {
|
|
600
|
-
if (u.action = !0,
|
|
602
|
+
if (u.action = !0, d && Array.isArray(y(i, s))) {
|
|
601
603
|
const g = l(y(i, s), h.argA, h.argB);
|
|
602
604
|
f && F(i, s, g);
|
|
603
605
|
}
|
|
604
|
-
if (
|
|
606
|
+
if (d && Array.isArray(y(t.errors, s))) {
|
|
605
607
|
const g = l(y(t.errors, s), h.argA, h.argB);
|
|
606
608
|
f && F(t.errors, s, g), zt(t.errors, s);
|
|
607
609
|
}
|
|
608
|
-
if ((V.touchedFields || S.touchedFields) &&
|
|
610
|
+
if ((V.touchedFields || S.touchedFields) && d && Array.isArray(y(t.touchedFields, s))) {
|
|
609
611
|
const g = l(y(t.touchedFields, s), h.argA, h.argB);
|
|
610
612
|
f && F(t.touchedFields, s, g);
|
|
611
613
|
}
|
|
@@ -618,7 +620,7 @@ function $t(e = {}) {
|
|
|
618
620
|
});
|
|
619
621
|
} else
|
|
620
622
|
F(o, s, n);
|
|
621
|
-
},
|
|
623
|
+
}, m = (s, n) => {
|
|
622
624
|
F(t.errors, s, n), b.state.next({
|
|
623
625
|
errors: t.errors
|
|
624
626
|
});
|
|
@@ -630,33 +632,33 @@ function $t(e = {}) {
|
|
|
630
632
|
}, p = (s, n, l, h) => {
|
|
631
633
|
const f = y(i, s);
|
|
632
634
|
if (f) {
|
|
633
|
-
const
|
|
634
|
-
M(
|
|
635
|
+
const d = y(o, s, M(l) ? y(a, s) : l);
|
|
636
|
+
M(d) || h && h.defaultChecked || n ? F(o, s, n ? d : rt(f._f)) : T(s, d), u.mount && k();
|
|
635
637
|
}
|
|
636
638
|
}, O = (s, n, l, h, f) => {
|
|
637
|
-
let
|
|
639
|
+
let d = !1, g = !1;
|
|
638
640
|
const x = {
|
|
639
641
|
name: s
|
|
640
642
|
};
|
|
641
643
|
if (!r.disabled) {
|
|
642
644
|
if (!l || h) {
|
|
643
|
-
(V.isDirty || S.isDirty) && (g = t.isDirty, t.isDirty = x.isDirty = G(),
|
|
645
|
+
(V.isDirty || S.isDirty) && (g = t.isDirty, t.isDirty = x.isDirty = G(), d = g !== x.isDirty);
|
|
644
646
|
const w = re(y(a, s), n);
|
|
645
|
-
g = !!y(t.dirtyFields, s), w ? R(t.dirtyFields, s) : F(t.dirtyFields, s, !0), x.dirtyFields = t.dirtyFields,
|
|
647
|
+
g = !!y(t.dirtyFields, s), w ? R(t.dirtyFields, s) : F(t.dirtyFields, s, !0), x.dirtyFields = t.dirtyFields, d = d || (V.dirtyFields || S.dirtyFields) && g !== !w;
|
|
646
648
|
}
|
|
647
649
|
if (l) {
|
|
648
650
|
const w = y(t.touchedFields, s);
|
|
649
|
-
w || (F(t.touchedFields, s, l), x.touchedFields = t.touchedFields,
|
|
651
|
+
w || (F(t.touchedFields, s, l), x.touchedFields = t.touchedFields, d = d || (V.touchedFields || S.touchedFields) && w !== l);
|
|
650
652
|
}
|
|
651
|
-
|
|
653
|
+
d && f && b.state.next(x);
|
|
652
654
|
}
|
|
653
|
-
return
|
|
655
|
+
return d ? x : {};
|
|
654
656
|
}, he = (s, n, l, h) => {
|
|
655
|
-
const f = y(t.errors, s),
|
|
656
|
-
if (r.delayError && l ? (v = H(() =>
|
|
657
|
+
const f = y(t.errors, s), d = (V.isValid || S.isValid) && W(n) && t.isValid !== n;
|
|
658
|
+
if (r.delayError && l ? (v = H(() => m(s, l)), v(r.delayError)) : (clearTimeout(D), v = null, l ? F(t.errors, s, l) : R(t.errors, s)), (l ? !re(f, l) : f) || !I(h) || d) {
|
|
657
659
|
const g = {
|
|
658
660
|
...h,
|
|
659
|
-
...
|
|
661
|
+
...d && W(n) ? { isValid: n } : {},
|
|
660
662
|
errors: t.errors,
|
|
661
663
|
name: s
|
|
662
664
|
};
|
|
@@ -667,7 +669,7 @@ function $t(e = {}) {
|
|
|
667
669
|
}
|
|
668
670
|
}, ee = async (s) => {
|
|
669
671
|
C(s, !0);
|
|
670
|
-
const n = await r.resolver(o, r.context, Wt(s ||
|
|
672
|
+
const n = await r.resolver(o, r.context, Wt(s || c.mount, i, r.criteriaMode, r.shouldUseNativeValidation));
|
|
671
673
|
return C(s), n;
|
|
672
674
|
}, xe = async (s) => {
|
|
673
675
|
const { errors: n } = await ee(s);
|
|
@@ -685,35 +687,35 @@ function $t(e = {}) {
|
|
|
685
687
|
for (const h in s) {
|
|
686
688
|
const f = s[h];
|
|
687
689
|
if (f) {
|
|
688
|
-
const { _f:
|
|
689
|
-
if (
|
|
690
|
-
const x =
|
|
690
|
+
const { _f: d, ...g } = f;
|
|
691
|
+
if (d) {
|
|
692
|
+
const x = c.array.has(d.name), w = f._f && qt(f._f);
|
|
691
693
|
w && V.validatingFields && C([h], !0);
|
|
692
|
-
const q = await
|
|
693
|
-
if (w && V.validatingFields && C([h]), q[
|
|
694
|
+
const q = await lt(f, c.disabled, o, Z, r.shouldUseNativeValidation && !n, x);
|
|
695
|
+
if (w && V.validatingFields && C([h]), q[d.name] && (l.valid = !1, n))
|
|
694
696
|
break;
|
|
695
|
-
!n && (y(q,
|
|
697
|
+
!n && (y(q, d.name) ? x ? Gt(t.errors, q, d.name) : F(t.errors, d.name, q[d.name]) : R(t.errors, d.name));
|
|
696
698
|
}
|
|
697
699
|
!I(g) && await K(g, n, l);
|
|
698
700
|
}
|
|
699
701
|
}
|
|
700
702
|
return l.valid;
|
|
701
703
|
}, se = () => {
|
|
702
|
-
for (const s of
|
|
704
|
+
for (const s of c.unMount) {
|
|
703
705
|
const n = y(i, s);
|
|
704
706
|
n && (n._f.refs ? n._f.refs.every((l) => !Ce(l)) : !Ce(n._f.ref)) && Ee(s);
|
|
705
707
|
}
|
|
706
|
-
|
|
707
|
-
}, G = (s, n) => !r.disabled && (s && n && F(o, s, n), !re(ge(), a)),
|
|
708
|
+
c.unMount = /* @__PURE__ */ new Set();
|
|
709
|
+
}, G = (s, n) => !r.disabled && (s && n && F(o, s, n), !re(ge(), a)), _ = (s, n, l) => ht(s, c, {
|
|
708
710
|
...u.mount ? o : M(n) ? a : $(s) ? { [s]: n } : n
|
|
709
|
-
}, l, n), E = (s) =>
|
|
711
|
+
}, l, n), E = (s) => Le(y(u.mount ? o : a, s, r.shouldUnregister ? y(a, s, []) : [])), T = (s, n, l = {}) => {
|
|
710
712
|
const h = y(i, s);
|
|
711
713
|
let f = n;
|
|
712
714
|
if (h) {
|
|
713
|
-
const
|
|
714
|
-
|
|
715
|
+
const d = h._f;
|
|
716
|
+
d && (!d.disabled && F(o, s, Vt(n, d)), f = _e(d.ref) && P(n) ? "" : n, vt(d.ref) ? [...d.ref.options].forEach((g) => g.selected = f.includes(g.value)) : d.refs ? ye(d.ref) ? d.refs.forEach((g) => {
|
|
715
717
|
(!g.defaultChecked || !g.disabled) && (Array.isArray(f) ? g.checked = !!f.find((x) => x === g.value) : g.checked = f === g.value || !!f);
|
|
716
|
-
}) :
|
|
718
|
+
}) : d.refs.forEach((g) => g.checked = g.value === f) : Pe(d.ref) ? d.ref.value = "" : (d.ref.value = f, d.ref.type || b.state.next({
|
|
717
719
|
name: s,
|
|
718
720
|
values: U(o)
|
|
719
721
|
})));
|
|
@@ -723,19 +725,19 @@ function $t(e = {}) {
|
|
|
723
725
|
for (const h in n) {
|
|
724
726
|
if (!n.hasOwnProperty(h))
|
|
725
727
|
return;
|
|
726
|
-
const f = n[h],
|
|
727
|
-
(
|
|
728
|
+
const f = n[h], d = s + "." + h, g = y(i, d);
|
|
729
|
+
(c.array.has(s) || L(f) || g && !g._f) && !ie(f) ? N(d, f, l) : T(d, f, l);
|
|
728
730
|
}
|
|
729
731
|
}, B = (s, n, l = {}) => {
|
|
730
|
-
const h = y(i, s), f =
|
|
731
|
-
F(o, s,
|
|
732
|
+
const h = y(i, s), f = c.array.has(s), d = U(n);
|
|
733
|
+
F(o, s, d), f ? (b.array.next({
|
|
732
734
|
name: s,
|
|
733
735
|
values: U(o)
|
|
734
736
|
}), (V.isDirty || V.dirtyFields || S.isDirty || S.dirtyFields) && l.shouldDirty && b.state.next({
|
|
735
737
|
name: s,
|
|
736
738
|
dirtyFields: ue(a, o),
|
|
737
|
-
isDirty: G(s,
|
|
738
|
-
})) : h && !h._f && !P(
|
|
739
|
+
isDirty: G(s, d)
|
|
740
|
+
})) : h && !h._f && !P(d) ? N(s, d, l) : T(s, d, l), nt(s, c) && b.state.next({ ...t }), b.state.next({
|
|
739
741
|
name: u.mount ? s : void 0,
|
|
740
742
|
values: U(o)
|
|
741
743
|
});
|
|
@@ -743,12 +745,12 @@ function $t(e = {}) {
|
|
|
743
745
|
u.mount = !0;
|
|
744
746
|
const n = s.target;
|
|
745
747
|
let l = n.name, h = !0;
|
|
746
|
-
const f = y(i, l),
|
|
748
|
+
const f = y(i, l), d = (w) => {
|
|
747
749
|
h = Number.isNaN(w) || ie(w) && isNaN(w.getTime()) || re(w, y(o, l, w));
|
|
748
|
-
}, g =
|
|
750
|
+
}, g = st(r.mode), x = st(r.reValidateMode);
|
|
749
751
|
if (f) {
|
|
750
752
|
let w, q;
|
|
751
|
-
const ve = n.type ?
|
|
753
|
+
const ve = n.type ? rt(f._f) : dt(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, x, g), Se = nt(l, c, te);
|
|
752
754
|
F(o, l, ve), te ? (f._f.onBlur && f._f.onBlur(s), v && v(0)) : f._f.onChange && f._f.onChange(s);
|
|
753
755
|
const ke = O(l, ve, te), Mt = !I(ke) || Se;
|
|
754
756
|
if (!te && b.state.next({
|
|
@@ -758,13 +760,13 @@ function $t(e = {}) {
|
|
|
758
760
|
}), Tt)
|
|
759
761
|
return (V.isValid || S.isValid) && (r.mode === "onBlur" ? te && k() : te || k()), Mt && b.state.next({ name: l, ...Se ? {} : ke });
|
|
760
762
|
if (!te && Se && b.state.next({ ...t }), r.resolver) {
|
|
761
|
-
const { errors:
|
|
762
|
-
if (
|
|
763
|
-
const Lt =
|
|
764
|
-
w =
|
|
763
|
+
const { errors: ze } = await ee([l]);
|
|
764
|
+
if (d(ve), h) {
|
|
765
|
+
const Lt = at(t.errors, i, l), Ge = at(ze, i, Lt.name || l);
|
|
766
|
+
w = Ge.error, l = Ge.name, q = I(ze);
|
|
765
767
|
}
|
|
766
768
|
} else
|
|
767
|
-
C([l], !0), w = (await
|
|
769
|
+
C([l], !0), w = (await lt(f, c.disabled, o, Z, r.shouldUseNativeValidation))[l], C([l]), d(ve), h && (w ? q = !1 : (V.isValid || S.isValid) && (q = await K(i, !0)));
|
|
768
770
|
h && (f._f.deps && ae(f._f.deps), he(l, q, w, ke));
|
|
769
771
|
}
|
|
770
772
|
}, le = (s, n) => {
|
|
@@ -774,23 +776,23 @@ function $t(e = {}) {
|
|
|
774
776
|
let l, h;
|
|
775
777
|
const f = de(s);
|
|
776
778
|
if (r.resolver) {
|
|
777
|
-
const
|
|
778
|
-
l = I(
|
|
779
|
-
} else s ? (h = (await Promise.all(f.map(async (
|
|
780
|
-
const g = y(i,
|
|
781
|
-
return await K(g && g._f ? { [
|
|
779
|
+
const d = await xe(M(s) ? s : f);
|
|
780
|
+
l = I(d), h = s ? !f.some((g) => y(d, g)) : l;
|
|
781
|
+
} else s ? (h = (await Promise.all(f.map(async (d) => {
|
|
782
|
+
const g = y(i, d);
|
|
783
|
+
return await K(g && g._f ? { [d]: g } : g);
|
|
782
784
|
}))).every(Boolean), !(!h && !t.isValid) && k()) : h = l = await K(i);
|
|
783
785
|
return b.state.next({
|
|
784
786
|
...!$(s) || (V.isValid || S.isValid) && l !== t.isValid ? {} : { name: s },
|
|
785
787
|
...r.resolver || !s ? { isValid: l } : {},
|
|
786
788
|
errors: t.errors
|
|
787
|
-
}), n.shouldFocus && !h && fe(i, le, s ? f :
|
|
789
|
+
}), n.shouldFocus && !h && fe(i, le, s ? f : c.mount), h;
|
|
788
790
|
}, ge = (s) => {
|
|
789
791
|
const n = {
|
|
790
792
|
...u.mount ? o : a
|
|
791
793
|
};
|
|
792
794
|
return M(s) ? n : $(s) ? y(n, s) : s.map((l) => y(n, l));
|
|
793
|
-
},
|
|
795
|
+
}, Be = (s, n) => ({
|
|
794
796
|
invalid: !!y((n || t).errors, s),
|
|
795
797
|
isDirty: !!y((n || t).dirtyFields, s),
|
|
796
798
|
error: y((n || t).errors, s),
|
|
@@ -800,8 +802,8 @@ function $t(e = {}) {
|
|
|
800
802
|
s && de(s).forEach((n) => R(t.errors, n)), b.state.next({
|
|
801
803
|
errors: s ? t.errors : {}
|
|
802
804
|
});
|
|
803
|
-
},
|
|
804
|
-
const h = (y(i, s, { _f: {} })._f || {}).ref, f = y(t.errors, s) || {}, { ref:
|
|
805
|
+
}, Ie = (s, n, l) => {
|
|
806
|
+
const h = (y(i, s, { _f: {} })._f || {}).ref, f = y(t.errors, s) || {}, { ref: d, message: g, type: x, ...w } = f;
|
|
805
807
|
F(t.errors, s, {
|
|
806
808
|
...w,
|
|
807
809
|
...n,
|
|
@@ -812,8 +814,8 @@ function $t(e = {}) {
|
|
|
812
814
|
isValid: !1
|
|
813
815
|
}), l && l.shouldFocus && h && h.focus && h.focus();
|
|
814
816
|
}, Et = (s, n) => z(s) ? b.state.subscribe({
|
|
815
|
-
next: (l) => s(
|
|
816
|
-
}) :
|
|
817
|
+
next: (l) => s(_(void 0, n), l)
|
|
818
|
+
}) : _(s, n, !0), We = (s) => b.state.subscribe({
|
|
817
819
|
next: (n) => {
|
|
818
820
|
Kt(s.name, n.name, s.exact) && jt(n, s.formState || V, Ct, s.reRenderRoot) && s.callback({
|
|
819
821
|
values: { ...o },
|
|
@@ -824,20 +826,20 @@ function $t(e = {}) {
|
|
|
824
826
|
}).unsubscribe, wt = (s) => (u.mount = !0, S = {
|
|
825
827
|
...S,
|
|
826
828
|
...s.formState
|
|
827
|
-
},
|
|
829
|
+
}, We({
|
|
828
830
|
...s,
|
|
829
831
|
formState: S
|
|
830
832
|
})), Ee = (s, n = {}) => {
|
|
831
|
-
for (const l of s ? de(s) :
|
|
832
|
-
|
|
833
|
+
for (const l of s ? de(s) : c.mount)
|
|
834
|
+
c.mount.delete(l), c.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);
|
|
833
835
|
b.state.next({
|
|
834
836
|
values: U(o)
|
|
835
837
|
}), b.state.next({
|
|
836
838
|
...t,
|
|
837
839
|
...n.keepDirty ? { isDirty: G() } : {}
|
|
838
840
|
}), !n.keepIsValid && k();
|
|
839
|
-
},
|
|
840
|
-
(W(s) && u.mount || s ||
|
|
841
|
+
}, qe = ({ disabled: s, name: n }) => {
|
|
842
|
+
(W(s) && u.mount || s || c.disabled.has(n)) && (s ? c.disabled.add(n) : c.disabled.delete(n));
|
|
841
843
|
}, we = (s, n = {}) => {
|
|
842
844
|
let l = y(i, s);
|
|
843
845
|
const h = W(n.disabled) || W(r.disabled);
|
|
@@ -849,7 +851,7 @@ function $t(e = {}) {
|
|
|
849
851
|
mount: !0,
|
|
850
852
|
...n
|
|
851
853
|
}
|
|
852
|
-
}),
|
|
854
|
+
}), c.mount.add(s), l ? qe({
|
|
853
855
|
disabled: W(n.disabled) ? n.disabled : r.disabled,
|
|
854
856
|
name: s
|
|
855
857
|
}) : p(s, !0, n.value), {
|
|
@@ -868,8 +870,8 @@ function $t(e = {}) {
|
|
|
868
870
|
ref: (f) => {
|
|
869
871
|
if (f) {
|
|
870
872
|
we(s, n), l = y(i, s);
|
|
871
|
-
const
|
|
872
|
-
if (g ? x.find((w) => w ===
|
|
873
|
+
const d = M(f.value) && f.querySelectorAll && f.querySelectorAll("input,select,textarea")[0] || f, g = pt(d), x = l._f.refs || [];
|
|
874
|
+
if (g ? x.find((w) => w === d) : d === l._f.ref)
|
|
873
875
|
return;
|
|
874
876
|
F(i, s, {
|
|
875
877
|
_f: {
|
|
@@ -877,46 +879,46 @@ function $t(e = {}) {
|
|
|
877
879
|
...g ? {
|
|
878
880
|
refs: [
|
|
879
881
|
...x.filter(Ce),
|
|
880
|
-
|
|
882
|
+
d,
|
|
881
883
|
...Array.isArray(y(a, s)) ? [{}] : []
|
|
882
884
|
],
|
|
883
|
-
ref: { type:
|
|
884
|
-
} : { ref:
|
|
885
|
+
ref: { type: d.type, name: s }
|
|
886
|
+
} : { ref: d }
|
|
885
887
|
}
|
|
886
|
-
}), p(s, !1, void 0,
|
|
888
|
+
}), p(s, !1, void 0, d);
|
|
887
889
|
} else
|
|
888
|
-
l = y(i, s, {}), l._f && (l._f.mount = !1), (r.shouldUnregister || n.shouldUnregister) && !(
|
|
890
|
+
l = y(i, s, {}), l._f && (l._f.mount = !1), (r.shouldUnregister || n.shouldUnregister) && !(ft(c.array, s) && u.action) && c.unMount.add(s);
|
|
889
891
|
}
|
|
890
892
|
};
|
|
891
|
-
}, De = () => r.shouldFocusError && fe(i, le,
|
|
893
|
+
}, De = () => r.shouldFocusError && fe(i, le, c.mount), Dt = (s) => {
|
|
892
894
|
W(s) && (b.state.next({ disabled: s }), fe(i, (n, l) => {
|
|
893
895
|
const h = y(i, l);
|
|
894
896
|
h && (n.disabled = h._f.disabled || s, Array.isArray(h._f.refs) && h._f.refs.forEach((f) => {
|
|
895
897
|
f.disabled = h._f.disabled || s;
|
|
896
898
|
}));
|
|
897
899
|
}, 0, !1));
|
|
898
|
-
},
|
|
900
|
+
}, He = (s, n) => async (l) => {
|
|
899
901
|
let h;
|
|
900
902
|
l && (l.preventDefault && l.preventDefault(), l.persist && l.persist());
|
|
901
903
|
let f = U(o);
|
|
902
904
|
if (b.state.next({
|
|
903
905
|
isSubmitting: !0
|
|
904
906
|
}), r.resolver) {
|
|
905
|
-
const { errors:
|
|
906
|
-
t.errors =
|
|
907
|
+
const { errors: d, values: g } = await ee();
|
|
908
|
+
t.errors = d, f = g;
|
|
907
909
|
} else
|
|
908
910
|
await K(i);
|
|
909
|
-
if (
|
|
910
|
-
for (const
|
|
911
|
-
F(f,
|
|
911
|
+
if (c.disabled.size)
|
|
912
|
+
for (const d of c.disabled)
|
|
913
|
+
F(f, d, void 0);
|
|
912
914
|
if (R(t.errors, "root"), I(t.errors)) {
|
|
913
915
|
b.state.next({
|
|
914
916
|
errors: {}
|
|
915
917
|
});
|
|
916
918
|
try {
|
|
917
919
|
await s(f, l);
|
|
918
|
-
} catch (
|
|
919
|
-
h =
|
|
920
|
+
} catch (d) {
|
|
921
|
+
h = d;
|
|
920
922
|
}
|
|
921
923
|
} else
|
|
922
924
|
n && await n({ ...t.errors }, l), De(), setTimeout(De);
|
|
@@ -930,23 +932,23 @@ function $t(e = {}) {
|
|
|
930
932
|
throw h;
|
|
931
933
|
}, St = (s, n = {}) => {
|
|
932
934
|
y(i, s) && (M(n.defaultValue) ? B(s, U(y(a, s))) : (B(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 ? G(s, U(y(a, s))) : G()), n.keepError || (R(t.errors, s), V.isValid && k()), b.state.next({ ...t }));
|
|
933
|
-
},
|
|
934
|
-
const l = s ? U(s) : a, h = U(l), f = I(s),
|
|
935
|
+
}, je = (s, n = {}) => {
|
|
936
|
+
const l = s ? U(s) : a, h = U(l), f = I(s), d = f ? a : h;
|
|
935
937
|
if (n.keepDefaultValues || (a = l), !n.keepValues) {
|
|
936
938
|
if (n.keepDirtyValues) {
|
|
937
939
|
const g = /* @__PURE__ */ new Set([
|
|
938
|
-
...
|
|
940
|
+
...c.mount,
|
|
939
941
|
...Object.keys(ue(a, o))
|
|
940
942
|
]);
|
|
941
943
|
for (const x of Array.from(g))
|
|
942
|
-
y(t.dirtyFields, x) ? F(
|
|
944
|
+
y(t.dirtyFields, x) ? F(d, x, y(o, x)) : B(x, y(d, x));
|
|
943
945
|
} else {
|
|
944
946
|
if (Me && M(s))
|
|
945
|
-
for (const g of
|
|
947
|
+
for (const g of c.mount) {
|
|
946
948
|
const x = y(i, g);
|
|
947
949
|
if (x && x._f) {
|
|
948
950
|
const w = Array.isArray(x._f.refs) ? x._f.refs[0] : x._f.ref;
|
|
949
|
-
if (
|
|
951
|
+
if (_e(w)) {
|
|
950
952
|
const q = w.closest("form");
|
|
951
953
|
if (q) {
|
|
952
954
|
q.reset();
|
|
@@ -955,17 +957,17 @@ function $t(e = {}) {
|
|
|
955
957
|
}
|
|
956
958
|
}
|
|
957
959
|
}
|
|
958
|
-
for (const g of
|
|
959
|
-
B(g, y(
|
|
960
|
+
for (const g of c.mount)
|
|
961
|
+
B(g, y(d, g));
|
|
960
962
|
}
|
|
961
|
-
o = U(
|
|
962
|
-
values: { ...
|
|
963
|
+
o = U(d), b.array.next({
|
|
964
|
+
values: { ...d }
|
|
963
965
|
}), b.state.next({
|
|
964
|
-
values: { ...
|
|
966
|
+
values: { ...d }
|
|
965
967
|
});
|
|
966
968
|
}
|
|
967
|
-
|
|
968
|
-
mount: n.keepDirtyValues ?
|
|
969
|
+
c = {
|
|
970
|
+
mount: n.keepDirtyValues ? c.mount : /* @__PURE__ */ new Set(),
|
|
969
971
|
unMount: /* @__PURE__ */ new Set(),
|
|
970
972
|
array: /* @__PURE__ */ new Set(),
|
|
971
973
|
disabled: /* @__PURE__ */ new Set(),
|
|
@@ -982,7 +984,7 @@ function $t(e = {}) {
|
|
|
982
984
|
isSubmitSuccessful: n.keepIsSubmitSuccessful ? t.isSubmitSuccessful : !1,
|
|
983
985
|
isSubmitting: !1
|
|
984
986
|
});
|
|
985
|
-
},
|
|
987
|
+
}, Ke = (s, n) => je(z(s) ? s(o) : s, n), kt = (s, n = {}) => {
|
|
986
988
|
const l = y(i, s), h = l && l._f;
|
|
987
989
|
if (h) {
|
|
988
990
|
const f = h.refs ? h.refs[0] : h.ref;
|
|
@@ -993,26 +995,26 @@ function $t(e = {}) {
|
|
|
993
995
|
...t,
|
|
994
996
|
...s
|
|
995
997
|
};
|
|
996
|
-
},
|
|
998
|
+
}, Qe = {
|
|
997
999
|
control: {
|
|
998
1000
|
register: we,
|
|
999
1001
|
unregister: Ee,
|
|
1000
|
-
getFieldState:
|
|
1001
|
-
handleSubmit:
|
|
1002
|
-
setError:
|
|
1003
|
-
_subscribe:
|
|
1002
|
+
getFieldState: Be,
|
|
1003
|
+
handleSubmit: He,
|
|
1004
|
+
setError: Ie,
|
|
1005
|
+
_subscribe: We,
|
|
1004
1006
|
_runSchema: ee,
|
|
1005
1007
|
_focusError: De,
|
|
1006
|
-
_getWatch:
|
|
1008
|
+
_getWatch: _,
|
|
1007
1009
|
_getDirty: G,
|
|
1008
1010
|
_setValid: k,
|
|
1009
1011
|
_setFieldArray: J,
|
|
1010
|
-
_setDisabledField:
|
|
1012
|
+
_setDisabledField: qe,
|
|
1011
1013
|
_setErrors: j,
|
|
1012
1014
|
_getFieldArray: E,
|
|
1013
|
-
_reset:
|
|
1015
|
+
_reset: je,
|
|
1014
1016
|
_resetDefaultValues: () => z(r.defaultValues) && r.defaultValues().then((s) => {
|
|
1015
|
-
|
|
1017
|
+
Ke(s, r.resetOptions), b.state.next({
|
|
1016
1018
|
isLoading: !1
|
|
1017
1019
|
});
|
|
1018
1020
|
}),
|
|
@@ -1036,10 +1038,10 @@ function $t(e = {}) {
|
|
|
1036
1038
|
return a;
|
|
1037
1039
|
},
|
|
1038
1040
|
get _names() {
|
|
1039
|
-
return
|
|
1041
|
+
return c;
|
|
1040
1042
|
},
|
|
1041
1043
|
set _names(s) {
|
|
1042
|
-
|
|
1044
|
+
c = s;
|
|
1043
1045
|
},
|
|
1044
1046
|
get _formState() {
|
|
1045
1047
|
return t;
|
|
@@ -1057,21 +1059,21 @@ function $t(e = {}) {
|
|
|
1057
1059
|
subscribe: wt,
|
|
1058
1060
|
trigger: ae,
|
|
1059
1061
|
register: we,
|
|
1060
|
-
handleSubmit:
|
|
1062
|
+
handleSubmit: He,
|
|
1061
1063
|
watch: Et,
|
|
1062
1064
|
setValue: B,
|
|
1063
1065
|
getValues: ge,
|
|
1064
|
-
reset:
|
|
1066
|
+
reset: Ke,
|
|
1065
1067
|
resetField: St,
|
|
1066
1068
|
clearErrors: xt,
|
|
1067
1069
|
unregister: Ee,
|
|
1068
|
-
setError:
|
|
1070
|
+
setError: Ie,
|
|
1069
1071
|
setFocus: kt,
|
|
1070
|
-
getFieldState:
|
|
1072
|
+
getFieldState: Be
|
|
1071
1073
|
};
|
|
1072
1074
|
return {
|
|
1073
|
-
...
|
|
1074
|
-
formControl:
|
|
1075
|
+
...Qe,
|
|
1076
|
+
formControl: Qe
|
|
1075
1077
|
};
|
|
1076
1078
|
}
|
|
1077
1079
|
function Jt(e = {}) {
|
|
@@ -1092,19 +1094,28 @@ function Jt(e = {}) {
|
|
|
1092
1094
|
isReady: !1,
|
|
1093
1095
|
defaultValues: z(e.defaultValues) ? void 0 : e.defaultValues
|
|
1094
1096
|
});
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1097
|
+
if (!r.current)
|
|
1098
|
+
if (e.formControl)
|
|
1099
|
+
r.current = {
|
|
1100
|
+
...e.formControl,
|
|
1101
|
+
formState: i
|
|
1102
|
+
}, e.defaultValues && !z(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
|
|
1103
|
+
else {
|
|
1104
|
+
const { formControl: u, ...c } = $t(e);
|
|
1105
|
+
r.current = {
|
|
1106
|
+
...c,
|
|
1107
|
+
formState: i
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1099
1110
|
const o = r.current.control;
|
|
1100
|
-
return o._options = e,
|
|
1111
|
+
return o._options = e, Ne(() => {
|
|
1101
1112
|
const u = o._subscribe({
|
|
1102
1113
|
formState: o._proxyFormState,
|
|
1103
1114
|
callback: () => a({ ...o._formState }),
|
|
1104
1115
|
reRenderRoot: !0
|
|
1105
1116
|
});
|
|
1106
|
-
return a((
|
|
1107
|
-
...
|
|
1117
|
+
return a((c) => ({
|
|
1118
|
+
...c,
|
|
1108
1119
|
isReady: !0
|
|
1109
1120
|
})), o._formState.isReady = !0, u;
|
|
1110
1121
|
}, [o]), A.useEffect(() => o._disableForm(e.disabled), [o, e.disabled]), A.useEffect(() => {
|
|
@@ -1128,7 +1139,7 @@ function Jt(e = {}) {
|
|
|
1128
1139
|
o._state.mount || (o._setValid(), o._state.mount = !0), o._state.watch && (o._state.watch = !1, o._subjects.state.next({ ...o._formState })), o._removeUnmounted();
|
|
1129
1140
|
}), r.current.formState = yt(i, o), r.current;
|
|
1130
1141
|
}
|
|
1131
|
-
const
|
|
1142
|
+
const ut = (e, r, t) => {
|
|
1132
1143
|
if (e && "reportValidity" in e) {
|
|
1133
1144
|
const i = y(t, r);
|
|
1134
1145
|
e.setCustomValidity(i && i.message || ""), e.reportValidity();
|
|
@@ -1136,7 +1147,7 @@ const ot = (e, r, t) => {
|
|
|
1136
1147
|
}, At = (e, r) => {
|
|
1137
1148
|
for (const t in r.fields) {
|
|
1138
1149
|
const i = r.fields[t];
|
|
1139
|
-
i && i.ref && "reportValidity" in i.ref ?
|
|
1150
|
+
i && i.ref && "reportValidity" in i.ref ? ut(i.ref, t, e) : i.refs && i.refs.forEach((a) => ut(a, t, e));
|
|
1140
1151
|
}
|
|
1141
1152
|
}, Xt = (e, r) => {
|
|
1142
1153
|
r.shouldUseNativeValidation && At(e, r);
|
|
@@ -1154,8 +1165,8 @@ var er = function(e, r) {
|
|
|
1154
1165
|
for (var t = {}; e.length; ) {
|
|
1155
1166
|
var i = e[0], a = i.code, o = i.message, u = i.path.join(".");
|
|
1156
1167
|
if (!t[u]) if ("unionErrors" in i) {
|
|
1157
|
-
var
|
|
1158
|
-
t[u] = { message:
|
|
1168
|
+
var c = i.unionErrors[0].errors[0];
|
|
1169
|
+
t[u] = { message: c.message, type: c.code };
|
|
1159
1170
|
} else t[u] = { message: o, type: a };
|
|
1160
1171
|
if ("unionErrors" in i && i.unionErrors.forEach(function(V) {
|
|
1161
1172
|
return V.errors.forEach(function(S) {
|
|
@@ -1171,18 +1182,18 @@ var er = function(e, r) {
|
|
|
1171
1182
|
}, tr = function(e, r, t) {
|
|
1172
1183
|
return t === void 0 && (t = {}), function(i, a, o) {
|
|
1173
1184
|
try {
|
|
1174
|
-
return Promise.resolve(function(u,
|
|
1185
|
+
return Promise.resolve(function(u, c) {
|
|
1175
1186
|
try {
|
|
1176
1187
|
var v = Promise.resolve(e[t.mode === "sync" ? "parse" : "parseAsync"](i, r)).then(function(D) {
|
|
1177
1188
|
return o.shouldUseNativeValidation && At({}, o), { errors: {}, values: t.raw ? i : D };
|
|
1178
1189
|
});
|
|
1179
1190
|
} catch (D) {
|
|
1180
|
-
return
|
|
1191
|
+
return c(D);
|
|
1181
1192
|
}
|
|
1182
|
-
return v && v.then ? v.then(void 0,
|
|
1193
|
+
return v && v.then ? v.then(void 0, c) : v;
|
|
1183
1194
|
}(0, function(u) {
|
|
1184
|
-
if (function(
|
|
1185
|
-
return Array.isArray(
|
|
1195
|
+
if (function(c) {
|
|
1196
|
+
return Array.isArray(c == null ? void 0 : c.errors);
|
|
1186
1197
|
}(u)) return { values: {}, errors: Xt(er(u.errors, !o.shouldUseNativeValidation && o.criteriaMode === "all"), o) };
|
|
1187
1198
|
throw u;
|
|
1188
1199
|
}));
|
|
@@ -1213,8 +1224,8 @@ export {
|
|
|
1213
1224
|
rr as d,
|
|
1214
1225
|
fr as e,
|
|
1215
1226
|
Pt as f,
|
|
1216
|
-
|
|
1227
|
+
Ue as g,
|
|
1217
1228
|
cr as h,
|
|
1218
1229
|
or as u
|
|
1219
1230
|
};
|
|
1220
|
-
//# sourceMappingURL=useDebounce-
|
|
1231
|
+
//# sourceMappingURL=useDebounce-5MeprqTX.js.map
|