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