tailwindcss 0.0.0-insiders.f4635e0 → 0.0.0-insiders.f4a2ccd

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 (238) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +15 -7
  3. package/colors.d.ts +3 -0
  4. package/colors.js +2 -304
  5. package/defaultConfig.d.ts +3 -0
  6. package/defaultConfig.js +2 -4
  7. package/defaultTheme.d.ts +4 -0
  8. package/defaultTheme.js +2 -4
  9. package/lib/cli/build/deps.js +54 -0
  10. package/lib/cli/build/index.js +52 -0
  11. package/lib/cli/build/plugin.js +376 -0
  12. package/lib/cli/build/utils.js +78 -0
  13. package/lib/cli/build/watching.js +180 -0
  14. package/lib/cli/help/index.js +71 -0
  15. package/lib/cli/index.js +230 -0
  16. package/lib/cli/init/index.js +61 -0
  17. package/lib/cli-peer-dependencies.js +22 -14
  18. package/lib/cli.js +4 -762
  19. package/lib/corePluginList.js +182 -5
  20. package/lib/corePlugins.js +4109 -2952
  21. package/lib/css/preflight.css +24 -9
  22. package/lib/featureFlags.js +68 -50
  23. package/lib/index.js +5 -30
  24. package/lib/lib/cacheInvalidation.js +90 -0
  25. package/lib/lib/collapseAdjacentRules.js +52 -36
  26. package/lib/lib/collapseDuplicateDeclarations.js +83 -0
  27. package/lib/lib/content.js +177 -0
  28. package/lib/lib/defaultExtractor.js +241 -0
  29. package/lib/lib/detectNesting.js +39 -17
  30. package/lib/lib/evaluateTailwindFunctions.js +203 -161
  31. package/lib/lib/expandApplyAtRules.js +503 -221
  32. package/lib/lib/expandTailwindAtRules.js +255 -243
  33. package/lib/lib/findAtConfigPath.js +44 -0
  34. package/lib/lib/generateRules.js +831 -317
  35. package/lib/lib/getModuleDependencies.js +93 -49
  36. package/lib/lib/load-config.js +36 -0
  37. package/lib/lib/normalizeTailwindDirectives.js +79 -60
  38. package/lib/lib/offsets.js +304 -0
  39. package/lib/lib/partitionApplyAtRules.js +56 -0
  40. package/lib/lib/regex.js +60 -0
  41. package/lib/lib/remap-bitfield.js +87 -0
  42. package/lib/lib/resolveDefaultsAtRules.js +150 -94
  43. package/lib/lib/setupContextUtils.js +1197 -685
  44. package/lib/lib/setupTrackingContext.js +150 -177
  45. package/lib/lib/sharedState.js +70 -21
  46. package/lib/lib/substituteScreenAtRules.js +26 -28
  47. package/lib/oxide/cli/build/deps.js +81 -0
  48. package/lib/oxide/cli/build/index.js +51 -0
  49. package/lib/oxide/cli/build/plugin.js +373 -0
  50. package/lib/oxide/cli/build/utils.js +77 -0
  51. package/lib/oxide/cli/build/watching.js +177 -0
  52. package/lib/oxide/cli/help/index.js +70 -0
  53. package/lib/oxide/cli/index.js +214 -0
  54. package/lib/oxide/cli/init/index.js +50 -0
  55. package/lib/oxide/cli.js +5 -0
  56. package/lib/oxide/postcss-plugin.js +2 -0
  57. package/lib/plugin.js +98 -0
  58. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  59. package/lib/postcss-plugins/nesting/index.js +19 -0
  60. package/lib/postcss-plugins/nesting/plugin.js +87 -0
  61. package/lib/processTailwindFeatures.js +58 -56
  62. package/lib/public/colors.js +353 -0
  63. package/lib/public/create-plugin.js +15 -0
  64. package/lib/public/default-config.js +16 -0
  65. package/lib/public/default-theme.js +16 -0
  66. package/lib/public/load-config.js +10 -0
  67. package/lib/public/resolve-config.js +22 -0
  68. package/lib/util/applyImportantSelector.js +22 -0
  69. package/lib/util/bigSign.js +7 -6
  70. package/lib/util/buildMediaQuery.js +21 -32
  71. package/lib/util/cloneDeep.js +16 -14
  72. package/lib/util/cloneNodes.js +29 -15
  73. package/lib/util/color.js +104 -66
  74. package/lib/util/configurePlugins.js +17 -15
  75. package/lib/util/createPlugin.js +23 -26
  76. package/lib/util/createUtilityPlugin.js +46 -46
  77. package/lib/util/dataTypes.js +266 -0
  78. package/lib/util/defaults.js +20 -15
  79. package/lib/util/escapeClassName.js +18 -17
  80. package/lib/util/escapeCommas.js +7 -6
  81. package/lib/util/flattenColorPalette.js +13 -12
  82. package/lib/util/formatVariantSelector.js +341 -0
  83. package/lib/util/getAllConfigs.js +44 -18
  84. package/lib/util/hashConfig.js +15 -12
  85. package/lib/util/isKeyframeRule.js +7 -6
  86. package/lib/util/isPlainObject.js +11 -11
  87. package/lib/util/isSyntacticallyValidPropertyValue.js +72 -0
  88. package/lib/util/log.js +52 -33
  89. package/lib/util/nameClass.js +35 -29
  90. package/lib/util/negateValue.js +31 -17
  91. package/lib/util/normalizeConfig.js +294 -0
  92. package/lib/util/normalizeScreens.js +170 -0
  93. package/lib/util/parseAnimationValue.js +85 -54
  94. package/lib/util/parseBoxShadowValue.js +84 -0
  95. package/lib/util/parseDependency.js +41 -70
  96. package/lib/util/parseGlob.js +34 -0
  97. package/lib/util/parseObjectStyles.js +30 -24
  98. package/lib/util/pluginUtils.js +234 -288
  99. package/lib/util/prefixSelector.js +33 -19
  100. package/lib/util/removeAlphaVariables.js +29 -0
  101. package/lib/util/resolveConfig.js +221 -256
  102. package/lib/util/resolveConfigPath.js +55 -48
  103. package/lib/util/responsive.js +18 -14
  104. package/lib/util/splitAtTopLevelOnly.js +49 -0
  105. package/lib/util/tap.js +8 -7
  106. package/lib/util/toColorValue.js +7 -6
  107. package/lib/util/toPath.js +27 -8
  108. package/lib/util/transformThemeValue.js +67 -28
  109. package/lib/util/validateConfig.js +24 -0
  110. package/lib/util/validateFormalSyntax.js +24 -0
  111. package/lib/util/withAlphaVariable.js +67 -57
  112. package/loadConfig.d.ts +4 -0
  113. package/loadConfig.js +2 -0
  114. package/nesting/index.js +2 -12
  115. package/package.json +69 -66
  116. package/peers/index.js +76328 -84169
  117. package/plugin.d.ts +11 -0
  118. package/plugin.js +1 -2
  119. package/resolveConfig.d.ts +12 -0
  120. package/resolveConfig.js +2 -7
  121. package/scripts/create-plugin-list.js +2 -2
  122. package/scripts/generate-types.js +105 -0
  123. package/scripts/release-channel.js +18 -0
  124. package/scripts/release-notes.js +21 -0
  125. package/scripts/swap-engines.js +40 -0
  126. package/scripts/type-utils.js +27 -0
  127. package/src/cli/build/deps.js +56 -0
  128. package/src/cli/build/index.js +49 -0
  129. package/src/cli/build/plugin.js +444 -0
  130. package/src/cli/build/utils.js +76 -0
  131. package/src/cli/build/watching.js +229 -0
  132. package/src/cli/help/index.js +70 -0
  133. package/src/cli/index.js +216 -0
  134. package/src/cli/init/index.js +79 -0
  135. package/src/cli-peer-dependencies.js +7 -1
  136. package/src/cli.js +4 -756
  137. package/src/corePluginList.js +1 -1
  138. package/src/corePlugins.js +2526 -1956
  139. package/src/css/preflight.css +24 -9
  140. package/src/featureFlags.js +33 -10
  141. package/src/index.js +4 -33
  142. package/src/lib/cacheInvalidation.js +52 -0
  143. package/src/lib/collapseAdjacentRules.js +21 -2
  144. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  145. package/src/lib/content.js +208 -0
  146. package/src/lib/defaultExtractor.js +217 -0
  147. package/src/lib/detectNesting.js +30 -3
  148. package/src/lib/evaluateTailwindFunctions.js +84 -10
  149. package/src/lib/expandApplyAtRules.js +509 -153
  150. package/src/lib/expandTailwindAtRules.js +125 -104
  151. package/src/lib/findAtConfigPath.js +48 -0
  152. package/src/lib/generateRules.js +678 -70
  153. package/src/lib/getModuleDependencies.js +70 -30
  154. package/src/lib/load-config.ts +27 -0
  155. package/src/lib/normalizeTailwindDirectives.js +10 -3
  156. package/src/lib/offsets.js +373 -0
  157. package/src/lib/partitionApplyAtRules.js +52 -0
  158. package/src/lib/regex.js +74 -0
  159. package/src/lib/remap-bitfield.js +82 -0
  160. package/src/lib/resolveDefaultsAtRules.js +105 -47
  161. package/src/lib/setupContextUtils.js +848 -247
  162. package/src/lib/setupTrackingContext.js +53 -64
  163. package/src/lib/sharedState.js +60 -6
  164. package/src/lib/substituteScreenAtRules.js +6 -3
  165. package/src/oxide/cli/build/deps.ts +91 -0
  166. package/src/oxide/cli/build/index.ts +47 -0
  167. package/src/oxide/cli/build/plugin.ts +442 -0
  168. package/src/oxide/cli/build/utils.ts +74 -0
  169. package/src/oxide/cli/build/watching.ts +225 -0
  170. package/src/oxide/cli/help/index.ts +69 -0
  171. package/src/oxide/cli/index.ts +204 -0
  172. package/src/oxide/cli/init/index.ts +59 -0
  173. package/src/oxide/cli.ts +1 -0
  174. package/src/oxide/postcss-plugin.ts +1 -0
  175. package/src/plugin.js +107 -0
  176. package/src/postcss-plugins/nesting/README.md +42 -0
  177. package/src/postcss-plugins/nesting/index.js +13 -0
  178. package/src/postcss-plugins/nesting/plugin.js +80 -0
  179. package/src/processTailwindFeatures.js +18 -3
  180. package/src/public/colors.js +322 -0
  181. package/src/public/create-plugin.js +2 -0
  182. package/src/public/default-config.js +4 -0
  183. package/src/public/default-theme.js +4 -0
  184. package/src/public/load-config.js +2 -0
  185. package/src/public/resolve-config.js +7 -0
  186. package/src/util/applyImportantSelector.js +19 -0
  187. package/src/util/buildMediaQuery.js +14 -16
  188. package/src/util/cloneNodes.js +19 -2
  189. package/src/util/color.js +43 -11
  190. package/src/util/createUtilityPlugin.js +2 -11
  191. package/src/util/dataTypes.js +281 -0
  192. package/src/util/defaults.js +6 -0
  193. package/src/util/formatVariantSelector.js +412 -0
  194. package/src/util/getAllConfigs.js +21 -2
  195. package/src/util/isSyntacticallyValidPropertyValue.js +61 -0
  196. package/src/util/log.js +23 -22
  197. package/src/util/nameClass.js +6 -2
  198. package/src/util/negateValue.js +15 -5
  199. package/src/util/normalizeConfig.js +318 -0
  200. package/src/util/normalizeScreens.js +140 -0
  201. package/src/util/parseAnimationValue.js +7 -1
  202. package/src/util/parseBoxShadowValue.js +72 -0
  203. package/src/util/parseDependency.js +37 -38
  204. package/src/util/parseGlob.js +24 -0
  205. package/src/util/pluginUtils.js +219 -219
  206. package/src/util/prefixSelector.js +30 -13
  207. package/src/util/removeAlphaVariables.js +24 -0
  208. package/src/util/resolveConfig.js +86 -91
  209. package/src/util/resolveConfigPath.js +12 -1
  210. package/src/util/splitAtTopLevelOnly.js +52 -0
  211. package/src/util/toPath.js +23 -1
  212. package/src/util/transformThemeValue.js +33 -8
  213. package/src/util/validateConfig.js +13 -0
  214. package/src/util/validateFormalSyntax.js +34 -0
  215. package/src/util/withAlphaVariable.js +14 -9
  216. package/stubs/.gitignore +1 -0
  217. package/stubs/.prettierrc.json +6 -0
  218. package/stubs/{defaultConfig.stub.js → config.full.js} +332 -249
  219. package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -1
  220. package/stubs/postcss.config.js +6 -0
  221. package/stubs/tailwind.config.cjs +2 -0
  222. package/stubs/tailwind.config.js +2 -0
  223. package/stubs/tailwind.config.ts +3 -0
  224. package/types/config.d.ts +373 -0
  225. package/types/generated/.gitkeep +0 -0
  226. package/types/generated/colors.d.ts +298 -0
  227. package/types/generated/corePluginList.d.ts +1 -0
  228. package/types/generated/default-theme.d.ts +347 -0
  229. package/types/index.d.ts +7 -0
  230. package/CHANGELOG.md +0 -1742
  231. package/lib/constants.js +0 -37
  232. package/lib/lib/setupWatchingContext.js +0 -331
  233. package/nesting/plugin.js +0 -41
  234. package/scripts/install-integrations.js +0 -27
  235. package/scripts/rebuildFixtures.js +0 -68
  236. package/src/constants.js +0 -17
  237. package/src/lib/setupWatchingContext.js +0 -307
  238. /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
