tailwindcss 3.1.5 → 3.1.8
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 +36 -8
- package/README.md +6 -3
- package/lib/cli-peer-dependencies.js +12 -4
- package/lib/cli.js +78 -75
- package/lib/constants.js +19 -12
- package/lib/corePluginList.js +5 -3
- package/lib/corePlugins.js +194 -187
- package/lib/featureFlags.js +14 -7
- package/lib/index.js +9 -6
- package/lib/lib/cacheInvalidation.js +18 -15
- package/lib/lib/collapseAdjacentRules.js +14 -11
- package/lib/lib/collapseDuplicateDeclarations.js +11 -8
- package/lib/lib/defaultExtractor.js +38 -35
- package/lib/lib/detectNesting.js +4 -1
- package/lib/lib/evaluateTailwindFunctions.js +75 -44
- package/lib/lib/expandApplyAtRules.js +50 -42
- package/lib/lib/expandTailwindAtRules.js +153 -150
- package/lib/lib/generateRules.js +81 -73
- package/lib/lib/getModuleDependencies.js +21 -18
- package/lib/lib/normalizeTailwindDirectives.js +10 -7
- package/lib/lib/partitionApplyAtRules.js +14 -11
- package/lib/lib/regex.js +15 -7
- package/lib/lib/resolveDefaultsAtRules.js +92 -85
- package/lib/lib/setupContextUtils.js +109 -97
- package/lib/lib/setupTrackingContext.js +82 -75
- package/lib/lib/sharedState.js +15 -8
- package/lib/lib/substituteScreenAtRules.js +8 -5
- package/lib/postcss-plugins/nesting/index.js +7 -5
- package/lib/postcss-plugins/nesting/plugin.js +7 -4
- package/lib/processTailwindFeatures.js +34 -31
- package/lib/public/colors.js +6 -4
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +13 -10
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +5 -2
- package/lib/util/cloneDeep.js +4 -1
- package/lib/util/cloneNodes.js +9 -2
- package/lib/util/color.js +11 -3
- package/lib/util/configurePlugins.js +4 -1
- package/lib/util/createPlugin.js +5 -3
- package/lib/util/createUtilityPlugin.js +13 -10
- package/lib/util/dataTypes.js +27 -19
- package/lib/util/defaults.js +4 -1
- package/lib/util/escapeClassName.js +12 -9
- package/lib/util/escapeCommas.js +4 -1
- package/lib/util/flattenColorPalette.js +5 -3
- package/lib/util/formatVariantSelector.js +21 -14
- package/lib/util/getAllConfigs.js +12 -9
- package/lib/util/hashConfig.js +10 -7
- package/lib/util/isKeyframeRule.js +4 -1
- package/lib/util/isPlainObject.js +4 -1
- package/lib/util/isValidArbitraryValue.js +33 -24
- package/lib/util/log.js +12 -5
- package/lib/util/nameClass.js +16 -8
- package/lib/util/negateValue.js +4 -1
- package/lib/util/normalizeConfig.js +26 -23
- package/lib/util/normalizeScreens.js +17 -2
- package/lib/util/parseAnimationValue.js +42 -39
- package/lib/util/parseBoxShadowValue.js +12 -4
- package/lib/util/parseDependency.js +35 -32
- package/lib/util/parseObjectStyles.js +14 -11
- package/lib/util/pluginUtils.js +28 -20
- package/lib/util/prefixSelector.js +6 -3
- package/lib/util/removeAlphaVariables.js +13 -2
- package/lib/util/resolveConfig.js +56 -53
- package/lib/util/resolveConfigPath.js +20 -17
- package/lib/util/responsive.js +12 -9
- package/lib/util/splitAtTopLevelOnly.js +16 -13
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +4 -1
- package/lib/util/toPath.js +18 -2
- package/lib/util/transformThemeValue.js +10 -7
- package/lib/util/validateConfig.js +5 -2
- package/lib/util/withAlphaVariable.js +30 -22
- package/package.json +10 -10
- package/peers/index.js +950 -825
- package/resolveConfig.d.ts +3 -0
- package/src/lib/evaluateTailwindFunctions.js +41 -15
- package/src/lib/expandApplyAtRules.js +6 -0
- package/src/lib/generateRules.js +6 -5
- package/src/lib/setupContextUtils.js +4 -2
- package/src/util/cloneNodes.js +5 -1
- package/src/util/resolveConfig.js +1 -1
|
@@ -157,26 +157,52 @@ let nodeTypePropertyMap = {
|
|
|
157
157
|
decl: 'value',
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
160
|
+
/**
|
|
161
|
+
* @param {string} path
|
|
162
|
+
* @returns {Iterable<[path: string, alpha: string|undefined]>}
|
|
163
|
+
*/
|
|
164
|
+
function* toPaths(path) {
|
|
165
|
+
// Strip quotes from beginning and end of string
|
|
166
|
+
// This allows the alpha value to be present inside of quotes
|
|
167
|
+
path = path.replace(/^['"]+|['"]+$/g, '')
|
|
166
168
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
+
let matches = path.match(/^([^\s]+)(?![^\[]*\])(?:\s*\/\s*([^\/\s]+))$/)
|
|
170
|
+
let alpha = undefined
|
|
169
171
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
yield [path, undefined]
|
|
173
|
+
|
|
174
|
+
if (matches) {
|
|
175
|
+
path = matches[1]
|
|
176
|
+
alpha = matches[2]
|
|
177
|
+
|
|
178
|
+
yield [path, alpha]
|
|
179
|
+
}
|
|
180
|
+
}
|
|
174
181
|
|
|
175
|
-
|
|
182
|
+
/**
|
|
183
|
+
*
|
|
184
|
+
* @param {any} config
|
|
185
|
+
* @param {string} path
|
|
186
|
+
* @param {any} defaultValue
|
|
187
|
+
*/
|
|
188
|
+
function resolvePath(config, path, defaultValue) {
|
|
189
|
+
const results = Array.from(toPaths(path)).map(([path, alpha]) => {
|
|
190
|
+
return Object.assign(validatePath(config, path, defaultValue, { opacityValue: alpha }), {
|
|
191
|
+
resolvedPath: path,
|
|
192
|
+
alpha,
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
return results.find((result) => result.isValid) ?? results[0]
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export default function ({ tailwindConfig: config }) {
|
|
200
|
+
let functions = {
|
|
201
|
+
theme: (node, path, ...defaultValue) => {
|
|
202
|
+
let { isValid, value, error, alpha } = resolvePath(
|
|
176
203
|
config,
|
|
177
204
|
path,
|
|
178
|
-
defaultValue.length ? defaultValue : undefined
|
|
179
|
-
{ opacityValue: alpha }
|
|
205
|
+
defaultValue.length ? defaultValue : undefined
|
|
180
206
|
)
|
|
181
207
|
|
|
182
208
|
if (!isValid) {
|
|
@@ -499,6 +499,12 @@ function processApply(root, context, localCache) {
|
|
|
499
499
|
})
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
+
// It could be that the node we were inserted was removed because the class didn't match
|
|
503
|
+
// If that was the *only* rule in the parent, then we have nothing add so we skip it
|
|
504
|
+
if (!root.nodes[0]) {
|
|
505
|
+
continue
|
|
506
|
+
}
|
|
507
|
+
|
|
502
508
|
// Insert it
|
|
503
509
|
siblings.push([
|
|
504
510
|
// Ensure that when we are sorting, that we take the layer order into account
|
package/src/lib/generateRules.js
CHANGED
|
@@ -129,7 +129,6 @@ function applyVariant(variant, matches, context) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
let args
|
|
132
|
-
let isArbitraryVariant = false
|
|
133
132
|
|
|
134
133
|
// Find partial arbitrary variants
|
|
135
134
|
if (variant.endsWith(']') && !variant.startsWith('[')) {
|
|
@@ -145,8 +144,6 @@ function applyVariant(variant, matches, context) {
|
|
|
145
144
|
return []
|
|
146
145
|
}
|
|
147
146
|
|
|
148
|
-
isArbitraryVariant = true
|
|
149
|
-
|
|
150
147
|
let fn = parseVariant(selector)
|
|
151
148
|
|
|
152
149
|
let sort = Array.from(context.variantOrder.values()).pop() << 1n
|
|
@@ -303,7 +300,7 @@ function applyVariant(variant, matches, context) {
|
|
|
303
300
|
...meta,
|
|
304
301
|
sort: variantSort | meta.sort,
|
|
305
302
|
collectedFormats: (meta.collectedFormats ?? []).concat(collectedFormats),
|
|
306
|
-
isArbitraryVariant,
|
|
303
|
+
isArbitraryVariant: isArbitraryValue(variant),
|
|
307
304
|
},
|
|
308
305
|
clone.nodes[0],
|
|
309
306
|
]
|
|
@@ -471,7 +468,11 @@ function splitWithSeparator(input, separator) {
|
|
|
471
468
|
|
|
472
469
|
function* recordCandidates(matches, classCandidate) {
|
|
473
470
|
for (const match of matches) {
|
|
474
|
-
match[1].raws.tailwind = {
|
|
471
|
+
match[1].raws.tailwind = {
|
|
472
|
+
...match[1].raws.tailwind,
|
|
473
|
+
classCandidate,
|
|
474
|
+
preserveSource: match[0].options?.preserveSource ?? false,
|
|
475
|
+
}
|
|
475
476
|
|
|
476
477
|
yield match
|
|
477
478
|
}
|
|
@@ -289,6 +289,7 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
|
|
|
289
289
|
},
|
|
290
290
|
addComponents(components, options) {
|
|
291
291
|
let defaultOptions = {
|
|
292
|
+
preserveSource: false,
|
|
292
293
|
respectPrefix: true,
|
|
293
294
|
respectImportant: false,
|
|
294
295
|
}
|
|
@@ -311,6 +312,7 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
|
|
|
311
312
|
},
|
|
312
313
|
addUtilities(utilities, options) {
|
|
313
314
|
let defaultOptions = {
|
|
315
|
+
preserveSource: false,
|
|
314
316
|
respectPrefix: true,
|
|
315
317
|
respectImportant: true,
|
|
316
318
|
}
|
|
@@ -579,14 +581,14 @@ function collectLayerPlugins(root) {
|
|
|
579
581
|
} else if (layerRule.params === 'components') {
|
|
580
582
|
for (let node of layerRule.nodes) {
|
|
581
583
|
layerPlugins.push(function ({ addComponents }) {
|
|
582
|
-
addComponents(node, { respectPrefix: false })
|
|
584
|
+
addComponents(node, { respectPrefix: false, preserveSource: true })
|
|
583
585
|
})
|
|
584
586
|
}
|
|
585
587
|
layerRule.remove()
|
|
586
588
|
} else if (layerRule.params === 'utilities') {
|
|
587
589
|
for (let node of layerRule.nodes) {
|
|
588
590
|
layerPlugins.push(function ({ addUtilities }) {
|
|
589
|
-
addUtilities(node, { respectPrefix: false })
|
|
591
|
+
addUtilities(node, { respectPrefix: false, preserveSource: true })
|
|
590
592
|
})
|
|
591
593
|
}
|
|
592
594
|
layerRule.remove()
|
package/src/util/cloneNodes.js
CHANGED
|
@@ -2,7 +2,11 @@ export default function cloneNodes(nodes, source = undefined, raws = undefined)
|
|
|
2
2
|
return nodes.map((node) => {
|
|
3
3
|
let cloned = node.clone()
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// We always want override the source map
|
|
6
|
+
// except when explicitly told not to
|
|
7
|
+
let shouldOverwriteSource = node.raws.tailwind?.preserveSource !== true || !cloned.source
|
|
8
|
+
|
|
9
|
+
if (source !== undefined && shouldOverwriteSource) {
|
|
6
10
|
cloned.source = source
|
|
7
11
|
|
|
8
12
|
if ('walk' in cloned) {
|
|
@@ -180,7 +180,7 @@ function resolveFunctionKeys(object) {
|
|
|
180
180
|
val = val[path[index++]]
|
|
181
181
|
|
|
182
182
|
let shouldResolveAsFn =
|
|
183
|
-
isFunction(val) && (path.alpha === undefined || index
|
|
183
|
+
isFunction(val) && (path.alpha === undefined || index <= path.length - 1)
|
|
184
184
|
|
|
185
185
|
val = shouldResolveAsFn ? val(resolvePath, configUtils) : val
|
|
186
186
|
}
|