tailwindcss 0.0.0-insiders.ea80db2 → 0.0.0-insiders.ea90d3a

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 (214) hide show
  1. package/README.md +13 -10
  2. package/defaultTheme.d.ts +2 -1
  3. package/lib/cli/build/deps.js +62 -0
  4. package/lib/cli/build/index.js +54 -0
  5. package/lib/cli/build/plugin.js +371 -0
  6. package/lib/cli/build/utils.js +88 -0
  7. package/lib/cli/build/watching.js +182 -0
  8. package/lib/cli/help/index.js +73 -0
  9. package/lib/cli/index.js +230 -0
  10. package/lib/cli/init/index.js +63 -0
  11. package/lib/cli-peer-dependencies.js +28 -7
  12. package/lib/cli.js +1 -759
  13. package/lib/corePluginList.js +16 -4
  14. package/lib/corePlugins.js +2421 -1738
  15. package/lib/css/preflight.css +31 -12
  16. package/lib/featureFlags.js +45 -25
  17. package/lib/index.js +1 -40
  18. package/lib/lib/cacheInvalidation.js +48 -25
  19. package/lib/lib/collapseAdjacentRules.js +17 -10
  20. package/lib/lib/collapseDuplicateDeclarations.js +13 -8
  21. package/lib/lib/content.js +214 -0
  22. package/lib/lib/defaultExtractor.js +240 -33
  23. package/lib/lib/detectNesting.js +21 -10
  24. package/lib/lib/evaluateTailwindFunctions.js +117 -50
  25. package/lib/lib/expandApplyAtRules.js +322 -215
  26. package/lib/lib/expandTailwindAtRules.js +132 -115
  27. package/lib/lib/findAtConfigPath.js +46 -0
  28. package/lib/lib/generateRules.js +466 -208
  29. package/lib/lib/getModuleDependencies.js +88 -37
  30. package/lib/lib/load-config.js +57 -0
  31. package/lib/lib/normalizeTailwindDirectives.js +38 -33
  32. package/lib/lib/offsets.js +355 -0
  33. package/lib/lib/partitionApplyAtRules.js +13 -8
  34. package/lib/lib/regex.js +74 -0
  35. package/lib/lib/remap-bitfield.js +89 -0
  36. package/lib/lib/resolveDefaultsAtRules.js +98 -74
  37. package/lib/lib/setupContextUtils.js +744 -319
  38. package/lib/lib/setupTrackingContext.js +63 -68
  39. package/lib/lib/sharedState.js +44 -17
  40. package/lib/lib/substituteScreenAtRules.js +14 -10
  41. package/lib/plugin.js +48 -0
  42. package/lib/postcss-plugins/nesting/README.md +2 -2
  43. package/lib/postcss-plugins/nesting/index.js +10 -6
  44. package/lib/postcss-plugins/nesting/plugin.js +24 -20
  45. package/lib/processTailwindFeatures.js +35 -30
  46. package/lib/public/colors.js +272 -246
  47. package/lib/public/create-plugin.js +9 -5
  48. package/lib/public/default-config.js +10 -6
  49. package/lib/public/default-theme.js +10 -6
  50. package/lib/public/load-config.js +12 -0
  51. package/lib/public/resolve-config.js +11 -6
  52. package/lib/util/applyImportantSelector.js +36 -0
  53. package/lib/util/bigSign.js +6 -1
  54. package/lib/util/buildMediaQuery.js +13 -6
  55. package/lib/util/cloneDeep.js +9 -6
  56. package/lib/util/cloneNodes.js +39 -10
  57. package/lib/util/color.js +67 -51
  58. package/lib/util/colorNames.js +752 -0
  59. package/lib/util/configurePlugins.js +7 -2
  60. package/lib/util/createPlugin.js +8 -5
  61. package/lib/util/createUtilityPlugin.js +13 -9
  62. package/lib/util/dataTypes.js +295 -113
  63. package/lib/util/defaults.js +12 -7
  64. package/lib/util/escapeClassName.js +13 -8
  65. package/lib/util/escapeCommas.js +7 -2
  66. package/lib/util/flattenColorPalette.js +11 -10
  67. package/lib/util/formatVariantSelector.js +235 -151
  68. package/lib/util/getAllConfigs.js +33 -12
  69. package/lib/util/hashConfig.js +9 -4
  70. package/lib/util/isKeyframeRule.js +7 -2
  71. package/lib/util/isPlainObject.js +8 -3
  72. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +25 -15
  73. package/lib/util/log.js +23 -13
  74. package/lib/util/nameClass.js +27 -10
  75. package/lib/util/negateValue.js +25 -8
  76. package/lib/util/normalizeConfig.js +124 -82
  77. package/lib/util/normalizeScreens.js +127 -8
  78. package/lib/util/parseAnimationValue.js +44 -40
  79. package/lib/util/parseBoxShadowValue.js +33 -62
  80. package/lib/util/parseDependency.js +39 -55
  81. package/lib/util/parseGlob.js +36 -0
  82. package/lib/util/parseObjectStyles.js +15 -10
  83. package/lib/util/pluginUtils.js +169 -59
  84. package/lib/util/prefixSelector.js +29 -10
  85. package/lib/util/pseudoElements.js +212 -0
  86. package/lib/util/removeAlphaVariables.js +31 -0
  87. package/lib/util/resolveConfig.js +96 -95
  88. package/lib/util/resolveConfigPath.js +29 -10
  89. package/lib/util/responsive.js +11 -6
  90. package/lib/util/splitAtTopLevelOnly.js +51 -0
  91. package/lib/util/tap.js +6 -1
  92. package/lib/util/toColorValue.js +7 -2
  93. package/lib/util/toPath.js +22 -4
  94. package/lib/util/transformThemeValue.js +40 -26
  95. package/lib/util/validateConfig.js +37 -0
  96. package/lib/util/validateFormalSyntax.js +26 -0
  97. package/lib/util/withAlphaVariable.js +27 -15
  98. package/lib/value-parser/LICENSE +22 -0
  99. package/lib/value-parser/README.md +3 -0
  100. package/lib/value-parser/index.d.js +2 -0
  101. package/lib/value-parser/index.js +22 -0
  102. package/lib/value-parser/parse.js +259 -0
  103. package/lib/value-parser/stringify.js +38 -0
  104. package/lib/value-parser/unit.js +86 -0
  105. package/lib/value-parser/walk.js +16 -0
  106. package/loadConfig.d.ts +4 -0
  107. package/loadConfig.js +2 -0
  108. package/nesting/index.d.ts +4 -0
  109. package/package.json +50 -43
  110. package/peers/index.js +72234 -50887
  111. package/plugin.d.ts +10 -5
  112. package/resolveConfig.d.ts +31 -0
  113. package/scripts/generate-types.js +52 -0
  114. package/scripts/release-channel.js +18 -0
  115. package/scripts/release-notes.js +21 -0
  116. package/scripts/type-utils.js +27 -0
  117. package/src/cli/build/deps.js +56 -0
  118. package/src/cli/build/index.js +49 -0
  119. package/src/cli/build/plugin.js +437 -0
  120. package/src/cli/build/utils.js +76 -0
  121. package/src/cli/build/watching.js +229 -0
  122. package/src/cli/help/index.js +70 -0
  123. package/src/cli/index.js +216 -0
  124. package/src/cli/init/index.js +79 -0
  125. package/src/cli-peer-dependencies.js +7 -1
  126. package/src/cli.js +1 -836
  127. package/src/corePluginList.js +1 -1
  128. package/src/corePlugins.js +665 -107
  129. package/src/css/preflight.css +31 -12
  130. package/src/featureFlags.js +10 -2
  131. package/src/index.js +1 -42
  132. package/src/lib/collapseAdjacentRules.js +5 -1
  133. package/src/lib/content.js +249 -0
  134. package/src/lib/defaultExtractor.js +215 -35
  135. package/src/lib/detectNesting.js +9 -1
  136. package/src/lib/evaluateTailwindFunctions.js +82 -8
  137. package/src/lib/expandApplyAtRules.js +329 -189
  138. package/src/lib/expandTailwindAtRules.js +46 -56
  139. package/src/lib/findAtConfigPath.js +48 -0
  140. package/src/lib/generateRules.js +439 -130
  141. package/src/lib/getModuleDependencies.js +70 -30
  142. package/src/lib/load-config.ts +44 -0
  143. package/src/lib/offsets.js +432 -0
  144. package/src/lib/regex.js +74 -0
  145. package/src/lib/remap-bitfield.js +82 -0
  146. package/src/lib/resolveDefaultsAtRules.js +57 -36
  147. package/src/lib/setupContextUtils.js +654 -182
  148. package/src/lib/setupTrackingContext.js +44 -58
  149. package/src/lib/sharedState.js +13 -4
  150. package/src/plugin.js +47 -0
  151. package/src/postcss-plugins/nesting/README.md +2 -2
  152. package/src/processTailwindFeatures.js +3 -2
  153. package/src/public/colors.js +22 -0
  154. package/src/public/default-config.js +1 -1
  155. package/src/public/default-theme.js +2 -2
  156. package/src/public/load-config.js +2 -0
  157. package/src/util/applyImportantSelector.js +27 -0
  158. package/src/util/buildMediaQuery.js +5 -3
  159. package/src/util/cloneNodes.js +35 -10
  160. package/src/util/color.js +35 -18
  161. package/src/util/colorNames.js +150 -0
  162. package/src/util/dataTypes.js +183 -25
  163. package/src/util/formatVariantSelector.js +272 -144
  164. package/src/util/getAllConfigs.js +21 -2
  165. package/src/util/isPlainObject.js +1 -1
  166. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  167. package/src/util/log.js +1 -1
  168. package/src/util/nameClass.js +4 -0
  169. package/src/util/negateValue.js +11 -3
  170. package/src/util/normalizeConfig.js +41 -10
  171. package/src/util/normalizeScreens.js +99 -4
  172. package/src/util/parseBoxShadowValue.js +3 -50
  173. package/src/util/parseDependency.js +37 -42
  174. package/src/util/parseGlob.js +24 -0
  175. package/src/util/pluginUtils.js +139 -24
  176. package/src/util/prefixSelector.js +29 -10
  177. package/src/util/pseudoElements.js +171 -0
  178. package/src/util/removeAlphaVariables.js +24 -0
  179. package/src/util/resolveConfig.js +70 -62
  180. package/src/util/resolveConfigPath.js +12 -1
  181. package/src/util/splitAtTopLevelOnly.js +52 -0
  182. package/src/util/toPath.js +1 -1
  183. package/src/util/transformThemeValue.js +13 -3
  184. package/src/util/validateConfig.js +26 -0
  185. package/src/util/validateFormalSyntax.js +34 -0
  186. package/src/util/withAlphaVariable.js +1 -1
  187. package/src/value-parser/LICENSE +22 -0
  188. package/src/value-parser/README.md +3 -0
  189. package/src/value-parser/index.d.ts +177 -0
  190. package/src/value-parser/index.js +28 -0
  191. package/src/value-parser/parse.js +303 -0
  192. package/src/value-parser/stringify.js +41 -0
  193. package/src/value-parser/unit.js +118 -0
  194. package/src/value-parser/walk.js +18 -0
  195. package/stubs/.gitignore +1 -0
  196. package/stubs/.prettierrc.json +6 -0
  197. package/stubs/{defaultConfig.stub.js → config.full.js} +287 -178
  198. package/stubs/postcss.config.js +6 -0
  199. package/stubs/tailwind.config.cjs +2 -0
  200. package/stubs/tailwind.config.js +2 -0
  201. package/stubs/tailwind.config.ts +3 -0
  202. package/types/config.d.ts +113 -60
  203. package/types/generated/colors.d.ts +22 -0
  204. package/types/generated/corePluginList.d.ts +1 -1
  205. package/types/generated/default-theme.d.ts +397 -0
  206. package/types/index.d.ts +11 -1
  207. package/CHANGELOG.md +0 -2099
  208. package/lib/constants.js +0 -37
  209. package/scripts/install-integrations.js +0 -27
  210. package/scripts/rebuildFixtures.js +0 -68
  211. package/src/constants.js +0 -17
  212. package/types.d.ts +0 -1
  213. /package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -0
  214. /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
