tailwindcss 0.0.0-insiders.fda68f7 → 0.0.0-oxide.6bf5e56
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 +603 -2
- package/LICENSE +1 -2
- package/README.md +14 -6
- package/colors.d.ts +3 -0
- package/colors.js +2 -304
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -4
- package/defaultTheme.d.ts +4 -0
- package/defaultTheme.js +2 -4
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +48 -0
- package/lib/cli/build/plugin.js +367 -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 +13 -0
- package/lib/cli-peer-dependencies.js +22 -14
- package/lib/cli.js +217 -743
- package/lib/constants.js +41 -34
- package/lib/corePluginList.js +178 -5
- package/lib/corePlugins.js +3879 -2941
- package/lib/css/preflight.css +22 -9
- package/lib/featureFlags.js +61 -50
- package/lib/index.js +45 -28
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +52 -36
- package/lib/lib/collapseDuplicateDeclarations.js +83 -0
- package/lib/lib/content.js +176 -0
- package/lib/lib/defaultExtractor.js +236 -0
- package/lib/lib/detectNesting.js +37 -0
- package/lib/lib/evaluateTailwindFunctions.js +203 -161
- package/lib/lib/expandApplyAtRules.js +502 -221
- package/lib/lib/expandTailwindAtRules.js +258 -243
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +775 -320
- package/lib/lib/getModuleDependencies.js +44 -46
- package/lib/lib/normalizeTailwindDirectives.js +79 -60
- 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 +150 -94
- package/lib/lib/setupContextUtils.js +1146 -599
- package/lib/lib/setupTrackingContext.js +129 -177
- package/lib/lib/sharedState.js +53 -21
- package/lib/lib/substituteScreenAtRules.js +26 -28
- 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 +58 -53
- package/lib/public/colors.js +331 -0
- package/lib/public/create-plugin.js +15 -0
- package/lib/public/default-config.js +16 -0
- package/lib/public/default-theme.js +16 -0
- package/lib/public/resolve-config.js +22 -0
- package/lib/util/bigSign.js +7 -6
- package/lib/util/buildMediaQuery.js +21 -32
- package/lib/util/cloneDeep.js +16 -14
- package/lib/util/cloneNodes.js +29 -15
- package/lib/util/color.js +90 -66
- package/lib/util/configurePlugins.js +17 -15
- package/lib/util/createPlugin.js +23 -26
- package/lib/util/createUtilityPlugin.js +46 -46
- package/lib/util/dataTypes.js +242 -0
- package/lib/util/defaults.js +20 -15
- package/lib/util/escapeClassName.js +18 -17
- package/lib/util/escapeCommas.js +7 -6
- package/lib/util/flattenColorPalette.js +13 -12
- package/lib/util/formatVariantSelector.js +285 -0
- package/lib/util/getAllConfigs.js +44 -18
- package/lib/util/hashConfig.js +15 -12
- package/lib/util/isKeyframeRule.js +7 -6
- package/lib/util/isPlainObject.js +11 -11
- package/lib/util/isSyntacticallyValidPropertyValue.js +72 -0
- package/lib/util/log.js +52 -33
- package/lib/util/nameClass.js +37 -26
- package/lib/util/negateValue.js +31 -17
- package/lib/util/normalizeConfig.js +281 -0
- package/lib/util/normalizeScreens.js +170 -0
- package/lib/util/parseAnimationValue.js +85 -54
- package/lib/util/parseBoxShadowValue.js +84 -0
- package/lib/util/parseDependency.js +41 -70
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +30 -24
- package/lib/util/pluginUtils.js +252 -287
- package/lib/util/prefixSelector.js +20 -20
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +221 -256
- package/lib/util/resolveConfigPath.js +43 -48
- package/lib/util/responsive.js +18 -14
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +8 -7
- package/lib/util/toColorValue.js +7 -6
- package/lib/util/toPath.js +27 -8
- package/lib/util/transformThemeValue.js +67 -28
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/validateFormalSyntax.js +24 -0
- package/lib/util/withAlphaVariable.js +67 -57
- package/nesting/index.js +2 -12
- package/package.json +60 -65
- package/peers/index.js +76445 -84221
- package/plugin.d.ts +11 -0
- package/plugin.js +1 -2
- package/resolveConfig.d.ts +12 -0
- package/resolveConfig.js +2 -7
- 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 +49 -0
- package/src/cli/build/plugin.js +439 -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 +6 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +50 -575
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +2405 -1948
- package/src/css/preflight.css +22 -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 +212 -0
- package/src/lib/defaultExtractor.js +211 -0
- package/src/lib/detectNesting.js +39 -0
- package/src/lib/evaluateTailwindFunctions.js +84 -10
- package/src/lib/expandApplyAtRules.js +508 -153
- package/src/lib/expandTailwindAtRules.js +130 -104
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +596 -70
- 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 +105 -47
- package/src/lib/setupContextUtils.js +828 -196
- package/src/lib/setupTrackingContext.js +19 -54
- package/src/lib/sharedState.js +45 -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 +19 -2
- package/src/public/colors.js +300 -0
- package/src/public/create-plugin.js +2 -0
- package/src/public/default-config.js +4 -0
- package/src/public/default-theme.js +4 -0
- package/src/public/resolve-config.js +7 -0
- 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 -11
- package/src/util/dataTypes.js +256 -0
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +319 -0
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/isSyntacticallyValidPropertyValue.js +61 -0
- package/src/util/log.js +23 -22
- package/src/util/nameClass.js +14 -6
- package/src/util/negateValue.js +15 -5
- package/src/util/normalizeConfig.js +300 -0
- package/src/util/normalizeScreens.js +140 -0
- package/src/util/parseAnimationValue.js +7 -1
- package/src/util/parseBoxShadowValue.js +72 -0
- package/src/util/parseDependency.js +37 -38
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +216 -197
- package/src/util/prefixSelector.js +7 -8
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +86 -91
- 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 +14 -9
- package/stubs/defaultConfig.stub.js +186 -117
- package/stubs/simpleConfig.stub.js +1 -1
- package/types/config.d.ts +362 -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 -331
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -306
package/lib/util/pluginUtils.js
CHANGED
|
@@ -1,318 +1,283 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
let markerIdx = selector.indexOf(marker + ':');
|
|
35
|
-
|
|
36
|
-
if (markerIdx !== -1) {
|
|
37
|
-
let existingMarker = selector.slice(markerIdx, selector.indexOf(' ', markerIdx));
|
|
38
|
-
states = states.concat(selector.slice(markerIdx + marker.length + 1, existingMarker.length).split(':'));
|
|
39
|
-
selector = selector.replace(existingMarker, '');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return join(`${[marker, ...states].join(':')}`, selector);
|
|
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");
|
|
29
|
+
function _interopRequireDefault(obj) {
|
|
30
|
+
return obj && obj.__esModule ? obj : {
|
|
31
|
+
default: obj
|
|
32
|
+
};
|
|
43
33
|
}
|
|
44
|
-
|
|
45
34
|
function updateAllClasses(selectors, updateClass) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
sel.value = updatedClass;
|
|
58
|
-
|
|
59
|
-
if (sel.raws && sel.raws.value) {
|
|
60
|
-
sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
|
|
61
|
-
}
|
|
35
|
+
let parser = (0, _postcssSelectorParser.default)((selectors)=>{
|
|
36
|
+
selectors.walkClasses((sel)=>{
|
|
37
|
+
let updatedClass = updateClass(sel.value);
|
|
38
|
+
sel.value = updatedClass;
|
|
39
|
+
if (sel.raws && sel.raws.value) {
|
|
40
|
+
sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
62
43
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return result;
|
|
44
|
+
let result = parser.processSync(selectors);
|
|
45
|
+
return result;
|
|
66
46
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (lastClass === undefined) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
let updatedClass = updateClass(lastClass.value, {
|
|
80
|
-
withPseudo(className, pseudo) {
|
|
81
|
-
lastClass.parent.insertAfter(lastClass, _postcssSelectorParser.default.pseudo({
|
|
82
|
-
value: `${pseudo}`
|
|
83
|
-
}));
|
|
84
|
-
return className;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
});
|
|
88
|
-
lastClass.value = updatedClass;
|
|
89
|
-
|
|
90
|
-
if (lastClass.raws && lastClass.raws.value) {
|
|
91
|
-
lastClass.raws.value = (0, _escapeCommas.default)(lastClass.raws.value);
|
|
92
|
-
}
|
|
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();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
93
55
|
});
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return result;
|
|
56
|
+
let result = parser.processSync(selectors);
|
|
57
|
+
return result;
|
|
97
58
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
let currentChunk = '';
|
|
102
|
-
|
|
103
|
-
for (let i = 0; i < str.length; i++) {
|
|
104
|
-
if (str[i] === ',' && str[i - 1] !== '\\') {
|
|
105
|
-
chunks.push(currentChunk);
|
|
106
|
-
currentChunk = '';
|
|
107
|
-
} else {
|
|
108
|
-
currentChunk += str[i];
|
|
59
|
+
function resolveArbitraryValue(modifier, validate) {
|
|
60
|
+
if (!isArbitraryValue(modifier)) {
|
|
61
|
+
return undefined;
|
|
109
62
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return chunks;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function transformAllSelectors(transformSelector, {
|
|
117
|
-
wrap,
|
|
118
|
-
withRule
|
|
119
|
-
} = {}) {
|
|
120
|
-
return ({
|
|
121
|
-
container
|
|
122
|
-
}) => {
|
|
123
|
-
container.walkRules(rule => {
|
|
124
|
-
if ((0, _isKeyframeRule.default)(rule)) {
|
|
125
|
-
return rule;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
let transformed = splitByNotEscapedCommas(rule.selector).map(transformSelector).join(',');
|
|
129
|
-
rule.selector = transformed;
|
|
130
|
-
|
|
131
|
-
if (withRule) {
|
|
132
|
-
withRule(rule);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return rule;
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
if (wrap) {
|
|
139
|
-
let wrapper = wrap();
|
|
140
|
-
let nodes = container.nodes;
|
|
141
|
-
container.removeAll();
|
|
142
|
-
wrapper.append(nodes);
|
|
143
|
-
container.append(wrapper);
|
|
63
|
+
let value = modifier.slice(1, -1);
|
|
64
|
+
if (!validate(value)) {
|
|
65
|
+
return undefined;
|
|
144
66
|
}
|
|
145
|
-
|
|
67
|
+
return (0, _dataTypes.normalize)(value);
|
|
146
68
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
} = {}) {
|
|
152
|
-
return ({
|
|
153
|
-
container
|
|
154
|
-
}) => {
|
|
155
|
-
container.walkRules(rule => {
|
|
156
|
-
let selector = rule.selector;
|
|
157
|
-
let variantSelector = updateAllClasses(selector, transformClass);
|
|
158
|
-
rule.selector = variantSelector;
|
|
159
|
-
|
|
160
|
-
if (withRule) {
|
|
161
|
-
withRule(rule);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return rule;
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
if (wrap) {
|
|
168
|
-
let wrapper = wrap();
|
|
169
|
-
let nodes = container.nodes;
|
|
170
|
-
container.removeAll();
|
|
171
|
-
wrapper.append(nodes);
|
|
172
|
-
container.append(wrapper);
|
|
69
|
+
function asNegativeValue(modifier, lookup = {}, validate) {
|
|
70
|
+
let positiveValue = lookup[modifier];
|
|
71
|
+
if (positiveValue !== undefined) {
|
|
72
|
+
return (0, _negateValue.default)(positiveValue);
|
|
173
73
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
} = {}) {
|
|
181
|
-
return ({
|
|
182
|
-
container
|
|
183
|
-
}) => {
|
|
184
|
-
container.walkRules(rule => {
|
|
185
|
-
let selector = rule.selector;
|
|
186
|
-
let variantSelector = updateLastClasses(selector, transformClass);
|
|
187
|
-
rule.selector = variantSelector;
|
|
188
|
-
|
|
189
|
-
if (withRule) {
|
|
190
|
-
withRule(rule);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return rule;
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
if (wrap) {
|
|
197
|
-
let wrapper = wrap();
|
|
198
|
-
let nodes = container.nodes;
|
|
199
|
-
container.removeAll();
|
|
200
|
-
wrapper.append(nodes);
|
|
201
|
-
container.append(wrapper);
|
|
74
|
+
if (isArbitraryValue(modifier)) {
|
|
75
|
+
let resolved = resolveArbitraryValue(modifier, validate);
|
|
76
|
+
if (resolved === undefined) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
return (0, _negateValue.default)(resolved);
|
|
202
80
|
}
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function asValue(modifier, lookup = {}, {
|
|
207
|
-
validate = () => true
|
|
208
|
-
} = {}) {
|
|
209
|
-
let value = lookup[modifier];
|
|
210
|
-
|
|
211
|
-
if (value !== undefined) {
|
|
212
|
-
return value;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (modifier[0] !== '[' || modifier[modifier.length - 1] !== ']') {
|
|
216
|
-
return undefined;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
value = modifier.slice(1, -1);
|
|
220
|
-
|
|
221
|
-
if (!validate(value)) {
|
|
222
|
-
return undefined;
|
|
223
|
-
} // convert `_` to ` `, escept for escaped underscores `\_`
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
value = value.replace(/([^\\])_/g, '$1 ').replace(/^_/g, ' ').replace(/\\_/g, '_'); // add spaces around operators inside calc() that do not follow an operator or (
|
|
227
|
-
|
|
228
|
-
return value.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, '$1 $2 ');
|
|
229
81
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return new RegExp(`${unitsPattern}$`).test(value) || new RegExp(`^calc\\(.+?${unitsPattern}`).test(value);
|
|
82
|
+
function asValue(modifier, options = {}, { validate =()=>true } = {}) {
|
|
83
|
+
var ref;
|
|
84
|
+
let value = (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
|
|
85
|
+
if (value !== undefined) {
|
|
86
|
+
return value;
|
|
236
87
|
}
|
|
237
|
-
|
|
88
|
+
if (options.supportsNegativeValues && modifier.startsWith("-")) {
|
|
89
|
+
return asNegativeValue(modifier.slice(1), options.values, validate);
|
|
90
|
+
}
|
|
91
|
+
return resolveArbitraryValue(modifier, validate);
|
|
238
92
|
}
|
|
239
|
-
|
|
240
93
|
function isArbitraryValue(input) {
|
|
241
|
-
|
|
94
|
+
return input.startsWith("[") && input.endsWith("]");
|
|
242
95
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
96
|
+
function splitUtilityModifier(modifier) {
|
|
97
|
+
let slashIdx = modifier.lastIndexOf("/");
|
|
98
|
+
if (slashIdx === -1 || slashIdx === modifier.length - 1) {
|
|
99
|
+
return [
|
|
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
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
return [
|
|
115
|
+
modifier.slice(0, slashIdx),
|
|
116
|
+
modifier.slice(slashIdx + 1)
|
|
117
|
+
];
|
|
252
118
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
let [color, alpha] = splitAlpha(modifier);
|
|
260
|
-
|
|
261
|
-
if (lookup[color] !== undefined) {
|
|
262
|
-
var _tailwindConfig$theme, _tailwindConfig$theme2;
|
|
263
|
-
|
|
264
|
-
if (isArbitraryValue(alpha)) {
|
|
265
|
-
return (0, _withAlphaVariable.withAlphaValue)(lookup[color], alpha.slice(1, -1));
|
|
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);
|
|
266
123
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
function unwrapArbitraryModifier(modifier) {
|
|
127
|
+
modifier = modifier.slice(1, -1);
|
|
128
|
+
if (modifier.startsWith("--")) {
|
|
129
|
+
modifier = `var(${modifier})`;
|
|
270
130
|
}
|
|
271
|
-
|
|
272
|
-
return (0, _withAlphaVariable.withAlphaValue)(lookup[color], tailwindConfig.theme.opacity[alpha]);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
return asValue(modifier, lookup, {
|
|
276
|
-
validate: value => (0, _color.parseColor)(value) !== null
|
|
277
|
-
});
|
|
131
|
+
return modifier;
|
|
278
132
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
133
|
+
function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
|
|
134
|
+
var ref;
|
|
135
|
+
if (((ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier]) !== undefined) {
|
|
136
|
+
var ref1;
|
|
137
|
+
return parseColorFormat((ref1 = options.values) === null || ref1 === void 0 ? void 0 : ref1[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);
|
|
142
|
+
if (alpha !== undefined) {
|
|
143
|
+
var ref2, ref3, ref4;
|
|
144
|
+
var ref5;
|
|
145
|
+
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;
|
|
146
|
+
if (normalizedColor === undefined) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
normalizedColor = parseColorFormat(normalizedColor);
|
|
150
|
+
if (isArbitraryValue(alpha)) {
|
|
151
|
+
return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, unwrapArbitraryModifier(alpha));
|
|
152
|
+
}
|
|
153
|
+
if (((ref3 = tailwindConfig.theme) === null || ref3 === void 0 ? void 0 : (ref4 = ref3.opacity) === null || ref4 === void 0 ? void 0 : ref4[alpha]) === undefined) {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, tailwindConfig.theme.opacity[alpha]);
|
|
157
|
+
}
|
|
158
|
+
return asValue(modifier, options, {
|
|
159
|
+
validate: _dataTypes.color
|
|
160
|
+
});
|
|
282
161
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
162
|
+
function asLookupValue(modifier, options = {}) {
|
|
163
|
+
var ref;
|
|
164
|
+
return (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
|
|
286
165
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
166
|
+
function guess(validate) {
|
|
167
|
+
return (modifier, options)=>{
|
|
168
|
+
return asValue(modifier, options, {
|
|
169
|
+
validate
|
|
170
|
+
});
|
|
171
|
+
};
|
|
290
172
|
}
|
|
291
|
-
|
|
292
173
|
let typeMap = {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
174
|
+
any: asValue,
|
|
175
|
+
color: asColor,
|
|
176
|
+
url: guess(_dataTypes.url),
|
|
177
|
+
image: guess(_dataTypes.image),
|
|
178
|
+
length: guess(_dataTypes.length),
|
|
179
|
+
percentage: guess(_dataTypes.percentage),
|
|
180
|
+
position: guess(_dataTypes.position),
|
|
181
|
+
lookup: asLookupValue,
|
|
182
|
+
"generic-name": guess(_dataTypes.genericName),
|
|
183
|
+
"family-name": guess(_dataTypes.familyName),
|
|
184
|
+
number: guess(_dataTypes.number),
|
|
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)
|
|
298
190
|
};
|
|
299
|
-
|
|
191
|
+
let supportedTypes = Object.keys(typeMap);
|
|
300
192
|
function splitAtFirst(input, delim) {
|
|
301
|
-
|
|
193
|
+
let idx = input.indexOf(delim);
|
|
194
|
+
if (idx === -1) return [
|
|
195
|
+
undefined,
|
|
196
|
+
input
|
|
197
|
+
];
|
|
198
|
+
return [
|
|
199
|
+
input.slice(0, idx),
|
|
200
|
+
input.slice(idx + 1)
|
|
201
|
+
];
|
|
202
|
+
}
|
|
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
|
+
}
|
|
219
|
+
if (isArbitraryValue(modifier)) {
|
|
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)) {
|
|
228
|
+
return [];
|
|
229
|
+
}
|
|
230
|
+
if (value.length > 0 && supportedTypes.includes(explicitType)) {
|
|
231
|
+
return [
|
|
232
|
+
asValue(`[${value}]`, options),
|
|
233
|
+
explicitType,
|
|
234
|
+
null
|
|
235
|
+
];
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
let matches = getMatchingTypes(types, modifier, options, tailwindConfig);
|
|
239
|
+
// Find first matching type
|
|
240
|
+
for (let match of matches){
|
|
241
|
+
return match;
|
|
242
|
+
}
|
|
243
|
+
return [];
|
|
302
244
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
if (value.length > 0 && Object.keys(typeMap).includes(explicitType)) {
|
|
311
|
-
return [asValue(`[${value}]`, values, tailwindConfig), explicitType];
|
|
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;
|
|
312
252
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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 ref;
|
|
261
|
+
var ref1;
|
|
262
|
+
let configValue = (ref1 = (ref = options.modifiers) === null || ref === void 0 ? void 0 : ref[utilityModifier]) !== null && ref1 !== void 0 ? ref1 : 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 [
|
|
278
|
+
result,
|
|
279
|
+
type,
|
|
280
|
+
utilityModifier !== null && utilityModifier !== void 0 ? utilityModifier : null
|
|
281
|
+
];
|
|
282
|
+
}
|
|
283
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_default
|
|
8
|
+
});
|
|
9
|
+
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
|
10
|
+
function _interopRequireDefault(obj) {
|
|
11
|
+
return obj && obj.__esModule ? obj : {
|
|
12
|
+
default: obj
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function _default(prefix, selector, prependNegative = false) {
|
|
16
|
+
return (0, _postcssSelectorParser.default)((selectors)=>{
|
|
17
|
+
selectors.walkClasses((classSelector)=>{
|
|
18
|
+
let baseClass = classSelector.value;
|
|
19
|
+
let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
|
|
20
|
+
classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
|
|
21
|
+
});
|
|
22
|
+
}).processSync(selector);
|
|
23
|
+
}
|
|
@@ -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
|
+
}
|