import { CommonModule } from '@angular/common'; import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'; import { Component, Host, ViewChild, TemplateRef, AfterViewInit, Input, } from '@angular/core'; @Component({ selector: 'mainCaTooltip, [mainCaTooltip]', templateUrl: './ca-app-tooltip-v2.component.html', styleUrls: ['./ca-app-tooltip-v2.component.scss'], standalone: true, imports: [CommonModule], }) export class CaAppTooltipV2Component implements AfterViewInit { @ViewChild(TemplateRef) template!: TemplateRef; @Input() mainCaTooltip?: string = ''; @Input() position: string = ''; @Input() tooltipBackground?: string = 'rgb(40, 82, 159)'; @Input() tooltipColor: string = '#fff'; @Input() tooltipTextAlign: string = 'left'; @Input() tooltipMarginTop!: string; @Input() tooltipMarginRight!: string; @Input() set disableTooltip(isDisabled: boolean) { if (this.ngbTooltop) this.ngbTooltop.disableTooltip = isDisabled; } @Input() set openTooltipDelay(value: number) { this._openTooltipDelay = value; this.updateDelay(); } private _openTooltipDelay: number = 1000; constructor(@Host() private ngbTooltop: NgbTooltip) { this.ngbTooltop.container = 'body'; this.setOpenDelay(); } ngAfterViewInit() { this.updateDelay(); this.bindTemplete(); } private updateDelay() { if (this.ngbTooltop) { this.ngbTooltop.openDelay = this._openTooltipDelay; this.setOpenDelay(); } } private setOpenDelay(): void { Object.defineProperty(this.ngbTooltop, 'openDelay', { value: this._openTooltipDelay, writable: true, configurable: true, }); } public bindTemplete(): void { if (this.ngbTooltop) { this.ngbTooltop.tooltipClass = 'app-ca-main-tooltip'; this.ngbTooltop.placement = this.position; this.ngbTooltop.ngbTooltip = this.template; this.updateDelay(); } } }