tailwindcss 0.0.0-insiders.93e0fdf → 0.0.0-insiders.941ef21

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 (170) hide show
  1. package/CHANGELOG.md +293 -5
  2. package/README.md +13 -9
  3. package/colors.d.ts +3 -0
  4. package/defaultConfig.d.ts +3 -0
  5. package/defaultTheme.d.ts +4 -0
  6. package/lib/cli/build/deps.js +54 -0
  7. package/lib/cli/build/index.js +48 -0
  8. package/lib/cli/build/plugin.js +362 -0
  9. package/lib/cli/build/utils.js +78 -0
  10. package/lib/cli/build/watching.js +178 -0
  11. package/lib/cli/help/index.js +71 -0
  12. package/lib/cli/index.js +18 -0
  13. package/lib/cli/init/index.js +46 -0
  14. package/lib/cli/shared.js +12 -0
  15. package/lib/cli-peer-dependencies.js +20 -7
  16. package/lib/cli.js +109 -611
  17. package/lib/constants.js +27 -20
  18. package/lib/corePluginList.js +6 -3
  19. package/lib/corePlugins.js +2005 -1686
  20. package/lib/css/preflight.css +4 -4
  21. package/lib/featureFlags.js +36 -24
  22. package/lib/index.js +28 -10
  23. package/lib/lib/cacheInvalidation.js +90 -0
  24. package/lib/lib/collapseAdjacentRules.js +28 -10
  25. package/lib/lib/collapseDuplicateDeclarations.js +14 -11
  26. package/lib/lib/content.js +177 -0
  27. package/lib/lib/defaultExtractor.js +225 -33
  28. package/lib/lib/detectNesting.js +13 -10
  29. package/lib/lib/evaluateTailwindFunctions.js +118 -55
  30. package/lib/lib/expandApplyAtRules.js +439 -193
  31. package/lib/lib/expandTailwindAtRules.js +104 -109
  32. package/lib/lib/findAtConfigPath.js +44 -0
  33. package/lib/lib/generateRules.js +405 -197
  34. package/lib/lib/getModuleDependencies.js +11 -8
  35. package/lib/lib/normalizeTailwindDirectives.js +35 -32
  36. package/lib/lib/offsets.js +285 -0
  37. package/lib/lib/partitionApplyAtRules.js +11 -8
  38. package/lib/lib/regex.js +60 -0
  39. package/lib/lib/remap-bitfield.js +87 -0
  40. package/lib/lib/resolveDefaultsAtRules.js +89 -67
  41. package/lib/lib/setupContextUtils.js +617 -309
  42. package/lib/lib/setupTrackingContext.js +38 -67
  43. package/lib/lib/sharedState.js +25 -15
  44. package/lib/lib/substituteScreenAtRules.js +11 -9
  45. package/lib/postcss-plugins/nesting/README.md +2 -2
  46. package/lib/postcss-plugins/nesting/index.js +8 -6
  47. package/lib/postcss-plugins/nesting/plugin.js +48 -14
  48. package/lib/processTailwindFeatures.js +31 -28
  49. package/lib/public/colors.js +247 -245
  50. package/lib/public/create-plugin.js +6 -4
  51. package/lib/public/default-config.js +7 -5
  52. package/lib/public/default-theme.js +7 -5
  53. package/lib/public/resolve-config.js +8 -5
  54. package/lib/util/bigSign.js +4 -1
  55. package/lib/util/buildMediaQuery.js +11 -6
  56. package/lib/util/cloneDeep.js +7 -6
  57. package/lib/util/cloneNodes.js +21 -3
  58. package/lib/util/color.js +53 -54
  59. package/lib/util/configurePlugins.js +5 -2
  60. package/lib/util/createPlugin.js +6 -5
  61. package/lib/util/createUtilityPlugin.js +10 -8
  62. package/lib/util/dataTypes.js +143 -110
  63. package/lib/util/defaults.js +8 -5
  64. package/lib/util/escapeClassName.js +9 -6
  65. package/lib/util/escapeCommas.js +5 -2
  66. package/lib/util/flattenColorPalette.js +9 -10
  67. package/lib/util/formatVariantSelector.js +193 -86
  68. package/lib/util/getAllConfigs.js +29 -10
  69. package/lib/util/hashConfig.js +6 -3
  70. package/lib/util/isKeyframeRule.js +5 -2
  71. package/lib/util/isPlainObject.js +5 -2
  72. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +23 -15
  73. package/lib/util/log.js +20 -14
  74. package/lib/util/nameClass.js +20 -9
  75. package/lib/util/negateValue.js +22 -7
  76. package/lib/util/normalizeConfig.js +124 -83
  77. package/lib/util/normalizeScreens.js +119 -8
  78. package/lib/util/parseAnimationValue.js +42 -40
  79. package/lib/util/parseBoxShadowValue.js +29 -22
  80. package/lib/util/parseDependency.js +38 -56
  81. package/lib/util/parseGlob.js +34 -0
  82. package/lib/util/parseObjectStyles.js +11 -8
  83. package/lib/util/pluginUtils.js +155 -51
  84. package/lib/util/prefixSelector.js +7 -4
  85. package/lib/util/removeAlphaVariables.js +29 -0
  86. package/lib/util/resolveConfig.js +93 -72
  87. package/lib/util/resolveConfigPath.js +10 -7
  88. package/lib/util/responsive.js +8 -5
  89. package/lib/util/splitAtTopLevelOnly.js +43 -0
  90. package/lib/util/tap.js +4 -1
  91. package/lib/util/toColorValue.js +5 -2
  92. package/lib/util/toPath.js +20 -4
  93. package/lib/util/transformThemeValue.js +37 -25
  94. package/lib/util/validateConfig.js +24 -0
  95. package/lib/util/validateFormalSyntax.js +24 -0
  96. package/lib/util/withAlphaVariable.js +23 -15
  97. package/package.json +44 -37
  98. package/peers/index.js +11099 -7475
  99. package/plugin.d.ts +11 -0
  100. package/resolveConfig.d.ts +12 -0
  101. package/scripts/generate-types.js +105 -0
  102. package/scripts/release-channel.js +18 -0
  103. package/scripts/release-notes.js +21 -0
  104. package/scripts/type-utils.js +27 -0
  105. package/src/cli/build/deps.js +56 -0
  106. package/src/cli/build/index.js +49 -0
  107. package/src/cli/build/plugin.js +434 -0
  108. package/src/cli/build/utils.js +76 -0
  109. package/src/cli/build/watching.js +227 -0
  110. package/src/cli/help/index.js +70 -0
  111. package/src/cli/index.js +3 -0
  112. package/src/cli/init/index.js +50 -0
  113. package/src/cli/shared.js +5 -0
  114. package/src/cli-peer-dependencies.js +7 -1
  115. package/src/cli.js +50 -631
  116. package/src/corePluginList.js +1 -1
  117. package/src/corePlugins.js +399 -84
  118. package/src/css/preflight.css +4 -4
  119. package/src/featureFlags.js +14 -4
  120. package/src/index.js +20 -1
  121. package/src/lib/cacheInvalidation.js +52 -0
  122. package/src/lib/collapseAdjacentRules.js +21 -2
  123. package/src/lib/content.js +213 -0
  124. package/src/lib/defaultExtractor.js +196 -35
  125. package/src/lib/evaluateTailwindFunctions.js +78 -7
  126. package/src/lib/expandApplyAtRules.js +482 -183
  127. package/src/lib/expandTailwindAtRules.js +37 -55
  128. package/src/lib/findAtConfigPath.js +48 -0
  129. package/src/lib/generateRules.js +359 -112
  130. package/src/lib/offsets.js +351 -0
  131. package/src/lib/regex.js +74 -0
  132. package/src/lib/remap-bitfield.js +82 -0
  133. package/src/lib/resolveDefaultsAtRules.js +53 -32
  134. package/src/lib/setupContextUtils.js +517 -146
  135. package/src/lib/setupTrackingContext.js +11 -48
  136. package/src/lib/sharedState.js +3 -0
  137. package/src/postcss-plugins/nesting/README.md +2 -2
  138. package/src/postcss-plugins/nesting/plugin.js +36 -0
  139. package/src/util/buildMediaQuery.js +5 -3
  140. package/src/util/cloneNodes.js +19 -2
  141. package/src/util/color.js +25 -21
  142. package/src/util/dataTypes.js +54 -21
  143. package/src/util/formatVariantSelector.js +196 -62
  144. package/src/util/getAllConfigs.js +19 -0
  145. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  146. package/src/util/log.js +8 -8
  147. package/src/util/nameClass.js +4 -0
  148. package/src/util/negateValue.js +10 -2
  149. package/src/util/normalizeConfig.js +40 -10
  150. package/src/util/normalizeScreens.js +99 -4
  151. package/src/util/parseBoxShadowValue.js +3 -2
  152. package/src/util/parseDependency.js +37 -42
  153. package/src/util/parseGlob.js +24 -0
  154. package/src/util/pluginUtils.js +132 -10
  155. package/src/util/removeAlphaVariables.js +24 -0
  156. package/src/util/resolveConfig.js +70 -32
  157. package/src/util/splitAtTopLevelOnly.js +45 -0
  158. package/src/util/toPath.js +1 -1
  159. package/src/util/transformThemeValue.js +13 -3
  160. package/src/util/validateConfig.js +13 -0
  161. package/src/util/validateFormalSyntax.js +34 -0
  162. package/src/util/withAlphaVariable.js +1 -1
  163. package/stubs/defaultConfig.stub.js +168 -164
  164. package/stubs/simpleConfig.stub.js +1 -0
  165. package/types/config.d.ts +363 -0
  166. package/types/generated/.gitkeep +0 -0
  167. package/types/generated/colors.d.ts +276 -0
  168. package/types/generated/corePluginList.d.ts +1 -0
  169. package/types/generated/default-theme.d.ts +342 -0
  170. package/types/index.d.ts +7 -0
