tailwindcss 0.0.0-insiders.7c337f2 → 0.0.0-insiders.7d8eb21
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 +246 -6
- package/README.md +13 -9
- package/defaultTheme.d.ts +2 -1
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +48 -0
- package/lib/cli/build/plugin.js +362 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +178 -0
- package/lib/cli/help/index.js +71 -0
- package/lib/cli/index.js +18 -0
- package/lib/cli/init/index.js +46 -0
- package/lib/cli/shared.js +12 -0
- package/lib/cli-peer-dependencies.js +18 -5
- package/lib/cli.js +62 -592
- package/lib/constants.js +19 -12
- package/lib/corePluginList.js +5 -3
- package/lib/corePlugins.js +619 -347
- package/lib/css/preflight.css +7 -0
- package/lib/featureFlags.js +34 -22
- package/lib/index.js +16 -9
- package/lib/lib/cacheInvalidation.js +42 -21
- package/lib/lib/collapseAdjacentRules.js +16 -14
- package/lib/lib/collapseDuplicateDeclarations.js +13 -10
- package/lib/lib/content.js +177 -0
- package/lib/lib/defaultExtractor.js +230 -33
- package/lib/lib/detectNesting.js +13 -4
- package/lib/lib/evaluateTailwindFunctions.js +105 -42
- package/lib/lib/expandApplyAtRules.js +151 -92
- package/lib/lib/expandTailwindAtRules.js +134 -149
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +404 -185
- package/lib/lib/getModuleDependencies.js +21 -18
- package/lib/lib/normalizeTailwindDirectives.js +11 -8
- package/lib/lib/offsets.js +285 -0
- package/lib/lib/partitionApplyAtRules.js +14 -11
- package/lib/lib/regex.js +60 -0
- package/lib/lib/remap-bitfield.js +87 -0
- package/lib/lib/resolveDefaultsAtRules.js +97 -79
- package/lib/lib/setupContextUtils.js +567 -242
- package/lib/lib/setupTrackingContext.js +77 -106
- package/lib/lib/sharedState.js +18 -10
- package/lib/lib/substituteScreenAtRules.js +9 -7
- package/lib/postcss-plugins/nesting/index.js +7 -5
- package/lib/postcss-plugins/nesting/plugin.js +10 -8
- package/lib/processTailwindFeatures.js +34 -31
- package/lib/public/colors.js +7 -5
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +13 -10
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +10 -5
- package/lib/util/cloneDeep.js +6 -5
- package/lib/util/cloneNodes.js +9 -2
- package/lib/util/color.js +20 -17
- package/lib/util/configurePlugins.js +5 -2
- package/lib/util/createPlugin.js +6 -5
- package/lib/util/createUtilityPlugin.js +15 -13
- package/lib/util/dataTypes.js +75 -51
- package/lib/util/defaults.js +8 -5
- package/lib/util/escapeClassName.js +13 -10
- package/lib/util/escapeCommas.js +4 -1
- package/lib/util/flattenColorPalette.js +7 -8
- package/lib/util/formatVariantSelector.js +270 -103
- package/lib/util/getAllConfigs.js +34 -15
- package/lib/util/hashConfig.js +10 -7
- package/lib/util/isKeyframeRule.js +4 -1
- package/lib/util/isPlainObject.js +4 -1
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +34 -26
- package/lib/util/log.js +14 -8
- package/lib/util/nameClass.js +19 -8
- package/lib/util/negateValue.js +20 -5
- package/lib/util/normalizeConfig.js +94 -53
- package/lib/util/normalizeScreens.js +115 -4
- package/lib/util/parseAnimationValue.js +43 -41
- package/lib/util/parseBoxShadowValue.js +12 -45
- package/lib/util/parseDependency.js +37 -55
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +15 -12
- package/lib/util/pluginUtils.js +146 -42
- package/lib/util/prefixSelector.js +26 -9
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +104 -105
- package/lib/util/resolveConfigPath.js +20 -17
- package/lib/util/responsive.js +12 -9
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +4 -1
- package/lib/util/toPath.js +18 -2
- package/lib/util/transformThemeValue.js +23 -11
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/validateFormalSyntax.js +24 -0
- package/lib/util/withAlphaVariable.js +32 -24
- package/package.json +32 -29
- package/peers/index.js +6693 -3036
- package/plugin.d.ts +10 -5
- package/resolveConfig.d.ts +12 -0
- package/scripts/generate-types.js +53 -0
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +49 -0
- package/src/cli/build/plugin.js +434 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +227 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +3 -0
- package/src/cli/init/index.js +50 -0
- package/src/cli/shared.js +5 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +46 -659
- package/src/corePlugins.js +346 -79
- package/src/css/preflight.css +7 -0
- package/src/featureFlags.js +12 -2
- package/src/index.js +5 -0
- package/src/lib/content.js +213 -0
- package/src/lib/defaultExtractor.js +202 -35
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/evaluateTailwindFunctions.js +78 -7
- package/src/lib/expandApplyAtRules.js +129 -34
- package/src/lib/expandTailwindAtRules.js +12 -50
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +379 -126
- package/src/lib/offsets.js +351 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/resolveDefaultsAtRules.js +53 -36
- package/src/lib/setupContextUtils.js +510 -120
- package/src/lib/setupTrackingContext.js +8 -45
- package/src/lib/sharedState.js +2 -0
- package/src/util/buildMediaQuery.js +5 -3
- package/src/util/cloneNodes.js +5 -1
- package/src/util/dataTypes.js +51 -26
- package/src/util/formatVariantSelector.js +317 -101
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/log.js +1 -1
- package/src/util/nameClass.js +4 -0
- package/src/util/negateValue.js +10 -2
- package/src/util/normalizeConfig.js +40 -10
- package/src/util/normalizeScreens.js +99 -4
- package/src/util/parseBoxShadowValue.js +3 -50
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +132 -10
- package/src/util/prefixSelector.js +28 -10
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +70 -62
- package/src/util/splitAtTopLevelOnly.js +45 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +13 -3
- package/src/util/validateConfig.js +13 -0
- package/src/util/validateFormalSyntax.js +34 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +165 -164
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +77 -37
- package/types/generated/default-theme.d.ts +342 -0
- package/types/index.d.ts +7 -1
- package/types.d.ts +0 -1
|
@@ -1,63 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {{type: 'dependency', file: string} | {type: 'dir-dependency', dir: string, glob: string}} Dependency
|
|
4
|
+
*/ /**
|
|
5
|
+
*
|
|
6
|
+
* @param {import('../lib/content.js').ContentPath} contentPath
|
|
7
|
+
* @returns {Dependency[]}
|
|
8
|
+
*/ "use strict";
|
|
2
9
|
Object.defineProperty(exports, "__esModule", {
|
|
3
10
|
value: true
|
|
4
11
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function parseDependency(
|
|
10
|
-
if (
|
|
11
|
-
return
|
|
12
|
+
Object.defineProperty(exports, "default", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: ()=>parseDependency
|
|
15
|
+
});
|
|
16
|
+
function parseDependency(contentPath) {
|
|
17
|
+
if (contentPath.ignore) {
|
|
18
|
+
return [];
|
|
12
19
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
} else {
|
|
22
|
-
message = {
|
|
23
|
-
type: "dependency",
|
|
24
|
-
file: _path.default.resolve(normalizedFileOrGlob)
|
|
25
|
-
};
|
|
20
|
+
if (!contentPath.glob) {
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
type: "dependency",
|
|
24
|
+
file: contentPath.base
|
|
25
|
+
}
|
|
26
|
+
];
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
if (process.env.ROLLUP_WATCH === "true") {
|
|
29
|
+
// rollup-plugin-postcss does not support dir-dependency messages
|
|
30
|
+
// but directories can be watched in the same way as files
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
type: "dependency",
|
|
34
|
+
file: contentPath.base
|
|
35
|
+
}
|
|
36
|
+
];
|
|
34
37
|
}
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
// Based on `glob-base`
|
|
43
|
-
// https://github.com/micromatch/glob-base/blob/master/index.js
|
|
44
|
-
function parseGlob(pattern) {
|
|
45
|
-
let glob = pattern;
|
|
46
|
-
let base = (0, _globParent).default(pattern);
|
|
47
|
-
if (base !== ".") {
|
|
48
|
-
glob = pattern.substr(base.length);
|
|
49
|
-
if (glob.charAt(0) === "/") {
|
|
50
|
-
glob = glob.substr(1);
|
|
38
|
+
return [
|
|
39
|
+
{
|
|
40
|
+
type: "dir-dependency",
|
|
41
|
+
dir: contentPath.base,
|
|
42
|
+
glob: contentPath.glob
|
|
51
43
|
}
|
|
52
|
-
|
|
53
|
-
if (glob.substr(0, 2) === "./") {
|
|
54
|
-
glob = glob.substr(2);
|
|
55
|
-
}
|
|
56
|
-
if (glob.charAt(0) === "/") {
|
|
57
|
-
glob = glob.substr(1);
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
base,
|
|
61
|
-
glob
|
|
62
|
-
};
|
|
44
|
+
];
|
|
63
45
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "parseGlob", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>parseGlob
|
|
8
|
+
});
|
|
9
|
+
const _globParent = /*#__PURE__*/ _interopRequireDefault(require("glob-parent"));
|
|
10
|
+
function _interopRequireDefault(obj) {
|
|
11
|
+
return obj && obj.__esModule ? obj : {
|
|
12
|
+
default: obj
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function parseGlob(pattern) {
|
|
16
|
+
let glob = pattern;
|
|
17
|
+
let base = (0, _globParent.default)(pattern);
|
|
18
|
+
if (base !== ".") {
|
|
19
|
+
glob = pattern.substr(base.length);
|
|
20
|
+
if (glob.charAt(0) === "/") {
|
|
21
|
+
glob = glob.substr(1);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (glob.substr(0, 2) === "./") {
|
|
25
|
+
glob = glob.substr(2);
|
|
26
|
+
}
|
|
27
|
+
if (glob.charAt(0) === "/") {
|
|
28
|
+
glob = glob.substr(1);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
base,
|
|
32
|
+
glob
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -2,10 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>parseObjectStyles
|
|
8
|
+
});
|
|
9
|
+
const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
|
|
10
|
+
const _postcssNested = /*#__PURE__*/ _interopRequireDefault(require("postcss-nested"));
|
|
11
|
+
const _postcssJs = /*#__PURE__*/ _interopRequireDefault(require("postcss-js"));
|
|
12
|
+
function _interopRequireDefault(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
9
17
|
function parseObjectStyles(styles) {
|
|
10
18
|
if (!Array.isArray(styles)) {
|
|
11
19
|
return parseObjectStyles([
|
|
@@ -13,19 +21,14 @@ function parseObjectStyles(styles) {
|
|
|
13
21
|
]);
|
|
14
22
|
}
|
|
15
23
|
return styles.flatMap((style)=>{
|
|
16
|
-
return (0, _postcss
|
|
17
|
-
(0, _postcssNested
|
|
24
|
+
return (0, _postcss.default)([
|
|
25
|
+
(0, _postcssNested.default)({
|
|
18
26
|
bubble: [
|
|
19
27
|
"screen"
|
|
20
28
|
]
|
|
21
|
-
})
|
|
29
|
+
})
|
|
22
30
|
]).process(style, {
|
|
23
31
|
parser: _postcssJs.default
|
|
24
32
|
}).root.nodes;
|
|
25
33
|
});
|
|
26
34
|
}
|
|
27
|
-
function _interopRequireDefault(obj) {
|
|
28
|
-
return obj && obj.__esModule ? obj : {
|
|
29
|
-
default: obj
|
|
30
|
-
};
|
|
31
|
-
}
|
package/lib/util/pluginUtils.js
CHANGED
|
@@ -2,32 +2,58 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
updateAllClasses: ()=>updateAllClasses,
|
|
13
|
+
filterSelectorsForClass: ()=>filterSelectorsForClass,
|
|
14
|
+
asValue: ()=>asValue,
|
|
15
|
+
parseColorFormat: ()=>parseColorFormat,
|
|
16
|
+
asColor: ()=>asColor,
|
|
17
|
+
asLookupValue: ()=>asLookupValue,
|
|
18
|
+
typeMap: ()=>typeMap,
|
|
19
|
+
coerceValue: ()=>coerceValue,
|
|
20
|
+
getMatchingTypes: ()=>getMatchingTypes
|
|
21
|
+
});
|
|
22
|
+
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
23
|
+
const _escapeCommas = /*#__PURE__*/ _interopRequireDefault(require("./escapeCommas"));
|
|
24
|
+
const _withAlphaVariable = require("./withAlphaVariable");
|
|
25
|
+
const _dataTypes = require("./dataTypes");
|
|
26
|
+
const _negateValue = /*#__PURE__*/ _interopRequireDefault(require("./negateValue"));
|
|
27
|
+
const _validateFormalSyntax = require("./validateFormalSyntax");
|
|
28
|
+
const _featureFlagsJs = require("../featureFlags.js");
|
|
15
29
|
function _interopRequireDefault(obj) {
|
|
16
30
|
return obj && obj.__esModule ? obj : {
|
|
17
31
|
default: obj
|
|
18
32
|
};
|
|
19
33
|
}
|
|
20
|
-
function updateAllClasses(
|
|
21
|
-
let parser = (0, _postcssSelectorParser
|
|
34
|
+
function updateAllClasses(selectors, updateClass) {
|
|
35
|
+
let parser = (0, _postcssSelectorParser.default)((selectors)=>{
|
|
22
36
|
selectors.walkClasses((sel)=>{
|
|
23
37
|
let updatedClass = updateClass(sel.value);
|
|
24
38
|
sel.value = updatedClass;
|
|
25
39
|
if (sel.raws && sel.raws.value) {
|
|
26
|
-
sel.raws.value = (0, _escapeCommas
|
|
40
|
+
sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
let result = parser.processSync(selectors);
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
function filterSelectorsForClass(selectors, classCandidate) {
|
|
48
|
+
let parser = (0, _postcssSelectorParser.default)((selectors)=>{
|
|
49
|
+
selectors.each((sel)=>{
|
|
50
|
+
const containsClass = sel.nodes.some((node)=>node.type === "class" && node.value === classCandidate);
|
|
51
|
+
if (!containsClass) {
|
|
52
|
+
sel.remove();
|
|
27
53
|
}
|
|
28
54
|
});
|
|
29
55
|
});
|
|
30
|
-
let result = parser.processSync(
|
|
56
|
+
let result = parser.processSync(selectors);
|
|
31
57
|
return result;
|
|
32
58
|
}
|
|
33
59
|
function resolveArbitraryValue(modifier, validate) {
|
|
@@ -38,25 +64,24 @@ function resolveArbitraryValue(modifier, validate) {
|
|
|
38
64
|
if (!validate(value)) {
|
|
39
65
|
return undefined;
|
|
40
66
|
}
|
|
41
|
-
return (0, _dataTypes
|
|
67
|
+
return (0, _dataTypes.normalize)(value);
|
|
42
68
|
}
|
|
43
69
|
function asNegativeValue(modifier, lookup = {}, validate) {
|
|
44
70
|
let positiveValue = lookup[modifier];
|
|
45
71
|
if (positiveValue !== undefined) {
|
|
46
|
-
return (0, _negateValue
|
|
72
|
+
return (0, _negateValue.default)(positiveValue);
|
|
47
73
|
}
|
|
48
74
|
if (isArbitraryValue(modifier)) {
|
|
49
75
|
let resolved = resolveArbitraryValue(modifier, validate);
|
|
50
76
|
if (resolved === undefined) {
|
|
51
77
|
return undefined;
|
|
52
78
|
}
|
|
53
|
-
return (0, _negateValue
|
|
79
|
+
return (0, _negateValue.default)(resolved);
|
|
54
80
|
}
|
|
55
81
|
}
|
|
56
|
-
function asValue(modifier, options = {}, { validate =()=>true
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
let value = (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
|
|
82
|
+
function asValue(modifier, options = {}, { validate =()=>true } = {}) {
|
|
83
|
+
var _options_values;
|
|
84
|
+
let value = (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
|
|
60
85
|
if (value !== undefined) {
|
|
61
86
|
return value;
|
|
62
87
|
}
|
|
@@ -68,11 +93,22 @@ function asValue(modifier, options = {}, { validate =()=>true
|
|
|
68
93
|
function isArbitraryValue(input) {
|
|
69
94
|
return input.startsWith("[") && input.endsWith("]");
|
|
70
95
|
}
|
|
71
|
-
function
|
|
96
|
+
function splitUtilityModifier(modifier) {
|
|
72
97
|
let slashIdx = modifier.lastIndexOf("/");
|
|
73
98
|
if (slashIdx === -1 || slashIdx === modifier.length - 1) {
|
|
74
99
|
return [
|
|
75
|
-
modifier
|
|
100
|
+
modifier,
|
|
101
|
+
undefined
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
let arbitrary = isArbitraryValue(modifier);
|
|
105
|
+
// The modifier could be of the form `[foo]/[bar]`
|
|
106
|
+
// We want to handle this case properly
|
|
107
|
+
// without affecting `[foo/bar]`
|
|
108
|
+
if (arbitrary && !modifier.includes("]/[")) {
|
|
109
|
+
return [
|
|
110
|
+
modifier,
|
|
111
|
+
undefined
|
|
76
112
|
];
|
|
77
113
|
}
|
|
78
114
|
return [
|
|
@@ -80,35 +116,52 @@ function splitAlpha(modifier) {
|
|
|
80
116
|
modifier.slice(slashIdx + 1)
|
|
81
117
|
];
|
|
82
118
|
}
|
|
119
|
+
function parseColorFormat(value) {
|
|
120
|
+
if (typeof value === "string" && value.includes("<alpha-value>")) {
|
|
121
|
+
let oldValue = value;
|
|
122
|
+
return ({ opacityValue =1 })=>oldValue.replace("<alpha-value>", opacityValue);
|
|
123
|
+
}
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
function unwrapArbitraryModifier(modifier) {
|
|
127
|
+
modifier = modifier.slice(1, -1);
|
|
128
|
+
if (modifier.startsWith("--")) {
|
|
129
|
+
modifier = `var(${modifier})`;
|
|
130
|
+
}
|
|
131
|
+
return modifier;
|
|
132
|
+
}
|
|
83
133
|
function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
|
|
84
|
-
var
|
|
85
|
-
if (((
|
|
86
|
-
var
|
|
87
|
-
return (
|
|
134
|
+
var _options_values;
|
|
135
|
+
if (((_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier]) !== undefined) {
|
|
136
|
+
var _options_values1;
|
|
137
|
+
return parseColorFormat((_options_values1 = options.values) === null || _options_values1 === void 0 ? void 0 : _options_values1[modifier]);
|
|
88
138
|
}
|
|
89
|
-
|
|
139
|
+
// TODO: Hoist this up to getMatchingTypes or something
|
|
140
|
+
// We do this here because we need the alpha value (if any)
|
|
141
|
+
let [color, alpha] = splitUtilityModifier(modifier);
|
|
90
142
|
if (alpha !== undefined) {
|
|
91
|
-
var
|
|
92
|
-
var
|
|
93
|
-
let normalizedColor = (
|
|
143
|
+
var _options_values2, _tailwindConfig_theme, _tailwindConfig_theme_opacity;
|
|
144
|
+
var _options_values_color;
|
|
145
|
+
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;
|
|
94
146
|
if (normalizedColor === undefined) {
|
|
95
147
|
return undefined;
|
|
96
148
|
}
|
|
149
|
+
normalizedColor = parseColorFormat(normalizedColor);
|
|
97
150
|
if (isArbitraryValue(alpha)) {
|
|
98
|
-
return (0, _withAlphaVariable
|
|
151
|
+
return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, unwrapArbitraryModifier(alpha));
|
|
99
152
|
}
|
|
100
|
-
if (((
|
|
153
|
+
if (((_tailwindConfig_theme = tailwindConfig.theme) === null || _tailwindConfig_theme === void 0 ? void 0 : (_tailwindConfig_theme_opacity = _tailwindConfig_theme.opacity) === null || _tailwindConfig_theme_opacity === void 0 ? void 0 : _tailwindConfig_theme_opacity[alpha]) === undefined) {
|
|
101
154
|
return undefined;
|
|
102
155
|
}
|
|
103
|
-
return (0, _withAlphaVariable
|
|
156
|
+
return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, tailwindConfig.theme.opacity[alpha]);
|
|
104
157
|
}
|
|
105
158
|
return asValue(modifier, options, {
|
|
106
159
|
validate: _dataTypes.color
|
|
107
160
|
});
|
|
108
161
|
}
|
|
109
162
|
function asLookupValue(modifier, options = {}) {
|
|
110
|
-
var
|
|
111
|
-
return (
|
|
163
|
+
var _options_values;
|
|
164
|
+
return (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
|
|
112
165
|
}
|
|
113
166
|
function guess(validate) {
|
|
114
167
|
return (modifier, options)=>{
|
|
@@ -132,7 +185,8 @@ let typeMap = {
|
|
|
132
185
|
"line-width": guess(_dataTypes.lineWidth),
|
|
133
186
|
"absolute-size": guess(_dataTypes.absoluteSize),
|
|
134
187
|
"relative-size": guess(_dataTypes.relativeSize),
|
|
135
|
-
shadow: guess(_dataTypes.shadow)
|
|
188
|
+
shadow: guess(_dataTypes.shadow),
|
|
189
|
+
size: guess(_validateFormalSyntax.backgroundSize)
|
|
136
190
|
};
|
|
137
191
|
let supportedTypes = Object.keys(typeMap);
|
|
138
192
|
function splitAtFirst(input, delim) {
|
|
@@ -147,6 +201,21 @@ function splitAtFirst(input, delim) {
|
|
|
147
201
|
];
|
|
148
202
|
}
|
|
149
203
|
function coerceValue(types, modifier, options, tailwindConfig) {
|
|
204
|
+
if (options.values && modifier in options.values) {
|
|
205
|
+
for (let { type } of types !== null && types !== void 0 ? types : []){
|
|
206
|
+
let result = typeMap[type](modifier, options, {
|
|
207
|
+
tailwindConfig
|
|
208
|
+
});
|
|
209
|
+
if (result === undefined) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
return [
|
|
213
|
+
result,
|
|
214
|
+
type,
|
|
215
|
+
null
|
|
216
|
+
];
|
|
217
|
+
}
|
|
218
|
+
}
|
|
150
219
|
if (isArbitraryValue(modifier)) {
|
|
151
220
|
let arbitraryValue = modifier.slice(1, -1);
|
|
152
221
|
let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
|
|
@@ -161,19 +230,54 @@ function coerceValue(types, modifier, options, tailwindConfig) {
|
|
|
161
230
|
if (value.length > 0 && supportedTypes.includes(explicitType)) {
|
|
162
231
|
return [
|
|
163
232
|
asValue(`[${value}]`, options),
|
|
164
|
-
explicitType
|
|
233
|
+
explicitType,
|
|
234
|
+
null
|
|
165
235
|
];
|
|
166
236
|
}
|
|
167
237
|
}
|
|
238
|
+
let matches = getMatchingTypes(types, modifier, options, tailwindConfig);
|
|
168
239
|
// Find first matching type
|
|
169
|
-
for (let
|
|
240
|
+
for (let match of matches){
|
|
241
|
+
return match;
|
|
242
|
+
}
|
|
243
|
+
return [];
|
|
244
|
+
}
|
|
245
|
+
function* getMatchingTypes(types, rawModifier, options, tailwindConfig) {
|
|
246
|
+
let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
|
|
247
|
+
let [modifier, utilityModifier] = splitUtilityModifier(rawModifier);
|
|
248
|
+
let canUseUtilityModifier = modifiersEnabled && options.modifiers != null && (options.modifiers === "any" || typeof options.modifiers === "object" && (utilityModifier && isArbitraryValue(utilityModifier) || utilityModifier in options.modifiers));
|
|
249
|
+
if (!canUseUtilityModifier) {
|
|
250
|
+
modifier = rawModifier;
|
|
251
|
+
utilityModifier = undefined;
|
|
252
|
+
}
|
|
253
|
+
if (utilityModifier !== undefined && modifier === "") {
|
|
254
|
+
modifier = "DEFAULT";
|
|
255
|
+
}
|
|
256
|
+
// Check the full value first
|
|
257
|
+
// TODO: Move to asValue… somehow
|
|
258
|
+
if (utilityModifier !== undefined) {
|
|
259
|
+
if (typeof options.modifiers === "object") {
|
|
260
|
+
var _options_modifiers;
|
|
261
|
+
var _options_modifiers_utilityModifier;
|
|
262
|
+
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;
|
|
263
|
+
if (configValue !== null) {
|
|
264
|
+
utilityModifier = configValue;
|
|
265
|
+
} else if (isArbitraryValue(utilityModifier)) {
|
|
266
|
+
utilityModifier = unwrapArbitraryModifier(utilityModifier);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
for (let { type } of types !== null && types !== void 0 ? types : []){
|
|
170
271
|
let result = typeMap[type](modifier, options, {
|
|
171
272
|
tailwindConfig
|
|
172
273
|
});
|
|
173
|
-
if (result
|
|
274
|
+
if (result === undefined) {
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
yield [
|
|
174
278
|
result,
|
|
175
|
-
type
|
|
279
|
+
type,
|
|
280
|
+
utilityModifier !== null && utilityModifier !== void 0 ? utilityModifier : null
|
|
176
281
|
];
|
|
177
282
|
}
|
|
178
|
-
return [];
|
|
179
283
|
}
|
|
@@ -2,19 +2,36 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
5
|
+
Object.defineProperty(exports, /**
|
|
6
|
+
* @template {string | import('postcss-selector-parser').Root} T
|
|
7
|
+
*
|
|
8
|
+
* Prefix all classes in the selector with the given prefix
|
|
9
|
+
*
|
|
10
|
+
* It can take either a string or a selector AST and will return the same type
|
|
11
|
+
*
|
|
12
|
+
* @param {string} prefix
|
|
13
|
+
* @param {T} selector
|
|
14
|
+
* @param {boolean} prependNegative
|
|
15
|
+
* @returns {T}
|
|
16
|
+
*/ "default", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: ()=>_default
|
|
19
|
+
});
|
|
20
|
+
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
7
21
|
function _interopRequireDefault(obj) {
|
|
8
22
|
return obj && obj.__esModule ? obj : {
|
|
9
23
|
default: obj
|
|
10
24
|
};
|
|
11
25
|
}
|
|
12
26
|
function _default(prefix, selector, prependNegative = false) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
if (prefix === "") {
|
|
28
|
+
return selector;
|
|
29
|
+
}
|
|
30
|
+
let ast = typeof selector === "string" ? (0, _postcssSelectorParser.default)().astSync(selector) : selector;
|
|
31
|
+
ast.walkClasses((classSelector)=>{
|
|
32
|
+
let baseClass = classSelector.value;
|
|
33
|
+
let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
|
|
34
|
+
classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
|
|
35
|
+
});
|
|
36
|
+
return typeof selector === "string" ? ast.toString() : ast;
|
|
20
37
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function removes any uses of CSS variables used as an alpha channel
|
|
3
|
+
*
|
|
4
|
+
* This is required for selectors like `:visited` which do not allow
|
|
5
|
+
* changes in opacity or external control using CSS variables.
|
|
6
|
+
*
|
|
7
|
+
* @param {import('postcss').Container} container
|
|
8
|
+
* @param {string[]} toRemove
|
|
9
|
+
*/ "use strict";
|
|
10
|
+
Object.defineProperty(exports, "__esModule", {
|
|
11
|
+
value: true
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "removeAlphaVariables", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: ()=>removeAlphaVariables
|
|
16
|
+
});
|
|
17
|
+
function removeAlphaVariables(container, toRemove) {
|
|
18
|
+
container.walkDecls((decl)=>{
|
|
19
|
+
if (toRemove.includes(decl.prop)) {
|
|
20
|
+
decl.remove();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
for (let varName of toRemove){
|
|
24
|
+
if (decl.value.includes(`/ var(${varName})`)) {
|
|
25
|
+
decl.value = decl.value.replace(`/ var(${varName})`, "");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|