@@ -12,15 +12,39 @@ import isPlainObject from './util/isPlainObject'
12
12
  import transformThemeValue from './util/transformThemeValue'
13
13
  import { version as tailwindVersion } from '../package.json'
14
14
  import log from './util/log'
15
- import { normalizeScreens } from './util/normalizeScreens'
15
+ import {
16
+ normalizeScreens,
17
+ isScreenSortable,
18
+ compareScreens,
19
+ toScreen,
20
+ } from './util/normalizeScreens'
16
21
  import { formatBoxShadowValue, parseBoxShadowValue } from './util/parseBoxShadowValue'
22
+ import { removeAlphaVariables } from './util/removeAlphaVariables'
23
+ import { flagEnabled } from './featureFlags'
24
+ import { normalize } from './util/dataTypes'
25
+ import { INTERNAL_FEATURES } from './lib/setupContextUtils'
17
26
 
18
27
  export let variantPlugins = {
28
+ childVariant: ({ addVariant }) => {
29
+ addVariant('*', '& > *')
30
+ },
19
31
  pseudoElementVariants: ({ addVariant }) => {
20
32
  addVariant('first-letter', '&::first-letter')
21
33
  addVariant('first-line', '&::first-line')
22
34
 
23
- addVariant('marker', ['& *::marker', '&::marker'])
35
+ addVariant('marker', [
36
+ ({ container }) => {
37
+ removeAlphaVariables(container, ['--tw-text-opacity'])
38
+
39
+ return '& *::marker'
40
+ },
41
+ ({ container }) => {
42
+ removeAlphaVariables(container, ['--tw-text-opacity'])
43
+
44
+ return '&::marker'
45
+ },
46
+ ])
47
+
24
48
  addVariant('selection', ['& *::selection', '&::selection'])
25
49
 
26
50
  addVariant('file', '&::file-selector-button')
@@ -60,14 +84,14 @@ export let variantPlugins = {
60
84
  })
61
85
  },
62
86
 
