"use client" /* eslint-disable no-restricted-syntax */ import type { ComponentPropsWithoutRef, ReactNode } from "react" import { type As, type CheckboxProps, type MergeWithAs, Checkbox } from "@heroui/react" import type { Field } from "soda-tanstack-form" import { getFieldProps } from "../utils/getFieldProps" export type FormCheckboxProps = MergeWithAs< ComponentPropsWithoutRef<"input">, ComponentPropsWithoutRef, CheckboxProps, AsComponent > & { field: Field component?: ( props: MergeWithAs, ComponentPropsWithoutRef, CheckboxProps, AsComponent>, ) => ReactNode } export function FormCheckbox({ field, component: Checkbox2 = Checkbox, ...rest }: FormCheckboxProps): ReactNode { return ( isSelected={field.state.value ?? false} onValueChange={field.handleChange as (value: boolean) => void} {...getFieldProps(field, true)} {...rest} /> ) }