tailwindcss 0.0.0-insiders.bd970d0 → 0.0.0-insiders.bda8421
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/README.md +1 -2
- package/lib/cli/build/deps.js +62 -0
- package/lib/cli/build/index.js +12 -15
- package/lib/cli/build/plugin.js +107 -167
- package/lib/cli/build/utils.js +13 -13
- package/lib/cli/build/watching.js +10 -10
- package/lib/cli/help/index.js +11 -11
- package/lib/cli/index.js +60 -61
- package/lib/cli/init/index.js +16 -16
- package/lib/cli-peer-dependencies.js +36 -0
- package/lib/cli.js +1 -1
- package/lib/corePluginList.js +4 -1
- package/lib/corePlugins.js +2018 -1905
- package/lib/css/preflight.css +18 -12
- package/lib/featureFlags.js +17 -23
- package/lib/index.js +1 -1
- package/lib/lib/cacheInvalidation.js +3 -3
- package/lib/lib/collapseAdjacentRules.js +6 -6
- package/lib/lib/collapseDuplicateDeclarations.js +1 -1
- package/lib/lib/content.js +39 -32
- package/lib/lib/defaultExtractor.js +40 -17
- package/lib/lib/evaluateTailwindFunctions.js +23 -23
- package/lib/lib/expandApplyAtRules.js +37 -18
- package/lib/lib/expandTailwindAtRules.js +49 -85
- package/lib/lib/findAtConfigPath.js +5 -5
- package/lib/lib/generateRules.js +82 -55
- package/lib/lib/getModuleDependencies.js +23 -23
- package/lib/lib/load-config.js +21 -6
- package/lib/lib/normalizeTailwindDirectives.js +36 -21
- package/lib/lib/offsets.js +97 -48
- package/lib/lib/partitionApplyAtRules.js +2 -2
- package/lib/lib/regex.js +5 -5
- package/lib/lib/resolveDefaultsAtRules.js +27 -25
- package/lib/lib/setupContextUtils.js +195 -167
- package/lib/lib/setupTrackingContext.js +4 -5
- package/lib/lib/sharedState.js +10 -10
- package/lib/lib/substituteScreenAtRules.js +4 -4
- package/lib/plugin.js +8 -124
- package/lib/postcss-plugins/nesting/index.js +2 -2
- package/lib/postcss-plugins/nesting/plugin.js +11 -11
- package/lib/processTailwindFeatures.js +3 -5
- package/lib/public/colors.js +264 -264
- package/lib/util/applyImportantSelector.js +2 -2
- package/lib/util/buildMediaQuery.js +2 -2
- package/lib/util/cloneDeep.js +1 -1
- package/lib/util/cloneNodes.js +33 -13
- package/lib/util/color.js +19 -19
- package/lib/util/createUtilityPlugin.js +3 -3
- package/lib/util/dataTypes.js +170 -113
- package/lib/util/defaults.js +4 -4
- package/lib/util/escapeClassName.js +2 -2
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +2 -2
- package/lib/util/formatVariantSelector.js +24 -19
- package/lib/util/getAllConfigs.js +4 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +2 -2
- package/lib/util/isSyntacticallyValidPropertyValue.js +10 -10
- package/lib/util/log.js +6 -23
- package/lib/util/nameClass.js +4 -4
- package/lib/util/negateValue.js +8 -8
- package/lib/util/normalizeConfig.js +63 -94
- package/lib/util/normalizeScreens.js +18 -18
- package/lib/util/parseAnimationValue.js +38 -38
- package/lib/util/parseBoxShadowValue.js +18 -18
- package/lib/util/parseDependency.js +4 -4
- package/lib/util/parseGlob.js +4 -4
- package/lib/util/parseObjectStyles.js +1 -1
- package/lib/util/pluginUtils.js +36 -21
- package/lib/util/prefixSelector.js +4 -4
- package/lib/util/pseudoElements.js +72 -69
- package/lib/util/removeAlphaVariables.js +1 -1
- package/lib/util/resolveConfig.js +11 -15
- package/lib/util/resolveConfigPath.js +6 -6
- package/lib/util/responsive.js +1 -1
- package/lib/util/splitAtTopLevelOnly.js +3 -3
- package/lib/util/toColorValue.js +1 -1
- package/lib/util/toPath.js +2 -2
- package/lib/util/transformThemeValue.js +24 -24
- package/lib/util/validateConfig.js +9 -20
- package/lib/util/validateFormalSyntax.js +5 -5
- package/lib/util/withAlphaVariable.js +5 -5
- package/lib/value-parser/index.js +5 -5
- package/lib/value-parser/parse.js +43 -43
- package/lib/value-parser/stringify.js +11 -11
- package/lib/value-parser/unit.js +5 -5
- package/lib/value-parser/walk.js +1 -1
- package/nesting/index.d.ts +4 -0
- package/package.json +41 -36
- package/peers/index.js +96503 -0
- package/resolveConfig.d.ts +22 -3
- package/scripts/generate-types.js +1 -2
- package/scripts/release-notes.js +1 -1
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +0 -4
- package/src/cli/build/plugin.js +53 -85
- package/src/cli/build/watching.js +1 -1
- package/src/cli/index.js +0 -1
- package/src/cli-peer-dependencies.js +15 -0
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +118 -31
- package/src/css/preflight.css +18 -12
- package/src/featureFlags.js +3 -5
- package/src/lib/content.js +39 -30
- package/src/lib/defaultExtractor.js +29 -6
- package/src/lib/expandApplyAtRules.js +24 -0
- package/src/lib/expandTailwindAtRules.js +19 -56
- package/src/lib/generateRules.js +39 -8
- package/src/lib/load-config.ts +13 -0
- package/src/lib/normalizeTailwindDirectives.js +27 -0
- package/src/lib/offsets.js +62 -3
- package/src/lib/resolveDefaultsAtRules.js +5 -1
- package/src/lib/setupContextUtils.js +79 -39
- package/src/plugin.js +0 -86
- package/src/processTailwindFeatures.js +0 -3
- package/src/util/cloneNodes.js +35 -14
- package/src/util/dataTypes.js +72 -6
- package/src/util/formatVariantSelector.js +7 -0
- package/src/util/isPlainObject.js +1 -1
- package/src/util/log.js +0 -24
- package/src/util/normalizeConfig.js +11 -38
- package/src/util/pluginUtils.js +20 -0
- package/src/util/pseudoElements.js +4 -0
- package/src/util/validateConfig.js +0 -10
- package/stubs/config.full.js +68 -8
- package/stubs/config.simple.js +1 -1
- package/stubs/postcss.config.cjs +1 -0
- package/stubs/postcss.config.js +1 -0
- package/types/config.d.ts +12 -5
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +28 -9
- package/types/index.d.ts +7 -3
- package/index.css +0 -5
- package/lib/lib/detectNesting.js +0 -45
- package/lib/lib/handleImportAtRules.js +0 -50
- package/src/lib/detectNesting.js +0 -47
- package/src/lib/handleImportAtRules.js +0 -34
|
@@ -50,9 +50,9 @@ function normalizeScreens(screens, root = true) {
|
|
|
50
50
|
if (Array.isArray(screens)) {
|
|
51
51
|
return screens.map((screen)=>{
|
|
52
52
|
if (root && Array.isArray(screen)) {
|
|
53
|
-
throw new Error(
|
|
53
|
+
throw new Error("The tuple syntax is not supported for `screens`.");
|
|
54
54
|
}
|
|
55
|
-
if (typeof screen ===
|
|
55
|
+
if (typeof screen === "string") {
|
|
56
56
|
return {
|
|
57
57
|
name: screen.toString(),
|
|
58
58
|
not: false,
|
|
@@ -66,7 +66,7 @@ function normalizeScreens(screens, root = true) {
|
|
|
66
66
|
}
|
|
67
67
|
let [name, options] = screen;
|
|
68
68
|
name = name.toString();
|
|
69
|
-
if (typeof options ===
|
|
69
|
+
if (typeof options === "string") {
|
|
70
70
|
return {
|
|
71
71
|
name,
|
|
72
72
|
not: false,
|
|
@@ -100,17 +100,17 @@ function isScreenSortable(screen) {
|
|
|
100
100
|
if (screen.values.length !== 1) {
|
|
101
101
|
return {
|
|
102
102
|
result: false,
|
|
103
|
-
reason:
|
|
103
|
+
reason: "multiple-values"
|
|
104
104
|
};
|
|
105
105
|
} else if (screen.values[0].raw !== undefined) {
|
|
106
106
|
return {
|
|
107
107
|
result: false,
|
|
108
|
-
reason:
|
|
108
|
+
reason: "raw-values"
|
|
109
109
|
};
|
|
110
110
|
} else if (screen.values[0].min !== undefined && screen.values[0].max !== undefined) {
|
|
111
111
|
return {
|
|
112
112
|
result: false,
|
|
113
|
-
reason:
|
|
113
|
+
reason: "min-and-max"
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
return {
|
|
@@ -124,16 +124,16 @@ function compareScreens(type, a, z) {
|
|
|
124
124
|
let aSorting = isScreenSortable(aScreen);
|
|
125
125
|
let bSorting = isScreenSortable(zScreen);
|
|
126
126
|
// These cases should never happen and indicate a bug in Tailwind CSS itself
|
|
127
|
-
if (aSorting.reason ===
|
|
128
|
-
throw new Error(
|
|
129
|
-
} else if (aSorting.reason ===
|
|
130
|
-
throw new Error(
|
|
131
|
-
} else if (aSorting.reason ===
|
|
132
|
-
throw new Error(
|
|
127
|
+
if (aSorting.reason === "multiple-values" || bSorting.reason === "multiple-values") {
|
|
128
|
+
throw new Error("Attempted to sort a screen with multiple values. This should never happen. Please open a bug report.");
|
|
129
|
+
} else if (aSorting.reason === "raw-values" || bSorting.reason === "raw-values") {
|
|
130
|
+
throw new Error("Attempted to sort a screen with raw values. This should never happen. Please open a bug report.");
|
|
131
|
+
} else if (aSorting.reason === "min-and-max" || bSorting.reason === "min-and-max") {
|
|
132
|
+
throw new Error("Attempted to sort a screen with both min and max values. This should never happen. Please open a bug report.");
|
|
133
133
|
}
|
|
134
134
|
// Let the sorting begin
|
|
135
|
-
let { min: aMin, max: aMax
|
|
136
|
-
let { min: zMin, max: zMax
|
|
135
|
+
let { min: aMin , max: aMax } = aScreen.values[0];
|
|
136
|
+
let { min: zMin , max: zMax } = zScreen.values[0];
|
|
137
137
|
// Negating screens flip their behavior. Basically `not min-width` is `max-width`
|
|
138
138
|
if (a.not) [aMin, aMax] = [
|
|
139
139
|
aMax,
|
|
@@ -147,7 +147,7 @@ function compareScreens(type, a, z) {
|
|
|
147
147
|
aMax = aMax === undefined ? aMax : parseFloat(aMax);
|
|
148
148
|
zMin = zMin === undefined ? zMin : parseFloat(zMin);
|
|
149
149
|
zMax = zMax === undefined ? zMax : parseFloat(zMax);
|
|
150
|
-
let [aValue, zValue] = type ===
|
|
150
|
+
let [aValue, zValue] = type === "min" ? [
|
|
151
151
|
aMin,
|
|
152
152
|
zMin
|
|
153
153
|
] : [
|
|
@@ -157,11 +157,11 @@ function compareScreens(type, a, z) {
|
|
|
157
157
|
return aValue - zValue;
|
|
158
158
|
}
|
|
159
159
|
function toScreen(value, type) {
|
|
160
|
-
if (typeof value ===
|
|
160
|
+
if (typeof value === "object") {
|
|
161
161
|
return value;
|
|
162
162
|
}
|
|
163
163
|
return {
|
|
164
|
-
name:
|
|
164
|
+
name: "arbitrary-screen",
|
|
165
165
|
values: [
|
|
166
166
|
{
|
|
167
167
|
[type]: value
|
|
@@ -169,7 +169,7 @@ function toScreen(value, type) {
|
|
|
169
169
|
]
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
|
-
function resolveValue({
|
|
172
|
+
function resolveValue({ "min-width": _minWidth , min =_minWidth , max , raw } = {}) {
|
|
173
173
|
return {
|
|
174
174
|
min,
|
|
175
175
|
max,
|
|
@@ -9,36 +9,36 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const DIRECTIONS = new Set([
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
"normal",
|
|
13
|
+
"reverse",
|
|
14
|
+
"alternate",
|
|
15
|
+
"alternate-reverse"
|
|
16
16
|
]);
|
|
17
17
|
const PLAY_STATES = new Set([
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
"running",
|
|
19
|
+
"paused"
|
|
20
20
|
]);
|
|
21
21
|
const FILL_MODES = new Set([
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
"none",
|
|
23
|
+
"forwards",
|
|
24
|
+
"backwards",
|
|
25
|
+
"both"
|
|
26
26
|
]);
|
|
27
27
|
const ITERATION_COUNTS = new Set([
|
|
28
|
-
|
|
28
|
+
"infinite"
|
|
29
29
|
]);
|
|
30
30
|
const TIMINGS = new Set([
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
"linear",
|
|
32
|
+
"ease",
|
|
33
|
+
"ease-in",
|
|
34
|
+
"ease-out",
|
|
35
|
+
"ease-in-out",
|
|
36
|
+
"step-start",
|
|
37
|
+
"step-end"
|
|
38
38
|
]);
|
|
39
39
|
const TIMING_FNS = [
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
"cubic-bezier",
|
|
41
|
+
"steps"
|
|
42
42
|
];
|
|
43
43
|
const COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
|
|
44
44
|
;
|
|
@@ -56,33 +56,33 @@ function parseAnimationValue(input) {
|
|
|
56
56
|
let parts = value.split(SPACE);
|
|
57
57
|
let seen = new Set();
|
|
58
58
|
for (let part of parts){
|
|
59
|
-
if (!seen.has(
|
|
59
|
+
if (!seen.has("DIRECTIONS") && DIRECTIONS.has(part)) {
|
|
60
60
|
result.direction = part;
|
|
61
|
-
seen.add(
|
|
62
|
-
} else if (!seen.has(
|
|
61
|
+
seen.add("DIRECTIONS");
|
|
62
|
+
} else if (!seen.has("PLAY_STATES") && PLAY_STATES.has(part)) {
|
|
63
63
|
result.playState = part;
|
|
64
|
-
seen.add(
|
|
65
|
-
} else if (!seen.has(
|
|
64
|
+
seen.add("PLAY_STATES");
|
|
65
|
+
} else if (!seen.has("FILL_MODES") && FILL_MODES.has(part)) {
|
|
66
66
|
result.fillMode = part;
|
|
67
|
-
seen.add(
|
|
68
|
-
} else if (!seen.has(
|
|
67
|
+
seen.add("FILL_MODES");
|
|
68
|
+
} else if (!seen.has("ITERATION_COUNTS") && (ITERATION_COUNTS.has(part) || DIGIT.test(part))) {
|
|
69
69
|
result.iterationCount = part;
|
|
70
|
-
seen.add(
|
|
71
|
-
} else if (!seen.has(
|
|
70
|
+
seen.add("ITERATION_COUNTS");
|
|
71
|
+
} else if (!seen.has("TIMING_FUNCTION") && TIMINGS.has(part)) {
|
|
72
72
|
result.timingFunction = part;
|
|
73
|
-
seen.add(
|
|
74
|
-
} else if (!seen.has(
|
|
73
|
+
seen.add("TIMING_FUNCTION");
|
|
74
|
+
} else if (!seen.has("TIMING_FUNCTION") && TIMING_FNS.some((f)=>part.startsWith(`${f}(`))) {
|
|
75
75
|
result.timingFunction = part;
|
|
76
|
-
seen.add(
|
|
77
|
-
} else if (!seen.has(
|
|
76
|
+
seen.add("TIMING_FUNCTION");
|
|
77
|
+
} else if (!seen.has("DURATION") && TIME.test(part)) {
|
|
78
78
|
result.duration = part;
|
|
79
|
-
seen.add(
|
|
80
|
-
} else if (!seen.has(
|
|
79
|
+
seen.add("DURATION");
|
|
80
|
+
} else if (!seen.has("DELAY") && TIME.test(part)) {
|
|
81
81
|
result.delay = part;
|
|
82
|
-
seen.add(
|
|
83
|
-
} else if (!seen.has(
|
|
82
|
+
seen.add("DELAY");
|
|
83
|
+
} else if (!seen.has("NAME")) {
|
|
84
84
|
result.name = part;
|
|
85
|
-
seen.add(
|
|
85
|
+
seen.add("NAME");
|
|
86
86
|
} else {
|
|
87
87
|
if (!result.unknown) result.unknown = [];
|
|
88
88
|
result.unknown.push(part);
|
|
@@ -18,17 +18,17 @@ _export(exports, {
|
|
|
18
18
|
});
|
|
19
19
|
const _splitAtTopLevelOnly = require("./splitAtTopLevelOnly");
|
|
20
20
|
let KEYWORDS = new Set([
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
"inset",
|
|
22
|
+
"inherit",
|
|
23
|
+
"initial",
|
|
24
|
+
"revert",
|
|
25
|
+
"unset"
|
|
26
26
|
]);
|
|
27
27
|
let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
|
|
28
28
|
;
|
|
29
29
|
let LENGTH = /^-?(\d+|\.\d+)(.*?)$/g;
|
|
30
30
|
function parseBoxShadowValue(input) {
|
|
31
|
-
let shadows = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(input,
|
|
31
|
+
let shadows = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(input, ",");
|
|
32
32
|
return shadows.map((shadow)=>{
|
|
33
33
|
let value = shadow.trim();
|
|
34
34
|
let result = {
|
|
@@ -40,22 +40,22 @@ function parseBoxShadowValue(input) {
|
|
|
40
40
|
// Reset index, since the regex is stateful.
|
|
41
41
|
LENGTH.lastIndex = 0;
|
|
42
42
|
// Keyword
|
|
43
|
-
if (!seen.has(
|
|
43
|
+
if (!seen.has("KEYWORD") && KEYWORDS.has(part)) {
|
|
44
44
|
result.keyword = part;
|
|
45
|
-
seen.add(
|
|
45
|
+
seen.add("KEYWORD");
|
|
46
46
|
} else if (LENGTH.test(part)) {
|
|
47
|
-
if (!seen.has(
|
|
47
|
+
if (!seen.has("X")) {
|
|
48
48
|
result.x = part;
|
|
49
|
-
seen.add(
|
|
50
|
-
} else if (!seen.has(
|
|
49
|
+
seen.add("X");
|
|
50
|
+
} else if (!seen.has("Y")) {
|
|
51
51
|
result.y = part;
|
|
52
|
-
seen.add(
|
|
53
|
-
} else if (!seen.has(
|
|
52
|
+
seen.add("Y");
|
|
53
|
+
} else if (!seen.has("BLUR")) {
|
|
54
54
|
result.blur = part;
|
|
55
|
-
seen.add(
|
|
56
|
-
} else if (!seen.has(
|
|
55
|
+
seen.add("BLUR");
|
|
56
|
+
} else if (!seen.has("SPREAD")) {
|
|
57
57
|
result.spread = part;
|
|
58
|
-
seen.add(
|
|
58
|
+
seen.add("SPREAD");
|
|
59
59
|
}
|
|
60
60
|
} else {
|
|
61
61
|
if (!result.color) {
|
|
@@ -83,6 +83,6 @@ function formatBoxShadowValue(shadows) {
|
|
|
83
83
|
shadow.blur,
|
|
84
84
|
shadow.spread,
|
|
85
85
|
shadow.color
|
|
86
|
-
].filter(Boolean).join(
|
|
87
|
-
}).join(
|
|
86
|
+
].filter(Boolean).join(" ");
|
|
87
|
+
}).join(", ");
|
|
88
88
|
}
|
|
@@ -22,24 +22,24 @@ function parseDependency(contentPath) {
|
|
|
22
22
|
if (!contentPath.glob) {
|
|
23
23
|
return [
|
|
24
24
|
{
|
|
25
|
-
type:
|
|
25
|
+
type: "dependency",
|
|
26
26
|
file: contentPath.base
|
|
27
27
|
}
|
|
28
28
|
];
|
|
29
29
|
}
|
|
30
|
-
if (process.env.ROLLUP_WATCH ===
|
|
30
|
+
if (process.env.ROLLUP_WATCH === "true") {
|
|
31
31
|
// rollup-plugin-postcss does not support dir-dependency messages
|
|
32
32
|
// but directories can be watched in the same way as files
|
|
33
33
|
return [
|
|
34
34
|
{
|
|
35
|
-
type:
|
|
35
|
+
type: "dependency",
|
|
36
36
|
file: contentPath.base
|
|
37
37
|
}
|
|
38
38
|
];
|
|
39
39
|
}
|
|
40
40
|
return [
|
|
41
41
|
{
|
|
42
|
-
type:
|
|
42
|
+
type: "dir-dependency",
|
|
43
43
|
dir: contentPath.base,
|
|
44
44
|
glob: contentPath.glob
|
|
45
45
|
}
|
package/lib/util/parseGlob.js
CHANGED
|
@@ -17,16 +17,16 @@ function _interop_require_default(obj) {
|
|
|
17
17
|
function parseGlob(pattern) {
|
|
18
18
|
let glob = pattern;
|
|
19
19
|
let base = (0, _globparent.default)(pattern);
|
|
20
|
-
if (base !==
|
|
20
|
+
if (base !== ".") {
|
|
21
21
|
glob = pattern.substr(base.length);
|
|
22
|
-
if (glob.charAt(0) ===
|
|
22
|
+
if (glob.charAt(0) === "/") {
|
|
23
23
|
glob = glob.substr(1);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
if (glob.substr(0, 2) ===
|
|
26
|
+
if (glob.substr(0, 2) === "./") {
|
|
27
27
|
glob = glob.substr(2);
|
|
28
28
|
}
|
|
29
|
-
if (glob.charAt(0) ===
|
|
29
|
+
if (glob.charAt(0) === "/") {
|
|
30
30
|
glob = glob.substr(1);
|
|
31
31
|
}
|
|
32
32
|
return {
|
package/lib/util/pluginUtils.js
CHANGED
|
@@ -39,6 +39,7 @@ const _withAlphaVariable = require("./withAlphaVariable");
|
|
|
39
39
|
const _dataTypes = require("./dataTypes");
|
|
40
40
|
const _negateValue = /*#__PURE__*/ _interop_require_default(require("./negateValue"));
|
|
41
41
|
const _validateFormalSyntax = require("./validateFormalSyntax");
|
|
42
|
+
const _featureFlags = require("../featureFlags.js");
|
|
42
43
|
function _interop_require_default(obj) {
|
|
43
44
|
return obj && obj.__esModule ? obj : {
|
|
44
45
|
default: obj
|
|
@@ -75,22 +76,35 @@ function asNegativeValue(modifier, lookup = {}, validate) {
|
|
|
75
76
|
return (0, _negateValue.default)(resolved);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
|
-
function asValue(modifier, options = {}, { validate =
|
|
79
|
+
function asValue(modifier, options = {}, { validate =()=>true } = {}) {
|
|
79
80
|
var _options_values;
|
|
80
81
|
let value = (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
|
|
81
82
|
if (value !== undefined) {
|
|
82
83
|
return value;
|
|
83
84
|
}
|
|
84
|
-
if (options.supportsNegativeValues && modifier.startsWith(
|
|
85
|
+
if (options.supportsNegativeValues && modifier.startsWith("-")) {
|
|
85
86
|
return asNegativeValue(modifier.slice(1), options.values, validate);
|
|
86
87
|
}
|
|
87
88
|
return resolveArbitraryValue(modifier, validate);
|
|
88
89
|
}
|
|
89
90
|
function isArbitraryValue(input) {
|
|
90
|
-
return input.startsWith(
|
|
91
|
+
return input.startsWith("[") && input.endsWith("]");
|
|
91
92
|
}
|
|
92
93
|
function splitUtilityModifier(modifier) {
|
|
93
|
-
let slashIdx = modifier.lastIndexOf(
|
|
94
|
+
let slashIdx = modifier.lastIndexOf("/");
|
|
95
|
+
// If the `/` is inside an arbitrary, we want to find the previous one if any
|
|
96
|
+
// This logic probably isn't perfect but it should work for most cases
|
|
97
|
+
let arbitraryStartIdx = modifier.lastIndexOf("[", slashIdx);
|
|
98
|
+
let arbitraryEndIdx = modifier.indexOf("]", slashIdx);
|
|
99
|
+
let isNextToArbitrary = modifier[slashIdx - 1] === "]" || modifier[slashIdx + 1] === "[";
|
|
100
|
+
// Backtrack to the previous `/` if the one we found was inside an arbitrary
|
|
101
|
+
if (!isNextToArbitrary) {
|
|
102
|
+
if (arbitraryStartIdx !== -1 && arbitraryEndIdx !== -1) {
|
|
103
|
+
if (arbitraryStartIdx < slashIdx && slashIdx < arbitraryEndIdx) {
|
|
104
|
+
slashIdx = modifier.lastIndexOf("/", arbitraryStartIdx);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
94
108
|
if (slashIdx === -1 || slashIdx === modifier.length - 1) {
|
|
95
109
|
return [
|
|
96
110
|
modifier,
|
|
@@ -101,7 +115,7 @@ function splitUtilityModifier(modifier) {
|
|
|
101
115
|
// The modifier could be of the form `[foo]/[bar]`
|
|
102
116
|
// We want to handle this case properly
|
|
103
117
|
// without affecting `[foo/bar]`
|
|
104
|
-
if (arbitrary && !modifier.includes(
|
|
118
|
+
if (arbitrary && !modifier.includes("]/[")) {
|
|
105
119
|
return [
|
|
106
120
|
modifier,
|
|
107
121
|
undefined
|
|
@@ -113,16 +127,16 @@ function splitUtilityModifier(modifier) {
|
|
|
113
127
|
];
|
|
114
128
|
}
|
|
115
129
|
function parseColorFormat(value) {
|
|
116
|
-
if (typeof value ===
|
|
130
|
+
if (typeof value === "string" && value.includes("<alpha-value>")) {
|
|
117
131
|
let oldValue = value;
|
|
118
|
-
return ({ opacityValue =
|
|
132
|
+
return ({ opacityValue =1 })=>oldValue.replace("<alpha-value>", opacityValue);
|
|
119
133
|
}
|
|
120
134
|
return value;
|
|
121
135
|
}
|
|
122
136
|
function unwrapArbitraryModifier(modifier) {
|
|
123
137
|
return (0, _dataTypes.normalize)(modifier.slice(1, -1));
|
|
124
138
|
}
|
|
125
|
-
function asColor(modifier, options = {}, { tailwindConfig =
|
|
139
|
+
function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
|
|
126
140
|
var _options_values;
|
|
127
141
|
if (((_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier]) !== undefined) {
|
|
128
142
|
var _options_values1;
|
|
@@ -132,7 +146,7 @@ function asColor(modifier, options = {}, { tailwindConfig = {} } = {}) {
|
|
|
132
146
|
// We do this here because we need the alpha value (if any)
|
|
133
147
|
let [color, alpha] = splitUtilityModifier(modifier);
|
|
134
148
|
if (alpha !== undefined) {
|
|
135
|
-
var _options_values2,
|
|
149
|
+
var _options_values2, _tailwindConfig_theme, _tailwindConfig_theme_opacity;
|
|
136
150
|
var _options_values_color;
|
|
137
151
|
let normalizedColor = (_options_values_color = (_options_values2 = options.values) === null || _options_values2 === void 0 ? void 0 : _options_values2[color]) !== null && _options_values_color !== void 0 ? _options_values_color : isArbitraryValue(color) ? color.slice(1, -1) : undefined;
|
|
138
152
|
if (normalizedColor === undefined) {
|
|
@@ -171,12 +185,12 @@ let typeMap = {
|
|
|
171
185
|
percentage: guess(_dataTypes.percentage),
|
|
172
186
|
position: guess(_dataTypes.position),
|
|
173
187
|
lookup: asLookupValue,
|
|
174
|
-
|
|
175
|
-
|
|
188
|
+
"generic-name": guess(_dataTypes.genericName),
|
|
189
|
+
"family-name": guess(_dataTypes.familyName),
|
|
176
190
|
number: guess(_dataTypes.number),
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
191
|
+
"line-width": guess(_dataTypes.lineWidth),
|
|
192
|
+
"absolute-size": guess(_dataTypes.absoluteSize),
|
|
193
|
+
"relative-size": guess(_dataTypes.relativeSize),
|
|
180
194
|
shadow: guess(_dataTypes.shadow),
|
|
181
195
|
size: guess(_validateFormalSyntax.backgroundSize)
|
|
182
196
|
};
|
|
@@ -194,7 +208,7 @@ function splitAtFirst(input, delim) {
|
|
|
194
208
|
}
|
|
195
209
|
function coerceValue(types, modifier, options, tailwindConfig) {
|
|
196
210
|
if (options.values && modifier in options.values) {
|
|
197
|
-
for (let { type
|
|
211
|
+
for (let { type } of types !== null && types !== void 0 ? types : []){
|
|
198
212
|
let result = typeMap[type](modifier, options, {
|
|
199
213
|
tailwindConfig
|
|
200
214
|
});
|
|
@@ -210,7 +224,7 @@ function coerceValue(types, modifier, options, tailwindConfig) {
|
|
|
210
224
|
}
|
|
211
225
|
if (isArbitraryValue(modifier)) {
|
|
212
226
|
let arbitraryValue = modifier.slice(1, -1);
|
|
213
|
-
let [explicitType, value] = splitAtFirst(arbitraryValue,
|
|
227
|
+
let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
|
|
214
228
|
// It could be that this resolves to `url(https` which is not a valid
|
|
215
229
|
// identifier. We currently only support "simple" words with dashes or
|
|
216
230
|
// underscores. E.g.: family-name
|
|
@@ -235,19 +249,20 @@ function coerceValue(types, modifier, options, tailwindConfig) {
|
|
|
235
249
|
return [];
|
|
236
250
|
}
|
|
237
251
|
function* getMatchingTypes(types, rawModifier, options, tailwindConfig) {
|
|
252
|
+
let modifiersEnabled = (0, _featureFlags.flagEnabled)(tailwindConfig, "generalizedModifiers");
|
|
238
253
|
let [modifier, utilityModifier] = splitUtilityModifier(rawModifier);
|
|
239
|
-
let canUseUtilityModifier = options.modifiers != null && (options.modifiers ===
|
|
254
|
+
let canUseUtilityModifier = modifiersEnabled && options.modifiers != null && (options.modifiers === "any" || typeof options.modifiers === "object" && (utilityModifier && isArbitraryValue(utilityModifier) || utilityModifier in options.modifiers));
|
|
240
255
|
if (!canUseUtilityModifier) {
|
|
241
256
|
modifier = rawModifier;
|
|
242
257
|
utilityModifier = undefined;
|
|
243
258
|
}
|
|
244
|
-
if (utilityModifier !== undefined && modifier ===
|
|
245
|
-
modifier =
|
|
259
|
+
if (utilityModifier !== undefined && modifier === "") {
|
|
260
|
+
modifier = "DEFAULT";
|
|
246
261
|
}
|
|
247
262
|
// Check the full value first
|
|
248
263
|
// TODO: Move to asValue… somehow
|
|
249
264
|
if (utilityModifier !== undefined) {
|
|
250
|
-
if (typeof options.modifiers ===
|
|
265
|
+
if (typeof options.modifiers === "object") {
|
|
251
266
|
var _options_modifiers;
|
|
252
267
|
var _options_modifiers_utilityModifier;
|
|
253
268
|
let configValue = (_options_modifiers_utilityModifier = (_options_modifiers = options.modifiers) === null || _options_modifiers === void 0 ? void 0 : _options_modifiers[utilityModifier]) !== null && _options_modifiers_utilityModifier !== void 0 ? _options_modifiers_utilityModifier : null;
|
|
@@ -258,7 +273,7 @@ function* getMatchingTypes(types, rawModifier, options, tailwindConfig) {
|
|
|
258
273
|
}
|
|
259
274
|
}
|
|
260
275
|
}
|
|
261
|
-
for (let { type
|
|
276
|
+
for (let { type } of types !== null && types !== void 0 ? types : []){
|
|
262
277
|
let result = typeMap[type](modifier, options, {
|
|
263
278
|
tailwindConfig
|
|
264
279
|
});
|
|
@@ -26,14 +26,14 @@ function _interop_require_default(obj) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
function _default(prefix, selector, prependNegative = false) {
|
|
29
|
-
if (prefix ===
|
|
29
|
+
if (prefix === "") {
|
|
30
30
|
return selector;
|
|
31
31
|
}
|
|
32
|
-
/** @type {import('postcss-selector-parser').Root} */ let ast = typeof selector ===
|
|
32
|
+
/** @type {import('postcss-selector-parser').Root} */ let ast = typeof selector === "string" ? (0, _postcssselectorparser.default)().astSync(selector) : selector;
|
|
33
33
|
ast.walkClasses((classSelector)=>{
|
|
34
34
|
let baseClass = classSelector.value;
|
|
35
|
-
let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith(
|
|
35
|
+
let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
|
|
36
36
|
classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
|
|
37
37
|
});
|
|
38
|
-
return typeof selector ===
|
|
38
|
+
return typeof selector === "string" ? ast.toString() : ast;
|
|
39
39
|
}
|