@@ -3,14 +3,14 @@ import {
3
3
ChangeDetectorRef ,
4
4
Component ,
5
5
ElementRef ,
6
- EventEmitter ,
7
6
HostBinding ,
8
7
HostListener ,
9
8
Input ,
9
+ input ,
10
10
numberAttribute ,
11
11
OnDestroy ,
12
12
OnInit ,
13
- Output ,
13
+ output ,
14
14
Renderer2
15
15
} from '@angular/core' ;
16
16
@@ -50,44 +50,45 @@ type AnimateType = 'hide' | 'show';
50
50
host : { class : 'toast show' }
51
51
} )
52
52
export class ToastComponent implements OnInit , OnDestroy {
53
- public dynamic ! : boolean ;
54
- public placement ! : TToasterPlacement ;
55
-
56
53
constructor (
57
54
public hostElement : ElementRef ,
58
55
public renderer : Renderer2 ,
59
56
public toasterService : ToasterService ,
60
57
public changeDetectorRef : ChangeDetectorRef
61
58
) { }
62
59
60
+ readonly dynamic = input < boolean > ( ) ;
61
+ readonly placement = input < TToasterPlacement > ( ) ;
62
+
63
63
/**
64
64
* Auto hide the toast.
65
65
* @type boolean
66
66
*/
67
- @ Input ( ) autohide : boolean = true ;
67
+ readonly autohide = input ( true ) ;
68
68
69
69
/**
70
70
* Sets the color context of the component to one of CoreUI’s themed colors.
71
71
* @type Colors
72
72
*/
73
- @ Input ( ) color ?: Colors = '' ;
73
+ readonly color = input < Colors > ( '' ) ;
74
74
75
75
/**
76
76
* Delay hiding the toast (ms).
77
77
* @type number
78
78
*/
79
- @ Input ( { transform : numberAttribute } ) delay : number = 5000 ;
79
+ readonly delay = input ( 5000 , { transform : numberAttribute } ) ;
80
80
81
81
/**
82
82
* Apply fade transition to the toast.
83
83
* @type boolean
84
84
*/
85
- @ Input ( ) fade : boolean = true ;
85
+ readonly fade = input ( true ) ;
86
86
87
87
/**
88
88
* Toggle the visibility of component.
89
89
* @type boolean
90
90
*/
91
+
91
92
@Input ( { transform : booleanAttribute } )
92
93
set visible ( value : boolean ) {
93
94
const newValue = value ;
@@ -108,19 +109,19 @@ export class ToastComponent implements OnInit, OnDestroy {
108
109
/**
109
110
* @ignore
110
111
*/
111
- @ Input ( { transform : numberAttribute } ) index ?: number ;
112
+ readonly index = input ( 0 , { transform : numberAttribute } ) ;
112
113
113
114
/**
114
115
* Event emitted on visibility change. [docs]
115
- * @type EventEmitter <boolean>
116
+ * @type <boolean>
116
117
*/
117
- @ Output ( ) visibleChange : EventEmitter < boolean > = new EventEmitter < boolean > ( ) ;
118
+ readonly visibleChange = output < boolean > ( ) ;
118
119
119
120
/**
120
121
* Event emitted on timer tick. [docs]
121
122
* @type number
122
123
*/
123
- @ Output ( ) timer : EventEmitter < number > = new EventEmitter ( ) ;
124
+ readonly timer = output < number > ( ) ;
124
125
125
126
private timerId : ReturnType < typeof setTimeout > | undefined ;
126
127
private clockId : ReturnType < typeof setInterval > | undefined ;
@@ -140,7 +141,7 @@ export class ToastComponent implements OnInit, OnDestroy {
140
141
141
142
@HostBinding ( '@.disabled' )
142
143
get animationDisabled ( ) : boolean {
143
- return ! this . fade ;
144
+ return ! this . fade ( ) ;
144
145
}
145
146
146
147
@HostBinding ( '@fadeInOut' )
@@ -161,8 +162,8 @@ export class ToastComponent implements OnInit, OnDestroy {
161
162
return {
162
163
toast : true ,
163
164
show : true ,
164
- [ `bg-${ this . color } ` ] : ! ! this . color ,
165
- 'border-0' : ! ! this . color
165
+ [ `bg-${ this . color ( ) } ` ] : ! ! this . color ( ) ,
166
+ 'border-0' : ! ! this . color ( )
166
167
} ;
167
168
}
168
169
@@ -171,7 +172,7 @@ export class ToastComponent implements OnInit, OnDestroy {
171
172
this . toasterService . setState ( {
172
173
toast : this ,
173
174
show : this . visible ,
174
- placement : this . placement
175
+ placement : this . placement ( )
175
176
} ) ;
176
177
this . clearTimer ( ) ;
177
178
this . setTimer ( ) ;
@@ -184,8 +185,8 @@ export class ToastComponent implements OnInit, OnDestroy {
184
185
185
186
setTimer ( ) : void {
186
187
this . clearTimer ( ) ;
187
- if ( this . autohide && this . visible ) {
188
- this . timerId = this . delay > 0 ? setTimeout ( ( ) => this . onClose ( ) , this . delay ) : undefined ;
188
+ if ( this . autohide ( ) && this . visible ) {
189
+ this . timerId = this . delay ( ) > 0 ? setTimeout ( ( ) => this . onClose ( ) , this . delay ( ) ) : undefined ;
189
190
this . setClock ( ) ;
190
191
}
191
192
}
@@ -201,7 +202,7 @@ export class ToastComponent implements OnInit, OnDestroy {
201
202
this . toasterService . setState ( {
202
203
toast : this ,
203
204
show : false ,
204
- placement : this . placement
205
+ placement : this . placement ( )
205
206
} ) ;
206
207
}
207
208
@@ -214,7 +215,7 @@ export class ToastComponent implements OnInit, OnDestroy {
214
215
} , 1000 ) ;
215
216
this . clockTimerId = setTimeout ( ( ) => {
216
217
this . clearClock ( ) ;
217
- } , this . delay ) ;
218
+ } , this . delay ( ) ) ;
218
219
}
219
220
220
221
clearClock ( ) : void {
0 commit comments