{"version":3,"sources":["../../src/app/components/overlaypanel/overlaypanel.ts"],"names":["OverlayPanel","el","renderer","cd","zone","this","dismissable","autoZIndex","baseZIndex","focusOnShow","showTransitionOptions","hideTransitionOptions","onShow","EventEmitter","onHide","overlayVisible","render","isContainerClicked","prototype","ngAfterContentInit","_this","templates","forEach","item","getType","contentTemplate","template","markForCheck","onContainerClick","bindDocumentClickListener","documentClickListener","runOutsideAngular","documentEvent","DomHandler","isIOS","documentTarget","nativeElement","ownerDocument","listen","event","container","contains","target","run","hide","unbindDocumentClickListener","toggle","hasTargetChanged","destroyCallback","show","currentTarget","appendContainer","appendTo","document","body","appendChild","restoreAppend","align","style","zIndex","String","zindex","absolutePosition","containerOffset","getOffset","targetOffset","arrowLeft","left","setProperty","top","addClass","onAnimationStart","toState","element","emit","bindDocumentResizeListener","bindScrollListener","focus","onAnimationEnd","onContainerDestroy","focusable","findSingle","setTimeout","onCloseClick","preventDefault","onWindowResize","documentResizeListener","bind","window","addEventListener","unbindDocumentResizeListener","removeEventListener","scrollHandler","ConnectedOverlayScrollHandler","unbindScrollListener","ngOnDestroy","destroy","Component","args","selector","animations","trigger","state","transform","opacity","transition","animate","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ElementRef","Renderer2","ChangeDetectorRef","NgZone","Input","Output","ContentChildren","PrimeTemplate","NgModule","imports","CommonModule","RippleModule","exports","declarations"],"mappings":"6pBAgGI,SAAAA,EAAmBC,EAAuBC,EAA4BC,EAA+BC,GAAlFC,KAAAJ,GAAAA,EAAuBI,KAAAH,SAAAA,EAA4BG,KAAAF,GAAAA,EAA+BE,KAAAD,KAAAA,EAlD5FC,KAAAC,aAAuB,EAUvBD,KAAAE,YAAsB,EAItBF,KAAAG,WAAqB,EAErBH,KAAAI,aAAuB,EAEvBJ,KAAAK,sBAAgC,kCAEhCL,KAAAM,sBAAgC,aAE/BN,KAAAO,OAA4B,IAAIC,EAAAA,aAEhCR,KAAAS,OAA4B,IAAID,EAAA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rF,KAAKyF,wBAGT9F,EAAAkB,UAAA6E,YAAA,WACQ1F,KAAKuF,gBACLvF,KAAKuF,cAAcI,UACnB3F,KAAKuF,cAAgB,MAGzBvF,KAAKqC,OAAS,KACdrC,KAAK2C,gBAAkB,KACnB3C,KAAKmC,YACLnC,KAAKmD,gBACLnD,KAAK0E,gDA7ShBkB,EAAAA,UAASC,KAAA,CAAC,CACPC,SAAU,iBACVzE,SAAU,y6BAaV0E,WAAY,CACRC,EAAAA,QAAQ,YAAa,CACjBC,EAAAA,MAAM,OAAQ5C,EAAAA,MAAM,CAChB6C,UAAW,cACXC,QAAS,KAEbF,EAAAA,MAAM,QAAS5C,EAAAA,MAAM,CACjB8C,QAAS,KAEbF,EAAAA,MAAM,OAAQ5C,EAAAA,MAAM,CAChB6C,UAAW,gBACXC,QAAS,KAEbC,EAAAA,WAAW,eAAgBC,EAAAA,QAAQ,6BACnCD,EAAAA,WAAW,gBAAiBC,EAAAA,QAAQ,gCAG5CC,gBAAiBC,EAAAA,wBAAwBC,OACzCC,cAAeC,EAAAA,kBAAkBC,w2BAzCoCC,EAAAA,kBAAVC,EAAAA,iBAAqBC,EAAAA,yBAAkBC,EAAAA,+CA8CjGC,EAAAA,6BAEAA,EAAAA,qBAEAA,EAAAA,0BAEAA,EAAAA,wBAEAA,EAAAA,0BAEAA,EAAAA,8BAEAA,EAAAA,0BAEAA,EAAAA,2BAEAA,EAAAA,qCAEAA,EAAAA,qCAEAA,EAAAA,sBAEAC,EAAAA,uBAEAA,EAAAA,0BAEAC,EAAAA,gBAAerB,KAAA,CAACsB,EAAAA,wBAuPrB,iCALCC,EAAAA,SAAQvB,KAAA,CAAC,CACNwB,QAAS,CAACC,EAAAA,aAAaC,EAAAA,cACvBC,QAAS,CAAC7H,GACV8H,aAAc,CAAC9H","sourcesContent":["import {NgModule,Component,Input,Output,OnDestroy,EventEmitter,Renderer2,ElementRef,ChangeDetectorRef,NgZone,\n ContentChildren,TemplateRef,AfterContentInit,QueryList,ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {DomHandler, ConnectedOverlayScrollHandler} from 'primeng/dom';\nimport {PrimeTemplate} from 'primeng/api';\nimport {RippleModule} from 'primeng/ripple';\nimport {trigger,state,style,transition,animate,AnimationEvent} from '@angular/animations';\n\n@Component({\n selector: 'p-overlayPanel',\n template: `\n
\n
\n \n \n
\n \n
\n `,\n animations: [\n trigger('animation', [\n state('void', style({\n transform: 'scaleY(0.8)',\n opacity: 0\n })),\n state('close', style({\n opacity: 0\n })),\n state('open', style({\n transform: 'translateY(0)',\n opacity: 1\n })),\n transition('void => open', animate('{{showTransitionParams}}')),\n transition('open => close', animate('{{hideTransitionParams}}')),\n ])\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./overlaypanel.css']\n})\nexport class OverlayPanel implements AfterContentInit, OnDestroy {\n\n @Input() dismissable: boolean = true;\n\n @Input() showCloseIcon: boolean;\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() appendTo: any;\n\n @Input() autoZIndex: boolean = true;\n\n @Input() ariaCloseLabel: string;\n\n @Input() baseZIndex: number = 0;\n\n @Input() focusOnShow: boolean = true;\n\n @Input() showTransitionOptions: string = '.12s cubic-bezier(0, 0, 0.2, 1)';\n\n @Input() hideTransitionOptions: string = '.1s linear';\n\n @Output() onShow: EventEmitter = new EventEmitter();\n\n @Output() onHide: EventEmitter = new EventEmitter();\n\n @ContentChildren(PrimeTemplate) templates: QueryList;\n\n container: HTMLDivElement;\n\n overlayVisible: boolean = false;\n\n render: boolean = false;\n\n isContainerClicked: boolean = true;\n\n documentClickListener: any;\n\n target: any;\n\n willHide: boolean;\n\n scrollHandler: any;\n\n documentResizeListener: any;\n\n contentTemplate: TemplateRef;\n\n destroyCallback: Function;\n\n constructor(public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, private zone: NgZone) {}\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'content':\n this.contentTemplate = item.template;\n break;\n\n default:\n this.contentTemplate = item.template;\n break;\n }\n\n this.cd.markForCheck();\n });\n }\n\n onContainerClick() {\n this.isContainerClicked = true;\n }\n\n bindDocumentClickListener() {\n if (!this.documentClickListener && this.dismissable) {\n this.zone.runOutsideAngular(() => {\n let documentEvent = DomHandler.isIOS() ? 'touchstart' : 'click';\n const documentTarget: any = this.el ? this.el.nativeElement.ownerDocument : 'document';\n\n this.documentClickListener = this.renderer.listen(documentTarget, documentEvent, (event) => {\n if (!this.container.contains(event.target) && this.target !== event.target && !this.target.contains(event.target) && !this.isContainerClicked) {\n this.zone.run(() => {\n this.hide();\n });\n }\n\n this.isContainerClicked = false;\n this.cd.markForCheck();\n });\n });\n }\n }\n\n unbindDocumentClickListener() {\n if (this.documentClickListener) {\n this.documentClickListener();\n this.documentClickListener = null;\n }\n }\n\n toggle(event, target?) {\n if (this.overlayVisible) {\n if (this.hasTargetChanged(event, target)) {\n this.destroyCallback = () => {\n this.show(null, (target||event.currentTarget||event.target));\n };\n }\n\n this.hide();\n }\n else {\n this.show(event, target);\n }\n }\n\n show(event, target?) {\n this.target = target||event.currentTarget||event.target;\n this.overlayVisible = true;\n this.render = true;\n this.cd.markForCheck();\n }\n\n hasTargetChanged(event, target) {\n return this.target != null && this.target !== (target||event.currentTarget||event.target);\n }\n\n appendContainer() {\n if (this.appendTo) {\n if (this.appendTo === 'body')\n document.body.appendChild(this.container);\n else\n DomHandler.appendChild(this.container, this.appendTo);\n }\n }\n\n restoreAppend() {\n if (this.container && this.appendTo) {\n this.el.nativeElement.appendChild(this.container);\n }\n }\n\n align() {\n if (this.autoZIndex) {\n this.container.style.zIndex = String(this.baseZIndex + (++DomHandler.zindex));\n }\n DomHandler.absolutePosition(this.container, this.target);\n\n const containerOffset = DomHandler.getOffset(this.container);\n const targetOffset = DomHandler.getOffset(this.target);\n let arrowLeft = 0;\n\n if (containerOffset.left < targetOffset.left) {\n arrowLeft = targetOffset.left - containerOffset.left;\n }\n this.container.style.setProperty('--overlayArrowLeft', `${arrowLeft}px`);\n\n if (containerOffset.top < targetOffset.top) {\n DomHandler.addClass(this.container, 'p-overlaypanel-flipped');\n }\n }\n\n onAnimationStart(event: AnimationEvent) {\n if (event.toState === 'open') {\n this.container = event.element;\n this.onShow.emit(null);\n this.appendContainer();\n this.align();\n this.bindDocumentClickListener();\n this.bindDocumentResizeListener();\n this.bindScrollListener();\n\n if (this.focusOnShow) {\n this.focus();\n }\n }\n }\n\n onAnimationEnd(event: AnimationEvent) {\n switch (event.toState) {\n case 'void':\n if (this.destroyCallback) {\n this.destroyCallback();\n this.destroyCallback = null;\n }\n break;\n\n case 'close':\n this.onContainerDestroy();\n this.onHide.emit({});\n this.render = false;\n break;\n }\n }\n\n focus() {\n let focusable = DomHandler.findSingle(this.container, '[autofocus]');\n if (focusable) {\n this.zone.runOutsideAngular(() => {\n setTimeout(() => focusable.focus(), 5);\n });\n }\n }\n\n hide() {\n this.overlayVisible = false;\n this.cd.markForCheck();\n }\n\n onCloseClick(event) {\n this.hide();\n event.preventDefault();\n }\n\n onWindowResize(event) {\n this.hide();\n }\n\n bindDocumentResizeListener() {\n this.documentResizeListener = this.onWindowResize.bind(this);\n window.addEventListener('resize', this.documentResizeListener);\n }\n\n unbindDocumentResizeListener() {\n if (this.documentResizeListener) {\n window.removeEventListener('resize', this.documentResizeListener);\n this.documentResizeListener = null;\n }\n }\n\n bindScrollListener() {\n if (!this.scrollHandler) {\n this.scrollHandler = new ConnectedOverlayScrollHandler(this.target, () => {\n if (this.overlayVisible) {\n this.hide();\n }\n });\n }\n\n this.scrollHandler.bindScrollListener();\n }\n\n unbindScrollListener() {\n if (this.scrollHandler) {\n this.scrollHandler.unbindScrollListener();\n }\n }\n\n onContainerDestroy() {\n this.target = null;\n this.unbindDocumentClickListener();\n this.unbindDocumentResizeListener();\n this.unbindScrollListener();\n }\n\n ngOnDestroy() {\n if (this.scrollHandler) {\n this.scrollHandler.destroy();\n this.scrollHandler = null;\n }\n\n this.target = null;\n this.destroyCallback = null;\n if (this.container) {\n this.restoreAppend();\n this.onContainerDestroy();\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule,RippleModule],\n exports: [OverlayPanel],\n declarations: [OverlayPanel]\n})\nexport class OverlayPanelModule { }\n"]}