@paragrav/rhf-utils 0.0.140 → 0.0.142

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 (108) hide show
  1. package/README.md +2 -2
  2. package/dist/types/_exports/group.d.ts +9 -0
  3. package/dist/types/_exports/index.d.ts +15 -0
  4. package/dist/types/_exports/main.d.ts +15 -0
  5. package/dist/types/_exports/trpc.d.ts +2 -0
  6. package/dist/types/_exports/utils.d.ts +1 -0
  7. package/dist/types/client/config/RhfUtilsClientConfig.d.ts +71 -0
  8. package/dist/types/client/config/useRhfUtilsClientConfigContext.d.ts +5 -0
  9. package/dist/types/client/context.d.ts +3 -0
  10. package/dist/types/client/index.d.ts +30 -0
  11. package/dist/types/client/utils.d.ts +13 -0
  12. package/dist/types/client/zod/RhfUtilsUseFormChildrenZodFC.d.ts +13 -0
  13. package/dist/types/client/zod/RhfUtilsUseFormChildrenZodProps.d.ts +5 -0
  14. package/dist/types/client/zod/ZodTypeFieldValues.d.ts +4 -0
  15. package/dist/types/client/zod/consts.d.ts +4 -0
  16. package/dist/types/client/zod/context/RhfUtilsClientForZodContextProvider.d.ts +8 -0
  17. package/dist/types/client/zod/context/RhfUtilsZodForm.d.ts +9 -0
  18. package/dist/types/client/zod/context/useRhfUtilsClientForZodContext.d.ts +6 -0
  19. package/dist/types/client/zod/context/useRhfUtilsZodForm.d.ts +8 -0
  20. package/dist/types/client/zod/createRhfUtilsClientForZod.d.ts +4 -0
  21. package/dist/types/devtool/LazyDevTool.d.ts +12 -0
  22. package/dist/types/errors/flat/FlatFieldErrorsList.d.ts +7 -0
  23. package/dist/types/errors/flat/context/FlatFieldErrorsContextProvider.d.ts +11 -0
  24. package/dist/types/errors/flat/context/FlatFieldErrorsOutputConfig.d.ts +20 -0
  25. package/dist/types/errors/flat/context/useFlatFieldErrorsContext.d.ts +13 -0
  26. package/dist/types/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.d.ts +7 -0
  27. package/dist/types/errors/flat/context/useFlatFieldErrorsContextOutput.d.ts +7 -0
  28. package/dist/types/errors/flat/filterFlatFieldErrors.d.ts +9 -0
  29. package/dist/types/errors/flat/flattenFieldErrors.d.ts +16 -0
  30. package/dist/types/errors/flat/getFlatFieldErrors.d.ts +31 -0
  31. package/dist/types/errors/flat/types.d.ts +17 -0
  32. package/dist/types/errors/getRefdFromFlatFieldErrors.d.ts +2 -0
  33. package/dist/types/errors/isFieldErrorRefd.d.ts +7 -0
  34. package/dist/types/errors/isFlatFieldErrorEntryRefd.d.ts +7 -0
  35. package/dist/types/errors/message/FormErrorMessage.d.ts +8 -0
  36. package/dist/types/errors/message/RhfUtilsFieldErrorMessage.d.ts +10 -0
  37. package/dist/types/errors/nonfield/RhfUtilsNonFieldErrorMarker.d.ts +13 -0
  38. package/dist/types/errors/nonfield/RhfUtilsNonFieldErrorMarker.spec.d.ts +1 -0
  39. package/dist/types/errors/nonfield/RhfUtilsNonFieldErrorMarker.utils.d.ts +18 -0
  40. package/dist/types/errors/nonfield/RhfUtilsNonFieldErrorMarkerHtmlAttribute.d.ts +5 -0
  41. package/dist/types/errors/nonfield/isNonFieldError.d.ts +19 -0
  42. package/dist/types/errors/nonfield/isNonFieldErrorMarkerInDOM.d.ts +6 -0
  43. package/dist/types/errors/orphan/getIsOrphanFormErrorWithParentElement.d.ts +7 -0
  44. package/dist/types/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +4 -0
  45. package/dist/types/errors/orphan/isOrphanFormError.d.ts +4 -0
  46. package/dist/types/errors/output/consoleErrors.d.ts +7 -0
  47. package/dist/types/errors/output/types.d.ts +7 -0
  48. package/dist/types/errors/root/RootErrorsListFromFlatFieldErrorsContext.d.ts +2 -0
  49. package/dist/types/errors/root/consts.d.ts +1 -0
  50. package/dist/types/errors/root/getRootsFromFlatFieldErrors.d.ts +2 -0
  51. package/dist/types/errors/root/isFlatFieldErrorEntryPathRoot.d.ts +7 -0
  52. package/dist/types/errors/root/isFormErrorPathRoot.d.ts +7 -0
  53. package/dist/types/errors/trpc/makeOnSubmitTrpcClientErrorHandler.d.ts +11 -0
  54. package/dist/types/errors/trpc/trpcClientErrorMessageSchema.d.ts +24 -0
  55. package/dist/types/errors/trpc/trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer.d.ts +28 -0
  56. package/dist/types/form/Form.d.ts +11 -0
  57. package/dist/types/form/FormWithProviders.d.ts +13 -0
  58. package/dist/types/form/RhfUtilsFormOptions.d.ts +29 -0
  59. package/dist/types/form/RhfUtilsFormProviders.d.ts +12 -0
  60. package/dist/types/form/SafeFieldValues.d.ts +4 -0
  61. package/dist/types/form/UseRhfUtilsFormChildrenProps.d.ts +20 -0
  62. package/dist/types/form/UseRhfUtilsFormOnSubmitContext.d.ts +27 -0
  63. package/dist/types/form/UseRhfUtilsFormProps.d.ts +23 -0
  64. package/dist/types/form/UseRhfUtilsFormReturn.d.ts +20 -0
  65. package/dist/types/form/_Controller.d.ts +6 -0
  66. package/dist/types/form/context/group/FormGroupContextProvider.d.ts +5 -0
  67. package/dist/types/form/context/group/index.d.ts +14 -0
  68. package/dist/types/form/context/group/useFormGroupChildIsMountedTracker.d.ts +5 -0
  69. package/dist/types/form/context/group/useFormGroupChildIsSubmittingTracker.d.ts +5 -0
  70. package/dist/types/form/context/group/useFormGroupChildTracker.d.ts +6 -0
  71. package/dist/types/form/context/group/useFormGroupIsAnyBusy.d.ts +2 -0
  72. package/dist/types/form/context/group/useFormGroupIsChildBusy.d.ts +2 -0
  73. package/dist/types/form/context/group/useFormGroupIsParentBusy.d.ts +2 -0
  74. package/dist/types/form/context/group/useFormGroupParentTracker.d.ts +7 -0
  75. package/dist/types/form/context/group/useFormOrParentIsBusy.d.ts +2 -0
  76. package/dist/types/form/context/utils/RhfUtilsContextProvider.d.ts +9 -0
  77. package/dist/types/form/context/utils/useRhfUtilsContext.d.ts +14 -0
  78. package/dist/types/form/context/utils/useRhfUtilsContextRequestSubmit.d.ts +5 -0
  79. package/dist/types/form/useFormIsBusy.d.ts +2 -0
  80. package/dist/types/form/useRhfUtilsForm.d.ts +16 -0
  81. package/dist/types/form/utils/getSubmitterButtonData.d.ts +8 -0
  82. package/dist/types/form/utils/useFormRequestSubmit.d.ts +11 -0
  83. package/dist/types/form/utils/useShouldFormBlockNavigation.d.ts +26 -0
  84. package/dist/types/group.d.ts +29 -9
  85. package/dist/types/main.d.ts +1 -15
  86. package/dist/types/register.d.ts +7 -0
  87. package/dist/types/submit/error/FormSubmitError.d.ts +7 -0
  88. package/dist/types/submit/error/FormSubmitFieldErrors.d.ts +15 -0
  89. package/dist/types/submit/error/setCtxErrorsByFormSubmitFieldErrors.d.ts +10 -0
  90. package/dist/types/submit/useFormOnSubmitSuccessfulAndReset.d.ts +15 -0
  91. package/dist/types/submit/useFormOnSubmitted.d.ts +6 -0
  92. package/dist/types/submit/useResetFormOnSubmitted.d.ts +36 -0
  93. package/dist/types/submit/useSubmitFormOnChange.d.ts +9 -0
  94. package/dist/types/trpc.d.ts +8 -2
  95. package/dist/types/utils/PassthroughChildren.d.ts +7 -0
  96. package/dist/types/utils/createContext.d.ts +12 -0
  97. package/dist/types/utils/fixedForwardRef.d.ts +7 -0
  98. package/dist/types/utils/isEmptyObject.d.ts +2 -0
  99. package/dist/types/utils/timeoutAsync.d.ts +6 -0
  100. package/dist/types/utils/types.d.ts +1 -0
  101. package/dist/types/utils/useDebouncedOnChangeValue.d.ts +14 -0
  102. package/dist/types/utils/useImperativeForwardedRef.d.ts +11 -0
  103. package/dist/types/utils/useRefIfValueWasTrue.d.ts +2 -0
  104. package/dist/types/utils/useThrowAsyncError.d.ts +5 -0
  105. package/dist/types/utils/useToggle.d.ts +4 -0
  106. package/dist/types/utils.d.ts +5 -1
  107. package/package.json +7 -7
  108. /package/dist/esm/{main.mjs → index.mjs} +0 -0
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Component for simply passing through children.
3
+ *
4
+ * (Useful for conditional wrapping of children.)
5
+ */
6
+ declare const PassthroughChildren: React.FC<React.PropsWithChildren>;
7
+ export default PassthroughChildren;
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+
3
+ /**
4
+ * Create a strictly-typed context that throws error if no provider is found.
5
+ * @returns A tuple with a function to get the context and the context provider.
6
+ */
7
+ declare function createContext<T = unknown>(): {
8
+ readonly Provider: React.Provider<T | undefined>;
9
+ readonly useMaybe: () => T | undefined;
10
+ readonly useRequired: () => T & ({} | null);
11
+ };
12
+ export default createContext;
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+
3
+ /**
4
+ * @see https://www.totaltypescript.com/forwardref-with-generic-components
5
+ */
6
+ declare function fixedForwardRef<T, P = object>(render: (props: P, ref: React.Ref<T>) => React.ReactNode): (props: P & React.RefAttributes<T>) => React.ReactNode;
7
+ export default fixedForwardRef;
@@ -0,0 +1,2 @@
1
+ declare const isEmptyObject: (obj: Record<string, unknown>) => boolean;
2
+ export default isEmptyObject;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Awaitable `setTimeout`.
3
+ * @param timeout milliseconds
4
+ * @returns `Promise<void>`
5
+ */
6
+ export declare const timeoutAsync: (timeout: number) => Promise<void>;
@@ -0,0 +1 @@
1
+ export type MaybePromise<T> = T | Promise<T>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * React hook to debounce onChange event callback.
3
+ *
4
+ * Returns debounced state setter (uses ref internally).
5
+ *
6
+ * When debounce delay has elapsed after setting value,
7
+ * onChange callback is called with latest value.
8
+ *
9
+ * @returns `[setValueDebounced]`
10
+ */
11
+ export declare const useDebouncedOnChangeValue: <TValue>({ onChange, delay, }: {
12
+ onChange: (value: TValue) => void;
13
+ delay: number;
14
+ }) => readonly [(value: TValue) => void];
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+
3
+ /**
4
+ * Create a ref and point forwarded ref to it.
5
+ *
6
+ * Use case: forwarded refs are optional, but sometimes you need the ref.
7
+ *
8
+ * @param forwardedRef Forwarded `ref` prop.
9
+ */
10
+ declare const useImperativeForwardedRef: <TRef>(forwardedRef?: React.ForwardedRef<TRef>) => React.RefObject<TRef>;
11
+ export default useImperativeForwardedRef;
@@ -0,0 +1,2 @@
1
+ declare const useRefIfValueWasTrue: (value: boolean) => readonly [boolean, () => void];
2
+ export default useRefIfValueWasTrue;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * React cannot handle async errors in event handlers or useEffects.
3
+ */
4
+ declare const useThrowAsyncError: () => (error: unknown) => void;
5
+ export default useThrowAsyncError;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+
3
+ declare const useToggle: (defaultValue?: boolean) => [boolean, React.DispatchWithoutAction];
4
+ export default useToggle;
@@ -1 +1,5 @@
1
- export { default as RootErrorsListFromFlatFieldErrorsContext } from '../errors/root/RootErrorsListFromFlatFieldErrorsContext';
1
+ import { default as RootErrorsListFromFlatFieldErrorsContext } from '../errors/root/RootErrorsListFromFlatFieldErrorsContext';
2
+
3
+ export { RootErrorsListFromFlatFieldErrorsContext }
4
+
5
+ export { }
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.140",
5
+ "version": "0.0.142",
6
6
  "description": "Integration utilities for react-hook-form.",
