- Name
theme- Kind
- property
- Type
string- Requirement
- required
Docs/API reference/UI machines/theme-menu
theme-menu machine
The public state machine contract for @grassroot/ui-machines/theme-menu. The machine owns behaviour; the matching headless layer owns composition.
@grassroot/ui-machines/theme-menu
Package
View source
packages/ui-machines/src/theme-menu/index.ts
Service example
theme-menu.tsts
1
2
3
4
5
6
7
import { createService } from "@grassroot/statechart";import { themeMenuMachine } from "@grassroot/ui-machines/theme-menu"; const service = createService(themeMenuMachine, { input: {} });service.start();service.send({ type: "…" });service.stop();15 of 15
Exports
DeclarationView source
ThemeMenuChangeReasonts
type ThemeMenuChangeReason = ThemeMenuOpenReason | ThemeMenuCloseReason;ThemeMenuCloseReason
typeDeclarationView source
ThemeMenuCloseReasonts
type ThemeMenuCloseReason = "escape" | "outside-click" | "select" | "programmatic";ThemeMenuCommand
typeDeclarationView source
ThemeMenuCommandts
type ThemeMenuCommand = (CommandObject & { readonly type: "OPEN_CHANGE_REQUEST"; readonly open: boolean; readonly reason: ThemeMenuChangeReason;}) | (CommandObject & { readonly type: "THEME_CHANGE_REQUEST"; readonly theme: string; readonly storageKey: string; readonly reason: "select";}) | ScheduleCommand<ThemeMenuEvent> | CancelCommand;ThemeMenuContext
typeDeclarationView source
ThemeMenuContextts
type ThemeMenuContext = MenuContext & { readonly theme: string;};Name
Kind
Type
Requirement
themeproperty
stringrequired
ThemeMenuDiagnosticCodes
valueDeclarationView source
ThemeMenuDiagnosticCodests
export declare const ThemeMenuDiagnosticCodes: readonly DiagnosticCatalogueEntry[];ThemeMenuEvent
typeDeclarationView source
ThemeMenuEventts
type ThemeMenuEvent = { readonly type: "TOGGLE"; readonly reason: "trigger";} | { readonly type: "OPEN"; readonly reason: ThemeMenuOpenReason; readonly highlight?: "first" | "last";} | { readonly type: "CLOSE"; readonly reason: ThemeMenuCloseReason;} | { readonly type: "MOVE"; readonly direction: -1 | 1;} | { readonly type: "HIGHLIGHT"; readonly index: number;} | { readonly type: "HOME";} | { readonly type: "END";} | { readonly type: "SELECT";} | { readonly type: "TYPEAHEAD"; readonly char: string;} | { readonly type: "SYNC_THEME"; readonly theme: string;};ThemeMenuInput
typeDeclarationView source
ThemeMenuInputts
type ThemeMenuInput = { readonly open?: boolean; readonly defaultOpen?: boolean; readonly items: readonly ThemeMenuItem[]; readonly theme?: string; /** Required uncontrolled seed when no current theme is supplied. */ readonly defaultTheme: string; /** Required key copied into the persistence command. */ readonly storageKey: string; readonly typeaheadTimeoutMs?: number;};Name
Kind
Type
Requirement
Description
defaultOpenproperty
booleanoptional
—
defaultThemeproperty
stringrequired
Required uncontrolled seed when no current theme is supplied.
itemsproperty
readonly ThemeMenuItem[]required
—
openproperty
booleanoptional
—
storageKeyproperty
stringrequired
Required key copied into the persistence command.
themeproperty
stringoptional
—
typeaheadTimeoutMsproperty
numberoptional
—
- Name
defaultOpen- Kind
- property
- Type
boolean- Requirement
- optional
- Description
- —
- Name
defaultTheme- Kind
- property
- Type
string- Requirement
- required
- Description
- Required uncontrolled seed when no current theme is supplied.
- Name
items- Kind
- property
- Type
readonly ThemeMenuItem[]- Requirement
- required
- Description
- —
- Name
open- Kind
- property
- Type
boolean- Requirement
- optional
- Description
- —
- Name
storageKey- Kind
- property
- Type
string- Requirement
- required
- Description
- Required key copied into the persistence command.
- Name
theme- Kind
- property
- Type
string- Requirement
- optional
- Description
- —
- Name
typeaheadTimeoutMs- Kind
- property
- Type
number- Requirement
- optional
- Description
- —
ThemeMenuItem
interfaceDeclarationView source
ThemeMenuItemts
interface ThemeMenuItem { readonly id: string; readonly value: string; readonly disabled?: boolean; readonly textValue?: string;}Name
Kind
Type
Requirement
disabledproperty
booleanoptional
idproperty
stringrequired
textValueproperty
stringoptional
valueproperty
stringrequired
- Name
disabled- Kind
- property
- Type
boolean- Requirement
- optional
- Name
id- Kind
- property
- Type
string- Requirement
- required
- Name
textValue- Kind
- property
- Type
string- Requirement
- optional
- Name
value- Kind
- property
- Type
string- Requirement
- required
themeMenuMachine
valueDeclarationView source
themeMenuMachinets
export declare const themeMenuMachine: ThemeMenuMachine;ThemeMenuMachine
typeDeclarationView source
ThemeMenuMachinets
type ThemeMenuMachine = Machine<ThemeMenuInput, ThemeMenuStateValue, ThemeMenuContext, ThemeMenuEvent, ThemeMenuCommand>;ThemeMenuOpenReason
typeDeclarationView source
ThemeMenuOpenReasonts
type ThemeMenuOpenReason = "trigger" | "programmatic";themeMenuReplaySequence
valueDeclarationView source
themeMenuReplaySequencets
export declare const themeMenuReplaySequence: readonly ThemeMenuEvent[];themeMenuSelectors
valueDeclarationView source
themeMenuSelectorsts
export declare const themeMenuSelectors: { open: (snapshot: ThemeMenuSnapshot) => boolean; highlightedIndex: (snapshot: ThemeMenuSnapshot) => number; typeaheadBuffer: (snapshot: ThemeMenuSnapshot) => string; theme: (snapshot: ThemeMenuSnapshot) => string;};Name
Kind
Type
Requirement
highlightedIndexproperty
(snapshot: ThemeMenuSnapshot) => numberrequired
openproperty
(snapshot: ThemeMenuSnapshot) => booleanrequired
themeproperty
(snapshot: ThemeMenuSnapshot) => stringrequired
typeaheadBufferproperty
(snapshot: ThemeMenuSnapshot) => stringrequired
- Name
highlightedIndex- Kind
- property
- Type
(snapshot: ThemeMenuSnapshot) => number- Requirement
- required
- Name
open- Kind
- property
- Type
(snapshot: ThemeMenuSnapshot) => boolean- Requirement
- required
- Name
theme- Kind
- property
- Type
(snapshot: ThemeMenuSnapshot) => string- Requirement
- required
- Name
typeaheadBuffer- Kind
- property
- Type
(snapshot: ThemeMenuSnapshot) => string- Requirement
- required
ThemeMenuSnapshot
typeDeclarationView source
ThemeMenuSnapshotts
type ThemeMenuSnapshot = Snapshot<ThemeMenuStateValue, ThemeMenuContext>;ThemeMenuStateValue
typeDeclarationView source
ThemeMenuStateValuets
type ThemeMenuStateValue = "open" | "closed";