tailwindcss 0.0.0-insiders.bd4dddd → 0.0.0-insiders.bda8421

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 (224) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +13 -10
  3. package/colors.d.ts +3 -0
  4. package/defaultConfig.d.ts +3 -0
  5. package/defaultTheme.d.ts +4 -0
  6. package/lib/cli/build/deps.js +62 -0
  7. package/lib/cli/build/index.js +54 -0
  8. package/lib/cli/build/plugin.js +371 -0
  9. package/lib/cli/build/utils.js +88 -0
  10. package/lib/cli/build/watching.js +182 -0
  11. package/lib/cli/help/index.js +73 -0
  12. package/lib/cli/index.js +230 -0
  13. package/lib/cli/init/index.js +63 -0
  14. package/lib/cli-peer-dependencies.js +28 -7
  15. package/lib/cli.js +1 -741
  16. package/lib/corePluginList.js +17 -4
  17. package/lib/corePlugins.js +2503 -1839
  18. package/lib/css/preflight.css +32 -13
  19. package/lib/featureFlags.js +45 -28
  20. package/lib/index.js +1 -29
  21. package/lib/lib/cacheInvalidation.js +92 -0
  22. package/lib/lib/collapseAdjacentRules.js +30 -10
  23. package/lib/lib/collapseDuplicateDeclarations.js +13 -8
  24. package/lib/lib/content.js +214 -0
  25. package/lib/lib/defaultExtractor.js +240 -31
  26. package/lib/lib/evaluateTailwindFunctions.js +117 -50
  27. package/lib/lib/expandApplyAtRules.js +466 -230
  28. package/lib/lib/expandTailwindAtRules.js +156 -135
  29. package/lib/lib/findAtConfigPath.js +46 -0
  30. package/lib/lib/generateRules.js +554 -200
  31. package/lib/lib/getModuleDependencies.js +88 -37
  32. package/lib/lib/load-config.js +57 -0
  33. package/lib/lib/normalizeTailwindDirectives.js +39 -33
  34. package/lib/lib/offsets.js +355 -0
  35. package/lib/lib/partitionApplyAtRules.js +58 -0
  36. package/lib/lib/regex.js +74 -0
  37. package/lib/lib/remap-bitfield.js +89 -0
  38. package/lib/lib/resolveDefaultsAtRules.js +97 -69
  39. package/lib/lib/setupContextUtils.js +796 -341
  40. package/lib/lib/setupTrackingContext.js +66 -71
  41. package/lib/lib/sharedState.js +45 -14
  42. package/lib/lib/substituteScreenAtRules.js +14 -10
  43. package/lib/plugin.js +48 -0
  44. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  45. package/lib/postcss-plugins/nesting/index.js +21 -0
  46. package/lib/postcss-plugins/nesting/plugin.js +89 -0
  47. package/lib/processTailwindFeatures.js +37 -27
  48. package/lib/public/colors.js +272 -246
  49. package/lib/public/create-plugin.js +9 -5
  50. package/lib/public/default-config.js +10 -6
  51. package/lib/public/default-theme.js +10 -6
  52. package/lib/public/load-config.js +12 -0
  53. package/lib/public/resolve-config.js +11 -6
  54. package/lib/util/applyImportantSelector.js +36 -0
  55. package/lib/util/bigSign.js +6 -1
  56. package/lib/util/buildMediaQuery.js +13 -6
  57. package/lib/util/cloneDeep.js +9 -6
  58. package/lib/util/cloneNodes.js +44 -4
  59. package/lib/util/color.js +70 -53
  60. package/lib/util/colorNames.js +752 -0
  61. package/lib/util/configurePlugins.js +7 -2
  62. package/lib/util/createPlugin.js +8 -6
  63. package/lib/util/createUtilityPlugin.js +16 -16
  64. package/lib/util/dataTypes.js +295 -113
  65. package/lib/util/defaults.js +12 -7
  66. package/lib/util/escapeClassName.js +13 -8
  67. package/lib/util/escapeCommas.js +7 -2
  68. package/lib/util/flattenColorPalette.js +11 -12
  69. package/lib/util/formatVariantSelector.js +235 -151
  70. package/lib/util/getAllConfigs.js +33 -12
  71. package/lib/util/hashConfig.js +9 -4
  72. package/lib/util/isKeyframeRule.js +7 -2
  73. package/lib/util/isPlainObject.js +8 -3
  74. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +25 -15
  75. package/lib/util/log.js +25 -15
  76. package/lib/util/nameClass.js +27 -10
  77. package/lib/util/negateValue.js +25 -8
  78. package/lib/util/normalizeConfig.js +127 -82
  79. package/lib/util/normalizeScreens.js +128 -11
  80. package/lib/util/parseAnimationValue.js +44 -40
  81. package/lib/util/parseBoxShadowValue.js +34 -23
  82. package/lib/util/parseDependency.js +39 -55
  83. package/lib/util/parseGlob.js +36 -0
  84. package/lib/util/parseObjectStyles.js +15 -10
  85. package/lib/util/pluginUtils.js +172 -69
  86. package/lib/util/prefixSelector.js +30 -12
  87. package/lib/util/pseudoElements.js +212 -0
  88. package/lib/util/removeAlphaVariables.js +31 -0
  89. package/lib/util/resolveConfig.js +101 -87
  90. package/lib/util/resolveConfigPath.js +30 -12
  91. package/lib/util/responsive.js +11 -6
  92. package/lib/util/splitAtTopLevelOnly.js +51 -0
  93. package/lib/util/tap.js +6 -1
  94. package/lib/util/toColorValue.js +7 -3
  95. package/lib/util/toPath.js +22 -4
  96. package/lib/util/transformThemeValue.js +40 -30
  97. package/lib/util/validateConfig.js +37 -0
  98. package/lib/util/validateFormalSyntax.js +26 -0
  99. package/lib/util/withAlphaVariable.js +27 -15
  100. package/lib/value-parser/LICENSE +22 -0
  101. package/lib/value-parser/README.md +3 -0
  102. package/lib/value-parser/index.d.js +2 -0
  103. package/lib/value-parser/index.js +22 -0
  104. package/lib/value-parser/parse.js +259 -0
  105. package/lib/value-parser/stringify.js +38 -0
  106. package/lib/value-parser/unit.js +86 -0
  107. package/lib/value-parser/walk.js +16 -0
  108. package/loadConfig.d.ts +4 -0
  109. package/loadConfig.js +2 -0
  110. package/nesting/index.d.ts +4 -0
  111. package/nesting/index.js +2 -12
  112. package/package.json +60 -55
  113. package/peers/index.js +75503 -55095
  114. package/plugin.d.ts +11 -0
  115. package/resolveConfig.d.ts +31 -0
  116. package/scripts/generate-types.js +104 -0
  117. package/scripts/release-channel.js +18 -0
  118. package/scripts/release-notes.js +21 -0
  119. package/scripts/type-utils.js +27 -0
  120. package/src/cli/build/deps.js +56 -0
  121. package/src/cli/build/index.js +49 -0
  122. package/src/cli/build/plugin.js +437 -0
  123. package/src/cli/build/utils.js +76 -0
  124. package/src/cli/build/watching.js +229 -0
  125. package/src/cli/help/index.js +70 -0
  126. package/src/cli/index.js +216 -0
  127. package/src/cli/init/index.js +79 -0
  128. package/src/cli-peer-dependencies.js +7 -1
  129. package/src/cli.js +1 -811
  130. package/src/corePluginList.js +1 -1
  131. package/src/corePlugins.js +849 -243
  132. package/src/css/preflight.css +32 -13
  133. package/src/featureFlags.js +13 -9
  134. package/src/index.js +1 -28
  135. package/src/lib/cacheInvalidation.js +52 -0
  136. package/src/lib/collapseAdjacentRules.js +21 -2
  137. package/src/lib/content.js +249 -0
  138. package/src/lib/defaultExtractor.js +215 -33
  139. package/src/lib/evaluateTailwindFunctions.js +82 -8
  140. package/src/lib/expandApplyAtRules.js +512 -224
  141. package/src/lib/expandTailwindAtRules.js +102 -87
  142. package/src/lib/findAtConfigPath.js +48 -0
  143. package/src/lib/generateRules.js +541 -146
  144. package/src/lib/getModuleDependencies.js +70 -30
  145. package/src/lib/load-config.ts +44 -0
  146. package/src/lib/normalizeTailwindDirectives.js +1 -0
  147. package/src/lib/offsets.js +432 -0
  148. package/src/lib/partitionApplyAtRules.js +52 -0
  149. package/src/lib/regex.js +74 -0
  150. package/src/lib/remap-bitfield.js +82 -0
  151. package/src/lib/resolveDefaultsAtRules.js +55 -30
  152. package/src/lib/setupContextUtils.js +720 -190
  153. package/src/lib/setupTrackingContext.js +47 -61
  154. package/src/lib/sharedState.js +15 -4
  155. package/src/plugin.js +47 -0
  156. package/src/postcss-plugins/nesting/README.md +42 -0
  157. package/src/postcss-plugins/nesting/index.js +13 -0
  158. package/src/postcss-plugins/nesting/plugin.js +80 -0
  159. package/src/processTailwindFeatures.js +11 -4
  160. package/src/public/colors.js +22 -0
  161. package/src/public/default-config.js +1 -1
  162. package/src/public/default-theme.js +2 -2
  163. package/src/public/load-config.js +2 -0
  164. package/src/util/applyImportantSelector.js +27 -0
  165. package/src/util/buildMediaQuery.js +5 -3
  166. package/src/util/cloneNodes.js +40 -2
  167. package/src/util/color.js +39 -20
  168. package/src/util/colorNames.js +150 -0
  169. package/src/util/dataTypes.js +184 -26
  170. package/src/util/formatVariantSelector.js +272 -144
  171. package/src/util/getAllConfigs.js +21 -2
  172. package/src/util/isPlainObject.js +1 -1
  173. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  174. package/src/util/log.js +8 -8
  175. package/src/util/nameClass.js +4 -0
  176. package/src/util/negateValue.js +11 -3
  177. package/src/util/normalizeConfig.js +45 -6
  178. package/src/util/normalizeScreens.js +99 -4
  179. package/src/util/parseBoxShadowValue.js +4 -3
  180. package/src/util/parseDependency.js +37 -42
  181. package/src/util/parseGlob.js +24 -0
  182. package/src/util/pluginUtils.js +139 -24
  183. package/src/util/prefixSelector.js +31 -10
  184. package/src/util/pseudoElements.js +171 -0
  185. package/src/util/removeAlphaVariables.js +24 -0
  186. package/src/util/resolveConfig.js +70 -32
  187. package/src/util/resolveConfigPath.js +12 -1
  188. package/src/util/splitAtTopLevelOnly.js +52 -0
  189. package/src/util/toPath.js +1 -1
  190. package/src/util/transformThemeValue.js +13 -3
  191. package/src/util/validateConfig.js +26 -0
  192. package/src/util/validateFormalSyntax.js +34 -0
  193. package/src/util/withAlphaVariable.js +1 -1
  194. package/src/value-parser/LICENSE +22 -0
  195. package/src/value-parser/README.md +3 -0
  196. package/src/value-parser/index.d.ts +177 -0
  197. package/src/value-parser/index.js +28 -0
  198. package/src/value-parser/parse.js +303 -0
  199. package/src/value-parser/stringify.js +41 -0
  200. package/src/value-parser/unit.js +118 -0
  201. package/src/value-parser/walk.js +18 -0
  202. package/stubs/.gitignore +1 -0
  203. package/stubs/.prettierrc.json +6 -0
  204. package/stubs/{defaultConfig.stub.js → config.full.js} +290 -178
  205. package/stubs/postcss.config.js +6 -0
  206. package/stubs/tailwind.config.cjs +2 -0
  207. package/stubs/tailwind.config.js +2 -0
  208. package/stubs/tailwind.config.ts +3 -0
  209. package/types/config.d.ts +376 -0
  210. package/types/generated/.gitkeep +0 -0
  211. package/types/generated/colors.d.ts +298 -0
  212. package/types/generated/corePluginList.d.ts +1 -0
  213. package/types/generated/default-theme.d.ts +397 -0
  214. package/types/index.d.ts +11 -0
  215. package/CHANGELOG.md +0 -1959
  216. package/lib/constants.js +0 -37
  217. package/lib/lib/detectNesting.js +0 -34
  218. package/nesting/plugin.js +0 -41
  219. package/scripts/install-integrations.js +0 -27
  220. package/scripts/rebuildFixtures.js +0 -68
  221. package/src/constants.js +0 -17
  222. package/src/lib/detectNesting.js +0 -39
  223. /package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -0
  224. /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
