tailwindcss 0.0.0-insiders.bbafc8e → 0.0.0-insiders.bbf2b1b

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 (128) hide show
  1. package/CHANGELOG.md +163 -8
  2. package/README.md +6 -3
  3. package/colors.d.ts +3 -0
  4. package/defaultConfig.d.ts +3 -0
  5. package/defaultTheme.d.ts +4 -0
  6. package/lib/cli-peer-dependencies.js +20 -7
  7. package/lib/cli.js +314 -247
  8. package/lib/constants.js +27 -20
  9. package/lib/corePluginList.js +6 -3
  10. package/lib/corePlugins.js +1719 -1628
  11. package/lib/css/preflight.css +1 -8
  12. package/lib/featureFlags.js +27 -18
  13. package/lib/index.js +17 -15
  14. package/lib/lib/cacheInvalidation.js +45 -24
  15. package/lib/lib/collapseAdjacentRules.js +14 -9
  16. package/lib/lib/collapseDuplicateDeclarations.js +12 -9
  17. package/lib/lib/defaultExtractor.js +220 -33
  18. package/lib/lib/detectNesting.js +13 -10
  19. package/lib/lib/evaluateTailwindFunctions.js +101 -54
  20. package/lib/lib/expandApplyAtRules.js +254 -209
  21. package/lib/lib/expandTailwindAtRules.js +86 -69
  22. package/lib/lib/generateRules.js +244 -145
  23. package/lib/lib/getModuleDependencies.js +11 -8
  24. package/lib/lib/normalizeTailwindDirectives.js +35 -32
  25. package/lib/lib/partitionApplyAtRules.js +11 -8
  26. package/lib/lib/regex.js +60 -0
  27. package/lib/lib/resolveDefaultsAtRules.js +89 -71
  28. package/lib/lib/setupContextUtils.js +290 -205
  29. package/lib/lib/setupTrackingContext.js +44 -37
  30. package/lib/lib/sharedState.js +22 -16
  31. package/lib/lib/substituteScreenAtRules.js +11 -9
  32. package/lib/postcss-plugins/nesting/README.md +2 -2
  33. package/lib/postcss-plugins/nesting/index.js +8 -6
  34. package/lib/postcss-plugins/nesting/plugin.js +18 -16
  35. package/lib/processTailwindFeatures.js +31 -28
  36. package/lib/public/colors.js +247 -245
  37. package/lib/public/create-plugin.js +6 -4
  38. package/lib/public/default-config.js +7 -5
  39. package/lib/public/default-theme.js +7 -5
  40. package/lib/public/resolve-config.js +8 -5
  41. package/lib/util/bigSign.js +4 -1
  42. package/lib/util/buildMediaQuery.js +7 -5
  43. package/lib/util/cloneDeep.js +7 -6
  44. package/lib/util/cloneNodes.js +10 -3
  45. package/lib/util/color.js +53 -54
  46. package/lib/util/configurePlugins.js +4 -1
  47. package/lib/util/createPlugin.js +6 -5
  48. package/lib/util/createUtilityPlugin.js +9 -7
  49. package/lib/util/dataTypes.js +110 -100
  50. package/lib/util/defaults.js +4 -1
  51. package/lib/util/escapeClassName.js +7 -4
  52. package/lib/util/escapeCommas.js +5 -2
  53. package/lib/util/flattenColorPalette.js +9 -10
  54. package/lib/util/formatVariantSelector.js +100 -85
  55. package/lib/util/getAllConfigs.js +17 -8
  56. package/lib/util/hashConfig.js +6 -3
  57. package/lib/util/isKeyframeRule.js +5 -2
  58. package/lib/util/isPlainObject.js +5 -2
  59. package/lib/util/isValidArbitraryValue.js +21 -13
  60. package/lib/util/log.js +18 -12
  61. package/lib/util/nameClass.js +17 -9
  62. package/lib/util/negateValue.js +8 -6
  63. package/lib/util/normalizeConfig.js +84 -71
  64. package/lib/util/normalizeScreens.js +22 -8
  65. package/lib/util/parseAnimationValue.js +42 -40
  66. package/lib/util/parseBoxShadowValue.js +29 -62
  67. package/lib/util/parseDependency.js +18 -15
  68. package/lib/util/parseObjectStyles.js +10 -7
  69. package/lib/util/pluginUtils.js +47 -31
  70. package/lib/util/prefixSelector.js +7 -4
  71. package/lib/util/removeAlphaVariables.js +29 -0
  72. package/lib/util/resolveConfig.js +88 -84
  73. package/lib/util/resolveConfigPath.js +10 -7
  74. package/lib/util/responsive.js +8 -5
  75. package/lib/util/splitAtTopLevelOnly.js +93 -0
  76. package/lib/util/tap.js +4 -1
  77. package/lib/util/toColorValue.js +5 -2
  78. package/lib/util/toPath.js +20 -4
  79. package/lib/util/transformThemeValue.js +30 -25
  80. package/lib/util/validateConfig.js +24 -0
  81. package/lib/util/withAlphaVariable.js +23 -15
  82. package/package.json +32 -27
  83. package/peers/index.js +8612 -4245
  84. package/plugin.d.ts +11 -0
  85. package/resolveConfig.d.ts +3 -0
  86. package/scripts/generate-types.js +105 -0
  87. package/scripts/type-utils.js +27 -0
  88. package/src/cli-peer-dependencies.js +7 -1
  89. package/src/cli.js +125 -25
  90. package/src/corePluginList.js +1 -1
  91. package/src/corePlugins.js +145 -49
  92. package/src/css/preflight.css +1 -8
  93. package/src/featureFlags.js +2 -2
  94. package/src/lib/collapseAdjacentRules.js +5 -1
  95. package/src/lib/defaultExtractor.js +193 -35
  96. package/src/lib/evaluateTailwindFunctions.js +56 -6
  97. package/src/lib/expandApplyAtRules.js +252 -187
  98. package/src/lib/expandTailwindAtRules.js +4 -4
  99. package/src/lib/generateRules.js +156 -59
  100. package/src/lib/regex.js +74 -0
  101. package/src/lib/resolveDefaultsAtRules.js +53 -36
  102. package/src/lib/setupContextUtils.js +142 -46
  103. package/src/lib/setupTrackingContext.js +5 -1
  104. package/src/postcss-plugins/nesting/README.md +2 -2
  105. package/src/util/cloneNodes.js +5 -1
  106. package/src/util/color.js +25 -21
  107. package/src/util/dataTypes.js +13 -7
  108. package/src/util/formatVariantSelector.js +82 -63
  109. package/src/util/getAllConfigs.js +8 -0
  110. package/src/util/log.js +1 -1
  111. package/src/util/normalizeConfig.js +0 -8
  112. package/src/util/parseBoxShadowValue.js +3 -50
  113. package/src/util/pluginUtils.js +13 -1
  114. package/src/util/removeAlphaVariables.js +24 -0
  115. package/src/util/resolveConfig.js +66 -52
  116. package/src/util/splitAtTopLevelOnly.js +71 -0
  117. package/src/util/toPath.js +1 -1
  118. package/src/util/transformThemeValue.js +4 -2
  119. package/src/util/validateConfig.js +13 -0
  120. package/src/util/withAlphaVariable.js +1 -1
  121. package/stubs/defaultConfig.stub.js +5 -1
  122. package/stubs/simpleConfig.stub.js +1 -0
  123. package/types/config.d.ts +327 -0
  124. package/types/generated/.gitkeep +0 -0
  125. package/types/generated/colors.d.ts +276 -0
  126. package/types/generated/corePluginList.d.ts +1 -0
  127. package/types/generated/default-theme.d.ts +331 -0
  128. package/types/index.d.ts +7 -0
