@paragrav/rhf-utils 0.0.61 → 0.0.62

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 (91) hide show
  1. package/dist/types/src/main.d.ts +1 -7
  2. package/package.json +1 -1
  3. package/README.md +0 -1
  4. package/dist/assets/index-BgBykTYQ.js +0 -40
  5. package/dist/index.html +0 -12
  6. package/dist/types/devtool/LazyDevTool.d.ts +0 -11
  7. package/dist/types/errors/consoleErrors.d.ts +0 -13
  8. package/dist/types/errors/context/index.d.ts +0 -10
  9. package/dist/types/errors/context/provider.d.ts +0 -12
  10. package/dist/types/errors/flat/flattenFieldErrors.d.ts +0 -15
  11. package/dist/types/errors/flat/getFlatFieldErrors.d.ts +0 -25
  12. package/dist/types/errors/flat/types.d.ts +0 -13
  13. package/dist/types/errors/flat/useFormFlatFieldErrorsMemo.d.ts +0 -5
  14. package/dist/types/errors/flat/useRefdFieldErrorsMemo.d.ts +0 -9
  15. package/dist/types/errors/isFieldError.d.ts +0 -7
  16. package/dist/types/errors/message/FormErrorMessage.d.ts +0 -8
  17. package/dist/types/errors/message/FormErrorMessageByPath.d.ts +0 -9
  18. package/dist/types/errors/nonfield/FormNonFieldErrorMarker.d.ts +0 -10
  19. package/dist/types/errors/nonfield/FormNonFieldErrorMarker.spec.d.ts +0 -1
  20. package/dist/types/errors/nonfield/FormNonFieldErrorMarker.utils.d.ts +0 -2
  21. package/dist/types/errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute.d.ts +0 -5
  22. package/dist/types/errors/nonfield/isNonFieldError.d.ts +0 -19
  23. package/dist/types/errors/orphan/getOrphansFromFieldErrors.d.ts +0 -5
  24. package/dist/types/errors/orphan/getOrphansFromFlatFieldErrors.d.ts +0 -4
  25. package/dist/types/errors/orphan/useFormHasOrphanAndNoFieldErrors.d.ts +0 -9
  26. package/dist/types/errors/orphan/useOrphanFormErrorsMemo.d.ts +0 -4
  27. package/dist/types/errors/orphan/useOrphanFormErrorsToConsole.d.ts +0 -9
  28. package/dist/types/errors/outputErrors.d.ts +0 -14
  29. package/dist/types/errors/root/FormRootErrors.d.ts +0 -7
  30. package/dist/types/errors/root/FormRootErrorsFromContext.d.ts +0 -3
  31. package/dist/types/errors/root/consts.d.ts +0 -1
  32. package/dist/types/errors/root/getRootsFromFieldErrors.d.ts +0 -5
  33. package/dist/types/errors/root/getRootsFromFlatFieldErrors.d.ts +0 -4
  34. package/dist/types/errors/root/isFormErrorPathRoot.d.ts +0 -6
  35. package/dist/types/errors/root/useRootFormFieldErrorsMemo.d.ts +0 -6
  36. package/dist/types/errors/useFormErrorConsoleDebug.d.ts +0 -8
  37. package/dist/types/errors/useFormErrorsEffect.d.ts +0 -4
  38. package/dist/types/errors/useFormErrorsIfAny.d.ts +0 -6
  39. package/dist/types/errors/useFormErrorsMemo.d.ts +0 -7
  40. package/dist/types/errors/useFormErrorsToConsole.d.ts +0 -14
  41. package/dist/types/errors/useFormRequestSubmit.d.ts +0 -6
  42. package/dist/types/exports.d.ts +0 -37
  43. package/dist/types/form/ErrorBoundary.d.ts +0 -15
  44. package/dist/types/form/Form.d.ts +0 -30
  45. package/dist/types/form/FormBase.d.ts +0 -9
  46. package/dist/types/form/FormWithProviders.d.ts +0 -13
  47. package/dist/types/form/context/FormProvider.d.ts +0 -16
  48. package/dist/types/form/context/group/FormGroupContextProvider.d.ts +0 -5
  49. package/dist/types/form/context/group/index.d.ts +0 -15
  50. package/dist/types/form/context/group/useFormGroupChildIsMountedTracker.d.ts +0 -2
  51. package/dist/types/form/context/group/useFormGroupChildIsSubmittingTracker.d.ts +0 -2
  52. package/dist/types/form/context/group/useFormGroupIsAnyBusy.d.ts +0 -2
  53. package/dist/types/form/context/group/useFormGroupIsChildBusy.d.ts +0 -2
  54. package/dist/types/form/context/group/useFormGroupIsParentBusy.d.ts +0 -2
  55. package/dist/types/form/context/group/useFormGroupParentTracker.d.ts +0 -7
  56. package/dist/types/form/context/utils/FormUtilsContextProvider.d.ts +0 -15
  57. package/dist/types/form/context/utils/useFormUtilsContext.d.ts +0 -9
  58. package/dist/types/form/search/FormSearch.d.ts +0 -32
  59. package/dist/types/form/search/FormSearchHiddenInputs.d.ts +0 -13
  60. package/dist/types/form/search/getNewSearchParams.d.ts +0 -2
  61. package/dist/types/form/useForm.d.ts +0 -30
  62. package/dist/types/form/useFormIsBusy.d.ts +0 -2
  63. package/dist/types/form/useFormOrParentIsBusy.d.ts +0 -2
  64. package/dist/types/form/useFormWithProviders.d.ts +0 -31
  65. package/dist/types/form/utils/getSubmitterButtonData.d.ts +0 -11
  66. package/dist/types/isEmptyObject.d.ts +0 -2
  67. package/dist/types/main.d.ts +0 -1
  68. package/dist/types/src/config/index.d.ts +0 -69
  69. package/dist/types/src/form/ErrorBoundary.d.ts +0 -15
  70. package/dist/types/src/form/Form.d.ts +0 -29
  71. package/dist/types/src/form/FormBase.d.ts +0 -9
  72. package/dist/types/src/form/context/FormProvider.d.ts +0 -15
  73. package/dist/types/src/form/search/FormSearch.d.ts +0 -32
  74. package/dist/types/src/form/search/FormSearchHiddenInputs.d.ts +0 -13
  75. package/dist/types/src/form/search/getNewSearchParams.d.ts +0 -2
  76. package/dist/types/src/form/useFormOrParentIsBusy.d.ts +0 -2
  77. package/dist/types/src/form/useFormWithProviders.d.ts +0 -31
  78. package/dist/types/src/isEmptyObject.d.ts +0 -2
  79. package/dist/types/src/submit/error/handleFormSubmitError.d.ts +0 -7
  80. package/dist/types/submit/error/FormSubmitError.d.ts +0 -6
  81. package/dist/types/submit/error/handleFormSubmitError.d.ts +0 -7
  82. package/dist/types/submit/useFormOnSubmitSuccessful.d.ts +0 -2
  83. package/dist/types/submit/useFormOnSubmitSuccessfulAndReset.d.ts +0 -13
  84. package/dist/types/submit/useResetFormOnSubmitError.d.ts +0 -7
  85. package/dist/types/submit/useResetFormOnSubmitSuccessful.d.ts +0 -12
  86. package/dist/types/submit/useSubmitFormOnChange.d.ts +0 -4
  87. package/dist/types/utils/createContext.d.ts +0 -8
  88. package/dist/types/utils/fixedForwardRef.d.ts +0 -7
  89. package/dist/types/utils/useImperativeForwardedRef.d.ts +0 -11
  90. package/dist/types/utils/useThrowAsyncError.d.ts +0 -5
  91. package/dist/types/utils/useToggle.d.ts +0 -4
