UNPKG

vexip-ui

Version:

A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good

65 lines (64 loc) 2.74 kB
var h = Object.defineProperty; var a = (s, n, t) => n in s ? h(s, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[n] = t; var e = (s, n, t) => a(s, typeof n != "symbol" ? n + "" : n, t); import { render as r, createApp as c, createVNode as m } from "vue"; import "./contextmenu.vue.mjs"; import { proxyExposed as d, unrefElement as g } from "@vexip-ui/hooks"; import { isClient as p, destroyObject as f } from "@vexip-ui/utils"; import u from "./contextmenu.vue2.mjs"; class x { constructor() { e(this, "name"); e(this, "_mountedApp"); e(this, "_instance"); e(this, "_innerApp"); e(this, "_container"); e(this, "_pending"); e(this, "_wrapper"); e(this, "_mountedEl"); this._mountedApp = null, this._instance = null, this._innerApp = null, this._container = null, this._pending = null, this._wrapper = null, this._mountedEl = null, this.name = "Contextmenu"; } open(n) { if (!p) return; const { target: t = document.body, ...o } = n; return this._pending = this._getInstance(t).openContextmenu(o), this._pending; } destroy() { var n, t; this._mountedEl && ((n = this._wrapper) == null || n.removeChild(this._mountedEl)), (t = this._innerApp) == null || t.unmount(), this._container && r(null, this._container), f(this); } isDestroyed() { return !1; } install(n, t = {}) { const { property: o } = t; this._mountedApp = n, (o || !n.config.globalProperties.$contextmenu) && (n.config.globalProperties[o || "$contextmenu"] = this); } _getInstance(n) { var t, o; if (p) { if (this._pending) { let i = this._innerApp, l = this._container; const _ = () => { i == null || i.unmount(), l && r(null, l), i = null, l = null; }; this._pending.finally(_), (t = this._instance) == null || t.handleCancel(); } else (o = this._innerApp) == null || o.unmount(), this._container && r(null, this._container); if (this._pending = null, !this._mountedApp) console.warn("[vexip-ui:Contextmenu]: App missing, the plugin maybe not installed."), this._container = document.createElement("div"), this._innerApp = c(u), this._instance = this._innerApp.mount(this._container); else { const i = m(u, null, null); this._container = document.createElement("div"), i.appContext = this._mountedApp._context, r(i, this._container), this._instance = d(i); } return this._mountedEl = this._container.firstElementChild, this._wrapper = g(n) || document.body, this._wrapper.appendChild(this._mountedEl), this._instance; } } } const v = new x(); export { v as Contextmenu, x as ContextmenuManager }; //# sourceMappingURL=index.mjs.map