zudoku 0.13.5 → 0.13.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/main.js +1 -1
- package/dist/app/main.js.map +1 -1
- package/dist/lib/authentication/components/CallbackHandler.js +21 -31
- package/dist/lib/authentication/components/CallbackHandler.js.map +1 -1
- package/dist/lib/errors/ErrorAlert.d.ts +1 -1
- package/dist/lib/errors/ErrorAlert.js +8 -3
- package/dist/lib/errors/ErrorAlert.js.map +1 -1
- package/dist/lib/plugins/api-keys/CreateApiKey.js +1 -1
- package/dist/lib/plugins/api-keys/CreateApiKey.js.map +1 -1
- package/dist/lib/plugins/openapi/Sidecar.js +2 -2
- package/dist/lib/plugins/openapi/playground/Playground.js +1 -1
- package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +1 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
- package/dist/lib/ui/Accordion.d.ts +7 -0
- package/dist/lib/ui/Accordion.js +14 -0
- package/dist/lib/ui/Accordion.js.map +1 -0
- package/dist/lib/ui/Alert.d.ts +8 -0
- package/dist/lib/ui/Alert.js +23 -0
- package/dist/lib/ui/Alert.js.map +1 -0
- package/dist/lib/ui/AlertDialog.d.ts +20 -0
- package/dist/lib/ui/AlertDialog.js +27 -0
- package/dist/lib/ui/AlertDialog.js.map +1 -0
- package/dist/lib/ui/AspectRatio.d.ts +3 -0
- package/dist/lib/ui/AspectRatio.js +4 -0
- package/dist/lib/ui/AspectRatio.js.map +1 -0
- package/dist/lib/ui/Badge.d.ts +9 -0
- package/dist/lib/ui/Badge.js +21 -0
- package/dist/lib/ui/Badge.js.map +1 -0
- package/dist/lib/ui/Breadcrumb.d.ts +19 -0
- package/dist/lib/ui/Breadcrumb.js +24 -0
- package/dist/lib/ui/Breadcrumb.js.map +1 -0
- package/dist/lib/ui/Button.d.ts +1 -2
- package/dist/lib/ui/Button.js +1 -1
- package/dist/lib/ui/Button.js.map +1 -1
- package/dist/lib/ui/Carousel.d.ts +18 -0
- package/dist/lib/ui/Carousel.js +99 -0
- package/dist/lib/ui/Carousel.js.map +1 -0
- package/dist/lib/ui/Checkbox.d.ts +4 -0
- package/dist/lib/ui/Checkbox.js +9 -0
- package/dist/lib/ui/Checkbox.js.map +1 -0
- package/dist/lib/ui/Collapsible.d.ts +5 -0
- package/dist/lib/ui/Collapsible.js +6 -0
- package/dist/lib/ui/Collapsible.js.map +1 -0
- package/dist/lib/{components → ui}/Dialog.js +2 -2
- package/dist/lib/ui/Dialog.js.map +1 -0
- package/dist/lib/ui/Form.d.ts +23 -0
- package/dist/lib/ui/Form.js +63 -0
- package/dist/lib/ui/Form.js.map +1 -0
- package/dist/lib/ui/HoverCard.d.ts +6 -0
- package/dist/lib/ui/HoverCard.js +10 -0
- package/dist/lib/ui/HoverCard.js.map +1 -0
- package/dist/lib/ui/Label.d.ts +5 -0
- package/dist/lib/ui/Label.js +10 -0
- package/dist/lib/ui/Label.js.map +1 -0
- package/dist/lib/ui/Pagination.d.ts +28 -0
- package/dist/lib/ui/Pagination.js +24 -0
- package/dist/lib/ui/Pagination.js.map +1 -0
- package/dist/lib/ui/Popover.d.ts +6 -0
- package/dist/lib/ui/Popover.js +10 -0
- package/dist/lib/ui/Popover.js.map +1 -0
- package/dist/lib/ui/Progress.d.ts +4 -0
- package/dist/lib/ui/Progress.js +8 -0
- package/dist/lib/ui/Progress.js.map +1 -0
- package/dist/lib/ui/RadioGroup.d.ts +5 -0
- package/dist/lib/ui/RadioGroup.js +15 -0
- package/dist/lib/ui/RadioGroup.js.map +1 -0
- package/dist/lib/ui/ScrollArea.d.ts +5 -0
- package/dist/lib/ui/ScrollArea.js +12 -0
- package/dist/lib/ui/ScrollArea.js.map +1 -0
- package/dist/lib/ui/Select.js.map +1 -0
- package/dist/lib/ui/Skeleton.d.ts +2 -0
- package/dist/lib/ui/Skeleton.js +7 -0
- package/dist/lib/ui/Skeleton.js.map +1 -0
- package/dist/lib/ui/Slider.d.ts +4 -0
- package/dist/lib/ui/Slider.js +8 -0
- package/dist/lib/ui/Slider.js.map +1 -0
- package/dist/lib/ui/Switch.d.ts +4 -0
- package/dist/lib/ui/Switch.js +8 -0
- package/dist/lib/ui/Switch.js.map +1 -0
- package/dist/lib/ui/Textarea.d.ts +4 -0
- package/dist/lib/ui/Textarea.js +9 -0
- package/dist/lib/ui/Textarea.js.map +1 -0
- package/dist/lib/ui/Toggle.d.ts +12 -0
- package/dist/lib/ui/Toggle.js +26 -0
- package/dist/lib/ui/Toggle.js.map +1 -0
- package/dist/lib/ui/ToggleGroup.d.ts +12 -0
- package/dist/lib/ui/ToggleGroup.js +21 -0
- package/dist/lib/ui/ToggleGroup.js.map +1 -0
- package/dist/lib/ui/Tooltip.d.ts +7 -0
- package/dist/lib/ui/Tooltip.js +11 -0
- package/dist/lib/ui/Tooltip.js.map +1 -0
- package/dist/lib/util/invariant.d.ts +9 -0
- package/dist/lib/util/invariant.js +7 -3
- package/dist/lib/util/invariant.js.map +1 -1
- package/dist/vite/plugin-component.js +17 -7
- package/dist/vite/plugin-component.js.map +1 -1
- package/lib/{AuthenticationPlugin-D1nhROkO.js → AuthenticationPlugin-Bpdes0cJ.js} +3 -3
- package/lib/{AuthenticationPlugin-D1nhROkO.js.map → AuthenticationPlugin-Bpdes0cJ.js.map} +1 -1
- package/lib/{CategoryHeading-B7TlPvuN.js → CategoryHeading-Bb9dqxD3.js} +4 -4
- package/lib/{CategoryHeading-B7TlPvuN.js.map → CategoryHeading-Bb9dqxD3.js.map} +1 -1
- package/lib/{DeveloperHint-B_QCCafl.js → DeveloperHint-DHdLXGHA.js} +2 -2
- package/lib/{DeveloperHint-B_QCCafl.js.map → DeveloperHint-DHdLXGHA.js.map} +1 -1
- package/lib/{Markdown-Y__eLG0x.js → Markdown-1BO9EA_X.js} +4265 -6649
- package/lib/Markdown-1BO9EA_X.js.map +1 -0
- package/lib/{MdxPage-B4FcPIi5.js → MdxPage-BEOcOICU.js} +28 -27
- package/lib/{MdxPage-B4FcPIi5.js.map → MdxPage-BEOcOICU.js.map} +1 -1
- package/lib/{OperationList-C2jKCTwZ.js → OperationList-Cea2Yt8e.js} +131 -128
- package/lib/{OperationList-C2jKCTwZ.js.map → OperationList-Cea2Yt8e.js.map} +1 -1
- package/lib/{Route-DWXcQzRK.js → Route-BHT-onwf.js} +3 -3
- package/lib/{Route-DWXcQzRK.js.map → Route-BHT-onwf.js.map} +1 -1
- package/lib/Select-m1aXZGAP.js +223 -0
- package/lib/Select-m1aXZGAP.js.map +1 -0
- package/lib/SlotletProvider-CPfsBw39.js +241 -0
- package/lib/SlotletProvider-CPfsBw39.js.map +1 -0
- package/lib/Spinner-C6zroowC.js +40 -0
- package/lib/Spinner-C6zroowC.js.map +1 -0
- package/lib/StaggeredRender-DDHSzQKE.js +17 -0
- package/lib/StaggeredRender-DDHSzQKE.js.map +1 -0
- package/lib/{ZudokuContext-MRoel6bS.js → ZudokuContext-D1D8Anlj.js} +20 -20
- package/lib/{ZudokuContext-MRoel6bS.js.map → ZudokuContext-D1D8Anlj.js.map} +1 -1
- package/lib/_commonjsHelpers-BkfeUUK-.js +29 -0
- package/lib/_commonjsHelpers-BkfeUUK-.js.map +1 -0
- package/lib/cn-BmFQLtkS.js +2279 -0
- package/lib/cn-BmFQLtkS.js.map +1 -0
- package/lib/hook-JSRuxV1P.js +229 -0
- package/lib/hook-JSRuxV1P.js.map +1 -0
- package/lib/index-Bn6Lc9tq.js +9 -0
- package/lib/{index-DJqnphbT.js.map → index-Bn6Lc9tq.js.map} +1 -1
- package/lib/index-BuAyrJe3.js +46 -0
- package/lib/index-BuAyrJe3.js.map +1 -0
- package/lib/{index-DFN92YJN.js → index-CRo94sKK.js} +5 -4
- package/lib/{index-DFN92YJN.js.map → index-CRo94sKK.js.map} +1 -1
- package/lib/{index-Dso_b0di.js → index-Cj-F-4ME.js} +1207 -1424
- package/lib/index-Cj-F-4ME.js.map +1 -0
- package/lib/{index-D06ATMgg.js → index-LNp6rxyU.js} +2 -2
- package/lib/{index-D06ATMgg.js.map → index-LNp6rxyU.js.map} +1 -1
- package/lib/index.esm-C5mr_sKO.js +1193 -0
- package/lib/index.esm-C5mr_sKO.js.map +1 -0
- package/lib/invariant-Caa8-XvF.js +26 -0
- package/lib/invariant-Caa8-XvF.js.map +1 -0
- package/lib/ui/Accordion.js +47 -0
- package/lib/ui/Accordion.js.map +1 -0
- package/lib/ui/Alert.js +51 -0
- package/lib/ui/Alert.js.map +1 -0
- package/lib/ui/AlertDialog.js +114 -0
- package/lib/ui/AlertDialog.js.map +1 -0
- package/lib/ui/AspectRatio.js +6 -0
- package/lib/ui/AspectRatio.js.map +1 -0
- package/lib/ui/Badge.js +27 -0
- package/lib/ui/Badge.js.map +1 -0
- package/lib/ui/Breadcrumb.js +94 -0
- package/lib/ui/Breadcrumb.js.map +1 -0
- package/lib/ui/Button.js +49 -0
- package/lib/ui/Button.js.map +1 -0
- package/lib/ui/Callout.js +77 -0
- package/lib/ui/Callout.js.map +1 -0
- package/lib/ui/Card.js +62 -0
- package/lib/ui/Card.js.map +1 -0
- package/lib/ui/Carousel.js +1410 -0
- package/lib/ui/Carousel.js.map +1 -0
- package/lib/ui/Checkbox.js +28 -0
- package/lib/ui/Checkbox.js.map +1 -0
- package/lib/ui/Collapsible.js +8 -0
- package/lib/ui/Collapsible.js.map +1 -0
- package/lib/ui/Dialog.js +101 -0
- package/lib/ui/Dialog.js.map +1 -0
- package/lib/ui/Drawer.js +1153 -0
- package/lib/ui/Drawer.js.map +1 -0
- package/lib/ui/DropdownMenu.js +145 -0
- package/lib/ui/DropdownMenu.js.map +1 -0
- package/lib/ui/Form.js +95 -0
- package/lib/ui/Form.js.map +1 -0
- package/lib/ui/HoverCard.js +24 -0
- package/lib/ui/HoverCard.js.map +1 -0
- package/lib/ui/Input.js +22 -0
- package/lib/ui/Input.js.map +1 -0
- package/lib/ui/Label.js +20 -0
- package/lib/ui/Label.js.map +1 -0
- package/lib/ui/Note.js +51 -0
- package/lib/ui/Note.js.map +1 -0
- package/lib/ui/Pagination.js +106 -0
- package/lib/ui/Pagination.js.map +1 -0
- package/lib/ui/Popover.js +24 -0
- package/lib/ui/Popover.js.map +1 -0
- package/lib/ui/Progress.js +27 -0
- package/lib/ui/Progress.js.map +1 -0
- package/lib/ui/RadioGroup.js +32 -0
- package/lib/ui/RadioGroup.js.map +1 -0
- package/lib/ui/ScrollArea.js +39 -0
- package/lib/ui/ScrollArea.js.map +1 -0
- package/lib/ui/Select.js +122 -0
- package/lib/ui/Select.js.map +1 -0
- package/lib/ui/Skeleton.js +18 -0
- package/lib/ui/Skeleton.js.map +1 -0
- package/lib/ui/Slider.js +24 -0
- package/lib/ui/Slider.js.map +1 -0
- package/lib/ui/Switch.js +28 -0
- package/lib/ui/Switch.js.map +1 -0
- package/lib/ui/Tabs.js +47 -0
- package/lib/ui/Tabs.js.map +1 -0
- package/lib/ui/Textarea.js +21 -0
- package/lib/ui/Textarea.js.map +1 -0
- package/lib/ui/Toggle.js +38 -0
- package/lib/ui/Toggle.js.map +1 -0
- package/lib/ui/ToggleGroup.js +42 -0
- package/lib/ui/ToggleGroup.js.map +1 -0
- package/lib/ui/Tooltip.js +24 -0
- package/lib/ui/Tooltip.js.map +1 -0
- package/lib/{useExposedProps-BWwxa-Hg.js → useExposedProps-B9K-9GTc.js} +2 -2
- package/lib/{useExposedProps-BWwxa-Hg.js.map → useExposedProps-B9K-9GTc.js.map} +1 -1
- package/lib/{utils-C8S3st2k.js → utils-B2yoT99j.js} +63 -63
- package/lib/{utils-C8S3st2k.js.map → utils-B2yoT99j.js.map} +1 -1
- package/lib/zudoku.auth-clerk.js +1 -1
- package/lib/zudoku.auth-openid.js +477 -483
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.components.js +847 -2845
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.openapi-worker.js +2 -2
- package/lib/zudoku.plugin-api-keys.js +68 -75
- package/lib/zudoku.plugin-api-keys.js.map +1 -1
- package/lib/zudoku.plugin-custom-pages.js +14 -13
- package/lib/zudoku.plugin-custom-pages.js.map +1 -1
- package/lib/zudoku.plugin-markdown.js +1 -1
- package/lib/zudoku.plugin-openapi.js +6 -6
- package/package.json +28 -6
- package/src/app/main.tsx +1 -1
- package/src/lib/authentication/components/CallbackHandler.tsx +20 -51
- package/src/lib/errors/ErrorAlert.tsx +18 -5
- package/src/lib/plugins/api-keys/CreateApiKey.tsx +2 -2
- package/src/lib/plugins/openapi/Sidecar.tsx +2 -2
- package/src/lib/plugins/openapi/playground/Playground.tsx +3 -3
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +1 -1
- package/src/lib/ui/Accordion.tsx +56 -0
- package/src/lib/ui/Alert.tsx +59 -0
- package/src/lib/ui/AlertDialog.tsx +139 -0
- package/src/lib/ui/AspectRatio.tsx +5 -0
- package/src/lib/ui/Badge.tsx +36 -0
- package/src/lib/ui/Breadcrumb.tsx +115 -0
- package/src/lib/ui/Button.tsx +1 -1
- package/src/lib/ui/Carousel.tsx +260 -0
- package/src/lib/ui/Checkbox.tsx +28 -0
- package/src/lib/ui/Collapsible.tsx +9 -0
- package/src/lib/{components → ui}/Dialog.tsx +4 -3
- package/src/lib/ui/Form.tsx +177 -0
- package/src/lib/ui/HoverCard.tsx +27 -0
- package/src/lib/ui/Label.tsx +24 -0
- package/src/lib/ui/Pagination.tsx +117 -0
- package/src/lib/ui/Popover.tsx +29 -0
- package/src/lib/ui/Progress.tsx +26 -0
- package/src/lib/ui/RadioGroup.tsx +42 -0
- package/src/lib/ui/ScrollArea.tsx +46 -0
- package/src/lib/ui/Skeleton.tsx +15 -0
- package/src/lib/ui/Slider.tsx +26 -0
- package/src/lib/ui/Switch.tsx +27 -0
- package/src/lib/ui/Textarea.tsx +23 -0
- package/src/lib/ui/Toggle.tsx +43 -0
- package/src/lib/ui/ToggleGroup.tsx +59 -0
- package/src/lib/ui/Tooltip.tsx +28 -0
- package/src/lib/util/invariant.ts +15 -3
- package/dist/internal.d.ts +0 -1
- package/dist/internal.js +0 -2
- package/dist/internal.js.map +0 -1
- package/dist/lib/components/Dialog.js.map +0 -1
- package/dist/lib/components/Select.js.map +0 -1
- package/lib/ErrorPage-DqqAV1dr.js +0 -16
- package/lib/ErrorPage-DqqAV1dr.js.map +0 -1
- package/lib/Input-DrR6P3mq.js +0 -2229
- package/lib/Input-DrR6P3mq.js.map +0 -1
- package/lib/Markdown-Y__eLG0x.js.map +0 -1
- package/lib/SidebarBadge-C0iWtji9.js +0 -503
- package/lib/SidebarBadge-C0iWtji9.js.map +0 -1
- package/lib/SlotletProvider-DmqWiVFt.js +0 -239
- package/lib/SlotletProvider-DmqWiVFt.js.map +0 -1
- package/lib/Spinner-3cQDBVGr.js +0 -7
- package/lib/Spinner-3cQDBVGr.js.map +0 -1
- package/lib/index-Ch8VO_uX.js +0 -2867
- package/lib/index-Ch8VO_uX.js.map +0 -1
- package/lib/index-DJqnphbT.js +0 -35
- package/lib/index-Dso_b0di.js.map +0 -1
- package/lib/index-bYAqbdYl.js +0 -124
- package/lib/index-bYAqbdYl.js.map +0 -1
- /package/dist/lib/{components → ui}/Dialog.d.ts +0 -0
- /package/dist/lib/{components → ui}/Select.d.ts +0 -0
- /package/dist/lib/{components → ui}/Select.js +0 -0
- /package/src/lib/{components → ui}/Select.tsx +0 -0
|
@@ -0,0 +1,1193 @@
|
|
|
1
|
+
import F from "react";
|
|
2
|
+
var ge = (e) => e.type === "checkbox", ne = (e) => e instanceof Date, W = (e) => e == null;
|
|
3
|
+
const fr = (e) => typeof e == "object";
|
|
4
|
+
var T = (e) => !W(e) && !Array.isArray(e) && fr(e) && !ne(e), dr = (e) => T(e) && e.target ? ge(e.target) ? e.target.checked : e.target.value : e, Rr = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, yr = (e, s) => e.has(Rr(s)), Lr = (e) => {
|
|
5
|
+
const s = e.constructor && e.constructor.prototype;
|
|
6
|
+
return T(s) && s.hasOwnProperty("isPrototypeOf");
|
|
7
|
+
}, He = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
8
|
+
function M(e) {
|
|
9
|
+
let s;
|
|
10
|
+
const r = Array.isArray(e);
|
|
11
|
+
if (e instanceof Date)
|
|
12
|
+
s = new Date(e);
|
|
13
|
+
else if (e instanceof Set)
|
|
14
|
+
s = new Set(e);
|
|
15
|
+
else if (!(He && (e instanceof Blob || e instanceof FileList)) && (r || T(e)))
|
|
16
|
+
if (s = r ? [] : {}, !r && !Lr(e))
|
|
17
|
+
s = e;
|
|
18
|
+
else
|
|
19
|
+
for (const i in e)
|
|
20
|
+
e.hasOwnProperty(i) && (s[i] = M(e[i]));
|
|
21
|
+
else
|
|
22
|
+
return e;
|
|
23
|
+
return s;
|
|
24
|
+
}
|
|
25
|
+
var ve = (e) => Array.isArray(e) ? e.filter(Boolean) : [], E = (e) => e === void 0, c = (e, s, r) => {
|
|
26
|
+
if (!s || !T(e))
|
|
27
|
+
return r;
|
|
28
|
+
const i = ve(s.split(/[,[\].]+?/)).reduce((u, n) => W(u) ? u : u[n], e);
|
|
29
|
+
return E(i) || i === e ? E(e[s]) ? r : e[s] : i;
|
|
30
|
+
}, G = (e) => typeof e == "boolean", $e = (e) => /^\w*$/.test(e), _r = (e) => ve(e.replace(/["|']|\]/g, "").split(/\.|\[/)), k = (e, s, r) => {
|
|
31
|
+
let i = -1;
|
|
32
|
+
const u = $e(s) ? [s] : _r(s), n = u.length, y = n - 1;
|
|
33
|
+
for (; ++i < n; ) {
|
|
34
|
+
const g = u[i];
|
|
35
|
+
let m = r;
|
|
36
|
+
if (i !== y) {
|
|
37
|
+
const O = e[g];
|
|
38
|
+
m = T(O) || Array.isArray(O) ? O : isNaN(+u[i + 1]) ? {} : [];
|
|
39
|
+
}
|
|
40
|
+
if (g === "__proto__")
|
|
41
|
+
return;
|
|
42
|
+
e[g] = m, e = e[g];
|
|
43
|
+
}
|
|
44
|
+
return e;
|
|
45
|
+
};
|
|
46
|
+
const Ae = {
|
|
47
|
+
BLUR: "blur",
|
|
48
|
+
FOCUS_OUT: "focusout",
|
|
49
|
+
CHANGE: "change"
|
|
50
|
+
}, Y = {
|
|
51
|
+
onBlur: "onBlur",
|
|
52
|
+
onChange: "onChange",
|
|
53
|
+
onSubmit: "onSubmit",
|
|
54
|
+
onTouched: "onTouched",
|
|
55
|
+
all: "all"
|
|
56
|
+
}, re = {
|
|
57
|
+
max: "max",
|
|
58
|
+
min: "min",
|
|
59
|
+
maxLength: "maxLength",
|
|
60
|
+
minLength: "minLength",
|
|
61
|
+
pattern: "pattern",
|
|
62
|
+
required: "required",
|
|
63
|
+
validate: "validate"
|
|
64
|
+
}, gr = F.createContext(null), Se = () => F.useContext(gr), rt = (e) => {
|
|
65
|
+
const { children: s, ...r } = e;
|
|
66
|
+
return F.createElement(gr.Provider, { value: r }, s);
|
|
67
|
+
};
|
|
68
|
+
var vr = (e, s, r, i = !0) => {
|
|
69
|
+
const u = {
|
|
70
|
+
defaultValues: s._defaultValues
|
|
71
|
+
};
|
|
72
|
+
for (const n in e)
|
|
73
|
+
Object.defineProperty(u, n, {
|
|
74
|
+
get: () => {
|
|
75
|
+
const y = n;
|
|
76
|
+
return s._proxyFormState[y] !== Y.all && (s._proxyFormState[y] = !i || Y.all), r && (r[y] = !0), e[y];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return u;
|
|
80
|
+
}, j = (e) => T(e) && !Object.keys(e).length, hr = (e, s, r, i) => {
|
|
81
|
+
r(e);
|
|
82
|
+
const { name: u, ...n } = e;
|
|
83
|
+
return j(n) || Object.keys(n).length >= Object.keys(s).length || Object.keys(n).find((y) => s[y] === (!i || Y.all));
|
|
84
|
+
}, q = (e) => Array.isArray(e) ? e : [e], br = (e, s, r) => !e || !s || e === s || q(e).some((i) => i && (r ? i === s : i.startsWith(s) || s.startsWith(i)));
|
|
85
|
+
function we(e) {
|
|
86
|
+
const s = F.useRef(e);
|
|
87
|
+
s.current = e, F.useEffect(() => {
|
|
88
|
+
const r = !e.disabled && s.current.subject && s.current.subject.subscribe({
|
|
89
|
+
next: s.current.next
|
|
90
|
+
});
|
|
91
|
+
return () => {
|
|
92
|
+
r && r.unsubscribe();
|
|
93
|
+
};
|
|
94
|
+
}, [e.disabled]);
|
|
95
|
+
}
|
|
96
|
+
function Mr(e) {
|
|
97
|
+
const s = Se(), { control: r = s.control, disabled: i, name: u, exact: n } = e || {}, [y, g] = F.useState(r._formState), m = F.useRef(!0), O = F.useRef({
|
|
98
|
+
isDirty: !1,
|
|
99
|
+
isLoading: !1,
|
|
100
|
+
dirtyFields: !1,
|
|
101
|
+
touchedFields: !1,
|
|
102
|
+
validatingFields: !1,
|
|
103
|
+
isValidating: !1,
|
|
104
|
+
isValid: !1,
|
|
105
|
+
errors: !1
|
|
106
|
+
}), A = F.useRef(u);
|
|
107
|
+
return A.current = u, we({
|
|
108
|
+
disabled: i,
|
|
109
|
+
next: (b) => m.current && br(A.current, b.name, n) && hr(b, O.current, r._updateFormState) && g({
|
|
110
|
+
...r._formState,
|
|
111
|
+
...b
|
|
112
|
+
}),
|
|
113
|
+
subject: r._subjects.state
|
|
114
|
+
}), F.useEffect(() => (m.current = !0, O.current.isValid && r._updateValid(!0), () => {
|
|
115
|
+
m.current = !1;
|
|
116
|
+
}), [r]), vr(y, r, O.current, !1);
|
|
117
|
+
}
|
|
118
|
+
var ee = (e) => typeof e == "string", Fr = (e, s, r, i, u) => ee(e) ? (i && s.watch.add(e), c(r, e, u)) : Array.isArray(e) ? e.map((n) => (i && s.watch.add(n), c(r, n))) : (i && (s.watchAll = !0), r);
|
|
119
|
+
function Br(e) {
|
|
120
|
+
const s = Se(), { control: r = s.control, name: i, defaultValue: u, disabled: n, exact: y } = e || {}, g = F.useRef(i);
|
|
121
|
+
g.current = i, we({
|
|
122
|
+
disabled: n,
|
|
123
|
+
subject: r._subjects.values,
|
|
124
|
+
next: (A) => {
|
|
125
|
+
br(g.current, A.name, y) && O(M(Fr(g.current, r._names, A.values || r._formValues, !1, u)));
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const [m, O] = F.useState(r._getWatch(i, u));
|
|
129
|
+
return F.useEffect(() => r._removeUnmounted()), m;
|
|
130
|
+
}
|
|
131
|
+
function Ir(e) {
|
|
132
|
+
const s = Se(), { name: r, disabled: i, control: u = s.control, shouldUnregister: n } = e, y = yr(u._names.array, r), g = Br({
|
|
133
|
+
control: u,
|
|
134
|
+
name: r,
|
|
135
|
+
defaultValue: c(u._formValues, r, c(u._defaultValues, r, e.defaultValue)),
|
|
136
|
+
exact: !0
|
|
137
|
+
}), m = Mr({
|
|
138
|
+
control: u,
|
|
139
|
+
name: r,
|
|
140
|
+
exact: !0
|
|
141
|
+
}), O = F.useRef(u.register(r, {
|
|
142
|
+
...e.rules,
|
|
143
|
+
value: g,
|
|
144
|
+
...G(e.disabled) ? { disabled: e.disabled } : {}
|
|
145
|
+
}));
|
|
146
|
+
return F.useEffect(() => {
|
|
147
|
+
const A = u._options.shouldUnregister || n, b = (D, H) => {
|
|
148
|
+
const R = c(u._fields, D);
|
|
149
|
+
R && R._f && (R._f.mount = H);
|
|
150
|
+
};
|
|
151
|
+
if (b(r, !0), A) {
|
|
152
|
+
const D = M(c(u._options.defaultValues, r));
|
|
153
|
+
k(u._defaultValues, r, D), E(c(u._formValues, r)) && k(u._formValues, r, D);
|
|
154
|
+
}
|
|
155
|
+
return () => {
|
|
156
|
+
(y ? A && !u._state.action : A) ? u.unregister(r) : b(r, !1);
|
|
157
|
+
};
|
|
158
|
+
}, [r, u, y, n]), F.useEffect(() => {
|
|
159
|
+
c(u._fields, r) && u._updateDisabledField({
|
|
160
|
+
disabled: i,
|
|
161
|
+
fields: u._fields,
|
|
162
|
+
name: r,
|
|
163
|
+
value: c(u._fields, r)._f.value
|
|
164
|
+
});
|
|
165
|
+
}, [i, r, u]), {
|
|
166
|
+
field: {
|
|
167
|
+
name: r,
|
|
168
|
+
value: g,
|
|
169
|
+
...G(i) || m.disabled ? { disabled: m.disabled || i } : {},
|
|
170
|
+
onChange: F.useCallback((A) => O.current.onChange({
|
|
171
|
+
target: {
|
|
172
|
+
value: dr(A),
|
|
173
|
+
name: r
|
|
174
|
+
},
|
|
175
|
+
type: Ae.CHANGE
|
|
176
|
+
}), [r]),
|
|
177
|
+
onBlur: F.useCallback(() => O.current.onBlur({
|
|
178
|
+
target: {
|
|
179
|
+
value: c(u._formValues, r),
|
|
180
|
+
name: r
|
|
181
|
+
},
|
|
182
|
+
type: Ae.BLUR
|
|
183
|
+
}), [r, u]),
|
|
184
|
+
ref: F.useCallback((A) => {
|
|
185
|
+
const b = c(u._fields, r);
|
|
186
|
+
b && A && (b._f.ref = {
|
|
187
|
+
focus: () => A.focus(),
|
|
188
|
+
select: () => A.select(),
|
|
189
|
+
setCustomValidity: (D) => A.setCustomValidity(D),
|
|
190
|
+
reportValidity: () => A.reportValidity()
|
|
191
|
+
});
|
|
192
|
+
}, [u._fields, r])
|
|
193
|
+
},
|
|
194
|
+
formState: m,
|
|
195
|
+
fieldState: Object.defineProperties({}, {
|
|
196
|
+
invalid: {
|
|
197
|
+
enumerable: !0,
|
|
198
|
+
get: () => !!c(m.errors, r)
|
|
199
|
+
},
|
|
200
|
+
isDirty: {
|
|
201
|
+
enumerable: !0,
|
|
202
|
+
get: () => !!c(m.dirtyFields, r)
|
|
203
|
+
},
|
|
204
|
+
isTouched: {
|
|
205
|
+
enumerable: !0,
|
|
206
|
+
get: () => !!c(m.touchedFields, r)
|
|
207
|
+
},
|
|
208
|
+
isValidating: {
|
|
209
|
+
enumerable: !0,
|
|
210
|
+
get: () => !!c(m.validatingFields, r)
|
|
211
|
+
},
|
|
212
|
+
error: {
|
|
213
|
+
enumerable: !0,
|
|
214
|
+
get: () => c(m.errors, r)
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
const tt = (e) => e.render(Ir(e));
|
|
220
|
+
var Nr = (e, s, r, i, u) => s ? {
|
|
221
|
+
...r[e],
|
|
222
|
+
types: {
|
|
223
|
+
...r[e] && r[e].types ? r[e].types : {},
|
|
224
|
+
[i]: u || !0
|
|
225
|
+
}
|
|
226
|
+
} : {}, se = () => {
|
|
227
|
+
const e = typeof performance > "u" ? Date.now() : performance.now() * 1e3;
|
|
228
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (s) => {
|
|
229
|
+
const r = (Math.random() * 16 + e) % 16 | 0;
|
|
230
|
+
return (s == "x" ? r : r & 3 | 8).toString(16);
|
|
231
|
+
});
|
|
232
|
+
}, Oe = (e, s, r = {}) => r.shouldFocus || E(r.shouldFocus) ? r.focusName || `${e}.${E(r.focusIndex) ? s : r.focusIndex}.` : "", _e = (e) => ({
|
|
233
|
+
isOnSubmit: !e || e === Y.onSubmit,
|
|
234
|
+
isOnBlur: e === Y.onBlur,
|
|
235
|
+
isOnChange: e === Y.onChange,
|
|
236
|
+
isOnAll: e === Y.all,
|
|
237
|
+
isOnTouch: e === Y.onTouched
|
|
238
|
+
}), We = (e, s, r) => !r && (s.watchAll || s.watch.has(e) || [...s.watch].some((i) => e.startsWith(i) && /^\.\w+/.test(e.slice(i.length))));
|
|
239
|
+
const le = (e, s, r, i) => {
|
|
240
|
+
for (const u of r || Object.keys(e)) {
|
|
241
|
+
const n = c(e, u);
|
|
242
|
+
if (n) {
|
|
243
|
+
const { _f: y, ...g } = n;
|
|
244
|
+
if (y) {
|
|
245
|
+
if (y.refs && y.refs[0] && s(y.refs[0], u) && !i)
|
|
246
|
+
return !0;
|
|
247
|
+
if (y.ref && s(y.ref, y.name) && !i)
|
|
248
|
+
return !0;
|
|
249
|
+
if (le(g, s))
|
|
250
|
+
break;
|
|
251
|
+
} else if (T(g) && le(g, s))
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
var Ar = (e, s, r) => {
|
|
257
|
+
const i = q(c(e, r));
|
|
258
|
+
return k(i, "root", s[r]), k(e, r, i), e;
|
|
259
|
+
}, Ke = (e) => e.type === "file", te = (e) => typeof e == "function", me = (e) => {
|
|
260
|
+
if (!He)
|
|
261
|
+
return !1;
|
|
262
|
+
const s = e ? e.ownerDocument : 0;
|
|
263
|
+
return e instanceof (s && s.defaultView ? s.defaultView.HTMLElement : HTMLElement);
|
|
264
|
+
}, Fe = (e) => ee(e), Ge = (e) => e.type === "radio", Ve = (e) => e instanceof RegExp;
|
|
265
|
+
const ir = {
|
|
266
|
+
value: !1,
|
|
267
|
+
isValid: !1
|
|
268
|
+
}, ar = { value: !0, isValid: !0 };
|
|
269
|
+
var mr = (e) => {
|
|
270
|
+
if (Array.isArray(e)) {
|
|
271
|
+
if (e.length > 1) {
|
|
272
|
+
const s = e.filter((r) => r && r.checked && !r.disabled).map((r) => r.value);
|
|
273
|
+
return { value: s, isValid: !!s.length };
|
|
274
|
+
}
|
|
275
|
+
return e[0].checked && !e[0].disabled ? (
|
|
276
|
+
// @ts-expect-error expected to work in the browser
|
|
277
|
+
e[0].attributes && !E(e[0].attributes.value) ? E(e[0].value) || e[0].value === "" ? ar : { value: e[0].value, isValid: !0 } : ar
|
|
278
|
+
) : ir;
|
|
279
|
+
}
|
|
280
|
+
return ir;
|
|
281
|
+
};
|
|
282
|
+
const ur = {
|
|
283
|
+
isValid: !1,
|
|
284
|
+
value: null
|
|
285
|
+
};
|
|
286
|
+
var Vr = (e) => Array.isArray(e) ? e.reduce((s, r) => r && r.checked && !r.disabled ? {
|
|
287
|
+
isValid: !0,
|
|
288
|
+
value: r.value
|
|
289
|
+
} : s, ur) : ur;
|
|
290
|
+
function nr(e, s, r = "validate") {
|
|
291
|
+
if (Fe(e) || Array.isArray(e) && e.every(Fe) || G(e) && !e)
|
|
292
|
+
return {
|
|
293
|
+
type: r,
|
|
294
|
+
message: Fe(e) ? e : "",
|
|
295
|
+
ref: s
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
var ue = (e) => T(e) && !Ve(e) ? e : {
|
|
299
|
+
value: e,
|
|
300
|
+
message: ""
|
|
301
|
+
}, qe = async (e, s, r, i, u) => {
|
|
302
|
+
const { ref: n, refs: y, required: g, maxLength: m, minLength: O, min: A, max: b, pattern: D, validate: H, name: R, valueAsNumber: oe, mount: z, disabled: Z } = e._f, p = c(s, R);
|
|
303
|
+
if (!z || Z)
|
|
304
|
+
return {};
|
|
305
|
+
const J = y ? y[0] : n, Q = (x) => {
|
|
306
|
+
i && J.reportValidity && (J.setCustomValidity(G(x) ? "" : x || ""), J.reportValidity());
|
|
307
|
+
}, _ = {}, h = Ge(n), V = ge(n), C = h || V, $ = (oe || Ke(n)) && E(n.value) && E(p) || me(n) && n.value === "" || p === "" || Array.isArray(p) && !p.length, P = Nr.bind(null, R, r, _), he = (x, S, L, N = re.maxLength, X = re.minLength) => {
|
|
308
|
+
const K = x ? S : L;
|
|
309
|
+
_[R] = {
|
|
310
|
+
type: x ? N : X,
|
|
311
|
+
message: K,
|
|
312
|
+
ref: n,
|
|
313
|
+
...P(x ? N : X, K)
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
if (u ? !Array.isArray(p) || !p.length : g && (!C && ($ || W(p)) || G(p) && !p || V && !mr(y).isValid || h && !Vr(y).isValid)) {
|
|
317
|
+
const { value: x, message: S } = Fe(g) ? { value: !!g, message: g } : ue(g);
|
|
318
|
+
if (x && (_[R] = {
|
|
319
|
+
type: re.required,
|
|
320
|
+
message: S,
|
|
321
|
+
ref: J,
|
|
322
|
+
...P(re.required, S)
|
|
323
|
+
}, !r))
|
|
324
|
+
return Q(S), _;
|
|
325
|
+
}
|
|
326
|
+
if (!$ && (!W(A) || !W(b))) {
|
|
327
|
+
let x, S;
|
|
328
|
+
const L = ue(b), N = ue(A);
|
|
329
|
+
if (!W(p) && !isNaN(p)) {
|
|
330
|
+
const X = n.valueAsNumber || p && +p;
|
|
331
|
+
W(L.value) || (x = X > L.value), W(N.value) || (S = X < N.value);
|
|
332
|
+
} else {
|
|
333
|
+
const X = n.valueAsDate || new Date(p), K = (de) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + de), ce = n.type == "time", fe = n.type == "week";
|
|
334
|
+
ee(L.value) && p && (x = ce ? K(p) > K(L.value) : fe ? p > L.value : X > new Date(L.value)), ee(N.value) && p && (S = ce ? K(p) < K(N.value) : fe ? p < N.value : X < new Date(N.value));
|
|
335
|
+
}
|
|
336
|
+
if ((x || S) && (he(!!x, L.message, N.message, re.max, re.min), !r))
|
|
337
|
+
return Q(_[R].message), _;
|
|
338
|
+
}
|
|
339
|
+
if ((m || O) && !$ && (ee(p) || u && Array.isArray(p))) {
|
|
340
|
+
const x = ue(m), S = ue(O), L = !W(x.value) && p.length > +x.value, N = !W(S.value) && p.length < +S.value;
|
|
341
|
+
if ((L || N) && (he(L, x.message, S.message), !r))
|
|
342
|
+
return Q(_[R].message), _;
|
|
343
|
+
}
|
|
344
|
+
if (D && !$ && ee(p)) {
|
|
345
|
+
const { value: x, message: S } = ue(D);
|
|
346
|
+
if (Ve(x) && !p.match(x) && (_[R] = {
|
|
347
|
+
type: re.pattern,
|
|
348
|
+
message: S,
|
|
349
|
+
ref: n,
|
|
350
|
+
...P(re.pattern, S)
|
|
351
|
+
}, !r))
|
|
352
|
+
return Q(S), _;
|
|
353
|
+
}
|
|
354
|
+
if (H) {
|
|
355
|
+
if (te(H)) {
|
|
356
|
+
const x = await H(p, s), S = nr(x, J);
|
|
357
|
+
if (S && (_[R] = {
|
|
358
|
+
...S,
|
|
359
|
+
...P(re.validate, S.message)
|
|
360
|
+
}, !r))
|
|
361
|
+
return Q(S.message), _;
|
|
362
|
+
} else if (T(H)) {
|
|
363
|
+
let x = {};
|
|
364
|
+
for (const S in H) {
|
|
365
|
+
if (!j(x) && !r)
|
|
366
|
+
break;
|
|
367
|
+
const L = nr(await H[S](p, s), J, S);
|
|
368
|
+
L && (x = {
|
|
369
|
+
...L,
|
|
370
|
+
...P(S, L.message)
|
|
371
|
+
}, Q(L.message), r && (_[R] = x));
|
|
372
|
+
}
|
|
373
|
+
if (!j(x) && (_[R] = {
|
|
374
|
+
ref: J,
|
|
375
|
+
...x
|
|
376
|
+
}, !r))
|
|
377
|
+
return _;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return Q(!0), _;
|
|
381
|
+
}, Ue = (e, s) => [
|
|
382
|
+
...e,
|
|
383
|
+
...q(s)
|
|
384
|
+
], Te = (e) => Array.isArray(e) ? e.map(() => {
|
|
385
|
+
}) : void 0;
|
|
386
|
+
function Re(e, s, r) {
|
|
387
|
+
return [
|
|
388
|
+
...e.slice(0, s),
|
|
389
|
+
...q(r),
|
|
390
|
+
...e.slice(s)
|
|
391
|
+
];
|
|
392
|
+
}
|
|
393
|
+
var Le = (e, s, r) => Array.isArray(e) ? (E(e[r]) && (e[r] = void 0), e.splice(r, 0, e.splice(s, 1)[0]), e) : [], Me = (e, s) => [
|
|
394
|
+
...q(s),
|
|
395
|
+
...q(e)
|
|
396
|
+
];
|
|
397
|
+
function Pr(e, s) {
|
|
398
|
+
let r = 0;
|
|
399
|
+
const i = [...e];
|
|
400
|
+
for (const u of s)
|
|
401
|
+
i.splice(u - r, 1), r++;
|
|
402
|
+
return ve(i).length ? i : [];
|
|
403
|
+
}
|
|
404
|
+
var Be = (e, s) => E(s) ? [] : Pr(e, q(s).sort((r, i) => r - i)), Ie = (e, s, r) => {
|
|
405
|
+
[e[s], e[r]] = [e[r], e[s]];
|
|
406
|
+
};
|
|
407
|
+
function jr(e, s) {
|
|
408
|
+
const r = s.slice(0, -1).length;
|
|
409
|
+
let i = 0;
|
|
410
|
+
for (; i < r; )
|
|
411
|
+
e = E(e) ? i++ : e[s[i++]];
|
|
412
|
+
return e;
|
|
413
|
+
}
|
|
414
|
+
function Wr(e) {
|
|
415
|
+
for (const s in e)
|
|
416
|
+
if (e.hasOwnProperty(s) && !E(e[s]))
|
|
417
|
+
return !1;
|
|
418
|
+
return !0;
|
|
419
|
+
}
|
|
420
|
+
function U(e, s) {
|
|
421
|
+
const r = Array.isArray(s) ? s : $e(s) ? [s] : _r(s), i = r.length === 1 ? e : jr(e, r), u = r.length - 1, n = r[u];
|
|
422
|
+
return i && delete i[n], u !== 0 && (T(i) && j(i) || Array.isArray(i) && Wr(i)) && U(e, r.slice(0, -1)), e;
|
|
423
|
+
}
|
|
424
|
+
var lr = (e, s, r) => (e[s] = r, e);
|
|
425
|
+
function st(e) {
|
|
426
|
+
const s = Se(), { control: r = s.control, name: i, keyName: u = "id", shouldUnregister: n } = e, [y, g] = F.useState(r._getFieldArray(i)), m = F.useRef(r._getFieldArray(i).map(se)), O = F.useRef(y), A = F.useRef(i), b = F.useRef(!1);
|
|
427
|
+
A.current = i, O.current = y, r._names.array.add(i), e.rules && r.register(i, e.rules), we({
|
|
428
|
+
next: ({ values: _, name: h }) => {
|
|
429
|
+
if (h === A.current || !h) {
|
|
430
|
+
const V = c(_, A.current);
|
|
431
|
+
Array.isArray(V) && (g(V), m.current = V.map(se));
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
subject: r._subjects.array
|
|
435
|
+
});
|
|
436
|
+
const D = F.useCallback((_) => {
|
|
437
|
+
b.current = !0, r._updateFieldArray(i, _);
|
|
438
|
+
}, [r, i]), H = (_, h) => {
|
|
439
|
+
const V = q(M(_)), C = Ue(r._getFieldArray(i), V);
|
|
440
|
+
r._names.focus = Oe(i, C.length - 1, h), m.current = Ue(m.current, V.map(se)), D(C), g(C), r._updateFieldArray(i, C, Ue, {
|
|
441
|
+
argA: Te(_)
|
|
442
|
+
});
|
|
443
|
+
}, R = (_, h) => {
|
|
444
|
+
const V = q(M(_)), C = Me(r._getFieldArray(i), V);
|
|
445
|
+
r._names.focus = Oe(i, 0, h), m.current = Me(m.current, V.map(se)), D(C), g(C), r._updateFieldArray(i, C, Me, {
|
|
446
|
+
argA: Te(_)
|
|
447
|
+
});
|
|
448
|
+
}, oe = (_) => {
|
|
449
|
+
const h = Be(r._getFieldArray(i), _);
|
|
450
|
+
m.current = Be(m.current, _), D(h), g(h), r._updateFieldArray(i, h, Be, {
|
|
451
|
+
argA: _
|
|
452
|
+
});
|
|
453
|
+
}, z = (_, h, V) => {
|
|
454
|
+
const C = q(M(h)), $ = Re(r._getFieldArray(i), _, C);
|
|
455
|
+
r._names.focus = Oe(i, _, V), m.current = Re(m.current, _, C.map(se)), D($), g($), r._updateFieldArray(i, $, Re, {
|
|
456
|
+
argA: _,
|
|
457
|
+
argB: Te(h)
|
|
458
|
+
});
|
|
459
|
+
}, Z = (_, h) => {
|
|
460
|
+
const V = r._getFieldArray(i);
|
|
461
|
+
Ie(V, _, h), Ie(m.current, _, h), D(V), g(V), r._updateFieldArray(i, V, Ie, {
|
|
462
|
+
argA: _,
|
|
463
|
+
argB: h
|
|
464
|
+
}, !1);
|
|
465
|
+
}, p = (_, h) => {
|
|
466
|
+
const V = r._getFieldArray(i);
|
|
467
|
+
Le(V, _, h), Le(m.current, _, h), D(V), g(V), r._updateFieldArray(i, V, Le, {
|
|
468
|
+
argA: _,
|
|
469
|
+
argB: h
|
|
470
|
+
}, !1);
|
|
471
|
+
}, J = (_, h) => {
|
|
472
|
+
const V = M(h), C = lr(r._getFieldArray(i), _, V);
|
|
473
|
+
m.current = [...C].map(($, P) => !$ || P === _ ? se() : m.current[P]), D(C), g([...C]), r._updateFieldArray(i, C, lr, {
|
|
474
|
+
argA: _,
|
|
475
|
+
argB: V
|
|
476
|
+
}, !0, !1);
|
|
477
|
+
}, Q = (_) => {
|
|
478
|
+
const h = q(M(_));
|
|
479
|
+
m.current = h.map(se), D([...h]), g([...h]), r._updateFieldArray(i, [...h], (V) => V, {}, !0, !1);
|
|
480
|
+
};
|
|
481
|
+
return F.useEffect(() => {
|
|
482
|
+
if (r._state.action = !1, We(i, r._names) && r._subjects.state.next({
|
|
483
|
+
...r._formState
|
|
484
|
+
}), b.current && (!_e(r._options.mode).isOnSubmit || r._formState.isSubmitted))
|
|
485
|
+
if (r._options.resolver)
|
|
486
|
+
r._executeSchema([i]).then((_) => {
|
|
487
|
+
const h = c(_.errors, i), V = c(r._formState.errors, i);
|
|
488
|
+
(V ? !h && V.type || h && (V.type !== h.type || V.message !== h.message) : h && h.type) && (h ? k(r._formState.errors, i, h) : U(r._formState.errors, i), r._subjects.state.next({
|
|
489
|
+
errors: r._formState.errors
|
|
490
|
+
}));
|
|
491
|
+
});
|
|
492
|
+
else {
|
|
493
|
+
const _ = c(r._fields, i);
|
|
494
|
+
_ && _._f && !(_e(r._options.reValidateMode).isOnSubmit && _e(r._options.mode).isOnSubmit) && qe(_, r._formValues, r._options.criteriaMode === Y.all, r._options.shouldUseNativeValidation, !0).then((h) => !j(h) && r._subjects.state.next({
|
|
495
|
+
errors: Ar(r._formState.errors, h, i)
|
|
496
|
+
}));
|
|
497
|
+
}
|
|
498
|
+
r._subjects.values.next({
|
|
499
|
+
name: i,
|
|
500
|
+
values: { ...r._formValues }
|
|
501
|
+
}), r._names.focus && le(r._fields, (_, h) => {
|
|
502
|
+
if (r._names.focus && h.startsWith(r._names.focus) && _.focus)
|
|
503
|
+
return _.focus(), 1;
|
|
504
|
+
}), r._names.focus = "", r._updateValid(), b.current = !1;
|
|
505
|
+
}, [y, i, r]), F.useEffect(() => (!c(r._formValues, i) && r._updateFieldArray(i), () => {
|
|
506
|
+
(r._options.shouldUnregister || n) && r.unregister(i);
|
|
507
|
+
}), [i, r, u, n]), {
|
|
508
|
+
swap: F.useCallback(Z, [D, i, r]),
|
|
509
|
+
move: F.useCallback(p, [D, i, r]),
|
|
510
|
+
prepend: F.useCallback(R, [D, i, r]),
|
|
511
|
+
append: F.useCallback(H, [D, i, r]),
|
|
512
|
+
remove: F.useCallback(oe, [D, i, r]),
|
|
513
|
+
insert: F.useCallback(z, [D, i, r]),
|
|
514
|
+
update: F.useCallback(J, [D, i, r]),
|
|
515
|
+
replace: F.useCallback(Q, [D, i, r]),
|
|
516
|
+
fields: F.useMemo(() => y.map((_, h) => ({
|
|
517
|
+
..._,
|
|
518
|
+
[u]: m.current[h] || se()
|
|
519
|
+
})), [y, u])
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
var Ne = () => {
|
|
523
|
+
let e = [];
|
|
524
|
+
return {
|
|
525
|
+
get observers() {
|
|
526
|
+
return e;
|
|
527
|
+
},
|
|
528
|
+
next: (u) => {
|
|
529
|
+
for (const n of e)
|
|
530
|
+
n.next && n.next(u);
|
|
531
|
+
},
|
|
532
|
+
subscribe: (u) => (e.push(u), {
|
|
533
|
+
unsubscribe: () => {
|
|
534
|
+
e = e.filter((n) => n !== u);
|
|
535
|
+
}
|
|
536
|
+
}),
|
|
537
|
+
unsubscribe: () => {
|
|
538
|
+
e = [];
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
}, xe = (e) => W(e) || !fr(e);
|
|
542
|
+
function ie(e, s) {
|
|
543
|
+
if (xe(e) || xe(s))
|
|
544
|
+
return e === s;
|
|
545
|
+
if (ne(e) && ne(s))
|
|
546
|
+
return e.getTime() === s.getTime();
|
|
547
|
+
const r = Object.keys(e), i = Object.keys(s);
|
|
548
|
+
if (r.length !== i.length)
|
|
549
|
+
return !1;
|
|
550
|
+
for (const u of r) {
|
|
551
|
+
const n = e[u];
|
|
552
|
+
if (!i.includes(u))
|
|
553
|
+
return !1;
|
|
554
|
+
if (u !== "ref") {
|
|
555
|
+
const y = s[u];
|
|
556
|
+
if (ne(n) && ne(y) || T(n) && T(y) || Array.isArray(n) && Array.isArray(y) ? !ie(n, y) : n !== y)
|
|
557
|
+
return !1;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
return !0;
|
|
561
|
+
}
|
|
562
|
+
var xr = (e) => e.type === "select-multiple", qr = (e) => Ge(e) || ge(e), Pe = (e) => me(e) && e.isConnected, pr = (e) => {
|
|
563
|
+
for (const s in e)
|
|
564
|
+
if (te(e[s]))
|
|
565
|
+
return !0;
|
|
566
|
+
return !1;
|
|
567
|
+
};
|
|
568
|
+
function pe(e, s = {}) {
|
|
569
|
+
const r = Array.isArray(e);
|
|
570
|
+
if (T(e) || r)
|
|
571
|
+
for (const i in e)
|
|
572
|
+
Array.isArray(e[i]) || T(e[i]) && !pr(e[i]) ? (s[i] = Array.isArray(e[i]) ? [] : {}, pe(e[i], s[i])) : W(e[i]) || (s[i] = !0);
|
|
573
|
+
return s;
|
|
574
|
+
}
|
|
575
|
+
function Sr(e, s, r) {
|
|
576
|
+
const i = Array.isArray(e);
|
|
577
|
+
if (T(e) || i)
|
|
578
|
+
for (const u in e)
|
|
579
|
+
Array.isArray(e[u]) || T(e[u]) && !pr(e[u]) ? E(s) || xe(r[u]) ? r[u] = Array.isArray(e[u]) ? pe(e[u], []) : { ...pe(e[u]) } : Sr(e[u], W(s) ? {} : s[u], r[u]) : r[u] = !ie(e[u], s[u]);
|
|
580
|
+
return r;
|
|
581
|
+
}
|
|
582
|
+
var be = (e, s) => Sr(e, s, pe(s)), wr = (e, { valueAsNumber: s, valueAsDate: r, setValueAs: i }) => E(e) ? e : s ? e === "" ? NaN : e && +e : r && ee(e) ? new Date(e) : i ? i(e) : e;
|
|
583
|
+
function je(e) {
|
|
584
|
+
const s = e.ref;
|
|
585
|
+
if (!(e.refs ? e.refs.every((r) => r.disabled) : s.disabled))
|
|
586
|
+
return Ke(s) ? s.files : Ge(s) ? Vr(e.refs).value : xr(s) ? [...s.selectedOptions].map(({ value: r }) => r) : ge(s) ? mr(e.refs).value : wr(E(s.value) ? e.ref.value : s.value, e);
|
|
587
|
+
}
|
|
588
|
+
var Hr = (e, s, r, i) => {
|
|
589
|
+
const u = {};
|
|
590
|
+
for (const n of e) {
|
|
591
|
+
const y = c(s, n);
|
|
592
|
+
y && k(u, n, y._f);
|
|
593
|
+
}
|
|
594
|
+
return {
|
|
595
|
+
criteriaMode: r,
|
|
596
|
+
names: [...e],
|
|
597
|
+
fields: u,
|
|
598
|
+
shouldUseNativeValidation: i
|
|
599
|
+
};
|
|
600
|
+
}, ye = (e) => E(e) ? e : Ve(e) ? e.source : T(e) ? Ve(e.value) ? e.value.source : e.value : e;
|
|
601
|
+
const or = "AsyncFunction";
|
|
602
|
+
var $r = (e) => (!e || !e.validate) && !!(te(e.validate) && e.validate.constructor.name === or || T(e.validate) && Object.values(e.validate).find((s) => s.constructor.name === or)), Kr = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate);
|
|
603
|
+
function cr(e, s, r) {
|
|
604
|
+
const i = c(e, r);
|
|
605
|
+
if (i || $e(r))
|
|
606
|
+
return {
|
|
607
|
+
error: i,
|
|
608
|
+
name: r
|
|
609
|
+
};
|
|
610
|
+
const u = r.split(".");
|
|
611
|
+
for (; u.length; ) {
|
|
612
|
+
const n = u.join("."), y = c(s, n), g = c(e, n);
|
|
613
|
+
if (y && !Array.isArray(y) && r !== n)
|
|
614
|
+
return { name: r };
|
|
615
|
+
if (g && g.type)
|
|
616
|
+
return {
|
|
617
|
+
name: n,
|
|
618
|
+
error: g
|
|
619
|
+
};
|
|
620
|
+
u.pop();
|
|
621
|
+
}
|
|
622
|
+
return {
|
|
623
|
+
name: r
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
var Gr = (e, s, r, i, u) => u.isOnAll ? !1 : !r && u.isOnTouch ? !(s || e) : (r ? i.isOnBlur : u.isOnBlur) ? !e : (r ? i.isOnChange : u.isOnChange) ? e : !0, Yr = (e, s) => !ve(c(e, s)).length && U(e, s);
|
|
627
|
+
const zr = {
|
|
628
|
+
mode: Y.onSubmit,
|
|
629
|
+
reValidateMode: Y.onChange,
|
|
630
|
+
shouldFocusError: !0
|
|
631
|
+
};
|
|
632
|
+
function Jr(e = {}) {
|
|
633
|
+
let s = {
|
|
634
|
+
...zr,
|
|
635
|
+
...e
|
|
636
|
+
}, r = {
|
|
637
|
+
submitCount: 0,
|
|
638
|
+
isDirty: !1,
|
|
639
|
+
isLoading: te(s.defaultValues),
|
|
640
|
+
isValidating: !1,
|
|
641
|
+
isSubmitted: !1,
|
|
642
|
+
isSubmitting: !1,
|
|
643
|
+
isSubmitSuccessful: !1,
|
|
644
|
+
isValid: !1,
|
|
645
|
+
touchedFields: {},
|
|
646
|
+
dirtyFields: {},
|
|
647
|
+
validatingFields: {},
|
|
648
|
+
errors: s.errors || {},
|
|
649
|
+
disabled: s.disabled || !1
|
|
650
|
+
}, i = {}, u = T(s.defaultValues) || T(s.values) ? M(s.defaultValues || s.values) || {} : {}, n = s.shouldUnregister ? {} : M(u), y = {
|
|
651
|
+
action: !1,
|
|
652
|
+
mount: !1,
|
|
653
|
+
watch: !1
|
|
654
|
+
}, g = {
|
|
655
|
+
mount: /* @__PURE__ */ new Set(),
|
|
656
|
+
unMount: /* @__PURE__ */ new Set(),
|
|
657
|
+
array: /* @__PURE__ */ new Set(),
|
|
658
|
+
watch: /* @__PURE__ */ new Set()
|
|
659
|
+
}, m, O = 0;
|
|
660
|
+
const A = {
|
|
661
|
+
isDirty: !1,
|
|
662
|
+
dirtyFields: !1,
|
|
663
|
+
validatingFields: !1,
|
|
664
|
+
touchedFields: !1,
|
|
665
|
+
isValidating: !1,
|
|
666
|
+
isValid: !1,
|
|
667
|
+
errors: !1
|
|
668
|
+
}, b = {
|
|
669
|
+
values: Ne(),
|
|
670
|
+
array: Ne(),
|
|
671
|
+
state: Ne()
|
|
672
|
+
}, D = _e(s.mode), H = _e(s.reValidateMode), R = s.criteriaMode === Y.all, oe = (t) => (a) => {
|
|
673
|
+
clearTimeout(O), O = setTimeout(t, a);
|
|
674
|
+
}, z = async (t) => {
|
|
675
|
+
if (A.isValid || t) {
|
|
676
|
+
const a = s.resolver ? j((await C()).errors) : await P(i, !0);
|
|
677
|
+
a !== r.isValid && b.state.next({
|
|
678
|
+
isValid: a
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
}, Z = (t, a) => {
|
|
682
|
+
(A.isValidating || A.validatingFields) && ((t || Array.from(g.mount)).forEach((l) => {
|
|
683
|
+
l && (a ? k(r.validatingFields, l, a) : U(r.validatingFields, l));
|
|
684
|
+
}), b.state.next({
|
|
685
|
+
validatingFields: r.validatingFields,
|
|
686
|
+
isValidating: !j(r.validatingFields)
|
|
687
|
+
}));
|
|
688
|
+
}, p = (t, a = [], l, d, f = !0, o = !0) => {
|
|
689
|
+
if (d && l) {
|
|
690
|
+
if (y.action = !0, o && Array.isArray(c(i, t))) {
|
|
691
|
+
const v = l(c(i, t), d.argA, d.argB);
|
|
692
|
+
f && k(i, t, v);
|
|
693
|
+
}
|
|
694
|
+
if (o && Array.isArray(c(r.errors, t))) {
|
|
695
|
+
const v = l(c(r.errors, t), d.argA, d.argB);
|
|
696
|
+
f && k(r.errors, t, v), Yr(r.errors, t);
|
|
697
|
+
}
|
|
698
|
+
if (A.touchedFields && o && Array.isArray(c(r.touchedFields, t))) {
|
|
699
|
+
const v = l(c(r.touchedFields, t), d.argA, d.argB);
|
|
700
|
+
f && k(r.touchedFields, t, v);
|
|
701
|
+
}
|
|
702
|
+
A.dirtyFields && (r.dirtyFields = be(u, n)), b.state.next({
|
|
703
|
+
name: t,
|
|
704
|
+
isDirty: x(t, a),
|
|
705
|
+
dirtyFields: r.dirtyFields,
|
|
706
|
+
errors: r.errors,
|
|
707
|
+
isValid: r.isValid
|
|
708
|
+
});
|
|
709
|
+
} else
|
|
710
|
+
k(n, t, a);
|
|
711
|
+
}, J = (t, a) => {
|
|
712
|
+
k(r.errors, t, a), b.state.next({
|
|
713
|
+
errors: r.errors
|
|
714
|
+
});
|
|
715
|
+
}, Q = (t) => {
|
|
716
|
+
r.errors = t, b.state.next({
|
|
717
|
+
errors: r.errors,
|
|
718
|
+
isValid: !1
|
|
719
|
+
});
|
|
720
|
+
}, _ = (t, a, l, d) => {
|
|
721
|
+
const f = c(i, t);
|
|
722
|
+
if (f) {
|
|
723
|
+
const o = c(n, t, E(l) ? c(u, t) : l);
|
|
724
|
+
E(o) || d && d.defaultChecked || a ? k(n, t, a ? o : je(f._f)) : N(t, o), y.mount && z();
|
|
725
|
+
}
|
|
726
|
+
}, h = (t, a, l, d, f) => {
|
|
727
|
+
let o = !1, v = !1;
|
|
728
|
+
const w = {
|
|
729
|
+
name: t
|
|
730
|
+
}, B = !!(c(i, t) && c(i, t)._f && c(i, t)._f.disabled);
|
|
731
|
+
if (!l || d) {
|
|
732
|
+
A.isDirty && (v = r.isDirty, r.isDirty = w.isDirty = x(), o = v !== w.isDirty);
|
|
733
|
+
const I = B || ie(c(u, t), a);
|
|
734
|
+
v = !!(!B && c(r.dirtyFields, t)), I || B ? U(r.dirtyFields, t) : k(r.dirtyFields, t, !0), w.dirtyFields = r.dirtyFields, o = o || A.dirtyFields && v !== !I;
|
|
735
|
+
}
|
|
736
|
+
if (l) {
|
|
737
|
+
const I = c(r.touchedFields, t);
|
|
738
|
+
I || (k(r.touchedFields, t, l), w.touchedFields = r.touchedFields, o = o || A.touchedFields && I !== l);
|
|
739
|
+
}
|
|
740
|
+
return o && f && b.state.next(w), o ? w : {};
|
|
741
|
+
}, V = (t, a, l, d) => {
|
|
742
|
+
const f = c(r.errors, t), o = A.isValid && G(a) && r.isValid !== a;
|
|
743
|
+
if (e.delayError && l ? (m = oe(() => J(t, l)), m(e.delayError)) : (clearTimeout(O), m = null, l ? k(r.errors, t, l) : U(r.errors, t)), (l ? !ie(f, l) : f) || !j(d) || o) {
|
|
744
|
+
const v = {
|
|
745
|
+
...d,
|
|
746
|
+
...o && G(a) ? { isValid: a } : {},
|
|
747
|
+
errors: r.errors,
|
|
748
|
+
name: t
|
|
749
|
+
};
|
|
750
|
+
r = {
|
|
751
|
+
...r,
|
|
752
|
+
...v
|
|
753
|
+
}, b.state.next(v);
|
|
754
|
+
}
|
|
755
|
+
}, C = async (t) => {
|
|
756
|
+
Z(t, !0);
|
|
757
|
+
const a = await s.resolver(n, s.context, Hr(t || g.mount, i, s.criteriaMode, s.shouldUseNativeValidation));
|
|
758
|
+
return Z(t), a;
|
|
759
|
+
}, $ = async (t) => {
|
|
760
|
+
const { errors: a } = await C(t);
|
|
761
|
+
if (t)
|
|
762
|
+
for (const l of t) {
|
|
763
|
+
const d = c(a, l);
|
|
764
|
+
d ? k(r.errors, l, d) : U(r.errors, l);
|
|
765
|
+
}
|
|
766
|
+
else
|
|
767
|
+
r.errors = a;
|
|
768
|
+
return a;
|
|
769
|
+
}, P = async (t, a, l = {
|
|
770
|
+
valid: !0
|
|
771
|
+
}) => {
|
|
772
|
+
for (const d in t) {
|
|
773
|
+
const f = t[d];
|
|
774
|
+
if (f) {
|
|
775
|
+
const { _f: o, ...v } = f;
|
|
776
|
+
if (o) {
|
|
777
|
+
const w = g.array.has(o.name), B = f._f && $r(f._f);
|
|
778
|
+
B && A.validatingFields && Z([d], !0);
|
|
779
|
+
const I = await qe(f, n, R, s.shouldUseNativeValidation && !a, w);
|
|
780
|
+
if (B && A.validatingFields && Z([d]), I[o.name] && (l.valid = !1, a))
|
|
781
|
+
break;
|
|
782
|
+
!a && (c(I, o.name) ? w ? Ar(r.errors, I, o.name) : k(r.errors, o.name, I[o.name]) : U(r.errors, o.name));
|
|
783
|
+
}
|
|
784
|
+
!j(v) && await P(v, a, l);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
return l.valid;
|
|
788
|
+
}, he = () => {
|
|
789
|
+
for (const t of g.unMount) {
|
|
790
|
+
const a = c(i, t);
|
|
791
|
+
a && (a._f.refs ? a._f.refs.every((l) => !Pe(l)) : !Pe(a._f.ref)) && De(t);
|
|
792
|
+
}
|
|
793
|
+
g.unMount = /* @__PURE__ */ new Set();
|
|
794
|
+
}, x = (t, a) => (t && a && k(n, t, a), !ie(Ye(), u)), S = (t, a, l) => Fr(t, g, {
|
|
795
|
+
...y.mount ? n : E(a) ? u : ee(t) ? { [t]: a } : a
|
|
796
|
+
}, l, a), L = (t) => ve(c(y.mount ? n : u, t, e.shouldUnregister ? c(u, t, []) : [])), N = (t, a, l = {}) => {
|
|
797
|
+
const d = c(i, t);
|
|
798
|
+
let f = a;
|
|
799
|
+
if (d) {
|
|
800
|
+
const o = d._f;
|
|
801
|
+
o && (!o.disabled && k(n, t, wr(a, o)), f = me(o.ref) && W(a) ? "" : a, xr(o.ref) ? [...o.ref.options].forEach((v) => v.selected = f.includes(v.value)) : o.refs ? ge(o.ref) ? o.refs.length > 1 ? o.refs.forEach((v) => (!v.defaultChecked || !v.disabled) && (v.checked = Array.isArray(f) ? !!f.find((w) => w === v.value) : f === v.value)) : o.refs[0] && (o.refs[0].checked = !!f) : o.refs.forEach((v) => v.checked = v.value === f) : Ke(o.ref) ? o.ref.value = "" : (o.ref.value = f, o.ref.type || b.values.next({
|
|
802
|
+
name: t,
|
|
803
|
+
values: { ...n }
|
|
804
|
+
})));
|
|
805
|
+
}
|
|
806
|
+
(l.shouldDirty || l.shouldTouch) && h(t, f, l.shouldTouch, l.shouldDirty, !0), l.shouldValidate && de(t);
|
|
807
|
+
}, X = (t, a, l) => {
|
|
808
|
+
for (const d in a) {
|
|
809
|
+
const f = a[d], o = `${t}.${d}`, v = c(i, o);
|
|
810
|
+
(g.array.has(t) || !xe(f) || v && !v._f) && !ne(f) ? X(o, f, l) : N(o, f, l);
|
|
811
|
+
}
|
|
812
|
+
}, K = (t, a, l = {}) => {
|
|
813
|
+
const d = c(i, t), f = g.array.has(t), o = M(a);
|
|
814
|
+
k(n, t, o), f ? (b.array.next({
|
|
815
|
+
name: t,
|
|
816
|
+
values: { ...n }
|
|
817
|
+
}), (A.isDirty || A.dirtyFields) && l.shouldDirty && b.state.next({
|
|
818
|
+
name: t,
|
|
819
|
+
dirtyFields: be(u, n),
|
|
820
|
+
isDirty: x(t, o)
|
|
821
|
+
})) : d && !d._f && !W(o) ? X(t, o, l) : N(t, o, l), We(t, g) && b.state.next({ ...r }), b.values.next({
|
|
822
|
+
name: y.mount ? t : void 0,
|
|
823
|
+
values: { ...n }
|
|
824
|
+
});
|
|
825
|
+
}, ce = async (t) => {
|
|
826
|
+
y.mount = !0;
|
|
827
|
+
const a = t.target;
|
|
828
|
+
let l = a.name, d = !0;
|
|
829
|
+
const f = c(i, l), o = () => a.type ? je(f._f) : dr(t), v = (w) => {
|
|
830
|
+
d = Number.isNaN(w) || ie(w, c(n, l, w));
|
|
831
|
+
};
|
|
832
|
+
if (f) {
|
|
833
|
+
let w, B;
|
|
834
|
+
const I = o(), ae = t.type === Ae.BLUR || t.type === Ae.FOCUS_OUT, Or = !Kr(f._f) && !s.resolver && !c(r.errors, l) && !f._f.deps || Gr(ae, c(r.touchedFields, l), r.isSubmitted, H, D), Ee = We(l, g, ae);
|
|
835
|
+
k(n, l, I), ae ? (f._f.onBlur && f._f.onBlur(t), m && m(0)) : f._f.onChange && f._f.onChange(t);
|
|
836
|
+
const Ce = h(l, I, ae, !1), Ur = !j(Ce) || Ee;
|
|
837
|
+
if (!ae && b.values.next({
|
|
838
|
+
name: l,
|
|
839
|
+
type: t.type,
|
|
840
|
+
values: { ...n }
|
|
841
|
+
}), Or)
|
|
842
|
+
return A.isValid && (e.mode === "onBlur" ? ae && z() : z()), Ur && b.state.next({ name: l, ...Ee ? {} : Ce });
|
|
843
|
+
if (!ae && Ee && b.state.next({ ...r }), s.resolver) {
|
|
844
|
+
const { errors: tr } = await C([l]);
|
|
845
|
+
if (v(I), d) {
|
|
846
|
+
const Tr = cr(r.errors, i, l), sr = cr(tr, i, Tr.name || l);
|
|
847
|
+
w = sr.error, l = sr.name, B = j(tr);
|
|
848
|
+
}
|
|
849
|
+
} else
|
|
850
|
+
Z([l], !0), w = (await qe(f, n, R, s.shouldUseNativeValidation))[l], Z([l]), v(I), d && (w ? B = !1 : A.isValid && (B = await P(i, !0)));
|
|
851
|
+
d && (f._f.deps && de(f._f.deps), V(l, B, w, Ce));
|
|
852
|
+
}
|
|
853
|
+
}, fe = (t, a) => {
|
|
854
|
+
if (c(r.errors, a) && t.focus)
|
|
855
|
+
return t.focus(), 1;
|
|
856
|
+
}, de = async (t, a = {}) => {
|
|
857
|
+
let l, d;
|
|
858
|
+
const f = q(t);
|
|
859
|
+
if (s.resolver) {
|
|
860
|
+
const o = await $(E(t) ? t : f);
|
|
861
|
+
l = j(o), d = t ? !f.some((v) => c(o, v)) : l;
|
|
862
|
+
} else t ? (d = (await Promise.all(f.map(async (o) => {
|
|
863
|
+
const v = c(i, o);
|
|
864
|
+
return await P(v && v._f ? { [o]: v } : v);
|
|
865
|
+
}))).every(Boolean), !(!d && !r.isValid) && z()) : d = l = await P(i);
|
|
866
|
+
return b.state.next({
|
|
867
|
+
...!ee(t) || A.isValid && l !== r.isValid ? {} : { name: t },
|
|
868
|
+
...s.resolver || !t ? { isValid: l } : {},
|
|
869
|
+
errors: r.errors
|
|
870
|
+
}), a.shouldFocus && !d && le(i, fe, t ? f : g.mount), d;
|
|
871
|
+
}, Ye = (t) => {
|
|
872
|
+
const a = {
|
|
873
|
+
...y.mount ? n : u
|
|
874
|
+
};
|
|
875
|
+
return E(t) ? a : ee(t) ? c(a, t) : t.map((l) => c(a, l));
|
|
876
|
+
}, ze = (t, a) => ({
|
|
877
|
+
invalid: !!c((a || r).errors, t),
|
|
878
|
+
isDirty: !!c((a || r).dirtyFields, t),
|
|
879
|
+
error: c((a || r).errors, t),
|
|
880
|
+
isValidating: !!c(r.validatingFields, t),
|
|
881
|
+
isTouched: !!c((a || r).touchedFields, t)
|
|
882
|
+
}), Dr = (t) => {
|
|
883
|
+
t && q(t).forEach((a) => U(r.errors, a)), b.state.next({
|
|
884
|
+
errors: t ? r.errors : {}
|
|
885
|
+
});
|
|
886
|
+
}, Je = (t, a, l) => {
|
|
887
|
+
const d = (c(i, t, { _f: {} })._f || {}).ref, f = c(r.errors, t) || {}, { ref: o, message: v, type: w, ...B } = f;
|
|
888
|
+
k(r.errors, t, {
|
|
889
|
+
...B,
|
|
890
|
+
...a,
|
|
891
|
+
ref: d
|
|
892
|
+
}), b.state.next({
|
|
893
|
+
name: t,
|
|
894
|
+
errors: r.errors,
|
|
895
|
+
isValid: !1
|
|
896
|
+
}), l && l.shouldFocus && d && d.focus && d.focus();
|
|
897
|
+
}, kr = (t, a) => te(t) ? b.values.subscribe({
|
|
898
|
+
next: (l) => t(S(void 0, a), l)
|
|
899
|
+
}) : S(t, a, !0), De = (t, a = {}) => {
|
|
900
|
+
for (const l of t ? q(t) : g.mount)
|
|
901
|
+
g.mount.delete(l), g.array.delete(l), a.keepValue || (U(i, l), U(n, l)), !a.keepError && U(r.errors, l), !a.keepDirty && U(r.dirtyFields, l), !a.keepTouched && U(r.touchedFields, l), !a.keepIsValidating && U(r.validatingFields, l), !s.shouldUnregister && !a.keepDefaultValue && U(u, l);
|
|
902
|
+
b.values.next({
|
|
903
|
+
values: { ...n }
|
|
904
|
+
}), b.state.next({
|
|
905
|
+
...r,
|
|
906
|
+
...a.keepDirty ? { isDirty: x() } : {}
|
|
907
|
+
}), !a.keepIsValid && z();
|
|
908
|
+
}, Qe = ({ disabled: t, name: a, field: l, fields: d, value: f }) => {
|
|
909
|
+
if (G(t) && y.mount || t) {
|
|
910
|
+
const o = t ? void 0 : E(f) ? je(l ? l._f : c(d, a)._f) : f;
|
|
911
|
+
k(n, a, o), h(a, o, !1, !1, !0);
|
|
912
|
+
}
|
|
913
|
+
}, ke = (t, a = {}) => {
|
|
914
|
+
let l = c(i, t);
|
|
915
|
+
const d = G(a.disabled) || G(e.disabled);
|
|
916
|
+
return k(i, t, {
|
|
917
|
+
...l || {},
|
|
918
|
+
_f: {
|
|
919
|
+
...l && l._f ? l._f : { ref: { name: t } },
|
|
920
|
+
name: t,
|
|
921
|
+
mount: !0,
|
|
922
|
+
...a
|
|
923
|
+
}
|
|
924
|
+
}), g.mount.add(t), l ? Qe({
|
|
925
|
+
field: l,
|
|
926
|
+
disabled: G(a.disabled) ? a.disabled : e.disabled,
|
|
927
|
+
name: t,
|
|
928
|
+
value: a.value
|
|
929
|
+
}) : _(t, !0, a.value), {
|
|
930
|
+
...d ? { disabled: a.disabled || e.disabled } : {},
|
|
931
|
+
...s.progressive ? {
|
|
932
|
+
required: !!a.required,
|
|
933
|
+
min: ye(a.min),
|
|
934
|
+
max: ye(a.max),
|
|
935
|
+
minLength: ye(a.minLength),
|
|
936
|
+
maxLength: ye(a.maxLength),
|
|
937
|
+
pattern: ye(a.pattern)
|
|
938
|
+
} : {},
|
|
939
|
+
name: t,
|
|
940
|
+
onChange: ce,
|
|
941
|
+
onBlur: ce,
|
|
942
|
+
ref: (f) => {
|
|
943
|
+
if (f) {
|
|
944
|
+
ke(t, a), l = c(i, t);
|
|
945
|
+
const o = E(f.value) && f.querySelectorAll && f.querySelectorAll("input,select,textarea")[0] || f, v = qr(o), w = l._f.refs || [];
|
|
946
|
+
if (v ? w.find((B) => B === o) : o === l._f.ref)
|
|
947
|
+
return;
|
|
948
|
+
k(i, t, {
|
|
949
|
+
_f: {
|
|
950
|
+
...l._f,
|
|
951
|
+
...v ? {
|
|
952
|
+
refs: [
|
|
953
|
+
...w.filter(Pe),
|
|
954
|
+
o,
|
|
955
|
+
...Array.isArray(c(u, t)) ? [{}] : []
|
|
956
|
+
],
|
|
957
|
+
ref: { type: o.type, name: t }
|
|
958
|
+
} : { ref: o }
|
|
959
|
+
}
|
|
960
|
+
}), _(t, !1, void 0, o);
|
|
961
|
+
} else
|
|
962
|
+
l = c(i, t, {}), l._f && (l._f.mount = !1), (s.shouldUnregister || a.shouldUnregister) && !(yr(g.array, t) && y.action) && g.unMount.add(t);
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
}, Xe = () => s.shouldFocusError && le(i, fe, g.mount), Er = (t) => {
|
|
966
|
+
G(t) && (b.state.next({ disabled: t }), le(i, (a, l) => {
|
|
967
|
+
const d = c(i, l);
|
|
968
|
+
d && (a.disabled = d._f.disabled || t, Array.isArray(d._f.refs) && d._f.refs.forEach((f) => {
|
|
969
|
+
f.disabled = d._f.disabled || t;
|
|
970
|
+
}));
|
|
971
|
+
}, 0, !1));
|
|
972
|
+
}, Ze = (t, a) => async (l) => {
|
|
973
|
+
let d;
|
|
974
|
+
l && (l.preventDefault && l.preventDefault(), l.persist && l.persist());
|
|
975
|
+
let f = M(n);
|
|
976
|
+
if (b.state.next({
|
|
977
|
+
isSubmitting: !0
|
|
978
|
+
}), s.resolver) {
|
|
979
|
+
const { errors: o, values: v } = await C();
|
|
980
|
+
r.errors = o, f = v;
|
|
981
|
+
} else
|
|
982
|
+
await P(i);
|
|
983
|
+
if (U(r.errors, "root"), j(r.errors)) {
|
|
984
|
+
b.state.next({
|
|
985
|
+
errors: {}
|
|
986
|
+
});
|
|
987
|
+
try {
|
|
988
|
+
await t(f, l);
|
|
989
|
+
} catch (o) {
|
|
990
|
+
d = o;
|
|
991
|
+
}
|
|
992
|
+
} else
|
|
993
|
+
a && await a({ ...r.errors }, l), Xe(), setTimeout(Xe);
|
|
994
|
+
if (b.state.next({
|
|
995
|
+
isSubmitted: !0,
|
|
996
|
+
isSubmitting: !1,
|
|
997
|
+
isSubmitSuccessful: j(r.errors) && !d,
|
|
998
|
+
submitCount: r.submitCount + 1,
|
|
999
|
+
errors: r.errors
|
|
1000
|
+
}), d)
|
|
1001
|
+
throw d;
|
|
1002
|
+
}, Cr = (t, a = {}) => {
|
|
1003
|
+
c(i, t) && (E(a.defaultValue) ? K(t, M(c(u, t))) : (K(t, a.defaultValue), k(u, t, M(a.defaultValue))), a.keepTouched || U(r.touchedFields, t), a.keepDirty || (U(r.dirtyFields, t), r.isDirty = a.defaultValue ? x(t, M(c(u, t))) : x()), a.keepError || (U(r.errors, t), A.isValid && z()), b.state.next({ ...r }));
|
|
1004
|
+
}, er = (t, a = {}) => {
|
|
1005
|
+
const l = t ? M(t) : u, d = M(l), f = j(t), o = f ? u : d;
|
|
1006
|
+
if (a.keepDefaultValues || (u = l), !a.keepValues) {
|
|
1007
|
+
if (a.keepDirtyValues)
|
|
1008
|
+
for (const v of g.mount)
|
|
1009
|
+
c(r.dirtyFields, v) ? k(o, v, c(n, v)) : K(v, c(o, v));
|
|
1010
|
+
else {
|
|
1011
|
+
if (He && E(t))
|
|
1012
|
+
for (const v of g.mount) {
|
|
1013
|
+
const w = c(i, v);
|
|
1014
|
+
if (w && w._f) {
|
|
1015
|
+
const B = Array.isArray(w._f.refs) ? w._f.refs[0] : w._f.ref;
|
|
1016
|
+
if (me(B)) {
|
|
1017
|
+
const I = B.closest("form");
|
|
1018
|
+
if (I) {
|
|
1019
|
+
I.reset();
|
|
1020
|
+
break;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
i = {};
|
|
1026
|
+
}
|
|
1027
|
+
n = e.shouldUnregister ? a.keepDefaultValues ? M(u) : {} : M(o), b.array.next({
|
|
1028
|
+
values: { ...o }
|
|
1029
|
+
}), b.values.next({
|
|
1030
|
+
values: { ...o }
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
g = {
|
|
1034
|
+
mount: a.keepDirtyValues ? g.mount : /* @__PURE__ */ new Set(),
|
|
1035
|
+
unMount: /* @__PURE__ */ new Set(),
|
|
1036
|
+
array: /* @__PURE__ */ new Set(),
|
|
1037
|
+
watch: /* @__PURE__ */ new Set(),
|
|
1038
|
+
watchAll: !1,
|
|
1039
|
+
focus: ""
|
|
1040
|
+
}, y.mount = !A.isValid || !!a.keepIsValid || !!a.keepDirtyValues, y.watch = !!e.shouldUnregister, b.state.next({
|
|
1041
|
+
submitCount: a.keepSubmitCount ? r.submitCount : 0,
|
|
1042
|
+
isDirty: f ? !1 : a.keepDirty ? r.isDirty : !!(a.keepDefaultValues && !ie(t, u)),
|
|
1043
|
+
isSubmitted: a.keepIsSubmitted ? r.isSubmitted : !1,
|
|
1044
|
+
dirtyFields: f ? {} : a.keepDirtyValues ? a.keepDefaultValues && n ? be(u, n) : r.dirtyFields : a.keepDefaultValues && t ? be(u, t) : a.keepDirty ? r.dirtyFields : {},
|
|
1045
|
+
touchedFields: a.keepTouched ? r.touchedFields : {},
|
|
1046
|
+
errors: a.keepErrors ? r.errors : {},
|
|
1047
|
+
isSubmitSuccessful: a.keepIsSubmitSuccessful ? r.isSubmitSuccessful : !1,
|
|
1048
|
+
isSubmitting: !1
|
|
1049
|
+
});
|
|
1050
|
+
}, rr = (t, a) => er(te(t) ? t(n) : t, a);
|
|
1051
|
+
return {
|
|
1052
|
+
control: {
|
|
1053
|
+
register: ke,
|
|
1054
|
+
unregister: De,
|
|
1055
|
+
getFieldState: ze,
|
|
1056
|
+
handleSubmit: Ze,
|
|
1057
|
+
setError: Je,
|
|
1058
|
+
_executeSchema: C,
|
|
1059
|
+
_getWatch: S,
|
|
1060
|
+
_getDirty: x,
|
|
1061
|
+
_updateValid: z,
|
|
1062
|
+
_removeUnmounted: he,
|
|
1063
|
+
_updateFieldArray: p,
|
|
1064
|
+
_updateDisabledField: Qe,
|
|
1065
|
+
_getFieldArray: L,
|
|
1066
|
+
_reset: er,
|
|
1067
|
+
_resetDefaultValues: () => te(s.defaultValues) && s.defaultValues().then((t) => {
|
|
1068
|
+
rr(t, s.resetOptions), b.state.next({
|
|
1069
|
+
isLoading: !1
|
|
1070
|
+
});
|
|
1071
|
+
}),
|
|
1072
|
+
_updateFormState: (t) => {
|
|
1073
|
+
r = {
|
|
1074
|
+
...r,
|
|
1075
|
+
...t
|
|
1076
|
+
};
|
|
1077
|
+
},
|
|
1078
|
+
_disableForm: Er,
|
|
1079
|
+
_subjects: b,
|
|
1080
|
+
_proxyFormState: A,
|
|
1081
|
+
_setErrors: Q,
|
|
1082
|
+
get _fields() {
|
|
1083
|
+
return i;
|
|
1084
|
+
},
|
|
1085
|
+
get _formValues() {
|
|
1086
|
+
return n;
|
|
1087
|
+
},
|
|
1088
|
+
get _state() {
|
|
1089
|
+
return y;
|
|
1090
|
+
},
|
|
1091
|
+
set _state(t) {
|
|
1092
|
+
y = t;
|
|
1093
|
+
},
|
|
1094
|
+
get _defaultValues() {
|
|
1095
|
+
return u;
|
|
1096
|
+
},
|
|
1097
|
+
get _names() {
|
|
1098
|
+
return g;
|
|
1099
|
+
},
|
|
1100
|
+
set _names(t) {
|
|
1101
|
+
g = t;
|
|
1102
|
+
},
|
|
1103
|
+
get _formState() {
|
|
1104
|
+
return r;
|
|
1105
|
+
},
|
|
1106
|
+
set _formState(t) {
|
|
1107
|
+
r = t;
|
|
1108
|
+
},
|
|
1109
|
+
get _options() {
|
|
1110
|
+
return s;
|
|
1111
|
+
},
|
|
1112
|
+
set _options(t) {
|
|
1113
|
+
s = {
|
|
1114
|
+
...s,
|
|
1115
|
+
...t
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
},
|
|
1119
|
+
trigger: de,
|
|
1120
|
+
register: ke,
|
|
1121
|
+
handleSubmit: Ze,
|
|
1122
|
+
watch: kr,
|
|
1123
|
+
setValue: K,
|
|
1124
|
+
getValues: Ye,
|
|
1125
|
+
reset: rr,
|
|
1126
|
+
resetField: Cr,
|
|
1127
|
+
clearErrors: Dr,
|
|
1128
|
+
unregister: De,
|
|
1129
|
+
setError: Je,
|
|
1130
|
+
setFocus: (t, a = {}) => {
|
|
1131
|
+
const l = c(i, t), d = l && l._f;
|
|
1132
|
+
if (d) {
|
|
1133
|
+
const f = d.refs ? d.refs[0] : d.ref;
|
|
1134
|
+
f.focus && (f.focus(), a.shouldSelect && f.select());
|
|
1135
|
+
}
|
|
1136
|
+
},
|
|
1137
|
+
getFieldState: ze
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
function it(e = {}) {
|
|
1141
|
+
const s = F.useRef(), r = F.useRef(), [i, u] = F.useState({
|
|
1142
|
+
isDirty: !1,
|
|
1143
|
+
isValidating: !1,
|
|
1144
|
+
isLoading: te(e.defaultValues),
|
|
1145
|
+
isSubmitted: !1,
|
|
1146
|
+
isSubmitting: !1,
|
|
1147
|
+
isSubmitSuccessful: !1,
|
|
1148
|
+
isValid: !1,
|
|
1149
|
+
submitCount: 0,
|
|
1150
|
+
dirtyFields: {},
|
|
1151
|
+
touchedFields: {},
|
|
1152
|
+
validatingFields: {},
|
|
1153
|
+
errors: e.errors || {},
|
|
1154
|
+
disabled: e.disabled || !1,
|
|
1155
|
+
defaultValues: te(e.defaultValues) ? void 0 : e.defaultValues
|
|
1156
|
+
});
|
|
1157
|
+
s.current || (s.current = {
|
|
1158
|
+
...Jr(e),
|
|
1159
|
+
formState: i
|
|
1160
|
+
});
|
|
1161
|
+
const n = s.current.control;
|
|
1162
|
+
return n._options = e, we({
|
|
1163
|
+
subject: n._subjects.state,
|
|
1164
|
+
next: (y) => {
|
|
1165
|
+
hr(y, n._proxyFormState, n._updateFormState, !0) && u({ ...n._formState });
|
|
1166
|
+
}
|
|
1167
|
+
}), F.useEffect(() => n._disableForm(e.disabled), [n, e.disabled]), F.useEffect(() => {
|
|
1168
|
+
if (n._proxyFormState.isDirty) {
|
|
1169
|
+
const y = n._getDirty();
|
|
1170
|
+
y !== i.isDirty && n._subjects.state.next({
|
|
1171
|
+
isDirty: y
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
}, [n, i.isDirty]), F.useEffect(() => {
|
|
1175
|
+
e.values && !ie(e.values, r.current) ? (n._reset(e.values, n._options.resetOptions), r.current = e.values, u((y) => ({ ...y }))) : n._resetDefaultValues();
|
|
1176
|
+
}, [e.values, n]), F.useEffect(() => {
|
|
1177
|
+
e.errors && n._setErrors(e.errors);
|
|
1178
|
+
}, [e.errors, n]), F.useEffect(() => {
|
|
1179
|
+
n._state.mount || (n._updateValid(), n._state.mount = !0), n._state.watch && (n._state.watch = !1, n._subjects.state.next({ ...n._formState })), n._removeUnmounted();
|
|
1180
|
+
}), F.useEffect(() => {
|
|
1181
|
+
e.shouldUnregister && n._subjects.values.next({
|
|
1182
|
+
values: n._getWatch()
|
|
1183
|
+
});
|
|
1184
|
+
}, [e.shouldUnregister, n]), s.current.formState = vr(i, n), s.current;
|
|
1185
|
+
}
|
|
1186
|
+
export {
|
|
1187
|
+
tt as C,
|
|
1188
|
+
rt as F,
|
|
1189
|
+
it as a,
|
|
1190
|
+
st as b,
|
|
1191
|
+
Se as u
|
|
1192
|
+
};
|
|
1193
|
+
//# sourceMappingURL=index.esm-C5mr_sKO.js.map
|