- Name
nextKey- Kind
- property
- Type
number- Requirement
- required
DocsAPI referenceUI machinestoast
toast machine
The public state machine contract for @grassroot/ui-machines/toast. The machine owns behaviour; the matching headless layer owns composition.
@grassroot/ui-machines/toast
Package
Service example
toast.tsts
import { createService } from "@grassroot/statechart";import { toastMachine } from "@grassroot/ui-machines/toast"; const service = createService(toastMachine, { input: {} });service.start();service.send({ type: "…" });service.stop();17 of 17
Exports
TOAST_DEFAULT_DURATION
valueTOAST_DEFAULT_DURATIONts
export declare const TOAST_DEFAULT_DURATION: 4000;TOAST_DEFAULT_VARIANT
valueTOAST_DEFAULT_VARIANTts
export declare const TOAST_DEFAULT_VARIANT: "info";TOAST_DISMISS_KEY_PREFIX
valueTOAST_DISMISS_KEY_PREFIXts
export declare const TOAST_DISMISS_KEY_PREFIX: "toast.dismiss.";ToastCommand
typeToastCommandts
type ToastCommand = ScheduleCommand<ToastEvent> | CancelCommand;ToastContext
typeToastContextts
type ToastContext = { readonly nextKey: number; readonly toasts: readonly ToastRecord[];};Name
Kind
Type
Requirement
nextKeyproperty
numberrequired
toastsproperty
readonly ToastRecord[]required
- Name
toasts- Kind
- property
- Type
readonly ToastRecord[]- Requirement
- required
ToastDiagnosticCodes
valueToastDiagnosticCodests
export declare const ToastDiagnosticCodes: readonly DiagnosticCatalogueEntry[];toastDismissKey
functiontoastDismissKeyts
declare function toastDismissKey(instanceKey: string): string;Name
Kind
Type
Requirement
instanceKeyparameter
stringrequired
returnreturn value
stringn/a
- Name
instanceKey- Kind
- parameter
- Type
string- Requirement
- required
- Name
return- Kind
- return value
- Type
string- Requirement
- n/a
ToastEvent
typeToastEventts
type ToastEvent = { readonly type: "ADD"; readonly id: string; readonly variant?: ToastVariant; readonly duration?: number;} | { readonly type: "DISMISS"; readonly id: string;} | { readonly type: "DISMISS_INSTANCE"; readonly instanceKey: string;};ToastInput
typeNo S12 bindings — the queue is service-owned.
ToastInputts
type ToastInput = {};toastMachine
valuetoastMachinets
export declare const toastMachine: ToastMachine;ToastMachine
typeToastMachinets
type ToastMachine = Machine<ToastInput, ToastStateValue, ToastContext, ToastEvent, ToastCommand>;ToastRecord
typeToastRecordts
type ToastRecord = { readonly instanceKey: string; readonly id: string; readonly variant: ToastVariant; readonly duration: number;};Name
Kind
Type
Requirement
durationproperty
numberrequired
idproperty
stringrequired
instanceKeyproperty
stringrequired
variantproperty
ToastVariantrequired
- Name
duration- Kind
- property
- Type
number- Requirement
- required
- Name
id- Kind
- property
- Type
string- Requirement
- required
- Name
instanceKey- Kind
- property
- Type
string- Requirement
- required
- Name
variant- Kind
- property
- Type
ToastVariant- Requirement
- required
toastReplaySequence
valuetoastReplaySequencets
export declare const toastReplaySequence: readonly ToastEvent[];toastSelectors
valuetoastSelectorsts
export declare const toastSelectors: { toasts: (snapshot: ToastSnapshot) => readonly ToastRecord[]; nextKey: (snapshot: ToastSnapshot) => number; ids: (snapshot: ToastSnapshot) => string[]; instanceKeys: (snapshot: ToastSnapshot) => string[]; empty: (snapshot: ToastSnapshot) => boolean;};Name
Kind
Type
Requirement
emptyproperty
(snapshot: ToastSnapshot) => booleanrequired
idsproperty
(snapshot: ToastSnapshot) => string[]required
instanceKeysproperty
(snapshot: ToastSnapshot) => string[]required
nextKeyproperty
(snapshot: ToastSnapshot) => numberrequired
toastsproperty
(snapshot: ToastSnapshot) => readonly ToastRecord[]required
- Name
empty- Kind
- property
- Type
(snapshot: ToastSnapshot) => boolean- Requirement
- required
- Name
ids- Kind
- property
- Type
(snapshot: ToastSnapshot) => string[]- Requirement
- required
- Name
instanceKeys- Kind
- property
- Type
(snapshot: ToastSnapshot) => string[]- Requirement
- required
- Name
nextKey- Kind
- property
- Type
(snapshot: ToastSnapshot) => number- Requirement
- required
- Name
toasts- Kind
- property
- Type
(snapshot: ToastSnapshot) => readonly ToastRecord[]- Requirement
- required
ToastSnapshot
typeToastSnapshotts
type ToastSnapshot = Snapshot<ToastStateValue, ToastContext>;ToastStateValue
typeToastStateValuets
type ToastStateValue = "idle" | "queued";ToastVariant
typeToastVariantts
type ToastVariant = "info" | "success" | "warning" | "error";