UNPKG

22.1 kBSource Map (JSON)View Raw
1{"version":3,"sources":["ng://primeng/dynamicdialog/dynamicdialogcontent.ts","ng://primeng/dynamicdialog/dynamicdialog-config.ts","ng://primeng/dynamicdialog/dynamicdialog-ref.ts","ng://primeng/dynamicdialog/dynamicdialog.ts","ng://primeng/dynamicdialog/dynamicdialog-injector.ts","ng://primeng/dynamicdialog/dialogservice.ts"],"names":["DynamicDialogContent","viewContainerRef","this","ViewContainerRef","__decorate","Directive","selector","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","_this","closable","dismissableMask","maskClickListener","listen","isSameNode","target","contains","addClass","document","body","unbindMaskClickListener","removeClass","destroyed","onKeydown","which","preventDefault","focusableElements","getFocusableElements","length","activeElement","focusedIndex","indexOf","shiftKey","focusable","findSingle","runOutsideAngular","setTimeout","bindDocumentKeydownListener","closeOnEscape","bindDocumentEscapeListener","unbindDocumentKeydownListener","unbindDocumentEscapeListener","documentKeydownListener","bind","window","addEventListener","removeEventListener","documentEscapeListener","parseInt","ngOnDestroy","ComponentFactoryResolver","ChangeDetectorRef","Renderer2","DynamicDialogConfig","NgZone","ViewChild","__decorate$1","Component","template","animations","trigger","transition","useAnimation","changeDetection","ChangeDetectionStrategy","Default","DynamicDialogModule","NgModule","imports","CommonModule","declarations","entryComponents","DynamicDialogInjector","_parentInjector","_additionalTokens","get","token","notFoundValue","flags","value","DialogService","appRef","injector","open","appendDialogComponentToBody","dialogComponentRef","instance","map","WeakMap","set","sub","subscribe","destroySub","removeDialogComponentFromBody","unsubscribe","create","attachView","hostView","domElem","rootNodes","appendChild","detachView","ApplicationRef","Injector","__decorate$2","Injectable"],"mappings":"k3BAAAA,EAAA,WAOC,SAAAA,EAAmBC,GAAAC,KAAAD,iBAAAA,EAEpB,gDAFsCE,EAAAA,oBAFzBH,EAAoBI,EAAA,CAHhCC,EAAAA,UAAU,CACTC,SAAU,6BAECN,GALb,KCAA,0BCGC,SAAAO,IAUiBL,KAAAM,SAAW,IAAIC,EAAAA,QAC7BP,KAAAQ,QAA2BR,KAAKM,SAASG,eAExBT,KAAAU,WAAa,IAAIH,EAAAA,QACrCP,KAAAW,UAA6BX,KAAKU,WAAWD,eAC9C,OAbCJ,EAAAO,UAAAC,MAAA,SAAMC,GACLd,KAAKM,SAASS,KAAKD,IAGjBT,EAAAO,UAAAI,QAAA,WACFhB,KAAKU,WAAWK,QAQlBV,kWCVMY,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,OAwC3EG,EAAA,WA0BC,SAAAA,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,aAiM/B,OA5LCR,EAAAZ,UAAAqB,gBAAA,WACCjC,KAAKkC,mBAAmBlC,KAAKmC,oBAC7Bn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I,SAAUK,IAEtFlJ,KAAK4I,OAAOe,WAAWjH,EAAakH,UAEpC,IAAMC,EAAWnH,EAAakH,SAAkCE,UAAU,GAK1E,OAJAjF,SAASC,KAAKiF,YAAYF,GAE1B7J,KAAKgJ,mBAAqBtG,EAEnBb,GAGH8G,EAAA/H,UAAA4I,8BAAR,WACIxJ,KAAK4I,OAAOoB,WAAWhK,KAAKgJ,mBAAmBY,UAC/C5J,KAAKgJ,mBAAmBhI,oDA1CkB6F,EAAAA,gCAA0CoD,EAAAA,sBAAkCC,EAAAA,YAJjHvB,EAAawB,EAAA,CADzBC,EAAAA,cACYzB,GAPb","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<any>();\r\n onClose: Observable<any> = this._onClose.asObservable();\r\n\r\n private readonly _onDestroy = new Subject<any>();\r\n\tonDestroy: Observable<any> = this._onDestroy.asObservable();\r\n}\r\n","import { Component, NgModule, Type, ComponentFactoryResolver, ViewChild, OnDestroy, ComponentRef, AfterViewInit, ChangeDetectorRef, Renderer2, NgZone, ElementRef, ChangeDetectionStrategy, ViewRef } 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 <div #mask [ngClass]=\"{'ui-dialog-mask ui-dialog-visible':true, 'ui-widget-overlay ui-dialog-mask-scrollblocker': config.modal !== false}\">\n <div [ngClass]=\"{'ui-dialog ui-dynamicdialog ui-widget ui-widget-content ui-corner-all ui-shadow':true, 'ui-dialog-rtl': config.rtl}\" [ngStyle]=\"config.style\" [class]=\"config.styleClass\"\n [@animation]=\"{value: 'visible', params: {transform: transformOptions, transition: config.transitionOptions || '150ms cubic-bezier(0, 0, 0.2, 1)'}}\"\n (@animation.start)=\"onAnimationStart($event)\" (@animation.done)=\"onAnimationEnd($event)\" role=\"dialog\" *ngIf=\"visible\"\n [style.width]=\"config.width\" [style.height]=\"config.height\">\n <div class=\"ui-dialog-titlebar ui-widget-header ui-helper-clearfix ui-corner-top\" *ngIf=\"config.showHeader === false ? false: true\">\n <span class=\"ui-dialog-title\">{{config.header}}</span>\n <div class=\"ui-dialog-titlebar-icons\">\n <a [ngClass]=\"'ui-dialog-titlebar-icon ui-dialog-titlebar-close ui-corner-all'\" tabindex=\"0\" role=\"button\" (click)=\"close()\" (keydown.enter)=\"close()\" *ngIf=\"config.closable !== false\">\n <span class=\"pi pi-times\"></span>\n </a>\n </div>\n </div>\n <div class=\"ui-dialog-content ui-widget-content\" [ngStyle]=\"config.contentStyle\">\n <ng-template pDynamicDialogContent></ng-template>\n </div>\n <div class=\"ui-dialog-footer ui-widget-content\" *ngIf=\"config.footer\">\n {{config.footer}}\n </div>\n </div>\n </div>\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})\nexport class DynamicDialogComponent implements AfterViewInit, OnDestroy {\n\n\tvisible: boolean = true;\n\n\tcomponentRef: ComponentRef<any>;\n\n\tmask: HTMLDivElement;\n\n\t@ViewChild(DynamicDialogContent) insertionPoint: DynamicDialogContent;\n\n\t@ViewChild('mask') maskViewChild: ElementRef;\n\n\tchildComponentType: Type<any>;\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<any>) {\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\t}\n\n enableModality() {\n if (this.config.closable !== false && this.config.dismissableMask !== false) {\n this.maskClickListener = this.renderer.listen(this.wrapper, 'click', (event: any) => {\n if (this.container && !this.container.isSameNode(event.target) && !this.container.contains(event.target)) {\n this.close();\n }\n });\n }\n\n if (this.config.modal !== false) {\n DomHandler.addClass(document.body, 'ui-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, 'ui-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 (!document.activeElement) {\n focusableElements[0].focus();\n }\n else {\n let focusedIndex = focusableElements.indexOf(document.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, 'a');\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 this.documentEscapeListener = this.renderer.listen('document', '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.close();\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<any, any>) { }\r\n\r\n\tget<T>(token: Type<T> | InjectionToken<T>, 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<any>(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 dialogComponentRef: ComponentRef<DynamicDialogComponent>;\n\n constructor(private componentFactoryResolver: ComponentFactoryResolver, private appRef: ApplicationRef, private injector: Injector) { }\n\n public open(componentType: Type<any>, config: DynamicDialogConfig) {\n const dialogRef = this.appendDialogComponentToBody(config);\n\n this.dialogComponentRef.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.dialogComponentRef.instance.close();\n });\n\n const destroySub = dialogRef.onDestroy.subscribe(() => {\n this.removeDialogComponentFromBody();\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<any>).rootNodes[0] as HTMLElement;\n document.body.appendChild(domElem);\n\n this.dialogComponentRef = componentRef;\n\n return dialogRef;\n }\n\n private removeDialogComponentFromBody() {\n this.appRef.detachView(this.dialogComponentRef.hostView);\n this.dialogComponentRef.destroy();\n }\n}\n"]}
\No newline at end of file