@@ -3,6 +3,7 @@ import * as path from 'path'
3
3
  import postcss from 'postcss'
4
4
  import createUtilityPlugin from './util/createUtilityPlugin'
5
5
  import buildMediaQuery from './util/buildMediaQuery'
6
+ import escapeClassName from './util/escapeClassName'
6
7
  import parseAnimationValue from './util/parseAnimationValue'
7
8
  import flattenColorPalette from './util/flattenColorPalette'
8
9
  import withAlphaVariable, { withAlphaValue } from './util/withAlphaVariable'
@@ -11,21 +12,43 @@ import isPlainObject from './util/isPlainObject'
11
12
  import transformThemeValue from './util/transformThemeValue'
12
13
  import { version as tailwindVersion } from '../package.json'
13
14
  import log from './util/log'
14
- import { normalizeScreens } from './util/normalizeScreens'
15
+ import {
16
+ normalizeScreens,
17
+ isScreenSortable,
18
+ compareScreens,
19
+ toScreen,
20
+ } from './util/normalizeScreens'
15
21
  import { formatBoxShadowValue, parseBoxShadowValue } from './util/parseBoxShadowValue'
22
+ import { removeAlphaVariables } from './util/removeAlphaVariables'
23
+ import { flagEnabled } from './featureFlags'
24
+ import { normalize } from './util/dataTypes'
16
25
 
