tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.ca7b10e
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/LICENSE +1 -2
- package/README.md +18 -11
- package/dist/chunk-7MHEDNEU.mjs +1 -0
- package/dist/chunk-AZANAYY2.mjs +1 -0
- package/dist/chunk-YTVGJJD3.mjs +12 -0
- package/dist/colors-b_6i0Oi7.d.ts +295 -0
- package/dist/colors.d.mts +295 -0
- package/dist/colors.d.ts +5 -0
- package/dist/colors.js +1 -0
- package/dist/colors.mjs +1 -0
- package/dist/default-theme.d.mts +1147 -0
- package/dist/default-theme.d.ts +1147 -0
- package/dist/default-theme.js +1 -0
- package/dist/default-theme.mjs +1 -0
- package/dist/flatten-color-palette.d.mts +6 -0
- package/dist/flatten-color-palette.d.ts +6 -0
- package/dist/flatten-color-palette.js +1 -0
- package/dist/flatten-color-palette.mjs +1 -0
- package/dist/lib.d.mts +264 -0
- package/dist/lib.d.ts +3 -0
- package/dist/lib.js +33 -0
- package/dist/lib.mjs +22 -0
- package/dist/plugin.d.mts +11 -0
- package/dist/plugin.d.ts +104 -0
- package/dist/plugin.js +1 -0
- package/dist/plugin.mjs +1 -0
- package/dist/resolve-config-BIFUA2FY.d.ts +29 -0
- package/dist/resolve-config-QUZ9b-Gn.d.mts +190 -0
- package/dist/types-B254mqw1.d.mts +98 -0
- package/index.css +866 -0
- package/package.json +73 -100
- package/preflight.css +375 -0
- package/theme.css +453 -0
- package/CHANGELOG.md +0 -1758
- package/base.css +0 -1
- package/colors.js +0 -1
- package/components.css +0 -1
- package/defaultConfig.js +0 -1
- package/defaultTheme.js +0 -1
- package/lib/cli-peer-dependencies.js +0 -15
- package/lib/cli.js +0 -707
- package/lib/constants.js +0 -37
- package/lib/corePluginList.js +0 -169
- package/lib/corePlugins.js +0 -3525
- package/lib/css/LICENSE +0 -25
- package/lib/css/preflight.css +0 -354
- package/lib/featureFlags.js +0 -57
- package/lib/index.js +0 -32
- package/lib/lib/collapseAdjacentRules.js +0 -41
- package/lib/lib/detectNesting.js +0 -19
- package/lib/lib/evaluateTailwindFunctions.js +0 -167
- package/lib/lib/expandApplyAtRules.js +0 -228
- package/lib/lib/expandTailwindAtRules.js +0 -257
- package/lib/lib/generateRules.js +0 -350
- package/lib/lib/getModuleDependencies.js +0 -48
- package/lib/lib/normalizeTailwindDirectives.js +0 -75
- package/lib/lib/resolveDefaultsAtRules.js +0 -128
- package/lib/lib/setupContextUtils.js +0 -791
- package/lib/lib/setupTrackingContext.js +0 -170
- package/lib/lib/setupWatchingContext.js +0 -284
- package/lib/lib/sharedState.js +0 -29
- package/lib/lib/substituteScreenAtRules.js +0 -24
- package/lib/processTailwindFeatures.js +0 -47
- package/lib/public/colors.js +0 -333
- package/lib/public/create-plugin.js +0 -13
- package/lib/public/default-config.js +0 -14
- package/lib/public/default-theme.js +0 -14
- package/lib/public/resolve-config.js +0 -19
- package/lib/util/bigSign.js +0 -8
- package/lib/util/buildMediaQuery.js +0 -31
- package/lib/util/cloneDeep.js +0 -19
- package/lib/util/cloneNodes.js +0 -14
- package/lib/util/color.js +0 -84
- package/lib/util/configurePlugins.js +0 -18
- package/lib/util/createPlugin.js +0 -30
- package/lib/util/createUtilityPlugin.js +0 -53
- package/lib/util/dataTypes.js +0 -202
- package/lib/util/defaults.js +0 -16
- package/lib/util/escapeClassName.js +0 -19
- package/lib/util/escapeCommas.js +0 -8
- package/lib/util/flattenColorPalette.js +0 -19
- package/lib/util/getAllConfigs.js +0 -29
- package/lib/util/hashConfig.js +0 -16
- package/lib/util/isKeyframeRule.js +0 -8
- package/lib/util/isPlainObject.js +0 -12
- package/lib/util/log.js +0 -35
- package/lib/util/nameClass.js +0 -31
- package/lib/util/negateValue.js +0 -17
- package/lib/util/parseAnimationValue.js +0 -89
- package/lib/util/parseDependency.js +0 -63
- package/lib/util/parseObjectStyles.js +0 -31
- package/lib/util/pluginUtils.js +0 -282
- package/lib/util/prefixSelector.js +0 -23
- package/lib/util/resolveConfig.js +0 -293
- package/lib/util/resolveConfigPath.js +0 -52
- package/lib/util/responsive.js +0 -19
- package/lib/util/tap.js +0 -9
- package/lib/util/toColorValue.js +0 -9
- package/lib/util/toPath.js +0 -9
- package/lib/util/transformThemeValue.js +0 -53
- package/lib/util/withAlphaVariable.js +0 -67
- package/nesting/README.md +0 -42
- package/nesting/index.js +0 -12
- package/nesting/plugin.js +0 -41
- package/peers/index.js +0 -77111
- package/plugin.js +0 -1
- package/prettier.config.js +0 -19
- package/resolveConfig.js +0 -1
- package/screens.css +0 -1
- package/scripts/create-plugin-list.js +0 -10
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli-peer-dependencies.js +0 -9
- package/src/cli.js +0 -762
- package/src/constants.js +0 -17
- package/src/corePluginList.js +0 -1
- package/src/corePlugins.js +0 -2382
- package/src/css/LICENSE +0 -25
- package/src/css/preflight.css +0 -354
- package/src/featureFlags.js +0 -48
- package/src/index.js +0 -34
- package/src/lib/collapseAdjacentRules.js +0 -39
- package/src/lib/detectNesting.js +0 -20
- package/src/lib/evaluateTailwindFunctions.js +0 -195
- package/src/lib/expandApplyAtRules.js +0 -251
- package/src/lib/expandTailwindAtRules.js +0 -266
- package/src/lib/generateRules.js +0 -320
- package/src/lib/getModuleDependencies.js +0 -39
- package/src/lib/normalizeTailwindDirectives.js +0 -77
- package/src/lib/resolveDefaultsAtRules.js +0 -125
- package/src/lib/setupContextUtils.js +0 -775
- package/src/lib/setupTrackingContext.js +0 -184
- package/src/lib/setupWatchingContext.js +0 -306
- package/src/lib/sharedState.js +0 -13
- package/src/lib/substituteScreenAtRules.js +0 -16
- package/src/processTailwindFeatures.js +0 -43
- package/src/public/colors.js +0 -305
- package/src/public/create-plugin.js +0 -2
- package/src/public/default-config.js +0 -4
- package/src/public/default-theme.js +0 -4
- package/src/public/resolve-config.js +0 -7
- package/src/util/bigSign.js +0 -3
- package/src/util/buildMediaQuery.js +0 -24
- package/src/util/cloneDeep.js +0 -11
- package/src/util/cloneNodes.js +0 -11
- package/src/util/color.js +0 -56
- package/src/util/configurePlugins.js +0 -23
- package/src/util/createPlugin.js +0 -27
- package/src/util/createUtilityPlugin.js +0 -37
- package/src/util/dataTypes.js +0 -216
- package/src/util/defaults.js +0 -11
- package/src/util/escapeClassName.js +0 -8
- package/src/util/escapeCommas.js +0 -3
- package/src/util/flattenColorPalette.js +0 -13
- package/src/util/getAllConfigs.js +0 -19
- package/src/util/hashConfig.js +0 -5
- package/src/util/isKeyframeRule.js +0 -3
- package/src/util/isPlainObject.js +0 -8
- package/src/util/log.js +0 -28
- package/src/util/nameClass.js +0 -26
- package/src/util/negateValue.js +0 -14
- package/src/util/parseAnimationValue.js +0 -68
- package/src/util/parseDependency.js +0 -49
- package/src/util/parseObjectStyles.js +0 -19
- package/src/util/pluginUtils.js +0 -288
- package/src/util/prefixSelector.js +0 -15
- package/src/util/resolveConfig.js +0 -282
- package/src/util/resolveConfigPath.js +0 -55
- package/src/util/responsive.js +0 -10
- package/src/util/tap.js +0 -4
- package/src/util/toColorValue.js +0 -3
- package/src/util/toPath.js +0 -4
- package/src/util/transformThemeValue.js +0 -37
- package/src/util/withAlphaVariable.js +0 -49
- package/stubs/defaultConfig.stub.js +0 -890
- package/stubs/defaultPostCssConfig.stub.js +0 -6
- package/stubs/simpleConfig.stub.js +0 -8
- package/tailwind.css +0 -5
- package/variants.css +0 -1
package/src/util/pluginUtils.js
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import selectorParser from 'postcss-selector-parser'
|
|
2
|
-
import escapeCommas from './escapeCommas'
|
|
3
|
-
import { withAlphaValue } from './withAlphaVariable'
|
|
4
|
-
import isKeyframeRule from './isKeyframeRule'
|
|
5
|
-
import {
|
|
6
|
-
normalize,
|
|
7
|
-
length,
|
|
8
|
-
number,
|
|
9
|
-
percentage,
|
|
10
|
-
url,
|
|
11
|
-
color as validateColor,
|
|
12
|
-
genericName,
|
|
13
|
-
familyName,
|
|
14
|
-
image,
|
|
15
|
-
absoluteSize,
|
|
16
|
-
relativeSize,
|
|
17
|
-
position,
|
|
18
|
-
lineWidth,
|
|
19
|
-
} from './dataTypes'
|
|
20
|
-
|
|
21
|
-
export function applyStateToMarker(selector, marker, state, join) {
|
|
22
|
-
let markerIdx = selector.search(new RegExp(`${marker}[:[]`))
|
|
23
|
-
|
|
24
|
-
if (markerIdx === -1) {
|
|
25
|
-
return join(marker + state, selector)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let markerSelector = selector.slice(markerIdx, selector.indexOf(' ', markerIdx))
|
|
29
|
-
|
|
30
|
-
return join(
|
|
31
|
-
marker + state + markerSelector.slice(markerIdx + marker.length),
|
|
32
|
-
selector.replace(markerSelector, '')
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function updateAllClasses(selectors, updateClass) {
|
|
37
|
-
let parser = selectorParser((selectors) => {
|
|
38
|
-
selectors.walkClasses((sel) => {
|
|
39
|
-
let updatedClass = updateClass(sel.value, {
|
|
40
|
-
withAttr(className, attr) {
|
|
41
|
-
sel.parent.insertAfter(sel, selectorParser.attribute({ attribute: attr.slice(1, -1) }))
|
|
42
|
-
return className
|
|
43
|
-
},
|
|
44
|
-
withPseudo(className, pseudo) {
|
|
45
|
-
sel.parent.insertAfter(sel, selectorParser.pseudo({ value: pseudo }))
|
|
46
|
-
return className
|
|
47
|
-
},
|
|
48
|
-
})
|
|
49
|
-
sel.value = updatedClass
|
|
50
|
-
if (sel.raws && sel.raws.value) {
|
|
51
|
-
sel.raws.value = escapeCommas(sel.raws.value)
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
let result = parser.processSync(selectors)
|
|
57
|
-
|
|
58
|
-
return result
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function updateLastClasses(selectors, updateClass) {
|
|
62
|
-
let parser = selectorParser((selectors) => {
|
|
63
|
-
selectors.each((sel) => {
|
|
64
|
-
let lastClass = sel.filter(({ type }) => type === 'class').pop()
|
|
65
|
-
|
|
66
|
-
if (lastClass === undefined) {
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
let updatedClass = updateClass(lastClass.value, {
|
|
71
|
-
withPseudo(className, pseudo) {
|
|
72
|
-
lastClass.parent.insertAfter(lastClass, selectorParser.pseudo({ value: `${pseudo}` }))
|
|
73
|
-
return className
|
|
74
|
-
},
|
|
75
|
-
})
|
|
76
|
-
lastClass.value = updatedClass
|
|
77
|
-
if (lastClass.raws && lastClass.raws.value) {
|
|
78
|
-
lastClass.raws.value = escapeCommas(lastClass.raws.value)
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
})
|
|
82
|
-
let result = parser.processSync(selectors)
|
|
83
|
-
|
|
84
|
-
return result
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function splitByNotEscapedCommas(str) {
|
|
88
|
-
let chunks = []
|
|
89
|
-
let currentChunk = ''
|
|
90
|
-
for (let i = 0; i < str.length; i++) {
|
|
91
|
-
if (str[i] === ',' && str[i - 1] !== '\\') {
|
|
92
|
-
chunks.push(currentChunk)
|
|
93
|
-
currentChunk = ''
|
|
94
|
-
} else {
|
|
95
|
-
currentChunk += str[i]
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
chunks.push(currentChunk)
|
|
99
|
-
return chunks
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function transformAllSelectors(transformSelector, { wrap, withRule } = {}) {
|
|
103
|
-
return ({ container }) => {
|
|
104
|
-
container.walkRules((rule) => {
|
|
105
|
-
if (isKeyframeRule(rule)) {
|
|
106
|
-
return rule
|
|
107
|
-
}
|
|
108
|
-
let transformed = splitByNotEscapedCommas(rule.selector).map(transformSelector).join(',')
|
|
109
|
-
rule.selector = transformed
|
|
110
|
-
if (withRule) {
|
|
111
|
-
withRule(rule)
|
|
112
|
-
}
|
|
113
|
-
return rule
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
if (wrap) {
|
|
117
|
-
let wrapper = wrap()
|
|
118
|
-
let nodes = container.nodes
|
|
119
|
-
container.removeAll()
|
|
120
|
-
wrapper.append(nodes)
|
|
121
|
-
container.append(wrapper)
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function transformAllClasses(transformClass, { wrap, withRule } = {}) {
|
|
127
|
-
return ({ container }) => {
|
|
128
|
-
container.walkRules((rule) => {
|
|
129
|
-
let selector = rule.selector
|
|
130
|
-
let variantSelector = updateAllClasses(selector, transformClass)
|
|
131
|
-
rule.selector = variantSelector
|
|
132
|
-
if (withRule) {
|
|
133
|
-
withRule(rule)
|
|
134
|
-
}
|
|
135
|
-
return rule
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
if (wrap) {
|
|
139
|
-
let wrapper = wrap()
|
|
140
|
-
let nodes = container.nodes
|
|
141
|
-
container.removeAll()
|
|
142
|
-
wrapper.append(nodes)
|
|
143
|
-
container.append(wrapper)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export function transformLastClasses(transformClass, { wrap, withRule } = {}) {
|
|
149
|
-
return ({ container }) => {
|
|
150
|
-
container.walkRules((rule) => {
|
|
151
|
-
let selector = rule.selector
|
|
152
|
-
let variantSelector = updateLastClasses(selector, transformClass)
|
|
153
|
-
rule.selector = variantSelector
|
|
154
|
-
if (withRule) {
|
|
155
|
-
withRule(rule)
|
|
156
|
-
}
|
|
157
|
-
return rule
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
if (wrap) {
|
|
161
|
-
let wrapper = wrap()
|
|
162
|
-
let nodes = container.nodes
|
|
163
|
-
container.removeAll()
|
|
164
|
-
wrapper.append(nodes)
|
|
165
|
-
container.append(wrapper)
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export function asValue(modifier, lookup = {}, { validate = () => true } = {}) {
|
|
171
|
-
let value = lookup[modifier]
|
|
172
|
-
|
|
173
|
-
if (value !== undefined) {
|
|
174
|
-
return value
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (!isArbitraryValue(modifier)) {
|
|
178
|
-
return undefined
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
value = modifier.slice(1, -1)
|
|
182
|
-
|
|
183
|
-
if (!validate(value)) {
|
|
184
|
-
return undefined
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return normalize(value)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function isArbitraryValue(input) {
|
|
191
|
-
return input.startsWith('[') && input.endsWith(']')
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function splitAlpha(modifier) {
|
|
195
|
-
let slashIdx = modifier.lastIndexOf('/')
|
|
196
|
-
|
|
197
|
-
if (slashIdx === -1 || slashIdx === modifier.length - 1) {
|
|
198
|
-
return [modifier]
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return [modifier.slice(0, slashIdx), modifier.slice(slashIdx + 1)]
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export function asColor(modifier, lookup = {}, tailwindConfig = {}) {
|
|
205
|
-
if (lookup[modifier] !== undefined) {
|
|
206
|
-
return lookup[modifier]
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
let [color, alpha] = splitAlpha(modifier)
|
|
210
|
-
|
|
211
|
-
if (alpha !== undefined) {
|
|
212
|
-
let normalizedColor =
|
|
213
|
-
lookup[color] ?? (isArbitraryValue(color) ? color.slice(1, -1) : undefined)
|
|
214
|
-
|
|
215
|
-
if (normalizedColor === undefined) {
|
|
216
|
-
return undefined
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if (isArbitraryValue(alpha)) {
|
|
220
|
-
return withAlphaValue(normalizedColor, alpha.slice(1, -1))
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (tailwindConfig.theme?.opacity?.[alpha] === undefined) {
|
|
224
|
-
return undefined
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return withAlphaValue(normalizedColor, tailwindConfig.theme.opacity[alpha])
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return asValue(modifier, lookup, { validate: validateColor })
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export function asLookupValue(modifier, lookup = {}) {
|
|
234
|
-
return lookup[modifier]
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function guess(validate) {
|
|
238
|
-
return (modifier, lookup) => {
|
|
239
|
-
return asValue(modifier, lookup, { validate })
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
let typeMap = {
|
|
244
|
-
any: asValue,
|
|
245
|
-
color: asColor,
|
|
246
|
-
url: guess(url),
|
|
247
|
-
image: guess(image),
|
|
248
|
-
length: guess(length),
|
|
249
|
-
percentage: guess(percentage),
|
|
250
|
-
position: guess(position),
|
|
251
|
-
lookup: asLookupValue,
|
|
252
|
-
'generic-name': guess(genericName),
|
|
253
|
-
'family-name': guess(familyName),
|
|
254
|
-
number: guess(number),
|
|
255
|
-
'line-width': guess(lineWidth),
|
|
256
|
-
'absolute-size': guess(absoluteSize),
|
|
257
|
-
'relative-size': guess(relativeSize),
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
let supportedTypes = Object.keys(typeMap)
|
|
261
|
-
|
|
262
|
-
function splitAtFirst(input, delim) {
|
|
263
|
-
let idx = input.indexOf(delim)
|
|
264
|
-
if (idx === -1) return [undefined, input]
|
|
265
|
-
return [input.slice(0, idx), input.slice(idx + 1)]
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
export function coerceValue(types, modifier, values, tailwindConfig) {
|
|
269
|
-
if (isArbitraryValue(modifier)) {
|
|
270
|
-
let [explicitType, value] = splitAtFirst(modifier.slice(1, -1), ':')
|
|
271
|
-
|
|
272
|
-
if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
|
|
273
|
-
return []
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
if (value.length > 0 && supportedTypes.includes(explicitType)) {
|
|
277
|
-
return [asValue(`[${value}]`, values, tailwindConfig), explicitType]
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// Find first matching type
|
|
282
|
-
for (let type of [].concat(types)) {
|
|
283
|
-
let result = typeMap[type](modifier, values, tailwindConfig)
|
|
284
|
-
if (result) return [result, type]
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return []
|
|
288
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
return parser((selectors) => {
|
|
9
|
-
selectors.walkClasses((classSelector) => {
|
|
10
|
-
tap(classSelector.value, (baseClass) => {
|
|
11
|
-
classSelector.value = `${getPrefix('.' + baseClass)}${baseClass}`
|
|
12
|
-
})
|
|
13
|
-
})
|
|
14
|
-
}).processSync(selector)
|
|
15
|
-
}
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import negateValue from './negateValue'
|
|
2
|
-
import corePluginList from '../corePluginList'
|
|
3
|
-
import configurePlugins from './configurePlugins'
|
|
4
|
-
import defaultConfig from '../../stubs/defaultConfig.stub'
|
|
5
|
-
import colors from '../public/colors'
|
|
6
|
-
import log from './log'
|
|
7
|
-
import { defaults } from './defaults'
|
|
8
|
-
import { toPath } from './toPath'
|
|
9
|
-
|
|
10
|
-
function isFunction(input) {
|
|
11
|
-
return typeof input === 'function'
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function isObject(input) {
|
|
15
|
-
return typeof input === 'object' && input !== null
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function mergeWith(target, ...sources) {
|
|
19
|
-
let customizer = sources.pop()
|
|
20
|
-
|
|
21
|
-
for (let source of sources) {
|
|
22
|
-
for (let k in source) {
|
|
23
|
-
let merged = customizer(target[k], source[k])
|
|
24
|
-
|
|
25
|
-
if (merged === undefined) {
|
|
26
|
-
if (isObject(target[k]) && isObject(source[k])) {
|
|
27
|
-
target[k] = mergeWith(target[k], source[k], customizer)
|
|
28
|
-
} else {
|
|
29
|
-
target[k] = source[k]
|
|
30
|
-
}
|
|
31
|
-
} else {
|
|
32
|
-
target[k] = merged
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return target
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const configUtils = {
|
|
41
|
-
colors,
|
|
42
|
-
negative(scale) {
|
|
43
|
-
return Object.keys(scale)
|
|
44
|
-
.filter((key) => scale[key] !== '0')
|
|
45
|
-
.reduce(
|
|
46
|
-
(negativeScale, key) => ({
|
|
47
|
-
...negativeScale,
|
|
48
|
-
[`-${key}`]: negateValue(scale[key]),
|
|
49
|
-
}),
|
|
50
|
-
{}
|
|
51
|
-
)
|
|
52
|
-
},
|
|
53
|
-
breakpoints(screens) {
|
|
54
|
-
return Object.keys(screens)
|
|
55
|
-
.filter((key) => typeof screens[key] === 'string')
|
|
56
|
-
.reduce(
|
|
57
|
-
(breakpoints, key) => ({
|
|
58
|
-
...breakpoints,
|
|
59
|
-
[`screen-${key}`]: screens[key],
|
|
60
|
-
}),
|
|
61
|
-
{}
|
|
62
|
-
)
|
|
63
|
-
},
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function value(valueToResolve, ...args) {
|
|
67
|
-
return isFunction(valueToResolve) ? valueToResolve(...args) : valueToResolve
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function collectExtends(items) {
|
|
71
|
-
return items.reduce((merged, { extend }) => {
|
|
72
|
-
return mergeWith(merged, extend, (mergedValue, extendValue) => {
|
|
73
|
-
if (mergedValue === undefined) {
|
|
74
|
-
return [extendValue]
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (Array.isArray(mergedValue)) {
|
|
78
|
-
return [extendValue, ...mergedValue]
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return [extendValue, mergedValue]
|
|
82
|
-
})
|
|
83
|
-
}, {})
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function mergeThemes(themes) {
|
|
87
|
-
return {
|
|
88
|
-
...themes.reduce((merged, theme) => defaults(merged, theme), {}),
|
|
89
|
-
|
|
90
|
-
// In order to resolve n config objects, we combine all of their `extend` properties
|
|
91
|
-
// into arrays instead of objects so they aren't overridden.
|
|
92
|
-
extend: collectExtends(themes),
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function mergeExtensionCustomizer(merged, value) {
|
|
97
|
-
// When we have an array of objects, we do want to merge it
|
|
98
|
-
if (Array.isArray(merged) && isObject(merged[0])) {
|
|
99
|
-
return merged.concat(value)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// When the incoming value is an array, and the existing config is an object, prepend the existing object
|
|
103
|
-
if (Array.isArray(value) && isObject(value[0]) && isObject(merged)) {
|
|
104
|
-
return [merged, ...value]
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Override arrays (for example for font-families, box-shadows, ...)
|
|
108
|
-
if (Array.isArray(value)) {
|
|
109
|
-
return value
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Execute default behaviour
|
|
113
|
-
return undefined
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function mergeExtensions({ extend, ...theme }) {
|
|
117
|
-
return mergeWith(theme, extend, (themeValue, extensions) => {
|
|
118
|
-
// The `extend` property is an array, so we need to check if it contains any functions
|
|
119
|
-
if (!isFunction(themeValue) && !extensions.some(isFunction)) {
|
|
120
|
-
return mergeWith({}, themeValue, ...extensions, mergeExtensionCustomizer)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return (resolveThemePath, utils) =>
|
|
124
|
-
mergeWith(
|
|
125
|
-
{},
|
|
126
|
-
...[themeValue, ...extensions].map((e) => value(e, resolveThemePath, utils)),
|
|
127
|
-
mergeExtensionCustomizer
|
|
128
|
-
)
|
|
129
|
-
})
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function resolveFunctionKeys(object) {
|
|
133
|
-
const resolvePath = (key, defaultValue) => {
|
|
134
|
-
const path = toPath(key)
|
|
135
|
-
|
|
136
|
-
let index = 0
|
|
137
|
-
let val = object
|
|
138
|
-
|
|
139
|
-
while (val !== undefined && val !== null && index < path.length) {
|
|
140
|
-
val = val[path[index++]]
|
|
141
|
-
val = isFunction(val) ? val(resolvePath, configUtils) : val
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return val === undefined ? defaultValue : val
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
resolvePath.theme = resolvePath
|
|
148
|
-
|
|
149
|
-
for (let key in configUtils) {
|
|
150
|
-
resolvePath[key] = configUtils[key]
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return Object.keys(object).reduce((resolved, key) => {
|
|
154
|
-
return {
|
|
155
|
-
...resolved,
|
|
156
|
-
[key]: isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key],
|
|
157
|
-
}
|
|
158
|
-
}, {})
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function extractPluginConfigs(configs) {
|
|
162
|
-
let allConfigs = []
|
|
163
|
-
|
|
164
|
-
configs.forEach((config) => {
|
|
165
|
-
allConfigs = [...allConfigs, config]
|
|
166
|
-
|
|
167
|
-
const plugins = config?.plugins ?? []
|
|
168
|
-
|
|
169
|
-
if (plugins.length === 0) {
|
|
170
|
-
return
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
plugins.forEach((plugin) => {
|
|
174
|
-
if (plugin.__isOptionsFunction) {
|
|
175
|
-
plugin = plugin()
|
|
176
|
-
}
|
|
177
|
-
allConfigs = [...allConfigs, ...extractPluginConfigs([plugin?.config ?? {}])]
|
|
178
|
-
})
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
return allConfigs
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function resolveCorePlugins(corePluginConfigs) {
|
|
185
|
-
const result = [...corePluginConfigs].reduceRight((resolved, corePluginConfig) => {
|
|
186
|
-
if (isFunction(corePluginConfig)) {
|
|
187
|
-
return corePluginConfig({ corePlugins: resolved })
|
|
188
|
-
}
|
|
189
|
-
return configurePlugins(corePluginConfig, resolved)
|
|
190
|
-
}, corePluginList)
|
|
191
|
-
|
|
192
|
-
return result
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function resolvePluginLists(pluginLists) {
|
|
196
|
-
const result = [...pluginLists].reduceRight((resolved, pluginList) => {
|
|
197
|
-
return [...resolved, ...pluginList]
|
|
198
|
-
}, [])
|
|
199
|
-
|
|
200
|
-
return result
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export default function resolveConfig(configs) {
|
|
204
|
-
let allConfigs = [
|
|
205
|
-
...extractPluginConfigs(configs),
|
|
206
|
-
{
|
|
207
|
-
prefix: '',
|
|
208
|
-
important: false,
|
|
209
|
-
separator: ':',
|
|
210
|
-
variantOrder: defaultConfig.variantOrder,
|
|
211
|
-
},
|
|
212
|
-
]
|
|
213
|
-
|
|
214
|
-
return normalizeConfig(
|
|
215
|
-
defaults(
|
|
216
|
-
{
|
|
217
|
-
theme: resolveFunctionKeys(
|
|
218
|
-
mergeExtensions(mergeThemes(allConfigs.map((t) => t?.theme ?? {})))
|
|
219
|
-
),
|
|
220
|
-
corePlugins: resolveCorePlugins(allConfigs.map((c) => c.corePlugins)),
|
|
221
|
-
plugins: resolvePluginLists(configs.map((c) => c?.plugins ?? [])),
|
|
222
|
-
},
|
|
223
|
-
...allConfigs
|
|
224
|
-
)
|
|
225
|
-
)
|
|
226
|
-
}
|
|
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
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
|
|
4
|
-
function isObject(value) {
|
|
5
|
-
return typeof value === 'object' && value !== null
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function isEmpty(obj) {
|
|
9
|
-
return Object.keys(obj).length === 0
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function isString(value) {
|
|
13
|
-
return typeof value === 'string' || value instanceof String
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default function resolveConfigPath(pathOrConfig) {
|
|
17
|
-
// require('tailwindcss')({ theme: ..., variants: ... })
|
|
18
|
-
if (isObject(pathOrConfig) && pathOrConfig.config === undefined && !isEmpty(pathOrConfig)) {
|
|
19
|
-
return null
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// require('tailwindcss')({ config: 'custom-config.js' })
|
|
23
|
-
if (
|
|
24
|
-
isObject(pathOrConfig) &&
|
|
25
|
-
pathOrConfig.config !== undefined &&
|
|
26
|
-
isString(pathOrConfig.config)
|
|
27
|
-
) {
|
|
28
|
-
return path.resolve(pathOrConfig.config)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// require('tailwindcss')({ config: { theme: ..., variants: ... } })
|
|
32
|
-
if (
|
|
33
|
-
isObject(pathOrConfig) &&
|
|
34
|
-
pathOrConfig.config !== undefined &&
|
|
35
|
-
isObject(pathOrConfig.config)
|
|
36
|
-
) {
|
|
37
|
-
return null
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// require('tailwindcss')('custom-config.js')
|
|
41
|
-
if (isString(pathOrConfig)) {
|
|
42
|
-
return path.resolve(pathOrConfig)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// require('tailwindcss')
|
|
46
|
-
for (const configFile of ['./tailwind.config.js', './tailwind.config.cjs']) {
|
|
47
|
-
try {
|
|
48
|
-
const configPath = path.resolve(configFile)
|
|
49
|
-
fs.accessSync(configPath)
|
|
50
|
-
return configPath
|
|
51
|
-
} catch (err) {}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return null
|
|
55
|
-
}
|
package/src/util/responsive.js
DELETED
package/src/util/tap.js
DELETED
package/src/util/toColorValue.js
DELETED
package/src/util/toPath.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import postcss from 'postcss'
|
|
2
|
-
|
|
3
|
-
export default function transformThemeValue(themeSection) {
|
|
4
|
-
if (['fontSize', 'outline'].includes(themeSection)) {
|
|
5
|
-
return (value) => (Array.isArray(value) ? value[0] : value)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
[
|
|
10
|
-
'fontFamily',
|
|
11
|
-
'boxShadow',
|
|
12
|
-
'transitionProperty',
|
|
13
|
-
'transitionDuration',
|
|
14
|
-
'transitionDelay',
|
|
15
|
-
'transitionTimingFunction',
|
|
16
|
-
'backgroundImage',
|
|
17
|
-
'backgroundSize',
|
|
18
|
-
'backgroundColor',
|
|
19
|
-
'cursor',
|
|
20
|
-
'animation',
|
|
21
|
-
].includes(themeSection)
|
|
22
|
-
) {
|
|
23
|
-
return (value) => (Array.isArray(value) ? value.join(', ') : value)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// For backwards compatibility reasons, before we switched to underscores
|
|
27
|
-
// instead of commas for arbitrary values.
|
|
28
|
-
if (['gridTemplateColumns', 'gridTemplateRows', 'objectPosition'].includes(themeSection)) {
|
|
29
|
-
return (value) => (typeof value === 'string' ? postcss.list.comma(value).join(' ') : value)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (themeSection === 'colors') {
|
|
33
|
-
return (value) => (typeof value === 'function' ? value({}) : value)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return (value) => value
|
|
37
|
-
}
|