sd-component-library
Version:
A Vue3 + Element Plus components library
257 lines (256 loc) • 7.53 kB
JavaScript
import { getCurrentInstance as $, inject as T, ref as y, computed as F, unref as b, watch as B, shallowRef as z, watchEffect as J, readonly as V, getCurrentScope as M, onScopeDispose as R, onMounted as q, nextTick as U, warn as W } from "vue";
const O = "el", G = "is-", v = (e, n, t, r, o) => {
let a = `${e}-${n}`;
return t && (a += `-${t}`), r && (a += `__${r}`), o && (a += `--${o}`), a;
}, L = Symbol("namespaceContextKey"), x = (e) => {
const n = $() ? T(L, y(O)) : y(O);
return F(() => b(n) || O);
}, be = (e, n) => {
const t = x();
return {
namespace: t,
b: (s = "") => v(t.value, e, s, "", ""),
e: (s) => s ? v(t.value, e, "", s, "") : "",
m: (s) => s ? v(t.value, e, "", "", s) : "",
be: (s, c) => s && c ? v(t.value, e, s, c, "") : "",
em: (s, c) => s && c ? v(t.value, e, "", s, c) : "",
bm: (s, c) => s && c ? v(t.value, e, s, "", c) : "",
bem: (s, c, i) => s && c && i ? v(t.value, e, s, c, i) : "",
is: (s, ...c) => {
const i = c.length >= 1 ? c[0] : !0;
return s && i ? `${G}${s}` : "";
},
cssVar: (s) => {
const c = {};
for (const i in s)
s[i] && (c[`--${t.value}-${i}`] = s[i]);
return c;
},
cssVarName: (s) => `--${t.value}-${s}`,
cssVarBlock: (s) => {
const c = {};
for (const i in s)
s[i] && (c[`--${t.value}-${e}-${i}`] = s[i]);
return c;
},
cssVarBlockName: (s) => `--${t.value}-${e}-${s}`
};
};
/**
* @vue/shared v3.5.17
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
process.env.NODE_ENV !== "production" && Object.freeze({});
process.env.NODE_ENV !== "production" && Object.freeze([]);
const Y = () => {
}, H = Object.prototype.hasOwnProperty, N = (e, n) => H.call(e, n), ge = Array.isArray, he = (e) => typeof e == "function", C = (e) => typeof e == "string", D = (e) => e !== null && typeof e == "object", Q = Object.prototype.toString, X = (e) => Q.call(e), Pe = (e) => X(e) === "[object Object]", Z = (e) => {
const n = /* @__PURE__ */ Object.create(null);
return (t) => n[t] || (n[t] = e(t));
}, k = /-(\w)/g, Ne = Z(
(e) => e.replace(k, (n, t) => t ? t.toUpperCase() : "")
);
function ee(e) {
for (var n = -1, t = e == null ? 0 : e.length, r = {}; ++n < t; ) {
var o = e[n];
r[o[0]] = o[1];
}
return r;
}
function te(e) {
return e == null;
}
const Ee = (e) => e === void 0, Ie = (e) => typeof e == "boolean", je = (e) => typeof e == "number", Se = (e) => typeof Element > "u" ? !1 : e instanceof Element, Te = (e) => te(e), Ve = (e) => C(e) ? !Number.isNaN(Number(e)) : !1;
var ne = Object.defineProperty, re = Object.defineProperties, se = Object.getOwnPropertyDescriptors, E = Object.getOwnPropertySymbols, oe = Object.prototype.hasOwnProperty, ae = Object.prototype.propertyIsEnumerable, I = (e, n, t) => n in e ? ne(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t, ce = (e, n) => {
for (var t in n || (n = {}))
oe.call(n, t) && I(e, t, n[t]);
if (E)
for (var t of E(n))
ae.call(n, t) && I(e, t, n[t]);
return e;
}, ie = (e, n) => re(e, se(n));
function ue(e, n) {
var t;
const r = z();
return J(() => {
r.value = e();
}, ie(ce({}, n), {
flush: (t = void 0) != null ? t : "sync"
})), V(r);
}
var j;
const g = typeof window < "u", xe = (e) => typeof e == "string", S = () => {
}, Ce = g && ((j = window == null ? void 0 : window.navigator) == null ? void 0 : j.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
function _(e) {
return typeof e == "function" ? e() : b(e);
}
function le(e, n) {
function t(...r) {
return new Promise((o, a) => {
Promise.resolve(e(() => n.apply(this, r), { fn: n, thisArg: this, args: r })).then(o).catch(a);
});
}
return t;
}
function fe(e, n = {}) {
let t, r, o = S;
const a = (f) => {
clearTimeout(f), o(), o = S;
};
return (f) => {
const p = _(e), u = _(n.maxWait);
return t && a(t), p <= 0 || u !== void 0 && u <= 0 ? (r && (a(r), r = null), Promise.resolve(f())) : new Promise((l, m) => {
o = n.rejectOnCancel ? m : l, u && !r && (r = setTimeout(() => {
t && a(t), r = null, l(f());
}, u)), t = setTimeout(() => {
r && a(r), r = null, l(f());
}, p);
});
};
}
function De(e) {
return e;
}
function pe(e) {
return M() ? (R(e), !0) : !1;
}
function de(e, n = 200, t = {}) {
return le(fe(n, t), e);
}
function Ke(e, n = 200, t = {}) {
const r = y(e.value), o = de(() => {
r.value = e.value;
}, n, t);
return B(e, () => o()), r;
}
function Ae(e, n = !0) {
$() ? q(e) : n ? e() : U(e);
}
function Fe(e, n, t = {}) {
const {
immediate: r = !0
} = t, o = y(!1);
let a = null;
function d() {
a && (clearTimeout(a), a = null);
}
function f() {
o.value = !1, d();
}
function p(...u) {
d(), o.value = !0, a = setTimeout(() => {
o.value = !1, a = null, e(...u);
}, _(n));
}
return r && (o.value = !0, g && p()), pe(f), {
isPending: V(o),
start: p,
stop: f
};
}
class K extends Error {
constructor(n) {
super(n), this.name = "ElementPlusError";
}
}
function Be(e, n) {
throw new K(`[${e}] ${n}`);
}
function me(e, n) {
if (process.env.NODE_ENV !== "production") {
const t = C(e) ? new K(`[${e}] ${n}`) : e;
console.warn(t);
}
}
const A = "__epPropKey", ze = (e) => e, ve = (e) => D(e) && !!e[A], ye = (e, n) => {
if (!D(e) || ve(e))
return e;
const { values: t, required: r, default: o, type: a, validator: d } = e, p = {
type: a,
required: !!r,
validator: t || d ? (u) => {
let l = !1, m = [];
if (t && (m = Array.from(t), N(e, "default") && m.push(o), l || (l = m.includes(u))), d && (l || (l = d(u))), !l && m.length > 0) {
const h = [...new Set(m)].map((P) => JSON.stringify(P)).join(", ");
W(`Invalid prop: validation failed${n ? ` for prop "${n}"` : ""}. Expected one of [${h}], got value ${JSON.stringify(u)}.`);
}
return l;
} : void 0,
[A]: !0
};
return N(e, "default") && (p.default = o), p;
}, Je = (e) => ee(Object.entries(e).map(([n, t]) => [
n,
ye(t, n)
]));
var Me = (e, n) => {
const t = e.__vccOpts || e;
for (const [r, o] of n)
t[r] = o;
return t;
};
const Re = (e, n) => {
if (e.install = (t) => {
for (const r of [e, ...Object.values(n ?? {})])
t.component(r.name, r);
}, n)
for (const [t, r] of Object.entries(n))
e[t] = r;
return e;
}, qe = (e) => (e.install = Y, e), w = {
prefix: Math.floor(Math.random() * 1e4),
current: 0
}, Oe = Symbol("elIdInjection"), _e = () => $() ? T(Oe, w) : w, Ue = (e) => {
const n = _e();
!g && n === w && me("IdInjection", `Looks like you are using server rendering, you must provide a id provider to ensure the hydration process to be succeed
usage: app.provide(ID_INJECTION_KEY, {
prefix: number,
current: number,
})`);
const t = x();
return ue(() => b(e) || `${t.value}-id-${n.prefix}-${n.current++}`);
}, We = Symbol("formContextKey"), Ge = Symbol("formItemContextKey");
export {
Ce as A,
Pe as B,
ye as C,
Ve as D,
Ne as E,
xe as F,
S as G,
_ as H,
pe as I,
Ae as J,
De as K,
x as L,
_e as M,
Y as N,
ue as O,
Me as _,
Ie as a,
Je as b,
g as c,
ze as d,
Ue as e,
O as f,
Fe as g,
ge as h,
he as i,
je as j,
me as k,
C as l,
We as m,
Ge as n,
qe as o,
Ee as p,
Te as q,
Ke as r,
D as s,
Be as t,
be as u,
N as v,
Re as w,
Se as x,
ee as y,
te as z
};