license import { FocusMonitor , FocusableOption , FocusOrigin } from '@angular/cdk/a11y' ; import { ENTER , SPACE , hasModifierKey } from '@angular/cdk/keycodes' ; import { ChangeDetectionStrategy , ChangeDetectorRef , Component , Directive , ElementRef , Host , Input , OnDestroy , ViewEncapsulation , Optional , Inject , } from '@angular/core' ; import { merge , Subscription , EMPTY } from 'rxjs' ; import { filter } from 'rxjs/operators' ; import { matExpansionAnimations } from './expansion-animations' ; import { MatExpansionPanel , MatExpansionPanelDefaultOptions , MAT_EXPANSION_PANEL_DEFAULT_OPTIONS , } from './expansion-panel' ; /**
 * `<mat-expansion-panel-header>`
 *
 * This component corresponds to the header element of an `<mat-expansion-panel>`.
 */ @ Component ( { moduleId : module . id , selector : 'mat-expansion-panel-header' , styleUrls : [ './expansion-panel-header.css' ] , templateUrl : './expansion-panel-header.html' , encapsulation : ViewEncapsulation . None , changeDetection : ChangeDetectionStrategy . OnPush , animations : [ matExpansionAnimations . indicatorRotate , matExpansionAnimations . expansionHeaderHeight ] , host : { 'class' : 'mat-expansion-panel-header' , 'role' : 'button' , '[attr.id]' : 'panel._headerId' , '[attr.tabindex]' : 'disabled ? -1 : 0' , '[attr.aria-controls]' : '_getPanelId()' , '[attr.aria-expanded]' : '_isExpanded()' , '[attr.aria-disabled]' : 'panel.disabled' , '[class.mat-expanded]' : '_isExpanded()' , '(click)' : '_toggle()' , '(keydown)' : '_keydown($event)' , '[@expansionHeight]' : `{
        value: _getExpandedState(),
        params: {
          collapsedHeight: collapsedHeight,
          expandedHeight: expandedHeight
        }
    }` , } , } ) export class MatExpansionPanelHeader implements OnDestroy , FocusableOption { private _parentChangeSubscription = Subscription . EMPTY ; constructor ( @ Host ( ) public panel , private _element , private _focusMonitor , private _changeDetectorRef , @ Inject ( MAT_EXPANSION_PANEL_DEFAULT_OPTIONS ) @ Optional ( ) defaultOptions ? ) { const accordionHideToggleChange = panel . accordion ? panel . accordion . _stateChanges . pipe ( filter ( changes => ! ! changes . hideToggle ) ) : EMPTY ; this . _parentChangeSubscription = merge ( panel . opened , panel . closed , accordionHideToggleChange , panel . _inputChanges . pipe ( filter ( changes => ! ! ( changes . hideToggle || changes . disabled ) ) ) ) . subscribe ( ( ) => this . _changeDetectorRef . markForCheck ( ) ) ; panel . closed . pipe ( filter ( ( ) => panel . _containsFocus ( ) ) ) . subscribe ( ( ) => _focusMonitor . focusVia ( _element , 'program' ) ) ; _focusMonitor . monitor ( _element ) . subscribe ( origin => { if ( origin && panel . accordion ) { panel . accordion . _handleHeaderFocus ( this ) ; } } ) ; if ( defaultOptions ) { this . expandedHeight = defaultOptions . expandedHeight ; this . collapsedHeight = defaultOptions . collapsedHeight ; } } /** Height of the header while the panel is expanded. */ @ Input ( ) expandedHeight : string ; /** Height of the header while the panel is collapsed. */ @ Input ( ) collapsedHeight : string ; docs-private get disabled ( ) { return this . panel . disabled ; } /** Toggles the expanded state of the panel. */ _toggle ( ) { this . panel . toggle ( ) ; } /** Gets whether the panel is expanded. */ _isExpanded ( ) { return this . panel . expanded ; } /** Gets the expanded state string of the panel. */ _getExpandedState ( ) { return this . panel . _getExpandedState ( ) ; } /** Gets the panel id. */ _getPanelId ( ) { return this . panel . id ; } /** Gets whether the expand indicator should be shown. */ _showToggle ( ) { return ! this . panel . hideToggle && ! this . panel . disabled ; } /** Handle keydown event calling to toggle() if appropriate. */ _keydown ( event ) { switch ( event . keyCode ) { case SPACE : case ENTER : if ( ! hasModifierKey ( event ) ) { event . preventDefault ( ) ; this . _toggle ( ) ; } break ; default : if ( this . panel . accordion ) { this . panel . accordion . _handleHeaderKeydown ( event ) ; } return ; } } param origin docs-private focus ( origin = 'program' ) { this . _focusMonitor . focusVia ( this . _element , origin ) ; } ngOnDestroy ( ) { this . _parentChangeSubscription . unsubscribe ( ) ; this . _focusMonitor . stopMonitoring ( this . _element ) ; } } /**
 * `<mat-panel-description>`
 *
 * This directive is to be used inside of the MatExpansionPanelHeader component.
 */ @ Directive ( { selector : 'mat-panel-description' , host : { class : 'mat-expansion-panel-header-description' } } ) export class MatExpansionPanelDescription { } /**
 * `<mat-panel-title>`
 *
 * This directive is to be used inside of the MatExpansionPanelHeader component.
 */ @ Directive ( { selector : 'mat-panel-title' , host : { class : 'mat-expansion-panel-header-title' } } ) export class MatExpansionPanelTitle { }