primevue
Version:
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/primevue) [ • 2.48 kB
JavaScript
this.primevue=this.primevue||{},this.primevue.dynamicdialog=function(e,t,n,o,i){"use strict";function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=s(e),a=s(t),r=s(n),c={name:"DynamicDialog",extends:l.default,inheritAttrs:!1,data:()=>({instanceMap:{}}),openListener:null,closeListener:null,currentInstance:null,mounted(){this.openListener=({instance:e})=>{const t=o.UniqueComponentId()+"_dynamic_dialog";e.visible=!0,e.key=t,this.instanceMap[t]=e},this.closeListener=({instance:e,params:t})=>{const n=e.key,o=this.instanceMap[n];o&&(o.visible=!1,o.options.onClose&&o.options.onClose({data:t,type:"config-close"}),this.currentInstance=o)},r.default.on("open",this.openListener),r.default.on("close",this.closeListener)},beforeUnmount(){r.default.off("open",this.openListener),r.default.off("close",this.closeListener)},methods:{onDialogHide(e){!this.currentInstance&&e.options.onClose&&e.options.onClose({type:"dialog-close"})},onDialogAfterHide(){this.currentInstance&&delete this.currentInstance,this.currentInstance=null},getTemplateItems:e=>Array.isArray(e)?e:[e]},components:{DDialog:a.default}};return c.render=function(e,t,n,o,s,l){const a=i.resolveComponent("DDialog");return i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.instanceMap,((t,n)=>(i.openBlock(),i.createBlock(a,i.mergeProps({key:n,visible:t.visible,"onUpdate:visible":e=>t.visible=e,_instance:t},t.options.props,{pt:e.pt,onHide:e=>l.onDialogHide(t),onAfterHide:l.onDialogAfterHide}),i.createSlots({default:i.withCtx((()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(t.content),i.normalizeProps(i.guardReactiveProps(t.options.emits)),null,16))])),_:2},[t.options.templates&&t.options.templates.header?{name:"header",fn:i.withCtx((()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(l.getTemplateItems(t.options.templates.header),((e,t)=>(i.openBlock(),i.createBlock(i.resolveDynamicComponent(e),{key:t+"_header"})))),128))])),key:"0"}:void 0,t.options.templates&&t.options.templates.footer?{name:"footer",fn:i.withCtx((()=>[(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(l.getTemplateItems(t.options.templates.footer),((e,t)=>(i.openBlock(),i.createBlock(i.resolveDynamicComponent(e),{key:t+"_footer"})))),128))])),key:"1"}:void 0]),1040,["visible","onUpdate:visible","_instance","pt","onHide","onAfterHide"])))),128)},c}(primevue.basecomponent,primevue.dialog,primevue.dynamicdialogeventbus,primevue.utils,Vue);