import * as React from "react" import { View } from "@tarojs/components" import { cn } from "@/lib/utils" const Switch = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { checked?: boolean defaultChecked?: boolean onCheckedChange?: (checked: boolean) => void disabled?: boolean } >(({ className, checked, defaultChecked, onCheckedChange, disabled, ...props }, ref) => { const [localChecked, setLocalChecked] = React.useState(defaultChecked || false) const isControlled = checked !== undefined const currentChecked = isControlled ? checked : localChecked return ( { if (disabled) return e.stopPropagation() const newChecked = !currentChecked if (!isControlled) { setLocalChecked(newChecked) } onCheckedChange?.(newChecked) }} > ) }) Switch.displayName = "Switch" export { Switch }