@@ -2,19 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = _default;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>_default
8
+ });
6
9
  function _default(_context) {
7
10
  return (root, result)=>{
8
11
  let found = false;
9
- root.walkAtRules('tailwind', (node)=>{
12
+ root.walkAtRules("tailwind", (node)=>{
10
13
  if (found) return false;
11
- if (node.parent && node.parent.type !== 'root') {
14
+ if (node.parent && node.parent.type !== "root") {
12
15
  found = true;
13
16
  node.warn(result, [
14
- 'Nested @tailwind rules were detected, but are not supported.',
17
+ "Nested @tailwind rules were detected, but are not supported.",
15
18
  "Consider using a prefix to scope Tailwind's classes: https://tailwindcss.com/docs/configuration#prefix",
16
- 'Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy',
17
- ].join('\n'));
19
+ "Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy",
20
+ ].join("\n"));
18
21
  return false;
19
22
  }
20
23
  });
@@ -23,10 +26,10 @@ function _default(_context) {
23
26
  rule.walkRules((nestedRule)=>{
24
27
  found = true;
25
28
  nestedRule.warn(result, [
26
- 'Nested CSS was detected, but CSS nesting has not been configured correctly.',
27
- 'Please enable a CSS nesting plugin *before* Tailwind in your configuration.',
28
- 'See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting',
29
- ].join('\n'));
29
+ "Nested CSS was detected, but CSS nesting has not been configured correctly.",
30
+ "Please enable a CSS nesting plugin *before* Tailwind in your configuration.",
31
+ "See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting",
32
+ ].join("\n"));
30
33
  return false;
31
34
  });
32
35
  });
