tailwindcss 3.0.23 → 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 +29 -3
- package/lib/cli-peer-dependencies.js +3 -3
- package/lib/cli.js +183 -161
- package/lib/constants.js +8 -8
- package/lib/corePlugins.js +1572 -1523
- 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 +6 -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 +90 -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 +78 -87
- package/lib/lib/setupTrackingContext.js +57 -57
- package/lib/lib/sharedState.js +10 -8
- 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 +24 -23
- package/peers/index.js +4777 -4831
- package/scripts/generate-types.js +52 -0
- package/src/cli.js +41 -11
- package/src/corePlugins.js +67 -5
- 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 +4 -4
- package/src/lib/expandApplyAtRules.js +179 -6
- package/src/lib/expandTailwindAtRules.js +25 -5
- package/src/lib/generateRules.js +68 -46
- package/src/lib/resolveDefaultsAtRules.js +6 -2
- package/src/lib/setupContextUtils.js +25 -26
- package/src/lib/setupTrackingContext.js +3 -3
- package/src/lib/sharedState.js +1 -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
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) {
|