autoforma 2.8.0 → 2.9.1
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/layouts/FieldLayout.d.ts +1 -1
- package/dist/autoform/render/FieldRenderer.d.ts +1 -1
- package/dist/autoform/types.d.ts +1 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +494 -478
- package/dist/stories/fields/containers/Array.stories.d.ts +6 -0
- package/dist/stories/fields/containers/Object.stories.d.ts +6 -0
- package/dist/stories/fields/primitives/Input.stories.d.ts +8 -0
- package/dist/stories/form/Form.stories.d.ts +12 -0
- package/dist/stories/form/FormCustomize.stories.d.ts +6 -0
- package/dist/stories/form/FormValidation.stories.d.ts +6 -0
- package/package.json +2 -1
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import R, { useMemo as
|
|
2
|
-
var De = { exports: {} },
|
|
1
|
+
import R, { useMemo as ve, createContext as $t, useContext as Wt, useState as xt, useEffect as Ce, useRef as Et, useImperativeHandle as Yt } from "react";
|
|
2
|
+
var De = { exports: {} }, pe = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
5
5
|
* react-jsx-runtime.production.js
|
|
@@ -11,12 +11,12 @@ var De = { exports: {} }, Ae = {};
|
|
|
11
11
|
*/
|
|
12
12
|
var it;
|
|
13
13
|
function qt() {
|
|
14
|
-
if (it) return
|
|
14
|
+
if (it) return pe;
|
|
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 u = null;
|
|
19
|
+
if (i !== void 0 && (u = "" + i), o.key !== void 0 && (u = "" + o.key), "key" in o) {
|
|
20
20
|
i = {};
|
|
21
21
|
for (var f in o)
|
|
22
22
|
f !== "key" && (i[f] = o[f]);
|
|
@@ -24,14 +24,14 @@ function qt() {
|
|
|
24
24
|
return o = i.ref, {
|
|
25
25
|
$$typeof: e,
|
|
26
26
|
type: n,
|
|
27
|
-
key:
|
|
27
|
+
key: u,
|
|
28
28
|
ref: o !== void 0 ? o : null,
|
|
29
29
|
props: i
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return pe.Fragment = r, pe.jsx = t, pe.jsxs = t, pe;
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var Ae = {};
|
|
35
35
|
/**
|
|
36
36
|
* @license React
|
|
37
37
|
* react-jsx-runtime.development.js
|
|
@@ -47,38 +47,38 @@ function zt() {
|
|
|
47
47
|
function e(c) {
|
|
48
48
|
if (c == null) return null;
|
|
49
49
|
if (typeof c == "function")
|
|
50
|
-
return c.$$typeof ===
|
|
50
|
+
return c.$$typeof === fe ? null : c.displayName || c.name || null;
|
|
51
51
|
if (typeof c == "string") return c;
|
|
52
52
|
switch (c) {
|
|
53
53
|
case z:
|
|
54
54
|
return "Fragment";
|
|
55
|
-
case
|
|
55
|
+
case E:
|
|
56
56
|
return "Profiler";
|
|
57
|
-
case
|
|
57
|
+
case $:
|
|
58
58
|
return "StrictMode";
|
|
59
|
-
case
|
|
59
|
+
case ee:
|
|
60
60
|
return "Suspense";
|
|
61
|
-
case
|
|
61
|
+
case ce:
|
|
62
62
|
return "SuspenseList";
|
|
63
|
-
case
|
|
63
|
+
case J:
|
|
64
64
|
return "Activity";
|
|
65
65
|
}
|
|
66
66
|
if (typeof c == "object")
|
|
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 O:
|
|
71
71
|
return "Portal";
|
|
72
72
|
case C:
|
|
73
73
|
return c.displayName || "Context";
|
|
74
|
-
case
|
|
74
|
+
case G:
|
|
75
75
|
return (c._context.displayName || "Context") + ".Consumer";
|
|
76
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 se:
|
|
80
80
|
return g = c.displayName || null, g !== null ? g : e(c.type) || "Memo";
|
|
81
|
-
case
|
|
81
|
+
case N:
|
|
82
82
|
g = c._payload, c = c._init;
|
|
83
83
|
try {
|
|
84
84
|
return e(c(g));
|
|
@@ -109,7 +109,7 @@ function zt() {
|
|
|
109
109
|
}
|
|
110
110
|
function n(c) {
|
|
111
111
|
if (c === z) return "<>";
|
|
112
|
-
if (typeof c == "object" && c !== null && c.$$typeof ===
|
|
112
|
+
if (typeof c == "object" && c !== null && c.$$typeof === N)
|
|
113
113
|
return "<...>";
|
|
114
114
|
try {
|
|
115
115
|
var g = e(c);
|
|
@@ -125,8 +125,8 @@ function zt() {
|
|
|
125
125
|
function i() {
|
|
126
126
|
return Error("react-stack-top-frame");
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
if (
|
|
128
|
+
function u(c) {
|
|
129
|
+
if (A.call(c, "key")) {
|
|
130
130
|
var g = Object.getOwnPropertyDescriptor(c, "key").get;
|
|
131
131
|
if (g && g.isReactWarning) return !1;
|
|
132
132
|
}
|
|
@@ -144,23 +144,23 @@ function zt() {
|
|
|
144
144
|
configurable: !0
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function F() {
|
|
148
148
|
var c = e(this.type);
|
|
149
|
-
return
|
|
149
|
+
return X[c] || (X[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
153
|
function w(c, g, j, I, _e, xe) {
|
|
154
|
-
var
|
|
154
|
+
var U = j.ref;
|
|
155
155
|
return c = {
|
|
156
|
-
$$typeof:
|
|
156
|
+
$$typeof: B,
|
|
157
157
|
type: c,
|
|
158
158
|
key: g,
|
|
159
159
|
props: j,
|
|
160
160
|
_owner: I
|
|
161
|
-
}, (
|
|
161
|
+
}, (U !== void 0 ? U : null) !== null ? Object.defineProperty(c, "ref", {
|
|
162
162
|
enumerable: !1,
|
|
163
|
-
get:
|
|
163
|
+
get: F
|
|
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,
|
|
@@ -184,24 +184,24 @@ function zt() {
|
|
|
184
184
|
}), Object.freeze && (Object.freeze(c.props), Object.freeze(c)), c;
|
|
185
185
|
}
|
|
186
186
|
function T(c, g, j, I, _e, xe) {
|
|
187
|
-
var
|
|
188
|
-
if (
|
|
187
|
+
var U = g.children;
|
|
188
|
+
if (U !== void 0)
|
|
189
189
|
if (I)
|
|
190
|
-
if (
|
|
191
|
-
for (I = 0; I <
|
|
192
|
-
x(
|
|
193
|
-
Object.freeze && Object.freeze(
|
|
190
|
+
if (L(U)) {
|
|
191
|
+
for (I = 0; I < U.length; I++)
|
|
192
|
+
x(U[I]);
|
|
193
|
+
Object.freeze && Object.freeze(U);
|
|
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 x(
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
var oe = Object.keys(g).filter(function(
|
|
202
|
-
return
|
|
198
|
+
else x(U);
|
|
199
|
+
if (A.call(g, "key")) {
|
|
200
|
+
U = e(c);
|
|
201
|
+
var oe = Object.keys(g).filter(function(we) {
|
|
202
|
+
return we !== "key";
|
|
203
203
|
});
|
|
204
|
-
I = 0 < oe.length ? "{key: someKey, " + oe.join(": ..., ") + ": ...}" : "{key: someKey}",
|
|
204
|
+
I = 0 < oe.length ? "{key: someKey, " + oe.join(": ..., ") + ": ...}" : "{key: someKey}", me[U + 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} />
|
|
@@ -209,22 +209,22 @@ React keys must be passed directly to JSX without using spread:
|
|
|
209
209
|
let props = %s;
|
|
210
210
|
<%s key={someKey} {...props} />`,
|
|
211
211
|
I,
|
|
212
|
-
|
|
212
|
+
U,
|
|
213
213
|
oe,
|
|
214
|
-
|
|
215
|
-
),
|
|
214
|
+
U
|
|
215
|
+
), me[U + I] = !0);
|
|
216
216
|
}
|
|
217
|
-
if (
|
|
217
|
+
if (U = null, j !== void 0 && (t(j), U = "" + j), u(g) && (t(g.key), U = "" + g.key), "key" in g) {
|
|
218
218
|
j = {};
|
|
219
219
|
for (var Ee in g)
|
|
220
220
|
Ee !== "key" && (j[Ee] = g[Ee]);
|
|
221
221
|
} else j = g;
|
|
222
|
-
return
|
|
222
|
+
return U && f(
|
|
223
223
|
j,
|
|
224
224
|
typeof c == "function" ? c.displayName || c.name || "Unknown" : c
|
|
225
225
|
), w(
|
|
226
226
|
c,
|
|
227
|
-
|
|
227
|
+
U,
|
|
228
228
|
j,
|
|
229
229
|
o(),
|
|
230
230
|
_e,
|
|
@@ -232,12 +232,12 @@ React keys must be passed directly to JSX without using spread:
|
|
|
232
232
|
);
|
|
233
233
|
}
|
|
234
234
|
function x(c) {
|
|
235
|
-
|
|
235
|
+
p(c) ? c._store && (c._store.validated = 1) : typeof c == "object" && c !== null && c.$$typeof === N && (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
|
-
function
|
|
238
|
-
return typeof c == "object" && c !== null && c.$$typeof ===
|
|
237
|
+
function p(c) {
|
|
238
|
+
return typeof c == "object" && c !== null && c.$$typeof === B;
|
|
239
239
|
}
|
|
240
|
-
var b = R,
|
|
240
|
+
var b = R, B = Symbol.for("react.transitional.element"), O = Symbol.for("react.portal"), z = Symbol.for("react.fragment"), $ = Symbol.for("react.strict_mode"), E = Symbol.for("react.profiler"), G = Symbol.for("react.consumer"), C = Symbol.for("react.context"), k = Symbol.for("react.forward_ref"), ee = Symbol.for("react.suspense"), ce = Symbol.for("react.suspense_list"), se = Symbol.for("react.memo"), N = Symbol.for("react.lazy"), J = Symbol.for("react.activity"), fe = Symbol.for("react.client.reference"), _ = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, A = Object.prototype.hasOwnProperty, L = Array.isArray, W = console.createTask ? console.createTask : function() {
|
|
241
241
|
return null;
|
|
242
242
|
};
|
|
243
243
|
b = {
|
|
@@ -245,40 +245,40 @@ React keys must be passed directly to JSX without using spread:
|
|
|
245
245
|
return c();
|
|
246
246
|
}
|
|
247
247
|
};
|
|
248
|
-
var Q,
|
|
248
|
+
var Q, X = {}, de = b.react_stack_bottom_frame.bind(
|
|
249
249
|
b,
|
|
250
250
|
i
|
|
251
|
-
)(),
|
|
252
|
-
|
|
251
|
+
)(), ye = W(n(i)), me = {};
|
|
252
|
+
Ae.Fragment = z, Ae.jsx = function(c, g, j) {
|
|
253
253
|
var I = 1e4 > _.recentlyCreatedOwnerStacks++;
|
|
254
254
|
return T(
|
|
255
255
|
c,
|
|
256
256
|
g,
|
|
257
257
|
j,
|
|
258
258
|
!1,
|
|
259
|
-
I ? Error("react-stack-top-frame") :
|
|
260
|
-
I ? W(n(c)) :
|
|
259
|
+
I ? Error("react-stack-top-frame") : de,
|
|
260
|
+
I ? W(n(c)) : ye
|
|
261
261
|
);
|
|
262
|
-
},
|
|
262
|
+
}, Ae.jsxs = function(c, g, j) {
|
|
263
263
|
var I = 1e4 > _.recentlyCreatedOwnerStacks++;
|
|
264
264
|
return T(
|
|
265
265
|
c,
|
|
266
266
|
g,
|
|
267
267
|
j,
|
|
268
268
|
!0,
|
|
269
|
-
I ? Error("react-stack-top-frame") :
|
|
270
|
-
I ? W(n(c)) :
|
|
269
|
+
I ? Error("react-stack-top-frame") : de,
|
|
270
|
+
I ? W(n(c)) : ye
|
|
271
271
|
);
|
|
272
272
|
};
|
|
273
|
-
})()),
|
|
273
|
+
})()), Ae;
|
|
274
274
|
}
|
|
275
275
|
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 V = Ht(), Te = (e) => e.type === "checkbox", be = (e) => e instanceof Date, K = (e) => e == null;
|
|
280
|
+
const Vt = (e) => typeof e == "object";
|
|
281
|
+
var q = (e) => !K(e) && !Array.isArray(e) && Vt(e) && !be(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";
|
|
@@ -296,36 +296,36 @@ function H(e) {
|
|
|
296
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), M = (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 M(n) || n === e ? M(e[r]) ? t : e[r] : n;
|
|
304
|
+
}, le = (e) => typeof e == "boolean", ne = (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, u = i - 1;
|
|
307
307
|
for (; ++n < i; ) {
|
|
308
308
|
const f = o[n];
|
|
309
|
-
let
|
|
310
|
-
if (n !==
|
|
309
|
+
let F = t;
|
|
310
|
+
if (n !== u) {
|
|
311
311
|
const w = e[f];
|
|
312
|
-
|
|
312
|
+
F = 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] = F, e = e[f];
|
|
317
317
|
}
|
|
318
318
|
};
|
|
319
|
-
const
|
|
319
|
+
const lt = {
|
|
320
320
|
BLUR: "blur",
|
|
321
321
|
FOCUS_OUT: "focusout"
|
|
322
|
-
},
|
|
322
|
+
}, ie = {
|
|
323
323
|
onBlur: "onBlur",
|
|
324
324
|
onChange: "onChange",
|
|
325
325
|
onSubmit: "onSubmit",
|
|
326
326
|
onTouched: "onTouched",
|
|
327
327
|
all: "all"
|
|
328
|
-
},
|
|
328
|
+
}, ue = {
|
|
329
329
|
max: "max",
|
|
330
330
|
min: "min",
|
|
331
331
|
maxLength: "maxLength",
|
|
@@ -335,7 +335,7 @@ const ut = {
|
|
|
335
335
|
validate: "validate"
|
|
336
336
|
}, Ge = R.createContext(null);
|
|
337
337
|
Ge.displayName = "HookFormContext";
|
|
338
|
-
const
|
|
338
|
+
const ge = () => R.useContext(Ge), Qt = (e) => {
|
|
339
339
|
const { children: r, ...t } = e;
|
|
340
340
|
return R.createElement(Ge.Provider, { value: t }, r);
|
|
341
341
|
};
|
|
@@ -346,18 +346,18 @@ 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 u = i;
|
|
350
|
+
return r._proxyFormState[u] !== ie.all && (r._proxyFormState[u] = !n || ie.all), e[u];
|
|
351
351
|
}
|
|
352
352
|
});
|
|
353
353
|
return o;
|
|
354
354
|
};
|
|
355
|
-
const
|
|
356
|
-
var
|
|
357
|
-
function
|
|
355
|
+
const Ft = typeof window < "u" ? R.useLayoutEffect : R.useEffect;
|
|
356
|
+
var te = (e) => typeof e == "string", We = (e, r, t, n, o) => te(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) || !Vt(e);
|
|
357
|
+
function ae(e, r, t = /* @__PURE__ */ new WeakSet()) {
|
|
358
358
|
if (Ye(e) || Ye(r))
|
|
359
359
|
return Object.is(e, r);
|
|
360
|
-
if (
|
|
360
|
+
if (be(e) && be(r))
|
|
361
361
|
return e.getTime() === r.getTime();
|
|
362
362
|
const n = Object.keys(e), o = Object.keys(r);
|
|
363
363
|
if (n.length !== o.length)
|
|
@@ -366,53 +366,53 @@ function ie(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 u = 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 (
|
|
374
|
+
if (be(u) && be(f) || q(u) && q(f) || Array.isArray(u) && Array.isArray(f) ? !ae(u, f, t) : !Object.is(u, f))
|
|
375
375
|
return !1;
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
return !0;
|
|
379
379
|
}
|
|
380
380
|
function wt(e) {
|
|
381
|
-
const r =
|
|
381
|
+
const r = ge(), { control: t = r.control, name: n, defaultValue: o, disabled: i, exact: u, compute: f } = e || {}, F = R.useRef(o), w = R.useRef(f), T = R.useRef(void 0), x = R.useRef(t), p = R.useRef(n);
|
|
382
382
|
w.current = f;
|
|
383
|
-
const [b,
|
|
384
|
-
const C = t._getWatch(n,
|
|
383
|
+
const [b, B] = R.useState(() => {
|
|
384
|
+
const C = t._getWatch(n, F.current);
|
|
385
385
|
return w.current ? w.current(C) : C;
|
|
386
|
-
}),
|
|
387
|
-
const k = We(n, t._names, C || t._formValues, !1,
|
|
386
|
+
}), O = R.useCallback((C) => {
|
|
387
|
+
const k = We(n, t._names, C || t._formValues, !1, F.current);
|
|
388
388
|
return w.current ? w.current(k) : k;
|
|
389
389
|
}, [t._formValues, t._names, n]), z = R.useCallback((C) => {
|
|
390
390
|
if (!i) {
|
|
391
|
-
const k = We(n, t._names, C || t._formValues, !1,
|
|
391
|
+
const k = We(n, t._names, C || t._formValues, !1, F.current);
|
|
392
392
|
if (w.current) {
|
|
393
|
-
const
|
|
394
|
-
|
|
393
|
+
const ee = w.current(k);
|
|
394
|
+
ae(ee, T.current) || (B(ee), T.current = ee);
|
|
395
395
|
} else
|
|
396
|
-
|
|
396
|
+
B(k);
|
|
397
397
|
}
|
|
398
398
|
}, [t._formValues, t._names, i, n]);
|
|
399
|
-
|
|
399
|
+
Ft(() => ((x.current !== t || !ae(p.current, n)) && (x.current = t, p.current = n, z()), t._subscribe({
|
|
400
400
|
name: n,
|
|
401
401
|
formState: {
|
|
402
402
|
values: !0
|
|
403
403
|
},
|
|
404
|
-
exact:
|
|
404
|
+
exact: u,
|
|
405
405
|
callback: (C) => {
|
|
406
406
|
z(C.values);
|
|
407
407
|
}
|
|
408
|
-
})), [t,
|
|
409
|
-
const
|
|
408
|
+
})), [t, u, n, z]), R.useEffect(() => t._removeUnmounted());
|
|
409
|
+
const $ = x.current !== t, E = p.current, G = R.useMemo(() => {
|
|
410
410
|
if (i)
|
|
411
411
|
return null;
|
|
412
|
-
const C =
|
|
413
|
-
return
|
|
414
|
-
}, [i,
|
|
415
|
-
return
|
|
412
|
+
const C = !$ && !ae(E, n);
|
|
413
|
+
return $ || C ? O() : null;
|
|
414
|
+
}, [i, $, n, E, O]);
|
|
415
|
+
return G !== null ? G : 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], ut = () => {
|
|
424
424
|
let e = [];
|
|
425
425
|
return {
|
|
426
426
|
get observers() {
|
|
@@ -440,19 +440,19 @@ var er = (e, r, t, n, o) => r ? {
|
|
|
440
440
|
}
|
|
441
441
|
};
|
|
442
442
|
};
|
|
443
|
-
function
|
|
443
|
+
function pt(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 u = pt(o, i);
|
|
450
|
+
q(u) && (t[n] = u);
|
|
451
451
|
} else e[n] && (t[n] = i);
|
|
452
452
|
}
|
|
453
453
|
return t;
|
|
454
454
|
}
|
|
455
|
-
var
|
|
455
|
+
var Z = (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;
|
|
@@ -462,44 +462,44 @@ 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 = M(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) && !M(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) && Z(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 (ne(e[r]))
|
|
481
481
|
return !0;
|
|
482
482
|
return !1;
|
|
483
483
|
};
|
|
484
|
-
function
|
|
484
|
+
function Rt(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
|
+
Rt(n) ? (r[t] = Array.isArray(n) ? [] : {}, qe(n, r[t])) : M(n) || (r[t] = !0);
|
|
491
491
|
}
|
|
492
492
|
return r;
|
|
493
493
|
}
|
|
494
|
-
function
|
|
494
|
+
function Fe(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 (Rt(o))
|
|
499
|
+
M(r) || Ye(t[n]) ? t[n] = qe(o, Array.isArray(o) ? [] : {}) : Fe(o, K(r) ? {} : r[n], t[n]);
|
|
500
500
|
else {
|
|
501
501
|
const i = r[n];
|
|
502
|
-
t[n] = !
|
|
502
|
+
t[n] = !ae(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 kt = (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 Rt = (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 && !M(e[0].attributes.value) ? M(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
|
+
}, St = (e, { valueAsNumber: r, valueAsDate: t, setValueAs: n }) => M(e) ? e : r ? e === "" ? NaN : e && +e : t && te(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 Tt = (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 Xe(r) ? r.files : Ze(r) ?
|
|
534
|
+
return Xe(r) ? r.files : Ze(r) ? Tt(e.refs).value : At(r) ? [...r.selectedOptions].map(({ value: t }) => t) : Te(r) ? kt(e.refs).value : St(M(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 u = h(r, i);
|
|
540
|
+
u && P(o, i, u._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) => M(e) ? e : Pe(e) ? e.source : q(e) ? Pe(e.value) ? e.value.source : e.value : e, mt = (e) => ({
|
|
549
|
+
isOnSubmit: !e || e === ie.onSubmit,
|
|
550
|
+
isOnBlur: e === ie.onBlur,
|
|
551
|
+
isOnChange: e === ie.onChange,
|
|
552
|
+
isOnAll: e === ie.all,
|
|
553
|
+
isOnTouch: e === ie.onTouched
|
|
554
554
|
});
|
|
555
555
|
const ht = "AsyncFunction";
|
|
556
|
-
var ar = (e) => !!e && !!e.validate && !!(
|
|
556
|
+
var ar = (e) => !!e && !!e.validate && !!(ne(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: u, ...f } = i;
|
|
562
|
+
if (u) {
|
|
563
|
+
if (u.refs && u.refs[0] && r(u.refs[0], o) && !n)
|
|
564
564
|
return !0;
|
|
565
|
-
if (
|
|
565
|
+
if (u.ref && r(u.ref, u.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("."), u = h(r, i), f = h(e, i);
|
|
584
|
+
if (u && !Array.isArray(u) && t !== i)
|
|
585
585
|
return { name: t };
|
|
586
586
|
if (f && f.type)
|
|
587
587
|
return {
|
|
@@ -599,19 +599,19 @@ function bt(e, r, t) {
|
|
|
599
599
|
name: t
|
|
600
600
|
};
|
|
601
601
|
}
|
|
602
|
-
var
|
|
602
|
+
var lr = (e, r, t, n) => {
|
|
603
603
|
t(e);
|
|
604
604
|
const { name: o, ...i } = e;
|
|
605
|
-
return
|
|
606
|
-
},
|
|
605
|
+
return Z(i) || Object.keys(i).length >= Object.keys(r).length || Object.keys(i).find((u) => r[u] === (!n || ie.all));
|
|
606
|
+
}, ur = (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
608
|
return P(n, "root", r[t]), P(e, t, n), e;
|
|
609
609
|
};
|
|
610
610
|
function gt(e, r, t = "validate") {
|
|
611
|
-
if (
|
|
611
|
+
if (te(e) || Array.isArray(e) && e.every(te) || le(e) && !e)
|
|
612
612
|
return {
|
|
613
613
|
type: t,
|
|
614
|
-
message:
|
|
614
|
+
message: te(e) ? e : "",
|
|
615
615
|
ref: r
|
|
616
616
|
};
|
|
617
617
|
}
|
|
@@ -619,79 +619,79 @@ 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: u, refs: f, required: F, maxLength: w, minLength: T, min: x, max: p, pattern: b, validate: B, name: O, valueAsNumber: z, mount: $ } = e._f, E = h(t, O);
|
|
623
|
+
if (!$ || r.has(O))
|
|
624
624
|
return {};
|
|
625
|
-
const
|
|
626
|
-
o &&
|
|
627
|
-
}, k = {},
|
|
628
|
-
const
|
|
629
|
-
k[
|
|
625
|
+
const G = f ? f[0] : u, C = (_) => {
|
|
626
|
+
o && G.reportValidity && (G.setCustomValidity(le(_) ? "" : _ || ""), G.reportValidity());
|
|
627
|
+
}, k = {}, ee = Ze(u), ce = Te(u), se = ee || ce, N = (z || Xe(u)) && M(u.value) && M(E) || je(u) && u.value === "" || E === "" || Array.isArray(E) && !E.length, J = er.bind(null, O, n, k), fe = (_, A, L, W = ue.maxLength, Q = ue.minLength) => {
|
|
628
|
+
const X = _ ? A : L;
|
|
629
|
+
k[O] = {
|
|
630
630
|
type: _ ? W : Q,
|
|
631
|
-
message:
|
|
632
|
-
ref:
|
|
633
|
-
...
|
|
631
|
+
message: X,
|
|
632
|
+
ref: u,
|
|
633
|
+
...J(_ ? W : Q, X)
|
|
634
634
|
};
|
|
635
635
|
};
|
|
636
|
-
if (i ? !Array.isArray(
|
|
637
|
-
const { value: _, message:
|
|
638
|
-
if (_ && (k[
|
|
639
|
-
type:
|
|
640
|
-
message:
|
|
641
|
-
ref:
|
|
642
|
-
...
|
|
636
|
+
if (i ? !Array.isArray(E) || !E.length : F && (!se && (N || K(E)) || le(E) && !E || ce && !kt(f).isValid || ee && !Tt(f).isValid)) {
|
|
637
|
+
const { value: _, message: A } = te(F) ? { value: !!F, message: F } : Ve(F);
|
|
638
|
+
if (_ && (k[O] = {
|
|
639
|
+
type: ue.required,
|
|
640
|
+
message: A,
|
|
641
|
+
ref: G,
|
|
642
|
+
...J(ue.required, A)
|
|
643
643
|
}, !n))
|
|
644
|
-
return C(
|
|
644
|
+
return C(A), k;
|
|
645
645
|
}
|
|
646
|
-
if (!
|
|
647
|
-
let _,
|
|
648
|
-
const
|
|
649
|
-
if (!K(
|
|
650
|
-
const Q =
|
|
651
|
-
K(
|
|
646
|
+
if (!N && (!K(x) || !K(p))) {
|
|
647
|
+
let _, A;
|
|
648
|
+
const L = Ve(p), W = Ve(x);
|
|
649
|
+
if (!K(E) && !isNaN(E)) {
|
|
650
|
+
const Q = u.valueAsNumber || E && +E;
|
|
651
|
+
K(L.value) || (_ = Q > L.value), K(W.value) || (A = Q < W.value);
|
|
652
652
|
} else {
|
|
653
|
-
const Q =
|
|
654
|
-
|
|
653
|
+
const Q = u.valueAsDate || new Date(E), X = (me) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + me), de = u.type == "time", ye = u.type == "week";
|
|
654
|
+
te(L.value) && E && (_ = de ? X(E) > X(L.value) : ye ? E > L.value : Q > new Date(L.value)), te(W.value) && E && (A = de ? X(E) < X(W.value) : ye ? E < W.value : Q < new Date(W.value));
|
|
655
655
|
}
|
|
656
|
-
if ((_ ||
|
|
657
|
-
return C(k[
|
|
656
|
+
if ((_ || A) && (fe(!!_, L.message, W.message, ue.max, ue.min), !n))
|
|
657
|
+
return C(k[O].message), k;
|
|
658
658
|
}
|
|
659
|
-
if ((w || T) && !
|
|
660
|
-
const _ = Ve(w),
|
|
661
|
-
if ((
|
|
662
|
-
return C(k[
|
|
659
|
+
if ((w || T) && !N && (te(E) || i && Array.isArray(E))) {
|
|
660
|
+
const _ = Ve(w), A = Ve(T), L = !K(_.value) && E.length > +_.value, W = !K(A.value) && E.length < +A.value;
|
|
661
|
+
if ((L || W) && (fe(L, _.message, A.message), !n))
|
|
662
|
+
return C(k[O].message), k;
|
|
663
663
|
}
|
|
664
|
-
if (b && !
|
|
665
|
-
const { value: _, message:
|
|
666
|
-
if (Pe(_) && !
|
|
667
|
-
type:
|
|
668
|
-
message:
|
|
669
|
-
ref:
|
|
670
|
-
...
|
|
664
|
+
if (b && !N && te(E)) {
|
|
665
|
+
const { value: _, message: A } = Ve(b);
|
|
666
|
+
if (Pe(_) && !E.match(_) && (k[O] = {
|
|
667
|
+
type: ue.pattern,
|
|
668
|
+
message: A,
|
|
669
|
+
ref: u,
|
|
670
|
+
...J(ue.pattern, A)
|
|
671
671
|
}, !n))
|
|
672
|
-
return C(
|
|
672
|
+
return C(A), k;
|
|
673
673
|
}
|
|
674
|
-
if (
|
|
675
|
-
if (
|
|
676
|
-
const _ = await
|
|
677
|
-
if (
|
|
678
|
-
...
|
|
679
|
-
...
|
|
674
|
+
if (B) {
|
|
675
|
+
if (ne(B)) {
|
|
676
|
+
const _ = await B(E, t), A = gt(_, G);
|
|
677
|
+
if (A && (k[O] = {
|
|
678
|
+
...A,
|
|
679
|
+
...J(ue.validate, A.message)
|
|
680
680
|
}, !n))
|
|
681
|
-
return C(
|
|
682
|
-
} else if (q(
|
|
681
|
+
return C(A.message), k;
|
|
682
|
+
} else if (q(B)) {
|
|
683
683
|
let _ = {};
|
|
684
|
-
for (const
|
|
685
|
-
if (!
|
|
684
|
+
for (const A in B) {
|
|
685
|
+
if (!Z(_) && !n)
|
|
686
686
|
break;
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
...
|
|
690
|
-
...
|
|
691
|
-
}, C(
|
|
687
|
+
const L = gt(await B[A](E, t), G, A);
|
|
688
|
+
L && (_ = {
|
|
689
|
+
...L,
|
|
690
|
+
...J(A, L.message)
|
|
691
|
+
}, C(L.message), n && (k[O] = _));
|
|
692
692
|
}
|
|
693
|
-
if (!
|
|
694
|
-
ref:
|
|
693
|
+
if (!Z(_) && (k[O] = {
|
|
694
|
+
ref: G,
|
|
695
695
|
..._
|
|
696
696
|
}, !n))
|
|
697
697
|
return k;
|
|
@@ -700,8 +700,8 @@ var Ve = (e) => q(e) && !Pe(e) ? e : {
|
|
|
700
700
|
return C(!0), k;
|
|
701
701
|
};
|
|
702
702
|
const yr = {
|
|
703
|
-
mode:
|
|
704
|
-
reValidateMode:
|
|
703
|
+
mode: ie.onSubmit,
|
|
704
|
+
reValidateMode: ie.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: ne(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) ? H(r.defaultValues || r.values) || {} : {}, i = r.shouldUnregister ? {} : H(o),
|
|
726
|
+
}, n = {}, o = q(r.defaultValues) || q(r.values) ? H(r.defaultValues || r.values) || {} : {}, i = r.shouldUnregister ? {} : H(o), u = {
|
|
727
727
|
action: !1,
|
|
728
728
|
mount: !1,
|
|
729
729
|
watch: !1,
|
|
@@ -734,7 +734,7 @@ function mr(e = {}) {
|
|
|
734
734
|
unMount: /* @__PURE__ */ new Set(),
|
|
735
735
|
array: /* @__PURE__ */ new Set(),
|
|
736
736
|
watch: /* @__PURE__ */ new Set()
|
|
737
|
-
},
|
|
737
|
+
}, F, w = 0;
|
|
738
738
|
const T = {
|
|
739
739
|
isDirty: !1,
|
|
740
740
|
dirtyFields: !1,
|
|
@@ -746,43 +746,43 @@ function mr(e = {}) {
|
|
|
746
746
|
}, x = {
|
|
747
747
|
...T
|
|
748
748
|
};
|
|
749
|
-
let
|
|
749
|
+
let p = {
|
|
750
750
|
...x
|
|
751
751
|
};
|
|
752
752
|
const b = {
|
|
753
|
-
array:
|
|
754
|
-
state:
|
|
755
|
-
},
|
|
753
|
+
array: ut(),
|
|
754
|
+
state: ut()
|
|
755
|
+
}, B = r.criteriaMode === ie.all, O = (s) => (a) => {
|
|
756
756
|
clearTimeout(w), w = setTimeout(s, a);
|
|
757
757
|
}, z = async (s) => {
|
|
758
|
-
if (!
|
|
758
|
+
if (!u.keepIsValid && !r.disabled && (x.isValid || p.isValid || s)) {
|
|
759
759
|
let a;
|
|
760
|
-
r.resolver ? (a =
|
|
760
|
+
r.resolver ? (a = Z((await se()).errors), $()) : a = await J(n, !0), a !== t.isValid && b.state.next({
|
|
761
761
|
isValid: a
|
|
762
762
|
});
|
|
763
763
|
}
|
|
764
|
-
},
|
|
765
|
-
!r.disabled && (x.isValidating || x.validatingFields ||
|
|
766
|
-
|
|
764
|
+
}, $ = (s, a) => {
|
|
765
|
+
!r.disabled && (x.isValidating || x.validatingFields || p.isValidating || p.validatingFields) && ((s || Array.from(f.mount)).forEach((l) => {
|
|
766
|
+
l && (a ? P(t.validatingFields, l, a) : Y(t.validatingFields, l));
|
|
767
767
|
}), b.state.next({
|
|
768
768
|
validatingFields: t.validatingFields,
|
|
769
|
-
isValidating: !
|
|
769
|
+
isValidating: !Z(t.validatingFields)
|
|
770
770
|
}));
|
|
771
|
-
},
|
|
772
|
-
if (m &&
|
|
773
|
-
if (
|
|
774
|
-
const v =
|
|
771
|
+
}, E = (s, a = [], l, m, y = !0, d = !0) => {
|
|
772
|
+
if (m && l && !r.disabled) {
|
|
773
|
+
if (u.action = !0, d && Array.isArray(h(n, s))) {
|
|
774
|
+
const v = l(h(n, s), m.argA, m.argB);
|
|
775
775
|
y && P(n, s, v);
|
|
776
776
|
}
|
|
777
777
|
if (d && Array.isArray(h(t.errors, s))) {
|
|
778
|
-
const v =
|
|
778
|
+
const v = l(h(t.errors, s), m.argA, m.argB);
|
|
779
779
|
y && P(t.errors, s, v), fr(t.errors, s);
|
|
780
780
|
}
|
|
781
|
-
if ((x.touchedFields ||
|
|
782
|
-
const v =
|
|
781
|
+
if ((x.touchedFields || p.touchedFields) && d && Array.isArray(h(t.touchedFields, s))) {
|
|
782
|
+
const v = l(h(t.touchedFields, s), m.argA, m.argB);
|
|
783
783
|
y && P(t.touchedFields, s, v);
|
|
784
784
|
}
|
|
785
|
-
(x.dirtyFields ||
|
|
785
|
+
(x.dirtyFields || p.dirtyFields) && (t.dirtyFields = Fe(o, i)), b.state.next({
|
|
786
786
|
name: s,
|
|
787
787
|
isDirty: _(s, a),
|
|
788
788
|
dirtyFields: t.dirtyFields,
|
|
@@ -791,7 +791,7 @@ function mr(e = {}) {
|
|
|
791
791
|
});
|
|
792
792
|
} else
|
|
793
793
|
P(i, s, a);
|
|
794
|
-
},
|
|
794
|
+
}, G = (s, a) => {
|
|
795
795
|
P(t.errors, s, a), b.state.next({
|
|
796
796
|
errors: t.errors
|
|
797
797
|
});
|
|
@@ -800,36 +800,36 @@ function mr(e = {}) {
|
|
|
800
800
|
errors: t.errors,
|
|
801
801
|
isValid: !1
|
|
802
802
|
});
|
|
803
|
-
}, k = (s, a,
|
|
803
|
+
}, k = (s, a, l, 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, M(l) ? h(o, s) : l);
|
|
807
|
+
M(d) || m && m.defaultChecked || a ? P(i, s, a ? d : yt(y._f)) : W(s, d), u.mount && !u.action && z();
|
|
808
808
|
}
|
|
809
|
-
},
|
|
809
|
+
}, ee = (s, a, l, m, y) => {
|
|
810
810
|
let d = !1, v = !1;
|
|
811
811
|
const S = {
|
|
812
812
|
name: s
|
|
813
813
|
};
|
|
814
814
|
if (!r.disabled) {
|
|
815
|
-
if (!
|
|
816
|
-
(x.isDirty ||
|
|
817
|
-
const D =
|
|
818
|
-
v = !!h(t.dirtyFields, s), D ? Y(t.dirtyFields, s) : P(t.dirtyFields, s, !0), S.dirtyFields = t.dirtyFields, d = d || (x.dirtyFields ||
|
|
815
|
+
if (!l || m) {
|
|
816
|
+
(x.isDirty || p.isDirty) && (v = t.isDirty, t.isDirty = S.isDirty = _(), d = v !== S.isDirty);
|
|
817
|
+
const D = ae(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 || p.dirtyFields) && v !== !D;
|
|
819
819
|
}
|
|
820
|
-
if (
|
|
820
|
+
if (l) {
|
|
821
821
|
const D = h(t.touchedFields, s);
|
|
822
|
-
D || (P(t.touchedFields, s,
|
|
822
|
+
D || (P(t.touchedFields, s, l), S.touchedFields = t.touchedFields, d = d || (x.touchedFields || p.touchedFields) && D !== l);
|
|
823
823
|
}
|
|
824
824
|
d && y && b.state.next(S);
|
|
825
825
|
}
|
|
826
826
|
return d ? S : {};
|
|
827
|
-
},
|
|
828
|
-
const y = h(t.errors, s), d = (x.isValid ||
|
|
829
|
-
if (r.delayError &&
|
|
827
|
+
}, ce = (s, a, l, m) => {
|
|
828
|
+
const y = h(t.errors, s), d = (x.isValid || p.isValid) && le(a) && t.isValid !== a;
|
|
829
|
+
if (r.delayError && l ? (F = O(() => G(s, l)), F(r.delayError)) : (clearTimeout(w), F = null, l ? P(t.errors, s, l) : Y(t.errors, s)), (l ? !ae(y, l) : y) || !Z(m) || d) {
|
|
830
830
|
const v = {
|
|
831
831
|
...m,
|
|
832
|
-
...d &&
|
|
832
|
+
...d && le(a) ? { isValid: a } : {},
|
|
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
|
-
},
|
|
842
|
-
const { errors: a } = await
|
|
843
|
-
if (
|
|
844
|
-
for (const
|
|
845
|
-
const m = h(a,
|
|
846
|
-
m ? P(t.errors,
|
|
841
|
+
}, se = async (s) => ($(s, !0), await r.resolver(i, r.context, ir(s || f.mount, n, r.criteriaMode, r.shouldUseNativeValidation))), N = async (s) => {
|
|
842
|
+
const { errors: a } = await se(s);
|
|
843
|
+
if ($(s), s)
|
|
844
|
+
for (const l of s) {
|
|
845
|
+
const m = h(a, l);
|
|
846
|
+
m ? P(t.errors, l, m) : Y(t.errors, l);
|
|
847
847
|
}
|
|
848
848
|
else
|
|
849
849
|
t.errors = a;
|
|
850
850
|
return a;
|
|
851
|
-
},
|
|
851
|
+
}, J = async (s, a, l = {
|
|
852
852
|
valid: !0
|
|
853
853
|
}) => {
|
|
854
854
|
for (const m in s) {
|
|
@@ -857,108 +857,108 @@ function mr(e = {}) {
|
|
|
857
857
|
const { _f: d, ...v } = y;
|
|
858
858
|
if (d) {
|
|
859
859
|
const S = f.array.has(d.name), D = y._f && ar(y._f);
|
|
860
|
-
D && x.validatingFields &&
|
|
861
|
-
const
|
|
862
|
-
if (D && x.validatingFields &&
|
|
860
|
+
D && x.validatingFields && $([d.name], !0);
|
|
861
|
+
const re = await _t(y, f.disabled, i, B, r.shouldUseNativeValidation && !a, S);
|
|
862
|
+
if (D && x.validatingFields && $([d.name]), re[d.name] && (l.valid = !1, a))
|
|
863
863
|
break;
|
|
864
|
-
!a && (h(
|
|
864
|
+
!a && (h(re, d.name) ? S ? dr(t.errors, re, d.name) : P(t.errors, d.name, re[d.name]) : Y(t.errors, d.name));
|
|
865
865
|
}
|
|
866
|
-
!
|
|
866
|
+
!Z(v) && await J(v, a, l);
|
|
867
867
|
}
|
|
868
868
|
}
|
|
869
|
-
return
|
|
870
|
-
},
|
|
869
|
+
return l.valid;
|
|
870
|
+
}, fe = () => {
|
|
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((l) => !$e(l)) : !$e(a._f.ref)) && oe(s);
|
|
874
874
|
}
|
|
875
875
|
f.unMount = /* @__PURE__ */ new Set();
|
|
876
|
-
}, _ = (s, a) => !r.disabled && (s && a && P(i, s, a), !
|
|
877
|
-
...
|
|
878
|
-
},
|
|
876
|
+
}, _ = (s, a) => !r.disabled && (s && a && P(i, s, a), !ae(c(), o)), A = (s, a, l) => We(s, f, {
|
|
877
|
+
...u.mount ? i : M(a) ? o : te(s) ? { [s]: a } : a
|
|
878
|
+
}, l, a), L = (s) => He(h(u.mount ? i : o, s, r.shouldUnregister ? h(o, s, []) : [])), W = (s, a, l = {}) => {
|
|
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 && P(i, s,
|
|
883
|
+
d && (!d.disabled && P(i, s, St(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
884
|
(!v.defaultChecked || !v.disabled) && (Array.isArray(y) ? v.checked = !!y.find((S) => S === v.value) : v.checked = y === v.value || !!y);
|
|
885
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
887
|
values: H(i)
|
|
888
888
|
})));
|
|
889
889
|
}
|
|
890
|
-
(
|
|
891
|
-
}, Q = (s, a,
|
|
890
|
+
(l.shouldDirty || l.shouldTouch) && ee(s, y, l.shouldTouch, l.shouldDirty, !0), l.shouldValidate && me(s);
|
|
891
|
+
}, Q = (s, a, l) => {
|
|
892
892
|
for (const m in a) {
|
|
893
893
|
if (!a.hasOwnProperty(m))
|
|
894
894
|
return;
|
|
895
895
|
const y = a[m], d = s + "." + m, v = h(n, d);
|
|
896
|
-
(f.array.has(s) || q(y) || v && !v._f) && !
|
|
896
|
+
(f.array.has(s) || q(y) || v && !v._f) && !be(y) ? Q(d, y, l) : W(d, y, l);
|
|
897
897
|
}
|
|
898
|
-
},
|
|
898
|
+
}, X = (s, a, l = {}) => {
|
|
899
899
|
const m = h(n, s), y = f.array.has(s), d = H(a);
|
|
900
900
|
P(i, s, d), y ? (b.array.next({
|
|
901
901
|
name: s,
|
|
902
902
|
values: H(i)
|
|
903
|
-
}), (x.isDirty || x.dirtyFields ||
|
|
903
|
+
}), (x.isDirty || x.dirtyFields || p.isDirty || p.dirtyFields) && l.shouldDirty && b.state.next({
|
|
904
904
|
name: s,
|
|
905
|
-
dirtyFields:
|
|
905
|
+
dirtyFields: Fe(o, i),
|
|
906
906
|
isDirty: _(s, d)
|
|
907
|
-
})) : m && !m._f && !K(d) ? Q(s, d,
|
|
908
|
-
name:
|
|
907
|
+
})) : m && !m._f && !K(d) ? Q(s, d, l) : W(s, d, l), vt(s, f) && b.state.next({ ...t, name: s }), b.state.next({
|
|
908
|
+
name: u.mount ? s : void 0,
|
|
909
909
|
values: H(i)
|
|
910
910
|
});
|
|
911
|
-
},
|
|
912
|
-
|
|
911
|
+
}, de = async (s) => {
|
|
912
|
+
u.mount = !0;
|
|
913
913
|
const a = s.target;
|
|
914
|
-
let
|
|
915
|
-
const y = h(n,
|
|
916
|
-
m = Number.isNaN(D) ||
|
|
914
|
+
let l = a.name, m = !0;
|
|
915
|
+
const y = h(n, l), d = (D) => {
|
|
916
|
+
m = Number.isNaN(D) || be(D) && isNaN(D.getTime()) || ae(D, h(i, l, D));
|
|
917
917
|
}, v = mt(r.mode), S = mt(r.reValidateMode);
|
|
918
918
|
if (y) {
|
|
919
|
-
let D,
|
|
920
|
-
const Oe = a.type ? yt(y._f) : Jt(s),
|
|
921
|
-
P(i,
|
|
922
|
-
const Be =
|
|
923
|
-
if (!
|
|
924
|
-
name:
|
|
919
|
+
let D, re;
|
|
920
|
+
const Oe = a.type ? yt(y._f) : Jt(s), he = s.type === lt.BLUR || s.type === lt.FOCUS_OUT, Ut = !or(y._f) && !r.resolver && !h(t.errors, l) && !y._f.deps || cr(he, h(t.touchedFields, l), t.isSubmitted, S, v), Me = vt(l, f, he);
|
|
921
|
+
P(i, l, Oe), he ? (!a || !a.readOnly) && (y._f.onBlur && y._f.onBlur(s), F && F(0)) : y._f.onChange && y._f.onChange(s);
|
|
922
|
+
const Be = ee(l, Oe, he), Mt = !Z(Be) || Me;
|
|
923
|
+
if (!he && b.state.next({
|
|
924
|
+
name: l,
|
|
925
925
|
type: s.type,
|
|
926
926
|
values: H(i)
|
|
927
|
-
}),
|
|
928
|
-
return (x.isValid ||
|
|
929
|
-
if (!
|
|
930
|
-
const { errors: st } = await
|
|
931
|
-
if (
|
|
932
|
-
const
|
|
933
|
-
D = nt.error,
|
|
927
|
+
}), Ut)
|
|
928
|
+
return (x.isValid || p.isValid) && (r.mode === "onBlur" ? he && z() : he || z()), Mt && b.state.next({ name: l, ...Me ? {} : Be });
|
|
929
|
+
if (!he && Me && b.state.next({ ...t }), r.resolver) {
|
|
930
|
+
const { errors: st } = await se([l]);
|
|
931
|
+
if ($([l]), d(Oe), m) {
|
|
932
|
+
const Bt = bt(t.errors, n, l), nt = bt(st, n, Bt.name || l);
|
|
933
|
+
D = nt.error, l = nt.name, re = Z(st);
|
|
934
934
|
}
|
|
935
935
|
} else
|
|
936
|
-
|
|
937
|
-
m && (y._f.deps && (!Array.isArray(y._f.deps) || y._f.deps.length > 0) &&
|
|
936
|
+
$([l], !0), D = (await _t(y, f.disabled, i, B, r.shouldUseNativeValidation))[l], $([l]), d(Oe), m && (D ? re = !1 : (x.isValid || p.isValid) && (re = await J(n, !0)));
|
|
937
|
+
m && (y._f.deps && (!Array.isArray(y._f.deps) || y._f.deps.length > 0) && me(y._f.deps), ce(l, re, D, Be));
|
|
938
938
|
}
|
|
939
|
-
},
|
|
939
|
+
}, ye = (s, a) => {
|
|
940
940
|
if (h(t.errors, a) && s.focus)
|
|
941
941
|
return s.focus(), 1;
|
|
942
|
-
},
|
|
943
|
-
let
|
|
942
|
+
}, me = async (s, a = {}) => {
|
|
943
|
+
let l, m;
|
|
944
944
|
const y = ke(s);
|
|
945
945
|
if (r.resolver) {
|
|
946
|
-
const d = await
|
|
947
|
-
|
|
946
|
+
const d = await N(M(s) ? s : y);
|
|
947
|
+
l = Z(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
|
-
return await
|
|
951
|
-
}))).every(Boolean), !(!m && !t.isValid) && z()) : m =
|
|
950
|
+
return await J(v && v._f ? { [d]: v } : v);
|
|
951
|
+
}))).every(Boolean), !(!m && !t.isValid) && z()) : m = l = await J(n);
|
|
952
952
|
return b.state.next({
|
|
953
|
-
...!
|
|
954
|
-
...r.resolver || !s ? { isValid:
|
|
953
|
+
...!te(s) || (x.isValid || p.isValid) && l !== t.isValid ? {} : { name: s },
|
|
954
|
+
...r.resolver || !s ? { isValid: l } : {},
|
|
955
955
|
errors: t.errors
|
|
956
|
-
}), a.shouldFocus && !m && Se(n,
|
|
956
|
+
}), a.shouldFocus && !m && Se(n, ye, s ? y : f.mount), m;
|
|
957
957
|
}, c = (s, a) => {
|
|
958
|
-
let
|
|
959
|
-
...
|
|
958
|
+
let l = {
|
|
959
|
+
...u.mount ? i : o
|
|
960
960
|
};
|
|
961
|
-
return a && (
|
|
961
|
+
return a && (l = pt(a.dirtyFields ? t.dirtyFields : t.touchedFields, l)), M(s) ? l : te(s) ? h(l, s) : s.map((m) => h(l, m));
|
|
962
962
|
}, g = (s, a) => ({
|
|
963
963
|
invalid: !!h((a || t).errors, s),
|
|
964
964
|
isDirty: !!h((a || t).dirtyFields, s),
|
|
@@ -969,7 +969,7 @@ function mr(e = {}) {
|
|
|
969
969
|
s && ke(s).forEach((a) => Y(t.errors, a)), b.state.next({
|
|
970
970
|
errors: s ? t.errors : {}
|
|
971
971
|
});
|
|
972
|
-
}, I = (s, a,
|
|
972
|
+
}, I = (s, a, l) => {
|
|
973
973
|
const m = (h(n, s, { _f: {} })._f || {}).ref, y = h(t.errors, s) || {}, { ref: d, message: v, type: S, ...D } = y;
|
|
974
974
|
P(t.errors, s, {
|
|
975
975
|
...D,
|
|
@@ -979,20 +979,20 @@ function mr(e = {}) {
|
|
|
979
979
|
name: s,
|
|
980
980
|
errors: t.errors,
|
|
981
981
|
isValid: !1
|
|
982
|
-
}),
|
|
983
|
-
}, _e = (s, a) =>
|
|
984
|
-
next: (
|
|
985
|
-
}) :
|
|
982
|
+
}), l && l.shouldFocus && m && m.focus && m.focus();
|
|
983
|
+
}, _e = (s, a) => ne(s) ? b.state.subscribe({
|
|
984
|
+
next: (l) => "values" in l && s(A(void 0, a), l)
|
|
985
|
+
}) : A(s, a, !0), xe = (s) => b.state.subscribe({
|
|
986
986
|
next: (a) => {
|
|
987
|
-
|
|
987
|
+
ur(s.name, a.name, s.exact) && lr(a, s.formState || x, Lt, 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, U = (s) => (u.mount = !0, p = {
|
|
995
|
+
...p,
|
|
996
996
|
...s.formState
|
|
997
997
|
}, xe({
|
|
998
998
|
...s,
|
|
@@ -1001,8 +1001,8 @@ function mr(e = {}) {
|
|
|
1001
1001
|
...s.formState
|
|
1002
1002
|
}
|
|
1003
1003
|
})), oe = (s, a = {}) => {
|
|
1004
|
-
for (const
|
|
1005
|
-
f.mount.delete(
|
|
1004
|
+
for (const l of s ? ke(s) : f.mount)
|
|
1005
|
+
f.mount.delete(l), f.array.delete(l), a.keepValue || (Y(n, l), Y(i, l)), !a.keepError && Y(t.errors, l), !a.keepDirty && Y(t.dirtyFields, l), !a.keepTouched && Y(t.touchedFields, l), !a.keepIsValidating && Y(t.validatingFields, l), !r.shouldUnregister && !a.keepDefaultValue && Y(o, l);
|
|
1006
1006
|
b.state.next({
|
|
1007
1007
|
values: H(i)
|
|
1008
1008
|
}), b.state.next({
|
|
@@ -1010,20 +1010,20 @@ function mr(e = {}) {
|
|
|
1010
1010
|
...a.keepDirty ? { isDirty: _() } : {}
|
|
1011
1011
|
}), !a.keepIsValid && z();
|
|
1012
1012
|
}, Ee = ({ disabled: s, name: a }) => {
|
|
1013
|
-
(
|
|
1014
|
-
},
|
|
1015
|
-
let
|
|
1016
|
-
const m =
|
|
1013
|
+
(le(s) && u.mount || s || f.disabled.has(a)) && (s ? f.disabled.add(a) : f.disabled.delete(a));
|
|
1014
|
+
}, we = (s, a = {}) => {
|
|
1015
|
+
let l = h(n, s);
|
|
1016
|
+
const m = le(a.disabled) || le(r.disabled);
|
|
1017
1017
|
return P(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
|
...a
|
|
1024
1024
|
}
|
|
1025
|
-
}), f.mount.add(s),
|
|
1026
|
-
disabled:
|
|
1025
|
+
}), f.mount.add(s), l ? Ee({
|
|
1026
|
+
disabled: le(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 } : {},
|
|
@@ -1036,17 +1036,17 @@ function mr(e = {}) {
|
|
|
1036
1036
|
pattern: Re(a.pattern)
|
|
1037
1037
|
} : {},
|
|
1038
1038
|
name: s,
|
|
1039
|
-
onChange:
|
|
1040
|
-
onBlur:
|
|
1039
|
+
onChange: de,
|
|
1040
|
+
onBlur: de,
|
|
1041
1041
|
ref: (y) => {
|
|
1042
1042
|
if (y) {
|
|
1043
|
-
|
|
1044
|
-
const d =
|
|
1045
|
-
if (v ? S.find((D) => D === d) : d ===
|
|
1043
|
+
we(s, a), l = h(n, s);
|
|
1044
|
+
const d = M(y.value) && y.querySelectorAll && y.querySelectorAll("input,select,textarea")[0] || y, v = tr(d), S = l._f.refs || [];
|
|
1045
|
+
if (v ? S.find((D) => D === d) : d === l._f.ref)
|
|
1046
1046
|
return;
|
|
1047
1047
|
P(n, s, {
|
|
1048
1048
|
_f: {
|
|
1049
|
-
...
|
|
1049
|
+
...l._f,
|
|
1050
1050
|
...v ? {
|
|
1051
1051
|
refs: [
|
|
1052
1052
|
...S.filter($e),
|
|
@@ -1058,71 +1058,71 @@ function mr(e = {}) {
|
|
|
1058
1058
|
}
|
|
1059
1059
|
}), k(s, !1, void 0, d);
|
|
1060
1060
|
} else
|
|
1061
|
-
|
|
1061
|
+
l = h(n, s, {}), l._f && (l._f.mount = !1), (r.shouldUnregister || a.shouldUnregister) && !(Xt(f.array, s) && u.action) && f.unMount.add(s);
|
|
1062
1062
|
}
|
|
1063
1063
|
};
|
|
1064
|
-
}, Ue = () => r.shouldFocusError && Se(n,
|
|
1065
|
-
|
|
1066
|
-
const m = h(n,
|
|
1064
|
+
}, Ue = () => r.shouldFocusError && Se(n, ye, f.mount), Pt = (s) => {
|
|
1065
|
+
le(s) && (b.state.next({ disabled: s }), Se(n, (a, l) => {
|
|
1066
|
+
const m = h(n, l);
|
|
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 (l) => {
|
|
1072
1072
|
let m;
|
|
1073
|
-
|
|
1073
|
+
l && (l.preventDefault && l.preventDefault(), l.persist && l.persist());
|
|
1074
1074
|
let y = H(i);
|
|
1075
1075
|
if (b.state.next({
|
|
1076
1076
|
isSubmitting: !0
|
|
1077
1077
|
}), r.resolver) {
|
|
1078
|
-
const { errors: d, values: v } = await
|
|
1079
|
-
|
|
1078
|
+
const { errors: d, values: v } = await se();
|
|
1079
|
+
$(), t.errors = d, y = H(v);
|
|
1080
1080
|
} else
|
|
1081
|
-
await
|
|
1081
|
+
await J(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"),
|
|
1085
|
+
if (Y(t.errors, "root"), Z(t.errors)) {
|
|
1086
1086
|
b.state.next({
|
|
1087
1087
|
errors: {}
|
|
1088
1088
|
});
|
|
1089
1089
|
try {
|
|
1090
|
-
await s(y,
|
|
1090
|
+
await s(y, l);
|
|
1091
1091
|
} catch (d) {
|
|
1092
1092
|
m = d;
|
|
1093
1093
|
}
|
|
1094
1094
|
} else
|
|
1095
|
-
a && await a({ ...t.errors },
|
|
1095
|
+
a && await a({ ...t.errors }, l), Ue(), setTimeout(Ue);
|
|
1096
1096
|
if (b.state.next({
|
|
1097
1097
|
isSubmitted: !0,
|
|
1098
1098
|
isSubmitting: !1,
|
|
1099
|
-
isSubmitSuccessful:
|
|
1099
|
+
isSubmitSuccessful: Z(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
|
+
}, Nt = (s, a = {}) => {
|
|
1105
|
+
h(n, s) && (M(a.defaultValue) ? X(s, H(h(o, s))) : (X(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 l = s ? H(s) : o, m = H(l), y = Z(s), d = y ? o : m;
|
|
1108
|
+
if (a.keepDefaultValues || (o = l), !a.keepValues) {
|
|
1109
1109
|
if (a.keepDirtyValues) {
|
|
1110
1110
|
const v = /* @__PURE__ */ new Set([
|
|
1111
1111
|
...f.mount,
|
|
1112
|
-
...Object.keys(
|
|
1112
|
+
...Object.keys(Fe(o, i))
|
|
1113
1113
|
]);
|
|
1114
1114
|
for (const S of Array.from(v))
|
|
1115
|
-
h(t.dirtyFields, S) ? P(d, S, h(i, S)) :
|
|
1115
|
+
h(t.dirtyFields, S) ? P(d, S, h(i, S)) : X(S, h(d, S));
|
|
1116
1116
|
} else {
|
|
1117
|
-
if (ze &&
|
|
1117
|
+
if (ze && M(s))
|
|
1118
1118
|
for (const v of f.mount) {
|
|
1119
1119
|
const S = h(n, v);
|
|
1120
1120
|
if (S && S._f) {
|
|
1121
1121
|
const D = Array.isArray(S._f.refs) ? S._f.refs[0] : S._f.ref;
|
|
1122
1122
|
if (je(D)) {
|
|
1123
|
-
const
|
|
1124
|
-
if (
|
|
1125
|
-
|
|
1123
|
+
const re = D.closest("form");
|
|
1124
|
+
if (re) {
|
|
1125
|
+
re.reset();
|
|
1126
1126
|
break;
|
|
1127
1127
|
}
|
|
1128
1128
|
}
|
|
@@ -1130,7 +1130,7 @@ function mr(e = {}) {
|
|
|
1130
1130
|
}
|
|
1131
1131
|
if (a.keepFieldsRef)
|
|
1132
1132
|
for (const v of f.mount)
|
|
1133
|
-
|
|
1133
|
+
X(v, h(d, v));
|
|
1134
1134
|
else
|
|
1135
1135
|
n = {};
|
|
1136
1136
|
}
|
|
@@ -1148,56 +1148,56 @@ function mr(e = {}) {
|
|
|
1148
1148
|
watch: /* @__PURE__ */ new Set(),
|
|
1149
1149
|
watchAll: !1,
|
|
1150
1150
|
focus: ""
|
|
1151
|
-
},
|
|
1151
|
+
}, u.mount = !x.isValid || !!a.keepIsValid || !!a.keepDirtyValues || !r.shouldUnregister && !Z(d), u.watch = !!r.shouldUnregister, u.keepIsValid = !!a.keepIsValid, u.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 && !ae(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 ? Fe(o, i) : t.dirtyFields : a.keepDefaultValues && s ? Fe(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(ne(s) ? s(i) : s, { ...r.resetOptions, ...a }), It = (s, a = {}) => {
|
|
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(), a.shouldSelect &&
|
|
1167
|
+
y.focus(), a.shouldSelect && ne(y.select) && y.select();
|
|
1168
1168
|
});
|
|
1169
1169
|
}
|
|
1170
|
-
},
|
|
1170
|
+
}, Lt = (s) => {
|
|
1171
1171
|
t = {
|
|
1172
1172
|
...t,
|
|
1173
1173
|
...s
|
|
1174
1174
|
};
|
|
1175
1175
|
}, rt = {
|
|
1176
1176
|
control: {
|
|
1177
|
-
register:
|
|
1177
|
+
register: we,
|
|
1178
1178
|
unregister: oe,
|
|
1179
1179
|
getFieldState: g,
|
|
1180
1180
|
handleSubmit: Ke,
|
|
1181
1181
|
setError: I,
|
|
1182
1182
|
_subscribe: xe,
|
|
1183
|
-
_runSchema:
|
|
1184
|
-
_updateIsValidating:
|
|
1183
|
+
_runSchema: se,
|
|
1184
|
+
_updateIsValidating: $,
|
|
1185
1185
|
_focusError: Ue,
|
|
1186
|
-
_getWatch:
|
|
1186
|
+
_getWatch: A,
|
|
1187
1187
|
_getDirty: _,
|
|
1188
1188
|
_setValid: z,
|
|
1189
|
-
_setFieldArray:
|
|
1189
|
+
_setFieldArray: E,
|
|
1190
1190
|
_setDisabledField: Ee,
|
|
1191
1191
|
_setErrors: C,
|
|
1192
|
-
_getFieldArray:
|
|
1192
|
+
_getFieldArray: L,
|
|
1193
1193
|
_reset: et,
|
|
1194
|
-
_resetDefaultValues: () =>
|
|
1194
|
+
_resetDefaultValues: () => ne(r.defaultValues) && r.defaultValues().then((s) => {
|
|
1195
1195
|
tt(s, r.resetOptions), b.state.next({
|
|
1196
1196
|
isLoading: !1
|
|
1197
1197
|
});
|
|
1198
1198
|
}),
|
|
1199
|
-
_removeUnmounted:
|
|
1200
|
-
_disableForm:
|
|
1199
|
+
_removeUnmounted: fe,
|
|
1200
|
+
_disableForm: Pt,
|
|
1201
1201
|
_subjects: b,
|
|
1202
1202
|
_proxyFormState: x,
|
|
1203
1203
|
get _fields() {
|
|
@@ -1207,10 +1207,10 @@ function mr(e = {}) {
|
|
|
1207
1207
|
return i;
|
|
1208
1208
|
},
|
|
1209
1209
|
get _state() {
|
|
1210
|
-
return
|
|
1210
|
+
return u;
|
|
1211
1211
|
},
|
|
1212
1212
|
set _state(s) {
|
|
1213
|
-
|
|
1213
|
+
u = 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:
|
|
1238
|
-
trigger:
|
|
1239
|
-
register:
|
|
1237
|
+
subscribe: U,
|
|
1238
|
+
trigger: me,
|
|
1239
|
+
register: we,
|
|
1240
1240
|
handleSubmit: Ke,
|
|
1241
1241
|
watch: _e,
|
|
1242
|
-
setValue:
|
|
1242
|
+
setValue: X,
|
|
1243
1243
|
getValues: c,
|
|
1244
1244
|
reset: tt,
|
|
1245
|
-
resetField:
|
|
1245
|
+
resetField: Nt,
|
|
1246
1246
|
clearErrors: j,
|
|
1247
1247
|
unregister: oe,
|
|
1248
1248
|
setError: I,
|
|
1249
|
-
setFocus:
|
|
1249
|
+
setFocus: It,
|
|
1250
1250
|
getFieldState: g
|
|
1251
1251
|
};
|
|
1252
1252
|
return {
|
|
@@ -1258,7 +1258,7 @@ function hr(e = {}) {
|
|
|
1258
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: ne(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: ne(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 && !ne(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
|
|
1281
1281
|
else {
|
|
1282
|
-
const { formControl:
|
|
1282
|
+
const { formControl: u, ...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, Ft(() => {
|
|
1290
|
+
const u = i._subscribe({
|
|
1291
1291
|
formState: i._proxyFormState,
|
|
1292
1292
|
callback: () => o({ ...i._formState }),
|
|
1293
1293
|
reRenderRoot: !0
|
|
@@ -1295,7 +1295,7 @@ function hr(e = {}) {
|
|
|
1295
1295
|
return o((f) => ({
|
|
1296
1296
|
...f,
|
|
1297
1297
|
isReady: !0
|
|
1298
|
-
})), i._formState.isReady = !0,
|
|
1298
|
+
})), i._formState.isReady = !0, u;
|
|
1299
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
1301
|
}, [i, e.mode, e.reValidateMode]), R.useEffect(() => {
|
|
@@ -1306,28 +1306,28 @@ function hr(e = {}) {
|
|
|
1306
1306
|
});
|
|
1307
1307
|
}, [i, e.shouldUnregister]), R.useEffect(() => {
|
|
1308
1308
|
if (i._proxyFormState.isDirty) {
|
|
1309
|
-
const
|
|
1310
|
-
|
|
1311
|
-
isDirty:
|
|
1309
|
+
const u = i._getDirty();
|
|
1310
|
+
u !== n.isDirty && i._subjects.state.next({
|
|
1311
|
+
isDirty: u
|
|
1312
1312
|
});
|
|
1313
1313
|
}
|
|
1314
1314
|
}, [i, n.isDirty]), R.useEffect(() => {
|
|
1315
|
-
var
|
|
1316
|
-
e.values && !
|
|
1315
|
+
var u;
|
|
1316
|
+
e.values && !ae(e.values, t.current) ? (i._reset(e.values, {
|
|
1317
1317
|
keepFieldsRef: !0,
|
|
1318
1318
|
...i._options.resetOptions
|
|
1319
|
-
}), !((
|
|
1319
|
+
}), !((u = i._options.resetOptions) === null || u === void 0) && u.keepIsValid || i._setValid(), t.current = e.values, o((f) => ({ ...f }))) : i._resetDefaultValues();
|
|
1320
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 Ot = $t(null), vr = ({
|
|
1325
1325
|
children: e,
|
|
1326
1326
|
layout: r = "vertical",
|
|
1327
1327
|
uiConfig: t,
|
|
1328
1328
|
updateFieldSchema: n
|
|
1329
1329
|
}) => {
|
|
1330
|
-
const o =
|
|
1330
|
+
const o = ve(
|
|
1331
1331
|
() => ({
|
|
1332
1332
|
layout: r,
|
|
1333
1333
|
uiConfig: t,
|
|
@@ -1335,33 +1335,33 @@ const Tt = Bt(null), vr = ({
|
|
|
1335
1335
|
}),
|
|
1336
1336
|
[r, t, n]
|
|
1337
1337
|
);
|
|
1338
|
-
return /* @__PURE__ */
|
|
1339
|
-
},
|
|
1340
|
-
const e =
|
|
1338
|
+
return /* @__PURE__ */ V.jsx(Ot.Provider, { value: o, children: e });
|
|
1339
|
+
}, Dt = () => {
|
|
1340
|
+
const e = Wt(Ot);
|
|
1341
1341
|
if (!e)
|
|
1342
1342
|
throw new Error("useAutoFormRenderContext must be used within AutoFormRenderContextProvider");
|
|
1343
1343
|
return e;
|
|
1344
1344
|
}, br = (e) => {
|
|
1345
|
-
const { fieldSchema: r } = e, { register: t } =
|
|
1346
|
-
return /* @__PURE__ */
|
|
1347
|
-
/* @__PURE__ */
|
|
1348
|
-
/* @__PURE__ */
|
|
1345
|
+
const { fieldSchema: r } = e, { register: t } = ge(), n = t(r.name);
|
|
1346
|
+
return /* @__PURE__ */ V.jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
|
|
1347
|
+
/* @__PURE__ */ V.jsx("label", { children: r.label }),
|
|
1348
|
+
/* @__PURE__ */ V.jsx("input", { type: r.type, ...n, readOnly: r.readonly })
|
|
1349
1349
|
] });
|
|
1350
1350
|
}, gr = (e) => {
|
|
1351
|
-
const { fieldSchema: r } = e, { register: t } =
|
|
1352
|
-
return /* @__PURE__ */
|
|
1353
|
-
/* @__PURE__ */
|
|
1354
|
-
/* @__PURE__ */
|
|
1351
|
+
const { fieldSchema: r } = e, { register: t } = ge(), n = t(r.name), o = r.options;
|
|
1352
|
+
return /* @__PURE__ */ V.jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
|
|
1353
|
+
/* @__PURE__ */ V.jsx("label", { children: r.label }),
|
|
1354
|
+
/* @__PURE__ */ V.jsx("select", { ...n, disabled: r.readonly, children: o.map((i) => /* @__PURE__ */ V.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 w =
|
|
1364
|
-
w ?
|
|
1361
|
+
let u = t;
|
|
1362
|
+
i.forEach((f, F) => {
|
|
1363
|
+
const w = F === i.length - 1, T = !isNaN(Number(f));
|
|
1364
|
+
w ? u[f] = r[o] : (f in u || (u[f] = T ? [] : {}), u = u[f]);
|
|
1365
1365
|
});
|
|
1366
1366
|
}), t;
|
|
1367
1367
|
}
|
|
@@ -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 u = [...o.split(".")];
|
|
1401
|
+
return n.forEach(({ pos: f, value: F }) => {
|
|
1402
|
+
f <= u.length && u.splice(f, 0, F);
|
|
1403
|
+
}), u.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 Ct(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: Ct(t)
|
|
1424
1424
|
};
|
|
1425
1425
|
}
|
|
1426
1426
|
return {
|
|
@@ -1437,42 +1437,42 @@ const Vr = R.memo((e) => {
|
|
|
1437
1437
|
})),
|
|
1438
1438
|
[r, t, n]
|
|
1439
1439
|
);
|
|
1440
|
-
return /* @__PURE__ */
|
|
1441
|
-
/* @__PURE__ */
|
|
1440
|
+
return /* @__PURE__ */ V.jsxs("div", { children: [
|
|
1441
|
+
/* @__PURE__ */ V.jsxs("div", { children: [
|
|
1442
1442
|
"row ",
|
|
1443
1443
|
t
|
|
1444
1444
|
] }),
|
|
1445
|
-
/* @__PURE__ */
|
|
1445
|
+
/* @__PURE__ */ V.jsx(Ie, { schema: o })
|
|
1446
1446
|
] });
|
|
1447
|
-
}),
|
|
1448
|
-
const { fieldSchema: r } = e, { control: t, getValues: n, setValue: o } =
|
|
1447
|
+
}), Fr = (e) => {
|
|
1448
|
+
const { fieldSchema: r } = e, { control: t, getValues: n, setValue: o } = ge(), u = wt({
|
|
1449
1449
|
control: t,
|
|
1450
1450
|
name: r.name
|
|
1451
1451
|
}) ?? [], f = () => {
|
|
1452
1452
|
const w = n(r.name) || [];
|
|
1453
1453
|
o(r.name, [...w, Ne(r.fields)]);
|
|
1454
|
-
},
|
|
1455
|
-
const x = (n(r.name) || []).filter((
|
|
1454
|
+
}, F = (w) => {
|
|
1455
|
+
const x = (n(r.name) || []).filter((p, b) => b !== w);
|
|
1456
1456
|
o(r.name, x);
|
|
1457
1457
|
};
|
|
1458
|
-
return /* @__PURE__ */
|
|
1459
|
-
|
|
1460
|
-
/* @__PURE__ */
|
|
1461
|
-
!r.readonly && /* @__PURE__ */
|
|
1458
|
+
return /* @__PURE__ */ V.jsxs("div", { children: [
|
|
1459
|
+
u.map((w, T) => /* @__PURE__ */ V.jsxs("div", { children: [
|
|
1460
|
+
/* @__PURE__ */ V.jsx(Vr, { baseName: r.name, index: T, fields: r.fields }),
|
|
1461
|
+
!r.readonly && /* @__PURE__ */ V.jsx("button", { type: "button", onClick: () => F(T), children: "Remove" })
|
|
1462
1462
|
] }, T)),
|
|
1463
|
-
!r.readonly && /* @__PURE__ */
|
|
1463
|
+
!r.readonly && /* @__PURE__ */ V.jsx("button", { type: "button", onClick: f, children: "Add Row" })
|
|
1464
1464
|
] });
|
|
1465
|
-
},
|
|
1465
|
+
}, wr = R.memo(Fr), pr = (e) => {
|
|
1466
1466
|
const { fieldSchema: r } = e;
|
|
1467
|
-
let t =
|
|
1467
|
+
let t = ve(
|
|
1468
1468
|
() => r.fields.map((n) => ({
|
|
1469
1469
|
...n,
|
|
1470
1470
|
name: `${r.name}.${n.name}`
|
|
1471
1471
|
})),
|
|
1472
1472
|
[r.fields]
|
|
1473
1473
|
);
|
|
1474
|
-
return /* @__PURE__ */
|
|
1475
|
-
},
|
|
1474
|
+
return /* @__PURE__ */ V.jsx(Ie, { schema: t });
|
|
1475
|
+
}, Ar = [
|
|
1476
1476
|
"text",
|
|
1477
1477
|
"number",
|
|
1478
1478
|
"checkbox",
|
|
@@ -1482,55 +1482,56 @@ const Vr = R.memo((e) => {
|
|
|
1482
1482
|
"time",
|
|
1483
1483
|
"array",
|
|
1484
1484
|
"object"
|
|
1485
|
-
],
|
|
1485
|
+
], jt = ({ fieldSchema: e }) => {
|
|
1486
1486
|
var w, T;
|
|
1487
|
-
const t =
|
|
1487
|
+
const t = Dt().uiConfig, { register: n, control: o } = ge(), i = Qe(e.name), u = n(e.name), f = (w = t == null ? void 0 : t.renderersByName) == null ? void 0 : w[i];
|
|
1488
|
+
if (e.visible === !1)
|
|
1489
|
+
return null;
|
|
1488
1490
|
if (f)
|
|
1489
|
-
return /* @__PURE__ */
|
|
1490
|
-
const
|
|
1491
|
-
if (
|
|
1492
|
-
return /* @__PURE__ */
|
|
1493
|
-
if (
|
|
1494
|
-
return e.type === "select" ? /* @__PURE__ */
|
|
1491
|
+
return /* @__PURE__ */ V.jsx(f, { fieldSchema: e, control: o, register: u });
|
|
1492
|
+
const F = (T = t == null ? void 0 : t.renderersByType) == null ? void 0 : T[e.type];
|
|
1493
|
+
if (F)
|
|
1494
|
+
return /* @__PURE__ */ V.jsx(F, { fieldSchema: e, control: o, register: u });
|
|
1495
|
+
if (Ar.includes(e.type))
|
|
1496
|
+
return e.type === "select" ? /* @__PURE__ */ V.jsx(gr, { fieldSchema: e }) : e.type === "array" ? /* @__PURE__ */ V.jsx(wr, { fieldSchema: e }) : e.type === "object" ? /* @__PURE__ */ V.jsx(pr, { fieldSchema: e }) : /* @__PURE__ */ V.jsx(br, { fieldSchema: e });
|
|
1495
1497
|
throw new Error(
|
|
1496
1498
|
`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
1499
|
);
|
|
1498
|
-
}, Rr = ({ fieldSchema: e }) => /* @__PURE__ */
|
|
1499
|
-
const { control: r } =
|
|
1500
|
+
}, Rr = ({ fieldSchema: e }) => /* @__PURE__ */ V.jsx(jt, { fieldSchema: e }), kr = ({ fieldSchema: e }) => {
|
|
1501
|
+
const { control: r } = ge(), t = Dt(), n = e.dependsOn ?? [], o = ve(
|
|
1500
1502
|
() => Er(e.name, n),
|
|
1501
1503
|
[e.name, n]
|
|
1502
1504
|
), i = wt({
|
|
1503
1505
|
control: r,
|
|
1504
1506
|
name: o
|
|
1505
|
-
}), [
|
|
1507
|
+
}), [u, f] = xt(e);
|
|
1506
1508
|
return Ce(() => {
|
|
1507
1509
|
if (!n.length) return;
|
|
1508
|
-
let
|
|
1510
|
+
let F = !1;
|
|
1509
1511
|
return (async () => {
|
|
1510
|
-
var
|
|
1511
|
-
const T = Qe(e.name), x = _r(o, i ?? []),
|
|
1512
|
-
if (!
|
|
1513
|
-
const b = await
|
|
1514
|
-
!
|
|
1512
|
+
var B;
|
|
1513
|
+
const T = Qe(e.name), x = _r(o, i ?? []), p = (B = t == null ? void 0 : t.updateFieldSchema) == null ? void 0 : B[T];
|
|
1514
|
+
if (!p) return;
|
|
1515
|
+
const b = await p(e.name, e, x);
|
|
1516
|
+
!F && b && f({
|
|
1515
1517
|
...e,
|
|
1516
1518
|
...b
|
|
1517
1519
|
});
|
|
1518
1520
|
})(), () => {
|
|
1519
|
-
|
|
1521
|
+
F = !0;
|
|
1520
1522
|
};
|
|
1521
|
-
}, [i]), /* @__PURE__ */
|
|
1523
|
+
}, [i]), /* @__PURE__ */ V.jsx(jt, { fieldSchema: u });
|
|
1522
1524
|
}, Sr = (e) => {
|
|
1523
1525
|
var t;
|
|
1524
1526
|
const { fieldSchema: r } = e;
|
|
1525
|
-
return (t = r.dependsOn) != null && t.length ? /* @__PURE__ */
|
|
1527
|
+
return (t = r.dependsOn) != null && t.length ? /* @__PURE__ */ V.jsx(kr, { fieldSchema: r }) : /* @__PURE__ */ V.jsx(Rr, { fieldSchema: r });
|
|
1526
1528
|
}, Tr = (e) => {
|
|
1527
1529
|
const { fieldSchema: r } = e;
|
|
1528
|
-
|
|
1529
|
-
return /* @__PURE__ */ A.jsx(Sr, { fieldSchema: r });
|
|
1530
|
+
return /* @__PURE__ */ V.jsx(Sr, { fieldSchema: r });
|
|
1530
1531
|
}, Ie = R.memo(
|
|
1531
1532
|
(e) => {
|
|
1532
1533
|
const { schema: r } = e;
|
|
1533
|
-
return r.map((t) => /* @__PURE__ */
|
|
1534
|
+
return r.map((t) => /* @__PURE__ */ V.jsx(Tr, { fieldSchema: t }, t.name));
|
|
1534
1535
|
}
|
|
1535
1536
|
);
|
|
1536
1537
|
function Or(e, r) {
|
|
@@ -1538,24 +1539,24 @@ function Or(e, r) {
|
|
|
1538
1539
|
let o = r;
|
|
1539
1540
|
for (const i of n) {
|
|
1540
1541
|
if (o == null) return;
|
|
1541
|
-
const
|
|
1542
|
-
o = o[
|
|
1542
|
+
const u = t(i) ? Number(i) : i;
|
|
1543
|
+
o = o[u];
|
|
1543
1544
|
}
|
|
1544
1545
|
return o;
|
|
1545
1546
|
}
|
|
1546
1547
|
const Dr = (e) => {
|
|
1547
|
-
const { onDirtyChange: r, onValuesChange: t, onFieldChange: n } = e, { formState: o, watch: i } =
|
|
1548
|
+
const { onDirtyChange: r, onValuesChange: t, onFieldChange: n } = e, { formState: o, watch: i } = ge(), u = Et(!0);
|
|
1548
1549
|
return Ce(() => {
|
|
1549
|
-
const f = i((
|
|
1550
|
-
var
|
|
1551
|
-
t(
|
|
1552
|
-
const T = Qe(w), x = Or(w,
|
|
1553
|
-
(
|
|
1550
|
+
const f = i((F, { name: w = "" }) => {
|
|
1551
|
+
var p;
|
|
1552
|
+
t(F);
|
|
1553
|
+
const T = Qe(w), x = Or(w, F);
|
|
1554
|
+
(p = n == null ? void 0 : n[T]) == null || p.call(n, w, x, F);
|
|
1554
1555
|
});
|
|
1555
1556
|
return () => f.unsubscribe();
|
|
1556
1557
|
}, [i, t]), Ce(() => {
|
|
1557
|
-
if (
|
|
1558
|
-
|
|
1558
|
+
if (u.current) {
|
|
1559
|
+
u.current = !1;
|
|
1559
1560
|
return;
|
|
1560
1561
|
}
|
|
1561
1562
|
r(o.isDirty);
|
|
@@ -1578,30 +1579,31 @@ const Dr = (e) => {
|
|
|
1578
1579
|
renderersByType: {}
|
|
1579
1580
|
},
|
|
1580
1581
|
updateFieldSchema: i = {},
|
|
1581
|
-
layout:
|
|
1582
|
+
layout: u = "vertical",
|
|
1582
1583
|
values: f = () => ({}),
|
|
1583
|
-
hideSubmit:
|
|
1584
|
+
hideSubmit: F = !1,
|
|
1584
1585
|
onDirtyChange: w = () => {
|
|
1585
1586
|
},
|
|
1586
1587
|
onValuesChange: T = () => {
|
|
1587
1588
|
},
|
|
1588
1589
|
resolver: x,
|
|
1589
|
-
readonly:
|
|
1590
|
-
onFieldChange: b = {}
|
|
1590
|
+
readonly: p,
|
|
1591
|
+
onFieldChange: b = {},
|
|
1592
|
+
loadingComponent: B
|
|
1591
1593
|
} = e, O = hr({
|
|
1592
1594
|
reValidateMode: "onSubmit",
|
|
1593
1595
|
criteriaMode: "all",
|
|
1594
1596
|
resolver: x
|
|
1595
|
-
}),
|
|
1597
|
+
}), z = Et(!1), [$, E] = xt(!1), G = O.handleSubmit(n), C = ve(() => {
|
|
1596
1598
|
let N = t;
|
|
1597
|
-
return
|
|
1598
|
-
}, [
|
|
1599
|
+
return p && (N = Ct(N)), N;
|
|
1600
|
+
}, [p, t]);
|
|
1599
1601
|
Ce(() => {
|
|
1600
|
-
if (L.current) return;
|
|
1601
1602
|
let N = !1;
|
|
1602
1603
|
return (async () => {
|
|
1603
|
-
|
|
1604
|
-
|
|
1604
|
+
E(!1);
|
|
1605
|
+
const fe = await f();
|
|
1606
|
+
N || (O.reset(Ne(t, fe)), z.current = !0, E(!0));
|
|
1605
1607
|
})(), () => {
|
|
1606
1608
|
N = !0;
|
|
1607
1609
|
};
|
|
@@ -1613,20 +1615,23 @@ const Dr = (e) => {
|
|
|
1613
1615
|
O.reset(N ? Ne(t, N) : void 0);
|
|
1614
1616
|
},
|
|
1615
1617
|
getValues: () => O.getValues(),
|
|
1616
|
-
setValue: (N,
|
|
1617
|
-
O.setValue(N,
|
|
1618
|
+
setValue: (N, J) => {
|
|
1619
|
+
O.setValue(N, J);
|
|
1618
1620
|
}
|
|
1619
1621
|
}));
|
|
1620
|
-
const
|
|
1622
|
+
const k = F || p, ee = ve(() => o, [o]), ce = ve(
|
|
1623
|
+
() => i,
|
|
1624
|
+
[i]
|
|
1625
|
+
), se = ve(
|
|
1621
1626
|
() => ({
|
|
1622
|
-
layout:
|
|
1627
|
+
layout: u,
|
|
1623
1628
|
uiConfig: o,
|
|
1624
1629
|
updateFieldSchema: i
|
|
1625
1630
|
}),
|
|
1626
|
-
[
|
|
1631
|
+
[u, o, i]
|
|
1627
1632
|
);
|
|
1628
|
-
return /* @__PURE__ */
|
|
1629
|
-
/* @__PURE__ */
|
|
1633
|
+
return $ ? /* @__PURE__ */ V.jsxs(Qt, { ...O, children: [
|
|
1634
|
+
/* @__PURE__ */ V.jsx(
|
|
1630
1635
|
Cr,
|
|
1631
1636
|
{
|
|
1632
1637
|
onDirtyChange: w,
|
|
@@ -1634,29 +1639,40 @@ const Dr = (e) => {
|
|
|
1634
1639
|
onFieldChange: b
|
|
1635
1640
|
}
|
|
1636
1641
|
),
|
|
1637
|
-
/* @__PURE__ */
|
|
1642
|
+
/* @__PURE__ */ V.jsxs(
|
|
1638
1643
|
vr,
|
|
1639
1644
|
{
|
|
1640
|
-
layout:
|
|
1641
|
-
uiConfig:
|
|
1642
|
-
updateFieldSchema:
|
|
1645
|
+
layout: se.layout,
|
|
1646
|
+
uiConfig: ee,
|
|
1647
|
+
updateFieldSchema: ce,
|
|
1643
1648
|
children: [
|
|
1644
|
-
["vertical", "horizontal"].includes(
|
|
1649
|
+
["vertical", "horizontal"].includes(u) && /* @__PURE__ */ V.jsx(
|
|
1645
1650
|
"div",
|
|
1646
1651
|
{
|
|
1647
1652
|
style: {
|
|
1648
1653
|
display: "flex",
|
|
1649
|
-
flexDirection:
|
|
1654
|
+
flexDirection: u === "vertical" ? "column" : "row"
|
|
1650
1655
|
},
|
|
1651
|
-
children: /* @__PURE__ */
|
|
1656
|
+
children: /* @__PURE__ */ V.jsx(Ie, { schema: C })
|
|
1652
1657
|
}
|
|
1653
1658
|
),
|
|
1654
|
-
|
|
1655
|
-
!
|
|
1659
|
+
u === "custom" && /* @__PURE__ */ V.jsx(Ie, { schema: C }),
|
|
1660
|
+
!k && /* @__PURE__ */ V.jsx("button", { style: { marginTop: "1rem" }, onClick: G, children: "Submit" })
|
|
1656
1661
|
]
|
|
1657
1662
|
}
|
|
1658
1663
|
)
|
|
1659
|
-
] })
|
|
1664
|
+
] }) : /* @__PURE__ */ V.jsx(V.Fragment, { children: B ?? /* @__PURE__ */ V.jsx(
|
|
1665
|
+
"div",
|
|
1666
|
+
{
|
|
1667
|
+
style: {
|
|
1668
|
+
padding: "2rem",
|
|
1669
|
+
textAlign: "center",
|
|
1670
|
+
color: "#666",
|
|
1671
|
+
fontSize: "0.9rem"
|
|
1672
|
+
},
|
|
1673
|
+
children: "Loading form..."
|
|
1674
|
+
}
|
|
1675
|
+
) });
|
|
1660
1676
|
}
|
|
1661
1677
|
);
|
|
1662
1678
|
export {
|
|
@@ -1665,7 +1681,7 @@ export {
|
|
|
1665
1681
|
_r as buildNestedPartialValues,
|
|
1666
1682
|
Ne as generateInitialValues,
|
|
1667
1683
|
xr as getDefaultValueForField,
|
|
1668
|
-
|
|
1684
|
+
Ct as makeSchemaReadOnly,
|
|
1669
1685
|
Qe as normalizeFieldPath,
|
|
1670
1686
|
Er as resolveDependsOnNew
|
|
1671
1687
|
};
|