@@ -2,59 +2,62 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = _default;
6
- var _dlv = _interopRequireDefault(require("dlv"));
7
- var _didyoumean = _interopRequireDefault(require("didyoumean"));
8
- var _transformThemeValue = _interopRequireDefault(require("../util/transformThemeValue"));
9
- var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
10
- var _normalizeScreens = require("../util/normalizeScreens");
11
- var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
12
- var _toPath = require("../util/toPath");
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>_default
8
+ });
9
+ const _dlv = /*#__PURE__*/ _interopRequireDefault(require("dlv"));
10
+ const _didyoumean = /*#__PURE__*/ _interopRequireDefault(require("didyoumean"));
11
+ const _transformThemeValue = /*#__PURE__*/ _interopRequireDefault(require("../util/transformThemeValue"));
12
+ const _postcssValueParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-value-parser"));
13
+ const _normalizeScreens = require("../util/normalizeScreens");
14
+ const _buildMediaQuery = /*#__PURE__*/ _interopRequireDefault(require("../util/buildMediaQuery"));
15
+ const _toPath = require("../util/toPath");
16
+ const _withAlphaVariable = require("../util/withAlphaVariable");
17
+ const _pluginUtils = require("../util/pluginUtils");
13
18
  function _interopRequireDefault(obj) {
14
19
  return obj && obj.__esModule ? obj : {
15
20
  default: obj
16
21
  };
17
22
  }
18
23
  function isObject(input) {
19
- return typeof input === 'object' && input !== null;
24
+ return typeof input === "object" && input !== null;
20
25
  }
21
26
  function findClosestExistingPath(theme, path) {
22
- let parts = (0, _toPath).toPath(path);
27
+ let parts = (0, _toPath.toPath)(path);
23
28
  do {
24
29
  parts.pop();
25
- if ((0, _dlv).default(theme, parts) !== undefined) break;
26
- }while (parts.length)
30
+ if ((0, _dlv.default)(theme, parts) !== undefined) break;
31
+ }while (parts.length);
27
32
  return parts.length ? parts : undefined;
28
33
  }
29
34
  function pathToString(path) {
30
- if (typeof path === 'string') return path;
35
+ if (typeof path === "string") return path;
31
36
  return path.reduce((acc, cur, i)=>{
32
- if (cur.includes('.')) return `${acc}[${cur}]`;
37
+ if (cur.includes(".")) return `${acc}[${cur}]`;
33
38
  return i === 0 ? cur : `${acc}.${cur}`;
34
- }, '');
39
+ }, "");
35
40
  }
36
41
  function list(items) {
37
- return items.map((key)=>`'${key}'`
38
- ).join(', ');
42
+ return items.map((key)=>`'${key}'`).join(", ");
39
43
  }
40
44
  function listKeys(obj) {
41
45
  return list(Object.keys(obj));
42
46
  }
