@unocss/preset-mini 0.20.0 → 0.21.0
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 +10 -12
- package/dist/chunks/default.mjs +10 -12
- package/dist/chunks/default2.cjs +203 -263
- package/dist/chunks/default2.mjs +213 -273
- package/dist/chunks/default3.cjs +35 -60
- package/dist/chunks/default3.mjs +34 -61
- package/dist/chunks/pseudo.cjs +38 -29
- package/dist/chunks/pseudo.mjs +38 -29
- package/dist/chunks/utilities.cjs +87 -43
- package/dist/chunks/utilities.mjs +87 -44
- package/dist/chunks/variants.cjs +17 -2
- package/dist/chunks/variants.mjs +17 -3
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/theme.d.ts +0 -10
- package/dist/utils.cjs +2 -0
- package/dist/utils.d.ts +9 -4
- package/dist/utils.mjs +2 -2
- package/dist/variants.cjs +3 -1
- package/dist/variants.d.ts +15 -6
- package/dist/variants.mjs +1 -1
- package/package.json +2 -2
package/dist/chunks/default3.cjs
CHANGED
|
@@ -46,43 +46,22 @@ const variantCombinators = [
|
|
|
46
46
|
variants$1.variantMatcher("svg", (input) => `${input} svg *`)
|
|
47
47
|
];
|
|
48
48
|
|
|
49
|
-
const variantColorsMediaOrClass =
|
|
50
|
-
(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
(v, { options: { dark } }) => {
|
|
58
|
-
if (dark === "class") {
|
|
59
|
-
const match = variants$1.variantMatcher("light", (input) => `.light $$ ${input}`)(v);
|
|
60
|
-
if (match)
|
|
61
|
-
return match;
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
(v, { options: { dark } }) => {
|
|
65
|
-
if (dark === "media") {
|
|
66
|
-
const match = variants$1.variantMatcher("dark")(v);
|
|
67
|
-
if (match) {
|
|
68
|
-
return {
|
|
69
|
-
...match,
|
|
70
|
-
parent: "@media (prefers-color-scheme: dark)"
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
(v, { options: { dark } }) => {
|
|
76
|
-
if (dark === "media") {
|
|
77
|
-
const match = variants$1.variantMatcher("light")(v);
|
|
78
|
-
if (match) {
|
|
79
|
-
return {
|
|
80
|
-
...match,
|
|
81
|
-
parent: "@media (prefers-color-scheme: light)"
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
49
|
+
const variantColorsMediaOrClass = (options = {}) => {
|
|
50
|
+
if (options?.dark === "class") {
|
|
51
|
+
return [
|
|
52
|
+
variants$1.variantMatcher("dark", (input) => `.dark $$ ${input}`),
|
|
53
|
+
variants$1.variantMatcher("light", (input) => `.light $$ ${input}`)
|
|
54
|
+
];
|
|
85
55
|
}
|
|
56
|
+
return [
|
|
57
|
+
variants$1.variantParentMatcher("dark", "@media (prefers-color-scheme: dark)"),
|
|
58
|
+
variants$1.variantParentMatcher("light", "@media (prefers-color-scheme: light)")
|
|
59
|
+
];
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const variantLanguageDirections = [
|
|
63
|
+
variants$1.variantMatcher("rtl", (input) => `[dir="rtl"] $$ ${input}`),
|
|
64
|
+
variants$1.variantMatcher("ltr", (input) => `[dir="ltr"] $$ ${input}`)
|
|
86
65
|
];
|
|
87
66
|
|
|
88
67
|
const variantImportant = {
|
|
@@ -118,47 +97,43 @@ const variantNegative = {
|
|
|
118
97
|
}
|
|
119
98
|
}
|
|
120
99
|
};
|
|
121
|
-
const variantSpace = (matcher) => {
|
|
122
|
-
if (/^space-?([xy])-?(-?.+)$/.test(matcher) || /^divide-/.test(matcher)) {
|
|
123
|
-
return {
|
|
124
|
-
matcher,
|
|
125
|
-
selector: (input) => {
|
|
126
|
-
return `${input}>:not([hidden])~:not([hidden])`;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
100
|
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
101
|
+
const variantMotions = [
|
|
102
|
+
variants$1.variantParentMatcher("motion-reduce", "@media (prefers-reduced-motion: reduce)"),
|
|
103
|
+
variants$1.variantParentMatcher("motion-safe", "@media (prefers-reduced-motion: no-preference)")
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
const variantOrientations = [
|
|
107
|
+
variants$1.variantParentMatcher("landscape", "@media (orientation: landscape)"),
|
|
108
|
+
variants$1.variantParentMatcher("portrait", "@media (orientation: portrait)")
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
const variantPrint = variants$1.variantParentMatcher("print", "@media print");
|
|
141
112
|
|
|
142
|
-
const variants = [
|
|
143
|
-
variantSpace,
|
|
113
|
+
const variants = (options) => [
|
|
144
114
|
variantNegative,
|
|
145
115
|
variantImportant,
|
|
146
116
|
variantPrint,
|
|
117
|
+
...variantOrientations,
|
|
118
|
+
...variantMotions,
|
|
147
119
|
variantBreakpoints,
|
|
148
120
|
...variantCombinators,
|
|
149
121
|
pseudo.variantPseudoClasses,
|
|
150
122
|
pseudo.variantPseudoClassFunctions,
|
|
151
|
-
pseudo.variantTaggedPseudoClasses,
|
|
123
|
+
...pseudo.variantTaggedPseudoClasses(options),
|
|
152
124
|
pseudo.variantPseudoElements,
|
|
153
125
|
pseudo.partClasses,
|
|
154
|
-
...variantColorsMediaOrClass
|
|
126
|
+
...variantColorsMediaOrClass(options),
|
|
127
|
+
...variantLanguageDirections
|
|
155
128
|
];
|
|
156
129
|
|
|
157
130
|
exports.variantBreakpoints = variantBreakpoints;
|
|
158
131
|
exports.variantColorsMediaOrClass = variantColorsMediaOrClass;
|
|
159
132
|
exports.variantCombinators = variantCombinators;
|
|
160
133
|
exports.variantImportant = variantImportant;
|
|
134
|
+
exports.variantLanguageDirections = variantLanguageDirections;
|
|
135
|
+
exports.variantMotions = variantMotions;
|
|
161
136
|
exports.variantNegative = variantNegative;
|
|
137
|
+
exports.variantOrientations = variantOrientations;
|
|
162
138
|
exports.variantPrint = variantPrint;
|
|
163
|
-
exports.variantSpace = variantSpace;
|
|
164
139
|
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 = {};
|
|
@@ -44,43 +44,22 @@ const variantCombinators = [
|
|
|
44
44
|
variantMatcher("svg", (input) => `${input} svg *`)
|
|
45
45
|
];
|
|
46
46
|
|
|
47
|
-
const variantColorsMediaOrClass =
|
|
48
|
-
(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
(v, { options: { dark } }) => {
|
|
56
|
-
if (dark === "class") {
|
|
57
|
-
const match = variantMatcher("light", (input) => `.light $$ ${input}`)(v);
|
|
58
|
-
if (match)
|
|
59
|
-
return match;
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
(v, { options: { dark } }) => {
|
|
63
|
-
if (dark === "media") {
|
|
64
|
-
const match = variantMatcher("dark")(v);
|
|
65
|
-
if (match) {
|
|
66
|
-
return {
|
|
67
|
-
...match,
|
|
68
|
-
parent: "@media (prefers-color-scheme: dark)"
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
(v, { options: { dark } }) => {
|
|
74
|
-
if (dark === "media") {
|
|
75
|
-
const match = variantMatcher("light")(v);
|
|
76
|
-
if (match) {
|
|
77
|
-
return {
|
|
78
|
-
...match,
|
|
79
|
-
parent: "@media (prefers-color-scheme: light)"
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
47
|
+
const variantColorsMediaOrClass = (options = {}) => {
|
|
48
|
+
if (options?.dark === "class") {
|
|
49
|
+
return [
|
|
50
|
+
variantMatcher("dark", (input) => `.dark $$ ${input}`),
|
|
51
|
+
variantMatcher("light", (input) => `.light $$ ${input}`)
|
|
52
|
+
];
|
|
83
53
|
}
|
|
54
|
+
return [
|
|
55
|
+
variantParentMatcher("dark", "@media (prefers-color-scheme: dark)"),
|
|
56
|
+
variantParentMatcher("light", "@media (prefers-color-scheme: light)")
|
|
57
|
+
];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const variantLanguageDirections = [
|
|
61
|
+
variantMatcher("rtl", (input) => `[dir="rtl"] $$ ${input}`),
|
|
62
|
+
variantMatcher("ltr", (input) => `[dir="ltr"] $$ ${input}`)
|
|
84
63
|
];
|
|
85
64
|
|
|
86
65
|
const variantImportant = {
|
|
@@ -116,40 +95,34 @@ const variantNegative = {
|
|
|
116
95
|
}
|
|
117
96
|
}
|
|
118
97
|
};
|
|
119
|
-
const variantSpace = (matcher) => {
|
|
120
|
-
if (/^space-?([xy])-?(-?.+)$/.test(matcher) || /^divide-/.test(matcher)) {
|
|
121
|
-
return {
|
|
122
|
-
matcher,
|
|
123
|
-
selector: (input) => {
|
|
124
|
-
return `${input}>:not([hidden])~:not([hidden])`;
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
98
|
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
99
|
+
const variantMotions = [
|
|
100
|
+
variantParentMatcher("motion-reduce", "@media (prefers-reduced-motion: reduce)"),
|
|
101
|
+
variantParentMatcher("motion-safe", "@media (prefers-reduced-motion: no-preference)")
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
const variantOrientations = [
|
|
105
|
+
variantParentMatcher("landscape", "@media (orientation: landscape)"),
|
|
106
|
+
variantParentMatcher("portrait", "@media (orientation: portrait)")
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
const variantPrint = variantParentMatcher("print", "@media print");
|
|
139
110
|
|
|
140
|
-
const variants = [
|
|
141
|
-
variantSpace,
|
|
111
|
+
const variants = (options) => [
|
|
142
112
|
variantNegative,
|
|
143
113
|
variantImportant,
|
|
144
114
|
variantPrint,
|
|
115
|
+
...variantOrientations,
|
|
116
|
+
...variantMotions,
|
|
145
117
|
variantBreakpoints,
|
|
146
118
|
...variantCombinators,
|
|
147
119
|
variantPseudoClasses,
|
|
148
120
|
variantPseudoClassFunctions,
|
|
149
|
-
variantTaggedPseudoClasses,
|
|
121
|
+
...variantTaggedPseudoClasses(options),
|
|
150
122
|
variantPseudoElements,
|
|
151
123
|
partClasses,
|
|
152
|
-
...variantColorsMediaOrClass
|
|
124
|
+
...variantColorsMediaOrClass(options),
|
|
125
|
+
...variantLanguageDirections
|
|
153
126
|
];
|
|
154
127
|
|
|
155
|
-
export { variantBreakpoints as a, variantCombinators as b, variantColorsMediaOrClass as c,
|
|
128
|
+
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,25 +114,27 @@ 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
|
},
|
|
117
124
|
multiPass: true
|
|
118
125
|
};
|
|
119
|
-
const variantTaggedPseudoClasses = {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
const variantTaggedPseudoClasses = (options = {}) => {
|
|
127
|
+
const attributify = !!options?.attributifyPseudo;
|
|
128
|
+
return [
|
|
129
|
+
{
|
|
130
|
+
match: taggedPseudoClassMatcher("group", attributify ? '[group=""]' : ".group", " "),
|
|
131
|
+
multiPass: true
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
|
|
135
|
+
multiPass: true
|
|
136
|
+
}
|
|
137
|
+
];
|
|
129
138
|
};
|
|
130
139
|
const partClasses = {
|
|
131
140
|
match: (input) => {
|
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,25 +112,27 @@ 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
|
},
|
|
115
122
|
multiPass: true
|
|
116
123
|
};
|
|
117
|
-
const variantTaggedPseudoClasses = {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
const variantTaggedPseudoClasses = (options = {}) => {
|
|
125
|
+
const attributify = !!options?.attributifyPseudo;
|
|
126
|
+
return [
|
|
127
|
+
{
|
|
128
|
+
match: taggedPseudoClassMatcher("group", attributify ? '[group=""]' : ".group", " "),
|
|
129
|
+
multiPass: true
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
|
|
133
|
+
multiPass: true
|
|
134
|
+
}
|
|
135
|
+
];
|
|
127
136
|
};
|
|
128
137
|
const partClasses = {
|
|
129
138
|
match: (input) => {
|