tailwindcss 0.0.0-insiders.fe08e91 → 0.0.0-oxide.956419c

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 (186) hide show
  1. package/CHANGELOG.md +384 -3
  2. package/LICENSE +1 -2
  3. package/README.md +12 -8
  4. package/colors.d.ts +3 -0
  5. package/defaultConfig.d.ts +3 -0
  6. package/defaultTheme.d.ts +4 -0
  7. package/lib/cli/build/deps.js +54 -0
  8. package/lib/cli/build/index.js +48 -0
  9. package/lib/cli/build/plugin.js +367 -0
  10. package/lib/cli/build/utils.js +78 -0
  11. package/lib/cli/build/watching.js +178 -0
  12. package/lib/cli/help/index.js +71 -0
  13. package/lib/cli/index.js +239 -0
  14. package/lib/cli/init/index.js +46 -0
  15. package/lib/cli/shared.js +13 -0
  16. package/lib/cli-peer-dependencies.js +20 -7
  17. package/lib/cli.js +4 -740
  18. package/lib/constants.js +27 -20
  19. package/lib/corePluginList.js +6 -3
  20. package/lib/corePlugins.js +2064 -1811
  21. package/lib/css/preflight.css +5 -5
  22. package/lib/featureFlags.js +31 -22
  23. package/lib/index.js +4 -28
  24. package/lib/lib/cacheInvalidation.js +90 -0
  25. package/lib/lib/collapseAdjacentRules.js +27 -9
  26. package/lib/lib/collapseDuplicateDeclarations.js +12 -9
  27. package/lib/lib/content.js +176 -0
  28. package/lib/lib/defaultExtractor.js +225 -31
  29. package/lib/lib/detectNesting.js +13 -10
  30. package/lib/lib/evaluateTailwindFunctions.js +118 -55
  31. package/lib/lib/expandApplyAtRules.js +439 -190
  32. package/lib/lib/expandTailwindAtRules.js +151 -134
  33. package/lib/lib/findAtConfigPath.js +44 -0
  34. package/lib/lib/generateRules.js +454 -187
  35. package/lib/lib/getModuleDependencies.js +11 -8
  36. package/lib/lib/normalizeTailwindDirectives.js +36 -32
  37. package/lib/lib/offsets.js +217 -0
  38. package/lib/lib/partitionApplyAtRules.js +56 -0
  39. package/lib/lib/regex.js +60 -0
  40. package/lib/lib/resolveDefaultsAtRules.js +89 -67
  41. package/lib/lib/setupContextUtils.js +667 -376
  42. package/lib/lib/setupTrackingContext.js +38 -67
  43. package/lib/lib/sharedState.js +27 -14
  44. package/lib/lib/substituteScreenAtRules.js +11 -9
  45. package/lib/oxide/cli.d.js +1 -0
  46. package/lib/oxide/cli.js +2 -0
  47. package/lib/oxide/postcss-plugin.d.js +1 -0
  48. package/lib/oxide/postcss-plugin.js +2 -0
  49. package/lib/plugin.js +48 -0
  50. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  51. package/lib/postcss-plugins/nesting/index.js +19 -0
  52. package/lib/postcss-plugins/nesting/plugin.js +87 -0
  53. package/lib/processTailwindFeatures.js +35 -25
  54. package/lib/public/colors.js +247 -245
  55. package/lib/public/create-plugin.js +6 -4
  56. package/lib/public/default-config.js +7 -5
  57. package/lib/public/default-theme.js +7 -5
  58. package/lib/public/resolve-config.js +8 -5
  59. package/lib/util/bigSign.js +4 -1
  60. package/lib/util/buildMediaQuery.js +11 -6
  61. package/lib/util/cloneDeep.js +7 -6
  62. package/lib/util/cloneNodes.js +21 -3
  63. package/lib/util/color.js +53 -54
  64. package/lib/util/configurePlugins.js +5 -2
  65. package/lib/util/createPlugin.js +6 -6
  66. package/lib/util/createUtilityPlugin.js +12 -14
  67. package/lib/util/dataTypes.js +119 -110
  68. package/lib/util/defaults.js +4 -1
  69. package/lib/util/escapeClassName.js +7 -4
  70. package/lib/util/escapeCommas.js +5 -2
  71. package/lib/util/flattenColorPalette.js +9 -12
  72. package/lib/util/formatVariantSelector.js +184 -85
  73. package/lib/util/getAllConfigs.js +27 -8
  74. package/lib/util/hashConfig.js +6 -3
  75. package/lib/util/isKeyframeRule.js +5 -2
  76. package/lib/util/isPlainObject.js +5 -2
  77. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +23 -15
  78. package/lib/util/log.js +20 -14
  79. package/lib/util/nameClass.js +20 -9
  80. package/lib/util/negateValue.js +23 -8
  81. package/lib/util/normalizeConfig.js +116 -72
  82. package/lib/util/normalizeScreens.js +120 -11
  83. package/lib/util/parseAnimationValue.js +42 -40
  84. package/lib/util/parseBoxShadowValue.js +30 -23
  85. package/lib/util/parseDependency.js +38 -56
  86. package/lib/util/parseGlob.js +34 -0
  87. package/lib/util/parseObjectStyles.js +11 -8
  88. package/lib/util/pluginUtils.js +147 -50
  89. package/lib/util/prefixSelector.js +10 -8
  90. package/lib/util/removeAlphaVariables.js +29 -0
  91. package/lib/util/resolveConfig.js +97 -85
  92. package/lib/util/resolveConfigPath.js +11 -9
  93. package/lib/util/responsive.js +8 -5
  94. package/lib/util/splitAtTopLevelOnly.js +43 -0
  95. package/lib/util/tap.js +4 -1
  96. package/lib/util/toColorValue.js +5 -3
  97. package/lib/util/toPath.js +20 -4
  98. package/lib/util/transformThemeValue.js +37 -29
  99. package/lib/util/validateConfig.js +24 -0
  100. package/lib/util/validateFormalSyntax.js +24 -0
  101. package/lib/util/withAlphaVariable.js +23 -15
  102. package/nesting/index.js +2 -12
  103. package/package.json +50 -45
  104. package/peers/index.js +11381 -7950
  105. package/plugin.d.ts +11 -0
  106. package/resolveConfig.d.ts +12 -0
  107. package/scripts/generate-types.js +105 -0
  108. package/scripts/release-channel.js +18 -0
  109. package/scripts/release-notes.js +21 -0
  110. package/scripts/type-utils.js +27 -0
  111. package/src/cli/build/deps.js +56 -0
  112. package/src/cli/build/index.js +49 -0
  113. package/src/cli/build/plugin.js +439 -0
  114. package/src/cli/build/utils.js +76 -0
  115. package/src/cli/build/watching.js +227 -0
  116. package/src/cli/help/index.js +70 -0
  117. package/src/cli/index.js +234 -0
  118. package/src/cli/init/index.js +50 -0
  119. package/src/cli/shared.js +6 -0
  120. package/src/cli-peer-dependencies.js +7 -1
  121. package/src/cli.js +4 -810
  122. package/src/corePluginList.js +1 -1
  123. package/src/corePlugins.js +532 -217
  124. package/src/css/preflight.css +5 -5
  125. package/src/featureFlags.js +15 -9
  126. package/src/index.js +4 -27
  127. package/src/lib/cacheInvalidation.js +52 -0
  128. package/src/lib/collapseAdjacentRules.js +21 -2
  129. package/src/lib/content.js +212 -0
  130. package/src/lib/defaultExtractor.js +196 -33
  131. package/src/lib/evaluateTailwindFunctions.js +78 -7
  132. package/src/lib/expandApplyAtRules.js +482 -183
  133. package/src/lib/expandTailwindAtRules.js +106 -85
  134. package/src/lib/findAtConfigPath.js +48 -0
  135. package/src/lib/generateRules.js +418 -129
  136. package/src/lib/normalizeTailwindDirectives.js +1 -0
  137. package/src/lib/offsets.js +270 -0
  138. package/src/lib/partitionApplyAtRules.js +52 -0
  139. package/src/lib/regex.js +74 -0
  140. package/src/lib/resolveDefaultsAtRules.js +51 -30
  141. package/src/lib/setupContextUtils.js +556 -208
  142. package/src/lib/setupTrackingContext.js +11 -48
  143. package/src/lib/sharedState.js +5 -0
  144. package/src/oxide/cli.d.ts +0 -0
  145. package/src/oxide/cli.ts +1 -0
  146. package/src/oxide/postcss-plugin.d.ts +0 -0
  147. package/src/oxide/postcss-plugin.ts +1 -0
  148. package/src/plugin.js +47 -0
  149. package/src/postcss-plugins/nesting/README.md +42 -0
  150. package/src/postcss-plugins/nesting/index.js +13 -0
  151. package/src/postcss-plugins/nesting/plugin.js +80 -0
  152. package/src/processTailwindFeatures.js +8 -0
  153. package/src/util/buildMediaQuery.js +5 -3
  154. package/src/util/cloneNodes.js +19 -2
  155. package/src/util/color.js +25 -21
  156. package/src/util/dataTypes.js +29 -21
  157. package/src/util/formatVariantSelector.js +184 -61
  158. package/src/util/getAllConfigs.js +19 -0
  159. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  160. package/src/util/log.js +8 -8
  161. package/src/util/nameClass.js +4 -0
  162. package/src/util/negateValue.js +11 -3
  163. package/src/util/normalizeConfig.js +44 -6
  164. package/src/util/normalizeScreens.js +99 -4
  165. package/src/util/parseBoxShadowValue.js +4 -3
  166. package/src/util/parseDependency.js +37 -42
  167. package/src/util/parseGlob.js +24 -0
  168. package/src/util/pluginUtils.js +132 -10
  169. package/src/util/prefixSelector.js +7 -5
  170. package/src/util/removeAlphaVariables.js +24 -0
  171. package/src/util/resolveConfig.js +70 -32
  172. package/src/util/splitAtTopLevelOnly.js +45 -0
  173. package/src/util/toPath.js +1 -1
  174. package/src/util/transformThemeValue.js +13 -3
  175. package/src/util/validateConfig.js +13 -0
  176. package/src/util/validateFormalSyntax.js +34 -0
  177. package/src/util/withAlphaVariable.js +1 -1
  178. package/stubs/defaultConfig.stub.js +167 -164
  179. package/stubs/simpleConfig.stub.js +1 -0
  180. package/types/config.d.ts +362 -0
  181. package/types/generated/.gitkeep +0 -0
  182. package/types/generated/colors.d.ts +276 -0
  183. package/types/generated/corePluginList.d.ts +1 -0
  184. package/types/generated/default-theme.d.ts +342 -0
  185. package/types/index.d.ts +7 -0
  186. package/nesting/plugin.js +0 -41
