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