tailwindcss 0.0.0-insiders.bd970d0 → 0.0.0-insiders.bda8421

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 (137) hide show
  1. package/README.md +1 -2
  2. package/lib/cli/build/deps.js +62 -0
  3. package/lib/cli/build/index.js +12 -15
  4. package/lib/cli/build/plugin.js +107 -167
  5. package/lib/cli/build/utils.js +13 -13
  6. package/lib/cli/build/watching.js +10 -10
  7. package/lib/cli/help/index.js +11 -11
  8. package/lib/cli/index.js +60 -61
  9. package/lib/cli/init/index.js +16 -16
  10. package/lib/cli-peer-dependencies.js +36 -0
  11. package/lib/cli.js +1 -1
  12. package/lib/corePluginList.js +4 -1
  13. package/lib/corePlugins.js +2018 -1905
  14. package/lib/css/preflight.css +18 -12
  15. package/lib/featureFlags.js +17 -23
  16. package/lib/index.js +1 -1
  17. package/lib/lib/cacheInvalidation.js +3 -3
  18. package/lib/lib/collapseAdjacentRules.js +6 -6
  19. package/lib/lib/collapseDuplicateDeclarations.js +1 -1
  20. package/lib/lib/content.js +39 -32
  21. package/lib/lib/defaultExtractor.js +40 -17
  22. package/lib/lib/evaluateTailwindFunctions.js +23 -23
  23. package/lib/lib/expandApplyAtRules.js +37 -18
  24. package/lib/lib/expandTailwindAtRules.js +49 -85
  25. package/lib/lib/findAtConfigPath.js +5 -5
  26. package/lib/lib/generateRules.js +82 -55
  27. package/lib/lib/getModuleDependencies.js +23 -23
  28. package/lib/lib/load-config.js +21 -6
  29. package/lib/lib/normalizeTailwindDirectives.js +36 -21
  30. package/lib/lib/offsets.js +97 -48
  31. package/lib/lib/partitionApplyAtRules.js +2 -2
  32. package/lib/lib/regex.js +5 -5
  33. package/lib/lib/resolveDefaultsAtRules.js +27 -25
  34. package/lib/lib/setupContextUtils.js +195 -167
  35. package/lib/lib/setupTrackingContext.js +4 -5
  36. package/lib/lib/sharedState.js +10 -10
  37. package/lib/lib/substituteScreenAtRules.js +4 -4
  38. package/lib/plugin.js +8 -124
  39. package/lib/postcss-plugins/nesting/index.js +2 -2
  40. package/lib/postcss-plugins/nesting/plugin.js +11 -11
  41. package/lib/processTailwindFeatures.js +3 -5
  42. package/lib/public/colors.js +264 -264
  43. package/lib/util/applyImportantSelector.js +2 -2
  44. package/lib/util/buildMediaQuery.js +2 -2
  45. package/lib/util/cloneDeep.js +1 -1
  46. package/lib/util/cloneNodes.js +33 -13
  47. package/lib/util/color.js +19 -19
  48. package/lib/util/createUtilityPlugin.js +3 -3
  49. package/lib/util/dataTypes.js +170 -113
  50. package/lib/util/defaults.js +4 -4
  51. package/lib/util/escapeClassName.js +2 -2
  52. package/lib/util/escapeCommas.js +1 -1
  53. package/lib/util/flattenColorPalette.js +2 -2
  54. package/lib/util/formatVariantSelector.js +24 -19
  55. package/lib/util/getAllConfigs.js +4 -5
  56. package/lib/util/isKeyframeRule.js +1 -1
  57. package/lib/util/isPlainObject.js +2 -2
  58. package/lib/util/isSyntacticallyValidPropertyValue.js +10 -10
  59. package/lib/util/log.js +6 -23
  60. package/lib/util/nameClass.js +4 -4
  61. package/lib/util/negateValue.js +8 -8
  62. package/lib/util/normalizeConfig.js +63 -94
  63. package/lib/util/normalizeScreens.js +18 -18
  64. package/lib/util/parseAnimationValue.js +38 -38
  65. package/lib/util/parseBoxShadowValue.js +18 -18
  66. package/lib/util/parseDependency.js +4 -4
  67. package/lib/util/parseGlob.js +4 -4
  68. package/lib/util/parseObjectStyles.js +1 -1
  69. package/lib/util/pluginUtils.js +36 -21
  70. package/lib/util/prefixSelector.js +4 -4
  71. package/lib/util/pseudoElements.js +72 -69
  72. package/lib/util/removeAlphaVariables.js +1 -1
  73. package/lib/util/resolveConfig.js +11 -15
  74. package/lib/util/resolveConfigPath.js +6 -6
  75. package/lib/util/responsive.js +1 -1
  76. package/lib/util/splitAtTopLevelOnly.js +3 -3
  77. package/lib/util/toColorValue.js +1 -1
  78. package/lib/util/toPath.js +2 -2
  79. package/lib/util/transformThemeValue.js +24 -24
  80. package/lib/util/validateConfig.js +9 -20
  81. package/lib/util/validateFormalSyntax.js +5 -5
  82. package/lib/util/withAlphaVariable.js +5 -5
  83. package/lib/value-parser/index.js +5 -5
  84. package/lib/value-parser/parse.js +43 -43
  85. package/lib/value-parser/stringify.js +11 -11
  86. package/lib/value-parser/unit.js +5 -5
  87. package/lib/value-parser/walk.js +1 -1
  88. package/nesting/index.d.ts +4 -0
  89. package/package.json +41 -36
  90. package/peers/index.js +96503 -0
  91. package/resolveConfig.d.ts +22 -3
  92. package/scripts/generate-types.js +1 -2
  93. package/scripts/release-notes.js +1 -1
  94. package/src/cli/build/deps.js +56 -0
  95. package/src/cli/build/index.js +0 -4
  96. package/src/cli/build/plugin.js +53 -85
  97. package/src/cli/build/watching.js +1 -1
  98. package/src/cli/index.js +0 -1
  99. package/src/cli-peer-dependencies.js +15 -0
  100. package/src/corePluginList.js +1 -1
  101. package/src/corePlugins.js +118 -31
  102. package/src/css/preflight.css +18 -12
  103. package/src/featureFlags.js +3 -5
  104. package/src/lib/content.js +39 -30
  105. package/src/lib/defaultExtractor.js +29 -6
  106. package/src/lib/expandApplyAtRules.js +24 -0
  107. package/src/lib/expandTailwindAtRules.js +19 -56
  108. package/src/lib/generateRules.js +39 -8
  109. package/src/lib/load-config.ts +13 -0
  110. package/src/lib/normalizeTailwindDirectives.js +27 -0
  111. package/src/lib/offsets.js +62 -3
  112. package/src/lib/resolveDefaultsAtRules.js +5 -1
  113. package/src/lib/setupContextUtils.js +79 -39
  114. package/src/plugin.js +0 -86
  115. package/src/processTailwindFeatures.js +0 -3
  116. package/src/util/cloneNodes.js +35 -14
  117. package/src/util/dataTypes.js +72 -6
  118. package/src/util/formatVariantSelector.js +7 -0
  119. package/src/util/isPlainObject.js +1 -1
  120. package/src/util/log.js +0 -24
  121. package/src/util/normalizeConfig.js +11 -38
  122. package/src/util/pluginUtils.js +20 -0
  123. package/src/util/pseudoElements.js +4 -0
  124. package/src/util/validateConfig.js +0 -10
  125. package/stubs/config.full.js +68 -8
  126. package/stubs/config.simple.js +1 -1
  127. package/stubs/postcss.config.cjs +1 -0
  128. package/stubs/postcss.config.js +1 -0
  129. package/types/config.d.ts +12 -5
  130. package/types/generated/corePluginList.d.ts +1 -1
  131. package/types/generated/default-theme.d.ts +28 -9
  132. package/types/index.d.ts +7 -3
  133. package/index.css +0 -5
  134. package/lib/lib/detectNesting.js +0 -45
  135. package/lib/lib/handleImportAtRules.js +0 -50
  136. package/src/lib/detectNesting.js +0 -47
  137. package/src/lib/handleImportAtRules.js +0 -34
