ng-toast-notify
Version:
Lightweight and flexible toast notifications for Angular
105 lines (104 loc) • 3.41 kB
TypeScript
import { Type } from '@angular/core';
import { ToastysoundService } from './toastysound.service';
import * as i0 from "@angular/core";
export declare enum ToastType {
Basic = "basic",
Success = "success",
Error = "error",
Info = "info",
Warning = "warning",
Custom = "custom",
Promise = "promise",
Component = "component"
}
interface ToastGesture {
date: number;
touchStart?: Touch;
touchEnd?: Touch;
offsetX?: number;
}
export interface ToastModel {
id: number;
hash?: string;
title: string;
message: string;
type: ToastType;
timestamp: number;
duration: number;
expires: number;
config?: ToastyConfig;
get icon(): string;
gesture?: ToastGesture;
animatePbar?: boolean;
count: number;
scheduleId?: number;
timeOutRef?: ReturnType<typeof setTimeout>;
}
export interface ToastSchedule {
startAt: number;
repeatEvery: number;
repeatCount: number;
}
export interface ToastAction {
label: string;
callback: () => void;
class?: string;
}
export interface ToastyConfig {
type?: ToastType;
duration?: number;
sticky?: boolean;
enableHtml?: boolean;
customStyle?: Record<string, string>;
loading?: boolean;
beep?: boolean;
progressBar?: boolean;
component?: Type<any>;
componentParams?: Record<string, any>;
schedule?: ToastSchedule;
actions?: ToastAction[];
}
export interface ToastyPromise<T> {
promise: Promise<T>;
loading: string;
success: string | ((result: T) => string);
error: string | ((err: any) => string);
}
export declare class ToastyService {
private _toastySoundService;
private TOASTY_SERVICE_CONFIG;
private queue;
private counter;
private newToastBehaviorSubject;
newToast$: import("rxjs").Observable<ToastModel[]>;
private deleteToastBehaviorSubject;
deleteToast$: import("rxjs").Observable<ToastModel | undefined>;
private updateToastBehaviorSubject;
updateToast$: import("rxjs").Observable<ToastModel | undefined>;
constructor(_toastySoundService: ToastysoundService);
setDefaultDuration(d: number): void;
getDefaultDuration(): number;
setCapacity(c: number): void;
getCapacity(): number;
getGrouping(): boolean;
setGrouping(g: boolean): void;
showToast(title: string, message: string, toastConfig?: ToastyConfig | undefined): number;
private executeToastFinalLogic;
showToastPromise<T>(title: string, promise: ToastyPromise<T>, config?: ToastyConfig): void;
showToastComponent(component: Type<any>, componentParams: Record<string, any>, config?: ToastyConfig): number;
showToastSchedule(title: string, message: string, schedule: ToastSchedule, config: Omit<ToastyConfig, "schedule">): void;
showToastConfirm(title: string, message: string, onConfirm: () => void, onCancel?: () => void, config?: Omit<ToastyConfig, 'actions'>): number;
private scheduled;
private scheduleToast;
removeToast(id: number): void;
closeToast(id: number): void;
updateTouchStart(id: number, touch: Touch): void;
updateTouchEnd(touch: Touch): void;
updateTouchMove(touch: Touch): void;
private updateToast;
private refreshToastExpiration;
private hash;
static ɵfac: i0.ɵɵFactoryDeclaration<ToastyService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<ToastyService>;
}
export {};