import { Component, ChangeDetectionStrategy, Input, HostBinding, Output, EventEmitter } from '@angular/core';
import { AutocompleteDTO } from '@swagger/oms';
import { Highlightable } from '@angular/cdk/a11y';

@Component({
  selector: 'app-autocomplete-result-item',
  templateUrl: 'result-item.component.html',
  styleUrls: ['./result-item.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ResultItemComponent implements Highlightable {
  @Input() result: AutocompleteDTO;
  @Output() clicked = new EventEmitter<AutocompleteDTO>();

  private _isActive: boolean;

  @HostBinding('class.active') get isActive() {
    return this._isActive;
  }

  set isActive(isActive: boolean) {
    this._isActive = isActive;
  }

  constructor() {}

  setActiveStyles(): void {
    this.isActive = true;
  }
  setInactiveStyles(): void {
    this.isActive = false;
  }
}
