tailwindcss 0.0.0-insiders.8259dfd → 0.0.0-insiders.8293c2d

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 (93) hide show
  1. package/CHANGELOG.md +207 -2
  2. package/README.md +8 -4
  3. package/colors.js +2 -1
  4. package/defaultConfig.js +2 -1
  5. package/defaultTheme.js +2 -1
  6. package/lib/cli.js +94 -61
  7. package/lib/constants.js +1 -1
  8. package/lib/corePluginList.js +8 -1
  9. package/lib/corePlugins.js +477 -517
  10. package/lib/css/preflight.css +18 -5
  11. package/lib/featureFlags.js +5 -6
  12. package/lib/index.js +1 -3
  13. package/lib/lib/collapseDuplicateDeclarations.js +80 -0
  14. package/lib/lib/defaultExtractor.js +42 -0
  15. package/lib/lib/detectNesting.js +17 -2
  16. package/lib/lib/evaluateTailwindFunctions.js +10 -6
  17. package/lib/lib/expandApplyAtRules.js +94 -45
  18. package/lib/lib/expandTailwindAtRules.js +32 -33
  19. package/lib/lib/generateRules.js +167 -21
  20. package/lib/lib/normalizeTailwindDirectives.js +8 -1
  21. package/lib/lib/partitionApplyAtRules.js +53 -0
  22. package/lib/lib/resolveDefaultsAtRules.js +28 -14
  23. package/lib/lib/setupContextUtils.js +153 -129
  24. package/lib/lib/setupTrackingContext.js +11 -10
  25. package/lib/lib/sharedState.js +34 -5
  26. package/lib/lib/substituteScreenAtRules.js +7 -4
  27. package/lib/processTailwindFeatures.js +7 -2
  28. package/lib/util/buildMediaQuery.js +13 -24
  29. package/lib/util/color.js +23 -8
  30. package/lib/util/createPlugin.js +1 -2
  31. package/lib/util/createUtilityPlugin.js +6 -10
  32. package/lib/util/dataTypes.js +38 -7
  33. package/lib/util/defaults.js +6 -0
  34. package/lib/util/flattenColorPalette.js +1 -3
  35. package/lib/util/formatVariantSelector.js +186 -0
  36. package/lib/util/isValidArbitraryValue.js +64 -0
  37. package/lib/util/log.js +4 -0
  38. package/lib/util/nameClass.js +1 -0
  39. package/lib/util/normalizeConfig.js +63 -21
  40. package/lib/util/normalizeScreens.js +59 -0
  41. package/lib/util/parseBoxShadowValue.js +77 -0
  42. package/lib/util/pluginUtils.js +27 -158
  43. package/lib/util/prefixSelector.js +1 -3
  44. package/lib/util/resolveConfig.js +30 -31
  45. package/lib/util/resolveConfigPath.js +1 -2
  46. package/lib/util/toColorValue.js +1 -2
  47. package/lib/util/toPath.js +6 -1
  48. package/lib/util/transformThemeValue.js +19 -13
  49. package/nesting/plugin.js +4 -1
  50. package/package.json +19 -21
  51. package/peers/index.js +4621 -5626
  52. package/plugin.js +2 -1
  53. package/resolveConfig.js +2 -1
  54. package/src/cli.js +66 -14
  55. package/src/corePluginList.js +1 -1
  56. package/src/corePlugins.js +406 -518
  57. package/src/css/preflight.css +18 -5
  58. package/src/featureFlags.js +1 -1
  59. package/src/index.js +1 -7
  60. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  61. package/src/lib/defaultExtractor.js +48 -0
  62. package/src/lib/detectNesting.js +22 -3
  63. package/src/lib/evaluateTailwindFunctions.js +6 -3
  64. package/src/lib/expandApplyAtRules.js +101 -45
  65. package/src/lib/expandTailwindAtRules.js +33 -27
  66. package/src/lib/generateRules.js +178 -11
  67. package/src/lib/normalizeTailwindDirectives.js +6 -1
  68. package/src/lib/partitionApplyAtRules.js +52 -0
  69. package/src/lib/resolveDefaultsAtRules.js +31 -10
  70. package/src/lib/setupContextUtils.js +140 -84
  71. package/src/lib/setupTrackingContext.js +11 -10
  72. package/src/lib/sharedState.js +40 -4
  73. package/src/lib/substituteScreenAtRules.js +6 -3
  74. package/src/processTailwindFeatures.js +8 -2
  75. package/src/util/buildMediaQuery.js +14 -18
  76. package/src/util/color.js +20 -7
  77. package/src/util/dataTypes.js +43 -11
  78. package/src/util/defaults.js +6 -0
  79. package/src/util/formatVariantSelector.js +196 -0
  80. package/src/util/isValidArbitraryValue.js +61 -0
  81. package/src/util/log.js +4 -0
  82. package/src/util/nameClass.js +1 -1
  83. package/src/util/normalizeConfig.js +37 -2
  84. package/src/util/normalizeScreens.js +45 -0
  85. package/src/util/parseBoxShadowValue.js +71 -0
  86. package/src/util/pluginUtils.js +15 -138
  87. package/src/util/prefixSelector.js +1 -4
  88. package/src/util/resolveConfig.js +11 -1
  89. package/src/util/toPath.js +23 -1
  90. package/src/util/transformThemeValue.js +22 -7
  91. package/stubs/defaultConfig.stub.js +42 -16
  92. package/lib/lib/setupWatchingContext.js +0 -284
  93. package/src/lib/setupWatchingContext.js +0 -304
