primevue-mirror/packages/primevue/src/dialogservice/DialogService.js

29 lines
1.0 KiB
JavaScript
Raw Normal View History

2022-09-06 12:03:37 +00:00
import DynamicDialogEventBus from 'primevue/dynamicdialogeventbus';
2023-05-15 09:50:24 +00:00
import { PrimeVueDialogSymbol } from 'primevue/usedialog';
import { markRaw } from 'vue';
2022-09-06 12:03:37 +00:00
export default {
install: (app) => {
const DialogService = {
open: (content, options) => {
const instance = {
content: content && markRaw(content),
options: options || {},
data: options && options.data,
close: (params) => {
DynamicDialogEventBus.emit('close', { instance, params });
}
2022-09-14 11:26:01 +00:00
};
2022-09-06 12:03:37 +00:00
DynamicDialogEventBus.emit('open', { instance });
return instance;
}
};
2023-05-15 09:50:24 +00:00
// app.config.unwrapInjectedRef = true; // Remove it after Vue 3.3. Details: https://vuejs.org/guide/components/provide-inject.html#working-with-reactivity
2022-09-06 12:03:37 +00:00
app.config.globalProperties.$dialog = DialogService;
app.provide(PrimeVueDialogSymbol, DialogService);
}
2022-09-14 11:26:01 +00:00
};