tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.cb6e45a

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 (190) hide show
  1. package/CHANGELOG.md +526 -2
  2. package/LICENSE +1 -2
  3. package/README.md +13 -6
  4. package/colors.d.ts +3 -0
  5. package/colors.js +2 -1
  6. package/defaultConfig.d.ts +3 -0
  7. package/defaultConfig.js +2 -1
  8. package/defaultTheme.d.ts +4 -0
  9. package/defaultTheme.js +2 -1
  10. package/lib/cli/build/deps.js +54 -0
  11. package/lib/cli/build/index.js +44 -0
  12. package/lib/cli/build/plugin.js +335 -0
  13. package/lib/cli/build/utils.js +78 -0
  14. package/lib/cli/build/watching.js +113 -0
  15. package/lib/cli/help/index.js +71 -0
  16. package/lib/cli/index.js +18 -0
  17. package/lib/cli/init/index.js +46 -0
  18. package/lib/cli/shared.js +12 -0
  19. package/lib/cli-peer-dependencies.js +20 -7
  20. package/lib/cli.js +91 -569
  21. package/lib/constants.js +27 -20
  22. package/lib/corePluginList.js +16 -4
  23. package/lib/corePlugins.js +2247 -1873
  24. package/lib/css/preflight.css +20 -9
  25. package/lib/featureFlags.js +37 -23
  26. package/lib/index.js +28 -12
  27. package/lib/lib/cacheInvalidation.js +90 -0
  28. package/lib/lib/collapseAdjacentRules.js +27 -9
  29. package/lib/lib/collapseDuplicateDeclarations.js +83 -0
  30. package/lib/lib/content.js +167 -0
  31. package/lib/lib/defaultExtractor.js +236 -0
  32. package/lib/lib/detectNesting.js +21 -3
  33. package/lib/lib/evaluateTailwindFunctions.js +117 -50
  34. package/lib/lib/expandApplyAtRules.js +439 -160
  35. package/lib/lib/expandTailwindAtRules.js +141 -151
  36. package/lib/lib/findAtConfigPath.js +44 -0
  37. package/lib/lib/generateRules.js +572 -105
  38. package/lib/lib/getModuleDependencies.js +11 -8
  39. package/lib/lib/normalizeTailwindDirectives.js +45 -33
  40. package/lib/lib/offsets.js +217 -0
  41. package/lib/lib/partitionApplyAtRules.js +56 -0
  42. package/lib/lib/regex.js +60 -0
  43. package/lib/lib/resolveDefaultsAtRules.js +114 -81
  44. package/lib/lib/setupContextUtils.js +777 -385
  45. package/lib/lib/setupTrackingContext.js +43 -71
  46. package/lib/lib/sharedState.js +49 -18
  47. package/lib/lib/substituteScreenAtRules.js +13 -8
  48. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  49. package/lib/postcss-plugins/nesting/index.js +19 -0
  50. package/lib/postcss-plugins/nesting/plugin.js +87 -0
  51. package/lib/processTailwindFeatures.js +36 -21
  52. package/lib/public/colors.js +250 -252
  53. package/lib/public/create-plugin.js +6 -4
  54. package/lib/public/default-config.js +7 -5
  55. package/lib/public/default-theme.js +7 -5
  56. package/lib/public/resolve-config.js +8 -5
  57. package/lib/util/bigSign.js +4 -1
  58. package/lib/util/buildMediaQuery.js +18 -24
  59. package/lib/util/cloneDeep.js +7 -6
  60. package/lib/util/cloneNodes.js +21 -3
  61. package/lib/util/color.js +54 -40
  62. package/lib/util/configurePlugins.js +5 -2
  63. package/lib/util/createPlugin.js +6 -6
  64. package/lib/util/createUtilityPlugin.js +11 -13
  65. package/lib/util/dataTypes.js +137 -100
  66. package/lib/util/defaults.js +10 -1
  67. package/lib/util/escapeClassName.js +7 -4
  68. package/lib/util/escapeCommas.js +5 -2
  69. package/lib/util/flattenColorPalette.js +9 -12
  70. package/lib/util/formatVariantSelector.js +285 -0
  71. package/lib/util/getAllConfigs.js +27 -8
  72. package/lib/util/hashConfig.js +6 -3
  73. package/lib/util/isKeyframeRule.js +5 -2
  74. package/lib/util/isPlainObject.js +5 -2
  75. package/lib/util/isValidArbitraryValue.js +72 -0
  76. package/lib/util/log.js +44 -22
  77. package/lib/util/nameClass.js +20 -8
  78. package/lib/util/negateValue.js +23 -6
  79. package/lib/util/normalizeConfig.js +267 -0
  80. package/lib/util/normalizeScreens.js +170 -0
  81. package/lib/util/parseAnimationValue.js +42 -40
  82. package/lib/util/parseBoxShadowValue.js +84 -0
  83. package/lib/util/parseDependency.js +38 -56
  84. package/lib/util/parseGlob.js +34 -0
  85. package/lib/util/parseObjectStyles.js +11 -8
  86. package/lib/util/pluginUtils.js +171 -189
  87. package/lib/util/prefixSelector.js +10 -10
  88. package/lib/util/removeAlphaVariables.js +29 -0
  89. package/lib/util/resolveConfig.js +92 -126
  90. package/lib/util/resolveConfigPath.js +11 -9
  91. package/lib/util/responsive.js +8 -5
  92. package/lib/util/splitAtTopLevelOnly.js +43 -0
  93. package/lib/util/tap.js +4 -1
  94. package/lib/util/toColorValue.js +5 -3
  95. package/lib/util/toPath.js +24 -3
  96. package/lib/util/transformThemeValue.js +49 -31
  97. package/lib/util/validateConfig.js +24 -0
  98. package/lib/util/validateFormalSyntax.js +24 -0
  99. package/lib/util/withAlphaVariable.js +23 -15
  100. package/nesting/index.js +2 -12
  101. package/package.json +48 -46
  102. package/peers/index.js +14817 -12471
  103. package/plugin.d.ts +11 -0
  104. package/plugin.js +2 -1
  105. package/resolveConfig.d.ts +3 -0
  106. package/resolveConfig.js +2 -1
  107. package/scripts/create-plugin-list.js +2 -2
  108. package/scripts/generate-types.js +105 -0
  109. package/scripts/release-channel.js +18 -0
  110. package/scripts/release-notes.js +21 -0
  111. package/scripts/type-utils.js +27 -0
  112. package/src/cli/build/deps.js +56 -0
  113. package/src/cli/build/index.js +45 -0
  114. package/src/cli/build/plugin.js +397 -0
  115. package/src/cli/build/utils.js +76 -0
  116. package/src/cli/build/watching.js +134 -0
  117. package/src/cli/help/index.js +70 -0
  118. package/src/cli/index.js +3 -0
  119. package/src/cli/init/index.js +50 -0
  120. package/src/cli/shared.js +5 -0
  121. package/src/cli-peer-dependencies.js +7 -1
  122. package/src/cli.js +26 -565
  123. package/src/corePluginList.js +1 -1
  124. package/src/corePlugins.js +905 -615
  125. package/src/css/preflight.css +20 -9
  126. package/src/featureFlags.js +26 -10
  127. package/src/index.js +19 -6
  128. package/src/lib/cacheInvalidation.js +52 -0
  129. package/src/lib/collapseAdjacentRules.js +21 -2
  130. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  131. package/src/lib/content.js +205 -0
  132. package/src/lib/defaultExtractor.js +211 -0
  133. package/src/lib/detectNesting.js +22 -3
  134. package/src/lib/evaluateTailwindFunctions.js +84 -10
  135. package/src/lib/expandApplyAtRules.js +488 -153
  136. package/src/lib/expandTailwindAtRules.js +94 -106
  137. package/src/lib/findAtConfigPath.js +50 -0
  138. package/src/lib/generateRules.js +589 -67
  139. package/src/lib/normalizeTailwindDirectives.js +10 -3
  140. package/src/lib/offsets.js +270 -0
  141. package/src/lib/partitionApplyAtRules.js +52 -0
  142. package/src/lib/regex.js +74 -0
  143. package/src/lib/resolveDefaultsAtRules.js +98 -60
  144. package/src/lib/setupContextUtils.js +737 -246
  145. package/src/lib/setupTrackingContext.js +16 -54
  146. package/src/lib/sharedState.js +44 -7
  147. package/src/lib/substituteScreenAtRules.js +6 -3
  148. package/src/postcss-plugins/nesting/README.md +42 -0
  149. package/src/postcss-plugins/nesting/index.js +13 -0
  150. package/src/postcss-plugins/nesting/plugin.js +80 -0
  151. package/src/processTailwindFeatures.js +17 -2
  152. package/src/public/colors.js +4 -9
  153. package/src/util/buildMediaQuery.js +14 -16
  154. package/src/util/cloneNodes.js +19 -2
  155. package/src/util/color.js +31 -14
  156. package/src/util/createUtilityPlugin.js +2 -2
  157. package/src/util/dataTypes.js +57 -21
  158. package/src/util/defaults.js +6 -0
  159. package/src/util/formatVariantSelector.js +319 -0
  160. package/src/util/getAllConfigs.js +19 -0
  161. package/src/util/isValidArbitraryValue.js +61 -0
  162. package/src/util/log.js +23 -22
  163. package/src/util/nameClass.js +6 -2
  164. package/src/util/negateValue.js +14 -4
  165. package/src/util/normalizeConfig.js +282 -0
  166. package/src/util/normalizeScreens.js +140 -0
  167. package/src/util/parseBoxShadowValue.js +72 -0
  168. package/src/util/parseDependency.js +37 -42
  169. package/src/util/parseGlob.js +24 -0
  170. package/src/util/pluginUtils.js +144 -152
  171. package/src/util/prefixSelector.js +7 -8
  172. package/src/util/removeAlphaVariables.js +24 -0
  173. package/src/util/resolveConfig.js +82 -81
  174. package/src/util/splitAtTopLevelOnly.js +45 -0
  175. package/src/util/toPath.js +23 -1
  176. package/src/util/transformThemeValue.js +33 -8
  177. package/src/util/validateConfig.js +13 -0
  178. package/src/util/validateFormalSyntax.js +34 -0
  179. package/src/util/withAlphaVariable.js +1 -1
  180. package/stubs/defaultConfig.stub.js +173 -93
  181. package/stubs/simpleConfig.stub.js +1 -1
  182. package/types/config.d.ts +361 -0
  183. package/types/generated/.gitkeep +0 -0
  184. package/types/generated/colors.d.ts +276 -0
  185. package/types/generated/corePluginList.d.ts +1 -0
  186. package/types/generated/default-theme.d.ts +342 -0
  187. package/types/index.d.ts +7 -0
  188. package/lib/lib/setupWatchingContext.js +0 -284
  189. package/nesting/plugin.js +0 -41
  190. package/src/lib/setupWatchingContext.js +0 -306
