tailwindcss 0.0.0-insiders.bd970d0 → 0.0.0-insiders.bda8421
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/README.md +1 -2
- package/lib/cli/build/deps.js +62 -0
- package/lib/cli/build/index.js +12 -15
- package/lib/cli/build/plugin.js +107 -167
- package/lib/cli/build/utils.js +13 -13
- package/lib/cli/build/watching.js +10 -10
- package/lib/cli/help/index.js +11 -11
- package/lib/cli/index.js +60 -61
- package/lib/cli/init/index.js +16 -16
- package/lib/cli-peer-dependencies.js +36 -0
- package/lib/cli.js +1 -1
- package/lib/corePluginList.js +4 -1
- package/lib/corePlugins.js +2018 -1905
- package/lib/css/preflight.css +18 -12
- package/lib/featureFlags.js +17 -23
- package/lib/index.js +1 -1
- package/lib/lib/cacheInvalidation.js +3 -3
- package/lib/lib/collapseAdjacentRules.js +6 -6
- package/lib/lib/collapseDuplicateDeclarations.js +1 -1
- package/lib/lib/content.js +39 -32
- package/lib/lib/defaultExtractor.js +40 -17
- package/lib/lib/evaluateTailwindFunctions.js +23 -23
- package/lib/lib/expandApplyAtRules.js +37 -18
- package/lib/lib/expandTailwindAtRules.js +49 -85
- package/lib/lib/findAtConfigPath.js +5 -5
- package/lib/lib/generateRules.js +82 -55
- package/lib/lib/getModuleDependencies.js +23 -23
- package/lib/lib/load-config.js +21 -6
- package/lib/lib/normalizeTailwindDirectives.js +36 -21
- package/lib/lib/offsets.js +97 -48
- package/lib/lib/partitionApplyAtRules.js +2 -2
- package/lib/lib/regex.js +5 -5
- package/lib/lib/resolveDefaultsAtRules.js +27 -25
- package/lib/lib/setupContextUtils.js +195 -167
- package/lib/lib/setupTrackingContext.js +4 -5
- package/lib/lib/sharedState.js +10 -10
- package/lib/lib/substituteScreenAtRules.js +4 -4
- package/lib/plugin.js +8 -124
- package/lib/postcss-plugins/nesting/index.js +2 -2
- package/lib/postcss-plugins/nesting/plugin.js +11 -11
- package/lib/processTailwindFeatures.js +3 -5
- package/lib/public/colors.js +264 -264
- package/lib/util/applyImportantSelector.js +2 -2
- package/lib/util/buildMediaQuery.js +2 -2
- package/lib/util/cloneDeep.js +1 -1
- package/lib/util/cloneNodes.js +33 -13
- package/lib/util/color.js +19 -19
- package/lib/util/createUtilityPlugin.js +3 -3
- package/lib/util/dataTypes.js +170 -113
- package/lib/util/defaults.js +4 -4
- package/lib/util/escapeClassName.js +2 -2
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +2 -2
- package/lib/util/formatVariantSelector.js +24 -19
- package/lib/util/getAllConfigs.js +4 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +2 -2
- package/lib/util/isSyntacticallyValidPropertyValue.js +10 -10
- package/lib/util/log.js +6 -23
- package/lib/util/nameClass.js +4 -4
- package/lib/util/negateValue.js +8 -8
- package/lib/util/normalizeConfig.js +63 -94
- package/lib/util/normalizeScreens.js +18 -18
- package/lib/util/parseAnimationValue.js +38 -38
- package/lib/util/parseBoxShadowValue.js +18 -18
- package/lib/util/parseDependency.js +4 -4
- package/lib/util/parseGlob.js +4 -4
- package/lib/util/parseObjectStyles.js +1 -1
- package/lib/util/pluginUtils.js +36 -21
- package/lib/util/prefixSelector.js +4 -4
- package/lib/util/pseudoElements.js +72 -69
- package/lib/util/removeAlphaVariables.js +1 -1
- package/lib/util/resolveConfig.js +11 -15
- package/lib/util/resolveConfigPath.js +6 -6
- package/lib/util/responsive.js +1 -1
- package/lib/util/splitAtTopLevelOnly.js +3 -3
- package/lib/util/toColorValue.js +1 -1
- package/lib/util/toPath.js +2 -2
- package/lib/util/transformThemeValue.js +24 -24
- package/lib/util/validateConfig.js +9 -20
- package/lib/util/validateFormalSyntax.js +5 -5
- package/lib/util/withAlphaVariable.js +5 -5
- package/lib/value-parser/index.js +5 -5
- package/lib/value-parser/parse.js +43 -43
- package/lib/value-parser/stringify.js +11 -11
- package/lib/value-parser/unit.js +5 -5
- package/lib/value-parser/walk.js +1 -1
- package/nesting/index.d.ts +4 -0
- package/package.json +41 -36
- package/peers/index.js +96503 -0
- package/resolveConfig.d.ts +22 -3
- package/scripts/generate-types.js +1 -2
- package/scripts/release-notes.js +1 -1
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +0 -4
- package/src/cli/build/plugin.js +53 -85
- package/src/cli/build/watching.js +1 -1
- package/src/cli/index.js +0 -1
- package/src/cli-peer-dependencies.js +15 -0
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +118 -31
- package/src/css/preflight.css +18 -12
- package/src/featureFlags.js +3 -5
- package/src/lib/content.js +39 -30
- package/src/lib/defaultExtractor.js +29 -6
- package/src/lib/expandApplyAtRules.js +24 -0
- package/src/lib/expandTailwindAtRules.js +19 -56
- package/src/lib/generateRules.js +39 -8
- package/src/lib/load-config.ts +13 -0
- package/src/lib/normalizeTailwindDirectives.js +27 -0
- package/src/lib/offsets.js +62 -3
- package/src/lib/resolveDefaultsAtRules.js +5 -1
- package/src/lib/setupContextUtils.js +79 -39
- package/src/plugin.js +0 -86
- package/src/processTailwindFeatures.js +0 -3
- package/src/util/cloneNodes.js +35 -14
- package/src/util/dataTypes.js +72 -6
- package/src/util/formatVariantSelector.js +7 -0
- package/src/util/isPlainObject.js +1 -1
- package/src/util/log.js +0 -24
- package/src/util/normalizeConfig.js +11 -38
- package/src/util/pluginUtils.js +20 -0
- package/src/util/pseudoElements.js +4 -0
- package/src/util/validateConfig.js +0 -10
- package/stubs/config.full.js +68 -8
- package/stubs/config.simple.js +1 -1
- package/stubs/postcss.config.cjs +1 -0
- package/stubs/postcss.config.js +1 -0
- package/types/config.d.ts +12 -5
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +28 -9
- package/types/index.d.ts +7 -3
- package/index.css +0 -5
- package/lib/lib/detectNesting.js +0 -45
- package/lib/lib/handleImportAtRules.js +0 -50
- package/src/lib/detectNesting.js +0 -47
- package/src/lib/handleImportAtRules.js +0 -34
|
@@ -49,6 +49,7 @@ const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interop_require_defaul
|
|
|
49
49
|
const _generateRules = require("./generateRules");
|
|
50
50
|
const _cacheInvalidation = require("./cacheInvalidation.js");
|
|
51
51
|
const _offsets = require("./offsets.js");
|
|
52
|
+
const _featureFlags = require("../featureFlags.js");
|
|
52
53
|
const _formatVariantSelector = require("../util/formatVariantSelector");
|
|
53
54
|
function _interop_require_default(obj) {
|
|
54
55
|
return obj && obj.__esModule ? obj : {
|
|
@@ -96,8 +97,8 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
96
97
|
}
|
|
97
98
|
const INTERNAL_FEATURES = Symbol();
|
|
98
99
|
const VARIANT_TYPES = {
|
|
99
|
-
AddVariant: Symbol.for(
|
|
100
|
-
MatchVariant: Symbol.for(
|
|
100
|
+
AddVariant: Symbol.for("ADD_VARIANT"),
|
|
101
|
+
MatchVariant: Symbol.for("MATCH_VARIANT")
|
|
101
102
|
};
|
|
102
103
|
const VARIANT_INFO = {
|
|
103
104
|
Base: 1 << 0,
|
|
@@ -105,9 +106,9 @@ const VARIANT_INFO = {
|
|
|
105
106
|
};
|
|
106
107
|
function prefix(context, selector) {
|
|
107
108
|
let prefix = context.tailwindConfig.prefix;
|
|
108
|
-
return typeof prefix ===
|
|
109
|
+
return typeof prefix === "function" ? prefix(selector) : prefix + selector;
|
|
109
110
|
}
|
|
110
|
-
function normalizeOptionTypes({ type =
|
|
111
|
+
function normalizeOptionTypes({ type ="any" , ...options }) {
|
|
111
112
|
let types = [].concat(type);
|
|
112
113
|
return {
|
|
113
114
|
...options,
|
|
@@ -132,25 +133,25 @@ function parseVariantFormatString(input) {
|
|
|
132
133
|
// Because the selector could look like this
|
|
133
134
|
// @media { &[data-name="foo bar"] }
|
|
134
135
|
// This is why we do not skip whitespace
|
|
135
|
-
let current =
|
|
136
|
+
let current = "";
|
|
136
137
|
let depth = 0;
|
|
137
138
|
for(let idx = 0; idx < input.length; idx++){
|
|
138
139
|
let char = input[idx];
|
|
139
|
-
if (char ===
|
|
140
|
+
if (char === "\\") {
|
|
140
141
|
// Escaped characters are not special
|
|
141
|
-
current +=
|
|
142
|
-
} else if (char ===
|
|
142
|
+
current += "\\" + input[++idx];
|
|
143
|
+
} else if (char === "{") {
|
|
143
144
|
// Nested rule: start
|
|
144
145
|
++depth;
|
|
145
146
|
parts.push(current.trim());
|
|
146
|
-
current =
|
|
147
|
-
} else if (char ===
|
|
147
|
+
current = "";
|
|
148
|
+
} else if (char === "}") {
|
|
148
149
|
// Nested rule: end
|
|
149
150
|
if (--depth < 0) {
|
|
150
151
|
throw new Error(`Your { and } are unbalanced.`);
|
|
151
152
|
}
|
|
152
153
|
parts.push(current.trim());
|
|
153
|
-
current =
|
|
154
|
+
current = "";
|
|
154
155
|
} else {
|
|
155
156
|
// Normal character
|
|
156
157
|
current += char;
|
|
@@ -159,10 +160,10 @@ function parseVariantFormatString(input) {
|
|
|
159
160
|
if (current.length > 0) {
|
|
160
161
|
parts.push(current.trim());
|
|
161
162
|
}
|
|
162
|
-
parts = parts.filter((part)=>part !==
|
|
163
|
+
parts = parts.filter((part)=>part !== "");
|
|
163
164
|
return parts;
|
|
164
165
|
}
|
|
165
|
-
function insertInto(list, value, { before =
|
|
166
|
+
function insertInto(list, value, { before =[] } = {}) {
|
|
166
167
|
before = [].concat(before);
|
|
167
168
|
if (before.length <= 0) {
|
|
168
169
|
list.push(value);
|
|
@@ -200,39 +201,41 @@ function getClasses(selector, mutate) {
|
|
|
200
201
|
});
|
|
201
202
|
return parser.transformSync(selector);
|
|
202
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Ignore everything inside a :not(...). This allows you to write code like
|
|
206
|
+
* `div:not(.foo)`. If `.foo` is never found in your code, then we used to
|
|
207
|
+
* not generated it. But now we will ignore everything inside a `:not`, so
|
|
208
|
+
* that it still gets generated.
|
|
209
|
+
*
|
|
210
|
+
* @param {selectorParser.Root} selectors
|
|
211
|
+
*/ function ignoreNot(selectors) {
|
|
212
|
+
selectors.walkPseudos((pseudo)=>{
|
|
213
|
+
if (pseudo.value === ":not") {
|
|
214
|
+
pseudo.remove();
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
203
218
|
function extractCandidates(node, state = {
|
|
204
219
|
containsNonOnDemandable: false
|
|
205
220
|
}, depth = 0) {
|
|
206
221
|
let classes = [];
|
|
207
|
-
|
|
208
|
-
if (node.type ===
|
|
209
|
-
//
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
//
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
222
|
+
let selectors = [];
|
|
223
|
+
if (node.type === "rule") {
|
|
224
|
+
// Handle normal rules
|
|
225
|
+
selectors.push(...node.selectors);
|
|
226
|
+
} else if (node.type === "atrule") {
|
|
227
|
+
// Handle at-rules (which contains nested rules)
|
|
228
|
+
node.walkRules((rule)=>selectors.push(...rule.selectors));
|
|
229
|
+
}
|
|
230
|
+
for (let selector of selectors){
|
|
231
|
+
let classCandidates = getClasses(selector, ignoreNot);
|
|
232
|
+
// At least one of the selectors contains non-"on-demandable" candidates.
|
|
233
|
+
if (classCandidates.length === 0) {
|
|
234
|
+
state.containsNonOnDemandable = true;
|
|
219
235
|
}
|
|
220
|
-
for (let
|
|
221
|
-
|
|
222
|
-
// At least one of the selectors contains non-"on-demandable" candidates.
|
|
223
|
-
if (classCandidates.length === 0) {
|
|
224
|
-
state.containsNonOnDemandable = true;
|
|
225
|
-
}
|
|
226
|
-
for (let classCandidate of classCandidates){
|
|
227
|
-
classes.push(classCandidate);
|
|
228
|
-
}
|
|
236
|
+
for (let classCandidate of classCandidates){
|
|
237
|
+
classes.push(classCandidate);
|
|
229
238
|
}
|
|
230
|
-
} else if (node.type === 'atrule') {
|
|
231
|
-
node.walkRules((rule)=>{
|
|
232
|
-
for (let classCandidate of rule.selectors.flatMap((selector)=>getClasses(selector))){
|
|
233
|
-
classes.push(classCandidate);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
239
|
}
|
|
237
240
|
if (depth === 0) {
|
|
238
241
|
return [
|
|
@@ -265,21 +268,20 @@ function withIdentifiers(styles) {
|
|
|
265
268
|
});
|
|
266
269
|
}
|
|
267
270
|
function isValidVariantFormatString(format) {
|
|
268
|
-
return format.startsWith(
|
|
271
|
+
return format.startsWith("@") || format.includes("&");
|
|
269
272
|
}
|
|
270
273
|
function parseVariant(variant) {
|
|
271
|
-
variant = variant.replace(/\n+/g,
|
|
274
|
+
variant = variant.replace(/\n+/g, "").replace(/\s{1,}/g, " ").trim();
|
|
272
275
|
let fns = parseVariantFormatString(variant).map((str)=>{
|
|
273
|
-
if (!str.startsWith(
|
|
274
|
-
return ({ format
|
|
276
|
+
if (!str.startsWith("@")) {
|
|
277
|
+
return ({ format })=>format(str);
|
|
275
278
|
}
|
|
276
279
|
let [, name, params] = /@(\S*)( .+|[({].*)?/g.exec(str);
|
|
277
280
|
var _params_trim;
|
|
278
|
-
return ({ wrap
|
|
279
|
-
var _params;
|
|
281
|
+
return ({ wrap })=>{
|
|
280
282
|
return wrap(_postcss.default.atRule({
|
|
281
283
|
name,
|
|
282
|
-
params: (_params_trim =
|
|
284
|
+
params: (_params_trim = params === null || params === void 0 ? void 0 : params.trim()) !== null && _params_trim !== void 0 ? _params_trim : ""
|
|
283
285
|
}));
|
|
284
286
|
};
|
|
285
287
|
}).reverse();
|
|
@@ -295,7 +297,7 @@ function parseVariant(variant) {
|
|
|
295
297
|
* @param {any} context
|
|
296
298
|
* @param {object} param2
|
|
297
299
|
* @param {Offsets} param2.offsets
|
|
298
|
-
*/ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offsets, classList
|
|
300
|
+
*/ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , offsets , classList }) {
|
|
299
301
|
function getConfigValue(path, defaultValue) {
|
|
300
302
|
return path ? (0, _dlv.default)(tailwindConfig, path, defaultValue) : tailwindConfig;
|
|
301
303
|
}
|
|
@@ -314,7 +316,7 @@ function parseVariant(variant) {
|
|
|
314
316
|
function resolveThemeValue(path, defaultValue, opts = {}) {
|
|
315
317
|
let parts = (0, _toPath.toPath)(path);
|
|
316
318
|
let value = getConfigValue([
|
|
317
|
-
|
|
319
|
+
"theme",
|
|
318
320
|
...parts
|
|
319
321
|
], defaultValue);
|
|
320
322
|
return (0, _transformThemeValue.default)(parts[0])(value, opts);
|
|
@@ -331,7 +333,7 @@ function parseVariant(variant) {
|
|
|
331
333
|
return tailwindConfig.corePlugins.includes(path);
|
|
332
334
|
}
|
|
333
335
|
return getConfigValue([
|
|
334
|
-
|
|
336
|
+
"corePlugins",
|
|
335
337
|
path
|
|
336
338
|
], true);
|
|
337
339
|
},
|
|
@@ -342,14 +344,14 @@ function parseVariant(variant) {
|
|
|
342
344
|
addBase (base) {
|
|
343
345
|
for (let [identifier, rule] of withIdentifiers(base)){
|
|
344
346
|
let prefixedIdentifier = prefixIdentifier(identifier, {});
|
|
345
|
-
let offset = offsets.create(
|
|
347
|
+
let offset = offsets.create("base");
|
|
346
348
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
347
349
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
348
350
|
}
|
|
349
351
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
350
352
|
{
|
|
351
353
|
sort: offset,
|
|
352
|
-
layer:
|
|
354
|
+
layer: "base"
|
|
353
355
|
},
|
|
354
356
|
rule
|
|
355
357
|
]);
|
|
@@ -369,8 +371,8 @@ function parseVariant(variant) {
|
|
|
369
371
|
}
|
|
370
372
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
371
373
|
{
|
|
372
|
-
sort: offsets.create(
|
|
373
|
-
layer:
|
|
374
|
+
sort: offsets.create("defaults"),
|
|
375
|
+
layer: "defaults"
|
|
374
376
|
},
|
|
375
377
|
rule
|
|
376
378
|
]);
|
|
@@ -391,8 +393,8 @@ function parseVariant(variant) {
|
|
|
391
393
|
}
|
|
392
394
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
393
395
|
{
|
|
394
|
-
sort: offsets.create(
|
|
395
|
-
layer:
|
|
396
|
+
sort: offsets.create("components"),
|
|
397
|
+
layer: "components",
|
|
396
398
|
options
|
|
397
399
|
},
|
|
398
400
|
rule
|
|
@@ -414,8 +416,8 @@ function parseVariant(variant) {
|
|
|
414
416
|
}
|
|
415
417
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
416
418
|
{
|
|
417
|
-
sort: offsets.create(
|
|
418
|
-
layer:
|
|
419
|
+
sort: offsets.create("utilities"),
|
|
420
|
+
layer: "utilities",
|
|
419
421
|
options
|
|
420
422
|
},
|
|
421
423
|
rule
|
|
@@ -432,7 +434,7 @@ function parseVariant(variant) {
|
|
|
432
434
|
...defaultOptions,
|
|
433
435
|
...options
|
|
434
436
|
});
|
|
435
|
-
let offset = offsets.create(
|
|
437
|
+
let offset = offsets.create("utilities");
|
|
436
438
|
for(let identifier in utilities){
|
|
437
439
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
438
440
|
let rule = utilities[identifier];
|
|
@@ -440,16 +442,16 @@ function parseVariant(variant) {
|
|
|
440
442
|
prefixedIdentifier,
|
|
441
443
|
options
|
|
442
444
|
]);
|
|
443
|
-
function wrapped(modifier, { isOnlyPlugin
|
|
445
|
+
function wrapped(modifier, { isOnlyPlugin }) {
|
|
444
446
|
let [value, coercedType, utilityModifier] = (0, _pluginUtils.coerceValue)(options.types, modifier, options, tailwindConfig);
|
|
445
447
|
if (value === undefined) {
|
|
446
448
|
return [];
|
|
447
449
|
}
|
|
448
|
-
if (!options.types.some(({ type
|
|
450
|
+
if (!options.types.some(({ type })=>type === coercedType)) {
|
|
449
451
|
if (isOnlyPlugin) {
|
|
450
452
|
_log.default.warn([
|
|
451
453
|
`Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
|
|
452
|
-
`You can safely update it to \`${identifier}-${modifier.replace(coercedType +
|
|
454
|
+
`You can safely update it to \`${identifier}-${modifier.replace(coercedType + ":", "")}\`.`
|
|
453
455
|
]);
|
|
454
456
|
} else {
|
|
455
457
|
return [];
|
|
@@ -462,13 +464,14 @@ function parseVariant(variant) {
|
|
|
462
464
|
get modifier () {
|
|
463
465
|
if (!options.modifiers) {
|
|
464
466
|
_log.default.warn(`modifier-used-without-options-for-${identifier}`, [
|
|
465
|
-
|
|
467
|
+
"Your plugin must set `modifiers: true` in its options to support modifiers."
|
|
466
468
|
]);
|
|
467
469
|
}
|
|
468
470
|
return utilityModifier;
|
|
469
471
|
}
|
|
470
472
|
};
|
|
471
|
-
let
|
|
473
|
+
let modifiersEnabled = (0, _featureFlags.flagEnabled)(tailwindConfig, "generalizedModifiers");
|
|
474
|
+
let ruleSets = [].concat(modifiersEnabled ? rule(value, extras) : rule(value)).filter(Boolean).map((declaration)=>({
|
|
472
475
|
[(0, _nameClass.default)(identifier, modifier)]: declaration
|
|
473
476
|
}));
|
|
474
477
|
return ruleSets;
|
|
@@ -476,7 +479,7 @@ function parseVariant(variant) {
|
|
|
476
479
|
let withOffsets = [
|
|
477
480
|
{
|
|
478
481
|
sort: offset,
|
|
479
|
-
layer:
|
|
482
|
+
layer: "utilities",
|
|
480
483
|
options
|
|
481
484
|
},
|
|
482
485
|
wrapped
|
|
@@ -497,7 +500,7 @@ function parseVariant(variant) {
|
|
|
497
500
|
...defaultOptions,
|
|
498
501
|
...options
|
|
499
502
|
});
|
|
500
|
-
let offset = offsets.create(
|
|
503
|
+
let offset = offsets.create("components");
|
|
501
504
|
for(let identifier in components){
|
|
502
505
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
503
506
|
let rule = components[identifier];
|
|
@@ -505,16 +508,16 @@ function parseVariant(variant) {
|
|
|
505
508
|
prefixedIdentifier,
|
|
506
509
|
options
|
|
507
510
|
]);
|
|
508
|
-
function wrapped(modifier, { isOnlyPlugin
|
|
511
|
+
function wrapped(modifier, { isOnlyPlugin }) {
|
|
509
512
|
let [value, coercedType, utilityModifier] = (0, _pluginUtils.coerceValue)(options.types, modifier, options, tailwindConfig);
|
|
510
513
|
if (value === undefined) {
|
|
511
514
|
return [];
|
|
512
515
|
}
|
|
513
|
-
if (!options.types.some(({ type
|
|
516
|
+
if (!options.types.some(({ type })=>type === coercedType)) {
|
|
514
517
|
if (isOnlyPlugin) {
|
|
515
518
|
_log.default.warn([
|
|
516
519
|
`Unnecessary typehint \`${coercedType}\` in \`${identifier}-${modifier}\`.`,
|
|
517
|
-
`You can safely update it to \`${identifier}-${modifier.replace(coercedType +
|
|
520
|
+
`You can safely update it to \`${identifier}-${modifier.replace(coercedType + ":", "")}\`.`
|
|
518
521
|
]);
|
|
519
522
|
} else {
|
|
520
523
|
return [];
|
|
@@ -527,13 +530,14 @@ function parseVariant(variant) {
|
|
|
527
530
|
get modifier () {
|
|
528
531
|
if (!options.modifiers) {
|
|
529
532
|
_log.default.warn(`modifier-used-without-options-for-${identifier}`, [
|
|
530
|
-
|
|
533
|
+
"Your plugin must set `modifiers: true` in its options to support modifiers."
|
|
531
534
|
]);
|
|
532
535
|
}
|
|
533
536
|
return utilityModifier;
|
|
534
537
|
}
|
|
535
538
|
};
|
|
536
|
-
let
|
|
539
|
+
let modifiersEnabled = (0, _featureFlags.flagEnabled)(tailwindConfig, "generalizedModifiers");
|
|
540
|
+
let ruleSets = [].concat(modifiersEnabled ? rule(value, extras) : rule(value)).filter(Boolean).map((declaration)=>({
|
|
537
541
|
[(0, _nameClass.default)(identifier, modifier)]: declaration
|
|
538
542
|
}));
|
|
539
543
|
return ruleSets;
|
|
@@ -541,7 +545,7 @@ function parseVariant(variant) {
|
|
|
541
545
|
let withOffsets = [
|
|
542
546
|
{
|
|
543
547
|
sort: offset,
|
|
544
|
-
layer:
|
|
548
|
+
layer: "components",
|
|
545
549
|
options
|
|
546
550
|
},
|
|
547
551
|
wrapped
|
|
@@ -554,10 +558,10 @@ function parseVariant(variant) {
|
|
|
554
558
|
},
|
|
555
559
|
addVariant (variantName, variantFunctions, options = {}) {
|
|
556
560
|
variantFunctions = [].concat(variantFunctions).map((variantFunction)=>{
|
|
557
|
-
if (typeof variantFunction !==
|
|
561
|
+
if (typeof variantFunction !== "string") {
|
|
558
562
|
// Safelist public API functions
|
|
559
563
|
return (api = {})=>{
|
|
560
|
-
let { args, modifySelectors, container, separator, wrap, format
|
|
564
|
+
let { args , modifySelectors , container , separator , wrap , format } = api;
|
|
561
565
|
let result = variantFunction(Object.assign({
|
|
562
566
|
modifySelectors,
|
|
563
567
|
container,
|
|
@@ -567,15 +571,15 @@ function parseVariant(variant) {
|
|
|
567
571
|
wrap,
|
|
568
572
|
format
|
|
569
573
|
}));
|
|
570
|
-
if (typeof result ===
|
|
574
|
+
if (typeof result === "string" && !isValidVariantFormatString(result)) {
|
|
571
575
|
throw new Error(`Your custom variant \`${variantName}\` has an invalid format string. Make sure it's an at-rule or contains a \`&\` placeholder.`);
|
|
572
576
|
}
|
|
573
577
|
if (Array.isArray(result)) {
|
|
574
|
-
return result.filter((variant)=>typeof variant ===
|
|
578
|
+
return result.filter((variant)=>typeof variant === "string").map((variant)=>parseVariant(variant));
|
|
575
579
|
}
|
|
576
580
|
// result may be undefined with legacy variants that use APIs like `modifySelectors`
|
|
577
581
|
// result may also be a postcss node if someone was returning the result from `modifySelectors`
|
|
578
|
-
return result && typeof result ===
|
|
582
|
+
return result && typeof result === "string" && parseVariant(result)(api);
|
|
579
583
|
};
|
|
580
584
|
}
|
|
581
585
|
if (!isValidVariantFormatString(variantFunction)) {
|
|
@@ -588,19 +592,20 @@ function parseVariant(variant) {
|
|
|
588
592
|
context.variantOptions.set(variantName, options);
|
|
589
593
|
},
|
|
590
594
|
matchVariant (variant, variantFn, options) {
|
|
591
|
-
var _options, _options1, _options2;
|
|
592
595
|
var _options_id;
|
|
593
596
|
// A unique identifier that "groups" these variants together.
|
|
594
597
|
// This is for internal use only which is why it is not present in the types
|
|
595
|
-
let id = (_options_id =
|
|
596
|
-
let isSpecial = variant ===
|
|
598
|
+
let id = (_options_id = options === null || options === void 0 ? void 0 : options.id) !== null && _options_id !== void 0 ? _options_id : ++variantIdentifier;
|
|
599
|
+
let isSpecial = variant === "@";
|
|
600
|
+
let modifiersEnabled = (0, _featureFlags.flagEnabled)(tailwindConfig, "generalizedModifiers");
|
|
597
601
|
var _options_values;
|
|
598
|
-
for (let [key, value] of Object.entries((_options_values =
|
|
599
|
-
if (key ===
|
|
600
|
-
api.addVariant(isSpecial ? `${variant}${key}` : `${variant}-${key}`, ({ args, container
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
602
|
+
for (let [key, value] of Object.entries((_options_values = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values !== void 0 ? _options_values : {})){
|
|
603
|
+
if (key === "DEFAULT") continue;
|
|
604
|
+
api.addVariant(isSpecial ? `${variant}${key}` : `${variant}-${key}`, ({ args , container })=>{
|
|
605
|
+
return variantFn(value, modifiersEnabled ? {
|
|
606
|
+
modifier: args === null || args === void 0 ? void 0 : args.modifier,
|
|
607
|
+
container
|
|
608
|
+
} : {
|
|
604
609
|
container
|
|
605
610
|
});
|
|
606
611
|
}, {
|
|
@@ -612,16 +617,17 @@ function parseVariant(variant) {
|
|
|
612
617
|
});
|
|
613
618
|
}
|
|
614
619
|
var _options_values1;
|
|
615
|
-
let hasDefault =
|
|
616
|
-
api.addVariant(variant, ({ args, container
|
|
617
|
-
|
|
618
|
-
_args2, _args3;
|
|
619
|
-
if (((_args = args) === null || _args === void 0 ? void 0 : _args.value) === _sharedState.NONE && !hasDefault) {
|
|
620
|
+
let hasDefault = "DEFAULT" in ((_options_values1 = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values1 !== void 0 ? _options_values1 : {});
|
|
621
|
+
api.addVariant(variant, ({ args , container })=>{
|
|
622
|
+
if ((args === null || args === void 0 ? void 0 : args.value) === _sharedState.NONE && !hasDefault) {
|
|
620
623
|
return null;
|
|
621
624
|
}
|
|
622
|
-
var
|
|
623
|
-
|
|
624
|
-
|
|
625
|
+
var // (JetBrains) plugins.
|
|
626
|
+
_args_value;
|
|
627
|
+
return variantFn((args === null || args === void 0 ? void 0 : args.value) === _sharedState.NONE ? options.values.DEFAULT : (_args_value = args === null || args === void 0 ? void 0 : args.value) !== null && _args_value !== void 0 ? _args_value : typeof args === "string" ? args : "", modifiersEnabled ? {
|
|
628
|
+
modifier: args === null || args === void 0 ? void 0 : args.modifier,
|
|
629
|
+
container
|
|
630
|
+
} : {
|
|
625
631
|
container
|
|
626
632
|
});
|
|
627
633
|
}, {
|
|
@@ -648,8 +654,8 @@ function trackModified(files, fileModifiedMap) {
|
|
|
648
654
|
var _fs_statSync;
|
|
649
655
|
if (!file) continue;
|
|
650
656
|
let parsed = _url.default.parse(file);
|
|
651
|
-
let pathname = parsed.hash ? parsed.href.replace(parsed.hash,
|
|
652
|
-
pathname = parsed.search ? pathname.replace(parsed.search,
|
|
657
|
+
let pathname = parsed.hash ? parsed.href.replace(parsed.hash, "") : parsed.href;
|
|
658
|
+
pathname = parsed.search ? pathname.replace(parsed.search, "") : pathname;
|
|
653
659
|
let newModified = (_fs_statSync = _fs.default.statSync(decodeURIComponent(pathname), {
|
|
654
660
|
throwIfNoEntry: false
|
|
655
661
|
})) === null || _fs_statSync === void 0 ? void 0 : _fs_statSync.mtimeMs;
|
|
@@ -669,8 +675,8 @@ function trackModified(files, fileModifiedMap) {
|
|
|
669
675
|
function extractVariantAtRules(node) {
|
|
670
676
|
node.walkAtRules((atRule)=>{
|
|
671
677
|
if ([
|
|
672
|
-
|
|
673
|
-
|
|
678
|
+
"responsive",
|
|
679
|
+
"variants"
|
|
674
680
|
].includes(atRule.name)) {
|
|
675
681
|
extractVariantAtRules(atRule);
|
|
676
682
|
atRule.before(atRule.nodes);
|
|
@@ -681,29 +687,29 @@ function extractVariantAtRules(node) {
|
|
|
681
687
|
function collectLayerPlugins(root) {
|
|
682
688
|
let layerPlugins = [];
|
|
683
689
|
root.each((node)=>{
|
|
684
|
-
if (node.type ===
|
|
685
|
-
|
|
686
|
-
|
|
690
|
+
if (node.type === "atrule" && [
|
|
691
|
+
"responsive",
|
|
692
|
+
"variants"
|
|
687
693
|
].includes(node.name)) {
|
|
688
|
-
node.name =
|
|
689
|
-
node.params =
|
|
694
|
+
node.name = "layer";
|
|
695
|
+
node.params = "utilities";
|
|
690
696
|
}
|
|
691
697
|
});
|
|
692
698
|
// Walk @layer rules and treat them like plugins
|
|
693
|
-
root.walkAtRules(
|
|
699
|
+
root.walkAtRules("layer", (layerRule)=>{
|
|
694
700
|
extractVariantAtRules(layerRule);
|
|
695
|
-
if (layerRule.params ===
|
|
701
|
+
if (layerRule.params === "base") {
|
|
696
702
|
for (let node of layerRule.nodes){
|
|
697
|
-
layerPlugins.push(function({ addBase
|
|
703
|
+
layerPlugins.push(function({ addBase }) {
|
|
698
704
|
addBase(node, {
|
|
699
705
|
respectPrefix: false
|
|
700
706
|
});
|
|
701
707
|
});
|
|
702
708
|
}
|
|
703
709
|
layerRule.remove();
|
|
704
|
-
} else if (layerRule.params ===
|
|
710
|
+
} else if (layerRule.params === "components") {
|
|
705
711
|
for (let node of layerRule.nodes){
|
|
706
|
-
layerPlugins.push(function({ addComponents
|
|
712
|
+
layerPlugins.push(function({ addComponents }) {
|
|
707
713
|
addComponents(node, {
|
|
708
714
|
respectPrefix: false,
|
|
709
715
|
preserveSource: true
|
|
@@ -711,9 +717,9 @@ function collectLayerPlugins(root) {
|
|
|
711
717
|
});
|
|
712
718
|
}
|
|
713
719
|
layerRule.remove();
|
|
714
|
-
} else if (layerRule.params ===
|
|
720
|
+
} else if (layerRule.params === "utilities") {
|
|
715
721
|
for (let node of layerRule.nodes){
|
|
716
|
-
layerPlugins.push(function({ addUtilities
|
|
722
|
+
layerPlugins.push(function({ addUtilities }) {
|
|
717
723
|
addUtilities(node, {
|
|
718
724
|
respectPrefix: false,
|
|
719
725
|
preserveSource: true
|
|
@@ -726,7 +732,10 @@ function collectLayerPlugins(root) {
|
|
|
726
732
|
return layerPlugins;
|
|
727
733
|
}
|
|
728
734
|
function resolvePlugins(context, root) {
|
|
729
|
-
let corePluginList = Object.entries(
|
|
735
|
+
let corePluginList = Object.entries({
|
|
736
|
+
..._corePlugins.variantPlugins,
|
|
737
|
+
..._corePlugins.corePlugins
|
|
738
|
+
}).map(([name, plugin])=>{
|
|
730
739
|
if (!context.tailwindConfig.corePlugins.includes(name)) {
|
|
731
740
|
return null;
|
|
732
741
|
}
|
|
@@ -736,28 +745,46 @@ function resolvePlugins(context, root) {
|
|
|
736
745
|
if (plugin.__isOptionsFunction) {
|
|
737
746
|
plugin = plugin();
|
|
738
747
|
}
|
|
739
|
-
return typeof plugin ===
|
|
748
|
+
return typeof plugin === "function" ? plugin : plugin.handler;
|
|
740
749
|
});
|
|
741
750
|
let layerPlugins = collectLayerPlugins(root);
|
|
742
751
|
// TODO: This is a workaround for backwards compatibility, since custom variants
|
|
743
752
|
// were historically sorted before screen/stackable variants.
|
|
744
753
|
let beforeVariants = [
|
|
745
|
-
_corePlugins.variantPlugins[
|
|
746
|
-
_corePlugins.variantPlugins[
|
|
747
|
-
_corePlugins.variantPlugins[
|
|
748
|
-
_corePlugins.variantPlugins[
|
|
749
|
-
_corePlugins.variantPlugins[
|
|
754
|
+
_corePlugins.variantPlugins["childVariant"],
|
|
755
|
+
_corePlugins.variantPlugins["pseudoElementVariants"],
|
|
756
|
+
_corePlugins.variantPlugins["pseudoClassVariants"],
|
|
757
|
+
_corePlugins.variantPlugins["hasVariants"],
|
|
758
|
+
_corePlugins.variantPlugins["ariaVariants"],
|
|
759
|
+
_corePlugins.variantPlugins["dataVariants"]
|
|
750
760
|
];
|
|
751
761
|
let afterVariants = [
|
|
752
|
-
_corePlugins.variantPlugins[
|
|
753
|
-
_corePlugins.variantPlugins[
|
|
754
|
-
_corePlugins.variantPlugins[
|
|
755
|
-
_corePlugins.variantPlugins[
|
|
756
|
-
_corePlugins.variantPlugins[
|
|
757
|
-
_corePlugins.variantPlugins[
|
|
758
|
-
_corePlugins.variantPlugins[
|
|
759
|
-
_corePlugins.variantPlugins[
|
|
762
|
+
_corePlugins.variantPlugins["supportsVariants"],
|
|
763
|
+
_corePlugins.variantPlugins["reducedMotionVariants"],
|
|
764
|
+
_corePlugins.variantPlugins["prefersContrastVariants"],
|
|
765
|
+
_corePlugins.variantPlugins["screenVariants"],
|
|
766
|
+
_corePlugins.variantPlugins["orientationVariants"],
|
|
767
|
+
_corePlugins.variantPlugins["directionVariants"],
|
|
768
|
+
_corePlugins.variantPlugins["darkVariants"],
|
|
769
|
+
_corePlugins.variantPlugins["forcedColorsVariants"],
|
|
770
|
+
_corePlugins.variantPlugins["printVariant"]
|
|
760
771
|
];
|
|
772
|
+
// This is a compatibility fix for the pre 3.4 dark mode behavior
|
|
773
|
+
// `class` retains the old behavior, but `selector` keeps the new behavior
|
|
774
|
+
let isLegacyDarkMode = context.tailwindConfig.darkMode === "class" || Array.isArray(context.tailwindConfig.darkMode) && context.tailwindConfig.darkMode[0] === "class";
|
|
775
|
+
if (isLegacyDarkMode) {
|
|
776
|
+
afterVariants = [
|
|
777
|
+
_corePlugins.variantPlugins["supportsVariants"],
|
|
778
|
+
_corePlugins.variantPlugins["reducedMotionVariants"],
|
|
779
|
+
_corePlugins.variantPlugins["prefersContrastVariants"],
|
|
780
|
+
_corePlugins.variantPlugins["darkVariants"],
|
|
781
|
+
_corePlugins.variantPlugins["screenVariants"],
|
|
782
|
+
_corePlugins.variantPlugins["orientationVariants"],
|
|
783
|
+
_corePlugins.variantPlugins["directionVariants"],
|
|
784
|
+
_corePlugins.variantPlugins["forcedColorsVariants"],
|
|
785
|
+
_corePlugins.variantPlugins["printVariant"]
|
|
786
|
+
];
|
|
787
|
+
}
|
|
761
788
|
return [
|
|
762
789
|
...corePluginList,
|
|
763
790
|
...beforeVariants,
|
|
@@ -785,8 +812,7 @@ function registerPlugins(plugins, context) {
|
|
|
785
812
|
pluginItem(pluginApi);
|
|
786
813
|
}
|
|
787
814
|
} else {
|
|
788
|
-
|
|
789
|
-
(_plugin = plugin) === null || _plugin === void 0 ? void 0 : _plugin(pluginApi);
|
|
815
|
+
plugin === null || plugin === void 0 ? void 0 : plugin(pluginApi);
|
|
790
816
|
}
|
|
791
817
|
}
|
|
792
818
|
// Make sure to record bit masks for every variant
|
|
@@ -803,18 +829,18 @@ function registerPlugins(plugins, context) {
|
|
|
803
829
|
if (safelist.length > 0) {
|
|
804
830
|
let checks = [];
|
|
805
831
|
for (let value of safelist){
|
|
806
|
-
if (typeof value ===
|
|
832
|
+
if (typeof value === "string") {
|
|
807
833
|
context.changedContent.push({
|
|
808
834
|
content: value,
|
|
809
|
-
extension:
|
|
835
|
+
extension: "html"
|
|
810
836
|
});
|
|
811
837
|
continue;
|
|
812
838
|
}
|
|
813
839
|
if (value instanceof RegExp) {
|
|
814
|
-
_log.default.warn(
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
840
|
+
_log.default.warn("root-regex", [
|
|
841
|
+
"Regular expressions in `safelist` work differently in Tailwind CSS v3.0.",
|
|
842
|
+
"Update your `safelist` configuration to eliminate this warning.",
|
|
843
|
+
"https://tailwindcss.com/docs/content-configuration#safelisting-classes"
|
|
818
844
|
]);
|
|
819
845
|
continue;
|
|
820
846
|
}
|
|
@@ -823,20 +849,19 @@ function registerPlugins(plugins, context) {
|
|
|
823
849
|
if (checks.length > 0) {
|
|
824
850
|
let patternMatchingCount = new Map();
|
|
825
851
|
let prefixLength = context.tailwindConfig.prefix.length;
|
|
826
|
-
let checkImportantUtils = checks.some((check)=>check.pattern.source.includes(
|
|
852
|
+
let checkImportantUtils = checks.some((check)=>check.pattern.source.includes("!"));
|
|
827
853
|
for (let util of classList){
|
|
828
854
|
let utils = Array.isArray(util) ? (()=>{
|
|
829
|
-
var _options, _options1, _options2;
|
|
830
855
|
let [utilName, options] = util;
|
|
831
856
|
var _options_values;
|
|
832
|
-
let values = Object.keys((_options_values =
|
|
857
|
+
let values = Object.keys((_options_values = options === null || options === void 0 ? void 0 : options.values) !== null && _options_values !== void 0 ? _options_values : {});
|
|
833
858
|
let classes = values.map((value)=>(0, _nameClass.formatClass)(utilName, value));
|
|
834
|
-
if (
|
|
859
|
+
if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
|
|
835
860
|
// This is the normal negated version
|
|
836
861
|
// e.g. `-inset-1` or `-tw-inset-1`
|
|
837
862
|
classes = [
|
|
838
863
|
...classes,
|
|
839
|
-
...classes.map((cls)=>
|
|
864
|
+
...classes.map((cls)=>"-" + cls)
|
|
840
865
|
];
|
|
841
866
|
// This is the negated version *after* the prefix
|
|
842
867
|
// e.g. `tw--inset-1`
|
|
@@ -844,19 +869,19 @@ function registerPlugins(plugins, context) {
|
|
|
844
869
|
// So we add the negative after the prefix
|
|
845
870
|
classes = [
|
|
846
871
|
...classes,
|
|
847
|
-
...classes.map((cls)=>cls.slice(0, prefixLength) +
|
|
872
|
+
...classes.map((cls)=>cls.slice(0, prefixLength) + "-" + cls.slice(prefixLength))
|
|
848
873
|
];
|
|
849
874
|
}
|
|
850
|
-
if (options.types.some(({ type
|
|
875
|
+
if (options.types.some(({ type })=>type === "color")) {
|
|
851
876
|
classes = [
|
|
852
877
|
...classes,
|
|
853
878
|
...classes.flatMap((cls)=>Object.keys(context.tailwindConfig.theme.opacity).map((opacity)=>`${cls}/${opacity}`))
|
|
854
879
|
];
|
|
855
880
|
}
|
|
856
|
-
if (checkImportantUtils && (
|
|
881
|
+
if (checkImportantUtils && (options === null || options === void 0 ? void 0 : options.respectImportant)) {
|
|
857
882
|
classes = [
|
|
858
883
|
...classes,
|
|
859
|
-
...classes.map((cls)=>
|
|
884
|
+
...classes.map((cls)=>"!" + cls)
|
|
860
885
|
];
|
|
861
886
|
}
|
|
862
887
|
return classes;
|
|
@@ -864,7 +889,7 @@ function registerPlugins(plugins, context) {
|
|
|
864
889
|
util
|
|
865
890
|
];
|
|
866
891
|
for (let util of utils){
|
|
867
|
-
for (let { pattern, variants =
|
|
892
|
+
for (let { pattern , variants =[] } of checks){
|
|
868
893
|
// RegExp with the /g flag are stateful, so let's reset the last
|
|
869
894
|
// index pointer to reset the state.
|
|
870
895
|
pattern.lastIndex = 0;
|
|
@@ -875,12 +900,12 @@ function registerPlugins(plugins, context) {
|
|
|
875
900
|
patternMatchingCount.set(pattern, patternMatchingCount.get(pattern) + 1);
|
|
876
901
|
context.changedContent.push({
|
|
877
902
|
content: util,
|
|
878
|
-
extension:
|
|
903
|
+
extension: "html"
|
|
879
904
|
});
|
|
880
905
|
for (let variant of variants){
|
|
881
906
|
context.changedContent.push({
|
|
882
907
|
content: variant + context.tailwindConfig.separator + util,
|
|
883
|
-
extension:
|
|
908
|
+
extension: "html"
|
|
884
909
|
});
|
|
885
910
|
}
|
|
886
911
|
}
|
|
@@ -890,22 +915,22 @@ function registerPlugins(plugins, context) {
|
|
|
890
915
|
if (count !== 0) continue;
|
|
891
916
|
_log.default.warn([
|
|
892
917
|
`The safelist pattern \`${regex}\` doesn't match any Tailwind CSS classes.`,
|
|
893
|
-
|
|
894
|
-
|
|
918
|
+
"Fix this pattern or remove it from your `safelist` configuration.",
|
|
919
|
+
"https://tailwindcss.com/docs/content-configuration#safelisting-classes"
|
|
895
920
|
]);
|
|
896
921
|
}
|
|
897
922
|
}
|
|
898
923
|
}
|
|
899
924
|
var _context_tailwindConfig_darkMode, _concat_;
|
|
900
|
-
let darkClassName = (_concat_ = [].concat((_context_tailwindConfig_darkMode = context.tailwindConfig.darkMode) !== null && _context_tailwindConfig_darkMode !== void 0 ? _context_tailwindConfig_darkMode :
|
|
925
|
+
let darkClassName = (_concat_ = [].concat((_context_tailwindConfig_darkMode = context.tailwindConfig.darkMode) !== null && _context_tailwindConfig_darkMode !== void 0 ? _context_tailwindConfig_darkMode : "media")[1]) !== null && _concat_ !== void 0 ? _concat_ : "dark";
|
|
901
926
|
// A list of utilities that are used by certain Tailwind CSS utilities but
|
|
902
927
|
// that don't exist on their own. This will result in them "not existing" and
|
|
903
928
|
// sorting could be weird since you still require them in order to make the
|
|
904
929
|
// host utilities work properly. (Thanks Biology)
|
|
905
930
|
let parasiteUtilities = [
|
|
906
931
|
prefix(context, darkClassName),
|
|
907
|
-
prefix(context,
|
|
908
|
-
prefix(context,
|
|
932
|
+
prefix(context, "group"),
|
|
933
|
+
prefix(context, "peer")
|
|
909
934
|
];
|
|
910
935
|
context.getClassOrder = function getClassOrder(classes) {
|
|
911
936
|
// Sort classes so they're ordered in a deterministic manner
|
|
@@ -923,7 +948,7 @@ function registerPlugins(plugins, context) {
|
|
|
923
948
|
]));
|
|
924
949
|
// Sort all classes in order
|
|
925
950
|
// Non-tailwind classes won't be generated and will be left as `null`
|
|
926
|
-
let rules = (0, _generateRules.generateRules)(new Set(sorted), context);
|
|
951
|
+
let rules = (0, _generateRules.generateRules)(new Set(sorted), context, true);
|
|
927
952
|
rules = context.offsets.sort(rules);
|
|
928
953
|
let idx = BigInt(parasiteUtilities.length);
|
|
929
954
|
for (const [, rule] of rules){
|
|
@@ -955,12 +980,12 @@ function registerPlugins(plugins, context) {
|
|
|
955
980
|
let output = [];
|
|
956
981
|
for (let util of classList){
|
|
957
982
|
if (Array.isArray(util)) {
|
|
958
|
-
var
|
|
983
|
+
var _utilOptions_types;
|
|
959
984
|
let [utilName, utilOptions] = util;
|
|
960
985
|
let negativeClasses = [];
|
|
961
986
|
var _utilOptions_modifiers;
|
|
962
|
-
let modifiers = Object.keys((_utilOptions_modifiers =
|
|
963
|
-
if (
|
|
987
|
+
let modifiers = Object.keys((_utilOptions_modifiers = utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.modifiers) !== null && _utilOptions_modifiers !== void 0 ? _utilOptions_modifiers : {});
|
|
988
|
+
if (utilOptions === null || utilOptions === void 0 ? void 0 : (_utilOptions_types = utilOptions.types) === null || _utilOptions_types === void 0 ? void 0 : _utilOptions_types.some(({ type })=>type === "color")) {
|
|
964
989
|
var _context_tailwindConfig_theme_opacity;
|
|
965
990
|
modifiers.push(...Object.keys((_context_tailwindConfig_theme_opacity = context.tailwindConfig.theme.opacity) !== null && _context_tailwindConfig_theme_opacity !== void 0 ? _context_tailwindConfig_theme_opacity : {}));
|
|
966
991
|
}
|
|
@@ -969,8 +994,7 @@ function registerPlugins(plugins, context) {
|
|
|
969
994
|
};
|
|
970
995
|
let includeMetadata = options.includeMetadata && modifiers.length > 0;
|
|
971
996
|
var _utilOptions_values;
|
|
972
|
-
for (let [key, value] of Object.entries((_utilOptions_values =
|
|
973
|
-
var _utilOptions3;
|
|
997
|
+
for (let [key, value] of Object.entries((_utilOptions_values = utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.values) !== null && _utilOptions_values !== void 0 ? _utilOptions_values : {})){
|
|
974
998
|
// Ignore undefined and null values
|
|
975
999
|
if (value == null) {
|
|
976
1000
|
continue;
|
|
@@ -980,7 +1004,7 @@ function registerPlugins(plugins, context) {
|
|
|
980
1004
|
cls,
|
|
981
1005
|
metadata
|
|
982
1006
|
] : cls);
|
|
983
|
-
if ((
|
|
1007
|
+
if ((utilOptions === null || utilOptions === void 0 ? void 0 : utilOptions.supportsNegativeValues) && (0, _negateValue.default)(value)) {
|
|
984
1008
|
let cls = (0, _nameClass.formatClass)(utilName, `-${key}`);
|
|
985
1009
|
negativeClasses.push(includeMetadata ? [
|
|
986
1010
|
cls,
|
|
@@ -997,17 +1021,21 @@ function registerPlugins(plugins, context) {
|
|
|
997
1021
|
};
|
|
998
1022
|
// Generate a list of available variants with meta information of the type of variant.
|
|
999
1023
|
context.getVariants = function getVariants() {
|
|
1024
|
+
// We use a unique, random ID for candidate names to avoid conflicts
|
|
1025
|
+
// We can't use characters like `_`, `:`, `@` or `.` because they might
|
|
1026
|
+
// be used as a separator
|
|
1027
|
+
let id = Math.random().toString(36).substring(7).toUpperCase();
|
|
1000
1028
|
let result = [];
|
|
1001
1029
|
for (let [name, options] of context.variantOptions.entries()){
|
|
1002
1030
|
if (options.variantInfo === VARIANT_INFO.Base) continue;
|
|
1003
1031
|
var _options_values;
|
|
1004
1032
|
result.push({
|
|
1005
1033
|
name,
|
|
1006
|
-
isArbitrary: options.type === Symbol.for(
|
|
1034
|
+
isArbitrary: options.type === Symbol.for("MATCH_VARIANT"),
|
|
1007
1035
|
values: Object.keys((_options_values = options.values) !== null && _options_values !== void 0 ? _options_values : {}),
|
|
1008
|
-
hasDash: name !==
|
|
1009
|
-
selectors ({ modifier, value
|
|
1010
|
-
let candidate =
|
|
1036
|
+
hasDash: name !== "@",
|
|
1037
|
+
selectors ({ modifier , value } = {}) {
|
|
1038
|
+
let candidate = `TAILWINDPLACEHOLDER${id}`;
|
|
1011
1039
|
let rule = _postcss.default.rule({
|
|
1012
1040
|
selector: `.${candidate}`
|
|
1013
1041
|
});
|
|
@@ -1033,7 +1061,7 @@ function registerPlugins(plugins, context) {
|
|
|
1033
1061
|
modifySelectors (modifierFunction) {
|
|
1034
1062
|
// Run the modifierFunction over each rule
|
|
1035
1063
|
container.each((rule)=>{
|
|
1036
|
-
if (rule.type !==
|
|
1064
|
+
if (rule.type !== "rule") {
|
|
1037
1065
|
return;
|
|
1038
1066
|
}
|
|
1039
1067
|
rule.selectors = rule.selectors.map((selector)=>{
|
|
@@ -1094,7 +1122,7 @@ function registerPlugins(plugins, context) {
|
|
|
1094
1122
|
// modified (by plugin): .foo .foo\\:markdown > p
|
|
1095
1123
|
// rebuiltBase (internal): .foo\\:markdown > p
|
|
1096
1124
|
// format: .foo &
|
|
1097
|
-
manualFormatStrings.push(modified.replace(rebuiltBase,
|
|
1125
|
+
manualFormatStrings.push(modified.replace(rebuiltBase, "&").replace(candidate, "&"));
|
|
1098
1126
|
});
|
|
1099
1127
|
// Figure out all atrules
|
|
1100
1128
|
container.walkAtRules((atrule)=>{
|
|
@@ -1122,9 +1150,9 @@ function registerPlugins(plugins, context) {
|
|
|
1122
1150
|
candidate,
|
|
1123
1151
|
context
|
|
1124
1152
|
};
|
|
1125
|
-
let result = formatStrings.map((formats)=>(0, _formatVariantSelector.finalizeSelector)(`.${candidate}`, (0, _formatVariantSelector.formatVariantSelector)(formats, opts), opts).replace(`.${candidate}`,
|
|
1153
|
+
let result = formatStrings.map((formats)=>(0, _formatVariantSelector.finalizeSelector)(`.${candidate}`, (0, _formatVariantSelector.formatVariantSelector)(formats, opts), opts).replace(`.${candidate}`, "&").replace("{ & }", "").trim());
|
|
1126
1154
|
if (manualFormatStrings.length > 0) {
|
|
1127
|
-
result.push((0, _formatVariantSelector.formatVariantSelector)(manualFormatStrings, opts).toString().replace(`.${candidate}`,
|
|
1155
|
+
result.push((0, _formatVariantSelector.formatVariantSelector)(manualFormatStrings, opts).toString().replace(`.${candidate}`, "&"));
|
|
1128
1156
|
}
|
|
1129
1157
|
return result;
|
|
1130
1158
|
}
|
|
@@ -1199,7 +1227,7 @@ let contextSourcesMap = _sharedState.contextSourcesMap;
|
|
|
1199
1227
|
function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies) {
|
|
1200
1228
|
let sourcePath = result.opts.from;
|
|
1201
1229
|
let isConfigFile = userConfigPath !== null;
|
|
1202
|
-
_sharedState.env.DEBUG && console.log(
|
|
1230
|
+
_sharedState.env.DEBUG && console.log("Source path:", sourcePath);
|
|
1203
1231
|
let existingContext;
|
|
1204
1232
|
if (isConfigFile && contextMap.has(sourcePath)) {
|
|
1205
1233
|
existingContext = contextMap.get(sourcePath);
|
|
@@ -1246,7 +1274,7 @@ function getContext(root, result, tailwindConfig, userConfigPath, tailwindConfig
|
|
|
1246
1274
|
}
|
|
1247
1275
|
}
|
|
1248
1276
|
}
|
|
1249
|
-
_sharedState.env.DEBUG && console.log(
|
|
1277
|
+
_sharedState.env.DEBUG && console.log("Setting up new context...");
|
|
1250
1278
|
let context = createContext(tailwindConfig, [], root);
|
|
1251
1279
|
Object.assign(context, {
|
|
1252
1280
|
userConfigPath
|