@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.
Files changed (144) hide show
  1. package/README.md +3 -2
  2. package/package.json +31 -44
  3. package/dist/dts/Register.d.ts +0 -16
  4. package/dist/dts/_exports/config.d.ts +0 -2
  5. package/dist/dts/_exports/errors.d.ts +0 -3
  6. package/dist/dts/_exports/form.d.ts +0 -7
  7. package/dist/dts/_exports/index.d.ts +0 -14
  8. package/dist/dts/_exports/relay.d.ts +0 -7
  9. package/dist/dts/_exports/submit.d.ts +0 -4
  10. package/dist/dts/_exports/trpc.d.ts +0 -2
  11. package/dist/dts/_exports/types.d.ts +0 -7
  12. package/dist/dts/_exports/zod.d.ts +0 -6
  13. package/dist/dts/client/config/RhfUtilsClientConfigType.d.ts +0 -71
  14. package/dist/dts/client/config/context/RhfUtilsClientConfigContext.d.ts +0 -3
  15. package/dist/dts/client/config/context/RhfUtilsClientConfigProvider.d.ts +0 -7
  16. package/dist/dts/client/config/context/useRhfUtilsClientConfig.d.ts +0 -1
  17. package/dist/dts/devtool/LazyDevTool.d.ts +0 -10
  18. package/dist/dts/devtool/LazyDevToolViaProviders.d.ts +0 -1
  19. package/dist/dts/errors/flat/FlatFieldErrorsList.d.ts +0 -6
  20. package/dist/dts/errors/flat/context/FlatFieldErrorsContextProvider.d.ts +0 -10
  21. package/dist/dts/errors/flat/context/FlatFieldErrorsOutputConfig.d.ts +0 -19
  22. package/dist/dts/errors/flat/context/useFlatFieldErrorsContext.d.ts +0 -11
  23. package/dist/dts/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.d.ts +0 -6
  24. package/dist/dts/errors/flat/context/useFlatFieldErrorsContextOutput.d.ts +0 -5
  25. package/dist/dts/errors/flat/filterFlatFieldErrors.d.ts +0 -7
  26. package/dist/dts/errors/flat/flattenFieldErrors.d.ts +0 -14
  27. package/dist/dts/errors/flat/getFlatFieldErrors.d.ts +0 -35
  28. package/dist/dts/errors/flat/types.d.ts +0 -16
  29. package/dist/dts/errors/getRefdFromFlatFieldErrors.d.ts +0 -1
  30. package/dist/dts/errors/isFieldErrorRefd.d.ts +0 -5
  31. package/dist/dts/errors/isFlatFieldErrorEntryRefd.d.ts +0 -5
  32. package/dist/dts/errors/message/FormErrorMessage.d.ts +0 -7
  33. package/dist/dts/errors/message/RhfUtilsFieldErrorMessage.d.ts +0 -10
  34. package/dist/dts/errors/nonfield/RhfUtilsNonFieldErrorMarker.d.ts +0 -13
  35. package/dist/dts/errors/nonfield/RhfUtilsNonFieldErrorMarker.spec.d.ts +0 -1
  36. package/dist/dts/errors/nonfield/RhfUtilsNonFieldErrorMarker.utils.d.ts +0 -18
  37. package/dist/dts/errors/nonfield/RhfUtilsNonFieldErrorMarkerHtmlAttribute.d.ts +0 -4
  38. package/dist/dts/errors/nonfield/isNonFieldError.d.ts +0 -17
  39. package/dist/dts/errors/nonfield/isNonFieldErrorMarkerInDOM.d.ts +0 -5
  40. package/dist/dts/errors/orphan/getIsOrphanFormErrorWithParentElement.d.ts +0 -5
  41. package/dist/dts/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +0 -2
  42. package/dist/dts/errors/orphan/isOrphanFormError.d.ts +0 -2
  43. package/dist/dts/errors/output/consoleErrors.d.ts +0 -5
  44. package/dist/dts/errors/output/types.d.ts +0 -7
  45. package/dist/dts/errors/root/RootErrorsListFromFlatFieldErrorsContext.d.ts +0 -1
  46. package/dist/dts/errors/root/consts.d.ts +0 -1
  47. package/dist/dts/errors/root/getRootsFromFlatFieldErrors.d.ts +0 -1
  48. package/dist/dts/errors/root/isFlatFieldErrorEntryPathRoot.d.ts +0 -5
  49. package/dist/dts/errors/root/isFormErrorPathRoot.d.ts +0 -6
  50. package/dist/dts/errors/trpc/makeOnSubmitTrpcClientErrorHandler.d.ts +0 -9
  51. package/dist/dts/errors/trpc/trpcClientErrorMessageSchema.d.ts +0 -19
  52. package/dist/dts/errors/trpc/trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer.d.ts +0 -23
  53. package/dist/dts/form/RHF_UseFormReturnWithoutProxiesType.d.ts +0 -15
  54. package/dist/dts/form/RhfUtilsFormInjectorProps.d.ts +0 -17
  55. package/dist/dts/form/UseRhfUtilsFormChildrenPropsType.d.ts +0 -25
  56. package/dist/dts/form/_Controller.d.ts +0 -4
  57. package/dist/dts/form/context/utils/LastSubmitStateType.d.ts +0 -1
  58. package/dist/dts/form/context/utils/RhfUtilsContextProvider.d.ts +0 -9
  59. package/dist/dts/form/context/utils/RhfUtilsContextType.d.ts +0 -12
  60. package/dist/dts/form/context/utils/useRhfUtilsContext.d.ts +0 -5
  61. package/dist/dts/form/context/utils/useRhfUtilsContextRequestSubmit.d.ts +0 -4
  62. package/dist/dts/form/defaults/UseRhfUtilsFormGlobalDefaults.d.ts +0 -24
  63. package/dist/dts/form/defaults/UseRhfUtilsFormInstanceDefaults.d.ts +0 -18
  64. package/dist/dts/form/defaults/UseRhfUtilsFormResolvedDefaultsType.d.ts +0 -12
  65. package/dist/dts/form/defaults/form/UseRhfUtilsFormInstanceFormProps.d.ts +0 -6
  66. package/dist/dts/form/defaults/form/getRhfUtilsFormResolvedFormProps.d.ts +0 -2
  67. package/dist/dts/form/defaults/form/useRhfUtilsFormResolvedFormProps.d.ts +0 -293
  68. package/dist/dts/form/options/RhfUtilsFormOptionsType.d.ts +0 -27
  69. package/dist/dts/form/options/getRhfUtilsFormResolvedOptions.d.ts +0 -2
  70. package/dist/dts/form/options/useRhfUtilsFormResolvedOptions.d.ts +0 -8
  71. package/dist/dts/form/providers/RhfUtilsFormProviders.d.ts +0 -6
  72. package/dist/dts/form/providers/RhfUtilsFormProvidersPropsType.d.ts +0 -17
  73. package/dist/dts/form/relay/FormRelayOptions.d.ts +0 -16
  74. package/dist/dts/form/relay/context/FormRelayContextProvider.d.ts +0 -4
  75. package/dist/dts/form/relay/context/useFormRelayContext.d.ts +0 -12
  76. package/dist/dts/form/relay/context/utils.d.ts +0 -4
  77. package/dist/dts/form/relay/get/FormRelayGroupType.d.ts +0 -16
  78. package/dist/dts/form/relay/get/grouper/context/hooks.d.ts +0 -8
  79. package/dist/dts/form/relay/get/grouper/context/index.d.ts +0 -5
  80. package/dist/dts/form/relay/get/grouper/context/provider.d.ts +0 -9
  81. package/dist/dts/form/relay/get/grouper/useFirstFormStateGroup.d.ts +0 -9
  82. package/dist/dts/form/relay/get/useFormRelay.d.ts +0 -13
  83. package/dist/dts/form/relay/set/FormRelaySetter.d.ts +0 -6
  84. package/dist/dts/form/relay/set/useFormRelaySet.d.ts +0 -2
  85. package/dist/dts/form/relay/types.d.ts +0 -12
  86. package/dist/dts/form/rhf/SafeFieldValuesType.d.ts +0 -4
  87. package/dist/dts/form/rhf/UseFormPropsType.d.ts +0 -4
  88. package/dist/dts/form/rhf/getRhfUtilsFormResolvedRhfProps.d.ts +0 -4
  89. package/dist/dts/form/rhf/useRhfFormWithResolvedProps.d.ts +0 -5
  90. package/dist/dts/form/utils/getSubmitterButtonData.d.ts +0 -6
  91. package/dist/dts/form/utils/useFormRequestSubmit.d.ts +0 -9
  92. package/dist/dts/form/utils/useHandleCancelWithCheckIfCanBe.d.ts +0 -4
  93. package/dist/dts/form/utils/useHandleCancelWithCheckIfCanBeViaProviders.d.ts +0 -2
  94. package/dist/dts/form/utils/useShouldFormBlockNavigation.d.ts +0 -24
  95. package/dist/dts/form/with-handlers-and-children/RhfUtilsForm.d.ts +0 -3
  96. package/dist/dts/form/with-handlers-and-children/RhfUtilsFormProps.d.ts +0 -42
  97. package/dist/dts/form/with-handlers-and-children/RhfUtilsFormPropsOnBeforeSubmitInvariants.d.ts +0 -12
  98. package/dist/dts/form/with-handlers-and-children/_ChildrenViaProviders.d.ts +0 -3
  99. package/dist/dts/form/with-handlers-and-children/_FormWithSubmitHandler.d.ts +0 -4
  100. package/dist/dts/form/with-handlers-and-children/_useHandleSubmit.d.ts +0 -11
  101. package/dist/dts/form/with-providers/RhfUtilsFormWithProviders.d.ts +0 -8
  102. package/dist/dts/form/with-providers/RhfUtilsFormWithProvidersProps.d.ts +0 -8
  103. package/dist/dts/main.d.ts +0 -1
  104. package/dist/dts/resolvers/ObjectSchema.d.ts +0 -7
  105. package/dist/dts/resolvers/zod/RhfUtilsUseZodFormChildrenFCType.d.ts +0 -7
  106. package/dist/dts/resolvers/zod/RhfUtilsUseZodFormChildrenPropsType.d.ts +0 -4
  107. package/dist/dts/resolvers/zod/ZodTypeSafeFieldValuesType.d.ts +0 -5
  108. package/dist/dts/resolvers/zod/consts.d.ts +0 -4
  109. package/dist/dts/resolvers/zod/form/RhfUtilsZodForm.d.ts +0 -7
  110. package/dist/dts/resolvers/zod/getZodResolver.d.ts +0 -4
  111. package/dist/dts/resolvers/zod/providers/RhfUtilsZodFormProviders.d.ts +0 -8
  112. package/dist/dts/resolvers/zod/with-providers/RhfUtilsZodFormWithProviders.d.ts +0 -10
  113. package/dist/dts/submit/UseRhfUtilsFormOnSubmitContextType.d.ts +0 -23
  114. package/dist/dts/submit/error/FormSubmitError.d.ts +0 -6
  115. package/dist/dts/submit/error/FormSubmitFieldErrors.d.ts +0 -14
  116. package/dist/dts/submit/error/setCtxErrorsByFormSubmitFieldErrors.d.ts +0 -8
  117. package/dist/dts/submit/last-error/LastSubmitErrorContextProvider.d.ts +0 -4
  118. package/dist/dts/submit/last-error/LastSubmitErrorContextType.d.ts +0 -8
  119. package/dist/dts/submit/last-error/useLastSubmitError.d.ts +0 -4
  120. package/dist/dts/submit/last-error/useLastSubmitErrorContext.d.ts +0 -3
  121. package/dist/dts/submit/last-error/useLastSubmitErrorContextWith.d.ts +0 -2
  122. package/dist/dts/submit/useFormOnSubmitSuccessfulAndReset.d.ts +0 -13
  123. package/dist/dts/submit/useFormOnSubmitted.d.ts +0 -4
  124. package/dist/dts/submit/useResetFormOnSubmitted.d.ts +0 -35
  125. package/dist/dts/submit/useRhfUtilsFormOnSubmitContext.d.ts +0 -3
  126. package/dist/dts/submit/useSubmitFormOnChange.d.ts +0 -15
  127. package/dist/dts/submit/useSubmitFormOnEvent.d.ts +0 -9
  128. package/dist/dts/submit/useSubmitFormOnWatch.d.ts +0 -14
  129. package/dist/dts/utils/PassthroughChildren.d.ts +0 -7
  130. package/dist/dts/utils/createContext.d.ts +0 -10
  131. package/dist/dts/utils/fixedForwardRef.d.ts +0 -5
  132. package/dist/dts/utils/isEmptyObject.d.ts +0 -1
  133. package/dist/dts/utils/timeoutAsync.d.ts +0 -6
  134. package/dist/dts/utils/types.d.ts +0 -3
  135. package/dist/dts/utils/useDebouncedOnChangeValue.d.ts +0 -14
  136. package/dist/dts/utils/useImperativeForwardedRef.d.ts +0 -9
  137. package/dist/dts/utils/useIsFirstRender.d.ts +0 -7
  138. package/dist/dts/utils/useRefIfValueWasTrue.d.ts +0 -2
  139. package/dist/dts/utils/useToggle.d.ts +0 -2
  140. package/dist/dts/vite-env.d.ts +0 -1
  141. package/dist/esm/FormRelaySetter.mjs +0 -89
  142. package/dist/esm/index.mjs +0 -350
  143. package/dist/esm/relay.mjs +0 -49
  144. 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 (`FormChildren`)
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
- FormChildren: (
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.64.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
- "import": {
17
- "types": "./dist/dts/_exports/index.d.ts",
18
- "default": "./dist/esm/index.mjs"
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.5",
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.59.1",
67
- "@playwright/test": "^1.59.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.12.2",
70
- "@typescript-eslint/eslint-plugin": "^8.59.0",
71
- "@typescript-eslint/parser": "^8.59.0",
72
- "@vitejs/plugin-react": "^6.0.1",
73
- "clean-publish": "^6.0.5",
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.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.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": "^12.1.1",
86
- "globals": "^17.5.0",
87
- "happy-dom": "^20.9.0",
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": "^16.4.0",
90
- "prettier": "^3.8.3",
91
- "rollup": "^4.60.2",
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.46.2",
78
+ "terser": "^5.48.0",
79
+ "tsdown": "^0.22.2",
94
80
  "typescript": "^6.0.3",
95
- "typescript-eslint": "^8.59.0",
96
- "vite": "^8.0.10",
97
- "vite-plugin-dts": "^4.5.4",
98
- "vitest": "^4.1.5"
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.2",
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 && vite build",
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",
@@ -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,2 +0,0 @@
1
- export { RhfUtilsClientConfigProvider } from '../client/config/context/RhfUtilsClientConfigProvider';
2
- export type { RhfUtilsClientConfig } from '../client/config/RhfUtilsClientConfigType';
@@ -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,2 +0,0 @@
1
- export { makeOnSubmitTrpcClientErrorHandler } from '../errors/trpc/makeOnSubmitTrpcClientErrorHandler';
2
- export { trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer } from '../errors/trpc/trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer';
@@ -1,7 +0,0 @@
1
- export type * from './errors';
2
- export type * from './form';
3
- export type * from './relay';
4
- export type * from './submit';
5
- export type * from './trpc';
6
- export type * from './zod';
7
- export type { FlatFieldErrors } from '../errors/flat/types';
@@ -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,3 +0,0 @@
1
- import { default as React } from 'react';
2
- import { RhfUtilsClientConfig } from '../RhfUtilsClientConfigType';
3
- export declare const RhfUtilsClientConfigContext_Internal: React.Context<RhfUtilsClientConfig | undefined>;
@@ -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,6 +0,0 @@
1
- import { FlatFieldErrors } from './types';
2
- export type Props = {
3
- errors: FlatFieldErrors | null | undefined;
4
- className?: string;
5
- };
6
- export declare const FlatFieldErrorsList: React.FC<Props>;
@@ -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,6 +0,0 @@
1
- /**
2
- * Returns `true` if all errors are orphans.
3
- *
4
- * You may want to treat this case specifically.
5
- */
6
- export declare const useFlatFieldErrorsContextHasOnlyOrphans: () => boolean;
@@ -1,5 +0,0 @@
1
- import { FlatFieldErrorsOutputConfig } from './FlatFieldErrorsOutputConfig';
2
- /**
3
- * Outputs (e.g., console, throw) errors based on config.
4
- */
5
- export declare const useFlatFieldErrorsContextOutput: (config?: FlatFieldErrorsOutputConfig) => void;
@@ -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,5 +0,0 @@
1
- import { FieldError } from 'react-hook-form';
2
- /**
3
- * Determine if {@link FieldError} is a `ref`'d field error.
4
- */
5
- export declare const isFieldErrorRefd: (error: FieldError) => boolean;
@@ -1,5 +0,0 @@
1
- import { FlatFieldErrorEntry } from './flat/types';
2
- /**
3
- * Determine if {@link FieldError} is a `ref`'d field error.
4
- */
5
- export declare const isFlatFieldErrorEntryRefd: ([, error,]: FlatFieldErrorEntry) => boolean;
@@ -1,7 +0,0 @@
1
- import { default as React } from 'react';
2
- type Props = {
3
- message: string;
4
- className?: string;
5
- };
6
- export declare const FormErrorMessage: React.FC<Props>;
7
- export {};
@@ -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,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,4 +0,0 @@
1
- /**
2
- * HTML data attribute for {@link RhfUtilsNonFieldErrorMarker}.
3
- */
4
- export declare const RhfUtilsNonFieldErrorMarkerHtmlAttribute = "data-rhfutils-nonfield-error-marker-path";
@@ -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
- /**
2
- * Determine if a non-field error marker is in the DOM.
3
- * Note: this will also look for nested markers to accommodate field arrays
4
- */
5
- export declare const isNonFieldErrorMarkerInDOM: (path: string, parentElement: Pick<HTMLElement, "querySelector">) => 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,2 +0,0 @@
1
- import { FlatFieldErrors } from '../flat/types';
2
- export declare const getOrphansFromFlatFieldErrors: (errors: FlatFieldErrors, parentElement: Pick<HTMLElement, "querySelector">) => FlatFieldErrors;
@@ -1,2 +0,0 @@
1
- import { FieldError } from 'react-hook-form';
2
- export declare const isOrphanFormError: (path: string, error: FieldError, parentElement: Pick<HTMLElement, "querySelector">) => 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,7 +0,0 @@
1
- /**
2
- * Config object for error output.
3
- */
4
- export type RhfUtilsErrorsOutputConsoleConfig = {
5
- type?: 'debug' | 'error';
6
- message?: string;
7
- };
@@ -1 +0,0 @@
1
- export declare const RootErrorsListFromFlatFieldErrorsContext: React.FC;