@@ -1,318 +1,264 @@
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);
43
- }
44
-
45
- 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
- }
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
62
9
  });
63
- });
64
- let result = parser.processSync(selectors);
65
- return result;
66
10
  }
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;
11
+ _export(exports, {
12
+ updateAllClasses: ()=>updateAllClasses,
13
+ asValue: ()=>asValue,
14
+ parseColorFormat: ()=>parseColorFormat,
15
+ asColor: ()=>asColor,
16
+ asLookupValue: ()=>asLookupValue,
17
+ typeMap: ()=>typeMap,
18
+ coerceValue: ()=>coerceValue,
19
+ getMatchingTypes: ()=>getMatchingTypes
20
+ });
21
+ const _escapeCommas = /*#__PURE__*/ _interopRequireDefault(require("./escapeCommas"));
22
+ const _withAlphaVariable = require("./withAlphaVariable");
23
+ const _dataTypes = require("./dataTypes");
24
+ const _negateValue = /*#__PURE__*/ _interopRequireDefault(require("./negateValue"));
25
+ const _validateFormalSyntax = require("./validateFormalSyntax");
26
+ const _featureFlagsJs = require("../featureFlags.js");
27
+ function _interopRequireDefault(obj) {
28
+ return obj && obj.__esModule ? obj : {
29
+ default: obj
30
+ };
31
+ }
32
+ function updateAllClasses(selectors, updateClass) {
33
+ selectors.walkClasses((sel)=>{
34
+ sel.value = updateClass(sel.value);
35
+ if (sel.raws && sel.raws.value) {
36
+ sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
85
37
  }
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
- }
93
38
  });
