{"version":3,"sources":["../../src/app/components/confirmdialog/confirmdialog.ts"],"names":["showAnimation","animation","style","transform","opacity","animate","hideAnimation","ConfirmDialog","el","renderer","confirmationService","zone","cd","config","_this","this","acceptIcon","acceptVisible","rejectIcon","rejectVisible","closeOnEscape","blockScroll","closable","autoZIndex","baseZIndex","transitionOptions","focusTrap","defaultFocus","_position","transformOptions","subscription","requireConfirmation$","subscribe","confirmation","key","confirmationOptions","message","icon","header","acceptLabel","rejectLabel","acceptButtonStyleClass","rejectButtonStyleClass","dismissableMask","accept","acceptEvent","EventEmitter","reject","rejectEvent","visible","hide","Object","defineProperty","prototype","_visible","value","maskVisible","markForCheck","ngAfterContentInit","templates","forEach","item","getType","footerTemplate","template","option","name","source","hasOwnProperty","onAnimationStart","event","toState","container","element","wrapper","parentElement","contentContainer","DomHandler","findSingle","getElementToFocus","focus","appendContainer","moveOnTop","bindGlobalListeners","enableModality","onAnimationEnd","onOverlayHide","appendTo","document","body","appendChild","restoreAppend","nativeElement","addClass","maskClickListener","listen","isSameNode","target","close","disableModality","removeClass","unbindMaskClickListener","detectChanges","emit","preventDefault","zIndex","String","zindex","getMaskClass","maskClass","p-dialog-mask p-component-overlay","p-dialog-mask-scrollblocker","getPositionClass","toString","pos","find","position","documentEscapeListener","documentTarget","ownerDocument","which","parseInt","focusableElements","getFocusableElements","length","activeElement","focusedIndex","indexOf","shiftKey","unbindGlobalListeners","ngOnDestroy","unsubscribe","getTranslation","TranslationKeys","ACCEPT","REJECT","Component","args","selector","animations","trigger","transition","useAnimation","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ElementRef","Renderer2","ConfirmationService","NgZone","ChangeDetectorRef","PrimeNGConfig","Input","ContentChild","Footer","ViewChild","ContentChildren","PrimeTemplate","NgModule","imports","CommonModule","ButtonModule","exports","SharedModule","declarations"],"mappings":"8oBAUA,IAAMA,EAAgBC,EAAAA,UAAU,CAC5BC,EAAAA,MAAM,CAAEC,UAAW,gBAAiBC,QA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BAAwBC,OACzCC,cAAeC,EAAAA,kBAAkBC,i5DA3DVC,EAAAA,kBAAwCC,EAAAA,iBAO3DC,EAAAA,2BAPkFC,EAAAA,cAAiBC,EAAAA,yBAI/DC,EAAAA,iDA4DvCC,EAAAA,oBAEAA,EAAAA,uBAEAA,EAAAA,qBAEAA,EAAAA,0BAEAA,EAAAA,8BAEAA,EAAAA,0BAEAA,EAAAA,2BAEAA,EAAAA,+BAEAA,EAAAA,6BAEAA,EAAAA,0BAEAA,EAAAA,2BAEAA,EAAAA,+BAEAA,EAAAA,6BAEAA,EAAAA,sCAEAA,EAAAA,sCAEAA,EAAAA,6BAEAA,EAAAA,+BAEAA,EAAAA,2BAEAA,EAAAA,mBAEAA,EAAAA,wBAEAA,EAAAA,wBAEAA,EAAAA,mBAEAA,EAAAA,0BAEAA,EAAAA,0BAEAA,EAAAA,iCAEAA,EAAAA,yBAEAA,EAAAA,4BAEAA,EAAAA,uBAEAA,EAAAA,wBAaAA,EAAAA,sBA8BAC,EAAAA,aAAYnB,KAAA,CAACoB,EAAAA,kCAEbC,EAAAA,UAASrB,KAAA,CAAC,8BAEVsB,EAAAA,gBAAetB,KAAA,CAACuB,EAAAA,wBA4TrB,iCALCC,EAAAA,SAAQxB,KAAA,CAAC,CACNyB,QAAS,CAACC,EAAAA,aAAaC,EAAAA,cACvBC,QAAS,CAAC9J,EAAc6J,EAAAA,aAAaE,EAAAA,cACrCC,aAAc,CAAChK","sourcesContent":["import {NgModule,Component,ElementRef,OnDestroy,Input,EventEmitter,Renderer2,ContentChild,NgZone,ViewChild,ChangeDetectorRef,ChangeDetectionStrategy, ViewEncapsulation, ContentChildren, QueryList, TemplateRef, AfterContentInit} from '@angular/core';\nimport {trigger,style,transition,animate,AnimationEvent, useAnimation, animation} from '@angular/animations';\nimport {CommonModule} from '@angular/common';\nimport {DomHandler} from 'primeng/dom';\nimport {Footer,SharedModule, PrimeTemplate, PrimeNGConfig, TranslationKeys} from 'primeng/api';\nimport {ButtonModule} from 'primeng/button';\nimport {Confirmation} from 'primeng/api';\nimport {ConfirmationService} from 'primeng/api';\nimport {Subscription} from 'rxjs';\n\nconst showAnimation = animation([\n style({ transform: '{{transform}}', opacity: 0 }),\n animate('{{transition}}', style({ transform: 'none', opacity: 1 }))\n]);\n\nconst hideAnimation = animation([\n animate('{{transition}}', style({ transform: '{{transform}}', opacity: 0 }))\n]);\n\n@Component({\n selector: 'p-confirmDialog',\n template: `\n
\n
\n
\n {{option('header')}}\n
\n \n
\n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n
\n `,\n animations: [\n trigger('animation', [\n transition('void => visible', [\n useAnimation(showAnimation)\n ]),\n transition('visible => void', [\n useAnimation(hideAnimation)\n ])\n ])\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['../dialog/dialog.css']\n})\nexport class ConfirmDialog implements AfterContentInit,OnDestroy {\n\n @Input() header: string;\n\n @Input() icon: string;\n\n @Input() message: string;\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() maskStyleClass: string;\n\n @Input() acceptIcon: string = 'pi pi-check';\n\n @Input() acceptLabel: string;\n\n @Input() acceptAriaLabel: string;\n\n @Input() acceptVisible: boolean = true;\n\n @Input() rejectIcon: string = 'pi pi-times';\n\n @Input() rejectLabel: string;\n\n @Input() rejectAriaLabel: string;\n\n @Input() rejectVisible: boolean = true;\n\n @Input() acceptButtonStyleClass: string;\n\n @Input() rejectButtonStyleClass: string;\n\n @Input() closeOnEscape: boolean = true;\n\n @Input() dismissableMask: boolean;\n\n @Input() blockScroll: boolean = true;\n\n @Input() rtl: boolean;\n\n @Input() closable: boolean = true;\n\n @Input() appendTo: any;\n\n @Input() key: string;\n\n @Input() autoZIndex: boolean = true;\n\n @Input() baseZIndex: number = 0;\n\n @Input() transitionOptions: string = '150ms cubic-bezier(0, 0, 0.2, 1)';\n\n @Input() focusTrap: boolean = true;\n\n @Input() defaultFocus: string = 'accept';\n\n @Input() get visible(): any {\n return this._visible;\n }\n set visible(value:any) {\n this._visible = value;\n\n if (this._visible && !this.maskVisible) {\n this.maskVisible = true;\n }\n\n this.cd.markForCheck();\n }\n\n @Input() get position(): string {\n return this._position;\n };\n\n set position(value: string) {\n this._position = value;\n\n switch (value) {\n case 'top-left':\n case 'bottom-left':\n case 'left':\n this.transformOptions = \"translate3d(-100%, 0px, 0px)\";\n break;\n case 'top-right':\n case 'bottom-right':\n case 'right':\n this.transformOptions = \"translate3d(100%, 0px, 0px)\";\n break;\n case 'bottom':\n this.transformOptions = \"translate3d(0px, 100%, 0px)\";\n break;\n case 'top':\n this.transformOptions = \"translate3d(0px, -100%, 0px)\";\n break;\n default:\n this.transformOptions = \"scale(0.7)\";\n break;\n }\n }\n\n @ContentChild(Footer) footer;\n\n @ViewChild('content') contentViewChild: ElementRef;\n\n @ContentChildren(PrimeTemplate) templates: QueryList;\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'footerTemplate':\n this.footerTemplate = item.template;\n break;\n }\n });\n }\n\n footerTemplate: TemplateRef;\n\n confirmation: Confirmation;\n\n _visible: boolean;\n\n maskVisible: boolean;\n\n documentEscapeListener: any;\n\n container: HTMLDivElement;\n\n wrapper: HTMLElement;\n\n contentContainer: HTMLDivElement;\n\n subscription: Subscription;\n\n maskClickListener: Function;\n\n preWidth: number;\n\n _position: string = \"center\";\n\n transformOptions: any = \"scale(0.7)\";\n\n confirmationOptions: Confirmation;\n\n constructor(public el: ElementRef, public renderer: Renderer2, private confirmationService: ConfirmationService, public zone: NgZone, 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 this.confirmationOptions = {\n message: this.confirmation.message||this.message,\n icon: this.confirmation.icon||this.icon,\n header: this.confirmation.header||this.header,\n rejectVisible: this.confirmation.rejectVisible == null ? this.rejectVisible : this.confirmation.rejectVisible,\n acceptVisible: this.confirmation.acceptVisible == null ? this.acceptVisible : this.confirmation.acceptVisible,\n acceptLabel: this.confirmation.acceptLabel||this.acceptLabel,\n rejectLabel: this.confirmation.rejectLabel||this.rejectLabel,\n acceptIcon: this.confirmation.acceptIcon || this.acceptIcon,\n rejectIcon: this.confirmation.rejectIcon || this.rejectIcon,\n acceptButtonStyleClass: this.confirmation.acceptButtonStyleClass || this.acceptButtonStyleClass,\n rejectButtonStyleClass: this.confirmation.rejectButtonStyleClass || this.rejectButtonStyleClass,\n defaultFocus: this.confirmation.defaultFocus || this.defaultFocus,\n blockScroll: (this.confirmation.blockScroll === false || this.confirmation.blockScroll === true) ? this.confirmation.blockScroll : this.blockScroll,\n closeOnEscape: (this.confirmation.closeOnEscape === false || this.confirmation.closeOnEscape === true) ? this.confirmation.closeOnEscape : this.closeOnEscape,\n dismissableMask: (this.confirmation.dismissableMask === false || this.confirmation.dismissableMask === true) ? this.confirmation.dismissableMask : this.dismissableMask\n };\n\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 option(name: string) {\n const source = this.confirmationOptions || this;\n if (source.hasOwnProperty(name)) {\n return source[name];\n }\n return undefined;\n }\n\n onAnimationStart(event: AnimationEvent) {\n switch(event.toState) {\n case 'visible':\n this.container = event.element;\n this.wrapper = this.container.parentElement;\n this.contentContainer = DomHandler.findSingle(this.container, '.p-dialog-content');\n\n const element = this.getElementToFocus();\n if (element) {\n element.focus();\n }\n\n this.appendContainer();\n this.moveOnTop();\n this.bindGlobalListeners();\n this.enableModality();\n break;\n }\n }\n\n onAnimationEnd(event: AnimationEvent) {\n switch(event.toState) {\n case 'void':\n this.onOverlayHide();\n break;\n }\n }\n\n getElementToFocus() {\n switch(this.option('defaultFocus')) {\n case 'accept':\n return DomHandler.findSingle(this.container, '.p-confirm-dialog-accept');\n\n case 'reject':\n return DomHandler.findSingle(this.container, '.p-confirm-dialog-reject');\n\n case 'close':\n return DomHandler.findSingle(this.container, '.p-dialog-header-close');\n\n case 'none':\n return null;\n\n //backward compatibility\n default:\n return DomHandler.findSingle(this.container, '.p-confirm-dialog-accept');\n }\n }\n\n appendContainer() {\n if (this.appendTo) {\n if (this.appendTo === 'body')\n document.body.appendChild(this.wrapper);\n else\n DomHandler.appendChild(this.wrapper, this.appendTo);\n }\n }\n\n restoreAppend() {\n if (this.wrapper && this.appendTo) {\n this.el.nativeElement.appendChild(this.wrapper);\n }\n }\n\n enableModality() {\n if (this.option('blockScroll')) {\n DomHandler.addClass(document.body, 'p-overflow-hidden');\n }\n\n if (this.option('dismissableMask')) {\n this.maskClickListener = this.renderer.listen(this.wrapper, 'mousedown', (event: any) => {\n if (this.wrapper && this.wrapper.isSameNode(event.target)) {\n this.close(event);\n }\n });\n }\n }\n\n disableModality() {\n this.maskVisible = false;\n\n if (this.option('blockScroll')) {\n DomHandler.removeClass(document.body, 'p-overflow-hidden');\n }\n\n if (this.dismissableMask) {\n this.unbindMaskClickListener();\n }\n\n if (this.container) {\n this.cd.detectChanges();\n }\n }\n\n close(event: Event) {\n if (this.confirmation.rejectEvent) {\n this.confirmation.rejectEvent.emit();\n }\n\n this.hide();\n event.preventDefault();\n }\n\n hide() {\n this.visible = false;\n this.confirmation = null;\n this.confirmationOptions = null;\n }\n\n moveOnTop() {\n if (this.autoZIndex) {\n this.container.style.zIndex = String(this.baseZIndex + (++DomHandler.zindex));\n this.wrapper.style.zIndex = String(this.baseZIndex + (DomHandler.zindex - 1));\n }\n }\n\n getMaskClass() {\n let maskClass = {'p-dialog-mask p-component-overlay': true, 'p-dialog-mask-scrollblocker': this.blockScroll};\n maskClass[this.getPositionClass().toString()] = true;\n return maskClass;\n }\n\n getPositionClass() {\n const positions = ['left', 'right', 'top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right'];\n const pos = positions.find(item => item === this.position);\n\n return pos ? `p-dialog-${pos}` : '';\n }\n\n bindGlobalListeners() {\n if ((this.option('closeOnEscape') && this.closable) || this.focusTrap && !this.documentEscapeListener) {\n const documentTarget: any = this.el ? this.el.nativeElement.ownerDocument : 'document';\n\n this.documentEscapeListener = this.renderer.listen(documentTarget, 'keydown', (event) => {\n if (event.which == 27 && (this.option('closeOnEscape') && this.closable)) {\n if (parseInt(this.container.style.zIndex) === (DomHandler.zindex + this.baseZIndex) && this.visible) {\n this.close(event);\n }\n }\n\n if (event.which === 9 && this.focusTrap) {\n event.preventDefault();\n\n let focusableElements = DomHandler.getFocusableElements(this.container);\n\n if (focusableElements && focusableElements.length > 0) {\n if (!focusableElements[0].ownerDocument.activeElement) {\n focusableElements[0].focus();\n }\n else {\n let focusedIndex = focusableElements.indexOf(focusableElements[0].ownerDocument.activeElement);\n\n if (event.shiftKey) {\n if (focusedIndex == -1 || focusedIndex === 0)\n focusableElements[focusableElements.length - 1].focus();\n else\n focusableElements[focusedIndex - 1].focus();\n }\n else {\n if (focusedIndex == -1 || focusedIndex === (focusableElements.length - 1))\n focusableElements[0].focus();\n else\n focusableElements[focusedIndex + 1].focus();\n }\n }\n }\n }\n });\n }\n }\n\n unbindGlobalListeners() {\n if (this.documentEscapeListener) {\n this.documentEscapeListener();\n this.documentEscapeListener = null;\n }\n }\n\n unbindMaskClickListener() {\n if (this.maskClickListener) {\n this.maskClickListener();\n this.maskClickListener = null;\n }\n }\n\n onOverlayHide() {\n this.disableModality();\n this.unbindGlobalListeners();\n this.container = null;\n }\n\n ngOnDestroy() {\n this.restoreAppend();\n this.onOverlayHide();\n this.subscription.unsubscribe();\n }\n\n accept() {\n if (this.confirmation && this.confirmation.acceptEvent) {\n this.confirmation.acceptEvent.emit();\n }\n\n this.hide();\n }\n\n reject() {\n if (this.confirmation && this.confirmation.rejectEvent) {\n this.confirmation.rejectEvent.emit();\n }\n\n this.hide();\n }\n\n get acceptButtonLabel(): string {\n return this.option('acceptLabel') || this.config.getTranslation(TranslationKeys.ACCEPT);\n }\n\n get rejectButtonLabel(): string {\n return this.option('rejectLabel') || this.config.getTranslation(TranslationKeys.REJECT);\n }\n}\n\n@NgModule({\n imports: [CommonModule,ButtonModule],\n exports: [ConfirmDialog,ButtonModule,SharedModule],\n declarations: [ConfirmDialog]\n})\nexport class ConfirmDialogModule { }\n"]}