@csstools/postcss-ic-unit 3.0.3 → 3.0.4

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,12 @@
1
1
  # Changes to PostCSS IC Unit
2
2
 
3
+ ### 3.0.4
4
+
5
+ _February 19, 2024_
6
+
7
+ - Reuse code with `@csstools/utilities`
8
+ - Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.1.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#310) (minor)
9
+
3
10
  ### 3.0.3
4
11
 
5
12
  _December 15, 2023_
@@ -13,11 +20,4 @@ _October 9, 2023_
13
20
 
14
21
  - Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.2`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#302) (patch)
15
22
 
16
- ### 3.0.1
17
-
18
- _September 18, 2023_
19
-
20
- - Improve performance
21
- - Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.1`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#301) (patch)
22
-
23
23
  [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-ic-unit/CHANGELOG.md)
package/README.md CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
 
4
4
  [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-ic-unit.svg" height="20">][npm-url]
5
- [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/ic-unit.svg" height="20">][css-url]
6
5
  [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url]
7
6
  [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
7
+ <br><br>
8
+ [<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/ic-unit.svg" height="20">][css-url]
9
+ [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/ic-unit.svg" height="20">][css-url]
8
10
 
9
11
  [PostCSS IC Unit] lets you use the ic length unit, following the [CSS Values and Units Module] specification.
10
12
 
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@csstools/postcss-progressive-custom-properties"),s=require("postcss-value-parser");function hasFallback(e){const s=e.parent;if(!s)return!1;const t=e.prop.toLowerCase(),r=s.index(e);for(let e=0;e<r;e++){const r=s.nodes[e];if("decl"===r.type&&r.prop.toLowerCase()===t)return!0}return!1}function hasSupportsAtRuleAncestor(e){let s=e.parent;for(;s;)if("atrule"===s.type){if("supports"===s.name.toLowerCase()&&/\(font-size: \d+ic\)/i.test(s.params))return!0;s=s.parent}else s=s.parent;return!1}const t=/ic\b/i,basePlugin=e=>({postcssPlugin:"postcss-ic-unit",Declaration(r){if(!t.test(r.value))return;if(hasFallback(r))return;if(hasSupportsAtRuleAncestor(r))return;const o=s(r.value);o.walk((e=>{if(!e.type||"word"!==e.type)return;const t=s.unit(e.value);t&&"ic"===t.unit.toLowerCase()&&(e.value=`${t.number}em`)}));const n=String(o);n!==r.value&&(r.cloneBefore({value:n}),e?.preserve||r.remove())}});basePlugin.postcss=!0;const postcssPlugin=s=>{const t=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},s);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-ic-unit",plugins:[e(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0,module.exports=postcssPlugin;
1
+ "use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("postcss-value-parser"),r=require("@csstools/utilities");const t=/ic\b/i,o=/\(font-size: \d+ic\)/i,basePlugin=s=>({postcssPlugin:"postcss-ic-unit",Declaration(i){if(!t.test(i.value))return;if(r.hasFallback(i))return;if(r.hasSupportsAtRuleAncestor(i,o))return;const u=e(i.value);u.walk((s=>{if(!s.type||"word"!==s.type)return;const r=e.unit(s.value);r&&"ic"===r.unit.toLowerCase()&&(s.value=`${r.number}em`)}));const c=String(u);c!==i.value&&(i.cloneBefore({value:c}),s?.preserve||i.remove())}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},e);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-ic-unit",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0,module.exports=postcssPlugin;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import e from"@csstools/postcss-progressive-custom-properties";import s from"postcss-value-parser";function hasFallback(e){const s=e.parent;if(!s)return!1;const t=e.prop.toLowerCase(),r=s.index(e);for(let e=0;e<r;e++){const r=s.nodes[e];if("decl"===r.type&&r.prop.toLowerCase()===t)return!0}return!1}function hasSupportsAtRuleAncestor(e){let s=e.parent;for(;s;)if("atrule"===s.type){if("supports"===s.name.toLowerCase()&&/\(font-size: \d+ic\)/i.test(s.params))return!0;s=s.parent}else s=s.parent;return!1}const t=/ic\b/i,basePlugin=e=>({postcssPlugin:"postcss-ic-unit",Declaration(r){if(!t.test(r.value))return;if(hasFallback(r))return;if(hasSupportsAtRuleAncestor(r))return;const o=s(r.value);o.walk((e=>{if(!e.type||"word"!==e.type)return;const t=s.unit(e.value);t&&"ic"===t.unit.toLowerCase()&&(e.value=`${t.number}em`)}));const n=String(o);n!==r.value&&(r.cloneBefore({value:n}),e?.preserve||r.remove())}});basePlugin.postcss=!0;const postcssPlugin=s=>{const t=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},s);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-ic-unit",plugins:[e(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default};
1
+ import s from"@csstools/postcss-progressive-custom-properties";import e from"postcss-value-parser";import{hasFallback as t,hasSupportsAtRuleAncestor as r}from"@csstools/utilities";const o=/ic\b/i,i=/\(font-size: \d+ic\)/i,basePlugin=s=>({postcssPlugin:"postcss-ic-unit",Declaration(n){if(!o.test(n.value))return;if(t(n))return;if(r(n,i))return;const c=e(n.value);c.walk((s=>{if(!s.type||"word"!==s.type)return;const t=e.unit(s.value);t&&"ic"===t.unit.toLowerCase()&&(s.value=`${t.number}em`)}));const u=String(c);u!==n.value&&(n.cloneBefore({value:u}),s?.preserve||n.remove())}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},e);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-ic-unit",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@csstools/postcss-ic-unit",
3
3
  "description": "Use the ic length unit",
4
- "version": "3.0.3",
4
+ "version": "3.0.4",
5
5
  "author": "Jonathan Neal <jonathantneal@hotmail.com>",
6
6
  "license": "MIT-0",
7
7
  "funding": [
@@ -38,7 +38,8 @@
38
38
  "dist"
39
39
  ],
40
40
  "dependencies": {
41
- "@csstools/postcss-progressive-custom-properties": "^3.0.3",
41
+ "@csstools/postcss-progressive-custom-properties": "^3.1.0",
42
+ "@csstools/utilities": "^1.0.0",
42
43
  "postcss-value-parser": "^4.2.0"
43
44
  },
44
45
  "peerDependencies": {