tailwindcss 3.0.23 → 3.1.1

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 (119) hide show
  1. package/CHANGELOG.md +92 -2
  2. package/colors.d.ts +3 -0
  3. package/defaultConfig.d.ts +3 -0
  4. package/defaultTheme.d.ts +3 -0
  5. package/lib/cli-peer-dependencies.js +10 -5
  6. package/lib/cli.js +266 -203
  7. package/lib/constants.js +8 -8
  8. package/lib/corePluginList.js +1 -0
  9. package/lib/corePlugins.js +1640 -1562
  10. package/lib/css/preflight.css +1 -8
  11. package/lib/featureFlags.js +14 -12
  12. package/lib/index.js +16 -6
  13. package/lib/lib/cacheInvalidation.js +87 -0
  14. package/lib/lib/collapseAdjacentRules.js +30 -15
  15. package/lib/lib/collapseDuplicateDeclarations.js +1 -1
  16. package/lib/lib/defaultExtractor.js +191 -32
  17. package/lib/lib/detectNesting.js +9 -9
  18. package/lib/lib/evaluateTailwindFunctions.js +37 -28
  19. package/lib/lib/expandApplyAtRules.js +379 -189
  20. package/lib/lib/expandTailwindAtRules.js +168 -144
  21. package/lib/lib/generateRules.js +177 -95
  22. package/lib/lib/getModuleDependencies.js +14 -14
  23. package/lib/lib/normalizeTailwindDirectives.js +35 -35
  24. package/lib/lib/partitionApplyAtRules.js +7 -7
  25. package/lib/lib/regex.js +52 -0
  26. package/lib/lib/resolveDefaultsAtRules.js +96 -81
  27. package/lib/lib/setupContextUtils.js +202 -159
  28. package/lib/lib/setupTrackingContext.js +61 -63
  29. package/lib/lib/sharedState.js +10 -9
  30. package/lib/lib/substituteScreenAtRules.js +3 -4
  31. package/lib/postcss-plugins/nesting/README.md +2 -2
  32. package/lib/postcss-plugins/nesting/index.js +1 -1
  33. package/lib/postcss-plugins/nesting/plugin.js +40 -9
  34. package/lib/processTailwindFeatures.js +7 -7
  35. package/lib/public/colors.js +241 -241
  36. package/lib/public/resolve-config.js +5 -5
  37. package/lib/util/buildMediaQuery.js +2 -3
  38. package/lib/util/cloneDeep.js +3 -5
  39. package/lib/util/cloneNodes.js +12 -1
  40. package/lib/util/color.js +42 -51
  41. package/lib/util/createPlugin.js +1 -2
  42. package/lib/util/createUtilityPlugin.js +6 -7
  43. package/lib/util/dataTypes.js +85 -81
  44. package/lib/util/escapeClassName.js +5 -5
  45. package/lib/util/escapeCommas.js +1 -1
  46. package/lib/util/flattenColorPalette.js +4 -7
  47. package/lib/util/formatVariantSelector.js +82 -75
  48. package/lib/util/getAllConfigs.js +15 -10
  49. package/lib/util/hashConfig.js +5 -5
  50. package/lib/util/isKeyframeRule.js +1 -1
  51. package/lib/util/isPlainObject.js +1 -1
  52. package/lib/util/isValidArbitraryValue.js +26 -27
  53. package/lib/util/log.js +9 -10
  54. package/lib/util/nameClass.js +7 -7
  55. package/lib/util/negateValue.js +4 -5
  56. package/lib/util/normalizeConfig.js +68 -58
  57. package/lib/util/normalizeScreens.js +5 -6
  58. package/lib/util/parseAnimationValue.js +56 -57
  59. package/lib/util/parseBoxShadowValue.js +19 -20
  60. package/lib/util/parseDependency.js +32 -32
  61. package/lib/util/parseObjectStyles.js +6 -6
  62. package/lib/util/pluginUtils.js +20 -12
  63. package/lib/util/prefixSelector.js +1 -1
  64. package/lib/util/resolveConfig.js +81 -58
  65. package/lib/util/resolveConfigPath.js +16 -16
  66. package/lib/util/responsive.js +6 -6
  67. package/lib/util/splitAtTopLevelOnly.js +90 -0
  68. package/lib/util/toColorValue.js +1 -1
  69. package/lib/util/toPath.js +2 -2
  70. package/lib/util/transformThemeValue.js +30 -28
  71. package/lib/util/validateConfig.js +21 -0
  72. package/lib/util/withAlphaVariable.js +23 -23
  73. package/package.json +33 -27
  74. package/peers/index.js +7702 -5822
  75. package/plugin.d.ts +11 -0
  76. package/scripts/generate-types.js +52 -0
  77. package/src/cli-peer-dependencies.js +7 -1
  78. package/src/cli.js +118 -24
  79. package/src/corePluginList.js +1 -1
  80. package/src/corePlugins.js +109 -30
  81. package/src/css/preflight.css +1 -8
  82. package/src/featureFlags.js +4 -4
  83. package/src/index.js +15 -1
  84. package/src/lib/cacheInvalidation.js +52 -0
  85. package/src/lib/collapseAdjacentRules.js +21 -2
  86. package/src/lib/defaultExtractor.js +177 -35
  87. package/src/lib/evaluateTailwindFunctions.js +20 -4
  88. package/src/lib/expandApplyAtRules.js +418 -186
  89. package/src/lib/expandTailwindAtRules.js +29 -9
  90. package/src/lib/generateRules.js +137 -51
  91. package/src/lib/regex.js +74 -0
  92. package/src/lib/resolveDefaultsAtRules.js +53 -32
  93. package/src/lib/setupContextUtils.js +128 -65
  94. package/src/lib/setupTrackingContext.js +7 -3
  95. package/src/lib/sharedState.js +1 -0
  96. package/src/postcss-plugins/nesting/README.md +2 -2
  97. package/src/postcss-plugins/nesting/plugin.js +36 -0
  98. package/src/util/cloneNodes.js +14 -1
  99. package/src/util/color.js +25 -21
  100. package/src/util/dataTypes.js +14 -6
  101. package/src/util/formatVariantSelector.js +79 -62
  102. package/src/util/getAllConfigs.js +7 -0
  103. package/src/util/log.js +8 -8
  104. package/src/util/normalizeConfig.js +0 -8
  105. package/src/util/parseBoxShadowValue.js +3 -2
  106. package/src/util/pluginUtils.js +13 -1
  107. package/src/util/resolveConfig.js +66 -22
  108. package/src/util/splitAtTopLevelOnly.js +71 -0
  109. package/src/util/toPath.js +1 -1
  110. package/src/util/transformThemeValue.js +4 -2
  111. package/src/util/validateConfig.js +13 -0
  112. package/src/util/withAlphaVariable.js +1 -1
  113. package/stubs/defaultConfig.stub.js +5 -1
  114. package/stubs/simpleConfig.stub.js +1 -0
  115. package/types/config.d.ts +325 -0
  116. package/types/generated/.gitkeep +0 -0
  117. package/types/generated/colors.d.ts +276 -0
  118. package/types/generated/corePluginList.d.ts +1 -0
  119. package/types/index.d.ts +7 -0
