tailwindcss 3.0.0-alpha.1 → 3.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +67 -1
  2. package/lib/cli.js +66 -62
  3. package/lib/constants.js +1 -1
  4. package/lib/corePluginList.js +7 -1
  5. package/lib/corePlugins.js +264 -203
  6. package/lib/css/preflight.css +12 -0
  7. package/lib/featureFlags.js +10 -7
  8. package/lib/lib/collapseDuplicateDeclarations.js +29 -0
  9. package/lib/lib/evaluateTailwindFunctions.js +3 -3
  10. package/lib/lib/expandApplyAtRules.js +7 -7
  11. package/lib/lib/expandTailwindAtRules.js +2 -1
  12. package/lib/lib/generateRules.js +115 -19
  13. package/lib/lib/resolveDefaultsAtRules.js +44 -47
  14. package/lib/lib/setupContextUtils.js +72 -15
  15. package/lib/lib/setupWatchingContext.js +5 -1
  16. package/lib/lib/sharedState.js +2 -2
  17. package/lib/processTailwindFeatures.js +4 -0
  18. package/lib/util/createUtilityPlugin.js +5 -5
  19. package/lib/util/dataTypes.js +24 -4
  20. package/lib/util/formatVariantSelector.js +102 -0
  21. package/lib/util/nameClass.js +1 -1
  22. package/lib/util/negateValue.js +3 -1
  23. package/lib/util/normalizeConfig.js +22 -8
  24. package/lib/util/parseBoxShadowValue.js +77 -0
  25. package/lib/util/pluginUtils.js +62 -158
  26. package/lib/util/prefixSelector.js +1 -3
  27. package/lib/util/resolveConfig.js +13 -9
  28. package/lib/util/transformThemeValue.js +23 -13
  29. package/package.json +11 -11
  30. package/peers/index.js +873 -2505
  31. package/src/cli.js +9 -2
  32. package/src/corePluginList.js +1 -1
  33. package/src/corePlugins.js +282 -348
  34. package/src/css/preflight.css +12 -0
  35. package/src/featureFlags.js +10 -4
  36. package/src/lib/collapseDuplicateDeclarations.js +28 -0
  37. package/src/lib/expandTailwindAtRules.js +3 -2
  38. package/src/lib/generateRules.js +121 -11
  39. package/src/lib/resolveDefaultsAtRules.js +39 -43
  40. package/src/lib/setupContextUtils.js +71 -9
  41. package/src/lib/setupWatchingContext.js +7 -0
  42. package/src/lib/sharedState.js +1 -1
  43. package/src/processTailwindFeatures.js +5 -0
  44. package/src/util/createUtilityPlugin.js +2 -2
  45. package/src/util/dataTypes.js +32 -5
  46. package/src/util/formatVariantSelector.js +105 -0
  47. package/src/util/nameClass.js +1 -1
  48. package/src/util/negateValue.js +4 -2
  49. package/src/util/normalizeConfig.js +17 -1
  50. package/src/util/parseBoxShadowValue.js +71 -0
  51. package/src/util/pluginUtils.js +50 -146
  52. package/src/util/prefixSelector.js +1 -4
  53. package/src/util/resolveConfig.js +7 -1
  54. package/src/util/transformThemeValue.js +22 -7
  55. package/stubs/defaultConfig.stub.js +101 -58
  56. package/peers/.svgo.yml +0 -75
  57. package/peers/orders/concentric-css.json +0 -299
  58. package/peers/orders/smacss.json +0 -299
  59. package/peers/orders/source.json +0 -295
  60. package/src/.DS_Store +0 -0
@@ -1,130 +1,60 @@
1
1
  import fs from 'fs'
2
+ import * as path from 'path'
2
3
  import postcss from 'postcss'
3
4
  import createUtilityPlugin from './util/createUtilityPlugin'
4
5
  import buildMediaQuery from './util/buildMediaQuery'
5
- import prefixSelector from './util/prefixSelector'
6
6
  import parseAnimationValue from './util/parseAnimationValue'
7
7
  import flattenColorPalette from './util/flattenColorPalette'
8
8
  import withAlphaVariable, { withAlphaValue } from './util/withAlphaVariable'
9
9
  import toColorValue from './util/toColorValue'
10
10
  import isPlainObject from './util/isPlainObject'
11
11
  import transformThemeValue from './util/transformThemeValue'
12
- import {
13
- applyStateToMarker,
14
- updateLastClasses,
15
- updateAllClasses,
16
- transformAllSelectors,
17
- transformAllClasses,
18
- transformLastClasses,
19
- } from './util/pluginUtils'
20
12
  import { version as tailwindVersion } from '../package.json'
21
13
  import log from './util/log'
14
+ import { formatBoxShadowValue, parseBoxShadowValue } from './util/parseBoxShadowValue'
22
15
 
