# Notification Center

- Entry point: `@koobiq/components/notification-center`
- NgModule: `KbqNotificationCenterModule`
- API: https://koobiq.io/api/notification-center.md
- Component tokens: https://koobiq.io/tokens/notification-center.md
- Page: https://koobiq.io/en/components/notification-center/overview

## Overview

Notification center — a panel for application notifications.

[**Example: notification-center** (`notification-center-overview`)](https://koobiq.io/examples/notification-center-overview.md)

The notification list opens from the main menu. The menu shows an unread message counter: it is hidden when the count is 0, and displays "99+" when the count exceeds 99.

New notifications appear in the list and are grouped by date, with the newest at the top. Each item has a title and timestamp; optionally it may include a caption and actions. A delete button appears on hover or focus. Messages can be cleared per day or all at once.

The date adapter and the formatter have to be provided at the application root — `importProvidersFrom(KbqLuxonDateModule, KbqFormattersModule)` at bootstrap, or the Moment equivalent. `KbqNotificationCenterService` is `providedIn: 'root'` and reads both, so an adapter provided on a feature module or on a component does not reach it.

The `date` of a notification is any value the configured `DateAdapter` parses without an explicit format — ISO 8601, RFC 2822 or SQL for the Luxon adapter. It drives both the date group and the ordering. A value the adapter cannot parse is shown verbatim as its own group heading and sorted last, instead of breaking the list.

Unread messages are marked with a blue dot and by an "Unread" label for screen readers. Dwelling on an item — with the pointer or with keyboard focus — or interacting with it (link, button, delete) marks the message as read.

### Empty state

In the empty state, a "No notifications" message is displayed and the "Delete all" button is hidden.

[**Example: notification-center-empty** (`notification-center-empty`)](https://koobiq.io/examples/notification-center-empty.md)

### Error

If notifications fail to load, a "Failed to load notifications" message and a "Repeat" button are shown instead of the list. Enable this state with `setErrorMode`, and subscribe to `KbqNotificationCenterService.onReload` to retry loading when the button is pressed.

[**Example: notification-center-error** (`notification-center-error`)](https://koobiq.io/examples/notification-center-error.md)

### Infinite scroll

The list can load notifications page by page as the user scrolls to the bottom. Subscribe to `KbqNotificationCenterService.onNextPage` to fetch the next page, append the result to `items`, and control the flow with `setLoadingMore`, `setHasMore` and `setLoadMoreErrorMode`. The threshold at which loading starts is configured with the `scrolledToBottomOffset` input.

[**Example: notification-center-infinite-scroll** (`notification-center-infinite-scroll`)](https://koobiq.io/examples/notification-center-infinite-scroll.md)

### Deletion

Notifications can be removed one by one, by date group, or all at once. Subscribe to `KbqNotificationCenterService.onDelete` to react to a removal — for example, to delete the items on the server. The event fires for all three cases and carries `type` (`'item'`, `'group'` or `'all'`) and `items` — the notifications that were removed. Removing a notification that is not in the list is a no-op and emits nothing, so a stale reference cannot trigger a phantom deletion on the server.

### Dropdown window

The notification center can be opened in a popover. For example, when placed in a horizontal menu.

[**Example: notification-center-popover** (`notification-center-popover`)](https://koobiq.io/examples/notification-center-popover.md)

## Examples

### Using KbqNotificationCenterService

[**Example: notification-center** (`notification-center-push`)](https://koobiq.io/examples/notification-center-push.md)
