- Name
filteredGroups- Kind
- property
- Type
readonly CommandGroup<Item>[]- Requirement
- required
- Description
- —
DocsAPI referenceUI machinescommand
command machine
The public state machine contract for @grassroot/ui-machines/command. The machine owns behaviour; the matching headless layer owns composition.
@grassroot/ui-machines/command
Package
Service example
command.tsts
import { createService } from "@grassroot/statechart";import { commandMachine } from "@grassroot/ui-machines/command"; const service = createService(commandMachine, { input: {} });service.start();service.send({ type: "…" });service.stop();18 of 18
Exports
CommandBindingMode
typeCommandBindingModets
type CommandBindingMode = "controlled" | "uncontrolled";CommandChangeReason
typeCommandChangeReasonts
type CommandChangeReason = "pointer" | "keyboard" | "programmatic" | "trigger" | "input" | "escape" | "outside-click";CommandCommand
typeCommandCommandts
type CommandCommand = CommandObject & ({ readonly type: "VALUE_CHANGE_REQUEST"; readonly value: string; readonly reason: CommandSelectionReason;} | { readonly type: "OPEN_CHANGE_REQUEST"; readonly open: boolean; readonly reason: Exclude<CommandChangeReason, "input">;} | { readonly type: "QUERY_CHANGE_REQUEST"; readonly query: string; readonly reason: "input" | "programmatic";} | { readonly type: "FOCUS_PART"; readonly part: "input" | "panel";} | { readonly type: "ANNOUNCE"; readonly key: "selection-changed" | "results-available"; readonly params: { readonly label: string | null; readonly count: number | null; }; readonly politeness: "polite" | "assertive";});CommandContext
interfaceCommandContextts
interface CommandContext<Item extends CommandItem = CommandItem> { readonly value: string | undefined; readonly open: boolean; readonly query: string; /** Index into the current flattened item list; filtering never creates a second index model. */ readonly highlightedIndex: number; readonly filteredGroups: readonly CommandGroup<Item>[]; readonly flatItems: readonly Item[]; readonly modes: CommandModes;}Name
Kind
Type
Requirement
Description
filteredGroupsproperty
readonly CommandGroup<Item>[]required
—
flatItemsproperty
readonly Item[]required
—
highlightedIndexproperty
numberrequired
Index into the current flattened item list; filtering never creates a second index model.
modesproperty
CommandModesrequired
—
openproperty
booleanrequired
—
queryproperty
stringrequired
—
valueproperty
string | undefinedrequired
—
- Name
flatItems- Kind
- property
- Type
readonly Item[]- Requirement
- required
- Description
- —
- Name
highlightedIndex- Kind
- property
- Type
number- Requirement
- required
- Description
- Index into the current flattened item list; filtering never creates a second index model.
- Name
modes- Kind
- property
- Type
CommandModes- Requirement
- required
- Description
- —
- Name
open- Kind
- property
- Type
boolean- Requirement
- required
- Description
- —
- Name
query- Kind
- property
- Type
string- Requirement
- required
- Description
- —
- Name
value- Kind
- property
- Type
string | undefined- Requirement
- required
- Description
- —
CommandDiagnosticCodes
valueCommandDiagnosticCodests
export declare const CommandDiagnosticCodes: readonly DiagnosticCatalogueEntry[];CommandEvent
typeCommandEventts
type CommandEvent = { readonly type: "OPEN"; readonly reason: Exclude<CommandChangeReason, "input">;} | { readonly type: "CLOSE"; readonly reason: Exclude<CommandChangeReason, "input">;} | { readonly type: "TOGGLE"; readonly reason: Exclude<CommandChangeReason, "input">;} | { readonly type: "SET_QUERY"; readonly query: string; readonly reason: "input" | "programmatic";} | { readonly type: "MOVE"; readonly direction: -1 | 1;} | { readonly type: "HIGHLIGHT"; readonly index: number;} | { readonly type: "SELECT"; readonly value: string; readonly reason: CommandSelectionReason;} | { readonly type: "RESET";};CommandFilter
typeCommandFilterts
type CommandFilter<Item extends CommandItem = CommandItem> = (item: Item, normalizedQuery: string) => boolean;CommandGroup
typeCommandGroupts
type CommandGroup<Item extends CommandItem = CommandItem> = CommandGroup$1<Item>;CommandInput
interfaceCommandInputts
interface CommandInput<Item extends CommandItem = CommandItem> { readonly groups: readonly CommandGroup<Item>[]; readonly value?: string; readonly defaultValue?: string; readonly open?: boolean; readonly defaultOpen?: boolean; readonly query?: string; readonly defaultQuery?: string; /** Replaces the default oracle predicate; the machine still owns grouping. */ readonly filter?: CommandFilter<Item>;}Name
Kind
Type
Requirement
Description
defaultOpenproperty
booleanoptional
—
defaultQueryproperty
stringoptional
—
defaultValueproperty
stringoptional
—
filterproperty
CommandFilter<Item>optional
Replaces the default oracle predicate; the machine still owns grouping.
groupsproperty
readonly CommandGroup<Item>[]required
—
openproperty
booleanoptional
—
queryproperty
stringoptional
—
valueproperty
stringoptional
—
- Name
defaultOpen- Kind
- property
- Type
boolean- Requirement
- optional
- Description
- —
- Name
defaultQuery- Kind
- property
- Type
string- Requirement
- optional
- Description
- —
- Name
defaultValue- Kind
- property
- Type
string- Requirement
- optional
- Description
- —
- Name
filter- Kind
- property
- Type
CommandFilter<Item>- Requirement
- optional
- Description
- Replaces the default oracle predicate; the machine still owns grouping.
- Name
groups- Kind
- property
- Type
readonly CommandGroup<Item>[]- Requirement
- required
- Description
- —
- Name
open- Kind
- property
- Type
boolean- Requirement
- optional
- Description
- —
- Name
query- Kind
- property
- Type
string- Requirement
- optional
- Description
- —
- Name
value- Kind
- property
- Type
string- Requirement
- optional
- Description
- —
CommandItem
typeCommandItemts
type CommandItem = CommandItem$1;commandMachine
valuecommandMachinets
export declare const commandMachine: CommandMachine;CommandMachine
typeCommandMachinets
type CommandMachine<Item extends CommandItem = CommandItem> = Machine<CommandInput<Item>, CommandStateValue, CommandContext<Item>, CommandEvent, CommandCommand>;CommandModes
interfaceCommandModests
interface CommandModes { readonly value: CommandBindingMode; readonly open: CommandBindingMode; readonly query: CommandBindingMode;}Name
Kind
Type
Requirement
openproperty
CommandBindingModerequired
queryproperty
CommandBindingModerequired
valueproperty
CommandBindingModerequired
- Name
open- Kind
- property
- Type
CommandBindingMode- Requirement
- required
- Name
query- Kind
- property
- Type
CommandBindingMode- Requirement
- required
- Name
value- Kind
- property
- Type
CommandBindingMode- Requirement
- required
commandReplaySequence
valuecommandReplaySequencets
export declare const commandReplaySequence: readonly CommandEvent[];CommandSelectionReasonts
type CommandSelectionReason = "pointer" | "keyboard" | "programmatic";commandSelectors
valuecommandSelectorsts
export declare const commandSelectors: { value: <Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => string | undefined; open: <Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => boolean; query: <Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => string; highlightedIndex: <Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => number; filteredGroups: <Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => readonly CommandGroup<Item>[]; flatItems: <Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => readonly Item[];};Name
Kind
Type
Requirement
filteredGroupsproperty
<Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => readonly CommandGroup<Item>[]required
flatItemsproperty
<Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => readonly Item[]required
highlightedIndexproperty
<Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => numberrequired
openproperty
<Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => booleanrequired
queryproperty
<Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => stringrequired
valueproperty
<Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => string | undefinedrequired
- Name
filteredGroups- Kind
- property
- Type
<Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => readonly CommandGroup<Item>[]- Requirement
- required
- Name
flatItems- Kind
- property
- Type
<Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => readonly Item[]- Requirement
- required
- Name
highlightedIndex- Kind
- property
- Type
<Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => number- Requirement
- required
- Name
open- Kind
- property
- Type
<Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => boolean- Requirement
- required
- Name
query- Kind
- property
- Type
<Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => string- Requirement
- required
- Name
value- Kind
- property
- Type
<Item extends CommandItem>(snapshot: CommandSnapshot<Item>) => string | undefined- Requirement
- required
CommandSnapshot
typeCommandSnapshotts
type CommandSnapshot<Item extends CommandItem = CommandItem> = Snapshot<CommandStateValue, CommandContext<Item>>;CommandStateValue
typeCommandStateValuets
type CommandStateValue = "open" | "closed";