@@ -10,6 +10,7 @@ import withAlphaVariable, { withAlphaValue } from './util/withAlphaVariable'
10
10
  import toColorValue from './util/toColorValue'
11
11
  import isPlainObject from './util/isPlainObject'
12
12
  import transformThemeValue from './util/transformThemeValue'
13
+ import { version as tailwindVersion } from '../package.json'
13
14
  import log from './util/log'
14
15
  import {
15
16
  normalizeScreens,
@@ -24,6 +25,9 @@ import { normalize } from './util/dataTypes'
24
25
  import { INTERNAL_FEATURES } from './lib/setupContextUtils'
25
26
 
26
27
  export let variantPlugins = {
28
+ childVariant: ({ addVariant }) => {
29
+ addVariant('*', '& > *')
30
+ },
27
31
  pseudoElementVariants: ({ addVariant }) => {
28
32
  addVariant('first-letter', '&::first-letter')
29
33
  addVariant('first-line', '&::first-line')
@@ -203,8 +207,8 @@ export let variantPlugins = {
203
207
  },
204
208
 
205
209
  directionVariants: ({ addVariant }) => {
206
- addVariant('ltr', ':is([dir="ltr"] &)')
207
- addVariant('rtl', ':is([dir="rtl"] &)')
210
+ addVariant('ltr', '&:where([dir="ltr"], [dir="ltr"] *)')
211
+ addVariant('rtl', '&:where([dir="rtl"], [dir="rtl"] *)')
208
212
  },
209
213
 
210
214
  reducedMotionVariants: ({ addVariant }) => {
@@ -213,7 +217,7 @@ export let variantPlugins = {
213
217
  },
214
218
 
215
219
  darkVariants: ({ config, addVariant }) => {
216
- let [mode, className = '.dark'] = [].concat(config('darkMode', 'media'))
220
+ let [mode, selector = '.dark'] = [].concat(config('darkMode', 'media'))
217
221
 
218
222
  if (mode === false) {
219
223
  mode = 'media'
@@ -224,10 +228,49 @@ export let variantPlugins = {
224
228
  ])
225
229
  }
226
230
 
227
- if (mode === 'class') {
228
- addVariant('dark', `:is(${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} *)`)
229
267
  } else if (mode === 'media') {
230
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} &)`)
231
274
  }
232
275
  },
233
276
 
@@ -369,7 +412,7 @@ export let variantPlugins = {
369
412
  let check = normalize(value)
370
413
  let isRaw = /^\w*\s*\(/.test(check)
371
414
 
372
- // Chrome has a bug where `(condition1)or(condition2)` is not valid
415
+ // Chrome has a bug where `(condtion1)or(condition2)` is not valid
373
416
  // But `(condition1) or (condition2)` is supported.
374
417
  check = isRaw ? check.replace(/\b(and|or|not)\b/g, ' $1 ') : check
375
418
 
@@ -460,6 +503,10 @@ export let variantPlugins = {
460
503
  addVariant('contrast-more', '@media (prefers-contrast: more)')
461
504
  addVariant('contrast-less', '@media (prefers-contrast: less)')
462
505
  },
506
+
507
+ forcedColorsVariants: ({ addVariant }) => {
508
+ addVariant('forced-colors', '@media (forced-colors: active)')
509
+ },
463
510
  }
464
511
 
465
512
  let cssTransformValue = [
@@ -501,7 +548,12 @@ export let corePlugins = {
501
548
  fs.readFileSync(path.join(__dirname, './css/preflight.css'), 'utf8')
502
549
  )
503
550
 
504
- addBase(preflightStyles.nodes)
551
+ addBase([
552
+ postcss.comment({
553
+ text: `! tailwindcss v${tailwindVersion} | MIT License | https://tailwindcss.com`,
554
+ }),
555
+ ...preflightStyles.nodes,
556
+ ])
505
557
  },
