react-simple-formkit 2.4.5 → 2.4.7
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/README.md +143 -100
- package/dist/react-simple-formkit.js +4 -4
- package/dist/react-simple-formkit.mjs +401 -409
- package/dist/react-simple-formkit.umd.js +4 -4
- package/package.json +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
var
|
|
1
|
+
import jr, { createContext as wr, useContext as $r, useCallback as h, useEffect as Er, useState as lr, useRef as Y, useMemo as hr, useLayoutEffect as mr } from "react";
|
|
2
|
+
var ir = { exports: {} }, er = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
5
5
|
* react-jsx-runtime.production.js
|
|
@@ -10,28 +10,28 @@ var lr = { exports: {} }, tr = {};
|
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/
|
|
12
12
|
var vr;
|
|
13
|
-
function
|
|
14
|
-
if (vr) return
|
|
13
|
+
function Pr() {
|
|
14
|
+
if (vr) return er;
|
|
15
15
|
vr = 1;
|
|
16
16
|
var s = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
|
|
17
|
-
function u(
|
|
17
|
+
function u(l, c, f) {
|
|
18
18
|
var o = null;
|
|
19
19
|
if (f !== void 0 && (o = "" + f), c.key !== void 0 && (o = "" + c.key), "key" in c) {
|
|
20
20
|
f = {};
|
|
21
|
-
for (var
|
|
22
|
-
|
|
21
|
+
for (var b in c)
|
|
22
|
+
b !== "key" && (f[b] = c[b]);
|
|
23
23
|
} else f = c;
|
|
24
24
|
return c = f.ref, {
|
|
25
25
|
$$typeof: s,
|
|
26
|
-
type:
|
|
26
|
+
type: l,
|
|
27
27
|
key: o,
|
|
28
28
|
ref: c !== void 0 ? c : null,
|
|
29
29
|
props: f
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return er.Fragment = t, er.jsx = u, er.jsxs = u, er;
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var tr = {};
|
|
35
35
|
/**
|
|
36
36
|
* @license React
|
|
37
37
|
* react-jsx-runtime.development.js
|
|
@@ -42,38 +42,38 @@ var nr = {};
|
|
|
42
42
|
* LICENSE file in the root directory of this source tree.
|
|
43
43
|
*/
|
|
44
44
|
var Rr;
|
|
45
|
-
function
|
|
45
|
+
function kr() {
|
|
46
46
|
return Rr || (Rr = 1, process.env.NODE_ENV !== "production" && function() {
|
|
47
47
|
function s(e) {
|
|
48
48
|
if (e == null) return null;
|
|
49
49
|
if (typeof e == "function")
|
|
50
|
-
return e.$$typeof ===
|
|
50
|
+
return e.$$typeof === nr ? null : e.displayName || e.name || null;
|
|
51
51
|
if (typeof e == "string") return e;
|
|
52
52
|
switch (e) {
|
|
53
53
|
case S:
|
|
54
54
|
return "Fragment";
|
|
55
|
-
case
|
|
55
|
+
case y:
|
|
56
56
|
return "Profiler";
|
|
57
|
-
case
|
|
57
|
+
case $:
|
|
58
58
|
return "StrictMode";
|
|
59
59
|
case x:
|
|
60
60
|
return "Suspense";
|
|
61
|
-
case
|
|
61
|
+
case q:
|
|
62
62
|
return "SuspenseList";
|
|
63
|
-
case
|
|
63
|
+
case F:
|
|
64
64
|
return "Activity";
|
|
65
65
|
}
|
|
66
66
|
if (typeof e == "object")
|
|
67
67
|
switch (typeof e.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
|
), e.$$typeof) {
|
|
70
|
-
case p:
|
|
71
|
-
return "Portal";
|
|
72
70
|
case A:
|
|
71
|
+
return "Portal";
|
|
72
|
+
case O:
|
|
73
73
|
return (e.displayName || "Context") + ".Provider";
|
|
74
|
-
case
|
|
74
|
+
case _:
|
|
75
75
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
|
-
case
|
|
76
|
+
case P:
|
|
77
77
|
var g = e.render;
|
|
78
78
|
return e = e.displayName, e || (e = g.displayName || g.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
79
|
case H:
|
|
@@ -99,15 +99,15 @@ function Nr() {
|
|
|
99
99
|
}
|
|
100
100
|
if (g) {
|
|
101
101
|
g = console;
|
|
102
|
-
var
|
|
103
|
-
return
|
|
102
|
+
var T = g.error, w = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
103
|
+
return T.call(
|
|
104
104
|
g,
|
|
105
105
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
-
|
|
106
|
+
w
|
|
107
107
|
), t(e);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function l(e) {
|
|
111
111
|
if (e === S) return "<>";
|
|
112
112
|
if (typeof e == "object" && e !== null && e.$$typeof === J)
|
|
113
113
|
return "<...>";
|
|
@@ -119,47 +119,47 @@ function Nr() {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
function c() {
|
|
122
|
-
var e =
|
|
122
|
+
var e = K.A;
|
|
123
123
|
return e === null ? null : e.getOwner();
|
|
124
124
|
}
|
|
125
125
|
function f() {
|
|
126
126
|
return Error("react-stack-top-frame");
|
|
127
127
|
}
|
|
128
128
|
function o(e) {
|
|
129
|
-
if (
|
|
129
|
+
if (sr.call(e, "key")) {
|
|
130
130
|
var g = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
131
131
|
if (g && g.isReactWarning) return !1;
|
|
132
132
|
}
|
|
133
133
|
return e.key !== void 0;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
function
|
|
135
|
+
function b(e, g) {
|
|
136
|
+
function T() {
|
|
137
137
|
z || (z = !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
|
+
T.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
143
|
+
get: T,
|
|
144
144
|
configurable: !0
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function E() {
|
|
148
148
|
var e = s(this.type);
|
|
149
|
-
return
|
|
149
|
+
return or[e] || (or[e] = !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
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
154
|
-
return
|
|
155
|
-
$$typeof:
|
|
153
|
+
function R(e, g, T, w, L, I, Z, Q) {
|
|
154
|
+
return T = I.ref, e = {
|
|
155
|
+
$$typeof: C,
|
|
156
156
|
type: e,
|
|
157
157
|
key: g,
|
|
158
|
-
props:
|
|
159
|
-
_owner:
|
|
160
|
-
}, (
|
|
158
|
+
props: I,
|
|
159
|
+
_owner: L
|
|
160
|
+
}, (T !== void 0 ? T : null) !== null ? Object.defineProperty(e, "ref", {
|
|
161
161
|
enumerable: !1,
|
|
162
|
-
get:
|
|
162
|
+
get: E
|
|
163
163
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
164
164
|
configurable: !1,
|
|
165
165
|
enumerable: !1,
|
|
@@ -179,63 +179,63 @@ function Nr() {
|
|
|
179
179
|
configurable: !1,
|
|
180
180
|
enumerable: !1,
|
|
181
181
|
writable: !0,
|
|
182
|
-
value:
|
|
182
|
+
value: Q
|
|
183
183
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
var
|
|
187
|
-
if (
|
|
188
|
-
if (
|
|
189
|
-
if (fr(
|
|
190
|
-
for (
|
|
191
|
-
a(
|
|
192
|
-
Object.freeze && Object.freeze(
|
|
185
|
+
function m(e, g, T, w, L, I, Z, Q) {
|
|
186
|
+
var j = g.children;
|
|
187
|
+
if (j !== void 0)
|
|
188
|
+
if (w)
|
|
189
|
+
if (fr(j)) {
|
|
190
|
+
for (w = 0; w < j.length; w++)
|
|
191
|
+
a(j[w]);
|
|
192
|
+
Object.freeze && Object.freeze(j);
|
|
193
193
|
} else
|
|
194
194
|
console.error(
|
|
195
195
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
196
196
|
);
|
|
197
|
-
else a(
|
|
198
|
-
if (
|
|
199
|
-
|
|
200
|
-
var
|
|
197
|
+
else a(j);
|
|
198
|
+
if (sr.call(g, "key")) {
|
|
199
|
+
j = s(e);
|
|
200
|
+
var V = Object.keys(g).filter(function(dr) {
|
|
201
201
|
return dr !== "key";
|
|
202
202
|
});
|
|
203
|
-
|
|
203
|
+
w = 0 < V.length ? "{key: someKey, " + V.join(": ..., ") + ": ...}" : "{key: someKey}", cr[j + w] || (V = 0 < V.length ? "{" + V.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
204
204
|
`A props object containing a "key" prop is being spread into JSX:
|
|
205
205
|
let props = %s;
|
|
206
206
|
<%s {...props} />
|
|
207
207
|
React keys must be passed directly to JSX without using spread:
|
|
208
208
|
let props = %s;
|
|
209
209
|
<%s key={someKey} {...props} />`,
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
),
|
|
210
|
+
w,
|
|
211
|
+
j,
|
|
212
|
+
V,
|
|
213
|
+
j
|
|
214
|
+
), cr[j + w] = !0);
|
|
215
215
|
}
|
|
216
|
-
if (
|
|
217
|
-
|
|
218
|
-
for (var
|
|
219
|
-
|
|
220
|
-
} else
|
|
221
|
-
return
|
|
222
|
-
|
|
216
|
+
if (j = null, T !== void 0 && (u(T), j = "" + T), o(g) && (u(g.key), j = "" + g.key), "key" in g) {
|
|
217
|
+
T = {};
|
|
218
|
+
for (var rr in g)
|
|
219
|
+
rr !== "key" && (T[rr] = g[rr]);
|
|
220
|
+
} else T = g;
|
|
221
|
+
return j && b(
|
|
222
|
+
T,
|
|
223
223
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
224
|
-
),
|
|
224
|
+
), R(
|
|
225
225
|
e,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
226
|
+
j,
|
|
227
|
+
I,
|
|
228
|
+
L,
|
|
229
229
|
c(),
|
|
230
|
-
|
|
230
|
+
T,
|
|
231
231
|
Z,
|
|
232
|
-
|
|
232
|
+
Q
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
235
|
function a(e) {
|
|
236
|
-
typeof e == "object" && e !== null && e.$$typeof ===
|
|
236
|
+
typeof e == "object" && e !== null && e.$$typeof === C && e._store && (e._store.validated = 1);
|
|
237
237
|
}
|
|
238
|
-
var v =
|
|
238
|
+
var v = jr, C = Symbol.for("react.transitional.element"), A = Symbol.for("react.portal"), S = Symbol.for("react.fragment"), $ = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), _ = Symbol.for("react.consumer"), O = Symbol.for("react.context"), P = Symbol.for("react.forward_ref"), x = Symbol.for("react.suspense"), q = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), J = Symbol.for("react.lazy"), F = Symbol.for("react.activity"), nr = Symbol.for("react.client.reference"), K = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, sr = Object.prototype.hasOwnProperty, fr = Array.isArray, X = console.createTask ? console.createTask : function() {
|
|
239
239
|
return null;
|
|
240
240
|
};
|
|
241
241
|
v = {
|
|
@@ -243,135 +243,135 @@ React keys must be passed directly to JSX without using spread:
|
|
|
243
243
|
return e();
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
|
-
var z,
|
|
246
|
+
var z, or = {}, W = v["react-stack-bottom-frame"].bind(
|
|
247
247
|
v,
|
|
248
248
|
f
|
|
249
|
-
)(),
|
|
250
|
-
|
|
251
|
-
var
|
|
252
|
-
return
|
|
249
|
+
)(), ur = X(l(f)), cr = {};
|
|
250
|
+
tr.Fragment = S, tr.jsx = function(e, g, T, w, L) {
|
|
251
|
+
var I = 1e4 > K.recentlyCreatedOwnerStacks++;
|
|
252
|
+
return m(
|
|
253
253
|
e,
|
|
254
254
|
g,
|
|
255
|
-
|
|
255
|
+
T,
|
|
256
256
|
!1,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
257
|
+
w,
|
|
258
|
+
L,
|
|
259
|
+
I ? Error("react-stack-top-frame") : W,
|
|
260
|
+
I ? X(l(e)) : ur
|
|
261
261
|
);
|
|
262
|
-
},
|
|
263
|
-
var
|
|
264
|
-
return
|
|
262
|
+
}, tr.jsxs = function(e, g, T, w, L) {
|
|
263
|
+
var I = 1e4 > K.recentlyCreatedOwnerStacks++;
|
|
264
|
+
return m(
|
|
265
265
|
e,
|
|
266
266
|
g,
|
|
267
|
-
|
|
267
|
+
T,
|
|
268
268
|
!0,
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
269
|
+
w,
|
|
270
|
+
L,
|
|
271
|
+
I ? Error("react-stack-top-frame") : W,
|
|
272
|
+
I ? X(l(e)) : ur
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
|
-
}()),
|
|
275
|
+
}()), tr;
|
|
276
276
|
}
|
|
277
277
|
var Sr;
|
|
278
|
-
function
|
|
279
|
-
return Sr || (Sr = 1, process.env.NODE_ENV === "production" ?
|
|
278
|
+
function Nr() {
|
|
279
|
+
return Sr || (Sr = 1, process.env.NODE_ENV === "production" ? ir.exports = Pr() : ir.exports = kr()), ir.exports;
|
|
280
280
|
}
|
|
281
|
-
var yr =
|
|
282
|
-
const
|
|
283
|
-
}, Ar =
|
|
281
|
+
var yr = Nr();
|
|
282
|
+
const p = () => {
|
|
283
|
+
}, Ar = wr({
|
|
284
284
|
ref: null,
|
|
285
|
-
watch:
|
|
285
|
+
watch: p,
|
|
286
286
|
actions: {
|
|
287
|
-
subscribe:
|
|
288
|
-
reset:
|
|
289
|
-
trigger:
|
|
290
|
-
reload:
|
|
291
|
-
resetField:
|
|
292
|
-
setValue:
|
|
293
|
-
getValues:
|
|
294
|
-
getErrors:
|
|
295
|
-
getFieldStates:
|
|
296
|
-
getFormState:
|
|
297
|
-
setError:
|
|
298
|
-
clearError:
|
|
299
|
-
clearErrors:
|
|
300
|
-
checkValidity:
|
|
301
|
-
getFieldValidity:
|
|
302
|
-
getDefaultValues:
|
|
303
|
-
setFieldState:
|
|
304
|
-
triggerFieldBlur:
|
|
305
|
-
resetFieldState:
|
|
306
|
-
getControlledFields:
|
|
307
|
-
setFormState:
|
|
308
|
-
getEvents:
|
|
309
|
-
getWatchEvents:
|
|
310
|
-
addGroups:
|
|
287
|
+
subscribe: p,
|
|
288
|
+
reset: p,
|
|
289
|
+
trigger: p,
|
|
290
|
+
reload: p,
|
|
291
|
+
resetField: p,
|
|
292
|
+
setValue: p,
|
|
293
|
+
getValues: p,
|
|
294
|
+
getErrors: p,
|
|
295
|
+
getFieldStates: p,
|
|
296
|
+
getFormState: p,
|
|
297
|
+
setError: p,
|
|
298
|
+
clearError: p,
|
|
299
|
+
clearErrors: p,
|
|
300
|
+
checkValidity: p,
|
|
301
|
+
getFieldValidity: p,
|
|
302
|
+
getDefaultValues: p,
|
|
303
|
+
setFieldState: p,
|
|
304
|
+
triggerFieldBlur: p,
|
|
305
|
+
resetFieldState: p,
|
|
306
|
+
getControlledFields: p,
|
|
307
|
+
setFormState: p,
|
|
308
|
+
getEvents: p,
|
|
309
|
+
getWatchEvents: p,
|
|
310
|
+
addGroups: p
|
|
311
311
|
},
|
|
312
|
-
registerController:
|
|
313
|
-
registerHookWatcher:
|
|
314
|
-
lastReloadedAt:
|
|
315
|
-
loadFormValues:
|
|
316
|
-
getWatchValue:
|
|
312
|
+
registerController: p,
|
|
313
|
+
registerHookWatcher: p,
|
|
314
|
+
lastReloadedAt: p,
|
|
315
|
+
loadFormValues: p,
|
|
316
|
+
getWatchValue: p,
|
|
317
317
|
channels: {}
|
|
318
318
|
}), Tr = () => $r(Ar), qr = ({
|
|
319
319
|
id: s,
|
|
320
320
|
control: t,
|
|
321
321
|
method: u,
|
|
322
|
-
action:
|
|
322
|
+
action: l,
|
|
323
323
|
children: c,
|
|
324
324
|
onChange: f,
|
|
325
325
|
onBlur: o,
|
|
326
|
-
onSubmit:
|
|
326
|
+
onSubmit: b = () => {
|
|
327
327
|
},
|
|
328
|
-
onInput:
|
|
328
|
+
onInput: E = () => {
|
|
329
329
|
},
|
|
330
|
-
onReset:
|
|
330
|
+
onReset: R = () => {
|
|
331
331
|
},
|
|
332
|
-
numberFields:
|
|
332
|
+
numberFields: m = [],
|
|
333
333
|
className: a,
|
|
334
334
|
...v
|
|
335
335
|
}) => {
|
|
336
|
-
const
|
|
337
|
-
(
|
|
338
|
-
t.ref && (t.ref.current =
|
|
336
|
+
const C = h(
|
|
337
|
+
(A) => {
|
|
338
|
+
t.ref && (t.ref.current = A, t.ref.current && t.initForm());
|
|
339
339
|
},
|
|
340
340
|
[t]
|
|
341
341
|
);
|
|
342
|
-
return
|
|
343
|
-
let
|
|
342
|
+
return Er(() => {
|
|
343
|
+
let A = () => {
|
|
344
344
|
}, S = () => {
|
|
345
345
|
};
|
|
346
|
-
return f && (
|
|
347
|
-
|
|
346
|
+
return f && (A = t.channels.subscribe("onChange", f)), o && (S = t.channels.subscribe("onBlur", o)), () => {
|
|
347
|
+
A(), S();
|
|
348
348
|
};
|
|
349
349
|
}, [t.lastReloadedAt]), /* @__PURE__ */ yr.jsx(Ar.Provider, { value: t, children: /* @__PURE__ */ yr.jsx(
|
|
350
350
|
"form",
|
|
351
351
|
{
|
|
352
352
|
id: s,
|
|
353
|
-
ref:
|
|
354
|
-
action:
|
|
353
|
+
ref: C,
|
|
354
|
+
action: l,
|
|
355
355
|
method: u,
|
|
356
356
|
className: a,
|
|
357
|
-
onInput:
|
|
358
|
-
onSubmit: (
|
|
359
|
-
u ||
|
|
357
|
+
onInput: E,
|
|
358
|
+
onSubmit: (A) => {
|
|
359
|
+
u || A.preventDefault();
|
|
360
360
|
const S = t.loadFormValues();
|
|
361
|
-
|
|
361
|
+
b(S);
|
|
362
362
|
},
|
|
363
|
-
onChange: (
|
|
364
|
-
const S =
|
|
365
|
-
!S || t.actions.getControlledFields().has(S) || t.actions.setValue(S,
|
|
363
|
+
onChange: (A) => {
|
|
364
|
+
const S = A.target.name;
|
|
365
|
+
!S || t.actions.getControlledFields().has(S) || t.actions.setValue(S, A.target.value);
|
|
366
366
|
},
|
|
367
|
-
onBlur: (
|
|
368
|
-
const S =
|
|
367
|
+
onBlur: (A) => {
|
|
368
|
+
const S = A.target.name;
|
|
369
369
|
if (!S || t.actions.getControlledFields().has(S)) return;
|
|
370
|
-
const
|
|
371
|
-
t.channels.publish("onBlur", S,
|
|
370
|
+
const $ = A.target.value;
|
|
371
|
+
t.channels.publish("onBlur", S, $, t.actions.getValues()), t.triggerBlurWatchers(S);
|
|
372
372
|
},
|
|
373
|
-
onReset: (
|
|
374
|
-
t.actions.reset(),
|
|
373
|
+
onReset: (A) => {
|
|
374
|
+
t.actions.reset(), R(A);
|
|
375
375
|
},
|
|
376
376
|
...v,
|
|
377
377
|
children: c
|
|
@@ -385,7 +385,7 @@ const y = () => {
|
|
|
385
385
|
errorFields: [],
|
|
386
386
|
dirtyFields: [],
|
|
387
387
|
touchedFields: []
|
|
388
|
-
},
|
|
388
|
+
}, Dr = {}, xr = [
|
|
389
389
|
"badInput",
|
|
390
390
|
"customError",
|
|
391
391
|
"patternMismatch",
|
|
@@ -396,58 +396,61 @@ const y = () => {
|
|
|
396
396
|
"tooShort",
|
|
397
397
|
"typeMismatch",
|
|
398
398
|
"valueMissing"
|
|
399
|
-
], D = (s = {}, t = "") => t.split(".").reduce((u,
|
|
400
|
-
const
|
|
401
|
-
let c =
|
|
399
|
+
], D = (s = {}, t = "") => t.split(".").reduce((u, l) => u && u[l] !== void 0 ? u[l] : void 0, s), M = (s = {}, t = "", u) => {
|
|
400
|
+
const l = Array.isArray(s) ? [...s] : { ...s };
|
|
401
|
+
let c = l;
|
|
402
402
|
const f = t.split(".");
|
|
403
|
-
return f.forEach((o,
|
|
404
|
-
|
|
405
|
-
}),
|
|
406
|
-
},
|
|
403
|
+
return f.forEach((o, b) => {
|
|
404
|
+
b < f.length - 1 ? (c[o] || (c[o] = /^\d+$/.test(f[b + 1]) ? [] : {}), Array.isArray(c[o]) ? c[o] = [...c[o]] : c[o] = { ...c[o] }, c = c[o]) : c[o] = u;
|
|
405
|
+
}), l;
|
|
406
|
+
}, Wr = (s) => {
|
|
407
407
|
let t = Array.isArray(s) ? [...s] : { ...s };
|
|
408
408
|
return Object.keys(t).forEach((u) => {
|
|
409
409
|
if (u.includes(".")) {
|
|
410
|
-
const
|
|
411
|
-
t =
|
|
410
|
+
const l = D(t, u);
|
|
411
|
+
t = M(t, u, l || ""), delete t[u];
|
|
412
412
|
}
|
|
413
413
|
}), t;
|
|
414
|
-
},
|
|
414
|
+
}, Br = ["errors", "fieldStates", "formState"], G = (s) => Br.some((t) => s.startsWith(t)) ? s : "values." + s, Fr = (s) => {
|
|
415
415
|
typeof s.setCustomValidity == "function" && s.setCustomValidity("");
|
|
416
|
-
let t = s.validity, u =
|
|
416
|
+
let t = s.validity, u = xr.find((l) => t[l]);
|
|
417
417
|
if (u) return { type: u, message: s.validationMessage };
|
|
418
|
-
}, _r = (s = /* @__PURE__ */ new Set(), t = {}, u = "") => Object.keys(t || {}).reduce((
|
|
418
|
+
}, _r = (s = /* @__PURE__ */ new Set(), t = {}, u = "") => Object.keys(t || {}).reduce((l, c) => {
|
|
419
419
|
const f = (t || {})[c];
|
|
420
|
-
return s.has(u + c) ? [...
|
|
421
|
-
}, []), Or = (s = /* @__PURE__ */ new Set(), t = {}, u = "") => Object.keys(t || {}).reduce((
|
|
420
|
+
return s.has(u + c) ? [...l, ..._r(s, f, u + c + ".")] : f != null && f.isDirty ? [...l, u + c] : l;
|
|
421
|
+
}, []), Or = (s = /* @__PURE__ */ new Set(), t = {}, u = "") => Object.keys(t || {}).reduce((l, c) => {
|
|
422
422
|
const f = (t || {})[c];
|
|
423
|
-
return s.has(u + c) ? [...
|
|
424
|
-
}, []),
|
|
423
|
+
return s.has(u + c) ? [...l, ...Or(s, f, u + c + ".")] : f != null && f.isTouched ? [...l, u + c] : l;
|
|
424
|
+
}, []), Cr = (s = /* @__PURE__ */ new Set(), t = {}, u = "") => Object.keys(t || {}).reduce((l, c) => {
|
|
425
425
|
const f = (t || {})[c];
|
|
426
|
-
return s.has(u + c) ? [...
|
|
427
|
-
}, []),
|
|
428
|
-
const {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
426
|
+
return s.has(u + c) ? [...l, ...Cr(s, f, u + c + ".")] : f ? [...l, u + c] : l;
|
|
427
|
+
}, []), Ir = ({ control: s, name: t, compute: u, mode: l }) => {
|
|
428
|
+
const { getWatchValue: c, registerHookWatcher: f } = s || Tr(), o = c({ name: t, compute: u }), [b, E] = lr(o);
|
|
429
|
+
return Er(() => f({ name: t, compute: u, value: b, setValue: E, mode: l }), []), b;
|
|
430
|
+
}, Yr = ({ control: s, name: t, defaultValue: u, shouldUnRegister: l }) => {
|
|
431
|
+
const { actions: c, registerController: f, channels: o, getWatchValue: b, triggerBlurWatchers: E } = s || Tr(), R = Y(), m = Y(), a = D(c.getDefaultValues(), t) || u || "", v = Ir({ name: t }) ?? a, [C, A] = lr({}), S = h(
|
|
432
|
+
(y, { shouldDirty: _ = !0, shouldOnChange: O = !0 } = {}) => {
|
|
433
|
+
var x;
|
|
434
|
+
let P = y;
|
|
435
|
+
((x = y == null ? void 0 : y.target) == null ? void 0 : x.value) !== void 0 && (P = y.target.value), c.setValue(t, P, { shouldDirty: _, shouldOnChange: O });
|
|
433
436
|
},
|
|
434
437
|
[c.setValue]
|
|
435
|
-
),
|
|
436
|
-
const
|
|
437
|
-
o.publish("onBlur", t,
|
|
438
|
+
), $ = h((y) => {
|
|
439
|
+
const _ = c.getValues(), O = y ?? D(_, t);
|
|
440
|
+
o.publish("onBlur", t, O, _), E(t);
|
|
438
441
|
}, []);
|
|
439
|
-
return
|
|
440
|
-
const
|
|
442
|
+
return Er(() => {
|
|
443
|
+
const y = f(t, { shouldUnRegister: l });
|
|
441
444
|
return () => {
|
|
442
|
-
|
|
445
|
+
y && y(), m.current && m.current();
|
|
443
446
|
};
|
|
444
|
-
}, [
|
|
445
|
-
{ ref:
|
|
447
|
+
}, [l, t]), new Proxy(
|
|
448
|
+
{ ref: R, name: t, defaultValue: a, value: v, onChange: S, onBlur: $, fieldState: C },
|
|
446
449
|
{
|
|
447
|
-
get(
|
|
448
|
-
return typeof
|
|
449
|
-
|
|
450
|
-
})), Reflect.get(
|
|
450
|
+
get(y, _, O) {
|
|
451
|
+
return typeof _ == "string" && _ === "fieldState" && (m.current && m.current(), m.current = c.subscribe(`fieldStates.${t}`, () => {
|
|
452
|
+
A(b({ name: `fieldStates.${t}` }));
|
|
453
|
+
})), Reflect.get(y, _, O);
|
|
451
454
|
}
|
|
452
455
|
}
|
|
453
456
|
);
|
|
@@ -455,344 +458,333 @@ const y = () => {
|
|
|
455
458
|
name: s,
|
|
456
459
|
control: t,
|
|
457
460
|
shouldUnRegister: u,
|
|
458
|
-
defaultValue:
|
|
459
|
-
render: c = ({ ref: f, name: o, defaultValue:
|
|
461
|
+
defaultValue: l,
|
|
462
|
+
render: c = ({ ref: f, name: o, defaultValue: b, value: E, onChange: R, onBlur: m, fieldState: a }) => null
|
|
460
463
|
}) => {
|
|
461
|
-
const f =
|
|
464
|
+
const f = Yr({ name: s, defaultValue: l, shouldUnRegister: u, control: t });
|
|
462
465
|
return c(f);
|
|
463
|
-
},
|
|
464
|
-
const [s, t] =
|
|
466
|
+
}, Mr = () => {
|
|
467
|
+
const [s, t] = lr(), u = h(() => t((/* @__PURE__ */ new Date()).toString()), []);
|
|
465
468
|
return [s, u];
|
|
466
469
|
}, Lr = () => {
|
|
467
|
-
const [, s] =
|
|
468
|
-
return
|
|
470
|
+
const [, s] = lr({});
|
|
471
|
+
return h(() => s({}), []);
|
|
469
472
|
}, Vr = ({ channels: s, getWatchValue: t }) => {
|
|
470
|
-
const u = Lr(),
|
|
473
|
+
const u = Lr(), l = h((o, b = "onChange") => {
|
|
471
474
|
if (!o)
|
|
472
475
|
return s.subscribeWatch("values", () => u()), t();
|
|
473
476
|
if (typeof o == "string") {
|
|
474
|
-
let
|
|
475
|
-
|
|
476
|
-
|
|
477
|
+
let E = G(o);
|
|
478
|
+
b === "onBlur" && (E = `blur.${E}`), s.subscribeWatch(E, (R, m) => {
|
|
479
|
+
R !== m && u();
|
|
477
480
|
});
|
|
478
481
|
}
|
|
479
|
-
return Array.isArray(o) && o.forEach((
|
|
480
|
-
let
|
|
481
|
-
|
|
482
|
-
|
|
482
|
+
return Array.isArray(o) && o.forEach((E) => {
|
|
483
|
+
let R = G(E);
|
|
484
|
+
b === "onBlur" && (R = `blur.${R}`), s.subscribeWatch(R, (m, a) => {
|
|
485
|
+
m !== a && u();
|
|
483
486
|
});
|
|
484
487
|
}), t({ name: o });
|
|
485
|
-
}, []), c =
|
|
486
|
-
if (typeof
|
|
488
|
+
}, []), c = h(({ name: o, compute: b, setValue: E, mode: R = "onChange" }) => {
|
|
489
|
+
if (typeof b == "function")
|
|
487
490
|
return s.subscribe("values", () => {
|
|
488
|
-
const a = t({ compute:
|
|
489
|
-
|
|
491
|
+
const a = t({ compute: b });
|
|
492
|
+
E(a);
|
|
490
493
|
});
|
|
491
494
|
if (!o)
|
|
492
495
|
return s.subscribe("values", () => {
|
|
493
|
-
|
|
496
|
+
E(t());
|
|
494
497
|
});
|
|
495
498
|
if (typeof o == "string") {
|
|
496
|
-
let
|
|
497
|
-
return
|
|
499
|
+
let m = G(o);
|
|
500
|
+
return R === "onBlur" && (m = `blur.${m}`), s.subscribe(m, () => {
|
|
498
501
|
const v = t({ name: o });
|
|
499
|
-
|
|
502
|
+
E(v);
|
|
500
503
|
});
|
|
501
504
|
}
|
|
502
505
|
if (Array.isArray(o)) {
|
|
503
|
-
const
|
|
506
|
+
const m = [];
|
|
504
507
|
return o.forEach((a) => {
|
|
505
|
-
let v =
|
|
506
|
-
|
|
507
|
-
const
|
|
508
|
-
const
|
|
509
|
-
|
|
508
|
+
let v = G(a);
|
|
509
|
+
R === "onBlur" && (v = `blur.${v}`);
|
|
510
|
+
const C = s.subscribe(v, () => {
|
|
511
|
+
const A = t({ name: o });
|
|
512
|
+
E(A);
|
|
510
513
|
});
|
|
511
|
-
|
|
512
|
-
}), () =>
|
|
514
|
+
m.push(C);
|
|
515
|
+
}), () => m.forEach((a) => a());
|
|
513
516
|
}
|
|
514
517
|
throw new Error("Parameters of name must be string or array of string or compute must be a function");
|
|
515
|
-
}, []), f =
|
|
518
|
+
}, []), f = h((o, b, E = "onChange") => {
|
|
516
519
|
if (!o)
|
|
517
|
-
return s.subscribe("values", () =>
|
|
520
|
+
return s.subscribe("values", () => b(t()));
|
|
518
521
|
if (["onChange", "onBlur"].includes(o))
|
|
519
|
-
return s.subscribe(o,
|
|
522
|
+
return s.subscribe(o, b);
|
|
520
523
|
if (typeof o == "string") {
|
|
521
|
-
let
|
|
522
|
-
return
|
|
524
|
+
let R = G(o);
|
|
525
|
+
return E === "onBlur" && (R = `blur.${R}`), s.subscribe(R, () => b(t({ name: o })));
|
|
523
526
|
}
|
|
524
527
|
if (Array.isArray(o)) {
|
|
525
|
-
const
|
|
526
|
-
return o.forEach((
|
|
527
|
-
let a =
|
|
528
|
-
|
|
528
|
+
const R = [];
|
|
529
|
+
return o.forEach((m) => {
|
|
530
|
+
let a = G(m);
|
|
531
|
+
E === "onBlur" && (a = `blur.${a}`);
|
|
529
532
|
const v = s.subscribe(a, () => {
|
|
530
|
-
|
|
533
|
+
b(t({ name: o }));
|
|
531
534
|
});
|
|
532
|
-
|
|
533
|
-
}), () =>
|
|
535
|
+
R.push(v);
|
|
536
|
+
}), () => R.forEach((m) => m());
|
|
534
537
|
}
|
|
535
538
|
throw new Error("Parameters of name must be string or array of string");
|
|
536
539
|
}, []);
|
|
537
|
-
return { watch:
|
|
540
|
+
return { watch: l, registerHookWatcher: c, getWatchValue: t, subscribe: f };
|
|
538
541
|
}, Ur = ({ getWatchValue: s }) => {
|
|
539
|
-
const t =
|
|
542
|
+
const t = Y(/* @__PURE__ */ new Map()), u = Y(/* @__PURE__ */ new Map()), l = h(() => u.current, []), c = h(() => t.current, []), f = h(() => {
|
|
540
543
|
t.current.clear(), u.current.clear();
|
|
541
|
-
}, []), o = (a) => a.replace("values.", "").replace("values", ""),
|
|
542
|
-
const
|
|
543
|
-
|
|
544
|
-
const
|
|
544
|
+
}, []), o = (a) => a.replace("values.", "").replace("values", ""), b = h((a, ...v) => {
|
|
545
|
+
const C = a.split(".");
|
|
546
|
+
C.forEach((A, S) => {
|
|
547
|
+
const $ = C.slice(0, C.length - S).join("."), y = t.current.get($), _ = u.current.get($);
|
|
545
548
|
if (S > 0) {
|
|
546
|
-
const
|
|
547
|
-
v = [
|
|
549
|
+
const O = v[0], P = s({ name: o($) });
|
|
550
|
+
v = [M(P, a.replace($, ""), O)];
|
|
548
551
|
}
|
|
549
|
-
|
|
552
|
+
y && y.forEach((O) => O(...v)), _ && _.forEach((O) => O(...v));
|
|
550
553
|
});
|
|
551
|
-
}, []),
|
|
552
|
-
const
|
|
554
|
+
}, []), E = h((a, { trickle: v = !1, bubble: C = !1 }) => {
|
|
555
|
+
const A = a.split(".");
|
|
553
556
|
let S = [s({ name: o(a) })];
|
|
554
|
-
|
|
555
|
-
const
|
|
556
|
-
if (
|
|
557
|
-
const x = S[0],
|
|
558
|
-
S = [
|
|
557
|
+
A.forEach(($, y) => {
|
|
558
|
+
const _ = A.slice(0, A.length - y).join("."), O = t.current.get(_), P = u.current.get(_);
|
|
559
|
+
if (y > 0 && C) {
|
|
560
|
+
const x = S[0], q = s({ name: o(_) });
|
|
561
|
+
S = [M(q, a.replace(_, ""), x)];
|
|
559
562
|
}
|
|
560
|
-
|
|
561
|
-
}), v && (t.current.forEach((
|
|
562
|
-
|
|
563
|
-
}), u.current.forEach((
|
|
564
|
-
|
|
563
|
+
O && (y === 0 || C) && O.forEach((x) => x(...S)), P && (y === 0 || C) && P.forEach((x) => x(...S));
|
|
564
|
+
}), v && (t.current.forEach(($, y) => {
|
|
565
|
+
y.startsWith(a) && $.forEach((_) => _(s({ name: o(y) })));
|
|
566
|
+
}), u.current.forEach(($, y) => {
|
|
567
|
+
y.startsWith(a) && $.forEach((_) => _(s({ name: o(y) })));
|
|
565
568
|
}));
|
|
566
|
-
}, []),
|
|
567
|
-
var
|
|
568
|
-
return (
|
|
569
|
-
}), []),
|
|
569
|
+
}, []), R = h((a, v) => (t.current.has(a) || t.current.set(a, /* @__PURE__ */ new Set()), t.current.get(a).add(v), () => {
|
|
570
|
+
var C;
|
|
571
|
+
return (C = t.current.get(a)) == null ? void 0 : C.delete(v);
|
|
572
|
+
}), []), m = h((a, v) => {
|
|
570
573
|
u.current.has(a) || (u.current.set(a, /* @__PURE__ */ new Set()), u.current.get(a).add(v));
|
|
571
574
|
}, []);
|
|
572
|
-
return { reset: f, publish:
|
|
573
|
-
}, zr = ({ defaultValues: s =
|
|
574
|
-
const [
|
|
575
|
-
if (typeof n[
|
|
576
|
-
return { ...
|
|
577
|
-
const k = { ...r ? {} :
|
|
578
|
-
return { ...
|
|
579
|
-
}, {}), []),
|
|
580
|
-
(r = {}, { clearCustomFormStates: n = !1, clearCustomFieldStates:
|
|
581
|
-
|
|
582
|
-
k(D(a.current, j) ?? "");
|
|
583
|
-
}), m.current = {}, v.current = new Set(l), o.current = /* @__PURE__ */ new Map(), h.current = { ...n ? {} : h.current, ...pr }, R.current = O(d), T.reset(), c();
|
|
575
|
+
return { reset: f, publish: b, subscribe: R, subscribeWatch: m, getEvents: c, getWatchEvents: l, trigger: E };
|
|
576
|
+
}, zr = ({ defaultValues: s = Dr, shouldUnRegister: t = !1, groups: u = [] } = {}) => {
|
|
577
|
+
const [l, c] = Mr(), f = Y(), o = Y({}), b = Y({}), E = Y({ ...pr }), R = Y({ ...s }), m = Y({ ...s }), a = Y(/* @__PURE__ */ new Set()), v = Y(new Set(u)), C = h((r, n = m.current) => Object.keys(n).reduce((i, d) => {
|
|
578
|
+
if (typeof n[d] == "object")
|
|
579
|
+
return { ...i, [d]: C(r, n[d]) };
|
|
580
|
+
const k = { ...r ? {} : b.current[d] || {}, ...br };
|
|
581
|
+
return { ...i, [d]: k };
|
|
582
|
+
}, {}), []), A = h(
|
|
583
|
+
(r = {}, { clearCustomFormStates: n = !1, clearCustomFieldStates: i = !1, groups: d = v.current } = {}) => {
|
|
584
|
+
o.current = {}, m.current = { ...m.current, ...r }, R.current = { ...m.current }, a.current = /* @__PURE__ */ new Set(), v.current = new Set(d), E.current = { ...n ? {} : E.current, ...pr }, b.current = C(i), F.reset(), c();
|
|
584
585
|
},
|
|
585
586
|
[]
|
|
586
|
-
), S =
|
|
587
|
+
), S = h(() => {
|
|
587
588
|
let r = Object.fromEntries(new FormData(f.current));
|
|
588
|
-
|
|
589
|
-
r =
|
|
589
|
+
a.current.forEach((i) => {
|
|
590
|
+
r = M(r, i, D(R.current, i));
|
|
590
591
|
});
|
|
591
|
-
let n = { ...
|
|
592
|
-
return
|
|
593
|
-
}, []),
|
|
594
|
-
(r) =>
|
|
595
|
-
[
|
|
596
|
-
), J =
|
|
592
|
+
let n = { ...R.current, ...r };
|
|
593
|
+
return Wr(n);
|
|
594
|
+
}, []), $ = h((r) => Fr(r.target), []), y = h(() => m.current, []), _ = h(() => a.current, []), O = h((r, n) => n ? Array.isArray(n) ? n.reduce((i, d) => ({ ...i, [d]: D(r, d) }), {}) : D(r, n) : { ...r }, []), P = h((r) => O(R.current, r), [O]), x = h((r) => O(o.current, r), [O]), q = h((r) => O(b.current, r), [O]), H = h(
|
|
595
|
+
(r) => O({ ...E.current, lastReset: l }, r),
|
|
596
|
+
[l]
|
|
597
|
+
), J = h(({ name: r, compute: n } = {}) => !r && !n || r === "values" ? P() : typeof n == "function" ? n(P()) : Array.isArray(r) ? r.reduce((i, d) => ({ ...i, [d]: J({ name: d }) }), {}) : D(
|
|
597
598
|
{
|
|
598
|
-
...
|
|
599
|
-
errors:
|
|
600
|
-
fieldStates:
|
|
599
|
+
...R.current,
|
|
600
|
+
errors: o.current,
|
|
601
|
+
fieldStates: b.current,
|
|
601
602
|
formState: H()
|
|
602
603
|
},
|
|
603
604
|
r
|
|
604
|
-
), []),
|
|
605
|
+
), []), F = Ur({ getWatchValue: J }), { watch: nr, registerHookWatcher: K, subscribe: sr } = Vr({ getWatchValue: J, channels: F }), fr = h((r, n) => {
|
|
605
606
|
typeof n == "function" && (n = n(H(r)));
|
|
606
|
-
const
|
|
607
|
-
|
|
608
|
-
}, []), X =
|
|
607
|
+
const i = E.current, d = D(i, r);
|
|
608
|
+
d !== n && (E.current = M(E.current, r, n), F.publish(`formState.${r}`, n, d));
|
|
609
|
+
}, []), X = h((r, n) => {
|
|
609
610
|
typeof n == "function" && (n = n(x(r))), W(r, "error", n);
|
|
610
|
-
}, []), z =
|
|
611
|
+
}, []), z = h((r) => {
|
|
611
612
|
W(r, "error", null);
|
|
612
|
-
}, []),
|
|
613
|
-
|
|
614
|
-
}, []), W =
|
|
613
|
+
}, []), or = h(() => {
|
|
614
|
+
E.current.isError && Object.keys(o.current).forEach((r) => z(r));
|
|
615
|
+
}, []), W = h((r, n, i) => {
|
|
615
616
|
try {
|
|
616
|
-
if (typeof
|
|
617
|
-
if (typeof
|
|
618
|
-
Object.keys(
|
|
619
|
-
W(`${r}.${
|
|
617
|
+
if (typeof i == "function" && (i = i(q(r))), v.current.has(r))
|
|
618
|
+
if (typeof i == "object" && i !== null) {
|
|
619
|
+
Object.keys(i).forEach((N) => {
|
|
620
|
+
W(`${r}.${N}`, n, i[N]);
|
|
620
621
|
});
|
|
621
622
|
return;
|
|
622
623
|
} else
|
|
623
624
|
return console.error(
|
|
624
625
|
`Cannot set primitive value for nested parent field "${r}". Please set value for its children or provide an object.`
|
|
625
626
|
);
|
|
626
|
-
const
|
|
627
|
-
if (k !==
|
|
628
|
-
if (
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
const
|
|
634
|
-
if (
|
|
635
|
-
const
|
|
636
|
-
|
|
627
|
+
const d = D(b.current, r) || { ...br }, k = D(d, n);
|
|
628
|
+
if (k !== i) {
|
|
629
|
+
if (b.current = M(b.current, `${r}.${n}`, i), F.publish(`fieldStates.${r}.${n}`, i, k), n === "error") {
|
|
630
|
+
const N = D(o.current, r), B = i || null;
|
|
631
|
+
N !== B && (o.current = M(o.current, r, B), F.publish(`errors.${r}`, B, N));
|
|
632
|
+
const U = Cr(v.current, o.current);
|
|
633
|
+
E.current.errorFields = U, F.publish("formState.errorFields", U);
|
|
634
|
+
const ar = U.length > 0;
|
|
635
|
+
if (E.current.isError !== ar) {
|
|
636
|
+
const gr = E.current.isError;
|
|
637
|
+
E.current.isError = ar, F.publish("formState.isError", ar, gr);
|
|
637
638
|
}
|
|
638
639
|
}
|
|
639
640
|
if (n === "isDirty") {
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
const
|
|
643
|
-
if (
|
|
644
|
-
const
|
|
645
|
-
|
|
641
|
+
const N = _r(v.current, b.current);
|
|
642
|
+
E.current.dirtyFields = N, F.publish("formState.dirtyFields", N);
|
|
643
|
+
const B = N.length > 0;
|
|
644
|
+
if (E.current.isDirty !== B) {
|
|
645
|
+
const U = E.current.isDirty;
|
|
646
|
+
E.current.isDirty = B, F.publish("formState.isDirty", B, U);
|
|
646
647
|
}
|
|
647
648
|
}
|
|
648
649
|
if (n === "isTouched") {
|
|
649
|
-
const
|
|
650
|
-
|
|
650
|
+
const N = Or(v.current, b.current);
|
|
651
|
+
E.current.touchedFields = N, F.publish("formState.touchedFields", N);
|
|
651
652
|
}
|
|
652
653
|
}
|
|
653
|
-
} catch (
|
|
654
|
-
console.log(
|
|
654
|
+
} catch (d) {
|
|
655
|
+
console.log(d);
|
|
655
656
|
}
|
|
656
|
-
}, []),
|
|
657
|
-
W(r, "isDirty", !1), W(r, "isTouched", !1), W(r, "error",
|
|
658
|
-
}, []),
|
|
657
|
+
}, []), ur = h((r) => {
|
|
658
|
+
W(r, "isDirty", !1), W(r, "isTouched", !1), W(r, "error", null);
|
|
659
|
+
}, []), cr = h((r) => {
|
|
659
660
|
const n = Fr(r.target);
|
|
660
661
|
n ? X(r.target.name, n) : z(r.target.name);
|
|
661
|
-
}, []), e =
|
|
662
|
-
if (typeof n == "function" && (n = n(
|
|
663
|
-
typeof n == "object" && n !== null ? Object.keys(n).forEach((
|
|
664
|
-
e(`${r}.${
|
|
662
|
+
}, []), e = h((r, n, { shouldDirty: i = !0, shouldOnChange: d = !0 } = {}) => {
|
|
663
|
+
if (typeof n == "function" && (n = n(P(r))), v.current.has(r)) {
|
|
664
|
+
typeof n == "object" && n !== null ? Object.keys(n).forEach((B) => {
|
|
665
|
+
e(`${r}.${B}`, n[B], { shouldDirty: i, shouldOnChange: d });
|
|
665
666
|
}) : console.error(
|
|
666
667
|
`Cannot set primitive value for nested parent field "${r}". Please set value for its children or provide an object.`
|
|
667
668
|
);
|
|
668
669
|
return;
|
|
669
670
|
}
|
|
670
|
-
const k = D(
|
|
671
|
+
const k = D(R.current, r);
|
|
671
672
|
if (n === k) return;
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
const I = r.split("."), K = I.findIndex(
|
|
676
|
-
(Er, Cr) => !v.current.has(I.slice(0, Cr + 1).join("."))
|
|
673
|
+
if (R.current = M(R.current, r, n), F.publish(`values.${r}`, n, k), r.includes(".")) {
|
|
674
|
+
const B = r.split("."), U = B.findIndex(
|
|
675
|
+
(ar, gr) => !v.current.has(B.slice(0, gr + 1).join("."))
|
|
677
676
|
);
|
|
678
|
-
|
|
677
|
+
U !== -1 && (r = B.slice(0, U + 1).join("."));
|
|
679
678
|
}
|
|
680
679
|
n && W(r, "isTouched", !0);
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
}, []), g =
|
|
680
|
+
const N = n !== (D(m.current, r) || "");
|
|
681
|
+
i && W(r, "isDirty", N), d && F.publish("onChange", r, n, k);
|
|
682
|
+
}, []), g = h((r) => {
|
|
684
683
|
const n = r.split(".");
|
|
685
|
-
let
|
|
686
|
-
n.forEach((
|
|
687
|
-
k < n.length - 1 && (
|
|
684
|
+
let i = "";
|
|
685
|
+
n.forEach((d, k) => {
|
|
686
|
+
k < n.length - 1 && (i = i ? `${i}.${d}` : d, v.current.add(i));
|
|
688
687
|
});
|
|
689
|
-
}, []),
|
|
688
|
+
}, []), T = h((r) => {
|
|
690
689
|
Array.isArray(r) ? r.forEach((n) => g(n + ".")) : g(r + ".");
|
|
691
|
-
}, []),
|
|
692
|
-
(r = "",
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
return;
|
|
696
|
-
}
|
|
697
|
-
return o.current.set(r, n), R.current = Y(R.current, r, { ...br }), r.includes(".") && g(r), () => {
|
|
698
|
-
d && o.current.delete(r);
|
|
699
|
-
};
|
|
700
|
-
},
|
|
690
|
+
}, []), w = h(
|
|
691
|
+
(r = "", { shouldUnRegister: n = t } = {}) => r ? (a.current.add(r), b.current = M(b.current, r, { ...br }), r.includes(".") && g(r), () => {
|
|
692
|
+
n && (e(r, void 0, { shouldDirty: !1, shouldOnChange: !1 }), a.current.delete(r));
|
|
693
|
+
}) : console.error("Controller must have a name"),
|
|
701
694
|
[]
|
|
702
|
-
),
|
|
703
|
-
|
|
704
|
-
if (!j)
|
|
695
|
+
), L = h((r, { keepError: n, keepDirty: i, keepTouched: d, defaultValue: k }) => {
|
|
696
|
+
if (!a.current.has(r))
|
|
705
697
|
throw new Error(`Cannot reset "${r}" because it's uncontrolled field`);
|
|
706
|
-
|
|
707
|
-
}, []),
|
|
708
|
-
if (!r)
|
|
698
|
+
m.current = M(m.current, r, k), R.current = M(R.current, r, k), F.publish(`values.${r}`, k), n || z(r), i || W(r, "isDirty", !1), d || W(r, "isTouched", !1);
|
|
699
|
+
}, []), I = h((r, { bubble: n, trickle: i } = {}) => {
|
|
700
|
+
if (!r) {
|
|
701
|
+
F.trigger("values", { bubble: n, trickle: i ?? !0 }), F.trigger("blur.values", { bubble: n, trickle: i ?? !0 });
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
709
704
|
if (!Array.isArray(r)) {
|
|
710
|
-
const
|
|
711
|
-
|
|
705
|
+
const d = G(r);
|
|
706
|
+
F.trigger(d, { bubble: n, trickle: i }), F.trigger(`blur.${d}`, { bubble: n, trickle: i });
|
|
712
707
|
return;
|
|
713
708
|
}
|
|
714
|
-
r.forEach((
|
|
715
|
-
const k =
|
|
716
|
-
|
|
709
|
+
r.forEach((d) => {
|
|
710
|
+
const k = G(d);
|
|
711
|
+
F.trigger(k, { bubble: n, trickle: i }), F.trigger(`blur.${k}`, { bubble: n, trickle: i });
|
|
717
712
|
});
|
|
718
|
-
}, []), Z =
|
|
719
|
-
|
|
720
|
-
const n =
|
|
721
|
-
Object.keys(n || {}).forEach((
|
|
722
|
-
|
|
713
|
+
}, []), Z = h((r) => {
|
|
714
|
+
F.publish(`blur.values.${r}`, P(r)), F.publish(`blur.errors.${r}`, x(r));
|
|
715
|
+
const n = q(r);
|
|
716
|
+
Object.keys(n || {}).forEach((d) => {
|
|
717
|
+
F.publish(`blur.fieldStates.${r}.${d}`, n[d]);
|
|
723
718
|
});
|
|
724
|
-
const
|
|
725
|
-
Object.keys(
|
|
726
|
-
|
|
719
|
+
const i = H();
|
|
720
|
+
Object.keys(i || {}).forEach((d) => {
|
|
721
|
+
F.publish(`blur.formState.${d}`, i[d]);
|
|
727
722
|
});
|
|
728
|
-
}, []),
|
|
729
|
-
|
|
730
|
-
}, []),
|
|
723
|
+
}, []), Q = h((r, n = P(r)) => {
|
|
724
|
+
F.publish("onBlur", r, n, P()), Z(r);
|
|
725
|
+
}, []), j = hr(
|
|
731
726
|
() => ({
|
|
732
|
-
subscribe:
|
|
733
|
-
reset:
|
|
734
|
-
trigger:
|
|
727
|
+
subscribe: sr,
|
|
728
|
+
reset: A,
|
|
729
|
+
trigger: I,
|
|
735
730
|
reload: c,
|
|
736
|
-
resetField:
|
|
731
|
+
resetField: L,
|
|
737
732
|
setValue: e,
|
|
738
|
-
getValues:
|
|
733
|
+
getValues: P,
|
|
739
734
|
getErrors: x,
|
|
740
|
-
getFieldStates:
|
|
735
|
+
getFieldStates: q,
|
|
741
736
|
getFormState: H,
|
|
742
737
|
setError: X,
|
|
743
738
|
clearError: z,
|
|
744
|
-
clearErrors:
|
|
745
|
-
checkValidity:
|
|
746
|
-
getFieldValidity:
|
|
747
|
-
getDefaultValues:
|
|
739
|
+
clearErrors: or,
|
|
740
|
+
checkValidity: cr,
|
|
741
|
+
getFieldValidity: $,
|
|
742
|
+
getDefaultValues: y,
|
|
748
743
|
setFieldState: W,
|
|
749
|
-
triggerFieldBlur:
|
|
750
|
-
resetFieldState:
|
|
751
|
-
getControlledFields:
|
|
744
|
+
triggerFieldBlur: Q,
|
|
745
|
+
resetFieldState: ur,
|
|
746
|
+
getControlledFields: _,
|
|
752
747
|
setFormState: fr,
|
|
753
|
-
getEvents:
|
|
754
|
-
getWatchEvents:
|
|
755
|
-
addGroups:
|
|
748
|
+
getEvents: F.getEvents,
|
|
749
|
+
getWatchEvents: F.getWatchEvents,
|
|
750
|
+
addGroups: T
|
|
756
751
|
}),
|
|
757
|
-
[
|
|
758
|
-
),
|
|
759
|
-
[...f.current.querySelectorAll("[name]")].forEach((
|
|
760
|
-
const
|
|
761
|
-
|
|
752
|
+
[l]
|
|
753
|
+
), V = h(() => {
|
|
754
|
+
[...f.current.querySelectorAll("[name]")].forEach((i) => {
|
|
755
|
+
const d = i.name || "";
|
|
756
|
+
d.includes(".") && g(d), !i.defaultValue && !a.current.has(d) && D(m.current, d) && (i.defaultValue = D(m.current, d));
|
|
762
757
|
});
|
|
763
758
|
const n = S();
|
|
764
|
-
|
|
765
|
-
}, []),
|
|
759
|
+
R.current = { ...n }, m.current = { ...n };
|
|
760
|
+
}, []), rr = hr(
|
|
766
761
|
() => ({
|
|
767
762
|
ref: f,
|
|
768
|
-
watch:
|
|
769
|
-
actions:
|
|
770
|
-
initForm:
|
|
771
|
-
registerController:
|
|
772
|
-
registerHookWatcher:
|
|
773
|
-
lastReloadedAt:
|
|
763
|
+
watch: nr,
|
|
764
|
+
actions: j,
|
|
765
|
+
initForm: V,
|
|
766
|
+
registerController: w,
|
|
767
|
+
registerHookWatcher: K,
|
|
768
|
+
lastReloadedAt: l,
|
|
774
769
|
loadFormValues: S,
|
|
775
770
|
getWatchValue: J,
|
|
776
771
|
triggerBlurWatchers: Z,
|
|
777
|
-
channels:
|
|
772
|
+
channels: F
|
|
778
773
|
}),
|
|
779
|
-
[
|
|
780
|
-
), dr =
|
|
774
|
+
[l]
|
|
775
|
+
), dr = hr(() => ({ control: rr, actions: j, watch: nr }), [l]);
|
|
781
776
|
return mr(() => {
|
|
782
|
-
f.current &&
|
|
783
|
-
}, [
|
|
784
|
-
|
|
777
|
+
f.current && V();
|
|
778
|
+
}, [l]), mr(() => {
|
|
779
|
+
b.current = C(!1);
|
|
785
780
|
}, []), dr;
|
|
786
|
-
}, Hr = ({ control: s, name: t, compute: u, mode: i }) => {
|
|
787
|
-
const { getWatchValue: c, registerHookWatcher: f } = s || Tr(), o = c({ name: t, compute: u }), [m, R] = sr(o);
|
|
788
|
-
return hr(() => f({ name: t, compute: u, value: m, setValue: R, mode: i }), []), m;
|
|
789
781
|
};
|
|
790
782
|
export {
|
|
791
783
|
Jr as Controller,
|
|
792
784
|
qr as Form,
|
|
793
|
-
|
|
794
|
-
|
|
785
|
+
Wr as restoreFromDotNotation,
|
|
786
|
+
Yr as useController,
|
|
795
787
|
zr as useForm,
|
|
796
788
|
Tr as useFormContext,
|
|
797
|
-
|
|
789
|
+
Ir as useWatch
|
|
798
790
|
};
|