epiphany/node_modules/postcss-place/dist/index.cjs
2023-12-09 22:48:07 -08:00

1 line
809 B
JavaScript

"use strict";var e=require("postcss-value-parser");function onCSSDeclaration(r,o,s){var n;const a=null==(n=r.prop.toLowerCase().match(t))?void 0:n[1];if(!a)return;let l;try{l=e(r.value)}catch(e){r.warn(o,`Failed to parse value '${r.value}'. Leaving the original value intact.`)}if(void 0===l)return;let i=[];i=l.nodes.length?l.nodes.filter((e=>"word"===e.type||"function"===e.type)).map((t=>e.stringify(t))):[e.stringify(l.nodes)],r.cloneBefore({prop:`align-${a}`,value:i[0]}),r.cloneBefore({prop:`justify-${a}`,value:i[1]||i[0]}),s.preserve||r.remove()}const t=/^place-(content|items|self)/,creator=e=>{const r=Object.assign({preserve:!0},e);return{postcssPlugin:"postcss-place",Declaration:(e,{result:o})=>{t.test(e.prop.toLowerCase())&&onCSSDeclaration(e,o,r)}}};creator.postcss=!0,module.exports=creator;