import { useContext } from 'react'; import { CheckboxRadioContext } from '../../utils/context'; import HintText from '../../common/HintText'; import { CheckboxProps } from './types'; import clsx from 'clsx'; const Checkbox = ({ checked, hintText, id, isSmall, isExclusive, label, name, onBlur, onChange }: CheckboxProps) => { const hintTextId = `hint-text-${id}`; const behaviour = isExclusive && 'exclusive'; function handleBlur(event: React.FocusEvent) { if (typeof onBlur === 'function') { onBlur(event); } } function handleChange(event: React.ChangeEvent) { if (typeof onChange === 'function') { onChange(event); } } isSmall = isSmall || useContext(CheckboxRadioContext).isSmall; return ( <> {isExclusive &&

or

}
{hintText && {hintText}}
); }; Checkbox.displayName = 'Checkbox'; export default Checkbox;