- Name
filteredValues- Kind
- property
- Type
readonly string[]- Requirement
- required
- Description
- Normalized option ids, in filtered option order.
DocsAPI referenceUI machinescombobox
combobox machine
The public state machine contract for @grassroot/ui-machines/combobox. The machine owns behaviour; the matching headless layer owns composition.
@grassroot/ui-machines/combobox
Package
Service example
combobox.tsts
import { createService } from "@grassroot/statechart";import { comboboxMachine } from "@grassroot/ui-machines/combobox"; const service = createService(comboboxMachine, { input: {} });service.start();service.send({ type: "…" });service.stop();21 of 21
Exports
ComboboxBindingMode
typeComboboxBindingModets
type ComboboxBindingMode = "controlled" | "uncontrolled";ComboboxChangeReason
typeComboboxChangeReasonts
type ComboboxChangeReason = "pointer" | "keyboard" | "input" | "trigger" | "programmatic" | "escape" | "outside-click";ComboboxCommand
typeComboboxCommandts
type ComboboxCommand = CommandObject & ({ readonly type: "VALUE_CHANGE_REQUEST"; readonly value: ComboboxCommandValue; readonly reason: Exclude<ComboboxChangeReason, "input">;} | { readonly type: "OPEN_CHANGE_REQUEST"; readonly open: boolean; readonly reason: ComboboxChangeReason;} | { readonly type: "INPUT_VALUE_CHANGE_REQUEST"; readonly inputValue: string; readonly reason: "input" | "programmatic";} | { readonly type: "FOCUS_PART"; readonly part: "input" | "trigger";} | { readonly type: "ANNOUNCE"; readonly key: string; readonly params?: Record<string, string | number | boolean>;} | { readonly type: "statechart.schedule"; readonly key: "combobox.debounce"; readonly event: { readonly type: "OPTIONS_REQUEST_FIRE"; }; readonly delayMs: number;} | { readonly type: "statechart.cancel"; readonly key: "combobox.debounce";} | { readonly type: "OPTIONS_REQUEST"; readonly key: "combobox.options"; readonly request: { readonly query: string; }; readonly onSettled: { readonly type: "OPTIONS_LOADED"; readonly payloadKey: "options"; }; readonly onFailed: { readonly type: "OPTIONS_LOAD_FAILED"; readonly payloadKey: "error"; };});ComboboxContext
interfaceComboboxContextts
interface ComboboxContext { /** Caller-facing selection representation: strings or option records. */ readonly value: ComboboxValue; /** Normalized identity used by the machine for all selection operations. */ readonly selectedIds: readonly string[]; readonly valueKind: SelectionKind; readonly open: boolean; readonly inputValue: string; /** Original options-list index; filtered and disabled options are skipped while moving. */ readonly highlightedIndex: number; /** Normalized option ids, in filtered option order. */ readonly filteredValues: readonly string[]; readonly loading: boolean; readonly loadError: unknown; readonly modes: ComboboxModes;}Name
Kind
Type
Requirement
Description
filteredValuesproperty
readonly string[]required
Normalized option ids, in filtered option order.
highlightedIndexproperty
numberrequired
Original options-list index; filtered and disabled options are skipped while moving.
inputValueproperty
stringrequired
—
loadErrorproperty
unknownrequired
—
loadingproperty
booleanrequired
—
modesproperty
ComboboxModesrequired
—
openproperty
booleanrequired
—
selectedIdsproperty
readonly string[]required
Normalized identity used by the machine for all selection operations.
valueproperty
ComboboxValuerequired
Caller-facing selection representation: strings or option records.
valueKindproperty
SelectionKindrequired
—
- Name
highlightedIndex- Kind
- property
- Type
number- Requirement
- required
- Description
- Original options-list index; filtered and disabled options are skipped while moving.
- Name
inputValue- Kind
- property
- Type
string- Requirement
- required
- Description
- —
- Name
loadError- Kind
- property
- Type
unknown- Requirement
- required
- Description
- —
- Name
loading- Kind
- property
- Type
boolean- Requirement
- required
- Description
- —
- Name
modes- Kind
- property
- Type
ComboboxModes- Requirement
- required
- Description
- —
- Name
open- Kind
- property
- Type
boolean- Requirement
- required
- Description
- —
- Name
selectedIds- Kind
- property
- Type
readonly string[]- Requirement
- required
- Description
- Normalized identity used by the machine for all selection operations.
- Name
value- Kind
- property
- Type
ComboboxValue- Requirement
- required
- Description
- Caller-facing selection representation: strings or option records.
- Name
valueKind- Kind
- property
- Type
SelectionKind- Requirement
- required
- Description
- —
ComboboxDiagnosticCodes
valueComboboxDiagnosticCodests
export declare const ComboboxDiagnosticCodes: readonly DiagnosticCatalogueEntry[];ComboboxEvent
typeComboboxEventts
type ComboboxEvent = { readonly type: "OPEN"; readonly reason: ComboboxChangeReason; readonly value?: string;} | { readonly type: "CLOSE"; readonly reason: ComboboxChangeReason;} | { readonly type: "TOGGLE"; readonly reason: ComboboxChangeReason; readonly value?: string;} | { readonly type: "SET_INPUT_VALUE"; readonly value: string; readonly reason: "input" | "programmatic";} | { readonly type: "MOVE"; readonly direction: -1 | 1;} | { readonly type: "HOME";} | { readonly type: "END";} | { readonly type: "HIGHLIGHT"; readonly id: string;} | { readonly type: "SELECT"; readonly id: string; readonly reason: Exclude<ComboboxChangeReason, "input">;} | { readonly type: "OPTIONS_REQUEST_FIRE";} | { readonly type: "OPTIONS_LOADED"; readonly options: readonly ComboboxOptionInput[];} | { readonly type: "OPTIONS_LOAD_FAILED"; readonly error: unknown;} | { readonly type: "RESET";};ComboboxInput
interfaceComboboxInputts
interface ComboboxInput { readonly options: readonly ComboboxOptionInput[]; readonly loadOptions?: boolean; readonly selectionMode?: ComboboxSelectionMode; readonly value?: ComboboxValue; readonly defaultValue?: ComboboxValue; readonly open?: boolean; readonly defaultOpen?: boolean; readonly inputValue?: string; readonly defaultInputValue?: string;}Name
Kind
Type
Requirement
defaultInputValueproperty
stringoptional
defaultOpenproperty
booleanoptional
defaultValueproperty
ComboboxValueoptional
inputValueproperty
stringoptional
loadOptionsproperty
booleanoptional
openproperty
booleanoptional
optionsproperty
readonly ComboboxOptionInput[]required
selectionModeproperty
ComboboxSelectionModeoptional
valueproperty
ComboboxValueoptional
- Name
defaultInputValue- Kind
- property
- Type
string- Requirement
- optional
- Name
defaultOpen- Kind
- property
- Type
boolean- Requirement
- optional
- Name
defaultValue- Kind
- property
- Type
ComboboxValue- Requirement
- optional
- Name
inputValue- Kind
- property
- Type
string- Requirement
- optional
- Name
loadOptions- Kind
- property
- Type
boolean- Requirement
- optional
- Name
open- Kind
- property
- Type
boolean- Requirement
- optional
- Name
options- Kind
- property
- Type
readonly ComboboxOptionInput[]- Requirement
- required
- Name
selectionMode- Kind
- property
- Type
ComboboxSelectionMode- Requirement
- optional
- Name
value- Kind
- property
- Type
ComboboxValue- Requirement
- optional
comboboxMachine
valuecomboboxMachinets
export declare const comboboxMachine: ComboboxMachine;ComboboxMachine
typeComboboxMachinets
type ComboboxMachine = Machine<ComboboxInput, ComboboxStateValue, ComboboxContext, ComboboxEvent, ComboboxCommand>;ComboboxModes
interfaceComboboxModests
interface ComboboxModes { readonly value: ComboboxBindingMode; readonly open: ComboboxBindingMode; readonly inputValue: ComboboxBindingMode;}Name
Kind
Type
Requirement
inputValueproperty
ComboboxBindingModerequired
openproperty
ComboboxBindingModerequired
valueproperty
ComboboxBindingModerequired
- Name
inputValue- Kind
- property
- Type
ComboboxBindingMode- Requirement
- required
- Name
open- Kind
- property
- Type
ComboboxBindingMode- Requirement
- required
- Name
value- Kind
- property
- Type
ComboboxBindingMode- Requirement
- required
ComboboxOption
interfaceComboboxOptionts
interface ComboboxOption { readonly id?: string; readonly value: string; readonly label: string; readonly disabled?: boolean;}Name
Kind
Type
Requirement
disabledproperty
booleanoptional
idproperty
stringoptional
labelproperty
stringrequired
valueproperty
stringrequired
- Name
disabled- Kind
- property
- Type
boolean- Requirement
- optional
- Name
id- Kind
- property
- Type
string- Requirement
- optional
- Name
label- Kind
- property
- Type
string- Requirement
- required
- Name
value- Kind
- property
- Type
string- Requirement
- required
ComboboxOptionInput
typeComboboxOptionInputts
type ComboboxOptionInput = string | ComboboxOption;comboboxReplaySequence
valuecomboboxReplaySequencets
export declare const comboboxReplaySequence: readonly ComboboxEvent[];ComboboxSelection
typeComboboxSelectionts
type ComboboxSelection = string | ComboboxOption;ComboboxSelectionModets
type ComboboxSelectionMode = "single" | "multiple";comboboxSelectors
valuecomboboxSelectorsts
export declare const comboboxSelectors: { open: (snapshot: ComboboxSnapshot) => boolean; value: (snapshot: ComboboxSnapshot) => ComboboxValue; selectedIds: (snapshot: ComboboxSnapshot) => readonly string[]; inputValue: (snapshot: ComboboxSnapshot) => string; highlightedIndex: (snapshot: ComboboxSnapshot) => number; filteredValues: (snapshot: ComboboxSnapshot) => readonly string[];};Name
Kind
Type
Requirement
filteredValuesproperty
(snapshot: ComboboxSnapshot) => readonly string[]required
highlightedIndexproperty
(snapshot: ComboboxSnapshot) => numberrequired
inputValueproperty
(snapshot: ComboboxSnapshot) => stringrequired
openproperty
(snapshot: ComboboxSnapshot) => booleanrequired
selectedIdsproperty
(snapshot: ComboboxSnapshot) => readonly string[]required
valueproperty
(snapshot: ComboboxSnapshot) => ComboboxValuerequired
- Name
filteredValues- Kind
- property
- Type
(snapshot: ComboboxSnapshot) => readonly string[]- Requirement
- required
- Name
highlightedIndex- Kind
- property
- Type
(snapshot: ComboboxSnapshot) => number- Requirement
- required
- Name
inputValue- Kind
- property
- Type
(snapshot: ComboboxSnapshot) => string- Requirement
- required
- Name
open- Kind
- property
- Type
(snapshot: ComboboxSnapshot) => boolean- Requirement
- required
- Name
selectedIds- Kind
- property
- Type
(snapshot: ComboboxSnapshot) => readonly string[]- Requirement
- required
- Name
value- Kind
- property
- Type
(snapshot: ComboboxSnapshot) => ComboboxValue- Requirement
- required
ComboboxSnapshot
typeComboboxSnapshotts
type ComboboxSnapshot = Snapshot<ComboboxStateValue, ComboboxContext>;ComboboxStateValue
typeComboboxStateValuets
type ComboboxStateValue = "open" | "closed";ComboboxValue
typeComboboxValuets
type ComboboxValue = readonly ComboboxSelection[];normalizedOptions
functionnormalizedOptionsts
declare function normalizedOptions(options: readonly OptionInput[]): readonly NormalizedOption[];Name
Kind
Type
Requirement
optionsparameter
readonly OptionInput[]required
returnreturn value
readonly NormalizedOption[]n/a
- Name
options- Kind
- parameter
- Type
readonly OptionInput[]- Requirement
- required
- Name
return- Kind
- return value
- Type
readonly NormalizedOption[]- Requirement
- n/a
normalizeOption
functionnormalizeOptionts
declare function normalizeOption(option: OptionInput): NormalizedOption;Name
Kind
Type
Requirement
optionparameter
OptionInputrequired
returnreturn value
NormalizedOptionn/a
- Name
option- Kind
- parameter
- Type
OptionInput- Requirement
- required
- Name
return- Kind
- return value
- Type
NormalizedOption- Requirement
- n/a