tailwindcss 0.0.0-insiders.7b94fea → 0.0.0-insiders.7d8eb21

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 (190) hide show
  1. package/CHANGELOG.md +588 -3
  2. package/LICENSE +1 -2
  3. package/README.md +15 -7
  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 +4 -0
  9. package/defaultTheme.js +2 -1
  10. package/lib/cli/build/deps.js +54 -0
  11. package/lib/cli/build/index.js +48 -0
  12. package/lib/cli/build/plugin.js +362 -0
  13. package/lib/cli/build/utils.js +78 -0
  14. package/lib/cli/build/watching.js +178 -0
  15. package/lib/cli/help/index.js +71 -0
  16. package/lib/cli/index.js +18 -0
  17. package/lib/cli/init/index.js +46 -0
  18. package/lib/cli/shared.js +12 -0
  19. package/lib/cli-peer-dependencies.js +20 -7
  20. package/lib/cli.js +108 -571
  21. package/lib/constants.js +27 -20
  22. package/lib/corePluginList.js +15 -4
  23. package/lib/corePlugins.js +2229 -1868
  24. package/lib/css/preflight.css +22 -9
  25. package/lib/featureFlags.js +39 -25
  26. package/lib/index.js +28 -12
  27. package/lib/lib/cacheInvalidation.js +90 -0
  28. package/lib/lib/collapseAdjacentRules.js +28 -10
  29. package/lib/lib/collapseDuplicateDeclarations.js +83 -0
  30. package/lib/lib/content.js +177 -0
  31. package/lib/lib/defaultExtractor.js +241 -0
  32. package/lib/lib/detectNesting.js +27 -3
  33. package/lib/lib/evaluateTailwindFunctions.js +117 -50
  34. package/lib/lib/expandApplyAtRules.js +457 -159
  35. package/lib/lib/expandTailwindAtRules.js +130 -127
  36. package/lib/lib/findAtConfigPath.js +44 -0
  37. package/lib/lib/generateRules.js +610 -141
  38. package/lib/lib/getModuleDependencies.js +11 -8
  39. package/lib/lib/normalizeTailwindDirectives.js +43 -32
  40. package/lib/lib/offsets.js +285 -0
  41. package/lib/lib/partitionApplyAtRules.js +56 -0
  42. package/lib/lib/regex.js +60 -0
  43. package/lib/lib/remap-bitfield.js +87 -0
  44. package/lib/lib/resolveDefaultsAtRules.js +114 -81
  45. package/lib/lib/setupContextUtils.js +718 -323
  46. package/lib/lib/setupTrackingContext.js +43 -71
  47. package/lib/lib/sharedState.js +50 -9
  48. package/lib/lib/substituteScreenAtRules.js +13 -8
  49. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  50. package/lib/postcss-plugins/nesting/index.js +19 -0
  51. package/lib/postcss-plugins/nesting/plugin.js +87 -0
  52. package/lib/processTailwindFeatures.js +36 -21
  53. package/lib/public/colors.js +247 -245
  54. package/lib/public/create-plugin.js +6 -4
  55. package/lib/public/default-config.js +7 -5
  56. package/lib/public/default-theme.js +7 -5
  57. package/lib/public/resolve-config.js +8 -5
  58. package/lib/util/bigSign.js +4 -1
  59. package/lib/util/buildMediaQuery.js +18 -24
  60. package/lib/util/cloneDeep.js +7 -6
  61. package/lib/util/cloneNodes.js +21 -3
  62. package/lib/util/color.js +54 -40
  63. package/lib/util/configurePlugins.js +5 -2
  64. package/lib/util/createPlugin.js +6 -6
  65. package/lib/util/createUtilityPlugin.js +12 -14
  66. package/lib/util/dataTypes.js +164 -100
  67. package/lib/util/defaults.js +12 -3
  68. package/lib/util/escapeClassName.js +9 -6
  69. package/lib/util/escapeCommas.js +5 -2
  70. package/lib/util/flattenColorPalette.js +9 -12
  71. package/lib/util/formatVariantSelector.js +353 -0
  72. package/lib/util/getAllConfigs.js +29 -10
  73. package/lib/util/hashConfig.js +6 -3
  74. package/lib/util/isKeyframeRule.js +5 -2
  75. package/lib/util/isPlainObject.js +5 -2
  76. package/lib/util/isSyntacticallyValidPropertyValue.js +72 -0
  77. package/lib/util/log.js +22 -12
  78. package/lib/util/nameClass.js +20 -8
  79. package/lib/util/negateValue.js +23 -6
  80. package/lib/util/normalizeConfig.js +147 -60
  81. package/lib/util/normalizeScreens.js +170 -0
  82. package/lib/util/parseAnimationValue.js +42 -40
  83. package/lib/util/parseBoxShadowValue.js +84 -0
  84. package/lib/util/parseDependency.js +38 -56
  85. package/lib/util/parseGlob.js +34 -0
  86. package/lib/util/parseObjectStyles.js +11 -8
  87. package/lib/util/pluginUtils.js +182 -181
  88. package/lib/util/prefixSelector.js +27 -13
  89. package/lib/util/removeAlphaVariables.js +29 -0
  90. package/lib/util/resolveConfig.js +97 -73
  91. package/lib/util/resolveConfigPath.js +11 -9
  92. package/lib/util/responsive.js +8 -5
  93. package/lib/util/splitAtTopLevelOnly.js +43 -0
  94. package/lib/util/tap.js +4 -1
  95. package/lib/util/toColorValue.js +5 -3
  96. package/lib/util/toPath.js +24 -3
  97. package/lib/util/transformThemeValue.js +49 -31
  98. package/lib/util/validateConfig.js +24 -0
  99. package/lib/util/validateFormalSyntax.js +24 -0
  100. package/lib/util/withAlphaVariable.js +23 -15
  101. package/nesting/index.js +2 -12
  102. package/package.json +51 -50
  103. package/peers/index.js +15019 -12583
  104. package/plugin.d.ts +11 -0
  105. package/plugin.js +2 -1
  106. package/resolveConfig.d.ts +12 -0
  107. package/resolveConfig.js +2 -1
  108. package/scripts/generate-types.js +105 -0
  109. package/scripts/release-channel.js +18 -0
  110. package/scripts/release-notes.js +21 -0
  111. package/scripts/type-utils.js +27 -0
  112. package/src/cli/build/deps.js +56 -0
  113. package/src/cli/build/index.js +49 -0
  114. package/src/cli/build/plugin.js +434 -0
  115. package/src/cli/build/utils.js +76 -0
  116. package/src/cli/build/watching.js +227 -0
  117. package/src/cli/help/index.js +70 -0
  118. package/src/cli/index.js +3 -0
  119. package/src/cli/init/index.js +50 -0
  120. package/src/cli/shared.js +5 -0
  121. package/src/cli-peer-dependencies.js +7 -1
  122. package/src/cli.js +50 -577
  123. package/src/corePluginList.js +1 -1
  124. package/src/corePlugins.js +886 -598
  125. package/src/css/preflight.css +22 -9
  126. package/src/featureFlags.js +24 -8
  127. package/src/index.js +19 -6
  128. package/src/lib/cacheInvalidation.js +52 -0
  129. package/src/lib/collapseAdjacentRules.js +21 -2
  130. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  131. package/src/lib/content.js +213 -0
  132. package/src/lib/defaultExtractor.js +217 -0
  133. package/src/lib/detectNesting.js +30 -3
  134. package/src/lib/evaluateTailwindFunctions.js +84 -10
  135. package/src/lib/expandApplyAtRules.js +508 -153
  136. package/src/lib/expandTailwindAtRules.js +82 -79
  137. package/src/lib/findAtConfigPath.js +48 -0
  138. package/src/lib/generateRules.js +625 -111
  139. package/src/lib/normalizeTailwindDirectives.js +7 -1
  140. package/src/lib/offsets.js +351 -0
  141. package/src/lib/partitionApplyAtRules.js +52 -0
  142. package/src/lib/regex.js +74 -0
  143. package/src/lib/remap-bitfield.js +82 -0
  144. package/src/lib/resolveDefaultsAtRules.js +98 -60
  145. package/src/lib/setupContextUtils.js +666 -168
  146. package/src/lib/setupTrackingContext.js +16 -52
  147. package/src/lib/sharedState.js +44 -4
  148. package/src/lib/substituteScreenAtRules.js +6 -3
  149. package/src/postcss-plugins/nesting/README.md +42 -0
  150. package/src/postcss-plugins/nesting/index.js +13 -0
  151. package/src/postcss-plugins/nesting/plugin.js +80 -0
  152. package/src/processTailwindFeatures.js +17 -2
  153. package/src/util/buildMediaQuery.js +14 -16
  154. package/src/util/cloneNodes.js +19 -2
  155. package/src/util/color.js +31 -14
  156. package/src/util/createUtilityPlugin.js +2 -2
  157. package/src/util/dataTypes.js +86 -21
  158. package/src/util/defaults.js +6 -0
  159. package/src/util/formatVariantSelector.js +412 -0
  160. package/src/util/getAllConfigs.js +19 -0
  161. package/src/util/isSyntacticallyValidPropertyValue.js +61 -0
  162. package/src/util/log.js +11 -7
  163. package/src/util/nameClass.js +6 -2
  164. package/src/util/negateValue.js +14 -4
  165. package/src/util/normalizeConfig.js +72 -5
  166. package/src/util/normalizeScreens.js +140 -0
  167. package/src/util/parseBoxShadowValue.js +72 -0
  168. package/src/util/parseDependency.js +37 -42
  169. package/src/util/parseGlob.js +24 -0
  170. package/src/util/pluginUtils.js +169 -143
  171. package/src/util/prefixSelector.js +30 -13
  172. package/src/util/removeAlphaVariables.js +24 -0
  173. package/src/util/resolveConfig.js +81 -27
  174. package/src/util/splitAtTopLevelOnly.js +45 -0
  175. package/src/util/toPath.js +23 -1
  176. package/src/util/transformThemeValue.js +33 -8
  177. package/src/util/validateConfig.js +13 -0
  178. package/src/util/validateFormalSyntax.js +34 -0
  179. package/src/util/withAlphaVariable.js +1 -1
  180. package/stubs/defaultConfig.stub.js +246 -213
  181. package/stubs/simpleConfig.stub.js +1 -0
  182. package/types/config.d.ts +363 -0
  183. package/types/generated/.gitkeep +0 -0
  184. package/types/generated/colors.d.ts +276 -0
  185. package/types/generated/corePluginList.d.ts +1 -0
  186. package/types/generated/default-theme.d.ts +342 -0
  187. package/types/index.d.ts +7 -0
  188. package/lib/lib/setupWatchingContext.js +0 -284
  189. package/nesting/plugin.js +0 -41
  190. package/src/lib/setupWatchingContext.js +0 -304
