@paragrav/rhf-utils 0.0.139 → 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.
Files changed (111) hide show
  1. package/README.md +20 -2
  2. package/dist/esm/group.mjs +74 -0
  3. package/dist/esm/{exports.mjs → main.mjs} +161 -163
  4. package/dist/esm/trpc.mjs +41 -0
  5. package/dist/esm/useFlatFieldErrorsContext.mjs +10 -0
  6. package/dist/esm/utils.mjs +20 -0
  7. package/dist/types/group.d.ts +9 -0
  8. package/dist/types/main.d.ts +15 -1
  9. package/dist/types/trpc.d.ts +2 -0
  10. package/dist/types/utils.d.ts +1 -0
  11. package/package.json +19 -7
  12. package/dist/esm/form/context/group/exports.mjs +0 -74
  13. package/dist/types/client/config/RhfUtilsClientConfig.d.ts +0 -71
  14. package/dist/types/client/config/useRhfUtilsClientConfigContext.d.ts +0 -5
  15. package/dist/types/client/context.d.ts +0 -3
  16. package/dist/types/client/index.d.ts +0 -30
  17. package/dist/types/client/utils.d.ts +0 -13
  18. package/dist/types/client/zod/RhfUtilsUseFormChildrenZodFC.d.ts +0 -13
  19. package/dist/types/client/zod/RhfUtilsUseFormChildrenZodProps.d.ts +0 -5
  20. package/dist/types/client/zod/ZodTypeFieldValues.d.ts +0 -4
  21. package/dist/types/client/zod/consts.d.ts +0 -4
  22. package/dist/types/client/zod/context/RhfUtilsClientForZodContextProvider.d.ts +0 -8
  23. package/dist/types/client/zod/context/RhfUtilsZodForm.d.ts +0 -9
  24. package/dist/types/client/zod/context/useRhfUtilsClientForZodContext.d.ts +0 -6
  25. package/dist/types/client/zod/context/useRhfUtilsZodForm.d.ts +0 -8
  26. package/dist/types/client/zod/createRhfUtilsClientForZod.d.ts +0 -4
  27. package/dist/types/devtool/LazyDevTool.d.ts +0 -12
  28. package/dist/types/errors/flat/FlatFieldErrorsList.d.ts +0 -7
  29. package/dist/types/errors/flat/context/FlatFieldErrorsContextProvider.d.ts +0 -11
  30. package/dist/types/errors/flat/context/FlatFieldErrorsOutputConfig.d.ts +0 -20
  31. package/dist/types/errors/flat/context/useFlatFieldErrorsContext.d.ts +0 -13
  32. package/dist/types/errors/flat/context/useFlatFieldErrorsContextHasOnlyOrphans.d.ts +0 -7
  33. package/dist/types/errors/flat/context/useFlatFieldErrorsContextOutput.d.ts +0 -7
  34. package/dist/types/errors/flat/filterFlatFieldErrors.d.ts +0 -9
  35. package/dist/types/errors/flat/flattenFieldErrors.d.ts +0 -16
  36. package/dist/types/errors/flat/getFlatFieldErrors.d.ts +0 -32
  37. package/dist/types/errors/flat/types.d.ts +0 -17
  38. package/dist/types/errors/getRefdFromFlatFieldErrors.d.ts +0 -2
  39. package/dist/types/errors/isFieldErrorRefd.d.ts +0 -7
  40. package/dist/types/errors/isFlatFieldErrorEntryRefd.d.ts +0 -7
  41. package/dist/types/errors/message/FormErrorMessage.d.ts +0 -8
  42. package/dist/types/errors/message/RhfUtilsFieldErrorMessage.d.ts +0 -10
  43. package/dist/types/errors/nonfield/RhfUtilsNonFieldErrorMarker.d.ts +0 -13
  44. package/dist/types/errors/nonfield/RhfUtilsNonFieldErrorMarker.spec.d.ts +0 -1
  45. package/dist/types/errors/nonfield/RhfUtilsNonFieldErrorMarker.utils.d.ts +0 -18
  46. package/dist/types/errors/nonfield/RhfUtilsNonFieldErrorMarkerHtmlAttribute.d.ts +0 -5
  47. package/dist/types/errors/nonfield/isNonFieldError.d.ts +0 -19
  48. package/dist/types/errors/nonfield/isNonFieldErrorMarkerInDOM.d.ts +0 -6
  49. package/dist/types/errors/orphan/getIsOrphanFormErrorWithParentElement.d.ts +0 -7
  50. package/dist/types/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +0 -4
  51. package/dist/types/errors/orphan/isOrphanFormError.d.ts +0 -4
  52. package/dist/types/errors/output/consoleErrors.d.ts +0 -7
  53. package/dist/types/errors/output/types.d.ts +0 -7
  54. package/dist/types/errors/root/RootErrorsListFromFlatFieldErrorsContext.d.ts +0 -2
  55. package/dist/types/errors/root/consts.d.ts +0 -1
  56. package/dist/types/errors/root/getRootsFromFlatFieldErrors.d.ts +0 -2
  57. package/dist/types/errors/root/isFlatFieldErrorEntryPathRoot.d.ts +0 -7
  58. package/dist/types/errors/root/isFormErrorPathRoot.d.ts +0 -7
  59. package/dist/types/errors/trpc/getOnSubmitTrpcClientErrorHandler.d.ts +0 -11
  60. package/dist/types/errors/trpc/trpcClientErrorMessageSchema.d.ts +0 -24
  61. package/dist/types/errors/trpc/trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer.d.ts +0 -28
  62. package/dist/types/exports.d.ts +0 -15
  63. package/dist/types/form/Form.d.ts +0 -11
  64. package/dist/types/form/FormWithProviders.d.ts +0 -13
  65. package/dist/types/form/RhfUtilsFormOptions.d.ts +0 -29
  66. package/dist/types/form/RhfUtilsFormProviders.d.ts +0 -12
  67. package/dist/types/form/SafeFieldValues.d.ts +0 -4
  68. package/dist/types/form/UseRhfUtilsFormChildrenProps.d.ts +0 -20
  69. package/dist/types/form/UseRhfUtilsFormOnSubmitContext.d.ts +0 -27
  70. package/dist/types/form/UseRhfUtilsFormProps.d.ts +0 -23
  71. package/dist/types/form/UseRhfUtilsFormReturn.d.ts +0 -20
  72. package/dist/types/form/_Controller.d.ts +0 -6
  73. package/dist/types/form/context/group/FormGroupContextProvider.d.ts +0 -5
  74. package/dist/types/form/context/group/exports.d.ts +0 -9
  75. package/dist/types/form/context/group/index.d.ts +0 -14
  76. package/dist/types/form/context/group/useFormGroupChildIsMountedTracker.d.ts +0 -5
  77. package/dist/types/form/context/group/useFormGroupChildIsSubmittingTracker.d.ts +0 -5
  78. package/dist/types/form/context/group/useFormGroupChildTracker.d.ts +0 -6
  79. package/dist/types/form/context/group/useFormGroupIsAnyBusy.d.ts +0 -2
  80. package/dist/types/form/context/group/useFormGroupIsChildBusy.d.ts +0 -2
  81. package/dist/types/form/context/group/useFormGroupIsParentBusy.d.ts +0 -2
  82. package/dist/types/form/context/group/useFormGroupParentTracker.d.ts +0 -7
  83. package/dist/types/form/context/group/useFormOrParentIsBusy.d.ts +0 -2
  84. package/dist/types/form/context/utils/RhfUtilsContextProvider.d.ts +0 -9
  85. package/dist/types/form/context/utils/useRhfUtilsContext.d.ts +0 -14
  86. package/dist/types/form/context/utils/useRhfUtilsContextRequestSubmit.d.ts +0 -5
  87. package/dist/types/form/useFormIsBusy.d.ts +0 -2
  88. package/dist/types/form/useRhfUtilsForm.d.ts +0 -16
  89. package/dist/types/form/utils/getSubmitterButtonData.d.ts +0 -8
  90. package/dist/types/form/utils/useFormRequestSubmit.d.ts +0 -11
  91. package/dist/types/form/utils/useShouldFormBlockNavigation.d.ts +0 -26
  92. package/dist/types/register.d.ts +0 -7
  93. package/dist/types/submit/error/FormSubmitError.d.ts +0 -7
  94. package/dist/types/submit/error/FormSubmitFieldErrors.d.ts +0 -15
  95. package/dist/types/submit/error/setCtxErrorsByFormSubmitFieldErrors.d.ts +0 -10
  96. package/dist/types/submit/useFormOnSubmitSuccessfulAndReset.d.ts +0 -15
  97. package/dist/types/submit/useFormOnSubmitted.d.ts +0 -6
  98. package/dist/types/submit/useResetFormOnSubmitted.d.ts +0 -36
  99. package/dist/types/submit/useSubmitFormOnChange.d.ts +0 -9
  100. package/dist/types/utils/PassthroughChildren.d.ts +0 -7
  101. package/dist/types/utils/createContext.d.ts +0 -12
  102. package/dist/types/utils/fixedForwardRef.d.ts +0 -7
  103. package/dist/types/utils/isEmptyObject.d.ts +0 -2
  104. package/dist/types/utils/timeoutAsync.d.ts +0 -6
  105. package/dist/types/utils/types.d.ts +0 -1
  106. package/dist/types/utils/useDebouncedOnChangeValue.d.ts +0 -14
  107. package/dist/types/utils/useImperativeForwardedRef.d.ts +0 -11
  108. package/dist/types/utils/useRefIfValueWasTrue.d.ts +0 -2
  109. package/dist/types/utils/useThrowAsyncError.d.ts +0 -5
  110. package/dist/types/utils/useToggle.d.ts +0 -4
  111. /package/dist/esm/{createContext-Jzs0Nsql.js → createContext.mjs} +0 -0
