tailwindcss 3.1.3 → 3.1.6

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
@@ -7,7 +7,33 @@ 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
+ ### Fixed
11
+
12
+ - Fix usage on Node 12.x ([b4e637e](https://github.com/tailwindlabs/tailwindcss/commit/b4e637e2e096a9d6f2210efba9541f6fd4f28e56))
13
+ - Handle theme keys with slashes when using `theme()` in CSS ([#8831](https://github.com/tailwindlabs/tailwindcss/pull/8831))
14
+
15
+ ## [3.1.5] - 2022-07-07
16
+
17
+ ### Added
18
+
19
+ - Support configuring a default `font-weight` for each font size utility ([#8763](https://github.com/tailwindlabs/tailwindcss/pull/8763))
20
+ - Add support for alpha values in safe list ([#8774](https://github.com/tailwindlabs/tailwindcss/pull/8774))
21
+
22
+ ### Fixed
23
+
24
+ - Improve types to support fallback values in the CSS-in-JS syntax used in plugin APIs ([#8762](https://github.com/tailwindlabs/tailwindcss/pull/8762))
25
+ - Support including `tailwindcss` and `autoprefixer` in `postcss.config.js` in standalone CLI ([#8769](https://github.com/tailwindlabs/tailwindcss/pull/8769))
26
+ - Fix using special-characters as prefixes ([#8772](https://github.com/tailwindlabs/tailwindcss/pull/8772))
27
+ - Don’t prefix classes used within arbitrary variants ([#8773](https://github.com/tailwindlabs/tailwindcss/pull/8773))
28
+ - Add more explicit types for the default theme ([#8780](https://github.com/tailwindlabs/tailwindcss/pull/8780))
29
+
30
+ ## [3.1.4] - 2022-06-21
31
+
32
+ ### Fixed
33
+
34
+ - Provide default to `<alpha-value>` when using `theme()` ([#8652](https://github.com/tailwindlabs/tailwindcss/pull/8652))
35
+ - Detect arbitrary variants with quotes ([#8687](https://github.com/tailwindlabs/tailwindcss/pull/8687))
36
+ - Don’t add spaces around raw `/` that are preceded by numbers ([#8688](https://github.com/tailwindlabs/tailwindcss/pull/8688))
11
37
 
12
38
  ## [3.1.3] - 2022-06-14
13
39
 
@@ -1981,7 +2007,9 @@ No release notes
1981
2007
 
1982
2008
  - Everything!
1983
2009
 
1984
- [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.3...HEAD
2010
+ [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.5...HEAD
2011
+ [3.1.5]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.4...v3.1.5
2012
+ [3.1.4]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.3...v3.1.4
1985
2013
  [3.1.3]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.2...v3.1.3
1986
2014
  [3.1.2]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.1...v3.1.2
1987
2015
  [3.1.1]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.0...v3.1.1
package/defaultTheme.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import type { Config } from './types/config'
2
- declare const theme: Config['theme']
2
+ import { DefaultTheme } from './types/generated/default-theme'
3
+ declare const theme: Config['theme'] & DefaultTheme
3
4
  export = theme
@@ -2657,7 +2657,7 @@ let corePlugins = {
2657
2657
  let [fontSize, options] = Array.isArray(value) ? value : [
2658
2658
  value
2659
2659
  ];
2660
- let { lineHeight , letterSpacing } = (0, _isPlainObject).default(options) ? options : {
2660
+ let { lineHeight , letterSpacing , fontWeight } = (0, _isPlainObject).default(options) ? options : {
2661
2661
  lineHeight: options
2662
2662
  };
2663
2663
  return {
@@ -2667,6 +2667,9 @@ let corePlugins = {
2667
2667
  },
2668
2668
  ...letterSpacing === undefined ? {} : {
2669
2669
  "letter-spacing": letterSpacing
2670
+ },
2671
+ ...fontWeight === undefined ? {} : {
2672
+ "font-weight": fontWeight
2670
2673
  }
2671
2674
  };
2672
2675
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.defaultExtractor = defaultExtractor;
6
- var _featureFlagsJs = require("../featureFlags.js");
6
+ var _featureFlags = require("../featureFlags");
7
7
  var regex = _interopRequireWildcard(require("./regex"));
8
8
  function _getRequireWildcardCache() {
9
9
  if (typeof WeakMap !== "function") return null;
@@ -62,7 +62,11 @@ function defaultExtractor(context) {
62
62
  }
63
63
  function* buildRegExps(context) {
64
64
  let separator = context.tailwindConfig.separator;
65
- let variantGroupingEnabled = (0, _featureFlagsJs).flagEnabled(context.tailwindConfig, "variantGrouping");
65
+ let variantGroupingEnabled = (0, _featureFlags).flagEnabled(context.tailwindConfig, "variantGrouping");
66
+ let prefix = context.tailwindConfig.prefix !== "" ? regex.optional(regex.pattern([
67
+ /-?/,
68
+ regex.escape(context.tailwindConfig.prefix)
69
+ ])) : "";
66
70
  let utility = regex.any([
67
71
  // Arbitrary properties
68
72
  /\[[^\s:'"`]+:[^\s\]]+\]/,
@@ -93,9 +97,8 @@ function* buildRegExps(context) {
93
97
  ])),
94
98
  ]),
95
99
  ]);
96
- yield regex.pattern([
97
- // Variants
98
- "((?=((",
100
+ let variantPatterns = [
101
+ // Without quotes
99
102
  regex.any([
100
103
  regex.pattern([
101
104
  /([^\s"'`\[\\]+-)?\[[^\s"'`]+\]/,
@@ -105,25 +108,44 @@ function* buildRegExps(context) {
105
108
  /[^\s"'`\[\\]+/,
106
109
  separator
107
110
  ]),
108
- ], true),
109
- ")+))\\2)?",
110
- // Important (optional)
111
- /!?/,
112
- variantGroupingEnabled ? regex.any([
113
- // Or any of those things but grouped separated by commas
111
+ ]),
112
+ // With quotes allowed
113
+ regex.any([
114
114
  regex.pattern([
115
- /\(/,
116
- utility,
117
- regex.zeroOrMore([
118
- /,/,
119
- utility
120
- ]),
121
- /\)/
115
+ /([^\s"'`\[\\]+-)?\[[^\s`]+\]/,
116
+ separator
122
117
  ]),
123
- // Arbitrary properties, constrained utilities, arbitrary values, etc…
124
- utility,
125
- ]) : utility,
126
- ]);
118
+ regex.pattern([
119
+ /[^\s`\[\\]+/,
120
+ separator
121
+ ]),
122
+ ]),
123
+ ];
124
+ for (const variantPattern of variantPatterns){
125
+ yield regex.pattern([
126
+ // Variants
127
+ "((?=((",
128
+ variantPattern,
129
+ ")+))\\2)?",
130
+ // Important (optional)
131
+ /!?/,
132
+ prefix,
133
+ variantGroupingEnabled ? regex.any([
134
+ // Or any of those things but grouped separated by commas
135
+ regex.pattern([
136
+ /\(/,
137
+ utility,
138
+ regex.zeroOrMore([
139
+ /,/,
140
+ utility
141
+ ]),
142
+ /\)/
143
+ ]),
144
+ // Arbitrary properties, constrained utilities, arbitrary values, etc…
145
+ utility,
146
+ ]) : utility,
147
+ ]);
148
+ }
127
149
  // 5. Inner matches
128
150
  yield /[^<>"'`\s.(){}[\]#=%$]*[^<>"'`\s.(){}[\]#=%:$]/g;
129
151
  }
@@ -137,27 +137,59 @@ let nodeTypePropertyMap = {
137
137
  atrule: "params",
138
138
  decl: "value"
139
139
  };
140
+ /**
141
+ * @param {string} path
142
+ * @returns {Iterable<[path: string, alpha: string|undefined]>}
143
+ */ function* toPaths(path) {
144
+ // Strip quotes from beginning and end of string
145
+ // This allows the alpha value to be present inside of quotes
146
+ path = path.replace(/^['"]+|['"]+$/g, "");
147
+ let matches = path.match(/^([^\s]+)(?![^\[]*\])(?:\s*\/\s*([^\/\s]+))$/);
148
+ let alpha = undefined;
149
+ yield [
150
+ path,
151
+ undefined
152
+ ];
153
+ if (matches) {
154
+ path = matches[1];
155
+ alpha = matches[2];
156
+ yield [
157
+ path,
158
+ alpha
159
+ ];
160
+ }
161
+ }
162
+ /**
163
+ *
164
+ * @param {any} config
165
+ * @param {string} path
166
+ * @param {any} defaultValue
167
+ */ function resolvePath(config, path1, defaultValue) {
168
+ const results = Array.from(toPaths(path1)).map(([path, alpha])=>{
169
+ return Object.assign(validatePath(config, path, defaultValue, {
170
+ opacityValue: alpha
171
+ }), {
172
+ resolvedPath: path,
173
+ alpha
174
+ });
175
+ });
176
+ var ref;
177
+ return (ref = results.find((result)=>result.isValid)) !== null && ref !== void 0 ? ref : results[0];
178
+ }
140
179
  function _default({ tailwindConfig: config }) {
141
180
  let functions = {
142
181
  theme: (node, path, ...defaultValue)=>{
143
- // Strip quotes from beginning and end of string
144
- // This allows the alpha value to be present inside of quotes
145
- path = path.replace(/^['"]+|['"]+$/g, "");
146
- let matches = path.match(/^([^\s]+)(?![^\[]*\])(?:\s*\/\s*([^\/\s]+))$/);
147
- let alpha = undefined;
148
- if (matches) {
149
- path = matches[1];
150
- alpha = matches[2];
151
- }
152
- let { isValid , value , error } = validatePath(config, path, defaultValue.length ? defaultValue : undefined, {
153
- opacityValue: alpha
154
- });
182
+ let { isValid , value , error , alpha } = resolvePath(config, path, defaultValue.length ? defaultValue : undefined);
155
183
  if (!isValid) {
156
184
  throw node.error(error);
157
185
  }
158
- if (alpha !== undefined) {
159
- value = (0, _pluginUtils).parseColorFormat(value);
160
- value = (0, _withAlphaVariable).withAlphaValue(value, alpha, value);
186
+ let maybeColor = (0, _pluginUtils).parseColorFormat(value);
187
+ let isColorFunction = maybeColor !== undefined && typeof maybeColor === "function";
188
+ if (alpha !== undefined || isColorFunction) {
189
+ if (alpha === undefined) {
190
+ alpha = 1.0;
191
+ }
192
+ value = (0, _withAlphaVariable).withAlphaValue(maybeColor, alpha, maybeColor);
161
193
  }
162
194
  return value;
163
195
  },
@@ -171,6 +171,7 @@ function applyVariant(variant, matches, context) {
171
171
  return matches;
172
172
  }
173
173
  let args;
174
+ let isArbitraryVariant = false;
174
175
  // Find partial arbitrary variants
175
176
  if (variant.endsWith("]") && !variant.startsWith("[")) {
176
177
  args = variant.slice(variant.lastIndexOf("[") + 1, -1);
@@ -182,6 +183,7 @@ function applyVariant(variant, matches, context) {
182
183
  if (!(0, _setupContextUtils).isValidVariantFormatString(selector)) {
183
184
  return [];
184
185
  }
186
+ isArbitraryVariant = true;
185
187
  let fn = (0, _setupContextUtils).parseVariant(selector);
186
188
  let sort = Array.from(context.variantOrder.values()).pop() << 1n;
187
189
  context.variantMap.set(variant, [
@@ -329,7 +331,8 @@ function applyVariant(variant, matches, context) {
329
331
  {
330
332
  ...meta,
331
333
  sort: variantSort | meta.sort,
332
- collectedFormats: ((_collectedFormats = meta.collectedFormats) !== null && _collectedFormats !== void 0 ? _collectedFormats : []).concat(collectedFormats)
334
+ collectedFormats: ((_collectedFormats = meta.collectedFormats) !== null && _collectedFormats !== void 0 ? _collectedFormats : []).concat(collectedFormats),
335
+ isArbitraryVariant
333
336
  },
334
337
  clone.nodes[0],
335
338
  ];
@@ -639,6 +642,7 @@ function* resolveMatches(candidate, context, original = candidate) {
639
642
  selector: rule.selector,
640
643
  candidate: original,
641
644
  base: candidate.split(new RegExp(`\\${(ref2 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref2 !== void 0 ? ref2 : ":"}(?![^[]*\\])`)).pop(),
645
+ isArbitraryVariant: match1[0].isArbitraryVariant,
642
646
  context
643
647
  });
644
648
  });
@@ -747,6 +747,12 @@ function registerPlugins(plugins, context) {
747
747
  ...classes.map((cls)=>cls.slice(0, prefixLength) + "-" + cls.slice(prefixLength)),
748
748
  ];
749
749
  }
750
+ if ([].concat(options === null || options === void 0 ? void 0 : options.type).includes("color")) {
751
+ classes = [
752
+ ...classes,
753
+ ...classes.flatMap((cls)=>Object.keys(context.tailwindConfig.theme.opacity).map((opacity)=>`${cls}/${opacity}`)),
754
+ ];
755
+ }
750
756
  return classes;
751
757
  })() : [
752
758
  util
@@ -51,9 +51,7 @@ function normalize(value, isRoot = true) {
51
51
  value = value.replace(/(calc|min|max|clamp)\(.+\)/g, (match)=>{
52
52
  return match.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
53
53
  });
54
- // Add spaces around some operators not inside calc() that do not follow an operator
55
- // or '('.
56
- return value.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([\/])/g, "$1 $2 ");
54
+ return value;
57
55
  }
58
56
  function url(value) {
59
57
  return value.startsWith("url(");
@@ -39,7 +39,7 @@ function formatVariantSelector(current, ...others) {
39
39
  return current;
40
40
  }
41
41
  var ref1;
42
- function finalizeSelector(format, { selector: selector1 , candidate , context , // Split by the separator, but ignore the separator inside square brackets:
42
+ function finalizeSelector(format, { selector: selector1 , candidate , context , isArbitraryVariant , // Split by the separator, but ignore the separator inside square brackets:
43
43
  //
44
44
  // E.g.: dark:lg:hover:[paint-order:markers]
45
45
  // ┬ ┬ ┬ ┬
@@ -49,7 +49,8 @@ function finalizeSelector(format, { selector: selector1 , candidate , context ,
49
49
  base =candidate.split(new RegExp(`\\${(ref1 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref1 !== void 0 ? ref1 : ":"}(?![^[]*\\])`)).pop() , }) {
50
50
  var ref2;
51
51
  let ast = (0, _postcssSelectorParser).default().astSync(selector1);
52
- if (context === null || context === void 0 ? void 0 : (ref2 = context.tailwindConfig) === null || ref2 === void 0 ? void 0 : ref2.prefix) {
52
+ // We explicitly DO NOT prefix classes in arbitrary variants
53
+ if ((context === null || context === void 0 ? void 0 : (ref2 = context.tailwindConfig) === null || ref2 === void 0 ? void 0 : ref2.prefix) && !isArbitraryVariant) {
53
54
  format = (0, _prefixSelector).default(context.tailwindConfig.prefix, format);
54
55
  }
55
56
  format = format.replace(PARENT, `.${(0, _escapeClassName).default(candidate)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss",
3
- "version": "3.1.3",
3
+ "version": "3.1.6",
4
4
  "description": "A utility-first CSS framework for rapidly building custom user interfaces.",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -47,14 +47,14 @@
47
47
  "@swc/jest": "^0.2.21",
48
48
  "@swc/register": "^0.1.10",
49
49
  "autoprefixer": "^10.4.7",
50
- "cssnano": "^5.1.9",
51
- "esbuild": "^0.14.39",
52
- "eslint": "^8.16.0",
50
+ "cssnano": "^5.1.12",
51
+ "esbuild": "^0.14.48",
52
+ "eslint": "^8.18.0",
53
53
  "eslint-config-prettier": "^8.5.0",
54
- "eslint-plugin-prettier": "^4.0.0",
55
- "jest": "^28.1.1",
54
+ "eslint-plugin-prettier": "^4.2.1",
55
+ "jest": "^28.1.2",
56
56
  "jest-diff": "^28.1.1",
57
- "prettier": "^2.6.2",
57
+ "prettier": "^2.7.1",
58
58
  "prettier-plugin-tailwindcss": "^0.1.11",
59
59
  "rimraf": "^3.0.0",
60
60
  "source-map-js": "^1.0.2"
@@ -84,7 +84,7 @@
84
84
  "postcss-selector-parser": "^6.0.10",
85
85
  "postcss-value-parser": "^4.2.0",
86
86
  "quick-lru": "^5.1.1",
87
- "resolve": "^1.22.0"
87
+ "resolve": "^1.22.1"
88
88
  },
89
89
  "browserslist": [
90
90
  "> 1%",