primevue
Version:
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/primevue) [ • 2.09 kB
JavaScript
import e from"primevue/dialog";import t from"primevue/dynamicdialogeventbus";import{UniqueComponentId as n}from"primevue/utils";import{resolveComponent as o,openBlock as i,createElementBlock as s,Fragment as a,renderList as l,createBlock as r,mergeProps as p,createSlots as c,withCtx as m,resolveDynamicComponent as d,normalizeProps as u,guardReactiveProps as f}from"vue";var h={name:"DynamicDialog",inheritAttrs:!1,data:()=>({instanceMap:{}}),openListener:null,closeListener:null,currentInstance:null,mounted(){this.openListener=({instance:e})=>{const t=n()+"_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)},t.on("open",this.openListener),t.on("close",this.closeListener)},beforeUnmount(){t.off("open",this.openListener),t.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:e}};h.render=function(e,t,n,h,v,g){const y=o("DDialog");return i(!0),s(a,null,l(v.instanceMap,((e,t)=>(i(),r(y,p({key:t,visible:e.visible,"onUpdate:visible":t=>e.visible=t,_instance:e},e.options.props,{onHide:t=>g.onDialogHide(e),onAfterHide:g.onDialogAfterHide}),c({default:m((()=>[(i(),r(d(e.content),u(f(e.options.emits)),null,16))])),_:2},[e.options.templates&&e.options.templates.header?{name:"header",fn:m((()=>[(i(!0),s(a,null,l(g.getTemplateItems(e.options.templates.header),((e,t)=>(i(),r(d(e),{key:t+"_header"})))),128))])),key:"0"}:void 0,e.options.templates&&e.options.templates.footer?{name:"footer",fn:m((()=>[(i(!0),s(a,null,l(g.getTemplateItems(e.options.templates.footer),((e,t)=>(i(),r(d(e),{key:t+"_footer"})))),128))])),key:"1"}:void 0]),1040,["visible","onUpdate:visible","_instance","onHide","onAfterHide"])))),128)};export{h as default};