UNPKG

ll-package

Version:

2 lines (1 loc) 971 B
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("../../../../../@babel/runtime/helpers/esm/extends.js"),m=require("../../../../../@emotion/unitless/dist/emotion-unitless.esm.js"),f=/url\([^)]+\)|var\([^)]+\)|(\d*\.?\d+)px/g;function x(i,u){const o=Math.pow(10,u+1),l=Math.floor(i*o);return Math.round(l/10)*10/o}const g=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{rootValue:u=16,precision:o=5,mediaQuery:l=!1}=i,a=(n,e)=>{if(!e)return n;const s=parseFloat(e);return s<=1?n:`${x(s/u,o)}rem`};return{visit:n=>{const e=p.default({},n);return Object.entries(n).forEach(s=>{let[t,r]=s;if(typeof r=="string"&&r.includes("px")){const c=r.replace(f,a);e[t]=c}!m.default[t]&&typeof r=="number"&&r!==0&&(e[t]=`${r}px`.replace(f,a));const d=t.trim();if(d.startsWith("@")&&d.includes("px")&&l){const c=t.replace(f,a);e[c]=e[t],delete e[t]}}),e}}},h=g;exports.default=h;