import { Directive, HostListener, Input } from '@angular/core';
import * as i0 from "@angular/core";
export class DropdownDirective {
    constructor(
    //private element: ElementRef,
    renderer) {
        this.renderer = renderer;
        this.targetId = '';
        this.isVisible = false;
    }
    onBlur() {
        this.close(document.getElementById(this.targetId));
    }
    onClick() {
        this.toggle(document.getElementById(this.targetId));
    }
    toggle(element) {
        this.isVisible = !this.isVisible;
        this.renderer.addClass(element, this.isVisible ? 'block' : 'hidden');
        this.renderer.removeClass(element, this.isVisible ? 'hidden' : 'block');
    }
    close(element) {
        this.isVisible = false;
        this.renderer.addClass(element, 'hidden');
        this.renderer.removeClass(element, 'block');
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: DropdownDirective, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.2", type: DropdownDirective, isStandalone: true, selector: "[ctDropdown]", inputs: { targetId: "targetId" }, host: { listeners: { "blur": "onBlur()", "focusout": "onBlur()", "click": "onClick()" } }, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: DropdownDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[ctDropdown]',
                    standalone: true,
                }]
        }], ctorParameters: () => [{ type: i0.Renderer2 }], propDecorators: { targetId: [{
                type: Input,
                args: [{ required: true }]
            }], onBlur: [{
                type: HostListener,
                args: ['blur']
            }, {
                type: HostListener,
                args: ['focusout']
            }], onClick: [{
                type: HostListener,
                args: ['click']
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZHJvcGRvd24uZGlyZWN0aXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvY2lyY2xldG9uZS9zcmMvbGliL2RpcmVjd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