@@ -1,2 +0,0 @@
1
- export declare const getFormNonFieldErrorMarkerQuerySelector: (path: string) => string;
2
- export declare const hasNonFieldErrorMarkerInDOM: (path: string, parentElement: Pick<HTMLElement, 'querySelector'>) => boolean;
@@ -1,5 +0,0 @@
1
- /**
2
- * HTML data attribute for {@link FormNonFieldErrorMarker}.
3
- */
4
- declare const FormNonFieldErrorMarkerHtmlAttribute = "data-paragrav-rhf-utils-nonfield-error-marker-path";
5
- export default FormNonFieldErrorMarkerHtmlAttribute;
@@ -1,19 +0,0 @@
1
- import { FieldError } from 'react-hook-form';
2
-
3
- /**
4
- * Determine if {@link FieldError} is a non-field error (i.e., has no `ref`).
5
- *
6
- * A non-field error has no association to an input via {@link FieldError.ref}.
7
- *
8
- * These fall into one of two categories:
9
- * - Root, which are typically displayed to user at bottom/top of form.
10
- * - Non-root, which fall into two main sub-sets:
11
- * - Non-orphan (displayed -- typically manually)
12
- * - e.g., array min/max validation
13
- * - Orphan (undisplayed), which are typically caused by one of the following cases:
14
- * - The input is missing.
15
- * - The schema is incorrect.
16
- * - The error is not displayed to user with `FormErrorNonFieldMarker`.
17
- */
18
- declare const isNonFieldError: (error: FieldError) => boolean;
19
- export default isNonFieldError;
@@ -1,5 +0,0 @@
1
- import { FlatFieldErrors } from '../flat/types';
2
- import { FieldErrors } from 'react-hook-form';
3
-
4
- declare const getOrphansFromFieldErrors: (errors: FieldErrors, parentElement: Pick<HTMLElement, 'querySelector'>) => FlatFieldErrors;
5
- export default getOrphansFromFieldErrors;
@@ -1,4 +0,0 @@
1
- import { FlatFieldErrors } from '../flat/types';
2
-
3
- declare const getOrphansFromFlatFieldErrors: (errors: FlatFieldErrors, parentElement: Pick<HTMLElement, 'querySelector'>) => FlatFieldErrors;
4
- export default getOrphansFromFlatFieldErrors;
@@ -1,9 +0,0 @@
1
- /**
2
- * Determined if there are orphan errors and no field errors.
3
- * (May be useful when reporting or displaying a specific message to user.)
4
- * RHF doesn't seem to have any other mechanism to indicate a failed submit but to `setErrors()`.
5
- * Therefore, we have no way of distinguishing between "placeholder" root error and actual error.
6
- * (e.g., "Please fix form errors above." vs "Start date must be less than end date.")
7
- */
8
- declare const useFormHasOrphanAndNoFieldErrors: (formRef: React.RefObject<HTMLFormElement>) => boolean;
9
- export default useFormHasOrphanAndNoFieldErrors;
@@ -1,4 +0,0 @@
1
- import { default as React } from 'react';
2
-
3
- declare const useOrphanFormErrorsMemo: (formRef: React.RefObject<HTMLFormElement>) => import('../flat/types').FlatFieldErrors;
4
- export default useOrphanFormErrorsMemo;
@@ -1,9 +0,0 @@
1
- import { default as React } from 'react';
2
-
3
- /**
4
- * Logs out orphan errors to console.error.
5
- *
6
- * When `isDev`, it will also throw an error to bring attention to dev.
7
- */
8
- declare const useOrphanFormErrorsToConsole: (formRef: React.RefObject<HTMLFormElement>, isDev?: boolean, enabled?: boolean) => void;
9
- export default useOrphanFormErrorsToConsole;
@@ -1,14 +0,0 @@
1
- import { FieldErrors, FieldValues } from 'react-hook-form';
2
-
3
- /**
4
- * Output form values and errors to console and throw in dev.
5
- */
6
- declare const outputErrors: (message: string, form: {
7
- values: FieldValues;
8
- errors: FieldErrors;
9
- }, options?: {
10
- other?: Record<string, unknown>;
11
- isDev?: boolean;
12
- isError?: boolean;
13
- }) => void;
14
- export default outputErrors;
@@ -1,7 +0,0 @@
1
- import { FlatFieldErrors } from '../flat/types';
2
-
3
- type Props = React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement> & {
4
- errors: FlatFieldErrors;
5
- };
6
- declare const FormRootErrors: React.FC<Props>;
7
- export default FormRootErrors;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- declare const FormRootErrorsFromContext: React.FC;
3
- export default FormRootErrorsFromContext;
@@ -1 +0,0 @@
1
- export declare const FormErrorPathRoot = "root";
@@ -1,5 +0,0 @@
1
- import { FlatFieldErrors } from '../flat/types';
2
- import { FieldErrors } from 'react-hook-form';
3
-
4
- declare const getRootsFromFieldErrors: (errors: FieldErrors) => FlatFieldErrors;
5
- export default getRootsFromFieldErrors;
@@ -1,4 +0,0 @@
1
- import { FlatFieldErrors } from '../flat/types';
2
-
3
- declare const getRootsFromFlatFieldErrors: (errors: FlatFieldErrors) => FlatFieldErrors;
4
- export default getRootsFromFlatFieldErrors;
@@ -1,6 +0,0 @@
1
- /**
2
- * Determine if an error path is root. (e.g., `root` or `root.nested`)
3
- * @param path Flat path. (e.g., 'root.nested')
4
- */
5
- declare const isFormErrorPathRoot: (path: string) => boolean;
6
- export default isFormErrorPathRoot;
@@ -1,6 +0,0 @@
1
- /**
2
- * Root field errors from form.
3
- * These are typically displayed at the bottom of the form.
4
- */
5
- declare const useRootFormFieldErrorsMemo: () => import('../flat/types').FlatFieldErrors;
6
- export default useRootFormFieldErrorsMemo;
@@ -1,8 +0,0 @@
1
- /**
2
- * Output form errors to console.debug() for easier debugging for certain condition.
3
- * (e.g., in dev/staging environments or certain users)
4
- *
5
- * `console.debug()` is unlikely to trigger any automated console capture reporting.
6
- */
7
- declare const useFormErrorConsoleDebug: (enabled?: boolean) => void;
8
- export default useFormErrorConsoleDebug;
@@ -1,4 +0,0 @@
1
- import { FieldErrors } from 'react-hook-form';
2
-
3
- declare const useFormErrorsEffect: <TReturn>(callback: (errors: FieldErrors) => TReturn) => void;
4
- export default useFormErrorsEffect;
@@ -1,6 +0,0 @@
1
- /**
2
- * Returns errors only if there are errors.
3
- * Allows simple typeguard without `isEmpty` dependency.
4
- */
5
- declare const useFormErrorsIfAny: () => false | import('react-hook-form').FieldErrors<import('react-hook-form').FieldValues>;
6
- export default useFormErrorsIfAny;
@@ -1,7 +0,0 @@
1
- import { FieldErrors } from 'react-hook-form';
2
-
3
- /**
4
- * Create memoized value from form errors.
5
- */
6
- declare const useFormErrorsMemo: <TReturn>(callback: (errors: FieldErrors) => TReturn) => TReturn;
7
- export default useFormErrorsMemo;
@@ -1,14 +0,0 @@
1
- import { FlatFieldErrors } from './flat/types';
2
-
3
- /**
4
- * Logs out orphan errors to console.error.
5
- *
6
- * When `isDev`, it will also throw an error to bring attention to dev.
7
- */
8
- declare const useFormErrorsToConsole: (message: string, flatErrors: FlatFieldErrors, options?: {
9
- disabled?: boolean;
10
- isDev?: boolean;
11
- isError?: boolean;
12
- data?: Record<string, unknown>;
13
- }) => void;
14
- export default useFormErrorsToConsole;
@@ -1,6 +0,0 @@
1
- /**
2
- * Get callback to trigger submit manually on form.
3
- * @link https://developer.mozilla.org/docs/Web/API/HTMLFormElement/requestSubmit
4
- */
5
- declare const useFormRequestSubmit: (ref: React.RefObject<HTMLFormElement>) => HTMLFormElement['requestSubmit'];
6
- export default useFormRequestSubmit;
@@ -1,37 +0,0 @@
1
- export { default as LazyDevTool } from './devtool/LazyDevTool';
2
- export { default as useFormErrorsFlatContext } from './errors/context';
3
- export { default as FormErrorsFlatContextProvider } from './errors/context/provider';
4
- export { default as FormErrorMessage } from './errors/message/FormErrorMessage';
5
- export { default as FormErrorMessageByPath } from './errors/message/FormErrorMessageByPath';
6
- export { default as FormNonFieldErrorMarker } from './errors/nonfield/FormNonFieldErrorMarker';
7
- export { default as FormNonFieldErrorMarkerHtmlAttribute } from './errors/nonfield/FormNonFieldErrorMarkerHtmlAttribute';
8
- export { default as useFormHasOrphanAndNoFieldErrors } from './errors/orphan/useFormHasOrphanAndNoFieldErrors';
9
- export { default as useOrphanFormErrorsMemo } from './errors/orphan/useOrphanFormErrorsMemo';
10
- export { default as useOrphanFormErrorsToConsole } from './errors/orphan/useOrphanFormErrorsToConsole';
11
- export { default as useRootFormFieldErrorsMemo } from './errors/root/useRootFormFieldErrorsMemo';
12
- export { default as useFormErrorConsoleDebug } from './errors/useFormErrorConsoleDebug';
13
- export { default as useFormErrorsEffect } from './errors/useFormErrorsEffect';
14
- export { default as useFormErrorsIfAny } from './errors/useFormErrorsIfAny';
15
- export { default as useFormErrorsMemo } from './errors/useFormErrorsMemo';
16
- export { default as useFormRequestSubmit } from './errors/useFormRequestSubmit';
17
- export { default as Form } from './form/Form';
18
- export { default as FormWithProviders } from './form/FormWithProviders';
19
- export { default as useForm } from './form/useForm';
20
- export { default as useFormWithProviders } from './form/useFormWithProviders';
21
- export { default as FormProvider } from './form/context/FormProvider';
22
- export { default as FormUtilsContextProvider } from './form/context/utils/FormUtilsContextProvider';
23
- export { default as useFormUtilsContext } from './form/context/utils/useFormUtilsContext';
24
- export { default as FormGroupContextProvider } from './form/context/group/FormGroupContextProvider';
25
- export { default as useFormGroupChildIsMountedTracker } from './form/context/group/useFormGroupChildIsMountedTracker';
26
- export { default as useFormGroupChildIsSubmittingTracker } from './form/context/group/useFormGroupChildIsSubmittingTracker';
27
- export { default as useFormGroupIsAnyBusy } from './form/context/group/useFormGroupIsAnyBusy';
28
- export { default as useFormGroupIsChildBusy } from './form/context/group/useFormGroupIsChildBusy';
29
- export { default as useFormGroupIsParentBusy } from './form/context/group/useFormGroupIsParentBusy';
30
- export { default as useFormGroupParentTracker } from './form/context/group/useFormGroupParentTracker';
31
- export { default as getSubmitterButtonData } from './form/utils/getSubmitterButtonData';
32
- export { FormSubmitError } from './submit/error/FormSubmitError';
33
- export { default as useFormOnSubmitSuccessful } from './submit/useFormOnSubmitSuccessful';
34
- export { default as useFormOnSubmitSuccessfulAndReset } from './submit/useFormOnSubmitSuccessfulAndReset';
35
- export { default as useResetFormOnSubmitError } from './submit/useResetFormOnSubmitError';
36
- export { default as useResetFormAfterSubmitSuccessful } from './submit/useResetFormOnSubmitSuccessful';
37
- export { default as useSubmitFormOnChange } from './submit/useSubmitFormOnChange';
@@ -1,15 +0,0 @@
1
- import { default as React } from 'react';
2
-
3
- type Props = React.PropsWithChildren;
4
- type State = {
5
- error: null | Error;
6
- };
7
- export declare class ErrorBoundary extends React.Component<Props, State> {
8
- state: State;
9
- static getDerivedStateFromError(error: Error): {
10
- error: Error;
11
- };
12
- componentDidCatch(error: unknown, errorInfo: React.ErrorInfo): void;
13
- render(): string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
14
- }
15
- export {};
@@ -1,30 +0,0 @@
1
- import { FormBaseProps } from './FormBase';
2
- import { FieldValues, SubmitErrorHandler, UseFormReturn } from 'react-hook-form';
3
- import { default as React } from 'react';
4
- import { DevtoolUIProps } from '@hookform/devtools/dist/devToolUI';
5
-
6
- export type FormProps<TFieldValues extends FieldValues, TTransformedValues extends FieldValues> = React.PropsWithChildren<Pick<FormBaseProps, 'onChange'> & {
7
- isDev: boolean;
8
- formId?: string;
9
- formRef?: React.RefObject<HTMLFormElement>;
10
- Fields?: React.FC<{
11
- ctx: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
12
- }>;
13
- onSubmit?: (values: TTransformedValues, context: UseFormReturn<TFieldValues, unknown, TTransformedValues>, event: React.BaseSyntheticEvent<SubmitEvent>) => unknown | Promise<unknown>;
14
- /** Submit error handler. (Only for errors not of instance `FormError`, which are handled internally.) */
15
- onSubmitError?: (error: unknown, context: UseFormReturn<TFieldValues, unknown, TTransformedValues>, event: React.BaseSyntheticEvent<SubmitEvent>) => void;
16
- /** Submit handler when form is invalid. */
17
- onSubmitInvalid?: SubmitErrorHandler<TFieldValues>;
18
- options?: {
19
- hideRootErrors?: boolean;
20
- /** Request submit via listener on form change. */
21
- submitOnChange?: boolean;
22
- /** Reset form values if submit throw errors. Use case: optimistic UI toggle form that submits on each change */
23
- resetValuesOnSubmitError?: boolean;
24
- stopSubmitPropagation?: boolean;
25
- devTool?: DevtoolUIProps | 'disabled';
26
- };
27
- className?: string;
28
- }>;
29
- declare function Form<TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ isDev, formId, formRef, Fields, onSubmit, onSubmitError, onSubmitInvalid, options, children, ...props }: FormProps<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
30
- export default Form;
@@ -1,9 +0,0 @@
1
- import { default as React } from 'react';
2
-
3
- export type FormBaseProps = React.PropsWithoutRef<JSX.IntrinsicElements['form']> & {
4
- antiCsrfToken?: string;
5
- };
6
- declare const _default: (props: Omit<React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & {
7
- antiCsrfToken?: string | undefined;
8
- } & React.RefAttributes<HTMLFormElement>) => React.ReactNode;
9
- export default _default;
@@ -1,13 +0,0 @@
1
- import { UseFormProps } from './useForm';
2
- import { FieldValues } from 'react-hook-form';
3
-
4
- export type FormWithProviders<TFieldValues extends FieldValues, TTransformedValues extends FieldValues> = React.PropsWithChildren<UseFormProps<TFieldValues, TTransformedValues>>;
5
- /**
6
- * {@link FormProvider} (and utils) with immediate descendent {@link Form}.
7
- * (Syntactic sugar for {@link useForm}. Use this for most applications.)
8
- *
9
- * Use {@link useForm} if you need to specific nesting hierarchy.
10
- * (e.g., wrapping `<tr>` with provider and nesting `<form>` within `<td>` to appease HTML rules.)
11
- */
12
- declare function FormWithProviders<TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ children, ...props }: FormWithProviders<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
13
- export default FormWithProviders;
@@ -1,16 +0,0 @@
1
- import { FormUtilsContextProviderProps } from './utils/FormUtilsContextProvider';
2
- import { FormProps } from '../Form';
3
- import { FieldValues, UseFormReturn } from 'react-hook-form';
4
-
5
- type Props<TFieldValues extends FieldValues, // input values
6
- TTransformedValues extends FieldValues> = React.PropsWithChildren<{
7
- isDev: boolean;
8
- formId: string;
9
- formRef: React.RefObject<HTMLFormElement>;
10
- rhf: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
11
- } & {
12
- form?: Omit<FormProps<TFieldValues, TTransformedValues>, 'isDev' | 'formRef' | 'formId'>;
13
- utils?: FormUtilsContextProviderProps;
14
- }>;
15
- declare function FormProvider<TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ isDev, formId, formRef, rhf, form, utils, children, }: Props<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
16
- export default FormProvider;
@@ -1,5 +0,0 @@
1
- import { default as React } from 'react';
2
-
3
- type Props = React.PropsWithChildren;
4
- declare const FormGroupContextProvider: React.FC<Props>;
5
- export default FormGroupContextProvider;
@@ -1,15 +0,0 @@
1
- /// <reference types="react" />
2
- export type FormGroupContext = {
3
- /** Dependent forms. */
4
- children: {
5
- busyIds: string[];
6
- busyCount: number;
7
- setBusyId: (id: string, isBusy: boolean) => void;
8
- };
9
- /** Main form. */
10
- parent: {
11
- isBusy: boolean;
12
- setIsBusy: (isBusy: boolean) => void;
13
- };
14
- };
15
- export declare const _useFormGroupContextMaybe: () => FormGroupContext | undefined, _useFormGroupContext: () => FormGroupContext, _FormGroupContextProvider: import('react').Provider<FormGroupContext | undefined>;
@@ -1,2 +0,0 @@
1
- declare const useFormGroupChildIsMountedTracker: () => void;
2
- export default useFormGroupChildIsMountedTracker;
@@ -1,2 +0,0 @@
1
- declare const useFormGroupChildIsSubmittingTracker: () => void;
2
- export default useFormGroupChildIsSubmittingTracker;
@@ -1,2 +0,0 @@
1
- declare const useFormGroupIsAnyBusy: () => boolean;
2
- export default useFormGroupIsAnyBusy;
@@ -1,2 +0,0 @@
1
- declare const useFormGroupIsChildBusy: () => boolean;
2
- export default useFormGroupIsChildBusy;
@@ -1,2 +0,0 @@
1
- declare const useFormGroupIsParentBusy: () => boolean;
2
- export default useFormGroupIsParentBusy;
@@ -1,7 +0,0 @@
1
- /**
2
- * Connect specific form state as parent context.
3
- *
4
- * Requires usage of provider.
5
- */
6
- declare const useFormGroupParentTracker: () => void;
7
- export default useFormGroupParentTracker;
@@ -1,15 +0,0 @@
1
- import { FormProps } from '../../Form';
2
- import { FieldValues } from 'react-hook-form';
3
-
4
- export type FormUtilsContextProviderProps = {
5
- /** Callback after successful submit, and form reset. */
6
- onSubmitSuccessfulAndReset?: () => void;
7
- };
8
- type Props<TFieldValues extends FieldValues, TTransformedValues extends FieldValues> = React.PropsWithChildren<{
9
- isDev: boolean;
10
- formId: string;
11
- formRef: React.RefObject<HTMLFormElement>;
12
- formProps?: Omit<FormProps<TFieldValues, TTransformedValues>, 'isDev' | 'formRef' | 'formId'>;
13
- } & FormUtilsContextProviderProps>;
14
- declare function FormUtilsContextProvider<TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ isDev, formRef, onSubmitSuccessfulAndReset, children, }: Props<TFieldValues, TTransformedValues>): import("react/jsx-runtime").JSX.Element;
15
- export default FormUtilsContextProvider;
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- export type FormUtilsContext = {
3
- formRef: React.RefObject<HTMLFormElement>;
4
- /** Callback to trigger submit manually -- e.g., on change. */
5
- requestSubmit: HTMLFormElement['requestSubmit'];
6
- };
7
- declare const useFormUtilsContext: () => FormUtilsContext, _FormUtilsContextProvider: import('react').Provider<FormUtilsContext | undefined>;
8
- export default useFormUtilsContext;
9
- export { _FormUtilsContextProvider };
@@ -1,32 +0,0 @@
1
- import { FormBaseProps } from '../FormBase';
2
- import { z } from 'zod';
3
- import { default as React } from 'react';
4
-
5
- declare const _default: <TSchema extends z.ZodTypeAny, TSchemaOutput extends z.output<TSchema> = z.output<TSchema>>(props: Omit<FormBaseProps, "children" | "onSubmit"> & {
6
- /**
7
- * Search params schema.
8
- *
9
- * Make sure all properties are marked as `optional().catch(undefiend)` to avoid errors from parsing.
10
- */
11
- schema: TSchema;
12
- /** Current search params. */
13
- search: NoInfer<TSchemaOutput>;
14
- Fields: React.FC<{
15
- search: TSchemaOutput;
16
- isSubmitting: boolean;
17
- }>;
18
- /**
19
- * Callback to handle form submission.
20
- * @param search New search params.
21
- * @param data Sanitized form data.
22
- * @param event Form submit event.
23
- */
24
- onSubmit?: ((search: TSchemaOutput, data: TSchemaOutput, event: React.FormEvent<HTMLFormElement>) => unknown) | undefined;
25
- /**
26
- * Error handler.
27
- *
28
- * Obviates need for consumer `try/catch`.
29
- */
30
- onSubmitError?: ((error: unknown, search: TSchemaOutput, data: TSchemaOutput, event: React.FormEvent<HTMLFormElement>) => void) | undefined;
31
- } & React.RefAttributes<HTMLFormElement>) => React.ReactNode;
32
- export default _default;
@@ -1,13 +0,0 @@
1
- import { default as React } from 'react';
2
- import { Stringifiable } from 'query-string';
3
-
4
- /**
5
- * Generate hidden inputs from the current search query string.
6
- * This allows form to not require JS.
7
- */
8
- declare const FormSearchHiddenInputs: React.FC<{
9
- search: Record<string, Stringifiable>;
10
- /** Keys to ignore. i.e., they have inputs. */
11
- include: string[];
12
- }>;
13
- export default FormSearchHiddenInputs;
@@ -1,2 +0,0 @@
1
- declare const getNewSearchParams: <TSearchParams extends Record<string, unknown>>(current: TSearchParams | undefined, update: TSearchParams) => TSearchParams;
2
- export default getNewSearchParams;
@@ -1,30 +0,0 @@
1
- import { FormProps } from './Form';
2
- import { FieldValues, UseFormProps as RhfUseFormProps } from 'react-hook-form';
3
- import { default as React } from 'react';
4
-
5
- export type UseFormProps<TFieldValues extends FieldValues, TTransformedValues extends FieldValues> = {
6
- isDev: boolean;
7
- /** {@link RhfUseFormProps} props for RHF's {@link useRhfForm}. */
8
- rhf?: RhfUseFormProps<TFieldValues>;
9
- /** {@link FormProps} props for Form. */
10
- form?: Omit<FormProps<TFieldValues, TTransformedValues>, 'isDev' | 'formId' | 'formRef'>;
11
- };
12
- export type UseFormReturn = ReturnType<typeof useForm>;
13
- /**
14
- * Base Rhf Form hook. Use `Form` in `index.ts` for most cases.
15
- * Use this if you need to separate form components.
16
- * e.g., a form for table row due to `form` being considered invalid HTML around `tr` tags.
17
- * With this hook, you can wrap the `tr` tag with `form.Provider` and use `form.Form` inside
18
- * one of the cells. Other components can be outside form while referring to form by its id via `form` attribute.
19
- * see https://caniuse.com/?search=form%20attribute
20
- * @returns Form provider and form.
21
- */
22
- declare const useForm: <TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ isDev, rhf, form, }: UseFormProps<TFieldValues, TTransformedValues>) => {
23
- readonly id: string;
24
- readonly ref: React.RefObject<HTMLFormElement>;
25
- readonly context: import('react-hook-form').UseFormReturn<TFieldValues, unknown, TTransformedValues>;
26
- readonly Form: React.FC<{
27
- children?: React.ReactNode;
28
- }>;
29
- };
30
- export default useForm;
@@ -1,2 +0,0 @@
1
- declare const useFormIsBusy: () => boolean;
2
- export default useFormIsBusy;
@@ -1,2 +0,0 @@
1
- declare const useFormOrParentIsBusy: () => boolean;
2
- export default useFormOrParentIsBusy;
@@ -1,31 +0,0 @@
1
- import { UseFormProps } from './useForm';
2
- import { FormUtilsContextProviderProps } from './context/utils/FormUtilsContextProvider';
3
- import { FieldValues } from 'react-hook-form';
4
- import { default as React } from 'react';
5
-
6
- export type UseFormWithProvidersProps<TFieldValues extends FieldValues, TTransformedValues extends FieldValues> = UseFormProps<TFieldValues, TTransformedValues> & {
7
- /** {@link FormUtilsContextProviderProps} props for `FormUtilsContextProvider`. */
8
- utils?: FormUtilsContextProviderProps;
9
- };
10
- export type UseFormWithProvidersReturn = ReturnType<typeof useFormWithProviders>;
11
- /**
12
- * Base Rhf Form hook. Use `Form` in `index.ts` for most cases.
13
- * Use this if you need to separate form components.
14
- * e.g., a form for table row due to `form` being considered invalid HTML around `tr` tags.
15
- * With this hook, you can wrap the `tr` tag with `form.Provider` and use `form.Form` inside
16
- * one of the cells. Other components can be outside form while referring to form by its id via `form` attribute.
17
- * see https://caniuse.com/?search=form%20attribute
18
- * @returns Form provider and form.
19
- */
20
- declare const useFormWithProviders: <TFieldValues extends FieldValues, TTransformedValues extends FieldValues>({ isDev, rhf, form, utils, }: UseFormWithProvidersProps<TFieldValues, TTransformedValues>) => {
21
- readonly Provider: React.FC<{
22
- children?: React.ReactNode;
23
- }>;
24
- readonly id: string;
25
- readonly ref: React.RefObject<HTMLFormElement>;
26
- readonly context: import('react-hook-form').UseFormReturn<TFieldValues, unknown, TTransformedValues>;
27
- readonly Form: React.FC<{
28
- children?: React.ReactNode;
29
- }>;
30
- };
31
- export default useFormWithProviders;
@@ -1,11 +0,0 @@
1
- import { default as React } from 'react';
2
-
3
- /**
4
- * Get [name, value] of button/input that submitted form.
5
- * Useful when determining user intent
6
- */
7
- declare const getSubmitterButtonData: (event: React.BaseSyntheticEvent) => [
8
- name: string,
9
- value: string
10
- ] | undefined;
11
- export default getSubmitterButtonData;
@@ -1,2 +0,0 @@
1
- declare const isEmptyObject: (obj: Record<string, unknown>) => boolean;
2
- export default isEmptyObject;
@@ -1 +0,0 @@
1
- export {};
@@ -1,69 +0,0 @@
1
- import { FormSubmitError } from '../submit/error/FormSubmitError';
2
- import { UseFormFieldsProps, UseFormOptions } from '../form/useForm';
3
- import { _FormSlots } from '../form/_Form';
4
- import { UseFormProps } from 'react-hook-form';
5
-
6
- type Config = {
7
- rhf?: Pick<UseFormProps, 'mode' | 'reValidateMode' | 'resetOptions' | 'context' | 'shouldFocusError' | 'shouldUnregister' | 'shouldUseNativeValidation' | 'progressive' | 'criteriaMode' | 'delayError'>;
8
- /**
9
- * Default global options settings.
10
- *
11
- * Extend this type to inject custom options/functionality via `Children` component.
12
- */
13
- options?: UseFormOptions;
14
- /**
15
- * Components injected by slot.
16
- *
17
- * e.g., top: block navigation on dirty form.
18
- * e.g., bottom: root errors list.
19
- */
20
- Children?: Partial<Record<_FormSlots, React.FC<UseFormFieldsProps>>>;
21
- /**
22
- * Handle non-{@link FormSubmitError} errors. Optionally, return {@link FormSubmitError} to merge into context errors.
23
- */
24
- onSubmitError?: (error: unknown) => FormSubmitError | undefined;
25
- };
26
- export declare const setConfig: (config: Config) => void;
27
- export declare const _getConfig: (options?: UseFormOptions) => {
28
- options: {
29
- classNames: string[];
30
- submitOnChange?: boolean | undefined;
31
- resetValuesOnSubmitError?: boolean | undefined;
32
- stopSubmitPropagation?: boolean | undefined;
33
- devTool?: import('@hookform/devtools/dist/devToolUI').DevtoolUIProps | "disabled" | undefined;
34
- };
35
- rhf?: Pick<Partial<{
36
- mode: "onBlur" | "onChange" | "onSubmit" | "onTouched" | "all";
37
- disabled: boolean;
38
- reValidateMode: "onBlur" | "onChange" | "onSubmit";
39
- defaultValues: {
40
- [x: string]: any;
41
- } | ((payload?: unknown) => Promise<import('react-hook-form').FieldValues>);
42
- values: import('react-hook-form').FieldValues;
43
- errors: import('react-hook-form').FieldErrors<import('react-hook-form').FieldValues>;
44
- resetOptions: Partial<{
45
- keepDirtyValues: boolean;
46
- keepErrors: boolean;
47
- keepDirty: boolean;
48
- keepValues: boolean;
49
- keepDefaultValues: boolean;
50
- keepIsSubmitted: boolean;
51
- keepIsSubmitSuccessful: boolean;
52
- keepTouched: boolean;
53
- keepIsValidating: boolean;
54
- keepIsValid: boolean;
55
- keepSubmitCount: boolean;
56
- }> | undefined;
57
- resolver: import('react-hook-form').Resolver<import('react-hook-form').FieldValues, any>;
58
- context: any;
59
- shouldFocusError: boolean;
60
- shouldUnregister: boolean;
61
- shouldUseNativeValidation: boolean;
62
- progressive: boolean;
63
- criteriaMode: import('react-hook-form').CriteriaMode;
64
- delayError: number;
65
- }>, "mode" | "reValidateMode" | "resetOptions" | "context" | "shouldFocusError" | "shouldUnregister" | "shouldUseNativeValidation" | "progressive" | "criteriaMode" | "delayError"> | undefined;
66
- Children?: Partial<Record<_FormSlots, import('react').FC<UseFormFieldsProps>>> | undefined;
67
- onSubmitError?: ((error: unknown) => FormSubmitError | undefined) | undefined;
68
- };
69
- export {};