94
- });
95
- let result = parser.processSync(selectors);
96
- return result;
97
39
  }
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];
40
+ function resolveArbitraryValue(modifier, validate) {
41
+ if (!isArbitraryValue(modifier)) {
42
+ return undefined;
109
43
  }
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);
44
+ let value = modifier.slice(1, -1);
45
+ if (!validate(value)) {
46
+ return undefined;
144
47
  }
145
- };
48
+ return (0, _dataTypes.normalize)(value);
146
49
  }
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);
50
+ function asNegativeValue(modifier, lookup = {}, validate) {
51
+ let positiveValue = lookup[modifier];
52
+ if (positiveValue !== undefined) {
53
+ return (0, _negateValue.default)(positiveValue);
173
54
  }
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);
55
+ if (isArbitraryValue(modifier)) {
56
+ let resolved = resolveArbitraryValue(modifier, validate);
57
+ if (resolved === undefined) {
58
+ return undefined;
59
+ }
60
+ return (0, _negateValue.default)(resolved);
202
61
  }
203
- };
204
62
  }
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
- }
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);
63
+ function asValue(modifier, options = {}, { validate =()=>true } = {}) {
64
+ var _options_values;
65
+ let value = (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
66
+ if (value !== undefined) {
67
+ return value;
68
+ }
69
+ if (options.supportsNegativeValues && modifier.startsWith("-")) {
70
+ return asNegativeValue(modifier.slice(1), options.values, validate);
236
71
  }
237
- });
72
+ return resolveArbitraryValue(modifier, validate);
238
73
  }
