react-simple-formkit 2.4.7 → 2.4.8

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