import { Button } from "@/components/ui/button" import { Checkbox } from "@/components/ui/checkbox" import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover" export default function MultiSelect({ name, options = [], value = [], onChange, placeholder = "Pilih data", }) { const toggle = (val) => { let newValue if (value.includes(val)) { newValue = value.filter((v) => v !== val) } else { newValue = [...value, val] } if (onChange) { onChange({ target: { name, value: newValue, }, }) } } const selectedLabels = options .filter((o) => value.includes(o.value)) .map((o) => o.label) .join(", ") return ( // // // // // {value.length > 0 ? selectedLabels : placeholder} // // // // // // {options.map((opt) => ( // // toggle(opt.value)} // /> // {opt.label} // // ))} // // // {value.length > 0 ? selectedLabels : placeholder} {options.map((opt) => ( toggle(opt.value)} /> {opt.label} ))} ) }