UNPKG

angular-toaster

Version:

An Angular Toaster Notification library based on AngularJS-Toaster

205 lines (197 loc) 8.25 kB
import { Observable, Subject } from 'rxjs'; import * as i0 from '@angular/core'; import { InjectionToken, OnInit, OnDestroy, AfterViewInit, ViewContainerRef, EventEmitter, ModuleWithProviders } from '@angular/core'; import * as i1 from '@angular/common'; type ToastType = "success" | "info" | "warning" | "wait" | "error"; type OnActionCallback = (_toast: Toast) => void; type ProgressBarDirection = "decreasing" | "increasing"; declare enum BodyOutputType { Default = 0, TrustedHtml = 1, Component = 2 } interface IClearWrapper { toastId?: string; toastContainerId?: number; } interface Toast { type: ToastType; title?: string; body?: any; toastId?: string; toastContainerId?: number; onShowCallback?: OnActionCallback; onHideCallback?: OnActionCallback; onClickCallback?: OnActionCallback; timeout?: number; bodyOutputType?: BodyOutputType; showCloseButton?: boolean; closeHtml?: string; data?: any; tapToDismiss?: boolean; progressBar?: boolean; progressBarDirection?: ProgressBarDirection; } declare const DefaultTypeClasses: Partial<Record<ToastType, string>>; declare const DefaultIconClasses: Partial<Record<ToastType, string>>; interface IToasterConfig { limit?: number | null; tapToDismiss?: boolean; showCloseButton?: boolean | Partial<Record<ToastType, boolean>>; closeHtml?: string; newestOnTop?: boolean; timeout?: number | Partial<Record<ToastType, number>>; typeClasses?: Partial<Record<ToastType, string>>; iconClasses?: Partial<Record<ToastType, string>>; bodyOutputType?: BodyOutputType; bodyTemplate?: string; defaultToastType?: ToastType; positionClass?: string; titleClass?: string; messageClass?: string; animation?: string; preventDuplicates?: boolean; mouseoverTimerStop?: boolean; toastContainerId?: number | null; } declare const defaultToasterConfig: IToasterConfig; declare const ToasterConfigInjectionToken: InjectionToken<IToasterConfig>; declare class ToasterConfig implements IToasterConfig { limit?: number | null; tapToDismiss: boolean; showCloseButton: boolean | Partial<Record<ToastType, boolean>>; closeHtml: string; newestOnTop: boolean; timeout: number | Partial<Record<ToastType, number>>; typeClasses: Partial<Record<ToastType, string>>; iconClasses: Partial<Record<ToastType, string>>; bodyOutputType: BodyOutputType; bodyTemplate: string; defaultToastType: ToastType; positionClass: string; titleClass: string; messageClass: string; animation: string; preventDuplicates: boolean; mouseoverTimerStop: boolean; toastContainerId?: number | null; constructor(configOverrides?: IToasterConfig); } declare class ToasterService { addToast: Observable<Toast>; private _addToast; clearToasts: Observable<IClearWrapper>; private _clearToasts; removeToast: Observable<IClearWrapper>; /** @internal */ _removeToastSubject: Subject<IClearWrapper>; constructor(); /** * Synchronously create and show a new toast instance. * * @param {(string | Toast)} type The type of the toast, or a Toast object. * @param {string=} title The toast title. * @param {string=} body The toast body. * @returns {Toast} * The newly created Toast instance with a randomly generated GUID Id. */ pop(type: ToastType | Toast, title?: string, body?: string): Toast; /** * Asynchronously create and show a new toast instance. * * @param {(string | Toast)} type The type of the toast, or a Toast object. * @param {string=} title The toast title. * @param {string=} body The toast body. * @returns {Observable<Toast>} * A hot Observable that can be subscribed to in order to receive the Toast instance * with a randomly generated GUID Id. */ popAsync(type: ToastType | Toast, title?: string, body?: string): Observable<Toast>; /** * Clears a toast by toastId and/or toastContainerId. * * @param {string} toastId The toastId to clear. * @param {number=} toastContainerId * The toastContainerId of the container to remove toasts from. */ clear(toastId?: string, toastContainerId?: number): void; static ɵfac: i0.ɵɵFactoryDeclaration<ToasterService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ToasterService>; } declare class ToasterContainerComponent implements OnInit, OnDestroy { private _defaultToasterConfig; private _toasterconfig; set toasterconfig(_toasterconfig: IToasterConfig); get toasterconfig(): IToasterConfig; toasts: Toast[]; private toasterService; private addToastSubscriber; private clearToastsSubscriber; constructor(); ngOnInit(): void; ngOnDestroy(): void; click(toast: Toast, isCloseButton?: boolean): void; keypress(toast: Toast): void; childClick($event: { value: { toast: Toast; isCloseButton?: boolean; }; }): void; removeToast(toast: Toast): void; protected buildPositionClass(): string[]; protected buildToastCompClasses(toast: Toast): string[]; private registerSubscribers; private addToast; private isLimitExceeded; private removeAllToasts; private clearToasts; private clearToastsAction; private toastIdOrDefault; private isNullOrUndefined; static ɵfac: i0.ɵɵFactoryDeclaration<ToasterContainerComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<ToasterContainerComponent, "toaster-container, angular-toaster-container, div[toaster-container], div[angular-toaster-container]", never, { "toasterconfig": { "alias": "toasterconfig"; "required": false; }; }, {}, never, never, true, never>; } declare class ToasterComponent implements OnInit, AfterViewInit, OnDestroy { toasterconfig: IToasterConfig; toast: Toast; titleClass: string; messageClass: string; componentBody: ViewContainerRef; private viewContainerRef; private changeDetectorRef; private ngZone; private element; private renderer2; progressBarWidth: number; bodyOutputType: typeof BodyOutputType; clickEvent: EventEmitter<any>; removeToastEvent: EventEmitter<Toast>; private timeoutId?; private timeout; private progressBarIntervalId?; private removeToastTick; private removeMouseOverListener; ngOnInit(): void; ngAfterViewInit(): void; click(event: MouseEvent, toast: Toast): void; stopTimer(): void; restartTimer(): void; ngOnDestroy(): void; private configureTimer; private updateProgressBar; private clearTimers; private removeToast; static ɵfac: i0.ɵɵFactoryDeclaration<ToasterComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<ToasterComponent, "[toastComp]", never, { "toasterconfig": { "alias": "toasterconfig"; "required": false; }; "toast": { "alias": "toast"; "required": false; }; "titleClass": { "alias": "titleClass"; "required": false; }; "messageClass": { "alias": "messageClass"; "required": false; }; }, { "clickEvent": "clickEvent"; "removeToastEvent": "removeToastEvent"; }, never, never, true, never>; } declare class ToasterModule { static forRoot(config?: IToasterConfig): ModuleWithProviders<ToasterModule>; static forChild(config?: IToasterConfig): ModuleWithProviders<ToasterModule>; static ɵfac: i0.ɵɵFactoryDeclaration<ToasterModule, never>; static ɵmod: i0.ɵɵNgModuleDeclaration<ToasterModule, never, [typeof i1.CommonModule, typeof ToasterComponent, typeof ToasterContainerComponent], [typeof ToasterContainerComponent, typeof ToasterComponent]>; static ɵinj: i0.ɵɵInjectorDeclaration<ToasterModule>; } declare const provideAngularToaster: (config?: IToasterConfig) => i0.EnvironmentProviders; export { BodyOutputType, DefaultIconClasses, DefaultTypeClasses, ToasterComponent, ToasterConfig, ToasterConfigInjectionToken, ToasterContainerComponent, ToasterModule, ToasterService, defaultToasterConfig, provideAngularToaster }; export type { IClearWrapper, IToasterConfig, OnActionCallback, ProgressBarDirection, Toast, ToastType };