tailwindcss 3.3.1 → 3.3.2

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 (122) hide show
  1. package/CHANGELOG.md +22 -6
  2. package/lib/cli/build/deps.js +17 -9
  3. package/lib/cli/build/index.js +10 -8
  4. package/lib/cli/build/plugin.js +27 -25
  5. package/lib/cli/build/utils.js +18 -8
  6. package/lib/cli/build/watching.js +12 -10
  7. package/lib/cli/help/index.js +6 -4
  8. package/lib/cli/index.js +4 -4
  9. package/lib/cli/init/index.js +8 -6
  10. package/lib/cli-peer-dependencies.js +12 -4
  11. package/lib/cli.js +1 -1
  12. package/lib/corePluginList.js +3 -1
  13. package/lib/corePlugins.js +41 -35
  14. package/lib/featureFlags.js +14 -9
  15. package/lib/index.js +1 -5
  16. package/lib/lib/cacheInvalidation.js +7 -5
  17. package/lib/lib/collapseAdjacentRules.js +3 -1
  18. package/lib/lib/collapseDuplicateDeclarations.js +10 -8
  19. package/lib/lib/content.js +18 -14
  20. package/lib/lib/defaultExtractor.js +6 -4
  21. package/lib/lib/detectNesting.js +3 -1
  22. package/lib/lib/evaluateTailwindFunctions.js +18 -16
  23. package/lib/lib/expandApplyAtRules.js +37 -40
  24. package/lib/lib/expandTailwindAtRules.js +15 -13
  25. package/lib/lib/findAtConfigPath.js +6 -4
  26. package/lib/lib/generateRules.js +37 -31
  27. package/lib/lib/getModuleDependencies.js +10 -8
  28. package/lib/lib/load-config.js +5 -3
  29. package/lib/lib/normalizeTailwindDirectives.js +5 -3
  30. package/lib/lib/offsets.js +7 -5
  31. package/lib/lib/partitionApplyAtRules.js +3 -1
  32. package/lib/lib/regex.js +21 -7
  33. package/lib/lib/remap-bitfield.js +3 -1
  34. package/lib/lib/resolveDefaultsAtRules.js +24 -20
  35. package/lib/lib/setupContextUtils.js +67 -57
  36. package/lib/lib/setupTrackingContext.js +26 -24
  37. package/lib/lib/sharedState.js +28 -24
  38. package/lib/lib/substituteScreenAtRules.js +5 -3
  39. package/lib/oxide/cli/build/deps.js +16 -8
  40. package/lib/oxide/cli/build/index.js +6 -4
  41. package/lib/oxide/cli/build/plugin.js +19 -17
  42. package/lib/oxide/cli/build/utils.js +18 -8
  43. package/lib/oxide/cli/build/watching.js +10 -8
  44. package/lib/oxide/cli/help/index.js +6 -4
  45. package/lib/oxide/cli/index.js +4 -4
  46. package/lib/oxide/cli/init/index.js +6 -4
  47. package/lib/plugin.js +7 -7
  48. package/lib/postcss-plugins/nesting/index.js +3 -1
  49. package/lib/postcss-plugins/nesting/plugin.js +8 -6
  50. package/lib/processTailwindFeatures.js +14 -12
  51. package/lib/public/colors.js +5 -3
  52. package/lib/public/create-plugin.js +5 -3
  53. package/lib/public/default-config.js +6 -4
  54. package/lib/public/default-theme.js +6 -4
  55. package/lib/public/load-config.js +5 -3
  56. package/lib/public/resolve-config.js +6 -4
  57. package/lib/util/applyImportantSelector.js +9 -10
  58. package/lib/util/bigSign.js +3 -1
  59. package/lib/util/buildMediaQuery.js +3 -1
  60. package/lib/util/cloneDeep.js +3 -1
  61. package/lib/util/cloneNodes.js +3 -1
  62. package/lib/util/color.js +10 -6
  63. package/lib/util/colorNames.js +752 -0
  64. package/lib/util/configurePlugins.js +3 -1
  65. package/lib/util/createPlugin.js +3 -1
  66. package/lib/util/createUtilityPlugin.js +5 -3
  67. package/lib/util/dataTypes.js +45 -15
  68. package/lib/util/defaults.js +6 -4
  69. package/lib/util/escapeClassName.js +7 -5
  70. package/lib/util/escapeCommas.js +3 -1
  71. package/lib/util/flattenColorPalette.js +3 -1
  72. package/lib/util/formatVariantSelector.js +28 -108
  73. package/lib/util/getAllConfigs.js +6 -4
  74. package/lib/util/hashConfig.js +6 -4
  75. package/lib/util/isKeyframeRule.js +3 -1
  76. package/lib/util/isPlainObject.js +3 -1
  77. package/lib/util/isSyntacticallyValidPropertyValue.js +3 -1
  78. package/lib/util/log.js +8 -4
  79. package/lib/util/nameClass.js +12 -6
  80. package/lib/util/negateValue.js +3 -1
  81. package/lib/util/normalizeConfig.js +7 -5
  82. package/lib/util/normalizeScreens.js +12 -4
  83. package/lib/util/parseAnimationValue.js +3 -1
  84. package/lib/util/parseBoxShadowValue.js +6 -2
  85. package/lib/util/parseDependency.js +3 -1
  86. package/lib/util/parseGlob.js +6 -4
  87. package/lib/util/parseObjectStyles.js +9 -7
  88. package/lib/util/pluginUtils.js +30 -18
  89. package/lib/util/prefixSelector.js +6 -4
  90. package/lib/util/pseudoElements.js +225 -0
  91. package/lib/util/removeAlphaVariables.js +3 -1
  92. package/lib/util/resolveConfig.js +10 -8
  93. package/lib/util/resolveConfigPath.js +9 -5
  94. package/lib/util/responsive.js +6 -4
  95. package/lib/util/splitAtTopLevelOnly.js +3 -1
  96. package/lib/util/tap.js +3 -1
  97. package/lib/util/toColorValue.js +3 -1
  98. package/lib/util/toPath.js +3 -1
  99. package/lib/util/transformThemeValue.js +6 -4
  100. package/lib/util/validateConfig.js +5 -3
  101. package/lib/util/validateFormalSyntax.js +3 -1
  102. package/lib/util/withAlphaVariable.js +6 -2
  103. package/package.json +30 -34
  104. package/peers/index.js +65828 -48819
  105. package/src/cli/build/plugin.js +1 -1
  106. package/src/cli.js +1 -1
  107. package/src/corePlugins.js +16 -17
  108. package/src/featureFlags.js +2 -3
  109. package/src/index.js +1 -5
  110. package/src/lib/defaultExtractor.js +1 -1
  111. package/src/lib/expandApplyAtRules.js +2 -8
  112. package/src/lib/expandTailwindAtRules.js +3 -3
  113. package/src/lib/setupTrackingContext.js +1 -1
  114. package/src/lib/sharedState.js +0 -15
  115. package/src/oxide/cli/build/plugin.ts +1 -1
  116. package/src/plugin.js +1 -1
  117. package/src/util/applyImportantSelector.js +2 -5
  118. package/src/util/color.js +1 -1
  119. package/src/util/colorNames.js +150 -0
  120. package/src/util/formatVariantSelector.js +2 -124
  121. package/src/util/pluginUtils.js +1 -5
  122. package/src/util/pseudoElements.js +170 -0