@@ -2,189 +2,113 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.applyStateToMarker = applyStateToMarker;
6
- exports.updateAllClasses = updateAllClasses;
7
- exports.updateLastClasses = updateLastClasses;
8
- exports.transformAllSelectors = transformAllSelectors;
9
- exports.transformAllClasses = transformAllClasses;
10
- exports.transformLastClasses = transformLastClasses;
11
- exports.asValue = asValue;
12
- exports.asColor = asColor;
13
- exports.asLookupValue = asLookupValue;
14
- exports.coerceValue = coerceValue;
15
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
16
- var _escapeCommas = _interopRequireDefault(require("./escapeCommas"));
17
- var _withAlphaVariable = require("./withAlphaVariable");
18
- var _isKeyframeRule = _interopRequireDefault(require("./isKeyframeRule"));
19
- var _dataTypes = require("./dataTypes");
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ updateAllClasses: ()=>updateAllClasses,
13
+ filterSelectorsForClass: ()=>filterSelectorsForClass,
14
+ asValue: ()=>asValue,
15
+ parseColorFormat: ()=>parseColorFormat,
16
+ asColor: ()=>asColor,
17
+ asLookupValue: ()=>asLookupValue,
18
+ typeMap: ()=>typeMap,
19
+ coerceValue: ()=>coerceValue,
20
+ getMatchingTypes: ()=>getMatchingTypes
21
+ });
22
+ const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
23
+ const _escapeCommas = /*#__PURE__*/ _interopRequireDefault(require("./escapeCommas"));
24
+ const _withAlphaVariable = require("./withAlphaVariable");
25
+ const _dataTypes = require("./dataTypes");
26
+ const _negateValue = /*#__PURE__*/ _interopRequireDefault(require("./negateValue"));
27
+ const _validateFormalSyntax = require("./validateFormalSyntax");
28
+ const _featureFlagsJs = require("../featureFlags.js");
20
29
  function _interopRequireDefault(obj) {
21
30
  return obj && obj.__esModule ? obj : {
22
31
  default: obj
23
32
  };
24
33
  }
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
34
  function updateAllClasses(selectors, updateClass) {
34
- let parser = (0, _postcssSelectorParser).default((selectors)=>{
35
+ let parser = (0, _postcssSelectorParser.default)((selectors)=>{
35
36
  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
- });
37
+ let updatedClass = updateClass(sel.value);
50
38
  sel.value = updatedClass;
51
39
  if (sel.raws && sel.raws.value) {
52
- sel.raws.value = (0, _escapeCommas).default(sel.raws.value);
40
+ sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
53
41
  }
54
42
  });
55
43
  });
