UNPKG

4.5 kBTypeScriptView Raw
1import { InjectionToken } from '@angular/core';
2import { Observable } from 'rxjs';
3import { ComponentType } from '../portal/portal';
4import { ToastRef } from './toast-injector';
5export declare type ProgressAnimationType = 'increasing' | 'decreasing';
6/**
7 * Configuration for an individual toast.
8 */
9export interface IndividualConfig {
10 /**
11 * disable both timeOut and extendedTimeOut
12 * default: false
13 */
14 disableTimeOut: boolean | 'timeOut' | 'extendedTimeOut';
15 /**
16 * toast time to live in milliseconds
17 * default: 5000
18 */
19 timeOut: number;
20 /**
21 * toast show close button
22 * default: false
23 */
24 closeButton: boolean;
25 /**
26 * time to close after a user hovers over toast
27 * default: 1000
28 */
29 extendedTimeOut: number;
30 /**
31 * show toast progress bar
32 * default: false
33 */
34 progressBar: boolean;
35 /**
36 * changes toast progress bar animation
37 * default: decreasing
38 */
39 progressAnimation: ProgressAnimationType;
40 /**
41 * render html in toast message (possibly unsafe)
42 * default: false
43 */
44 enableHtml: boolean;
45 /**
46 * css class on toast component
47 * default: ngx-toastr
48 */
49 toastClass: string;
50 /**
51 * css class on toast container
52 * default: toast-top-right
53 */
54 positionClass: string;
55 /**
56 * css class on toast title
57 * default: toast-title
58 */
59 titleClass: string;
60 /**
61 * css class on toast message
62 * default: toast-message
63 */
64 messageClass: string;
65 /**
66 * animation easing on toast
67 * default: ease-in
68 */
69 easing: string;
70 /**
71 * animation ease time on toast
72 * default: 300
73 */
74 easeTime: string | number;
75 /**
76 * clicking on toast dismisses it
77 * default: true
78 */
79 tapToDismiss: boolean;
80 /**
81 * Angular toast component to be shown
82 * default: Toast
83 */
84 toastComponent?: ComponentType<any>;
85 /**
86 * Helps show toast from a websocket or from event outside Angular
87 * default: false
88 */
89 onActivateTick: boolean;
90 /**
91 * New toast placement
92 * default: true
93 */
94 newestOnTop: boolean;
95}
96export interface ToastrIconClasses {
97 error: string;
98 info: string;
99 success: string;
100 warning: string;
101 [key: string]: string;
102}
103/**
104 * Global Toast configuration
105 * Includes all IndividualConfig
106 */
107export interface GlobalConfig extends IndividualConfig {
108 /**
109 * max toasts opened. Toasts will be queued
110 * Zero is unlimited
111 * default: 0
112 */
113 maxOpened: number;
114 /**
115 * dismiss current toast when max is reached
116 * default: false
117 */
118 autoDismiss: boolean;
119 iconClasses: Partial<ToastrIconClasses>;
120 /**
121 * block duplicate messages
122 * default: false
123 */
124 preventDuplicates: boolean;
125 /**
126 * display the number of duplicate messages
127 * default: false
128 */
129 countDuplicates: boolean;
130 /**
131 * Reset toast timeout when there's a duplicate (preventDuplicates needs to be set to true)
132 * default: false
133 */
134 resetTimeoutOnDuplicate: boolean;
135 /**
136 * consider the title of a toast when checking if duplicate
137 * default: false
138 */
139 includeTitleDuplicates: boolean;
140}
141/**
142 * Everything a toast needs to launch
143 */
144export declare class ToastPackage {
145 toastId: number;
146 config: IndividualConfig;
147 message: string | null | undefined;
148 title: string | undefined;
149 toastType: string;
150 toastRef: ToastRef<any>;
151 private _onTap;
152 private _onAction;
153 constructor(toastId: number, config: IndividualConfig, message: string | null | undefined, title: string | undefined, toastType: string, toastRef: ToastRef<any>);
154 /** Fired on click */
155 triggerTap(): void;
156 onTap(): Observable<void>;
157 /** available for use in custom toast */
158 triggerAction(action?: any): void;
159 onAction(): Observable<void>;
160}
161/** @deprecated use GlobalConfig */
162export interface GlobalToastrConfig extends GlobalConfig {
163}
164/** @deprecated use IndividualConfig */
165export interface IndividualToastrConfig extends IndividualConfig {
166}
167/** @deprecated use IndividualConfig */
168export interface ToastrConfig extends IndividualConfig {
169}
170export declare const DefaultNoComponentGlobalConfig: GlobalConfig;
171export interface ToastToken {
172 default: GlobalConfig;
173 config: Partial<GlobalConfig>;
174}
175export declare const TOAST_CONFIG: InjectionToken<ToastToken>;