epiphany/node_modules/@csstools/postcss-stepped-value-functions/dist/index.mjs
2023-12-09 22:48:07 -08:00

1 line
785 B
JavaScript

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