@paragrav/rhf-utils 0.0.138 → 0.0.140
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/README.md +29 -18
- package/dist/esm/{utils/createContext.mjs → createContext.mjs} +1 -1
- package/dist/esm/group.mjs +74 -0
- package/dist/esm/main.mjs +483 -0
- package/dist/esm/trpc.mjs +41 -0
- package/dist/esm/useFlatFieldErrorsContext.mjs +10 -0
- package/dist/esm/utils.mjs +20 -0
- package/dist/types/group.d.ts +9 -0
- package/dist/types/main.d.ts +15 -1
- package/dist/types/trpc.d.ts +2 -0
- package/dist/types/utils.d.ts +1 -0
- package/package.json +22 -4
- package/dist/esm/client/config/useRhfUtilsClientConfigContext.mjs +0 -9
- package/dist/esm/client/index.mjs +0 -49
- package/dist/esm/client/utils.mjs +0 -38
- package/dist/esm/client/zod/context/RhfUtilsClientForZodContextProvider.mjs +0 -17
- package/dist/esm/client/zod/context/RhfUtilsZodForm.mjs +0 -12
- package/dist/esm/client/zod/context/useRhfUtilsClientForZodContext.mjs +0 -9
- package/dist/esm/client/zod/context/useRhfUtilsZodForm.mjs +0 -5
- package/dist/esm/client/zod/createRhfUtilsClientForZod.mjs +0 -6
- package/dist/esm/devtool/LazyDevTool.mjs +0 -15
- package/dist/esm/errors/flat/FlatFieldErrorsList.mjs +0 -17
- package/dist/esm/errors/flat/context/FlatFieldErrorsContextProvider.mjs +0 -27
- package/dist/esm/errors/flat/context/useFlatFieldErrorsContext.mjs +0 -9
- package/dist/esm/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.mjs +0 -9
- package/dist/esm/errors/flat/context/useFlatFieldErrorsContextOutput.mjs +0 -24
- package/dist/esm/errors/flat/filterFlatFieldErrors.mjs +0 -10
- package/dist/esm/errors/flat/flattenFieldErrors.mjs +0 -5
- package/dist/esm/errors/flat/getFlatFieldErrors.mjs +0 -24
- package/dist/esm/errors/getRefdFromFlatFieldErrors.mjs +0 -8
- package/dist/esm/errors/isFieldErrorRefd.mjs +0 -4
- package/dist/esm/errors/isFlatFieldErrorEntryRefd.mjs +0 -5
- package/dist/esm/errors/message/FormErrorMessage.mjs +0 -14
- package/dist/esm/errors/message/RhfUtilsFieldErrorMessage.mjs +0 -14
- package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.mjs +0 -19
- package/dist/esm/errors/nonfield/FormNonFieldErrorMarker.utils.mjs +0 -23
- package/dist/esm/errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.mjs +0 -4
- package/dist/esm/errors/nonfield/isNonFieldErrorMarkerInDOM.mjs +0 -5
- package/dist/esm/errors/orphan/getIsOrphanFormErrorWithParentElement.mjs +0 -5
- package/dist/esm/errors/orphan/getOrphansFromFlatFieldErrors.mjs +0 -8
- package/dist/esm/errors/orphan/isOrphanFormError.mjs +0 -12
- package/dist/esm/errors/output/consoleErrors.mjs +0 -6
- package/dist/esm/errors/root/RootErrorsListFromFlatFieldErrorsContext.mjs +0 -10
- package/dist/esm/errors/root/consts.mjs +0 -4
- package/dist/esm/errors/root/getRootsFromFlatFieldErrors.mjs +0 -8
- package/dist/esm/errors/root/isFlatFieldErrorEntryPathRoot.mjs +0 -5
- package/dist/esm/errors/root/isFormErrorPathRoot.mjs +0 -5
- package/dist/esm/exports.mjs +0 -46
- package/dist/esm/form/Form.mjs +0 -86
- package/dist/esm/form/FormWithProviders.mjs +0 -11
- package/dist/esm/form/RhfUtilsFormProviders.mjs +0 -24
- package/dist/esm/form/_Controller.mjs +0 -8
- package/dist/esm/form/context/group/FormGroupContextProvider.mjs +0 -30
- package/dist/esm/form/context/group/index.mjs +0 -11
- package/dist/esm/form/context/group/useFormGroupChildIsMountedTracker.mjs +0 -6
- package/dist/esm/form/context/group/useFormGroupChildIsSubmittingTracker.mjs +0 -10
- package/dist/esm/form/context/group/useFormGroupChildTracker.mjs +0 -13
- package/dist/esm/form/context/group/useFormGroupIsAnyBusy.mjs +0 -8
- package/dist/esm/form/context/group/useFormGroupIsChildBusy.mjs +0 -8
- package/dist/esm/form/context/group/useFormGroupIsParentBusy.mjs +0 -8
- package/dist/esm/form/context/group/useFormGroupParentTracker.mjs +0 -13
- package/dist/esm/form/context/group/useFormOrParentIsBusy.mjs +0 -10
- package/dist/esm/form/context/utils/RhfUtilsContextProvider.mjs +0 -23
- package/dist/esm/form/context/utils/useRhfUtilsContext.mjs +0 -6
- package/dist/esm/form/context/utils/useRhfUtilsContextRequestSubmit.mjs +0 -9
- package/dist/esm/form/useFormIsBusy.mjs +0 -8
- package/dist/esm/form/useRhfUtilsForm.mjs +0 -43
- package/dist/esm/form/utils/getSubmitterButtonData.mjs +0 -12
- package/dist/esm/form/utils/useFormRequestSubmit.mjs +0 -13
- package/dist/esm/submit/error/FormSubmitError.mjs +0 -8
- package/dist/esm/submit/error/setCtxErrorsByFormSubmitFieldErrors.mjs +0 -12
- package/dist/esm/submit/useFormOnSubmitted.mjs +0 -12
- package/dist/esm/submit/useResetFormOnSubmitted.mjs +0 -36
- package/dist/esm/submit/useSubmitFormOnChange.mjs +0 -26
- package/dist/esm/utils/PassthroughChildren.mjs +0 -7
- package/dist/esm/utils/isEmptyObject.mjs +0 -4
- package/dist/esm/utils/useDebouncedOnChangeValue.mjs +0 -26
- package/dist/esm/utils/useRefIfValueWasTrue.mjs +0 -14
- package/dist/types/client/config/RhfUtilsClientConfig.d.ts +0 -71
- package/dist/types/client/config/useRhfUtilsClientConfigContext.d.ts +0 -5
- package/dist/types/client/context.d.ts +0 -3
- package/dist/types/client/index.d.ts +0 -30
- package/dist/types/client/utils.d.ts +0 -13
- package/dist/types/client/zod/RhfUtilsUseFormChildrenZodFC.d.ts +0 -13
- package/dist/types/client/zod/RhfUtilsUseFormChildrenZodProps.d.ts +0 -5
- package/dist/types/client/zod/ZodTypeFieldValues.d.ts +0 -4
- package/dist/types/client/zod/consts.d.ts +0 -4
- package/dist/types/client/zod/context/RhfUtilsClientForZodContextProvider.d.ts +0 -8
- package/dist/types/client/zod/context/RhfUtilsZodForm.d.ts +0 -9
- package/dist/types/client/zod/context/useRhfUtilsClientForZodContext.d.ts +0 -6
- package/dist/types/client/zod/context/useRhfUtilsZodForm.d.ts +0 -8
- package/dist/types/client/zod/createRhfUtilsClientForZod.d.ts +0 -4
- package/dist/types/devtool/LazyDevTool.d.ts +0 -12
- package/dist/types/errors/flat/FlatFieldErrorsList.d.ts +0 -7
- package/dist/types/errors/flat/context/FlatFieldErrorsContextProvider.d.ts +0 -11
- package/dist/types/errors/flat/context/FlatFieldErrorsOutputConfig.d.ts +0 -20
- package/dist/types/errors/flat/context/useFlatFieldErrorsContext.d.ts +0 -13
- package/dist/types/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.d.ts +0 -7
- package/dist/types/errors/flat/context/useFlatFieldErrorsContextOutput.d.ts +0 -7
- package/dist/types/errors/flat/filterFlatFieldErrors.d.ts +0 -9
- package/dist/types/errors/flat/flattenFieldErrors.d.ts +0 -16
- package/dist/types/errors/flat/getFlatFieldErrors.d.ts +0 -32
- package/dist/types/errors/flat/types.d.ts +0 -17
- package/dist/types/errors/getRefdFromFlatFieldErrors.d.ts +0 -2
- package/dist/types/errors/isFieldErrorRefd.d.ts +0 -7
- package/dist/types/errors/isFlatFieldErrorEntryRefd.d.ts +0 -7
- package/dist/types/errors/message/FormErrorMessage.d.ts +0 -8
- package/dist/types/errors/message/RhfUtilsFieldErrorMessage.d.ts +0 -10
- package/dist/types/errors/nonfield/FormNonFieldErrorMarker.d.ts +0 -13
- package/dist/types/errors/nonfield/FormNonFieldErrorMarker.spec.d.ts +0 -1
- package/dist/types/errors/nonfield/FormNonFieldErrorMarker.utils.d.ts +0 -18
- package/dist/types/errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.d.ts +0 -5
- package/dist/types/errors/nonfield/isNonFieldError.d.ts +0 -19
- package/dist/types/errors/nonfield/isNonFieldErrorMarkerInDOM.d.ts +0 -6
- package/dist/types/errors/orphan/getIsOrphanFormErrorWithParentElement.d.ts +0 -7
- package/dist/types/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +0 -4
- package/dist/types/errors/orphan/isOrphanFormError.d.ts +0 -4
- package/dist/types/errors/output/consoleErrors.d.ts +0 -7
- package/dist/types/errors/output/types.d.ts +0 -7
- package/dist/types/errors/root/RootErrorsListFromFlatFieldErrorsContext.d.ts +0 -2
- package/dist/types/errors/root/consts.d.ts +0 -1
- package/dist/types/errors/root/getRootsFromFlatFieldErrors.d.ts +0 -2
- package/dist/types/errors/root/isFlatFieldErrorEntryPathRoot.d.ts +0 -7
- package/dist/types/errors/root/isFormErrorPathRoot.d.ts +0 -7
- package/dist/types/errors/trpc/getOnSubmitTrpcClientErrorHandler.d.ts +0 -11
- package/dist/types/errors/trpc/trpcClientErrorMessageSchema.d.ts +0 -24
- package/dist/types/errors/trpc/trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer.d.ts +0 -28
- package/dist/types/exports.d.ts +0 -29
- package/dist/types/form/Form.d.ts +0 -11
- package/dist/types/form/FormWithProviders.d.ts +0 -13
- package/dist/types/form/RhfUtilsFormOptions.d.ts +0 -29
- package/dist/types/form/RhfUtilsFormProviders.d.ts +0 -12
- package/dist/types/form/SafeFieldValues.d.ts +0 -4
- package/dist/types/form/UseRhfUtilsFormChildrenProps.d.ts +0 -20
- package/dist/types/form/UseRhfUtilsFormOnSubmitContext.d.ts +0 -27
- package/dist/types/form/UseRhfUtilsFormProps.d.ts +0 -23
- package/dist/types/form/UseRhfUtilsFormReturn.d.ts +0 -20
- package/dist/types/form/_Controller.d.ts +0 -6
- package/dist/types/form/context/group/FormGroupContextProvider.d.ts +0 -5
- package/dist/types/form/context/group/index.d.ts +0 -14
- package/dist/types/form/context/group/useFormGroupChildIsMountedTracker.d.ts +0 -5
- package/dist/types/form/context/group/useFormGroupChildIsSubmittingTracker.d.ts +0 -5
- package/dist/types/form/context/group/useFormGroupChildTracker.d.ts +0 -6
- package/dist/types/form/context/group/useFormGroupIsAnyBusy.d.ts +0 -2
- package/dist/types/form/context/group/useFormGroupIsChildBusy.d.ts +0 -2
- package/dist/types/form/context/group/useFormGroupIsParentBusy.d.ts +0 -2
- package/dist/types/form/context/group/useFormGroupParentTracker.d.ts +0 -7
- package/dist/types/form/context/group/useFormOrParentIsBusy.d.ts +0 -2
- package/dist/types/form/context/utils/RhfUtilsContextProvider.d.ts +0 -9
- package/dist/types/form/context/utils/useRhfUtilsContext.d.ts +0 -14
- package/dist/types/form/context/utils/useRhfUtilsContextRequestSubmit.d.ts +0 -5
- package/dist/types/form/useFormIsBusy.d.ts +0 -2
- package/dist/types/form/useRhfUtilsForm.d.ts +0 -16
- package/dist/types/form/utils/getSubmitterButtonData.d.ts +0 -8
- package/dist/types/form/utils/useFormRequestSubmit.d.ts +0 -11
- package/dist/types/form/utils/useShouldFormBlockNavigation.d.ts +0 -26
- package/dist/types/register.d.ts +0 -7
- package/dist/types/submit/error/FormSubmitError.d.ts +0 -7
- package/dist/types/submit/error/FormSubmitFieldErrors.d.ts +0 -15
- package/dist/types/submit/error/setCtxErrorsByFormSubmitFieldErrors.d.ts +0 -10
- package/dist/types/submit/useFormOnSubmitSuccessfulAndReset.d.ts +0 -15
- package/dist/types/submit/useFormOnSubmitted.d.ts +0 -6
- package/dist/types/submit/useResetFormOnSubmitted.d.ts +0 -36
- package/dist/types/submit/useSubmitFormOnChange.d.ts +0 -9
- package/dist/types/utils/PassthroughChildren.d.ts +0 -7
- package/dist/types/utils/createContext.d.ts +0 -12
- package/dist/types/utils/fixedForwardRef.d.ts +0 -7
- package/dist/types/utils/isEmptyObject.d.ts +0 -2
- package/dist/types/utils/timeoutAsync.d.ts +0 -6
- package/dist/types/utils/types.d.ts +0 -1
- package/dist/types/utils/useDebouncedOnChangeValue.d.ts +0 -14
- package/dist/types/utils/useImperativeForwardedRef.d.ts +0 -11
- package/dist/types/utils/useRefIfValueWasTrue.d.ts +0 -2
- package/dist/types/utils/useThrowAsyncError.d.ts +0 -5
- package/dist/types/utils/useToggle.d.ts +0 -4
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TRPCClientError as a } from "@trpc/client";
|
|
2
|
+
import { z as e } from "zod";
|
|
3
|
+
const o = e.object({
|
|
4
|
+
validation: e.string(),
|
|
5
|
+
code: e.string(),
|
|
6
|
+
message: e.string(),
|
|
7
|
+
path: e.array(e.string())
|
|
8
|
+
}), s = e.custom(
|
|
9
|
+
(r) => r instanceof a
|
|
10
|
+
// check instance type
|
|
11
|
+
).transform((r) => r.message).transform((r) => {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(r);
|
|
14
|
+
} catch {
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
validation: "root",
|
|
18
|
+
code: "server",
|
|
19
|
+
message: r,
|
|
20
|
+
path: ["root"]
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
}).pipe(e.array(o)).transform(
|
|
25
|
+
(r) => r.map(
|
|
26
|
+
(t) => [
|
|
27
|
+
t.path.join("."),
|
|
28
|
+
// flatten path (e.g., "street.name")
|
|
29
|
+
{
|
|
30
|
+
type: t.code,
|
|
31
|
+
message: t.message
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
)
|
|
35
|
+
).transform((r) => Object.fromEntries(r)), m = (r) => (t) => t instanceof a ? s.parse(
|
|
36
|
+
t
|
|
37
|
+
) : r(t);
|
|
38
|
+
export {
|
|
39
|
+
m as makeOnSubmitTrpcClientErrorHandler,
|
|
40
|
+
s as trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer
|
|
41
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { i as s, u as i } from "./useFlatFieldErrorsContext.mjs";
|
|
3
|
+
const l = ({ errors: r }) => {
|
|
4
|
+
if (r && !s(r))
|
|
5
|
+
return /* @__PURE__ */ t("ul", { children: Object.values(r).map((o, e) => /* @__PURE__ */ t(
|
|
6
|
+
"li",
|
|
7
|
+
{
|
|
8
|
+
role: "alert",
|
|
9
|
+
"aria-live": "polite",
|
|
10
|
+
children: o.message
|
|
11
|
+
},
|
|
12
|
+
e
|
|
13
|
+
)) });
|
|
14
|
+
}, m = () => {
|
|
15
|
+
const r = i().roots;
|
|
16
|
+
return /* @__PURE__ */ t(l, { errors: r });
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
m as RootErrorsListFromFlatFieldErrorsContext
|
|
20
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as FormGroupContextProvider } from '../form/context/group/FormGroupContextProvider';
|
|
2
|
+
export { default as useFormGroupChildIsMountedTracker } from '../form/context/group/useFormGroupChildIsMountedTracker';
|
|
3
|
+
export { default as useFormGroupChildIsSubmittingTracker } from '../form/context/group/useFormGroupChildIsSubmittingTracker';
|
|
4
|
+
export { default as useFormGroupChildTracker } from '../form/context/group/useFormGroupChildTracker';
|
|
5
|
+
export { default as useFormGroupIsAnyBusy } from '../form/context/group/useFormGroupIsAnyBusy';
|
|
6
|
+
export { default as useFormGroupIsChildBusy } from '../form/context/group/useFormGroupIsChildBusy';
|
|
7
|
+
export { default as useFormGroupIsParentBusy } from '../form/context/group/useFormGroupIsParentBusy';
|
|
8
|
+
export { default as useFormGroupParentTracker } from '../form/context/group/useFormGroupParentTracker';
|
|
9
|
+
export { default as useFormOrParentIsBusy } from '../form/context/group/useFormOrParentIsBusy';
|
package/dist/types/main.d.ts
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export type { Register } from '../register';
|
|
2
|
+
export type { RhfUtilsClientConfig } from '../client/config/RhfUtilsClientConfig';
|
|
3
|
+
export { default as RhfUtilsClientForZodContextProvider } from '../client/zod/context/RhfUtilsClientForZodContextProvider';
|
|
4
|
+
export { default as RhfUtilsZodForm } from '../client/zod/context/RhfUtilsZodForm';
|
|
5
|
+
export { default as useRhfUtilsZodForm } from '../client/zod/context/useRhfUtilsZodForm';
|
|
6
|
+
export type { RhfUtilsUseFormChildrenZodFC } from '../client/zod/RhfUtilsUseFormChildrenZodFC';
|
|
7
|
+
export type { RhfUtilsUseFormChildrenZodProps } from '../client/zod/RhfUtilsUseFormChildrenZodProps';
|
|
8
|
+
export { default as useFlatFieldErrorsContext } from '../errors/flat/context/useFlatFieldErrorsContext';
|
|
9
|
+
export { default as useFlatFieldErrorsContextHasOnlyOrphans } from '../errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans';
|
|
10
|
+
export { default as RhfUtilsNonFieldErrorMarker } from '../errors/nonfield/RhfUtilsNonFieldErrorMarker';
|
|
11
|
+
export type { RhfUtilsFormOptions } from '../form/RhfUtilsFormOptions';
|
|
12
|
+
export type { SafeFieldValues } from '../form/SafeFieldValues';
|
|
13
|
+
export type { UseRhfUtilsFormChildrenProps } from '../form/UseRhfUtilsFormChildrenProps';
|
|
14
|
+
export { default as useRhfUtilsContext } from '../form/context/utils/useRhfUtilsContext';
|
|
15
|
+
export { FormSubmitError } from '../submit/error/FormSubmitError';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as RootErrorsListFromFlatFieldErrorsContext } from '../errors/root/RootErrorsListFromFlatFieldErrorsContext';
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@paragrav/rhf-utils",
|
|
3
3
|
"author": "paragrav.dev",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.140",
|
|
6
6
|
"description": "Integration utilities for react-hook-form.",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -10,12 +10,30 @@
|
|
|
10
10
|
"dist/esm/*",
|
|
11
11
|
"dist/types/*"
|
|
12
12
|
],
|
|
13
|
-
"module": "./dist/esm/
|
|
13
|
+
"module": "./dist/esm/main.mjs",
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
16
|
"import": {
|
|
17
|
-
"default": "./dist/esm/
|
|
18
|
-
"types": "./dist/types/
|
|
17
|
+
"default": "./dist/esm/main.mjs",
|
|
18
|
+
"types": "./dist/types/main.d.ts"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"./group": {
|
|
22
|
+
"import": {
|
|
23
|
+
"default": "./dist/esm/group.mjs",
|
|
24
|
+
"types": "./dist/types/group.d.ts"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"./trpc": {
|
|
28
|
+
"import": {
|
|
29
|
+
"default": "./dist/esm/trpc.mjs",
|
|
30
|
+
"types": "./dist/types/trpc.d.ts"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"./utils": {
|
|
34
|
+
"import": {
|
|
35
|
+
"default": "./dist/esm/utils.mjs",
|
|
36
|
+
"types": "./dist/types/utils.d.ts"
|
|
19
37
|
}
|
|
20
38
|
}
|
|
21
39
|
},
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
-
import "react";
|
|
3
|
-
import n from "../form/FormWithProviders.mjs";
|
|
4
|
-
import l from "../form/useRhfUtilsForm.mjs";
|
|
5
|
-
import { mergeRhfUtilsClientConfigDefaultsWithUseRhfUtilsFormProps as F } from "./utils.mjs";
|
|
6
|
-
const c = (r) => (o) => {
|
|
7
|
-
const e = f(r, o);
|
|
8
|
-
return {
|
|
9
|
-
useForm: (s, t) => {
|
|
10
|
-
const i = e(s, t);
|
|
11
|
-
return {
|
|
12
|
-
...l(i),
|
|
13
|
-
FormWithProviders: () => /* @__PURE__ */ m(n, { ...i })
|
|
14
|
-
};
|
|
15
|
-
},
|
|
16
|
-
FormWithProviders: u(r, o)
|
|
17
|
-
};
|
|
18
|
-
}, f = (r, o) => function(s, t) {
|
|
19
|
-
return {
|
|
20
|
-
...t,
|
|
21
|
-
...F(
|
|
22
|
-
o.defaults,
|
|
23
|
-
t,
|
|
24
|
-
{
|
|
25
|
-
rhf: {
|
|
26
|
-
resolver: r(s)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
)
|
|
30
|
-
};
|
|
31
|
-
}, u = (r, o) => {
|
|
32
|
-
const e = f(r, o);
|
|
33
|
-
return function({
|
|
34
|
-
schema: t,
|
|
35
|
-
children: i,
|
|
36
|
-
...h
|
|
37
|
-
}) {
|
|
38
|
-
return /* @__PURE__ */ m(
|
|
39
|
-
n,
|
|
40
|
-
{
|
|
41
|
-
...e(t, h),
|
|
42
|
-
children: i
|
|
43
|
-
}
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
export {
|
|
48
|
-
c as createRhfUtilsClient
|
|
49
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const u = (n, ...r) => (
|
|
2
|
-
// sequentially merge each set of props into defaults
|
|
3
|
-
r.reduce(
|
|
4
|
-
(t, e) => {
|
|
5
|
-
var s, i, l, m, o, f;
|
|
6
|
-
return {
|
|
7
|
-
rhf: {
|
|
8
|
-
...t == null ? void 0 : t.rhf,
|
|
9
|
-
...e.rhf
|
|
10
|
-
},
|
|
11
|
-
utils: {
|
|
12
|
-
...t == null ? void 0 : t.utils,
|
|
13
|
-
...e.utils,
|
|
14
|
-
// manual merges
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- false positive
|
|
16
|
-
...(((s = t == null ? void 0 : t.utils) == null ? void 0 : s.resetOnSubmitted) || ((i = e.utils) == null ? void 0 : i.resetOnSubmitted)) && {
|
|
17
|
-
resetOnSubmitted: {
|
|
18
|
-
...(l = t == null ? void 0 : t.utils) == null ? void 0 : l.resetOnSubmitted,
|
|
19
|
-
...(m = e.utils) == null ? void 0 : m.resetOnSubmitted
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
form: {
|
|
24
|
-
...t == null ? void 0 : t.form,
|
|
25
|
-
...e.form,
|
|
26
|
-
// manual merges
|
|
27
|
-
className: [(o = t == null ? void 0 : t.form) == null ? void 0 : o.className, (f = e.form) == null ? void 0 : f.className].filter(Boolean).join(" ") || void 0
|
|
28
|
-
// stringify (replace empty string with undefined)
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
// start with defaults
|
|
33
|
-
n
|
|
34
|
-
)
|
|
35
|
-
);
|
|
36
|
-
export {
|
|
37
|
-
u as mergeRhfUtilsClientConfigDefaultsWithUseRhfUtilsFormProps
|
|
38
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import e from "react";
|
|
3
|
-
import { _RhfUtilsClientConfigContextProvider as l } from "../../config/useRhfUtilsClientConfigContext.mjs";
|
|
4
|
-
import f from "../createRhfUtilsClientForZod.mjs";
|
|
5
|
-
import { _RhfUtilsClientForZodContextProvider as s } from "./useRhfUtilsClientForZodContext.mjs";
|
|
6
|
-
const d = ({
|
|
7
|
-
config: r,
|
|
8
|
-
children: i
|
|
9
|
-
}) => {
|
|
10
|
-
const [t] = e.useState(r), [n] = e.useState(
|
|
11
|
-
() => f(t ?? {})
|
|
12
|
-
);
|
|
13
|
-
return /* @__PURE__ */ o(l, { value: t, children: /* @__PURE__ */ o(s, { value: n, children: i }) });
|
|
14
|
-
}, p = d;
|
|
15
|
-
export {
|
|
16
|
-
p as default
|
|
17
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import e from "./useRhfUtilsClientForZodContext.mjs";
|
|
3
|
-
function m({
|
|
4
|
-
schema: o,
|
|
5
|
-
...t
|
|
6
|
-
}) {
|
|
7
|
-
const { FormWithProviders: r } = e();
|
|
8
|
-
return /* @__PURE__ */ i(r, { schema: o, ...t });
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
m as default
|
|
12
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import e from "react";
|
|
3
|
-
import { useFormContext as n } from "react-hook-form";
|
|
4
|
-
const a = e.lazy(
|
|
5
|
-
() => import("@hookform/devtools").then((o) => ({
|
|
6
|
-
default: o.DevTool
|
|
7
|
-
}))
|
|
8
|
-
), u = ({ isDevelopment: o, props: r }) => {
|
|
9
|
-
if (!o) return null;
|
|
10
|
-
const { control: l } = n();
|
|
11
|
-
return /* @__PURE__ */ t(e.Suspense, { fallback: null, children: /* @__PURE__ */ t(a, { control: l, ...r }) });
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
u as default
|
|
15
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import l from "../../utils/isEmptyObject.mjs";
|
|
3
|
-
const o = ({ errors: e }) => {
|
|
4
|
-
if (e && !l(e))
|
|
5
|
-
return /* @__PURE__ */ t("ul", { children: Object.values(e).map((i, r) => /* @__PURE__ */ t(
|
|
6
|
-
"li",
|
|
7
|
-
{
|
|
8
|
-
role: "alert",
|
|
9
|
-
"aria-live": "polite",
|
|
10
|
-
children: i.message
|
|
11
|
-
},
|
|
12
|
-
r
|
|
13
|
-
)) });
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
o as default
|
|
17
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import "react";
|
|
3
|
-
import { useFormState as l } from "react-hook-form";
|
|
4
|
-
import F from "../../getRefdFromFlatFieldErrors.mjs";
|
|
5
|
-
import e from "../../../utils/isEmptyObject.mjs";
|
|
6
|
-
import p from "../../orphan/getOrphansFromFlatFieldErrors.mjs";
|
|
7
|
-
import n from "../../root/getRootsFromFlatFieldErrors.mjs";
|
|
8
|
-
import d from "../getFlatFieldErrors.mjs";
|
|
9
|
-
import { _FormErrorsFlatContextProvider as f } from "./useFlatFieldErrorsContext.mjs";
|
|
10
|
-
const C = ({
|
|
11
|
-
formRef: o,
|
|
12
|
-
children: m
|
|
13
|
-
}) => {
|
|
14
|
-
const { errors: t } = l(), r = d(t), s = o.current ? p(r, o.current) : {}, i = {
|
|
15
|
-
all: r,
|
|
16
|
-
fields: F(r),
|
|
17
|
-
roots: n(r),
|
|
18
|
-
orphans: s,
|
|
19
|
-
// computed
|
|
20
|
-
hasErrors: !e(t),
|
|
21
|
-
hasOrphans: !e(s)
|
|
22
|
-
};
|
|
23
|
-
return /* @__PURE__ */ a(f, { value: i, children: m });
|
|
24
|
-
};
|
|
25
|
-
export {
|
|
26
|
-
C as default
|
|
27
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import s from "react";
|
|
2
|
-
import e from "./useFlatFieldErrorsContext.mjs";
|
|
3
|
-
const t = () => {
|
|
4
|
-
const r = e();
|
|
5
|
-
return s.useMemo(() => !r.hasErrors || !r.hasOrphans ? !1 : Object.keys(r.orphans).length === Object.keys(r.all).length, [r]);
|
|
6
|
-
}, l = t;
|
|
7
|
-
export {
|
|
8
|
-
l as default
|
|
9
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import u from "react";
|
|
2
|
-
import { useFormContext as p } from "react-hook-form";
|
|
3
|
-
import E from "../../output/consoleErrors.mjs";
|
|
4
|
-
import F from "./useFlatFieldErrorsContext.mjs";
|
|
5
|
-
const C = (r) => {
|
|
6
|
-
const l = p(), t = F();
|
|
7
|
-
u.useEffect(() => {
|
|
8
|
-
var o, m;
|
|
9
|
-
if (!t.hasErrors) return;
|
|
10
|
-
const e = (o = r == null ? void 0 : r.console) == null ? void 0 : o.call(r, t);
|
|
11
|
-
e && E(
|
|
12
|
-
e.message ?? a,
|
|
13
|
-
l.getValues(),
|
|
14
|
-
t,
|
|
15
|
-
e.type
|
|
16
|
-
);
|
|
17
|
-
const s = (m = r == null ? void 0 : r.throw) == null ? void 0 : m.call(r, t);
|
|
18
|
-
if (s)
|
|
19
|
-
throw new Error(typeof s == "string" ? s : a);
|
|
20
|
-
}, [t]);
|
|
21
|
-
}, a = "Form errors";
|
|
22
|
-
export {
|
|
23
|
-
C as default
|
|
24
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { get as d } from "react-hook-form";
|
|
2
|
-
import a from "./flattenFieldErrors.mjs";
|
|
3
|
-
const b = (t) => {
|
|
4
|
-
const s = a(t), n = Object.keys(s);
|
|
5
|
-
return Object.fromEntries(
|
|
6
|
-
n.reduce(
|
|
7
|
-
(e, o) => {
|
|
8
|
-
const r = o.replace(
|
|
9
|
-
i,
|
|
10
|
-
""
|
|
11
|
-
);
|
|
12
|
-
if (r === o) return e;
|
|
13
|
-
const f = d(t, r, void 0);
|
|
14
|
-
return f && e.push([r, f]), e;
|
|
15
|
-
},
|
|
16
|
-
[]
|
|
17
|
-
// entries
|
|
18
|
-
)
|
|
19
|
-
);
|
|
20
|
-
}, i = /\.(?:type|message)\b$/;
|
|
21
|
-
export {
|
|
22
|
-
b as default,
|
|
23
|
-
i as regexMaybeFieldErrorLeafNodeSuffix
|
|
24
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import "react";
|
|
3
|
-
const i = ({ message: r, className: e }) => /* @__PURE__ */ o(
|
|
4
|
-
"p",
|
|
5
|
-
{
|
|
6
|
-
role: "alert",
|
|
7
|
-
"aria-live": "polite",
|
|
8
|
-
className: e,
|
|
9
|
-
children: r
|
|
10
|
-
}
|
|
11
|
-
);
|
|
12
|
-
export {
|
|
13
|
-
i as default
|
|
14
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jsxs as n, Fragment as i, jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { useFormState as a, get as l } from "react-hook-form";
|
|
3
|
-
import f from "../nonfield/FormNonFieldErrorMarker.mjs";
|
|
4
|
-
import g from "./FormErrorMessage.mjs";
|
|
5
|
-
const F = ({ path: e, Component: s }) => {
|
|
6
|
-
const { errors: t } = a(), r = l(t, e, void 0), m = s ?? g;
|
|
7
|
-
return r != null && r.message ? /* @__PURE__ */ n(i, { children: [
|
|
8
|
-
/* @__PURE__ */ o(m, { message: r.message }),
|
|
9
|
-
/* @__PURE__ */ o(f, { path: e })
|
|
10
|
-
] }) : null;
|
|
11
|
-
}, E = F;
|
|
12
|
-
export {
|
|
13
|
-
E as default
|
|
14
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import e from "./FormNonFieldErrorMarkerHtmlAttribute.mjs";
|
|
3
|
-
const a = ({ path: r }) => {
|
|
4
|
-
const o = {
|
|
5
|
-
[e]: r
|
|
6
|
-
};
|
|
7
|
-
return /* @__PURE__ */ t(
|
|
8
|
-
"div",
|
|
9
|
-
{
|
|
10
|
-
role: "alert",
|
|
11
|
-
"aria-hidden": "true",
|
|
12
|
-
style: { display: "none" },
|
|
13
|
-
...o
|
|
14
|
-
}
|
|
15
|
-
);
|
|
16
|
-
}, d = a;
|
|
17
|
-
export {
|
|
18
|
-
d as default
|
|
19
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import l from "./FormNonFieldErrorMarkerHtmlAttribute.mjs";
|
|
2
|
-
const m = (r, e) => (
|
|
3
|
-
// list of selector variants
|
|
4
|
-
[
|
|
5
|
-
// equals
|
|
6
|
-
// e.g., attr="path"
|
|
7
|
-
["", ""],
|
|
8
|
-
[
|
|
9
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors#attrvalue_4
|
|
10
|
-
"^",
|
|
11
|
-
// only match nested (avoid match 'field' with 'field1`)
|
|
12
|
-
"."
|
|
13
|
-
]
|
|
14
|
-
].map(
|
|
15
|
-
([o, t]) => n(
|
|
16
|
-
l + o,
|
|
17
|
-
r + t
|
|
18
|
-
)
|
|
19
|
-
).join(", ")
|
|
20
|
-
), n = (r, e) => `[role="alert"][${r}="${e}"]`;
|
|
21
|
-
export {
|
|
22
|
-
m as getFormNonFieldErrorMarkerQuerySelector
|
|
23
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import m from "../isFieldErrorRefd.mjs";
|
|
2
|
-
import t from "../nonfield/isNonFieldErrorMarkerInDOM.mjs";
|
|
3
|
-
import e from "../root/isFormErrorPathRoot.mjs";
|
|
4
|
-
const d = (r, o, i) => (
|
|
5
|
-
// non-field
|
|
6
|
-
!m(o) && // non-root
|
|
7
|
-
!e(r) && // not marked in DOM
|
|
8
|
-
!t(r, i)
|
|
9
|
-
);
|
|
10
|
-
export {
|
|
11
|
-
d as default
|
|
12
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import t from "../flat/context/useFlatFieldErrorsContext.mjs";
|
|
3
|
-
import s from "../flat/FlatFieldErrorsList.mjs";
|
|
4
|
-
const e = () => {
|
|
5
|
-
const r = t().roots;
|
|
6
|
-
return /* @__PURE__ */ o(s, { errors: r });
|
|
7
|
-
}, m = e;
|
|
8
|
-
export {
|
|
9
|
-
m as default
|
|
10
|
-
};
|