import clsx from 'clsx'; import { globalIDs } from '@/utils/constants'; import { CheckboxChecked } from '../Icons'; import { type Button } from '../props'; 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`. */ onChange?: (newValue: boolean) => void; } /** * Component that allows toggling a boolean value. */ export function Checkbox({ disabled, label, title, titleHtml, hideTitle, className, value, onChange, ...restProps }: CheckboxProps) { const cursor = disabled ? 'cursor-arrow' : onChange ? 'cursor-pointer' : ''; function handleClick(event: React.MouseEvent): void { event.preventDefault(); event.stopPropagation(); if (disabled || !onChange) { return; } onChange(!value); } return ( ); }