23
16
  export let variantPlugins = {
24
- pseudoElementVariants: ({ config, addVariant }) => {
25
- addVariant(
26
- 'first-letter',
27
- transformAllSelectors((selector) => {
28
- return updateAllClasses(selector, (className, { withPseudo }) => {
29
- return withPseudo(`first-letter${config('separator')}${className}`, '::first-letter')
30
- })
31
- })
32
- )
17
+ pseudoElementVariants: ({ addVariant }) => {
18
+ addVariant('first-letter', '&::first-letter')
19
+ addVariant('first-line', '&::first-line')
33
20
 
34
- addVariant(
35
- 'first-line',
36
- transformAllSelectors((selector) => {
37
- return updateAllClasses(selector, (className, { withPseudo }) => {
38
- return withPseudo(`first-line${config('separator')}${className}`, '::first-line')
39
- })
40
- })
41
- )
21
+ addVariant('marker', ['& *::marker', '&::marker'])
22
+ addVariant('selection', ['& *::selection', '&::selection'])
42
23
 
43
- addVariant('marker', [
44
- transformAllSelectors((selector) => {
45
- let variantSelector = updateAllClasses(selector, (className) => {
46
- return `marker${config('separator')}${className}`
47
- })
24
+ addVariant('file', '&::file-selector-button')
48
25
 
49
- return `${variantSelector} *::marker`
50
- }),
51
- transformAllSelectors((selector) => {
52
- return updateAllClasses(selector, (className, { withPseudo }) => {
53
- return withPseudo(`marker${config('separator')}${className}`, '::marker')
26
+ addVariant('before', ({ container }) => {
27
+ container.walkRules((rule) => {
28
+ let foundContent = false
29
+ rule.walkDecls('content', () => {
30
+ foundContent = true
54
31
  })
55
- }),
56
- ])
57
32
 
58
- addVariant('selection', [
59
- transformAllSelectors((selector) => {
60
- let variantSelector = updateAllClasses(selector, (className) => {
61
- return `selection${config('separator')}${className}`
62
- })
33
+ if (!foundContent) {
34
+ rule.prepend(postcss.decl({ prop: 'content', value: 'var(--tw-content)' }))
35
+ }
36
+ })
63
37
 
64
- return `${variantSelector} *::selection`
65
- }),
66
- transformAllSelectors((selector) => {
67
- return updateAllClasses(selector, (className, { withPseudo }) => {
68
- return withPseudo(`selection${config('separator')}${className}`, '::selection')
69
- })
70
- }),
71
- ])
38
+ return '&::before'
39
+ })
72
40
 
73
- addVariant(
74
- 'file',
75
- transformAllSelectors((selector) => {
76
- return updateAllClasses(selector, (className, { withPseudo }) => {
77
- return withPseudo(`file${config('separator')}${className}`, '::file-selector-button')
41
+ addVariant('after', ({ container }) => {
42
+ container.walkRules((rule) => {
43
+ let foundContent = false
44
+ rule.walkDecls('content', () => {
45
+ foundContent = true
78
46
  })
79
- })
80
- )
81
47
 
82
- addVariant(
83
- 'before',
84
- transformAllSelectors(
85
- (selector) => {
86
- return updateAllClasses(selector, (className, { withPseudo }) => {
87
- return withPseudo(`before${config('separator')}${className}`, '::before')
88
- })
89
- },
90
- {
91
- withRule: (rule) => {
92
- let foundContent = false
93
- rule.walkDecls('content', () => {
94
- foundContent = true
95
- })
96
- if (!foundContent) {
97
- rule.prepend(postcss.decl({ prop: 'content', value: '""' }))
98
- }
99
- },
48
+ if (!foundContent) {
49
+ rule.prepend(postcss.decl({ prop: 'content', value: 'var(--tw-content)' }))
100
50
  }
101
- )
102
- )
51
+ })
103
52
 
104
- addVariant(
105
- 'after',
106
- transformAllSelectors(
107
- (selector) => {
108
- return updateAllClasses(selector, (className, { withPseudo }) => {
109
- return withPseudo(`after${config('separator')}${className}`, '::after')
110
- })
111
- },
112
- {
113
- withRule: (rule) => {
114
- let foundContent = false
115
- rule.walkDecls('content', () => {
116
- foundContent = true
117
- })
118
- if (!foundContent) {
119
- rule.prepend(postcss.decl({ prop: 'content', value: '""' }))
120
- }
121
- },
122
- }
123
- )
124
- )
53
+ return '&::after'
54
+ })
125
55
  },
126
56
 
127
- pseudoClassVariants: ({ config, addVariant }) => {
57
+ pseudoClassVariants: ({ addVariant }) => {
128
58
  let pseudoVariants = [
129
59
  // Positional
130
60
  ['first', ':first-child'],
@@ -164,137 +94,44 @@ export let variantPlugins = {
164
94
  'focus-visible',
165
95
  'active',
166
96
  'disabled',
167
- ]
168
-
169
- for (let variant of pseudoVariants) {
170
- let [variantName, state] = Array.isArray(variant) ? variant : [variant, `:${variant}`]
171
-
172
- addVariant(
173
- variantName,
174
- transformAllClasses((className, { withAttr, withPseudo }) => {
175
- if (state.startsWith(':')) {
176
- return withPseudo(`${variantName}${config('separator')}${className}`, state)
177
- } else if (state.startsWith('[')) {
178
- return withAttr(`${variantName}${config('separator')}${className}`, state)
179
- }
180
- })
181
- )
182
- }
183
-
184
- let groupMarker = prefixSelector(config('prefix'), '.group')
185
- for (let variant of pseudoVariants) {
186
- let [variantName, state] = Array.isArray(variant) ? variant : [variant, `:${variant}`]
187
- let groupVariantName = `group-${variantName}`
188
-
189
- addVariant(
190
- groupVariantName,
191
- transformAllSelectors((selector) => {
192
- let variantSelector = updateAllClasses(selector, (className) => {
193
- if (`.${className}` === groupMarker) return className
194
- return `${groupVariantName}${config('separator')}${className}`
195
- })
97
+ ].map((variant) => (Array.isArray(variant) ? variant : [variant, `:${variant}`]))
196
98
 
197
- if (variantSelector === selector) {
198
- return null
199
- }
200
-
201
- return applyStateToMarker(
202
- variantSelector,
203
- groupMarker,
204
- state,
205
- (marker, selector) => `${marker} ${selector}`
206
- )
207
- })
208
- )
99
+ for (let [variantName, state] of pseudoVariants) {
100
+ addVariant(variantName, `&${state}`)
209
101
  }
210
102
 
211
- let peerMarker = prefixSelector(config('prefix'), '.peer')
212
- for (let variant of pseudoVariants) {
213
- let [variantName, state] = Array.isArray(variant) ? variant : [variant, `:${variant}`]
214
- let peerVariantName = `peer-${variantName}`
215
-
216
- addVariant(
217
- peerVariantName,
218
- transformAllSelectors((selector) => {
219
- let variantSelector = updateAllClasses(selector, (className) => {
220
- if (`.${className}` === peerMarker) return className
221
- return `${peerVariantName}${config('separator')}${className}`
222
- })
223
-
224
- if (variantSelector === selector) {
225
- return null
226
- }
103
+ for (let [variantName, state] of pseudoVariants) {
104
+ addVariant(`group-${variantName}`, `:merge(.group)${state} &`)
105
+ }
227
106
 
228
- return applyStateToMarker(variantSelector, peerMarker, state, (marker, selector) =>
229
- selector.trim().startsWith('~') ? `${marker}${selector}` : `${marker} ~ ${selector}`
230
- )
231
- })
232
- )
107
+ for (let [variantName, state] of pseudoVariants) {
108
+ addVariant(`peer-${variantName}`, `:merge(.peer)${state} ~ &`)
233
109
  }
234
110
  },
235
111
 
236
- directionVariants: ({ config, addVariant }) => {
237
- addVariant(
238
- 'ltr',
239
- transformAllSelectors((selector) => {
240
- log.warn('rtl-experimental', [
241
- 'The RTL features in Tailwind CSS are currently in preview.',
242
- 'Preview features are not covered by semver, and may be improved in breaking ways at any time.',
243
- ])
244
- return `[dir="ltr"] ${updateAllClasses(
245
- selector,
246
- (className) => `ltr${config('separator')}${className}`
247
- )}`
248
- })
249
- )
112
+ directionVariants: ({ addVariant }) => {
113
+ addVariant('ltr', () => {
114
+ log.warn('rtl-experimental', [
115
+ 'The RTL features in Tailwind CSS are currently in preview.',
116
+ 'Preview features are not covered by semver, and may be improved in breaking ways at any time.',
117
+ ])
250
118
 
251
- addVariant(
252
- 'rtl',
253
- transformAllSelectors((selector) => {
254
- log.warn('rtl-experimental', [
255
- 'The RTL features in Tailwind CSS are currently in preview.',
256
- 'Preview features are not covered by semver, and may be improved in breaking ways at any time.',
257
- ])
258
- return `[dir="rtl"] ${updateAllClasses(
259
- selector,
260
- (className) => `rtl${config('separator')}${className}`
261
- )}`
262
- })
263
- )
264
- },
119
+ return '[dir="ltr"] &'
120
+ })
265
121
 
266
- reducedMotionVariants: ({ config, addVariant }) => {
267
- addVariant(
268
- 'motion-safe',
269
- transformLastClasses(
270
- (className) => {
271
- return `motion-safe${config('separator')}${className}`
272
- },
273
- {
274
- wrap: () =>
275
- postcss.atRule({
276
- name: 'media',
277
- params: '(prefers-reduced-motion: no-preference)',
278
- }),
279
- }
280
- )
281
- )
122
+ addVariant('rtl', () => {
123
+ log.warn('rtl-experimental', [
124
+ 'The RTL features in Tailwind CSS are currently in preview.',
125
+ 'Preview features are not covered by semver, and may be improved in breaking ways at any time.',
126
+ ])
282
127
 
283
- addVariant(
284
- 'motion-reduce',
285
- transformLastClasses(
286
- (className) => {
287
- return `motion-reduce${config('separator')}${className}`
288
- },
289
- {
290
- wrap: () =>
291
- postcss.atRule({
292
- name: 'media',
293
- params: '(prefers-reduced-motion: reduce)',
294
- }),
295
- }
296
- )
297
- )
128
+ return '[dir="rtl"] &'
129
+ })
130
+ },
131
+
132
+ reducedMotionVariants: ({ addVariant }) => {
133
+ addVariant('motion-safe', '@media (prefers-reduced-motion: no-preference)')
134
+ addVariant('motion-reduce', '@media (prefers-reduced-motion: reduce)')
298
135
  },
299
136
 
300
137
  darkVariants: ({ config, addVariant }) => {
@@ -308,62 +145,31 @@ export let variantPlugins = {
308
145
  }
309
146
 
310
147
  if (mode === 'class') {
311
- addVariant(
312
- 'dark',
313
- transformAllSelectors((selector) => {
314
- let variantSelector = updateLastClasses(selector, (className) => {
315
- return `dark${config('separator')}${className}`
316
- })
317
-
318
- if (variantSelector === selector) {
319
- return null
320
- }
321
-
322
- let darkSelector = prefixSelector(config('prefix'), `.dark`)
323
-
324
- return `${darkSelector} ${variantSelector}`
325
- })
326
- )
148
+ addVariant('dark', '.dark &')
327
149
  } else if (mode === 'media') {
328
- addVariant(
329
- 'dark',
330
- transformLastClasses(
331
- (className) => {
332
- return `dark${config('separator')}${className}`
333
- },
334
- {
335
- wrap: () =>
336
- postcss.atRule({
337
- name: 'media',
338
- params: '(prefers-color-scheme: dark)',
339
- }),
340
- }
341
- )
342
- )
150
+ addVariant('dark', '@media (prefers-color-scheme: dark)')
343
151
  }
344
152
  },
345
153
 
346
- screenVariants: ({ config, theme, addVariant }) => {
154
+ printVariant: ({ addVariant }) => {
155
+ addVariant('print', '@media print')
156
+ },
157
+
158
+ screenVariants: ({ theme, addVariant }) => {
347
159
  for (let screen in theme('screens')) {
348
160
  let size = theme('screens')[screen]
349
161
  let query = buildMediaQuery(size)
350
162
 
351
- addVariant(
352
- screen,
353
- transformLastClasses(
354
- (className) => {
355
- return `${screen}${config('separator')}${className}`
356
- },
357
- { wrap: () => postcss.atRule({ name: 'media', params: query }) }
358
- )
359
- )
163
+ addVariant(screen, `@media ${query}`)
360
164
  }
361
165
  },
362
166
  }
363
167
 
364
168
  export let corePlugins = {
365
169
  preflight: ({ addBase }) => {
366
- let preflightStyles = postcss.parse(fs.readFileSync(`${__dirname}/css/preflight.css`, 'utf8'))
170
+ let preflightStyles = postcss.parse(
171
+ fs.readFileSync(path.join(__dirname, './css/preflight.css'), 'utf8')
172
+ )
367
173
 
368
174
  addBase([
369
175
  postcss.comment({
@@ -529,19 +335,23 @@ export let corePlugins = {
529
335
  })
530
336
  },
531
337
 
532
- inset: createUtilityPlugin('inset', [
533
- ['inset', ['top', 'right', 'bottom', 'left']],
534
- [
535
- ['inset-x', ['left', 'right']],
536
- ['inset-y', ['top', 'bottom']],
537
- ],
338
+ inset: createUtilityPlugin(
339
+ 'inset',
538
340
  [
539
- ['top', ['top']],
540
- ['right', ['right']],
541
- ['bottom', ['bottom']],
542
- ['left', ['left']],
341
+ ['inset', ['top', 'right', 'bottom', 'left']],
342
+ [
343
+ ['inset-x', ['left', 'right']],
344
+ ['inset-y', ['top', 'bottom']],
345
+ ],
346
+ [
347
+ ['top', ['top']],
348
+ ['right', ['right']],
349
+ ['bottom', ['bottom']],
350
+ ['left', ['left']],
351
+ ],
543
352
  ],
544
- ]),
353
+ { supportsNegativeValues: true }
354
+ ),
545
355
 
546
356
  isolation: ({ addUtilities }) => {
547
357
  addUtilities({
@@ -550,8 +360,8 @@ export let corePlugins = {
550
360
  })
551
361
  },
552
362
 
553
- zIndex: createUtilityPlugin('zIndex', [['z', ['zIndex']]]),
554
- order: createUtilityPlugin('order'),
363
+ zIndex: createUtilityPlugin('zIndex', [['z', ['zIndex']]], { supportsNegativeValues: true }),
364
+ order: createUtilityPlugin('order', undefined, { supportsNegativeValues: true }),
555
365
  gridColumn: createUtilityPlugin('gridColumn', [['col', ['gridColumn']]]),
556
366
  gridColumnStart: createUtilityPlugin('gridColumnStart', [['col-start', ['gridColumnStart']]]),
557
367
  gridColumnEnd: createUtilityPlugin('gridColumnEnd', [['col-end', ['gridColumnEnd']]]),
@@ -576,19 +386,23 @@ export let corePlugins = {
576
386
  })
577
387
  },
578
388
 
579
- margin: createUtilityPlugin('margin', [
580
- ['m', ['margin']],
581
- [
582
- ['mx', ['margin-left', 'margin-right']],
583
- ['my', ['margin-top', 'margin-bottom']],
584
- ],
389
+ margin: createUtilityPlugin(
390
+ 'margin',
585
391
  [
586
- ['mt', ['margin-top']],
587
- ['mr', ['margin-right']],
588
- ['mb', ['margin-bottom']],
589
- ['ml', ['margin-left']],
392
+ ['m', ['margin']],
393
+ [
394
+ ['mx', ['margin-left', 'margin-right']],
395
+ ['my', ['margin-top', 'margin-bottom']],
396
+ ],
397
+ [
398
+ ['mt', ['margin-top']],
399
+ ['mr', ['margin-right']],
400
+ ['mb', ['margin-bottom']],
401
+ ['ml', ['margin-left']],
402
+ ],
590
403
  ],
591
- ]),
404
+ { supportsNegativeValues: true }
405
+ ),
592
406
 
593
407
  boxSizing: ({ addUtilities }) => {
594
408
  addUtilities({
@@ -634,8 +448,15 @@ export let corePlugins = {
634
448
  maxWidth: createUtilityPlugin('maxWidth', [['max-w', ['maxWidth']]]),
635
449
 
636
450
  flex: createUtilityPlugin('flex'),
637
- flexShrink: createUtilityPlugin('flexShrink', [['flex-shrink', ['flex-shrink']]]),
638
- flexGrow: createUtilityPlugin('flexGrow', [['flex-grow', ['flex-grow']]]),
451
+ flexShrink: createUtilityPlugin('flexShrink', [
452
+ ['flex-shrink', ['flex-shrink']], // Deprecated
453
+ ['shrink', ['flex-shrink']],
454
+ ]),
455
+ flexGrow: createUtilityPlugin('flexGrow', [
456
+ ['flex-grow', ['flex-grow']], // Deprecated
457
+ ['grow', ['flex-grow']],
458
+ ]),
459
+ flexBasis: createUtilityPlugin('flexBasis', [['basis', ['flex-basis']]]),
639
460
 
640
461
  tableLayout: ({ addUtilities }) => {
641
462
  addUtilities({
@@ -652,33 +473,48 @@ export let corePlugins = {
652
473
  },
653
474
 
654
475
  transformOrigin: createUtilityPlugin('transformOrigin', [['origin', ['transformOrigin']]]),
655
- translate: createUtilityPlugin('translate', [
476
+ translate: createUtilityPlugin(
477
+ 'translate',
656
478
  [
657
479
  [
658
- 'translate-x',
659
- [['@defaults transform', {}], '--tw-translate-x', ['transform', 'var(--tw-transform)']],
660
- ],
661
- [
662
- 'translate-y',
663
- [['@defaults transform', {}], '--tw-translate-y', ['transform', 'var(--tw-transform)']],
480
+ [
481
+ 'translate-x',
482
+ [['@defaults transform', {}], '--tw-translate-x', ['transform', 'var(--tw-transform)']],
483
+ ],
484
+ [
485
+ 'translate-y',
486
+ [['@defaults transform', {}], '--tw-translate-y', ['transform', 'var(--tw-transform)']],
487
+ ],
664
488
  ],
665
489
  ],
666
- ]),
667
- rotate: createUtilityPlugin('rotate', [
668
- ['rotate', [['@defaults transform', {}], '--tw-rotate', ['transform', 'var(--tw-transform)']]],
669
- ]),
670
- skew: createUtilityPlugin('skew', [
490
+ { supportsNegativeValues: true }
491
+ ),
492
+ rotate: createUtilityPlugin(
493
+ 'rotate',
671
494
  [
672
495
  [
673
- 'skew-x',
674
- [['@defaults transform', {}], '--tw-skew-x', ['transform', 'var(--tw-transform)']],
496
+ 'rotate',
497
+ [['@defaults transform', {}], '--tw-rotate', ['transform', 'var(--tw-transform)']],
675
498
  ],
499
+ ],
500
+ { supportsNegativeValues: true }
501
+ ),
502
+ skew: createUtilityPlugin(
503
+ 'skew',
504
+ [
676
505
  [
677
- 'skew-y',
678
- [['@defaults transform', {}], '--tw-skew-y', ['transform', 'var(--tw-transform)']],
506
+ [
507
+ 'skew-x',
508
+ [['@defaults transform', {}], '--tw-skew-x', ['transform', 'var(--tw-transform)']],
509
+ ],
510
+ [
511
+ 'skew-y',
512
+ [['@defaults transform', {}], '--tw-skew-y', ['transform', 'var(--tw-transform)']],
513
+ ],
679
514
  ],
680
515
  ],
681
- ]),
516
+ { supportsNegativeValues: true }
517
+ ),
682
518
  scale: createUtilityPlugin('scale', [
683
519
  [
684
520
  'scale',
@@ -858,19 +694,23 @@ export let corePlugins = {
858
694
  })
859
695
  },
860
696
 
861
- scrollMargin: createUtilityPlugin('scrollMargin', [
862
- ['scroll-m', ['scroll-margin']],
863
- [
864
- ['scroll-mx', ['scroll-margin-left', 'scroll-margin-right']],
865
- ['scroll-my', ['scroll-margin-top', 'scroll-margin-bottom']],
866
- ],
697
+ scrollMargin: createUtilityPlugin(
698
+ 'scrollMargin',
867
699
  [
868
- ['scroll-mt', ['scroll-margin-top']],
869
- ['scroll-mr', ['scroll-margin-right']],
870
- ['scroll-mb', ['scroll-margin-bottom']],
871
- ['scroll-ml', ['scroll-margin-left']],
700
+ ['scroll-m', ['scroll-margin']],
701
+ [
702
+ ['scroll-mx', ['scroll-margin-left', 'scroll-margin-right']],
703
+ ['scroll-my', ['scroll-margin-top', 'scroll-margin-bottom']],
704
+ ],
705
+ [
706
+ ['scroll-mt', ['scroll-margin-top']],
707
+ ['scroll-mr', ['scroll-margin-right']],
708
+ ['scroll-mb', ['scroll-margin-bottom']],
709
+ ['scroll-ml', ['scroll-margin-left']],
710
+ ],
872
711
  ],
873
- ]),
712
+ { supportsNegativeValues: true }
713
+ ),
874
714
 
875
715
  scrollPadding: createUtilityPlugin('scrollPadding', [
876
716
  ['scroll-p', ['scroll-padding']],
@@ -1068,7 +908,7 @@ export let corePlugins = {
1068
908
  }
1069
909
  },
1070
910
  },
1071
- { values: theme('space') }
911
+ { values: theme('space'), supportsNegativeValues: true }
1072
912
  )
1073
913
 
1074
914
  addUtilities({
@@ -1640,7 +1480,9 @@ export let corePlugins = {
1640
1480
  })
1641
1481
  },
1642
1482
 
1643
- textIndent: createUtilityPlugin('textIndent', [['indent', ['text-indent']]]),
1483
+ textIndent: createUtilityPlugin('textIndent', [['indent', ['text-indent']]], {
1484
+ supportsNegativeValues: true,
1485
+ }),
1644
1486
 
1645
1487
  verticalAlign: ({ addUtilities, matchUtilities }) => {
1646
1488
  addUtilities({
@@ -1706,30 +1548,63 @@ export let corePlugins = {
1706
1548
 
1707
1549
  fontVariantNumeric: ({ addUtilities }) => {
1708
1550
  addUtilities({
1709
- '.ordinal, .slashed-zero, .lining-nums, .oldstyle-nums, .proportional-nums, .tabular-nums, .diagonal-fractions, .stacked-fractions':
1710
- {
1711
- '--tw-ordinal': 'var(--tw-empty,/*!*/ /*!*/)',
1712
- '--tw-slashed-zero': 'var(--tw-empty,/*!*/ /*!*/)',
1713
- '--tw-numeric-figure': 'var(--tw-empty,/*!*/ /*!*/)',
1714
- '--tw-numeric-spacing': 'var(--tw-empty,/*!*/ /*!*/)',
1715
- '--tw-numeric-fraction': 'var(--tw-empty,/*!*/ /*!*/)',
1716
- 'font-variant-numeric':
1717
- 'var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)',
1718
- },
1551
+ '@defaults font-variant-numeric': {
1552
+ '--tw-ordinal': 'var(--tw-empty,/*!*/ /*!*/)',
1553
+ '--tw-slashed-zero': 'var(--tw-empty,/*!*/ /*!*/)',
1554
+ '--tw-numeric-figure': 'var(--tw-empty,/*!*/ /*!*/)',
1555
+ '--tw-numeric-spacing': 'var(--tw-empty,/*!*/ /*!*/)',
1556
+ '--tw-numeric-fraction': 'var(--tw-empty,/*!*/ /*!*/)',
1557
+ '--tw-font-variant-numeric':
1558
+ 'var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)',
1559
+ },
1719
1560
  '.normal-nums': { 'font-variant-numeric': 'normal' },
1720
- '.ordinal': { '--tw-ordinal': 'ordinal' },
1721
- '.slashed-zero': { '--tw-slashed-zero': 'slashed-zero' },
1722
- '.lining-nums': { '--tw-numeric-figure': 'lining-nums' },
1723
- '.oldstyle-nums': { '--tw-numeric-figure': 'oldstyle-nums' },
1724
- '.proportional-nums': { '--tw-numeric-spacing': 'proportional-nums' },
1725
- '.tabular-nums': { '--tw-numeric-spacing': 'tabular-nums' },
1726
- '.diagonal-fractions': { '--tw-numeric-fraction': 'diagonal-fractions' },
1727
- '.stacked-fractions': { '--tw-numeric-fraction': 'stacked-fractions' },
1561
+ '.ordinal': {
1562
+ '@defaults font-variant-numeric': {},
1563
+ '--tw-ordinal': 'ordinal',
1564
+ 'font-variant-numeric': 'var(--tw-font-variant-numeric)',
1565
+ },
1566
+ '.slashed-zero': {
1567
+ '@defaults font-variant-numeric': {},
1568
+ '--tw-slashed-zero': 'slashed-zero',
1569
+ 'font-variant-numeric': 'var(--tw-font-variant-numeric)',
1570
+ },
1571
+ '.lining-nums': {
1572
+ '@defaults font-variant-numeric': {},
1573
+ '--tw-numeric-figure': 'lining-nums',
1574
+ 'font-variant-numeric': 'var(--tw-font-variant-numeric)',
1575
+ },
1576
+ '.oldstyle-nums': {
1577
+ '@defaults font-variant-numeric': {},
1578
+ '--tw-numeric-figure': 'oldstyle-nums',
1579
+ 'font-variant-numeric': 'var(--tw-font-variant-numeric)',
1580
+ },
1581
+ '.proportional-nums': {
1582
+ '@defaults font-variant-numeric': {},
1583
+ '--tw-numeric-spacing': 'proportional-nums',
1584
+ 'font-variant-numeric': 'var(--tw-font-variant-numeric)',
1585
+ },
1586
+ '.tabular-nums': {
1587
+ '@defaults font-variant-numeric': {},
1588
+ '--tw-numeric-spacing': 'tabular-nums',
1589
+ 'font-variant-numeric': 'var(--tw-font-variant-numeric)',
1590
+ },
1591
+ '.diagonal-fractions': {
1592
+ '@defaults font-variant-numeric': {},
1593
+ '--tw-numeric-fraction': 'diagonal-fractions',
1594
+ 'font-variant-numeric': 'var(--tw-font-variant-numeric)',
1595
+ },
1596
+ '.stacked-fractions': {
1597
+ '@defaults font-variant-numeric': {},
1598
+ '--tw-numeric-fraction': 'stacked-fractions',
1599
+ 'font-variant-numeric': 'var(--tw-font-variant-numeric)',
1600
+ },
1728
1601
  })
1729
1602
  },
1730
1603
 
1731
1604
  lineHeight: createUtilityPlugin('lineHeight', [['leading', ['lineHeight']]]),
1732
- letterSpacing: createUtilityPlugin('letterSpacing', [['tracking', ['letterSpacing']]]),
1605
+ letterSpacing: createUtilityPlugin('letterSpacing', [['tracking', ['letterSpacing']]], {
1606
+ supportsNegativeValues: true,
1607
+ }),
1733
1608
 
1734
1609
  textColor: ({ matchUtilities, theme, corePlugins }) => {
1735
1610
  matchUtilities(
@@ -1760,6 +1635,17 @@ export let corePlugins = {
1760
1635
  })
1761
1636
  },
1762
1637
 
1638
+ textDecorationColor: ({ matchUtilities, theme }) => {
1639
+ matchUtilities(
1640
+ {
1641
+ decoration: (value) => {
1642
+ return { 'text-decoration-color': toColorValue(value) }
1643
+ },
1644
+ },
1645
+ { values: flattenColorPalette(theme('textDecorationColor')), type: ['color', 'any'] }
1646
+ )
1647
+ },
1648
+
1763
1649
  fontSmoothing: ({ addUtilities }) => {
1764
1650
  addUtilities({
1765
1651
  '.antialiased': {
@@ -1889,6 +1775,7 @@ export let corePlugins = {
1889
1775
  '--tw-ring-offset-shadow': '0 0 #0000',
1890
1776
  '--tw-ring-shadow': '0 0 #0000',
1891
1777
  '--tw-shadow': '0 0 #0000',
1778
+ '--tw-shadow-colored': '0 0 #0000',
1892
1779
  },
1893
1780
  })
1894
1781
 
@@ -1897,29 +1784,73 @@ export let corePlugins = {
1897
1784
  shadow: (value) => {
1898
1785
  value = transformValue(value)
1899
1786
 
1787
+ let ast = parseBoxShadowValue(value)
1788
+ for (let shadow of ast) {
1789
+ // Don't override color if the whole shadow is a variable
1790
+ if (!shadow.valid) {
1791
+ continue
1792
+ }
1793
+
1794
+ shadow.color = 'var(--tw-shadow-color)'
1795
+ }
1796
+
1900
1797
  return {
1901
1798
  '@defaults box-shadow': {},
1902
1799
  '--tw-shadow': value === 'none' ? '0 0 #0000' : value,
1800
+ '--tw-shadow-colored': value === 'none' ? '0 0 #0000' : formatBoxShadowValue(ast),
1903
1801
  'box-shadow': defaultBoxShadow,
1904
1802
  }
1905
1803
  },
1906
1804
  },
1907
- { values: theme('boxShadow') }
1805
+ { values: theme('boxShadow'), type: ['shadow'] }
1908
1806
  )
1909
1807
  }
1910
1808
  })(),
1911
1809
 
1912
- outline: ({ matchUtilities, theme }) => {
1810
+ boxShadowColor: ({ matchUtilities, theme }) => {
1913
1811
  matchUtilities(
1914
1812
  {
1915
- outline: (value) => {
1916
- value = Array.isArray(value) ? value : value.split(',')
1917
- let [outline, outlineOffset = '0'] = Array.isArray(value) ? value : [value]
1813
+ shadow: (value) => {
1814
+ return {
1815
+ '--tw-shadow-color': toColorValue(value),
1816
+ '--tw-shadow': 'var(--tw-shadow-colored)',
1817
+ }
1818
+ },
1819
+ },
1820
+ { values: flattenColorPalette(theme('boxShadowColor')), type: ['color'] }
1821
+ )
1822
+ },
1823
+
1824
+ outlineStyle: ({ addUtilities }) => {
1825
+ addUtilities({
1826
+ '.outline-none': {
1827
+ outline: '2px solid transparent',
1828
+ 'outline-offset': '2px',
1829
+ },
1830
+ '.outline': { 'outline-style': 'solid' },
1831
+ '.outline-dashed': { 'outline-style': 'dashed' },
1832
+ '.outline-dotted': { 'outline-style': 'dotted' },
1833
+ '.outline-double': { 'outline-style': 'double' },
1834
+ '.outline-hidden': { 'outline-style': 'hidden' },
1835
+ })
1836
+ },
1837
+
1838
+ outlineWidth: createUtilityPlugin('outlineWidth', [['outline', ['outline-width']]], {
1839
+ type: ['length', 'number', 'percentage'],
1840
+ }),
1918
1841
 
1919
- return { outline, 'outline-offset': outlineOffset }
1842
+ outlineOffset: createUtilityPlugin('outlineOffset', [['outline-offset', ['outline-offset']]], {
1843
+ type: ['length', 'number', 'percentage'],
1844
+ }),
1845
+
1846
+ outlineColor: ({ matchUtilities, theme }) => {
1847
+ matchUtilities(
1848
+ {
1849
+ outline: (value) => {
1850
+ return { 'outline-color': toColorValue(value) }
1920
1851
  },
1921
1852
  },
1922
- { values: theme('outline') }
1853
+ { values: flattenColorPalette(theme('outlineColor')), type: ['color'] }
1923
1854
  )
1924
1855
  },
1925
1856
 
@@ -1940,6 +1871,7 @@ export let corePlugins = {
1940
1871
  '--tw-ring-offset-shadow': '0 0 #0000',
1941
1872
  '--tw-ring-shadow': '0 0 #0000',
1942
1873
  '--tw-shadow': '0 0 #0000',
1874
+ '--tw-shadow-colored': '0 0 #0000',
1943
1875
  },
1944
1876
  })
1945
1877
 
@@ -2098,7 +2030,7 @@ export let corePlugins = {
2098
2030
  }
2099
2031
  },
2100
2032
  },
2101
- { values: theme('hueRotate') }
2033
+ { values: theme('hueRotate'), supportsNegativeValues: true }
2102
2034
  )
2103
2035
  },
2104
2036
 
@@ -2249,7 +2181,7 @@ export let corePlugins = {
2249
2181
  }
2250
2182
  },
2251
2183
  },
2252
- { values: theme('backdropHueRotate') }
2184
+ { values: theme('backdropHueRotate'), supportsNegativeValues: true }
2253
2185
  )
2254
2186
  },
2255
2187
 
@@ -2381,5 +2313,7 @@ export let corePlugins = {
2381
2313
  { filterDefault: true }
2382
2314
  ),
2383
2315
  willChange: createUtilityPlugin('willChange', [['will-change', ['will-change']]]),
2384
- content: createUtilityPlugin('content'),
2316
+ content: createUtilityPlugin('content', [
2317
+ ['content', ['--tw-content', ['content', 'var(--tw-content)']]],
2318
+ ]),
2385
2319
  }