tailwindcss 0.0.0-insiders.7b94fea → 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 +588 -3
- package/LICENSE +1 -2
- package/README.md +15 -7
- 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 +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 +20 -7
- package/lib/cli.js +108 -571
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +15 -4
- package/lib/corePlugins.js +2229 -1868
- package/lib/css/preflight.css +22 -9
- package/lib/featureFlags.js +39 -25
- package/lib/index.js +28 -12
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +28 -10
- package/lib/lib/collapseDuplicateDeclarations.js +83 -0
- package/lib/lib/content.js +177 -0
- package/lib/lib/defaultExtractor.js +241 -0
- package/lib/lib/detectNesting.js +27 -3
- package/lib/lib/evaluateTailwindFunctions.js +117 -50
- package/lib/lib/expandApplyAtRules.js +457 -159
- package/lib/lib/expandTailwindAtRules.js +130 -127
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +610 -141
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +43 -32
- package/lib/lib/offsets.js +285 -0
- package/lib/lib/partitionApplyAtRules.js +56 -0
- package/lib/lib/regex.js +60 -0
- package/lib/lib/remap-bitfield.js +87 -0
- package/lib/lib/resolveDefaultsAtRules.js +114 -81
- package/lib/lib/setupContextUtils.js +718 -323
- package/lib/lib/setupTrackingContext.js +43 -71
- package/lib/lib/sharedState.js +50 -9
- 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 +247 -245
- 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 +12 -14
- package/lib/util/dataTypes.js +164 -100
- package/lib/util/defaults.js +12 -3
- package/lib/util/escapeClassName.js +9 -6
- package/lib/util/escapeCommas.js +5 -2
- package/lib/util/flattenColorPalette.js +9 -12
- package/lib/util/formatVariantSelector.js +353 -0
- package/lib/util/getAllConfigs.js +29 -10
- package/lib/util/hashConfig.js +6 -3
- package/lib/util/isKeyframeRule.js +5 -2
- package/lib/util/isPlainObject.js +5 -2
- package/lib/util/isSyntacticallyValidPropertyValue.js +72 -0
- package/lib/util/log.js +22 -12
- package/lib/util/nameClass.js +20 -8
- package/lib/util/negateValue.js +23 -6
- package/lib/util/normalizeConfig.js +147 -60
- 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 +182 -181
- package/lib/util/prefixSelector.js +27 -13
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +97 -73
- 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 +51 -50
- package/peers/index.js +15019 -12583
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.d.ts +12 -0
- package/resolveConfig.js +2 -1
- 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 +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 +50 -577
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +886 -598
- package/src/css/preflight.css +22 -9
- package/src/featureFlags.js +24 -8
- 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 +213 -0
- package/src/lib/defaultExtractor.js +217 -0
- package/src/lib/detectNesting.js +30 -3
- package/src/lib/evaluateTailwindFunctions.js +84 -10
- package/src/lib/expandApplyAtRules.js +508 -153
- package/src/lib/expandTailwindAtRules.js +82 -79
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +625 -111
- package/src/lib/normalizeTailwindDirectives.js +7 -1
- package/src/lib/offsets.js +351 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/resolveDefaultsAtRules.js +98 -60
- package/src/lib/setupContextUtils.js +666 -168
- package/src/lib/setupTrackingContext.js +16 -52
- package/src/lib/sharedState.js +44 -4
- 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/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 +86 -21
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +412 -0
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/isSyntacticallyValidPropertyValue.js +61 -0
- package/src/util/log.js +11 -7
- package/src/util/nameClass.js +6 -2
- package/src/util/negateValue.js +14 -4
- package/src/util/normalizeConfig.js +72 -5
- 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 +169 -143
- package/src/util/prefixSelector.js +30 -13
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +81 -27
- 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 +246 -213
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +363 -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 -304
package/lib/util/pluginUtils.js
CHANGED
|
@@ -2,189 +2,113 @@
|
|
|
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
|
+
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");
|
|
20
29
|
function _interopRequireDefault(obj) {
|
|
21
30
|
return obj && obj.__esModule ? obj : {
|
|
22
31
|
default: obj
|
|
23
32
|
};
|
|
24
33
|
}
|
|
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
34
|
function updateAllClasses(selectors, updateClass) {
|
|
34
|
-
let parser = (0, _postcssSelectorParser
|
|
35
|
+
let parser = (0, _postcssSelectorParser.default)((selectors)=>{
|
|
35
36
|
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
|
-
});
|
|
37
|
+
let updatedClass = updateClass(sel.value);
|
|
50
38
|
sel.value = updatedClass;
|
|
51
39
|
if (sel.raws && sel.raws.value) {
|
|
52
|
-
sel.raws.value = (0, _escapeCommas
|
|
40
|
+
sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
|
|
53
41
|
}
|
|
54
42
|
});
|
|
55
43
|
});
|
|
56
44
|
let result = parser.processSync(selectors);
|
|
57
45
|
return result;
|
|
58
46
|
}
|
|
59
|
-
function
|
|
60
|
-
let parser = (0, _postcssSelectorParser
|
|
47
|
+
function filterSelectorsForClass(selectors, classCandidate) {
|
|
48
|
+
let parser = (0, _postcssSelectorParser.default)((selectors)=>{
|
|
61
49
|
selectors.each((sel)=>{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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);
|
|
50
|
+
const containsClass = sel.nodes.some((node)=>node.type === "class" && node.value === classCandidate);
|
|
51
|
+
if (!containsClass) {
|
|
52
|
+
sel.remove();
|
|
78
53
|
}
|
|
79
54
|
});
|
|
80
55
|
});
|
|
81
56
|
let result = parser.processSync(selectors);
|
|
82
57
|
return result;
|
|
83
58
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
}
|
|
59
|
+
function resolveArbitraryValue(modifier, validate) {
|
|
60
|
+
if (!isArbitraryValue(modifier)) {
|
|
61
|
+
return undefined;
|
|
94
62
|
}
|
|
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
|
-
};
|
|
63
|
+
let value = modifier.slice(1, -1);
|
|
64
|
+
if (!validate(value)) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return (0, _dataTypes.normalize)(value);
|
|
141
68
|
}
|
|
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);
|
|
69
|
+
function asNegativeValue(modifier, lookup = {}, validate) {
|
|
70
|
+
let positiveValue = lookup[modifier];
|
|
71
|
+
if (positiveValue !== undefined) {
|
|
72
|
+
return (0, _negateValue.default)(positiveValue);
|
|
73
|
+
}
|
|
74
|
+
if (isArbitraryValue(modifier)) {
|
|
75
|
+
let resolved = resolveArbitraryValue(modifier, validate);
|
|
76
|
+
if (resolved === undefined) {
|
|
77
|
+
return undefined;
|
|
160
78
|
}
|
|
161
|
-
|
|
79
|
+
return (0, _negateValue.default)(resolved);
|
|
80
|
+
}
|
|
162
81
|
}
|
|
163
|
-
function asValue(modifier,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}) {
|
|
167
|
-
let value = lookup[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];
|
|
168
85
|
if (value !== undefined) {
|
|
169
86
|
return value;
|
|
170
87
|
}
|
|
171
|
-
if (
|
|
172
|
-
return
|
|
173
|
-
}
|
|
174
|
-
value = modifier.slice(1, -1);
|
|
175
|
-
if (!validate(value)) {
|
|
176
|
-
return undefined;
|
|
88
|
+
if (options.supportsNegativeValues && modifier.startsWith("-")) {
|
|
89
|
+
return asNegativeValue(modifier.slice(1), options.values, validate);
|
|
177
90
|
}
|
|
178
|
-
return (
|
|
91
|
+
return resolveArbitraryValue(modifier, validate);
|
|
179
92
|
}
|
|
180
93
|
function isArbitraryValue(input) {
|
|
181
|
-
return input.startsWith(
|
|
94
|
+
return input.startsWith("[") && input.endsWith("]");
|
|
182
95
|
}
|
|
183
|
-
function
|
|
184
|
-
let slashIdx = modifier.lastIndexOf(
|
|
96
|
+
function splitUtilityModifier(modifier) {
|
|
97
|
+
let slashIdx = modifier.lastIndexOf("/");
|
|
185
98
|
if (slashIdx === -1 || slashIdx === modifier.length - 1) {
|
|
186
99
|
return [
|
|
187
|
-
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
|
|
188
112
|
];
|
|
189
113
|
}
|
|
190
114
|
return [
|
|
@@ -192,39 +116,56 @@ function splitAlpha(modifier) {
|
|
|
192
116
|
modifier.slice(slashIdx + 1)
|
|
193
117
|
];
|
|
194
118
|
}
|
|
195
|
-
function
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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})`;
|
|
200
130
|
}
|
|
201
|
-
|
|
131
|
+
return modifier;
|
|
132
|
+
}
|
|
133
|
+
function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
|
|
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]);
|
|
138
|
+
}
|
|
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);
|
|
202
142
|
if (alpha !== undefined) {
|
|
203
|
-
var
|
|
204
|
-
var
|
|
205
|
-
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;
|
|
206
146
|
if (normalizedColor === undefined) {
|
|
207
147
|
return undefined;
|
|
208
148
|
}
|
|
149
|
+
normalizedColor = parseColorFormat(normalizedColor);
|
|
209
150
|
if (isArbitraryValue(alpha)) {
|
|
210
|
-
return (0, _withAlphaVariable
|
|
151
|
+
return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, unwrapArbitraryModifier(alpha));
|
|
211
152
|
}
|
|
212
|
-
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) {
|
|
213
154
|
return undefined;
|
|
214
155
|
}
|
|
215
|
-
return (0, _withAlphaVariable
|
|
156
|
+
return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, tailwindConfig.theme.opacity[alpha]);
|
|
216
157
|
}
|
|
217
|
-
return asValue(modifier,
|
|
158
|
+
return asValue(modifier, options, {
|
|
218
159
|
validate: _dataTypes.color
|
|
219
160
|
});
|
|
220
161
|
}
|
|
221
|
-
function asLookupValue(modifier,
|
|
222
|
-
|
|
223
|
-
return
|
|
162
|
+
function asLookupValue(modifier, options = {}) {
|
|
163
|
+
var _options_values;
|
|
164
|
+
return (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
|
|
224
165
|
}
|
|
225
166
|
function guess(validate) {
|
|
226
|
-
return (modifier,
|
|
227
|
-
return asValue(modifier,
|
|
167
|
+
return (modifier, options)=>{
|
|
168
|
+
return asValue(modifier, options, {
|
|
228
169
|
validate
|
|
229
170
|
});
|
|
230
171
|
};
|
|
@@ -238,12 +179,14 @@ let typeMap = {
|
|
|
238
179
|
percentage: guess(_dataTypes.percentage),
|
|
239
180
|
position: guess(_dataTypes.position),
|
|
240
181
|
lookup: asLookupValue,
|
|
241
|
-
|
|
242
|
-
|
|
182
|
+
"generic-name": guess(_dataTypes.genericName),
|
|
183
|
+
"family-name": guess(_dataTypes.familyName),
|
|
243
184
|
number: guess(_dataTypes.number),
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
185
|
+
"line-width": guess(_dataTypes.lineWidth),
|
|
186
|
+
"absolute-size": guess(_dataTypes.absoluteSize),
|
|
187
|
+
"relative-size": guess(_dataTypes.relativeSize),
|
|
188
|
+
shadow: guess(_dataTypes.shadow),
|
|
189
|
+
size: guess(_validateFormalSyntax.backgroundSize)
|
|
247
190
|
};
|
|
248
191
|
let supportedTypes = Object.keys(typeMap);
|
|
249
192
|
function splitAtFirst(input, delim) {
|
|
@@ -257,26 +200,84 @@ function splitAtFirst(input, delim) {
|
|
|
257
200
|
input.slice(idx + 1)
|
|
258
201
|
];
|
|
259
202
|
}
|
|
260
|
-
function coerceValue(types, modifier,
|
|
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
|
+
}
|
|
261
219
|
if (isArbitraryValue(modifier)) {
|
|
262
|
-
let
|
|
263
|
-
|
|
220
|
+
let arbitraryValue = modifier.slice(1, -1);
|
|
221
|
+
let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
|
|
222
|
+
// It could be that this resolves to `url(https` which is not a valid
|
|
223
|
+
// identifier. We currently only support "simple" words with dashes or
|
|
224
|
+
// underscores. E.g.: family-name
|
|
225
|
+
if (!/^[\w-_]+$/g.test(explicitType)) {
|
|
226
|
+
value = arbitraryValue;
|
|
227
|
+
} else if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
|
|
264
228
|
return [];
|
|
265
229
|
}
|
|
266
230
|
if (value.length > 0 && supportedTypes.includes(explicitType)) {
|
|
267
231
|
return [
|
|
268
|
-
asValue(`[${value}]`,
|
|
269
|
-
explicitType
|
|
232
|
+
asValue(`[${value}]`, options),
|
|
233
|
+
explicitType,
|
|
234
|
+
null
|
|
270
235
|
];
|
|
271
236
|
}
|
|
272
237
|
}
|
|
238
|
+
let matches = getMatchingTypes(types, modifier, options, tailwindConfig);
|
|
273
239
|
// Find first matching type
|
|
274
|
-
for (let
|
|
275
|
-
|
|
276
|
-
|
|
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 : []){
|
|
271
|
+
let result = typeMap[type](modifier, options, {
|
|
272
|
+
tailwindConfig
|
|
273
|
+
});
|
|
274
|
+
if (result === undefined) {
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
yield [
|
|
277
278
|
result,
|
|
278
|
-
type
|
|
279
|
+
type,
|
|
280
|
+
utilityModifier !== null && utilityModifier !== void 0 ? utilityModifier : null
|
|
279
281
|
];
|
|
280
282
|
}
|
|
281
|
-
return [];
|
|
282
283
|
}
|
|
@@ -2,22 +2,36 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
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"));
|
|
8
21
|
function _interopRequireDefault(obj) {
|
|
9
22
|
return obj && obj.__esModule ? obj : {
|
|
10
23
|
default: obj
|
|
11
24
|
};
|
|
12
25
|
}
|
|
13
|
-
function _default(prefix, selector) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
})
|
|
22
|
-
})
|
|
26
|
+
function _default(prefix, selector, prependNegative = false) {
|
|
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;
|
|
23
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
|
+
}
|