{"version":3,"file":"primeng-confirmpopup.umd.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":["EventEmitter","DomHandler","ConnectedOverlayScrollHandler","TranslationKeys","Component","trigger","state","style","transition","animate","ChangeDetectionStrategy","ViewEncapsulation","ElementRef","ConfirmationService","Renderer2","ChangeDetectorRef","PrimeNGConfig","Input","NgModule","CommonModule","ButtonModule"],"mappings":";;;;;;;QAkFI,sBAAmB,EAAc,EAAU,mBAAwC,EAAS,QAAmB,EAAU,EAAqB,EAAS,MAAqB;YAA5K,iBAsBC;YAtBkB,OAAE,GAAF,EAAE,CAAY;YAAU,wBAAmB,GAAnB,mBAAmB,CAAqB;YAAS,aAAQ,GAAR,QAAQ,CAAW;YAAU,OAAE,GAAF,EAAE,CAAmB;YAAS,WAAM,GAAN,MAAM,CAAe;YAlCnK,0BAAqB,GAAW,iCAAiC,CAAC;YAElE,0BAAqB,GAAW,YAAY,CAAC;YAE7C,eAAU,GAAY,IAAI,CAAC;YAE3B,eAAU,GAAW,CAAC,CAAC;YA6B5B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,SAAS,CAAC,UAAA,YAAY;gBACpF,IAAI,CAAC,YAAY,EAAE;oBACf,KAAI,CAAC,IAAI,EAAE,CAAC;oBACZ,OAAO;iBACV;gBAED,IAAI,YAAY,CAAC,GAAG,KAAK,KAAI,CAAC,GAAG,EAAE;oBAC/B,KAAI,CAAC,YAAY,GAAG,YAAY,CAAC;oBACjC,IAAI,KAAI,CAAC,YAAY,CAAC,MAAM,EAAE;wBAC1B,KAAI,CAAC,YAAY,CAAC,WAAW,GAAG,IAAIA,iBAAY,EAAE,CAAC;wBACnD,KAAI,CAAC,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,KAAI,CAAC,YAAY,CAAC,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