tailwindcss 3.2.4 → 3.2.5

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 (100) hide show
  1. package/CHANGELOG.md +44 -1
  2. package/README.md +1 -1
  3. package/lib/cli/build/index.js +5 -1
  4. package/lib/cli/build/plugin.js +39 -34
  5. package/lib/cli/index.js +231 -10
  6. package/lib/cli/init/index.js +2 -2
  7. package/lib/cli.js +4 -226
  8. package/lib/corePlugins.js +45 -27
  9. package/lib/featureFlags.js +8 -8
  10. package/lib/index.js +4 -46
  11. package/lib/lib/collapseAdjacentRules.js +2 -2
  12. package/lib/lib/collapseDuplicateDeclarations.js +2 -2
  13. package/lib/lib/content.js +16 -16
  14. package/lib/lib/defaultExtractor.js +10 -5
  15. package/lib/lib/detectNesting.js +7 -1
  16. package/lib/lib/evaluateTailwindFunctions.js +4 -4
  17. package/lib/lib/expandApplyAtRules.js +2 -2
  18. package/lib/lib/expandTailwindAtRules.js +35 -9
  19. package/lib/lib/findAtConfigPath.js +3 -3
  20. package/lib/lib/generateRules.js +105 -50
  21. package/lib/lib/offsets.js +88 -1
  22. package/lib/lib/remap-bitfield.js +87 -0
  23. package/lib/lib/resolveDefaultsAtRules.js +4 -4
  24. package/lib/lib/setupContextUtils.js +121 -80
  25. package/lib/lib/setupTrackingContext.js +25 -4
  26. package/lib/lib/sharedState.js +19 -1
  27. package/lib/oxide/cli/build/deps.js +81 -0
  28. package/lib/oxide/cli/build/index.js +47 -0
  29. package/lib/oxide/cli/build/plugin.js +364 -0
  30. package/lib/oxide/cli/build/utils.js +77 -0
  31. package/lib/oxide/cli/build/watching.js +177 -0
  32. package/lib/oxide/cli/help/index.js +70 -0
  33. package/lib/oxide/cli/index.js +220 -0
  34. package/lib/oxide/cli/init/index.js +35 -0
  35. package/lib/oxide/cli.js +5 -0
  36. package/lib/oxide/postcss-plugin.js +2 -0
  37. package/lib/plugin.js +98 -0
  38. package/lib/postcss-plugins/nesting/plugin.js +2 -2
  39. package/lib/util/cloneNodes.js +2 -2
  40. package/lib/util/color.js +20 -6
  41. package/lib/util/createUtilityPlugin.js +2 -2
  42. package/lib/util/dataTypes.js +26 -2
  43. package/lib/util/defaults.js +4 -4
  44. package/lib/util/escapeClassName.js +3 -3
  45. package/lib/util/formatVariantSelector.js +171 -105
  46. package/lib/util/getAllConfigs.js +2 -2
  47. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +2 -2
  48. package/lib/util/negateValue.js +2 -2
  49. package/lib/util/normalizeConfig.js +22 -22
  50. package/lib/util/pluginUtils.js +38 -40
  51. package/lib/util/prefixSelector.js +22 -8
  52. package/lib/util/resolveConfig.js +8 -10
  53. package/oxide-node-api-shim/index.js +21 -0
  54. package/oxide-node-api-shim/package.json +5 -0
  55. package/package.json +32 -19
  56. package/peers/index.js +61 -42
  57. package/resolveConfig.d.ts +11 -2
  58. package/scripts/swap-engines.js +40 -0
  59. package/src/cli/build/index.js +6 -2
  60. package/src/cli/build/plugin.js +14 -9
  61. package/src/cli/index.js +234 -3
  62. package/src/cli.js +4 -220
  63. package/src/corePlugins.js +31 -3
  64. package/src/index.js +4 -46
  65. package/src/lib/content.js +12 -17
  66. package/src/lib/defaultExtractor.js +9 -3
  67. package/src/lib/detectNesting.js +9 -1
  68. package/src/lib/expandTailwindAtRules.js +37 -6
  69. package/src/lib/generateRules.js +90 -28
  70. package/src/lib/offsets.js +104 -1
  71. package/src/lib/remap-bitfield.js +82 -0
  72. package/src/lib/setupContextUtils.js +97 -55
  73. package/src/lib/setupTrackingContext.js +31 -6
  74. package/src/lib/sharedState.js +17 -0
  75. package/src/oxide/cli/build/deps.ts +91 -0
  76. package/src/oxide/cli/build/index.ts +47 -0
  77. package/src/oxide/cli/build/plugin.ts +436 -0
  78. package/src/oxide/cli/build/utils.ts +74 -0
  79. package/src/oxide/cli/build/watching.ts +225 -0
  80. package/src/oxide/cli/help/index.ts +69 -0
  81. package/src/oxide/cli/index.ts +212 -0
  82. package/src/oxide/cli/init/index.ts +32 -0
  83. package/src/oxide/cli.ts +1 -0
  84. package/src/oxide/postcss-plugin.ts +1 -0
  85. package/src/plugin.js +107 -0
  86. package/src/util/color.js +17 -2
  87. package/src/util/dataTypes.js +29 -4
  88. package/src/util/formatVariantSelector.js +215 -122
  89. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  90. package/src/util/negateValue.js +1 -1
  91. package/src/util/pluginUtils.js +22 -19
  92. package/src/util/prefixSelector.js +28 -10
  93. package/src/util/resolveConfig.js +0 -2
  94. package/stubs/defaultConfig.stub.js +149 -165
  95. package/types/config.d.ts +7 -2
  96. package/types/generated/default-theme.d.ts +77 -77
  97. package/lib/cli/shared.js +0 -12
  98. package/scripts/install-integrations.js +0 -27
  99. package/scripts/rebuildFixtures.js +0 -68
  100. package/src/cli/shared.js +0 -5
