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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/CHANGELOG.md +246 -6
  2. package/README.md +13 -9
  3. package/defaultTheme.d.ts +2 -1
  4. package/lib/cli/build/deps.js +54 -0
  5. package/lib/cli/build/index.js +48 -0
  6. package/lib/cli/build/plugin.js +362 -0
  7. package/lib/cli/build/utils.js +78 -0
  8. package/lib/cli/build/watching.js +178 -0
  9. package/lib/cli/help/index.js +71 -0
  10. package/lib/cli/index.js +18 -0
  11. package/lib/cli/init/index.js +46 -0
  12. package/lib/cli/shared.js +12 -0
  13. package/lib/cli-peer-dependencies.js +18 -5
  14. package/lib/cli.js +62 -592
  15. package/lib/constants.js +19 -12
  16. package/lib/corePluginList.js +5 -3
  17. package/lib/corePlugins.js +619 -347
  18. package/lib/css/preflight.css +7 -0
  19. package/lib/featureFlags.js +34 -22
  20. package/lib/index.js +16 -9
  21. package/lib/lib/cacheInvalidation.js +42 -21
  22. package/lib/lib/collapseAdjacentRules.js +16 -14
  23. package/lib/lib/collapseDuplicateDeclarations.js +13 -10
  24. package/lib/lib/content.js +177 -0
  25. package/lib/lib/defaultExtractor.js +230 -33
  26. package/lib/lib/detectNesting.js +13 -4
  27. package/lib/lib/evaluateTailwindFunctions.js +105 -42
  28. package/lib/lib/expandApplyAtRules.js +151 -92
  29. package/lib/lib/expandTailwindAtRules.js +134 -149
  30. package/lib/lib/findAtConfigPath.js +44 -0
  31. package/lib/lib/generateRules.js +404 -185
  32. package/lib/lib/getModuleDependencies.js +21 -18
  33. package/lib/lib/normalizeTailwindDirectives.js +11 -8
  34. package/lib/lib/offsets.js +285 -0
  35. package/lib/lib/partitionApplyAtRules.js +14 -11
  36. package/lib/lib/regex.js +60 -0
  37. package/lib/lib/remap-bitfield.js +87 -0
  38. package/lib/lib/resolveDefaultsAtRules.js +97 -79
  39. package/lib/lib/setupContextUtils.js +567 -242
  40. package/lib/lib/setupTrackingContext.js +77 -106
  41. package/lib/lib/sharedState.js +18 -10
  42. package/lib/lib/substituteScreenAtRules.js +9 -7
  43. package/lib/postcss-plugins/nesting/index.js +7 -5
  44. package/lib/postcss-plugins/nesting/plugin.js +10 -8
  45. package/lib/processTailwindFeatures.js +34 -31
  46. package/lib/public/colors.js +7 -5
  47. package/lib/public/create-plugin.js +6 -4
  48. package/lib/public/default-config.js +7 -5
  49. package/lib/public/default-theme.js +7 -5
  50. package/lib/public/resolve-config.js +13 -10
  51. package/lib/util/bigSign.js +4 -1
  52. package/lib/util/buildMediaQuery.js +10 -5
  53. package/lib/util/cloneDeep.js +6 -5
  54. package/lib/util/cloneNodes.js +9 -2
  55. package/lib/util/color.js +20 -17
  56. package/lib/util/configurePlugins.js +5 -2
  57. package/lib/util/createPlugin.js +6 -5
  58. package/lib/util/createUtilityPlugin.js +15 -13
  59. package/lib/util/dataTypes.js +75 -51
  60. package/lib/util/defaults.js +8 -5
  61. package/lib/util/escapeClassName.js +13 -10
  62. package/lib/util/escapeCommas.js +4 -1
  63. package/lib/util/flattenColorPalette.js +7 -8
  64. package/lib/util/formatVariantSelector.js +270 -103
  65. package/lib/util/getAllConfigs.js +34 -15
  66. package/lib/util/hashConfig.js +10 -7
  67. package/lib/util/isKeyframeRule.js +4 -1
  68. package/lib/util/isPlainObject.js +4 -1
  69. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +34 -26
  70. package/lib/util/log.js +14 -8
  71. package/lib/util/nameClass.js +19 -8
  72. package/lib/util/negateValue.js +20 -5
  73. package/lib/util/normalizeConfig.js +94 -53
  74. package/lib/util/normalizeScreens.js +115 -4
  75. package/lib/util/parseAnimationValue.js +43 -41
  76. package/lib/util/parseBoxShadowValue.js +12 -45
  77. package/lib/util/parseDependency.js +37 -55
  78. package/lib/util/parseGlob.js +34 -0
  79. package/lib/util/parseObjectStyles.js +15 -12
  80. package/lib/util/pluginUtils.js +146 -42
  81. package/lib/util/prefixSelector.js +26 -9
  82. package/lib/util/removeAlphaVariables.js +29 -0
  83. package/lib/util/resolveConfig.js +104 -105
  84. package/lib/util/resolveConfigPath.js +20 -17
  85. package/lib/util/responsive.js +12 -9
  86. package/lib/util/splitAtTopLevelOnly.js +43 -0
  87. package/lib/util/tap.js +4 -1
  88. package/lib/util/toColorValue.js +4 -1
  89. package/lib/util/toPath.js +18 -2
  90. package/lib/util/transformThemeValue.js +23 -11
  91. package/lib/util/validateConfig.js +24 -0
  92. package/lib/util/validateFormalSyntax.js +24 -0
  93. package/lib/util/withAlphaVariable.js +32 -24
  94. package/package.json +32 -29
  95. package/peers/index.js +6693 -3036
  96. package/plugin.d.ts +10 -5
  97. package/resolveConfig.d.ts +12 -0
  98. package/scripts/generate-types.js +53 -0
  99. package/scripts/release-channel.js +18 -0
  100. package/scripts/release-notes.js +21 -0
  101. package/scripts/type-utils.js +27 -0
  102. package/src/cli/build/deps.js +56 -0
  103. package/src/cli/build/index.js +49 -0
  104. package/src/cli/build/plugin.js +434 -0
  105. package/src/cli/build/utils.js +76 -0
  106. package/src/cli/build/watching.js +227 -0
  107. package/src/cli/help/index.js +70 -0
  108. package/src/cli/index.js +3 -0
  109. package/src/cli/init/index.js +50 -0
  110. package/src/cli/shared.js +5 -0
  111. package/src/cli-peer-dependencies.js +7 -1
  112. package/src/cli.js +46 -659
  113. package/src/corePlugins.js +346 -79
  114. package/src/css/preflight.css +7 -0
  115. package/src/featureFlags.js +12 -2
  116. package/src/index.js +5 -0
  117. package/src/lib/content.js +213 -0
  118. package/src/lib/defaultExtractor.js +202 -35
  119. package/src/lib/detectNesting.js +9 -1
  120. package/src/lib/evaluateTailwindFunctions.js +78 -7
  121. package/src/lib/expandApplyAtRules.js +129 -34
  122. package/src/lib/expandTailwindAtRules.js +12 -50
  123. package/src/lib/findAtConfigPath.js +48 -0
  124. package/src/lib/generateRules.js +379 -126
  125. package/src/lib/offsets.js +351 -0
  126. package/src/lib/regex.js +74 -0
  127. package/src/lib/remap-bitfield.js +82 -0
  128. package/src/lib/resolveDefaultsAtRules.js +53 -36
  129. package/src/lib/setupContextUtils.js +510 -120
  130. package/src/lib/setupTrackingContext.js +8 -45
  131. package/src/lib/sharedState.js +2 -0
  132. package/src/util/buildMediaQuery.js +5 -3
  133. package/src/util/cloneNodes.js +5 -1
  134. package/src/util/dataTypes.js +51 -26
  135. package/src/util/formatVariantSelector.js +317 -101
  136. package/src/util/getAllConfigs.js +19 -0
  137. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  138. package/src/util/log.js +1 -1
  139. package/src/util/nameClass.js +4 -0
  140. package/src/util/negateValue.js +10 -2
  141. package/src/util/normalizeConfig.js +40 -10
  142. package/src/util/normalizeScreens.js +99 -4
  143. package/src/util/parseBoxShadowValue.js +3 -50
  144. package/src/util/parseDependency.js +37 -42
  145. package/src/util/parseGlob.js +24 -0
  146. package/src/util/pluginUtils.js +132 -10
  147. package/src/util/prefixSelector.js +28 -10
  148. package/src/util/removeAlphaVariables.js +24 -0
  149. package/src/util/resolveConfig.js +70 -62
  150. package/src/util/splitAtTopLevelOnly.js +45 -0
  151. package/src/util/toPath.js +1 -1
  152. package/src/util/transformThemeValue.js +13 -3
  153. package/src/util/validateConfig.js +13 -0
  154. package/src/util/validateFormalSyntax.js +34 -0
  155. package/src/util/withAlphaVariable.js +1 -1
  156. package/stubs/defaultConfig.stub.js +165 -164
  157. package/stubs/simpleConfig.stub.js +1 -0
  158. package/types/config.d.ts +77 -37
  159. package/types/generated/default-theme.d.ts +342 -0
  160. package/types/index.d.ts +7 -1
  161. package/types.d.ts +0 -1
