@csstools/postcss-text-decoration-shorthand 2.2.0 → 2.2.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 Text Decoration Shorthand
2
2
 
3
+ ### 2.2.1 (February 13, 2023)
4
+
5
+ - Updated: `preserve` option defaults to `true`
6
+
3
7
  ### 2.2.0 (February 2, 2023)
4
8
 
5
9
  - Add: `@csstools/color-helpers` dependency for the named colors list.
package/README.md CHANGED
@@ -15,6 +15,7 @@
15
15
  text-decoration: underline;
16
16
  text-decoration: underline wavy purple;
17
17
  text-decoration-thickness: calc(0.01em * 25);
18
+ text-decoration: wavy underline purple 25%;
18
19
  }
19
20
  ```
20
21
 
@@ -53,10 +54,10 @@ instructions for:
53
54
  ### preserve
54
55
 
55
56
  The `preserve` option determines whether the original notation
56
- is preserved. By default, it is not preserved.
57
+ is preserved. By default, it is preserved.
57
58
 
58
59
  ```js
59
- postcssTextDecorationShorthand({ preserve: true })
60
+ postcssTextDecorationShorthand({ preserve: false })
60
61
  ```
61
62
 
62
63
  ```pcss
@@ -70,7 +71,6 @@ postcssTextDecorationShorthand({ preserve: true })
70
71
  text-decoration: underline;
71
72
  text-decoration: underline wavy purple;
72
73
  text-decoration-thickness: calc(0.01em * 25);
73
- text-decoration: wavy underline purple 25%;
74
74
  }
75
75
  ```
76
76
 
package/dist/index.cjs CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";var e=require("@csstools/color-helpers"),t=require("postcss-value-parser");const creator=e=>{const l=Object.assign({preserve:!0},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.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { PluginCreator } from 'postcss';
2
2
  /** postcss-text-decoration-shorthand plugin options */
3
3
  export type pluginOptions = {
4
- /** Preserve the original notation. default: false */
4
+ /** Preserve the original notation. default: true */
5
5
  preserve?: boolean;
6
6
  };
7
7
  declare const creator: PluginCreator<pluginOptions>;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
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};
1
+ import{namedColors as e}from"@csstools/color-helpers";import t from"postcss-value-parser";const creator=e=>{const l=Object.assign({preserve:!0},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.2.0",
4
+ "version": "2.2.1",
5
5
  "contributors": [
6
6
  {
7
7
  "name": "Antonio Laguna",