import { Directive, ElementRef, Input, Renderer2 } from '@angular/core';
import { RbjTooltipService } from '../../services/rbj-tooltip.service';
import { UuidUtils } from '../../utilities/uuid-utils';
@Directive({
  selector: '[rbjTooltip]',
})
export class RbjTooltipDirective {

  @Input('rbjTooltip') message: string;
  @Input('rbjTooltipAutoHideSeconds') autoHideSeconds: number = 3;

  private uuid: string;
  constructor(
    private elementRef: ElementRef,
    private rbjTooltipService: RbjTooltipService
  ) { }


  ngOnInit(): void {
    this.uuid = UuidUtils.generate();
  }
  ngOnDestroy() {
    this.rbjTooltipService.destroy(this.uuid);
  }

  show() {
    this.rbjTooltipService.show(this.elementRef, this.message, this.uuid, this.autoHideSeconds);
  }

  hide() {
    this.rbjTooltipService.hide(this.uuid);
  }
}
