tailwindcss 0.0.0-insiders.d2b53cd → 0.0.0-insiders.d2fdf9e

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 (143) hide show
  1. package/CHANGELOG.md +364 -2
  2. package/LICENSE +1 -2
  3. package/README.md +8 -4
  4. package/colors.d.ts +3 -0
  5. package/colors.js +2 -1
  6. package/defaultConfig.d.ts +3 -0
  7. package/defaultConfig.js +2 -1
  8. package/defaultTheme.d.ts +3 -0
  9. package/defaultTheme.js +2 -1
  10. package/lib/cli-peer-dependencies.js +10 -5
  11. package/lib/cli.js +306 -203
  12. package/lib/constants.js +9 -9
  13. package/lib/corePluginList.js +10 -1
  14. package/lib/corePlugins.js +1835 -1760
  15. package/lib/css/preflight.css +19 -13
  16. package/lib/featureFlags.js +18 -15
  17. package/lib/index.js +17 -8
  18. package/lib/lib/cacheInvalidation.js +69 -0
  19. package/lib/lib/collapseAdjacentRules.js +30 -14
  20. package/lib/lib/collapseDuplicateDeclarations.js +80 -0
  21. package/lib/lib/defaultExtractor.js +187 -0
  22. package/lib/lib/detectNesting.js +17 -2
  23. package/lib/lib/evaluateTailwindFunctions.js +40 -24
  24. package/lib/lib/expandApplyAtRules.js +414 -157
  25. package/lib/lib/expandTailwindAtRules.js +145 -126
  26. package/lib/lib/generateRules.js +403 -103
  27. package/lib/lib/getModuleDependencies.js +14 -14
  28. package/lib/lib/normalizeTailwindDirectives.js +43 -35
  29. package/lib/lib/partitionApplyAtRules.js +53 -0
  30. package/lib/lib/regex.js +53 -0
  31. package/lib/lib/resolveDefaultsAtRules.js +83 -65
  32. package/lib/lib/setupContextUtils.js +315 -204
  33. package/lib/lib/setupTrackingContext.js +60 -56
  34. package/lib/lib/sharedState.js +38 -5
  35. package/lib/lib/substituteScreenAtRules.js +9 -6
  36. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  37. package/lib/postcss-plugins/nesting/index.js +17 -0
  38. package/lib/postcss-plugins/nesting/plugin.js +85 -0
  39. package/lib/processTailwindFeatures.js +19 -9
  40. package/lib/public/colors.js +241 -241
  41. package/lib/public/resolve-config.js +5 -5
  42. package/lib/util/buildMediaQuery.js +13 -24
  43. package/lib/util/cloneDeep.js +1 -1
  44. package/lib/util/cloneNodes.js +12 -1
  45. package/lib/util/color.js +43 -32
  46. package/lib/util/createPlugin.js +1 -2
  47. package/lib/util/createUtilityPlugin.js +11 -15
  48. package/lib/util/dataTypes.js +114 -74
  49. package/lib/util/defaults.js +6 -0
  50. package/lib/util/escapeClassName.js +5 -5
  51. package/lib/util/escapeCommas.js +1 -1
  52. package/lib/util/flattenColorPalette.js +2 -4
  53. package/lib/util/formatVariantSelector.js +194 -0
  54. package/lib/util/getAllConfigs.js +13 -5
  55. package/lib/util/hashConfig.js +5 -5
  56. package/lib/util/isKeyframeRule.js +1 -1
  57. package/lib/util/isPlainObject.js +1 -1
  58. package/lib/util/isValidArbitraryValue.js +64 -0
  59. package/lib/util/log.js +11 -7
  60. package/lib/util/nameClass.js +7 -6
  61. package/lib/util/negateValue.js +4 -4
  62. package/lib/util/normalizeConfig.js +84 -45
  63. package/lib/util/normalizeScreens.js +59 -0
  64. package/lib/util/parseAnimationValue.js +56 -56
  65. package/lib/util/parseBoxShadowValue.js +76 -0
  66. package/lib/util/parseDependency.js +32 -32
  67. package/lib/util/parseObjectStyles.js +6 -6
  68. package/lib/util/pluginUtils.js +34 -165
  69. package/lib/util/prefixSelector.js +4 -7
  70. package/lib/util/resolveConfig.js +115 -66
  71. package/lib/util/resolveConfigPath.js +17 -18
  72. package/lib/util/responsive.js +6 -6
  73. package/lib/util/splitAtTopLevelOnly.js +72 -0
  74. package/lib/util/toColorValue.js +1 -2
  75. package/lib/util/toPath.js +6 -1
  76. package/lib/util/transformThemeValue.js +42 -34
  77. package/lib/util/validateConfig.js +21 -0
  78. package/lib/util/withAlphaVariable.js +19 -19
  79. package/nesting/index.js +2 -12
  80. package/package.json +39 -40
  81. package/peers/index.js +11511 -10819
  82. package/plugin.d.ts +11 -0
  83. package/plugin.js +2 -1
  84. package/resolveConfig.js +2 -1
  85. package/scripts/generate-types.js +52 -0
  86. package/src/cli-peer-dependencies.js +7 -1
  87. package/src/cli.js +164 -30
  88. package/src/corePluginList.js +1 -1
  89. package/src/corePlugins.js +540 -535
  90. package/src/css/preflight.css +19 -13
  91. package/src/featureFlags.js +5 -5
  92. package/src/index.js +14 -6
  93. package/src/lib/cacheInvalidation.js +52 -0
  94. package/src/lib/collapseAdjacentRules.js +21 -2
  95. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  96. package/src/lib/defaultExtractor.js +192 -0
  97. package/src/lib/detectNesting.js +22 -3
  98. package/src/lib/evaluateTailwindFunctions.js +24 -7
  99. package/src/lib/expandApplyAtRules.js +442 -154
  100. package/src/lib/expandTailwindAtRules.js +79 -37
  101. package/src/lib/generateRules.js +400 -83
  102. package/src/lib/normalizeTailwindDirectives.js +7 -1
  103. package/src/lib/partitionApplyAtRules.js +52 -0
  104. package/src/lib/regex.js +74 -0
  105. package/src/lib/resolveDefaultsAtRules.js +35 -10
  106. package/src/lib/setupContextUtils.js +273 -112
  107. package/src/lib/setupTrackingContext.js +12 -7
  108. package/src/lib/sharedState.js +42 -4
  109. package/src/lib/substituteScreenAtRules.js +6 -3
  110. package/src/postcss-plugins/nesting/README.md +42 -0
  111. package/src/postcss-plugins/nesting/index.js +13 -0
  112. package/src/postcss-plugins/nesting/plugin.js +80 -0
  113. package/src/processTailwindFeatures.js +14 -2
  114. package/src/util/buildMediaQuery.js +14 -18
  115. package/src/util/cloneNodes.js +14 -1
  116. package/src/util/color.js +31 -14
  117. package/src/util/dataTypes.js +56 -16
  118. package/src/util/defaults.js +6 -0
  119. package/src/util/formatVariantSelector.js +213 -0
  120. package/src/util/getAllConfigs.js +7 -0
  121. package/src/util/isValidArbitraryValue.js +61 -0
  122. package/src/util/log.js +10 -6
  123. package/src/util/nameClass.js +1 -1
  124. package/src/util/normalizeConfig.js +32 -3
  125. package/src/util/normalizeScreens.js +45 -0
  126. package/src/util/parseBoxShadowValue.js +72 -0
  127. package/src/util/pluginUtils.js +15 -138
  128. package/src/util/prefixSelector.js +7 -8
  129. package/src/util/resolveConfig.js +97 -15
  130. package/src/util/splitAtTopLevelOnly.js +71 -0
  131. package/src/util/toPath.js +23 -1
  132. package/src/util/transformThemeValue.js +24 -7
  133. package/src/util/validateConfig.js +13 -0
  134. package/stubs/defaultConfig.stub.js +47 -17
  135. package/types/config.d.ts +325 -0
  136. package/types/generated/.gitkeep +0 -0
  137. package/types/generated/colors.d.ts +276 -0
  138. package/types/generated/corePluginList.d.ts +1 -0
  139. package/types/index.d.ts +1 -0
  140. package/types.d.ts +1 -0
  141. package/lib/lib/setupWatchingContext.js +0 -284
  142. package/nesting/plugin.js +0 -41
  143. 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 []
