@gen-epix/ui-client-casedb 4.0.2 → 4.2.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.
Files changed (69) hide show
  1. package/dist/_chunks/AddCasesToEventDialog.js +98 -98
  2. package/dist/_chunks/AddCasesToEventDialog.js.map +1 -1
  3. package/dist/_chunks/CaseContentForm.js +10 -10
  4. package/dist/_chunks/CaseDbDownloadUtil.js +1 -1
  5. package/dist/_chunks/CaseDbDownloadUtil.js.map +1 -1
  6. package/dist/_chunks/CaseInfoDialog.js +222 -222
  7. package/dist/_chunks/CaseInfoDialog.js.map +1 -1
  8. package/dist/_chunks/CaseSetInfoDialog.js +222 -222
  9. package/dist/_chunks/CaseSetInfoDialog.js.map +1 -1
  10. package/dist/_chunks/CasesAlreadyInCaseSetWarning.js.map +1 -1
  11. package/dist/_chunks/Dashboard.js +296 -295
  12. package/dist/_chunks/Dashboard.js.map +1 -1
  13. package/dist/_chunks/FindSimilarCasesDialog.js +81 -81
  14. package/dist/_chunks/FindSimilarCasesDialog.js.map +1 -1
  15. package/dist/_chunks/HomePageTrends.js.map +1 -1
  16. package/dist/_chunks/LegendaItem.js.map +1 -1
  17. package/dist/_chunks/LineListWidget.js +46 -45
  18. package/dist/_chunks/LineListWidget.js.map +1 -1
  19. package/dist/_chunks/PanelSeparator.js +3 -3
  20. package/dist/_chunks/PanelSeparator.js.map +1 -1
  21. package/dist/_chunks/Upload.js +422 -418
  22. package/dist/_chunks/Upload.js.map +1 -1
  23. package/dist/_chunks/UploadUtil.js +44 -40
  24. package/dist/_chunks/UploadUtil.js.map +1 -1
  25. package/dist/_chunks/chunk-BV7QT456.js +1 -1
  26. package/dist/_chunks/chunk-BV7QT456.js.map +1 -1
  27. package/dist/_chunks/cloneDeep.js +1 -1
  28. package/dist/_chunks/cloneDeep.js.map +1 -1
  29. package/dist/_chunks/dashboardStore.js.map +1 -1
  30. package/dist/_chunks/esm.js +3 -3
  31. package/dist/_chunks/esm.js.map +1 -1
  32. package/dist/_chunks/index.module.js +1 -1
  33. package/dist/_chunks/index.module.js.map +1 -1
  34. package/dist/_chunks/react.js +1 -1
  35. package/dist/_chunks/react.js.map +1 -1
  36. package/dist/_chunks/shallow.js +2 -2
  37. package/dist/_chunks/shallow.js.map +1 -1
  38. package/dist/_chunks/vanilla.js +1 -1
  39. package/dist/_chunks/vanilla.js.map +1 -1
  40. package/dist/_chunks/yup.js +24 -24
  41. package/dist/_chunks/yup.js.map +1 -1
  42. package/dist/classes/services/EventBusService/EventBusService.d.ts +9 -2
  43. package/dist/classes/services/EventBusService/index.js.map +1 -1
  44. package/dist/components/form/fields/ArrangementEditor/index.js +30 -30
  45. package/dist/components/ui/CreateEventDialog/index.js +40 -40
  46. package/dist/components/ui/CreateEventDialog/index.js.map +1 -1
  47. package/dist/components/ui/MapWidget/index.js.map +1 -1
  48. package/dist/components/ui/RemoveCasesFromEventDialog/index.js.map +1 -1
  49. package/dist/components/ui/SequenceDownloadDialog/index.js +57 -44
  50. package/dist/components/ui/SequenceDownloadDialog/index.js.map +1 -1
  51. package/dist/components/ui/TreeWidget/index.js +8 -2
  52. package/dist/components/ui/TreeWidget/index.js.map +1 -1
  53. package/dist/locale/en.json +0 -11
  54. package/dist/locale/nl.json +0 -11
  55. package/dist/models/config.d.ts +2 -0
  56. package/dist/pages/UserEffectiveRightsTesterAdminPage/index.js +59 -59
  57. package/dist/pages/UserEffectiveRightsTesterAdminPage/index.js.map +1 -1
  58. package/dist/utils/UploadUtil/UploadUtil.d.ts +1 -0
  59. package/package.json +68 -75
  60. package/dist/_chunks/index.esm.js +0 -1465
  61. package/dist/_chunks/index.esm.js.map +0 -1
  62. package/dist/components/ui/FileSelector/FileSelector.d.ts +0 -7
  63. package/dist/components/ui/FileSelector/index.d.ts +0 -1
  64. package/dist/components/ui/FileSelector/index.js +0 -206
  65. package/dist/components/ui/FileSelector/index.js.map +0 -1
  66. package/dist/utils/FileUtil/FileUtil.d.ts +0 -5
  67. package/dist/utils/FileUtil/index.d.ts +0 -1
  68. package/dist/utils/FileUtil/index.js +0 -15
  69. package/dist/utils/FileUtil/index.js.map +0 -1
