import { KbqNotificationCenterModule } from '@koobiq/components/notification-center';

KbqNotificationCenterTrigger

directiveCopy link to KbqNotificationCenterTrigger
@Directive({
    selector: '[kbqNotificationCenterTrigger]',
    exportAs: 'kbqNotificationCenterTrigger'
})
class KbqNotificationCenterTrigger extends KbqPopUpTrigger<KbqNotificationCenterComponent> {
    readonly backdropClass = input<string>(
        'cdk-overlay-transparent-backdrop'
    );
    readonly panelClass = input<string>('', {
        alias: 'kbqNotificationCenterPanelClass'
    });
    readonly offset = input<number>(defaultOffsetX);
    readonly scrolledToBottomOffset = input<number>(0);
    popoverMode = input<boolean | undefined>();
    popoverHeight = input<string | undefined>();
    disabled = input<boolean | undefined>();
    stickToWindow = input<KbqStickToWindowPlacementValues | undefined>();
    container = input<HTMLElement | undefined>();
    get unreadItemsCounter(): Signal<string>;
    placement: KbqPopUpPlacementValues;
    readonly placementChange: EventEmitter<KbqPopUpPlacementValues>;
    readonly visibleChange: EventEmitter<boolean>;
    isOpen: boolean;
    get isAttached(): boolean;
    get openedChange(): Observable<boolean>;
    arrowCentered: boolean;
    updateOrigin(origin: KbqOverlayOrigin | null): void;
}
backdropClassinputCopy link to backdropClassstring

Class that will be used in the background

kbqNotificationCenterPanelClassinputCopy link to kbqNotificationCenterPanelClassstring

Class that will be used in the panel

offsetinputCopy link to offsetnumber

Offset of popUp

scrolledToBottomOffsetinputCopy link to scrolledToBottomOffsetnumber

Distance in pixels from the bottom of the list at which the next page is requested via onNextPage.

popoverModeinputCopy link to popoverModeboolean | undefined

Use popover or not

popoverHeightinputCopy link to popoverHeightstring | undefined

Set height of popover. Default is calc(100vh - <navbar height>).

disabledinputCopy link to disabledboolean | undefined

Whether the trigger is disabled.

stickToWindowinputCopy link to stickToWindowKbqStickToWindowPlacementValues | undefined

Additionally positions the element relative to the window side (Top, Right, Bottom and Left). If container is specified, the positioning will be relative to it.

containerinputCopy link to containerHTMLElement | undefined

Container for additional positioning, used with stickToWindow

unreadItemsCounterCopy link to unreadItemsCounterSignal<string>

Number of unread notifications, formatted for the trigger badge.

placementChangeCopy link to placementChangeEventEmitter<KbqPopUpPlacementValues>

Emits a change event whenever the placement state changes.

visibleChangeCopy link to visibleChangeEventEmitter<boolean>

Emits a change event whenever the visible state changes.

isOpenCopy link to isOpenboolean

Whether the pop-up overlay is currently open.

isAttachedCopy link to isAttachedboolean

Whether the pop-up overlay is currently attached.

Unlike isOpen, which follows the visibility of the pop-up component and therefore lags a task behind show()/hide(), this flips synchronously — it is the window during which the overlay (and its backdrop) is present in the DOM. Part of the KbqSiblingPopup contract.

openedChangeCopy link to openedChangeObservable<boolean>

Emits true when the pop-up opens and false when it closes. Part of the KbqSiblingPopup contract.

arrowCenteredCopy link to arrowCenteredboolean

Whether the arrow points at the origin center while the panel keeps its placement. Defaults to false.

updateOrigin()Copy link to updateOrigin()void

Positions the pop-up against origin — an element, or a rectangle in viewport coordinates such as the one kbqCreateCaretOrigin keeps on the caret — instead of the host element; null restores the host element. An open pop-up moves to the new origin at once.

This moves the position origin only. setExternalNativeElement moves the host itself, and with it the trigger's event listeners, its focus target and the scroll containers the pop-up follows.

KbqNotificationCenterService

serviceCopy link to KbqNotificationCenterService

State and commands of the notification center: the list itself, its modes, and the removal events.

@Injectable({ providedIn: 'root' })
class KbqNotificationCenterService {
    readonly loadingMore: Signal<boolean>;
    readonly loadMoreErrorMode: Signal<boolean>;
    readonly hasMore: Signal<boolean>;
    readonly onRead: BehaviorSubject<KbqNotificationItem | null>;
    readonly onReload: Subject<void>;
    readonly onNextPage: Subject<void>;
    readonly onDelete: Subject<KbqNotificationDeleteEvent>;
    readonly changes: Observable<void>;
    readonly unreadItemsCounter: Signal<string>;
    items: KbqNotificationItem[];
    get isEmpty(): boolean;
    setSilentMode(value: boolean): void;
    setLoadingMode(value: boolean): void;
    setErrorMode(value: boolean): void;
    setLoadingMore(value: boolean): void;
    setLoadMoreErrorMode(value: boolean): void;
    setHasMore(value: boolean): void;
    push(item: KbqNotificationItem): void;
    hideToast(item: KbqNotificationItem): void;
    remove(removedItem: KbqNotificationItem): void;
    removeGroup(group: KbqNotificationsGroup): void;
    removeAll(): void;
}
loadingMoreCopy link to loadingMoreSignal<boolean>

