tailwindcss 0.0.0-insiders.bef3838 → 0.0.0-insiders.c13afd3

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +75 -1
  2. package/LICENSE +1 -2
  3. package/lib/cli.js +9 -3
  4. package/lib/corePlugins.js +2 -1
  5. package/lib/css/preflight.css +1 -1
  6. package/lib/lib/expandApplyAtRules.js +7 -4
  7. package/lib/lib/expandTailwindAtRules.js +22 -12
  8. package/lib/lib/generateRules.js +79 -27
  9. package/lib/lib/normalizeTailwindDirectives.js +2 -1
  10. package/lib/lib/setupContextUtils.js +59 -4
  11. package/{nesting → lib/postcss-plugins/nesting}/README.md +0 -0
  12. package/lib/postcss-plugins/nesting/index.js +17 -0
  13. package/lib/postcss-plugins/nesting/plugin.js +53 -0
  14. package/lib/processTailwindFeatures.js +5 -0
  15. package/lib/util/normalizeConfig.js +9 -5
  16. package/lib/util/parseBoxShadowValue.js +1 -1
  17. package/lib/util/prefixSelector.js +4 -5
  18. package/nesting/index.js +2 -12
  19. package/package.json +13 -17
  20. package/peers/index.js +981 -1164
  21. package/src/cli.js +5 -3
  22. package/src/corePlugins.js +1 -0
  23. package/src/css/preflight.css +1 -1
  24. package/src/lib/expandApplyAtRules.js +5 -5
  25. package/src/lib/expandTailwindAtRules.js +25 -9
  26. package/src/lib/generateRules.js +81 -22
  27. package/src/lib/normalizeTailwindDirectives.js +1 -0
  28. package/src/lib/setupContextUtils.js +59 -5
  29. package/src/postcss-plugins/nesting/README.md +42 -0
  30. package/src/postcss-plugins/nesting/index.js +13 -0
  31. package/{nesting → src/postcss-plugins/nesting}/plugin.js +7 -4
  32. package/src/processTailwindFeatures.js +6 -0
  33. package/src/util/normalizeConfig.js +7 -5
  34. package/src/util/parseBoxShadowValue.js +1 -1
  35. package/src/util/prefixSelector.js +7 -5