@@ -2,22 +2,29 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.parseBoxShadowValue = parseBoxShadowValue;
6
- exports.formatBoxShadowValue = formatBoxShadowValue;
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
+ parseBoxShadowValue: ()=>parseBoxShadowValue,
13
+ formatBoxShadowValue: ()=>formatBoxShadowValue
14
+ });
15
+ const _splitAtTopLevelOnly = require("./splitAtTopLevelOnly");
7
16
  let KEYWORDS = new Set([
8
- 'inset',
9
- 'inherit',
10
- 'initial',
11
- 'revert',
12
- 'unset'
17
+ "inset",
18
+ "inherit",
19
+ "initial",
20
+ "revert",
21
+ "unset"
13
22
  ]);
14
- let COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
15
- ;
16
23
  let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
17
24
  ;
18
- let LENGTH = /^-?(\d+)(.*?)$/g;
25
+ let LENGTH = /^-?(\d+|\.\d+)(.*?)$/g;
19
26
  function parseBoxShadowValue(input) {
20
- let shadows = input.split(COMMA);
27
+ let shadows = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(input, ",");
21
28
  return shadows.map((shadow)=>{
22
29
  let value = shadow.trim();
23
30
  let result = {
@@ -29,22 +36,22 @@ function parseBoxShadowValue(input) {
29
36
  // Reset index, since the regex is stateful.
30
37
  LENGTH.lastIndex = 0;
31
38
  // Keyword
32
- if (!seen.has('KEYWORD') && KEYWORDS.has(part)) {
39
+ if (!seen.has("KEYWORD") && KEYWORDS.has(part)) {
33
40
  result.keyword = part;
34
- seen.add('KEYWORD');
41
+ seen.add("KEYWORD");
35
42
  } else if (LENGTH.test(part)) {
36
- if (!seen.has('X')) {
43
+ if (!seen.has("X")) {
37
44
  result.x = part;
38
- seen.add('X');
39
- } else if (!seen.has('Y')) {
45
+ seen.add("X");
46
+ } else if (!seen.has("Y")) {
40
47
  result.y = part;
41
- seen.add('Y');
42
- } else if (!seen.has('BLUR')) {
48
+ seen.add("Y");
49
+ } else if (!seen.has("BLUR")) {
43
50
  result.blur = part;
44
- seen.add('BLUR');
45
- } else if (!seen.has('SPREAD')) {
51
+ seen.add("BLUR");
52
+ } else if (!seen.has("SPREAD")) {
46
53
  result.spread = part;
47
- seen.add('SPREAD');
54
+ seen.add("SPREAD");
48
55
  }
49
56
  } else {
50
57
  if (!result.color) {
@@ -72,6 +79,6 @@ function formatBoxShadowValue(shadows) {
72
79
  shadow.blur,
73
80
  shadow.spread,
74
81
  shadow.color
75
- ].filter(Boolean).join(' ');
76
- }).join(', ');
82
+ ].filter(Boolean).join(" ");
83
+ }).join(", ");
77
84
  }
@@ -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 _interopRequireDefault(obj) {
10
- return obj && obj.__esModule ? obj : {
11
- default: obj
12
- };
13
- }
14
- // Based on `glob-base`
15
- // https://github.com/micromatch/glob-base/blob/master/index.js
16
- function parseGlob(pattern) {
17
- let glob = pattern;
18
- let base = (0, _globParent).default(pattern);
19
- if (base !== '.') {
20
- glob = pattern.substr(base.length);
21
- if (glob.charAt(0) === '/') {
22
- glob = glob.substr(1);
23
- }
24
- }
25
- if (glob.substr(0, 2) === './') {
26
- glob = glob.substr(2);
27
- }
28
- if (glob.charAt(0) === '/') {
29
- glob = glob.substr(1);
30
- }
31
- return {
32
- base,
33
- glob
34
- };
35
- }
36
- function parseDependency(normalizedFileOrGlob) {
37
- if (normalizedFileOrGlob.startsWith('!')) {
38
- return null;
12
+ Object.defineProperty(exports, "default", {
13
+ enumerable: true,
14
+ get: ()=>parseDependency
15
+ });
16
+ function parseDependency(contentPath) {
17
+ if (contentPath.ignore) {
18
+ return [];
39
19
  }
40
- let message;
41
- if ((0, _isGlob).default(normalizedFileOrGlob)) {
42
- let { base , glob } = parseGlob(normalizedFileOrGlob);
43
- message = {
44
- type: 'dir-dependency',
45
- dir: _path.default.resolve(base),
46
- glob
47
- };
48
- } else {
49
- message = {
50
- type: 'dependency',
51
- file: _path.default.resolve(normalizedFileOrGlob)
52
- };
20
+ if (!contentPath.glob) {
21
+ return [
22
+ {
23
+ type: "dependency",
24
+ file: contentPath.base
25
+ }
26
+ ];
53
27
  }
54
- // rollup-plugin-postcss does not support dir-dependency messages
55
- // but directories can be watched in the same way as files
56
- if (message.type === 'dir-dependency' && process.env.ROLLUP_WATCH === 'true') {
57
- message = {
58
- type: 'dependency',
59
- file: message.dir
60
- };
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
+ ];
61
37
  }
62
- return message;
38
+ return [
39
+ {
40
+ type: "dir-dependency",
41
+ dir: contentPath.base,
42
+ glob: contentPath.glob
43
+ }
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,13 @@
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"));
9
12
  function _interopRequireDefault(obj) {
10
13
  return obj && obj.__esModule ? obj : {
11
14
  default: obj
@@ -18,12 +21,12 @@ function parseObjectStyles(styles) {
18
21
  ]);
19
22
  }
20
23
  return styles.flatMap((style)=>{
21
- return (0, _postcss).default([
22
- (0, _postcssNested).default({
24
+ return (0, _postcss.default)([
25
+ (0, _postcssNested.default)({
23
26
  bubble: [
24
- 'screen'
27
+ "screen"
25
28
  ]
26
- }),
29
+ })
27
30
  ]).process(style, {
28
31
  parser: _postcssJs.default
29
32
  }).root.nodes;
@@ -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,44 +64,51 @@ 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
- function asNegativeValue(modifier, lookup = {
44
- }, validate) {
69
+ function asNegativeValue(modifier, lookup = {}, validate) {
45
70
  let positiveValue = lookup[modifier];
46
71
  if (positiveValue !== undefined) {
47
- return (0, _negateValue).default(positiveValue);
72
+ return (0, _negateValue.default)(positiveValue);
48
73
  }
49
74
  if (isArbitraryValue(modifier)) {
50
75
  let resolved = resolveArbitraryValue(modifier, validate);
51
76
  if (resolved === undefined) {
52
77
  return undefined;
53
78
  }
54
- return (0, _negateValue).default(resolved);
79
+ return (0, _negateValue.default)(resolved);
55
80
  }
56
81
  }
57
- function asValue(modifier, options = {
58
- }, { validate =()=>true
59
- } = {
60
- }) {
82
+ function asValue(modifier, options = {}, { validate =()=>true } = {}) {
61
83
  var ref;
62
84
  let value = (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
63
85
  if (value !== undefined) {
64
86
  return value;
65
87
  }
66
- if (options.supportsNegativeValues && modifier.startsWith('-')) {
88
+ if (options.supportsNegativeValues && modifier.startsWith("-")) {
67
89
  return asNegativeValue(modifier.slice(1), options.values, validate);
68
90
  }
69
91
  return resolveArbitraryValue(modifier, validate);
70
92
  }
71
93
  function isArbitraryValue(input) {
72
- return input.startsWith('[') && input.endsWith(']');
94
+ return input.startsWith("[") && input.endsWith("]");
73
95
  }
74
- function splitAlpha(modifier) {
75
- let slashIdx = modifier.lastIndexOf('/');
96
+ function splitUtilityModifier(modifier) {
97
+ let slashIdx = modifier.lastIndexOf("/");
76
98
  if (slashIdx === -1 || slashIdx === modifier.length - 1) {
77
99
  return [
78
- 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
79
112
  ];
80
113
  }
81
114
  return [
@@ -83,16 +116,29 @@ function splitAlpha(modifier) {
83
116
  modifier.slice(slashIdx + 1)
84
117
  ];
85
118
  }
86
- function asColor(modifier, options = {
87
- }, { tailwindConfig ={
88
- } } = {
89
- }) {
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
+ }
133
+ function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
90
134
  var ref;
91
135
  if (((ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier]) !== undefined) {
92
136
  var ref1;
93
- return (ref1 = options.values) === null || ref1 === void 0 ? void 0 : ref1[modifier];
137
+ return parseColorFormat((ref1 = options.values) === null || ref1 === void 0 ? void 0 : ref1[modifier]);
94
138
  }
95
- 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);
96
142
  if (alpha !== undefined) {
97
143
  var ref2, ref3, ref4;
98
144
  var ref5;
@@ -100,20 +146,20 @@ function asColor(modifier, options = {
100
146
  if (normalizedColor === undefined) {
101
147
  return undefined;
102
148
  }
149
+ normalizedColor = parseColorFormat(normalizedColor);
103
150
  if (isArbitraryValue(alpha)) {
104
- return (0, _withAlphaVariable).withAlphaValue(normalizedColor, alpha.slice(1, -1));
151
+ return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, unwrapArbitraryModifier(alpha));
105
152
  }
106
153
  if (((ref3 = tailwindConfig.theme) === null || ref3 === void 0 ? void 0 : (ref4 = ref3.opacity) === null || ref4 === void 0 ? void 0 : ref4[alpha]) === undefined) {
107
154
  return undefined;
108
155
  }
109
- return (0, _withAlphaVariable).withAlphaValue(normalizedColor, tailwindConfig.theme.opacity[alpha]);
156
+ return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, tailwindConfig.theme.opacity[alpha]);
110
157
  }
111
158
  return asValue(modifier, options, {
112
159
  validate: _dataTypes.color
113
160
  });
114
161
  }
115
- function asLookupValue(modifier, options = {
116
- }) {
162
+ function asLookupValue(modifier, options = {}) {
117
163
  var ref;
118
164
  return (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
119
165
  }
@@ -133,13 +179,14 @@ let typeMap = {
133
179
  percentage: guess(_dataTypes.percentage),
134
180
  position: guess(_dataTypes.position),
135
181
  lookup: asLookupValue,
136
- 'generic-name': guess(_dataTypes.genericName),
137
- 'family-name': guess(_dataTypes.familyName),
182
+ "generic-name": guess(_dataTypes.genericName),
183
+ "family-name": guess(_dataTypes.familyName),
138
184
  number: guess(_dataTypes.number),
139
- 'line-width': guess(_dataTypes.lineWidth),
140
- 'absolute-size': guess(_dataTypes.absoluteSize),
141
- 'relative-size': guess(_dataTypes.relativeSize),
142
- shadow: guess(_dataTypes.shadow)
185
+ "line-width": guess(_dataTypes.lineWidth),
186
+ "absolute-size": guess(_dataTypes.absoluteSize),
187
+ "relative-size": guess(_dataTypes.relativeSize),
188
+ shadow: guess(_dataTypes.shadow),
189
+ size: guess(_validateFormalSyntax.backgroundSize)
143
190
  };
144
191
  let supportedTypes = Object.keys(typeMap);
145
192
  function splitAtFirst(input, delim) {
@@ -154,9 +201,24 @@ function splitAtFirst(input, delim) {
154
201
  ];
155
202
  }
156
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
+ }
157
219
  if (isArbitraryValue(modifier)) {
158
220
  let arbitraryValue = modifier.slice(1, -1);
159
- let [explicitType, value] = splitAtFirst(arbitraryValue, ':');
221
+ let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
160
222
  // It could be that this resolves to `url(https` which is not a valid
161
223
  // identifier. We currently only support "simple" words with dashes or
162
224
  // underscores. E.g.: family-name
@@ -168,19 +230,54 @@ function coerceValue(types, modifier, options, tailwindConfig) {
168
230
  if (value.length > 0 && supportedTypes.includes(explicitType)) {
169
231
  return [
170
232
  asValue(`[${value}]`, options),
171
- explicitType
233
+ explicitType,
234
+ null
172
235
  ];
173
236
  }
174
237
  }
238
+ let matches = getMatchingTypes(types, modifier, options, tailwindConfig);
175
239
  // Find first matching type
176
- 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 ref;
261
+ var ref1;
262
+ let configValue = (ref1 = (ref = options.modifiers) === null || ref === void 0 ? void 0 : ref[utilityModifier]) !== null && ref1 !== void 0 ? ref1 : null;
263
+ if (configValue !== null) {
264
+ utilityModifier = configValue;
265
+ } else if (isArbitraryValue(utilityModifier)) {
266
+ utilityModifier = unwrapArbitraryModifier(utilityModifier);
267
+ }
268
+ }
269
+ }
270
+ for (let { type } of types !== null && types !== void 0 ? types : []){
177
271
  let result = typeMap[type](modifier, options, {
178
272
  tailwindConfig
179
273
  });
180
- if (result !== undefined) return [
274
+ if (result === undefined) {
275
+ continue;
276
+ }
277
+ yield [
181
278
  result,
182
- type
279
+ type,
280
+ utilityModifier !== null && utilityModifier !== void 0 ? utilityModifier : null
183
281
  ];
184
282
  }
185
- return [];
186
283
  }
@@ -2,20 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = _default;
6
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
7
- var _tap = require("./tap");
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>_default
8
+ });
9
+ const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
8
10
  function _interopRequireDefault(obj) {
9
11
  return obj && obj.__esModule ? obj : {
10
12
  default: obj
11
13
  };
12
14
  }
13
- function _default(prefix, selector) {
14
- return (0, _postcssSelectorParser).default((selectors)=>{
15
+ function _default(prefix, selector, prependNegative = false) {
16
+ return (0, _postcssSelectorParser.default)((selectors)=>{
15
17
  selectors.walkClasses((classSelector)=>{
16
- (0, _tap).tap(classSelector.value, (baseClass)=>{
17
- classSelector.value = `${prefix}${baseClass}`;
18
- });
18
+ let baseClass = classSelector.value;
19
+ let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
20
+ classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
19
21
  });
20
22
  }).processSync(selector);
21
23
  }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * This function removes any uses of CSS variables used as an alpha channel
3
+ *
4
+ * This is required for selectors like `:visited` which do not allow
5
+ * changes in opacity or external control using CSS variables.
6
+ *
7
+ * @param {import('postcss').Container} container
8
+ * @param {string[]} toRemove
9
+ */ "use strict";
10
+ Object.defineProperty(exports, "__esModule", {
11
+ value: true
12
+ });
13
+ Object.defineProperty(exports, "removeAlphaVariables", {
14
+ enumerable: true,
15
+ get: ()=>removeAlphaVariables
16
+ });
17
+ function removeAlphaVariables(container, toRemove) {
18
+ container.walkDecls((decl)=>{
19
+ if (toRemove.includes(decl.prop)) {
20
+ decl.remove();
21
+ return;
22
+ }
23
+ for (let varName of toRemove){
24
+ if (decl.value.includes(`/ var(${varName})`)) {
25
+ decl.value = decl.value.replace(`/ var(${varName})`, "");
26
+ }
27
+ }
28
+ });
29
+ }