import { useContext } from "react"; import { CategoryCatalogContext } from "@/context/CategoryCatalogContext"; import { useState, type ReactNode } from "react"; import { Check, ChevronDown, LayoutGrid } from "lucide-react"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@/components/ui/command"; import { CATEGORIES } from "@/lib/categories"; import { cn } from "@/lib/utils"; import { CategoryIcon } from "./CategoryIcon"; export const ALL_CATEGORIES = "all"; interface Props { value: string; onChange: (category: string) => void; categories?: readonly string[]; /** Adds an "all" row (value `"all"`) above the categories, for filters. */ allLabel?: string; placeholder?: string; /** Replaces the default select-style trigger, e.g. a bulk-action button. */ trigger?: ReactNode; triggerClassName?: string; align?: "start" | "center" | "end"; disabled?: boolean; "aria-label"?: string; } /** * Searchable category picker. Twenty categories is past what a plain select * list scans comfortably, so typing narrows the list; each row carries the * category's icon and colour so the choice is recognisable before it is read. * * The default trigger matches the app's select trigger, so it drops into any * form or filter row in place of a