tailwindcss 3.3.1 → 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 +22 -6
- 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 +37 -40
- 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 +5 -3
- 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 +28 -24
- 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 +9 -10
- 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 -108
- 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 -5
- 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 +5 -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 +2 -8
- package/src/lib/expandTailwindAtRules.js +3 -3
- package/src/lib/setupTrackingContext.js +1 -1
- package/src/lib/sharedState.js +0 -15
- package/src/oxide/cli/build/plugin.ts +1 -1
- package/src/plugin.js +1 -1
- package/src/util/applyImportantSelector.js +2 -5
- package/src/util/color.js +1 -1
- package/src/util/colorNames.js +150 -0
- package/src/util/formatVariantSelector.js +2 -124
- package/src/util/pluginUtils.js +1 -5
- package/src/util/pseudoElements.js +170 -0
package/src/cli/build/plugin.js
CHANGED
package/src/cli.js
CHANGED
package/src/corePlugins.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
2
|
import * as path from 'path'
|
|
3
3
|
import postcss from 'postcss'
|
|
4
|
-
import { env } from './lib/sharedState'
|
|
5
4
|
import createUtilityPlugin from './util/createUtilityPlugin'
|
|
6
5
|
import buildMediaQuery from './util/buildMediaQuery'
|
|
7
6
|
import escapeClassName from './util/escapeClassName'
|
|
@@ -1262,7 +1261,7 @@ export let corePlugins = {
|
|
|
1262
1261
|
'space-x': (value) => {
|
|
1263
1262
|
value = value === '0' ? '0px' : value
|
|
1264
1263
|
|
|
1265
|
-
if (
|
|
1264
|
+
if (__OXIDE__) {
|
|
1266
1265
|
return {
|
|
1267
1266
|
'& > :not([hidden]) ~ :not([hidden])': {
|
|
1268
1267
|
'--tw-space-x-reverse': '0',
|
|
@@ -1307,7 +1306,7 @@ export let corePlugins = {
|
|
|
1307
1306
|
'divide-x': (value) => {
|
|
1308
1307
|
value = value === '0' ? '0px' : value
|
|
1309
1308
|
|
|
1310
|
-
if (
|
|
1309
|
+
if (__OXIDE__) {
|
|
1311
1310
|
return {
|
|
1312
1311
|
'& > :not([hidden]) ~ :not([hidden])': {
|
|
1313
1312
|
'@defaults border-width': {},
|
|
@@ -1750,7 +1749,13 @@ export let corePlugins = {
|
|
|
1750
1749
|
return withAlphaValue(value, 0, 'rgb(255 255 255 / 0)')
|
|
1751
1750
|
}
|
|
1752
1751
|
|
|
1753
|
-
return function ({ matchUtilities, theme }) {
|
|
1752
|
+
return function ({ matchUtilities, theme, addDefaults }) {
|
|
1753
|
+
addDefaults('gradient-color-stops', {
|
|
1754
|
+
'--tw-gradient-from-position': ' ',
|
|
1755
|
+
'--tw-gradient-via-position': ' ',
|
|
1756
|
+
'--tw-gradient-to-position': ' ',
|
|
1757
|
+
})
|
|
1758
|
+
|
|
1754
1759
|
let options = {
|
|
1755
1760
|
values: flattenColorPalette(theme('gradientColorStops')),
|
|
1756
1761
|
type: ['color', 'any'],
|
|
@@ -1767,13 +1772,9 @@ export let corePlugins = {
|
|
|
1767
1772
|
let transparentToValue = transparentTo(value)
|
|
1768
1773
|
|
|
1769
1774
|
return {
|
|
1770
|
-
'
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
)} var(--tw-gradient-from-position)`,
|
|
1774
|
-
'--tw-gradient-from-position': ' ',
|
|
1775
|
-
'--tw-gradient-to': `${transparentToValue} var(--tw-gradient-from-position)`,
|
|
1776
|
-
'--tw-gradient-to-position': ' ',
|
|
1775
|
+
'@defaults gradient-color-stops': {},
|
|
1776
|
+
'--tw-gradient-from': `${toColorValue(value)} var(--tw-gradient-from-position)`,
|
|
1777
|
+
'--tw-gradient-to': `${transparentToValue} var(--tw-gradient-to-position)`,
|
|
1777
1778
|
'--tw-gradient-stops': `var(--tw-gradient-from), var(--tw-gradient-to)`,
|
|
1778
1779
|
}
|
|
1779
1780
|
},
|
|
@@ -1798,12 +1799,10 @@ export let corePlugins = {
|
|
|
1798
1799
|
let transparentToValue = transparentTo(value)
|
|
1799
1800
|
|
|
1800
1801
|
return {
|
|
1801
|
-
'
|
|
1802
|
+
'@defaults gradient-color-stops': {},
|
|
1802
1803
|
'--tw-gradient-to': `${transparentToValue} var(--tw-gradient-to-position)`,
|
|
1803
|
-
'--tw-gradient-to-position': ' ',
|
|
1804
1804
|
'--tw-gradient-stops': `var(--tw-gradient-from), ${toColorValue(
|
|
1805
|
-
value
|
|
1806
|
-
'via'
|
|
1805
|
+
value
|
|
1807
1806
|
)} var(--tw-gradient-via-position), var(--tw-gradient-to)`,
|
|
1808
1807
|
}
|
|
1809
1808
|
},
|
|
@@ -1825,8 +1824,8 @@ export let corePlugins = {
|
|
|
1825
1824
|
matchUtilities(
|
|
1826
1825
|
{
|
|
1827
1826
|
to: (value) => ({
|
|
1828
|
-
'
|
|
1829
|
-
'--tw-gradient-to
|
|
1827
|
+
'@defaults gradient-color-stops': {},
|
|
1828
|
+
'--tw-gradient-to': `${toColorValue(value)} var(--tw-gradient-to-position)`,
|
|
1830
1829
|
}),
|
|
1831
1830
|
},
|
|
1832
1831
|
options
|
package/src/featureFlags.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import colors from 'picocolors'
|
|
2
2
|
import log from './util/log'
|
|
3
|
-
import { env } from './lib/sharedState'
|
|
4
3
|
|
|
5
4
|
let defaults = {
|
|
6
5
|
optimizeUniversalDefaults: false,
|
|
7
6
|
generalizedModifiers: true,
|
|
8
7
|
get disableColorOpacityUtilitiesByDefault() {
|
|
9
|
-
return
|
|
8
|
+
return __OXIDE__
|
|
10
9
|
},
|
|
11
10
|
get relativeContentPathsByDefault() {
|
|
12
|
-
return
|
|
11
|
+
return __OXIDE__
|
|
13
12
|
},
|
|
14
13
|
}
|
|
15
14
|
|
package/src/index.js
CHANGED
|
@@ -35,7 +35,7 @@ function* buildRegExps(context) {
|
|
|
35
35
|
// This is a targeted fix to continue to allow theme()
|
|
36
36
|
// with square brackets to work in arbitrary properties
|
|
37
37
|
// while fixing a problem with the regex matching too much
|
|
38
|
-
/\[[^\s:'"`]+:[^\s]+?\[[^\s]
|
|
38
|
+
/\[[^\s:'"`]+:[^\s]+?\[[^\s]+\][^\s]+?\]/,
|
|
39
39
|
|
|
40
40
|
// Utilities
|
|
41
41
|
regex.pattern([
|
|
@@ -4,7 +4,7 @@ import parser from 'postcss-selector-parser'
|
|
|
4
4
|
import { resolveMatches } from './generateRules'
|
|
5
5
|
import escapeClassName from '../util/escapeClassName'
|
|
6
6
|
import { applyImportantSelector } from '../util/applyImportantSelector'
|
|
7
|
-
import {
|
|
7
|
+
import { movePseudos } from '../util/pseudoElements'
|
|
8
8
|
|
|
9
9
|
/** @typedef {Map<string, [any, import('postcss').Rule[]]>} ApplyCache */
|
|
10
10
|
|
|
@@ -566,13 +566,7 @@ function processApply(root, context, localCache) {
|
|
|
566
566
|
|
|
567
567
|
// Move pseudo elements to the end of the selector (if necessary)
|
|
568
568
|
let selector = parser().astSync(rule.selector)
|
|
569
|
-
selector.each((sel) =>
|
|
570
|
-
let [pseudoElements] = collectPseudoElements(sel)
|
|
571
|
-
if (pseudoElements.length > 0) {
|
|
572
|
-
sel.nodes.push(...pseudoElements.sort(sortSelector))
|
|
573
|
-
}
|
|
574
|
-
})
|
|
575
|
-
|
|
569
|
+
selector.each((sel) => movePseudos(sel))
|
|
576
570
|
rule.selector = selector.toString()
|
|
577
571
|
})
|
|
578
572
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
|
-
import LRU from 'quick-lru'
|
|
2
|
+
import LRU from '@alloc/quick-lru'
|
|
3
3
|
import * as sharedState from './sharedState'
|
|
4
4
|
import { generateRules } from './generateRules'
|
|
5
5
|
import log from '../util/log'
|
|
@@ -130,7 +130,7 @@ export default function expandTailwindAtRules(context) {
|
|
|
130
130
|
|
|
131
131
|
env.DEBUG && console.time('Reading changed files')
|
|
132
132
|
|
|
133
|
-
if (
|
|
133
|
+
if (__OXIDE__) {
|
|
134
134
|
// TODO: Pass through or implement `extractor`
|
|
135
135
|
for (let candidate of require('@tailwindcss/oxide').parseCandidateStringsFromFiles(
|
|
136
136
|
context.changedContent
|
|
@@ -162,7 +162,7 @@ export default function expandTailwindAtRules(context) {
|
|
|
162
162
|
|
|
163
163
|
env.DEBUG && console.time('Generate rules')
|
|
164
164
|
env.DEBUG && console.time('Sorting candidates')
|
|
165
|
-
let sortedCandidates =
|
|
165
|
+
let sortedCandidates = __OXIDE__
|
|
166
166
|
? candidates
|
|
167
167
|
: new Set(
|
|
168
168
|
[...candidates].sort((a, z) => {
|
package/src/lib/sharedState.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import pkg from '../../package.json'
|
|
2
|
-
let OXIDE_DEFAULT_ENABLED = pkg.tailwindcss.engine === 'oxide'
|
|
3
2
|
|
|
4
3
|
export const env =
|
|
5
4
|
typeof process !== 'undefined'
|
|
@@ -7,13 +6,11 @@ export const env =
|
|
|
7
6
|
NODE_ENV: process.env.NODE_ENV,
|
|
8
7
|
DEBUG: resolveDebug(process.env.DEBUG),
|
|
9
8
|
ENGINE: pkg.tailwindcss.engine,
|
|
10
|
-
OXIDE: resolveBoolean(process.env.OXIDE, OXIDE_DEFAULT_ENABLED),
|
|
11
9
|
}
|
|
12
10
|
: {
|
|
13
11
|
NODE_ENV: 'production',
|
|
14
12
|
DEBUG: false,
|
|
15
13
|
ENGINE: pkg.tailwindcss.engine,
|
|
16
|
-
OXIDE: OXIDE_DEFAULT_ENABLED,
|
|
17
14
|
}
|
|
18
15
|
|
|
19
16
|
export const contextMap = new Map()
|
|
@@ -24,18 +21,6 @@ export const NOT_ON_DEMAND = new String('*')
|
|
|
24
21
|
|
|
25
22
|
export const NONE = Symbol('__NONE__')
|
|
26
23
|
|
|
27
|
-
function resolveBoolean(value, defaultValue) {
|
|
28
|
-
if (value === undefined) {
|
|
29
|
-
return defaultValue
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (value === '0' || value === 'false') {
|
|
33
|
-
return false
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return true
|
|
37
|
-
}
|
|
38
|
-
|
|
39
24
|
export function resolveDebug(debug) {
|
|
40
25
|
if (debug === undefined) {
|
|
41
26
|
return false
|
package/src/plugin.js
CHANGED
|
@@ -34,7 +34,7 @@ module.exports = function tailwindcss(configOrPath) {
|
|
|
34
34
|
|
|
35
35
|
processTailwindFeatures(context)(root, result)
|
|
36
36
|
},
|
|
37
|
-
|
|
37
|
+
__OXIDE__ &&
|
|
38
38
|
function lightningCssPlugin(_root, result) {
|
|
39
39
|
let postcss = require('postcss')
|
|
40
40
|
let lightningcss = require('lightningcss')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import parser from 'postcss-selector-parser'
|
|
2
|
-
import {
|
|
2
|
+
import { movePseudos } from './pseudoElements'
|
|
3
3
|
|
|
4
4
|
export function applyImportantSelector(selector, important) {
|
|
5
5
|
let sel = parser().astSync(selector)
|
|
@@ -20,10 +20,7 @@ export function applyImportantSelector(selector, important) {
|
|
|
20
20
|
]
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
if (pseudoElements.length > 0) {
|
|
25
|
-
sel.nodes.push(...pseudoElements.sort(sortSelector))
|
|
26
|
-
}
|
|
23
|
+
movePseudos(sel)
|
|
27
24
|
})
|
|
28
25
|
|
|
29
26
|
return `${important} ${sel.toString()}`
|
package/src/util/color.js
CHANGED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
aliceblue: [240, 248, 255],
|
|
3
|
+
antiquewhite: [250, 235, 215],
|
|
4
|
+
aqua: [0, 255, 255],
|
|
5
|
+
aquamarine: [127, 255, 212],
|
|
6
|
+
azure: [240, 255, 255],
|
|
7
|
+
beige: [245, 245, 220],
|
|
8
|
+
bisque: [255, 228, 196],
|
|
9
|
+
black: [0, 0, 0],
|
|
10
|
+
blanchedalmond: [255, 235, 205],
|
|
11
|
+
blue: [0, 0, 255],
|
|
12
|
+
blueviolet: [138, 43, 226],
|
|
13
|
+
brown: [165, 42, 42],
|
|
14
|
+
burlywood: [222, 184, 135],
|
|
15
|
+
cadetblue: [95, 158, 160],
|
|
16
|
+
chartreuse: [127, 255, 0],
|
|
17
|
+
chocolate: [210, 105, 30],
|
|
18
|
+
coral: [255, 127, 80],
|
|
19
|
+
cornflowerblue: [100, 149, 237],
|
|
20
|
+
cornsilk: [255, 248, 220],
|
|
21
|
+
crimson: [220, 20, 60],
|
|
22
|
+
cyan: [0, 255, 255],
|
|
23
|
+
darkblue: [0, 0, 139],
|
|
24
|
+
darkcyan: [0, 139, 139],
|
|
25
|
+
darkgoldenrod: [184, 134, 11],
|
|
26
|
+
darkgray: [169, 169, 169],
|
|
27
|
+
darkgreen: [0, 100, 0],
|
|
28
|
+
darkgrey: [169, 169, 169],
|
|
29
|
+
darkkhaki: [189, 183, 107],
|
|
30
|
+
darkmagenta: [139, 0, 139],
|
|
31
|
+
darkolivegreen: [85, 107, 47],
|
|
32
|
+
darkorange: [255, 140, 0],
|
|
33
|
+
darkorchid: [153, 50, 204],
|
|
34
|
+
darkred: [139, 0, 0],
|
|
35
|
+
darksalmon: [233, 150, 122],
|
|
36
|
+
darkseagreen: [143, 188, 143],
|
|
37
|
+
darkslateblue: [72, 61, 139],
|
|
38
|
+
darkslategray: [47, 79, 79],
|
|
39
|
+
darkslategrey: [47, 79, 79],
|
|
40
|
+
darkturquoise: [0, 206, 209],
|
|
41
|
+
darkviolet: [148, 0, 211],
|
|
42
|
+
deeppink: [255, 20, 147],
|
|
43
|
+
deepskyblue: [0, 191, 255],
|
|
44
|
+
dimgray: [105, 105, 105],
|
|
45
|
+
dimgrey: [105, 105, 105],
|
|
46
|
+
dodgerblue: [30, 144, 255],
|
|
47
|
+
firebrick: [178, 34, 34],
|
|
48
|
+
floralwhite: [255, 250, 240],
|
|
49
|
+
forestgreen: [34, 139, 34],
|
|
50
|
+
fuchsia: [255, 0, 255],
|
|
51
|
+
gainsboro: [220, 220, 220],
|
|
52
|
+
ghostwhite: [248, 248, 255],
|
|
53
|
+
gold: [255, 215, 0],
|
|
54
|
+
goldenrod: [218, 165, 32],
|
|
55
|
+
gray: [128, 128, 128],
|
|
56
|
+
green: [0, 128, 0],
|
|
57
|
+
greenyellow: [173, 255, 47],
|
|
58
|
+
grey: [128, 128, 128],
|
|
59
|
+
honeydew: [240, 255, 240],
|
|
60
|
+
hotpink: [255, 105, 180],
|
|
61
|
+
indianred: [205, 92, 92],
|
|
62
|
+
indigo: [75, 0, 130],
|
|
63
|
+
ivory: [255, 255, 240],
|
|
64
|
+
khaki: [240, 230, 140],
|
|
65
|
+
lavender: [230, 230, 250],
|
|
66
|
+
lavenderblush: [255, 240, 245],
|
|
67
|
+
lawngreen: [124, 252, 0],
|
|
68
|
+
lemonchiffon: [255, 250, 205],
|
|
69
|
+
lightblue: [173, 216, 230],
|
|
70
|
+
lightcoral: [240, 128, 128],
|
|
71
|
+
lightcyan: [224, 255, 255],
|
|
72
|
+
lightgoldenrodyellow: [250, 250, 210],
|
|
73
|
+
lightgray: [211, 211, 211],
|
|
74
|
+
lightgreen: [144, 238, 144],
|
|
75
|
+
lightgrey: [211, 211, 211],
|
|
76
|
+
lightpink: [255, 182, 193],
|
|
77
|
+
lightsalmon: [255, 160, 122],
|
|
78
|
+
lightseagreen: [32, 178, 170],
|
|
79
|
+
lightskyblue: [135, 206, 250],
|
|
80
|
+
lightslategray: [119, 136, 153],
|
|
81
|
+
lightslategrey: [119, 136, 153],
|
|
82
|
+
lightsteelblue: [176, 196, 222],
|
|
83
|
+
lightyellow: [255, 255, 224],
|
|
84
|
+
lime: [0, 255, 0],
|
|
85
|
+
limegreen: [50, 205, 50],
|
|
86
|
+
linen: [250, 240, 230],
|
|
87
|
+
magenta: [255, 0, 255],
|
|
88
|
+
maroon: [128, 0, 0],
|
|
89
|
+
mediumaquamarine: [102, 205, 170],
|
|
90
|
+
mediumblue: [0, 0, 205],
|
|
91
|
+
mediumorchid: [186, 85, 211],
|
|
92
|
+
mediumpurple: [147, 112, 219],
|
|
93
|
+
mediumseagreen: [60, 179, 113],
|
|
94
|
+
mediumslateblue: [123, 104, 238],
|
|
95
|
+
mediumspringgreen: [0, 250, 154],
|
|
96
|
+
mediumturquoise: [72, 209, 204],
|
|
97
|
+
mediumvioletred: [199, 21, 133],
|
|
98
|
+
midnightblue: [25, 25, 112],
|
|
99
|
+
mintcream: [245, 255, 250],
|
|
100
|
+
mistyrose: [255, 228, 225],
|
|
101
|
+
moccasin: [255, 228, 181],
|
|
102
|
+
navajowhite: [255, 222, 173],
|
|
103
|
+
navy: [0, 0, 128],
|
|
104
|
+
oldlace: [253, 245, 230],
|
|
105
|
+
olive: [128, 128, 0],
|
|
106
|
+
olivedrab: [107, 142, 35],
|
|
107
|
+
orange: [255, 165, 0],
|
|
108
|
+
orangered: [255, 69, 0],
|
|
109
|
+
orchid: [218, 112, 214],
|
|
110
|
+
palegoldenrod: [238, 232, 170],
|
|
111
|
+
palegreen: [152, 251, 152],
|
|
112
|
+
paleturquoise: [175, 238, 238],
|
|
113
|
+
palevioletred: [219, 112, 147],
|
|
114
|
+
papayawhip: [255, 239, 213],
|
|
115
|
+
peachpuff: [255, 218, 185],
|
|
116
|
+
peru: [205, 133, 63],
|
|
117
|
+
pink: [255, 192, 203],
|
|
118
|
+
plum: [221, 160, 221],
|
|
119
|
+
powderblue: [176, 224, 230],
|
|
120
|
+
purple: [128, 0, 128],
|
|
121
|
+
rebeccapurple: [102, 51, 153],
|
|
122
|
+
red: [255, 0, 0],
|
|
123
|
+
rosybrown: [188, 143, 143],
|
|
124
|
+
royalblue: [65, 105, 225],
|
|
125
|
+
saddlebrown: [139, 69, 19],
|
|
126
|
+
salmon: [250, 128, 114],
|
|
127
|
+
sandybrown: [244, 164, 96],
|
|
128
|
+
seagreen: [46, 139, 87],
|
|
129
|
+
seashell: [255, 245, 238],
|
|
130
|
+
sienna: [160, 82, 45],
|
|
131
|
+
silver: [192, 192, 192],
|
|
132
|
+
skyblue: [135, 206, 235],
|
|
133
|
+
slateblue: [106, 90, 205],
|
|
134
|
+
slategray: [112, 128, 144],
|
|
135
|
+
slategrey: [112, 128, 144],
|
|
136
|
+
snow: [255, 250, 250],
|
|
137
|
+
springgreen: [0, 255, 127],
|
|
138
|
+
steelblue: [70, 130, 180],
|
|
139
|
+
tan: [210, 180, 140],
|
|
140
|
+
teal: [0, 128, 128],
|
|
141
|
+
thistle: [216, 191, 216],
|
|
142
|
+
tomato: [255, 99, 71],
|
|
143
|
+
turquoise: [64, 224, 208],
|
|
144
|
+
violet: [238, 130, 238],
|
|
145
|
+
wheat: [245, 222, 179],
|
|
146
|
+
white: [255, 255, 255],
|
|
147
|
+
whitesmoke: [245, 245, 245],
|
|
148
|
+
yellow: [255, 255, 0],
|
|
149
|
+
yellowgreen: [154, 205, 50],
|
|
150
|
+
}
|
|
@@ -2,6 +2,7 @@ import selectorParser from 'postcss-selector-parser'
|
|
|
2
2
|
import unescape from 'postcss-selector-parser/dist/util/unesc'
|
|
3
3
|
import escapeClassName from '../util/escapeClassName'
|
|
4
4
|
import prefixSelector from '../util/prefixSelector'
|
|
5
|
+
import { movePseudos } from './pseudoElements'
|
|
5
6
|
|
|
6
7
|
/** @typedef {import('postcss-selector-parser').Root} Root */
|
|
7
8
|
/** @typedef {import('postcss-selector-parser').Selector} Selector */
|
|
@@ -245,12 +246,7 @@ export function finalizeSelector(current, formats, { context, candidate, base })
|
|
|
245
246
|
})
|
|
246
247
|
|
|
247
248
|
// Move pseudo elements to the end of the selector (if necessary)
|
|
248
|
-
selector.each((sel) =>
|
|
249
|
-
let [pseudoElements] = collectPseudoElements(sel)
|
|
250
|
-
if (pseudoElements.length > 0) {
|
|
251
|
-
sel.nodes.push(...pseudoElements.sort(sortSelector))
|
|
252
|
-
}
|
|
253
|
-
})
|
|
249
|
+
selector.each((sel) => movePseudos(sel))
|
|
254
250
|
|
|
255
251
|
return selector.toString()
|
|
256
252
|
}
|
|
@@ -318,121 +314,3 @@ export function handleMergePseudo(selector, format) {
|
|
|
318
314
|
|
|
319
315
|
return [selector, format]
|
|
320
316
|
}
|
|
321
|
-
|
|
322
|
-
// Note: As a rule, double colons (::) should be used instead of a single colon
|
|
323
|
-
// (:). This distinguishes pseudo-classes from pseudo-elements. However, since
|
|
324
|
-
// this distinction was not present in older versions of the W3C spec, most
|
|
325
|
-
// browsers support both syntaxes for the original pseudo-elements.
|
|
326
|
-
let pseudoElementsBC = [':before', ':after', ':first-line', ':first-letter']
|
|
327
|
-
|
|
328
|
-
// These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
|
|
329
|
-
let pseudoElementExceptions = [
|
|
330
|
-
'::file-selector-button',
|
|
331
|
-
|
|
332
|
-
// Webkit scroll bar pseudo elements can be combined with user-action pseudo classes
|
|
333
|
-
'::-webkit-scrollbar',
|
|
334
|
-
'::-webkit-scrollbar-button',
|
|
335
|
-
'::-webkit-scrollbar-thumb',
|
|
336
|
-
'::-webkit-scrollbar-track',
|
|
337
|
-
'::-webkit-scrollbar-track-piece',
|
|
338
|
-
'::-webkit-scrollbar-corner',
|
|
339
|
-
'::-webkit-resizer',
|
|
340
|
-
]
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* This will make sure to move pseudo's to the correct spot (the end for
|
|
344
|
-
* pseudo elements) because otherwise the selector will never work
|
|
345
|
-
* anyway.
|
|
346
|
-
*
|
|
347
|
-
* E.g.:
|
|
348
|
-
* - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
349
|
-
* - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
350
|
-
*
|
|
351
|
-
* `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
|
|
352
|
-
*
|
|
353
|
-
* @param {Selector} selector
|
|
354
|
-
* @param {boolean} force
|
|
355
|
-
**/
|
|
356
|
-
export function collectPseudoElements(selector, force = false) {
|
|
357
|
-
/** @type {Node[]} */
|
|
358
|
-
let nodes = []
|
|
359
|
-
let seenPseudoElement = null
|
|
360
|
-
|
|
361
|
-
for (let node of [...selector.nodes]) {
|
|
362
|
-
if (isPseudoElement(node, force)) {
|
|
363
|
-
nodes.push(node)
|
|
364
|
-
selector.removeChild(node)
|
|
365
|
-
seenPseudoElement = node.value
|
|
366
|
-
} else if (seenPseudoElement !== null) {
|
|
367
|
-
if (pseudoElementExceptions.includes(seenPseudoElement) && isPseudoClass(node, force)) {
|
|
368
|
-
nodes.push(node)
|
|
369
|
-
selector.removeChild(node)
|
|
370
|
-
} else {
|
|
371
|
-
seenPseudoElement = null
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
if (node?.nodes) {
|
|
376
|
-
let hasPseudoElementRestrictions =
|
|
377
|
-
node.type === 'pseudo' && (node.value === ':is' || node.value === ':has')
|
|
378
|
-
|
|
379
|
-
let [collected, seenPseudoElementInSelector] = collectPseudoElements(
|
|
380
|
-
node,
|
|
381
|
-
force || hasPseudoElementRestrictions
|
|
382
|
-
)
|
|
383
|
-
|
|
384
|
-
if (seenPseudoElementInSelector) {
|
|
385
|
-
seenPseudoElement = seenPseudoElementInSelector
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
nodes.push(...collected)
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
return [nodes, seenPseudoElement]
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
// This will make sure to move pseudo's to the correct spot (the end for
|
|
396
|
-
// pseudo elements) because otherwise the selector will never work
|
|
397
|
-
// anyway.
|
|
398
|
-
//
|
|
399
|
-
// E.g.:
|
|
400
|
-
// - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
401
|
-
// - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
402
|
-
//
|
|
403
|
-
// `::before:hover` doesn't work, which means that we can make it work
|
|
404
|
-
// for you by flipping the order.
|
|
405
|
-
export function sortSelector(a, z) {
|
|
406
|
-
// Both nodes are non-pseudo's so we can safely ignore them and keep
|
|
407
|
-
// them in the same order.
|
|
408
|
-
if (a.type !== 'pseudo' && z.type !== 'pseudo') {
|
|
409
|
-
return 0
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// If one of them is a combinator, we need to keep it in the same order
|
|
413
|
-
// because that means it will start a new "section" in the selector.
|
|
414
|
-
if ((a.type === 'combinator') ^ (z.type === 'combinator')) {
|
|
415
|
-
return 0
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
// One of the items is a pseudo and the other one isn't. Let's move
|
|
419
|
-
// the pseudo to the right.
|
|
420
|
-
if ((a.type === 'pseudo') ^ (z.type === 'pseudo')) {
|
|
421
|
-
return (a.type === 'pseudo') - (z.type === 'pseudo')
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
// Both are pseudo's, move the pseudo elements (except for
|
|
425
|
-
// ::file-selector-button) to the right.
|
|
426
|
-
return isPseudoElement(a) - isPseudoElement(z)
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
function isPseudoElement(node, force = false) {
|
|
430
|
-
if (node.type !== 'pseudo') return false
|
|
431
|
-
if (pseudoElementExceptions.includes(node.value) && !force) return false
|
|
432
|
-
|
|
433
|
-
return node.value.startsWith('::') || pseudoElementsBC.includes(node.value)
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
function isPseudoClass(node, force) {
|
|
437
|
-
return node.type === 'pseudo' && !isPseudoElement(node, force)
|
|
438
|
-
}
|
package/src/util/pluginUtils.js
CHANGED
|
@@ -115,11 +115,7 @@ export function parseColorFormat(value) {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
function unwrapArbitraryModifier(modifier) {
|
|
118
|
-
|
|
119
|
-
if (modifier.startsWith('--')) {
|
|
120
|
-
modifier = `var(${modifier})`
|
|
121
|
-
}
|
|
122
|
-
return modifier
|
|
118
|
+
return normalize(modifier.slice(1, -1))
|
|
123
119
|
}
|
|
124
120
|
|
|
125
121
|
export function asColor(modifier, options = {}, { tailwindConfig = {} } = {}) {
|