"use client"; import { useState } from "react"; import { CheckIcon, ChevronsUpDownIcon } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@/components/ui/command"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { cn } from "@/lib/utils"; import { rarityGradientClass } from "@/lib/catalog-rarity"; import type { CatalogItem } from "@/lib/translator/types"; export function CatalogCombobox({ items, value, onChange, placeholder }: { items: CatalogItem[]; value: string; onChange: (item: CatalogItem) => void; placeholder: string }) { const [open, setOpen] = useState(false); const selected = items.find((item) => item.id === value); return }>{selected ? {selected.name.slice(0, 1)} : null}{selected?.name ?? placeholder}{selected?.rarity ? {selected.rarity}★ : null} No matching item.{items.map((item) => { onChange(item); setOpen(false); }}>{item.name.slice(0, 1)}{item.name}{item.rarity ? {item.rarity}★ : null})} ; }