DocsAPI referenceUI machinesnotification-center

notification-center machine

The public state machine contract for @grassroot/ui-machines/notification-center. The machine owns behaviour; the matching headless layer owns composition.

@grassroot/ui-machines/notification-center

Package

23 exports
View source packages/ui-machines/src/notification-center/index.ts

Service example

notification-center.tsts
import { createService } from "@grassroot/statechart";
import { notificationCenterMachine } from "@grassroot/ui-machines/notification-center";
const service = createService(notificationCenterMachine, { input: {} });
service.start();
service.send({ type: "…" });
service.stop();

Exports

Duplicate of frozen `countUnreadNotifications`.

DeclarationView source
countUnreadNotificationProjectionsts
declare function countUnreadNotificationProjections(items: readonly NotificationItemProjection[]): number;
Name
Kind
Type
Requirement
items
parameter
readonly NotificationItemProjection[]
required
return
return value
number
n/a
Name
items
Kind
parameter
Type
readonly NotificationItemProjection[]
Requirement
required
Name
return
Kind
return value
Type
number
Requirement
n/a

Duplicate of frozen `groupNotifications`.

DeclarationView source
groupNotificationProjectionsts
declare function groupNotificationProjections(items: readonly NotificationItemProjection[]): readonly NotificationGroupProjection[];
Name
Kind
Type
Requirement
items
parameter
readonly NotificationItemProjection[]
required
return
return value
readonly NotificationGroupProjection[]
n/a
Name
items
Kind
parameter
Type
readonly NotificationItemProjection[]
Requirement
required
Name
return
Kind
return value
Type
readonly NotificationGroupProjection[]
Requirement
n/a
DeclarationView source
NotificationActionts
type NotificationAction = {
readonly type: "markAllRead";
} | {
readonly type: "dismiss";
readonly id: string;
};
DeclarationView source
NotificationCenterChangeReasonts
type NotificationCenterChangeReason = "pointer" | "keyboard" | "programmatic";
DeclarationView source
NotificationCenterCommandts
type NotificationCenterCommand = CommandObject & {
readonly type: "ITEMS_CHANGE_REQUEST";
readonly items: readonly NotificationItemProjection[];
readonly action: NotificationAction;
readonly reason: NotificationCenterChangeReason;
};
Name
Kind
Type
Requirement
action
property
NotificationAction
required
items
property
readonly NotificationItemProjection[]
required
reason
property
NotificationCenterChangeReason
required
type
property
string
required
Name
action
Kind
property
Type
NotificationAction
Requirement
required
Name
items
Kind
property
Type
readonly NotificationItemProjection[]
Requirement
required
Name
reason
Kind
property
Type
NotificationCenterChangeReason
Requirement
required
Name
type
Kind
property
Type
string
Requirement
required
DeclarationView source
NotificationCenterContextts
type NotificationCenterContext = {
readonly mode: BindingMode;
readonly items: readonly NotificationItemProjection[];
};
Name
Kind
Type
Requirement
items
property
readonly NotificationItemProjection[]
required
mode
property
BindingMode
required
Name
items
Kind
property
Type
readonly NotificationItemProjection[]
Requirement
required
Name
mode
Kind
property
Type
BindingMode
Requirement
required
DeclarationView source
NotificationCenterDiagnosticCodests
export declare const NotificationCenterDiagnosticCodes: readonly DiagnosticCatalogueEntry[];
DeclarationView source
NotificationCenterEventts
type NotificationCenterEvent = {
readonly type: "MARK_ALL_READ";
readonly reason: NotificationCenterChangeReason;
} | {
readonly type: "DISMISS";
readonly id: string;
readonly reason: NotificationCenterChangeReason;
} | {
readonly type: "RESET";
};
DeclarationView source
NotificationCenterInputts
type NotificationCenterInput = {
/** Controlled committed projections. Defining it (including `[]`) fixes controlled mode. */
readonly items?: readonly NotificationItemProjection[];
/** Uncontrolled initial projections. @default [] */
readonly defaultItems?: readonly NotificationItemProjection[];
/** Accessible name. Presentation-only; the machine ignores it. @default "Notifications" */
readonly title?: string;
};
Name
Kind
Type
Requirement
Description
defaultItems
property
readonly NotificationItemProjection[]
optional
Uncontrolled initial projections.
items
property
readonly NotificationItemProjection[]
optional
Controlled committed projections. Defining it (including `[]`) fixes controlled mode.
title
property
string
optional
Accessible name. Presentation-only; the machine ignores it.
Name
defaultItems
Kind
property
Type
readonly NotificationItemProjection[]
Requirement
optional
Description
Uncontrolled initial projections.
Name
items
Kind
property
Type
readonly NotificationItemProjection[]
Requirement
optional
Description
Controlled committed projections. Defining it (including `[]`) fixes controlled mode.
Name
title
Kind
property
Type
string
Requirement
optional
Description
Accessible name. Presentation-only; the machine ignores it.
DeclarationView source
notificationCenterMachinets
export declare const notificationCenterMachine: NotificationCenterMachine;
DeclarationView source
NotificationCenterMachinets
type NotificationCenterMachine = Machine<NotificationCenterInput, NotificationCenterStateValue, NotificationCenterContext, NotificationCenterEvent, NotificationCenterCommand>;
DeclarationView source
NotificationCenterMachineStatets
type NotificationCenterMachineState = MachineState<NotificationCenterStateValue, NotificationCenterContext>;
DeclarationView source
notificationCenterReplaySequencets
export declare const notificationCenterReplaySequence: readonly NotificationCenterEvent[];
DeclarationView source
notificationCenterSelectorsts
export declare const notificationCenterSelectors: {
items: (snapshot: NotificationCenterSnapshot) => readonly NotificationItemProjection[];
mode: (snapshot: NotificationCenterSnapshot) => BindingMode;
unreadCount: (snapshot: NotificationCenterSnapshot) => number;
groups: (snapshot: NotificationCenterSnapshot) => readonly NotificationGroupProjection[];
};
Name
Kind
Type
Requirement
groups
property
(snapshot: NotificationCenterSnapshot) => readonly NotificationGroupProjection[]
required
items
property
(snapshot: NotificationCenterSnapshot) => readonly NotificationItemProjection[]
required
mode
property
(snapshot: NotificationCenterSnapshot) => BindingMode
required
unreadCount
property
(snapshot: NotificationCenterSnapshot) => number
required
Name
groups
Kind
property
Type
(snapshot: NotificationCenterSnapshot) => readonly NotificationGroupProjection[]
Requirement
required
Name
items
Kind
property
Type
(snapshot: NotificationCenterSnapshot) => readonly NotificationItemProjection[]
Requirement
required
Name
mode
Kind
property
Type
(snapshot: NotificationCenterSnapshot) => BindingMode
Requirement
required
Name
unreadCount
Kind
property
Type
(snapshot: NotificationCenterSnapshot) => number
Requirement
required
DeclarationView source
NotificationCenterSnapshotts
type NotificationCenterSnapshot = Snapshot<NotificationCenterStateValue, NotificationCenterContext>;
DeclarationView source
NotificationCenterStateValuets
type NotificationCenterStateValue = "active";
DeclarationView source
NotificationGroupProjectionts
type NotificationGroupProjection = {
readonly name: string;
readonly rows: readonly NotificationItemProjection[];
};
Name
Kind
Type
Requirement
name
property
string
required
rows
property
readonly NotificationItemProjection[]
required
Name
name
Kind
property
Type
string
Requirement
required
Name
rows
Kind
property
Type
readonly NotificationItemProjection[]
Requirement
required
DeclarationView source
NotificationItemProjectionts
type NotificationItemProjection = {
readonly id: string;
readonly group: string;
readonly kind: NotificationKind;
readonly time: string;
readonly unread: boolean;
};
Name
Kind
Type
Requirement
group
property
string
required
id
property
string
required
kind
property
NotificationKind
required
time
property
string
required
unread
property
boolean
required
Name
group
Kind
property
Type
string
Requirement
required
Name
id
Kind
property
Type
string
Requirement
required
Name
kind
Kind
property
Type
NotificationKind
Requirement
required
Name
time
Kind
property
Type
string
Requirement
required
Name
unread
Kind
property
Type
boolean
Requirement
required
DeclarationView source
NotificationKindts
type NotificationKind = "deploy" | "alert" | "mention" | "pr" | "error";
DeclarationView source
notificationProjectionsEqualts
declare function notificationProjectionsEqual(left: readonly NotificationItemProjection[], right: readonly NotificationItemProjection[]): boolean;
Name
Kind
Type
Requirement
left
parameter
readonly NotificationItemProjection[]
required
right
parameter
readonly NotificationItemProjection[]
required
return
return value
boolean
n/a
Name
left
Kind
parameter
Type
readonly NotificationItemProjection[]
Requirement
required
Name
right
Kind
parameter
Type
readonly NotificationItemProjection[]
Requirement
required
Name
return
Kind
return value
Type
boolean
Requirement
n/a
DeclarationView source
projectNotificationItemts
declare function projectNotificationItem(item: {
readonly id: string;
readonly group: string;
readonly kind: NotificationKind;
readonly time: string;
readonly unread?: boolean;
}): NotificationItemProjection;
Name
Kind
Type
Requirement
item
parameter
{ readonly id: string; readonly group: string; readonly kind: NotificationKind; readonly time: string; readonly unread?: boolean; }
required
return
return value
NotificationItemProjection
n/a
Name
item
Kind
parameter
Type
{ readonly id: string; readonly group: string; readonly kind: NotificationKind; readonly time: string; readonly unread?: boolean; }
Requirement
required
Name
return
Kind
return value
Type
NotificationItemProjection
Requirement
n/a
DeclarationView source
projectNotificationItemsts
declare function projectNotificationItems(items: readonly {
readonly id: string;
readonly group: string;
readonly kind: NotificationKind;
readonly time: string;
readonly unread?: boolean;
}[]): NotificationItemProjection[];
Name
Kind
Type
Requirement
items
parameter
readonly { readonly id: string; readonly group: string; readonly kind: NotificationKind; readonly time: string; readonly unread?: boolean; }[]
required
return
return value
NotificationItemProjection[]
n/a
Name
items
Kind
parameter
Type
readonly { readonly id: string; readonly group: string; readonly kind: NotificationKind; readonly time: string; readonly unread?: boolean; }[]
Requirement
required
Name
return
Kind
return value
Type
NotificationItemProjection[]
Requirement
n/a

Duplicate of frozen `reduceNotifications`, with S6 same-reference no-ops.

DeclarationView source
reduceNotificationProjectionsts
declare function reduceNotificationProjections(items: readonly NotificationItemProjection[], action: NotificationAction): readonly NotificationItemProjection[];
Name
Kind
Type
Requirement
items
parameter
readonly NotificationItemProjection[]
required
action
parameter
NotificationAction
required
return
return value
readonly NotificationItemProjection[]
n/a
Name
items
Kind
parameter
Type
readonly NotificationItemProjection[]
Requirement
required
Name
action
Kind
parameter
Type
NotificationAction
Requirement
required
Name
return
Kind
return value
Type
readonly NotificationItemProjection[]
Requirement
n/a