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