react-simple-formkit 2.2.3 → 2.2.5
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 +49 -40
- package/dist/react-simple-formkit.js +4 -4
- package/dist/react-simple-formkit.mjs +472 -457
- package/dist/react-simple-formkit.umd.js +4 -4
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
var
|
|
1
|
+
import we, { createContext as Te, useContext as _e, useEffect as de, useState as ie, useRef as V, useCallback as b, useMemo as le, useLayoutEffect as be } from "react";
|
|
2
|
+
var ae = { exports: {} }, ee = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
5
5
|
* react-jsx-runtime.production.js
|
|
@@ -10,28 +10,28 @@ var ue = { exports: {} }, K = {};
|
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/
|
|
12
12
|
var he;
|
|
13
|
-
function
|
|
14
|
-
if (he) return
|
|
13
|
+
function ke() {
|
|
14
|
+
if (he) return ee;
|
|
15
15
|
he = 1;
|
|
16
|
-
var t = Symbol.for("react.transitional.element"),
|
|
17
|
-
function
|
|
18
|
-
var
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
for (var
|
|
22
|
-
|
|
23
|
-
} else
|
|
24
|
-
return
|
|
16
|
+
var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
17
|
+
function i(l, h, E) {
|
|
18
|
+
var g = null;
|
|
19
|
+
if (E !== void 0 && (g = "" + E), h.key !== void 0 && (g = "" + h.key), "key" in h) {
|
|
20
|
+
E = {};
|
|
21
|
+
for (var m in h)
|
|
22
|
+
m !== "key" && (E[m] = h[m]);
|
|
23
|
+
} else E = h;
|
|
24
|
+
return h = E.ref, {
|
|
25
25
|
$$typeof: t,
|
|
26
|
-
type:
|
|
27
|
-
key:
|
|
28
|
-
ref:
|
|
29
|
-
props:
|
|
26
|
+
type: l,
|
|
27
|
+
key: g,
|
|
28
|
+
ref: h !== void 0 ? h : null,
|
|
29
|
+
props: E
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return ee.Fragment = n, ee.jsx = i, ee.jsxs = i, ee;
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var re = {};
|
|
35
35
|
/**
|
|
36
36
|
* @license React
|
|
37
37
|
* react-jsx-runtime.development.js
|
|
@@ -41,125 +41,125 @@ var ee = {};
|
|
|
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 Ee;
|
|
45
|
+
function Ae() {
|
|
46
|
+
return Ee || (Ee = 1, process.env.NODE_ENV !== "production" && function() {
|
|
47
47
|
function t(e) {
|
|
48
48
|
if (e == null) return null;
|
|
49
49
|
if (typeof e == "function")
|
|
50
|
-
return e.$$typeof ===
|
|
50
|
+
return e.$$typeof === $ ? null : e.displayName || e.name || null;
|
|
51
51
|
if (typeof e == "string") return e;
|
|
52
52
|
switch (e) {
|
|
53
|
-
case
|
|
53
|
+
case F:
|
|
54
54
|
return "Fragment";
|
|
55
|
-
case
|
|
55
|
+
case x:
|
|
56
56
|
return "Profiler";
|
|
57
|
-
case
|
|
57
|
+
case C:
|
|
58
58
|
return "StrictMode";
|
|
59
|
-
case
|
|
59
|
+
case ne:
|
|
60
60
|
return "Suspense";
|
|
61
|
-
case
|
|
61
|
+
case oe:
|
|
62
62
|
return "SuspenseList";
|
|
63
|
-
case
|
|
63
|
+
case H:
|
|
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
|
|
70
|
+
case o:
|
|
71
71
|
return "Portal";
|
|
72
|
-
case
|
|
72
|
+
case G:
|
|
73
73
|
return (e.displayName || "Context") + ".Provider";
|
|
74
|
-
case M:
|
|
75
|
-
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
|
-
case J:
|
|
77
|
-
var u = e.render;
|
|
78
|
-
return e = e.displayName, e || (e = u.displayName || u.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
|
-
case ne:
|
|
80
|
-
return u = e.displayName || null, u !== null ? u : t(e.type) || "Memo";
|
|
81
74
|
case z:
|
|
82
|
-
|
|
75
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
|
+
case se:
|
|
77
|
+
var a = e.render;
|
|
78
|
+
return e = e.displayName, e || (e = a.displayName || a.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
|
+
case ue:
|
|
80
|
+
return a = e.displayName || null, a !== null ? a : t(e.type) || "Memo";
|
|
81
|
+
case P:
|
|
82
|
+
a = e._payload, e = e._init;
|
|
83
83
|
try {
|
|
84
|
-
return t(e(
|
|
84
|
+
return t(e(a));
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
return null;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function n(e) {
|
|
91
91
|
return "" + e;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function i(e) {
|
|
94
94
|
try {
|
|
95
|
-
|
|
96
|
-
var
|
|
95
|
+
n(e);
|
|
96
|
+
var a = !1;
|
|
97
97
|
} catch {
|
|
98
|
-
|
|
98
|
+
a = !0;
|
|
99
99
|
}
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
var
|
|
103
|
-
return
|
|
104
|
-
|
|
100
|
+
if (a) {
|
|
101
|
+
a = console;
|
|
102
|
+
var R = a.error, T = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
103
|
+
return R.call(
|
|
104
|
+
a,
|
|
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
|
+
T
|
|
107
|
+
), n(e);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
if (e ===
|
|
112
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
110
|
+
function l(e) {
|
|
111
|
+
if (e === F) return "<>";
|
|
112
|
+
if (typeof e == "object" && e !== null && e.$$typeof === P)
|
|
113
113
|
return "<...>";
|
|
114
114
|
try {
|
|
115
|
-
var
|
|
116
|
-
return
|
|
115
|
+
var a = t(e);
|
|
116
|
+
return a ? "<" + a + ">" : "<...>";
|
|
117
117
|
} catch {
|
|
118
118
|
return "<...>";
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function h() {
|
|
122
122
|
var e = W.A;
|
|
123
123
|
return e === null ? null : e.getOwner();
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function E() {
|
|
126
126
|
return Error("react-stack-top-frame");
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
if (
|
|
130
|
-
var
|
|
131
|
-
if (
|
|
128
|
+
function g(e) {
|
|
129
|
+
if (M.call(e, "key")) {
|
|
130
|
+
var a = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
131
|
+
if (a && a.isReactWarning) return !1;
|
|
132
132
|
}
|
|
133
133
|
return e.key !== void 0;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
function
|
|
137
|
-
|
|
135
|
+
function m(e, a) {
|
|
136
|
+
function R() {
|
|
137
|
+
X || (X = !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
|
+
a
|
|
140
140
|
));
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
get:
|
|
142
|
+
R.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
143
|
+
get: R,
|
|
144
144
|
configurable: !0
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function v() {
|
|
148
148
|
var e = t(this.type);
|
|
149
|
-
return
|
|
149
|
+
return Z[e] || (Z[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
|
|
153
|
+
function y(e, a, R, T, j, A, I, L) {
|
|
154
|
+
return R = A.ref, e = {
|
|
155
155
|
$$typeof: c,
|
|
156
156
|
type: e,
|
|
157
|
-
key:
|
|
157
|
+
key: a,
|
|
158
158
|
props: A,
|
|
159
|
-
_owner:
|
|
160
|
-
}, (
|
|
159
|
+
_owner: j
|
|
160
|
+
}, (R !== void 0 ? R : null) !== null ? Object.defineProperty(e, "ref", {
|
|
161
161
|
enumerable: !1,
|
|
162
|
-
get:
|
|
162
|
+
get: v
|
|
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,
|
|
@@ -182,220 +182,220 @@ function _e() {
|
|
|
182
182
|
value: L
|
|
183
183
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
var
|
|
187
|
-
if (
|
|
188
|
-
if (
|
|
189
|
-
if (
|
|
190
|
-
for (
|
|
191
|
-
|
|
192
|
-
Object.freeze && Object.freeze(
|
|
185
|
+
function f(e, a, R, T, j, A, I, L) {
|
|
186
|
+
var _ = a.children;
|
|
187
|
+
if (_ !== void 0)
|
|
188
|
+
if (T)
|
|
189
|
+
if (Y(_)) {
|
|
190
|
+
for (T = 0; T < _.length; T++)
|
|
191
|
+
d(_[T]);
|
|
192
|
+
Object.freeze && Object.freeze(_);
|
|
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
|
|
198
|
-
if (
|
|
199
|
-
|
|
200
|
-
var
|
|
201
|
-
return
|
|
197
|
+
else d(_);
|
|
198
|
+
if (M.call(a, "key")) {
|
|
199
|
+
_ = t(e);
|
|
200
|
+
var D = Object.keys(a).filter(function(ce) {
|
|
201
|
+
return ce !== "key";
|
|
202
202
|
});
|
|
203
|
-
|
|
203
|
+
T = 0 < D.length ? "{key: someKey, " + D.join(": ..., ") + ": ...}" : "{key: someKey}", K[_ + T] || (D = 0 < D.length ? "{" + D.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
|
+
T,
|
|
211
|
+
_,
|
|
212
|
+
D,
|
|
213
|
+
_
|
|
214
|
+
), K[_ + T] = !0);
|
|
215
215
|
}
|
|
216
|
-
if (
|
|
217
|
-
|
|
218
|
-
for (var
|
|
219
|
-
|
|
220
|
-
} else
|
|
221
|
-
return
|
|
222
|
-
|
|
216
|
+
if (_ = null, R !== void 0 && (i(R), _ = "" + R), g(a) && (i(a.key), _ = "" + a.key), "key" in a) {
|
|
217
|
+
R = {};
|
|
218
|
+
for (var N in a)
|
|
219
|
+
N !== "key" && (R[N] = a[N]);
|
|
220
|
+
} else R = a;
|
|
221
|
+
return _ && m(
|
|
222
|
+
R,
|
|
223
223
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
224
|
-
),
|
|
224
|
+
), y(
|
|
225
225
|
e,
|
|
226
|
-
|
|
226
|
+
_,
|
|
227
227
|
A,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
228
|
+
j,
|
|
229
|
+
h(),
|
|
230
|
+
R,
|
|
231
231
|
I,
|
|
232
232
|
L
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function d(e) {
|
|
236
236
|
typeof e == "object" && e !== null && e.$$typeof === c && e._store && (e._store.validated = 1);
|
|
237
237
|
}
|
|
238
|
-
var
|
|
238
|
+
var u = we, c = Symbol.for("react.transitional.element"), o = Symbol.for("react.portal"), F = Symbol.for("react.fragment"), C = Symbol.for("react.strict_mode"), x = Symbol.for("react.profiler"), z = Symbol.for("react.consumer"), G = Symbol.for("react.context"), se = Symbol.for("react.forward_ref"), ne = Symbol.for("react.suspense"), oe = Symbol.for("react.suspense_list"), ue = Symbol.for("react.memo"), P = Symbol.for("react.lazy"), H = Symbol.for("react.activity"), $ = Symbol.for("react.client.reference"), W = u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, M = Object.prototype.hasOwnProperty, Y = Array.isArray, B = console.createTask ? console.createTask : function() {
|
|
239
239
|
return null;
|
|
240
240
|
};
|
|
241
|
-
|
|
241
|
+
u = {
|
|
242
242
|
"react-stack-bottom-frame": function(e) {
|
|
243
243
|
return e();
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
|
-
var
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
)(),
|
|
250
|
-
|
|
246
|
+
var X, Z = {}, Q = u["react-stack-bottom-frame"].bind(
|
|
247
|
+
u,
|
|
248
|
+
E
|
|
249
|
+
)(), w = B(l(E)), K = {};
|
|
250
|
+
re.Fragment = F, re.jsx = function(e, a, R, T, j) {
|
|
251
251
|
var A = 1e4 > W.recentlyCreatedOwnerStacks++;
|
|
252
|
-
return
|
|
252
|
+
return f(
|
|
253
253
|
e,
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
a,
|
|
255
|
+
R,
|
|
256
256
|
!1,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
A ? Error("react-stack-top-frame") :
|
|
260
|
-
A ?
|
|
257
|
+
T,
|
|
258
|
+
j,
|
|
259
|
+
A ? Error("react-stack-top-frame") : Q,
|
|
260
|
+
A ? B(l(e)) : w
|
|
261
261
|
);
|
|
262
|
-
},
|
|
262
|
+
}, re.jsxs = function(e, a, R, T, j) {
|
|
263
263
|
var A = 1e4 > W.recentlyCreatedOwnerStacks++;
|
|
264
|
-
return
|
|
264
|
+
return f(
|
|
265
265
|
e,
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
a,
|
|
267
|
+
R,
|
|
268
268
|
!0,
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
A ? Error("react-stack-top-frame") :
|
|
272
|
-
A ?
|
|
269
|
+
T,
|
|
270
|
+
j,
|
|
271
|
+
A ? Error("react-stack-top-frame") : Q,
|
|
272
|
+
A ? B(l(e)) : w
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
|
-
}()),
|
|
275
|
+
}()), re;
|
|
276
276
|
}
|
|
277
|
-
var
|
|
278
|
-
function
|
|
279
|
-
return
|
|
277
|
+
var ge;
|
|
278
|
+
function Oe() {
|
|
279
|
+
return ge || (ge = 1, process.env.NODE_ENV === "production" ? ae.exports = ke() : ae.exports = Ae()), ae.exports;
|
|
280
280
|
}
|
|
281
|
-
var me =
|
|
282
|
-
const
|
|
283
|
-
},
|
|
281
|
+
var me = Oe();
|
|
282
|
+
const p = () => {
|
|
283
|
+
}, pe = Te({
|
|
284
284
|
ref: null,
|
|
285
|
-
watch:
|
|
285
|
+
watch: p,
|
|
286
286
|
actions: {
|
|
287
|
-
reset:
|
|
288
|
-
resetField:
|
|
289
|
-
setValue:
|
|
290
|
-
getValues:
|
|
291
|
-
getErrors:
|
|
292
|
-
getFieldStates:
|
|
293
|
-
getFormStates:
|
|
294
|
-
setError:
|
|
295
|
-
clearError:
|
|
296
|
-
clearErrors:
|
|
297
|
-
checkValidity:
|
|
298
|
-
getNumberFields:
|
|
299
|
-
getFieldValidity:
|
|
300
|
-
getDefaultValues:
|
|
301
|
-
setFieldState:
|
|
302
|
-
resetFieldState:
|
|
303
|
-
getControlledFields:
|
|
287
|
+
reset: p,
|
|
288
|
+
resetField: p,
|
|
289
|
+
setValue: p,
|
|
290
|
+
getValues: p,
|
|
291
|
+
getErrors: p,
|
|
292
|
+
getFieldStates: p,
|
|
293
|
+
getFormStates: p,
|
|
294
|
+
setError: p,
|
|
295
|
+
clearError: p,
|
|
296
|
+
clearErrors: p,
|
|
297
|
+
checkValidity: p,
|
|
298
|
+
getNumberFields: p,
|
|
299
|
+
getFieldValidity: p,
|
|
300
|
+
getDefaultValues: p,
|
|
301
|
+
setFieldState: p,
|
|
302
|
+
resetFieldState: p,
|
|
303
|
+
getControlledFields: p
|
|
304
304
|
},
|
|
305
|
-
registerController:
|
|
306
|
-
registerHookWatcher:
|
|
307
|
-
lastReloadedAt:
|
|
308
|
-
loadFormValues:
|
|
309
|
-
getWatchValue:
|
|
305
|
+
registerController: p,
|
|
306
|
+
registerHookWatcher: p,
|
|
307
|
+
lastReloadedAt: p,
|
|
308
|
+
loadFormValues: p,
|
|
309
|
+
getWatchValue: p,
|
|
310
310
|
channels: {}
|
|
311
|
-
}),
|
|
311
|
+
}), ye = () => _e(pe), Le = ({
|
|
312
312
|
id: t,
|
|
313
|
-
control:
|
|
314
|
-
method:
|
|
315
|
-
action:
|
|
316
|
-
children:
|
|
317
|
-
onSubmit:
|
|
313
|
+
control: n,
|
|
314
|
+
method: i,
|
|
315
|
+
action: l,
|
|
316
|
+
children: h,
|
|
317
|
+
onSubmit: E = () => {
|
|
318
318
|
},
|
|
319
|
-
onInput:
|
|
319
|
+
onInput: g = () => {
|
|
320
320
|
},
|
|
321
|
-
onChange:
|
|
321
|
+
onChange: m = () => {
|
|
322
322
|
},
|
|
323
|
-
onBlur:
|
|
323
|
+
onBlur: v = () => {
|
|
324
324
|
},
|
|
325
|
-
onReset:
|
|
325
|
+
onReset: y = () => {
|
|
326
326
|
},
|
|
327
|
-
numberFields:
|
|
328
|
-
className:
|
|
329
|
-
...
|
|
327
|
+
numberFields: f = [],
|
|
328
|
+
className: d,
|
|
329
|
+
...u
|
|
330
330
|
}) => (de(() => {
|
|
331
|
-
const c =
|
|
331
|
+
const c = n.channels.subscribe("onChange", m), o = n.channels.subscribe("onBlur", v);
|
|
332
332
|
return () => {
|
|
333
|
-
c(),
|
|
333
|
+
c(), o();
|
|
334
334
|
};
|
|
335
|
-
}, [
|
|
335
|
+
}, [n.lastReloadedAt]), /* @__PURE__ */ me.jsx(pe.Provider, { value: n, children: /* @__PURE__ */ me.jsx(
|
|
336
336
|
"form",
|
|
337
337
|
{
|
|
338
338
|
id: t,
|
|
339
|
-
ref:
|
|
340
|
-
action:
|
|
341
|
-
method:
|
|
342
|
-
className:
|
|
343
|
-
onInput:
|
|
339
|
+
ref: n.ref,
|
|
340
|
+
action: l,
|
|
341
|
+
method: i,
|
|
342
|
+
className: d,
|
|
343
|
+
onInput: g,
|
|
344
344
|
onSubmit: (c) => {
|
|
345
|
-
|
|
346
|
-
const
|
|
347
|
-
|
|
345
|
+
i || c.preventDefault();
|
|
346
|
+
const o = n.loadFormValues();
|
|
347
|
+
E(o);
|
|
348
348
|
},
|
|
349
349
|
onChange: (c) => {
|
|
350
|
-
const
|
|
351
|
-
!
|
|
350
|
+
const o = c.target.name;
|
|
351
|
+
!o || n.actions.getControlledFields().has(o) || n.actions.setValue(o, c.target.value);
|
|
352
352
|
},
|
|
353
353
|
onBlur: (c) => {
|
|
354
|
-
const
|
|
355
|
-
if (!
|
|
356
|
-
const
|
|
357
|
-
|
|
354
|
+
const o = c.target.name;
|
|
355
|
+
if (!o || n.actions.getControlledFields().has(o)) return;
|
|
356
|
+
const F = c.target.value;
|
|
357
|
+
n.channels.publish("onBlur", o, F, n.actions.getValues());
|
|
358
358
|
},
|
|
359
359
|
onReset: (c) => {
|
|
360
|
-
|
|
360
|
+
n.actions.reset(), y(c);
|
|
361
361
|
},
|
|
362
|
-
...
|
|
363
|
-
children:
|
|
362
|
+
...u,
|
|
363
|
+
children: h
|
|
364
364
|
},
|
|
365
|
-
|
|
366
|
-
) })),
|
|
367
|
-
const { getWatchValue:
|
|
365
|
+
n.lastReloadedAt
|
|
366
|
+
) })), Ce = ({ control: t, name: n, compute: i }) => {
|
|
367
|
+
const { getWatchValue: l, registerHookWatcher: h } = t || ye(), E = l({ name: n, compute: i }), [g, m] = ie(E);
|
|
368
368
|
return de(() => {
|
|
369
|
-
const
|
|
370
|
-
return () =>
|
|
371
|
-
}, []),
|
|
372
|
-
},
|
|
373
|
-
const { actions:
|
|
374
|
-
(
|
|
375
|
-
var
|
|
376
|
-
let
|
|
377
|
-
(
|
|
369
|
+
const v = h({ name: n, compute: i, value: g, setValue: m });
|
|
370
|
+
return () => v.forEach((y) => y());
|
|
371
|
+
}, []), g;
|
|
372
|
+
}, Pe = ({ name: t, defaultValue: n }) => {
|
|
373
|
+
const { actions: i, registerController: l, channels: h } = ye(), E = V(), g = i.getDefaultValues()[t] || n || "", [m, v] = ie(g), y = Ce({ name: `fieldStates.${t}` }), f = b(
|
|
374
|
+
(u, { shouldDirty: c = !0, shouldOnChange: o = !0 } = {}) => {
|
|
375
|
+
var C, x;
|
|
376
|
+
let F = u;
|
|
377
|
+
(C = u == null ? void 0 : u.target) != null && C.value && (F = u.target.value), (x = u == null ? void 0 : u.target) != null && x.checked && (F = u.target.checked + ""), v(F), i.setValue(t, F, { shouldDirty: c, shouldOnChange: o });
|
|
378
378
|
},
|
|
379
|
-
[
|
|
380
|
-
),
|
|
381
|
-
const c =
|
|
382
|
-
|
|
379
|
+
[i.setValue]
|
|
380
|
+
), d = b((u) => {
|
|
381
|
+
const c = i.getValues(), o = u ?? c[t];
|
|
382
|
+
h.publish("onBlur", t, o, c);
|
|
383
383
|
}, []);
|
|
384
|
-
return de(() =>
|
|
385
|
-
},
|
|
384
|
+
return de(() => l(t, v), []), { ref: E, name: t, defaultValue: g, value: m, onChange: f, onBlur: d, fieldState: y };
|
|
385
|
+
}, Ue = ({
|
|
386
386
|
name: t,
|
|
387
|
-
defaultValue:
|
|
388
|
-
render:
|
|
387
|
+
defaultValue: n,
|
|
388
|
+
render: i = ({ ref: l, name: h, defaultValue: E, value: g, onChange: m, onBlur: v, fieldState: y }) => null
|
|
389
389
|
}) => {
|
|
390
|
-
const
|
|
391
|
-
return
|
|
392
|
-
},
|
|
393
|
-
let
|
|
394
|
-
const
|
|
395
|
-
return
|
|
396
|
-
|
|
390
|
+
const l = Pe({ name: t, defaultValue: n });
|
|
391
|
+
return i(l);
|
|
392
|
+
}, je = ["errors", "fieldStates", "formState"], te = (t = {}, n = "") => n.split(".").reduce((i, l) => i && i[l] !== void 0 ? i[l] : void 0, t), ve = (t = {}, n = "", i) => {
|
|
393
|
+
let l = t;
|
|
394
|
+
const h = n.split(".");
|
|
395
|
+
return h.forEach((E, g) => {
|
|
396
|
+
g < h.length - 1 && (l[E] || (l[E] = {}), g === h.length - 2 && (l[E] = { ...l[E] }), l = l[E]), l[E] = i;
|
|
397
397
|
}), t;
|
|
398
|
-
},
|
|
398
|
+
}, J = (t) => je.some((n) => t.startsWith(n)) ? t : "values." + t, xe = [
|
|
399
399
|
"badInput",
|
|
400
400
|
"customError",
|
|
401
401
|
"patternMismatch",
|
|
@@ -406,12 +406,12 @@ const S = () => {
|
|
|
406
406
|
"tooShort",
|
|
407
407
|
"typeMismatch",
|
|
408
408
|
"valueMissing"
|
|
409
|
-
],
|
|
409
|
+
], Re = (t) => {
|
|
410
410
|
typeof t.setCustomValidity == "function" && t.setCustomValidity("");
|
|
411
|
-
let
|
|
412
|
-
if (
|
|
411
|
+
let n = t.validity, i = xe.find((l) => n[l]);
|
|
412
|
+
if (i) return { type: i, message: t.validationMessage };
|
|
413
413
|
};
|
|
414
|
-
class
|
|
414
|
+
class Ne {
|
|
415
415
|
constructor() {
|
|
416
416
|
this.events = /* @__PURE__ */ new Map(), this.watchEvents = /* @__PURE__ */ new Map();
|
|
417
417
|
}
|
|
@@ -421,309 +421,324 @@ class xe {
|
|
|
421
421
|
getEvents() {
|
|
422
422
|
return this.events;
|
|
423
423
|
}
|
|
424
|
-
subscribe(
|
|
425
|
-
return this.events.has(
|
|
426
|
-
var
|
|
427
|
-
return (
|
|
424
|
+
subscribe(n, i) {
|
|
425
|
+
return this.events.has(n) || this.events.set(n, /* @__PURE__ */ new Set()), this.events.get(n).add(i), () => {
|
|
426
|
+
var l;
|
|
427
|
+
return (l = this.events.get(n)) == null ? void 0 : l.delete(i);
|
|
428
428
|
};
|
|
429
429
|
}
|
|
430
|
-
subscribeWatch(
|
|
431
|
-
this.watchEvents.has(
|
|
430
|
+
subscribeWatch(n, i) {
|
|
431
|
+
this.watchEvents.has(n) || (this.watchEvents.set(n, /* @__PURE__ */ new Set()), this.watchEvents.get(n).add(i));
|
|
432
432
|
}
|
|
433
|
-
publish(
|
|
434
|
-
this.events.forEach((
|
|
435
|
-
|
|
436
|
-
}), this.watchEvents.forEach((
|
|
437
|
-
|
|
433
|
+
publish(n, ...i) {
|
|
434
|
+
this.events.forEach((l, h) => {
|
|
435
|
+
n.includes(h) && l.forEach((E) => E(...i));
|
|
436
|
+
}), this.watchEvents.forEach((l, h) => {
|
|
437
|
+
n.includes(h) && l.forEach((E) => E(...i));
|
|
438
438
|
});
|
|
439
439
|
}
|
|
440
440
|
reset() {
|
|
441
441
|
this.events.clear(), this.watchEvents.clear();
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
|
-
const
|
|
445
|
-
const t =
|
|
446
|
-
t.current.publish(
|
|
447
|
-
}, []),
|
|
448
|
-
t.current.subscribeWatch(
|
|
449
|
-
}, []),
|
|
444
|
+
const Ve = () => {
|
|
445
|
+
const t = V(new Ne()), n = b((m, ...v) => {
|
|
446
|
+
t.current.publish(m, ...v);
|
|
447
|
+
}, []), i = b((m, v) => t.current.subscribe(m, v), []), l = b((m, v) => {
|
|
448
|
+
t.current.subscribeWatch(m, v);
|
|
449
|
+
}, []), h = b(() => t.current.getEvents(), []), E = b(() => t.current.getWatchEvents(), []), g = b(() => {
|
|
450
450
|
t.current.reset();
|
|
451
451
|
}, []);
|
|
452
|
-
return { publish:
|
|
453
|
-
},
|
|
454
|
-
const [t,
|
|
455
|
-
return [t,
|
|
452
|
+
return { publish: n, subscribe: i, reset: g, getEvents: h, subscribeWatch: l, getWatchEvents: E };
|
|
453
|
+
}, De = () => {
|
|
454
|
+
const [t, n] = ie(), i = b(() => n((/* @__PURE__ */ new Date()).toString()), []);
|
|
455
|
+
return [t, i];
|
|
456
456
|
}, We = () => {
|
|
457
|
-
const [, t] =
|
|
458
|
-
return
|
|
459
|
-
},
|
|
460
|
-
const
|
|
461
|
-
if (typeof
|
|
462
|
-
if (Array.isArray(
|
|
463
|
-
const
|
|
464
|
-
return
|
|
465
|
-
|
|
466
|
-
}),
|
|
457
|
+
const [, t] = ie({});
|
|
458
|
+
return b(() => t({}), []);
|
|
459
|
+
}, $e = ({ channels: t, getValues: n, getErrors: i, getFieldStates: l, getFormState: h }) => {
|
|
460
|
+
const E = We(), g = b(({ name: f, compute: d }) => {
|
|
461
|
+
if (typeof d == "function") return d(n());
|
|
462
|
+
if (Array.isArray(f)) {
|
|
463
|
+
const u = {};
|
|
464
|
+
return f.forEach((c) => {
|
|
465
|
+
u[c] = g({ name: c });
|
|
466
|
+
}), u;
|
|
467
467
|
}
|
|
468
|
-
return
|
|
468
|
+
return te(
|
|
469
469
|
{
|
|
470
|
-
...
|
|
471
|
-
errors: { ...
|
|
472
|
-
formState: { ...
|
|
473
|
-
fieldStates: { ...
|
|
470
|
+
...n(),
|
|
471
|
+
errors: { ...i() },
|
|
472
|
+
formState: { ...h() },
|
|
473
|
+
fieldStates: { ...l() }
|
|
474
474
|
},
|
|
475
|
-
|
|
475
|
+
f
|
|
476
476
|
);
|
|
477
|
-
}, []),
|
|
478
|
-
if (!
|
|
479
|
-
return t.subscribeWatch("values", () =>
|
|
480
|
-
if (typeof
|
|
481
|
-
const
|
|
482
|
-
return t.subscribeWatch(
|
|
477
|
+
}, []), m = b((f) => {
|
|
478
|
+
if (!f)
|
|
479
|
+
return t.subscribeWatch("values", () => E()), n();
|
|
480
|
+
if (typeof f == "string") {
|
|
481
|
+
const d = J(f);
|
|
482
|
+
return t.subscribeWatch(d, () => E()), g({ name: f });
|
|
483
483
|
}
|
|
484
|
-
if (Array.isArray(
|
|
485
|
-
const
|
|
486
|
-
return
|
|
487
|
-
const c =
|
|
488
|
-
t.subscribeWatch(c, () =>
|
|
489
|
-
}), { ...
|
|
484
|
+
if (Array.isArray(f)) {
|
|
485
|
+
const d = {};
|
|
486
|
+
return f.forEach((u) => {
|
|
487
|
+
const c = J(u);
|
|
488
|
+
t.subscribeWatch(c, () => E()), d[u] = g({ name: u });
|
|
489
|
+
}), { ...d };
|
|
490
490
|
}
|
|
491
491
|
throw new Error("Parameters of watch must be string or array of string");
|
|
492
|
-
}, []),
|
|
493
|
-
if (typeof
|
|
492
|
+
}, []), v = b(({ name: f, compute: d, setValue: u }) => {
|
|
493
|
+
if (typeof d == "function")
|
|
494
494
|
return [t.subscribe("values", () => {
|
|
495
|
-
const
|
|
496
|
-
o
|
|
495
|
+
const o = g({ compute: d });
|
|
496
|
+
u(o);
|
|
497
497
|
})];
|
|
498
|
-
if (!
|
|
498
|
+
if (!f)
|
|
499
499
|
return [t.subscribe("values", () => {
|
|
500
|
-
|
|
500
|
+
u(n());
|
|
501
501
|
})];
|
|
502
|
-
if (typeof
|
|
503
|
-
const c =
|
|
502
|
+
if (typeof f == "string") {
|
|
503
|
+
const c = J(f);
|
|
504
504
|
return [t.subscribe(c, () => {
|
|
505
|
-
const
|
|
506
|
-
|
|
505
|
+
const F = g({ name: f });
|
|
506
|
+
u(F);
|
|
507
507
|
})];
|
|
508
508
|
}
|
|
509
|
-
if (Array.isArray(
|
|
510
|
-
const c =
|
|
511
|
-
return
|
|
512
|
-
const
|
|
513
|
-
const
|
|
514
|
-
c[
|
|
509
|
+
if (Array.isArray(f)) {
|
|
510
|
+
const c = g({ name: f }), o = [];
|
|
511
|
+
return f.forEach((F) => {
|
|
512
|
+
const C = J(F), x = t.subscribe(C, () => {
|
|
513
|
+
const z = g({ name: F });
|
|
514
|
+
c[F] = z, u({ ...c });
|
|
515
515
|
});
|
|
516
|
-
|
|
517
|
-
}),
|
|
516
|
+
o.push(x);
|
|
517
|
+
}), o;
|
|
518
518
|
}
|
|
519
519
|
throw new Error("Parameters of name must be string or array of string or compute must be a function");
|
|
520
|
-
}, []),
|
|
521
|
-
(
|
|
522
|
-
if (!
|
|
523
|
-
return t.subscribe("values",
|
|
524
|
-
if (typeof
|
|
525
|
-
const
|
|
526
|
-
return t.subscribe(
|
|
520
|
+
}, []), y = b(
|
|
521
|
+
(f, d) => {
|
|
522
|
+
if (!f)
|
|
523
|
+
return t.subscribe("values", d);
|
|
524
|
+
if (typeof f == "string") {
|
|
525
|
+
const u = J(f);
|
|
526
|
+
return t.subscribe(u, d);
|
|
527
527
|
}
|
|
528
|
-
if (Array.isArray(
|
|
529
|
-
const
|
|
530
|
-
return
|
|
531
|
-
const
|
|
532
|
-
o
|
|
528
|
+
if (Array.isArray(f)) {
|
|
529
|
+
const u = {}, c = [];
|
|
530
|
+
return f.forEach((o) => {
|
|
531
|
+
const F = J(o), C = t.subscribe(F, () => {
|
|
532
|
+
u[o] = g({ name: o }), d({ ...u });
|
|
533
533
|
});
|
|
534
|
-
c.push(
|
|
534
|
+
c.push(C);
|
|
535
535
|
}), c;
|
|
536
536
|
}
|
|
537
537
|
throw new Error("Parameters of name must be string or array of string");
|
|
538
538
|
},
|
|
539
539
|
[t]
|
|
540
540
|
);
|
|
541
|
-
return { watch:
|
|
542
|
-
},
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
541
|
+
return { watch: m, registerHookWatcher: v, getWatchValue: g, subscribe: y };
|
|
542
|
+
}, Se = {
|
|
543
|
+
lastReset: null,
|
|
544
|
+
isDirty: !1,
|
|
545
|
+
isError: !1,
|
|
546
|
+
errorFields: [],
|
|
547
|
+
dirtyFields: [],
|
|
548
|
+
touchedFields: []
|
|
549
|
+
}, fe = { isDirty: !1, isTouched: !1, error: null }, Me = [], Ye = {}, qe = ({
|
|
550
|
+
numberFields: t = Me,
|
|
551
|
+
defaultValues: n = Ye,
|
|
552
|
+
shouldUnRegister: i = !1,
|
|
553
|
+
shouldConvertNumber: l = !1
|
|
547
554
|
} = {}) => {
|
|
548
|
-
const [
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
(
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
}),
|
|
580
|
-
const k =
|
|
581
|
-
|
|
582
|
-
|
|
555
|
+
const [h, E] = De(), g = V(), m = V(t), v = V(/* @__PURE__ */ new Map()), y = V({}), f = V({}), d = V({ ...Se }), u = V({ ...n }), c = V({ ...n }), o = Ve(), F = b((r) => {
|
|
556
|
+
f.current = Object.keys(c.current).reduce((s, S) => ({
|
|
557
|
+
...s,
|
|
558
|
+
[S]: { ...r ? {} : f.current[S] || {}, ...fe }
|
|
559
|
+
}), {});
|
|
560
|
+
}, []), C = b(
|
|
561
|
+
(r = {}, { clearCustomFormStates: s = !1, clearCustomFieldStates: S = !1 }) => {
|
|
562
|
+
c.current = { ...c.current, ...r }, u.current = { ...c.current }, v.current.forEach((k, U) => {
|
|
563
|
+
k(c.current[U]);
|
|
564
|
+
}), y.current = {}, d.current = { ...s ? {} : d.current, ...Se }, m.current = t, v.current = /* @__PURE__ */ new Map(), o.reset(), F(S), t.length > 0 && (l = !0), E();
|
|
565
|
+
},
|
|
566
|
+
[]
|
|
567
|
+
), x = b(() => {
|
|
568
|
+
const r = Object.fromEntries(new FormData(g.current));
|
|
569
|
+
return v.current.forEach((S, k) => {
|
|
570
|
+
r[k] = u.current[k];
|
|
571
|
+
}), l && m.current.forEach(
|
|
572
|
+
(S) => r.hasOwnProperty(S) && (r[S] = Number(r[S]) || 0)
|
|
573
|
+
), { ...u.current, ...r };
|
|
574
|
+
}, []), z = b(() => !!Object.values(W()).find((r) => r.isDirty), []), G = b(() => !!Object.values($()).find((r) => !!r), []), se = b((r) => Re(r.target), []), ne = b(() => c.current, []), oe = b(() => m.current, []), ue = b(() => v.current, []), P = b((r, s) => s ? Array.isArray(s) ? s.reduce((S, k) => ({ ...S, [k]: te(r, k) }), {}) : te(r, s) : { ...r }, []), H = b((r) => P(u.current, r), [P]), $ = b((r) => P(y.current, r), [P]), W = b((r) => P(f.current, r), [P]), M = b(
|
|
575
|
+
(r) => P({ ...d.current, lastReset: h }, r),
|
|
576
|
+
[P, h]
|
|
577
|
+
), { watch: Y, registerHookWatcher: B, getWatchValue: X, subscribe: Z } = $e({
|
|
578
|
+
channels: o,
|
|
579
|
+
getValues: H,
|
|
580
|
+
getErrors: $,
|
|
581
|
+
getFieldStates: W,
|
|
582
|
+
getFormState: M
|
|
583
|
+
}), Q = b((r, s) => {
|
|
584
|
+
const S = d.current;
|
|
585
|
+
te(S, r) !== s && (ve(d.current, r, s), o.publish(`formState.${r}`, s));
|
|
586
|
+
}, []), w = b((r, s, S) => {
|
|
587
|
+
const k = f.current[r] || { ...fe };
|
|
588
|
+
te(k, s) !== S && (ve(f.current, `${r}.${s}`, S), o.publish(`fieldStates.${r}.${s}`, S), s === "error" && (d.current.errorFields = Object.keys(y.current).filter(
|
|
589
|
+
(O) => !!y.current[O]
|
|
590
|
+
), o.publish("formState.errorFields", d.current.errorFields)), s === "isDirty" && (d.current.dirtyFields = Object.keys(f.current).filter(
|
|
591
|
+
(O) => f.current[O].isDirty
|
|
592
|
+
), o.publish("formState.dirtyFields", d.current.dirtyFields)), s === "isTouched" && (d.current.touchedFields = Object.keys(f.current).filter(
|
|
593
|
+
(O) => f.current[O].isTouched
|
|
594
|
+
), o.publish("formState.touchedFields", d.current.touchedFields)));
|
|
595
|
+
}, []), K = b(
|
|
583
596
|
(r) => {
|
|
584
|
-
|
|
597
|
+
w(r, "isDirty", !1), w(r, "isTouched", !1), w(r, "error", null);
|
|
585
598
|
},
|
|
586
|
-
[
|
|
587
|
-
), e =
|
|
588
|
-
(r,
|
|
589
|
-
if (
|
|
590
|
-
|
|
591
|
-
const k =
|
|
592
|
-
|
|
599
|
+
[w]
|
|
600
|
+
), e = b(
|
|
601
|
+
(r, s) => {
|
|
602
|
+
if (y.current[r] === s) return;
|
|
603
|
+
y.current[r] = s, w(r, "error", s), o.publish(`errors.${r}`, s);
|
|
604
|
+
const k = G();
|
|
605
|
+
d.current.isError !== k && (d.current.isError = k, o.publish("formState.isError", k));
|
|
593
606
|
},
|
|
594
|
-
[
|
|
595
|
-
),
|
|
607
|
+
[w]
|
|
608
|
+
), a = b(
|
|
596
609
|
(r) => {
|
|
597
|
-
if (!
|
|
598
|
-
|
|
599
|
-
const
|
|
600
|
-
|
|
610
|
+
if (!y.current[r]) return;
|
|
611
|
+
y.current[r] = null, w(r, "error", null), o.publish(`errors.${r}`, null);
|
|
612
|
+
const s = G();
|
|
613
|
+
d.current.isError !== s && (d.current.isError = s, o.publish("formState.isError", s));
|
|
601
614
|
},
|
|
602
|
-
[
|
|
603
|
-
),
|
|
604
|
-
if (Object.keys(
|
|
605
|
-
Object.keys(
|
|
606
|
-
const r =
|
|
607
|
-
|
|
608
|
-
}, []),
|
|
615
|
+
[w]
|
|
616
|
+
), R = b(() => {
|
|
617
|
+
if (Object.keys(y.current) === 0) return;
|
|
618
|
+
Object.keys(y.current).forEach((s) => a(s)), y.current = {};
|
|
619
|
+
const r = G();
|
|
620
|
+
d.current.isError !== r && (d.current.isError = r, o.publish("formState.isError", r));
|
|
621
|
+
}, []), T = b(
|
|
609
622
|
(r) => {
|
|
610
|
-
const
|
|
611
|
-
|
|
623
|
+
const s = Re(r.target);
|
|
624
|
+
s ? e(r.target.name, s) : a(r.target.name);
|
|
612
625
|
},
|
|
613
|
-
[e,
|
|
614
|
-
),
|
|
615
|
-
(r,
|
|
616
|
-
if (
|
|
617
|
-
|
|
618
|
-
const
|
|
619
|
-
|
|
620
|
-
const
|
|
621
|
-
|
|
622
|
-
const
|
|
623
|
-
|
|
626
|
+
[e, a]
|
|
627
|
+
), j = b(
|
|
628
|
+
(r, s, { shouldDirty: S = !0, shouldOnChange: k = !0 } = {}) => {
|
|
629
|
+
if (s === u.current[r]) return;
|
|
630
|
+
l && m.current.includes(r) && (s = Number(s) || void 0), w(r, "isTouched", !0);
|
|
631
|
+
const U = s !== c.current[r];
|
|
632
|
+
S && f.current[r].isDirty !== U && w(r, "isDirty", U);
|
|
633
|
+
const O = z();
|
|
634
|
+
d.current.isDirty !== O && (d.current.isDirty = O, o.publish("formState.isDirty", O)), u.current[r] = s;
|
|
635
|
+
const q = v.current.get(r);
|
|
636
|
+
q && q(s), o.publish(`values.${r}`, s, { shouldDirty: S, shouldOnChange: k }), k && o.publish("onChange", r, s, u.current);
|
|
624
637
|
},
|
|
625
|
-
[
|
|
626
|
-
), A =
|
|
627
|
-
|
|
628
|
-
}), []), I =
|
|
629
|
-
(r, { keepError:
|
|
630
|
-
const
|
|
631
|
-
if (!
|
|
638
|
+
[w]
|
|
639
|
+
), A = b((r, s) => (v.current.set(r, s), f.current[r] = { ...fe }, () => {
|
|
640
|
+
i && v.current.delete(r);
|
|
641
|
+
}), []), I = b(
|
|
642
|
+
(r, { keepError: s, keepDirty: S, keepTouched: k, keepCustomState: U, defaultValue: O }) => {
|
|
643
|
+
const q = v.current.get(r);
|
|
644
|
+
if (!q)
|
|
632
645
|
throw new Error(`Cannot reset "${r}" because it's uncontrolled field`);
|
|
633
|
-
|
|
646
|
+
c.current[r] = O, u.current[r] = O, q && q(O), s || a(r), S || w(r, "isDirty", !1), k || w(r, "isTouched", !1);
|
|
634
647
|
},
|
|
635
|
-
[
|
|
636
|
-
), L =
|
|
637
|
-
|
|
638
|
-
}, []),
|
|
648
|
+
[a, w]
|
|
649
|
+
), L = b((r, s = N.getValues(r)) => {
|
|
650
|
+
o.publish("onBlur", r, s, N.getValues());
|
|
651
|
+
}, []), _ = b((r) => o.subscribe("onChange", r), []), D = b((r) => o.subscribe("onBlur", r), []), N = le(
|
|
639
652
|
() => ({
|
|
640
653
|
subscribe: Z,
|
|
641
|
-
reset:
|
|
654
|
+
reset: C,
|
|
642
655
|
resetField: I,
|
|
643
|
-
setValue:
|
|
644
|
-
getValues:
|
|
645
|
-
getErrors:
|
|
646
|
-
getFieldStates:
|
|
647
|
-
getFormState:
|
|
656
|
+
setValue: j,
|
|
657
|
+
getValues: H,
|
|
658
|
+
getErrors: $,
|
|
659
|
+
getFieldStates: W,
|
|
660
|
+
getFormState: M,
|
|
648
661
|
setError: e,
|
|
649
|
-
clearError:
|
|
650
|
-
clearErrors:
|
|
651
|
-
checkValidity:
|
|
652
|
-
getNumberFields:
|
|
653
|
-
getFieldValidity:
|
|
654
|
-
getDefaultValues:
|
|
655
|
-
setFieldState:
|
|
662
|
+
clearError: a,
|
|
663
|
+
clearErrors: R,
|
|
664
|
+
checkValidity: T,
|
|
665
|
+
getNumberFields: oe,
|
|
666
|
+
getFieldValidity: se,
|
|
667
|
+
getDefaultValues: ne,
|
|
668
|
+
setFieldState: w,
|
|
656
669
|
triggerFieldBlur: L,
|
|
657
|
-
resetFieldState:
|
|
658
|
-
getControlledFields:
|
|
659
|
-
subscribeChange:
|
|
660
|
-
subscribeBlur:
|
|
661
|
-
|
|
662
|
-
|
|
670
|
+
resetFieldState: K,
|
|
671
|
+
getControlledFields: ue,
|
|
672
|
+
subscribeChange: _,
|
|
673
|
+
subscribeBlur: D,
|
|
674
|
+
setFormState: Q,
|
|
675
|
+
getEvents: o.getEvents,
|
|
676
|
+
getWatchEvents: o.getWatchEvents
|
|
663
677
|
}),
|
|
664
678
|
[
|
|
665
679
|
Z,
|
|
666
|
-
N,
|
|
667
|
-
I,
|
|
668
680
|
C,
|
|
669
|
-
|
|
681
|
+
I,
|
|
682
|
+
j,
|
|
683
|
+
H,
|
|
684
|
+
$,
|
|
670
685
|
W,
|
|
671
|
-
|
|
672
|
-
D,
|
|
686
|
+
M,
|
|
673
687
|
e,
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
688
|
+
a,
|
|
689
|
+
R,
|
|
690
|
+
T,
|
|
691
|
+
oe,
|
|
692
|
+
se,
|
|
677
693
|
ne,
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
y,
|
|
681
|
-
Q,
|
|
694
|
+
w,
|
|
695
|
+
K,
|
|
682
696
|
L,
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
697
|
+
ue,
|
|
698
|
+
_,
|
|
699
|
+
D,
|
|
700
|
+
Q
|
|
686
701
|
]
|
|
687
|
-
),
|
|
702
|
+
), ce = le(
|
|
688
703
|
() => ({
|
|
689
|
-
ref:
|
|
690
|
-
watch:
|
|
691
|
-
actions:
|
|
704
|
+
ref: g,
|
|
705
|
+
watch: Y,
|
|
706
|
+
actions: N,
|
|
692
707
|
registerController: A,
|
|
693
|
-
registerHookWatcher:
|
|
694
|
-
lastReloadedAt:
|
|
695
|
-
loadFormValues:
|
|
708
|
+
registerHookWatcher: B,
|
|
709
|
+
lastReloadedAt: h,
|
|
710
|
+
loadFormValues: x,
|
|
696
711
|
getWatchValue: X,
|
|
697
|
-
channels:
|
|
712
|
+
channels: o
|
|
698
713
|
}),
|
|
699
714
|
[
|
|
700
|
-
E,
|
|
701
|
-
$,
|
|
702
|
-
x,
|
|
703
|
-
A,
|
|
704
|
-
H,
|
|
705
715
|
g,
|
|
706
|
-
|
|
716
|
+
Y,
|
|
717
|
+
N,
|
|
718
|
+
A,
|
|
719
|
+
B,
|
|
720
|
+
h,
|
|
721
|
+
x,
|
|
707
722
|
X,
|
|
708
|
-
|
|
723
|
+
o
|
|
709
724
|
]
|
|
710
|
-
),
|
|
725
|
+
), Fe = le(() => ({ control: ce, actions: N, watch: Y }), [h, ce, N, Y]);
|
|
711
726
|
return be(() => {
|
|
712
|
-
if ([...
|
|
713
|
-
!
|
|
714
|
-
}),
|
|
715
|
-
const
|
|
716
|
-
|
|
727
|
+
if ([...g.current.querySelectorAll("[name]")].forEach((s) => {
|
|
728
|
+
!s.defaultValue && !v.current.has(s.name) && c.current[s.name] && (s.defaultValue = c.current[s.name]), s.type === "number" && !m.current.includes(s.name) && m.current.push(s.name);
|
|
729
|
+
}), g.current) {
|
|
730
|
+
const s = x();
|
|
731
|
+
u.current = { ...s }, c.current = { ...s };
|
|
717
732
|
}
|
|
718
|
-
}, [
|
|
719
|
-
|
|
720
|
-
}, []),
|
|
733
|
+
}, [h]), be(() => {
|
|
734
|
+
F();
|
|
735
|
+
}, []), Fe;
|
|
721
736
|
};
|
|
722
737
|
export {
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
738
|
+
Ue as Controller,
|
|
739
|
+
Le as Form,
|
|
740
|
+
Pe as useController,
|
|
741
|
+
qe as useForm,
|
|
742
|
+
ye as useFormContext,
|
|
743
|
+
Ce as useWatch
|
|
729
744
|
};
|