@@ -10,38 +10,39 @@ var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser")
10
10
  var _normalizeScreens = require("../util/normalizeScreens");
11
11
  var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
12
12
  var _toPath = require("../util/toPath");
13
+ var _withAlphaVariable = require("../util/withAlphaVariable");
14
+ var _pluginUtils = require("../util/pluginUtils");
13
15
  function _interopRequireDefault(obj) {
14
16
  return obj && obj.__esModule ? obj : {
15
17
  default: obj
16
18
  };
17
19
  }
18
20
  function isObject(input) {
19
- return typeof input === 'object' && input !== null;
21
+ return typeof input === "object" && input !== null;
20
22
  }
21
23
  function findClosestExistingPath(theme, path) {
22
24
  let parts = (0, _toPath).toPath(path);
23
25
  do {
24
26
  parts.pop();
25
27
  if ((0, _dlv).default(theme, parts) !== undefined) break;
26
- }while (parts.length)
28
+ }while (parts.length);
27
29
  return parts.length ? parts : undefined;
28
30
  }
29
31
  function pathToString(path) {
30
- if (typeof path === 'string') return path;
32
+ if (typeof path === "string") return path;
31
33
  return path.reduce((acc, cur, i)=>{
32
- if (cur.includes('.')) return `${acc}[${cur}]`;
34
+ if (cur.includes(".")) return `${acc}[${cur}]`;
33
35
  return i === 0 ? cur : `${acc}.${cur}`;
34
- }, '');
36
+ }, "");
35
37
  }
36
38
  function list(items) {
37
- return items.map((key)=>`'${key}'`
38
- ).join(', ');
39
+ return items.map((key)=>`'${key}'`).join(", ");
39
40
  }
40
41
  function listKeys(obj) {
41
42
  return list(Object.keys(obj));
42
43
  }
