import { forwardRef, type ComponentPropsWithoutRef, type ReactNode } from 'react'; import { Check } from 'lucide-react'; import { cn } from '../../lib/cn'; import { Checkbox as UiCheckbox } from '../ui/checkbox'; import { Label } from '../ui/label'; import { Toggle } from '../ui/toggle'; import { Spinner } from '../Spinner/Spinner'; export interface CheckboxProps extends ComponentPropsWithoutRef { label: ReactNode; } /** Plain form checkbox, e.g. "Angemeldet bleiben". Use `checked` / `onCheckedChange`. */ export const Checkbox = forwardRef(function Checkbox( { label, className, ...props }, ref, ) { return ( ); }); export interface TaskCheckboxProps { checked: boolean; onToggle?: () => void; loading?: boolean; /** Title of the task, used for the accessible label. */ taskTitle: string; /** Hit area: 36px in the dashboard, 40px in the task list. */ size?: 36 | 40; className?: string; } /** The rounded-square toggle that completes or reopens a task. */ export function TaskCheckbox({ checked, onToggle, loading, taskTitle, size = 36, className }: TaskCheckboxProps) { return ( onToggle?.()} aria-busy={loading || undefined} aria-label={checked ? `${taskTitle} wieder öffnen` : `${taskTitle} als erledigt markieren`} disabled={loading} className={cn('group flex-none rounded-lg', size === 36 ? 'h-9 w-9' : 'h-10 w-10', className)} > {loading ? ( ) : ( checked && ); }