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