506
558
 
507
559
  container: (() => {
@@ -680,6 +732,8 @@ export let corePlugins = {
680
732
 
681
733
  float: ({ addUtilities }) => {
682
734
  addUtilities({
735
+ '.float-start': { float: 'inline-start' },
736
+ '.float-end': { float: 'inline-end' },
683
737
  '.float-right': { float: 'right' },
684
738
  '.float-left': { float: 'left' },
685
739
  '.float-none': { float: 'none' },
@@ -688,6 +742,8 @@ export let corePlugins = {
688
742
 
689
743
  clear: ({ addUtilities }) => {
690
744
  addUtilities({
745
+ '.clear-start': { clear: 'inline-start' },
746
+ '.clear-end': { clear: 'inline-end' },
691
747
  '.clear-left': { clear: 'left' },
692
748
  '.clear-right': { clear: 'right' },
693
749
  '.clear-both': { clear: 'both' },
@@ -773,6 +829,8 @@ export let corePlugins = {
773
829
 
774
830
  aspectRatio: createUtilityPlugin('aspectRatio', [['aspect', ['aspect-ratio']]]),
775
831
 
832
+ size: createUtilityPlugin('size', [['size', ['width', 'height']]]),
833
+
776
834
  height: createUtilityPlugin('height', [['h', ['height']]]),
777
835
  maxHeight: createUtilityPlugin('maxHeight', [['max-h', ['maxHeight']]]),
778
836
  minHeight: createUtilityPlugin('minHeight', [['min-h', ['minHeight']]]),
@@ -1123,6 +1181,7 @@ export let corePlugins = {
1123
1181
  appearance: ({ addUtilities }) => {
1124
1182
  addUtilities({
1125
1183
  '.appearance-none': { appearance: 'none' },
1184
+ '.appearance-auto': { appearance: 'auto' },
1126
1185
  })
1127
1186
  },
1128
1187
 
@@ -1275,22 +1334,12 @@ export let corePlugins = {
1275
1334
  ],
1276
1335
  ]),
1277
1336
 
1278
- space: ({ matchUtilities, addUtilities, theme, config }) => {
1337
+ space: ({ matchUtilities, addUtilities, theme }) => {
1279
1338
  matchUtilities(
1280
1339
  {
1281
1340
  'space-x': (value) => {
1282
1341
  value = value === '0' ? '0px' : value
1283
1342
 
1284
- if (flagEnabled(config(), 'logicalSiblingUtilities')) {
1285
- return {
1286
- '& > :not([hidden]) ~ :not([hidden])': {
1287
- '--tw-space-x-reverse': '0',
1288
- 'margin-inline-end': `calc(${value} * var(--tw-space-x-reverse))`,
1289
- 'margin-inline-start': `calc(${value} * calc(1 - var(--tw-space-x-reverse)))`,
1290
- },
1291
- }
1292
- }
1293
-
1294
1343
  return {
1295
1344
  '& > :not([hidden]) ~ :not([hidden])': {
1296
1345
  '--tw-space-x-reverse': '0',
@@ -1320,23 +1369,12 @@ export let corePlugins = {
1320
1369
  })
1321
1370
  },
1322
1371
 
1323
- divideWidth: ({ matchUtilities, addUtilities, theme, config }) => {
1372
+ divideWidth: ({ matchUtilities, addUtilities, theme }) => {
1324
1373
  matchUtilities(
1325
1374
  {
1326
1375
  'divide-x': (value) => {
1327
1376
  value = value === '0' ? '0px' : value
1328
1377
 
1329
- if (flagEnabled(config(), 'logicalSiblingUtilities')) {
1330
- return {
1331
- '& > :not([hidden]) ~ :not([hidden])': {
1332
- '@defaults border-width': {},
1333
- '--tw-divide-x-reverse': '0',
1334
- 'border-inline-end-width': `calc(${value} * var(--tw-divide-x-reverse))`,
1335
- 'border-inline-start-width': `calc(${value} * calc(1 - var(--tw-divide-x-reverse)))`,
1336
- },
1337
- }
1338
- }
1339
-
1340
1378
  return {
1341
1379
  '& > :not([hidden]) ~ :not([hidden])': {
1342
1380
  '@defaults border-width': {},
@@ -2325,6 +2363,7 @@ export let corePlugins = {
2325
2363
  '.mix-blend-saturation': { 'mix-blend-mode': 'saturation' },
2326
2364
  '.mix-blend-color': { 'mix-blend-mode': 'color' },
2327
2365
  '.mix-blend-luminosity': { 'mix-blend-mode': 'luminosity' },
2366
+ '.mix-blend-plus-darker': { 'mix-blend-mode': 'plus-darker' },
2328
2367
  '.mix-blend-plus-lighter': { 'mix-blend-mode': 'plus-lighter' },
2329
2368
  })
2330
2369
  },
@@ -2338,7 +2377,7 @@ export let corePlugins = {
2338
2377
  ].join(', ')
2339
2378
 
2340
2379
  return function ({ matchUtilities, addDefaults, theme }) {
2341
- addDefaults(' box-shadow', {
2380
+ addDefaults('box-shadow', {
2342
2381
  '--tw-ring-offset-shadow': '0 0 #0000',
2343
2382
  '--tw-ring-shadow': '0 0 #0000',
2344
2383
  '--tw-shadow': '0 0 #0000',
@@ -2872,7 +2911,55 @@ export let corePlugins = {
2872
2911
  { filterDefault: true }
2873
2912
  ),
2874
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
+ },
2875
2956
  content: createUtilityPlugin('content', [
2876
2957
  ['content', ['--tw-content', ['content', 'var(--tw-content)']]],
2877
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
+ },
2878
2965
  }
@@ -24,6 +24,7 @@
24
24
  4. Use the user's configured `sans` font-family by default.
25
25
  5. Use the user's configured `sans` font-feature-settings by default.
26
26
  6. Use the user's configured `sans` font-variation-settings by default.
27
+ 7. Disable tap highlights on iOS
27
28
  */
28
29
 
29
30
  html,
@@ -35,6 +36,7 @@ html,
35
36
  font-family: theme('fontFamily.sans', ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"); /* 4 */
36
37
  font-feature-settings: theme('fontFamily.sans[1].fontFeatureSettings', normal); /* 5 */
37
38
  font-variation-settings: theme('fontFamily.sans[1].fontVariationSettings', normal); /* 6 */
39
+ -webkit-tap-highlight-color: transparent; /* 7 */
38
40
  }
39
41
 
40
42
  /*
@@ -100,8 +102,10 @@ strong {
100
102
  }
101
103
 
102
104
  /*
103
- 1. Use the user's configured `mono` font family by default.
104
- 2. Correct the odd `em` font sizing in all browsers.
105
+ 1. Use the user's configured `mono` font-family by default.
106
+ 2. Use the user's configured `mono` font-feature-settings by default.
107
+ 3. Use the user's configured `mono` font-variation-settings by default.
108
+ 4. Correct the odd `em` font sizing in all browsers.
105
109
  */
106
110
 
107
111
  code,
@@ -109,7 +113,9 @@ kbd,
109
113
  samp,
110
114
  pre {
111
115
  font-family: theme('fontFamily.mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace); /* 1 */
112
- font-size: 1em; /* 2 */
116
+ font-feature-settings: theme('fontFamily.mono[1].fontFeatureSettings', normal); /* 2 */
117
+ font-variation-settings: theme('fontFamily.mono[1].fontVariationSettings', normal); /* 3 */
118
+ font-size: 1em; /* 4 */
113
119
  }
114
120
 
115
121
  /*
@@ -169,6 +175,7 @@ textarea {
169
175
  font-size: 100%; /* 1 */
170
176
  font-weight: inherit; /* 1 */
171
177
  line-height: inherit; /* 1 */
178
+ letter-spacing: inherit; /* 1 */
172
179
  color: inherit; /* 1 */
173
180
  margin: 0; /* 2 */
174
181
  padding: 0; /* 3 */
@@ -189,9 +196,9 @@ select {
189
196
  */
190
197
 
191
198
  button,
192
- [type='button'],
193
- [type='reset'],
194
- [type='submit'] {
199
+ input:where([type='button']),
200
+ input:where([type='reset']),
201
+ input:where([type='submit']) {
195
202
  -webkit-appearance: button; /* 1 */
196
203
  background-color: transparent; /* 2 */
197
204
  background-image: none; /* 2 */
@@ -267,7 +274,7 @@ summary {
267
274
  }
268
275
 
269
276
  /*
270
- Removes the default spacing for appropriate elements.
277
+ Removes the default spacing and border for appropriate elements.
271
278
  */
272
279
 
273
280
  blockquote,
@@ -303,6 +310,9 @@ menu {
303
310
  padding: 0;
304
311
  }
305
312
 
313
+ /*
314
+ Reset default styling for dialogs.
315
+ */
306
316
  dialog {
307
317
  padding: 0;
308
318
  }
@@ -338,7 +348,6 @@ button,
338
348
  /*
339
349
  Make sure disabled buttons don't get the pointer cursor.
340
350
  */
341
-
342
351
  :disabled {
343
352
  cursor: default;
344
353
  }
@@ -371,10 +380,7 @@ video {
371
380
  height: auto;
372
381
  }
373
382
 
374
- /*
375
- Make elements with the HTML hidden attribute stay hidden by default.
376
- */
377
-
383
+ /* Make elements with the HTML hidden attribute stay hidden by default */
378
384
  [hidden] {
379
385
  display: none;
380
386
  }
@@ -3,21 +3,19 @@ import log from './util/log'
3
3
 
4
4
  let defaults = {
5
5
  optimizeUniversalDefaults: false,
6
+ generalizedModifiers: true,
6
7
  disableColorOpacityUtilitiesByDefault: false,
7
8
  relativeContentPathsByDefault: false,
8
- oxideParser: true,
9
- logicalSiblingUtilities: false,
10
9
  }
11
10
 
12
- export let featureFlags = {
11
+ let featureFlags = {
13
12
  future: [
14
13
  'hoverOnlyWhenSupported',
15
14
  'respectDefaultRingColorOpacity',
16
15
  'disableColorOpacityUtilitiesByDefault',
17
16
  'relativeContentPathsByDefault',
18
- 'logicalSiblingUtilities',
19
17
  ],
20
- experimental: ['optimizeUniversalDefaults', 'oxideParser'],
18
+ experimental: ['optimizeUniversalDefaults', 'generalizedModifiers'],
21
19
  }
22
20
 
23
21
  export function flagEnabled(config, flag) {
@@ -4,43 +4,50 @@ import fs from 'fs'
4
4
  import path from 'path'
5
5
  import isGlob from 'is-glob'
6
6
  import fastGlob from 'fast-glob'
7
- import normalizePath from 'normalize-path'
8
7
  import { parseGlob } from '../util/parseGlob'
9
8
  import { env } from './sharedState'
10
- import { resolveContentPaths } from '@tailwindcss/oxide'
11
9
 
12
- /** @typedef {import('../../types/config.js').RawFile} RawFile */
13
- /** @typedef {import('../../types/config.js').FilePath} FilePath */
14
-
15
- /*
16
- * @param {import('tailwindcss').Config} tailwindConfig
17
- * @param {{skip:string[]}} options
18
- * @returns {ContentPath[]}
10
+ /*!
11
+ * Modified version of normalize-path, original license below
12
+ *
13
+ * normalize-path <https://github.com/jonschlinkert/normalize-path>
14
+ *
15
+ * Copyright (c) 2014-2018, Jon Schlinkert.
16
+ * Released under the MIT License.
19
17
  */
20
- function resolveContentFiles(tailwindConfig, { skip = [] } = {}) {
21
- if (
22
- Array.isArray(tailwindConfig.content.files) &&
23
- tailwindConfig.content.files.includes('auto')
24
- ) {
25
- let idx = tailwindConfig.content.files.indexOf('auto')
26
- if (idx !== -1) {
27
- env.DEBUG && console.time('Calculating resolve content paths')
28
- let resolved = resolveContentPaths({ base: process.cwd() })
29
- env.DEBUG && console.timeEnd('Calculating resolve content paths')
30
-
31
- tailwindConfig.content.files.splice(idx, 1, ...resolved)
32
- }
18
+
19
+ function normalizePath(path) {
20
+ if (typeof path !== 'string') {
21
+ throw new TypeError('expected path to be a string')
33
22
  }
34
23
 
35
- if (skip.length > 0) {
36
- tailwindConfig.content.files = tailwindConfig.content.files.filter(
37
- (filePath) => !skip.includes(filePath)
38
- )
24
+ if (path === '\\' || path === '/') return '/'
25
+
26
+ var len = path.length
27
+ if (len <= 1) return path
28
+
29
+ // ensure that win32 namespaces has two leading slashes, so that the path is
30
+ // handled properly by the win32 version of path.parse() after being normalized
31
+ // https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces
32
+ var prefix = ''
33
+ if (len > 4 && path[3] === '\\') {
34
+ var ch = path[2]
35
+ if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\') {
36
+ path = path.slice(2)
37
+ prefix = '//'
38
+ }
39
39
  }
40
40
 
41
- return tailwindConfig.content.files
41
+ // Modified part: instead of purely splitting on `\\` and `/`, we split on
42
+ // `/` and `\\` that is _not_ followed by any of the following characters: ()[]
43
+ // This is to ensure that we keep the escaping of brackets and parentheses
44
+ let segs = path.split(/[/\\]+(?![\(\)\[\]])/)
45
+ return prefix + segs.join('/')
42
46
  }
43
47
 
48
+ /** @typedef {import('../../types/config.js').RawFile} RawFile */
49
+ /** @typedef {import('../../types/config.js').FilePath} FilePath */
50
+
44
51
  /**
45
52
  * @typedef {object} ContentPath
46
53
  * @property {string} original
@@ -62,9 +69,7 @@ function resolveContentFiles(tailwindConfig, { skip = [] } = {}) {
62
69
  * @returns {ContentPath[]}
63
70
  */
64
71
  export function parseCandidateFiles(context, tailwindConfig) {
65
- let files = resolveContentFiles(tailwindConfig, {
66
- skip: [context.userConfigPath],
67
- })
72
+ let files = tailwindConfig.content.files
68
73
 
69
74
  // Normalize the file globs
70
75
  files = files.filter((filePath) => typeof filePath === 'string')
@@ -105,6 +110,10 @@ export function parseCandidateFiles(context, tailwindConfig) {
105
110
  * @returns {ContentPath}
106
111
  */
107
112
  function parseFilePath(filePath, ignore) {
113
+ // Escape special characters in the file path such as: ()[]
114
+ // But only if the special character isn't already escaped
115
+ filePath = filePath.replace(/(?<!\\)([\[\]\(\)])/g, '\\$1')
116
+
108
117
  let contentPath = {
109
118
  original: filePath,
110
119
  base: filePath,
@@ -11,10 +11,12 @@ export function defaultExtractor(context) {
11
11
  let results = []
12
12
 
13
13
  for (let pattern of patterns) {
14
- results = [...results, ...(content.match(pattern) ?? [])]
14
+ for (let result of content.match(pattern) ?? []) {
15
+ results.push(clipAtBalancedParens(result))
16
+ }
15
17
  }
16
18
 
17
- return results.filter((v) => v !== undefined).map(clipAtBalancedParens)
19
+ return results
18
20
  }
19
21
  }
20
22
 
@@ -33,19 +35,29 @@ function* buildRegExps(context) {
33
35
  // This is a targeted fix to continue to allow theme()
34
36
  // with square brackets to work in arbitrary properties
35
37
  // while fixing a problem with the regex matching too much
36
- /\[[^\s:'"`]+:[^\s]+?\[[^\s]+\][^\s]+?\]/,
38
+ /\[[^\s:'"`\]]+:[^\s]+?\[[^\s]+\][^\s]+?\]/,
37
39
 
38
40
  // Utilities
39
41
  regex.pattern([
40
42
  // Utility Name / Group Name
41
- /-?(?:\w+)/,
43
+ regex.any([
44
+ /-?(?:\w+)/,
45
+
46
+ // This is here to make sure @container supports everything that other utilities do
47
+ /@(?:\w+)/,
48
+ ]),
42
49
 
43
50
  // Normal/Arbitrary values
44
51
  regex.optional(
45
52
  regex.any([
46
53
  regex.pattern([
47
54
  // Arbitrary values
48
- /-(?:\w+-)*\[[^\s:]+\]/,
55
+ regex.any([
56
+ /-(?:\w+-)*\['[^\s]+'\]/,
57
+ /-(?:\w+-)*\["[^\s]+"\]/,
58
+ /-(?:\w+-)*\[`[^\s]+`\]/,
59
+ /-(?:\w+-)*\[(?:[^\s\[\]]+\[[^\s\[\]]+\])*[^\s:\[\]]+\]/,
60
+ ]),
49
61
 
50
62
  // Not immediately followed by an `{[(`
51
63
  /(?![{([]])/,
@@ -56,7 +68,12 @@ function* buildRegExps(context) {
56
68
 
57
69
  regex.pattern([
58
70
  // Arbitrary values
59
- /-(?:\w+-)*\[[^\s]+\]/,
71
+ regex.any([
72
+ /-(?:\w+-)*\['[^\s]+'\]/,
73
+ /-(?:\w+-)*\["[^\s]+"\]/,
74
+ /-(?:\w+-)*\[`[^\s]+`\]/,
75
+ /-(?:\w+-)*\[(?:[^\s\[\]]+\[[^\s\[\]]+\])*[^\s\[\]]+\]/,
76
+ ]),
60
77
 
61
78
  // Not immediately followed by an `{[(`
62
79
  /(?![{([]])/,
@@ -78,12 +95,18 @@ function* buildRegExps(context) {
78
95
  // This is here to provide special support for the `@` variant
79
96
  regex.pattern([/@\[[^\s"'`]+\](\/[^\s"'`]+)?/, separator]),
80
97
 
98
+ // With variant modifier (e.g.: group-[..]/modifier)
99
+ regex.pattern([/([^\s"'`\[\\]+-)?\[[^\s"'`]+\]\/[\w_-]+/, separator]),
100
+
81
101
  regex.pattern([/([^\s"'`\[\\]+-)?\[[^\s"'`]+\]/, separator]),
82
102
  regex.pattern([/[^\s"'`\[\\]+/, separator]),
83
103
  ]),
84
104
 
85
105
  // With quotes allowed
86
106
  regex.any([
107
+ // With variant modifier (e.g.: group-[..]/modifier)
108
+ regex.pattern([/([^\s"'`\[\\]+-)?\[[^\s`]+\]\/[\w_-]+/, separator]),
109
+
87
110
  regex.pattern([/([^\s"'`\[\\]+-)?\[[^\s`]+\]/, separator]),
88
111
  regex.pattern([/[^\s`\[\\]+/, separator]),
89
112
  ]),
@@ -432,6 +432,23 @@ function processApply(root, context, localCache) {
432
432
 
433
433
  let rules = applyClassCache.get(applyCandidate)
434
434
 
435
+ // Verify that we can apply the class
436
+ for (let [, rule] of rules) {
437
+ if (rule.type === 'atrule') {
438
+ continue
439
+ }
440
+
441
+ rule.walkRules(() => {
442
+ throw apply.error(
443
+ [
444
+ `The \`${applyCandidate}\` class cannot be used with \`@apply\` because \`@apply\` does not currently support nested CSS.`,
445
+ 'Rewrite the selector without nesting or configure the `tailwindcss/nesting` plugin:',
446
+ 'https://tailwindcss.com/docs/using-with-preprocessors#nesting',
447
+ ].join('\n')
448
+ )
449
+ })
450
+ }
451
+
435
452
  candidates.push([applyCandidate, important, rules])
436
453
  }
437
454
  }
@@ -553,6 +570,13 @@ function processApply(root, context, localCache) {
553
570
  ? parent.selector.slice(importantSelector.length)
554
571
  : parent.selector
555
572
 
573
+ // If the selector becomes empty after replacing the important selector
574
+ // This means that it's the same as the parent selector and we don't want to replace it
575
+ // Otherwise we'll crash
576
+ if (parentSelector === '') {
577
+ parentSelector = parent.selector
578
+ }
579
+
556
580
  rule.selector = replaceSelector(parentSelector, rule.selector, applyCandidate)
557
581
 
558
582
  // And then re-add it if it was removed