postcss-convert-values 7.0.0 → 7.0.2
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/package.json +3 -3
- package/src/index.js +20 -11
- package/types/index.d.ts +7 -10
- package/types/index.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-convert-values",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.2",
|
|
4
4
|
"description": "Convert values with PostCSS (e.g. ms -> s)",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"repository": "cssnano/cssnano",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"browserslist": "^4.23.
|
|
27
|
+
"browserslist": "^4.23.1",
|
|
28
28
|
"postcss-value-parser": "^4.2.0"
|
|
29
29
|
},
|
|
30
30
|
"bugs": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"node": "^18.12.0 || ^20.9.0 || >=22.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"postcss": "^8.4.
|
|
37
|
+
"postcss": "^8.4.39"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"postcss": "^8.4.31"
|
package/src/index.js
CHANGED
|
@@ -39,7 +39,23 @@ const keepWhenZero = new Set([
|
|
|
39
39
|
]);
|
|
40
40
|
|
|
41
41
|
// Can't remove the % on these properties when they're 0 on IE 11
|
|
42
|
-
const
|
|
42
|
+
const keepZeroPercentOnIE11 = new Set(['max-height', 'height', 'min-width']);
|
|
43
|
+
|
|
44
|
+
const keepZeroPercentAlways = new Set([
|
|
45
|
+
'calc',
|
|
46
|
+
'color-mix',
|
|
47
|
+
'min',
|
|
48
|
+
'max',
|
|
49
|
+
'clamp',
|
|
50
|
+
'hsl',
|
|
51
|
+
'hsla',
|
|
52
|
+
'hwb',
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
const keepZeroPercentageInKeyframe = new Set([
|
|
56
|
+
'border-image-width',
|
|
57
|
+
'stroke-dasharray',
|
|
58
|
+
]);
|
|
43
59
|
|
|
44
60
|
/**
|
|
45
61
|
* Numbers without digits after the dot are technically invalid,
|
|
@@ -118,9 +134,9 @@ function shouldKeepZeroUnit(decl, browsers) {
|
|
|
118
134
|
|
|
119
135
|
return (
|
|
120
136
|
(decl.value.includes('%') &&
|
|
121
|
-
|
|
137
|
+
keepZeroPercentOnIE11.has(lowerCasedProp) &&
|
|
122
138
|
browsers.includes('ie 11')) ||
|
|
123
|
-
(lowerCasedProp
|
|
139
|
+
(keepZeroPercentageInKeyframe.has(lowerCasedProp) &&
|
|
124
140
|
parent &&
|
|
125
141
|
parent.parent &&
|
|
126
142
|
parent.parent.type === 'atrule' &&
|
|
@@ -172,14 +188,7 @@ function transform(opts, browsers, decl) {
|
|
|
172
188
|
clampOpacity(node);
|
|
173
189
|
}
|
|
174
190
|
} else if (node.type === 'function') {
|
|
175
|
-
if (
|
|
176
|
-
lowerCasedValue === 'calc' ||
|
|
177
|
-
lowerCasedValue === 'min' ||
|
|
178
|
-
lowerCasedValue === 'max' ||
|
|
179
|
-
lowerCasedValue === 'clamp' ||
|
|
180
|
-
lowerCasedValue === 'hsl' ||
|
|
181
|
-
lowerCasedValue === 'hsla'
|
|
182
|
-
) {
|
|
191
|
+
if (keepZeroPercentAlways.has(lowerCasedValue)) {
|
|
183
192
|
valueParser.walk(node.nodes, (n) => {
|
|
184
193
|
if (n.type === 'word') {
|
|
185
194
|
parseWord(n, opts, true);
|
package/types/index.d.ts
CHANGED
|
@@ -10,22 +10,19 @@ export = pluginCreator;
|
|
|
10
10
|
* @param {Options} opts
|
|
11
11
|
* @return {import('postcss').Plugin}
|
|
12
12
|
*/
|
|
13
|
-
declare function pluginCreator(opts?: Options): import(
|
|
13
|
+
declare function pluginCreator(opts?: Options): import("postcss").Plugin;
|
|
14
14
|
declare namespace pluginCreator {
|
|
15
15
|
export { postcss, ConvertOptions, AutoprefixerOptions, BrowserslistOptions, Options };
|
|
16
16
|
}
|
|
17
|
-
type Options = {
|
|
18
|
-
precision?: false | number;
|
|
19
|
-
} & ConvertOptions & AutoprefixerOptions & BrowserslistOptions;
|
|
20
17
|
declare var postcss: true;
|
|
21
|
-
type ConvertOptions = [
|
|
22
|
-
time?: boolean | undefined;
|
|
23
|
-
length?: boolean | undefined;
|
|
24
|
-
angle?: boolean | undefined;
|
|
25
|
-
}][2];
|
|
18
|
+
type ConvertOptions = Parameters<typeof convert>[2];
|
|
26
19
|
type AutoprefixerOptions = {
|
|
27
20
|
overrideBrowserslist?: string | string[];
|
|
28
21
|
};
|
|
29
|
-
type BrowserslistOptions = Pick<browserslist.Options,
|
|
22
|
+
type BrowserslistOptions = Pick<browserslist.Options, "stats" | "path" | "env">;
|
|
23
|
+
type Options = {
|
|
24
|
+
precision?: false | number;
|
|
25
|
+
} & ConvertOptions & AutoprefixerOptions & BrowserslistOptions;
|
|
26
|
+
import convert = require("./lib/convert.js");
|
|
30
27
|
import browserslist = require("browserslist");
|
|
31
28
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";AAgNA;;;;;GAKG;AAEH;;;;GAIG;AACH,sCAHW,OAAO,GACN,OAAO,SAAS,EAAE,MAAM,CAwBnC;;;;;sBAjCY,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;2BAC7B;IAAE,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAE;2BAC5C,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;eACpD;IAAC,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;CAAC,GAAG,cAAc,GAAG,mBAAmB,GAAG,mBAAmB"}
|