suprform 1.2.1 → 1.3.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/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 +351 -364
- package/dist/suprform.es.js.map +1 -1
- package/dist/type.d.ts +2 -4
- package/dist/type.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/suprform.es.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsx as te, jsxs as
|
|
2
|
-
import F, { createContext as zt, useContext as
|
|
1
|
+
import { jsx as te, jsxs as Ne, Fragment as Qt } from "react/jsx-runtime";
|
|
2
|
+
import F, { createContext as zt, useContext as Jt, useMemo as ye, cloneElement as Ae, useImperativeHandle as At, Children as Kt, isValidElement as Yt, useEffect as Xt } from "react";
|
|
3
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
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
7
|
return H(r) && r.hasOwnProperty("isPrototypeOf");
|
|
8
|
-
},
|
|
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
16
|
if (!e && !(H(t) && er(t)))
|
|
@@ -20,24 +20,24 @@ function M(t) {
|
|
|
20
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),
|
|
23
|
+
var Ee = (t) => /^\w*$/.test(t), L = (t) => t === void 0, we = (t) => Array.isArray(t) ? t.filter(Boolean) : [], Ke = (t) => we(t.replace(/["|']|\]/g, "").split(/\.|\[/)), m = (t, r, e) => {
|
|
24
24
|
if (!r || !H(t))
|
|
25
25
|
return e;
|
|
26
|
-
const s = (Ee(r) ? [r] :
|
|
27
|
-
return
|
|
28
|
-
},
|
|
26
|
+
const s = (Ee(r) ? [r] : Ke(r)).reduce((u, i) => Q(u) ? u : u[i], t);
|
|
27
|
+
return L(s) || s === t ? L(t[r]) ? e : t[r] : s;
|
|
28
|
+
}, Y = (t) => typeof t == "boolean", G = (t) => typeof t == "function", T = (t, r, e) => {
|
|
29
29
|
let s = -1;
|
|
30
|
-
const u = Ee(r) ? [r] :
|
|
30
|
+
const u = Ee(r) ? [r] : Ke(r), i = u.length, c = i - 1;
|
|
31
31
|
for (; ++s < i; ) {
|
|
32
32
|
const l = u[s];
|
|
33
|
-
let
|
|
33
|
+
let v = e;
|
|
34
34
|
if (s !== c) {
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const V = t[l];
|
|
36
|
+
v = H(V) || Array.isArray(V) ? V : isNaN(+u[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 = {
|
|
@@ -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
|
+
}, Ye = F.createContext(null);
|
|
62
|
+
Ye.displayName = "HookFormContext";
|
|
63
|
+
const Ve = () => F.useContext(Ye), tr = (t) => {
|
|
64
64
|
const { children: r, ...e } = t;
|
|
65
|
-
return F.createElement(
|
|
65
|
+
return F.createElement(Ye.Provider, { value: e }, r);
|
|
66
66
|
};
|
|
67
67
|
var Et = (t, r, e, s = !0) => {
|
|
68
68
|
const u = {
|
|
@@ -79,7 +79,7 @@ var Et = (t, r, e, s = !0) => {
|
|
|
79
79
|
};
|
|
80
80
|
const ke = typeof window < "u" ? F.useLayoutEffect : F.useEffect;
|
|
81
81
|
function rr(t) {
|
|
82
|
-
const r = Ve(), { control: e = r.control, disabled: s, name: u, exact: i } = t || {}, [c, l] = F.useState(e._formState),
|
|
82
|
+
const r = Ve(), { control: e = r.control, disabled: s, name: u, exact: i } = t || {}, [c, l] = F.useState(e._formState), v = F.useRef({
|
|
83
83
|
isDirty: !1,
|
|
84
84
|
isLoading: !1,
|
|
85
85
|
dirtyFields: !1,
|
|
@@ -91,17 +91,17 @@ function rr(t) {
|
|
|
91
91
|
});
|
|
92
92
|
return ke(() => e._subscribe({
|
|
93
93
|
name: u,
|
|
94
|
-
formState:
|
|
94
|
+
formState: v.current,
|
|
95
95
|
exact: i,
|
|
96
|
-
callback: (
|
|
96
|
+
callback: (V) => {
|
|
97
97
|
!s && l({
|
|
98
98
|
...e._formState,
|
|
99
|
-
...
|
|
99
|
+
...V
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
}), [u, s, i]), F.useEffect(() => {
|
|
103
|
-
|
|
104
|
-
}, [e]), F.useMemo(() => Et(c, e,
|
|
103
|
+
v.current.isValid && e._setValid(!0);
|
|
104
|
+
}, [e]), F.useMemo(() => Et(c, e, v.current, !1), [c, e]);
|
|
105
105
|
}
|
|
106
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()) {
|
|
@@ -128,35 +128,35 @@ function ae(t, r, e = /* @__PURE__ */ new WeakSet()) {
|
|
|
128
128
|
return !0;
|
|
129
129
|
}
|
|
130
130
|
function Xe(t) {
|
|
131
|
-
const r = Ve(), { control: e = r.control, name: s, defaultValue: u, disabled: i, exact: c, compute: l } = t || {},
|
|
132
|
-
|
|
131
|
+
const r = Ve(), { control: e = r.control, name: s, defaultValue: u, disabled: i, exact: c, compute: l } = t || {}, v = F.useRef(u), V = F.useRef(l), C = F.useRef(void 0), g = F.useRef(e), S = F.useRef(s);
|
|
132
|
+
V.current = l;
|
|
133
133
|
const [p, I] = F.useState(() => {
|
|
134
|
-
const f = e._getWatch(s,
|
|
135
|
-
return
|
|
134
|
+
const f = e._getWatch(s, v.current);
|
|
135
|
+
return V.current ? V.current(f) : f;
|
|
136
136
|
}), R = F.useCallback((f) => {
|
|
137
|
-
const d = qe(s, e._names, f || e._formValues, !1,
|
|
138
|
-
return
|
|
139
|
-
}, [e._formValues, e._names, s]),
|
|
137
|
+
const d = qe(s, e._names, f || e._formValues, !1, v.current);
|
|
138
|
+
return V.current ? V.current(d) : d;
|
|
139
|
+
}, [e._formValues, e._names, s]), O = F.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 (V.current) {
|
|
143
|
+
const A = V.current(d);
|
|
144
|
+
ae(A, C.current) || (I(A), C.current = A);
|
|
145
145
|
} else
|
|
146
146
|
I(d);
|
|
147
147
|
}
|
|
148
148
|
}, [e._formValues, e._names, i, s]);
|
|
149
|
-
ke(() => ((
|
|
149
|
+
ke(() => ((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 U =
|
|
158
|
+
})), [e, c, s, O]), 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
162
|
const f = !U && !ae(x, s);
|
|
@@ -165,43 +165,43 @@ function Xe(t) {
|
|
|
165
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,
|
|
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), V = F.useMemo(() => m(u._formValues, e, m(u._defaultValues, e, c)), [u, e, c]), C = Xe({
|
|
169
169
|
control: u,
|
|
170
170
|
name: e,
|
|
171
|
-
defaultValue:
|
|
171
|
+
defaultValue: V,
|
|
172
172
|
exact: l
|
|
173
|
-
}),
|
|
173
|
+
}), g = rr({
|
|
174
174
|
control: u,
|
|
175
175
|
name: e,
|
|
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:
|
|
180
|
-
...
|
|
179
|
+
value: C,
|
|
180
|
+
...Y(t.disabled) ? { disabled: t.disabled } : {}
|
|
181
181
|
}));
|
|
182
182
|
S.current = t;
|
|
183
183
|
const R = F.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 = F.useCallback((f) => I.current.onChange({
|
|
205
205
|
target: {
|
|
206
206
|
value: xt(f),
|
|
207
207
|
name: e
|
|
@@ -223,39 +223,39 @@ function sr(t) {
|
|
|
223
223
|
});
|
|
224
224
|
}, [u._fields, e]), B = F.useMemo(() => ({
|
|
225
225
|
name: e,
|
|
226
|
-
value:
|
|
227
|
-
...
|
|
228
|
-
onChange:
|
|
226
|
+
value: C,
|
|
227
|
+
...Y(s) || g.disabled ? { disabled: g.disabled || s } : {},
|
|
228
|
+
onChange: O,
|
|
229
229
|
onBlur: U,
|
|
230
230
|
ref: x
|
|
231
|
-
}), [e, s,
|
|
231
|
+
}), [e, s, g.disabled, O, U, x, C]);
|
|
232
232
|
return F.useEffect(() => {
|
|
233
233
|
const f = u._options.shouldUnregister || i, d = p.current;
|
|
234
|
-
d && d !== e && !
|
|
234
|
+
d && d !== e && !v && u.unregister(d), u.register(e, {
|
|
235
235
|
...S.current.rules,
|
|
236
|
-
...
|
|
236
|
+
...Y(S.current.disabled) ? { disabled: S.current.disabled } : {}
|
|
237
237
|
});
|
|
238
238
|
const A = (w, W) => {
|
|
239
|
-
const
|
|
240
|
-
|
|
239
|
+
const J = m(u._fields, w);
|
|
240
|
+
J && J._f && (J._f.mount = W);
|
|
241
241
|
};
|
|
242
242
|
if (A(e, !0), f) {
|
|
243
243
|
const w = M(m(u._options.defaultValues, e, S.current.defaultValue));
|
|
244
|
-
|
|
244
|
+
T(u._defaultValues, e, w), L(m(u._formValues, e)) && T(u._formValues, e, w);
|
|
245
245
|
}
|
|
246
|
-
return !
|
|
247
|
-
(
|
|
246
|
+
return !v && u.register(e), p.current = e, () => {
|
|
247
|
+
(v ? f && !u._state.action : f) ? u.unregister(e) : A(e, !1);
|
|
248
248
|
};
|
|
249
|
-
}, [e, u,
|
|
249
|
+
}, [e, u, v, i]), F.useEffect(() => {
|
|
250
250
|
u._setDisabledField({
|
|
251
251
|
disabled: s,
|
|
252
252
|
name: e
|
|
253
253
|
});
|
|
254
254
|
}, [s, e, u]), F.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
261
|
var nr = (t, r, e, s, u) => r ? {
|
|
@@ -297,26 +297,26 @@ function wt(t, r) {
|
|
|
297
297
|
return e;
|
|
298
298
|
}
|
|
299
299
|
var j = (t) => H(t) && !Object.keys(t).length, Ze = (t) => t.type === "file", xe = (t) => {
|
|
300
|
-
if (!
|
|
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
|
-
}, kt = (t) => t.type === "select-multiple", et = (t) => t.type === "radio", ir = (t) => et(t) || ve(t),
|
|
304
|
+
}, kt = (t) => t.type === "select-multiple", et = (t) => t.type === "radio", ir = (t) => et(t) || ve(t), Le = (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 = L(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) && !L(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] :
|
|
319
|
+
const e = Array.isArray(r) ? r : Ee(r) ? [r] : Ke(r), s = e.length === 1 ? t : ur(t, e), u = e.length - 1, i = e[u];
|
|
320
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) => {
|
|
@@ -331,7 +331,7 @@ function Ct(t) {
|
|
|
331
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) ? [] : {}, Ge(s, r[e])) :
|
|
334
|
+
Ct(s) ? (r[e] = Array.isArray(s) ? [] : {}, Ge(s, r[e])) : L(s) || (r[e] = !0);
|
|
335
335
|
}
|
|
336
336
|
return r;
|
|
337
337
|
}
|
|
@@ -340,7 +340,7 @@ function ce(t, r, e) {
|
|
|
340
340
|
for (const s in t) {
|
|
341
341
|
const u = t[s];
|
|
342
342
|
if (Ct(u))
|
|
343
|
-
|
|
343
|
+
L(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 && !L(t[0].attributes.value) ? L(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 }) => L(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 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 : kt(r) ? [...r.selectedOptions].map(({ value: e }) => e) : ve(r) ? Dt(t.refs).value : Ot(L(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 && T(u, i, c._f);
|
|
385
385
|
}
|
|
386
386
|
return {
|
|
387
387
|
criteriaMode: e,
|
|
@@ -389,7 +389,7 @@ var cr = (t, r, e, s) => {
|
|
|
389
389
|
fields: u,
|
|
390
390
|
shouldUseNativeValidation: s
|
|
391
391
|
};
|
|
392
|
-
}, Se = (t) => t instanceof RegExp, he = (t) =>
|
|
392
|
+
}, Se = (t) => t instanceof RegExp, he = (t) => L(t) ? t : Se(t) ? t.source : H(t) ? Se(t.value) ? t.value.source : t.value : t, de = (t) => ({
|
|
393
393
|
isOnSubmit: !t || t === re.onSubmit,
|
|
394
394
|
isOnBlur: t === re.onBlur,
|
|
395
395
|
isOnChange: t === re.onChange,
|
|
@@ -449,10 +449,10 @@ var yr = (t, r, e, s) => {
|
|
|
449
449
|
return j(i) || Object.keys(i).length >= Object.keys(r).length || Object.keys(i).find((c) => r[c] === (!s || re.all));
|
|
450
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 T(s, "root", r[e]), T(t, e, s), t;
|
|
453
453
|
};
|
|
454
454
|
function Ft(t, r, e = "validate") {
|
|
455
|
-
if (X(t) || Array.isArray(t) && t.every(X) ||
|
|
455
|
+
if (X(t) || Array.isArray(t) && t.every(X) || Y(t) && !t)
|
|
456
456
|
return {
|
|
457
457
|
type: e,
|
|
458
458
|
message: X(t) ? t : "",
|
|
@@ -463,75 +463,75 @@ var le = (t) => H(t) && !Se(t) ? t : {
|
|
|
463
463
|
value: t,
|
|
464
464
|
message: ""
|
|
465
465
|
}, ze = async (t, r, e, s, u, i) => {
|
|
466
|
-
const { ref: c, refs: l, required:
|
|
466
|
+
const { ref: c, refs: l, required: v, maxLength: V, minLength: C, min: g, max: S, pattern: p, validate: I, name: R, valueAsNumber: O, mount: U } = t._f, x = m(e, R);
|
|
467
467
|
if (!U || r.has(R))
|
|
468
468
|
return {};
|
|
469
469
|
const B = l ? l[0] : c, f = (E) => {
|
|
470
|
-
u && B.reportValidity && (B.setCustomValidity(
|
|
471
|
-
}, d = {}, A = et(c), w = ve(c), W = A || w,
|
|
472
|
-
const
|
|
470
|
+
u && B.reportValidity && (B.setCustomValidity(Y(E) ? "" : E || ""), B.reportValidity());
|
|
471
|
+
}, d = {}, A = et(c), w = ve(c), W = A || w, J = (O || Ze(c)) && L(c.value) && L(x) || xe(c) && c.value === "" || x === "" || Array.isArray(x) && !x.length, Z = nr.bind(null, R, s, d), Fe = (E, k, $, q = ne.maxLength, se = ne.minLength) => {
|
|
472
|
+
const K = E ? k : $;
|
|
473
473
|
d[R] = {
|
|
474
474
|
type: E ? q : se,
|
|
475
|
-
message:
|
|
475
|
+
message: K,
|
|
476
476
|
ref: c,
|
|
477
|
-
...Z(E ? q : se,
|
|
477
|
+
...Z(E ? q : se, K)
|
|
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 && (!W && (J || Q(x)) || Y(x) && !x || w && !Dt(l).isValid || A && !Tt(l).isValid)) {
|
|
481
|
+
const { value: E, message: k } = X(v) ? { value: !!v, message: v } : le(v);
|
|
482
482
|
if (E && (d[R] = {
|
|
483
483
|
type: ne.required,
|
|
484
|
-
message:
|
|
484
|
+
message: k,
|
|
485
485
|
ref: B,
|
|
486
|
-
...Z(ne.required,
|
|
486
|
+
...Z(ne.required, k)
|
|
487
487
|
}, !s))
|
|
488
|
-
return f(
|
|
488
|
+
return f(k), d;
|
|
489
489
|
}
|
|
490
|
-
if (!
|
|
491
|
-
let E,
|
|
492
|
-
const $ = le(S), q = le(
|
|
490
|
+
if (!J && (!Q(g) || !Q(S))) {
|
|
491
|
+
let E, k;
|
|
492
|
+
const $ = le(S), q = le(g);
|
|
493
493
|
if (!Q(x) && !isNaN(x)) {
|
|
494
494
|
const se = c.valueAsNumber || x && +x;
|
|
495
|
-
Q($.value) || (E = se > $.value), Q(q.value) || (
|
|
495
|
+
Q($.value) || (E = se > $.value), Q(q.value) || (k = se < q.value);
|
|
496
496
|
} else {
|
|
497
|
-
const se = c.valueAsDate || new Date(x),
|
|
498
|
-
X($.value) && x && (E = me ?
|
|
497
|
+
const se = c.valueAsDate || new Date(x), K = (ge) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + ge), me = c.type == "time", _e = c.type == "week";
|
|
498
|
+
X($.value) && x && (E = me ? K(x) > K($.value) : _e ? x > $.value : se > new Date($.value)), X(q.value) && x && (k = me ? K(x) < K(q.value) : _e ? x < q.value : se < new Date(q.value));
|
|
499
499
|
}
|
|
500
|
-
if ((E ||
|
|
500
|
+
if ((E || k) && (Fe(!!E, $.message, q.message, ne.max, ne.min), !s))
|
|
501
501
|
return f(d[R].message), d;
|
|
502
502
|
}
|
|
503
|
-
if ((
|
|
504
|
-
const E = le(
|
|
505
|
-
if (($ || q) && (Fe($, E.message,
|
|
503
|
+
if ((V || C) && !J && (X(x) || i && Array.isArray(x))) {
|
|
504
|
+
const E = le(V), k = le(C), $ = !Q(E.value) && x.length > +E.value, q = !Q(k.value) && x.length < +k.value;
|
|
505
|
+
if (($ || q) && (Fe($, 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 && !J && X(x)) {
|
|
509
|
+
const { value: E, message: k } = le(p);
|
|
510
510
|
if (Se(E) && !x.match(E) && (d[R] = {
|
|
511
511
|
type: ne.pattern,
|
|
512
|
-
message:
|
|
512
|
+
message: k,
|
|
513
513
|
ref: c,
|
|
514
|
-
...Z(ne.pattern,
|
|
514
|
+
...Z(ne.pattern, k)
|
|
515
515
|
}, !s))
|
|
516
|
-
return f(
|
|
516
|
+
return f(k), d;
|
|
517
517
|
}
|
|
518
518
|
if (I) {
|
|
519
519
|
if (G(I)) {
|
|
520
|
-
const E = await I(x, e),
|
|
521
|
-
if (
|
|
522
|
-
...
|
|
523
|
-
...Z(ne.validate,
|
|
520
|
+
const E = await I(x, e), k = Ft(E, B);
|
|
521
|
+
if (k && (d[R] = {
|
|
522
|
+
...k,
|
|
523
|
+
...Z(ne.validate, k.message)
|
|
524
524
|
}, !s))
|
|
525
|
-
return f(
|
|
525
|
+
return f(k.message), d;
|
|
526
526
|
} else if (H(I)) {
|
|
527
527
|
let E = {};
|
|
528
|
-
for (const
|
|
528
|
+
for (const k in I) {
|
|
529
529
|
if (!j(E) && !s)
|
|
530
530
|
break;
|
|
531
|
-
const $ = Ft(await I[
|
|
531
|
+
const $ = Ft(await I[k](x, e), B, k);
|
|
532
532
|
$ && (E = {
|
|
533
533
|
...$,
|
|
534
|
-
...Z(
|
|
534
|
+
...Z(k, $.message)
|
|
535
535
|
}, f($.message), s && (d[R] = E));
|
|
536
536
|
}
|
|
537
537
|
if (!j(E) && (d[R] = {
|
|
@@ -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, V = 0;
|
|
582
|
+
const C = {
|
|
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
|
+
...C
|
|
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(V), V = setTimeout(a, n);
|
|
601
|
+
}, O = async (a) => {
|
|
602
|
+
if (!c.keepIsValid && !r.disabled && (g.isValid || S.isValid || a)) {
|
|
603
603
|
let n;
|
|
604
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
|
-
!r.disabled && (
|
|
610
|
-
o && (n ?
|
|
609
|
+
!r.disabled && (g.isValidating || g.validatingFields || S.isValidating || S.validatingFields) && ((a || Array.from(l.mount)).forEach((o) => {
|
|
610
|
+
o && (n ? T(e.validatingFields, o, n) : P(e.validatingFields, o));
|
|
611
611
|
}), p.state.next({
|
|
612
612
|
validatingFields: e.validatingFields,
|
|
613
613
|
isValidating: !j(e.validatingFields)
|
|
614
614
|
}));
|
|
615
|
-
}, x = (a, n = [], o,
|
|
616
|
-
if (
|
|
615
|
+
}, x = (a, n = [], o, h, _ = !0, y = !0) => {
|
|
616
|
+
if (h && 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), h.argA, h.argB);
|
|
619
|
+
_ && T(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), h.argA, h.argB);
|
|
623
|
+
_ && T(e.errors, a, b), gr(e.errors, a);
|
|
624
624
|
}
|
|
625
|
-
if ((
|
|
626
|
-
const b = o(m(e.touchedFields, a),
|
|
627
|
-
_ &&
|
|
625
|
+
if ((g.touchedFields || S.touchedFields) && y && Array.isArray(m(e.touchedFields, a))) {
|
|
626
|
+
const b = o(m(e.touchedFields, a), h.argA, h.argB);
|
|
627
|
+
_ && T(e.touchedFields, a, b);
|
|
628
628
|
}
|
|
629
|
-
(
|
|
629
|
+
(g.dirtyFields || S.dirtyFields) && (e.dirtyFields = ce(u, 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,36 +644,36 @@ function vr(t = {}) {
|
|
|
644
644
|
errors: e.errors,
|
|
645
645
|
isValid: !1
|
|
646
646
|
});
|
|
647
|
-
}, d = (a, n, o,
|
|
647
|
+
}, d = (a, n, o, h) => {
|
|
648
648
|
const _ = m(s, a);
|
|
649
649
|
if (_) {
|
|
650
|
-
const y = m(i, a,
|
|
651
|
-
|
|
650
|
+
const y = m(i, a, L(o) ? m(u, a) : o);
|
|
651
|
+
L(y) || h && h.defaultChecked || n ? T(i, a, n ? y : ht(_._f)) : q(a, y), c.mount && !c.action && O();
|
|
652
652
|
}
|
|
653
|
-
}, A = (a, n, o,
|
|
653
|
+
}, A = (a, n, o, h, _) => {
|
|
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 ||
|
|
660
|
-
(
|
|
661
|
-
const
|
|
662
|
-
b = !!m(e.dirtyFields, a),
|
|
659
|
+
if (!o || h) {
|
|
660
|
+
(g.isDirty || S.isDirty) && (b = e.isDirty, e.isDirty = D.isDirty = E(), y = b !== D.isDirty);
|
|
661
|
+
const N = ae(m(u, a), n);
|
|
662
|
+
b = !!m(e.dirtyFields, a), N ? P(e.dirtyFields, a) : T(e.dirtyFields, a, !0), D.dirtyFields = e.dirtyFields, y = y || (g.dirtyFields || S.dirtyFields) && b !== !N;
|
|
663
663
|
}
|
|
664
664
|
if (o) {
|
|
665
|
-
const
|
|
666
|
-
|
|
665
|
+
const N = m(e.touchedFields, a);
|
|
666
|
+
N || (T(e.touchedFields, a, o), D.touchedFields = e.touchedFields, y = y || (g.touchedFields || S.touchedFields) && N !== o);
|
|
667
667
|
}
|
|
668
668
|
y && _ && p.state.next(D);
|
|
669
669
|
}
|
|
670
670
|
return y ? D : {};
|
|
671
|
-
}, w = (a, n, o,
|
|
672
|
-
const _ = m(e.errors, a), y = (
|
|
673
|
-
if (r.delayError && o ? (
|
|
671
|
+
}, w = (a, n, o, h) => {
|
|
672
|
+
const _ = m(e.errors, a), y = (g.isValid || S.isValid) && Y(n) && e.isValid !== n;
|
|
673
|
+
if (r.delayError && o ? (v = R(() => B(a, o)), v(r.delayError)) : (clearTimeout(V), v = null, o ? T(e.errors, a, o) : P(e.errors, a)), (o ? !ae(_, o) : _) || !j(h) || y) {
|
|
674
674
|
const b = {
|
|
675
|
-
...
|
|
676
|
-
...y &&
|
|
675
|
+
...h,
|
|
676
|
+
...y && Y(n) ? { isValid: n } : {},
|
|
677
677
|
errors: e.errors,
|
|
678
678
|
name: a
|
|
679
679
|
};
|
|
@@ -682,12 +682,12 @@ function vr(t = {}) {
|
|
|
682
682
|
...b
|
|
683
683
|
}, p.state.next(b);
|
|
684
684
|
}
|
|
685
|
-
}, W = async (a) => (U(a, !0), await r.resolver(i, r.context, cr(a || l.mount, s, r.criteriaMode, r.shouldUseNativeValidation))),
|
|
685
|
+
}, W = async (a) => (U(a, !0), await r.resolver(i, r.context, cr(a || l.mount, s, r.criteriaMode, r.shouldUseNativeValidation))), J = async (a) => {
|
|
686
686
|
const { errors: n } = await W(a);
|
|
687
687
|
if (U(a), a)
|
|
688
688
|
for (const o of a) {
|
|
689
|
-
const
|
|
690
|
-
|
|
689
|
+
const h = m(n, o);
|
|
690
|
+
h ? T(e.errors, o, h) : P(e.errors, o);
|
|
691
691
|
}
|
|
692
692
|
else
|
|
693
693
|
e.errors = n;
|
|
@@ -695,17 +695,17 @@ 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 h in a) {
|
|
699
|
+
const _ = a[h];
|
|
700
700
|
if (_) {
|
|
701
701
|
const { _f: y, ...b } = _;
|
|
702
702
|
if (y) {
|
|
703
|
-
const D = l.array.has(y.name),
|
|
704
|
-
|
|
703
|
+
const D = l.array.has(y.name), N = _._f && dr(_._f);
|
|
704
|
+
N && g.validatingFields && U([y.name], !0);
|
|
705
705
|
const ee = await ze(_, l.disabled, i, I, r.shouldUseNativeValidation && !n, D);
|
|
706
|
-
if (
|
|
706
|
+
if (N && g.validatingFields && U([y.name]), ee[y.name] && (o.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
|
!j(b) && await Z(b, n, o);
|
|
711
711
|
}
|
|
@@ -714,17 +714,17 @@ function vr(t = {}) {
|
|
|
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) => !Le(o)) : !Le(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 :
|
|
720
|
+
}, E = (a, n) => !r.disabled && (a && n && T(i, a, n), !ae(rt(), u)), k = (a, n, o) => qe(a, l, {
|
|
721
|
+
...c.mount ? i : L(n) ? u : X(a) ? { [a]: n } : n
|
|
722
722
|
}, o, n), $ = (a) => we(m(c.mount ? i : u, a, r.shouldUnregister ? m(u, a, []) : [])), q = (a, n, o = {}) => {
|
|
723
|
-
const
|
|
723
|
+
const h = m(s, a);
|
|
724
724
|
let _ = n;
|
|
725
|
-
if (
|
|
726
|
-
const y =
|
|
727
|
-
y && (!y.disabled &&
|
|
725
|
+
if (h) {
|
|
726
|
+
const y = h._f;
|
|
727
|
+
y && (!y.disabled && T(i, a, Ot(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
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,
|
|
@@ -733,76 +733,76 @@ function vr(t = {}) {
|
|
|
733
733
|
}
|
|
734
734
|
(o.shouldDirty || o.shouldTouch) && A(a, _, o.shouldTouch, o.shouldDirty, !0), o.shouldValidate && ge(a);
|
|
735
735
|
}, se = (a, n, o) => {
|
|
736
|
-
for (const
|
|
737
|
-
if (!n.hasOwnProperty(
|
|
736
|
+
for (const h in n) {
|
|
737
|
+
if (!n.hasOwnProperty(h))
|
|
738
738
|
return;
|
|
739
|
-
const _ = n[
|
|
739
|
+
const _ = n[h], y = a + "." + h, b = m(s, y);
|
|
740
740
|
(l.array.has(a) || H(_) || b && !b._f) && !oe(_) ? se(y, _, o) : q(y, _, o);
|
|
741
741
|
}
|
|
742
|
-
},
|
|
743
|
-
const
|
|
744
|
-
|
|
742
|
+
}, K = (a, n, o = {}) => {
|
|
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) && o.shouldDirty && p.state.next({
|
|
748
748
|
name: a,
|
|
749
749
|
dirtyFields: ce(u, i),
|
|
750
750
|
isDirty: E(a, y)
|
|
751
|
-
})) :
|
|
751
|
+
})) : h && !h._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
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, h = !0;
|
|
759
|
+
const _ = m(s, o), y = (N) => {
|
|
760
|
+
h = Number.isNaN(N) || oe(N) && isNaN(N.getTime()) || ae(N, m(i, o, N));
|
|
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 Re = A(o, be, ie), jt = !j(Re) ||
|
|
763
|
+
let N, 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), Te = Qe(o, l, ie);
|
|
765
|
+
T(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) || Te;
|
|
767
767
|
if (!ie && p.state.next({
|
|
768
768
|
name: o,
|
|
769
769
|
type: a.type,
|
|
770
770
|
values: M(i)
|
|
771
771
|
}), qt)
|
|
772
|
-
return (
|
|
773
|
-
if (!ie &&
|
|
772
|
+
return (g.isValid || S.isValid) && (r.mode === "onBlur" ? ie && O() : ie || O()), jt && p.state.next({ name: o, ...Te ? {} : Re });
|
|
773
|
+
if (!ie && Te && p.state.next({ ...e }), r.resolver) {
|
|
774
774
|
const { errors: dt } = await W([o]);
|
|
775
|
-
if (U([o]), y(be),
|
|
775
|
+
if (U([o]), y(be), h) {
|
|
776
776
|
const Gt = Vt(e.errors, s, o), ft = Vt(dt, s, Gt.name || o);
|
|
777
|
-
|
|
777
|
+
N = ft.error, o = ft.name, ee = j(dt);
|
|
778
778
|
}
|
|
779
779
|
} else
|
|
780
|
-
U([o], !0),
|
|
781
|
-
|
|
780
|
+
U([o], !0), N = (await ze(_, l.disabled, i, I, r.shouldUseNativeValidation))[o], U([o]), y(be), h && (N ? ee = !1 : (g.isValid || S.isValid) && (ee = await Z(s, !0)));
|
|
781
|
+
h && (_._f.deps && (!Array.isArray(_._f.deps) || _._f.deps.length > 0) && ge(_._f.deps), w(o, ee, N, Re));
|
|
782
782
|
}
|
|
783
783
|
}, _e = (a, n) => {
|
|
784
784
|
if (m(e.errors, n) && a.focus)
|
|
785
785
|
return a.focus(), 1;
|
|
786
786
|
}, ge = async (a, n = {}) => {
|
|
787
|
-
let o,
|
|
787
|
+
let o, h;
|
|
788
788
|
const _ = z(a);
|
|
789
789
|
if (r.resolver) {
|
|
790
|
-
const y = await
|
|
791
|
-
o = j(y),
|
|
792
|
-
} else a ? (
|
|
790
|
+
const y = await J(L(a) ? a : _);
|
|
791
|
+
o = j(y), h = a ? !_.some((b) => m(y, b)) : o;
|
|
792
|
+
} else a ? (h = (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), !(!h && !e.isValid) && O()) : h = o = await Z(s);
|
|
796
796
|
return p.state.next({
|
|
797
|
-
...!X(a) || (
|
|
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 && !
|
|
800
|
+
}), n.shouldFocus && !h && fe(s, _e, a ? _ : l.mount), h;
|
|
801
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)),
|
|
805
|
+
return n && (o = wt(n.dirtyFields ? e.dirtyFields : e.touchedFields, o)), L(a) ? o : X(a) ? m(o, a) : a.map((h) => m(o, h));
|
|
806
806
|
}, st = (a, n) => ({
|
|
807
807
|
invalid: !!m((n || e).errors, a),
|
|
808
808
|
isDirty: !!m((n || e).dirtyFields, a),
|
|
@@ -814,21 +814,21 @@ function vr(t = {}) {
|
|
|
814
814
|
errors: a ? e.errors : {}
|
|
815
815
|
});
|
|
816
816
|
}, at = (a, n, o) => {
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
...
|
|
817
|
+
const h = (m(s, a, { _f: {} })._f || {}).ref, _ = m(e.errors, a) || {}, { ref: y, message: b, type: D, ...N } = _;
|
|
818
|
+
T(e.errors, a, {
|
|
819
|
+
...N,
|
|
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
|
-
}), o && o.shouldFocus &&
|
|
826
|
+
}), o && o.shouldFocus && h && h.focus && h.focus();
|
|
827
827
|
}, It = (a, n) => G(a) ? p.state.subscribe({
|
|
828
|
-
next: (o) => "values" in o && a(
|
|
829
|
-
}) :
|
|
828
|
+
next: (o) => "values" in o && a(k(void 0, n), o)
|
|
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,
|
|
@@ -841,7 +841,7 @@ function vr(t = {}) {
|
|
|
841
841
|
}, nt({
|
|
842
842
|
...a,
|
|
843
843
|
formState: {
|
|
844
|
-
...
|
|
844
|
+
...C,
|
|
845
845
|
...a.formState
|
|
846
846
|
}
|
|
847
847
|
})), Ce = (a, n = {}) => {
|
|
@@ -852,13 +852,13 @@ function vr(t = {}) {
|
|
|
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
|
+
(Y(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 h = Y(n.disabled) || Y(r.disabled);
|
|
861
|
+
return T(s, a, {
|
|
862
862
|
...o || {},
|
|
863
863
|
_f: {
|
|
864
864
|
...o && o._f ? o._f : { ref: { name: a } },
|
|
@@ -867,10 +867,10 @@ function vr(t = {}) {
|
|
|
867
867
|
...n
|
|
868
868
|
}
|
|
869
869
|
}), l.mount.add(a), o ? it({
|
|
870
|
-
disabled:
|
|
870
|
+
disabled: Y(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
876
|
min: he(n.min),
|
|
@@ -885,15 +885,15 @@ function vr(t = {}) {
|
|
|
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 = L(_.value) && _.querySelectorAll && _.querySelectorAll("input,select,textarea")[0] || _, b = ir(y), D = o._f.refs || [];
|
|
889
|
+
if (b ? D.find((N) => N === y) : y === o._f.ref)
|
|
890
890
|
return;
|
|
891
|
-
|
|
891
|
+
T(s, a, {
|
|
892
892
|
_f: {
|
|
893
893
|
...o._f,
|
|
894
894
|
...b ? {
|
|
895
895
|
refs: [
|
|
896
|
-
...D.filter(
|
|
896
|
+
...D.filter(Le),
|
|
897
897
|
y,
|
|
898
898
|
...Array.isArray(m(u, a)) ? [{}] : []
|
|
899
899
|
],
|
|
@@ -905,15 +905,15 @@ 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
|
-
},
|
|
909
|
-
|
|
910
|
-
const
|
|
911
|
-
|
|
912
|
-
_.disabled =
|
|
908
|
+
}, Oe = () => r.shouldFocusError && fe(s, _e, l.mount), Pt = (a) => {
|
|
909
|
+
Y(a) && (p.state.next({ disabled: a }), fe(s, (n, o) => {
|
|
910
|
+
const h = m(s, o);
|
|
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
915
|
}, ut = (a, n) => async (o) => {
|
|
916
|
-
let
|
|
916
|
+
let h;
|
|
917
917
|
o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
|
|
918
918
|
let _ = M(i);
|
|
919
919
|
if (p.state.next({
|
|
@@ -933,22 +933,22 @@ function vr(t = {}) {
|
|
|
933
933
|
try {
|
|
934
934
|
await a(_, o);
|
|
935
935
|
} catch (y) {
|
|
936
|
-
|
|
936
|
+
h = y;
|
|
937
937
|
}
|
|
938
938
|
} else
|
|
939
|
-
n && await n({ ...e.errors }, o),
|
|
939
|
+
n && await n({ ...e.errors }, o), Oe(), setTimeout(Oe);
|
|
940
940
|
if (p.state.next({
|
|
941
941
|
isSubmitted: !0,
|
|
942
942
|
isSubmitting: !1,
|
|
943
|
-
isSubmitSuccessful: j(e.errors) && !
|
|
943
|
+
isSubmitSuccessful: j(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) && (
|
|
949
|
+
m(s, a) && (L(n.defaultValue) ? K(a, M(m(u, a))) : (K(a, n.defaultValue), T(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 && O()), p.state.next({ ...e }));
|
|
950
950
|
}, ot = (a, n = {}) => {
|
|
951
|
-
const o = a ? M(a) : u,
|
|
951
|
+
const o = a ? M(a) : u, h = M(o), _ = j(a), y = _ ? u : h;
|
|
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) ? T(y, D, m(i, D)) : K(D, m(y, D));
|
|
960
960
|
} else {
|
|
961
|
-
if (
|
|
961
|
+
if (Je && L(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 N = Array.isArray(D._f.refs) ? D._f.refs[0] : D._f.ref;
|
|
966
|
+
if (xe(N)) {
|
|
967
|
+
const ee = N.closest("form");
|
|
968
968
|
if (ee) {
|
|
969
969
|
ee.reset();
|
|
970
970
|
break;
|
|
@@ -974,7 +974,7 @@ function vr(t = {}) {
|
|
|
974
974
|
}
|
|
975
975
|
if (n.keepFieldsRef)
|
|
976
976
|
for (const b of l.mount)
|
|
977
|
-
|
|
977
|
+
K(b, m(y, b));
|
|
978
978
|
else
|
|
979
979
|
s = {};
|
|
980
980
|
}
|
|
@@ -992,7 +992,7 @@ 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 && !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,
|
|
@@ -1004,9 +1004,9 @@ function vr(t = {}) {
|
|
|
1004
1004
|
defaultValues: u
|
|
1005
1005
|
});
|
|
1006
1006
|
}, lt = (a, n) => ot(G(a) ? a(i) : a, { ...r.resetOptions, ...n }), Ht = (a, n = {}) => {
|
|
1007
|
-
const o = m(s, a),
|
|
1008
|
-
if (
|
|
1009
|
-
const _ =
|
|
1007
|
+
const o = m(s, a), h = o && o._f;
|
|
1008
|
+
if (h) {
|
|
1009
|
+
const _ = h.refs ? h.refs[0] : h.ref;
|
|
1010
1010
|
_.focus && setTimeout(() => {
|
|
1011
1011
|
_.focus(), n.shouldSelect && G(_.select) && _.select();
|
|
1012
1012
|
});
|
|
@@ -1026,10 +1026,10 @@ function vr(t = {}) {
|
|
|
1026
1026
|
_subscribe: nt,
|
|
1027
1027
|
_runSchema: W,
|
|
1028
1028
|
_updateIsValidating: U,
|
|
1029
|
-
_focusError:
|
|
1030
|
-
_getWatch:
|
|
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,
|
|
@@ -1043,7 +1043,7 @@ function vr(t = {}) {
|
|
|
1043
1043
|
_removeUnmounted: Fe,
|
|
1044
1044
|
_disableForm: Pt,
|
|
1045
1045
|
_subjects: p,
|
|
1046
|
-
_proxyFormState:
|
|
1046
|
+
_proxyFormState: g,
|
|
1047
1047
|
get _fields() {
|
|
1048
1048
|
return s;
|
|
1049
1049
|
},
|
|
@@ -1083,7 +1083,7 @@ function vr(t = {}) {
|
|
|
1083
1083
|
register: De,
|
|
1084
1084
|
handleSubmit: ut,
|
|
1085
1085
|
watch: It,
|
|
1086
|
-
setValue:
|
|
1086
|
+
setValue: K,
|
|
1087
1087
|
getValues: rt,
|
|
1088
1088
|
reset: lt,
|
|
1089
1089
|
resetField: Wt,
|
|
@@ -1106,7 +1106,7 @@ 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 || L(e.shouldFocus) ? e.focusName || `${t}.${L(e.focusIndex) ? r : e.focusIndex}.` : "", Me = (t, r) => [
|
|
1110
1110
|
...t,
|
|
1111
1111
|
...z(r)
|
|
1112
1112
|
], Ie = (t) => Array.isArray(t) ? t.map(() => {
|
|
@@ -1118,7 +1118,7 @@ function Be(t, r, 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) ? (L(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,73 +1129,73 @@ function Vr(t, r) {
|
|
|
1129
1129
|
s.splice(u - e, 1), e++;
|
|
1130
1130
|
return we(s).length ? s : [];
|
|
1131
1131
|
}
|
|
1132
|
-
var He = (t, r) =>
|
|
1132
|
+
var He = (t, r) => L(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,
|
|
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)), V = F.useRef(e._getFieldArray(s).map(ue)), C = 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) && (
|
|
1141
|
+
Array.isArray(A) && (v(A), V.current = A.map(ue));
|
|
1142
1142
|
}
|
|
1143
1143
|
}
|
|
1144
1144
|
}).unsubscribe, [e, s]);
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1145
|
+
const g = F.useCallback((f) => {
|
|
1146
|
+
C.current = !0, e._setFieldArray(s, f);
|
|
1147
1147
|
}, [e, s]), S = (f, d) => {
|
|
1148
1148
|
const A = z(M(f)), w = Me(e._getFieldArray(s), A);
|
|
1149
|
-
e._names.focus = Ue(s, w.length - 1, d),
|
|
1149
|
+
e._names.focus = Ue(s, w.length - 1, d), V.current = Me(V.current, A.map(ue)), g(w), v(w), e._setFieldArray(s, w, Me, {
|
|
1150
1150
|
argA: Ie(f)
|
|
1151
1151
|
});
|
|
1152
1152
|
}, p = (f, d) => {
|
|
1153
1153
|
const A = z(M(f)), w = We(e._getFieldArray(s), A);
|
|
1154
|
-
e._names.focus = Ue(s, 0, d),
|
|
1154
|
+
e._names.focus = Ue(s, 0, d), V.current = We(V.current, A.map(ue)), g(w), v(w), e._setFieldArray(s, w, We, {
|
|
1155
1155
|
argA: Ie(f)
|
|
1156
1156
|
});
|
|
1157
1157
|
}, I = (f) => {
|
|
1158
1158
|
const d = He(e._getFieldArray(s), f);
|
|
1159
|
-
|
|
1159
|
+
V.current = He(V.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
1163
|
const w = z(M(d)), W = Be(e._getFieldArray(s), f, w);
|
|
1164
|
-
e._names.focus = Ue(s, f, A),
|
|
1164
|
+
e._names.focus = Ue(s, f, A), V.current = Be(V.current, f, w.map(ue)), g(W), v(W), e._setFieldArray(s, W, 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(V.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(V.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
1181
|
const A = M(d), w = bt(e._getFieldArray(s), f, A);
|
|
1182
|
-
|
|
1182
|
+
V.current = [...w].map((W, J) => !W || J === f ? ue() : V.current[J]), g(w), v([...w]), e._setFieldArray(s, w, bt, {
|
|
1183
1183
|
argA: f,
|
|
1184
1184
|
argB: A
|
|
1185
1185
|
}, !0, !1);
|
|
1186
1186
|
}, B = (f) => {
|
|
1187
1187
|
const d = z(M(f));
|
|
1188
|
-
|
|
1188
|
+
V.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
|
+
}), C.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 ? 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
|
});
|
|
@@ -1211,7 +1211,7 @@ function Fr(t) {
|
|
|
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(), C.current = !1;
|
|
1215
1215
|
}, [l, s, e]), F.useEffect(() => (!m(e._formValues, s) && e._setFieldArray(s), () => {
|
|
1216
1216
|
const f = (d, A) => {
|
|
1217
1217
|
const w = m(e._fields, d);
|
|
@@ -1219,17 +1219,17 @@ function Fr(t) {
|
|
|
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(U, [
|
|
1224
|
-
prepend: F.useCallback(p, [
|
|
1225
|
-
append: F.useCallback(S, [
|
|
1226
|
-
remove: F.useCallback(I, [
|
|
1227
|
-
insert: F.useCallback(R, [
|
|
1228
|
-
update: F.useCallback(x, [
|
|
1229
|
-
replace: F.useCallback(B, [
|
|
1222
|
+
swap: F.useCallback(O, [g, s, e]),
|
|
1223
|
+
move: F.useCallback(U, [g, s, e]),
|
|
1224
|
+
prepend: F.useCallback(p, [g, s, e]),
|
|
1225
|
+
append: F.useCallback(S, [g, s, e]),
|
|
1226
|
+
remove: F.useCallback(I, [g, s, e]),
|
|
1227
|
+
insert: F.useCallback(R, [g, s, e]),
|
|
1228
|
+
update: F.useCallback(x, [g, s, e]),
|
|
1229
|
+
replace: F.useCallback(B, [g, s, e]),
|
|
1230
1230
|
fields: F.useMemo(() => l.map((f, d) => ({
|
|
1231
1231
|
...f,
|
|
1232
|
-
[u]:
|
|
1232
|
+
[u]: V.current[d] || ue()
|
|
1233
1233
|
})), [l, u])
|
|
1234
1234
|
};
|
|
1235
1235
|
}
|
|
@@ -1300,36 +1300,36 @@ 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 =
|
|
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: u } = e, i = t.reduce((l,
|
|
1311
|
-
const
|
|
1309
|
+
function Lt(t, r, e) {
|
|
1310
|
+
const { conditions: s, operator: u } = e, i = t.reduce((l, v, V) => (l[v] = r[V], 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
|
}
|
|
@@ -1341,12 +1341,12 @@ const xr = ({
|
|
|
1341
1341
|
visibility: r
|
|
1342
1342
|
}) => {
|
|
1343
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 :
|
|
1344
|
+
return ye(() => 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 = 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 :
|
|
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 : Lt(e, s, r), [r, e, s]);
|
|
1350
1350
|
return Ae(t, { ...t.props, disabled: u });
|
|
1351
1351
|
}, tt = ({
|
|
1352
1352
|
children: t,
|
|
@@ -1357,48 +1357,48 @@ const xr = ({
|
|
|
1357
1357
|
id: i,
|
|
1358
1358
|
disabled: c,
|
|
1359
1359
|
shouldUnregister: l,
|
|
1360
|
-
visibility:
|
|
1361
|
-
description:
|
|
1360
|
+
visibility: v,
|
|
1361
|
+
description: V
|
|
1362
1362
|
}) => {
|
|
1363
|
-
const { control:
|
|
1364
|
-
if (
|
|
1365
|
-
return typeof
|
|
1366
|
-
}, [
|
|
1367
|
-
return /* @__PURE__ */ te(xr, { visibility:
|
|
1363
|
+
const { control: C } = Ve(), g = t.props.value ?? "", { showAsterisk: S } = pr(), p = t.props.onChange, I = t.props.onBlur, R = ye(() => i || crypto.randomUUID(), []), O = ye(() => {
|
|
1364
|
+
if (V)
|
|
1365
|
+
return typeof V == "string" ? { position: "LABEL_BOTTOM", text: V } : V;
|
|
1366
|
+
}, [V]);
|
|
1367
|
+
return /* @__PURE__ */ te(xr, { visibility: v, children: /* @__PURE__ */ te(Sr, { disabled: c, children: /* @__PURE__ */ te(
|
|
1368
1368
|
ar,
|
|
1369
1369
|
{
|
|
1370
|
-
control:
|
|
1370
|
+
control: C,
|
|
1371
1371
|
name: r,
|
|
1372
1372
|
rules: e,
|
|
1373
|
-
defaultValue:
|
|
1373
|
+
defaultValue: g,
|
|
1374
1374
|
shouldUnregister: l,
|
|
1375
1375
|
render: ({
|
|
1376
1376
|
field: { name: U, onBlur: x, value: B, onChange: f, ref: d, disabled: A },
|
|
1377
1377
|
fieldState: { error: w }
|
|
1378
|
-
}) => /* @__PURE__ */
|
|
1378
|
+
}) => /* @__PURE__ */ Ne(
|
|
1379
1379
|
"div",
|
|
1380
1380
|
{
|
|
1381
1381
|
className: `controlled-field ${s}`,
|
|
1382
1382
|
style: { display: "flex", flexDirection: "column", gap: "5px" },
|
|
1383
1383
|
children: [
|
|
1384
|
-
/* @__PURE__ */
|
|
1384
|
+
/* @__PURE__ */ Ne(
|
|
1385
1385
|
"div",
|
|
1386
1386
|
{
|
|
1387
1387
|
className: "controlled-field-description",
|
|
1388
1388
|
style: {
|
|
1389
1389
|
display: "inline-flex",
|
|
1390
|
-
...
|
|
1390
|
+
...O && {
|
|
1391
1391
|
gap: "2px",
|
|
1392
1392
|
alignItems: "center",
|
|
1393
|
-
flexDirection:
|
|
1393
|
+
flexDirection: O.position === "LABEL_RIGHT" ? "row" : "column"
|
|
1394
1394
|
}
|
|
1395
1395
|
},
|
|
1396
1396
|
children: [
|
|
1397
|
-
u && /* @__PURE__ */
|
|
1397
|
+
u && /* @__PURE__ */ Ne("label", { htmlFor: R, className: "controlled-field-label", children: [
|
|
1398
1398
|
u,
|
|
1399
1399
|
S && !!e && /* @__PURE__ */ te("span", { style: { color: "red" }, children: " *" })
|
|
1400
1400
|
] }),
|
|
1401
|
-
|
|
1401
|
+
O && O.position !== "CONTROL_BOTTOM" && /* @__PURE__ */ te("span", { style: { color: "#a1a1a1", fontSize: 12 }, children: O.text })
|
|
1402
1402
|
]
|
|
1403
1403
|
}
|
|
1404
1404
|
),
|
|
@@ -1436,102 +1436,89 @@ const Er = ({
|
|
|
1436
1436
|
name: t,
|
|
1437
1437
|
rules: r
|
|
1438
1438
|
});
|
|
1439
|
-
At(e, () => c, [c]);
|
|
1440
|
-
const l = (
|
|
1439
|
+
At(e, () => c, [JSON.stringify(c)]);
|
|
1440
|
+
const l = (v, V) => Kt.map(v, (C) => {
|
|
1441
1441
|
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 =
|
|
1442
|
+
if (!Yt(C))
|
|
1443
|
+
return C;
|
|
1444
|
+
const g = C.props, S = C.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 O = u ? u[g.name] : void 0, U = O ? {
|
|
1447
|
+
...O,
|
|
1448
|
+
conditions: ((I = O.conditions) == null ? void 0 : I.map((d) => ({
|
|
1449
1449
|
...d,
|
|
1450
|
-
name: `${
|
|
1450
|
+
name: `${V}${d.name}`
|
|
1451
1451
|
}))) || []
|
|
1452
|
-
} : void 0, x = i ? i[
|
|
1452
|
+
} : void 0, x = i ? i[g.name] : void 0, B = x ? {
|
|
1453
1453
|
...x,
|
|
1454
1454
|
conditions: ((R = x.conditions) == null ? void 0 : R.map((d) => ({
|
|
1455
1455
|
...d,
|
|
1456
|
-
name: `${
|
|
1456
|
+
name: `${V}${d.name}`
|
|
1457
1457
|
}))) || []
|
|
1458
1458
|
} : void 0, f = {
|
|
1459
|
-
...
|
|
1460
|
-
name: `${
|
|
1459
|
+
...g,
|
|
1460
|
+
name: `${V}${g.name}`,
|
|
1461
1461
|
visibility: U,
|
|
1462
1462
|
disabled: B
|
|
1463
1463
|
};
|
|
1464
|
-
return
|
|
1464
|
+
return g.id !== void 0 && (f.id = `${V}${g.id}`), Ae(C, f);
|
|
1465
1465
|
}
|
|
1466
|
-
return
|
|
1467
|
-
...
|
|
1468
|
-
children: l(
|
|
1469
|
-
}) :
|
|
1466
|
+
return g.children ? Ae(C, {
|
|
1467
|
+
...g,
|
|
1468
|
+
children: l(g.children, V)
|
|
1469
|
+
}) : C;
|
|
1470
1470
|
});
|
|
1471
|
-
return /* @__PURE__ */ te(Qt, { children: c.fields.map((
|
|
1472
|
-
const
|
|
1471
|
+
return /* @__PURE__ */ te(Qt, { children: c.fields.map((v, V) => {
|
|
1472
|
+
const C = `${t}.${V}.`;
|
|
1473
1473
|
return /* @__PURE__ */ te(
|
|
1474
1474
|
"div",
|
|
1475
1475
|
{
|
|
1476
|
-
"data-index":
|
|
1476
|
+
"data-index": V,
|
|
1477
1477
|
style: { display: "contents" },
|
|
1478
1478
|
id: "field-array-item",
|
|
1479
|
-
children: l(s,
|
|
1479
|
+
children: l(s, C)
|
|
1480
1480
|
},
|
|
1481
|
-
|
|
1481
|
+
C
|
|
1482
1482
|
);
|
|
1483
1483
|
}) });
|
|
1484
1484
|
}, Ut = ({
|
|
1485
1485
|
children: t,
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
formOptions: i,
|
|
1493
|
-
showAsterisk: c,
|
|
1494
|
-
ref: l,
|
|
1495
|
-
onChange: V
|
|
1486
|
+
style: r = {},
|
|
1487
|
+
className: e = "",
|
|
1488
|
+
formOptions: s,
|
|
1489
|
+
showAsterisk: u,
|
|
1490
|
+
ref: i,
|
|
1491
|
+
onChange: c
|
|
1496
1492
|
}) => {
|
|
1497
|
-
const
|
|
1493
|
+
const l = br({
|
|
1498
1494
|
mode: "onSubmit",
|
|
1499
1495
|
reValidateMode: "onChange",
|
|
1500
1496
|
shouldFocusError: !0,
|
|
1501
|
-
...
|
|
1497
|
+
...s
|
|
1502
1498
|
});
|
|
1503
1499
|
return At(
|
|
1504
|
-
|
|
1500
|
+
i,
|
|
1505
1501
|
() => ({
|
|
1506
|
-
setValue:
|
|
1507
|
-
setError:
|
|
1508
|
-
clearErrors:
|
|
1509
|
-
getValues:
|
|
1510
|
-
reset:
|
|
1511
|
-
setFocus:
|
|
1512
|
-
resetField:
|
|
1513
|
-
trigger:
|
|
1514
|
-
unregister:
|
|
1515
|
-
watch:
|
|
1516
|
-
handleSubmit:
|
|
1517
|
-
formState:
|
|
1502
|
+
setValue: l.setValue,
|
|
1503
|
+
setError: l.setError,
|
|
1504
|
+
clearErrors: l.clearErrors,
|
|
1505
|
+
getValues: l.getValues,
|
|
1506
|
+
reset: l.reset,
|
|
1507
|
+
setFocus: l.setFocus,
|
|
1508
|
+
resetField: l.resetField,
|
|
1509
|
+
trigger: l.trigger,
|
|
1510
|
+
unregister: l.unregister,
|
|
1511
|
+
watch: l.watch,
|
|
1512
|
+
handleSubmit: l.handleSubmit,
|
|
1513
|
+
formState: l.formState
|
|
1518
1514
|
}),
|
|
1519
|
-
[
|
|
1515
|
+
[JSON.stringify(l)]
|
|
1520
1516
|
), Xt(() => {
|
|
1521
|
-
const
|
|
1522
|
-
|
|
1517
|
+
const v = l.watch((V) => {
|
|
1518
|
+
c == null || c(V);
|
|
1523
1519
|
});
|
|
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
|
-
) }) });
|
|
1520
|
+
return () => v.unsubscribe();
|
|
1521
|
+
}, [l.watch]), /* @__PURE__ */ te(Ar, { showAsterisk: u, children: /* @__PURE__ */ te(tr, { ...l, children: /* @__PURE__ */ te("div", { style: r, className: e, children: t }) }) });
|
|
1535
1522
|
};
|
|
1536
1523
|
Ut.Control = tt;
|
|
1537
1524
|
Ut.ControlArray = Er;
|