tailwindcss 0.0.0-insiders.ff2c25f → 0.0.0-internal.b2586d4e
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/README.md +5 -6
- package/dist/lib.d.mts +339 -0
- package/dist/lib.d.ts +339 -0
- package/dist/lib.js +17 -0
- package/dist/lib.mjs +17 -0
- package/index.css +5 -0
- package/package.json +36 -107
- package/preflight.css +334 -0
- package/theme.css +463 -0
- package/base.css +0 -1
- package/colors.d.ts +0 -3
- package/colors.js +0 -2
- package/components.css +0 -1
- package/defaultConfig.d.ts +0 -3
- package/defaultConfig.js +0 -2
- package/defaultTheme.d.ts +0 -4
- package/defaultTheme.js +0 -2
- package/lib/cli/build/deps.js +0 -54
- package/lib/cli/build/index.js +0 -48
- package/lib/cli/build/plugin.js +0 -367
- package/lib/cli/build/utils.js +0 -78
- package/lib/cli/build/watching.js +0 -178
- package/lib/cli/help/index.js +0 -71
- package/lib/cli/index.js +0 -239
- package/lib/cli/init/index.js +0 -46
- package/lib/cli-peer-dependencies.js +0 -28
- package/lib/cli.js +0 -7
- package/lib/constants.js +0 -44
- package/lib/corePluginList.js +0 -181
- package/lib/corePlugins.js +0 -4062
- package/lib/css/LICENSE +0 -25
- package/lib/css/preflight.css +0 -367
- package/lib/featureFlags.js +0 -71
- package/lib/index.js +0 -6
- package/lib/lib/cacheInvalidation.js +0 -90
- package/lib/lib/collapseAdjacentRules.js +0 -59
- package/lib/lib/collapseDuplicateDeclarations.js +0 -83
- package/lib/lib/content.js +0 -177
- package/lib/lib/defaultExtractor.js +0 -241
- package/lib/lib/detectNesting.js +0 -43
- package/lib/lib/evaluateTailwindFunctions.js +0 -234
- package/lib/lib/expandApplyAtRules.js +0 -526
- package/lib/lib/expandTailwindAtRules.js +0 -273
- package/lib/lib/findAtConfigPath.js +0 -44
- package/lib/lib/generateRules.js +0 -866
- package/lib/lib/getModuleDependencies.js +0 -51
- package/lib/lib/normalizeTailwindDirectives.js +0 -87
- package/lib/lib/offsets.js +0 -299
- package/lib/lib/partitionApplyAtRules.js +0 -56
- package/lib/lib/regex.js +0 -60
- package/lib/lib/remap-bitfield.js +0 -87
- package/lib/lib/resolveDefaultsAtRules.js +0 -161
- package/lib/lib/setupContextUtils.js +0 -1218
- package/lib/lib/setupTrackingContext.js +0 -163
- package/lib/lib/sharedState.js +0 -78
- package/lib/lib/substituteScreenAtRules.js +0 -29
- package/lib/oxide/cli/build/deps.js +0 -81
- package/lib/oxide/cli/build/index.js +0 -47
- package/lib/oxide/cli/build/plugin.js +0 -364
- package/lib/oxide/cli/build/utils.js +0 -77
- package/lib/oxide/cli/build/watching.js +0 -177
- package/lib/oxide/cli/help/index.js +0 -70
- package/lib/oxide/cli/index.js +0 -220
- package/lib/oxide/cli/init/index.js +0 -35
- package/lib/oxide/cli.js +0 -5
- package/lib/oxide/postcss-plugin.js +0 -2
- package/lib/plugin.js +0 -48
- package/lib/postcss-plugins/nesting/README.md +0 -42
- package/lib/postcss-plugins/nesting/index.js +0 -19
- package/lib/postcss-plugins/nesting/plugin.js +0 -87
- package/lib/processTailwindFeatures.js +0 -62
- package/lib/public/colors.js +0 -331
- package/lib/public/create-plugin.js +0 -15
- package/lib/public/default-config.js +0 -16
- package/lib/public/default-theme.js +0 -16
- package/lib/public/resolve-config.js +0 -22
- package/lib/util/bigSign.js +0 -11
- package/lib/util/buildMediaQuery.js +0 -25
- package/lib/util/cloneDeep.js +0 -20
- package/lib/util/cloneNodes.js +0 -32
- package/lib/util/color.js +0 -98
- package/lib/util/configurePlugins.js +0 -21
- package/lib/util/createPlugin.js +0 -30
- package/lib/util/createUtilityPlugin.js +0 -51
- package/lib/util/dataTypes.js +0 -266
- package/lib/util/defaults.js +0 -25
- package/lib/util/escapeClassName.js +0 -22
- package/lib/util/escapeCommas.js +0 -11
- package/lib/util/flattenColorPalette.js +0 -16
- package/lib/util/formatVariantSelector.js +0 -351
- package/lib/util/getAllConfigs.js +0 -48
- package/lib/util/hashConfig.js +0 -19
- package/lib/util/isKeyframeRule.js +0 -11
- package/lib/util/isPlainObject.js +0 -15
- package/lib/util/isSyntacticallyValidPropertyValue.js +0 -72
- package/lib/util/log.js +0 -57
- package/lib/util/nameClass.js +0 -43
- package/lib/util/negateValue.js +0 -34
- package/lib/util/normalizeConfig.js +0 -281
- package/lib/util/normalizeScreens.js +0 -170
- package/lib/util/parseAnimationValue.js +0 -91
- package/lib/util/parseBoxShadowValue.js +0 -84
- package/lib/util/parseDependency.js +0 -45
- package/lib/util/parseGlob.js +0 -34
- package/lib/util/parseObjectStyles.js +0 -34
- package/lib/util/pluginUtils.js +0 -283
- package/lib/util/prefixSelector.js +0 -37
- package/lib/util/removeAlphaVariables.js +0 -29
- package/lib/util/resolveConfig.js +0 -254
- package/lib/util/resolveConfigPath.js +0 -54
- package/lib/util/responsive.js +0 -22
- package/lib/util/splitAtTopLevelOnly.js +0 -43
- package/lib/util/tap.js +0 -12
- package/lib/util/toColorValue.js +0 -11
- package/lib/util/toPath.js +0 -30
- package/lib/util/transformThemeValue.js +0 -71
- package/lib/util/validateConfig.js +0 -24
- package/lib/util/validateFormalSyntax.js +0 -24
- package/lib/util/withAlphaVariable.js +0 -75
- package/nesting/index.js +0 -2
- package/oxide-node-api-shim/index.js +0 -21
- package/oxide-node-api-shim/package.json +0 -5
- package/peers/index.js +0 -79461
- package/plugin.d.ts +0 -11
- package/plugin.js +0 -2
- package/prettier.config.js +0 -19
- package/resolveConfig.d.ts +0 -12
- package/resolveConfig.js +0 -2
- package/screens.css +0 -1
- package/scripts/create-plugin-list.js +0 -10
- package/scripts/generate-types.js +0 -105
- package/scripts/release-channel.js +0 -18
- package/scripts/release-notes.js +0 -21
- package/scripts/swap-engines.js +0 -40
- package/scripts/type-utils.js +0 -27
- package/src/cli/build/deps.js +0 -56
- package/src/cli/build/index.js +0 -49
- package/src/cli/build/plugin.js +0 -439
- package/src/cli/build/utils.js +0 -76
- package/src/cli/build/watching.js +0 -227
- package/src/cli/help/index.js +0 -70
- package/src/cli/index.js +0 -234
- package/src/cli/init/index.js +0 -50
- package/src/cli-peer-dependencies.js +0 -15
- package/src/cli.js +0 -7
- package/src/constants.js +0 -17
- package/src/corePluginList.js +0 -1
- package/src/corePlugins.js +0 -2744
- package/src/css/LICENSE +0 -25
- package/src/css/preflight.css +0 -367
- package/src/featureFlags.js +0 -64
- package/src/index.js +0 -5
- package/src/lib/cacheInvalidation.js +0 -52
- package/src/lib/collapseAdjacentRules.js +0 -58
- package/src/lib/collapseDuplicateDeclarations.js +0 -93
- package/src/lib/content.js +0 -208
- package/src/lib/defaultExtractor.js +0 -217
- package/src/lib/detectNesting.js +0 -47
- package/src/lib/evaluateTailwindFunctions.js +0 -269
- package/src/lib/expandApplyAtRules.js +0 -606
- package/src/lib/expandTailwindAtRules.js +0 -285
- package/src/lib/findAtConfigPath.js +0 -48
- package/src/lib/generateRules.js +0 -899
- package/src/lib/getModuleDependencies.js +0 -39
- package/src/lib/normalizeTailwindDirectives.js +0 -84
- package/src/lib/offsets.js +0 -367
- package/src/lib/partitionApplyAtRules.js +0 -52
- package/src/lib/regex.js +0 -74
- package/src/lib/remap-bitfield.js +0 -82
- package/src/lib/resolveDefaultsAtRules.js +0 -163
- package/src/lib/setupContextUtils.js +0 -1308
- package/src/lib/setupTrackingContext.js +0 -171
- package/src/lib/sharedState.js +0 -67
- package/src/lib/substituteScreenAtRules.js +0 -19
- package/src/oxide/cli/build/deps.ts +0 -91
- package/src/oxide/cli/build/index.ts +0 -47
- package/src/oxide/cli/build/plugin.ts +0 -436
- package/src/oxide/cli/build/utils.ts +0 -74
- package/src/oxide/cli/build/watching.ts +0 -225
- package/src/oxide/cli/help/index.ts +0 -69
- package/src/oxide/cli/index.ts +0 -212
- package/src/oxide/cli/init/index.ts +0 -32
- package/src/oxide/cli.ts +0 -1
- package/src/oxide/postcss-plugin.ts +0 -1
- package/src/plugin.js +0 -47
- package/src/postcss-plugins/nesting/README.md +0 -42
- package/src/postcss-plugins/nesting/index.js +0 -13
- package/src/postcss-plugins/nesting/plugin.js +0 -80
- package/src/processTailwindFeatures.js +0 -58
- package/src/public/colors.js +0 -300
- 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 -22
- package/src/util/cloneDeep.js +0 -11
- package/src/util/cloneNodes.js +0 -28
- package/src/util/color.js +0 -73
- 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 -281
- package/src/util/defaults.js +0 -17
- package/src/util/escapeClassName.js +0 -8
- package/src/util/escapeCommas.js +0 -3
- package/src/util/flattenColorPalette.js +0 -13
- package/src/util/formatVariantSelector.js +0 -412
- package/src/util/getAllConfigs.js +0 -38
- package/src/util/hashConfig.js +0 -5
- package/src/util/isKeyframeRule.js +0 -3
- package/src/util/isPlainObject.js +0 -8
- package/src/util/isSyntacticallyValidPropertyValue.js +0 -61
- package/src/util/log.js +0 -29
- package/src/util/nameClass.js +0 -30
- package/src/util/negateValue.js +0 -24
- package/src/util/normalizeConfig.js +0 -300
- package/src/util/normalizeScreens.js +0 -140
- package/src/util/parseAnimationValue.js +0 -68
- package/src/util/parseBoxShadowValue.js +0 -72
- package/src/util/parseDependency.js +0 -44
- package/src/util/parseGlob.js +0 -24
- package/src/util/parseObjectStyles.js +0 -19
- package/src/util/pluginUtils.js +0 -314
- package/src/util/prefixSelector.js +0 -32
- package/src/util/removeAlphaVariables.js +0 -24
- package/src/util/resolveConfig.js +0 -277
- package/src/util/resolveConfigPath.js +0 -55
- package/src/util/responsive.js +0 -10
- package/src/util/splitAtTopLevelOnly.js +0 -45
- package/src/util/tap.js +0 -4
- package/src/util/toColorValue.js +0 -3
- package/src/util/toPath.js +0 -26
- package/src/util/transformThemeValue.js +0 -62
- package/src/util/validateConfig.js +0 -13
- package/src/util/validateFormalSyntax.js +0 -34
- package/src/util/withAlphaVariable.js +0 -49
- package/stubs/defaultConfig.stub.js +0 -956
- package/stubs/defaultPostCssConfig.stub.js +0 -6
- package/stubs/simpleConfig.stub.js +0 -8
- package/tailwind.css +0 -5
- package/types/config.d.ts +0 -367
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +0 -276
- package/types/generated/corePluginList.d.ts +0 -1
- package/types/generated/default-theme.d.ts +0 -345
- package/types/index.d.ts +0 -7
- package/variants.css +0 -1
package/src/util/pluginUtils.js
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
import selectorParser from 'postcss-selector-parser'
|
|
2
|
-
import escapeCommas from './escapeCommas'
|
|
3
|
-
import { withAlphaValue } from './withAlphaVariable'
|
|
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'
|
|
21
|
-
import { backgroundSize } from './validateFormalSyntax'
|
|
22
|
-
import { flagEnabled } from '../featureFlags.js'
|
|
23
|
-
|
|
24
|
-
export function updateAllClasses(selectors, updateClass) {
|
|
25
|
-
let parser = selectorParser((selectors) => {
|
|
26
|
-
selectors.walkClasses((sel) => {
|
|
27
|
-
let updatedClass = updateClass(sel.value)
|
|
28
|
-
sel.value = updatedClass
|
|
29
|
-
if (sel.raws && sel.raws.value) {
|
|
30
|
-
sel.raws.value = escapeCommas(sel.raws.value)
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
let result = parser.processSync(selectors)
|
|
36
|
-
|
|
37
|
-
return result
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function filterSelectorsForClass(selectors, classCandidate) {
|
|
41
|
-
let parser = selectorParser((selectors) => {
|
|
42
|
-
selectors.each((sel) => {
|
|
43
|
-
const containsClass = sel.nodes.some(
|
|
44
|
-
(node) => node.type === 'class' && node.value === classCandidate
|
|
45
|
-
)
|
|
46
|
-
if (!containsClass) {
|
|
47
|
-
sel.remove()
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
let result = parser.processSync(selectors)
|
|
53
|
-
|
|
54
|
-
return result
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function resolveArbitraryValue(modifier, validate) {
|
|
58
|
-
if (!isArbitraryValue(modifier)) {
|
|
59
|
-
return undefined
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
let value = modifier.slice(1, -1)
|
|
63
|
-
|
|
64
|
-
if (!validate(value)) {
|
|
65
|
-
return undefined
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return normalize(value)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function asNegativeValue(modifier, lookup = {}, validate) {
|
|
72
|
-
let positiveValue = lookup[modifier]
|
|
73
|
-
|
|
74
|
-
if (positiveValue !== undefined) {
|
|
75
|
-
return negateValue(positiveValue)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (isArbitraryValue(modifier)) {
|
|
79
|
-
let resolved = resolveArbitraryValue(modifier, validate)
|
|
80
|
-
|
|
81
|
-
if (resolved === undefined) {
|
|
82
|
-
return undefined
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return negateValue(resolved)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function asValue(modifier, options = {}, { validate = () => true } = {}) {
|
|
90
|
-
let value = options.values?.[modifier]
|
|
91
|
-
|
|
92
|
-
if (value !== undefined) {
|
|
93
|
-
return value
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (options.supportsNegativeValues && modifier.startsWith('-')) {
|
|
97
|
-
return asNegativeValue(modifier.slice(1), options.values, validate)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return resolveArbitraryValue(modifier, validate)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function isArbitraryValue(input) {
|
|
104
|
-
return input.startsWith('[') && input.endsWith(']')
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function splitUtilityModifier(modifier) {
|
|
108
|
-
let slashIdx = modifier.lastIndexOf('/')
|
|
109
|
-
|
|
110
|
-
if (slashIdx === -1 || slashIdx === modifier.length - 1) {
|
|
111
|
-
return [modifier, undefined]
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
let arbitrary = isArbitraryValue(modifier)
|
|
115
|
-
|
|
116
|
-
// The modifier could be of the form `[foo]/[bar]`
|
|
117
|
-
// We want to handle this case properly
|
|
118
|
-
// without affecting `[foo/bar]`
|
|
119
|
-
if (arbitrary && !modifier.includes(']/[')) {
|
|
120
|
-
return [modifier, undefined]
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return [modifier.slice(0, slashIdx), modifier.slice(slashIdx + 1)]
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function parseColorFormat(value) {
|
|
127
|
-
if (typeof value === 'string' && value.includes('<alpha-value>')) {
|
|
128
|
-
let oldValue = value
|
|
129
|
-
|
|
130
|
-
return ({ opacityValue = 1 }) => oldValue.replace('<alpha-value>', opacityValue)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return value
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function unwrapArbitraryModifier(modifier) {
|
|
137
|
-
modifier = modifier.slice(1, -1)
|
|
138
|
-
if (modifier.startsWith('--')) {
|
|
139
|
-
modifier = `var(${modifier})`
|
|
140
|
-
}
|
|
141
|
-
return modifier
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function asColor(modifier, options = {}, { tailwindConfig = {} } = {}) {
|
|
145
|
-
if (options.values?.[modifier] !== undefined) {
|
|
146
|
-
return parseColorFormat(options.values?.[modifier])
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// TODO: Hoist this up to getMatchingTypes or something
|
|
150
|
-
// We do this here because we need the alpha value (if any)
|
|
151
|
-
let [color, alpha] = splitUtilityModifier(modifier)
|
|
152
|
-
|
|
153
|
-
if (alpha !== undefined) {
|
|
154
|
-
let normalizedColor =
|
|
155
|
-
options.values?.[color] ?? (isArbitraryValue(color) ? color.slice(1, -1) : undefined)
|
|
156
|
-
|
|
157
|
-
if (normalizedColor === undefined) {
|
|
158
|
-
return undefined
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
normalizedColor = parseColorFormat(normalizedColor)
|
|
162
|
-
|
|
163
|
-
if (isArbitraryValue(alpha)) {
|
|
164
|
-
return withAlphaValue(normalizedColor, unwrapArbitraryModifier(alpha))
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (tailwindConfig.theme?.opacity?.[alpha] === undefined) {
|
|
168
|
-
return undefined
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return withAlphaValue(normalizedColor, tailwindConfig.theme.opacity[alpha])
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return asValue(modifier, options, { validate: validateColor })
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export function asLookupValue(modifier, options = {}) {
|
|
178
|
-
return options.values?.[modifier]
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function guess(validate) {
|
|
182
|
-
return (modifier, options) => {
|
|
183
|
-
return asValue(modifier, options, { validate })
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export let typeMap = {
|
|
188
|
-
any: asValue,
|
|
189
|
-
color: asColor,
|
|
190
|
-
url: guess(url),
|
|
191
|
-
image: guess(image),
|
|
192
|
-
length: guess(length),
|
|
193
|
-
percentage: guess(percentage),
|
|
194
|
-
position: guess(position),
|
|
195
|
-
lookup: asLookupValue,
|
|
196
|
-
'generic-name': guess(genericName),
|
|
197
|
-
'family-name': guess(familyName),
|
|
198
|
-
number: guess(number),
|
|
199
|
-
'line-width': guess(lineWidth),
|
|
200
|
-
'absolute-size': guess(absoluteSize),
|
|
201
|
-
'relative-size': guess(relativeSize),
|
|
202
|
-
shadow: guess(shadow),
|
|
203
|
-
size: guess(backgroundSize),
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
let supportedTypes = Object.keys(typeMap)
|
|
207
|
-
|
|
208
|
-
function splitAtFirst(input, delim) {
|
|
209
|
-
let idx = input.indexOf(delim)
|
|
210
|
-
if (idx === -1) return [undefined, input]
|
|
211
|
-
return [input.slice(0, idx), input.slice(idx + 1)]
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export function coerceValue(types, modifier, options, tailwindConfig) {
|
|
215
|
-
if (options.values && modifier in options.values) {
|
|
216
|
-
for (let { type } of types ?? []) {
|
|
217
|
-
let result = typeMap[type](modifier, options, {
|
|
218
|
-
tailwindConfig,
|
|
219
|
-
})
|
|
220
|
-
|
|
221
|
-
if (result === undefined) {
|
|
222
|
-
continue
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return [result, type, null]
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (isArbitraryValue(modifier)) {
|
|
230
|
-
let arbitraryValue = modifier.slice(1, -1)
|
|
231
|
-
let [explicitType, value] = splitAtFirst(arbitraryValue, ':')
|
|
232
|
-
|
|
233
|
-
// It could be that this resolves to `url(https` which is not a valid
|
|
234
|
-
// identifier. We currently only support "simple" words with dashes or
|
|
235
|
-
// underscores. E.g.: family-name
|
|
236
|
-
if (!/^[\w-_]+$/g.test(explicitType)) {
|
|
237
|
-
value = arbitraryValue
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
//
|
|
241
|
-
else if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
|
|
242
|
-
return []
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (value.length > 0 && supportedTypes.includes(explicitType)) {
|
|
246
|
-
return [asValue(`[${value}]`, options), explicitType, null]
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
let matches = getMatchingTypes(types, modifier, options, tailwindConfig)
|
|
251
|
-
|
|
252
|
-
// Find first matching type
|
|
253
|
-
for (let match of matches) {
|
|
254
|
-
return match
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return []
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
*
|
|
262
|
-
* @param {{type: string}[]} types
|
|
263
|
-
* @param {string} rawModifier
|
|
264
|
-
* @param {any} options
|
|
265
|
-
* @param {any} tailwindConfig
|
|
266
|
-
* @returns {Iterator<[value: string, type: string, modifier: string | null]>}
|
|
267
|
-
*/
|
|
268
|
-
export function* getMatchingTypes(types, rawModifier, options, tailwindConfig) {
|
|
269
|
-
let modifiersEnabled = flagEnabled(tailwindConfig, 'generalizedModifiers')
|
|
270
|
-
|
|
271
|
-
let [modifier, utilityModifier] = splitUtilityModifier(rawModifier)
|
|
272
|
-
|
|
273
|
-
let canUseUtilityModifier =
|
|
274
|
-
modifiersEnabled &&
|
|
275
|
-
options.modifiers != null &&
|
|
276
|
-
(options.modifiers === 'any' ||
|
|
277
|
-
(typeof options.modifiers === 'object' &&
|
|
278
|
-
((utilityModifier && isArbitraryValue(utilityModifier)) ||
|
|
279
|
-
utilityModifier in options.modifiers)))
|
|
280
|
-
|
|
281
|
-
if (!canUseUtilityModifier) {
|
|
282
|
-
modifier = rawModifier
|
|
283
|
-
utilityModifier = undefined
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (utilityModifier !== undefined && modifier === '') {
|
|
287
|
-
modifier = 'DEFAULT'
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// Check the full value first
|
|
291
|
-
// TODO: Move to asValue… somehow
|
|
292
|
-
if (utilityModifier !== undefined) {
|
|
293
|
-
if (typeof options.modifiers === 'object') {
|
|
294
|
-
let configValue = options.modifiers?.[utilityModifier] ?? null
|
|
295
|
-
if (configValue !== null) {
|
|
296
|
-
utilityModifier = configValue
|
|
297
|
-
} else if (isArbitraryValue(utilityModifier)) {
|
|
298
|
-
utilityModifier = unwrapArbitraryModifier(utilityModifier)
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
for (let { type } of types ?? []) {
|
|
304
|
-
let result = typeMap[type](modifier, options, {
|
|
305
|
-
tailwindConfig,
|
|
306
|
-
})
|
|
307
|
-
|
|
308
|
-
if (result === undefined) {
|
|
309
|
-
continue
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
yield [result, type, utilityModifier ?? null]
|
|
313
|
-
}
|
|
314
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import parser from 'postcss-selector-parser'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @template {string | import('postcss-selector-parser').Root} T
|
|
5
|
-
*
|
|
6
|
-
* Prefix all classes in the selector with the given prefix
|
|
7
|
-
*
|
|
8
|
-
* It can take either a string or a selector AST and will return the same type
|
|
9
|
-
*
|
|
10
|
-
* @param {string} prefix
|
|
11
|
-
* @param {T} selector
|
|
12
|
-
* @param {boolean} prependNegative
|
|
13
|
-
* @returns {T}
|
|
14
|
-
*/
|
|
15
|
-
export default function (prefix, selector, prependNegative = false) {
|
|
16
|
-
if (prefix === '') {
|
|
17
|
-
return selector
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let ast = typeof selector === 'string' ? parser().astSync(selector) : selector
|
|
21
|
-
|
|
22
|
-
ast.walkClasses((classSelector) => {
|
|
23
|
-
let baseClass = classSelector.value
|
|
24
|
-
let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith('-')
|
|
25
|
-
|
|
26
|
-
classSelector.value = shouldPlaceNegativeBeforePrefix
|
|
27
|
-
? `-${prefix}${baseClass.slice(1)}`
|
|
28
|
-
: `${prefix}${baseClass}`
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
return typeof selector === 'string' ? ast.toString() : ast
|
|
32
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This function removes any uses of CSS variables used as an alpha channel
|
|
3
|
-
*
|
|
4
|
-
* This is required for selectors like `:visited` which do not allow
|
|
5
|
-
* changes in opacity or external control using CSS variables.
|
|
6
|
-
*
|
|
7
|
-
* @param {import('postcss').Container} container
|
|
8
|
-
* @param {string[]} toRemove
|
|
9
|
-
*/
|
|
10
|
-
export function removeAlphaVariables(container, toRemove) {
|
|
11
|
-
container.walkDecls((decl) => {
|
|
12
|
-
if (toRemove.includes(decl.prop)) {
|
|
13
|
-
decl.remove()
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
for (let varName of toRemove) {
|
|
19
|
-
if (decl.value.includes(`/ var(${varName})`)) {
|
|
20
|
-
decl.value = decl.value.replace(`/ var(${varName})`, '')
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
}
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
import negateValue from './negateValue'
|
|
2
|
-
import corePluginList from '../corePluginList'
|
|
3
|
-
import configurePlugins from './configurePlugins'
|
|
4
|
-
import colors from '../public/colors'
|
|
5
|
-
import { defaults } from './defaults'
|
|
6
|
-
import { toPath } from './toPath'
|
|
7
|
-
import { normalizeConfig } from './normalizeConfig'
|
|
8
|
-
import isPlainObject from './isPlainObject'
|
|
9
|
-
import { cloneDeep } from './cloneDeep'
|
|
10
|
-
import { parseColorFormat } from './pluginUtils'
|
|
11
|
-
import { withAlphaValue } from './withAlphaVariable'
|
|
12
|
-
import toColorValue from './toColorValue'
|
|
13
|
-
|
|
14
|
-
function isFunction(input) {
|
|
15
|
-
return typeof input === 'function'
|
|
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 (isPlainObject(target[k]) && isPlainObject(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
|
-
// TODO: Log that this function isn't really needed anymore?
|
|
44
|
-
return Object.keys(scale)
|
|
45
|
-
.filter((key) => scale[key] !== '0')
|
|
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
|
-
}, {})
|
|
55
|
-
},
|
|
56
|
-
breakpoints(screens) {
|
|
57
|
-
return Object.keys(screens)
|
|
58
|
-
.filter((key) => typeof screens[key] === 'string')
|
|
59
|
-
.reduce(
|
|
60
|
-
(breakpoints, key) => ({
|
|
61
|
-
...breakpoints,
|
|
62
|
-
[`screen-${key}`]: screens[key],
|
|
63
|
-
}),
|
|
64
|
-
{}
|
|
65
|
-
)
|
|
66
|
-
},
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function value(valueToResolve, ...args) {
|
|
70
|
-
return isFunction(valueToResolve) ? valueToResolve(...args) : valueToResolve
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function collectExtends(items) {
|
|
74
|
-
return items.reduce((merged, { extend }) => {
|
|
75
|
-
return mergeWith(merged, extend, (mergedValue, extendValue) => {
|
|
76
|
-
if (mergedValue === undefined) {
|
|
77
|
-
return [extendValue]
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (Array.isArray(mergedValue)) {
|
|
81
|
-
return [extendValue, ...mergedValue]
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return [extendValue, mergedValue]
|
|
85
|
-
})
|
|
86
|
-
}, {})
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function mergeThemes(themes) {
|
|
90
|
-
return {
|
|
91
|
-
...themes.reduce((merged, theme) => defaults(merged, theme), {}),
|
|
92
|
-
|
|
93
|
-
// In order to resolve n config objects, we combine all of their `extend` properties
|
|
94
|
-
// into arrays instead of objects so they aren't overridden.
|
|
95
|
-
extend: collectExtends(themes),
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function mergeExtensionCustomizer(merged, value) {
|
|
100
|
-
// When we have an array of objects, we do want to merge it
|
|
101
|
-
if (Array.isArray(merged) && isPlainObject(merged[0])) {
|
|
102
|
-
return merged.concat(value)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// When the incoming value is an array, and the existing config is an object, prepend the existing object
|
|
106
|
-
if (Array.isArray(value) && isPlainObject(value[0]) && isPlainObject(merged)) {
|
|
107
|
-
return [merged, ...value]
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Override arrays (for example for font-families, box-shadows, ...)
|
|
111
|
-
if (Array.isArray(value)) {
|
|
112
|
-
return value
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Execute default behaviour
|
|
116
|
-
return undefined
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function mergeExtensions({ extend, ...theme }) {
|
|
120
|
-
return mergeWith(theme, extend, (themeValue, extensions) => {
|
|
121
|
-
// The `extend` property is an array, so we need to check if it contains any functions
|
|
122
|
-
if (!isFunction(themeValue) && !extensions.some(isFunction)) {
|
|
123
|
-
return mergeWith({}, themeValue, ...extensions, mergeExtensionCustomizer)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return (resolveThemePath, utils) =>
|
|
127
|
-
mergeWith(
|
|
128
|
-
{},
|
|
129
|
-
...[themeValue, ...extensions].map((e) => value(e, resolveThemePath, utils)),
|
|
130
|
-
mergeExtensionCustomizer
|
|
131
|
-
)
|
|
132
|
-
})
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
*
|
|
137
|
-
* @param {string} key
|
|
138
|
-
* @return {Iterable<string[] & {alpha: string | undefined}>}
|
|
139
|
-
*/
|
|
140
|
-
function* toPaths(key) {
|
|
141
|
-
let path = toPath(key)
|
|
142
|
-
|
|
143
|
-
if (path.length === 0) {
|
|
144
|
-
return
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
yield path
|
|
148
|
-
|
|
149
|
-
if (Array.isArray(key)) {
|
|
150
|
-
return
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
let pattern = /^(.*?)\s*\/\s*([^/]+)$/
|
|
154
|
-
let matches = key.match(pattern)
|
|
155
|
-
|
|
156
|
-
if (matches !== null) {
|
|
157
|
-
let [, prefix, alpha] = matches
|
|
158
|
-
|
|
159
|
-
let newPath = toPath(prefix)
|
|
160
|
-
newPath.alpha = alpha
|
|
161
|
-
|
|
162
|
-
yield newPath
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function resolveFunctionKeys(object) {
|
|
167
|
-
// theme('colors.red.500 / 0.5') -> ['colors', 'red', '500 / 0', '5]
|
|
168
|
-
|
|
169
|
-
const resolvePath = (key, defaultValue) => {
|
|
170
|
-
for (const path of toPaths(key)) {
|
|
171
|
-
let index = 0
|
|
172
|
-
let val = object
|
|
173
|
-
|
|
174
|
-
while (val !== undefined && val !== null && index < path.length) {
|
|
175
|
-
val = val[path[index++]]
|
|
176
|
-
|
|
177
|
-
let shouldResolveAsFn =
|
|
178
|
-
isFunction(val) && (path.alpha === undefined || index <= path.length - 1)
|
|
179
|
-
|
|
180
|
-
val = shouldResolveAsFn ? val(resolvePath, configUtils) : val
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (val !== undefined) {
|
|
184
|
-
if (path.alpha !== undefined) {
|
|
185
|
-
let normalized = parseColorFormat(val)
|
|
186
|
-
|
|
187
|
-
return withAlphaValue(normalized, path.alpha, toColorValue(normalized))
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (isPlainObject(val)) {
|
|
191
|
-
return cloneDeep(val)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return val
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return defaultValue
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
Object.assign(resolvePath, {
|
|
202
|
-
theme: resolvePath,
|
|
203
|
-
...configUtils,
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
return Object.keys(object).reduce((resolved, key) => {
|
|
207
|
-
resolved[key] = isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key]
|
|
208
|
-
|
|
209
|
-
return resolved
|
|
210
|
-
}, {})
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
function extractPluginConfigs(configs) {
|
|
214
|
-
let allConfigs = []
|
|
215
|
-
|
|
216
|
-
configs.forEach((config) => {
|
|
217
|
-
allConfigs = [...allConfigs, config]
|
|
218
|
-
|
|
219
|
-
const plugins = config?.plugins ?? []
|
|
220
|
-
|
|
221
|
-
if (plugins.length === 0) {
|
|
222
|
-
return
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
plugins.forEach((plugin) => {
|
|
226
|
-
if (plugin.__isOptionsFunction) {
|
|
227
|
-
plugin = plugin()
|
|
228
|
-
}
|
|
229
|
-
allConfigs = [...allConfigs, ...extractPluginConfigs([plugin?.config ?? {}])]
|
|
230
|
-
})
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
return allConfigs
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
function resolveCorePlugins(corePluginConfigs) {
|
|
237
|
-
const result = [...corePluginConfigs].reduceRight((resolved, corePluginConfig) => {
|
|
238
|
-
if (isFunction(corePluginConfig)) {
|
|
239
|
-
return corePluginConfig({ corePlugins: resolved })
|
|
240
|
-
}
|
|
241
|
-
return configurePlugins(corePluginConfig, resolved)
|
|
242
|
-
}, corePluginList)
|
|
243
|
-
|
|
244
|
-
return result
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
function resolvePluginLists(pluginLists) {
|
|
248
|
-
const result = [...pluginLists].reduceRight((resolved, pluginList) => {
|
|
249
|
-
return [...resolved, ...pluginList]
|
|
250
|
-
}, [])
|
|
251
|
-
|
|
252
|
-
return result
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
export default function resolveConfig(configs) {
|
|
256
|
-
let allConfigs = [
|
|
257
|
-
...extractPluginConfigs(configs),
|
|
258
|
-
{
|
|
259
|
-
prefix: '',
|
|
260
|
-
important: false,
|
|
261
|
-
separator: ':',
|
|
262
|
-
},
|
|
263
|
-
]
|
|
264
|
-
|
|
265
|
-
return normalizeConfig(
|
|
266
|
-
defaults(
|
|
267
|
-
{
|
|
268
|
-
theme: resolveFunctionKeys(
|
|
269
|
-
mergeExtensions(mergeThemes(allConfigs.map((t) => t?.theme ?? {})))
|
|
270
|
-
),
|
|
271
|
-
corePlugins: resolveCorePlugins(allConfigs.map((c) => c.corePlugins)),
|
|
272
|
-
plugins: resolvePluginLists(configs.map((c) => c?.plugins ?? [])),
|
|
273
|
-
},
|
|
274
|
-
...allConfigs
|
|
275
|
-
)
|
|
276
|
-
)
|
|
277
|
-
}
|
|
@@ -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