@@ -1,7 +1,6 @@
1
1
  import selectorParser from 'postcss-selector-parser'
2
2
  import escapeCommas from './escapeCommas'
3
3
  import { withAlphaValue } from './withAlphaVariable'
4
- import isKeyframeRule from './isKeyframeRule'
5
4
  import {
6
5
  normalize,
7
6
  length,
@@ -16,37 +15,14 @@ import {
16
15
  relativeSize,
17
16
  position,
18
17
  lineWidth,
18
+ shadow,
19
19
  } from './dataTypes'
20
20
  import negateValue from './negateValue'
21
21
 
22
- export function applyStateToMarker(selector, marker, state, join) {
23
- let markerIdx = selector.search(new RegExp(`${marker}[:[]`))
24
-
25
- if (markerIdx === -1) {
26
- return join(marker + state, selector)
27
- }
28
-
29
- let markerSelector = selector.slice(markerIdx, selector.indexOf(' ', markerIdx))
30
-
31
- return join(
32
- marker + state + markerSelector.slice(markerIdx + marker.length),
33
- selector.replace(markerSelector, '')
34
- )
35
- }
36
-
37
22
  export function updateAllClasses(selectors, updateClass) {
38
23
  let parser = selectorParser((selectors) => {
39
24
  selectors.walkClasses((sel) => {
40
- let updatedClass = updateClass(sel.value, {
41
- withAttr(className, attr) {
42
- sel.parent.insertAfter(sel, selectorParser.attribute({ attribute: attr.slice(1, -1) }))
43
- return className
44
- },
45
- withPseudo(className, pseudo) {
46
- sel.parent.insertAfter(sel, selectorParser.pseudo({ value: pseudo }))
47
- return className
48
- },
49
- })
25
+ let updatedClass = updateClass(sel.value)
50
26
  sel.value = updatedClass
51
27
  if (sel.raws && sel.raws.value) {
52
28
  sel.raws.value = escapeCommas(sel.raws.value)
@@ -59,115 +35,6 @@ export function updateAllClasses(selectors, updateClass) {
59
35
  return result
60
36
  }
61
37
 
62
- export function updateLastClasses(selectors, updateClass) {
63
- let parser = selectorParser((selectors) => {
64
- selectors.each((sel) => {
65
- let lastClass = sel.filter(({ type }) => type === 'class').pop()
66
-
67
- if (lastClass === undefined) {
68
- return
69
- }
70
-
71
- let updatedClass = updateClass(lastClass.value, {
72
- withPseudo(className, pseudo) {
73
- lastClass.parent.insertAfter(lastClass, selectorParser.pseudo({ value: `${pseudo}` }))
74
- return className
75
- },
76
- })
77
- lastClass.value = updatedClass
78
- if (lastClass.raws && lastClass.raws.value) {
79
- lastClass.raws.value = escapeCommas(lastClass.raws.value)
80
- }
81
- })
82
- })
83
- let result = parser.processSync(selectors)
84
-
85
- return result
86
- }
87
-
88
- function splitByNotEscapedCommas(str) {
89
- let chunks = []
90
- let currentChunk = ''
91
- for (let i = 0; i < str.length; i++) {
92
- if (str[i] === ',' && str[i - 1] !== '\\') {
93
- chunks.push(currentChunk)
94
- currentChunk = ''
95
- } else {
96
- currentChunk += str[i]
97
- }
98
- }
99
- chunks.push(currentChunk)
100
- return chunks
101
- }
102
-
103
- export function transformAllSelectors(transformSelector, { wrap, withRule } = {}) {
104
- return ({ container }) => {
105
- container.walkRules((rule) => {
106
- if (isKeyframeRule(rule)) {
107
- return rule
108
- }
109
- let transformed = splitByNotEscapedCommas(rule.selector).map(transformSelector).join(',')
110
- rule.selector = transformed
111
- if (withRule) {
112
- withRule(rule)
113
- }
114
- return rule
115
- })
116
-
117
- if (wrap) {
118
- let wrapper = wrap()
119
- let nodes = container.nodes
120
- container.removeAll()
121
- wrapper.append(nodes)
122
- container.append(wrapper)
123
- }
124
- }
125
- }
126
-
127
- export function transformAllClasses(transformClass, { wrap, withRule } = {}) {
128
- return ({ container }) => {
129
- container.walkRules((rule) => {
130
- let selector = rule.selector
131
- let variantSelector = updateAllClasses(selector, transformClass)
132
- rule.selector = variantSelector
133
- if (withRule) {
134
- withRule(rule)
135
- }
136
- return rule
137
- })
138
-
139
- if (wrap) {
140
- let wrapper = wrap()
141
- let nodes = container.nodes
142
- container.removeAll()
143
- wrapper.append(nodes)
144
- container.append(wrapper)
145
- }
146
- }
147
- }
148
-
149
- export function transformLastClasses(transformClass, { wrap, withRule } = {}) {
150
- return ({ container }) => {
151
- container.walkRules((rule) => {
152
- let selector = rule.selector
153
- let variantSelector = updateLastClasses(selector, transformClass)
154
- rule.selector = variantSelector
155
- if (withRule) {
156
- withRule(rule)
157
- }
158
- return rule
159
- })
160
-
161
- if (wrap) {
162
- let wrapper = wrap()
163
- let nodes = container.nodes
164
- container.removeAll()
165
- wrapper.append(nodes)
166
- container.append(wrapper)
167
- }
168
- }
169
- }
170
-
171
38
  function resolveArbitraryValue(modifier, validate) {
172
39
  if (!isArbitraryValue(modifier)) {
173
40
  return undefined
@@ -282,6 +149,7 @@ let typeMap = {
282
149
  'line-width': guess(lineWidth),
283
150
  'absolute-size': guess(absoluteSize),
284
151
  'relative-size': guess(relativeSize),
152
+ shadow: guess(shadow),
285
153
  }
286
154
 
287
155
  let supportedTypes = Object.keys(typeMap)
@@ -294,9 +162,18 @@ function splitAtFirst(input, delim) {
294
162
 
295
163
  export function coerceValue(types, modifier, options, tailwindConfig) {
296
164
  if (isArbitraryValue(modifier)) {
297
- let [explicitType, value] = splitAtFirst(modifier.slice(1, -1), ':')
165
+ let arbitraryValue = modifier.slice(1, -1)
166
+ let [explicitType, value] = splitAtFirst(arbitraryValue, ':')
167
+
168
+ // It could be that this resolves to `url(https` which is not a valid
169
+ // identifier. We currently only support "simple" words with dashes or
170
+ // underscores. E.g.: family-name
171
+ if (!/^[\w-_]+$/g.test(explicitType)) {
172
+ value = arbitraryValue
173
+ }
298
174
 
299
- if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
175
+ //
176
+ else if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
300
177
  return []
301
178
  }
302
179
 
@@ -308,7 +185,7 @@ export function coerceValue(types, modifier, options, tailwindConfig) {
308
185
  // Find first matching type
309
186
  for (let type of [].concat(types)) {
310
187
  let result = typeMap[type](modifier, options, { tailwindConfig })
311
- if (result) return [result, type]
188
+ if (result !== undefined) return [result, type]
312
189
  }
313
190
 
314
191
  return []
@@ -2,13 +2,10 @@ import parser from 'postcss-selector-parser'
2
2
  import { tap } from './tap'
3
3
 
4
4
  export default function (prefix, selector) {
5
- const getPrefix =
6
- typeof prefix === 'function' ? prefix : () => (prefix === undefined ? '' : prefix)
7
-
8
5
  return parser((selectors) => {
9
6
  selectors.walkClasses((classSelector) => {
10
7
  tap(classSelector.value, (baseClass) => {
11
- classSelector.value = `${getPrefix('.' + baseClass)}${baseClass}`
8
+ classSelector.value = `${prefix}${baseClass}`
12
9
  })
13
10
  })
14
11
  }).processSync(selector)
@@ -6,6 +6,8 @@ import colors from '../public/colors'
6
6
  import { defaults } from './defaults'
7
7
  import { toPath } from './toPath'
8
8
  import { normalizeConfig } from './normalizeConfig'
9
+ import isPlainObject from './isPlainObject'
10
+ import { cloneDeep } from './cloneDeep'
9
11
 
10
12
  function isFunction(input) {
11
13
  return typeof input === 'function'
@@ -144,7 +146,15 @@ function resolveFunctionKeys(object) {
144
146
  val = isFunction(val) ? val(resolvePath, configUtils) : val
145
147
  }
146
148
 
147
- return val === undefined ? defaultValue : val
149
+ if (val === undefined) {
150
+ return defaultValue
151
+ }
152
+
153
+ if (isPlainObject(val)) {
154
+ return cloneDeep(val)
155
+ }
156
+
157
+ return val
148
158
  }
149
159
 
150
160
  resolvePath.theme = resolvePath
@@ -1,4 +1,26 @@
1
+ /**
2
+ * Parse a path string into an array of path segments.
3
+ *
4
+ * Square bracket notation `a[b]` may be used to "escape" dots that would otherwise be interpreted as path separators.
5
+ *
6
+ * Example:
7
+ * a -> ['a]
8
+ * a.b.c -> ['a', 'b', 'c']
9
+ * a[b].c -> ['a', 'b', 'c']
10
+ * a[b.c].e.f -> ['a', 'b.c', 'e', 'f']
11
+ * a[b][c][d] -> ['a', 'b', 'c', 'd']
12
+ *
13
+ * @param {string|string[]} path
14
+ **/
1
15
  export function toPath(path) {
2
16
  if (Array.isArray(path)) return path
3
- return path.split(/[\.\]\[]+/g)
17
+
18
+ let openBrackets = path.split('[').length - 1
19
+ let closedBrackets = path.split(']').length - 1
20
+
21
+ if (openBrackets !== closedBrackets) {
22
+ throw new Error(`Path is invalid. Has unbalanced brackets: ${path}`)
23
+ }
24
+
25
+ return path.split(/\.(?![^\[]*\])|[\[\]]/g).filter(Boolean)
4
26
  }
@@ -2,7 +2,12 @@ import postcss from 'postcss'
2
2
 
3
3
  export default function transformThemeValue(themeSection) {
4
4
  if (['fontSize', 'outline'].includes(themeSection)) {
5
- return (value) => (Array.isArray(value) ? value[0] : value)
5
+ return (value) => {
6
+ if (typeof value === 'function') value = value({})
7
+ if (Array.isArray(value)) value = value[0]
8
+
9
+ return value
10
+ }
6
11
  }
7
12
 
8
13
  if (
@@ -20,18 +25,28 @@ export default function transformThemeValue(themeSection) {
20
25
  'animation',
21
26
  ].includes(themeSection)
22
27
  ) {
23
- return (value) => (Array.isArray(value) ? value.join(', ') : value)
28
+ return (value) => {
29
+ if (typeof value === 'function') value = value({})
30
+ if (Array.isArray(value)) value = value.join(', ')
31
+
32
+ return value
33
+ }
24
34
  }
25
35
 
26
36
  // For backwards compatibility reasons, before we switched to underscores
27
37
  // instead of commas for arbitrary values.
28
38
  if (['gridTemplateColumns', 'gridTemplateRows', 'objectPosition'].includes(themeSection)) {
29
- return (value) => (typeof value === 'string' ? postcss.list.comma(value).join(' ') : value)
30
- }
39
+ return (value) => {
40
+ if (typeof value === 'function') value = value({})
41
+ if (typeof value === 'string') value = postcss.list.comma(value).join(' ')
31
42
 
32
- if (themeSection === 'colors') {
33
- return (value) => (typeof value === 'function' ? value({}) : value)
43
+ return value
44
+ }
34
45
  }
35
46
 
36
- return (value) => value
47
+ return (value) => {
48
+ if (typeof value === 'function') value = value({})
49
+
50
+ return value
51
+ }
37
52
  }
@@ -203,14 +203,15 @@ module.exports = {
203
203
  },
204
204
  boxShadow: {
205
205
  sm: '0 1px 2px 0 rgb(0 0 0 / 0.05)',
206
- DEFAULT: '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px 0 rgb(0 0 0 / 0.06)',
207
- md: '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -1px rgb(0 0 0 / 0.06)',
208
- lg: '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05)',
209
- xl: '0 20px 25px -5px rgb(0 0 0 / 0.1), 0 10px 10px -5px rgb(0 0 0 / 0.04)',
206
+ DEFAULT: '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)',
207
+ md: '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)',
208
+ lg: '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)',
209
+ xl: '0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)',
210
210
  '2xl': '0 25px 50px -12px rgb(0 0 0 / 0.25)',
211
- inner: 'inset 0 2px 4px 0 rgb(0 0 0 / 0.06)',
211
+ inner: 'inset 0 2px 4px 0 rgb(0 0 0 / 0.05)',
212
212
  none: 'none',
213
213
  },
214
+ boxShadowColor: ({ theme }) => theme('colors'),
214
215
  caretColor: ({ theme }) => theme('colors'),
215
216
  accentColor: ({ theme }) => ({
216
217
  ...theme('colors'),
@@ -279,7 +280,7 @@ module.exports = {
279
280
  '2xl': '0 25px 25px rgb(0 0 0 / 0.15)',
280
281
  none: '0 0 #0000',
281
282
  },
282
- fill: { current: 'currentColor' },
283
+ fill: ({ theme }) => theme('colors'),
283
284
  grayscale: {
284
285
  0: '0',
285
286
  DEFAULT: '100%',
@@ -697,14 +698,24 @@ module.exports = {
697
698
  11: '11',
698
699
  12: '12',
699
700
  },
700
- outline: {
701
- none: ['2px solid transparent', '2px'],
702
- white: ['2px dotted white', '2px'],
703
- black: ['2px dotted black', '2px'],
704
- },
705
701
  padding: ({ theme }) => theme('spacing'),
706
702
  placeholderColor: ({ theme }) => theme('colors'),
707
703
  placeholderOpacity: ({ theme }) => theme('opacity'),
704
+ outlineColor: ({ theme }) => theme('colors'),
705
+ outlineOffset: {
706
+ 0: '0px',
707
+ 1: '1px',
708
+ 2: '2px',
709
+ 4: '4px',
710
+ 8: '8px',
711
+ },
712
+ outlineWidth: {
713
+ 0: '0px',
714
+ 1: '1px',
715
+ 2: '2px',
716
+ 4: '4px',
717
+ 8: '8px',
718
+ },
708
719
  ringColor: ({ theme }) => ({
709
720
  DEFAULT: theme('colors.blue.500', '#3b82f6'),
710
721
  ...theme('colors'),
@@ -778,9 +789,7 @@ module.exports = {
778
789
  space: ({ theme }) => ({
779
790
  ...theme('spacing'),
780
791
  }),
781
- stroke: {
782
- current: 'currentColor',
783
- },
792
+ stroke: ({ theme }) => theme('colors'),
784
793
  strokeWidth: {
785
794
  0: '0',
786
795
  1: '1',
@@ -788,6 +797,23 @@ module.exports = {
788
797
  },
789
798
  textColor: ({ theme }) => theme('colors'),
790
799
  textDecorationColor: ({ theme }) => theme('colors'),
800
+ textDecorationThickness: {
801
+ auto: 'auto',
802
+ 'from-font': 'from-font',
803
+ 0: '0px',
804
+ 1: '1px',
805
+ 2: '2px',
806
+ 4: '4px',
807
+ 8: '8px',
808
+ },
809
+ textUnderlineOffset: {
810
+ auto: 'auto',
811
+ 0: '0px',
812
+ 1: '1px',
813
+ 2: '2px',
814
+ 4: '4px',
815
+ 8: '8px',
816
+ },
791
817
  textIndent: ({ theme }) => ({
792
818
  ...theme('spacing'),
793
819
  }),
@@ -828,8 +854,8 @@ module.exports = {
828
854
  none: 'none',
829
855
  all: 'all',
830
856
  DEFAULT:
831
- 'background-color, border-color, color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter',
832
- colors: 'background-color, border-color, color, fill, stroke',
857
+ 'color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter',
858
+ colors: 'color, background-color, border-color, text-decoration-color, fill, stroke',
833
859
  opacity: 'opacity',
834
860
  shadow: 'box-shadow',
835
861
  transform: 'transform',