@@ -3,14 +3,14 @@ import {
33 ChangeDetectorRef ,
44 Component ,
55 ElementRef ,
6- EventEmitter ,
76 HostBinding ,
87 HostListener ,
98 Input ,
9+ input ,
1010 numberAttribute ,
1111 OnDestroy ,
1212 OnInit ,
13- Output ,
13+ output ,
1414 Renderer2
1515} from '@angular/core' ;
1616
@@ -50,44 +50,45 @@ type AnimateType = 'hide' | 'show';
5050 host : { class : 'toast show' }
5151} )
5252export class ToastComponent implements OnInit , OnDestroy {
53- public dynamic ! : boolean ;
54- public placement ! : TToasterPlacement ;
55-
5653 constructor (
5754 public hostElement : ElementRef ,
5855 public renderer : Renderer2 ,
5956 public toasterService : ToasterService ,
6057 public changeDetectorRef : ChangeDetectorRef
6158 ) { }
6259
60+ readonly dynamic = input < boolean > ( ) ;
61+ readonly placement = input < TToasterPlacement > ( ) ;
62+
6363 /**
6464 * Auto hide the toast.
6565 * @type boolean
6666 */
67- @ Input ( ) autohide : boolean = true ;
67+ readonly autohide = input ( true ) ;
6868
6969 /**
7070 * Sets the color context of the component to one of CoreUI’s themed colors.
7171 * @type Colors
7272 */
73- @ Input ( ) color ?: Colors = '' ;
73+ readonly color = input < Colors > ( '' ) ;
7474
7575 /**
7676 * Delay hiding the toast (ms).
7777 * @type number
7878 */
79- @ Input ( { transform : numberAttribute } ) delay : number = 5000 ;
79+ readonly delay = input ( 5000 , { transform : numberAttribute } ) ;
8080
8181 /**
8282 * Apply fade transition to the toast.
8383 * @type boolean
8484 */
85- @ Input ( ) fade : boolean = true ;
85+ readonly fade = input ( true ) ;
8686
8787 /**
8888 * Toggle the visibility of component.
8989 * @type boolean
9090 */
91+
9192 @Input ( { transform : booleanAttribute } )
9293 set visible ( value : boolean ) {
9394 const newValue = value ;
@@ -108,19 +109,19 @@ export class ToastComponent implements OnInit, OnDestroy {
108109 /**
109110 * @ignore
110111 */
111- @ Input ( { transform : numberAttribute } ) index ?: number ;
112+ readonly index = input ( 0 , { transform : numberAttribute } ) ;
112113
113114 /**
114115 * Event emitted on visibility change. [docs]
115- * @type EventEmitter <boolean>
116+ * @type <boolean>
116117 */
117- @ Output ( ) visibleChange : EventEmitter < boolean > = new EventEmitter < boolean > ( ) ;
118+ readonly visibleChange = output < boolean > ( ) ;
118119
119120 /**
120121 * Event emitted on timer tick. [docs]
121122 * @type number
122123 */
123- @ Output ( ) timer : EventEmitter < number > = new EventEmitter ( ) ;
124+ readonly timer = output < number > ( ) ;
124125
125126 private timerId : ReturnType < typeof setTimeout > | undefined ;
126127 private clockId : ReturnType < typeof setInterval > | undefined ;
@@ -140,7 +141,7 @@ export class ToastComponent implements OnInit, OnDestroy {
140141
141142 @HostBinding ( '@.disabled' )
142143 get animationDisabled ( ) : boolean {
143- return ! this . fade ;
144+ return ! this . fade ( ) ;
144145 }
145146
146147 @HostBinding ( '@fadeInOut' )
@@ -161,8 +162,8 @@ export class ToastComponent implements OnInit, OnDestroy {
161162 return {
162163 toast : true ,
163164 show : true ,
164- [ `bg-${ this . color } ` ] : ! ! this . color ,
165- 'border-0' : ! ! this . color
165+ [ `bg-${ this . color ( ) } ` ] : ! ! this . color ( ) ,
166+ 'border-0' : ! ! this . color ( )
166167 } ;
167168 }
168169
@@ -171,7 +172,7 @@ export class ToastComponent implements OnInit, OnDestroy {
171172 this . toasterService . setState ( {
172173 toast : this ,
173174 show : this . visible ,
174- placement : this . placement
175+ placement : this . placement ( )
175176 } ) ;
176177 this . clearTimer ( ) ;
177178 this . setTimer ( ) ;
@@ -184,8 +185,8 @@ export class ToastComponent implements OnInit, OnDestroy {
184185
185186 setTimer ( ) : void {
186187 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 ;
189190 this . setClock ( ) ;
190191 }
191192 }
@@ -201,7 +202,7 @@ export class ToastComponent implements OnInit, OnDestroy {
201202 this . toasterService . setState ( {
202203 toast : this ,
203204 show : false ,
204- placement : this . placement
205+ placement : this . placement ( )
205206 } ) ;
206207 }
207208
@@ -214,7 +215,7 @@ export class ToastComponent implements OnInit, OnDestroy {
214215 } , 1000 ) ;
215216 this . clockTimerId = setTimeout ( ( ) => {
216217 this . clearClock ( ) ;
217- } , this . delay ) ;
218+ } , this . delay ( ) ) ;
218219 }
219220
220221 clearClock ( ) : void {
0 commit comments