react-simple-formkit 2.2.6 → 2.3.0

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