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