@@ -1,36 +0,0 @@
1
- /**
2
- * Configuration options for {@link useResetFormOnSubmitted}.
3
- */
4
- export type UseResetFormOnSubmittedOptions = undefined | {
5
- /**
6
- * Reset values on successful submit.
7
- * - `defaults`: reset current values to defaults
8
- * - `current`: reset defaults to current values
9
- */
10
- success?: {
11
- values: 'defaults' | 'current';
12
- };
13
- /**
14
- * Reset values to defaults on submit error.
15
- */
16
- error?: {
17
- values: 'defaults';
18
- };
19
- };
20
- /**
21
- * Control resetting of values and (some) state (e.g., `isDirty`) after form submitted.
22
- *
23
- * `isDirty` and other state is reset, but submit-related state is preserved, as well as errors.
24
- *
25
- * Use cases:
26
- * - on success:
27
- * - `defaults`: reset current values to defaults (e.g., clear form)
28
- * - `current`: reset defaults to current values (e.g., keep values)
29
- * - on error:
30
- * - reset current values to default values (e.g., submitOnChange reset)
31
- *
32
- * See `Rules` section: https://react-hook-form.com/api/useform/reset/
33
- * Specifically: "- It's recommended to reset inside useEffect after submission."
34
- */
35
- declare const useResetFormOnSubmitted: (options: UseResetFormOnSubmittedOptions) => void;
36
- export default useResetFormOnSubmitted;
@@ -1,9 +0,0 @@
1
- import { default as React } from 'react';
2
-
3
- declare const useSubmitFormOnChange: (formRef: React.RefObject<HTMLFormElement>, options?: {
4
- /** Disable behavior. (Default behavior is enabled for sake of simplicity of general usage.) */
5
- disabled?: boolean;
6
- /** Milliseconds to debounce form submission. (Default is none.) */
7
- debounce?: number;
8
- }) => void;
9
- export default useSubmitFormOnChange;
@@ -1,7 +0,0 @@
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;
@@ -1,12 +0,0 @@
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;
@@ -1,7 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- declare const isEmptyObject: (obj: Record<string, unknown>) => boolean;
2
- export default isEmptyObject;
@@ -1,6 +0,0 @@
1
- /**
2
- * Awaitable `setTimeout`.
3
- * @param timeout milliseconds
4
- * @returns `Promise<void>`
5
- */
6
- export declare const timeoutAsync: (timeout: number) => Promise<void>;
@@ -1 +0,0 @@
1
- export type MaybePromise<T> = T | Promise<T>;
@@ -1,14 +0,0 @@
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];
@@ -1,11 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- declare const useRefIfValueWasTrue: (value: boolean) => readonly [boolean, () => void];
2
- export default useRefIfValueWasTrue;
@@ -1,5 +0,0 @@
1
- /**
2
- * React cannot handle async errors in event handlers or useEffects.
3
- */
4
- declare const useThrowAsyncError: () => (error: unknown) => void;
5
- export default useThrowAsyncError;
@@ -1,4 +0,0 @@
1
- import { default as React } from 'react';
2
-
3
- declare const useToggle: (defaultValue?: boolean) => [boolean, React.DispatchWithoutAction];
4
- export default useToggle;