@csstools/postcss-stepped-value-functions 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changes to PostCSS Stepped Value Functions
2
2
 
3
+ ### 1.0.1 (July 8, 2022)
4
+
5
+ - Fix case insensitive matching.
6
+
3
7
  ### 1.0.0 (May 2, 2022)
4
8
 
5
9
  - Initial version
package/README.md CHANGED
@@ -1,9 +1,6 @@
1
1
  # PostCSS Stepped Value Functions [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
2
2
 
3
- [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-stepped-value-functions.svg" height="20">][npm-url]
4
- [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/stepped-value-functions.svg" height="20">][css-url]
5
- [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url]
6
- [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
3
+ [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-stepped-value-functions.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/stepped-value-functions.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
7
4
 
8
5
  [PostCSS Stepped Value Functions] lets you use `round`, `rem` and `mod` stepped value functions, following the [CSS Values 4].
9
6
 
@@ -58,7 +55,7 @@ instructions for:
58
55
 
59
56
  ## ⚠️ About custom properties
60
57
 
61
- Given the dynamic nature of custom properties it's impossible to know what the variable value is which means the plugin can't compute a final value for the stylesheet.
58
+ Given the dynamic nature of custom properties it's impossible to know what the variable value is, which means the plugin can't compute a final value for the stylesheet.
62
59
 
63
60
  Because of that, any usage that contains a `var` is skipped.
64
61
 
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=e(require("postcss-value-parser"));function n(e,n,r,a){const o=[];let l=!1;if(e.nodes.forEach((e=>{"word"!==e.type?function(e){return"function"===e.type&&"var"===e.value}(e)&&(l=!0):o.push(e)})),l)return void u(n,r,`Failed to transform ${n.value} as variables can't be processed.`,a);if(2!==o.length)return void u(n,r,`Failed to transform ${n.value} as it's expecting 2 arguments instead of ${o.length}`,a);const i=t.default.unit(o[0].value),s=t.default.unit(o[1].value);if(i&&s){if(i.unit===s.unit)return[i,s];u(n,r,`Failed to transform ${n.value} as the units don't match`,a)}}function u(e,t,n,u){"warn"===u.onInvalid&&e.warn(t,n)}function r(e){delete e.nodes;const t=e;return t.type="word",t}var a;!function(e){e.Nearest="nearest",e.Up="up",e.Down="down",e.ToZero="to-zero"}(a||(a={}));const o=/^[a-z|-]+$/i;const l=e=>{const l=Object.assign({preserve:!1,onInvalid:""},e);return{postcssPlugin:"postcss-stepped-value-functions",Declaration(e,{result:i}){const s=["mod(","rem(","round("].some((t=>e.value.includes(t)));if(!e||!s)return;const c=e.clone();if(e.value.includes("mod(")){const e=function(e,u,a){const o=t.default(e.value);return o.walk((t=>{if("function"!==t.type||"mod"!==t.value)return;const o=n(t,e,u,a);if(!o)return;const[l,i]=o,s=Number(l.number),c=Number(i.number),d=(s%c+c)%c;"number"!=typeof d||isNaN(d)||(r(t).value=0===d?"0":`${d}${l.unit}`)})),o.toString()}(c,i,l);e&&(c.value=e)}if(c.value.includes("rem(")){const e=function(e,u,a){const o=t.default(e.value);return o.walk((t=>{if("function"!==t.type||"rem"!==t.value)return;const o=n(t,e,u,a);if(!o)return;const[l,i]=o,s=Number(l.number)%Number(i.number);("number"==typeof s||isNaN(s))&&(r(t).value=0===s?"0":`${s}${l.unit}`)})),o.toString()}(c,i,l);e&&(c.value=e)}if(c.value.includes("round(")){const e=function(e,n,l){const i=t.default(e.value);return i.walk((i=>{if("function"!==i.type||"round"!==i.value)return;if(3!==i.nodes.length&&5!==i.nodes.length)return void u(e,n,`Failed to transform ${e.value} as the amount of arguments isn't valid`,l);const s=i.nodes.filter((e=>"word"===e.type)),c=s[0].value;let d,f,v;if(o.test(c)){var m,p;if(!Object.values(a).includes(c))return void u(e,n,`Failed to transform ${e.value} as ${c} is not a valid rounding strategy.`,l);d=c,f=t.default.unit((null==s||null==(m=s[1])?void 0:m.value)||""),v=t.default.unit((null==s||null==(p=s[2])?void 0:p.value)||"")}else{var b,h;d=a.Nearest,f=t.default.unit((null==s||null==(b=s[0])?void 0:b.value)||""),v=t.default.unit((null==s||null==(h=s[1])?void 0:h.value)||"")}if(!f||!v)return;if(f.unit!==v.unit)return void u(e,n,`Failed to transform ${e.value} as the units don't match`,l);const N=Number(f.number),$=Number(v.number);let g;switch(d){case a.Down:g=Math.floor(N/$)*$;break;case a.Up:g=Math.ceil(N/$)*$;break;case a.ToZero:g=Math.trunc(N/$)*$;break;case a.Nearest:default:g=Math.round(N/$)*$}"number"!=typeof g||isNaN(g)||(r(i).value=0===g?"0":`${g}${f.unit}`)})),i.toString()}(c,i,l);e&&(c.value=e)}e.value!==c.value&&(l.preserve?e.cloneBefore({value:c.value}):e.value=c.value)}}};l.postcss=!0,module.exports=l;
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=e(require("postcss-value-parser"));function n(e,n,o,r){const a=[];let s=!1;if(e.nodes.forEach((e=>{"word"!==e.type?function(e){return"function"===e.type&&"var"===e.value.toLowerCase()}(e)&&(s=!0):a.push(e)})),s)return void u(n,o,`Failed to transform ${n.value} as variables can't be processed.`,r);if(2!==a.length)return void u(n,o,`Failed to transform ${n.value} as it's expecting 2 arguments instead of ${a.length}`,r);const l=t.default.unit(a[0].value),i=t.default.unit(a[1].value);if(l&&i){if(l.unit===i.unit)return[l,i];u(n,o,`Failed to transform ${n.value} as the units don't match`,r)}}function u(e,t,n,u){"warn"===u.onInvalid&&e.warn(t,n)}function o(e){delete e.nodes;const t=e;return t.type="word",t}var r;!function(e){e.Nearest="nearest",e.Up="up",e.Down="down",e.ToZero="to-zero"}(r||(r={}));const a=/^[a-z|-]+$/i;const s=e=>{const s=Object.assign({preserve:!1,onInvalid:""},e);return{postcssPlugin:"postcss-stepped-value-functions",Declaration(e,{result:l}){const i=["mod(","rem(","round("].some((t=>e.value.toLowerCase().includes(t)));if(!e||!i)return;const c=e.clone();if(c.value.toLowerCase().includes("mod(")){const e=function(e,u,r){const a=t.default(e.value);return a.walk((t=>{if("function"!==t.type||"mod"!==t.value.toLowerCase())return;const a=n(t,e,u,r);if(!a)return;const[s,l]=a,i=Number(s.number),c=Number(l.number),d=(i%c+c)%c;"number"!=typeof d||isNaN(d)||(o(t).value=0===d?"0":`${d}${s.unit}`)}),!0),a.toString()}(c,l,s);e&&(c.value=e)}if(c.value.toLowerCase().includes("rem(")){const e=function(e,u,r){const a=t.default(e.value);return a.walk((t=>{if("function"!==t.type||"rem"!==t.value.toLowerCase())return;const a=n(t,e,u,r);if(!a)return;const[s,l]=a,i=Number(s.number)%Number(l.number);("number"==typeof i||isNaN(i))&&(o(t).value=0===i?"0":`${i}${s.unit}`)}),!0),a.toString()}(c,l,s);e&&(c.value=e)}if(c.value.toLowerCase().includes("round(")){const e=function(e,n,s){const l=t.default(e.value);return l.walk((l=>{if("function"!==l.type||"round"!==l.value.toLowerCase())return;if(3!==l.nodes.length&&5!==l.nodes.length)return void u(e,n,`Failed to transform ${e.value} as the amount of arguments isn't valid`,s);const i=l.nodes.filter((e=>"word"===e.type)),c=i[0].value;let d,f,v;if(a.test(c.toLowerCase())){var m,p;if(!Object.values(r).includes(c.toLowerCase()))return void u(e,n,`Failed to transform ${e.value} as ${c} is not a valid rounding strategy.`,s);d=c.toLowerCase(),f=t.default.unit((null==i||null==(m=i[1])?void 0:m.value)||""),v=t.default.unit((null==i||null==(p=i[2])?void 0:p.value)||"")}else{var b,w;d=r.Nearest,f=t.default.unit((null==i||null==(b=i[0])?void 0:b.value)||""),v=t.default.unit((null==i||null==(w=i[1])?void 0:w.value)||"")}if(!f||!v)return;if(f.unit!==v.unit)return void u(e,n,`Failed to transform ${e.value} as the units don't match`,s);const h=Number(f.number),N=Number(v.number);let $;switch(d){case r.Down:$=Math.floor(h/N)*N;break;case r.Up:$=Math.ceil(h/N)*N;break;case r.ToZero:$=Math.trunc(h/N)*N;break;case r.Nearest:default:$=Math.round(h/N)*N}"number"!=typeof $||isNaN($)||(o(l).value=0===$?"0":`${$}${f.unit}`)}),!0),l.toString()}(c,l,s);e&&(c.value=e)}e.value!==c.value&&(e.before(c),s.preserve||e.remove())}}};s.postcss=!0,module.exports=s;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import e from"postcss-value-parser";function n(n,u,r,o){const a=[];let l=!1;if(n.nodes.forEach((e=>{"word"!==e.type?function(e){return"function"===e.type&&"var"===e.value}(e)&&(l=!0):a.push(e)})),l)return void t(u,r,`Failed to transform ${u.value} as variables can't be processed.`,o);if(2!==a.length)return void t(u,r,`Failed to transform ${u.value} as it's expecting 2 arguments instead of ${a.length}`,o);const s=e.unit(a[0].value),i=e.unit(a[1].value);if(s&&i){if(s.unit===i.unit)return[s,i];t(u,r,`Failed to transform ${u.value} as the units don't match`,o)}}function t(e,n,t,u){"warn"===u.onInvalid&&e.warn(n,t)}function u(e){delete e.nodes;const n=e;return n.type="word",n}var r;!function(e){e.Nearest="nearest",e.Up="up",e.Down="down",e.ToZero="to-zero"}(r||(r={}));const o=/^[a-z|-]+$/i;const a=a=>{const l=Object.assign({preserve:!1,onInvalid:""},a);return{postcssPlugin:"postcss-stepped-value-functions",Declaration(a,{result:s}){const i=["mod(","rem(","round("].some((e=>a.value.includes(e)));if(!a||!i)return;const c=a.clone();if(a.value.includes("mod(")){const t=function(t,r,o){const a=e(t.value);return a.walk((e=>{if("function"!==e.type||"mod"!==e.value)return;const a=n(e,t,r,o);if(!a)return;const[l,s]=a,i=Number(l.number),c=Number(s.number),v=(i%c+c)%c;"number"!=typeof v||isNaN(v)||(u(e).value=0===v?"0":`${v}${l.unit}`)})),a.toString()}(c,s,l);t&&(c.value=t)}if(c.value.includes("rem(")){const t=function(t,r,o){const a=e(t.value);return a.walk((e=>{if("function"!==e.type||"rem"!==e.value)return;const a=n(e,t,r,o);if(!a)return;const[l,s]=a,i=Number(l.number)%Number(s.number);("number"==typeof i||isNaN(i))&&(u(e).value=0===i?"0":`${i}${l.unit}`)})),a.toString()}(c,s,l);t&&(c.value=t)}if(c.value.includes("round(")){const n=function(n,a,l){const s=e(n.value);return s.walk((s=>{if("function"!==s.type||"round"!==s.value)return;if(3!==s.nodes.length&&5!==s.nodes.length)return void t(n,a,`Failed to transform ${n.value} as the amount of arguments isn't valid`,l);const i=s.nodes.filter((e=>"word"===e.type)),c=i[0].value;let v,d,f;if(o.test(c)){var m,p;if(!Object.values(r).includes(c))return void t(n,a,`Failed to transform ${n.value} as ${c} is not a valid rounding strategy.`,l);v=c,d=e.unit((null==i||null==(m=i[1])?void 0:m.value)||""),f=e.unit((null==i||null==(p=i[2])?void 0:p.value)||"")}else{var b,h;v=r.Nearest,d=e.unit((null==i||null==(b=i[0])?void 0:b.value)||""),f=e.unit((null==i||null==(h=i[1])?void 0:h.value)||"")}if(!d||!f)return;if(d.unit!==f.unit)return void t(n,a,`Failed to transform ${n.value} as the units don't match`,l);const N=Number(d.number),$=Number(f.number);let g;switch(v){case r.Down:g=Math.floor(N/$)*$;break;case r.Up:g=Math.ceil(N/$)*$;break;case r.ToZero:g=Math.trunc(N/$)*$;break;case r.Nearest:default:g=Math.round(N/$)*$}"number"!=typeof g||isNaN(g)||(u(s).value=0===g?"0":`${g}${d.unit}`)})),s.toString()}(c,s,l);n&&(c.value=n)}a.value!==c.value&&(l.preserve?a.cloneBefore({value:c.value}):a.value=c.value)}}};a.postcss=!0;export{a as default};
1
+ import e from"postcss-value-parser";function t(t,o,r,u){const a=[];let s=!1;if(t.nodes.forEach((e=>{"word"!==e.type?function(e){return"function"===e.type&&"var"===e.value.toLowerCase()}(e)&&(s=!0):a.push(e)})),s)return void n(o,r,`Failed to transform ${o.value} as variables can't be processed.`,u);if(2!==a.length)return void n(o,r,`Failed to transform ${o.value} as it's expecting 2 arguments instead of ${a.length}`,u);const i=e.unit(a[0].value),l=e.unit(a[1].value);if(i&&l){if(i.unit===l.unit)return[i,l];n(o,r,`Failed to transform ${o.value} as the units don't match`,u)}}function n(e,t,n,o){"warn"===o.onInvalid&&e.warn(t,n)}function o(e){delete e.nodes;const t=e;return t.type="word",t}var r;!function(e){e.Nearest="nearest",e.Up="up",e.Down="down",e.ToZero="to-zero"}(r||(r={}));const u=/^[a-z|-]+$/i;const a=a=>{const s=Object.assign({preserve:!1,onInvalid:""},a);return{postcssPlugin:"postcss-stepped-value-functions",Declaration(a,{result:i}){const l=["mod(","rem(","round("].some((e=>a.value.toLowerCase().includes(e)));if(!a||!l)return;const c=a.clone();if(c.value.toLowerCase().includes("mod(")){const n=function(n,r,u){const a=e(n.value);return a.walk((e=>{if("function"!==e.type||"mod"!==e.value.toLowerCase())return;const a=t(e,n,r,u);if(!a)return;const[s,i]=a,l=Number(s.number),c=Number(i.number),v=(l%c+c)%c;"number"!=typeof v||isNaN(v)||(o(e).value=0===v?"0":`${v}${s.unit}`)}),!0),a.toString()}(c,i,s);n&&(c.value=n)}if(c.value.toLowerCase().includes("rem(")){const n=function(n,r,u){const a=e(n.value);return a.walk((e=>{if("function"!==e.type||"rem"!==e.value.toLowerCase())return;const a=t(e,n,r,u);if(!a)return;const[s,i]=a,l=Number(s.number)%Number(i.number);("number"==typeof l||isNaN(l))&&(o(e).value=0===l?"0":`${l}${s.unit}`)}),!0),a.toString()}(c,i,s);n&&(c.value=n)}if(c.value.toLowerCase().includes("round(")){const t=function(t,a,s){const i=e(t.value);return i.walk((i=>{if("function"!==i.type||"round"!==i.value.toLowerCase())return;if(3!==i.nodes.length&&5!==i.nodes.length)return void n(t,a,`Failed to transform ${t.value} as the amount of arguments isn't valid`,s);const l=i.nodes.filter((e=>"word"===e.type)),c=l[0].value;let v,d,f;if(u.test(c.toLowerCase())){var m,p;if(!Object.values(r).includes(c.toLowerCase()))return void n(t,a,`Failed to transform ${t.value} as ${c} is not a valid rounding strategy.`,s);v=c.toLowerCase(),d=e.unit((null==l||null==(m=l[1])?void 0:m.value)||""),f=e.unit((null==l||null==(p=l[2])?void 0:p.value)||"")}else{var b,w;v=r.Nearest,d=e.unit((null==l||null==(b=l[0])?void 0:b.value)||""),f=e.unit((null==l||null==(w=l[1])?void 0:w.value)||"")}if(!d||!f)return;if(d.unit!==f.unit)return void n(t,a,`Failed to transform ${t.value} as the units don't match`,s);const h=Number(d.number),N=Number(f.number);let $;switch(v){case r.Down:$=Math.floor(h/N)*N;break;case r.Up:$=Math.ceil(h/N)*N;break;case r.ToZero:$=Math.trunc(h/N)*N;break;case r.Nearest:default:$=Math.round(h/N)*N}"number"!=typeof $||isNaN($)||(o(i).value=0===$?"0":`${$}${d.unit}`)}),!0),i.toString()}(c,i,s);t&&(c.value=t)}a.value!==c.value&&(a.before(c),s.preserve||a.remove())}}};a.postcss=!0;export{a as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@csstools/postcss-stepped-value-functions",
3
3
  "description": "Use round, rem and mod functions in CSS",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "contributors": [
6
6
  {
7
7
  "name": "Antonio Laguna",
@@ -9,7 +9,7 @@
9
9
  "url": "https://antonio.laguna.es"
10
10
  },
11
11
  {
12
- "name": "Romain Menke ",
12
+ "name": "Romain Menke",
13
13
  "email": "romainmenke@gmail.com"
14
14
  }
15
15
  ],
@@ -41,7 +41,7 @@
41
41
  "postcss-value-parser": "^4.2.0"
42
42
  },
43
43
  "peerDependencies": {
44
- "postcss": "^8.3"
44
+ "postcss": "^8.2"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "rollup -c ../../rollup/default.js",