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