tailwindcss 3.1.2 → 3.1.5
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 +40 -1
- package/defaultTheme.d.ts +2 -1
- package/lib/corePlugins.js +20 -17
- package/lib/lib/defaultExtractor.js +50 -25
- package/lib/lib/evaluateTailwindFunctions.js +11 -4
- package/lib/lib/generateRules.js +23 -11
- package/lib/lib/setupContextUtils.js +9 -2
- package/lib/util/dataTypes.js +3 -5
- package/lib/util/formatVariantSelector.js +3 -2
- package/lib/util/removeAlphaVariables.js +18 -0
- package/package.json +11 -11
- package/peers/index.js +286 -123
- package/scripts/generate-types.js +53 -0
- package/scripts/type-utils.js +27 -0
- package/src/corePlugins.js +21 -17
- package/src/lib/defaultExtractor.js +45 -29
- package/src/lib/evaluateTailwindFunctions.js +14 -6
- package/src/lib/generateRules.js +23 -10
- package/src/lib/setupContextUtils.js +16 -2
- package/src/util/dataTypes.js +3 -5
- package/src/util/formatVariantSelector.js +3 -1
- package/src/util/removeAlphaVariables.js +24 -0
- package/types/config.d.ts +8 -6
- package/types/generated/default-theme.d.ts +331 -0
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
- Nothing yet!
|
|
11
11
|
|
|
12
|
+
## [3.1.5] - 2022-07-07
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Support default `font-weight`s in font size utilities ([#8763](https://github.com/tailwindlabs/tailwindcss/pull/8763))
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Allows fallback values in plugin API helpers ([#8762](https://github.com/tailwindlabs/tailwindcss/pull/8762))
|
|
21
|
+
- Fix usage of postcss.config.js in standalone CLI ([#8769](https://github.com/tailwindlabs/tailwindcss/pull/8769))
|
|
22
|
+
- Fix usage of special-character prefixes ([#8772](https://github.com/tailwindlabs/tailwindcss/pull/8772))
|
|
23
|
+
- Don’t prefix selectors in arbitrary variants ([#8773](https://github.com/tailwindlabs/tailwindcss/pull/8773))
|
|
24
|
+
- Add support for alpha values in safe list ([#8774](https://github.com/tailwindlabs/tailwindcss/pull/8774))
|
|
25
|
+
- Add more explicit types for the default theme ([#8780](https://github.com/tailwindlabs/tailwindcss/pull/8780))
|
|
26
|
+
|
|
27
|
+
## [3.1.4] - 2022-06-21
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- Provide default to `<alpha-value>` when using `theme()` ([#8652](https://github.com/tailwindlabs/tailwindcss/pull/8652))
|
|
32
|
+
- Detect arbitrary variants with quotes ([#8687](https://github.com/tailwindlabs/tailwindcss/pull/8687))
|
|
33
|
+
- Don’t add spaces around raw `/` that are preceded by numbers ([#8688](https://github.com/tailwindlabs/tailwindcss/pull/8688))
|
|
34
|
+
|
|
35
|
+
## [3.1.3] - 2022-06-14
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- Fix extraction of multi-word utilities with arbitrary values and quotes ([#8604](https://github.com/tailwindlabs/tailwindcss/pull/8604))
|
|
40
|
+
- Fix casing of import of `corePluginList` type definition ([#8587](https://github.com/tailwindlabs/tailwindcss/pull/8587))
|
|
41
|
+
- Ignore PostCSS nodes returned by `addVariant` ([#8608](https://github.com/tailwindlabs/tailwindcss/pull/8608))
|
|
42
|
+
- Fix missing spaces around arithmetic operators ([#8615](https://github.com/tailwindlabs/tailwindcss/pull/8615))
|
|
43
|
+
- Detect alpha value in CSS `theme()` function when using quotes ([#8625](https://github.com/tailwindlabs/tailwindcss/pull/8625))
|
|
44
|
+
- Fix "Maximum call stack size exceeded" bug ([#8636](https://github.com/tailwindlabs/tailwindcss/pull/8636))
|
|
45
|
+
- Allow functions returning parallel variants to mutate the container ([#8622](https://github.com/tailwindlabs/tailwindcss/pull/8622))
|
|
46
|
+
- Remove text opacity CSS variables from `::marker` ([#8622](https://github.com/tailwindlabs/tailwindcss/pull/8622))
|
|
47
|
+
|
|
12
48
|
## [3.1.2] - 2022-06-10
|
|
13
49
|
|
|
14
50
|
### Fixed
|
|
@@ -1968,7 +2004,10 @@ No release notes
|
|
|
1968
2004
|
|
|
1969
2005
|
- Everything!
|
|
1970
2006
|
|
|
1971
|
-
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.
|
|
2007
|
+
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.5...HEAD
|
|
2008
|
+
[3.1.5]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.4...v3.1.5
|
|
2009
|
+
[3.1.4]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.3...v3.1.4
|
|
2010
|
+
[3.1.3]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.2...v3.1.3
|
|
1972
2011
|
[3.1.2]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.1...v3.1.2
|
|
1973
2012
|
[3.1.1]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.0...v3.1.1
|
|
1974
2013
|
[3.1.0]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.24...v3.1.0
|
package/defaultTheme.d.ts
CHANGED
package/lib/corePlugins.js
CHANGED
|
@@ -19,6 +19,7 @@ var _packageJson = require("../package.json");
|
|
|
19
19
|
var _log = _interopRequireDefault(require("./util/log"));
|
|
20
20
|
var _normalizeScreens = require("./util/normalizeScreens");
|
|
21
21
|
var _parseBoxShadowValue = require("./util/parseBoxShadowValue");
|
|
22
|
+
var _removeAlphaVariables = require("./util/removeAlphaVariables");
|
|
22
23
|
var _featureFlags = require("./featureFlags");
|
|
23
24
|
function _interopRequireDefault(obj) {
|
|
24
25
|
return obj && obj.__esModule ? obj : {
|
|
@@ -69,8 +70,18 @@ let variantPlugins = {
|
|
|
69
70
|
addVariant("first-letter", "&::first-letter");
|
|
70
71
|
addVariant("first-line", "&::first-line");
|
|
71
72
|
addVariant("marker", [
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
({ container })=>{
|
|
74
|
+
(0, _removeAlphaVariables).removeAlphaVariables(container, [
|
|
75
|
+
"--tw-text-opacity"
|
|
76
|
+
]);
|
|
77
|
+
return "& *::marker";
|
|
78
|
+
},
|
|
79
|
+
({ container })=>{
|
|
80
|
+
(0, _removeAlphaVariables).removeAlphaVariables(container, [
|
|
81
|
+
"--tw-text-opacity"
|
|
82
|
+
]);
|
|
83
|
+
return "&::marker";
|
|
84
|
+
},
|
|
74
85
|
]);
|
|
75
86
|
addVariant("selection", [
|
|
76
87
|
"& *::selection",
|
|
@@ -140,22 +151,11 @@ let variantPlugins = {
|
|
|
140
151
|
[
|
|
141
152
|
"visited",
|
|
142
153
|
({ container })=>{
|
|
143
|
-
|
|
154
|
+
(0, _removeAlphaVariables).removeAlphaVariables(container, [
|
|
144
155
|
"--tw-text-opacity",
|
|
145
156
|
"--tw-border-opacity",
|
|
146
|
-
"--tw-bg-opacity"
|
|
147
|
-
];
|
|
148
|
-
container.walkDecls((decl)=>{
|
|
149
|
-
if (toRemove.includes(decl.prop)) {
|
|
150
|
-
decl.remove();
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
for (const varName of toRemove){
|
|
154
|
-
if (decl.value.includes(`/ var(${varName})`)) {
|
|
155
|
-
decl.value = decl.value.replace(`/ var(${varName})`, "");
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
});
|
|
157
|
+
"--tw-bg-opacity",
|
|
158
|
+
]);
|
|
159
159
|
return "&:visited";
|
|
160
160
|
},
|
|
161
161
|
],
|
|
@@ -2657,7 +2657,7 @@ let corePlugins = {
|
|
|
2657
2657
|
let [fontSize, options] = Array.isArray(value) ? value : [
|
|
2658
2658
|
value
|
|
2659
2659
|
];
|
|
2660
|
-
let { lineHeight , letterSpacing } = (0, _isPlainObject).default(options) ? options : {
|
|
2660
|
+
let { lineHeight , letterSpacing , fontWeight } = (0, _isPlainObject).default(options) ? options : {
|
|
2661
2661
|
lineHeight: options
|
|
2662
2662
|
};
|
|
2663
2663
|
return {
|
|
@@ -2667,6 +2667,9 @@ let corePlugins = {
|
|
|
2667
2667
|
},
|
|
2668
2668
|
...letterSpacing === undefined ? {} : {
|
|
2669
2669
|
"letter-spacing": letterSpacing
|
|
2670
|
+
},
|
|
2671
|
+
...fontWeight === undefined ? {} : {
|
|
2672
|
+
"font-weight": fontWeight
|
|
2670
2673
|
}
|
|
2671
2674
|
};
|
|
2672
2675
|
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.defaultExtractor = defaultExtractor;
|
|
6
|
-
var
|
|
6
|
+
var _featureFlags = require("../featureFlags");
|
|
7
7
|
var regex = _interopRequireWildcard(require("./regex"));
|
|
8
8
|
function _getRequireWildcardCache() {
|
|
9
9
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -52,14 +52,21 @@ function defaultExtractor(context) {
|
|
|
52
52
|
/** @type {(string|string)[]} */ let results = [];
|
|
53
53
|
for (let pattern of patterns){
|
|
54
54
|
var ref;
|
|
55
|
-
results
|
|
55
|
+
results = [
|
|
56
|
+
...results,
|
|
57
|
+
...(ref = content.match(pattern)) !== null && ref !== void 0 ? ref : []
|
|
58
|
+
];
|
|
56
59
|
}
|
|
57
60
|
return results.filter((v)=>v !== undefined).map(clipAtBalancedParens);
|
|
58
61
|
};
|
|
59
62
|
}
|
|
60
63
|
function* buildRegExps(context) {
|
|
61
64
|
let separator = context.tailwindConfig.separator;
|
|
62
|
-
let variantGroupingEnabled = (0,
|
|
65
|
+
let variantGroupingEnabled = (0, _featureFlags).flagEnabled(context.tailwindConfig, "variantGrouping");
|
|
66
|
+
let prefix = context.tailwindConfig.prefix !== "" ? regex.optional(regex.pattern([
|
|
67
|
+
/-?/,
|
|
68
|
+
regex.escape(context.tailwindConfig.prefix)
|
|
69
|
+
])) : "";
|
|
63
70
|
let utility = regex.any([
|
|
64
71
|
// Arbitrary properties
|
|
65
72
|
/\[[^\s:'"`]+:[^\s\]]+\]/,
|
|
@@ -71,7 +78,7 @@ function* buildRegExps(context) {
|
|
|
71
78
|
regex.optional(regex.any([
|
|
72
79
|
regex.pattern([
|
|
73
80
|
// Arbitrary values
|
|
74
|
-
|
|
81
|
+
/-(?:\w+-)*\[[^\s:]+\]/,
|
|
75
82
|
// Not immediately followed by an `{[(`
|
|
76
83
|
/(?![{([]])/,
|
|
77
84
|
// optionally followed by an opacity modifier
|
|
@@ -79,7 +86,7 @@ function* buildRegExps(context) {
|
|
|
79
86
|
]),
|
|
80
87
|
regex.pattern([
|
|
81
88
|
// Arbitrary values
|
|
82
|
-
|
|
89
|
+
/-(?:\w+-)*\[[^\s]+\]/,
|
|
83
90
|
// Not immediately followed by an `{[(`
|
|
84
91
|
/(?![{([]])/,
|
|
85
92
|
// optionally followed by an opacity modifier
|
|
@@ -90,9 +97,8 @@ function* buildRegExps(context) {
|
|
|
90
97
|
])),
|
|
91
98
|
]),
|
|
92
99
|
]);
|
|
93
|
-
|
|
94
|
-
//
|
|
95
|
-
"((?=((",
|
|
100
|
+
let variantPatterns = [
|
|
101
|
+
// Without quotes
|
|
96
102
|
regex.any([
|
|
97
103
|
regex.pattern([
|
|
98
104
|
/([^\s"'`\[\\]+-)?\[[^\s"'`]+\]/,
|
|
@@ -102,25 +108,44 @@ function* buildRegExps(context) {
|
|
|
102
108
|
/[^\s"'`\[\\]+/,
|
|
103
109
|
separator
|
|
104
110
|
]),
|
|
105
|
-
]
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
/!?/,
|
|
109
|
-
variantGroupingEnabled ? regex.any([
|
|
110
|
-
// Or any of those things but grouped separated by commas
|
|
111
|
+
]),
|
|
112
|
+
// With quotes allowed
|
|
113
|
+
regex.any([
|
|
111
114
|
regex.pattern([
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
regex.zeroOrMore([
|
|
115
|
-
/,/,
|
|
116
|
-
utility
|
|
117
|
-
]),
|
|
118
|
-
/\)/
|
|
115
|
+
/([^\s"'`\[\\]+-)?\[[^\s`]+\]/,
|
|
116
|
+
separator
|
|
119
117
|
]),
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
regex.pattern([
|
|
119
|
+
/[^\s`\[\\]+/,
|
|
120
|
+
separator
|
|
121
|
+
]),
|
|
122
|
+
]),
|
|
123
|
+
];
|
|
124
|
+
for (const variantPattern of variantPatterns){
|
|
125
|
+
yield regex.pattern([
|
|
126
|
+
// Variants
|
|
127
|
+
"((?=((",
|
|
128
|
+
variantPattern,
|
|
129
|
+
")+))\\2)?",
|
|
130
|
+
// Important (optional)
|
|
131
|
+
/!?/,
|
|
132
|
+
prefix,
|
|
133
|
+
variantGroupingEnabled ? regex.any([
|
|
134
|
+
// Or any of those things but grouped separated by commas
|
|
135
|
+
regex.pattern([
|
|
136
|
+
/\(/,
|
|
137
|
+
utility,
|
|
138
|
+
regex.zeroOrMore([
|
|
139
|
+
/,/,
|
|
140
|
+
utility
|
|
141
|
+
]),
|
|
142
|
+
/\)/
|
|
143
|
+
]),
|
|
144
|
+
// Arbitrary properties, constrained utilities, arbitrary values, etc…
|
|
145
|
+
utility,
|
|
146
|
+
]) : utility,
|
|
147
|
+
]);
|
|
148
|
+
}
|
|
124
149
|
// 5. Inner matches
|
|
125
150
|
yield /[^<>"'`\s.(){}[\]#=%$]*[^<>"'`\s.(){}[\]#=%:$]/g;
|
|
126
151
|
}
|
|
@@ -42,7 +42,7 @@ function listKeys(obj) {
|
|
|
42
42
|
return list(Object.keys(obj));
|
|
43
43
|
}
|
|
44
44
|
function validatePath(config, path, defaultValue, themeOpts = {}) {
|
|
45
|
-
const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]
|
|
45
|
+
const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+|['"]+$/g, "");
|
|
46
46
|
const pathSegments = Array.isArray(path) ? path : (0, _toPath).toPath(pathString);
|
|
47
47
|
const value = (0, _dlv).default(config.theme, pathSegments, defaultValue);
|
|
48
48
|
if (value === undefined) {
|
|
@@ -140,6 +140,9 @@ let nodeTypePropertyMap = {
|
|
|
140
140
|
function _default({ tailwindConfig: config }) {
|
|
141
141
|
let functions = {
|
|
142
142
|
theme: (node, path, ...defaultValue)=>{
|
|
143
|
+
// Strip quotes from beginning and end of string
|
|
144
|
+
// This allows the alpha value to be present inside of quotes
|
|
145
|
+
path = path.replace(/^['"]+|['"]+$/g, "");
|
|
143
146
|
let matches = path.match(/^([^\s]+)(?![^\[]*\])(?:\s*\/\s*([^\/\s]+))$/);
|
|
144
147
|
let alpha = undefined;
|
|
145
148
|
if (matches) {
|
|
@@ -152,9 +155,13 @@ function _default({ tailwindConfig: config }) {
|
|
|
152
155
|
if (!isValid) {
|
|
153
156
|
throw node.error(error);
|
|
154
157
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
let maybeColor = (0, _pluginUtils).parseColorFormat(value);
|
|
159
|
+
let isColorFunction = maybeColor !== undefined && typeof maybeColor === "function";
|
|
160
|
+
if (alpha !== undefined || isColorFunction) {
|
|
161
|
+
if (alpha === undefined) {
|
|
162
|
+
alpha = 1.0;
|
|
163
|
+
}
|
|
164
|
+
value = (0, _withAlphaVariable).withAlphaValue(maybeColor, alpha, maybeColor);
|
|
158
165
|
}
|
|
159
166
|
return value;
|
|
160
167
|
},
|
package/lib/lib/generateRules.js
CHANGED
|
@@ -171,6 +171,7 @@ function applyVariant(variant, matches, context) {
|
|
|
171
171
|
return matches;
|
|
172
172
|
}
|
|
173
173
|
let args;
|
|
174
|
+
let isArbitraryVariant = false;
|
|
174
175
|
// Find partial arbitrary variants
|
|
175
176
|
if (variant.endsWith("]") && !variant.startsWith("[")) {
|
|
176
177
|
args = variant.slice(variant.lastIndexOf("[") + 1, -1);
|
|
@@ -182,6 +183,7 @@ function applyVariant(variant, matches, context) {
|
|
|
182
183
|
if (!(0, _setupContextUtils).isValidVariantFormatString(selector)) {
|
|
183
184
|
return [];
|
|
184
185
|
}
|
|
186
|
+
isArbitraryVariant = true;
|
|
185
187
|
let fn = (0, _setupContextUtils).parseVariant(selector);
|
|
186
188
|
let sort = Array.from(context.variantOrder.values()).pop() << 1n;
|
|
187
189
|
context.variantMap.set(variant, [
|
|
@@ -205,13 +207,16 @@ function applyVariant(variant, matches, context) {
|
|
|
205
207
|
rule1.clone()
|
|
206
208
|
]
|
|
207
209
|
});
|
|
208
|
-
for (let [variantSort, variantFunction] of variantFunctionTuples){
|
|
209
|
-
let clone = container.clone();
|
|
210
|
+
for (let [variantSort, variantFunction, containerFromArray] of variantFunctionTuples){
|
|
211
|
+
let clone = containerFromArray !== null && containerFromArray !== void 0 ? containerFromArray : container.clone();
|
|
210
212
|
let collectedFormats = [];
|
|
211
|
-
let originals = new Map();
|
|
212
213
|
function prepareBackup() {
|
|
213
|
-
|
|
214
|
-
clone.
|
|
214
|
+
// Already prepared, chicken out
|
|
215
|
+
if (clone.raws.neededBackup) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
clone.raws.neededBackup = true;
|
|
219
|
+
clone.walkRules((rule)=>rule.raws.originalSelector = rule.selector);
|
|
215
220
|
}
|
|
216
221
|
function modifySelectors(modifierFunction) {
|
|
217
222
|
prepareBackup();
|
|
@@ -264,7 +269,10 @@ function applyVariant(variant, matches, context) {
|
|
|
264
269
|
// then this might be the place too look at. One potential solution to this problem is
|
|
265
270
|
// reserving additional X places for these 'unknown' variants in between.
|
|
266
271
|
variantSort | BigInt(idx << ruleWithVariant.length),
|
|
267
|
-
variantFunction,
|
|
272
|
+
variantFunction,
|
|
273
|
+
// If the clone has been modified we have to pass that back
|
|
274
|
+
// though so each rule can use the modified container
|
|
275
|
+
clone.clone(),
|
|
268
276
|
]);
|
|
269
277
|
}
|
|
270
278
|
continue;
|
|
@@ -275,13 +283,15 @@ function applyVariant(variant, matches, context) {
|
|
|
275
283
|
if (ruleWithVariant === null) {
|
|
276
284
|
continue;
|
|
277
285
|
}
|
|
278
|
-
// We
|
|
286
|
+
// We had to backup selectors, therefore we assume that somebody touched
|
|
279
287
|
// `container` or `modifySelectors`. Let's see if they did, so that we
|
|
280
288
|
// can restore the selectors, and collect the format strings.
|
|
281
|
-
if (
|
|
289
|
+
if (clone.raws.neededBackup) {
|
|
290
|
+
delete clone.raws.neededBackup;
|
|
282
291
|
clone.walkRules((rule)=>{
|
|
283
|
-
|
|
284
|
-
|
|
292
|
+
let before = rule.raws.originalSelector;
|
|
293
|
+
if (!before) return;
|
|
294
|
+
delete rule.raws.originalSelector;
|
|
285
295
|
if (before === rule.selector) return; // No mutation happened
|
|
286
296
|
let modified = rule.selector;
|
|
287
297
|
// Rebuild the base selector, this is what plugin authors would do
|
|
@@ -321,7 +331,8 @@ function applyVariant(variant, matches, context) {
|
|
|
321
331
|
{
|
|
322
332
|
...meta,
|
|
323
333
|
sort: variantSort | meta.sort,
|
|
324
|
-
collectedFormats: ((_collectedFormats = meta.collectedFormats) !== null && _collectedFormats !== void 0 ? _collectedFormats : []).concat(collectedFormats)
|
|
334
|
+
collectedFormats: ((_collectedFormats = meta.collectedFormats) !== null && _collectedFormats !== void 0 ? _collectedFormats : []).concat(collectedFormats),
|
|
335
|
+
isArbitraryVariant
|
|
325
336
|
},
|
|
326
337
|
clone.nodes[0],
|
|
327
338
|
];
|
|
@@ -631,6 +642,7 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
631
642
|
selector: rule.selector,
|
|
632
643
|
candidate: original,
|
|
633
644
|
base: candidate.split(new RegExp(`\\${(ref2 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref2 !== void 0 ? ref2 : ":"}(?![^[]*\\])`)).pop(),
|
|
645
|
+
isArbitraryVariant: match1[0].isArbitraryVariant,
|
|
634
646
|
context
|
|
635
647
|
});
|
|
636
648
|
});
|
|
@@ -478,10 +478,11 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
478
478
|
throw new Error(`Your custom variant \`${variantName}\` has an invalid format string. Make sure it's an at-rule or contains a \`&\` placeholder.`);
|
|
479
479
|
}
|
|
480
480
|
if (Array.isArray(result)) {
|
|
481
|
-
return result.map((variant)=>parseVariant(variant));
|
|
481
|
+
return result.filter((variant)=>typeof variant === "string").map((variant)=>parseVariant(variant));
|
|
482
482
|
}
|
|
483
483
|
// result may be undefined with legacy variants that use APIs like `modifySelectors`
|
|
484
|
-
|
|
484
|
+
// result may also be a postcss node if someone was returning the result from `modifySelectors`
|
|
485
|
+
return result && typeof result === "string" && parseVariant(result)(api);
|
|
485
486
|
};
|
|
486
487
|
}
|
|
487
488
|
if (!isValidVariantFormatString(variantFunction)) {
|
|
@@ -746,6 +747,12 @@ function registerPlugins(plugins, context) {
|
|
|
746
747
|
...classes.map((cls)=>cls.slice(0, prefixLength) + "-" + cls.slice(prefixLength)),
|
|
747
748
|
];
|
|
748
749
|
}
|
|
750
|
+
if ([].concat(options === null || options === void 0 ? void 0 : options.type).includes("color")) {
|
|
751
|
+
classes = [
|
|
752
|
+
...classes,
|
|
753
|
+
...classes.flatMap((cls)=>Object.keys(context.tailwindConfig.theme.opacity).map((opacity)=>`${cls}/${opacity}`)),
|
|
754
|
+
];
|
|
755
|
+
}
|
|
749
756
|
return classes;
|
|
750
757
|
})() : [
|
|
751
758
|
util
|
package/lib/util/dataTypes.js
CHANGED
|
@@ -46,14 +46,12 @@ function normalize(value, isRoot = true) {
|
|
|
46
46
|
if (isRoot) {
|
|
47
47
|
value = value.trim();
|
|
48
48
|
}
|
|
49
|
-
// Add spaces around operators inside calc() that do not follow an operator
|
|
49
|
+
// Add spaces around operators inside math functions like calc() that do not follow an operator
|
|
50
50
|
// or '('.
|
|
51
|
-
value = value.replace(/calc\(.+\)/g, (match)=>{
|
|
51
|
+
value = value.replace(/(calc|min|max|clamp)\(.+\)/g, (match)=>{
|
|
52
52
|
return match.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
|
|
53
53
|
});
|
|
54
|
-
|
|
55
|
-
// or '('.
|
|
56
|
-
return value.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([\/])/g, "$1 $2 ");
|
|
54
|
+
return value;
|
|
57
55
|
}
|
|
58
56
|
function url(value) {
|
|
59
57
|
return value.startsWith("url(");
|
|
@@ -39,7 +39,7 @@ function formatVariantSelector(current, ...others) {
|
|
|
39
39
|
return current;
|
|
40
40
|
}
|
|
41
41
|
var ref1;
|
|
42
|
-
function finalizeSelector(format, { selector: selector1 , candidate , context , // Split by the separator, but ignore the separator inside square brackets:
|
|
42
|
+
function finalizeSelector(format, { selector: selector1 , candidate , context , isArbitraryVariant , // Split by the separator, but ignore the separator inside square brackets:
|
|
43
43
|
//
|
|
44
44
|
// E.g.: dark:lg:hover:[paint-order:markers]
|
|
45
45
|
// ┬ ┬ ┬ ┬
|
|
@@ -49,7 +49,8 @@ function finalizeSelector(format, { selector: selector1 , candidate , context ,
|
|
|
49
49
|
base =candidate.split(new RegExp(`\\${(ref1 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref1 !== void 0 ? ref1 : ":"}(?![^[]*\\])`)).pop() , }) {
|
|
50
50
|
var ref2;
|
|
51
51
|
let ast = (0, _postcssSelectorParser).default().astSync(selector1);
|
|
52
|
-
|
|
52
|
+
// We explicitly DO NOT prefix classes in arbitrary variants
|
|
53
|
+
if ((context === null || context === void 0 ? void 0 : (ref2 = context.tailwindConfig) === null || ref2 === void 0 ? void 0 : ref2.prefix) && !isArbitraryVariant) {
|
|
53
54
|
format = (0, _prefixSelector).default(context.tailwindConfig.prefix, format);
|
|
54
55
|
}
|
|
55
56
|
format = format.replace(PARENT, `.${(0, _escapeClassName).default(candidate)}`);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.removeAlphaVariables = removeAlphaVariables;
|
|
6
|
+
function removeAlphaVariables(container, toRemove) {
|
|
7
|
+
container.walkDecls((decl)=>{
|
|
8
|
+
if (toRemove.includes(decl.prop)) {
|
|
9
|
+
decl.remove();
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
for (let varName of toRemove){
|
|
13
|
+
if (decl.value.includes(`/ var(${varName})`)) {
|
|
14
|
+
decl.value = decl.value.replace(`/ var(${varName})`, "");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"@swc/jest": "^0.2.21",
|
|
48
48
|
"@swc/register": "^0.1.10",
|
|
49
49
|
"autoprefixer": "^10.4.7",
|
|
50
|
-
"cssnano": "^5.1.
|
|
51
|
-
"esbuild": "^0.14.
|
|
52
|
-
"eslint": "^8.
|
|
50
|
+
"cssnano": "^5.1.12",
|
|
51
|
+
"esbuild": "^0.14.48",
|
|
52
|
+
"eslint": "^8.18.0",
|
|
53
53
|
"eslint-config-prettier": "^8.5.0",
|
|
54
|
-
"eslint-plugin-prettier": "^4.
|
|
55
|
-
"jest": "^28.1.
|
|
56
|
-
"jest-diff": "^28.1.
|
|
57
|
-
"prettier": "^2.
|
|
54
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
55
|
+
"jest": "^28.1.2",
|
|
56
|
+
"jest-diff": "^28.1.1",
|
|
57
|
+
"prettier": "^2.7.1",
|
|
58
58
|
"prettier-plugin-tailwindcss": "^0.1.11",
|
|
59
59
|
"rimraf": "^3.0.0",
|
|
60
60
|
"source-map-js": "^1.0.2"
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"postcss": "^8.0.9"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"arg": "^5.0.
|
|
66
|
+
"arg": "^5.0.2",
|
|
67
67
|
"chokidar": "^3.5.3",
|
|
68
68
|
"color-name": "^1.1.4",
|
|
69
69
|
"detective": "^5.2.1",
|
|
@@ -79,12 +79,12 @@
|
|
|
79
79
|
"postcss": "^8.4.14",
|
|
80
80
|
"postcss-import": "^14.1.0",
|
|
81
81
|
"postcss-js": "^4.0.0",
|
|
82
|
-
"postcss-load-config": "^
|
|
82
|
+
"postcss-load-config": "^4.0.1",
|
|
83
83
|
"postcss-nested": "5.0.6",
|
|
84
84
|
"postcss-selector-parser": "^6.0.10",
|
|
85
85
|
"postcss-value-parser": "^4.2.0",
|
|
86
86
|
"quick-lru": "^5.1.1",
|
|
87
|
-
"resolve": "^1.22.
|
|
87
|
+
"resolve": "^1.22.1"
|
|
88
88
|
},
|
|
89
89
|
"browserslist": [
|
|
90
90
|
"> 1%",
|