tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.cab1fce
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 +380 -1
- package/LICENSE +1 -2
- package/README.md +8 -4
- package/colors.d.ts +3 -0
- package/colors.js +2 -1
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -1
- package/defaultTheme.d.ts +3 -0
- package/defaultTheme.js +2 -1
- package/lib/cli-peer-dependencies.js +10 -5
- package/lib/cli.js +311 -213
- package/lib/constants.js +9 -9
- package/lib/corePluginList.js +11 -1
- package/lib/corePlugins.js +1895 -1773
- package/lib/css/preflight.css +19 -13
- package/lib/featureFlags.js +22 -16
- package/lib/index.js +17 -8
- package/lib/lib/cacheInvalidation.js +69 -0
- package/lib/lib/collapseAdjacentRules.js +30 -14
- package/lib/lib/collapseDuplicateDeclarations.js +80 -0
- package/lib/lib/defaultExtractor.js +187 -0
- package/lib/lib/detectNesting.js +17 -2
- package/lib/lib/evaluateTailwindFunctions.js +40 -24
- package/lib/lib/expandApplyAtRules.js +414 -157
- package/lib/lib/expandTailwindAtRules.js +156 -151
- package/lib/lib/generateRules.js +402 -68
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +45 -36
- package/lib/lib/partitionApplyAtRules.js +53 -0
- package/lib/lib/regex.js +53 -0
- package/lib/lib/resolveDefaultsAtRules.js +105 -90
- package/lib/lib/setupContextUtils.js +416 -291
- package/lib/lib/setupTrackingContext.js +60 -56
- package/lib/lib/sharedState.js +38 -15
- package/lib/lib/substituteScreenAtRules.js +9 -6
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +17 -0
- package/lib/postcss-plugins/nesting/plugin.js +85 -0
- package/lib/processTailwindFeatures.js +21 -9
- package/lib/public/colors.js +244 -248
- package/lib/public/resolve-config.js +5 -5
- package/lib/util/buildMediaQuery.js +13 -24
- package/lib/util/cloneDeep.js +1 -1
- package/lib/util/cloneNodes.js +12 -1
- package/lib/util/color.js +43 -32
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +13 -17
- package/lib/util/dataTypes.js +114 -74
- package/lib/util/defaults.js +6 -0
- package/lib/util/escapeClassName.js +5 -5
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +2 -4
- package/lib/util/formatVariantSelector.js +194 -0
- package/lib/util/getAllConfigs.js +13 -5
- package/lib/util/hashConfig.js +5 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +1 -1
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +35 -19
- package/lib/util/nameClass.js +7 -6
- package/lib/util/negateValue.js +5 -3
- package/lib/util/normalizeConfig.js +233 -0
- package/lib/util/normalizeScreens.js +59 -0
- package/lib/util/parseAnimationValue.js +56 -56
- package/lib/util/parseBoxShadowValue.js +76 -0
- package/lib/util/parseDependency.js +32 -32
- package/lib/util/parseObjectStyles.js +6 -6
- package/lib/util/pluginUtils.js +67 -170
- package/lib/util/prefixSelector.js +4 -7
- package/lib/util/resolveConfig.js +123 -133
- package/lib/util/resolveConfigPath.js +17 -18
- package/lib/util/responsive.js +6 -6
- package/lib/util/splitAtTopLevelOnly.js +72 -0
- package/lib/util/toColorValue.js +1 -2
- package/lib/util/toPath.js +6 -1
- package/lib/util/transformThemeValue.js +42 -34
- package/lib/util/validateConfig.js +21 -0
- package/lib/util/withAlphaVariable.js +19 -19
- package/nesting/index.js +2 -12
- package/package.json +41 -42
- package/peers/index.js +11539 -10859
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.js +2 -1
- package/scripts/create-plugin-list.js +2 -2
- package/scripts/generate-types.js +52 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +174 -41
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +641 -596
- package/src/css/preflight.css +19 -13
- package/src/featureFlags.js +16 -10
- package/src/index.js +14 -6
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/collapseDuplicateDeclarations.js +93 -0
- package/src/lib/defaultExtractor.js +192 -0
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +24 -7
- package/src/lib/expandApplyAtRules.js +442 -154
- package/src/lib/expandTailwindAtRules.js +91 -65
- package/src/lib/generateRules.js +409 -43
- package/src/lib/normalizeTailwindDirectives.js +10 -3
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +74 -53
- package/src/lib/setupContextUtils.js +388 -208
- package/src/lib/setupTrackingContext.js +15 -12
- package/src/lib/sharedState.js +42 -7
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/src/postcss-plugins/nesting/plugin.js +80 -0
- package/src/processTailwindFeatures.js +17 -2
- package/src/public/colors.js +4 -9
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +31 -14
- package/src/util/createUtilityPlugin.js +2 -2
- package/src/util/dataTypes.js +56 -16
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +213 -0
- package/src/util/getAllConfigs.js +7 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +23 -22
- package/src/util/nameClass.js +2 -2
- package/src/util/negateValue.js +4 -2
- package/src/util/normalizeConfig.js +262 -0
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +72 -0
- package/src/util/pluginUtils.js +51 -147
- package/src/util/prefixSelector.js +7 -8
- package/src/util/resolveConfig.js +108 -79
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +24 -7
- package/src/util/validateConfig.js +13 -0
- package/stubs/defaultConfig.stub.js +157 -94
- package/stubs/simpleConfig.stub.js +0 -1
- package/types/config.d.ts +325 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types.d.ts +1 -0
- package/lib/lib/setupWatchingContext.js +0 -284
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -306
package/lib/util/cloneNodes.js
CHANGED
|
@@ -3,11 +3,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = cloneNodes;
|
|
6
|
-
function cloneNodes(nodes, source) {
|
|
6
|
+
function cloneNodes(nodes, source = undefined, raws = undefined) {
|
|
7
7
|
return nodes.map((node)=>{
|
|
8
8
|
let cloned = node.clone();
|
|
9
9
|
if (source !== undefined) {
|
|
10
10
|
cloned.source = source;
|
|
11
|
+
if ("walk" in cloned) {
|
|
12
|
+
cloned.walk((child)=>{
|
|
13
|
+
child.source = source;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (raws !== undefined) {
|
|
18
|
+
cloned.raws.tailwind = {
|
|
19
|
+
...cloned.raws.tailwind,
|
|
20
|
+
...raws
|
|
21
|
+
};
|
|
11
22
|
}
|
|
12
23
|
return cloned;
|
|
13
24
|
});
|
package/lib/util/color.js
CHANGED
|
@@ -12,47 +12,50 @@ function _interopRequireDefault(obj) {
|
|
|
12
12
|
}
|
|
13
13
|
let HEX = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i;
|
|
14
14
|
let SHORT_HEX = /^#([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i;
|
|
15
|
-
let VALUE =
|
|
16
|
-
let SEP =
|
|
17
|
-
let ALPHA_SEP =
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
let VALUE = /(?:\d+|\d*\.\d+)%?/;
|
|
16
|
+
let SEP = /(?:\s*,\s*|\s+)/;
|
|
17
|
+
let ALPHA_SEP = /\s*[,/]\s*/;
|
|
18
|
+
let CUSTOM_PROPERTY = /var\(--(?:[^ )]*?)\)/;
|
|
19
|
+
let RGB = new RegExp(`^(rgb)a?\\(\\s*(${VALUE.source}|${CUSTOM_PROPERTY.source})(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`);
|
|
20
|
+
let HSL = new RegExp(`^(hsl)a?\\(\\s*((?:${VALUE.source})(?:deg|rad|grad|turn)?|${CUSTOM_PROPERTY.source})(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`);
|
|
21
|
+
function parseColor(value, { loose =false } = {}) {
|
|
22
|
+
var ref, ref1;
|
|
23
|
+
if (typeof value !== "string") {
|
|
21
24
|
return null;
|
|
22
25
|
}
|
|
23
26
|
value = value.trim();
|
|
24
|
-
if (value ===
|
|
27
|
+
if (value === "transparent") {
|
|
25
28
|
return {
|
|
26
|
-
mode:
|
|
29
|
+
mode: "rgb",
|
|
27
30
|
color: [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
"0",
|
|
32
|
+
"0",
|
|
33
|
+
"0"
|
|
31
34
|
],
|
|
32
|
-
alpha:
|
|
35
|
+
alpha: "0"
|
|
33
36
|
};
|
|
34
37
|
}
|
|
35
38
|
if (value in _colorName.default) {
|
|
36
39
|
return {
|
|
37
|
-
mode:
|
|
40
|
+
mode: "rgb",
|
|
38
41
|
color: _colorName.default[value].map((v)=>v.toString()
|
|
39
42
|
)
|
|
40
43
|
};
|
|
41
44
|
}
|
|
42
45
|
let hex = value.replace(SHORT_HEX, (_, r, g, b, a)=>[
|
|
43
|
-
|
|
46
|
+
"#",
|
|
44
47
|
r,
|
|
45
48
|
r,
|
|
46
49
|
g,
|
|
47
50
|
g,
|
|
48
51
|
b,
|
|
49
52
|
b,
|
|
50
|
-
a ? a + a :
|
|
51
|
-
].join(
|
|
53
|
+
a ? a + a : ""
|
|
54
|
+
].join("")
|
|
52
55
|
).match(HEX);
|
|
53
56
|
if (hex !== null) {
|
|
54
57
|
return {
|
|
55
|
-
mode:
|
|
58
|
+
mode: "rgb",
|
|
56
59
|
color: [
|
|
57
60
|
parseInt(hex[1], 16),
|
|
58
61
|
parseInt(hex[2], 16),
|
|
@@ -62,23 +65,31 @@ function parseColor(value) {
|
|
|
62
65
|
alpha: hex[4] ? (parseInt(hex[4], 16) / 255).toString() : undefined
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return
|
|
69
|
-
mode: match[1],
|
|
70
|
-
color: [
|
|
71
|
-
match[2],
|
|
72
|
-
match[3],
|
|
73
|
-
match[4]
|
|
74
|
-
].map((v)=>v.toString()
|
|
75
|
-
),
|
|
76
|
-
alpha: (ref = match[5]) === null || ref === void 0 ? void 0 : (ref1 = ref.toString) === null || ref1 === void 0 ? void 0 : ref1.call(ref)
|
|
77
|
-
};
|
|
68
|
+
var ref2;
|
|
69
|
+
let match = (ref2 = value.match(RGB)) !== null && ref2 !== void 0 ? ref2 : value.match(HSL);
|
|
70
|
+
if (match === null) {
|
|
71
|
+
return null;
|
|
78
72
|
}
|
|
79
|
-
|
|
73
|
+
let color = [
|
|
74
|
+
match[2],
|
|
75
|
+
match[3],
|
|
76
|
+
match[4]
|
|
77
|
+
].filter(Boolean).map((v)=>v.toString()
|
|
78
|
+
);
|
|
79
|
+
if (!loose && color.length !== 3) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
if (color.length < 3 && !color.some((part)=>/^var\(.*?\)$/.test(part)
|
|
83
|
+
)) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
mode: match[1],
|
|
88
|
+
color,
|
|
89
|
+
alpha: (ref = match[5]) === null || ref === void 0 ? void 0 : (ref1 = ref.toString) === null || ref1 === void 0 ? void 0 : ref1.call(ref)
|
|
90
|
+
};
|
|
80
91
|
}
|
|
81
92
|
function formatColor({ mode , color , alpha }) {
|
|
82
93
|
let hasAlpha = alpha !== undefined;
|
|
83
|
-
return `${mode}(${color.join(
|
|
94
|
+
return `${mode}(${color.join(" ")}${hasAlpha ? ` / ${alpha}` : ""})`;
|
|
84
95
|
}
|
package/lib/util/createPlugin.js
CHANGED
|
@@ -9,8 +9,7 @@ function createPlugin(plugin, config) {
|
|
|
9
9
|
config
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
createPlugin.withOptions = function(pluginFunction, configFunction = ()=>({
|
|
13
|
-
})
|
|
12
|
+
createPlugin.withOptions = function(pluginFunction, configFunction = ()=>({})
|
|
14
13
|
) {
|
|
15
14
|
const optionsFunction = function(options) {
|
|
16
15
|
return {
|
|
@@ -4,11 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.default = createUtilityPlugin;
|
|
6
6
|
var _transformThemeValue = _interopRequireDefault(require("./transformThemeValue"));
|
|
7
|
-
function _interopRequireDefault(obj) {
|
|
8
|
-
return obj && obj.__esModule ? obj : {
|
|
9
|
-
default: obj
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
7
|
function createUtilityPlugin(themeKey, utilityVariations = [
|
|
13
8
|
[
|
|
14
9
|
themeKey,
|
|
@@ -16,8 +11,7 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
16
11
|
themeKey
|
|
17
12
|
]
|
|
18
13
|
]
|
|
19
|
-
], { filterDefault =false ,
|
|
20
|
-
}) {
|
|
14
|
+
], { filterDefault =false , ...options } = {}) {
|
|
21
15
|
let transformValue = (0, _transformThemeValue).default(themeKey);
|
|
22
16
|
return function({ matchUtilities , theme }) {
|
|
23
17
|
for (let utilityVariation of utilityVariations){
|
|
@@ -25,8 +19,8 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
25
19
|
utilityVariation
|
|
26
20
|
];
|
|
27
21
|
var ref;
|
|
28
|
-
matchUtilities(group.reduce((
|
|
29
|
-
return Object.assign(
|
|
22
|
+
matchUtilities(group.reduce((obj1, [classPrefix, properties])=>{
|
|
23
|
+
return Object.assign(obj1, {
|
|
30
24
|
[classPrefix]: (value)=>{
|
|
31
25
|
return properties.reduce((obj, name)=>{
|
|
32
26
|
if (Array.isArray(name)) {
|
|
@@ -37,17 +31,19 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
37
31
|
return Object.assign(obj, {
|
|
38
32
|
[name]: transformValue(value)
|
|
39
33
|
});
|
|
40
|
-
}, {
|
|
41
|
-
});
|
|
34
|
+
}, {});
|
|
42
35
|
}
|
|
43
36
|
});
|
|
44
|
-
}, {
|
|
45
|
-
|
|
46
|
-
values: filterDefault ? Object.fromEntries(Object.entries((ref = theme(themeKey)) !== null && ref !== void 0 ? ref : {
|
|
47
|
-
|
|
48
|
-
)) : theme(themeKey),
|
|
49
|
-
type
|
|
37
|
+
}, {}), {
|
|
38
|
+
...options,
|
|
39
|
+
values: filterDefault ? Object.fromEntries(Object.entries((ref = theme(themeKey)) !== null && ref !== void 0 ? ref : {}).filter(([modifier])=>modifier !== "DEFAULT"
|
|
40
|
+
)) : theme(themeKey)
|
|
50
41
|
});
|
|
51
42
|
}
|
|
52
43
|
};
|
|
53
44
|
}
|
|
45
|
+
function _interopRequireDefault(obj) {
|
|
46
|
+
return obj && obj.__esModule ? obj : {
|
|
47
|
+
default: obj
|
|
48
|
+
};
|
|
49
|
+
}
|
package/lib/util/dataTypes.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.number = number;
|
|
|
8
8
|
exports.percentage = percentage;
|
|
9
9
|
exports.length = length;
|
|
10
10
|
exports.lineWidth = lineWidth;
|
|
11
|
+
exports.shadow = shadow;
|
|
11
12
|
exports.color = color;
|
|
12
13
|
exports.image = image;
|
|
13
14
|
exports.gradient = gradient;
|
|
@@ -17,68 +18,107 @@ exports.genericName = genericName;
|
|
|
17
18
|
exports.absoluteSize = absoluteSize;
|
|
18
19
|
exports.relativeSize = relativeSize;
|
|
19
20
|
var _color = require("./color");
|
|
21
|
+
var _parseBoxShadowValue = require("./parseBoxShadowValue");
|
|
22
|
+
let cssFunctions = [
|
|
23
|
+
"min",
|
|
24
|
+
"max",
|
|
25
|
+
"clamp",
|
|
26
|
+
"calc"
|
|
27
|
+
];
|
|
20
28
|
// Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Types
|
|
21
29
|
let COMMA = /,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
|
|
22
30
|
;
|
|
23
31
|
let UNDERSCORE = /_(?![^(]*\))/g // Underscore separator that is not located between brackets. E.g.: `rgba(255,_255,_255)_black` these don't count.
|
|
24
32
|
;
|
|
25
|
-
function normalize(value) {
|
|
33
|
+
function normalize(value, isRoot = true) {
|
|
34
|
+
// Keep raw strings if it starts with `url(`
|
|
35
|
+
if (value.includes("url(")) {
|
|
36
|
+
return value.split(/(url\(.*?\))/g).filter(Boolean).map((part)=>{
|
|
37
|
+
if (/^url\(.*?\)$/.test(part)) {
|
|
38
|
+
return part;
|
|
39
|
+
}
|
|
40
|
+
return normalize(part, false);
|
|
41
|
+
}).join("");
|
|
42
|
+
}
|
|
26
43
|
// Convert `_` to ` `, except for escaped underscores `\_`
|
|
27
|
-
value = value.replace(/([^\\])_+/g, (fullMatch, characterBefore)=>characterBefore +
|
|
28
|
-
).replace(/^_/g,
|
|
44
|
+
value = value.replace(/([^\\])_+/g, (fullMatch, characterBefore)=>characterBefore + " ".repeat(fullMatch.length - 1)
|
|
45
|
+
).replace(/^_/g, " ").replace(/\\_/g, "_");
|
|
29
46
|
// Remove leftover whitespace
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
47
|
+
if (isRoot) {
|
|
48
|
+
value = value.trim();
|
|
49
|
+
}
|
|
33
50
|
// Add spaces around operators inside calc() that do not follow an operator
|
|
34
51
|
// or '('.
|
|
35
|
-
|
|
52
|
+
value = value.replace(/calc\(.+\)/g, (match)=>{
|
|
53
|
+
return match.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
|
|
54
|
+
});
|
|
55
|
+
// Add spaces around some operators not inside calc() that do not follow an operator
|
|
56
|
+
// or '('.
|
|
57
|
+
return value.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([\/])/g, "$1 $2 ");
|
|
36
58
|
}
|
|
37
59
|
function url(value) {
|
|
38
|
-
return value.startsWith(
|
|
60
|
+
return value.startsWith("url(");
|
|
39
61
|
}
|
|
40
62
|
function number(value) {
|
|
41
|
-
return !isNaN(Number(value))
|
|
63
|
+
return !isNaN(Number(value)) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?`).test(value)
|
|
64
|
+
);
|
|
42
65
|
}
|
|
43
66
|
function percentage(value) {
|
|
44
|
-
return
|
|
67
|
+
return value.split(UNDERSCORE).every((part)=>{
|
|
68
|
+
return /%$/g.test(part) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?%`).test(part)
|
|
69
|
+
);
|
|
70
|
+
});
|
|
45
71
|
}
|
|
46
72
|
let lengthUnits = [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
73
|
+
"cm",
|
|
74
|
+
"mm",
|
|
75
|
+
"Q",
|
|
76
|
+
"in",
|
|
77
|
+
"pc",
|
|
78
|
+
"pt",
|
|
79
|
+
"px",
|
|
80
|
+
"em",
|
|
81
|
+
"ex",
|
|
82
|
+
"ch",
|
|
83
|
+
"rem",
|
|
84
|
+
"lh",
|
|
85
|
+
"vw",
|
|
86
|
+
"vh",
|
|
87
|
+
"vmin",
|
|
88
|
+
"vmax",
|
|
63
89
|
];
|
|
64
|
-
let lengthUnitsPattern = `(?:${lengthUnits.join(
|
|
90
|
+
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
|
|
65
91
|
function length(value) {
|
|
66
|
-
return
|
|
92
|
+
return value.split(UNDERSCORE).every((part)=>{
|
|
93
|
+
return part === "0" || new RegExp(`${lengthUnitsPattern}$`).test(part) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?${lengthUnitsPattern}`).test(part)
|
|
94
|
+
);
|
|
95
|
+
});
|
|
67
96
|
}
|
|
68
97
|
let lineWidths = new Set([
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
98
|
+
"thin",
|
|
99
|
+
"medium",
|
|
100
|
+
"thick"
|
|
72
101
|
]);
|
|
73
102
|
function lineWidth(value) {
|
|
74
103
|
return lineWidths.has(value);
|
|
75
104
|
}
|
|
105
|
+
function shadow(value) {
|
|
106
|
+
let parsedShadows = (0, _parseBoxShadowValue).parseBoxShadowValue(normalize(value));
|
|
107
|
+
for (let parsedShadow of parsedShadows){
|
|
108
|
+
if (!parsedShadow.valid) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
76
114
|
function color(value) {
|
|
77
115
|
let colors = 0;
|
|
78
116
|
let result = value.split(UNDERSCORE).every((part)=>{
|
|
79
117
|
part = normalize(part);
|
|
80
|
-
if (part.startsWith(
|
|
81
|
-
if ((0, _color).parseColor(part
|
|
118
|
+
if (part.startsWith("var(")) return true;
|
|
119
|
+
if ((0, _color).parseColor(part, {
|
|
120
|
+
loose: true
|
|
121
|
+
}) !== null) return colors++, true;
|
|
82
122
|
return false;
|
|
83
123
|
});
|
|
84
124
|
if (!result) return false;
|
|
@@ -88,12 +128,12 @@ function image(value) {
|
|
|
88
128
|
let images = 0;
|
|
89
129
|
let result = value.split(COMMA).every((part)=>{
|
|
90
130
|
part = normalize(part);
|
|
91
|
-
if (part.startsWith(
|
|
131
|
+
if (part.startsWith("var(")) return true;
|
|
92
132
|
if (url(part) || gradient(part) || [
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
133
|
+
"element(",
|
|
134
|
+
"image(",
|
|
135
|
+
"cross-fade(",
|
|
136
|
+
"image-set("
|
|
97
137
|
].some((fn)=>part.startsWith(fn)
|
|
98
138
|
)) {
|
|
99
139
|
images++;
|
|
@@ -105,11 +145,11 @@ function image(value) {
|
|
|
105
145
|
return images > 0;
|
|
106
146
|
}
|
|
107
147
|
let gradientTypes = new Set([
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
148
|
+
"linear-gradient",
|
|
149
|
+
"radial-gradient",
|
|
150
|
+
"repeating-linear-gradient",
|
|
151
|
+
"repeating-radial-gradient",
|
|
152
|
+
"conic-gradient",
|
|
113
153
|
]);
|
|
114
154
|
function gradient(value) {
|
|
115
155
|
value = normalize(value);
|
|
@@ -121,17 +161,17 @@ function gradient(value) {
|
|
|
121
161
|
return false;
|
|
122
162
|
}
|
|
123
163
|
let validPositions = new Set([
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
164
|
+
"center",
|
|
165
|
+
"top",
|
|
166
|
+
"right",
|
|
167
|
+
"bottom",
|
|
168
|
+
"left"
|
|
129
169
|
]);
|
|
130
170
|
function position(value) {
|
|
131
171
|
let positions = 0;
|
|
132
172
|
let result = value.split(UNDERSCORE).every((part)=>{
|
|
133
173
|
part = normalize(part);
|
|
134
|
-
if (part.startsWith(
|
|
174
|
+
if (part.startsWith("var(")) return true;
|
|
135
175
|
if (validPositions.has(part) || length(part) || percentage(part)) {
|
|
136
176
|
positions++;
|
|
137
177
|
return true;
|
|
@@ -145,9 +185,9 @@ function familyName(value) {
|
|
|
145
185
|
let fonts = 0;
|
|
146
186
|
let result = value.split(COMMA).every((part)=>{
|
|
147
187
|
part = normalize(part);
|
|
148
|
-
if (part.startsWith(
|
|
188
|
+
if (part.startsWith("var(")) return true;
|
|
149
189
|
// If it contains spaces, then it should be quoted
|
|
150
|
-
if (part.includes(
|
|
190
|
+
if (part.includes(" ")) {
|
|
151
191
|
if (!/(['"])([^"']+)\1/g.test(part)) {
|
|
152
192
|
return false;
|
|
153
193
|
}
|
|
@@ -163,39 +203,39 @@ function familyName(value) {
|
|
|
163
203
|
return fonts > 0;
|
|
164
204
|
}
|
|
165
205
|
let genericNames = new Set([
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
206
|
+
"serif",
|
|
207
|
+
"sans-serif",
|
|
208
|
+
"monospace",
|
|
209
|
+
"cursive",
|
|
210
|
+
"fantasy",
|
|
211
|
+
"system-ui",
|
|
212
|
+
"ui-serif",
|
|
213
|
+
"ui-sans-serif",
|
|
214
|
+
"ui-monospace",
|
|
215
|
+
"ui-rounded",
|
|
216
|
+
"math",
|
|
217
|
+
"emoji",
|
|
218
|
+
"fangsong",
|
|
179
219
|
]);
|
|
180
220
|
function genericName(value) {
|
|
181
221
|
return genericNames.has(value);
|
|
182
222
|
}
|
|
183
223
|
let absoluteSizes = new Set([
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
224
|
+
"xx-small",
|
|
225
|
+
"x-small",
|
|
226
|
+
"small",
|
|
227
|
+
"medium",
|
|
228
|
+
"large",
|
|
229
|
+
"x-large",
|
|
230
|
+
"x-large",
|
|
231
|
+
"xxx-large",
|
|
192
232
|
]);
|
|
193
233
|
function absoluteSize(value) {
|
|
194
234
|
return absoluteSizes.has(value);
|
|
195
235
|
}
|
|
196
236
|
let relativeSizes = new Set([
|
|
197
|
-
|
|
198
|
-
|
|
237
|
+
"larger",
|
|
238
|
+
"smaller"
|
|
199
239
|
]);
|
|
200
240
|
function relativeSize(value) {
|
|
201
241
|
return relativeSizes.has(value);
|
package/lib/util/defaults.js
CHANGED
|
@@ -11,6 +11,12 @@ function defaults(target, ...sources) {
|
|
|
11
11
|
target[k] = source[k];
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
+
for (let k1 of Object.getOwnPropertySymbols(source)){
|
|
15
|
+
var ref1;
|
|
16
|
+
if (!(target === null || target === void 0 ? void 0 : (ref1 = target.hasOwnProperty) === null || ref1 === void 0 ? void 0 : ref1.call(target, k1))) {
|
|
17
|
+
target[k1] = source[k1];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
14
20
|
}
|
|
15
21
|
return target;
|
|
16
22
|
}
|
|
@@ -5,11 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.default = escapeClassName;
|
|
6
6
|
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
|
|
7
7
|
var _escapeCommas = _interopRequireDefault(require("./escapeCommas"));
|
|
8
|
-
function _interopRequireDefault(obj) {
|
|
9
|
-
return obj && obj.__esModule ? obj : {
|
|
10
|
-
default: obj
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
8
|
function escapeClassName(className) {
|
|
14
9
|
var ref;
|
|
15
10
|
let node = _postcssSelectorParser.default.className();
|
|
@@ -17,3 +12,8 @@ function escapeClassName(className) {
|
|
|
17
12
|
var ref1;
|
|
18
13
|
return (0, _escapeCommas).default((ref1 = node === null || node === void 0 ? void 0 : (ref = node.raws) === null || ref === void 0 ? void 0 : ref.value) !== null && ref1 !== void 0 ? ref1 : node.value);
|
|
19
14
|
}
|
|
15
|
+
function _interopRequireDefault(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
package/lib/util/escapeCommas.js
CHANGED
|
@@ -3,10 +3,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = void 0;
|
|
6
|
-
const flattenColorPalette = (colors)=>Object.assign({
|
|
7
|
-
|
|
8
|
-
}).flatMap(([color, values])=>typeof values == 'object' ? Object.entries(flattenColorPalette(values)).map(([number, hex])=>({
|
|
9
|
-
[color + (number === 'DEFAULT' ? '' : `-${number}`)]: hex
|
|
6
|
+
const flattenColorPalette = (colors)=>Object.assign({}, ...Object.entries(colors !== null && colors !== void 0 ? colors : {}).flatMap(([color, values])=>typeof values == "object" ? Object.entries(flattenColorPalette(values)).map(([number, hex])=>({
|
|
7
|
+
[color + (number === "DEFAULT" ? "" : `-${number}`)]: hex
|
|
10
8
|
})
|
|
11
9
|
) : [
|
|
12
10
|
{
|