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.
- package/CHANGELOG.md +364 -2
- package/LICENSE +1 -2
- package/README.md +8 -4
- package/colors.d.ts +3 -0
- package/colors.js +2 -1
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -1
- package/defaultTheme.d.ts +3 -0
- package/defaultTheme.js +2 -1
- package/lib/cli-peer-dependencies.js +10 -5
- package/lib/cli.js +306 -203
- package/lib/constants.js +9 -9
- package/lib/corePluginList.js +10 -1
- package/lib/corePlugins.js +1835 -1760
- package/lib/css/preflight.css +19 -13
- package/lib/featureFlags.js +18 -15
- package/lib/index.js +17 -8
- package/lib/lib/cacheInvalidation.js +69 -0
- package/lib/lib/collapseAdjacentRules.js +30 -14
- package/lib/lib/collapseDuplicateDeclarations.js +80 -0
- package/lib/lib/defaultExtractor.js +187 -0
- package/lib/lib/detectNesting.js +17 -2
- package/lib/lib/evaluateTailwindFunctions.js +40 -24
- package/lib/lib/expandApplyAtRules.js +414 -157
- package/lib/lib/expandTailwindAtRules.js +145 -126
- package/lib/lib/generateRules.js +403 -103
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +43 -35
- package/lib/lib/partitionApplyAtRules.js +53 -0
- package/lib/lib/regex.js +53 -0
- package/lib/lib/resolveDefaultsAtRules.js +83 -65
- package/lib/lib/setupContextUtils.js +315 -204
- package/lib/lib/setupTrackingContext.js +60 -56
- package/lib/lib/sharedState.js +38 -5
- package/lib/lib/substituteScreenAtRules.js +9 -6
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +17 -0
- package/lib/postcss-plugins/nesting/plugin.js +85 -0
- package/lib/processTailwindFeatures.js +19 -9
- package/lib/public/colors.js +241 -241
- package/lib/public/resolve-config.js +5 -5
- package/lib/util/buildMediaQuery.js +13 -24
- package/lib/util/cloneDeep.js +1 -1
- package/lib/util/cloneNodes.js +12 -1
- package/lib/util/color.js +43 -32
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +11 -15
- package/lib/util/dataTypes.js +114 -74
- package/lib/util/defaults.js +6 -0
- package/lib/util/escapeClassName.js +5 -5
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +2 -4
- package/lib/util/formatVariantSelector.js +194 -0
- package/lib/util/getAllConfigs.js +13 -5
- package/lib/util/hashConfig.js +5 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +1 -1
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +11 -7
- package/lib/util/nameClass.js +7 -6
- package/lib/util/negateValue.js +4 -4
- package/lib/util/normalizeConfig.js +84 -45
- package/lib/util/normalizeScreens.js +59 -0
- package/lib/util/parseAnimationValue.js +56 -56
- package/lib/util/parseBoxShadowValue.js +76 -0
- package/lib/util/parseDependency.js +32 -32
- package/lib/util/parseObjectStyles.js +6 -6
- package/lib/util/pluginUtils.js +34 -165
- package/lib/util/prefixSelector.js +4 -7
- package/lib/util/resolveConfig.js +115 -66
- package/lib/util/resolveConfigPath.js +17 -18
- package/lib/util/responsive.js +6 -6
- package/lib/util/splitAtTopLevelOnly.js +72 -0
- package/lib/util/toColorValue.js +1 -2
- package/lib/util/toPath.js +6 -1
- package/lib/util/transformThemeValue.js +42 -34
- package/lib/util/validateConfig.js +21 -0
- package/lib/util/withAlphaVariable.js +19 -19
- package/nesting/index.js +2 -12
- package/package.json +39 -40
- package/peers/index.js +11511 -10819
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.js +2 -1
- package/scripts/generate-types.js +52 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +164 -30
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +540 -535
- package/src/css/preflight.css +19 -13
- package/src/featureFlags.js +5 -5
- package/src/index.js +14 -6
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/collapseDuplicateDeclarations.js +93 -0
- package/src/lib/defaultExtractor.js +192 -0
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +24 -7
- package/src/lib/expandApplyAtRules.js +442 -154
- package/src/lib/expandTailwindAtRules.js +79 -37
- package/src/lib/generateRules.js +400 -83
- package/src/lib/normalizeTailwindDirectives.js +7 -1
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +35 -10
- package/src/lib/setupContextUtils.js +273 -112
- package/src/lib/setupTrackingContext.js +12 -7
- package/src/lib/sharedState.js +42 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/src/postcss-plugins/nesting/plugin.js +80 -0
- package/src/processTailwindFeatures.js +14 -2
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +31 -14
- package/src/util/dataTypes.js +56 -16
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +213 -0
- package/src/util/getAllConfigs.js +7 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +10 -6
- package/src/util/nameClass.js +1 -1
- package/src/util/normalizeConfig.js +32 -3
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +72 -0
- package/src/util/pluginUtils.js +15 -138
- package/src/util/prefixSelector.js +7 -8
- package/src/util/resolveConfig.js +97 -15
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +24 -7
- package/src/util/validateConfig.js +13 -0
- package/stubs/defaultConfig.stub.js +47 -17
- package/types/config.d.ts +325 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types.d.ts +1 -0
- package/lib/lib/setupWatchingContext.js +0 -284
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -304
package/src/util/pluginUtils.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
11
|
-
|
|
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
|
|
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
|
-
|
|
140
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
|
229
|
+
return defaultValue
|
|
148
230
|
}
|
|
149
231
|
|
|
150
|
-
|
|
232
|
+
// colors.red.500/50
|
|
151
233
|
|
|
152
|
-
|
|
153
|
-
resolvePath
|
|
154
|
-
|
|
234
|
+
Object.assign(resolvePath, {
|
|
235
|
+
theme: resolvePath,
|
|
236
|
+
...configUtils,
|
|
237
|
+
})
|
|
155
238
|
|
|
156
239
|
return Object.keys(object).reduce((resolved, key) => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
+
}
|
package/src/util/toPath.js
CHANGED
|
@@ -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
|
-
|
|
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) =>
|
|
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) =>
|
|
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) =>
|
|
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
|
-
|
|
33
|
-
|
|
43
|
+
return value
|
|
44
|
+
}
|
|
34
45
|
}
|
|
35
46
|
|
|
36
|
-
return (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
|
|
207
|
-
md: '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -
|
|
208
|
-
lg: '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -
|
|
209
|
-
xl: '0 20px 25px -5px rgb(0 0 0 / 0.1), 0
|
|
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.
|
|
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: {
|
|
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(
|
|
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',
|