ant-design-x-vue
Version:
Craft AI-driven interfaces effortlessly
32 lines (31 loc) • 957 B
JavaScript
import { b as u } from "../hooks/useStyleRegister/index.tsx2.mjs";
const l = /url\([^)]+\)|var\([^)]+\)|(\d*\.?\d+)px/g;
function d(s, i) {
const o = Math.pow(10, i + 1), c = Math.floor(s * o);
return Math.round(c / 10) * 10 / o;
}
const h = (s = {}) => {
const { rootValue: i = 16, precision: o = 5, mediaQuery: c = !1 } = s, p = (n, e) => {
if (!e) return n;
const t = parseFloat(e);
return t <= 1 ? n : `${d(t / i, o)}rem`;
};
return { visit: (n) => {
const e = { ...n };
return Object.entries(n).forEach(([t, r]) => {
if (typeof r == "string" && r.includes("px")) {
const a = r.replace(l, p);
e[t] = a;
}
!u[t] && typeof r == "number" && r !== 0 && (e[t] = `${r}px`.replace(l, p));
const f = t.trim();
if (f.startsWith("@") && f.includes("px") && c) {
const a = t.replace(l, p);
e[a] = e[t], delete e[t];
}
}), e;
} };
};
export {
h as default
};