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