import * as React from "react"; import * as DropdownMenu from "@radix-ui/react-dropdown-menu"; import { Check, ChevronDown, X } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; interface AgentMultiSelectProps { options: string[]; value: string[]; onChange: (value: string[]) => void; placeholder?: string; } export const AgentMultiSelect: React.FC = ({ options, value, onChange, placeholder = "Filter by agent", }) => { const toggle = (agent: string) => { if (value.includes(agent)) { onChange(value.filter((a) => a !== agent)); } else { onChange([...value, agent]); } }; return ( {options.map((opt) => { const checked = value.includes(opt); return ( { e.preventDefault(); toggle(opt); }} className="flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer hover:bg-muted focus:outline-none" > {checked && } {opt} ); })} {/* Selected chips */} {value.length > 0 && (
{value.map((v) => ( {v} toggle(v)} /> ))}
)}
); };