@paragrav/rhf-utils 0.0.141 → 0.0.143

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 (65) hide show
  1. package/README.md +2 -2
  2. package/dist/types/client/config/RhfUtilsClientConfig.d.ts +0 -1
  3. package/dist/types/client/config/useRhfUtilsClientConfigContext.d.ts +0 -1
  4. package/dist/types/client/context.d.ts +0 -1
  5. package/dist/types/client/index.d.ts +1 -2
  6. package/dist/types/client/utils.d.ts +0 -1
  7. package/dist/types/client/zod/RhfUtilsUseFormChildrenZodFC.d.ts +0 -1
  8. package/dist/types/client/zod/RhfUtilsUseFormChildrenZodProps.d.ts +0 -1
  9. package/dist/types/client/zod/ZodTypeFieldValues.d.ts +0 -1
  10. package/dist/types/client/zod/context/RhfUtilsClientForZodContextProvider.d.ts +0 -1
  11. package/dist/types/client/zod/context/RhfUtilsZodForm.d.ts +0 -1
  12. package/dist/types/client/zod/context/useRhfUtilsClientForZodContext.d.ts +0 -1
  13. package/dist/types/client/zod/context/useRhfUtilsZodForm.d.ts +1 -2
  14. package/dist/types/client/zod/createRhfUtilsClientForZod.d.ts +0 -1
  15. package/dist/types/devtool/LazyDevTool.d.ts +0 -1
  16. package/dist/types/errors/flat/FlatFieldErrorsList.d.ts +0 -1
  17. package/dist/types/errors/flat/context/FlatFieldErrorsContextProvider.d.ts +0 -1
  18. package/dist/types/errors/flat/context/FlatFieldErrorsOutputConfig.d.ts +0 -1
  19. package/dist/types/errors/flat/context/useFlatFieldErrorsContext.d.ts +0 -1
  20. package/dist/types/errors/flat/context/useFlatFieldErrorsContextOutput.d.ts +0 -1
  21. package/dist/types/errors/flat/filterFlatFieldErrors.d.ts +0 -1
  22. package/dist/types/errors/flat/flattenFieldErrors.d.ts +0 -1
  23. package/dist/types/errors/flat/getFlatFieldErrors.d.ts +0 -1
  24. package/dist/types/errors/flat/types.d.ts +0 -1
  25. package/dist/types/errors/isFieldErrorRefd.d.ts +0 -1
  26. package/dist/types/errors/isFlatFieldErrorEntryRefd.d.ts +0 -1
  27. package/dist/types/errors/message/FormErrorMessage.d.ts +0 -1
  28. package/dist/types/errors/nonfield/isNonFieldError.d.ts +0 -1
  29. package/dist/types/errors/orphan/getIsOrphanFormErrorWithParentElement.d.ts +0 -1
  30. package/dist/types/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +0 -1
  31. package/dist/types/errors/orphan/isOrphanFormError.d.ts +0 -1
  32. package/dist/types/errors/output/consoleErrors.d.ts +0 -1
  33. package/dist/types/errors/root/isFlatFieldErrorEntryPathRoot.d.ts +0 -1
  34. package/dist/types/errors/trpc/makeOnSubmitTrpcClientErrorHandler.d.ts +0 -1
  35. package/dist/types/errors/trpc/trpcClientErrorMessageSchema.d.ts +0 -1
  36. package/dist/types/errors/trpc/trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer.d.ts +3 -4
  37. package/dist/types/form/Form.d.ts +0 -1
  38. package/dist/types/form/FormWithProviders.d.ts +0 -1
  39. package/dist/types/form/RhfUtilsFormOptions.d.ts +0 -1
  40. package/dist/types/form/RhfUtilsFormProviders.d.ts +0 -1
  41. package/dist/types/form/UseRhfUtilsFormChildrenProps.d.ts +0 -1
  42. package/dist/types/form/UseRhfUtilsFormOnSubmitContext.d.ts +0 -1
  43. package/dist/types/form/UseRhfUtilsFormProps.d.ts +0 -1
  44. package/dist/types/form/UseRhfUtilsFormReturn.d.ts +0 -1
  45. package/dist/types/form/_Controller.d.ts +0 -1
  46. package/dist/types/form/context/group/FormGroupContextProvider.d.ts +0 -1
  47. package/dist/types/form/context/utils/RhfUtilsContextProvider.d.ts +0 -1
  48. package/dist/types/form/context/utils/useRhfUtilsContext.d.ts +0 -1
  49. package/dist/types/form/useRhfUtilsForm.d.ts +0 -1
  50. package/dist/types/form/utils/getSubmitterButtonData.d.ts +0 -1
  51. package/dist/types/form/utils/useFormRequestSubmit.d.ts +0 -1
  52. package/dist/types/form/utils/useShouldFormBlockNavigation.d.ts +0 -1
  53. package/dist/types/submit/error/FormSubmitError.d.ts +0 -1
  54. package/dist/types/submit/error/FormSubmitFieldErrors.d.ts +0 -1
  55. package/dist/types/submit/error/setCtxErrorsByFormSubmitFieldErrors.d.ts +0 -1
  56. package/dist/types/submit/useFormOnSubmitSuccessfulAndReset.d.ts +0 -1
  57. package/dist/types/submit/useFormOnSubmitted.d.ts +0 -1
  58. package/dist/types/submit/useSubmitFormOnChange.d.ts +0 -1
  59. package/dist/types/utils/createContext.d.ts +0 -1
  60. package/dist/types/utils/fixedForwardRef.d.ts +1 -2
  61. package/dist/types/utils/useImperativeForwardedRef.d.ts +0 -1
  62. package/dist/types/utils/useToggle.d.ts +0 -1
  63. package/package.json +4 -4
  64. /package/dist/esm/{main.mjs → index.mjs} +0 -0
  65. /package/dist/types/_exports/{main.d.ts → index.d.ts} +0 -0
