import clsx from 'clsx'; import { CheckboxChecked } from '@/components/Icons'; import { CProps } from '@/components/props'; import { globals } from '@/utils/constants'; export interface CheckboxProps extends Omit { /** Label to display next to the checkbox. */ label?: string; /** Indicates whether the checkbox is disabled. */ disabled?: boolean; /** Current value - `true` or `false`. */ value?: boolean; /** Callback to set the `value`. */ setValue?: (newValue: boolean) => void; } /** * Component that allows toggling a boolean value. */ function Checkbox({ disabled, label, title, titleHtml, hideTitle, className, value, setValue, ...restProps }: CheckboxProps) { const cursor = disabled ? 'cursor-arrow' : setValue ? 'cursor-pointer' : ''; function handleClick(event: CProps.EventMouse): void { event.preventDefault(); event.stopPropagation(); if (disabled || !setValue) { return; } setValue(!value); } return ( ); } export default Checkbox;