import clsx from 'clsx'; import { useMemo } from 'react'; import { globals } from '@/utils/constants'; import { CheckboxChecked } from '../Icons'; import { CProps } from '../props'; export interface CheckboxProps extends Omit { label?: string; disabled?: boolean; value: boolean; setValue?: (newValue: boolean) => void; } function Checkbox({ disabled, label, title, titleHtml, hideTitle, className, value, setValue, ...restProps }: CheckboxProps) { const cursor = useMemo(() => { if (disabled) { return 'cursor-not-allowed'; } else if (setValue) { return 'cursor-pointer'; } else { return ''; } }, [disabled, setValue]); function handleClick(event: CProps.EventMouse): void { event.preventDefault(); event.stopPropagation(); if (disabled || !setValue) { return; } setValue(!value); } return ( ); } export default Checkbox;