11import { ReactNode } from "react" ;
2- import { DeepPartial , FieldPath , FieldValues , Resolver , SubmitHandler , useForm , UseFormReturn } from "react-hook-form" ;
2+ import { DeepPartial , FieldPath , FieldValues , Mode , Resolver , SubmitHandler , useForm , UseFormReturn } from "react-hook-form" ;
33import { jsonIsoDateReviver } from "./helpers/dateUtils" ;
44import { FormContext , FormContextProps } from "./context/FormContext" ;
55import { AutoSubmitConfig , useAutoSubmit } from "./hooks/useAutoSubmit" ;
@@ -12,6 +12,11 @@ interface FormProps<T extends FieldValues> {
1212 */
1313 onSubmit : SubmitHandler < T > ;
1414
15+ /**
16+ * The default validation mode of the form
17+ */
18+ mode ?: Mode ;
19+
1520 /**
1621 * the resolver for the validation
1722 */
@@ -70,13 +75,14 @@ const Form = <T extends FieldValues>({
7075 formRef,
7176 hideValidationMessages = false ,
7277 autoComplete,
78+ mode,
7379} : FormProps < T > ) => {
7480 const revivedDefaultValues = defaultValues
7581 ? ( JSON . parse ( JSON . stringify ( defaultValues ) , jsonIsoDateReviver ) as DeepPartial < T > )
7682 : defaultValues ;
7783
7884 const disableAriaAutocomplete = autoComplete === "off" ;
79- const formMethods = useForm < T > ( { resolver, defaultValues : revivedDefaultValues } ) ;
85+ const formMethods = useForm < T > ( { resolver, defaultValues : revivedDefaultValues , mode : mode } ) ;
8086 const autoSubmitHandler = useAutoSubmit ( { onSubmit, formMethods, autoSubmitConfig } ) ;
8187
8288 return (
0 commit comments