43
- function validatePath(config, path, defaultValue) {
44
- const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
45
- const pathSegments = Array.isArray(path) ? path : (0, _toPath).toPath(pathString);
46
- const value = (0, _dlv).default(config.theme, pathSegments, defaultValue);
47
+ function validatePath(config, path, defaultValue, themeOpts = {}) {
48
+ const pathString = Array.isArray(path) ? pathToString(path) : path.replace(/^['"]+|['"]+$/g, "");
49
+ const pathSegments = Array.isArray(path) ? path : (0, _toPath.toPath)(pathString);
50
+ const value = (0, _dlv.default)(config.theme, pathSegments, defaultValue);
47
51
  if (value === undefined) {
48
52
  let error = `'${pathString}' does not exist in your theme config.`;
49
53
  const parentSegments = pathSegments.slice(0, -1);
50
- const parentValue = (0, _dlv).default(config.theme, parentSegments);
54
+ const parentValue = (0, _dlv.default)(config.theme, parentSegments);
51
55
  if (isObject(parentValue)) {
52
56
  const validKeys = Object.keys(parentValue).filter((key)=>validatePath(config, [
53
57
  ...parentSegments,
54
58
  key
55
- ]).isValid
56
- );
57
- const suggestion = (0, _didyoumean).default(pathSegments[pathSegments.length - 1], validKeys);
59
+ ]).isValid);
60
+ const suggestion = (0, _didyoumean.default)(pathSegments[pathSegments.length - 1], validKeys);
58
61
  if (suggestion) {
59
62
  error += ` Did you mean '${pathToString([
60
63
  ...parentSegments,
@@ -66,7 +69,7 @@ function validatePath(config, path, defaultValue) {
66
69
  } else {
67
70
  const closestPath = findClosestExistingPath(config.theme, pathString);
68
71
  if (closestPath) {
69
- const closestValue = (0, _dlv).default(config.theme, closestPath);
72
+ const closestValue = (0, _dlv.default)(config.theme, closestPath);
70
73
  if (isObject(closestValue)) {
71
74
  error += ` '${pathToString(closestPath)}' has the following keys: ${listKeys(closestValue)}`;
72
75
  } else {
@@ -81,82 +84,126 @@ function validatePath(config, path, defaultValue) {
81
84
  error
82
85
  };
83
86
  }
84
- if (!(typeof value === 'string' || typeof value === 'number' || typeof value === 'function' || value instanceof String || value instanceof Number || Array.isArray(value))) {
85
- let error = `'${pathString}' was found but does not resolve to a string.`;
87
+ if (!(typeof value === "string" || typeof value === "number" || typeof value === "function" || value instanceof String || value instanceof Number || Array.isArray(value))) {
88
+ let error1 = `'${pathString}' was found but does not resolve to a string.`;
86
89
  if (isObject(value)) {
87
- let validKeys = Object.keys(value).filter((key)=>validatePath(config, [
90
+ let validKeys1 = Object.keys(value).filter((key)=>validatePath(config, [
88
91
  ...pathSegments,
89
92
  key
90
- ]).isValid
91
- );
92
- if (validKeys.length) {
93
- error += ` Did you mean something like '${pathToString([
93
+ ]).isValid);
94
+ if (validKeys1.length) {
95
+ error1 += ` Did you mean something like '${pathToString([
94
96
  ...pathSegments,
95
- validKeys[0]
97
+ validKeys1[0]
96
98
  ])}'?`;
97
99
  }
98
100
  }
99
101
  return {
100
102
  isValid: false,
101
- error
103
+ error: error1
102
104
  };
103
105
  }
104
106
  const [themeSection] = pathSegments;
105
107
  return {
106
108
  isValid: true,
107
- value: (0, _transformThemeValue).default(themeSection)(value)
109
+ value: (0, _transformThemeValue.default)(themeSection)(value, themeOpts)
108
110
  };
109
111
  }
110
112
  function extractArgs(node, vNodes, functions) {
111
- vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions)
112
- );
113
+ vNodes = vNodes.map((vNode)=>resolveVNode(node, vNode, functions));
113
114
  let args = [
114
- ''
115
+ ""
115
116
  ];
