tailwindcss 3.1.4 → 3.1.7
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 +37 -2
- package/defaultTheme.d.ts +2 -1
- package/lib/cli-peer-dependencies.js +12 -4
- package/lib/cli.js +78 -75
- package/lib/constants.js +19 -12
- package/lib/corePluginList.js +5 -3
- package/lib/corePlugins.js +197 -187
- package/lib/featureFlags.js +14 -7
- package/lib/index.js +9 -6
- package/lib/lib/cacheInvalidation.js +18 -15
- package/lib/lib/collapseAdjacentRules.js +14 -11
- package/lib/lib/collapseDuplicateDeclarations.js +11 -8
- package/lib/lib/defaultExtractor.js +41 -33
- package/lib/lib/detectNesting.js +4 -1
- package/lib/lib/evaluateTailwindFunctions.js +75 -44
- package/lib/lib/expandApplyAtRules.js +45 -42
- package/lib/lib/expandTailwindAtRules.js +153 -150
- package/lib/lib/generateRules.js +84 -70
- package/lib/lib/getModuleDependencies.js +21 -18
- package/lib/lib/normalizeTailwindDirectives.js +10 -7
- package/lib/lib/partitionApplyAtRules.js +14 -11
- package/lib/lib/regex.js +15 -7
- package/lib/lib/resolveDefaultsAtRules.js +92 -85
- package/lib/lib/setupContextUtils.js +115 -97
- package/lib/lib/setupTrackingContext.js +82 -75
- package/lib/lib/sharedState.js +15 -8
- package/lib/lib/substituteScreenAtRules.js +8 -5
- package/lib/postcss-plugins/nesting/index.js +7 -5
- package/lib/postcss-plugins/nesting/plugin.js +7 -4
- package/lib/processTailwindFeatures.js +34 -31
- package/lib/public/colors.js +6 -4
- 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 +5 -2
- package/lib/util/cloneDeep.js +4 -1
- package/lib/util/cloneNodes.js +9 -2
- package/lib/util/color.js +11 -3
- package/lib/util/configurePlugins.js +4 -1
- package/lib/util/createPlugin.js +5 -3
- package/lib/util/createUtilityPlugin.js +13 -10
- package/lib/util/dataTypes.js +27 -19
- package/lib/util/defaults.js +4 -1
- package/lib/util/escapeClassName.js +12 -9
- package/lib/util/escapeCommas.js +4 -1
- package/lib/util/flattenColorPalette.js +5 -3
- package/lib/util/formatVariantSelector.js +23 -15
- package/lib/util/getAllConfigs.js +12 -9
- 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 +33 -24
- package/lib/util/log.js +12 -5
- package/lib/util/nameClass.js +16 -8
- package/lib/util/negateValue.js +4 -1
- package/lib/util/normalizeConfig.js +26 -23
- package/lib/util/normalizeScreens.js +17 -2
- package/lib/util/parseAnimationValue.js +42 -39
- package/lib/util/parseBoxShadowValue.js +12 -4
- package/lib/util/parseDependency.js +35 -32
- package/lib/util/parseObjectStyles.js +14 -11
- package/lib/util/pluginUtils.js +28 -20
- package/lib/util/prefixSelector.js +6 -3
- package/lib/util/removeAlphaVariables.js +13 -2
- package/lib/util/resolveConfig.js +55 -52
- package/lib/util/resolveConfigPath.js +20 -17
- package/lib/util/responsive.js +12 -9
- package/lib/util/splitAtTopLevelOnly.js +16 -13
- 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 +10 -7
- package/lib/util/validateConfig.js +5 -2
- package/lib/util/withAlphaVariable.js +30 -22
- package/package.json +12 -12
- package/peers/index.js +24 -10
- package/resolveConfig.d.ts +3 -0
- package/scripts/generate-types.js +53 -0
- package/scripts/type-utils.js +27 -0
- package/src/corePlugins.js +2 -1
- package/src/lib/defaultExtractor.js +7 -1
- package/src/lib/evaluateTailwindFunctions.js +41 -15
- package/src/lib/generateRules.js +10 -1
- package/src/lib/setupContextUtils.js +15 -2
- package/src/util/cloneNodes.js +5 -1
- package/src/util/formatVariantSelector.js +3 -1
- package/types/config.d.ts +7 -5
- package/types/generated/default-theme.d.ts +331 -0
|
@@ -2,18 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Object.defineProperty(exports, "splitAtTopLevelOnly", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>splitAtTopLevelOnly
|
|
8
|
+
});
|
|
9
|
+
const _regex = /*#__PURE__*/ _interopRequireWildcard(require("../lib/regex"));
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
8
11
|
if (typeof WeakMap !== "function") return null;
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
var cacheBabelInterop = new WeakMap();
|
|
13
|
+
var cacheNodeInterop = new WeakMap();
|
|
14
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
15
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
16
|
+
})(nodeInterop);
|
|
14
17
|
}
|
|
15
|
-
function _interopRequireWildcard(obj) {
|
|
16
|
-
if (obj && obj.__esModule) {
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
19
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
17
20
|
return obj;
|
|
18
21
|
}
|
|
19
22
|
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
@@ -21,14 +24,14 @@ function _interopRequireWildcard(obj) {
|
|
|
21
24
|
default: obj
|
|
22
25
|
};
|
|
23
26
|
}
|
|
24
|
-
var cache = _getRequireWildcardCache();
|
|
27
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
25
28
|
if (cache && cache.has(obj)) {
|
|
26
29
|
return cache.get(obj);
|
|
27
30
|
}
|
|
28
31
|
var newObj = {};
|
|
29
32
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
30
33
|
for(var key in obj){
|
|
31
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
34
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
32
35
|
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
33
36
|
if (desc && (desc.get || desc.set)) {
|
|
34
37
|
Object.defineProperty(newObj, key, desc);
|
|
@@ -44,7 +47,7 @@ function _interopRequireWildcard(obj) {
|
|
|
44
47
|
return newObj;
|
|
45
48
|
}
|
|
46
49
|
function* splitAtTopLevelOnly(input, separator) {
|
|
47
|
-
let SPECIALS = new RegExp(`[(){}\\[\\]${
|
|
50
|
+
let SPECIALS = new RegExp(`[(){}\\[\\]${_regex.escape(separator)}]`, "g");
|
|
48
51
|
let depth = 0;
|
|
49
52
|
let lastIndex = 0;
|
|
50
53
|
let found = false;
|
package/lib/util/tap.js
CHANGED
package/lib/util/toColorValue.js
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>toColorValue
|
|
8
|
+
});
|
|
6
9
|
function toColorValue(maybeFunction) {
|
|
7
10
|
return typeof maybeFunction === "function" ? maybeFunction({}) : maybeFunction;
|
|
8
11
|
}
|
package/lib/util/toPath.js
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Parse a path string into an array of path segments.
|
|
3
|
+
*
|
|
4
|
+
* Square bracket notation `a[b]` may be used to "escape" dots that would otherwise be interpreted as path separators.
|
|
5
|
+
*
|
|
6
|
+
* Example:
|
|
7
|
+
* a -> ['a']
|
|
8
|
+
* a.b.c -> ['a', 'b', 'c']
|
|
9
|
+
* a[b].c -> ['a', 'b', 'c']
|
|
10
|
+
* a[b.c].e.f -> ['a', 'b.c', 'e', 'f']
|
|
11
|
+
* a[b][c][d] -> ['a', 'b', 'c', 'd']
|
|
12
|
+
*
|
|
13
|
+
* @param {string|string[]} path
|
|
14
|
+
**/ "use strict";
|
|
2
15
|
Object.defineProperty(exports, "__esModule", {
|
|
3
16
|
value: true
|
|
4
17
|
});
|
|
5
|
-
exports
|
|
18
|
+
Object.defineProperty(exports, "toPath", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: ()=>toPath
|
|
21
|
+
});
|
|
6
22
|
function toPath(path) {
|
|
7
23
|
if (Array.isArray(path)) return path;
|
|
8
24
|
let openBrackets = path.split("[").length - 1;
|
|
@@ -2,8 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>transformThemeValue
|
|
8
|
+
});
|
|
9
|
+
const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
|
|
10
|
+
function _interopRequireDefault(obj) {
|
|
11
|
+
return obj && obj.__esModule ? obj : {
|
|
12
|
+
default: obj
|
|
13
|
+
};
|
|
14
|
+
}
|
|
7
15
|
function transformThemeValue(themeSection) {
|
|
8
16
|
if ([
|
|
9
17
|
"fontSize",
|
|
@@ -54,8 +62,3 @@ function transformThemeValue(themeSection) {
|
|
|
54
62
|
return value;
|
|
55
63
|
};
|
|
56
64
|
}
|
|
57
|
-
function _interopRequireDefault(obj) {
|
|
58
|
-
return obj && obj.__esModule ? obj : {
|
|
59
|
-
default: obj
|
|
60
|
-
};
|
|
61
|
-
}
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
5
|
+
Object.defineProperty(exports, "validateConfig", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>validateConfig
|
|
8
|
+
});
|
|
9
|
+
const _log = /*#__PURE__*/ _interopRequireDefault(require("./log"));
|
|
7
10
|
function _interopRequireDefault(obj) {
|
|
8
11
|
return obj && obj.__esModule ? obj : {
|
|
9
12
|
default: obj
|
|
@@ -2,9 +2,34 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
withAlphaValue: ()=>withAlphaValue,
|
|
13
|
+
default: ()=>withAlphaVariable
|
|
14
|
+
});
|
|
15
|
+
const _color = require("./color");
|
|
16
|
+
function withAlphaValue(color, alphaValue, defaultValue) {
|
|
17
|
+
if (typeof color === "function") {
|
|
18
|
+
return color({
|
|
19
|
+
opacityValue: alphaValue
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
let parsed = (0, _color.parseColor)(color, {
|
|
23
|
+
loose: true
|
|
24
|
+
});
|
|
25
|
+
if (parsed === null) {
|
|
26
|
+
return defaultValue;
|
|
27
|
+
}
|
|
28
|
+
return (0, _color.formatColor)({
|
|
29
|
+
...parsed,
|
|
30
|
+
alpha: alphaValue
|
|
31
|
+
});
|
|
32
|
+
}
|
|
8
33
|
function withAlphaVariable({ color , property , variable }) {
|
|
9
34
|
let properties = [].concat(property);
|
|
10
35
|
if (typeof color === "function") {
|
|
@@ -21,7 +46,7 @@ function withAlphaVariable({ color , property , variable }) {
|
|
|
21
46
|
}))
|
|
22
47
|
};
|
|
23
48
|
}
|
|
24
|
-
const parsed = (0, _color
|
|
49
|
+
const parsed = (0, _color.parseColor)(color);
|
|
25
50
|
if (parsed === null) {
|
|
26
51
|
return Object.fromEntries(properties.map((p)=>[
|
|
27
52
|
p,
|
|
@@ -40,7 +65,7 @@ function withAlphaVariable({ color , property , variable }) {
|
|
|
40
65
|
...Object.fromEntries(properties.map((p)=>{
|
|
41
66
|
return [
|
|
42
67
|
p,
|
|
43
|
-
(0, _color
|
|
68
|
+
(0, _color.formatColor)({
|
|
44
69
|
...parsed,
|
|
45
70
|
alpha: `var(${variable})`
|
|
46
71
|
})
|
|
@@ -48,20 +73,3 @@ function withAlphaVariable({ color , property , variable }) {
|
|
|
48
73
|
}))
|
|
49
74
|
};
|
|
50
75
|
}
|
|
51
|
-
function withAlphaValue(color, alphaValue, defaultValue) {
|
|
52
|
-
if (typeof color === "function") {
|
|
53
|
-
return color({
|
|
54
|
-
opacityValue: alphaValue
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
let parsed = (0, _color).parseColor(color, {
|
|
58
|
-
loose: true
|
|
59
|
-
});
|
|
60
|
-
if (parsed === null) {
|
|
61
|
-
return defaultValue;
|
|
62
|
-
}
|
|
63
|
-
return (0, _color).formatColor({
|
|
64
|
-
...parsed,
|
|
65
|
-
alpha: alphaValue
|
|
66
|
-
});
|
|
67
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.7",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -43,19 +43,19 @@
|
|
|
43
43
|
],
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@swc/cli": "^0.1.57",
|
|
46
|
-
"@swc/core": "^1.2.
|
|
47
|
-
"@swc/jest": "^0.2.
|
|
46
|
+
"@swc/core": "^1.2.218",
|
|
47
|
+
"@swc/jest": "^0.2.22",
|
|
48
48
|
"@swc/register": "^0.1.10",
|
|
49
49
|
"autoprefixer": "^10.4.7",
|
|
50
|
-
"cssnano": "^5.1.
|
|
51
|
-
"esbuild": "^0.14.
|
|
52
|
-
"eslint": "^8.
|
|
50
|
+
"cssnano": "^5.1.12",
|
|
51
|
+
"esbuild": "^0.14.48",
|
|
52
|
+
"eslint": "^8.19.0",
|
|
53
53
|
"eslint-config-prettier": "^8.5.0",
|
|
54
|
-
"eslint-plugin-prettier": "^4.
|
|
55
|
-
"jest": "^28.1.
|
|
56
|
-
"jest-diff": "^28.1.
|
|
54
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
55
|
+
"jest": "^28.1.3",
|
|
56
|
+
"jest-diff": "^28.1.3",
|
|
57
57
|
"prettier": "^2.7.1",
|
|
58
|
-
"prettier-plugin-tailwindcss": "^0.1.
|
|
58
|
+
"prettier-plugin-tailwindcss": "^0.1.12",
|
|
59
59
|
"rimraf": "^3.0.0",
|
|
60
60
|
"source-map-js": "^1.0.2"
|
|
61
61
|
},
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"fast-glob": "^3.2.11",
|
|
73
73
|
"glob-parent": "^6.0.2",
|
|
74
74
|
"is-glob": "^4.0.3",
|
|
75
|
-
"lilconfig": "^2.0.
|
|
75
|
+
"lilconfig": "^2.0.6",
|
|
76
76
|
"normalize-path": "^3.0.0",
|
|
77
77
|
"object-hash": "^3.0.0",
|
|
78
78
|
"picocolors": "^1.0.0",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"postcss-selector-parser": "^6.0.10",
|
|
85
85
|
"postcss-value-parser": "^4.2.0",
|
|
86
86
|
"quick-lru": "^5.1.1",
|
|
87
|
-
"resolve": "^1.22.
|
|
87
|
+
"resolve": "^1.22.1"
|
|
88
88
|
},
|
|
89
89
|
"browserslist": [
|
|
90
90
|
"> 1%",
|
package/peers/index.js
CHANGED
|
@@ -5978,6 +5978,7 @@ var require_core = __commonJS({
|
|
|
5978
5978
|
"node:string_decoder": [">= 14.18 && < 15", ">= 16"],
|
|
5979
5979
|
sys: [">= 0.4 && < 0.7", ">= 0.8"],
|
|
5980
5980
|
"node:sys": [">= 14.18 && < 15", ">= 16"],
|
|
5981
|
+
"node:test": ">= 18",
|
|
5981
5982
|
timers: true,
|
|
5982
5983
|
"node:timers": [">= 14.18 && < 15", ">= 16"],
|
|
5983
5984
|
"timers/promises": ">= 15",
|
|
@@ -6092,7 +6093,7 @@ var require_async = __commonJS({
|
|
|
6092
6093
|
var nodeModulesPaths = require_node_modules_paths();
|
|
6093
6094
|
var normalizeOptions = require_normalize_options();
|
|
6094
6095
|
var isCore = require_is_core_module();
|
|
6095
|
-
var realpathFS = fs.realpath && typeof fs.realpath.native === "function" ? fs.realpath.native : fs.realpath;
|
|
6096
|
+
var realpathFS = process.platform !== "win32" && fs.realpath && typeof fs.realpath.native === "function" ? fs.realpath.native : fs.realpath;
|
|
6096
6097
|
var homedir = getHomedir();
|
|
6097
6098
|
var defaultPaths = function() {
|
|
6098
6099
|
return [
|
|
@@ -6525,6 +6526,7 @@ var require_core2 = __commonJS({
|
|
|
6525
6526
|
"node:string_decoder": [">= 14.18 && < 15", ">= 16"],
|
|
6526
6527
|
sys: [">= 0.4 && < 0.7", ">= 0.8"],
|
|
6527
6528
|
"node:sys": [">= 14.18 && < 15", ">= 16"],
|
|
6529
|
+
"node:test": ">= 18",
|
|
6528
6530
|
timers: true,
|
|
6529
6531
|
"node:timers": [">= 14.18 && < 15", ">= 16"],
|
|
6530
6532
|
"timers/promises": ">= 15",
|
|
@@ -6647,7 +6649,7 @@ var require_sync = __commonJS({
|
|
|
6647
6649
|
var caller = require_caller();
|
|
6648
6650
|
var nodeModulesPaths = require_node_modules_paths();
|
|
6649
6651
|
var normalizeOptions = require_normalize_options();
|
|
6650
|
-
var realpathFS = fs.realpathSync && typeof fs.realpathSync.native === "function" ? fs.realpathSync.native : fs.realpathSync;
|
|
6652
|
+
var realpathFS = process.platform !== "win32" && fs.realpathSync && typeof fs.realpathSync.native === "function" ? fs.realpathSync.native : fs.realpathSync;
|
|
6651
6653
|
var homedir = getHomedir();
|
|
6652
6654
|
var defaultPaths = function() {
|
|
6653
6655
|
return [
|
|
@@ -73369,11 +73371,12 @@ var require_src11 = __commonJS({
|
|
|
73369
73371
|
...grid,
|
|
73370
73372
|
...columnRules
|
|
73371
73373
|
]);
|
|
73374
|
+
var variableFunctions = /* @__PURE__ */ new Set(["var", "env", "constant"]);
|
|
73372
73375
|
function isVariableFunctionNode(node) {
|
|
73373
73376
|
if (node.type !== "function") {
|
|
73374
73377
|
return false;
|
|
73375
73378
|
}
|
|
73376
|
-
return
|
|
73379
|
+
return variableFunctions.has(node.value.toLowerCase());
|
|
73377
73380
|
}
|
|
73378
73381
|
function shouldAbort(parsed) {
|
|
73379
73382
|
let abort = false;
|
|
@@ -75319,7 +75322,7 @@ var require_parseWsc = __commonJS({
|
|
|
75319
75322
|
var { list } = require_postcss();
|
|
75320
75323
|
var { isWidth, isStyle, isColor } = require_validateWsc();
|
|
75321
75324
|
var none = /^\s*(none|medium)(\s+none(\s+(none|currentcolor))?)?\s*$/i;
|
|
75322
|
-
var varRE = /--(\w
|
|
75325
|
+
var varRE = /--(\w|-|[^\x00-\x7F])+/g;
|
|
75323
75326
|
var toLower = (v) => {
|
|
75324
75327
|
let match;
|
|
75325
75328
|
let lastIndex = 0;
|
|
@@ -76402,11 +76405,12 @@ var require_src21 = __commonJS({
|
|
|
76402
76405
|
function isCommaNode(node) {
|
|
76403
76406
|
return node.type === "div" && node.value === ",";
|
|
76404
76407
|
}
|
|
76408
|
+
var variableFunctions = /* @__PURE__ */ new Set(["var", "env", "constant"]);
|
|
76405
76409
|
function isVariableFunctionNode(node) {
|
|
76406
76410
|
if (node.type !== "function") {
|
|
76407
76411
|
return false;
|
|
76408
76412
|
}
|
|
76409
|
-
return
|
|
76413
|
+
return variableFunctions.has(node.value.toLowerCase());
|
|
76410
76414
|
}
|
|
76411
76415
|
function transform(value) {
|
|
76412
76416
|
const parsed = valueParser(value);
|
|
@@ -77216,6 +77220,7 @@ var require_src26 = __commonJS({
|
|
|
77216
77220
|
["top", "0"]
|
|
77217
77221
|
]);
|
|
77218
77222
|
var mathFunctions = /* @__PURE__ */ new Set(["calc", "min", "max", "clamp"]);
|
|
77223
|
+
var variableFunctions = /* @__PURE__ */ new Set(["var", "env", "constant"]);
|
|
77219
77224
|
function isCommaNode(node) {
|
|
77220
77225
|
return node.type === "div" && node.value === ",";
|
|
77221
77226
|
}
|
|
@@ -77223,7 +77228,7 @@ var require_src26 = __commonJS({
|
|
|
77223
77228
|
if (node.type !== "function") {
|
|
77224
77229
|
return false;
|
|
77225
77230
|
}
|
|
77226
|
-
return
|
|
77231
|
+
return variableFunctions.has(node.value.toLowerCase());
|
|
77227
77232
|
}
|
|
77228
77233
|
function isMathFunctionNode(node) {
|
|
77229
77234
|
if (node.type !== "function") {
|
|
@@ -77910,10 +77915,19 @@ var require_src32 = __commonJS({
|
|
|
77910
77915
|
Object.defineProperty(exports, "__esModule", {
|
|
77911
77916
|
value: true
|
|
77912
77917
|
});
|
|
77913
|
-
|
|
77914
|
-
|
|
77915
|
-
|
|
77916
|
-
|
|
77918
|
+
function _export(target, all) {
|
|
77919
|
+
for (var name in all)
|
|
77920
|
+
Object.defineProperty(target, name, {
|
|
77921
|
+
enumerable: true,
|
|
77922
|
+
get: all[name]
|
|
77923
|
+
});
|
|
77924
|
+
}
|
|
77925
|
+
_export(exports, {
|
|
77926
|
+
lazyPostcss: () => lazyPostcss,
|
|
77927
|
+
lazyPostcssImport: () => lazyPostcssImport,
|
|
77928
|
+
lazyAutoprefixer: () => lazyAutoprefixer,
|
|
77929
|
+
lazyCssnano: () => lazyCssnano
|
|
77930
|
+
});
|
|
77917
77931
|
function lazyPostcss() {
|
|
77918
77932
|
return require_postcss();
|
|
77919
77933
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import prettier from 'prettier'
|
|
2
2
|
import { corePlugins } from '../src/corePlugins'
|
|
3
3
|
import colors from '../src/public/colors'
|
|
4
|
+
import defaultTheme from '../src/public/default-theme'
|
|
4
5
|
import fs from 'fs'
|
|
5
6
|
import path from 'path'
|
|
7
|
+
import * as types from './type-utils'
|
|
6
8
|
|
|
7
9
|
fs.writeFileSync(
|
|
8
10
|
path.join(process.cwd(), 'types', 'generated', 'corePluginList.d.ts'),
|
|
@@ -50,3 +52,54 @@ fs.writeFileSync(
|
|
|
50
52
|
}
|
|
51
53
|
)
|
|
52
54
|
)
|
|
55
|
+
|
|
56
|
+
const defaultThemeTypes = Object.entries(defaultTheme)
|
|
57
|
+
.map(([name, value]) => {
|
|
58
|
+
// Special cases for slightly more accurate types
|
|
59
|
+
if (name === 'keyframes') {
|
|
60
|
+
return [name, `Record<${types.forKeys(value)}, Record<string, CSSDeclarationList>>`]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (name === 'fontSize') {
|
|
64
|
+
return [name, `Record<${types.forKeys(value)}, [string, { lineHeight: string }]>`]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// General cases
|
|
68
|
+
if (typeof value === 'string') {
|
|
69
|
+
return [name, `string`]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (typeof value === 'function') {
|
|
73
|
+
return [name, null]
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (typeof value === 'object') {
|
|
77
|
+
if (Object.keys(value).length === 0) {
|
|
78
|
+
return [name, null]
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return [name, types.forValue(value)]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return [name, `unknown`]
|
|
85
|
+
})
|
|
86
|
+
.filter(([, type]) => type !== null)
|
|
87
|
+
.map(([name, type]) => `${name}: ${type}`)
|
|
88
|
+
.join('\n')
|
|
89
|
+
|
|
90
|
+
fs.writeFileSync(
|
|
91
|
+
path.join(process.cwd(), 'types', 'generated', 'default-theme.d.ts'),
|
|
92
|
+
prettier.format(
|
|
93
|
+
`
|
|
94
|
+
import { Config } from '../../types'
|
|
95
|
+
type CSSDeclarationList = Record<string, string>
|
|
96
|
+
export type DefaultTheme = Config['theme'] & { ${defaultThemeTypes} }
|
|
97
|
+
`,
|
|
98
|
+
{
|
|
99
|
+
semi: false,
|
|
100
|
+
singleQuote: true,
|
|
101
|
+
printWidth: 100,
|
|
102
|
+
parser: 'typescript',
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function union(types) {
|
|
2
|
+
return [...new Set(types)].join(' | ')
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function unionValues(values) {
|
|
6
|
+
return union(values.map(forValue))
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function forKeys(value) {
|
|
10
|
+
return union(Object.keys(value).map((key) => `'${key}'`))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function forValue(value) {
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
return `(${unionValues(value)})[]`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (typeof value === 'object') {
|
|
19
|
+
return `Record<${forKeys(value)}, ${unionValues(Object.values(value))}>`
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (typeof value === 'string') {
|
|
23
|
+
return `string`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return `any`
|
|
27
|
+
}
|
package/src/corePlugins.js
CHANGED
|
@@ -1613,7 +1613,7 @@ export let corePlugins = {
|
|
|
1613
1613
|
{
|
|
1614
1614
|
text: (value) => {
|
|
1615
1615
|
let [fontSize, options] = Array.isArray(value) ? value : [value]
|
|
1616
|
-
let { lineHeight, letterSpacing } = isPlainObject(options)
|
|
1616
|
+
let { lineHeight, letterSpacing, fontWeight } = isPlainObject(options)
|
|
1617
1617
|
? options
|
|
1618
1618
|
: { lineHeight: options }
|
|
1619
1619
|
|
|
@@ -1621,6 +1621,7 @@ export let corePlugins = {
|
|
|
1621
1621
|
'font-size': fontSize,
|
|
1622
1622
|
...(lineHeight === undefined ? {} : { 'line-height': lineHeight }),
|
|
1623
1623
|
...(letterSpacing === undefined ? {} : { 'letter-spacing': letterSpacing }),
|
|
1624
|
+
...(fontWeight === undefined ? {} : { 'font-weight': fontWeight }),
|
|
1624
1625
|
}
|
|
1625
1626
|
},
|
|
1626
1627
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flagEnabled } from '../featureFlags
|
|
1
|
+
import { flagEnabled } from '../featureFlags'
|
|
2
2
|
import * as regex from './regex'
|
|
3
3
|
|
|
4
4
|
export function defaultExtractor(context) {
|
|
@@ -22,6 +22,10 @@ export function defaultExtractor(context) {
|
|
|
22
22
|
function* buildRegExps(context) {
|
|
23
23
|
let separator = context.tailwindConfig.separator
|
|
24
24
|
let variantGroupingEnabled = flagEnabled(context.tailwindConfig, 'variantGrouping')
|
|
25
|
+
let prefix =
|
|
26
|
+
context.tailwindConfig.prefix !== ''
|
|
27
|
+
? regex.optional(regex.pattern([/-?/, regex.escape(context.tailwindConfig.prefix)]))
|
|
28
|
+
: ''
|
|
25
29
|
|
|
26
30
|
let utility = regex.any([
|
|
27
31
|
// Arbitrary properties
|
|
@@ -88,6 +92,8 @@ function* buildRegExps(context) {
|
|
|
88
92
|
// Important (optional)
|
|
89
93
|
/!?/,
|
|
90
94
|
|
|
95
|
+
prefix,
|
|
96
|
+
|
|
91
97
|
variantGroupingEnabled
|
|
92
98
|
? regex.any([
|
|
93
99
|
// Or any of those things but grouped separated by commas
|
|
@@ -157,26 +157,52 @@ let nodeTypePropertyMap = {
|
|
|
157
157
|
decl: 'value',
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
160
|
+
/**
|
|
161
|
+
* @param {string} path
|
|
162
|
+
* @returns {Iterable<[path: string, alpha: string|undefined]>}
|
|
163
|
+
*/
|
|
164
|
+
function* toPaths(path) {
|
|
165
|
+
// Strip quotes from beginning and end of string
|
|
166
|
+
// This allows the alpha value to be present inside of quotes
|
|
167
|
+
path = path.replace(/^['"]+|['"]+$/g, '')
|
|
166
168
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
+
let matches = path.match(/^([^\s]+)(?![^\[]*\])(?:\s*\/\s*([^\/\s]+))$/)
|
|
170
|
+
let alpha = undefined
|
|
169
171
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
yield [path, undefined]
|
|
173
|
+
|
|
174
|
+
if (matches) {
|
|
175
|
+
path = matches[1]
|
|
176
|
+
alpha = matches[2]
|
|
177
|
+
|
|
178
|
+
yield [path, alpha]
|
|
179
|
+
}
|
|
180
|
+
}
|
|
174
181
|
|
|
175
|
-
|
|
182
|
+
/**
|
|
183
|
+
*
|
|
184
|
+
* @param {any} config
|
|
185
|
+
* @param {string} path
|
|
186
|
+
* @param {any} defaultValue
|
|
187
|
+
*/
|
|
188
|
+
function resolvePath(config, path, defaultValue) {
|
|
189
|
+
const results = Array.from(toPaths(path)).map(([path, alpha]) => {
|
|
190
|
+
return Object.assign(validatePath(config, path, defaultValue, { opacityValue: alpha }), {
|
|
191
|
+
resolvedPath: path,
|
|
192
|
+
alpha,
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
return results.find((result) => result.isValid) ?? results[0]
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export default function ({ tailwindConfig: config }) {
|
|
200
|
+
let functions = {
|
|
201
|
+
theme: (node, path, ...defaultValue) => {
|
|
202
|
+
let { isValid, value, error, alpha } = resolvePath(
|
|
176
203
|
config,
|
|
177
204
|
path,
|
|
178
|
-
defaultValue.length ? defaultValue : undefined
|
|
179
|
-
{ opacityValue: alpha }
|
|
205
|
+
defaultValue.length ? defaultValue : undefined
|
|
180
206
|
)
|
|
181
207
|
|
|
182
208
|
if (!isValid) {
|
package/src/lib/generateRules.js
CHANGED
|
@@ -129,6 +129,7 @@ function applyVariant(variant, matches, context) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
let args
|
|
132
|
+
let isArbitraryVariant = false
|
|
132
133
|
|
|
133
134
|
// Find partial arbitrary variants
|
|
134
135
|
if (variant.endsWith(']') && !variant.startsWith('[')) {
|
|
@@ -144,6 +145,8 @@ function applyVariant(variant, matches, context) {
|
|
|
144
145
|
return []
|
|
145
146
|
}
|
|
146
147
|
|
|
148
|
+
isArbitraryVariant = true
|
|
149
|
+
|
|
147
150
|
let fn = parseVariant(selector)
|
|
148
151
|
|
|
149
152
|
let sort = Array.from(context.variantOrder.values()).pop() << 1n
|
|
@@ -300,6 +303,7 @@ function applyVariant(variant, matches, context) {
|
|
|
300
303
|
...meta,
|
|
301
304
|
sort: variantSort | meta.sort,
|
|
302
305
|
collectedFormats: (meta.collectedFormats ?? []).concat(collectedFormats),
|
|
306
|
+
isArbitraryVariant,
|
|
303
307
|
},
|
|
304
308
|
clone.nodes[0],
|
|
305
309
|
]
|
|
@@ -467,7 +471,11 @@ function splitWithSeparator(input, separator) {
|
|
|
467
471
|
|
|
468
472
|
function* recordCandidates(matches, classCandidate) {
|
|
469
473
|
for (const match of matches) {
|
|
470
|
-
match[1].raws.tailwind = {
|
|
474
|
+
match[1].raws.tailwind = {
|
|
475
|
+
...match[1].raws.tailwind,
|
|
476
|
+
classCandidate,
|
|
477
|
+
preserveSource: match[0].options?.preserveSource ?? false,
|
|
478
|
+
}
|
|
471
479
|
|
|
472
480
|
yield match
|
|
473
481
|
}
|
|
@@ -627,6 +635,7 @@ function* resolveMatches(candidate, context, original = candidate) {
|
|
|
627
635
|
base: candidate
|
|
628
636
|
.split(new RegExp(`\\${context?.tailwindConfig?.separator ?? ':'}(?![^[]*\\])`))
|
|
629
637
|
.pop(),
|
|
638
|
+
isArbitraryVariant: match[0].isArbitraryVariant,
|
|
630
639
|
|
|
631
640
|
context,
|
|
632
641
|
})
|