UNPKG

@extclp/vexip-ui

Version:

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

74 lines (73 loc) 2.97 kB
var a = Object.defineProperty; var h = (s, t, n) => t in s ? a(s, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : s[t] = n; var e = (s, t, n) => h(s, typeof t != "symbol" ? t + "" : t, n); import { markRaw as _, render as m, createApp as u, createVNode as f } from "vue"; import "./confirm.vue.mjs"; import { unrefElement as d, proxyExposed as g } from "@vexip-ui/hooks"; import { isClient as o, destroyObject as A } from "@vexip-ui/utils"; import { confirmProps as T } from "./props.mjs"; import p from "./confirm.vue2.mjs"; p.name = "Confirm"; class c { constructor(t = {}) { e(this, "name"); e(this, "defaults"); e(this, "_mountedApp"); e(this, "_instance"); e(this, "_innerApp"); e(this, "_container"); e(this, "_wrapper"); e(this, "_mountedEl"); this._mountedApp = null, this._instance = null, this._innerApp = null, this._container = null, this._wrapper = null, this._mountedEl = null, this.name = "Confirm", this.defaults = {}, this.config(t); } open(t, n, r) { var l; if (!o) return; typeof t == "string" && (r ? t = { title: n, content: t, confirmType: r } : t = { content: t, confirmType: n }); const i = { ...this.defaults, ...t }; return i.icon && typeof i.icon == "object" && (i.icon = _(i.icon)), (l = this._getInstance()) == null ? void 0 : l.openConfirm(i); } config(t) { this.defaults = { ...this.defaults, ...t }; } clone() { const t = new c(this.defaults); return t._mountedApp = this._mountedApp, t; } destroy() { var t, n; this._mountedEl && ((t = this._wrapper) == null || t.removeChild(this._mountedEl)), (n = this._innerApp) == null || n.unmount(), this._container && m(null, this._container), A(this); } isDestroyed() { return !1; } install(t, n = {}) { const { property: r, ...i } = n; this.config(i), this._mountedApp = t, (r || !t.config.globalProperties.$confirm) && (t.config.globalProperties[r || "$confirm"] = this); } transferTo(t) { if (!o) return; const n = d(t); n && (this._wrapper = n, this._instance ? this._mountedEl && this._wrapper.appendChild(this._mountedEl) : this._getInstance()); } _getInstance() { if (!this._instance && o) { if (!this._mountedApp) console.warn("[vexip-ui:Confirm]: App missing, the plugin maybe not installed."), this._container = document.createElement("div"), this._innerApp = u(p), this._instance = this._innerApp.mount(this._container); else { const t = f(p, null, null); this._container = document.createElement("div"), t.appContext = this._mountedApp._context, m(t, this._container), this._instance = g(t); } this._mountedEl = this._container.firstElementChild, (this._wrapper || document.body).appendChild(this._mountedEl); } return this._instance; } } const v = new c(); export { v as Confirm, c as ConfirmManager, T as confirmProps }; //# sourceMappingURL=index.mjs.map