import { CommonModule } from '@angular/common'; import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewEncapsulation, } from '@angular/core'; import { NgbModule, NgbPopover } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; // enums import { AutoCloseStringEnum } from './enums/autoclose-string.enum'; @Component({ selector: '[app-ca-autoclose-popover]', templateUrl: './ca-autoclose-popover.component.html', styleUrls: ['./ca-autoclose-popover.component.scss'], imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule], encapsulation: ViewEncapsulation.Emulated }) export class CaAutoclosePopoverComponent implements OnInit { @Input() isDisabled!: boolean; @Input() customClass!: string; @Input() autoClose: string | boolean = 'outside'; @Input() placement: string = AutoCloseStringEnum.BOTTOM_RIGHT_PLACEMENT; @Output() closeFilter = new EventEmitter(); @Output() openFilter = new EventEmitter(); public tooltip: NgbPopover | null = null; constructor(private eRef: ElementRef) {} ngOnInit(): void {} public switchTab(event: Event, t2: NgbPopover): void { if (this.tooltip?.isOpen()) this.tooltip.close(); this.tooltip = t2; this.tooltip.open(); } public onFilterClose(): void { if (this.closeFilter) this.closeFilter.emit(); } public onFilterShown(): void { if (this.openFilter) this.openFilter.emit(); } public closeCustomPopover(): void { if (this.tooltip) this.tooltip.close(); } }