UNPKG

@nextcloud/vue

Version:
41 lines (40 loc) 1.43 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const Vue = require("vue"); const _interopDefault = (e) => e && e.__esModule ? e : { default: e }; const Vue__default = /* @__PURE__ */ _interopDefault(Vue); function spawnDialog(dialog, props = {}, optionsOrOnClose = {}, onClose = () => { }) { if (typeof optionsOrOnClose === "function") { onClose = optionsOrOnClose; optionsOrOnClose = {}; } let { container } = optionsOrOnClose; if ("container" in props && typeof props.container === "string") { container ??= props.container; } const resolvedContainer = typeof container === "string" && document.querySelector(container) || document.body; const element = resolvedContainer.appendChild(document.createElement("div")); const vm = new Vue__default.default({ el: element, name: "VueDialogHelper", render: (h) => h(dialog, { props: { // If dialog has no `container` prop passing a falsy value does nothing // Otherwise it is expected that `null` disables teleport and mounts dialog in place like NcDialog/NcModal container: null, ...props }, on: { close: (...rest) => { onClose(...rest.map((v) => Vue.toRaw(v))); vm.$destroy(); element.remove(); } } }) }); return vm; } exports.spawnDialog = spawnDialog; //# sourceMappingURL=dialog.cjs.map