tailwindcss 3.0.21 → 3.0.24
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 +45 -2
- package/lib/cli-peer-dependencies.js +3 -3
- package/lib/cli.js +183 -161
- package/lib/constants.js +8 -8
- package/lib/corePlugins.js +1597 -1518
- package/lib/featureFlags.js +9 -9
- package/lib/index.js +19 -6
- package/lib/lib/cacheInvalidation.js +69 -0
- package/lib/lib/collapseAdjacentRules.js +26 -13
- package/lib/lib/collapseDuplicateDeclarations.js +1 -1
- package/lib/lib/defaultExtractor.js +8 -6
- package/lib/lib/detectNesting.js +9 -9
- package/lib/lib/evaluateTailwindFunctions.js +16 -16
- package/lib/lib/expandApplyAtRules.js +180 -27
- package/lib/lib/expandTailwindAtRules.js +132 -122
- package/lib/lib/generateRules.js +117 -72
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +35 -35
- package/lib/lib/partitionApplyAtRules.js +7 -7
- package/lib/lib/resolveDefaultsAtRules.js +81 -77
- package/lib/lib/setupContextUtils.js +83 -98
- package/lib/lib/setupTrackingContext.js +57 -57
- package/lib/lib/sharedState.js +11 -7
- package/lib/lib/substituteScreenAtRules.js +2 -2
- package/lib/postcss-plugins/nesting/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +1 -1
- package/lib/postcss-plugins/nesting/plugin.js +41 -9
- package/lib/processTailwindFeatures.js +7 -7
- package/lib/public/colors.js +241 -241
- package/lib/public/resolve-config.js +5 -5
- package/lib/util/buildMediaQuery.js +2 -2
- package/lib/util/cloneDeep.js +1 -1
- package/lib/util/cloneNodes.js +12 -1
- package/lib/util/color.js +21 -20
- package/lib/util/createUtilityPlugin.js +6 -6
- package/lib/util/dataTypes.js +77 -75
- package/lib/util/escapeClassName.js +5 -5
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +2 -2
- package/lib/util/formatVariantSelector.js +19 -19
- package/lib/util/getAllConfigs.js +5 -5
- package/lib/util/hashConfig.js +5 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +1 -1
- package/lib/util/isValidArbitraryValue.js +27 -27
- package/lib/util/log.js +8 -8
- package/lib/util/nameClass.js +7 -7
- package/lib/util/negateValue.js +4 -4
- package/lib/util/normalizeConfig.js +39 -39
- package/lib/util/normalizeScreens.js +4 -4
- package/lib/util/parseAnimationValue.js +56 -56
- package/lib/util/parseBoxShadowValue.js +60 -20
- package/lib/util/parseDependency.js +32 -32
- package/lib/util/parseObjectStyles.js +6 -6
- package/lib/util/pluginUtils.js +9 -9
- package/lib/util/prefixSelector.js +1 -1
- package/lib/util/resolveConfig.js +28 -28
- package/lib/util/resolveConfigPath.js +16 -16
- package/lib/util/responsive.js +6 -6
- package/lib/util/toColorValue.js +1 -1
- package/lib/util/toPath.js +2 -2
- package/lib/util/transformThemeValue.js +27 -27
- package/lib/util/withAlphaVariable.js +19 -19
- package/package.json +26 -25
- package/peers/index.js +4803 -4857
- package/scripts/generate-types.js +52 -0
- package/src/cli.js +41 -11
- package/src/corePlugins.js +104 -9
- package/src/featureFlags.js +2 -2
- package/src/index.js +17 -1
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +16 -1
- package/src/lib/defaultExtractor.js +6 -4
- package/src/lib/expandApplyAtRules.js +179 -6
- package/src/lib/expandTailwindAtRules.js +26 -6
- package/src/lib/generateRules.js +73 -46
- package/src/lib/resolveDefaultsAtRules.js +6 -2
- package/src/lib/setupContextUtils.js +39 -48
- package/src/lib/setupTrackingContext.js +3 -3
- package/src/lib/sharedState.js +2 -0
- package/src/postcss-plugins/nesting/README.md +2 -2
- package/src/postcss-plugins/nesting/plugin.js +36 -0
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +7 -5
- package/src/util/dataTypes.js +3 -1
- package/src/util/log.js +7 -7
- package/src/util/parseBoxShadowValue.js +50 -2
- package/src/util/resolveConfig.js +32 -0
- package/stubs/defaultConfig.stub.js +5 -0
|
@@ -112,7 +112,7 @@ function resolveChangedFiles(candidateFiles, fileModifiedMap) {
|
|
|
112
112
|
// source path), or set up a new one (including setting up watchers and registering
|
|
113
113
|
// plugins) then return it
|
|
114
114
|
export default function setupTrackingContext(configOrPath) {
|
|
115
|
-
return ({ tailwindDirectives, registerDependency
|
|
115
|
+
return ({ tailwindDirectives, registerDependency }) => {
|
|
116
116
|
return (root, result) => {
|
|
117
117
|
let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] =
|
|
118
118
|
getTailwindConfig(configOrPath)
|
|
@@ -125,7 +125,7 @@ export default function setupTrackingContext(configOrPath) {
|
|
|
125
125
|
// being part of this trigger too, but it's tough because it's impossible
|
|
126
126
|
// for a layer in one file to end up in the actual @tailwind rule in
|
|
127
127
|
// another file since independent sources are effectively isolated.
|
|
128
|
-
if (tailwindDirectives.size > 0
|
|
128
|
+
if (tailwindDirectives.size > 0) {
|
|
129
129
|
// Add current css file as a context dependencies.
|
|
130
130
|
contextDependencies.add(result.opts.from)
|
|
131
131
|
|
|
@@ -153,7 +153,7 @@ export default function setupTrackingContext(configOrPath) {
|
|
|
153
153
|
// We may want to think about `@layer` being part of this trigger too, but it's tough
|
|
154
154
|
// because it's impossible for a layer in one file to end up in the actual @tailwind rule
|
|
155
155
|
// in another file since independent sources are effectively isolated.
|
|
156
|
-
if (tailwindDirectives.size > 0
|
|
156
|
+
if (tailwindDirectives.size > 0) {
|
|
157
157
|
let fileModifiedMap = getFileModifiedMap(context)
|
|
158
158
|
|
|
159
159
|
// Add template paths as postcss dependencies.
|
package/src/lib/sharedState.js
CHANGED
|
@@ -5,6 +5,8 @@ export const env = {
|
|
|
5
5
|
export const contextMap = new Map()
|
|
6
6
|
export const configContextMap = new Map()
|
|
7
7
|
export const contextSourcesMap = new Map()
|
|
8
|
+
export const sourceHashMap = new Map()
|
|
9
|
+
export const NOT_ON_DEMAND = new String('*')
|
|
8
10
|
|
|
9
11
|
export function resolveDebug(debug) {
|
|
10
12
|
if (debug === undefined) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# tailwindcss/nesting
|
|
2
2
|
|
|
3
|
-
This is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/
|
|
3
|
+
This is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) and acts as a compatibility layer to make sure your nesting plugin of choice properly understands Tailwind's custom syntax like `@apply` and `@screen`.
|
|
4
4
|
|
|
5
5
|
Add it to your PostCSS configuration, somewhere before Tailwind itself:
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
|
18
18
|
|
|
19
19
|
By default, it uses the [postcss-nested](https://github.com/postcss/postcss-nested) plugin under the hood, which uses a Sass-like syntax and is the plugin that powers nesting support in the [Tailwind CSS plugin API](https://tailwindcss.com/docs/plugins#css-in-js-syntax).
|
|
20
20
|
|
|
21
|
-
If you'd rather use [postcss-nesting](https://github.com/
|
|
21
|
+
If you'd rather use [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) (which is based on the work-in-progress [CSS Nesting](https://drafts.csswg.org/css-nesting-1/) specification), first install the plugin alongside:
|
|
22
22
|
|
|
23
23
|
```shell
|
|
24
24
|
npm install postcss-nesting
|
|
@@ -39,6 +39,42 @@ export function nesting(opts = postcssNested) {
|
|
|
39
39
|
decl.remove()
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Use a private PostCSS API to remove the "clean" flag from the entire AST.
|
|
44
|
+
* This is done because running process() on the AST will set the "clean"
|
|
45
|
+
* flag on all nodes, which we don't want.
|
|
46
|
+
*
|
|
47
|
+
* This causes downstream plugins using the visitor API to be skipped.
|
|
48
|
+
*
|
|
49
|
+
* This is guarded because the PostCSS API is not public
|
|
50
|
+
* and may change in future versions of PostCSS.
|
|
51
|
+
*
|
|
52
|
+
* See https://github.com/postcss/postcss/issues/1712 for more details
|
|
53
|
+
*
|
|
54
|
+
* @param {import('postcss').Node} node
|
|
55
|
+
*/
|
|
56
|
+
function markDirty(node) {
|
|
57
|
+
if (!('markDirty' in node)) {
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Traverse the tree down to the leaf nodes
|
|
62
|
+
if (node.nodes) {
|
|
63
|
+
node.nodes.forEach((n) => markDirty(n))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// If it's a leaf node mark it as dirty
|
|
67
|
+
// We do this here because marking a node as dirty
|
|
68
|
+
// will walk up the tree and mark all parents as dirty
|
|
69
|
+
// resulting in a lot of unnecessary work if we did this
|
|
70
|
+
// for every single node
|
|
71
|
+
if (!node.nodes) {
|
|
72
|
+
node.markDirty()
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
markDirty(root)
|
|
77
|
+
|
|
42
78
|
return root
|
|
43
79
|
}
|
|
44
80
|
}
|
package/src/util/cloneNodes.js
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
export default function cloneNodes(nodes, source) {
|
|
1
|
+
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
|
if (source !== undefined) {
|
|
6
6
|
cloned.source = source
|
|
7
|
+
|
|
8
|
+
if ('walk' in cloned) {
|
|
9
|
+
cloned.walk((child) => {
|
|
10
|
+
child.source = source
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (raws !== undefined) {
|
|
16
|
+
cloned.raws.tailwind = {
|
|
17
|
+
...cloned.raws.tailwind,
|
|
18
|
+
...raws,
|
|
19
|
+
}
|
|
7
20
|
}
|
|
8
21
|
|
|
9
22
|
return cloned
|
package/src/util/color.js
CHANGED
|
@@ -2,14 +2,16 @@ import namedColors from 'color-name'
|
|
|
2
2
|
|
|
3
3
|
let HEX = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i
|
|
4
4
|
let SHORT_HEX = /^#([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i
|
|
5
|
-
let VALUE =
|
|
6
|
-
let SEP =
|
|
7
|
-
let ALPHA_SEP =
|
|
5
|
+
let VALUE = /(?:\d+|\d*\.\d+)%?/
|
|
6
|
+
let SEP = /(?:\s*,\s*|\s+)/
|
|
7
|
+
let ALPHA_SEP = /\s*[,/]\s*/
|
|
8
|
+
let CUSTOM_PROPERTY = /var\(--(?:[^ )]*?)\)/
|
|
9
|
+
|
|
8
10
|
let RGB = new RegExp(
|
|
9
|
-
`^rgba?\\(\\s*(${VALUE})${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`
|
|
11
|
+
`^rgba?\\(\\s*(${VALUE.source}|${CUSTOM_PROPERTY.source})${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source})${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source})(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`
|
|
10
12
|
)
|
|
11
13
|
let HSL = new RegExp(
|
|
12
|
-
`^hsla?\\(\\s*((?:${VALUE})(?:deg|rad|grad|turn)
|
|
14
|
+
`^hsla?\\(\\s*((?:${VALUE.source})(?:deg|rad|grad|turn)?|${CUSTOM_PROPERTY.source})${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source})${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source})(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`
|
|
13
15
|
)
|
|
14
16
|
|
|
15
17
|
export function parseColor(value) {
|
package/src/util/dataTypes.js
CHANGED
|
@@ -57,7 +57,9 @@ export function number(value) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export function percentage(value) {
|
|
60
|
-
return
|
|
60
|
+
return value.split(UNDERSCORE).every((part) => {
|
|
61
|
+
return /%$/g.test(part) || cssFunctions.some((fn) => new RegExp(`^${fn}\\(.+?%`).test(part))
|
|
62
|
+
})
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
let lengthUnits = [
|
package/src/util/log.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import
|
|
1
|
+
import colors from 'picocolors'
|
|
2
2
|
|
|
3
3
|
let alreadyShown = new Set()
|
|
4
4
|
|
|
5
|
-
function log(
|
|
5
|
+
function log(type, messages, key) {
|
|
6
6
|
if (process.env.JEST_WORKER_ID !== undefined) return
|
|
7
7
|
|
|
8
8
|
if (key && alreadyShown.has(key)) return
|
|
9
9
|
if (key) alreadyShown.add(key)
|
|
10
10
|
|
|
11
11
|
console.warn('')
|
|
12
|
-
messages.forEach((message) => console.warn(
|
|
12
|
+
messages.forEach((message) => console.warn(type, '-', message))
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export function dim(input) {
|
|
16
|
-
return
|
|
16
|
+
return colors.dim(input)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export default {
|
|
20
20
|
info(key, messages) {
|
|
21
|
-
log(
|
|
21
|
+
log(colors.bold(colors.cyan('info')), ...(Array.isArray(key) ? [key] : [messages, key]))
|
|
22
22
|
},
|
|
23
23
|
warn(key, messages) {
|
|
24
|
-
log(
|
|
24
|
+
log(colors.bold(colors.yellow('warn')), ...(Array.isArray(key) ? [key] : [messages, key]))
|
|
25
25
|
},
|
|
26
26
|
risk(key, messages) {
|
|
27
|
-
log(
|
|
27
|
+
log(colors.bold(colors.magenta('risk')), ...(Array.isArray(key) ? [key] : [messages, key]))
|
|
28
28
|
},
|
|
29
29
|
}
|
|
@@ -1,10 +1,58 @@
|
|
|
1
1
|
let KEYWORDS = new Set(['inset', 'inherit', 'initial', 'revert', 'unset'])
|
|
2
|
-
let COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
|
|
3
2
|
let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
|
|
4
3
|
let LENGTH = /^-?(\d+|\.\d+)(.*?)$/g
|
|
5
4
|
|
|
5
|
+
let SPECIALS = /[(),]/g
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This splits a string on top-level commas.
|
|
9
|
+
*
|
|
10
|
+
* Regex doesn't support recursion (at least not the JS-flavored version).
|
|
11
|
+
* So we have to use a tiny state machine to keep track of paren vs comma
|
|
12
|
+
* placement. Before we'd only exclude commas from the inner-most nested
|
|
13
|
+
* set of parens rather than any commas that were not contained in parens
|
|
14
|
+
* at all which is the intended behavior here.
|
|
15
|
+
*
|
|
16
|
+
* Expected behavior:
|
|
17
|
+
* var(--a, 0 0 1px rgb(0, 0, 0)), 0 0 1px rgb(0, 0, 0)
|
|
18
|
+
* ─┬─ ┬ ┬ ┬
|
|
19
|
+
* x x x ╰──────── Split because top-level
|
|
20
|
+
* ╰──────────────┴──┴───────────── Ignored b/c inside >= 1 levels of parens
|
|
21
|
+
*
|
|
22
|
+
* @param {string} input
|
|
23
|
+
*/
|
|
24
|
+
function* splitByTopLevelCommas(input) {
|
|
25
|
+
SPECIALS.lastIndex = -1
|
|
26
|
+
|
|
27
|
+
let depth = 0
|
|
28
|
+
let lastIndex = 0
|
|
29
|
+
let found = false
|
|
30
|
+
|
|
31
|
+
// Find all parens & commas
|
|
32
|
+
// And only split on commas if they're top-level
|
|
33
|
+
for (let match of input.matchAll(SPECIALS)) {
|
|
34
|
+
if (match[0] === '(') depth++
|
|
35
|
+
if (match[0] === ')') depth--
|
|
36
|
+
if (match[0] === ',' && depth === 0) {
|
|
37
|
+
found = true
|
|
38
|
+
|
|
39
|
+
yield input.substring(lastIndex, match.index)
|
|
40
|
+
lastIndex = match.index + match[0].length
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Provide the last segment of the string if available
|
|
45
|
+
// Otherwise the whole string since no commas were found
|
|
46
|
+
// This mirrors the behavior of string.split()
|
|
47
|
+
if (found) {
|
|
48
|
+
yield input.substring(lastIndex)
|
|
49
|
+
} else {
|
|
50
|
+
yield input
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
6
54
|
export function parseBoxShadowValue(input) {
|
|
7
|
-
let shadows =
|
|
55
|
+
let shadows = Array.from(splitByTopLevelCommas(input))
|
|
8
56
|
return shadows.map((shadow) => {
|
|
9
57
|
let value = shadow.trim()
|
|
10
58
|
let result = { raw: value }
|
|
@@ -66,6 +66,38 @@ const configUtils = {
|
|
|
66
66
|
{}
|
|
67
67
|
)
|
|
68
68
|
},
|
|
69
|
+
/*
|
|
70
|
+
rgb(property) {
|
|
71
|
+
if (!property.startsWith('--')) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
'The rgb() helper requires a custom property name to be passed as the first argument.'
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return ({ opacityValue }) => {
|
|
78
|
+
if (opacityValue === undefined || opacityValue === 1) {
|
|
79
|
+
return `rgb(var(${property}) / 1.0)`
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return `rgb(var(${property}) / ${opacityValue})`
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
hsl(property) {
|
|
86
|
+
if (!property.startsWith('--')) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
'The hsl() helper requires a custom property name to be passed as the first argument.'
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return ({ opacityValue }) => {
|
|
93
|
+
if (opacityValue === undefined || opacityValue === 1) {
|
|
94
|
+
return `hsl(var(${property}) / 1)`
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return `hsl(var(${property}) / ${opacityValue})`
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
*/
|
|
69
101
|
}
|
|
70
102
|
|
|
71
103
|
function value(valueToResolve, ...args) {
|