Whether the bottom "load more" spinner is shown while the next page is being loaded. Note: this is the infinite-scroll indicator and is distinct from loadingMode, which renders the full-screen loader instead of the list. Set it with setLoadingMore().

loadMoreErrorModeCopy link to loadMoreErrorModeSignal<boolean>

Whether the bottom "load more" error row (with a retry button) is shown. Distinct from errorMode, which replaces the whole list with the full-screen error state. Set it with setLoadMoreErrorMode().

hasMoreCopy link to hasMoreSignal<boolean>

Whether there are more notifications to load. While true, scrolling to the bottom emits onNextPage; set it to false with setHasMore() to stop further infinite-scroll requests.

onReadCopy link to onReadBehaviorSubject<KbqNotificationItem | null>

Emits a notification the moment it flips from unread to read.

onReloadCopy link to onReloadSubject<void>

Triggers an event when the user presses the reload button.

onNextPageCopy link to onNextPageSubject<void>

Triggers an event when the list is scrolled to the bottom and the next page should be loaded.

onDeleteCopy link to onDeleteSubject<KbqNotificationDeleteEvent>

Triggers an event when an item, a group, or all notifications are removed.

changesCopy link to changesObservable<void>

Emits whenever any part of the center's state changes. Carries no payload — it is a ping — and emits nothing on subscription.

unreadItemsCounterCopy link to unreadItemsCounterSignal<string>

Number of unread notifications, formatted for the trigger badge: empty while nothing is unread, and "99+" above maxUnreadItemsLength.

itemsCopy link to itemsKbqNotificationItem[]

The notifications, as a snapshot: reading them does not make an effect() or a computed() depend on the list, so an effect can read and reassign it. Follow changes to react to updates.

isEmptyCopy link to isEmptyboolean

Whether there are no notifications. A snapshot, like items.

setSilentMode()Copy link to setSilentMode()void

Set silent mode

setLoadingMode()Copy link to setLoadingMode()void

Set loading mode

setErrorMode()Copy link to setErrorMode()void

Set error mode

setLoadingMore()Copy link to setLoadingMore()void

Set the bottom "load more" spinner visibility.

setLoadMoreErrorMode()Copy link to setLoadMoreErrorMode()void

Set the bottom "load more" error state visibility.

setHasMore()Copy link to setHasMore()void

Set whether there are more notifications to load via infinite scroll.

push()Copy link to push()void

Adds a notification to the list and, unless silent mode is on, shows it as a toast. Re-pushing the very same notification object is a no-op: a duplicate would show a second toast and produce a colliding list key. A different notification carrying an id the list already uses is added under a freshly generated one instead of being dropped.

hideToast()Copy link to hideToast()void

Hides the toast that corresponds to the given notification item.

remove()Copy link to remove()void

Removes a notification. Removing one that is not in the list is a no-op and emits nothing.

removeGroup()Copy link to removeGroup()void

Removes a whole day group. Only the notifications that are actually in the list are removed and reported; a group holding none of them — a stale reference kept from an earlier groupedItems value — is a no-op and emits nothing.

removeAll()Copy link to removeAll()void

Removes every notification. Removing from an already empty list is a no-op and emits nothing.

KbqNotificationCenterPanel

interfaceCopy link to KbqNotificationCenterPanel

The panel members a rendered notification item depends on.

interface KbqNotificationCenterPanel {
    readonly localeConfiguration: Signal<KbqNotificationCenterLocaleConfiguration>;
    restoreFocusAfterRemove(): void;
}
localeConfigurationCopy link to localeConfigurationSignal<KbqNotificationCenterLocaleConfiguration>

Localized strings of the panel.

restoreFocusAfterRemove()Copy link to restoreFocusAfterRemove()void

Moves focus to a control that survives the removal, once the delete button has unmounted.

KbqNotificationDeleteEvent

typeCopy link to KbqNotificationDeleteEvent

Payload emitted by KbqNotificationCenterService.onDelete.

type KbqNotificationDeleteEvent = {
    type: 'item' | 'group' | 'all';
    items: KbqNotificationItem[];
};
typeCopy link to type'item' | 'group' | 'all'

What was removed: a single item, a whole date group, or all notifications.

itemsCopy link to itemsKbqNotificationItem[]

The notification items that were removed.

KbqNotificationItem

interfaceCopy link to KbqNotificationItem

A single notification rendered by the notification center.

