cc-ui-plus
Version:
347 lines (345 loc) • 9.17 kB
JavaScript
import { defineComponent as v, provide as R, renderSlot as w, inject as k, computed as g, onBeforeMount as B, h as q, openBlock as L, createBlock as N, unref as P, withCtx as M } from "vue";
function O(n, e) {
return n.install = (t) => {
t.component(e, n);
}, n;
}
function W(n) {
let e = 0;
for (let t = 0; t < n.length; ++t)
n[t] === "&" && ++e;
return e;
}
const $ = /\s*,(?![^(]*\))\s*/g, K = /\s+/g;
function U(n, e) {
const t = [];
return e.split($).forEach((r) => {
let u = W(r);
if (u) {
if (u === 1) {
n.forEach((o) => {
t.push(r.replace("&", o));
});
return;
}
} else {
n.forEach((o) => {
t.push(
(o && o + " ") + r
);
});
return;
}
let i = [
r
];
for (; u--; ) {
const o = [];
i.forEach((f) => {
n.forEach((s) => {
o.push(f.replace("&", s));
});
}), i = o;
}
i.forEach((o) => t.push(o));
}), t;
}
function Z(n, e) {
const t = [];
return e.split($).forEach((r) => {
n.forEach((u) => {
t.push((u && u + " ") + r);
});
}), t;
}
function D(n) {
let e = [""];
return n.forEach((t) => {
t = t && t.trim(), t && (t.includes("&") ? e = U(e, t) : e = Z(e, t));
}), e.join(", ").replace(K, " ");
}
const F = /[A-Z]/g;
function S(n) {
return n.replace(F, (e) => "-" + e.toLowerCase());
}
function G(n, e = " ") {
return typeof n == "object" && n !== null ? ` {
` + Object.entries(n).map((t) => e + ` ${S(t[0])}: ${t[1]};`).join(`
`) + `
` + e + "}" : `: ${n};`;
}
function H(n, e, t) {
return typeof n == "function" ? n({
context: e.context,
props: t
}) : n;
}
function b(n, e, t, r) {
if (!e)
return "";
const u = H(e, t, r);
if (!u)
return "";
if (typeof u == "string")
return `${n} {
${u}
}`;
const i = Object.keys(u);
if (i.length === 0)
return t.config.keepEmptyBlock ? n + ` {
}` : "";
const o = n ? [
n + " {"
] : [];
return i.forEach((f) => {
const s = u[f];
if (f === "raw") {
o.push(`
` + s + `
`);
return;
}
f = S(f), s != null && o.push(` ${f}${G(s)}`);
}), n && o.push("}"), o.join(`
`);
}
function y(n, e, t) {
!n || n.forEach((r) => {
if (Array.isArray(r))
y(r, e, t);
else if (typeof r == "function") {
const u = r(e);
Array.isArray(u) ? y(u, e, t) : u && t(u);
} else
r && t(r);
});
}
function _(n, e, t, r, u, i) {
const o = n.$;
!o || typeof o == "string" ? e.push(o) : typeof o == "function" ? e.push(o({
context: r.context,
props: u
})) : (o.before && o.before(r.context), !o.$ || typeof o.$ == "string" ? e.push(o.$) : o.$ && e.push(o.$({
context: r.context,
props: u
})));
const f = D(e), s = b(f, n.props, r, u);
i && s && i.insertRule(s), !i && s.length && t.push(s), n.children && y(n.children, {
context: r.context,
props: u
}, (c) => {
if (typeof c == "string") {
const h = b(f, { raw: c }, r, u);
i ? i.insertRule(h) : t.push(h);
} else
_(c, e, t, r, u, i);
}), e.pop(), o && o.after && o.after(r.context);
}
function j(n, e, t, r = !1) {
const u = [];
return _(n, [], u, e, t, r ? n.instance.__styleSheet : void 0), r ? "" : u.join(`
`);
}
function J(n) {
for (var e = 0, t, r = 0, u = n.length; u >= 4; ++r, u -= 4)
t = n.charCodeAt(r) & 255 | (n.charCodeAt(++r) & 255) << 8 | (n.charCodeAt(++r) & 255) << 16 | (n.charCodeAt(++r) & 255) << 24, t = (t & 65535) * 1540483477 + ((t >>> 16) * 59797 << 16), t ^= t >>> 24, e = (t & 65535) * 1540483477 + ((t >>> 16) * 59797 << 16) ^ (e & 65535) * 1540483477 + ((e >>> 16) * 59797 << 16);
switch (u) {
case 3:
e ^= (n.charCodeAt(r + 2) & 255) << 16;
case 2:
e ^= (n.charCodeAt(r + 1) & 255) << 8;
case 1:
e ^= n.charCodeAt(r) & 255, e = (e & 65535) * 1540483477 + ((e >>> 16) * 59797 << 16);
}
return e ^= e >>> 13, e = (e & 65535) * 1540483477 + ((e >>> 16) * 59797 << 16), ((e ^ e >>> 15) >>> 0).toString(36);
}
function x(n) {
if (!n)
return;
const e = n.parentElement;
e && e.removeChild(n);
}
function E(n) {
return document.querySelector(`style[cssr-id="${n}"]`);
}
function Q(n) {
const e = document.createElement("style");
return e.setAttribute("cssr-id", n), e;
}
window && (window.__cssrContext = {});
function z(n) {
const e = n.getAttribute("mount-count");
return e === null ? null : Number(e);
}
function C(n, e) {
n.setAttribute("mount-count", String(e));
}
function A(n, e, t, r) {
const { els: u } = e;
if (t === void 0)
u.forEach(x), e.els = [];
else {
const i = E(t);
if (i && u.includes(i)) {
const o = z(i);
r ? o === null ? console.error(`[css-render/unmount]: The style with target='${t}' is mounted in count mode.`) : o <= 1 ? (x(i), e.els = u.filter((f) => f !== i)) : C(i, o - 1) : o !== null ? console.error(`[css-render/unmount]: The style with target='${t}' is mounted in no-count mode.`) : (x(i), e.els = u.filter((f) => f !== i));
}
}
}
function V(n, e) {
n.push(e);
}
function X(n, e, t, r, u, i, o, f, s) {
if (o && !s) {
if (t === void 0) {
console.error("[css-render/mount]: `id` is required in `boost` mode.");
return;
}
const a = window.__cssrContext;
a[t] || (a[t] = !0, j(e, n, r, o));
return;
}
let c;
const { els: h } = e;
let d;
if (t === void 0 && (d = e.render(r), t = J(d)), s) {
s(t, d != null ? d : e.render(r));
return;
}
const l = E(t);
if (f || l === null) {
if (c = l === null ? Q(t) : l, d === void 0 && (d = e.render(r)), c.textContent = d, l !== null)
return;
if (u) {
const a = document.head.getElementsByTagName("style")[0] || null;
document.head.insertBefore(c, a);
} else
document.head.appendChild(c);
i && C(c, 1), V(h, c);
} else {
const a = z(l);
i ? a === null ? console.error(`[css-render/mount]: The style with id='${t}' has been mounted in no-count mode.`) : C(l, a + 1) : a !== null && console.error(`[css-render/mount]: The style with id='${t}' has been mounted in count mode.`);
}
return l != null ? l : c;
}
function Y(n) {
return j(this, this.instance, n);
}
function ee(n = {}) {
const { target: e, id: t, ssr: r, props: u, count: i = !1, head: o = !1, boost: f = !1, force: s = !1 } = n;
return X(this.instance, this, t != null ? t : e, u, o, i, f, s, r);
}
function ne(n = {}) {
const { id: e, target: t, delay: r = 0, count: u = !1 } = n;
r === 0 ? A(this.instance, this, e != null ? e : t, u) : setTimeout(() => A(this.instance, this, e != null ? e : t, u), r);
}
const m = function(n, e, t, r) {
return {
instance: n,
$: e,
props: t,
children: r,
els: [],
render: Y,
mount: ee,
unmount: ne
};
}, te = function(n, e, t, r) {
return Array.isArray(e) ? m(n, { $: null }, null, e) : Array.isArray(t) ? m(n, e, null, t) : Array.isArray(r) ? m(n, e, t, r) : m(n, e, t, null);
};
function re(n = {}) {
let e = null;
const t = {
c: (...r) => te(t, ...r),
use: (r, ...u) => r.install(t, ...u),
find: E,
context: {},
config: n,
get __styleSheet() {
if (!e) {
const r = document.createElement("style");
return document.head.appendChild(r), e = document.styleSheets[document.styleSheets.length - 1], e;
}
return e;
}
};
return t;
}
const { c: p } = re(), oe = p(".xicon", {
width: "1em",
height: "1em",
display: "inline-flex"
}, [
p("svg", {
width: "1em",
height: "1em"
}),
p("svg:not([fill])", {
fill: "currentColor"
})
]), ue = () => {
oe.mount({ id: "xicons-icon" });
}, T = {
size: [String, Number],
color: String,
tag: String
}, I = Symbol("IconConfigInjection");
v({
name: "IconConfigProvider",
props: T,
setup(n, { slots: e }) {
return R(I, n), () => w(e, "default");
}
});
const ie = "span", fe = v({
name: "Icon",
props: T,
setup(n, { slots: e }) {
const t = k(I, null), r = g(() => {
var o;
const f = (o = n.size) !== null && o !== void 0 ? o : t == null ? void 0 : t.size;
if (f !== void 0)
return typeof f == "number" || /^\d+$/.test(f) ? `${f}px` : f;
}), u = g(() => {
const { color: o } = n;
return o === void 0 ? t ? t.color : void 0 : o;
}), i = g(() => {
var o;
const { tag: f } = n;
return f === void 0 ? (o = t == null ? void 0 : t.tag) !== null && o !== void 0 ? o : ie : f;
});
return B(() => {
ue();
}), () => q(i.value, {
class: "xicon",
style: {
color: u.value,
fontSize: r.value
}
}, [
w(e, "default")
]);
}
}), se = /* @__PURE__ */ v({
__name: "icon",
props: {
color: { default: "inherit" },
size: { default: 16 },
tag: { default: "span" }
},
setup(n) {
return (e, t) => (L(), N(P(fe), {
size: n.size,
color: n.color,
tag: n.tag
}, {
default: M(() => [
w(e.$slots, "default")
]),
_: 3
}, 8, ["size", "color", "tag"]));
}
}), le = O(se, "cc-icon");
export {
le as default
};