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

import { Directive, ElementRef, HostBinding, Input } from '@angular/core';
import { Highlightable } from '@angular/cdk/a11y';
import { ColumnItem } from './column-browser.model';

@Directive({
  selector: '[bciColumnItem]',
})
export class ColumnItemDirective implements Highlightable {
  @Input() item: ColumnItem;

  @Input() label: string;

  @Input() index: number;

  @Input() columnLevel: number;

  private _isActive = false;

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

  constructor(public elem: ElementRef) {}

  setActiveStyles(): void {
    this._isActive = true;
  }

  setInactiveStyles(): void {
    this._isActive = false;
  }

  getLabel(): string {
    return this.label;
  }

  get offsetTop(): number {
    return this.elem.nativeElement.offsetTop;
  }
}
