import { Directive , HostListener } from '@angular/core' ; import { isKeyboardTrigger } from '../../common/index' ; import { FocusIndicatorOriginService } from '../../directives/accessibility/index' ; import { SidePanelService } from './side-panel.service' ; @ Directive ( { selector : '[uxSidePanelClose]' } ) export class SidePanelCloseDirective { constructor ( private readonly _service , private readonly _focusOrigin ) { } @ HostListener ( 'click' , [ '$event' ] ) onClick ( event ) { this . _focusOrigin . setOrigin ( isKeyboardTrigger ( event ) ? 'keyboard' : 'mouse' ) ; this . _service . close ( ) ; } }