tailwindcss 3.0.22 → 3.0.23

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 CHANGED
@@ -9,6 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  - Nothing yet!
11
11
 
12
+ ## [3.0.23] - 2022-02-16
13
+
14
+ ### Fixed
15
+
16
+ - Remove opacity variables from `:visited` pseudo class ([#7458](https://github.com/tailwindlabs/tailwindcss/pull/7458))
17
+ - Support arbitrary values + calc + theme with quotes ([#7462](https://github.com/tailwindlabs/tailwindcss/pull/7462))
18
+ - Don't duplicate layer output when scanning content with variants + wildcards ([#7478](https://github.com/tailwindlabs/tailwindcss/pull/7478))
19
+ - Implement `getClassOrder` instead of `sortClassList` ([#7459](https://github.com/tailwindlabs/tailwindcss/pull/7459))
20
+
12
21
  ## [3.0.22] - 2022-02-11
13
22
 
14
23
  ### Fixed
@@ -1865,7 +1874,8 @@ No release notes
1865
1874
 
1866
1875
  - Everything!
1867
1876
 
1868
- [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.22...HEAD
1877
+ [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.23...HEAD
1878
+ [3.0.23]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.22...v3.0.23
1869
1879
  [3.0.22]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.21...v3.0.22
1870
1880
  [3.0.21]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.20...v3.0.21
1871
1881
  [3.0.20]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.19...v3.0.20
@@ -116,7 +116,28 @@ let variantPlugins = {
116
116
  'last-of-type',
117
117
  'only-of-type',
118
118
  // State
119
- 'visited',
119
+ [
120
+ 'visited',
121
+ ({ container })=>{
122
+ let toRemove = [
123
+ '--tw-text-opacity',
124
+ '--tw-border-opacity',
125
+ '--tw-bg-opacity'
126
+ ];
127
+ container.walkDecls((decl)=>{
128
+ if (toRemove.includes(decl.prop)) {
129
+ decl.remove();
130
+ return;
131
+ }
132
+ for (const varName of toRemove){
133
+ if (decl.value.includes(`/ var(${varName})`)) {
134
+ decl.value = decl.value.replace(`/ var(${varName})`, '');
135
+ }
136
+ }
137
+ });
138
+ return ':visited';
139
+ },
140
+ ],
120
141
  'target',
121
142
  [
122
143
  'open',
@@ -149,13 +170,22 @@ let variantPlugins = {
149
170
  ]
150
171
  );
151
172
  for (let [variantName, state] of pseudoVariants){
152
- addVariant(variantName, `&${state}`);
173
+ addVariant(variantName, (ctx)=>{
174
+ let result = typeof state === 'function' ? state(ctx) : state;
175
+ return `&${result}`;
176
+ });
153
177
  }
154
178
  for (let [variantName1, state1] of pseudoVariants){
155
- addVariant(`group-${variantName1}`, `:merge(.group)${state1} &`);
179
+ addVariant(`group-${variantName1}`, (ctx)=>{
180
+ let result = typeof state1 === 'function' ? state1(ctx) : state1;
181
+ return `:merge(.group)${result} &`;
182
+ });
156
183
  }
157
184
  for (let [variantName2, state2] of pseudoVariants){
158
- addVariant(`peer-${variantName2}`, `:merge(.peer)${state2} ~ &`);
185
+ addVariant(`peer-${variantName2}`, (ctx)=>{
186
+ let result = typeof state2 === 'function' ? state2(ctx) : state2;
187
+ return `:merge(.peer)${result} ~ &`;
188
+ });
159
189
  }
160
190
  },
161
191
  directionVariants: ({ addVariant })=>{
@@ -13,6 +13,8 @@ const PATTERNS = [
13
13
  /([^<>"'`\s]*\[\w*\("[^"'`\s]*"\)\])/.source,
14
14
  /([^<>"'`\s]*\[\w*\('[^"`\s]*'\)\])/.source,
15
15
  /([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source,
16
+ /([^<>"'`\s]*\[[^<>"'`\s]*\('[^"`\s]*'\)+\])/.source,
17
+ /([^<>"'`\s]*\[[^<>"'`\s]*\("[^'`\s]*"\)+\])/.source,
16
18
  /([^<>"'`\s]*\['[^"'`\s]*'\])/.source,
17
19
  /([^<>"'`\s]*\["[^"'`\s]*"\])/.source,
18
20
  /([^<>"'`\s]*\[[^<>"'`\s]*:[^\]\s]*\])/.source,
@@ -157,7 +157,7 @@ function expandTailwindAtRules(context) {
157
157
  // ---
158
158
  // Find potential rules in changed files
159
159
  let candidates = new Set([
160
- '*'
160
+ sharedState.NOT_ON_DEMAND
161
161
  ]);
162
162
  let seen = new Set();
163
163
  env.DEBUG && console.time('Reading changed files');
@@ -10,6 +10,7 @@ var _isPlainObject = _interopRequireDefault(require("../util/isPlainObject"));
10
10
  var _prefixSelector = _interopRequireDefault(require("../util/prefixSelector"));
11
11
  var _pluginUtils = require("../util/pluginUtils");
12
12
  var _log = _interopRequireDefault(require("../util/log"));
13
+ var sharedState = _interopRequireWildcard(require("./sharedState"));
13
14
  var _formatVariantSelector = require("../util/formatVariantSelector");
14
15
  var _nameClass = require("../util/nameClass");
15
16
  var _dataTypes = require("../util/dataTypes");
@@ -19,6 +20,27 @@ function _interopRequireDefault(obj) {
19
20
  default: obj
20
21
  };
21
22
  }
23
+ function _interopRequireWildcard(obj) {
24
+ if (obj && obj.__esModule) {
25
+ return obj;
26
+ } else {
27
+ var newObj = {};
28
+ if (obj != null) {
29
+ for(var key in obj){
30
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
31
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
32
+ if (desc.get || desc.set) {
33
+ Object.defineProperty(newObj, key, desc);
34
+ } else {
35
+ newObj[key] = obj[key];
36
+ }
37
+ }
38
+ }
39
+ }
40
+ newObj.default = obj;
41
+ return newObj;
42
+ }
43
+ }
22
44
  let classNameParser = (0, _postcssSelectorParser).default((selectors)=>{
23
45
  return selectors.first.filter(({ type })=>type === 'class'
24
46
  ).pop().value;
@@ -375,6 +397,11 @@ function* resolveMatchedPlugins(classCandidate, context) {
375
397
  }
376
398
  }
377
399
  function splitWithSeparator(input, separator) {
400
+ if (input === sharedState.NOT_ON_DEMAND) {
401
+ return [
402
+ sharedState.NOT_ON_DEMAND
403
+ ];
404
+ }
378
405
  return input.split(new RegExp(`\\${separator}(?![^[]*\\])`, 'g'));
379
406
  }
380
407
  function* recordCandidates(matches, classCandidate) {
@@ -152,7 +152,7 @@ function withIdentifiers(styles) {
152
152
  let [containsNonOnDemandableSelectors, candidates] = extractCandidates(node);
153
153
  // If this isn't "on-demandable", assign it a universal candidate to always include it.
154
154
  if (containsNonOnDemandableSelectors) {
155
- candidates.unshift('*');
155
+ candidates.unshift(sharedState.NOT_ON_DEMAND);
156
156
  }
157
157
  // However, it could be that it also contains "on-demandable" candidates.
158
158
  // E.g.: `span, .foo {}`, in that case it should still be possible to use
@@ -176,8 +176,8 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
176
176
  return (0, _prefixSelector).default(tailwindConfig.prefix, selector);
177
177
  }
178
178
  function prefixIdentifier(identifier, options) {
179
- if (identifier === '*') {
180
- return '*';
179
+ if (identifier === sharedState.NOT_ON_DEMAND) {
180
+ return sharedState.NOT_ON_DEMAND;
181
181
  }
182
182
  if (!options.respectPrefix) {
183
183
  return identifier;
@@ -749,7 +749,7 @@ function registerPlugins(plugins, context) {
749
749
  prefix(context, 'group'),
750
750
  prefix(context, 'peer')
751
751
  ]);
752
- context.sortClassList = function sortClassList(classes) {
752
+ context.getClassOrder = function getClassOrder(classes) {
753
753
  let sortedClassNames = new Map();
754
754
  for (let [sort, rule] of (0, _generateRules).generateRules(new Set(classes), context)){
755
755
  if (sortedClassNames.has(rule.raws.tailwind.candidate)) continue;
@@ -768,13 +768,7 @@ function registerPlugins(plugins, context) {
768
768
  className,
769
769
  order
770
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
- );
771
+ });
778
772
  };
779
773
  // Generate a list of strings for autocompletion purposes, e.g.
780
774
  // ['uppercase', 'lowercase', ...]
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.resolveDebug = resolveDebug;
6
- exports.contextSourcesMap = exports.configContextMap = exports.contextMap = exports.env = void 0;
6
+ exports.NOT_ON_DEMAND = exports.contextSourcesMap = exports.configContextMap = exports.contextMap = exports.env = void 0;
7
7
  const env = {
8
8
  NODE_ENV: process.env.NODE_ENV,
9
9
  DEBUG: resolveDebug(process.env.DEBUG)
@@ -15,6 +15,8 @@ const configContextMap = new Map();
15
15
  exports.configContextMap = configContextMap;
16
16
  const contextSourcesMap = new Map();
17
17
  exports.contextSourcesMap = contextSourcesMap;
18
+ const NOT_ON_DEMAND = new String('*');
19
+ exports.NOT_ON_DEMAND = NOT_ON_DEMAND;
18
20
  function resolveDebug(debug) {
19
21
  if (debug === undefined) {
20
22
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss",
3
- "version": "3.0.22",
3
+ "version": "3.0.23",
4
4
  "description": "A utility-first CSS framework for rapidly building custom user interfaces.",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -44,12 +44,12 @@
44
44
  "@swc/register": "^0.1.10",
45
45
  "autoprefixer": "^10.4.2",
46
46
  "cssnano": "^5.0.16",
47
- "esbuild": "^0.14.10",
47
+ "esbuild": "^0.14.21",
48
48
  "eslint": "^8.8.0",
49
49
  "eslint-config-prettier": "^8.3.0",
50
50
  "eslint-plugin-prettier": "^4.0.0",
51
- "jest": "^27.4.7",
52
- "jest-diff": "^27.4.6",
51
+ "jest": "^27.5.1",
52
+ "jest-diff": "^27.5.1",
53
53
  "prettier": "^2.5.1",
54
54
  "prettier-plugin-tailwindcss": "^0.1.7",
55
55
  "rimraf": "^3.0.0"
package/peers/index.js CHANGED
@@ -22,31 +22,31 @@ var require_picocolors = __commonJS({
22
22
  };
23
23
  var createColors = (enabled = isColorSupported) => ({
24
24
  isColorSupported: enabled,
25
- reset: enabled ? (s) => `${s}` : String,
26
- bold: enabled ? formatter("", "", "") : String,
27
- dim: enabled ? formatter("", "", "") : String,
28
- italic: enabled ? formatter("", "") : String,
29
- underline: enabled ? formatter("", "") : String,
30
- inverse: enabled ? formatter("", "") : String,
31
- hidden: enabled ? formatter("", "") : String,
32
- strikethrough: enabled ? formatter("", "") : String,
33
- black: enabled ? formatter("", "") : String,
34
- red: enabled ? formatter("", "") : String,
35
- green: enabled ? formatter("", "") : String,
36
- yellow: enabled ? formatter("", "") : String,
37
- blue: enabled ? formatter("", "") : String,
38
- magenta: enabled ? formatter("", "") : String,
39
- cyan: enabled ? formatter("", "") : String,
40
- white: enabled ? formatter("", "") : String,
41
- gray: enabled ? formatter("", "") : String,
42
- bgBlack: enabled ? formatter("", "") : String,
43
- bgRed: enabled ? formatter("", "") : String,
44
- bgGreen: enabled ? formatter("", "") : String,
45
- bgYellow: enabled ? formatter("", "") : String,
46
- bgBlue: enabled ? formatter("", "") : String,
47
- bgMagenta: enabled ? formatter("", "") : String,
48
- bgCyan: enabled ? formatter("", "") : String,
49
- bgWhite: enabled ? formatter("", "") : String
25
+ reset: enabled ? (s) => `\x1B[0m${s}\x1B[0m` : String,
26
+ bold: enabled ? formatter("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m") : String,
27
+ dim: enabled ? formatter("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m") : String,
28
+ italic: enabled ? formatter("\x1B[3m", "\x1B[23m") : String,
29
+ underline: enabled ? formatter("\x1B[4m", "\x1B[24m") : String,
30
+ inverse: enabled ? formatter("\x1B[7m", "\x1B[27m") : String,
31
+ hidden: enabled ? formatter("\x1B[8m", "\x1B[28m") : String,
32
+ strikethrough: enabled ? formatter("\x1B[9m", "\x1B[29m") : String,
33
+ black: enabled ? formatter("\x1B[30m", "\x1B[39m") : String,
34
+ red: enabled ? formatter("\x1B[31m", "\x1B[39m") : String,
35
+ green: enabled ? formatter("\x1B[32m", "\x1B[39m") : String,
36
+ yellow: enabled ? formatter("\x1B[33m", "\x1B[39m") : String,
37
+ blue: enabled ? formatter("\x1B[34m", "\x1B[39m") : String,
38
+ magenta: enabled ? formatter("\x1B[35m", "\x1B[39m") : String,
39
+ cyan: enabled ? formatter("\x1B[36m", "\x1B[39m") : String,
40
+ white: enabled ? formatter("\x1B[37m", "\x1B[39m") : String,
41
+ gray: enabled ? formatter("\x1B[90m", "\x1B[39m") : String,
42
+ bgBlack: enabled ? formatter("\x1B[40m", "\x1B[49m") : String,
43
+ bgRed: enabled ? formatter("\x1B[41m", "\x1B[49m") : String,
44
+ bgGreen: enabled ? formatter("\x1B[42m", "\x1B[49m") : String,
45
+ bgYellow: enabled ? formatter("\x1B[43m", "\x1B[49m") : String,
46
+ bgBlue: enabled ? formatter("\x1B[44m", "\x1B[49m") : String,
47
+ bgMagenta: enabled ? formatter("\x1B[45m", "\x1B[49m") : String,
48
+ bgCyan: enabled ? formatter("\x1B[46m", "\x1B[49m") : String,
49
+ bgWhite: enabled ? formatter("\x1B[47m", "\x1B[49m") : String
50
50
  });
51
51
  module2.exports = createColors();
52
52
  module2.exports.createColors = createColors;
@@ -19743,7 +19743,7 @@ var require_parse_cst = __commonJS({
19743
19743
  str += "\b";
19744
19744
  break;
19745
19745
  case "e":
19746
- str += "";
19746
+ str += "\x1B";
19747
19747
  break;
19748
19748
  case "f":
19749
19749
  str += "\f";
@@ -70,7 +70,28 @@ export let variantPlugins = {
70
70
  'only-of-type',
71
71
 
72
72
  // State
73
- 'visited',
73
+ [
74
+ 'visited',
75
+ ({ container }) => {
76
+ let toRemove = ['--tw-text-opacity', '--tw-border-opacity', '--tw-bg-opacity']
77
+
78
+ container.walkDecls((decl) => {
79
+ if (toRemove.includes(decl.prop)) {
80
+ decl.remove()
81
+
82
+ return
83
+ }
84
+
85
+ for (const varName of toRemove) {
86
+ if (decl.value.includes(`/ var(${varName})`)) {
87
+ decl.value = decl.value.replace(`/ var(${varName})`, '')
88
+ }
89
+ }
90
+ })
91
+
92
+ return ':visited'
93
+ },
94
+ ],
74
95
  'target',
75
96
  ['open', '[open]'],
76
97
 
@@ -100,15 +121,27 @@ export let variantPlugins = {
100
121
  ].map((variant) => (Array.isArray(variant) ? variant : [variant, `:${variant}`]))
101
122
 
102
123
  for (let [variantName, state] of pseudoVariants) {
103
- addVariant(variantName, `&${state}`)
124
+ addVariant(variantName, (ctx) => {
125
+ let result = typeof state === 'function' ? state(ctx) : state
126
+
127
+ return `&${result}`
128
+ })
104
129
  }
105
130
 
106
131
  for (let [variantName, state] of pseudoVariants) {
107
- addVariant(`group-${variantName}`, `:merge(.group)${state} &`)
132
+ addVariant(`group-${variantName}`, (ctx) => {
133
+ let result = typeof state === 'function' ? state(ctx) : state
134
+
135
+ return `:merge(.group)${result} &`
136
+ })
108
137
  }
109
138
 
110
139
  for (let [variantName, state] of pseudoVariants) {
111
- addVariant(`peer-${variantName}`, `:merge(.peer)${state} ~ &`)
140
+ addVariant(`peer-${variantName}`, (ctx) => {
141
+ let result = typeof state === 'function' ? state(ctx) : state
142
+
143
+ return `:merge(.peer)${result} ~ &`
144
+ })
112
145
  }
113
146
  },
114
147
 
@@ -8,6 +8,8 @@ const PATTERNS = [
8
8
  /([^<>"'`\s]*\[\w*\("[^"'`\s]*"\)\])/.source, // bg-[url("...")]
9
9
  /([^<>"'`\s]*\[\w*\('[^"`\s]*'\)\])/.source, // bg-[url('...'),url('...')]
10
10
  /([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source, // bg-[url("..."),url("...")]
11
+ /([^<>"'`\s]*\[[^<>"'`\s]*\('[^"`\s]*'\)+\])/.source, // h-[calc(100%-theme('spacing.1'))]
12
+ /([^<>"'`\s]*\[[^<>"'`\s]*\("[^'`\s]*"\)+\])/.source, // h-[calc(100%-theme("spacing.1"))]
11
13
  /([^<>"'`\s]*\['[^"'`\s]*'\])/.source, // `content-['hello']` but not `content-['hello']']`
12
14
  /([^<>"'`\s]*\["[^"'`\s]*"\])/.source, // `content-["hello"]` but not `content-["hello"]"]`
13
15
  /([^<>"'`\s]*\[[^<>"'`\s]*:[^\]\s]*\])/.source, // `[attr:value]`
@@ -158,7 +158,7 @@ export default function expandTailwindAtRules(context) {
158
158
  // ---
159
159
 
160
160
  // Find potential rules in changed files
161
- let candidates = new Set(['*'])
161
+ let candidates = new Set([sharedState.NOT_ON_DEMAND])
162
162
  let seen = new Set()
163
163
 
164
164
  env.DEBUG && console.time('Reading changed files')
@@ -5,6 +5,7 @@ import isPlainObject from '../util/isPlainObject'
5
5
  import prefixSelector from '../util/prefixSelector'
6
6
  import { updateAllClasses } from '../util/pluginUtils'
7
7
  import log from '../util/log'
8
+ import * as sharedState from './sharedState'
8
9
  import { formatVariantSelector, finalizeSelector } from '../util/formatVariantSelector'
9
10
  import { asClass } from '../util/nameClass'
10
11
  import { normalize } from '../util/dataTypes'
@@ -382,6 +383,10 @@ function* resolveMatchedPlugins(classCandidate, context) {
382
383
  }
383
384
 
384
385
  function splitWithSeparator(input, separator) {
386
+ if (input === sharedState.NOT_ON_DEMAND) {
387
+ return [sharedState.NOT_ON_DEMAND]
388
+ }
389
+
385
390
  return input.split(new RegExp(`\\${separator}(?![^[]*\\])`, 'g'))
386
391
  }
387
392
 
@@ -138,7 +138,7 @@ function withIdentifiers(styles) {
138
138
 
139
139
  // If this isn't "on-demandable", assign it a universal candidate to always include it.
140
140
  if (containsNonOnDemandableSelectors) {
141
- candidates.unshift('*')
141
+ candidates.unshift(sharedState.NOT_ON_DEMAND)
142
142
  }
143
143
 
144
144
  // However, it could be that it also contains "on-demandable" candidates.
@@ -163,8 +163,8 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
163
163
  }
164
164
 
165
165
  function prefixIdentifier(identifier, options) {
166
- if (identifier === '*') {
167
- return '*'
166
+ if (identifier === sharedState.NOT_ON_DEMAND) {
167
+ return sharedState.NOT_ON_DEMAND
168
168
  }
169
169
 
170
170
  if (!options.respectPrefix) {
@@ -744,33 +744,25 @@ function registerPlugins(plugins, context) {
744
744
  // sorting could be weird since you still require them in order to make the
745
745
  // host utitlies work properly. (Thanks Biology)
746
746
  let parasiteUtilities = new Set([prefix(context, 'group'), prefix(context, 'peer')])
747
- context.sortClassList = function sortClassList(classes) {
747
+ context.getClassOrder = function getClassOrder(classes) {
748
748
  let sortedClassNames = new Map()
749
749
  for (let [sort, rule] of generateRules(new Set(classes), context)) {
750
750
  if (sortedClassNames.has(rule.raws.tailwind.candidate)) continue
751
751
  sortedClassNames.set(rule.raws.tailwind.candidate, sort)
752
752
  }
753
753
 
754
- return classes
755
- .map((className) => {
756
- let order = sortedClassNames.get(className) ?? null
754
+ return classes.map((className) => {
755
+ let order = sortedClassNames.get(className) ?? null
757
756
 
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
- }
757
+ if (order === null && parasiteUtilities.has(className)) {
758
+ // This will make sure that it is at the very beginning of the
759
+ // `components` layer which technically means 'before any
760
+ // components'.
761
+ order = context.layerOrder.components
762
+ }
764
763
 
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)
764
+ return [className, order]
765
+ })
774
766
  }
775
767
 
776
768
  // Generate a list of strings for autocompletion purposes, e.g.
@@ -5,6 +5,7 @@ export const env = {
5
5
  export const contextMap = new Map()
6
6
  export const configContextMap = new Map()
7
7
  export const contextSourcesMap = new Map()
8
+ export const NOT_ON_DEMAND = new String('*')
8
9
 
9
10
  export function resolveDebug(debug) {
10
11
  if (debug === undefined) {