UNPKG

ant-design-x-vue

Version:

Craft AI-driven interfaces effortlessly

213 lines (212 loc) 6.17 kB
import { s as L, c as M, m as K, a as q, u as U } from "../../../../chunks/module-chunk.mjs"; import { useStyleInject as W, CSS_IN_JS_INSTANCE as D, ATTR_TOKEN as z, ATTR_MARK as T } from "../../StyleContext.mjs"; import { supportLayer as J } from "../../util.mjs"; import Q from "../useGlobalCache.mjs"; import { updateCSS as I, removeCSS as Z } from "../../../../vc-util/Dom/dynamicCSS.mjs"; import { computed as x } from "vue"; import B from "../../../../vc-util/Dom/canUseDom.mjs"; import { existPath as F, getStyleAndHash as G, ATTR_CACHE_MAP as b, serialize as X } from "./cacheMapUtil.mjs"; const H = B(), Y = "_skip_check_", R = "_multi_value_"; function k(t) { return L(M(t), q).replace(/\{%%%\:[^;];}/g, ";"); } function V(t) { return typeof t == "object" && t && (Y in t || R in t); } function ee(t, c, m) { if (!c) return t; const $ = `.${c}`, _ = m === "low" ? `:where(${$})` : $; return t.split(",").map((s) => { var p; const C = s.trim().split(/\s+/); let v = C[0] || ""; const r = ((p = v.match(/^\w+/)) == null ? void 0 : p[0]) || ""; return v = `${r}${_}${v.slice(r.length)}`, [v, ...C.slice(1)].join(" "); }).join(","); } const O = /* @__PURE__ */ new Set(), fe = void 0, N = (t, c = {}, { root: m, injectHash: $, parentSelectors: _ } = { root: !0, parentSelectors: [] }) => { const { hashId: h, layer: s, path: C, hashPriority: v, transformers: r = [], linters: p = [] } = c; let f = "", y = {}; function j(o) { const n = o.getName(h); if (!y[n]) { const [a] = N(o.style, c, { root: !1, parentSelectors: _ }); y[n] = `@keyframes ${o.getName(h)}${a}`; } } function g(o, n = []) { return o.forEach((a) => { Array.isArray(a) ? g(a, n) : a && n.push(a); }), n; } return g(Array.isArray(t) ? t : [t]).forEach((o) => { const n = typeof o == "string" && !m ? {} : o; if (typeof n == "string") f += `${n} `; else if (n._keyframe) j(n); else { const a = r.reduce((S, e) => { var d; return ((d = e == null ? void 0 : e.visit) == null ? void 0 : d.call(e, S)) || S; }, n); Object.keys(a).forEach((S) => { const e = a[S]; if (typeof e == "object" && e && (S !== "animationName" || !e._keyframe) && !V(e)) { let d = !1, i = S.trim(), l = !1; (m || $) && h ? i.startsWith("@") ? d = !0 : i = ee(S, h, v) : m && !h && (i === "&" || i === "") && (i = "", l = !0); const [u, P] = N(e, c, { root: l, injectHash: d, parentSelectors: [..._, i] }); y = { ...y, ...P }, f += `${i}${u}`; } else { let d = function(l, u) { const P = l.replace(/[A-Z]/g, (w) => `-${w.toLowerCase()}`); let A = u; !U[l] && typeof A == "number" && A !== 0 && (A = `${A}px`), l === "animationName" && (u != null && u._keyframe) && (j(u), A = u.getName(h)), f += `${P}:${A};`; }; const i = (e == null ? void 0 : e.value) ?? e; typeof e == "object" && (e != null && e[R]) && Array.isArray(i) ? i.forEach((l) => { d(S, l); }) : d(S, i); } }); } }), m ? s && J() : f = `{${f}}`, [f, y]; }; function te(t, c) { return K(`${t.join("%")}${c}`); } function ye(t, c) { const m = W(), $ = x(() => { var s; return (s = t.value) == null ? void 0 : s.token._tokenKey; }), _ = x(() => { var s; return [$.value, ...((s = t.value) == null ? void 0 : s.path) || []]; }); let h = H; return Q( "style", _, // Create cache if needed () => { const { path: s, hashId: C, layer: v, nonce: r, clientOnly: p, order: f = 0 } = t.value || {}, y = _.value.join("|"); if (F(y)) { const [l, u] = G(y); if (l) return [l, $.value, u, {}, p, f]; } const j = c(), { hashPriority: g, container: E, transformers: o, linters: n, cache: a } = m.value, [S, e] = N(j, { hashId: C, hashPriority: g, layer: v, path: s == null ? void 0 : s.join("-"), transformers: o, linters: n }), d = k(S), i = te(_.value, d); if (h) { const l = { mark: T, prepend: "queue", attachTo: E }, u = typeof r == "function" ? r() : r; u && (l.csp = { nonce: u }); const P = I(d, i, l); P[D] = a.instanceId, P.setAttribute(z, $.value), Object.keys(e).forEach((A) => { O.has(A) || (O.add(A), I(k(e[A]), `_effect-${A}`, { mark: T, prepend: "queue", attachTo: E })); }); } return [d, $.value, i, e, p, f]; }, // Remove cache if no need ([, , s], C) => { (C || m.value.autoClear) && H && Z(s, { mark: T }); } ), (s) => s; } function ue(t, c = !1) { const m = "style%", $ = Array.from(t.cache.keys()).filter((r) => r.startsWith(m)), _ = {}, h = {}; let s = ""; function C(r, p, f, y = {}) { const j = { ...y, [z]: p, [T]: f }, g = Object.keys(j).map((E) => { const o = j[E]; return o ? `${E}="${o}"` : null; }).filter((E) => E).join(" "); return c ? r : `<style ${g}>${r}</style>`; } return $.map((r) => { const p = r.slice(m.length).replace(/%/g, "|"), [f, y, j, g, E, o] = t.cache.get(r)[1]; if (E) return null; const n = { "data-vc-order": "prependQueue", "data-vc-priority": `${o}` }; let a = C(f, y, j, n); return h[p] = j, g && Object.keys(g).forEach((e) => { _[e] || (_[e] = !0, a += C(k(g[e]), y, `_effect-${e}`, n)); }), [o, a]; }).filter((r) => r).sort((r, p) => r[0] - p[0]).forEach(([, r]) => { s += r; }), s += C(`.${b}{content:"${X(h)}";}`, void 0, void 0, { [b]: b }), s; } export { fe as _cf, ye as default, ue as extractStyle, k as normalizeStyle, N as parseStyle, te as uniqueHash };