@@ -9,9 +9,9 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- selectorFunctions: ()=>selectorFunctions,
13
12
  formatVariantSelector: ()=>formatVariantSelector,
14
- finalizeSelector: ()=>finalizeSelector
13
+ finalizeSelector: ()=>finalizeSelector,
14
+ handleMergePseudo: ()=>handleMergePseudo
15
15
  });
16
16
  const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
17
17
  const _unesc = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser/dist/util/unesc"));
@@ -22,28 +22,39 @@ function _interopRequireDefault(obj) {
22
22
  default: obj
23
23
  };
24
24
  }
25
- var ref;
26
- let MERGE = ":merge";
27
- let PARENT = "&";
28
- let selectorFunctions = new Set([
29
- MERGE
30
- ]);
31
- function formatVariantSelector(current, ...others) {
32
- for (let other of others){
33
- let incomingValue = resolveFunctionArgument(other, MERGE);
34
- if (incomingValue !== null) {
35
- let existingValue = resolveFunctionArgument(current, MERGE, incomingValue);
36
- if (existingValue !== null) {
37
- let existingTarget = `${MERGE}(${incomingValue})`;
38
- let splitIdx = other.indexOf(existingTarget);
39
- let addition = other.slice(splitIdx + existingTarget.length).split(" ")[0];
40
- current = current.replace(existingTarget, existingTarget + addition);
41
- continue;
42
- }
43
- }
44
- current = other.replace(PARENT, current);
25
+ /** @typedef {import('postcss-selector-parser').Root} Root */ /** @typedef {import('postcss-selector-parser').Selector} Selector */ /** @typedef {import('postcss-selector-parser').Pseudo} Pseudo */ /** @typedef {import('postcss-selector-parser').Node} Node */ /** @typedef {{format: string, isArbitraryVariant: boolean}[]} RawFormats */ /** @typedef {import('postcss-selector-parser').Root} ParsedFormats */ /** @typedef {RawFormats | ParsedFormats} AcceptedFormats */ let MERGE = ":merge";
26
+ function formatVariantSelector(formats, { context , candidate }) {
27
+ var _context_tailwindConfig_prefix;
28
+ let prefix = (_context_tailwindConfig_prefix = context === null || context === void 0 ? void 0 : context.tailwindConfig.prefix) !== null && _context_tailwindConfig_prefix !== void 0 ? _context_tailwindConfig_prefix : "";
29
+ // Parse the format selector into an AST
30
+ let parsedFormats = formats.map((format)=>{
31
+ let ast = (0, _postcssSelectorParser.default)().astSync(format.format);
32
+ return {
33
+ ...format,
34
+ ast: format.isArbitraryVariant ? ast : (0, _prefixSelector.default)(prefix, ast)
35
+ };
36
+ });
37
+ // We start with the candidate selector
38
+ let formatAst = _postcssSelectorParser.default.root({
39
+ nodes: [
40
+ _postcssSelectorParser.default.selector({
41
+ nodes: [
42
+ _postcssSelectorParser.default.className({
43
+ value: (0, _escapeClassName.default)(candidate)
44
+ })
45
+ ]
46
+ })
47
+ ]
48
+ });
49
+ // And iteratively merge each format selector into the candidate selector
50
+ for (let { ast } of parsedFormats){
51
+ [formatAst, ast] = handleMergePseudo(formatAst, ast);
52
+ // 2. Merge the format selector into the current selector AST
53
+ ast.walkNesting((nesting)=>nesting.replaceWith(...formatAst.nodes[0].nodes));
54
+ // 3. Keep going!
55
+ formatAst = ast;
45
56
  }
46
- return current;
57
+ return formatAst;
47
58
  }
48
59
  /**
49
60
  * Given any node in a selector this gets the "simple" selector it's a part of
@@ -51,10 +62,10 @@ function formatVariantSelector(current, ...others) {
51
62
  * Technically :is(), :not(), :has(), etc… can have combinators but those are nested
52
63
  * inside the relevant node and won't be picked up so they're fine to ignore
53
64
  *
54
- * @param {import('postcss-selector-parser').Node} node
55
- * @returns {import('postcss-selector-parser').Node[]}
65
+ * @param {Node} node
66
+ * @returns {Node[]}
56
67
  **/ function simpleSelectorForNode(node) {
57
- /** @type {import('postcss-selector-parser').Node[]} */ let nodes = [];
68
+ /** @type {Node[]} */ let nodes = [];
58
69
  // Walk backwards until we hit a combinator node (or the start)
59
70
  while(node.prev() && node.prev().type !== "combinator"){
60
71
  node = node.prev();
@@ -70,8 +81,8 @@ function formatVariantSelector(current, ...others) {
70
81
  * Resorts the nodes in a selector to ensure they're in the correct order
71
82
  * Tags go before classes, and pseudo classes go after classes
72
83
  *
73
- * @param {import('postcss-selector-parser').Selector} sel
74
- * @returns {import('postcss-selector-parser').Selector}
84
+ * @param {Selector} sel
85
+ * @returns {Selector}
75
86
  **/ function resortSelector(sel) {
76
87
  sel.sort((a, b)=>{
77
88
  if (a.type === "tag" && b.type === "class") {
@@ -87,7 +98,18 @@ function formatVariantSelector(current, ...others) {
87
98
  });
88
99
  return sel;
89
100
  }
90
- function eliminateIrrelevantSelectors(sel, base) {
101
+ /**
102
+ * Remove extraneous selectors that do not include the base class/candidate
103
+ *
104
+ * Example:
105
+ * Given the utility `.a, .b { color: red}`
106
+ * Given the candidate `sm:b`
107
+ *
108
+ * The final selector should be `.sm\:b` and not `.a, .sm\:b`
109
+ *
110
+ * @param {Selector} ast
111
+ * @param {string} base
112
+ */ function eliminateIrrelevantSelectors(sel, base) {
91
113
  let hasClassesMatchingCandidate = false;
92
114
  sel.walk((child)=>{
93
115
  if (child.type === "class" && child.value === base) {
@@ -106,27 +128,20 @@ function eliminateIrrelevantSelectors(sel, base) {
106
128
  // meaning of the selector.
107
129
  // TODO: Can we do this for :matches, :is, and :where?
108
130
  }
109
- var ref1;
110
- function finalizeSelector(format, { selector , candidate , context , isArbitraryVariant , // Split by the separator, but ignore the separator inside square brackets:
111
- //
112
- // E.g.: dark:lg:hover:[paint-order:markers]
113
- // ┬ ┬ ┬ ┬
114
- // │ │ │ ╰── We will not split here
115
- // ╰──┴─────┴─────────────── We will split here
116
- //
117
- base =candidate.split(new RegExp(`\\${(ref1 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref1 !== void 0 ? ref1 : ":"}(?![^[]*\\])`)).pop() }) {
118
- var ref2;
119
- let ast = (0, _postcssSelectorParser.default)().astSync(selector);
120
- // We explicitly DO NOT prefix classes in arbitrary variants
121
- if ((context === null || context === void 0 ? void 0 : (ref2 = context.tailwindConfig) === null || ref2 === void 0 ? void 0 : ref2.prefix) && !isArbitraryVariant) {
122
- format = (0, _prefixSelector.default)(context.tailwindConfig.prefix, format);
123
- }
124
- format = format.replace(PARENT, `.${(0, _escapeClassName.default)(candidate)}`);
125
- let formatAst = (0, _postcssSelectorParser.default)().astSync(format);
126
- // Remove extraneous selectors that do not include the base class/candidate being matched against
127
- // For example if we have a utility defined `.a, .b { color: red}`
128
- // And the formatted variant is sm:b then we want the final selector to be `.sm\:b` and not `.a, .sm\:b`
129
- ast.each((sel)=>eliminateIrrelevantSelectors(sel, base));
131
+ function finalizeSelector(current, formats, { context , candidate , base }) {
132
+ var _context_tailwindConfig;
133
+ var _context_tailwindConfig_separator;
134
+ let separator = (_context_tailwindConfig_separator = context === null || context === void 0 ? void 0 : (_context_tailwindConfig = context.tailwindConfig) === null || _context_tailwindConfig === void 0 ? void 0 : _context_tailwindConfig.separator) !== null && _context_tailwindConfig_separator !== void 0 ? _context_tailwindConfig_separator : ":";
135
+ // Split by the separator, but ignore the separator inside square brackets:
136
+ //
137
+ // E.g.: dark:lg:hover:[paint-order:markers]
138
+ // ┬ ┬ ┬ ┬
139
+ // │ │ │ ╰── We will not split here
140
+ // ╰──┴─────┴─────────────── We will split here
141
+ //
142
+ base = base !== null && base !== void 0 ? base : candidate.split(new RegExp(`\\${separator}(?![^[]*\\])`)).pop();
143
+ // Parse the selector into an AST
144
+ let selector = (0, _postcssSelectorParser.default)().astSync(current);
130
145
  // Normalize escaped classes, e.g.:
131
146
  //
132
147
  // The idea would be to replace the escaped `base` in the selector with the
@@ -138,11 +153,22 @@ base =candidate.split(new RegExp(`\\${(ref1 = context === null || context === vo
138
153
  // base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
139
154
  // escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
140
155
  //
141
- ast.walkClasses((node)=>{
156
+ selector.walkClasses((node)=>{
142
157
  if (node.raws && node.value.includes(base)) {
143
158
  node.raws.value = (0, _escapeClassName.default)((0, _unesc.default)(node.raws.value));
144
159
  }
145
160
  });
161
+ // Remove extraneous selectors that do not include the base candidate
162
+ selector.each((sel)=>eliminateIrrelevantSelectors(sel, base));
163
+ // If there are no formats that means there were no variants added to the candidate
164
+ // so we can just return the selector as-is
165
+ let formatAst = Array.isArray(formats) ? formatVariantSelector(formats, {
166
+ context,
167
+ candidate
168
+ }) : formats;
169
+ if (formatAst === null) {
170
+ return selector.toString();
171
+ }
146
172
  let simpleStart = _postcssSelectorParser.default.comment({
147
173
  value: "/*__simple__*/"
148
174
  });
@@ -151,7 +177,7 @@ base =candidate.split(new RegExp(`\\${(ref1 = context === null || context === vo
151
177
  });
152
178
  // We can safely replace the escaped base now, since the `base` section is
153
179
  // now in a normalized escaped value.
154
- ast.walkClasses((node)=>{
180
+ selector.walkClasses((node)=>{
155
181
  if (node.value !== base) {
156
182
  return;
157
183
  }
@@ -166,7 +192,7 @@ base =candidate.split(new RegExp(`\\${(ref1 = context === null || context === vo
166
192
  parent.insertBefore(simpleSelector[0], simpleStart);
167
193
  parent.insertAfter(simpleSelector[simpleSelector.length - 1], simpleEnd);
168
194
  for (let child of formatNodes){
169
- parent.insertBefore(simpleSelector[0], child);
195
+ parent.insertBefore(simpleSelector[0], child.clone());
170
196
  }
171
197
  node.remove();
172
198
  // Re-sort the simple selector to ensure it's in the correct order
@@ -178,41 +204,68 @@ base =candidate.split(new RegExp(`\\${(ref1 = context === null || context === vo
178
204
  simpleStart.remove();
179
205
  simpleEnd.remove();
180
206
  });
181
- // This will make sure to move pseudo's to the correct spot (the end for
182
- // pseudo elements) because otherwise the selector will never work
183
- // anyway.
184
- //
185
- // E.g.:
186
- // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
187
- // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
188
- //
189
- // `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
190
- function collectPseudoElements(selector) {
191
- let nodes = [];
192
- for (let node of selector.nodes){
193
- if (isPseudoElement(node)) {
194
- nodes.push(node);
195
- selector.removeChild(node);
196
- }
197
- if (node === null || node === void 0 ? void 0 : node.nodes) {
198
- nodes.push(...collectPseudoElements(node));
199
- }
200
- }
201
- return nodes;
202
- }
203
207
  // Remove unnecessary pseudo selectors that we used as placeholders
204
- ast.each((selector)=>{
205
- selector.walkPseudos((p)=>{
206
- if (selectorFunctions.has(p.value)) {
207
- p.replaceWith(p.nodes);
208
- }
209
- });
210
- let pseudoElements = collectPseudoElements(selector);
208
+ selector.walkPseudos((p)=>{
209
+ if (p.value === MERGE) {
210
+ p.replaceWith(p.nodes);
211
+ }
212
+ });
213
+ // Move pseudo elements to the end of the selector (if necessary)
214
+ selector.each((sel)=>{
215
+ let pseudoElements = collectPseudoElements(sel);
211
216
  if (pseudoElements.length > 0) {
212
- selector.nodes.push(pseudoElements.sort(sortSelector));
217
+ sel.nodes.push(pseudoElements.sort(sortSelector));
213
218
  }
214
219
  });
215
- return ast.toString();
220
+ return selector.toString();
221
+ }
222
+ function handleMergePseudo(selector, format) {
223
+ /** @type {{pseudo: Pseudo, value: string}[]} */ let merges = [];
224
+ // Find all :merge() pseudo-classes in `selector`
225
+ selector.walkPseudos((pseudo)=>{
226
+ if (pseudo.value === MERGE) {
227
+ merges.push({
228
+ pseudo,
229
+ value: pseudo.nodes[0].toString()
230
+ });
231
+ }
232
+ });
233
+ // Find all :merge() "attachments" in `format` and attach them to the matching selector in `selector`
234
+ format.walkPseudos((pseudo)=>{
235
+ if (pseudo.value !== MERGE) {
236
+ return;
237
+ }
238
+ let value = pseudo.nodes[0].toString();
239
+ // Does `selector` contain a :merge() pseudo-class with the same value?
240
+ let existing = merges.find((merge)=>merge.value === value);
241
+ // Nope so there's nothing to do
242
+ if (!existing) {
243
+ return;
244
+ }
245
+ // Everything after `:merge()` up to the next combinator is what is attached to the merged selector
246
+ let attachments = [];
247
+ let next = pseudo.next();
248
+ while(next && next.type !== "combinator"){
249
+ attachments.push(next);
250
+ next = next.next();
251
+ }
252
+ let combinator = next;
253
+ existing.pseudo.parent.insertAfter(existing.pseudo, _postcssSelectorParser.default.selector({
254
+ nodes: attachments.map((node)=>node.clone())
255
+ }));
256
+ pseudo.remove();
257
+ attachments.forEach((node)=>node.remove());
258
+ // What about this case:
259
+ // :merge(.group):focus > &
260
+ // :merge(.group):hover &
261
+ if (combinator && combinator.type === "combinator") {
262
+ combinator.remove();
263
+ }
264
+ });
265
+ return [
266
+ selector,
267
+ format
268
+ ];
216
269
  }
217
270
  // Note: As a rule, double colons (::) should be used instead of a single colon
218
271
  // (:). This distinguishes pseudo-classes from pseudo-elements. However, since
@@ -226,8 +279,41 @@ let pseudoElementsBC = [
226
279
  ];
227
280
  // These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
228
281
  let pseudoElementExceptions = [
229
- "::file-selector-button"
282
+ "::file-selector-button",
283
+ // Webkit scroll bar pseudo elements can be combined with user-action pseudo classes
284
+ "::-webkit-scrollbar",
285
+ "::-webkit-scrollbar-button",
286
+ "::-webkit-scrollbar-thumb",
287
+ "::-webkit-scrollbar-track",
288
+ "::-webkit-scrollbar-track-piece",
289
+ "::-webkit-scrollbar-corner",
290
+ "::-webkit-resizer"
230
291
  ];
292
+ /**
293
+ * This will make sure to move pseudo's to the correct spot (the end for
294
+ * pseudo elements) because otherwise the selector will never work
295
+ * anyway.
296
+ *
297
+ * E.g.:
298
+ * - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
299
+ * - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
300
+ *
301
+ * `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
302
+ *
303
+ * @param {Selector} selector
304
+ **/ function collectPseudoElements(selector) {
305
+ /** @type {Node[]} */ let nodes = [];
306
+ for (let node of selector.nodes){
307
+ if (isPseudoElement(node)) {
308
+ nodes.push(node);
309
+ selector.removeChild(node);
310
+ }
311
+ if (node === null || node === void 0 ? void 0 : node.nodes) {
312
+ nodes.push(...collectPseudoElements(node));
313
+ }
314
+ }
315
+ return nodes;
316
+ }
231
317
  // This will make sure to move pseudo's to the correct spot (the end for
232
318
  // pseudo elements) because otherwise the selector will never work
233
319
  // anyway.
@@ -263,23 +349,3 @@ function isPseudoElement(node) {
263
349
  if (pseudoElementExceptions.includes(node.value)) return false;
264
350
  return node.value.startsWith("::") || pseudoElementsBC.includes(node.value);
265
351
  }
266
- function resolveFunctionArgument(haystack, needle, arg) {
267
- let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle);
268
- if (startIdx === -1) return null;
269
- // Start inside the `(`
270
- startIdx += needle.length + 1;
271
- let target = "";
272
- let count = 0;
273
- for (let char of haystack.slice(startIdx)){
274
- if (char !== "(" && char !== ")") {
275
- target += char;
276
- } else if (char === "(") {
277
- target += char;
278
- count++;
279
- } else if (char === ")") {
280
- if (--count < 0) break; // unbalanced
281
- target += char;
282
- }
283
- }
284
- return target;
285
- }
@@ -14,8 +14,8 @@ function _interopRequireDefault(obj) {
14
14
  };
15
15
  }
16
16
  function getAllConfigs(config) {
17
- var ref;
18
- const configs = ((ref = config === null || config === void 0 ? void 0 : config.presets) !== null && ref !== void 0 ? ref : [
17
+ var _config_presets;
18
+ const configs = ((_config_presets = config === null || config === void 0 ? void 0 : config.presets) !== null && _config_presets !== void 0 ? _config_presets : [
19
19
  _defaultConfigStubJs.default
20
20
  ]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset));
21
21
  const features = {
@@ -10,7 +10,7 @@ Object.defineProperty(exports, // Arbitrary values must contain balanced bracket
10
10
  // E.g.: content-['this-is-also-valid]-weirdly-enough']
11
11
  "default", {
12
12
  enumerable: true,
13
- get: ()=>isValidArbitraryValue
13
+ get: ()=>isSyntacticallyValidPropertyValue
14
14
  });
15
15
  let matchingBrackets = new Map([
16
16
  [
@@ -35,7 +35,7 @@ let quotes = new Set([
35
35
  "'",
36
36
  "`"
37
37
  ]);
38
- function isValidArbitraryValue(value) {
38
+ function isSyntacticallyValidPropertyValue(value) {
39
39
  let stack = [];
40
40
  let inQuotes = false;
41
41
  for(let i = 0; i < value.length; i++){
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "default", {
6
6
  enumerable: true,
7
- get: ()=>_default
7
+ get: ()=>negateValue
8
8
  });
9
- function _default(value) {
9
+ function negateValue(value) {
10
10
  value = `${value}`;
11
11
  if (value === "0") {
12
12
  return "0";
@@ -154,12 +154,12 @@ function normalizeConfig(config) {
154
154
  }
155
155
  // Normalize the `safelist`
156
156
  config.safelist = (()=>{
157
- var ref;
157
+ var _purge_options;
158
158
  let { content , purge , safelist } = config;
159
159
  if (Array.isArray(safelist)) return safelist;
160
160
  if (Array.isArray(content === null || content === void 0 ? void 0 : content.safelist)) return content.safelist;
161
161
  if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.safelist)) return purge.safelist;
162
- if (Array.isArray(purge === null || purge === void 0 ? void 0 : (ref = purge.options) === null || ref === void 0 ? void 0 : ref.safelist)) return purge.options.safelist;
162
+ if (Array.isArray(purge === null || purge === void 0 ? void 0 : (_purge_options = purge.options) === null || _purge_options === void 0 ? void 0 : _purge_options.safelist)) return purge.options.safelist;
163
163
  return [];
164
164
  })();
165
165
  // Normalize the `blocklist`
@@ -185,19 +185,19 @@ function normalizeConfig(config) {
185
185
  ]);
186
186
  config.prefix = "";
187
187
  } else {
188
- var _prefix;
189
- config.prefix = (_prefix = config.prefix) !== null && _prefix !== void 0 ? _prefix : "";
188
+ var _config_prefix;
189
+ config.prefix = (_config_prefix = config.prefix) !== null && _config_prefix !== void 0 ? _config_prefix : "";
190
190
  }
191
191
  // Normalize the `content`
192
192
  config.content = {
193
193
  relative: (()=>{
194
- var ref;
194
+ var _config_future;
195
195
  let { content } = config;
196
196
  if (content === null || content === void 0 ? void 0 : content.relative) {
197
197
  return content.relative;
198
198
  }
199
- var ref1;
200
- return (ref1 = (ref = config.future) === null || ref === void 0 ? void 0 : ref.relativeContentPathsByDefault) !== null && ref1 !== void 0 ? ref1 : false;
199
+ var _config_future_relativeContentPathsByDefault;
200
+ return (_config_future_relativeContentPathsByDefault = (_config_future = config.future) === null || _config_future === void 0 ? void 0 : _config_future.relativeContentPathsByDefault) !== null && _config_future_relativeContentPathsByDefault !== void 0 ? _config_future_relativeContentPathsByDefault : false;
201
201
  })(),
202
202
  files: (()=>{
203
203
  let { content , purge } = config;
@@ -210,22 +210,22 @@ function normalizeConfig(config) {
210
210
  })(),
211
211
  extract: (()=>{
212
212
  let extract = (()=>{
213
- var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9;
214
- if ((ref = config.purge) === null || ref === void 0 ? void 0 : ref.extract) return config.purge.extract;
215
- if ((ref1 = config.content) === null || ref1 === void 0 ? void 0 : ref1.extract) return config.content.extract;
216
- if ((ref2 = config.purge) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.extract) === null || ref3 === void 0 ? void 0 : ref3.DEFAULT) return config.purge.extract.DEFAULT;
217
- if ((ref4 = config.content) === null || ref4 === void 0 ? void 0 : (ref5 = ref4.extract) === null || ref5 === void 0 ? void 0 : ref5.DEFAULT) return config.content.extract.DEFAULT;
218
- if ((ref6 = config.purge) === null || ref6 === void 0 ? void 0 : (ref7 = ref6.options) === null || ref7 === void 0 ? void 0 : ref7.extractors) return config.purge.options.extractors;
219
- if ((ref8 = config.content) === null || ref8 === void 0 ? void 0 : (ref9 = ref8.options) === null || ref9 === void 0 ? void 0 : ref9.extractors) return config.content.options.extractors;
213
+ var _config_purge, _config_content, _config_purge1, _config_purge_extract, _config_content1, _config_content_extract, _config_purge2, _config_purge_options, _config_content2, _config_content_options;
214
+ if ((_config_purge = config.purge) === null || _config_purge === void 0 ? void 0 : _config_purge.extract) return config.purge.extract;
215
+ if ((_config_content = config.content) === null || _config_content === void 0 ? void 0 : _config_content.extract) return config.content.extract;
216
+ if ((_config_purge1 = config.purge) === null || _config_purge1 === void 0 ? void 0 : (_config_purge_extract = _config_purge1.extract) === null || _config_purge_extract === void 0 ? void 0 : _config_purge_extract.DEFAULT) return config.purge.extract.DEFAULT;
217
+ if ((_config_content1 = config.content) === null || _config_content1 === void 0 ? void 0 : (_config_content_extract = _config_content1.extract) === null || _config_content_extract === void 0 ? void 0 : _config_content_extract.DEFAULT) return config.content.extract.DEFAULT;
218
+ if ((_config_purge2 = config.purge) === null || _config_purge2 === void 0 ? void 0 : (_config_purge_options = _config_purge2.options) === null || _config_purge_options === void 0 ? void 0 : _config_purge_options.extractors) return config.purge.options.extractors;
219
+ if ((_config_content2 = config.content) === null || _config_content2 === void 0 ? void 0 : (_config_content_options = _config_content2.options) === null || _config_content_options === void 0 ? void 0 : _config_content_options.extractors) return config.content.options.extractors;
220
220
  return {};
221
221
  })();
222
222
  let extractors = {};
223
223
  let defaultExtractor = (()=>{
224
- var ref, ref1, ref2, ref3;
225
- if ((ref = config.purge) === null || ref === void 0 ? void 0 : (ref1 = ref.options) === null || ref1 === void 0 ? void 0 : ref1.defaultExtractor) {
224
+ var _config_purge, _config_purge_options, _config_content, _config_content_options;
225
+ if ((_config_purge = config.purge) === null || _config_purge === void 0 ? void 0 : (_config_purge_options = _config_purge.options) === null || _config_purge_options === void 0 ? void 0 : _config_purge_options.defaultExtractor) {
226
226
  return config.purge.options.defaultExtractor;
227
227
  }
228
- if ((ref2 = config.content) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.options) === null || ref3 === void 0 ? void 0 : ref3.defaultExtractor) {
228
+ if ((_config_content = config.content) === null || _config_content === void 0 ? void 0 : (_config_content_options = _config_content.options) === null || _config_content_options === void 0 ? void 0 : _config_content_options.defaultExtractor) {
229
229
  return config.content.options.defaultExtractor;
230
230
  }
231
231
  return undefined;
@@ -249,11 +249,11 @@ function normalizeConfig(config) {
249
249
  })(),
250
250
  transform: (()=>{
251
251
  let transform = (()=>{
252
- var ref, ref1, ref2, ref3, ref4, ref5;
253
- if ((ref = config.purge) === null || ref === void 0 ? void 0 : ref.transform) return config.purge.transform;
254
- if ((ref1 = config.content) === null || ref1 === void 0 ? void 0 : ref1.transform) return config.content.transform;
255
- if ((ref2 = config.purge) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.transform) === null || ref3 === void 0 ? void 0 : ref3.DEFAULT) return config.purge.transform.DEFAULT;
256
- if ((ref4 = config.content) === null || ref4 === void 0 ? void 0 : (ref5 = ref4.transform) === null || ref5 === void 0 ? void 0 : ref5.DEFAULT) return config.content.transform.DEFAULT;
252
+ var _config_purge, _config_content, _config_purge1, _config_purge_transform, _config_content1, _config_content_transform;
253
+ if ((_config_purge = config.purge) === null || _config_purge === void 0 ? void 0 : _config_purge.transform) return config.purge.transform;
254
+ if ((_config_content = config.content) === null || _config_content === void 0 ? void 0 : _config_content.transform) return config.content.transform;
255
+ if ((_config_purge1 = config.purge) === null || _config_purge1 === void 0 ? void 0 : (_config_purge_transform = _config_purge1.transform) === null || _config_purge_transform === void 0 ? void 0 : _config_purge_transform.DEFAULT) return config.purge.transform.DEFAULT;
256
+ if ((_config_content1 = config.content) === null || _config_content1 === void 0 ? void 0 : (_config_content_transform = _config_content1.transform) === null || _config_content_transform === void 0 ? void 0 : _config_content_transform.DEFAULT) return config.content.transform.DEFAULT;
257
257
  return {};
258
258
  })();
259
259
  let transformers = {};
@@ -80,8 +80,8 @@ function asNegativeValue(modifier, lookup = {}, validate) {
80
80
  }
81
81
  }
82
82
  function asValue(modifier, options = {}, { validate =()=>true } = {}) {
83
- var ref;
84
- let value = (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
83
+ var _options_values;
84
+ let value = (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
85
85
  if (value !== undefined) {
86
86
  return value;
87
87
  }
@@ -123,19 +123,19 @@ function parseColorFormat(value) {
123
123
  }
124
124
  return value;
125
125
  }
126
- function asColor(_, options = {}, { tailwindConfig ={} , utilityModifier , rawModifier } = {}) {
127
- var ref;
128
- if (((ref = options.values) === null || ref === void 0 ? void 0 : ref[rawModifier]) !== undefined) {
129
- var ref1;
130
- return parseColorFormat((ref1 = options.values) === null || ref1 === void 0 ? void 0 : ref1[rawModifier]);
126
+ function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
127
+ var _options_values;
128
+ if (((_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier]) !== undefined) {
129
+ var _options_values1;
130
+ return parseColorFormat((_options_values1 = options.values) === null || _options_values1 === void 0 ? void 0 : _options_values1[modifier]);
131
131
  }
132
132
  // TODO: Hoist this up to getMatchingTypes or something
133
133
  // We do this here because we need the alpha value (if any)
134
- let [color, alpha] = splitUtilityModifier(rawModifier);
134
+ let [color, alpha] = splitUtilityModifier(modifier);
135
135
  if (alpha !== undefined) {
136
- var ref2, ref3, ref4;
137
- var ref5;
138
- 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;
136
+ var _options_values2, _tailwindConfig_theme, _tailwindConfig_theme_opacity;
137
+ var _options_values_color;
138
+ 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;
139
139
  if (normalizedColor === undefined) {
140
140
  return undefined;
141
141
  }
@@ -143,25 +143,22 @@ function asColor(_, options = {}, { tailwindConfig ={} , utilityModifier , rawMo
143
143
  if (isArbitraryValue(alpha)) {
144
144
  return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, alpha.slice(1, -1));
145
145
  }
146
- if (((ref3 = tailwindConfig.theme) === null || ref3 === void 0 ? void 0 : (ref4 = ref3.opacity) === null || ref4 === void 0 ? void 0 : ref4[alpha]) === undefined) {
146
+ 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) {
147
147
  return undefined;
148
148
  }
149
149
  return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, tailwindConfig.theme.opacity[alpha]);
150
150
  }
151
- return asValue(rawModifier, options, {
152
- rawModifier,
153
- utilityModifier,
151
+ return asValue(modifier, options, {
154
152
  validate: _dataTypes.color
155
153
  });
156
154
  }
157
155
  function asLookupValue(modifier, options = {}) {
158
- var ref;
159
- return (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
156
+ var _options_values;
157
+ return (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
160
158
  }
161
159
  function guess(validate) {
162
- return (modifier, options, extras)=>{
160
+ return (modifier, options)=>{
163
161
  return asValue(modifier, options, {
164
- ...extras,
165
162
  validate
166
163
  });
167
164
  };
@@ -197,6 +194,21 @@ function splitAtFirst(input, delim) {
197
194
  ];
198
195
  }
199
196
  function coerceValue(types, modifier, options, tailwindConfig) {
197
+ if (options.values && modifier in options.values) {
198
+ for (let { type } of types !== null && types !== void 0 ? types : []){
199
+ let result = typeMap[type](modifier, options, {
200
+ tailwindConfig
201
+ });
202
+ if (result === undefined) {
203
+ continue;
204
+ }
205
+ return [
206
+ result,
207
+ type,
208
+ null
209
+ ];
210
+ }
211
+ }
200
212
  if (isArbitraryValue(modifier)) {
201
213
  let arbitraryValue = modifier.slice(1, -1);
202
214
  let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
@@ -238,39 +250,25 @@ function* getMatchingTypes(types, rawModifier, options, tailwindConfig) {
238
250
  // TODO: Move to asValue… somehow
239
251
  if (utilityModifier !== undefined) {
240
252
  if (typeof options.modifiers === "object") {
241
- var ref;
242
- var ref1;
243
- let configValue = (ref1 = (ref = options.modifiers) === null || ref === void 0 ? void 0 : ref[utilityModifier]) !== null && ref1 !== void 0 ? ref1 : null;
253
+ var _options_modifiers;
254
+ var _options_modifiers_utilityModifier;
255
+ 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
256
  if (configValue !== null) {
245
257
  utilityModifier = configValue;
246
258
  } else if (isArbitraryValue(utilityModifier)) {
247
259
  utilityModifier = utilityModifier.slice(1, -1);
248
260
  }
249
261
  }
250
- let result = asValue(rawModifier, options, {
251
- rawModifier,
252
- utilityModifier,
253
- tailwindConfig
254
- });
255
- if (result !== undefined) {
256
- yield [
257
- result,
258
- "any",
259
- null
260
- ];
261
- }
262
262
  }
263
- for (const { type } of types !== null && types !== void 0 ? types : []){
264
- let result1 = typeMap[type](modifier, options, {
265
- rawModifier,
266
- utilityModifier,
263
+ for (let { type } of types !== null && types !== void 0 ? types : []){
264
+ let result = typeMap[type](modifier, options, {
267
265
  tailwindConfig
268
266
  });
269
- if (result1 === undefined) {
267
+ if (result === undefined) {
270
268
  continue;
271
269
  }
272
270
  yield [
273
- result1,
271
+ result,
274
272
  type,
275
273
  utilityModifier !== null && utilityModifier !== void 0 ? utilityModifier : null
276
274
  ];