@@ -1,15 +1,14 @@
1
1
  import parser from 'postcss-selector-parser'
2
- import { tap } from './tap'
3
-
4
- export default function (prefix, selector) {
5
- const getPrefix =
6
- typeof prefix === 'function' ? prefix : () => (prefix === undefined ? '' : prefix)
7
2
 
3
+ export default function (prefix, selector, prependNegative = false) {
8
4
  return parser((selectors) => {
9
5
  selectors.walkClasses((classSelector) => {
10
- tap(classSelector.value, (baseClass) => {
11
- classSelector.value = `${getPrefix('.' + baseClass)}${baseClass}`
12
- })
6
+ let baseClass = classSelector.value
7
+ let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith('-')
8
+
9
+ classSelector.value = shouldPlaceNegativeBeforePrefix
10
+ ? `-${prefix}${baseClass.slice(1)}`
11
+ : `${prefix}${baseClass}`
13
12
  })
14
13
  }).processSync(selector)
15
14
  }
@@ -6,6 +6,9 @@ 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'
11
+ import { withAlphaValue } from './withAlphaVariable'
9
12
 
10
13
  function isFunction(input) {
11
14
  return typeof input === 'function'
@@ -64,6 +67,36 @@ const configUtils = {
64
67
  {}
65
68
  )
66
69
  },
70
+ rgb(property) {
71
+ if (!property.startsWith('--')) {
72
+ throw new Error(
73
+ 'The rgb() helper requires a custom property name to be passed as the first argument.'
74
+ )
75
+ }
76
+
77
+ return ({ opacityValue }) => {
78
+ if (opacityValue === undefined || opacityValue === 1) {
79
+ return `rgb(var(${property}) / 1.0)`
80
+ }
81
+
82
+ return `rgb(var(${property}) / ${opacityValue})`
83
+ }
84
+ },
85
+ hsl(property) {
86
+ if (!property.startsWith('--')) {
87
+ throw new Error(
88
+ 'The hsl() helper requires a custom property name to be passed as the first argument.'
89
+ )
90
+ }
91
+
92
+ return ({ opacityValue }) => {
93
+ if (opacityValue === undefined || opacityValue === 1) {
94
+ return `hsl(var(${property}) / 1)`
95
+ }
96
+
97
+ return `hsl(var(${property}) / ${opacityValue})`
98
+ }
99
+ },
67
100
  }