package/README.md CHANGED
@@ -383,7 +383,7 @@ _If you include the marker in bulk error lists, it will defeat the purpose of th
383
383
 
384
384
  ## Other Features
385
385
 
386
- ### Form Groups _(0.65kB min+gzip)_
386
+ ### Form Groups _(0.7kB min+gzip)_
387
387
 
388
388
  Sometimes you need to group multiple forms together.
389
389
 
@@ -408,7 +408,7 @@ In children forms, there are two options. You can choose to consider form "busy"
408
408
 
409
409
  Both hooks return `boolean` value indicating whether parent form is busy.
410
410
 
411
- ### TRPC.io Utils _(0.41kB min+gzip)_
411
+ ### TRPC.io Utils _(0.4kB min+gzip)_
412
412
 
413
413
  #### `trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer`
414
414
 
@@ -3,7 +3,6 @@ import { FlatFieldErrorsOutputConfig } from '../../errors/flat/context/FlatField
3
3
  import { RhfUtilsFormOptions } from '../../form/RhfUtilsFormOptions';
4
4
  import { UseRhfUtilsFormChildrenProps } from '../../form/UseRhfUtilsFormChildrenProps';
5
5
  import { FormSubmitFieldErrors } from '../../submit/error/FormSubmitFieldErrors';
6
-
7
6
  /**
8
7
  * Client configuration object.
9
8
  *
@@ -1,5 +1,4 @@
1
1
  import { RhfUtilsClientConfig } from './RhfUtilsClientConfig';
2
-
3
2
  declare const _RhfUtilsClientConfigContextProvider: import('react').Provider<RhfUtilsClientConfig | undefined>, useRhfUtilsClientConfigMaybeContext: () => RhfUtilsClientConfig | undefined;
4
3
  export default useRhfUtilsClientConfigMaybeContext;
5
4
  export { _RhfUtilsClientConfigContextProvider };
@@ -1,3 +1,2 @@
1
1
  import { CreateRhfUtilsClient, ObjectSchema } from '.';
2
-
3
2
  export type RhfUtilsClientContext<TObjectSchema extends ObjectSchema<TObjectSchemaInputKey, TObjectSchemaOutputKey>, TObjectSchemaInputKey extends string, TObjectSchemaOutputKey extends string> = CreateRhfUtilsClient<TObjectSchema, TObjectSchemaInputKey, TObjectSchemaOutputKey>;
@@ -5,7 +5,6 @@ import { FormWithProvidersProps } from '../form/FormWithProviders';
5
5
  import { SafeFieldValues } from '../form/SafeFieldValues';
6
6
  import { UseRhfUtilsFormProps } from '../form/UseRhfUtilsFormProps';
7
7
  import { UseRhfUtilsFormReturn } from '../form/UseRhfUtilsFormReturn';
8
-
9
8
  /**
10
9
  * Generic object schema type.
11
10
  */
