tailwindcss 3.0.22 → 3.1.0
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 +92 -2
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +3 -0
- package/lib/cli-peer-dependencies.js +10 -5
- package/lib/cli.js +266 -203
- package/lib/constants.js +8 -8
- package/lib/corePluginList.js +1 -0
- package/lib/corePlugins.js +1662 -1554
- package/lib/css/preflight.css +1 -8
- package/lib/featureFlags.js +14 -12
- package/lib/index.js +16 -6
- package/lib/lib/cacheInvalidation.js +87 -0
- package/lib/lib/collapseAdjacentRules.js +30 -15
- package/lib/lib/collapseDuplicateDeclarations.js +1 -1
- package/lib/lib/defaultExtractor.js +191 -30
- package/lib/lib/detectNesting.js +9 -9
- package/lib/lib/evaluateTailwindFunctions.js +37 -28
- package/lib/lib/expandApplyAtRules.js +379 -189
- package/lib/lib/expandTailwindAtRules.js +168 -144
- package/lib/lib/generateRules.js +190 -81
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +35 -35
- package/lib/lib/partitionApplyAtRules.js +7 -7
- package/lib/lib/regex.js +52 -0
- package/lib/lib/resolveDefaultsAtRules.js +80 -79
- package/lib/lib/setupContextUtils.js +207 -170
- package/lib/lib/setupTrackingContext.js +61 -63
- package/lib/lib/sharedState.js +11 -8
- package/lib/lib/substituteScreenAtRules.js +3 -4
- package/lib/postcss-plugins/nesting/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +1 -1
- package/lib/postcss-plugins/nesting/plugin.js +40 -9
- package/lib/processTailwindFeatures.js +7 -7
- package/lib/public/colors.js +241 -241
- package/lib/public/resolve-config.js +5 -5
- package/lib/util/buildMediaQuery.js +2 -3
- package/lib/util/cloneDeep.js +3 -5
- package/lib/util/cloneNodes.js +12 -1
- package/lib/util/color.js +42 -51
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +6 -7
- package/lib/util/dataTypes.js +85 -81
- package/lib/util/escapeClassName.js +5 -5
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +4 -7
- package/lib/util/formatVariantSelector.js +82 -75
- package/lib/util/getAllConfigs.js +15 -10
- package/lib/util/hashConfig.js +5 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +1 -1
- package/lib/util/isValidArbitraryValue.js +26 -27
- package/lib/util/log.js +9 -10
- package/lib/util/nameClass.js +7 -7
- package/lib/util/negateValue.js +4 -5
- package/lib/util/normalizeConfig.js +68 -58
- package/lib/util/normalizeScreens.js +5 -6
- package/lib/util/parseAnimationValue.js +56 -57
- package/lib/util/parseBoxShadowValue.js +19 -20
- package/lib/util/parseDependency.js +32 -32
- package/lib/util/parseObjectStyles.js +6 -6
- package/lib/util/pluginUtils.js +20 -12
- package/lib/util/prefixSelector.js +1 -1
- package/lib/util/resolveConfig.js +81 -58
- package/lib/util/resolveConfigPath.js +16 -16
- package/lib/util/responsive.js +6 -6
- package/lib/util/splitAtTopLevelOnly.js +90 -0
- package/lib/util/toColorValue.js +1 -1
- package/lib/util/toPath.js +2 -2
- package/lib/util/transformThemeValue.js +30 -28
- package/lib/util/validateConfig.js +21 -0
- package/lib/util/withAlphaVariable.js +23 -23
- package/package.json +33 -27
- package/peers/index.js +7728 -5848
- package/plugin.d.ts +11 -0
- package/scripts/generate-types.js +52 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +118 -24
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +142 -30
- package/src/css/preflight.css +1 -8
- package/src/featureFlags.js +4 -4
- package/src/index.js +15 -1
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/defaultExtractor.js +177 -33
- package/src/lib/evaluateTailwindFunctions.js +20 -4
- package/src/lib/expandApplyAtRules.js +418 -186
- package/src/lib/expandTailwindAtRules.js +30 -10
- package/src/lib/generateRules.js +142 -51
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +7 -3
- package/src/lib/setupContextUtils.js +142 -87
- package/src/lib/setupTrackingContext.js +7 -3
- package/src/lib/sharedState.js +2 -0
- package/src/postcss-plugins/nesting/README.md +2 -2
- package/src/postcss-plugins/nesting/plugin.js +36 -0
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +25 -21
- package/src/util/dataTypes.js +14 -6
- package/src/util/formatVariantSelector.js +79 -62
- package/src/util/getAllConfigs.js +7 -0
- package/src/util/log.js +8 -8
- package/src/util/normalizeConfig.js +0 -8
- package/src/util/parseBoxShadowValue.js +3 -2
- package/src/util/pluginUtils.js +13 -1
- package/src/util/resolveConfig.js +66 -22
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +4 -2
- package/src/util/validateConfig.js +13 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +5 -1
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +325 -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/index.d.ts +1 -0
package/lib/util/pluginUtils.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.updateAllClasses = updateAllClasses;
|
|
6
6
|
exports.asValue = asValue;
|
|
7
|
+
exports.parseColorFormat = parseColorFormat;
|
|
7
8
|
exports.asColor = asColor;
|
|
8
9
|
exports.asLookupValue = asLookupValue;
|
|
9
10
|
exports.coerceValue = coerceValue;
|
|
@@ -53,23 +54,22 @@ function asNegativeValue(modifier, lookup = {}, validate) {
|
|
|
53
54
|
return (0, _negateValue).default(resolved);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
|
-
function asValue(modifier, options = {}, { validate =()=>true
|
|
57
|
-
} = {}) {
|
|
57
|
+
function asValue(modifier, options = {}, { validate =()=>true } = {}) {
|
|
58
58
|
var ref;
|
|
59
59
|
let value = (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
|
|
60
60
|
if (value !== undefined) {
|
|
61
61
|
return value;
|
|
62
62
|
}
|
|
63
|
-
if (options.supportsNegativeValues && modifier.startsWith(
|
|
63
|
+
if (options.supportsNegativeValues && modifier.startsWith("-")) {
|
|
64
64
|
return asNegativeValue(modifier.slice(1), options.values, validate);
|
|
65
65
|
}
|
|
66
66
|
return resolveArbitraryValue(modifier, validate);
|
|
67
67
|
}
|
|
68
68
|
function isArbitraryValue(input) {
|
|
69
|
-
return input.startsWith(
|
|
69
|
+
return input.startsWith("[") && input.endsWith("]");
|
|
70
70
|
}
|
|
71
71
|
function splitAlpha(modifier) {
|
|
72
|
-
let slashIdx = modifier.lastIndexOf(
|
|
72
|
+
let slashIdx = modifier.lastIndexOf("/");
|
|
73
73
|
if (slashIdx === -1 || slashIdx === modifier.length - 1) {
|
|
74
74
|
return [
|
|
75
75
|
modifier
|
|
@@ -80,11 +80,18 @@ function splitAlpha(modifier) {
|
|
|
80
80
|
modifier.slice(slashIdx + 1)
|
|
81
81
|
];
|
|
82
82
|
}
|
|
83
|
+
function parseColorFormat(value) {
|
|
84
|
+
if (typeof value === "string" && value.includes("<alpha-value>")) {
|
|
85
|
+
let oldValue = value;
|
|
86
|
+
return ({ opacityValue =1 })=>oldValue.replace("<alpha-value>", opacityValue);
|
|
87
|
+
}
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
83
90
|
function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
|
|
84
91
|
var ref;
|
|
85
92
|
if (((ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier]) !== undefined) {
|
|
86
93
|
var ref1;
|
|
87
|
-
return (ref1 = options.values) === null || ref1 === void 0 ? void 0 : ref1[modifier];
|
|
94
|
+
return parseColorFormat((ref1 = options.values) === null || ref1 === void 0 ? void 0 : ref1[modifier]);
|
|
88
95
|
}
|
|
89
96
|
let [color, alpha] = splitAlpha(modifier);
|
|
90
97
|
if (alpha !== undefined) {
|
|
@@ -94,6 +101,7 @@ function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
|
|
|
94
101
|
if (normalizedColor === undefined) {
|
|
95
102
|
return undefined;
|
|
96
103
|
}
|
|
104
|
+
normalizedColor = parseColorFormat(normalizedColor);
|
|
97
105
|
if (isArbitraryValue(alpha)) {
|
|
98
106
|
return (0, _withAlphaVariable).withAlphaValue(normalizedColor, alpha.slice(1, -1));
|
|
99
107
|
}
|
|
@@ -126,12 +134,12 @@ let typeMap = {
|
|
|
126
134
|
percentage: guess(_dataTypes.percentage),
|
|
127
135
|
position: guess(_dataTypes.position),
|
|
128
136
|
lookup: asLookupValue,
|
|
129
|
-
|
|
130
|
-
|
|
137
|
+
"generic-name": guess(_dataTypes.genericName),
|
|
138
|
+
"family-name": guess(_dataTypes.familyName),
|
|
131
139
|
number: guess(_dataTypes.number),
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
140
|
+
"line-width": guess(_dataTypes.lineWidth),
|
|
141
|
+
"absolute-size": guess(_dataTypes.absoluteSize),
|
|
142
|
+
"relative-size": guess(_dataTypes.relativeSize),
|
|
135
143
|
shadow: guess(_dataTypes.shadow)
|
|
136
144
|
};
|
|
137
145
|
let supportedTypes = Object.keys(typeMap);
|
|
@@ -149,7 +157,7 @@ function splitAtFirst(input, delim) {
|
|
|
149
157
|
function coerceValue(types, modifier, options, tailwindConfig) {
|
|
150
158
|
if (isArbitraryValue(modifier)) {
|
|
151
159
|
let arbitraryValue = modifier.slice(1, -1);
|
|
152
|
-
let [explicitType, value] = splitAtFirst(arbitraryValue,
|
|
160
|
+
let [explicitType, value] = splitAtFirst(arbitraryValue, ":");
|
|
153
161
|
// It could be that this resolves to `url(https` which is not a valid
|
|
154
162
|
// identifier. We currently only support "simple" words with dashes or
|
|
155
163
|
// underscores. E.g.: family-name
|
|
@@ -13,7 +13,7 @@ function _default(prefix, selector, prependNegative = false) {
|
|
|
13
13
|
return (0, _postcssSelectorParser).default((selectors)=>{
|
|
14
14
|
selectors.walkClasses((classSelector)=>{
|
|
15
15
|
let baseClass = classSelector.value;
|
|
16
|
-
let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith(
|
|
16
|
+
let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
|
|
17
17
|
classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
|
|
18
18
|
});
|
|
19
19
|
}).processSync(selector);
|
|
@@ -13,16 +13,40 @@ var _toPath = require("./toPath");
|
|
|
13
13
|
var _normalizeConfig = require("./normalizeConfig");
|
|
14
14
|
var _isPlainObject = _interopRequireDefault(require("./isPlainObject"));
|
|
15
15
|
var _cloneDeep = require("./cloneDeep");
|
|
16
|
+
var _pluginUtils = require("./pluginUtils");
|
|
17
|
+
var _withAlphaVariable = require("./withAlphaVariable");
|
|
18
|
+
var _toColorValue = _interopRequireDefault(require("./toColorValue"));
|
|
19
|
+
function resolveConfig(configs) {
|
|
20
|
+
let allConfigs = [
|
|
21
|
+
...extractPluginConfigs(configs),
|
|
22
|
+
{
|
|
23
|
+
prefix: "",
|
|
24
|
+
important: false,
|
|
25
|
+
separator: ":",
|
|
26
|
+
variantOrder: _defaultConfigStub.default.variantOrder
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
var ref, ref1;
|
|
30
|
+
return (0, _normalizeConfig).normalizeConfig((0, _defaults).defaults({
|
|
31
|
+
theme: resolveFunctionKeys(mergeExtensions(mergeThemes(allConfigs.map((t)=>{
|
|
32
|
+
return (ref = t === null || t === void 0 ? void 0 : t.theme) !== null && ref !== void 0 ? ref : {};
|
|
33
|
+
})))),
|
|
34
|
+
corePlugins: resolveCorePlugins(allConfigs.map((c)=>c.corePlugins)),
|
|
35
|
+
plugins: resolvePluginLists(configs.map((c)=>{
|
|
36
|
+
return (ref1 = c === null || c === void 0 ? void 0 : c.plugins) !== null && ref1 !== void 0 ? ref1 : [];
|
|
37
|
+
}))
|
|
38
|
+
}, ...allConfigs));
|
|
39
|
+
}
|
|
16
40
|
function _interopRequireDefault(obj) {
|
|
17
41
|
return obj && obj.__esModule ? obj : {
|
|
18
42
|
default: obj
|
|
19
43
|
};
|
|
20
44
|
}
|
|
21
45
|
function isFunction(input) {
|
|
22
|
-
return typeof input ===
|
|
46
|
+
return typeof input === "function";
|
|
23
47
|
}
|
|
24
48
|
function isObject(input) {
|
|
25
|
-
return typeof input ===
|
|
49
|
+
return typeof input === "object" && input !== null;
|
|
26
50
|
}
|
|
27
51
|
function mergeWith(target, ...sources) {
|
|
28
52
|
let customizer = sources.pop();
|
|
@@ -46,8 +70,7 @@ const configUtils = {
|
|
|
46
70
|
colors: _colors.default,
|
|
47
71
|
negative (scale) {
|
|
48
72
|
// TODO: Log that this function isn't really needed anymore?
|
|
49
|
-
return Object.keys(scale).filter((key)=>scale[key] !==
|
|
50
|
-
).reduce((negativeScale, key)=>{
|
|
73
|
+
return Object.keys(scale).filter((key)=>scale[key] !== "0").reduce((negativeScale, key)=>{
|
|
51
74
|
let negativeValue = (0, _negateValue).default(scale[key]);
|
|
52
75
|
if (negativeValue !== undefined) {
|
|
53
76
|
negativeScale[`-${key}`] = negativeValue;
|
|
@@ -56,12 +79,10 @@ const configUtils = {
|
|
|
56
79
|
}, {});
|
|
57
80
|
},
|
|
58
81
|
breakpoints (screens) {
|
|
59
|
-
return Object.keys(screens).filter((key)=>typeof screens[key] ===
|
|
60
|
-
).reduce((breakpoints, key)=>({
|
|
82
|
+
return Object.keys(screens).filter((key)=>typeof screens[key] === "string").reduce((breakpoints, key)=>({
|
|
61
83
|
...breakpoints,
|
|
62
84
|
[`screen-${key}`]: screens[key]
|
|
63
|
-
})
|
|
64
|
-
, {});
|
|
85
|
+
}), {});
|
|
65
86
|
}
|
|
66
87
|
};
|
|
67
88
|
function value(valueToResolve, ...args) {
|
|
@@ -90,8 +111,7 @@ function collectExtends(items) {
|
|
|
90
111
|
}
|
|
91
112
|
function mergeThemes(themes) {
|
|
92
113
|
return {
|
|
93
|
-
...themes.reduce((merged, theme)=>(0, _defaults).defaults(merged, theme)
|
|
94
|
-
, {}),
|
|
114
|
+
...themes.reduce((merged, theme)=>(0, _defaults).defaults(merged, theme), {}),
|
|
95
115
|
// In order to resolve n config objects, we combine all of their `extend` properties
|
|
96
116
|
// into arrays instead of objects so they aren't overridden.
|
|
97
117
|
extend: collectExtends(themes)
|
|
@@ -125,37 +145,62 @@ function mergeExtensions({ extend , ...theme }) {
|
|
|
125
145
|
return (resolveThemePath, utils)=>mergeWith({}, ...[
|
|
126
146
|
themeValue,
|
|
127
147
|
...extensions
|
|
128
|
-
].map((e)=>value(e, resolveThemePath, utils)
|
|
129
|
-
), mergeExtensionCustomizer)
|
|
130
|
-
;
|
|
148
|
+
].map((e)=>value(e, resolveThemePath, utils)), mergeExtensionCustomizer);
|
|
131
149
|
});
|
|
132
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
*
|
|
153
|
+
* @param {string} key
|
|
154
|
+
* @return {Iterable<string[] & {alpha: string | undefined}>}
|
|
155
|
+
*/ function* toPaths(key) {
|
|
156
|
+
let path = (0, _toPath).toPath(key);
|
|
157
|
+
if (path.length === 0) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
yield path;
|
|
161
|
+
if (Array.isArray(key)) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
let pattern = /^(.*?)\s*\/\s*([^/]+)$/;
|
|
165
|
+
let matches = key.match(pattern);
|
|
166
|
+
if (matches !== null) {
|
|
167
|
+
let [, prefix, alpha] = matches;
|
|
168
|
+
let newPath = (0, _toPath).toPath(prefix);
|
|
169
|
+
newPath.alpha = alpha;
|
|
170
|
+
yield newPath;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
133
173
|
function resolveFunctionKeys(object) {
|
|
174
|
+
// theme('colors.red.500 / 0.5') -> ['colors', 'red', '500 / 0', '5]
|
|
134
175
|
const resolvePath = (key, defaultValue)=>{
|
|
135
|
-
const path
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
176
|
+
for (const path of toPaths(key)){
|
|
177
|
+
let index = 0;
|
|
178
|
+
let val = object;
|
|
179
|
+
while(val !== undefined && val !== null && index < path.length){
|
|
180
|
+
val = val[path[index++]];
|
|
181
|
+
let shouldResolveAsFn = isFunction(val) && (path.alpha === undefined || index < path.length - 1);
|
|
182
|
+
val = shouldResolveAsFn ? val(resolvePath, configUtils) : val;
|
|
183
|
+
}
|
|
184
|
+
if (val !== undefined) {
|
|
185
|
+
if (path.alpha !== undefined) {
|
|
186
|
+
let normalized = (0, _pluginUtils).parseColorFormat(val);
|
|
187
|
+
return (0, _withAlphaVariable).withAlphaValue(normalized, path.alpha, (0, _toColorValue).default(normalized));
|
|
188
|
+
}
|
|
189
|
+
if ((0, _isPlainObject).default(val)) {
|
|
190
|
+
return (0, _cloneDeep).cloneDeep(val);
|
|
191
|
+
}
|
|
192
|
+
return val;
|
|
193
|
+
}
|
|
147
194
|
}
|
|
148
|
-
return
|
|
195
|
+
return defaultValue;
|
|
149
196
|
};
|
|
150
|
-
resolvePath
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
197
|
+
Object.assign(resolvePath, {
|
|
198
|
+
theme: resolvePath,
|
|
199
|
+
...configUtils
|
|
200
|
+
});
|
|
154
201
|
return Object.keys(object).reduce((resolved, key)=>{
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
[key]: isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key]
|
|
158
|
-
};
|
|
202
|
+
resolved[key] = isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key];
|
|
203
|
+
return resolved;
|
|
159
204
|
}, {});
|
|
160
205
|
}
|
|
161
206
|
function extractPluginConfigs(configs) {
|
|
@@ -165,8 +210,8 @@ function extractPluginConfigs(configs) {
|
|
|
165
210
|
...allConfigs,
|
|
166
211
|
config
|
|
167
212
|
];
|
|
168
|
-
var
|
|
169
|
-
const plugins = (
|
|
213
|
+
var ref2;
|
|
214
|
+
const plugins = (ref2 = config === null || config === void 0 ? void 0 : config.plugins) !== null && ref2 !== void 0 ? ref2 : [];
|
|
170
215
|
if (plugins.length === 0) {
|
|
171
216
|
return;
|
|
172
217
|
}
|
|
@@ -209,25 +254,3 @@ function resolvePluginLists(pluginLists) {
|
|
|
209
254
|
}, []);
|
|
210
255
|
return result;
|
|
211
256
|
}
|
|
212
|
-
function resolveConfig(configs) {
|
|
213
|
-
let allConfigs = [
|
|
214
|
-
...extractPluginConfigs(configs),
|
|
215
|
-
{
|
|
216
|
-
prefix: '',
|
|
217
|
-
important: false,
|
|
218
|
-
separator: ':',
|
|
219
|
-
variantOrder: _defaultConfigStub.default.variantOrder
|
|
220
|
-
},
|
|
221
|
-
];
|
|
222
|
-
var ref, ref2;
|
|
223
|
-
return (0, _normalizeConfig).normalizeConfig((0, _defaults).defaults({
|
|
224
|
-
theme: resolveFunctionKeys(mergeExtensions(mergeThemes(allConfigs.map((t)=>{
|
|
225
|
-
return (ref = t === null || t === void 0 ? void 0 : t.theme) !== null && ref !== void 0 ? ref : {};
|
|
226
|
-
})))),
|
|
227
|
-
corePlugins: resolveCorePlugins(allConfigs.map((c)=>c.corePlugins
|
|
228
|
-
)),
|
|
229
|
-
plugins: resolvePluginLists(configs.map((c)=>{
|
|
230
|
-
return (ref2 = c === null || c === void 0 ? void 0 : c.plugins) !== null && ref2 !== void 0 ? ref2 : [];
|
|
231
|
-
}))
|
|
232
|
-
}, ...allConfigs));
|
|
233
|
-
}
|
|
@@ -5,20 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.default = resolveConfigPath;
|
|
6
6
|
var _fs = _interopRequireDefault(require("fs"));
|
|
7
7
|
var _path = _interopRequireDefault(require("path"));
|
|
8
|
-
function _interopRequireDefault(obj) {
|
|
9
|
-
return obj && obj.__esModule ? obj : {
|
|
10
|
-
default: obj
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function isObject(value) {
|
|
14
|
-
return typeof value === 'object' && value !== null;
|
|
15
|
-
}
|
|
16
|
-
function isEmpty(obj) {
|
|
17
|
-
return Object.keys(obj).length === 0;
|
|
18
|
-
}
|
|
19
|
-
function isString(value) {
|
|
20
|
-
return typeof value === 'string' || value instanceof String;
|
|
21
|
-
}
|
|
22
8
|
function resolveConfigPath(pathOrConfig) {
|
|
23
9
|
// require('tailwindcss')({ theme: ..., variants: ... })
|
|
24
10
|
if (isObject(pathOrConfig) && pathOrConfig.config === undefined && !isEmpty(pathOrConfig)) {
|
|
@@ -38,8 +24,8 @@ function resolveConfigPath(pathOrConfig) {
|
|
|
38
24
|
}
|
|
39
25
|
// require('tailwindcss')
|
|
40
26
|
for (const configFile of [
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
"./tailwind.config.js",
|
|
28
|
+
"./tailwind.config.cjs"
|
|
43
29
|
]){
|
|
44
30
|
try {
|
|
45
31
|
const configPath = _path.default.resolve(configFile);
|
|
@@ -49,3 +35,17 @@ function resolveConfigPath(pathOrConfig) {
|
|
|
49
35
|
}
|
|
50
36
|
return null;
|
|
51
37
|
}
|
|
38
|
+
function _interopRequireDefault(obj) {
|
|
39
|
+
return obj && obj.__esModule ? obj : {
|
|
40
|
+
default: obj
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function isObject(value) {
|
|
44
|
+
return typeof value === "object" && value !== null;
|
|
45
|
+
}
|
|
46
|
+
function isEmpty(obj) {
|
|
47
|
+
return Object.keys(obj).length === 0;
|
|
48
|
+
}
|
|
49
|
+
function isString(value) {
|
|
50
|
+
return typeof value === "string" || value instanceof String;
|
|
51
|
+
}
|
package/lib/util/responsive.js
CHANGED
|
@@ -5,15 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.default = responsive;
|
|
6
6
|
var _postcss = _interopRequireDefault(require("postcss"));
|
|
7
7
|
var _cloneNodes = _interopRequireDefault(require("./cloneNodes"));
|
|
8
|
-
function _interopRequireDefault(obj) {
|
|
9
|
-
return obj && obj.__esModule ? obj : {
|
|
10
|
-
default: obj
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
8
|
function responsive(rules) {
|
|
14
9
|
return _postcss.default.atRule({
|
|
15
|
-
name:
|
|
10
|
+
name: "responsive"
|
|
16
11
|
}).append((0, _cloneNodes).default(Array.isArray(rules) ? rules : [
|
|
17
12
|
rules
|
|
18
13
|
]));
|
|
19
14
|
}
|
|
15
|
+
function _interopRequireDefault(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.splitAtTopLevelOnly = splitAtTopLevelOnly;
|
|
6
|
+
var regex = _interopRequireWildcard(require("../lib/regex"));
|
|
7
|
+
function _getRequireWildcardCache() {
|
|
8
|
+
if (typeof WeakMap !== "function") return null;
|
|
9
|
+
var cache = new WeakMap();
|
|
10
|
+
_getRequireWildcardCache = function() {
|
|
11
|
+
return cache;
|
|
12
|
+
};
|
|
13
|
+
return cache;
|
|
14
|
+
}
|
|
15
|
+
function _interopRequireWildcard(obj) {
|
|
16
|
+
if (obj && obj.__esModule) {
|
|
17
|
+
return obj;
|
|
18
|
+
}
|
|
19
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
20
|
+
return {
|
|
21
|
+
default: obj
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
var cache = _getRequireWildcardCache();
|
|
25
|
+
if (cache && cache.has(obj)) {
|
|
26
|
+
return cache.get(obj);
|
|
27
|
+
}
|
|
28
|
+
var newObj = {};
|
|
29
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
30
|
+
for(var key in obj){
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
32
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
33
|
+
if (desc && (desc.get || desc.set)) {
|
|
34
|
+
Object.defineProperty(newObj, key, desc);
|
|
35
|
+
} else {
|
|
36
|
+
newObj[key] = obj[key];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
newObj.default = obj;
|
|
41
|
+
if (cache) {
|
|
42
|
+
cache.set(obj, newObj);
|
|
43
|
+
}
|
|
44
|
+
return newObj;
|
|
45
|
+
}
|
|
46
|
+
function* splitAtTopLevelOnly(input, separator) {
|
|
47
|
+
let SPECIALS = new RegExp(`[(){}\\[\\]${regex.escape(separator)}]`, "g");
|
|
48
|
+
let depth = 0;
|
|
49
|
+
let lastIndex = 0;
|
|
50
|
+
let found = false;
|
|
51
|
+
let separatorIndex = 0;
|
|
52
|
+
let separatorStart = 0;
|
|
53
|
+
let separatorLength = separator.length;
|
|
54
|
+
// Find all paren-like things & character
|
|
55
|
+
// And only split on commas if they're top-level
|
|
56
|
+
for (let match of input.matchAll(SPECIALS)){
|
|
57
|
+
let matchesSeparator = match[0] === separator[separatorIndex];
|
|
58
|
+
let atEndOfSeparator = separatorIndex === separatorLength - 1;
|
|
59
|
+
let matchesFullSeparator = matchesSeparator && atEndOfSeparator;
|
|
60
|
+
if (match[0] === "(") depth++;
|
|
61
|
+
if (match[0] === ")") depth--;
|
|
62
|
+
if (match[0] === "[") depth++;
|
|
63
|
+
if (match[0] === "]") depth--;
|
|
64
|
+
if (match[0] === "{") depth++;
|
|
65
|
+
if (match[0] === "}") depth--;
|
|
66
|
+
if (matchesSeparator && depth === 0) {
|
|
67
|
+
if (separatorStart === 0) {
|
|
68
|
+
separatorStart = match.index;
|
|
69
|
+
}
|
|
70
|
+
separatorIndex++;
|
|
71
|
+
}
|
|
72
|
+
if (matchesFullSeparator && depth === 0) {
|
|
73
|
+
found = true;
|
|
74
|
+
yield input.substring(lastIndex, separatorStart);
|
|
75
|
+
lastIndex = separatorStart + separatorLength;
|
|
76
|
+
}
|
|
77
|
+
if (separatorIndex === separatorLength) {
|
|
78
|
+
separatorIndex = 0;
|
|
79
|
+
separatorStart = 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Provide the last segment of the string if available
|
|
83
|
+
// Otherwise the whole string since no `char`s were found
|
|
84
|
+
// This mirrors the behavior of string.split()
|
|
85
|
+
if (found) {
|
|
86
|
+
yield input.substring(lastIndex);
|
|
87
|
+
} else {
|
|
88
|
+
yield input;
|
|
89
|
+
}
|
|
90
|
+
}
|
package/lib/util/toColorValue.js
CHANGED
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.default = toColorValue;
|
|
6
6
|
function toColorValue(maybeFunction) {
|
|
7
|
-
return typeof maybeFunction ===
|
|
7
|
+
return typeof maybeFunction === "function" ? maybeFunction({}) : maybeFunction;
|
|
8
8
|
}
|
package/lib/util/toPath.js
CHANGED
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.toPath = toPath;
|
|
6
6
|
function toPath(path) {
|
|
7
7
|
if (Array.isArray(path)) return path;
|
|
8
|
-
let openBrackets = path.split(
|
|
9
|
-
let closedBrackets = path.split(
|
|
8
|
+
let openBrackets = path.split("[").length - 1;
|
|
9
|
+
let closedBrackets = path.split("]").length - 1;
|
|
10
10
|
if (openBrackets !== closedBrackets) {
|
|
11
11
|
throw new Error(`Path is invalid. Has unbalanced brackets: ${path}`);
|
|
12
12
|
}
|
|
@@ -4,56 +4,58 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.default = transformThemeValue;
|
|
6
6
|
var _postcss = _interopRequireDefault(require("postcss"));
|
|
7
|
-
function _interopRequireDefault(obj) {
|
|
8
|
-
return obj && obj.__esModule ? obj : {
|
|
9
|
-
default: obj
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
7
|
function transformThemeValue(themeSection) {
|
|
13
8
|
if ([
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
"fontSize",
|
|
10
|
+
"outline"
|
|
16
11
|
].includes(themeSection)) {
|
|
17
12
|
return (value)=>{
|
|
18
|
-
if (typeof value ===
|
|
13
|
+
if (typeof value === "function") value = value({});
|
|
19
14
|
if (Array.isArray(value)) value = value[0];
|
|
20
15
|
return value;
|
|
21
16
|
};
|
|
22
17
|
}
|
|
23
18
|
if ([
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
"fontFamily",
|
|
20
|
+
"boxShadow",
|
|
21
|
+
"transitionProperty",
|
|
22
|
+
"transitionDuration",
|
|
23
|
+
"transitionDelay",
|
|
24
|
+
"transitionTimingFunction",
|
|
25
|
+
"backgroundImage",
|
|
26
|
+
"backgroundSize",
|
|
27
|
+
"backgroundColor",
|
|
28
|
+
"cursor",
|
|
29
|
+
"animation",
|
|
35
30
|
].includes(themeSection)) {
|
|
36
31
|
return (value)=>{
|
|
37
|
-
if (typeof value ===
|
|
38
|
-
if (Array.isArray(value)) value = value.join(
|
|
32
|
+
if (typeof value === "function") value = value({});
|
|
33
|
+
if (Array.isArray(value)) value = value.join(", ");
|
|
39
34
|
return value;
|
|
40
35
|
};
|
|
41
36
|
}
|
|
42
37
|
// For backwards compatibility reasons, before we switched to underscores
|
|
43
38
|
// instead of commas for arbitrary values.
|
|
44
39
|
if ([
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
"gridTemplateColumns",
|
|
41
|
+
"gridTemplateRows",
|
|
42
|
+
"objectPosition"
|
|
48
43
|
].includes(themeSection)) {
|
|
49
44
|
return (value)=>{
|
|
50
|
-
if (typeof value ===
|
|
51
|
-
if (typeof value ===
|
|
45
|
+
if (typeof value === "function") value = value({});
|
|
46
|
+
if (typeof value === "string") value = _postcss.default.list.comma(value).join(" ");
|
|
52
47
|
return value;
|
|
53
48
|
};
|
|
54
49
|
}
|
|
55
|
-
return (value)=>{
|
|
56
|
-
if (typeof value ===
|
|
50
|
+
return (value, opts = {})=>{
|
|
51
|
+
if (typeof value === "function") {
|
|
52
|
+
value = value(opts);
|
|
53
|
+
}
|
|
57
54
|
return value;
|
|
58
55
|
};
|
|
59
56
|
}
|
|
57
|
+
function _interopRequireDefault(obj) {
|
|
58
|
+
return obj && obj.__esModule ? obj : {
|
|
59
|
+
default: obj
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.validateConfig = validateConfig;
|
|
6
|
+
var _log = _interopRequireDefault(require("./log"));
|
|
7
|
+
function _interopRequireDefault(obj) {
|
|
8
|
+
return obj && obj.__esModule ? obj : {
|
|
9
|
+
default: obj
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function validateConfig(config) {
|
|
13
|
+
if (config.content.files.length === 0) {
|
|
14
|
+
_log.default.warn("content-problems", [
|
|
15
|
+
"The `content` option in your Tailwind CSS configuration is missing or empty.",
|
|
16
|
+
"Configure your content sources or your generated CSS will be missing styles.",
|
|
17
|
+
"https://tailwindcss.com/docs/content-configuration",
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
return config;
|
|
21
|
+
}
|
|
@@ -2,29 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.withAlphaValue = withAlphaValue;
|
|
6
5
|
exports.default = withAlphaVariable;
|
|
6
|
+
exports.withAlphaValue = withAlphaValue;
|
|
7
7
|
var _color = require("./color");
|
|
8
|
-
function withAlphaValue(color, alphaValue, defaultValue) {
|
|
9
|
-
if (typeof color === 'function') {
|
|
10
|
-
return color({
|
|
11
|
-
opacityValue: alphaValue
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
let parsed = (0, _color).parseColor(color);
|
|
15
|
-
if (parsed === null) {
|
|
16
|
-
return defaultValue;
|
|
17
|
-
}
|
|
18
|
-
return (0, _color).formatColor({
|
|
19
|
-
...parsed,
|
|
20
|
-
alpha: alphaValue
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
8
|
function withAlphaVariable({ color , property , variable }) {
|
|
24
9
|
let properties = [].concat(property);
|
|
25
|
-
if (typeof color ===
|
|
10
|
+
if (typeof color === "function") {
|
|
26
11
|
return {
|
|
27
|
-
[variable]:
|
|
12
|
+
[variable]: "1",
|
|
28
13
|
...Object.fromEntries(properties.map((p)=>{
|
|
29
14
|
return [
|
|
30
15
|
p,
|
|
@@ -41,19 +26,17 @@ function withAlphaVariable({ color , property , variable }) {
|
|
|
41
26
|
return Object.fromEntries(properties.map((p)=>[
|
|
42
27
|
p,
|
|
43
28
|
color
|
|
44
|
-
]
|
|
45
|
-
));
|
|
29
|
+
]));
|
|
46
30
|
}
|
|
47
31
|
if (parsed.alpha !== undefined) {
|
|
48
32
|
// Has an alpha value, return color as-is
|
|
49
33
|
return Object.fromEntries(properties.map((p)=>[
|
|
50
34
|
p,
|
|
51
35
|
color
|
|
52
|
-
]
|
|
53
|
-
));
|
|
36
|
+
]));
|
|
54
37
|
}
|
|
55
38
|
return {
|
|
56
|
-
[variable]:
|
|
39
|
+
[variable]: "1",
|
|
57
40
|
...Object.fromEntries(properties.map((p)=>{
|
|
58
41
|
return [
|
|
59
42
|
p,
|
|
@@ -65,3 +48,20 @@ function withAlphaVariable({ color , property , variable }) {
|
|
|
65
48
|
}))
|
|
66
49
|
};
|
|
67
50
|
}
|
|
51
|
+
function withAlphaValue(color, alphaValue, defaultValue) {
|
|
52
|
+
if (typeof color === "function") {
|
|
53
|
+
return color({
|
|
54
|
+
opacityValue: alphaValue
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
let parsed = (0, _color).parseColor(color, {
|
|
58
|
+
loose: true
|
|
59
|
+
});
|
|
60
|
+
if (parsed === null) {
|
|
61
|
+
return defaultValue;
|
|
62
|
+
}
|
|
63
|
+
return (0, _color).formatColor({
|
|
64
|
+
...parsed,
|
|
65
|
+
alpha: alphaValue
|
|
66
|
+
});
|
|
67
|
+
}
|