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