license import { Directive , Input , OnChanges , OnInit , Optional , SimpleChanges , ElementRef , } from '@angular/core' ; import { MatDialog } from './dialog' ; import { MatDialogRef } from './dialog-ref' ; /** Counter used to generate unique IDs for dialog elements. */ let dialogElementUid = 0 ; /**
 * Button that will close the current dialog.
 */ @ Directive ( { selector : `button[mat-dialog-close], button[matDialogClose]` , exportAs : 'matDialogClose' , host : { '(click)' : 'dialogRef.close(dialogResult)' , '[attr.aria-label]' : 'ariaLabel' , 'type' : 'button' , } } ) export class MatDialogClose implements OnInit , OnChanges { /** Screenreader label for the button. */ @ Input ( 'aria-label' ) ariaLabel : string = 'Close dialog' ; /** Dialog close input. */ @ Input ( 'mat-dialog-close' ) dialogResult : any ; @ Input ( 'matDialogClose' ) _matDialogClose : any ; constructor ( @ Optional ( ) public dialogRef , private _elementRef , private _dialog ) { } ngOnInit ( ) { if ( ! this . dialogRef ) { this . dialogRef = getClosestDialog ( this . _elementRef , this . _dialog . openDialogs ) ! ; } } ngOnChanges ( changes ) { const proxiedChange = changes . _matDialogClose || changes . _matDialogCloseResult ; if ( proxiedChange ) { this . dialogResult = proxiedChange . currentValue ; } } } /**
 * Title of a dialog element. Stays fixed to the top of the dialog when scrolling.
 */ @ Directive ( { selector : '[mat-dialog-title], [matDialogTitle]' , exportAs : 'matDialogTitle' , host : { 'class' : 'mat-dialog-title' , '[id]' : 'id' , } , } ) export class MatDialogTitle implements OnInit { @ Input ( ) id = `mat-dialog-title-${ dialogElementUid ++ }` ; constructor ( @ Optional ( ) private _dialogRef , private _elementRef , private _dialog ) { } ngOnInit ( ) { if ( ! this . _dialogRef ) { this . _dialogRef = getClosestDialog ( this . _elementRef , this . _dialog . openDialogs ) ! ; } if ( this . _dialogRef ) { Promise . resolve ( ) . then ( ( ) => { const container = this . _dialogRef . _containerInstance ; if ( container && ! container . _ariaLabelledBy ) { container . _ariaLabelledBy = this . id ; } } ) ; } } } /**
 * Scrollable content container of a dialog.
 */ @ Directive ( { selector : `[mat-dialog-content], mat-dialog-content, [matDialogContent]` , host : { 'class' : 'mat-dialog-content' } } ) export class MatDialogContent { } /**
 * Container for the bottom action buttons in a dialog.
 * Stays fixed to the bottom when scrolling.
 */ @ Directive ( { selector : `[mat-dialog-actions], mat-dialog-actions, [matDialogActions]` , host : { 'class' : 'mat-dialog-actions' } } ) export class MatDialogActions { } param element param openDialogs function getClosestDialog ( element , openDialogs ) { let parent = element . nativeElement . parentElement ; while ( parent && ! parent . classList . contains ( 'mat-dialog-container' ) ) { parent = parent . parentElement ; } return parent ? openDialogs . find ( dialog => dialog . id === parent ! . id ) : null ; }