@unocss/preset-mini 0.19.0 → 0.20.4
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/dist/chunks/default.cjs +6 -6
- package/dist/chunks/default.mjs +6 -6
- package/dist/chunks/default2.cjs +146 -182
- package/dist/chunks/default2.mjs +156 -191
- package/dist/chunks/default3.cjs +34 -41
- package/dist/chunks/default3.mjs +32 -42
- package/dist/chunks/pseudo.cjs +26 -19
- package/dist/chunks/pseudo.mjs +26 -19
- package/dist/chunks/utilities.cjs +64 -28
- package/dist/chunks/utilities.mjs +64 -29
- package/dist/chunks/variants.cjs +17 -2
- package/dist/chunks/variants.mjs +17 -3
- package/dist/index.cjs +11 -2
- package/dist/index.mjs +11 -2
- package/dist/rules.cjs +0 -1
- package/dist/rules.d.ts +1 -2
- package/dist/rules.mjs +1 -1
- package/dist/utils.cjs +2 -0
- package/dist/utils.d.ts +4 -2
- package/dist/utils.mjs +2 -2
- package/dist/variants.cjs +4 -1
- package/dist/variants.d.ts +10 -2
- package/dist/variants.mjs +1 -1
- package/package.json +2 -2
package/dist/chunks/default3.cjs
CHANGED
|
@@ -48,43 +48,28 @@ const variantCombinators = [
|
|
|
48
48
|
|
|
49
49
|
const variantColorsMediaOrClass = [
|
|
50
50
|
(v, { options: { dark } }) => {
|
|
51
|
-
if (dark === "class")
|
|
52
|
-
|
|
53
|
-
if (match)
|
|
54
|
-
return match;
|
|
55
|
-
}
|
|
51
|
+
if (dark === "class")
|
|
52
|
+
return variants$1.variantMatcher("dark", (input) => `.dark $$ ${input}`)(v);
|
|
56
53
|
},
|
|
57
54
|
(v, { options: { dark } }) => {
|
|
58
|
-
if (dark === "class")
|
|
59
|
-
|
|
60
|
-
if (match)
|
|
61
|
-
return match;
|
|
62
|
-
}
|
|
55
|
+
if (dark === "class")
|
|
56
|
+
return variants$1.variantMatcher("light", (input) => `.light $$ ${input}`)(v);
|
|
63
57
|
},
|
|
64
58
|
(v, { options: { dark } }) => {
|
|
65
|
-
if (dark === "media")
|
|
66
|
-
|
|
67
|
-
if (match) {
|
|
68
|
-
return {
|
|
69
|
-
...match,
|
|
70
|
-
parent: "@media (prefers-color-scheme: dark)"
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
59
|
+
if (dark === "media")
|
|
60
|
+
return variants$1.variantParentMatcher("dark", "@media (prefers-color-scheme: dark)")(v);
|
|
74
61
|
},
|
|
75
62
|
(v, { options: { dark } }) => {
|
|
76
|
-
if (dark === "media")
|
|
77
|
-
|
|
78
|
-
if (match) {
|
|
79
|
-
return {
|
|
80
|
-
...match,
|
|
81
|
-
parent: "@media (prefers-color-scheme: light)"
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
63
|
+
if (dark === "media")
|
|
64
|
+
return variants$1.variantParentMatcher("light", "@media (prefers-color-scheme: light)")(v);
|
|
85
65
|
}
|
|
86
66
|
];
|
|
87
67
|
|
|
68
|
+
const variantLanguageDirections = [
|
|
69
|
+
variants$1.variantMatcher("rtl", (input) => `[dir="rtl"] $$ ${input}`),
|
|
70
|
+
variants$1.variantMatcher("ltr", (input) => `[dir="ltr"] $$ ${input}`)
|
|
71
|
+
];
|
|
72
|
+
|
|
88
73
|
const variantImportant = {
|
|
89
74
|
match(matcher) {
|
|
90
75
|
if (matcher.startsWith("!")) {
|
|
@@ -118,21 +103,25 @@ const variantNegative = {
|
|
|
118
103
|
}
|
|
119
104
|
}
|
|
120
105
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
106
|
+
|
|
107
|
+
const variantMotions = [
|
|
108
|
+
variants$1.variantParentMatcher("motion-reduce", "@media (prefers-reduced-motion: reduce)"),
|
|
109
|
+
variants$1.variantParentMatcher("motion-safe", "@media (prefers-reduced-motion: no-preference)")
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
const variantOrientations = [
|
|
113
|
+
variants$1.variantParentMatcher("landscape", "@media (orientation: landscape)"),
|
|
114
|
+
variants$1.variantParentMatcher("portrait", "@media (orientation: portrait)")
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
const variantPrint = variants$1.variantParentMatcher("print", "@media print");
|
|
131
118
|
|
|
132
119
|
const variants = [
|
|
133
|
-
variantSpace,
|
|
134
120
|
variantNegative,
|
|
135
121
|
variantImportant,
|
|
122
|
+
variantPrint,
|
|
123
|
+
...variantOrientations,
|
|
124
|
+
...variantMotions,
|
|
136
125
|
variantBreakpoints,
|
|
137
126
|
...variantCombinators,
|
|
138
127
|
pseudo.variantPseudoClasses,
|
|
@@ -140,13 +129,17 @@ const variants = [
|
|
|
140
129
|
pseudo.variantTaggedPseudoClasses,
|
|
141
130
|
pseudo.variantPseudoElements,
|
|
142
131
|
pseudo.partClasses,
|
|
143
|
-
...variantColorsMediaOrClass
|
|
132
|
+
...variantColorsMediaOrClass,
|
|
133
|
+
...variantLanguageDirections
|
|
144
134
|
];
|
|
145
135
|
|
|
146
136
|
exports.variantBreakpoints = variantBreakpoints;
|
|
147
137
|
exports.variantColorsMediaOrClass = variantColorsMediaOrClass;
|
|
148
138
|
exports.variantCombinators = variantCombinators;
|
|
149
139
|
exports.variantImportant = variantImportant;
|
|
140
|
+
exports.variantLanguageDirections = variantLanguageDirections;
|
|
141
|
+
exports.variantMotions = variantMotions;
|
|
150
142
|
exports.variantNegative = variantNegative;
|
|
151
|
-
exports.
|
|
143
|
+
exports.variantOrientations = variantOrientations;
|
|
144
|
+
exports.variantPrint = variantPrint;
|
|
152
145
|
exports.variants = variants;
|
package/dist/chunks/default3.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { v as variantMatcher } from './variants.mjs';
|
|
1
|
+
import { v as variantMatcher, a as variantParentMatcher } from './variants.mjs';
|
|
2
2
|
import { v as variantPseudoClasses, a as variantPseudoClassFunctions, b as variantTaggedPseudoClasses, c as variantPseudoElements, p as partClasses } from './pseudo.mjs';
|
|
3
3
|
|
|
4
4
|
const regexCache = {};
|
|
@@ -46,43 +46,28 @@ const variantCombinators = [
|
|
|
46
46
|
|
|
47
47
|
const variantColorsMediaOrClass = [
|
|
48
48
|
(v, { options: { dark } }) => {
|
|
49
|
-
if (dark === "class")
|
|
50
|
-
|
|
51
|
-
if (match)
|
|
52
|
-
return match;
|
|
53
|
-
}
|
|
49
|
+
if (dark === "class")
|
|
50
|
+
return variantMatcher("dark", (input) => `.dark $$ ${input}`)(v);
|
|
54
51
|
},
|
|
55
52
|
(v, { options: { dark } }) => {
|
|
56
|
-
if (dark === "class")
|
|
57
|
-
|
|
58
|
-
if (match)
|
|
59
|
-
return match;
|
|
60
|
-
}
|
|
53
|
+
if (dark === "class")
|
|
54
|
+
return variantMatcher("light", (input) => `.light $$ ${input}`)(v);
|
|
61
55
|
},
|
|
62
56
|
(v, { options: { dark } }) => {
|
|
63
|
-
if (dark === "media")
|
|
64
|
-
|
|
65
|
-
if (match) {
|
|
66
|
-
return {
|
|
67
|
-
...match,
|
|
68
|
-
parent: "@media (prefers-color-scheme: dark)"
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
57
|
+
if (dark === "media")
|
|
58
|
+
return variantParentMatcher("dark", "@media (prefers-color-scheme: dark)")(v);
|
|
72
59
|
},
|
|
73
60
|
(v, { options: { dark } }) => {
|
|
74
|
-
if (dark === "media")
|
|
75
|
-
|
|
76
|
-
if (match) {
|
|
77
|
-
return {
|
|
78
|
-
...match,
|
|
79
|
-
parent: "@media (prefers-color-scheme: light)"
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
61
|
+
if (dark === "media")
|
|
62
|
+
return variantParentMatcher("light", "@media (prefers-color-scheme: light)")(v);
|
|
83
63
|
}
|
|
84
64
|
];
|
|
85
65
|
|
|
66
|
+
const variantLanguageDirections = [
|
|
67
|
+
variantMatcher("rtl", (input) => `[dir="rtl"] $$ ${input}`),
|
|
68
|
+
variantMatcher("ltr", (input) => `[dir="ltr"] $$ ${input}`)
|
|
69
|
+
];
|
|
70
|
+
|
|
86
71
|
const variantImportant = {
|
|
87
72
|
match(matcher) {
|
|
88
73
|
if (matcher.startsWith("!")) {
|
|
@@ -116,21 +101,25 @@ const variantNegative = {
|
|
|
116
101
|
}
|
|
117
102
|
}
|
|
118
103
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
104
|
+
|
|
105
|
+
const variantMotions = [
|
|
106
|
+
variantParentMatcher("motion-reduce", "@media (prefers-reduced-motion: reduce)"),
|
|
107
|
+
variantParentMatcher("motion-safe", "@media (prefers-reduced-motion: no-preference)")
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
const variantOrientations = [
|
|
111
|
+
variantParentMatcher("landscape", "@media (orientation: landscape)"),
|
|
112
|
+
variantParentMatcher("portrait", "@media (orientation: portrait)")
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
const variantPrint = variantParentMatcher("print", "@media print");
|
|
129
116
|
|
|
130
117
|
const variants = [
|
|
131
|
-
variantSpace,
|
|
132
118
|
variantNegative,
|
|
133
119
|
variantImportant,
|
|
120
|
+
variantPrint,
|
|
121
|
+
...variantOrientations,
|
|
122
|
+
...variantMotions,
|
|
134
123
|
variantBreakpoints,
|
|
135
124
|
...variantCombinators,
|
|
136
125
|
variantPseudoClasses,
|
|
@@ -138,7 +127,8 @@ const variants = [
|
|
|
138
127
|
variantTaggedPseudoClasses,
|
|
139
128
|
variantPseudoElements,
|
|
140
129
|
partClasses,
|
|
141
|
-
...variantColorsMediaOrClass
|
|
130
|
+
...variantColorsMediaOrClass,
|
|
131
|
+
...variantLanguageDirections
|
|
142
132
|
];
|
|
143
133
|
|
|
144
|
-
export { variantBreakpoints as a, variantCombinators as b, variantColorsMediaOrClass as c,
|
|
134
|
+
export { variantBreakpoints as a, variantCombinators as b, variantColorsMediaOrClass as c, variantLanguageDirections as d, variantImportant as e, variantNegative as f, variantMotions as g, variantOrientations as h, variantPrint as i, variants as v };
|
package/dist/chunks/pseudo.cjs
CHANGED
|
@@ -8,6 +8,7 @@ const PseudoClasses = Object.fromEntries([
|
|
|
8
8
|
"link",
|
|
9
9
|
"visited",
|
|
10
10
|
"target",
|
|
11
|
+
["open", "[open]"],
|
|
11
12
|
"hover",
|
|
12
13
|
"active",
|
|
13
14
|
"focus-visible",
|
|
@@ -24,39 +25,44 @@ const PseudoClasses = Object.fromEntries([
|
|
|
24
25
|
"indeterminate",
|
|
25
26
|
"valid",
|
|
26
27
|
"invalid",
|
|
28
|
+
"in-range",
|
|
29
|
+
"out-of-range",
|
|
27
30
|
"required",
|
|
28
31
|
"optional",
|
|
29
32
|
"root",
|
|
30
33
|
"empty",
|
|
31
|
-
["even-of-type", "nth-of-type(even)"],
|
|
32
|
-
["even", "nth-child(even)"],
|
|
33
|
-
["odd-of-type", "nth-of-type(odd)"],
|
|
34
|
-
["odd", "nth-child(odd)"],
|
|
34
|
+
["even-of-type", ":nth-of-type(even)"],
|
|
35
|
+
["even", ":nth-child(even)"],
|
|
36
|
+
["odd-of-type", ":nth-of-type(odd)"],
|
|
37
|
+
["odd", ":nth-child(odd)"],
|
|
35
38
|
"first-of-type",
|
|
36
|
-
["first", "first-child"],
|
|
39
|
+
["first", ":first-child"],
|
|
37
40
|
"last-of-type",
|
|
38
|
-
["last", "last-child"],
|
|
41
|
+
["last", ":last-child"],
|
|
39
42
|
"only-child",
|
|
40
43
|
"only-of-type"
|
|
41
44
|
].map(core.toArray));
|
|
42
|
-
const PseudoElements = [
|
|
45
|
+
const PseudoElements = Object.fromEntries([
|
|
43
46
|
"placeholder",
|
|
44
47
|
"before",
|
|
45
48
|
"after",
|
|
46
49
|
"first-letter",
|
|
47
50
|
"first-line",
|
|
48
|
-
"selection"
|
|
49
|
-
|
|
51
|
+
"selection",
|
|
52
|
+
"marker",
|
|
53
|
+
["file", "::file-selector-button"]
|
|
54
|
+
].map(core.toArray));
|
|
50
55
|
const PseudoClassFunctions = [
|
|
51
56
|
"not",
|
|
52
57
|
"is",
|
|
53
58
|
"where",
|
|
54
59
|
"has"
|
|
55
60
|
];
|
|
56
|
-
const
|
|
57
|
-
const PseudoElementsRE = new RegExp(`^(${PseudoElements.join("|")})[:-]`);
|
|
61
|
+
const PseudoElementsStr = Object.keys(PseudoElements).join("|");
|
|
58
62
|
const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
|
|
59
63
|
const PseudoClassFunctionsStr = PseudoClassFunctions.join("|");
|
|
64
|
+
const PartClassesRE = /(part-\[(.+)]:)(.+)/;
|
|
65
|
+
const PseudoElementsRE = new RegExp(`^(${PseudoElementsStr})[:-]`);
|
|
60
66
|
const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
|
|
61
67
|
const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
|
|
62
68
|
function shouldAdd(entires) {
|
|
@@ -68,13 +74,13 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
|
|
|
68
74
|
return (input) => {
|
|
69
75
|
const match = input.match(re);
|
|
70
76
|
if (match) {
|
|
71
|
-
let pseudo = PseudoClasses[match[3]] || match[3]
|
|
77
|
+
let pseudo = PseudoClasses[match[3]] || `:${match[3]}`;
|
|
72
78
|
if (match[2])
|
|
73
|
-
pseudo =
|
|
79
|
+
pseudo = `:${match[2]}(${pseudo})`;
|
|
74
80
|
return {
|
|
75
81
|
matcher: input.slice(match[1].length + tag.length + 2),
|
|
76
82
|
selector: (s, body) => {
|
|
77
|
-
return shouldAdd(body) && rawRe.test(s) ? s.replace(rawRe, `${parent}
|
|
83
|
+
return shouldAdd(body) && rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`;
|
|
78
84
|
}
|
|
79
85
|
};
|
|
80
86
|
}
|
|
@@ -83,9 +89,10 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
|
|
|
83
89
|
const variantPseudoElements = (input) => {
|
|
84
90
|
const match = input.match(PseudoElementsRE);
|
|
85
91
|
if (match) {
|
|
92
|
+
const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
|
|
86
93
|
return {
|
|
87
94
|
matcher: input.slice(match[1].length + 1),
|
|
88
|
-
selector: (s) => `${s}
|
|
95
|
+
selector: (s) => `${s}${pseudo}`
|
|
89
96
|
};
|
|
90
97
|
}
|
|
91
98
|
};
|
|
@@ -93,10 +100,10 @@ const variantPseudoClasses = {
|
|
|
93
100
|
match: (input) => {
|
|
94
101
|
const match = input.match(PseudoClassesRE);
|
|
95
102
|
if (match) {
|
|
96
|
-
const pseudo = PseudoClasses[match[1]] || match[1]
|
|
103
|
+
const pseudo = PseudoClasses[match[1]] || `:${match[1]}`;
|
|
97
104
|
return {
|
|
98
105
|
matcher: input.slice(match[1].length + 1),
|
|
99
|
-
selector: (s, body) => shouldAdd(body) && `${s}
|
|
106
|
+
selector: (s, body) => shouldAdd(body) && `${s}${pseudo}`
|
|
100
107
|
};
|
|
101
108
|
}
|
|
102
109
|
},
|
|
@@ -107,10 +114,10 @@ const variantPseudoClassFunctions = {
|
|
|
107
114
|
const match = input.match(PseudoClassFunctionsRE);
|
|
108
115
|
if (match) {
|
|
109
116
|
const fn = match[1];
|
|
110
|
-
const pseudo = PseudoClasses[match[2]] || match[2]
|
|
117
|
+
const pseudo = PseudoClasses[match[2]] || `:${match[2]}`;
|
|
111
118
|
return {
|
|
112
119
|
matcher: input.slice(match[1].length + match[2].length + 2),
|
|
113
|
-
selector: (s, body) => shouldAdd(body) && `${s}:${fn}(
|
|
120
|
+
selector: (s, body) => shouldAdd(body) && `${s}:${fn}(${pseudo})`
|
|
114
121
|
};
|
|
115
122
|
}
|
|
116
123
|
},
|
package/dist/chunks/pseudo.mjs
CHANGED
|
@@ -6,6 +6,7 @@ const PseudoClasses = Object.fromEntries([
|
|
|
6
6
|
"link",
|
|
7
7
|
"visited",
|
|
8
8
|
"target",
|
|
9
|
+
["open", "[open]"],
|
|
9
10
|
"hover",
|
|
10
11
|
"active",
|
|
11
12
|
"focus-visible",
|
|
@@ -22,39 +23,44 @@ const PseudoClasses = Object.fromEntries([
|
|
|
22
23
|
"indeterminate",
|
|
23
24
|
"valid",
|
|
24
25
|
"invalid",
|
|
26
|
+
"in-range",
|
|
27
|
+
"out-of-range",
|
|
25
28
|
"required",
|
|
26
29
|
"optional",
|
|
27
30
|
"root",
|
|
28
31
|
"empty",
|
|
29
|
-
["even-of-type", "nth-of-type(even)"],
|
|
30
|
-
["even", "nth-child(even)"],
|
|
31
|
-
["odd-of-type", "nth-of-type(odd)"],
|
|
32
|
-
["odd", "nth-child(odd)"],
|
|
32
|
+
["even-of-type", ":nth-of-type(even)"],
|
|
33
|
+
["even", ":nth-child(even)"],
|
|
34
|
+
["odd-of-type", ":nth-of-type(odd)"],
|
|
35
|
+
["odd", ":nth-child(odd)"],
|
|
33
36
|
"first-of-type",
|
|
34
|
-
["first", "first-child"],
|
|
37
|
+
["first", ":first-child"],
|
|
35
38
|
"last-of-type",
|
|
36
|
-
["last", "last-child"],
|
|
39
|
+
["last", ":last-child"],
|
|
37
40
|
"only-child",
|
|
38
41
|
"only-of-type"
|
|
39
42
|
].map(toArray));
|
|
40
|
-
const PseudoElements = [
|
|
43
|
+
const PseudoElements = Object.fromEntries([
|
|
41
44
|
"placeholder",
|
|
42
45
|
"before",
|
|
43
46
|
"after",
|
|
44
47
|
"first-letter",
|
|
45
48
|
"first-line",
|
|
46
|
-
"selection"
|
|
47
|
-
|
|
49
|
+
"selection",
|
|
50
|
+
"marker",
|
|
51
|
+
["file", "::file-selector-button"]
|
|
52
|
+
].map(toArray));
|
|
48
53
|
const PseudoClassFunctions = [
|
|
49
54
|
"not",
|
|
50
55
|
"is",
|
|
51
56
|
"where",
|
|
52
57
|
"has"
|
|
53
58
|
];
|
|
54
|
-
const
|
|
55
|
-
const PseudoElementsRE = new RegExp(`^(${PseudoElements.join("|")})[:-]`);
|
|
59
|
+
const PseudoElementsStr = Object.keys(PseudoElements).join("|");
|
|
56
60
|
const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
|
|
57
61
|
const PseudoClassFunctionsStr = PseudoClassFunctions.join("|");
|
|
62
|
+
const PartClassesRE = /(part-\[(.+)]:)(.+)/;
|
|
63
|
+
const PseudoElementsRE = new RegExp(`^(${PseudoElementsStr})[:-]`);
|
|
58
64
|
const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
|
|
59
65
|
const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
|
|
60
66
|
function shouldAdd(entires) {
|
|
@@ -66,13 +72,13 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
|
|
|
66
72
|
return (input) => {
|
|
67
73
|
const match = input.match(re);
|
|
68
74
|
if (match) {
|
|
69
|
-
let pseudo = PseudoClasses[match[3]] || match[3]
|
|
75
|
+
let pseudo = PseudoClasses[match[3]] || `:${match[3]}`;
|
|
70
76
|
if (match[2])
|
|
71
|
-
pseudo =
|
|
77
|
+
pseudo = `:${match[2]}(${pseudo})`;
|
|
72
78
|
return {
|
|
73
79
|
matcher: input.slice(match[1].length + tag.length + 2),
|
|
74
80
|
selector: (s, body) => {
|
|
75
|
-
return shouldAdd(body) && rawRe.test(s) ? s.replace(rawRe, `${parent}
|
|
81
|
+
return shouldAdd(body) && rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`;
|
|
76
82
|
}
|
|
77
83
|
};
|
|
78
84
|
}
|
|
@@ -81,9 +87,10 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
|
|
|
81
87
|
const variantPseudoElements = (input) => {
|
|
82
88
|
const match = input.match(PseudoElementsRE);
|
|
83
89
|
if (match) {
|
|
90
|
+
const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
|
|
84
91
|
return {
|
|
85
92
|
matcher: input.slice(match[1].length + 1),
|
|
86
|
-
selector: (s) => `${s}
|
|
93
|
+
selector: (s) => `${s}${pseudo}`
|
|
87
94
|
};
|
|
88
95
|
}
|
|
89
96
|
};
|
|
@@ -91,10 +98,10 @@ const variantPseudoClasses = {
|
|
|
91
98
|
match: (input) => {
|
|
92
99
|
const match = input.match(PseudoClassesRE);
|
|
93
100
|
if (match) {
|
|
94
|
-
const pseudo = PseudoClasses[match[1]] || match[1]
|
|
101
|
+
const pseudo = PseudoClasses[match[1]] || `:${match[1]}`;
|
|
95
102
|
return {
|
|
96
103
|
matcher: input.slice(match[1].length + 1),
|
|
97
|
-
selector: (s, body) => shouldAdd(body) && `${s}
|
|
104
|
+
selector: (s, body) => shouldAdd(body) && `${s}${pseudo}`
|
|
98
105
|
};
|
|
99
106
|
}
|
|
100
107
|
},
|
|
@@ -105,10 +112,10 @@ const variantPseudoClassFunctions = {
|
|
|
105
112
|
const match = input.match(PseudoClassFunctionsRE);
|
|
106
113
|
if (match) {
|
|
107
114
|
const fn = match[1];
|
|
108
|
-
const pseudo = PseudoClasses[match[2]] || match[2]
|
|
115
|
+
const pseudo = PseudoClasses[match[2]] || `:${match[2]}`;
|
|
109
116
|
return {
|
|
110
117
|
matcher: input.slice(match[1].length + match[2].length + 2),
|
|
111
|
-
selector: (s, body) => shouldAdd(body) && `${s}:${fn}(
|
|
118
|
+
selector: (s, body) => shouldAdd(body) && `${s}:${fn}(${pseudo})`
|
|
112
119
|
};
|
|
113
120
|
}
|
|
114
121
|
},
|
|
@@ -35,6 +35,31 @@ const xyzMap = {
|
|
|
35
35
|
"z": ["-z"],
|
|
36
36
|
"": ["-x", "-y"]
|
|
37
37
|
};
|
|
38
|
+
const basePositionMap = [
|
|
39
|
+
"top",
|
|
40
|
+
"top center",
|
|
41
|
+
"top left",
|
|
42
|
+
"top right",
|
|
43
|
+
"bottom",
|
|
44
|
+
"bottom center",
|
|
45
|
+
"bottom left",
|
|
46
|
+
"bottom right",
|
|
47
|
+
"left",
|
|
48
|
+
"left center",
|
|
49
|
+
"left top",
|
|
50
|
+
"left bottom",
|
|
51
|
+
"right",
|
|
52
|
+
"right center",
|
|
53
|
+
"right top",
|
|
54
|
+
"right bottom",
|
|
55
|
+
"center",
|
|
56
|
+
"center top",
|
|
57
|
+
"center bottom",
|
|
58
|
+
"center left",
|
|
59
|
+
"center right",
|
|
60
|
+
"center center"
|
|
61
|
+
];
|
|
62
|
+
const positionMap = Object.assign({}, ...basePositionMap.map((p) => ({ [p.replace(/ /, "-")]: p })), ...basePositionMap.map((p) => ({ [p.replace(/\b(\w)\w+/g, "$1").replace(/ /, "")]: p })));
|
|
38
63
|
|
|
39
64
|
const cssBasicProps = [
|
|
40
65
|
"color",
|
|
@@ -93,13 +118,17 @@ const cssProps = [
|
|
|
93
118
|
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax)?$/i;
|
|
94
119
|
const numberRE = /^(-?[0-9.]+)$/i;
|
|
95
120
|
const unitOnlyRE = /^(px)$/i;
|
|
121
|
+
function round(n) {
|
|
122
|
+
return n.toFixed(10).replace(/\.0+$/, "").replace(/(\.\d+?)0+$/, "$1");
|
|
123
|
+
}
|
|
96
124
|
function numberWithUnit(str) {
|
|
97
125
|
const match = str.match(numberWithUnitRE);
|
|
98
126
|
if (!match)
|
|
99
127
|
return;
|
|
100
|
-
const [, , unit] = match;
|
|
101
|
-
|
|
102
|
-
|
|
128
|
+
const [, n, unit] = match;
|
|
129
|
+
const num = parseFloat(n);
|
|
130
|
+
if (unit && !Number.isNaN(num))
|
|
131
|
+
return `${round(num)}${unit}`;
|
|
103
132
|
}
|
|
104
133
|
function auto(str) {
|
|
105
134
|
if (str === "auto" || str === "a")
|
|
@@ -112,11 +141,9 @@ function rem(str) {
|
|
|
112
141
|
if (!match)
|
|
113
142
|
return;
|
|
114
143
|
const [, n, unit] = match;
|
|
115
|
-
if (unit)
|
|
116
|
-
return str;
|
|
117
144
|
const num = parseFloat(n);
|
|
118
145
|
if (!Number.isNaN(num))
|
|
119
|
-
return `${num / 4}rem`;
|
|
146
|
+
return unit ? `${round(num)}${unit}` : `${round(num / 4)}rem`;
|
|
120
147
|
}
|
|
121
148
|
function px(str) {
|
|
122
149
|
if (str.match(unitOnlyRE))
|
|
@@ -125,25 +152,23 @@ function px(str) {
|
|
|
125
152
|
if (!match)
|
|
126
153
|
return;
|
|
127
154
|
const [, n, unit] = match;
|
|
128
|
-
if (unit)
|
|
129
|
-
return str;
|
|
130
155
|
const num = parseFloat(n);
|
|
131
156
|
if (!Number.isNaN(num))
|
|
132
|
-
return `${num}px`;
|
|
157
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}px`;
|
|
133
158
|
}
|
|
134
159
|
function number(str) {
|
|
135
160
|
if (!numberRE.test(str))
|
|
136
161
|
return;
|
|
137
162
|
const num = parseFloat(str);
|
|
138
163
|
if (!Number.isNaN(num))
|
|
139
|
-
return num;
|
|
164
|
+
return round(num);
|
|
140
165
|
}
|
|
141
166
|
function percent(str) {
|
|
142
167
|
if (str.endsWith("%"))
|
|
143
168
|
str = str.slice(0, -1);
|
|
144
169
|
const num = parseFloat(str);
|
|
145
170
|
if (!Number.isNaN(num))
|
|
146
|
-
return `${num / 100}`;
|
|
171
|
+
return `${round(num / 100)}`;
|
|
147
172
|
}
|
|
148
173
|
function fraction(str) {
|
|
149
174
|
if (str === "full")
|
|
@@ -151,7 +176,7 @@ function fraction(str) {
|
|
|
151
176
|
const [left, right] = str.split("/");
|
|
152
177
|
const num = parseFloat(left) / parseFloat(right);
|
|
153
178
|
if (!Number.isNaN(num))
|
|
154
|
-
return `${num * 100}%`;
|
|
179
|
+
return `${round(num * 100)}%`;
|
|
155
180
|
}
|
|
156
181
|
function bracket(str) {
|
|
157
182
|
if (str && str[0] === "[" && str[str.length - 1] === "]") {
|
|
@@ -165,20 +190,19 @@ function cssvar(str) {
|
|
|
165
190
|
return `var(--${str.slice(1)})`;
|
|
166
191
|
}
|
|
167
192
|
function time(str) {
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
193
|
+
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
194
|
+
if (!match)
|
|
170
195
|
return;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
196
|
+
const [, n, unit] = match;
|
|
197
|
+
const num = parseFloat(n);
|
|
198
|
+
if (!Number.isNaN(num))
|
|
199
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}ms`;
|
|
174
200
|
}
|
|
175
201
|
function global(str) {
|
|
176
202
|
if (["inherit", "initial", "revert", "unset"].includes(str))
|
|
177
203
|
return str;
|
|
178
204
|
}
|
|
179
205
|
function properties(str) {
|
|
180
|
-
if (str === void 0)
|
|
181
|
-
return;
|
|
182
206
|
for (const prop of str.split(",")) {
|
|
183
207
|
if (!cssProps.includes(prop))
|
|
184
208
|
return;
|
|
@@ -225,8 +249,10 @@ const parseColor = (body, theme) => {
|
|
|
225
249
|
const bracketOrMain = bracket || main;
|
|
226
250
|
if (bracketOrMain.startsWith("#"))
|
|
227
251
|
color = bracketOrMain.slice(1);
|
|
228
|
-
if (bracketOrMain.startsWith("hex-"))
|
|
252
|
+
else if (bracketOrMain.startsWith("hex-"))
|
|
229
253
|
color = bracketOrMain.slice(4);
|
|
254
|
+
else if (main.startsWith("$"))
|
|
255
|
+
color = handler.cssvar(main);
|
|
230
256
|
color = color || bracket;
|
|
231
257
|
let no = "DEFAULT";
|
|
232
258
|
if (!color) {
|
|
@@ -247,37 +273,46 @@ const parseColor = (body, theme) => {
|
|
|
247
273
|
else if (no && colorData)
|
|
248
274
|
color = colorData[no];
|
|
249
275
|
}
|
|
276
|
+
const rgba = core.hex2rgba(color);
|
|
277
|
+
const alpha = opacity ? opacity[0] === "[" ? handler.bracket.percent(opacity) : parseFloat(opacity) / 100 : rgba?.[3];
|
|
278
|
+
const hasAlpha = alpha != null && !Number.isNaN(alpha);
|
|
279
|
+
if (rgba) {
|
|
280
|
+
if (hasAlpha) {
|
|
281
|
+
rgba[3] = typeof alpha === "string" && !alpha.includes("%") ? parseFloat(alpha) : alpha;
|
|
282
|
+
} else {
|
|
283
|
+
rgba.splice(3);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
250
286
|
return {
|
|
251
287
|
opacity,
|
|
252
288
|
name,
|
|
253
289
|
no,
|
|
254
290
|
color,
|
|
255
|
-
rgba
|
|
291
|
+
rgba,
|
|
292
|
+
alpha: hasAlpha ? alpha : void 0
|
|
256
293
|
};
|
|
257
294
|
};
|
|
258
295
|
const colorResolver = (property, varName) => ([, body], { theme }) => {
|
|
259
296
|
const data = parseColor(body, theme);
|
|
260
297
|
if (!data)
|
|
261
298
|
return;
|
|
262
|
-
const { opacity, color, rgba } = data;
|
|
299
|
+
const { alpha, opacity, color, rgba } = data;
|
|
263
300
|
if (!color)
|
|
264
301
|
return;
|
|
265
|
-
const a = opacity ? opacity[0] === "[" ? handler.bracket.percent(opacity) : parseFloat(opacity) / 100 : rgba?.[3];
|
|
266
302
|
if (rgba) {
|
|
267
|
-
if (
|
|
268
|
-
rgba[3] = typeof a === "string" && !a.includes("%") ? parseFloat(a) : a;
|
|
303
|
+
if (alpha != null) {
|
|
269
304
|
return {
|
|
270
305
|
[property]: `rgba(${rgba.join(",")})`
|
|
271
306
|
};
|
|
272
307
|
} else {
|
|
273
308
|
return {
|
|
274
|
-
[`--un-${varName}-opacity`]: 1,
|
|
275
|
-
[property]: `rgba(${rgba.
|
|
309
|
+
[`--un-${varName}-opacity`]: (opacity && handler.cssvar(opacity)) ?? 1,
|
|
310
|
+
[property]: `rgba(${rgba.join(",")},var(--un-${varName}-opacity))`
|
|
276
311
|
};
|
|
277
312
|
}
|
|
278
313
|
} else {
|
|
279
314
|
return {
|
|
280
|
-
[property]: color.replace("%alpha", `${
|
|
315
|
+
[property]: color.replace("%alpha", `${alpha || 1}`)
|
|
281
316
|
};
|
|
282
317
|
}
|
|
283
318
|
};
|
|
@@ -290,5 +325,6 @@ exports.directionSize = directionSize;
|
|
|
290
325
|
exports.h = h;
|
|
291
326
|
exports.handler = handler;
|
|
292
327
|
exports.parseColor = parseColor;
|
|
328
|
+
exports.positionMap = positionMap;
|
|
293
329
|
exports.valueHandlers = valueHandlers;
|
|
294
330
|
exports.xyzMap = xyzMap;
|