@ux-aspects/ux-aspects
Version:
Open source user interface framework for building modern, responsive, mobile big data applications
79 lines (78 loc) • 3.29 kB
TypeScript
import { TemplateRef } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import * as i0 from "@angular/core";
export declare class NotificationService {
private readonly _colorService;
/**
* Sets the order in which notifications are displayed:
`above` - newer notifications will appear above older ones.
`below` - newer notifications will appear below older ones.
*/
direction: NotificationListDirection;
/**
* The list of notifications including notifications that have been dismissed
*/
notifications$: BehaviorSubject<NotificationRef[]>;
/**
* Access the list of notifications as an array
*/
get notifications(): NotificationRef[];
/**
* Define the default set of notification options
*/
options: NotificationOptions;
/**
* This function should be called to show a notification.
* It should be given a TemplateRef containing the content to be displayed.
* @param templateRef - A TemplateRef containing the content to be displayed
* @param options - The properties to configure the notification.
* @param context - The context passed to the notification TemplateRef. This can be accessed by adding a let-data="data" to the ng-template element.
*/
show(templateRef: TemplateRef<void>, options?: NotificationOptions, context?: {
[key: string]: unknown;
}): NotificationRef;
/**
* This function will return a list of all the notifications that have been shown.
*/
getHistory(): NotificationRef[];
/**
* This function can be called to dismiss a notification. It should be passed the object to dismiss.
* @param notificationRef - The notification that should be dismissed
*/
dismiss(notificationRef: NotificationRef): void;
/**
* This function will dismiss any currently visible notifications.
*/
dismissAll(): void;
/** Remove the notification from the screen and from the notification history */
remove(notificationRef: NotificationRef): void;
/** Remove all notifications from the screen and from the notification history */
removeAll(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NotificationService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<NotificationService>;
}
export interface NotificationRef extends NotificationOptions {
/** The content to display in the notification */
templateRef: TemplateRef<void>;
/** The datestamp to display in the notification */
date: Date;
/** Indicated whether or not the notification has been dismissed or not */
visible?: boolean;
/** Additional data passed as template context to the notification */
data: {
[key: string]: unknown;
};
}
export interface NotificationOptions {
/** The duration the notification should display for before it is automatically dismissed */
duration: number;
/** The height of the notification */
height?: number;
/** The spacing between each notification */
spacing?: number;
/** The background color of the notification */
backgroundColor?: string;
/** The color of the notification icon */
iconColor?: string;
}
export type NotificationListDirection = 'above' | 'below';