68
101
 
69
102
  function value(valueToResolve, ...args) {
@@ -132,32 +165,81 @@ function mergeExtensions({ extend, ...theme }) {
132
165
  })
133
166
  }
134
167
 
168
+ /**
169
+ *
170
+ * @param {string} key
171
+ * @return {Iterable<string[] & {alpha: string | undefined}>}
172
+ */
173
+ function* toPaths(key) {
174
+ let path = toPath(key)
175
+
176
+ if (path.length === 0) {
177
+ return
178
+ }
179
+
180
+ yield path
181
+
182
+ if (Array.isArray(key)) {
183
+ return
184
+ }
185
+
186
+ let pattern = /^(.*?)\s*\/\s*([^/]+)$/
187
+ let matches = key.match(pattern)
188
+
189
+ if (matches !== null) {
190
+ let [, prefix, alpha] = matches
191
+
192
+ let newPath = toPath(prefix)
193
+ newPath.alpha = alpha
194
+
195
+ yield newPath
196
+ }
197
+ }
198
+
135
199
  function resolveFunctionKeys(object) {
200
+ // theme('colors.red.500 / 0.5') -> ['colors', 'red', '500 / 0', '5]
201
+
136
202
  const resolvePath = (key, defaultValue) => {
137
- const path = toPath(key)
203
+ for (const path of toPaths(key)) {
204
+ let index = 0
205
+ let val = object
206
+
207
+ while (val !== undefined && val !== null && index < path.length) {
208
+ val = val[path[index++]]
138
209
 
139
- let index = 0
140
- let val = object
210
+ let shouldResolveAsFn =
211
+ isFunction(val) && (path.alpha === undefined || index < path.length - 1)
212
+
213
+ val = shouldResolveAsFn ? val(resolvePath, configUtils) : val
214
+ }
141
215
 
142
- while (val !== undefined && val !== null && index < path.length) {
143
- val = val[path[index++]]
144
- val = isFunction(val) ? val(resolvePath, configUtils) : val
216
+ if (val !== undefined) {
217
+ if (path.alpha !== undefined) {
218
+ return withAlphaValue(val, path.alpha)
219
+ }
220
+
221
+ if (isPlainObject(val)) {
222
+ return cloneDeep(val)
223
+ }
224
+
225
+ return val
226
+ }
145
227
  }
146
228
 
147
- return val === undefined ? defaultValue : val
229
+ return defaultValue
148
230
  }
149
231
 
150
- resolvePath.theme = resolvePath
232
+ // colors.red.500/50
151
233
 
152
- for (let key in configUtils) {
153
- resolvePath[key] = configUtils[key]
154
- }
234
+ Object.assign(resolvePath, {
235
+ theme: resolvePath,
236
+ ...configUtils,
237
+ })
155
238
 
156
239
  return Object.keys(object).reduce((resolved, key) => {
157
- return {
158
- ...resolved,
159
- [key]: isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key],
160
- }
240
+ resolved[key] = isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key]
241
+
242
+ return resolved
161
243
  }, {})
