{"version":3,"sources":["../../src/app/components/dynamicdialog/dynamicdialogcontent.ts","../../src/app/components/dynamicdialog/dynamicdialog-config.ts","../../src/app/components/dynamicdialog/dynamicdialog-ref.ts","../../src/app/components/dynamicdialog/dynamicdialog.ts","../../src/app/components/dynamicdialog/dynamicdialog-injector.ts","../../src/app/components/dynamicdialog/dialogservice.ts"],"names":["viewContainerRef","this","Directive","args","selector","ViewContainerRef","DynamicDialogRef","_onClose","Subject","onClose","asObservable","_onDestroy","onDestroy","prototype","close","result","next","destroy","showAnimation","animation","style","transform","opacity","animate","hideAnimation","DynamicDialogComponent","componentFactoryResolver","cd","renderer","config","dialogRef","zone","visible","transformOptions","ngAfterViewInit","loadChildComponent","childComponentType","detectChanges","componentType","componentFactory","resolveComponentFactory","insertionPoint","clear","componentRef","createComponent","moveOnTop","autoZIndex","zIndex","baseZIndex","DomHandler","zindex","container","String","maskViewChild","nativeElement","onAnimationStart","event","toState","element","wrapper","parentElement","bindGlobalListeners","modal","enableModality","focus","onContainerDestroy","onAnimationEnd","unbindGlobalListeners","disableModality","markForCheck","hide","_this","closable","dismissableMask","maskClickListener","listen","isSameNode","target","addClass","document","body","unbindMaskClickListener","removeClass","destroyed","onKeydown","which","preventDefault","focusableElements","getFocusableElements","length","ownerDocument","activeElement","focusedIndex","indexOf","shiftKey","focusable","findSingle","runOutsideAngular","setTimeout","bindDocumentKeydownListener","closeOnEscape","bindDocumentEscapeListener","unbindDocumentKeydownListener","unbindDocumentEscapeListener","documentKeydownListener","bind","window","addEventListener","removeEventListener","documentTarget","documentEscapeListener","parseInt","ngOnDestroy","Component","template","animations","trigger","transition","useAnimation","changeDetection","ChangeDetectionStrategy","Default","encapsulation","ViewEncapsulation","None","ComponentFactoryResolver","ChangeDetectorRef","Renderer2","DynamicDialogConfig","NgZone","ViewChild","DynamicDialogContent","NgModule","imports","CommonModule","declarations","entryComponents","DynamicDialogInjector","_parentInjector","_additionalTokens","get","token","notFoundValue","flags","value","DialogService","appRef","injector","dialogComponentRefMap","Map","open","appendDialogComponentToBody","instance","map","WeakMap","set","sub","subscribe","destroySub","removeDialogComponentFromBody","unsubscribe","create","attachView","hostView","domElem","rootNodes","appendChild","has","dialogComponentRef","detachView","delete","Injectable","ApplicationRef","Injector"],"mappings":"ikBAOC,SAAmBA,GAAAC,KAAAD,iBAAAA,uBALnBE,EAAAA,UAASC,KAAA,CAAC,CACTC,SAAU,uEAHQC,EAAAA,0BCApB,0BCGC,SAAAC,IAUiBL,KAAAM,SAAW,IAAIC,EAAAA,QAC7BP,KAAAQ,QAA2BR,KAAKM,SAASG,eAExBT,KAAAU,WAAa,IAAIH,EAAAA,QACrCP,KAAAW,UAA6BX,KAAKU,WAAWD,sBAZ7CJ,EAAAO,UAAAC,MAAA,SAAMC,GACLd,KAAKM,SAASS,KAAKD,IAGjBT,EAAAO,UAAAI,QAAA,WACFhB,KAAKU,WAAWK,aCFZE,EAAgBC,EAAAA,UAAU,CAC5BC,EAAAA,MAAM,CAAEC,UAAW,gBAAiBC,QAAS,IAC7CC,EAAAA,QAAQ,iBAAkBH,EAAAA,MAAM,CAAEC,UAAW,OAAQC,QAAS,OAG5DE,EAAgBL,EAAAA,UAAU,CAC5BI,EAAAA,QAAQ,iBAAkBH,EAAAA,MAAM,CAAEC,UAAW,gBAAiBC,QAAS,oBAoE1E,SAAAG,EAAoBC,EAA4DC,EAA8BC,EACrGC,EAAqCC,EAAoCC,GAD9D9B,KAAAyB,yBAAAA,EAA4DzB,KAAA0B,GAAAA,EAA8B1B,KAAA2B,SAAAA,EACrG3B,KAAA4B,OAAAA,EAAqC5B,KAAA6B,UAAAA,EAAoC7B,KAAA8B,KAAAA,EAzBlF9B,KAAA+B,SAAmB,EAsBhB/B,KAAAgC,iBAA2B,oBAK9BR,EAAAZ,UAAAqB,gBAAA,WACCjC,KAAKkC,mBAAmBlC,KAAKmC,oBAC7BnC,KAAK0B,GAAGU,iBAGTZ,EAAAZ,UAAAsB,mBAAA,SAAmBG,GAClB,IAAIC,EA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CgI,EAAWE,cACXJ,EAAII,iBAIFrH,EADmB1C,KAAKyB,yBAAyBc,wBAAwBf,GACzCwI,OAAO,IAAIxB,EAAsBxI,KAAKkJ,SAAUM,IAEtFxJ,KAAKiJ,OAAOgB,WAAWvH,EAAawH,UAEpC,IAAMC,EAAWzH,EAAawH,SAAkCE,UAAU,GAK1E,OAJAtF,SAASC,KAAKsF,YAAYF,GAE1BnK,KAAKmJ,sBAAsBO,IAAI7H,EAAWa,GAEnCb,GAGHmH,EAAApI,UAAAkJ,8BAAA,SAA8BjI,GAClC,GAAKA,GAAc7B,KAAKmJ,sBAAsBmB,IAAIzI,GAAlD,CAIA,IAAM0I,EAAqBvK,KAAKmJ,sBAAsBR,IAAI9G,GAC1D7B,KAAKiJ,OAAOuB,WAAWD,EAAmBL,UAC1CK,EAAmBvJ,UACnBhB,KAAKmJ,sBAAsBsB,OAAO5I,8BAtDzC6I,EAAAA,sDANoB9C,EAAAA,gCAA0B+C,EAAAA,sBAAgBC,EAAAA","sourcesContent":["import { Directive, ViewContainerRef } from '@angular/core';\n\n@Directive({\n selector: '[pDynamicDialogContent]'\n})\nexport class DynamicDialogContent {\n \n\tconstructor(public viewContainerRef: ViewContainerRef) {}\n\n}\n","export class DynamicDialogConfig {\r\n\tdata?: any;\r\n\theader?: string;\r\n\tfooter?: string;\r\n\twidth?: string;\r\n\theight?: string;\r\n\tcloseOnEscape?: boolean;\r\n\tbaseZIndex?: number;\r\n\tautoZIndex?: boolean;\r\n\tdismissableMask?: boolean;\r\n\trtl?: boolean;\r\n\tstyle?: any;\r\n\tcontentStyle?: any;\r\n\tstyleClass?: string;\r\n\ttransitionOptions?: string;\r\n\tclosable?: boolean;\r\n\tshowHeader?: boolean;\r\n\tmodal?: boolean;\r\n}\r\n","import { Observable, Subject } from 'rxjs';\r\n\r\nexport class DynamicDialogRef {\r\n\tconstructor() { }\r\n\r\n\tclose(result?: any) {\r\n\t\tthis._onClose.next(result);\r\n }\r\n \r\n destroy() {\r\n\t\tthis._onDestroy.next();\r\n\t}\r\n\r\n\tprivate readonly _onClose = new Subject();\r\n onClose: Observable = this._onClose.asObservable();\r\n\r\n private readonly _onDestroy = new Subject();\r\n\tonDestroy: Observable = this._onDestroy.asObservable();\r\n}\r\n","import { Component, NgModule, Type, ComponentFactoryResolver, ViewChild, OnDestroy, ComponentRef, AfterViewInit, ChangeDetectorRef, Renderer2, NgZone, ElementRef, ChangeDetectionStrategy, ViewRef, ViewEncapsulation } from '@angular/core';\nimport { trigger,style,transition,animate,AnimationEvent, animation, useAnimation } from '@angular/animations';\nimport { DynamicDialogContent } from './dynamicdialogcontent';\nimport { DynamicDialogConfig } from './dynamicdialog-config';\nimport { CommonModule } from '@angular/common';\nimport { DomHandler } from 'primeng/dom';\nimport { DynamicDialogRef } from './dynamicdialog-ref';\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\tselector: 'p-dynamicDialog',\n\ttemplate: `\n
\n
\n
\n {{config.header}}\n
\n \n
\n
\n
\n \n
\n
\n {{config.footer}}\n
\n
\n
\n\t`,\n\tanimations: [\n trigger('animation', [\n transition('void => visible', [\n useAnimation(showAnimation)\n ]),\n transition('visible => void', [\n useAnimation(hideAnimation)\n ])\n ])\n ],\n changeDetection: ChangeDetectionStrategy.Default,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['../dialog/dialog.css']\n})\nexport class DynamicDialogComponent implements AfterViewInit, OnDestroy {\n\n\tvisible: boolean = true;\n\n\tcomponentRef: ComponentRef;\n\n\tmask: HTMLDivElement;\n\n\t@ViewChild(DynamicDialogContent) insertionPoint: DynamicDialogContent;\n\n\t@ViewChild('mask') maskViewChild: ElementRef;\n\n\tchildComponentType: Type;\n\n container: HTMLDivElement;\n\n wrapper: HTMLElement;\n\n documentKeydownListener: any;\n\n documentEscapeListener: Function;\n\n maskClickListener: Function;\n\n transformOptions: string = \"scale(0.7)\";\n\n\tconstructor(private componentFactoryResolver: ComponentFactoryResolver, private cd: ChangeDetectorRef, public renderer: Renderer2,\n\t\t\tpublic config: DynamicDialogConfig, private dialogRef: DynamicDialogRef, public zone: NgZone) { }\n\n\tngAfterViewInit() {\n\t\tthis.loadChildComponent(this.childComponentType);\n\t\tthis.cd.detectChanges();\n\t}\n\n\tloadChildComponent(componentType: Type) {\n\t\tlet componentFactory = this.componentFactoryResolver.resolveComponentFactory(componentType);\n\n\t\tlet viewContainerRef = this.insertionPoint.viewContainerRef;\n\t\tviewContainerRef.clear();\n\n\t\tthis.componentRef = viewContainerRef.createComponent(componentFactory);\n\t}\n\n\tmoveOnTop() {\n if (this.config.autoZIndex !== false) {\n\t\t\tconst zIndex = (this.config.baseZIndex||0) + (++DomHandler.zindex);\n\t\t\tthis.container.style.zIndex = String(zIndex);\n\t\t\tthis.maskViewChild.nativeElement.style.zIndex = String(zIndex - 1);\n\t\t}\n }\n\n\tonAnimationStart(event: AnimationEvent) {\n\t\tswitch(event.toState) {\n\t\t\tcase 'visible':\n this.container = event.element;\n this.wrapper = this.container.parentElement;\n\t\t\t\tthis.moveOnTop();\n this.bindGlobalListeners();\n\n if (this.config.modal !== false) {\n this.enableModality();\n }\n this.focus();\n\t\t\tbreak;\n\n\t\t\tcase 'void':\n\t\t\t\tthis.onContainerDestroy();\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tonAnimationEnd(event: AnimationEvent) {\n\t\tif (event.toState === 'void') {\n\t\t\tthis.dialogRef.destroy();\n\t\t}\n\t}\n\n\tonContainerDestroy() {\n\t\tthis.unbindGlobalListeners();\n\n if (this.config.modal !== false) {\n this.disableModality();\n }\n this.container = null;\n\t}\n\n\tclose() {\n this.visible = false;\n this.cd.markForCheck();\n\t}\n\n hide() {\n if (this.dialogRef) {\n this.dialogRef.close();\n }\n }\n\n enableModality() {\n if (this.config.closable !== false && this.config.dismissableMask) {\n this.maskClickListener = this.renderer.listen(this.wrapper, 'mousedown', (event: any) => {\n if (this.wrapper && this.wrapper.isSameNode(event.target)) {\n this.hide();\n }\n });\n }\n\n if (this.config.modal !== false) {\n DomHandler.addClass(document.body, 'p-overflow-hidden');\n }\n }\n\n disableModality() {\n if (this.wrapper) {\n if (this.config.dismissableMask) {\n this.unbindMaskClickListener();\n }\n\n if (this.config.modal !== false) {\n DomHandler.removeClass(document.body, 'p-overflow-hidden');\n }\n\n if (!(this.cd as ViewRef).destroyed) {\n this.cd.detectChanges();\n }\n }\n }\n\n onKeydown(event: KeyboardEvent) {\n if (event.which === 9) {\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 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\tbindGlobalListeners() {\n this.bindDocumentKeydownListener();\n\n if (this.config.closeOnEscape !== false && this.config.closable !== false) {\n this.bindDocumentEscapeListener();\n }\n }\n\n unbindGlobalListeners() {\n this.unbindDocumentKeydownListener();\n this.unbindDocumentEscapeListener();\n }\n\n bindDocumentKeydownListener() {\n this.zone.runOutsideAngular(() => {\n this.documentKeydownListener = this.onKeydown.bind(this);\n window.document.addEventListener('keydown', this.documentKeydownListener);\n });\n }\n\n unbindDocumentKeydownListener() {\n if (this.documentKeydownListener) {\n window.document.removeEventListener('keydown', this.documentKeydownListener);\n this.documentKeydownListener = null;\n }\n }\n\n\tbindDocumentEscapeListener() {\n const documentTarget: any = this.maskViewChild ? this.maskViewChild.nativeElement.ownerDocument : 'document';\n\n this.documentEscapeListener = this.renderer.listen(documentTarget, 'keydown', (event) => {\n if (event.which == 27) {\n if (parseInt(this.container.style.zIndex) == (DomHandler.zindex + (this.config.baseZIndex ? this.config.baseZIndex : 0))) {\n\t\t\t\t\tthis.hide();\n\t\t\t\t}\n }\n });\n }\n\n unbindDocumentEscapeListener() {\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\tngOnDestroy() {\n\t\tthis.onContainerDestroy();\n\n\t\tif (this.componentRef) {\n\t\t\tthis.componentRef.destroy();\n\t\t}\n\t}\n}\n\n@NgModule({\n\timports: [CommonModule],\n\tdeclarations: [DynamicDialogComponent, DynamicDialogContent],\n\tentryComponents: [DynamicDialogComponent]\n})\nexport class DynamicDialogModule { }\n","import { Injector, Type, InjectionToken, InjectFlags } from '@angular/core';\r\n\r\nexport class DynamicDialogInjector implements Injector {\r\n\t\r\n\tconstructor(private _parentInjector: Injector, private _additionalTokens: WeakMap) { }\r\n\r\n\tget(token: Type | InjectionToken, notFoundValue?: T, flags?: InjectFlags): T;\r\n\tget(token: any, notFoundValue?: any);\r\n\tget(token: any, notFoundValue?: any, flags?: any) {\r\n\t\tconst value = this._additionalTokens.get(token);\r\n\r\n\t\tif (value) return value;\r\n\r\n\t\treturn this._parentInjector.get(token, notFoundValue);\r\n\t}\r\n}\r\n","import { Injectable, ComponentFactoryResolver, ApplicationRef, Injector, Type, EmbeddedViewRef, ComponentRef } from '@angular/core';\nimport { DynamicDialogComponent } from './dynamicdialog';\nimport { DynamicDialogInjector } from './dynamicdialog-injector';\nimport { DynamicDialogConfig } from './dynamicdialog-config';\nimport { DynamicDialogRef } from './dynamicdialog-ref';\n\n@Injectable()\nexport class DialogService {\n\n dialogComponentRefMap: Map> = new Map();\n\n constructor(private componentFactoryResolver: ComponentFactoryResolver, private appRef: ApplicationRef, private injector: Injector) {\n }\n\n public open(componentType: Type, config: DynamicDialogConfig) {\n const dialogRef = this.appendDialogComponentToBody(config);\n\n this.dialogComponentRefMap.get(dialogRef).instance.childComponentType = componentType;\n\n return dialogRef;\n }\n\n private appendDialogComponentToBody(config: DynamicDialogConfig) {\n const map = new WeakMap();\n map.set(DynamicDialogConfig, config);\n\n const dialogRef = new DynamicDialogRef();\n map.set(DynamicDialogRef, dialogRef);\n\n const sub = dialogRef.onClose.subscribe(() => {\n this.dialogComponentRefMap.get(dialogRef).instance.close();\n });\n\n const destroySub = dialogRef.onDestroy.subscribe(() => {\n this.removeDialogComponentFromBody(dialogRef);\n destroySub.unsubscribe();\n sub.unsubscribe();\n });\n\n const componentFactory = this.componentFactoryResolver.resolveComponentFactory(DynamicDialogComponent);\n const componentRef = componentFactory.create(new DynamicDialogInjector(this.injector, map));\n\n this.appRef.attachView(componentRef.hostView);\n\n const domElem = (componentRef.hostView as EmbeddedViewRef).rootNodes[0] as HTMLElement;\n document.body.appendChild(domElem);\n\n this.dialogComponentRefMap.set(dialogRef, componentRef);\n\n return dialogRef;\n }\n\n private removeDialogComponentFromBody(dialogRef: DynamicDialogRef) {\n if (!dialogRef || !this.dialogComponentRefMap.has(dialogRef)) {\n return;\n }\n\n const dialogComponentRef = this.dialogComponentRefMap.get(dialogRef);\n this.appRef.detachView(dialogComponentRef.hostView);\n dialogComponentRef.destroy();\n this.dialogComponentRefMap.delete(dialogRef);\n }\n}\n"]}