import React, { forwardRef, useRef } from 'react'; import { classes } from '../../utils'; import { useFieldValidation } from '../input'; import { useMergeRefs } from '@floating-ui/react'; import { ErrorNotification } from '../input/Input'; export interface Props extends React.InputHTMLAttributes { label?: string; indeterminate?: boolean; errorMessage?: string; } export const Checkbox = forwardRef( ({ label, disabled = false, indeterminate = false, onChange, errorMessage, ...props }, propRef) => { const localRef = useRef(null); const ref = useMergeRefs([localRef, propRef]); if (indeterminate && localRef.current) localRef.current.indeterminate = true; if (!indeterminate && localRef.current) localRef.current.indeterminate = false; const { errorText, isValid, handleChange } = useFieldValidation(errorMessage, localRef, onChange); return ( ); } );