import { ChevronDown } from 'lucide-react'; import * as React from 'react'; import { cn } from '../lib/utils'; import { DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger, } from './ui/dropdown-menu'; export interface CompactSelectOption { value: string; label: string; } interface Props { value: string; onChange: ( next: string ) => void; options: CompactSelectOption[]; // Required — used as the trigger's aria-label. The visible text is // the currently-selected option's label, which screen readers need // the surrounding role context for (e.g. "Group by, source / campaign"). label: string; leadingIcon?: React.ReactNode; align?: 'start' | 'end'; className?: string; } // Compact dropdown trigger matching ToggleGroup `size="sm"`'s // silhouette (h-8 px-2). Pair this with ToggleGroup in the same row // for visual parity — they're the two halves of the same selector // family. See src/components/CLAUDE.md for when to pick which. export function CompactSelect( { value, onChange, options, label, leadingIcon, align = 'end', className, }: Props ) { const current = options.find( o => o.value === value ); return ( { leadingIcon && { leadingIcon } } { current?.label ?? value } { options.map( o => ( { o.label } ) ) } ); }