tailwindcss 0.0.0-insiders.bd970d0 → 0.0.0-insiders.bda8421
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/README.md +1 -2
- package/lib/cli/build/deps.js +62 -0
- package/lib/cli/build/index.js +12 -15
- package/lib/cli/build/plugin.js +107 -167
- package/lib/cli/build/utils.js +13 -13
- package/lib/cli/build/watching.js +10 -10
- package/lib/cli/help/index.js +11 -11
- package/lib/cli/index.js +60 -61
- package/lib/cli/init/index.js +16 -16
- package/lib/cli-peer-dependencies.js +36 -0
- package/lib/cli.js +1 -1
- package/lib/corePluginList.js +4 -1
- package/lib/corePlugins.js +2018 -1905
- package/lib/css/preflight.css +18 -12
- package/lib/featureFlags.js +17 -23
- package/lib/index.js +1 -1
- package/lib/lib/cacheInvalidation.js +3 -3
- package/lib/lib/collapseAdjacentRules.js +6 -6
- package/lib/lib/collapseDuplicateDeclarations.js +1 -1
- package/lib/lib/content.js +39 -32
- package/lib/lib/defaultExtractor.js +40 -17
- package/lib/lib/evaluateTailwindFunctions.js +23 -23
- package/lib/lib/expandApplyAtRules.js +37 -18
- package/lib/lib/expandTailwindAtRules.js +49 -85
- package/lib/lib/findAtConfigPath.js +5 -5
- package/lib/lib/generateRules.js +82 -55
- package/lib/lib/getModuleDependencies.js +23 -23
- package/lib/lib/load-config.js +21 -6
- package/lib/lib/normalizeTailwindDirectives.js +36 -21
- package/lib/lib/offsets.js +97 -48
- package/lib/lib/partitionApplyAtRules.js +2 -2
- package/lib/lib/regex.js +5 -5
- package/lib/lib/resolveDefaultsAtRules.js +27 -25
- package/lib/lib/setupContextUtils.js +195 -167
- package/lib/lib/setupTrackingContext.js +4 -5
- package/lib/lib/sharedState.js +10 -10
- package/lib/lib/substituteScreenAtRules.js +4 -4
- package/lib/plugin.js +8 -124
- package/lib/postcss-plugins/nesting/index.js +2 -2
- package/lib/postcss-plugins/nesting/plugin.js +11 -11
- package/lib/processTailwindFeatures.js +3 -5
- package/lib/public/colors.js +264 -264
- package/lib/util/applyImportantSelector.js +2 -2
- package/lib/util/buildMediaQuery.js +2 -2
- package/lib/util/cloneDeep.js +1 -1
- package/lib/util/cloneNodes.js +33 -13
- package/lib/util/color.js +19 -19
- package/lib/util/createUtilityPlugin.js +3 -3
- package/lib/util/dataTypes.js +170 -113
- package/lib/util/defaults.js +4 -4
- package/lib/util/escapeClassName.js +2 -2
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +2 -2
- package/lib/util/formatVariantSelector.js +24 -19
- package/lib/util/getAllConfigs.js +4 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +2 -2
- package/lib/util/isSyntacticallyValidPropertyValue.js +10 -10
- package/lib/util/log.js +6 -23
- package/lib/util/nameClass.js +4 -4
- package/lib/util/negateValue.js +8 -8
- package/lib/util/normalizeConfig.js +63 -94
- package/lib/util/normalizeScreens.js +18 -18
- package/lib/util/parseAnimationValue.js +38 -38
- package/lib/util/parseBoxShadowValue.js +18 -18
- package/lib/util/parseDependency.js +4 -4
- package/lib/util/parseGlob.js +4 -4
- package/lib/util/parseObjectStyles.js +1 -1
- package/lib/util/pluginUtils.js +36 -21
- package/lib/util/prefixSelector.js +4 -4
- package/lib/util/pseudoElements.js +72 -69
- package/lib/util/removeAlphaVariables.js +1 -1
- package/lib/util/resolveConfig.js +11 -15
- package/lib/util/resolveConfigPath.js +6 -6
- package/lib/util/responsive.js +1 -1
- package/lib/util/splitAtTopLevelOnly.js +3 -3
- package/lib/util/toColorValue.js +1 -1
- package/lib/util/toPath.js +2 -2
- package/lib/util/transformThemeValue.js +24 -24
- package/lib/util/validateConfig.js +9 -20
- package/lib/util/validateFormalSyntax.js +5 -5
- package/lib/util/withAlphaVariable.js +5 -5
- package/lib/value-parser/index.js +5 -5
- package/lib/value-parser/parse.js +43 -43
- package/lib/value-parser/stringify.js +11 -11
- package/lib/value-parser/unit.js +5 -5
- package/lib/value-parser/walk.js +1 -1
- package/nesting/index.d.ts +4 -0
- package/package.json +41 -36
- package/peers/index.js +96503 -0
- package/resolveConfig.d.ts +22 -3
- package/scripts/generate-types.js +1 -2
- package/scripts/release-notes.js +1 -1
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +0 -4
- package/src/cli/build/plugin.js +53 -85
- package/src/cli/build/watching.js +1 -1
- package/src/cli/index.js +0 -1
- package/src/cli-peer-dependencies.js +15 -0
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +118 -31
- package/src/css/preflight.css +18 -12
- package/src/featureFlags.js +3 -5
- package/src/lib/content.js +39 -30
- package/src/lib/defaultExtractor.js +29 -6
- package/src/lib/expandApplyAtRules.js +24 -0
- package/src/lib/expandTailwindAtRules.js +19 -56
- package/src/lib/generateRules.js +39 -8
- package/src/lib/load-config.ts +13 -0
- package/src/lib/normalizeTailwindDirectives.js +27 -0
- package/src/lib/offsets.js +62 -3
- package/src/lib/resolveDefaultsAtRules.js +5 -1
- package/src/lib/setupContextUtils.js +79 -39
- package/src/plugin.js +0 -86
- package/src/processTailwindFeatures.js +0 -3
- package/src/util/cloneNodes.js +35 -14
- package/src/util/dataTypes.js +72 -6
- package/src/util/formatVariantSelector.js +7 -0
- package/src/util/isPlainObject.js +1 -1
- package/src/util/log.js +0 -24
- package/src/util/normalizeConfig.js +11 -38
- package/src/util/pluginUtils.js +20 -0
- package/src/util/pseudoElements.js +4 -0
- package/src/util/validateConfig.js +0 -10
- package/stubs/config.full.js +68 -8
- package/stubs/config.simple.js +1 -1
- package/stubs/postcss.config.cjs +1 -0
- package/stubs/postcss.config.js +1 -0
- package/types/config.d.ts +12 -5
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +28 -9
- package/types/index.d.ts +7 -3
- package/index.css +0 -5
- package/lib/lib/detectNesting.js +0 -45
- package/lib/lib/handleImportAtRules.js +0 -50
- package/src/lib/detectNesting.js +0 -47
- package/src/lib/handleImportAtRules.js +0 -34
package/lib/util/cloneNodes.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('postcss').Container[]} nodes
|
|
3
|
+
* @param {any} source
|
|
4
|
+
* @param {any} raws
|
|
5
|
+
* @returns {import('postcss').Container[]}
|
|
6
|
+
*/ "use strict";
|
|
2
7
|
Object.defineProperty(exports, "__esModule", {
|
|
3
8
|
value: true
|
|
4
9
|
});
|
|
@@ -10,25 +15,40 @@ Object.defineProperty(exports, "default", {
|
|
|
10
15
|
});
|
|
11
16
|
function cloneNodes(nodes, source = undefined, raws = undefined) {
|
|
12
17
|
return nodes.map((node)=>{
|
|
13
|
-
var _node_raws_tailwind;
|
|
14
18
|
let cloned = node.clone();
|
|
15
|
-
// We always want override the source map
|
|
16
|
-
// except when explicitly told not to
|
|
17
|
-
let shouldOverwriteSource = ((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.preserveSource) !== true || !cloned.source;
|
|
18
|
-
if (source !== undefined && shouldOverwriteSource) {
|
|
19
|
-
cloned.source = source;
|
|
20
|
-
if ('walk' in cloned) {
|
|
21
|
-
cloned.walk((child)=>{
|
|
22
|
-
child.source = source;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
19
|
if (raws !== undefined) {
|
|
27
20
|
cloned.raws.tailwind = {
|
|
28
21
|
...cloned.raws.tailwind,
|
|
29
22
|
...raws
|
|
30
23
|
};
|
|
31
24
|
}
|
|
25
|
+
if (source !== undefined) {
|
|
26
|
+
traverse(cloned, (node)=>{
|
|
27
|
+
var _node_raws_tailwind;
|
|
28
|
+
// Do not traverse nodes that have opted
|
|
29
|
+
// to preserve their original source
|
|
30
|
+
let shouldPreserveSource = ((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.preserveSource) === true && node.source;
|
|
31
|
+
if (shouldPreserveSource) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
// Otherwise we can safely replace the source
|
|
35
|
+
// And continue traversing
|
|
36
|
+
node.source = source;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
32
39
|
return cloned;
|
|
33
40
|
});
|
|
34
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Traverse a tree of nodes and don't traverse children if the callback
|
|
44
|
+
* returns false. Ideally we'd use Container#walk instead of this
|
|
45
|
+
* function but it stops traversing siblings too.
|
|
46
|
+
*
|
|
47
|
+
* @param {import('postcss').Container} node
|
|
48
|
+
* @param {(node: import('postcss').Container) => boolean} onNode
|
|
49
|
+
*/ function traverse(node, onNode) {
|
|
50
|
+
if (onNode(node) !== false) {
|
|
51
|
+
var _node_each;
|
|
52
|
+
(_node_each = node.each) === null || _node_each === void 0 ? void 0 : _node_each.call(node, (child)=>traverse(child, onNode));
|
|
53
|
+
}
|
|
54
|
+
}
|
package/lib/util/color.js
CHANGED
|
@@ -30,42 +30,42 @@ let ALPHA_SEP = /\s*[,/]\s*/;
|
|
|
30
30
|
let CUSTOM_PROPERTY = /var\(--(?:[^ )]*?)(?:,(?:[^ )]*?|var\(--[^ )]*?\)))?\)/;
|
|
31
31
|
let RGB = new RegExp(`^(rgba?)\\(\\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*\\)$`);
|
|
32
32
|
let HSL = new RegExp(`^(hsla?)\\(\\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*\\)$`);
|
|
33
|
-
function parseColor(value, { loose =
|
|
34
|
-
var
|
|
35
|
-
if (typeof value !==
|
|
33
|
+
function parseColor(value, { loose =false } = {}) {
|
|
34
|
+
var _match_, _match__toString;
|
|
35
|
+
if (typeof value !== "string") {
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
38
38
|
value = value.trim();
|
|
39
|
-
if (value ===
|
|
39
|
+
if (value === "transparent") {
|
|
40
40
|
return {
|
|
41
|
-
mode:
|
|
41
|
+
mode: "rgb",
|
|
42
42
|
color: [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
"0",
|
|
44
|
+
"0",
|
|
45
|
+
"0"
|
|
46
46
|
],
|
|
47
|
-
alpha:
|
|
47
|
+
alpha: "0"
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
if (value in _colorNames.default) {
|
|
51
51
|
return {
|
|
52
|
-
mode:
|
|
52
|
+
mode: "rgb",
|
|
53
53
|
color: _colorNames.default[value].map((v)=>v.toString())
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
let hex = value.replace(SHORT_HEX, (_, r, g, b, a)=>[
|
|
57
|
-
|
|
57
|
+
"#",
|
|
58
58
|
r,
|
|
59
59
|
r,
|
|
60
60
|
g,
|
|
61
61
|
g,
|
|
62
62
|
b,
|
|
63
63
|
b,
|
|
64
|
-
a ? a + a :
|
|
65
|
-
].join(
|
|
64
|
+
a ? a + a : ""
|
|
65
|
+
].join("")).match(HEX);
|
|
66
66
|
if (hex !== null) {
|
|
67
67
|
return {
|
|
68
|
-
mode:
|
|
68
|
+
mode: "rgb",
|
|
69
69
|
color: [
|
|
70
70
|
parseInt(hex[1], 16),
|
|
71
71
|
parseInt(hex[2], 16),
|
|
@@ -86,7 +86,7 @@ function parseColor(value, { loose = false } = {}) {
|
|
|
86
86
|
].filter(Boolean).map((v)=>v.toString());
|
|
87
87
|
// rgba(var(--my-color), 0.1)
|
|
88
88
|
// hsla(var(--my-color), 0.1)
|
|
89
|
-
if (color.length === 2 && color[0].startsWith(
|
|
89
|
+
if (color.length === 2 && color[0].startsWith("var(")) {
|
|
90
90
|
return {
|
|
91
91
|
mode: match[1],
|
|
92
92
|
color: [
|
|
@@ -107,10 +107,10 @@ function parseColor(value, { loose = false } = {}) {
|
|
|
107
107
|
alpha: (_match_ = match[5]) === null || _match_ === void 0 ? void 0 : (_match__toString = _match_.toString) === null || _match__toString === void 0 ? void 0 : _match__toString.call(_match_)
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
|
-
function formatColor({ mode, color, alpha
|
|
110
|
+
function formatColor({ mode , color , alpha }) {
|
|
111
111
|
let hasAlpha = alpha !== undefined;
|
|
112
|
-
if (mode ===
|
|
113
|
-
return `${mode}(${color.join(
|
|
112
|
+
if (mode === "rgba" || mode === "hsla") {
|
|
113
|
+
return `${mode}(${color.join(", ")}${hasAlpha ? `, ${alpha}` : ""})`;
|
|
114
114
|
}
|
|
115
|
-
return `${mode}(${color.join(
|
|
115
|
+
return `${mode}(${color.join(" ")}${hasAlpha ? ` / ${alpha}` : ""})`;
|
|
116
116
|
}
|
|
@@ -21,9 +21,9 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
21
21
|
themeKey
|
|
22
22
|
]
|
|
23
23
|
]
|
|
24
|
-
], { filterDefault =
|
|
24
|
+
], { filterDefault =false , ...options } = {}) {
|
|
25
25
|
let transformValue = (0, _transformThemeValue.default)(themeKey);
|
|
26
|
-
return function({ matchUtilities, theme
|
|
26
|
+
return function({ matchUtilities , theme }) {
|
|
27
27
|
for (let utilityVariation of utilityVariations){
|
|
28
28
|
let group = Array.isArray(utilityVariation[0]) ? utilityVariation : [
|
|
29
29
|
utilityVariation
|
|
@@ -46,7 +46,7 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
46
46
|
});
|
|
47
47
|
}, {}), {
|
|
48
48
|
...options,
|
|
49
|
-
values: filterDefault ? Object.fromEntries(Object.entries((_theme = theme(themeKey)) !== null && _theme !== void 0 ? _theme : {}).filter(([modifier])=>modifier !==
|
|
49
|
+
values: filterDefault ? Object.fromEntries(Object.entries((_theme = theme(themeKey)) !== null && _theme !== void 0 ? _theme : {}).filter(([modifier])=>modifier !== "DEFAULT")) : theme(themeKey)
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
};
|
package/lib/util/dataTypes.js
CHANGED
|
@@ -59,30 +59,52 @@ const _color = require("./color");
|
|
|
59
59
|
const _parseBoxShadowValue = require("./parseBoxShadowValue");
|
|
60
60
|
const _splitAtTopLevelOnly = require("./splitAtTopLevelOnly");
|
|
61
61
|
let cssFunctions = [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
"min",
|
|
63
|
+
"max",
|
|
64
|
+
"clamp",
|
|
65
|
+
"calc"
|
|
66
66
|
];
|
|
67
67
|
// Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Types
|
|
68
68
|
function isCSSFunction(value) {
|
|
69
69
|
return cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.*\\)`).test(value));
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
// These properties accept a `<dashed-ident>` as one of the values. This means that you can use them
|
|
72
|
+
// as: `timeline-scope: --tl;`
|
|
73
|
+
//
|
|
74
|
+
// Without the `var(--tl)`, in these cases we don't want to normalize the value, and you should add
|
|
75
|
+
// the `var()` yourself.
|
|
76
|
+
//
|
|
77
|
+
// More info:
|
|
78
|
+
// - https://drafts.csswg.org/scroll-animations/#propdef-timeline-scope
|
|
79
|
+
// - https://developer.mozilla.org/en-US/docs/Web/CSS/timeline-scope#dashed-ident
|
|
80
|
+
//
|
|
81
|
+
const AUTO_VAR_INJECTION_EXCEPTIONS = new Set([
|
|
82
|
+
// Concrete properties
|
|
83
|
+
"scroll-timeline-name",
|
|
84
|
+
"timeline-scope",
|
|
85
|
+
"view-timeline-name",
|
|
86
|
+
"font-palette",
|
|
87
|
+
// Shorthand properties
|
|
88
|
+
"scroll-timeline",
|
|
89
|
+
"animation-timeline",
|
|
90
|
+
"view-timeline"
|
|
91
|
+
]);
|
|
92
|
+
function normalize(value, context = null, isRoot = true) {
|
|
93
|
+
let isVarException = context && AUTO_VAR_INJECTION_EXCEPTIONS.has(context.property);
|
|
94
|
+
if (value.startsWith("--") && !isVarException) {
|
|
73
95
|
return `var(${value})`;
|
|
74
96
|
}
|
|
75
97
|
// Keep raw strings if it starts with `url(`
|
|
76
|
-
if (value.includes(
|
|
98
|
+
if (value.includes("url(")) {
|
|
77
99
|
return value.split(/(url\(.*?\))/g).filter(Boolean).map((part)=>{
|
|
78
100
|
if (/^url\(.*?\)$/.test(part)) {
|
|
79
101
|
return part;
|
|
80
102
|
}
|
|
81
|
-
return normalize(part, false);
|
|
82
|
-
}).join(
|
|
103
|
+
return normalize(part, context, false);
|
|
104
|
+
}).join("");
|
|
83
105
|
}
|
|
84
106
|
// Convert `_` to ` `, except for escaped underscores `\_`
|
|
85
|
-
value = value.replace(/([^\\])_+/g, (fullMatch, characterBefore)=>characterBefore +
|
|
107
|
+
value = value.replace(/([^\\])_+/g, (fullMatch, characterBefore)=>characterBefore + " ".repeat(fullMatch.length - 1)).replace(/^_/g, " ").replace(/\\_/g, "_");
|
|
86
108
|
// Remove leftover whitespace
|
|
87
109
|
if (isRoot) {
|
|
88
110
|
value = value.trim();
|
|
@@ -92,23 +114,49 @@ function normalize(value, isRoot = true) {
|
|
|
92
114
|
}
|
|
93
115
|
/**
|
|
94
116
|
* Add spaces around operators inside math functions
|
|
95
|
-
* like calc() that do not follow an operator
|
|
117
|
+
* like calc() that do not follow an operator, '(', or `,`.
|
|
96
118
|
*
|
|
97
119
|
* @param {string} value
|
|
98
120
|
* @returns {string}
|
|
99
121
|
*/ function normalizeMathOperatorSpacing(value) {
|
|
100
122
|
let preventFormattingInFunctions = [
|
|
101
|
-
|
|
123
|
+
"theme"
|
|
124
|
+
];
|
|
125
|
+
let preventFormattingKeywords = [
|
|
126
|
+
"min-content",
|
|
127
|
+
"max-content",
|
|
128
|
+
"fit-content",
|
|
129
|
+
// Env
|
|
130
|
+
"safe-area-inset-top",
|
|
131
|
+
"safe-area-inset-right",
|
|
132
|
+
"safe-area-inset-bottom",
|
|
133
|
+
"safe-area-inset-left",
|
|
134
|
+
"titlebar-area-x",
|
|
135
|
+
"titlebar-area-y",
|
|
136
|
+
"titlebar-area-width",
|
|
137
|
+
"titlebar-area-height",
|
|
138
|
+
"keyboard-inset-top",
|
|
139
|
+
"keyboard-inset-right",
|
|
140
|
+
"keyboard-inset-bottom",
|
|
141
|
+
"keyboard-inset-left",
|
|
142
|
+
"keyboard-inset-width",
|
|
143
|
+
"keyboard-inset-height",
|
|
144
|
+
"radial-gradient",
|
|
145
|
+
"linear-gradient",
|
|
146
|
+
"conic-gradient",
|
|
147
|
+
"repeating-radial-gradient",
|
|
148
|
+
"repeating-linear-gradient",
|
|
149
|
+
"repeating-conic-gradient"
|
|
102
150
|
];
|
|
103
151
|
return value.replace(/(calc|min|max|clamp)\(.+\)/g, (match)=>{
|
|
104
|
-
let result =
|
|
152
|
+
let result = "";
|
|
105
153
|
function lastChar() {
|
|
106
154
|
let char = result.trimEnd();
|
|
107
155
|
return char[char.length - 1];
|
|
108
156
|
}
|
|
109
157
|
for(let i = 0; i < match.length; i++){
|
|
110
158
|
function peek(word) {
|
|
111
|
-
return word.split(
|
|
159
|
+
return word.split("").every((char, j)=>match[i + j] === char);
|
|
112
160
|
}
|
|
113
161
|
function consumeUntil(chars) {
|
|
114
162
|
let minIndex = Infinity;
|
|
@@ -124,7 +172,7 @@ function normalize(value, isRoot = true) {
|
|
|
124
172
|
}
|
|
125
173
|
let char = match[i];
|
|
126
174
|
// Handle `var(--variable)`
|
|
127
|
-
if (peek(
|
|
175
|
+
if (peek("var")) {
|
|
128
176
|
// When we consume until `)`, then we are dealing with this scenario:
|
|
129
177
|
// `var(--example)`
|
|
130
178
|
//
|
|
@@ -133,24 +181,33 @@ function normalize(value, isRoot = true) {
|
|
|
133
181
|
//
|
|
134
182
|
// In this case we do want to "format", the default value as well
|
|
135
183
|
result += consumeUntil([
|
|
136
|
-
|
|
137
|
-
|
|
184
|
+
")",
|
|
185
|
+
","
|
|
138
186
|
]);
|
|
187
|
+
} else if (preventFormattingKeywords.some((keyword)=>peek(keyword))) {
|
|
188
|
+
let keyword = preventFormattingKeywords.find((keyword)=>peek(keyword));
|
|
189
|
+
result += keyword;
|
|
190
|
+
i += keyword.length - 1;
|
|
139
191
|
} else if (preventFormattingInFunctions.some((fn)=>peek(fn))) {
|
|
140
192
|
result += consumeUntil([
|
|
141
|
-
|
|
193
|
+
")"
|
|
194
|
+
]);
|
|
195
|
+
} else if (peek("[")) {
|
|
196
|
+
result += consumeUntil([
|
|
197
|
+
"]"
|
|
142
198
|
]);
|
|
143
199
|
} else if ([
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
200
|
+
"+",
|
|
201
|
+
"-",
|
|
202
|
+
"*",
|
|
203
|
+
"/"
|
|
148
204
|
].includes(char) && ![
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
205
|
+
"(",
|
|
206
|
+
"+",
|
|
207
|
+
"-",
|
|
208
|
+
"*",
|
|
209
|
+
"/",
|
|
210
|
+
","
|
|
154
211
|
].includes(lastChar())) {
|
|
155
212
|
result += ` ${char} `;
|
|
156
213
|
} else {
|
|
@@ -158,62 +215,62 @@ function normalize(value, isRoot = true) {
|
|
|
158
215
|
}
|
|
159
216
|
}
|
|
160
217
|
// Simplify multiple spaces
|
|
161
|
-
return result.replace(/\s+/g,
|
|
218
|
+
return result.replace(/\s+/g, " ");
|
|
162
219
|
});
|
|
163
220
|
}
|
|
164
221
|
function url(value) {
|
|
165
|
-
return value.startsWith(
|
|
222
|
+
return value.startsWith("url(");
|
|
166
223
|
}
|
|
167
224
|
function number(value) {
|
|
168
225
|
return !isNaN(Number(value)) || isCSSFunction(value);
|
|
169
226
|
}
|
|
170
227
|
function percentage(value) {
|
|
171
|
-
return value.endsWith(
|
|
228
|
+
return value.endsWith("%") && number(value.slice(0, -1)) || isCSSFunction(value);
|
|
172
229
|
}
|
|
173
230
|
// Please refer to MDN when updating this list:
|
|
174
231
|
// https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
|
|
175
232
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units
|
|
176
233
|
let lengthUnits = [
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
234
|
+
"cm",
|
|
235
|
+
"mm",
|
|
236
|
+
"Q",
|
|
237
|
+
"in",
|
|
238
|
+
"pc",
|
|
239
|
+
"pt",
|
|
240
|
+
"px",
|
|
241
|
+
"em",
|
|
242
|
+
"ex",
|
|
243
|
+
"ch",
|
|
244
|
+
"rem",
|
|
245
|
+
"lh",
|
|
246
|
+
"rlh",
|
|
247
|
+
"vw",
|
|
248
|
+
"vh",
|
|
249
|
+
"vmin",
|
|
250
|
+
"vmax",
|
|
251
|
+
"vb",
|
|
252
|
+
"vi",
|
|
253
|
+
"svw",
|
|
254
|
+
"svh",
|
|
255
|
+
"lvw",
|
|
256
|
+
"lvh",
|
|
257
|
+
"dvw",
|
|
258
|
+
"dvh",
|
|
259
|
+
"cqw",
|
|
260
|
+
"cqh",
|
|
261
|
+
"cqi",
|
|
262
|
+
"cqb",
|
|
263
|
+
"cqmin",
|
|
264
|
+
"cqmax"
|
|
208
265
|
];
|
|
209
|
-
let lengthUnitsPattern = `(?:${lengthUnits.join(
|
|
266
|
+
let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
|
|
210
267
|
function length(value) {
|
|
211
|
-
return value ===
|
|
268
|
+
return value === "0" || new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) || isCSSFunction(value);
|
|
212
269
|
}
|
|
213
270
|
let lineWidths = new Set([
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
271
|
+
"thin",
|
|
272
|
+
"medium",
|
|
273
|
+
"thick"
|
|
217
274
|
]);
|
|
218
275
|
function lineWidth(value) {
|
|
219
276
|
return lineWidths.has(value);
|
|
@@ -229,9 +286,9 @@ function shadow(value) {
|
|
|
229
286
|
}
|
|
230
287
|
function color(value) {
|
|
231
288
|
let colors = 0;
|
|
232
|
-
let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value,
|
|
289
|
+
let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value, "_").every((part)=>{
|
|
233
290
|
part = normalize(part);
|
|
234
|
-
if (part.startsWith(
|
|
291
|
+
if (part.startsWith("var(")) return true;
|
|
235
292
|
if ((0, _color.parseColor)(part, {
|
|
236
293
|
loose: true
|
|
237
294
|
}) !== null) return colors++, true;
|
|
@@ -242,14 +299,14 @@ function color(value) {
|
|
|
242
299
|
}
|
|
243
300
|
function image(value) {
|
|
244
301
|
let images = 0;
|
|
245
|
-
let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value,
|
|
302
|
+
let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value, ",").every((part)=>{
|
|
246
303
|
part = normalize(part);
|
|
247
|
-
if (part.startsWith(
|
|
304
|
+
if (part.startsWith("var(")) return true;
|
|
248
305
|
if (url(part) || gradient(part) || [
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
306
|
+
"element(",
|
|
307
|
+
"image(",
|
|
308
|
+
"cross-fade(",
|
|
309
|
+
"image-set("
|
|
253
310
|
].some((fn)=>part.startsWith(fn))) {
|
|
254
311
|
images++;
|
|
255
312
|
return true;
|
|
@@ -260,12 +317,12 @@ function image(value) {
|
|
|
260
317
|
return images > 0;
|
|
261
318
|
}
|
|
262
319
|
let gradientTypes = new Set([
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
320
|
+
"conic-gradient",
|
|
321
|
+
"linear-gradient",
|
|
322
|
+
"radial-gradient",
|
|
323
|
+
"repeating-conic-gradient",
|
|
324
|
+
"repeating-linear-gradient",
|
|
325
|
+
"repeating-radial-gradient"
|
|
269
326
|
]);
|
|
270
327
|
function gradient(value) {
|
|
271
328
|
value = normalize(value);
|
|
@@ -277,17 +334,17 @@ function gradient(value) {
|
|
|
277
334
|
return false;
|
|
278
335
|
}
|
|
279
336
|
let validPositions = new Set([
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
337
|
+
"center",
|
|
338
|
+
"top",
|
|
339
|
+
"right",
|
|
340
|
+
"bottom",
|
|
341
|
+
"left"
|
|
285
342
|
]);
|
|
286
343
|
function position(value) {
|
|
287
344
|
let positions = 0;
|
|
288
|
-
let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value,
|
|
345
|
+
let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value, "_").every((part)=>{
|
|
289
346
|
part = normalize(part);
|
|
290
|
-
if (part.startsWith(
|
|
347
|
+
if (part.startsWith("var(")) return true;
|
|
291
348
|
if (validPositions.has(part) || length(part) || percentage(part)) {
|
|
292
349
|
positions++;
|
|
293
350
|
return true;
|
|
@@ -299,11 +356,11 @@ function position(value) {
|
|
|
299
356
|
}
|
|
300
357
|
function familyName(value) {
|
|
301
358
|
let fonts = 0;
|
|
302
|
-
let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value,
|
|
359
|
+
let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value, ",").every((part)=>{
|
|
303
360
|
part = normalize(part);
|
|
304
|
-
if (part.startsWith(
|
|
361
|
+
if (part.startsWith("var(")) return true;
|
|
305
362
|
// If it contains spaces, then it should be quoted
|
|
306
|
-
if (part.includes(
|
|
363
|
+
if (part.includes(" ")) {
|
|
307
364
|
if (!/(['"])([^"']+)\1/g.test(part)) {
|
|
308
365
|
return false;
|
|
309
366
|
}
|
|
@@ -319,39 +376,39 @@ function familyName(value) {
|
|
|
319
376
|
return fonts > 0;
|
|
320
377
|
}
|
|
321
378
|
let genericNames = new Set([
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
379
|
+
"serif",
|
|
380
|
+
"sans-serif",
|
|
381
|
+
"monospace",
|
|
382
|
+
"cursive",
|
|
383
|
+
"fantasy",
|
|
384
|
+
"system-ui",
|
|
385
|
+
"ui-serif",
|
|
386
|
+
"ui-sans-serif",
|
|
387
|
+
"ui-monospace",
|
|
388
|
+
"ui-rounded",
|
|
389
|
+
"math",
|
|
390
|
+
"emoji",
|
|
391
|
+
"fangsong"
|
|
335
392
|
]);
|
|
336
393
|
function genericName(value) {
|
|
337
394
|
return genericNames.has(value);
|
|
338
395
|
}
|
|
339
396
|
let absoluteSizes = new Set([
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
397
|
+
"xx-small",
|
|
398
|
+
"x-small",
|
|
399
|
+
"small",
|
|
400
|
+
"medium",
|
|
401
|
+
"large",
|
|
402
|
+
"x-large",
|
|
403
|
+
"xx-large",
|
|
404
|
+
"xxx-large"
|
|
348
405
|
]);
|
|
349
406
|
function absoluteSize(value) {
|
|
350
407
|
return absoluteSizes.has(value);
|
|
351
408
|
}
|
|
352
409
|
let relativeSizes = new Set([
|
|
353
|
-
|
|
354
|
-
|
|
410
|
+
"larger",
|
|
411
|
+
"smaller"
|
|
355
412
|
]);
|
|
356
413
|
function relativeSize(value) {
|
|
357
414
|
return relativeSizes.has(value);
|
package/lib/util/defaults.js
CHANGED
|
@@ -11,14 +11,14 @@ Object.defineProperty(exports, "defaults", {
|
|
|
11
11
|
function defaults(target, ...sources) {
|
|
12
12
|
for (let source of sources){
|
|
13
13
|
for(let k in source){
|
|
14
|
-
var _target_hasOwnProperty
|
|
15
|
-
if (!(
|
|
14
|
+
var _target_hasOwnProperty;
|
|
15
|
+
if (!(target === null || target === void 0 ? void 0 : (_target_hasOwnProperty = target.hasOwnProperty) === null || _target_hasOwnProperty === void 0 ? void 0 : _target_hasOwnProperty.call(target, k))) {
|
|
16
16
|
target[k] = source[k];
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
for (let k of Object.getOwnPropertySymbols(source)){
|
|
20
|
-
var _target_hasOwnProperty1
|
|
21
|
-
if (!(
|
|
20
|
+
var _target_hasOwnProperty1;
|
|
21
|
+
if (!(target === null || target === void 0 ? void 0 : (_target_hasOwnProperty1 = target.hasOwnProperty) === null || _target_hasOwnProperty1 === void 0 ? void 0 : _target_hasOwnProperty1.call(target, k))) {
|
|
22
22
|
target[k] = source[k];
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -16,9 +16,9 @@ function _interop_require_default(obj) {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function escapeClassName(className) {
|
|
19
|
-
var _node_raws
|
|
19
|
+
var _node_raws;
|
|
20
20
|
let node = _postcssselectorparser.default.className();
|
|
21
21
|
node.value = className;
|
|
22
22
|
var _node_raws_value;
|
|
23
|
-
return (0, _escapeCommas.default)((_node_raws_value =
|
|
23
|
+
return (0, _escapeCommas.default)((_node_raws_value = node === null || node === void 0 ? void 0 : (_node_raws = node.raws) === null || _node_raws === void 0 ? void 0 : _node_raws.value) !== null && _node_raws_value !== void 0 ? _node_raws_value : node.value);
|
|
24
24
|
}
|
package/lib/util/escapeCommas.js
CHANGED
|
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return _default;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const flattenColorPalette = (colors)=>Object.assign({}, ...Object.entries(colors !== null && colors !== void 0 ? colors : {}).flatMap(([color, values])=>typeof values ==
|
|
12
|
-
[color + (number ===
|
|
11
|
+
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])=>({
|
|
12
|
+
[color + (number === "DEFAULT" ? "" : `-${number}`)]: hex
|
|
13
13
|
})) : [
|
|
14
14
|
{
|
|
15
15
|
[`${color}`]: values
|