tailwindcss 3.0.0-alpha.1 → 3.0.0-alpha.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/CHANGELOG.md +67 -1
- package/lib/cli.js +66 -62
- package/lib/constants.js +1 -1
- package/lib/corePluginList.js +7 -1
- package/lib/corePlugins.js +264 -203
- package/lib/css/preflight.css +12 -0
- package/lib/featureFlags.js +10 -7
- package/lib/lib/collapseDuplicateDeclarations.js +29 -0
- package/lib/lib/evaluateTailwindFunctions.js +3 -3
- package/lib/lib/expandApplyAtRules.js +7 -7
- package/lib/lib/expandTailwindAtRules.js +2 -1
- package/lib/lib/generateRules.js +115 -19
- package/lib/lib/resolveDefaultsAtRules.js +44 -47
- package/lib/lib/setupContextUtils.js +72 -15
- package/lib/lib/setupWatchingContext.js +5 -1
- package/lib/lib/sharedState.js +2 -2
- package/lib/processTailwindFeatures.js +4 -0
- package/lib/util/createUtilityPlugin.js +5 -5
- package/lib/util/dataTypes.js +24 -4
- package/lib/util/formatVariantSelector.js +102 -0
- package/lib/util/nameClass.js +1 -1
- package/lib/util/negateValue.js +3 -1
- package/lib/util/normalizeConfig.js +22 -8
- 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 +13 -9
- package/lib/util/transformThemeValue.js +23 -13
- package/package.json +11 -11
- package/peers/index.js +873 -2505
- package/src/cli.js +9 -2
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +282 -348
- package/src/css/preflight.css +12 -0
- package/src/featureFlags.js +10 -4
- package/src/lib/collapseDuplicateDeclarations.js +28 -0
- package/src/lib/expandTailwindAtRules.js +3 -2
- package/src/lib/generateRules.js +121 -11
- package/src/lib/resolveDefaultsAtRules.js +39 -43
- package/src/lib/setupContextUtils.js +71 -9
- package/src/lib/setupWatchingContext.js +7 -0
- package/src/lib/sharedState.js +1 -1
- package/src/processTailwindFeatures.js +5 -0
- package/src/util/createUtilityPlugin.js +2 -2
- package/src/util/dataTypes.js +32 -5
- package/src/util/formatVariantSelector.js +105 -0
- package/src/util/nameClass.js +1 -1
- package/src/util/negateValue.js +4 -2
- package/src/util/normalizeConfig.js +17 -1
- 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 +101 -58
- package/peers/.svgo.yml +0 -75
- package/peers/orders/concentric-css.json +0 -299
- package/peers/orders/smacss.json +0 -299
- package/peers/orders/source.json +0 -295
- package/src/.DS_Store +0 -0
|
@@ -22,6 +22,7 @@ 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"));
|
|
25
26
|
function _interopRequireDefault(obj) {
|
|
26
27
|
return obj && obj.__esModule ? obj : {
|
|
27
28
|
default: obj
|
|
@@ -50,6 +51,30 @@ function _interopRequireWildcard(obj) {
|
|
|
50
51
|
return newObj;
|
|
51
52
|
}
|
|
52
53
|
}
|
|
54
|
+
function parseVariantFormatString(input) {
|
|
55
|
+
if (input.includes('{')) {
|
|
56
|
+
if (!isBalanced(input)) throw new Error(`Your { and } are unbalanced.`);
|
|
57
|
+
return input.split(/{(.*)}/gim).flatMap((line)=>parseVariantFormatString(line)
|
|
58
|
+
).filter(Boolean);
|
|
59
|
+
}
|
|
60
|
+
return [
|
|
61
|
+
input.trim()
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
function isBalanced(input) {
|
|
65
|
+
let count = 0;
|
|
66
|
+
for (let char of input){
|
|
67
|
+
if (char === '{') {
|
|
68
|
+
count++;
|
|
69
|
+
} else if (char === '}') {
|
|
70
|
+
if (--count < 0) {
|
|
71
|
+
return false // unbalanced
|
|
72
|
+
;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return count === 0;
|
|
77
|
+
}
|
|
53
78
|
function insertInto(list, value, { before =[] } = {
|
|
54
79
|
}) {
|
|
55
80
|
before = [].concat(before);
|
|
@@ -211,15 +236,41 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
211
236
|
if (!options.respectPrefix) {
|
|
212
237
|
return identifier;
|
|
213
238
|
}
|
|
214
|
-
if (typeof context.tailwindConfig.prefix === 'function') {
|
|
215
|
-
return (0, _prefixSelector).default(context.tailwindConfig.prefix, `.${identifier}`).substr(1);
|
|
216
|
-
}
|
|
217
239
|
return context.tailwindConfig.prefix + identifier;
|
|
218
240
|
}
|
|
219
241
|
return {
|
|
220
242
|
addVariant (variantName, variantFunctions, options = {
|
|
221
243
|
}) {
|
|
222
|
-
variantFunctions = [].concat(variantFunctions)
|
|
244
|
+
variantFunctions = [].concat(variantFunctions).map((variantFunction)=>{
|
|
245
|
+
if (typeof variantFunction !== 'string') {
|
|
246
|
+
// Safelist public API functions
|
|
247
|
+
return ({ modifySelectors , container , separator })=>{
|
|
248
|
+
return variantFunction({
|
|
249
|
+
modifySelectors,
|
|
250
|
+
container,
|
|
251
|
+
separator
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
variantFunction = variantFunction.replace(/\n+/g, '').replace(/\s{1,}/g, ' ').trim();
|
|
256
|
+
let fns = parseVariantFormatString(variantFunction).map((str)=>{
|
|
257
|
+
if (!str.startsWith('@')) {
|
|
258
|
+
return ({ format })=>format(str)
|
|
259
|
+
;
|
|
260
|
+
}
|
|
261
|
+
let [, name, params] = /@(.*?) (.*)/g.exec(str);
|
|
262
|
+
return ({ wrap })=>wrap(_postcss.default.atRule({
|
|
263
|
+
name,
|
|
264
|
+
params
|
|
265
|
+
}))
|
|
266
|
+
;
|
|
267
|
+
}).reverse();
|
|
268
|
+
return (api)=>{
|
|
269
|
+
for (let fn of fns){
|
|
270
|
+
fn(api);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
});
|
|
223
274
|
insertInto(variantList, variantName, options);
|
|
224
275
|
variantMap.set(variantName, variantFunctions);
|
|
225
276
|
},
|
|
@@ -351,7 +402,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
351
402
|
function wrapped(modifier, { isOnlyPlugin }) {
|
|
352
403
|
let { type ='any' } = options;
|
|
353
404
|
type = [].concat(type);
|
|
354
|
-
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options
|
|
405
|
+
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options, tailwindConfig);
|
|
355
406
|
if (value === undefined) {
|
|
356
407
|
return [];
|
|
357
408
|
}
|
|
@@ -401,7 +452,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
401
452
|
function wrapped(modifier, { isOnlyPlugin }) {
|
|
402
453
|
let { type ='any' } = options;
|
|
403
454
|
type = [].concat(type);
|
|
404
|
-
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options
|
|
455
|
+
let [value, coercedType] = (0, _pluginUtils).coerceValue(type, modifier, options, tailwindConfig);
|
|
405
456
|
if (value === undefined) {
|
|
406
457
|
return [];
|
|
407
458
|
}
|
|
@@ -556,6 +607,7 @@ function resolvePlugins(context, root) {
|
|
|
556
607
|
_corePlugins.variantPlugins['directionVariants'],
|
|
557
608
|
_corePlugins.variantPlugins['reducedMotionVariants'],
|
|
558
609
|
_corePlugins.variantPlugins['darkVariants'],
|
|
610
|
+
_corePlugins.variantPlugins['printVariant'],
|
|
559
611
|
_corePlugins.variantPlugins['screenVariants'],
|
|
560
612
|
];
|
|
561
613
|
return [
|
|
@@ -622,9 +674,9 @@ function registerPlugins(plugins, context) {
|
|
|
622
674
|
...context.variantOrder.values()
|
|
623
675
|
].shift();
|
|
624
676
|
// Build variantMap
|
|
625
|
-
for (let [variantName,
|
|
677
|
+
for (let [variantName, variantFunctions1] of variantMap.entries()){
|
|
626
678
|
let sort = context.variantOrder.get(variantName);
|
|
627
|
-
context.variantMap.set(variantName,
|
|
679
|
+
context.variantMap.set(variantName, variantFunctions1.map((variantFunction, idx)=>[
|
|
628
680
|
sort << BigInt(idx),
|
|
629
681
|
variantFunction
|
|
630
682
|
]
|
|
@@ -634,22 +686,22 @@ function registerPlugins(plugins, context) {
|
|
|
634
686
|
let safelist = ((_safelist = context.tailwindConfig.safelist) !== null && _safelist !== void 0 ? _safelist : []).filter(Boolean);
|
|
635
687
|
if (safelist.length > 0) {
|
|
636
688
|
let checks = [];
|
|
637
|
-
for (let
|
|
638
|
-
if (typeof
|
|
689
|
+
for (let value1 of safelist){
|
|
690
|
+
if (typeof value1 === 'string') {
|
|
639
691
|
context.changedContent.push({
|
|
640
|
-
content:
|
|
692
|
+
content: value1,
|
|
641
693
|
extension: 'html'
|
|
642
694
|
});
|
|
643
695
|
continue;
|
|
644
696
|
}
|
|
645
|
-
if (
|
|
697
|
+
if (value1 instanceof RegExp) {
|
|
646
698
|
_log.default.warn('root-regex', [
|
|
647
699
|
'Regular expressions in `safelist` work differently in Tailwind CSS v3.0.',
|
|
648
700
|
'Update your `safelist` configuration to eliminate this warning.'
|
|
649
701
|
]);
|
|
650
702
|
continue;
|
|
651
703
|
}
|
|
652
|
-
checks.push(
|
|
704
|
+
checks.push(value1);
|
|
653
705
|
}
|
|
654
706
|
if (checks.length > 0) {
|
|
655
707
|
let patternMatchingCount = new Map();
|
|
@@ -702,11 +754,16 @@ function registerPlugins(plugins, context) {
|
|
|
702
754
|
for (let util of classList){
|
|
703
755
|
if (Array.isArray(util)) {
|
|
704
756
|
let [utilName, options] = util;
|
|
757
|
+
let negativeClasses = [];
|
|
705
758
|
var ref;
|
|
706
|
-
for (let value of Object.
|
|
759
|
+
for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
|
|
707
760
|
})){
|
|
708
|
-
output.push((0, _nameClass).formatClass(utilName,
|
|
761
|
+
output.push((0, _nameClass).formatClass(utilName, key));
|
|
762
|
+
if ((options === null || options === void 0 ? void 0 : options.supportsNegativeValues) && (0, _negateValue).default(value)) {
|
|
763
|
+
negativeClasses.push((0, _nameClass).formatClass(utilName, `-${key}`));
|
|
764
|
+
}
|
|
709
765
|
}
|
|
766
|
+
output.push(...negativeClasses);
|
|
710
767
|
} else {
|
|
711
768
|
output.push(util);
|
|
712
769
|
}
|
|
@@ -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
|
};
|
|
@@ -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
|
}
|
|
@@ -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
|
};
|
package/lib/util/dataTypes.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.number = number;
|
|
|
8
8
|
exports.percentage = percentage;
|
|
9
9
|
exports.length = length;
|
|
10
10
|
exports.lineWidth = lineWidth;
|
|
11
|
+
exports.shadow = shadow;
|
|
11
12
|
exports.color = color;
|
|
12
13
|
exports.image = image;
|
|
13
14
|
exports.gradient = gradient;
|
|
@@ -17,19 +18,29 @@ exports.genericName = genericName;
|
|
|
17
18
|
exports.absoluteSize = absoluteSize;
|
|
18
19
|
exports.relativeSize = relativeSize;
|
|
19
20
|
var _color = require("./color");
|
|
21
|
+
var _parseBoxShadowValue = require("./parseBoxShadowValue");
|
|
20
22
|
// Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Types
|
|
21
23
|
let COMMA = /,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
|
|
22
24
|
;
|
|
23
25
|
let UNDERSCORE = /_(?![^(]*\))/g // Underscore separator that is not located between brackets. E.g.: `rgba(255,_255,_255)_black` these don't count.
|
|
24
26
|
;
|
|
25
|
-
function normalize(value) {
|
|
27
|
+
function normalize(value, isRoot = true) {
|
|
28
|
+
// Keep raw strings if it starts with `url(`
|
|
29
|
+
if (value.includes('url(')) {
|
|
30
|
+
return value.split(/(url\(.*?\))/g).filter(Boolean).map((part)=>{
|
|
31
|
+
if (/^url\(.*?\)$/.test(part)) {
|
|
32
|
+
return part;
|
|
33
|
+
}
|
|
34
|
+
return normalize(part, false);
|
|
35
|
+
}).join('');
|
|
36
|
+
}
|
|
26
37
|
// Convert `_` to ` `, except for escaped underscores `\_`
|
|
27
38
|
value = value.replace(/([^\\])_+/g, (fullMatch, characterBefore)=>characterBefore + ' '.repeat(fullMatch.length - 1)
|
|
28
39
|
).replace(/^_/g, ' ').replace(/\\_/g, '_');
|
|
29
40
|
// Remove leftover whitespace
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
if (isRoot) {
|
|
42
|
+
value = value.trim();
|
|
43
|
+
}
|
|
33
44
|
// Add spaces around operators inside calc() that do not follow an operator
|
|
34
45
|
// or '('.
|
|
35
46
|
return value.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, '$1 $2 ');
|
|
@@ -73,6 +84,15 @@ let lineWidths = new Set([
|
|
|
73
84
|
function lineWidth(value) {
|
|
74
85
|
return lineWidths.has(value);
|
|
75
86
|
}
|
|
87
|
+
function shadow(value) {
|
|
88
|
+
let parsedShadows = (0, _parseBoxShadowValue).parseBoxShadowValue(normalize(value));
|
|
89
|
+
for (let parsedShadow of parsedShadows){
|
|
90
|
+
if (!parsedShadow.valid) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
76
96
|
function color(value) {
|
|
77
97
|
let colors = 0;
|
|
78
98
|
let result = value.split(UNDERSCORE).every((part)=>{
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.formatVariantSelector = formatVariantSelector;
|
|
6
|
+
exports.finalizeSelector = finalizeSelector;
|
|
7
|
+
exports.selectorFunctions = void 0;
|
|
8
|
+
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
|
|
9
|
+
var _unesc = _interopRequireDefault(require("postcss-selector-parser/dist/util/unesc"));
|
|
10
|
+
var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
|
|
11
|
+
var _prefixSelector = _interopRequireDefault(require("../util/prefixSelector"));
|
|
12
|
+
function _interopRequireDefault(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
let MERGE = ':merge';
|
|
18
|
+
let PARENT = '&';
|
|
19
|
+
let selectorFunctions = new Set([
|
|
20
|
+
MERGE
|
|
21
|
+
]);
|
|
22
|
+
exports.selectorFunctions = selectorFunctions;
|
|
23
|
+
function formatVariantSelector(current, ...others) {
|
|
24
|
+
for (let other of others){
|
|
25
|
+
let incomingValue = resolveFunctionArgument(other, MERGE);
|
|
26
|
+
if (incomingValue !== null) {
|
|
27
|
+
let existingValue = resolveFunctionArgument(current, MERGE, incomingValue);
|
|
28
|
+
if (existingValue !== null) {
|
|
29
|
+
let existingTarget = `${MERGE}(${incomingValue})`;
|
|
30
|
+
let splitIdx = other.indexOf(existingTarget);
|
|
31
|
+
let addition = other.slice(splitIdx + existingTarget.length).split(' ')[0];
|
|
32
|
+
current = current.replace(existingTarget, existingTarget + addition);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
current = other.replace(PARENT, current);
|
|
37
|
+
}
|
|
38
|
+
return current;
|
|
39
|
+
}
|
|
40
|
+
function finalizeSelector(format, { selector: selector1 , candidate , context }) {
|
|
41
|
+
var ref, ref1;
|
|
42
|
+
var ref2;
|
|
43
|
+
let base = candidate.split((ref2 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref2 !== void 0 ? ref2 : ':').pop();
|
|
44
|
+
if (context === null || context === void 0 ? void 0 : (ref1 = context.tailwindConfig) === null || ref1 === void 0 ? void 0 : ref1.prefix) {
|
|
45
|
+
format = (0, _prefixSelector).default(context.tailwindConfig.prefix, format);
|
|
46
|
+
}
|
|
47
|
+
format = format.replace(PARENT, `.${(0, _escapeClassName).default(candidate)}`);
|
|
48
|
+
// Normalize escaped classes, e.g.:
|
|
49
|
+
//
|
|
50
|
+
// The idea would be to replace the escaped `base` in the selector with the
|
|
51
|
+
// `format`. However, in css you can escape the same selector in a few
|
|
52
|
+
// different ways. This would result in different strings and therefore we
|
|
53
|
+
// can't replace it properly.
|
|
54
|
+
//
|
|
55
|
+
// base: bg-[rgb(255,0,0)]
|
|
56
|
+
// base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
|
|
57
|
+
// escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
|
|
58
|
+
//
|
|
59
|
+
selector1 = (0, _postcssSelectorParser).default((selectors)=>{
|
|
60
|
+
return selectors.walkClasses((node)=>{
|
|
61
|
+
if (node.raws && node.value.includes(base)) {
|
|
62
|
+
node.raws.value = (0, _escapeClassName).default((0, _unesc).default(node.raws.value));
|
|
63
|
+
}
|
|
64
|
+
return node;
|
|
65
|
+
});
|
|
66
|
+
}).processSync(selector1);
|
|
67
|
+
// We can safely replace the escaped base now, since the `base` section is
|
|
68
|
+
// now in a normalized escaped value.
|
|
69
|
+
selector1 = selector1.replace(`.${(0, _escapeClassName).default(base)}`, format);
|
|
70
|
+
// Remove unnecessary pseudo selectors that we used as placeholders
|
|
71
|
+
return (0, _postcssSelectorParser).default((selectors)=>{
|
|
72
|
+
return selectors.map((selector)=>{
|
|
73
|
+
selector.walkPseudos((p)=>{
|
|
74
|
+
if (selectorFunctions.has(p.value)) {
|
|
75
|
+
p.replaceWith(p.nodes);
|
|
76
|
+
}
|
|
77
|
+
return p;
|
|
78
|
+
});
|
|
79
|
+
return selector;
|
|
80
|
+
});
|
|
81
|
+
}).processSync(selector1);
|
|
82
|
+
}
|
|
83
|
+
function resolveFunctionArgument(haystack, needle, arg) {
|
|
84
|
+
let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle);
|
|
85
|
+
if (startIdx === -1) return null;
|
|
86
|
+
// Start inside the `(`
|
|
87
|
+
startIdx += needle.length + 1;
|
|
88
|
+
let target = '';
|
|
89
|
+
let count = 0;
|
|
90
|
+
for (let char of haystack.slice(startIdx)){
|
|
91
|
+
if (char !== '(' && char !== ')') {
|
|
92
|
+
target += char;
|
|
93
|
+
} else if (char === '(') {
|
|
94
|
+
target += char;
|
|
95
|
+
count++;
|
|
96
|
+
} else if (char === ')') {
|
|
97
|
+
if (--count < 0) break; // unbalanced
|
|
98
|
+
target += char;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return target;
|
|
102
|
+
}
|
package/lib/util/nameClass.js
CHANGED
package/lib/util/negateValue.js
CHANGED
|
@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.default = _default;
|
|
6
6
|
function _default(value) {
|
|
7
7
|
value = `${value}`;
|
|
8
|
+
if (value === '0') {
|
|
9
|
+
return '0';
|
|
10
|
+
}
|
|
8
11
|
// Flip sign of numbers
|
|
9
12
|
if (/^[+-]?(\d+|\d*\.\d+)(e[+-]?\d+)?(%|\w+)?$/.test(value)) {
|
|
10
13
|
return value.replace(/^[+-]?/, (sign)=>sign === '-' ? '' : '-'
|
|
@@ -13,5 +16,4 @@ function _default(value) {
|
|
|
13
16
|
if (value.includes('var(') || value.includes('calc(')) {
|
|
14
17
|
return `calc(${value} * -1)`;
|
|
15
18
|
}
|
|
16
|
-
return value;
|
|
17
19
|
}
|
|
@@ -120,6 +120,17 @@ function normalizeConfig(config) {
|
|
|
120
120
|
if (Array.isArray(purge === null || purge === void 0 ? void 0 : (ref = purge.options) === null || ref === void 0 ? void 0 : ref.safelist)) return purge.options.safelist;
|
|
121
121
|
return [];
|
|
122
122
|
})();
|
|
123
|
+
// Normalize prefix option
|
|
124
|
+
if (typeof config.prefix === 'function') {
|
|
125
|
+
_log.default.warn('prefix-function', [
|
|
126
|
+
'As of Tailwind CSS v3.0, `prefix` cannot be a function.',
|
|
127
|
+
'Update `prefix` in your configuration to be a string to eliminate this warning.'
|
|
128
|
+
]);
|
|
129
|
+
config.prefix = '';
|
|
130
|
+
} else {
|
|
131
|
+
var _prefix;
|
|
132
|
+
config.prefix = (_prefix = config.prefix) !== null && _prefix !== void 0 ? _prefix : '';
|
|
133
|
+
}
|
|
123
134
|
// Normalize the `content`
|
|
124
135
|
config.content = {
|
|
125
136
|
files: (()=>{
|
|
@@ -145,16 +156,19 @@ function normalizeConfig(config) {
|
|
|
145
156
|
})();
|
|
146
157
|
let extractors = {
|
|
147
158
|
};
|
|
148
|
-
|
|
149
|
-
var ref,
|
|
150
|
-
if ((ref = config.purge) === null || ref === void 0 ? void 0 : (
|
|
159
|
+
let defaultExtractor = (()=>{
|
|
160
|
+
var ref, ref10, ref11, ref12;
|
|
161
|
+
if ((ref = config.purge) === null || ref === void 0 ? void 0 : (ref10 = ref.options) === null || ref10 === void 0 ? void 0 : ref10.defaultExtractor) {
|
|
151
162
|
return config.purge.options.defaultExtractor;
|
|
152
163
|
}
|
|
153
|
-
if ((
|
|
164
|
+
if ((ref11 = config.content) === null || ref11 === void 0 ? void 0 : (ref12 = ref11.options) === null || ref12 === void 0 ? void 0 : ref12.defaultExtractor) {
|
|
154
165
|
return config.content.options.defaultExtractor;
|
|
155
166
|
}
|
|
156
167
|
return undefined;
|
|
157
168
|
})();
|
|
169
|
+
if (defaultExtractor !== undefined) {
|
|
170
|
+
extractors.DEFAULT = defaultExtractor;
|
|
171
|
+
}
|
|
158
172
|
// Functions
|
|
159
173
|
if (typeof extract === 'function') {
|
|
160
174
|
extractors.DEFAULT = extract;
|
|
@@ -171,11 +185,11 @@ function normalizeConfig(config) {
|
|
|
171
185
|
})(),
|
|
172
186
|
transform: (()=>{
|
|
173
187
|
let transform = (()=>{
|
|
174
|
-
var ref,
|
|
188
|
+
var ref, ref13, ref14, ref15, ref16, ref17;
|
|
175
189
|
if ((ref = config.purge) === null || ref === void 0 ? void 0 : ref.transform) return config.purge.transform;
|
|
176
|
-
if ((
|
|
177
|
-
if ((
|
|
178
|
-
if ((
|
|
190
|
+
if ((ref13 = config.content) === null || ref13 === void 0 ? void 0 : ref13.transform) return config.content.transform;
|
|
191
|
+
if ((ref14 = config.purge) === null || ref14 === void 0 ? void 0 : (ref15 = ref14.transform) === null || ref15 === void 0 ? void 0 : ref15.DEFAULT) return config.purge.transform.DEFAULT;
|
|
192
|
+
if ((ref16 = config.content) === null || ref16 === void 0 ? void 0 : (ref17 = ref16.transform) === null || ref17 === void 0 ? void 0 : ref17.DEFAULT) return config.content.transform.DEFAULT;
|
|
179
193
|
return {
|
|
180
194
|
};
|
|
181
195
|
})();
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.parseBoxShadowValue = parseBoxShadowValue;
|
|
6
|
+
exports.formatBoxShadowValue = formatBoxShadowValue;
|
|
7
|
+
let KEYWORDS = new Set([
|
|
8
|
+
'inset',
|
|
9
|
+
'inherit',
|
|
10
|
+
'initial',
|
|
11
|
+
'revert',
|
|
12
|
+
'unset'
|
|
13
|
+
]);
|
|
14
|
+
let COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
|
|
15
|
+
;
|
|
16
|
+
let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
|
|
17
|
+
;
|
|
18
|
+
let LENGTH = /^-?(\d+)(.*?)$/g;
|
|
19
|
+
function parseBoxShadowValue(input) {
|
|
20
|
+
let shadows = input.split(COMMA);
|
|
21
|
+
return shadows.map((shadow)=>{
|
|
22
|
+
let value = shadow.trim();
|
|
23
|
+
let result = {
|
|
24
|
+
raw: value
|
|
25
|
+
};
|
|
26
|
+
let parts = value.split(SPACE);
|
|
27
|
+
let seen = new Set();
|
|
28
|
+
for (let part of parts){
|
|
29
|
+
// Reset index, since the regex is stateful.
|
|
30
|
+
LENGTH.lastIndex = 0;
|
|
31
|
+
// Keyword
|
|
32
|
+
if (!seen.has('KEYWORD') && KEYWORDS.has(part)) {
|
|
33
|
+
result.keyword = part;
|
|
34
|
+
seen.add('KEYWORD');
|
|
35
|
+
} else if (LENGTH.test(part)) {
|
|
36
|
+
if (!seen.has('X')) {
|
|
37
|
+
result.x = part;
|
|
38
|
+
seen.add('X');
|
|
39
|
+
} else if (!seen.has('Y')) {
|
|
40
|
+
result.y = part;
|
|
41
|
+
seen.add('Y');
|
|
42
|
+
} else if (!seen.has('BLUR')) {
|
|
43
|
+
result.blur = part;
|
|
44
|
+
seen.add('BLUR');
|
|
45
|
+
} else if (!seen.has('SPREAD')) {
|
|
46
|
+
result.spread = part;
|
|
47
|
+
seen.add('SPREAD');
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
if (!result.color) {
|
|
51
|
+
result.color = part;
|
|
52
|
+
} else {
|
|
53
|
+
if (!result.unknown) result.unknown = [];
|
|
54
|
+
result.unknown.push(part);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Check if valid
|
|
59
|
+
result.valid = result.x !== undefined && result.y !== undefined;
|
|
60
|
+
return result;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function formatBoxShadowValue(shadows) {
|
|
64
|
+
return shadows.map((shadow)=>{
|
|
65
|
+
if (!shadow.valid) {
|
|
66
|
+
return shadow.raw;
|
|
67
|
+
}
|
|
68
|
+
return [
|
|
69
|
+
shadow.keyword,
|
|
70
|
+
shadow.x,
|
|
71
|
+
shadow.y,
|
|
72
|
+
shadow.blur,
|
|
73
|
+
shadow.spread,
|
|
74
|
+
shadow.color
|
|
75
|
+
].filter(Boolean).join(' ');
|
|
76
|
+
}).join(', ');
|
|
77
|
+
}
|