@csstools/postcss-text-decoration-shorthand 2.0.1 → 2.2.0
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 +8 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changes to PostCSS Text Decoration Shorthand
|
|
2
2
|
|
|
3
|
+
### 2.2.0 (February 2, 2023)
|
|
4
|
+
|
|
5
|
+
- Add: `@csstools/color-helpers` dependency for the named colors list.
|
|
6
|
+
|
|
7
|
+
### 2.1.0 (January 28, 2023)
|
|
8
|
+
|
|
9
|
+
- Add: support for multiple line values (`text-decoration: overline underline;`)
|
|
10
|
+
|
|
3
11
|
### 2.0.1 (January 28, 2023)
|
|
4
12
|
|
|
5
13
|
- Improve `types` declaration in `package.json`
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("postcss-value-parser");const creator=
|
|
1
|
+
"use strict";var e=require("@csstools/color-helpers"),t=require("postcss-value-parser");const creator=e=>{const l=Object.assign({preserve:!1},e);return{postcssPlugin:"postcss-text-decoration-shorthand",prepare(){const e=new Map;return{OnceExit:()=>{e.clear()},Declaration:i=>{if("text-decoration"!==i.prop.toLowerCase())return;const a=i.parent.index(i);if(i.parent.nodes.some((t=>"decl"===t.type&&"text-decoration"===t.prop.toLowerCase()&&e.get(i.value)===t.value&&i.parent.index(t)!==a)))return;const c=t(i.value),u=c.nodes.filter((e=>"space"!==e.type&&"comment"!==e.type));if(u.find((e=>"var"===e.value.toLowerCase()&&"function"===e.type)))return;if(u.find((e=>"word"===e.type&&o.includes(e.value))))return;const p={line:[],style:null,color:null,thickness:null};for(let e=0;e<u.length;e++){const o=u[e];if(p.line.length||"word"!==o.type||!r.includes(o.value.toLowerCase()))if(p.line.length||"word"!==o.type||"none"!==o.value.toLowerCase())if(p.style||"word"!==o.type||!n.includes(o.value.toLowerCase()))if(p.thickness||"word"!==o.type||!s.includes(o.value.toLowerCase()))if(p.thickness||"function"!==o.type||"calc"!==o.value.toLowerCase())if(p.color||!nodeIsAColor(o)){if("word"!==o.type)return;{let e;try{e=t.unit(o.value)}catch(e){return}if(!e||!e.unit)return;p.thickness=o,"%"===e.unit&&(p.thickness={type:"function",value:"calc",nodes:[{type:"word",value:"0.01em"},{type:"space",value:" "},{type:"word",value:"*"},{type:"space",value:" "},{type:"word",value:e.number}]})}}else p.color=o;else p.thickness=o;else p.thickness=o;else p.style=o;else p.line.push(o);else{const t=o;let n=o;for(;;){const t=u[e+1];if(!t||"word"!==t.type||!r.includes(t.value.toLowerCase()))break;n=t,e++}p.line=c.nodes.slice(c.nodes.indexOf(t),c.nodes.indexOf(n)+1)}}p.line.length||p.line.push({type:"word",value:"none"}),p.style||(p.style={type:"word",value:"solid"}),p.color||(p.color={type:"word",value:"currentColor"});const d=t.stringify(p.line);if(i.value.toLowerCase()===d.toLowerCase()){const e=i.next();return void(e&&"decl"===e.type&&"text-decoration"===e.prop.toLowerCase()||i.cloneBefore({prop:"-webkit-text-decoration",value:d}))}i.cloneBefore({prop:"text-decoration",value:d});const v=t.stringify([...p.line,{type:"space",value:" "},p.style,{type:"space",value:" "},p.color]);p.thickness&&i.cloneBefore({prop:"text-decoration",value:v}),p.thickness&&i.cloneBefore({prop:"text-decoration-thickness",value:t.stringify([p.thickness])}),e.set(i.value,d),e.set(v,d),l.preserve||i.remove()}}}}};function nodeIsAColor(e){return!("word"!==e.type||!e.value.startsWith("#"))||(!("word"!==e.type||!i.includes(e.value.toLowerCase()))||!("function"!==e.type||!l.includes(e.value.toLowerCase())))}creator.postcss=!0;const o=["unset","inherit","initial","revert","revert-layer"],r=["underline","overline","line-through","blink","spelling-error","grammar-error"],n=["solid","double","dotted","dashed","wavy"],s=["auto","from-font"],l=["rgb","rgba","hsl","hsla","hwb","lch","lab","color","oklch","oklab"],i=["currentcolor","transparent",...Object.keys(e.namedColors)];module.exports=creator;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"postcss-value-parser";const creator=
|
|
1
|
+
import{namedColors as e}from"@csstools/color-helpers";import t from"postcss-value-parser";const creator=e=>{const l=Object.assign({preserve:!1},e);return{postcssPlugin:"postcss-text-decoration-shorthand",prepare(){const e=new Map;return{OnceExit:()=>{e.clear()},Declaration:a=>{if("text-decoration"!==a.prop.toLowerCase())return;const i=a.parent.index(a);if(a.parent.nodes.some((t=>"decl"===t.type&&"text-decoration"===t.prop.toLowerCase()&&e.get(a.value)===t.value&&a.parent.index(t)!==i)))return;const c=t(a.value),u=c.nodes.filter((e=>"space"!==e.type&&"comment"!==e.type));if(u.find((e=>"var"===e.value.toLowerCase()&&"function"===e.type)))return;if(u.find((e=>"word"===e.type&&o.includes(e.value))))return;const p={line:[],style:null,color:null,thickness:null};for(let e=0;e<u.length;e++){const o=u[e];if(p.line.length||"word"!==o.type||!r.includes(o.value.toLowerCase()))if(p.line.length||"word"!==o.type||"none"!==o.value.toLowerCase())if(p.style||"word"!==o.type||!n.includes(o.value.toLowerCase()))if(p.thickness||"word"!==o.type||!s.includes(o.value.toLowerCase()))if(p.thickness||"function"!==o.type||"calc"!==o.value.toLowerCase())if(p.color||!nodeIsAColor(o)){if("word"!==o.type)return;{let e;try{e=t.unit(o.value)}catch(e){return}if(!e||!e.unit)return;p.thickness=o,"%"===e.unit&&(p.thickness={type:"function",value:"calc",nodes:[{type:"word",value:"0.01em"},{type:"space",value:" "},{type:"word",value:"*"},{type:"space",value:" "},{type:"word",value:e.number}]})}}else p.color=o;else p.thickness=o;else p.thickness=o;else p.style=o;else p.line.push(o);else{const t=o;let n=o;for(;;){const t=u[e+1];if(!t||"word"!==t.type||!r.includes(t.value.toLowerCase()))break;n=t,e++}p.line=c.nodes.slice(c.nodes.indexOf(t),c.nodes.indexOf(n)+1)}}p.line.length||p.line.push({type:"word",value:"none"}),p.style||(p.style={type:"word",value:"solid"}),p.color||(p.color={type:"word",value:"currentColor"});const d=t.stringify(p.line);if(a.value.toLowerCase()===d.toLowerCase()){const e=a.next();return void(e&&"decl"===e.type&&"text-decoration"===e.prop.toLowerCase()||a.cloneBefore({prop:"-webkit-text-decoration",value:d}))}a.cloneBefore({prop:"text-decoration",value:d});const v=t.stringify([...p.line,{type:"space",value:" "},p.style,{type:"space",value:" "},p.color]);p.thickness&&a.cloneBefore({prop:"text-decoration",value:v}),p.thickness&&a.cloneBefore({prop:"text-decoration-thickness",value:t.stringify([p.thickness])}),e.set(a.value,d),e.set(v,d),l.preserve||a.remove()}}}}};function nodeIsAColor(e){return!("word"!==e.type||!e.value.startsWith("#"))||(!("word"!==e.type||!a.includes(e.value.toLowerCase()))||!("function"!==e.type||!l.includes(e.value.toLowerCase())))}creator.postcss=!0;const o=["unset","inherit","initial","revert","revert-layer"],r=["underline","overline","line-through","blink","spelling-error","grammar-error"],n=["solid","double","dotted","dashed","wavy"],s=["auto","from-font"],l=["rgb","rgba","hsl","hsla","hwb","lch","lab","color","oklch","oklab"],a=["currentcolor","transparent",...Object.keys(e)];export{creator as default};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csstools/postcss-text-decoration-shorthand",
|
|
3
3
|
"description": "Use text-decoration in it's shorthand form in CSS",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
7
7
|
"name": "Antonio Laguna",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
+
"@csstools/color-helpers": "^1.0.0",
|
|
42
43
|
"postcss-value-parser": "^4.2.0"
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|