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