tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.cab1fce

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 (148) hide show
  1. package/CHANGELOG.md +380 -1
  2. package/LICENSE +1 -2
  3. package/README.md +8 -4
  4. package/colors.d.ts +3 -0
  5. package/colors.js +2 -1
  6. package/defaultConfig.d.ts +3 -0
  7. package/defaultConfig.js +2 -1
  8. package/defaultTheme.d.ts +3 -0
  9. package/defaultTheme.js +2 -1
  10. package/lib/cli-peer-dependencies.js +10 -5
  11. package/lib/cli.js +311 -213
  12. package/lib/constants.js +9 -9
  13. package/lib/corePluginList.js +11 -1
  14. package/lib/corePlugins.js +1895 -1773
  15. package/lib/css/preflight.css +19 -13
  16. package/lib/featureFlags.js +22 -16
  17. package/lib/index.js +17 -8
  18. package/lib/lib/cacheInvalidation.js +69 -0
  19. package/lib/lib/collapseAdjacentRules.js +30 -14
  20. package/lib/lib/collapseDuplicateDeclarations.js +80 -0
  21. package/lib/lib/defaultExtractor.js +187 -0
  22. package/lib/lib/detectNesting.js +17 -2
  23. package/lib/lib/evaluateTailwindFunctions.js +40 -24
  24. package/lib/lib/expandApplyAtRules.js +414 -157
  25. package/lib/lib/expandTailwindAtRules.js +156 -151
  26. package/lib/lib/generateRules.js +402 -68
  27. package/lib/lib/getModuleDependencies.js +14 -14
  28. package/lib/lib/normalizeTailwindDirectives.js +45 -36
  29. package/lib/lib/partitionApplyAtRules.js +53 -0
  30. package/lib/lib/regex.js +53 -0
  31. package/lib/lib/resolveDefaultsAtRules.js +105 -90
  32. package/lib/lib/setupContextUtils.js +416 -291
  33. package/lib/lib/setupTrackingContext.js +60 -56
  34. package/lib/lib/sharedState.js +38 -15
  35. package/lib/lib/substituteScreenAtRules.js +9 -6
  36. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  37. package/lib/postcss-plugins/nesting/index.js +17 -0
  38. package/lib/postcss-plugins/nesting/plugin.js +85 -0
  39. package/lib/processTailwindFeatures.js +21 -9
  40. package/lib/public/colors.js +244 -248
  41. package/lib/public/resolve-config.js +5 -5
  42. package/lib/util/buildMediaQuery.js +13 -24
  43. package/lib/util/cloneDeep.js +1 -1
  44. package/lib/util/cloneNodes.js +12 -1
  45. package/lib/util/color.js +43 -32
  46. package/lib/util/createPlugin.js +1 -2
  47. package/lib/util/createUtilityPlugin.js +13 -17
  48. package/lib/util/dataTypes.js +114 -74
  49. package/lib/util/defaults.js +6 -0
  50. package/lib/util/escapeClassName.js +5 -5
  51. package/lib/util/escapeCommas.js +1 -1
  52. package/lib/util/flattenColorPalette.js +2 -4
  53. package/lib/util/formatVariantSelector.js +194 -0
  54. package/lib/util/getAllConfigs.js +13 -5
  55. package/lib/util/hashConfig.js +5 -5
  56. package/lib/util/isKeyframeRule.js +1 -1
  57. package/lib/util/isPlainObject.js +1 -1
  58. package/lib/util/isValidArbitraryValue.js +64 -0
  59. package/lib/util/log.js +35 -19
  60. package/lib/util/nameClass.js +7 -6
  61. package/lib/util/negateValue.js +5 -3
  62. package/lib/util/normalizeConfig.js +233 -0
  63. package/lib/util/normalizeScreens.js +59 -0
  64. package/lib/util/parseAnimationValue.js +56 -56
  65. package/lib/util/parseBoxShadowValue.js +76 -0
  66. package/lib/util/parseDependency.js +32 -32
  67. package/lib/util/parseObjectStyles.js +6 -6
  68. package/lib/util/pluginUtils.js +67 -170
  69. package/lib/util/prefixSelector.js +4 -7
  70. package/lib/util/resolveConfig.js +123 -133
  71. package/lib/util/resolveConfigPath.js +17 -18
  72. package/lib/util/responsive.js +6 -6
  73. package/lib/util/splitAtTopLevelOnly.js +72 -0
  74. package/lib/util/toColorValue.js +1 -2
  75. package/lib/util/toPath.js +6 -1
  76. package/lib/util/transformThemeValue.js +42 -34
  77. package/lib/util/validateConfig.js +21 -0
  78. package/lib/util/withAlphaVariable.js +19 -19
  79. package/nesting/index.js +2 -12
  80. package/package.json +41 -42
  81. package/peers/index.js +11539 -10859
  82. package/plugin.d.ts +11 -0
  83. package/plugin.js +2 -1
  84. package/resolveConfig.js +2 -1
  85. package/scripts/create-plugin-list.js +2 -2
  86. package/scripts/generate-types.js +52 -0
  87. package/src/cli-peer-dependencies.js +7 -1
  88. package/src/cli.js +174 -41
  89. package/src/corePluginList.js +1 -1
  90. package/src/corePlugins.js +641 -596
  91. package/src/css/preflight.css +19 -13
  92. package/src/featureFlags.js +16 -10
  93. package/src/index.js +14 -6
  94. package/src/lib/cacheInvalidation.js +52 -0
  95. package/src/lib/collapseAdjacentRules.js +21 -2
  96. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  97. package/src/lib/defaultExtractor.js +192 -0
  98. package/src/lib/detectNesting.js +22 -3
  99. package/src/lib/evaluateTailwindFunctions.js +24 -7
  100. package/src/lib/expandApplyAtRules.js +442 -154
  101. package/src/lib/expandTailwindAtRules.js +91 -65
  102. package/src/lib/generateRules.js +409 -43
  103. package/src/lib/normalizeTailwindDirectives.js +10 -3
  104. package/src/lib/partitionApplyAtRules.js +52 -0
  105. package/src/lib/regex.js +74 -0
  106. package/src/lib/resolveDefaultsAtRules.js +74 -53
  107. package/src/lib/setupContextUtils.js +388 -208
  108. package/src/lib/setupTrackingContext.js +15 -12
  109. package/src/lib/sharedState.js +42 -7
  110. package/src/lib/substituteScreenAtRules.js +6 -3
  111. package/src/postcss-plugins/nesting/README.md +42 -0
  112. package/src/postcss-plugins/nesting/index.js +13 -0
  113. package/src/postcss-plugins/nesting/plugin.js +80 -0
  114. package/src/processTailwindFeatures.js +17 -2
  115. package/src/public/colors.js +4 -9
  116. package/src/util/buildMediaQuery.js +14 -18
  117. package/src/util/cloneNodes.js +14 -1
  118. package/src/util/color.js +31 -14
  119. package/src/util/createUtilityPlugin.js +2 -2
  120. package/src/util/dataTypes.js +56 -16
  121. package/src/util/defaults.js +6 -0
  122. package/src/util/formatVariantSelector.js +213 -0
  123. package/src/util/getAllConfigs.js +7 -0
  124. package/src/util/isValidArbitraryValue.js +61 -0
  125. package/src/util/log.js +23 -22
  126. package/src/util/nameClass.js +2 -2
  127. package/src/util/negateValue.js +4 -2
  128. package/src/util/normalizeConfig.js +262 -0
  129. package/src/util/normalizeScreens.js +45 -0
  130. package/src/util/parseBoxShadowValue.js +72 -0
  131. package/src/util/pluginUtils.js +51 -147
  132. package/src/util/prefixSelector.js +7 -8
  133. package/src/util/resolveConfig.js +108 -79
  134. package/src/util/splitAtTopLevelOnly.js +71 -0
  135. package/src/util/toPath.js +23 -1
  136. package/src/util/transformThemeValue.js +24 -7
  137. package/src/util/validateConfig.js +13 -0
  138. package/stubs/defaultConfig.stub.js +157 -94
  139. package/stubs/simpleConfig.stub.js +0 -1
  140. package/types/config.d.ts +325 -0
  141. package/types/generated/.gitkeep +0 -0
  142. package/types/generated/colors.d.ts +276 -0
  143. package/types/generated/corePluginList.d.ts +1 -0
  144. package/types/index.d.ts +1 -0
  145. package/types.d.ts +1 -0
  146. package/lib/lib/setupWatchingContext.js +0 -284
  147. package/nesting/plugin.js +0 -41
  148. package/src/lib/setupWatchingContext.js +0 -306
