import OptionMap from '../../lib/option-map.js'; import { type Option } from '../../types.js'; type State = { /** * Map where key is option's value and value is option's index. */ optionMap: OptionMap; /** * Number of visible options. */ visibleOptionCount: number; /** * Value of the currently focused option. */ focusedValue: string | undefined; /** * Index of the first visible option. */ visibleFromIndex: number; /** * Index of the last visible option. */ visibleToIndex: number; /** * Values of previously selected options. */ previousValue: string[]; /** * Indexes of selected options. */ value: string[]; }; export type UseMultiSelectStateProps = { /** * Number of visible options. * * @default 5 */ visibleOptionCount?: number; /** * Options. */ options: Option[]; /** * Initially selected option values. */ defaultValue?: string[]; /** * Callback for selecting options. */ onChange?: (value: string[]) => void; /** * Callback when user presses enter. * First argument is an array of selected option values. */ onSubmit?: (value: string[]) => void; }; export type MultiSelectState = Pick & { /** * Visible options. */ visibleOptions: Array