interface KbqNotificationItem {
    id?: string;
    toastId?: number;
    title?: string | TemplateRef<unknown>;
    style?: string | KbqToastStyle;
    icon?: boolean | TemplateRef<unknown>;
    iconClass?: string;
    caption?: string | TemplateRef<unknown>;
    content?: string | TemplateRef<unknown>;
    actions?: TemplateRef<unknown>;
    date: string;
    read?: boolean;
}
idoptionalCopy link to idstring

Identity of the notification, unique across the list — it is the list's track key and the key the toast is matched back by. Generated on ingestion when omitted, and replaced by a generated one when the supplied value is already taken by another notification.

toastIdoptionalCopy link to toastIdnumber

Numeric id of the shown toast, set by push() and consumed by hideToast().

titleoptionalCopy link to titlestring | TemplateRef<unknown>

Heading of the notification.

styleoptionalCopy link to stylestring | KbqToastStyle

Visual style; also selects the built-in icon when icon is true.

iconoptionalCopy link to iconboolean | TemplateRef<unknown>

true renders the built-in icon for style; a template renders that template instead.

iconClassoptionalCopy link to iconClassstring

Extra classes for the built-in icon.

captionoptionalCopy link to captionstring | TemplateRef<unknown>

Secondary line below the title.

contentoptionalCopy link to contentstring | TemplateRef<unknown>

Body of the notification.

actionsoptionalCopy link to actionsTemplateRef<unknown>

Template with the notification's action controls.

dateCopy link to datestring

When the notification happened. Any value the configured DateAdapter parses without an explicit format — ISO 8601, RFC 2822 or SQL for the Luxon adapter. The value drives both the day group and the ordering; values the adapter cannot parse are shown verbatim in their own group instead of breaking the list.

readoptionalCopy link to readboolean

Whether the user has already read the notification. Defaults to false on ingestion.

KbqNotificationsGroup

typeCopy link to KbqNotificationsGroup

Notifications that happened on the same day, as rendered by one sub-header of the panel.

type KbqNotificationsGroup = {
    id: string;
    title: string;
    items: KbqNotificationItem[];
};
idCopy link to idstring

Stable identity of the day group; used as the list's track key.

titleCopy link to titlestring

Localized day heading.

itemsCopy link to itemsKbqNotificationItem[]

Notifications of that day, newest first.

KBQ_NOTIFICATION_CENTER_CONFIGURATION

constDeprecatedCopy link to KBQ_NOTIFICATION_CENTER_CONFIGURATION

Use KBQ_NOTIFICATION_CENTER_LOCALE_CONFIGURATION. Will be removed in 22.0.0.

const KBQ_NOTIFICATION_CENTER_CONFIGURATION: InjectionToken<KbqNotificationCenterLocaleConfiguration>;

KBQ_NOTIFICATION_CENTER_DEFAULT_CONFIGURATION

constDeprecatedCopy link to KBQ_NOTIFICATION_CENTER_DEFAULT_CONFIGURATION

Use KBQ_NOTIFICATION_CENTER_DEFAULT_LOCALE_CONFIGURATION. Will be removed in 22.0.0.

const KBQ_NOTIFICATION_CENTER_DEFAULT_CONFIGURATION: KbqNotificationCenterLocaleConfiguration;

KBQ_NOTIFICATION_CENTER_DEFAULT_LOCALE_CONFIGURATION

constCopy link to KBQ_NOTIFICATION_CENTER_DEFAULT_LOCALE_CONFIGURATION

Default configuration of notification-center.

const KBQ_NOTIFICATION_CENTER_DEFAULT_LOCALE_CONFIGURATION: KbqNotificationCenterLocaleConfiguration;

KBQ_NOTIFICATION_CENTER_LOCALE_CONFIGURATION

constCopy link to KBQ_NOTIFICATION_CENTER_LOCALE_CONFIGURATION

Injection Token for providing configuration of notification-center.

const KBQ_NOTIFICATION_CENTER_LOCALE_CONFIGURATION: InjectionToken<KbqNotificationCenterLocaleConfiguration>;

KBQ_NOTIFICATION_CENTER_PANEL

constCopy link to KBQ_NOTIFICATION_CENTER_PANEL

Narrow contract a kbq-notification-item consumes from the panel that renders it, instead of injecting the panel component itself.

const KBQ_NOTIFICATION_CENTER_PANEL: InjectionToken<KbqNotificationCenterPanel>;

kbqNotificationCenterLocaleConfigurationProvider

constCopy link to kbqNotificationCenterLocaleConfigurationProvider

Utility provider for KBQ_NOTIFICATION_CENTER_LOCALE_CONFIGURATION. Only the strings you pass are overridden; the rest keep following the active locale.

const kbqNotificationCenterLocaleConfigurationProvider: (
    configuration: KbqDeepPartial<KbqNotificationCenterLocaleConfiguration>
) => Provider;

maxUnreadItemsLength

constCopy link to maxUnreadItemsLength

Number of unread notifications above which the trigger counter switches to "99+".

const maxUnreadItemsLength: number;
Suggestions for improvement
If you found a mistake or want to improve the article, create an issue on GitHub.