tailwindcss 3.0.19 → 3.0.20
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 +9 -2
- package/lib/lib/expandApplyAtRules.js +7 -4
- package/lib/lib/generateRules.js +6 -0
- package/lib/lib/setupContextUtils.js +41 -1
- package/package.json +3 -2
- package/peers/index.js +30 -21
- package/src/lib/expandApplyAtRules.js +5 -5
- package/src/lib/generateRules.js +4 -2
- package/src/lib/setupContextUtils.js +41 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
Nothing yet!
|
|
10
|
+
- Nothing yet!
|
|
11
|
+
|
|
12
|
+
## [3.0.20] - 2022-02-10
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Expose `context.sortClassList(classes)` ([#7412](https://github.com/tailwindlabs/tailwindcss/pull/7412))
|
|
11
17
|
|
|
12
18
|
## [3.0.19] - 2022-02-07
|
|
13
19
|
|
|
@@ -1847,7 +1853,8 @@ No release notes
|
|
|
1847
1853
|
|
|
1848
1854
|
- Everything!
|
|
1849
1855
|
|
|
1850
|
-
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.
|
|
1856
|
+
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.20...HEAD
|
|
1857
|
+
[3.0.20]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.19...v3.0.20
|
|
1851
1858
|
[3.0.19]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.18...v3.0.19
|
|
1852
1859
|
[3.0.18]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.17...v3.0.18
|
|
1853
1860
|
[3.0.17]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.16...v3.0.17
|
|
@@ -140,11 +140,14 @@ function processApply(root, context) {
|
|
|
140
140
|
throw apply.error(`@apply is not supported within nested at-rules like @${apply.parent.name}. You can fix this by un-nesting @${apply.parent.name}.`);
|
|
141
141
|
}
|
|
142
142
|
for (let applyCandidate of applyCandidates){
|
|
143
|
+
if ([
|
|
144
|
+
prefix(context, 'group'),
|
|
145
|
+
prefix(context, 'peer')
|
|
146
|
+
].includes(applyCandidate)) {
|
|
147
|
+
// TODO: Link to specific documentation page with error code.
|
|
148
|
+
throw apply.error(`@apply should not be used with the '${applyCandidate}' utility`);
|
|
149
|
+
}
|
|
143
150
|
if (!applyClassCache.has(applyCandidate)) {
|
|
144
|
-
if (applyCandidate === prefix(context, 'group')) {
|
|
145
|
-
// TODO: Link to specific documentation page with error code.
|
|
146
|
-
throw apply.error(`@apply should not be used with the '${applyCandidate}' utility`);
|
|
147
|
-
}
|
|
148
151
|
throw apply.error(`The \`${applyCandidate}\` class does not exist. If \`${applyCandidate}\` is a custom class, make sure it is defined within a \`@layer\` directive.`);
|
|
149
152
|
}
|
|
150
153
|
let rules = applyClassCache.get(applyCandidate);
|
package/lib/lib/generateRules.js
CHANGED
|
@@ -228,6 +228,7 @@ function applyVariant(variant, matches, context) {
|
|
|
228
228
|
// .sm:underline {} is a variant of something in the utilities layer
|
|
229
229
|
// .sm:container {} is a variant of the container component
|
|
230
230
|
clone.nodes[0].raws.tailwind = {
|
|
231
|
+
...clone.nodes[0].raws.tailwind,
|
|
231
232
|
parentLayer: meta.layer
|
|
232
233
|
};
|
|
233
234
|
var _collectedFormats;
|
|
@@ -379,6 +380,7 @@ function splitWithSeparator(input, separator) {
|
|
|
379
380
|
function* recordCandidates(matches, classCandidate) {
|
|
380
381
|
for (const match of matches){
|
|
381
382
|
match[1].raws.tailwind = {
|
|
383
|
+
...match[1].raws.tailwind,
|
|
382
384
|
classCandidate
|
|
383
385
|
};
|
|
384
386
|
yield match;
|
|
@@ -503,6 +505,10 @@ function* resolveMatches(candidate, context) {
|
|
|
503
505
|
matches = applyVariant(variant, matches, context);
|
|
504
506
|
}
|
|
505
507
|
for (let match1 of matches){
|
|
508
|
+
match1[1].raws.tailwind = {
|
|
509
|
+
...match1[1].raws.tailwind,
|
|
510
|
+
candidate
|
|
511
|
+
};
|
|
506
512
|
// Apply final format selector
|
|
507
513
|
if (match1[0].collectedFormats) {
|
|
508
514
|
let finalFormat = (0, _formatVariantSelector).formatVariantSelector('&', ...match1[0].collectedFormats);
|
|
@@ -24,6 +24,7 @@ var _toPath = require("../util/toPath");
|
|
|
24
24
|
var _log = _interopRequireDefault(require("../util/log"));
|
|
25
25
|
var _negateValue = _interopRequireDefault(require("../util/negateValue"));
|
|
26
26
|
var _isValidArbitraryValue = _interopRequireDefault(require("../util/isValidArbitraryValue"));
|
|
27
|
+
var _generateRules = require("./generateRules");
|
|
27
28
|
function _interopRequireDefault(obj) {
|
|
28
29
|
return obj && obj.__esModule ? obj : {
|
|
29
30
|
default: obj
|
|
@@ -50,6 +51,10 @@ function _interopRequireWildcard(obj) {
|
|
|
50
51
|
return newObj;
|
|
51
52
|
}
|
|
52
53
|
}
|
|
54
|
+
function prefix(context, selector) {
|
|
55
|
+
let prefix1 = context.tailwindConfig.prefix;
|
|
56
|
+
return typeof prefix1 === 'function' ? prefix1(selector) : prefix1 + selector;
|
|
57
|
+
}
|
|
53
58
|
function parseVariantFormatString(input) {
|
|
54
59
|
if (input.includes('{')) {
|
|
55
60
|
if (!isBalanced(input)) throw new Error(`Your { and } are unbalanced.`);
|
|
@@ -736,9 +741,44 @@ function registerPlugins(plugins, context) {
|
|
|
736
741
|
}
|
|
737
742
|
}
|
|
738
743
|
}
|
|
744
|
+
// A list of utilities that are used by certain Tailwind CSS utilities but
|
|
745
|
+
// that don't exist on their own. This will result in them "not existing" and
|
|
746
|
+
// sorting could be weird since you still require them in order to make the
|
|
747
|
+
// host utitlies work properly. (Thanks Biology)
|
|
748
|
+
let parasiteUtilities = new Set([
|
|
749
|
+
prefix(context, 'group'),
|
|
750
|
+
prefix(context, 'peer')
|
|
751
|
+
]);
|
|
752
|
+
context.sortClassList = function sortClassList(classes) {
|
|
753
|
+
let sortedClassNames = new Map();
|
|
754
|
+
for (let [sort, rule] of (0, _generateRules).generateRules(new Set(classes), context)){
|
|
755
|
+
if (sortedClassNames.has(rule.raws.tailwind.candidate)) continue;
|
|
756
|
+
sortedClassNames.set(rule.raws.tailwind.candidate, sort);
|
|
757
|
+
}
|
|
758
|
+
return classes.map((className)=>{
|
|
759
|
+
var ref;
|
|
760
|
+
let order = (ref = sortedClassNames.get(className)) !== null && ref !== void 0 ? ref : null;
|
|
761
|
+
if (order === null && parasiteUtilities.has(className)) {
|
|
762
|
+
// This will make sure that it is at the very beginning of the
|
|
763
|
+
// `components` layer which technically means 'before any
|
|
764
|
+
// components'.
|
|
765
|
+
order = context.layerOrder.components;
|
|
766
|
+
}
|
|
767
|
+
return [
|
|
768
|
+
className,
|
|
769
|
+
order
|
|
770
|
+
];
|
|
771
|
+
}).sort(([, a], [, z])=>{
|
|
772
|
+
if (a === z) return 0;
|
|
773
|
+
if (a === null) return -1;
|
|
774
|
+
if (z === null) return 1;
|
|
775
|
+
return (0, _bigSign).default(a - z);
|
|
776
|
+
}).map(([className])=>className
|
|
777
|
+
);
|
|
778
|
+
};
|
|
739
779
|
// Generate a list of strings for autocompletion purposes, e.g.
|
|
740
780
|
// ['uppercase', 'lowercase', ...]
|
|
741
|
-
context.getClassList = function() {
|
|
781
|
+
context.getClassList = function getClassList() {
|
|
742
782
|
let output = [];
|
|
743
783
|
for (let util of classList){
|
|
744
784
|
if (Array.isArray(util)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.20",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"eslint-plugin-prettier": "^4.0.0",
|
|
51
51
|
"jest": "^27.4.7",
|
|
52
52
|
"jest-diff": "^27.4.6",
|
|
53
|
-
"postcss": "^8.4.
|
|
53
|
+
"postcss": "^8.4.6",
|
|
54
54
|
"prettier": "^2.5.1",
|
|
55
55
|
"rimraf": "^3.0.0"
|
|
56
56
|
},
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"postcss-nested": "5.0.6",
|
|
78
78
|
"postcss-selector-parser": "^6.0.9",
|
|
79
79
|
"postcss-value-parser": "^4.2.0",
|
|
80
|
+
"prettier-plugin-tailwindcss": "^0.1.7",
|
|
80
81
|
"quick-lru": "^5.1.1",
|
|
81
82
|
"resolve": "^1.22.0"
|
|
82
83
|
},
|
package/peers/index.js
CHANGED
|
@@ -4407,11 +4407,13 @@ var require_parser = __commonJS({
|
|
|
4407
4407
|
if (brackets.length > 0)
|
|
4408
4408
|
this.unclosedBracket(bracket);
|
|
4409
4409
|
if (end && colon) {
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4410
|
+
if (!customProperty) {
|
|
4411
|
+
while (tokens.length) {
|
|
4412
|
+
token = tokens[tokens.length - 1][0];
|
|
4413
|
+
if (token !== "space" && token !== "comment")
|
|
4414
|
+
break;
|
|
4415
|
+
this.tokenizer.back(tokens.pop());
|
|
4416
|
+
}
|
|
4415
4417
|
}
|
|
4416
4418
|
this.decl(tokens, customProperty);
|
|
4417
4419
|
} else {
|
|
@@ -4467,7 +4469,14 @@ var require_parser = __commonJS({
|
|
|
4467
4469
|
node.raws.before += node.prop[0];
|
|
4468
4470
|
node.prop = node.prop.slice(1);
|
|
4469
4471
|
}
|
|
4470
|
-
let firstSpaces =
|
|
4472
|
+
let firstSpaces = [];
|
|
4473
|
+
let next;
|
|
4474
|
+
while (tokens.length) {
|
|
4475
|
+
next = tokens[0][0];
|
|
4476
|
+
if (next !== "space" && next !== "comment")
|
|
4477
|
+
break;
|
|
4478
|
+
firstSpaces.push(tokens.shift());
|
|
4479
|
+
}
|
|
4471
4480
|
this.precheckMissedSemicolon(tokens);
|
|
4472
4481
|
for (let i = tokens.length - 1; i >= 0; i--) {
|
|
4473
4482
|
token = tokens[i];
|
|
@@ -4499,12 +4508,11 @@ var require_parser = __commonJS({
|
|
|
4499
4508
|
}
|
|
4500
4509
|
}
|
|
4501
4510
|
let hasWord = tokens.some((i) => i[0] !== "space" && i[0] !== "comment");
|
|
4502
|
-
this.raw(node, "value", tokens);
|
|
4503
4511
|
if (hasWord) {
|
|
4504
|
-
node.raws.between += firstSpaces;
|
|
4505
|
-
|
|
4506
|
-
node.value = firstSpaces + node.value;
|
|
4512
|
+
node.raws.between += firstSpaces.map((i) => i[1]).join("");
|
|
4513
|
+
firstSpaces = [];
|
|
4507
4514
|
}
|
|
4515
|
+
this.raw(node, "value", firstSpaces.concat(tokens), customProperty);
|
|
4508
4516
|
if (node.value.includes(":") && !customProperty) {
|
|
4509
4517
|
this.checkMissedSemicolon(tokens);
|
|
4510
4518
|
}
|
|
@@ -4635,28 +4643,25 @@ var require_parser = __commonJS({
|
|
|
4635
4643
|
if (node.type !== "comment")
|
|
4636
4644
|
this.semicolon = false;
|
|
4637
4645
|
}
|
|
4638
|
-
raw(node, prop, tokens) {
|
|
4646
|
+
raw(node, prop, tokens, customProperty) {
|
|
4639
4647
|
let token, type;
|
|
4640
4648
|
let length = tokens.length;
|
|
4641
4649
|
let value = "";
|
|
4642
4650
|
let clean = true;
|
|
4643
4651
|
let next, prev;
|
|
4644
|
-
let pattern = /^([#.|])?(\w)+/i;
|
|
4645
4652
|
for (let i = 0; i < length; i += 1) {
|
|
4646
4653
|
token = tokens[i];
|
|
4647
4654
|
type = token[0];
|
|
4648
|
-
if (type === "
|
|
4655
|
+
if (type === "space" && i === length - 1 && !customProperty) {
|
|
4656
|
+
clean = false;
|
|
4657
|
+
} else if (type === "comment") {
|
|
4649
4658
|
prev = tokens[i - 1];
|
|
4650
4659
|
next = tokens[i + 1];
|
|
4651
|
-
if (prev[0] !== "space" && next[0] !== "space"
|
|
4660
|
+
if (prev && next && prev[0] !== "space" && next[0] !== "space") {
|
|
4652
4661
|
value += token[1];
|
|
4653
4662
|
} else {
|
|
4654
4663
|
clean = false;
|
|
4655
4664
|
}
|
|
4656
|
-
continue;
|
|
4657
|
-
}
|
|
4658
|
-
if (type === "comment" || type === "space" && i === length - 1) {
|
|
4659
|
-
clean = false;
|
|
4660
4665
|
} else {
|
|
4661
4666
|
value += token[1];
|
|
4662
4667
|
}
|
|
@@ -5356,8 +5361,12 @@ var require_no_work_result = __commonJS({
|
|
|
5356
5361
|
} catch (error) {
|
|
5357
5362
|
this.error = error;
|
|
5358
5363
|
}
|
|
5359
|
-
this.
|
|
5360
|
-
|
|
5364
|
+
if (this.error) {
|
|
5365
|
+
throw this.error;
|
|
5366
|
+
} else {
|
|
5367
|
+
this._root = root;
|
|
5368
|
+
return root;
|
|
5369
|
+
}
|
|
5361
5370
|
}
|
|
5362
5371
|
get messages() {
|
|
5363
5372
|
return [];
|
|
@@ -5408,7 +5417,7 @@ var require_processor = __commonJS({
|
|
|
5408
5417
|
var Root = require_root();
|
|
5409
5418
|
var Processor = class {
|
|
5410
5419
|
constructor(plugins = []) {
|
|
5411
|
-
this.version = "8.4.
|
|
5420
|
+
this.version = "8.4.6";
|
|
5412
5421
|
this.plugins = this.normalize(plugins);
|
|
5413
5422
|
}
|
|
5414
5423
|
use(plugin) {
|
|
@@ -161,12 +161,12 @@ function processApply(root, context) {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
for (let applyCandidate of applyCandidates) {
|
|
164
|
-
if (
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
164
|
+
if ([prefix(context, 'group'), prefix(context, 'peer')].includes(applyCandidate)) {
|
|
165
|
+
// TODO: Link to specific documentation page with error code.
|
|
166
|
+
throw apply.error(`@apply should not be used with the '${applyCandidate}' utility`)
|
|
167
|
+
}
|
|
169
168
|
|
|
169
|
+
if (!applyClassCache.has(applyCandidate)) {
|
|
170
170
|
throw apply.error(
|
|
171
171
|
`The \`${applyCandidate}\` class does not exist. If \`${applyCandidate}\` is a custom class, make sure it is defined within a \`@layer\` directive.`
|
|
172
172
|
)
|
package/src/lib/generateRules.js
CHANGED
|
@@ -234,7 +234,7 @@ function applyVariant(variant, matches, context) {
|
|
|
234
234
|
// For example:
|
|
235
235
|
// .sm:underline {} is a variant of something in the utilities layer
|
|
236
236
|
// .sm:container {} is a variant of the container component
|
|
237
|
-
clone.nodes[0].raws.tailwind = { parentLayer: meta.layer }
|
|
237
|
+
clone.nodes[0].raws.tailwind = { ...clone.nodes[0].raws.tailwind, parentLayer: meta.layer }
|
|
238
238
|
|
|
239
239
|
let withOffset = [
|
|
240
240
|
{
|
|
@@ -387,7 +387,7 @@ function splitWithSeparator(input, separator) {
|
|
|
387
387
|
|
|
388
388
|
function* recordCandidates(matches, classCandidate) {
|
|
389
389
|
for (const match of matches) {
|
|
390
|
-
match[1].raws.tailwind = { classCandidate }
|
|
390
|
+
match[1].raws.tailwind = { ...match[1].raws.tailwind, classCandidate }
|
|
391
391
|
|
|
392
392
|
yield match
|
|
393
393
|
}
|
|
@@ -517,6 +517,8 @@ function* resolveMatches(candidate, context) {
|
|
|
517
517
|
}
|
|
518
518
|
|
|
519
519
|
for (let match of matches) {
|
|
520
|
+
match[1].raws.tailwind = { ...match[1].raws.tailwind, candidate }
|
|
521
|
+
|
|
520
522
|
// Apply final format selector
|
|
521
523
|
if (match[0].collectedFormats) {
|
|
522
524
|
let finalFormat = formatVariantSelector('&', ...match[0].collectedFormats)
|
|
@@ -19,6 +19,12 @@ import { toPath } from '../util/toPath'
|
|
|
19
19
|
import log from '../util/log'
|
|
20
20
|
import negateValue from '../util/negateValue'
|
|
21
21
|
import isValidArbitraryValue from '../util/isValidArbitraryValue'
|
|
22
|
+
import { generateRules } from './generateRules'
|
|
23
|
+
|
|
24
|
+
function prefix(context, selector) {
|
|
25
|
+
let prefix = context.tailwindConfig.prefix
|
|
26
|
+
return typeof prefix === 'function' ? prefix(selector) : prefix + selector
|
|
27
|
+
}
|
|
22
28
|
|
|
23
29
|
function parseVariantFormatString(input) {
|
|
24
30
|
if (input.includes('{')) {
|
|
@@ -733,9 +739,43 @@ function registerPlugins(plugins, context) {
|
|
|
733
739
|
}
|
|
734
740
|
}
|
|
735
741
|
|
|
742
|
+
// A list of utilities that are used by certain Tailwind CSS utilities but
|
|
743
|
+
// that don't exist on their own. This will result in them "not existing" and
|
|
744
|
+
// sorting could be weird since you still require them in order to make the
|
|
745
|
+
// host utitlies work properly. (Thanks Biology)
|
|
746
|
+
let parasiteUtilities = new Set([prefix(context, 'group'), prefix(context, 'peer')])
|
|
747
|
+
context.sortClassList = function sortClassList(classes) {
|
|
748
|
+
let sortedClassNames = new Map()
|
|
749
|
+
for (let [sort, rule] of generateRules(new Set(classes), context)) {
|
|
750
|
+
if (sortedClassNames.has(rule.raws.tailwind.candidate)) continue
|
|
751
|
+
sortedClassNames.set(rule.raws.tailwind.candidate, sort)
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
return classes
|
|
755
|
+
.map((className) => {
|
|
756
|
+
let order = sortedClassNames.get(className) ?? null
|
|
757
|
+
|
|
758
|
+
if (order === null && parasiteUtilities.has(className)) {
|
|
759
|
+
// This will make sure that it is at the very beginning of the
|
|
760
|
+
// `components` layer which technically means 'before any
|
|
761
|
+
// components'.
|
|
762
|
+
order = context.layerOrder.components
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
return [className, order]
|
|
766
|
+
})
|
|
767
|
+
.sort(([, a], [, z]) => {
|
|
768
|
+
if (a === z) return 0
|
|
769
|
+
if (a === null) return -1
|
|
770
|
+
if (z === null) return 1
|
|
771
|
+
return bigSign(a - z)
|
|
772
|
+
})
|
|
773
|
+
.map(([className]) => className)
|
|
774
|
+
}
|
|
775
|
+
|
|
736
776
|
// Generate a list of strings for autocompletion purposes, e.g.
|
|
737
777
|
// ['uppercase', 'lowercase', ...]
|
|
738
|
-
context.getClassList = function () {
|
|
778
|
+
context.getClassList = function getClassList() {
|
|
739
779
|
let output = []
|
|
740
780
|
|
|
741
781
|
for (let util of classList) {
|