29 lines
567 B
TypeScript
29 lines
567 B
TypeScript
"use client"
|
|
|
|
import type { BaseFieldControlProps } from "../types"
|
|
import { Checkbox } from "@/shared/components/ui/checkbox"
|
|
|
|
export type CheckboxFieldProps = BaseFieldControlProps<boolean> & {
|
|
label?: string
|
|
}
|
|
|
|
export function CheckboxField({
|
|
value,
|
|
onChange,
|
|
onBlur,
|
|
name,
|
|
disabled,
|
|
invalid,
|
|
}: CheckboxFieldProps) {
|
|
return (
|
|
<Checkbox
|
|
checked={value}
|
|
onCheckedChange={(checked) => onChange(checked === true)}
|
|
onBlur={onBlur}
|
|
name={name}
|
|
disabled={disabled}
|
|
aria-invalid={invalid || undefined}
|
|
/>
|
|
)
|
|
}
|