import { type ReactElement, type ReactNode } from 'react'; import { type ComboboxItems } from './comboboxItems.js'; import { type FieldBoxSize } from './fieldBox.js'; export type { ComboboxGroup, ComboboxItem, ComboboxItems, ComboboxLeaf, } from './comboboxItems.js'; interface FieldProps { id?: string | undefined; placeholder?: string | undefined; disabled?: boolean | undefined; required?: boolean | undefined; 'aria-label'?: string | undefined; 'aria-labelledby'?: string | undefined; 'aria-describedby'?: string | undefined; 'aria-invalid'?: boolean | undefined; 'aria-required'?: boolean | undefined; /** `sm` for dense places such as toolbars and table cells, `lg` for a form that stands alone, * such as sign-in. */ size?: FieldBoxSize | undefined; /** Classes for the field box: border, background, width. */ className?: string | undefined; } type SelectionProps = { multiple?: false | undefined; value?: Value | null | undefined; defaultValue?: Value | null | undefined; onValueChange?: ((value: NoInfer | null) => void) | undefined; } | { multiple: true; value?: readonly Value[] | undefined; defaultValue?: readonly Value[] | undefined; onValueChange?: ((value: NoInfer[]) => void) | undefined; /** Typed text the list doesn't have can be added as a value of its own, as tags are. The * values are then strings. For one free-text value, use Autocomplete. */ creatable?: (Value extends string ? boolean : never) | undefined; /** The most values the field takes; past it, only removing one lets another in. */ maxItems?: number | undefined; /** The longest text that can be typed, such as for a created value. */ maxLength?: number | undefined; /** With `creatable`: turns typed text into the value it adds, such as trimmed and * lowercased; undefined refuses it. */ createValue?: ((typed: string) => string | undefined) | undefined; /** With `creatable`: keys that add what is typed, beside Enter, such as `','`. Pasted * text splits on them too, adding each part. */ separators?: readonly string[] | undefined; /** With `creatable`: leaving the field adds what is typed, so a value half entered isn't * lost. */ addOnBlur?: boolean | undefined; /** With `creatable`: values offered as chips under the field, each added with a press. * Chosen ones leave the row. */ suggested?: readonly string[] | undefined; }; export type ComboboxProps = FieldProps & SelectionProps & { items: ComboboxItems; /** Matches a value to its item. Defaults to deep equality, so object values can be recreated. */ isItemEqualToValue?: ((itemValue: Value, value: Value) => boolean) | undefined; /** Labels a selected value that no item has, such as a saved choice the list no longer offers. */ itemToStringLabel?: ((value: Value) => string) | undefined; /** Renders the field as this button, with the search input inside the popup, for compact * pickers such as a toolbar pill. The button shows the selection itself. */ trigger?: ReactElement | undefined; /** A hint on the trigger button. */ triggerTooltip?: ReactNode; /** A pane beside the list about the highlighted item, such as who is in a group; it gets * undefined while nothing is highlighted. It follows the highlight from the keyboard and * the pointer alike, and is hidden from assistive technology, so each item's * `accessibleDescription` must say what matters in it. Where the list is narrower than * 30rem the pane has no room, and `detailsSummary` shows under the highlighted item. */ details?: ((value: Value | undefined) => ReactNode) | undefined; /** Called as the highlight moves, from the keyboard or the pointer, such as to load what * `details` shows; undefined once nothing is highlighted. */ onItemHighlighted?: ((value: Value | undefined) => void) | undefined; /** A line about the highlighted item, under it, where the list has no room for `details`. */ detailsSummary?: ((value: Value) => ReactNode) | undefined; /** Called as the typed text changes. With it, the host does the filtering: the list shows * `items` as given, such as the results of a search on the server. */ onQueryChange?: ((query: string) => void) | undefined; /** The host's search is under way. */ loading?: boolean | undefined; /** The area the open list stays inside, such as a drawer's body above its footer; by * default, the viewport. With `details`, the list grows to fill it. */ collisionBoundary?: Element | null | undefined; /** Whether the list is open, for a host that opens it itself, such as from a shortcut or * to keep one picker open at a time. */ open?: boolean | undefined; defaultOpen?: boolean | undefined; onOpenChange?: ((open: boolean) => void) | undefined; /** The edge of the field or trigger the open list lines up with. */ align?: 'start' | 'end' | undefined; /** Offers a row that creates the typed text, such as a label that doesn't exist yet, while * no item has that text. Choosing it calls this with the text and picks nothing itself: * the host creates the thing and picks it, if it should. */ onCreate?: ((text: string) => void) | undefined; }; export interface AutocompleteProps extends FieldProps { /** Suggestions; any typed text is also a valid value. */ items: ComboboxItems; value?: string | undefined; defaultValue?: string | undefined; onValueChange?: ((value: string) => void) | undefined; } /** A pick-from-the-list field: one value, or several with `multiple`. Typing filters the list. */ export declare function Combobox(props: ComboboxProps): import("react").JSX.Element; /** A free-text field that suggests values as you type. */ export declare function Autocomplete({ items, value, defaultValue, onValueChange, className, placeholder, disabled, required, id: ownId, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'aria-required': ariaRequired, size, }: AutocompleteProps): import("react").JSX.Element;