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.
@@ -1,5 +1,5 @@
1
- import ie, { createContext as fe, useContext as de, useEffect as ee, useState as X, useRef as C, useCallback as R, useMemo as se } from "react";
2
- var G = { exports: {} }, M = {};
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 re;
13
- function Ee() {
14
- if (re) return M;
15
- re = 1;
16
- var o = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
17
- function i(l, c, a) {
18
- var E = null;
19
- if (a !== void 0 && (E = "" + a), c.key !== void 0 && (E = "" + c.key), "key" in c) {
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 c)
22
- u !== "key" && (a[u] = c[u]);
23
- } else a = c;
24
- return c = a.ref, {
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: l,
27
- key: E,
28
- ref: c !== void 0 ? c : null,
26
+ type: d,
27
+ key: b,
28
+ ref: s !== void 0 ? s : null,
29
29
  props: a
30
30
  };
31
31
  }
32
- return M.Fragment = n, M.jsx = i, M.jsxs = i, M;
32
+ return Y.Fragment = r, Y.jsx = i, Y.jsxs = i, Y;
33
33
  }
34
- var L = {};
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 te;
45
- function be() {
46
- return te || (te = 1, process.env.NODE_ENV !== "production" && function() {
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 === x ? null : e.displayName || e.name || null;
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 O:
53
+ case h:
54
54
  return "Fragment";
55
- case j:
55
+ case M:
56
56
  return "Profiler";
57
- case N:
57
+ case $:
58
58
  return "StrictMode";
59
- case B:
59
+ case U:
60
60
  return "Suspense";
61
61
  case q:
62
62
  return "SuspenseList";
63
- case z:
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 A:
70
+ case F:
71
71
  return "Portal";
72
- case V:
72
+ case L:
73
73
  return (e.displayName || "Context") + ".Provider";
74
- case W:
74
+ case B:
75
75
  return (e._context.displayName || "Context") + ".Consumer";
76
- case U:
77
- var r = e.render;
78
- return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
79
- case J:
80
- return r = e.displayName || null, r !== null ? r : o(e.type) || "Memo";
81
- case D:
82
- r = e._payload, e = e._init;
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(r));
84
+ return o(e(t));
85
85
  } catch {
86
86
  }
87
87
  }
88
88
  return null;
89
89
  }
90
- function n(e) {
90
+ function r(e) {
91
91
  return "" + e;
92
92
  }
93
93
  function i(e) {
94
94
  try {
95
- n(e);
96
- var r = !1;
95
+ r(e);
96
+ var t = !1;
97
97
  } catch {
98
- r = !0;
98
+ t = !0;
99
99
  }
100
- if (r) {
101
- r = console;
102
- var s = r.error, _ = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
103
- return s.call(
104
- r,
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
- ), n(e);
107
+ ), r(e);
108
108
  }
109
109
  }
110
- function l(e) {
111
- if (e === O) return "<>";
112
- if (typeof e == "object" && e !== null && e.$$typeof === D)
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 r = o(e);
116
- return r ? "<" + r + ">" : "<...>";
115
+ var t = o(e);
116
+ return t ? "<" + t + ">" : "<...>";
117
117
  } catch {
118
118
  return "<...>";
119
119
  }
120
120
  }
