import type { Ref } from "react"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "../ui/command"; import { cn } from "@app/lib/cn"; import { CheckIcon } from "lucide-react"; export type TagValue = { text: string; id: string }; export type MultiSelectTagsProps = { emptyPlaceholder: string; searchPlaceholder: string; searchQuery?: string; options: Array; value: Array; onChange: (newValue: Array) => void; onSearch: (query: string) => void; ref?: Ref; }; export function MultiSelectContent({ emptyPlaceholder, searchPlaceholder, searchQuery, value, options, onSearch, onChange }: MultiSelectTagsProps) { const selectedValues = new Set(value.map((v) => v.id)); return ( {/* FIXME: why isn't this list scrolling ????? */} {emptyPlaceholder} {options.map((option) => ( { let newValues = []; if (selectedValues.has(option.id)) { newValues = value.filter( (v) => v.id !== option.id ); } else { newValues = [...value, option]; } onChange(newValues); }} > {`${option.text}`} ))} ); }