sci-pro
Version:
47 lines (46 loc) • 1.32 kB
JavaScript
import { ref as u } from "vue";
import { getStyle as d, addClass as g } from "../utils/dom.mjs";
import { isString as p } from "../utils/type.mjs";
import { createLoadingComponent as m } from "./loading.mjs";
const i = Symbol("ElementLoading");
function v(e) {
var a, o;
const t = m({
...e
}), s = d((a = t.target) == null ? void 0 : a.value, "position");
return ["absolute", "fixed", "sticky"].includes(s) || g((o = t.target) == null ? void 0 : o.value, "loading-relative"), t.target.value.appendChild(t.$el), t;
}
const c = (e, t) => {
const s = t.instance, a = (n) => {
const r = p(n) && (s == null ? void 0 : s[n]) || n;
return r && u(r);
}, o = (n) => a(e.getAttribute(`sci-loading-${n}`)), l = {
text: o("text"),
svg: o("svg"),
svgViewBox: o("svgViewBox"),
spinner: o("spinner"),
background: o("background"),
customClass: o("customClass"),
target: e,
visible: o("visible") ?? !0
};
e[i] = {
options: l,
instance: v(l)
};
}, L = {
mounted(e, t) {
t.value && c(e, t);
},
updated(e, t) {
const s = e[i];
t.oldValue !== t.value && (t.value && !t.oldValue ? c(e, t) : s == null || s.instance.close());
},
unmounted(e) {
var t;
(t = e[i]) == null || t.instance.close(), e[i] = null;
}
};
export {
L as vLoading
};