tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.cb6e45a
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 +526 -2
- package/LICENSE +1 -2
- package/README.md +13 -6
- package/colors.d.ts +3 -0
- package/colors.js +2 -1
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -1
- package/defaultTheme.d.ts +4 -0
- package/defaultTheme.js +2 -1
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +44 -0
- package/lib/cli/build/plugin.js +335 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +113 -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 +20 -7
- package/lib/cli.js +91 -569
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +16 -4
- package/lib/corePlugins.js +2247 -1873
- package/lib/css/preflight.css +20 -9
- package/lib/featureFlags.js +37 -23
- package/lib/index.js +28 -12
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +27 -9
- package/lib/lib/collapseDuplicateDeclarations.js +83 -0
- package/lib/lib/content.js +167 -0
- package/lib/lib/defaultExtractor.js +236 -0
- package/lib/lib/detectNesting.js +21 -3
- package/lib/lib/evaluateTailwindFunctions.js +117 -50
- package/lib/lib/expandApplyAtRules.js +439 -160
- package/lib/lib/expandTailwindAtRules.js +141 -151
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +572 -105
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +45 -33
- package/lib/lib/offsets.js +217 -0
- package/lib/lib/partitionApplyAtRules.js +56 -0
- package/lib/lib/regex.js +60 -0
- package/lib/lib/resolveDefaultsAtRules.js +114 -81
- package/lib/lib/setupContextUtils.js +777 -385
- package/lib/lib/setupTrackingContext.js +43 -71
- package/lib/lib/sharedState.js +49 -18
- package/lib/lib/substituteScreenAtRules.js +13 -8
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +19 -0
- package/lib/postcss-plugins/nesting/plugin.js +87 -0
- package/lib/processTailwindFeatures.js +36 -21
- package/lib/public/colors.js +250 -252
- 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 +8 -5
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +18 -24
- package/lib/util/cloneDeep.js +7 -6
- package/lib/util/cloneNodes.js +21 -3
- package/lib/util/color.js +54 -40
- package/lib/util/configurePlugins.js +5 -2
- package/lib/util/createPlugin.js +6 -6
- package/lib/util/createUtilityPlugin.js +11 -13
- package/lib/util/dataTypes.js +137 -100
- package/lib/util/defaults.js +10 -1
- package/lib/util/escapeClassName.js +7 -4
- package/lib/util/escapeCommas.js +5 -2
- package/lib/util/flattenColorPalette.js +9 -12
- package/lib/util/formatVariantSelector.js +285 -0
- package/lib/util/getAllConfigs.js +27 -8
- package/lib/util/hashConfig.js +6 -3
- package/lib/util/isKeyframeRule.js +5 -2
- package/lib/util/isPlainObject.js +5 -2
- package/lib/util/isValidArbitraryValue.js +72 -0
- package/lib/util/log.js +44 -22
- package/lib/util/nameClass.js +20 -8
- package/lib/util/negateValue.js +23 -6
- package/lib/util/normalizeConfig.js +267 -0
- package/lib/util/normalizeScreens.js +170 -0
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +84 -0
- package/lib/util/parseDependency.js +38 -56
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +11 -8
- package/lib/util/pluginUtils.js +171 -189
- package/lib/util/prefixSelector.js +10 -10
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +92 -126
- package/lib/util/resolveConfigPath.js +11 -9
- package/lib/util/responsive.js +8 -5
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +5 -3
- package/lib/util/toPath.js +24 -3
- package/lib/util/transformThemeValue.js +49 -31
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/validateFormalSyntax.js +24 -0
- package/lib/util/withAlphaVariable.js +23 -15
- package/nesting/index.js +2 -12
- package/package.json +48 -46
- package/peers/index.js +14817 -12471
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.d.ts +3 -0
- package/resolveConfig.js +2 -1
- package/scripts/create-plugin-list.js +2 -2
- package/scripts/generate-types.js +105 -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 +45 -0
- package/src/cli/build/plugin.js +397 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +134 -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 +26 -565
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +905 -615
- package/src/css/preflight.css +20 -9
- package/src/featureFlags.js +26 -10
- package/src/index.js +19 -6
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/collapseDuplicateDeclarations.js +93 -0
- package/src/lib/content.js +205 -0
- package/src/lib/defaultExtractor.js +211 -0
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +84 -10
- package/src/lib/expandApplyAtRules.js +488 -153
- package/src/lib/expandTailwindAtRules.js +94 -106
- package/src/lib/findAtConfigPath.js +50 -0
- package/src/lib/generateRules.js +589 -67
- package/src/lib/normalizeTailwindDirectives.js +10 -3
- package/src/lib/offsets.js +270 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +98 -60
- package/src/lib/setupContextUtils.js +737 -246
- package/src/lib/setupTrackingContext.js +16 -54
- package/src/lib/sharedState.js +44 -7
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/src/postcss-plugins/nesting/plugin.js +80 -0
- package/src/processTailwindFeatures.js +17 -2
- package/src/public/colors.js +4 -9
- package/src/util/buildMediaQuery.js +14 -16
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +31 -14
- package/src/util/createUtilityPlugin.js +2 -2
- package/src/util/dataTypes.js +57 -21
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +319 -0
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +23 -22
- package/src/util/nameClass.js +6 -2
- package/src/util/negateValue.js +14 -4
- package/src/util/normalizeConfig.js +282 -0
- package/src/util/normalizeScreens.js +140 -0
- package/src/util/parseBoxShadowValue.js +72 -0
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +144 -152
- package/src/util/prefixSelector.js +7 -8
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +82 -81
- package/src/util/splitAtTopLevelOnly.js +45 -0
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +33 -8
- 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 +173 -93
- package/stubs/simpleConfig.stub.js +1 -1
- package/types/config.d.ts +361 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +342 -0
- package/types/index.d.ts +7 -0
- package/lib/lib/setupWatchingContext.js +0 -284
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -306
|
@@ -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
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
// Based on `glob-base`
|
|
15
|
-
// https://github.com/micromatch/glob-base/blob/master/index.js
|
|
16
|
-
function parseGlob(pattern) {
|
|
17
|
-
let glob = pattern;
|
|
18
|
-
let base = (0, _globParent).default(pattern);
|
|
19
|
-
if (base !== '.') {
|
|
20
|
-
glob = pattern.substr(base.length);
|
|
21
|
-
if (glob.charAt(0) === '/') {
|
|
22
|
-
glob = glob.substr(1);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (glob.substr(0, 2) === './') {
|
|
26
|
-
glob = glob.substr(2);
|
|
27
|
-
}
|
|
28
|
-
if (glob.charAt(0) === '/') {
|
|
29
|
-
glob = glob.substr(1);
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
base,
|
|
33
|
-
glob
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function parseDependency(normalizedFileOrGlob) {
|
|
37
|
-
if (normalizedFileOrGlob.startsWith('!')) {
|
|
38
|
-
return null;
|
|
12
|
+
Object.defineProperty(exports, "default", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: ()=>parseDependency
|
|
15
|
+
});
|
|
16
|
+
function parseDependency(contentPath) {
|
|
17
|
+
if (contentPath.ignore) {
|
|
18
|
+
return [];
|
|
39
19
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
} else {
|
|
49
|
-
message = {
|
|
50
|
-
type: 'dependency',
|
|
51
|
-
file: _path.default.resolve(normalizedFileOrGlob)
|
|
52
|
-
};
|
|
20
|
+
if (!contentPath.glob) {
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
type: "dependency",
|
|
24
|
+
file: contentPath.base
|
|
25
|
+
}
|
|
26
|
+
];
|
|
53
27
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
+
];
|
|
61
37
|
}
|
|
62
|
-
return
|
|
38
|
+
return [
|
|
39
|
+
{
|
|
40
|
+
type: "dir-dependency",
|
|
41
|
+
dir: contentPath.base,
|
|
42
|
+
glob: contentPath.glob
|
|
43
|
+
}
|
|
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,13 @@
|
|
|
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"));
|
|
9
12
|
function _interopRequireDefault(obj) {
|
|
10
13
|
return obj && obj.__esModule ? obj : {
|
|
11
14
|
default: obj
|
|
@@ -18,12 +21,12 @@ function parseObjectStyles(styles) {
|
|
|
18
21
|
]);
|
|
19
22
|
}
|
|
20
23
|
return styles.flatMap((style)=>{
|
|
21
|
-
return (0, _postcss
|
|
22
|
-
(0, _postcssNested
|
|
24
|
+
return (0, _postcss.default)([
|
|
25
|
+
(0, _postcssNested.default)({
|
|
23
26
|
bubble: [
|
|
24
|
-
|
|
27
|
+
"screen"
|
|
25
28
|
]
|
|
26
|
-
})
|
|
29
|
+
})
|
|
27
30
|
]).process(style, {
|
|
28
31
|
parser: _postcssJs.default
|
|
29
32
|
}).root.nodes;
|
package/lib/util/pluginUtils.js
CHANGED
|
@@ -2,189 +2,100 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
asValue: ()=>asValue,
|
|
14
|
+
parseColorFormat: ()=>parseColorFormat,
|
|
15
|
+
asColor: ()=>asColor,
|
|
16
|
+
asLookupValue: ()=>asLookupValue,
|
|
17
|
+
typeMap: ()=>typeMap,
|
|
18
|
+
coerceValue: ()=>coerceValue,
|
|
19
|
+
getMatchingTypes: ()=>getMatchingTypes
|
|
20
|
+
});
|
|
21
|
+
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
22
|
+
const _escapeCommas = /*#__PURE__*/ _interopRequireDefault(require("./escapeCommas"));
|
|
23
|
+
const _withAlphaVariable = require("./withAlphaVariable");
|
|
24
|
+
const _dataTypes = require("./dataTypes");
|
|
25
|
+
const _negateValue = /*#__PURE__*/ _interopRequireDefault(require("./negateValue"));
|
|
26
|
+
const _validateFormalSyntax = require("./validateFormalSyntax");
|
|
27
|
+
const _featureFlagsJs = require("../featureFlags.js");
|
|
20
28
|
function _interopRequireDefault(obj) {
|
|
21
29
|
return obj && obj.__esModule ? obj : {
|
|
22
30
|
default: obj
|
|
23
31
|
};
|
|
24
32
|
}
|
|
25
|
-
function applyStateToMarker(selector, marker, state, join) {
|
|
26
|
-
let markerIdx = selector.search(new RegExp(`${marker}[:[]`));
|
|
27
|
-
if (markerIdx === -1) {
|
|
28
|
-
return join(marker + state, selector);
|
|
29
|
-
}
|
|
30
|
-
let markerSelector = selector.slice(markerIdx, selector.indexOf(' ', markerIdx));
|
|
31
|
-
return join(marker + state + markerSelector.slice(markerIdx + marker.length), selector.replace(markerSelector, ''));
|
|
32
|
-
}
|
|
33
33
|
function updateAllClasses(selectors, updateClass) {
|
|
34
|
-
let parser = (0, _postcssSelectorParser
|
|
34
|
+
let parser = (0, _postcssSelectorParser.default)((selectors)=>{
|
|
35
35
|
selectors.walkClasses((sel)=>{
|
|
36
|
-
let updatedClass = updateClass(sel.value
|
|
37
|
-
withAttr (className, attr) {
|
|
38
|
-
sel.parent.insertAfter(sel, _postcssSelectorParser.default.attribute({
|
|
39
|
-
attribute: attr.slice(1, -1)
|
|
40
|
-
}));
|
|
41
|
-
return className;
|
|
42
|
-
},
|
|
43
|
-
withPseudo (className, pseudo) {
|
|
44
|
-
sel.parent.insertAfter(sel, _postcssSelectorParser.default.pseudo({
|
|
45
|
-
value: pseudo
|
|
46
|
-
}));
|
|
47
|
-
return className;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
36
|
+
let updatedClass = updateClass(sel.value);
|
|
50
37
|
sel.value = updatedClass;
|
|
51
38
|
if (sel.raws && sel.raws.value) {
|
|
52
|
-
sel.raws.value = (0, _escapeCommas
|
|
39
|
+
sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
|
|
53
40
|
}
|
|
54
41
|
});
|
|
55
42
|
});
|
|
56
43
|
let result = parser.processSync(selectors);
|
|
57
44
|
return result;
|
|
58
45
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let lastClass = sel.filter(({ type })=>type === 'class'
|
|
63
|
-
).pop();
|
|
64
|
-
if (lastClass === undefined) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
let updatedClass = updateClass(lastClass.value, {
|
|
68
|
-
withPseudo (className, pseudo) {
|
|
69
|
-
lastClass.parent.insertAfter(lastClass, _postcssSelectorParser.default.pseudo({
|
|
70
|
-
value: `${pseudo}`
|
|
71
|
-
}));
|
|
72
|
-
return className;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
lastClass.value = updatedClass;
|
|
76
|
-
if (lastClass.raws && lastClass.raws.value) {
|
|
77
|
-
lastClass.raws.value = (0, _escapeCommas).default(lastClass.raws.value);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
let result = parser.processSync(selectors);
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
function splitByNotEscapedCommas(str) {
|
|
85
|
-
let chunks = [];
|
|
86
|
-
let currentChunk = '';
|
|
87
|
-
for(let i = 0; i < str.length; i++){
|
|
88
|
-
if (str[i] === ',' && str[i - 1] !== '\\') {
|
|
89
|
-
chunks.push(currentChunk);
|
|
90
|
-
currentChunk = '';
|
|
91
|
-
} else {
|
|
92
|
-
currentChunk += str[i];
|
|
93
|
-
}
|
|
46
|
+
function resolveArbitraryValue(modifier, validate) {
|
|
47
|
+
if (!isArbitraryValue(modifier)) {
|
|
48
|
+
return undefined;
|
|
94
49
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return ({ container })=>{
|
|
101
|
-
container.walkRules((rule)=>{
|
|
102
|
-
if ((0, _isKeyframeRule).default(rule)) {
|
|
103
|
-
return rule;
|
|
104
|
-
}
|
|
105
|
-
let transformed = splitByNotEscapedCommas(rule.selector).map(transformSelector).join(',');
|
|
106
|
-
rule.selector = transformed;
|
|
107
|
-
if (withRule) {
|
|
108
|
-
withRule(rule);
|
|
109
|
-
}
|
|
110
|
-
return rule;
|
|
111
|
-
});
|
|
112
|
-
if (wrap) {
|
|
113
|
-
let wrapper = wrap();
|
|
114
|
-
let nodes = container.nodes;
|
|
115
|
-
container.removeAll();
|
|
116
|
-
wrapper.append(nodes);
|
|
117
|
-
container.append(wrapper);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
function transformAllClasses(transformClass, { wrap , withRule } = {
|
|
122
|
-
}) {
|
|
123
|
-
return ({ container })=>{
|
|
124
|
-
container.walkRules((rule)=>{
|
|
125
|
-
let selector = rule.selector;
|
|
126
|
-
let variantSelector = updateAllClasses(selector, transformClass);
|
|
127
|
-
rule.selector = variantSelector;
|
|
128
|
-
if (withRule) {
|
|
129
|
-
withRule(rule);
|
|
130
|
-
}
|
|
131
|
-
return rule;
|
|
132
|
-
});
|
|
133
|
-
if (wrap) {
|
|
134
|
-
let wrapper = wrap();
|
|
135
|
-
let nodes = container.nodes;
|
|
136
|
-
container.removeAll();
|
|
137
|
-
wrapper.append(nodes);
|
|
138
|
-
container.append(wrapper);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
50
|
+
let value = modifier.slice(1, -1);
|
|
51
|
+
if (!validate(value)) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return (0, _dataTypes.normalize)(value);
|
|
141
55
|
}
|
|
142
|
-
function
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
return rule;
|
|
153
|
-
});
|
|
154
|
-
if (wrap) {
|
|
155
|
-
let wrapper = wrap();
|
|
156
|
-
let nodes = container.nodes;
|
|
157
|
-
container.removeAll();
|
|
158
|
-
wrapper.append(nodes);
|
|
159
|
-
container.append(wrapper);
|
|
56
|
+
function asNegativeValue(modifier, lookup = {}, validate) {
|
|
57
|
+
let positiveValue = lookup[modifier];
|
|
58
|
+
if (positiveValue !== undefined) {
|
|
59
|
+
return (0, _negateValue.default)(positiveValue);
|
|
60
|
+
}
|
|
61
|
+
if (isArbitraryValue(modifier)) {
|
|
62
|
+
let resolved = resolveArbitraryValue(modifier, validate);
|
|
63
|
+
if (resolved === undefined) {
|
|
64
|
+
return undefined;
|
|
160
65
|
}
|
|
161
|
-
|
|
66
|
+
return (0, _negateValue.default)(resolved);
|
|
67
|
+
}
|
|
162
68
|
}
|
|
163
|
-
function asValue(modifier,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}) {
|
|
167
|
-
let value = lookup[modifier];
|
|
69
|
+
function asValue(modifier, options = {}, { validate =()=>true } = {}) {
|
|
70
|
+
var ref;
|
|
71
|
+
let value = (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
|
|
168
72
|
if (value !== undefined) {
|
|
169
73
|
return value;
|
|
170
74
|
}
|
|
171
|
-
if (
|
|
172
|
-
return
|
|
75
|
+
if (options.supportsNegativeValues && modifier.startsWith("-")) {
|
|
76
|
+
return asNegativeValue(modifier.slice(1), options.values, validate);
|
|
173
77
|
}
|
|
174
|
-
|
|
175
|
-
if (!validate(value)) {
|
|
176
|
-
return undefined;
|
|
177
|
-
}
|
|
178
|
-
return (0, _dataTypes).normalize(value);
|
|
78
|
+
return resolveArbitraryValue(modifier, validate);
|
|
179
79
|
}
|
|
180
80
|
function isArbitraryValue(input) {
|
|
181
|
-
return input.startsWith(
|
|
81
|
+
return input.startsWith("[") && input.endsWith("]");
|
|
182
82
|
}
|
|
183
|
-
function
|
|
184
|
-
let slashIdx = modifier.lastIndexOf(
|
|
83
|
+
function splitUtilityModifier(modifier) {
|
|
84
|
+
let slashIdx = modifier.lastIndexOf("/");
|
|
185
85
|
if (slashIdx === -1 || slashIdx === modifier.length - 1) {
|
|
186
86
|
return [
|
|
187
|
-
modifier
|
|
87
|
+
modifier,
|
|
88
|
+
undefined
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
let arbitrary = isArbitraryValue(modifier);
|
|
92
|
+
// The modifier could be of the form `[foo]/[bar]`
|
|
93
|
+
// We want to handle this case properly
|
|
94
|
+
// without affecting `[foo/bar]`
|
|
95
|
+
if (arbitrary && !modifier.includes("]/[")) {
|
|
96
|
+
return [
|
|
97
|
+
modifier,
|
|
98
|
+
undefined
|
|
188
99
|
];
|
|
189
100
|
}
|
|
190
101
|
return [
|
|
@@ -192,39 +103,52 @@ function splitAlpha(modifier) {
|
|
|
192
103
|
modifier.slice(slashIdx + 1)
|
|
193
104
|
];
|
|
194
105
|
}
|
|
195
|
-
function
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
106
|
+
function parseColorFormat(value) {
|
|
107
|
+
if (typeof value === "string" && value.includes("<alpha-value>")) {
|
|
108
|
+
let oldValue = value;
|
|
109
|
+
return ({ opacityValue =1 })=>oldValue.replace("<alpha-value>", opacityValue);
|
|
110
|
+
}
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
function asColor(_, options = {}, { tailwindConfig ={} , utilityModifier , rawModifier } = {}) {
|
|
114
|
+
var ref;
|
|
115
|
+
if (((ref = options.values) === null || ref === void 0 ? void 0 : ref[rawModifier]) !== undefined) {
|
|
116
|
+
var ref1;
|
|
117
|
+
return parseColorFormat((ref1 = options.values) === null || ref1 === void 0 ? void 0 : ref1[rawModifier]);
|
|
200
118
|
}
|
|
201
|
-
|
|
119
|
+
// TODO: Hoist this up to getMatchingTypes or something
|
|
120
|
+
// We do this here because we need the alpha value (if any)
|
|
121
|
+
let [color, alpha] = splitUtilityModifier(rawModifier);
|
|
202
122
|
if (alpha !== undefined) {
|
|
203
|
-
var
|
|
204
|
-
var
|
|
205
|
-
let normalizedColor = (
|
|
123
|
+
var ref2, ref3, ref4;
|
|
124
|
+
var ref5;
|
|
125
|
+
let normalizedColor = (ref5 = (ref2 = options.values) === null || ref2 === void 0 ? void 0 : ref2[color]) !== null && ref5 !== void 0 ? ref5 : isArbitraryValue(color) ? color.slice(1, -1) : undefined;
|
|
206
126
|
if (normalizedColor === undefined) {
|
|
207
127
|
return undefined;
|
|
208
128
|
}
|
|
129
|
+
normalizedColor = parseColorFormat(normalizedColor);
|
|
209
130
|
if (isArbitraryValue(alpha)) {
|
|
210
|
-
return (0, _withAlphaVariable
|
|
131
|
+
return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, alpha.slice(1, -1));
|
|
211
132
|
}
|
|
212
|
-
if (((
|
|
133
|
+
if (((ref3 = tailwindConfig.theme) === null || ref3 === void 0 ? void 0 : (ref4 = ref3.opacity) === null || ref4 === void 0 ? void 0 : ref4[alpha]) === undefined) {
|
|
213
134
|
return undefined;
|
|
214
135
|
}
|
|
215
|
-
return (0, _withAlphaVariable
|
|
136
|
+
return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, tailwindConfig.theme.opacity[alpha]);
|
|
216
137
|
}
|
|
217
|
-
return asValue(
|
|
138
|
+
return asValue(rawModifier, options, {
|
|
139
|
+
rawModifier,
|
|
140
|
+
utilityModifier,
|
|
218
141
|
validate: _dataTypes.color
|
|
219
142
|
});
|
|
220
143
|
}
|
|
221
|
-
function asLookupValue(modifier,
|
|
222
|
-
|
|
223
|
-
return
|
|
144
|
+
function asLookupValue(modifier, options = {}) {
|
|
145
|
+
var ref;
|
|
146
|
+
return (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
|
|
224
147
|
}
|
|
225
148
|
function guess(validate) {
|
|
226
|
-
return (modifier,
|
|
227
|
-
return asValue(modifier,
|
|
149
|
+
return (modifier, options, extras)=>{
|
|
150
|
+
return asValue(modifier, options, {
|
|
151
|
+
...extras,
|
|
228
152
|
validate
|
|
229
153
|
});
|
|
230
154
|
};
|
|
@@ -238,12 +162,14 @@ let typeMap = {
|
|
|
238
162
|
percentage: guess(_dataTypes.percentage),
|
|
239
163
|
position: guess(_dataTypes.position),
|
|
240
164
|
lookup: asLookupValue,
|
|
241
|
-
|
|
242
|
-
|
|
165
|
+
"generic-name": guess(_dataTypes.genericName),
|
|
166
|
+
"family-name": guess(_dataTypes.familyName),
|
|
243
167
|
number: guess(_dataTypes.number),
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
168
|
+
"line-width": guess(_dataTypes.lineWidth),
|
|
169
|
+
"absolute-size": guess(_dataTypes.absoluteSize),
|
|
170
|
+
"relative-size": guess(_dataTypes.relativeSize),
|
|
171
|
+
shadow: guess(_dataTypes.shadow),
|
|
172
|
+
size: guess(_validateFormalSyntax.backgroundSize)
|
|
247
173
|
};
|
|
248
174
|
let supportedTypes = Object.keys(typeMap);
|
|
249
175
|
function splitAtFirst(input, delim) {
|
|
@@ -257,26 +183,82 @@ function splitAtFirst(input, delim) {
|
|
|
257
183
|
input.slice(idx + 1)
|
|
258
184
|
];
|
|
259
185
|
}
|
|
260
|
-
function coerceValue(types, modifier,
|
|
186
|
+
function coerceValue(types, modifier, options, tailwindConfig) {
|
|
261
187
|
if (isArbitraryValue(modifier)) {
|
|
262
|
-
let
|
|
263
|
-
|
|
188
|
+
let arbitraryValue = modifier.slice(1, -1);
|
|
189
|
+
let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
|
|
190
|
+
// It could be that this resolves to `url(https` which is not a valid
|
|
191
|
+
// identifier. We currently only support "simple" words with dashes or
|
|
192
|
+
// underscores. E.g.: family-name
|
|
193
|
+
if (!/^[\w-_]+$/g.test(explicitType)) {
|
|
194
|
+
value = arbitraryValue;
|
|
195
|
+
} else if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
|
|
264
196
|
return [];
|
|
265
197
|
}
|
|
266
198
|
if (value.length > 0 && supportedTypes.includes(explicitType)) {
|
|
267
199
|
return [
|
|
268
|
-
asValue(`[${value}]`,
|
|
269
|
-
explicitType
|
|
200
|
+
asValue(`[${value}]`, options),
|
|
201
|
+
explicitType,
|
|
202
|
+
null
|
|
270
203
|
];
|
|
271
204
|
}
|
|
272
205
|
}
|
|
206
|
+
let matches = getMatchingTypes(types, modifier, options, tailwindConfig);
|
|
273
207
|
// Find first matching type
|
|
274
|
-
for (let
|
|
275
|
-
|
|
276
|
-
if (result) return [
|
|
277
|
-
result,
|
|
278
|
-
type
|
|
279
|
-
];
|
|
208
|
+
for (let match of matches){
|
|
209
|
+
return match;
|
|
280
210
|
}
|
|
281
211
|
return [];
|
|
282
212
|
}
|
|
213
|
+
function* getMatchingTypes(types, rawModifier, options, tailwindConfig) {
|
|
214
|
+
let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
|
|
215
|
+
let canUseUtilityModifier = modifiersEnabled && options.modifiers != null && (options.modifiers === "any" || typeof options.modifiers === "object");
|
|
216
|
+
let [modifier, utilityModifier] = canUseUtilityModifier ? splitUtilityModifier(rawModifier) : [
|
|
217
|
+
rawModifier,
|
|
218
|
+
undefined
|
|
219
|
+
];
|
|
220
|
+
if (utilityModifier !== undefined && modifier === "") {
|
|
221
|
+
modifier = "DEFAULT";
|
|
222
|
+
}
|
|
223
|
+
// Check the full value first
|
|
224
|
+
// TODO: Move to asValue… somehow
|
|
225
|
+
if (utilityModifier !== undefined) {
|
|
226
|
+
if (typeof options.modifiers === "object") {
|
|
227
|
+
var ref;
|
|
228
|
+
var ref1;
|
|
229
|
+
let configValue = (ref1 = (ref = options.modifiers) === null || ref === void 0 ? void 0 : ref[utilityModifier]) !== null && ref1 !== void 0 ? ref1 : null;
|
|
230
|
+
if (configValue !== null) {
|
|
231
|
+
utilityModifier = configValue;
|
|
232
|
+
} else if (isArbitraryValue(utilityModifier)) {
|
|
233
|
+
utilityModifier = utilityModifier.slice(1, -1);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
let result = asValue(rawModifier, options, {
|
|
237
|
+
rawModifier,
|
|
238
|
+
utilityModifier,
|
|
239
|
+
tailwindConfig
|
|
240
|
+
});
|
|
241
|
+
if (result !== undefined) {
|
|
242
|
+
yield [
|
|
243
|
+
result,
|
|
244
|
+
"any",
|
|
245
|
+
null
|
|
246
|
+
];
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
for (const { type } of types !== null && types !== void 0 ? types : []){
|
|
250
|
+
let result1 = typeMap[type](modifier, options, {
|
|
251
|
+
rawModifier,
|
|
252
|
+
utilityModifier,
|
|
253
|
+
tailwindConfig
|
|
254
|
+
});
|
|
255
|
+
if (result1 === undefined) {
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
yield [
|
|
259
|
+
result1,
|
|
260
|
+
type,
|
|
261
|
+
utilityModifier !== null && utilityModifier !== void 0 ? utilityModifier : null
|
|
262
|
+
];
|
|
263
|
+
}
|
|
264
|
+
}
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_default
|
|
8
|
+
});
|
|
9
|
+
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
8
10
|
function _interopRequireDefault(obj) {
|
|
9
11
|
return obj && obj.__esModule ? obj : {
|
|
10
12
|
default: obj
|
|
11
13
|
};
|
|
12
14
|
}
|
|
13
|
-
function _default(prefix, selector) {
|
|
14
|
-
|
|
15
|
-
;
|
|
16
|
-
return (0, _postcssSelectorParser).default((selectors)=>{
|
|
15
|
+
function _default(prefix, selector, prependNegative = false) {
|
|
16
|
+
return (0, _postcssSelectorParser.default)((selectors)=>{
|
|
17
17
|
selectors.walkClasses((classSelector)=>{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
18
|
+
let baseClass = classSelector.value;
|
|
19
|
+
let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
|
|
20
|
+
classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
|
|
21
21
|
});
|
|
22
22
|
}).processSync(selector);
|
|
23
23
|
}
|