tailwindcss 0.0.0-insiders.f9fb2ce → 0.0.0-insiders.fb545bc
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 +84 -3
- package/colors.js +2 -1
- package/defaultConfig.js +2 -1
- package/defaultTheme.js +2 -1
- package/lib/cli.js +32 -32
- package/lib/constants.js +1 -1
- package/lib/corePluginList.js +4 -0
- package/lib/corePlugins.js +257 -172
- package/lib/css/preflight.css +4 -3
- package/lib/featureFlags.js +6 -4
- package/lib/lib/collapseDuplicateDeclarations.js +2 -2
- 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 +27 -1
- package/lib/lib/generateRules.js +64 -10
- package/lib/lib/resolveDefaultsAtRules.js +25 -11
- package/lib/lib/setupContextUtils.js +55 -78
- package/lib/lib/sharedState.js +1 -1
- package/lib/lib/substituteScreenAtRules.js +7 -4
- package/lib/util/buildMediaQuery.js +13 -24
- package/lib/util/createUtilityPlugin.js +2 -2
- package/lib/util/dataTypes.js +25 -3
- package/lib/util/defaults.js +6 -0
- package/lib/util/formatVariantSelector.js +93 -9
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +4 -0
- package/lib/util/nameClass.js +1 -0
- package/lib/util/normalizeConfig.js +41 -12
- package/lib/util/normalizeScreens.js +61 -0
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/pluginUtils.js +12 -11
- package/lib/util/resolveConfig.js +12 -12
- package/package.json +15 -14
- package/peers/index.js +3798 -3098
- package/plugin.js +2 -1
- package/resolveConfig.js +2 -1
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +232 -164
- package/src/css/preflight.css +4 -3
- package/src/featureFlags.js +5 -1
- 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 +25 -0
- package/src/lib/generateRules.js +57 -0
- package/src/lib/resolveDefaultsAtRules.js +28 -7
- package/src/lib/setupContextUtils.js +45 -64
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/dataTypes.js +24 -6
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +92 -1
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +4 -0
- package/src/util/nameClass.js +1 -1
- package/src/util/normalizeConfig.js +14 -1
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/pluginUtils.js +2 -0
- package/stubs/defaultConfig.stub.js +23 -5
package/lib/css/preflight.css
CHANGED
|
@@ -144,7 +144,7 @@ sup {
|
|
|
144
144
|
table {
|
|
145
145
|
text-indent: 0; /* 1 */
|
|
146
146
|
border-color: inherit; /* 2 */
|
|
147
|
-
border-collapse: collapse;
|
|
147
|
+
border-collapse: collapse; /* 3 */
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
/*
|
|
@@ -288,7 +288,8 @@ legend {
|
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
ol,
|
|
291
|
-
ul
|
|
291
|
+
ul,
|
|
292
|
+
menu {
|
|
292
293
|
list-style: none;
|
|
293
294
|
margin: 0;
|
|
294
295
|
padding: 0;
|
|
@@ -309,7 +310,7 @@ textarea {
|
|
|
309
310
|
|
|
310
311
|
input::placeholder,
|
|
311
312
|
textarea::placeholder {
|
|
312
|
-
opacity: 1;
|
|
313
|
+
opacity: 1; /* 1 */
|
|
313
314
|
color: theme('colors.gray.400', #9ca3af); /* 2 */
|
|
314
315
|
}
|
|
315
316
|
|
package/lib/featureFlags.js
CHANGED
|
@@ -13,7 +13,9 @@ function _interopRequireDefault(obj) {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
let defaults = {
|
|
16
|
-
|
|
16
|
+
// TODO: Drop this once we can safely rely on optimizeUniversalDefaults being
|
|
17
|
+
// the default.
|
|
18
|
+
optimizeUniversalDefaults: process.env.NODE_ENV === 'test' ? true : false
|
|
17
19
|
};
|
|
18
20
|
let featureFlags = {
|
|
19
21
|
future: [],
|
|
@@ -28,9 +30,9 @@ function flagEnabled(config, flag) {
|
|
|
28
30
|
return config.future === 'all' || ((ref2 = (ref1 = config === null || config === void 0 ? void 0 : (ref = config.future) === null || ref === void 0 ? void 0 : ref[flag]) !== null && ref1 !== void 0 ? ref1 : defaults[flag]) !== null && ref2 !== void 0 ? ref2 : false);
|
|
29
31
|
}
|
|
30
32
|
if (featureFlags.experimental.includes(flag)) {
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
return config.experimental === 'all' || ((
|
|
33
|
+
var ref3;
|
|
34
|
+
var ref4, ref5;
|
|
35
|
+
return config.experimental === 'all' || ((ref5 = (ref4 = config === null || config === void 0 ? void 0 : (ref3 = config.experimental) === null || ref3 === void 0 ? void 0 : ref3[flag]) !== null && ref4 !== void 0 ? ref4 : defaults[flag]) !== null && ref5 !== void 0 ? ref5 : false);
|
|
34
36
|
}
|
|
35
37
|
return false;
|
|
36
38
|
}
|
package/lib/lib/detectNesting.js
CHANGED
|
@@ -6,12 +6,27 @@ exports.default = _default;
|
|
|
6
6
|
function _default(_context) {
|
|
7
7
|
return (root, result)=>{
|
|
8
8
|
let found = false;
|
|
9
|
+
root.walkAtRules('tailwind', (node)=>{
|
|
10
|
+
if (found) return false;
|
|
11
|
+
if (node.parent && node.parent.type !== 'root') {
|
|
12
|
+
found = true;
|
|
13
|
+
node.warn(result, [
|
|
14
|
+
'Nested @tailwind rules were detected, but are not supported.',
|
|
15
|
+
"Consider using a prefix to scope Tailwind's classes: https://tailwindcss.com/docs/configuration#prefix",
|
|
16
|
+
'Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy',
|
|
17
|
+
].join('\n'));
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
9
21
|
root.walkRules((rule)=>{
|
|
10
22
|
if (found) return false;
|
|
11
23
|
rule.walkRules((nestedRule)=>{
|
|
12
24
|
found = true;
|
|
13
|
-
nestedRule.warn(result,
|
|
14
|
-
|
|
25
|
+
nestedRule.warn(result, [
|
|
26
|
+
'Nested CSS was detected, but CSS nesting has not been configured correctly.',
|
|
27
|
+
'Please enable a CSS nesting plugin *before* Tailwind in your configuration.',
|
|
28
|
+
'See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting',
|
|
29
|
+
].join('\n'));
|
|
15
30
|
return false;
|
|
16
31
|
});
|
|
17
32
|
});
|
|
@@ -7,6 +7,7 @@ var _dlv = _interopRequireDefault(require("dlv"));
|
|
|
7
7
|
var _didyoumean = _interopRequireDefault(require("didyoumean"));
|
|
8
8
|
var _transformThemeValue = _interopRequireDefault(require("../util/transformThemeValue"));
|
|
9
9
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
|
10
|
+
var _normalizeScreens = require("../util/normalizeScreens");
|
|
10
11
|
var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
11
12
|
var _toPath = require("../util/toPath");
|
|
12
13
|
function _interopRequireDefault(obj) {
|
|
@@ -112,11 +113,11 @@ function extractArgs(node, vNodes, functions) {
|
|
|
112
113
|
let args = [
|
|
113
114
|
''
|
|
114
115
|
];
|
|
115
|
-
for (let
|
|
116
|
-
if (
|
|
116
|
+
for (let vNode1 of vNodes){
|
|
117
|
+
if (vNode1.type === 'div' && vNode1.value === ',') {
|
|
117
118
|
args.push('');
|
|
118
119
|
} else {
|
|
119
|
-
args[args.length - 1] += _postcssValueParser.default.stringify(
|
|
120
|
+
args[args.length - 1] += _postcssValueParser.default.stringify(vNode1);
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
return args;
|
|
@@ -149,10 +150,13 @@ function _default({ tailwindConfig: config }) {
|
|
|
149
150
|
},
|
|
150
151
|
screen: (node, screen)=>{
|
|
151
152
|
screen = screen.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
|
|
152
|
-
|
|
153
|
+
let screens = (0, _normalizeScreens).normalizeScreens(config.theme.screens);
|
|
154
|
+
let screenDefinition = screens.find(({ name })=>name === screen
|
|
155
|
+
);
|
|
156
|
+
if (!screenDefinition) {
|
|
153
157
|
throw node.error(`The '${screen}' screen does not exist in your theme.`);
|
|
154
158
|
}
|
|
155
|
-
return (0, _buildMediaQuery).default(
|
|
159
|
+
return (0, _buildMediaQuery).default(screenDefinition);
|
|
156
160
|
}
|
|
157
161
|
};
|
|
158
162
|
return (root)=>{
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.default = expandApplyAtRules;
|
|
6
6
|
var _postcss = _interopRequireDefault(require("postcss"));
|
|
7
|
+
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
|
|
7
8
|
var _generateRules = require("./generateRules");
|
|
8
9
|
var _bigSign = _interopRequireDefault(require("../util/bigSign"));
|
|
9
10
|
var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
|
|
@@ -12,9 +13,21 @@ function _interopRequireDefault(obj) {
|
|
|
12
13
|
default: obj
|
|
13
14
|
};
|
|
14
15
|
}
|
|
16
|
+
function containsBase(selector, classCandidateBase, separator) {
|
|
17
|
+
return (0, _postcssSelectorParser).default((selectors)=>{
|
|
18
|
+
let contains = false;
|
|
19
|
+
selectors.walkClasses((classSelector)=>{
|
|
20
|
+
if (classSelector.value.split(separator).pop() === classCandidateBase) {
|
|
21
|
+
contains = true;
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return contains;
|
|
26
|
+
}).transformSync(selector);
|
|
27
|
+
}
|
|
15
28
|
function prefix(context, selector) {
|
|
16
|
-
let
|
|
17
|
-
return typeof
|
|
29
|
+
let prefix1 = context.tailwindConfig.prefix;
|
|
30
|
+
return typeof prefix1 === 'function' ? prefix1(selector) : prefix1 + selector;
|
|
18
31
|
}
|
|
19
32
|
function buildApplyCache(applyCandidates, context) {
|
|
20
33
|
for (let candidate of applyCandidates){
|
|
@@ -56,10 +69,10 @@ function partitionApplyParents(root) {
|
|
|
56
69
|
root.walkAtRules('apply', (rule)=>{
|
|
57
70
|
applyParents.add(rule.parent);
|
|
58
71
|
});
|
|
59
|
-
for (let
|
|
72
|
+
for (let rule1 of applyParents){
|
|
60
73
|
let nodeGroups = [];
|
|
61
74
|
let lastGroup = [];
|
|
62
|
-
for (let node of
|
|
75
|
+
for (let node of rule1.nodes){
|
|
63
76
|
if (node.type === 'atrule' && node.name === 'apply') {
|
|
64
77
|
if (lastGroup.length > 0) {
|
|
65
78
|
nodeGroups.push(lastGroup);
|
|
@@ -81,13 +94,13 @@ function partitionApplyParents(root) {
|
|
|
81
94
|
for (let group of [
|
|
82
95
|
...nodeGroups
|
|
83
96
|
].reverse()){
|
|
84
|
-
let newParent =
|
|
97
|
+
let newParent = rule1.clone({
|
|
85
98
|
nodes: []
|
|
86
99
|
});
|
|
87
100
|
newParent.append(group);
|
|
88
|
-
|
|
101
|
+
rule1.after(newParent);
|
|
89
102
|
}
|
|
90
|
-
|
|
103
|
+
rule1.remove();
|
|
91
104
|
}
|
|
92
105
|
}
|
|
93
106
|
function processApply(root, context) {
|
|
@@ -127,8 +140,8 @@ function processApply(root, context) {
|
|
|
127
140
|
*/ // TODO: Should we use postcss-selector-parser for this instead?
|
|
128
141
|
function replaceSelector(selector, utilitySelectors, candidate) {
|
|
129
142
|
let needle = `.${(0, _escapeClassName).default(candidate)}`;
|
|
130
|
-
let utilitySelectorsList = utilitySelectors.split(/\s
|
|
131
|
-
return selector.split(/\s
|
|
143
|
+
let utilitySelectorsList = utilitySelectors.split(/\s*\,(?![^(]*\))\s*/g);
|
|
144
|
+
return selector.split(/\s*\,(?![^(]*\))\s*/g).map((s)=>{
|
|
132
145
|
let replaced = [];
|
|
133
146
|
for (let utilitySelector of utilitySelectorsList){
|
|
134
147
|
let replacedSelector = utilitySelector.replace(needle, s);
|
|
@@ -173,7 +186,11 @@ function processApply(root, context) {
|
|
|
173
186
|
for (const [parent, candidates] of perParentApplies){
|
|
174
187
|
let siblings = [];
|
|
175
188
|
for (let [applyCandidate, important, rules] of candidates){
|
|
189
|
+
let base = applyCandidate.split(context.tailwindConfig.separator).pop();
|
|
176
190
|
for (let [meta, node] of rules){
|
|
191
|
+
if (containsBase(parent.selector, base, context.tailwindConfig.separator) && containsBase(node.selector, base, context.tailwindConfig.separator)) {
|
|
192
|
+
throw node.error(`Circular dependency detected when using: \`@apply ${applyCandidate}\``);
|
|
193
|
+
}
|
|
177
194
|
let root = _postcss.default.root({
|
|
178
195
|
nodes: [
|
|
179
196
|
node.clone()
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = expandTailwindAtRules;
|
|
6
|
+
exports.DEFAULTS_LAYER = void 0;
|
|
6
7
|
var _quickLru = _interopRequireDefault(require("quick-lru"));
|
|
7
8
|
var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
8
9
|
var _generateRules = require("./generateRules");
|
|
@@ -46,6 +47,8 @@ const PATTERNS = [
|
|
|
46
47
|
/([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source,
|
|
47
48
|
/([^<>"'`\s]*\['[^"'`\s]*'\])/.source,
|
|
48
49
|
/([^<>"'`\s]*\["[^"'`\s]*"\])/.source,
|
|
50
|
+
/([^<>"'`\s]*\[[^<>"'`\s]*:'[^"'`\s]*'\])/.source,
|
|
51
|
+
/([^<>"'`\s]*\[[^<>"'`\s]*:"[^"'`\s]*"\])/.source,
|
|
49
52
|
/([^<>"'`\s]*\[[^"'`\s]+\][^<>"'`\s]*)/.source,
|
|
50
53
|
/([^<>"'`\s]*[^"'`\s:])/.source
|
|
51
54
|
].join('|');
|
|
@@ -110,6 +113,7 @@ function buildStylesheet(rules, context) {
|
|
|
110
113
|
);
|
|
111
114
|
let returnValue = {
|
|
112
115
|
base: new Set(),
|
|
116
|
+
defaults: new Set(),
|
|
113
117
|
components: new Set(),
|
|
114
118
|
utilities: new Set(),
|
|
115
119
|
variants: new Set(),
|
|
@@ -132,6 +136,10 @@ function buildStylesheet(rules, context) {
|
|
|
132
136
|
returnValue.base.add(rule);
|
|
133
137
|
continue;
|
|
134
138
|
}
|
|
139
|
+
if (sort & context.layerOrder.defaults) {
|
|
140
|
+
returnValue.defaults.add(rule);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
135
143
|
if (sort & context.layerOrder.components) {
|
|
136
144
|
returnValue.components.add(rule);
|
|
137
145
|
continue;
|
|
@@ -147,6 +155,8 @@ function buildStylesheet(rules, context) {
|
|
|
147
155
|
}
|
|
148
156
|
return returnValue;
|
|
149
157
|
}
|
|
158
|
+
const DEFAULTS_LAYER = Symbol('defaults-layer');
|
|
159
|
+
exports.DEFAULTS_LAYER = DEFAULTS_LAYER;
|
|
150
160
|
function expandTailwindAtRules(context) {
|
|
151
161
|
return (root)=>{
|
|
152
162
|
let layerNodes = {
|
|
@@ -197,13 +207,29 @@ function expandTailwindAtRules(context) {
|
|
|
197
207
|
], context);
|
|
198
208
|
}
|
|
199
209
|
env.DEBUG && console.timeEnd('Build stylesheet');
|
|
200
|
-
let { base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes , } = context.stylesheetCache;
|
|
210
|
+
let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes , } = context.stylesheetCache;
|
|
201
211
|
// ---
|
|
202
212
|
// Replace any Tailwind directives with generated CSS
|
|
203
213
|
if (layerNodes.base) {
|
|
204
214
|
layerNodes.base.before((0, _cloneNodes).default([
|
|
205
215
|
...baseNodes
|
|
206
216
|
], layerNodes.base.source));
|
|
217
|
+
}
|
|
218
|
+
// @defaults rules are unconditionally added first to ensure that
|
|
219
|
+
// using any utility that relies on defaults will work even when
|
|
220
|
+
// compiled in an isolated environment like CSS modules
|
|
221
|
+
if (context.tailwindConfig[DEFAULTS_LAYER] !== false) {
|
|
222
|
+
if (layerNodes.base) {
|
|
223
|
+
layerNodes.base.after((0, _cloneNodes).default([
|
|
224
|
+
...defaultNodes
|
|
225
|
+
], root.source));
|
|
226
|
+
} else {
|
|
227
|
+
root.prepend((0, _cloneNodes).default([
|
|
228
|
+
...defaultNodes
|
|
229
|
+
], root.source));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (layerNodes.base) {
|
|
207
233
|
layerNodes.base.remove();
|
|
208
234
|
}
|
|
209
235
|
if (layerNodes.components) {
|
package/lib/lib/generateRules.js
CHANGED
|
@@ -11,6 +11,9 @@ var _prefixSelector = _interopRequireDefault(require("../util/prefixSelector"));
|
|
|
11
11
|
var _pluginUtils = require("../util/pluginUtils");
|
|
12
12
|
var _log = _interopRequireDefault(require("../util/log"));
|
|
13
13
|
var _formatVariantSelector = require("../util/formatVariantSelector");
|
|
14
|
+
var _nameClass = require("../util/nameClass");
|
|
15
|
+
var _dataTypes = require("../util/dataTypes");
|
|
16
|
+
var _isValidArbitraryValue = _interopRequireDefault(require("../util/isValidArbitraryValue"));
|
|
14
17
|
function _interopRequireDefault(obj) {
|
|
15
18
|
return obj && obj.__esModule ? obj : {
|
|
16
19
|
default: obj
|
|
@@ -120,10 +123,10 @@ function applyVariant(variant, matches, context) {
|
|
|
120
123
|
if (context.variantMap.has(variant)) {
|
|
121
124
|
let variantFunctionTuples = context.variantMap.get(variant);
|
|
122
125
|
let result = [];
|
|
123
|
-
for (let [meta,
|
|
126
|
+
for (let [meta, rule1] of matches){
|
|
124
127
|
let container = _postcss.default.root({
|
|
125
128
|
nodes: [
|
|
126
|
-
|
|
129
|
+
rule1.clone()
|
|
127
130
|
]
|
|
128
131
|
});
|
|
129
132
|
for (let [variantSort, variantFunction] of variantFunctionTuples){
|
|
@@ -250,6 +253,49 @@ function parseRules(rule, cache, options = {
|
|
|
250
253
|
options
|
|
251
254
|
];
|
|
252
255
|
}
|
|
256
|
+
const IS_VALID_PROPERTY_NAME = /^[a-z_-]/;
|
|
257
|
+
function isValidPropName(name) {
|
|
258
|
+
return IS_VALID_PROPERTY_NAME.test(name);
|
|
259
|
+
}
|
|
260
|
+
function isParsableCssValue(property, value) {
|
|
261
|
+
try {
|
|
262
|
+
_postcss.default.parse(`a{${property}:${value}}`).toResult();
|
|
263
|
+
return true;
|
|
264
|
+
} catch (err) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function extractArbitraryProperty(classCandidate, context) {
|
|
269
|
+
var ref;
|
|
270
|
+
let [, property, value] = (ref = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/)) !== null && ref !== void 0 ? ref : [];
|
|
271
|
+
if (value === undefined) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
if (!isValidPropName(property)) {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
if (!(0, _isValidArbitraryValue).default(value)) {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
let normalized = (0, _dataTypes).normalize(value);
|
|
281
|
+
if (!isParsableCssValue(property, normalized)) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
return [
|
|
285
|
+
[
|
|
286
|
+
{
|
|
287
|
+
sort: context.arbitraryPropertiesSort,
|
|
288
|
+
layer: 'utilities'
|
|
289
|
+
},
|
|
290
|
+
()=>({
|
|
291
|
+
[(0, _nameClass).asClass(classCandidate)]: {
|
|
292
|
+
[property]: normalized
|
|
293
|
+
}
|
|
294
|
+
})
|
|
295
|
+
,
|
|
296
|
+
],
|
|
297
|
+
];
|
|
298
|
+
}
|
|
253
299
|
function* resolveMatchedPlugins(classCandidate, context) {
|
|
254
300
|
if (context.candidateRuleMap.has(classCandidate)) {
|
|
255
301
|
yield [
|
|
@@ -257,6 +303,14 @@ function* resolveMatchedPlugins(classCandidate, context) {
|
|
|
257
303
|
'DEFAULT'
|
|
258
304
|
];
|
|
259
305
|
}
|
|
306
|
+
yield* (function*(arbitraryPropertyRule) {
|
|
307
|
+
if (arbitraryPropertyRule !== null) {
|
|
308
|
+
yield [
|
|
309
|
+
arbitraryPropertyRule,
|
|
310
|
+
'DEFAULT'
|
|
311
|
+
];
|
|
312
|
+
}
|
|
313
|
+
})(extractArbitraryProperty(classCandidate, context));
|
|
260
314
|
let candidatePrefix = classCandidate;
|
|
261
315
|
let negative = false;
|
|
262
316
|
const twConfigPrefix = context.tailwindConfig.prefix;
|
|
@@ -353,9 +407,9 @@ function* resolveMatches(candidate, context) {
|
|
|
353
407
|
// Only keep the result of the very first plugin if we are dealing with
|
|
354
408
|
// arbitrary values, to protect against ambiguity.
|
|
355
409
|
if (isArbitraryValue(modifier) && matches.length > 1) {
|
|
356
|
-
var
|
|
410
|
+
var ref1;
|
|
357
411
|
let typesPerPlugin = matches.map((match)=>new Set([
|
|
358
|
-
...(
|
|
412
|
+
...(ref1 = typesByMatches.get(match)) !== null && ref1 !== void 0 ? ref1 : []
|
|
359
413
|
])
|
|
360
414
|
);
|
|
361
415
|
// Remove duplicates, so that we can detect proper unique types for each plugin.
|
|
@@ -400,13 +454,13 @@ function* resolveMatches(candidate, context) {
|
|
|
400
454
|
for (let variant of variants){
|
|
401
455
|
matches = applyVariant(variant, matches, context);
|
|
402
456
|
}
|
|
403
|
-
for (let
|
|
457
|
+
for (let match1 of matches){
|
|
404
458
|
// Apply final format selector
|
|
405
|
-
if (
|
|
406
|
-
let finalFormat = (0, _formatVariantSelector).formatVariantSelector('&', ...
|
|
459
|
+
if (match1[0].collectedFormats) {
|
|
460
|
+
let finalFormat = (0, _formatVariantSelector).formatVariantSelector('&', ...match1[0].collectedFormats);
|
|
407
461
|
let container = _postcss.default.root({
|
|
408
462
|
nodes: [
|
|
409
|
-
|
|
463
|
+
match1[1].clone()
|
|
410
464
|
]
|
|
411
465
|
});
|
|
412
466
|
container.walkRules((rule)=>{
|
|
@@ -417,9 +471,9 @@ function* resolveMatches(candidate, context) {
|
|
|
417
471
|
context
|
|
418
472
|
});
|
|
419
473
|
});
|
|
420
|
-
|
|
474
|
+
match1[1] = container.nodes[0];
|
|
421
475
|
}
|
|
422
|
-
yield
|
|
476
|
+
yield match1;
|
|
423
477
|
}
|
|
424
478
|
}
|
|
425
479
|
}
|
|
@@ -47,8 +47,8 @@ function minimumImpactSelector(nodes) {
|
|
|
47
47
|
let splitPointIdx = rest.findIndex((n)=>searchFor.has(n.type)
|
|
48
48
|
);
|
|
49
49
|
if (splitPointIdx === -1) return rest.reverse().join('').trim();
|
|
50
|
-
let
|
|
51
|
-
let bestNode = getNode[
|
|
50
|
+
let node1 = rest[splitPointIdx];
|
|
51
|
+
let bestNode = getNode[node1.type] ? getNode[node1.type](node1) : node1;
|
|
52
52
|
rest = rest.slice(0, splitPointIdx);
|
|
53
53
|
let combinatorIdx = rest.findIndex((n)=>n.type === 'combinator' && n.value === '>'
|
|
54
54
|
);
|
|
@@ -79,7 +79,7 @@ function extractElementSelector(selector) {
|
|
|
79
79
|
function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
80
80
|
return (root)=>{
|
|
81
81
|
let variableNodeMap = new Map();
|
|
82
|
-
let universals = new Set();
|
|
82
|
+
/** @type {Set<import('postcss').AtRule>} */ let universals = new Set();
|
|
83
83
|
root.walkAtRules('defaults', (rule)=>{
|
|
84
84
|
if (rule.nodes && rule.nodes.length > 0) {
|
|
85
85
|
universals.add(rule);
|
|
@@ -93,32 +93,46 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
93
93
|
rule.remove();
|
|
94
94
|
});
|
|
95
95
|
for (let universal of universals){
|
|
96
|
-
let
|
|
96
|
+
/** @type {Map<string, Set<string>>} */ let selectorGroups = new Map();
|
|
97
97
|
var ref;
|
|
98
98
|
let rules = (ref = variableNodeMap.get(universal.params)) !== null && ref !== void 0 ? ref : [];
|
|
99
99
|
for (let rule of rules){
|
|
100
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);
|
|
101
109
|
selectors.add(selector);
|
|
102
110
|
}
|
|
103
111
|
}
|
|
104
|
-
if (
|
|
112
|
+
if (selectorGroups.size === 0) {
|
|
105
113
|
universal.remove();
|
|
106
114
|
continue;
|
|
107
115
|
}
|
|
108
|
-
let universalRule = _postcss.default.rule();
|
|
109
116
|
if ((0, _featureFlags).flagEnabled(tailwindConfig, 'optimizeUniversalDefaults')) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
+
}
|
|
113
126
|
} else {
|
|
127
|
+
let universalRule = _postcss.default.rule();
|
|
114
128
|
universalRule.selectors = [
|
|
115
129
|
'*',
|
|
116
130
|
'::before',
|
|
117
131
|
'::after'
|
|
118
132
|
];
|
|
133
|
+
universalRule.append(universal.nodes);
|
|
134
|
+
universal.before(universalRule);
|
|
119
135
|
}
|
|
120
|
-
universalRule.append(universal.nodes);
|
|
121
|
-
universal.before(universalRule);
|
|
122
136
|
universal.remove();
|
|
123
137
|
}
|
|
124
138
|
};
|