/*
 * Copyright (C) 2018 Robert Bosch GmbH Copyright (C) 2018 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { Directive, EventEmitter, HostBinding, HostListener, Input, Output } from '@angular/core';

@Directive({
  selector: '[bciClickableItem]',
})
export class ClickableItemDirective {
  @HostBinding('attr.tabindex')
  @Input()
  tabindex = 0;

  @Output()
  trigger = new EventEmitter<KeyboardEvent | MouseEvent>();

  @HostListener('keyup.enter', ['$event'])
  @HostListener('click', ['$event'])
  public click(event: KeyboardEvent | MouseEvent) {
    this.trigger.emit(event);
  }
}
