UNPKG

ant-design-x-vue

Version:

Craft AI-driven interfaces effortlessly

542 lines (541 loc) 13.7 kB
import { m as me } from "../useCacheToken.tsx2.mjs"; import { useStyleInject as de, CSS_IN_JS_INSTANCE as pe, ATTR_TOKEN as ae, ATTR_MARK as H } from "../../StyleContext.mjs"; import { supportLayer as ye } from "../../util.mjs"; import Se from "../useGlobalCache.mjs"; import { updateCSS as X, removeCSS as ve } from "../../../../vc-util/Dom/dynamicCSS.mjs"; import { computed as V } from "vue"; import be from "../../../../vc-util/Dom/canUseDom.mjs"; import { existPath as ge, getStyleAndHash as ke, ATTR_CACHE_MAP as U, serialize as Ce } from "./cacheMapUtil.mjs"; var we = { animationIterationCount: 1, aspectRatio: 1, borderImageOutset: 1, borderImageSlice: 1, borderImageWidth: 1, boxFlex: 1, boxFlexGroup: 1, boxOrdinalGroup: 1, columnCount: 1, columns: 1, flex: 1, flexGrow: 1, flexPositive: 1, flexShrink: 1, flexNegative: 1, flexOrder: 1, gridRow: 1, gridRowEnd: 1, gridRowSpan: 1, gridRowStart: 1, gridColumn: 1, gridColumnEnd: 1, gridColumnSpan: 1, gridColumnStart: 1, msGridRow: 1, msGridRowSpan: 1, msGridColumn: 1, msGridColumnSpan: 1, fontWeight: 1, lineHeight: 1, opacity: 1, order: 1, orphans: 1, scale: 1, tabSize: 1, widows: 1, zIndex: 1, zoom: 1, WebkitLineClamp: 1, // SVG-related properties fillOpacity: 1, floodOpacity: 1, stopOpacity: 1, strokeDasharray: 1, strokeDashoffset: 1, strokeMiterlimit: 1, strokeOpacity: 1, strokeWidth: 1 }, ce = "comm", ie = "rule", se = "decl", $e = "@import", Ae = "@keyframes", Ee = "@layer", oe = Math.abs, Z = String.fromCharCode; function fe(e) { return e.trim(); } function L(e, t, n) { return e.replace(t, n); } function xe(e, t, n) { return e.indexOf(t, n); } function P(e, t) { return e.charCodeAt(t) | 0; } function I(e, t, n) { return e.slice(t, n); } function O(e) { return e.length; } function _e(e) { return e.length; } function z(e, t) { return t.push(e), e; } var K = 1, T = 1, le = 0, E = 0, C = 0, N = ""; function B(e, t, n, c, u, p, o, m) { return { value: e, root: t, parent: n, type: c, props: u, children: p, line: K, column: T, length: o, return: "", siblings: m }; } function Oe() { return C; } function je() { return C = E > 0 ? P(N, --E) : 0, T--, C === 10 && (T = 1, K--), C; } function _() { return C = E < le ? P(N, E++) : 0, T++, C === 10 && (T = 1, K++), C; } function j() { return P(N, E); } function G() { return E; } function D(e, t) { return I(N, e, t); } function M(e) { switch (e) { // \0 \t \n \r \s whitespace token case 0: case 9: case 10: case 13: case 32: return 5; // ! + , / > @ ~ isolate token case 33: case 43: case 44: case 47: case 62: case 64: case 126: // ; { } breakpoint token case 59: case 123: case 125: return 4; // : accompanied token case 58: return 3; // " ' ( [ opening delimit token case 34: case 39: case 40: case 91: return 2; // ) ] closing delimit token case 41: case 93: return 1; } return 0; } function Re(e) { return K = T = 1, le = O(N = e), E = 0, []; } function Ie(e) { return N = "", e; } function q(e) { return fe(D(E - 1, F(e === 91 ? e + 2 : e === 40 ? e + 1 : e))); } function Te(e) { for (; (C = j()) && C < 33; ) _(); return M(e) > 2 || M(C) > 3 ? "" : " "; } function Ne(e, t) { for (; --t && _() && !(C < 48 || C > 102 || C > 57 && C < 65 || C > 70 && C < 97); ) ; return D(e, G() + (t < 6 && j() == 32 && _() == 32)); } function F(e) { for (; _(); ) switch (C) { // ] ) " ' case e: return E; // " ' case 34: case 39: e !== 34 && e !== 39 && F(C); break; // ( case 40: e === 41 && F(e); break; // \ case 92: _(); break; } return E; } function Pe(e, t) { for (; _() && e + C !== 57; ) if (e + C === 84 && j() === 47) break; return "/*" + D(t, E - 1) + "*" + Z(e === 47 ? e : _()); } function Me(e) { for (; !M(j()); ) _(); return D(e, E); } function ze(e) { return Ie(W("", null, null, null, [""], e = Re(e), 0, [0], e)); } function W(e, t, n, c, u, p, o, m, $) { for (var i = 0, S = 0, f = o, g = 0, w = 0, k = 0, d = 1, y = 1, l = 1, s = 0, v = "", a = u, b = p, h = c, r = v; y; ) switch (k = s, s = _()) { // ( case 40: if (k != 108 && P(r, f - 1) == 58) { xe(r += L(q(s), "&", "&\f"), "&\f", oe(i ? m[i - 1] : 0)) != -1 && (l = -1); break; } // " ' [ case 34: case 39: case 91: r += q(s); break; // \t \n \r \s case 9: case 10: case 13: case 32: r += Te(k); break; // \ case 92: r += Ne(G() - 1, 7); continue; // / case 47: switch (j()) { case 42: case 47: z(He(Pe(_(), G()), t, n, $), $), (M(k || 1) == 5 || M(j() || 1) == 5) && O(r) && I(r, -1, void 0) !== " " && (r += " "); break; default: r += "/"; } break; // { case 123 * d: m[i++] = O(r) * l; // } ; \0 case 125 * d: case 59: case 0: switch (s) { // \0 } case 0: case 125: y = 0; // ; case 59 + S: l == -1 && (r = L(r, /\f/g, "")), w > 0 && (O(r) - f || d === 0 && k === 47) && z(w > 32 ? te(r + ";", c, n, f - 1, $) : te(L(r, " ", "") + ";", c, n, f - 2, $), $); break; // @ ; case 59: r += ";"; // { rule/at-rule default: if (z(h = ee(r, t, n, i, S, u, m, v, a = [], b = [], f, p), p), s === 123) if (S === 0) W(r, t, h, h, a, p, f, m, b); else switch (g === 99 && P(r, 3) === 110 ? 100 : g) { // d l m s case 100: case 108: case 109: case 115: W(e, h, h, c && z(ee(e, h, h, 0, 0, u, m, v, u, a = [], f, b), b), u, b, f, m, c ? a : b); break; default: W(r, h, h, h, [""], b, 0, m, b); } } i = S = w = 0, d = l = 1, v = r = "", f = o; break; // : case 58: f = 1 + O(r), w = k; default: if (d < 1) { if (s == 123) --d; else if (s == 125 && d++ == 0 && je() == 125) continue; } switch (r += Z(s), s * d) { // & case 38: l = S > 0 ? 1 : (r += "\f", -1); break; // , case 44: m[i++] = (O(r) - 1) * l, l = 1; break; // @ case 64: j() === 45 && (r += q(_())), g = j(), S = f = O(v = r += Me(G())), s++; break; // - case 45: k === 45 && O(r) == 2 && (d = 0); } } return p; } function ee(e, t, n, c, u, p, o, m, $, i, S, f) { for (var g = u - 1, w = u === 0 ? p : [""], k = _e(w), d = 0, y = 0, l = 0; d < c; ++d) for (var s = 0, v = I(e, g + 1, g = oe(y = o[d])), a = e; s < k; ++s) (a = fe(y > 0 ? w[s] + " " + v : L(v, /&\f/g, w[s]))) && ($[l++] = a); return B(e, t, n, u === 0 ? ie : m, $, i, S, f); } function He(e, t, n, c) { return B(e, t, n, ce, Z(Oe()), I(e, 2, -2), 0, c); } function te(e, t, n, c, u) { return B(e, t, n, se, I(e, 0, c), I(e, c + 1, -1), c, u); } function Y(e, t) { for (var n = "", c = 0; c < e.length; c++) n += t(e[c], c, e, t) || ""; return n; } function Le(e, t, n, c) { switch (e.type) { case Ee: if (e.children.length) break; case $e: case se: return e.return = e.return || e.value; case ce: return ""; case Ae: return e.return = e.value + "{" + Y(e.children, c) + "}"; case ie: if (!O(e.value = e.props.join(","))) return ""; } return O(n = Y(e.children, c)) ? e.return = e.value + "{" + n + "}" : ""; } const re = be(), Ge = "_skip_check_", ue = "_multi_value_"; function J(e) { return Y(ze(e), Le).replace(/\{%%%\:[^;];}/g, ";"); } function We(e) { return typeof e == "object" && e && (Ge in e || ue in e); } function Ke(e, t, n) { if (!t) return e; const c = `.${t}`, u = n === "low" ? `:where(${c})` : c; return e.split(",").map((o) => { var S; const m = o.trim().split(/\s+/); let $ = m[0] || ""; const i = ((S = $.match(/^\w+/)) == null ? void 0 : S[0]) || ""; return $ = `${i}${u}${$.slice(i.length)}`, [$, ...m.slice(1)].join(" "); }).join(","); } const ne = /* @__PURE__ */ new Set(), Xe = void 0, Q = (e, t = {}, { root: n, injectHash: c, parentSelectors: u } = { root: !0, parentSelectors: [] }) => { const { hashId: p, layer: o, path: m, hashPriority: $, transformers: i = [], linters: S = [] } = t; let f = "", g = {}; function w(y) { const l = y.getName(p); if (!g[l]) { const [s] = Q(y.style, t, { root: !1, parentSelectors: u }); g[l] = `@keyframes ${y.getName(p)}${s}`; } } function k(y, l = []) { return y.forEach((s) => { Array.isArray(s) ? k(s, l) : s && l.push(s); }), l; } return k(Array.isArray(e) ? e : [e]).forEach((y) => { const l = typeof y == "string" && !n ? {} : y; if (typeof l == "string") f += `${l} `; else if (l._keyframe) w(l); else { const s = i.reduce((v, a) => { var b; return ((b = a == null ? void 0 : a.visit) == null ? void 0 : b.call(a, v)) || v; }, l); Object.keys(s).forEach((v) => { const a = s[v]; if (typeof a == "object" && a && (v !== "animationName" || !a._keyframe) && !We(a)) { let b = !1, h = v.trim(), r = !1; (n || c) && p ? h.startsWith("@") ? b = !0 : h = Ke(v, p, $) : n && !p && (h === "&" || h === "") && (h = "", r = !0); const [A, R] = Q(a, t, { root: r, injectHash: b, parentSelectors: [...u, h] }); g = { ...g, ...R }, f += `${h}${A}`; } else { let b = function(r, A) { const R = r.replace(/[A-Z]/g, (he) => `-${he.toLowerCase()}`); let x = A; !we[r] && typeof x == "number" && x !== 0 && (x = `${x}px`), r === "animationName" && (A != null && A._keyframe) && (w(A), x = A.getName(p)), f += `${R}:${x};`; }; const h = (a == null ? void 0 : a.value) ?? a; typeof a == "object" && (a != null && a[ue]) && Array.isArray(h) ? h.forEach((r) => { b(v, r); }) : b(v, h); } }); } }), n ? o && ye() : f = `{${f}}`, [f, g]; }; function De(e, t) { return me(`${e.join("%")}${t}`); } function Ve(e, t) { const n = de(), c = V(() => { var o; return (o = e.value) == null ? void 0 : o.token._tokenKey; }), u = V(() => { var o; return [c.value, ...((o = e.value) == null ? void 0 : o.path) || []]; }); let p = re; return Se( "style", u, // Create cache if needed () => { const { path: o, hashId: m, layer: $, nonce: i, clientOnly: S, order: f = 0 } = e.value || {}, g = u.value.join("|"); if (ge(g)) { const [r, A] = ke(g); if (r) return [r, c.value, A, {}, S, f]; } const w = t(), { hashPriority: k, container: d, transformers: y, linters: l, cache: s } = n.value, [v, a] = Q(w, { hashId: m, hashPriority: k, layer: $, path: o == null ? void 0 : o.join("-"), transformers: y, linters: l }), b = J(v), h = De(u.value, b); if (p) { const r = { mark: H, prepend: "queue", attachTo: d }, A = typeof i == "function" ? i() : i; A && (r.csp = { nonce: A }); const R = X(b, h, r); R[pe] = s.instanceId, R.setAttribute(ae, c.value), Object.keys(a).forEach((x) => { ne.has(x) || (ne.add(x), X(J(a[x]), `_effect-${x}`, { mark: H, prepend: "queue", attachTo: d })); }); } return [b, c.value, h, a, S, f]; }, // Remove cache if no need ([, , o], m) => { (m || n.value.autoClear) && re && ve(o, { mark: H }); } ), (o) => o; } function et(e, t = !1) { const n = "style%", c = Array.from(e.cache.keys()).filter((i) => i.startsWith(n)), u = {}, p = {}; let o = ""; function m(i, S, f, g = {}) { const w = { ...g, [ae]: S, [H]: f }, k = Object.keys(w).map((d) => { const y = w[d]; return y ? `${d}="${y}"` : null; }).filter((d) => d).join(" "); return t ? i : `<style ${k}>${i}</style>`; } return c.map((i) => { const S = i.slice(n.length).replace(/%/g, "|"), [f, g, w, k, d, y] = e.cache.get(i)[1]; if (d) return null; const l = { "data-vc-order": "prependQueue", "data-vc-priority": `${y}` }; let s = m(f, g, w, l); return p[S] = w, k && Object.keys(k).forEach((a) => { u[a] || (u[a] = !0, s += m(J(k[a]), g, `_effect-${a}`, l)); }), [y, s]; }).filter((i) => i).sort((i, S) => i[0] - S[0]).forEach(([, i]) => { o += i; }), o += m(`.${U}{content:"${Ce(p)}";}`, void 0, void 0, { [U]: U }), o; } export { Xe as _, De as a, we as b, et as e, J as n, Q as p, Ve as u };