- Name
focusedValue- Kind
- property
- Type
string- Requirement
- optional
DocsAPI referenceUI machinestoggle-group
toggle-group machine
The public state machine contract for @grassroot/ui-machines/toggle-group. The machine owns behaviour; the matching headless layer owns composition.
@grassroot/ui-machines/toggle-group
Package
Service example
toggle-group.tsts
import { createService } from "@grassroot/statechart";import { segmentedMachine } from "@grassroot/ui-machines/toggle-group"; const service = createService(segmentedMachine, { input: {} });service.start();service.send({ type: "…" });service.stop();25 of 25
Exports
SegmentedChangeReasonts
type SegmentedChangeReason = "pointer" | "keyboard" | "programmatic";SegmentedCommand
typeSegmentedCommandts
type SegmentedCommand = CommandObject & ({ readonly type: "VALUE_CHANGE_REQUEST"; readonly value: SegmentedSelection; readonly reason: SegmentedChangeReason;} | { readonly type: "FOCUS_ITEM"; readonly key: string;});SegmentedContext
typeSegmentedContextts
type SegmentedContext = { readonly type: SegmentedType; readonly value: SegmentedSelection | undefined; readonly focusedValue?: string; readonly mode: BindingMode;};Name
Kind
Type
Requirement
focusedValueproperty
stringoptional
modeproperty
BindingModerequired
typeproperty
SegmentedTyperequired
valueproperty
SegmentedSelection | undefinedrequired
- Name
mode- Kind
- property
- Type
BindingMode- Requirement
- required
- Name
type- Kind
- property
- Type
SegmentedType- Requirement
- required
- Name
value- Kind
- property
- Type
SegmentedSelection | undefined- Requirement
- required
SegmentedDiagnosticCodes
valueSegmentedDiagnosticCodests
export declare const SegmentedDiagnosticCodes: readonly DiagnosticCatalogueEntry[];SegmentedEvent
typeSegmentedEventts
type SegmentedEvent = { readonly type: "SELECT"; readonly value: string; readonly reason: SegmentedChangeReason;} | { readonly type: "MOVE"; readonly direction: -1 | 1;} | { readonly type: "HOME";} | { readonly type: "END";} | { readonly type: "FOCUS"; readonly value: string;} | { readonly type: "BLUR";} | { readonly type: "RESET";};SegmentedInput
typeSegmentedInputts
type SegmentedInput = { readonly options: readonly SegmentedItem[]; readonly type?: SegmentedType; /** Controlled committed value. A defined empty array is controlled. */ readonly value?: SegmentedSelection; /** Uncontrolled initial value. */ readonly defaultValue?: SegmentedSelection; readonly disabled?: boolean; readonly readOnly?: boolean; /** Connector hint; the machine receives logical movement only. */ readonly orientation?: SegmentedOrientation; readonly loop?: boolean;};Name
Kind
Type
Requirement
Description
defaultValueproperty
SegmentedSelectionoptional
Uncontrolled initial value.
disabledproperty
booleanoptional
—
loopproperty
booleanoptional
—
optionsproperty
readonly SegmentedItem[]required
—
orientationproperty
SegmentedOrientationoptional
Connector hint; the machine receives logical movement only.
readOnlyproperty
booleanoptional
—
typeproperty
SegmentedTypeoptional
—
valueproperty
SegmentedSelectionoptional
Controlled committed value. A defined empty array is controlled.
- Name
defaultValue- Kind
- property
- Type
SegmentedSelection- Requirement
- optional
- Description
- Uncontrolled initial value.
- Name
disabled- Kind
- property
- Type
boolean- Requirement
- optional
- Description
- —
- Name
loop- Kind
- property
- Type
boolean- Requirement
- optional
- Description
- —
- Name
options- Kind
- property
- Type
readonly SegmentedItem[]- Requirement
- required
- Description
- —
- Name
orientation- Kind
- property
- Type
SegmentedOrientation- Requirement
- optional
- Description
- Connector hint; the machine receives logical movement only.
- Name
readOnly- Kind
- property
- Type
boolean- Requirement
- optional
- Description
- —
- Name
type- Kind
- property
- Type
SegmentedType- Requirement
- optional
- Description
- —
- Name
value- Kind
- property
- Type
SegmentedSelection- Requirement
- optional
- Description
- Controlled committed value. A defined empty array is controlled.
SegmentedItem
interfaceSegmentedItemts
interface SegmentedItem { readonly value: string; readonly disabled?: boolean;}Name
Kind
Type
Requirement
disabledproperty
booleanoptional
valueproperty
stringrequired
- Name
disabled- Kind
- property
- Type
boolean- Requirement
- optional
- Name
value- Kind
- property
- Type
string- Requirement
- required
segmentedMachine
valuesegmentedMachinets
export declare const segmentedMachine: SegmentedMachine;SegmentedMachine
typeSegmentedMachinets
type SegmentedMachine = Machine<SegmentedInput, SegmentedStateValue, SegmentedContext, SegmentedEvent, SegmentedCommand>;SegmentedOrientation
typeSegmentedOrientationts
type SegmentedOrientation = "horizontal" | "vertical";segmentedReplaySequence
valuesegmentedReplaySequencets
export declare const segmentedReplaySequence: readonly SegmentedEvent[];SegmentedSelection
typeSegmentedSelectionts
type SegmentedSelection = string | readonly string[];segmentedSelectors
valuesegmentedSelectorsts
export declare const segmentedSelectors: { type: (snapshot: SegmentedSnapshot) => SegmentedType; value: (snapshot: SegmentedSnapshot) => SegmentedSelection | undefined; focusedValue: (snapshot: SegmentedSnapshot) => string | undefined; isSelected: (snapshot: SegmentedSnapshot, value: string) => boolean;};Name
Kind
Type
Requirement
focusedValueproperty
(snapshot: SegmentedSnapshot) => string | undefinedrequired
isSelectedproperty
(snapshot: SegmentedSnapshot, value: string) => booleanrequired
typeproperty
(snapshot: SegmentedSnapshot) => SegmentedTyperequired
valueproperty
(snapshot: SegmentedSnapshot) => SegmentedSelection | undefinedrequired
- Name
focusedValue- Kind
- property
- Type
(snapshot: SegmentedSnapshot) => string | undefined- Requirement
- required
- Name
isSelected- Kind
- property
- Type
(snapshot: SegmentedSnapshot, value: string) => boolean- Requirement
- required
- Name
type- Kind
- property
- Type
(snapshot: SegmentedSnapshot) => SegmentedType- Requirement
- required
- Name
value- Kind
- property
- Type
(snapshot: SegmentedSnapshot) => SegmentedSelection | undefined- Requirement
- required
SegmentedSnapshot
typeSegmentedSnapshotts
type SegmentedSnapshot = Snapshot<SegmentedStateValue, SegmentedContext>;SegmentedStateValue
typeSegmentedStateValuets
type SegmentedStateValue = "ready";SegmentedType
typeSegmentedTypets
type SegmentedType = "single" | "multiple";ToggleGroupCommand
typeToggleGroupCommandts
type ToggleGroupCommand = SegmentedCommand;ToggleGroupContext
typeToggleGroupContextts
type ToggleGroupContext = SegmentedContext;ToggleGroupEvent
typeToggleGroupEventts
type ToggleGroupEvent = SegmentedEvent;ToggleGroupInput
typeToggleGroupInputts
type ToggleGroupInput = SegmentedInput;ToggleGroupItem
typeToggleGroupItemts
type ToggleGroupItem = SegmentedItem;toggleGroupMachine
valuetoggleGroupMachinets
export declare const toggleGroupMachine: SegmentedMachine;ToggleGroupMachine
typeToggleGroupMachinets
type ToggleGroupMachine = SegmentedMachine;toggleGroupSelectors
valuetoggleGroupSelectorsts
export declare const toggleGroupSelectors: { type: (snapshot: SegmentedSnapshot) => SegmentedType; value: (snapshot: SegmentedSnapshot) => SegmentedSelection | undefined; focusedValue: (snapshot: SegmentedSnapshot) => string | undefined; isSelected: (snapshot: SegmentedSnapshot, value: string) => boolean;};Name
Kind
Type
Requirement
focusedValueproperty
(snapshot: SegmentedSnapshot) => string | undefinedrequired
isSelectedproperty
(snapshot: SegmentedSnapshot, value: string) => booleanrequired
typeproperty
(snapshot: SegmentedSnapshot) => SegmentedTyperequired
valueproperty
(snapshot: SegmentedSnapshot) => SegmentedSelection | undefinedrequired
- Name
focusedValue- Kind
- property
- Type
(snapshot: SegmentedSnapshot) => string | undefined- Requirement
- required
- Name
isSelected- Kind
- property
- Type
(snapshot: SegmentedSnapshot, value: string) => boolean- Requirement
- required
- Name
type- Kind
- property
- Type
(snapshot: SegmentedSnapshot) => SegmentedType- Requirement
- required
- Name
value- Kind
- property
- Type
(snapshot: SegmentedSnapshot) => SegmentedSelection | undefined- Requirement
- required
ToggleGroupSnapshot
typeToggleGroupSnapshotts
type ToggleGroupSnapshot = SegmentedSnapshot;