@paragrav/rhf-utils 0.0.58 → 0.0.59
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FormSubmitError } from '../submit/error/FormSubmitError';
|
|
2
2
|
import { UseFormFieldsProps, UseFormOptions } from '../form/useForm';
|
|
3
|
+
import { _FormSlots } from '../form/_Form';
|
|
3
4
|
import { UseFormProps } from 'react-hook-form';
|
|
4
5
|
|
|
5
6
|
type Config = {
|
|
@@ -11,17 +12,12 @@ type Config = {
|
|
|
11
12
|
*/
|
|
12
13
|
options?: UseFormOptions;
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
+
* Components injected by slot.
|
|
15
16
|
*
|
|
16
|
-
* e.g., block navigation on dirty form.
|
|
17
|
+
* e.g., top: block navigation on dirty form.
|
|
18
|
+
* e.g., bottom: root errors list.
|
|
17
19
|
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Component injected at the bottom of the form.
|
|
21
|
-
*
|
|
22
|
-
* e.g., root errors list.
|
|
23
|
-
*/
|
|
24
|
-
ChildrenLast?: React.FC<UseFormFieldsProps>;
|
|
20
|
+
Children?: Partial<Record<_FormSlots, React.FC<UseFormFieldsProps>>>;
|
|
25
21
|
/**
|
|
26
22
|
* Handle non-{@link FormSubmitError} errors. Optionally, return {@link FormSubmitError} to merge into context errors.
|
|
27
23
|
*/
|
|
@@ -67,8 +63,7 @@ export declare const _getConfig: (options?: UseFormOptions) => {
|
|
|
67
63
|
criteriaMode: import('react-hook-form').CriteriaMode;
|
|
68
64
|
delayError: number;
|
|
69
65
|
}>, "mode" | "reValidateMode" | "resetOptions" | "context" | "shouldFocusError" | "shouldUnregister" | "shouldUseNativeValidation" | "progressive" | "criteriaMode" | "delayError"> | undefined;
|
|
70
|
-
|
|
71
|
-
ChildrenLast?: import('react').FC<UseFormFieldsProps> | undefined;
|
|
66
|
+
Children?: Partial<Record<_FormSlots, import('react').FC<UseFormFieldsProps>>> | undefined;
|
|
72
67
|
onSubmitError?: ((error: unknown) => FormSubmitError | undefined) | undefined;
|
|
73
68
|
};
|
|
74
69
|
export {};
|
|
@@ -3,6 +3,7 @@ import { z } from 'zod';
|
|
|
3
3
|
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { default as React } from 'react';
|
|
5
5
|
|
|
6
|
+
export type _FormSlots = 'top' | 'bottom';
|
|
6
7
|
export type _FormProps<TSchema extends z.ZodObject<FieldValues>, TFieldValues extends z.input<TSchema>, TTransformedValues extends z.output<TSchema>> = React.PropsWithChildren<Pick<UseFormProps<TSchema, TFieldValues, TTransformedValues>, 'form'> & {
|
|
7
8
|
formId: string;
|
|
8
9
|
formRef: React.RefObject<HTMLFormElement>;
|