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.35 kB
this.primevue=this.primevue||{},this.primevue.dynamicdialog=function(e,t,n,o){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(t),l={name:"DynamicDialog",inheritAttrs:!1,data:()=>({instanceMap:{}}),openListener:null,closeListener:null,currentInstance:null,mounted(){this.openListener=({instance:t})=>{const n=e.UniqueComponentId()+"_dynamic_dialog";t.visible=!0,t.key=n,this.instanceMap[n]=t},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)},s.default.on("open",this.openListener),s.default.on("close",this.closeListener)},beforeUnmount(){s.default.off("open",this.openListener),s.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:i(n).default}};return l.render=function(e,t,n,i,s,l){const a=o.resolveComponent("DDialog");return o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(s.instanceMap,((e,t)=>(o.openBlock(),o.createBlock(a,o.mergeProps({key:t,visible:e.visible,"onUpdate:visible":t=>e.visible=t,_instance:e},e.options.props,{onHide:t=>l.onDialogHide(e),onAfterHide:l.onDialogAfterHide}),o.createSlots({default:o.withCtx((()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(e.content)))])),_:2},[e.options.templates&&e.options.templates.header?{name:"header",fn:o.withCtx((()=>[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(l.getTemplateItems(e.options.templates.header),((e,t)=>(o.openBlock(),o.createBlock(o.resolveDynamicComponent(e),{key:t+"_header"})))),128))])),key:"0"}:void 0,e.options.templates&&e.options.templates.footer?{name:"footer",fn:o.withCtx((()=>[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(l.getTemplateItems(e.options.templates.footer),((e,t)=>(o.openBlock(),o.createBlock(o.resolveDynamicComponent(e),{key:t+"_footer"})))),128))])),key:"1"}:void 0]),1040,["visible","onUpdate:visible","_instance","onHide","onAfterHide"])))),128)},l}(primevue.utils,primevue.dynamicdialogeventbus,primevue.dialog,Vue);