tailwindcss 0.0.0-insiders.fda68f7 → 0.0.0-oxide.6bf5e56

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 (195) hide show
  1. package/CHANGELOG.md +603 -2
  2. package/LICENSE +1 -2
  3. package/README.md +14 -6
  4. package/colors.d.ts +3 -0
  5. package/colors.js +2 -304
  6. package/defaultConfig.d.ts +3 -0
  7. package/defaultConfig.js +2 -4
  8. package/defaultTheme.d.ts +4 -0
  9. package/defaultTheme.js +2 -4
  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 +367 -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 +13 -0
  19. package/lib/cli-peer-dependencies.js +22 -14
  20. package/lib/cli.js +217 -743
  21. package/lib/constants.js +41 -34
  22. package/lib/corePluginList.js +178 -5
  23. package/lib/corePlugins.js +3879 -2941
  24. package/lib/css/preflight.css +22 -9
  25. package/lib/featureFlags.js +61 -50
  26. package/lib/index.js +45 -28
  27. package/lib/lib/cacheInvalidation.js +90 -0
  28. package/lib/lib/collapseAdjacentRules.js +52 -36
  29. package/lib/lib/collapseDuplicateDeclarations.js +83 -0
  30. package/lib/lib/content.js +176 -0
  31. package/lib/lib/defaultExtractor.js +236 -0
  32. package/lib/lib/detectNesting.js +37 -0
  33. package/lib/lib/evaluateTailwindFunctions.js +203 -161
  34. package/lib/lib/expandApplyAtRules.js +502 -221
  35. package/lib/lib/expandTailwindAtRules.js +258 -243
  36. package/lib/lib/findAtConfigPath.js +44 -0
  37. package/lib/lib/generateRules.js +775 -320
  38. package/lib/lib/getModuleDependencies.js +44 -46
  39. package/lib/lib/normalizeTailwindDirectives.js +79 -60
  40. package/lib/lib/offsets.js +217 -0
  41. package/lib/lib/partitionApplyAtRules.js +56 -0
  42. package/lib/lib/regex.js +60 -0
  43. package/lib/lib/resolveDefaultsAtRules.js +150 -94
  44. package/lib/lib/setupContextUtils.js +1146 -599
  45. package/lib/lib/setupTrackingContext.js +129 -177
  46. package/lib/lib/sharedState.js +53 -21
  47. package/lib/lib/substituteScreenAtRules.js +26 -28
  48. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  49. package/lib/postcss-plugins/nesting/index.js +19 -0
  50. package/lib/postcss-plugins/nesting/plugin.js +87 -0
  51. package/lib/processTailwindFeatures.js +58 -53
  52. package/lib/public/colors.js +331 -0
  53. package/lib/public/create-plugin.js +15 -0
  54. package/lib/public/default-config.js +16 -0
  55. package/lib/public/default-theme.js +16 -0
  56. package/lib/public/resolve-config.js +22 -0
  57. package/lib/util/bigSign.js +7 -6
  58. package/lib/util/buildMediaQuery.js +21 -32
  59. package/lib/util/cloneDeep.js +16 -14
  60. package/lib/util/cloneNodes.js +29 -15
  61. package/lib/util/color.js +90 -66
  62. package/lib/util/configurePlugins.js +17 -15
  63. package/lib/util/createPlugin.js +23 -26
  64. package/lib/util/createUtilityPlugin.js +46 -46
  65. package/lib/util/dataTypes.js +242 -0
  66. package/lib/util/defaults.js +20 -15
  67. package/lib/util/escapeClassName.js +18 -17
  68. package/lib/util/escapeCommas.js +7 -6
  69. package/lib/util/flattenColorPalette.js +13 -12
  70. package/lib/util/formatVariantSelector.js +285 -0
  71. package/lib/util/getAllConfigs.js +44 -18
  72. package/lib/util/hashConfig.js +15 -12
  73. package/lib/util/isKeyframeRule.js +7 -6
  74. package/lib/util/isPlainObject.js +11 -11
  75. package/lib/util/isSyntacticallyValidPropertyValue.js +72 -0
  76. package/lib/util/log.js +52 -33
  77. package/lib/util/nameClass.js +37 -26
  78. package/lib/util/negateValue.js +31 -17
  79. package/lib/util/normalizeConfig.js +281 -0
  80. package/lib/util/normalizeScreens.js +170 -0
  81. package/lib/util/parseAnimationValue.js +85 -54
  82. package/lib/util/parseBoxShadowValue.js +84 -0
  83. package/lib/util/parseDependency.js +41 -70
  84. package/lib/util/parseGlob.js +34 -0
  85. package/lib/util/parseObjectStyles.js +30 -24
  86. package/lib/util/pluginUtils.js +252 -287
  87. package/lib/util/prefixSelector.js +20 -20
  88. package/lib/util/removeAlphaVariables.js +29 -0
  89. package/lib/util/resolveConfig.js +221 -256
  90. package/lib/util/resolveConfigPath.js +43 -48
  91. package/lib/util/responsive.js +18 -14
  92. package/lib/util/splitAtTopLevelOnly.js +43 -0
  93. package/lib/util/tap.js +8 -7
  94. package/lib/util/toColorValue.js +7 -6
  95. package/lib/util/toPath.js +27 -8
  96. package/lib/util/transformThemeValue.js +67 -28
  97. package/lib/util/validateConfig.js +24 -0
  98. package/lib/util/validateFormalSyntax.js +24 -0
  99. package/lib/util/withAlphaVariable.js +67 -57
  100. package/nesting/index.js +2 -12
  101. package/package.json +60 -65
  102. package/peers/index.js +76445 -84221
  103. package/plugin.d.ts +11 -0
  104. package/plugin.js +1 -2
  105. package/resolveConfig.d.ts +12 -0
  106. package/resolveConfig.js +2 -7
  107. package/scripts/create-plugin-list.js +2 -2
  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 +439 -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 +6 -0
  121. package/src/cli-peer-dependencies.js +7 -1
  122. package/src/cli.js +50 -575
  123. package/src/corePluginList.js +1 -1
  124. package/src/corePlugins.js +2405 -1948
  125. package/src/css/preflight.css +22 -9
  126. package/src/featureFlags.js +26 -10
  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 +212 -0
  132. package/src/lib/defaultExtractor.js +211 -0
  133. package/src/lib/detectNesting.js +39 -0
  134. package/src/lib/evaluateTailwindFunctions.js +84 -10
  135. package/src/lib/expandApplyAtRules.js +508 -153
  136. package/src/lib/expandTailwindAtRules.js +130 -104
  137. package/src/lib/findAtConfigPath.js +48 -0
  138. package/src/lib/generateRules.js +596 -70
  139. package/src/lib/normalizeTailwindDirectives.js +10 -3
  140. package/src/lib/offsets.js +270 -0
  141. package/src/lib/partitionApplyAtRules.js +52 -0
  142. package/src/lib/regex.js +74 -0
  143. package/src/lib/resolveDefaultsAtRules.js +105 -47
  144. package/src/lib/setupContextUtils.js +828 -196
  145. package/src/lib/setupTrackingContext.js +19 -54
  146. package/src/lib/sharedState.js +45 -7
  147. package/src/lib/substituteScreenAtRules.js +6 -3
  148. package/src/postcss-plugins/nesting/README.md +42 -0
  149. package/src/postcss-plugins/nesting/index.js +13 -0
  150. package/src/postcss-plugins/nesting/plugin.js +80 -0
  151. package/src/processTailwindFeatures.js +19 -2
  152. package/src/public/colors.js +300 -0
  153. package/src/public/create-plugin.js +2 -0
  154. package/src/public/default-config.js +4 -0
  155. package/src/public/default-theme.js +4 -0
  156. package/src/public/resolve-config.js +7 -0
  157. package/src/util/buildMediaQuery.js +14 -16
  158. package/src/util/cloneNodes.js +19 -2
  159. package/src/util/color.js +31 -14
  160. package/src/util/createUtilityPlugin.js +2 -11
  161. package/src/util/dataTypes.js +256 -0
  162. package/src/util/defaults.js +6 -0
  163. package/src/util/formatVariantSelector.js +319 -0
  164. package/src/util/getAllConfigs.js +19 -0
  165. package/src/util/isSyntacticallyValidPropertyValue.js +61 -0
  166. package/src/util/log.js +23 -22
  167. package/src/util/nameClass.js +14 -6
  168. package/src/util/negateValue.js +15 -5
  169. package/src/util/normalizeConfig.js +300 -0
  170. package/src/util/normalizeScreens.js +140 -0
  171. package/src/util/parseAnimationValue.js +7 -1
  172. package/src/util/parseBoxShadowValue.js +72 -0
  173. package/src/util/parseDependency.js +37 -38
  174. package/src/util/parseGlob.js +24 -0
  175. package/src/util/pluginUtils.js +216 -197
  176. package/src/util/prefixSelector.js +7 -8
  177. package/src/util/removeAlphaVariables.js +24 -0
  178. package/src/util/resolveConfig.js +86 -91
  179. package/src/util/splitAtTopLevelOnly.js +45 -0
  180. package/src/util/toPath.js +23 -1
  181. package/src/util/transformThemeValue.js +33 -8
  182. package/src/util/validateConfig.js +13 -0
  183. package/src/util/validateFormalSyntax.js +34 -0
  184. package/src/util/withAlphaVariable.js +14 -9
  185. package/stubs/defaultConfig.stub.js +186 -117
  186. package/stubs/simpleConfig.stub.js +1 -1
  187. package/types/config.d.ts +362 -0
  188. package/types/generated/.gitkeep +0 -0
  189. package/types/generated/colors.d.ts +276 -0
  190. package/types/generated/corePluginList.d.ts +1 -0
  191. package/types/generated/default-theme.d.ts +342 -0
  192. package/types/index.d.ts +7 -0
  193. package/lib/lib/setupWatchingContext.js +0 -331
  194. package/nesting/plugin.js +0 -41
  195. package/src/lib/setupWatchingContext.js +0 -306