@@ -2,18 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = escapeClassName;
6
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
7
- var _escapeCommas = _interopRequireDefault(require("./escapeCommas"));
8
- function _interopRequireDefault(obj) {
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return escapeClassName;
9
+ }
10
+ });
11
+ const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
12
+ const _escapeCommas = /*#__PURE__*/ _interop_require_default(require("./escapeCommas"));
13
+ function _interop_require_default(obj) {
9
14
  return obj && obj.__esModule ? obj : {
10
15
  default: obj
11
16
  };
12
17
  }
13
18
  function escapeClassName(className) {
14
- var ref;
15
- let node = _postcssSelectorParser.default.className();
19
+ var _node_raws;
20
+ let node = _postcssselectorparser.default.className();
16
21
  node.value = className;
17
- var ref1;
18
- return (0, _escapeCommas).default((ref1 = node === null || node === void 0 ? void 0 : (ref = node.raws) === null || ref === void 0 ? void 0 : ref.value) !== null && ref1 !== void 0 ? ref1 : node.value);
22
+ var _node_raws_value;
23
+ return (0, _escapeCommas.default)((_node_raws_value = node === null || node === void 0 ? void 0 : (_node_raws = node.raws) === null || _node_raws === void 0 ? void 0 : _node_raws.value) !== null && _node_raws_value !== void 0 ? _node_raws_value : node.value);
19
24
  }
