tailwindcss 0.0.0-insiders.df011dc → 0.0.0-insiders.e2d5f21
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 +106 -1
- package/README.md +1 -1
- package/colors.js +1 -304
- package/defaultConfig.js +1 -4
- package/defaultTheme.js +1 -4
- package/lib/cli-peer-dependencies.js +4 -9
- package/lib/cli.js +646 -705
- package/lib/constants.js +15 -15
- package/lib/corePluginList.js +174 -4
- package/lib/corePlugins.js +3637 -2934
- package/lib/css/preflight.css +14 -1
- package/lib/featureFlags.js +44 -44
- package/lib/index.js +25 -24
- package/lib/lib/collapseAdjacentRules.js +33 -35
- package/lib/lib/collapseDuplicateDeclarations.js +29 -0
- package/lib/lib/detectNesting.js +34 -0
- package/lib/lib/evaluateTailwindFunctions.js +134 -155
- package/lib/lib/expandApplyAtRules.js +183 -200
- package/lib/lib/expandTailwindAtRules.js +219 -232
- package/lib/lib/generateRules.js +478 -311
- package/lib/lib/getModuleDependencies.js +36 -41
- package/lib/lib/normalizeTailwindDirectives.js +66 -58
- package/lib/lib/resolveDefaultsAtRules.js +110 -90
- package/lib/lib/setupContextUtils.js +740 -580
- package/lib/lib/setupTrackingContext.js +142 -162
- package/lib/lib/setupWatchingContext.js +235 -278
- package/lib/lib/sharedState.js +7 -17
- package/lib/lib/substituteScreenAtRules.js +22 -26
- package/lib/processTailwindFeatures.js +38 -44
- package/lib/public/colors.js +329 -0
- package/lib/public/create-plugin.js +13 -0
- package/lib/public/default-config.js +14 -0
- package/lib/public/default-theme.js +14 -0
- package/lib/public/resolve-config.js +19 -0
- package/lib/util/bigSign.js +3 -5
- package/lib/util/buildMediaQuery.js +15 -31
- package/lib/util/cloneDeep.js +14 -13
- package/lib/util/cloneNodes.js +9 -13
- package/lib/util/color.js +69 -59
- package/lib/util/configurePlugins.js +13 -14
- package/lib/util/createPlugin.js +21 -24
- package/lib/util/createUtilityPlugin.js +47 -45
- package/lib/util/dataTypes.js +231 -0
- package/lib/util/defaults.js +10 -14
- package/lib/util/escapeClassName.js +12 -14
- package/lib/util/escapeCommas.js +3 -5
- package/lib/util/flattenColorPalette.js +14 -10
- package/lib/util/formatVariantSelector.js +186 -0
- package/lib/util/getAllConfigs.js +23 -16
- package/lib/util/hashConfig.js +10 -10
- package/lib/util/isKeyframeRule.js +3 -5
- package/lib/util/isPlainObject.js +7 -10
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +39 -30
- package/lib/util/nameClass.js +23 -23
- package/lib/util/negateValue.js +14 -15
- package/lib/util/normalizeConfig.js +208 -0
- package/lib/util/normalizeScreens.js +58 -0
- package/lib/util/parseAnimationValue.js +82 -53
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/parseDependency.js +49 -60
- package/lib/util/parseObjectStyles.js +23 -20
- package/lib/util/pluginUtils.js +153 -285
- package/lib/util/prefixSelector.js +14 -16
- package/lib/util/resolveConfig.js +194 -249
- package/lib/util/resolveConfigPath.js +38 -45
- package/lib/util/responsive.js +12 -11
- package/lib/util/tap.js +4 -6
- package/lib/util/toColorValue.js +4 -5
- package/lib/util/toPath.js +4 -6
- package/lib/util/transformThemeValue.js +57 -26
- package/lib/util/withAlphaVariable.js +56 -54
- package/package.json +27 -37
- package/peers/index.js +73099 -84294
- package/plugin.js +1 -3
- package/resolveConfig.js +1 -7
- package/scripts/create-plugin-list.js +2 -2
- package/src/cli.js +27 -18
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +2124 -1968
- package/src/css/preflight.css +14 -1
- package/src/featureFlags.js +12 -6
- package/src/lib/collapseDuplicateDeclarations.js +28 -0
- package/src/lib/detectNesting.js +39 -0
- package/src/lib/evaluateTailwindFunctions.js +5 -2
- package/src/lib/expandTailwindAtRules.js +24 -32
- package/src/lib/generateRules.js +230 -20
- package/src/lib/normalizeTailwindDirectives.js +3 -2
- package/src/lib/resolveDefaultsAtRules.js +46 -30
- package/src/lib/setupContextUtils.js +275 -113
- package/src/lib/setupTrackingContext.js +9 -8
- package/src/lib/setupWatchingContext.js +12 -7
- package/src/lib/sharedState.js +1 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/processTailwindFeatures.js +8 -1
- package/src/public/colors.js +300 -0
- package/src/public/create-plugin.js +2 -0
- package/src/public/default-config.js +4 -0
- package/src/public/default-theme.js +4 -0
- package/src/public/resolve-config.js +7 -0
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/createUtilityPlugin.js +2 -11
- package/src/util/dataTypes.js +246 -0
- package/src/util/formatVariantSelector.js +196 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +18 -21
- package/src/util/nameClass.js +10 -6
- package/src/util/negateValue.js +4 -2
- package/src/util/normalizeConfig.js +249 -0
- package/src/util/normalizeScreens.js +42 -0
- package/src/util/parseAnimationValue.js +7 -1
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/parseDependency.js +4 -0
- package/src/util/pluginUtils.js +101 -204
- package/src/util/prefixSelector.js +1 -4
- package/src/util/resolveConfig.js +12 -65
- package/src/util/transformThemeValue.js +22 -7
- package/src/util/withAlphaVariable.js +13 -8
- package/stubs/defaultConfig.stub.js +163 -97
- package/stubs/simpleConfig.stub.js +0 -1
package/src/util/pluginUtils.js
CHANGED
|
@@ -1,36 +1,28 @@
|
|
|
1
1
|
import selectorParser from 'postcss-selector-parser'
|
|
2
2
|
import escapeCommas from './escapeCommas'
|
|
3
3
|
import { withAlphaValue } from './withAlphaVariable'
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return join(`${[marker, ...states].join(':')}`, selector)
|
|
23
|
-
}
|
|
4
|
+
import {
|
|
5
|
+
normalize,
|
|
6
|
+
length,
|
|
7
|
+
number,
|
|
8
|
+
percentage,
|
|
9
|
+
url,
|
|
10
|
+
color as validateColor,
|
|
11
|
+
genericName,
|
|
12
|
+
familyName,
|
|
13
|
+
image,
|
|
14
|
+
absoluteSize,
|
|
15
|
+
relativeSize,
|
|
16
|
+
position,
|
|
17
|
+
lineWidth,
|
|
18
|
+
shadow,
|
|
19
|
+
} from './dataTypes'
|
|
20
|
+
import negateValue from './negateValue'
|
|
24
21
|
|
|
25
22
|
export function updateAllClasses(selectors, updateClass) {
|
|
26
23
|
let parser = selectorParser((selectors) => {
|
|
27
24
|
selectors.walkClasses((sel) => {
|
|
28
|
-
let updatedClass = updateClass(sel.value
|
|
29
|
-
withPseudo(className, pseudo) {
|
|
30
|
-
sel.parent.insertAfter(sel, selectorParser.pseudo({ value: `${pseudo}` }))
|
|
31
|
-
return className
|
|
32
|
-
},
|
|
33
|
-
})
|
|
25
|
+
let updatedClass = updateClass(sel.value)
|
|
34
26
|
sel.value = updatedClass
|
|
35
27
|
if (sel.raws && sel.raws.value) {
|
|
36
28
|
sel.raws.value = escapeCommas(sel.raws.value)
|
|
@@ -43,155 +35,50 @@ export function updateAllClasses(selectors, updateClass) {
|
|
|
43
35
|
return result
|
|
44
36
|
}
|
|
45
37
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
let lastClass = sel.filter(({ type }) => type === 'class').pop()
|
|
50
|
-
|
|
51
|
-
if (lastClass === undefined) {
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
let updatedClass = updateClass(lastClass.value, {
|
|
56
|
-
withPseudo(className, pseudo) {
|
|
57
|
-
lastClass.parent.insertAfter(lastClass, selectorParser.pseudo({ value: `${pseudo}` }))
|
|
58
|
-
return className
|
|
59
|
-
},
|
|
60
|
-
})
|
|
61
|
-
lastClass.value = updatedClass
|
|
62
|
-
if (lastClass.raws && lastClass.raws.value) {
|
|
63
|
-
lastClass.raws.value = escapeCommas(lastClass.raws.value)
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
let result = parser.processSync(selectors)
|
|
68
|
-
|
|
69
|
-
return result
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function splitByNotEscapedCommas(str) {
|
|
73
|
-
let chunks = []
|
|
74
|
-
let currentChunk = ''
|
|
75
|
-
for (let i = 0; i < str.length; i++) {
|
|
76
|
-
if (str[i] === ',' && str[i - 1] !== '\\') {
|
|
77
|
-
chunks.push(currentChunk)
|
|
78
|
-
currentChunk = ''
|
|
79
|
-
} else {
|
|
80
|
-
currentChunk += str[i]
|
|
81
|
-
}
|
|
38
|
+
function resolveArbitraryValue(modifier, validate) {
|
|
39
|
+
if (!isArbitraryValue(modifier)) {
|
|
40
|
+
return undefined
|
|
82
41
|
}
|
|
83
|
-
chunks.push(currentChunk)
|
|
84
|
-
return chunks
|
|
85
|
-
}
|
|
86
42
|
|
|
87
|
-
|
|
88
|
-
return ({ container }) => {
|
|
89
|
-
container.walkRules((rule) => {
|
|
90
|
-
if (isKeyframeRule(rule)) {
|
|
91
|
-
return rule
|
|
92
|
-
}
|
|
93
|
-
let transformed = splitByNotEscapedCommas(rule.selector).map(transformSelector).join(',')
|
|
94
|
-
rule.selector = transformed
|
|
95
|
-
if (withRule) {
|
|
96
|
-
withRule(rule)
|
|
97
|
-
}
|
|
98
|
-
return rule
|
|
99
|
-
})
|
|
43
|
+
let value = modifier.slice(1, -1)
|
|
100
44
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
let nodes = container.nodes
|
|
104
|
-
container.removeAll()
|
|
105
|
-
wrapper.append(nodes)
|
|
106
|
-
container.append(wrapper)
|
|
107
|
-
}
|
|
45
|
+
if (!validate(value)) {
|
|
46
|
+
return undefined
|
|
108
47
|
}
|
|
48
|
+
|
|
49
|
+
return normalize(value)
|
|
109
50
|
}
|
|
110
51
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
container.walkRules((rule) => {
|
|
114
|
-
let selector = rule.selector
|
|
115
|
-
let variantSelector = updateAllClasses(selector, transformClass)
|
|
116
|
-
rule.selector = variantSelector
|
|
117
|
-
if (withRule) {
|
|
118
|
-
withRule(rule)
|
|
119
|
-
}
|
|
120
|
-
return rule
|
|
121
|
-
})
|
|
52
|
+
function asNegativeValue(modifier, lookup = {}, validate) {
|
|
53
|
+
let positiveValue = lookup[modifier]
|
|
122
54
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
let nodes = container.nodes
|
|
126
|
-
container.removeAll()
|
|
127
|
-
wrapper.append(nodes)
|
|
128
|
-
container.append(wrapper)
|
|
129
|
-
}
|
|
55
|
+
if (positiveValue !== undefined) {
|
|
56
|
+
return negateValue(positiveValue)
|
|
130
57
|
}
|
|
131
|
-
}
|
|
132
58
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
container.walkRules((rule) => {
|
|
136
|
-
let selector = rule.selector
|
|
137
|
-
let variantSelector = updateLastClasses(selector, transformClass)
|
|
138
|
-
rule.selector = variantSelector
|
|
139
|
-
if (withRule) {
|
|
140
|
-
withRule(rule)
|
|
141
|
-
}
|
|
142
|
-
return rule
|
|
143
|
-
})
|
|
59
|
+
if (isArbitraryValue(modifier)) {
|
|
60
|
+
let resolved = resolveArbitraryValue(modifier, validate)
|
|
144
61
|
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
let nodes = container.nodes
|
|
148
|
-
container.removeAll()
|
|
149
|
-
wrapper.append(nodes)
|
|
150
|
-
container.append(wrapper)
|
|
62
|
+
if (resolved === undefined) {
|
|
63
|
+
return undefined
|
|
151
64
|
}
|
|
65
|
+
|
|
66
|
+
return negateValue(resolved)
|
|
152
67
|
}
|
|
153
68
|
}
|
|
154
69
|
|
|
155
|
-
export function asValue(modifier,
|
|
156
|
-
let value =
|
|
70
|
+
export function asValue(modifier, options = {}, { validate = () => true } = {}) {
|
|
71
|
+
let value = options.values?.[modifier]
|
|
157
72
|
|
|
158
73
|
if (value !== undefined) {
|
|
159
74
|
return value
|
|
160
75
|
}
|
|
161
76
|
|
|
162
|
-
if (
|
|
163
|
-
return
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
value = modifier.slice(1, -1)
|
|
167
|
-
|
|
168
|
-
if (!validate(value)) {
|
|
169
|
-
return undefined
|
|
77
|
+
if (options.supportsNegativeValues && modifier.startsWith('-')) {
|
|
78
|
+
return asNegativeValue(modifier.slice(1), options.values, validate)
|
|
170
79
|
}
|
|
171
80
|
|
|
172
|
-
|
|
173
|
-
value = value
|
|
174
|
-
.replace(/([^\\])_/g, '$1 ')
|
|
175
|
-
.replace(/^_/g, ' ')
|
|
176
|
-
.replace(/\\_/g, '_')
|
|
177
|
-
|
|
178
|
-
// add spaces around operators inside calc() that do not follow an operator or (
|
|
179
|
-
return value.replace(
|
|
180
|
-
/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g,
|
|
181
|
-
'$1 $2 '
|
|
182
|
-
)
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export function asUnit(modifier, units, lookup = {}) {
|
|
186
|
-
return asValue(modifier, lookup, {
|
|
187
|
-
validate: (value) => {
|
|
188
|
-
let unitsPattern = `(?:${units.join('|')})`
|
|
189
|
-
return (
|
|
190
|
-
new RegExp(`${unitsPattern}$`).test(value) ||
|
|
191
|
-
new RegExp(`^calc\\(.+?${unitsPattern}`).test(value)
|
|
192
|
-
)
|
|
193
|
-
},
|
|
194
|
-
})
|
|
81
|
+
return resolveArbitraryValue(modifier, validate)
|
|
195
82
|
}
|
|
196
83
|
|
|
197
84
|
function isArbitraryValue(input) {
|
|
@@ -208,88 +95,98 @@ function splitAlpha(modifier) {
|
|
|
208
95
|
return [modifier.slice(0, slashIdx), modifier.slice(slashIdx + 1)]
|
|
209
96
|
}
|
|
210
97
|
|
|
211
|
-
export function asColor(modifier,
|
|
212
|
-
if (
|
|
213
|
-
return
|
|
98
|
+
export function asColor(modifier, options = {}, { tailwindConfig = {} } = {}) {
|
|
99
|
+
if (options.values?.[modifier] !== undefined) {
|
|
100
|
+
return options.values?.[modifier]
|
|
214
101
|
}
|
|
215
102
|
|
|
216
103
|
let [color, alpha] = splitAlpha(modifier)
|
|
217
104
|
|
|
218
|
-
if (
|
|
105
|
+
if (alpha !== undefined) {
|
|
106
|
+
let normalizedColor =
|
|
107
|
+
options.values?.[color] ?? (isArbitraryValue(color) ? color.slice(1, -1) : undefined)
|
|
108
|
+
|
|
109
|
+
if (normalizedColor === undefined) {
|
|
110
|
+
return undefined
|
|
111
|
+
}
|
|
112
|
+
|
|
219
113
|
if (isArbitraryValue(alpha)) {
|
|
220
|
-
return withAlphaValue(
|
|
114
|
+
return withAlphaValue(normalizedColor, alpha.slice(1, -1))
|
|
221
115
|
}
|
|
222
116
|
|
|
223
117
|
if (tailwindConfig.theme?.opacity?.[alpha] === undefined) {
|
|
224
118
|
return undefined
|
|
225
119
|
}
|
|
226
120
|
|
|
227
|
-
return withAlphaValue(
|
|
121
|
+
return withAlphaValue(normalizedColor, tailwindConfig.theme.opacity[alpha])
|
|
228
122
|
}
|
|
229
123
|
|
|
230
|
-
return asValue(modifier,
|
|
231
|
-
validate: (value) => parseColor(value) !== null,
|
|
232
|
-
})
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export function asAngle(modifier, lookup = {}) {
|
|
236
|
-
return asUnit(modifier, ['deg', 'grad', 'rad', 'turn'], lookup)
|
|
124
|
+
return asValue(modifier, options, { validate: validateColor })
|
|
237
125
|
}
|
|
238
126
|
|
|
239
|
-
export function
|
|
240
|
-
return
|
|
241
|
-
modifier,
|
|
242
|
-
[
|
|
243
|
-
'cm',
|
|
244
|
-
'mm',
|
|
245
|
-
'Q',
|
|
246
|
-
'in',
|
|
247
|
-
'pc',
|
|
248
|
-
'pt',
|
|
249
|
-
'px',
|
|
250
|
-
'em',
|
|
251
|
-
'ex',
|
|
252
|
-
'ch',
|
|
253
|
-
'rem',
|
|
254
|
-
'lh',
|
|
255
|
-
'vw',
|
|
256
|
-
'vh',
|
|
257
|
-
'vmin',
|
|
258
|
-
'vmax',
|
|
259
|
-
'%',
|
|
260
|
-
],
|
|
261
|
-
lookup
|
|
262
|
-
)
|
|
127
|
+
export function asLookupValue(modifier, options = {}) {
|
|
128
|
+
return options.values?.[modifier]
|
|
263
129
|
}
|
|
264
130
|
|
|
265
|
-
|
|
266
|
-
return
|
|
131
|
+
function guess(validate) {
|
|
132
|
+
return (modifier, options) => {
|
|
133
|
+
return asValue(modifier, options, { validate })
|
|
134
|
+
}
|
|
267
135
|
}
|
|
268
136
|
|
|
269
137
|
let typeMap = {
|
|
270
138
|
any: asValue,
|
|
271
139
|
color: asColor,
|
|
272
|
-
|
|
273
|
-
|
|
140
|
+
url: guess(url),
|
|
141
|
+
image: guess(image),
|
|
142
|
+
length: guess(length),
|
|
143
|
+
percentage: guess(percentage),
|
|
144
|
+
position: guess(position),
|
|
274
145
|
lookup: asLookupValue,
|
|
146
|
+
'generic-name': guess(genericName),
|
|
147
|
+
'family-name': guess(familyName),
|
|
148
|
+
number: guess(number),
|
|
149
|
+
'line-width': guess(lineWidth),
|
|
150
|
+
'absolute-size': guess(absoluteSize),
|
|
151
|
+
'relative-size': guess(relativeSize),
|
|
152
|
+
shadow: guess(shadow),
|
|
275
153
|
}
|
|
276
154
|
|
|
155
|
+
let supportedTypes = Object.keys(typeMap)
|
|
156
|
+
|
|
277
157
|
function splitAtFirst(input, delim) {
|
|
278
|
-
|
|
158
|
+
let idx = input.indexOf(delim)
|
|
159
|
+
if (idx === -1) return [undefined, input]
|
|
160
|
+
return [input.slice(0, idx), input.slice(idx + 1)]
|
|
279
161
|
}
|
|
280
162
|
|
|
281
|
-
export function coerceValue(
|
|
282
|
-
let [scaleType, arbitraryType = scaleType] = [].concat(type)
|
|
283
|
-
|
|
163
|
+
export function coerceValue(types, modifier, options, tailwindConfig) {
|
|
284
164
|
if (isArbitraryValue(modifier)) {
|
|
285
|
-
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
|
+
}
|
|
286
174
|
|
|
287
|
-
|
|
288
|
-
|
|
175
|
+
//
|
|
176
|
+
else if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
|
|
177
|
+
return []
|
|
289
178
|
}
|
|
290
179
|
|
|
291
|
-
|
|
180
|
+
if (value.length > 0 && supportedTypes.includes(explicitType)) {
|
|
181
|
+
return [asValue(`[${value}]`, options), explicitType]
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Find first matching type
|
|
186
|
+
for (let type of [].concat(types)) {
|
|
187
|
+
let result = typeMap[type](modifier, options, { tailwindConfig })
|
|
188
|
+
if (result) return [result, type]
|
|
292
189
|
}
|
|
293
190
|
|
|
294
|
-
return [
|
|
191
|
+
return []
|
|
295
192
|
}
|
|
@@ -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 = `${
|
|
8
|
+
classSelector.value = `${prefix}${baseClass}`
|
|
12
9
|
})
|
|
13
10
|
})
|
|
14
11
|
}).processSync(selector)
|
|
@@ -2,10 +2,10 @@ import negateValue from './negateValue'
|
|
|
2
2
|
import corePluginList from '../corePluginList'
|
|
3
3
|
import configurePlugins from './configurePlugins'
|
|
4
4
|
import defaultConfig from '../../stubs/defaultConfig.stub'
|
|
5
|
-
import colors from '
|
|
6
|
-
import log from './log'
|
|
5
|
+
import colors from '../public/colors'
|
|
7
6
|
import { defaults } from './defaults'
|
|
8
7
|
import { toPath } from './toPath'
|
|
8
|
+
import { normalizeConfig } from './normalizeConfig'
|
|
9
9
|
|
|
10
10
|
function isFunction(input) {
|
|
11
11
|
return typeof input === 'function'
|
|
@@ -40,15 +40,18 @@ function mergeWith(target, ...sources) {
|
|
|
40
40
|
const configUtils = {
|
|
41
41
|
colors,
|
|
42
42
|
negative(scale) {
|
|
43
|
+
// TODO: Log that this function isn't really needed anymore?
|
|
43
44
|
return Object.keys(scale)
|
|
44
45
|
.filter((key) => scale[key] !== '0')
|
|
45
|
-
.reduce(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
.reduce((negativeScale, key) => {
|
|
47
|
+
let negativeValue = negateValue(scale[key])
|
|
48
|
+
|
|
49
|
+
if (negativeValue !== undefined) {
|
|
50
|
+
negativeScale[`-${key}`] = negativeValue
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return negativeScale
|
|
54
|
+
}, {})
|
|
52
55
|
},
|
|
53
56
|
breakpoints(screens) {
|
|
54
57
|
return Object.keys(screens)
|
|
@@ -224,59 +227,3 @@ export default function resolveConfig(configs) {
|
|
|
224
227
|
)
|
|
225
228
|
)
|
|
226
229
|
}
|
|
227
|
-
|
|
228
|
-
let warnedAbout = new Set()
|
|
229
|
-
function normalizeConfig(config) {
|
|
230
|
-
if (!warnedAbout.has('purge-deprecation') && config.hasOwnProperty('purge')) {
|
|
231
|
-
log.warn([
|
|
232
|
-
'The `purge` option in your tailwind.config.js file has been deprecated.',
|
|
233
|
-
'Please rename this to `content` instead.',
|
|
234
|
-
])
|
|
235
|
-
warnedAbout.add('purge-deprecation')
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
config.content = {
|
|
239
|
-
content: (() => {
|
|
240
|
-
let { content, purge } = config
|
|
241
|
-
|
|
242
|
-
if (Array.isArray(purge)) return purge
|
|
243
|
-
if (Array.isArray(purge?.content)) return purge.content
|
|
244
|
-
if (Array.isArray(content)) return content
|
|
245
|
-
if (Array.isArray(content?.content)) return content.content
|
|
246
|
-
|
|
247
|
-
return []
|
|
248
|
-
})(),
|
|
249
|
-
safelist: (() => {
|
|
250
|
-
let { content, purge } = config
|
|
251
|
-
|
|
252
|
-
let [safelistKey, safelistPaths] = (() => {
|
|
253
|
-
if (Array.isArray(content?.safelist)) return ['content.safelist', content.safelist]
|
|
254
|
-
if (Array.isArray(purge?.safelist)) return ['purge.safelist', purge.safelist]
|
|
255
|
-
if (Array.isArray(purge?.options?.safelist))
|
|
256
|
-
return ['purge.options.safelist', purge.options.safelist]
|
|
257
|
-
return [null, []]
|
|
258
|
-
})()
|
|
259
|
-
|
|
260
|
-
return safelistPaths.map((content) => {
|
|
261
|
-
if (typeof content === 'string') {
|
|
262
|
-
return { raw: content, extension: 'html' }
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (content instanceof RegExp) {
|
|
266
|
-
throw new Error(
|
|
267
|
-
`Values inside '${safelistKey}' can only be of type 'string', found 'regex'.`
|
|
268
|
-
)
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
throw new Error(
|
|
272
|
-
`Values inside '${safelistKey}' can only be of type 'string', found '${typeof content}'.`
|
|
273
|
-
)
|
|
274
|
-
})
|
|
275
|
-
})(),
|
|
276
|
-
extract: config.content?.extract || config.purge?.extract || {},
|
|
277
|
-
options: config.content?.options || config.purge?.options || {},
|
|
278
|
-
transform: config.content?.transform || config.purge?.transform || {},
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return config
|
|
282
|
-
}
|
|
@@ -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,28 @@ 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) => {
|
|
48
|
+
if (typeof value === 'function') value = value({})
|
|
49
|
+
|
|
50
|
+
return value
|
|
51
|
+
}
|
|
37
52
|
}
|
|
@@ -15,30 +15,35 @@ export function withAlphaValue(color, alphaValue, defaultValue) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export default function withAlphaVariable({ color, property, variable }) {
|
|
18
|
+
let properties = [].concat(property)
|
|
18
19
|
if (typeof color === 'function') {
|
|
19
20
|
return {
|
|
20
21
|
[variable]: '1',
|
|
21
|
-
|
|
22
|
+
...Object.fromEntries(
|
|
23
|
+
properties.map((p) => {
|
|
24
|
+
return [p, color({ opacityVariable: variable, opacityValue: `var(${variable})` })]
|
|
25
|
+
})
|
|
26
|
+
),
|
|
22
27
|
}
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
const parsed = parseColor(color)
|
|
26
31
|
|
|
27
32
|
if (parsed === null) {
|
|
28
|
-
return
|
|
29
|
-
[property]: color,
|
|
30
|
-
}
|
|
33
|
+
return Object.fromEntries(properties.map((p) => [p, color]))
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
if (parsed.alpha !== undefined) {
|
|
34
37
|
// Has an alpha value, return color as-is
|
|
35
|
-
return
|
|
36
|
-
[property]: color,
|
|
37
|
-
}
|
|
38
|
+
return Object.fromEntries(properties.map((p) => [p, color]))
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
return {
|
|
41
42
|
[variable]: '1',
|
|
42
|
-
|
|
43
|
+
...Object.fromEntries(
|
|
44
|
+
properties.map((p) => {
|
|
45
|
+
return [p, formatColor({ ...parsed, alpha: `var(${variable})` })]
|
|
46
|
+
})
|
|
47
|
+
),
|
|
43
48
|
}
|
|
44
49
|
}
|