@@ -1,318 +1,283 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.applyPseudoToMarker = applyPseudoToMarker;
7
- exports.updateAllClasses = updateAllClasses;
8
- exports.updateLastClasses = updateLastClasses;
9
- exports.transformAllSelectors = transformAllSelectors;
10
- exports.transformAllClasses = transformAllClasses;
11
- exports.transformLastClasses = transformLastClasses;
12
- exports.asValue = asValue;
13
- exports.asUnit = asUnit;
14
- exports.asColor = asColor;
15
- exports.asAngle = asAngle;
16
- exports.asLength = asLength;
17
- exports.asLookupValue = asLookupValue;
18
- exports.coerceValue = coerceValue;
19
-
20
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
21
-
22
- var _escapeCommas = _interopRequireDefault(require("./escapeCommas"));
23
-
24
- var _withAlphaVariable = require("./withAlphaVariable");
25
-
26
- var _isKeyframeRule = _interopRequireDefault(require("./isKeyframeRule"));
27
-
28
- var _color = require("./color");
29
-
30
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
-
32
- function applyPseudoToMarker(selector, marker, state, join) {
33
- let states = [state];
34
- let markerIdx = selector.indexOf(marker + ':');
35
-
36
- if (markerIdx !== -1) {
37
- let existingMarker = selector.slice(markerIdx, selector.indexOf(' ', markerIdx));
38
- states = states.concat(selector.slice(markerIdx + marker.length + 1, existingMarker.length).split(':'));
39
- selector = selector.replace(existingMarker, '');
40
- }
41
-
42
- return join(`${[marker, ...states].join(':')}`, selector);
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");
29
+ function _interopRequireDefault(obj) {
30
+ return obj && obj.__esModule ? obj : {
31
+ default: obj
32
+ };
43
33
  }
44
-
45
34
  function updateAllClasses(selectors, updateClass) {
46
- let parser = (0, _postcssSelectorParser.default)(selectors => {
47
- selectors.walkClasses(sel => {
48
- let updatedClass = updateClass(sel.value, {
49
- withPseudo(className, pseudo) {
50
- sel.parent.insertAfter(sel, _postcssSelectorParser.default.pseudo({
51
- value: `${pseudo}`
52
- }));
53
- return className;
54
- }
55
-
56
- });
57
- sel.value = updatedClass;
58
-
59
- if (sel.raws && sel.raws.value) {
60
- sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
61
- }
35
+ let parser = (0, _postcssSelectorParser.default)((selectors)=>{
36
+ selectors.walkClasses((sel)=>{
37
+ let updatedClass = updateClass(sel.value);
38
+ sel.value = updatedClass;
39
+ if (sel.raws && sel.raws.value) {
40
+ sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
41
+ }
42
+ });
62
43
  });
63
- });
64
- let result = parser.processSync(selectors);
65
- return result;
44
+ let result = parser.processSync(selectors);
45
+ return result;
66
46
  }
67
-
68
- function updateLastClasses(selectors, updateClass) {
69
- let parser = (0, _postcssSelectorParser.default)(selectors => {
70
- selectors.each(sel => {
71
- let lastClass = sel.filter(({
72
- type
73
- }) => type === 'class').pop();
74
-
75
- if (lastClass === undefined) {
76
- return;
77
- }
78
-
79
- let updatedClass = updateClass(lastClass.value, {
80
- withPseudo(className, pseudo) {
81
- lastClass.parent.insertAfter(lastClass, _postcssSelectorParser.default.pseudo({
82
- value: `${pseudo}`
83
- }));
84
- return className;
85
- }
86
-
87
- });
88
- lastClass.value = updatedClass;
89
-
90
- if (lastClass.raws && lastClass.raws.value) {
91
- lastClass.raws.value = (0, _escapeCommas.default)(lastClass.raws.value);
92
- }
47
+ function filterSelectorsForClass(selectors, classCandidate) {
48
+ let parser = (0, _postcssSelectorParser.default)((selectors)=>{
49
+ selectors.each((sel)=>{
50
+ const containsClass = sel.nodes.some((node)=>node.type === "class" && node.value === classCandidate);
51
+ if (!containsClass) {
52
+ sel.remove();
53
+ }
54
+ });
93
55
  });
94
- });
95
- let result = parser.processSync(selectors);
96
- return result;
56
+ let result = parser.processSync(selectors);
57
+ return result;
97
58
  }
98
-
99
- function splitByNotEscapedCommas(str) {
100
- let chunks = [];
101
- let currentChunk = '';
102
-
103
- for (let i = 0; i < str.length; i++) {
104
- if (str[i] === ',' && str[i - 1] !== '\\') {
105
- chunks.push(currentChunk);
106
- currentChunk = '';
107
- } else {
108
- currentChunk += str[i];
59
+ function resolveArbitraryValue(modifier, validate) {
60
+ if (!isArbitraryValue(modifier)) {
61
+ return undefined;
109
62
  }
110
- }
111
-
112
- chunks.push(currentChunk);
113
- return chunks;
114
- }
115
-
116
- function transformAllSelectors(transformSelector, {
117
- wrap,
118
- withRule
119
- } = {}) {
120
- return ({
121
- container
122
- }) => {
123
- container.walkRules(rule => {
124
- if ((0, _isKeyframeRule.default)(rule)) {
125
- return rule;
126
- }
127
-
128
- let transformed = splitByNotEscapedCommas(rule.selector).map(transformSelector).join(',');
129
- rule.selector = transformed;
130
-
131
- if (withRule) {
132
- withRule(rule);
133
- }
134
-
135
- return rule;
136
- });
137
-
138
- if (wrap) {
139
- let wrapper = wrap();
140
- let nodes = container.nodes;
141
- container.removeAll();
142
- wrapper.append(nodes);
143
- container.append(wrapper);
63
+ let value = modifier.slice(1, -1);
64
+ if (!validate(value)) {
65
+ return undefined;
144
66
  }
145
- };
67
+ return (0, _dataTypes.normalize)(value);
146
68
  }
147
-
148
- function transformAllClasses(transformClass, {
149
- wrap,
150
- withRule
151
- } = {}) {
152
- return ({
153
- container
154
- }) => {
155
- container.walkRules(rule => {
156
- let selector = rule.selector;
157
- let variantSelector = updateAllClasses(selector, transformClass);
158
- rule.selector = variantSelector;
159
-
160
- if (withRule) {
161
- withRule(rule);
162
- }
163
-
164
- return rule;
165
- });
166
-
167
- if (wrap) {
168
- let wrapper = wrap();
169
- let nodes = container.nodes;
170
- container.removeAll();
171
- wrapper.append(nodes);
172
- container.append(wrapper);
69
+ function asNegativeValue(modifier, lookup = {}, validate) {
70
+ let positiveValue = lookup[modifier];
71
+ if (positiveValue !== undefined) {
72
+ return (0, _negateValue.default)(positiveValue);
173
73
  }
174
- };
175
- }
176
-
177
- function transformLastClasses(transformClass, {
178
- wrap,
179
- withRule
180
- } = {}) {
181
- return ({
182
- container
183
- }) => {
184
- container.walkRules(rule => {
185
- let selector = rule.selector;
186
- let variantSelector = updateLastClasses(selector, transformClass);
187
- rule.selector = variantSelector;
188
-
189
- if (withRule) {
190
- withRule(rule);
191
- }
192
-
193
- return rule;
194
- });
195
-
196
- if (wrap) {
197
- let wrapper = wrap();
198
- let nodes = container.nodes;
199
- container.removeAll();
200
- wrapper.append(nodes);
201
- container.append(wrapper);
74
+ if (isArbitraryValue(modifier)) {
75
+ let resolved = resolveArbitraryValue(modifier, validate);
76
+ if (resolved === undefined) {
77
+ return undefined;
78
+ }
79
+ return (0, _negateValue.default)(resolved);
202
80
  }
203
- };
204
- }
205
-
206
- function asValue(modifier, lookup = {}, {
207
- validate = () => true
208
- } = {}) {
209
- let value = lookup[modifier];
210
-
211
- if (value !== undefined) {
212
- return value;
213
- }
214
-
215
- if (modifier[0] !== '[' || modifier[modifier.length - 1] !== ']') {
216
- return undefined;
217
- }
218
-
219
- value = modifier.slice(1, -1);
220
-
221
- if (!validate(value)) {
222
- return undefined;
223
- } // convert `_` to ` `, escept for escaped underscores `\_`
224
-
225
-
226
- value = value.replace(/([^\\])_/g, '$1 ').replace(/^_/g, ' ').replace(/\\_/g, '_'); // add spaces around operators inside calc() that do not follow an operator or (
227
-
228
- return value.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, '$1 $2 ');
229
81
  }
230
-
231
- function asUnit(modifier, units, lookup = {}) {
232
- return asValue(modifier, lookup, {
233
- validate: value => {
234
- let unitsPattern = `(?:${units.join('|')})`;
235
- return new RegExp(`${unitsPattern}$`).test(value) || new RegExp(`^calc\\(.+?${unitsPattern}`).test(value);
82
+ function asValue(modifier, options = {}, { validate =()=>true } = {}) {
83
+ var ref;
84
+ let value = (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
85
+ if (value !== undefined) {
86
+ return value;
236
87
  }
237
- });
88
+ if (options.supportsNegativeValues && modifier.startsWith("-")) {
89
+ return asNegativeValue(modifier.slice(1), options.values, validate);
90
+ }
91
+ return resolveArbitraryValue(modifier, validate);
238
92
  }
239
-
240
93
  function isArbitraryValue(input) {
241
- return input.startsWith('[') && input.endsWith(']');
94
+ return input.startsWith("[") && input.endsWith("]");
242
95
  }
243
-
244
- function splitAlpha(modifier) {
245
- let slashIdx = modifier.lastIndexOf('/');
246
-
247
- if (slashIdx === -1 || slashIdx === modifier.length - 1) {
248
- return [modifier];
249
- }
250
-
251
- return [modifier.slice(0, slashIdx), modifier.slice(slashIdx + 1)];
96
+ function splitUtilityModifier(modifier) {
97
+ let slashIdx = modifier.lastIndexOf("/");
98
+ if (slashIdx === -1 || slashIdx === modifier.length - 1) {
99
+ return [
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
112
+ ];
113
+ }
114
+ return [
115
+ modifier.slice(0, slashIdx),
116
+ modifier.slice(slashIdx + 1)
117
+ ];
252
118
  }
253
-
254
- function asColor(modifier, lookup = {}, tailwindConfig = {}) {
255
- if (lookup[modifier] !== undefined) {
256
- return lookup[modifier];
257
- }
258
-
259
- let [color, alpha] = splitAlpha(modifier);
260
-
261
- if (lookup[color] !== undefined) {
262
- var _tailwindConfig$theme, _tailwindConfig$theme2;
263
-
264
- if (isArbitraryValue(alpha)) {
265
- return (0, _withAlphaVariable.withAlphaValue)(lookup[color], alpha.slice(1, -1));
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);
266
123
  }
267
-
268
- if (((_tailwindConfig$theme = tailwindConfig.theme) === null || _tailwindConfig$theme === void 0 ? void 0 : (_tailwindConfig$theme2 = _tailwindConfig$theme.opacity) === null || _tailwindConfig$theme2 === void 0 ? void 0 : _tailwindConfig$theme2[alpha]) === undefined) {
269
- return undefined;
124
+ return value;
125
+ }
126
+ function unwrapArbitraryModifier(modifier) {
127
+ modifier = modifier.slice(1, -1);
128
+ if (modifier.startsWith("--")) {
129
+ modifier = `var(${modifier})`;
270
130
  }
271
-
272
- return (0, _withAlphaVariable.withAlphaValue)(lookup[color], tailwindConfig.theme.opacity[alpha]);
273
- }
274
-
275
- return asValue(modifier, lookup, {
276
- validate: value => (0, _color.parseColor)(value) !== null
277
- });
131
+ return modifier;
278
132
  }
279
-
280
- function asAngle(modifier, lookup = {}) {
281
- return asUnit(modifier, ['deg', 'grad', 'rad', 'turn'], lookup);
133
+ function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
134
+ var ref;
135
+ if (((ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier]) !== undefined) {
136
+ var ref1;
137
+ return parseColorFormat((ref1 = options.values) === null || ref1 === void 0 ? void 0 : ref1[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);
142
+ if (alpha !== undefined) {
143
+ var ref2, ref3, ref4;
144
+ var ref5;
145
+ 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;
146
+ if (normalizedColor === undefined) {
147
+ return undefined;
148
+ }
149
+ normalizedColor = parseColorFormat(normalizedColor);
150
+ if (isArbitraryValue(alpha)) {
151
+ return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, unwrapArbitraryModifier(alpha));
152
+ }
153
+ if (((ref3 = tailwindConfig.theme) === null || ref3 === void 0 ? void 0 : (ref4 = ref3.opacity) === null || ref4 === void 0 ? void 0 : ref4[alpha]) === undefined) {
154
+ return undefined;
155
+ }
156
+ return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, tailwindConfig.theme.opacity[alpha]);
157
+ }
158
+ return asValue(modifier, options, {
159
+ validate: _dataTypes.color
160
+ });
282
161
  }
283
-
284
- function asLength(modifier, lookup = {}) {
285
- return asUnit(modifier, ['cm', 'mm', 'Q', 'in', 'pc', 'pt', 'px', 'em', 'ex', 'ch', 'rem', 'lh', 'vw', 'vh', 'vmin', 'vmax', '%'], lookup);
162
+ function asLookupValue(modifier, options = {}) {
163
+ var ref;
164
+ return (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
286
165
  }
287
-
288
- function asLookupValue(modifier, lookup = {}) {
289
- return lookup[modifier];
166
+ function guess(validate) {
167
+ return (modifier, options)=>{
168
+ return asValue(modifier, options, {
169
+ validate
170
+ });
171
+ };
290
172
  }
291
-
292
173
  let typeMap = {
293
- any: asValue,
294
- color: asColor,
295
- angle: asAngle,
296
- length: asLength,
297
- lookup: asLookupValue
174
+ any: asValue,
175
+ color: asColor,
176
+ url: guess(_dataTypes.url),
177
+ image: guess(_dataTypes.image),
178
+ length: guess(_dataTypes.length),
179
+ percentage: guess(_dataTypes.percentage),
180
+ position: guess(_dataTypes.position),
181
+ lookup: asLookupValue,
182
+ "generic-name": guess(_dataTypes.genericName),
183
+ "family-name": guess(_dataTypes.familyName),
184
+ number: guess(_dataTypes.number),
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)
298
190
  };
299
-
191
+ let supportedTypes = Object.keys(typeMap);
300
192
  function splitAtFirst(input, delim) {
301
- return (([first, ...rest]) => [first, rest.join(delim)])(input.split(delim));
193
+ let idx = input.indexOf(delim);
194
+ if (idx === -1) return [
195
+ undefined,
196
+ input
197
+ ];
198
+ return [
199
+ input.slice(0, idx),
200
+ input.slice(idx + 1)
201
+ ];
202
+ }
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
+ }
219
+ if (isArbitraryValue(modifier)) {
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)) {
228
+ return [];
229
+ }
230
+ if (value.length > 0 && supportedTypes.includes(explicitType)) {
231
+ return [
232
+ asValue(`[${value}]`, options),
233
+ explicitType,
234
+ null
235
+ ];
236
+ }
237
+ }
238
+ let matches = getMatchingTypes(types, modifier, options, tailwindConfig);
239
+ // Find first matching type
240
+ for (let match of matches){
241
+ return match;
242
+ }
243
+ return [];
302
244
  }
303
-
304
- function coerceValue(type, modifier, values, tailwindConfig) {
305
- let [scaleType, arbitraryType = scaleType] = [].concat(type);
306
-
307
- if (isArbitraryValue(modifier)) {
308
- let [explicitType, value] = splitAtFirst(modifier.slice(1, -1), ':');
309
-
310
- if (value.length > 0 && Object.keys(typeMap).includes(explicitType)) {
311
- return [asValue(`[${value}]`, values, tailwindConfig), explicitType];
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;
312
252
  }
313
-
314
- return [typeMap[arbitraryType](modifier, values, tailwindConfig), arbitraryType];
315
- }
316
-
317
- return [typeMap[scaleType](modifier, values, tailwindConfig), scaleType];
318
- }
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 ref;
261
+ var ref1;
262
+ let configValue = (ref1 = (ref = options.modifiers) === null || ref === void 0 ? void 0 : ref[utilityModifier]) !== null && ref1 !== void 0 ? ref1 : 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 [
278
+ result,
279
+ type,
280
+ utilityModifier !== null && utilityModifier !== void 0 ? utilityModifier : null
281
+ ];
282
+ }
283
+ }
@@ -1,23 +1,23 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.default = _default;
7
-
8
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
9
-
10
- var _tap = require("./tap");
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- function _default(prefix, selector) {
15
- const getPrefix = typeof prefix === 'function' ? prefix : () => prefix === undefined ? '' : prefix;
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);
23
- }
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>_default
8
+ });
9
+ const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
10
+ function _interopRequireDefault(obj) {
11
+ return obj && obj.__esModule ? obj : {
12
+ default: obj
13
+ };
14
+ }
15
+ function _default(prefix, selector, prependNegative = false) {
16
+ return (0, _postcssSelectorParser.default)((selectors)=>{
17
+ selectors.walkClasses((classSelector)=>{
18
+ let baseClass = classSelector.value;
19
+ let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
20
+ classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
21
+ });
22
+ }).processSync(selector);
23
+ }
@@ -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
+ }