tailwindcss 3.3.0 → 3.3.2
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 +28 -1
- package/lib/cli/build/deps.js +17 -9
- package/lib/cli/build/index.js +10 -8
- package/lib/cli/build/plugin.js +27 -25
- package/lib/cli/build/utils.js +18 -8
- package/lib/cli/build/watching.js +12 -10
- package/lib/cli/help/index.js +6 -4
- package/lib/cli/index.js +4 -4
- package/lib/cli/init/index.js +8 -6
- package/lib/cli-peer-dependencies.js +12 -4
- package/lib/cli.js +1 -1
- package/lib/corePluginList.js +3 -1
- package/lib/corePlugins.js +41 -35
- package/lib/featureFlags.js +14 -9
- package/lib/index.js +1 -5
- package/lib/lib/cacheInvalidation.js +7 -5
- package/lib/lib/collapseAdjacentRules.js +3 -1
- package/lib/lib/collapseDuplicateDeclarations.js +10 -8
- package/lib/lib/content.js +18 -14
- package/lib/lib/defaultExtractor.js +6 -4
- package/lib/lib/detectNesting.js +3 -1
- package/lib/lib/evaluateTailwindFunctions.js +18 -16
- package/lib/lib/expandApplyAtRules.js +39 -32
- package/lib/lib/expandTailwindAtRules.js +15 -13
- package/lib/lib/findAtConfigPath.js +6 -4
- package/lib/lib/generateRules.js +37 -31
- package/lib/lib/getModuleDependencies.js +10 -8
- package/lib/lib/load-config.js +14 -8
- package/lib/lib/normalizeTailwindDirectives.js +5 -3
- package/lib/lib/offsets.js +7 -5
- package/lib/lib/partitionApplyAtRules.js +3 -1
- package/lib/lib/regex.js +21 -7
- package/lib/lib/remap-bitfield.js +3 -1
- package/lib/lib/resolveDefaultsAtRules.js +24 -20
- package/lib/lib/setupContextUtils.js +67 -57
- package/lib/lib/setupTrackingContext.js +26 -24
- package/lib/lib/sharedState.js +32 -23
- package/lib/lib/substituteScreenAtRules.js +5 -3
- package/lib/oxide/cli/build/deps.js +16 -8
- package/lib/oxide/cli/build/index.js +6 -4
- package/lib/oxide/cli/build/plugin.js +19 -17
- package/lib/oxide/cli/build/utils.js +18 -8
- package/lib/oxide/cli/build/watching.js +10 -8
- package/lib/oxide/cli/help/index.js +6 -4
- package/lib/oxide/cli/index.js +4 -4
- package/lib/oxide/cli/init/index.js +6 -4
- package/lib/plugin.js +7 -7
- package/lib/postcss-plugins/nesting/index.js +3 -1
- package/lib/postcss-plugins/nesting/plugin.js +8 -6
- package/lib/processTailwindFeatures.js +14 -12
- package/lib/public/colors.js +5 -3
- package/lib/public/create-plugin.js +5 -3
- package/lib/public/default-config.js +6 -4
- package/lib/public/default-theme.js +6 -4
- package/lib/public/load-config.js +5 -3
- package/lib/public/resolve-config.js +6 -4
- package/lib/util/applyImportantSelector.js +27 -13
- package/lib/util/bigSign.js +3 -1
- package/lib/util/buildMediaQuery.js +3 -1
- package/lib/util/cloneDeep.js +3 -1
- package/lib/util/cloneNodes.js +3 -1
- package/lib/util/color.js +10 -6
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +3 -1
- package/lib/util/createPlugin.js +3 -1
- package/lib/util/createUtilityPlugin.js +5 -3
- package/lib/util/dataTypes.js +45 -15
- package/lib/util/defaults.js +6 -4
- package/lib/util/escapeClassName.js +7 -5
- package/lib/util/escapeCommas.js +3 -1
- package/lib/util/flattenColorPalette.js +3 -1
- package/lib/util/formatVariantSelector.js +28 -106
- package/lib/util/getAllConfigs.js +6 -4
- package/lib/util/hashConfig.js +6 -4
- package/lib/util/isKeyframeRule.js +3 -1
- package/lib/util/isPlainObject.js +3 -1
- package/lib/util/isSyntacticallyValidPropertyValue.js +3 -1
- package/lib/util/log.js +8 -4
- package/lib/util/nameClass.js +12 -6
- package/lib/util/negateValue.js +3 -1
- package/lib/util/normalizeConfig.js +7 -19
- package/lib/util/normalizeScreens.js +12 -4
- package/lib/util/parseAnimationValue.js +3 -1
- package/lib/util/parseBoxShadowValue.js +6 -2
- package/lib/util/parseDependency.js +3 -1
- package/lib/util/parseGlob.js +6 -4
- package/lib/util/parseObjectStyles.js +9 -7
- package/lib/util/pluginUtils.js +30 -18
- package/lib/util/prefixSelector.js +6 -4
- package/lib/util/pseudoElements.js +225 -0
- package/lib/util/removeAlphaVariables.js +3 -1
- package/lib/util/resolveConfig.js +10 -8
- package/lib/util/resolveConfigPath.js +9 -5
- package/lib/util/responsive.js +6 -4
- package/lib/util/splitAtTopLevelOnly.js +3 -1
- package/lib/util/tap.js +3 -1
- package/lib/util/toColorValue.js +3 -1
- package/lib/util/toPath.js +3 -1
- package/lib/util/transformThemeValue.js +6 -4
- package/lib/util/validateConfig.js +16 -3
- package/lib/util/validateFormalSyntax.js +3 -1
- package/lib/util/withAlphaVariable.js +6 -2
- package/package.json +30 -34
- package/peers/index.js +65828 -48819
- package/src/cli/build/plugin.js +1 -1
- package/src/cli.js +1 -1
- package/src/corePlugins.js +16 -17
- package/src/featureFlags.js +2 -3
- package/src/index.js +1 -5
- package/src/lib/defaultExtractor.js +1 -1
- package/src/lib/expandApplyAtRules.js +6 -0
- package/src/lib/expandTailwindAtRules.js +3 -3
- package/src/lib/load-config.ts +9 -5
- package/src/lib/setupTrackingContext.js +1 -1
- package/src/lib/sharedState.js +13 -19
- package/src/oxide/cli/build/plugin.ts +1 -1
- package/src/plugin.js +1 -1
- package/src/util/applyImportantSelector.js +20 -12
- package/src/util/color.js +1 -1
- package/src/util/colorNames.js +150 -0
- package/src/util/formatVariantSelector.js +2 -98
- package/src/util/normalizeConfig.js +0 -17
- package/src/util/pluginUtils.js +1 -5
- package/src/util/pseudoElements.js +170 -0
- package/src/util/validateConfig.js +13 -0
- package/types/config.d.ts +1 -6
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/** @typedef {import('postcss-selector-parser').Root} Root */
|
|
2
|
+
/** @typedef {import('postcss-selector-parser').Selector} Selector */
|
|
3
|
+
/** @typedef {import('postcss-selector-parser').Pseudo} Pseudo */
|
|
4
|
+
/** @typedef {import('postcss-selector-parser').Node} Node */
|
|
5
|
+
|
|
6
|
+
// There are some pseudo-elements that may or may not be:
|
|
7
|
+
|
|
8
|
+
// **Actionable**
|
|
9
|
+
// Zero or more user-action pseudo-classes may be attached to the pseudo-element itself
|
|
10
|
+
// structural-pseudo-classes are NOT allowed but we don't make
|
|
11
|
+
// The spec is not clear on whether this is allowed or not — but in practice it is.
|
|
12
|
+
|
|
13
|
+
// **Terminal**
|
|
14
|
+
// It MUST be placed at the end of a selector
|
|
15
|
+
//
|
|
16
|
+
// This is the required in the spec. However, some pseudo elements are not "terminal" because
|
|
17
|
+
// they represent a "boundary piercing" that is compiled out by a build step.
|
|
18
|
+
|
|
19
|
+
// **Jumpable**
|
|
20
|
+
// Any terminal element may "jump" over combinators when moving to the end of the selector
|
|
21
|
+
//
|
|
22
|
+
// This is a backwards-compat quirk of :before and :after variants.
|
|
23
|
+
|
|
24
|
+
/** @typedef {'terminal' | 'actionable' | 'jumpable'} PseudoProperty */
|
|
25
|
+
|
|
26
|
+
/** @type {Record<string, PseudoProperty[]>} */
|
|
27
|
+
let elementProperties = {
|
|
28
|
+
'::after': ['terminal', 'jumpable'],
|
|
29
|
+
'::backdrop': ['terminal'],
|
|
30
|
+
'::before': ['terminal', 'jumpable'],
|
|
31
|
+
'::cue': ['terminal'],
|
|
32
|
+
'::cue-region': ['terminal'],
|
|
33
|
+
'::first-letter': ['terminal', 'jumpable'],
|
|
34
|
+
'::first-line': ['terminal', 'jumpable'],
|
|
35
|
+
'::grammar-error': ['terminal'],
|
|
36
|
+
'::marker': ['terminal'],
|
|
37
|
+
'::part': ['terminal', 'actionable'],
|
|
38
|
+
'::placeholder': ['terminal'],
|
|
39
|
+
'::selection': ['terminal'],
|
|
40
|
+
'::slotted': ['terminal'],
|
|
41
|
+
'::spelling-error': ['terminal'],
|
|
42
|
+
'::target-text': ['terminal'],
|
|
43
|
+
|
|
44
|
+
// other
|
|
45
|
+
'::file-selector-button': ['terminal', 'actionable'],
|
|
46
|
+
'::-webkit-progress-bar': ['terminal', 'actionable'],
|
|
47
|
+
|
|
48
|
+
// Webkit scroll bar pseudo elements can be combined with user-action pseudo classes
|
|
49
|
+
'::-webkit-scrollbar': ['terminal', 'actionable'],
|
|
50
|
+
'::-webkit-scrollbar-button': ['terminal', 'actionable'],
|
|
51
|
+
'::-webkit-scrollbar-thumb': ['terminal', 'actionable'],
|
|
52
|
+
'::-webkit-scrollbar-track': ['terminal', 'actionable'],
|
|
53
|
+
'::-webkit-scrollbar-track-piece': ['terminal', 'actionable'],
|
|
54
|
+
'::-webkit-scrollbar-corner': ['terminal', 'actionable'],
|
|
55
|
+
'::-webkit-resizer': ['terminal', 'actionable'],
|
|
56
|
+
|
|
57
|
+
// Note: As a rule, double colons (::) should be used instead of a single colon
|
|
58
|
+
// (:). This distinguishes pseudo-classes from pseudo-elements. However, since
|
|
59
|
+
// this distinction was not present in older versions of the W3C spec, most
|
|
60
|
+
// browsers support both syntaxes for the original pseudo-elements.
|
|
61
|
+
':after': ['terminal', 'jumpable'],
|
|
62
|
+
':before': ['terminal', 'jumpable'],
|
|
63
|
+
':first-letter': ['terminal', 'jumpable'],
|
|
64
|
+
':first-line': ['terminal', 'jumpable'],
|
|
65
|
+
|
|
66
|
+
// The default value is used when the pseudo-element is not recognized
|
|
67
|
+
// Because it's not recognized, we don't know if it's terminal or not
|
|
68
|
+
// So we assume it can't be moved AND can have user-action pseudo classes attached to it
|
|
69
|
+
__default__: ['actionable'],
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param {Selector} sel
|
|
74
|
+
* @returns {Selector}
|
|
75
|
+
*/
|
|
76
|
+
export function movePseudos(sel) {
|
|
77
|
+
let [pseudos] = movablePseudos(sel)
|
|
78
|
+
|
|
79
|
+
// Remove all pseudo elements from their respective selectors
|
|
80
|
+
pseudos.forEach(([sel, pseudo]) => sel.removeChild(pseudo))
|
|
81
|
+
|
|
82
|
+
// Re-add them to the end of the selector in the correct order.
|
|
83
|
+
// This moves terminal pseudo elements to the end of the
|
|
84
|
+
// selector otherwise the selector will not be valid.
|
|
85
|
+
//
|
|
86
|
+
// Examples:
|
|
87
|
+
// - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
88
|
+
// - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
89
|
+
//
|
|
90
|
+
// The selector `::before:hover` does not work but we
|
|
91
|
+
// can make it work for you by flipping the order.
|
|
92
|
+
sel.nodes.push(...pseudos.map(([, pseudo]) => pseudo))
|
|
93
|
+
|
|
94
|
+
return sel
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** @typedef {[sel: Selector, pseudo: Pseudo, attachedTo: Pseudo | null]} MovablePseudo */
|
|
98
|
+
/** @typedef {[pseudos: MovablePseudo[], lastSeenElement: Pseudo | null]} MovablePseudosResult */
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param {Selector} sel
|
|
102
|
+
* @returns {MovablePseudosResult}
|
|
103
|
+
*/
|
|
104
|
+
function movablePseudos(sel) {
|
|
105
|
+
/** @type {MovablePseudo[]} */
|
|
106
|
+
let buffer = []
|
|
107
|
+
|
|
108
|
+
/** @type {Pseudo | null} */
|
|
109
|
+
let lastSeenElement = null
|
|
110
|
+
|
|
111
|
+
for (let node of sel.nodes) {
|
|
112
|
+
if (node.type === 'combinator') {
|
|
113
|
+
buffer = buffer.filter(([, node]) => propertiesForPseudo(node).includes('jumpable'))
|
|
114
|
+
lastSeenElement = null
|
|
115
|
+
} else if (node.type === 'pseudo') {
|
|
116
|
+
if (isMovablePseudoElement(node)) {
|
|
117
|
+
lastSeenElement = node
|
|
118
|
+
buffer.push([sel, node, null])
|
|
119
|
+
} else if (lastSeenElement && isAttachablePseudoClass(node, lastSeenElement)) {
|
|
120
|
+
buffer.push([sel, node, lastSeenElement])
|
|
121
|
+
} else {
|
|
122
|
+
lastSeenElement = null
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
for (let sub of node.nodes ?? []) {
|
|
126
|
+
let [movable, lastSeenElementInSub] = movablePseudos(sub)
|
|
127
|
+
lastSeenElement = lastSeenElementInSub || lastSeenElement
|
|
128
|
+
buffer.push(...movable)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return [buffer, lastSeenElement]
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @param {Node} node
|
|
138
|
+
* @returns {boolean}
|
|
139
|
+
*/
|
|
140
|
+
function isPseudoElement(node) {
|
|
141
|
+
return node.value.startsWith('::') || elementProperties[node.value] !== undefined
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @param {Node} node
|
|
146
|
+
* @returns {boolean}
|
|
147
|
+
*/
|
|
148
|
+
function isMovablePseudoElement(node) {
|
|
149
|
+
return isPseudoElement(node) && propertiesForPseudo(node).includes('terminal')
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @param {Node} node
|
|
154
|
+
* @param {Pseudo} pseudo
|
|
155
|
+
* @returns {boolean}
|
|
156
|
+
*/
|
|
157
|
+
function isAttachablePseudoClass(node, pseudo) {
|
|
158
|
+
if (node.type !== 'pseudo') return false
|
|
159
|
+
if (isPseudoElement(node)) return false
|
|
160
|
+
|
|
161
|
+
return propertiesForPseudo(pseudo).includes('actionable')
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @param {Pseudo} pseudo
|
|
166
|
+
* @returns {PseudoProperty[]}
|
|
167
|
+
*/
|
|
168
|
+
function propertiesForPseudo(pseudo) {
|
|
169
|
+
return elementProperties[pseudo.value] ?? elementProperties.__default__
|
|
170
|
+
}
|
|
@@ -9,5 +9,18 @@ export function validateConfig(config) {
|
|
|
9
9
|
])
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// Warn if the line-clamp plugin is installed
|
|
13
|
+
try {
|
|
14
|
+
let plugin = require('@tailwindcss/line-clamp')
|
|
15
|
+
if (config.plugins.includes(plugin)) {
|
|
16
|
+
log.warn('line-clamp-in-core', [
|
|
17
|
+
'As of Tailwind CSS v3.3, the `@tailwindcss/line-clamp` plugin is now included by default.',
|
|
18
|
+
'Remove it from the `plugins` array in your configuration to eliminate this warning.',
|
|
19
|
+
])
|
|
20
|
+
|
|
21
|
+
config.plugins = config.plugins.filter((p) => p !== plugin)
|
|
22
|
+
}
|
|
23
|
+
} catch {}
|
|
24
|
+
|
|
12
25
|
return config
|
|
13
26
|
}
|
package/types/config.d.ts
CHANGED
|
@@ -46,12 +46,7 @@ type PrefixConfig = string
|
|
|
46
46
|
type SeparatorConfig = string
|
|
47
47
|
|
|
48
48
|
// Safelist related config
|
|
49
|
-
type SafelistConfig =
|
|
50
|
-
| string[]
|
|
51
|
-
| {
|
|
52
|
-
pattern: RegExp
|
|
53
|
-
variants?: string[]
|
|
54
|
-
}[]
|
|
49
|
+
type SafelistConfig = (string | { pattern: RegExp; variants?: string[] })[]
|
|
55
50
|
|
|
56
51
|
// Blocklist related config
|
|
57
52
|
type BlocklistConfig = string[]
|