tailwindcss 3.0.23 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +92 -2
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +3 -0
- package/lib/cli-peer-dependencies.js +10 -5
- package/lib/cli.js +266 -203
- package/lib/constants.js +8 -8
- package/lib/corePluginList.js +1 -0
- package/lib/corePlugins.js +1640 -1562
- package/lib/css/preflight.css +1 -8
- package/lib/featureFlags.js +14 -12
- package/lib/index.js +16 -6
- package/lib/lib/cacheInvalidation.js +87 -0
- package/lib/lib/collapseAdjacentRules.js +30 -15
- package/lib/lib/collapseDuplicateDeclarations.js +1 -1
- package/lib/lib/defaultExtractor.js +191 -32
- package/lib/lib/detectNesting.js +9 -9
- package/lib/lib/evaluateTailwindFunctions.js +37 -28
- package/lib/lib/expandApplyAtRules.js +379 -189
- package/lib/lib/expandTailwindAtRules.js +168 -144
- package/lib/lib/generateRules.js +177 -95
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +35 -35
- package/lib/lib/partitionApplyAtRules.js +7 -7
- package/lib/lib/regex.js +52 -0
- package/lib/lib/resolveDefaultsAtRules.js +96 -81
- package/lib/lib/setupContextUtils.js +202 -159
- package/lib/lib/setupTrackingContext.js +61 -63
- package/lib/lib/sharedState.js +10 -9
- package/lib/lib/substituteScreenAtRules.js +3 -4
- package/lib/postcss-plugins/nesting/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +1 -1
- package/lib/postcss-plugins/nesting/plugin.js +40 -9
- package/lib/processTailwindFeatures.js +7 -7
- package/lib/public/colors.js +241 -241
- package/lib/public/resolve-config.js +5 -5
- package/lib/util/buildMediaQuery.js +2 -3
- package/lib/util/cloneDeep.js +3 -5
- package/lib/util/cloneNodes.js +12 -1
- package/lib/util/color.js +42 -51
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +6 -7
- package/lib/util/dataTypes.js +85 -81
- package/lib/util/escapeClassName.js +5 -5
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +4 -7
- package/lib/util/formatVariantSelector.js +82 -75
- package/lib/util/getAllConfigs.js +15 -10
- package/lib/util/hashConfig.js +5 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +1 -1
- package/lib/util/isValidArbitraryValue.js +26 -27
- package/lib/util/log.js +9 -10
- package/lib/util/nameClass.js +7 -7
- package/lib/util/negateValue.js +4 -5
- package/lib/util/normalizeConfig.js +68 -58
- package/lib/util/normalizeScreens.js +5 -6
- package/lib/util/parseAnimationValue.js +56 -57
- package/lib/util/parseBoxShadowValue.js +19 -20
- package/lib/util/parseDependency.js +32 -32
- package/lib/util/parseObjectStyles.js +6 -6
- package/lib/util/pluginUtils.js +20 -12
- package/lib/util/prefixSelector.js +1 -1
- package/lib/util/resolveConfig.js +81 -58
- package/lib/util/resolveConfigPath.js +16 -16
- package/lib/util/responsive.js +6 -6
- package/lib/util/splitAtTopLevelOnly.js +90 -0
- package/lib/util/toColorValue.js +1 -1
- package/lib/util/toPath.js +2 -2
- package/lib/util/transformThemeValue.js +30 -28
- package/lib/util/validateConfig.js +21 -0
- package/lib/util/withAlphaVariable.js +23 -23
- package/package.json +33 -27
- package/peers/index.js +7702 -5822
- package/plugin.d.ts +11 -0
- package/scripts/generate-types.js +52 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +118 -24
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +109 -30
- package/src/css/preflight.css +1 -8
- package/src/featureFlags.js +4 -4
- package/src/index.js +15 -1
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/defaultExtractor.js +177 -35
- package/src/lib/evaluateTailwindFunctions.js +20 -4
- package/src/lib/expandApplyAtRules.js +418 -186
- package/src/lib/expandTailwindAtRules.js +29 -9
- package/src/lib/generateRules.js +137 -51
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +53 -32
- package/src/lib/setupContextUtils.js +128 -65
- package/src/lib/setupTrackingContext.js +7 -3
- package/src/lib/sharedState.js +1 -0
- package/src/postcss-plugins/nesting/README.md +2 -2
- package/src/postcss-plugins/nesting/plugin.js +36 -0
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +25 -21
- package/src/util/dataTypes.js +14 -6
- package/src/util/formatVariantSelector.js +79 -62
- package/src/util/getAllConfigs.js +7 -0
- package/src/util/log.js +8 -8
- package/src/util/normalizeConfig.js +0 -8
- package/src/util/parseBoxShadowValue.js +3 -2
- package/src/util/pluginUtils.js +13 -1
- package/src/util/resolveConfig.js +66 -22
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +4 -2
- package/src/util/validateConfig.js +13 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +5 -1
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +325 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/index.d.ts +7 -0
|
@@ -14,8 +14,9 @@ function _interopRequireDefault(obj) {
|
|
|
14
14
|
default: obj
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
let
|
|
17
|
+
var ref;
|
|
18
|
+
let MERGE = ":merge";
|
|
19
|
+
let PARENT = "&";
|
|
19
20
|
let selectorFunctions = new Set([
|
|
20
21
|
MERGE
|
|
21
22
|
]);
|
|
@@ -28,7 +29,7 @@ function formatVariantSelector(current, ...others) {
|
|
|
28
29
|
if (existingValue !== null) {
|
|
29
30
|
let existingTarget = `${MERGE}(${incomingValue})`;
|
|
30
31
|
let splitIdx = other.indexOf(existingTarget);
|
|
31
|
-
let addition = other.slice(splitIdx + existingTarget.length).split(
|
|
32
|
+
let addition = other.slice(splitIdx + existingTarget.length).split(" ")[0];
|
|
32
33
|
current = current.replace(existingTarget, existingTarget + addition);
|
|
33
34
|
continue;
|
|
34
35
|
}
|
|
@@ -37,23 +38,31 @@ function formatVariantSelector(current, ...others) {
|
|
|
37
38
|
}
|
|
38
39
|
return current;
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
var ref1;
|
|
42
|
+
function finalizeSelector(format, { selector: selector1 , candidate , context , // Split by the separator, but ignore the separator inside square brackets:
|
|
43
|
+
//
|
|
44
|
+
// E.g.: dark:lg:hover:[paint-order:markers]
|
|
45
|
+
// ┬ ┬ ┬ ┬
|
|
46
|
+
// │ │ │ ╰── We will not split here
|
|
47
|
+
// ╰──┴─────┴─────────────── We will split here
|
|
48
|
+
//
|
|
49
|
+
base =candidate.split(new RegExp(`\\${(ref1 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref1 !== void 0 ? ref1 : ":"}(?![^[]*\\])`)).pop() , }) {
|
|
42
50
|
var ref2;
|
|
43
|
-
let
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
// E.g.: dark:lg:hover:[paint-order:markers]
|
|
47
|
-
// ┬ ┬ ┬ ┬
|
|
48
|
-
// │ │ │ ╰── We will not split here
|
|
49
|
-
// ╰──┴─────┴─────────────── We will split here
|
|
50
|
-
//
|
|
51
|
-
let splitter = new RegExp(`\\${separator}(?![^[]*\\])`);
|
|
52
|
-
let base = candidate.split(splitter).pop();
|
|
53
|
-
if (context === null || context === void 0 ? void 0 : (ref1 = context.tailwindConfig) === null || ref1 === void 0 ? void 0 : ref1.prefix) {
|
|
51
|
+
let ast = (0, _postcssSelectorParser).default().astSync(selector1);
|
|
52
|
+
if (context === null || context === void 0 ? void 0 : (ref2 = context.tailwindConfig) === null || ref2 === void 0 ? void 0 : ref2.prefix) {
|
|
54
53
|
format = (0, _prefixSelector).default(context.tailwindConfig.prefix, format);
|
|
55
54
|
}
|
|
56
55
|
format = format.replace(PARENT, `.${(0, _escapeClassName).default(candidate)}`);
|
|
56
|
+
let formatAst = (0, _postcssSelectorParser).default().astSync(format);
|
|
57
|
+
// Remove extraneous selectors that do not include the base class/candidate being matched against
|
|
58
|
+
// For example if we have a utility defined `.a, .b { color: red}`
|
|
59
|
+
// And the formatted variant is sm:b then we want the final selector to be `.sm\:b` and not `.a, .sm\:b`
|
|
60
|
+
ast.each((node)=>{
|
|
61
|
+
let hasClassesMatchingCandidate = node.some((n)=>n.type === "class" && n.value === base);
|
|
62
|
+
if (!hasClassesMatchingCandidate) {
|
|
63
|
+
node.remove();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
57
66
|
// Normalize escaped classes, e.g.:
|
|
58
67
|
//
|
|
59
68
|
// The idea would be to replace the escaped `base` in the selector with the
|
|
@@ -65,69 +74,67 @@ function finalizeSelector(format, { selector: selector1 , candidate , context }
|
|
|
65
74
|
// base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
|
|
66
75
|
// escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
|
|
67
76
|
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return node;
|
|
74
|
-
});
|
|
75
|
-
}).processSync(selector1);
|
|
77
|
+
ast.walkClasses((node)=>{
|
|
78
|
+
if (node.raws && node.value.includes(base)) {
|
|
79
|
+
node.raws.value = (0, _escapeClassName).default((0, _unesc).default(node.raws.value));
|
|
80
|
+
}
|
|
81
|
+
});
|
|
76
82
|
// We can safely replace the escaped base now, since the `base` section is
|
|
77
83
|
// now in a normalized escaped value.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
nodes.push(node);
|
|
102
|
-
selector.removeChild(node);
|
|
103
|
-
}
|
|
104
|
-
if (node === null || node === void 0 ? void 0 : node.nodes) {
|
|
105
|
-
nodes.push(...collectPseudoElements(node));
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return nodes;
|
|
84
|
+
ast.walkClasses((node)=>{
|
|
85
|
+
if (node.value === base) {
|
|
86
|
+
node.replaceWith(...formatAst.nodes);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
// This will make sure to move pseudo's to the correct spot (the end for
|
|
90
|
+
// pseudo elements) because otherwise the selector will never work
|
|
91
|
+
// anyway.
|
|
92
|
+
//
|
|
93
|
+
// E.g.:
|
|
94
|
+
// - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
95
|
+
// - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
96
|
+
//
|
|
97
|
+
// `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
|
|
98
|
+
function collectPseudoElements(selector) {
|
|
99
|
+
let nodes = [];
|
|
100
|
+
for (let node of selector.nodes){
|
|
101
|
+
if (isPseudoElement(node)) {
|
|
102
|
+
nodes.push(node);
|
|
103
|
+
selector.removeChild(node);
|
|
104
|
+
}
|
|
105
|
+
if (node === null || node === void 0 ? void 0 : node.nodes) {
|
|
106
|
+
nodes.push(...collectPseudoElements(node));
|
|
109
107
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
}
|
|
109
|
+
return nodes;
|
|
110
|
+
}
|
|
111
|
+
// Remove unnecessary pseudo selectors that we used as placeholders
|
|
112
|
+
ast.each((selector)=>{
|
|
113
|
+
selector.walkPseudos((p)=>{
|
|
114
|
+
if (selectorFunctions.has(p.value)) {
|
|
115
|
+
p.replaceWith(p.nodes);
|
|
113
116
|
}
|
|
114
|
-
return selector2;
|
|
115
117
|
});
|
|
116
|
-
|
|
118
|
+
let pseudoElements = collectPseudoElements(selector);
|
|
119
|
+
if (pseudoElements.length > 0) {
|
|
120
|
+
selector.nodes.push(pseudoElements.sort(sortSelector));
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return ast.toString();
|
|
117
124
|
}
|
|
118
125
|
// Note: As a rule, double colons (::) should be used instead of a single colon
|
|
119
126
|
// (:). This distinguishes pseudo-classes from pseudo-elements. However, since
|
|
120
127
|
// this distinction was not present in older versions of the W3C spec, most
|
|
121
128
|
// browsers support both syntaxes for the original pseudo-elements.
|
|
122
129
|
let pseudoElementsBC = [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
130
|
+
":before",
|
|
131
|
+
":after",
|
|
132
|
+
":first-line",
|
|
133
|
+
":first-letter"
|
|
127
134
|
];
|
|
128
135
|
// These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
|
|
129
136
|
let pseudoElementExceptions = [
|
|
130
|
-
|
|
137
|
+
"::file-selector-button"
|
|
131
138
|
];
|
|
132
139
|
// This will make sure to move pseudo's to the correct spot (the end for
|
|
133
140
|
// pseudo elements) because otherwise the selector will never work
|
|
@@ -142,42 +149,42 @@ let pseudoElementExceptions = [
|
|
|
142
149
|
function sortSelector(a, z) {
|
|
143
150
|
// Both nodes are non-pseudo's so we can safely ignore them and keep
|
|
144
151
|
// them in the same order.
|
|
145
|
-
if (a.type !==
|
|
152
|
+
if (a.type !== "pseudo" && z.type !== "pseudo") {
|
|
146
153
|
return 0;
|
|
147
154
|
}
|
|
148
155
|
// If one of them is a combinator, we need to keep it in the same order
|
|
149
156
|
// because that means it will start a new "section" in the selector.
|
|
150
|
-
if (a.type ===
|
|
157
|
+
if (a.type === "combinator" ^ z.type === "combinator") {
|
|
151
158
|
return 0;
|
|
152
159
|
}
|
|
153
160
|
// One of the items is a pseudo and the other one isn't. Let's move
|
|
154
161
|
// the pseudo to the right.
|
|
155
|
-
if (a.type ===
|
|
156
|
-
return (a.type ===
|
|
162
|
+
if (a.type === "pseudo" ^ z.type === "pseudo") {
|
|
163
|
+
return (a.type === "pseudo") - (z.type === "pseudo");
|
|
157
164
|
}
|
|
158
165
|
// Both are pseudo's, move the pseudo elements (except for
|
|
159
166
|
// ::file-selector-button) to the right.
|
|
160
167
|
return isPseudoElement(a) - isPseudoElement(z);
|
|
161
168
|
}
|
|
162
169
|
function isPseudoElement(node) {
|
|
163
|
-
if (node.type !==
|
|
170
|
+
if (node.type !== "pseudo") return false;
|
|
164
171
|
if (pseudoElementExceptions.includes(node.value)) return false;
|
|
165
|
-
return node.value.startsWith(
|
|
172
|
+
return node.value.startsWith("::") || pseudoElementsBC.includes(node.value);
|
|
166
173
|
}
|
|
167
174
|
function resolveFunctionArgument(haystack, needle, arg) {
|
|
168
175
|
let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle);
|
|
169
176
|
if (startIdx === -1) return null;
|
|
170
177
|
// Start inside the `(`
|
|
171
178
|
startIdx += needle.length + 1;
|
|
172
|
-
let target =
|
|
179
|
+
let target = "";
|
|
173
180
|
let count = 0;
|
|
174
181
|
for (let char of haystack.slice(startIdx)){
|
|
175
|
-
if (char !==
|
|
182
|
+
if (char !== "(" && char !== ")") {
|
|
176
183
|
target += char;
|
|
177
|
-
} else if (char ===
|
|
184
|
+
} else if (char === "(") {
|
|
178
185
|
target += char;
|
|
179
186
|
count++;
|
|
180
|
-
} else if (char ===
|
|
187
|
+
} else if (char === ")") {
|
|
181
188
|
if (--count < 0) break; // unbalanced
|
|
182
189
|
target += char;
|
|
183
190
|
}
|
|
@@ -5,25 +5,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.default = getAllConfigs;
|
|
6
6
|
var _defaultConfigStubJs = _interopRequireDefault(require("../../stubs/defaultConfig.stub.js"));
|
|
7
7
|
var _featureFlags = require("../featureFlags");
|
|
8
|
-
function _interopRequireDefault(obj) {
|
|
9
|
-
return obj && obj.__esModule ? obj : {
|
|
10
|
-
default: obj
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
8
|
function getAllConfigs(config) {
|
|
14
9
|
var ref;
|
|
15
10
|
const configs = ((ref = config === null || config === void 0 ? void 0 : config.presets) !== null && ref !== void 0 ? ref : [
|
|
16
11
|
_defaultConfigStubJs.default
|
|
17
|
-
]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset)
|
|
18
|
-
);
|
|
12
|
+
]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset));
|
|
19
13
|
const features = {
|
|
14
|
+
// Add experimental configs here...
|
|
15
|
+
respectDefaultRingColorOpacity: {
|
|
16
|
+
theme: {
|
|
17
|
+
ringColor: {
|
|
18
|
+
DEFAULT: "#3b82f67f"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
20
22
|
};
|
|
21
|
-
const experimentals = Object.keys(features).filter((feature)=>(0, _featureFlags).flagEnabled(config, feature)
|
|
22
|
-
).map((feature)=>features[feature]
|
|
23
|
-
);
|
|
23
|
+
const experimentals = Object.keys(features).filter((feature)=>(0, _featureFlags).flagEnabled(config, feature)).map((feature)=>features[feature]);
|
|
24
24
|
return [
|
|
25
25
|
config,
|
|
26
26
|
...experimentals,
|
|
27
27
|
...configs
|
|
28
28
|
];
|
|
29
29
|
}
|
|
30
|
+
function _interopRequireDefault(obj) {
|
|
31
|
+
return obj && obj.__esModule ? obj : {
|
|
32
|
+
default: obj
|
|
33
|
+
};
|
|
34
|
+
}
|
package/lib/util/hashConfig.js
CHANGED
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.default = hashConfig;
|
|
6
6
|
var _objectHash = _interopRequireDefault(require("object-hash"));
|
|
7
|
-
function _interopRequireDefault(obj) {
|
|
8
|
-
return obj && obj.__esModule ? obj : {
|
|
9
|
-
default: obj
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
7
|
function hashConfig(config) {
|
|
13
8
|
return (0, _objectHash).default(config, {
|
|
14
9
|
ignoreUnknown: true
|
|
15
10
|
});
|
|
16
11
|
}
|
|
12
|
+
function _interopRequireDefault(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.default = isKeyframeRule;
|
|
6
6
|
function isKeyframeRule(rule) {
|
|
7
|
-
return rule.parent && rule.parent.type ===
|
|
7
|
+
return rule.parent && rule.parent.type === "atrule" && /keyframes$/.test(rule.parent.name);
|
|
8
8
|
}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.default = isPlainObject;
|
|
6
6
|
function isPlainObject(value) {
|
|
7
|
-
if (Object.prototype.toString.call(value) !==
|
|
7
|
+
if (Object.prototype.toString.call(value) !== "[object Object]") {
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
10
10
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -3,44 +3,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = isValidArbitraryValue;
|
|
6
|
-
let matchingBrackets = new Map([
|
|
7
|
-
[
|
|
8
|
-
'{',
|
|
9
|
-
'}'
|
|
10
|
-
],
|
|
11
|
-
[
|
|
12
|
-
'[',
|
|
13
|
-
']'
|
|
14
|
-
],
|
|
15
|
-
[
|
|
16
|
-
'(',
|
|
17
|
-
')'
|
|
18
|
-
],
|
|
19
|
-
]);
|
|
20
|
-
let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
|
|
21
|
-
v,
|
|
22
|
-
k
|
|
23
|
-
]
|
|
24
|
-
));
|
|
25
|
-
let quotes = new Set([
|
|
26
|
-
'"',
|
|
27
|
-
"'",
|
|
28
|
-
'`'
|
|
29
|
-
]);
|
|
30
6
|
function isValidArbitraryValue(value) {
|
|
31
7
|
let stack = [];
|
|
32
8
|
let inQuotes = false;
|
|
33
9
|
for(let i = 0; i < value.length; i++){
|
|
34
10
|
let char = value[i];
|
|
35
|
-
if (char ===
|
|
11
|
+
if (char === ":" && !inQuotes && stack.length === 0) {
|
|
36
12
|
return false;
|
|
37
13
|
}
|
|
38
14
|
// Non-escaped quotes allow us to "allow" anything in between
|
|
39
|
-
if (quotes.has(char) && value[i - 1] !==
|
|
15
|
+
if (quotes.has(char) && value[i - 1] !== "\\") {
|
|
40
16
|
inQuotes = !inQuotes;
|
|
41
17
|
}
|
|
42
18
|
if (inQuotes) continue;
|
|
43
|
-
if (value[i - 1] ===
|
|
19
|
+
if (value[i - 1] === "\\") continue; // Escaped
|
|
44
20
|
if (matchingBrackets.has(char)) {
|
|
45
21
|
stack.push(char);
|
|
46
22
|
} else if (inverseMatchingBrackets.has(char)) {
|
|
@@ -62,3 +38,26 @@ function isValidArbitraryValue(value) {
|
|
|
62
38
|
// All good, totally balanced!
|
|
63
39
|
return true;
|
|
64
40
|
}
|
|
41
|
+
let matchingBrackets = new Map([
|
|
42
|
+
[
|
|
43
|
+
"{",
|
|
44
|
+
"}"
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
"[",
|
|
48
|
+
"]"
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
"(",
|
|
52
|
+
")"
|
|
53
|
+
],
|
|
54
|
+
]);
|
|
55
|
+
let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
|
|
56
|
+
v,
|
|
57
|
+
k
|
|
58
|
+
]));
|
|
59
|
+
let quotes = new Set([
|
|
60
|
+
'"',
|
|
61
|
+
"'",
|
|
62
|
+
"`"
|
|
63
|
+
]);
|
package/lib/util/log.js
CHANGED
|
@@ -4,27 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.dim = dim;
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _picocolors = _interopRequireDefault(require("picocolors"));
|
|
8
8
|
function _interopRequireDefault(obj) {
|
|
9
9
|
return obj && obj.__esModule ? obj : {
|
|
10
10
|
default: obj
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
let alreadyShown = new Set();
|
|
14
|
-
function log(
|
|
15
|
-
if (process.env.JEST_WORKER_ID
|
|
14
|
+
function log(type, messages, key) {
|
|
15
|
+
if (typeof process !== "undefined" && process.env.JEST_WORKER_ID) return;
|
|
16
16
|
if (key && alreadyShown.has(key)) return;
|
|
17
17
|
if (key) alreadyShown.add(key);
|
|
18
|
-
console.warn(
|
|
19
|
-
messages.forEach((message)=>console.warn(
|
|
20
|
-
);
|
|
18
|
+
console.warn("");
|
|
19
|
+
messages.forEach((message)=>console.warn(type, "-", message));
|
|
21
20
|
}
|
|
22
21
|
function dim(input) {
|
|
23
|
-
return
|
|
22
|
+
return _picocolors.default.dim(input);
|
|
24
23
|
}
|
|
25
24
|
var _default = {
|
|
26
25
|
info (key, messages) {
|
|
27
|
-
log(
|
|
26
|
+
log(_picocolors.default.bold(_picocolors.default.cyan("info")), ...Array.isArray(key) ? [
|
|
28
27
|
key
|
|
29
28
|
] : [
|
|
30
29
|
messages,
|
|
@@ -32,7 +31,7 @@ var _default = {
|
|
|
32
31
|
]);
|
|
33
32
|
},
|
|
34
33
|
warn (key, messages) {
|
|
35
|
-
log(
|
|
34
|
+
log(_picocolors.default.bold(_picocolors.default.yellow("warn")), ...Array.isArray(key) ? [
|
|
36
35
|
key
|
|
37
36
|
] : [
|
|
38
37
|
messages,
|
|
@@ -40,7 +39,7 @@ var _default = {
|
|
|
40
39
|
]);
|
|
41
40
|
},
|
|
42
41
|
risk (key, messages) {
|
|
43
|
-
log(
|
|
42
|
+
log(_picocolors.default.bold(_picocolors.default.magenta("risk")), ...Array.isArray(key) ? [
|
|
44
43
|
key
|
|
45
44
|
] : [
|
|
46
45
|
messages,
|
package/lib/util/nameClass.js
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.asClass = asClass;
|
|
6
5
|
exports.default = nameClass;
|
|
6
|
+
exports.asClass = asClass;
|
|
7
7
|
exports.formatClass = formatClass;
|
|
8
8
|
var _escapeClassName = _interopRequireDefault(require("./escapeClassName"));
|
|
9
9
|
var _escapeCommas = _interopRequireDefault(require("./escapeCommas"));
|
|
10
|
+
function nameClass(classPrefix, key) {
|
|
11
|
+
return asClass(formatClass(classPrefix, key));
|
|
12
|
+
}
|
|
10
13
|
function _interopRequireDefault(obj) {
|
|
11
14
|
return obj && obj.__esModule ? obj : {
|
|
12
15
|
default: obj
|
|
@@ -15,17 +18,14 @@ function _interopRequireDefault(obj) {
|
|
|
15
18
|
function asClass(name) {
|
|
16
19
|
return (0, _escapeCommas).default(`.${(0, _escapeClassName).default(name)}`);
|
|
17
20
|
}
|
|
18
|
-
function nameClass(classPrefix, key) {
|
|
19
|
-
return asClass(formatClass(classPrefix, key));
|
|
20
|
-
}
|
|
21
21
|
function formatClass(classPrefix, key) {
|
|
22
|
-
if (key ===
|
|
22
|
+
if (key === "DEFAULT") {
|
|
23
23
|
return classPrefix;
|
|
24
24
|
}
|
|
25
|
-
if (key ===
|
|
25
|
+
if (key === "-" || key === "-DEFAULT") {
|
|
26
26
|
return `-${classPrefix}`;
|
|
27
27
|
}
|
|
28
|
-
if (key.startsWith(
|
|
28
|
+
if (key.startsWith("-")) {
|
|
29
29
|
return `-${classPrefix}${key}`;
|
|
30
30
|
}
|
|
31
31
|
return `${classPrefix}-${key}`;
|
package/lib/util/negateValue.js
CHANGED
|
@@ -5,15 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.default = _default;
|
|
6
6
|
function _default(value) {
|
|
7
7
|
value = `${value}`;
|
|
8
|
-
if (value ===
|
|
9
|
-
return
|
|
8
|
+
if (value === "0") {
|
|
9
|
+
return "0";
|
|
10
10
|
}
|
|
11
11
|
// Flip sign of numbers
|
|
12
12
|
if (/^[+-]?(\d+|\d*\.\d+)(e[+-]?\d+)?(%|\w+)?$/.test(value)) {
|
|
13
|
-
return value.replace(/^[+-]?/, (sign)=>sign ===
|
|
14
|
-
);
|
|
13
|
+
return value.replace(/^[+-]?/, (sign)=>sign === "-" ? "" : "-");
|
|
15
14
|
}
|
|
16
|
-
if (value.includes(
|
|
15
|
+
if (value.includes("var(") || value.includes("calc(")) {
|
|
17
16
|
return `calc(${value} * -1)`;
|
|
18
17
|
}
|
|
19
18
|
}
|