UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

31 lines (30 loc) 2.15 kB
import { ComboboxDropdownEventSource, ComboboxStore } from './use-combobox'; export interface UseVirtualizedComboboxOptions { /** Default value for `dropdownOpened`, `false` by default */ defaultOpened?: boolean; /** Controlled `dropdownOpened` state */ opened?: boolean; /** Called when `dropdownOpened` state changes */ onOpenedChange?: (opened: boolean) => void; /** Called when dropdown closes */ onDropdownClose?: (eventSource: ComboboxDropdownEventSource) => void; /** Called when dropdown opens */ onDropdownOpen?: (eventSource: ComboboxDropdownEventSource) => void; /** Determines whether arrow key presses should loop though items (first to last and last to first), `true` by default */ loop?: boolean; /** Function to determine whether the option is disabled */ isOptionDisabled?: (optionIndex: number) => boolean; /** Total number of options in the virtualized list. Required for proper keyboard navigation and index calculations. */ totalOptionsCount: number; /** Function that returns the id of the option at the given index. Required for setting aria attributes and element references. */ getOptionId: (index: number) => string | null; /** Current selected option index. Must be controlled by parent component. */ selectedOptionIndex: number; /** Callback to update the selected option index. Called when user navigates or selects options. */ setSelectedOptionIndex: (index: number) => void; /** Currently active/highlighted option index. Used to determine which option to select when selectActiveOption is called. */ activeOptionIndex?: number; /** Called when the selected option is submitted (e.g., via Enter key or clicking). Receives the selected option index. */ onSelectedOptionSubmit: (index: number) => void; } export declare function useVirtualizedCombobox({ defaultOpened, opened, onOpenedChange, onDropdownClose, onDropdownOpen, loop, totalOptionsCount, isOptionDisabled, getOptionId, selectedOptionIndex, setSelectedOptionIndex, activeOptionIndex, onSelectedOptionSubmit, }?: UseVirtualizedComboboxOptions): ComboboxStore;