@@ -17,6 +17,7 @@ import { cn } from '@/utils';
1717
1818import { Button } from '../Button' ;
1919import { Heading } from '../Heading' ;
20+ import { Separator } from '../Separator' ;
2021import { ErrorMessage } from './ErrorMessage' ;
2122import { FieldsComponent } from './FieldsComponent' ;
2223import { getInitialValues } from './utils' ;
@@ -38,7 +39,9 @@ type FormProps<TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<T
3839 fieldsFooter ?: React . ReactNode ;
3940 id ?: string ;
4041 initialValues ?: PartialNullableFormDataType < NoInfer < TData > > ;
41- onBeforeSubmit ?: ( data : NoInfer < TData > ) => Promisable < { errorMessage : string ; success : false } | { success : true } > ;
42+ onBeforeSubmit ?:
43+ | ( ( data : NoInfer < TData > ) => Promisable < { errorMessage : string ; success : false } | { success : true } > )
44+ | null ;
4245 onError ?: ( error : z . ZodError < NoInfer < TData > > ) => void ;
4346 onSubmit : ( data : NoInfer < TData > ) => Promisable < void > ;
4447 preventResetValuesOnReset ?: boolean ;
@@ -165,7 +168,7 @@ const Form = <TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<TS
165168 return (
166169 < form
167170 autoComplete = "off"
168- className = { twMerge ( 'relative w-full' , isGrouped ? 'space-y-8 divide-y' : 'space-y -6', className ) }
171+ className = { twMerge ( 'relative flex w-full flex-col ' , ! isGrouped && 'gap -6', className ) }
169172 id = { id }
170173 onBlur = { revalidateOnBlur ? revalidate : undefined }
171174 onSubmit = { ( event ) => void handleSubmit ( event ) }
@@ -175,26 +178,29 @@ const Form = <TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<TS
175178 { isGrouped ? (
176179 content . map ( ( fieldGroup , i ) => {
177180 return (
178- < div className = "flex flex-col space-y-6 [&:not(:first-child)]:pt-8" key = { i } >
179- < div className = "space-y-1" >
180- { fieldGroup . title && (
181- < Heading className = "text-base" variant = "h4" >
182- { fieldGroup . title }
183- </ Heading >
184- ) }
185- { fieldGroup . description && (
186- < p className = "text-muted-foreground text-sm leading-tight italic" > { fieldGroup . description } </ p >
187- ) }
181+ < >
182+ < div className = "flex flex-col gap-6 [&:not(:first-child)]:pt-8" key = { i } >
183+ < div className = "flex flex-col gap-1" >
184+ { fieldGroup . title && (
185+ < Heading className = "text-base" variant = "h4" >
186+ { fieldGroup . title }
187+ </ Heading >
188+ ) }
189+ { fieldGroup . description && (
190+ < p className = "text-muted-foreground text-sm leading-tight italic" > { fieldGroup . description } </ p >
191+ ) }
192+ </ div >
193+ < FieldsComponent
194+ errors = { errors }
195+ fields = { fieldGroup . fields as FormFields < TData > }
196+ readOnly = { readOnly }
197+ setErrors = { setErrors }
198+ setValues = { setValues }
199+ values = { values }
200+ />
188201 </ div >
189- < FieldsComponent
190- errors = { errors }
191- fields = { fieldGroup . fields as FormFields < TData > }
192- readOnly = { readOnly }
193- setErrors = { setErrors }
194- setValues = { setValues }
195- values = { values }
196- />
197- </ div >
202+ < Separator className = "mt-8" />
203+ </ >
198204 ) ;
199205 } )
200206 ) : (
0 commit comments