- Name
ids- Kind
- parameter
- Type
readonly string[]- Requirement
- required
DocsAPI referenceUI machinesselection
selection machine
The public state machine contract for @grassroot/ui-machines/selection. The machine owns behaviour; the matching headless layer owns composition.
@grassroot/ui-machines/selection
Package
Service example
selection.tsts
import { createService } from "@grassroot/statechart";import { selectionMachine } from "@grassroot/ui-machines/selection"; const service = createService(selectionMachine, { input: {} });service.start();service.send({ type: "…" });service.stop();21 of 21
Exports
dedupeSelectionIds
functiondedupeSelectionIdsts
declare function dedupeSelectionIds(ids: readonly string[]): SelectionValue;Name
Kind
Type
Requirement
idsparameter
readonly string[]required
returnreturn value
SelectionValuen/a
- Name
return- Kind
- return value
- Type
SelectionValue- Requirement
- n/a
EMPTY_SELECTION_IDS
valueEMPTY_SELECTION_IDSts
export declare const EMPTY_SELECTION_IDS: SelectionValue;isSelectableId
functionisSelectableIdts
declare function isSelectableId(id: string, input: SelectionInput): boolean;Name
Kind
Type
Requirement
idparameter
stringrequired
inputparameter
SelectionInputrequired
returnreturn value
booleann/a
- Name
id- Kind
- parameter
- Type
string- Requirement
- required
- Name
input- Kind
- parameter
- Type
SelectionInput- Requirement
- required
- Name
return- Kind
- return value
- Type
boolean- Requirement
- n/a
rangeSelectionIds
functionrangeSelectionIdsts
declare function rangeSelectionIds(orderedIds: readonly string[], disabledIds: readonly string[], fromId: string | null, toId: string): SelectionValue;Name
Kind
Type
Requirement
orderedIdsparameter
readonly string[]required
disabledIdsparameter
readonly string[]required
fromIdparameter
string | nullrequired
toIdparameter
stringrequired
returnreturn value
SelectionValuen/a
- Name
orderedIds- Kind
- parameter
- Type
readonly string[]- Requirement
- required
- Name
disabledIds- Kind
- parameter
- Type
readonly string[]- Requirement
- required
- Name
fromId- Kind
- parameter
- Type
string | null- Requirement
- required
- Name
toId- Kind
- parameter
- Type
string- Requirement
- required
- Name
return- Kind
- return value
- Type
SelectionValue- Requirement
- n/a
sameSelectionIds
functionsameSelectionIdsts
declare function sameSelectionIds(left: SelectionValue, right: SelectionValue): boolean;Name
Kind
Type
Requirement
leftparameter
SelectionValuerequired
rightparameter
SelectionValuerequired
returnreturn value
booleann/a
- Name
left- Kind
- parameter
- Type
SelectionValue- Requirement
- required
- Name
right- Kind
- parameter
- Type
SelectionValue- Requirement
- required
- Name
return- Kind
- return value
- Type
boolean- Requirement
- n/a
SelectionChangeDetailts
type SelectionChangeDetail = { readonly selectedIds: SelectionValue; readonly reason: SelectionChangeReason;};Name
Kind
Type
Requirement
reasonproperty
SelectionChangeReasonrequired
selectedIdsproperty
SelectionValuerequired
- Name
reason- Kind
- property
- Type
SelectionChangeReason- Requirement
- required
- Name
selectedIds- Kind
- property
- Type
SelectionValue- Requirement
- required
SelectionChangeReasonts
type SelectionChangeReason = "pointer" | "keyboard" | "programmatic";SelectionCommand
typeSelectionCommandts
type SelectionCommand = CommandObject & { readonly type: "SELECTION_CHANGE_REQUEST"; readonly selectedIds: SelectionValue; readonly reason: SelectionChangeReason;};Name
Kind
Type
Requirement
reasonproperty
SelectionChangeReasonrequired
selectedIdsproperty
SelectionValuerequired
typeproperty
stringrequired
- Name
reason- Kind
- property
- Type
SelectionChangeReason- Requirement
- required
- Name
selectedIds- Kind
- property
- Type
SelectionValue- Requirement
- required
- Name
type- Kind
- property
- Type
string- Requirement
- required
SelectionContext
typeSelectionContextts
type SelectionContext = { readonly mode: BindingMode; readonly selectedIds: SelectionValue; readonly anchorId: string | null;};Name
Kind
Type
Requirement
anchorIdproperty
string | nullrequired
modeproperty
BindingModerequired
selectedIdsproperty
SelectionValuerequired
- Name
anchorId- Kind
- property
- Type
string | null- Requirement
- required
- Name
mode- Kind
- property
- Type
BindingMode- Requirement
- required
- Name
selectedIds- Kind
- property
- Type
SelectionValue- Requirement
- required
SelectionDiagnosticCodes
valueSelectionDiagnosticCodests
export declare const SelectionDiagnosticCodes: readonly DiagnosticCatalogueEntry[];SelectionEvent
typeSelectionEventts
type SelectionEvent = { readonly type: "SELECT"; readonly id: string; readonly reason: SelectionChangeReason;} | { readonly type: "TOGGLE"; readonly id: string; readonly reason: SelectionChangeReason;} | { readonly type: "RANGE_EXTEND"; readonly id: string; readonly reason: SelectionChangeReason;} | { readonly type: "SELECT_ALL"; readonly selectableIds: readonly string[]; readonly reason: SelectionChangeReason;} | { readonly type: "CLEAR"; readonly reason: SelectionChangeReason;} | { readonly type: "REPLACE"; readonly selectedIds: SelectionValue; readonly reason: SelectionChangeReason;} | { readonly type: "RESET";};SelectionInput
interfaceSelectionInputts
interface SelectionInput { readonly mode: SelectionMode; readonly selectedIds?: SelectionValue; readonly defaultSelectedIds?: SelectionValue; readonly orderedIds: readonly string[]; readonly disabledIds?: readonly string[];}Name
Kind
Type
Requirement
defaultSelectedIdsproperty
SelectionValueoptional
disabledIdsproperty
readonly string[]optional
modeproperty
SelectionModerequired
orderedIdsproperty
readonly string[]required
selectedIdsproperty
SelectionValueoptional
- Name
defaultSelectedIds- Kind
- property
- Type
SelectionValue- Requirement
- optional
- Name
disabledIds- Kind
- property
- Type
readonly string[]- Requirement
- optional
- Name
mode- Kind
- property
- Type
SelectionMode- Requirement
- required
- Name
orderedIds- Kind
- property
- Type
readonly string[]- Requirement
- required
- Name
selectedIds- Kind
- property
- Type
SelectionValue- Requirement
- optional
selectionMachine
valueselectionMachinets
export declare const selectionMachine: SelectionMachine;SelectionMachine
typeSelectionMachinets
type SelectionMachine = Machine<SelectionInput, SelectionStateValue, SelectionContext, SelectionEvent, SelectionCommand>;SelectionMachineStatets
type SelectionMachineState = MachineState<SelectionStateValue, SelectionContext>;SelectionMode
typeSelectionModets
type SelectionMode = "none" | "single" | "multiple";selectionReplaySequence
valueselectionReplaySequencets
export declare const selectionReplaySequence: readonly SelectionEvent[];selectionSelectors
valueselectionSelectorsts
export declare const selectionSelectors: { selectedIds: (snapshot: SelectionSnapshot) => SelectionValue; anchorId: (snapshot: SelectionSnapshot) => string | null; bindingMode: (snapshot: SelectionSnapshot) => BindingMode; isSelected: (snapshot: SelectionSnapshot, id: string) => boolean;};Name
Kind
Type
Requirement
anchorIdproperty
(snapshot: SelectionSnapshot) => string | nullrequired
bindingModeproperty
(snapshot: SelectionSnapshot) => BindingModerequired
isSelectedproperty
(snapshot: SelectionSnapshot, id: string) => booleanrequired
selectedIdsproperty
(snapshot: SelectionSnapshot) => SelectionValuerequired
- Name
anchorId- Kind
- property
- Type
(snapshot: SelectionSnapshot) => string | null- Requirement
- required
- Name
bindingMode- Kind
- property
- Type
(snapshot: SelectionSnapshot) => BindingMode- Requirement
- required
- Name
isSelected- Kind
- property
- Type
(snapshot: SelectionSnapshot, id: string) => boolean- Requirement
- required
- Name
selectedIds- Kind
- property
- Type
(snapshot: SelectionSnapshot) => SelectionValue- Requirement
- required
SelectionSnapshot
typeSelectionSnapshotts
type SelectionSnapshot = Snapshot<SelectionStateValue, SelectionContext>;SelectionStateValue
typeSelectionStateValuets
type SelectionStateValue = "ready";SelectionValue
typeSelectionValuets
type SelectionValue = readonly string[];