tailwindcss 3.0.23 → 3.0.24

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 (89) hide show
  1. package/CHANGELOG.md +29 -3
  2. package/lib/cli-peer-dependencies.js +3 -3
  3. package/lib/cli.js +183 -161
  4. package/lib/constants.js +8 -8
  5. package/lib/corePlugins.js +1572 -1523
  6. package/lib/featureFlags.js +9 -9
  7. package/lib/index.js +19 -6
  8. package/lib/lib/cacheInvalidation.js +69 -0
  9. package/lib/lib/collapseAdjacentRules.js +26 -13
  10. package/lib/lib/collapseDuplicateDeclarations.js +1 -1
  11. package/lib/lib/defaultExtractor.js +6 -6
  12. package/lib/lib/detectNesting.js +9 -9
  13. package/lib/lib/evaluateTailwindFunctions.js +16 -16
  14. package/lib/lib/expandApplyAtRules.js +180 -27
  15. package/lib/lib/expandTailwindAtRules.js +132 -122
  16. package/lib/lib/generateRules.js +90 -72
  17. package/lib/lib/getModuleDependencies.js +14 -14
  18. package/lib/lib/normalizeTailwindDirectives.js +35 -35
  19. package/lib/lib/partitionApplyAtRules.js +7 -7
  20. package/lib/lib/resolveDefaultsAtRules.js +81 -77
  21. package/lib/lib/setupContextUtils.js +78 -87
  22. package/lib/lib/setupTrackingContext.js +57 -57
  23. package/lib/lib/sharedState.js +10 -8
  24. package/lib/lib/substituteScreenAtRules.js +2 -2
  25. package/lib/postcss-plugins/nesting/README.md +2 -2
  26. package/lib/postcss-plugins/nesting/index.js +1 -1
  27. package/lib/postcss-plugins/nesting/plugin.js +41 -9
  28. package/lib/processTailwindFeatures.js +7 -7
  29. package/lib/public/colors.js +241 -241
  30. package/lib/public/resolve-config.js +5 -5
  31. package/lib/util/buildMediaQuery.js +2 -2
  32. package/lib/util/cloneDeep.js +1 -1
  33. package/lib/util/cloneNodes.js +12 -1
  34. package/lib/util/color.js +21 -20
  35. package/lib/util/createUtilityPlugin.js +6 -6
  36. package/lib/util/dataTypes.js +77 -75
  37. package/lib/util/escapeClassName.js +5 -5
  38. package/lib/util/escapeCommas.js +1 -1
  39. package/lib/util/flattenColorPalette.js +2 -2
  40. package/lib/util/formatVariantSelector.js +19 -19
  41. package/lib/util/getAllConfigs.js +5 -5
  42. package/lib/util/hashConfig.js +5 -5
  43. package/lib/util/isKeyframeRule.js +1 -1
  44. package/lib/util/isPlainObject.js +1 -1
  45. package/lib/util/isValidArbitraryValue.js +27 -27
  46. package/lib/util/log.js +8 -8
  47. package/lib/util/nameClass.js +7 -7
  48. package/lib/util/negateValue.js +4 -4
  49. package/lib/util/normalizeConfig.js +39 -39
  50. package/lib/util/normalizeScreens.js +4 -4
  51. package/lib/util/parseAnimationValue.js +56 -56
  52. package/lib/util/parseBoxShadowValue.js +60 -20
  53. package/lib/util/parseDependency.js +32 -32
  54. package/lib/util/parseObjectStyles.js +6 -6
  55. package/lib/util/pluginUtils.js +9 -9
  56. package/lib/util/prefixSelector.js +1 -1
  57. package/lib/util/resolveConfig.js +28 -28
  58. package/lib/util/resolveConfigPath.js +16 -16
  59. package/lib/util/responsive.js +6 -6
  60. package/lib/util/toColorValue.js +1 -1
  61. package/lib/util/toPath.js +2 -2
  62. package/lib/util/transformThemeValue.js +27 -27
  63. package/lib/util/withAlphaVariable.js +19 -19
  64. package/package.json +24 -23
  65. package/peers/index.js +4777 -4831
  66. package/scripts/generate-types.js +52 -0
  67. package/src/cli.js +41 -11
  68. package/src/corePlugins.js +67 -5
  69. package/src/featureFlags.js +2 -2
  70. package/src/index.js +17 -1
  71. package/src/lib/cacheInvalidation.js +52 -0
  72. package/src/lib/collapseAdjacentRules.js +16 -1
  73. package/src/lib/defaultExtractor.js +4 -4
  74. package/src/lib/expandApplyAtRules.js +179 -6
  75. package/src/lib/expandTailwindAtRules.js +25 -5
  76. package/src/lib/generateRules.js +68 -46
  77. package/src/lib/resolveDefaultsAtRules.js +6 -2
  78. package/src/lib/setupContextUtils.js +25 -26
  79. package/src/lib/setupTrackingContext.js +3 -3
  80. package/src/lib/sharedState.js +1 -0
  81. package/src/postcss-plugins/nesting/README.md +2 -2
  82. package/src/postcss-plugins/nesting/plugin.js +36 -0
  83. package/src/util/cloneNodes.js +14 -1
  84. package/src/util/color.js +7 -5
  85. package/src/util/dataTypes.js +3 -1
  86. package/src/util/log.js +7 -7
  87. package/src/util/parseBoxShadowValue.js +50 -2
  88. package/src/util/resolveConfig.js +32 -0
  89. package/stubs/defaultConfig.stub.js +5 -0
