in progress

This commit is contained in:
andres
2023-07-29 20:06:25 +02:00
parent 06afed2826
commit d03b211595
12 changed files with 357 additions and 4 deletions

View File

@@ -0,0 +1,36 @@
import { FieldValues, useController, UseControllerProps } from 'react-hook-form'
import { Checkbox, CheckboxProps } from '@/components'
type Props<T extends FieldValues> = UseControllerProps<T> &
Omit<CheckboxProps, 'checked' | 'onValueChange' | 'id'>
export const ControlledCheckbox = <T extends FieldValues>({
name,
rules,
shouldUnregister,
control,
defaultValue,
...checkboxProps
}: Props<T>) => {
const {
field: { onChange, value },
} = useController({
name,
rules,
shouldUnregister,
control,
defaultValue,
})
return (
<Checkbox
{...{
onValueChange: onChange,
checked: value,
id: name,
...checkboxProps,
}}
/>
)
}