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