{"version":3,"file":"primeng-confirmpopup.js","sources":["../../src/app/components/confirmpopup/confirmpopup.ts","../../src/app/components/confirmpopup/primeng-confirmpopup.ts"],"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 restoreAppend() {\n if (this.container) {\n document.body.removeChild(this.container);\n }\n\n this.onContainerDestroy();\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.restoreAppend();\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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;MA4Ca,YAAY;IAsCrB,YAAmB,EAAc,EAAU,mBAAwC,EAAS,QAAmB,EAAU,EAAqB,EAAS,MAAqB;QAAzJ,OAAE,GAAF,EAAE,CAAY;QAAU,wBAAmB,GAAnB,mBAAmB,CAAqB;QAAS,aAAQ,GAAR,QAAQ,CAAW;QAAU,OAAE,GAAF,EAAE,CAAmB;QAAS,WAAM,GAAN,MAAM,CAAe;QAlCnK,0BAAqB,GAAW,iCAAiC,CAAC;QAElE,0BAAqB,GAAW,YAAY,CAAC;QAE7C,eAAU,GAAY,IAAI,CAAC;QAE3B,eAAU,GAAW,CAAC,CAAC;QA6B5B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,SAAS,CAAC,YAAY;YACpF,IAAI,CAAC,YAAY,EAAE;gBACf,IAAI,CAAC,IAAI,EAAE,CAAC;gBACZ,OAAO;aACV;YAED,IAAI,YAAY,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,EAAE;gBAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;gBACjC,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;oBAC1B,IAAI,CAAC,YAAY,CAAC,WAAW,GAAG,IAAI,YAAY,EAAE,CAAC;oBACnD,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;iBACrE;gBAED,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;oBAC1B,IAAI,CAAC,YAAY,CAAC,WAAW,GAAG,IAAI,YAAY,EAAE,CAAC;oBACnD,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC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