{"version":3,"file":"kif-lib-tooltip.mjs","sources":["../../../projects/kif-lib/tooltip/tooltip-content.component.ts","../../../projects/kif-lib/tooltip/tooltip-content.component.html","../../../projects/kif-lib/tooltip/directive/tooltip.directive.ts","../../../projects/kif-lib/tooltip/tooltip.module.ts","../../../projects/kif-lib/tooltip/public-api.ts","../../../projects/kif-lib/tooltip/kif-lib-tooltip.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, ElementRef, Input, signal, TemplateRef } from '@angular/core';\n\n@Component({\n    selector: 'kit-tooltip-content',\n    templateUrl: './tooltip-content.component.html',\n    changeDetection: ChangeDetectionStrategy.OnPush,\n\n})\nexport class TooltipContentComponent {\n    @Input() title?: string;\n    @Input() description?: string;\n    @Input() templateRef?: TemplateRef<any>;\n    @Input() positionType = 'top';\n    @Input() offset = 8;\n    \n    private visibleState = signal(false);\n    private positionCoords = signal({ top: 0, left: 0 });\n    \n    // Expose signal readers for the template\n    visible = this.visibleState.asReadonly();\n    positionState = this.positionCoords.asReadonly();\n    \n    show(x: number, y: number, position?: string): void {\n        if (position) {\n            this.positionType = position;\n        }\n        \n        this.calculatePosition(x, y);\n        this.visibleState.set(true);\n    }\n    \n    hide(): void {\n        this.visibleState.set(false);\n    }\n    \n    private calculatePosition(x: number, y: number): void {\n        let top = 0;\n        let left = 0;\n        \n        // Get tooltip dimensions\n        const tooltipElement = this.elementRef.nativeElement.querySelector('.tooltip-container');\n        const tooltipHeight = tooltipElement.offsetHeight;\n        const tooltipWidth = tooltipElement.offsetWidth;\n        \n        switch (this.positionType) {\n            case 'top':\n                top = y - tooltipHeight - this.offset;\n                left = x - (tooltipWidth / 2);\n                break;\n            case 'bottom':\n                top = y + this.offset;\n                left = x - (tooltipWidth / 2);\n                break;\n            case 'left':\n                top = y - (tooltipHeight / 2);\n                left = x - tooltipWidth - this.offset;\n                break;\n            case 'right':\n                top = y - (tooltipHeight / 2);\n                left = x + this.offset;\n                break;\n        }\n        \n        // Ensure tooltip doesn't go outside viewport\n        const viewportWidth = window.innerWidth;\n        const viewportHeight = window.innerHeight;\n        \n        if (left < 0) left = 0;\n        if (left + tooltipWidth > viewportWidth) left = viewportWidth - tooltipWidth;\n        if (top < 0) top = 0;\n        if (top + tooltipHeight > viewportHeight) top = viewportHeight - tooltipHeight;\n        \n        this.positionCoords.set({ top, left });\n    }\n    \n    constructor(private elementRef: ElementRef) {}\n}\n\n","<div \nclass=\"tooltip-container d-flex flex-column gap-2\" \n[class.visible]=\"visible()\" \n\n[style.top.px]=\"positionState().top\" \n[style.left.px]=\"positionState().left\">\n@if (title) {\n  <div class=\"tooltip-title\">{{ title }}</div>\n}\n@if (description) {\n  <div class=\"tooltip-description\">{{ description }}</div>\n}\n@if (templateRef) {\n  <ng-container [ngTemplateOutlet]=\"templateRef\"></ng-container>\n}","import { ComponentRef, Directive, ElementRef, HostListener, inject, Input, OnDestroy, TemplateRef, ViewContainerRef } from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\nimport { TooltipContentComponent } from '../tooltip-content.component';\n\n@Directive({\n    selector: '[kitTooltip]',\n    exportAs: 'kitTooltip'\n})\nexport class TooltipDirective implements OnDestroy {\n    @Input() kitTooltip = '';\n    @Input() tooltipDescription = '';\n    @Input() tooltipTemplate?: TemplateRef<any>;\n    @Input() tooltipPosition: 'top' | 'bottom' | 'left' | 'right' = 'top';\n    @Input() tooltipOffset = 8;\n    @Input() tooltipDelay = 100;\n  \n    private tooltipRef?: ComponentRef<TooltipContentComponent>;\n    private showTimeoutId?: number;\n    private hideTimeoutId?: number;\n    private viewContainerRef = inject(ViewContainerRef);\n    private document = inject(DOCUMENT);\n  \n    constructor(private elementRef: ElementRef) {}\n  \n    @HostListener('mouseenter')\n    onMouseEnter(): void {\n        this.clearTimeouts();\n        \n        this.showTimeoutId = window.setTimeout(() => {\n            this.show();\n        }, this.tooltipDelay);\n    }\n      \n    @HostListener('mouseleave')\n    onMouseLeave(): void {\n        this.clearTimeouts();\n        \n        if (this.tooltipRef) {\n            this.hideTimeoutId = window.setTimeout(() => {\n                this.hide();\n            }, 100);\n        }\n    }\n    \n    private show(): void {\n        if (this.tooltipRef) {\n            return;\n        }\n      \n        // Create tooltip component\n        this.tooltipRef = this.viewContainerRef.createComponent(TooltipContentComponent);\n        \n        // Set inputs\n        this.tooltipRef.instance.title = this.kitTooltip;\n        this.tooltipRef.instance.description = this.tooltipDescription;\n        this.tooltipRef.instance.templateRef = this.tooltipTemplate;\n        this.tooltipRef.instance.positionType = this.tooltipPosition;\n        this.tooltipRef.instance.offset = this.tooltipOffset;\n        \n        // Append to body to avoid clipping issues\n        this.document.body.appendChild(this.tooltipRef.location.nativeElement);\n        \n        // Calculate position and show\n        const rect = this.elementRef.nativeElement.getBoundingClientRect();\n        let x = rect.left + rect.width / 2;\n        let y = 0;\n        \n        switch (this.tooltipPosition) {\n            case 'top':\n                y = rect.top;\n                break;\n            case 'bottom':\n                y = rect.bottom;\n                break;\n            case 'left':\n            case 'right':\n                y = rect.top + rect.height / 2;\n                break;\n        }\n        \n        if (this.tooltipPosition === 'left') {\n            x = rect.left;\n        } else if (this.tooltipPosition === 'right') {\n            x = rect.right;\n        }\n        \n        // Give the browser a chance to render before calculating position\n        setTimeout(() => {\n            this.tooltipRef?.instance.show(x, y, this.tooltipPosition);\n        });\n    }\n    \n    private hide(): void {\n        if (this.tooltipRef) {\n            this.tooltipRef.instance.hide();\n          \n            setTimeout(() => {\n                this.tooltipRef?.destroy();\n                this.tooltipRef = undefined;\n            }, 150);\n        }\n    }\n    \n    private clearTimeouts(): void {\n        if (this.showTimeoutId) {\n            clearTimeout(this.showTimeoutId);\n            this.showTimeoutId = undefined;\n        }\n        \n        if (this.hideTimeoutId) {\n            clearTimeout(this.hideTimeoutId);\n            this.hideTimeoutId = undefined;\n        }\n    }\n    \n    ngOnDestroy(): void {\n        this.clearTimeouts();\n        \n        if (this.tooltipRef) {\n            this.tooltipRef.destroy();\n        }\n    }\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { TooltipContentComponent } from './tooltip-content.component';\nimport { TooltipDirective } from './directive/tooltip.directive';\n@NgModule({\n    imports: [\n        CommonModule,\n\n    ],\n    declarations: [\n        TooltipContentComponent,\n        TooltipDirective\n    ],\n    exports:[\n        TooltipDirective\n    ],\n    \n})\nexport class KifTooltipModule { }\n","/*\n * Public API Surface of kif-lib-input\n */\n\nexport * from './tooltip-content.component';\nexport * from './tooltip.module';\nexport * from './directive/tooltip.directive';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAQa,uBAAuB,CAAA;AAchC,IAAA,IAAI,CAAC,CAAS,EAAE,CAAS,EAAE,QAAiB,EAAA;AACxC,QAAA,IAAI,QAAQ,EAAE;AACV,YAAA,IAAI,CAAC,YAAY,GAAG,QAAQ;AAC/B,QAAA;AAED,QAAA,IAAI,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC;AAC5B,QAAA,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;IAC/B;IAEA,IAAI,GAAA;AACA,QAAA,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC;IAChC;IAEQ,iBAAiB,CAAC,CAAS,EAAE,CAAS,EAAA;QAC1C,IAAI,GAAG,GAAG,CAAC;QACX,IAAI,IAAI,GAAG,CAAC;;AAGZ,QAAA,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,oBAAoB,CAAC;AACxF,QAAA,MAAM,aAAa,GAAG,cAAc,CAAC,YAAY;AACjD,QAAA,MAAM,YAAY,GAAG,cAAc,CAAC,WAAW;QAE/C,QAAQ,IAAI,CAAC,YAAY;AACrB,YAAA,KAAK,KAAK;gBACN,GAAG,GAAG,CAAC,GAAG,aAAa,GAAG,IAAI,CAAC,MAAM;gBACrC,IAAI,GAAG,CAAC,IAAI,YAAY,GAAG,CAAC,CAAC;gBAC7B;AACJ,YAAA,KAAK,Q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