@@ -2,12 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.applyStateToMarker = applyStateToMarker;
6
5
  exports.updateAllClasses = updateAllClasses;
7
- exports.updateLastClasses = updateLastClasses;
8
- exports.transformAllSelectors = transformAllSelectors;
9
- exports.transformAllClasses = transformAllClasses;
10
- exports.transformLastClasses = transformLastClasses;
11
6
  exports.asValue = asValue;
12
7
  exports.asColor = asColor;
13
8
  exports.asLookupValue = asLookupValue;
@@ -15,173 +10,66 @@ exports.coerceValue = coerceValue;
15
10
  var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
16
11
  var _escapeCommas = _interopRequireDefault(require("./escapeCommas"));
17
12
  var _withAlphaVariable = require("./withAlphaVariable");
18
- var _isKeyframeRule = _interopRequireDefault(require("./isKeyframeRule"));
19
13
  var _dataTypes = require("./dataTypes");
14
+ var _negateValue = _interopRequireDefault(require("./negateValue"));
20
15
  function _interopRequireDefault(obj) {
21
16
  return obj && obj.__esModule ? obj : {
22
17
  default: obj
23
18
  };
24
19
  }
25
- function applyStateToMarker(selector, marker, state, join) {
26
- let markerIdx = selector.search(new RegExp(`${marker}[:[]`));
27
- if (markerIdx === -1) {
28
- return join(marker + state, selector);
29
- }
30
- let markerSelector = selector.slice(markerIdx, selector.indexOf(' ', markerIdx));
31
- return join(marker + state + markerSelector.slice(markerIdx + marker.length), selector.replace(markerSelector, ''));
32
- }
33
- function updateAllClasses(selectors, updateClass) {
20
+ function updateAllClasses(selectors1, updateClass) {
34
21
  let parser = (0, _postcssSelectorParser).default((selectors)=>{
35
22
  selectors.walkClasses((sel)=>{
36
- let updatedClass = updateClass(sel.value, {
37
- withAttr (className, attr) {
38
- sel.parent.insertAfter(sel, _postcssSelectorParser.default.attribute({
39
- attribute: attr.slice(1, -1)
40
- }));
41
- return className;
42
- },
43
- withPseudo (className, pseudo) {
44
- sel.parent.insertAfter(sel, _postcssSelectorParser.default.pseudo({
45
- value: pseudo
46
- }));
47
- return className;
48
- }
49
- });
23
+ let updatedClass = updateClass(sel.value);
50
24
  sel.value = updatedClass;
51
25
  if (sel.raws && sel.raws.value) {
52
26
  sel.raws.value = (0, _escapeCommas).default(sel.raws.value);
53
27
  }
54
28
  });
55
29
  });
56
- let result = parser.processSync(selectors);
30
+ let result = parser.processSync(selectors1);
57
31
  return result;
58
32
  }
59
- function updateLastClasses(selectors, updateClass) {
60
- let parser = (0, _postcssSelectorParser).default((selectors)=>{
61
- selectors.each((sel)=>{
62
- let lastClass = sel.filter(({ type })=>type === 'class'
63
- ).pop();
64
- if (lastClass === undefined) {
65
- return;
66
- }
67
- let updatedClass = updateClass(lastClass.value, {
68
- withPseudo (className, pseudo) {
69
- lastClass.parent.insertAfter(lastClass, _postcssSelectorParser.default.pseudo({
70
- value: `${pseudo}`
71
- }));
72
- return className;
73
- }
74
- });
75
- lastClass.value = updatedClass;
76
- if (lastClass.raws && lastClass.raws.value) {
77
- lastClass.raws.value = (0, _escapeCommas).default(lastClass.raws.value);
78
- }
79
- });
80
- });
81
- let result = parser.processSync(selectors);
82
- return result;
83
- }
84
- function splitByNotEscapedCommas(str) {
85
- let chunks = [];
86
- let currentChunk = '';
87
- for(let i = 0; i < str.length; i++){
88
- if (str[i] === ',' && str[i - 1] !== '\\') {
89
- chunks.push(currentChunk);
90
- currentChunk = '';
91
- } else {
92
- currentChunk += str[i];
93
- }
33
+ function resolveArbitraryValue(modifier, validate) {
34
+ if (!isArbitraryValue(modifier)) {
35
+ return undefined;
94
36
  }
95
- chunks.push(currentChunk);
96
- return chunks;
97
- }
98
- function transformAllSelectors(transformSelector, { wrap , withRule } = {
99
- }) {
100
- return ({ container })=>{
101
- container.walkRules((rule)=>{
102
- if ((0, _isKeyframeRule).default(rule)) {
103
- return rule;
104
- }
105
- let transformed = splitByNotEscapedCommas(rule.selector).map(transformSelector).join(',');
106
- rule.selector = transformed;
107
- if (withRule) {
108
- withRule(rule);
109
- }
110
- return rule;
111
- });
112
- if (wrap) {
113
- let wrapper = wrap();
114
- let nodes = container.nodes;
115
- container.removeAll();
116
- wrapper.append(nodes);
117
- container.append(wrapper);
118
- }
119
- };
120
- }
121
- function transformAllClasses(transformClass, { wrap , withRule } = {
122
- }) {
123
- return ({ container })=>{
124
- container.walkRules((rule)=>{
125
- let selector = rule.selector;
126
- let variantSelector = updateAllClasses(selector, transformClass);
127
- rule.selector = variantSelector;
128
- if (withRule) {
129
- withRule(rule);
130
- }
131
- return rule;
132
- });
133
- if (wrap) {
134
- let wrapper = wrap();
135
- let nodes = container.nodes;
136
- container.removeAll();
137
- wrapper.append(nodes);
138
- container.append(wrapper);
139
- }
140
- };
37
+ let value = modifier.slice(1, -1);
38
+ if (!validate(value)) {
39
+ return undefined;
40
+ }
41
+ return (0, _dataTypes).normalize(value);
141
42
  }
142
- function transformLastClasses(transformClass, { wrap , withRule } = {
143
- }) {
144
- return ({ container })=>{
145
- container.walkRules((rule)=>{
146
- let selector = rule.selector;
147
- let variantSelector = updateLastClasses(selector, transformClass);
148
- rule.selector = variantSelector;
149
- if (withRule) {
150
- withRule(rule);
151
- }
152
- return rule;
153
- });
154
- if (wrap) {
155
- let wrapper = wrap();
156
- let nodes = container.nodes;
157
- container.removeAll();
158
- wrapper.append(nodes);
159
- container.append(wrapper);
43
+ function asNegativeValue(modifier, lookup = {}, validate) {
44
+ let positiveValue = lookup[modifier];
45
+ if (positiveValue !== undefined) {
46
+ return (0, _negateValue).default(positiveValue);
47
+ }
48
+ if (isArbitraryValue(modifier)) {
49
+ let resolved = resolveArbitraryValue(modifier, validate);
50
+ if (resolved === undefined) {
51
+ return undefined;
160
52
  }
161
- };
53
+ return (0, _negateValue).default(resolved);
54
+ }
162
55
  }
163
- function asValue(modifier, lookup = {
164
- }, { validate =()=>true
165
- } = {
166
- }) {
167
- let value = lookup[modifier];
56
+ function asValue(modifier, options = {}, { validate =()=>true
57
+ } = {}) {
58
+ var ref;
59
+ let value = (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
168
60
  if (value !== undefined) {
169
61
  return value;
170
62
  }
171
- if (!isArbitraryValue(modifier)) {
172
- return undefined;
173
- }
174
- value = modifier.slice(1, -1);
175
- if (!validate(value)) {
176
- return undefined;
63
+ if (options.supportsNegativeValues && modifier.startsWith("-")) {
64
+ return asNegativeValue(modifier.slice(1), options.values, validate);
177
65
  }
178
- return (0, _dataTypes).normalize(value);
66
+ return resolveArbitraryValue(modifier, validate);
179
67
  }
180
68
  function isArbitraryValue(input) {
181
- return input.startsWith('[') && input.endsWith(']');
69
+ return input.startsWith("[") && input.endsWith("]");
182
70
  }
183
71
  function splitAlpha(modifier) {
184
- let slashIdx = modifier.lastIndexOf('/');
72
+ let slashIdx = modifier.lastIndexOf("/");
185
73
  if (slashIdx === -1 || slashIdx === modifier.length - 1) {
186
74
  return [
187
75
  modifier
@@ -192,39 +80,39 @@ function splitAlpha(modifier) {
192
80
  modifier.slice(slashIdx + 1)
193
81
  ];
194
82
  }
195
- function asColor(modifier, lookup = {
196
- }, tailwindConfig = {
197
- }) {
198
- if (lookup[modifier] !== undefined) {
199
- return lookup[modifier];
83
+ function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
84
+ var ref;
85
+ if (((ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier]) !== undefined) {
86
+ var ref1;
87
+ return (ref1 = options.values) === null || ref1 === void 0 ? void 0 : ref1[modifier];
200
88
  }
201
89
  let [color, alpha] = splitAlpha(modifier);
202
90
  if (alpha !== undefined) {
203
- var ref, ref1;
204
- var _color;
205
- let normalizedColor = (_color = lookup[color]) !== null && _color !== void 0 ? _color : isArbitraryValue(color) ? color.slice(1, -1) : undefined;
91
+ var ref2, ref3, ref4;
92
+ var ref5;
93
+ let normalizedColor = (ref5 = (ref2 = options.values) === null || ref2 === void 0 ? void 0 : ref2[color]) !== null && ref5 !== void 0 ? ref5 : isArbitraryValue(color) ? color.slice(1, -1) : undefined;
206
94
  if (normalizedColor === undefined) {
207
95
  return undefined;
208
96
  }
209
97
  if (isArbitraryValue(alpha)) {
210
98
  return (0, _withAlphaVariable).withAlphaValue(normalizedColor, alpha.slice(1, -1));
211
99
  }
212
- if (((ref = tailwindConfig.theme) === null || ref === void 0 ? void 0 : (ref1 = ref.opacity) === null || ref1 === void 0 ? void 0 : ref1[alpha]) === undefined) {
100
+ if (((ref3 = tailwindConfig.theme) === null || ref3 === void 0 ? void 0 : (ref4 = ref3.opacity) === null || ref4 === void 0 ? void 0 : ref4[alpha]) === undefined) {
213
101
  return undefined;
214
102
  }
215
103
  return (0, _withAlphaVariable).withAlphaValue(normalizedColor, tailwindConfig.theme.opacity[alpha]);
216
104
  }
217
- return asValue(modifier, lookup, {
105
+ return asValue(modifier, options, {
218
106
  validate: _dataTypes.color
219
107
  });
220
108
  }
221
- function asLookupValue(modifier, lookup = {
222
- }) {
223
- return lookup[modifier];
109
+ function asLookupValue(modifier, options = {}) {
110
+ var ref;
111
+ return (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
224
112
  }
225
113
  function guess(validate) {
226
- return (modifier, lookup)=>{
227
- return asValue(modifier, lookup, {
114
+ return (modifier, options)=>{
115
+ return asValue(modifier, options, {
228
116
  validate
229
117
  });
230
118
  };
@@ -238,12 +126,13 @@ let typeMap = {
238
126
  percentage: guess(_dataTypes.percentage),
239
127
  position: guess(_dataTypes.position),
240
128
  lookup: asLookupValue,
241
- 'generic-name': guess(_dataTypes.genericName),
242
- 'family-name': guess(_dataTypes.familyName),
129
+ "generic-name": guess(_dataTypes.genericName),
130
+ "family-name": guess(_dataTypes.familyName),
243
131
  number: guess(_dataTypes.number),
244
- 'line-width': guess(_dataTypes.lineWidth),
245
- 'absolute-size': guess(_dataTypes.absoluteSize),
246
- 'relative-size': guess(_dataTypes.relativeSize)
132
+ "line-width": guess(_dataTypes.lineWidth),
133
+ "absolute-size": guess(_dataTypes.absoluteSize),
134
+ "relative-size": guess(_dataTypes.relativeSize),
135
+ shadow: guess(_dataTypes.shadow)
247
136
  };
248
137
  let supportedTypes = Object.keys(typeMap);
249
138
  function splitAtFirst(input, delim) {
@@ -257,23 +146,31 @@ function splitAtFirst(input, delim) {
257
146
  input.slice(idx + 1)
258
147
  ];
259
148
  }
260
- function coerceValue(types, modifier, values, tailwindConfig) {
149
+ function coerceValue(types, modifier, options, tailwindConfig) {
261
150
  if (isArbitraryValue(modifier)) {
262
- let [explicitType, value] = splitAtFirst(modifier.slice(1, -1), ':');
263
- if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
151
+ let arbitraryValue = modifier.slice(1, -1);
152
+ let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
153
+ // It could be that this resolves to `url(https` which is not a valid
154
+ // identifier. We currently only support "simple" words with dashes or
155
+ // underscores. E.g.: family-name
156
+ if (!/^[\w-_]+$/g.test(explicitType)) {
157
+ value = arbitraryValue;
158
+ } else if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
264
159
  return [];
265
160
  }
266
161
  if (value.length > 0 && supportedTypes.includes(explicitType)) {
267
162
  return [
268
- asValue(`[${value}]`, values, tailwindConfig),
163
+ asValue(`[${value}]`, options),
269
164
  explicitType
270
165
  ];
271
166
  }
272
167
  }
273
168
  // Find first matching type
274
169
  for (let type of [].concat(types)){
275
- let result = typeMap[type](modifier, values, tailwindConfig);
276
- if (result) return [
170
+ let result = typeMap[type](modifier, options, {
171
+ tailwindConfig
172
+ });
173
+ if (result !== undefined) return [
277
174
  result,
278
175
  type
279
176
  ];
@@ -4,20 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.default = _default;
6
6
  var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
7
- var _tap = require("./tap");
8
7
  function _interopRequireDefault(obj) {
9
8
  return obj && obj.__esModule ? obj : {
10
9
  default: obj
11
10
  };
12
11
  }
13
- function _default(prefix, selector) {
14
- const getPrefix = typeof prefix === 'function' ? prefix : ()=>prefix === undefined ? '' : prefix
15
- ;
12
+ function _default(prefix, selector, prependNegative = false) {
16
13
  return (0, _postcssSelectorParser).default((selectors)=>{
17
14
  selectors.walkClasses((classSelector)=>{
18
- (0, _tap).tap(classSelector.value, (baseClass)=>{
19
- classSelector.value = `${getPrefix('.' + baseClass)}${baseClass}`;
20
- });
15
+ let baseClass = classSelector.value;
16
+ let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
17
+ classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
21
18
  });
22
19
  }).processSync(selector);
23
20
  }