{"version":3,"sources":["../../src/app/components/confirmpopup/confirmpopup.ts"],"names":["ConfirmPopup","el","confirmationService","renderer","cd","config","_this","this","showTransitionOptions","hideTransitionOptions","autoZIndex","baseZIndex","subscription","requireConfirmation$","subscribe","confirmation","key","accept","acceptEvent","EventEmitter","reject","rejectEvent","visible","hide","Object","defineProperty","prototype","_visible","value","markForCheck","onAnimationStart","event","toState","container","element","document","body","appendChild","align","bindListeners","onAnimationEnd","onContainerDestroy","style","zIndex","String","DomHandler","zindex","absolutePosition","target","containerOffset","getOffset","targetOffset","arrowLeft","left","setProperty","top","addClass","emit","bindDocumentClickListener","bindDocumentResizeListener","bindScrollListener","unbindListeners","unbindDocumentClickListener","unbindDocumentResizeListener","unbindScrollListener","documentClickListener","documentEvent","isIOS","documentTarget","nativeElement","ownerDocument","listen","targetElement","contains","onWindowResize","documentResizeListener","bind","window","addEventListener","removeEventListener","scrollHandler","ConnectedOverlayScrollHandler","unsubscribeConfirmationSubscriptions","unsubscribe","acceptLabel","getTranslation","TranslationKeys","ACCEPT","rejectLabel","REJECT","ngOnDestroy","Component","args","selector","template","animations","trigger","state","transform","opacity","transition","animate","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ElementRef","ConfirmationService","Renderer2","ChangeDetectorRef","PrimeNGConfig","Input","NgModule","imports","CommonModule","ButtonModule","exports","declarations"],"mappings":"6pBAkFI,SAAAA,EAAmBC,EAAwBC,EAAiDC,EAA6BC,EAA8BC,GAAvJ,IAAAC,EAAAC,KAAmBA,KAAAN,GAAAA,EAAwBM,KAAAL,oBAAAA,EAAiDK,KAAAJ,SAAAA,EAA6BI,KAAAH,GAAAA,EAA8BG,KAAAF,OAAAA,EAlC9IE,KAAAC,sBAAgC,kCAEhCD,KAAAE,sBAAgC,aAEhCF,KAAAG,YAAsB,EAEtBH,KAAAI,WAAqB,EA6B1BJ,KAAKK,aAAeL,KAAKL,oBAAoBW,qBAAqBC,WAAU,SAAAC,GACnEA,EAKDA,EA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G3CC,gBAAiBC,EAAAA,wBAAwBC,OACzCC,cAAeC,EAAAA,kBAAkBC,0uBAzCoCC,EAAAA,kBAEnDC,EAAAA,2BAFkHC,EAAAA,iBAAnDC,EAAAA,yBAE1CC,EAAAA,8CA4CtCC,EAAAA,qCAEAA,EAAAA,qCAEAA,EAAAA,0BAEAA,EAAAA,0BAEAA,EAAAA,qBAEAA,EAAAA,0BAEAA,EAAAA,uBAgBAA,EAAAA,eAuML,iCALCC,EAAAA,SAAQtB,KAAA,CAAC,CACNuB,QAAS,CAACC,EAAAA,aAAaC,EAAAA,cACvBC,QAAS,CAACtH,GACVuH,aAAc,CAACvH","sourcesContent":["import {NgModule ,Component, ChangeDetectionStrategy, ViewEncapsulation, ElementRef, ChangeDetectorRef, OnDestroy, Input, EventEmitter, Renderer2} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {Confirmation, ConfirmationService, PrimeNGConfig, TranslationKeys} from 'primeng/api';\nimport {Subscription} from 'rxjs';\nimport {ButtonModule} from 'primeng/button';\nimport {trigger,state,style,transition,animate,AnimationEvent} from '@angular/animations';\nimport {DomHandler, ConnectedOverlayScrollHandler} from 'primeng/dom';\n\n@Component({\n selector: 'p-confirmPopup',\n template: `\n
\n
\n \n {{confirmation.message}}\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('open', style({\n transform: 'translateY(0)',\n opacity: 1\n })),\n transition('void => open', animate('{{showTransitionParams}}')),\n transition('open => void', animate('{{hideTransitionParams}}')),\n ])\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./confirmpopup.css']\n})\nexport class ConfirmPopup implements OnDestroy {\n\n @Input() key: string;\n\n @Input() showTransitionOptions: string = '.12s cubic-bezier(0, 0, 0.2, 1)';\n\n @Input() hideTransitionOptions: string = '.1s linear';\n\n @Input() autoZIndex: boolean = true;\n\n @Input() baseZIndex: number = 0;\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n container: HTMLDivElement;\n\n subscription: Subscription;\n\n confirmation: Confirmation;\n\n _visible: boolean;\n\n documentClickListener: any;\n\n documentResizeListener: any;\n\n scrollHandler: any;\n\n @Input() get visible(): any {\n return this._visible;\n }\n set visible(value:any) {\n this._visible = value;\n this.cd.markForCheck();\n }\n\n constructor(public el: ElementRef, private confirmationService: ConfirmationService, public renderer: Renderer2, private cd: ChangeDetectorRef, public config: PrimeNGConfig) {\n this.subscription = this.confirmationService.requireConfirmation$.subscribe(confirmation => {\n if (!confirmation) {\n this.hide();\n return;\n }\n\n if (confirmation.key === this.key) {\n this.confirmation = confirmation;\n if (this.confirmation.accept) {\n this.confirmation.acceptEvent = new EventEmitter();\n this.confirmation.acceptEvent.subscribe(this.confirmation.accept);\n }\n\n if (this.confirmation.reject) {\n this.confirmation.rejectEvent = new EventEmitter();\n this.confirmation.rejectEvent.subscribe(this.confirmation.reject);\n }\n\n this.visible = true;\n }\n });\n }\n\n onAnimationStart(event: AnimationEvent) {\n if (event.toState === 'open') {\n this.container = event.element;\n document.body.appendChild(this.container);\n this.align();\n this.bindListeners();\n }\n }\n\n onAnimationEnd(event: AnimationEvent) {\n switch (event.toState) {\n case 'void':\n this.onContainerDestroy();\n break;\n }\n }\n\n align() {\n if (this.autoZIndex) {\n this.container.style.zIndex = String(this.baseZIndex + (++DomHandler.zindex));\n }\n\n DomHandler.absolutePosition(this.container, this.confirmation.target);\n\n const containerOffset = DomHandler.getOffset(this.container);\n const targetOffset = DomHandler.getOffset(this.confirmation.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-confirm-popup-flipped');\n }\n }\n\n hide() {\n this.visible = false;\n }\n\n accept() {\n if (this.confirmation.acceptEvent) {\n this.confirmation.acceptEvent.emit();\n }\n\n this.hide();\n }\n\n reject() {\n if (this.confirmation.rejectEvent) {\n this.confirmation.rejectEvent.emit();\n }\n\n this.hide();\n }\n\n bindListeners() {\n this.bindDocumentClickListener();\n this.bindDocumentResizeListener();\n this.bindScrollListener();\n }\n\n unbindListeners() {\n this.unbindDocumentClickListener();\n this.unbindDocumentResizeListener();\n this.unbindScrollListener();\n }\n\n bindDocumentClickListener() {\n if (!this.documentClickListener) {\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 let targetElement = this.confirmation.target;\n if (this.container !== event.target && !this.container.contains(event.target) &&\n targetElement !== event.target && !targetElement.contains(event.target)) {\n this.hide();\n }\n });\n }\n }\n\n unbindDocumentClickListener() {\n if (this.documentClickListener) {\n this.documentClickListener();\n this.documentClickListener = null;\n }\n }\n\n onWindowResize() {\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.confirmation.target, () => {\n if (this.visible) {\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 unsubscribeConfirmationSubscriptions() {\n if (this.confirmation) {\n if (this.confirmation.acceptEvent) {\n this.confirmation.acceptEvent.unsubscribe();\n }\n\n if (this.confirmation.rejectEvent) {\n this.confirmation.rejectEvent.unsubscribe();\n }\n }\n }\n\n onContainerDestroy() {\n this.unbindListeners();\n this.unsubscribeConfirmationSubscriptions();\n this.confirmation = null;\n this.container = null;\n }\n\n get acceptButtonLabel(): string {\n return this.confirmation.acceptLabel || this.config.getTranslation(TranslationKeys.ACCEPT);\n }\n\n get rejectButtonLabel(): string {\n return this.confirmation.rejectLabel || this.config.getTranslation(TranslationKeys.REJECT);\n }\n\n ngOnDestroy() {\n this.onContainerDestroy();\n\n if (this.subscription) {\n this.subscription.unsubscribe();\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule,ButtonModule],\n exports: [ConfirmPopup],\n declarations: [ConfirmPopup]\n})\nexport class ConfirmPopupModule { }\n"]}