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
@@ -2,18 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.cloneDeep = cloneDeep;
5
+ Object.defineProperty(exports, "cloneDeep", {
6
+ enumerable: true,
7
+ get: ()=>cloneDeep
8
+ });
6
9
  function cloneDeep(value) {
7
10
  if (Array.isArray(value)) {
8
- return value.map((child)=>cloneDeep(child)
9
- );
11
+ return value.map((child)=>cloneDeep(child));
10
12
  }
11
13
  if (typeof value === "object" && value !== null) {
12
14
  return Object.fromEntries(Object.entries(value).map(([k, v])=>[
13
15
  k,
14
16
  cloneDeep(v)
15
- ]
16
- ));
17
+ ]));
17
18
  }
18
19
  return value;
19
20
  }
@@ -2,11 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = cloneNodes;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>cloneNodes
8
+ });
6
9
  function cloneNodes(nodes, source = undefined, raws = undefined) {
7
10
  return nodes.map((node)=>{
11
+ var _node_raws_tailwind;
8
12
  let cloned = node.clone();
9
- if (source !== undefined) {
13
+ // We always want override the source map
14
+ // except when explicitly told not to
15
+ let shouldOverwriteSource = ((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.preserveSource) !== true || !cloned.source;
16
+ if (source !== undefined && shouldOverwriteSource) {
10
17
  cloned.source = source;
11
18
  if ("walk" in cloned) {
12
19
  cloned.walk((child)=>{
package/lib/util/color.js CHANGED
@@ -2,9 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.parseColor = parseColor;
6
- exports.formatColor = formatColor;
7
- var _colorName = _interopRequireDefault(require("color-name"));
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
+ parseColor: ()=>parseColor,
13
+ formatColor: ()=>formatColor
14
+ });
15
+ const _colorName = /*#__PURE__*/ _interopRequireDefault(require("color-name"));
8
16
  function _interopRequireDefault(obj) {
9
17
  return obj && obj.__esModule ? obj : {
10
18
  default: obj
@@ -19,7 +27,7 @@ let CUSTOM_PROPERTY = /var\(--(?:[^ )]*?)\)/;
19
27
  let RGB = new RegExp(`^(rgb)a?\\(\\s*(${VALUE.source}|${CUSTOM_PROPERTY.source})(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`);
20
28
  let HSL = new RegExp(`^(hsl)a?\\(\\s*((?:${VALUE.source})(?:deg|rad|grad|turn)?|${CUSTOM_PROPERTY.source})(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`);
21
29
  function parseColor(value, { loose =false } = {}) {
22
- var ref, ref1;
30
+ var _match_, _match__toString;
23
31
  if (typeof value !== "string") {
24
32
  return null;
25
33
  }
@@ -38,8 +46,7 @@ function parseColor(value, { loose =false } = {}) {
38
46
  if (value in _colorName.default) {
39
47
  return {
40
48
  mode: "rgb",
41
- color: _colorName.default[value].map((v)=>v.toString()
42
- )
49
+ color: _colorName.default[value].map((v)=>v.toString())
43
50
  };
44
51
  }
45
52
  let hex = value.replace(SHORT_HEX, (_, r, g, b, a)=>[
@@ -51,8 +58,7 @@ function parseColor(value, { loose =false } = {}) {
51
58
  b,
52
59
  b,
53
60
  a ? a + a : ""
54
- ].join("")
55
- ).match(HEX);
61
+ ].join("")).match(HEX);
56
62
  if (hex !== null) {
57
63
  return {
58
64
  mode: "rgb",
@@ -60,13 +66,12 @@ function parseColor(value, { loose =false } = {}) {
60
66
  parseInt(hex[1], 16),
61
67
  parseInt(hex[2], 16),
62
68
  parseInt(hex[3], 16)
63
- ].map((v)=>v.toString()
64
- ),
69
+ ].map((v)=>v.toString()),
65
70
  alpha: hex[4] ? (parseInt(hex[4], 16) / 255).toString() : undefined
66
71
  };
67
72
  }
68
- var ref2;
69
- let match = (ref2 = value.match(RGB)) !== null && ref2 !== void 0 ? ref2 : value.match(HSL);
73
+ var _value_match;
74
+ let match = (_value_match = value.match(RGB)) !== null && _value_match !== void 0 ? _value_match : value.match(HSL);
70
75
  if (match === null) {
71
76
  return null;
72
77
  }
@@ -74,19 +79,17 @@ function parseColor(value, { loose =false } = {}) {
74
79
  match[2],
75
80
  match[3],
76
81
  match[4]
77
- ].filter(Boolean).map((v)=>v.toString()
78
- );
82
+ ].filter(Boolean).map((v)=>v.toString());
79
83
  if (!loose && color.length !== 3) {
80
84
  return null;
81
85
  }
82
- if (color.length < 3 && !color.some((part)=>/^var\(.*?\)$/.test(part)
83
- )) {
86
+ if (color.length < 3 && !color.some((part)=>/^var\(.*?\)$/.test(part))) {
84
87
  return null;
85
88
  }
86
89
  return {
87
90
  mode: match[1],
88
91
  color,
89
- alpha: (ref = match[5]) === null || ref === void 0 ? void 0 : (ref1 = ref.toString) === null || ref1 === void 0 ? void 0 : ref1.call(ref)
92
+ alpha: (_match_ = match[5]) === null || _match_ === void 0 ? void 0 : (_match__toString = _match_.toString) === null || _match__toString === void 0 ? void 0 : _match__toString.call(_match_)
90
93
  };
91
94
  }
92
95
  function formatColor({ mode , color , alpha }) {
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = _default;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>_default
8
+ });
6
9
  function _default(pluginConfig, plugins) {
7
10
  if (pluginConfig === undefined) {
8
11
  return plugins;
@@ -12,7 +15,7 @@ function _default(pluginConfig, plugins) {
12
15
  return pluginConfig !== false && pluginConfig[pluginName] !== false;
13
16
  }).concat(Object.keys(pluginConfig).filter((pluginName)=>{
14
17
  return pluginConfig[pluginName] !== false;
15
- }))),
18
+ })))
16
19
  ];
17
20
  return pluginNames;
18
21
  }
