- Name
index- Kind
- property
- Type
number- Requirement
- required
DocsAPI referenceUI machinesselect
select machine
The public state machine contract for @grassroot/ui-machines/select. The machine owns behaviour; the matching headless layer owns composition.
@grassroot/ui-machines/select
Package
Service example
select.tsts
import { createService } from "@grassroot/statechart";import { selectMachine } from "@grassroot/ui-machines/select"; const service = createService(selectMachine, { input: {} });service.start();service.send({ type: "…" });service.stop();22 of 22
Exports
LegacyHighlightEvent
typeLegacyHighlightEventts
type LegacyHighlightEvent = { readonly type: typeof LEGACY_HIGHLIGHT_EVENT; readonly index: number;};Name
Kind
Type
Requirement
indexproperty
numberrequired
typeproperty
typeof LEGACY_HIGHLIGHT_EVENTrequired
- Name
type- Kind
- property
- Type
typeof LEGACY_HIGHLIGHT_EVENT- Requirement
- required
LegacyHighlightType
typeLegacyHighlightTypets
type LegacyHighlightType = `ACT${"IVATE"}`;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
SelectChangeReason
typeSelectChangeReasonts
type SelectChangeReason = "pointer" | "keyboard" | "programmatic";SelectCommand
typeSelectCommandts
type SelectCommand<TValue extends SelectItemValue = string> = CommandObject & { readonly type: "VALUE_CHANGE_REQUEST"; readonly value: SelectCommandValue<TValue>; readonly reason: SelectChangeReason;};Name
Kind
Type
Requirement
reasonproperty
SelectChangeReasonrequired
typeproperty
stringrequired
valueproperty
SelectCommandValue<TValue>required
- Name
reason- Kind
- property
- Type
SelectChangeReason- Requirement
- required
- Name
type- Kind
- property
- Type
string- Requirement
- required
- Name
value- Kind
- property
- Type
SelectCommandValue<TValue>- Requirement
- required
SelectContext
typeSelectContextts
type SelectContext<TValue extends SelectItemValue = string> = { /** Caller-facing selection representation. */ readonly value: SelectValue<TValue>; /** Normalized identity used by the machine for all selection operations. */ readonly selectedIds: readonly string[]; readonly valueKind: SelectionKind; /** Original options-list index; disabled options are skipped during movement. */ readonly highlightedIndex: number; readonly mode: "controlled" | "uncontrolled";};Name
Kind
Type
Requirement
Description
highlightedIndexproperty
numberrequired
Original options-list index; disabled options are skipped during movement.
modeproperty
"controlled" | "uncontrolled"required
—
selectedIdsproperty
readonly string[]required
Normalized identity used by the machine for all selection operations.
valueproperty
SelectValue<TValue>required
Caller-facing selection representation.
valueKindproperty
SelectionKindrequired
—
- Name
highlightedIndex- Kind
- property
- Type
number- Requirement
- required
- Description
- Original options-list index; disabled options are skipped during movement.
- Name
mode- Kind
- property
- Type
"controlled" | "uncontrolled"- 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
SelectValue<TValue>- Requirement
- required
- Description
- Caller-facing selection representation.
- Name
valueKind- Kind
- property
- Type
SelectionKind- Requirement
- required
- Description
- —
SelectDiagnosticCodes
valueSelectDiagnosticCodests
export declare const SelectDiagnosticCodes: readonly DiagnosticCatalogueEntry[];SelectEvent
typeSelectEventts
type SelectEvent<TValue extends SelectItemValue = string> = { readonly type: "TOGGLE";} | { readonly type: "OPEN";} | { readonly type: "CLOSE";} | { readonly type: "MOVE"; readonly direction: -1 | 1;} | { readonly type: "SELECT"; readonly value: TValue; readonly reason: SelectChangeReason;} | { readonly type: "HIGHLIGHT"; readonly index: number;} | LegacyHighlightEvent | { readonly type: "HOME";} | { readonly type: "END";} | { readonly type: "TYPEAHEAD"; readonly query: string;} | { readonly type: "RESET";};SelectInput
typeSelectInputts
type SelectInput<TValue extends SelectItemValue = string> = { readonly options: readonly SelectOptionInput<TValue>[]; readonly selectionMode?: SelectSelectionMode; /** Controlled committed value. Defining it fixes controlled mode at first start. */ readonly value?: SelectValue<TValue>; /** Uncontrolled initial committed value. */ readonly defaultValue?: SelectValue<TValue>; readonly defaultOpen?: boolean; /** Versioned behavior: MOVE wraps past either end when true. Default false (legacy clamp). */ readonly loop?: boolean;};Name
Kind
Type
Requirement
Description
defaultOpenproperty
booleanoptional
—
defaultValueproperty
SelectValue<TValue>optional
Uncontrolled initial committed value.
loopproperty
booleanoptional
Versioned behavior: MOVE wraps past either end when true. Default false (legacy clamp).
optionsproperty
readonly SelectOptionInput<TValue>[]required
—
selectionModeproperty
SelectSelectionModeoptional
—
valueproperty
SelectValue<TValue>optional
Controlled committed value. Defining it fixes controlled mode at first start.
- Name
defaultOpen- Kind
- property
- Type
boolean- Requirement
- optional
- Description
- —
- Name
defaultValue- Kind
- property
- Type
SelectValue<TValue>- Requirement
- optional
- Description
- Uncontrolled initial committed value.
- Name
loop- Kind
- property
- Type
boolean- Requirement
- optional
- Description
- Versioned behavior: MOVE wraps past either end when true. Default false (legacy clamp).
- Name
options- Kind
- property
- Type
readonly SelectOptionInput<TValue>[]- Requirement
- required
- Description
- —
- Name
selectionMode- Kind
- property
- Type
SelectSelectionMode- Requirement
- optional
- Description
- —
- Name
value- Kind
- property
- Type
SelectValue<TValue>- Requirement
- optional
- Description
- Controlled committed value. Defining it fixes controlled mode at first start.
SelectItemValue
typeSelectItemValuets
type SelectItemValue = string;selectMachine
valueselectMachinets
export declare const selectMachine: SelectMachine;SelectMachine
typeSelectMachinets
type SelectMachine<TValue extends SelectItemValue = string> = Machine<SelectInput<TValue>, SelectStateValue, SelectContext<TValue>, SelectEvent<TValue>, SelectCommand<TValue>>;SelectOption
interfaceSelectOptionts
interface SelectOption<TValue extends SelectItemValue = string> { readonly id?: string; readonly value: TValue; readonly label: string; readonly disabled?: boolean;}Name
Kind
Type
Requirement
disabledproperty
booleanoptional
idproperty
stringoptional
labelproperty
stringrequired
valueproperty
TValuerequired
- 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
TValue- Requirement
- required
SelectOptionInput
typeSelectOptionInputts
type SelectOptionInput<TValue extends SelectItemValue = string> = string | SelectOption<TValue>;selectReplaySequence
valueselectReplaySequencets
export declare const selectReplaySequence: readonly SelectEvent[];SelectSelection
typeSelectSelectionts
type SelectSelection<TValue extends SelectItemValue = string> = string | SelectOption<TValue>;SelectSelectionMode
typeSelectSelectionModets
type SelectSelectionMode = "single" | "multiple";selectSelectors
valueselectSelectorsts
export declare const selectSelectors: { open: (snapshot: SelectSnapshot) => boolean; value: (snapshot: SelectSnapshot) => SelectValue<string>; selectedIds: (snapshot: SelectSnapshot) => readonly string[]; highlightedIndex: (snapshot: SelectSnapshot) => number;};Name
Kind
Type
Requirement
highlightedIndexproperty
(snapshot: SelectSnapshot) => numberrequired
openproperty
(snapshot: SelectSnapshot) => booleanrequired
selectedIdsproperty
(snapshot: SelectSnapshot) => readonly string[]required
valueproperty
(snapshot: SelectSnapshot) => SelectValue<string>required
- Name
highlightedIndex- Kind
- property
- Type
(snapshot: SelectSnapshot) => number- Requirement
- required
- Name
open- Kind
- property
- Type
(snapshot: SelectSnapshot) => boolean- Requirement
- required
- Name
selectedIds- Kind
- property
- Type
(snapshot: SelectSnapshot) => readonly string[]- Requirement
- required
- Name
value- Kind
- property
- Type
(snapshot: SelectSnapshot) => SelectValue<string>- Requirement
- required
SelectSnapshot
typeSelectSnapshotts
type SelectSnapshot<TValue extends SelectItemValue = string> = Snapshot<SelectStateValue, SelectContext<TValue>>;SelectStateValue
typeSelectStateValuets
type SelectStateValue = "open" | "closed";SelectValue
typeSelectValuets
type SelectValue<TValue extends SelectItemValue = string> = readonly SelectSelection<TValue>[];