1 line
773 B
JavaScript
1 line
773 B
JavaScript
"use strict";var e=require("@csstools/css-calc"),s=require("@csstools/css-parser-algorithms"),o=require("@csstools/css-tokenizer");const n=["mod","rem","round"],t=new RegExp(`^(${n.join("|")})$`,"i"),r=new RegExp(`(${n.join("|")})\\(`,"i");function calc(n){const r=o.tokenize({css:n});return r.some((e=>e[0]===o.TokenType.Function&&t.test(e[4].value)))?s.stringify(e.calcFromComponentValues(s.parseCommaSeparatedListOfComponentValues(r),{precision:5,toCanonicalUnits:!0})):n}const creator=e=>{const s=Object.assign({preserve:!1,onInvalid:""},e);return{postcssPlugin:"postcss-stepped-value-functions",Declaration(e){if(!r.test(e.value))return;const o=calc(e.value);o!==e.value&&(e.cloneBefore({value:o}),s.preserve||e.remove())}}};creator.postcss=!0,module.exports=creator;
|