@@ -2,15 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = void 0;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>_default
8
+ });
6
9
  function createPlugin(plugin, config) {
7
10
  return {
8
11
  handler: plugin,
9
12
  config
10
13
  };
11
14
  }
12
- createPlugin.withOptions = function(pluginFunction, configFunction = ()=>({})
13
- ) {
15
+ createPlugin.withOptions = function(pluginFunction, configFunction = ()=>({})) {
14
16
  const optionsFunction = function(options) {
15
17
  return {
16
18
  __options: options,
@@ -25,5 +27,4 @@ createPlugin.withOptions = function(pluginFunction, configFunction = ()=>({})
25
27
  optionsFunction.__configFunction = configFunction;
26
28
  return optionsFunction;
27
29
  };
28
- var _default = createPlugin;
29
- exports.default = _default;
30
+ const _default = createPlugin;
@@ -2,8 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = createUtilityPlugin;
6
- var _transformThemeValue = _interopRequireDefault(require("./transformThemeValue"));
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>createUtilityPlugin
8
+ });
9
+ const _transformThemeValue = /*#__PURE__*/ _interopRequireDefault(require("./transformThemeValue"));
10
+ function _interopRequireDefault(obj) {
11
+ return obj && obj.__esModule ? obj : {
12
+ default: obj
13
+ };
14
+ }
7
15
  function createUtilityPlugin(themeKey, utilityVariations = [
8
16
  [
9
17
  themeKey,
@@ -12,15 +20,15 @@ function createUtilityPlugin(themeKey, utilityVariations = [
12
20
  ]
13
21
  ]
14
22
  ], { filterDefault =false , ...options } = {}) {
15
- let transformValue = (0, _transformThemeValue).default(themeKey);
23
+ let transformValue = (0, _transformThemeValue.default)(themeKey);
16
24
  return function({ matchUtilities , theme }) {
17
25
  for (let utilityVariation of utilityVariations){
18
26
  let group = Array.isArray(utilityVariation[0]) ? utilityVariation : [
19
27
  utilityVariation
20
28
  ];
21
- var ref;
22
- matchUtilities(group.reduce((obj1, [classPrefix, properties])=>{
23
- return Object.assign(obj1, {
29
+ var _theme;
30
+ matchUtilities(group.reduce((obj, [classPrefix, properties])=>{
31
+ return Object.assign(obj, {
24
32
  [classPrefix]: (value)=>{
25
33
  return properties.reduce((obj, name)=>{
26
34
  if (Array.isArray(name)) {
@@ -36,14 +44,8 @@ function createUtilityPlugin(themeKey, utilityVariations = [
36
44
  });
37
45
  }, {}), {
38
46
  ...options,
39
- values: filterDefault ? Object.fromEntries(Object.entries((ref = theme(themeKey)) !== null && ref !== void 0 ? ref : {}).filter(([modifier])=>modifier !== "DEFAULT"
40
- )) : theme(themeKey)
47
+ values: filterDefault ? Object.fromEntries(Object.entries((_theme = theme(themeKey)) !== null && _theme !== void 0 ? _theme : {}).filter(([modifier])=>modifier !== "DEFAULT")) : theme(themeKey)
41
48
  });
42
49
  }
43
50
  };
44
51
  }
45
- function _interopRequireDefault(obj) {
46
- return obj && obj.__esModule ? obj : {
47
- default: obj
48
- };
49
- }
@@ -2,23 +2,32 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.normalize = normalize;
6
- exports.url = url;
7
- exports.number = number;
8
- exports.percentage = percentage;
9
- exports.length = length;
10
- exports.lineWidth = lineWidth;
11
- exports.shadow = shadow;
12
- exports.color = color;
13
- exports.image = image;
14
- exports.gradient = gradient;
15
- exports.position = position;
16
- exports.familyName = familyName;
17
- exports.genericName = genericName;
18
- exports.absoluteSize = absoluteSize;
19
- exports.relativeSize = relativeSize;
20
- var _color = require("./color");
21
- var _parseBoxShadowValue = require("./parseBoxShadowValue");
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
+ normalize: ()=>normalize,
13
+ url: ()=>url,
14
+ number: ()=>number,
15
+ percentage: ()=>percentage,
16
+ length: ()=>length,
17
+ lineWidth: ()=>lineWidth,
18
+ shadow: ()=>shadow,
19
+ color: ()=>color,
20
+ image: ()=>image,
21
+ gradient: ()=>gradient,
22
+ position: ()=>position,
23
+ familyName: ()=>familyName,
24
+ genericName: ()=>genericName,
25
+ absoluteSize: ()=>absoluteSize,
26
+ relativeSize: ()=>relativeSize
27
+ });
28
+ const _color = require("./color");
29
+ const _parseBoxShadowValue = require("./parseBoxShadowValue");
30
+ const _splitAtTopLevelOnly = require("./splitAtTopLevelOnly");
22
31
  let cssFunctions = [
23
32
  "min",
24
33
  "max",
@@ -26,11 +35,15 @@ let cssFunctions = [
26
35
  "calc"
27
36
  ];
28
37
  // Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Types
29
- let COMMA = /,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
30
- ;
31
- let UNDERSCORE = /_(?![^(]*\))/g // Underscore separator that is not located between brackets. E.g.: `rgba(255,_255,_255)_black` these don't count.
32
- ;
38
+ function isCSSFunction(value) {
39
+ return cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.*\\)`).test(value));
40
+ }
41
+ const placeholder = "--tw-placeholder";
42
+ const placeholderRe = new RegExp(placeholder, "g");
33
43
  function normalize(value, isRoot = true) {
44
+ if (value.startsWith("--")) {
45
+ return `var(${value})`;
46
+ }
34
47
  // Keep raw strings if it starts with `url(`
35
48
  if (value.includes("url(")) {
36
49
  return value.split(/(url\(.*?\))/g).filter(Boolean).map((part)=>{
@@ -41,34 +54,34 @@ function normalize(value, isRoot = true) {
41
54
  }).join("");
42
55
  }
43
56
  // Convert `_` to ` `, except for escaped underscores `\_`
44
- value = value.replace(/([^\\])_+/g, (fullMatch, characterBefore)=>characterBefore + " ".repeat(fullMatch.length - 1)
45
- ).replace(/^_/g, " ").replace(/\\_/g, "_");
57
+ value = value.replace(/([^\\])_+/g, (fullMatch, characterBefore)=>characterBefore + " ".repeat(fullMatch.length - 1)).replace(/^_/g, " ").replace(/\\_/g, "_");
46
58
  // Remove leftover whitespace
47
59
  if (isRoot) {
48
60
  value = value.trim();
49
61
  }
50
- // Add spaces around operators inside calc() that do not follow an operator
62
+ // Add spaces around operators inside math functions like calc() that do not follow an operator
51
63
  // or '('.
52
- value = value.replace(/calc\(.+\)/g, (match)=>{
53
- return match.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
64
+ value = value.replace(/(calc|min|max|clamp)\(.+\)/g, (match)=>{
65
+ let vars = [];
66
+ return match.replace(/var\((--.+?)[,)]/g, (match, g1)=>{
67
+ vars.push(g1);
68
+ return match.replace(g1, placeholder);
69
+ }).replace(/(-?\d*\.?\d(?!\b-\d.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ").replace(placeholderRe, ()=>vars.shift());
54
70
  });
55
- // Add spaces around some operators not inside calc() that do not follow an operator
56
- // or '('.
57
- return value.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([\/])/g, "$1 $2 ");
71
+ return value;
58
72
  }
59
73
  function url(value) {
60
74
  return value.startsWith("url(");
61
75
  }
62
76
  function number(value) {
63
- return !isNaN(Number(value)) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?`).test(value)
64
- );
77
+ return !isNaN(Number(value)) || isCSSFunction(value);
65
78
  }
66
79
  function percentage(value) {
67
- return value.split(UNDERSCORE).every((part)=>{
68
- return /%$/g.test(part) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?%`).test(part)
69
- );
70
- });
80
+ return value.endsWith("%") && number(value.slice(0, -1)) || isCSSFunction(value);
71
81
  }
82
+ // Please refer to MDN when updating this list:
83
+ // https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
84
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units
72
85
  let lengthUnits = [
73
86
  "cm",
74
87
  "mm",
@@ -82,17 +95,29 @@ let lengthUnits = [
82
95
  "ch",
83
96
  "rem",
84
97
  "lh",
98
+ "rlh",
85
99
  "vw",
86
100
  "vh",
87
101
  "vmin",
88
- "vmax",
102
+ "vmax",
103
+ "vb",
104
+ "vi",
105
+ "svw",
106
+ "svh",
107
+ "lvw",
108
+ "lvh",
109
+ "dvw",
110
+ "dvh",
111
+ "cqw",
112
+ "cqh",
113
+ "cqi",
114
+ "cqb",
115
+ "cqmin",
116
+ "cqmax"
89
117
  ];
90
118
  let lengthUnitsPattern = `(?:${lengthUnits.join("|")})`;
91
119
  function length(value) {
92
- return value.split(UNDERSCORE).every((part)=>{
93
- return part === "0" || new RegExp(`${lengthUnitsPattern}$`).test(part) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?${lengthUnitsPattern}`).test(part)
94
- );
95
- });
120
+ return value === "0" || new RegExp(`^[+-]?[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`).test(value) || isCSSFunction(value);
96
121
  }
97
122
  let lineWidths = new Set([
98
123
  "thin",
@@ -103,7 +128,7 @@ function lineWidth(value) {
103
128
  return lineWidths.has(value);
104
129
  }
105
130
  function shadow(value) {
106
- let parsedShadows = (0, _parseBoxShadowValue).parseBoxShadowValue(normalize(value));
131
+ let parsedShadows = (0, _parseBoxShadowValue.parseBoxShadowValue)(normalize(value));
107
132
  for (let parsedShadow of parsedShadows){
108
133
  if (!parsedShadow.valid) {
109
134
  return false;
@@ -113,10 +138,10 @@ function shadow(value) {
113
138
  }
114
139
  function color(value) {
115
140
  let colors = 0;
116
- let result = value.split(UNDERSCORE).every((part)=>{
141
+ let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value, "_").every((part)=>{
117
142
  part = normalize(part);
118
143
  if (part.startsWith("var(")) return true;
119
- if ((0, _color).parseColor(part, {
144
+ if ((0, _color.parseColor)(part, {
120
145
  loose: true
121
146
  }) !== null) return colors++, true;
122
147
  return false;
@@ -126,7 +151,7 @@ function color(value) {
126
151
  }
127
152
  function image(value) {
128
153
  let images = 0;
129
- let result = value.split(COMMA).every((part)=>{
154
+ let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value, ",").every((part)=>{
130
155
  part = normalize(part);
131
156
  if (part.startsWith("var(")) return true;
132
157
  if (url(part) || gradient(part) || [
@@ -134,8 +159,7 @@ function image(value) {
134
159
  "image(",
135
160
  "cross-fade(",
136
161
  "image-set("
137
- ].some((fn)=>part.startsWith(fn)
138
- )) {
162
+ ].some((fn)=>part.startsWith(fn))) {
139
163
  images++;
140
164
  return true;
141
165
  }
@@ -149,7 +173,7 @@ let gradientTypes = new Set([
149
173
  "radial-gradient",
150
174
  "repeating-linear-gradient",
151
175
  "repeating-radial-gradient",
152
- "conic-gradient",
176
+ "conic-gradient"
153
177
  ]);
154
178
  function gradient(value) {
155
179
  value = normalize(value);
@@ -169,7 +193,7 @@ let validPositions = new Set([
169
193
  ]);
170
194
  function position(value) {
171
195
  let positions = 0;
172
- let result = value.split(UNDERSCORE).every((part)=>{
196
+ let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value, "_").every((part)=>{
173
197
  part = normalize(part);
174
198
  if (part.startsWith("var(")) return true;
175
199
  if (validPositions.has(part) || length(part) || percentage(part)) {
@@ -183,7 +207,7 @@ function position(value) {
183
207
  }
184
208
  function familyName(value) {
185
209
  let fonts = 0;
186
- let result = value.split(COMMA).every((part)=>{
210
+ let result = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(value, ",").every((part)=>{
187
211
  part = normalize(part);
188
212
  if (part.startsWith("var(")) return true;
189
213
  // If it contains spaces, then it should be quoted
@@ -215,7 +239,7 @@ let genericNames = new Set([
215
239
  "ui-rounded",
216
240
  "math",
217
241
  "emoji",
218
- "fangsong",
242
+ "fangsong"
219
243
  ]);
220
244
  function genericName(value) {
221
245
  return genericNames.has(value);
@@ -228,7 +252,7 @@ let absoluteSizes = new Set([
228
252
  "large",
229
253
  "x-large",
230
254
  "x-large",
231
- "xxx-large",
255
+ "xxx-large"
232
256
  ]);
233
257
  function absoluteSize(value) {
234
258
  return absoluteSizes.has(value);
@@ -2,18 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.defaults = defaults;
5
+ Object.defineProperty(exports, "defaults", {
6
+ enumerable: true,
7
+ get: ()=>defaults
8
+ });
6
9
  function defaults(target, ...sources) {
7
10
  for (let source of sources){
8
11
  for(let k in source){
9
- var ref;
10
- if (!(target === null || target === void 0 ? void 0 : (ref = target.hasOwnProperty) === null || ref === void 0 ? void 0 : ref.call(target, k))) {
12
+ var _target_hasOwnProperty;
13
+ if (!(target === null || target === void 0 ? void 0 : (_target_hasOwnProperty = target.hasOwnProperty) === null || _target_hasOwnProperty === void 0 ? void 0 : _target_hasOwnProperty.call(target, k))) {
11
14
  target[k] = source[k];
12
15
  }
13
16
  }
14
17
  for (let k1 of Object.getOwnPropertySymbols(source)){
15
- var ref1;
16
- if (!(target === null || target === void 0 ? void 0 : (ref1 = target.hasOwnProperty) === null || ref1 === void 0 ? void 0 : ref1.call(target, k1))) {
18
+ var _target_hasOwnProperty1;
19
+ if (!(target === null || target === void 0 ? void 0 : (_target_hasOwnProperty1 = target.hasOwnProperty) === null || _target_hasOwnProperty1 === void 0 ? void 0 : _target_hasOwnProperty1.call(target, k1))) {
17
20
  target[k1] = source[k1];
18
21
  }
19
22
  }
@@ -2,18 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = escapeClassName;
6
- var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
7
- var _escapeCommas = _interopRequireDefault(require("./escapeCommas"));
8
- function escapeClassName(className) {
9
- var ref;
10
- let node = _postcssSelectorParser.default.className();
11
- node.value = className;
12
- var ref1;
13
- return (0, _escapeCommas).default((ref1 = node === null || node === void 0 ? void 0 : (ref = node.raws) === null || ref === void 0 ? void 0 : ref.value) !== null && ref1 !== void 0 ? ref1 : node.value);
14
- }
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>escapeClassName
8
+ });
9
+ const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
10
+ const _escapeCommas = /*#__PURE__*/ _interopRequireDefault(require("./escapeCommas"));
15
11
  function _interopRequireDefault(obj) {
16
12
  return obj && obj.__esModule ? obj : {
17
13
  default: obj
18
14
  };
19
15
  }
16
+ function escapeClassName(className) {
17
+ var _node_raws;
18
+ let node = _postcssSelectorParser.default.className();
19
+ node.value = className;
20
+ var _node_raws_value;
21
+ return (0, _escapeCommas.default)((_node_raws_value = node === null || node === void 0 ? void 0 : (_node_raws = node.raws) === null || _node_raws === void 0 ? void 0 : _node_raws.value) !== null && _node_raws_value !== void 0 ? _node_raws_value : node.value);
22
+ }
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = escapeCommas;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>escapeCommas
8
+ });
6
9
  function escapeCommas(className) {
7
10
  return className.replace(/\\,/g, "\\2c ");
8
11
  }
@@ -2,16 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = void 0;
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>_default
8
+ });
6
9
  const flattenColorPalette = (colors)=>Object.assign({}, ...Object.entries(colors !== null && colors !== void 0 ? colors : {}).flatMap(([color, values])=>typeof values == "object" ? Object.entries(flattenColorPalette(values)).map(([number, hex])=>({
7
10
  [color + (number === "DEFAULT" ? "" : `-${number}`)]: hex
8
- })
9
- ) : [
11
+ })) : [
10
12
  {
11
13
  [`${color}`]: values
12
14
  }
13
- ]
14
- ))
15
- ;
16
- var _default = flattenColorPalette;
17
- exports.default = _default;
15
+ ]));
16
+ const _default = flattenColorPalette;