license import { FocusMonitor } from '@angular/cdk/a11y' ; import { ChangeDetectionStrategy , ChangeDetectorRef , Component , ElementRef , Input , OnDestroy , ViewEncapsulation , TemplateRef , } from '@angular/core' ; import { Subscription } from 'rxjs' ; import { MatStepLabel } from './step-label' ; import { MatStepperIntl } from './stepper-intl' ; import { MatStepperIconContext } from './stepper-icon' ; import { CdkStepHeader , StepState } from '@angular/cdk/stepper' ; @ Component ( { moduleId : module . id , selector : 'mat-step-header' , templateUrl : 'step-header.html' , styleUrls : [ 'step-header.css' ] , host : { 'class' : 'mat-step-header' , 'role' : 'tab' , } , encapsulation : ViewEncapsulation . None , changeDetection : ChangeDetectionStrategy . OnPush , } ) export class MatStepHeader extends CdkStepHeader implements OnDestroy { private _intlSubscription : Subscription ; /** State of the given step. */ @ Input ( ) state : StepState ; /** Label of the given step. */ @ Input ( ) label : MatStepLabel | string ; /** Error message to display when there's an error. */ @ Input ( ) errorMessage : string ; /** Overrides for the header icons, passed in via the stepper. */ @ Input ( ) iconOverrides : { [ key ] : TemplateRef < MatStepperIconContext > ; } ; /** Index of the given step. */ @ Input ( ) index : number ; /** Whether the given step is selected. */ @ Input ( ) selected : boolean ; /** Whether the given step label is active. */ @ Input ( ) active : boolean ; /** Whether the given step is optional. */ @ Input ( ) optional : boolean ; constructor ( public _intl , private _focusMonitor , _elementRef , changeDetectorRef ) { super ( _elementRef ) ; _focusMonitor . monitor ( _elementRef , true ) ; this . _intlSubscription = _intl . changes . subscribe ( ( ) => changeDetectorRef . markForCheck ( ) ) ; } ngOnDestroy ( ) { this . _intlSubscription . unsubscribe ( ) ; this . _focusMonitor . stopMonitoring ( this . _elementRef ) ; } /** Returns string label of given step if it is a text label. */ _stringLabel ( ) { return this . label instanceof MatStepLabel ? null : this . label ; } /** Returns MatStepLabel if the label of given step is a template label. */ _templateLabel ( ) { return this . label instanceof MatStepLabel ? this . label : null ; } /** Returns the host HTML element. */ _getHostElement ( ) { return this . _elementRef . nativeElement ; } /** Template context variables that are exposed to the `matStepperIcon` instances. */ _getIconContext ( ) { return { index : this . index , active : this . active , optional : this . optional } ; } }