suprform 1.2.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/FormControl.d.ts +1 -1
- package/dist/components/FormControl.d.ts.map +1 -1
- package/dist/components/SuprForm.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 +630 -637
- package/dist/suprform.es.js.map +1 -1
- package/dist/type.d.ts +7 -4
- package/dist/type.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/suprform.es.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { jsx as te, jsxs as
|
|
2
|
-
import
|
|
3
|
-
var
|
|
1
|
+
import { jsx as te, jsxs as Ne, Fragment as Qt } from "react/jsx-runtime";
|
|
2
|
+
import V, { createContext as zt, useContext as Jt, useMemo as me, cloneElement as Ae, useImperativeHandle as At, Children as Kt, isValidElement as Yt, useEffect as Xt } from "react";
|
|
3
|
+
var Ve = (t) => t.type === "checkbox", le = (t) => t instanceof Date, J = (t) => t == null;
|
|
4
4
|
const pt = (t) => typeof t == "object";
|
|
5
|
-
var
|
|
5
|
+
var W = (t) => !J(t) && !Array.isArray(t) && pt(t) && !le(t), xt = (t) => W(t) && t.target ? Ve(t.target) ? t.target.checked : t.target.value : t, Zt = (t) => t.substring(0, t.search(/\.\d+(\.|$)/)) || t, St = (t, r) => t.has(Zt(r)), er = (t) => {
|
|
6
6
|
const r = t.constructor && t.constructor.prototype;
|
|
7
|
-
return
|
|
8
|
-
},
|
|
7
|
+
return W(r) && r.hasOwnProperty("isPrototypeOf");
|
|
8
|
+
}, Je = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
9
9
|
function M(t) {
|
|
10
10
|
if (t instanceof Date)
|
|
11
11
|
return new Date(t);
|
|
12
12
|
const r = typeof FileList < "u" && t instanceof FileList;
|
|
13
|
-
if (
|
|
13
|
+
if (Je && (t instanceof Blob || r))
|
|
14
14
|
return t;
|
|
15
15
|
const e = Array.isArray(t);
|
|
16
|
-
if (!e && !(
|
|
16
|
+
if (!e && !(W(t) && er(t)))
|
|
17
17
|
return t;
|
|
18
18
|
const s = e ? [] : Object.create(Object.getPrototypeOf(t));
|
|
19
|
-
for (const
|
|
20
|
-
Object.prototype.hasOwnProperty.call(t,
|
|
19
|
+
for (const o in t)
|
|
20
|
+
Object.prototype.hasOwnProperty.call(t, o) && (s[o] = M(t[o]));
|
|
21
21
|
return s;
|
|
22
22
|
}
|
|
23
|
-
var Ee = (t) => /^\w*$/.test(t),
|
|
24
|
-
if (!r || !
|
|
23
|
+
var Ee = (t) => /^\w*$/.test(t), U = (t) => t === void 0, we = (t) => Array.isArray(t) ? t.filter(Boolean) : [], Ke = (t) => we(t.replace(/["|']|\]/g, "").split(/\.|\[/)), m = (t, r, e) => {
|
|
24
|
+
if (!r || !W(t))
|
|
25
25
|
return e;
|
|
26
|
-
const s = (Ee(r) ? [r] :
|
|
27
|
-
return
|
|
28
|
-
},
|
|
26
|
+
const s = (Ee(r) ? [r] : Ke(r)).reduce((o, i) => J(o) ? o : o[i], t);
|
|
27
|
+
return U(s) || s === t ? U(t[r]) ? e : t[r] : s;
|
|
28
|
+
}, X = (t) => typeof t == "boolean", z = (t) => typeof t == "function", T = (t, r, e) => {
|
|
29
29
|
let s = -1;
|
|
30
|
-
const
|
|
30
|
+
const o = Ee(r) ? [r] : Ke(r), i = o.length, c = i - 1;
|
|
31
31
|
for (; ++s < i; ) {
|
|
32
|
-
const l =
|
|
33
|
-
let
|
|
32
|
+
const l = o[s];
|
|
33
|
+
let v = e;
|
|
34
34
|
if (s !== c) {
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const b = t[l];
|
|
36
|
+
v = W(b) || Array.isArray(b) ? b : isNaN(+o[s + 1]) ? {} : [];
|
|
37
37
|
}
|
|
38
38
|
if (l === "__proto__" || l === "constructor" || l === "prototype")
|
|
39
39
|
return;
|
|
40
|
-
t[l] =
|
|
40
|
+
t[l] = v, t = t[l];
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
const pe = {
|
|
@@ -50,7 +50,7 @@ const pe = {
|
|
|
50
50
|
onSubmit: "onSubmit",
|
|
51
51
|
onTouched: "onTouched",
|
|
52
52
|
all: "all"
|
|
53
|
-
},
|
|
53
|
+
}, ie = {
|
|
54
54
|
max: "max",
|
|
55
55
|
min: "min",
|
|
56
56
|
maxLength: "maxLength",
|
|
@@ -58,28 +58,28 @@ const pe = {
|
|
|
58
58
|
pattern: "pattern",
|
|
59
59
|
required: "required",
|
|
60
60
|
validate: "validate"
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
const
|
|
61
|
+
}, Ye = V.createContext(null);
|
|
62
|
+
Ye.displayName = "HookFormContext";
|
|
63
|
+
const Fe = () => V.useContext(Ye), tr = (t) => {
|
|
64
64
|
const { children: r, ...e } = t;
|
|
65
|
-
return
|
|
65
|
+
return V.createElement(Ye.Provider, { value: e }, r);
|
|
66
66
|
};
|
|
67
67
|
var Et = (t, r, e, s = !0) => {
|
|
68
|
-
const
|
|
68
|
+
const o = {
|
|
69
69
|
defaultValues: r._defaultValues
|
|
70
70
|
};
|
|
71
71
|
for (const i in t)
|
|
72
|
-
Object.defineProperty(
|
|
72
|
+
Object.defineProperty(o, i, {
|
|
73
73
|
get: () => {
|
|
74
74
|
const c = i;
|
|
75
75
|
return r._proxyFormState[c] !== re.all && (r._proxyFormState[c] = !s || re.all), e && (e[c] = !0), t[c];
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
|
-
return
|
|
78
|
+
return o;
|
|
79
79
|
};
|
|
80
|
-
const
|
|
80
|
+
const Ce = typeof window < "u" ? V.useLayoutEffect : V.useEffect;
|
|
81
81
|
function rr(t) {
|
|
82
|
-
const r =
|
|
82
|
+
const r = Fe(), { control: e = r.control, disabled: s, name: o, exact: i } = t || {}, [c, l] = V.useState(e._formState), v = V.useRef({
|
|
83
83
|
isDirty: !1,
|
|
84
84
|
isLoading: !1,
|
|
85
85
|
dirtyFields: !1,
|
|
@@ -89,194 +89,194 @@ function rr(t) {
|
|
|
89
89
|
isValid: !1,
|
|
90
90
|
errors: !1
|
|
91
91
|
});
|
|
92
|
-
return
|
|
93
|
-
name:
|
|
94
|
-
formState:
|
|
92
|
+
return Ce(() => e._subscribe({
|
|
93
|
+
name: o,
|
|
94
|
+
formState: v.current,
|
|
95
95
|
exact: i,
|
|
96
|
-
callback: (
|
|
96
|
+
callback: (b) => {
|
|
97
97
|
!s && l({
|
|
98
98
|
...e._formState,
|
|
99
|
-
...
|
|
99
|
+
...b
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
}), [
|
|
103
|
-
|
|
104
|
-
}, [e]),
|
|
102
|
+
}), [o, s, i]), V.useEffect(() => {
|
|
103
|
+
v.current.isValid && e._setValid(!0);
|
|
104
|
+
}, [e]), V.useMemo(() => Et(c, e, v.current, !1), [c, e]);
|
|
105
105
|
}
|
|
106
|
-
var
|
|
106
|
+
var Z = (t) => typeof t == "string", qe = (t, r, e, s, o) => Z(t) ? (s && r.watch.add(t), m(e, t, o)) : Array.isArray(t) ? t.map((i) => (s && r.watch.add(i), m(e, i))) : (s && (r.watchAll = !0), e), je = (t) => J(t) || !pt(t);
|
|
107
107
|
function ae(t, r, e = /* @__PURE__ */ new WeakSet()) {
|
|
108
108
|
if (je(t) || je(r))
|
|
109
109
|
return Object.is(t, r);
|
|
110
|
-
if (
|
|
110
|
+
if (le(t) && le(r))
|
|
111
111
|
return t.getTime() === r.getTime();
|
|
112
|
-
const s = Object.keys(t),
|
|
113
|
-
if (s.length !==
|
|
112
|
+
const s = Object.keys(t), o = Object.keys(r);
|
|
113
|
+
if (s.length !== o.length)
|
|
114
114
|
return !1;
|
|
115
115
|
if (e.has(t) || e.has(r))
|
|
116
116
|
return !0;
|
|
117
117
|
e.add(t), e.add(r);
|
|
118
118
|
for (const i of s) {
|
|
119
119
|
const c = t[i];
|
|
120
|
-
if (!
|
|
120
|
+
if (!o.includes(i))
|
|
121
121
|
return !1;
|
|
122
122
|
if (i !== "ref") {
|
|
123
123
|
const l = r[i];
|
|
124
|
-
if (
|
|
124
|
+
if (le(c) && le(l) || W(c) && W(l) || Array.isArray(c) && Array.isArray(l) ? !ae(c, l, e) : !Object.is(c, l))
|
|
125
125
|
return !1;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
return !0;
|
|
129
129
|
}
|
|
130
130
|
function Xe(t) {
|
|
131
|
-
const r =
|
|
132
|
-
|
|
133
|
-
const [p, I] =
|
|
134
|
-
const f = e._getWatch(s,
|
|
135
|
-
return
|
|
136
|
-
}), R =
|
|
137
|
-
const d = qe(s, e._names, f || e._formValues, !1,
|
|
138
|
-
return
|
|
139
|
-
}, [e._formValues, e._names, s]),
|
|
131
|
+
const r = Fe(), { control: e = r.control, name: s, defaultValue: o, disabled: i, exact: c, compute: l } = t || {}, v = V.useRef(o), b = V.useRef(l), w = V.useRef(void 0), g = V.useRef(e), S = V.useRef(s);
|
|
132
|
+
b.current = l;
|
|
133
|
+
const [p, I] = V.useState(() => {
|
|
134
|
+
const f = e._getWatch(s, v.current);
|
|
135
|
+
return b.current ? b.current(f) : f;
|
|
136
|
+
}), R = V.useCallback((f) => {
|
|
137
|
+
const d = qe(s, e._names, f || e._formValues, !1, v.current);
|
|
138
|
+
return b.current ? b.current(d) : d;
|
|
139
|
+
}, [e._formValues, e._names, s]), O = V.useCallback((f) => {
|
|
140
140
|
if (!i) {
|
|
141
|
-
const d = qe(s, e._names, f || e._formValues, !1,
|
|
142
|
-
if (
|
|
143
|
-
const A =
|
|
144
|
-
ae(A,
|
|
141
|
+
const d = qe(s, e._names, f || e._formValues, !1, v.current);
|
|
142
|
+
if (b.current) {
|
|
143
|
+
const A = b.current(d);
|
|
144
|
+
ae(A, w.current) || (I(A), w.current = A);
|
|
145
145
|
} else
|
|
146
146
|
I(d);
|
|
147
147
|
}
|
|
148
148
|
}, [e._formValues, e._names, i, s]);
|
|
149
|
-
|
|
149
|
+
Ce(() => ((g.current !== e || !ae(S.current, s)) && (g.current = e, S.current = s, O()), e._subscribe({
|
|
150
150
|
name: s,
|
|
151
151
|
formState: {
|
|
152
152
|
values: !0
|
|
153
153
|
},
|
|
154
154
|
exact: c,
|
|
155
155
|
callback: (f) => {
|
|
156
|
-
|
|
156
|
+
O(f.values);
|
|
157
157
|
}
|
|
158
|
-
})), [e, c, s,
|
|
159
|
-
const
|
|
158
|
+
})), [e, c, s, O]), V.useEffect(() => e._removeUnmounted());
|
|
159
|
+
const N = g.current !== e, x = S.current, B = V.useMemo(() => {
|
|
160
160
|
if (i)
|
|
161
161
|
return null;
|
|
162
|
-
const f = !
|
|
163
|
-
return
|
|
164
|
-
}, [i,
|
|
162
|
+
const f = !N && !ae(x, s);
|
|
163
|
+
return N || f ? R() : null;
|
|
164
|
+
}, [i, N, s, x, R]);
|
|
165
165
|
return B !== null ? B : p;
|
|
166
166
|
}
|
|
167
167
|
function sr(t) {
|
|
168
|
-
const r =
|
|
169
|
-
control:
|
|
168
|
+
const r = Fe(), { name: e, disabled: s, control: o = r.control, shouldUnregister: i, defaultValue: c, exact: l = !0 } = t, v = St(o._names.array, e), b = V.useMemo(() => m(o._formValues, e, m(o._defaultValues, e, c)), [o, e, c]), w = Xe({
|
|
169
|
+
control: o,
|
|
170
170
|
name: e,
|
|
171
|
-
defaultValue:
|
|
171
|
+
defaultValue: b,
|
|
172
172
|
exact: l
|
|
173
|
-
}),
|
|
174
|
-
control:
|
|
173
|
+
}), g = rr({
|
|
174
|
+
control: o,
|
|
175
175
|
name: e,
|
|
176
176
|
exact: l
|
|
177
|
-
}), S =
|
|
177
|
+
}), S = V.useRef(t), p = V.useRef(void 0), I = V.useRef(o.register(e, {
|
|
178
178
|
...t.rules,
|
|
179
|
-
value:
|
|
180
|
-
...
|
|
179
|
+
value: w,
|
|
180
|
+
...X(t.disabled) ? { disabled: t.disabled } : {}
|
|
181
181
|
}));
|
|
182
182
|
S.current = t;
|
|
183
|
-
const R =
|
|
183
|
+
const R = V.useMemo(() => Object.defineProperties({}, {
|
|
184
184
|
invalid: {
|
|
185
185
|
enumerable: !0,
|
|
186
|
-
get: () => !!m(
|
|
186
|
+
get: () => !!m(g.errors, e)
|
|
187
187
|
},
|
|
188
188
|
isDirty: {
|
|
189
189
|
enumerable: !0,
|
|
190
|
-
get: () => !!m(
|
|
190
|
+
get: () => !!m(g.dirtyFields, e)
|
|
191
191
|
},
|
|
192
192
|
isTouched: {
|
|
193
193
|
enumerable: !0,
|
|
194
|
-
get: () => !!m(
|
|
194
|
+
get: () => !!m(g.touchedFields, e)
|
|
195
195
|
},
|
|
196
196
|
isValidating: {
|
|
197
197
|
enumerable: !0,
|
|
198
|
-
get: () => !!m(
|
|
198
|
+
get: () => !!m(g.validatingFields, e)
|
|
199
199
|
},
|
|
200
200
|
error: {
|
|
201
201
|
enumerable: !0,
|
|
202
|
-
get: () => m(
|
|
202
|
+
get: () => m(g.errors, e)
|
|
203
203
|
}
|
|
204
|
-
}), [
|
|
204
|
+
}), [g, e]), O = V.useCallback((f) => I.current.onChange({
|
|
205
205
|
target: {
|
|
206
206
|
value: xt(f),
|
|
207
207
|
name: e
|
|
208
208
|
},
|
|
209
209
|
type: pe.CHANGE
|
|
210
|
-
}), [e]),
|
|
210
|
+
}), [e]), N = V.useCallback(() => I.current.onBlur({
|
|
211
211
|
target: {
|
|
212
|
-
value: m(
|
|
212
|
+
value: m(o._formValues, e),
|
|
213
213
|
name: e
|
|
214
214
|
},
|
|
215
215
|
type: pe.BLUR
|
|
216
|
-
}), [e,
|
|
217
|
-
const d = m(
|
|
216
|
+
}), [e, o._formValues]), x = V.useCallback((f) => {
|
|
217
|
+
const d = m(o._fields, e);
|
|
218
218
|
d && d._f && f && (d._f.ref = {
|
|
219
|
-
focus: () =>
|
|
220
|
-
select: () =>
|
|
221
|
-
setCustomValidity: (A) =>
|
|
222
|
-
reportValidity: () =>
|
|
219
|
+
focus: () => z(f.focus) && f.focus(),
|
|
220
|
+
select: () => z(f.select) && f.select(),
|
|
221
|
+
setCustomValidity: (A) => z(f.setCustomValidity) && f.setCustomValidity(A),
|
|
222
|
+
reportValidity: () => z(f.reportValidity) && f.reportValidity()
|
|
223
223
|
});
|
|
224
|
-
}, [
|
|
224
|
+
}, [o._fields, e]), B = V.useMemo(() => ({
|
|
225
225
|
name: e,
|
|
226
|
-
value:
|
|
227
|
-
...
|
|
228
|
-
onChange:
|
|
229
|
-
onBlur:
|
|
226
|
+
value: w,
|
|
227
|
+
...X(s) || g.disabled ? { disabled: g.disabled || s } : {},
|
|
228
|
+
onChange: O,
|
|
229
|
+
onBlur: N,
|
|
230
230
|
ref: x
|
|
231
|
-
}), [e, s,
|
|
232
|
-
return
|
|
233
|
-
const f =
|
|
234
|
-
d && d !== e && !
|
|
231
|
+
}), [e, s, g.disabled, O, N, x, w]);
|
|
232
|
+
return V.useEffect(() => {
|
|
233
|
+
const f = o._options.shouldUnregister || i, d = p.current;
|
|
234
|
+
d && d !== e && !v && o.unregister(d), o.register(e, {
|
|
235
235
|
...S.current.rules,
|
|
236
|
-
...
|
|
236
|
+
...X(S.current.disabled) ? { disabled: S.current.disabled } : {}
|
|
237
237
|
});
|
|
238
|
-
const A = (
|
|
239
|
-
const
|
|
240
|
-
|
|
238
|
+
const A = (C, $) => {
|
|
239
|
+
const q = m(o._fields, C);
|
|
240
|
+
q && q._f && (q._f.mount = $);
|
|
241
241
|
};
|
|
242
242
|
if (A(e, !0), f) {
|
|
243
|
-
const
|
|
244
|
-
|
|
243
|
+
const C = M(m(o._options.defaultValues, e, S.current.defaultValue));
|
|
244
|
+
T(o._defaultValues, e, C), U(m(o._formValues, e)) && T(o._formValues, e, C);
|
|
245
245
|
}
|
|
246
|
-
return !
|
|
247
|
-
(
|
|
246
|
+
return !v && o.register(e), p.current = e, () => {
|
|
247
|
+
(v ? f && !o._state.action : f) ? o.unregister(e) : A(e, !1);
|
|
248
248
|
};
|
|
249
|
-
}, [e,
|
|
250
|
-
|
|
249
|
+
}, [e, o, v, i]), V.useEffect(() => {
|
|
250
|
+
o._setDisabledField({
|
|
251
251
|
disabled: s,
|
|
252
252
|
name: e
|
|
253
253
|
});
|
|
254
|
-
}, [s, e,
|
|
254
|
+
}, [s, e, o]), V.useMemo(() => ({
|
|
255
255
|
field: B,
|
|
256
|
-
formState:
|
|
256
|
+
formState: g,
|
|
257
257
|
fieldState: R
|
|
258
|
-
}), [B,
|
|
258
|
+
}), [B, g, R]);
|
|
259
259
|
}
|
|
260
260
|
const ar = (t) => t.render(sr(t));
|
|
261
|
-
var nr = (t, r, e, s,
|
|
261
|
+
var nr = (t, r, e, s, o) => r ? {
|
|
262
262
|
...e[t],
|
|
263
263
|
types: {
|
|
264
264
|
...e[t] && e[t].types ? e[t].types : {},
|
|
265
|
-
[s]:
|
|
265
|
+
[s]: o || !0
|
|
266
266
|
}
|
|
267
|
-
} : {},
|
|
267
|
+
} : {}, K = (t) => Array.isArray(t) ? t : [t], yt = () => {
|
|
268
268
|
let t = [];
|
|
269
269
|
return {
|
|
270
270
|
get observers() {
|
|
271
271
|
return t;
|
|
272
272
|
},
|
|
273
|
-
next: (
|
|
273
|
+
next: (o) => {
|
|
274
274
|
for (const i of t)
|
|
275
|
-
i.next && i.next(
|
|
275
|
+
i.next && i.next(o);
|
|
276
276
|
},
|
|
277
|
-
subscribe: (
|
|
277
|
+
subscribe: (o) => (t.push(o), {
|
|
278
278
|
unsubscribe: () => {
|
|
279
|
-
t = t.filter((i) => i !==
|
|
279
|
+
t = t.filter((i) => i !== o);
|
|
280
280
|
}
|
|
281
281
|
}),
|
|
282
282
|
unsubscribe: () => {
|
|
@@ -288,62 +288,62 @@ function wt(t, r) {
|
|
|
288
288
|
const e = {};
|
|
289
289
|
for (const s in t)
|
|
290
290
|
if (t.hasOwnProperty(s)) {
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
293
|
-
const c = wt(
|
|
294
|
-
|
|
291
|
+
const o = t[s], i = r[s];
|
|
292
|
+
if (o && W(o) && i) {
|
|
293
|
+
const c = wt(o, i);
|
|
294
|
+
W(c) && (e[s] = c);
|
|
295
295
|
} else t[s] && (e[s] = i);
|
|
296
296
|
}
|
|
297
297
|
return e;
|
|
298
298
|
}
|
|
299
|
-
var
|
|
300
|
-
if (!
|
|
299
|
+
var Q = (t) => W(t) && !Object.keys(t).length, Ze = (t) => t.type === "file", xe = (t) => {
|
|
300
|
+
if (!Je)
|
|
301
301
|
return !1;
|
|
302
302
|
const r = t ? t.ownerDocument : 0;
|
|
303
303
|
return t instanceof (r && r.defaultView ? r.defaultView.HTMLElement : HTMLElement);
|
|
304
|
-
},
|
|
305
|
-
function
|
|
304
|
+
}, Ct = (t) => t.type === "select-multiple", et = (t) => t.type === "radio", ir = (t) => et(t) || Ve(t), Le = (t) => xe(t) && t.isConnected;
|
|
305
|
+
function or(t, r) {
|
|
306
306
|
const e = r.slice(0, -1).length;
|
|
307
307
|
let s = 0;
|
|
308
308
|
for (; s < e; )
|
|
309
|
-
t =
|
|
309
|
+
t = U(t) ? s++ : t[r[s++]];
|
|
310
310
|
return t;
|
|
311
311
|
}
|
|
312
|
-
function
|
|
312
|
+
function ur(t) {
|
|
313
313
|
for (const r in t)
|
|
314
|
-
if (t.hasOwnProperty(r) && !
|
|
314
|
+
if (t.hasOwnProperty(r) && !U(t[r]))
|
|
315
315
|
return !1;
|
|
316
316
|
return !0;
|
|
317
317
|
}
|
|
318
318
|
function P(t, r) {
|
|
319
|
-
const e = Array.isArray(r) ? r : Ee(r) ? [r] :
|
|
320
|
-
return s && delete s[i],
|
|
319
|
+
const e = Array.isArray(r) ? r : Ee(r) ? [r] : Ke(r), s = e.length === 1 ? t : or(t, e), o = e.length - 1, i = e[o];
|
|
320
|
+
return s && delete s[i], o !== 0 && (W(s) && Q(s) || Array.isArray(s) && ur(s)) && P(t, e.slice(0, -1)), t;
|
|
321
321
|
}
|
|
322
322
|
var lr = (t) => {
|
|
323
323
|
for (const r in t)
|
|
324
|
-
if (
|
|
324
|
+
if (z(t[r]))
|
|
325
325
|
return !0;
|
|
326
326
|
return !1;
|
|
327
327
|
};
|
|
328
|
-
function
|
|
329
|
-
return Array.isArray(t) ||
|
|
328
|
+
function kt(t) {
|
|
329
|
+
return Array.isArray(t) || W(t) && !lr(t);
|
|
330
330
|
}
|
|
331
331
|
function Ge(t, r = {}) {
|
|
332
332
|
for (const e in t) {
|
|
333
333
|
const s = t[e];
|
|
334
|
-
|
|
334
|
+
kt(s) ? (r[e] = Array.isArray(s) ? [] : {}, Ge(s, r[e])) : U(s) || (r[e] = !0);
|
|
335
335
|
}
|
|
336
336
|
return r;
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function de(t, r, e) {
|
|
339
339
|
e || (e = Ge(r));
|
|
340
340
|
for (const s in t) {
|
|
341
|
-
const
|
|
342
|
-
if (
|
|
343
|
-
|
|
341
|
+
const o = t[s];
|
|
342
|
+
if (kt(o))
|
|
343
|
+
U(r) || je(e[s]) ? e[s] = Ge(o, Array.isArray(o) ? [] : {}) : de(o, J(r) ? {} : r[s], e[s]);
|
|
344
344
|
else {
|
|
345
345
|
const i = r[s];
|
|
346
|
-
e[s] = !ae(
|
|
346
|
+
e[s] = !ae(o, i);
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
return e;
|
|
@@ -360,36 +360,36 @@ var Dt = (t) => {
|
|
|
360
360
|
}
|
|
361
361
|
return t[0].checked && !t[0].disabled ? (
|
|
362
362
|
// @ts-expect-error expected to work in the browser
|
|
363
|
-
t[0].attributes && !
|
|
363
|
+
t[0].attributes && !U(t[0].attributes.value) ? U(t[0].value) || t[0].value === "" ? _t : { value: t[0].value, isValid: !0 } : _t
|
|
364
364
|
) : mt;
|
|
365
365
|
}
|
|
366
366
|
return mt;
|
|
367
|
-
},
|
|
367
|
+
}, Ot = (t, { valueAsNumber: r, valueAsDate: e, setValueAs: s }) => U(t) ? t : r ? t === "" ? NaN : t && +t : e && Z(t) ? new Date(t) : s ? s(t) : t;
|
|
368
368
|
const gt = {
|
|
369
369
|
isValid: !1,
|
|
370
370
|
value: null
|
|
371
371
|
};
|
|
372
|
-
var
|
|
372
|
+
var Tt = (t) => Array.isArray(t) ? t.reduce((r, e) => e && e.checked && !e.disabled ? {
|
|
373
373
|
isValid: !0,
|
|
374
374
|
value: e.value
|
|
375
375
|
} : r, gt) : gt;
|
|
376
376
|
function ht(t) {
|
|
377
377
|
const r = t.ref;
|
|
378
|
-
return Ze(r) ? r.files : et(r) ?
|
|
378
|
+
return Ze(r) ? r.files : et(r) ? Tt(t.refs).value : Ct(r) ? [...r.selectedOptions].map(({ value: e }) => e) : Ve(r) ? Dt(t.refs).value : Ot(U(r.value) ? t.ref.value : r.value, t);
|
|
379
379
|
}
|
|
380
380
|
var cr = (t, r, e, s) => {
|
|
381
|
-
const
|
|
381
|
+
const o = {};
|
|
382
382
|
for (const i of t) {
|
|
383
383
|
const c = m(r, i);
|
|
384
|
-
c &&
|
|
384
|
+
c && T(o, i, c._f);
|
|
385
385
|
}
|
|
386
386
|
return {
|
|
387
387
|
criteriaMode: e,
|
|
388
388
|
names: [...t],
|
|
389
|
-
fields:
|
|
389
|
+
fields: o,
|
|
390
390
|
shouldUseNativeValidation: s
|
|
391
391
|
};
|
|
392
|
-
}, Se = (t) => t instanceof RegExp,
|
|
392
|
+
}, Se = (t) => t instanceof RegExp, ve = (t) => U(t) ? t : Se(t) ? t.source : W(t) ? Se(t.value) ? t.value.source : t.value : t, fe = (t) => ({
|
|
393
393
|
isOnSubmit: !t || t === re.onSubmit,
|
|
394
394
|
isOnBlur: t === re.onBlur,
|
|
395
395
|
isOnChange: t === re.onChange,
|
|
@@ -397,20 +397,20 @@ var cr = (t, r, e, s) => {
|
|
|
397
397
|
isOnTouch: t === re.onTouched
|
|
398
398
|
});
|
|
399
399
|
const vt = "AsyncFunction";
|
|
400
|
-
var dr = (t) => !!t && !!t.validate && !!(
|
|
401
|
-
const
|
|
402
|
-
for (const
|
|
403
|
-
const i = m(t,
|
|
400
|
+
var dr = (t) => !!t && !!t.validate && !!(z(t.validate) && t.validate.constructor.name === vt || W(t.validate) && Object.values(t.validate).find((r) => r.constructor.name === vt)), fr = (t) => t.mount && (t.required || t.min || t.max || t.maxLength || t.minLength || t.pattern || t.validate), Qe = (t, r, e) => !e && (r.watchAll || r.watch.has(t) || [...r.watch].some((s) => t.startsWith(s) && /^\.\w+/.test(t.slice(s.length))));
|
|
401
|
+
const ye = (t, r, e, s) => {
|
|
402
|
+
for (const o of e || Object.keys(t)) {
|
|
403
|
+
const i = m(t, o);
|
|
404
404
|
if (i) {
|
|
405
405
|
const { _f: c, ...l } = i;
|
|
406
406
|
if (c) {
|
|
407
|
-
if (c.refs && c.refs[0] && r(c.refs[0],
|
|
407
|
+
if (c.refs && c.refs[0] && r(c.refs[0], o) && !s)
|
|
408
408
|
return !0;
|
|
409
409
|
if (c.ref && r(c.ref, c.name) && !s)
|
|
410
410
|
return !0;
|
|
411
|
-
if (
|
|
411
|
+
if (ye(l, r))
|
|
412
412
|
break;
|
|
413
|
-
} else if (
|
|
413
|
+
} else if (W(l) && ye(l, r))
|
|
414
414
|
break;
|
|
415
415
|
}
|
|
416
416
|
}
|
|
@@ -422,9 +422,9 @@ function Vt(t, r, e) {
|
|
|
422
422
|
error: s,
|
|
423
423
|
name: e
|
|
424
424
|
};
|
|
425
|
-
const
|
|
426
|
-
for (;
|
|
427
|
-
const i =
|
|
425
|
+
const o = e.split(".");
|
|
426
|
+
for (; o.length; ) {
|
|
427
|
+
const i = o.join("."), c = m(r, i), l = m(t, i);
|
|
428
428
|
if (c && !Array.isArray(c) && e !== i)
|
|
429
429
|
return { name: e };
|
|
430
430
|
if (l && l.type)
|
|
@@ -437,7 +437,7 @@ function Vt(t, r, e) {
|
|
|
437
437
|
name: `${i}.root`,
|
|
438
438
|
error: l.root
|
|
439
439
|
};
|
|
440
|
-
|
|
440
|
+
o.pop();
|
|
441
441
|
}
|
|
442
442
|
return {
|
|
443
443
|
name: e
|
|
@@ -445,96 +445,96 @@ function Vt(t, r, e) {
|
|
|
445
445
|
}
|
|
446
446
|
var yr = (t, r, e, s) => {
|
|
447
447
|
e(t);
|
|
448
|
-
const { name:
|
|
449
|
-
return
|
|
450
|
-
}, mr = (t, r, e) => !t || !r || t === r ||
|
|
451
|
-
const s =
|
|
452
|
-
return
|
|
448
|
+
const { name: o, ...i } = t;
|
|
449
|
+
return Q(i) || Object.keys(i).length >= Object.keys(r).length || Object.keys(i).find((c) => r[c] === (!s || re.all));
|
|
450
|
+
}, mr = (t, r, e) => !t || !r || t === r || K(t).some((s) => s && (e ? s === r : s.startsWith(r) || r.startsWith(s))), _r = (t, r, e, s, o) => o.isOnAll ? !1 : !e && o.isOnTouch ? !(r || t) : (e ? s.isOnBlur : o.isOnBlur) ? !t : (e ? s.isOnChange : o.isOnChange) ? t : !0, gr = (t, r) => !we(m(t, r)).length && P(t, r), Rt = (t, r, e) => {
|
|
451
|
+
const s = K(m(t, e));
|
|
452
|
+
return T(s, "root", r[e]), T(t, e, s), t;
|
|
453
453
|
};
|
|
454
454
|
function Ft(t, r, e = "validate") {
|
|
455
|
-
if (
|
|
455
|
+
if (Z(t) || Array.isArray(t) && t.every(Z) || X(t) && !t)
|
|
456
456
|
return {
|
|
457
457
|
type: e,
|
|
458
|
-
message:
|
|
458
|
+
message: Z(t) ? t : "",
|
|
459
459
|
ref: r
|
|
460
460
|
};
|
|
461
461
|
}
|
|
462
|
-
var
|
|
462
|
+
var ce = (t) => W(t) && !Se(t) ? t : {
|
|
463
463
|
value: t,
|
|
464
464
|
message: ""
|
|
465
|
-
}, ze = async (t, r, e, s,
|
|
466
|
-
const { ref: c, refs: l, required:
|
|
467
|
-
if (!
|
|
465
|
+
}, ze = async (t, r, e, s, o, i) => {
|
|
466
|
+
const { ref: c, refs: l, required: v, maxLength: b, minLength: w, min: g, max: S, pattern: p, validate: I, name: R, valueAsNumber: O, mount: N } = t._f, x = m(e, R);
|
|
467
|
+
if (!N || r.has(R))
|
|
468
468
|
return {};
|
|
469
469
|
const B = l ? l[0] : c, f = (E) => {
|
|
470
|
-
|
|
471
|
-
}, d = {}, A = et(c),
|
|
472
|
-
const Y = E ?
|
|
470
|
+
o && B.reportValidity && (B.setCustomValidity(X(E) ? "" : E || ""), B.reportValidity());
|
|
471
|
+
}, d = {}, A = et(c), C = Ve(c), $ = A || C, q = (O || Ze(c)) && U(c.value) && U(x) || xe(c) && c.value === "" || x === "" || Array.isArray(x) && !x.length, j = nr.bind(null, R, s, d), ne = (E, k, H, G = ie.maxLength, se = ie.minLength) => {
|
|
472
|
+
const Y = E ? k : H;
|
|
473
473
|
d[R] = {
|
|
474
|
-
type: E ?
|
|
474
|
+
type: E ? G : se,
|
|
475
475
|
message: Y,
|
|
476
476
|
ref: c,
|
|
477
|
-
...
|
|
477
|
+
...j(E ? G : se, Y)
|
|
478
478
|
};
|
|
479
479
|
};
|
|
480
|
-
if (i ? !Array.isArray(x) || !x.length :
|
|
481
|
-
const { value: E, message:
|
|
480
|
+
if (i ? !Array.isArray(x) || !x.length : v && (!$ && (q || J(x)) || X(x) && !x || C && !Dt(l).isValid || A && !Tt(l).isValid)) {
|
|
481
|
+
const { value: E, message: k } = Z(v) ? { value: !!v, message: v } : ce(v);
|
|
482
482
|
if (E && (d[R] = {
|
|
483
|
-
type:
|
|
484
|
-
message:
|
|
483
|
+
type: ie.required,
|
|
484
|
+
message: k,
|
|
485
485
|
ref: B,
|
|
486
|
-
...
|
|
486
|
+
...j(ie.required, k)
|
|
487
487
|
}, !s))
|
|
488
|
-
return f(
|
|
488
|
+
return f(k), d;
|
|
489
489
|
}
|
|
490
|
-
if (!
|
|
491
|
-
let E,
|
|
492
|
-
const
|
|
493
|
-
if (!
|
|
490
|
+
if (!q && (!J(g) || !J(S))) {
|
|
491
|
+
let E, k;
|
|
492
|
+
const H = ce(S), G = ce(g);
|
|
493
|
+
if (!J(x) && !isNaN(x)) {
|
|
494
494
|
const se = c.valueAsNumber || x && +x;
|
|
495
|
-
|
|
495
|
+
J(H.value) || (E = se > H.value), J(G.value) || (k = se < G.value);
|
|
496
496
|
} else {
|
|
497
|
-
const se = c.valueAsDate || new Date(x), Y = (
|
|
498
|
-
|
|
497
|
+
const se = c.valueAsDate || new Date(x), Y = (he) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + he), _e = c.type == "time", ge = c.type == "week";
|
|
498
|
+
Z(H.value) && x && (E = _e ? Y(x) > Y(H.value) : ge ? x > H.value : se > new Date(H.value)), Z(G.value) && x && (k = _e ? Y(x) < Y(G.value) : ge ? x < G.value : se < new Date(G.value));
|
|
499
499
|
}
|
|
500
|
-
if ((E ||
|
|
500
|
+
if ((E || k) && (ne(!!E, H.message, G.message, ie.max, ie.min), !s))
|
|
501
501
|
return f(d[R].message), d;
|
|
502
502
|
}
|
|
503
|
-
if ((
|
|
504
|
-
const E =
|
|
505
|
-
if ((
|
|
503
|
+
if ((b || w) && !q && (Z(x) || i && Array.isArray(x))) {
|
|
504
|
+
const E = ce(b), k = ce(w), H = !J(E.value) && x.length > +E.value, G = !J(k.value) && x.length < +k.value;
|
|
505
|
+
if ((H || G) && (ne(H, E.message, k.message), !s))
|
|
506
506
|
return f(d[R].message), d;
|
|
507
507
|
}
|
|
508
|
-
if (p && !
|
|
509
|
-
const { value: E, message:
|
|
508
|
+
if (p && !q && Z(x)) {
|
|
509
|
+
const { value: E, message: k } = ce(p);
|
|
510
510
|
if (Se(E) && !x.match(E) && (d[R] = {
|
|
511
|
-
type:
|
|
512
|
-
message:
|
|
511
|
+
type: ie.pattern,
|
|
512
|
+
message: k,
|
|
513
513
|
ref: c,
|
|
514
|
-
...
|
|
514
|
+
...j(ie.pattern, k)
|
|
515
515
|
}, !s))
|
|
516
|
-
return f(
|
|
516
|
+
return f(k), d;
|
|
517
517
|
}
|
|
518
518
|
if (I) {
|
|
519
|
-
if (
|
|
520
|
-
const E = await I(x, e),
|
|
521
|
-
if (
|
|
522
|
-
...
|
|
523
|
-
...
|
|
519
|
+
if (z(I)) {
|
|
520
|
+
const E = await I(x, e), k = Ft(E, B);
|
|
521
|
+
if (k && (d[R] = {
|
|
522
|
+
...k,
|
|
523
|
+
...j(ie.validate, k.message)
|
|
524
524
|
}, !s))
|
|
525
|
-
return f(
|
|
526
|
-
} else if (
|
|
525
|
+
return f(k.message), d;
|
|
526
|
+
} else if (W(I)) {
|
|
527
527
|
let E = {};
|
|
528
|
-
for (const
|
|
529
|
-
if (!
|
|
528
|
+
for (const k in I) {
|
|
529
|
+
if (!Q(E) && !s)
|
|
530
530
|
break;
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
...
|
|
535
|
-
}, f(
|
|
531
|
+
const H = Ft(await I[k](x, e), B, k);
|
|
532
|
+
H && (E = {
|
|
533
|
+
...H,
|
|
534
|
+
...j(k, H.message)
|
|
535
|
+
}, f(H.message), s && (d[R] = E));
|
|
536
536
|
}
|
|
537
|
-
if (!
|
|
537
|
+
if (!Q(E) && (d[R] = {
|
|
538
538
|
ref: B,
|
|
539
539
|
...E
|
|
540
540
|
}, !s))
|
|
@@ -556,7 +556,7 @@ function vr(t = {}) {
|
|
|
556
556
|
submitCount: 0,
|
|
557
557
|
isDirty: !1,
|
|
558
558
|
isReady: !1,
|
|
559
|
-
isLoading:
|
|
559
|
+
isLoading: z(r.defaultValues),
|
|
560
560
|
isValidating: !1,
|
|
561
561
|
isSubmitted: !1,
|
|
562
562
|
isSubmitting: !1,
|
|
@@ -567,7 +567,7 @@ function vr(t = {}) {
|
|
|
567
567
|
validatingFields: {},
|
|
568
568
|
errors: r.errors || {},
|
|
569
569
|
disabled: r.disabled || !1
|
|
570
|
-
}, s = {},
|
|
570
|
+
}, s = {}, o = W(r.defaultValues) || W(r.values) ? M(r.defaultValues || r.values) || {} : {}, i = r.shouldUnregister ? {} : M(o), c = {
|
|
571
571
|
action: !1,
|
|
572
572
|
mount: !1,
|
|
573
573
|
watch: !1,
|
|
@@ -578,8 +578,8 @@ function vr(t = {}) {
|
|
|
578
578
|
unMount: /* @__PURE__ */ new Set(),
|
|
579
579
|
array: /* @__PURE__ */ new Set(),
|
|
580
580
|
watch: /* @__PURE__ */ new Set()
|
|
581
|
-
},
|
|
582
|
-
const
|
|
581
|
+
}, v, b = 0;
|
|
582
|
+
const w = {
|
|
583
583
|
isDirty: !1,
|
|
584
584
|
dirtyFields: !1,
|
|
585
585
|
validatingFields: !1,
|
|
@@ -587,46 +587,46 @@ function vr(t = {}) {
|
|
|
587
587
|
isValidating: !1,
|
|
588
588
|
isValid: !1,
|
|
589
589
|
errors: !1
|
|
590
|
-
},
|
|
591
|
-
...
|
|
590
|
+
}, g = {
|
|
591
|
+
...w
|
|
592
592
|
};
|
|
593
593
|
let S = {
|
|
594
|
-
...
|
|
594
|
+
...g
|
|
595
595
|
};
|
|
596
596
|
const p = {
|
|
597
597
|
array: yt(),
|
|
598
598
|
state: yt()
|
|
599
599
|
}, I = r.criteriaMode === re.all, R = (a) => (n) => {
|
|
600
|
-
clearTimeout(
|
|
601
|
-
},
|
|
602
|
-
if (!c.keepIsValid && !r.disabled && (
|
|
600
|
+
clearTimeout(b), b = setTimeout(a, n);
|
|
601
|
+
}, O = async (a) => {
|
|
602
|
+
if (!c.keepIsValid && !r.disabled && (g.isValid || S.isValid || a)) {
|
|
603
603
|
let n;
|
|
604
|
-
r.resolver ? (n =
|
|
604
|
+
r.resolver ? (n = Q((await $()).errors), N()) : n = await j(s, !0), n !== e.isValid && p.state.next({
|
|
605
605
|
isValid: n
|
|
606
606
|
});
|
|
607
607
|
}
|
|
608
|
-
},
|
|
609
|
-
!r.disabled && (
|
|
610
|
-
|
|
608
|
+
}, N = (a, n) => {
|
|
609
|
+
!r.disabled && (g.isValidating || g.validatingFields || S.isValidating || S.validatingFields) && ((a || Array.from(l.mount)).forEach((u) => {
|
|
610
|
+
u && (n ? T(e.validatingFields, u, n) : P(e.validatingFields, u));
|
|
611
611
|
}), p.state.next({
|
|
612
612
|
validatingFields: e.validatingFields,
|
|
613
|
-
isValidating: !
|
|
613
|
+
isValidating: !Q(e.validatingFields)
|
|
614
614
|
}));
|
|
615
|
-
}, x = (a, n = [],
|
|
616
|
-
if (
|
|
615
|
+
}, x = (a, n = [], u, h, _ = !0, y = !0) => {
|
|
616
|
+
if (h && u && !r.disabled) {
|
|
617
617
|
if (c.action = !0, y && Array.isArray(m(s, a))) {
|
|
618
|
-
const
|
|
619
|
-
_ &&
|
|
618
|
+
const F = u(m(s, a), h.argA, h.argB);
|
|
619
|
+
_ && T(s, a, F);
|
|
620
620
|
}
|
|
621
621
|
if (y && Array.isArray(m(e.errors, a))) {
|
|
622
|
-
const
|
|
623
|
-
_ &&
|
|
622
|
+
const F = u(m(e.errors, a), h.argA, h.argB);
|
|
623
|
+
_ && T(e.errors, a, F), gr(e.errors, a);
|
|
624
624
|
}
|
|
625
|
-
if ((
|
|
626
|
-
const
|
|
627
|
-
_ &&
|
|
625
|
+
if ((g.touchedFields || S.touchedFields) && y && Array.isArray(m(e.touchedFields, a))) {
|
|
626
|
+
const F = u(m(e.touchedFields, a), h.argA, h.argB);
|
|
627
|
+
_ && T(e.touchedFields, a, F);
|
|
628
628
|
}
|
|
629
|
-
(
|
|
629
|
+
(g.dirtyFields || S.dirtyFields) && (e.dirtyFields = de(o, i)), p.state.next({
|
|
630
630
|
name: a,
|
|
631
631
|
isDirty: E(a, n),
|
|
632
632
|
dirtyFields: e.dirtyFields,
|
|
@@ -634,9 +634,9 @@ function vr(t = {}) {
|
|
|
634
634
|
isValid: e.isValid
|
|
635
635
|
});
|
|
636
636
|
} else
|
|
637
|
-
|
|
637
|
+
T(i, a, n);
|
|
638
638
|
}, B = (a, n) => {
|
|
639
|
-
|
|
639
|
+
T(e.errors, a, n), p.state.next({
|
|
640
640
|
errors: e.errors
|
|
641
641
|
});
|
|
642
642
|
}, f = (a) => {
|
|
@@ -644,165 +644,165 @@ function vr(t = {}) {
|
|
|
644
644
|
errors: e.errors,
|
|
645
645
|
isValid: !1
|
|
646
646
|
});
|
|
647
|
-
}, d = (a, n,
|
|
647
|
+
}, d = (a, n, u, h) => {
|
|
648
648
|
const _ = m(s, a);
|
|
649
649
|
if (_) {
|
|
650
|
-
const y = m(i, a,
|
|
651
|
-
|
|
650
|
+
const y = m(i, a, U(u) ? m(o, a) : u);
|
|
651
|
+
U(y) || h && h.defaultChecked || n ? T(i, a, n ? y : ht(_._f)) : G(a, y), c.mount && !c.action && O();
|
|
652
652
|
}
|
|
653
|
-
}, A = (a, n,
|
|
654
|
-
let y = !1,
|
|
653
|
+
}, A = (a, n, u, h, _) => {
|
|
654
|
+
let y = !1, F = !1;
|
|
655
655
|
const D = {
|
|
656
656
|
name: a
|
|
657
657
|
};
|
|
658
658
|
if (!r.disabled) {
|
|
659
|
-
if (!
|
|
660
|
-
(
|
|
661
|
-
const L = ae(m(
|
|
662
|
-
|
|
659
|
+
if (!u || h) {
|
|
660
|
+
(g.isDirty || S.isDirty) && (F = e.isDirty, e.isDirty = D.isDirty = E(), y = F !== D.isDirty);
|
|
661
|
+
const L = ae(m(o, a), n);
|
|
662
|
+
F = !!m(e.dirtyFields, a), L ? P(e.dirtyFields, a) : T(e.dirtyFields, a, !0), D.dirtyFields = e.dirtyFields, y = y || (g.dirtyFields || S.dirtyFields) && F !== !L;
|
|
663
663
|
}
|
|
664
|
-
if (
|
|
664
|
+
if (u) {
|
|
665
665
|
const L = m(e.touchedFields, a);
|
|
666
|
-
L || (
|
|
666
|
+
L || (T(e.touchedFields, a, u), D.touchedFields = e.touchedFields, y = y || (g.touchedFields || S.touchedFields) && L !== u);
|
|
667
667
|
}
|
|
668
668
|
y && _ && p.state.next(D);
|
|
669
669
|
}
|
|
670
670
|
return y ? D : {};
|
|
671
|
-
},
|
|
672
|
-
const _ = m(e.errors, a), y = (
|
|
673
|
-
if (r.delayError &&
|
|
674
|
-
const
|
|
675
|
-
...
|
|
676
|
-
...y &&
|
|
671
|
+
}, C = (a, n, u, h) => {
|
|
672
|
+
const _ = m(e.errors, a), y = (g.isValid || S.isValid) && X(n) && e.isValid !== n;
|
|
673
|
+
if (r.delayError && u ? (v = R(() => B(a, u)), v(r.delayError)) : (clearTimeout(b), v = null, u ? T(e.errors, a, u) : P(e.errors, a)), (u ? !ae(_, u) : _) || !Q(h) || y) {
|
|
674
|
+
const F = {
|
|
675
|
+
...h,
|
|
676
|
+
...y && X(n) ? { isValid: n } : {},
|
|
677
677
|
errors: e.errors,
|
|
678
678
|
name: a
|
|
679
679
|
};
|
|
680
680
|
e = {
|
|
681
681
|
...e,
|
|
682
|
-
...
|
|
683
|
-
}, p.state.next(
|
|
682
|
+
...F
|
|
683
|
+
}, p.state.next(F);
|
|
684
684
|
}
|
|
685
|
-
},
|
|
686
|
-
const { errors: n } = await
|
|
687
|
-
if (
|
|
688
|
-
for (const
|
|
689
|
-
const
|
|
690
|
-
|
|
685
|
+
}, $ = async (a) => (N(a, !0), await r.resolver(i, r.context, cr(a || l.mount, s, r.criteriaMode, r.shouldUseNativeValidation))), q = async (a) => {
|
|
686
|
+
const { errors: n } = await $(a);
|
|
687
|
+
if (N(a), a)
|
|
688
|
+
for (const u of a) {
|
|
689
|
+
const h = m(n, u);
|
|
690
|
+
h ? T(e.errors, u, h) : P(e.errors, u);
|
|
691
691
|
}
|
|
692
692
|
else
|
|
693
693
|
e.errors = n;
|
|
694
694
|
return n;
|
|
695
|
-
},
|
|
695
|
+
}, j = async (a, n, u = {
|
|
696
696
|
valid: !0
|
|
697
697
|
}) => {
|
|
698
|
-
for (const
|
|
699
|
-
const _ = a[
|
|
698
|
+
for (const h in a) {
|
|
699
|
+
const _ = a[h];
|
|
700
700
|
if (_) {
|
|
701
|
-
const { _f: y, ...
|
|
701
|
+
const { _f: y, ...F } = _;
|
|
702
702
|
if (y) {
|
|
703
703
|
const D = l.array.has(y.name), L = _._f && dr(_._f);
|
|
704
|
-
L &&
|
|
704
|
+
L && g.validatingFields && N([y.name], !0);
|
|
705
705
|
const ee = await ze(_, l.disabled, i, I, r.shouldUseNativeValidation && !n, D);
|
|
706
|
-
if (L &&
|
|
706
|
+
if (L && g.validatingFields && N([y.name]), ee[y.name] && (u.valid = !1, n))
|
|
707
707
|
break;
|
|
708
|
-
!n && (m(ee, y.name) ? D ? Rt(e.errors, ee, y.name) :
|
|
708
|
+
!n && (m(ee, y.name) ? D ? Rt(e.errors, ee, y.name) : T(e.errors, y.name, ee[y.name]) : P(e.errors, y.name));
|
|
709
709
|
}
|
|
710
|
-
!
|
|
710
|
+
!Q(F) && await j(F, n, u);
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
|
-
return
|
|
714
|
-
},
|
|
713
|
+
return u.valid;
|
|
714
|
+
}, ne = () => {
|
|
715
715
|
for (const a of l.unMount) {
|
|
716
716
|
const n = m(s, a);
|
|
717
|
-
n && (n._f.refs ? n._f.refs.every((
|
|
717
|
+
n && (n._f.refs ? n._f.refs.every((u) => !Le(u)) : !Le(n._f.ref)) && ke(a);
|
|
718
718
|
}
|
|
719
719
|
l.unMount = /* @__PURE__ */ new Set();
|
|
720
|
-
}, E = (a, n) => !r.disabled && (a && n &&
|
|
721
|
-
...c.mount ? i :
|
|
722
|
-
},
|
|
723
|
-
const
|
|
720
|
+
}, E = (a, n) => !r.disabled && (a && n && T(i, a, n), !ae(rt(), o)), k = (a, n, u) => qe(a, l, {
|
|
721
|
+
...c.mount ? i : U(n) ? o : Z(a) ? { [a]: n } : n
|
|
722
|
+
}, u, n), H = (a) => we(m(c.mount ? i : o, a, r.shouldUnregister ? m(o, a, []) : [])), G = (a, n, u = {}) => {
|
|
723
|
+
const h = m(s, a);
|
|
724
724
|
let _ = n;
|
|
725
|
-
if (
|
|
726
|
-
const y =
|
|
727
|
-
y && (!y.disabled &&
|
|
728
|
-
(!
|
|
729
|
-
}) : y.refs.forEach((
|
|
725
|
+
if (h) {
|
|
726
|
+
const y = h._f;
|
|
727
|
+
y && (!y.disabled && T(i, a, Ot(n, y)), _ = xe(y.ref) && J(n) ? "" : n, Ct(y.ref) ? [...y.ref.options].forEach((F) => F.selected = _.includes(F.value)) : y.refs ? Ve(y.ref) ? y.refs.forEach((F) => {
|
|
728
|
+
(!F.defaultChecked || !F.disabled) && (Array.isArray(_) ? F.checked = !!_.find((D) => D === F.value) : F.checked = _ === F.value || !!_);
|
|
729
|
+
}) : y.refs.forEach((F) => F.checked = F.value === _) : Ze(y.ref) ? y.ref.value = "" : (y.ref.value = _, y.ref.type || p.state.next({
|
|
730
730
|
name: a,
|
|
731
731
|
values: M(i)
|
|
732
732
|
})));
|
|
733
733
|
}
|
|
734
|
-
(
|
|
735
|
-
}, se = (a, n,
|
|
736
|
-
for (const
|
|
737
|
-
if (!n.hasOwnProperty(
|
|
734
|
+
(u.shouldDirty || u.shouldTouch) && A(a, _, u.shouldTouch, u.shouldDirty, !0), u.shouldValidate && he(a);
|
|
735
|
+
}, se = (a, n, u) => {
|
|
736
|
+
for (const h in n) {
|
|
737
|
+
if (!n.hasOwnProperty(h))
|
|
738
738
|
return;
|
|
739
|
-
const _ = n[
|
|
740
|
-
(l.array.has(a) ||
|
|
739
|
+
const _ = n[h], y = a + "." + h, F = m(s, y);
|
|
740
|
+
(l.array.has(a) || W(_) || F && !F._f) && !le(_) ? se(y, _, u) : G(y, _, u);
|
|
741
741
|
}
|
|
742
|
-
}, Y = (a, n,
|
|
743
|
-
const
|
|
744
|
-
|
|
742
|
+
}, Y = (a, n, u = {}) => {
|
|
743
|
+
const h = m(s, a), _ = l.array.has(a), y = M(n);
|
|
744
|
+
T(i, a, y), _ ? (p.array.next({
|
|
745
745
|
name: a,
|
|
746
746
|
values: M(i)
|
|
747
|
-
}), (
|
|
747
|
+
}), (g.isDirty || g.dirtyFields || S.isDirty || S.dirtyFields) && u.shouldDirty && p.state.next({
|
|
748
748
|
name: a,
|
|
749
|
-
dirtyFields:
|
|
749
|
+
dirtyFields: de(o, i),
|
|
750
750
|
isDirty: E(a, y)
|
|
751
|
-
})) :
|
|
751
|
+
})) : h && !h._f && !J(y) ? se(a, y, u) : G(a, y, u), Qe(a, l) && p.state.next({ ...e, name: a }), p.state.next({
|
|
752
752
|
name: c.mount ? a : void 0,
|
|
753
753
|
values: M(i)
|
|
754
754
|
});
|
|
755
|
-
},
|
|
755
|
+
}, _e = async (a) => {
|
|
756
756
|
c.mount = !0;
|
|
757
757
|
const n = a.target;
|
|
758
|
-
let
|
|
759
|
-
const _ = m(s,
|
|
760
|
-
|
|
761
|
-
},
|
|
758
|
+
let u = n.name, h = !0;
|
|
759
|
+
const _ = m(s, u), y = (L) => {
|
|
760
|
+
h = Number.isNaN(L) || le(L) && isNaN(L.getTime()) || ae(L, m(i, u, L));
|
|
761
|
+
}, F = fe(r.mode), D = fe(r.reValidateMode);
|
|
762
762
|
if (_) {
|
|
763
763
|
let L, ee;
|
|
764
|
-
const be = n.type ? ht(_._f) : xt(a),
|
|
765
|
-
|
|
766
|
-
const Re = A(
|
|
767
|
-
if (!
|
|
768
|
-
name:
|
|
764
|
+
const be = n.type ? ht(_._f) : xt(a), oe = a.type === pe.BLUR || a.type === pe.FOCUS_OUT, qt = !fr(_._f) && !r.resolver && !m(e.errors, u) && !_._f.deps || _r(oe, m(e.touchedFields, u), e.isSubmitted, D, F), Te = Qe(u, l, oe);
|
|
765
|
+
T(i, u, be), oe ? (!n || !n.readOnly) && (_._f.onBlur && _._f.onBlur(a), v && v(0)) : _._f.onChange && _._f.onChange(a);
|
|
766
|
+
const Re = A(u, be, oe), jt = !Q(Re) || Te;
|
|
767
|
+
if (!oe && p.state.next({
|
|
768
|
+
name: u,
|
|
769
769
|
type: a.type,
|
|
770
770
|
values: M(i)
|
|
771
771
|
}), qt)
|
|
772
|
-
return (
|
|
773
|
-
if (!
|
|
774
|
-
const { errors: dt } = await
|
|
775
|
-
if (
|
|
776
|
-
const Gt = Vt(e.errors, s,
|
|
777
|
-
L = ft.error,
|
|
772
|
+
return (g.isValid || S.isValid) && (r.mode === "onBlur" ? oe && O() : oe || O()), jt && p.state.next({ name: u, ...Te ? {} : Re });
|
|
773
|
+
if (!oe && Te && p.state.next({ ...e }), r.resolver) {
|
|
774
|
+
const { errors: dt } = await $([u]);
|
|
775
|
+
if (N([u]), y(be), h) {
|
|
776
|
+
const Gt = Vt(e.errors, s, u), ft = Vt(dt, s, Gt.name || u);
|
|
777
|
+
L = ft.error, u = ft.name, ee = Q(dt);
|
|
778
778
|
}
|
|
779
779
|
} else
|
|
780
|
-
|
|
781
|
-
|
|
780
|
+
N([u], !0), L = (await ze(_, l.disabled, i, I, r.shouldUseNativeValidation))[u], N([u]), y(be), h && (L ? ee = !1 : (g.isValid || S.isValid) && (ee = await j(s, !0)));
|
|
781
|
+
h && (_._f.deps && (!Array.isArray(_._f.deps) || _._f.deps.length > 0) && he(_._f.deps), C(u, ee, L, Re));
|
|
782
782
|
}
|
|
783
|
-
},
|
|
783
|
+
}, ge = (a, n) => {
|
|
784
784
|
if (m(e.errors, n) && a.focus)
|
|
785
785
|
return a.focus(), 1;
|
|
786
|
-
},
|
|
787
|
-
let
|
|
788
|
-
const _ =
|
|
786
|
+
}, he = async (a, n = {}) => {
|
|
787
|
+
let u, h;
|
|
788
|
+
const _ = K(a);
|
|
789
789
|
if (r.resolver) {
|
|
790
|
-
const y = await
|
|
791
|
-
|
|
792
|
-
} else a ? (
|
|
793
|
-
const
|
|
794
|
-
return await
|
|
795
|
-
}))).every(Boolean), !(!
|
|
790
|
+
const y = await q(U(a) ? a : _);
|
|
791
|
+
u = Q(y), h = a ? !_.some((F) => m(y, F)) : u;
|
|
792
|
+
} else a ? (h = (await Promise.all(_.map(async (y) => {
|
|
793
|
+
const F = m(s, y);
|
|
794
|
+
return await j(F && F._f ? { [y]: F } : F);
|
|
795
|
+
}))).every(Boolean), !(!h && !e.isValid) && O()) : h = u = await j(s);
|
|
796
796
|
return p.state.next({
|
|
797
|
-
...!
|
|
798
|
-
...r.resolver || !a ? { isValid:
|
|
797
|
+
...!Z(a) || (g.isValid || S.isValid) && u !== e.isValid ? {} : { name: a },
|
|
798
|
+
...r.resolver || !a ? { isValid: u } : {},
|
|
799
799
|
errors: e.errors
|
|
800
|
-
}), n.shouldFocus && !
|
|
800
|
+
}), n.shouldFocus && !h && ye(s, ge, a ? _ : l.mount), h;
|
|
801
801
|
}, rt = (a, n) => {
|
|
802
|
-
let
|
|
803
|
-
...c.mount ? i :
|
|
802
|
+
let u = {
|
|
803
|
+
...c.mount ? i : o
|
|
804
804
|
};
|
|
805
|
-
return n && (
|
|
805
|
+
return n && (u = wt(n.dirtyFields ? e.dirtyFields : e.touchedFields, u)), U(a) ? u : Z(a) ? m(u, a) : a.map((h) => m(u, h));
|
|
806
806
|
}, st = (a, n) => ({
|
|
807
807
|
invalid: !!m((n || e).errors, a),
|
|
808
808
|
isDirty: !!m((n || e).dirtyFields, a),
|
|
@@ -810,29 +810,29 @@ function vr(t = {}) {
|
|
|
810
810
|
isValidating: !!m(e.validatingFields, a),
|
|
811
811
|
isTouched: !!m((n || e).touchedFields, a)
|
|
812
812
|
}), Mt = (a) => {
|
|
813
|
-
a &&
|
|
813
|
+
a && K(a).forEach((n) => P(e.errors, n)), p.state.next({
|
|
814
814
|
errors: a ? e.errors : {}
|
|
815
815
|
});
|
|
816
|
-
}, at = (a, n,
|
|
817
|
-
const
|
|
818
|
-
|
|
816
|
+
}, at = (a, n, u) => {
|
|
817
|
+
const h = (m(s, a, { _f: {} })._f || {}).ref, _ = m(e.errors, a) || {}, { ref: y, message: F, type: D, ...L } = _;
|
|
818
|
+
T(e.errors, a, {
|
|
819
819
|
...L,
|
|
820
820
|
...n,
|
|
821
|
-
ref:
|
|
821
|
+
ref: h
|
|
822
822
|
}), p.state.next({
|
|
823
823
|
name: a,
|
|
824
824
|
errors: e.errors,
|
|
825
825
|
isValid: !1
|
|
826
|
-
}),
|
|
827
|
-
}, It = (a, n) =>
|
|
828
|
-
next: (
|
|
829
|
-
}) :
|
|
826
|
+
}), u && u.shouldFocus && h && h.focus && h.focus();
|
|
827
|
+
}, It = (a, n) => z(a) ? p.state.subscribe({
|
|
828
|
+
next: (u) => "values" in u && a(k(void 0, n), u)
|
|
829
|
+
}) : k(a, n, !0), nt = (a) => p.state.subscribe({
|
|
830
830
|
next: (n) => {
|
|
831
|
-
mr(a.name, n.name, a.exact) && yr(n, a.formState ||
|
|
831
|
+
mr(a.name, n.name, a.exact) && yr(n, a.formState || g, $t, a.reRenderRoot) && a.callback({
|
|
832
832
|
values: { ...i },
|
|
833
833
|
...e,
|
|
834
834
|
...n,
|
|
835
|
-
defaultValues:
|
|
835
|
+
defaultValues: o
|
|
836
836
|
});
|
|
837
837
|
}
|
|
838
838
|
}).unsubscribe, Bt = (a) => (c.mount = !0, S = {
|
|
@@ -841,126 +841,126 @@ function vr(t = {}) {
|
|
|
841
841
|
}, nt({
|
|
842
842
|
...a,
|
|
843
843
|
formState: {
|
|
844
|
-
...
|
|
844
|
+
...w,
|
|
845
845
|
...a.formState
|
|
846
846
|
}
|
|
847
|
-
})),
|
|
848
|
-
for (const
|
|
849
|
-
l.mount.delete(
|
|
847
|
+
})), ke = (a, n = {}) => {
|
|
848
|
+
for (const u of a ? K(a) : l.mount)
|
|
849
|
+
l.mount.delete(u), l.array.delete(u), n.keepValue || (P(s, u), P(i, u)), !n.keepError && P(e.errors, u), !n.keepDirty && P(e.dirtyFields, u), !n.keepTouched && P(e.touchedFields, u), !n.keepIsValidating && P(e.validatingFields, u), !r.shouldUnregister && !n.keepDefaultValue && P(o, u);
|
|
850
850
|
p.state.next({
|
|
851
851
|
values: M(i)
|
|
852
852
|
}), p.state.next({
|
|
853
853
|
...e,
|
|
854
854
|
...n.keepDirty ? { isDirty: E() } : {}
|
|
855
|
-
}), !n.keepIsValid &&
|
|
855
|
+
}), !n.keepIsValid && O();
|
|
856
856
|
}, it = ({ disabled: a, name: n }) => {
|
|
857
|
-
(
|
|
857
|
+
(X(a) && c.mount || a || l.disabled.has(n)) && (a ? l.disabled.add(n) : l.disabled.delete(n));
|
|
858
858
|
}, De = (a, n = {}) => {
|
|
859
|
-
let
|
|
860
|
-
const
|
|
861
|
-
return
|
|
862
|
-
...
|
|
859
|
+
let u = m(s, a);
|
|
860
|
+
const h = X(n.disabled) || X(r.disabled);
|
|
861
|
+
return T(s, a, {
|
|
862
|
+
...u || {},
|
|
863
863
|
_f: {
|
|
864
|
-
...
|
|
864
|
+
...u && u._f ? u._f : { ref: { name: a } },
|
|
865
865
|
name: a,
|
|
866
866
|
mount: !0,
|
|
867
867
|
...n
|
|
868
868
|
}
|
|
869
|
-
}), l.mount.add(a),
|
|
870
|
-
disabled:
|
|
869
|
+
}), l.mount.add(a), u ? it({
|
|
870
|
+
disabled: X(n.disabled) ? n.disabled : r.disabled,
|
|
871
871
|
name: a
|
|
872
872
|
}) : d(a, !0, n.value), {
|
|
873
|
-
...
|
|
873
|
+
...h ? { disabled: n.disabled || r.disabled } : {},
|
|
874
874
|
...r.progressive ? {
|
|
875
875
|
required: !!n.required,
|
|
876
|
-
min:
|
|
877
|
-
max:
|
|
878
|
-
minLength:
|
|
879
|
-
maxLength:
|
|
880
|
-
pattern:
|
|
876
|
+
min: ve(n.min),
|
|
877
|
+
max: ve(n.max),
|
|
878
|
+
minLength: ve(n.minLength),
|
|
879
|
+
maxLength: ve(n.maxLength),
|
|
880
|
+
pattern: ve(n.pattern)
|
|
881
881
|
} : {},
|
|
882
882
|
name: a,
|
|
883
|
-
onChange:
|
|
884
|
-
onBlur:
|
|
883
|
+
onChange: _e,
|
|
884
|
+
onBlur: _e,
|
|
885
885
|
ref: (_) => {
|
|
886
886
|
if (_) {
|
|
887
|
-
De(a, n),
|
|
888
|
-
const y =
|
|
889
|
-
if (
|
|
887
|
+
De(a, n), u = m(s, a);
|
|
888
|
+
const y = U(_.value) && _.querySelectorAll && _.querySelectorAll("input,select,textarea")[0] || _, F = ir(y), D = u._f.refs || [];
|
|
889
|
+
if (F ? D.find((L) => L === y) : y === u._f.ref)
|
|
890
890
|
return;
|
|
891
|
-
|
|
891
|
+
T(s, a, {
|
|
892
892
|
_f: {
|
|
893
|
-
...
|
|
894
|
-
...
|
|
893
|
+
...u._f,
|
|
894
|
+
...F ? {
|
|
895
895
|
refs: [
|
|
896
|
-
...D.filter(
|
|
896
|
+
...D.filter(Le),
|
|
897
897
|
y,
|
|
898
|
-
...Array.isArray(m(
|
|
898
|
+
...Array.isArray(m(o, a)) ? [{}] : []
|
|
899
899
|
],
|
|
900
900
|
ref: { type: y.type, name: a }
|
|
901
901
|
} : { ref: y }
|
|
902
902
|
}
|
|
903
903
|
}), d(a, !1, void 0, y);
|
|
904
904
|
} else
|
|
905
|
-
|
|
905
|
+
u = m(s, a, {}), u._f && (u._f.mount = !1), (r.shouldUnregister || n.shouldUnregister) && !(St(l.array, a) && c.action) && l.unMount.add(a);
|
|
906
906
|
}
|
|
907
907
|
};
|
|
908
|
-
},
|
|
909
|
-
|
|
910
|
-
const
|
|
911
|
-
|
|
912
|
-
_.disabled =
|
|
908
|
+
}, Oe = () => r.shouldFocusError && ye(s, ge, l.mount), Pt = (a) => {
|
|
909
|
+
X(a) && (p.state.next({ disabled: a }), ye(s, (n, u) => {
|
|
910
|
+
const h = m(s, u);
|
|
911
|
+
h && (n.disabled = h._f.disabled || a, Array.isArray(h._f.refs) && h._f.refs.forEach((_) => {
|
|
912
|
+
_.disabled = h._f.disabled || a;
|
|
913
913
|
}));
|
|
914
914
|
}, 0, !1));
|
|
915
|
-
},
|
|
916
|
-
let
|
|
917
|
-
|
|
915
|
+
}, ot = (a, n) => async (u) => {
|
|
916
|
+
let h;
|
|
917
|
+
u && (u.preventDefault && u.preventDefault(), u.persist && u.persist());
|
|
918
918
|
let _ = M(i);
|
|
919
919
|
if (p.state.next({
|
|
920
920
|
isSubmitting: !0
|
|
921
921
|
}), r.resolver) {
|
|
922
|
-
const { errors: y, values:
|
|
923
|
-
|
|
922
|
+
const { errors: y, values: F } = await $();
|
|
923
|
+
N(), e.errors = y, _ = M(F);
|
|
924
924
|
} else
|
|
925
|
-
await
|
|
925
|
+
await j(s);
|
|
926
926
|
if (l.disabled.size)
|
|
927
927
|
for (const y of l.disabled)
|
|
928
928
|
P(_, y);
|
|
929
|
-
if (P(e.errors, "root"),
|
|
929
|
+
if (P(e.errors, "root"), Q(e.errors)) {
|
|
930
930
|
p.state.next({
|
|
931
931
|
errors: {}
|
|
932
932
|
});
|
|
933
933
|
try {
|
|
934
|
-
await a(_,
|
|
934
|
+
await a(_, u);
|
|
935
935
|
} catch (y) {
|
|
936
|
-
|
|
936
|
+
h = y;
|
|
937
937
|
}
|
|
938
938
|
} else
|
|
939
|
-
n && await n({ ...e.errors },
|
|
939
|
+
n && await n({ ...e.errors }, u), Oe(), setTimeout(Oe);
|
|
940
940
|
if (p.state.next({
|
|
941
941
|
isSubmitted: !0,
|
|
942
942
|
isSubmitting: !1,
|
|
943
|
-
isSubmitSuccessful:
|
|
943
|
+
isSubmitSuccessful: Q(e.errors) && !h,
|
|
944
944
|
submitCount: e.submitCount + 1,
|
|
945
945
|
errors: e.errors
|
|
946
|
-
}),
|
|
947
|
-
throw
|
|
946
|
+
}), h)
|
|
947
|
+
throw h;
|
|
948
948
|
}, Wt = (a, n = {}) => {
|
|
949
|
-
m(s, a) && (
|
|
950
|
-
},
|
|
951
|
-
const
|
|
952
|
-
if (n.keepDefaultValues || (
|
|
949
|
+
m(s, a) && (U(n.defaultValue) ? Y(a, M(m(o, a))) : (Y(a, n.defaultValue), T(o, a, M(n.defaultValue))), n.keepTouched || P(e.touchedFields, a), n.keepDirty || (P(e.dirtyFields, a), e.isDirty = n.defaultValue ? E(a, M(m(o, a))) : E()), n.keepError || (P(e.errors, a), g.isValid && O()), p.state.next({ ...e }));
|
|
950
|
+
}, ut = (a, n = {}) => {
|
|
951
|
+
const u = a ? M(a) : o, h = M(u), _ = Q(a), y = _ ? o : h;
|
|
952
|
+
if (n.keepDefaultValues || (o = u), !n.keepValues) {
|
|
953
953
|
if (n.keepDirtyValues) {
|
|
954
|
-
const
|
|
954
|
+
const F = /* @__PURE__ */ new Set([
|
|
955
955
|
...l.mount,
|
|
956
|
-
...Object.keys(
|
|
956
|
+
...Object.keys(de(o, i))
|
|
957
957
|
]);
|
|
958
|
-
for (const D of Array.from(
|
|
959
|
-
m(e.dirtyFields, D) ?
|
|
958
|
+
for (const D of Array.from(F))
|
|
959
|
+
m(e.dirtyFields, D) ? T(y, D, m(i, D)) : Y(D, m(y, D));
|
|
960
960
|
} else {
|
|
961
|
-
if (
|
|
962
|
-
for (const
|
|
963
|
-
const D = m(s,
|
|
961
|
+
if (Je && U(a))
|
|
962
|
+
for (const F of l.mount) {
|
|
963
|
+
const D = m(s, F);
|
|
964
964
|
if (D && D._f) {
|
|
965
965
|
const L = Array.isArray(D._f.refs) ? D._f.refs[0] : D._f.ref;
|
|
966
966
|
if (xe(L)) {
|
|
@@ -973,12 +973,12 @@ function vr(t = {}) {
|
|
|
973
973
|
}
|
|
974
974
|
}
|
|
975
975
|
if (n.keepFieldsRef)
|
|
976
|
-
for (const
|
|
977
|
-
Y(
|
|
976
|
+
for (const F of l.mount)
|
|
977
|
+
Y(F, m(y, F));
|
|
978
978
|
else
|
|
979
979
|
s = {};
|
|
980
980
|
}
|
|
981
|
-
i = r.shouldUnregister ? n.keepDefaultValues ? M(
|
|
981
|
+
i = r.shouldUnregister ? n.keepDefaultValues ? M(o) : {} : M(y), p.array.next({
|
|
982
982
|
values: { ...y }
|
|
983
983
|
}), p.state.next({
|
|
984
984
|
values: { ...y }
|
|
@@ -992,23 +992,23 @@ function vr(t = {}) {
|
|
|
992
992
|
watch: /* @__PURE__ */ new Set(),
|
|
993
993
|
watchAll: !1,
|
|
994
994
|
focus: ""
|
|
995
|
-
}, c.mount = !
|
|
995
|
+
}, c.mount = !g.isValid || !!n.keepIsValid || !!n.keepDirtyValues || !r.shouldUnregister && !Q(y), c.watch = !!r.shouldUnregister, c.keepIsValid = !!n.keepIsValid, c.action = !1, n.keepErrors || (e.errors = {}), p.state.next({
|
|
996
996
|
submitCount: n.keepSubmitCount ? e.submitCount : 0,
|
|
997
|
-
isDirty: _ ? !1 : n.keepDirty ? e.isDirty : !!(n.keepDefaultValues && !ae(a,
|
|
997
|
+
isDirty: _ ? !1 : n.keepDirty ? e.isDirty : !!(n.keepDefaultValues && !ae(a, o)),
|
|
998
998
|
isSubmitted: n.keepIsSubmitted ? e.isSubmitted : !1,
|
|
999
|
-
dirtyFields: _ ? {} : n.keepDirtyValues ? n.keepDefaultValues && i ?
|
|
999
|
+
dirtyFields: _ ? {} : n.keepDirtyValues ? n.keepDefaultValues && i ? de(o, i) : e.dirtyFields : n.keepDefaultValues && a ? de(o, a) : n.keepDirty ? e.dirtyFields : {},
|
|
1000
1000
|
touchedFields: n.keepTouched ? e.touchedFields : {},
|
|
1001
1001
|
errors: n.keepErrors ? e.errors : {},
|
|
1002
1002
|
isSubmitSuccessful: n.keepIsSubmitSuccessful ? e.isSubmitSuccessful : !1,
|
|
1003
1003
|
isSubmitting: !1,
|
|
1004
|
-
defaultValues:
|
|
1004
|
+
defaultValues: o
|
|
1005
1005
|
});
|
|
1006
|
-
}, lt = (a, n) =>
|
|
1007
|
-
const
|
|
1008
|
-
if (
|
|
1009
|
-
const _ =
|
|
1006
|
+
}, lt = (a, n) => ut(z(a) ? a(i) : a, { ...r.resetOptions, ...n }), Ht = (a, n = {}) => {
|
|
1007
|
+
const u = m(s, a), h = u && u._f;
|
|
1008
|
+
if (h) {
|
|
1009
|
+
const _ = h.refs ? h.refs[0] : h.ref;
|
|
1010
1010
|
_.focus && setTimeout(() => {
|
|
1011
|
-
_.focus(), n.shouldSelect &&
|
|
1011
|
+
_.focus(), n.shouldSelect && z(_.select) && _.select();
|
|
1012
1012
|
});
|
|
1013
1013
|
}
|
|
1014
1014
|
}, $t = (a) => {
|
|
@@ -1019,31 +1019,31 @@ function vr(t = {}) {
|
|
|
1019
1019
|
}, ct = {
|
|
1020
1020
|
control: {
|
|
1021
1021
|
register: De,
|
|
1022
|
-
unregister:
|
|
1022
|
+
unregister: ke,
|
|
1023
1023
|
getFieldState: st,
|
|
1024
|
-
handleSubmit:
|
|
1024
|
+
handleSubmit: ot,
|
|
1025
1025
|
setError: at,
|
|
1026
1026
|
_subscribe: nt,
|
|
1027
|
-
_runSchema:
|
|
1028
|
-
_updateIsValidating:
|
|
1029
|
-
_focusError:
|
|
1030
|
-
_getWatch:
|
|
1027
|
+
_runSchema: $,
|
|
1028
|
+
_updateIsValidating: N,
|
|
1029
|
+
_focusError: Oe,
|
|
1030
|
+
_getWatch: k,
|
|
1031
1031
|
_getDirty: E,
|
|
1032
|
-
_setValid:
|
|
1032
|
+
_setValid: O,
|
|
1033
1033
|
_setFieldArray: x,
|
|
1034
1034
|
_setDisabledField: it,
|
|
1035
1035
|
_setErrors: f,
|
|
1036
|
-
_getFieldArray:
|
|
1037
|
-
_reset:
|
|
1038
|
-
_resetDefaultValues: () =>
|
|
1036
|
+
_getFieldArray: H,
|
|
1037
|
+
_reset: ut,
|
|
1038
|
+
_resetDefaultValues: () => z(r.defaultValues) && r.defaultValues().then((a) => {
|
|
1039
1039
|
lt(a, r.resetOptions), p.state.next({
|
|
1040
1040
|
isLoading: !1
|
|
1041
1041
|
});
|
|
1042
1042
|
}),
|
|
1043
|
-
_removeUnmounted:
|
|
1043
|
+
_removeUnmounted: ne,
|
|
1044
1044
|
_disableForm: Pt,
|
|
1045
1045
|
_subjects: p,
|
|
1046
|
-
_proxyFormState:
|
|
1046
|
+
_proxyFormState: g,
|
|
1047
1047
|
get _fields() {
|
|
1048
1048
|
return s;
|
|
1049
1049
|
},
|
|
@@ -1057,7 +1057,7 @@ function vr(t = {}) {
|
|
|
1057
1057
|
c = a;
|
|
1058
1058
|
},
|
|
1059
1059
|
get _defaultValues() {
|
|
1060
|
-
return
|
|
1060
|
+
return o;
|
|
1061
1061
|
},
|
|
1062
1062
|
get _names() {
|
|
1063
1063
|
return l;
|
|
@@ -1079,16 +1079,16 @@ function vr(t = {}) {
|
|
|
1079
1079
|
}
|
|
1080
1080
|
},
|
|
1081
1081
|
subscribe: Bt,
|
|
1082
|
-
trigger:
|
|
1082
|
+
trigger: he,
|
|
1083
1083
|
register: De,
|
|
1084
|
-
handleSubmit:
|
|
1084
|
+
handleSubmit: ot,
|
|
1085
1085
|
watch: It,
|
|
1086
1086
|
setValue: Y,
|
|
1087
1087
|
getValues: rt,
|
|
1088
1088
|
reset: lt,
|
|
1089
1089
|
resetField: Wt,
|
|
1090
1090
|
clearErrors: Mt,
|
|
1091
|
-
unregister:
|
|
1091
|
+
unregister: ke,
|
|
1092
1092
|
setError: at,
|
|
1093
1093
|
setFocus: Ht,
|
|
1094
1094
|
getFieldState: st
|
|
@@ -1106,138 +1106,138 @@ var ue = () => {
|
|
|
1106
1106
|
const e = (Math.random() * 16 + t) % 16 | 0;
|
|
1107
1107
|
return (r == "x" ? e : e & 3 | 8).toString(16);
|
|
1108
1108
|
});
|
|
1109
|
-
}, Ue = (t, r, e = {}) => e.shouldFocus ||
|
|
1109
|
+
}, Ue = (t, r, e = {}) => e.shouldFocus || U(e.shouldFocus) ? e.focusName || `${t}.${U(e.focusIndex) ? r : e.focusIndex}.` : "", Me = (t, r) => [
|
|
1110
1110
|
...t,
|
|
1111
|
-
...
|
|
1111
|
+
...K(r)
|
|
1112
1112
|
], Ie = (t) => Array.isArray(t) ? t.map(() => {
|
|
1113
1113
|
}) : void 0;
|
|
1114
1114
|
function Be(t, r, e) {
|
|
1115
1115
|
return [
|
|
1116
1116
|
...t.slice(0, r),
|
|
1117
|
-
...
|
|
1117
|
+
...K(e),
|
|
1118
1118
|
...t.slice(r)
|
|
1119
1119
|
];
|
|
1120
1120
|
}
|
|
1121
|
-
var Pe = (t, r, e) => Array.isArray(t) ? (
|
|
1122
|
-
...
|
|
1123
|
-
...
|
|
1121
|
+
var Pe = (t, r, e) => Array.isArray(t) ? (U(t[e]) && (t[e] = void 0), t.splice(e, 0, t.splice(r, 1)[0]), t) : [], We = (t, r) => [
|
|
1122
|
+
...K(r),
|
|
1123
|
+
...K(t)
|
|
1124
1124
|
];
|
|
1125
1125
|
function Vr(t, r) {
|
|
1126
1126
|
let e = 0;
|
|
1127
1127
|
const s = [...t];
|
|
1128
|
-
for (const
|
|
1129
|
-
s.splice(
|
|
1128
|
+
for (const o of r)
|
|
1129
|
+
s.splice(o - e, 1), e++;
|
|
1130
1130
|
return we(s).length ? s : [];
|
|
1131
1131
|
}
|
|
1132
|
-
var He = (t, r) =>
|
|
1132
|
+
var He = (t, r) => U(r) ? [] : Vr(t, K(r).sort((e, s) => e - s)), $e = (t, r, e) => {
|
|
1133
1133
|
[t[r], t[e]] = [t[e], t[r]];
|
|
1134
1134
|
}, bt = (t, r, e) => (t[r] = e, t);
|
|
1135
1135
|
function Fr(t) {
|
|
1136
|
-
const r =
|
|
1137
|
-
e._names.array.add(s),
|
|
1136
|
+
const r = Fe(), { control: e = r.control, name: s, keyName: o = "id", shouldUnregister: i, rules: c } = t, [l, v] = V.useState(e._getFieldArray(s)), b = V.useRef(e._getFieldArray(s).map(ue)), w = V.useRef(!1);
|
|
1137
|
+
e._names.array.add(s), V.useMemo(() => c && l.length >= 0 && e.register(s, c), [e, s, l.length, c]), Ce(() => e._subjects.array.subscribe({
|
|
1138
1138
|
next: ({ values: f, name: d }) => {
|
|
1139
1139
|
if (d === s || !d) {
|
|
1140
1140
|
const A = m(f, s);
|
|
1141
|
-
Array.isArray(A) && (
|
|
1141
|
+
Array.isArray(A) && (v(A), b.current = A.map(ue));
|
|
1142
1142
|
}
|
|
1143
1143
|
}
|
|
1144
1144
|
}).unsubscribe, [e, s]);
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1145
|
+
const g = V.useCallback((f) => {
|
|
1146
|
+
w.current = !0, e._setFieldArray(s, f);
|
|
1147
1147
|
}, [e, s]), S = (f, d) => {
|
|
1148
|
-
const A =
|
|
1149
|
-
e._names.focus = Ue(s,
|
|
1148
|
+
const A = K(M(f)), C = Me(e._getFieldArray(s), A);
|
|
1149
|
+
e._names.focus = Ue(s, C.length - 1, d), b.current = Me(b.current, A.map(ue)), g(C), v(C), e._setFieldArray(s, C, Me, {
|
|
1150
1150
|
argA: Ie(f)
|
|
1151
1151
|
});
|
|
1152
1152
|
}, p = (f, d) => {
|
|
1153
|
-
const A =
|
|
1154
|
-
e._names.focus = Ue(s, 0, d),
|
|
1153
|
+
const A = K(M(f)), C = We(e._getFieldArray(s), A);
|
|
1154
|
+
e._names.focus = Ue(s, 0, d), b.current = We(b.current, A.map(ue)), g(C), v(C), e._setFieldArray(s, C, We, {
|
|
1155
1155
|
argA: Ie(f)
|
|
1156
1156
|
});
|
|
1157
1157
|
}, I = (f) => {
|
|
1158
1158
|
const d = He(e._getFieldArray(s), f);
|
|
1159
|
-
|
|
1159
|
+
b.current = He(b.current, f), g(d), v(d), !Array.isArray(m(e._fields, s)) && T(e._fields, s, void 0), e._setFieldArray(s, d, He, {
|
|
1160
1160
|
argA: f
|
|
1161
1161
|
});
|
|
1162
1162
|
}, R = (f, d, A) => {
|
|
1163
|
-
const
|
|
1164
|
-
e._names.focus = Ue(s, f, A),
|
|
1163
|
+
const C = K(M(d)), $ = Be(e._getFieldArray(s), f, C);
|
|
1164
|
+
e._names.focus = Ue(s, f, A), b.current = Be(b.current, f, C.map(ue)), g($), v($), e._setFieldArray(s, $, Be, {
|
|
1165
1165
|
argA: f,
|
|
1166
1166
|
argB: Ie(d)
|
|
1167
1167
|
});
|
|
1168
|
-
},
|
|
1168
|
+
}, O = (f, d) => {
|
|
1169
1169
|
const A = e._getFieldArray(s);
|
|
1170
|
-
$e(A, f, d), $e(
|
|
1170
|
+
$e(A, f, d), $e(b.current, f, d), g(A), v(A), e._setFieldArray(s, A, $e, {
|
|
1171
1171
|
argA: f,
|
|
1172
1172
|
argB: d
|
|
1173
1173
|
}, !1);
|
|
1174
|
-
},
|
|
1174
|
+
}, N = (f, d) => {
|
|
1175
1175
|
const A = e._getFieldArray(s);
|
|
1176
|
-
Pe(A, f, d), Pe(
|
|
1176
|
+
Pe(A, f, d), Pe(b.current, f, d), g(A), v(A), e._setFieldArray(s, A, Pe, {
|
|
1177
1177
|
argA: f,
|
|
1178
1178
|
argB: d
|
|
1179
1179
|
}, !1);
|
|
1180
1180
|
}, x = (f, d) => {
|
|
1181
|
-
const A = M(d),
|
|
1182
|
-
|
|
1181
|
+
const A = M(d), C = bt(e._getFieldArray(s), f, A);
|
|
1182
|
+
b.current = [...C].map(($, q) => !$ || q === f ? ue() : b.current[q]), g(C), v([...C]), e._setFieldArray(s, C, bt, {
|
|
1183
1183
|
argA: f,
|
|
1184
1184
|
argB: A
|
|
1185
1185
|
}, !0, !1);
|
|
1186
1186
|
}, B = (f) => {
|
|
1187
|
-
const d =
|
|
1188
|
-
|
|
1187
|
+
const d = K(M(f));
|
|
1188
|
+
b.current = d.map(ue), g([...d]), v([...d]), e._setFieldArray(s, [...d], (A) => A, {}, !0, !1);
|
|
1189
1189
|
};
|
|
1190
|
-
return
|
|
1190
|
+
return V.useEffect(() => {
|
|
1191
1191
|
if (e._state.action = !1, Qe(s, e._names) && e._subjects.state.next({
|
|
1192
1192
|
...e._formState
|
|
1193
|
-
}),
|
|
1193
|
+
}), w.current && (!fe(e._options.mode).isOnSubmit || e._formState.isSubmitted) && !fe(e._options.reValidateMode).isOnSubmit)
|
|
1194
1194
|
if (e._options.resolver)
|
|
1195
1195
|
e._runSchema([s]).then((f) => {
|
|
1196
1196
|
e._updateIsValidating([s]);
|
|
1197
1197
|
const d = m(f.errors, s), A = m(e._formState.errors, s);
|
|
1198
|
-
(A ? !d && A.type || d && (A.type !== d.type || A.message !== d.message) : d && d.type) && (d ?
|
|
1198
|
+
(A ? !d && A.type || d && (A.type !== d.type || A.message !== d.message) : d && d.type) && (d ? T(e._formState.errors, s, d) : P(e._formState.errors, s), e._subjects.state.next({
|
|
1199
1199
|
errors: e._formState.errors
|
|
1200
1200
|
}));
|
|
1201
1201
|
});
|
|
1202
1202
|
else {
|
|
1203
1203
|
const f = m(e._fields, s);
|
|
1204
|
-
f && f._f && !(
|
|
1204
|
+
f && f._f && !(fe(e._options.reValidateMode).isOnSubmit && fe(e._options.mode).isOnSubmit) && ze(f, e._names.disabled, e._formValues, e._options.criteriaMode === re.all, e._options.shouldUseNativeValidation, !0).then((d) => !Q(d) && e._subjects.state.next({
|
|
1205
1205
|
errors: Rt(e._formState.errors, d, s)
|
|
1206
1206
|
}));
|
|
1207
1207
|
}
|
|
1208
1208
|
e._subjects.state.next({
|
|
1209
1209
|
name: s,
|
|
1210
1210
|
values: M(e._formValues)
|
|
1211
|
-
}), e._names.focus &&
|
|
1211
|
+
}), e._names.focus && ye(e._fields, (f, d) => {
|
|
1212
1212
|
if (e._names.focus && d.startsWith(e._names.focus) && f.focus)
|
|
1213
1213
|
return f.focus(), 1;
|
|
1214
|
-
}), e._names.focus = "", e._setValid(),
|
|
1215
|
-
}, [l, s, e]),
|
|
1214
|
+
}), e._names.focus = "", e._setValid(), w.current = !1;
|
|
1215
|
+
}, [l, s, e]), V.useEffect(() => (!m(e._formValues, s) && e._setFieldArray(s), () => {
|
|
1216
1216
|
const f = (d, A) => {
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1217
|
+
const C = m(e._fields, d);
|
|
1218
|
+
C && C._f && (C._f.mount = A);
|
|
1219
1219
|
};
|
|
1220
1220
|
e._options.shouldUnregister || i ? e.unregister(s) : f(s, !1);
|
|
1221
|
-
}), [s, e,
|
|
1222
|
-
swap:
|
|
1223
|
-
move:
|
|
1224
|
-
prepend:
|
|
1225
|
-
append:
|
|
1226
|
-
remove:
|
|
1227
|
-
insert:
|
|
1228
|
-
update:
|
|
1229
|
-
replace:
|
|
1230
|
-
fields:
|
|
1221
|
+
}), [s, e, o, i]), {
|
|
1222
|
+
swap: V.useCallback(O, [g, s, e]),
|
|
1223
|
+
move: V.useCallback(N, [g, s, e]),
|
|
1224
|
+
prepend: V.useCallback(p, [g, s, e]),
|
|
1225
|
+
append: V.useCallback(S, [g, s, e]),
|
|
1226
|
+
remove: V.useCallback(I, [g, s, e]),
|
|
1227
|
+
insert: V.useCallback(R, [g, s, e]),
|
|
1228
|
+
update: V.useCallback(x, [g, s, e]),
|
|
1229
|
+
replace: V.useCallback(B, [g, s, e]),
|
|
1230
|
+
fields: V.useMemo(() => l.map((f, d) => ({
|
|
1231
1231
|
...f,
|
|
1232
|
-
[
|
|
1233
|
-
})), [l,
|
|
1232
|
+
[o]: b.current[d] || ue()
|
|
1233
|
+
})), [l, o])
|
|
1234
1234
|
};
|
|
1235
1235
|
}
|
|
1236
1236
|
function br(t = {}) {
|
|
1237
|
-
const r =
|
|
1237
|
+
const r = V.useRef(void 0), e = V.useRef(void 0), [s, o] = V.useState({
|
|
1238
1238
|
isDirty: !1,
|
|
1239
1239
|
isValidating: !1,
|
|
1240
|
-
isLoading:
|
|
1240
|
+
isLoading: z(t.defaultValues),
|
|
1241
1241
|
isSubmitted: !1,
|
|
1242
1242
|
isSubmitting: !1,
|
|
1243
1243
|
isSubmitSuccessful: !1,
|
|
@@ -1249,14 +1249,14 @@ function br(t = {}) {
|
|
|
1249
1249
|
errors: t.errors || {},
|
|
1250
1250
|
disabled: t.disabled || !1,
|
|
1251
1251
|
isReady: !1,
|
|
1252
|
-
defaultValues:
|
|
1252
|
+
defaultValues: z(t.defaultValues) ? void 0 : t.defaultValues
|
|
1253
1253
|
});
|
|
1254
1254
|
if (!r.current)
|
|
1255
1255
|
if (t.formControl)
|
|
1256
1256
|
r.current = {
|
|
1257
1257
|
...t.formControl,
|
|
1258
1258
|
formState: s
|
|
1259
|
-
}, t.defaultValues && !
|
|
1259
|
+
}, t.defaultValues && !z(t.defaultValues) && t.formControl.reset(t.defaultValues, t.resetOptions);
|
|
1260
1260
|
else {
|
|
1261
1261
|
const { formControl: c, ...l } = vr(t);
|
|
1262
1262
|
r.current = {
|
|
@@ -1265,161 +1265,167 @@ function br(t = {}) {
|
|
|
1265
1265
|
};
|
|
1266
1266
|
}
|
|
1267
1267
|
const i = r.current.control;
|
|
1268
|
-
return i._options = t,
|
|
1268
|
+
return i._options = t, Ce(() => {
|
|
1269
1269
|
const c = i._subscribe({
|
|
1270
1270
|
formState: i._proxyFormState,
|
|
1271
|
-
callback: () =>
|
|
1271
|
+
callback: () => o({ ...i._formState }),
|
|
1272
1272
|
reRenderRoot: !0
|
|
1273
1273
|
});
|
|
1274
|
-
return
|
|
1274
|
+
return o((l) => ({
|
|
1275
1275
|
...l,
|
|
1276
1276
|
isReady: !0
|
|
1277
1277
|
})), i._formState.isReady = !0, c;
|
|
1278
|
-
}, [i]),
|
|
1278
|
+
}, [i]), V.useEffect(() => i._disableForm(t.disabled), [i, t.disabled]), V.useEffect(() => {
|
|
1279
1279
|
t.mode && (i._options.mode = t.mode), t.reValidateMode && (i._options.reValidateMode = t.reValidateMode);
|
|
1280
|
-
}, [i, t.mode, t.reValidateMode]),
|
|
1280
|
+
}, [i, t.mode, t.reValidateMode]), V.useEffect(() => {
|
|
1281
1281
|
t.errors && (i._setErrors(t.errors), i._focusError());
|
|
1282
|
-
}, [i, t.errors]),
|
|
1282
|
+
}, [i, t.errors]), V.useEffect(() => {
|
|
1283
1283
|
t.shouldUnregister && i._subjects.state.next({
|
|
1284
1284
|
values: i._getWatch()
|
|
1285
1285
|
});
|
|
1286
|
-
}, [i, t.shouldUnregister]),
|
|
1286
|
+
}, [i, t.shouldUnregister]), V.useEffect(() => {
|
|
1287
1287
|
if (i._proxyFormState.isDirty) {
|
|
1288
1288
|
const c = i._getDirty();
|
|
1289
1289
|
c !== s.isDirty && i._subjects.state.next({
|
|
1290
1290
|
isDirty: c
|
|
1291
1291
|
});
|
|
1292
1292
|
}
|
|
1293
|
-
}, [i, s.isDirty]),
|
|
1293
|
+
}, [i, s.isDirty]), V.useEffect(() => {
|
|
1294
1294
|
var c;
|
|
1295
1295
|
t.values && !ae(t.values, e.current) ? (i._reset(t.values, {
|
|
1296
1296
|
keepFieldsRef: !0,
|
|
1297
1297
|
...i._options.resetOptions
|
|
1298
|
-
}), !((c = i._options.resetOptions) === null || c === void 0) && c.keepIsValid || i._setValid(), e.current = t.values,
|
|
1299
|
-
}, [i, t.values]),
|
|
1298
|
+
}), !((c = i._options.resetOptions) === null || c === void 0) && c.keepIsValid || i._setValid(), e.current = t.values, o((l) => ({ ...l }))) : i._resetDefaultValues();
|
|
1299
|
+
}, [i, t.values]), V.useEffect(() => {
|
|
1300
1300
|
i._state.mount || (i._setValid(), i._state.mount = !0), i._state.watch && (i._state.watch = !1, i._subjects.state.next({ ...i._formState })), i._removeUnmounted();
|
|
1301
1301
|
}), r.current.formState = Et(s, i), r.current;
|
|
1302
1302
|
}
|
|
1303
|
-
const
|
|
1304
|
-
const t =
|
|
1303
|
+
const Nt = zt(void 0), Ar = ({ showAsterisk: t, children: r }) => /* @__PURE__ */ te(Nt.Provider, { value: { showAsterisk: t }, children: r }), pr = () => {
|
|
1304
|
+
const t = Jt(Nt);
|
|
1305
1305
|
if (!t)
|
|
1306
1306
|
throw new Error("useSuprFormContext must be used within a SuprFormProvider");
|
|
1307
1307
|
return t;
|
|
1308
1308
|
};
|
|
1309
|
-
function
|
|
1310
|
-
const { conditions: s, operator:
|
|
1311
|
-
const
|
|
1309
|
+
function Lt(t, r, e) {
|
|
1310
|
+
const { conditions: s, operator: o } = e, i = t.reduce((l, v, b) => (l[v] = r[b], l), {}), c = s.map((l) => {
|
|
1311
|
+
const v = i[l.name];
|
|
1312
1312
|
switch (l.operator) {
|
|
1313
1313
|
case "EQUALS":
|
|
1314
|
-
return
|
|
1314
|
+
return v === l.value;
|
|
1315
1315
|
case "NOT_EQUALS":
|
|
1316
|
-
return
|
|
1316
|
+
return v !== l.value;
|
|
1317
1317
|
case "GREATER_THAN":
|
|
1318
|
-
return
|
|
1318
|
+
return v > l.value;
|
|
1319
1319
|
case "LESS_THAN":
|
|
1320
|
-
return
|
|
1320
|
+
return v < l.value;
|
|
1321
1321
|
case "GREATER_THAN_OR_EQUAL":
|
|
1322
|
-
return
|
|
1322
|
+
return v >= l.value;
|
|
1323
1323
|
case "LESS_THAN_OR_EQUAL":
|
|
1324
|
-
return
|
|
1324
|
+
return v <= l.value;
|
|
1325
1325
|
case "STARTS_WITH":
|
|
1326
|
-
return
|
|
1326
|
+
return v.startsWith(l.value);
|
|
1327
1327
|
case "ENDS_WITH":
|
|
1328
|
-
return
|
|
1328
|
+
return v.endsWith(l.value);
|
|
1329
1329
|
case "INCLUDES":
|
|
1330
|
-
return
|
|
1330
|
+
return v.includes(l.value);
|
|
1331
1331
|
case "NOT_INCLUDES":
|
|
1332
|
-
return !
|
|
1332
|
+
return !v.includes(l.value);
|
|
1333
1333
|
default:
|
|
1334
1334
|
return !1;
|
|
1335
1335
|
}
|
|
1336
1336
|
});
|
|
1337
|
-
return
|
|
1337
|
+
return o === "AND" ? c.every(Boolean) : c.some(Boolean);
|
|
1338
1338
|
}
|
|
1339
1339
|
const xr = ({
|
|
1340
1340
|
children: t,
|
|
1341
1341
|
visibility: r
|
|
1342
1342
|
}) => {
|
|
1343
|
-
const e =
|
|
1344
|
-
return
|
|
1343
|
+
const e = me(() => typeof r == "boolean" ? [] : (r == null ? void 0 : r.conditions.map((i) => i.name)) || [], [r]), s = Xe({ name: e });
|
|
1344
|
+
return me(() => typeof r == "boolean" ? r : !r || (r == null ? void 0 : r.conditions.length) === 0 ? !0 : Lt(e, s, r), [r, e, s]) ? t : null;
|
|
1345
1345
|
}, Sr = ({
|
|
1346
1346
|
children: t,
|
|
1347
1347
|
disabled: r
|
|
1348
1348
|
}) => {
|
|
1349
|
-
const e =
|
|
1350
|
-
return Ae(t, { ...t.props, disabled:
|
|
1349
|
+
const e = me(() => typeof r == "boolean" ? [] : (r == null ? void 0 : r.conditions.map((i) => i.name)) || [], [r]), s = Xe({ name: e }), o = me(() => typeof r == "boolean" ? r : !r || (r == null ? void 0 : r.conditions.length) === 0 ? !1 : Lt(e, s, r), [r, e, s]);
|
|
1350
|
+
return Ae(t, { ...t.props, disabled: o });
|
|
1351
1351
|
}, tt = ({
|
|
1352
1352
|
children: t,
|
|
1353
1353
|
name: r,
|
|
1354
1354
|
rules: e,
|
|
1355
1355
|
className: s = "",
|
|
1356
|
-
label:
|
|
1356
|
+
label: o,
|
|
1357
1357
|
id: i,
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1358
|
+
value: c,
|
|
1359
|
+
disabled: l,
|
|
1360
|
+
shouldUnregister: v,
|
|
1361
|
+
visibility: b,
|
|
1362
|
+
description: w
|
|
1362
1363
|
}) => {
|
|
1363
|
-
const { control:
|
|
1364
|
-
if (
|
|
1365
|
-
return typeof
|
|
1366
|
-
}, [
|
|
1367
|
-
return /* @__PURE__ */ te(xr, { visibility:
|
|
1364
|
+
const { control: g } = Fe(), S = typeof t == "function", p = S ? c ?? "" : t.props.value ?? "", { showAsterisk: I } = pr(), R = me(() => i || crypto.randomUUID(), []), O = me(() => {
|
|
1365
|
+
if (w)
|
|
1366
|
+
return typeof w == "string" ? { position: "LABEL_BOTTOM", text: w } : w;
|
|
1367
|
+
}, [w]);
|
|
1368
|
+
return /* @__PURE__ */ te(xr, { visibility: b, children: /* @__PURE__ */ te(Sr, { disabled: l, children: /* @__PURE__ */ te(
|
|
1368
1369
|
ar,
|
|
1369
1370
|
{
|
|
1370
|
-
control:
|
|
1371
|
+
control: g,
|
|
1371
1372
|
name: r,
|
|
1372
1373
|
rules: e,
|
|
1373
|
-
defaultValue:
|
|
1374
|
-
shouldUnregister:
|
|
1375
|
-
render: ({
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1374
|
+
defaultValue: p,
|
|
1375
|
+
shouldUnregister: v,
|
|
1376
|
+
render: (N) => {
|
|
1377
|
+
const {
|
|
1378
|
+
field: { name: x, onBlur: B, value: f, onChange: d, ref: A, disabled: C },
|
|
1379
|
+
fieldState: { error: $ }
|
|
1380
|
+
} = N;
|
|
1381
|
+
return /* @__PURE__ */ Ne(
|
|
1382
|
+
"div",
|
|
1383
|
+
{
|
|
1384
|
+
className: `controlled-field ${s}`,
|
|
1385
|
+
style: { display: "flex", flexDirection: "column", gap: "5px" },
|
|
1386
|
+
children: [
|
|
1387
|
+
/* @__PURE__ */ Ne(
|
|
1388
|
+
"div",
|
|
1389
|
+
{
|
|
1390
|
+
className: "controlled-field-description",
|
|
1391
|
+
style: {
|
|
1392
|
+
display: "inline-flex",
|
|
1393
|
+
...O && {
|
|
1394
|
+
gap: "2px",
|
|
1395
|
+
alignItems: "center",
|
|
1396
|
+
flexDirection: O.position === "LABEL_RIGHT" ? "row" : "column"
|
|
1397
|
+
}
|
|
1398
|
+
},
|
|
1399
|
+
children: [
|
|
1400
|
+
o && /* @__PURE__ */ Ne("label", { htmlFor: R, className: "controlled-field-label", children: [
|
|
1401
|
+
o,
|
|
1402
|
+
I && !!e && /* @__PURE__ */ te("span", { style: { color: "red" }, children: " *" })
|
|
1403
|
+
] }),
|
|
1404
|
+
O && O.position !== "CONTROL_BOTTOM" && /* @__PURE__ */ te("span", { style: { color: "#a1a1a1", fontSize: 12 }, children: O.text })
|
|
1405
|
+
]
|
|
1406
|
+
}
|
|
1407
|
+
),
|
|
1408
|
+
S ? t(N) : Ae(t, {
|
|
1409
|
+
...t.props,
|
|
1410
|
+
id: R,
|
|
1411
|
+
name: x,
|
|
1412
|
+
disabled: C,
|
|
1413
|
+
onChange: (...q) => {
|
|
1414
|
+
var j, ne;
|
|
1415
|
+
d(...q), (ne = (j = t.props).onChange) == null || ne.call(j, ...q);
|
|
1395
1416
|
},
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
name: U,
|
|
1409
|
-
disabled: A,
|
|
1410
|
-
onChange: (...W) => {
|
|
1411
|
-
f(...W), p == null || p(...W);
|
|
1412
|
-
},
|
|
1413
|
-
value: B,
|
|
1414
|
-
onBlur: (...W) => {
|
|
1415
|
-
x(), I == null || I(...W);
|
|
1416
|
-
},
|
|
1417
|
-
ref: d
|
|
1418
|
-
}),
|
|
1419
|
-
w && /* @__PURE__ */ te("div", { style: { color: "red", fontSize: 13 }, className: "controlled-field-error", children: w.message })
|
|
1420
|
-
]
|
|
1421
|
-
}
|
|
1422
|
-
)
|
|
1417
|
+
value: f,
|
|
1418
|
+
onBlur: (...q) => {
|
|
1419
|
+
var j, ne;
|
|
1420
|
+
B(), (ne = (j = t.props).onBlur) == null || ne.call(j, ...q);
|
|
1421
|
+
},
|
|
1422
|
+
ref: A
|
|
1423
|
+
}),
|
|
1424
|
+
$ && /* @__PURE__ */ te("div", { style: { color: "red", fontSize: 13 }, className: "controlled-field-error", children: $.message })
|
|
1425
|
+
]
|
|
1426
|
+
}
|
|
1427
|
+
);
|
|
1428
|
+
}
|
|
1423
1429
|
}
|
|
1424
1430
|
) }) });
|
|
1425
1431
|
};
|
|
@@ -1429,109 +1435,96 @@ const Er = ({
|
|
|
1429
1435
|
rules: r,
|
|
1430
1436
|
ref: e,
|
|
1431
1437
|
children: s,
|
|
1432
|
-
visibility:
|
|
1438
|
+
visibility: o,
|
|
1433
1439
|
disabled: i
|
|
1434
1440
|
}) => {
|
|
1435
1441
|
const c = Fr({
|
|
1436
1442
|
name: t,
|
|
1437
1443
|
rules: r
|
|
1438
1444
|
});
|
|
1439
|
-
At(e, () => c, [c]);
|
|
1440
|
-
const l = (
|
|
1445
|
+
At(e, () => c, [JSON.stringify(c)]);
|
|
1446
|
+
const l = (v, b) => Kt.map(v, (w) => {
|
|
1441
1447
|
var I, R;
|
|
1442
|
-
if (!
|
|
1443
|
-
return
|
|
1444
|
-
const
|
|
1445
|
-
if (((S == null ? void 0 : S.displayName) === "SuprFormControl" || S === tt ||
|
|
1446
|
-
const
|
|
1447
|
-
...
|
|
1448
|
-
conditions: ((I =
|
|
1448
|
+
if (!Yt(w))
|
|
1449
|
+
return w;
|
|
1450
|
+
const g = w.props, S = w.type;
|
|
1451
|
+
if (((S == null ? void 0 : S.displayName) === "SuprFormControl" || S === tt || g.name !== void 0 && typeof S != "string") && g.name !== void 0) {
|
|
1452
|
+
const O = o ? o[g.name] : void 0, N = O ? {
|
|
1453
|
+
...O,
|
|
1454
|
+
conditions: ((I = O.conditions) == null ? void 0 : I.map((d) => ({
|
|
1449
1455
|
...d,
|
|
1450
|
-
name: `${
|
|
1456
|
+
name: `${b}${d.name}`
|
|
1451
1457
|
}))) || []
|
|
1452
|
-
} : void 0, x = i ? i[
|
|
1458
|
+
} : void 0, x = i ? i[g.name] : void 0, B = x ? {
|
|
1453
1459
|
...x,
|
|
1454
1460
|
conditions: ((R = x.conditions) == null ? void 0 : R.map((d) => ({
|
|
1455
1461
|
...d,
|
|
1456
|
-
name: `${
|
|
1462
|
+
name: `${b}${d.name}`
|
|
1457
1463
|
}))) || []
|
|
1458
1464
|
} : void 0, f = {
|
|
1459
|
-
...
|
|
1460
|
-
name: `${
|
|
1461
|
-
visibility:
|
|
1465
|
+
...g,
|
|
1466
|
+
name: `${b}${g.name}`,
|
|
1467
|
+
visibility: N,
|
|
1462
1468
|
disabled: B
|
|
1463
1469
|
};
|
|
1464
|
-
return
|
|
1470
|
+
return g.id !== void 0 && (f.id = `${b}${g.id}`), Ae(w, f);
|
|
1465
1471
|
}
|
|
1466
|
-
return
|
|
1467
|
-
...
|
|
1468
|
-
children: l(
|
|
1469
|
-
}) :
|
|
1472
|
+
return g.children ? Ae(w, {
|
|
1473
|
+
...g,
|
|
1474
|
+
children: l(g.children, b)
|
|
1475
|
+
}) : w;
|
|
1470
1476
|
});
|
|
1471
|
-
return /* @__PURE__ */ te(Qt, { children: c.fields.map((
|
|
1472
|
-
const
|
|
1477
|
+
return /* @__PURE__ */ te(Qt, { children: c.fields.map((v, b) => {
|
|
1478
|
+
const w = `${t}.${b}.`;
|
|
1473
1479
|
return /* @__PURE__ */ te(
|
|
1474
1480
|
"div",
|
|
1475
1481
|
{
|
|
1476
|
-
"data-index":
|
|
1482
|
+
"data-index": b,
|
|
1477
1483
|
style: { display: "contents" },
|
|
1478
1484
|
id: "field-array-item",
|
|
1479
|
-
children: l(s,
|
|
1485
|
+
children: l(s, w)
|
|
1480
1486
|
},
|
|
1481
|
-
|
|
1487
|
+
w
|
|
1482
1488
|
);
|
|
1483
1489
|
}) });
|
|
1484
1490
|
}, Ut = ({
|
|
1485
1491
|
children: t,
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
formOptions: i,
|
|
1493
|
-
showAsterisk: c,
|
|
1494
|
-
ref: l,
|
|
1495
|
-
onChange: V
|
|
1492
|
+
style: r = {},
|
|
1493
|
+
className: e = "",
|
|
1494
|
+
formOptions: s,
|
|
1495
|
+
showAsterisk: o,
|
|
1496
|
+
ref: i,
|
|
1497
|
+
onChange: c
|
|
1496
1498
|
}) => {
|
|
1497
|
-
const
|
|
1499
|
+
const l = br({
|
|
1498
1500
|
mode: "onSubmit",
|
|
1499
1501
|
reValidateMode: "onChange",
|
|
1500
1502
|
shouldFocusError: !0,
|
|
1501
|
-
...
|
|
1503
|
+
...s
|
|
1502
1504
|
});
|
|
1503
1505
|
return At(
|
|
1504
|
-
|
|
1506
|
+
i,
|
|
1505
1507
|
() => ({
|
|
1506
|
-
setValue:
|
|
1507
|
-
setError:
|
|
1508
|
-
clearErrors:
|
|
1509
|
-
getValues:
|
|
1510
|
-
reset:
|
|
1511
|
-
setFocus:
|
|
1512
|
-
resetField:
|
|
1513
|
-
trigger:
|
|
1514
|
-
unregister:
|
|
1515
|
-
watch:
|
|
1516
|
-
handleSubmit:
|
|
1517
|
-
formState:
|
|
1508
|
+
setValue: l.setValue,
|
|
1509
|
+
setError: l.setError,
|
|
1510
|
+
clearErrors: l.clearErrors,
|
|
1511
|
+
getValues: l.getValues,
|
|
1512
|
+
reset: l.reset,
|
|
1513
|
+
setFocus: l.setFocus,
|
|
1514
|
+
resetField: l.resetField,
|
|
1515
|
+
trigger: l.trigger,
|
|
1516
|
+
unregister: l.unregister,
|
|
1517
|
+
watch: l.watch,
|
|
1518
|
+
handleSubmit: l.handleSubmit,
|
|
1519
|
+
formState: l.formState
|
|
1518
1520
|
}),
|
|
1519
|
-
[
|
|
1521
|
+
[JSON.stringify(l)]
|
|
1520
1522
|
), Xt(() => {
|
|
1521
|
-
const
|
|
1522
|
-
|
|
1523
|
+
const v = l.watch((b) => {
|
|
1524
|
+
c == null || c(b);
|
|
1523
1525
|
});
|
|
1524
|
-
return () =>
|
|
1525
|
-
}, [
|
|
1526
|
-
"form",
|
|
1527
|
-
{
|
|
1528
|
-
noValidate: !0,
|
|
1529
|
-
onSubmit: g.handleSubmit(r, e),
|
|
1530
|
-
style: s,
|
|
1531
|
-
className: u,
|
|
1532
|
-
children: t
|
|
1533
|
-
}
|
|
1534
|
-
) }) });
|
|
1526
|
+
return () => v.unsubscribe();
|
|
1527
|
+
}, [l.watch]), /* @__PURE__ */ te(Ar, { showAsterisk: o, children: /* @__PURE__ */ te(tr, { ...l, children: /* @__PURE__ */ te("div", { style: r, className: e, children: t }) }) });
|
|
1535
1528
|
};
|
|
1536
1529
|
Ut.Control = tt;
|
|
1537
1530
|
Ut.ControlArray = Er;
|