package/CHANGELOG.md CHANGED
@@ -7,10 +7,75 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ - Nothing yet!
11
+
12
+ ## [3.0.22] - 2022-02-11
13
+
14
+ ### Fixed
15
+
16
+ - Temporarily move postcss to dependencies ([#7424](https://github.com/tailwindlabs/tailwindcss/pull/7424))
17
+
18
+ ## [3.0.21] - 2022-02-10
19
+
20
+ ### Fixed
21
+
22
+ - Move prettier plugin to dev dependencies ([#7418](https://github.com/tailwindlabs/tailwindcss/pull/7418))
23
+
24
+ ## [3.0.20] - 2022-02-10
25
+
26
+ ### Added
27
+
28
+ - Expose `context.sortClassList(classes)` ([#7412](https://github.com/tailwindlabs/tailwindcss/pull/7412))
29
+
30
+ ## [3.0.19] - 2022-02-07
31
+
32
+ ### Fixed
33
+
34
+ - Fix preflight border color fallback ([#7288](https://github.com/tailwindlabs/tailwindcss/pull/7288))
35
+ - Correctly parse shadow lengths without a leading zero ([#7289](https://github.com/tailwindlabs/tailwindcss/pull/7289))
36
+ - Don't crash when scanning extremely long class candidates ([#7331](https://github.com/tailwindlabs/tailwindcss/pull/7331))
37
+ - Use less hacky fix for URLs detected as custom properties ([#7275](https://github.com/tailwindlabs/tailwindcss/pull/7275))
38
+ - Correctly generate negative utilities when dash is before the prefix ([#7295](https://github.com/tailwindlabs/tailwindcss/pull/7295))
39
+ - Detect prefixed negative utilities in the safelist ([#7295](https://github.com/tailwindlabs/tailwindcss/pull/7295))
40
+
41
+ ## [3.0.18] - 2022-01-28
42
+
43
+ ### Fixed
44
+
45
+ - Fix `@apply` order regression (in `addComponents`, `addUtilities`, ...) ([#7232](https://github.com/tailwindlabs/tailwindcss/pull/7232))
46
+ - Quick fix for incorrect arbitrary properties when using URLs ([#7252](https://github.com/tailwindlabs/tailwindcss/pull/7252))
47
+
48
+ ## [3.0.17] - 2022-01-26
49
+
50
+ ### Fixed
51
+
52
+ - Remove false positive warning in CLI when using the `--content` option ([#7220](https://github.com/tailwindlabs/tailwindcss/pull/7220))
53
+
54
+ ## [3.0.16] - 2022-01-24
55
+
56
+ ### Fixed
57
+
58
+ - Ensure to transpile the PostCSS Nesting plugin (tailwindcss/nesting) ([#7080](https://github.com/tailwindlabs/tailwindcss/pull/7080))
59
+ - Improve various warnings ([#7118](https://github.com/tailwindlabs/tailwindcss/pull/7118))
60
+ - Fix grammatical mistake ([cca5a38](https://github.com/tailwindlabs/tailwindcss/commit/cca5a3804e1d3ee0214491921e1aec35bf62a813))
61
+
62
+ ## [3.0.15] - 2022-01-15
63
+
64
+ ### Fixed
65
+
66
+ - Temporarily remove optional chaining in nesting plugin ([#7077](https://github.com/tailwindlabs/tailwindcss/pull/7077))
67
+
68
+ ## [3.0.14] - 2022-01-14
69
+
10
70
  ### Added
11
71
 
12
72
  - Show warnings for invalid content config ([#7065](https://github.com/tailwindlabs/tailwindcss/pull/7065))
13
73
 
74
+ ### Fixed
75
+
76
+ - Only emit utility/component variants when those layers exist ([#7066](https://github.com/tailwindlabs/tailwindcss/pull/7066))
77
+ - Ensure nesting plugins can receive options ([#7016](https://github.com/tailwindlabs/tailwindcss/pull/7016))
78
+
14
79
  ## [3.0.13] - 2022-01-11
15
80
 
16
81
  ### Fixed
@@ -1800,7 +1865,16 @@ No release notes
1800
1865
 
1801
1866
  - Everything!
1802
1867
 
1803
- [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.13...HEAD
1868
+ [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.22...HEAD
1869
+ [3.0.22]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.21...v3.0.22
1870
+ [3.0.21]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.20...v3.0.21
1871
+ [3.0.20]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.19...v3.0.20
1872
+ [3.0.19]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.18...v3.0.19
1873
+ [3.0.18]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.17...v3.0.18
1874
+ [3.0.17]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.16...v3.0.17
1875
+ [3.0.16]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.15...v3.0.16
1876
+ [3.0.15]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.14...v3.0.15
1877
+ [3.0.14]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.13...v3.0.14
1804
1878
  [3.0.13]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.12...v3.0.13
1805
1879
  [3.0.12]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.11...v3.0.12
1806
1880
  [3.0.11]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.10...v3.0.11
package/LICENSE CHANGED
@@ -1,7 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) Adam Wathan <adam.wathan@gmail.com>
4
- Copyright (c) Jonathan Reinink <jonathan@reinink.ca>
3
+ Copyright (c) Tailwind Labs, Inc.
5
4
 
6
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
6
  of this software and associated documentation files (the "Software"), to deal
package/lib/cli.js CHANGED
@@ -400,7 +400,6 @@ async function build() {
400
400
  }
401
401
  function resolveConfig() {
402
402
  let config = configPath ? require(configPath) : {};
403
- let resolvedConfig = (0, _resolveConfig).default(config);
404
403
  if (args['--purge']) {
405
404
  _log.default.warn('purge-flag-deprecated', [
406
405
  'The `--purge` flag has been deprecated.',
@@ -411,9 +410,16 @@ async function build() {
411
410
  }
412
411
  }
413
412
  if (args['--content']) {
414
- resolvedConfig.content.files = args['--content'].split(/(?<!{[^}]+),/);
413
+ let files = args['--content'].split(/(?<!{[^}]+),/);
414
+ let resolvedConfig = (0, _resolveConfig).default(config, {
415
+ content: {
416
+ files
417
+ }
418
+ });
419
+ resolvedConfig.content.files = files;
420
+ return resolvedConfig;
415
421
  }
416
- return resolvedConfig;
422
+ return (0, _resolveConfig).default(config);
417
423
  }
418
424
  function extractFileGlobs(config) {
419
425
  return config.content.files.filter((file)=>{
@@ -184,7 +184,8 @@ let variantPlugins = {
184
184
  mode = 'media';
185
185
  _log.default.warn('darkmode-false', [
186
186
  'The `darkMode` option in your Tailwind CSS configuration is set to `false`, which now behaves the same as `media`.',
187
- 'Change `darkMode` to `media` or remove it entirely.',
187
+ 'Change `darkMode` to `media` or remove it entirely.',
188
+ 'https://tailwindcss.com/docs/upgrade-guide#remove-dark-mode-configuration',
188
189
  ]);
189
190
  }
190
191
  if (mode === 'class') {
@@ -9,7 +9,7 @@
9
9
  box-sizing: border-box; /* 1 */
10
10
  border-width: 0; /* 2 */
11
11
  border-style: solid; /* 2 */
12
- border-color: theme('borderColor.DEFAULT', 'currentColor'); /* 2 */
12
+ border-color: theme('borderColor.DEFAULT', currentColor); /* 2 */
13
13
  }
14
14
 
15
15
  ::before,
@@ -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);
@@ -192,8 +192,6 @@ function expandTailwindAtRules(context) {
192
192
  ...baseNodes,
193
193
  ...defaultNodes
194
194
  ], layerNodes.base.source));
195
- }
196
- if (layerNodes.base) {
197
195
  layerNodes.base.remove();
198
196
  }
199
197
  if (layerNodes.components) {
@@ -208,21 +206,33 @@ function expandTailwindAtRules(context) {
208
206
  ], layerNodes.utilities.source));
209
207
  layerNodes.utilities.remove();
210
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
+ });
211
221
  if (layerNodes.variants) {
212
- layerNodes.variants.before((0, _cloneNodes).default([
213
- ...screenNodes
214
- ], layerNodes.variants.source));
222
+ layerNodes.variants.before((0, _cloneNodes).default(variantNodes, layerNodes.variants.source));
215
223
  layerNodes.variants.remove();
216
- } else {
217
- root.append((0, _cloneNodes).default([
218
- ...screenNodes
219
- ], root.source));
224
+ } else if (variantNodes.length > 0) {
225
+ root.append((0, _cloneNodes).default(variantNodes, root.source));
220
226
  }
221
227
  // If we've got a utility layer and no utilities are generated there's likely something wrong
222
- // TODO: Detect utility variants only
223
- if (layerNodes.utilities && utilityNodes.size === 0 && screenNodes.size === 0) {
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) {
224
233
  _log.default.warn('content-problems', [
225
- 'No utilities were generated there is likely a problem with the `content` key in the tailwind config. For more information see the documentation: https://tailwindcss.com/docs/content-configuration',
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',
226
236
  ]);
227
237
  }
228
238
  // ---
@@ -33,32 +33,32 @@ function getClassNameFromSelector(selector) {
33
33
  // Example with dynamic classes:
34
34
  // ['grid-cols', '[[linename],1fr,auto]']
35
35
  // ['grid', 'cols-[[linename],1fr,auto]']
36
- function* candidatePermutations(candidate, lastIndex = Infinity) {
37
- if (lastIndex < 0) {
38
- return;
39
- }
40
- let dashIdx;
41
- if (lastIndex === Infinity && candidate.endsWith(']')) {
42
- let bracketIdx = candidate.indexOf('[');
43
- // If character before `[` isn't a dash or a slash, this isn't a dynamic class
44
- // eg. string[]
45
- dashIdx = [
46
- '-',
47
- '/'
48
- ].includes(candidate[bracketIdx - 1]) ? bracketIdx - 1 : -1;
49
- } else {
50
- dashIdx = candidate.lastIndexOf('-', lastIndex);
51
- }
52
- if (dashIdx < 0) {
53
- return;
36
+ function* candidatePermutations(candidate) {
37
+ let lastIndex = Infinity;
38
+ while(lastIndex >= 0){
39
+ let dashIdx;
40
+ if (lastIndex === Infinity && candidate.endsWith(']')) {
41
+ let bracketIdx = candidate.indexOf('[');
42
+ // If character before `[` isn't a dash or a slash, this isn't a dynamic class
43
+ // eg. string[]
44
+ dashIdx = [
45
+ '-',
46
+ '/'
47
+ ].includes(candidate[bracketIdx - 1]) ? bracketIdx - 1 : -1;
48
+ } else {
49
+ dashIdx = candidate.lastIndexOf('-', lastIndex);
50
+ }
51
+ if (dashIdx < 0) {
52
+ break;
53
+ }
54
+ let prefix = candidate.slice(0, dashIdx);
55
+ let modifier = candidate.slice(dashIdx + 1);
56
+ yield [
57
+ prefix,
58
+ modifier
59
+ ];
60
+ lastIndex = dashIdx - 1;
54
61
  }
55
- let prefix = candidate.slice(0, dashIdx);
56
- let modifier = candidate.slice(dashIdx + 1);
57
- yield [
58
- prefix,
59
- modifier
60
- ];
61
- yield* candidatePermutations(candidate, dashIdx - 1);
62
62
  }
63
63
  function applyPrefix(matches, context) {
64
64
  if (matches.length === 0 || context.tailwindConfig.prefix === '') {
@@ -72,8 +72,14 @@ function applyPrefix(matches, context) {
72
72
  match[1].clone()
73
73
  ]
74
74
  });
75
+ let classCandidate = match[1].raws.tailwind.classCandidate;
75
76
  container.walkRules((r)=>{
76
- r.selector = (0, _prefixSelector).default(context.tailwindConfig.prefix, r.selector);
77
+ // If this is a negative utility with a dash *before* the prefix we
78
+ // have to ensure that the generated selector matches the candidate
79
+ // Not doing this will cause `-tw-top-1` to generate the class `.tw--top-1`
80
+ // The disconnect between candidate <-> class can cause @apply to hard crash.
81
+ let shouldPrependNegative = classCandidate.startsWith('-');
82
+ r.selector = (0, _prefixSelector).default(context.tailwindConfig.prefix, r.selector, shouldPrependNegative);
77
83
  });
78
84
  match[1] = container.nodes[0];
79
85
  }
@@ -217,6 +223,14 @@ function applyVariant(variant, matches, context) {
217
223
  rule.selector = before;
218
224
  });
219
225
  }
226
+ // This tracks the originating layer for the variant
227
+ // For example:
228
+ // .sm:underline {} is a variant of something in the utilities layer
229
+ // .sm:container {} is a variant of the container component
230
+ clone.nodes[0].raws.tailwind = {
231
+ ...clone.nodes[0].raws.tailwind,
232
+ parentLayer: meta.layer
233
+ };
220
234
  var _collectedFormats;
221
235
  let withOffset = [
222
236
  {
@@ -260,7 +274,30 @@ const IS_VALID_PROPERTY_NAME = /^[a-z_-]/;
260
274
  function isValidPropName(name) {
261
275
  return IS_VALID_PROPERTY_NAME.test(name);
262
276
  }
277
+ /**
278
+ * @param {string} declaration
279
+ * @returns {boolean}
280
+ */ function looksLikeUri(declaration) {
281
+ // Quick bailout for obvious non-urls
282
+ // This doesn't support schemes that don't use a leading // but that's unlikely to be a problem
283
+ if (!declaration.includes('://')) {
284
+ return false;
285
+ }
286
+ try {
287
+ const url = new URL(declaration);
288
+ return url.scheme !== '' && url.host !== '';
289
+ } catch (err) {
290
+ // Definitely not a valid url
291
+ return false;
292
+ }
293
+ }
263
294
  function isParsableCssValue(property, value) {
295
+ // We don't want to to treat [https://example.com] as a custom property
296
+ // Even though, according to the CSS grammar, it's a totally valid CSS declaration
297
+ // So we short-circuit here by checking if the custom property looks like a url
298
+ if (looksLikeUri(`${property}:${value}`)) {
299
+ return false;
300
+ }
264
301
  try {
265
302
  _postcss.default.parse(`a{${property}:${value}}`).toResult();
266
303
  return true;
@@ -340,6 +377,15 @@ function* resolveMatchedPlugins(classCandidate, context) {
340
377
  function splitWithSeparator(input, separator) {
341
378
  return input.split(new RegExp(`\\${separator}(?![^[]*\\])`, 'g'));
342
379
  }
380
+ function* recordCandidates(matches, classCandidate) {
381
+ for (const match of matches){
382
+ match[1].raws.tailwind = {
383
+ ...match[1].raws.tailwind,
384
+ classCandidate
385
+ };
386
+ yield match;
387
+ }
388
+ }
343
389
  function* resolveMatches(candidate, context) {
344
390
  let separator = context.tailwindConfig.separator;
345
391
  let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse();
@@ -449,7 +495,9 @@ function* resolveMatches(candidate, context) {
449
495
  ]);
450
496
  continue;
451
497
  }
452
- matches = applyPrefix(matches.flat(), context);
498
+ matches = matches.flat();
499
+ matches = Array.from(recordCandidates(matches, classCandidate));
500
+ matches = applyPrefix(matches, context);
453
501
  if (important) {
454
502
  matches = applyImportant(matches, context);
455
503
  }
@@ -457,6 +505,10 @@ function* resolveMatches(candidate, context) {
457
505
  matches = applyVariant(variant, matches, context);
458
506
  }
459
507
  for (let match1 of matches){
508
+ match1[1].raws.tailwind = {
509
+ ...match1[1].raws.tailwind,
510
+ candidate
511
+ };
460
512
  // Apply final format selector
461
513
  if (match1[0].collectedFormats) {
462
514
  let finalFormat = (0, _formatVariantSelector).formatVariantSelector('&', ...match1[0].collectedFormats);
@@ -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);
@@ -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.`);
@@ -664,7 +669,8 @@ function registerPlugins(plugins, context) {
664
669
  if (value1 instanceof RegExp) {
665
670
  _log.default.warn('root-regex', [
666
671
  'Regular expressions in `safelist` work differently in Tailwind CSS v3.0.',
667
- 'Update your `safelist` configuration to eliminate this warning.'
672
+ 'Update your `safelist` configuration to eliminate this warning.',
673
+ 'https://tailwindcss.com/docs/content-configuration#safelisting-classes',
668
674
  ]);
669
675
  continue;
670
676
  }
@@ -672,18 +678,31 @@ function registerPlugins(plugins, context) {
672
678
  }
673
679
  if (checks.length > 0) {
674
680
  let patternMatchingCount = new Map();
681
+ let prefixLength = context.tailwindConfig.prefix.length;
675
682
  for (let util of classList){
676
683
  let utils = Array.isArray(util) ? (()=>{
677
684
  let [utilName, options] = util;
678
685
  var ref;
679
- 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)
686
+ let values = Object.keys((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {});
687
+ let classes = values.map((value)=>(0, _nameClass).formatClass(utilName, value)
680
688
  );
681
689
  if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
690
+ // This is the normal negated version
691
+ // e.g. `-inset-1` or `-tw-inset-1`
682
692
  classes = [
683
693
  ...classes,
684
694
  ...classes.map((cls)=>'-' + cls
685
695
  )
686
696
  ];
697
+ // This is the negated version *after* the prefix
698
+ // e.g. `tw--inset-1`
699
+ // The prefix is already attached to util name
700
+ // So we add the negative after the prefix
701
+ classes = [
702
+ ...classes,
703
+ ...classes.map((cls)=>cls.slice(0, prefixLength) + '-' + cls.slice(prefixLength)
704
+ ),
705
+ ];
687
706
  }
688
707
  return classes;
689
708
  })() : [
@@ -716,14 +735,50 @@ function registerPlugins(plugins, context) {
716
735
  if (count !== 0) continue;
717
736
  _log.default.warn([
718
737
  `The safelist pattern \`${regex}\` doesn't match any Tailwind CSS classes.`,
719
- 'Fix this pattern or remove it from your `safelist` configuration.',
738
+ 'Fix this pattern or remove it from your `safelist` configuration.',
739
+ 'https://tailwindcss.com/docs/content-configuration#safelisting-classes',
720
740
  ]);
721
741
  }
722
742
  }
723
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
+ };
724
779
  // Generate a list of strings for autocompletion purposes, e.g.
725
780
  // ['uppercase', 'lowercase', ...]
726
- context.getClassList = function() {
781
+ context.getClassList = function getClassList() {
727
782
  let output = [];
728
783
  for (let util of classList){
729
784
  if (Array.isArray(util)) {
@@ -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
+ }
@@ -24,6 +24,8 @@ function processTailwindFeatures(setupContext) {
24
24
  return function(root, result) {
25
25
  let { tailwindDirectives , applyDirectives } = (0, _normalizeTailwindDirectives).default(root);
26
26
  (0, _detectNesting).default()(root, result);
27
+ // Partition apply rules that are found in the css
28
+ // itself.
27
29
  (0, _partitionApplyAtRules).default()(root, result);
28
30
  let context = setupContext({
29
31
  tailwindDirectives,
@@ -44,6 +46,9 @@ function processTailwindFeatures(setupContext) {
44
46
  }
45
47
  (0, _featureFlags).issueFlagNotices(context.tailwindConfig);
46
48
  (0, _expandTailwindAtRules).default(context)(root, result);
49
+ // Partition apply rules that are generated by
50
+ // addComponents, addUtilities and so on.
51
+ (0, _partitionApplyAtRules).default()(root, result);
47
52
  (0, _expandApplyAtRules).default(context)(root, result);
48
53
  (0, _evaluateTailwindFunctions).default(context)(root, result);
49
54
  (0, _substituteScreenAtRules).default(context)(root, result);
@@ -123,7 +123,8 @@ function normalizeConfig(config) {
123
123
  if (!valid) {
124
124
  _log.default.warn('purge-deprecation', [
125
125
  'The `purge`/`content` options have changed in Tailwind CSS v3.0.',
126
- 'Update your configuration file to eliminate this warning.'
126
+ 'Update your configuration file to eliminate this warning.',
127
+ 'https://tailwindcss.com/docs/upgrade-guide#configure-content-sources',
127
128
  ]);
128
129
  }
129
130
  // Normalize the `safelist`
@@ -140,7 +141,8 @@ function normalizeConfig(config) {
140
141
  if (typeof config.prefix === 'function') {
141
142
  _log.default.warn('prefix-function', [
142
143
  'As of Tailwind CSS v3.0, `prefix` cannot be a function.',
143
- 'Update `prefix` in your configuration to be a string to eliminate this warning.'
144
+ 'Update `prefix` in your configuration to be a string to eliminate this warning.',
145
+ 'https://tailwindcss.com/docs/upgrade-guide#prefix-cannot-be-a-function',
144
146
  ]);
145
147
  config.prefix = '';
146
148
  } else {
@@ -221,15 +223,17 @@ function normalizeConfig(config) {
221
223
  for (let file of config.content.files){
222
224
  if (typeof file === 'string' && /{([^,]*?)}/g.test(file)) {
223
225
  _log.default.warn('invalid-glob-braces', [
224
- `The glob pattern ${(0, _log).dim(file)} in your config is invalid.`,
225
- ` Update it to ${(0, _log).dim(file.replace(/{([^,]*?)}/g, '$1'))} to silence this warning.`
226
+ `The glob pattern ${(0, _log).dim(file)} in your Tailwind CSS configuration is invalid.`,
227
+ `Update it to ${(0, _log).dim(file.replace(/{([^,]*?)}/g, '$1'))} to silence this warning.`
226
228
  ]);
227
229
  break;
228
230
  }
229
231
  }
230
232
  if (config.content.files.length === 0) {
231
233
  _log.default.warn('content-problems', [
232
- 'The `content` key is missing or empty. Please populate the content key as Tailwind generates utilities on-demand based on the files that use them. For more information see the documentation: https://tailwindcss.com/docs/content-configuration',
234
+ 'The `content` option in your Tailwind CSS configuration is missing or empty.',
235
+ 'Configure your content sources or your generated CSS will be missing styles.',
236
+ 'https://tailwindcss.com/docs/content-configuration',
233
237
  ]);
234
238
  }
235
239
  return config;
@@ -15,7 +15,7 @@ let COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brac
15
15
  ;
16
16
  let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
17
17
  ;
18
- let LENGTH = /^-?(\d+)(.*?)$/g;
18
+ let LENGTH = /^-?(\d+|\.\d+)(.*?)$/g;
19
19
  function parseBoxShadowValue(input) {
20
20
  let shadows = input.split(COMMA);
21
21
  return shadows.map((shadow)=>{