@@ -0,0 +1,170 @@
1
+ /** @typedef {import('postcss-selector-parser').Root} Root */
2
+ /** @typedef {import('postcss-selector-parser').Selector} Selector */
3
+ /** @typedef {import('postcss-selector-parser').Pseudo} Pseudo */
4
+ /** @typedef {import('postcss-selector-parser').Node} Node */
5
+
6
+ // There are some pseudo-elements that may or may not be:
7
+
8
+ // **Actionable**
9
+ // Zero or more user-action pseudo-classes may be attached to the pseudo-element itself
10
+ // structural-pseudo-classes are NOT allowed but we don't make
11
+ // The spec is not clear on whether this is allowed or not — but in practice it is.
12
+
13
+ // **Terminal**
14
+ // It MUST be placed at the end of a selector
15
+ //
16
+ // This is the required in the spec. However, some pseudo elements are not "terminal" because
17
+ // they represent a "boundary piercing" that is compiled out by a build step.
18
+
19
+ // **Jumpable**
20
+ // Any terminal element may "jump" over combinators when moving to the end of the selector
21
+ //
22
+ // This is a backwards-compat quirk of :before and :after variants.
23
+
24
+ /** @typedef {'terminal' | 'actionable' | 'jumpable'} PseudoProperty */
25
+
26
+ /** @type {Record<string, PseudoProperty[]>} */
27
+ let elementProperties = {
28
+ '::after': ['terminal', 'jumpable'],
29
+ '::backdrop': ['terminal'],
30
+ '::before': ['terminal', 'jumpable'],
31
+ '::cue': ['terminal'],
32
+ '::cue-region': ['terminal'],
33
+ '::first-letter': ['terminal', 'jumpable'],
34
+ '::first-line': ['terminal', 'jumpable'],
35
+ '::grammar-error': ['terminal'],
36
+ '::marker': ['terminal'],
37
+ '::part': ['terminal', 'actionable'],
38
+ '::placeholder': ['terminal'],
39
+ '::selection': ['terminal'],
40
+ '::slotted': ['terminal'],
41
+ '::spelling-error': ['terminal'],
42
+ '::target-text': ['terminal'],
43
+
44
+ // other
45
+ '::file-selector-button': ['terminal', 'actionable'],
46
+ '::-webkit-progress-bar': ['terminal', 'actionable'],
47
+
48
+ // Webkit scroll bar pseudo elements can be combined with user-action pseudo classes
49
+ '::-webkit-scrollbar': ['terminal', 'actionable'],
50
+ '::-webkit-scrollbar-button': ['terminal', 'actionable'],
51
+ '::-webkit-scrollbar-thumb': ['terminal', 'actionable'],
52
+ '::-webkit-scrollbar-track': ['terminal', 'actionable'],
53
+ '::-webkit-scrollbar-track-piece': ['terminal', 'actionable'],
54
+ '::-webkit-scrollbar-corner': ['terminal', 'actionable'],
55
+ '::-webkit-resizer': ['terminal', 'actionable'],
56
+
57
+ // Note: As a rule, double colons (::) should be used instead of a single colon
58
+ // (:). This distinguishes pseudo-classes from pseudo-elements. However, since
59
+ // this distinction was not present in older versions of the W3C spec, most
60
+ // browsers support both syntaxes for the original pseudo-elements.
61
+ ':after': ['terminal', 'jumpable'],
62
+ ':before': ['terminal', 'jumpable'],
63
+ ':first-letter': ['terminal', 'jumpable'],
64
+ ':first-line': ['terminal', 'jumpable'],
65
+
66
+ // The default value is used when the pseudo-element is not recognized
67
+ // Because it's not recognized, we don't know if it's terminal or not
68
+ // So we assume it can't be moved AND can have user-action pseudo classes attached to it
69
+ __default__: ['actionable'],
70
+ }
71
+
72
+ /**
73
+ * @param {Selector} sel
74
+ * @returns {Selector}
75
+ */
76
+ export function movePseudos(sel) {
77
+ let [pseudos] = movablePseudos(sel)
78
+
79
+ // Remove all pseudo elements from their respective selectors
80
+ pseudos.forEach(([sel, pseudo]) => sel.removeChild(pseudo))
81
+
82
+ // Re-add them to the end of the selector in the correct order.
83
+ // This moves terminal pseudo elements to the end of the
84
+ // selector otherwise the selector will not be valid.
85
+ //
86
+ // Examples:
87
+ // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
88
+ // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
89
+ //
90
+ // The selector `::before:hover` does not work but we
91
+ // can make it work for you by flipping the order.
92
+ sel.nodes.push(...pseudos.map(([, pseudo]) => pseudo))
93
+
94
+ return sel
95
+ }
96
+
97
+ /** @typedef {[sel: Selector, pseudo: Pseudo, attachedTo: Pseudo | null]} MovablePseudo */
98
+ /** @typedef {[pseudos: MovablePseudo[], lastSeenElement: Pseudo | null]} MovablePseudosResult */
99
+
100
+ /**
101
+ * @param {Selector} sel
102
+ * @returns {MovablePseudosResult}
103
+ */
104
+ function movablePseudos(sel) {
105
+ /** @type {MovablePseudo[]} */
106
+ let buffer = []
107
+
108
+ /** @type {Pseudo | null} */
109
+ let lastSeenElement = null
110
+
111
+ for (let node of sel.nodes) {
112
+ if (node.type === 'combinator') {
113
+ buffer = buffer.filter(([, node]) => propertiesForPseudo(node).includes('jumpable'))
114
+ lastSeenElement = null
115
+ } else if (node.type === 'pseudo') {
116
+ if (isMovablePseudoElement(node)) {
117
+ lastSeenElement = node
118
+ buffer.push([sel, node, null])
119
+ } else if (lastSeenElement && isAttachablePseudoClass(node, lastSeenElement)) {
120
+ buffer.push([sel, node, lastSeenElement])
121
+ } else {
122
+ lastSeenElement = null
123
+ }
124
+
125
+ for (let sub of node.nodes ?? []) {
126
+ let [movable, lastSeenElementInSub] = movablePseudos(sub)
127
+ lastSeenElement = lastSeenElementInSub || lastSeenElement
128
+ buffer.push(...movable)
129
+ }
130
+ }
131
+ }
132
+
133
+ return [buffer, lastSeenElement]
134
+ }
135
+
136
+ /**
137
+ * @param {Node} node
138
+ * @returns {boolean}
139
+ */
140
+ function isPseudoElement(node) {
141
+ return node.value.startsWith('::') || elementProperties[node.value] !== undefined
142
+ }
143
+
144
+ /**
145
+ * @param {Node} node
146
+ * @returns {boolean}
147
+ */
148
+ function isMovablePseudoElement(node) {
149
+ return isPseudoElement(node) && propertiesForPseudo(node).includes('terminal')
150
+ }
151
+
152
+ /**
153
+ * @param {Node} node
154
+ * @param {Pseudo} pseudo
155
+ * @returns {boolean}
156
+ */
157
+ function isAttachablePseudoClass(node, pseudo) {
158
+ if (node.type !== 'pseudo') return false
159
+ if (isPseudoElement(node)) return false
160
+
161
+ return propertiesForPseudo(pseudo).includes('actionable')
162
+ }
163
+
164
+ /**
165
+ * @param {Pseudo} pseudo
166
+ * @returns {PseudoProperty[]}
167
+ */
168
+ function propertiesForPseudo(pseudo) {
169
+ return elementProperties[pseudo.value] ?? elementProperties.__default__
170
+ }