import { type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from 'react'; import { type FloatingAnchor } from './floating.js'; export interface ListboxNavigationOptions { items: readonly T[]; /** Called with the highlighted item on Enter, a `chooseKeys` key or a click. */ onChoose: (item: T, index: number) => void; /** Called on Escape, such as to close the list until the text changes. */ onDismiss?: (() => void) | undefined; /** False while the list isn't shown: the keys are then the host's own. A list that hides * itself while empty passes false then too, or Escape dismisses what isn't there. Default * true. */ open?: boolean | undefined; /** Past the end comes the start, and before the start the end. Default true. */ loop?: boolean | undefined; /** Keys that choose besides Enter. Default `['Tab']`. */ chooseKeys?: readonly string[] | undefined; /** Home and End move to the first and last items rather than the caret, for a host whose * text is a short query rather than prose. Default false. */ homeEnd?: boolean | undefined; /** An item that can't be chosen, which the highlight passes over. */ isDisabled?: ((item: T) => boolean) | undefined; /** Opens the highlighted item's menu from the keyboard, on Shift+F10 or the menu key, at its * option. Returns whether a menu opened; the key is then the list's. */ onContextMenu?: ((item: T, index: number, anchor: HTMLElement) => boolean) | undefined; } /** Keys are DOM or React keyboard events alike, as an editor plugin and an input pass them. */ type AnyKeyboardEvent = KeyboardEvent | ReactKeyboardEvent; /** The parts a highlighted list needs while focus stays on the box the reader types in, such * as a text box, an editor or a search input: the highlight and its keys, and the ids that * let assistive technology follow the highlight. Spread `hostProps` on the focused box, * `listProps` on the list and `optionProps(i)` on each option, or draw them with * ListboxPanel and ListboxOption. */ export declare function useListboxNavigation({ items, onChoose, onDismiss, open, loop, chooseKeys, homeEnd, isDisabled, onContextMenu, }: ListboxNavigationOptions): { /** The highlighted item's index, or -1 with nothing to show. */ active: number; setActive: import("react").Dispatch>; handleKey: (event: AnyKeyboardEvent) => boolean; listId: string; /** For the box that keeps focus: it points at the list and its highlighted option. */ hostProps: { 'aria-autocomplete': 'list'; 'aria-controls': string | undefined; 'aria-activedescendant': string | undefined; }; listProps: { id: string; role: 'listbox'; }; optionProps: (index: number) => { id: string; role: 'option'; tabIndex: number; 'aria-selected': boolean; 'aria-disabled': true | undefined; 'data-highlighted': true | undefined; 'data-disabled': true | undefined; onMouseDown: (event: { preventDefault: () => void; }) => void; onMouseMove: () => void; onClick: () => void; }; }; export type ListboxNavigation = ReturnType>; export interface ListboxPanelProps { /** `listProps` from useListboxNavigation. */ listProps: { id: string; role: 'listbox'; }; /** Names the list for assistive technology. */ 'aria-label': string; /** Under the list, such as which keys choose and dismiss. */ footer?: ReactNode; /** In place of the options while there are none. */ empty?: ReactNode; /** Opens at this element or point, such as an editor's caret, over the page and inside a * modal dialog alike; without one the panel stands where the host places it. */ at?: FloatingAnchor | undefined; /** With `at`: called when a press outside closes it. */ onDismiss?: (() => void) | undefined; /** On the panel: its width or place. */ className?: string | undefined; children: ReactNode; } /** The panel of a highlighted list that the reader drives from a box that keeps focus. */ export declare function ListboxPanel({ listProps, 'aria-label': label, footer, empty, at, onDismiss, className, children, }: ListboxPanelProps): import("react").JSX.Element; export interface ListboxOptionProps { /** `optionProps(index)` from useListboxNavigation. */ option: ReturnType['optionProps']>; icon?: ReactNode; label: ReactNode; /** Under the label, or beside it with `inline`. */ description?: ReactNode; /** The description on the label's line, as a command's summary beside its name. */ inline?: boolean | undefined; /** Short muted text at the row's end, such as a key. */ hint?: ReactNode; /** In a list of choices that stay chosen, such as the labels on an issue: true shows the * check at the row's end and tells assistive technology, false leaves it unchecked. Leave * it out for a list that only acts. */ checked?: boolean | undefined; /** The option opens more choices, such as a submenu or a next step: a chevron ends the row. */ submenu?: boolean | undefined; className?: string | undefined; } /** One option of a ListboxPanel: an icon, its label and description, and at its end a hint, a * check while it is chosen and a chevron when it opens more. */ export declare function ListboxOption({ option, icon, label, description, inline, hint, checked, submenu, className, }: ListboxOptionProps): import("react").JSX.Element; /** Options under a heading in a ListboxPanel. */ export declare function ListboxGroup({ label, children }: { label: ReactNode; children: ReactNode; }): import("react").JSX.Element; export {};