@@ -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,189 +2,100 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.applyStateToMarker = applyStateToMarker;
6
- exports.updateAllClasses = updateAllClasses;
7
- exports.updateLastClasses = updateLastClasses;
8
- exports.transformAllSelectors = transformAllSelectors;
9
- exports.transformAllClasses = transformAllClasses;
10
- exports.transformLastClasses = transformLastClasses;
11
- exports.asValue = asValue;
12
- exports.asColor = asColor;
13
- exports.asLookupValue = asLookupValue;
14
- exports.coerceValue = coerceValue;
15
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
16
- var _escapeCommas = _interopRequireDefault(require("./escapeCommas"));
17
- var _withAlphaVariable = require("./withAlphaVariable");
18
- var _isKeyframeRule = _interopRequireDefault(require("./isKeyframeRule"));
19
- var _dataTypes = require("./dataTypes");
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
+ asValue: ()=>asValue,
14
+ parseColorFormat: ()=>parseColorFormat,
15
+ asColor: ()=>asColor,
16
+ asLookupValue: ()=>asLookupValue,
17
+ typeMap: ()=>typeMap,
18
+ coerceValue: ()=>coerceValue,
19
+ getMatchingTypes: ()=>getMatchingTypes
20
+ });
21
+ const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
22
+ const _escapeCommas = /*#__PURE__*/ _interopRequireDefault(require("./escapeCommas"));
23
+ const _withAlphaVariable = require("./withAlphaVariable");
24
+ const _dataTypes = require("./dataTypes");
25
+ const _negateValue = /*#__PURE__*/ _interopRequireDefault(require("./negateValue"));
26
+ const _validateFormalSyntax = require("./validateFormalSyntax");
27
+ const _featureFlagsJs = require("../featureFlags.js");
20
28
  function _interopRequireDefault(obj) {
21
29
  return obj && obj.__esModule ? obj : {
22
30
  default: obj
23
31
  };
24
32
  }
