import { Item } from '../components/SelectInput.js'; type Option = Item; type OptionMapItem = Option & { previous: OptionMapItem | undefined; next: OptionMapItem | undefined; index: number; }; export default class OptionMap extends Map> { readonly first: OptionMapItem | undefined; constructor(options: Option[]); } interface State { /** * Map where key is option's value and value is option's index. */ optionMap: OptionMap; /** * Number of visible options. */ visibleOptionCount: number; /** * Index of the first visible option. */ visibleFromIndex: number; /** * Index of the last visible option. */ visibleToIndex: number; /** * Value of the previously selected option. */ previousValue: T | undefined; /** * Value of the selected option. */ value: T | undefined; } export interface UseSelectStateProps { /** * Number of items to display. * */ visibleOptionCount: number; /** * Options. */ options: Option[]; /** * Initially selected option's value. */ defaultValue?: T; } export type SelectState = Pick, 'visibleOptionCount' | 'visibleFromIndex' | 'visibleToIndex' | 'value'> & { /** * Visible options. */ visibleOptions: (Option & { index: number; })[]; /** * Select next option and scroll the list down, if needed. */ selectNextOption: () => void; /** * Select previous option and scroll the list up, if needed. */ selectPreviousOption: () => void; /** * Select option directly. */ selectOption: (option: Option) => void; }; export declare const useSelectState: ({ visibleOptionCount, options, defaultValue }: UseSelectStateProps) => { visibleFromIndex: number; visibleToIndex: number; value: unknown; visibleOptions: Option[]; selectNextOption: () => void; selectPreviousOption: () => void; selectOption: ({ option }: { option: Option; }) => void; previousValue: unknown; }; export {};