162
244
  }
163
245
 
@@ -0,0 +1,71 @@
1
+ import * as regex from '../lib/regex'
2
+
3
+ /**
4
+ * This splits a string on a top-level character.
5
+ *
6
+ * Regex doesn't support recursion (at least not the JS-flavored version).
7
+ * So we have to use a tiny state machine to keep track of paren placement.
8
+ *
9
+ * Expected behavior using commas:
10
+ * var(--a, 0 0 1px rgb(0, 0, 0)), 0 0 1px rgb(0, 0, 0)
11
+ * ─┬─ ┬ ┬ ┬
12
+ * x x x ╰──────── Split because top-level
13
+ * ╰──────────────┴──┴───────────── Ignored b/c inside >= 1 levels of parens
14
+ *
15
+ * @param {string} input
16
+ * @param {string} separator
17
+ */
18
+ export function* splitAtTopLevelOnly(input, separator) {
19
+ let SPECIALS = new RegExp(`[(){}\\[\\]${regex.escape(separator)}]`, 'g')
20
+
21
+ let depth = 0
22
+ let lastIndex = 0
23
+ let found = false
24
+ let separatorIndex = 0
25
+ let separatorStart = 0
26
+ let separatorLength = separator.length
27
+
28
+ // Find all paren-like things & character
29
+ // And only split on commas if they're top-level
30
+ for (let match of input.matchAll(SPECIALS)) {
31
+ let matchesSeparator = match[0] === separator[separatorIndex]
32
+ let atEndOfSeparator = separatorIndex === separatorLength - 1
33
+ let matchesFullSeparator = matchesSeparator && atEndOfSeparator
34
+
35
+ if (match[0] === '(') depth++
36
+ if (match[0] === ')') depth--
37
+ if (match[0] === '[') depth++
38
+ if (match[0] === ']') depth--
39
+ if (match[0] === '{') depth++
40
+ if (match[0] === '}') depth--
41
+
42
+ if (matchesSeparator && depth === 0) {
43
+ if (separatorStart === 0) {
44
+ separatorStart = match.index
45
+ }
46
+
47
+ separatorIndex++
48
+ }
49
+
50
+ if (matchesFullSeparator && depth === 0) {
51
+ found = true
52
+
53
+ yield input.substring(lastIndex, separatorStart)
54
+ lastIndex = separatorStart + separatorLength
55
+ }
56
+
57
+ if (separatorIndex === separatorLength) {
58
+ separatorIndex = 0
59
+ separatorStart = 0
60
+ }
61
+ }
62
+
63
+ // Provide the last segment of the string if available
64
+ // Otherwise the whole string since no `char`s were found
65
+ // This mirrors the behavior of string.split()
66
+ if (found) {
67
+ yield input.substring(lastIndex)
68
+ } else {
69
+ yield input
70
+ }
71
+ }
@@ -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,30 @@ 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, opts = {}) => {
48
+ if (typeof value === 'function') {
49
+ value = value(opts)
50
+ }
51
+
52
+ return value
53
+ }
37
54
  }
@@ -0,0 +1,13 @@
1
+ import log from './log'
2
+
3
+ export function validateConfig(config) {
4
+ if (config.content.files.length === 0) {
5
+ log.warn('content-problems', [
6
+ 'The `content` option in your Tailwind CSS configuration is missing or empty.',
7
+ 'Configure your content sources or your generated CSS will be missing styles.',
8
+ 'https://tailwindcss.com/docs/content-configuration',
9
+ ])
10
+ }
11
+
12
+ return config
13
+ }
@@ -194,6 +194,9 @@ module.exports = {
194
194
  '3xl': '1.5rem',
195
195
  full: '9999px',
196
196
  },