43
- function validatePath(config, path, defaultValue) {
44
- const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
44
+ function validatePath(config, path, defaultValue, themeOpts = {}) {
45
+ const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
45
46
  const pathSegments = Array.isArray(path) ? path : (0, _toPath).toPath(pathString);
46
47
  const value = (0, _dlv).default(config.theme, pathSegments, defaultValue);
47
48
  if (value === undefined) {
@@ -52,8 +53,7 @@ function validatePath(config, path, defaultValue) {
52
53
  const validKeys = Object.keys(parentValue).filter((key)=>validatePath(config, [
53
54
  ...parentSegments,
54
55
  key
55
- ]).isValid
56
- );
56
+ ]).isValid);
57
57
  const suggestion = (0, _didyoumean).default(pathSegments[pathSegments.length - 1], validKeys);
58
58
  if (suggestion) {
59
59
  error += ` Did you mean '${pathToString([
@@ -81,14 +81,13 @@ function validatePath(config, path, defaultValue) {
81
81
  error
82
82
  };
83
83
  }
84
- if (!(typeof value === 'string' || typeof value === 'number' || typeof value === 'function' || value instanceof String || value instanceof Number || Array.isArray(value))) {
84
+ if (!(typeof value === "string" || typeof value === "number" || typeof value === "function" || value instanceof String || value instanceof Number || Array.isArray(value))) {
85
85
  let error = `'${pathString}' was found but does not resolve to a string.`;
86
86
  if (isObject(value)) {
87
87
  let validKeys = Object.keys(value).filter((key)=>validatePath(config, [
88
88
  ...pathSegments,
89
89
  key
90
- ]).isValid
91
- );
90
+ ]).isValid);
92
91
  if (validKeys.length) {
93
92
  error += ` Did you mean something like '${pathToString([
94
93
  ...pathSegments,
@@ -104,18 +103,17 @@ function validatePath(config, path, defaultValue) {
104
103
  const [themeSection] = pathSegments;
105
104
  return {
106
105
  isValid: true,
107
- value: (0, _transformThemeValue).default(themeSection)(value)
106
+ value: (0, _transformThemeValue).default(themeSection)(value, themeOpts)
108
107
  };
109
108
  }
110
109
  function extractArgs(node, vNodes, functions) {
111
- vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions)
112
- );
110
+ vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions));
113
111
  let args = [
114
- ''
112
+ ""
115
113
  ];
116
114
  for (let vNode1 of vNodes){
117
- if (vNode1.type === 'div' && vNode1.value === ',') {
118
- args.push('');
115
+ if (vNode1.type === "div" && vNode1.value === ",") {
116
+ args.push("");
119
117
  } else {
120
118
  args[args.length - 1] += _postcssValueParser.default.stringify(vNode1);
121
119
  }
@@ -123,9 +121,9 @@ function extractArgs(node, vNodes, functions) {
123
121
  return args;
124
122
  }
125
123
  function resolveVNode(node, vNode, functions) {
126
- if (vNode.type === 'function' && functions[vNode.value] !== undefined) {
124
+ if (vNode.type === "function" && functions[vNode.value] !== undefined) {
127
125
  let args = extractArgs(node, vNode.nodes, functions);
128
- vNode.type = 'word';
126
+ vNode.type = "word";
129
127
  vNode.value = functions[vNode.value](node, ...args);
130
128
  }
131
129
  return vNode;
@@ -136,23 +134,34 @@ function resolveFunctions(node, input, functions) {
136
134
  }).toString();
137
135
  }
138
136
  let nodeTypePropertyMap = {
139
- atrule: 'params',
140
- decl: 'value'
137
+ atrule: "params",
138
+ decl: "value"
141
139
  };
142
140
  function _default({ tailwindConfig: config }) {
143
141
  let functions = {
144
142
  theme: (node, path, ...defaultValue)=>{
145
- const { isValid , value , error } = validatePath(config, path, defaultValue.length ? defaultValue : undefined);
143
+ let matches = path.match(/^([^\s]+)(?![^\[]*\])(?:\s*\/\s*([^\/\s]+))$/);
144
+ let alpha = undefined;
145
+ if (matches) {
146
+ path = matches[1];
147
+ alpha = matches[2];
148
+ }
149
+ let { isValid , value , error } = validatePath(config, path, defaultValue.length ? defaultValue : undefined, {
150
+ opacityValue: alpha
151
+ });
146
152
  if (!isValid) {
147
153
  throw node.error(error);
148
154
  }
155
+ if (alpha !== undefined) {
156
+ value = (0, _pluginUtils).parseColorFormat(value);
157
+ value = (0, _withAlphaVariable).withAlphaValue(value, alpha, value);
158
+ }
149
159
  return value;
150
160
  },
151
161
  screen: (node, screen)=>{
152
- screen = screen.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
162
+ screen = screen.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
153
163
  let screens = (0, _normalizeScreens).normalizeScreens(config.theme.screens);
154
- let screenDefinition = screens.find(({ name })=>name === screen
155
- );
164
+ let screenDefinition = screens.find(({ name })=>name === screen);
156
165
  if (!screenDefinition) {
157
166
  throw node.error(`The '${screen}' screen does not exist in your theme.`);
158
167
  }