@@ -1,9 +1,22 @@
1
- export default function cloneNodes(nodes, source) {
1
+ export default function cloneNodes(nodes, source = undefined, raws = undefined) {
2
2
  return nodes.map((node) => {
3
3
  let cloned = node.clone()
4
4
 
5
5
  if (source !== undefined) {
6
6
  cloned.source = source
7
+
8
+ if ('walk' in cloned) {
9
+ cloned.walk((child) => {
10
+ child.source = source
11
+ })
12
+ }
13
+ }
14
+
15
+ if (raws !== undefined) {
16
+ cloned.raws.tailwind = {
17
+ ...cloned.raws.tailwind,
18
+ ...raws,
19
+ }
7
20
  }
8
21
 
9
22
  return cloned
package/src/util/color.js CHANGED
@@ -2,14 +2,16 @@ import namedColors from 'color-name'
2
2
 
3
3
  let HEX = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i
4
4
  let SHORT_HEX = /^#([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i
5
- let VALUE = `(?:\\d+|\\d*\\.\\d+)%?`
6
- let SEP = `(?:\\s*,\\s*|\\s+)`
7
- let ALPHA_SEP = `\\s*[,/]\\s*`
5
+ let VALUE = /(?:\d+|\d*\.\d+)%?/
6
+ let SEP = /(?:\s*,\s*|\s+)/
7
+ let ALPHA_SEP = /\s*[,/]\s*/
8
+ let CUSTOM_PROPERTY = /var\(--(?:[^ )]*?)\)/
9
+
8
10
  let RGB = new RegExp(
9
- `^rgba?\\(\\s*(${VALUE})${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`
11
+ `^rgba?\\(\\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*\\)$`
10
12
  )
11
13
  let HSL = new RegExp(
12
- `^hsla?\\(\\s*((?:${VALUE})(?:deg|rad|grad|turn)?)${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`
14
+ `^hsla?\\(\\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*\\)$`
13
15
  )
14
16
 
15
17
  export function parseColor(value) {
@@ -57,7 +57,9 @@ export function number(value) {
57
57
  }
58
58
 
59
59
  export function percentage(value) {
60
- return /%$/g.test(value) || cssFunctions.some((fn) => new RegExp(`^${fn}\\(.+?%`).test(value))
60
+ return value.split(UNDERSCORE).every((part) => {
61
+ return /%$/g.test(part) || cssFunctions.some((fn) => new RegExp(`^${fn}\\(.+?%`).test(part))
62
+ })
61
63
  }
62
64
 
63
65
  let lengthUnits = [
package/src/util/log.js CHANGED
@@ -1,29 +1,29 @@
1
- import chalk from 'chalk'
1
+ import colors from 'picocolors'
2
2
 
3
3
  let alreadyShown = new Set()
4
4
 
5
- function log(chalk, messages, key) {
5
+ function log(type, messages, key) {
6
6
  if (process.env.JEST_WORKER_ID !== undefined) return
7
7
 
8
8
  if (key && alreadyShown.has(key)) return
9
9
  if (key) alreadyShown.add(key)
10
10
 
11
11
  console.warn('')
12
- messages.forEach((message) => console.warn(chalk, '-', message))
12
+ messages.forEach((message) => console.warn(type, '-', message))
13
13
  }
14
14
 
15
15
  export function dim(input) {
16
- return chalk.dim(input)
16
+ return colors.dim(input)
17
17
  }
18
18
 
19
19
  export default {
20
20
  info(key, messages) {
21
- log(chalk.bold.cyan('info'), ...(Array.isArray(key) ? [key] : [messages, key]))
21
+ log(colors.bold(colors.cyan('info')), ...(Array.isArray(key) ? [key] : [messages, key]))
22
22
  },
23
23
  warn(key, messages) {
24
- log(chalk.bold.yellow('warn'), ...(Array.isArray(key) ? [key] : [messages, key]))
24
+ log(colors.bold(colors.yellow('warn')), ...(Array.isArray(key) ? [key] : [messages, key]))
25
25
  },
26
26
  risk(key, messages) {
27
- log(chalk.bold.magenta('risk'), ...(Array.isArray(key) ? [key] : [messages, key]))
27
+ log(colors.bold(colors.magenta('risk')), ...(Array.isArray(key) ? [key] : [messages, key]))
28
28
  },
29
29
  }
@@ -1,10 +1,58 @@
1
1
  let KEYWORDS = new Set(['inset', 'inherit', 'initial', 'revert', 'unset'])
2
- let COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
3
2
  let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
4
3
  let LENGTH = /^-?(\d+|\.\d+)(.*?)$/g
5
4
 
5
+ let SPECIALS = /[(),]/g
6
+
7
+ /**
8
+ * This splits a string on top-level commas.
9
+ *
10
+ * Regex doesn't support recursion (at least not the JS-flavored version).
11
+ * So we have to use a tiny state machine to keep track of paren vs comma
12
+ * placement. Before we'd only exclude commas from the inner-most nested
13
+ * set of parens rather than any commas that were not contained in parens
14
+ * at all which is the intended behavior here.
15
+ *
16
+ * Expected behavior:
17
+ * var(--a, 0 0 1px rgb(0, 0, 0)), 0 0 1px rgb(0, 0, 0)
18
+ * ─┬─ ┬ ┬ ┬
19
+ * x x x ╰──────── Split because top-level
20
+ * ╰──────────────┴──┴───────────── Ignored b/c inside >= 1 levels of parens
21
+ *
22
+ * @param {string} input
23
+ */
24
+ function* splitByTopLevelCommas(input) {
25
+ SPECIALS.lastIndex = -1
26
+
27
+ let depth = 0
28
+ let lastIndex = 0
29
+ let found = false
30
+
31
+ // Find all parens & commas
32
+ // And only split on commas if they're top-level
33
+ for (let match of input.matchAll(SPECIALS)) {
34
+ if (match[0] === '(') depth++
35
+ if (match[0] === ')') depth--
36
+ if (match[0] === ',' && depth === 0) {
37
+ found = true
38
+
39
+ yield input.substring(lastIndex, match.index)
40
+ lastIndex = match.index + match[0].length
41
+ }
42
+ }
43
+
44
+ // Provide the last segment of the string if available
45
+ // Otherwise the whole string since no commas were found
46
+ // This mirrors the behavior of string.split()
47
+ if (found) {
48
+ yield input.substring(lastIndex)
49
+ } else {
50
+ yield input
51
+ }
52
+ }
53
+
6
54
  export function parseBoxShadowValue(input) {
7
- let shadows = input.split(COMMA)
55
+ let shadows = Array.from(splitByTopLevelCommas(input))
8
56
  return shadows.map((shadow) => {
9
57
  let value = shadow.trim()
10
58
  let result = { raw: value }
@@ -66,6 +66,38 @@ const configUtils = {
66
66
  {}
67
67
  )
68
68
  },
69
+ /*
70
+ rgb(property) {
71
+ if (!property.startsWith('--')) {
72
+ throw new Error(
73
+ 'The rgb() helper requires a custom property name to be passed as the first argument.'
74
+ )
75
+ }
76
+
77
+ return ({ opacityValue }) => {
78
+ if (opacityValue === undefined || opacityValue === 1) {
79
+ return `rgb(var(${property}) / 1.0)`
80
+ }
81
+
82
+ return `rgb(var(${property}) / ${opacityValue})`
83
+ }
84
+ },
85
+ hsl(property) {
86
+ if (!property.startsWith('--')) {
87
+ throw new Error(
88
+ 'The hsl() helper requires a custom property name to be passed as the first argument.'
89
+ )
90
+ }
91
+
92
+ return ({ opacityValue }) => {
93
+ if (opacityValue === undefined || opacityValue === 1) {
94
+ return `hsl(var(${property}) / 1)`
95
+ }
96
+
97
+ return `hsl(var(${property}) / ${opacityValue})`
98
+ }
99
+ },
100
+ */
69
101
  }
70
102
 
71
103
  function value(valueToResolve, ...args) {
@@ -194,6 +194,11 @@ module.exports = {
194
194
  '3xl': '1.5rem',
195
195
  full: '9999px',
196
196
  },
197
+ /*
198
+ borderSpacing: ({ theme }) => ({
199
+ ...theme('spacing'),
200
+ }),
201
+ */
197
202
  borderWidth: {
198
203
  DEFAULT: '1px',
199
204
  0: '0px',