17
26
  export let variantPlugins = {
18
27
  pseudoElementVariants: ({ addVariant }) => {
19
28
  addVariant('first-letter', '&::first-letter')
20
29
  addVariant('first-line', '&::first-line')
21
30
 
22
- addVariant('marker', ['& *::marker', '&::marker'])
31
+ addVariant('marker', [
32
+ ({ container }) => {
33
+ removeAlphaVariables(container, ['--tw-text-opacity'])
34
+
35
+ return '& *::marker'
36
+ },
37
+ ({ container }) => {
38
+ removeAlphaVariables(container, ['--tw-text-opacity'])
39
+
40
+ return '&::marker'
41
+ },
42
+ ])
43
+
23
44
  addVariant('selection', ['& *::selection', '&::selection'])
24
45
 
25
46
  addVariant('file', '&::file-selector-button')
26
47
 
27
48
  addVariant('placeholder', '&::placeholder')
28
49
 
50
+ addVariant('backdrop', '&::backdrop')
51
+
29
52
  addVariant('before', ({ container }) => {
30
53
  container.walkRules((rule) => {
31
54
  let foundContent = false
@@ -57,14 +80,14 @@ export let variantPlugins = {
57
80
  })
58
81
  },
59
82
 
60
- pseudoClassVariants: ({ addVariant }) => {
83
+ pseudoClassVariants: ({ addVariant, matchVariant, config }) => {
61
84
  let pseudoVariants = [
62
85
  // Positional
63
- ['first', ':first-child'],
64
- ['last', ':last-child'],
65
- ['only', ':only-child'],
66
- ['odd', ':nth-child(odd)'],
67
- ['even', ':nth-child(even)'],
86
+ ['first', '&:first-child'],
87
+ ['last', '&:last-child'],
88
+ ['only', '&:only-child'],
89
+ ['odd', '&:nth-child(odd)'],
90
+ ['even', '&:nth-child(even)'],
68
91
  'first-of-type',
69
92
  'last-of-type',
70
93
  'only-of-type',
@@ -73,27 +96,17 @@ export let variantPlugins = {
73
96
  [
74
97
  'visited',
75
98
  ({ container }) => {
76
- let toRemove = ['--tw-text-opacity', '--tw-border-opacity', '--tw-bg-opacity']
99
+ removeAlphaVariables(container, [
100
+ '--tw-text-opacity',
101
+ '--tw-border-opacity',
102
+ '--tw-bg-opacity',
103
+ ])
77
104
 
78
- container.walkDecls((decl) => {
79
- if (toRemove.includes(decl.prop)) {
80
- decl.remove()
81
-
82
- return
83
- }
84
-
85
- for (const varName of toRemove) {
86
- if (decl.value.includes(`/ var(${varName})`)) {
87
- decl.value = decl.value.replace(`/ var(${varName})`, '')
88
- }
89
- }
90
- })
91
-
92
- return ':visited'
105
+ return '&:visited'
93
106
  },
94
107
  ],
95
108
  'target',
96
- ['open', '[open]'],
109
+ ['open', '&[open]'],
97
110
 
98
111
  // Forms
99
112
  'default',
@@ -101,6 +114,7 @@ export let variantPlugins = {
101
114
  'indeterminate',
102
115
  'placeholder-shown',
103
116
  'autofill',
117
+ 'optional',
104
118
  'required',
105
119
  'valid',
106
120
  'invalid',
@@ -113,35 +127,46 @@ export let variantPlugins = {
113
127
 
114
128
  // Interactive
115
129
  'focus-within',
116
- 'hover',
130
+ [
131
+ 'hover',
132
+ !flagEnabled(config(), 'hoverOnlyWhenSupported')
133
+ ? '&:hover'
134
+ : '@media (hover: hover) and (pointer: fine) { &:hover }',
135
+ ],
117
136
  'focus',
118
137
  'focus-visible',
119
138
  'active',
139
+ 'enabled',
120
140
  'disabled',
121
- ].map((variant) => (Array.isArray(variant) ? variant : [variant, `:${variant}`]))
141
+ ].map((variant) => (Array.isArray(variant) ? variant : [variant, `&:${variant}`]))
122
142
 
123
143
  for (let [variantName, state] of pseudoVariants) {
124
144
  addVariant(variantName, (ctx) => {
125
145
  let result = typeof state === 'function' ? state(ctx) : state
126
146
 
127
- return `&${result}`
147
+ return result
128
148
  })
129
149
  }
130
150
 
131
- for (let [variantName, state] of pseudoVariants) {
132
- addVariant(`group-${variantName}`, (ctx) => {
133
- let result = typeof state === 'function' ? state(ctx) : state
134
-
135
- return `:merge(.group)${result} &`
136
- })
151
+ let variants = {
152
+ group: (_, { modifier }) =>
153
+ modifier ? [`:merge(.group\\/${modifier})`, ' &'] : [`:merge(.group)`, ' &'],
154
+ peer: (_, { modifier }) =>
155
+ modifier ? [`:merge(.peer\\/${modifier})`, ' ~ &'] : [`:merge(.peer)`, ' ~ &'],
137
156
  }
138
157
 
139
- for (let [variantName, state] of pseudoVariants) {
140
- addVariant(`peer-${variantName}`, (ctx) => {
141
- let result = typeof state === 'function' ? state(ctx) : state
158
+ for (let [name, fn] of Object.entries(variants)) {
159
+ matchVariant(
160
+ name,
161
+ (value = '', extra) => {
162
+ let result = normalize(typeof value === 'function' ? value(extra) : value)
163
+ if (!result.includes('&')) result = '&' + result
142
164
 
143
- return `:merge(.peer)${result} ~ &`
144
- })
165
+ let [a, b] = fn('', extra)
166
+ return result.replace(/&(\S+)?/g, (_, pseudo = '') => a + pseudo + b)
167
+ },
168
+ { values: Object.fromEntries(pseudoVariants) }
169
+ )
145
170
  }
146
171
  },
147
172
 
@@ -171,7 +196,8 @@ export let variantPlugins = {
171
196
  },
172
197
 
173
198
  darkVariants: ({ config, addVariant }) => {
174
- let mode = config('darkMode', 'media')
199
+ let [mode, className = '.dark'] = [].concat(config('darkMode', 'media'))
200
+
175
201
  if (mode === false) {
176
202
  mode = 'media'
177
203
  log.warn('darkmode-false', [
@@ -182,7 +208,7 @@ export let variantPlugins = {
182
208
  }
183
209
 
184
210
  if (mode === 'class') {
185
- addVariant('dark', '.dark &')
211
+ addVariant('dark', `${className} &`)
186
212
  } else if (mode === 'media') {
187
213
  addVariant('dark', '@media (prefers-color-scheme: dark)')
188
214
  }
@@ -192,18 +218,211 @@ export let variantPlugins = {
192
218
  addVariant('print', '@media print')
193
219
  },
194
220
 
195
- screenVariants: ({ theme, addVariant }) => {
196
- for (let screen of normalizeScreens(theme('screens'))) {
197
- let query = buildMediaQuery(screen)
221
+ screenVariants: ({ theme, addVariant, matchVariant }) => {
222
+ let rawScreens = theme('screens') ?? {}
223
+ let areSimpleScreens = Object.values(rawScreens).every((v) => typeof v === 'string')
224
+ let screens = normalizeScreens(theme('screens'))
225
+
226
+ /** @type {Set<string>} */
227
+ let unitCache = new Set([])
228
+
229
+ /** @param {string} value */
230
+ function units(value) {
231
+ return value.match(/(\D+)$/)?.[1] ?? '(none)'
232
+ }
233
+
234
+ /** @param {string} value */
235
+ function recordUnits(value) {
236
+ if (value !== undefined) {
237
+ unitCache.add(units(value))
238
+ }
239
+ }
240
+
241
+ /** @param {string} value */
242
+ function canUseUnits(value) {
243
+ recordUnits(value)
244
+
245
+ // If the cache was empty it'll become 1 because we've just added the current unit
246
+ // If the cache was not empty and the units are the same the size doesn't change
247
+ // Otherwise, if the units are different from what is already known the size will always be > 1
248
+ return unitCache.size === 1
249
+ }
250
+
251
+ for (const screen of screens) {
252
+ for (const value of screen.values) {
253
+ recordUnits(value.min)
254
+ recordUnits(value.max)
255
+ }
256
+ }
257
+
258
+ let screensUseConsistentUnits = unitCache.size <= 1
259
+
260
+ /**
261
+ * @typedef {import('./util/normalizeScreens').Screen} Screen
262
+ */
263
+
264
+ /**
265
+ * @param {'min' | 'max'} type
266
+ * @returns {Record<string, Screen>}
267
+ */
268
+ function buildScreenValues(type) {
269
+ return Object.fromEntries(
270
+ screens
271
+ .filter((screen) => isScreenSortable(screen).result)
272
+ .map((screen) => {
273
+ let { min, max } = screen.values[0]
274
+
275
+ if (type === 'min' && min !== undefined) {
276
+ return screen
277
+ } else if (type === 'min' && max !== undefined) {
278
+ return { ...screen, not: !screen.not }
279
+ } else if (type === 'max' && max !== undefined) {
280
+ return screen
281
+ } else if (type === 'max' && min !== undefined) {
282
+ return { ...screen, not: !screen.not }
283
+ }
284
+ })
285
+ .map((screen) => [screen.name, screen])
286
+ )
287
+ }
288
+
289
+ /**
290
+ * @param {'min' | 'max'} type
291
+ * @returns {(a: { value: string | Screen }, z: { value: string | Screen }) => number}
292
+ */
293
+ function buildSort(type) {
294
+ return (a, z) => compareScreens(type, a.value, z.value)
295
+ }
296
+
297
+ let maxSort = buildSort('max')
298
+ let minSort = buildSort('min')
299
+
300
+ /** @param {'min'|'max'} type */
301
+ function buildScreenVariant(type) {
302
+ return (value) => {
303
+ if (!areSimpleScreens) {
304
+ log.warn('complex-screen-config', [
305
+ 'The `min-*` and `max-*` variants are not supported with a `screens` configuration containing objects.',
306
+ ])
307
+
308
+ return []
309
+ } else if (!screensUseConsistentUnits) {
310
+ log.warn('mixed-screen-units', [
311
+ 'The `min-*` and `max-*` variants are not supported with a `screens` configuration containing mixed units.',
312
+ ])
313
+
314
+ return []
315
+ } else if (typeof value === 'string' && !canUseUnits(value)) {
316
+ log.warn('minmax-have-mixed-units', [
317
+ 'The `min-*` and `max-*` variants are not supported with a `screens` configuration containing mixed units.',
318
+ ])
319
+
320
+ return []
321
+ }
322
+
323
+ return [`@media ${buildMediaQuery(toScreen(value, type))}`]
324
+ }
325
+ }
326
+
327
+ matchVariant('max', buildScreenVariant('max'), {
328
+ sort: maxSort,
329
+ values: areSimpleScreens ? buildScreenValues('max') : {},
330
+ })
198
331
 
199
- addVariant(screen.name, `@media ${query}`)
332
+ // screens and min-* are sorted together when they can be
333
+ let id = 'min-screens'
334
+ for (let screen of screens) {
335
+ addVariant(screen.name, `@media ${buildMediaQuery(screen)}`, {
336
+ id,
337
+ sort: areSimpleScreens && screensUseConsistentUnits ? minSort : undefined,
338
+ value: screen,
339
+ })
200
340
  }
341
+
342
+ matchVariant('min', buildScreenVariant('min'), {
343
+ id,
344
+ sort: minSort,
345
+ })
346
+ },
347
+
348
+ supportsVariants: ({ matchVariant, theme }) => {
349
+ matchVariant(
350
+ 'supports',
351
+ (value = '') => {
352
+ let check = normalize(value)
353
+ let isRaw = /^\w*\s*\(/.test(check)
354
+
355
+ // Chrome has a bug where `(condtion1)or(condition2)` is not valid
356
+ // But `(condition1) or (condition2)` is supported.
357
+ check = isRaw ? check.replace(/\b(and|or|not)\b/g, ' $1 ') : check
358
+
359
+ if (isRaw) {
360
+ return `@supports ${check}`
361
+ }
362
+
363
+ if (!check.includes(':')) {
364
+ check = `${check}: var(--tw)`
365
+ }
366
+
367
+ if (!(check.startsWith('(') && check.endsWith(')'))) {
368
+ check = `(${check})`
369
+ }
370
+
371
+ return `@supports ${check}`
372
+ },
373
+ { values: theme('supports') ?? {} }
374
+ )
375
+ },
376
+
377
+ ariaVariants: ({ matchVariant, theme }) => {
378
+ matchVariant('aria', (value) => `&[aria-${normalize(value)}]`, { values: theme('aria') ?? {} })
379
+ matchVariant(
380
+ 'group-aria',
381
+ (value, { modifier }) =>
382
+ modifier
383
+ ? `:merge(.group\\/${modifier})[aria-${normalize(value)}] &`
384
+ : `:merge(.group)[aria-${normalize(value)}] &`,
385
+ { values: theme('aria') ?? {} }
386
+ )
387
+ matchVariant(
388
+ 'peer-aria',
389
+ (value, { modifier }) =>
390
+ modifier
391
+ ? `:merge(.peer\\/${modifier})[aria-${normalize(value)}] ~ &`
392
+ : `:merge(.peer)[aria-${normalize(value)}] ~ &`,
393
+ { values: theme('aria') ?? {} }
394
+ )
395
+ },
396
+
397
+ dataVariants: ({ matchVariant, theme }) => {
398
+ matchVariant('data', (value) => `&[data-${normalize(value)}]`, { values: theme('data') ?? {} })
399
+ matchVariant(
400
+ 'group-data',
401
+ (value, { modifier }) =>
402
+ modifier
403
+ ? `:merge(.group\\/${modifier})[data-${normalize(value)}] &`
404
+ : `:merge(.group)[data-${normalize(value)}] &`,
405
+ { values: theme('data') ?? {} }
406
+ )
407
+ matchVariant(
408
+ 'peer-data',
409
+ (value, { modifier }) =>
410
+ modifier
411
+ ? `:merge(.peer\\/${modifier})[data-${normalize(value)}] ~ &`
412
+ : `:merge(.peer)[data-${normalize(value)}] ~ &`,
413
+ { values: theme('data') ?? {} }
414
+ )
201
415
  },
202
416
 
203
417
  orientationVariants: ({ addVariant }) => {
204
418
  addVariant('portrait', '@media (orientation: portrait)')
205
419
  addVariant('landscape', '@media (orientation: landscape)')
206
420
  },
421
+
422
+ prefersContrastVariants: ({ addVariant }) => {
423
+ addVariant('contrast-more', '@media (prefers-contrast: more)')
424
+ addVariant('contrast-less', '@media (prefers-contrast: less)')
425
+ },
207
426
  }
208
427
 
209
428
  let cssTransformValue = [
@@ -377,6 +596,7 @@ export let corePlugins = {
377
596
  addUtilities({
378
597
  '.visible': { visibility: 'visible' },
379
598
  '.invisible': { visibility: 'hidden' },
599
+ '.collapse': { visibility: 'collapse' },
380
600
  })
381
601
  },
382
602
 
@@ -527,6 +747,41 @@ export let corePlugins = {
527
747
  })
528
748
  },
529
749
 
750
+ borderSpacing: ({ addDefaults, matchUtilities, theme }) => {
751
+ addDefaults('border-spacing', {
752
+ '--tw-border-spacing-x': 0,
753
+ '--tw-border-spacing-y': 0,
754
+ })
755
+
756
+ matchUtilities(
757
+ {
758
+ 'border-spacing': (value) => {
759
+ return {
760
+ '--tw-border-spacing-x': value,
761
+ '--tw-border-spacing-y': value,
762
+ '@defaults border-spacing': {},
763
+ 'border-spacing': 'var(--tw-border-spacing-x) var(--tw-border-spacing-y)',
764
+ }
765
+ },
766
+ 'border-spacing-x': (value) => {
767
+ return {
768
+ '--tw-border-spacing-x': value,
769
+ '@defaults border-spacing': {},
770
+ 'border-spacing': 'var(--tw-border-spacing-x) var(--tw-border-spacing-y)',
771
+ }
772
+ },
773
+ 'border-spacing-y': (value) => {
774
+ return {
775
+ '--tw-border-spacing-y': value,
776
+ '@defaults border-spacing': {},
777
+ 'border-spacing': 'var(--tw-border-spacing-x) var(--tw-border-spacing-y)',
778
+ }
779
+ },
780
+ },
781
+ { values: theme('borderSpacing') }
782
+ )
783
+ },
784
+
530
785
  transformOrigin: createUtilityPlugin('transformOrigin', [['origin', ['transformOrigin']]]),
531
786
  translate: createUtilityPlugin(
532
787
  'translate',
@@ -611,8 +866,8 @@ export let corePlugins = {
611
866
  })
612
867
  },
613
868
 
614
- animation: ({ matchUtilities, theme, prefix }) => {
615
- let prefixName = (name) => prefix(`.${name}`).slice(1)
869
+ animation: ({ matchUtilities, theme, config }) => {
870
+ let prefixName = (name) => `${config('prefix')}${escapeClassName(name)}`
616
871
  let keyframes = Object.fromEntries(
617
872
  Object.entries(theme('keyframes') ?? {}).map(([key, value]) => {
618
873
  return [key, { [`@keyframes ${prefixName(key)}`]: value }]
@@ -844,6 +1099,7 @@ export let corePlugins = {
844
1099
  addUtilities({
845
1100
  '.grid-flow-row': { gridAutoFlow: 'row' },
846
1101
  '.grid-flow-col': { gridAutoFlow: 'column' },
1102
+ '.grid-flow-dense': { gridAutoFlow: 'dense' },
847
1103
  '.grid-flow-row-dense': { gridAutoFlow: 'row dense' },
848
1104
  '.grid-flow-col-dense': { gridAutoFlow: 'column dense' },
849
1105
  })
@@ -880,6 +1136,7 @@ export let corePlugins = {
880
1136
  '.place-content-between': { 'place-content': 'space-between' },
881
1137
  '.place-content-around': { 'place-content': 'space-around' },
882
1138
  '.place-content-evenly': { 'place-content': 'space-evenly' },
1139
+ '.place-content-baseline': { 'place-content': 'baseline' },
883
1140
  '.place-content-stretch': { 'place-content': 'stretch' },
884
1141
  })
885
1142
  },
@@ -889,6 +1146,7 @@ export let corePlugins = {
889
1146
  '.place-items-start': { 'place-items': 'start' },
890
1147
  '.place-items-end': { 'place-items': 'end' },
891
1148
  '.place-items-center': { 'place-items': 'center' },
1149
+ '.place-items-baseline': { 'place-items': 'baseline' },
892
1150
  '.place-items-stretch': { 'place-items': 'stretch' },
893
1151
  })
894
1152
  },
@@ -901,6 +1159,7 @@ export let corePlugins = {
901
1159
  '.content-between': { 'align-content': 'space-between' },
902
1160
  '.content-around': { 'align-content': 'space-around' },
903
1161
  '.content-evenly': { 'align-content': 'space-evenly' },
1162
+ '.content-baseline': { 'align-content': 'baseline' },
904
1163
  })
905
1164
  },
906
1165
 
@@ -1005,7 +1264,7 @@ export let corePlugins = {
1005
1264
  }
1006
1265
  },
1007
1266
  },
1008
- { values: theme('divideWidth'), type: ['line-width', 'length'] }
1267
+ { values: theme('divideWidth'), type: ['line-width', 'length', 'any'] }
1009
1268
  )
1010
1269
 
1011
1270
  addUtilities({
@@ -1053,7 +1312,7 @@ export let corePlugins = {
1053
1312
  },
1054
1313
  {
1055
1314
  values: (({ DEFAULT: _, ...colors }) => colors)(flattenColorPalette(theme('divideColor'))),
1056
- type: 'color',
1315
+ type: ['color', 'any'],
1057
1316
  }
1058
1317
  )
1059
1318
  },
@@ -1165,6 +1424,7 @@ export let corePlugins = {
1165
1424
  '.break-normal': { 'overflow-wrap': 'normal', 'word-break': 'normal' },
1166
1425
  '.break-words': { 'overflow-wrap': 'break-word' },
1167
1426
  '.break-all': { 'word-break': 'break-all' },
1427
+ '.break-keep': { 'word-break': 'keep-all' },
1168
1428
  })
1169
1429
  },
1170
1430
 
@@ -1232,7 +1492,7 @@ export let corePlugins = {
1232
1492
  },
1233
1493
  {
1234
1494
  values: (({ DEFAULT: _, ...colors }) => colors)(flattenColorPalette(theme('borderColor'))),
1235
- type: ['color'],
1495
+ type: ['color', 'any'],
1236
1496
  }
1237
1497
  )
1238
1498
 
@@ -1269,7 +1529,7 @@ export let corePlugins = {
1269
1529
  },
1270
1530
  {
1271
1531
  values: (({ DEFAULT: _, ...colors }) => colors)(flattenColorPalette(theme('borderColor'))),
1272
- type: 'color',
1532
+ type: ['color', 'any'],
1273
1533
  }
1274
1534
  )
1275
1535
 
@@ -1330,7 +1590,7 @@ export let corePlugins = {
1330
1590
  },
1331
1591
  {
1332
1592
  values: (({ DEFAULT: _, ...colors }) => colors)(flattenColorPalette(theme('borderColor'))),
1333
- type: 'color',
1593
+ type: ['color', 'any'],
1334
1594
  }
1335
1595
  )
1336
1596
  },
@@ -1356,7 +1616,7 @@ export let corePlugins = {
1356
1616
  })
1357
1617
  },
1358
1618
  },
1359
- { values: flattenColorPalette(theme('backgroundColor')), type: 'color' }
1619
+ { values: flattenColorPalette(theme('backgroundColor')), type: ['color', 'any'] }
1360
1620
  )