121
- function c() {
122
- var e = F.A;
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 E(e) {
129
- if (Y.call(e, "key")) {
130
- var r = Object.getOwnPropertyDescriptor(e, "key").get;
131
- if (r && r.isReactWarning) return !1;
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, r) {
136
- function s() {
137
- t || (t = !0, console.error(
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
- r
139
+ t
140
140
  ));
141
141
  }
142
- s.isReactWarning = !0, Object.defineProperty(e, "key", {
143
- get: s,
142
+ l.isReactWarning = !0, Object.defineProperty(e, "key", {
143
+ get: l,
144
144
  configurable: !0
145
145
  });
146
146
  }
147
- function m() {
147
+ function E() {
148
148
  var e = o(this.type);
149
- return p[e] || (p[e] = !0, console.error(
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 f(e, r, s, _, w, S, H, Z) {
154
- return s = S.ref, e = {
155
- $$typeof: h,
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: r,
157
+ key: t,
158
158
  props: S,
159
- _owner: w
160
- }, (s !== void 0 ? s : null) !== null ? Object.defineProperty(e, "ref", {
159
+ _owner: j
160
+ }, (l !== void 0 ? l : null) !== null ? Object.defineProperty(e, "ref", {
161
161
  enumerable: !1,
162
- get: m
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, r, s, _, w, S, H, Z) {
186
- var v = r.children;
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 (I(v)) {
189
+ if (T(v)) {
190
190
  for (_ = 0; _ < v.length; _++)
191
- b(v[_]);
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 b(v);
198
- if (Y.call(r, "key")) {
197
+ else c(v);
198
+ if (n.call(t, "key")) {
199
199
  v = o(e);
200
- var P = Object.keys(r).filter(function(le) {
201
- return le !== "key";
200
+ var x = Object.keys(t).filter(function(ce) {
201
+ return ce !== "key";
202
202
  });
203
- _ = 0 < P.length ? "{key: someKey, " + P.join(": ..., ") + ": ...}" : "{key: someKey}", y[v + _] || (P = 0 < P.length ? "{" + P.join(": ..., ") + ": ...}" : "{}", console.error(
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
- P,
212
+ x,
213
213
  v
214
- ), y[v + _] = !0);
214
+ ), V[v + _] = !0);
215
215
  }
216
- if (v = null, s !== void 0 && (i(s), v = "" + s), E(r) && (i(r.key), v = "" + r.key), "key" in r) {
217
- s = {};
218
- for (var Q in r)
219
- Q !== "key" && (s[Q] = r[Q]);
220
- } else s = r;
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
- s,
222
+ l,
223
223
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
224
- ), f(
224
+ ), m(
225
225
  e,
226
226
  v,
227
227
  S,
228
- w,
229
- c(),
230
- s,
228
+ j,
229
+ s(),
230
+ l,
231
231
  H,
232
232
  Z
233
233
  );
234
234
  }
235
- function b(e) {
236
- typeof e == "object" && e !== null && e.$$typeof === h && e._store && (e._store.validated = 1);
235
+ function c(e) {
236
+ typeof e == "object" && e !== null && e.$$typeof === w && e._store && (e._store.validated = 1);
237
237
  }
238
- var T = ie, h = Symbol.for("react.transitional.element"), A = Symbol.for("react.portal"), O = Symbol.for("react.fragment"), N = Symbol.for("react.strict_mode"), j = Symbol.for("react.profiler"), W = Symbol.for("react.consumer"), V = Symbol.for("react.context"), U = Symbol.for("react.forward_ref"), B = Symbol.for("react.suspense"), q = Symbol.for("react.suspense_list"), J = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), z = Symbol.for("react.activity"), x = Symbol.for("react.client.reference"), F = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Y = Object.prototype.hasOwnProperty, I = Array.isArray, $ = console.createTask ? console.createTask : function() {
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
- T = {
241
+ p = {
242
242
  "react-stack-bottom-frame": function(e) {
243
243
  return e();
244
244
  }
245
245
  };
246
- var t, p = {}, d = T["react-stack-bottom-frame"].bind(
247
- T,
246
+ var k, y = {}, O = p["react-stack-bottom-frame"].bind(
247
+ p,
248
248
  a
249
- )(), k = $(l(a)), y = {};
250
- L.Fragment = O, L.jsx = function(e, r, s, _, w) {
251
- var S = 1e4 > F.recentlyCreatedOwnerStacks++;
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
- r,
255
- s,
254
+ t,
255
+ l,
256
256
  !1,
257
257
  _,
258
- w,
259
- S ? Error("react-stack-top-frame") : d,
260
- S ? $(l(e)) : k
258
+ j,
259
+ S ? Error("react-stack-top-frame") : O,
260
+ S ? f(d(e)) : z
261
261
  );
262
- }, L.jsxs = function(e, r, s, _, w) {
263
- var S = 1e4 > F.recentlyCreatedOwnerStacks++;
262
+ }, I.jsxs = function(e, t, l, _, j) {
263
+ var S = 1e4 > D.recentlyCreatedOwnerStacks++;
264
264
  return g(
265
265
  e,
266
- r,
267
- s,
266
+ t,
267
+ l,
268
268
  !0,
269
269
  _,
270
- w,
271
- S ? Error("react-stack-top-frame") : d,
272
- S ? $(l(e)) : k
270
+ j,
271
+ S ? Error("react-stack-top-frame") : O,
272
+ S ? f(d(e)) : z
273
273
  );
274
274
  };
275
- }()), L;
275
+ }()), I;
276
276
  }
277
- var ne;
278
- function me() {
279
- return ne || (ne = 1, process.env.NODE_ENV === "production" ? G.exports = Ee() : G.exports = be()), G.exports;
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 oe = me();
282
- const ce = fe({}), Re = () => de(ce), pe = (o, n) => {
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: n,
284
+ form: r,
292
285
  method: i,
293
- action: l,
294
- children: c,
286
+ action: d,
287
+ children: s,
295
288
  onSubmit: a = () => {
296
289
  },
297
- onInput: E = () => {
290
+ onInput: b = () => {
298
291
  },
299
292
  onChange: u = () => {
300
293
  },
301
- numberFields: m = [],
302
- className: f,
294
+ numberFields: E = [],
295
+ className: m,
303
296
  ...g
304
- }) => (ee(() => n.actions.registerOnchange(u), [u]), /* @__PURE__ */ oe.jsx(ce.Provider, { value: n, children: /* @__PURE__ */ oe.jsx(
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: n == null ? void 0 : n.ref,
308
- action: l,
309
- className: f,
310
- onSubmit: (b) => {
311
- i || b.preventDefault();
312
- const T = n.actions.loadFormValues();
313
- a(T);
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: (b) => {
316
- if (b.target.tagName === "FORM") {
317
- const T = n.actions.loadFormValues();
318
- n.actions.setFormState(T);
308
+ onInput: (c) => {
309
+ if (c.target.tagName === "FORM") {
310
+ const p = r.actions.loadFormValues();
311
+ r.actions.setFormState(p);
319
312
  } else
320
- E(b);
313
+ b(c);
321
314
  },
322
315
  onChange: () => {
323
- const b = n.actions.loadFormValues();
324
- n.actions.setFormState(b);
316
+ const c = r.actions.loadFormValues();
317
+ r.actions.setFormState(c);
325
318
  },
326
- onReset: (b) => {
327
- n && (b.preventDefault(), n.actions.reset());
319
+ onReset: (c) => {
320
+ r && (c.preventDefault(), r.actions.reset());
328
321
  },
329
322
  ...g,
330
- children: c
323
+ children: s
331
324
  },
332
- n == null ? void 0 : n.lastReloadedAt
333
- ) })), ve = ({ name: o, defaultValue: n, render: i = ({ ref: l, name: c, defaultValue: a, value: E, setValue: u }) => null }) => {
334
- const [l, c] = X(n), a = Re(), E = C(), u = R(
335
- (m, { shouldDirty: f = !1 } = {}) => {
336
- a.actions.setFormState((g) => ({ ...g, [o]: m }), { shouldDirty: f }), c(m);
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
- [c, a.actions.setFormState]
331
+ [s, a.actions.setFormState]
339
332
  );
340
- return ee(() => (a.actions.setFormState((f) => ({ ...f, [o]: n }), { shouldDirty: !1 }), a.subscribe(o, (f, { shouldDirty: g = !0, shouldOnChange: b = !0 } = {}) => {
341
- c(f), a.actions.setFormState((T) => ({ ...T, [o]: f }), { shouldDirty: g, shouldOnChange: b }), E.current && typeof E.current.dispatchEvent == "function" && b && E.current.dispatchEvent(new Event("change"));
342
- })), []), i({ ref: E, name: o, defaultValue: n, value: l, setValue: u });
343
- }, ue = () => {
344
- const [o, n] = X({}), i = se(() => Object.values(o).filter(Boolean).length > 0, [o]), l = R((u, m) => {
345
- n((f) => f[u] === m ? f : { ...f, [u]: m });
346
- }, []), c = R((u) => {
347
- n((m) => ({ ...m, ...u }));
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
- n((m) => m[u] ? { ...m, [u]: "" } : m);
350
- }, []), E = R(() => {
351
- n({});
349
+ r((E) => E[u] ? { ...E, [u]: "" } : E);
350
+ }, []), b = R(() => {
351
+ r({});
352
352
  }, []);
353
- return { isError: i, errors: o, changeError: l, changeErrors: c, clearError: a, clearErrors: E };
354
- }, K = {
355
- defaultValues: {},
356
- numberFields: []
357
- }, Te = (o = K) => {
358
- const { defaultValues: n = K.defaultValues, numberFields: i = K.numberFields } = o, { changeError: l, errors: c, changeErrors: a, clearError: E, clearErrors: u, isError: m } = ue(), [f, g] = X(!1), [b, T] = X(null), h = C({}), A = C(n), O = C({}), N = C(() => {
359
- }), j = C(), W = R(
360
- (t, { shouldDirty: p = !0, shouldOnChange: d = !0 } = {}) => {
361
- let k = t;
362
- typeof t == "function" && (k = t(h.current)), h.current = k;
363
- let y = f;
364
- p && (y = pe(h.current, A.current), y !== f && g(y)), d && N.current(h.current);
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
- [f]
367
- ), V = R(() => T((/* @__PURE__ */ new Date()).toString()), []), U = R(() => {
368
- g(!1), u();
369
- const t = O.current;
370
- Object.keys(t).forEach((p) => {
371
- const d = t[p];
372
- d(A.current[p], { shouldDirty: !1, shouldOnChange: !1 });
373
- }), j.current && j.current.reset(), V();
374
- }, [u]), B = R((t, p) => {
375
- const d = O.current;
376
- return d[t] = p, () => d[t] = null;
377
- }, []), q = R((t) => (N.current = t, () => N.current = () => {
378
- })), J = R((t) => ae(t.target), []), D = R((t) => t ? h.current[t] : h.current, []), z = R(() => A.current, []), x = R(() => {
379
- setTimeout(() => j.current.dispatchEvent(new Event("input", { bubbles: !0 })));
380
- }, []), F = R(
381
- (t) => {
382
- const p = ae(t.target);
383
- p ? l(t.target.name, p) : l(t.target.name, null);
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
- [l]
386
- ), Y = R(
387
- (t, p, { shouldDirty: d = !0, shouldOnChange: k = !0 } = {}) => {
388
- const y = O.current;
389
- switch (typeof t) {
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 e = y[t];
393
- if (!e)
394
- throw new Error(`${t} is uncontrolled, please use Controller for it!`);
395
- e(p, { shouldDirty: d, shouldOnChange: k }), k && x();
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(t).forEach(([e, r]) => {
400
- const s = y[e];
401
- if (!s)
402
- throw new Error(`${e} is uncontrolled, please use Controller for it!`);
403
- s(r, { shouldDirty: d, shouldOnChange: k });
404
- }), k && x();
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
- [x]
410
- ), I = R(() => {
411
- const t = Object.fromEntries(new FormData(j.current)), p = O.current;
412
- return Object.keys(p).map((d) => {
413
- t[d] = h.current[d];
414
- }), i.forEach((d) => t.hasOwnProperty(d) && (t[d] = +t[d])), t;
415
- }, []), $ = se(
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: Y,
418
- instantChange: x,
419
- getDefaultValues: z,
420
- getFormState: D,
421
- setFormState: W,
422
- changeError: l,
423
- changeErrors: a,
424
- clearError: E,
425
- clearErrors: u,
426
- loadFormValues: I,
427
- checkValidity: F,
428
- getFieldValidity: J,
429
- registerOnchange: q,
430
- reload: V,
431
- reset: U
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
- F,
435
+ A,
445
436
  q,
446
- V,
447
- U
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 ee(() => {
451
- if (j.current) {
452
- const t = I();
453
- A.current = { ...t, ...n }, h.current = { ...t, ...n };
450
+ return K(() => {
451
+ if (h.current) {
452
+ const n = N();
453
+ p.current = n, c.current = n;
454
454
  }
455
- }, [b]), { ref: j, lastReloadedAt: b, isDirty: f, isError: m, errors: c, numberFields: i, subscribe: B, actions: $ };
456
- }, he = {
457
- Form: _e,
458
- Controller: ve,
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
- ve as Controller,
464
- _e as Form,
465
- he as default,
466
- Te as useForm,
467
- ue as useValidateForm
461
+ ge as Controller,
462
+ Te as Form,
463
+ he as useForm,
464
+ Re as useValidateForm
468
465
  };