@@ -2,7 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = escapeCommas;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return escapeCommas;
9
+ }
10
+ });
6
11
  function escapeCommas(className) {
7
- return className.replace(/\\,/g, '\\2c ');
12
+ return className.replace(/\\,/g, "\\2c ");
8
13
  }
@@ -2,18 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = void 0;
6
- const flattenColorPalette = (colors)=>Object.assign({
7
- }, ...Object.entries(colors !== null && colors !== void 0 ? colors : {
8
- }).flatMap(([color, values])=>typeof values == 'object' ? Object.entries(flattenColorPalette(values)).map(([number, hex])=>({
9
- [color + (number === 'DEFAULT' ? '' : `-${number}`)]: hex
10
- })
11
- ) : [
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const flattenColorPalette = (colors)=>Object.assign({}, ...Object.entries(colors !== null && colors !== void 0 ? colors : {}).flatMap(([color, values])=>typeof values == "object" ? Object.entries(flattenColorPalette(values)).map(([number, hex])=>({
12
+ [color + (number === "DEFAULT" ? "" : `-${number}`)]: hex
13
+ })) : [
12
14
  {
13
15
  [`${color}`]: values
14
16
  }
15
- ]
16
- ))
17
- ;
18
- var _default = flattenColorPalette;
19
- exports.default = _default;
17
+ ]));
18
+ const _default = flattenColorPalette;
@@ -2,45 +2,136 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.formatVariantSelector = formatVariantSelector;
6
- exports.finalizeSelector = finalizeSelector;
7
- exports.selectorFunctions = void 0;
8
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
9
- var _unesc = _interopRequireDefault(require("postcss-selector-parser/dist/util/unesc"));
10
- var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
11
- var _prefixSelector = _interopRequireDefault(require("../util/prefixSelector"));
12
- function _interopRequireDefault(obj) {
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
+ formatVariantSelector: function() {
13
+ return formatVariantSelector;
14
+ },
15
+ eliminateIrrelevantSelectors: function() {
16
+ return eliminateIrrelevantSelectors;
17
+ },
18
+ finalizeSelector: function() {
19
+ return finalizeSelector;
20
+ },
21
+ handleMergePseudo: function() {
22
+ return handleMergePseudo;
23
+ }
24
+ });
25
+ const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
26
+ const _unesc = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser/dist/util/unesc"));
27
+ const _escapeClassName = /*#__PURE__*/ _interop_require_default(require("../util/escapeClassName"));
28
+ const _prefixSelector = /*#__PURE__*/ _interop_require_default(require("../util/prefixSelector"));
29
+ const _pseudoElements = require("./pseudoElements");
30
+ const _splitAtTopLevelOnly = require("./splitAtTopLevelOnly");
31
+ function _interop_require_default(obj) {
13
32
  return obj && obj.__esModule ? obj : {
14
33
  default: obj
15
34
  };
16
35
  }
