ngx-notifier
Version:
A Simple Notification Service for Angular Applications
111 lines (106 loc) • 4.22 kB
TypeScript
import { Subject } from 'rxjs';
import * as i0 from '@angular/core';
import { OnDestroy } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
/** Notification Class */
declare class Notification {
/** unique id for each notification */
id: string;
/** message to be shown */
message: string;
/** bootstrap background colors */
style: string;
/** timeout for notification */
duration: number | undefined;
/**
* Constructor For Notification
*
* @param message message to be shown
* @param style bootstrap background colors
* @param duration timeout for notification
*/
constructor(message: string, style?: string, duration?: number);
}
/** INotification interface */
interface INotification {
/** unique id for each notification */
id: string;
/** message to be shown */
message: string;
/** bootstrap background colors */
style?: string;
/** timeout for notification */
duration?: number;
}
/** Notification Service, recieves notifications from user and interacts with components */
declare class NgxNotifierService {
/** notification which can be subscribed on new messages */
notification: Subject<Notification>;
/** clear all toast notifications */
clearToasts: Subject<void>;
/** clear last toast notification */
clearLastToast: Subject<void>;
/** pushes a new notification */
createToast(message: string, style?: string, duration?: number): void;
/** clear all toast notifications */
clear(): void;
/** clear last toast notification */
clearLast(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxNotifierService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<NgxNotifierService>;
}
/**
* Notifier compoent, which holds all the notifications can be accessed via `ngx-notifier` selector
*/
declare class NgxNotifier implements OnDestroy {
private componentDestroyed$;
/** whether to allow duplicate messages or not */
allowDuplicates: boolean;
/** allow HTML in notification */
allowHTML: boolean;
/** custom class to be attached */
className: string;
/** default duration for dismissing notifications (60s/1minute) */
duration: number;
/** weather to enable or disable animations */
disableAnimations: boolean;
/** click to dismiss a notification */
dismissOnClick: boolean;
/** whether to insert on top or at bottom */
insertOnTop: boolean;
/** Maximum number of notifications to keep */
max: number;
/** array of notifications */
notifications: INotification[];
/** id of last inserted message */
private lastInsertedNotificationId;
ngxNotifierService: NgxNotifierService;
domSanitizer: DomSanitizer;
constructor();
/**
* updates notification into the array i.e., Which is the display
*
* @param notification notification element
*/
private updateNotifications;
/**
* remove the element from the array based on index
*
* @param index position of the element
*/
removeNotification(index: number): void;
/**
* click event when toast is cleared
*
* @param index position of the element
*/
onToastClick(index: number): void;
onKeyUp(): void;
/** clear last inserted toast notification */
private clearLastToast;
/** stop subscription when component is destroyed */
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxNotifier, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NgxNotifier, "ngx-notifier", never, { "allowDuplicates": { "alias": "allowDuplicates"; "required": false; }; "allowHTML": { "alias": "allowHTML"; "required": false; }; "className": { "alias": "className"; "required": false; }; "duration": { "alias": "duration"; "required": false; }; "disableAnimations": { "alias": "disableAnimations"; "required": false; }; "dismissOnClick": { "alias": "dismissOnClick"; "required": false; }; "insertOnTop": { "alias": "insertOnTop"; "required": false; }; "max": { "alias": "max"; "required": false; }; }, {}, never, never, true, never>;
}
export { NgxNotifier, NgxNotifierService };