116
- for (let vNode1 of vNodes){
117
- if (vNode1.type === 'div' && vNode1.value === ',') {
118
- args.push('');
117
+ for (let vNode of vNodes){
118
+ if (vNode.type === "div" && vNode.value === ",") {
119
+ args.push("");
119
120
  } else {
120
- args[args.length - 1] += _postcssValueParser.default.stringify(vNode1);
121
+ args[args.length - 1] += _postcssValueParser.default.stringify(vNode);
121
122
  }
122
123
  }
123
124
  return args;
124
125
  }
125
126
  function resolveVNode(node, vNode, functions) {
126
- if (vNode.type === 'function' && functions[vNode.value] !== undefined) {
127
+ if (vNode.type === "function" && functions[vNode.value] !== undefined) {
127
128
  let args = extractArgs(node, vNode.nodes, functions);
128
- vNode.type = 'word';
129
+ vNode.type = "word";
129
130
  vNode.value = functions[vNode.value](node, ...args);
130
131
  }
131
132
  return vNode;
132
133
  }
133
134
  function resolveFunctions(node, input, functions) {
134
- return (0, _postcssValueParser).default(input).walk((vNode)=>{
135
+ return (0, _postcssValueParser.default)(input).walk((vNode)=>{
135
136
  resolveVNode(node, vNode, functions);
136
137
  }).toString();
137
138
  }
138
139
  let nodeTypePropertyMap = {
139
- atrule: 'params',
140
- decl: 'value'
140
+ atrule: "params",
141
+ decl: "value"
141
142
  };
143
+ /**
144
+ * @param {string} path
145
+ * @returns {Iterable<[path: string, alpha: string|undefined]>}
146
+ */ function* toPaths(path) {
147
+ // Strip quotes from beginning and end of string
148
+ // This allows the alpha value to be present inside of quotes
149
+ path = path.replace(/^['"]+|['"]+$/g, "");
150
+ let matches = path.match(/^([^\s]+)(?![^\[]*\])(?:\s*\/\s*([^\/\s]+))$/);
151
+ let alpha = undefined;
152
+ yield [
153
+ path,
154
+ undefined
155
+ ];
156
+ if (matches) {
157
+ path = matches[1];
158
+ alpha = matches[2];
159
+ yield [
160
+ path,
161
+ alpha
162
+ ];
163
+ }
164
+ }
165
+ /**
166
+ *
167
+ * @param {any} config
168
+ * @param {string} path
169
+ * @param {any} defaultValue
170
+ */ function resolvePath(config, path, defaultValue) {
171
+ const results = Array.from(toPaths(path)).map(([path, alpha])=>{
172
+ return Object.assign(validatePath(config, path, defaultValue, {
173
+ opacityValue: alpha
174
+ }), {
175
+ resolvedPath: path,
176
+ alpha
177
+ });
178
+ });
179
+ var ref;
180
+ return (ref = results.find((result)=>result.isValid)) !== null && ref !== void 0 ? ref : results[0];
181
+ }
142
182
  function _default({ tailwindConfig: config }) {
143
183
  let functions = {
144
184
  theme: (node, path, ...defaultValue)=>{
145
- const { isValid , value , error } = validatePath(config, path, defaultValue.length ? defaultValue : undefined);
185
+ let { isValid , value , error , alpha } = resolvePath(config, path, defaultValue.length ? defaultValue : undefined);
146
186
  if (!isValid) {
147
187
  throw node.error(error);
148
188
  }
189
+ let maybeColor = (0, _pluginUtils.parseColorFormat)(value);
190
+ let isColorFunction = maybeColor !== undefined && typeof maybeColor === "function";
191
+ if (alpha !== undefined || isColorFunction) {
192
+ if (alpha === undefined) {
193
+ alpha = 1.0;
194
+ }
195
+ value = (0, _withAlphaVariable.withAlphaValue)(maybeColor, alpha, maybeColor);
196
+ }
149
197
  return value;
150
198
  },
151
199
  screen: (node, screen)=>{
152
- screen = screen.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
153
- let screens = (0, _normalizeScreens).normalizeScreens(config.theme.screens);
154
- let screenDefinition = screens.find(({ name })=>name === screen
155
- );
200
+ screen = screen.replace(/^['"]+/g, "").replace(/['"]+$/g, "");
201
+ let screens = (0, _normalizeScreens.normalizeScreens)(config.theme.screens);
202
+ let screenDefinition = screens.find(({ name })=>name === screen);
156
203
  if (!screenDefinition) {
157
204
  throw node.error(`The '${screen}' screen does not exist in your theme.`);
158
205
  }
159
- return (0, _buildMediaQuery).default(screenDefinition);
206
+ return (0, _buildMediaQuery.default)(screenDefinition);
160
207
  }
161
208
  };
162
209
  return (root)=>{