autoforma 2.10.2 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/autoform/core/FormSideEffects.d.ts +2 -6
- package/dist/autoform/demo/App.d.ts +0 -3
- package/dist/autoform/types.d.ts +20 -3
- package/dist/index.cjs.js +4 -4
- package/dist/index.es.js +629 -618
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
var De = { exports: {} },
|
|
1
|
+
import S, { useMemo as he, createContext as Wt, useContext as $t, useState as Et, useEffect as Ce, useRef as Yt, useImperativeHandle as qt } from "react";
|
|
2
|
+
var De = { exports: {} }, Ae = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
5
5
|
* react-jsx-runtime.production.js
|
|
@@ -10,26 +10,26 @@ var De = { exports: {} }, pe = {};
|
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/
|
|
12
12
|
var it;
|
|
13
|
-
function
|
|
14
|
-
if (it) return
|
|
13
|
+
function zt() {
|
|
14
|
+
if (it) return Ae;
|
|
15
15
|
it = 1;
|
|
16
16
|
var e = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
|
|
17
|
-
function t(n, o,
|
|
17
|
+
function t(n, o, a) {
|
|
18
18
|
var u = null;
|
|
19
|
-
if (
|
|
20
|
-
|
|
19
|
+
if (a !== void 0 && (u = "" + a), o.key !== void 0 && (u = "" + o.key), "key" in o) {
|
|
20
|
+
a = {};
|
|
21
21
|
for (var f in o)
|
|
22
|
-
f !== "key" && (
|
|
23
|
-
} else
|
|
24
|
-
return o =
|
|
22
|
+
f !== "key" && (a[f] = o[f]);
|
|
23
|
+
} else a = o;
|
|
24
|
+
return o = a.ref, {
|
|
25
25
|
$$typeof: e,
|
|
26
26
|
type: n,
|
|
27
27
|
key: u,
|
|
28
28
|
ref: o !== void 0 ? o : null,
|
|
29
|
-
props:
|
|
29
|
+
props: a
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return Ae.Fragment = r, Ae.jsx = t, Ae.jsxs = t, Ae;
|
|
33
33
|
}
|
|
34
34
|
var we = {};
|
|
35
35
|
/**
|
|
@@ -41,20 +41,20 @@ var we = {};
|
|
|
41
41
|
* This source code is licensed under the MIT license found in the
|
|
42
42
|
* LICENSE file in the root directory of this source tree.
|
|
43
43
|
*/
|
|
44
|
-
var
|
|
45
|
-
function
|
|
46
|
-
return
|
|
44
|
+
var ot;
|
|
45
|
+
function Ht() {
|
|
46
|
+
return ot || (ot = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
47
47
|
function e(c) {
|
|
48
48
|
if (c == null) return null;
|
|
49
49
|
if (typeof c == "function")
|
|
50
50
|
return c.$$typeof === ge ? null : c.displayName || c.name || null;
|
|
51
51
|
if (typeof c == "string") return c;
|
|
52
52
|
switch (c) {
|
|
53
|
-
case
|
|
53
|
+
case I:
|
|
54
54
|
return "Fragment";
|
|
55
|
-
case
|
|
55
|
+
case g:
|
|
56
56
|
return "Profiler";
|
|
57
|
-
case
|
|
57
|
+
case w:
|
|
58
58
|
return "StrictMode";
|
|
59
59
|
case K:
|
|
60
60
|
return "Suspense";
|
|
@@ -67,21 +67,21 @@ function zt() {
|
|
|
67
67
|
switch (typeof c.tag == "number" && console.error(
|
|
68
68
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
69
|
), c.$$typeof) {
|
|
70
|
-
case
|
|
70
|
+
case T:
|
|
71
71
|
return "Portal";
|
|
72
|
-
case
|
|
72
|
+
case P:
|
|
73
73
|
return c.displayName || "Context";
|
|
74
74
|
case J:
|
|
75
75
|
return (c._context.displayName || "Context") + ".Consumer";
|
|
76
|
-
case
|
|
77
|
-
var
|
|
78
|
-
return c = c.displayName, c || (c =
|
|
76
|
+
case k:
|
|
77
|
+
var _ = c.render;
|
|
78
|
+
return c = c.displayName, c || (c = _.displayName || _.name || "", c = c !== "" ? "ForwardRef(" + c + ")" : "ForwardRef"), c;
|
|
79
79
|
case j:
|
|
80
|
-
return
|
|
80
|
+
return _ = c.displayName || null, _ !== null ? _ : e(c.type) || "Memo";
|
|
81
81
|
case G:
|
|
82
|
-
|
|
82
|
+
_ = c._payload, c = c._init;
|
|
83
83
|
try {
|
|
84
|
-
return e(c(
|
|
84
|
+
return e(c(_));
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -93,54 +93,54 @@ function zt() {
|
|
|
93
93
|
function t(c) {
|
|
94
94
|
try {
|
|
95
95
|
r(c);
|
|
96
|
-
var
|
|
96
|
+
var _ = !1;
|
|
97
97
|
} catch {
|
|
98
|
-
|
|
98
|
+
_ = !0;
|
|
99
99
|
}
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
var
|
|
103
|
-
return
|
|
104
|
-
|
|
100
|
+
if (_) {
|
|
101
|
+
_ = console;
|
|
102
|
+
var N = _.error, M = typeof Symbol == "function" && Symbol.toStringTag && c[Symbol.toStringTag] || c.constructor.name || "Object";
|
|
103
|
+
return N.call(
|
|
104
|
+
_,
|
|
105
105
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
-
|
|
106
|
+
M
|
|
107
107
|
), r(c);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
function n(c) {
|
|
111
|
-
if (c ===
|
|
111
|
+
if (c === I) return "<>";
|
|
112
112
|
if (typeof c == "object" && c !== null && c.$$typeof === G)
|
|
113
113
|
return "<...>";
|
|
114
114
|
try {
|
|
115
|
-
var
|
|
116
|
-
return
|
|
115
|
+
var _ = e(c);
|
|
116
|
+
return _ ? "<" + _ + ">" : "<...>";
|
|
117
117
|
} catch {
|
|
118
118
|
return "<...>";
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
function o() {
|
|
122
|
-
var c =
|
|
122
|
+
var c = x.A;
|
|
123
123
|
return c === null ? null : c.getOwner();
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function a() {
|
|
126
126
|
return Error("react-stack-top-frame");
|
|
127
127
|
}
|
|
128
128
|
function u(c) {
|
|
129
|
-
if (
|
|
130
|
-
var
|
|
131
|
-
if (
|
|
129
|
+
if (R.call(c, "key")) {
|
|
130
|
+
var _ = Object.getOwnPropertyDescriptor(c, "key").get;
|
|
131
|
+
if (_ && _.isReactWarning) return !1;
|
|
132
132
|
}
|
|
133
133
|
return c.key !== void 0;
|
|
134
134
|
}
|
|
135
|
-
function f(c,
|
|
136
|
-
function
|
|
135
|
+
function f(c, _) {
|
|
136
|
+
function N() {
|
|
137
137
|
ee || (ee = !0, console.error(
|
|
138
138
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
139
|
-
|
|
139
|
+
_
|
|
140
140
|
));
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
get:
|
|
142
|
+
N.isReactWarning = !0, Object.defineProperty(c, "key", {
|
|
143
|
+
get: N,
|
|
144
144
|
configurable: !0
|
|
145
145
|
});
|
|
146
146
|
}
|
|
@@ -150,15 +150,15 @@ function zt() {
|
|
|
150
150
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
151
|
)), c = this.props.ref, c !== void 0 ? c : null;
|
|
152
152
|
}
|
|
153
|
-
function A(c,
|
|
154
|
-
var
|
|
153
|
+
function A(c, _, N, M, _e, xe) {
|
|
154
|
+
var W = N.ref;
|
|
155
155
|
return c = {
|
|
156
|
-
$$typeof:
|
|
156
|
+
$$typeof: U,
|
|
157
157
|
type: c,
|
|
158
|
-
key:
|
|
159
|
-
props:
|
|
160
|
-
_owner:
|
|
161
|
-
}, (
|
|
158
|
+
key: _,
|
|
159
|
+
props: N,
|
|
160
|
+
_owner: M
|
|
161
|
+
}, (W !== void 0 ? W : null) !== null ? Object.defineProperty(c, "ref", {
|
|
162
162
|
enumerable: !1,
|
|
163
163
|
get: F
|
|
164
164
|
}) : Object.defineProperty(c, "ref", { enumerable: !1, value: null }), c._store = {}, Object.defineProperty(c._store, "validated", {
|
|
@@ -183,61 +183,61 @@ function zt() {
|
|
|
183
183
|
value: xe
|
|
184
184
|
}), Object.freeze && (Object.freeze(c.props), Object.freeze(c)), c;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
var
|
|
188
|
-
if (
|
|
189
|
-
if (
|
|
190
|
-
if (
|
|
191
|
-
for (
|
|
192
|
-
|
|
193
|
-
Object.freeze && Object.freeze(
|
|
186
|
+
function D(c, _, N, M, _e, xe) {
|
|
187
|
+
var W = _.children;
|
|
188
|
+
if (W !== void 0)
|
|
189
|
+
if (M)
|
|
190
|
+
if (B(W)) {
|
|
191
|
+
for (M = 0; M < W.length; M++)
|
|
192
|
+
E(W[M]);
|
|
193
|
+
Object.freeze && Object.freeze(W);
|
|
194
194
|
} else
|
|
195
195
|
console.error(
|
|
196
196
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
197
197
|
);
|
|
198
|
-
else
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
var le = Object.keys(
|
|
202
|
-
return
|
|
198
|
+
else E(W);
|
|
199
|
+
if (R.call(_, "key")) {
|
|
200
|
+
W = e(c);
|
|
201
|
+
var le = Object.keys(_).filter(function(pe) {
|
|
202
|
+
return pe !== "key";
|
|
203
203
|
});
|
|
204
|
-
|
|
204
|
+
M = 0 < le.length ? "{key: someKey, " + le.join(": ..., ") + ": ...}" : "{key: someKey}", ye[W + M] || (le = 0 < le.length ? "{" + le.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
205
205
|
`A props object containing a "key" prop is being spread into JSX:
|
|
206
206
|
let props = %s;
|
|
207
207
|
<%s {...props} />
|
|
208
208
|
React keys must be passed directly to JSX without using spread:
|
|
209
209
|
let props = %s;
|
|
210
210
|
<%s key={someKey} {...props} />`,
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
M,
|
|
212
|
+
W,
|
|
213
213
|
le,
|
|
214
|
-
|
|
215
|
-
), ye[
|
|
214
|
+
W
|
|
215
|
+
), ye[W + M] = !0);
|
|
216
216
|
}
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
for (var Ee in
|
|
220
|
-
Ee !== "key" && (
|
|
221
|
-
} else
|
|
222
|
-
return
|
|
223
|
-
|
|
217
|
+
if (W = null, N !== void 0 && (t(N), W = "" + N), u(_) && (t(_.key), W = "" + _.key), "key" in _) {
|
|
218
|
+
N = {};
|
|
219
|
+
for (var Ee in _)
|
|
220
|
+
Ee !== "key" && (N[Ee] = _[Ee]);
|
|
221
|
+
} else N = _;
|
|
222
|
+
return W && f(
|
|
223
|
+
N,
|
|
224
224
|
typeof c == "function" ? c.displayName || c.name || "Unknown" : c
|
|
225
225
|
), A(
|
|
226
226
|
c,
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
W,
|
|
228
|
+
N,
|
|
229
229
|
o(),
|
|
230
230
|
_e,
|
|
231
231
|
xe
|
|
232
232
|
);
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function E(c) {
|
|
235
235
|
p(c) ? c._store && (c._store.validated = 1) : typeof c == "object" && c !== null && c.$$typeof === G && (c._payload.status === "fulfilled" ? p(c._payload.value) && c._payload.value._store && (c._payload.value._store.validated = 1) : c._store && (c._store.validated = 1));
|
|
236
236
|
}
|
|
237
237
|
function p(c) {
|
|
238
|
-
return typeof c == "object" && c !== null && c.$$typeof ===
|
|
238
|
+
return typeof c == "object" && c !== null && c.$$typeof === U;
|
|
239
239
|
}
|
|
240
|
-
var b =
|
|
240
|
+
var b = S, U = Symbol.for("react.transitional.element"), T = Symbol.for("react.portal"), I = Symbol.for("react.fragment"), w = Symbol.for("react.strict_mode"), g = Symbol.for("react.profiler"), J = Symbol.for("react.consumer"), P = Symbol.for("react.context"), k = Symbol.for("react.forward_ref"), K = Symbol.for("react.suspense"), oe = Symbol.for("react.suspense_list"), j = Symbol.for("react.memo"), G = Symbol.for("react.lazy"), X = Symbol.for("react.activity"), ge = Symbol.for("react.client.reference"), x = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, R = Object.prototype.hasOwnProperty, B = Array.isArray, Y = console.createTask ? console.createTask : function() {
|
|
241
241
|
return null;
|
|
242
242
|
};
|
|
243
243
|
b = {
|
|
@@ -247,64 +247,64 @@ React keys must be passed directly to JSX without using spread:
|
|
|
247
247
|
};
|
|
248
248
|
var ee, Z = {}, fe = b.react_stack_bottom_frame.bind(
|
|
249
249
|
b,
|
|
250
|
-
|
|
251
|
-
)(), de = Y(n(
|
|
252
|
-
we.Fragment =
|
|
253
|
-
var
|
|
254
|
-
return
|
|
250
|
+
a
|
|
251
|
+
)(), de = Y(n(a)), ye = {};
|
|
252
|
+
we.Fragment = I, we.jsx = function(c, _, N) {
|
|
253
|
+
var M = 1e4 > x.recentlyCreatedOwnerStacks++;
|
|
254
|
+
return D(
|
|
255
255
|
c,
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
_,
|
|
257
|
+
N,
|
|
258
258
|
!1,
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
M ? Error("react-stack-top-frame") : fe,
|
|
260
|
+
M ? Y(n(c)) : de
|
|
261
261
|
);
|
|
262
|
-
}, we.jsxs = function(c,
|
|
263
|
-
var
|
|
264
|
-
return
|
|
262
|
+
}, we.jsxs = function(c, _, N) {
|
|
263
|
+
var M = 1e4 > x.recentlyCreatedOwnerStacks++;
|
|
264
|
+
return D(
|
|
265
265
|
c,
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
_,
|
|
267
|
+
N,
|
|
268
268
|
!0,
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
M ? Error("react-stack-top-frame") : fe,
|
|
270
|
+
M ? Y(n(c)) : de
|
|
271
271
|
);
|
|
272
272
|
};
|
|
273
273
|
})()), we;
|
|
274
274
|
}
|
|
275
|
-
var
|
|
276
|
-
function
|
|
277
|
-
return
|
|
275
|
+
var lt;
|
|
276
|
+
function Jt() {
|
|
277
|
+
return lt || (lt = 1, process.env.NODE_ENV === "production" ? De.exports = zt() : De.exports = Ht()), De.exports;
|
|
278
278
|
}
|
|
279
|
-
var V =
|
|
279
|
+
var V = Jt(), Te = (e) => e.type === "checkbox", ve = (e) => e instanceof Date, te = (e) => e == null;
|
|
280
280
|
const Vt = (e) => typeof e == "object";
|
|
281
|
-
var z = (e) => !te(e) && !Array.isArray(e) && Vt(e) && !ve(e),
|
|
281
|
+
var z = (e) => !te(e) && !Array.isArray(e) && Vt(e) && !ve(e), Gt = (e) => z(e) && e.target ? Te(e.target) ? e.target.checked : e.target.value : e, Xt = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, Zt = (e, r) => e.has(Xt(r)), Qt = (e) => {
|
|
282
282
|
const r = e.constructor && e.constructor.prototype;
|
|
283
283
|
return z(r) && r.hasOwnProperty("isPrototypeOf");
|
|
284
|
-
},
|
|
284
|
+
}, He = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
285
285
|
function H(e) {
|
|
286
286
|
if (e instanceof Date)
|
|
287
287
|
return new Date(e);
|
|
288
288
|
const r = typeof FileList < "u" && e instanceof FileList;
|
|
289
|
-
if (
|
|
289
|
+
if (He && (e instanceof Blob || r))
|
|
290
290
|
return e;
|
|
291
291
|
const t = Array.isArray(e);
|
|
292
|
-
if (!t && !(z(e) &&
|
|
292
|
+
if (!t && !(z(e) && Qt(e)))
|
|
293
293
|
return e;
|
|
294
294
|
const n = t ? [] : Object.create(Object.getPrototypeOf(e));
|
|
295
295
|
for (const o in e)
|
|
296
296
|
Object.prototype.hasOwnProperty.call(e, o) && (n[o] = H(e[o]));
|
|
297
297
|
return n;
|
|
298
298
|
}
|
|
299
|
-
var Ie = (e) => /^\w*$/.test(e),
|
|
299
|
+
var Ie = (e) => /^\w*$/.test(e), $ = (e) => e === void 0, Je = (e) => Array.isArray(e) ? e.filter(Boolean) : [], Ge = (e) => Je(e.replace(/["|']|\]/g, "").split(/\.|\[/)), h = (e, r, t) => {
|
|
300
300
|
if (!r || !z(e))
|
|
301
301
|
return t;
|
|
302
|
-
const n = (Ie(r) ? [r] :
|
|
303
|
-
return
|
|
304
|
-
}, ue = (e) => typeof e == "boolean", ne = (e) => typeof e == "function",
|
|
302
|
+
const n = (Ie(r) ? [r] : Ge(r)).reduce((o, a) => te(o) ? o : o[a], e);
|
|
303
|
+
return $(n) || n === e ? $(e[r]) ? t : e[r] : n;
|
|
304
|
+
}, ue = (e) => typeof e == "boolean", ne = (e) => typeof e == "function", L = (e, r, t) => {
|
|
305
305
|
let n = -1;
|
|
306
|
-
const o = Ie(r) ? [r] :
|
|
307
|
-
for (; ++n <
|
|
306
|
+
const o = Ie(r) ? [r] : Ge(r), a = o.length, u = a - 1;
|
|
307
|
+
for (; ++n < a; ) {
|
|
308
308
|
const f = o[n];
|
|
309
309
|
let F = t;
|
|
310
310
|
if (n !== u) {
|
|
@@ -316,10 +316,10 @@ var Ie = (e) => /^\w*$/.test(e), M = (e) => e === void 0, He = (e) => Array.isAr
|
|
|
316
316
|
e[f] = F, e = e[f];
|
|
317
317
|
}
|
|
318
318
|
};
|
|
319
|
-
const
|
|
319
|
+
const ut = {
|
|
320
320
|
BLUR: "blur",
|
|
321
321
|
FOCUS_OUT: "focusout"
|
|
322
|
-
},
|
|
322
|
+
}, ae = {
|
|
323
323
|
onBlur: "onBlur",
|
|
324
324
|
onChange: "onChange",
|
|
325
325
|
onSubmit: "onSubmit",
|
|
@@ -333,29 +333,29 @@ const lt = {
|
|
|
333
333
|
pattern: "pattern",
|
|
334
334
|
required: "required",
|
|
335
335
|
validate: "validate"
|
|
336
|
-
},
|
|
337
|
-
|
|
338
|
-
const be = () =>
|
|
336
|
+
}, Xe = S.createContext(null);
|
|
337
|
+
Xe.displayName = "HookFormContext";
|
|
338
|
+
const be = () => S.useContext(Xe), Kt = (e) => {
|
|
339
339
|
const { children: r, ...t } = e;
|
|
340
|
-
return
|
|
340
|
+
return S.createElement(Xe.Provider, { value: t }, r);
|
|
341
341
|
};
|
|
342
|
-
var
|
|
342
|
+
var er = (e, r, t, n = !0) => {
|
|
343
343
|
const o = {
|
|
344
344
|
defaultValues: r._defaultValues
|
|
345
345
|
};
|
|
346
|
-
for (const
|
|
347
|
-
Object.defineProperty(o,
|
|
346
|
+
for (const a in e)
|
|
347
|
+
Object.defineProperty(o, a, {
|
|
348
348
|
get: () => {
|
|
349
|
-
const u =
|
|
350
|
-
return r._proxyFormState[u] !==
|
|
349
|
+
const u = a;
|
|
350
|
+
return r._proxyFormState[u] !== ae.all && (r._proxyFormState[u] = !n || ae.all), e[u];
|
|
351
351
|
}
|
|
352
352
|
});
|
|
353
353
|
return o;
|
|
354
354
|
};
|
|
355
|
-
const Ft = typeof window < "u" ?
|
|
356
|
-
var re = (e) => typeof e == "string",
|
|
357
|
-
function
|
|
358
|
-
if (
|
|
355
|
+
const Ft = typeof window < "u" ? S.useLayoutEffect : S.useEffect;
|
|
356
|
+
var re = (e) => typeof e == "string", Ye = (e, r, t, n, o) => re(e) ? (n && r.watch.add(e), h(t, e, o)) : Array.isArray(e) ? e.map((a) => (n && r.watch.add(a), h(t, a))) : (n && (r.watchAll = !0), t), qe = (e) => te(e) || !Vt(e);
|
|
357
|
+
function ie(e, r, t = /* @__PURE__ */ new WeakSet()) {
|
|
358
|
+
if (qe(e) || qe(r))
|
|
359
359
|
return Object.is(e, r);
|
|
360
360
|
if (ve(e) && ve(r))
|
|
361
361
|
return e.getTime() === r.getTime();
|
|
@@ -365,74 +365,74 @@ function ae(e, r, t = /* @__PURE__ */ new WeakSet()) {
|
|
|
365
365
|
if (t.has(e) || t.has(r))
|
|
366
366
|
return !0;
|
|
367
367
|
t.add(e), t.add(r);
|
|
368
|
-
for (const
|
|
369
|
-
const u = e[
|
|
370
|
-
if (!o.includes(
|
|
368
|
+
for (const a of n) {
|
|
369
|
+
const u = e[a];
|
|
370
|
+
if (!o.includes(a))
|
|
371
371
|
return !1;
|
|
372
|
-
if (
|
|
373
|
-
const f = r[
|
|
374
|
-
if (ve(u) && ve(f) || z(u) && z(f) || Array.isArray(u) && Array.isArray(f) ? !
|
|
372
|
+
if (a !== "ref") {
|
|
373
|
+
const f = r[a];
|
|
374
|
+
if (ve(u) && ve(f) || z(u) && z(f) || Array.isArray(u) && Array.isArray(f) ? !ie(u, f, t) : !Object.is(u, f))
|
|
375
375
|
return !1;
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
return !0;
|
|
379
379
|
}
|
|
380
|
-
function
|
|
381
|
-
const r = be(), { control: t = r.control, name: n, defaultValue: o, disabled:
|
|
380
|
+
function pt(e) {
|
|
381
|
+
const r = be(), { control: t = r.control, name: n, defaultValue: o, disabled: a, exact: u, compute: f } = e || {}, F = S.useRef(o), A = S.useRef(f), D = S.useRef(void 0), E = S.useRef(t), p = S.useRef(n);
|
|
382
382
|
A.current = f;
|
|
383
|
-
const [b,
|
|
384
|
-
const
|
|
385
|
-
return A.current ? A.current(
|
|
386
|
-
}),
|
|
387
|
-
const
|
|
388
|
-
return A.current ? A.current(
|
|
389
|
-
}, [t._formValues, t._names, n]),
|
|
390
|
-
if (!
|
|
391
|
-
const
|
|
383
|
+
const [b, U] = S.useState(() => {
|
|
384
|
+
const P = t._getWatch(n, F.current);
|
|
385
|
+
return A.current ? A.current(P) : P;
|
|
386
|
+
}), T = S.useCallback((P) => {
|
|
387
|
+
const k = Ye(n, t._names, P || t._formValues, !1, F.current);
|
|
388
|
+
return A.current ? A.current(k) : k;
|
|
389
|
+
}, [t._formValues, t._names, n]), I = S.useCallback((P) => {
|
|
390
|
+
if (!a) {
|
|
391
|
+
const k = Ye(n, t._names, P || t._formValues, !1, F.current);
|
|
392
392
|
if (A.current) {
|
|
393
|
-
const K = A.current(
|
|
394
|
-
|
|
393
|
+
const K = A.current(k);
|
|
394
|
+
ie(K, D.current) || (U(K), D.current = K);
|
|
395
395
|
} else
|
|
396
|
-
|
|
396
|
+
U(k);
|
|
397
397
|
}
|
|
398
|
-
}, [t._formValues, t._names,
|
|
399
|
-
Ft(() => ((
|
|
398
|
+
}, [t._formValues, t._names, a, n]);
|
|
399
|
+
Ft(() => ((E.current !== t || !ie(p.current, n)) && (E.current = t, p.current = n, I()), t._subscribe({
|
|
400
400
|
name: n,
|
|
401
401
|
formState: {
|
|
402
402
|
values: !0
|
|
403
403
|
},
|
|
404
404
|
exact: u,
|
|
405
|
-
callback: (
|
|
406
|
-
|
|
405
|
+
callback: (P) => {
|
|
406
|
+
I(P.values);
|
|
407
407
|
}
|
|
408
|
-
})), [t, u, n,
|
|
409
|
-
const
|
|
410
|
-
if (
|
|
408
|
+
})), [t, u, n, I]), S.useEffect(() => t._removeUnmounted());
|
|
409
|
+
const w = E.current !== t, g = p.current, J = S.useMemo(() => {
|
|
410
|
+
if (a)
|
|
411
411
|
return null;
|
|
412
|
-
const
|
|
413
|
-
return
|
|
414
|
-
}, [
|
|
412
|
+
const P = !w && !ie(g, n);
|
|
413
|
+
return w || P ? T() : null;
|
|
414
|
+
}, [a, w, n, g, T]);
|
|
415
415
|
return J !== null ? J : b;
|
|
416
416
|
}
|
|
417
|
-
var
|
|
417
|
+
var tr = (e, r, t, n, o) => r ? {
|
|
418
418
|
...t[e],
|
|
419
419
|
types: {
|
|
420
420
|
...t[e] && t[e].types ? t[e].types : {},
|
|
421
421
|
[n]: o || !0
|
|
422
422
|
}
|
|
423
|
-
} : {}, ke = (e) => Array.isArray(e) ? e : [e],
|
|
423
|
+
} : {}, ke = (e) => Array.isArray(e) ? e : [e], ct = () => {
|
|
424
424
|
let e = [];
|
|
425
425
|
return {
|
|
426
426
|
get observers() {
|
|
427
427
|
return e;
|
|
428
428
|
},
|
|
429
429
|
next: (o) => {
|
|
430
|
-
for (const
|
|
431
|
-
|
|
430
|
+
for (const a of e)
|
|
431
|
+
a.next && a.next(o);
|
|
432
432
|
},
|
|
433
433
|
subscribe: (o) => (e.push(o), {
|
|
434
434
|
unsubscribe: () => {
|
|
435
|
-
e = e.filter((
|
|
435
|
+
e = e.filter((a) => a !== o);
|
|
436
436
|
}
|
|
437
437
|
}),
|
|
438
438
|
unsubscribe: () => {
|
|
@@ -440,74 +440,74 @@ var er = (e, r, t, n, o) => r ? {
|
|
|
440
440
|
}
|
|
441
441
|
};
|
|
442
442
|
};
|
|
443
|
-
function
|
|
443
|
+
function At(e, r) {
|
|
444
444
|
const t = {};
|
|
445
445
|
for (const n in e)
|
|
446
446
|
if (e.hasOwnProperty(n)) {
|
|
447
|
-
const o = e[n],
|
|
448
|
-
if (o && z(o) &&
|
|
449
|
-
const u =
|
|
447
|
+
const o = e[n], a = r[n];
|
|
448
|
+
if (o && z(o) && a) {
|
|
449
|
+
const u = At(o, a);
|
|
450
450
|
z(u) && (t[n] = u);
|
|
451
|
-
} else e[n] && (t[n] =
|
|
451
|
+
} else e[n] && (t[n] = a);
|
|
452
452
|
}
|
|
453
453
|
return t;
|
|
454
454
|
}
|
|
455
|
-
var Q = (e) => z(e) && !Object.keys(e).length,
|
|
456
|
-
if (!
|
|
455
|
+
var Q = (e) => z(e) && !Object.keys(e).length, Ze = (e) => e.type === "file", je = (e) => {
|
|
456
|
+
if (!He)
|
|
457
457
|
return !1;
|
|
458
458
|
const r = e ? e.ownerDocument : 0;
|
|
459
459
|
return e instanceof (r && r.defaultView ? r.defaultView.HTMLElement : HTMLElement);
|
|
460
|
-
}, wt = (e) => e.type === "select-multiple",
|
|
461
|
-
function
|
|
460
|
+
}, wt = (e) => e.type === "select-multiple", Qe = (e) => e.type === "radio", rr = (e) => Qe(e) || Te(e), We = (e) => je(e) && e.isConnected;
|
|
461
|
+
function sr(e, r) {
|
|
462
462
|
const t = r.slice(0, -1).length;
|
|
463
463
|
let n = 0;
|
|
464
464
|
for (; n < t; )
|
|
465
|
-
e =
|
|
465
|
+
e = $(e) ? n++ : e[r[n++]];
|
|
466
466
|
return e;
|
|
467
467
|
}
|
|
468
|
-
function
|
|
468
|
+
function nr(e) {
|
|
469
469
|
for (const r in e)
|
|
470
|
-
if (e.hasOwnProperty(r) &&
|
|
470
|
+
if (e.hasOwnProperty(r) && !$(e[r]))
|
|
471
471
|
return !1;
|
|
472
472
|
return !0;
|
|
473
473
|
}
|
|
474
474
|
function q(e, r) {
|
|
475
|
-
const t = Array.isArray(r) ? r : Ie(r) ? [r] :
|
|
476
|
-
return n && delete n[
|
|
475
|
+
const t = Array.isArray(r) ? r : Ie(r) ? [r] : Ge(r), n = t.length === 1 ? e : sr(e, t), o = t.length - 1, a = t[o];
|
|
476
|
+
return n && delete n[a], o !== 0 && (z(n) && Q(n) || Array.isArray(n) && nr(n)) && q(e, t.slice(0, -1)), e;
|
|
477
477
|
}
|
|
478
|
-
var
|
|
478
|
+
var ar = (e) => {
|
|
479
479
|
for (const r in e)
|
|
480
480
|
if (ne(e[r]))
|
|
481
481
|
return !0;
|
|
482
482
|
return !1;
|
|
483
483
|
};
|
|
484
484
|
function Rt(e) {
|
|
485
|
-
return Array.isArray(e) || z(e) && !
|
|
485
|
+
return Array.isArray(e) || z(e) && !ar(e);
|
|
486
486
|
}
|
|
487
|
-
function
|
|
487
|
+
function ze(e, r = {}) {
|
|
488
488
|
for (const t in e) {
|
|
489
489
|
const n = e[t];
|
|
490
|
-
Rt(n) ? (r[t] = Array.isArray(n) ? [] : {},
|
|
490
|
+
Rt(n) ? (r[t] = Array.isArray(n) ? [] : {}, ze(n, r[t])) : $(n) || (r[t] = !0);
|
|
491
491
|
}
|
|
492
492
|
return r;
|
|
493
493
|
}
|
|
494
494
|
function Fe(e, r, t) {
|
|
495
|
-
t || (t =
|
|
495
|
+
t || (t = ze(r));
|
|
496
496
|
for (const n in e) {
|
|
497
497
|
const o = e[n];
|
|
498
498
|
if (Rt(o))
|
|
499
|
-
|
|
499
|
+
$(r) || qe(t[n]) ? t[n] = ze(o, Array.isArray(o) ? [] : {}) : Fe(o, te(r) ? {} : r[n], t[n]);
|
|
500
500
|
else {
|
|
501
|
-
const
|
|
502
|
-
t[n] = !
|
|
501
|
+
const a = r[n];
|
|
502
|
+
t[n] = !ie(o, a);
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
505
|
return t;
|
|
506
506
|
}
|
|
507
|
-
const
|
|
507
|
+
const ft = {
|
|
508
508
|
value: !1,
|
|
509
509
|
isValid: !1
|
|
510
|
-
},
|
|
510
|
+
}, dt = { value: !0, isValid: !0 };
|
|
511
511
|
var kt = (e) => {
|
|
512
512
|
if (Array.isArray(e)) {
|
|
513
513
|
if (e.length > 1) {
|
|
@@ -516,28 +516,28 @@ var kt = (e) => {
|
|
|
516
516
|
}
|
|
517
517
|
return e[0].checked && !e[0].disabled ? (
|
|
518
518
|
// @ts-expect-error expected to work in the browser
|
|
519
|
-
e[0].attributes &&
|
|
520
|
-
) :
|
|
519
|
+
e[0].attributes && !$(e[0].attributes.value) ? $(e[0].value) || e[0].value === "" ? dt : { value: e[0].value, isValid: !0 } : dt
|
|
520
|
+
) : ft;
|
|
521
521
|
}
|
|
522
|
-
return
|
|
523
|
-
}, St = (e, { valueAsNumber: r, valueAsDate: t, setValueAs: n }) =>
|
|
524
|
-
const
|
|
522
|
+
return ft;
|
|
523
|
+
}, St = (e, { valueAsNumber: r, valueAsDate: t, setValueAs: n }) => $(e) ? e : r ? e === "" ? NaN : e && +e : t && re(e) ? new Date(e) : n ? n(e) : e;
|
|
524
|
+
const yt = {
|
|
525
525
|
isValid: !1,
|
|
526
526
|
value: null
|
|
527
527
|
};
|
|
528
528
|
var Tt = (e) => Array.isArray(e) ? e.reduce((r, t) => t && t.checked && !t.disabled ? {
|
|
529
529
|
isValid: !0,
|
|
530
530
|
value: t.value
|
|
531
|
-
} : r,
|
|
532
|
-
function
|
|
531
|
+
} : r, yt) : yt;
|
|
532
|
+
function mt(e) {
|
|
533
533
|
const r = e.ref;
|
|
534
|
-
return
|
|
534
|
+
return Ze(r) ? r.files : Qe(r) ? Tt(e.refs).value : wt(r) ? [...r.selectedOptions].map(({ value: t }) => t) : Te(r) ? kt(e.refs).value : St($(r.value) ? e.ref.value : r.value, e);
|
|
535
535
|
}
|
|
536
536
|
var ir = (e, r, t, n) => {
|
|
537
537
|
const o = {};
|
|
538
|
-
for (const
|
|
539
|
-
const u = h(r,
|
|
540
|
-
u &&
|
|
538
|
+
for (const a of e) {
|
|
539
|
+
const u = h(r, a);
|
|
540
|
+
u && L(o, a, u._f);
|
|
541
541
|
}
|
|
542
542
|
return {
|
|
543
543
|
criteriaMode: t,
|
|
@@ -545,20 +545,20 @@ var ir = (e, r, t, n) => {
|
|
|
545
545
|
fields: o,
|
|
546
546
|
shouldUseNativeValidation: n
|
|
547
547
|
};
|
|
548
|
-
}, Pe = (e) => e instanceof RegExp, Re = (e) =>
|
|
549
|
-
isOnSubmit: !e || e ===
|
|
550
|
-
isOnBlur: e ===
|
|
551
|
-
isOnChange: e ===
|
|
552
|
-
isOnAll: e ===
|
|
553
|
-
isOnTouch: e ===
|
|
548
|
+
}, Pe = (e) => e instanceof RegExp, Re = (e) => $(e) ? e : Pe(e) ? e.source : z(e) ? Pe(e.value) ? e.value.source : e.value : e, ht = (e) => ({
|
|
549
|
+
isOnSubmit: !e || e === ae.onSubmit,
|
|
550
|
+
isOnBlur: e === ae.onBlur,
|
|
551
|
+
isOnChange: e === ae.onChange,
|
|
552
|
+
isOnAll: e === ae.all,
|
|
553
|
+
isOnTouch: e === ae.onTouched
|
|
554
554
|
});
|
|
555
|
-
const
|
|
556
|
-
var
|
|
555
|
+
const vt = "AsyncFunction";
|
|
556
|
+
var or = (e) => !!e && !!e.validate && !!(ne(e.validate) && e.validate.constructor.name === vt || z(e.validate) && Object.values(e.validate).find((r) => r.constructor.name === vt)), lr = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), bt = (e, r, t) => !t && (r.watchAll || r.watch.has(e) || [...r.watch].some((n) => e.startsWith(n) && /^\.\w+/.test(e.slice(n.length))));
|
|
557
557
|
const Se = (e, r, t, n) => {
|
|
558
558
|
for (const o of t || Object.keys(e)) {
|
|
559
|
-
const
|
|
560
|
-
if (
|
|
561
|
-
const { _f: u, ...f } =
|
|
559
|
+
const a = h(e, o);
|
|
560
|
+
if (a) {
|
|
561
|
+
const { _f: u, ...f } = a;
|
|
562
562
|
if (u) {
|
|
563
563
|
if (u.refs && u.refs[0] && r(u.refs[0], o) && !n)
|
|
564
564
|
return !0;
|
|
@@ -571,7 +571,7 @@ const Se = (e, r, t, n) => {
|
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
573
|
};
|
|
574
|
-
function
|
|
574
|
+
function gt(e, r, t) {
|
|
575
575
|
const n = h(e, t);
|
|
576
576
|
if (n || Ie(t))
|
|
577
577
|
return {
|
|
@@ -580,17 +580,17 @@ function bt(e, r, t) {
|
|
|
580
580
|
};
|
|
581
581
|
const o = t.split(".");
|
|
582
582
|
for (; o.length; ) {
|
|
583
|
-
const
|
|
584
|
-
if (u && !Array.isArray(u) && t !==
|
|
583
|
+
const a = o.join("."), u = h(r, a), f = h(e, a);
|
|
584
|
+
if (u && !Array.isArray(u) && t !== a)
|
|
585
585
|
return { name: t };
|
|
586
586
|
if (f && f.type)
|
|
587
587
|
return {
|
|
588
|
-
name:
|
|
588
|
+
name: a,
|
|
589
589
|
error: f
|
|
590
590
|
};
|
|
591
591
|
if (f && f.root && f.root.type)
|
|
592
592
|
return {
|
|
593
|
-
name: `${
|
|
593
|
+
name: `${a}.root`,
|
|
594
594
|
error: f.root
|
|
595
595
|
};
|
|
596
596
|
o.pop();
|
|
@@ -599,15 +599,15 @@ function bt(e, r, t) {
|
|
|
599
599
|
name: t
|
|
600
600
|
};
|
|
601
601
|
}
|
|
602
|
-
var
|
|
602
|
+
var ur = (e, r, t, n) => {
|
|
603
603
|
t(e);
|
|
604
|
-
const { name: o, ...
|
|
605
|
-
return Q(
|
|
606
|
-
},
|
|
604
|
+
const { name: o, ...a } = e;
|
|
605
|
+
return Q(a) || Object.keys(a).length >= Object.keys(r).length || Object.keys(a).find((u) => r[u] === (!n || ae.all));
|
|
606
|
+
}, cr = (e, r, t) => !e || !r || e === r || ke(e).some((n) => n && (t ? n === r : n.startsWith(r) || r.startsWith(n))), fr = (e, r, t, n, o) => o.isOnAll ? !1 : !t && o.isOnTouch ? !(r || e) : (t ? n.isOnBlur : o.isOnBlur) ? !e : (t ? n.isOnChange : o.isOnChange) ? e : !0, dr = (e, r) => !Je(h(e, r)).length && q(e, r), yr = (e, r, t) => {
|
|
607
607
|
const n = ke(h(e, t));
|
|
608
|
-
return
|
|
608
|
+
return L(n, "root", r[t]), L(e, t, n), e;
|
|
609
609
|
};
|
|
610
|
-
function
|
|
610
|
+
function _t(e, r, t = "validate") {
|
|
611
611
|
if (re(e) || Array.isArray(e) && e.every(re) || ue(e) && !e)
|
|
612
612
|
return {
|
|
613
613
|
type: t,
|
|
@@ -618,95 +618,95 @@ function gt(e, r, t = "validate") {
|
|
|
618
618
|
var Ve = (e) => z(e) && !Pe(e) ? e : {
|
|
619
619
|
value: e,
|
|
620
620
|
message: ""
|
|
621
|
-
},
|
|
622
|
-
const { ref: u, refs: f, required: F, maxLength: A, minLength:
|
|
623
|
-
if (
|
|
621
|
+
}, xt = async (e, r, t, n, o, a) => {
|
|
622
|
+
const { ref: u, refs: f, required: F, maxLength: A, minLength: D, min: E, max: p, pattern: b, validate: U, name: T, valueAsNumber: I, mount: w } = e._f, g = h(t, T);
|
|
623
|
+
if (!w || r.has(T))
|
|
624
624
|
return {};
|
|
625
|
-
const J = f ? f[0] : u,
|
|
626
|
-
o && J.reportValidity && (J.setCustomValidity(ue(
|
|
627
|
-
},
|
|
628
|
-
const Z =
|
|
629
|
-
|
|
630
|
-
type:
|
|
625
|
+
const J = f ? f[0] : u, P = (x) => {
|
|
626
|
+
o && J.reportValidity && (J.setCustomValidity(ue(x) ? "" : x || ""), J.reportValidity());
|
|
627
|
+
}, k = {}, K = Qe(u), oe = Te(u), j = K || oe, G = (I || Ze(u)) && $(u.value) && $(g) || je(u) && u.value === "" || g === "" || Array.isArray(g) && !g.length, X = tr.bind(null, T, n, k), ge = (x, R, B, Y = ce.maxLength, ee = ce.minLength) => {
|
|
628
|
+
const Z = x ? R : B;
|
|
629
|
+
k[T] = {
|
|
630
|
+
type: x ? Y : ee,
|
|
631
631
|
message: Z,
|
|
632
632
|
ref: u,
|
|
633
|
-
...X(
|
|
633
|
+
...X(x ? Y : ee, Z)
|
|
634
634
|
};
|
|
635
635
|
};
|
|
636
|
-
if (
|
|
637
|
-
const { value:
|
|
638
|
-
if (
|
|
636
|
+
if (a ? !Array.isArray(g) || !g.length : F && (!j && (G || te(g)) || ue(g) && !g || oe && !kt(f).isValid || K && !Tt(f).isValid)) {
|
|
637
|
+
const { value: x, message: R } = re(F) ? { value: !!F, message: F } : Ve(F);
|
|
638
|
+
if (x && (k[T] = {
|
|
639
639
|
type: ce.required,
|
|
640
|
-
message:
|
|
640
|
+
message: R,
|
|
641
641
|
ref: J,
|
|
642
|
-
...X(ce.required,
|
|
642
|
+
...X(ce.required, R)
|
|
643
643
|
}, !n))
|
|
644
|
-
return
|
|
644
|
+
return P(R), k;
|
|
645
645
|
}
|
|
646
|
-
if (!G && (!te(
|
|
647
|
-
let
|
|
648
|
-
const
|
|
649
|
-
if (!te(
|
|
650
|
-
const ee = u.valueAsNumber ||
|
|
651
|
-
te(
|
|
646
|
+
if (!G && (!te(E) || !te(p))) {
|
|
647
|
+
let x, R;
|
|
648
|
+
const B = Ve(p), Y = Ve(E);
|
|
649
|
+
if (!te(g) && !isNaN(g)) {
|
|
650
|
+
const ee = u.valueAsNumber || g && +g;
|
|
651
|
+
te(B.value) || (x = ee > B.value), te(Y.value) || (R = ee < Y.value);
|
|
652
652
|
} else {
|
|
653
|
-
const ee = u.valueAsDate || new Date(
|
|
654
|
-
re(
|
|
653
|
+
const ee = u.valueAsDate || new Date(g), Z = (ye) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + ye), fe = u.type == "time", de = u.type == "week";
|
|
654
|
+
re(B.value) && g && (x = fe ? Z(g) > Z(B.value) : de ? g > B.value : ee > new Date(B.value)), re(Y.value) && g && (R = fe ? Z(g) < Z(Y.value) : de ? g < Y.value : ee < new Date(Y.value));
|
|
655
655
|
}
|
|
656
|
-
if ((
|
|
657
|
-
return
|
|
656
|
+
if ((x || R) && (ge(!!x, B.message, Y.message, ce.max, ce.min), !n))
|
|
657
|
+
return P(k[T].message), k;
|
|
658
658
|
}
|
|
659
|
-
if ((A ||
|
|
660
|
-
const
|
|
661
|
-
if ((
|
|
662
|
-
return
|
|
659
|
+
if ((A || D) && !G && (re(g) || a && Array.isArray(g))) {
|
|
660
|
+
const x = Ve(A), R = Ve(D), B = !te(x.value) && g.length > +x.value, Y = !te(R.value) && g.length < +R.value;
|
|
661
|
+
if ((B || Y) && (ge(B, x.message, R.message), !n))
|
|
662
|
+
return P(k[T].message), k;
|
|
663
663
|
}
|
|
664
|
-
if (b && !G && re(
|
|
665
|
-
const { value:
|
|
666
|
-
if (Pe(
|
|
664
|
+
if (b && !G && re(g)) {
|
|
665
|
+
const { value: x, message: R } = Ve(b);
|
|
666
|
+
if (Pe(x) && !g.match(x) && (k[T] = {
|
|
667
667
|
type: ce.pattern,
|
|
668
|
-
message:
|
|
668
|
+
message: R,
|
|
669
669
|
ref: u,
|
|
670
|
-
...X(ce.pattern,
|
|
670
|
+
...X(ce.pattern, R)
|
|
671
671
|
}, !n))
|
|
672
|
-
return
|
|
672
|
+
return P(R), k;
|
|
673
673
|
}
|
|
674
|
-
if (
|
|
675
|
-
if (ne(
|
|
676
|
-
const
|
|
677
|
-
if (
|
|
678
|
-
...
|
|
679
|
-
...X(ce.validate,
|
|
674
|
+
if (U) {
|
|
675
|
+
if (ne(U)) {
|
|
676
|
+
const x = await U(g, t), R = _t(x, J);
|
|
677
|
+
if (R && (k[T] = {
|
|
678
|
+
...R,
|
|
679
|
+
...X(ce.validate, R.message)
|
|
680
680
|
}, !n))
|
|
681
|
-
return
|
|
682
|
-
} else if (z(
|
|
683
|
-
let
|
|
684
|
-
for (const
|
|
685
|
-
if (!Q(
|
|
681
|
+
return P(R.message), k;
|
|
682
|
+
} else if (z(U)) {
|
|
683
|
+
let x = {};
|
|
684
|
+
for (const R in U) {
|
|
685
|
+
if (!Q(x) && !n)
|
|
686
686
|
break;
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
...
|
|
690
|
-
...X(
|
|
691
|
-
},
|
|
687
|
+
const B = _t(await U[R](g, t), J, R);
|
|
688
|
+
B && (x = {
|
|
689
|
+
...B,
|
|
690
|
+
...X(R, B.message)
|
|
691
|
+
}, P(B.message), n && (k[T] = x));
|
|
692
692
|
}
|
|
693
|
-
if (!Q(
|
|
693
|
+
if (!Q(x) && (k[T] = {
|
|
694
694
|
ref: J,
|
|
695
|
-
...
|
|
695
|
+
...x
|
|
696
696
|
}, !n))
|
|
697
|
-
return
|
|
697
|
+
return k;
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
|
-
return
|
|
700
|
+
return P(!0), k;
|
|
701
701
|
};
|
|
702
|
-
const
|
|
703
|
-
mode:
|
|
704
|
-
reValidateMode:
|
|
702
|
+
const mr = {
|
|
703
|
+
mode: ae.onSubmit,
|
|
704
|
+
reValidateMode: ae.onChange,
|
|
705
705
|
shouldFocusError: !0
|
|
706
706
|
};
|
|
707
|
-
function
|
|
707
|
+
function hr(e = {}) {
|
|
708
708
|
let r = {
|
|
709
|
-
...
|
|
709
|
+
...mr,
|
|
710
710
|
...e
|
|
711
711
|
}, t = {
|
|
712
712
|
submitCount: 0,
|
|
@@ -723,7 +723,7 @@ function mr(e = {}) {
|
|
|
723
723
|
validatingFields: {},
|
|
724
724
|
errors: r.errors || {},
|
|
725
725
|
disabled: r.disabled || !1
|
|
726
|
-
}, n = {}, o = z(r.defaultValues) || z(r.values) ? H(r.defaultValues || r.values) || {} : {},
|
|
726
|
+
}, n = {}, o = z(r.defaultValues) || z(r.values) ? H(r.defaultValues || r.values) || {} : {}, a = r.shouldUnregister ? {} : H(o), u = {
|
|
727
727
|
action: !1,
|
|
728
728
|
mount: !1,
|
|
729
729
|
watch: !1,
|
|
@@ -735,7 +735,7 @@ function mr(e = {}) {
|
|
|
735
735
|
array: /* @__PURE__ */ new Set(),
|
|
736
736
|
watch: /* @__PURE__ */ new Set()
|
|
737
737
|
}, F, A = 0;
|
|
738
|
-
const
|
|
738
|
+
const D = {
|
|
739
739
|
isDirty: !1,
|
|
740
740
|
dirtyFields: !1,
|
|
741
741
|
validatingFields: !1,
|
|
@@ -743,93 +743,93 @@ function mr(e = {}) {
|
|
|
743
743
|
isValidating: !1,
|
|
744
744
|
isValid: !1,
|
|
745
745
|
errors: !1
|
|
746
|
-
},
|
|
747
|
-
...
|
|
746
|
+
}, E = {
|
|
747
|
+
...D
|
|
748
748
|
};
|
|
749
749
|
let p = {
|
|
750
|
-
...
|
|
750
|
+
...E
|
|
751
751
|
};
|
|
752
752
|
const b = {
|
|
753
|
-
array:
|
|
754
|
-
state:
|
|
755
|
-
},
|
|
756
|
-
clearTimeout(A), A = setTimeout(s,
|
|
757
|
-
},
|
|
758
|
-
if (!u.keepIsValid && !r.disabled && (
|
|
759
|
-
let
|
|
760
|
-
r.resolver ? (
|
|
761
|
-
isValid:
|
|
753
|
+
array: ct(),
|
|
754
|
+
state: ct()
|
|
755
|
+
}, U = r.criteriaMode === ae.all, T = (s) => (i) => {
|
|
756
|
+
clearTimeout(A), A = setTimeout(s, i);
|
|
757
|
+
}, I = async (s) => {
|
|
758
|
+
if (!u.keepIsValid && !r.disabled && (E.isValid || p.isValid || s)) {
|
|
759
|
+
let i;
|
|
760
|
+
r.resolver ? (i = Q((await j()).errors), w()) : i = await X(n, !0), i !== t.isValid && b.state.next({
|
|
761
|
+
isValid: i
|
|
762
762
|
});
|
|
763
763
|
}
|
|
764
|
-
},
|
|
765
|
-
!r.disabled && (
|
|
766
|
-
l && (
|
|
764
|
+
}, w = (s, i) => {
|
|
765
|
+
!r.disabled && (E.isValidating || E.validatingFields || p.isValidating || p.validatingFields) && ((s || Array.from(f.mount)).forEach((l) => {
|
|
766
|
+
l && (i ? L(t.validatingFields, l, i) : q(t.validatingFields, l));
|
|
767
767
|
}), b.state.next({
|
|
768
768
|
validatingFields: t.validatingFields,
|
|
769
769
|
isValidating: !Q(t.validatingFields)
|
|
770
770
|
}));
|
|
771
|
-
},
|
|
771
|
+
}, g = (s, i = [], l, m, y = !0, d = !0) => {
|
|
772
772
|
if (m && l && !r.disabled) {
|
|
773
773
|
if (u.action = !0, d && Array.isArray(h(n, s))) {
|
|
774
774
|
const v = l(h(n, s), m.argA, m.argB);
|
|
775
|
-
y &&
|
|
775
|
+
y && L(n, s, v);
|
|
776
776
|
}
|
|
777
777
|
if (d && Array.isArray(h(t.errors, s))) {
|
|
778
778
|
const v = l(h(t.errors, s), m.argA, m.argB);
|
|
779
|
-
y &&
|
|
779
|
+
y && L(t.errors, s, v), dr(t.errors, s);
|
|
780
780
|
}
|
|
781
|
-
if ((
|
|
781
|
+
if ((E.touchedFields || p.touchedFields) && d && Array.isArray(h(t.touchedFields, s))) {
|
|
782
782
|
const v = l(h(t.touchedFields, s), m.argA, m.argB);
|
|
783
|
-
y &&
|
|
783
|
+
y && L(t.touchedFields, s, v);
|
|
784
784
|
}
|
|
785
|
-
(
|
|
785
|
+
(E.dirtyFields || p.dirtyFields) && (t.dirtyFields = Fe(o, a)), b.state.next({
|
|
786
786
|
name: s,
|
|
787
|
-
isDirty:
|
|
787
|
+
isDirty: x(s, i),
|
|
788
788
|
dirtyFields: t.dirtyFields,
|
|
789
789
|
errors: t.errors,
|
|
790
790
|
isValid: t.isValid
|
|
791
791
|
});
|
|
792
792
|
} else
|
|
793
|
-
|
|
794
|
-
}, J = (s,
|
|
795
|
-
|
|
793
|
+
L(a, s, i);
|
|
794
|
+
}, J = (s, i) => {
|
|
795
|
+
L(t.errors, s, i), b.state.next({
|
|
796
796
|
errors: t.errors
|
|
797
797
|
});
|
|
798
|
-
},
|
|
798
|
+
}, P = (s) => {
|
|
799
799
|
t.errors = s, b.state.next({
|
|
800
800
|
errors: t.errors,
|
|
801
801
|
isValid: !1
|
|
802
802
|
});
|
|
803
|
-
},
|
|
803
|
+
}, k = (s, i, l, m) => {
|
|
804
804
|
const y = h(n, s);
|
|
805
805
|
if (y) {
|
|
806
|
-
const d = h(
|
|
807
|
-
|
|
806
|
+
const d = h(a, s, $(l) ? h(o, s) : l);
|
|
807
|
+
$(d) || m && m.defaultChecked || i ? L(a, s, i ? d : mt(y._f)) : Y(s, d), u.mount && !u.action && I();
|
|
808
808
|
}
|
|
809
|
-
}, K = (s,
|
|
809
|
+
}, K = (s, i, l, m, y) => {
|
|
810
810
|
let d = !1, v = !1;
|
|
811
|
-
const
|
|
811
|
+
const O = {
|
|
812
812
|
name: s
|
|
813
813
|
};
|
|
814
814
|
if (!r.disabled) {
|
|
815
815
|
if (!l || m) {
|
|
816
|
-
(
|
|
817
|
-
const
|
|
818
|
-
v = !!h(t.dirtyFields, s),
|
|
816
|
+
(E.isDirty || p.isDirty) && (v = t.isDirty, t.isDirty = O.isDirty = x(), d = v !== O.isDirty);
|
|
817
|
+
const C = ie(h(o, s), i);
|
|
818
|
+
v = !!h(t.dirtyFields, s), C ? q(t.dirtyFields, s) : L(t.dirtyFields, s, !0), O.dirtyFields = t.dirtyFields, d = d || (E.dirtyFields || p.dirtyFields) && v !== !C;
|
|
819
819
|
}
|
|
820
820
|
if (l) {
|
|
821
|
-
const
|
|
822
|
-
|
|
821
|
+
const C = h(t.touchedFields, s);
|
|
822
|
+
C || (L(t.touchedFields, s, l), O.touchedFields = t.touchedFields, d = d || (E.touchedFields || p.touchedFields) && C !== l);
|
|
823
823
|
}
|
|
824
|
-
d && y && b.state.next(
|
|
824
|
+
d && y && b.state.next(O);
|
|
825
825
|
}
|
|
826
|
-
return d ?
|
|
827
|
-
}, oe = (s,
|
|
828
|
-
const y = h(t.errors, s), d = (
|
|
829
|
-
if (r.delayError && l ? (F =
|
|
826
|
+
return d ? O : {};
|
|
827
|
+
}, oe = (s, i, l, m) => {
|
|
828
|
+
const y = h(t.errors, s), d = (E.isValid || p.isValid) && ue(i) && t.isValid !== i;
|
|
829
|
+
if (r.delayError && l ? (F = T(() => J(s, l)), F(r.delayError)) : (clearTimeout(A), F = null, l ? L(t.errors, s, l) : q(t.errors, s)), (l ? !ie(y, l) : y) || !Q(m) || d) {
|
|
830
830
|
const v = {
|
|
831
831
|
...m,
|
|
832
|
-
...d && ue(
|
|
832
|
+
...d && ue(i) ? { isValid: i } : {},
|
|
833
833
|
errors: t.errors,
|
|
834
834
|
name: s
|
|
835
835
|
};
|
|
@@ -838,17 +838,17 @@ function mr(e = {}) {
|
|
|
838
838
|
...v
|
|
839
839
|
}, b.state.next(v);
|
|
840
840
|
}
|
|
841
|
-
}, j = async (s) => (
|
|
842
|
-
const { errors:
|
|
843
|
-
if (
|
|
841
|
+
}, j = async (s) => (w(s, !0), await r.resolver(a, r.context, ir(s || f.mount, n, r.criteriaMode, r.shouldUseNativeValidation))), G = async (s) => {
|
|
842
|
+
const { errors: i } = await j(s);
|
|
843
|
+
if (w(s), s)
|
|
844
844
|
for (const l of s) {
|
|
845
|
-
const m = h(
|
|
846
|
-
m ?
|
|
845
|
+
const m = h(i, l);
|
|
846
|
+
m ? L(t.errors, l, m) : q(t.errors, l);
|
|
847
847
|
}
|
|
848
848
|
else
|
|
849
|
-
t.errors =
|
|
850
|
-
return
|
|
851
|
-
}, X = async (s,
|
|
849
|
+
t.errors = i;
|
|
850
|
+
return i;
|
|
851
|
+
}, X = async (s, i, l = {
|
|
852
852
|
valid: !0
|
|
853
853
|
}) => {
|
|
854
854
|
for (const m in s) {
|
|
@@ -856,227 +856,227 @@ function mr(e = {}) {
|
|
|
856
856
|
if (y) {
|
|
857
857
|
const { _f: d, ...v } = y;
|
|
858
858
|
if (d) {
|
|
859
|
-
const
|
|
860
|
-
|
|
861
|
-
const se = await
|
|
862
|
-
if (
|
|
859
|
+
const O = f.array.has(d.name), C = y._f && or(y._f);
|
|
860
|
+
C && E.validatingFields && w([d.name], !0);
|
|
861
|
+
const se = await xt(y, f.disabled, a, U, r.shouldUseNativeValidation && !i, O);
|
|
862
|
+
if (C && E.validatingFields && w([d.name]), se[d.name] && (l.valid = !1, i))
|
|
863
863
|
break;
|
|
864
|
-
!
|
|
864
|
+
!i && (h(se, d.name) ? O ? yr(t.errors, se, d.name) : L(t.errors, d.name, se[d.name]) : q(t.errors, d.name));
|
|
865
865
|
}
|
|
866
|
-
!Q(v) && await X(v,
|
|
866
|
+
!Q(v) && await X(v, i, l);
|
|
867
867
|
}
|
|
868
868
|
}
|
|
869
869
|
return l.valid;
|
|
870
870
|
}, ge = () => {
|
|
871
871
|
for (const s of f.unMount) {
|
|
872
|
-
const
|
|
873
|
-
|
|
872
|
+
const i = h(n, s);
|
|
873
|
+
i && (i._f.refs ? i._f.refs.every((l) => !We(l)) : !We(i._f.ref)) && le(s);
|
|
874
874
|
}
|
|
875
875
|
f.unMount = /* @__PURE__ */ new Set();
|
|
876
|
-
},
|
|
877
|
-
...u.mount ?
|
|
878
|
-
}, l,
|
|
876
|
+
}, x = (s, i) => !r.disabled && (s && i && L(a, s, i), !ie(c(), o)), R = (s, i, l) => Ye(s, f, {
|
|
877
|
+
...u.mount ? a : $(i) ? o : re(s) ? { [s]: i } : i
|
|
878
|
+
}, l, i), B = (s) => Je(h(u.mount ? a : o, s, r.shouldUnregister ? h(o, s, []) : [])), Y = (s, i, l = {}) => {
|
|
879
879
|
const m = h(n, s);
|
|
880
|
-
let y =
|
|
880
|
+
let y = i;
|
|
881
881
|
if (m) {
|
|
882
882
|
const d = m._f;
|
|
883
|
-
d && (!d.disabled &&
|
|
884
|
-
(!v.defaultChecked || !v.disabled) && (Array.isArray(y) ? v.checked = !!y.find((
|
|
885
|
-
}) : d.refs.forEach((v) => v.checked = v.value === y) :
|
|
883
|
+
d && (!d.disabled && L(a, s, St(i, d)), y = je(d.ref) && te(i) ? "" : i, wt(d.ref) ? [...d.ref.options].forEach((v) => v.selected = y.includes(v.value)) : d.refs ? Te(d.ref) ? d.refs.forEach((v) => {
|
|
884
|
+
(!v.defaultChecked || !v.disabled) && (Array.isArray(y) ? v.checked = !!y.find((O) => O === v.value) : v.checked = y === v.value || !!y);
|
|
885
|
+
}) : d.refs.forEach((v) => v.checked = v.value === y) : Ze(d.ref) ? d.ref.value = "" : (d.ref.value = y, d.ref.type || b.state.next({
|
|
886
886
|
name: s,
|
|
887
|
-
values: H(
|
|
887
|
+
values: H(a)
|
|
888
888
|
})));
|
|
889
889
|
}
|
|
890
890
|
(l.shouldDirty || l.shouldTouch) && K(s, y, l.shouldTouch, l.shouldDirty, !0), l.shouldValidate && ye(s);
|
|
891
|
-
}, ee = (s,
|
|
892
|
-
for (const m in
|
|
893
|
-
if (!
|
|
891
|
+
}, ee = (s, i, l) => {
|
|
892
|
+
for (const m in i) {
|
|
893
|
+
if (!i.hasOwnProperty(m))
|
|
894
894
|
return;
|
|
895
|
-
const y =
|
|
895
|
+
const y = i[m], d = s + "." + m, v = h(n, d);
|
|
896
896
|
(f.array.has(s) || z(y) || v && !v._f) && !ve(y) ? ee(d, y, l) : Y(d, y, l);
|
|
897
897
|
}
|
|
898
|
-
}, Z = (s,
|
|
899
|
-
const m = h(n, s), y = f.array.has(s), d = H(
|
|
900
|
-
|
|
898
|
+
}, Z = (s, i, l = {}) => {
|
|
899
|
+
const m = h(n, s), y = f.array.has(s), d = H(i);
|
|
900
|
+
L(a, s, d), y ? (b.array.next({
|
|
901
901
|
name: s,
|
|
902
|
-
values: H(
|
|
903
|
-
}), (
|
|
902
|
+
values: H(a)
|
|
903
|
+
}), (E.isDirty || E.dirtyFields || p.isDirty || p.dirtyFields) && l.shouldDirty && b.state.next({
|
|
904
904
|
name: s,
|
|
905
|
-
dirtyFields: Fe(o,
|
|
906
|
-
isDirty:
|
|
907
|
-
})) : m && !m._f && !te(d) ? ee(s, d, l) : Y(s, d, l),
|
|
905
|
+
dirtyFields: Fe(o, a),
|
|
906
|
+
isDirty: x(s, d)
|
|
907
|
+
})) : m && !m._f && !te(d) ? ee(s, d, l) : Y(s, d, l), bt(s, f) && b.state.next({ ...t, name: s }), b.state.next({
|
|
908
908
|
name: u.mount ? s : void 0,
|
|
909
|
-
values: H(
|
|
909
|
+
values: H(a)
|
|
910
910
|
});
|
|
911
911
|
}, fe = async (s) => {
|
|
912
912
|
u.mount = !0;
|
|
913
|
-
const
|
|
914
|
-
let l =
|
|
915
|
-
const y = h(n, l), d = (
|
|
916
|
-
m = Number.isNaN(
|
|
917
|
-
}, v =
|
|
913
|
+
const i = s.target;
|
|
914
|
+
let l = i.name, m = !0;
|
|
915
|
+
const y = h(n, l), d = (C) => {
|
|
916
|
+
m = Number.isNaN(C) || ve(C) && isNaN(C.getTime()) || ie(C, h(a, l, C));
|
|
917
|
+
}, v = ht(r.mode), O = ht(r.reValidateMode);
|
|
918
918
|
if (y) {
|
|
919
|
-
let
|
|
920
|
-
const Oe =
|
|
921
|
-
|
|
919
|
+
let C, se;
|
|
920
|
+
const Oe = i.type ? mt(y._f) : Gt(s), me = s.type === ut.BLUR || s.type === ut.FOCUS_OUT, Ut = !lr(y._f) && !r.resolver && !h(t.errors, l) && !y._f.deps || fr(me, h(t.touchedFields, l), t.isSubmitted, O, v), Me = bt(l, f, me);
|
|
921
|
+
L(a, l, Oe), me ? (!i || !i.readOnly) && (y._f.onBlur && y._f.onBlur(s), F && F(0)) : y._f.onChange && y._f.onChange(s);
|
|
922
922
|
const Be = K(l, Oe, me), Mt = !Q(Be) || Me;
|
|
923
923
|
if (!me && b.state.next({
|
|
924
924
|
name: l,
|
|
925
925
|
type: s.type,
|
|
926
|
-
values: H(
|
|
926
|
+
values: H(a)
|
|
927
927
|
}), Ut)
|
|
928
|
-
return (
|
|
928
|
+
return (E.isValid || p.isValid) && (r.mode === "onBlur" ? me && I() : me || I()), Mt && b.state.next({ name: l, ...Me ? {} : Be });
|
|
929
929
|
if (!me && Me && b.state.next({ ...t }), r.resolver) {
|
|
930
|
-
const { errors:
|
|
931
|
-
if (
|
|
932
|
-
const Bt =
|
|
933
|
-
|
|
930
|
+
const { errors: nt } = await j([l]);
|
|
931
|
+
if (w([l]), d(Oe), m) {
|
|
932
|
+
const Bt = gt(t.errors, n, l), at = gt(nt, n, Bt.name || l);
|
|
933
|
+
C = at.error, l = at.name, se = Q(nt);
|
|
934
934
|
}
|
|
935
935
|
} else
|
|
936
|
-
|
|
937
|
-
m && (y._f.deps && (!Array.isArray(y._f.deps) || y._f.deps.length > 0) && ye(y._f.deps), oe(l, se,
|
|
936
|
+
w([l], !0), C = (await xt(y, f.disabled, a, U, r.shouldUseNativeValidation))[l], w([l]), d(Oe), m && (C ? se = !1 : (E.isValid || p.isValid) && (se = await X(n, !0)));
|
|
937
|
+
m && (y._f.deps && (!Array.isArray(y._f.deps) || y._f.deps.length > 0) && ye(y._f.deps), oe(l, se, C, Be));
|
|
938
938
|
}
|
|
939
|
-
}, de = (s,
|
|
940
|
-
if (h(t.errors,
|
|
939
|
+
}, de = (s, i) => {
|
|
940
|
+
if (h(t.errors, i) && s.focus)
|
|
941
941
|
return s.focus(), 1;
|
|
942
|
-
}, ye = async (s,
|
|
942
|
+
}, ye = async (s, i = {}) => {
|
|
943
943
|
let l, m;
|
|
944
944
|
const y = ke(s);
|
|
945
945
|
if (r.resolver) {
|
|
946
|
-
const d = await G(
|
|
946
|
+
const d = await G($(s) ? s : y);
|
|
947
947
|
l = Q(d), m = s ? !y.some((v) => h(d, v)) : l;
|
|
948
948
|
} else s ? (m = (await Promise.all(y.map(async (d) => {
|
|
949
949
|
const v = h(n, d);
|
|
950
950
|
return await X(v && v._f ? { [d]: v } : v);
|
|
951
|
-
}))).every(Boolean), !(!m && !t.isValid) &&
|
|
951
|
+
}))).every(Boolean), !(!m && !t.isValid) && I()) : m = l = await X(n);
|
|
952
952
|
return b.state.next({
|
|
953
|
-
...!re(s) || (
|
|
953
|
+
...!re(s) || (E.isValid || p.isValid) && l !== t.isValid ? {} : { name: s },
|
|
954
954
|
...r.resolver || !s ? { isValid: l } : {},
|
|
955
955
|
errors: t.errors
|
|
956
|
-
}),
|
|
957
|
-
}, c = (s,
|
|
956
|
+
}), i.shouldFocus && !m && Se(n, de, s ? y : f.mount), m;
|
|
957
|
+
}, c = (s, i) => {
|
|
958
958
|
let l = {
|
|
959
|
-
...u.mount ?
|
|
959
|
+
...u.mount ? a : o
|
|
960
960
|
};
|
|
961
|
-
return
|
|
962
|
-
},
|
|
963
|
-
invalid: !!h((
|
|
964
|
-
isDirty: !!h((
|
|
965
|
-
error: h((
|
|
961
|
+
return i && (l = At(i.dirtyFields ? t.dirtyFields : t.touchedFields, l)), $(s) ? l : re(s) ? h(l, s) : s.map((m) => h(l, m));
|
|
962
|
+
}, _ = (s, i) => ({
|
|
963
|
+
invalid: !!h((i || t).errors, s),
|
|
964
|
+
isDirty: !!h((i || t).dirtyFields, s),
|
|
965
|
+
error: h((i || t).errors, s),
|
|
966
966
|
isValidating: !!h(t.validatingFields, s),
|
|
967
|
-
isTouched: !!h((
|
|
968
|
-
}),
|
|
969
|
-
s && ke(s).forEach((
|
|
967
|
+
isTouched: !!h((i || t).touchedFields, s)
|
|
968
|
+
}), N = (s) => {
|
|
969
|
+
s && ke(s).forEach((i) => q(t.errors, i)), b.state.next({
|
|
970
970
|
errors: s ? t.errors : {}
|
|
971
971
|
});
|
|
972
|
-
},
|
|
973
|
-
const m = (h(n, s, { _f: {} })._f || {}).ref, y = h(t.errors, s) || {}, { ref: d, message: v, type:
|
|
974
|
-
|
|
975
|
-
...
|
|
976
|
-
...
|
|
972
|
+
}, M = (s, i, l) => {
|
|
973
|
+
const m = (h(n, s, { _f: {} })._f || {}).ref, y = h(t.errors, s) || {}, { ref: d, message: v, type: O, ...C } = y;
|
|
974
|
+
L(t.errors, s, {
|
|
975
|
+
...C,
|
|
976
|
+
...i,
|
|
977
977
|
ref: m
|
|
978
978
|
}), b.state.next({
|
|
979
979
|
name: s,
|
|
980
980
|
errors: t.errors,
|
|
981
981
|
isValid: !1
|
|
982
982
|
}), l && l.shouldFocus && m && m.focus && m.focus();
|
|
983
|
-
}, _e = (s,
|
|
984
|
-
next: (l) => "values" in l && s(
|
|
985
|
-
}) :
|
|
986
|
-
next: (
|
|
987
|
-
|
|
988
|
-
values: { ...
|
|
983
|
+
}, _e = (s, i) => ne(s) ? b.state.subscribe({
|
|
984
|
+
next: (l) => "values" in l && s(R(void 0, i), l)
|
|
985
|
+
}) : R(s, i, !0), xe = (s) => b.state.subscribe({
|
|
986
|
+
next: (i) => {
|
|
987
|
+
cr(s.name, i.name, s.exact) && ur(i, s.formState || E, It, s.reRenderRoot) && s.callback({
|
|
988
|
+
values: { ...a },
|
|
989
989
|
...t,
|
|
990
|
-
...
|
|
990
|
+
...i,
|
|
991
991
|
defaultValues: o
|
|
992
992
|
});
|
|
993
993
|
}
|
|
994
|
-
}).unsubscribe,
|
|
994
|
+
}).unsubscribe, W = (s) => (u.mount = !0, p = {
|
|
995
995
|
...p,
|
|
996
996
|
...s.formState
|
|
997
997
|
}, xe({
|
|
998
998
|
...s,
|
|
999
999
|
formState: {
|
|
1000
|
-
...
|
|
1000
|
+
...D,
|
|
1001
1001
|
...s.formState
|
|
1002
1002
|
}
|
|
1003
|
-
})), le = (s,
|
|
1003
|
+
})), le = (s, i = {}) => {
|
|
1004
1004
|
for (const l of s ? ke(s) : f.mount)
|
|
1005
|
-
f.mount.delete(l), f.array.delete(l),
|
|
1005
|
+
f.mount.delete(l), f.array.delete(l), i.keepValue || (q(n, l), q(a, l)), !i.keepError && q(t.errors, l), !i.keepDirty && q(t.dirtyFields, l), !i.keepTouched && q(t.touchedFields, l), !i.keepIsValidating && q(t.validatingFields, l), !r.shouldUnregister && !i.keepDefaultValue && q(o, l);
|
|
1006
1006
|
b.state.next({
|
|
1007
|
-
values: H(
|
|
1007
|
+
values: H(a)
|
|
1008
1008
|
}), b.state.next({
|
|
1009
1009
|
...t,
|
|
1010
|
-
...
|
|
1011
|
-
}), !
|
|
1012
|
-
}, Ee = ({ disabled: s, name:
|
|
1013
|
-
(ue(s) && u.mount || s || f.disabled.has(
|
|
1014
|
-
},
|
|
1010
|
+
...i.keepDirty ? { isDirty: x() } : {}
|
|
1011
|
+
}), !i.keepIsValid && I();
|
|
1012
|
+
}, Ee = ({ disabled: s, name: i }) => {
|
|
1013
|
+
(ue(s) && u.mount || s || f.disabled.has(i)) && (s ? f.disabled.add(i) : f.disabled.delete(i));
|
|
1014
|
+
}, pe = (s, i = {}) => {
|
|
1015
1015
|
let l = h(n, s);
|
|
1016
|
-
const m = ue(
|
|
1017
|
-
return
|
|
1016
|
+
const m = ue(i.disabled) || ue(r.disabled);
|
|
1017
|
+
return L(n, s, {
|
|
1018
1018
|
...l || {},
|
|
1019
1019
|
_f: {
|
|
1020
1020
|
...l && l._f ? l._f : { ref: { name: s } },
|
|
1021
1021
|
name: s,
|
|
1022
1022
|
mount: !0,
|
|
1023
|
-
...
|
|
1023
|
+
...i
|
|
1024
1024
|
}
|
|
1025
1025
|
}), f.mount.add(s), l ? Ee({
|
|
1026
|
-
disabled: ue(
|
|
1026
|
+
disabled: ue(i.disabled) ? i.disabled : r.disabled,
|
|
1027
1027
|
name: s
|
|
1028
|
-
}) :
|
|
1029
|
-
...m ? { disabled:
|
|
1028
|
+
}) : k(s, !0, i.value), {
|
|
1029
|
+
...m ? { disabled: i.disabled || r.disabled } : {},
|
|
1030
1030
|
...r.progressive ? {
|
|
1031
|
-
required: !!
|
|
1032
|
-
min: Re(
|
|
1033
|
-
max: Re(
|
|
1034
|
-
minLength: Re(
|
|
1035
|
-
maxLength: Re(
|
|
1036
|
-
pattern: Re(
|
|
1031
|
+
required: !!i.required,
|
|
1032
|
+
min: Re(i.min),
|
|
1033
|
+
max: Re(i.max),
|
|
1034
|
+
minLength: Re(i.minLength),
|
|
1035
|
+
maxLength: Re(i.maxLength),
|
|
1036
|
+
pattern: Re(i.pattern)
|
|
1037
1037
|
} : {},
|
|
1038
1038
|
name: s,
|
|
1039
1039
|
onChange: fe,
|
|
1040
1040
|
onBlur: fe,
|
|
1041
1041
|
ref: (y) => {
|
|
1042
1042
|
if (y) {
|
|
1043
|
-
|
|
1044
|
-
const d =
|
|
1045
|
-
if (v ?
|
|
1043
|
+
pe(s, i), l = h(n, s);
|
|
1044
|
+
const d = $(y.value) && y.querySelectorAll && y.querySelectorAll("input,select,textarea")[0] || y, v = rr(d), O = l._f.refs || [];
|
|
1045
|
+
if (v ? O.find((C) => C === d) : d === l._f.ref)
|
|
1046
1046
|
return;
|
|
1047
|
-
|
|
1047
|
+
L(n, s, {
|
|
1048
1048
|
_f: {
|
|
1049
1049
|
...l._f,
|
|
1050
1050
|
...v ? {
|
|
1051
1051
|
refs: [
|
|
1052
|
-
...
|
|
1052
|
+
...O.filter(We),
|
|
1053
1053
|
d,
|
|
1054
1054
|
...Array.isArray(h(o, s)) ? [{}] : []
|
|
1055
1055
|
],
|
|
1056
1056
|
ref: { type: d.type, name: s }
|
|
1057
1057
|
} : { ref: d }
|
|
1058
1058
|
}
|
|
1059
|
-
}),
|
|
1059
|
+
}), k(s, !1, void 0, d);
|
|
1060
1060
|
} else
|
|
1061
|
-
l = h(n, s, {}), l._f && (l._f.mount = !1), (r.shouldUnregister ||
|
|
1061
|
+
l = h(n, s, {}), l._f && (l._f.mount = !1), (r.shouldUnregister || i.shouldUnregister) && !(Zt(f.array, s) && u.action) && f.unMount.add(s);
|
|
1062
1062
|
}
|
|
1063
1063
|
};
|
|
1064
1064
|
}, Ue = () => r.shouldFocusError && Se(n, de, f.mount), Pt = (s) => {
|
|
1065
|
-
ue(s) && (b.state.next({ disabled: s }), Se(n, (
|
|
1065
|
+
ue(s) && (b.state.next({ disabled: s }), Se(n, (i, l) => {
|
|
1066
1066
|
const m = h(n, l);
|
|
1067
|
-
m && (
|
|
1067
|
+
m && (i.disabled = m._f.disabled || s, Array.isArray(m._f.refs) && m._f.refs.forEach((y) => {
|
|
1068
1068
|
y.disabled = m._f.disabled || s;
|
|
1069
1069
|
}));
|
|
1070
1070
|
}, 0, !1));
|
|
1071
|
-
},
|
|
1071
|
+
}, et = (s, i) => async (l) => {
|
|
1072
1072
|
let m;
|
|
1073
1073
|
l && (l.preventDefault && l.preventDefault(), l.persist && l.persist());
|
|
1074
|
-
let y = H(
|
|
1074
|
+
let y = H(a);
|
|
1075
1075
|
if (b.state.next({
|
|
1076
1076
|
isSubmitting: !0
|
|
1077
1077
|
}), r.resolver) {
|
|
1078
1078
|
const { errors: d, values: v } = await j();
|
|
1079
|
-
|
|
1079
|
+
w(), t.errors = d, y = H(v);
|
|
1080
1080
|
} else
|
|
1081
1081
|
await X(n);
|
|
1082
1082
|
if (f.disabled.size)
|
|
@@ -1092,7 +1092,7 @@ function mr(e = {}) {
|
|
|
1092
1092
|
m = d;
|
|
1093
1093
|
}
|
|
1094
1094
|
} else
|
|
1095
|
-
|
|
1095
|
+
i && await i({ ...t.errors }, l), Ue(), setTimeout(Ue);
|
|
1096
1096
|
if (b.state.next({
|
|
1097
1097
|
isSubmitted: !0,
|
|
1098
1098
|
isSubmitting: !1,
|
|
@@ -1101,26 +1101,26 @@ function mr(e = {}) {
|
|
|
1101
1101
|
errors: t.errors
|
|
1102
1102
|
}), m)
|
|
1103
1103
|
throw m;
|
|
1104
|
-
}, Nt = (s,
|
|
1105
|
-
h(n, s) && (
|
|
1106
|
-
},
|
|
1104
|
+
}, Nt = (s, i = {}) => {
|
|
1105
|
+
h(n, s) && ($(i.defaultValue) ? Z(s, H(h(o, s))) : (Z(s, i.defaultValue), L(o, s, H(i.defaultValue))), i.keepTouched || q(t.touchedFields, s), i.keepDirty || (q(t.dirtyFields, s), t.isDirty = i.defaultValue ? x(s, H(h(o, s))) : x()), i.keepError || (q(t.errors, s), E.isValid && I()), b.state.next({ ...t }));
|
|
1106
|
+
}, tt = (s, i = {}) => {
|
|
1107
1107
|
const l = s ? H(s) : o, m = H(l), y = Q(s), d = y ? o : m;
|
|
1108
|
-
if (
|
|
1109
|
-
if (
|
|
1108
|
+
if (i.keepDefaultValues || (o = l), !i.keepValues) {
|
|
1109
|
+
if (i.keepDirtyValues) {
|
|
1110
1110
|
const v = /* @__PURE__ */ new Set([
|
|
1111
1111
|
...f.mount,
|
|
1112
|
-
...Object.keys(Fe(o,
|
|
1112
|
+
...Object.keys(Fe(o, a))
|
|
1113
1113
|
]);
|
|
1114
|
-
for (const
|
|
1115
|
-
h(t.dirtyFields,
|
|
1114
|
+
for (const O of Array.from(v))
|
|
1115
|
+
h(t.dirtyFields, O) ? L(d, O, h(a, O)) : Z(O, h(d, O));
|
|
1116
1116
|
} else {
|
|
1117
|
-
if (
|
|
1117
|
+
if (He && $(s))
|
|
1118
1118
|
for (const v of f.mount) {
|
|
1119
|
-
const
|
|
1120
|
-
if (
|
|
1121
|
-
const
|
|
1122
|
-
if (je(
|
|
1123
|
-
const se =
|
|
1119
|
+
const O = h(n, v);
|
|
1120
|
+
if (O && O._f) {
|
|
1121
|
+
const C = Array.isArray(O._f.refs) ? O._f.refs[0] : O._f.ref;
|
|
1122
|
+
if (je(C)) {
|
|
1123
|
+
const se = C.closest("form");
|
|
1124
1124
|
if (se) {
|
|
1125
1125
|
se.reset();
|
|
1126
1126
|
break;
|
|
@@ -1128,43 +1128,43 @@ function mr(e = {}) {
|
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
1131
|
-
if (
|
|
1131
|
+
if (i.keepFieldsRef)
|
|
1132
1132
|
for (const v of f.mount)
|
|
1133
1133
|
Z(v, h(d, v));
|
|
1134
1134
|
else
|
|
1135
1135
|
n = {};
|
|
1136
1136
|
}
|
|
1137
|
-
|
|
1137
|
+
a = r.shouldUnregister ? i.keepDefaultValues ? H(o) : {} : H(d), b.array.next({
|
|
1138
1138
|
values: { ...d }
|
|
1139
1139
|
}), b.state.next({
|
|
1140
1140
|
values: { ...d }
|
|
1141
1141
|
});
|
|
1142
1142
|
}
|
|
1143
1143
|
f = {
|
|
1144
|
-
mount:
|
|
1144
|
+
mount: i.keepDirtyValues ? f.mount : /* @__PURE__ */ new Set(),
|
|
1145
1145
|
unMount: /* @__PURE__ */ new Set(),
|
|
1146
1146
|
array: /* @__PURE__ */ new Set(),
|
|
1147
1147
|
disabled: /* @__PURE__ */ new Set(),
|
|
1148
1148
|
watch: /* @__PURE__ */ new Set(),
|
|
1149
1149
|
watchAll: !1,
|
|
1150
1150
|
focus: ""
|
|
1151
|
-
}, u.mount = !
|
|
1152
|
-
submitCount:
|
|
1153
|
-
isDirty: y ? !1 :
|
|
1154
|
-
isSubmitted:
|
|
1155
|
-
dirtyFields: y ? {} :
|
|
1156
|
-
touchedFields:
|
|
1157
|
-
errors:
|
|
1158
|
-
isSubmitSuccessful:
|
|
1151
|
+
}, u.mount = !E.isValid || !!i.keepIsValid || !!i.keepDirtyValues || !r.shouldUnregister && !Q(d), u.watch = !!r.shouldUnregister, u.keepIsValid = !!i.keepIsValid, u.action = !1, i.keepErrors || (t.errors = {}), b.state.next({
|
|
1152
|
+
submitCount: i.keepSubmitCount ? t.submitCount : 0,
|
|
1153
|
+
isDirty: y ? !1 : i.keepDirty ? t.isDirty : !!(i.keepDefaultValues && !ie(s, o)),
|
|
1154
|
+
isSubmitted: i.keepIsSubmitted ? t.isSubmitted : !1,
|
|
1155
|
+
dirtyFields: y ? {} : i.keepDirtyValues ? i.keepDefaultValues && a ? Fe(o, a) : t.dirtyFields : i.keepDefaultValues && s ? Fe(o, s) : i.keepDirty ? t.dirtyFields : {},
|
|
1156
|
+
touchedFields: i.keepTouched ? t.touchedFields : {},
|
|
1157
|
+
errors: i.keepErrors ? t.errors : {},
|
|
1158
|
+
isSubmitSuccessful: i.keepIsSubmitSuccessful ? t.isSubmitSuccessful : !1,
|
|
1159
1159
|
isSubmitting: !1,
|
|
1160
1160
|
defaultValues: o
|
|
1161
1161
|
});
|
|
1162
|
-
},
|
|
1162
|
+
}, rt = (s, i) => tt(ne(s) ? s(a) : s, { ...r.resetOptions, ...i }), Lt = (s, i = {}) => {
|
|
1163
1163
|
const l = h(n, s), m = l && l._f;
|
|
1164
1164
|
if (m) {
|
|
1165
1165
|
const y = m.refs ? m.refs[0] : m.ref;
|
|
1166
1166
|
y.focus && setTimeout(() => {
|
|
1167
|
-
y.focus(),
|
|
1167
|
+
y.focus(), i.shouldSelect && ne(y.select) && y.select();
|
|
1168
1168
|
});
|
|
1169
1169
|
}
|
|
1170
1170
|
}, It = (s) => {
|
|
@@ -1172,39 +1172,39 @@ function mr(e = {}) {
|
|
|
1172
1172
|
...t,
|
|
1173
1173
|
...s
|
|
1174
1174
|
};
|
|
1175
|
-
},
|
|
1175
|
+
}, st = {
|
|
1176
1176
|
control: {
|
|
1177
|
-
register:
|
|
1177
|
+
register: pe,
|
|
1178
1178
|
unregister: le,
|
|
1179
|
-
getFieldState:
|
|
1180
|
-
handleSubmit:
|
|
1181
|
-
setError:
|
|
1179
|
+
getFieldState: _,
|
|
1180
|
+
handleSubmit: et,
|
|
1181
|
+
setError: M,
|
|
1182
1182
|
_subscribe: xe,
|
|
1183
1183
|
_runSchema: j,
|
|
1184
|
-
_updateIsValidating:
|
|
1184
|
+
_updateIsValidating: w,
|
|
1185
1185
|
_focusError: Ue,
|
|
1186
|
-
_getWatch:
|
|
1187
|
-
_getDirty:
|
|
1188
|
-
_setValid:
|
|
1189
|
-
_setFieldArray:
|
|
1186
|
+
_getWatch: R,
|
|
1187
|
+
_getDirty: x,
|
|
1188
|
+
_setValid: I,
|
|
1189
|
+
_setFieldArray: g,
|
|
1190
1190
|
_setDisabledField: Ee,
|
|
1191
|
-
_setErrors:
|
|
1192
|
-
_getFieldArray:
|
|
1193
|
-
_reset:
|
|
1191
|
+
_setErrors: P,
|
|
1192
|
+
_getFieldArray: B,
|
|
1193
|
+
_reset: tt,
|
|
1194
1194
|
_resetDefaultValues: () => ne(r.defaultValues) && r.defaultValues().then((s) => {
|
|
1195
|
-
|
|
1195
|
+
rt(s, r.resetOptions), b.state.next({
|
|
1196
1196
|
isLoading: !1
|
|
1197
1197
|
});
|
|
1198
1198
|
}),
|
|
1199
1199
|
_removeUnmounted: ge,
|
|
1200
1200
|
_disableForm: Pt,
|
|
1201
1201
|
_subjects: b,
|
|
1202
|
-
_proxyFormState:
|
|
1202
|
+
_proxyFormState: E,
|
|
1203
1203
|
get _fields() {
|
|
1204
1204
|
return n;
|
|
1205
1205
|
},
|
|
1206
1206
|
get _formValues() {
|
|
1207
|
-
return
|
|
1207
|
+
return a;
|
|
1208
1208
|
},
|
|
1209
1209
|
get _state() {
|
|
1210
1210
|
return u;
|
|
@@ -1234,28 +1234,28 @@ function mr(e = {}) {
|
|
|
1234
1234
|
};
|
|
1235
1235
|
}
|
|
1236
1236
|
},
|
|
1237
|
-
subscribe:
|
|
1237
|
+
subscribe: W,
|
|
1238
1238
|
trigger: ye,
|
|
1239
|
-
register:
|
|
1240
|
-
handleSubmit:
|
|
1239
|
+
register: pe,
|
|
1240
|
+
handleSubmit: et,
|
|
1241
1241
|
watch: _e,
|
|
1242
1242
|
setValue: Z,
|
|
1243
1243
|
getValues: c,
|
|
1244
|
-
reset:
|
|
1244
|
+
reset: rt,
|
|
1245
1245
|
resetField: Nt,
|
|
1246
|
-
clearErrors:
|
|
1246
|
+
clearErrors: N,
|
|
1247
1247
|
unregister: le,
|
|
1248
|
-
setError:
|
|
1248
|
+
setError: M,
|
|
1249
1249
|
setFocus: Lt,
|
|
1250
|
-
getFieldState:
|
|
1250
|
+
getFieldState: _
|
|
1251
1251
|
};
|
|
1252
1252
|
return {
|
|
1253
|
-
...
|
|
1254
|
-
formControl:
|
|
1253
|
+
...st,
|
|
1254
|
+
formControl: st
|
|
1255
1255
|
};
|
|
1256
1256
|
}
|
|
1257
|
-
function
|
|
1258
|
-
const r =
|
|
1257
|
+
function vr(e = {}) {
|
|
1258
|
+
const r = S.useRef(void 0), t = S.useRef(void 0), [n, o] = S.useState({
|
|
1259
1259
|
isDirty: !1,
|
|
1260
1260
|
isValidating: !1,
|
|
1261
1261
|
isLoading: ne(e.defaultValues),
|
|
@@ -1279,49 +1279,49 @@ function hr(e = {}) {
|
|
|
1279
1279
|
formState: n
|
|
1280
1280
|
}, e.defaultValues && !ne(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
|
|
1281
1281
|
else {
|
|
1282
|
-
const { formControl: u, ...f } =
|
|
1282
|
+
const { formControl: u, ...f } = hr(e);
|
|
1283
1283
|
r.current = {
|
|
1284
1284
|
...f,
|
|
1285
1285
|
formState: n
|
|
1286
1286
|
};
|
|
1287
1287
|
}
|
|
1288
|
-
const
|
|
1289
|
-
return
|
|
1290
|
-
const u =
|
|
1291
|
-
formState:
|
|
1292
|
-
callback: () => o({ ...
|
|
1288
|
+
const a = r.current.control;
|
|
1289
|
+
return a._options = e, Ft(() => {
|
|
1290
|
+
const u = a._subscribe({
|
|
1291
|
+
formState: a._proxyFormState,
|
|
1292
|
+
callback: () => o({ ...a._formState }),
|
|
1293
1293
|
reRenderRoot: !0
|
|
1294
1294
|
});
|
|
1295
1295
|
return o((f) => ({
|
|
1296
1296
|
...f,
|
|
1297
1297
|
isReady: !0
|
|
1298
|
-
})),
|
|
1299
|
-
}, [
|
|
1300
|
-
e.mode && (
|
|
1301
|
-
}, [
|
|
1302
|
-
e.errors && (
|
|
1303
|
-
}, [
|
|
1304
|
-
e.shouldUnregister &&
|
|
1305
|
-
values:
|
|
1298
|
+
})), a._formState.isReady = !0, u;
|
|
1299
|
+
}, [a]), S.useEffect(() => a._disableForm(e.disabled), [a, e.disabled]), S.useEffect(() => {
|
|
1300
|
+
e.mode && (a._options.mode = e.mode), e.reValidateMode && (a._options.reValidateMode = e.reValidateMode);
|
|
1301
|
+
}, [a, e.mode, e.reValidateMode]), S.useEffect(() => {
|
|
1302
|
+
e.errors && (a._setErrors(e.errors), a._focusError());
|
|
1303
|
+
}, [a, e.errors]), S.useEffect(() => {
|
|
1304
|
+
e.shouldUnregister && a._subjects.state.next({
|
|
1305
|
+
values: a._getWatch()
|
|
1306
1306
|
});
|
|
1307
|
-
}, [
|
|
1308
|
-
if (
|
|
1309
|
-
const u =
|
|
1310
|
-
u !== n.isDirty &&
|
|
1307
|
+
}, [a, e.shouldUnregister]), S.useEffect(() => {
|
|
1308
|
+
if (a._proxyFormState.isDirty) {
|
|
1309
|
+
const u = a._getDirty();
|
|
1310
|
+
u !== n.isDirty && a._subjects.state.next({
|
|
1311
1311
|
isDirty: u
|
|
1312
1312
|
});
|
|
1313
1313
|
}
|
|
1314
|
-
}, [
|
|
1314
|
+
}, [a, n.isDirty]), S.useEffect(() => {
|
|
1315
1315
|
var u;
|
|
1316
|
-
e.values && !
|
|
1316
|
+
e.values && !ie(e.values, t.current) ? (a._reset(e.values, {
|
|
1317
1317
|
keepFieldsRef: !0,
|
|
1318
|
-
...
|
|
1319
|
-
}), !((u =
|
|
1320
|
-
}, [
|
|
1321
|
-
|
|
1322
|
-
}), r.current.formState =
|
|
1318
|
+
...a._options.resetOptions
|
|
1319
|
+
}), !((u = a._options.resetOptions) === null || u === void 0) && u.keepIsValid || a._setValid(), t.current = e.values, o((f) => ({ ...f }))) : a._resetDefaultValues();
|
|
1320
|
+
}, [a, e.values]), S.useEffect(() => {
|
|
1321
|
+
a._state.mount || (a._setValid(), a._state.mount = !0), a._state.watch && (a._state.watch = !1, a._subjects.state.next({ ...a._formState })), a._removeUnmounted();
|
|
1322
|
+
}), r.current.formState = er(n, a), r.current;
|
|
1323
1323
|
}
|
|
1324
|
-
const Ot = Wt(null),
|
|
1324
|
+
const Ot = Wt(null), br = ({
|
|
1325
1325
|
children: e,
|
|
1326
1326
|
layout: r = "vertical",
|
|
1327
1327
|
uiConfig: t,
|
|
@@ -1341,31 +1341,31 @@ const Ot = Wt(null), vr = ({
|
|
|
1341
1341
|
if (!e)
|
|
1342
1342
|
throw new Error("useAutoFormRenderContext must be used within AutoFormRenderContextProvider");
|
|
1343
1343
|
return e;
|
|
1344
|
-
},
|
|
1344
|
+
}, gr = (e) => {
|
|
1345
1345
|
const { fieldSchema: r } = e, { register: t } = be(), n = t(r.name);
|
|
1346
1346
|
return /* @__PURE__ */ V.jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
|
|
1347
1347
|
/* @__PURE__ */ V.jsx("label", { children: r.label }),
|
|
1348
1348
|
/* @__PURE__ */ V.jsx("input", { type: r.type, ...n, readOnly: r.readonly })
|
|
1349
1349
|
] });
|
|
1350
|
-
},
|
|
1350
|
+
}, _r = (e) => {
|
|
1351
1351
|
const { fieldSchema: r } = e, { register: t } = be(), n = t(r.name), o = r.options;
|
|
1352
1352
|
return /* @__PURE__ */ V.jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
|
|
1353
1353
|
/* @__PURE__ */ V.jsx("label", { children: r.label }),
|
|
1354
|
-
/* @__PURE__ */ V.jsx("select", { ...n, disabled: r.readonly, children: o.map((
|
|
1354
|
+
/* @__PURE__ */ V.jsx("select", { ...n, disabled: r.readonly, children: o.map((a) => /* @__PURE__ */ V.jsx("option", { value: a.value, children: a.label }, a.value)) })
|
|
1355
1355
|
] });
|
|
1356
1356
|
};
|
|
1357
|
-
function
|
|
1357
|
+
function xr(e, r) {
|
|
1358
1358
|
const t = {};
|
|
1359
1359
|
return e.forEach((n, o) => {
|
|
1360
|
-
const
|
|
1360
|
+
const a = n.split(".");
|
|
1361
1361
|
let u = t;
|
|
1362
|
-
|
|
1363
|
-
const A = F ===
|
|
1364
|
-
A ? u[f] = r[o] : (f in u || (u[f] =
|
|
1362
|
+
a.forEach((f, F) => {
|
|
1363
|
+
const A = F === a.length - 1, D = !isNaN(Number(f));
|
|
1364
|
+
A ? u[f] = r[o] : (f in u || (u[f] = D ? [] : {}), u = u[f]);
|
|
1365
1365
|
});
|
|
1366
1366
|
}), t;
|
|
1367
1367
|
}
|
|
1368
|
-
function
|
|
1368
|
+
function Er(e) {
|
|
1369
1369
|
switch (e) {
|
|
1370
1370
|
case "array":
|
|
1371
1371
|
return [];
|
|
@@ -1374,13 +1374,13 @@ function xr(e) {
|
|
|
1374
1374
|
return null;
|
|
1375
1375
|
}
|
|
1376
1376
|
}
|
|
1377
|
-
function
|
|
1377
|
+
function Ke(e) {
|
|
1378
1378
|
return e.replace(/\.\d+\./g, ".");
|
|
1379
1379
|
}
|
|
1380
|
-
function
|
|
1380
|
+
function Vr(e, r) {
|
|
1381
1381
|
const t = e.split("."), n = [];
|
|
1382
|
-
return t.forEach((o,
|
|
1383
|
-
isNaN(Number(o)) || n.push({ pos:
|
|
1382
|
+
return t.forEach((o, a) => {
|
|
1383
|
+
isNaN(Number(o)) || n.push({ pos: a, value: o });
|
|
1384
1384
|
}), r.map((o) => {
|
|
1385
1385
|
const u = [...o.split(".")];
|
|
1386
1386
|
return n.forEach(({ pos: f, value: F }) => {
|
|
@@ -1395,7 +1395,7 @@ function Ne(e, r = {}) {
|
|
|
1395
1395
|
const o = n.fields;
|
|
1396
1396
|
t[n.name] = Ne(o, r == null ? void 0 : r[n.name]);
|
|
1397
1397
|
} else
|
|
1398
|
-
t[n.name] = (r == null ? void 0 : r[n.name]) ?? n.initialValue ??
|
|
1398
|
+
t[n.name] = (r == null ? void 0 : r[n.name]) ?? n.initialValue ?? Er(n.type);
|
|
1399
1399
|
return t;
|
|
1400
1400
|
}
|
|
1401
1401
|
function Ct(e) {
|
|
@@ -1414,11 +1414,11 @@ function Ct(e) {
|
|
|
1414
1414
|
};
|
|
1415
1415
|
});
|
|
1416
1416
|
}
|
|
1417
|
-
const
|
|
1418
|
-
const { baseName: r, index: t, fields: n } = e, o =
|
|
1419
|
-
() => n.map((
|
|
1420
|
-
...
|
|
1421
|
-
name: `${r}.${t}.${
|
|
1417
|
+
const Fr = S.memo((e) => {
|
|
1418
|
+
const { baseName: r, index: t, fields: n } = e, o = S.useMemo(
|
|
1419
|
+
() => n.map((a) => ({
|
|
1420
|
+
...a,
|
|
1421
|
+
name: `${r}.${t}.${a.name}`
|
|
1422
1422
|
})),
|
|
1423
1423
|
[r, t, n]
|
|
1424
1424
|
);
|
|
@@ -1429,25 +1429,25 @@ const Vr = k.memo((e) => {
|
|
|
1429
1429
|
] }),
|
|
1430
1430
|
/* @__PURE__ */ V.jsx(Le, { schema: o })
|
|
1431
1431
|
] });
|
|
1432
|
-
}),
|
|
1433
|
-
const { fieldSchema: r } = e, { control: t, getValues: n, setValue: o } = be(), u =
|
|
1432
|
+
}), pr = (e) => {
|
|
1433
|
+
const { fieldSchema: r } = e, { control: t, getValues: n, setValue: o } = be(), u = pt({
|
|
1434
1434
|
control: t,
|
|
1435
1435
|
name: r.name
|
|
1436
1436
|
}) ?? [], f = () => {
|
|
1437
1437
|
const A = n(r.name) || [];
|
|
1438
1438
|
o(r.name, [...A, Ne(r.fields)]);
|
|
1439
1439
|
}, F = (A) => {
|
|
1440
|
-
const
|
|
1441
|
-
o(r.name,
|
|
1440
|
+
const E = (n(r.name) || []).filter((p, b) => b !== A);
|
|
1441
|
+
o(r.name, E);
|
|
1442
1442
|
};
|
|
1443
1443
|
return /* @__PURE__ */ V.jsxs("div", { children: [
|
|
1444
|
-
u.map((A,
|
|
1445
|
-
/* @__PURE__ */ V.jsx(
|
|
1446
|
-
!r.readonly && /* @__PURE__ */ V.jsx("button", { type: "button", onClick: () => F(
|
|
1447
|
-
] },
|
|
1444
|
+
u.map((A, D) => /* @__PURE__ */ V.jsxs("div", { children: [
|
|
1445
|
+
/* @__PURE__ */ V.jsx(Fr, { baseName: r.name, index: D, fields: r.fields }),
|
|
1446
|
+
!r.readonly && /* @__PURE__ */ V.jsx("button", { type: "button", onClick: () => F(D), children: "Remove" })
|
|
1447
|
+
] }, D)),
|
|
1448
1448
|
!r.readonly && /* @__PURE__ */ V.jsx("button", { type: "button", onClick: f, children: "Add Row" })
|
|
1449
1449
|
] });
|
|
1450
|
-
}, Ar =
|
|
1450
|
+
}, Ar = S.memo(pr), wr = (e) => {
|
|
1451
1451
|
const { fieldSchema: r } = e;
|
|
1452
1452
|
let t = he(
|
|
1453
1453
|
() => r.fields.map((n) => ({
|
|
@@ -1458,46 +1458,46 @@ const Vr = k.memo((e) => {
|
|
|
1458
1458
|
);
|
|
1459
1459
|
return /* @__PURE__ */ V.jsx(Le, { schema: t });
|
|
1460
1460
|
}, jt = ({ fieldSchema: e }) => {
|
|
1461
|
-
var A,
|
|
1462
|
-
const t = Dt().uiConfig, { register: n, control: o } = be(),
|
|
1461
|
+
var A, D;
|
|
1462
|
+
const t = Dt().uiConfig, { register: n, control: o } = be(), a = Ke(e.name), u = n(e.name), f = (A = t == null ? void 0 : t.renderersByName) == null ? void 0 : A[a];
|
|
1463
1463
|
if (e.visible === !1)
|
|
1464
1464
|
return null;
|
|
1465
1465
|
if (f)
|
|
1466
1466
|
return /* @__PURE__ */ V.jsx(f, { fieldSchema: e, control: o, register: u });
|
|
1467
|
-
const F = (
|
|
1467
|
+
const F = (D = t == null ? void 0 : t.renderersByType) == null ? void 0 : D[e.type];
|
|
1468
1468
|
if (F)
|
|
1469
1469
|
return /* @__PURE__ */ V.jsx(F, { fieldSchema: e, control: o, register: u });
|
|
1470
1470
|
switch (e.type) {
|
|
1471
1471
|
case "select":
|
|
1472
|
-
return /* @__PURE__ */ V.jsx(
|
|
1472
|
+
return /* @__PURE__ */ V.jsx(_r, { fieldSchema: e });
|
|
1473
1473
|
case "array":
|
|
1474
1474
|
return /* @__PURE__ */ V.jsx(Ar, { fieldSchema: e });
|
|
1475
1475
|
case "object":
|
|
1476
|
-
return /* @__PURE__ */ V.jsx(
|
|
1476
|
+
return /* @__PURE__ */ V.jsx(wr, { fieldSchema: e });
|
|
1477
1477
|
case "text":
|
|
1478
1478
|
case "number":
|
|
1479
1479
|
case "checkbox":
|
|
1480
1480
|
case "date":
|
|
1481
1481
|
case "datetime-local":
|
|
1482
1482
|
case "time":
|
|
1483
|
-
return /* @__PURE__ */ V.jsx(
|
|
1483
|
+
return /* @__PURE__ */ V.jsx(gr, { fieldSchema: e });
|
|
1484
1484
|
}
|
|
1485
|
-
},
|
|
1485
|
+
}, Rr = ({ fieldSchema: e }) => /* @__PURE__ */ V.jsx(jt, { fieldSchema: e }), kr = ({ fieldSchema: e }) => {
|
|
1486
1486
|
const { control: r } = be(), t = Dt(), n = e.dependsOn ?? [], o = he(
|
|
1487
|
-
() =>
|
|
1487
|
+
() => Vr(e.name, n),
|
|
1488
1488
|
[e.name, n]
|
|
1489
|
-
),
|
|
1489
|
+
), a = pt({
|
|
1490
1490
|
control: r,
|
|
1491
1491
|
name: o
|
|
1492
|
-
}), [u, f] =
|
|
1492
|
+
}), [u, f] = Et(e);
|
|
1493
1493
|
return Ce(() => {
|
|
1494
1494
|
if (!n.length) return;
|
|
1495
1495
|
let F = !1;
|
|
1496
1496
|
return (async () => {
|
|
1497
|
-
var
|
|
1498
|
-
const
|
|
1497
|
+
var U;
|
|
1498
|
+
const D = Ke(e.name), E = xr(o, a ?? []), p = (U = t == null ? void 0 : t.updateFieldSchema) == null ? void 0 : U[D];
|
|
1499
1499
|
if (!p) return;
|
|
1500
|
-
const b = await p(e.name, e,
|
|
1500
|
+
const b = await p(e.name, e, E);
|
|
1501
1501
|
!F && b && f({
|
|
1502
1502
|
...e,
|
|
1503
1503
|
...b
|
|
@@ -1505,44 +1505,54 @@ const Vr = k.memo((e) => {
|
|
|
1505
1505
|
})(), () => {
|
|
1506
1506
|
F = !0;
|
|
1507
1507
|
};
|
|
1508
|
-
}, [
|
|
1509
|
-
},
|
|
1508
|
+
}, [a]), /* @__PURE__ */ V.jsx(jt, { fieldSchema: u });
|
|
1509
|
+
}, Sr = (e) => {
|
|
1510
1510
|
var t;
|
|
1511
1511
|
const { fieldSchema: r } = e;
|
|
1512
|
-
return (t = r.dependsOn) != null && t.length ? /* @__PURE__ */ V.jsx(
|
|
1513
|
-
},
|
|
1512
|
+
return (t = r.dependsOn) != null && t.length ? /* @__PURE__ */ V.jsx(kr, { fieldSchema: r }) : /* @__PURE__ */ V.jsx(Rr, { fieldSchema: r });
|
|
1513
|
+
}, Tr = (e) => {
|
|
1514
1514
|
const { fieldSchema: r } = e;
|
|
1515
|
-
return /* @__PURE__ */ V.jsx(
|
|
1516
|
-
}, Le =
|
|
1515
|
+
return /* @__PURE__ */ V.jsx(Sr, { fieldSchema: r });
|
|
1516
|
+
}, Le = S.memo((e) => {
|
|
1517
1517
|
const { schema: r } = e;
|
|
1518
|
-
return r.map((t) => /* @__PURE__ */ V.jsx(
|
|
1518
|
+
return r.map((t) => /* @__PURE__ */ V.jsx(Tr, { fieldSchema: t }, t.name));
|
|
1519
1519
|
});
|
|
1520
|
-
function
|
|
1521
|
-
const t = (
|
|
1520
|
+
function $e(e, r) {
|
|
1521
|
+
const t = (a) => /^\d+$/.test(a), n = e.split(".");
|
|
1522
1522
|
let o = r;
|
|
1523
|
-
for (const
|
|
1523
|
+
for (const a of n) {
|
|
1524
1524
|
if (o == null) return;
|
|
1525
|
-
const u = t(
|
|
1525
|
+
const u = t(a) ? Number(a) : a;
|
|
1526
1526
|
o = o[u];
|
|
1527
1527
|
}
|
|
1528
1528
|
return o;
|
|
1529
1529
|
}
|
|
1530
1530
|
const Or = (e) => {
|
|
1531
|
-
const { onDirtyChange: r, onValuesChange: t, onFieldChange: n } = e, { formState: o, watch:
|
|
1531
|
+
const { onDirtyChange: r, onValuesChange: t, onFieldChange: n } = e, { formState: o, watch: a, getValues: u, setValue: f, setError: F, clearErrors: A } = be();
|
|
1532
1532
|
return Ce(() => {
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1535
|
-
t(
|
|
1536
|
-
|
|
1537
|
-
|
|
1533
|
+
const D = a((E, { name: p = "" }) => {
|
|
1534
|
+
const b = E;
|
|
1535
|
+
t == null || t({
|
|
1536
|
+
values: b,
|
|
1537
|
+
setValue: (w, g) => f(w, g),
|
|
1538
|
+
setError: (w, g) => F(w, { type: "manual", message: g }),
|
|
1539
|
+
clearError: (w) => A(w),
|
|
1540
|
+
getValue: (w) => $e(w, u())
|
|
1541
|
+
});
|
|
1542
|
+
const U = Ke(p), T = $e(p, b), I = n == null ? void 0 : n[U];
|
|
1543
|
+
I && I({
|
|
1544
|
+
path: p,
|
|
1545
|
+
value: T,
|
|
1546
|
+
values: b,
|
|
1547
|
+
setValue: (w, g) => f(w, g),
|
|
1548
|
+
setError: (w, g) => F(w, { type: "manual", message: g }),
|
|
1549
|
+
clearError: (w) => A(w),
|
|
1550
|
+
getValue: (w) => $e(w, u())
|
|
1551
|
+
});
|
|
1538
1552
|
});
|
|
1539
|
-
return () =>
|
|
1540
|
-
}, [
|
|
1541
|
-
|
|
1542
|
-
u.current = !1;
|
|
1543
|
-
return;
|
|
1544
|
-
}
|
|
1545
|
-
r(o.isDirty);
|
|
1553
|
+
return () => D.unsubscribe();
|
|
1554
|
+
}, [a, t, n, u, f, F, A]), Ce(() => {
|
|
1555
|
+
r == null || r(o.isDirty);
|
|
1546
1556
|
}, [o.isDirty, r]), null;
|
|
1547
1557
|
}, Dr = ({
|
|
1548
1558
|
onValuesChange: e,
|
|
@@ -1552,7 +1562,7 @@ const Or = (e) => {
|
|
|
1552
1562
|
onDirtyChange: r,
|
|
1553
1563
|
onValuesChange: e,
|
|
1554
1564
|
onFieldChange: t
|
|
1555
|
-
}), null), Pr =
|
|
1565
|
+
}), null), Pr = S.forwardRef((e, r) => {
|
|
1556
1566
|
const {
|
|
1557
1567
|
schema: t,
|
|
1558
1568
|
onSubmit: n,
|
|
@@ -1560,23 +1570,23 @@ const Or = (e) => {
|
|
|
1560
1570
|
renderersByName: {},
|
|
1561
1571
|
renderersByType: {}
|
|
1562
1572
|
},
|
|
1563
|
-
updateFieldSchema:
|
|
1573
|
+
updateFieldSchema: a = {},
|
|
1564
1574
|
layout: u = "vertical",
|
|
1565
1575
|
values: f = () => ({}),
|
|
1566
1576
|
hideSubmit: F = !1,
|
|
1567
1577
|
onDirtyChange: A = () => {
|
|
1568
1578
|
},
|
|
1569
|
-
onValuesChange:
|
|
1579
|
+
onValuesChange: D = (j) => {
|
|
1570
1580
|
},
|
|
1571
|
-
resolver:
|
|
1581
|
+
resolver: E,
|
|
1572
1582
|
readonly: p,
|
|
1573
1583
|
onFieldChange: b = {},
|
|
1574
|
-
loadingComponent:
|
|
1575
|
-
} = e,
|
|
1584
|
+
loadingComponent: U
|
|
1585
|
+
} = e, T = vr({
|
|
1576
1586
|
reValidateMode: "onSubmit",
|
|
1577
1587
|
criteriaMode: "all",
|
|
1578
|
-
resolver:
|
|
1579
|
-
}),
|
|
1588
|
+
resolver: E
|
|
1589
|
+
}), I = Yt(!1), [w, g] = Et(!1), J = he(() => {
|
|
1580
1590
|
let j = t;
|
|
1581
1591
|
return p && (j = Ct(j)), j;
|
|
1582
1592
|
}, [p, t]);
|
|
@@ -1584,20 +1594,20 @@ const Or = (e) => {
|
|
|
1584
1594
|
if (!f) return;
|
|
1585
1595
|
let j = !1;
|
|
1586
1596
|
return (async () => {
|
|
1587
|
-
if (
|
|
1588
|
-
|
|
1597
|
+
if (I.current) return;
|
|
1598
|
+
g(!1);
|
|
1589
1599
|
const X = await f();
|
|
1590
|
-
j || (
|
|
1600
|
+
j || (T.reset(Ne(t, X), {
|
|
1591
1601
|
keepErrors: !0,
|
|
1592
1602
|
keepDirty: !1,
|
|
1593
1603
|
keepTouched: !1
|
|
1594
|
-
}),
|
|
1604
|
+
}), I.current = !0, g(!0));
|
|
1595
1605
|
})(), () => {
|
|
1596
1606
|
j = !0;
|
|
1597
1607
|
};
|
|
1598
|
-
}, [t, f]),
|
|
1608
|
+
}, [t, f]), qt(r, () => ({
|
|
1599
1609
|
submit: () => new Promise((j) => {
|
|
1600
|
-
|
|
1610
|
+
T.handleSubmit(
|
|
1601
1611
|
async (G) => {
|
|
1602
1612
|
await n(G), j({ success: !0, errors: {} });
|
|
1603
1613
|
},
|
|
@@ -1607,33 +1617,34 @@ const Or = (e) => {
|
|
|
1607
1617
|
)();
|
|
1608
1618
|
}),
|
|
1609
1619
|
reset: (j) => {
|
|
1610
|
-
|
|
1620
|
+
T.reset(j ? Ne(t, j) : void 0);
|
|
1611
1621
|
},
|
|
1612
|
-
getValues: () =>
|
|
1622
|
+
getValues: () => T.getValues(),
|
|
1613
1623
|
setValue: (j, G) => {
|
|
1614
|
-
|
|
1624
|
+
T.setValue(j, G);
|
|
1615
1625
|
},
|
|
1616
|
-
getErrors: () =>
|
|
1626
|
+
getErrors: () => T.formState.errors,
|
|
1627
|
+
formState: () => T.formState
|
|
1617
1628
|
}));
|
|
1618
|
-
const
|
|
1629
|
+
const P = F || p, k = he(() => o, [o]), K = he(() => a, [a]), oe = he(
|
|
1619
1630
|
() => ({
|
|
1620
1631
|
layout: u,
|
|
1621
|
-
uiConfig:
|
|
1632
|
+
uiConfig: k,
|
|
1622
1633
|
updateFieldSchema: K
|
|
1623
1634
|
}),
|
|
1624
|
-
[u,
|
|
1635
|
+
[u, k, K]
|
|
1625
1636
|
);
|
|
1626
|
-
return
|
|
1637
|
+
return w ? /* @__PURE__ */ V.jsxs(Kt, { ...T, children: [
|
|
1627
1638
|
/* @__PURE__ */ V.jsx(
|
|
1628
1639
|
Dr,
|
|
1629
1640
|
{
|
|
1630
1641
|
onDirtyChange: A,
|
|
1631
|
-
onValuesChange:
|
|
1642
|
+
onValuesChange: D,
|
|
1632
1643
|
onFieldChange: b
|
|
1633
1644
|
}
|
|
1634
1645
|
),
|
|
1635
1646
|
/* @__PURE__ */ V.jsxs(
|
|
1636
|
-
|
|
1647
|
+
br,
|
|
1637
1648
|
{
|
|
1638
1649
|
layout: oe.layout,
|
|
1639
1650
|
uiConfig: oe.uiConfig,
|
|
@@ -1650,11 +1661,11 @@ const Or = (e) => {
|
|
|
1650
1661
|
}
|
|
1651
1662
|
),
|
|
1652
1663
|
u === "custom" && /* @__PURE__ */ V.jsx(Le, { schema: J }),
|
|
1653
|
-
!
|
|
1664
|
+
!P && /* @__PURE__ */ V.jsx("button", { style: { marginTop: "1rem" }, onClick: T.handleSubmit(n), children: "Submit" })
|
|
1654
1665
|
]
|
|
1655
1666
|
}
|
|
1656
1667
|
)
|
|
1657
|
-
] }) : /* @__PURE__ */ V.jsx(V.Fragment, { children:
|
|
1668
|
+
] }) : /* @__PURE__ */ V.jsx(V.Fragment, { children: U ?? /* @__PURE__ */ V.jsx(
|
|
1658
1669
|
"div",
|
|
1659
1670
|
{
|
|
1660
1671
|
style: {
|
|
@@ -1670,10 +1681,10 @@ const Or = (e) => {
|
|
|
1670
1681
|
export {
|
|
1671
1682
|
Pr as AutoForm,
|
|
1672
1683
|
Le as SchemaRenderer,
|
|
1673
|
-
|
|
1684
|
+
xr as buildNestedPartialValues,
|
|
1674
1685
|
Ne as generateInitialValues,
|
|
1675
|
-
|
|
1686
|
+
Er as getDefaultValueForField,
|
|
1676
1687
|
Ct as makeSchemaReadOnly,
|
|
1677
|
-
|
|
1678
|
-
|
|
1688
|
+
Ke as normalizeFieldPath,
|
|
1689
|
+
Vr as resolveDependsOnNew
|
|
1679
1690
|
};
|