import { Machine } from '../../machine.js'; import { Focus } from '../../utils/calculate-active-index.js'; import { ElementPositionState } from '../../utils/element-movement.js'; interface MutableRefObject { current: T; } export declare enum ListboxStates { Open = 0, Closed = 1 } export declare enum ValueMode { Single = 0, Multi = 1 } export declare enum ActivationTrigger { Pointer = 0, Other = 1 } type ListboxOptionDataRef = MutableRefObject<{ textValue?: string; disabled: boolean; value: T; domRef: MutableRefObject; }>; interface State { id: string; __demoMode: boolean; dataRef: MutableRefObject<{ value: unknown; disabled: boolean; invalid: boolean; mode: ValueMode; orientation: 'horizontal' | 'vertical'; onChange: (value: T) => void; compare(a: unknown, z: unknown): boolean; isSelected(value: unknown): boolean; optionsPropsRef: MutableRefObject<{ static: boolean; hold: boolean; }>; listRef: MutableRefObject>; }>; listboxState: ListboxStates; options: { id: string; dataRef: ListboxOptionDataRef; }[]; searchQuery: string; activeOptionIndex: number | null; activationTrigger: ActivationTrigger; frozenValue: boolean; buttonElement: HTMLButtonElement | null; optionsElement: HTMLElement | null; pendingShouldSort: boolean; pendingFocus: { focus: Exclude; } | { focus: Focus.Specific; id: string; }; buttonPositionState: ElementPositionState; } export declare enum ActionTypes { OpenListbox = 0, CloseListbox = 1, GoToOption = 2, Search = 3, ClearSearch = 4, SelectOption = 5, RegisterOptions = 6, UnregisterOptions = 7, SetButtonElement = 8, SetOptionsElement = 9, SortOptions = 10, MarkButtonAsMoved = 11 } type Actions = { type: ActionTypes.CloseListbox; } | { type: ActionTypes.OpenListbox; focus: { focus: Exclude; } | { focus: Focus.Specific; id: string; }; } | { type: ActionTypes.GoToOption; focus: Focus.Specific; id: string; trigger?: ActivationTrigger; } | { type: ActionTypes.GoToOption; focus: Exclude; trigger?: ActivationTrigger; } | { type: ActionTypes.Search; value: string; } | { type: ActionTypes.ClearSearch; } | { type: ActionTypes.SelectOption; value: T; } | { type: ActionTypes.RegisterOptions; options: { id: string; dataRef: ListboxOptionDataRef; }[]; } | { type: ActionTypes.UnregisterOptions; options: string[]; } | { type: ActionTypes.SetButtonElement; element: HTMLButtonElement | null; } | { type: ActionTypes.SetOptionsElement; element: HTMLElement | null; } | { type: ActionTypes.SortOptions; } | { type: ActionTypes.MarkButtonAsMoved; }; export declare class ListboxMachine extends Machine, Actions> { static new({ id, __demoMode }: { id: string; __demoMode?: boolean; }): ListboxMachine; constructor(initialState: State); actions: { onChange: (newValue: T) => void; registerOption: (id: string, dataRef: ListboxOptionDataRef) => void; unregisterOption: (id: string) => void; goToOption: (focus: { focus: Focus.Specific; id: string; } | { focus: Exclude; }, trigger?: ActivationTrigger | undefined) => void; closeListbox: () => void; openListbox: (focus: { focus: Exclude; } | { focus: Focus.Specific; id: string; }) => void; selectActiveOption: () => void; selectOption: (value: T) => void; search: (value: string) => void; clearSearch: () => void; setButtonElement: (element: HTMLButtonElement | null) => void; setOptionsElement: (element: HTMLElement | null) => void; }; selectors: { activeDescendantId(state: State): string | undefined; isActive(state: State, id: string): boolean; hasFrozenValue(state: State): boolean; shouldScrollIntoView(state: State, id: string): boolean; didButtonMove(state: State): boolean; }; reduce(state: Readonly>, action: Actions): State; } export {};