@csstools/postcss-stepped-value-functions 2.0.1 → 2.1.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 +12 -0
- package/README.md +0 -20
- package/dist/calc.d.ts +1 -0
- package/dist/checks.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.mjs +1 -1
- package/package.json +10 -10
- package/dist/mod.d.ts +0 -5
- package/dist/options.d.ts +0 -10
- package/dist/rem.d.ts +0 -5
- package/dist/round.d.ts +0 -5
- package/dist/utils.d.ts +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changes to PostCSS Stepped Value Functions
|
|
2
2
|
|
|
3
|
+
### 2.1.1 (April 10, 2023)
|
|
4
|
+
|
|
5
|
+
- Updated `@csstools/css-tokenizer` to `2.1.1` (patch)
|
|
6
|
+
- Updated `@csstools/css-parser-algorithms` to `2.1.1` (patch)
|
|
7
|
+
- Updated `@csstools/css-calc` to `1.1.1` (patch)
|
|
8
|
+
|
|
9
|
+
### 2.1.0 (February 21, 2023)
|
|
10
|
+
|
|
11
|
+
- Removed: warnings on `var()` or otherwise unconvertible values (doesn't affect the output, non-breaking)
|
|
12
|
+
- Added: `@csstools/css-calc`
|
|
13
|
+
- Added: unit conversions (`mod(735ms, 0.1s)`)
|
|
14
|
+
|
|
3
15
|
### 2.0.1 (January 28, 2023)
|
|
4
16
|
|
|
5
17
|
- Improve `types` declaration in `package.json`
|
package/README.md
CHANGED
|
@@ -106,26 +106,6 @@ postcssSteppedValueFunctions({ preserve: true })
|
|
|
106
106
|
}
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
### onInvalid
|
|
110
|
-
|
|
111
|
-
`onInvalid` option allows you to assign the `warn` value so you can get warnings when the usage of the functions is wrong.
|
|
112
|
-
|
|
113
|
-
```js
|
|
114
|
-
postcssSteppedValueFunctions({ onInvalid: 'warn' })
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
```pcss
|
|
118
|
-
.invalid {
|
|
119
|
-
font-size: mod(18px, 5rem);
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
Will produce on the terminal:
|
|
124
|
-
|
|
125
|
-
```txt
|
|
126
|
-
[postcss-stepped-value-functions]: Failed to transform mod(18px, 5rem) as the units don't match
|
|
127
|
-
```
|
|
128
|
-
|
|
129
109
|
[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
|
|
130
110
|
[css-url]: https://cssdb.org/#stepped-value-functions
|
|
131
111
|
[discord]: https://discord.gg/bUadyRwkJS
|
package/dist/calc.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function calc(css: string): string;
|
package/dist/checks.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const checks: string[];
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("
|
|
1
|
+
"use strict";var e=require("@csstools/css-calc"),o=require("@csstools/css-parser-algorithms"),s=require("@csstools/css-tokenizer");const n=["mod(","rem(","round("];function calc(t){const r=s.tokenizer({css:t}),c=[];for(;!r.endOfFile();)c.push(r.nextToken());c.push(r.nextToken());const i=o.parseCommaSeparatedListOfComponentValues(c,{});let a=!1;for(let e=0;e<i.length;e++){const s=i[e];for(let e=0;e<s.length;e++){const t=s[e];if(o.isFunctionNode(t)&&n.includes(t.getName().toLowerCase()+"(")){a=!0;break}(o.isSimpleBlockNode(t)||o.isFunctionNode(t))&&t.walk(((e,s)=>{if("number"!=typeof s)return;const t=e.node;return o.isFunctionNode(t)&&n.includes(t.getName().toLowerCase()+"(")?(a=!0,!1):void 0}))}}return a?e.calcFromComponentValues(i,{precision:5,toCanonicalUnits:!0}).map((e=>e.map((e=>s.stringify(...e.tokens()))).join(""))).join(","):t}const creator=e=>{const o=Object.assign({preserve:!1,onInvalid:""},e);return{postcssPlugin:"postcss-stepped-value-functions",Declaration(e){if(!n.some((o=>e.value.toLowerCase().includes(o))))return;const s=calc(e.value);s!==e.value&&(e.cloneBefore({value:s}),o.preserve||e.remove())}}};creator.postcss=!0,module.exports=creator;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { PluginCreator } from 'postcss';
|
|
2
|
-
|
|
3
|
-
export type
|
|
2
|
+
/** postcss-stepped-value-functions plugin options */
|
|
3
|
+
export type pluginOptions = {
|
|
4
|
+
/** Preserve the original notation. default: false */
|
|
5
|
+
preserve?: boolean;
|
|
6
|
+
};
|
|
4
7
|
declare const creator: PluginCreator<pluginOptions>;
|
|
5
8
|
export default creator;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e
|
|
1
|
+
import{calcFromComponentValues as e}from"@csstools/css-calc";import{parseCommaSeparatedListOfComponentValues as o,isFunctionNode as s,isSimpleBlockNode as t}from"@csstools/css-parser-algorithms";import{tokenizer as n,stringify as r}from"@csstools/css-tokenizer";const c=["mod(","rem(","round("];function calc(l){const a=n({css:l}),i=[];for(;!a.endOfFile();)i.push(a.nextToken());i.push(a.nextToken());const u=o(i,{});let p=!1;for(let e=0;e<u.length;e++){const o=u[e];for(let e=0;e<o.length;e++){const n=o[e];if(s(n)&&c.includes(n.getName().toLowerCase()+"(")){p=!0;break}(t(n)||s(n))&&n.walk(((e,o)=>{if("number"!=typeof o)return;const t=e.node;return s(t)&&c.includes(t.getName().toLowerCase()+"(")?(p=!0,!1):void 0}))}}return p?e(u,{precision:5,toCanonicalUnits:!0}).map((e=>e.map((e=>r(...e.tokens()))).join(""))).join(","):l}const creator=e=>{const o=Object.assign({preserve:!1,onInvalid:""},e);return{postcssPlugin:"postcss-stepped-value-functions",Declaration(e){if(!c.some((o=>e.value.toLowerCase().includes(o))))return;const s=calc(e.value);s!==e.value&&(e.cloneBefore({value:s}),o.preserve||e.remove())}}};creator.postcss=!0;export{creator 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": "2.
|
|
4
|
+
"version": "2.1.1",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
7
7
|
"name": "Antonio Laguna",
|
|
@@ -39,22 +39,22 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"
|
|
42
|
+
"@csstools/css-calc": "^1.1.1",
|
|
43
|
+
"@csstools/css-parser-algorithms": "^2.1.1",
|
|
44
|
+
"@csstools/css-tokenizer": "^2.1.1"
|
|
43
45
|
},
|
|
44
46
|
"peerDependencies": {
|
|
45
47
|
"postcss": "^8.4"
|
|
46
48
|
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@csstools/postcss-tape": "*"
|
|
51
|
+
},
|
|
47
52
|
"scripts": {
|
|
48
|
-
"prebuild": "npm run clean",
|
|
49
53
|
"build": "rollup -c ../../rollup/default.mjs",
|
|
50
|
-
"clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true }); fs.mkdirSync('./dist');\"",
|
|
51
54
|
"docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs",
|
|
52
|
-
"lint": "
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"prepublishOnly": "npm run clean && npm run build && npm run test",
|
|
56
|
-
"test": "node .tape.mjs && npm run test:exports",
|
|
57
|
-
"test:exports": "node ./test/_import.mjs && node ./test/_require.cjs",
|
|
55
|
+
"lint": "node ../../.github/bin/format-package-json.mjs",
|
|
56
|
+
"prepublishOnly": "npm run build && npm run test",
|
|
57
|
+
"test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs",
|
|
58
58
|
"test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
|
|
59
59
|
},
|
|
60
60
|
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-stepped-value-functions#readme",
|
package/dist/mod.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Declaration, Result } from 'postcss';
|
|
2
|
-
import type { pluginOptions } from './options';
|
|
3
|
-
declare const modFunctionCheck = "mod(";
|
|
4
|
-
declare function transformModFunction(decl: Declaration, result: Result, options: pluginOptions): string | undefined;
|
|
5
|
-
export { modFunctionCheck, transformModFunction };
|
package/dist/options.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** postcss-stepped-value-functions plugin options */
|
|
2
|
-
export type pluginOptions = {
|
|
3
|
-
/** Preserve the original notation. default: false */
|
|
4
|
-
preserve?: boolean;
|
|
5
|
-
/**
|
|
6
|
-
* Set `warn` to get warnings when the usage of the functions is incorrect.
|
|
7
|
-
* default: _not set_
|
|
8
|
-
*/
|
|
9
|
-
onInvalid?: 'warn';
|
|
10
|
-
};
|
package/dist/rem.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Declaration, Result } from 'postcss';
|
|
2
|
-
import type { pluginOptions } from './options';
|
|
3
|
-
declare const remFunctionCheck = "rem(";
|
|
4
|
-
declare function transformRemFunction(decl: Declaration, result: Result, options: pluginOptions): string | undefined;
|
|
5
|
-
export { remFunctionCheck, transformRemFunction };
|
package/dist/round.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Declaration, Result } from 'postcss';
|
|
2
|
-
import type { pluginOptions } from './options';
|
|
3
|
-
declare const roundFunctionCheck = "round(";
|
|
4
|
-
declare function transformRoundFunction(decl: Declaration, result: Result, options: pluginOptions): string | undefined;
|
|
5
|
-
export { roundFunctionCheck, transformRoundFunction };
|
package/dist/utils.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import valueParser from 'postcss-value-parser';
|
|
2
|
-
import type { FunctionNode, Node, WordNode } from 'postcss-value-parser';
|
|
3
|
-
import type { Declaration, Result } from 'postcss';
|
|
4
|
-
import type { pluginOptions } from './options';
|
|
5
|
-
export declare function isVarNode(node: Node): boolean;
|
|
6
|
-
export declare function validateArgumentsAndTypes(node: FunctionNode, decl: Declaration, result: Result, options: pluginOptions): valueParser.Dimension[] | undefined;
|
|
7
|
-
export declare function optionallyWarn(decl: Declaration, result: Result, message: string, options: pluginOptions): void;
|
|
8
|
-
export declare function functionNodeToWordNode(fn: FunctionNode): WordNode;
|