17
- let MERGE = ':merge';
18
- let PARENT = '&';
19
- let selectorFunctions = new Set([
20
- MERGE
21
- ]);
22
- exports.selectorFunctions = selectorFunctions;
23
- function formatVariantSelector(current, ...others) {
24
- for (let other of others){
25
- let incomingValue = resolveFunctionArgument(other, MERGE);
26
- if (incomingValue !== null) {
27
- let existingValue = resolveFunctionArgument(current, MERGE, incomingValue);
28
- if (existingValue !== null) {
29
- let existingTarget = `${MERGE}(${incomingValue})`;
30
- let splitIdx = other.indexOf(existingTarget);
31
- let addition = other.slice(splitIdx + existingTarget.length).split(' ')[0];
32
- current = current.replace(existingTarget, existingTarget + addition);
33
- continue;
34
- }
36
+ /** @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, respectPrefix: boolean}[]} RawFormats */ /** @typedef {import('postcss-selector-parser').Root} ParsedFormats */ /** @typedef {RawFormats | ParsedFormats} AcceptedFormats */ let MERGE = ":merge";
37
+ function formatVariantSelector(formats, { context , candidate }) {
38
+ var _context_tailwindConfig_prefix;
39
+ let prefix = (_context_tailwindConfig_prefix = context === null || context === void 0 ? void 0 : context.tailwindConfig.prefix) !== null && _context_tailwindConfig_prefix !== void 0 ? _context_tailwindConfig_prefix : "";
40
+ // Parse the format selector into an AST
41
+ let parsedFormats = formats.map((format)=>{
42
+ let ast = (0, _postcssselectorparser.default)().astSync(format.format);
43
+ return {
44
+ ...format,
45
+ ast: format.respectPrefix ? (0, _prefixSelector.default)(prefix, ast) : ast
46
+ };
47
+ });
48
+ // We start with the candidate selector
49
+ let formatAst = _postcssselectorparser.default.root({
50
+ nodes: [
51
+ _postcssselectorparser.default.selector({
52
+ nodes: [
53
+ _postcssselectorparser.default.className({
54
+ value: (0, _escapeClassName.default)(candidate)
55
+ })
56
+ ]
57
+ })
58
+ ]
59
+ });
60
+ // And iteratively merge each format selector into the candidate selector
61
+ for (let { ast } of parsedFormats){
62
+ [formatAst, ast] = handleMergePseudo(formatAst, ast);
63
+ // 2. Merge the format selector into the current selector AST
64
+ ast.walkNesting((nesting)=>nesting.replaceWith(...formatAst.nodes[0].nodes));
65
+ // 3. Keep going!
66
+ formatAst = ast;
67
+ }
68
+ return formatAst;
69
+ }
70
+ /**
71
+ * Given any node in a selector this gets the "simple" selector it's a part of
72
+ * A simple selector is just a list of nodes without any combinators
73
+ * Technically :is(), :not(), :has(), etc… can have combinators but those are nested
74
+ * inside the relevant node and won't be picked up so they're fine to ignore
75
+ *
76
+ * @param {Node} node
77
+ * @returns {Node[]}
78
+ **/ function simpleSelectorForNode(node) {
79
+ /** @type {Node[]} */ let nodes = [];
80
+ // Walk backwards until we hit a combinator node (or the start)
81
+ while(node.prev() && node.prev().type !== "combinator"){
82
+ node = node.prev();
83
+ }
84
+ // Now record all non-combinator nodes until we hit one (or the end)
85
+ while(node && node.type !== "combinator"){
86
+ nodes.push(node);
87
+ node = node.next();
88
+ }
89
+ return nodes;
90
+ }
91
+ /**
92
+ * Resorts the nodes in a selector to ensure they're in the correct order
93
+ * Tags go before classes, and pseudo classes go after classes
94
+ *
95
+ * @param {Selector} sel
96
+ * @returns {Selector}
97
+ **/ function resortSelector(sel) {
98
+ sel.sort((a, b)=>{
99
+ if (a.type === "tag" && b.type === "class") {
100
+ return -1;
101
+ } else if (a.type === "class" && b.type === "tag") {
102
+ return 1;
103
+ } else if (a.type === "class" && b.type === "pseudo" && b.value.startsWith("::")) {
104
+ return -1;
105
+ } else if (a.type === "pseudo" && a.value.startsWith("::") && b.type === "class") {
106
+ return 1;
35
107
  }
36
- current = other.replace(PARENT, current);
108
+ return sel.index(a) - sel.index(b);
109
+ });
110
+ return sel;
111
+ }
112
+ function eliminateIrrelevantSelectors(sel, base) {
113
+ let hasClassesMatchingCandidate = false;
114
+ sel.walk((child)=>{
115
+ if (child.type === "class" && child.value === base) {
116
+ hasClassesMatchingCandidate = true;
117
+ return false // Stop walking
118
+ ;
119
+ }
120
+ });
121
+ if (!hasClassesMatchingCandidate) {
122
+ sel.remove();
37
123
  }
38
- return current;
124
+ // We do NOT recursively eliminate sub selectors that don't have the base class
125
+ // as this is NOT a safe operation. For example, if we have:
126
+ // `.space-x-2 > :not([hidden]) ~ :not([hidden])`
127
+ // We cannot remove the [hidden] from the :not() because it would change the
128
+ // meaning of the selector.
129
+ // TODO: Can we do this for :matches, :is, and :where?
39
130
  }
40
- function finalizeSelector(format, { selector: selector1 , candidate , context }) {
41
- var ref, ref1;
42
- var ref2;
43
- let separator = (ref2 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref2 !== void 0 ? ref2 : ':';
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 : ":";
44
135
  // Split by the separator, but ignore the separator inside square brackets:
45
136
  //
46
137
  // E.g.: dark:lg:hover:[paint-order:markers]
@@ -48,12 +139,9 @@ function finalizeSelector(format, { selector: selector1 , candidate , context }
48
139
  // │ │ │ ╰── We will not split here
49
140
  // ╰──┴─────┴─────────────── We will split here
50
141
  //
51
- let splitter = new RegExp(`\\${separator}(?![^[]*\\])`);
52
- let base = candidate.split(splitter).pop();
53
- if (context === null || context === void 0 ? void 0 : (ref1 = context.tailwindConfig) === null || ref1 === void 0 ? void 0 : ref1.prefix) {
54
- format = (0, _prefixSelector).default(context.tailwindConfig.prefix, format);
55
- }
56
- format = format.replace(PARENT, `.${(0, _escapeClassName).default(candidate)}`);
142
+ base = base !== null && base !== void 0 ? base : (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(candidate, separator).pop();
143
+ // Parse the selector into an AST
144
+ let selector = (0, _postcssselectorparser.default)().astSync(current);
57
145
  // Normalize escaped classes, e.g.:
58
146
  //
59
147
  // The idea would be to replace the escaped `base` in the selector with the
@@ -65,122 +153,118 @@ function finalizeSelector(format, { selector: selector1 , candidate , context }
65
153
  // base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
66
154
  // escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
67
155
  //
68
- selector1 = (0, _postcssSelectorParser).default((selectors)=>{
69
- return selectors.walkClasses((node)=>{
70
- if (node.raws && node.value.includes(base)) {
71
- node.raws.value = (0, _escapeClassName).default((0, _unesc).default(node.raws.value));
72
- }
73
- return node;
74
- });
75
- }).processSync(selector1);
156
+ selector.walkClasses((node)=>{
157
+ if (node.raws && node.value.includes(base)) {
158
+ node.raws.value = (0, _escapeClassName.default)((0, _unesc.default)(node.raws.value));
159
+ }
160
+ });
161
+ // Remove extraneous selectors that do not include the base candidate
162
+ selector.each((sel)=>eliminateIrrelevantSelectors(sel, base));
163
+ // If ffter eliminating irrelevant selectors, we end up with nothing
164
+ // Then the whole "rule" this is associated with does not need to exist
165
+ // We use `null` as a marker value for that case
166
+ if (selector.length === 0) {
167
+ return null;
168
+ }
169
+ // If there are no formats that means there were no variants added to the candidate
170
+ // so we can just return the selector as-is
171
+ let formatAst = Array.isArray(formats) ? formatVariantSelector(formats, {
172
+ context,
173
+ candidate
174
+ }) : formats;
175
+ if (formatAst === null) {
176
+ return selector.toString();
177
+ }
178
+ let simpleStart = _postcssselectorparser.default.comment({
179
+ value: "/*__simple__*/"
180
+ });
181
+ let simpleEnd = _postcssselectorparser.default.comment({
182
+ value: "/*__simple__*/"
183
+ });
76
184
  // We can safely replace the escaped base now, since the `base` section is
77
185
  // now in a normalized escaped value.
78
- selector1 = selector1.replace(`.${(0, _escapeClassName).default(base)}`, format);
186
+ selector.walkClasses((node)=>{
187
+ if (node.value !== base) {
188
+ return;
189
+ }
190
+ let parent = node.parent;
191
+ let formatNodes = formatAst.nodes[0].nodes;
192
+ // Perf optimization: if the parent is a single class we can just replace it and be done
193
+ if (parent.nodes.length === 1) {
194
+ node.replaceWith(...formatNodes);
195
+ return;
196
+ }
197
+ let simpleSelector = simpleSelectorForNode(node);
198
+ parent.insertBefore(simpleSelector[0], simpleStart);
199
+ parent.insertAfter(simpleSelector[simpleSelector.length - 1], simpleEnd);
200
+ for (let child of formatNodes){
201
+ parent.insertBefore(simpleSelector[0], child.clone());
202
+ }
203
+ node.remove();
204
+ // Re-sort the simple selector to ensure it's in the correct order
205
+ simpleSelector = simpleSelectorForNode(simpleStart);
206
+ let firstNode = parent.index(simpleStart);
207
+ parent.nodes.splice(firstNode, simpleSelector.length, ...resortSelector(_postcssselectorparser.default.selector({
208
+ nodes: simpleSelector
209
+ })).nodes);
210
+ simpleStart.remove();
211
+ simpleEnd.remove();
212
+ });
79
213
  // Remove unnecessary pseudo selectors that we used as placeholders
80
- return (0, _postcssSelectorParser).default((selectors)=>{
81
- return selectors.map((selector2)=>{
82
- selector2.walkPseudos((p)=>{
83
- if (selectorFunctions.has(p.value)) {
84
- p.replaceWith(p.nodes);
85
- }
86
- return p;
87
- });
88
- // This will make sure to move pseudo's to the correct spot (the end for
89
- // pseudo elements) because otherwise the selector will never work
90
- // anyway.
91
- //
92
- // E.g.:
93
- // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
94
- // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
95
- //
96
- // `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
97
- function collectPseudoElements(selector) {
98
- let nodes = [];
99
- for (let node of selector.nodes){
100
- if (isPseudoElement(node)) {
101
- nodes.push(node);
102
- selector.removeChild(node);
103
- }
104
- if (node === null || node === void 0 ? void 0 : node.nodes) {
105
- nodes.push(...collectPseudoElements(node));
106
- }
107
- }
108
- return nodes;
109
- }
110
- let pseudoElements = collectPseudoElements(selector2);
111
- if (pseudoElements.length > 0) {
112
- selector2.nodes.push(pseudoElements.sort(sortSelector));
113
- }
114
- return selector2;
115
- });
116
- }).processSync(selector1);
117
- }
118
- // Note: As a rule, double colons (::) should be used instead of a single colon
119
- // (:). This distinguishes pseudo-classes from pseudo-elements. However, since
120
- // this distinction was not present in older versions of the W3C spec, most
121
- // browsers support both syntaxes for the original pseudo-elements.
122
- let pseudoElementsBC = [
123
- ':before',
124
- ':after',
125
- ':first-line',
126
- ':first-letter'
127
- ];
128
- // These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
129
- let pseudoElementExceptions = [
130
- '::file-selector-button'
131
- ];
132
- // This will make sure to move pseudo's to the correct spot (the end for
133
- // pseudo elements) because otherwise the selector will never work
134
- // anyway.
135
- //
136
- // E.g.:
137
- // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
138
- // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
139
- //
140
- // `::before:hover` doesn't work, which means that we can make it work
141
- // for you by flipping the order.
142
- function sortSelector(a, z) {
143
- // Both nodes are non-pseudo's so we can safely ignore them and keep
144
- // them in the same order.
145
- if (a.type !== 'pseudo' && z.type !== 'pseudo') {
146
- return 0;
147
- }
148
- // If one of them is a combinator, we need to keep it in the same order
149
- // because that means it will start a new "section" in the selector.
150
- if (a.type === 'combinator' ^ z.type === 'combinator') {
151
- return 0;
152
- }
153
- // One of the items is a pseudo and the other one isn't. Let's move
154
- // the pseudo to the right.
155
- if (a.type === 'pseudo' ^ z.type === 'pseudo') {
156
- return (a.type === 'pseudo') - (z.type === 'pseudo');
157
- }
158
- // Both are pseudo's, move the pseudo elements (except for
159
- // ::file-selector-button) to the right.
160
- return isPseudoElement(a) - isPseudoElement(z);
161
- }
162
- function isPseudoElement(node) {
163
- if (node.type !== 'pseudo') return false;
164
- if (pseudoElementExceptions.includes(node.value)) return false;
165
- return node.value.startsWith('::') || pseudoElementsBC.includes(node.value);
214
+ selector.walkPseudos((p)=>{
215
+ if (p.value === MERGE) {
216
+ p.replaceWith(p.nodes);
217
+ }
218
+ });
219
+ // Move pseudo elements to the end of the selector (if necessary)
220
+ selector.each((sel)=>(0, _pseudoElements.movePseudos)(sel));
221
+ return selector.toString();
166
222
  }
167
- function resolveFunctionArgument(haystack, needle, arg) {
168
- let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle);
169
- if (startIdx === -1) return null;
170
- // Start inside the `(`
171
- startIdx += needle.length + 1;
172
- let target = '';
173
- let count = 0;
174
- for (let char of haystack.slice(startIdx)){
175
- if (char !== '(' && char !== ')') {
176
- target += char;
177
- } else if (char === '(') {
178
- target += char;
179
- count++;
180
- } else if (char === ')') {
181
- if (--count < 0) break; // unbalanced
182
- target += char;
223
+ function handleMergePseudo(selector, format) {
224
+ /** @type {{pseudo: Pseudo, value: string}[]} */ let merges = [];
225
+ // Find all :merge() pseudo-classes in `selector`
226
+ selector.walkPseudos((pseudo)=>{
227
+ if (pseudo.value === MERGE) {
228
+ merges.push({
229
+ pseudo,
230
+ value: pseudo.nodes[0].toString()
231
+ });
183
232
  }
184
- }
185
- return target;
233
+ });
234
+ // Find all :merge() "attachments" in `format` and attach them to the matching selector in `selector`
235
+ format.walkPseudos((pseudo)=>{
236
+ if (pseudo.value !== MERGE) {
237
+ return;
238
+ }
239
+ let value = pseudo.nodes[0].toString();
240
+ // Does `selector` contain a :merge() pseudo-class with the same value?
241
+ let existing = merges.find((merge)=>merge.value === value);
242
+ // Nope so there's nothing to do
243
+ if (!existing) {
244
+ return;
245
+ }
246
+ // Everything after `:merge()` up to the next combinator is what is attached to the merged selector
247
+ let attachments = [];
248
+ let next = pseudo.next();
249
+ while(next && next.type !== "combinator"){
250
+ attachments.push(next);
251
+ next = next.next();
252
+ }
253
+ let combinator = next;
254
+ existing.pseudo.parent.insertAfter(existing.pseudo, _postcssselectorparser.default.selector({
255
+ nodes: attachments.map((node)=>node.clone())
256
+ }));
257
+ pseudo.remove();
258
+ attachments.forEach((node)=>node.remove());
259
+ // What about this case:
260
+ // :merge(.group):focus > &
261
+ // :merge(.group):hover &
262
+ if (combinator && combinator.type === "combinator") {
263
+ combinator.remove();
264
+ }
265
+ });
266
+ return [
267
+ selector,
268
+ format
269
+ ];
186
270
  }
@@ -2,25 +2,46 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = getAllConfigs;
6
- var _defaultConfigStubJs = _interopRequireDefault(require("../../stubs/defaultConfig.stub.js"));
7
- var _featureFlags = require("../featureFlags");
8
- function _interopRequireDefault(obj) {
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getAllConfigs;
9
+ }
10
+ });
11
+ const _configfull = /*#__PURE__*/ _interop_require_default(require("../../stubs/config.full.js"));
12
+ const _featureFlags = require("../featureFlags");
13
+ function _interop_require_default(obj) {
9
14
  return obj && obj.__esModule ? obj : {
10
15
  default: obj
11
16
  };
12
17
  }
13
18
  function getAllConfigs(config) {
14
- var ref;
15
- const configs = ((ref = config === null || config === void 0 ? void 0 : config.presets) !== null && ref !== void 0 ? ref : [
16
- _defaultConfigStubJs.default
17
- ]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset)
18
- );
19
+ var _config_presets;
20
+ const configs = ((_config_presets = config === null || config === void 0 ? void 0 : config.presets) !== null && _config_presets !== void 0 ? _config_presets : [
21
+ _configfull.default
22
+ ]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset));
19
23
  const features = {
24
+ // Add experimental configs here...
25
+ respectDefaultRingColorOpacity: {
26
+ theme: {
27
+ ringColor: ({ theme })=>({
28
+ DEFAULT: "#3b82f67f",
29
+ ...theme("colors")
30
+ })
31
+ }
32
+ },
33
+ disableColorOpacityUtilitiesByDefault: {
34
+ corePlugins: {
35
+ backgroundOpacity: false,
36
+ borderOpacity: false,
37
+ divideOpacity: false,
38
+ placeholderOpacity: false,
39
+ ringOpacity: false,
40
+ textOpacity: false
41
+ }
42
+ }
20
43
  };
21
- const experimentals = Object.keys(features).filter((feature)=>(0, _featureFlags).flagEnabled(config, feature)
22
- ).map((feature)=>features[feature]
23
- );
44
+ const experimentals = Object.keys(features).filter((feature)=>(0, _featureFlags.flagEnabled)(config, feature)).map((feature)=>features[feature]);
24
45
  return [
25
46
  config,
26
47
  ...experimentals,
@@ -2,15 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = hashConfig;
6
- var _objectHash = _interopRequireDefault(require("object-hash"));
7
- function _interopRequireDefault(obj) {
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return hashConfig;
9
+ }
10
+ });
11
+ const _objecthash = /*#__PURE__*/ _interop_require_default(require("object-hash"));
12
+ function _interop_require_default(obj) {
8
13
  return obj && obj.__esModule ? obj : {
9
14
  default: obj
10
15
  };
11
16
  }
12
17
  function hashConfig(config) {
13
- return (0, _objectHash).default(config, {
18
+ return (0, _objecthash.default)(config, {
14
19
  ignoreUnknown: true
15
20
  });
16
21
  }
@@ -2,7 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = isKeyframeRule;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return isKeyframeRule;
9
+ }
10
+ });
6
11
  function isKeyframeRule(rule) {
7
- return rule.parent && rule.parent.type === 'atrule' && /keyframes$/.test(rule.parent.name);
12
+ return rule.parent && rule.parent.type === "atrule" && /keyframes$/.test(rule.parent.name);
8
13
  }
@@ -2,11 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = isPlainObject;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return isPlainObject;
9
+ }
10
+ });
6
11
  function isPlainObject(value) {
7
- if (Object.prototype.toString.call(value) !== '[object Object]') {
12
+ if (Object.prototype.toString.call(value) !== "[object Object]") {
8
13
  return false;
9
14
  }
10
15
  const prototype = Object.getPrototypeOf(value);
11
- return prototype === null || prototype === Object.prototype;
16
+ return prototype === null || Object.getPrototypeOf(prototype) === null;
12
17
  }