mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 00:42:36 +00:00
Fixed #3802 - Improve folder structure for nuxt configurations
This commit is contained in:
parent
851950270b
commit
f5fe822afb
563 changed files with 1703 additions and 1095 deletions
46
components/lib/dynamicdialog/DynamicDialog.d.ts
vendored
Normal file
46
components/lib/dynamicdialog/DynamicDialog.d.ts
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
*
|
||||
* DynamicDialogs can be created dynamically with any component as the content using a DialogService.
|
||||
*
|
||||
* [Live Demo](https://primevue.org/dynamicdialog)
|
||||
*
|
||||
* @module dynamicdialog
|
||||
*
|
||||
*/
|
||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||
|
||||
/**
|
||||
* Defines valid properties in DynamicDialog component.
|
||||
*/
|
||||
export interface DynamicDialogProps {}
|
||||
|
||||
/**
|
||||
* Defines valid emits in DynamicDialog component.
|
||||
*/
|
||||
export interface DynamicDialogEmits {}
|
||||
|
||||
/**
|
||||
* Defines valid slots in DynamicDialog component.
|
||||
*/
|
||||
export interface DynamicDialogSlots {}
|
||||
|
||||
/**
|
||||
* **PrimeVue - DynamicDialog**
|
||||
*
|
||||
* _DynamicDialogs can be created dynamically with any component as the content using a DialogService._
|
||||
*
|
||||
* [Live Demo](https://www.primevue.org/dynamicdialog/)
|
||||
* --- ---
|
||||
* 
|
||||
*
|
||||
* @group Component
|
||||
*/
|
||||
declare class DynamicDialog extends ClassComponent<DynamicDialogProps, DynamicDialogSlots, DynamicDialogEmits> {}
|
||||
|
||||
declare module '@vue/runtime-core' {
|
||||
interface GlobalComponents {
|
||||
DynamicDialog: GlobalComponentConstructor<DynamicDialog>;
|
||||
}
|
||||
}
|
||||
|
||||
export default DynamicDialog;
|
75
components/lib/dynamicdialog/DynamicDialog.vue
Normal file
75
components/lib/dynamicdialog/DynamicDialog.vue
Normal file
|
@ -0,0 +1,75 @@
|
|||
<template>
|
||||
<template v-for="(instance, key) in instanceMap" :key="key">
|
||||
<DDialog v-model:visible="instance.visible" :_instance="instance" v-bind="instance.options.props" @hide="onDialogHide(instance)" @after-hide="onDialogAfterHide">
|
||||
<template v-if="instance.options.templates && instance.options.templates.header" #header>
|
||||
<component v-for="(header, index) in getTemplateItems(instance.options.templates.header)" :is="header" :key="index + '_header'"></component>
|
||||
</template>
|
||||
<component :is="instance.content" v-bind="instance.options.emits"></component>
|
||||
<template v-if="instance.options.templates && instance.options.templates.footer" #footer>
|
||||
<component v-for="(footer, index) in getTemplateItems(instance.options.templates.footer)" :is="footer" :key="index + '_footer'"></component>
|
||||
</template>
|
||||
</DDialog>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Dialog from 'primevue/dialog';
|
||||
import DynamicDialogEventBus from 'primevue/dynamicdialogeventbus';
|
||||
import { UniqueComponentId } from 'primevue/utils';
|
||||
|
||||
export default {
|
||||
name: 'DynamicDialog',
|
||||
inheritAttrs: false,
|
||||
data() {
|
||||
return {
|
||||
instanceMap: {}
|
||||
};
|
||||
},
|
||||
openListener: null,
|
||||
closeListener: null,
|
||||
currentInstance: null,
|
||||
mounted() {
|
||||
this.openListener = ({ instance }) => {
|
||||
const key = UniqueComponentId() + '_dynamic_dialog';
|
||||
|
||||
instance.visible = true;
|
||||
instance.key = key;
|
||||
this.instanceMap[key] = instance;
|
||||
};
|
||||
|
||||
this.closeListener = ({ instance, params }) => {
|
||||
const key = instance.key;
|
||||
const currentInstance = this.instanceMap[key];
|
||||
|
||||
if (currentInstance) {
|
||||
currentInstance.visible = false;
|
||||
currentInstance.options.onClose && currentInstance.options.onClose({ data: params, type: 'config-close' });
|
||||
|
||||
this.currentInstance = currentInstance;
|
||||
}
|
||||
};
|
||||
|
||||
DynamicDialogEventBus.on('open', this.openListener);
|
||||
DynamicDialogEventBus.on('close', this.closeListener);
|
||||
},
|
||||
beforeUnmount() {
|
||||
DynamicDialogEventBus.off('open', this.openListener);
|
||||
DynamicDialogEventBus.off('close', this.closeListener);
|
||||
},
|
||||
methods: {
|
||||
onDialogHide(instance) {
|
||||
!this.currentInstance && instance.options.onClose && instance.options.onClose({ type: 'dialog-close' });
|
||||
},
|
||||
onDialogAfterHide() {
|
||||
this.currentInstance && delete this.currentInstance;
|
||||
this.currentInstance = null;
|
||||
},
|
||||
getTemplateItems(template) {
|
||||
return Array.isArray(template) ? template : [template];
|
||||
}
|
||||
},
|
||||
components: {
|
||||
DDialog: Dialog
|
||||
}
|
||||
};
|
||||
</script>
|
9
components/lib/dynamicdialog/package.json
Normal file
9
components/lib/dynamicdialog/package.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"main": "./dynamicdialog.cjs.js",
|
||||
"module": "./dynamicdialog.esm.js",
|
||||
"unpkg": "./dynamicdialog.min.js",
|
||||
"types": "./DynamicDialog.d.ts",
|
||||
"browser": {
|
||||
"./sfc": "./DynamicDialog.vue"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue