import { Machine } from '../../machine.js'; import type { EnsureArray } from '../../types.js'; import { Focus } from '../../utils/calculate-active-index.js'; import { ElementPositionState } from '../../utils/element-movement.js'; interface MutableRefObject { current: T; } export declare enum ComboboxState { Open = 0, Closed = 1 } export declare enum ValueMode { Single = 0, Multi = 1 } export declare enum ActivationTrigger { Pointer = 0, Focus = 1, Other = 2 } export type ComboboxOptionDataRef = MutableRefObject<{ disabled: boolean; value: T; domRef: MutableRefObject; order: number | null; }>; export interface State { id: string; dataRef: MutableRefObject<{ value: unknown; defaultValue: unknown; disabled: boolean; invalid: boolean; mode: ValueMode; immediate: boolean; onChange: (value: T) => void; onClose?: () => void; compare(a: unknown, z: unknown): boolean; isSelected(value: unknown): boolean; virtual: { options: T[]; disabled: (value: T) => boolean; } | null; calculateIndex(value: unknown): number; __demoMode: boolean; optionsPropsRef: MutableRefObject<{ static: boolean; hold: boolean; }>; }>; virtual: { options: T[]; disabled: (value: unknown) => boolean; } | null; comboboxState: ComboboxState; defaultToFirstOption: boolean; options: { id: string; dataRef: ComboboxOptionDataRef; }[]; activeOptionIndex: number | null; activationTrigger: ActivationTrigger; isTyping: boolean; inputElement: HTMLInputElement | null; buttonElement: HTMLButtonElement | null; optionsElement: HTMLElement | null; inputPositionState: ElementPositionState; __demoMode: boolean; } export declare enum ActionTypes { OpenCombobox = 0, CloseCombobox = 1, GoToOption = 2, SetTyping = 3, RegisterOption = 4, UnregisterOption = 5, DefaultToFirstOption = 6, SetActivationTrigger = 7, UpdateVirtualConfiguration = 8, SetInputElement = 9, SetButtonElement = 10, SetOptionsElement = 11, MarkInputAsMoved = 12 } type Actions = { type: ActionTypes.CloseCombobox; } | { type: ActionTypes.OpenCombobox; } | { type: ActionTypes.GoToOption; focus: Focus.Specific; idx: number; trigger?: ActivationTrigger; } | { type: ActionTypes.SetTyping; isTyping: boolean; } | { type: ActionTypes.GoToOption; focus: Exclude; trigger?: ActivationTrigger; } | { type: ActionTypes.RegisterOption; payload: { id: string; dataRef: ComboboxOptionDataRef; }; } | { type: ActionTypes.UnregisterOption; id: string; } | { type: ActionTypes.DefaultToFirstOption; value: boolean; } | { type: ActionTypes.SetActivationTrigger; trigger: ActivationTrigger; } | { type: ActionTypes.UpdateVirtualConfiguration; options: T[]; disabled: ((value: any) => boolean) | null; } | { type: ActionTypes.SetInputElement; element: HTMLInputElement | null; } | { type: ActionTypes.SetButtonElement; element: HTMLButtonElement | null; } | { type: ActionTypes.SetOptionsElement; element: HTMLElement | null; } | { type: ActionTypes.MarkInputAsMoved; }; export declare class ComboboxMachine extends Machine, Actions> { static new({ id, virtual, __demoMode, }: { id: string; virtual?: { options: TMultiple extends true ? EnsureArray> : NoInfer[]; disabled?: (value: TMultiple extends true ? EnsureArray>[number] : NoInfer) => boolean; } | null; __demoMode?: boolean; }): ComboboxMachine; constructor(initialState: State); actions: { onChange: (newValue: T) => void; registerOption: (id: string, dataRef: ComboboxOptionDataRef) => () => void; goToOption: (focus: { focus: Focus.Specific; idx: number; } | { focus: Exclude; }, trigger?: ActivationTrigger) => void; setIsTyping: (isTyping: boolean) => void; closeCombobox: () => void; openCombobox: () => void; setActivationTrigger: (trigger: ActivationTrigger) => void; selectActiveOption: () => void; setInputElement: (element: HTMLInputElement | null) => void; setButtonElement: (element: HTMLButtonElement | null) => void; setOptionsElement: (element: HTMLElement | null) => void; }; selectors: { activeDescendantId: (state: State) => string | undefined; activeOptionIndex: (state: State) => number | null; activeOption: (state: State) => T | null; isActive: (state: State, value: T, id: string) => boolean; shouldScrollIntoView: (state: State, value: T, id: string) => boolean; didInputMove(state: State): boolean; }; reduce(state: Readonly>, action: Actions): State; } export {};