'use client';
import { HTMLProps, useEffect, useRef } from 'react';
import { cn } from '@/lib/helper';
interface CheckboxInputProps extends HTMLProps {
name: string;
label?: string;
indeterminate?: boolean;
classNames?: {
wrapper?: string;
inputWrapper?: string;
checkbox?: string;
label?: string;
};
isError?: boolean;
isValid?: boolean;
errorMessage?: string;
}
const CheckboxInput = ({
indeterminate,
name,
label,
className,
classNames,
isValid,
isError,
errorMessage,
...rest
}: CheckboxInputProps) => {
const ref = useRef(null!);
useEffect(() => {
if (typeof indeterminate === 'boolean') {
ref.current.indeterminate = !rest.checked && indeterminate;
}
}, [ref, indeterminate]);
return (
{label && (
)}
{errorMessage &&
{errorMessage}}
);
};
export default CheckboxInput;