tailwindcss 0.0.0-insiders.f4635e0 → 0.0.0-insiders.f4a2ccd
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/LICENSE +1 -2
- package/README.md +15 -7
- 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 +52 -0
- package/lib/cli/build/plugin.js +376 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +180 -0
- package/lib/cli/help/index.js +71 -0
- package/lib/cli/index.js +230 -0
- package/lib/cli/init/index.js +61 -0
- package/lib/cli-peer-dependencies.js +22 -14
- package/lib/cli.js +4 -762
- package/lib/corePluginList.js +182 -5
- package/lib/corePlugins.js +4109 -2952
- package/lib/css/preflight.css +24 -9
- package/lib/featureFlags.js +68 -50
- package/lib/index.js +5 -30
- 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 +177 -0
- package/lib/lib/defaultExtractor.js +241 -0
- package/lib/lib/detectNesting.js +39 -17
- package/lib/lib/evaluateTailwindFunctions.js +203 -161
- package/lib/lib/expandApplyAtRules.js +503 -221
- package/lib/lib/expandTailwindAtRules.js +255 -243
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +831 -317
- package/lib/lib/getModuleDependencies.js +93 -49
- package/lib/lib/load-config.js +36 -0
- package/lib/lib/normalizeTailwindDirectives.js +79 -60
- package/lib/lib/offsets.js +304 -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 +150 -94
- package/lib/lib/setupContextUtils.js +1197 -685
- package/lib/lib/setupTrackingContext.js +150 -177
- package/lib/lib/sharedState.js +70 -21
- package/lib/lib/substituteScreenAtRules.js +26 -28
- package/lib/oxide/cli/build/deps.js +81 -0
- package/lib/oxide/cli/build/index.js +51 -0
- package/lib/oxide/cli/build/plugin.js +373 -0
- package/lib/oxide/cli/build/utils.js +77 -0
- package/lib/oxide/cli/build/watching.js +177 -0
- package/lib/oxide/cli/help/index.js +70 -0
- package/lib/oxide/cli/index.js +214 -0
- package/lib/oxide/cli/init/index.js +50 -0
- package/lib/oxide/cli.js +5 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +98 -0
- 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 -56
- package/lib/public/colors.js +353 -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/load-config.js +10 -0
- package/lib/public/resolve-config.js +22 -0
- package/lib/util/applyImportantSelector.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 +104 -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 +266 -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 +341 -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 +35 -29
- package/lib/util/negateValue.js +31 -17
- package/lib/util/normalizeConfig.js +294 -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 +234 -288
- package/lib/util/prefixSelector.js +33 -19
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +221 -256
- package/lib/util/resolveConfigPath.js +55 -48
- package/lib/util/responsive.js +18 -14
- package/lib/util/splitAtTopLevelOnly.js +49 -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/loadConfig.d.ts +4 -0
- package/loadConfig.js +2 -0
- package/nesting/index.js +2 -12
- package/package.json +69 -66
- package/peers/index.js +76328 -84169
- 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/swap-engines.js +40 -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 +444 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +229 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +216 -0
- package/src/cli/init/index.js +79 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +4 -756
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +2526 -1956
- package/src/css/preflight.css +24 -9
- package/src/featureFlags.js +33 -10
- package/src/index.js +4 -33
- 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 +208 -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 +509 -153
- package/src/lib/expandTailwindAtRules.js +125 -104
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +678 -70
- package/src/lib/getModuleDependencies.js +70 -30
- package/src/lib/load-config.ts +27 -0
- package/src/lib/normalizeTailwindDirectives.js +10 -3
- package/src/lib/offsets.js +373 -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 +105 -47
- package/src/lib/setupContextUtils.js +848 -247
- package/src/lib/setupTrackingContext.js +53 -64
- package/src/lib/sharedState.js +60 -6
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/oxide/cli/build/deps.ts +91 -0
- package/src/oxide/cli/build/index.ts +47 -0
- package/src/oxide/cli/build/plugin.ts +442 -0
- package/src/oxide/cli/build/utils.ts +74 -0
- package/src/oxide/cli/build/watching.ts +225 -0
- package/src/oxide/cli/help/index.ts +69 -0
- package/src/oxide/cli/index.ts +204 -0
- package/src/oxide/cli/init/index.ts +59 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +107 -0
- 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 +18 -3
- package/src/public/colors.js +322 -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/load-config.js +2 -0
- package/src/public/resolve-config.js +7 -0
- package/src/util/applyImportantSelector.js +19 -0
- package/src/util/buildMediaQuery.js +14 -16
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +43 -11
- package/src/util/createUtilityPlugin.js +2 -11
- package/src/util/dataTypes.js +281 -0
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +412 -0
- package/src/util/getAllConfigs.js +21 -2
- package/src/util/isSyntacticallyValidPropertyValue.js +61 -0
- package/src/util/log.js +23 -22
- package/src/util/nameClass.js +6 -2
- package/src/util/negateValue.js +15 -5
- package/src/util/normalizeConfig.js +318 -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 +219 -219
- package/src/util/prefixSelector.js +30 -13
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +86 -91
- package/src/util/resolveConfigPath.js +12 -1
- package/src/util/splitAtTopLevelOnly.js +52 -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/.gitignore +1 -0
- package/stubs/.prettierrc.json +6 -0
- package/stubs/{defaultConfig.stub.js → config.full.js} +332 -249
- package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -1
- package/stubs/postcss.config.js +6 -0
- package/stubs/tailwind.config.cjs +2 -0
- package/stubs/tailwind.config.js +2 -0
- package/stubs/tailwind.config.ts +3 -0
- package/types/config.d.ts +373 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +298 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +347 -0
- package/types/index.d.ts +7 -0
- package/CHANGELOG.md +0 -1742
- package/lib/constants.js +0 -37
- package/lib/lib/setupWatchingContext.js +0 -331
- package/nesting/plugin.js +0 -41
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/constants.js +0 -17
- package/src/lib/setupWatchingContext.js +0 -307
- /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
package/lib/util/pluginUtils.js
CHANGED
|
@@ -1,318 +1,264 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.transformAllClasses = transformAllClasses;
|
|
11
|
-
exports.transformLastClasses = transformLastClasses;
|
|
12
|
-
exports.asValue = asValue;
|
|
13
|
-
exports.asUnit = asUnit;
|
|
14
|
-
exports.asColor = asColor;
|
|
15
|
-
exports.asAngle = asAngle;
|
|
16
|
-
exports.asLength = asLength;
|
|
17
|
-
exports.asLookupValue = asLookupValue;
|
|
18
|
-
exports.coerceValue = coerceValue;
|
|
19
|
-
|
|
20
|
-
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
|
|
21
|
-
|
|
22
|
-
var _escapeCommas = _interopRequireDefault(require("./escapeCommas"));
|
|
23
|
-
|
|
24
|
-
var _withAlphaVariable = require("./withAlphaVariable");
|
|
25
|
-
|
|
26
|
-
var _isKeyframeRule = _interopRequireDefault(require("./isKeyframeRule"));
|
|
27
|
-
|
|
28
|
-
var _color = require("./color");
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
|
-
function applyPseudoToMarker(selector, marker, state, join) {
|
|
33
|
-
let states = [state];
|
|
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);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function updateAllClasses(selectors, updateClass) {
|
|
46
|
-
let parser = (0, _postcssSelectorParser.default)(selectors => {
|
|
47
|
-
selectors.walkClasses(sel => {
|
|
48
|
-
let updatedClass = updateClass(sel.value, {
|
|
49
|
-
withPseudo(className, pseudo) {
|
|
50
|
-
sel.parent.insertAfter(sel, _postcssSelectorParser.default.pseudo({
|
|
51
|
-
value: `${pseudo}`
|
|
52
|
-
}));
|
|
53
|
-
return className;
|
|
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
|
-
}
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
62
9
|
});
|
|
63
|
-
});
|
|
64
|
-
let result = parser.processSync(selectors);
|
|
65
|
-
return result;
|
|
66
10
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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 _escapeCommas = /*#__PURE__*/ _interopRequireDefault(require("./escapeCommas"));
|
|
22
|
+
const _withAlphaVariable = require("./withAlphaVariable");
|
|
23
|
+
const _dataTypes = require("./dataTypes");
|
|
24
|
+
const _negateValue = /*#__PURE__*/ _interopRequireDefault(require("./negateValue"));
|
|
25
|
+
const _validateFormalSyntax = require("./validateFormalSyntax");
|
|
26
|
+
const _featureFlagsJs = require("../featureFlags.js");
|
|
27
|
+
function _interopRequireDefault(obj) {
|
|
28
|
+
return obj && obj.__esModule ? obj : {
|
|
29
|
+
default: obj
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function updateAllClasses(selectors, updateClass) {
|
|
33
|
+
selectors.walkClasses((sel)=>{
|
|
34
|
+
sel.value = updateClass(sel.value);
|
|
35
|
+
if (sel.raws && sel.raws.value) {
|
|
36
|
+
sel.raws.value = (0, _escapeCommas.default)(sel.raws.value);
|
|
85
37
|
}
|
|
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
|
-
}
|
|
93
38
|
});
|
|
94
|
-
});
|
|
95
|
-
let result = parser.processSync(selectors);
|
|
96
|
-
return result;
|
|
97
39
|
}
|
|
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];
|
|
40
|
+
function resolveArbitraryValue(modifier, validate) {
|
|
41
|
+
if (!isArbitraryValue(modifier)) {
|
|
42
|
+
return undefined;
|
|
109
43
|
}
|
|
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);
|
|
44
|
+
let value = modifier.slice(1, -1);
|
|
45
|
+
if (!validate(value)) {
|
|
46
|
+
return undefined;
|
|
144
47
|
}
|
|
145
|
-
|
|
48
|
+
return (0, _dataTypes.normalize)(value);
|
|
146
49
|
}
|
|
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);
|
|
50
|
+
function asNegativeValue(modifier, lookup = {}, validate) {
|
|
51
|
+
let positiveValue = lookup[modifier];
|
|
52
|
+
if (positiveValue !== undefined) {
|
|
53
|
+
return (0, _negateValue.default)(positiveValue);
|
|
173
54
|
}
|
|
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);
|
|
55
|
+
if (isArbitraryValue(modifier)) {
|
|
56
|
+
let resolved = resolveArbitraryValue(modifier, validate);
|
|
57
|
+
if (resolved === undefined) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
return (0, _negateValue.default)(resolved);
|
|
202
61
|
}
|
|
203
|
-
};
|
|
204
62
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
-
}
|
|
230
|
-
|
|
231
|
-
function asUnit(modifier, units, lookup = {}) {
|
|
232
|
-
return asValue(modifier, lookup, {
|
|
233
|
-
validate: value => {
|
|
234
|
-
let unitsPattern = `(?:${units.join('|')})`;
|
|
235
|
-
return new RegExp(`${unitsPattern}$`).test(value) || new RegExp(`^calc\\(.+?${unitsPattern}`).test(value);
|
|
63
|
+
function asValue(modifier, options = {}, { validate =()=>true } = {}) {
|
|
64
|
+
var _options_values;
|
|
65
|
+
let value = (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
|
|
66
|
+
if (value !== undefined) {
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
if (options.supportsNegativeValues && modifier.startsWith("-")) {
|
|
70
|
+
return asNegativeValue(modifier.slice(1), options.values, validate);
|
|
236
71
|
}
|
|
237
|
-
|
|
72
|
+
return resolveArbitraryValue(modifier, validate);
|
|
238
73
|
}
|
|
239
|
-
|
|
240
74
|
function isArbitraryValue(input) {
|
|
241
|
-
|
|
75
|
+
return input.startsWith("[") && input.endsWith("]");
|
|
242
76
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
77
|
+
function splitUtilityModifier(modifier) {
|
|
78
|
+
let slashIdx = modifier.lastIndexOf("/");
|
|
79
|
+
if (slashIdx === -1 || slashIdx === modifier.length - 1) {
|
|
80
|
+
return [
|
|
81
|
+
modifier,
|
|
82
|
+
undefined
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
let arbitrary = isArbitraryValue(modifier);
|
|
86
|
+
// The modifier could be of the form `[foo]/[bar]`
|
|
87
|
+
// We want to handle this case properly
|
|
88
|
+
// without affecting `[foo/bar]`
|
|
89
|
+
if (arbitrary && !modifier.includes("]/[")) {
|
|
90
|
+
return [
|
|
91
|
+
modifier,
|
|
92
|
+
undefined
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
return [
|
|
96
|
+
modifier.slice(0, slashIdx),
|
|
97
|
+
modifier.slice(slashIdx + 1)
|
|
98
|
+
];
|
|
252
99
|
}
|
|
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));
|
|
100
|
+
function parseColorFormat(value) {
|
|
101
|
+
if (typeof value === "string" && value.includes("<alpha-value>")) {
|
|
102
|
+
let oldValue = value;
|
|
103
|
+
return ({ opacityValue =1 })=>oldValue.replace("<alpha-value>", opacityValue);
|
|
266
104
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
105
|
+
return value;
|
|
106
|
+
}
|
|
107
|
+
function unwrapArbitraryModifier(modifier) {
|
|
108
|
+
modifier = modifier.slice(1, -1);
|
|
109
|
+
if (modifier.startsWith("--")) {
|
|
110
|
+
modifier = `var(${modifier})`;
|
|
270
111
|
}
|
|
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
|
-
});
|
|
112
|
+
return modifier;
|
|
278
113
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
114
|
+
function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
|
|
115
|
+
var _options_values;
|
|
116
|
+
if (((_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier]) !== undefined) {
|
|
117
|
+
var _options_values1;
|
|
118
|
+
return parseColorFormat((_options_values1 = options.values) === null || _options_values1 === void 0 ? void 0 : _options_values1[modifier]);
|
|
119
|
+
}
|
|
120
|
+
// TODO: Hoist this up to getMatchingTypes or something
|
|
121
|
+
// We do this here because we need the alpha value (if any)
|
|
122
|
+
let [color, alpha] = splitUtilityModifier(modifier);
|
|
123
|
+
if (alpha !== undefined) {
|
|
124
|
+
var _options_values2, _tailwindConfig_theme, _tailwindConfig_theme_opacity;
|
|
125
|
+
var _options_values_color;
|
|
126
|
+
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;
|
|
127
|
+
if (normalizedColor === undefined) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
normalizedColor = parseColorFormat(normalizedColor);
|
|
131
|
+
if (isArbitraryValue(alpha)) {
|
|
132
|
+
return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, unwrapArbitraryModifier(alpha));
|
|
133
|
+
}
|
|
134
|
+
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) {
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
return (0, _withAlphaVariable.withAlphaValue)(normalizedColor, tailwindConfig.theme.opacity[alpha]);
|
|
138
|
+
}
|
|
139
|
+
return asValue(modifier, options, {
|
|
140
|
+
validate: _dataTypes.color
|
|
141
|
+
});
|
|
282
142
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
143
|
+
function asLookupValue(modifier, options = {}) {
|
|
144
|
+
var _options_values;
|
|
145
|
+
return (_options_values = options.values) === null || _options_values === void 0 ? void 0 : _options_values[modifier];
|
|
286
146
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
147
|
+
function guess(validate) {
|
|
148
|
+
return (modifier, options)=>{
|
|
149
|
+
return asValue(modifier, options, {
|
|
150
|
+
validate
|
|
151
|
+
});
|
|
152
|
+
};
|
|
290
153
|
}
|
|
291
|
-
|
|
292
154
|
let typeMap = {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
155
|
+
any: asValue,
|
|
156
|
+
color: asColor,
|
|
157
|
+
url: guess(_dataTypes.url),
|
|
158
|
+
image: guess(_dataTypes.image),
|
|
159
|
+
length: guess(_dataTypes.length),
|
|
160
|
+
percentage: guess(_dataTypes.percentage),
|
|
161
|
+
position: guess(_dataTypes.position),
|
|
162
|
+
lookup: asLookupValue,
|
|
163
|
+
"generic-name": guess(_dataTypes.genericName),
|
|
164
|
+
"family-name": guess(_dataTypes.familyName),
|
|
165
|
+
number: guess(_dataTypes.number),
|
|
166
|
+
"line-width": guess(_dataTypes.lineWidth),
|
|
167
|
+
"absolute-size": guess(_dataTypes.absoluteSize),
|
|
168
|
+
"relative-size": guess(_dataTypes.relativeSize),
|
|
169
|
+
shadow: guess(_dataTypes.shadow),
|
|
170
|
+
size: guess(_validateFormalSyntax.backgroundSize)
|
|
298
171
|
};
|
|
299
|
-
|
|
172
|
+
let supportedTypes = Object.keys(typeMap);
|
|
300
173
|
function splitAtFirst(input, delim) {
|
|
301
|
-
|
|
174
|
+
let idx = input.indexOf(delim);
|
|
175
|
+
if (idx === -1) return [
|
|
176
|
+
undefined,
|
|
177
|
+
input
|
|
178
|
+
];
|
|
179
|
+
return [
|
|
180
|
+
input.slice(0, idx),
|
|
181
|
+
input.slice(idx + 1)
|
|
182
|
+
];
|
|
302
183
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
184
|
+
function coerceValue(types, modifier, options, tailwindConfig) {
|
|
185
|
+
if (options.values && modifier in options.values) {
|
|
186
|
+
for (let { type } of types !== null && types !== void 0 ? types : []){
|
|
187
|
+
let result = typeMap[type](modifier, options, {
|
|
188
|
+
tailwindConfig
|
|
189
|
+
});
|
|
190
|
+
if (result === undefined) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
return [
|
|
194
|
+
result,
|
|
195
|
+
type,
|
|
196
|
+
null
|
|
197
|
+
];
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (isArbitraryValue(modifier)) {
|
|
201
|
+
let arbitraryValue = modifier.slice(1, -1);
|
|
202
|
+
let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
|
|
203
|
+
// It could be that this resolves to `url(https` which is not a valid
|
|
204
|
+
// identifier. We currently only support "simple" words with dashes or
|
|
205
|
+
// underscores. E.g.: family-name
|
|
206
|
+
if (!/^[\w-_]+$/g.test(explicitType)) {
|
|
207
|
+
value = arbitraryValue;
|
|
208
|
+
} else if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
if (value.length > 0 && supportedTypes.includes(explicitType)) {
|
|
212
|
+
return [
|
|
213
|
+
asValue(`[${value}]`, options),
|
|
214
|
+
explicitType,
|
|
215
|
+
null
|
|
216
|
+
];
|
|
217
|
+
}
|
|
312
218
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
219
|
+
let matches = getMatchingTypes(types, modifier, options, tailwindConfig);
|
|
220
|
+
// Find first matching type
|
|
221
|
+
for (let match of matches){
|
|
222
|
+
return match;
|
|
223
|
+
}
|
|
224
|
+
return [];
|
|
225
|
+
}
|
|
226
|
+
function* getMatchingTypes(types, rawModifier, options, tailwindConfig) {
|
|
227
|
+
let modifiersEnabled = (0, _featureFlagsJs.flagEnabled)(tailwindConfig, "generalizedModifiers");
|
|
228
|
+
let [modifier, utilityModifier] = splitUtilityModifier(rawModifier);
|
|
229
|
+
let canUseUtilityModifier = modifiersEnabled && options.modifiers != null && (options.modifiers === "any" || typeof options.modifiers === "object" && (utilityModifier && isArbitraryValue(utilityModifier) || utilityModifier in options.modifiers));
|
|
230
|
+
if (!canUseUtilityModifier) {
|
|
231
|
+
modifier = rawModifier;
|
|
232
|
+
utilityModifier = undefined;
|
|
233
|
+
}
|
|
234
|
+
if (utilityModifier !== undefined && modifier === "") {
|
|
235
|
+
modifier = "DEFAULT";
|
|
236
|
+
}
|
|
237
|
+
// Check the full value first
|
|
238
|
+
// TODO: Move to asValue… somehow
|
|
239
|
+
if (utilityModifier !== undefined) {
|
|
240
|
+
if (typeof options.modifiers === "object") {
|
|
241
|
+
var _options_modifiers;
|
|
242
|
+
var _options_modifiers_utilityModifier;
|
|
243
|
+
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;
|
|
244
|
+
if (configValue !== null) {
|
|
245
|
+
utilityModifier = configValue;
|
|
246
|
+
} else if (isArbitraryValue(utilityModifier)) {
|
|
247
|
+
utilityModifier = unwrapArbitraryModifier(utilityModifier);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
for (let { type } of types !== null && types !== void 0 ? types : []){
|
|
252
|
+
let result = typeMap[type](modifier, options, {
|
|
253
|
+
tailwindConfig
|
|
254
|
+
});
|
|
255
|
+
if (result === undefined) {
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
yield [
|
|
259
|
+
result,
|
|
260
|
+
type,
|
|
261
|
+
utilityModifier !== null && utilityModifier !== void 0 ? utilityModifier : null
|
|
262
|
+
];
|
|
263
|
+
}
|
|
264
|
+
}
|
|
@@ -1,23 +1,37 @@
|
|
|
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
|
-
|
|
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"));
|
|
21
|
+
function _interopRequireDefault(obj) {
|
|
22
|
+
return obj && obj.__esModule ? obj : {
|
|
23
|
+
default: obj
|
|
24
|
+
};
|
|
25
|
+
}
|
|
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}`;
|
|
21
35
|
});
|
|
22
|
-
|
|
23
|
-
}
|
|
36
|
+
return typeof selector === "string" ? ast.toString() : ast;
|
|
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
|
+
}
|