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