import * as React from "react" import { View } from "@tarojs/components" import { Check } from "lucide-react-taro" import { cn } from "@/lib/utils" const Checkbox = React.forwardRef< React.ElementRef, Omit, "onClick"> & { checked?: boolean defaultChecked?: boolean onCheckedChange?: (checked: boolean) => void disabled?: boolean } >(({ className, checked: checkedProp, defaultChecked, onCheckedChange, disabled, ...props }, ref) => { const [checkedState, setCheckedState] = React.useState( defaultChecked ?? false ) const isControlled = checkedProp !== undefined const checked = isControlled ? checkedProp : checkedState const handleClick = (e) => { if (disabled) return e.stopPropagation() const newChecked = !checked if (!isControlled) { setCheckedState(newChecked) } onCheckedChange?.(newChecked) } const tabIndex = (props as any).tabIndex ?? (disabled ? -1 : 0) return ( {checked && } ) }) Checkbox.displayName = "Checkbox" export { Checkbox }