'use client'; import * as React from 'react'; import { Checkbox as CheckboxPrimitive } from 'radix-ui'; import { motion, type HTMLMotionProps } from 'motion/react'; import { cn } from '@workspace/ui/lib/utils'; type CheckboxProps = React.ComponentProps & HTMLMotionProps<'button'>; function Checkbox({ className, onCheckedChange, ...props }: CheckboxProps) { const [isChecked, setIsChecked] = React.useState( props?.checked ?? props?.defaultChecked ?? false, ); React.useEffect(() => { if (props?.checked !== undefined) setIsChecked(props.checked); }, [props?.checked]); const handleCheckedChange = React.useCallback( (checked: boolean) => { setIsChecked(checked); onCheckedChange?.(checked); }, [onCheckedChange], ); return ( ); } export { Checkbox, type CheckboxProps };