tailwindcss 3.0.12 → 3.0.16
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 +38 -5
- package/lib/cli.js +8 -16
- package/lib/corePlugins.js +71 -139
- package/lib/featureFlags.js +1 -2
- package/lib/lib/expandTailwindAtRules.js +29 -13
- package/lib/lib/generateRules.js +8 -2
- package/lib/lib/normalizeTailwindDirectives.js +2 -1
- package/lib/lib/partitionApplyAtRules.js +53 -0
- package/lib/lib/setupContextUtils.js +56 -120
- package/{nesting → lib/postcss-plugins/nesting}/README.md +0 -0
- package/lib/postcss-plugins/nesting/index.js +17 -0
- package/lib/postcss-plugins/nesting/plugin.js +53 -0
- package/lib/processTailwindFeatures.js +2 -0
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +4 -8
- package/lib/util/flattenColorPalette.js +1 -3
- package/lib/util/normalizeConfig.js +19 -16
- package/lib/util/normalizeScreens.js +2 -4
- package/lib/util/pluginUtils.js +5 -12
- package/lib/util/resolveConfig.js +9 -18
- package/lib/util/resolveConfigPath.js +1 -2
- package/lib/util/toColorValue.js +1 -2
- package/lib/util/transformThemeValue.js +4 -8
- package/nesting/index.js +2 -12
- package/package.json +10 -12
- package/peers/index.js +261 -231
- package/src/corePlugins.js +1 -0
- package/src/lib/expandTailwindAtRules.js +31 -6
- package/src/lib/generateRules.js +6 -0
- package/src/lib/normalizeTailwindDirectives.js +1 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/setupContextUtils.js +7 -75
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/{nesting → src/postcss-plugins/nesting}/plugin.js +7 -4
- package/src/processTailwindFeatures.js +2 -0
- package/src/util/normalizeConfig.js +12 -4
|
@@ -7,6 +7,7 @@ var _quickLru = _interopRequireDefault(require("quick-lru"));
|
|
|
7
7
|
var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
8
8
|
var _generateRules = require("./generateRules");
|
|
9
9
|
var _bigSign = _interopRequireDefault(require("../util/bigSign"));
|
|
10
|
+
var _log = _interopRequireDefault(require("../util/log"));
|
|
10
11
|
var _cloneNodes = _interopRequireDefault(require("../util/cloneNodes"));
|
|
11
12
|
var _defaultExtractor = require("./defaultExtractor");
|
|
12
13
|
function _interopRequireDefault(obj) {
|
|
@@ -18,13 +19,11 @@ function _interopRequireWildcard(obj) {
|
|
|
18
19
|
if (obj && obj.__esModule) {
|
|
19
20
|
return obj;
|
|
20
21
|
} else {
|
|
21
|
-
var newObj = {
|
|
22
|
-
};
|
|
22
|
+
var newObj = {};
|
|
23
23
|
if (obj != null) {
|
|
24
24
|
for(var key in obj){
|
|
25
25
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
26
|
-
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
|
27
|
-
};
|
|
26
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
28
27
|
if (desc.get || desc.set) {
|
|
29
28
|
Object.defineProperty(newObj, key, desc);
|
|
30
29
|
} else {
|
|
@@ -193,8 +192,6 @@ function expandTailwindAtRules(context) {
|
|
|
193
192
|
...baseNodes,
|
|
194
193
|
...defaultNodes
|
|
195
194
|
], layerNodes.base.source));
|
|
196
|
-
}
|
|
197
|
-
if (layerNodes.base) {
|
|
198
195
|
layerNodes.base.remove();
|
|
199
196
|
}
|
|
200
197
|
if (layerNodes.components) {
|
|
@@ -209,15 +206,34 @@ function expandTailwindAtRules(context) {
|
|
|
209
206
|
], layerNodes.utilities.source));
|
|
210
207
|
layerNodes.utilities.remove();
|
|
211
208
|
}
|
|
209
|
+
// We do post-filtering to not alter the emitted order of the variants
|
|
210
|
+
const variantNodes = Array.from(screenNodes).filter((node)=>{
|
|
211
|
+
var ref;
|
|
212
|
+
const parentLayer = (ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer;
|
|
213
|
+
if (parentLayer === 'components') {
|
|
214
|
+
return layerNodes.components !== null;
|
|
215
|
+
}
|
|
216
|
+
if (parentLayer === 'utilities') {
|
|
217
|
+
return layerNodes.utilities !== null;
|
|
218
|
+
}
|
|
219
|
+
return true;
|
|
220
|
+
});
|
|
212
221
|
if (layerNodes.variants) {
|
|
213
|
-
layerNodes.variants.before((0, _cloneNodes).default(
|
|
214
|
-
...screenNodes
|
|
215
|
-
], layerNodes.variants.source));
|
|
222
|
+
layerNodes.variants.before((0, _cloneNodes).default(variantNodes, layerNodes.variants.source));
|
|
216
223
|
layerNodes.variants.remove();
|
|
217
|
-
} else {
|
|
218
|
-
root.append((0, _cloneNodes).default(
|
|
219
|
-
|
|
220
|
-
|
|
224
|
+
} else if (variantNodes.length > 0) {
|
|
225
|
+
root.append((0, _cloneNodes).default(variantNodes, root.source));
|
|
226
|
+
}
|
|
227
|
+
// If we've got a utility layer and no utilities are generated there's likely something wrong
|
|
228
|
+
const hasUtilityVariants = variantNodes.some((node)=>{
|
|
229
|
+
var ref;
|
|
230
|
+
return ((ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer) === 'utilities';
|
|
231
|
+
});
|
|
232
|
+
if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
|
|
233
|
+
_log.default.warn('content-problems', [
|
|
234
|
+
'No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.',
|
|
235
|
+
'https://tailwindcss.com/docs/content-configuration',
|
|
236
|
+
]);
|
|
221
237
|
}
|
|
222
238
|
// ---
|
|
223
239
|
if (env.DEBUG) {
|
package/lib/lib/generateRules.js
CHANGED
|
@@ -217,6 +217,13 @@ function applyVariant(variant, matches, context) {
|
|
|
217
217
|
rule.selector = before;
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
|
+
// This tracks the originating layer for the variant
|
|
221
|
+
// For example:
|
|
222
|
+
// .sm:underline {} is a variant of something in the utilities layer
|
|
223
|
+
// .sm:container {} is a variant of the container component
|
|
224
|
+
clone.nodes[0].raws.tailwind = {
|
|
225
|
+
parentLayer: meta.layer
|
|
226
|
+
};
|
|
220
227
|
var _collectedFormats;
|
|
221
228
|
let withOffset = [
|
|
222
229
|
{
|
|
@@ -233,8 +240,7 @@ function applyVariant(variant, matches, context) {
|
|
|
233
240
|
}
|
|
234
241
|
return [];
|
|
235
242
|
}
|
|
236
|
-
function parseRules(rule, cache, options = {
|
|
237
|
-
}) {
|
|
243
|
+
function parseRules(rule, cache, options = {}) {
|
|
238
244
|
// PostCSS node
|
|
239
245
|
if (!(0, _isPlainObject).default(rule) && !Array.isArray(rule)) {
|
|
240
246
|
return [
|
|
@@ -49,7 +49,8 @@ function normalizeTailwindDirectives(root) {
|
|
|
49
49
|
].includes(atRule.name)) {
|
|
50
50
|
_log.default.warn(`${atRule.name}-at-rule-deprecated`, [
|
|
51
51
|
`The \`@${atRule.name}\` directive has been deprecated in Tailwind CSS v3.0.`,
|
|
52
|
-
`Use \`@layer utilities\` or \`@layer components\` instead.`,
|
|
52
|
+
`Use \`@layer utilities\` or \`@layer components\` instead.`,
|
|
53
|
+
'https://tailwindcss.com/docs/upgrade-guide#replace-variants-with-layer',
|
|
53
54
|
]);
|
|
54
55
|
}
|
|
55
56
|
layerDirectives.add(atRule);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.default = expandApplyAtRules;
|
|
6
|
+
function partitionRules(root) {
|
|
7
|
+
if (!root.walkAtRules) return;
|
|
8
|
+
let applyParents = new Set();
|
|
9
|
+
root.walkAtRules('apply', (rule)=>{
|
|
10
|
+
applyParents.add(rule.parent);
|
|
11
|
+
});
|
|
12
|
+
if (applyParents.size === 0) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
for (let rule1 of applyParents){
|
|
16
|
+
let nodeGroups = [];
|
|
17
|
+
let lastGroup = [];
|
|
18
|
+
for (let node of rule1.nodes){
|
|
19
|
+
if (node.type === 'atrule' && node.name === 'apply') {
|
|
20
|
+
if (lastGroup.length > 0) {
|
|
21
|
+
nodeGroups.push(lastGroup);
|
|
22
|
+
lastGroup = [];
|
|
23
|
+
}
|
|
24
|
+
nodeGroups.push([
|
|
25
|
+
node
|
|
26
|
+
]);
|
|
27
|
+
} else {
|
|
28
|
+
lastGroup.push(node);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (lastGroup.length > 0) {
|
|
32
|
+
nodeGroups.push(lastGroup);
|
|
33
|
+
}
|
|
34
|
+
if (nodeGroups.length === 1) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
for (let group of [
|
|
38
|
+
...nodeGroups
|
|
39
|
+
].reverse()){
|
|
40
|
+
let clone = rule1.clone({
|
|
41
|
+
nodes: []
|
|
42
|
+
});
|
|
43
|
+
clone.append(group);
|
|
44
|
+
rule1.after(clone);
|
|
45
|
+
}
|
|
46
|
+
rule1.remove();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function expandApplyAtRules() {
|
|
50
|
+
return (root)=>{
|
|
51
|
+
partitionRules(root);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -33,13 +33,11 @@ function _interopRequireWildcard(obj) {
|
|
|
33
33
|
if (obj && obj.__esModule) {
|
|
34
34
|
return obj;
|
|
35
35
|
} else {
|
|
36
|
-
var newObj = {
|
|
37
|
-
};
|
|
36
|
+
var newObj = {};
|
|
38
37
|
if (obj != null) {
|
|
39
38
|
for(var key in obj){
|
|
40
39
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
41
|
-
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
|
42
|
-
};
|
|
40
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
43
41
|
if (desc.get || desc.set) {
|
|
44
42
|
Object.defineProperty(newObj, key, desc);
|
|
45
43
|
} else {
|
|
@@ -52,55 +50,6 @@ function _interopRequireWildcard(obj) {
|
|
|
52
50
|
return newObj;
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
|
-
function partitionRules(root) {
|
|
56
|
-
if (!root.walkAtRules) return [
|
|
57
|
-
root
|
|
58
|
-
];
|
|
59
|
-
let applyParents = new Set();
|
|
60
|
-
let rules = [];
|
|
61
|
-
root.walkAtRules('apply', (rule)=>{
|
|
62
|
-
applyParents.add(rule.parent);
|
|
63
|
-
});
|
|
64
|
-
if (applyParents.size === 0) {
|
|
65
|
-
rules.push(root);
|
|
66
|
-
}
|
|
67
|
-
for (let rule1 of applyParents){
|
|
68
|
-
let nodeGroups = [];
|
|
69
|
-
let lastGroup = [];
|
|
70
|
-
for (let node of rule1.nodes){
|
|
71
|
-
if (node.type === 'atrule' && node.name === 'apply') {
|
|
72
|
-
if (lastGroup.length > 0) {
|
|
73
|
-
nodeGroups.push(lastGroup);
|
|
74
|
-
lastGroup = [];
|
|
75
|
-
}
|
|
76
|
-
nodeGroups.push([
|
|
77
|
-
node
|
|
78
|
-
]);
|
|
79
|
-
} else {
|
|
80
|
-
lastGroup.push(node);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (lastGroup.length > 0) {
|
|
84
|
-
nodeGroups.push(lastGroup);
|
|
85
|
-
}
|
|
86
|
-
if (nodeGroups.length === 1) {
|
|
87
|
-
rules.push(rule1);
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
for (let group of [
|
|
91
|
-
...nodeGroups
|
|
92
|
-
].reverse()){
|
|
93
|
-
let clone = rule1.clone({
|
|
94
|
-
nodes: []
|
|
95
|
-
});
|
|
96
|
-
clone.append(group);
|
|
97
|
-
rules.unshift(clone);
|
|
98
|
-
rule1.after(clone);
|
|
99
|
-
}
|
|
100
|
-
rule1.remove();
|
|
101
|
-
}
|
|
102
|
-
return rules;
|
|
103
|
-
}
|
|
104
53
|
function parseVariantFormatString(input) {
|
|
105
54
|
if (input.includes('{')) {
|
|
106
55
|
if (!isBalanced(input)) throw new Error(`Your { and } are unbalanced.`);
|
|
@@ -125,8 +74,7 @@ function isBalanced(input) {
|
|
|
125
74
|
}
|
|
126
75
|
return count === 0;
|
|
127
76
|
}
|
|
128
|
-
function insertInto(list, value, { before =[] } = {
|
|
129
|
-
}) {
|
|
77
|
+
function insertInto(list, value, { before =[] } = {}) {
|
|
130
78
|
before = [].concat(before);
|
|
131
79
|
if (before.length <= 0) {
|
|
132
80
|
list.push(value);
|
|
@@ -232,8 +180,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
232
180
|
return context.tailwindConfig.prefix + identifier;
|
|
233
181
|
}
|
|
234
182
|
return {
|
|
235
|
-
addVariant (variantName, variantFunctions, options = {
|
|
236
|
-
}) {
|
|
183
|
+
addVariant (variantName, variantFunctions, options = {}) {
|
|
237
184
|
variantFunctions = [].concat(variantFunctions).map((variantFunction)=>{
|
|
238
185
|
if (typeof variantFunction !== 'string') {
|
|
239
186
|
// Safelist public API functions
|
|
@@ -294,37 +241,34 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
294
241
|
return [];
|
|
295
242
|
},
|
|
296
243
|
addUserCss (userCss) {
|
|
297
|
-
for (let [identifier,
|
|
244
|
+
for (let [identifier, rule] of withIdentifiers(userCss)){
|
|
298
245
|
let offset = offsets.user++;
|
|
299
246
|
if (!context.candidateRuleMap.has(identifier)) {
|
|
300
247
|
context.candidateRuleMap.set(identifier, []);
|
|
301
248
|
}
|
|
302
|
-
context.candidateRuleMap.get(identifier).push(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
));
|
|
249
|
+
context.candidateRuleMap.get(identifier).push([
|
|
250
|
+
{
|
|
251
|
+
sort: offset,
|
|
252
|
+
layer: 'user'
|
|
253
|
+
},
|
|
254
|
+
rule
|
|
255
|
+
]);
|
|
310
256
|
}
|
|
311
257
|
},
|
|
312
258
|
addBase (base) {
|
|
313
|
-
for (let [identifier,
|
|
314
|
-
let prefixedIdentifier = prefixIdentifier(identifier, {
|
|
315
|
-
});
|
|
259
|
+
for (let [identifier, rule] of withIdentifiers(base)){
|
|
260
|
+
let prefixedIdentifier = prefixIdentifier(identifier, {});
|
|
316
261
|
let offset = offsets.base++;
|
|
317
262
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
318
263
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
319
264
|
}
|
|
320
|
-
context.candidateRuleMap.get(prefixedIdentifier).push(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
));
|
|
265
|
+
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
266
|
+
{
|
|
267
|
+
sort: offset,
|
|
268
|
+
layer: 'base'
|
|
269
|
+
},
|
|
270
|
+
rule
|
|
271
|
+
]);
|
|
328
272
|
}
|
|
329
273
|
},
|
|
330
274
|
/**
|
|
@@ -334,20 +278,18 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
334
278
|
const groups = {
|
|
335
279
|
[`@defaults ${group}`]: declarations
|
|
336
280
|
};
|
|
337
|
-
for (let [identifier,
|
|
338
|
-
let prefixedIdentifier = prefixIdentifier(identifier, {
|
|
339
|
-
});
|
|
281
|
+
for (let [identifier, rule] of withIdentifiers(groups)){
|
|
282
|
+
let prefixedIdentifier = prefixIdentifier(identifier, {});
|
|
340
283
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
341
284
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
342
285
|
}
|
|
343
|
-
context.candidateRuleMap.get(prefixedIdentifier).push(
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
));
|
|
286
|
+
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
287
|
+
{
|
|
288
|
+
sort: offsets.base++,
|
|
289
|
+
layer: 'defaults'
|
|
290
|
+
},
|
|
291
|
+
rule
|
|
292
|
+
]);
|
|
351
293
|
}
|
|
352
294
|
},
|
|
353
295
|
addComponents (components, options) {
|
|
@@ -355,24 +297,21 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
355
297
|
respectPrefix: true,
|
|
356
298
|
respectImportant: false
|
|
357
299
|
};
|
|
358
|
-
options = Object.assign({
|
|
359
|
-
|
|
360
|
-
} : options);
|
|
361
|
-
for (let [identifier, rule5] of withIdentifiers(components)){
|
|
300
|
+
options = Object.assign({}, defaultOptions, Array.isArray(options) ? {} : options);
|
|
301
|
+
for (let [identifier, rule] of withIdentifiers(components)){
|
|
362
302
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
363
303
|
classList.add(prefixedIdentifier);
|
|
364
304
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
365
305
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
366
306
|
}
|
|
367
|
-
context.candidateRuleMap.get(prefixedIdentifier).push(
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
));
|
|
307
|
+
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
308
|
+
{
|
|
309
|
+
sort: offsets.components++,
|
|
310
|
+
layer: 'components',
|
|
311
|
+
options
|
|
312
|
+
},
|
|
313
|
+
rule
|
|
314
|
+
]);
|
|
376
315
|
}
|
|
377
316
|
},
|
|
378
317
|
addUtilities (utilities, options) {
|
|
@@ -380,24 +319,21 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
380
319
|
respectPrefix: true,
|
|
381
320
|
respectImportant: true
|
|
382
321
|
};
|
|
383
|
-
options = Object.assign({
|
|
384
|
-
|
|
385
|
-
} : options);
|
|
386
|
-
for (let [identifier, rule6] of withIdentifiers(utilities)){
|
|
322
|
+
options = Object.assign({}, defaultOptions, Array.isArray(options) ? {} : options);
|
|
323
|
+
for (let [identifier, rule] of withIdentifiers(utilities)){
|
|
387
324
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
388
325
|
classList.add(prefixedIdentifier);
|
|
389
326
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
390
327
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
391
328
|
}
|
|
392
|
-
context.candidateRuleMap.get(prefixedIdentifier).push(
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
));
|
|
329
|
+
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
330
|
+
{
|
|
331
|
+
sort: offsets.utilities++,
|
|
332
|
+
layer: 'utilities',
|
|
333
|
+
options
|
|
334
|
+
},
|
|
335
|
+
rule
|
|
336
|
+
]);
|
|
401
337
|
}
|
|
402
338
|
},
|
|
403
339
|
matchUtilities: function(utilities, options) {
|
|
@@ -728,7 +664,8 @@ function registerPlugins(plugins, context) {
|
|
|
728
664
|
if (value1 instanceof RegExp) {
|
|
729
665
|
_log.default.warn('root-regex', [
|
|
730
666
|
'Regular expressions in `safelist` work differently in Tailwind CSS v3.0.',
|
|
731
|
-
'Update your `safelist` configuration to eliminate this warning.'
|
|
667
|
+
'Update your `safelist` configuration to eliminate this warning.',
|
|
668
|
+
'https://tailwindcss.com/docs/content-configuration#safelisting-classes',
|
|
732
669
|
]);
|
|
733
670
|
continue;
|
|
734
671
|
}
|
|
@@ -740,8 +677,7 @@ function registerPlugins(plugins, context) {
|
|
|
740
677
|
let utils = Array.isArray(util) ? (()=>{
|
|
741
678
|
let [utilName, options] = util;
|
|
742
679
|
var ref;
|
|
743
|
-
let classes = Object.keys((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
|
|
744
|
-
}).map((value)=>(0, _nameClass).formatClass(utilName, value)
|
|
680
|
+
let classes = Object.keys((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {}).map((value)=>(0, _nameClass).formatClass(utilName, value)
|
|
745
681
|
);
|
|
746
682
|
if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
|
|
747
683
|
classes = [
|
|
@@ -781,7 +717,8 @@ function registerPlugins(plugins, context) {
|
|
|
781
717
|
if (count !== 0) continue;
|
|
782
718
|
_log.default.warn([
|
|
783
719
|
`The safelist pattern \`${regex}\` doesn't match any Tailwind CSS classes.`,
|
|
784
|
-
'Fix this pattern or remove it from your `safelist` configuration.',
|
|
720
|
+
'Fix this pattern or remove it from your `safelist` configuration.',
|
|
721
|
+
'https://tailwindcss.com/docs/content-configuration#safelisting-classes',
|
|
785
722
|
]);
|
|
786
723
|
}
|
|
787
724
|
}
|
|
@@ -795,8 +732,7 @@ function registerPlugins(plugins, context) {
|
|
|
795
732
|
let [utilName, options] = util;
|
|
796
733
|
let negativeClasses = [];
|
|
797
734
|
var ref;
|
|
798
|
-
for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
|
|
799
|
-
})){
|
|
735
|
+
for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {})){
|
|
800
736
|
output.push((0, _nameClass).formatClass(utilName, key));
|
|
801
737
|
if ((options === null || options === void 0 ? void 0 : options.supportsNegativeValues) && (0, _negateValue).default(value)) {
|
|
802
738
|
negativeClasses.push((0, _nameClass).formatClass(utilName, `-${key}`));
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _plugin = require("./plugin");
|
|
7
|
+
var _default = Object.assign(function(opts) {
|
|
8
|
+
return {
|
|
9
|
+
postcssPlugin: 'tailwindcss/nesting',
|
|
10
|
+
Once (root, { result }) {
|
|
11
|
+
return (0, _plugin).nesting(opts)(root, result);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}, {
|
|
15
|
+
postcss: true
|
|
16
|
+
});
|
|
17
|
+
exports.default = _default;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.nesting = nesting;
|
|
6
|
+
var _postcss = _interopRequireDefault(require("postcss"));
|
|
7
|
+
var _postcssNested = _interopRequireDefault(require("postcss-nested"));
|
|
8
|
+
function _interopRequireDefault(obj) {
|
|
9
|
+
return obj && obj.__esModule ? obj : {
|
|
10
|
+
default: obj
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function nesting(opts = _postcssNested.default) {
|
|
14
|
+
return (root, result)=>{
|
|
15
|
+
root.walkAtRules('screen', (rule)=>{
|
|
16
|
+
rule.name = 'media';
|
|
17
|
+
rule.params = `screen(${rule.params})`;
|
|
18
|
+
});
|
|
19
|
+
root.walkAtRules('apply', (rule)=>{
|
|
20
|
+
rule.before(_postcss.default.decl({
|
|
21
|
+
prop: '__apply',
|
|
22
|
+
value: rule.params,
|
|
23
|
+
source: rule.source
|
|
24
|
+
}));
|
|
25
|
+
rule.remove();
|
|
26
|
+
});
|
|
27
|
+
let plugin = (()=>{
|
|
28
|
+
var ref;
|
|
29
|
+
if (typeof opts === 'function' || typeof opts === 'object' && (opts === null || opts === void 0 ? void 0 : (ref = opts.hasOwnProperty) === null || ref === void 0 ? void 0 : ref.call(opts, 'postcssPlugin'))) {
|
|
30
|
+
return opts;
|
|
31
|
+
}
|
|
32
|
+
if (typeof opts === 'string') {
|
|
33
|
+
return require(opts);
|
|
34
|
+
}
|
|
35
|
+
if (Object.keys(opts).length <= 0) {
|
|
36
|
+
return _postcssNested.default;
|
|
37
|
+
}
|
|
38
|
+
throw new Error('tailwindcss/nesting should be loaded with a nesting plugin.');
|
|
39
|
+
})();
|
|
40
|
+
(0, _postcss).default([
|
|
41
|
+
plugin
|
|
42
|
+
]).process(root, result.opts).sync();
|
|
43
|
+
root.walkDecls('__apply', (decl)=>{
|
|
44
|
+
decl.before(_postcss.default.atRule({
|
|
45
|
+
name: 'apply',
|
|
46
|
+
params: decl.value,
|
|
47
|
+
source: decl.source
|
|
48
|
+
}));
|
|
49
|
+
decl.remove();
|
|
50
|
+
});
|
|
51
|
+
return root;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -11,6 +11,7 @@ var _substituteScreenAtRules = _interopRequireDefault(require("./lib/substituteS
|
|
|
11
11
|
var _resolveDefaultsAtRules = _interopRequireDefault(require("./lib/resolveDefaultsAtRules"));
|
|
12
12
|
var _collapseAdjacentRules = _interopRequireDefault(require("./lib/collapseAdjacentRules"));
|
|
13
13
|
var _collapseDuplicateDeclarations = _interopRequireDefault(require("./lib/collapseDuplicateDeclarations"));
|
|
14
|
+
var _partitionApplyAtRules = _interopRequireDefault(require("./lib/partitionApplyAtRules"));
|
|
14
15
|
var _detectNesting = _interopRequireDefault(require("./lib/detectNesting"));
|
|
15
16
|
var _setupContextUtils = require("./lib/setupContextUtils");
|
|
16
17
|
var _featureFlags = require("./featureFlags");
|
|
@@ -23,6 +24,7 @@ function processTailwindFeatures(setupContext) {
|
|
|
23
24
|
return function(root, result) {
|
|
24
25
|
let { tailwindDirectives , applyDirectives } = (0, _normalizeTailwindDirectives).default(root);
|
|
25
26
|
(0, _detectNesting).default()(root, result);
|
|
27
|
+
(0, _partitionApplyAtRules).default()(root, result);
|
|
26
28
|
let context = setupContext({
|
|
27
29
|
tailwindDirectives,
|
|
28
30
|
applyDirectives,
|
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 {
|
|
@@ -16,8 +16,7 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
16
16
|
themeKey
|
|
17
17
|
]
|
|
18
18
|
]
|
|
19
|
-
], { filterDefault =false , ...options } = {
|
|
20
|
-
}) {
|
|
19
|
+
], { filterDefault =false , ...options } = {}) {
|
|
21
20
|
let transformValue = (0, _transformThemeValue).default(themeKey);
|
|
22
21
|
return function({ matchUtilities , theme }) {
|
|
23
22
|
for (let utilityVariation of utilityVariations){
|
|
@@ -37,15 +36,12 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
37
36
|
return Object.assign(obj, {
|
|
38
37
|
[name]: transformValue(value)
|
|
39
38
|
});
|
|
40
|
-
}, {
|
|
41
|
-
});
|
|
39
|
+
}, {});
|
|
42
40
|
}
|
|
43
41
|
});
|
|
44
|
-
}, {
|
|
45
|
-
}), {
|
|
42
|
+
}, {}), {
|
|
46
43
|
...options,
|
|
47
|
-
values: filterDefault ? Object.fromEntries(Object.entries((ref = theme(themeKey)) !== null && ref !== void 0 ? ref : {
|
|
48
|
-
}).filter(([modifier])=>modifier !== 'DEFAULT'
|
|
44
|
+
values: filterDefault ? Object.fromEntries(Object.entries((ref = theme(themeKey)) !== null && ref !== void 0 ? ref : {}).filter(([modifier])=>modifier !== 'DEFAULT'
|
|
49
45
|
)) : theme(themeKey)
|
|
50
46
|
});
|
|
51
47
|
}
|
|
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = void 0;
|
|
6
|
-
const flattenColorPalette = (colors)=>Object.assign({
|
|
7
|
-
}, ...Object.entries(colors !== null && colors !== void 0 ? colors : {
|
|
8
|
-
}).flatMap(([color, values])=>typeof values == 'object' ? Object.entries(flattenColorPalette(values)).map(([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])=>({
|
|
9
7
|
[color + (number === 'DEFAULT' ? '' : `-${number}`)]: hex
|
|
10
8
|
})
|
|
11
9
|
) : [
|