@@ -1,63 +1,45 @@
1
- "use strict";
1
+ // @ts-check
2
+ /**
3
+ * @typedef {{type: 'dependency', file: string} | {type: 'dir-dependency', dir: string, glob: string}} Dependency
4
+ */ /**
5
+ *
6
+ * @param {import('../lib/content.js').ContentPath} contentPath
7
+ * @returns {Dependency[]}
8
+ */ "use strict";
2
9
  Object.defineProperty(exports, "__esModule", {
3
10
  value: true
4
11
  });
5
- exports.default = parseDependency;
6
- var _isGlob = _interopRequireDefault(require("is-glob"));
7
- var _globParent = _interopRequireDefault(require("glob-parent"));
8
- var _path = _interopRequireDefault(require("path"));
9
- function parseDependency(normalizedFileOrGlob) {
10
- if (normalizedFileOrGlob.startsWith("!")) {
11
- return null;
12
+ Object.defineProperty(exports, "default", {
13
+ enumerable: true,
14
+ get: ()=>parseDependency
15
+ });
16
+ function parseDependency(contentPath) {
17
+ if (contentPath.ignore) {
18
+ return [];
12
19
  }
13
- let message;
14
- if ((0, _isGlob).default(normalizedFileOrGlob)) {
15
- let { base , glob } = parseGlob(normalizedFileOrGlob);
16
- message = {
17
- type: "dir-dependency",
18
- dir: _path.default.resolve(base),
19
- glob
20
- };
21
- } else {
22
- message = {
23
- type: "dependency",
24
- file: _path.default.resolve(normalizedFileOrGlob)
25
- };
20
+ if (!contentPath.glob) {
21
+ return [
22
+ {
23
+ type: "dependency",
24
+ file: contentPath.base
25
+ }
26
+ ];
26
27
  }
27
- // rollup-plugin-postcss does not support dir-dependency messages
28
- // but directories can be watched in the same way as files
29
- if (message.type === "dir-dependency" && process.env.ROLLUP_WATCH === "true") {
30
- message = {
31
- type: "dependency",
32
- file: message.dir
33
- };
28
+ if (process.env.ROLLUP_WATCH === "true") {
29
+ // rollup-plugin-postcss does not support dir-dependency messages
30
+ // but directories can be watched in the same way as files
31
+ return [
32
+ {
33
+ type: "dependency",
34
+ file: contentPath.base
35
+ }
36
+ ];
34
37
  }
35
- return message;
36
- }
37
- function _interopRequireDefault(obj) {
38
- return obj && obj.__esModule ? obj : {
39
- default: obj
40
- };
41
- }
42
- // Based on `glob-base`
43
- // https://github.com/micromatch/glob-base/blob/master/index.js
44
- function parseGlob(pattern) {
45
- let glob = pattern;
46
- let base = (0, _globParent).default(pattern);
47
- if (base !== ".") {
48
- glob = pattern.substr(base.length);
49
- if (glob.charAt(0) === "/") {
50
- glob = glob.substr(1);
38
+ return [
39
+ {
40
+ type: "dir-dependency",
41
+ dir: contentPath.base,
42
+ glob: contentPath.glob
51
43
  }
52
- }
53
- if (glob.substr(0, 2) === "./") {
54
- glob = glob.substr(2);
55
- }
56
- if (glob.charAt(0) === "/") {
57
- glob = glob.substr(1);
58
- }
59
- return {
60
- base,
61
- glob
62
- };
44
+ ];
63
45
  }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "parseGlob", {
6
+ enumerable: true,
7
+ get: ()=>parseGlob
8
+ });
9
+ const _globParent = /*#__PURE__*/ _interopRequireDefault(require("glob-parent"));
10
+ function _interopRequireDefault(obj) {
11
+ return obj && obj.__esModule ? obj : {
12
+ default: obj
13
+ };
14
+ }
15
+ function parseGlob(pattern) {
16
+ let glob = pattern;
17
+ let base = (0, _globParent.default)(pattern);
18
+ if (base !== ".") {
19
+ glob = pattern.substr(base.length);
20
+ if (glob.charAt(0) === "/") {
21
+ glob = glob.substr(1);
22
+ }
23
+ }
24
+ if (glob.substr(0, 2) === "./") {
25
+ glob = glob.substr(2);
26
+ }
27
+ if (glob.charAt(0) === "/") {
28
+ glob = glob.substr(1);
29
+ }
30
+ return {
31
+ base,
32
+ glob
33
+ };
34
+ }
@@ -2,10 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = parseObjectStyles;
6
- var _postcss = _interopRequireDefault(require("postcss"));
7
- var _postcssNested = _interopRequireDefault(require("postcss-nested"));
8
- var _postcssJs = _interopRequireDefault(require("postcss-js"));
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>parseObjectStyles
8
+ });
9
+ const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
10
+ const _postcssNested = /*#__PURE__*/ _interopRequireDefault(require("postcss-nested"));
11
+ const _postcssJs = /*#__PURE__*/ _interopRequireDefault(require("postcss-js"));
12
+ function _interopRequireDefault(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
9
17
  function parseObjectStyles(styles) {
10
18
  if (!Array.isArray(styles)) {
11
19
  return parseObjectStyles([
@@ -13,19 +21,14 @@ function parseObjectStyles(styles) {
13
21
  ]);
14
22
  }
15
23
  return styles.flatMap((style)=>{
16
- return (0, _postcss).default([
17
- (0, _postcssNested).default({
24
+ return (0, _postcss.default)([
25
+ (0, _postcssNested.default)({
18
26
  bubble: [
19
27
  "screen"
20
28
  ]
21
- }),
29
+ })
22
30
  ]).process(style, {
23
31
  parser: _postcssJs.default
24
32
  }).root.nodes;
25
33
  });
26
34
  }
27
- function _interopRequireDefault(obj) {
28
- return obj && obj.__esModule ? obj : {
29
- default: obj
30
- };
31
- }
@@ -2,32 +2,58 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.updateAllClasses = updateAllClasses;
6
- exports.asValue = asValue;
7
- exports.asColor = asColor;
8
- exports.asLookupValue = asLookupValue;
9
- exports.coerceValue = coerceValue;
10
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
11
- var _escapeCommas = _interopRequireDefault(require("./escapeCommas"));
12
- var _withAlphaVariable = require("./withAlphaVariable");
13
- var _dataTypes = require("./dataTypes");
14
- var _negateValue = _interopRequireDefault(require("./negateValue"));
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ updateAllClasses: ()=>updateAllClasses,
13
+ filterSelectorsForClass: ()=>filterSelectorsForClass,
14
+ asValue: ()=>asValue,
15
+ parseColorFormat: ()=>parseColorFormat,
16
+ asColor: ()=>asColor,
17
+ asLookupValue: ()=>asLookupValue,
18
+ typeMap: ()=>typeMap,
19
+ coerceValue: ()=>coerceValue,
20
+ getMatchingTypes: ()=>getMatchingTypes
21
+ });
22
+ const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
23
+ const _escapeCommas = /*#__PURE__*/ _interopRequireDefault(require("./escapeCommas"));
24
+ const _withAlphaVariable = require("./withAlphaVariable");
25
+ const _dataTypes = require("./dataTypes");
26
+ const _negateValue = /*#__PURE__*/ _interopRequireDefault(require("./negateValue"));
27
+ const _validateFormalSyntax = require("./validateFormalSyntax");
28
+ const _featureFlagsJs = require("../featureFlags.js");
15
29
  function _interopRequireDefault(obj) {
16
30
  return obj && obj.__esModule ? obj : {
17
31
  default: obj
18
32
  };
19
33
  }
20
- function updateAllClasses(selectors1, updateClass) {
21
- let parser = (0, _postcssSelectorParser).default((selectors)=>{
34
+ function updateAllClasses(selectors, updateClass) {
35
+ let parser = (0, _postcssSelectorParser.default)((selectors)=>{
22
36
  selectors.walkClasses((sel)=>{
23
37
  let updatedClass = updateClass(sel.value);
24
38
  sel.value = updatedClass;
25
39
  if (sel.raws && sel.raws.value) {
26
- sel.raws.value = (0, _escapeCommas).default(sel.raws.value);
40
+ sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
41
+ }
42
+ });
43
+ });
44
+ let result = parser.processSync(selectors);
45
+ return result;
46
+ }
47
+ function filterSelectorsForClass(selectors, classCandidate) {
48
+ let parser = (0, _postcssSelectorParser.default)((selectors)=>{
49
+ selectors.each((sel)=>{
50
+ const containsClass = sel.nodes.some((node)=>node.type === "class" && node.value === classCandidate);
51
+ if (!containsClass) {
52
+ sel.remove();
27
53
  }
28
54
  });
29
55
  });
30
- let result = parser.processSync(selectors1);
56
+ let result = parser.processSync(selectors);
31
57
  return result;
32
58
  }
33
59
  function resolveArbitraryValue(modifier, validate) {
@@ -38,25 +64,24 @@ function resolveArbitraryValue(modifier, validate) {
38
64
  if (!validate(value)) {
39
65
  return undefined;
40
66
  }
41
- return (0, _dataTypes).normalize(value);
67
+ return (0, _dataTypes.normalize)(value);
42
68
  }
43
69
  function asNegativeValue(modifier, lookup = {}, validate) {
44
70
  let positiveValue = lookup[modifier];
45
71
  if (positiveValue !== undefined) {
46
- return (0, _negateValue).default(positiveValue);
72
+ return (0, _negateValue.default)(positiveValue);
47
73
  }
48
74
  if (isArbitraryValue(modifier)) {
49
75
  let resolved = resolveArbitraryValue(modifier, validate);
50
76
  if (resolved === undefined) {
51
77
  return undefined;
52
78
  }
53
- return (0, _negateValue).default(resolved);
79
+ return (0, _negateValue.default)(resolved);
54
80
  }
55
81
  }
56
- function asValue(modifier, options = {}, { validate =()=>true
57
- } = {}) {
58
- var ref;
59
- let value = (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
82
+ function asValue(modifier, options = {}, { validate =()=>true } = {}) {
83
+ var _options_values;
84
+ let value = (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
60
85
  if (value !== undefined) {
61
86
  return value;
62
87
  }
@@ -68,11 +93,22 @@ function asValue(modifier, options = {}, { validate =()=>true
68
93
  function isArbitraryValue(input) {
69
94
  return input.startsWith("[") && input.endsWith("]");
70
95
  }
71
- function splitAlpha(modifier) {
96
+ function splitUtilityModifier(modifier) {
72
97
  let slashIdx = modifier.lastIndexOf("/");
73
98
  if (slashIdx === -1 || slashIdx === modifier.length - 1) {
74
99
  return [
75
- modifier
100
+ modifier,
101
+ undefined
102
+ ];
103
+ }
104
+ let arbitrary = isArbitraryValue(modifier);
105
+ // The modifier could be of the form `[foo]/[bar]`
106
+ // We want to handle this case properly
107
+ // without affecting `[foo/bar]`
108
+ if (arbitrary && !modifier.includes("]/[")) {
109
+ return [
110
+ modifier,
111
+ undefined
76
112
  ];
77
113
  }
78
114
  return [
@@ -80,35 +116,52 @@ function splitAlpha(modifier) {
80
116
  modifier.slice(slashIdx + 1)
81
117
  ];
82
118
  }
119
+ function parseColorFormat(value) {
120
+ if (typeof value === "string" && value.includes("<alpha-value>")) {
121
+ let oldValue = value;
122
+ return ({ opacityValue =1 })=>oldValue.replace("<alpha-value>", opacityValue);
123
+ }
124
+ return value;
125
+ }
126
+ function unwrapArbitraryModifier(modifier) {
127
+ modifier = modifier.slice(1, -1);
128
+ if (modifier.startsWith("--")) {
129
+ modifier = `var(${modifier})`;
130
+ }
131
+ return modifier;
132
+ }
83
133
  function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
84
- var ref;
85
- if (((ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier]) !== undefined) {
86
- var ref1;
87
- return (ref1 = options.values) === null || ref1 === void 0 ? void 0 : ref1[modifier];
134
+ var _options_values;
135
+ if (((_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier]) !== undefined) {
136
+ var _options_values1;
137
+ return parseColorFormat((_options_values1 = options.values) === null || _options_values1 === void 0 ? void 0 : _options_values1[modifier]);
88
138
  }
89
- let [color, alpha] = splitAlpha(modifier);
139
+ // TODO: Hoist this up to getMatchingTypes or something
140
+ // We do this here because we need the alpha value (if any)
141
+ let [color, alpha] = splitUtilityModifier(modifier);
90
142
  if (alpha !== undefined) {
91
- var ref2, ref3, ref4;
92
- var ref5;
93
- 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;
143
+ var _options_values2, _tailwindConfig_theme, _tailwindConfig_theme_opacity;
144
+ var _options_values_color;
145
+ let normalizedColor = (_options_values_color = (_options_values2 = options.values) === null || _options_values2 === void 0 ? void 0 : _options_values2[color]) !== null && _options_values_color !== void 0 ? _options_values_color : isArbitraryValue(color) ? color.slice(1, -1) : undefined;
94
146
  if (normalizedColor === undefined) {
95
147
  return undefined;
96
148
  }
149
+ normalizedColor = parseColorFormat(normalizedColor);
97
150
  if (isArbitraryValue(alpha)) {
98
- return (0, _withAlphaVariable).withAlphaValue(normalizedColor, alpha.slice(1, -1));
151
+ return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, unwrapArbitraryModifier(alpha));
99
152
  }
100
- if (((ref3 = tailwindConfig.theme) === null || ref3 === void 0 ? void 0 : (ref4 = ref3.opacity) === null || ref4 === void 0 ? void 0 : ref4[alpha]) === undefined) {
153
+ if (((_tailwindConfig_theme = tailwindConfig.theme) === null || _tailwindConfig_theme === void 0 ? void 0 : (_tailwindConfig_theme_opacity = _tailwindConfig_theme.opacity) === null || _tailwindConfig_theme_opacity === void 0 ? void 0 : _tailwindConfig_theme_opacity[alpha]) === undefined) {
101
154
  return undefined;
102
155
  }
103
- return (0, _withAlphaVariable).withAlphaValue(normalizedColor, tailwindConfig.theme.opacity[alpha]);
156
+ return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, tailwindConfig.theme.opacity[alpha]);
104
157
  }
105
158
  return asValue(modifier, options, {
106
159
  validate: _dataTypes.color
107
160
  });
108
161
  }
109
162
  function asLookupValue(modifier, options = {}) {
110
- var ref;
111
- return (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
163
+ var _options_values;
164
+ return (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
112
165
  }
113
166
  function guess(validate) {
114
167
  return (modifier, options)=>{
@@ -132,7 +185,8 @@ let typeMap = {
132
185
  "line-width": guess(_dataTypes.lineWidth),
133
186
  "absolute-size": guess(_dataTypes.absoluteSize),
134
187
  "relative-size": guess(_dataTypes.relativeSize),
135
- shadow: guess(_dataTypes.shadow)
188
+ shadow: guess(_dataTypes.shadow),
189
+ size: guess(_validateFormalSyntax.backgroundSize)
136
190
  };
137
191
  let supportedTypes = Object.keys(typeMap);
138
192
  function splitAtFirst(input, delim) {
@@ -147,6 +201,21 @@ function splitAtFirst(input, delim) {
147
201
  ];
148
202
  }
149
203
  function coerceValue(types, modifier, options, tailwindConfig) {
204
+ if (options.values && modifier in options.values) {
205
+ for (let { type } of types !== null && types !== void 0 ? types : []){
206
+ let result = typeMap[type](modifier, options, {
207
+ tailwindConfig
208
+ });
209
+ if (result === undefined) {
210
+ continue;
211
+ }
212
+ return [
213
+ result,
214
+ type,
215
+ null
216
+ ];
217
+ }
218
+ }
150
219
  if (isArbitraryValue(modifier)) {
151
220
  let arbitraryValue = modifier.slice(1, -1);
152
221
  let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
@@ -161,19 +230,54 @@ function coerceValue(types, modifier, options, tailwindConfig) {
161
230
  if (value.length > 0 && supportedTypes.includes(explicitType)) {
162
231
  return [
163
232
  asValue(`[${value}]`, options),
164
- explicitType
233
+ explicitType,
234
+ null
165
235
  ];
166
236
  }
167
237
  }
238
+ let matches = getMatchingTypes(types, modifier, options, tailwindConfig);
168
239
  // Find first matching type
169
- for (let type of [].concat(types)){
240
+ for (let match of matches){
241
+ return match;
242
+ }
243
+ return [];
244
+ }
245
+ function* getMatchingTypes(types, rawModifier, options, tailwindConfig) {
246
+ let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
247
+ let [modifier, utilityModifier] = splitUtilityModifier(rawModifier);
248
+ let canUseUtilityModifier = modifiersEnabled && options.modifiers != null && (options.modifiers === "any" || typeof options.modifiers === "object" && (utilityModifier && isArbitraryValue(utilityModifier) || utilityModifier in options.modifiers));
249
+ if (!canUseUtilityModifier) {
250
+ modifier = rawModifier;
251
+ utilityModifier = undefined;
252
+ }
253
+ if (utilityModifier !== undefined && modifier === "") {
254
+ modifier = "DEFAULT";
255
+ }
256
+ // Check the full value first
257
+ // TODO: Move to asValue… somehow
258
+ if (utilityModifier !== undefined) {
259
+ if (typeof options.modifiers === "object") {
260
+ var _options_modifiers;
261
+ var _options_modifiers_utilityModifier;
262
+ let configValue = (_options_modifiers_utilityModifier = (_options_modifiers = options.modifiers) === null || _options_modifiers === void 0 ? void 0 : _options_modifiers[utilityModifier]) !== null && _options_modifiers_utilityModifier !== void 0 ? _options_modifiers_utilityModifier : null;
263
+ if (configValue !== null) {
264
+ utilityModifier = configValue;
265
+ } else if (isArbitraryValue(utilityModifier)) {
266
+ utilityModifier = unwrapArbitraryModifier(utilityModifier);
267
+ }
268
+ }
269
+ }
270
+ for (let { type } of types !== null && types !== void 0 ? types : []){
170
271
  let result = typeMap[type](modifier, options, {
171
272
  tailwindConfig
172
273
  });
173
- if (result !== undefined) return [
274
+ if (result === undefined) {
275
+ continue;
276
+ }
277
+ yield [
174
278
  result,
175
- type
279
+ type,
280
+ utilityModifier !== null && utilityModifier !== void 0 ? utilityModifier : null
176
281
  ];
177
282
  }
178
- return [];
179
283
  }
@@ -2,19 +2,36 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = _default;
6
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
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"));
7
21
  function _interopRequireDefault(obj) {
8
22
  return obj && obj.__esModule ? obj : {
9
23
  default: obj
10
24
  };
11
25
  }
12
26
  function _default(prefix, selector, prependNegative = false) {
13
- return (0, _postcssSelectorParser).default((selectors)=>{
14
- selectors.walkClasses((classSelector)=>{
15
- let baseClass = classSelector.value;
16
- let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
17
- classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
18
- });
19
- }).processSync(selector);
27
+ if (prefix === "") {
28
+ return selector;
29
+ }
30
+ let ast = typeof selector === "string" ? (0, _postcssSelectorParser.default)().astSync(selector) : selector;
31
+ ast.walkClasses((classSelector)=>{
32
+ let baseClass = classSelector.value;
33
+ let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
34
+ classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
35
+ });
36
+ return typeof selector === "string" ? ast.toString() : ast;
20
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
+ }