suprform 1.1.5 → 1.2.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/LICENSE +1 -1
- package/README.md +1302 -225
- package/dist/components/FormControl.d.ts +1 -1
- package/dist/components/FormControl.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 +470 -449
- package/dist/suprform.es.js.map +1 -1
- package/dist/type.d.ts +4 -0
- package/dist/type.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/suprform.es.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import F, { createContext as zt, useContext as Kt, useMemo as
|
|
3
|
-
var ve = (t) => t.type === "checkbox", oe = (t) => t instanceof Date,
|
|
1
|
+
import { jsx as te, jsxs as Le, Fragment as Qt } from "react/jsx-runtime";
|
|
2
|
+
import F, { createContext as zt, useContext as Kt, useMemo as ye, cloneElement as Ae, useImperativeHandle as At, Children as Yt, isValidElement as Jt, useEffect as Xt } from "react";
|
|
3
|
+
var ve = (t) => t.type === "checkbox", oe = (t) => t instanceof Date, Q = (t) => t == null;
|
|
4
4
|
const pt = (t) => typeof t == "object";
|
|
5
|
-
var
|
|
5
|
+
var H = (t) => !Q(t) && !Array.isArray(t) && pt(t) && !oe(t), xt = (t) => H(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
|
-
},
|
|
9
|
-
function
|
|
7
|
+
return H(r) && r.hasOwnProperty("isPrototypeOf");
|
|
8
|
+
}, Ke = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
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 (Ke && (t instanceof Blob || r))
|
|
14
14
|
return t;
|
|
15
15
|
const e = Array.isArray(t);
|
|
16
|
-
if (!e && !(
|
|
16
|
+
if (!e && !(H(t) && er(t)))
|
|
17
17
|
return t;
|
|
18
18
|
const s = e ? [] : Object.create(Object.getPrototypeOf(t));
|
|
19
19
|
for (const u in t)
|
|
20
|
-
Object.prototype.hasOwnProperty.call(t, u) && (s[u] =
|
|
20
|
+
Object.prototype.hasOwnProperty.call(t, u) && (s[u] = M(t[u]));
|
|
21
21
|
return s;
|
|
22
22
|
}
|
|
23
|
-
var Ee = (t) => /^\w*$/.test(t),
|
|
24
|
-
if (!r || !
|
|
23
|
+
var Ee = (t) => /^\w*$/.test(t), N = (t) => t === void 0, we = (t) => Array.isArray(t) ? t.filter(Boolean) : [], Ye = (t) => we(t.replace(/["|']|\]/g, "").split(/\.|\[/)), m = (t, r, e) => {
|
|
24
|
+
if (!r || !H(t))
|
|
25
25
|
return e;
|
|
26
|
-
const s = (Ee(r) ? [r] :
|
|
27
|
-
return
|
|
28
|
-
}, J = (t) => typeof t == "boolean",
|
|
26
|
+
const s = (Ee(r) ? [r] : Ye(r)).reduce((u, i) => Q(u) ? u : u[i], t);
|
|
27
|
+
return N(s) || s === t ? N(t[r]) ? e : t[r] : s;
|
|
28
|
+
}, J = (t) => typeof t == "boolean", G = (t) => typeof t == "function", O = (t, r, e) => {
|
|
29
29
|
let s = -1;
|
|
30
|
-
const u = Ee(r) ? [r] :
|
|
30
|
+
const u = Ee(r) ? [r] : Ye(r), i = u.length, c = i - 1;
|
|
31
31
|
for (; ++s < i; ) {
|
|
32
32
|
const l = u[s];
|
|
33
33
|
let V = e;
|
|
34
34
|
if (s !== c) {
|
|
35
|
-
const
|
|
36
|
-
V =
|
|
35
|
+
const h = t[l];
|
|
36
|
+
V = H(h) || Array.isArray(h) ? h : isNaN(+u[s + 1]) ? {} : [];
|
|
37
37
|
}
|
|
38
38
|
if (l === "__proto__" || l === "constructor" || l === "prototype")
|
|
39
39
|
return;
|
|
@@ -44,7 +44,7 @@ const pe = {
|
|
|
44
44
|
BLUR: "blur",
|
|
45
45
|
FOCUS_OUT: "focusout",
|
|
46
46
|
CHANGE: "change"
|
|
47
|
-
},
|
|
47
|
+
}, re = {
|
|
48
48
|
onBlur: "onBlur",
|
|
49
49
|
onChange: "onChange",
|
|
50
50
|
onSubmit: "onSubmit",
|
|
@@ -58,11 +58,11 @@ const pe = {
|
|
|
58
58
|
pattern: "pattern",
|
|
59
59
|
required: "required",
|
|
60
60
|
validate: "validate"
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
const Ve = () => F.useContext(
|
|
61
|
+
}, Je = F.createContext(null);
|
|
62
|
+
Je.displayName = "HookFormContext";
|
|
63
|
+
const Ve = () => F.useContext(Je), tr = (t) => {
|
|
64
64
|
const { children: r, ...e } = t;
|
|
65
|
-
return F.createElement(
|
|
65
|
+
return F.createElement(Je.Provider, { value: e }, r);
|
|
66
66
|
};
|
|
67
67
|
var Et = (t, r, e, s = !0) => {
|
|
68
68
|
const u = {
|
|
@@ -72,7 +72,7 @@ var Et = (t, r, e, s = !0) => {
|
|
|
72
72
|
Object.defineProperty(u, i, {
|
|
73
73
|
get: () => {
|
|
74
74
|
const c = i;
|
|
75
|
-
return r._proxyFormState[c] !==
|
|
75
|
+
return r._proxyFormState[c] !== re.all && (r._proxyFormState[c] = !s || re.all), e && (e[c] = !0), t[c];
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
return u;
|
|
@@ -93,19 +93,19 @@ function rr(t) {
|
|
|
93
93
|
name: u,
|
|
94
94
|
formState: V.current,
|
|
95
95
|
exact: i,
|
|
96
|
-
callback: (
|
|
96
|
+
callback: (h) => {
|
|
97
97
|
!s && l({
|
|
98
98
|
...e._formState,
|
|
99
|
-
...
|
|
99
|
+
...h
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
}), [u, s, i]), F.useEffect(() => {
|
|
103
103
|
V.current.isValid && e._setValid(!0);
|
|
104
104
|
}, [e]), F.useMemo(() => Et(c, e, V.current, !1), [c, e]);
|
|
105
105
|
}
|
|
106
|
-
var X = (t) => typeof t == "string",
|
|
106
|
+
var X = (t) => typeof t == "string", qe = (t, r, e, s, u) => X(t) ? (s && r.watch.add(t), m(e, t, u)) : Array.isArray(t) ? t.map((i) => (s && r.watch.add(i), m(e, i))) : (s && (r.watchAll = !0), e), je = (t) => Q(t) || !pt(t);
|
|
107
107
|
function ae(t, r, e = /* @__PURE__ */ new WeakSet()) {
|
|
108
|
-
if (
|
|
108
|
+
if (je(t) || je(r))
|
|
109
109
|
return Object.is(t, r);
|
|
110
110
|
if (oe(t) && oe(r))
|
|
111
111
|
return t.getTime() === r.getTime();
|
|
@@ -121,54 +121,54 @@ function ae(t, r, e = /* @__PURE__ */ new WeakSet()) {
|
|
|
121
121
|
return !1;
|
|
122
122
|
if (i !== "ref") {
|
|
123
123
|
const l = r[i];
|
|
124
|
-
if (oe(c) && oe(l) ||
|
|
124
|
+
if (oe(c) && oe(l) || H(c) && H(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
|
-
function
|
|
131
|
-
const r = Ve(), { control: e = r.control, name: s, defaultValue: u, disabled: i, exact: c, compute: l } = t || {}, V = F.useRef(u),
|
|
132
|
-
|
|
130
|
+
function Xe(t) {
|
|
131
|
+
const r = Ve(), { control: e = r.control, name: s, defaultValue: u, disabled: i, exact: c, compute: l } = t || {}, V = F.useRef(u), h = F.useRef(l), k = F.useRef(void 0), g = F.useRef(e), S = F.useRef(s);
|
|
132
|
+
h.current = l;
|
|
133
133
|
const [p, I] = F.useState(() => {
|
|
134
134
|
const f = e._getWatch(s, V.current);
|
|
135
|
-
return
|
|
136
|
-
}),
|
|
137
|
-
const d =
|
|
138
|
-
return
|
|
139
|
-
}, [e._formValues, e._names, s]),
|
|
135
|
+
return h.current ? h.current(f) : f;
|
|
136
|
+
}), R = F.useCallback((f) => {
|
|
137
|
+
const d = qe(s, e._names, f || e._formValues, !1, V.current);
|
|
138
|
+
return h.current ? h.current(d) : d;
|
|
139
|
+
}, [e._formValues, e._names, s]), T = F.useCallback((f) => {
|
|
140
140
|
if (!i) {
|
|
141
|
-
const d =
|
|
142
|
-
if (
|
|
143
|
-
const A =
|
|
144
|
-
ae(A,
|
|
141
|
+
const d = qe(s, e._names, f || e._formValues, !1, V.current);
|
|
142
|
+
if (h.current) {
|
|
143
|
+
const A = h.current(d);
|
|
144
|
+
ae(A, k.current) || (I(A), k.current = A);
|
|
145
145
|
} else
|
|
146
146
|
I(d);
|
|
147
147
|
}
|
|
148
148
|
}, [e._formValues, e._names, i, s]);
|
|
149
|
-
ke(() => ((g.current !== e || !ae(S.current, s)) && (g.current = e, S.current = s,
|
|
149
|
+
ke(() => ((g.current !== e || !ae(S.current, s)) && (g.current = e, S.current = s, T()), 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
|
+
T(f.values);
|
|
157
157
|
}
|
|
158
|
-
})), [e, c, s,
|
|
159
|
-
const
|
|
158
|
+
})), [e, c, s, T]), F.useEffect(() => e._removeUnmounted());
|
|
159
|
+
const U = g.current !== e, x = S.current, B = F.useMemo(() => {
|
|
160
160
|
if (i)
|
|
161
161
|
return null;
|
|
162
|
-
const f = !
|
|
163
|
-
return
|
|
164
|
-
}, [i,
|
|
165
|
-
return
|
|
162
|
+
const f = !U && !ae(x, s);
|
|
163
|
+
return U || f ? R() : null;
|
|
164
|
+
}, [i, U, s, x, R]);
|
|
165
|
+
return B !== null ? B : p;
|
|
166
166
|
}
|
|
167
167
|
function sr(t) {
|
|
168
|
-
const r = Ve(), { name: e, disabled: s, control: u = r.control, shouldUnregister: i, defaultValue: c, exact: l = !0 } = t, V = St(u._names.array, e),
|
|
168
|
+
const r = Ve(), { name: e, disabled: s, control: u = r.control, shouldUnregister: i, defaultValue: c, exact: l = !0 } = t, V = St(u._names.array, e), h = F.useMemo(() => m(u._formValues, e, m(u._defaultValues, e, c)), [u, e, c]), k = Xe({
|
|
169
169
|
control: u,
|
|
170
170
|
name: e,
|
|
171
|
-
defaultValue:
|
|
171
|
+
defaultValue: h,
|
|
172
172
|
exact: l
|
|
173
173
|
}), g = rr({
|
|
174
174
|
control: u,
|
|
@@ -176,11 +176,11 @@ function sr(t) {
|
|
|
176
176
|
exact: l
|
|
177
177
|
}), S = F.useRef(t), p = F.useRef(void 0), I = F.useRef(u.register(e, {
|
|
178
178
|
...t.rules,
|
|
179
|
-
value:
|
|
179
|
+
value: k,
|
|
180
180
|
...J(t.disabled) ? { disabled: t.disabled } : {}
|
|
181
181
|
}));
|
|
182
182
|
S.current = t;
|
|
183
|
-
const
|
|
183
|
+
const R = F.useMemo(() => Object.defineProperties({}, {
|
|
184
184
|
invalid: {
|
|
185
185
|
enumerable: !0,
|
|
186
186
|
get: () => !!m(g.errors, e)
|
|
@@ -201,13 +201,13 @@ function sr(t) {
|
|
|
201
201
|
enumerable: !0,
|
|
202
202
|
get: () => m(g.errors, e)
|
|
203
203
|
}
|
|
204
|
-
}), [g, e]),
|
|
204
|
+
}), [g, e]), T = F.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]), U = F.useCallback(() => I.current.onBlur({
|
|
211
211
|
target: {
|
|
212
212
|
value: m(u._formValues, e),
|
|
213
213
|
name: e
|
|
@@ -216,32 +216,32 @@ function sr(t) {
|
|
|
216
216
|
}), [e, u._formValues]), x = F.useCallback((f) => {
|
|
217
217
|
const d = m(u._fields, e);
|
|
218
218
|
d && d._f && f && (d._f.ref = {
|
|
219
|
-
focus: () =>
|
|
220
|
-
select: () =>
|
|
221
|
-
setCustomValidity: (A) =>
|
|
222
|
-
reportValidity: () =>
|
|
219
|
+
focus: () => G(f.focus) && f.focus(),
|
|
220
|
+
select: () => G(f.select) && f.select(),
|
|
221
|
+
setCustomValidity: (A) => G(f.setCustomValidity) && f.setCustomValidity(A),
|
|
222
|
+
reportValidity: () => G(f.reportValidity) && f.reportValidity()
|
|
223
223
|
});
|
|
224
|
-
}, [u._fields, e]),
|
|
224
|
+
}, [u._fields, e]), B = F.useMemo(() => ({
|
|
225
225
|
name: e,
|
|
226
|
-
value:
|
|
226
|
+
value: k,
|
|
227
227
|
...J(s) || g.disabled ? { disabled: g.disabled || s } : {},
|
|
228
|
-
onChange:
|
|
229
|
-
onBlur:
|
|
228
|
+
onChange: T,
|
|
229
|
+
onBlur: U,
|
|
230
230
|
ref: x
|
|
231
|
-
}), [e, s, g.disabled,
|
|
231
|
+
}), [e, s, g.disabled, T, U, x, k]);
|
|
232
232
|
return F.useEffect(() => {
|
|
233
233
|
const f = u._options.shouldUnregister || i, d = p.current;
|
|
234
234
|
d && d !== e && !V && u.unregister(d), u.register(e, {
|
|
235
235
|
...S.current.rules,
|
|
236
236
|
...J(S.current.disabled) ? { disabled: S.current.disabled } : {}
|
|
237
237
|
});
|
|
238
|
-
const A = (
|
|
239
|
-
const K = m(u._fields,
|
|
240
|
-
K && K._f && (K._f.mount =
|
|
238
|
+
const A = (w, W) => {
|
|
239
|
+
const K = m(u._fields, w);
|
|
240
|
+
K && K._f && (K._f.mount = W);
|
|
241
241
|
};
|
|
242
242
|
if (A(e, !0), f) {
|
|
243
|
-
const
|
|
244
|
-
|
|
243
|
+
const w = M(m(u._options.defaultValues, e, S.current.defaultValue));
|
|
244
|
+
O(u._defaultValues, e, w), N(m(u._formValues, e)) && O(u._formValues, e, w);
|
|
245
245
|
}
|
|
246
246
|
return !V && u.register(e), p.current = e, () => {
|
|
247
247
|
(V ? f && !u._state.action : f) ? u.unregister(e) : A(e, !1);
|
|
@@ -252,10 +252,10 @@ function sr(t) {
|
|
|
252
252
|
name: e
|
|
253
253
|
});
|
|
254
254
|
}, [s, e, u]), F.useMemo(() => ({
|
|
255
|
-
field:
|
|
255
|
+
field: B,
|
|
256
256
|
formState: g,
|
|
257
|
-
fieldState:
|
|
258
|
-
}), [
|
|
257
|
+
fieldState: R
|
|
258
|
+
}), [B, g, R]);
|
|
259
259
|
}
|
|
260
260
|
const ar = (t) => t.render(sr(t));
|
|
261
261
|
var nr = (t, r, e, s, u) => r ? {
|
|
@@ -289,58 +289,58 @@ function wt(t, r) {
|
|
|
289
289
|
for (const s in t)
|
|
290
290
|
if (t.hasOwnProperty(s)) {
|
|
291
291
|
const u = t[s], i = r[s];
|
|
292
|
-
if (u &&
|
|
292
|
+
if (u && H(u) && i) {
|
|
293
293
|
const c = wt(u, i);
|
|
294
|
-
|
|
294
|
+
H(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 j = (t) => H(t) && !Object.keys(t).length, Ze = (t) => t.type === "file", xe = (t) => {
|
|
300
|
+
if (!Ke)
|
|
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
|
-
}, kt = (t) => t.type === "select-multiple",
|
|
304
|
+
}, kt = (t) => t.type === "select-multiple", et = (t) => t.type === "radio", ir = (t) => et(t) || ve(t), Ne = (t) => xe(t) && t.isConnected;
|
|
305
305
|
function ur(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 = N(t) ? s++ : t[r[s++]];
|
|
310
310
|
return t;
|
|
311
311
|
}
|
|
312
312
|
function or(t) {
|
|
313
313
|
for (const r in t)
|
|
314
|
-
if (t.hasOwnProperty(r) && !
|
|
314
|
+
if (t.hasOwnProperty(r) && !N(t[r]))
|
|
315
315
|
return !1;
|
|
316
316
|
return !0;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
319
|
-
const e = Array.isArray(r) ? r : Ee(r) ? [r] :
|
|
320
|
-
return s && delete s[i], u !== 0 && (
|
|
318
|
+
function P(t, r) {
|
|
319
|
+
const e = Array.isArray(r) ? r : Ee(r) ? [r] : Ye(r), s = e.length === 1 ? t : ur(t, e), u = e.length - 1, i = e[u];
|
|
320
|
+
return s && delete s[i], u !== 0 && (H(s) && j(s) || Array.isArray(s) && or(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 (G(t[r]))
|
|
325
325
|
return !0;
|
|
326
326
|
return !1;
|
|
327
327
|
};
|
|
328
328
|
function Ct(t) {
|
|
329
|
-
return Array.isArray(t) ||
|
|
329
|
+
return Array.isArray(t) || H(t) && !lr(t);
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function Ge(t, r = {}) {
|
|
332
332
|
for (const e in t) {
|
|
333
333
|
const s = t[e];
|
|
334
|
-
Ct(s) ? (r[e] = Array.isArray(s) ? [] : {},
|
|
334
|
+
Ct(s) ? (r[e] = Array.isArray(s) ? [] : {}, Ge(s, r[e])) : N(s) || (r[e] = !0);
|
|
335
335
|
}
|
|
336
336
|
return r;
|
|
337
337
|
}
|
|
338
338
|
function ce(t, r, e) {
|
|
339
|
-
e || (e =
|
|
339
|
+
e || (e = Ge(r));
|
|
340
340
|
for (const s in t) {
|
|
341
341
|
const u = t[s];
|
|
342
342
|
if (Ct(u))
|
|
343
|
-
|
|
343
|
+
N(r) || je(e[s]) ? e[s] = Ge(u, Array.isArray(u) ? [] : {}) : ce(u, Q(r) ? {} : r[s], e[s]);
|
|
344
344
|
else {
|
|
345
345
|
const i = r[s];
|
|
346
346
|
e[s] = !ae(u, i);
|
|
@@ -360,28 +360,28 @@ 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 && !N(t[0].attributes.value) ? N(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
|
+
}, Tt = (t, { valueAsNumber: r, valueAsDate: e, setValueAs: s }) => N(t) ? t : r ? t === "" ? NaN : t && +t : e && X(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 Ot = (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
|
|
378
|
+
return Ze(r) ? r.files : et(r) ? Ot(t.refs).value : kt(r) ? [...r.selectedOptions].map(({ value: e }) => e) : ve(r) ? Dt(t.refs).value : Tt(N(r.value) ? t.ref.value : r.value, t);
|
|
379
379
|
}
|
|
380
380
|
var cr = (t, r, e, s) => {
|
|
381
381
|
const u = {};
|
|
382
382
|
for (const i of t) {
|
|
383
383
|
const c = m(r, i);
|
|
384
|
-
c &&
|
|
384
|
+
c && O(u, i, c._f);
|
|
385
385
|
}
|
|
386
386
|
return {
|
|
387
387
|
criteriaMode: e,
|
|
@@ -389,15 +389,15 @@ var cr = (t, r, e, s) => {
|
|
|
389
389
|
fields: u,
|
|
390
390
|
shouldUseNativeValidation: s
|
|
391
391
|
};
|
|
392
|
-
}, Se = (t) => t instanceof RegExp,
|
|
393
|
-
isOnSubmit: !t || t ===
|
|
394
|
-
isOnBlur: t ===
|
|
395
|
-
isOnChange: t ===
|
|
396
|
-
isOnAll: t ===
|
|
397
|
-
isOnTouch: t ===
|
|
392
|
+
}, Se = (t) => t instanceof RegExp, he = (t) => N(t) ? t : Se(t) ? t.source : H(t) ? Se(t.value) ? t.value.source : t.value : t, de = (t) => ({
|
|
393
|
+
isOnSubmit: !t || t === re.onSubmit,
|
|
394
|
+
isOnBlur: t === re.onBlur,
|
|
395
|
+
isOnChange: t === re.onChange,
|
|
396
|
+
isOnAll: t === re.all,
|
|
397
|
+
isOnTouch: t === re.onTouched
|
|
398
398
|
});
|
|
399
399
|
const vt = "AsyncFunction";
|
|
400
|
-
var dr = (t) => !!t && !!t.validate && !!(
|
|
400
|
+
var dr = (t) => !!t && !!t.validate && !!(G(t.validate) && t.validate.constructor.name === vt || H(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
401
|
const fe = (t, r, e, s) => {
|
|
402
402
|
for (const u of e || Object.keys(t)) {
|
|
403
403
|
const i = m(t, u);
|
|
@@ -410,7 +410,7 @@ const fe = (t, r, e, s) => {
|
|
|
410
410
|
return !0;
|
|
411
411
|
if (fe(l, r))
|
|
412
412
|
break;
|
|
413
|
-
} else if (
|
|
413
|
+
} else if (H(l) && fe(l, r))
|
|
414
414
|
break;
|
|
415
415
|
}
|
|
416
416
|
}
|
|
@@ -446,10 +446,10 @@ function Vt(t, r, e) {
|
|
|
446
446
|
var yr = (t, r, e, s) => {
|
|
447
447
|
e(t);
|
|
448
448
|
const { name: u, ...i } = t;
|
|
449
|
-
return
|
|
450
|
-
}, mr = (t, r, e) => !t || !r || t === r || z(t).some((s) => s && (e ? s === r : s.startsWith(r) || r.startsWith(s))), _r = (t, r, e, s, u) => u.isOnAll ? !1 : !e && u.isOnTouch ? !(r || t) : (e ? s.isOnBlur : u.isOnBlur) ? !t : (e ? s.isOnChange : u.isOnChange) ? t : !0, gr = (t, r) => !we(m(t, r)).length &&
|
|
449
|
+
return j(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 || z(t).some((s) => s && (e ? s === r : s.startsWith(r) || r.startsWith(s))), _r = (t, r, e, s, u) => u.isOnAll ? !1 : !e && u.isOnTouch ? !(r || t) : (e ? s.isOnBlur : u.isOnBlur) ? !t : (e ? s.isOnChange : u.isOnChange) ? t : !0, gr = (t, r) => !we(m(t, r)).length && P(t, r), Rt = (t, r, e) => {
|
|
451
451
|
const s = z(m(t, e));
|
|
452
|
-
return
|
|
452
|
+
return O(s, "root", r[e]), O(t, e, s), t;
|
|
453
453
|
};
|
|
454
454
|
function Ft(t, r, e = "validate") {
|
|
455
455
|
if (X(t) || Array.isArray(t) && t.every(X) || J(t) && !t)
|
|
@@ -459,55 +459,55 @@ function Ft(t, r, e = "validate") {
|
|
|
459
459
|
ref: r
|
|
460
460
|
};
|
|
461
461
|
}
|
|
462
|
-
var le = (t) =>
|
|
462
|
+
var le = (t) => H(t) && !Se(t) ? t : {
|
|
463
463
|
value: t,
|
|
464
464
|
message: ""
|
|
465
|
-
},
|
|
466
|
-
const { ref: c, refs: l, required: V, maxLength:
|
|
467
|
-
if (!
|
|
465
|
+
}, ze = async (t, r, e, s, u, i) => {
|
|
466
|
+
const { ref: c, refs: l, required: V, maxLength: h, minLength: k, min: g, max: S, pattern: p, validate: I, name: R, valueAsNumber: T, mount: U } = t._f, x = m(e, R);
|
|
467
|
+
if (!U || r.has(R))
|
|
468
468
|
return {};
|
|
469
|
-
const
|
|
470
|
-
u &&
|
|
471
|
-
}, d = {}, A =
|
|
469
|
+
const B = l ? l[0] : c, f = (E) => {
|
|
470
|
+
u && B.reportValidity && (B.setCustomValidity(J(E) ? "" : E || ""), B.reportValidity());
|
|
471
|
+
}, d = {}, A = et(c), w = ve(c), W = A || w, K = (T || Ze(c)) && N(c.value) && N(x) || xe(c) && c.value === "" || x === "" || Array.isArray(x) && !x.length, Z = nr.bind(null, R, s, d), Fe = (E, C, $, q = ne.maxLength, se = ne.minLength) => {
|
|
472
472
|
const Y = E ? C : $;
|
|
473
|
-
d[
|
|
474
|
-
type: E ?
|
|
473
|
+
d[R] = {
|
|
474
|
+
type: E ? q : se,
|
|
475
475
|
message: Y,
|
|
476
476
|
ref: c,
|
|
477
|
-
...Z(E ?
|
|
477
|
+
...Z(E ? q : se, Y)
|
|
478
478
|
};
|
|
479
479
|
};
|
|
480
|
-
if (i ? !Array.isArray(x) || !x.length : V && (!
|
|
480
|
+
if (i ? !Array.isArray(x) || !x.length : V && (!W && (K || Q(x)) || J(x) && !x || w && !Dt(l).isValid || A && !Ot(l).isValid)) {
|
|
481
481
|
const { value: E, message: C } = X(V) ? { value: !!V, message: V } : le(V);
|
|
482
|
-
if (E && (d[
|
|
482
|
+
if (E && (d[R] = {
|
|
483
483
|
type: ne.required,
|
|
484
484
|
message: C,
|
|
485
|
-
ref:
|
|
485
|
+
ref: B,
|
|
486
486
|
...Z(ne.required, C)
|
|
487
487
|
}, !s))
|
|
488
488
|
return f(C), d;
|
|
489
489
|
}
|
|
490
|
-
if (!K && (!
|
|
490
|
+
if (!K && (!Q(g) || !Q(S))) {
|
|
491
491
|
let E, C;
|
|
492
|
-
const $ = le(S),
|
|
493
|
-
if (!
|
|
494
|
-
const
|
|
495
|
-
|
|
492
|
+
const $ = le(S), q = le(g);
|
|
493
|
+
if (!Q(x) && !isNaN(x)) {
|
|
494
|
+
const se = c.valueAsNumber || x && +x;
|
|
495
|
+
Q($.value) || (E = se > $.value), Q(q.value) || (C = se < q.value);
|
|
496
496
|
} else {
|
|
497
|
-
const
|
|
498
|
-
X($.value) && x && (E =
|
|
497
|
+
const se = c.valueAsDate || new Date(x), Y = (ge) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + ge), me = c.type == "time", _e = c.type == "week";
|
|
498
|
+
X($.value) && x && (E = me ? Y(x) > Y($.value) : _e ? x > $.value : se > new Date($.value)), X(q.value) && x && (C = me ? Y(x) < Y(q.value) : _e ? x < q.value : se < new Date(q.value));
|
|
499
499
|
}
|
|
500
|
-
if ((E || C) && (Fe(!!E, $.message,
|
|
501
|
-
return f(d[
|
|
500
|
+
if ((E || C) && (Fe(!!E, $.message, q.message, ne.max, ne.min), !s))
|
|
501
|
+
return f(d[R].message), d;
|
|
502
502
|
}
|
|
503
|
-
if ((
|
|
504
|
-
const E = le(
|
|
505
|
-
if (($ ||
|
|
506
|
-
return f(d[
|
|
503
|
+
if ((h || k) && !K && (X(x) || i && Array.isArray(x))) {
|
|
504
|
+
const E = le(h), C = le(k), $ = !Q(E.value) && x.length > +E.value, q = !Q(C.value) && x.length < +C.value;
|
|
505
|
+
if (($ || q) && (Fe($, E.message, C.message), !s))
|
|
506
|
+
return f(d[R].message), d;
|
|
507
507
|
}
|
|
508
508
|
if (p && !K && X(x)) {
|
|
509
509
|
const { value: E, message: C } = le(p);
|
|
510
|
-
if (Se(E) && !x.match(E) && (d[
|
|
510
|
+
if (Se(E) && !x.match(E) && (d[R] = {
|
|
511
511
|
type: ne.pattern,
|
|
512
512
|
message: C,
|
|
513
513
|
ref: c,
|
|
@@ -516,26 +516,26 @@ var le = (t) => W(t) && !Se(t) ? t : {
|
|
|
516
516
|
return f(C), d;
|
|
517
517
|
}
|
|
518
518
|
if (I) {
|
|
519
|
-
if (
|
|
520
|
-
const E = await I(x, e), C = Ft(E,
|
|
521
|
-
if (C && (d[
|
|
519
|
+
if (G(I)) {
|
|
520
|
+
const E = await I(x, e), C = Ft(E, B);
|
|
521
|
+
if (C && (d[R] = {
|
|
522
522
|
...C,
|
|
523
523
|
...Z(ne.validate, C.message)
|
|
524
524
|
}, !s))
|
|
525
525
|
return f(C.message), d;
|
|
526
|
-
} else if (
|
|
526
|
+
} else if (H(I)) {
|
|
527
527
|
let E = {};
|
|
528
528
|
for (const C in I) {
|
|
529
|
-
if (!
|
|
529
|
+
if (!j(E) && !s)
|
|
530
530
|
break;
|
|
531
|
-
const $ = Ft(await I[C](x, e),
|
|
531
|
+
const $ = Ft(await I[C](x, e), B, C);
|
|
532
532
|
$ && (E = {
|
|
533
533
|
...$,
|
|
534
534
|
...Z(C, $.message)
|
|
535
|
-
}, f($.message), s && (d[
|
|
535
|
+
}, f($.message), s && (d[R] = E));
|
|
536
536
|
}
|
|
537
|
-
if (!
|
|
538
|
-
ref:
|
|
537
|
+
if (!j(E) && (d[R] = {
|
|
538
|
+
ref: B,
|
|
539
539
|
...E
|
|
540
540
|
}, !s))
|
|
541
541
|
return d;
|
|
@@ -544,8 +544,8 @@ var le = (t) => W(t) && !Se(t) ? t : {
|
|
|
544
544
|
return f(!0), d;
|
|
545
545
|
};
|
|
546
546
|
const hr = {
|
|
547
|
-
mode:
|
|
548
|
-
reValidateMode:
|
|
547
|
+
mode: re.onSubmit,
|
|
548
|
+
reValidateMode: re.onChange,
|
|
549
549
|
shouldFocusError: !0
|
|
550
550
|
};
|
|
551
551
|
function vr(t = {}) {
|
|
@@ -556,7 +556,7 @@ function vr(t = {}) {
|
|
|
556
556
|
submitCount: 0,
|
|
557
557
|
isDirty: !1,
|
|
558
558
|
isReady: !1,
|
|
559
|
-
isLoading:
|
|
559
|
+
isLoading: G(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 = {}, u =
|
|
570
|
+
}, s = {}, u = H(r.defaultValues) || H(r.values) ? M(r.defaultValues || r.values) || {} : {}, i = r.shouldUnregister ? {} : M(u), 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
|
-
}, V,
|
|
582
|
-
const
|
|
581
|
+
}, V, h = 0;
|
|
582
|
+
const k = {
|
|
583
583
|
isDirty: !1,
|
|
584
584
|
dirtyFields: !1,
|
|
585
585
|
validatingFields: !1,
|
|
@@ -588,7 +588,7 @@ function vr(t = {}) {
|
|
|
588
588
|
isValid: !1,
|
|
589
589
|
errors: !1
|
|
590
590
|
}, g = {
|
|
591
|
-
...
|
|
591
|
+
...k
|
|
592
592
|
};
|
|
593
593
|
let S = {
|
|
594
594
|
...g
|
|
@@ -596,35 +596,35 @@ function vr(t = {}) {
|
|
|
596
596
|
const p = {
|
|
597
597
|
array: yt(),
|
|
598
598
|
state: yt()
|
|
599
|
-
}, I = r.criteriaMode ===
|
|
600
|
-
clearTimeout(
|
|
601
|
-
},
|
|
599
|
+
}, I = r.criteriaMode === re.all, R = (a) => (n) => {
|
|
600
|
+
clearTimeout(h), h = setTimeout(a, n);
|
|
601
|
+
}, T = async (a) => {
|
|
602
602
|
if (!c.keepIsValid && !r.disabled && (g.isValid || S.isValid || a)) {
|
|
603
603
|
let n;
|
|
604
|
-
r.resolver ? (n =
|
|
604
|
+
r.resolver ? (n = j((await W()).errors), U()) : n = await Z(s, !0), n !== e.isValid && p.state.next({
|
|
605
605
|
isValid: n
|
|
606
606
|
});
|
|
607
607
|
}
|
|
608
|
-
},
|
|
608
|
+
}, U = (a, n) => {
|
|
609
609
|
!r.disabled && (g.isValidating || g.validatingFields || S.isValidating || S.validatingFields) && ((a || Array.from(l.mount)).forEach((o) => {
|
|
610
|
-
o && (n ?
|
|
610
|
+
o && (n ? O(e.validatingFields, o, n) : P(e.validatingFields, o));
|
|
611
611
|
}), p.state.next({
|
|
612
612
|
validatingFields: e.validatingFields,
|
|
613
|
-
isValidating: !
|
|
613
|
+
isValidating: !j(e.validatingFields)
|
|
614
614
|
}));
|
|
615
|
-
}, x = (a, n = [], o,
|
|
616
|
-
if (
|
|
615
|
+
}, x = (a, n = [], o, v, _ = !0, y = !0) => {
|
|
616
|
+
if (v && o && !r.disabled) {
|
|
617
617
|
if (c.action = !0, y && Array.isArray(m(s, a))) {
|
|
618
|
-
const b = o(m(s, a),
|
|
619
|
-
_ &&
|
|
618
|
+
const b = o(m(s, a), v.argA, v.argB);
|
|
619
|
+
_ && O(s, a, b);
|
|
620
620
|
}
|
|
621
621
|
if (y && Array.isArray(m(e.errors, a))) {
|
|
622
|
-
const b = o(m(e.errors, a),
|
|
623
|
-
_ &&
|
|
622
|
+
const b = o(m(e.errors, a), v.argA, v.argB);
|
|
623
|
+
_ && O(e.errors, a, b), gr(e.errors, a);
|
|
624
624
|
}
|
|
625
625
|
if ((g.touchedFields || S.touchedFields) && y && Array.isArray(m(e.touchedFields, a))) {
|
|
626
|
-
const b = o(m(e.touchedFields, a),
|
|
627
|
-
_ &&
|
|
626
|
+
const b = o(m(e.touchedFields, a), v.argA, v.argB);
|
|
627
|
+
_ && O(e.touchedFields, a, b);
|
|
628
628
|
}
|
|
629
629
|
(g.dirtyFields || S.dirtyFields) && (e.dirtyFields = ce(u, i)), p.state.next({
|
|
630
630
|
name: a,
|
|
@@ -634,9 +634,9 @@ function vr(t = {}) {
|
|
|
634
634
|
isValid: e.isValid
|
|
635
635
|
});
|
|
636
636
|
} else
|
|
637
|
-
|
|
638
|
-
},
|
|
639
|
-
|
|
637
|
+
O(i, a, n);
|
|
638
|
+
}, B = (a, n) => {
|
|
639
|
+
O(e.errors, a, n), p.state.next({
|
|
640
640
|
errors: e.errors
|
|
641
641
|
});
|
|
642
642
|
}, f = (a) => {
|
|
@@ -644,35 +644,35 @@ function vr(t = {}) {
|
|
|
644
644
|
errors: e.errors,
|
|
645
645
|
isValid: !1
|
|
646
646
|
});
|
|
647
|
-
}, d = (a, n, o,
|
|
647
|
+
}, d = (a, n, o, v) => {
|
|
648
648
|
const _ = m(s, a);
|
|
649
649
|
if (_) {
|
|
650
|
-
const y = m(i, a,
|
|
651
|
-
|
|
650
|
+
const y = m(i, a, N(o) ? m(u, a) : o);
|
|
651
|
+
N(y) || v && v.defaultChecked || n ? O(i, a, n ? y : ht(_._f)) : q(a, y), c.mount && !c.action && T();
|
|
652
652
|
}
|
|
653
|
-
}, A = (a, n, o,
|
|
653
|
+
}, A = (a, n, o, v, _) => {
|
|
654
654
|
let y = !1, b = !1;
|
|
655
655
|
const D = {
|
|
656
656
|
name: a
|
|
657
657
|
};
|
|
658
658
|
if (!r.disabled) {
|
|
659
|
-
if (!o ||
|
|
659
|
+
if (!o || v) {
|
|
660
660
|
(g.isDirty || S.isDirty) && (b = e.isDirty, e.isDirty = D.isDirty = E(), y = b !== D.isDirty);
|
|
661
|
-
const
|
|
662
|
-
b = !!m(e.dirtyFields, a),
|
|
661
|
+
const L = ae(m(u, a), n);
|
|
662
|
+
b = !!m(e.dirtyFields, a), L ? P(e.dirtyFields, a) : O(e.dirtyFields, a, !0), D.dirtyFields = e.dirtyFields, y = y || (g.dirtyFields || S.dirtyFields) && b !== !L;
|
|
663
663
|
}
|
|
664
664
|
if (o) {
|
|
665
|
-
const
|
|
666
|
-
|
|
665
|
+
const L = m(e.touchedFields, a);
|
|
666
|
+
L || (O(e.touchedFields, a, o), D.touchedFields = e.touchedFields, y = y || (g.touchedFields || S.touchedFields) && L !== o);
|
|
667
667
|
}
|
|
668
668
|
y && _ && p.state.next(D);
|
|
669
669
|
}
|
|
670
670
|
return y ? D : {};
|
|
671
|
-
},
|
|
671
|
+
}, w = (a, n, o, v) => {
|
|
672
672
|
const _ = m(e.errors, a), y = (g.isValid || S.isValid) && J(n) && e.isValid !== n;
|
|
673
|
-
if (r.delayError && o ? (V =
|
|
673
|
+
if (r.delayError && o ? (V = R(() => B(a, o)), V(r.delayError)) : (clearTimeout(h), V = null, o ? O(e.errors, a, o) : P(e.errors, a)), (o ? !ae(_, o) : _) || !j(v) || y) {
|
|
674
674
|
const b = {
|
|
675
|
-
...
|
|
675
|
+
...v,
|
|
676
676
|
...y && J(n) ? { isValid: n } : {},
|
|
677
677
|
errors: e.errors,
|
|
678
678
|
name: a
|
|
@@ -682,12 +682,12 @@ function vr(t = {}) {
|
|
|
682
682
|
...b
|
|
683
683
|
}, p.state.next(b);
|
|
684
684
|
}
|
|
685
|
-
},
|
|
686
|
-
const { errors: n } = await
|
|
687
|
-
if (
|
|
685
|
+
}, W = async (a) => (U(a, !0), await r.resolver(i, r.context, cr(a || l.mount, s, r.criteriaMode, r.shouldUseNativeValidation))), K = async (a) => {
|
|
686
|
+
const { errors: n } = await W(a);
|
|
687
|
+
if (U(a), a)
|
|
688
688
|
for (const o of a) {
|
|
689
|
-
const
|
|
690
|
-
|
|
689
|
+
const v = m(n, o);
|
|
690
|
+
v ? O(e.errors, o, v) : P(e.errors, o);
|
|
691
691
|
}
|
|
692
692
|
else
|
|
693
693
|
e.errors = n;
|
|
@@ -695,170 +695,170 @@ function vr(t = {}) {
|
|
|
695
695
|
}, Z = async (a, n, o = {
|
|
696
696
|
valid: !0
|
|
697
697
|
}) => {
|
|
698
|
-
for (const
|
|
699
|
-
const _ = a[
|
|
698
|
+
for (const v in a) {
|
|
699
|
+
const _ = a[v];
|
|
700
700
|
if (_) {
|
|
701
701
|
const { _f: y, ...b } = _;
|
|
702
702
|
if (y) {
|
|
703
|
-
const D = l.array.has(y.name),
|
|
704
|
-
|
|
705
|
-
const ee = await
|
|
706
|
-
if (
|
|
703
|
+
const D = l.array.has(y.name), L = _._f && dr(_._f);
|
|
704
|
+
L && g.validatingFields && U([y.name], !0);
|
|
705
|
+
const ee = await ze(_, l.disabled, i, I, r.shouldUseNativeValidation && !n, D);
|
|
706
|
+
if (L && g.validatingFields && U([y.name]), ee[y.name] && (o.valid = !1, n))
|
|
707
707
|
break;
|
|
708
|
-
!n && (m(ee, y.name) ? D ?
|
|
708
|
+
!n && (m(ee, y.name) ? D ? Rt(e.errors, ee, y.name) : O(e.errors, y.name, ee[y.name]) : P(e.errors, y.name));
|
|
709
709
|
}
|
|
710
|
-
!
|
|
710
|
+
!j(b) && await Z(b, n, o);
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
713
|
return o.valid;
|
|
714
714
|
}, Fe = () => {
|
|
715
715
|
for (const a of l.unMount) {
|
|
716
716
|
const n = m(s, a);
|
|
717
|
-
n && (n._f.refs ? n._f.refs.every((o) => !
|
|
717
|
+
n && (n._f.refs ? n._f.refs.every((o) => !Ne(o)) : !Ne(n._f.ref)) && Ce(a);
|
|
718
718
|
}
|
|
719
719
|
l.unMount = /* @__PURE__ */ new Set();
|
|
720
|
-
}, E = (a, n) => !r.disabled && (a && n &&
|
|
721
|
-
...c.mount ? i :
|
|
722
|
-
}, o, n), $ = (a) => we(m(c.mount ? i : u, a, r.shouldUnregister ? m(u, a, []) : [])),
|
|
723
|
-
const
|
|
720
|
+
}, E = (a, n) => !r.disabled && (a && n && O(i, a, n), !ae(rt(), u)), C = (a, n, o) => qe(a, l, {
|
|
721
|
+
...c.mount ? i : N(n) ? u : X(a) ? { [a]: n } : n
|
|
722
|
+
}, o, n), $ = (a) => we(m(c.mount ? i : u, a, r.shouldUnregister ? m(u, a, []) : [])), q = (a, n, o = {}) => {
|
|
723
|
+
const v = m(s, a);
|
|
724
724
|
let _ = n;
|
|
725
|
-
if (
|
|
726
|
-
const y =
|
|
727
|
-
y && (!y.disabled &&
|
|
725
|
+
if (v) {
|
|
726
|
+
const y = v._f;
|
|
727
|
+
y && (!y.disabled && O(i, a, Tt(n, y)), _ = xe(y.ref) && Q(n) ? "" : n, kt(y.ref) ? [...y.ref.options].forEach((b) => b.selected = _.includes(b.value)) : y.refs ? ve(y.ref) ? y.refs.forEach((b) => {
|
|
728
728
|
(!b.defaultChecked || !b.disabled) && (Array.isArray(_) ? b.checked = !!_.find((D) => D === b.value) : b.checked = _ === b.value || !!_);
|
|
729
|
-
}) : y.refs.forEach((b) => b.checked = b.value === _) :
|
|
729
|
+
}) : y.refs.forEach((b) => b.checked = b.value === _) : Ze(y.ref) ? y.ref.value = "" : (y.ref.value = _, y.ref.type || p.state.next({
|
|
730
730
|
name: a,
|
|
731
|
-
values:
|
|
731
|
+
values: M(i)
|
|
732
732
|
})));
|
|
733
733
|
}
|
|
734
|
-
(o.shouldDirty || o.shouldTouch) && A(a, _, o.shouldTouch, o.shouldDirty, !0), o.shouldValidate &&
|
|
735
|
-
},
|
|
736
|
-
for (const
|
|
737
|
-
if (!n.hasOwnProperty(
|
|
734
|
+
(o.shouldDirty || o.shouldTouch) && A(a, _, o.shouldTouch, o.shouldDirty, !0), o.shouldValidate && ge(a);
|
|
735
|
+
}, se = (a, n, o) => {
|
|
736
|
+
for (const v in n) {
|
|
737
|
+
if (!n.hasOwnProperty(v))
|
|
738
738
|
return;
|
|
739
|
-
const _ = n[
|
|
740
|
-
(l.array.has(a) ||
|
|
739
|
+
const _ = n[v], y = a + "." + v, b = m(s, y);
|
|
740
|
+
(l.array.has(a) || H(_) || b && !b._f) && !oe(_) ? se(y, _, o) : q(y, _, o);
|
|
741
741
|
}
|
|
742
742
|
}, Y = (a, n, o = {}) => {
|
|
743
|
-
const
|
|
744
|
-
|
|
743
|
+
const v = m(s, a), _ = l.array.has(a), y = M(n);
|
|
744
|
+
O(i, a, y), _ ? (p.array.next({
|
|
745
745
|
name: a,
|
|
746
|
-
values:
|
|
746
|
+
values: M(i)
|
|
747
747
|
}), (g.isDirty || g.dirtyFields || S.isDirty || S.dirtyFields) && o.shouldDirty && p.state.next({
|
|
748
748
|
name: a,
|
|
749
749
|
dirtyFields: ce(u, i),
|
|
750
750
|
isDirty: E(a, y)
|
|
751
|
-
})) :
|
|
751
|
+
})) : v && !v._f && !Q(y) ? se(a, y, o) : q(a, y, o), Qe(a, l) && p.state.next({ ...e, name: a }), p.state.next({
|
|
752
752
|
name: c.mount ? a : void 0,
|
|
753
|
-
values:
|
|
753
|
+
values: M(i)
|
|
754
754
|
});
|
|
755
|
-
},
|
|
755
|
+
}, me = async (a) => {
|
|
756
756
|
c.mount = !0;
|
|
757
757
|
const n = a.target;
|
|
758
|
-
let o = n.name,
|
|
759
|
-
const _ = m(s, o), y = (
|
|
760
|
-
|
|
758
|
+
let o = n.name, v = !0;
|
|
759
|
+
const _ = m(s, o), y = (L) => {
|
|
760
|
+
v = Number.isNaN(L) || oe(L) && isNaN(L.getTime()) || ae(L, m(i, o, L));
|
|
761
761
|
}, b = de(r.mode), D = de(r.reValidateMode);
|
|
762
762
|
if (_) {
|
|
763
|
-
let
|
|
764
|
-
const be = n.type ? ht(_._f) : xt(a), ie = a.type === pe.BLUR || a.type === pe.FOCUS_OUT, qt = !fr(_._f) && !r.resolver && !m(e.errors, o) && !_._f.deps || _r(ie, m(e.touchedFields, o), e.isSubmitted, D, b),
|
|
765
|
-
|
|
766
|
-
const
|
|
763
|
+
let L, ee;
|
|
764
|
+
const be = n.type ? ht(_._f) : xt(a), ie = a.type === pe.BLUR || a.type === pe.FOCUS_OUT, qt = !fr(_._f) && !r.resolver && !m(e.errors, o) && !_._f.deps || _r(ie, m(e.touchedFields, o), e.isSubmitted, D, b), Oe = Qe(o, l, ie);
|
|
765
|
+
O(i, o, be), ie ? (!n || !n.readOnly) && (_._f.onBlur && _._f.onBlur(a), V && V(0)) : _._f.onChange && _._f.onChange(a);
|
|
766
|
+
const Re = A(o, be, ie), jt = !j(Re) || Oe;
|
|
767
767
|
if (!ie && p.state.next({
|
|
768
768
|
name: o,
|
|
769
769
|
type: a.type,
|
|
770
|
-
values:
|
|
770
|
+
values: M(i)
|
|
771
771
|
}), qt)
|
|
772
|
-
return (g.isValid || S.isValid) && (r.mode === "onBlur" ? ie &&
|
|
773
|
-
if (!ie &&
|
|
774
|
-
const { errors:
|
|
775
|
-
if (
|
|
776
|
-
const
|
|
777
|
-
|
|
772
|
+
return (g.isValid || S.isValid) && (r.mode === "onBlur" ? ie && T() : ie || T()), jt && p.state.next({ name: o, ...Oe ? {} : Re });
|
|
773
|
+
if (!ie && Oe && p.state.next({ ...e }), r.resolver) {
|
|
774
|
+
const { errors: dt } = await W([o]);
|
|
775
|
+
if (U([o]), y(be), v) {
|
|
776
|
+
const Gt = Vt(e.errors, s, o), ft = Vt(dt, s, Gt.name || o);
|
|
777
|
+
L = ft.error, o = ft.name, ee = j(dt);
|
|
778
778
|
}
|
|
779
779
|
} else
|
|
780
|
-
|
|
781
|
-
|
|
780
|
+
U([o], !0), L = (await ze(_, l.disabled, i, I, r.shouldUseNativeValidation))[o], U([o]), y(be), v && (L ? ee = !1 : (g.isValid || S.isValid) && (ee = await Z(s, !0)));
|
|
781
|
+
v && (_._f.deps && (!Array.isArray(_._f.deps) || _._f.deps.length > 0) && ge(_._f.deps), w(o, ee, L, Re));
|
|
782
782
|
}
|
|
783
|
-
},
|
|
783
|
+
}, _e = (a, n) => {
|
|
784
784
|
if (m(e.errors, n) && a.focus)
|
|
785
785
|
return a.focus(), 1;
|
|
786
|
-
},
|
|
787
|
-
let o,
|
|
786
|
+
}, ge = async (a, n = {}) => {
|
|
787
|
+
let o, v;
|
|
788
788
|
const _ = z(a);
|
|
789
789
|
if (r.resolver) {
|
|
790
|
-
const y = await K(
|
|
791
|
-
o =
|
|
792
|
-
} else a ? (
|
|
790
|
+
const y = await K(N(a) ? a : _);
|
|
791
|
+
o = j(y), v = a ? !_.some((b) => m(y, b)) : o;
|
|
792
|
+
} else a ? (v = (await Promise.all(_.map(async (y) => {
|
|
793
793
|
const b = m(s, y);
|
|
794
794
|
return await Z(b && b._f ? { [y]: b } : b);
|
|
795
|
-
}))).every(Boolean), !(!
|
|
795
|
+
}))).every(Boolean), !(!v && !e.isValid) && T()) : v = o = await Z(s);
|
|
796
796
|
return p.state.next({
|
|
797
797
|
...!X(a) || (g.isValid || S.isValid) && o !== e.isValid ? {} : { name: a },
|
|
798
798
|
...r.resolver || !a ? { isValid: o } : {},
|
|
799
799
|
errors: e.errors
|
|
800
|
-
}), n.shouldFocus && !
|
|
801
|
-
},
|
|
800
|
+
}), n.shouldFocus && !v && fe(s, _e, a ? _ : l.mount), v;
|
|
801
|
+
}, rt = (a, n) => {
|
|
802
802
|
let o = {
|
|
803
803
|
...c.mount ? i : u
|
|
804
804
|
};
|
|
805
|
-
return n && (o = wt(n.dirtyFields ? e.dirtyFields : e.touchedFields, o)),
|
|
806
|
-
},
|
|
805
|
+
return n && (o = wt(n.dirtyFields ? e.dirtyFields : e.touchedFields, o)), N(a) ? o : X(a) ? m(o, a) : a.map((v) => m(o, v));
|
|
806
|
+
}, st = (a, n) => ({
|
|
807
807
|
invalid: !!m((n || e).errors, a),
|
|
808
808
|
isDirty: !!m((n || e).dirtyFields, a),
|
|
809
809
|
error: m((n || e).errors, a),
|
|
810
810
|
isValidating: !!m(e.validatingFields, a),
|
|
811
811
|
isTouched: !!m((n || e).touchedFields, a)
|
|
812
812
|
}), Mt = (a) => {
|
|
813
|
-
a && z(a).forEach((n) =>
|
|
813
|
+
a && z(a).forEach((n) => P(e.errors, n)), p.state.next({
|
|
814
814
|
errors: a ? e.errors : {}
|
|
815
815
|
});
|
|
816
|
-
},
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
...
|
|
816
|
+
}, at = (a, n, o) => {
|
|
817
|
+
const v = (m(s, a, { _f: {} })._f || {}).ref, _ = m(e.errors, a) || {}, { ref: y, message: b, type: D, ...L } = _;
|
|
818
|
+
O(e.errors, a, {
|
|
819
|
+
...L,
|
|
820
820
|
...n,
|
|
821
|
-
ref:
|
|
821
|
+
ref: v
|
|
822
822
|
}), p.state.next({
|
|
823
823
|
name: a,
|
|
824
824
|
errors: e.errors,
|
|
825
825
|
isValid: !1
|
|
826
|
-
}), o && o.shouldFocus &&
|
|
827
|
-
}, It = (a, n) =>
|
|
826
|
+
}), o && o.shouldFocus && v && v.focus && v.focus();
|
|
827
|
+
}, It = (a, n) => G(a) ? p.state.subscribe({
|
|
828
828
|
next: (o) => "values" in o && a(C(void 0, n), o)
|
|
829
|
-
}) : C(a, n, !0),
|
|
829
|
+
}) : C(a, n, !0), nt = (a) => p.state.subscribe({
|
|
830
830
|
next: (n) => {
|
|
831
|
-
mr(a.name, n.name, a.exact) && yr(n, a.formState || g,
|
|
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
835
|
defaultValues: u
|
|
836
836
|
});
|
|
837
837
|
}
|
|
838
|
-
}).unsubscribe,
|
|
838
|
+
}).unsubscribe, Bt = (a) => (c.mount = !0, S = {
|
|
839
839
|
...S,
|
|
840
840
|
...a.formState
|
|
841
|
-
},
|
|
841
|
+
}, nt({
|
|
842
842
|
...a,
|
|
843
843
|
formState: {
|
|
844
|
-
...
|
|
844
|
+
...k,
|
|
845
845
|
...a.formState
|
|
846
846
|
}
|
|
847
847
|
})), Ce = (a, n = {}) => {
|
|
848
848
|
for (const o of a ? z(a) : l.mount)
|
|
849
|
-
l.mount.delete(o), l.array.delete(o), n.keepValue || (
|
|
849
|
+
l.mount.delete(o), l.array.delete(o), n.keepValue || (P(s, o), P(i, o)), !n.keepError && P(e.errors, o), !n.keepDirty && P(e.dirtyFields, o), !n.keepTouched && P(e.touchedFields, o), !n.keepIsValidating && P(e.validatingFields, o), !r.shouldUnregister && !n.keepDefaultValue && P(u, o);
|
|
850
850
|
p.state.next({
|
|
851
|
-
values:
|
|
851
|
+
values: M(i)
|
|
852
852
|
}), p.state.next({
|
|
853
853
|
...e,
|
|
854
854
|
...n.keepDirty ? { isDirty: E() } : {}
|
|
855
|
-
}), !n.keepIsValid &&
|
|
856
|
-
},
|
|
855
|
+
}), !n.keepIsValid && T();
|
|
856
|
+
}, it = ({ disabled: a, name: n }) => {
|
|
857
857
|
(J(a) && c.mount || a || l.disabled.has(n)) && (a ? l.disabled.add(n) : l.disabled.delete(n));
|
|
858
858
|
}, De = (a, n = {}) => {
|
|
859
859
|
let o = m(s, a);
|
|
860
|
-
const
|
|
861
|
-
return
|
|
860
|
+
const v = J(n.disabled) || J(r.disabled);
|
|
861
|
+
return O(s, a, {
|
|
862
862
|
...o || {},
|
|
863
863
|
_f: {
|
|
864
864
|
...o && o._f ? o._f : { ref: { name: a } },
|
|
@@ -866,34 +866,34 @@ function vr(t = {}) {
|
|
|
866
866
|
mount: !0,
|
|
867
867
|
...n
|
|
868
868
|
}
|
|
869
|
-
}), l.mount.add(a), o ?
|
|
869
|
+
}), l.mount.add(a), o ? it({
|
|
870
870
|
disabled: J(n.disabled) ? n.disabled : r.disabled,
|
|
871
871
|
name: a
|
|
872
872
|
}) : d(a, !0, n.value), {
|
|
873
|
-
...
|
|
873
|
+
...v ? { 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: he(n.min),
|
|
877
|
+
max: he(n.max),
|
|
878
|
+
minLength: he(n.minLength),
|
|
879
|
+
maxLength: he(n.maxLength),
|
|
880
|
+
pattern: he(n.pattern)
|
|
881
881
|
} : {},
|
|
882
882
|
name: a,
|
|
883
|
-
onChange:
|
|
884
|
-
onBlur:
|
|
883
|
+
onChange: me,
|
|
884
|
+
onBlur: me,
|
|
885
885
|
ref: (_) => {
|
|
886
886
|
if (_) {
|
|
887
887
|
De(a, n), o = m(s, a);
|
|
888
|
-
const y =
|
|
889
|
-
if (b ? D.find((
|
|
888
|
+
const y = N(_.value) && _.querySelectorAll && _.querySelectorAll("input,select,textarea")[0] || _, b = ir(y), D = o._f.refs || [];
|
|
889
|
+
if (b ? D.find((L) => L === y) : y === o._f.ref)
|
|
890
890
|
return;
|
|
891
|
-
|
|
891
|
+
O(s, a, {
|
|
892
892
|
_f: {
|
|
893
893
|
...o._f,
|
|
894
894
|
...b ? {
|
|
895
895
|
refs: [
|
|
896
|
-
...D.filter(
|
|
896
|
+
...D.filter(Ne),
|
|
897
897
|
y,
|
|
898
898
|
...Array.isArray(m(u, a)) ? [{}] : []
|
|
899
899
|
],
|
|
@@ -905,50 +905,50 @@ function vr(t = {}) {
|
|
|
905
905
|
o = m(s, a, {}), o._f && (o._f.mount = !1), (r.shouldUnregister || n.shouldUnregister) && !(St(l.array, a) && c.action) && l.unMount.add(a);
|
|
906
906
|
}
|
|
907
907
|
};
|
|
908
|
-
},
|
|
908
|
+
}, Te = () => r.shouldFocusError && fe(s, _e, l.mount), Pt = (a) => {
|
|
909
909
|
J(a) && (p.state.next({ disabled: a }), fe(s, (n, o) => {
|
|
910
|
-
const
|
|
911
|
-
|
|
912
|
-
_.disabled =
|
|
910
|
+
const v = m(s, o);
|
|
911
|
+
v && (n.disabled = v._f.disabled || a, Array.isArray(v._f.refs) && v._f.refs.forEach((_) => {
|
|
912
|
+
_.disabled = v._f.disabled || a;
|
|
913
913
|
}));
|
|
914
914
|
}, 0, !1));
|
|
915
|
-
},
|
|
916
|
-
let
|
|
915
|
+
}, ut = (a, n) => async (o) => {
|
|
916
|
+
let v;
|
|
917
917
|
o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
|
|
918
|
-
let _ =
|
|
918
|
+
let _ = M(i);
|
|
919
919
|
if (p.state.next({
|
|
920
920
|
isSubmitting: !0
|
|
921
921
|
}), r.resolver) {
|
|
922
|
-
const { errors: y, values: b } = await
|
|
923
|
-
|
|
922
|
+
const { errors: y, values: b } = await W();
|
|
923
|
+
U(), e.errors = y, _ = M(b);
|
|
924
924
|
} else
|
|
925
925
|
await Z(s);
|
|
926
926
|
if (l.disabled.size)
|
|
927
927
|
for (const y of l.disabled)
|
|
928
|
-
|
|
929
|
-
if (
|
|
928
|
+
P(_, y);
|
|
929
|
+
if (P(e.errors, "root"), j(e.errors)) {
|
|
930
930
|
p.state.next({
|
|
931
931
|
errors: {}
|
|
932
932
|
});
|
|
933
933
|
try {
|
|
934
934
|
await a(_, o);
|
|
935
935
|
} catch (y) {
|
|
936
|
-
|
|
936
|
+
v = y;
|
|
937
937
|
}
|
|
938
938
|
} else
|
|
939
|
-
n && await n({ ...e.errors }, o),
|
|
939
|
+
n && await n({ ...e.errors }, o), Te(), setTimeout(Te);
|
|
940
940
|
if (p.state.next({
|
|
941
941
|
isSubmitted: !0,
|
|
942
942
|
isSubmitting: !1,
|
|
943
|
-
isSubmitSuccessful:
|
|
943
|
+
isSubmitSuccessful: j(e.errors) && !v,
|
|
944
944
|
submitCount: e.submitCount + 1,
|
|
945
945
|
errors: e.errors
|
|
946
|
-
}),
|
|
947
|
-
throw
|
|
946
|
+
}), v)
|
|
947
|
+
throw v;
|
|
948
948
|
}, Wt = (a, n = {}) => {
|
|
949
|
-
m(s, a) && (
|
|
950
|
-
},
|
|
951
|
-
const o = a ?
|
|
949
|
+
m(s, a) && (N(n.defaultValue) ? Y(a, M(m(u, a))) : (Y(a, n.defaultValue), O(u, a, M(n.defaultValue))), n.keepTouched || P(e.touchedFields, a), n.keepDirty || (P(e.dirtyFields, a), e.isDirty = n.defaultValue ? E(a, M(m(u, a))) : E()), n.keepError || (P(e.errors, a), g.isValid && T()), p.state.next({ ...e }));
|
|
950
|
+
}, ot = (a, n = {}) => {
|
|
951
|
+
const o = a ? M(a) : u, v = M(o), _ = j(a), y = _ ? u : v;
|
|
952
952
|
if (n.keepDefaultValues || (u = o), !n.keepValues) {
|
|
953
953
|
if (n.keepDirtyValues) {
|
|
954
954
|
const b = /* @__PURE__ */ new Set([
|
|
@@ -956,15 +956,15 @@ function vr(t = {}) {
|
|
|
956
956
|
...Object.keys(ce(u, i))
|
|
957
957
|
]);
|
|
958
958
|
for (const D of Array.from(b))
|
|
959
|
-
m(e.dirtyFields, D) ?
|
|
959
|
+
m(e.dirtyFields, D) ? O(y, D, m(i, D)) : Y(D, m(y, D));
|
|
960
960
|
} else {
|
|
961
|
-
if (
|
|
961
|
+
if (Ke && N(a))
|
|
962
962
|
for (const b of l.mount) {
|
|
963
963
|
const D = m(s, b);
|
|
964
964
|
if (D && D._f) {
|
|
965
|
-
const
|
|
966
|
-
if (xe(
|
|
967
|
-
const ee =
|
|
965
|
+
const L = Array.isArray(D._f.refs) ? D._f.refs[0] : D._f.ref;
|
|
966
|
+
if (xe(L)) {
|
|
967
|
+
const ee = L.closest("form");
|
|
968
968
|
if (ee) {
|
|
969
969
|
ee.reset();
|
|
970
970
|
break;
|
|
@@ -978,7 +978,7 @@ function vr(t = {}) {
|
|
|
978
978
|
else
|
|
979
979
|
s = {};
|
|
980
980
|
}
|
|
981
|
-
i = r.shouldUnregister ? n.keepDefaultValues ?
|
|
981
|
+
i = r.shouldUnregister ? n.keepDefaultValues ? M(u) : {} : M(y), p.array.next({
|
|
982
982
|
values: { ...y }
|
|
983
983
|
}), p.state.next({
|
|
984
984
|
values: { ...y }
|
|
@@ -992,7 +992,7 @@ function vr(t = {}) {
|
|
|
992
992
|
watch: /* @__PURE__ */ new Set(),
|
|
993
993
|
watchAll: !1,
|
|
994
994
|
focus: ""
|
|
995
|
-
}, c.mount = !g.isValid || !!n.keepIsValid || !!n.keepDirtyValues || !r.shouldUnregister && !
|
|
995
|
+
}, c.mount = !g.isValid || !!n.keepIsValid || !!n.keepDirtyValues || !r.shouldUnregister && !j(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
997
|
isDirty: _ ? !1 : n.keepDirty ? e.isDirty : !!(n.keepDefaultValues && !ae(a, u)),
|
|
998
998
|
isSubmitted: n.keepIsSubmitted ? e.isSubmitted : !1,
|
|
@@ -1003,45 +1003,45 @@ function vr(t = {}) {
|
|
|
1003
1003
|
isSubmitting: !1,
|
|
1004
1004
|
defaultValues: u
|
|
1005
1005
|
});
|
|
1006
|
-
},
|
|
1007
|
-
const o = m(s, a),
|
|
1008
|
-
if (
|
|
1009
|
-
const _ =
|
|
1006
|
+
}, lt = (a, n) => ot(G(a) ? a(i) : a, { ...r.resetOptions, ...n }), Ht = (a, n = {}) => {
|
|
1007
|
+
const o = m(s, a), v = o && o._f;
|
|
1008
|
+
if (v) {
|
|
1009
|
+
const _ = v.refs ? v.refs[0] : v.ref;
|
|
1010
1010
|
_.focus && setTimeout(() => {
|
|
1011
|
-
_.focus(), n.shouldSelect &&
|
|
1011
|
+
_.focus(), n.shouldSelect && G(_.select) && _.select();
|
|
1012
1012
|
});
|
|
1013
1013
|
}
|
|
1014
|
-
},
|
|
1014
|
+
}, $t = (a) => {
|
|
1015
1015
|
e = {
|
|
1016
1016
|
...e,
|
|
1017
1017
|
...a
|
|
1018
1018
|
};
|
|
1019
|
-
},
|
|
1019
|
+
}, ct = {
|
|
1020
1020
|
control: {
|
|
1021
1021
|
register: De,
|
|
1022
1022
|
unregister: Ce,
|
|
1023
|
-
getFieldState:
|
|
1024
|
-
handleSubmit:
|
|
1025
|
-
setError:
|
|
1026
|
-
_subscribe:
|
|
1027
|
-
_runSchema:
|
|
1028
|
-
_updateIsValidating:
|
|
1029
|
-
_focusError:
|
|
1023
|
+
getFieldState: st,
|
|
1024
|
+
handleSubmit: ut,
|
|
1025
|
+
setError: at,
|
|
1026
|
+
_subscribe: nt,
|
|
1027
|
+
_runSchema: W,
|
|
1028
|
+
_updateIsValidating: U,
|
|
1029
|
+
_focusError: Te,
|
|
1030
1030
|
_getWatch: C,
|
|
1031
1031
|
_getDirty: E,
|
|
1032
|
-
_setValid:
|
|
1032
|
+
_setValid: T,
|
|
1033
1033
|
_setFieldArray: x,
|
|
1034
|
-
_setDisabledField:
|
|
1034
|
+
_setDisabledField: it,
|
|
1035
1035
|
_setErrors: f,
|
|
1036
1036
|
_getFieldArray: $,
|
|
1037
|
-
_reset:
|
|
1038
|
-
_resetDefaultValues: () =>
|
|
1039
|
-
|
|
1037
|
+
_reset: ot,
|
|
1038
|
+
_resetDefaultValues: () => G(r.defaultValues) && r.defaultValues().then((a) => {
|
|
1039
|
+
lt(a, r.resetOptions), p.state.next({
|
|
1040
1040
|
isLoading: !1
|
|
1041
1041
|
});
|
|
1042
1042
|
}),
|
|
1043
1043
|
_removeUnmounted: Fe,
|
|
1044
|
-
_disableForm:
|
|
1044
|
+
_disableForm: Pt,
|
|
1045
1045
|
_subjects: p,
|
|
1046
1046
|
_proxyFormState: g,
|
|
1047
1047
|
get _fields() {
|
|
@@ -1078,24 +1078,24 @@ function vr(t = {}) {
|
|
|
1078
1078
|
};
|
|
1079
1079
|
}
|
|
1080
1080
|
},
|
|
1081
|
-
subscribe:
|
|
1082
|
-
trigger:
|
|
1081
|
+
subscribe: Bt,
|
|
1082
|
+
trigger: ge,
|
|
1083
1083
|
register: De,
|
|
1084
|
-
handleSubmit:
|
|
1084
|
+
handleSubmit: ut,
|
|
1085
1085
|
watch: It,
|
|
1086
1086
|
setValue: Y,
|
|
1087
|
-
getValues:
|
|
1088
|
-
reset:
|
|
1087
|
+
getValues: rt,
|
|
1088
|
+
reset: lt,
|
|
1089
1089
|
resetField: Wt,
|
|
1090
1090
|
clearErrors: Mt,
|
|
1091
1091
|
unregister: Ce,
|
|
1092
|
-
setError:
|
|
1093
|
-
setFocus:
|
|
1094
|
-
getFieldState:
|
|
1092
|
+
setError: at,
|
|
1093
|
+
setFocus: Ht,
|
|
1094
|
+
getFieldState: st
|
|
1095
1095
|
};
|
|
1096
1096
|
return {
|
|
1097
|
-
...
|
|
1098
|
-
formControl:
|
|
1097
|
+
...ct,
|
|
1098
|
+
formControl: ct
|
|
1099
1099
|
};
|
|
1100
1100
|
}
|
|
1101
1101
|
var ue = () => {
|
|
@@ -1106,19 +1106,19 @@ 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
|
-
},
|
|
1109
|
+
}, Ue = (t, r, e = {}) => e.shouldFocus || N(e.shouldFocus) ? e.focusName || `${t}.${N(e.focusIndex) ? r : e.focusIndex}.` : "", Me = (t, r) => [
|
|
1110
1110
|
...t,
|
|
1111
1111
|
...z(r)
|
|
1112
|
-
],
|
|
1112
|
+
], Ie = (t) => Array.isArray(t) ? t.map(() => {
|
|
1113
1113
|
}) : void 0;
|
|
1114
|
-
function
|
|
1114
|
+
function Be(t, r, e) {
|
|
1115
1115
|
return [
|
|
1116
1116
|
...t.slice(0, r),
|
|
1117
1117
|
...z(e),
|
|
1118
1118
|
...t.slice(r)
|
|
1119
1119
|
];
|
|
1120
1120
|
}
|
|
1121
|
-
var Pe = (t, r, e) => Array.isArray(t) ? (
|
|
1121
|
+
var Pe = (t, r, e) => Array.isArray(t) ? (N(t[e]) && (t[e] = void 0), t.splice(e, 0, t.splice(r, 1)[0]), t) : [], We = (t, r) => [
|
|
1122
1122
|
...z(r),
|
|
1123
1123
|
...z(t)
|
|
1124
1124
|
];
|
|
@@ -1129,107 +1129,107 @@ function Vr(t, r) {
|
|
|
1129
1129
|
s.splice(u - e, 1), e++;
|
|
1130
1130
|
return we(s).length ? s : [];
|
|
1131
1131
|
}
|
|
1132
|
-
var
|
|
1132
|
+
var He = (t, r) => N(r) ? [] : Vr(t, z(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 = Ve(), { control: e = r.control, name: s, keyName: u = "id", shouldUnregister: i, rules: c } = t, [l, V] = F.useState(e._getFieldArray(s)),
|
|
1136
|
+
const r = Ve(), { control: e = r.control, name: s, keyName: u = "id", shouldUnregister: i, rules: c } = t, [l, V] = F.useState(e._getFieldArray(s)), h = F.useRef(e._getFieldArray(s).map(ue)), k = F.useRef(!1);
|
|
1137
1137
|
e._names.array.add(s), F.useMemo(() => c && l.length >= 0 && e.register(s, c), [e, s, l.length, c]), ke(() => 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) && (V(A),
|
|
1141
|
+
Array.isArray(A) && (V(A), h.current = A.map(ue));
|
|
1142
1142
|
}
|
|
1143
1143
|
}
|
|
1144
1144
|
}).unsubscribe, [e, s]);
|
|
1145
1145
|
const g = F.useCallback((f) => {
|
|
1146
|
-
|
|
1146
|
+
k.current = !0, e._setFieldArray(s, f);
|
|
1147
1147
|
}, [e, s]), S = (f, d) => {
|
|
1148
|
-
const A = z(
|
|
1149
|
-
e._names.focus =
|
|
1150
|
-
argA:
|
|
1148
|
+
const A = z(M(f)), w = Me(e._getFieldArray(s), A);
|
|
1149
|
+
e._names.focus = Ue(s, w.length - 1, d), h.current = Me(h.current, A.map(ue)), g(w), V(w), e._setFieldArray(s, w, Me, {
|
|
1150
|
+
argA: Ie(f)
|
|
1151
1151
|
});
|
|
1152
1152
|
}, p = (f, d) => {
|
|
1153
|
-
const A = z(
|
|
1154
|
-
e._names.focus =
|
|
1155
|
-
argA:
|
|
1153
|
+
const A = z(M(f)), w = We(e._getFieldArray(s), A);
|
|
1154
|
+
e._names.focus = Ue(s, 0, d), h.current = We(h.current, A.map(ue)), g(w), V(w), e._setFieldArray(s, w, We, {
|
|
1155
|
+
argA: Ie(f)
|
|
1156
1156
|
});
|
|
1157
1157
|
}, I = (f) => {
|
|
1158
|
-
const d =
|
|
1159
|
-
|
|
1158
|
+
const d = He(e._getFieldArray(s), f);
|
|
1159
|
+
h.current = He(h.current, f), g(d), V(d), !Array.isArray(m(e._fields, s)) && O(e._fields, s, void 0), e._setFieldArray(s, d, He, {
|
|
1160
1160
|
argA: f
|
|
1161
1161
|
});
|
|
1162
|
-
},
|
|
1163
|
-
const
|
|
1164
|
-
e._names.focus =
|
|
1162
|
+
}, R = (f, d, A) => {
|
|
1163
|
+
const w = z(M(d)), W = Be(e._getFieldArray(s), f, w);
|
|
1164
|
+
e._names.focus = Ue(s, f, A), h.current = Be(h.current, f, w.map(ue)), g(W), V(W), e._setFieldArray(s, W, Be, {
|
|
1165
1165
|
argA: f,
|
|
1166
|
-
argB:
|
|
1166
|
+
argB: Ie(d)
|
|
1167
1167
|
});
|
|
1168
|
-
},
|
|
1168
|
+
}, T = (f, d) => {
|
|
1169
1169
|
const A = e._getFieldArray(s);
|
|
1170
|
-
$e(A, f, d), $e(
|
|
1170
|
+
$e(A, f, d), $e(h.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
|
+
}, U = (f, d) => {
|
|
1175
1175
|
const A = e._getFieldArray(s);
|
|
1176
|
-
Pe(A, f, d), Pe(
|
|
1176
|
+
Pe(A, f, d), Pe(h.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 =
|
|
1182
|
-
|
|
1181
|
+
const A = M(d), w = bt(e._getFieldArray(s), f, A);
|
|
1182
|
+
h.current = [...w].map((W, K) => !W || K === f ? ue() : h.current[K]), g(w), V([...w]), e._setFieldArray(s, w, bt, {
|
|
1183
1183
|
argA: f,
|
|
1184
1184
|
argB: A
|
|
1185
1185
|
}, !0, !1);
|
|
1186
|
-
},
|
|
1187
|
-
const d = z(
|
|
1188
|
-
|
|
1186
|
+
}, B = (f) => {
|
|
1187
|
+
const d = z(M(f));
|
|
1188
|
+
h.current = d.map(ue), g([...d]), V([...d]), e._setFieldArray(s, [...d], (A) => A, {}, !0, !1);
|
|
1189
1189
|
};
|
|
1190
1190
|
return F.useEffect(() => {
|
|
1191
1191
|
if (e._state.action = !1, Qe(s, e._names) && e._subjects.state.next({
|
|
1192
1192
|
...e._formState
|
|
1193
|
-
}),
|
|
1193
|
+
}), k.current && (!de(e._options.mode).isOnSubmit || e._formState.isSubmitted) && !de(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 ? O(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 && !(de(e._options.reValidateMode).isOnSubmit && de(e._options.mode).isOnSubmit) &&
|
|
1205
|
-
errors:
|
|
1204
|
+
f && f._f && !(de(e._options.reValidateMode).isOnSubmit && de(e._options.mode).isOnSubmit) && ze(f, e._names.disabled, e._formValues, e._options.criteriaMode === re.all, e._options.shouldUseNativeValidation, !0).then((d) => !j(d) && e._subjects.state.next({
|
|
1205
|
+
errors: Rt(e._formState.errors, d, s)
|
|
1206
1206
|
}));
|
|
1207
1207
|
}
|
|
1208
1208
|
e._subjects.state.next({
|
|
1209
1209
|
name: s,
|
|
1210
|
-
values:
|
|
1210
|
+
values: M(e._formValues)
|
|
1211
1211
|
}), e._names.focus && fe(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(),
|
|
1214
|
+
}), e._names.focus = "", e._setValid(), k.current = !1;
|
|
1215
1215
|
}, [l, s, e]), F.useEffect(() => (!m(e._formValues, s) && e._setFieldArray(s), () => {
|
|
1216
1216
|
const f = (d, A) => {
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1217
|
+
const w = m(e._fields, d);
|
|
1218
|
+
w && w._f && (w._f.mount = A);
|
|
1219
1219
|
};
|
|
1220
1220
|
e._options.shouldUnregister || i ? e.unregister(s) : f(s, !1);
|
|
1221
1221
|
}), [s, e, u, i]), {
|
|
1222
|
-
swap: F.useCallback(
|
|
1223
|
-
move: F.useCallback(
|
|
1222
|
+
swap: F.useCallback(T, [g, s, e]),
|
|
1223
|
+
move: F.useCallback(U, [g, s, e]),
|
|
1224
1224
|
prepend: F.useCallback(p, [g, s, e]),
|
|
1225
1225
|
append: F.useCallback(S, [g, s, e]),
|
|
1226
1226
|
remove: F.useCallback(I, [g, s, e]),
|
|
1227
|
-
insert: F.useCallback(
|
|
1227
|
+
insert: F.useCallback(R, [g, s, e]),
|
|
1228
1228
|
update: F.useCallback(x, [g, s, e]),
|
|
1229
|
-
replace: F.useCallback(
|
|
1229
|
+
replace: F.useCallback(B, [g, s, e]),
|
|
1230
1230
|
fields: F.useMemo(() => l.map((f, d) => ({
|
|
1231
1231
|
...f,
|
|
1232
|
-
[u]:
|
|
1232
|
+
[u]: h.current[d] || ue()
|
|
1233
1233
|
})), [l, u])
|
|
1234
1234
|
};
|
|
1235
1235
|
}
|
|
@@ -1237,7 +1237,7 @@ function br(t = {}) {
|
|
|
1237
1237
|
const r = F.useRef(void 0), e = F.useRef(void 0), [s, u] = F.useState({
|
|
1238
1238
|
isDirty: !1,
|
|
1239
1239
|
isValidating: !1,
|
|
1240
|
-
isLoading:
|
|
1240
|
+
isLoading: G(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: G(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 && !G(t.defaultValues) && t.formControl.reset(t.defaultValues, t.resetOptions);
|
|
1260
1260
|
else {
|
|
1261
1261
|
const { formControl: c, ...l } = vr(t);
|
|
1262
1262
|
r.current = {
|
|
@@ -1300,14 +1300,14 @@ function br(t = {}) {
|
|
|
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 = Kt(
|
|
1303
|
+
const Lt = zt(void 0), Ar = ({ showAsterisk: t, children: r }) => /* @__PURE__ */ te(Lt.Provider, { value: { showAsterisk: t }, children: r }), pr = () => {
|
|
1304
|
+
const t = Kt(Lt);
|
|
1305
1305
|
if (!t)
|
|
1306
1306
|
throw new Error("useSuprFormContext must be used within a SuprFormProvider");
|
|
1307
1307
|
return t;
|
|
1308
1308
|
};
|
|
1309
1309
|
function Nt(t, r, e) {
|
|
1310
|
-
const { conditions: s, operator: u } = e, i = t.reduce((l, V,
|
|
1310
|
+
const { conditions: s, operator: u } = e, i = t.reduce((l, V, h) => (l[V] = r[h], l), {}), c = s.map((l) => {
|
|
1311
1311
|
const V = i[l.name];
|
|
1312
1312
|
switch (l.operator) {
|
|
1313
1313
|
case "EQUALS":
|
|
@@ -1340,15 +1340,15 @@ const xr = ({
|
|
|
1340
1340
|
children: t,
|
|
1341
1341
|
visibility: r
|
|
1342
1342
|
}) => {
|
|
1343
|
-
const e =
|
|
1344
|
-
return
|
|
1343
|
+
const e = ye(() => typeof r == "boolean" ? [] : (r == null ? void 0 : r.conditions.map((i) => i.name)) || [], [r]), s = Xe({ name: e });
|
|
1344
|
+
return ye(() => typeof r == "boolean" ? r : !r || (r == null ? void 0 : r.conditions.length) === 0 ? !0 : Nt(e, s, r), [r, e, s]) ? t : null;
|
|
1345
1345
|
}, Sr = ({
|
|
1346
1346
|
children: t,
|
|
1347
1347
|
disabled: r
|
|
1348
1348
|
}) => {
|
|
1349
|
-
const e =
|
|
1349
|
+
const e = ye(() => typeof r == "boolean" ? [] : (r == null ? void 0 : r.conditions.map((i) => i.name)) || [], [r]), s = Xe({ name: e }), u = ye(() => typeof r == "boolean" ? r : !r || (r == null ? void 0 : r.conditions.length) === 0 ? !1 : Nt(e, s, r), [r, e, s]);
|
|
1350
1350
|
return Ae(t, { ...t.props, disabled: u });
|
|
1351
|
-
},
|
|
1351
|
+
}, tt = ({
|
|
1352
1352
|
children: t,
|
|
1353
1353
|
name: r,
|
|
1354
1354
|
rules: e,
|
|
@@ -1357,52 +1357,73 @@ const xr = ({
|
|
|
1357
1357
|
id: i,
|
|
1358
1358
|
disabled: c,
|
|
1359
1359
|
shouldUnregister: l,
|
|
1360
|
-
visibility: V
|
|
1360
|
+
visibility: V,
|
|
1361
|
+
description: h
|
|
1361
1362
|
}) => {
|
|
1362
|
-
const { control:
|
|
1363
|
-
|
|
1363
|
+
const { control: k } = Ve(), g = t.props.value ?? "", { showAsterisk: S } = pr(), p = t.props.onChange, I = t.props.onBlur, R = ye(() => i || crypto.randomUUID(), []), T = ye(() => {
|
|
1364
|
+
if (h)
|
|
1365
|
+
return typeof h == "string" ? { position: "LABEL_BOTTOM", text: h } : h;
|
|
1366
|
+
}, [h]);
|
|
1367
|
+
return /* @__PURE__ */ te(xr, { visibility: V, children: /* @__PURE__ */ te(Sr, { disabled: c, children: /* @__PURE__ */ te(
|
|
1364
1368
|
ar,
|
|
1365
1369
|
{
|
|
1366
|
-
control:
|
|
1370
|
+
control: k,
|
|
1367
1371
|
name: r,
|
|
1368
1372
|
rules: e,
|
|
1369
|
-
defaultValue:
|
|
1373
|
+
defaultValue: g,
|
|
1370
1374
|
shouldUnregister: l,
|
|
1371
1375
|
render: ({
|
|
1372
|
-
field: { name:
|
|
1373
|
-
fieldState: { error:
|
|
1374
|
-
}) => /* @__PURE__ */
|
|
1376
|
+
field: { name: U, onBlur: x, value: B, onChange: f, ref: d, disabled: A },
|
|
1377
|
+
fieldState: { error: w }
|
|
1378
|
+
}) => /* @__PURE__ */ Le(
|
|
1375
1379
|
"div",
|
|
1376
1380
|
{
|
|
1377
1381
|
className: `controlled-field ${s}`,
|
|
1378
1382
|
style: { display: "flex", flexDirection: "column", gap: "5px" },
|
|
1379
1383
|
children: [
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
+
/* @__PURE__ */ Le(
|
|
1385
|
+
"div",
|
|
1386
|
+
{
|
|
1387
|
+
className: "controlled-field-description",
|
|
1388
|
+
style: {
|
|
1389
|
+
display: "inline-flex",
|
|
1390
|
+
...T && {
|
|
1391
|
+
gap: "2px",
|
|
1392
|
+
alignItems: "center",
|
|
1393
|
+
flexDirection: T.position === "LABEL_RIGHT" ? "row" : "column"
|
|
1394
|
+
}
|
|
1395
|
+
},
|
|
1396
|
+
children: [
|
|
1397
|
+
u && /* @__PURE__ */ Le("label", { htmlFor: R, className: "controlled-field-label", children: [
|
|
1398
|
+
u,
|
|
1399
|
+
S && !!e && /* @__PURE__ */ te("span", { style: { color: "red" }, children: " *" })
|
|
1400
|
+
] }),
|
|
1401
|
+
T && T.position !== "CONTROL_BOTTOM" && /* @__PURE__ */ te("span", { style: { color: "#a1a1a1", fontSize: 12 }, children: T.text })
|
|
1402
|
+
]
|
|
1403
|
+
}
|
|
1404
|
+
),
|
|
1384
1405
|
Ae(t, {
|
|
1385
1406
|
...t.props,
|
|
1386
|
-
id:
|
|
1387
|
-
name:
|
|
1388
|
-
disabled:
|
|
1389
|
-
onChange: (...
|
|
1390
|
-
|
|
1407
|
+
id: R,
|
|
1408
|
+
name: U,
|
|
1409
|
+
disabled: A,
|
|
1410
|
+
onChange: (...W) => {
|
|
1411
|
+
f(...W), p == null || p(...W);
|
|
1391
1412
|
},
|
|
1392
|
-
value:
|
|
1393
|
-
onBlur: (...
|
|
1394
|
-
|
|
1413
|
+
value: B,
|
|
1414
|
+
onBlur: (...W) => {
|
|
1415
|
+
x(), I == null || I(...W);
|
|
1395
1416
|
},
|
|
1396
|
-
ref:
|
|
1417
|
+
ref: d
|
|
1397
1418
|
}),
|
|
1398
|
-
|
|
1419
|
+
w && /* @__PURE__ */ te("div", { style: { color: "red", fontSize: 13 }, className: "controlled-field-error", children: w.message })
|
|
1399
1420
|
]
|
|
1400
1421
|
}
|
|
1401
1422
|
)
|
|
1402
1423
|
}
|
|
1403
1424
|
) }) });
|
|
1404
1425
|
};
|
|
1405
|
-
|
|
1426
|
+
tt.displayName = "SuprFormControl";
|
|
1406
1427
|
const Er = ({
|
|
1407
1428
|
name: t,
|
|
1408
1429
|
rules: r,
|
|
@@ -1416,51 +1437,51 @@ const Er = ({
|
|
|
1416
1437
|
rules: r
|
|
1417
1438
|
});
|
|
1418
1439
|
At(e, () => c, [c]);
|
|
1419
|
-
const l = (V,
|
|
1420
|
-
var I,
|
|
1421
|
-
if (!Jt(
|
|
1422
|
-
return
|
|
1423
|
-
const g =
|
|
1424
|
-
if (((S == null ? void 0 : S.displayName) === "SuprFormControl" || S ===
|
|
1425
|
-
const
|
|
1426
|
-
...
|
|
1427
|
-
conditions: ((I =
|
|
1440
|
+
const l = (V, h) => Yt.map(V, (k) => {
|
|
1441
|
+
var I, R;
|
|
1442
|
+
if (!Jt(k))
|
|
1443
|
+
return k;
|
|
1444
|
+
const g = k.props, S = k.type;
|
|
1445
|
+
if (((S == null ? void 0 : S.displayName) === "SuprFormControl" || S === tt || g.name !== void 0 && typeof S != "string") && g.name !== void 0) {
|
|
1446
|
+
const T = u ? u[g.name] : void 0, U = T ? {
|
|
1447
|
+
...T,
|
|
1448
|
+
conditions: ((I = T.conditions) == null ? void 0 : I.map((d) => ({
|
|
1428
1449
|
...d,
|
|
1429
|
-
name: `${
|
|
1450
|
+
name: `${h}${d.name}`
|
|
1430
1451
|
}))) || []
|
|
1431
|
-
} : void 0, x = i ? i[g.name] : void 0,
|
|
1452
|
+
} : void 0, x = i ? i[g.name] : void 0, B = x ? {
|
|
1432
1453
|
...x,
|
|
1433
|
-
conditions: ((
|
|
1454
|
+
conditions: ((R = x.conditions) == null ? void 0 : R.map((d) => ({
|
|
1434
1455
|
...d,
|
|
1435
|
-
name: `${
|
|
1456
|
+
name: `${h}${d.name}`
|
|
1436
1457
|
}))) || []
|
|
1437
1458
|
} : void 0, f = {
|
|
1438
1459
|
...g,
|
|
1439
|
-
name: `${
|
|
1440
|
-
visibility:
|
|
1441
|
-
disabled:
|
|
1460
|
+
name: `${h}${g.name}`,
|
|
1461
|
+
visibility: U,
|
|
1462
|
+
disabled: B
|
|
1442
1463
|
};
|
|
1443
|
-
return g.id !== void 0 && (f.id = `${
|
|
1464
|
+
return g.id !== void 0 && (f.id = `${h}${g.id}`), Ae(k, f);
|
|
1444
1465
|
}
|
|
1445
|
-
return g.children ? Ae(
|
|
1466
|
+
return g.children ? Ae(k, {
|
|
1446
1467
|
...g,
|
|
1447
|
-
children: l(g.children,
|
|
1448
|
-
}) :
|
|
1468
|
+
children: l(g.children, h)
|
|
1469
|
+
}) : k;
|
|
1449
1470
|
});
|
|
1450
|
-
return /* @__PURE__ */
|
|
1451
|
-
const
|
|
1452
|
-
return /* @__PURE__ */
|
|
1471
|
+
return /* @__PURE__ */ te(Qt, { children: c.fields.map((V, h) => {
|
|
1472
|
+
const k = `${t}.${h}.`;
|
|
1473
|
+
return /* @__PURE__ */ te(
|
|
1453
1474
|
"div",
|
|
1454
1475
|
{
|
|
1455
|
-
"data-index":
|
|
1476
|
+
"data-index": h,
|
|
1456
1477
|
style: { display: "contents" },
|
|
1457
1478
|
id: "field-array-item",
|
|
1458
|
-
children: l(s,
|
|
1479
|
+
children: l(s, k)
|
|
1459
1480
|
},
|
|
1460
|
-
|
|
1481
|
+
k
|
|
1461
1482
|
);
|
|
1462
1483
|
}) });
|
|
1463
|
-
},
|
|
1484
|
+
}, Ut = ({
|
|
1464
1485
|
children: t,
|
|
1465
1486
|
onSubmit: r = () => {
|
|
1466
1487
|
},
|
|
@@ -1473,7 +1494,7 @@ const Er = ({
|
|
|
1473
1494
|
ref: l,
|
|
1474
1495
|
onChange: V
|
|
1475
1496
|
}) => {
|
|
1476
|
-
const
|
|
1497
|
+
const h = br({
|
|
1477
1498
|
mode: "onSubmit",
|
|
1478
1499
|
reValidateMode: "onChange",
|
|
1479
1500
|
shouldFocusError: !0,
|
|
@@ -1482,38 +1503,38 @@ const Er = ({
|
|
|
1482
1503
|
return At(
|
|
1483
1504
|
l,
|
|
1484
1505
|
() => ({
|
|
1485
|
-
setValue:
|
|
1486
|
-
setError:
|
|
1487
|
-
clearErrors:
|
|
1488
|
-
getValues:
|
|
1489
|
-
reset:
|
|
1490
|
-
setFocus:
|
|
1491
|
-
resetField:
|
|
1492
|
-
trigger:
|
|
1493
|
-
unregister:
|
|
1494
|
-
watch:
|
|
1495
|
-
handleSubmit:
|
|
1506
|
+
setValue: h.setValue,
|
|
1507
|
+
setError: h.setError,
|
|
1508
|
+
clearErrors: h.clearErrors,
|
|
1509
|
+
getValues: h.getValues,
|
|
1510
|
+
reset: h.reset,
|
|
1511
|
+
setFocus: h.setFocus,
|
|
1512
|
+
resetField: h.resetField,
|
|
1513
|
+
trigger: h.trigger,
|
|
1514
|
+
unregister: h.unregister,
|
|
1515
|
+
watch: h.watch,
|
|
1516
|
+
handleSubmit: h.handleSubmit
|
|
1496
1517
|
}),
|
|
1497
|
-
[
|
|
1518
|
+
[h]
|
|
1498
1519
|
), Xt(() => {
|
|
1499
|
-
const
|
|
1520
|
+
const k = h.watch((g) => {
|
|
1500
1521
|
V == null || V(g);
|
|
1501
1522
|
});
|
|
1502
|
-
return () =>
|
|
1503
|
-
}, [
|
|
1523
|
+
return () => k.unsubscribe();
|
|
1524
|
+
}, [h.watch]), /* @__PURE__ */ te(Ar, { showAsterisk: c, children: /* @__PURE__ */ te(tr, { ...h, children: /* @__PURE__ */ te(
|
|
1504
1525
|
"form",
|
|
1505
1526
|
{
|
|
1506
1527
|
noValidate: !0,
|
|
1507
|
-
onSubmit:
|
|
1528
|
+
onSubmit: h.handleSubmit(r, e),
|
|
1508
1529
|
style: s,
|
|
1509
1530
|
className: u,
|
|
1510
1531
|
children: t
|
|
1511
1532
|
}
|
|
1512
1533
|
) }) });
|
|
1513
1534
|
};
|
|
1514
|
-
|
|
1515
|
-
|
|
1535
|
+
Ut.Control = tt;
|
|
1536
|
+
Ut.ControlArray = Er;
|
|
1516
1537
|
export {
|
|
1517
|
-
|
|
1538
|
+
Ut as SuprForm
|
|
1518
1539
|
};
|
|
1519
1540
|
//# sourceMappingURL=suprform.es.js.map
|