import { Component , Input , Output , EventEmitter , ContentChild , TemplateRef , OnInit , HostBinding , ChangeDetectionStrategy , Optional , ElementRef } from '@angular/core' ; import { ThyDialog } from '../dialog.service' ; import { ThyDialogContainerComponent } from '../dialog-container.component' ; import { ThyTranslate } from 'ngx-tethys/core' ; import { ThyInternalDialogRef } from '../dialog-ref' ; @ Component ( { selector : 'thy-dialog-header' , templateUrl : './dialog-header.component.html' , exportAs : 'thyDialogHeader' } ) export class DialogHeaderComponent implements OnInit { @ HostBinding ( `class.dialog-header` ) isDialogHeader = true ; @ HostBinding ( `class.dialog-header-lg` ) isDialogHeaderLg = false ; @ ContentChild ( 'dialogHeader' ) public headerTemplate : TemplateRef < any > ; @ Input ( ) thyTitle : string ; @ Input ( ) set thySize ( value ) { this . isDialogHeaderLg = value === 'lg' ; } @ Input ( ) set thyTitleTranslationKey ( key ) { if ( key && ! this . thyTitle ) { this . thyTitle = this . translate . instant ( key ) ; } } @ Input ( ) thyIcon : string ; @ Output ( ) thyOnClose : EventEmitter < Event > = new EventEmitter < Event > ( ) ; constructor ( private elementRef , private dialog , private translate , @ Optional ( ) private dialogContainer ) { } ngOnInit ( ) { if ( ! this . dialogContainer ) { const dialogRef = this . dialog . getClosestDialog ( this . elementRef . nativeElement ) as ThyInternalDialogRef < any > ; this . dialogContainer = dialogRef ? dialogRef . containerInstance : null ; } Promise . resolve ( ) . then ( ( ) => { if ( this . dialogContainer ) { this . dialogContainer . ariaLabelledBy = this . thyTitle ; } } ) ; } close ( event ? ) { if ( this . thyOnClose . observers . length > 0 ) { this . thyOnClose . emit ( event ) ; } else { this . dialog . close ( ) ; } } }