239
-
240
74
  function isArbitraryValue(input) {
241
- return input.startsWith('[') && input.endsWith(']');
75
+ return input.startsWith("[") && input.endsWith("]");
242
76
  }
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)];
77
+ function splitUtilityModifier(modifier) {
78
+ let slashIdx = modifier.lastIndexOf("/");
79
+ if (slashIdx === -1 || slashIdx === modifier.length - 1) {
80
+ return [
81
+ modifier,
82
+ undefined
83
+ ];
84
+ }
85
+ let arbitrary = isArbitraryValue(modifier);
86
+ // The modifier could be of the form `[foo]/[bar]`
87
+ // We want to handle this case properly
88
+ // without affecting `[foo/bar]`
89
+ if (arbitrary && !modifier.includes("]/[")) {
90
+ return [
91
+ modifier,
92
+ undefined
93
+ ];
94
+ }
95
+ return [
96
+ modifier.slice(0, slashIdx),
97
+ modifier.slice(slashIdx + 1)
98
+ ];
252
99
  }
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));
100
+ function parseColorFormat(value) {
101
+ if (typeof value === "string" && value.includes("<alpha-value>")) {
102
+ let oldValue = value;
103
+ return ({ opacityValue =1 })=>oldValue.replace("<alpha-value>", opacityValue);
266
104
  }
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;
105
+ return value;
106
+ }
107
+ function unwrapArbitraryModifier(modifier) {
108
+ modifier = modifier.slice(1, -1);
109
+ if (modifier.startsWith("--")) {
110
+ modifier = `var(${modifier})`;
270
111
  }
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
- });
112
+ return modifier;
278
113
  }
