import clsx from "clsx"; import { forwardRef, ReactNode, Ref, RefObject, useImperativeHandle, useRef } from "react"; import HintTooltip from "../tooltips/HintTooltip"; export interface RefInputCheckbox { input: RefObject; } interface Props { name: string; title: string | ReactNode; value?: boolean; setValue?: React.Dispatch>; className?: string; help?: string; required?: boolean; disabled?: boolean; description?: ReactNode; readOnly?: boolean; autoFocus?: boolean; } const InputCheckboxInline = ( { name, title, value, setValue, description, className, help, required, disabled = false, readOnly, autoFocus }: Props, ref: Ref ) => { useImperativeHandle(ref, () => ({ input })); const input = useRef(null); return (
{ setValue?.(e.target.checked); }} disabled={disabled} readOnly={readOnly} autoFocus={autoFocus} className={clsx( (disabled || readOnly) && "cursor-not-allowed bg-gray-100", "h-4 w-4 cursor-pointer rounded border-gray-300 text-theme-600 focus:ring-theme-500" )} />
); }; export default forwardRef(InputCheckboxInline);