6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { FocusMonitor } from '@angular/cdk/a11y' ;
9
+ import { FocusMonitor } from '@angular/cdk/a11y' ;
10
10
import {
11
11
ChangeDetectionStrategy ,
12
12
ChangeDetectorRef ,
@@ -15,26 +15,25 @@ import {
15
15
Input ,
16
16
OnDestroy ,
17
17
ViewEncapsulation ,
18
- TemplateRef ,
18
+ TemplateRef
19
19
} from '@angular/core' ;
20
- import { Subscription } from 'rxjs' ;
21
- import { MatStepLabel } from './step-label' ;
22
- import { MatStepperIntl } from './stepper-intl' ;
23
- import { MatStepperIconContext } from './stepper-icon' ;
24
- import { CdkStepHeader , StepState } from '@angular/cdk/stepper' ;
25
-
20
+ import { Subscription } from 'rxjs' ;
21
+ import { MatStepLabel } from './step-label' ;
22
+ import { MatStepperIntl } from './stepper-intl' ;
23
+ import { MatStepperIconContext } from './stepper-icon' ;
24
+ import { CdkStepHeader , StepState } from '@angular/cdk/stepper' ;
26
25
27
26
@Component ( {
28
27
moduleId : module . id ,
29
28
selector : 'mat-step-header' ,
30
29
templateUrl : 'step-header.html' ,
31
30
styleUrls : [ 'step-header.css' ] ,
32
31
host : {
33
- ' class' : 'mat-step-header' ,
34
- ' role' : 'tab' ,
32
+ class : 'mat-step-header' ,
33
+ role : 'tab'
35
34
} ,
36
35
encapsulation : ViewEncapsulation . None ,
37
- changeDetection : ChangeDetectionStrategy . OnPush ,
36
+ changeDetection : ChangeDetectionStrategy . OnPush
38
37
} )
39
38
export class MatStepHeader extends CdkStepHeader implements OnDestroy {
40
39
private _intlSubscription : Subscription ;
@@ -49,7 +48,7 @@ export class MatStepHeader extends CdkStepHeader implements OnDestroy {
49
48
@Input ( ) errorMessage : string ;
50
49
51
50
/** Overrides for the header icons, passed in via the stepper. */
52
- @Input ( ) iconOverrides : { [ key : string ] : TemplateRef < MatStepperIconContext > } ;
51
+ @Input ( ) iconOverrides : { [ key : string ] : TemplateRef < MatStepperIconContext > } ;
53
52
54
53
/** Index of the given step. */
55
54
@Input ( ) index : number ;
@@ -67,10 +66,13 @@ export class MatStepHeader extends CdkStepHeader implements OnDestroy {
67
66
public _intl : MatStepperIntl ,
68
67
private _focusMonitor : FocusMonitor ,
69
68
_elementRef : ElementRef < HTMLElement > ,
70
- changeDetectorRef : ChangeDetectorRef ) {
69
+ changeDetectorRef : ChangeDetectorRef
70
+ ) {
71
71
super ( _elementRef ) ;
72
72
_focusMonitor . monitor ( _elementRef , true ) ;
73
- this . _intlSubscription = _intl . changes . subscribe ( ( ) => changeDetectorRef . markForCheck ( ) ) ;
73
+ this . _intlSubscription = _intl . changes . subscribe ( ( ) =>
74
+ changeDetectorRef . markForCheck ( )
75
+ ) ;
74
76
}
75
77
76
78
ngOnDestroy ( ) {
@@ -102,13 +104,16 @@ export class MatStepHeader extends CdkStepHeader implements OnDestroy {
102
104
} ;
103
105
}
104
106
105
- _getDefaultIconForState ( state : string ) : string {
107
+ _getDefaultIconForState ( state : StepState ) : string {
106
108
if ( state == 'number' ) {
107
109
return `${ this . index + 1 } ` ;
108
110
}
109
- return ( {
110
- 'edit' : 'create' ,
111
- 'error' : 'warning' ,
112
- } as { [ key : string ] : string } ) [ state ] || state ;
111
+ if ( state == 'edit' ) {
112
+ return 'create' ;
113
+ }
114
+ if ( state == 'error' ) {
115
+ return 'warning' ;
116
+ }
117
+ return state ;
113
118
}
114
119
}
0 commit comments