1
1
import {
2
2
AfterContentInit ,
3
+ booleanAttribute ,
3
4
Component ,
4
5
ContentChildren ,
5
6
EventEmitter ,
@@ -11,7 +12,6 @@ import {
11
12
} from '@angular/core' ;
12
13
import { NgTemplateOutlet } from '@angular/common' ;
13
14
import { animate , AnimationEvent , state , style , transition , trigger } from '@angular/animations' ;
14
- import { BooleanInput , coerceBooleanProperty } from '@angular/cdk/coercion' ;
15
15
16
16
import { Colors } from '../coreui.types' ;
17
17
import { TemplateIdDirective } from '../shared' ;
@@ -48,10 +48,6 @@ type AnimateType = ('hide' | 'show');
48
48
} )
49
49
export class AlertComponent implements AfterContentInit {
50
50
51
- static ngAcceptInputType_dismissible : BooleanInput ;
52
- static ngAcceptInputType_fade : BooleanInput ;
53
- static ngAcceptInputType_visible : BooleanInput ;
54
-
55
51
hide ! : boolean ;
56
52
/**
57
53
* Sets the color context of the component to one of CoreUI’s themed colors.
@@ -79,54 +75,37 @@ export class AlertComponent implements AfterContentInit {
79
75
templates : any = { } ;
80
76
@ContentChildren ( TemplateIdDirective , { descendants : true } ) contentTemplates ! : QueryList < TemplateIdDirective > ;
81
77
82
- private _dismissible = false ;
83
-
84
78
/**
85
79
* Optionally adds a close button to alert and allow it to self dismiss.
86
80
* @type boolean
81
+ * @default false
87
82
*/
88
- @Input ( )
89
- get dismissible ( ) : boolean {
90
- return this . _dismissible ;
91
- }
92
-
93
- set dismissible ( value : boolean ) {
94
- this . _dismissible = coerceBooleanProperty ( value ) ;
95
- }
96
-
97
- private _fade = false ;
83
+ @Input ( { transform : booleanAttribute } ) dismissible : boolean = false ;
98
84
99
85
/**
100
86
* Adds animation for dismissible alert.
101
87
* @type boolean
102
88
*/
103
- @Input ( )
104
- get fade ( ) : boolean {
105
- return this . _fade ;
106
- }
107
-
108
- set fade ( value : boolean ) {
109
- this . _fade = coerceBooleanProperty ( value ) ;
110
- }
111
-
112
- private _visible = true ;
113
-
114
- get visible ( ) {
115
- return this . _visible ;
116
- }
89
+ @Input ( { transform : booleanAttribute } ) fade : boolean = false ;
117
90
118
91
/**
119
92
* Toggle the visibility of alert component.
120
93
* @type boolean
121
94
*/
122
- @Input ( )
95
+ @Input ( { transform : booleanAttribute } )
123
96
set visible ( value : boolean ) {
124
- if ( this . _visible !== value ) {
125
- this . _visible = coerceBooleanProperty ( value ) ;
97
+ if ( this . #visible !== value ) {
98
+ this . #visible = value ;
126
99
this . visibleChange . emit ( value ) ;
127
100
}
128
101
} ;
129
102
103
+ get visible ( ) {
104
+ return this . #visible;
105
+ }
106
+
107
+ #visible: boolean = true ;
108
+
130
109
@HostBinding ( '@.disabled' )
131
110
get animationDisabled ( ) : boolean {
132
111
return ! this . fade ;
0 commit comments