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