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