197
+ borderSpacing: ({ theme }) => ({
198
+ ...theme('spacing'),
199
+ }),
197
200
  borderWidth: {
198
201
  DEFAULT: '1px',
199
202
  0: '0px',
@@ -203,14 +206,15 @@ module.exports = {
203
206
  },
204
207
  boxShadow: {
205
208
  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)',
209
+ DEFAULT: '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)',
210
+ md: '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)',
211
+ lg: '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)',
212
+ xl: '0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)',
210
213
  '2xl': '0 25px 50px -12px rgb(0 0 0 / 0.25)',
211
- inner: 'inset 0 2px 4px 0 rgb(0 0 0 / 0.06)',
214
+ inner: 'inset 0 2px 4px 0 rgb(0 0 0 / 0.05)',
212
215
  none: 'none',
213
216
  },
217
+ boxShadowColor: ({ theme }) => theme('colors'),
214
218
  caretColor: ({ theme }) => theme('colors'),
215
219
  accentColor: ({ theme }) => ({
216
220
  ...theme('colors'),
@@ -279,7 +283,7 @@ module.exports = {
279
283
  '2xl': '0 25px 25px rgb(0 0 0 / 0.15)',
280
284
  none: '0 0 #0000',
281
285
  },
282
- fill: { current: 'currentColor' },
286
+ fill: ({ theme }) => theme('colors'),
283
287
  grayscale: {
284
288
  0: '0',
285
289
  DEFAULT: '100%',
@@ -697,16 +701,26 @@ module.exports = {
697
701
  11: '11',
698
702
  12: '12',
699
703
  },
700
- outline: {
701
- none: ['2px solid transparent', '2px'],
702
- white: ['2px dotted white', '2px'],
703
- black: ['2px dotted black', '2px'],
704
- },
705
704
  padding: ({ theme }) => theme('spacing'),
706
705
  placeholderColor: ({ theme }) => theme('colors'),
707
706
  placeholderOpacity: ({ theme }) => theme('opacity'),
707
+ outlineColor: ({ theme }) => theme('colors'),
708
+ outlineOffset: {
709
+ 0: '0px',
710
+ 1: '1px',
711
+ 2: '2px',
712
+ 4: '4px',
713
+ 8: '8px',
714
+ },
715
+ outlineWidth: {
716
+ 0: '0px',
717
+ 1: '1px',
718
+ 2: '2px',
719
+ 4: '4px',
720
+ 8: '8px',
721
+ },
708
722
  ringColor: ({ theme }) => ({
709
- DEFAULT: theme('colors.blue.500', '#3b82f6'),
723
+ DEFAULT: theme(`colors.blue.500`, '#3b82f6'),
710
724
  ...theme('colors'),
711
725
  }),
712
726
  ringOffsetColor: ({ theme }) => theme('colors'),
@@ -778,15 +792,31 @@ module.exports = {
778
792
  space: ({ theme }) => ({
779
793
  ...theme('spacing'),
780
794
  }),
781
- stroke: {
782
- current: 'currentColor',
783
- },
795
+ stroke: ({ theme }) => theme('colors'),
784
796
  strokeWidth: {
785
797
  0: '0',
786
798
  1: '1',
787
799
  2: '2',
788
800
  },
789
801
  textColor: ({ theme }) => theme('colors'),
802
+ textDecorationColor: ({ theme }) => theme('colors'),
803
+ textDecorationThickness: {
804
+ auto: 'auto',
805
+ 'from-font': 'from-font',
806
+ 0: '0px',
807
+ 1: '1px',
808
+ 2: '2px',
809
+ 4: '4px',
810
+ 8: '8px',
811
+ },
812
+ textUnderlineOffset: {
813
+ auto: 'auto',
814
+ 0: '0px',
815
+ 1: '1px',
816
+ 2: '2px',
817
+ 4: '4px',
818
+ 8: '8px',
819
+ },
790
820
  textIndent: ({ theme }) => ({
791
821
  ...theme('spacing'),
792
822
  }),
@@ -827,8 +857,8 @@ module.exports = {
827
857
  none: 'none',
828
858
  all: 'all',
829
859
  DEFAULT:
830
- 'background-color, border-color, color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter',
831
- colors: 'background-color, border-color, color, fill, stroke',
860
+ 'color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter',
861
+ colors: 'color, background-color, border-color, text-decoration-color, fill, stroke',
832
862
  opacity: 'opacity',
833
863
  shadow: 'box-shadow',
834
864
  transform: 'transform',