@nextcloud/vue
Version:
Nextcloud vue components
26 lines (25 loc) • 614 B
JavaScript
import Vue, { toRaw } from "vue";
function spawnDialog(dialog, props, onClose = () => {
}) {
const el = document.createElement("div");
const container = typeof props?.container === "string" ? document.querySelector(props.container) || document.body : document.body;
container.appendChild(el);
const vm = new Vue({
el,
name: "VueDialogHelper",
render: (h) => h(dialog, {
props,
on: {
close: (...rest) => {
onClose(...rest.map((v) => toRaw(v)));
vm.$destroy();
el.remove();
}
}
})
});
return vm;
}
export {
spawnDialog
};