63
- pseudoClassVariants: ({ addVariant }) => {
87
+ pseudoClassVariants: ({ addVariant, matchVariant, config, prefix }) => {
64
88
  let pseudoVariants = [
65
89
  // Positional
66
- ['first', ':first-child'],
67
- ['last', ':last-child'],
68
- ['only', ':only-child'],
69
- ['odd', ':nth-child(odd)'],
70
- ['even', ':nth-child(even)'],
90
+ ['first', '&:first-child'],
91
+ ['last', '&:last-child'],
92
+ ['only', '&:only-child'],
93
+ ['odd', '&:nth-child(odd)'],
94
+ ['even', '&:nth-child(even)'],
71
95
  'first-of-type',
72
96
  'last-of-type',
73
97
  'only-of-type',
@@ -76,27 +100,17 @@ export let variantPlugins = {
76
100
  [
77
101
  'visited',
78
102
  ({ container }) => {
79
- let toRemove = ['--tw-text-opacity', '--tw-border-opacity', '--tw-bg-opacity']
80
-
81
- container.walkDecls((decl) => {
82
- if (toRemove.includes(decl.prop)) {
83
- decl.remove()
103
+ removeAlphaVariables(container, [
104
+ '--tw-text-opacity',
105
+ '--tw-border-opacity',
106
+ '--tw-bg-opacity',
107
+ ])
84
108
 
85
- return
86
- }
87
-
88
- for (const varName of toRemove) {
89
- if (decl.value.includes(`/ var(${varName})`)) {
90
- decl.value = decl.value.replace(`/ var(${varName})`, '')
91
- }
92
- }
93
- })
94
-
95
- return ':visited'
109
+ return '&:visited'
96
110
  },
97
111
  ],
98
112
  'target',
99
- ['open', '[open]'],
113
+ ['open', '&[open]'],
100
114
 
101
115
  // Forms
102
116
  'default',
@@ -104,6 +118,7 @@ export let variantPlugins = {
104
118
  'indeterminate',
105
119
  'placeholder-shown',
106
120
  'autofill',
121
+ 'optional',
107
122
  'required',
108
123
  'valid',
109
124
  'invalid',
@@ -116,57 +131,84 @@ export let variantPlugins = {
116
131
 
117
132
  // Interactive
118
133
  'focus-within',
119
- 'hover',
134
+ [
135
+ 'hover',
136
+ !flagEnabled(config(), 'hoverOnlyWhenSupported')
137
+ ? '&:hover'
138
+ : '@media (hover: hover) and (pointer: fine) { &:hover }',
139
+ ],
120
140
  'focus',
121
141
  'focus-visible',
122
142
  'active',
123
143
  'enabled',
124
144
  'disabled',
125
- ].map((variant) => (Array.isArray(variant) ? variant : [variant, `:${variant}`]))
145
+ ].map((variant) => (Array.isArray(variant) ? variant : [variant, `&:${variant}`]))
126
146
 
127
147
  for (let [variantName, state] of pseudoVariants) {
128
148
  addVariant(variantName, (ctx) => {
129
149
  let result = typeof state === 'function' ? state(ctx) : state
130
150
 
131
- return `&${result}`
151
+ return result
132
152
  })
133
153
  }
134
154
 
135
- for (let [variantName, state] of pseudoVariants) {
136
- addVariant(`group-${variantName}`, (ctx) => {
137
- let result = typeof state === 'function' ? state(ctx) : state
138
-
139
- return `:merge(.group)${result} &`
140
- })
155
+ let variants = {
156
+ group: (_, { modifier }) =>
157
+ modifier
158
+ ? [`:merge(${prefix('.group')}\\/${escapeClassName(modifier)})`, ' &']
159
+ : [`:merge(${prefix('.group')})`, ' &'],
160
+ peer: (_, { modifier }) =>
161
+ modifier
162
+ ? [`:merge(${prefix('.peer')}\\/${escapeClassName(modifier)})`, ' ~ &']
163
+ : [`:merge(${prefix('.peer')})`, ' ~ &'],
141
164
  }
142
165
 
143
- for (let [variantName, state] of pseudoVariants) {
144
- addVariant(`peer-${variantName}`, (ctx) => {
145
- let result = typeof state === 'function' ? state(ctx) : state
166
+ for (let [name, fn] of Object.entries(variants)) {
167
+ matchVariant(
168
+ name,
169
+ (value = '', extra) => {
170
+ let result = normalize(typeof value === 'function' ? value(extra) : value)
171
+ if (!result.includes('&')) result = '&' + result
172
+
173
+ let [a, b] = fn('', extra)
174
+
175
+ let start = null
176
+ let end = null
177
+ let quotes = 0
178
+
179
+ for (let i = 0; i < result.length; ++i) {
180
+ let c = result[i]
181
+ if (c === '&') {
182
+ start = i
183
+ } else if (c === "'" || c === '"') {
184
+ quotes += 1
185
+ } else if (start !== null && c === ' ' && !quotes) {
186
+ end = i
187
+ }
188
+ }
146
189
 
147
- return `:merge(.peer)${result} ~ &`
148
- })
190
+ if (start !== null && end === null) {
191
+ end = result.length
192
+ }
193
+
194
+ // Basically this but can handle quotes:
195
+ // result.replace(/&(\S+)?/g, (_, pseudo = '') => a + pseudo + b)
196
+
197
+ return result.slice(0, start) + a + result.slice(start + 1, end) + b + result.slice(end)
198
+ },
199
+ {
200
+ values: Object.fromEntries(pseudoVariants),
201
+ [INTERNAL_FEATURES]: {
202
+ respectPrefix: false,
203
+ },
204
+ }
205
+ )
149
206
  }
150
207
  },
151
208
 
152
209
  directionVariants: ({ addVariant }) => {
153
- addVariant('ltr', () => {
154
- log.warn('rtl-experimental', [
155
- 'The RTL features in Tailwind CSS are currently in preview.',
156
- 'Preview features are not covered by semver, and may be improved in breaking ways at any time.',
157
- ])
158
-
159
- return '[dir="ltr"] &'
160
- })
161
-
162
- addVariant('rtl', () => {
163
- log.warn('rtl-experimental', [
164
- 'The RTL features in Tailwind CSS are currently in preview.',
165
- 'Preview features are not covered by semver, and may be improved in breaking ways at any time.',
166
- ])
167
-
168
- return '[dir="rtl"] &'
169
- })
210
+ addVariant('ltr', '&:where([dir="ltr"], [dir="ltr"] *)')
211
+ addVariant('rtl', '&:where([dir="rtl"], [dir="rtl"] *)')
170
212
  },
171
213
 
172
214
  reducedMotionVariants: ({ addVariant }) => {
@@ -175,7 +217,7 @@ export let variantPlugins = {
175
217
  },
176
218
 
177
219
  darkVariants: ({ config, addVariant }) => {
178
- let [mode, className = '.dark'] = [].concat(config('darkMode', 'media'))
220
+ let [mode, selector = '.dark'] = [].concat(config('darkMode', 'media'))
179
221
 
180
222
  if (mode === false) {
181
223
  mode = 'media'
@@ -186,10 +228,49 @@ export let variantPlugins = {
186
228
  ])
187
229
  }
188
230
 
189
- if (mode === 'class') {
190
- addVariant('dark', `${className} &`)
231
+ if (mode === 'variant') {
232
+ let formats
233
+ if (Array.isArray(selector)) {
234
+ formats = selector
235
+ } else if (typeof selector === 'function') {
236
+ formats = selector
237
+ } else if (typeof selector === 'string') {
238
+ formats = [selector]
239
+ }
240
+
241
+ // TODO: We could also add these warnings if the user passes a function that returns string | string[]
242
+ // But this is an advanced enough use case that it's probably not necessary
243
+ if (Array.isArray(formats)) {
244
+ for (let format of formats) {
245
+ if (format === '.dark') {
246
+ mode = false
247
+ log.warn('darkmode-variant-without-selector', [
248
+ 'When using `variant` for `darkMode`, you must provide a selector.',
249
+ 'Example: `darkMode: ["variant", ".your-selector &"]`',
250
+ ])
251
+ } else if (!format.includes('&')) {
252
+ mode = false
253
+ log.warn('darkmode-variant-without-ampersand', [
254
+ 'When using `variant` for `darkMode`, your selector must contain `&`.',
255
+ 'Example `darkMode: ["variant", ".your-selector &"]`',
256
+ ])
257
+ }
258
+ }
259
+ }
260
+
261
+ selector = formats
262
+ }
263
+
264
+ if (mode === 'selector') {
265
+ // New preferred behavior
266
+ addVariant('dark', `&:where(${selector}, ${selector} *)`)
191
267
  } else if (mode === 'media') {
192
268
  addVariant('dark', '@media (prefers-color-scheme: dark)')
269
+ } else if (mode === 'variant') {
270
+ addVariant('dark', selector)
271
+ } else if (mode === 'class') {
272
+ // Old behavior
273
+ addVariant('dark', `:is(${selector} &)`)
193
274
  }
194
275
  },
195
276
 
@@ -197,18 +278,235 @@ export let variantPlugins = {
197
278
  addVariant('print', '@media print')
198
279
  },
199
280
 
200
- screenVariants: ({ theme, addVariant }) => {
201
- for (let screen of normalizeScreens(theme('screens'))) {
202
- let query = buildMediaQuery(screen)
281
+ screenVariants: ({ theme, addVariant, matchVariant }) => {
282
+ let rawScreens = theme('screens') ?? {}
283
+ let areSimpleScreens = Object.values(rawScreens).every((v) => typeof v === 'string')
284
+ let screens = normalizeScreens(theme('screens'))
285
+
286
+ /** @type {Set<string>} */
287
+ let unitCache = new Set([])
288
+
289
+ /** @param {string} value */
290
+ function units(value) {
291
+ return value.match(/(\D+)$/)?.[1] ?? '(none)'
292
+ }
293
+
294
+ /** @param {string} value */
295
+ function recordUnits(value) {
296
+ if (value !== undefined) {
297
+ unitCache.add(units(value))
298
+ }
299
+ }
300
+
301
+ /** @param {string} value */
302
+ function canUseUnits(value) {
303
+ recordUnits(value)
304
+
305
+ // If the cache was empty it'll become 1 because we've just added the current unit
306
+ // If the cache was not empty and the units are the same the size doesn't change
307
+ // Otherwise, if the units are different from what is already known the size will always be > 1
308
+ return unitCache.size === 1
309
+ }
310
+
311
+ for (const screen of screens) {
312
+ for (const value of screen.values) {
313
+ recordUnits(value.min)
314
+ recordUnits(value.max)
315
+ }
316
+ }
317
+
318
+ let screensUseConsistentUnits = unitCache.size <= 1
319
+
320
+ /**
321
+ * @typedef {import('./util/normalizeScreens').Screen} Screen
322
+ */
323
+
324
+ /**
325
+ * @param {'min' | 'max'} type
326
+ * @returns {Record<string, Screen>}
327
+ */
328
+ function buildScreenValues(type) {
329
+ return Object.fromEntries(
330
+ screens
331
+ .filter((screen) => isScreenSortable(screen).result)
332
+ .map((screen) => {
333
+ let { min, max } = screen.values[0]
334
+
335
+ if (type === 'min' && min !== undefined) {
336
+ return screen
337
+ } else if (type === 'min' && max !== undefined) {
338
+ return { ...screen, not: !screen.not }
339
+ } else if (type === 'max' && max !== undefined) {
340
+ return screen
341
+ } else if (type === 'max' && min !== undefined) {
342
+ return { ...screen, not: !screen.not }
343
+ }
344
+ })
345
+ .map((screen) => [screen.name, screen])
346
+ )
347
+ }
348
+
349
+ /**
350
+ * @param {'min' | 'max'} type
351
+ * @returns {(a: { value: string | Screen }, z: { value: string | Screen }) => number}
352
+ */
353
+ function buildSort(type) {
354
+ return (a, z) => compareScreens(type, a.value, z.value)
355
+ }
356
+
357
+ let maxSort = buildSort('max')
358
+ let minSort = buildSort('min')
359
+
360
+ /** @param {'min'|'max'} type */
361
+ function buildScreenVariant(type) {
362
+ return (value) => {
363
+ if (!areSimpleScreens) {
364
+ log.warn('complex-screen-config', [
365
+ 'The `min-*` and `max-*` variants are not supported with a `screens` configuration containing objects.',
366
+ ])
367
+
368
+ return []
369
+ } else if (!screensUseConsistentUnits) {
370
+ log.warn('mixed-screen-units', [
371
+ 'The `min-*` and `max-*` variants are not supported with a `screens` configuration containing mixed units.',
372
+ ])
373
+
374
+ return []
375
+ } else if (typeof value === 'string' && !canUseUnits(value)) {
376
+ log.warn('minmax-have-mixed-units', [
377
+ 'The `min-*` and `max-*` variants are not supported with a `screens` configuration containing mixed units.',
378
+ ])
379
+
380
+ return []
381
+ }
382
+
383
+ return [`@media ${buildMediaQuery(toScreen(value, type))}`]
384
+ }
385
+ }
386
+
387
+ matchVariant('max', buildScreenVariant('max'), {
388
+ sort: maxSort,
389
+ values: areSimpleScreens ? buildScreenValues('max') : {},
390
+ })
203
391
 
204
- addVariant(screen.name, `@media ${query}`)
392
+ // screens and min-* are sorted together when they can be
393
+ let id = 'min-screens'
394
+ for (let screen of screens) {
395
+ addVariant(screen.name, `@media ${buildMediaQuery(screen)}`, {
396
+ id,
397
+ sort: areSimpleScreens && screensUseConsistentUnits ? minSort : undefined,
398
+ value: screen,
399
+ })
205
400
  }
401
+
402
+ matchVariant('min', buildScreenVariant('min'), {
403
+ id,
404
+ sort: minSort,
405
+ })
406
+ },
407
+
408
+ supportsVariants: ({ matchVariant, theme }) => {
409
+ matchVariant(
410
+ 'supports',
411
+ (value = '') => {
412
+ let check = normalize(value)
413
+ let isRaw = /^\w*\s*\(/.test(check)
414
+
415
+ // Chrome has a bug where `(condtion1)or(condition2)` is not valid
416
+ // But `(condition1) or (condition2)` is supported.
417
+ check = isRaw ? check.replace(/\b(and|or|not)\b/g, ' $1 ') : check
418
+
419
+ if (isRaw) {
420
+ return `@supports ${check}`
421
+ }
422
+
423
+ if (!check.includes(':')) {
424
+ check = `${check}: var(--tw)`
425
+ }
426
+
427
+ if (!(check.startsWith('(') && check.endsWith(')'))) {
428
+ check = `(${check})`
429
+ }
430
+
431
+ return `@supports ${check}`
432
+ },
433
+ { values: theme('supports') ?? {} }
434
+ )
435
+ },
436
+
437
+ hasVariants: ({ matchVariant }) => {
438
+ matchVariant('has', (value) => `&:has(${normalize(value)})`, { values: {} })
439
+ matchVariant(
440
+ 'group-has',
441
+ (value, { modifier }) =>
442
+ modifier
443
+ ? `:merge(.group\\/${modifier}):has(${normalize(value)}) &`
444
+ : `:merge(.group):has(${normalize(value)}) &`,
445
+ { values: {} }
446
+ )
447
+ matchVariant(
448
+ 'peer-has',
449
+ (value, { modifier }) =>
450
+ modifier
451
+ ? `:merge(.peer\\/${modifier}):has(${normalize(value)}) ~ &`
452
+ : `:merge(.peer):has(${normalize(value)}) ~ &`,
453
+ { values: {} }
454
+ )
455
+ },
456
+
457
+ ariaVariants: ({ matchVariant, theme }) => {
458
+ matchVariant('aria', (value) => `&[aria-${normalize(value)}]`, { values: theme('aria') ?? {} })
459
+ matchVariant(
460
+ 'group-aria',
461
+ (value, { modifier }) =>
462
+ modifier
463
+ ? `:merge(.group\\/${modifier})[aria-${normalize(value)}] &`
464
+ : `:merge(.group)[aria-${normalize(value)}] &`,
465
+ { values: theme('aria') ?? {} }
466
+ )
467
+ matchVariant(
468
+ 'peer-aria',
469
+ (value, { modifier }) =>
470
+ modifier
471
+ ? `:merge(.peer\\/${modifier})[aria-${normalize(value)}] ~ &`
472
+ : `:merge(.peer)[aria-${normalize(value)}] ~ &`,
473
+ { values: theme('aria') ?? {} }
474
+ )
475
+ },
476
+
477
+ dataVariants: ({ matchVariant, theme }) => {
478
+ matchVariant('data', (value) => `&[data-${normalize(value)}]`, { values: theme('data') ?? {} })
479
+ matchVariant(
480
+ 'group-data',
481
+ (value, { modifier }) =>
482
+ modifier
483
+ ? `:merge(.group\\/${modifier})[data-${normalize(value)}] &`
484
+ : `:merge(.group)[data-${normalize(value)}] &`,
485
+ { values: theme('data') ?? {} }
486
+ )
487
+ matchVariant(
488
+ 'peer-data',
489
+ (value, { modifier }) =>
490
+ modifier
491
+ ? `:merge(.peer\\/${modifier})[data-${normalize(value)}] ~ &`
492
+ : `:merge(.peer)[data-${normalize(value)}] ~ &`,
493
+ { values: theme('data') ?? {} }
494
+ )
206
495
  },
207
496
 
208
497
  orientationVariants: ({ addVariant }) => {
209
498
  addVariant('portrait', '@media (orientation: portrait)')
210
499
  addVariant('landscape', '@media (orientation: landscape)')
211
500
  },
501
+
502
+ prefersContrastVariants: ({ addVariant }) => {
503
+ addVariant('contrast-more', '@media (prefers-contrast: more)')
504
+ addVariant('contrast-less', '@media (prefers-contrast: less)')
505
+ },
506
+
507
+ forcedColorsVariants: ({ addVariant }) => {
508
+ addVariant('forced-colors', '@media (forced-colors: active)')
509
+ },
212
510
  }
213
511
 
214
512
  let cssTransformValue = [
@@ -382,6 +680,7 @@ export let corePlugins = {
382
680
  addUtilities({
383
681
  '.visible': { visibility: 'visible' },
384
682
  '.invisible': { visibility: 'hidden' },
683
+ '.collapse': { visibility: 'collapse' },
385
684
  })
386
685
  },
387
686
 
@@ -398,12 +697,14 @@ export let corePlugins = {
398
697
  inset: createUtilityPlugin(
399
698
  'inset',
400
699
  [
401
- ['inset', ['top', 'right', 'bottom', 'left']],
700
+ ['inset', ['inset']],
402
701
  [
403
702
  ['inset-x', ['left', 'right']],
404
703
  ['inset-y', ['top', 'bottom']],
405
704
  ],
406
705
  [
706
+ ['start', ['inset-inline-start']],
707
+ ['end', ['inset-inline-end']],
407
708
  ['top', ['top']],
408
709
  ['right', ['right']],
409
710
  ['bottom', ['bottom']],
@@ -431,6 +732,8 @@ export let corePlugins = {
431
732
 
432
733
  float: ({ addUtilities }) => {
433
734
  addUtilities({
735
+ '.float-start': { float: 'inline-start' },
736
+ '.float-end': { float: 'inline-end' },
434
737
  '.float-right': { float: 'right' },
435
738
  '.float-left': { float: 'left' },
436
739
  '.float-none': { float: 'none' },
@@ -439,6 +742,8 @@ export let corePlugins = {
439
742
 
440
743
  clear: ({ addUtilities }) => {
441
744
  addUtilities({
745
+ '.clear-start': { clear: 'inline-start' },
746
+ '.clear-end': { clear: 'inline-end' },
442
747
  '.clear-left': { clear: 'left' },
443
748
  '.clear-right': { clear: 'right' },
444
749
  '.clear-both': { clear: 'both' },
@@ -455,6 +760,8 @@ export let corePlugins = {
455
760
  ['my', ['margin-top', 'margin-bottom']],
456
761
  ],
457
762
  [
763
+ ['ms', ['margin-inline-start']],
764
+ ['me', ['margin-inline-end']],
458
765
  ['mt', ['margin-top']],
459
766
  ['mr', ['margin-right']],
460
767
  ['mb', ['margin-bottom']],
@@ -471,6 +778,29 @@ export let corePlugins = {
471
778
  })
472
779
  },
473
780
 
781
+ lineClamp: ({ matchUtilities, addUtilities, theme }) => {
782
+ matchUtilities(
783
+ {
784
+ 'line-clamp': (value) => ({
785
+ overflow: 'hidden',
786
+ display: '-webkit-box',
787
+ '-webkit-box-orient': 'vertical',
788
+ '-webkit-line-clamp': `${value}`,
789
+ }),
790
+ },
791
+ { values: theme('lineClamp') }
792
+ )
793
+
794
+ addUtilities({
795
+ '.line-clamp-none': {
796
+ overflow: 'visible',
797
+ display: 'block',
798
+ '-webkit-box-orient': 'horizontal',
799
+ '-webkit-line-clamp': 'none',
800
+ },
801
+ })
802
+ },
803
+
474
804
  display: ({ addUtilities }) => {
475
805
  addUtilities({
476
806
  '.block': { display: 'block' },
@@ -499,6 +829,8 @@ export let corePlugins = {
499
829
 
500
830
  aspectRatio: createUtilityPlugin('aspectRatio', [['aspect', ['aspect-ratio']]]),
501
831
 
832
+ size: createUtilityPlugin('size', [['size', ['width', 'height']]]),
833
+
502
834
  height: createUtilityPlugin('height', [['h', ['height']]]),
503
835
  maxHeight: createUtilityPlugin('maxHeight', [['max-h', ['maxHeight']]]),
504
836
  minHeight: createUtilityPlugin('minHeight', [['min-h', ['minHeight']]]),
@@ -525,6 +857,13 @@ export let corePlugins = {
525
857
  })
526
858
  },
527
859
 
860
+ captionSide: ({ addUtilities }) => {
861
+ addUtilities({
862
+ '.caption-top': { 'caption-side': 'top' },
863
+ '.caption-bottom': { 'caption-side': 'bottom' },
864
+ })
865
+ },
866
+
528
867
  borderCollapse: ({ addUtilities }) => {
529
868
  addUtilities({
530
869
  '.border-collapse': { 'border-collapse': 'collapse' },
@@ -652,7 +991,7 @@ export let corePlugins = {
652
991
  },
653
992
 
654
993
  animation: ({ matchUtilities, theme, config }) => {
655
- let prefixName = (name) => `${config('prefix')}${escapeClassName(name)}`
994
+ let prefixName = (name) => escapeClassName(config('prefix') + name)
656
995
  let keyframes = Object.fromEntries(
657
996
  Object.entries(theme('keyframes') ?? {}).map(([key, value]) => {
658
997
  return [key, { [`@keyframes ${prefixName(key)}`]: value }]
@@ -803,6 +1142,8 @@ export let corePlugins = {
803
1142
  ['scroll-my', ['scroll-margin-top', 'scroll-margin-bottom']],
804
1143
  ],
805
1144
  [
1145
+ ['scroll-ms', ['scroll-margin-inline-start']],
1146
+ ['scroll-me', ['scroll-margin-inline-end']],
806
1147
  ['scroll-mt', ['scroll-margin-top']],
807
1148
  ['scroll-mr', ['scroll-margin-right']],
808
1149
  ['scroll-mb', ['scroll-margin-bottom']],
@@ -819,6 +1160,8 @@ export let corePlugins = {
819
1160
  ['scroll-py', ['scroll-padding-top', 'scroll-padding-bottom']],
820
1161
  ],
821
1162
  [
1163
+ ['scroll-ps', ['scroll-padding-inline-start']],
1164
+ ['scroll-pe', ['scroll-padding-inline-end']],
822
1165
  ['scroll-pt', ['scroll-padding-top']],
823
1166
  ['scroll-pr', ['scroll-padding-right']],
824
1167
  ['scroll-pb', ['scroll-padding-bottom']],
@@ -832,12 +1175,13 @@ export let corePlugins = {
832
1175
  '.list-outside': { 'list-style-position': 'outside' },
833
1176
  })
834
1177
  },
835
-
836
1178
  listStyleType: createUtilityPlugin('listStyleType', [['list', ['listStyleType']]]),
1179
+ listStyleImage: createUtilityPlugin('listStyleImage', [['list-image', ['listStyleImage']]]),
837
1180
 
838
1181
  appearance: ({ addUtilities }) => {
839
1182
  addUtilities({
840
1183
  '.appearance-none': { appearance: 'none' },
1184
+ '.appearance-auto': { appearance: 'auto' },
841
1185
  })
842
1186
  },
843
1187
 
@@ -884,6 +1228,7 @@ export let corePlugins = {
884
1228
  addUtilities({
885
1229
  '.grid-flow-row': { gridAutoFlow: 'row' },
886
1230
  '.grid-flow-col': { gridAutoFlow: 'column' },
1231
+ '.grid-flow-dense': { gridAutoFlow: 'dense' },
887
1232
  '.grid-flow-row-dense': { gridAutoFlow: 'row dense' },
888
1233
  '.grid-flow-col-dense': { gridAutoFlow: 'column dense' },
889
1234
  })
@@ -920,6 +1265,7 @@ export let corePlugins = {
920
1265
  '.place-content-between': { 'place-content': 'space-between' },
921
1266
  '.place-content-around': { 'place-content': 'space-around' },
922
1267
  '.place-content-evenly': { 'place-content': 'space-evenly' },
1268
+ '.place-content-baseline': { 'place-content': 'baseline' },
923
1269
  '.place-content-stretch': { 'place-content': 'stretch' },
924
1270
  })
925
1271
  },
@@ -929,18 +1275,22 @@ export let corePlugins = {
929
1275
  '.place-items-start': { 'place-items': 'start' },
930
1276
  '.place-items-end': { 'place-items': 'end' },
931
1277
  '.place-items-center': { 'place-items': 'center' },
1278
+ '.place-items-baseline': { 'place-items': 'baseline' },
932
1279
  '.place-items-stretch': { 'place-items': 'stretch' },
933
1280
  })
934
1281
  },
935
1282
 
936
1283
  alignContent: ({ addUtilities }) => {
937
1284
  addUtilities({
1285
+ '.content-normal': { 'align-content': 'normal' },
938
1286
  '.content-center': { 'align-content': 'center' },
939
1287
  '.content-start': { 'align-content': 'flex-start' },
940
1288
  '.content-end': { 'align-content': 'flex-end' },
941
1289
  '.content-between': { 'align-content': 'space-between' },
942
1290
  '.content-around': { 'align-content': 'space-around' },
943
1291
  '.content-evenly': { 'align-content': 'space-evenly' },
1292
+ '.content-baseline': { 'align-content': 'baseline' },
1293
+ '.content-stretch': { 'align-content': 'stretch' },
944
1294
  })
945
1295
  },
946
1296
 
@@ -956,12 +1306,14 @@ export let corePlugins = {
956
1306
 
957
1307
  justifyContent: ({ addUtilities }) => {
958
1308
  addUtilities({
1309
+ '.justify-normal': { 'justify-content': 'normal' },
959
1310
  '.justify-start': { 'justify-content': 'flex-start' },
960
1311
  '.justify-end': { 'justify-content': 'flex-end' },
961
1312
  '.justify-center': { 'justify-content': 'center' },
962
1313
  '.justify-between': { 'justify-content': 'space-between' },
963
1314
  '.justify-around': { 'justify-content': 'space-around' },
964
1315
  '.justify-evenly': { 'justify-content': 'space-evenly' },
1316
+ '.justify-stretch': { 'justify-content': 'stretch' },
965
1317
  })
966
1318
  },
967
1319
 
@@ -1045,7 +1397,7 @@ export let corePlugins = {
1045
1397
  }
1046
1398
  },
1047
1399
  },
1048
- { values: theme('divideWidth'), type: ['line-width', 'length'] }
1400
+ { values: theme('divideWidth'), type: ['line-width', 'length', 'any'] }
1049
1401
  )
1050
1402
 
1051
1403
  addUtilities({
@@ -1093,7 +1445,7 @@ export let corePlugins = {
1093
1445
  },
1094
1446
  {
1095
1447
  values: (({ DEFAULT: _, ...colors }) => colors)(flattenColorPalette(theme('divideColor'))),
1096
- type: 'color',
1448
+ type: ['color', 'any'],
1097
1449
  }
1098
1450
  )
1099
1451
  },
@@ -1190,6 +1542,14 @@ export let corePlugins = {
1190
1542
  })
1191
1543
  },
1192
1544
 
1545
+ hyphens: ({ addUtilities }) => {
1546
+ addUtilities({
1547
+ '.hyphens-none': { hyphens: 'none' },
1548
+ '.hyphens-manual': { hyphens: 'manual' },
1549
+ '.hyphens-auto': { hyphens: 'auto' },
1550
+ })
1551
+ },
1552
+
1193
1553
  whitespace: ({ addUtilities }) => {
1194
1554
  addUtilities({
1195
1555
  '.whitespace-normal': { 'white-space': 'normal' },
@@ -1197,6 +1557,16 @@ export let corePlugins = {
1197
1557
  '.whitespace-pre': { 'white-space': 'pre' },
1198
1558
  '.whitespace-pre-line': { 'white-space': 'pre-line' },
1199
1559
  '.whitespace-pre-wrap': { 'white-space': 'pre-wrap' },
1560
+ '.whitespace-break-spaces': { 'white-space': 'break-spaces' },
1561
+ })
1562
+ },
1563
+
1564
+ textWrap: ({ addUtilities }) => {
1565
+ addUtilities({
1566
+ '.text-wrap': { 'text-wrap': 'wrap' },
1567
+ '.text-nowrap': { 'text-wrap': 'nowrap' },
1568
+ '.text-balance': { 'text-wrap': 'balance' },
1569
+ '.text-pretty': { 'text-wrap': 'pretty' },
1200
1570
  })
1201
1571
  },
1202
1572
 
@@ -1205,18 +1575,25 @@ export let corePlugins = {
1205
1575
  '.break-normal': { 'overflow-wrap': 'normal', 'word-break': 'normal' },
1206
1576
  '.break-words': { 'overflow-wrap': 'break-word' },
1207
1577
  '.break-all': { 'word-break': 'break-all' },
1578
+ '.break-keep': { 'word-break': 'keep-all' },
1208
1579
  })
1209
1580
  },
1210
1581
 
1211
1582
  borderRadius: createUtilityPlugin('borderRadius', [
1212
1583
  ['rounded', ['border-radius']],
1213
1584
  [
1585
+ ['rounded-s', ['border-start-start-radius', 'border-end-start-radius']],
1586
+ ['rounded-e', ['border-start-end-radius', 'border-end-end-radius']],
1214
1587
  ['rounded-t', ['border-top-left-radius', 'border-top-right-radius']],
1215
1588
  ['rounded-r', ['border-top-right-radius', 'border-bottom-right-radius']],
1216
1589
  ['rounded-b', ['border-bottom-right-radius', 'border-bottom-left-radius']],
1217
1590
  ['rounded-l', ['border-top-left-radius', 'border-bottom-left-radius']],
1218
1591
  ],
1219
1592
  [
1593
+ ['rounded-ss', ['border-start-start-radius']],
1594
+ ['rounded-se', ['border-start-end-radius']],
1595
+ ['rounded-ee', ['border-end-end-radius']],
1596
+ ['rounded-es', ['border-end-start-radius']],
1220
1597
  ['rounded-tl', ['border-top-left-radius']],
1221
1598
  ['rounded-tr', ['border-top-right-radius']],
1222
1599
  ['rounded-br', ['border-bottom-right-radius']],
@@ -1233,6 +1610,8 @@ export let corePlugins = {
1233
1610
  ['border-y', [['@defaults border-width', {}], 'border-top-width', 'border-bottom-width']],
1234
1611
  ],
1235
1612
  [
1613
+ ['border-s', [['@defaults border-width', {}], 'border-inline-start-width']],
1614
+ ['border-e', [['@defaults border-width', {}], 'border-inline-end-width']],
1236
1615
  ['border-t', [['@defaults border-width', {}], 'border-top-width']],
1237
1616
  ['border-r', [['@defaults border-width', {}], 'border-right-width']],
1238
1617
  ['border-b', [['@defaults border-width', {}], 'border-bottom-width']],
@@ -1272,7 +1651,7 @@ export let corePlugins = {
1272
1651
  },
1273
1652
  {
1274
1653
  values: (({ DEFAULT: _, ...colors }) => colors)(flattenColorPalette(theme('borderColor'))),
1275
- type: ['color'],
1654
+ type: ['color', 'any'],
1276
1655
  }
1277
1656
  )
1278
1657
 
@@ -1309,12 +1688,38 @@ export let corePlugins = {
1309
1688
  },
1310
1689
  {
1311
1690
  values: (({ DEFAULT: _, ...colors }) => colors)(flattenColorPalette(theme('borderColor'))),
1312
- type: 'color',
1691
+ type: ['color', 'any'],
1313
1692
  }
1314
1693
  )
1315
1694
 
1316
1695
  matchUtilities(
1317
1696
  {
1697
+ 'border-s': (value) => {
1698
+ if (!corePlugins('borderOpacity')) {
1699
+ return {
1700
+ 'border-inline-start-color': toColorValue(value),
1701
+ }
1702
+ }
1703
+
1704
+ return withAlphaVariable({
1705
+ color: value,
1706
+ property: 'border-inline-start-color',
1707
+ variable: '--tw-border-opacity',
1708
+ })
1709
+ },
1710
+ 'border-e': (value) => {
1711
+ if (!corePlugins('borderOpacity')) {
1712
+ return {
1713
+ 'border-inline-end-color': toColorValue(value),
1714
+ }
1715
+ }
1716
+
1717
+ return withAlphaVariable({
1718
+ color: value,
1719
+ property: 'border-inline-end-color',
1720
+ variable: '--tw-border-opacity',
1721
+ })
1722
+ },
1318
1723
  'border-t': (value) => {
1319
1724
  if (!corePlugins('borderOpacity')) {
1320
1725
  return {
@@ -1370,7 +1775,7 @@ export let corePlugins = {
1370
1775
  },
1371
1776
  {
1372
1777
  values: (({ DEFAULT: _, ...colors }) => colors)(flattenColorPalette(theme('borderColor'))),
1373
- type: 'color',
1778
+ type: ['color', 'any'],
1374
1779
  }
1375
1780
  )
1376
1781
  },
@@ -1396,7 +1801,7 @@ export let corePlugins = {
1396
1801
  })
1397
1802
  },
1398
1803
  },
1399
- { values: flattenColorPalette(theme('backgroundColor')), type: 'color' }
1804
+ { values: flattenColorPalette(theme('backgroundColor')), type: ['color', 'any'] }
1400
1805
  )
1401
1806
  },
1402
1807
 
@@ -1411,44 +1816,98 @@ export let corePlugins = {
1411
1816
  return withAlphaValue(value, 0, 'rgb(255 255 255 / 0)')
1412
1817
  }
1413
1818
 
1414
- return function ({ matchUtilities, theme }) {
1819
+ return function ({ matchUtilities, theme, addDefaults }) {
1820
+ addDefaults('gradient-color-stops', {
1821
+ '--tw-gradient-from-position': ' ',
1822
+ '--tw-gradient-via-position': ' ',
1823
+ '--tw-gradient-to-position': ' ',
1824
+ })
1825
+
1415
1826
  let options = {
1416
1827
  values: flattenColorPalette(theme('gradientColorStops')),
1417
1828
  type: ['color', 'any'],
1418
1829
  }
1419
1830
 
1831
+ let positionOptions = {
1832
+ values: theme('gradientColorStopPositions'),
1833
+ type: ['length', 'percentage'],
1834
+ }
1835
+
1420
1836
  matchUtilities(
1421
1837
  {
1422
1838
  from: (value) => {
1423
1839
  let transparentToValue = transparentTo(value)
1424
1840
 
1425
1841
  return {
1426
- '--tw-gradient-from': toColorValue(value, 'from'),
1427
- '--tw-gradient-stops': `var(--tw-gradient-from), var(--tw-gradient-to, ${transparentToValue})`,
1842
+ '@defaults gradient-color-stops': {},
1843
+ '--tw-gradient-from': `${toColorValue(value)} var(--tw-gradient-from-position)`,
1844
+ '--tw-gradient-to': `${transparentToValue} var(--tw-gradient-to-position)`,
1845
+ '--tw-gradient-stops': `var(--tw-gradient-from), var(--tw-gradient-to)`,
1428
1846
  }
1429
1847
  },
1430
1848
  },
1431
1849
  options
1432
1850
  )
1851
+
1852
+ matchUtilities(
1853
+ {
1854
+ from: (value) => {
1855
+ return {
1856
+ '--tw-gradient-from-position': value,
1857
+ }
1858
+ },
1859
+ },
1860
+ positionOptions
1861
+ )
1862
+
1433
1863
  matchUtilities(
1434
1864
  {
1435
1865
  via: (value) => {
1436
1866
  let transparentToValue = transparentTo(value)
1437
1867
 
1438
1868
  return {
1869
+ '@defaults gradient-color-stops': {},
1870
+ '--tw-gradient-to': `${transparentToValue} var(--tw-gradient-to-position)`,
1439
1871
  '--tw-gradient-stops': `var(--tw-gradient-from), ${toColorValue(
1440
- value,
1441
- 'via'
1442
- )}, var(--tw-gradient-to, ${transparentToValue})`,
1872
+ value
1873
+ )} var(--tw-gradient-via-position), var(--tw-gradient-to)`,
1443
1874
  }
1444
1875
  },
1445
1876
  },
1446
1877
  options
1447
1878
  )
1879
+
1880
+ matchUtilities(
1881
+ {
1882
+ via: (value) => {
1883
+ return {
1884
+ '--tw-gradient-via-position': value,
1885
+ }
1886
+ },
1887
+ },
1888
+ positionOptions
1889
+ )
1890
+
1448
1891
  matchUtilities(
1449
- { to: (value) => ({ '--tw-gradient-to': toColorValue(value, 'to') }) },
1892
+ {
1893
+ to: (value) => ({
1894
+ '@defaults gradient-color-stops': {},
1895
+ '--tw-gradient-to': `${toColorValue(value)} var(--tw-gradient-to-position)`,
1896
+ }),
1897
+ },
1450
1898
  options
1451
1899
  )
1900
+
1901
+ matchUtilities(
1902
+ {
1903
+ to: (value) => {
1904
+ return {
1905
+ '--tw-gradient-to-position': value,
1906
+ }
1907
+ },
1908
+ },
1909
+ positionOptions
1910
+ )
1452
1911
  }
1453
1912
  })(),
1454
1913
 
@@ -1462,7 +1921,7 @@ export let corePlugins = {
1462
1921
  },
1463
1922
 
1464
1923
  backgroundSize: createUtilityPlugin('backgroundSize', [['bg', ['background-size']]], {
1465
- type: ['lookup', 'length', 'percentage'],
1924
+ type: ['lookup', 'length', 'percentage', 'size'],
1466
1925
  }),
1467
1926
 
1468
1927
  backgroundAttachment: ({ addUtilities }) => {
@@ -1483,7 +1942,7 @@ export let corePlugins = {
1483
1942
  },
1484
1943
 
1485
1944
  backgroundPosition: createUtilityPlugin('backgroundPosition', [['bg', ['background-position']]], {
1486
- type: ['lookup', 'position'],
1945
+ type: ['lookup', ['position', { preferOnConflict: true }]],
1487
1946
  }),
1488
1947
 
1489
1948
  backgroundRepeat: ({ addUtilities }) => {
@@ -1523,7 +1982,7 @@ export let corePlugins = {
1523
1982
  return { stroke: toColorValue(value) }
1524
1983
  },
1525
1984
  },
1526
- { values: flattenColorPalette(theme('stroke')), type: ['color', 'url'] }
1985
+ { values: flattenColorPalette(theme('stroke')), type: ['color', 'url', 'any'] }
1527
1986
  )
1528
1987
  },
1529
1988
 
@@ -1549,6 +2008,8 @@ export let corePlugins = {
1549
2008
  ['py', ['padding-top', 'padding-bottom']],
1550
2009
  ],
1551
2010
  [
2011
+ ['ps', ['padding-inline-start']],
2012
+ ['pe', ['padding-inline-end']],
1552
2013
  ['pt', ['padding-top']],
1553
2014
  ['pr', ['padding-right']],
1554
2015
  ['pb', ['padding-bottom']],
@@ -1586,16 +2047,46 @@ export let corePlugins = {
1586
2047
  matchUtilities({ align: (value) => ({ 'vertical-align': value }) })
1587
2048
  },
1588
2049
 
1589
- fontFamily: createUtilityPlugin('fontFamily', [['font', ['fontFamily']]], {
1590
- type: ['lookup', 'generic-name', 'family-name'],
1591
- }),
2050
+ fontFamily: ({ matchUtilities, theme }) => {
2051
+ matchUtilities(
2052
+ {
2053
+ font: (value) => {
2054
+ let [families, options = {}] =
2055
+ Array.isArray(value) && isPlainObject(value[1]) ? value : [value]
2056
+ let { fontFeatureSettings, fontVariationSettings } = options
2057
+
2058
+ return {
2059
+ 'font-family': Array.isArray(families) ? families.join(', ') : families,
2060
+ ...(fontFeatureSettings === undefined
2061
+ ? {}
2062
+ : { 'font-feature-settings': fontFeatureSettings }),
2063
+ ...(fontVariationSettings === undefined
2064
+ ? {}
2065
+ : { 'font-variation-settings': fontVariationSettings }),
2066
+ }
2067
+ },
2068
+ },
2069
+ {
2070
+ values: theme('fontFamily'),
2071
+ type: ['lookup', 'generic-name', 'family-name'],
2072
+ }
2073
+ )
2074
+ },
1592
2075
 
1593
2076
  fontSize: ({ matchUtilities, theme }) => {
1594
2077
  matchUtilities(
1595
2078
  {
1596
- text: (value) => {
2079
+ text: (value, { modifier }) => {
1597
2080
  let [fontSize, options] = Array.isArray(value) ? value : [value]
1598
- let { lineHeight, letterSpacing } = isPlainObject(options)
2081
+
2082
+ if (modifier) {
2083
+ return {
2084
+ 'font-size': fontSize,
2085
+ 'line-height': modifier,
2086
+ }
2087
+ }
2088
+
2089
+ let { lineHeight, letterSpacing, fontWeight } = isPlainObject(options)
1599
2090
  ? options
1600
2091
  : { lineHeight: options }
1601
2092
 
@@ -1603,18 +2094,20 @@ export let corePlugins = {
1603
2094
  'font-size': fontSize,
1604
2095
  ...(lineHeight === undefined ? {} : { 'line-height': lineHeight }),
1605
2096
  ...(letterSpacing === undefined ? {} : { 'letter-spacing': letterSpacing }),
2097
+ ...(fontWeight === undefined ? {} : { 'font-weight': fontWeight }),
1606
2098
  }
1607
2099
  },
1608
2100
  },
1609
2101
  {
1610
2102
  values: theme('fontSize'),
2103
+ modifiers: theme('lineHeight'),
1611
2104
  type: ['absolute-size', 'relative-size', 'length', 'percentage'],
1612
2105
  }
1613
2106
  )
1614
2107
  },
1615
2108
 
1616
2109
  fontWeight: createUtilityPlugin('fontWeight', [['font', ['fontWeight']]], {
1617
- type: ['lookup', 'number'],
2110
+ type: ['lookup', 'number', 'any'],
1618
2111
  }),
1619
2112
 
1620
2113
  textTransform: ({ addUtilities }) => {
@@ -1710,7 +2203,7 @@ export let corePlugins = {
1710
2203
  })
1711
2204
  },
1712
2205
  },
1713
- { values: flattenColorPalette(theme('textColor')), type: 'color' }
2206
+ { values: flattenColorPalette(theme('textColor')), type: ['color', 'any'] }
1714
2207
  )
1715
2208
  },
1716
2209
 
@@ -1732,7 +2225,7 @@ export let corePlugins = {
1732
2225
  return { 'text-decoration-color': toColorValue(value) }
1733
2226
  },
1734
2227
  },
1735
- { values: flattenColorPalette(theme('textDecorationColor')), type: ['color'] }
2228
+ { values: flattenColorPalette(theme('textDecorationColor')), type: ['color', 'any'] }
1736
2229
  )
1737
2230
  },
1738
2231
 
@@ -1755,7 +2248,7 @@ export let corePlugins = {
1755
2248
  textUnderlineOffset: createUtilityPlugin(
1756
2249
  'textUnderlineOffset',
1757
2250
  [['underline-offset', ['text-underline-offset']]],
1758
- { type: ['length', 'percentage'] }
2251
+ { type: ['length', 'percentage', 'any'] }
1759
2252
  ),
1760
2253
 
1761
2254
  fontSmoothing: ({ addUtilities }) => {
@@ -1870,6 +2363,8 @@ export let corePlugins = {
1870
2363
  '.mix-blend-saturation': { 'mix-blend-mode': 'saturation' },
1871
2364
  '.mix-blend-color': { 'mix-blend-mode': 'color' },
1872
2365
  '.mix-blend-luminosity': { 'mix-blend-mode': 'luminosity' },
2366
+ '.mix-blend-plus-darker': { 'mix-blend-mode': 'plus-darker' },
2367
+ '.mix-blend-plus-lighter': { 'mix-blend-mode': 'plus-lighter' },
1873
2368
  })
1874
2369
  },
1875
2370
 
@@ -1927,7 +2422,7 @@ export let corePlugins = {
1927
2422
  }
1928
2423
  },
1929
2424
  },
1930
- { values: flattenColorPalette(theme('boxShadowColor')), type: ['color'] }
2425
+ { values: flattenColorPalette(theme('boxShadowColor')), type: ['color', 'any'] }
1931
2426
  )
1932
2427
  },
1933
2428
 
@@ -1941,7 +2436,6 @@ export let corePlugins = {
1941
2436
  '.outline-dashed': { 'outline-style': 'dashed' },
1942
2437
  '.outline-dotted': { 'outline-style': 'dotted' },
1943
2438
  '.outline-double': { 'outline-style': 'double' },
1944
- '.outline-hidden': { 'outline-style': 'hidden' },
1945
2439
  })
1946
2440
  },
1947
2441
 
@@ -1950,7 +2444,8 @@ export let corePlugins = {
1950
2444
  }),
1951
2445
 
1952
2446
  outlineOffset: createUtilityPlugin('outlineOffset', [['outline-offset', ['outline-offset']]], {
1953
- type: ['length', 'number', 'percentage'],
2447
+ type: ['length', 'number', 'percentage', 'any'],
2448
+ supportsNegativeValues: true,
1954
2449
  }),
1955
2450
 
1956
2451
  outlineColor: ({ matchUtilities, theme }) => {
@@ -1960,17 +2455,28 @@ export let corePlugins = {
1960
2455
  return { 'outline-color': toColorValue(value) }
1961
2456
  },
1962
2457
  },
1963
- { values: flattenColorPalette(theme('outlineColor')), type: ['color'] }
2458
+ { values: flattenColorPalette(theme('outlineColor')), type: ['color', 'any'] }
1964
2459
  )
1965
2460
  },
1966
2461
 
1967
- ringWidth: ({ matchUtilities, addDefaults, addUtilities, theme }) => {
1968
- let ringOpacityDefault = theme('ringOpacity.DEFAULT', '0.5')
1969
- let ringColorDefault = withAlphaValue(
1970
- theme('ringColor')?.DEFAULT,
1971
- ringOpacityDefault,
1972
- `rgb(147 197 253 / ${ringOpacityDefault})`
1973
- )
2462
+ ringWidth: ({ matchUtilities, addDefaults, addUtilities, theme, config }) => {
2463
+ let ringColorDefault = (() => {
2464
+ if (flagEnabled(config(), 'respectDefaultRingColorOpacity')) {
2465
+ return theme('ringColor.DEFAULT')
2466
+ }
2467
+
2468
+ let ringOpacityDefault = theme('ringOpacity.DEFAULT', '0.5')
2469
+
2470
+ if (!theme('ringColor')?.DEFAULT) {
2471
+ return `rgb(147 197 253 / ${ringOpacityDefault})`
2472
+ }
2473
+
2474
+ return withAlphaValue(
2475
+ theme('ringColor')?.DEFAULT,
2476
+ ringOpacityDefault,
2477
+ `rgb(147 197 253 / ${ringOpacityDefault})`
2478
+ )
2479
+ })()
1974
2480
 
1975
2481
  addDefaults('ring-width', {
1976
2482
  '--tw-ring-inset': ' ',
@@ -2029,14 +2535,18 @@ export let corePlugins = {
2029
2535
  ([modifier]) => modifier !== 'DEFAULT'
2030
2536
  )
2031
2537
  ),
2032
- type: 'color',
2538
+ type: ['color', 'any'],
2033
2539
  }
2034
2540
  )
2035
2541
  },
2036
2542
 
2037
- ringOpacity: createUtilityPlugin('ringOpacity', [['ring-opacity', ['--tw-ring-opacity']]], {
2038
- filterDefault: true,
2039
- }),
2543
+ ringOpacity: (helpers) => {
2544
+ let { config } = helpers
2545
+
2546
+ return createUtilityPlugin('ringOpacity', [['ring-opacity', ['--tw-ring-opacity']]], {
2547
+ filterDefault: !flagEnabled(config(), 'respectDefaultRingColorOpacity'),
2548
+ })(helpers)
2549
+ },
2040
2550
  ringOffsetWidth: createUtilityPlugin(
2041
2551
  'ringOffsetWidth',
2042
2552
  [['ring-offset', ['--tw-ring-offset-width']]],
@@ -2052,7 +2562,7 @@ export let corePlugins = {
2052
2562
  }
2053
2563
  },
2054
2564
  },
2055
- { values: flattenColorPalette(theme('ringOffsetColor')), type: 'color' }
2565
+ { values: flattenColorPalette(theme('ringOffsetColor')), type: ['color', 'any'] }
2056
2566
  )
2057
2567
  },
2058
2568
 
@@ -2401,7 +2911,55 @@ export let corePlugins = {
2401
2911
  { filterDefault: true }
2402
2912
  ),
2403
2913
  willChange: createUtilityPlugin('willChange', [['will-change', ['will-change']]]),
2914
+ contain: ({ addDefaults, addUtilities }) => {
2915
+ let cssContainValue =
2916
+ 'var(--tw-contain-size) var(--tw-contain-layout) var(--tw-contain-paint) var(--tw-contain-style)'
2917
+
2918
+ addDefaults('contain', {
2919
+ '--tw-contain-size': ' ',
2920
+ '--tw-contain-layout': ' ',
2921
+ '--tw-contain-paint': ' ',
2922
+ '--tw-contain-style': ' ',
2923
+ })
2924
+
2925
+ addUtilities({
2926
+ '.contain-none': { contain: 'none' },
2927
+ '.contain-content': { contain: 'content' },
2928
+ '.contain-strict': { contain: 'strict' },
2929
+ '.contain-size': {
2930
+ '@defaults contain': {},
2931
+ '--tw-contain-size': 'size',
2932
+ contain: cssContainValue,
2933
+ },
2934
+ '.contain-inline-size': {
2935
+ '@defaults contain': {},
2936
+ '--tw-contain-size': 'inline-size',
2937
+ contain: cssContainValue,
2938
+ },
2939
+ '.contain-layout': {
2940
+ '@defaults contain': {},
2941
+ '--tw-contain-layout': 'layout',
2942
+ contain: cssContainValue,
2943
+ },
2944
+ '.contain-paint': {
2945
+ '@defaults contain': {},
2946
+ '--tw-contain-paint': 'paint',
2947
+ contain: cssContainValue,
2948
+ },
2949
+ '.contain-style': {
2950
+ '@defaults contain': {},
2951
+ '--tw-contain-style': 'style',
2952
+ contain: cssContainValue,
2953
+ },
2954
+ })
2955
+ },
2404
2956
  content: createUtilityPlugin('content', [
2405
2957
  ['content', ['--tw-content', ['content', 'var(--tw-content)']]],
2406
2958
  ]),
2959
+ forcedColorAdjust: ({ addUtilities }) => {
2960
+ addUtilities({
2961
+ '.forced-color-adjust-auto': { 'forced-color-adjust': 'auto' },
2962
+ '.forced-color-adjust-none': { 'forced-color-adjust': 'none' },
2963
+ })
2964
+ },
2407
2965
  }