tailwindcss 3.0.22 → 3.1.0
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 +92 -2
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +3 -0
- package/lib/cli-peer-dependencies.js +10 -5
- package/lib/cli.js +266 -203
- package/lib/constants.js +8 -8
- package/lib/corePluginList.js +1 -0
- package/lib/corePlugins.js +1662 -1554
- package/lib/css/preflight.css +1 -8
- package/lib/featureFlags.js +14 -12
- package/lib/index.js +16 -6
- package/lib/lib/cacheInvalidation.js +87 -0
- package/lib/lib/collapseAdjacentRules.js +30 -15
- package/lib/lib/collapseDuplicateDeclarations.js +1 -1
- package/lib/lib/defaultExtractor.js +191 -30
- package/lib/lib/detectNesting.js +9 -9
- package/lib/lib/evaluateTailwindFunctions.js +37 -28
- package/lib/lib/expandApplyAtRules.js +379 -189
- package/lib/lib/expandTailwindAtRules.js +168 -144
- package/lib/lib/generateRules.js +190 -81
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +35 -35
- package/lib/lib/partitionApplyAtRules.js +7 -7
- package/lib/lib/regex.js +52 -0
- package/lib/lib/resolveDefaultsAtRules.js +80 -79
- package/lib/lib/setupContextUtils.js +207 -170
- package/lib/lib/setupTrackingContext.js +61 -63
- package/lib/lib/sharedState.js +11 -8
- package/lib/lib/substituteScreenAtRules.js +3 -4
- package/lib/postcss-plugins/nesting/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +1 -1
- package/lib/postcss-plugins/nesting/plugin.js +40 -9
- package/lib/processTailwindFeatures.js +7 -7
- package/lib/public/colors.js +241 -241
- package/lib/public/resolve-config.js +5 -5
- package/lib/util/buildMediaQuery.js +2 -3
- package/lib/util/cloneDeep.js +3 -5
- package/lib/util/cloneNodes.js +12 -1
- package/lib/util/color.js +42 -51
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +6 -7
- package/lib/util/dataTypes.js +85 -81
- package/lib/util/escapeClassName.js +5 -5
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +4 -7
- package/lib/util/formatVariantSelector.js +82 -75
- package/lib/util/getAllConfigs.js +15 -10
- 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 +26 -27
- package/lib/util/log.js +9 -10
- package/lib/util/nameClass.js +7 -7
- package/lib/util/negateValue.js +4 -5
- package/lib/util/normalizeConfig.js +68 -58
- package/lib/util/normalizeScreens.js +5 -6
- package/lib/util/parseAnimationValue.js +56 -57
- package/lib/util/parseBoxShadowValue.js +19 -20
- package/lib/util/parseDependency.js +32 -32
- package/lib/util/parseObjectStyles.js +6 -6
- package/lib/util/pluginUtils.js +20 -12
- package/lib/util/prefixSelector.js +1 -1
- package/lib/util/resolveConfig.js +81 -58
- package/lib/util/resolveConfigPath.js +16 -16
- package/lib/util/responsive.js +6 -6
- package/lib/util/splitAtTopLevelOnly.js +90 -0
- package/lib/util/toColorValue.js +1 -1
- package/lib/util/toPath.js +2 -2
- package/lib/util/transformThemeValue.js +30 -28
- package/lib/util/validateConfig.js +21 -0
- package/lib/util/withAlphaVariable.js +23 -23
- package/package.json +33 -27
- package/peers/index.js +7728 -5848
- package/plugin.d.ts +11 -0
- package/scripts/generate-types.js +52 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +118 -24
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +142 -30
- package/src/css/preflight.css +1 -8
- package/src/featureFlags.js +4 -4
- package/src/index.js +15 -1
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/defaultExtractor.js +177 -33
- package/src/lib/evaluateTailwindFunctions.js +20 -4
- package/src/lib/expandApplyAtRules.js +418 -186
- package/src/lib/expandTailwindAtRules.js +30 -10
- package/src/lib/generateRules.js +142 -51
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +7 -3
- package/src/lib/setupContextUtils.js +142 -87
- package/src/lib/setupTrackingContext.js +7 -3
- package/src/lib/sharedState.js +2 -0
- package/src/postcss-plugins/nesting/README.md +2 -2
- package/src/postcss-plugins/nesting/plugin.js +36 -0
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +25 -21
- package/src/util/dataTypes.js +14 -6
- package/src/util/formatVariantSelector.js +79 -62
- package/src/util/getAllConfigs.js +7 -0
- package/src/util/log.js +8 -8
- package/src/util/normalizeConfig.js +0 -8
- package/src/util/parseBoxShadowValue.js +3 -2
- package/src/util/pluginUtils.js +13 -1
- package/src/util/resolveConfig.js +66 -22
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +4 -2
- package/src/util/validateConfig.js +13 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +5 -1
- package/stubs/simpleConfig.stub.js +1 -0
- 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
|
@@ -10,38 +10,39 @@ var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser")
|
|
|
10
10
|
var _normalizeScreens = require("../util/normalizeScreens");
|
|
11
11
|
var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
12
12
|
var _toPath = require("../util/toPath");
|
|
13
|
+
var _withAlphaVariable = require("../util/withAlphaVariable");
|
|
14
|
+
var _pluginUtils = require("../util/pluginUtils");
|
|
13
15
|
function _interopRequireDefault(obj) {
|
|
14
16
|
return obj && obj.__esModule ? obj : {
|
|
15
17
|
default: obj
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
20
|
function isObject(input) {
|
|
19
|
-
return typeof input ===
|
|
21
|
+
return typeof input === "object" && input !== null;
|
|
20
22
|
}
|
|
21
23
|
function findClosestExistingPath(theme, path) {
|
|
22
24
|
let parts = (0, _toPath).toPath(path);
|
|
23
25
|
do {
|
|
24
26
|
parts.pop();
|
|
25
27
|
if ((0, _dlv).default(theme, parts) !== undefined) break;
|
|
26
|
-
}while (parts.length)
|
|
28
|
+
}while (parts.length);
|
|
27
29
|
return parts.length ? parts : undefined;
|
|
28
30
|
}
|
|
29
31
|
function pathToString(path) {
|
|
30
|
-
if (typeof path ===
|
|
32
|
+
if (typeof path === "string") return path;
|
|
31
33
|
return path.reduce((acc, cur, i)=>{
|
|
32
|
-
if (cur.includes(
|
|
34
|
+
if (cur.includes(".")) return `${acc}[${cur}]`;
|
|
33
35
|
return i === 0 ? cur : `${acc}.${cur}`;
|
|
34
|
-
},
|
|
36
|
+
}, "");
|
|
35
37
|
}
|
|
36
38
|
function list(items) {
|
|
37
|
-
return items.map((key)=>`'${key}'`
|
|
38
|
-
).join(', ');
|
|
39
|
+
return items.map((key)=>`'${key}'`).join(", ");
|
|
39
40
|
}
|
|
40
41
|
function listKeys(obj) {
|
|
41
42
|
return list(Object.keys(obj));
|
|
42
43
|
}
|
|
43
|
-
function validatePath(config, path, defaultValue) {
|
|
44
|
-
const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g,
|
|
44
|
+
function validatePath(config, path, defaultValue, themeOpts = {}) {
|
|
45
|
+
const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
|
|
45
46
|
const pathSegments = Array.isArray(path) ? path : (0, _toPath).toPath(pathString);
|
|
46
47
|
const value = (0, _dlv).default(config.theme, pathSegments, defaultValue);
|
|
47
48
|
if (value === undefined) {
|
|
@@ -52,8 +53,7 @@ function validatePath(config, path, defaultValue) {
|
|
|
52
53
|
const validKeys = Object.keys(parentValue).filter((key)=>validatePath(config, [
|
|
53
54
|
...parentSegments,
|
|
54
55
|
key
|
|
55
|
-
]).isValid
|
|
56
|
-
);
|
|
56
|
+
]).isValid);
|
|
57
57
|
const suggestion = (0, _didyoumean).default(pathSegments[pathSegments.length - 1], validKeys);
|
|
58
58
|
if (suggestion) {
|
|
59
59
|
error += ` Did you mean '${pathToString([
|
|
@@ -81,14 +81,13 @@ function validatePath(config, path, defaultValue) {
|
|
|
81
81
|
error
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
if (!(typeof value ===
|
|
84
|
+
if (!(typeof value === "string" || typeof value === "number" || typeof value === "function" || value instanceof String || value instanceof Number || Array.isArray(value))) {
|
|
85
85
|
let error = `'${pathString}' was found but does not resolve to a string.`;
|
|
86
86
|
if (isObject(value)) {
|
|
87
87
|
let validKeys = Object.keys(value).filter((key)=>validatePath(config, [
|
|
88
88
|
...pathSegments,
|
|
89
89
|
key
|
|
90
|
-
]).isValid
|
|
91
|
-
);
|
|
90
|
+
]).isValid);
|
|
92
91
|
if (validKeys.length) {
|
|
93
92
|
error += ` Did you mean something like '${pathToString([
|
|
94
93
|
...pathSegments,
|
|
@@ -104,18 +103,17 @@ function validatePath(config, path, defaultValue) {
|
|
|
104
103
|
const [themeSection] = pathSegments;
|
|
105
104
|
return {
|
|
106
105
|
isValid: true,
|
|
107
|
-
value: (0, _transformThemeValue).default(themeSection)(value)
|
|
106
|
+
value: (0, _transformThemeValue).default(themeSection)(value, themeOpts)
|
|
108
107
|
};
|
|
109
108
|
}
|
|
110
109
|
function extractArgs(node, vNodes, functions) {
|
|
111
|
-
vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions)
|
|
112
|
-
);
|
|
110
|
+
vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions));
|
|
113
111
|
let args = [
|
|
114
|
-
|
|
112
|
+
""
|
|
115
113
|
];
|
|
116
114
|
for (let vNode1 of vNodes){
|
|
117
|
-
if (vNode1.type ===
|
|
118
|
-
args.push(
|
|
115
|
+
if (vNode1.type === "div" && vNode1.value === ",") {
|
|
116
|
+
args.push("");
|
|
119
117
|
} else {
|
|
120
118
|
args[args.length - 1] += _postcssValueParser.default.stringify(vNode1);
|
|
121
119
|
}
|
|
@@ -123,9 +121,9 @@ function extractArgs(node, vNodes, functions) {
|
|
|
123
121
|
return args;
|
|
124
122
|
}
|
|
125
123
|
function resolveVNode(node, vNode, functions) {
|
|
126
|
-
if (vNode.type ===
|
|
124
|
+
if (vNode.type === "function" && functions[vNode.value] !== undefined) {
|
|
127
125
|
let args = extractArgs(node, vNode.nodes, functions);
|
|
128
|
-
vNode.type =
|
|
126
|
+
vNode.type = "word";
|
|
129
127
|
vNode.value = functions[vNode.value](node, ...args);
|
|
130
128
|
}
|
|
131
129
|
return vNode;
|
|
@@ -136,23 +134,34 @@ function resolveFunctions(node, input, functions) {
|
|
|
136
134
|
}).toString();
|
|
137
135
|
}
|
|
138
136
|
let nodeTypePropertyMap = {
|
|
139
|
-
atrule:
|
|
140
|
-
decl:
|
|
137
|
+
atrule: "params",
|
|
138
|
+
decl: "value"
|
|
141
139
|
};
|
|
142
140
|
function _default({ tailwindConfig: config }) {
|
|
143
141
|
let functions = {
|
|
144
142
|
theme: (node, path, ...defaultValue)=>{
|
|
145
|
-
|
|
143
|
+
let matches = path.match(/^([^\/\s]+)(?:\s*\/\s*([^\/\s]+))$/);
|
|
144
|
+
let alpha = undefined;
|
|
145
|
+
if (matches) {
|
|
146
|
+
path = matches[1];
|
|
147
|
+
alpha = matches[2];
|
|
148
|
+
}
|
|
149
|
+
let { isValid , value , error } = validatePath(config, path, defaultValue.length ? defaultValue : undefined, {
|
|
150
|
+
opacityValue: alpha
|
|
151
|
+
});
|
|
146
152
|
if (!isValid) {
|
|
147
153
|
throw node.error(error);
|
|
148
154
|
}
|
|
155
|
+
if (alpha !== undefined) {
|
|
156
|
+
value = (0, _pluginUtils).parseColorFormat(value);
|
|
157
|
+
value = (0, _withAlphaVariable).withAlphaValue(value, alpha, value);
|
|
158
|
+
}
|
|
149
159
|
return value;
|
|
150
160
|
},
|
|
151
161
|
screen: (node, screen)=>{
|
|
152
|
-
screen = screen.replace(/^['"]+/g,
|
|
162
|
+
screen = screen.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
|
|
153
163
|
let screens = (0, _normalizeScreens).normalizeScreens(config.theme.screens);
|
|
154
|
-
let screenDefinition = screens.find(({ name })=>name === screen
|
|
155
|
-
);
|
|
164
|
+
let screenDefinition = screens.find(({ name })=>name === screen);
|
|
156
165
|
if (!screenDefinition) {
|
|
157
166
|
throw node.error(`The '${screen}' screen does not exist in your theme.`);
|
|
158
167
|
}
|