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