UNPKG

vexip-ui

Version:

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

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