279
-
280
- function asAngle(modifier, lookup = {}) {
281
- return asUnit(modifier, ['deg', 'grad', 'rad', 'turn'], lookup);
114
+ function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
115
+ var _options_values;
116
+ if (((_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier]) !== undefined) {
117
+ var _options_values1;
118
+ return parseColorFormat((_options_values1 = options.values) === null || _options_values1 === void 0 ? void 0 : _options_values1[modifier]);
119
+ }
120
+ // TODO: Hoist this up to getMatchingTypes or something
121
+ // We do this here because we need the alpha value (if any)
122
+ let [color, alpha] = splitUtilityModifier(modifier);
123
+ if (alpha !== undefined) {
124
+ var _options_values2, _tailwindConfig_theme, _tailwindConfig_theme_opacity;
125
+ var _options_values_color;
126
+ 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;
127
+ if (normalizedColor === undefined) {
128
+ return undefined;
129
+ }
130
+ normalizedColor = parseColorFormat(normalizedColor);
131
+ if (isArbitraryValue(alpha)) {
132
+ return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, unwrapArbitraryModifier(alpha));
133
+ }
134
+ 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) {
135
+ return undefined;
136
+ }
137
+ return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, tailwindConfig.theme.opacity[alpha]);
138
+ }
139
+ return asValue(modifier, options, {
140
+ validate: _dataTypes.color
141
+ });
282
142
  }
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);
143
+ function asLookupValue(modifier, options = {}) {
144
+ var _options_values;
145
+ return (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
286
146
  }
287
-
288
- function asLookupValue(modifier, lookup = {}) {
289
- return lookup[modifier];
147
+ function guess(validate) {
148
+ return (modifier, options)=>{
149
+ return asValue(modifier, options, {
150
+ validate
151
+ });
152
+ };
290
153
  }
291
-
292
154
  let typeMap = {
293
- any: asValue,
294
- color: asColor,
295
- angle: asAngle,
296
- length: asLength,
297
- lookup: asLookupValue
155
+ any: asValue,
156
+ color: asColor,
157
+ url: guess(_dataTypes.url),
158
+ image: guess(_dataTypes.image),
159
+ length: guess(_dataTypes.length),
160
+ percentage: guess(_dataTypes.percentage),
161
+ position: guess(_dataTypes.position),
162
+ lookup: asLookupValue,
163
+ "generic-name": guess(_dataTypes.genericName),
164
+ "family-name": guess(_dataTypes.familyName),
165
+ number: guess(_dataTypes.number),
166
+ "line-width": guess(_dataTypes.lineWidth),
167
+ "absolute-size": guess(_dataTypes.absoluteSize),
168
+ "relative-size": guess(_dataTypes.relativeSize),
169
+ shadow: guess(_dataTypes.shadow),
170
+ size: guess(_validateFormalSyntax.backgroundSize)
298
171
  };
299
-
172
+ let supportedTypes = Object.keys(typeMap);
300
173
  function splitAtFirst(input, delim) {
301
- return (([first, ...rest]) => [first, rest.join(delim)])(input.split(delim));
174
+ let idx = input.indexOf(delim);
175
+ if (idx === -1) return [
176
+ undefined,
177
+ input
178
+ ];
179
+ return [
180
+ input.slice(0, idx),
181
+ input.slice(idx + 1)
182
+ ];
302
183
  }
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];
184
+ function coerceValue(types, modifier, options, tailwindConfig) {
185
+ if (options.values && modifier in options.values) {
186
+ for (let { type } of types !== null && types !== void 0 ? types : []){
187
+ let result = typeMap[type](modifier, options, {
188
+ tailwindConfig
189
+ });
190
+ if (result === undefined) {
191
+ continue;
192
+ }
193
+ return [
194
+ result,
195
+ type,
196
+ null
197
+ ];
198
+ }
199
+ }
200
+ if (isArbitraryValue(modifier)) {
201
+ let arbitraryValue = modifier.slice(1, -1);
202
+ let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
203
+ // It could be that this resolves to `url(https` which is not a valid
204
+ // identifier. We currently only support "simple" words with dashes or
205
+ // underscores. E.g.: family-name
206
+ if (!/^[\w-_]+$/g.test(explicitType)) {
207
+ value = arbitraryValue;
208
+ } else if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
209
+ return [];
210
+ }
211
+ if (value.length > 0 && supportedTypes.includes(explicitType)) {
212
+ return [
213
+ asValue(`[${value}]`, options),
214
+ explicitType,
215
+ null
216
+ ];
217
+ }
312
218
  }
313
-
314
- return [typeMap[arbitraryType](modifier, values, tailwindConfig), arbitraryType];
315
- }
316
-
317
- return [typeMap[scaleType](modifier, values, tailwindConfig), scaleType];
318
- }
219
+ let matches = getMatchingTypes(types, modifier, options, tailwindConfig);
220
+ // Find first matching type
221
+ for (let match of matches){
222
+ return match;
223
+ }
224
+ return [];
225
+ }
226
+ function* getMatchingTypes(types, rawModifier, options, tailwindConfig) {
227
+ let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
228
+ let [modifier, utilityModifier] = splitUtilityModifier(rawModifier);
229
+ let canUseUtilityModifier = modifiersEnabled && options.modifiers != null && (options.modifiers === "any" || typeof options.modifiers === "object" && (utilityModifier && isArbitraryValue(utilityModifier) || utilityModifier in options.modifiers));
230
+ if (!canUseUtilityModifier) {
231
+ modifier = rawModifier;
232
+ utilityModifier = undefined;
233
+ }
234
+ if (utilityModifier !== undefined && modifier === "") {
235
+ modifier = "DEFAULT";
236
+ }
237
+ // Check the full value first
238
+ // TODO: Move to asValue… somehow
239
+ if (utilityModifier !== undefined) {
240
+ if (typeof options.modifiers === "object") {
241
+ var _options_modifiers;
242
+ var _options_modifiers_utilityModifier;
243
+ 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;
244
+ if (configValue !== null) {
245
+ utilityModifier = configValue;
246
+ } else if (isArbitraryValue(utilityModifier)) {
247
+ utilityModifier = unwrapArbitraryModifier(utilityModifier);
248
+ }
249
+ }
250
+ }
251
+ for (let { type } of types !== null && types !== void 0 ? types : []){
252
+ let result = typeMap[type](modifier, options, {
253
+ tailwindConfig
254
+ });
255
+ if (result === undefined) {
256
+ continue;
257
+ }
258
+ yield [
259
+ result,
260
+ type,
261
+ utilityModifier !== null && utilityModifier !== void 0 ? utilityModifier : null
262
+ ];
263
+ }
264
+ }
@@ -1,23 +1,37 @@
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
- });
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"));
21
+ function _interopRequireDefault(obj) {
22
+ return obj && obj.__esModule ? obj : {
23
+ default: obj
24
+ };
25
+ }
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}`;
21
35
  });
22
- }).processSync(selector);
23
- }
36
+ return typeof selector === "string" ? ast.toString() : ast;
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
+ }