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