@@ -1,1465 +0,0 @@
1
- import e from "react";
2
- //#region ../../node_modules/.pnpm/react-hook-form@7.87.0_react@19.2.8/node_modules/react-hook-form/dist/index.esm.mjs
3
- var t = (e) => e.type === "checkbox", n = (e) => e.type === "file", r = (e) => e instanceof Date, i = (e) => e == null, a = (e) => typeof e == "object", o = (e) => !i(e) && !Array.isArray(e) && a(e) && !r(e), s = (e) => o(e) && e.target ? t(e.target) ? e.target.checked : n(e.target) ? e.target.files : e.target.value : e, c = /[.[\]'"]/, l = (e) => e.split(c).filter(Boolean);
4
- function u(e, t) {
5
- let n = l(t), r = e._formValues, i = e._defaultValues;
6
- for (let e = 0; e < n.length - 1; e++) {
7
- let t = n[e];
8
- if (r = r == null ? r : r[t], i = i == null ? i : i[t], r === null || i === null) return null;
9
- }
10
- }
11
- var d = (e, t) => t.split(".").some((t, n, r) => !isNaN(Number(t)) && e.has(r.slice(0, n).join("."))), f = typeof window < "u" && window.HTMLElement !== void 0 && typeof document < "u";
12
- function p(e) {
13
- if (typeof e != "object" || !e) return e;
14
- if (e instanceof Date) return new Date(e);
15
- let t = typeof FileList < "u" && e instanceof FileList;
16
- if (f && (e instanceof Blob || t)) return e;
17
- let n = Array.isArray(e);
18
- if (!n && e.constructor !== Object) return e;
19
- let r = n ? [] : Object.create(Object.getPrototypeOf(e));
20
- for (let t in e) Object.prototype.hasOwnProperty.call(e, t) && (r[t] = p(e[t]));
21
- return r;
22
- }
23
- var m = {
24
- BLUR: "blur",
25
- FOCUS_OUT: "focusout",
26
- CHANGE: "change",
27
- SUBMIT: "submit",
28
- TRIGGER: "trigger",
29
- VALID: "valid"
30
- }, h = {
31
- onBlur: "onBlur",
32
- onChange: "onChange",
33
- onSubmit: "onSubmit",
34
- onTouched: "onTouched",
35
- all: "all"
36
- }, g = {
37
- max: "max",
38
- min: "min",
39
- maxLength: "maxLength",
40
- minLength: "minLength",
41
- pattern: "pattern",
42
- required: "required",
43
- validate: "validate"
44
- }, _ = "root", v = [
45
- "__proto__",
46
- "constructor",
47
- "prototype"
48
- ], y = /^\w*$/, b = (e) => y.test(e), x = (e) => e === void 0, S = (e, t, n) => {
49
- if (!t || !o(e)) return n;
50
- let r = b(t) ? [t] : l(t);
51
- if (r.some((e) => v.includes(e))) return n;
52
- let a = r.reduce((e, t) => i(e) ? void 0 : e[t], e);
53
- return x(a) || a === e ? x(e[t]) ? n : e[t] : a;
54
- }, C = (e) => typeof e == "boolean", w = (e) => typeof e == "function", T = (e, t, n) => {
55
- let r = -1, i = b(t) ? [t] : l(t), a = i.length, s = a - 1;
56
- for (; ++r < a;) {
57
- let t = i[r], a = n;
58
- if (r !== s) {
59
- let n = e[t];
60
- a = o(n) || Array.isArray(n) ? n : isNaN(+i[r + 1]) ? {} : [];
61
- }
62
- if (v.includes(t)) return;
63
- e[t] = a, e = e[t];
64
- }
65
- }, E = e.createContext(null);
66
- E.displayName = "HookFormControlContext";
67
- var D = () => e.useContext(E), O = (e, t, n, r = !0) => {
68
- let i = {};
69
- for (let a in e) Object.defineProperty(i, a, { get: () => {
70
- let i = a;
71
- return t._proxyFormState[i] !== h.all && (t._proxyFormState[i] = !r || h.all), n && (n[i] = !0), e[i];
72
- } });
73
- return i;
74
- }, k = f ? e.useLayoutEffect : e.useEffect, A = (e) => {
75
- let t = e.constructor && e.constructor.prototype;
76
- return o(t) && t.hasOwnProperty("isPrototypeOf");
77
- }, j = (e) => i(e) || !a(e), M = (e, t) => t.length === 0 && !Array.isArray(e) && !A(e);
78
- function N(e, t, n = /* @__PURE__ */ new WeakMap()) {
79
- if (e === t) return !0;
80
- if (j(e) || j(t)) return Object.is(e, t);
81
- if (r(e) && r(t)) return Object.is(e.getTime(), t.getTime());
82
- let i = Object.keys(e), a = Object.keys(t);
83
- if (i.length !== a.length) return !1;
84
- if (M(e, i) || M(t, a)) return Object.is(e, t);
85
- if (!i.length && Array.isArray(e) !== Array.isArray(t)) return !1;
86
- let s = n.get(e);
87
- if (s && s.has(t)) return !0;
88
- if (s) s.add(t);
89
- else {
90
- let r = /* @__PURE__ */ new WeakSet();
91
- r.add(t), n.set(e, r);
92
- }
93
- for (let a of i) {
94
- let i = e[a];
95
- if (!(a in t)) return !1;
96
- if (a !== "ref") {
97
- let e = t[a];
98
- if (r(i) && r(e) || (o(i) || Array.isArray(i)) && (o(e) || Array.isArray(e)) ? !N(i, e, n) : !Object.is(i, e)) return !1;
99
- }
100
- }
101
- return !0;
102
- }
103
- function P(t) {
104
- let n = e.useRef(!1), r = e.useRef(!1), i = e.useRef(void 0), a = e.useRef(0);
105
- return a.current++, !r.current && t && (r.current = !0, i.current = p(t())), {
106
- resyncIfNeeded: e.useCallback((e, t, o) => {
107
- if (e && (n.current || r.current && a.current > 1)) {
108
- let e = t();
109
- N(i.current, e) || o(e);
110
- }
111
- n.current = !0;
112
- }, []),
113
- snapshot: e.useCallback((e, t) => {
114
- e && (i.current = p(t()));
115
- }, [])
116
- };
117
- }
118
- function F(t) {
119
- let n = D(), { control: r = n, disabled: i, name: a, exact: o } = t || {}, s = () => ({
120
- ...r._formState,
121
- defaultValues: r._defaultValues
122
- }), [c, l] = e.useState(s), u = e.useRef({
123
- isDirty: !1,
124
- isLoading: !1,
125
- dirtyFields: !1,
126
- touchedFields: !1,
127
- validatingFields: !1,
128
- isValidating: !1,
129
- isValid: !1,
130
- errors: !1
131
- }), { resyncIfNeeded: d, snapshot: f } = P(s);
132
- return k(() => {
133
- d(!i, s, l);
134
- let e = r._subscribe({
135
- name: a,
136
- formState: u.current,
137
- exact: o,
138
- callback: (e) => {
139
- !i && l({
140
- ...r._formState,
141
- ...e,
142
- defaultValues: r._defaultValues
143
- });
144
- }
145
- });
146
- return () => {
147
- e(), f(!i, s);
148
- };
149
- }, [
150
- a,
151
- i,
152
- o,
153
- d,
154
- f
155
- ]), e.useEffect(() => {
156
- u.current.isValid && r._setValid(!0);
157
- }, [r]), e.useMemo(() => O(c, r, u.current, !1), [c, r]);
158
- }
159
- var I = (e) => typeof e == "string", L = (e, t, n, r, i) => I(e) ? (r && t.watch.add(e), S(n, e, i)) : Array.isArray(e) ? e.map((e) => (r && t.watch.add(e), S(n, e, S(i, e)))) : (r && (t.watchAll = !0), n);
160
- function R(t) {
161
- let n = D(), { control: r = n, name: i, defaultValue: a, disabled: o, exact: s, compute: c } = t || {}, l = e.useRef(a), u = e.useRef(c), d = e.useRef(void 0), f = e.useRef(r), p = e.useRef(i);
162
- u.current = c;
163
- let m = () => {
164
- let e = r._getWatch(i, l.current);
165
- return u.current ? u.current(e) : e;
166
- }, [h, g] = e.useState(m), _ = e.useCallback((e) => {
167
- let t = L(i, r._names, e || r._formValues, !1, l.current);
168
- return u.current ? u.current(t) : t;
169
- }, [
170
- r._formValues,
171
- r._names,
172
- i
173
- ]), v = e.useCallback((e) => {
174
- if (!o) {
175
- let t = L(i, r._names, e || r._formValues, !1, l.current);
176
- if (u.current) {
177
- let e = u.current(t);
178
- N(e, d.current) || (g(e), d.current = e);
179
- } else g(t);
180
- }
181
- }, [
182
- r._formValues,
183
- r._names,
184
- o,
185
- i
186
- ]), { resyncIfNeeded: y, snapshot: b } = P(m), x = e.useRef(v);
187
- x.current = v;
188
- let S = e.useRef(_);
189
- S.current = _, k(() => {
190
- f.current !== r || !N(p.current, i) ? (f.current = r, p.current = i, x.current()) : y(!o, () => S.current(), (e) => {
191
- g(e), d.current = e;
192
- });
193
- let e = r._subscribe({
194
- name: i,
195
- formState: { values: !0 },
196
- exact: s,
197
- callback: (e) => {
198
- x.current(e.values);
199
- }
200
- });
201
- return () => {
202
- e(), b(!o, () => S.current());
203
- };
204
- }, [
205
- r,
206
- s,
207
- i,
208
- o,
209
- y,
210
- b
211
- ]), e.useEffect(() => r._removeUnmounted());
212
- let C = f.current !== r, w = p.current;
213
- return e.useMemo(() => {
214
- if (o) return !1;
215
- let e = !C && !N(w, i);
216
- return C || e;
217
- }, [
218
- o,
219
- C,
220
- i,
221
- w
222
- ]) ? _() : h;
223
- }
224
- function z(t) {
225
- let n = D(), { name: r, disabled: i, control: a = n, shouldUnregister: o, defaultValue: c, exact: l = !0 } = t, f = d(a._names.array, r), h = R({
226
- control: a,
227
- name: r,
228
- defaultValue: e.useMemo(() => {
229
- let e = S(a._formValues, r, S(a._defaultValues, r, c));
230
- return x(e) ? u(a, r) : e;
231
- }, [
232
- a,
233
- r,
234
- c
235
- ]),
236
- exact: l
237
- }), g = F({
238
- control: a,
239
- name: r,
240
- exact: l
241
- }), _ = e.useRef(t), v = e.useRef(null), y = e.useRef(a.register(r, {
242
- ...t.rules,
243
- value: h,
244
- ...C(t.disabled) ? { disabled: t.disabled } : {}
245
- }));
246
- _.current = t;
247
- let b = e.useMemo(() => Object.defineProperties({}, {
248
- invalid: {
249
- enumerable: !0,
250
- get: () => !!S(g.errors, r)
251
- },
252
- isDirty: {
253
- enumerable: !0,
254
- get: () => !!S(g.dirtyFields, r)
255
- },
256
- isTouched: {
257
- enumerable: !0,
258
- get: () => !!S(g.touchedFields, r)
259
- },
260
- isValidating: {
261
- enumerable: !0,
262
- get: () => !!S(g.validatingFields, r)
263
- },
264
- error: {
265
- enumerable: !0,
266
- get: () => S(g.errors, r)
267
- }
268
- }), [g, r]), E = e.useCallback((e) => {
269
- let t = s(e);
270
- return S(a._fields, r) || (y.current = a.register(r, {
271
- ..._.current.rules,
272
- value: t
273
- })), y.current.onChange({
274
- target: {
275
- value: s(e),
276
- name: r
277
- },
278
- type: m.CHANGE
279
- });
280
- }, [r, a]), O = e.useCallback(() => y.current.onBlur({
281
- target: {
282
- value: S(a._formValues, r),
283
- name: r
284
- },
285
- type: m.BLUR
286
- }), [r, a._formValues]), k = e.useCallback((e) => {
287
- e && (v.current = {
288
- focus: () => w(e.focus) && e.focus(),
289
- select: () => w(e.select) && e.select(),
290
- setCustomValidity: (t) => w(e.setCustomValidity) && e.setCustomValidity(t),
291
- reportValidity: () => w(e.reportValidity) && e.reportValidity()
292
- });
293
- let t = S(a._fields, r);
294
- t && t._f && e && (t._f.ref = v.current);
295
- }, [a._fields, r]), A = e.useMemo(() => ({
296
- name: r,
297
- value: h,
298
- ...C(i) || g.disabled ? { disabled: g.disabled || i } : {},
299
- onChange: E,
300
- onBlur: O,
301
- ref: k
302
- }), [
303
- r,
304
- i,
305
- g.disabled,
306
- E,
307
- O,
308
- k,
309
- h
310
- ]);
311
- return e.useEffect(() => {
312
- let e = a._options.shouldUnregister || o;
313
- y.current = a.register(r, {
314
- ..._.current.rules,
315
- ...C(_.current.disabled) ? { disabled: _.current.disabled } : {}
316
- });
317
- let t = (e, t) => {
318
- let n = S(a._fields, e);
319
- n && n._f && (n._f.mount = t);
320
- };
321
- if (t(r, !0), e) {
322
- let e = p(S(o ? a._defaultValues : a._options.values || a._defaultValues, r, S(a._options.defaultValues, r, _.current.defaultValue)));
323
- T(a._defaultValues, r, e), x(S(a._formValues, r)) && T(a._formValues, r, e);
324
- }
325
- if (!f && a.register(r), v.current) {
326
- let e = S(a._fields, r);
327
- e && e._f && (e._f.ref = v.current);
328
- }
329
- return () => {
330
- (f ? e && !a._state.action : e) ? a.unregister(r) : t(r, !1);
331
- };
332
- }, [
333
- r,
334
- a,
335
- f,
336
- o
337
- ]), e.useEffect(() => {
338
- a._setDisabledField({
339
- disabled: i,
340
- name: r
341
- });
342
- }, [
343
- i,
344
- r,
345
- a
346
- ]), e.useMemo(() => ({
347
- field: A,
348
- formState: g,
349
- fieldState: b
350
- }), [
351
- A,
352
- g,
353
- b
354
- ]);
355
- }
356
- var ee = (e) => e.render(z(e)), te = (e) => ({
357
- isOnSubmit: !e || e === h.onSubmit,
358
- isOnBlur: e === h.onBlur,
359
- isOnChange: e === h.onChange,
360
- isOnAll: e === h.all,
361
- isOnTouch: e === h.onTouched
362
- }), ne = (e, t, n) => {
363
- if (n) return !1;
364
- if (t.watchAll || t.watch.has(e)) return !0;
365
- for (let n of t.watch) if (e.startsWith(n) && e.charAt(n.length) === ".") return !0;
366
- return !1;
367
- }, B = (e, t, n, r) => {
368
- for (let i of n || Object.keys(e)) {
369
- if (i === "_f") continue;
370
- let a = n ? S(e, i) : e[i];
371
- if (a) {
372
- let { _f: e } = a;
373
- if (e) {
374
- if (e.refs && e.refs[0] && t(e.refs[0], i) && !r || e.ref && t(e.ref, e.name) && !r) return !0;
375
- if (B(a, t)) break;
376
- } else if ((o(a) || Array.isArray(a)) && B(a, t)) break;
377
- }
378
- }
379
- }, re = (e, t, n) => {
380
- let r = S(e, n), i = Array.isArray(r) ? r : [];
381
- return T(i, _, t[n]), T(e, n, i), e;
382
- }, V = (e) => o(e) && !Object.keys(e).length, ie = (e) => {
383
- if (!f) return !1;
384
- let t = e ? e.ownerDocument : 0;
385
- return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
386
- }, H = (e) => e.type === "radio", U = (e) => e instanceof RegExp, W = (e, t, n, r, i) => t ? {
387
- ...n[e],
388
- types: {
389
- ...n[e] && n[e].types ? n[e].types : {},
390
- [r]: i || !0
391
- }
392
- } : {}, G = {
393
- value: !1,
394
- isValid: !1
395
- }, ae = {
396
- value: !0,
397
- isValid: !0
398
- }, oe = (e) => {
399
- if (!Array.isArray(e)) return G;
400
- if (e.length > 1) {
401
- let t = e.filter((e) => e && e.checked && !e.disabled).map((e) => e.value);
402
- return {
403
- value: t,
404
- isValid: !!t.length
405
- };
406
- }
407
- let t = e[0];
408
- return !t || !t.checked || t.disabled ? G : !t.attributes || !("value" in t.attributes) || x(t.value) || t.value === "" ? ae : {
409
- value: t.value,
410
- isValid: !0
411
- };
412
- }, se = {
413
- isValid: !1,
414
- value: null
415
- }, ce = (e) => Array.isArray(e) ? e.reduce((e, t) => t && t.checked && !t.disabled ? {
416
- isValid: !0,
417
- value: t.value
418
- } : e, se) : se;
419
- function le(e, t, n = "validate") {
420
- if (I(e) || Array.isArray(e) && e.every(I) || C(e) && !e) return {
421
- type: n,
422
- message: I(e) ? e : "",
423
- ref: t
424
- };
425
- }
426
- var K = (e) => o(e) && !U(e) ? e : {
427
- value: e,
428
- message: ""
429
- }, ue = async (e, a, s, c, l, u) => {
430
- let { ref: d, refs: f, required: p, maxLength: m, minLength: h, min: _, max: v, pattern: y, validate: b, name: T, valueAsNumber: E, mount: D } = e._f, O = S(s, T);
431
- if (!D || a.has(T)) return {};
432
- let k = f ? f[0] : d, A = (e) => {
433
- if (l && k.reportValidity) {
434
- let t = C(e) ? "" : e || "";
435
- f ? f.forEach((e) => e.setCustomValidity(t)) : k.setCustomValidity(t), k.reportValidity();
436
- }
437
- }, j = {}, M = H(d), N = t(d), P = M || N, F = (E || n(d)) && x(d.value) && x(O) || ie(d) && d.value === "" || O === "" || Array.isArray(O) && !O.length, L = W.bind(null, T, c, j), R = (e, t, n, r = g.maxLength, i = g.minLength) => {
438
- let a = e ? t : n;
439
- j[T] = {
440
- type: e ? r : i,
441
- message: a,
442
- ref: d,
443
- ...L(e ? r : i, a)
444
- };
445
- };
446
- if (u ? !Array.isArray(O) || !O.length : p && (!P && (F || i(O)) || C(O) && !O || N && !oe(f).isValid || M && !ce(f).isValid)) {
447
- let { value: e, message: t } = I(p) ? {
448
- value: !!p,
449
- message: p
450
- } : K(p);
451
- if (e && (j[T] = {
452
- type: g.required,
453
- message: t,
454
- ref: k,
455
- ...L(g.required, t)
456
- }, !c)) return A(t), j;
457
- }
458
- if (!F && (!i(_) || !i(v))) {
459
- let e, t, n = K(v), a = K(_);
460
- if (!i(O) && !r(O) && !isNaN(O)) {
461
- let r = d.valueAsNumber || O && +O;
462
- i(n.value) || (e = r > n.value), i(a.value) || (t = r < a.value);
463
- } else {
464
- let r = d.valueAsDate || new Date(O), i = (e) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + e), o = d.type == "time", s = d.type == "week";
465
- I(n.value) && O && (e = o ? i(O) > i(n.value) : s ? O > n.value : r > new Date(n.value)), I(a.value) && O && (t = o ? i(O) < i(a.value) : s ? O < a.value : r < new Date(a.value));
466
- }
467
- if ((e || t) && (R(!!e, n.message, a.message, g.max, g.min), !c)) return A(j[T].message), j;
468
- }
469
- if ((m || h) && !F && (I(O) || u && Array.isArray(O))) {
470
- let e = K(m), t = K(h), n = !i(e.value) && O.length > +e.value, r = !i(t.value) && O.length < +t.value;
471
- if ((n || r) && (R(n, e.message, t.message), !c)) return A(j[T].message), j;
472
- }
473
- if (y && !F && I(O)) {
474
- let { value: e, message: t } = K(y);
475
- if (U(e) && !O.match(e) && (j[T] = {
476
- type: g.pattern,
477
- message: t,
478
- ref: d,
479
- ...L(g.pattern, t)
480
- }, !c)) return A(t), j;
481
- }
482
- if (b) {
483
- if (w(b)) {
484
- let e = le(await b(O, s), k);
485
- if (e && (j[T] = {
486
- ...e,
487
- ...L(g.validate, e.message)
488
- }, !c)) return A(e.message), j;
489
- } else if (o(b)) {
490
- let e = {};
491
- for (let t in b) {
492
- if (!V(e) && !c) break;
493
- let n = le(await b[t](O, s), k, t);
494
- n && (e = {
495
- ...n,
496
- ...L(t, n.message)
497
- }, A(n.message), c && (j[T] = e));
498
- }
499
- if (!V(e) && (j[T] = {
500
- ref: k,
501
- ...e
502
- }, !c)) return j;
503
- }
504
- }
505
- let z = j[T];
506
- return A(!z || z.message), j;
507
- }, de = (e) => Array.isArray(e) ? e : [e], fe = (e) => Array.isArray(e) ? e.filter(Boolean) : [];
508
- function pe(e, t) {
509
- let n = t.length - 1, r = 0;
510
- for (; r < n;) {
511
- if (i(e)) {
512
- e = void 0;
513
- break;
514
- }
515
- e = e[t[r]], r++;
516
- }
517
- return e;
518
- }
519
- function me(e) {
520
- for (let t in e) if (e.hasOwnProperty(t) && !x(e[t])) return !1;
521
- return !0;
522
- }
523
- function q(e, t) {
524
- if (I(t) && Object.prototype.hasOwnProperty.call(e, t)) return delete e[t], e;
525
- let n = Array.isArray(t) ? t : b(t) ? [t] : l(t);
526
- if (n.some((e) => v.includes(String(e)))) return e;
527
- let r = n.length === 1 ? e : pe(e, n), i = n.length - 1, a = n[i];
528
- return r && delete r[a], i !== 0 && (o(r) && V(r) || Array.isArray(r) && me(r)) && q(e, n.slice(0, -1)), e;
529
- }
530
- var he = e.createContext(null);
531
- he.displayName = "HookFormContext";
532
- var J = () => e.useContext(he), ge = ({ children: t, watch: n, getValues: r, getErrors: i, getFieldState: a, setError: o, clearErrors: s, setValue: c, setValues: l, trigger: u, formState: d, resetField: f, reset: p, resetDefaultValues: m, handleSubmit: h, unregister: g, control: _, register: v, setFocus: y, subscribe: b }) => {
533
- let x = e.useMemo(() => ({
534
- watch: n,
535
- getValues: r,
536
- getErrors: i,
537
- getFieldState: a,
538
- setError: o,
539
- clearErrors: s,
540
- setValue: c,
541
- setValues: l,
542
- trigger: u,
543
- formState: d,
544
- resetField: f,
545
- reset: p,
546
- resetDefaultValues: m,
547
- handleSubmit: h,
548
- unregister: g,
549
- control: _,
550
- register: v,
551
- setFocus: y,
552
- subscribe: b
553
- }), [
554
- s,
555
- _,
556
- d,
557
- i,
558
- a,
559
- r,
560
- h,
561
- v,
562
- p,
563
- m,
564
- f,
565
- o,
566
- y,
567
- c,
568
- l,
569
- b,
570
- u,
571
- g,
572
- n
573
- ]);
574
- return e.createElement(he.Provider, { value: x }, e.createElement(E.Provider, { value: x.control }, t));
575
- }, _e = () => {
576
- let e = [];
577
- return {
578
- get observers() {
579
- return e;
580
- },
581
- next: (t) => {
582
- for (let n of e) n.next && n.next(t);
583
- },
584
- subscribe: (t) => (e.push(t), { unsubscribe: () => {
585
- e = e.filter((e) => e !== t);
586
- } }),
587
- unsubscribe: () => {
588
- e = [];
589
- }
590
- };
591
- };
592
- function ve(e, t) {
593
- let n = {};
594
- for (let r in e) if (e.hasOwnProperty(r)) {
595
- let i = e[r], a = t[r];
596
- if (i && o(i) && a) {
597
- let e = ve(i, a);
598
- o(e) && (n[r] = e);
599
- } else e[r] && (n[r] = a);
600
- }
601
- return n;
602
- }
603
- var ye = (e, t) => e !== null && a(e) && Object.prototype.hasOwnProperty.call(e, t), be = (e, t) => {
604
- if (!t) return !1;
605
- let n = e;
606
- for (let r of b(t) ? [t] : l(t)) {
607
- if (!ye(n, r)) return ye(e, t);
608
- n = n[r];
609
- }
610
- return !0;
611
- }, xe = (e) => e.type === "select-multiple", Se = (e) => H(e) || t(e), Ce = (e) => ie(e) && e.isConnected;
612
- function Y(e) {
613
- return Array.isArray(e) || o(e);
614
- }
615
- function we(e, t, n = "", r = []) {
616
- for (let i in e) {
617
- let a = n ? `${n}.${i}` : i, o = e[i];
618
- Y(o) && Y(S(t, a)) ? we(o, t, a, r) : r.push(a);
619
- }
620
- return r;
621
- }
622
- var Te = (e) => {
623
- for (let t in e) if (w(e[t])) return !0;
624
- return !1;
625
- };
626
- function X(e) {
627
- return Array.isArray(e) || o(e) && !Te(e);
628
- }
629
- function Ee(e) {
630
- return !!(e && "_f" in e);
631
- }
632
- function De(e) {
633
- return Array.isArray(e) ? !e.some((e) => !x(e)) : !Object.keys(e).length;
634
- }
635
- function Z(e, t) {
636
- Array.isArray(e) ? e[t] = void 0 : delete e[t];
637
- }
638
- function Oe(e, t = {}, n) {
639
- for (let r in e) {
640
- let i = e[r], a = n && n[r];
641
- X(i) && (!Array.isArray(i) || !Ee(a)) ? (t[r] = Array.isArray(i) ? [] : {}, Oe(i, t[r], a), De(t[r]) && Z(t, r)) : x(i) || (t[r] = !0);
642
- }
643
- return t;
644
- }
645
- function Q(e, t, n, r) {
646
- n ||= Oe(t, {}, r);
647
- for (let a in e) {
648
- let o = e[a], s = r && r[a];
649
- X(o) && (!Array.isArray(o) || !Ee(s)) ? (x(t) || j(n[a]) ? n[a] = Oe(o, Array.isArray(o) ? [] : {}, s) : Q(o, i(t) ? {} : t[a], n[a], s), De(n[a]) && Z(n, a)) : N(o, t[a]) ? Z(n, a) : n[a] = !0;
650
- }
651
- return n;
652
- }
653
- var ke = (e, t) => {
654
- let n = t.split("."), r = [], i = n[0];
655
- for (let t = 1; t < n.length; i += "." + n[t++]) !isNaN(+n[t]) && e.has(i) && r.push(`${i}.${n[t]}`);
656
- return r;
657
- }, Ae = (e, { valueAsNumber: t, valueAsDate: n, setValueAs: r }) => x(e) ? e : t ? e === "" ? NaN : e && +e : n && I(e) ? new Date(e) : r ? r(e) : e;
658
- function je(e) {
659
- let r = e.ref;
660
- return n(r) ? r.files : H(r) ? ce(e.refs).value : xe(r) ? [...r.selectedOptions].map(({ value: e }) => e) : t(r) ? oe(e.refs).value : Ae(r.value, e);
661
- }
662
- var Me = (e, t, n, r) => {
663
- let i = {};
664
- for (let n of e) {
665
- let e = S(t, n);
666
- e && T(i, n, e._f);
667
- }
668
- return {
669
- criteriaMode: n,
670
- names: [...e],
671
- fields: i,
672
- shouldUseNativeValidation: r
673
- };
674
- }, Ne = (e) => x(e) ? e : U(e) ? e.source : o(e) ? U(e.value) ? e.value.source : e.value : e, Pe = "AsyncFunction", Fe = (e) => {
675
- if (!e || !e.validate) return !1;
676
- if (w(e.validate)) return e.validate.constructor.name === Pe;
677
- if (o(e.validate)) {
678
- for (let t in e.validate) if (e.validate[t].constructor.name === Pe) return !0;
679
- }
680
- return !1;
681
- }, Ie = (e) => e.mount && (e.required || !x(e.required) && e.required !== !1 || !x(e.min) || !x(e.max) || !x(e.maxLength) || !x(e.minLength) || e.pattern || e.validate);
682
- function Le(e, t, n) {
683
- let r = S(e, n);
684
- if (r || b(n)) return {
685
- error: r,
686
- name: n
687
- };
688
- let i = n.split(".");
689
- for (; i.length;) {
690
- let r = i.join("."), a = S(t, r), o = S(e, r);
691
- if (a && !Array.isArray(a) && n !== r) return { name: n };
692
- if (o && o.type) return {
693
- name: r,
694
- error: o
695
- };
696
- if (o && o.root && o.root.type) return {
697
- name: `${r}.root`,
698
- error: o.root
699
- };
700
- i.pop();
701
- }
702
- return { name: n };
703
- }
704
- var Re = (e, t, n, r) => {
705
- n(e);
706
- let i = Object.keys(e).filter((e) => e !== "name");
707
- return !i.length || r && i.length >= Object.keys(t).length || i.find((e) => t[e] === (!r || h.all));
708
- }, ze = (e, t, n) => !e || !t || e === t || de(e).some((e) => e && (n ? e === t || e.startsWith(t + ".") : e.startsWith(t) || t.startsWith(e))), Be = (e, t, n, r, i) => i.isOnAll ? !1 : !n && i.isOnTouch ? !(t || e) : (n ? r.isOnBlur : i.isOnBlur) ? !e : !(n ? r.isOnChange : i.isOnChange) || e, Ve = (e, t) => {
709
- let n = S(e, t);
710
- !fe(n).length && !(n != null && n.root) && q(e, t);
711
- }, He = {
712
- mode: h.onSubmit,
713
- reValidateMode: h.onChange,
714
- shouldFocusError: !0
715
- }, Ue = "form", We = (e, t) => {
716
- for (let n in e) n in t || delete e[n];
717
- Object.assign(e, t);
718
- }, Ge = {
719
- submitCount: 0,
720
- isDirty: !1,
721
- isReady: !1,
722
- isValidating: !1,
723
- isSubmitted: !1,
724
- isSubmitting: !1,
725
- isSubmitSuccessful: !1,
726
- isValid: !1,
727
- touchedFields: {},
728
- dirtyFields: {},
729
- validatingFields: {}
730
- };
731
- function $(e = {}) {
732
- let a = {
733
- ...He,
734
- ...e
735
- }, c = {
736
- ...p(Ge),
737
- isLoading: w(a.defaultValues),
738
- errors: a.errors || {},
739
- disabled: a.disabled || !1
740
- }, u = {}, v = (o(a.defaultValues) || o(a.values)) && p(a.defaultValues || a.values) || {}, y = a.shouldUnregister ? {} : p(v), E = {
741
- action: !1,
742
- actionArrayLengths: /* @__PURE__ */ new Map(),
743
- mount: !1,
744
- watch: !1,
745
- keepIsValid: !1
746
- }, D = {
747
- mount: /* @__PURE__ */ new Set(),
748
- disabled: /* @__PURE__ */ new Set(),
749
- unMount: /* @__PURE__ */ new Set(),
750
- array: /* @__PURE__ */ new Set(),
751
- watch: /* @__PURE__ */ new Set(),
752
- registerName: /* @__PURE__ */ new Set()
753
- }, O = {}, k = {}, A = 0, j = te(a.mode), M = te(a.reValidateMode), P = {
754
- isDirty: !1,
755
- dirtyFields: !1,
756
- validatingFields: !1,
757
- touchedFields: !1,
758
- isValidating: !1,
759
- isValid: !1,
760
- errors: !1
761
- }, F = { ...P }, R = { ...F }, z = {
762
- array: _e(),
763
- state: _e()
764
- }, ee = 0, H = a.criteriaMode === h.all, U = (e, t) => (n) => {
765
- clearTimeout(k[e]), k[e] = setTimeout(t, n);
766
- }, W = async (e) => {
767
- if (!E.keepIsValid && !a.disabled && (F.isValid || R.isValid || e)) {
768
- let e = ++ee, t;
769
- a.resolver ? (t = V((await J()).errors), e === ee && G()) : t = await Y({
770
- fields: u,
771
- onlyCheckValid: !0,
772
- eventType: m.VALID
773
- }), e === ee && t !== c.isValid && z.state.next({ isValid: t });
774
- }
775
- }, G = (e, t) => {
776
- !a.disabled && (F.isValidating || F.validatingFields || R.isValidating || R.validatingFields) && ((e || D.mount).forEach((e) => {
777
- e && (t ? T(c.validatingFields, e, t) : q(c.validatingFields, e));
778
- }), z.state.next({
779
- validatingFields: c.validatingFields,
780
- isValidating: !V(c.validatingFields)
781
- }));
782
- }, ae = () => {
783
- c.dirtyFields = Q(v, y, void 0, u);
784
- }, oe = (e, t = [], n, r, i = !0, o = !0) => {
785
- if (r && n && !a.disabled) {
786
- E.action = !0;
787
- let a = S(u, e);
788
- if (E.actionArrayLengths.has(e) || E.actionArrayLengths.set(e, Array.isArray(a) ? a.length : 0), o && Array.isArray(a)) {
789
- let t = n(a, r.argA, r.argB);
790
- i && T(u, e, t);
791
- }
792
- let s = S(c.errors, e);
793
- if (o && Array.isArray(s)) {
794
- let t = s.root, a = n(s, r.argA, r.argB) || s;
795
- t && (a.root = t), i && T(c.errors, e, a), Ve(c.errors, e);
796
- }
797
- let l = S(c.touchedFields, e);
798
- if ((F.touchedFields || R.touchedFields) && o && Array.isArray(l)) {
799
- let t = n(l, r.argA, r.argB);
800
- i && T(c.touchedFields, e, t);
801
- }
802
- (F.dirtyFields || R.dirtyFields) && ae(), z.state.next({
803
- name: e,
804
- isDirty: X(e, t),
805
- dirtyFields: c.dirtyFields,
806
- errors: c.errors,
807
- isValid: c.isValid
808
- });
809
- } else T(y, e, t);
810
- }, se = (e, t) => {
811
- T(c.errors, e, t), c.errors = { ...c.errors }, z.state.next({ errors: c.errors });
812
- }, ce = (e) => {
813
- c.errors = e, z.state.next({
814
- errors: c.errors,
815
- isValid: !1
816
- });
817
- }, le = (e) => {
818
- let t = b(e) ? [e] : l(e), n = y, r = v;
819
- for (let e = 0; e < t.length - 1; e++) {
820
- let a = t[e];
821
- if (n = i(n) ? n : n[a], r = i(r) ? r : r[a], n === null && r !== null) return !0;
822
- }
823
- return !1;
824
- }, K = (e) => {
825
- if (!E.actionArrayLengths.size) return !1;
826
- let t = b(e) ? [e] : l(e), n = y, r = "", a = -1, o = 0;
827
- for (let e = 0; e < t.length; e++) {
828
- if (i(n)) return !1;
829
- let s = t[e];
830
- if (r = r ? `${r}.${s}` : s, Array.isArray(n) && +s >= n.length) return a === -1 ? !1 : e !== a || +s < o;
831
- E.actionArrayLengths.has(r) && (a = e + 1, o = E.actionArrayLengths.get(r)), n = n[s];
832
- }
833
- return !1;
834
- }, pe = (t, n, r, i) => {
835
- let a = S(u, t);
836
- if (a) {
837
- if (le(t) || K(t)) return;
838
- let o = x(S(y, t)), s = S(y, t, x(r) ? S(v, t) : r);
839
- x(s) || i && i.defaultChecked || n ? T(y, t, n ? s : je(a._f)) : Z(t, s), E.mount && !E.action && (W(), o && c.isDirty && (F.isDirty || R.isDirty) && (X() || (c.isDirty = !1, z.state.next({ ...c }))), e.shouldUnregister && o && !x(S(y, t)) && ne(t, D) && (E.watch = !0));
840
- }
841
- }, me = (e, t, n, r, i) => {
842
- let o = !1, s = !1, l = { name: e };
843
- if (!a.disabled || r === !0) {
844
- if (!n || r) {
845
- let n = N(S(v, e), t);
846
- (F.isDirty || R.isDirty) && (s = c.isDirty, c.isDirty = l.isDirty = !n || X(), o = s !== l.isDirty), s = !!S(c.dirtyFields, e), n === c.isDirty ? n ? q(c.dirtyFields, e) : T(c.dirtyFields, e, !0) : We(c.dirtyFields, Q(v, y, void 0, u)), l.dirtyFields = c.dirtyFields, o ||= (F.dirtyFields || R.dirtyFields) && s !== !n;
847
- }
848
- if (n) {
849
- let t = S(c.touchedFields, e);
850
- t || (T(c.touchedFields, e, n), l.touchedFields = c.touchedFields, o ||= (F.touchedFields || R.touchedFields) && t !== n);
851
- }
852
- o && i && z.state.next(l);
853
- }
854
- return o ? l : {};
855
- }, he = (e, t, n, r) => {
856
- let i = S(c.errors, e), o = (F.isValid || R.isValid) && C(t) && c.isValid !== t;
857
- if (a.delayError && n ? (O[e] = U(e, () => se(e, n)), O[e](a.delayError)) : (clearTimeout(k[e]), delete O[e], n ? T(c.errors, e, n) : q(c.errors, e), c.errors = { ...c.errors }), (n ? !N(i, n) : i) || !V(r) || o) {
858
- let n = {
859
- ...r,
860
- ...o && C(t) ? { isValid: t } : {},
861
- errors: c.errors,
862
- name: e
863
- };
864
- z.state.next(n);
865
- }
866
- }, J = async (e) => (G(e, !0), await a.resolver(y, a.context, Me(e || D.mount, u, a.criteriaMode, a.shouldUseNativeValidation))), ge = async (e) => {
867
- let { errors: t } = await J(e);
868
- if (G(e), e) {
869
- for (let n of e) {
870
- let e = S(t, n);
871
- e ? D.array.has(n) && o(e) && !Object.keys(e).some((e) => !Number.isNaN(Number(e))) ? re(c.errors, { [n]: e }, n) : T(c.errors, n, e) : q(c.errors, n);
872
- }
873
- c.errors = { ...c.errors };
874
- } else c.errors = t;
875
- return t;
876
- }, ye = async ({ name: t, eventType: n }) => {
877
- if (e.validate) {
878
- let r = await e.validate({
879
- formValues: y,
880
- formState: c,
881
- name: t,
882
- eventType: n
883
- });
884
- if (o(r)) for (let e in r) {
885
- let t = r[e];
886
- t && et(`${Ue}.${e}`, {
887
- message: I(t.message) ? t.message : "",
888
- type: t.type || g.validate
889
- });
890
- }
891
- else I(r) || !r ? et(Ue, {
892
- message: r || "",
893
- type: g.validate
894
- }) : $e(Ue);
895
- return r;
896
- }
897
- return !0;
898
- }, Y = async ({ fields: t, onlyCheckValid: n, name: r, eventType: i, context: o = {
899
- valid: !0,
900
- runRootValidation: !1
901
- } }) => {
902
- if (e.validate && (o.runRootValidation = !0, !await ye({
903
- name: r,
904
- eventType: i
905
- }) && (o.valid = !1, n))) return o.valid;
906
- for (let r in t) {
907
- let s = t[r];
908
- if (s) {
909
- let { _f: t, ...l } = s;
910
- if (t) {
911
- let r = D.array.has(t.name), i = s._f && Fe(s._f), l = F.validatingFields || F.isValidating || R.validatingFields || R.isValidating;
912
- i && l && G([t.name], !0);
913
- let u = await ue(s, D.disabled, y, H, a.shouldUseNativeValidation && !n, r);
914
- if (i && l && G([t.name]), u[t.name] && (o.valid = !1, n) || (!n && (S(u, t.name) ? r ? re(c.errors, u, t.name) : T(c.errors, t.name, u[t.name]) : q(c.errors, t.name)), e.shouldUseNativeValidation && u[t.name])) break;
915
- }
916
- !V(l) && await Y({
917
- context: o,
918
- onlyCheckValid: n,
919
- fields: l,
920
- name: r,
921
- eventType: i
922
- });
923
- }
924
- }
925
- return o.valid;
926
- }, Te = () => {
927
- for (let e of D.unMount) {
928
- let t = S(u, e);
929
- t && (t._f.refs ? t._f.refs.every((e) => !Ce(e)) : !Ce(t._f.ref)) && it(e);
930
- }
931
- D.unMount = /* @__PURE__ */ new Set();
932
- }, X = (e, t) => (e && t && T(y, e, t), !N(E.mount ? y : v, v)), Ee = (e, t, n) => L(e, D, { ...E.mount ? y : x(t) || I(e) ? v : t }, n, t), De = (e) => fe(S(E.mount ? y : v, e, a.shouldUnregister ? S(v, e, []) : [])), Z = (e, r, a = {}, o = !1, s = !1, c = !1) => {
933
- let l = S(u, e), d = r;
934
- if (l) {
935
- let a = l._f;
936
- a && (!a.disabled && T(y, e, Ae(r, a)), d = ie(a.ref) && i(r) ? "" : r, xe(a.ref) ? [...a.ref.options].forEach((e) => e.selected = d.includes(e.value)) : a.refs ? t(a.ref) ? a.refs.forEach((e) => {
937
- (!e.defaultChecked || !e.disabled) && (e.checked = Array.isArray(d) ? !!d.find((t) => t === e.value) : d === e.value || !!d);
938
- }) : a.refs.forEach((e) => e.checked = e.value === d) : n(a.ref) ? a.ref.value = "" : (a.ref.value = d, !a.ref.type && !s && !c && z.state.next({
939
- name: e,
940
- values: o ? y : p(y)
941
- })));
942
- }
943
- (a.shouldDirty || a.shouldTouch) && me(e, d, a.shouldTouch, a.shouldDirty, !s), a.shouldValidate && Ye(e, { delayError: a.delayError });
944
- }, Oe = (e, t, n, i = !1, a = !1, s = !1) => {
945
- D.array.has(e) && z.array.next({
946
- name: e,
947
- values: i ? y : p(y)
948
- });
949
- for (let c in t) {
950
- if (!t.hasOwnProperty(c)) continue;
951
- let l = t[c], d = e + "." + c, f = S(u, d);
952
- (D.array.has(e) || o(l) || f && !f._f) && !r(l) ? Oe(d, l, n, i, a, s) : Z(d, l, n, i, a, s);
953
- }
954
- }, Pe = (e, t, n, r, a = !1) => {
955
- let o = S(u, e), s = D.array.has(e), l = r ? t : p(t), d = N(S(y, e), l);
956
- if (d || T(y, e, l), s) z.array.next({
957
- name: e,
958
- values: r ? y : p(y)
959
- }), (F.isDirty || F.dirtyFields || R.isDirty || R.dirtyFields) && n.shouldDirty && (ae(), a || z.state.next({
960
- name: e,
961
- dirtyFields: c.dirtyFields,
962
- isDirty: X(e, l)
963
- }));
964
- else {
965
- let t = Array.isArray(l) && !l.length || V(l), s = !d && !a;
966
- !o || o._f || i(l) || t ? Z(e, l, n, r, a, s) : Oe(e, l, n, r, a, s);
967
- }
968
- if (!d && !a) {
969
- let t = ne(e, D), n = r ? y : p(y);
970
- if (z.state.next({
971
- ...t && c,
972
- name: E.mount || t ? e : void 0,
973
- values: n
974
- }), !s) for (let t of ke(D.array, e)) z.state.next({
975
- name: t,
976
- values: n
977
- });
978
- }
979
- }, $ = (e, t, n = {}) => Pe(e, t, n, !1), Ke = (e, t = {}) => {
980
- let n = w(e) ? e(y) : e;
981
- if (!N(y, n)) {
982
- y = {
983
- ...y,
984
- ...n
985
- };
986
- for (let e of D.mount) be(n, e) && Pe(e, S(n, e), t, !0, !0);
987
- z.state.next({
988
- ...c,
989
- name: void 0,
990
- type: void 0,
991
- ...A ? { values: y } : {}
992
- }), t.shouldValidate && W();
993
- }
994
- }, qe = async (t) => {
995
- E.mount = !0;
996
- let n = t.target, i = n.name, o = !0, l = S(u, i), d = (e) => {
997
- o = Number.isNaN(e) || r(e) && isNaN(e.getTime()) || N(e, S(y, i, e));
998
- };
999
- if (l) {
1000
- let r, f, h = n.type ? je(l._f) : s(t), g = t.type === m.BLUR || t.type === m.FOCUS_OUT, _ = !Ie(l._f) && !e.validate && !a.resolver && !S(c.errors, i) && !l._f.deps, v = _ || Be(g, S(c.touchedFields, i), c.isSubmitted, M, j), b = ne(i, D, g);
1001
- if (T(y, i, p(h)), g) {
1002
- if (!n || !n.readOnly) {
1003
- l._f.onBlur && l._f.onBlur(t);
1004
- let e = O[i];
1005
- e && e(0);
1006
- }
1007
- } else l._f.onChange && l._f.onChange(t);
1008
- let x = me(i, h, g), C = !V(x) || b;
1009
- if (!g && z.state.next({
1010
- name: i,
1011
- type: t.type,
1012
- ...A ? { values: p(y) } : {}
1013
- }), v) return (!_ || !c.isValid) && (F.isValid || R.isValid) && (a.mode === "onBlur" ? g && W() : g || W()), C && z.state.next({
1014
- name: i,
1015
- ...b ? {} : x
1016
- });
1017
- if (!a.resolver && e.validate && await ye({
1018
- name: i,
1019
- eventType: t.type
1020
- }), !g && b && z.state.next({ ...c }), a.resolver) {
1021
- let { errors: e } = await J([i]);
1022
- if (G([i]), d(h), !o) {
1023
- !V(x) && z.state.next(x);
1024
- return;
1025
- }
1026
- let t = Le(c.errors, u, i), n = Le(e, u, t.name || i);
1027
- r = n.error, i = n.name, f = V(e);
1028
- } else G([i], !0), r = (await ue(l, D.disabled, y, H, a.shouldUseNativeValidation))[i], G([i]), d(h), o && (r ? f = !1 : (F.isValid || R.isValid) && (f = await Y({
1029
- fields: u,
1030
- onlyCheckValid: !0,
1031
- name: i,
1032
- eventType: t.type
1033
- })));
1034
- o && (l._f.deps && (!Array.isArray(l._f.deps) || l._f.deps.length > 0) && Ye(l._f.deps), he(i, f, r, x));
1035
- }
1036
- }, Je = (e, t) => {
1037
- if (S(c.errors, t) && e.focus) return e.focus(), 1;
1038
- }, Ye = async (e, t = {}) => {
1039
- let n, r, i = de(e);
1040
- if (a.resolver) {
1041
- let t = await ge(x(e) ? e : i);
1042
- n = V(t), r = e ? !i.some((e) => S(t, e)) : n;
1043
- } else e ? (r = (await Promise.all(i.map(async (e) => {
1044
- let t = S(u, e);
1045
- return await Y({
1046
- fields: t && t._f ? { [e]: t } : t,
1047
- eventType: m.TRIGGER
1048
- });
1049
- }))).every(Boolean), !(!r && !c.isValid) && W()) : r = n = await Y({
1050
- fields: u,
1051
- name: e,
1052
- eventType: m.TRIGGER
1053
- });
1054
- if (t.delayError && a.delayError && I(e)) {
1055
- let t = S(c.errors, e);
1056
- t ? (q(c.errors, e), O[e] = U(e, () => se(e, t)), O[e](a.delayError)) : (clearTimeout(k[e]), delete O[e]);
1057
- }
1058
- if (t.shouldTouch) for (let t of e ? i : D.mount) !D.array.has(t) && T(c.touchedFields, t, !0);
1059
- return z.state.next({
1060
- ...!I(e) || (F.isValid || R.isValid) && n !== c.isValid ? {} : { name: e },
1061
- ...a.resolver || !e ? { isValid: n } : {},
1062
- ...t.shouldTouch && (F.touchedFields || R.touchedFields) ? { touchedFields: c.touchedFields } : {},
1063
- errors: c.errors
1064
- }), t.shouldFocus && !r && B(u, Je, e ? i : D.mount), r;
1065
- }, Xe = (e, t) => {
1066
- let n = { ...E.mount ? y : v };
1067
- return t && (n = ve(t.dirtyFields ? c.dirtyFields : c.touchedFields, n)), x(e) ? n : I(e) ? S(n, e) : e.map((e) => S(n, e));
1068
- }, Ze = (e) => x(e) ? { ...c.errors } : I(e) ? S(c.errors, e) : e.map((e) => S(c.errors, e)), Qe = (e, t) => {
1069
- let n = t || c, r = S(n.errors, e);
1070
- return {
1071
- invalid: !!r,
1072
- isDirty: !!S(n.dirtyFields, e),
1073
- error: r,
1074
- isValidating: !!S(c.validatingFields, e),
1075
- isTouched: !!S(n.touchedFields, e)
1076
- };
1077
- }, $e = (e) => {
1078
- let t = e ? de(e) : void 0;
1079
- t?.forEach((e) => q(c.errors, e)), t ? t.forEach((e) => {
1080
- z.state.next({
1081
- name: e,
1082
- errors: c.errors
1083
- });
1084
- }) : (c.errors = {}, z.state.next({ errors: c.errors }));
1085
- }, et = (e, t, n) => {
1086
- let r = (S(u, e, { _f: {} })._f || {}).ref, { ref: i, message: a, type: o, ...s } = S(c.errors, e) || {};
1087
- T(c.errors, e, {
1088
- ...s,
1089
- ...t,
1090
- ref: r
1091
- }), z.state.next({
1092
- name: e,
1093
- errors: c.errors,
1094
- isValid: !1
1095
- }), n && n.shouldFocus && r && r.focus && r.focus();
1096
- }, tt = (e, t) => {
1097
- if (w(e)) {
1098
- A++;
1099
- let { unsubscribe: n } = z.state.subscribe({ next: (n) => "values" in n && e(n.values || Ee(void 0, t), n) }), r = !1;
1100
- return { unsubscribe: () => {
1101
- r || (r = !0, A--, n());
1102
- } };
1103
- }
1104
- return Ee(e, t, !0);
1105
- }, nt = (e) => {
1106
- let t = !!e.formState?.values;
1107
- t && A++;
1108
- let { unsubscribe: n } = z.state.subscribe({ next: (t) => {
1109
- if (ze(e.name, t.name, e.exact) && Re(t, e.formState || F, mt, e.reRenderRoot)) {
1110
- let n = { ...y };
1111
- e.callback({
1112
- values: n,
1113
- ...c,
1114
- ...t,
1115
- defaultValues: v
1116
- });
1117
- }
1118
- } });
1119
- if (!t) return n;
1120
- let r = !1;
1121
- return () => {
1122
- r || (r = !0, A--, n());
1123
- };
1124
- }, rt = (e) => (E.mount = !0, R = {
1125
- ...R,
1126
- ...e.formState
1127
- }, nt({
1128
- ...e,
1129
- formState: {
1130
- ...P,
1131
- ...e.formState
1132
- }
1133
- })), it = (e, t = {}) => {
1134
- for (let n of e ? de(e) : D.mount) D.mount.delete(n), D.array.delete(n), t.keepValue || (q(u, n), q(y, n)), !t.keepError && q(c.errors, n), !t.keepDirty && q(c.dirtyFields, n), !t.keepTouched && q(c.touchedFields, n), !t.keepIsValidating && q(c.validatingFields, n), !a.shouldUnregister && !t.keepDefaultValue && q(v, n);
1135
- A && z.state.next({ values: p(y) }), z.state.next({
1136
- ...c,
1137
- ...t.keepDirty ? {} : { isDirty: X() }
1138
- }), !t.keepIsValid && W();
1139
- }, at = ({ disabled: e, name: t }) => {
1140
- if (C(e) && E.mount || e || D.disabled.has(t)) {
1141
- let n = D.disabled.has(t) !== !!e;
1142
- e ? D.disabled.add(t) : D.disabled.delete(t), n && E.mount && !E.action && W();
1143
- }
1144
- }, ot = (e, t = {}) => {
1145
- let n = S(u, e), r = C(t.disabled) || C(a.disabled), i = !D.registerName.has(e) && n && n._f && !n._f.mount;
1146
- return T(u, e, {
1147
- ...n || {},
1148
- _f: {
1149
- ...n && n._f ? n._f : { ref: { name: e } },
1150
- name: e,
1151
- mount: !0,
1152
- ...t
1153
- }
1154
- }), D.mount.add(e), n && !i ? at({
1155
- disabled: C(t.disabled) ? t.disabled : a.disabled,
1156
- name: e
1157
- }) : pe(e, !0, t.value), {
1158
- ...r ? { disabled: t.disabled || a.disabled } : {},
1159
- ...a.progressive ? {
1160
- required: !!t.required,
1161
- min: Ne(t.min),
1162
- max: Ne(t.max),
1163
- minLength: Ne(t.minLength),
1164
- maxLength: Ne(t.maxLength),
1165
- pattern: Ne(t.pattern)
1166
- } : {},
1167
- name: e,
1168
- onChange: qe,
1169
- onBlur: qe,
1170
- ref: (r) => {
1171
- if (r) {
1172
- D.registerName.add(e), ot(e, t), D.registerName.delete(e), n = S(u, e);
1173
- let i = x(r.value) && r.querySelectorAll && r.querySelectorAll("input,select,textarea")[0] || r, a = Se(i), o = n._f.refs || [];
1174
- if (a ? o.find((e) => e === i) : i === n._f.ref) return;
1175
- let s = { ...n._f };
1176
- a ? (s.refs = [
1177
- ...o.filter(Ce),
1178
- i,
1179
- ...Array.isArray(S(v, e)) ? [{}] : []
1180
- ], s.ref = {
1181
- type: i.type,
1182
- name: e
1183
- }) : (s.ref = i, delete s.refs), T(u, e, { _f: s }), pe(e, !1, void 0, i);
1184
- } else n = S(u, e, {}), n._f && (n._f.mount = !1), (a.shouldUnregister || t.shouldUnregister) && !(d(D.array, e) && E.action) && D.unMount.add(e);
1185
- }
1186
- };
1187
- }, st = () => a.shouldFocusError && !a.shouldUseNativeValidation && B(u, Je, D.mount), ct = (e) => {
1188
- C(e) && (z.state.next({ disabled: e }), B(u, (t, n) => {
1189
- let r = S(u, n);
1190
- r && (t.disabled = r._f.disabled || e, Array.isArray(r._f.refs) && r._f.refs.forEach((t) => {
1191
- t.disabled = r._f.disabled || e;
1192
- }));
1193
- }, 0, !1));
1194
- }, lt = (e, t) => async (n) => {
1195
- let r, i;
1196
- n && (n.preventDefault && n.preventDefault(), n.persist && n.persist());
1197
- let o = p(y);
1198
- if (z.state.next({ isSubmitting: !0 }), a.resolver) {
1199
- let { errors: e, values: t } = await J();
1200
- G(), c.errors = e, o = p(t);
1201
- } else await Y({
1202
- fields: u,
1203
- eventType: m.SUBMIT
1204
- });
1205
- if (D.disabled.size) for (let e of D.disabled) q(o, e);
1206
- if (q(c.errors, _), V(c.errors)) {
1207
- z.state.next({ errors: {} });
1208
- try {
1209
- r = await e(o, n);
1210
- } catch (e) {
1211
- i = e;
1212
- }
1213
- } else t && await t({ ...c.errors }, n), st(), setTimeout(st);
1214
- if (z.state.next({
1215
- isSubmitted: !0,
1216
- isSubmitting: !1,
1217
- isSubmitSuccessful: V(c.errors) && !i,
1218
- submitCount: c.submitCount + 1,
1219
- errors: c.errors
1220
- }), i) throw i;
1221
- return r;
1222
- }, ut = (e, t = {}) => {
1223
- S(u, e) && (x(t.defaultValue) ? $(e, p(S(v, e))) : ($(e, t.defaultValue), T(v, e, p(t.defaultValue))), t.keepTouched || q(c.touchedFields, e), t.keepDirty || (q(c.dirtyFields, e), c.isDirty = t.defaultValue ? X(e, p(S(v, e))) : X()), t.keepError || (q(c.errors, e), W()), z.state.next({ ...c }));
1224
- }, dt = (e, t = {}) => {
1225
- let n = e ? p(e) : v, r = p(n), i = V(e), o = r, s = u;
1226
- if (t.keepDefaultValues || (v = n), !t.keepValues) {
1227
- if (t.keepDirtyValues) {
1228
- let e = /* @__PURE__ */ new Set([...D.mount, ...we(Q(v, y, void 0, s), c.dirtyFields)]);
1229
- for (let t of e) {
1230
- let e = S(c.dirtyFields, t), n = S(y, t), r = S(o, t);
1231
- e && !x(n) ? T(o, t, n) : !e && !x(r) && $(t, r);
1232
- }
1233
- } else {
1234
- if (f && x(e)) for (let e of D.mount) {
1235
- let t = S(u, e);
1236
- if (t && t._f) {
1237
- let e = Array.isArray(t._f.refs) ? t._f.refs[0] : t._f.ref;
1238
- if (ie(e)) {
1239
- let t = e.closest("form");
1240
- if (t) {
1241
- t.reset();
1242
- break;
1243
- }
1244
- }
1245
- }
1246
- }
1247
- if (t.keepFieldsRef) for (let e of D.mount) $(e, S(o, e));
1248
- else u = {};
1249
- }
1250
- if (a.shouldUnregister) {
1251
- if (y = t.keepDefaultValues ? p(v) : {}, t.keepFieldsRef) for (let e of D.mount) T(y, e, S(o, e));
1252
- } else y = p(o);
1253
- z.array.next({ values: { ...o } }), z.state.next({
1254
- name: void 0,
1255
- type: void 0,
1256
- values: { ...o }
1257
- });
1258
- }
1259
- D = {
1260
- mount: t.keepDirtyValues ? D.mount : /* @__PURE__ */ new Set(),
1261
- unMount: /* @__PURE__ */ new Set(),
1262
- array: /* @__PURE__ */ new Set(),
1263
- registerName: /* @__PURE__ */ new Set(),
1264
- disabled: /* @__PURE__ */ new Set(),
1265
- watch: /* @__PURE__ */ new Set(),
1266
- watchAll: !1,
1267
- focus: ""
1268
- }, E.mount = !F.isValid || !!t.keepIsValid || !!t.keepDirtyValues || !a.shouldUnregister && !V(o), E.watch = !!a.shouldUnregister, E.keepIsValid = !!t.keepIsValid, E.action = !1, E.actionArrayLengths.clear(), t.keepErrors || (c.errors = {}), z.state.next({
1269
- submitCount: t.keepSubmitCount ? c.submitCount : 0,
1270
- isDirty: i ? !1 : t.keepDirty ? c.isDirty : t.keepValues ? X() : !!(t.keepDefaultValues && !N(e, v)),
1271
- isSubmitted: t.keepIsSubmitted ? c.isSubmitted : !1,
1272
- dirtyFields: i ? {} : t.keepDirtyValues ? t.keepDefaultValues && y ? Q(v, y, void 0, s) : c.dirtyFields : t.keepDefaultValues && e ? Q(v, e, void 0, s) : t.keepDirty ? c.dirtyFields : {},
1273
- touchedFields: t.keepTouched ? c.touchedFields : {},
1274
- errors: t.keepErrors ? c.errors : {},
1275
- isSubmitSuccessful: t.keepIsSubmitSuccessful ? c.isSubmitSuccessful : !1,
1276
- isSubmitting: !1,
1277
- defaultValues: v
1278
- });
1279
- }, ft = (e, t) => dt(w(e) ? e(y) : e, {
1280
- ...a.resetOptions,
1281
- ...t
1282
- }), pt = (e, t = {}) => {
1283
- let n = S(u, e), r = n && n._f;
1284
- if (r) {
1285
- let e = r.refs ? r.refs[0] : r.ref;
1286
- e.focus && setTimeout(() => {
1287
- e.focus(), t.shouldSelect && w(e.select) && e.select();
1288
- });
1289
- }
1290
- }, mt = (e) => {
1291
- let { name: t, type: n, values: r, ...i } = e;
1292
- c = {
1293
- ...c,
1294
- ...i
1295
- };
1296
- };
1297
- z.state.subscribe({ next: mt });
1298
- let ht = {
1299
- control: {
1300
- register: ot,
1301
- unregister: it,
1302
- getFieldState: Qe,
1303
- handleSubmit: lt,
1304
- setError: et,
1305
- _subscribe: nt,
1306
- _runSchema: J,
1307
- _updateIsValidating: G,
1308
- _focusError: st,
1309
- _getWatch: Ee,
1310
- _getDirty: X,
1311
- _setValid: W,
1312
- _setFieldArray: oe,
1313
- _setDisabledField: at,
1314
- _setErrors: ce,
1315
- _getFieldArray: De,
1316
- _reset: dt,
1317
- _resetDefaultValues: () => w(a.defaultValues) && a.defaultValues().then((e) => {
1318
- ft(e, a.resetOptions), z.state.next({ isLoading: !1 });
1319
- }),
1320
- _removeUnmounted: Te,
1321
- _disableForm: ct,
1322
- _subjects: z,
1323
- _proxyFormState: F,
1324
- get _fields() {
1325
- return u;
1326
- },
1327
- get _formValues() {
1328
- return y;
1329
- },
1330
- get _state() {
1331
- return E;
1332
- },
1333
- set _state(e) {
1334
- E = e;
1335
- },
1336
- get _defaultValues() {
1337
- return v;
1338
- },
1339
- get _names() {
1340
- return D;
1341
- },
1342
- set _names(e) {
1343
- D = e;
1344
- },
1345
- get _formState() {
1346
- return c;
1347
- },
1348
- get _options() {
1349
- return a;
1350
- },
1351
- set _options(e) {
1352
- a = {
1353
- ...a,
1354
- ...e
1355
- }, j = te(a.mode), M = te(a.reValidateMode);
1356
- }
1357
- },
1358
- subscribe: rt,
1359
- trigger: Ye,
1360
- register: ot,
1361
- handleSubmit: lt,
1362
- watch: tt,
1363
- setValue: $,
1364
- setValues: Ke,
1365
- getValues: Xe,
1366
- getErrors: Ze,
1367
- reset: ft,
1368
- resetField: ut,
1369
- resetDefaultValues: (e, t = {}) => {
1370
- if (v = p(e), !t.keepDirty) {
1371
- let e = Q(v, y, void 0, u);
1372
- c.dirtyFields = e, c.isDirty = !V(e);
1373
- }
1374
- t.keepIsValid || W(), z.state.next({
1375
- ...c,
1376
- defaultValues: v
1377
- });
1378
- },
1379
- clearErrors: $e,
1380
- unregister: it,
1381
- setError: et,
1382
- setFocus: pt,
1383
- getFieldState: Qe
1384
- };
1385
- return {
1386
- ...ht,
1387
- formControl: ht
1388
- };
1389
- }
1390
- function Ke(t = {}) {
1391
- let n = e.useRef(void 0), r = e.useRef(void 0), i = e.useRef(t.formControl), [a, o] = e.useState(() => ({
1392
- ...p(Ge),
1393
- isLoading: w(t.defaultValues),
1394
- errors: t.errors || {},
1395
- disabled: t.disabled || !1,
1396
- defaultValues: w(t.defaultValues) ? void 0 : t.defaultValues
1397
- }));
1398
- if (!n.current || t.formControl && i.current !== t.formControl) {
1399
- if (i.current = t.formControl, t.formControl) n.current = {
1400
- ...t.formControl,
1401
- formState: a
1402
- }, t.defaultValues && !w(t.defaultValues) && t.formControl.reset(t.defaultValues, t.resetOptions);
1403
- else {
1404
- let { formControl: e, ...r } = $(t);
1405
- n.current = {
1406
- ...r,
1407
- formState: a
1408
- };
1409
- }
1410
- }
1411
- let s = n.current.control;
1412
- s._options = t;
1413
- let { resyncIfNeeded: c, snapshot: l } = P();
1414
- return k(() => {
1415
- let e = () => ({
1416
- ...s._formState,
1417
- defaultValues: s._defaultValues
1418
- });
1419
- c(!0, e, o);
1420
- let t = s._subscribe({
1421
- formState: s._proxyFormState,
1422
- callback: () => o({
1423
- ...s._formState,
1424
- defaultValues: s._defaultValues
1425
- }),
1426
- reRenderRoot: !0
1427
- });
1428
- return o((e) => ({
1429
- ...e,
1430
- isReady: !0
1431
- })), s._formState.isReady = !0, () => {
1432
- t(), l(!0, e);
1433
- };
1434
- }, [
1435
- s,
1436
- c,
1437
- l
1438
- ]), e.useEffect(() => s._disableForm(t.disabled), [s, t.disabled]), e.useEffect(() => {
1439
- t.mode && (s._options.mode = t.mode), t.reValidateMode && (s._options.reValidateMode = t.reValidateMode);
1440
- }, [
1441
- s,
1442
- t.mode,
1443
- t.reValidateMode
1444
- ]), e.useEffect(() => {
1445
- t.errors && (s._setErrors(t.errors), s._focusError());
1446
- }, [s, t.errors]), e.useEffect(() => {
1447
- t.shouldUnregister && s._subjects.state.next({ values: s._getWatch() });
1448
- }, [s, t.shouldUnregister]), e.useEffect(() => {
1449
- if (s._proxyFormState.isDirty) {
1450
- let e = s._getDirty();
1451
- e !== a.isDirty && s._subjects.state.next({ isDirty: e });
1452
- }
1453
- }, [s, a.isDirty]), e.useEffect(() => {
1454
- t.values && !N(t.values, r.current) ? (s._reset(t.values, {
1455
- keepFieldsRef: !0,
1456
- ...s._options.resetOptions
1457
- }), s._options.resetOptions?.keepIsValid || s._setValid(), r.current = t.values, o((e) => ({ ...e }))) : s._resetDefaultValues();
1458
- }, [s, t.values]), e.useEffect(() => {
1459
- s._state.mount || (s._setValid(), s._state.mount = !0), s._state.watch && (s._state.watch = !1, s._subjects.state.next({ ...s._formState })), s._removeUnmounted();
1460
- }), n.current.formState = e.useMemo(() => O(a, s), [s, a]), n.current;
1461
- }
1462
- //#endregion
1463
- export { T as a, R as c, S as i, ge as n, Ke as o, W as r, J as s, ee as t };
1464
-
1465
- //# sourceMappingURL=index.esm.js.map