tailwindcss 3.0.0-alpha.1 → 3.0.2
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/colors.js +2 -1
- package/defaultConfig.js +2 -1
- package/defaultTheme.js +2 -1
- package/lib/cli.js +39 -35
- package/lib/constants.js +1 -1
- package/lib/corePluginList.js +10 -1
- package/lib/corePlugins.js +393 -259
- package/lib/css/preflight.css +14 -1
- package/lib/featureFlags.js +12 -7
- package/lib/lib/collapseDuplicateDeclarations.js +29 -0
- package/lib/lib/detectNesting.js +17 -2
- package/lib/lib/evaluateTailwindFunctions.js +9 -5
- package/lib/lib/expandApplyAtRules.js +26 -9
- package/lib/lib/expandTailwindAtRules.js +4 -1
- package/lib/lib/generateRules.js +151 -19
- package/lib/lib/resolveDefaultsAtRules.js +67 -56
- package/lib/lib/setupContextUtils.js +80 -80
- package/lib/lib/setupWatchingContext.js +5 -1
- package/lib/lib/sharedState.js +2 -2
- package/lib/lib/substituteScreenAtRules.js +7 -4
- package/lib/processTailwindFeatures.js +4 -0
- package/lib/util/buildMediaQuery.js +13 -24
- package/lib/util/createUtilityPlugin.js +5 -5
- package/lib/util/dataTypes.js +38 -7
- package/lib/util/formatVariantSelector.js +186 -0
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/nameClass.js +2 -1
- package/lib/util/negateValue.js +3 -1
- package/lib/util/normalizeConfig.js +22 -8
- package/lib/util/normalizeScreens.js +61 -0
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/pluginUtils.js +62 -158
- package/lib/util/prefixSelector.js +1 -3
- package/lib/util/resolveConfig.js +17 -13
- package/lib/util/transformThemeValue.js +23 -13
- package/package.json +15 -15
- package/peers/index.js +4456 -5450
- package/plugin.js +2 -1
- package/resolveConfig.js +2 -1
- package/src/.DS_Store +0 -0
- package/src/cli.js +9 -2
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +392 -404
- package/src/css/preflight.css +14 -1
- package/src/featureFlags.js +14 -4
- package/src/lib/collapseDuplicateDeclarations.js +28 -0
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +5 -2
- package/src/lib/expandApplyAtRules.js +29 -2
- package/src/lib/expandTailwindAtRules.js +5 -2
- package/src/lib/generateRules.js +155 -11
- package/src/lib/resolveDefaultsAtRules.js +67 -50
- package/src/lib/setupContextUtils.js +77 -67
- package/src/lib/setupWatchingContext.js +7 -0
- package/src/lib/sharedState.js +1 -1
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/processTailwindFeatures.js +5 -0
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/createUtilityPlugin.js +2 -2
- package/src/util/dataTypes.js +43 -11
- package/src/util/formatVariantSelector.js +196 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/nameClass.js +2 -2
- package/src/util/negateValue.js +4 -2
- package/src/util/normalizeConfig.js +17 -1
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/pluginUtils.js +50 -146
- package/src/util/prefixSelector.js +1 -4
- package/src/util/resolveConfig.js +7 -1
- package/src/util/transformThemeValue.js +22 -7
- package/stubs/defaultConfig.stub.js +118 -58
- package/CHANGELOG.md +0 -1759
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = resolveDefaultsAtRules;
|
|
6
|
+
exports.elementSelectorParser = void 0;
|
|
6
7
|
var _postcss = _interopRequireDefault(require("postcss"));
|
|
7
8
|
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
|
|
8
9
|
var _featureFlags = require("../featureFlags");
|
|
@@ -11,58 +12,53 @@ function _interopRequireDefault(obj) {
|
|
|
11
12
|
default: obj
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return
|
|
15
|
+
let getNode = {
|
|
16
|
+
id (node) {
|
|
17
|
+
return _postcssSelectorParser.default.attribute({
|
|
18
|
+
attribute: 'id',
|
|
19
|
+
operator: '=',
|
|
20
|
+
value: node.value,
|
|
21
|
+
quoteMark: '"'
|
|
22
|
+
});
|
|
17
23
|
}
|
|
18
|
-
|
|
19
|
-
':before',
|
|
20
|
-
':after',
|
|
21
|
-
':first-line',
|
|
22
|
-
':first-letter'
|
|
23
|
-
].includes(n.value);
|
|
24
|
-
}
|
|
24
|
+
};
|
|
25
25
|
function minimumImpactSelector(nodes) {
|
|
26
|
-
let rest = nodes
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
if (match) {
|
|
59
|
-
bestNode = getNode(match);
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
26
|
+
let rest = nodes.filter((node)=>{
|
|
27
|
+
// Keep non-pseudo nodes
|
|
28
|
+
if (node.type !== 'pseudo') return true;
|
|
29
|
+
// Keep pseudo nodes that have subnodes
|
|
30
|
+
// E.g.: `:not()` contains subnodes inside the parentheses
|
|
31
|
+
if (node.nodes.length > 0) return true;
|
|
32
|
+
// Keep pseudo `elements`
|
|
33
|
+
// This implicitly means that we ignore pseudo `classes`
|
|
34
|
+
return node.value.startsWith('::') || [
|
|
35
|
+
':before',
|
|
36
|
+
':after',
|
|
37
|
+
':first-line',
|
|
38
|
+
':first-letter'
|
|
39
|
+
].includes(node.value);
|
|
40
|
+
}).reverse();
|
|
41
|
+
let searchFor = new Set([
|
|
42
|
+
'tag',
|
|
43
|
+
'class',
|
|
44
|
+
'id',
|
|
45
|
+
'attribute'
|
|
46
|
+
]);
|
|
47
|
+
let splitPointIdx = rest.findIndex((n)=>searchFor.has(n.type)
|
|
48
|
+
);
|
|
49
|
+
if (splitPointIdx === -1) return rest.reverse().join('').trim();
|
|
50
|
+
let node1 = rest[splitPointIdx];
|
|
51
|
+
let bestNode = getNode[node1.type] ? getNode[node1.type](node1) : node1;
|
|
52
|
+
rest = rest.slice(0, splitPointIdx);
|
|
53
|
+
let combinatorIdx = rest.findIndex((n)=>n.type === 'combinator' && n.value === '>'
|
|
54
|
+
);
|
|
55
|
+
if (combinatorIdx !== -1) {
|
|
56
|
+
rest.splice(0, combinatorIdx);
|
|
57
|
+
rest.unshift(_postcssSelectorParser.default.universal());
|
|
62
58
|
}
|
|
63
59
|
return [
|
|
64
60
|
bestNode,
|
|
65
|
-
...rest
|
|
61
|
+
...rest.reverse()
|
|
66
62
|
].join('').trim();
|
|
67
63
|
}
|
|
68
64
|
let elementSelectorParser = (0, _postcssSelectorParser).default((selectors)=>{
|
|
@@ -72,6 +68,7 @@ let elementSelectorParser = (0, _postcssSelectorParser).default((selectors)=>{
|
|
|
72
68
|
return minimumImpactSelector(nodes);
|
|
73
69
|
});
|
|
74
70
|
});
|
|
71
|
+
exports.elementSelectorParser = elementSelectorParser;
|
|
75
72
|
let cache = new Map();
|
|
76
73
|
function extractElementSelector(selector) {
|
|
77
74
|
if (!cache.has(selector)) {
|
|
@@ -82,7 +79,7 @@ function extractElementSelector(selector) {
|
|
|
82
79
|
function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
83
80
|
return (root)=>{
|
|
84
81
|
let variableNodeMap = new Map();
|
|
85
|
-
let universals = new Set();
|
|
82
|
+
/** @type {Set<import('postcss').AtRule>} */ let universals = new Set();
|
|
86
83
|
root.walkAtRules('defaults', (rule)=>{
|
|
87
84
|
if (rule.nodes && rule.nodes.length > 0) {
|
|
88
85
|
universals.add(rule);
|
|
@@ -96,32 +93,46 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
96
93
|
rule.remove();
|
|
97
94
|
});
|
|
98
95
|
for (let universal of universals){
|
|
99
|
-
let
|
|
96
|
+
/** @type {Map<string, Set<string>>} */ let selectorGroups = new Map();
|
|
100
97
|
var ref;
|
|
101
98
|
let rules = (ref = variableNodeMap.get(universal.params)) !== null && ref !== void 0 ? ref : [];
|
|
102
99
|
for (let rule of rules){
|
|
103
100
|
for (let selector of extractElementSelector(rule.selector)){
|
|
101
|
+
// If selector contains a vendor prefix after a pseudo element or class,
|
|
102
|
+
// we consider them separately because merging the declarations into
|
|
103
|
+
// a single rule will cause browsers that do not understand the
|
|
104
|
+
// vendor prefix to throw out the whole rule
|
|
105
|
+
let selectorGroupName = selector.includes(':-') || selector.includes('::-') ? selector : '__DEFAULT__';
|
|
106
|
+
var ref1;
|
|
107
|
+
let selectors = (ref1 = selectorGroups.get(selectorGroupName)) !== null && ref1 !== void 0 ? ref1 : new Set();
|
|
108
|
+
selectorGroups.set(selectorGroupName, selectors);
|
|
104
109
|
selectors.add(selector);
|
|
105
110
|
}
|
|
106
111
|
}
|
|
107
|
-
if (
|
|
112
|
+
if (selectorGroups.size === 0) {
|
|
108
113
|
universal.remove();
|
|
109
114
|
continue;
|
|
110
115
|
}
|
|
111
|
-
let universalRule = _postcss.default.rule();
|
|
112
116
|
if ((0, _featureFlags).flagEnabled(tailwindConfig, 'optimizeUniversalDefaults')) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
for (let [, selectors] of selectorGroups){
|
|
118
|
+
let universalRule = _postcss.default.rule();
|
|
119
|
+
universalRule.selectors = [
|
|
120
|
+
...selectors
|
|
121
|
+
];
|
|
122
|
+
universalRule.append(universal.nodes.map((node)=>node.clone()
|
|
123
|
+
));
|
|
124
|
+
universal.before(universalRule);
|
|
125
|
+
}
|
|
116
126
|
} else {
|
|
127
|
+
let universalRule = _postcss.default.rule();
|
|
117
128
|
universalRule.selectors = [
|
|
118
129
|
'*',
|
|
119
130
|
'::before',
|
|
120
131
|
'::after'
|
|
121
132
|
];
|
|
133
|
+
universalRule.append(universal.nodes);
|
|
134
|
+
universal.before(universalRule);
|
|
122
135
|
}
|
|
123
|
-
universalRule.append(universal.nodes);
|
|
124
|
-
universal.before(universalRule);
|
|
125
136
|
universal.remove();
|
|
126
137
|
}
|
|
127
138
|
};
|
|
@@ -22,6 +22,8 @@ var _corePlugins = require("../corePlugins");
|
|
|
22
22
|
var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
23
23
|
var _toPath = require("../util/toPath");
|
|
24
24
|
var _log = _interopRequireDefault(require("../util/log"));
|
|
25
|
+
var _negateValue = _interopRequireDefault(require("../util/negateValue"));
|
|
26
|
+
var _isValidArbitraryValue = _interopRequireDefault(require("../util/isValidArbitraryValue"));
|
|
25
27
|
function _interopRequireDefault(obj) {
|
|
26
28
|
return obj && obj.__esModule ? obj : {
|
|
27
29
|
default: obj
|
|
@@ -50,6 +52,30 @@ function _interopRequireWildcard(obj) {
|
|
|
50
52
|
return newObj;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
55
|
+
function parseVariantFormatString(input) {
|
|
56
|
+
if (input.includes('{')) {
|
|
57
|
+
if (!isBalanced(input)) throw new Error(`Your { and } are unbalanced.`);
|
|
58
|
+
return input.split(/{(.*)}/gim).flatMap((line)=>parseVariantFormatString(line)
|
|
59
|
+
).filter(Boolean);
|
|
60
|
+
}
|
|
61
|
+
return [
|
|
62
|
+
input.trim()
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
function isBalanced(input) {
|
|
66
|
+
let count = 0;
|
|
67
|
+
for (let char of input){
|
|
68
|
+
if (char === '{') {
|
|
69
|
+
count++;
|
|
70
|
+
} else if (char === '}') {
|
|
71
|
+
if (--count < 0) {
|
|
72
|
+
return false // unbalanced
|
|
73
|
+
;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return count === 0;
|
|
78
|
+
}
|
|
53
79
|
function insertInto(list, value, { before =[] } = {
|
|
54
80
|
}) {
|
|
55
81
|
before = [].concat(before);
|
|
@@ -135,68 +161,6 @@ function withIdentifiers(styles) {
|
|
|
135
161
|
});
|
|
136
162
|
});
|
|
137
163
|
}
|
|
138
|
-
let matchingBrackets = new Map([
|
|
139
|
-
[
|
|
140
|
-
'{',
|
|
141
|
-
'}'
|
|
142
|
-
],
|
|
143
|
-
[
|
|
144
|
-
'[',
|
|
145
|
-
']'
|
|
146
|
-
],
|
|
147
|
-
[
|
|
148
|
-
'(',
|
|
149
|
-
')'
|
|
150
|
-
],
|
|
151
|
-
]);
|
|
152
|
-
let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
|
|
153
|
-
v,
|
|
154
|
-
k
|
|
155
|
-
]
|
|
156
|
-
));
|
|
157
|
-
let quotes = new Set([
|
|
158
|
-
'"',
|
|
159
|
-
"'",
|
|
160
|
-
'`'
|
|
161
|
-
]);
|
|
162
|
-
// Arbitrary values must contain balanced brackets (), [] and {}. Escaped
|
|
163
|
-
// values don't count, and brackets inside quotes also don't count.
|
|
164
|
-
//
|
|
165
|
-
// E.g.: w-[this-is]w-[weird-and-invalid]
|
|
166
|
-
// E.g.: w-[this-is\\]w-\\[weird-but-valid]
|
|
167
|
-
// E.g.: content-['this-is-also-valid]-weirdly-enough']
|
|
168
|
-
function isValidArbitraryValue(value) {
|
|
169
|
-
let stack = [];
|
|
170
|
-
let inQuotes = false;
|
|
171
|
-
for(let i = 0; i < value.length; i++){
|
|
172
|
-
let char = value[i];
|
|
173
|
-
// Non-escaped quotes allow us to "allow" anything in between
|
|
174
|
-
if (quotes.has(char) && value[i - 1] !== '\\') {
|
|
175
|
-
inQuotes = !inQuotes;
|
|
176
|
-
}
|
|
177
|
-
if (inQuotes) continue;
|
|
178
|
-
if (value[i - 1] === '\\') continue; // Escaped
|
|
179
|
-
if (matchingBrackets.has(char)) {
|
|
180
|
-
stack.push(char);
|
|
181
|
-
} else if (inverseMatchingBrackets.has(char)) {
|
|
182
|
-
let inverse = inverseMatchingBrackets.get(char);
|
|
183
|
-
// Nothing to pop from, therefore it is unbalanced
|
|
184
|
-
if (stack.length <= 0) {
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
// Popped value must match the inverse value, otherwise it is unbalanced
|
|
188
|
-
if (stack.pop() !== inverse) {
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
// If there is still something on the stack, it is also unbalanced
|
|
194
|
-
if (stack.length > 0) {
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
// All good, totally balanced!
|
|
198
|
-
return true;
|
|
199
|
-
}
|
|
200
164
|
function buildPluginApi(tailwindConfig, context, { variantList , variantMap , offsets , classList }) {
|
|
201
165
|
function getConfigValue(path, defaultValue) {
|
|
202
166
|
return path ? (0, _dlv).default(tailwindConfig, path, defaultValue) : tailwindConfig;
|
|
@@ -211,15 +175,41 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
211
175
|
if (!options.respectPrefix) {
|
|
212
176
|
return identifier;
|
|
213
177
|
}
|
|
214
|
-
if (typeof context.tailwindConfig.prefix === 'function') {
|
|
215
|
-
return (0, _prefixSelector).default(context.tailwindConfig.prefix, `.${identifier}`).substr(1);
|
|
216
|
-
}
|
|
217
178
|
return context.tailwindConfig.prefix + identifier;
|
|
218
179
|
}
|
|
219
180
|
return {
|
|
220
181
|
addVariant (variantName, variantFunctions, options = {
|
|
221
182
|
}) {
|
|
222
|
-
variantFunctions = [].concat(variantFunctions)
|
|
183
|
+
variantFunctions = [].concat(variantFunctions).map((variantFunction)=>{
|
|
184
|
+
if (typeof variantFunction !== 'string') {
|
|
185
|
+
// Safelist public API functions
|
|
186
|
+
return ({ modifySelectors , container , separator })=>{
|
|
187
|
+
return variantFunction({
|
|
188
|
+
modifySelectors,
|
|
189
|
+
container,
|
|
190
|
+
separator
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
variantFunction = variantFunction.replace(/\n+/g, '').replace(/\s{1,}/g, ' ').trim();
|
|
195
|
+
let fns = parseVariantFormatString(variantFunction).map((str)=>{
|
|
196
|
+
if (!str.startsWith('@')) {
|
|
197
|
+
return ({ format })=>format(str)
|
|
198
|
+
;
|
|
199
|
+
}
|
|
200
|
+
let [, name, params] = /@(.*?) (.*)/g.exec(str);
|
|
201
|
+
return ({ wrap })=>wrap(_postcss.default.atRule({
|
|
202
|
+
name,
|
|
203
|
+
params
|
|
204
|
+
}))
|
|
205
|
+
;
|
|
206
|
+
}).reverse();
|
|
207
|
+
return (api)=>{
|
|
208
|
+
for (let fn of fns){
|
|
209
|
+
fn(api);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
});
|
|
223
213
|
insertInto(variantList, variantName, options);
|
|
224
214
|
variantMap.set(variantName, variantFunctions);
|
|
225
215
|
},
|
|
@@ -351,14 +341,14 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
351
341
|
function wrapped(modifier, { isOnlyPlugin }) {
|
|
352
342
|
let { type ='any' } = options;
|
|
353
343
|
type = [].concat(type);
|
|
354
|
-
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options
|
|
344
|
+
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options, tailwindConfig);
|
|
355
345
|
if (value === undefined) {
|
|
356
346
|
return [];
|
|
357
347
|
}
|
|
358
348
|
if (!type.includes(coercedType) && !isOnlyPlugin) {
|
|
359
349
|
return [];
|
|
360
350
|
}
|
|
361
|
-
if (!
|
|
351
|
+
if (!(0, _isValidArbitraryValue).default(value)) {
|
|
362
352
|
return [];
|
|
363
353
|
}
|
|
364
354
|
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
@@ -401,7 +391,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
401
391
|
function wrapped(modifier, { isOnlyPlugin }) {
|
|
402
392
|
let { type ='any' } = options;
|
|
403
393
|
type = [].concat(type);
|
|
404
|
-
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options
|
|
394
|
+
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options, tailwindConfig);
|
|
405
395
|
if (value === undefined) {
|
|
406
396
|
return [];
|
|
407
397
|
}
|
|
@@ -415,7 +405,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
415
405
|
return [];
|
|
416
406
|
}
|
|
417
407
|
}
|
|
418
|
-
if (!
|
|
408
|
+
if (!(0, _isValidArbitraryValue).default(value)) {
|
|
419
409
|
return [];
|
|
420
410
|
}
|
|
421
411
|
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
@@ -556,7 +546,9 @@ function resolvePlugins(context, root) {
|
|
|
556
546
|
_corePlugins.variantPlugins['directionVariants'],
|
|
557
547
|
_corePlugins.variantPlugins['reducedMotionVariants'],
|
|
558
548
|
_corePlugins.variantPlugins['darkVariants'],
|
|
559
|
-
_corePlugins.variantPlugins['
|
|
549
|
+
_corePlugins.variantPlugins['printVariant'],
|
|
550
|
+
_corePlugins.variantPlugins['screenVariants'],
|
|
551
|
+
_corePlugins.variantPlugins['orientationVariants'],
|
|
560
552
|
];
|
|
561
553
|
return [
|
|
562
554
|
...corePluginList,
|
|
@@ -600,6 +592,9 @@ function registerPlugins(plugins, context) {
|
|
|
600
592
|
offsets.user,
|
|
601
593
|
]);
|
|
602
594
|
let reservedBits = BigInt(highestOffset.toString(2).length);
|
|
595
|
+
// A number one less than the top range of the highest offset area
|
|
596
|
+
// so arbitrary properties are always sorted at the end.
|
|
597
|
+
context.arbitraryPropertiesSort = (1n << reservedBits << 0n) - 1n;
|
|
603
598
|
context.layerOrder = {
|
|
604
599
|
base: 1n << reservedBits << 0n,
|
|
605
600
|
components: 1n << reservedBits << 1n,
|
|
@@ -622,9 +617,9 @@ function registerPlugins(plugins, context) {
|
|
|
622
617
|
...context.variantOrder.values()
|
|
623
618
|
].shift();
|
|
624
619
|
// Build variantMap
|
|
625
|
-
for (let [variantName,
|
|
620
|
+
for (let [variantName, variantFunctions1] of variantMap.entries()){
|
|
626
621
|
let sort = context.variantOrder.get(variantName);
|
|
627
|
-
context.variantMap.set(variantName,
|
|
622
|
+
context.variantMap.set(variantName, variantFunctions1.map((variantFunction, idx)=>[
|
|
628
623
|
sort << BigInt(idx),
|
|
629
624
|
variantFunction
|
|
630
625
|
]
|
|
@@ -634,22 +629,22 @@ function registerPlugins(plugins, context) {
|
|
|
634
629
|
let safelist = ((_safelist = context.tailwindConfig.safelist) !== null && _safelist !== void 0 ? _safelist : []).filter(Boolean);
|
|
635
630
|
if (safelist.length > 0) {
|
|
636
631
|
let checks = [];
|
|
637
|
-
for (let
|
|
638
|
-
if (typeof
|
|
632
|
+
for (let value1 of safelist){
|
|
633
|
+
if (typeof value1 === 'string') {
|
|
639
634
|
context.changedContent.push({
|
|
640
|
-
content:
|
|
635
|
+
content: value1,
|
|
641
636
|
extension: 'html'
|
|
642
637
|
});
|
|
643
638
|
continue;
|
|
644
639
|
}
|
|
645
|
-
if (
|
|
640
|
+
if (value1 instanceof RegExp) {
|
|
646
641
|
_log.default.warn('root-regex', [
|
|
647
642
|
'Regular expressions in `safelist` work differently in Tailwind CSS v3.0.',
|
|
648
643
|
'Update your `safelist` configuration to eliminate this warning.'
|
|
649
644
|
]);
|
|
650
645
|
continue;
|
|
651
646
|
}
|
|
652
|
-
checks.push(
|
|
647
|
+
checks.push(value1);
|
|
653
648
|
}
|
|
654
649
|
if (checks.length > 0) {
|
|
655
650
|
let patternMatchingCount = new Map();
|
|
@@ -702,11 +697,16 @@ function registerPlugins(plugins, context) {
|
|
|
702
697
|
for (let util of classList){
|
|
703
698
|
if (Array.isArray(util)) {
|
|
704
699
|
let [utilName, options] = util;
|
|
700
|
+
let negativeClasses = [];
|
|
705
701
|
var ref;
|
|
706
|
-
for (let value of Object.
|
|
702
|
+
for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
|
|
707
703
|
})){
|
|
708
|
-
output.push((0, _nameClass).formatClass(utilName,
|
|
704
|
+
output.push((0, _nameClass).formatClass(utilName, key));
|
|
705
|
+
if ((options === null || options === void 0 ? void 0 : options.supportsNegativeValues) && (0, _negateValue).default(value)) {
|
|
706
|
+
negativeClasses.push((0, _nameClass).formatClass(utilName, `-${key}`));
|
|
707
|
+
}
|
|
709
708
|
}
|
|
709
|
+
output.push(...negativeClasses);
|
|
710
710
|
} else {
|
|
711
711
|
output.push(util);
|
|
712
712
|
}
|
|
@@ -75,7 +75,11 @@ function rebootWatcher(context, configPath, configDependencies, candidateFiles)
|
|
|
75
75
|
...candidateFiles,
|
|
76
76
|
...configDependencies
|
|
77
77
|
], {
|
|
78
|
-
ignoreInitial: true
|
|
78
|
+
ignoreInitial: true,
|
|
79
|
+
awaitWriteFinish: process.platform === 'win32' ? {
|
|
80
|
+
stabilityThreshold: 50,
|
|
81
|
+
pollInterval: 10
|
|
82
|
+
} : false
|
|
79
83
|
});
|
|
80
84
|
setWatcher(context, watcher);
|
|
81
85
|
watcher.on('add', (file)=>{
|
package/lib/lib/sharedState.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.contextSourcesMap = exports.configContextMap = exports.
|
|
5
|
+
exports.contextSourcesMap = exports.configContextMap = exports.contextMap = exports.env = void 0;
|
|
6
6
|
const env = {
|
|
7
7
|
TAILWIND_MODE: process.env.TAILWIND_MODE,
|
|
8
8
|
NODE_ENV: process.env.NODE_ENV,
|
|
9
|
-
DEBUG: process.env.DEBUG !== undefined,
|
|
9
|
+
DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== '0',
|
|
10
10
|
TAILWIND_DISABLE_TOUCH: process.env.TAILWIND_DISABLE_TOUCH !== undefined,
|
|
11
11
|
TAILWIND_TOUCH_DIR: process.env.TAILWIND_TOUCH_DIR
|
|
12
12
|
};
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = _default;
|
|
6
|
+
var _normalizeScreens = require("../util/normalizeScreens");
|
|
6
7
|
var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
7
8
|
function _interopRequireDefault(obj) {
|
|
8
9
|
return obj && obj.__esModule ? obj : {
|
|
@@ -12,13 +13,15 @@ function _interopRequireDefault(obj) {
|
|
|
12
13
|
function _default({ tailwindConfig: { theme } }) {
|
|
13
14
|
return function(css) {
|
|
14
15
|
css.walkAtRules('screen', (atRule)=>{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
let screen = atRule.params;
|
|
17
|
+
let screens = (0, _normalizeScreens).normalizeScreens(theme.screens);
|
|
18
|
+
let screenDefinition = screens.find(({ name })=>name === screen
|
|
19
|
+
);
|
|
20
|
+
if (!screenDefinition) {
|
|
18
21
|
throw atRule.error(`No \`${screen}\` screen found.`);
|
|
19
22
|
}
|
|
20
23
|
atRule.name = 'media';
|
|
21
|
-
atRule.params = (0, _buildMediaQuery).default(
|
|
24
|
+
atRule.params = (0, _buildMediaQuery).default(screenDefinition);
|
|
22
25
|
});
|
|
23
26
|
};
|
|
24
27
|
}
|
|
@@ -10,8 +10,10 @@ var _evaluateTailwindFunctions = _interopRequireDefault(require("./lib/evaluateT
|
|
|
10
10
|
var _substituteScreenAtRules = _interopRequireDefault(require("./lib/substituteScreenAtRules"));
|
|
11
11
|
var _resolveDefaultsAtRules = _interopRequireDefault(require("./lib/resolveDefaultsAtRules"));
|
|
12
12
|
var _collapseAdjacentRules = _interopRequireDefault(require("./lib/collapseAdjacentRules"));
|
|
13
|
+
var _collapseDuplicateDeclarations = _interopRequireDefault(require("./lib/collapseDuplicateDeclarations"));
|
|
13
14
|
var _detectNesting = _interopRequireDefault(require("./lib/detectNesting"));
|
|
14
15
|
var _setupContextUtils = require("./lib/setupContextUtils");
|
|
16
|
+
var _featureFlags = require("./featureFlags");
|
|
15
17
|
function _interopRequireDefault(obj) {
|
|
16
18
|
return obj && obj.__esModule ? obj : {
|
|
17
19
|
default: obj
|
|
@@ -36,6 +38,7 @@ function processTailwindFeatures(setupContext) {
|
|
|
36
38
|
if (context.tailwindConfig.separator === '-') {
|
|
37
39
|
throw new Error("The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead.");
|
|
38
40
|
}
|
|
41
|
+
(0, _featureFlags).issueFlagNotices(context.tailwindConfig);
|
|
39
42
|
(0, _detectNesting).default(context)(root, result);
|
|
40
43
|
(0, _expandTailwindAtRules).default(context)(root, result);
|
|
41
44
|
(0, _expandApplyAtRules).default(context)(root, result);
|
|
@@ -43,5 +46,6 @@ function processTailwindFeatures(setupContext) {
|
|
|
43
46
|
(0, _substituteScreenAtRules).default(context)(root, result);
|
|
44
47
|
(0, _resolveDefaultsAtRules).default(context)(root, result);
|
|
45
48
|
(0, _collapseAdjacentRules).default(context)(root, result);
|
|
49
|
+
(0, _collapseDuplicateDeclarations).default(context)(root, result);
|
|
46
50
|
};
|
|
47
51
|
}
|
|
@@ -4,28 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.default = buildMediaQuery;
|
|
6
6
|
function buildMediaQuery(screens) {
|
|
7
|
-
|
|
8
|
-
screens
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return screen.raw;
|
|
21
|
-
}
|
|
22
|
-
return Object.entries(screen).map(([feature, value])=>{
|
|
23
|
-
var _feature;
|
|
24
|
-
feature = (_feature = ({
|
|
25
|
-
min: 'min-width',
|
|
26
|
-
max: 'max-width'
|
|
27
|
-
})[feature]) !== null && _feature !== void 0 ? _feature : feature;
|
|
28
|
-
return `(${feature}: ${value})`;
|
|
29
|
-
}).join(' and ');
|
|
30
|
-
}).join(', ');
|
|
7
|
+
screens = Array.isArray(screens) ? screens : [
|
|
8
|
+
screens
|
|
9
|
+
];
|
|
10
|
+
return screens.map((screen1)=>screen1.values.map((screen)=>{
|
|
11
|
+
if (screen.raw !== undefined) {
|
|
12
|
+
return screen.raw;
|
|
13
|
+
}
|
|
14
|
+
return [
|
|
15
|
+
screen.min && `(min-width: ${screen.min})`,
|
|
16
|
+
screen.max && `(max-width: ${screen.max})`,
|
|
17
|
+
].filter(Boolean).join(' and ');
|
|
18
|
+
})
|
|
19
|
+
).join(', ');
|
|
31
20
|
}
|
|
@@ -16,7 +16,7 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
16
16
|
themeKey
|
|
17
17
|
]
|
|
18
18
|
]
|
|
19
|
-
], { filterDefault =false ,
|
|
19
|
+
], { filterDefault =false , ...options } = {
|
|
20
20
|
}) {
|
|
21
21
|
let transformValue = (0, _transformThemeValue).default(themeKey);
|
|
22
22
|
return function({ matchUtilities , theme }) {
|
|
@@ -25,8 +25,8 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
25
25
|
utilityVariation
|
|
26
26
|
];
|
|
27
27
|
var ref;
|
|
28
|
-
matchUtilities(group.reduce((
|
|
29
|
-
return Object.assign(
|
|
28
|
+
matchUtilities(group.reduce((obj1, [classPrefix, properties])=>{
|
|
29
|
+
return Object.assign(obj1, {
|
|
30
30
|
[classPrefix]: (value)=>{
|
|
31
31
|
return properties.reduce((obj, name)=>{
|
|
32
32
|
if (Array.isArray(name)) {
|
|
@@ -43,10 +43,10 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
43
43
|
});
|
|
44
44
|
}, {
|
|
45
45
|
}), {
|
|
46
|
+
...options,
|
|
46
47
|
values: filterDefault ? Object.fromEntries(Object.entries((ref = theme(themeKey)) !== null && ref !== void 0 ? ref : {
|
|
47
48
|
}).filter(([modifier])=>modifier !== 'DEFAULT'
|
|
48
|
-
)) : theme(themeKey)
|
|
49
|
-
type
|
|
49
|
+
)) : theme(themeKey)
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
};
|