56
44
  let result = parser.processSync(selectors);
57
45
  return result;
58
46
  }
59
- function updateLastClasses(selectors, updateClass) {
60
- let parser = (0, _postcssSelectorParser).default((selectors)=>{
47
+ function filterSelectorsForClass(selectors, classCandidate) {
48
+ let parser = (0, _postcssSelectorParser.default)((selectors)=>{
61
49
  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);
50
+ const containsClass = sel.nodes.some((node)=>node.type === "class" && node.value === classCandidate);
51
+ if (!containsClass) {
52
+ sel.remove();
78
53
  }
79
54
  });
80
55
  });
81
56
  let result = parser.processSync(selectors);
82
57
  return result;
83
58
  }
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
- }
59
+ function resolveArbitraryValue(modifier, validate) {
60
+ if (!isArbitraryValue(modifier)) {
61
+ return undefined;
94
62
  }
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
- };
63
+ let value = modifier.slice(1, -1);
64
+ if (!validate(value)) {
65
+ return undefined;
66
+ }
67
+ return (0, _dataTypes.normalize)(value);
141
68
  }
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);
69
+ function asNegativeValue(modifier, lookup = {}, validate) {
70
+ let positiveValue = lookup[modifier];
71
+ if (positiveValue !== undefined) {
72
+ return (0, _negateValue.default)(positiveValue);
73
+ }
74
+ if (isArbitraryValue(modifier)) {
75
+ let resolved = resolveArbitraryValue(modifier, validate);
76
+ if (resolved === undefined) {
77
+ return undefined;
160
78
  }
161
- };
79
+ return (0, _negateValue.default)(resolved);
80
+ }
162
81
  }
