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