import type { CSSProperties, ReactNode } from 'react'; import type { SxProp } from '../Layout/sx.cjs'; export interface AutocompleteOption { /** Stable identifier — what gets stored in `value`. */ value: string; /** Visible label. */ label: string; /** Optional group heading. Options with the same `group` cluster together. */ group?: string; /** Disable selection of this option. */ disabled?: boolean; /** Right-aligned secondary text (e.g. department, hint). */ hint?: ReactNode; /** Leading icon node (overrides the avatar character). */ icon?: ReactNode; } export type AutocompleteSize = 'sm' | 'md' | 'lg'; export type AutocompleteColor = 'primary' | 'danger' | 'warning' | 'success'; interface AutocompleteBase { /** Flat list of options. */ options: AutocompleteOption[]; /** Trigger placeholder when nothing is selected. */ placeholder?: string; /** Search input placeholder inside the dropdown. */ searchPlaceholder?: string; /** Empty-state when no options match the search. */ emptyText?: ReactNode; /** Show a loading spinner inside the dropdown (appears after 150ms to avoid flicker). */ loading?: boolean; /** Loading-state text. */ loadingText?: ReactNode; /** Trigger size. */ size?: AutocompleteSize; /** Validation color on the trigger. */ color?: AutocompleteColor; /** Disable the entire control. */ disabled?: boolean; /** Show a clear button when something is selected. */ clearable?: boolean; /** Highlight the part of each label matching the search text. Default: `true`. */ highlightMatch?: boolean; /** Values shown as a "Recent" group while the search box is empty. */ recentItems?: string[]; /** Heading for the `recentItems` group. Default: `'Recent'`. */ recentLabel?: string; /** * Controlled open state of the dropdown. Pair with `onOpenChange`; leave * unset to let the component manage it. */ open?: boolean; /** Uncontrolled initial open state. Default: `false`. */ defaultOpen?: boolean; /** * Fires when the dropdown asks to open or close (trigger click, Esc, outside * click, or a pick in single mode) — e.g. to load options on first open. */ onOpenChange?: (open: boolean) => void; /** Field-threading: id forwarded to the trigger. */ id?: string; /** Field-threading: forwarded ARIA. */ 'aria-invalid'?: boolean; /** Field-threading: forwarded ARIA. */ 'aria-describedby'?: string; /** Accessible label when no `` wraps the control. */ 'aria-label'?: string; /** Custom className on the trigger. */ className?: string; /** Inline style applied to the trigger (the inline field). */ style?: CSSProperties; /** * One-off CSS, same as `Box`'s `sx`: each value may be a scalar or a * responsive breakpoint map (`{ base, sm, md, lg, xl }`). Applied to the * trigger. Scalar-only sx merges into inline style; responsive sx injects * a scoped class. */ sx?: SxProp; } export interface AutocompleteSingleProps extends AutocompleteBase { multiple?: false; /** Controlled selected value. */ value?: string | null; /** Uncontrolled initial value. */ defaultValue?: string | null; /** Fires on selection change. */ onValueChange?: (value: string | null) => void; } export interface AutocompleteMultipleProps extends AutocompleteBase { multiple: true; /** Controlled selected values. */ value?: string[]; /** Uncontrolled initial values. */ defaultValue?: string[]; /** Fires on selection change. */ onValueChange?: (value: string[]) => void; /** Cap on how many can be selected. */ maxItems?: number; } export type AutocompleteProps = AutocompleteSingleProps | AutocompleteMultipleProps; export {};