import React, { useEffect, useRef } from 'react'; import { FiCheck, FiMinus } from 'react-icons/fi'; export interface CheckboxProps extends Omit, 'type'> { label?: React.ReactNode; description?: string; errorMessage?: string; indeterminate?: boolean; } export const Checkbox = React.forwardRef( ( { label, description, errorMessage, indeterminate = false, checked, disabled, className = '', id, name, ...props }, forwardedRef ) => { const internalRef = useRef(null); const resolvedRef = (forwardedRef as React.RefObject) || internalRef; const checkboxId = id || name || (typeof label === 'string' ? label.toLowerCase().replace(/\s+/g, '-') : undefined); useEffect(() => { if (resolvedRef.current) { resolvedRef.current.indeterminate = indeterminate; } }, [indeterminate, resolvedRef]); const isChecked = Boolean(checked); return (
{errorMessage && (

{errorMessage}

)}
); } ); Checkbox.displayName = 'Checkbox';