1 | {"version":3,"file":"primeng-styleclass.mjs","sources":["../../src/app/components/styleclass/styleclass.ts","../../src/app/components/styleclass/primeng-styleclass.ts"],"sourcesContent":["import { CommonModule} from '@angular/common';\nimport { NgModule, Directive, ElementRef, Input, Renderer2, OnDestroy, AfterViewInit } from '@angular/core';\nimport { DomHandler } from 'primeng/dom';\n\n@Directive({\n selector: '[pStyleClass]',\n host: {\n 'class': 'p-element'\n }\n})\nexport class StyleClass implements AfterViewInit, OnDestroy {\n\n constructor(public el: ElementRef, public renderer: Renderer2) {}\n\n @Input('pStyleClass') selector: string;\n\n @Input() enterClass: string;\n\n @Input() enterActiveClass: string;\n\n @Input() enterToClass: string;\n\n @Input() leaveClass: string;\n\n @Input() leaveActiveClass: string;\n\n @Input() leaveToClass: string;\n\n @Input() hideOnOutsideClick: boolean;\n\n @Input() toggleClass: string;\n\n eventListener: Function;\n\n documentListener: Function;\n\n target: HTMLElement;\n\n enterListener: Function;\n\n leaveListener: Function;\n\n animating: boolean;\n\n ngAfterViewInit() {\n this.eventListener = this.renderer.listen(this.el.nativeElement, 'click', () => {\n this.target = this.resolveTarget();\n\n if (this.toggleClass) {\n if (DomHandler.hasClass(this.target, this.toggleClass))\n DomHandler.removeClass(this.target, this.toggleClass);\n else\n DomHandler.addClass(this.target, this.toggleClass);\n }\n else {\n if (this.target.offsetParent === null)\n this.enter();\n else\n this.leave();\n }\n });\n }\n\n enter() {\n if (this.enterActiveClass) {\n if (!this.animating) {\n this.animating = true;\n\n if (this.enterActiveClass === 'slidedown') {\n this.target.style.height = '0px';\n DomHandler.removeClass(this.target, 'hidden');\n this.target.style.maxHeight = this.target.scrollHeight + 'px';\n DomHandler.addClass(this.target, 'hidden');\n this.target.style.height = '';\n }\n\n DomHandler.addClass(this.target, this.enterActiveClass);\n if (this.enterClass) {\n DomHandler.removeClass(this.target, this.enterClass);\n }\n\n this.enterListener = this.renderer.listen(this.target, 'animationend', () => {\n DomHandler.removeClass(this.target, this.enterActiveClass);\n if (this.enterToClass) {\n DomHandler.addClass(this.target, this.enterToClass);\n }\n this.enterListener();\n\n if (this.enterActiveClass === 'slidedown') {\n this.target.style.maxHeight = '';\n }\n this.animating = false;\n });\n }\n }\n else {\n if (this.enterClass) {\n DomHandler.removeClass(this.target, this.enterClass);\n }\n\n if (this.enterToClass) {\n DomHandler.addClass(this.target, this.enterToClass);\n }\n }\n\n if (this.hideOnOutsideClick) {\n this.bindDocumentListener();\n }\n }\n\n leave() {\n if (this.leaveActiveClass) {\n if (!this.animating) {\n this.animating = true;\n DomHandler.addClass(this.target, this.leaveActiveClass);\n if (this.leaveClass) {\n DomHandler.removeClass(this.target, this.leaveClass);\n }\n\n this.leaveListener = this.renderer.listen(this.target, 'animationend', () => {\n DomHandler.removeClass(this.target, this.leaveActiveClass);\n if (this.leaveToClass) {\n DomHandler.addClass(this.target, this.leaveToClass);\n }\n this.leaveListener();\n this.animating = false;\n });\n }\n }\n else {\n if (this.leaveClass) {\n DomHandler.removeClass(this.target, this.leaveClass);\n }\n\n if (this.leaveToClass) {\n DomHandler.addClass(this.target, this.leaveToClass);\n }\n }\n\n if (this.hideOnOutsideClick) {\n this.unbindDocumentListener();\n }\n }\n\n resolveTarget() {\n if (this.target) {\n return this.target;\n }\n\n switch (this.selector) {\n case '@next':\n return this.el.nativeElement.nextElementSibling;\n\n case '@prev':\n return this.el.nativeElement.previousElementSibling;\n\n case '@parent':\n return this.el.nativeElement.parentElement;\n\n case '@grandparent':\n return this.el.nativeElement.parentElement.parentElement;\n\n default:\n return document.querySelector(this.selector);\n }\n }\n\n bindDocumentListener() {\n if (!this.documentListener) {\n this.documentListener = this.renderer.listen(this.el.nativeElement.ownerDocument, 'click', event => {\n if (getComputedStyle(this.target).getPropertyValue('position') === 'static') {\n this.unbindDocumentListener();\n }\n else if (!this.el.nativeElement.isSameNode(event.target) && !this.el.nativeElement.contains(event.target) && !this.target.contains(event.target)) {\n this.leave();\n }\n });\n }\n }\n\n unbindDocumentListener() {\n if (this.documentListener) {\n this.documentListener();\n this.documentListener = null;\n }\n }\n\n ngOnDestroy() {\n this.target = null;\n if (this.eventListener) {\n this.eventListener();\n }\n this.unbindDocumentListener();\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [StyleClass],\n declarations: [StyleClass]\n})\nexport class StyleClassModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;MAUa,UAAU;IAEnB,YAAmB,EAAc,EAAS,QAAmB;QAA1C,OAAE,GAAF,EAAE,CAAY;QAAS,aAAQ,GAAR,QAAQ,CAAW;KAAI;IAgCjE,eAAe;QACX,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE;YACtE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YAEnC,IAAI,IAAI,CAAC,WAAW,EAAE;gBAClB,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC;oBAClD,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;;oBAEtD,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;aAC1D;iBACI;gBACD,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,KAAK,IAAI;oBACjC,IAAI,CAAC,KAAK,EAAE,CAAC;;oBAEb,IAAI,CAAC,KAAK,EAAE,CAAC;aACpB;SACJ,CAAC,CAAC;KACN;IAED,KAAK;QACD,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACvB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACjB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBAEtB,IAAI,IAAI,CAAC,gBAAgB,KAAK,WAAW,EAAE;oBACvC,IAAI,CA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