import { useState } from '@lynx-js/react'; import { cn } from '../utils.js'; interface SwitchProps { size?: 'sm' | 'lg'; defaultChecked?: boolean; checked?: boolean; onCheckedChange?: (checked: boolean) => void; disabled?: boolean; className?: string; } function Switch( { size = 'sm', defaultChecked = false, checked: checkedProp, onCheckedChange, disabled = false, className, }: SwitchProps, ) { const isControlled = checkedProp !== undefined; const [uncontrolledChecked, setUncontrolledChecked] = useState( defaultChecked, ); const checked = isControlled ? checkedProp : uncontrolledChecked; const handleToggle = () => { if (disabled) return; const next = !checked; if (!isControlled) { setUncontrolledChecked(next); } onCheckedChange?.(next); }; return ( {/* Track */} {/* Thumb */} ); } export { Switch };