Reference machines
combobox
# ComboboxContext
Type Parameters
T
Members
errorerror: Error | nullMost recent fetcher error, if any.
filteredfiltered: readonly T[]Filtered subset shown in the listbox.
highlightedIdhighlightedId: string | nullId of the currently highlighted option, or null.
optionsoptions: readonly T[]Source list of options (sync mode). For async, mirrors the latest fetch.
pageSizepageSize: numberPage step for PageUp / PageDown navigation.
queryquery: stringCurrent input string.
statusstatus: ComboboxStatusAsync fetch lifecycle. Always 'idle' in sync mode.
tokentoken: numberMonotonic token incremented on every INPUT.CHANGE; used to drop stale fetches.
valuevalue: T | nullCurrently selected option, or null.
# ComboboxOption
Structural shape an option must satisfy. Most consumers pass typed domain objects (User, Product, …) — id and label are the floor; everything else propagates as T.
Members
disabled?readonly optional disabled?: booleanidreadonly id: stringlabelreadonly label: string
# CreateComboboxInput
Type Parameters
T
Members
defaultQuery?optional defaultQuery?: stringdefaultValue?optional defaultValue?: T | nulldisabled?optional disabled?: booleanfilter?optional filter?: (options, query) => readonly T[]Optional sync filter. Receives
(options, query)and returns a subset. Default: case-insensitivelabelsubstring match.###### Parameters
###### options
readonly
T[]###### query
string###### Returns
readonly
T[]options?optional options?: readonly T[]pageSize?optional pageSize?: numberPage step for PageUp/PageDown. Defaults to 10.
# ComboboxEvent
ComboboxEvent<T> = { type: "INPUT.FOCUS"; } | { type: "INPUT.BLUR"; } | { type: "INPUT.CHANGE"; value: string; } | { type: "INPUT.ESCAPE"; } | { type: "INPUT.ENTER"; } | { direction: NavigateDirection; type: "INPUT.NAVIGATE"; } | { id: string; type: "OPTION.HIGHLIGHT"; } | { option: T; type: "OPTION.SELECT"; } | { type: "TRIGGER.CLICK"; } | { type: "OPEN"; } | { type: "CLOSE"; } | { options: ReadonlyArray<T>; token: number; type: "FETCH.RESOLVE"; } | { error: Error; token: number; type: "FETCH.REJECT"; } | { token: number; type: "FETCH.LOADING"; } | { type: "SET.VALUE"; value: T | null; } | { type: "RESET"; } | { type: "DISABLE"; } | { type: "ENABLE"; }All events the Combobox machine can receive.
Type Parameters
T
# ComboboxMachine
ComboboxMachine<T> = Machine<ComboboxContext<T>, ComboboxEvent<T>, ComboboxState>Type Parameters
T
# ComboboxState
ComboboxState = "idle" | "open" | "disabled"# ComboboxStatus
ComboboxStatus = "idle" | "loading" | "error"Async fetch lifecycle.
# NavigateDirection
NavigateDirection = "next" | "prev" | "first" | "last" | "page-next" | "page-prev"Keyboard navigation directions.
# createComboboxMachine ( )
createComboboxMachine<T>(input?): ComboboxMachine<T>Construct a fresh Combobox machine for option type T.
Type Parameters
T
Parameters
input?CreateComboboxInput<T> = {}
Returns
ComboboxMachine<T>