33 ChangeDetectionStrategy ,
44 ChangeDetectorRef ,
55 Component ,
6- ContentChild ,
6+ ContentChild , ElementRef ,
77 EventEmitter ,
88 Input ,
99 NgZone ,
@@ -14,73 +14,60 @@ import {
1414} from '@angular/core' ;
1515
1616import { AnimationEvent } from '../animations/animations.interface' ;
17-
1817import { BoxContentDirective , BoxFooterDirective , BoxHeaderDirective , BoxToolsDirective } from './box.directive' ;
19-
2018import { removeListeners } from '../helpers' ;
2119
22- /*
23- *
24- */
20+
2521@Component ( {
2622 selector : 'mk-box' ,
2723 templateUrl : './box.component.html' ,
2824 styleUrls : [ './box.component.css' ] ,
2925 changeDetection : ChangeDetectionStrategy . OnPush
3026} )
3127export class BoxComponent implements AfterViewInit , OnDestroy {
32- public isCollaping : boolean ;
33- public remove = false ;
34- public removed : boolean ;
35- private listeners = [ ] ;
36-
3728 @Input ( ) public boxColor = 'default' ;
3829 @Input ( ) public buttonsStyleClass = 'btn btn-box-tool' ;
3930 @Input ( ) public contentStyleClass = 'box-content-wrapper' ;
40- @Input ( ) public contentColor : string ;
41- @Input ( ) public footer : string ;
42- @Input ( ) public footerColor : string ;
31+ @Input ( ) public contentColor ? : string ;
32+ @Input ( ) public footer ? : string ;
33+ @Input ( ) public footerColor ? : string ;
4334 @Input ( ) public footerStyleClass = 'box-footer' ;
44- @Input ( ) public header : string ;
35+ @Input ( ) public header ? : string ;
4536 @Input ( ) public headerBorder = true ;
46- @Input ( ) public headerColor : string ;
37+ @Input ( ) public headerColor ? : string ;
4738 @Input ( ) public headerStyleClass = 'box-header' ;
4839 @Input ( ) public isCollapsable = true ;
4940 @Input ( ) public isCollapsed = false ;
50- @Input ( ) public isLoading : boolean ;
41+ @Input ( ) public isLoading = false ;
5142 @Input ( ) public isRemovable = true ;
5243 @Input ( ) public isSolid = false ;
53- @Input ( ) public loadingColor : string ;
44+ @Input ( ) public loadingColor ? : string ;
5445 @Input ( ) public loadingStyleClass = 'fa fa-refresh fa-spin' ;
5546 @Input ( ) public styleClass = 'box' ;
5647
5748 @Output ( ) public collapseDone = new EventEmitter ( ) ;
5849 @Output ( ) public collapseStart = new EventEmitter ( ) ;
5950
60- @ContentChild ( BoxHeaderDirective , /* TODO: add static flag */ { } ) public boxHeaderDirective : BoxHeaderDirective ;
61- @ContentChild ( BoxFooterDirective , /* TODO: add static flag */ { } ) public boxFooterDirective : BoxFooterDirective ;
62- @ContentChild ( BoxContentDirective , /* TODO: add static flag */ { } ) public boxContentDirective : BoxContentDirective ;
63- @ContentChild ( BoxToolsDirective , /* TODO: add static flag */ { } ) public boxToolsDirective : BoxToolsDirective ;
51+ @ContentChild ( BoxHeaderDirective ) public boxHeaderDirective ?: BoxHeaderDirective ;
52+ @ContentChild ( BoxFooterDirective ) public boxFooterDirective ?: BoxFooterDirective ;
53+ @ContentChild ( BoxContentDirective ) public boxContentDirective ?: BoxContentDirective ;
54+ @ContentChild ( BoxToolsDirective ) public boxToolsDirective ?: BoxToolsDirective ;
55+
56+ @ViewChild ( 'toggleButtonElement' ) private toggleButtonElement ?: ElementRef < HTMLButtonElement > ;
57+ @ViewChild ( 'removeButtonElement' ) private removeButtonElement ?: ElementRef < HTMLButtonElement > ;
6458
65- @ViewChild ( 'toggleButtonElement' ) private toggleButtonElement ;
66- @ViewChild ( 'removeButtonElement' ) private removeButtonElement ;
59+ public isCollapsing = false ;
60+ public remove = false ;
61+ public removed = false ;
62+ private listeners : ( ( ) => void ) [ ] = [ ] ;
6763
68- /**
69- * @method constructor
70- * @param changeDetectorRef [description]
71- * @param ngZone [description]
72- * @param renderer2 [description]
73- */
7464 constructor (
7565 private changeDetectorRef : ChangeDetectorRef ,
7666 private ngZone : NgZone ,
7767 private renderer2 : Renderer2
7868 ) { }
7969
80- /**
81- * @method ngAfterViewInit
82- */
83- ngAfterViewInit ( ) {
70+ ngAfterViewInit ( ) : void {
8471 this . ngZone . runOutsideAngular ( ( ) => {
8572 if ( this . toggleButtonElement ) {
8673 this . listeners . push ( this . renderer2 . listen ( this . toggleButtonElement . nativeElement , 'click' , ( ) => {
@@ -97,44 +84,26 @@ export class BoxComponent implements AfterViewInit, OnDestroy {
9784 } ) ;
9885 }
9986
100- /**
101- * @method ngOnDestroy
102- */
103- ngOnDestroy ( ) {
87+ ngOnDestroy ( ) : void {
10488 removeListeners ( this . listeners ) ;
10589 }
10690
107- /**
108- * [removedDone description]
109- * @method removedDone
110- * @param event [description]
111- */
112- public removedDone ( event ) : void {
91+ public removedDone ( event : AnimationEvent ) : void {
11392 if ( event . toState === '1' ) {
11493 this . removed = true ;
11594 }
11695 }
11796
118- /**
119- * [collapseStart description]
120- * @method collapseStart
121- * @param event [description]
122- */
12397 public onCollapseStart ( event : AnimationEvent ) : void {
12498 if ( event . fromState !== 'void' ) {
125- this . isCollaping = true ;
99+ this . isCollapsing = true ;
126100 this . collapseStart . emit ( event ) ;
127101 }
128102 }
129103
130- /**
131- * [collapseDone description]
132- * @method collapseDone
133- * @param event [description]
134- */
135104 public onCollapseDone ( event : AnimationEvent ) : void {
136105 if ( event . fromState !== 'void' ) {
137- this . isCollaping = false ;
106+ this . isCollapsing = false ;
138107 this . collapseDone . emit ( event ) ;
139108 }
140109 }
0 commit comments