@@ -15,7 +14,7 @@ export type ObjectSchema<TInputKey extends string, TOutputKey extends string> =
15
14
  [key in TOutputKey]: SafeFieldValues;
16
15
  };
17
16
  export type CreateRhfUtilsClient<TObjectSchema extends ObjectSchema<TObjectSchemaInputKey, TObjectSchemaOutputKey>, TObjectSchemaInputKey extends string, TObjectSchemaOutputKey extends string> = {
18
- useForm: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey], UseRhfUtilsFormPropsForm extends UseRhfUtilsFormProps<TSchemaInput, TSchemaOutput> = UseRhfUtilsFormProps<TSchemaInput, TSchemaOutput>>(schema: TSchema, form: UseRhfUtilsFormPropsForm) => UseRhfUtilsFormReturn<TSchemaInput, TSchemaOutput> & {
17
+ useForm: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey]>(schema: TSchema, form: UseRhfUtilsFormProps<TSchemaInput, TSchemaOutput>) => UseRhfUtilsFormReturn<TSchemaInput, TSchemaOutput> & {
19
18
  FormWithProviders: React.FC<React.PropsWithChildren>;
20
19
  };
21
20
  FormWithProviders: <TSchema extends TObjectSchema, TSchemaInput extends SafeFieldValues = TSchema[TObjectSchemaInputKey], TSchemaOutput extends SafeFieldValues = TSchema[TObjectSchemaOutputKey]>(props: {
@@ -2,7 +2,6 @@ import { RhfUtilsFormOptions } from '../form/RhfUtilsFormOptions';
2
2
  import { SafeFieldValues } from '../form/SafeFieldValues';
3
3
  import { UseRhfUtilsFormProps } from '../form/UseRhfUtilsFormProps';
4
4
  import { RhfUtilsClientConfig } from './config/RhfUtilsClientConfig';
5
-
6
5
  /**
7
6
  * Merge {@link RhfUtilsClientConfig.defaults} with array of {@link UseRhfUtilsFormProps}'s overrides.
8
7
  */
@@ -1,7 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  import { RhfUtilsUseFormChildrenZodProps } from './RhfUtilsUseFormChildrenZodProps';
3
3
  import { ZodTypeFieldValues } from './ZodTypeFieldValues';
4
-
5
4
  /**
6
5
  * {@link React.FC} for {@link RhfUtilsUseFormChildrenZodProps}.
7
6
  *
@@ -1,5 +1,4 @@
1
1
  import { UseRhfUtilsFormChildrenProps } from '../../form/UseRhfUtilsFormChildrenProps';
2
2
  import { zodTypeInput, zodTypeOutput } from './consts';
3
3
  import { ZodTypeFieldValues } from './ZodTypeFieldValues';
4
-
5
4
  export type RhfUtilsUseFormChildrenZodProps<TSchema extends ZodTypeFieldValues> = UseRhfUtilsFormChildrenProps<TSchema[typeof zodTypeInput], TSchema[typeof zodTypeOutput]>;
@@ -1,4 +1,3 @@
1
1
  import { z } from 'zod';
2
2
  import { SafeFieldValues } from '../../form/SafeFieldValues';
3
-
4
3
  export type ZodTypeFieldValues = z.ZodType<SafeFieldValues>;
@@ -1,6 +1,5 @@
1
1
  import { default as React } from 'react';
2
2
  import { RhfUtilsClientConfig } from '../../config/RhfUtilsClientConfig';
3
-
4
3
  type Props = React.PropsWithChildren<{
5
4
  config?: RhfUtilsClientConfig;
6
5
  }>;
@@ -1,7 +1,6 @@
1
1
  import { UseRhfUtilsFormProps } from '../../../form/UseRhfUtilsFormProps';
2
2
  import { zodTypeInput, zodTypeOutput } from '../consts';
3
3
  import { ZodTypeFieldValues } from '../ZodTypeFieldValues';
4
-
5
4
  type Props<TSchema extends ZodTypeFieldValues> = {
6
5
  schema: TSchema;
7
6
  } & UseRhfUtilsFormProps<TSchema[typeof zodTypeInput], TSchema[typeof zodTypeOutput]>;
@@ -1,5 +1,4 @@
1
1
  import { default as createRhfUtilsClientForZod } from '../createRhfUtilsClientForZod';
2
-
3
2
  export type RhfUtilsClientForZodContext = ReturnType<typeof createRhfUtilsClientForZod>;
4
3
  declare const _RhfUtilsClientForZodContextProvider: import('react').Provider<import('../..').CreateRhfUtilsClient<import('../ZodTypeFieldValues').ZodTypeFieldValues, "_input", "_output"> | undefined>, useRhfUtilsClientForZodContext: () => import('../..').CreateRhfUtilsClient<import('../ZodTypeFieldValues').ZodTypeFieldValues, "_input", "_output">;
5
4
  export default useRhfUtilsClientForZodContext;
@@ -1,8 +1,7 @@
1
1
  import { UseRhfUtilsFormProps } from '../../../form/UseRhfUtilsFormProps';
2
2
  import { zodTypeInput, zodTypeOutput } from '../consts';
3
3
  import { ZodTypeFieldValues } from '../ZodTypeFieldValues';
4
-
5
4
  declare const useRhfUtilsZodForm: <TSchema extends ZodTypeFieldValues>(schema: TSchema, form: UseRhfUtilsFormProps<TSchema[typeof zodTypeInput], TSchema[typeof zodTypeOutput]>) => import('../../../form/UseRhfUtilsFormReturn').UseRhfUtilsFormReturn<TSchema["_input"], TSchema["_output"]> & {
6
- FormWithProviders: import('react').FC<import('react').PropsWithChildren>;
5
+ FormWithProviders: React.FC<React.PropsWithChildren>;
7
6
  };
8
7
  export default useRhfUtilsZodForm;
@@ -1,4 +1,3 @@
1
1
  import { ZodTypeFieldValues } from './ZodTypeFieldValues';
2
-
3
2
  declare const createRhfUtilsClientForZod: (config: import('../config/RhfUtilsClientConfig').RhfUtilsClientConfig) => import('..').CreateRhfUtilsClient<ZodTypeFieldValues, "_input", "_output">;
4
3
  export default createRhfUtilsClientForZod;
@@ -1,6 +1,5 @@
1
1
  import { DevtoolUIProps } from '@hookform/devtools/dist/devToolUI';
2
2
  import { default as React } from 'react';
3
-
4
3
  type LazyDevToolProps = {
5
4
  enabled?: boolean;
6
5
  props?: Omit<DevtoolUIProps, 'control'>;
@@ -1,5 +1,4 @@
1
1
  import { FlatFieldErrors } from './types';
2
-
3
2
  export type Props = {
4
3
  errors: FlatFieldErrors | null | undefined;
5
4
  };
@@ -1,5 +1,4 @@
1
1
  import { default as React } from 'react';
2
-
3
2
  type Props = React.PropsWithChildren<{
4
3
  formRef: React.RefObject<HTMLFormElement>;
5
4
  }>;
@@ -1,6 +1,5 @@
1
1
  import { RhfUtilsErrorsOutputConsoleConfig } from '../../output/types';
2
2
  import { FlatFieldErrorsContext } from './useFlatFieldErrorsContext';
3
-
4
3
  export type FlatFieldErrorsOutputConfig = {
5
4
  /**
6
5
  * Configure how/if errors should be outputted to console.
@@ -1,5 +1,4 @@
1
1
  import { FlatFieldErrors } from '../types';
2
-
3
2
  export type FlatFieldErrorsContext = {
4
3
  all: FlatFieldErrors;
5
4
  fields: FlatFieldErrors;
@@ -1,5 +1,4 @@
1
1
  import { FlatFieldErrorsOutputConfig } from './FlatFieldErrorsOutputConfig';
2
-
3
2
  /**
4
3
  * Outputs (e.g., console, throw) errors based on config.
5
4
  */
@@ -1,5 +1,4 @@
1
1
  import { FlatFieldErrorEntry, FlatFieldErrors } from './types';
2
-
3
2
  /**
4
3
  * Filter {@link FlatFieldErrors} by a predicate.
5
4
  *
@@ -1,5 +1,4 @@
1
1
  import { FieldErrors } from 'react-hook-form';
2
-
3
2
  /**
4
3
  * Flatten a {@link FieldErrors} object.
5
4
  *
@@ -1,6 +1,5 @@
1
1
  import { FieldErrors } from 'react-hook-form';
2
2
  import { FlatFieldErrors } from './types';
3
-
4
3
  /**
5
4
  * Get {@link FlatFieldErrors} from {@link FieldErrors}.
6
5
  * This makes it easy to work with potentially deeply-nested {@link FieldErrors}.
@@ -1,5 +1,4 @@
1
1
  import { FieldError } from 'react-hook-form';
2
-
3
2
  /**
4
3
  * Flattened field errors object.
5
4
  *
@@ -1,5 +1,4 @@
1
1
  import { FieldError } from 'react-hook-form';
2
-
3
2
  /**
4
3
  * Determine if {@link FieldError} is a `ref`'d field error.
5
4
  */
@@ -1,5 +1,4 @@
1
1
  import { FlatFieldErrorEntry } from './flat/types';
2
-
3
2
  /**
4
3
  * Determine if {@link FieldError} is a `ref`'d field error.
5
4
  */
@@ -1,5 +1,4 @@
1
1
  import { default as React } from 'react';
2
-
3
2
  type Props = {
4
3
  message: string;
5
4
  className?: string;
@@ -1,5 +1,4 @@
1
1
  import { FieldError } from 'react-hook-form';
2
-
3
2
  /**
4
3
  * Determine if {@link FieldError} is a non-field error (i.e., has no `ref`).
5
4
  *
@@ -1,5 +1,4 @@
1
1
  import { FlatFieldErrorEntry } from '../flat/types';
2
-
3
2
  /**
4
3
  * Util wrapper for {@link isOrphanFormError} for usage with {@link FlatFieldErrorEntry}.
5
4
  */
@@ -1,4 +1,3 @@
1
1
  import { FlatFieldErrors } from '../flat/types';
2
-
3
2
  declare const getOrphansFromFlatFieldErrors: (errors: FlatFieldErrors, parentElement: Pick<HTMLElement, "querySelector">) => FlatFieldErrors;
4
3
  export default getOrphansFromFlatFieldErrors;
@@ -1,4 +1,3 @@
1
1
  import { FieldError } from 'react-hook-form';
2
-
3
2
  declare const isOrphanFormError: (path: string, error: FieldError, parentElement: Pick<HTMLElement, "querySelector">) => boolean;
4
3
  export default isOrphanFormError;
@@ -1,5 +1,4 @@
1
1
  import { SafeFieldValues } from '../../form/SafeFieldValues';
2
-
3
2
  /**
4
3
  * Output form values and errors to console.
5
4
  */
@@ -1,5 +1,4 @@
1
1
  import { FlatFieldErrorEntry } from '../flat/types';
2
-
3
2
  /**
4
3
  * Util wrapper for {@link isFormErrorPathRoot} for usage with {@link FlatFieldErrorEntry}.
5
4
  */
@@ -1,6 +1,5 @@
1
1
  import { RhfUtilsClientConfig } from '../../client/config/RhfUtilsClientConfig';
2
2
  import { FormSubmitFieldErrors } from '../../submit/error/FormSubmitFieldErrors';
3
-
4
3
  /**
5
4
  * HOF that returns submit error handler for {@link RhfUtilsClientConfig.onSubmitErrorUnknown}.
6
5
  *
@@ -1,5 +1,4 @@
1
1
  import { z } from 'zod';
2
-
3
2
  /**
4
3
  * Schema for {@link TRPCClientError} message.
5
4
  *
@@ -1,12 +1,11 @@
1
1
  import { TRPCClientErrorLike } from '@trpc/client';
2
- import { AnyRouter } from '@trpc/server';
2
+ import { AnyTRPCRouter } from '@trpc/server';
3
3
  import { z } from 'zod';
4
4
  import { FormSubmitFieldErrors } from '../../submit/error/FormSubmitFieldErrors';
5
-
6
5
  /**
7
6
  * Schema that transforms {@link TRPCClientError} to RHF {@link FormSubmitFieldErrors}.
8
7
  */
9
- declare const trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer: z.ZodEffects<z.ZodEffects<z.ZodPipeline<z.ZodEffects<z.ZodEffects<z.ZodType<TRPCClientErrorLike<AnyRouter>, z.ZodTypeDef, TRPCClientErrorLike<AnyRouter>>, string, TRPCClientErrorLike<AnyRouter>>, unknown, TRPCClientErrorLike<AnyRouter>>, z.ZodArray<z.ZodObject<{
8
+ declare const trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer: z.ZodEffects<z.ZodEffects<z.ZodPipeline<z.ZodEffects<z.ZodEffects<z.ZodType<TRPCClientErrorLike<AnyTRPCRouter>, z.ZodTypeDef, TRPCClientErrorLike<AnyTRPCRouter>>, string, TRPCClientErrorLike<AnyTRPCRouter>>, unknown, TRPCClientErrorLike<AnyTRPCRouter>>, z.ZodArray<z.ZodObject<{
10
9
  validation: z.ZodString;
11
10
  code: z.ZodString;
12
11
  message: z.ZodString;
@@ -24,5 +23,5 @@ declare const trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer: z.ZodEffe
24
23
  }>, "many">>, (readonly [string, {
25
24
  type: string;
26
25
  message: string;
27
- }])[], TRPCClientErrorLike<AnyRouter>>, FormSubmitFieldErrors, TRPCClientErrorLike<AnyRouter>>;
26
+ }])[], TRPCClientErrorLike<AnyTRPCRouter>>, FormSubmitFieldErrors, TRPCClientErrorLike<AnyTRPCRouter>>;
28
27
  export default trpcClientErrorToFormSubmitFieldErrorsSchemaTransformer;
@@ -1,7 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  import { SafeFieldValues } from './SafeFieldValues';
3
3
  import { UseRhfUtilsFormProps } from './UseRhfUtilsFormProps';
4
-
5
4
  export type FormChildrenSlots = 'top' | 'bottom';
6
5
  export type FormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = {
7
6
  formId: string;
@@ -1,6 +1,5 @@
1
1
  import { SafeFieldValues } from './SafeFieldValues';
2
2
  import { UseRhfUtilsFormProps } from './UseRhfUtilsFormProps';
3
-
4
3
  export type FormWithProvidersProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<UseRhfUtilsFormProps<TFieldValues, TTransformedValues>>;
5
4
  /**
6
5
  * Form providers (with utils) with immediate descendent {@link Form}.
@@ -1,7 +1,6 @@
1
1
  import { DevtoolUIProps } from '@hookform/devtools/dist/devToolUI';
2
2
  import { UseResetFormOnSubmittedOptions } from '../submit/useResetFormOnSubmitted';
3
3
  import { Register } from '../register';
4
-
5
4
  /**
6
5
  * Options for enabling utils functionality provided by this library.
7
6
  *
@@ -1,7 +1,6 @@
1
1
  import { UseFormReturn } from 'react-hook-form';
2
2
  import { RhfUtilsFormOptions } from './RhfUtilsFormOptions';
3
3
  import { SafeFieldValues } from './SafeFieldValues';
4
-
5
4
  export type RhfUtilsFormProvidersProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = React.PropsWithChildren<{
6
5
  formId: string;
7
6
  formRef: React.RefObject<HTMLFormElement>;
@@ -4,7 +4,6 @@ import { FormSubmitError } from '../submit/error/FormSubmitError';
4
4
  import { default as _Controller } from './_Controller';
5
5
  import { RhfUtilsFormOptions } from './RhfUtilsFormOptions';
6
6
  import { SafeFieldValues } from './SafeFieldValues';
7
-
8
7
  /**
9
8
  * Component props for `Children`.
10
9
  *
@@ -3,7 +3,6 @@ import { UseFormReturn } from 'react-hook-form';
3
3
  import { FormSubmitError } from '../submit/error/FormSubmitError';
4
4
  import { RhfUtilsFormOptions } from './RhfUtilsFormOptions';
5
5
  import { SafeFieldValues } from './SafeFieldValues';
6
-
7
6
  /**
8
7
  * Props for onSubmit other than `data` and `event`.
9
8
  *
@@ -5,7 +5,6 @@ import { RhfUtilsFormOptions } from './RhfUtilsFormOptions';
5
5
  import { SafeFieldValues } from './SafeFieldValues';
6
6
  import { UseRhfUtilsFormChildrenProps } from './UseRhfUtilsFormChildrenProps';
7
7
  import { UseRhfUtilsFormOnSubmitContext, UseRhfUtilsFormOnSubmitErrorContext } from './UseRhfUtilsFormOnSubmitContext';
8
-
9
8
  export type UseRhfUtilsFormProps<TFieldValues extends SafeFieldValues, TTransformedValues extends SafeFieldValues> = {
10
9
  defaultValues?: UseFormProps<TFieldValues>['defaultValues'];
11
10
  onSubmit?: (values: TTransformedValues, context: UseRhfUtilsFormOnSubmitContext<TFieldValues, TTransformedValues>, event: React.BaseSyntheticEvent<SubmitEvent>) => MaybePromise<unknown>;
@@ -4,7 +4,6 @@ import { FormSubmitError } from '../submit/error/FormSubmitError';
4
4
  import { FormProps } from './Form';
5
5
  import { RhfUtilsFormProvidersProps } from './RhfUtilsFormProviders';
6
6
  import { SafeFieldValues } from './SafeFieldValues';
7
-
8
7
  /**
9
8
  * Return type for `useRhfUtilsForm`.
10
9
  *
@@ -1,6 +1,5 @@
1
1
  import { ControllerProps, FieldPath } from 'react-hook-form';
2
2
  import { SafeFieldValues } from './SafeFieldValues';
3
-
4
3
  export type _ControllerProps<TFieldValues extends SafeFieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = Omit<ControllerProps<TFieldValues, TName>, 'control'>;
5
4
  declare function _Controller<TFieldValues extends SafeFieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: _ControllerProps<TFieldValues, TName>): import("react/jsx-runtime").JSX.Element;
6
5
  export default _Controller;
@@ -1,5 +1,4 @@
1
1
  import { default as React } from 'react';
2
-
3
2
  type Props = React.PropsWithChildren;
4
3
  declare const FormGroupContextProvider: React.FC<Props>;
5
4
  export default FormGroupContextProvider;
@@ -1,5 +1,4 @@
1
1
  import { RhfUtilsFormOptions } from '../../RhfUtilsFormOptions';
2
-
3
2
  type Props = React.PropsWithChildren<{
4
3
  formId: string;
5
4
  formRef: React.RefObject<HTMLFormElement>;
@@ -1,5 +1,4 @@
1
1
  import { RhfUtilsFormOptions } from '../../RhfUtilsFormOptions';
2
-
3
2
  export type RhfUtilsContext = {
4
3
  formId: string;
5
4
  formRef: React.RefObject<HTMLFormElement>;
@@ -1,7 +1,6 @@
1
1
  import { SafeFieldValues } from './SafeFieldValues';
2
2
  import { UseRhfUtilsFormProps } from './UseRhfUtilsFormProps';
3
3
  import { UseRhfUtilsFormReturn } from './UseRhfUtilsFormReturn';
4
-
5
4
  /**
6
5
  * Core Rhf Form hook. Use `Form` in `index.ts` for most cases.
7
6
  * Use this if you need to separate form components.
@@ -1,5 +1,4 @@
1
1
  import { default as React } from 'react';
2
-
3
2
  /**
4
3
  * Get [name, value] tuple of button/input that submitted form.
5
4
  * Useful when determining user intent
@@ -1,5 +1,4 @@
1
1
  import { default as React } from 'react';
2
-
3
2
  /**
4
3
  * Get callback to trigger submit manually on form.
5
4
  *
@@ -1,5 +1,4 @@
1
1
  import { FieldValues, FormState } from 'react-hook-form';
2
-
3
2
  export type UseShouldFormBlockNavigationOptions = {
4
3
  disabled?: boolean;
5
4
  /**
@@ -1,6 +1,5 @@
1
1
  import { SafeFieldValues } from '../../form/SafeFieldValues';
2
2
  import { FormSubmitFieldErrors } from './FormSubmitFieldErrors';
3
-
4
3
  export declare class FormSubmitError<TFieldValues extends SafeFieldValues = SafeFieldValues> extends Error {
5
4
  errors: FormSubmitFieldErrors<TFieldValues>;
6
5
  constructor(errors: FormSubmitFieldErrors<TFieldValues>, message?: string);
@@ -1,6 +1,5 @@
1
1
  import { FieldPath } from 'react-hook-form';
2
2
  import { SafeFieldValues } from '../../form/SafeFieldValues';
3
-
4
3
  /**
5
4
  * Field errors structure based on RHF's `FieldErrors`.
6
5
  *
@@ -1,7 +1,6 @@
1
1
  import { UseFormReturn } from 'react-hook-form';
2
2
  import { SafeFieldValues } from '../../form/SafeFieldValues';
3
3
  import { FormSubmitFieldErrors } from './FormSubmitFieldErrors';
4
-
5
4
  /**
6
5
  * Handle thrown {@link FormSubmitError}.
7
6
  * Add key/values as name/message to RHF context errors.
@@ -1,5 +1,4 @@
1
1
  import { MaybePromise } from '../utils/types';
2
-
3
2
  /**
4
3
  * Calls a callback after a successful submit and after a form reset.
5
4
  *
@@ -1,5 +1,4 @@
1
1
  import { MaybePromise } from '../utils/types';
2
-
3
2
  declare const useFormOnSubmitted: (callback?: (success: boolean) => MaybePromise<unknown>, options?: {
4
3
  successful?: boolean;
5
4
  }) => void;
@@ -1,5 +1,4 @@
1
1
  import { default as React } from 'react';
2
-
3
2
  declare const useSubmitFormOnChange: (formRef: React.RefObject<HTMLFormElement>, options?: {
4
3
  /** Disable behavior. (Default behavior is enabled for sake of simplicity of general usage.) */
5
4
  disabled?: boolean;
@@ -1,5 +1,4 @@
1
1
  import { default as React } from 'react';
2
-
3
2
  /**
4
3
  * Create a strictly-typed context that throws error if no provider is found.
5
4
  * @returns A tuple with a function to get the context and the context provider.
@@ -1,7 +1,6 @@
1
1
  import { default as React } from 'react';
2
-
3
2
  /**
4
3
  * @see https://www.totaltypescript.com/forwardref-with-generic-components
5
4
  */
6
- declare function fixedForwardRef<T, P = object>(render: (props: P, ref: React.Ref<T>) => React.ReactNode): (props: P & React.RefAttributes<T>) => React.ReactNode;
5
+ declare function fixedForwardRef<T, P = object>(render: React.ForwardRefRenderFunction<T, React.PropsWithoutRef<P>>): (props: P & React.RefAttributes<T>) => React.ReactNode;
7
6
  export default fixedForwardRef;
@@ -1,5 +1,4 @@
1
1
  import { default as React } from 'react';
2
-
3
2
  /**
4
3
  * Create a ref and point forwarded ref to it.
5
4
  *
@@ -1,4 +1,3 @@
1
1
  import { default as React } from 'react';
2
-
3
2
  declare const useToggle: (defaultValue?: boolean) => [boolean, React.DispatchWithoutAction];
4
3
  export default useToggle;
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.141",
5
+ "version": "0.0.143",
6
6
  "description": "Integration utilities for react-hook-form.",
7
7
  "type": "module",
8
8
  "sideEffects": false,
@@ -10,12 +10,12 @@
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/_exports/main.d.ts"
17
+ "default": "./dist/esm/index.mjs",
18
+ "types": "./dist/types/_exports/index.d.ts"
19
19
  }
20
20
  },
21
21
  "./group": {
File without changes
File without changes