UNPKG

@extclp/vexip-ui

Version:

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

78 lines (77 loc) 3.06 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 r, destroyObject as A } from "@vexip-ui/utils"; import { confirmProps as T } from "./props.mjs"; import c from "./confirm.vue2.mjs"; c.name = "Confirm"; class l { 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, o) { var p; if (!r) return; typeof t == "string" && (o ? t = { title: n, content: t, confirmType: o } : t = { content: t, confirmType: n }); const i = { ...this.defaults, ...t }; return i.icon && typeof i.icon == "object" && (i.icon = _(i.icon)), (p = this._getInstance()) == null ? void 0 : p.openConfirm(i); } close() { var t; (t = this._getInstance()) == null || t.closeConfirm(); } config(t) { this.defaults = { ...this.defaults, ...t }; } clone() { const t = new l(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: o, ...i } = n; this.config(i), this._mountedApp = t, (o || !t.config.globalProperties.$confirm) && (t.config.globalProperties[o || "$confirm"] = this); } transferTo(t) { if (!r) return; const n = d(t); n && (this._wrapper = n, this._instance ? this._mountedEl && this._wrapper.appendChild(this._mountedEl) : this._getInstance()); } _getInstance() { if (!this._instance && r) { if (!this._mountedApp) console.warn("[vexip-ui:Confirm]: App missing, the plugin maybe not installed."), this._container = document.createElement("div"), this._innerApp = u(c), this._instance = this._innerApp.mount(this._container); else { const t = f(c, 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 l(); export { v as Confirm, l as ConfirmManager, T as confirmProps }; //# sourceMappingURL=index.mjs.map