primevue
Version:
PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc
1 lines • 11.7 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":["../../src/dynamicdialog/BaseDynamicDialog.vue","../../src/dynamicdialog/DynamicDialog.vue","../../src/dynamicdialog/DynamicDialog.vue?vue&type=template&id=4e9ba053&lang.js"],"sourcesContent":["<script>\nimport BaseComponent from '@primevue/core/basecomponent';\nimport DynamicDialogStyle from 'primevue/dynamicdialog/style';\n\nexport default {\n name: 'BaseDynamicDialog',\n extends: BaseComponent,\n props: {},\n style: DynamicDialogStyle,\n provide() {\n return {\n $pcDynamicDialog: this,\n $parentInstance: this\n };\n }\n};\n</script>\n","<template>\n <template v-for=\"(instance, key) in instanceMap\" :key=\"key\">\n <DDialog v-model:visible=\"instance.visible\" :_instance=\"instance\" v-bind=\"instance.options.props\" @hide=\"onDialogHide(instance)\" @after-hide=\"onDialogAfterHide(instance)\">\n <template v-if=\"instance.options.templates && instance.options.templates.header\" #header>\n <component v-for=\"(header, index) in getTemplateItems(instance.options.templates.header)\" :is=\"header\" :key=\"index + '_header'\" v-bind=\"instance.options.emits\"></component>\n </template>\n <component :is=\"instance.content\" v-bind=\"instance.options.emits\"></component>\n <template v-if=\"instance.options.templates && instance.options.templates.footer\" #footer>\n <component v-for=\"(footer, index) in getTemplateItems(instance.options.templates.footer)\" :is=\"footer\" :key=\"index + '_footer'\" v-bind=\"instance.options.emits\"></component>\n </template>\n </DDialog>\n </template>\n</template>\n\n<script>\nimport { uuid } from '@primeuix/utils';\nimport Dialog from 'primevue/dialog';\nimport DynamicDialogEventBus from 'primevue/dynamicdialogeventbus';\nimport BaseDynamicDialog from './BaseDynamicDialog.vue';\n\nexport default {\n name: 'DynamicDialog',\n extends: BaseDynamicDialog,\n inheritAttrs: false,\n data() {\n return {\n instanceMap: {}\n };\n },\n openListener: null,\n closeListener: null,\n currentInstance: null,\n mounted() {\n this.openListener = ({ instance }) => {\n const key = uuid() + '_dynamic_dialog';\n\n instance.visible = true;\n instance.key = key;\n this.instanceMap[key] = instance;\n };\n\n this.closeListener = ({ instance, params }) => {\n const key = instance.key;\n const currentInstance = this.instanceMap[key];\n\n if (currentInstance) {\n currentInstance.visible = false;\n currentInstance.options.onClose && currentInstance.options.onClose({ data: params, type: 'config-close' });\n\n this.currentInstance = currentInstance;\n }\n };\n\n DynamicDialogEventBus.on('open', this.openListener);\n DynamicDialogEventBus.on('close', this.closeListener);\n },\n beforeUnmount() {\n DynamicDialogEventBus.off('open', this.openListener);\n DynamicDialogEventBus.off('close', this.closeListener);\n },\n methods: {\n onDialogHide(instance) {\n !this.currentInstance && instance.options.onClose && instance.options.onClose({ type: 'dialog-close' });\n },\n onDialogAfterHide(instance) {\n this.currentInstance && delete this.currentInstance;\n this.currentInstance = null;\n delete this.instanceMap[instance.key];\n },\n getTemplateItems(template) {\n return Array.isArray(template) ? template : [template];\n }\n },\n components: {\n DDialog: Dialog\n }\n};\n</script>\n","<template>\n <template v-for=\"(instance, key) in instanceMap\" :key=\"key\">\n <DDialog v-model:visible=\"instance.visible\" :_instance=\"instance\" v-bind=\"instance.options.props\" @hide=\"onDialogHide(instance)\" @after-hide=\"onDialogAfterHide(instance)\">\n <template v-if=\"instance.options.templates && instance.options.templates.header\" #header>\n <component v-for=\"(header, index) in getTemplateItems(instance.options.templates.header)\" :is=\"header\" :key=\"index + '_header'\" v-bind=\"instance.options.emits\"></component>\n </template>\n <component :is=\"instance.content\" v-bind=\"instance.options.emits\"></component>\n <template v-if=\"instance.options.templates && instance.options.templates.footer\" #footer>\n <component v-for=\"(footer, index) in getTemplateItems(instance.options.templates.footer)\" :is=\"footer\" :key=\"index + '_footer'\" v-bind=\"instance.options.emits\"></component>\n </template>\n </DDialog>\n </template>\n</template>\n\n<script>\nimport { uuid } from '@primeuix/utils';\nimport Dialog from 'primevue/dialog';\nimport DynamicDialogEventBus from 'primevue/dynamicdialogeventbus';\nimport BaseDynamicDialog from './BaseDynamicDialog.vue';\n\nexport default {\n name: 'DynamicDialog',\n extends: BaseDynamicDialog,\n inheritAttrs: false,\n data() {\n return {\n instanceMap: {}\n };\n },\n openListener: null,\n closeListener: null,\n currentInstance: null,\n mounted() {\n this.openListener = ({ instance }) => {\n const key = uuid() + '_dynamic_dialog';\n\n instance.visible = true;\n instance.key = key;\n this.instanceMap[key] = instance;\n };\n\n this.closeListener = ({ instance, params }) => {\n const key = instance.key;\n const currentInstance = this.instanceMap[key];\n\n if (currentInstance) {\n currentInstance.visible = false;\n currentInstance.options.onClose && currentInstance.options.onClose({ data: params, type: 'config-close' });\n\n this.currentInstance = currentInstance;\n }\n };\n\n DynamicDialogEventBus.on('open', this.openListener);\n DynamicDialogEventBus.on('close', this.closeListener);\n },\n beforeUnmount() {\n DynamicDialogEventBus.off('open', this.openListener);\n DynamicDialogEventBus.off('close', this.closeListener);\n },\n methods: {\n onDialogHide(instance) {\n !this.currentInstance && instance.options.onClose && instance.options.onClose({ type: 'dialog-close' });\n },\n onDialogAfterHide(instance) {\n this.currentInstance && delete this.currentInstance;\n this.currentInstance = null;\n delete this.instanceMap[instance.key];\n },\n getTemplateItems(template) {\n return Array.isArray(template) ? template : [template];\n }\n },\n components: {\n DDialog: Dialog\n }\n};\n</script>\n"],"names":["name","BaseComponent","props","style","DynamicDialogStyle","provide","$pcDynamicDialog","$parentInstance","BaseDynamicDialog","inheritAttrs","data","instanceMap","openListener","closeListener","currentInstance","mounted","_this","_ref","instance","key","uuid","visible","_ref2","params","options","onClose","type","DynamicDialogEventBus","on","beforeUnmount","off","methods","onDialogHide","onDialogAfterHide","getTemplateItems","template","Array","isArray","components","DDialog","Dialog","_openBlock","_createElementBlock","_Fragment","_renderList","$data","_createBlock","_component_DDialog","_mergeProps","onUpdateVisible","$event","_instance","onHide","$options","onAfterHide","_resolveDynamicComponent","content","ref_for","emits","templates","header","index","footer"],"mappings":";;;;;;;AAIA,eAA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