163
- function asValue(modifier, lookup = {
164
- }, { validate =()=>true
165
- } = {
166
- }) {
167
- let value = lookup[modifier];
82
+ function asValue(modifier, options = {}, { validate =()=>true } = {}) {
83
+ var _options_values;
84
+ let value = (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
168
85
  if (value !== undefined) {
169
86
  return value;
170
87
  }
171
- if (!isArbitraryValue(modifier)) {
172
- return undefined;
173
- }
174
- value = modifier.slice(1, -1);
175
- if (!validate(value)) {
176
- return undefined;
88
+ if (options.supportsNegativeValues && modifier.startsWith("-")) {
89
+ return asNegativeValue(modifier.slice(1), options.values, validate);
177
90
  }
178
- return (0, _dataTypes).normalize(value);
91
+ return resolveArbitraryValue(modifier, validate);
179
92
  }
180
93
  function isArbitraryValue(input) {
181
- return input.startsWith('[') && input.endsWith(']');
94
+ return input.startsWith("[") && input.endsWith("]");
182
95
  }
183
- function splitAlpha(modifier) {
184
- let slashIdx = modifier.lastIndexOf('/');
96
+ function splitUtilityModifier(modifier) {
97
+ let slashIdx = modifier.lastIndexOf("/");
185
98
  if (slashIdx === -1 || slashIdx === modifier.length - 1) {
186
99
  return [
187
- modifier
100
+ modifier,
101
+ undefined
102
+ ];
103
+ }
104
+ let arbitrary = isArbitraryValue(modifier);
105
+ // The modifier could be of the form `[foo]/[bar]`
106
+ // We want to handle this case properly
107
+ // without affecting `[foo/bar]`
108
+ if (arbitrary && !modifier.includes("]/[")) {
109
+ return [
110
+ modifier,
111
+ undefined
188
112
  ];
189
113
  }
190
114
  return [
@@ -192,39 +116,56 @@ function splitAlpha(modifier) {
192
116
  modifier.slice(slashIdx + 1)
193
117
  ];
194
118
  }
195
- function asColor(modifier, lookup = {
196
- }, tailwindConfig = {
197
- }) {
198
- if (lookup[modifier] !== undefined) {
199
- return lookup[modifier];
119
+ function parseColorFormat(value) {
120
+ if (typeof value === "string" && value.includes("<alpha-value>")) {
121
+ let oldValue = value;
122
+ return ({ opacityValue =1 })=>oldValue.replace("<alpha-value>", opacityValue);
123
+ }
124
+ return value;
125
+ }
126
+ function unwrapArbitraryModifier(modifier) {
127
+ modifier = modifier.slice(1, -1);
128
+ if (modifier.startsWith("--")) {
129
+ modifier = `var(${modifier})`;
200
130
  }
201
- let [color, alpha] = splitAlpha(modifier);
131
+ return modifier;
132
+ }
133
+ function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
134
+ var _options_values;
135
+ if (((_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier]) !== undefined) {
136
+ var _options_values1;
137
+ return parseColorFormat((_options_values1 = options.values) === null || _options_values1 === void 0 ? void 0 : _options_values1[modifier]);
138
+ }
139
+ // TODO: Hoist this up to getMatchingTypes or something
140
+ // We do this here because we need the alpha value (if any)
141
+ let [color, alpha] = splitUtilityModifier(modifier);
202
142
  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;
143
+ var _options_values2, _tailwindConfig_theme, _tailwindConfig_theme_opacity;
144
+ var _options_values_color;
145
+ let normalizedColor = (_options_values_color = (_options_values2 = options.values) === null || _options_values2 === void 0 ? void 0 : _options_values2[color]) !== null && _options_values_color !== void 0 ? _options_values_color : isArbitraryValue(color) ? color.slice(1, -1) : undefined;
206
146
  if (normalizedColor === undefined) {
207
147
  return undefined;
208
148
  }
149
+ normalizedColor = parseColorFormat(normalizedColor);
209
150
  if (isArbitraryValue(alpha)) {
210
- return (0, _withAlphaVariable).withAlphaValue(normalizedColor, alpha.slice(1, -1));
151
+ return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, unwrapArbitraryModifier(alpha));
211
152
  }
212
- if (((ref = tailwindConfig.theme) === null || ref === void 0 ? void 0 : (ref1 = ref.opacity) === null || ref1 === void 0 ? void 0 : ref1[alpha]) === undefined) {
153
+ if (((_tailwindConfig_theme = tailwindConfig.theme) === null || _tailwindConfig_theme === void 0 ? void 0 : (_tailwindConfig_theme_opacity = _tailwindConfig_theme.opacity) === null || _tailwindConfig_theme_opacity === void 0 ? void 0 : _tailwindConfig_theme_opacity[alpha]) === undefined) {
213
154
  return undefined;
214
155
  }
215
- return (0, _withAlphaVariable).withAlphaValue(normalizedColor, tailwindConfig.theme.opacity[alpha]);
156
+ return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, tailwindConfig.theme.opacity[alpha]);
216
157
  }
217
- return asValue(modifier, lookup, {
158
+ return asValue(modifier, options, {
218
159
  validate: _dataTypes.color
219
160
  });
220
161
  }
221
- function asLookupValue(modifier, lookup = {
222
- }) {
223
- return lookup[modifier];
162
+ function asLookupValue(modifier, options = {}) {
163
+ var _options_values;
164
+ return (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
224
165
  }
225
166
  function guess(validate) {
226
- return (modifier, lookup)=>{
227
- return asValue(modifier, lookup, {
167
+ return (modifier, options)=>{
168
+ return asValue(modifier, options, {
228
169
  validate
229
170
  });
230
171
  };
@@ -238,12 +179,14 @@ let typeMap = {
238
179
  percentage: guess(_dataTypes.percentage),
239
180
  position: guess(_dataTypes.position),
240
181
  lookup: asLookupValue,
241
- 'generic-name': guess(_dataTypes.genericName),
242
- 'family-name': guess(_dataTypes.familyName),
182
+ "generic-name": guess(_dataTypes.genericName),
183
+ "family-name": guess(_dataTypes.familyName),
243
184
  number: guess(_dataTypes.number),
244
- 'line-width': guess(_dataTypes.lineWidth),
245
- 'absolute-size': guess(_dataTypes.absoluteSize),
246
- 'relative-size': guess(_dataTypes.relativeSize)
185
+ "line-width": guess(_dataTypes.lineWidth),
186
+ "absolute-size": guess(_dataTypes.absoluteSize),
187
+ "relative-size": guess(_dataTypes.relativeSize),
188
+ shadow: guess(_dataTypes.shadow),
189
+ size: guess(_validateFormalSyntax.backgroundSize)
247
190
  };
248
191
  let supportedTypes = Object.keys(typeMap);
249
192
  function splitAtFirst(input, delim) {
@@ -257,26 +200,84 @@ function splitAtFirst(input, delim) {
257
200
  input.slice(idx + 1)
258
201
  ];
259
202
  }
260
- function coerceValue(types, modifier, values, tailwindConfig) {
203
+ function coerceValue(types, modifier, options, tailwindConfig) {
204
+ if (options.values && modifier in options.values) {
205
+ for (let { type } of types !== null && types !== void 0 ? types : []){
206
+ let result = typeMap[type](modifier, options, {
207
+ tailwindConfig
208
+ });
209
+ if (result === undefined) {
210
+ continue;
211
+ }
212
+ return [
213
+ result,
214
+ type,
215
+ null
216
+ ];
217
+ }
218
+ }
261
219
  if (isArbitraryValue(modifier)) {
262
- let [explicitType, value] = splitAtFirst(modifier.slice(1, -1), ':');
263
- if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
220
+ let arbitraryValue = modifier.slice(1, -1);
221
+ let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
222
+ // It could be that this resolves to `url(https` which is not a valid
223
+ // identifier. We currently only support "simple" words with dashes or
224
+ // underscores. E.g.: family-name
225
+ if (!/^[\w-_]+$/g.test(explicitType)) {
226
+ value = arbitraryValue;
227
+ } else if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
264
228
  return [];
265
229
  }
266
230
  if (value.length > 0 && supportedTypes.includes(explicitType)) {
267
231
  return [
268
- asValue(`[${value}]`, values, tailwindConfig),
269
- explicitType
232
+ asValue(`[${value}]`, options),
233
+ explicitType,
234
+ null
270
235
  ];
271
236
  }
272
237
  }
238
+ let matches = getMatchingTypes(types, modifier, options, tailwindConfig);
273
239
  // Find first matching type
274
- for (let type of [].concat(types)){
275
- let result = typeMap[type](modifier, values, tailwindConfig);
276
- if (result) return [
240
+ for (let match of matches){
241
+ return match;
242
+ }
243
+ return [];
244
+ }
245
+ function* getMatchingTypes(types, rawModifier, options, tailwindConfig) {
246
+ let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
247
+ let [modifier, utilityModifier] = splitUtilityModifier(rawModifier);
248
+ let canUseUtilityModifier = modifiersEnabled && options.modifiers != null && (options.modifiers === "any" || typeof options.modifiers === "object" && (utilityModifier && isArbitraryValue(utilityModifier) || utilityModifier in options.modifiers));
249
+ if (!canUseUtilityModifier) {
250
+ modifier = rawModifier;
251
+ utilityModifier = undefined;
252
+ }
253
+ if (utilityModifier !== undefined && modifier === "") {
254
+ modifier = "DEFAULT";
255
+ }
256
+ // Check the full value first
257
+ // TODO: Move to asValue… somehow
258
+ if (utilityModifier !== undefined) {
259
+ if (typeof options.modifiers === "object") {
260
+ var _options_modifiers;
261
+ var _options_modifiers_utilityModifier;
262
+ let configValue = (_options_modifiers_utilityModifier = (_options_modifiers = options.modifiers) === null || _options_modifiers === void 0 ? void 0 : _options_modifiers[utilityModifier]) !== null && _options_modifiers_utilityModifier !== void 0 ? _options_modifiers_utilityModifier : null;
263
+ if (configValue !== null) {
264
+ utilityModifier = configValue;
265
+ } else if (isArbitraryValue(utilityModifier)) {
266
+ utilityModifier = unwrapArbitraryModifier(utilityModifier);
267
+ }
268
+ }
269
+ }
270
+ for (let { type } of types !== null && types !== void 0 ? types : []){
271
+ let result = typeMap[type](modifier, options, {
272
+ tailwindConfig
273
+ });
274
+ if (result === undefined) {
275
+ continue;
276
+ }
277
+ yield [
277
278
  result,
278
- type
279
+ type,
280
+ utilityModifier !== null && utilityModifier !== void 0 ? utilityModifier : null
279
281
  ];
280
282
  }
281
- return [];
282
283
  }
@@ -2,22 +2,36 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = _default;
6
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
7
- var _tap = require("./tap");
5
+ Object.defineProperty(exports, /**
6
+ * @template {string | import('postcss-selector-parser').Root} T
7
+ *
8
+ * Prefix all classes in the selector with the given prefix
9
+ *
10
+ * It can take either a string or a selector AST and will return the same type
11
+ *
12
+ * @param {string} prefix
13
+ * @param {T} selector
14
+ * @param {boolean} prependNegative
15
+ * @returns {T}
16
+ */ "default", {
17
+ enumerable: true,
18
+ get: ()=>_default
19
+ });
20
+ const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
8
21
  function _interopRequireDefault(obj) {
9
22
  return obj && obj.__esModule ? obj : {
10
23
  default: obj
11
24
  };
12
25
  }
13
- function _default(prefix, selector) {
14
- const getPrefix = typeof prefix === 'function' ? prefix : ()=>prefix === undefined ? '' : prefix
15
- ;
16
- return (0, _postcssSelectorParser).default((selectors)=>{
17
- selectors.walkClasses((classSelector)=>{
18
- (0, _tap).tap(classSelector.value, (baseClass)=>{
19
- classSelector.value = `${getPrefix('.' + baseClass)}${baseClass}`;
20
- });
21
- });
22
- }).processSync(selector);
26
+ function _default(prefix, selector, prependNegative = false) {
27
+ if (prefix === "") {
28
+ return selector;
29
+ }
30
+ let ast = typeof selector === "string" ? (0, _postcssSelectorParser.default)().astSync(selector) : selector;
31
+ ast.walkClasses((classSelector)=>{
32
+ let baseClass = classSelector.value;
33
+ let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
34
+ classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
35
+ });
36
+ return typeof selector === "string" ? ast.toString() : ast;
23
37
  }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * This function removes any uses of CSS variables used as an alpha channel
3
+ *
4
+ * This is required for selectors like `:visited` which do not allow
5
+ * changes in opacity or external control using CSS variables.
6
+ *
7
+ * @param {import('postcss').Container} container
8
+ * @param {string[]} toRemove
9
+ */ "use strict";
10
+ Object.defineProperty(exports, "__esModule", {
11
+ value: true
12
+ });
13
+ Object.defineProperty(exports, "removeAlphaVariables", {
14
+ enumerable: true,
15
+ get: ()=>removeAlphaVariables
16
+ });
17
+ function removeAlphaVariables(container, toRemove) {
18
+ container.walkDecls((decl)=>{
19
+ if (toRemove.includes(decl.prop)) {
20
+ decl.remove();
21
+ return;
22
+ }
23
+ for (let varName of toRemove){
24
+ if (decl.value.includes(`/ var(${varName})`)) {
25
+ decl.value = decl.value.replace(`/ var(${varName})`, "");
26
+ }
27
+ }
28
+ });
29
+ }