1361
1621
  },
1362
1622
 
@@ -1384,7 +1644,8 @@ export let corePlugins = {
1384
1644
 
1385
1645
  return {
1386
1646
  '--tw-gradient-from': toColorValue(value, 'from'),
1387
- '--tw-gradient-stops': `var(--tw-gradient-from), var(--tw-gradient-to, ${transparentToValue})`,
1647
+ '--tw-gradient-to': transparentToValue,
1648
+ '--tw-gradient-stops': `var(--tw-gradient-from), var(--tw-gradient-to)`,
1388
1649
  }
1389
1650
  },
1390
1651
  },
@@ -1396,10 +1657,11 @@ export let corePlugins = {
1396
1657
  let transparentToValue = transparentTo(value)
1397
1658
 
1398
1659
  return {
1660
+ '--tw-gradient-to': transparentToValue,
1399
1661
  '--tw-gradient-stops': `var(--tw-gradient-from), ${toColorValue(
1400
1662
  value,
1401
1663
  'via'
1402
- )}, var(--tw-gradient-to, ${transparentToValue})`,
1664
+ )}, var(--tw-gradient-to)`,
1403
1665
  }
1404
1666
  },
1405
1667
  },
@@ -1422,7 +1684,7 @@ export let corePlugins = {
1422
1684
  },
1423
1685
 
1424
1686
  backgroundSize: createUtilityPlugin('backgroundSize', [['bg', ['background-size']]], {
1425
- type: ['lookup', 'length', 'percentage'],
1687
+ type: ['lookup', 'length', 'percentage', 'size'],
1426
1688
  }),
1427
1689
 
1428
1690
  backgroundAttachment: ({ addUtilities }) => {
@@ -1443,7 +1705,7 @@ export let corePlugins = {
1443
1705
  },
1444
1706
 
1445
1707
  backgroundPosition: createUtilityPlugin('backgroundPosition', [['bg', ['background-position']]], {
1446
- type: ['lookup', 'position'],
1708
+ type: ['lookup', ['position', { preferOnConflict: true }]],
1447
1709
  }),
1448
1710
 
1449
1711
  backgroundRepeat: ({ addUtilities }) => {
@@ -1483,7 +1745,7 @@ export let corePlugins = {
1483
1745
  return { stroke: toColorValue(value) }
1484
1746
  },
1485
1747
  },
1486
- { values: flattenColorPalette(theme('stroke')), type: ['color', 'url'] }
1748
+ { values: flattenColorPalette(theme('stroke')), type: ['color', 'url', 'any'] }
1487
1749
  )
1488
1750
  },
1489
1751
 
@@ -1522,6 +1784,8 @@ export let corePlugins = {
1522
1784
  '.text-center': { 'text-align': 'center' },
1523
1785
  '.text-right': { 'text-align': 'right' },
1524
1786
  '.text-justify': { 'text-align': 'justify' },
1787
+ '.text-start': { 'text-align': 'start' },
1788
+ '.text-end': { 'text-align': 'end' },
1525
1789
  })
1526
1790
  },
1527
1791
 
@@ -1544,16 +1808,43 @@ export let corePlugins = {
1544
1808
  matchUtilities({ align: (value) => ({ 'vertical-align': value }) })
1545
1809
  },
1546
1810
 
1547
- fontFamily: createUtilityPlugin('fontFamily', [['font', ['fontFamily']]], {
1548
- type: ['lookup', 'generic-name', 'family-name'],
1549
- }),
1811
+ fontFamily: ({ matchUtilities, theme }) => {
1812
+ matchUtilities(
1813
+ {
1814
+ font: (value) => {
1815
+ let [families, options = {}] =
1816
+ Array.isArray(value) && isPlainObject(value[1]) ? value : [value]
1817
+ let { fontFeatureSettings } = options
1818
+
1819
+ return {
1820
+ 'font-family': Array.isArray(families) ? families.join(', ') : families,
1821
+ ...(fontFeatureSettings === undefined
1822
+ ? {}
1823
+ : { 'font-feature-settings': fontFeatureSettings }),
1824
+ }
1825
+ },
1826
+ },
1827
+ {
1828
+ values: theme('fontFamily'),
1829
+ type: ['lookup', 'generic-name', 'family-name'],
1830
+ }
1831
+ )
1832
+ },
1550
1833
 
1551
1834
  fontSize: ({ matchUtilities, theme }) => {
1552
1835
  matchUtilities(
1553
1836
  {
1554
- text: (value) => {
1837
+ text: (value, { modifier }) => {
1555
1838
  let [fontSize, options] = Array.isArray(value) ? value : [value]
1556
- let { lineHeight, letterSpacing } = isPlainObject(options)
1839
+
1840
+ if (modifier) {
1841
+ return {
1842
+ 'font-size': fontSize,
1843
+ 'line-height': modifier,
1844
+ }
1845
+ }
1846
+
1847
+ let { lineHeight, letterSpacing, fontWeight } = isPlainObject(options)
1557
1848
  ? options
1558
1849
  : { lineHeight: options }
1559
1850
 
@@ -1561,18 +1852,20 @@ export let corePlugins = {
1561
1852
  'font-size': fontSize,
1562
1853
  ...(lineHeight === undefined ? {} : { 'line-height': lineHeight }),
1563
1854
  ...(letterSpacing === undefined ? {} : { 'letter-spacing': letterSpacing }),
1855
+ ...(fontWeight === undefined ? {} : { 'font-weight': fontWeight }),
1564
1856
  }
1565
1857
  },
1566
1858
  },
1567
1859
  {
1568
1860
  values: theme('fontSize'),
1861
+ modifiers: theme('lineHeight'),
1569
1862
  type: ['absolute-size', 'relative-size', 'length', 'percentage'],
1570
1863
  }
1571
1864
  )
1572
1865
  },
1573
1866
 
1574
1867
  fontWeight: createUtilityPlugin('fontWeight', [['font', ['fontWeight']]], {
1575
- type: ['lookup', 'number'],
1868
+ type: ['lookup', 'number', 'any'],
1576
1869
  }),
1577
1870
 
1578
1871
  textTransform: ({ addUtilities }) => {
@@ -1668,7 +1961,7 @@ export let corePlugins = {
1668
1961
  })
1669
1962
  },
1670
1963
  },
1671
- { values: flattenColorPalette(theme('textColor')), type: 'color' }
1964
+ { values: flattenColorPalette(theme('textColor')), type: ['color', 'any'] }
1672
1965
  )
1673
1966
  },
1674
1967
 
@@ -1690,7 +1983,7 @@ export let corePlugins = {
1690
1983
  return { 'text-decoration-color': toColorValue(value) }
1691
1984
  },
1692
1985
  },
1693
- { values: flattenColorPalette(theme('textDecorationColor')), type: ['color'] }
1986
+ { values: flattenColorPalette(theme('textDecorationColor')), type: ['color', 'any'] }
1694
1987
  )
1695
1988
  },
1696
1989
 
@@ -1713,7 +2006,7 @@ export let corePlugins = {
1713
2006
  textUnderlineOffset: createUtilityPlugin(
1714
2007
  'textUnderlineOffset',
1715
2008
  [['underline-offset', ['text-underline-offset']]],
1716
- { type: ['length', 'percentage'] }
2009
+ { type: ['length', 'percentage', 'any'] }
1717
2010
  ),
1718
2011
 
1719
2012
  fontSmoothing: ({ addUtilities }) => {
@@ -1828,6 +2121,7 @@ export let corePlugins = {
1828
2121
  '.mix-blend-saturation': { 'mix-blend-mode': 'saturation' },
1829
2122
  '.mix-blend-color': { 'mix-blend-mode': 'color' },
1830
2123
  '.mix-blend-luminosity': { 'mix-blend-mode': 'luminosity' },
2124
+ '.mix-blend-plus-lighter': { 'mix-blend-mode': 'plus-lighter' },
1831
2125
  })
1832
2126
  },
1833
2127
 
@@ -1885,7 +2179,7 @@ export let corePlugins = {
1885
2179
  }
1886
2180
  },
1887
2181
  },
1888
- { values: flattenColorPalette(theme('boxShadowColor')), type: ['color'] }
2182
+ { values: flattenColorPalette(theme('boxShadowColor')), type: ['color', 'any'] }
1889
2183
  )
1890
2184
  },
1891
2185
 
@@ -1899,7 +2193,6 @@ export let corePlugins = {
1899
2193
  '.outline-dashed': { 'outline-style': 'dashed' },
1900
2194
  '.outline-dotted': { 'outline-style': 'dotted' },
1901
2195
  '.outline-double': { 'outline-style': 'double' },
1902
- '.outline-hidden': { 'outline-style': 'hidden' },
1903
2196
  })
1904
2197
  },
1905
2198
 
@@ -1908,7 +2201,8 @@ export let corePlugins = {
1908
2201
  }),
1909
2202
 
1910
2203
  outlineOffset: createUtilityPlugin('outlineOffset', [['outline-offset', ['outline-offset']]], {
1911
- type: ['length', 'number', 'percentage'],
2204
+ type: ['length', 'number', 'percentage', 'any'],
2205
+ supportsNegativeValues: true,
1912
2206
  }),
1913
2207
 
1914
2208
  outlineColor: ({ matchUtilities, theme }) => {
@@ -1918,17 +2212,28 @@ export let corePlugins = {
1918
2212
  return { 'outline-color': toColorValue(value) }
1919
2213
  },
1920
2214
  },
1921
- { values: flattenColorPalette(theme('outlineColor')), type: ['color'] }
2215
+ { values: flattenColorPalette(theme('outlineColor')), type: ['color', 'any'] }
1922
2216
  )
1923
2217
  },
1924
2218
 
1925
- ringWidth: ({ matchUtilities, addDefaults, addUtilities, theme }) => {
1926
- let ringOpacityDefault = theme('ringOpacity.DEFAULT', '0.5')
1927
- let ringColorDefault = withAlphaValue(
1928
- theme('ringColor.DEFAULT'),
1929
- ringOpacityDefault,
1930
- `rgb(147 197 253 / ${ringOpacityDefault})`
1931
- )
2219
+ ringWidth: ({ matchUtilities, addDefaults, addUtilities, theme, config }) => {
2220
+ let ringColorDefault = (() => {
2221
+ if (flagEnabled(config(), 'respectDefaultRingColorOpacity')) {
2222
+ return theme('ringColor.DEFAULT')
2223
+ }
2224
+
2225
+ let ringOpacityDefault = theme('ringOpacity.DEFAULT', '0.5')
2226
+
2227
+ if (!theme('ringColor')?.DEFAULT) {
2228
+ return `rgb(147 197 253 / ${ringOpacityDefault})`
2229
+ }
2230
+
2231
+ return withAlphaValue(
2232
+ theme('ringColor')?.DEFAULT,
2233
+ ringOpacityDefault,
2234
+ `rgb(147 197 253 / ${ringOpacityDefault})`
2235
+ )
2236
+ })()
1932
2237
 
1933
2238
  addDefaults('ring-width', {
1934
2239
  '--tw-ring-inset': ' ',
@@ -1964,10 +2269,16 @@ export let corePlugins = {
1964
2269
  })
1965
2270
  },
1966
2271
 
1967
- ringColor: ({ matchUtilities, theme }) => {
2272
+ ringColor: ({ matchUtilities, theme, corePlugins }) => {
1968
2273
  matchUtilities(
1969
2274
  {
1970
2275
  ring: (value) => {
2276
+ if (!corePlugins('ringOpacity')) {
2277
+ return {
2278
+ '--tw-ring-color': toColorValue(value),
2279
+ }
2280
+ }
2281
+
1971
2282
  return withAlphaVariable({
1972
2283
  color: value,
1973
2284
  property: '--tw-ring-color',
@@ -1981,14 +2292,18 @@ export let corePlugins = {
1981
2292
  ([modifier]) => modifier !== 'DEFAULT'
1982
2293
  )
1983
2294
  ),
1984
- type: 'color',
2295
+ type: ['color', 'any'],
1985
2296
  }
1986
2297
  )
1987
2298
  },
1988
2299
 
1989
- ringOpacity: createUtilityPlugin('ringOpacity', [['ring-opacity', ['--tw-ring-opacity']]], {
1990
- filterDefault: true,
1991
- }),
2300
+ ringOpacity: (helpers) => {
2301
+ let { config } = helpers
2302
+
2303
+ return createUtilityPlugin('ringOpacity', [['ring-opacity', ['--tw-ring-opacity']]], {
2304
+ filterDefault: !flagEnabled(config(), 'respectDefaultRingColorOpacity'),
2305
+ })(helpers)
2306
+ },
1992
2307
  ringOffsetWidth: createUtilityPlugin(
1993
2308
  'ringOffsetWidth',
1994
2309
  [['ring-offset', ['--tw-ring-offset-width']]],
@@ -2004,7 +2319,7 @@ export let corePlugins = {
2004
2319
  }
2005
2320
  },
2006
2321
  },
2007
- { values: flattenColorPalette(theme('ringOffsetColor')), type: 'color' }
2322
+ { values: flattenColorPalette(theme('ringOffsetColor')), type: ['color', 'any'] }
2008
2323
  )
2009
2324
  },
2010
2325