react-simple-formkit 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +194 -144
- package/dist/react-simple-formkit.js +4 -4
- package/dist/react-simple-formkit.mjs +262 -265
- package/dist/react-simple-formkit.umd.js +4 -4
- package/package.json +4 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
var G = { exports: {} },
|
|
1
|
+
import ue, { createContext as le, useContext as ie, useEffect as K, useState as X, useRef as P, useCallback as R, useMemo as ae } from "react";
|
|
2
|
+
var G = { exports: {} }, Y = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
5
5
|
* react-jsx-runtime.production.js
|
|
@@ -9,29 +9,29 @@ var G = { exports: {} }, M = {};
|
|
|
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 o = Symbol.for("react.transitional.element"),
|
|
17
|
-
function i(
|
|
18
|
-
var
|
|
19
|
-
if (a !== void 0 && (
|
|
12
|
+
var ee;
|
|
13
|
+
function fe() {
|
|
14
|
+
if (ee) return Y;
|
|
15
|
+
ee = 1;
|
|
16
|
+
var o = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
|
|
17
|
+
function i(d, s, a) {
|
|
18
|
+
var b = null;
|
|
19
|
+
if (a !== void 0 && (b = "" + a), s.key !== void 0 && (b = "" + s.key), "key" in s) {
|
|
20
20
|
a = {};
|
|
21
|
-
for (var u in
|
|
22
|
-
u !== "key" && (a[u] =
|
|
23
|
-
} else a =
|
|
24
|
-
return
|
|
21
|
+
for (var u in s)
|
|
22
|
+
u !== "key" && (a[u] = s[u]);
|
|
23
|
+
} else a = s;
|
|
24
|
+
return s = a.ref, {
|
|
25
25
|
$$typeof: o,
|
|
26
|
-
type:
|
|
27
|
-
key:
|
|
28
|
-
ref:
|
|
26
|
+
type: d,
|
|
27
|
+
key: b,
|
|
28
|
+
ref: s !== void 0 ? s : null,
|
|
29
29
|
props: a
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return Y.Fragment = r, Y.jsx = i, Y.jsxs = i, Y;
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var I = {};
|
|
35
35
|
/**
|
|
36
36
|
* @license React
|
|
37
37
|
* react-jsx-runtime.development.js
|
|
@@ -41,125 +41,125 @@ var L = {};
|
|
|
41
41
|
* This source code is licensed under the MIT license found in the
|
|
42
42
|
* LICENSE file in the root directory of this source tree.
|
|
43
43
|
*/
|
|
44
|
-
var
|
|
45
|
-
function
|
|
46
|
-
return
|
|
44
|
+
var re;
|
|
45
|
+
function de() {
|
|
46
|
+
return re || (re = 1, process.env.NODE_ENV !== "production" && function() {
|
|
47
47
|
function o(e) {
|
|
48
48
|
if (e == null) return null;
|
|
49
49
|
if (typeof e == "function")
|
|
50
|
-
return e.$$typeof ===
|
|
50
|
+
return e.$$typeof === N ? null : e.displayName || e.name || null;
|
|
51
51
|
if (typeof e == "string") return e;
|
|
52
52
|
switch (e) {
|
|
53
|
-
case
|
|
53
|
+
case h:
|
|
54
54
|
return "Fragment";
|
|
55
|
-
case
|
|
55
|
+
case M:
|
|
56
56
|
return "Profiler";
|
|
57
|
-
case
|
|
57
|
+
case $:
|
|
58
58
|
return "StrictMode";
|
|
59
|
-
case
|
|
59
|
+
case U:
|
|
60
60
|
return "Suspense";
|
|
61
61
|
case q:
|
|
62
62
|
return "SuspenseList";
|
|
63
|
-
case
|
|
63
|
+
case J:
|
|
64
64
|
return "Activity";
|
|
65
65
|
}
|
|
66
66
|
if (typeof e == "object")
|
|
67
67
|
switch (typeof e.tag == "number" && console.error(
|
|
68
68
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
69
|
), e.$$typeof) {
|
|
70
|
-
case
|
|
70
|
+
case F:
|
|
71
71
|
return "Portal";
|
|
72
|
-
case
|
|
72
|
+
case L:
|
|
73
73
|
return (e.displayName || "Context") + ".Provider";
|
|
74
|
-
case
|
|
74
|
+
case B:
|
|
75
75
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
|
-
case
|
|
77
|
-
var
|
|
78
|
-
return e = e.displayName, e || (e =
|
|
79
|
-
case
|
|
80
|
-
return
|
|
81
|
-
case
|
|
82
|
-
|
|
76
|
+
case W:
|
|
77
|
+
var t = e.render;
|
|
78
|
+
return e = e.displayName, e || (e = t.displayName || t.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
|
+
case A:
|
|
80
|
+
return t = e.displayName || null, t !== null ? t : o(e.type) || "Memo";
|
|
81
|
+
case C:
|
|
82
|
+
t = e._payload, e = e._init;
|
|
83
83
|
try {
|
|
84
|
-
return o(e(
|
|
84
|
+
return o(e(t));
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
return null;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function r(e) {
|
|
91
91
|
return "" + e;
|
|
92
92
|
}
|
|
93
93
|
function i(e) {
|
|
94
94
|
try {
|
|
95
|
-
|
|
96
|
-
var
|
|
95
|
+
r(e);
|
|
96
|
+
var t = !1;
|
|
97
97
|
} catch {
|
|
98
|
-
|
|
98
|
+
t = !0;
|
|
99
99
|
}
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
var
|
|
103
|
-
return
|
|
104
|
-
|
|
100
|
+
if (t) {
|
|
101
|
+
t = console;
|
|
102
|
+
var l = t.error, _ = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
103
|
+
return l.call(
|
|
104
|
+
t,
|
|
105
105
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
106
|
_
|
|
107
|
-
),
|
|
107
|
+
), r(e);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
if (e ===
|
|
112
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
110
|
+
function d(e) {
|
|
111
|
+
if (e === h) return "<>";
|
|
112
|
+
if (typeof e == "object" && e !== null && e.$$typeof === C)
|
|
113
113
|
return "<...>";
|
|
114
114
|
try {
|
|
115
|
-
var
|
|
116
|
-
return
|
|
115
|
+
var t = o(e);
|
|
116
|
+
return t ? "<" + t + ">" : "<...>";
|
|
117
117
|
} catch {
|
|
118
118
|
return "<...>";
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
function
|
|
122
|
-
var e =
|
|
121
|
+
function s() {
|
|
122
|
+
var e = D.A;
|
|
123
123
|
return e === null ? null : e.getOwner();
|
|
124
124
|
}
|
|
125
125
|
function a() {
|
|
126
126
|
return Error("react-stack-top-frame");
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
if (
|
|
130
|
-
var
|
|
131
|
-
if (
|
|
128
|
+
function b(e) {
|
|
129
|
+
if (n.call(e, "key")) {
|
|
130
|
+
var t = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
131
|
+
if (t && t.isReactWarning) return !1;
|
|
132
132
|
}
|
|
133
133
|
return e.key !== void 0;
|
|
134
134
|
}
|
|
135
|
-
function u(e,
|
|
136
|
-
function
|
|
137
|
-
|
|
135
|
+
function u(e, t) {
|
|
136
|
+
function l() {
|
|
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
|
+
t
|
|
140
140
|
));
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
get:
|
|
142
|
+
l.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
143
|
+
get: l,
|
|
144
144
|
configurable: !0
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function E() {
|
|
148
148
|
var e = o(this.type);
|
|
149
|
-
return
|
|
149
|
+
return y[e] || (y[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 m(e, t, l, _, j, S, H, Z) {
|
|
154
|
+
return l = S.ref, e = {
|
|
155
|
+
$$typeof: w,
|
|
156
156
|
type: e,
|
|
157
|
-
key:
|
|
157
|
+
key: t,
|
|
158
158
|
props: S,
|
|
159
|
-
_owner:
|
|
160
|
-
}, (
|
|
159
|
+
_owner: j
|
|
160
|
+
}, (l !== void 0 ? l : null) !== null ? Object.defineProperty(e, "ref", {
|
|
161
161
|
enumerable: !1,
|
|
162
|
-
get:
|
|
162
|
+
get: E
|
|
163
163
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
164
164
|
configurable: !1,
|
|
165
165
|
enumerable: !1,
|
|
@@ -182,25 +182,25 @@ function be() {
|
|
|
182
182
|
value: Z
|
|
183
183
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
184
184
|
}
|
|
185
|
-
function g(e,
|
|
186
|
-
var v =
|
|
185
|
+
function g(e, t, l, _, j, S, H, Z) {
|
|
186
|
+
var v = t.children;
|
|
187
187
|
if (v !== void 0)
|
|
188
188
|
if (_)
|
|
189
|
-
if (
|
|
189
|
+
if (T(v)) {
|
|
190
190
|
for (_ = 0; _ < v.length; _++)
|
|
191
|
-
|
|
191
|
+
c(v[_]);
|
|
192
192
|
Object.freeze && Object.freeze(v);
|
|
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 c(v);
|
|
198
|
+
if (n.call(t, "key")) {
|
|
199
199
|
v = o(e);
|
|
200
|
-
var
|
|
201
|
-
return
|
|
200
|
+
var x = Object.keys(t).filter(function(ce) {
|
|
201
|
+
return ce !== "key";
|
|
202
202
|
});
|
|
203
|
-
_ = 0 <
|
|
203
|
+
_ = 0 < x.length ? "{key: someKey, " + x.join(": ..., ") + ": ...}" : "{key: someKey}", V[v + _] || (x = 0 < x.length ? "{" + x.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,260 +209,257 @@ React keys must be passed directly to JSX without using spread:
|
|
|
209
209
|
<%s key={someKey} {...props} />`,
|
|
210
210
|
_,
|
|
211
211
|
v,
|
|
212
|
-
|
|
212
|
+
x,
|
|
213
213
|
v
|
|
214
|
-
),
|
|
214
|
+
), V[v + _] = !0);
|
|
215
215
|
}
|
|
216
|
-
if (v = null,
|
|
217
|
-
|
|
218
|
-
for (var Q in
|
|
219
|
-
Q !== "key" && (
|
|
220
|
-
} else
|
|
216
|
+
if (v = null, l !== void 0 && (i(l), v = "" + l), b(t) && (i(t.key), v = "" + t.key), "key" in t) {
|
|
217
|
+
l = {};
|
|
218
|
+
for (var Q in t)
|
|
219
|
+
Q !== "key" && (l[Q] = t[Q]);
|
|
220
|
+
} else l = t;
|
|
221
221
|
return v && u(
|
|
222
|
-
|
|
222
|
+
l,
|
|
223
223
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
224
|
-
),
|
|
224
|
+
), m(
|
|
225
225
|
e,
|
|
226
226
|
v,
|
|
227
227
|
S,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
228
|
+
j,
|
|
229
|
+
s(),
|
|
230
|
+
l,
|
|
231
231
|
H,
|
|
232
232
|
Z
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
typeof e == "object" && e !== null && e.$$typeof ===
|
|
235
|
+
function c(e) {
|
|
236
|
+
typeof e == "object" && e !== null && e.$$typeof === w && e._store && (e._store.validated = 1);
|
|
237
237
|
}
|
|
238
|
-
var
|
|
238
|
+
var p = ue, w = Symbol.for("react.transitional.element"), F = Symbol.for("react.portal"), h = Symbol.for("react.fragment"), $ = Symbol.for("react.strict_mode"), M = Symbol.for("react.profiler"), B = Symbol.for("react.consumer"), L = Symbol.for("react.context"), W = Symbol.for("react.forward_ref"), U = Symbol.for("react.suspense"), q = Symbol.for("react.suspense_list"), A = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), J = Symbol.for("react.activity"), N = Symbol.for("react.client.reference"), D = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, n = Object.prototype.hasOwnProperty, T = Array.isArray, f = console.createTask ? console.createTask : function() {
|
|
239
239
|
return null;
|
|
240
240
|
};
|
|
241
|
-
|
|
241
|
+
p = {
|
|
242
242
|
"react-stack-bottom-frame": function(e) {
|
|
243
243
|
return e();
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
|
-
var
|
|
247
|
-
|
|
246
|
+
var k, y = {}, O = p["react-stack-bottom-frame"].bind(
|
|
247
|
+
p,
|
|
248
248
|
a
|
|
249
|
-
)(),
|
|
250
|
-
|
|
251
|
-
var S = 1e4 >
|
|
249
|
+
)(), z = f(d(a)), V = {};
|
|
250
|
+
I.Fragment = h, I.jsx = function(e, t, l, _, j) {
|
|
251
|
+
var S = 1e4 > D.recentlyCreatedOwnerStacks++;
|
|
252
252
|
return g(
|
|
253
253
|
e,
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
t,
|
|
255
|
+
l,
|
|
256
256
|
!1,
|
|
257
257
|
_,
|
|
258
|
-
|
|
259
|
-
S ? Error("react-stack-top-frame") :
|
|
260
|
-
S ?
|
|
258
|
+
j,
|
|
259
|
+
S ? Error("react-stack-top-frame") : O,
|
|
260
|
+
S ? f(d(e)) : z
|
|
261
261
|
);
|
|
262
|
-
},
|
|
263
|
-
var S = 1e4 >
|
|
262
|
+
}, I.jsxs = function(e, t, l, _, j) {
|
|
263
|
+
var S = 1e4 > D.recentlyCreatedOwnerStacks++;
|
|
264
264
|
return g(
|
|
265
265
|
e,
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
t,
|
|
267
|
+
l,
|
|
268
268
|
!0,
|
|
269
269
|
_,
|
|
270
|
-
|
|
271
|
-
S ? Error("react-stack-top-frame") :
|
|
272
|
-
S ?
|
|
270
|
+
j,
|
|
271
|
+
S ? Error("react-stack-top-frame") : O,
|
|
272
|
+
S ? f(d(e)) : z
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
|
-
}()),
|
|
275
|
+
}()), I;
|
|
276
276
|
}
|
|
277
|
-
var
|
|
278
|
-
function
|
|
279
|
-
return
|
|
277
|
+
var te;
|
|
278
|
+
function Ee() {
|
|
279
|
+
return te || (te = 1, process.env.NODE_ENV === "production" ? G.exports = fe() : G.exports = de()), G.exports;
|
|
280
280
|
}
|
|
281
|
-
var
|
|
282
|
-
const
|
|
283
|
-
let i = !1;
|
|
284
|
-
return Object.keys(n).forEach((l) => {
|
|
285
|
-
if (!(l in o) || i) return;
|
|
286
|
-
const c = n[l], a = o[l];
|
|
287
|
-
(typeof c == "object" || c !== a) && (i = !0);
|
|
288
|
-
}), i;
|
|
289
|
-
}, ae = (o) => (typeof o.setCustomValidity == "function" && o.setCustomValidity(""), !o || typeof o.checkValidity != "function" || o.checkValidity() ? null : o.validationMessage), _e = ({
|
|
281
|
+
var ne = Ee();
|
|
282
|
+
const se = le({}), be = () => ie(se), Te = ({
|
|
290
283
|
id: o,
|
|
291
|
-
form:
|
|
284
|
+
form: r,
|
|
292
285
|
method: i,
|
|
293
|
-
action:
|
|
294
|
-
children:
|
|
286
|
+
action: d,
|
|
287
|
+
children: s,
|
|
295
288
|
onSubmit: a = () => {
|
|
296
289
|
},
|
|
297
|
-
onInput:
|
|
290
|
+
onInput: b = () => {
|
|
298
291
|
},
|
|
299
292
|
onChange: u = () => {
|
|
300
293
|
},
|
|
301
|
-
numberFields:
|
|
302
|
-
className:
|
|
294
|
+
numberFields: E = [],
|
|
295
|
+
className: m,
|
|
303
296
|
...g
|
|
304
|
-
}) => (
|
|
297
|
+
}) => (K(() => r.actions.registerOnchange(u), [u]), /* @__PURE__ */ ne.jsx(se.Provider, { value: r, children: /* @__PURE__ */ ne.jsx(
|
|
305
298
|
"form",
|
|
306
299
|
{
|
|
307
|
-
ref:
|
|
308
|
-
action:
|
|
309
|
-
className:
|
|
310
|
-
onSubmit: (
|
|
311
|
-
i ||
|
|
312
|
-
const
|
|
313
|
-
a(
|
|
300
|
+
ref: r == null ? void 0 : r.ref,
|
|
301
|
+
action: d,
|
|
302
|
+
className: m,
|
|
303
|
+
onSubmit: (c) => {
|
|
304
|
+
i || c.preventDefault();
|
|
305
|
+
const p = r.actions.loadFormValues();
|
|
306
|
+
a(p);
|
|
314
307
|
},
|
|
315
|
-
onInput: (
|
|
316
|
-
if (
|
|
317
|
-
const
|
|
318
|
-
|
|
308
|
+
onInput: (c) => {
|
|
309
|
+
if (c.target.tagName === "FORM") {
|
|
310
|
+
const p = r.actions.loadFormValues();
|
|
311
|
+
r.actions.setFormState(p);
|
|
319
312
|
} else
|
|
320
|
-
|
|
313
|
+
b(c);
|
|
321
314
|
},
|
|
322
315
|
onChange: () => {
|
|
323
|
-
const
|
|
324
|
-
|
|
316
|
+
const c = r.actions.loadFormValues();
|
|
317
|
+
r.actions.setFormState(c);
|
|
325
318
|
},
|
|
326
|
-
onReset: (
|
|
327
|
-
|
|
319
|
+
onReset: (c) => {
|
|
320
|
+
r && (c.preventDefault(), r.actions.reset());
|
|
328
321
|
},
|
|
329
322
|
...g,
|
|
330
|
-
children:
|
|
323
|
+
children: s
|
|
331
324
|
},
|
|
332
|
-
|
|
333
|
-
) })),
|
|
334
|
-
const [
|
|
335
|
-
(
|
|
336
|
-
a.actions.setFormState((g) => ({ ...g, [o]:
|
|
325
|
+
r == null ? void 0 : r.lastReloadedAt
|
|
326
|
+
) })), ge = ({ name: o, defaultValue: r, render: i = ({ ref: d, name: s, defaultValue: a, value: b, setValue: u }) => null }) => {
|
|
327
|
+
const [d, s] = X(r), a = be(), b = P(), u = R(
|
|
328
|
+
(E, { shouldDirty: m = !1 } = {}) => {
|
|
329
|
+
a.actions.setFormState((g) => ({ ...g, [o]: E }), { shouldDirty: m }), s(E);
|
|
337
330
|
},
|
|
338
|
-
[
|
|
331
|
+
[s, a.actions.setFormState]
|
|
339
332
|
);
|
|
340
|
-
return
|
|
341
|
-
|
|
342
|
-
})), []), i({ ref:
|
|
343
|
-
},
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
333
|
+
return K(() => (a.actions.setFormState((m) => ({ ...m, [o]: r }), { shouldDirty: !1 }), a.subscribe(o, (m, { shouldDirty: g = !0, shouldOnChange: c = !0 } = {}) => {
|
|
334
|
+
s(m), a.actions.setFormState((p) => ({ ...p, [o]: m }), { shouldDirty: g, shouldOnChange: c }), b.current && typeof b.current.dispatchEvent == "function" && c && b.current.dispatchEvent(new Event("change"));
|
|
335
|
+
})), []), i({ ref: b, name: o, defaultValue: r, value: d, setValue: u });
|
|
336
|
+
}, me = (o, r) => {
|
|
337
|
+
let i = !1;
|
|
338
|
+
return Object.keys(r).forEach((d) => {
|
|
339
|
+
if (!(d in o) || i) return;
|
|
340
|
+
const s = r[d], a = o[d];
|
|
341
|
+
(typeof s == "object" || s !== a) && (i = !0);
|
|
342
|
+
}), i;
|
|
343
|
+
}, oe = (o) => (typeof o.setCustomValidity == "function" && o.setCustomValidity(""), !o || typeof o.checkValidity != "function" || o.checkValidity() ? null : o.validationMessage), Re = () => {
|
|
344
|
+
const [o, r] = X({}), i = ae(() => Object.values(o).filter(Boolean).length > 0, [o]), d = R((u, E) => {
|
|
345
|
+
r((m) => m[u] === E ? m : { ...m, [u]: E });
|
|
346
|
+
}, []), s = R((u) => {
|
|
347
|
+
r((E) => ({ ...E, ...u }));
|
|
348
348
|
}, []), a = R((u) => {
|
|
349
|
-
|
|
350
|
-
}, []),
|
|
351
|
-
|
|
349
|
+
r((E) => E[u] ? { ...E, [u]: "" } : E);
|
|
350
|
+
}, []), b = R(() => {
|
|
351
|
+
r({});
|
|
352
352
|
}, []);
|
|
353
|
-
return { isError: i, errors: o, changeError:
|
|
354
|
-
},
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
},
|
|
358
|
-
const {
|
|
359
|
-
}),
|
|
360
|
-
(
|
|
361
|
-
let k =
|
|
362
|
-
typeof
|
|
363
|
-
let y =
|
|
364
|
-
|
|
353
|
+
return { isError: i, errors: o, changeError: d, changeErrors: s, clearError: a, clearErrors: b };
|
|
354
|
+
}, pe = () => {
|
|
355
|
+
const [o, r] = X(), i = R(() => r((/* @__PURE__ */ new Date()).toString()), []);
|
|
356
|
+
return [o, i];
|
|
357
|
+
}, _e = [], he = ({ numberFields: o = _e } = {}) => {
|
|
358
|
+
const { changeError: r, errors: i, changeErrors: d, clearError: s, clearErrors: a, isError: b } = Re(), [u, E] = X(!1), [m, g] = pe(), c = P({}), p = P({}), w = P({}), F = P(() => {
|
|
359
|
+
}), h = P(), $ = R(
|
|
360
|
+
(n, { shouldDirty: T = !0, shouldOnChange: f = !0 } = {}) => {
|
|
361
|
+
let k = n;
|
|
362
|
+
typeof n == "function" && (k = n(c.current)), c.current = k;
|
|
363
|
+
let y = u;
|
|
364
|
+
T && (y = me(c.current, p.current), y !== u && E(y)), f && F.current(c.current);
|
|
365
365
|
},
|
|
366
|
-
[
|
|
367
|
-
),
|
|
368
|
-
|
|
369
|
-
const
|
|
370
|
-
Object.keys(
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
}),
|
|
374
|
-
}, [
|
|
375
|
-
const
|
|
376
|
-
return
|
|
377
|
-
}, []),
|
|
378
|
-
})),
|
|
379
|
-
setTimeout(() =>
|
|
380
|
-
}, []),
|
|
381
|
-
(
|
|
382
|
-
const
|
|
383
|
-
|
|
366
|
+
[u]
|
|
367
|
+
), M = R(() => {
|
|
368
|
+
E(!1), a();
|
|
369
|
+
const n = w.current;
|
|
370
|
+
Object.keys(n).forEach((T) => {
|
|
371
|
+
const f = n[T];
|
|
372
|
+
f(p.current[T], { shouldDirty: !1, shouldOnChange: !1 });
|
|
373
|
+
}), h.current && h.current.reset(), g();
|
|
374
|
+
}, [a]), B = R((n, T) => {
|
|
375
|
+
const f = w.current;
|
|
376
|
+
return f[n] = T, () => f[n] = null;
|
|
377
|
+
}, []), L = R((n) => (F.current = n, () => F.current = () => {
|
|
378
|
+
})), W = R((n) => oe(n.target), []), U = R((n) => n ? c.current[n] : c.current, []), q = R(() => p.current, []), A = R(() => {
|
|
379
|
+
setTimeout(() => h.current.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
380
|
+
}, []), C = R(
|
|
381
|
+
(n) => {
|
|
382
|
+
const T = oe(n.target);
|
|
383
|
+
T ? r(n.target.name, T) : r(n.target.name, null);
|
|
384
384
|
},
|
|
385
|
-
[
|
|
386
|
-
),
|
|
387
|
-
(
|
|
388
|
-
const y =
|
|
389
|
-
switch (typeof
|
|
385
|
+
[r]
|
|
386
|
+
), J = R(
|
|
387
|
+
(n, T, { shouldDirty: f = !0, shouldOnChange: k = !0 } = {}) => {
|
|
388
|
+
const y = w.current;
|
|
389
|
+
switch (typeof n) {
|
|
390
390
|
case "string":
|
|
391
391
|
{
|
|
392
|
-
const
|
|
393
|
-
if (!
|
|
394
|
-
throw new Error(`${
|
|
395
|
-
|
|
392
|
+
const O = y[n];
|
|
393
|
+
if (!O)
|
|
394
|
+
throw new Error(`${n} is uncontrolled, please use Controller for it!`);
|
|
395
|
+
O(T, { shouldDirty: f, shouldOnChange: k }), k && A();
|
|
396
396
|
}
|
|
397
397
|
break;
|
|
398
398
|
case "object":
|
|
399
|
-
Object.entries(
|
|
400
|
-
const
|
|
401
|
-
if (!
|
|
402
|
-
throw new Error(`${
|
|
403
|
-
|
|
404
|
-
}), k &&
|
|
399
|
+
Object.entries(n).forEach(([O, z]) => {
|
|
400
|
+
const V = y[O];
|
|
401
|
+
if (!V)
|
|
402
|
+
throw new Error(`${O} is uncontrolled, please use Controller for it!`);
|
|
403
|
+
V(z, { shouldDirty: f, shouldOnChange: k });
|
|
404
|
+
}), k && A();
|
|
405
405
|
default:
|
|
406
406
|
return;
|
|
407
407
|
}
|
|
408
408
|
},
|
|
409
|
-
[
|
|
410
|
-
),
|
|
411
|
-
const
|
|
412
|
-
return Object.keys(
|
|
413
|
-
|
|
414
|
-
}),
|
|
415
|
-
}, []),
|
|
409
|
+
[A]
|
|
410
|
+
), N = R(() => {
|
|
411
|
+
const n = Object.fromEntries(new FormData(h.current)), T = w.current;
|
|
412
|
+
return Object.keys(T).map((f) => {
|
|
413
|
+
n[f] = c.current[f];
|
|
414
|
+
}), o.forEach((f) => n.hasOwnProperty(f) && (n[f] = +n[f])), n;
|
|
415
|
+
}, []), D = ae(
|
|
416
416
|
() => ({
|
|
417
|
-
setValue:
|
|
418
|
-
instantChange:
|
|
419
|
-
getDefaultValues:
|
|
420
|
-
getFormState:
|
|
421
|
-
setFormState:
|
|
422
|
-
changeError:
|
|
423
|
-
changeErrors:
|
|
424
|
-
clearError:
|
|
425
|
-
clearErrors:
|
|
426
|
-
loadFormValues:
|
|
427
|
-
checkValidity:
|
|
428
|
-
getFieldValidity:
|
|
429
|
-
registerOnchange:
|
|
430
|
-
reload:
|
|
431
|
-
reset:
|
|
417
|
+
setValue: J,
|
|
418
|
+
instantChange: A,
|
|
419
|
+
getDefaultValues: q,
|
|
420
|
+
getFormState: U,
|
|
421
|
+
setFormState: $,
|
|
422
|
+
changeError: r,
|
|
423
|
+
changeErrors: d,
|
|
424
|
+
clearError: s,
|
|
425
|
+
clearErrors: a,
|
|
426
|
+
loadFormValues: N,
|
|
427
|
+
checkValidity: C,
|
|
428
|
+
getFieldValidity: W,
|
|
429
|
+
registerOnchange: L,
|
|
430
|
+
reload: g,
|
|
431
|
+
reset: M
|
|
432
432
|
}),
|
|
433
433
|
[
|
|
434
|
-
Y,
|
|
435
|
-
x,
|
|
436
|
-
z,
|
|
437
|
-
D,
|
|
438
|
-
W,
|
|
439
|
-
l,
|
|
440
|
-
a,
|
|
441
|
-
E,
|
|
442
|
-
I,
|
|
443
434
|
J,
|
|
444
|
-
|
|
435
|
+
A,
|
|
445
436
|
q,
|
|
446
|
-
|
|
447
|
-
|
|
437
|
+
U,
|
|
438
|
+
$,
|
|
439
|
+
r,
|
|
440
|
+
d,
|
|
441
|
+
s,
|
|
442
|
+
N,
|
|
443
|
+
W,
|
|
444
|
+
C,
|
|
445
|
+
L,
|
|
446
|
+
g,
|
|
447
|
+
M
|
|
448
448
|
]
|
|
449
449
|
);
|
|
450
|
-
return
|
|
451
|
-
if (
|
|
452
|
-
const
|
|
453
|
-
|
|
450
|
+
return K(() => {
|
|
451
|
+
if (h.current) {
|
|
452
|
+
const n = N();
|
|
453
|
+
p.current = n, c.current = n;
|
|
454
454
|
}
|
|
455
|
-
|
|
456
|
-
},
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
useForm: Te,
|
|
460
|
-
useValidateForm: ue
|
|
455
|
+
return () => {
|
|
456
|
+
p.current = {}, c.current = {}, E(!1), a();
|
|
457
|
+
};
|
|
458
|
+
}, [m]), { ref: h, lastReloadedAt: m, isDirty: u, isError: b, errors: i, numberFields: o, subscribe: B, actions: D };
|
|
461
459
|
};
|
|
462
460
|
export {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
he as
|
|
466
|
-
|
|
467
|
-
ue as useValidateForm
|
|
461
|
+
ge as Controller,
|
|
462
|
+
Te as Form,
|
|
463
|
+
he as useForm,
|
|
464
|
+
Re as useValidateForm
|
|
468
465
|
};
|