@paragrav/rhf-utils 0.64.0 → 0.66.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/README.md +3 -2
- package/package.json +31 -44
- package/dist/dts/Register.d.ts +0 -16
- package/dist/dts/_exports/config.d.ts +0 -2
- package/dist/dts/_exports/errors.d.ts +0 -3
- package/dist/dts/_exports/form.d.ts +0 -7
- package/dist/dts/_exports/index.d.ts +0 -14
- package/dist/dts/_exports/relay.d.ts +0 -7
- package/dist/dts/_exports/submit.d.ts +0 -4
- package/dist/dts/_exports/trpc.d.ts +0 -2
- package/dist/dts/_exports/types.d.ts +0 -7
- package/dist/dts/_exports/zod.d.ts +0 -6
- package/dist/dts/client/config/RhfUtilsClientConfigType.d.ts +0 -71
- package/dist/dts/client/config/context/RhfUtilsClientConfigContext.d.ts +0 -3
- package/dist/dts/client/config/context/RhfUtilsClientConfigProvider.d.ts +0 -7
- package/dist/dts/client/config/context/useRhfUtilsClientConfig.d.ts +0 -1
- package/dist/dts/devtool/LazyDevTool.d.ts +0 -10
- package/dist/dts/devtool/LazyDevToolViaProviders.d.ts +0 -1
- package/dist/dts/errors/flat/FlatFieldErrorsList.d.ts +0 -6
- package/dist/dts/errors/flat/context/FlatFieldErrorsContextProvider.d.ts +0 -10
- package/dist/dts/errors/flat/context/FlatFieldErrorsOutputConfig.d.ts +0 -19
- package/dist/dts/errors/flat/context/useFlatFieldErrorsContext.d.ts +0 -11
- package/dist/dts/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.d.ts +0 -6
- package/dist/dts/errors/flat/context/useFlatFieldErrorsContextOutput.d.ts +0 -5
- package/dist/dts/errors/flat/filterFlatFieldErrors.d.ts +0 -7
- package/dist/dts/errors/flat/flattenFieldErrors.d.ts +0 -14
- package/dist/dts/errors/flat/getFlatFieldErrors.d.ts +0 -35
- package/dist/dts/errors/flat/types.d.ts +0 -16
- package/dist/dts/errors/getRefdFromFlatFieldErrors.d.ts +0 -1
- package/dist/dts/errors/isFieldErrorRefd.d.ts +0 -5
- package/dist/dts/errors/isFlatFieldErrorEntryRefd.d.ts +0 -5
- package/dist/dts/errors/message/FormErrorMessage.d.ts +0 -7
- package/dist/dts/errors/message/RhfUtilsFieldErrorMessage.d.ts +0 -10
- package/dist/dts/errors/nonfield/RhfUtilsNonFieldErrorMarker.d.ts +0 -13
- package/dist/dts/errors/nonfield/RhfUtilsNonFieldErrorMarker.spec.d.ts +0 -1
- package/dist/dts/errors/nonfield/RhfUtilsNonFieldErrorMarker.utils.d.ts +0 -18
- package/dist/dts/errors/nonfield/RhfUtilsNonFieldErrorMarkerHtmlAttribute.d.ts +0 -4
- package/dist/dts/errors/nonfield/isNonFieldError.d.ts +0 -17
- package/dist/dts/errors/nonfield/isNonFieldErrorMarkerInDOM.d.ts +0 -5
- package/dist/dts/errors/orphan/getIsOrphanFormErrorWithParentElement.d.ts +0 -5
- package/dist/dts/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +0 -2
- package/dist/dts/errors/orphan/isOrphanFormError.d.ts +0 -2
- package/dist/dts/errors/output/consoleErrors.d.ts +0 -5
- package/dist/dts/errors/output/types.d.ts +0 -7
- package/dist/dts/errors/root/RootErrorsListFromFlatFieldErrorsContext.d.ts +0 -1
- package/dist/dts/errors/root/consts.d.ts +0 -1
- package/dist/dts/errors/root/getRootsFromFlatFieldErrors.d.ts +0 -1
- package/dist/dts/errors/root/isFlatFieldErrorEntryPathRoot.d.ts +0 -5
- package/dist/dts/errors/root/isFormErrorPathRoot.d.ts +0 -6
- package/dist/dts/errors/trpc/makeOnSubmitTrpcClientErrorHandler.d.ts +0 -9
- package/dist/dts/errors/trpc/trpcClientErrorMessageSchema.d.ts +0 -19
- package/dist/dts/errors/trpc/trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer.d.ts +0 -23
- package/dist/dts/form/RHF_UseFormReturnWithoutProxiesType.d.ts +0 -15
- package/dist/dts/form/RhfUtilsFormInjectorProps.d.ts +0 -17
- package/dist/dts/form/UseRhfUtilsFormChildrenPropsType.d.ts +0 -25
- package/dist/dts/form/_Controller.d.ts +0 -4
- package/dist/dts/form/context/utils/LastSubmitStateType.d.ts +0 -1
- package/dist/dts/form/context/utils/RhfUtilsContextProvider.d.ts +0 -9
- package/dist/dts/form/context/utils/RhfUtilsContextType.d.ts +0 -12
- package/dist/dts/form/context/utils/useRhfUtilsContext.d.ts +0 -5
- package/dist/dts/form/context/utils/useRhfUtilsContextRequestSubmit.d.ts +0 -4
- package/dist/dts/form/defaults/UseRhfUtilsFormGlobalDefaults.d.ts +0 -24
- package/dist/dts/form/defaults/UseRhfUtilsFormInstanceDefaults.d.ts +0 -18
- package/dist/dts/form/defaults/UseRhfUtilsFormResolvedDefaultsType.d.ts +0 -12
- package/dist/dts/form/defaults/form/UseRhfUtilsFormInstanceFormProps.d.ts +0 -6
- package/dist/dts/form/defaults/form/getRhfUtilsFormResolvedFormProps.d.ts +0 -2
- package/dist/dts/form/defaults/form/useRhfUtilsFormResolvedFormProps.d.ts +0 -293
- package/dist/dts/form/options/RhfUtilsFormOptionsType.d.ts +0 -27
- package/dist/dts/form/options/getRhfUtilsFormResolvedOptions.d.ts +0 -2
- package/dist/dts/form/options/useRhfUtilsFormResolvedOptions.d.ts +0 -8
- package/dist/dts/form/providers/RhfUtilsFormProviders.d.ts +0 -6
- package/dist/dts/form/providers/RhfUtilsFormProvidersPropsType.d.ts +0 -17
- package/dist/dts/form/relay/FormRelayOptions.d.ts +0 -16
- package/dist/dts/form/relay/context/FormRelayContextProvider.d.ts +0 -4
- package/dist/dts/form/relay/context/useFormRelayContext.d.ts +0 -12
- package/dist/dts/form/relay/context/utils.d.ts +0 -4
- package/dist/dts/form/relay/get/FormRelayGroupType.d.ts +0 -16
- package/dist/dts/form/relay/get/grouper/context/hooks.d.ts +0 -8
- package/dist/dts/form/relay/get/grouper/context/index.d.ts +0 -5
- package/dist/dts/form/relay/get/grouper/context/provider.d.ts +0 -9
- package/dist/dts/form/relay/get/grouper/useFirstFormStateGroup.d.ts +0 -9
- package/dist/dts/form/relay/get/useFormRelay.d.ts +0 -13
- package/dist/dts/form/relay/set/FormRelaySetter.d.ts +0 -6
- package/dist/dts/form/relay/set/useFormRelaySet.d.ts +0 -2
- package/dist/dts/form/relay/types.d.ts +0 -12
- package/dist/dts/form/rhf/SafeFieldValuesType.d.ts +0 -4
- package/dist/dts/form/rhf/UseFormPropsType.d.ts +0 -4
- package/dist/dts/form/rhf/getRhfUtilsFormResolvedRhfProps.d.ts +0 -4
- package/dist/dts/form/rhf/useRhfFormWithResolvedProps.d.ts +0 -5
- package/dist/dts/form/utils/getSubmitterButtonData.d.ts +0 -6
- package/dist/dts/form/utils/useFormRequestSubmit.d.ts +0 -9
- package/dist/dts/form/utils/useHandleCancelWithCheckIfCanBe.d.ts +0 -4
- package/dist/dts/form/utils/useHandleCancelWithCheckIfCanBeViaProviders.d.ts +0 -2
- package/dist/dts/form/utils/useShouldFormBlockNavigation.d.ts +0 -24
- package/dist/dts/form/with-handlers-and-children/RhfUtilsForm.d.ts +0 -3
- package/dist/dts/form/with-handlers-and-children/RhfUtilsFormProps.d.ts +0 -42
- package/dist/dts/form/with-handlers-and-children/RhfUtilsFormPropsOnBeforeSubmitInvariants.d.ts +0 -12
- package/dist/dts/form/with-handlers-and-children/_ChildrenViaProviders.d.ts +0 -3
- package/dist/dts/form/with-handlers-and-children/_FormWithSubmitHandler.d.ts +0 -4
- package/dist/dts/form/with-handlers-and-children/_useHandleSubmit.d.ts +0 -11
- package/dist/dts/form/with-providers/RhfUtilsFormWithProviders.d.ts +0 -8
- package/dist/dts/form/with-providers/RhfUtilsFormWithProvidersProps.d.ts +0 -8
- package/dist/dts/main.d.ts +0 -1
- package/dist/dts/resolvers/ObjectSchema.d.ts +0 -7
- package/dist/dts/resolvers/zod/RhfUtilsUseZodFormChildrenFCType.d.ts +0 -7
- package/dist/dts/resolvers/zod/RhfUtilsUseZodFormChildrenPropsType.d.ts +0 -4
- package/dist/dts/resolvers/zod/ZodTypeSafeFieldValuesType.d.ts +0 -5
- package/dist/dts/resolvers/zod/consts.d.ts +0 -4
- package/dist/dts/resolvers/zod/form/RhfUtilsZodForm.d.ts +0 -7
- package/dist/dts/resolvers/zod/getZodResolver.d.ts +0 -4
- package/dist/dts/resolvers/zod/providers/RhfUtilsZodFormProviders.d.ts +0 -8
- package/dist/dts/resolvers/zod/with-providers/RhfUtilsZodFormWithProviders.d.ts +0 -10
- package/dist/dts/submit/UseRhfUtilsFormOnSubmitContextType.d.ts +0 -23
- package/dist/dts/submit/error/FormSubmitError.d.ts +0 -6
- package/dist/dts/submit/error/FormSubmitFieldErrors.d.ts +0 -14
- package/dist/dts/submit/error/setCtxErrorsByFormSubmitFieldErrors.d.ts +0 -8
- package/dist/dts/submit/last-error/LastSubmitErrorContextProvider.d.ts +0 -4
- package/dist/dts/submit/last-error/LastSubmitErrorContextType.d.ts +0 -8
- package/dist/dts/submit/last-error/useLastSubmitError.d.ts +0 -4
- package/dist/dts/submit/last-error/useLastSubmitErrorContext.d.ts +0 -3
- package/dist/dts/submit/last-error/useLastSubmitErrorContextWith.d.ts +0 -2
- package/dist/dts/submit/useFormOnSubmitSuccessfulAndReset.d.ts +0 -13
- package/dist/dts/submit/useFormOnSubmitted.d.ts +0 -4
- package/dist/dts/submit/useResetFormOnSubmitted.d.ts +0 -35
- package/dist/dts/submit/useRhfUtilsFormOnSubmitContext.d.ts +0 -3
- package/dist/dts/submit/useSubmitFormOnChange.d.ts +0 -15
- package/dist/dts/submit/useSubmitFormOnEvent.d.ts +0 -9
- package/dist/dts/submit/useSubmitFormOnWatch.d.ts +0 -14
- package/dist/dts/utils/PassthroughChildren.d.ts +0 -7
- package/dist/dts/utils/createContext.d.ts +0 -10
- package/dist/dts/utils/fixedForwardRef.d.ts +0 -5
- package/dist/dts/utils/isEmptyObject.d.ts +0 -1
- package/dist/dts/utils/timeoutAsync.d.ts +0 -6
- package/dist/dts/utils/types.d.ts +0 -3
- package/dist/dts/utils/useDebouncedOnChangeValue.d.ts +0 -14
- package/dist/dts/utils/useImperativeForwardedRef.d.ts +0 -9
- package/dist/dts/utils/useIsFirstRender.d.ts +0 -7
- package/dist/dts/utils/useRefIfValueWasTrue.d.ts +0 -2
- package/dist/dts/utils/useToggle.d.ts +0 -2
- package/dist/dts/vite-env.d.ts +0 -1
- package/dist/esm/FormRelaySetter.mjs +0 -89
- package/dist/esm/index.mjs +0 -350
- package/dist/esm/relay.mjs +0 -49
- package/dist/esm/trpc.mjs +0 -24
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Integration and utility library for [react-hook-form](https://www.react-hook-for
|
|
|
9
9
|
- TypeScript-first
|
|
10
10
|
- global configuration (🔗 [`RhfUtilsClientConfig`](#config) section)
|
|
11
11
|
- RHF (`UseFormProps`) and utilities (`RhfUtilsFormOptions`) options defaults
|
|
12
|
-
- inject your own hooks and UI (`
|
|
12
|
+
- inject your own hooks and UI (`FormInjector`)
|
|
13
13
|
- server error transformation (`onSubmitErrorUnknown`) ✨
|
|
14
14
|
- handle cancel prompt (`useCanFormBeCancelled`) ✨
|
|
15
15
|
- RHF `FormState.errors` logging/throwing (`RhfUtilsClientConfig.fieldErrors`) ✨
|
|
@@ -76,7 +76,7 @@ export const rhfUtilsClientConfig: RhfUtilsClientConfig = {
|
|
|
76
76
|
|
|
77
77
|
// inject your own hooks and components
|
|
78
78
|
// into all RhfUtilsZodForm instances
|
|
79
|
-
|
|
79
|
+
FormInjector: (
|
|
80
80
|
// RhfUtilsFormInjectorProps
|
|
81
81
|
{
|
|
82
82
|
Outlet, // Form instance (RhfUtilsZodForm.Children) "outlet"
|
|
@@ -116,6 +116,7 @@ export const rhfUtilsClientConfig: RhfUtilsClientConfig = {
|
|
|
116
116
|
// (i.e., calling your own hook in `FormComponent`)
|
|
117
117
|
useCanFormBeCancelled: () => {
|
|
118
118
|
const { isDirty } = useFormState();
|
|
119
|
+
const myPrompter = useMyPrompter();
|
|
119
120
|
|
|
120
121
|
// return callback to be called at event-time
|
|
121
122
|
return ({ options }) =>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paragrav/rhf-utils",
|
|
3
3
|
"author": "paragrav.dev",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.66.0",
|
|
5
5
|
"description": "Integration utilities for react-hook-form.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -9,27 +9,11 @@
|
|
|
9
9
|
"dist/esm/*",
|
|
10
10
|
"dist/dts/*"
|
|
11
11
|
],
|
|
12
|
-
"module": "./dist/esm/index.mjs",
|
|
13
|
-
"types": "./dist/dts/_exports/types.d.ts",
|
|
14
12
|
"exports": {
|
|
15
|
-
".":
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"./relay": {
|
|
22
|
-
"import": {
|
|
23
|
-
"types": "./dist/dts/_exports/relay.d.ts",
|
|
24
|
-
"default": "./dist/esm/relay.mjs"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
"./trpc": {
|
|
28
|
-
"import": {
|
|
29
|
-
"types": "./dist/dts/_exports/trpc.d.ts",
|
|
30
|
-
"default": "./dist/esm/trpc.mjs"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
13
|
+
".": "./dist/tsdown/index.js",
|
|
14
|
+
"./relay": "./dist/tsdown/relay.js",
|
|
15
|
+
"./trpc": "./dist/tsdown/trpc.js",
|
|
16
|
+
"./package.json": "./package.json"
|
|
33
17
|
},
|
|
34
18
|
"publishConfig": {
|
|
35
19
|
"withoutPublish": true,
|
|
@@ -60,50 +44,53 @@
|
|
|
60
44
|
}
|
|
61
45
|
},
|
|
62
46
|
"devDependencies": {
|
|
63
|
-
"@eslint/compat": "^2.0
|
|
47
|
+
"@eslint/compat": "^2.1.0",
|
|
48
|
+
"@eslint/config-helpers": "^0.6.0",
|
|
64
49
|
"@eslint/eslintrc": "^3.3.5",
|
|
65
50
|
"@eslint/js": "^9.39.4",
|
|
66
|
-
"@playwright/experimental-ct-react": "^1.
|
|
67
|
-
"@playwright/test": "^1.
|
|
51
|
+
"@playwright/experimental-ct-react": "^1.60.0",
|
|
52
|
+
"@playwright/test": "^1.60.0",
|
|
68
53
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
69
|
-
"@types/node": "^24.
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "
|
|
71
|
-
"@typescript-eslint/parser": "
|
|
72
|
-
"@vitejs/plugin-react": "^6.0.
|
|
73
|
-
"clean-publish": "^
|
|
54
|
+
"@types/node": "^24.13.1",
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "8.61.0",
|
|
56
|
+
"@typescript-eslint/parser": "8.61.0",
|
|
57
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
58
|
+
"clean-publish": "^7.1.0",
|
|
74
59
|
"cross-env": "^10.1.0",
|
|
75
60
|
"eslint": "^9.39.4",
|
|
76
61
|
"eslint-config-prettier": "^10.1.8",
|
|
77
62
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
78
|
-
"eslint-import-resolver-typescript": "^4.4.
|
|
63
|
+
"eslint-import-resolver-typescript": "^4.4.5",
|
|
79
64
|
"eslint-plugin-import": "^2.32.0",
|
|
80
65
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
81
|
-
"eslint-plugin-prettier": "^5.5.
|
|
66
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
82
67
|
"eslint-plugin-react": "^7.37.5",
|
|
83
68
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
84
69
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
85
|
-
"eslint-plugin-simple-import-sort": "^
|
|
86
|
-
"globals": "^17.
|
|
87
|
-
"happy-dom": "^20.
|
|
70
|
+
"eslint-plugin-simple-import-sort": "^13.0.0",
|
|
71
|
+
"globals": "^17.6.0",
|
|
72
|
+
"happy-dom": "^20.10.2",
|
|
88
73
|
"husky": "^9.1.7",
|
|
89
|
-
"lint-staged": "^
|
|
90
|
-
"prettier": "^3.8.
|
|
91
|
-
"rollup": "^4.
|
|
74
|
+
"lint-staged": "^17.0.7",
|
|
75
|
+
"prettier": "^3.8.4",
|
|
76
|
+
"rollup": "^4.61.1",
|
|
92
77
|
"safe-stable-stringify": "^2.5.0",
|
|
93
|
-
"terser": "^5.
|
|
78
|
+
"terser": "^5.48.0",
|
|
79
|
+
"tsdown": "^0.22.2",
|
|
94
80
|
"typescript": "^6.0.3",
|
|
95
|
-
"typescript-eslint": "
|
|
96
|
-
"
|
|
97
|
-
"vite
|
|
98
|
-
"vitest": "^4.1.
|
|
81
|
+
"typescript-eslint": "8.61.0",
|
|
82
|
+
"unplugin-dts": "^1.0.2",
|
|
83
|
+
"vite": "^8.0.16",
|
|
84
|
+
"vitest": "^4.1.8"
|
|
99
85
|
},
|
|
100
86
|
"resolutions": {
|
|
87
|
+
"unrs-resolver": "1.11.1",
|
|
101
88
|
"eslint": "^9.39.4",
|
|
102
89
|
"@types/react": "^19.0.4",
|
|
103
90
|
"@types/react-dom": "^19.0.2",
|
|
104
91
|
"react": "^19.0.0",
|
|
105
92
|
"react-dom": "^19.0.0",
|
|
106
|
-
"typescript": "^6.0.
|
|
93
|
+
"typescript": "^6.0.3",
|
|
107
94
|
"vite": "^8.0.2"
|
|
108
95
|
},
|
|
109
96
|
"repository": {
|
|
@@ -125,7 +112,7 @@
|
|
|
125
112
|
"zod"
|
|
126
113
|
],
|
|
127
114
|
"scripts": {
|
|
128
|
-
"build": "tsc -b &&
|
|
115
|
+
"build": "tsc -b && tsdown",
|
|
129
116
|
"build:dev": "vite build --config vite.config.dev.ts",
|
|
130
117
|
"dev": "vite --config vite.config.dev.ts --force",
|
|
131
118
|
"lint": "eslint . --cache --cache-strategy content",
|
package/dist/dts/Register.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Use this to extend internal types.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```ts
|
|
6
|
-
* declare module '@paragrav/rhf-utils' {
|
|
7
|
-
* export interface Register {
|
|
8
|
-
* RhfUtilsFormOptions: {
|
|
9
|
-
* myCustomOption?: boolean;
|
|
10
|
-
* };
|
|
11
|
-
* }
|
|
12
|
-
* }
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions, @typescript-eslint/no-empty-object-type
|
|
16
|
-
export interface Register {}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { useFlatFieldErrorsContext } from '../errors/flat/context/useFlatFieldErrorsContext';
|
|
2
|
-
export { useFlatFieldErrorsContextHasOnlyOrphans } from '../errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans';
|
|
3
|
-
export { RhfUtilsNonFieldErrorMarker } from '../errors/nonfield/RhfUtilsNonFieldErrorMarker';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { useRhfUtilsContext } from '../form/context/utils/useRhfUtilsContext';
|
|
2
|
-
export type { RhfUtilsFormOptions } from '../form/options/RhfUtilsFormOptionsType';
|
|
3
|
-
export type { SafeFieldValues } from '../form/rhf/SafeFieldValuesType';
|
|
4
|
-
export type { RHF_UseFormReturnWithoutProxies as UseFormReturnWithoutProxies } from '../form/RHF_UseFormReturnWithoutProxiesType';
|
|
5
|
-
export type { RhfUtilsFormInjectorProps } from '../form/RhfUtilsFormInjectorProps';
|
|
6
|
-
export type { UseRhfUtilsFormChildrenProps } from '../form/UseRhfUtilsFormChildrenPropsType';
|
|
7
|
-
export { useFormRequestSubmit } from '../form/utils/useFormRequestSubmit';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license @paragrav/rhf-utils
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2024-present paragrav.dev
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/
|
|
9
|
-
export * from './config';
|
|
10
|
-
export * from './errors';
|
|
11
|
-
export * from './form';
|
|
12
|
-
export * from './submit';
|
|
13
|
-
export * from './zod';
|
|
14
|
-
export type { Register } from '../Register';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { FormRelayContextProvider } from '../form/relay/context/FormRelayContextProvider';
|
|
2
|
-
export type { FormRelayGroup } from '../form/relay/get/FormRelayGroupType';
|
|
3
|
-
export { useFirstFormStateGroup } from '../form/relay/get/grouper/useFirstFormStateGroup';
|
|
4
|
-
export { useFormRelayGroup, useFormRelayId, } from '../form/relay/get/useFormRelay';
|
|
5
|
-
export { FormRelaySetter } from '../form/relay/set/FormRelaySetter';
|
|
6
|
-
export { useFormRelaySet } from '../form/relay/set/useFormRelaySet';
|
|
7
|
-
export type { FormRelay, FormRelayStateSelected } from '../form/relay/types';
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { FormSubmitError } from '../submit/error/FormSubmitError';
|
|
2
|
-
export type { FormSubmitFieldErrors } from '../submit/error/FormSubmitFieldErrors';
|
|
3
|
-
export { useLastSubmitError } from '../submit/last-error/useLastSubmitError';
|
|
4
|
-
export type { UseRhfUtilsFormOnSubmitContext, UseRhfUtilsFormOnSubmitErrorContext, } from '../submit/UseRhfUtilsFormOnSubmitContextType';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { RhfUtilsZodForm } from '../resolvers/zod/form/RhfUtilsZodForm';
|
|
2
|
-
export { RhfUtilsZodFormProviders } from '../resolvers/zod/providers/RhfUtilsZodFormProviders';
|
|
3
|
-
export { RhfUtilsZodFormWithProviders } from '../resolvers/zod/with-providers/RhfUtilsZodFormWithProviders';
|
|
4
|
-
export type { RhfUtilsUseZodFormChildrenFC } from '../resolvers/zod/RhfUtilsUseZodFormChildrenFCType';
|
|
5
|
-
export type { RhfUtilsUseZodFormChildrenProps } from '../resolvers/zod/RhfUtilsUseZodFormChildrenPropsType';
|
|
6
|
-
export type { ZodTypeSafeFieldValues } from '../resolvers/zod/ZodTypeSafeFieldValuesType';
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { FlatFieldErrorsOutputConfig } from '../../errors/flat/context/FlatFieldErrorsOutputConfig';
|
|
2
|
-
import { UseRhfUtilsFormGlobalDefaults } from '../../form/defaults/UseRhfUtilsFormGlobalDefaults';
|
|
3
|
-
import { RhfUtilsFormInjectorProps } from '../../form/RhfUtilsFormInjectorProps';
|
|
4
|
-
import { FormSubmitFieldErrors } from '../../submit/error/FormSubmitFieldErrors';
|
|
5
|
-
import { UseRhfUtilsFormOnSubmitContext } from '../../submit/UseRhfUtilsFormOnSubmitContextType';
|
|
6
|
-
import { MaybePromise } from '../../utils/types';
|
|
7
|
-
/**
|
|
8
|
-
* Client configuration object.
|
|
9
|
-
*
|
|
10
|
-
* Options under `defaults` can be overridden at form level.
|
|
11
|
-
*/
|
|
12
|
-
export type RhfUtilsClientConfig = {
|
|
13
|
-
/**
|
|
14
|
-
* Default options for all forms. (Are overridden by form-specific options.)
|
|
15
|
-
*/
|
|
16
|
-
defaults?: UseRhfUtilsFormGlobalDefaults;
|
|
17
|
-
/**
|
|
18
|
-
* Supply your own `<form>` component.
|
|
19
|
-
*
|
|
20
|
-
* (By default, a native {@link HTMLFormElement} is used.)
|
|
21
|
-
*/
|
|
22
|
-
FormComponent?: React.FC<React.PropsWithChildren<React.HTMLAttributes<HTMLFormElement>>>;
|
|
23
|
-
/**
|
|
24
|
-
* Inject your own hooks, components, etc., into every form instance.
|
|
25
|
-
*
|
|
26
|
-
* @description
|
|
27
|
-
*
|
|
28
|
-
* (NOTE: context params are not schema-typed as not possible at this level.)
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
*
|
|
32
|
-
* See README.
|
|
33
|
-
*/
|
|
34
|
-
FormInjector?: React.FC<RhfUtilsFormInjectorProps>;
|
|
35
|
-
/**
|
|
36
|
-
* A hook that returns a callback that determines whether form can be cancelled at event-time.
|
|
37
|
-
*
|
|
38
|
-
* @description
|
|
39
|
-
*
|
|
40
|
-
* Cancellation of forms often doesn't involve navigation, making it more challenging to centrally handle.
|
|
41
|
-
* Your hook's returned callback should internally prompt user and return response as `boolean`
|
|
42
|
-
* indicating whether cancellation should be blocked. See `README.md` for example.
|
|
43
|
-
*
|
|
44
|
-
* @returns Callback that, given {@link RhfUtilsFormContext} at event-time, returns `boolean` value indicating whether form can be cancelled.
|
|
45
|
-
*
|
|
46
|
-
* Callback should return:
|
|
47
|
-
* `true`: if form can be cancelled (e.g., form not dirty or user confirmed via prompt); {@link UseRhfUtilsFormProps.onCancel} is called.
|
|
48
|
-
* `false`: form cannot be cancelled (e.g., user denied); {@link UseRhfUtilsFormProps.onCancel} is not called.
|
|
49
|
-
*/
|
|
50
|
-
useCanFormBeCancelled?: () => (props: UseRhfUtilsFormOnSubmitContext) => MaybePromise<boolean>;
|
|
51
|
-
/**
|
|
52
|
-
* Global submit error handler when/if submit handler throws an error other than {@link FormSubmitError}.
|
|
53
|
-
*
|
|
54
|
-
* Example use case:
|
|
55
|
-
* - transform API errors to {@link FormSubmitFieldErrors}.
|
|
56
|
-
*
|
|
57
|
-
* @returns
|
|
58
|
-
* - if {@link FormSubmitFieldErrors}: merge into context errors.
|
|
59
|
-
* - if `undefined`: do nothing.
|
|
60
|
-
*/
|
|
61
|
-
onSubmitErrorUnknown?: (error: unknown) => FormSubmitFieldErrors | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Configuration regarding RHF form state errors (`useFormContext().formState.errors`).
|
|
64
|
-
*/
|
|
65
|
-
fieldErrors?: {
|
|
66
|
-
/**
|
|
67
|
-
* Configure how/if errors should be outputted for debugging/reporting (i.e., console and/or throwing).
|
|
68
|
-
*/
|
|
69
|
-
output?: FlatFieldErrorsOutputConfig;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { RhfUtilsClientConfig } from '../RhfUtilsClientConfigType';
|
|
3
|
-
type Props = React.PropsWithChildren<{
|
|
4
|
-
config?: RhfUtilsClientConfig;
|
|
5
|
-
}>;
|
|
6
|
-
export declare const RhfUtilsClientConfigProvider: React.FC<Props>;
|
|
7
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useRhfUtilsClientConfig: () => import('../RhfUtilsClientConfigType').RhfUtilsClientConfig;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { DevtoolUIProps } from '@hookform/devtools/dist/devToolUI';
|
|
2
|
-
import { default as React } from 'react';
|
|
3
|
-
type LazyDevToolProps = {
|
|
4
|
-
config?: boolean | Pick<DevtoolUIProps, 'placement' | 'styles'>;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Lazy-loaded RHF DevTool.
|
|
8
|
-
*/
|
|
9
|
-
export declare const LazyDevTool: React.FC<LazyDevToolProps>;
|
|
10
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const LazyDevToolViaProviders: React.FC;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
type Props = React.PropsWithChildren<{
|
|
3
|
-
formRef: React.RefObject<HTMLFormElement | null>;
|
|
4
|
-
}>;
|
|
5
|
-
/**
|
|
6
|
-
* Provides a flattened version of the form errors.
|
|
7
|
-
* Allows flattening and filtering to happen once per errors change.
|
|
8
|
-
*/
|
|
9
|
-
export declare const FlatFieldErrorsContextProvider: React.FC<Props>;
|
|
10
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { RhfUtilsErrorsOutputConsoleConfig } from '../../output/types';
|
|
2
|
-
import { FlatFieldErrorsContext } from './useFlatFieldErrorsContext';
|
|
3
|
-
export type FlatFieldErrorsOutputConfig = {
|
|
4
|
-
/**
|
|
5
|
-
* Configure how/if errors should be outputted to console.
|
|
6
|
-
*
|
|
7
|
-
* Example use cases:
|
|
8
|
-
* - console.debug errors in development environment.
|
|
9
|
-
* - console.error certain errors in production environment.
|
|
10
|
-
*/
|
|
11
|
-
console?: (context: FlatFieldErrorsContext) => RhfUtilsErrorsOutputConsoleConfig | null | false | undefined;
|
|
12
|
-
/**
|
|
13
|
-
* Configure how/if errors should be thrown.
|
|
14
|
-
*
|
|
15
|
-
* Example use case:
|
|
16
|
-
* - bring attention to certain errors in development environment.
|
|
17
|
-
*/
|
|
18
|
-
throw?: (context: FlatFieldErrorsContext) => true | string | false | undefined;
|
|
19
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { FlatFieldErrors } from '../types';
|
|
2
|
-
export type FlatFieldErrorsContext = {
|
|
3
|
-
all: FlatFieldErrors;
|
|
4
|
-
fields: FlatFieldErrors;
|
|
5
|
-
roots: FlatFieldErrors;
|
|
6
|
-
orphans: FlatFieldErrors;
|
|
7
|
-
hasErrors: boolean;
|
|
8
|
-
hasOrphans: boolean;
|
|
9
|
-
};
|
|
10
|
-
declare const _FormErrorsFlatContextProvider: import('react').Provider<FlatFieldErrorsContext | undefined>, useFlatFieldErrorsContext: () => FlatFieldErrorsContext;
|
|
11
|
-
export { _FormErrorsFlatContextProvider, useFlatFieldErrorsContext };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { FlatFieldErrorEntry, FlatFieldErrors } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Filter {@link FlatFieldErrors} by a predicate.
|
|
4
|
-
*
|
|
5
|
-
* (Encapsulates to and from Object entries.)
|
|
6
|
-
*/
|
|
7
|
-
export declare const makeFlatFieldErrorsFilter: (predicate: (entry: FlatFieldErrorEntry, index: number) => boolean) => (errors: FlatFieldErrors) => FlatFieldErrors;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { FieldErrors } from 'react-hook-form';
|
|
2
|
-
/**
|
|
3
|
-
* Flatten a {@link FieldErrors} object.
|
|
4
|
-
*
|
|
5
|
-
* @returns e.g.,
|
|
6
|
-
* ```ts
|
|
7
|
-
* {
|
|
8
|
-
* "address.street.type": "too_short",
|
|
9
|
-
* "address.street.ref.value": "123",
|
|
10
|
-
* "address.street.message": "Required."
|
|
11
|
-
* }
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
export declare const flattenFieldErrors: (errors: FieldErrors) => Record<string, unknown>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { FieldError, FieldErrors } from 'react-hook-form';
|
|
2
|
-
import { SafeFieldValues } from '../../form/rhf/SafeFieldValuesType';
|
|
3
|
-
import { FlatFieldErrors } from './types';
|
|
4
|
-
/**
|
|
5
|
-
* Get {@link FlatFieldErrors} from {@link FieldErrors}.
|
|
6
|
-
* This makes it easy to work with potentially deeply-nested {@link FieldErrors}.
|
|
7
|
-
*
|
|
8
|
-
* @param errors {@link FieldErrors} object.
|
|
9
|
-
*
|
|
10
|
-
* @returns `FlatFieldErrors` object.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```
|
|
14
|
-
* {
|
|
15
|
-
* "address.street": {
|
|
16
|
-
* type: "too_short",
|
|
17
|
-
* ref: { value: "123" },
|
|
18
|
-
* message: "Required." }
|
|
19
|
-
* }
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare const getFlatFieldErrors: (errors: FieldErrors) => FlatFieldErrors;
|
|
24
|
-
/**
|
|
25
|
-
* Regular expression to maybe match the end of a leaf node path.
|
|
26
|
-
*
|
|
27
|
-
* i.e., `name.type`, `address.street.message`
|
|
28
|
-
*
|
|
29
|
-
* iow: dot [?: non-capturing]("type" | "message")[\b word boundary][$ end of string]
|
|
30
|
-
*/
|
|
31
|
-
export declare const regexMaybeFieldErrorLeafNodeSuffix: RegExp;
|
|
32
|
-
export type FieldErrorsSansRef<TFieldValues extends SafeFieldValues = SafeFieldValues> = Record<keyof TFieldValues | 'root', Partial<Pick<FieldError, 'message' | 'type'>> & {
|
|
33
|
-
hasRef: boolean;
|
|
34
|
-
}>;
|
|
35
|
-
export declare const getFlatFieldErrorsSansRef: <TFieldValues extends SafeFieldValues>(errors: FieldErrors<TFieldValues>) => FieldErrorsSansRef<TFieldValues>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FieldError } from 'react-hook-form';
|
|
2
|
-
/**
|
|
3
|
-
* Flattened field errors object.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* {
|
|
8
|
-
* 'address.street': FieldError
|
|
9
|
-
* }
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export type FlatFieldErrors = Record<string, FieldError>;
|
|
13
|
-
/**
|
|
14
|
-
* Return from `Object.entries` on {@link FlatFieldErrors}.
|
|
15
|
-
*/
|
|
16
|
-
export type FlatFieldErrorEntry = [path: string, error: FieldError];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getRefdFromFlatFieldErrors: (errors: import('./flat/types').FlatFieldErrors) => import('./flat/types').FlatFieldErrors;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type Props = {
|
|
2
|
-
/** Field name as flat path. (e.g., "address.street") */
|
|
3
|
-
path: string;
|
|
4
|
-
/** Optional component to use to display message. (Defaults to {@link FormErrorMessage}) */
|
|
5
|
-
Component?: React.FC<{
|
|
6
|
-
message: string;
|
|
7
|
-
}>;
|
|
8
|
-
};
|
|
9
|
-
export declare const RhfUtilsFieldErrorMessage: React.FC<Props>;
|
|
10
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
type Props = {
|
|
2
|
-
/** Flat field name. (e.g., `address.street`) */
|
|
3
|
-
path: string;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Empty, hidden marker to indicate a non-field/non-root error is being displayed to user.
|
|
7
|
-
*
|
|
8
|
-
* Example use case:
|
|
9
|
-
* Field array with minimum items.
|
|
10
|
-
* (When there are no items, the error is not associated with a field and is displayed separately.)
|
|
11
|
-
*/
|
|
12
|
-
export declare const RhfUtilsNonFieldErrorMarker: React.FC<Props>;
|
|
13
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns query selector for matching non-field error marker.
|
|
3
|
-
* By default includes nested field matching. (See `options.excludeNested`.)
|
|
4
|
-
*
|
|
5
|
-
* @returns One or more selectors in a comma-separated list.
|
|
6
|
-
*/
|
|
7
|
-
export declare const getRhfUtilsNonFieldErrorMarkerQuerySelector: (path: string, options?: {
|
|
8
|
-
/**
|
|
9
|
-
* Do not look for match as nested field.
|
|
10
|
-
*
|
|
11
|
-
* By default this is enabled to facilitate looking for fields that may be nested inside objects.
|
|
12
|
-
* This is only a problem when a front-end field is nested more deeply than back-end.
|
|
13
|
-
* For example, field arrays require objects as items, so actual field may be `field.value`.
|
|
14
|
-
* This should be safe, as fields are by definition leaf nodes, so will not have nested fields.
|
|
15
|
-
* (If this check should need to be more precise in the future, it may be ideal to distinguish between client/server errors or paths.)
|
|
16
|
-
*/
|
|
17
|
-
excludeNested?: boolean;
|
|
18
|
-
}) => string;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { FieldError } from 'react-hook-form';
|
|
2
|
-
/**
|
|
3
|
-
* Determine if {@link FieldError} is a non-field error (i.e., has no `ref`).
|
|
4
|
-
*
|
|
5
|
-
* A non-field error has no association to an input via {@link FieldError.ref}.
|
|
6
|
-
*
|
|
7
|
-
* These fall into one of two categories:
|
|
8
|
-
* - Root, which are typically displayed to user at bottom/top of form.
|
|
9
|
-
* - Non-root, which fall into two main sub-sets:
|
|
10
|
-
* - Non-orphan (displayed -- typically manually)
|
|
11
|
-
* - e.g., array min/max validation
|
|
12
|
-
* - Orphan (undisplayed), which are typically caused by one of the following cases:
|
|
13
|
-
* - The input is missing.
|
|
14
|
-
* - The schema is incorrect.
|
|
15
|
-
* - The error is not displayed to user with `FormErrorNonFieldMarker`.
|
|
16
|
-
*/
|
|
17
|
-
export declare const isNonFieldError: (error: FieldError) => boolean;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { FlatFieldErrorEntry } from '../flat/types';
|
|
2
|
-
/**
|
|
3
|
-
* Util wrapper for {@link isOrphanFormError} for usage with {@link FlatFieldErrorEntry}.
|
|
4
|
-
*/
|
|
5
|
-
export declare const getIsFlatFieldErrorEntryOrphanByParentElement: (parentElement: Pick<HTMLElement, "querySelector">) => ([path, error]: FlatFieldErrorEntry) => boolean;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { SafeFieldValues } from '../../form/rhf/SafeFieldValuesType';
|
|
2
|
-
/**
|
|
3
|
-
* Output form values and errors to console.
|
|
4
|
-
*/
|
|
5
|
-
export declare const consoleErrors: (message: string, values: SafeFieldValues, errors: Record<string, unknown>, type?: "debug" | "error") => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const RootErrorsListFromFlatFieldErrorsContext: React.FC;
|