"use client" import { Check, ChevronsUpDown } from 'lucide-react'; import * as React from 'react'; import { useAppT } from '@djangocfg/i18n'; import { useStoredValue, type StorageType, type UseStoredValueOptions } from '../../hooks'; import { cn } from '../../lib/utils'; import { Badge } from '../data/badge'; import { Button } from '../forms/button'; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '../navigation/command'; import { Popover, PopoverContent, PopoverTrigger } from '../overlay/popover'; export interface ComboboxOption { value: string label: string description?: string icon?: React.ComponentType<{ className?: string }> badge?: string | React.ReactNode disabled?: boolean style?: { badgeColor?: string iconColor?: string gradient?: string } } export interface ComboboxProps { options: ComboboxOption[] value?: string onValueChange?: (value: string) => void placeholder?: string searchPlaceholder?: string emptyText?: string className?: string disabled?: boolean renderOption?: (option: ComboboxOption) => React.ReactNode renderValue?: (option: ComboboxOption | undefined) => React.ReactNode /** * Replace the default ` )}
{ e.stopPropagation() }} > {filteredOptions.length === 0 ? ( {resolvedEmptyText} ) : ( {filteredOptions.map((option) => ( { if (!option.disabled) { handleSelect(currentValue) } }} disabled={option.disabled} > {option.icon && } {renderOption ? ( renderOption(option) ) : (
{option.label} {option.badge && ( {option.badge} )}
{option.description && ( {option.description} )}
)}
))}
)}
) }