1
-
2
1
import { InjectionToken } from "@angular/core" ;
3
2
4
- export type ToastType = ' success' | ' info' | ' warning' | ' wait' | ' error' ;
3
+ export type ToastType = " success" | " info" | " warning" | " wait" | " error" ;
5
4
export type OnActionCallback = ( _toast : Toast ) => void ;
6
- export type ProgressBarDirection = ' decreasing' | ' increasing' ;
5
+ export type ProgressBarDirection = " decreasing" | " increasing" ;
7
6
8
7
export enum BodyOutputType {
9
- Default , TrustedHtml , Component
8
+ Default ,
9
+ TrustedHtml ,
10
+ Component ,
10
11
}
11
12
12
13
export interface IClearWrapper {
13
14
toastId ?: string ;
14
15
toastContainerId ?: number ;
15
16
}
16
17
17
-
18
18
export interface Toast {
19
19
type : ToastType ;
20
20
title ?: string ;
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
22
body ?: any ;
22
23
toastId ?: string ;
23
24
toastContainerId ?: number ;
@@ -28,35 +29,36 @@ export interface Toast {
28
29
bodyOutputType ?: BodyOutputType ;
29
30
showCloseButton ?: boolean ;
30
31
closeHtml ?: string ;
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
33
data ?: any ;
32
34
tapToDismiss ?: boolean ;
33
35
progressBar ?: boolean ;
34
- progressBarDirection ?: ProgressBarDirection
36
+ progressBarDirection ?: ProgressBarDirection ;
35
37
}
36
38
37
- export const DefaultTypeClasses : Partial < Record < ToastType , string > > = {
38
- error : ' angular-toast-error' ,
39
- info : ' angular-toast-info' ,
40
- wait : ' angular-toast-wait' ,
41
- success : ' angular-toast-success' ,
42
- warning : ' angular-toast-warning'
39
+ export const DefaultTypeClasses : Partial < Record < ToastType , string > > = {
40
+ error : " angular-toast-error" ,
41
+ info : " angular-toast-info" ,
42
+ wait : " angular-toast-wait" ,
43
+ success : " angular-toast-success" ,
44
+ warning : " angular-toast-warning" ,
43
45
} ;
44
46
45
- export const DefaultIconClasses : Partial < Record < ToastType , string > > = {
46
- error : ' icon-error' ,
47
- info : ' icon-info' ,
48
- wait : ' icon-wait' ,
49
- success : ' icon-success' ,
50
- warning : ' icon-warning'
47
+ export const DefaultIconClasses : Partial < Record < ToastType , string > > = {
48
+ error : " icon-error" ,
49
+ info : " icon-info" ,
50
+ wait : " icon-wait" ,
51
+ success : " icon-success" ,
52
+ warning : " icon-warning" ,
51
53
} ;
52
54
53
55
export interface IToasterConfig {
54
- limit ?: number | null ;
56
+ limit ?: number | null ;
55
57
tapToDismiss ?: boolean ;
56
- showCloseButton ?: boolean | Partial < Record < ToastType , boolean > > ;
58
+ showCloseButton ?: boolean | Partial < Record < ToastType , boolean > > ;
57
59
closeHtml ?: string ;
58
60
newestOnTop ?: boolean ;
59
- timeout ?: number | Partial < Record < ToastType , number > > ;
61
+ timeout ?: number | Partial < Record < ToastType , number > > ;
60
62
typeClasses ?: Partial < Record < ToastType , string > > ;
61
63
iconClasses ?: Partial < Record < ToastType , string > > ;
62
64
bodyOutputType ?: BodyOutputType ;
@@ -72,39 +74,40 @@ export interface IToasterConfig {
72
74
animation ?: string ;
73
75
preventDuplicates ?: boolean ;
74
76
mouseoverTimerStop ?: boolean ;
75
- toastContainerId ?: number | null ;
77
+ toastContainerId ?: number | null ;
76
78
}
77
79
78
80
export const defaultToasterConfig : IToasterConfig = {
79
81
limit : null ,
80
82
tapToDismiss : true ,
81
83
showCloseButton : false ,
82
- closeHtml : ' <span>×</span>' ,
84
+ closeHtml : " <span>×</span>" ,
83
85
newestOnTop : true ,
84
86
timeout : 5000 ,
85
87
typeClasses : DefaultTypeClasses ,
86
88
iconClasses : DefaultIconClasses ,
87
89
bodyOutputType : BodyOutputType . Default ,
88
- bodyTemplate : ' toasterBodyTmpl.html' ,
89
- defaultToastType : ' info' ,
90
- positionClass : ' angular-toast-top-right' ,
91
- titleClass : ' angular-toast-title' ,
92
- messageClass : ' angular-toast-message' ,
93
- animation : '' ,
90
+ bodyTemplate : " toasterBodyTmpl.html" ,
91
+ defaultToastType : " info" ,
92
+ positionClass : " angular-toast-top-right" ,
93
+ titleClass : " angular-toast-title" ,
94
+ messageClass : " angular-toast-message" ,
95
+ animation : "" ,
94
96
preventDuplicates : false ,
95
97
mouseoverTimerStop : false ,
96
- toastContainerId : null
97
- }
98
+ toastContainerId : null ,
99
+ } ;
98
100
99
- export const ToasterConfigInjectionToken : InjectionToken < IToasterConfig > = new InjectionToken < IToasterConfig > ( 'ToasterConfig' ) ;
101
+ export const ToasterConfigInjectionToken : InjectionToken < IToasterConfig > =
102
+ new InjectionToken < IToasterConfig > ( "ToasterConfig" ) ;
100
103
101
104
export class ToasterConfig implements IToasterConfig {
102
- limit ?: number | null ;
105
+ limit ?: number | null ;
103
106
tapToDismiss : boolean ;
104
- showCloseButton : boolean | Partial < Record < ToastType , boolean > > ;
107
+ showCloseButton : boolean | Partial < Record < ToastType , boolean > > ;
105
108
closeHtml : string ;
106
109
newestOnTop : boolean ;
107
- timeout : number | Partial < Record < ToastType , number > > ;
110
+ timeout : number | Partial < Record < ToastType , number > > ;
108
111
typeClasses : Partial < Record < ToastType , string > > ;
109
112
iconClasses : Partial < Record < ToastType , string > > ;
110
113
bodyOutputType : BodyOutputType ;
@@ -120,28 +123,46 @@ export class ToasterConfig implements IToasterConfig {
120
123
animation : string ;
121
124
preventDuplicates : boolean ;
122
125
mouseoverTimerStop : boolean ;
123
- toastContainerId ?: number | null ;
126
+ toastContainerId ?: number | null ;
124
127
125
128
constructor ( configOverrides ?: IToasterConfig ) {
126
- configOverrides = configOverrides || { } ;
127
- this . limit = configOverrides . limit || null ;
128
- this . tapToDismiss = configOverrides . tapToDismiss != null ? configOverrides . tapToDismiss : true ;
129
- this . showCloseButton = configOverrides . showCloseButton != null ? configOverrides . showCloseButton : false ;
130
- this . closeHtml = configOverrides . closeHtml || '<span>×</span>' ;
131
- this . newestOnTop = configOverrides . newestOnTop != null ? configOverrides . newestOnTop : true ;
132
- this . timeout = configOverrides . timeout != null ? configOverrides . timeout : 5000 ;
133
- this . typeClasses = configOverrides . typeClasses || DefaultTypeClasses ;
134
- this . iconClasses = configOverrides . iconClasses || DefaultIconClasses ;
135
- this . bodyOutputType = configOverrides . bodyOutputType || BodyOutputType . Default ;
136
- this . bodyTemplate = configOverrides . bodyTemplate || 'toasterBodyTmpl.html' ;
137
- this . defaultToastType = configOverrides . defaultToastType || 'info' ;
138
- this . positionClass = configOverrides . positionClass || 'angular-toast-top-right' ;
139
- this . titleClass = configOverrides . titleClass || 'angular-toast-title' ;
140
- this . messageClass = configOverrides . messageClass || 'angular-toast-message' ;
141
- this . animation = configOverrides . animation || '' ;
142
- this . preventDuplicates = configOverrides . preventDuplicates != null ? configOverrides . preventDuplicates : false ;
143
- this . mouseoverTimerStop = configOverrides . mouseoverTimerStop != null ? configOverrides . mouseoverTimerStop : false ;
144
- this . toastContainerId = configOverrides . toastContainerId != null ? configOverrides . toastContainerId : null ;
129
+ configOverrides = configOverrides || { } ;
130
+ this . limit = configOverrides . limit || null ;
131
+ this . tapToDismiss =
132
+ configOverrides . tapToDismiss != null
133
+ ? configOverrides . tapToDismiss
134
+ : true ;
135
+ this . showCloseButton =
136
+ configOverrides . showCloseButton != null
137
+ ? configOverrides . showCloseButton
138
+ : false ;
139
+ this . closeHtml = configOverrides . closeHtml || "<span>×</span>" ;
140
+ this . newestOnTop =
141
+ configOverrides . newestOnTop != null ? configOverrides . newestOnTop : true ;
142
+ this . timeout =
143
+ configOverrides . timeout != null ? configOverrides . timeout : 5000 ;
144
+ this . typeClasses = configOverrides . typeClasses || DefaultTypeClasses ;
145
+ this . iconClasses = configOverrides . iconClasses || DefaultIconClasses ;
146
+ this . bodyOutputType =
147
+ configOverrides . bodyOutputType || BodyOutputType . Default ;
148
+ this . bodyTemplate = configOverrides . bodyTemplate || "toasterBodyTmpl.html" ;
149
+ this . defaultToastType = configOverrides . defaultToastType || "info" ;
150
+ this . positionClass =
151
+ configOverrides . positionClass || "angular-toast-top-right" ;
152
+ this . titleClass = configOverrides . titleClass || "angular-toast-title" ;
153
+ this . messageClass = configOverrides . messageClass || "angular-toast-message" ;
154
+ this . animation = configOverrides . animation || "" ;
155
+ this . preventDuplicates =
156
+ configOverrides . preventDuplicates != null
157
+ ? configOverrides . preventDuplicates
158
+ : false ;
159
+ this . mouseoverTimerStop =
160
+ configOverrides . mouseoverTimerStop != null
161
+ ? configOverrides . mouseoverTimerStop
162
+ : false ;
163
+ this . toastContainerId =
164
+ configOverrides . toastContainerId != null
165
+ ? configOverrides . toastContainerId
166
+ : null ;
145
167
}
146
168
}
147
-
0 commit comments