@unocss/preset-mini 0.22.6 → 0.22.7
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/default3.cjs +17 -0
- package/dist/chunks/default3.mjs +17 -1
- package/dist/chunks/utilities.cjs +207 -2
- package/dist/chunks/utilities.mjs +206 -3
- package/dist/utils.cjs +2 -0
- package/dist/utils.d.ts +5 -2
- package/dist/utils.mjs +1 -1
- package/dist/variants.cjs +1 -0
- package/dist/variants.d.ts +2 -1
- package/dist/variants.mjs +1 -1
- package/package.json +2 -2
package/dist/chunks/default3.cjs
CHANGED
|
@@ -74,6 +74,17 @@ const variantLanguageDirections = [
|
|
|
74
74
|
variants$1.variantMatcher("ltr", (input) => `[dir="ltr"] $$ ${input}`)
|
|
75
75
|
];
|
|
76
76
|
|
|
77
|
+
const variantLayer = {
|
|
78
|
+
match(matcher) {
|
|
79
|
+
const match = matcher.match(/layer-([\d\w]+)[:-]/);
|
|
80
|
+
if (match) {
|
|
81
|
+
return {
|
|
82
|
+
matcher: matcher.slice(match[0].length),
|
|
83
|
+
layer: match[1]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
77
88
|
const variantImportant = {
|
|
78
89
|
match(matcher) {
|
|
79
90
|
if (matcher.startsWith("!")) {
|
|
@@ -233,6 +244,10 @@ const variantTaggedPseudoClasses = (options = {}) => {
|
|
|
233
244
|
{
|
|
234
245
|
match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
|
|
235
246
|
multiPass: true
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
match: taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
|
|
250
|
+
multiPass: true
|
|
236
251
|
}
|
|
237
252
|
];
|
|
238
253
|
};
|
|
@@ -251,6 +266,7 @@ const partClasses = {
|
|
|
251
266
|
};
|
|
252
267
|
|
|
253
268
|
const variants = (options) => [
|
|
269
|
+
variantLayer,
|
|
254
270
|
variantNegative,
|
|
255
271
|
variantImportant,
|
|
256
272
|
variantPrint,
|
|
@@ -273,6 +289,7 @@ exports.variantColorsMediaOrClass = variantColorsMediaOrClass;
|
|
|
273
289
|
exports.variantCombinators = variantCombinators;
|
|
274
290
|
exports.variantImportant = variantImportant;
|
|
275
291
|
exports.variantLanguageDirections = variantLanguageDirections;
|
|
292
|
+
exports.variantLayer = variantLayer;
|
|
276
293
|
exports.variantMotions = variantMotions;
|
|
277
294
|
exports.variantNegative = variantNegative;
|
|
278
295
|
exports.variantOrientations = variantOrientations;
|
package/dist/chunks/default3.mjs
CHANGED
|
@@ -72,6 +72,17 @@ const variantLanguageDirections = [
|
|
|
72
72
|
variantMatcher("ltr", (input) => `[dir="ltr"] $$ ${input}`)
|
|
73
73
|
];
|
|
74
74
|
|
|
75
|
+
const variantLayer = {
|
|
76
|
+
match(matcher) {
|
|
77
|
+
const match = matcher.match(/layer-([\d\w]+)[:-]/);
|
|
78
|
+
if (match) {
|
|
79
|
+
return {
|
|
80
|
+
matcher: matcher.slice(match[0].length),
|
|
81
|
+
layer: match[1]
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
75
86
|
const variantImportant = {
|
|
76
87
|
match(matcher) {
|
|
77
88
|
if (matcher.startsWith("!")) {
|
|
@@ -231,6 +242,10 @@ const variantTaggedPseudoClasses = (options = {}) => {
|
|
|
231
242
|
{
|
|
232
243
|
match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
|
|
233
244
|
multiPass: true
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
match: taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
|
|
248
|
+
multiPass: true
|
|
234
249
|
}
|
|
235
250
|
];
|
|
236
251
|
};
|
|
@@ -249,6 +264,7 @@ const partClasses = {
|
|
|
249
264
|
};
|
|
250
265
|
|
|
251
266
|
const variants = (options) => [
|
|
267
|
+
variantLayer,
|
|
252
268
|
variantNegative,
|
|
253
269
|
variantImportant,
|
|
254
270
|
variantPrint,
|
|
@@ -265,4 +281,4 @@ const variants = (options) => [
|
|
|
265
281
|
...variantLanguageDirections
|
|
266
282
|
];
|
|
267
283
|
|
|
268
|
-
export { variantBreakpoints as a, variantCombinators as b, variantMotions as c, variantOrientations as d, variantPrint as e, variantColorsMediaOrClass as f, variantLanguageDirections as g,
|
|
284
|
+
export { variantBreakpoints as a, variantCombinators as b, variantMotions as c, variantOrientations as d, variantPrint as e, variantColorsMediaOrClass as f, variantLanguageDirections as g, variantLayer as h, variantImportant as i, variantNegative as j, variantPseudoElements as k, variantPseudoClasses as l, variantPseudoClassFunctions as m, variantTaggedPseudoClasses as n, partClasses as p, variants as v };
|
|
@@ -2,6 +2,209 @@
|
|
|
2
2
|
|
|
3
3
|
const core = require('@unocss/core');
|
|
4
4
|
|
|
5
|
+
function hex2rgba(hex = "") {
|
|
6
|
+
const color = parseHexColor(hex);
|
|
7
|
+
if (color != null) {
|
|
8
|
+
const { components, alpha } = color;
|
|
9
|
+
if (alpha === void 0)
|
|
10
|
+
return components;
|
|
11
|
+
return [...components, alpha];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function parseHexColor(str) {
|
|
15
|
+
const [, body] = str.match(/^#?([\da-f]+)$/i) || [];
|
|
16
|
+
if (!body)
|
|
17
|
+
return;
|
|
18
|
+
switch (body.length) {
|
|
19
|
+
case 3:
|
|
20
|
+
case 4:
|
|
21
|
+
const digits = Array.from(body, (s) => Number.parseInt(s, 16)).map((n) => n << 4 | n);
|
|
22
|
+
return {
|
|
23
|
+
type: "rgb",
|
|
24
|
+
components: digits.slice(0, 3),
|
|
25
|
+
alpha: body.length === 3 ? void 0 : Math.round(digits[3] / 255 * 100) / 100
|
|
26
|
+
};
|
|
27
|
+
case 6:
|
|
28
|
+
case 8:
|
|
29
|
+
const value = Number.parseInt(body, 16);
|
|
30
|
+
return {
|
|
31
|
+
type: "rgb",
|
|
32
|
+
components: body.length === 6 ? [value >> 16 & 255, value >> 8 & 255, value & 255] : [value >> 24 & 255, value >> 16 & 255, value >> 8 & 255],
|
|
33
|
+
alpha: body.length === 6 ? void 0 : Math.round((value & 255) / 255 * 100) / 100
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function parseCssColor(str = "") {
|
|
38
|
+
const color = parseColor$1(str);
|
|
39
|
+
if (color == null)
|
|
40
|
+
return;
|
|
41
|
+
const { type: casedType, components, alpha } = color;
|
|
42
|
+
const type = casedType.toLowerCase();
|
|
43
|
+
if (["rgba", "hsla"].includes(type) && alpha === void 0)
|
|
44
|
+
return;
|
|
45
|
+
if (["rgb", "hsl", "hwb", "lab", "lch", "oklab", "oklch"].includes(type) && components.length !== 3)
|
|
46
|
+
return;
|
|
47
|
+
return { type, components, alpha };
|
|
48
|
+
}
|
|
49
|
+
function parseColor$1(str) {
|
|
50
|
+
if (!str)
|
|
51
|
+
return;
|
|
52
|
+
let color = parseHexColor(str);
|
|
53
|
+
if (color != null)
|
|
54
|
+
return color;
|
|
55
|
+
color = cssColorKeyword(str);
|
|
56
|
+
if (color != null)
|
|
57
|
+
return color;
|
|
58
|
+
color = parseCssCommaColorFunction(str);
|
|
59
|
+
if (color != null)
|
|
60
|
+
return color;
|
|
61
|
+
color = parseCssSpaceColorFunction(str);
|
|
62
|
+
if (color != null)
|
|
63
|
+
return color;
|
|
64
|
+
color = parseCssColorFunction(str);
|
|
65
|
+
if (color != null)
|
|
66
|
+
return color;
|
|
67
|
+
}
|
|
68
|
+
function cssColorKeyword(str) {
|
|
69
|
+
const color = {
|
|
70
|
+
rebeccapurple: [102, 51, 153, 1],
|
|
71
|
+
transparent: [0, 0, 0, 0]
|
|
72
|
+
}[str];
|
|
73
|
+
if (color != null) {
|
|
74
|
+
return {
|
|
75
|
+
type: "rgb",
|
|
76
|
+
components: color.slice(0, 3),
|
|
77
|
+
alpha: color[3]
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function getComponent(separator, str) {
|
|
82
|
+
const component = str.trim();
|
|
83
|
+
if (component === "")
|
|
84
|
+
return;
|
|
85
|
+
const l = str.length;
|
|
86
|
+
let parenthesis = 0;
|
|
87
|
+
for (let i = 0; i < l; i++) {
|
|
88
|
+
switch (str[i]) {
|
|
89
|
+
case "(":
|
|
90
|
+
parenthesis++;
|
|
91
|
+
break;
|
|
92
|
+
case ")":
|
|
93
|
+
if (--parenthesis < 0)
|
|
94
|
+
return;
|
|
95
|
+
break;
|
|
96
|
+
case separator:
|
|
97
|
+
if (parenthesis === 0) {
|
|
98
|
+
const component2 = str.slice(0, i).trim();
|
|
99
|
+
if (component2 === "")
|
|
100
|
+
return;
|
|
101
|
+
return [
|
|
102
|
+
str.slice(0, i).trim(),
|
|
103
|
+
str.slice(i + 1).trim()
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return [
|
|
109
|
+
str.trim(),
|
|
110
|
+
""
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
function parseCssCommaColorFunction(color) {
|
|
114
|
+
const match = color.match(/^(rgb|rgba|hsl|hsla)\((.+)\)$/i);
|
|
115
|
+
if (!match)
|
|
116
|
+
return;
|
|
117
|
+
const [, type, componentString] = match;
|
|
118
|
+
const components = [];
|
|
119
|
+
let cs = componentString;
|
|
120
|
+
for (let c = 5; c > 0 && cs !== ""; --c) {
|
|
121
|
+
const componentValue = getComponent(",", cs);
|
|
122
|
+
if (!componentValue)
|
|
123
|
+
return;
|
|
124
|
+
const [component, rest] = componentValue;
|
|
125
|
+
components.push(component);
|
|
126
|
+
cs = rest;
|
|
127
|
+
}
|
|
128
|
+
if ([3, 4].includes(components.length)) {
|
|
129
|
+
return {
|
|
130
|
+
type,
|
|
131
|
+
components: components.slice(0, 3),
|
|
132
|
+
alpha: components[3]
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function parseCssSpaceColorFunction(color) {
|
|
137
|
+
const match = color.match(/^(rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch)\((.+)\)$/i);
|
|
138
|
+
if (!match)
|
|
139
|
+
return;
|
|
140
|
+
const [, fn, componentString] = match;
|
|
141
|
+
const parsed = parseCssSpaceColorValues(`${fn} ${componentString}`);
|
|
142
|
+
if (parsed) {
|
|
143
|
+
const { alpha, components: [type, ...components] } = parsed;
|
|
144
|
+
return {
|
|
145
|
+
type,
|
|
146
|
+
components,
|
|
147
|
+
alpha
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function parseCssColorFunction(color) {
|
|
152
|
+
const match = color.match(/^color\((.+)\)$/);
|
|
153
|
+
if (!match)
|
|
154
|
+
return;
|
|
155
|
+
const parsed = parseCssSpaceColorValues(match[1]);
|
|
156
|
+
if (parsed) {
|
|
157
|
+
const { alpha, components: [type, ...components] } = parsed;
|
|
158
|
+
return {
|
|
159
|
+
type,
|
|
160
|
+
components,
|
|
161
|
+
alpha
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function parseCssSpaceColorValues(componentString) {
|
|
166
|
+
let cs = componentString;
|
|
167
|
+
const components = [];
|
|
168
|
+
while (cs !== "") {
|
|
169
|
+
const cc = getComponent(" ", cs);
|
|
170
|
+
if (!cc)
|
|
171
|
+
return;
|
|
172
|
+
const [component, rest] = cc;
|
|
173
|
+
components.push(component);
|
|
174
|
+
cs = rest;
|
|
175
|
+
}
|
|
176
|
+
let totalComponents = components.length;
|
|
177
|
+
if (components[totalComponents - 2] === "/") {
|
|
178
|
+
return {
|
|
179
|
+
components: components.slice(0, totalComponents - 2),
|
|
180
|
+
alpha: components[totalComponents - 1]
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
if (components[totalComponents - 2].endsWith("/") || components[totalComponents - 1].startsWith("/")) {
|
|
184
|
+
const removed = components.splice(totalComponents - 2);
|
|
185
|
+
components.push(removed.join(" "));
|
|
186
|
+
--totalComponents;
|
|
187
|
+
}
|
|
188
|
+
cs = components[totalComponents - 1];
|
|
189
|
+
const withAlpha = [];
|
|
190
|
+
while (cs !== "") {
|
|
191
|
+
const cc = getComponent("/", cs);
|
|
192
|
+
if (!cc)
|
|
193
|
+
return;
|
|
194
|
+
const [component, rest] = cc;
|
|
195
|
+
withAlpha.push(component);
|
|
196
|
+
cs = rest;
|
|
197
|
+
}
|
|
198
|
+
if (withAlpha.length === 1 || withAlpha[withAlpha.length - 1] === "")
|
|
199
|
+
return { components };
|
|
200
|
+
const alpha = withAlpha.pop();
|
|
201
|
+
components[totalComponents - 1] = withAlpha.join("/");
|
|
202
|
+
return {
|
|
203
|
+
components,
|
|
204
|
+
alpha
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
5
208
|
const directionMap = {
|
|
6
209
|
"l": ["-left"],
|
|
7
210
|
"r": ["-right"],
|
|
@@ -141,7 +344,7 @@ const cssProps = [
|
|
|
141
344
|
"clip-path",
|
|
142
345
|
"clip"
|
|
143
346
|
];
|
|
144
|
-
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax)?$/i;
|
|
347
|
+
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax|rpx)?$/i;
|
|
145
348
|
const numberRE = /^(-?[0-9.]+)$/i;
|
|
146
349
|
const unitOnlyRE = /^(px)$/i;
|
|
147
350
|
function round(n) {
|
|
@@ -306,7 +509,7 @@ const parseColor = (body, theme) => {
|
|
|
306
509
|
else if (no && colorData)
|
|
307
510
|
color = colorData[no];
|
|
308
511
|
}
|
|
309
|
-
const rgba =
|
|
512
|
+
const rgba = hex2rgba(color);
|
|
310
513
|
const alpha = opacity ? opacity[0] === "[" ? handler.bracket.percent(opacity) : parseFloat(opacity) / 100 : rgba?.[3];
|
|
311
514
|
const hasAlpha = alpha != null && !Number.isNaN(alpha);
|
|
312
515
|
if (rgba) {
|
|
@@ -356,8 +559,10 @@ exports.directionMap = directionMap;
|
|
|
356
559
|
exports.directionSize = directionSize;
|
|
357
560
|
exports.h = h;
|
|
358
561
|
exports.handler = handler;
|
|
562
|
+
exports.hex2rgba = hex2rgba;
|
|
359
563
|
exports.insetMap = insetMap;
|
|
360
564
|
exports.parseColor = parseColor;
|
|
565
|
+
exports.parseCssColor = parseCssColor;
|
|
361
566
|
exports.positionMap = positionMap;
|
|
362
567
|
exports.valueHandlers = valueHandlers;
|
|
363
568
|
exports.xyzMap = xyzMap;
|
|
@@ -1,4 +1,207 @@
|
|
|
1
|
-
import { escapeSelector, createValueHandler
|
|
1
|
+
import { escapeSelector, createValueHandler } from '@unocss/core';
|
|
2
|
+
|
|
3
|
+
function hex2rgba(hex = "") {
|
|
4
|
+
const color = parseHexColor(hex);
|
|
5
|
+
if (color != null) {
|
|
6
|
+
const { components, alpha } = color;
|
|
7
|
+
if (alpha === void 0)
|
|
8
|
+
return components;
|
|
9
|
+
return [...components, alpha];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function parseHexColor(str) {
|
|
13
|
+
const [, body] = str.match(/^#?([\da-f]+)$/i) || [];
|
|
14
|
+
if (!body)
|
|
15
|
+
return;
|
|
16
|
+
switch (body.length) {
|
|
17
|
+
case 3:
|
|
18
|
+
case 4:
|
|
19
|
+
const digits = Array.from(body, (s) => Number.parseInt(s, 16)).map((n) => n << 4 | n);
|
|
20
|
+
return {
|
|
21
|
+
type: "rgb",
|
|
22
|
+
components: digits.slice(0, 3),
|
|
23
|
+
alpha: body.length === 3 ? void 0 : Math.round(digits[3] / 255 * 100) / 100
|
|
24
|
+
};
|
|
25
|
+
case 6:
|
|
26
|
+
case 8:
|
|
27
|
+
const value = Number.parseInt(body, 16);
|
|
28
|
+
return {
|
|
29
|
+
type: "rgb",
|
|
30
|
+
components: body.length === 6 ? [value >> 16 & 255, value >> 8 & 255, value & 255] : [value >> 24 & 255, value >> 16 & 255, value >> 8 & 255],
|
|
31
|
+
alpha: body.length === 6 ? void 0 : Math.round((value & 255) / 255 * 100) / 100
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function parseCssColor(str = "") {
|
|
36
|
+
const color = parseColor$1(str);
|
|
37
|
+
if (color == null)
|
|
38
|
+
return;
|
|
39
|
+
const { type: casedType, components, alpha } = color;
|
|
40
|
+
const type = casedType.toLowerCase();
|
|
41
|
+
if (["rgba", "hsla"].includes(type) && alpha === void 0)
|
|
42
|
+
return;
|
|
43
|
+
if (["rgb", "hsl", "hwb", "lab", "lch", "oklab", "oklch"].includes(type) && components.length !== 3)
|
|
44
|
+
return;
|
|
45
|
+
return { type, components, alpha };
|
|
46
|
+
}
|
|
47
|
+
function parseColor$1(str) {
|
|
48
|
+
if (!str)
|
|
49
|
+
return;
|
|
50
|
+
let color = parseHexColor(str);
|
|
51
|
+
if (color != null)
|
|
52
|
+
return color;
|
|
53
|
+
color = cssColorKeyword(str);
|
|
54
|
+
if (color != null)
|
|
55
|
+
return color;
|
|
56
|
+
color = parseCssCommaColorFunction(str);
|
|
57
|
+
if (color != null)
|
|
58
|
+
return color;
|
|
59
|
+
color = parseCssSpaceColorFunction(str);
|
|
60
|
+
if (color != null)
|
|
61
|
+
return color;
|
|
62
|
+
color = parseCssColorFunction(str);
|
|
63
|
+
if (color != null)
|
|
64
|
+
return color;
|
|
65
|
+
}
|
|
66
|
+
function cssColorKeyword(str) {
|
|
67
|
+
const color = {
|
|
68
|
+
rebeccapurple: [102, 51, 153, 1],
|
|
69
|
+
transparent: [0, 0, 0, 0]
|
|
70
|
+
}[str];
|
|
71
|
+
if (color != null) {
|
|
72
|
+
return {
|
|
73
|
+
type: "rgb",
|
|
74
|
+
components: color.slice(0, 3),
|
|
75
|
+
alpha: color[3]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function getComponent(separator, str) {
|
|
80
|
+
const component = str.trim();
|
|
81
|
+
if (component === "")
|
|
82
|
+
return;
|
|
83
|
+
const l = str.length;
|
|
84
|
+
let parenthesis = 0;
|
|
85
|
+
for (let i = 0; i < l; i++) {
|
|
86
|
+
switch (str[i]) {
|
|
87
|
+
case "(":
|
|
88
|
+
parenthesis++;
|
|
89
|
+
break;
|
|
90
|
+
case ")":
|
|
91
|
+
if (--parenthesis < 0)
|
|
92
|
+
return;
|
|
93
|
+
break;
|
|
94
|
+
case separator:
|
|
95
|
+
if (parenthesis === 0) {
|
|
96
|
+
const component2 = str.slice(0, i).trim();
|
|
97
|
+
if (component2 === "")
|
|
98
|
+
return;
|
|
99
|
+
return [
|
|
100
|
+
str.slice(0, i).trim(),
|
|
101
|
+
str.slice(i + 1).trim()
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return [
|
|
107
|
+
str.trim(),
|
|
108
|
+
""
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
function parseCssCommaColorFunction(color) {
|
|
112
|
+
const match = color.match(/^(rgb|rgba|hsl|hsla)\((.+)\)$/i);
|
|
113
|
+
if (!match)
|
|
114
|
+
return;
|
|
115
|
+
const [, type, componentString] = match;
|
|
116
|
+
const components = [];
|
|
117
|
+
let cs = componentString;
|
|
118
|
+
for (let c = 5; c > 0 && cs !== ""; --c) {
|
|
119
|
+
const componentValue = getComponent(",", cs);
|
|
120
|
+
if (!componentValue)
|
|
121
|
+
return;
|
|
122
|
+
const [component, rest] = componentValue;
|
|
123
|
+
components.push(component);
|
|
124
|
+
cs = rest;
|
|
125
|
+
}
|
|
126
|
+
if ([3, 4].includes(components.length)) {
|
|
127
|
+
return {
|
|
128
|
+
type,
|
|
129
|
+
components: components.slice(0, 3),
|
|
130
|
+
alpha: components[3]
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function parseCssSpaceColorFunction(color) {
|
|
135
|
+
const match = color.match(/^(rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch)\((.+)\)$/i);
|
|
136
|
+
if (!match)
|
|
137
|
+
return;
|
|
138
|
+
const [, fn, componentString] = match;
|
|
139
|
+
const parsed = parseCssSpaceColorValues(`${fn} ${componentString}`);
|
|
140
|
+
if (parsed) {
|
|
141
|
+
const { alpha, components: [type, ...components] } = parsed;
|
|
142
|
+
return {
|
|
143
|
+
type,
|
|
144
|
+
components,
|
|
145
|
+
alpha
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function parseCssColorFunction(color) {
|
|
150
|
+
const match = color.match(/^color\((.+)\)$/);
|
|
151
|
+
if (!match)
|
|
152
|
+
return;
|
|
153
|
+
const parsed = parseCssSpaceColorValues(match[1]);
|
|
154
|
+
if (parsed) {
|
|
155
|
+
const { alpha, components: [type, ...components] } = parsed;
|
|
156
|
+
return {
|
|
157
|
+
type,
|
|
158
|
+
components,
|
|
159
|
+
alpha
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function parseCssSpaceColorValues(componentString) {
|
|
164
|
+
let cs = componentString;
|
|
165
|
+
const components = [];
|
|
166
|
+
while (cs !== "") {
|
|
167
|
+
const cc = getComponent(" ", cs);
|
|
168
|
+
if (!cc)
|
|
169
|
+
return;
|
|
170
|
+
const [component, rest] = cc;
|
|
171
|
+
components.push(component);
|
|
172
|
+
cs = rest;
|
|
173
|
+
}
|
|
174
|
+
let totalComponents = components.length;
|
|
175
|
+
if (components[totalComponents - 2] === "/") {
|
|
176
|
+
return {
|
|
177
|
+
components: components.slice(0, totalComponents - 2),
|
|
178
|
+
alpha: components[totalComponents - 1]
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
if (components[totalComponents - 2].endsWith("/") || components[totalComponents - 1].startsWith("/")) {
|
|
182
|
+
const removed = components.splice(totalComponents - 2);
|
|
183
|
+
components.push(removed.join(" "));
|
|
184
|
+
--totalComponents;
|
|
185
|
+
}
|
|
186
|
+
cs = components[totalComponents - 1];
|
|
187
|
+
const withAlpha = [];
|
|
188
|
+
while (cs !== "") {
|
|
189
|
+
const cc = getComponent("/", cs);
|
|
190
|
+
if (!cc)
|
|
191
|
+
return;
|
|
192
|
+
const [component, rest] = cc;
|
|
193
|
+
withAlpha.push(component);
|
|
194
|
+
cs = rest;
|
|
195
|
+
}
|
|
196
|
+
if (withAlpha.length === 1 || withAlpha[withAlpha.length - 1] === "")
|
|
197
|
+
return { components };
|
|
198
|
+
const alpha = withAlpha.pop();
|
|
199
|
+
components[totalComponents - 1] = withAlpha.join("/");
|
|
200
|
+
return {
|
|
201
|
+
components,
|
|
202
|
+
alpha
|
|
203
|
+
};
|
|
204
|
+
}
|
|
2
205
|
|
|
3
206
|
const directionMap = {
|
|
4
207
|
"l": ["-left"],
|
|
@@ -139,7 +342,7 @@ const cssProps = [
|
|
|
139
342
|
"clip-path",
|
|
140
343
|
"clip"
|
|
141
344
|
];
|
|
142
|
-
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax)?$/i;
|
|
345
|
+
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax|rpx)?$/i;
|
|
143
346
|
const numberRE = /^(-?[0-9.]+)$/i;
|
|
144
347
|
const unitOnlyRE = /^(px)$/i;
|
|
145
348
|
function round(n) {
|
|
@@ -348,4 +551,4 @@ const colorResolver = (property, varName) => ([, body], { theme }) => {
|
|
|
348
551
|
}
|
|
349
552
|
};
|
|
350
553
|
|
|
351
|
-
export { cornerMap as a, directionSize as b, colorResolver as c, directionMap as d, positionMap as e,
|
|
554
|
+
export { cornerMap as a, directionSize as b, colorResolver as c, directionMap as d, positionMap as e, hex2rgba as f, parseCssColor as g, handler as h, insetMap as i, h as j, parseColor as p, valueHandlers as v, xyzMap as x };
|
package/dist/utils.cjs
CHANGED
|
@@ -14,8 +14,10 @@ exports.directionMap = utilities.directionMap;
|
|
|
14
14
|
exports.directionSize = utilities.directionSize;
|
|
15
15
|
exports.h = utilities.h;
|
|
16
16
|
exports.handler = utilities.handler;
|
|
17
|
+
exports.hex2rgba = utilities.hex2rgba;
|
|
17
18
|
exports.insetMap = utilities.insetMap;
|
|
18
19
|
exports.parseColor = utilities.parseColor;
|
|
20
|
+
exports.parseCssColor = utilities.parseCssColor;
|
|
19
21
|
exports.positionMap = utilities.positionMap;
|
|
20
22
|
exports.valueHandlers = utilities.valueHandlers;
|
|
21
23
|
exports.xyzMap = utilities.xyzMap;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as _unocss_core from '@unocss/core';
|
|
2
|
-
import { VariantHandler } from '@unocss/core';
|
|
2
|
+
import { RGBAColorValue, CSSColorValue, VariantHandler } from '@unocss/core';
|
|
3
3
|
export { c as colorResolver, d as directionSize, p as parseColor } from './utilities-8c324eff';
|
|
4
4
|
import './types-154878eb';
|
|
5
5
|
|
|
6
|
+
declare function hex2rgba(hex?: string): RGBAColorValue | undefined;
|
|
7
|
+
declare function parseCssColor(str?: string): CSSColorValue | undefined;
|
|
8
|
+
|
|
6
9
|
declare const directionMap: Record<string, string[]>;
|
|
7
10
|
declare const insetMap: Record<string, string[]>;
|
|
8
11
|
declare const cornerMap: Record<string, string[]>;
|
|
@@ -60,4 +63,4 @@ declare const h: _unocss_core.ValueHandler<"number" | "auto" | "numberWithUnit"
|
|
|
60
63
|
declare const variantMatcher: (name: string, selector?: ((input: string) => string | undefined) | undefined) => (input: string) => VariantHandler | undefined;
|
|
61
64
|
declare const variantParentMatcher: (name: string, parent: string) => (input: string) => VariantHandler | undefined;
|
|
62
65
|
|
|
63
|
-
export { cornerMap, directionMap, h, handler, insetMap, positionMap, handlers as valueHandlers, variantMatcher, variantParentMatcher, xyzMap };
|
|
66
|
+
export { cornerMap, directionMap, h, handler, hex2rgba, insetMap, parseCssColor, positionMap, handlers as valueHandlers, variantMatcher, variantParentMatcher, xyzMap };
|
package/dist/utils.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { c as colorResolver, a as cornerMap, d as directionMap, b as directionSize,
|
|
1
|
+
export { c as colorResolver, a as cornerMap, d as directionMap, b as directionSize, j as h, h as handler, f as hex2rgba, i as insetMap, p as parseColor, g as parseCssColor, e as positionMap, v as valueHandlers, x as xyzMap } from './chunks/utilities.mjs';
|
|
2
2
|
export { v as variantMatcher, a as variantParentMatcher } from './chunks/variants.mjs';
|
|
3
3
|
import '@unocss/core';
|
package/dist/variants.cjs
CHANGED
|
@@ -14,6 +14,7 @@ exports.variantColorsMediaOrClass = _default.variantColorsMediaOrClass;
|
|
|
14
14
|
exports.variantCombinators = _default.variantCombinators;
|
|
15
15
|
exports.variantImportant = _default.variantImportant;
|
|
16
16
|
exports.variantLanguageDirections = _default.variantLanguageDirections;
|
|
17
|
+
exports.variantLayer = _default.variantLayer;
|
|
17
18
|
exports.variantMotions = _default.variantMotions;
|
|
18
19
|
exports.variantNegative = _default.variantNegative;
|
|
19
20
|
exports.variantOrientations = _default.variantOrientations;
|
package/dist/variants.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ declare const variants: (options: PresetMiniOptions) => Variant<Theme>[];
|
|
|
19
19
|
|
|
20
20
|
declare const variantLanguageDirections: Variant[];
|
|
21
21
|
|
|
22
|
+
declare const variantLayer: Variant;
|
|
22
23
|
declare const variantImportant: Variant;
|
|
23
24
|
declare const variantNegative: Variant;
|
|
24
25
|
|
|
@@ -28,4 +29,4 @@ declare const variantPseudoClassFunctions: VariantObject;
|
|
|
28
29
|
declare const variantTaggedPseudoClasses: (options?: PresetMiniOptions) => VariantObject[];
|
|
29
30
|
declare const partClasses: VariantObject;
|
|
30
31
|
|
|
31
|
-
export { partClasses, variantBreakpoints, variantColorsMediaOrClass, variantCombinators, variantImportant, variantLanguageDirections, variantMotions, variantNegative, variantOrientations, variantPrint, variantPseudoClassFunctions, variantPseudoClasses, variantPseudoElements, variantTaggedPseudoClasses, variants };
|
|
32
|
+
export { partClasses, variantBreakpoints, variantColorsMediaOrClass, variantCombinators, variantImportant, variantLanguageDirections, variantLayer, variantMotions, variantNegative, variantOrientations, variantPrint, variantPseudoClassFunctions, variantPseudoClasses, variantPseudoElements, variantTaggedPseudoClasses, variants };
|
package/dist/variants.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { p as partClasses, a as variantBreakpoints, f as variantColorsMediaOrClass, b as variantCombinators,
|
|
1
|
+
export { p as partClasses, a as variantBreakpoints, f as variantColorsMediaOrClass, b as variantCombinators, i as variantImportant, g as variantLanguageDirections, h as variantLayer, c as variantMotions, j as variantNegative, d as variantOrientations, e as variantPrint, m as variantPseudoClassFunctions, l as variantPseudoClasses, k as variantPseudoElements, n as variantTaggedPseudoClasses, v as variants } from './chunks/default3.mjs';
|
|
2
2
|
import './chunks/variants.mjs';
|
|
3
3
|
import '@unocss/core';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/preset-mini",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.7",
|
|
4
4
|
"description": "The minimal preset for UnoCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"*.css"
|
|
62
62
|
],
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@unocss/core": "0.22.
|
|
64
|
+
"@unocss/core": "0.22.7"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"build": "unbuild",
|