epiphany/node_modules/postcss-place/dist/index.mjs

2 lines
798 B
JavaScript
Raw Normal View History

2023-12-09 22:48:07 -08:00
import e from"postcss-value-parser";function onCSSDeclaration(o,r,s){var n;const a=null==(n=o.prop.toLowerCase().match(t))?void 0:n[1];if(!a)return;let l;try{l=e(o.value)}catch(e){o.warn(r,`Failed to parse value '${o.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)],o.cloneBefore({prop:`align-${a}`,value:i[0]}),o.cloneBefore({prop:`justify-${a}`,value:i[1]||i[0]}),s.preserve||o.remove()}const t=/^place-(content|items|self)/,creator=e=>{const o=Object.assign({preserve:!0},e);return{postcssPlugin:"postcss-place",Declaration:(e,{result:r})=>{t.test(e.prop.toLowerCase())&&onCSSDeclaration(e,r,o)}}};creator.postcss=!0;export{creator as default};