7
7
  "type": "module",
8
8
  "sideEffects": false,
@@ -10,30 +10,30 @@
10
10
  "dist/esm/*",
11
11
  "dist/types/*"
12
12
  ],
13
- "module": "./dist/esm/main.mjs",
13
+ "module": "./dist/esm/index.mjs",
14
14
  "exports": {
15
15
  ".": {
16
16
  "import": {
17
- "default": "./dist/esm/main.mjs",
18
- "types": "./dist/types/main.d.ts"
17
+ "default": "./dist/esm/index.mjs",
18
+ "types": "./dist/types/_exports/index.d.ts"
19
19
  }
20
20
  },
21
21
  "./group": {
22
22
  "import": {
23
23
  "default": "./dist/esm/group.mjs",
24
- "types": "./dist/types/group.d.ts"
24
+ "types": "./dist/types/_exports/group.d.ts"
25
25
  }
26
26
  },
27
27
  "./trpc": {
28
28
  "import": {
29
29
  "default": "./dist/esm/trpc.mjs",
30
- "types": "./dist/types/trpc.d.ts"
30
+ "types": "./dist/types/_exports/trpc.d.ts"
31
31
  }
32
32
  },
33
33
  "./utils": {
34
34
  "import": {
35
35
  "default": "./dist/esm/utils.mjs",
36
- "types": "./dist/types/utils.d.ts"
36
+ "types": "./dist/types/_exports/utils.d.ts"
37
37
  }
38
38
  }
39
39
  },
File without changes