import * as React from "react" import { X } from "lucide-react" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@/components/ui/command" import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover" interface MultiSelectProps { options: { label: string; value: string }[] selected: string[] onChange: (selected: string[]) => void placeholder?: string className?: string } export function MultiSelect({ options, selected, onChange, placeholder = "Select items...", className, }: MultiSelectProps) { const [open, setOpen] = React.useState(false) const handleUnselect = (item: string) => { onChange(selected.filter((i) => i !== item)) } return ( )) ) : ( {placeholder} )} No item found. {options.map((option) => ( { onChange( selected.includes(option.value) ? selected.filter((item) => item !== option.value) : [...selected, option.value] ) setOpen(true) }} >
{option.label}
))}
) }