@unocss/preset-mini 0.22.4 → 0.23.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 -1
- package/dist/chunks/default.mjs +10 -2
- package/dist/chunks/default2.cjs +48 -59
- package/dist/chunks/default2.mjs +48 -59
- package/dist/chunks/default3.cjs +46 -9
- package/dist/chunks/default3.mjs +46 -10
- package/dist/chunks/utilities.cjs +211 -6
- package/dist/chunks/utilities.mjs +210 -7
- package/dist/{colors-338f482c.d.ts → colors-db01a23e.d.ts} +1 -1
- package/dist/colors.d.ts +2 -2
- package/dist/{default-17948303.d.ts → default-c46850c2.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/rules.d.ts +2 -2
- package/dist/theme.cjs +1 -0
- package/dist/theme.d.ts +12 -5
- package/dist/theme.mjs +1 -1
- package/dist/{types-c14b808b.d.ts → types-154878eb.d.ts} +1 -0
- package/dist/{utilities-29b01158.d.ts → utilities-8c324eff.d.ts} +1 -1
- package/dist/utils.cjs +2 -0
- package/dist/utils.d.ts +7 -4
- package/dist/utils.mjs +1 -1
- package/dist/variants.cjs +1 -0
- package/dist/variants.d.ts +6 -5
- package/dist/variants.mjs +1 -1
- package/package.json +2 -2
package/dist/chunks/default3.mjs
CHANGED
|
@@ -35,12 +35,28 @@ const variantBreakpoints = (matcher, { theme }) => {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
const scopeMatcher = (strict, name, template) => {
|
|
39
|
+
const re = strict ? new RegExp(`^${name}(?:-\\[(.+?)\\])[:-]`) : new RegExp(`^${name}(?:-\\[(.+?)\\])?[:-]`);
|
|
40
|
+
return (matcher) => {
|
|
41
|
+
const match = matcher.match(re);
|
|
42
|
+
if (match) {
|
|
43
|
+
return {
|
|
44
|
+
matcher: matcher.slice(match[0].length),
|
|
45
|
+
selector: (s) => template.replace("&&-s", s).replace("&&-c", match[1] ?? "*")
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
38
50
|
const variantCombinators = [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
scopeMatcher(false, "all", "&&-s &&-c"),
|
|
52
|
+
scopeMatcher(false, "children", "&&-s>&&-c"),
|
|
53
|
+
scopeMatcher(false, "next", "&&-s+&&-c"),
|
|
54
|
+
scopeMatcher(false, "sibling", "&&-s+&&-c"),
|
|
55
|
+
scopeMatcher(false, "siblings", "&&-s~&&-c"),
|
|
56
|
+
scopeMatcher(true, "group", "&&-c &&-s"),
|
|
57
|
+
scopeMatcher(true, "parent", "&&-c>&&-s"),
|
|
58
|
+
scopeMatcher(true, "previous", "&&-c+&&-s"),
|
|
59
|
+
scopeMatcher(true, "peer", "&&-c~&&-s"),
|
|
44
60
|
variantMatcher("svg", (input) => `${input} svg`)
|
|
45
61
|
];
|
|
46
62
|
|
|
@@ -72,6 +88,17 @@ const variantLanguageDirections = [
|
|
|
72
88
|
variantMatcher("ltr", (input) => `[dir="ltr"] $$ ${input}`)
|
|
73
89
|
];
|
|
74
90
|
|
|
91
|
+
const variantLayer = {
|
|
92
|
+
match(matcher) {
|
|
93
|
+
const match = matcher.match(/layer-([\d\w]+)[:-]/);
|
|
94
|
+
if (match) {
|
|
95
|
+
return {
|
|
96
|
+
matcher: matcher.slice(match[0].length),
|
|
97
|
+
layer: match[1]
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
75
102
|
const variantImportant = {
|
|
76
103
|
match(matcher) {
|
|
77
104
|
if (matcher.startsWith("!")) {
|
|
@@ -178,7 +205,7 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
|
|
|
178
205
|
if (match[2])
|
|
179
206
|
pseudo = `:${match[2]}(${pseudo})`;
|
|
180
207
|
return {
|
|
181
|
-
matcher: input.slice(match[
|
|
208
|
+
matcher: input.slice(match[0].length),
|
|
182
209
|
selector: (s) => rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`
|
|
183
210
|
};
|
|
184
211
|
}
|
|
@@ -189,7 +216,7 @@ const variantPseudoElements = (input) => {
|
|
|
189
216
|
if (match) {
|
|
190
217
|
const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
|
|
191
218
|
return {
|
|
192
|
-
matcher: input.slice(match[
|
|
219
|
+
matcher: input.slice(match[0].length),
|
|
193
220
|
selector: (s) => `${s}${pseudo}`
|
|
194
221
|
};
|
|
195
222
|
}
|
|
@@ -200,7 +227,7 @@ const variantPseudoClasses = {
|
|
|
200
227
|
if (match) {
|
|
201
228
|
const pseudo = PseudoClasses[match[1]] || `:${match[1]}`;
|
|
202
229
|
return {
|
|
203
|
-
matcher: input.slice(match[
|
|
230
|
+
matcher: input.slice(match[0].length),
|
|
204
231
|
selector: (s) => `${s}${pseudo}`
|
|
205
232
|
};
|
|
206
233
|
}
|
|
@@ -214,7 +241,7 @@ const variantPseudoClassFunctions = {
|
|
|
214
241
|
const fn = match[1];
|
|
215
242
|
const pseudo = PseudoClasses[match[2]] || `:${match[2]}`;
|
|
216
243
|
return {
|
|
217
|
-
matcher: input.slice(match[
|
|
244
|
+
matcher: input.slice(match[0].length),
|
|
218
245
|
selector: (s) => `${s}:${fn}(${pseudo})`
|
|
219
246
|
};
|
|
220
247
|
}
|
|
@@ -231,6 +258,14 @@ const variantTaggedPseudoClasses = (options = {}) => {
|
|
|
231
258
|
{
|
|
232
259
|
match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
|
|
233
260
|
multiPass: true
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
match: taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
|
|
264
|
+
multiPass: true
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
match: taggedPseudoClassMatcher("previous", attributify ? '[previous=""]' : ".previous", "+"),
|
|
268
|
+
multiPass: true
|
|
234
269
|
}
|
|
235
270
|
];
|
|
236
271
|
};
|
|
@@ -249,6 +284,7 @@ const partClasses = {
|
|
|
249
284
|
};
|
|
250
285
|
|
|
251
286
|
const variants = (options) => [
|
|
287
|
+
variantLayer,
|
|
252
288
|
variantNegative,
|
|
253
289
|
variantImportant,
|
|
254
290
|
variantPrint,
|
|
@@ -265,4 +301,4 @@ const variants = (options) => [
|
|
|
265
301
|
...variantLanguageDirections
|
|
266
302
|
];
|
|
267
303
|
|
|
268
|
-
export { variantBreakpoints as a, variantCombinators as b, variantMotions as c, variantOrientations as d, variantPrint as e, variantColorsMediaOrClass as f, variantLanguageDirections as g,
|
|
304
|
+
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) {
|
|
@@ -206,14 +409,14 @@ function fraction(str) {
|
|
|
206
409
|
}
|
|
207
410
|
function bracket(str) {
|
|
208
411
|
if (str && str[0] === "[" && str[str.length - 1] === "]") {
|
|
209
|
-
return str.slice(1, -1).replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/(
|
|
412
|
+
return str.slice(1, -1).replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/([^\\])_/g, "$1 ").replace(/calc\((.*)/g, (v) => {
|
|
210
413
|
return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
|
|
211
414
|
});
|
|
212
415
|
}
|
|
213
416
|
}
|
|
214
417
|
function cssvar(str) {
|
|
215
|
-
if (str.
|
|
216
|
-
return `var(--${str.slice(1)})`;
|
|
418
|
+
if (str.match(/^\$\S/))
|
|
419
|
+
return `var(--${core.escapeSelector(str.slice(1))})`;
|
|
217
420
|
}
|
|
218
421
|
function time(str) {
|
|
219
422
|
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
@@ -296,7 +499,7 @@ const parseColor = (body, theme) => {
|
|
|
296
499
|
colorData = getThemeColor(theme, colors.slice(0, -1));
|
|
297
500
|
} else {
|
|
298
501
|
colorData = getThemeColor(theme, colors);
|
|
299
|
-
if (!colorData) {
|
|
502
|
+
if (!colorData && colors.length <= 2) {
|
|
300
503
|
[, no = no] = colors;
|
|
301
504
|
colorData = getThemeColor(theme, [name]);
|
|
302
505
|
}
|
|
@@ -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 {
|
|
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) {
|
|
@@ -204,14 +407,14 @@ function fraction(str) {
|
|
|
204
407
|
}
|
|
205
408
|
function bracket(str) {
|
|
206
409
|
if (str && str[0] === "[" && str[str.length - 1] === "]") {
|
|
207
|
-
return str.slice(1, -1).replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/(
|
|
410
|
+
return str.slice(1, -1).replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/([^\\])_/g, "$1 ").replace(/calc\((.*)/g, (v) => {
|
|
208
411
|
return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
|
|
209
412
|
});
|
|
210
413
|
}
|
|
211
414
|
}
|
|
212
415
|
function cssvar(str) {
|
|
213
|
-
if (str.
|
|
214
|
-
return `var(--${str.slice(1)})`;
|
|
416
|
+
if (str.match(/^\$\S/))
|
|
417
|
+
return `var(--${escapeSelector(str.slice(1))})`;
|
|
215
418
|
}
|
|
216
419
|
function time(str) {
|
|
217
420
|
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
@@ -294,7 +497,7 @@ const parseColor = (body, theme) => {
|
|
|
294
497
|
colorData = getThemeColor(theme, colors.slice(0, -1));
|
|
295
498
|
} else {
|
|
296
499
|
colorData = getThemeColor(theme, colors);
|
|
297
|
-
if (!colorData) {
|
|
500
|
+
if (!colorData && colors.length <= 2) {
|
|
298
501
|
[, no = no] = colors;
|
|
299
502
|
colorData = getThemeColor(theme, [name]);
|
|
300
503
|
}
|
|
@@ -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/colors.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { c as colors } from './colors-
|
|
2
|
-
import './types-
|
|
1
|
+
export { c as colors } from './colors-db01a23e';
|
|
2
|
+
import './types-154878eb';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PresetOptions, Preset } from '@unocss/core';
|
|
2
|
-
import { T as Theme } from './types-
|
|
3
|
-
export { T as Theme, a as ThemeAnimation } from './types-
|
|
4
|
-
export { t as theme } from './default-
|
|
5
|
-
export { c as colors } from './colors-
|
|
6
|
-
export { p as parseColor } from './utilities-
|
|
2
|
+
import { T as Theme } from './types-154878eb';
|
|
3
|
+
export { T as Theme, a as ThemeAnimation } from './types-154878eb';
|
|
4
|
+
export { t as theme } from './default-c46850c2';
|
|
5
|
+
export { c as colors } from './colors-db01a23e';
|
|
6
|
+
export { p as parseColor } from './utilities-8c324eff';
|
|
7
7
|
|
|
8
8
|
interface PresetMiniOptions extends PresetOptions {
|
|
9
9
|
/**
|
package/dist/rules.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Rule } from '@unocss/core';
|
|
2
|
-
import { T as Theme } from './types-
|
|
2
|
+
import { T as Theme } from './types-154878eb';
|
|
3
3
|
|
|
4
4
|
declare const verticalAligns: Rule[];
|
|
5
5
|
declare const textAligns: Rule[];
|
|
@@ -84,7 +84,7 @@ declare const svgUtilities: Rule[];
|
|
|
84
84
|
|
|
85
85
|
declare const transforms: Rule[];
|
|
86
86
|
|
|
87
|
-
declare const transitions: Rule[];
|
|
87
|
+
declare const transitions: Rule<Theme>[];
|
|
88
88
|
|
|
89
89
|
declare const fonts: Rule<Theme>[];
|
|
90
90
|
declare const tabSizes: Rule<Theme>[];
|
package/dist/theme.cjs
CHANGED
|
@@ -14,6 +14,7 @@ exports.borderRadius = _default.borderRadius;
|
|
|
14
14
|
exports.boxShadow = _default.boxShadow;
|
|
15
15
|
exports.breakpoints = _default.breakpoints;
|
|
16
16
|
exports.dropShadow = _default.dropShadow;
|
|
17
|
+
exports.easing = _default.easing;
|
|
17
18
|
exports.fontFamily = _default.fontFamily;
|
|
18
19
|
exports.fontSize = _default.fontSize;
|
|
19
20
|
exports.height = _default.height;
|