DocsAPI referenceUI machinestheme-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

15 exports
View source packages/ui-machines/src/theme-menu/index.ts

Service example

theme-menu.tsts
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();

Exports

DeclarationView source
ThemeMenuChangeReasonts
type ThemeMenuChangeReason = ThemeMenuOpenReason | ThemeMenuCloseReason;
DeclarationView source
ThemeMenuCloseReasonts
type ThemeMenuCloseReason = "escape" | "outside-click" | "select" | "programmatic";
DeclarationView 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;
DeclarationView source
ThemeMenuContextts
type ThemeMenuContext = MenuContext & {
readonly theme: string;
};
Name
Kind
Type
Requirement
theme
property
string
required
Name
theme
Kind
property
Type
string
Requirement
required
DeclarationView source
ThemeMenuDiagnosticCodests
export declare const ThemeMenuDiagnosticCodes: readonly DiagnosticCatalogueEntry[];
DeclarationView 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;
};
DeclarationView 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
defaultOpen
property
boolean
optional
defaultTheme
property
string
required
Required uncontrolled seed when no current theme is supplied.
items
property
readonly ThemeMenuItem[]
required
open
property
boolean
optional
storageKey
property
string
required
Required key copied into the persistence command.
theme
property
string
optional
typeaheadTimeoutMs
property
number
optional
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

interface
DeclarationView source
ThemeMenuItemts
interface ThemeMenuItem {
readonly id: string;
readonly value: string;
readonly disabled?: boolean;
readonly textValue?: string;
}
Name
Kind
Type
Requirement
disabled
property
boolean
optional
id
property
string
required
textValue
property
string
optional
value
property
string
required
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
DeclarationView source
themeMenuMachinets
export declare const themeMenuMachine: ThemeMenuMachine;
DeclarationView source
ThemeMenuMachinets
type ThemeMenuMachine = Machine<ThemeMenuInput, ThemeMenuStateValue, ThemeMenuContext, ThemeMenuEvent, ThemeMenuCommand>;
DeclarationView source
ThemeMenuOpenReasonts
type ThemeMenuOpenReason = "trigger" | "programmatic";
DeclarationView source
themeMenuReplaySequencets
export declare const themeMenuReplaySequence: readonly ThemeMenuEvent[];
DeclarationView 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
highlightedIndex
property
(snapshot: ThemeMenuSnapshot) => number
required
open
property
(snapshot: ThemeMenuSnapshot) => boolean
required
theme
property
(snapshot: ThemeMenuSnapshot) => string
required
typeaheadBuffer
property
(snapshot: ThemeMenuSnapshot) => string
required
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
DeclarationView source
ThemeMenuSnapshotts
type ThemeMenuSnapshot = Snapshot<ThemeMenuStateValue, ThemeMenuContext>;
DeclarationView source
ThemeMenuStateValuets
type ThemeMenuStateValue = "open" | "closed";