UNPKG

primevue

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primevue.svg)](https://badge.fury.io/js/primevue) [![Discord Chat](https://img.shields.io/discord/55794023

2 lines (1 loc) 2.47 kB
"use strict";var e=require("primevue/basecomponent"),t=require("primevue/dialog"),n=require("primevue/dynamicdialogeventbus"),o=require("primevue/utils"),i=require("vue");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=s(e),l=s(t),a=s(n),c={name:"DynamicDialog",extends:r.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)},a.default.on("open",this.openListener),a.default.on("close",this.closeListener)},beforeUnmount(){a.default.off("open",this.openListener),a.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:l.default}};c.render=function(e,t,n,o,s,r){const l=i.resolveComponent("DDialog");return i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(s.instanceMap,((t,n)=>(i.openBlock(),i.createBlock(l,i.mergeProps({key:n,visible:t.visible,"onUpdate:visible":e=>t.visible=e,_instance:t},t.options.props,{pt:e.pt,onHide:e=>r.onDialogHide(t),onAfterHide:r.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(r.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(r.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)},module.exports=c;