25
- function applyStateToMarker(selector, marker, state, join) {
26
- let markerIdx = selector.search(new RegExp(`${marker}[:[]`));
27
- if (markerIdx === -1) {
28
- return join(marker + state, selector);
29
- }
30
- let markerSelector = selector.slice(markerIdx, selector.indexOf(' ', markerIdx));
31
- return join(marker + state + markerSelector.slice(markerIdx + marker.length), selector.replace(markerSelector, ''));
32
- }
33
33
  function updateAllClasses(selectors, updateClass) {
34
- let parser = (0, _postcssSelectorParser).default((selectors)=>{
34
+ let parser = (0, _postcssSelectorParser.default)((selectors)=>{
35
35
  selectors.walkClasses((sel)=>{
36
- let updatedClass = updateClass(sel.value, {
37
- withAttr (className, attr) {
38
- sel.parent.insertAfter(sel, _postcssSelectorParser.default.attribute({
39
- attribute: attr.slice(1, -1)
40
- }));
41
- return className;
42
- },
43
- withPseudo (className, pseudo) {
44
- sel.parent.insertAfter(sel, _postcssSelectorParser.default.pseudo({
45
- value: pseudo
46
- }));
47
- return className;
48
- }
49
- });
36
+ let updatedClass = updateClass(sel.value);
50
37
  sel.value = updatedClass;
51
38
  if (sel.raws && sel.raws.value) {
52
- sel.raws.value = (0, _escapeCommas).default(sel.raws.value);
39
+ sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
53
40
  }
54
41
  });
55
42
  });
56
43
  let result = parser.processSync(selectors);
57
44
  return result;
58
45
  }
59
- function updateLastClasses(selectors, updateClass) {
60
- let parser = (0, _postcssSelectorParser).default((selectors)=>{
61
- selectors.each((sel)=>{
62
- let lastClass = sel.filter(({ type })=>type === 'class'
63
- ).pop();
64
- if (lastClass === undefined) {
65
- return;
66
- }
67
- let updatedClass = updateClass(lastClass.value, {
68
- withPseudo (className, pseudo) {
69
- lastClass.parent.insertAfter(lastClass, _postcssSelectorParser.default.pseudo({
70
- value: `${pseudo}`
71
- }));
72
- return className;
73
- }
74
- });
75
- lastClass.value = updatedClass;
76
- if (lastClass.raws && lastClass.raws.value) {
77
- lastClass.raws.value = (0, _escapeCommas).default(lastClass.raws.value);
78
- }
79
- });
80
- });
81
- let result = parser.processSync(selectors);
82
- return result;
83
- }
84
- function splitByNotEscapedCommas(str) {
85
- let chunks = [];
86
- let currentChunk = '';
87
- for(let i = 0; i < str.length; i++){
88
- if (str[i] === ',' && str[i - 1] !== '\\') {
89
- chunks.push(currentChunk);
90
- currentChunk = '';
91
- } else {
92
- currentChunk += str[i];
93
- }
46
+ function resolveArbitraryValue(modifier, validate) {
47
+ if (!isArbitraryValue(modifier)) {
48
+ return undefined;
94
49
  }
95
- chunks.push(currentChunk);
96
- return chunks;
97
- }
98
- function transformAllSelectors(transformSelector, { wrap , withRule } = {
99
- }) {
100
- return ({ container })=>{
101
- container.walkRules((rule)=>{
102
- if ((0, _isKeyframeRule).default(rule)) {
103
- return rule;
104
- }
105
- let transformed = splitByNotEscapedCommas(rule.selector).map(transformSelector).join(',');
106
- rule.selector = transformed;
107
- if (withRule) {
108
- withRule(rule);
109
- }
110
- return rule;
111
- });
112
- if (wrap) {
113
- let wrapper = wrap();
114
- let nodes = container.nodes;
115
- container.removeAll();
116
- wrapper.append(nodes);
117
- container.append(wrapper);
118
- }
119
- };
120
- }
121
- function transformAllClasses(transformClass, { wrap , withRule } = {
122
- }) {
123
- return ({ container })=>{
124
- container.walkRules((rule)=>{
125
- let selector = rule.selector;
126
- let variantSelector = updateAllClasses(selector, transformClass);
127
- rule.selector = variantSelector;
128
- if (withRule) {
129
- withRule(rule);
130
- }
131
- return rule;
132
- });
133
- if (wrap) {
134
- let wrapper = wrap();
135
- let nodes = container.nodes;
136
- container.removeAll();
137
- wrapper.append(nodes);
138
- container.append(wrapper);
139
- }
140
- };
50
+ let value = modifier.slice(1, -1);
51
+ if (!validate(value)) {
52
+ return undefined;
53
+ }
54
+ return (0, _dataTypes.normalize)(value);
141
55
  }
142
- function transformLastClasses(transformClass, { wrap , withRule } = {
143
- }) {
144
- return ({ container })=>{
145
- container.walkRules((rule)=>{
146
- let selector = rule.selector;
147
- let variantSelector = updateLastClasses(selector, transformClass);
148
- rule.selector = variantSelector;
149
- if (withRule) {
150
- withRule(rule);
151
- }
152
- return rule;
153
- });
154
- if (wrap) {
155
- let wrapper = wrap();
156
- let nodes = container.nodes;
157
- container.removeAll();
158
- wrapper.append(nodes);
159
- container.append(wrapper);
56
+ function asNegativeValue(modifier, lookup = {}, validate) {
57
+ let positiveValue = lookup[modifier];
58
+ if (positiveValue !== undefined) {
59
+ return (0, _negateValue.default)(positiveValue);
60
+ }
61
+ if (isArbitraryValue(modifier)) {
62
+ let resolved = resolveArbitraryValue(modifier, validate);
63
+ if (resolved === undefined) {
64
+ return undefined;
160
65
  }
161
- };
66
+ return (0, _negateValue.default)(resolved);
67
+ }
162
68
  }
163
- function asValue(modifier, lookup = {
164
- }, { validate =()=>true
165
- } = {
166
- }) {
167
- let value = lookup[modifier];
69
+ function asValue(modifier, options = {}, { validate =()=>true } = {}) {
70
+ var ref;
71
+ let value = (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
168
72
  if (value !== undefined) {
169
73
  return value;
170
74
  }
171
- if (!isArbitraryValue(modifier)) {
172
- return undefined;
75
+ if (options.supportsNegativeValues && modifier.startsWith("-")) {
76
+ return asNegativeValue(modifier.slice(1), options.values, validate);
173
77
  }
174
- value = modifier.slice(1, -1);
175
- if (!validate(value)) {
176
- return undefined;
177
- }
178
- return (0, _dataTypes).normalize(value);
78
+ return resolveArbitraryValue(modifier, validate);
179
79
  }
180
80
  function isArbitraryValue(input) {
181
- return input.startsWith('[') && input.endsWith(']');
81
+ return input.startsWith("[") && input.endsWith("]");
182
82
  }
183
- function splitAlpha(modifier) {
184
- let slashIdx = modifier.lastIndexOf('/');
83
+ function splitUtilityModifier(modifier) {
84
+ let slashIdx = modifier.lastIndexOf("/");
185
85
  if (slashIdx === -1 || slashIdx === modifier.length - 1) {
186
86
  return [
187
- modifier
87
+ modifier,
88
+ undefined
89
+ ];
90
+ }
91
+ let arbitrary = isArbitraryValue(modifier);
92
+ // The modifier could be of the form `[foo]/[bar]`
93
+ // We want to handle this case properly
94
+ // without affecting `[foo/bar]`
95
+ if (arbitrary && !modifier.includes("]/[")) {
96
+ return [
97
+ modifier,
98
+ undefined
188
99
  ];
189
100
  }
190
101
  return [
@@ -192,39 +103,52 @@ function splitAlpha(modifier) {
192
103
  modifier.slice(slashIdx + 1)
193
104
  ];
194
105
  }
195
- function asColor(modifier, lookup = {
196
- }, tailwindConfig = {
197
- }) {
198
- if (lookup[modifier] !== undefined) {
199
- return lookup[modifier];
106
+ function parseColorFormat(value) {
107
+ if (typeof value === "string" && value.includes("<alpha-value>")) {
108
+ let oldValue = value;
109
+ return ({ opacityValue =1 })=>oldValue.replace("<alpha-value>", opacityValue);
110
+ }
111
+ return value;
112
+ }
113
+ function asColor(_, options = {}, { tailwindConfig ={} , utilityModifier , rawModifier } = {}) {
114
+ var ref;
115
+ if (((ref = options.values) === null || ref === void 0 ? void 0 : ref[rawModifier]) !== undefined) {
116
+ var ref1;
117
+ return parseColorFormat((ref1 = options.values) === null || ref1 === void 0 ? void 0 : ref1[rawModifier]);
200
118
  }
201
- let [color, alpha] = splitAlpha(modifier);
119
+ // TODO: Hoist this up to getMatchingTypes or something
120
+ // We do this here because we need the alpha value (if any)
121
+ let [color, alpha] = splitUtilityModifier(rawModifier);
202
122
  if (alpha !== undefined) {
203
- var ref, ref1;
204
- var _color;
205
- let normalizedColor = (_color = lookup[color]) !== null && _color !== void 0 ? _color : isArbitraryValue(color) ? color.slice(1, -1) : undefined;
123
+ var ref2, ref3, ref4;
124
+ var ref5;
125
+ 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;
206
126
  if (normalizedColor === undefined) {
207
127
  return undefined;
208
128
  }
129
+ normalizedColor = parseColorFormat(normalizedColor);
209
130
  if (isArbitraryValue(alpha)) {
210
- return (0, _withAlphaVariable).withAlphaValue(normalizedColor, alpha.slice(1, -1));
131
+ return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, alpha.slice(1, -1));
211
132
  }
212
- if (((ref = tailwindConfig.theme) === null || ref === void 0 ? void 0 : (ref1 = ref.opacity) === null || ref1 === void 0 ? void 0 : ref1[alpha]) === undefined) {
133
+ if (((ref3 = tailwindConfig.theme) === null || ref3 === void 0 ? void 0 : (ref4 = ref3.opacity) === null || ref4 === void 0 ? void 0 : ref4[alpha]) === undefined) {
213
134
  return undefined;
214
135
  }
215
- return (0, _withAlphaVariable).withAlphaValue(normalizedColor, tailwindConfig.theme.opacity[alpha]);
136
+ return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, tailwindConfig.theme.opacity[alpha]);
216
137
  }
217
- return asValue(modifier, lookup, {
138
+ return asValue(rawModifier, options, {
139
+ rawModifier,
140
+ utilityModifier,
218
141
  validate: _dataTypes.color
219
142
  });
220
143
  }
221
- function asLookupValue(modifier, lookup = {
222
- }) {
223
- return lookup[modifier];
144
+ function asLookupValue(modifier, options = {}) {
145
+ var ref;
146
+ return (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
224
147
  }
225
148
  function guess(validate) {
226
- return (modifier, lookup)=>{
227
- return asValue(modifier, lookup, {
149
+ return (modifier, options, extras)=>{
150
+ return asValue(modifier, options, {
151
+ ...extras,
228
152
  validate
229
153
  });
230
154
  };
@@ -238,12 +162,14 @@ let typeMap = {
238
162
  percentage: guess(_dataTypes.percentage),
239
163
  position: guess(_dataTypes.position),
240
164
  lookup: asLookupValue,
241
- 'generic-name': guess(_dataTypes.genericName),
242
- 'family-name': guess(_dataTypes.familyName),
165
+ "generic-name": guess(_dataTypes.genericName),
166
+ "family-name": guess(_dataTypes.familyName),
243
167
  number: guess(_dataTypes.number),
244
- 'line-width': guess(_dataTypes.lineWidth),
245
- 'absolute-size': guess(_dataTypes.absoluteSize),
246
- 'relative-size': guess(_dataTypes.relativeSize)
168
+ "line-width": guess(_dataTypes.lineWidth),
169
+ "absolute-size": guess(_dataTypes.absoluteSize),
170
+ "relative-size": guess(_dataTypes.relativeSize),
171
+ shadow: guess(_dataTypes.shadow),
172
+ size: guess(_validateFormalSyntax.backgroundSize)
247
173
  };
248
174
  let supportedTypes = Object.keys(typeMap);
249
175
  function splitAtFirst(input, delim) {
@@ -257,26 +183,82 @@ function splitAtFirst(input, delim) {
257
183
  input.slice(idx + 1)
258
184
  ];
259
185
  }
260
- function coerceValue(types, modifier, values, tailwindConfig) {
186
+ function coerceValue(types, modifier, options, tailwindConfig) {
261
187
  if (isArbitraryValue(modifier)) {
262
- let [explicitType, value] = splitAtFirst(modifier.slice(1, -1), ':');
263
- if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
188
+ let arbitraryValue = modifier.slice(1, -1);
189
+ let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
190
+ // It could be that this resolves to `url(https` which is not a valid
191
+ // identifier. We currently only support "simple" words with dashes or
192
+ // underscores. E.g.: family-name
193
+ if (!/^[\w-_]+$/g.test(explicitType)) {
194
+ value = arbitraryValue;
195
+ } else if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
264
196
  return [];
265
197
  }
266
198
  if (value.length > 0 && supportedTypes.includes(explicitType)) {
267
199
  return [
268
- asValue(`[${value}]`, values, tailwindConfig),
269
- explicitType
200
+ asValue(`[${value}]`, options),
201
+ explicitType,
202
+ null
270
203
  ];
271
204
  }
272
205
  }
206
+ let matches = getMatchingTypes(types, modifier, options, tailwindConfig);
273
207
  // Find first matching type
274
- for (let type of [].concat(types)){
275
- let result = typeMap[type](modifier, values, tailwindConfig);
276
- if (result) return [
277
- result,
278
- type
279
- ];
208
+ for (let match of matches){
209
+ return match;
280
210
  }
281
211
  return [];
282
212
  }
213
+ function* getMatchingTypes(types, rawModifier, options, tailwindConfig) {
214
+ let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
215
+ let canUseUtilityModifier = modifiersEnabled && options.modifiers != null && (options.modifiers === "any" || typeof options.modifiers === "object");
216
+ let [modifier, utilityModifier] = canUseUtilityModifier ? splitUtilityModifier(rawModifier) : [
217
+ rawModifier,
218
+ undefined
219
+ ];
220
+ if (utilityModifier !== undefined && modifier === "") {
221
+ modifier = "DEFAULT";
222
+ }
223
+ // Check the full value first
224
+ // TODO: Move to asValue… somehow
225
+ if (utilityModifier !== undefined) {
226
+ if (typeof options.modifiers === "object") {
227
+ var ref;
228
+ var ref1;
229
+ let configValue = (ref1 = (ref = options.modifiers) === null || ref === void 0 ? void 0 : ref[utilityModifier]) !== null && ref1 !== void 0 ? ref1 : null;
230
+ if (configValue !== null) {
231
+ utilityModifier = configValue;
232
+ } else if (isArbitraryValue(utilityModifier)) {
233
+ utilityModifier = utilityModifier.slice(1, -1);
234
+ }
235
+ }
236
+ let result = asValue(rawModifier, options, {
237
+ rawModifier,
238
+ utilityModifier,
239
+ tailwindConfig
240
+ });
241
+ if (result !== undefined) {
242
+ yield [
243
+ result,
244
+ "any",
245
+ null
246
+ ];
247
+ }
248
+ }
249
+ for (const { type } of types !== null && types !== void 0 ? types : []){
250
+ let result1 = typeMap[type](modifier, options, {
251
+ rawModifier,
252
+ utilityModifier,
253
+ tailwindConfig
254
+ });
255
+ if (result1 === undefined) {
256
+ continue;
257
+ }
258
+ yield [
259
+ result1,
260
+ type,
261
+ utilityModifier !== null && utilityModifier !== void 0 ? utilityModifier : null
262
+ ];
263
+ }
264
+ }
@@ -2,22 +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
- const getPrefix = typeof prefix === 'function' ? prefix : ()=>prefix === undefined ? '' : prefix
15
- ;
16
- return (0, _postcssSelectorParser).default((selectors)=>{
15
+ function _default(prefix, selector, prependNegative = false) {
16
+ return (0, _postcssSelectorParser.default)((selectors)=>{
17
17
  selectors.walkClasses((classSelector)=>{
18
- (0, _tap).tap(classSelector.value, (baseClass)=>{
19
- classSelector.value = `${getPrefix('.' + baseClass)}${baseClass}`;
20
- });
18
+ let baseClass = classSelector.value;
19
+ let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
20
+ classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
21
21
  });
22
22
  }).processSync(selector);
23
23
  }