ant-design-x-vue
Version:
Craft AI-driven interfaces effortlessly
189 lines (188 loc) • 5.12 kB
JavaScript
import { unref as Z, computed as k, toValue as A, createVNode as E, Fragment as _ } from "vue";
import "../../cssinjs/StyleContext.mjs";
import { token2CSSVar as V } from "../../cssinjs/util.mjs";
import N from "../../cssinjs/hooks/useCSSVarRegister.mjs";
import { u as M } from "../../cssinjs/hooks/useStyleRegister/index.tsx2.mjs";
import "../../cssinjs/theme/ThemeCache.mjs";
import "../../warning.mjs";
import "../../cssinjs/transformers/legacyLogicalProperties.mjs";
import ee from "./calc/index.mjs";
import F from "./getCompVarPrefix.mjs";
import H from "./getComponentToken.mjs";
import q from "./getDefaultComponentToken.mjs";
import te from "./maxmin.mjs";
import ne, { merge as re } from "./statistic.mjs";
import oe from "../_util/hooks/useUniqueMemo.mjs";
import se from "../hooks/useCSP.mjs";
function xe(j) {
const {
useCSP: z = se,
useToken: T,
usePrefix: D,
getResetStyles: U,
getCommonStyle: O,
getCompUnitless: P
} = j;
function L(e, S, c, t) {
const i = Array.isArray(e) ? e[0] : e;
function o(r) {
return `${String(i)}${r.slice(0, 1).toUpperCase()}${r.slice(1)}`;
}
const m = (t == null ? void 0 : t.unitless) || {}, u = {
...typeof P == "function" ? P(e) : {},
[o("zIndexPopup")]: !0
};
Object.keys(m).forEach((r) => {
u[o(r)] = m[r];
});
const f = {
...t,
unitless: u,
prefixToken: o
}, s = v(e, S, c, f), l = B(i, c, f);
return (r, a = A(r)) => {
const [, n] = s(A(r), a), [y, d] = l(a);
return [y, n, d];
};
}
function B(e, S, c) {
const {
unitless: t,
injectStyle: i = !0,
prefixToken: o,
ignore: m
} = c, p = ({
rootCls: f,
cssVar: s = {}
}) => {
const {
realToken: l
} = T();
return N({
path: [e],
prefix: s.prefix,
key: s.key,
unitless: t,
ignore: m,
token: l,
scope: f
}, () => {
const r = q(e, l, S), a = H(e, l, r, {
deprecatedTokens: c == null ? void 0 : c.deprecatedTokens
});
return Object.keys(r).forEach((n) => {
a[o(n)] = a[n], delete a[n];
}), a;
}), null;
};
return (f) => {
const {
cssVar: s
} = T();
return [(l) => i && s ? E(_, null, [E(p, {
rootCls: f,
cssVar: s,
component: e
}, null), l]) : l, s == null ? void 0 : s.key];
};
}
function v(e, S, c, t = {}) {
const i = Array.isArray(e) ? e : [e, e], [o] = i, m = i.join("-"), p = j.layer || {
name: "antd"
};
return (u, f = u) => {
const {
theme: s,
realToken: l,
hashId: r,
token: a,
cssVar: n
} = T(), {
rootPrefixCls: y,
iconPrefixCls: d
} = D(), R = z(), x = n ? "css" : "js", J = Z(oe(() => {
const C = /* @__PURE__ */ new Set();
return n && Object.keys(t.unitless || {}).forEach((h) => {
C.add(V(h, n.prefix)), C.add(V(h, F(o, n.prefix)));
}), ee(x, C);
}, [x, o, n == null ? void 0 : n.prefix])), {
max: K,
min: Q
} = te(x), $ = k(() => ({
theme: s.value,
token: a.value,
hashId: r.value,
nonce: () => R.nonce,
clientOnly: t.clientOnly,
layer: p,
// antd is always at top of styles
order: t.order || -999
}));
return typeof U == "function" && M(k(() => ({
...$.value,
clientOnly: !1,
path: ["Shared", y]
})), () => U(a.value, {
prefix: {
rootPrefixCls: y,
iconPrefixCls: d
},
csp: R
})), [M(k(() => ({
...$.value,
path: [m, u, d]
})), () => {
if (t.injectStyle === !1)
return [];
const {
token: C,
flush: h
} = ne(a), g = q(o, l, c), W = `.${u}`, b = H(o, l, g, {
deprecatedTokens: t.deprecatedTokens
});
n && g && typeof g == "object" && Object.keys(g).forEach((w) => {
g[w] = `var(${V(w, F(o, n.prefix))})`;
});
const I = k(() => re(C.value, {
componentCls: W,
prefixCls: u,
iconCls: `.${d}`,
antCls: `.${y}`,
calc: J,
// @ts-ignore
max: K,
// @ts-ignore
min: Q
}, n ? g : b)), X = k(() => S(I.value, {
hashId: r.value,
prefixCls: u,
rootPrefixCls: y,
iconPrefixCls: d
}));
h(o, b);
const Y = typeof O == "function" ? O(I.value, u, f, t.resetFont) : null;
return [t.resetStyle === !1 ? null : Y, X.value];
}), r];
};
}
function G(e, S, c, t = {}) {
const i = v(e, S, c, {
resetStyle: !1,
// Sub Style should default after root one
order: -998,
...t
});
return ({
prefixCls: m,
rootCls: p = m
}) => (i(m, p), null);
}
return {
genStyleHooks: L,
genSubStyleComponent: G,
genComponentStyleHook: v
};
}
export {
xe as default
};