@odx/angular 5.3.3 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/components/button/lib/models/button-size.d.ts +2 -1
- package/components/notification/README.md +3 -0
- package/components/notification/index.d.ts +7 -0
- package/components/notification/lib/components/index.d.ts +2 -0
- package/components/notification/lib/components/notification-center/notification-center.component.d.ts +19 -0
- package/components/notification/lib/components/notification-item/notification-item.component.d.ts +37 -0
- package/components/notification/lib/directives/index.d.ts +1 -0
- package/components/notification/lib/directives/notification-center.directive.d.ts +69 -0
- package/components/notification/lib/features/index.d.ts +5 -0
- package/components/notification/lib/features/with-browser-notifications.d.ts +17 -0
- package/components/notification/lib/features/with-load-notifications.d.ts +18 -0
- package/components/notification/lib/features/with-notification-transformer.d.ts +26 -0
- package/components/notification/lib/features/with-peristent-notifications.d.ts +63 -0
- package/components/notification/lib/features/with-save-notifications.d.ts +11 -0
- package/components/notification/lib/helpers/get-notifications-by-tag.d.ts +2 -0
- package/components/notification/lib/helpers/index.d.ts +3 -0
- package/components/notification/lib/helpers/sort-notifications.d.ts +3 -0
- package/components/notification/lib/helpers/to-notification-collection.d.ts +3 -0
- package/components/notification/lib/models/index.d.ts +8 -0
- package/components/notification/lib/models/notification-action.d.ts +2 -0
- package/components/notification/lib/models/notification-collection.d.ts +6 -0
- package/components/notification/lib/models/notification-feature.d.ts +5 -0
- package/components/notification/lib/models/notification-options.d.ts +7 -0
- package/components/notification/lib/models/notification-query.d.ts +2 -0
- package/components/notification/lib/models/notification-sort-fn.d.ts +2 -0
- package/components/notification/lib/models/notification.d.ts +6 -0
- package/components/notification/lib/models/notification.ref.d.ts +9 -0
- package/components/notification/lib/notification.config.d.ts +11 -0
- package/components/notification/lib/notification.i18n.d.ts +3 -0
- package/components/notification/lib/notification.logger.d.ts +3 -0
- package/components/notification/lib/notification.service.d.ts +110 -0
- package/components/notification/lib/notification.tokens.d.ts +4 -0
- package/components/notification/lib/services/index.d.ts +1 -0
- package/components/notification/lib/services/notification-center.service.d.ts +69 -0
- package/components/notification/testing/README.md +3 -0
- package/components/notification/testing/index.d.ts +1 -0
- package/components/notification/testing/lib/test-helpers.d.ts +5 -0
- package/components/rich-list/lib/rich-list.component.d.ts +7 -1
- package/components/toast/lib/toast.service.d.ts +30 -2
- package/esm2022/components/button/lib/models/button-size.mjs +2 -1
- package/esm2022/components/notification/index.mjs +8 -0
- package/esm2022/components/notification/lib/components/index.mjs +3 -0
- package/esm2022/components/notification/lib/components/notification-center/notification-center.component.mjs +65 -0
- package/esm2022/components/notification/lib/components/notification-item/notification-item.component.mjs +65 -0
- package/esm2022/components/notification/lib/directives/index.mjs +2 -0
- package/esm2022/components/notification/lib/directives/notification-center.directive.mjs +142 -0
- package/esm2022/components/notification/lib/features/index.mjs +6 -0
- package/esm2022/components/notification/lib/features/with-browser-notifications.mjs +75 -0
- package/esm2022/components/notification/lib/features/with-load-notifications.mjs +45 -0
- package/esm2022/components/notification/lib/features/with-notification-transformer.mjs +34 -0
- package/esm2022/components/notification/lib/features/with-peristent-notifications.mjs +94 -0
- package/esm2022/components/notification/lib/features/with-save-notifications.mjs +45 -0
- package/esm2022/components/notification/lib/helpers/get-notifications-by-tag.mjs +7 -0
- package/esm2022/components/notification/lib/helpers/index.mjs +4 -0
- package/esm2022/components/notification/lib/helpers/sort-notifications.mjs +10 -0
- package/esm2022/components/notification/lib/helpers/to-notification-collection.mjs +9 -0
- package/esm2022/components/notification/lib/models/index.mjs +9 -0
- package/esm2022/components/notification/lib/models/notification-action.mjs +2 -0
- package/esm2022/components/notification/lib/models/notification-collection.mjs +2 -0
- package/esm2022/components/notification/lib/models/notification-feature.mjs +4 -0
- package/esm2022/components/notification/lib/models/notification-options.mjs +2 -0
- package/esm2022/components/notification/lib/models/notification-query.mjs +2 -0
- package/esm2022/components/notification/lib/models/notification-sort-fn.mjs +2 -0
- package/esm2022/components/notification/lib/models/notification.mjs +2 -0
- package/esm2022/components/notification/lib/models/notification.ref.mjs +2 -0
- package/esm2022/components/notification/lib/notification.config.mjs +11 -0
- package/esm2022/components/notification/lib/notification.i18n.mjs +11 -0
- package/esm2022/components/notification/lib/notification.logger.mjs +3 -0
- package/esm2022/components/notification/lib/notification.service.mjs +168 -0
- package/esm2022/components/notification/lib/notification.tokens.mjs +7 -0
- package/esm2022/components/notification/lib/services/index.mjs +2 -0
- package/esm2022/components/notification/lib/services/notification-center.service.mjs +96 -0
- package/esm2022/components/notification/odx-angular-components-notification.mjs +5 -0
- package/esm2022/components/notification/testing/index.mjs +2 -0
- package/esm2022/components/notification/testing/lib/test-helpers.mjs +33 -0
- package/esm2022/components/notification/testing/odx-angular-components-notification-testing.mjs +5 -0
- package/esm2022/components/rich-list/lib/rich-list.component.mjs +18 -6
- package/esm2022/components/toast/lib/components/toast-container/toast-container.component.mjs +6 -6
- package/esm2022/components/toast/lib/toast.service.mjs +38 -8
- package/esm2022/utils/lib/helpers/array.mjs +24 -1
- package/fesm2022/odx-angular-components-button.mjs +1 -0
- package/fesm2022/odx-angular-components-button.mjs.map +1 -1
- package/fesm2022/odx-angular-components-notification-testing.mjs +39 -0
- package/fesm2022/odx-angular-components-notification-testing.mjs.map +1 -0
- package/fesm2022/odx-angular-components-notification.mjs +832 -0
- package/fesm2022/odx-angular-components-notification.mjs.map +1 -0
- package/fesm2022/odx-angular-components-rich-list.mjs +17 -5
- package/fesm2022/odx-angular-components-rich-list.mjs.map +1 -1
- package/fesm2022/odx-angular-components-toast.mjs +42 -11
- package/fesm2022/odx-angular-components-toast.mjs.map +1 -1
- package/fesm2022/odx-angular-utils.mjs +23 -0
- package/fesm2022/odx-angular-utils.mjs.map +1 -1
- package/package.json +13 -1
- package/utils/lib/helpers/array.d.ts +23 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @odx/angular
|
|
2
2
|
|
|
3
|
+
## 5.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4375380: Add notification component and service
|
|
8
|
+
|
|
9
|
+
## 5.3.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 3eb8c54: Large variant for button component
|
|
14
|
+
- b3993a0: New condensed variant to rich-list component to set vrtical padding to 0 for list items
|
|
15
|
+
|
|
3
16
|
## 5.3.3
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './lib/components';
|
|
2
|
+
export * from './lib/directives';
|
|
3
|
+
export * from './lib/features';
|
|
4
|
+
export * from './lib/models';
|
|
5
|
+
export * from './lib/notification.config';
|
|
6
|
+
export * from './lib/notification.service';
|
|
7
|
+
export * from './lib/notification.tokens';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OnDestroy } from '@angular/core';
|
|
2
|
+
import { trackById } from '@odx/angular/utils';
|
|
3
|
+
import { NotificationRef } from '../../models';
|
|
4
|
+
import { NotificationCenterService } from '../../services';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/**
|
|
7
|
+
* A component for displaying and managing a list of notifications. It integrates various sub-components and directives to provide a rich user interface for notification interaction. Supports animations for notification transitions and leverages Angular's change detection strategies for performance.
|
|
8
|
+
*
|
|
9
|
+
* @CSSComponent 'notification-center' - Specifies the CSS class for styling the notification center component.
|
|
10
|
+
*/
|
|
11
|
+
export declare class NotificationCenterComponent implements OnDestroy {
|
|
12
|
+
protected readonly notificationCenterService: NotificationCenterService;
|
|
13
|
+
protected readonly trackById: typeof trackById;
|
|
14
|
+
readonly element: import("@angular/core").ElementRef<HTMLElement>;
|
|
15
|
+
ngOnDestroy(): void;
|
|
16
|
+
protected isMuted({ options, hasBeenSeen }: NotificationRef): boolean;
|
|
17
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NotificationCenterComponent, never>;
|
|
18
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NotificationCenterComponent, "odx-notification-center", never, {}, {}, never, never, true, never>;
|
|
19
|
+
}
|
package/components/notification/lib/components/notification-item/notification-item.component.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EventEmitter } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { NotificationRef } from '../../models';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* A component for displaying notifications.
|
|
7
|
+
* Supports customization through dynamic transformation of notification data.
|
|
8
|
+
* Utilizes the OnPush change detection strategy for better performance in large applications.
|
|
9
|
+
*
|
|
10
|
+
* @component
|
|
11
|
+
*/
|
|
12
|
+
export declare class NotificationItemComponent {
|
|
13
|
+
private readonly transformNotification;
|
|
14
|
+
private _notificationRef;
|
|
15
|
+
protected transformedNotification: Observable<NotificationRef>;
|
|
16
|
+
readonly element: import("@angular/core").ElementRef<HTMLElement>;
|
|
17
|
+
/**
|
|
18
|
+
* Input property to set the notification. On setting, it transforms the notification for display.
|
|
19
|
+
* This transformation can be a custom logic provided through dependency injection.
|
|
20
|
+
*
|
|
21
|
+
* @param value NotificationRef - The notification object to be displayed.
|
|
22
|
+
*/
|
|
23
|
+
set notification(value: NotificationRef);
|
|
24
|
+
/**
|
|
25
|
+
* Getter for the notification property.
|
|
26
|
+
*
|
|
27
|
+
* @returns NotificationRef - The current notification reference stored in the component.
|
|
28
|
+
*/
|
|
29
|
+
get notification(): NotificationRef;
|
|
30
|
+
/**
|
|
31
|
+
* An event emitter for dismissing the notification.
|
|
32
|
+
* It emits the notification reference that was dismissed.
|
|
33
|
+
*/
|
|
34
|
+
dismiss: EventEmitter<NotificationRef>;
|
|
35
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NotificationItemComponent, never>;
|
|
36
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NotificationItemComponent, "odx-notification-item", never, { "notification": { "alias": "notification"; "required": true; }; }, { "dismiss": "dismiss"; }, never, never, true, never>;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './notification-center.directive';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { AfterViewInit, OnInit } from '@angular/core';
|
|
2
|
+
import { DynamicTextContent } from '@odx/angular/cdk/dynamic-view';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { NotificationSortFn } from '../models';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
import * as i1 from "@odx/angular/components/badge";
|
|
7
|
+
import * as i2 from "@odx/angular/components/dropdown";
|
|
8
|
+
/**
|
|
9
|
+
* A directive that provides an interface for managing notifications.
|
|
10
|
+
* It allows configuring a notification center with dynamic content, sorting, and badge display functionalities.
|
|
11
|
+
*/
|
|
12
|
+
export declare class NotificationCenterDirective implements OnInit, AfterViewInit {
|
|
13
|
+
private readonly badgeDirective;
|
|
14
|
+
private readonly destroyRef;
|
|
15
|
+
private readonly disabledController;
|
|
16
|
+
private readonly dropdownDirective;
|
|
17
|
+
private readonly notificationCenterService;
|
|
18
|
+
private readonly dropdownStateChange$;
|
|
19
|
+
private readonly badgeValue$;
|
|
20
|
+
/**
|
|
21
|
+
* Sets the tag for filtering notifications. Only notifications with this tag will be shown in the notification center.
|
|
22
|
+
* @param value The tag value to filter notifications. If null, all notifications are shown.
|
|
23
|
+
*/
|
|
24
|
+
set tag(value: string | null);
|
|
25
|
+
/**
|
|
26
|
+
* Sets the title of the notification center. The title can be dynamic and change based on the application state.
|
|
27
|
+
* @param value The title content, which can be a string or an Observable returning a string. Allows for dynamic titles.
|
|
28
|
+
*/
|
|
29
|
+
set title(value: DynamicTextContent | null);
|
|
30
|
+
/**
|
|
31
|
+
* Sets the sorting function used to order notifications within the notification center.
|
|
32
|
+
* @param value A function that compares two notifications and returns the sort order.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* sortFfn = (a: NotificationRef, b: NotificationRef) => {
|
|
36
|
+
if (a.createdAt < b.createdAt) return -1;
|
|
37
|
+
if (a.createdAt > b.createdAt) return 1;
|
|
38
|
+
return 0;
|
|
39
|
+
};
|
|
40
|
+
*/
|
|
41
|
+
set sortFn(value: NotificationSortFn);
|
|
42
|
+
/**
|
|
43
|
+
* An event that is emitted when a new notification is added.
|
|
44
|
+
* Listeners can use this event to react to new notifications being added to the notification center.
|
|
45
|
+
*/
|
|
46
|
+
notificationAdd: Observable<import("../models").NotificationRef>;
|
|
47
|
+
/**
|
|
48
|
+
* An event that is emitted when a notification is updated.
|
|
49
|
+
* This can be used to react to changes in notifications, such as their read status or content updates.
|
|
50
|
+
*/
|
|
51
|
+
notificationUpdate: Observable<import("../models").NotificationRef>;
|
|
52
|
+
/**
|
|
53
|
+
* An event that is emitted when a notification is removed from the notification center.
|
|
54
|
+
* Use this event to handle the removal of notifications, such as cleaning up resources or updating UI elements.
|
|
55
|
+
*/
|
|
56
|
+
notificationRemove: Observable<import("../models").NotificationRef>;
|
|
57
|
+
/**
|
|
58
|
+
* An event that is emitted when a notification is marked as seen.
|
|
59
|
+
* This event can be used to perform actions when the user acknowledges a notification.
|
|
60
|
+
*/
|
|
61
|
+
notificationSeen: Observable<import("../models").NotificationRef>;
|
|
62
|
+
ngOnInit(): void;
|
|
63
|
+
ngAfterViewInit(): void;
|
|
64
|
+
private formatBadgeValue;
|
|
65
|
+
private handleBadgeUpdates;
|
|
66
|
+
private handleDropdownUpdates;
|
|
67
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NotificationCenterDirective, never>;
|
|
68
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<NotificationCenterDirective, "[odxNotificationCenter]", never, { "tag": { "alias": "odxNotificationCenter"; "required": false; }; "title": { "alias": "odxNotificationCenterTitle"; "required": false; }; "sortFn": { "alias": "odxNotificationCenterSortFn"; "required": false; }; }, { "notificationAdd": "odxNotificationCenterAdd"; "notificationUpdate": "odxNotificationCenterUpdate"; "notificationRemove": "odxNotificationCenterRemove"; "notificationSeen": "odxNotificationCenterSeen"; }, never, never, true, [{ directive: typeof i1.BadgeDirective; inputs: { "odxBadgeVariant": "odxNotificationCenterBadgeVariant"; }; outputs: {}; }, { directive: typeof i2.DropdownDirective; inputs: {}; outputs: {}; }]>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NotificationFeature, NotificationRef } from '../models';
|
|
2
|
+
export type BrowserNotificationExtras = Omit<NotificationOptions, 'body' | 'timestamp'>;
|
|
3
|
+
export type BrowserNotification = Notification;
|
|
4
|
+
export type BrowserNotificationFactory = (notificationRef: NotificationRef) => BrowserNotification;
|
|
5
|
+
export type SendBrowserNotificationFn = (notificationRef: NotificationRef) => unknown;
|
|
6
|
+
export interface WithBrowserNotificationsOptions {
|
|
7
|
+
sendFn?: SendBrowserNotificationFn;
|
|
8
|
+
extras?: BrowserNotificationExtras;
|
|
9
|
+
isEnabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Configures the application to send browser notifications, using Angular's `ENVIRONMENT_INITIALIZER` for setup.
|
|
13
|
+
* @function withBrowserNotifications
|
|
14
|
+
* @param {WithBrowserNotificationsOptions} [options] - Optional configuration for browser notifications.
|
|
15
|
+
* @returns {NotificationFeature} A notification feature for integration into the application environment.
|
|
16
|
+
*/
|
|
17
|
+
export declare function withBrowserNotifications(options?: WithBrowserNotificationsOptions): NotificationFeature;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { NotificationFeature, NotificationRef } from '../models';
|
|
3
|
+
/**
|
|
4
|
+
* Type definition for a function that loads notifications.
|
|
5
|
+
* Can return notifications directly as an array, as a Promise, or as an Observable.
|
|
6
|
+
* @typedef {Function} LoadNotificationsFn
|
|
7
|
+
* @returns {Observable<NotificationRef[]> | Promise<NotificationRef[]> | NotificationRef[]} The loaded notifications.
|
|
8
|
+
*/
|
|
9
|
+
export type LoadNotificationsFn = () => Observable<NotificationRef[]> | Promise<NotificationRef[]> | NotificationRef[];
|
|
10
|
+
/**
|
|
11
|
+
* Integrates notification loading into the application environment. This function uses the Angular
|
|
12
|
+
* `ENVIRONMENT_INITIALIZER` to ensure that notifications are loaded as part of the application's
|
|
13
|
+
* initialization process.
|
|
14
|
+
* @function withLoadNotifications
|
|
15
|
+
* @param {LoadNotificationsFn} loadFn - The function to load notifications.
|
|
16
|
+
* @returns {NotificationFeature} A notification feature configured to load notifications at startup.
|
|
17
|
+
*/
|
|
18
|
+
export declare function withLoadNotifications(loadFn: LoadNotificationsFn): NotificationFeature;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { NotificationFeature, NotificationRef } from '../models';
|
|
4
|
+
export type NotificationTransformFn = (ref: NotificationRef) => Observable<NotificationRef>;
|
|
5
|
+
/**
|
|
6
|
+
* An InjectionToken for the NotificationTransformFn. This token can be used to inject
|
|
7
|
+
* a custom notification transformation function into the Angular DI system.
|
|
8
|
+
* @type {InjectionToken<NotificationTransformFn>}
|
|
9
|
+
*/
|
|
10
|
+
export declare const ODX_NOTIFICATION_TRANSFORMER: InjectionToken<NotificationTransformFn>;
|
|
11
|
+
/**
|
|
12
|
+
* Attempts to inject a NotificationTransformFn from the Angular DI system.
|
|
13
|
+
* If no provider is found, it returns null.
|
|
14
|
+
* @function injectNotificationTransform
|
|
15
|
+
* @returns {NotificationTransformFn | null} The injected NotificationTransformFn, or null if not provided.
|
|
16
|
+
*/
|
|
17
|
+
export declare function injectNotificationTransform(): NotificationTransformFn | null;
|
|
18
|
+
/**
|
|
19
|
+
* Configures a notification transformation function to be used within the application.
|
|
20
|
+
* This function provides a mechanism to globally apply transformations to notifications
|
|
21
|
+
* before they are processed or displayed.
|
|
22
|
+
* @function withNotificationTransform
|
|
23
|
+
* @param {NotificationTransformFn} transformFn - The function to transform notifications.
|
|
24
|
+
* @returns {NotificationFeature} A NotificationFeature configured with the provided transformation function.
|
|
25
|
+
*/
|
|
26
|
+
export declare function withNotificationTransform(transformFn: NotificationTransformFn): NotificationFeature;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { NotificationFeature, NotificationRef } from '../models';
|
|
2
|
+
import { LoadNotificationsFn } from './with-load-notifications';
|
|
3
|
+
import { SaveNotificationsFn } from './with-save-notifications';
|
|
4
|
+
export interface NotificationSerializer {
|
|
5
|
+
serialize(value: NotificationRef[]): Promise<string>;
|
|
6
|
+
deserialize(value: string): Promise<NotificationRef[]>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Implementation of NotificationSerializer for persistent storage.
|
|
10
|
+
* @class PersistentNotificationSerializer
|
|
11
|
+
* @implements {NotificationSerializer}
|
|
12
|
+
*/
|
|
13
|
+
export declare class PersistentNotificationSerializer implements NotificationSerializer {
|
|
14
|
+
/**
|
|
15
|
+
* Serializes an array of NotificationRef objects into a string.
|
|
16
|
+
* @function serialize
|
|
17
|
+
* @memberof NotificationSerializer
|
|
18
|
+
* @param {NotificationRef[]} value - The notification references to serialize.
|
|
19
|
+
* @returns {Promise<string>} A promise that resolves to the serialized string representation of notification references.
|
|
20
|
+
*/
|
|
21
|
+
serialize(value: NotificationRef[]): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Deserializes a string into an array of NotificationRef objects.
|
|
24
|
+
* @function deserialize
|
|
25
|
+
* @memberof NotificationSerializer
|
|
26
|
+
* @param {string} value - The string representation of notification references to deserialize.
|
|
27
|
+
* @returns {Promise<NotificationRef[]>} A promise that resolves to the deserialized notification references.
|
|
28
|
+
*/
|
|
29
|
+
deserialize(value: string): Promise<NotificationRef[]>;
|
|
30
|
+
private serializeDynamicTextContent;
|
|
31
|
+
}
|
|
32
|
+
export interface WithPersistentNotificationsStorageOptions {
|
|
33
|
+
storageKey: string;
|
|
34
|
+
storage: Storage;
|
|
35
|
+
serializer: NotificationSerializer;
|
|
36
|
+
idTransformer?: (notificationRef: NotificationRef) => string;
|
|
37
|
+
}
|
|
38
|
+
export interface WithPersistentNotificationsOptions {
|
|
39
|
+
initFn: LoadNotificationsFn;
|
|
40
|
+
saveFn: SaveNotificationsFn;
|
|
41
|
+
storageOptions: WithPersistentNotificationsStorageOptions;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Initializes and returns a function for loading persistent notifications.
|
|
45
|
+
* @function initPersistentNotifications
|
|
46
|
+
* @param {WithPersistentNotificationsStorageOptions} options - The storage options including serializer and storage key.
|
|
47
|
+
* @returns {LoadNotificationsFn} A function to load notifications from storage.
|
|
48
|
+
*/
|
|
49
|
+
export declare function initPersistentNotifications({ storage, storageKey, serializer, idTransformer, }: WithPersistentNotificationsStorageOptions): LoadNotificationsFn;
|
|
50
|
+
/**
|
|
51
|
+
* Returns a function for persisting notifications.
|
|
52
|
+
* @function persistNotifications
|
|
53
|
+
* @param {WithPersistentNotificationsStorageOptions} options - The storage options including serializer and storage key.
|
|
54
|
+
* @returns {SaveNotificationsFn} A function to save notifications to storage.
|
|
55
|
+
*/
|
|
56
|
+
export declare function persistNotifications({ storage, storageKey, serializer }: WithPersistentNotificationsStorageOptions): SaveNotificationsFn;
|
|
57
|
+
/**
|
|
58
|
+
* Configures the application to use persistent notifications, automatically loading from and saving to the configured storage.
|
|
59
|
+
* @function withPersistentNotifications
|
|
60
|
+
* @param {Partial<WithPersistentNotificationsOptions>} [options] - Optional configuration for persistent notifications.
|
|
61
|
+
* @returns {NotificationFeature} A notification feature configured for persistence.
|
|
62
|
+
*/
|
|
63
|
+
export declare function withPersistentNotifications(options?: Partial<WithPersistentNotificationsOptions>): NotificationFeature;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { NotificationFeature, NotificationRef } from '../models';
|
|
3
|
+
export type SaveNotificationsFn = (notificationRefs: NotificationRef[]) => Observable<void> | Promise<void> | void;
|
|
4
|
+
/**
|
|
5
|
+
* Configures the application to automatically save notifications using a specified save function.
|
|
6
|
+
* This setup integrates with Angular's environment initialization process to ensure notifications are saved as needed.
|
|
7
|
+
* @function withSaveNotifications
|
|
8
|
+
* @param {SaveNotificationsFn} saveFn - The function to save notifications.
|
|
9
|
+
* @returns {NotificationFeature} A notification feature configured to automatically save notifications.
|
|
10
|
+
*/
|
|
11
|
+
export declare function withSaveNotifications(saveFn: SaveNotificationsFn): NotificationFeature;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './notification';
|
|
2
|
+
export * from './notification-action';
|
|
3
|
+
export * from './notification-collection';
|
|
4
|
+
export * from './notification-feature';
|
|
5
|
+
export * from './notification-options';
|
|
6
|
+
export * from './notification-query';
|
|
7
|
+
export * from './notification-sort-fn';
|
|
8
|
+
export * from './notification.ref';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EnvironmentProviders, Provider } from '@angular/core';
|
|
2
|
+
export type NotificationFeature = EnvironmentProviders & {
|
|
3
|
+
ɵodxBrand: '@odx/angular/components/notification::NotificationFeature';
|
|
4
|
+
};
|
|
5
|
+
export declare function makeNotificationFeature(provider: (Provider | NotificationFeature)[] | EnvironmentProviders): NotificationFeature;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Notification } from './notification';
|
|
2
|
+
import { NotificationOptions } from './notification-options';
|
|
3
|
+
export interface NotificationRef {
|
|
4
|
+
id: NonNullable<Notification['id']>;
|
|
5
|
+
createdAt: number;
|
|
6
|
+
item: Notification;
|
|
7
|
+
options: NotificationOptions;
|
|
8
|
+
hasBeenSeen: boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EnvironmentProviders } from '@angular/core';
|
|
2
|
+
import { NotificationAction, NotificationFeature, NotificationOptions, NotificationSortFn } from './models';
|
|
3
|
+
export interface NotificationConfig {
|
|
4
|
+
defaultIdPrefix: string;
|
|
5
|
+
options: NotificationOptions;
|
|
6
|
+
sortFn: NotificationSortFn;
|
|
7
|
+
tagToIconMap?: Record<string, string>;
|
|
8
|
+
actionMap?: Record<string, NotificationAction>;
|
|
9
|
+
}
|
|
10
|
+
export declare const NotificationConfig: import("@angular/core").InjectionToken<Partial<NotificationConfig>>, NotificationDefaultConfig: NotificationConfig, injectNotificationConfig: () => NotificationConfig, provideNotificationConfig: <D extends import("@odx/angular/utils").ConfigDependencies<unknown> = import("@odx/angular/utils").ConfigDependencies<Partial<NotificationConfig>>>(config: import("@odx/angular/utils").ConfigProvider<Partial<NotificationConfig>, D>) => import("@angular/core").ValueProvider | import("@angular/core").FactoryProvider;
|
|
11
|
+
export declare function provideNotifications(config?: Partial<NotificationConfig>, ...features: NotificationFeature[]): EnvironmentProviders;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { Notification, NotificationCollection, NotificationOptions, NotificationQuery, NotificationRef, NotificationSortFn } from './models';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class NotificationService {
|
|
5
|
+
private readonly config;
|
|
6
|
+
private readonly localizationService;
|
|
7
|
+
private readonly queue;
|
|
8
|
+
private readonly injector;
|
|
9
|
+
readonly notifications$: Observable<NotificationCollection>;
|
|
10
|
+
readonly unseenNotifications$: Observable<NotificationCollection>;
|
|
11
|
+
readonly onNotificationAdd$: Observable<NotificationRef>;
|
|
12
|
+
readonly onNotificationRemove$: Observable<NotificationRef>;
|
|
13
|
+
readonly onNotificationUpdate$: Observable<NotificationRef>;
|
|
14
|
+
readonly onNotificationSeen$: Observable<NotificationRef>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetches notifications filtered by a specified query and optionally sorted by a custom sort function.
|
|
17
|
+
*
|
|
18
|
+
* @param {NotificationQuery} query - A function or object to filter notifications.
|
|
19
|
+
* @param {NotificationSortFn} [sortFn] - An optional sorting function to order the filtered notifications.
|
|
20
|
+
* @returns {Observable<NotificationCollection>} An observable stream of the filtered (and optionally sorted) notification collection.
|
|
21
|
+
* @example
|
|
22
|
+
* // Fetch notifications with a specific tag, sorted by creation date
|
|
23
|
+
* const sortedNotifications$ = notificationService.getNotificationsBy$(
|
|
24
|
+
* notification => notification.tags.includes('important'),
|
|
25
|
+
* (a, b) => b.createdAt - a.createdAt
|
|
26
|
+
* );
|
|
27
|
+
*/
|
|
28
|
+
getNotificationsBy$(query: NotificationQuery, sortFn?: NotificationSortFn): Observable<NotificationCollection>;
|
|
29
|
+
/**
|
|
30
|
+
* Loads a list of notifications into the service.
|
|
31
|
+
*
|
|
32
|
+
* @param {NotificationRef[]} refs - An array of notification references to be loaded.
|
|
33
|
+
* @example
|
|
34
|
+
* // Load multiple notifications at once
|
|
35
|
+
* notificationService.load([
|
|
36
|
+
* { id: '1', item: { title: 'Notification 1' }, options: {dismissable: true, icon: 'plus', tags: ['important']}, hasBeenSeen: false, createdAt: Date.now() },
|
|
37
|
+
* { id: '2', item: { title: 'Notification 2' }, options: {dismissable: true, icon: 'plus', tags: ['important']}, hasBeenSeen: false, createdAt: Date.now() }
|
|
38
|
+
* ]);
|
|
39
|
+
*/
|
|
40
|
+
load(refs: NotificationRef[]): void;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new notification and adds it to the notification queue.
|
|
43
|
+
*
|
|
44
|
+
* @param {Notification} item - The notification to create.
|
|
45
|
+
* @param {Partial<NotificationOptions>} [options] - Optional settings for the notification.
|
|
46
|
+
* @example
|
|
47
|
+
* // Create a new notification with custom options
|
|
48
|
+
* notificationService.create(
|
|
49
|
+
* { title: 'New Notification' },
|
|
50
|
+
* { dismissable: true, icon: 'plus', tags: ['important'] }
|
|
51
|
+
* );
|
|
52
|
+
*/
|
|
53
|
+
create(item: Notification, options?: Partial<NotificationOptions>): void;
|
|
54
|
+
/**
|
|
55
|
+
* Marks a specific notification as seen.
|
|
56
|
+
*
|
|
57
|
+
* @param {NotificationRef} notificationRef - The reference to the notification to mark as seen.
|
|
58
|
+
* @example
|
|
59
|
+
* // Mark a notification as seen by its reference
|
|
60
|
+
* notificationService.markAsSeen(notificationRef);
|
|
61
|
+
*/
|
|
62
|
+
markAsSeen(notificationRef: NotificationRef): void;
|
|
63
|
+
/**
|
|
64
|
+
* Marks all notifications that match a specific query as seen.
|
|
65
|
+
*
|
|
66
|
+
* @param {NotificationQuery} query - The query to match notifications to mark as seen.
|
|
67
|
+
* @example
|
|
68
|
+
* // Mark all notifications with a specific tag as seen
|
|
69
|
+
* notificationService.markAsSeenBy(notification => notification.tags.includes('important'));
|
|
70
|
+
*/
|
|
71
|
+
markAsSeenBy(query: NotificationQuery): void;
|
|
72
|
+
/**
|
|
73
|
+
* Dismisses a specific notification.
|
|
74
|
+
*
|
|
75
|
+
* @param {NotificationRef} notificationRef - The reference to the notification to dismiss.
|
|
76
|
+
* @example
|
|
77
|
+
* // Dismiss a notification by its reference
|
|
78
|
+
* notificationService.dismiss(notificationRef);
|
|
79
|
+
*/
|
|
80
|
+
dismiss(notificationRef: NotificationRef): void;
|
|
81
|
+
/**
|
|
82
|
+
* Dismisses all notifications that match a specific query.
|
|
83
|
+
*
|
|
84
|
+
* @param {NotificationQuery} query - The query to match notifications to dismiss.
|
|
85
|
+
* @example
|
|
86
|
+
* // Dismiss all notifications with a specific tag
|
|
87
|
+
* notificationService.dismissBy(notification => notification.tags.includes('expired'));
|
|
88
|
+
*/
|
|
89
|
+
dismissBy(query: NotificationQuery): void;
|
|
90
|
+
/**
|
|
91
|
+
* Dismisses all notifications.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* // Dismiss all notifications
|
|
95
|
+
* notificationService.dismissAll();
|
|
96
|
+
*/
|
|
97
|
+
dismissAll(): void;
|
|
98
|
+
/**
|
|
99
|
+
* Executes the action associated with a specific notification.
|
|
100
|
+
*
|
|
101
|
+
* @param {NotificationRef} notificationRef - The reference to the notification whose action to execute.
|
|
102
|
+
* @example
|
|
103
|
+
* // Execute action for a notification
|
|
104
|
+
* notificationService.executeAction(notificationRef);
|
|
105
|
+
*/
|
|
106
|
+
executeAction(notificationRef: NotificationRef): void;
|
|
107
|
+
private resolveOptions;
|
|
108
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NotificationService, never>;
|
|
109
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<NotificationService>;
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './notification-center.service';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { DynamicTextContent } from '@odx/angular/cdk/dynamic-view';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { NotificationRef, NotificationSortFn } from '../models';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* A service for managing the notification center. This service provides functionalities
|
|
7
|
+
* to filter, sort, and manage actions on notifications.
|
|
8
|
+
*/
|
|
9
|
+
export declare class NotificationCenterService {
|
|
10
|
+
private readonly currentTag;
|
|
11
|
+
private readonly currentSortFn;
|
|
12
|
+
private readonly notificationService;
|
|
13
|
+
private readonly notificationQuery;
|
|
14
|
+
private readonly title;
|
|
15
|
+
readonly title$: Observable<string | null>;
|
|
16
|
+
readonly notifications$: Observable<import("../models").NotificationCollection>;
|
|
17
|
+
readonly unseenNotifications$: Observable<import("../models").NotificationCollection>;
|
|
18
|
+
onNotificationAdd$: Observable<NotificationRef>;
|
|
19
|
+
onNotificationUpdate$: Observable<NotificationRef>;
|
|
20
|
+
onNotificationRemove$: Observable<NotificationRef>;
|
|
21
|
+
onNotificationSeen$: Observable<NotificationRef>;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the title for the notification center. The title can be static text or an observable for dynamic content.
|
|
24
|
+
*
|
|
25
|
+
* @param {DynamicTextContent | null} [value] - The title content for the notification center.
|
|
26
|
+
*/
|
|
27
|
+
setTitle(value?: DynamicTextContent | null): void;
|
|
28
|
+
/**
|
|
29
|
+
* Sets the current tag to filter notifications. Only notifications with this tag will be included.
|
|
30
|
+
*
|
|
31
|
+
* @param {string | null} [value] - The tag to filter notifications by.
|
|
32
|
+
*/
|
|
33
|
+
setTag(value?: string | null): void;
|
|
34
|
+
/**
|
|
35
|
+
* Sets the sort function used to order the notifications.
|
|
36
|
+
*
|
|
37
|
+
* @param {NotificationSortFn} [value] - The sort function to apply to the notifications.
|
|
38
|
+
*/
|
|
39
|
+
setSortFn(value?: NotificationSortFn): void;
|
|
40
|
+
/**
|
|
41
|
+
* Marks a given notification as seen. This does not remove the notification but updates its seen status.
|
|
42
|
+
*
|
|
43
|
+
* @param {NotificationRef} notificationRef - The reference to the notification to be marked as seen.
|
|
44
|
+
*/
|
|
45
|
+
markAsSeen(notificationRef: NotificationRef): void;
|
|
46
|
+
/**
|
|
47
|
+
* Marks all current filtered notifications as seen.
|
|
48
|
+
*/
|
|
49
|
+
markAllAsSeen(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Dismisses a specific notification.
|
|
52
|
+
*
|
|
53
|
+
* @param {NotificationRef} notificationRef - The reference to the notification to dismiss.
|
|
54
|
+
*/
|
|
55
|
+
dismiss(notificationRef: NotificationRef): void;
|
|
56
|
+
/**
|
|
57
|
+
* Dismisses all notifications that match the current filter criteria.
|
|
58
|
+
*/
|
|
59
|
+
dismissAll(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Executes the action associated with a specific notification and marks it as seen.
|
|
62
|
+
*
|
|
63
|
+
* @param {NotificationRef} notificationRef - The reference to the notification whose action to execute.
|
|
64
|
+
*/
|
|
65
|
+
executeAction(notificationRef: NotificationRef): void;
|
|
66
|
+
private queryEvent;
|
|
67
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NotificationCenterService, never>;
|
|
68
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<NotificationCenterService>;
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/test-helpers';
|