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

KbqNotificationCenterTrigger

directiveСкопировать ссылку на 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;
}
backdropClassinputСкопировать ссылку на backdropClassstring

Class that will be used in the background

kbqNotificationCenterPanelClassinputСкопировать ссылку на kbqNotificationCenterPanelClassstring

Class that will be used in the panel

offsetinputСкопировать ссылку на offsetnumber

Offset of popUp

scrolledToBottomOffsetinputСкопировать ссылку на scrolledToBottomOffsetnumber

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

popoverModeinputСкопировать ссылку на popoverModeboolean | undefined

Use popover or not

popoverHeightinputСкопировать ссылку на popoverHeightstring | undefined

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

disabledinputСкопировать ссылку на disabledboolean | undefined

Whether the trigger is disabled.

stickToWindowinputСкопировать ссылку на 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.

containerinputСкопировать ссылку на containerHTMLElement | undefined

Container for additional positioning, used with stickToWindow

unreadItemsCounterСкопировать ссылку на unreadItemsCounterSignal<string>

Number of unread notifications, formatted for the trigger badge.

placementChangeСкопировать ссылку на placementChangeEventEmitter<KbqPopUpPlacementValues>

Emits a change event whenever the placement state changes.

visibleChangeСкопировать ссылку на visibleChangeEventEmitter<boolean>

Emits a change event whenever the visible state changes.

isOpenСкопировать ссылку на isOpenboolean

Whether the pop-up overlay is currently open.

isAttachedСкопировать ссылку на 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.

openedChangeСкопировать ссылку на openedChangeObservable<boolean>

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

arrowCenteredСкопировать ссылку на arrowCenteredboolean

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

updateOrigin()Скопировать ссылку на 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

serviceСкопировать ссылку на 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;
}
loadingMoreСкопировать ссылку на 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().

loadMoreErrorModeСкопировать ссылку на 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().

hasMoreСкопировать ссылку на 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.

onReadСкопировать ссылку на onReadBehaviorSubject<KbqNotificationItem | null>

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

onReloadСкопировать ссылку на onReloadSubject<void>

Triggers an event when the user presses the reload button.

onNextPageСкопировать ссылку на onNextPageSubject<void>

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

onDeleteСкопировать ссылку на onDeleteSubject<KbqNotificationDeleteEvent>

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

changesСкопировать ссылку на changesObservable<void>

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

unreadItemsCounterСкопировать ссылку на unreadItemsCounterSignal<string>

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

itemsСкопировать ссылку на 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.

isEmptyСкопировать ссылку на isEmptyboolean

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

setLoadingMore()Скопировать ссылку на setLoadingMore()void

Set the bottom "load more" spinner visibility.

setLoadMoreErrorMode()Скопировать ссылку на setLoadMoreErrorMode()void

Set the bottom "load more" error state visibility.

setHasMore()Скопировать ссылку на setHasMore()void

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

push()Скопировать ссылку на 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()Скопировать ссылку на hideToast()void

Hides the toast that corresponds to the given notification item.

remove()Скопировать ссылку на remove()void

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

removeGroup()Скопировать ссылку на 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()Скопировать ссылку на removeAll()void

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

KbqNotificationCenterPanel

interfaceСкопировать ссылку на KbqNotificationCenterPanel

The panel members a rendered notification item depends on.

interface KbqNotificationCenterPanel {
    readonly localeConfiguration: Signal<KbqNotificationCenterLocaleConfiguration>;
    restoreFocusAfterRemove(): void;
}
restoreFocusAfterRemove()Скопировать ссылку на restoreFocusAfterRemove()void

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

KbqNotificationDeleteEvent

typeСкопировать ссылку на KbqNotificationDeleteEvent

Payload emitted by KbqNotificationCenterService.onDelete.

type KbqNotificationDeleteEvent = {
    type: 'item' | 'group' | 'all';
    items: KbqNotificationItem[];
};
typeСкопировать ссылку на type'item' | 'group' | 'all'

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

itemsСкопировать ссылку на itemsKbqNotificationItem[]

The notification items that were removed.

KbqNotificationItem

interfaceСкопировать ссылку на 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;
}
idoptionalСкопировать ссылку на 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.

toastIdoptionalСкопировать ссылку на toastIdnumber

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

titleoptionalСкопировать ссылку на titlestring | TemplateRef<unknown>

Heading of the notification.

styleoptionalСкопировать ссылку на stylestring | KbqToastStyle

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

iconoptionalСкопировать ссылку на iconboolean | TemplateRef<unknown>

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

iconClassoptionalСкопировать ссылку на iconClassstring

Extra classes for the built-in icon.

captionoptionalСкопировать ссылку на captionstring | TemplateRef<unknown>

Secondary line below the title.

contentoptionalСкопировать ссылку на contentstring | TemplateRef<unknown>

Body of the notification.

actionsoptionalСкопировать ссылку на actionsTemplateRef<unknown>

Template with the notification's action controls.

dateСкопировать ссылку на 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.

readoptionalСкопировать ссылку на readboolean

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

KbqNotificationsGroup

typeСкопировать ссылку на 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[];
};
idСкопировать ссылку на idstring

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

titleСкопировать ссылку на titlestring

Localized day heading.

itemsСкопировать ссылку на itemsKbqNotificationItem[]

Notifications of that day, newest first.

KBQ_NOTIFICATION_CENTER_CONFIGURATION

constDeprecatedСкопировать ссылку на 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

constDeprecatedСкопировать ссылку на 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

constСкопировать ссылку на KBQ_NOTIFICATION_CENTER_DEFAULT_LOCALE_CONFIGURATION

Default configuration of notification-center.

const KBQ_NOTIFICATION_CENTER_DEFAULT_LOCALE_CONFIGURATION: KbqNotificationCenterLocaleConfiguration;

KBQ_NOTIFICATION_CENTER_LOCALE_CONFIGURATION

constСкопировать ссылку на 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

constСкопировать ссылку на 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

constСкопировать ссылку на 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

constСкопировать ссылку на maxUnreadItemsLength

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

const maxUnreadItemsLength: number;
Предложения по улучшению
Если вы нашли ошибку или хотите доработать статью, создайте запрос на GitHub.