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