@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
|
@@ -35,8 +35,33 @@ 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
|
-
const
|
|
64
|
+
const cssProps = [
|
|
40
65
|
"color",
|
|
41
66
|
"border-color",
|
|
42
67
|
"background-color",
|
|
@@ -53,17 +78,13 @@ const cssBasicProps = [
|
|
|
53
78
|
"zoom",
|
|
54
79
|
"text-shadow",
|
|
55
80
|
"transform",
|
|
56
|
-
"box-shadow"
|
|
57
|
-
];
|
|
58
|
-
const cssPositionProps = [
|
|
81
|
+
"box-shadow",
|
|
59
82
|
"backround-position",
|
|
60
83
|
"left",
|
|
61
84
|
"right",
|
|
62
85
|
"top",
|
|
63
86
|
"bottom",
|
|
64
|
-
"object-position"
|
|
65
|
-
];
|
|
66
|
-
const cssSizeProps = [
|
|
87
|
+
"object-position",
|
|
67
88
|
"max-height",
|
|
68
89
|
"min-height",
|
|
69
90
|
"max-width",
|
|
@@ -81,25 +102,31 @@ const cssSizeProps = [
|
|
|
81
102
|
"vertical-align",
|
|
82
103
|
"border-spacing",
|
|
83
104
|
"letter-spacing",
|
|
84
|
-
"word-spacing"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
105
|
+
"word-spacing",
|
|
106
|
+
"stroke",
|
|
107
|
+
"filter",
|
|
108
|
+
"backdrop-filter",
|
|
109
|
+
"fill",
|
|
110
|
+
"mask",
|
|
111
|
+
"mask-size",
|
|
112
|
+
"mask-border",
|
|
113
|
+
"clip-path",
|
|
114
|
+
"clip"
|
|
92
115
|
];
|
|
93
116
|
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax)?$/i;
|
|
94
117
|
const numberRE = /^(-?[0-9.]+)$/i;
|
|
95
118
|
const unitOnlyRE = /^(px)$/i;
|
|
119
|
+
function round(n) {
|
|
120
|
+
return n.toFixed(10).replace(/\.0+$/, "").replace(/(\.\d+?)0+$/, "$1");
|
|
121
|
+
}
|
|
96
122
|
function numberWithUnit(str) {
|
|
97
123
|
const match = str.match(numberWithUnitRE);
|
|
98
124
|
if (!match)
|
|
99
125
|
return;
|
|
100
|
-
const [, , unit] = match;
|
|
101
|
-
|
|
102
|
-
|
|
126
|
+
const [, n, unit] = match;
|
|
127
|
+
const num = parseFloat(n);
|
|
128
|
+
if (unit && !Number.isNaN(num))
|
|
129
|
+
return `${round(num)}${unit}`;
|
|
103
130
|
}
|
|
104
131
|
function auto(str) {
|
|
105
132
|
if (str === "auto" || str === "a")
|
|
@@ -112,11 +139,9 @@ function rem(str) {
|
|
|
112
139
|
if (!match)
|
|
113
140
|
return;
|
|
114
141
|
const [, n, unit] = match;
|
|
115
|
-
if (unit)
|
|
116
|
-
return str;
|
|
117
142
|
const num = parseFloat(n);
|
|
118
143
|
if (!Number.isNaN(num))
|
|
119
|
-
return `${num / 4}rem`;
|
|
144
|
+
return unit ? `${round(num)}${unit}` : `${round(num / 4)}rem`;
|
|
120
145
|
}
|
|
121
146
|
function px(str) {
|
|
122
147
|
if (str.match(unitOnlyRE))
|
|
@@ -125,25 +150,23 @@ function px(str) {
|
|
|
125
150
|
if (!match)
|
|
126
151
|
return;
|
|
127
152
|
const [, n, unit] = match;
|
|
128
|
-
if (unit)
|
|
129
|
-
return str;
|
|
130
153
|
const num = parseFloat(n);
|
|
131
154
|
if (!Number.isNaN(num))
|
|
132
|
-
return `${num}px`;
|
|
155
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}px`;
|
|
133
156
|
}
|
|
134
157
|
function number(str) {
|
|
135
158
|
if (!numberRE.test(str))
|
|
136
159
|
return;
|
|
137
160
|
const num = parseFloat(str);
|
|
138
161
|
if (!Number.isNaN(num))
|
|
139
|
-
return num;
|
|
162
|
+
return round(num);
|
|
140
163
|
}
|
|
141
164
|
function percent(str) {
|
|
142
165
|
if (str.endsWith("%"))
|
|
143
166
|
str = str.slice(0, -1);
|
|
144
167
|
const num = parseFloat(str);
|
|
145
168
|
if (!Number.isNaN(num))
|
|
146
|
-
return `${num / 100}`;
|
|
169
|
+
return `${round(num / 100)}`;
|
|
147
170
|
}
|
|
148
171
|
function fraction(str) {
|
|
149
172
|
if (str === "full")
|
|
@@ -151,7 +174,7 @@ function fraction(str) {
|
|
|
151
174
|
const [left, right] = str.split("/");
|
|
152
175
|
const num = parseFloat(left) / parseFloat(right);
|
|
153
176
|
if (!Number.isNaN(num))
|
|
154
|
-
return `${num * 100}%`;
|
|
177
|
+
return `${round(num * 100)}%`;
|
|
155
178
|
}
|
|
156
179
|
function bracket(str) {
|
|
157
180
|
if (str && str[0] === "[" && str[str.length - 1] === "]") {
|
|
@@ -165,20 +188,28 @@ function cssvar(str) {
|
|
|
165
188
|
return `var(--${str.slice(1)})`;
|
|
166
189
|
}
|
|
167
190
|
function time(str) {
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
191
|
+
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
192
|
+
if (!match)
|
|
170
193
|
return;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
194
|
+
const [, n, unit] = match;
|
|
195
|
+
const num = parseFloat(n);
|
|
196
|
+
if (!Number.isNaN(num))
|
|
197
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}ms`;
|
|
198
|
+
}
|
|
199
|
+
function degree(str) {
|
|
200
|
+
const match = str.match(/^(-?[0-9.]+)(deg)?$/i);
|
|
201
|
+
if (!match)
|
|
202
|
+
return;
|
|
203
|
+
const [, n, unit] = match;
|
|
204
|
+
const num = parseFloat(n);
|
|
205
|
+
if (!Number.isNaN(num))
|
|
206
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}deg`;
|
|
174
207
|
}
|
|
175
208
|
function global(str) {
|
|
176
209
|
if (["inherit", "initial", "revert", "unset"].includes(str))
|
|
177
210
|
return str;
|
|
178
211
|
}
|
|
179
212
|
function properties(str) {
|
|
180
|
-
if (str === void 0)
|
|
181
|
-
return;
|
|
182
213
|
for (const prop of str.split(",")) {
|
|
183
214
|
if (!cssProps.includes(prop))
|
|
184
215
|
return;
|
|
@@ -198,6 +229,7 @@ const valueHandlers = {
|
|
|
198
229
|
bracket: bracket,
|
|
199
230
|
cssvar: cssvar,
|
|
200
231
|
time: time,
|
|
232
|
+
degree: degree,
|
|
201
233
|
global: global,
|
|
202
234
|
properties: properties
|
|
203
235
|
};
|
|
@@ -225,8 +257,10 @@ const parseColor = (body, theme) => {
|
|
|
225
257
|
const bracketOrMain = bracket || main;
|
|
226
258
|
if (bracketOrMain.startsWith("#"))
|
|
227
259
|
color = bracketOrMain.slice(1);
|
|
228
|
-
if (bracketOrMain.startsWith("hex-"))
|
|
260
|
+
else if (bracketOrMain.startsWith("hex-"))
|
|
229
261
|
color = bracketOrMain.slice(4);
|
|
262
|
+
else if (main.startsWith("$"))
|
|
263
|
+
color = handler.cssvar(main);
|
|
230
264
|
color = color || bracket;
|
|
231
265
|
let no = "DEFAULT";
|
|
232
266
|
if (!color) {
|
|
@@ -247,37 +281,46 @@ const parseColor = (body, theme) => {
|
|
|
247
281
|
else if (no && colorData)
|
|
248
282
|
color = colorData[no];
|
|
249
283
|
}
|
|
284
|
+
const rgba = core.hex2rgba(color);
|
|
285
|
+
const alpha = opacity ? opacity[0] === "[" ? handler.bracket.percent(opacity) : parseFloat(opacity) / 100 : rgba?.[3];
|
|
286
|
+
const hasAlpha = alpha != null && !Number.isNaN(alpha);
|
|
287
|
+
if (rgba) {
|
|
288
|
+
if (hasAlpha) {
|
|
289
|
+
rgba[3] = typeof alpha === "string" && !alpha.includes("%") ? parseFloat(alpha) : alpha;
|
|
290
|
+
} else {
|
|
291
|
+
rgba.splice(3);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
250
294
|
return {
|
|
251
295
|
opacity,
|
|
252
296
|
name,
|
|
253
297
|
no,
|
|
254
298
|
color,
|
|
255
|
-
rgba
|
|
299
|
+
rgba,
|
|
300
|
+
alpha: hasAlpha ? alpha : void 0
|
|
256
301
|
};
|
|
257
302
|
};
|
|
258
303
|
const colorResolver = (property, varName) => ([, body], { theme }) => {
|
|
259
304
|
const data = parseColor(body, theme);
|
|
260
305
|
if (!data)
|
|
261
306
|
return;
|
|
262
|
-
const { opacity, color, rgba } = data;
|
|
307
|
+
const { alpha, opacity, color, rgba } = data;
|
|
263
308
|
if (!color)
|
|
264
309
|
return;
|
|
265
|
-
const a = opacity ? opacity[0] === "[" ? handler.bracket.percent(opacity) : parseFloat(opacity) / 100 : rgba?.[3];
|
|
266
310
|
if (rgba) {
|
|
267
|
-
if (
|
|
268
|
-
rgba[3] = typeof a === "string" && !a.includes("%") ? parseFloat(a) : a;
|
|
311
|
+
if (alpha != null) {
|
|
269
312
|
return {
|
|
270
313
|
[property]: `rgba(${rgba.join(",")})`
|
|
271
314
|
};
|
|
272
315
|
} else {
|
|
273
316
|
return {
|
|
274
|
-
[`--un-${varName}-opacity`]: 1,
|
|
275
|
-
[property]: `rgba(${rgba.
|
|
317
|
+
[`--un-${varName}-opacity`]: (opacity && handler.cssvar(opacity)) ?? 1,
|
|
318
|
+
[property]: `rgba(${rgba.join(",")},var(--un-${varName}-opacity))`
|
|
276
319
|
};
|
|
277
320
|
}
|
|
278
321
|
} else {
|
|
279
322
|
return {
|
|
280
|
-
[property]: color.replace("%alpha", `${
|
|
323
|
+
[property]: color.replace("%alpha", `${alpha || 1}`)
|
|
281
324
|
};
|
|
282
325
|
}
|
|
283
326
|
};
|
|
@@ -290,5 +333,6 @@ exports.directionSize = directionSize;
|
|
|
290
333
|
exports.h = h;
|
|
291
334
|
exports.handler = handler;
|
|
292
335
|
exports.parseColor = parseColor;
|
|
336
|
+
exports.positionMap = positionMap;
|
|
293
337
|
exports.valueHandlers = valueHandlers;
|
|
294
338
|
exports.xyzMap = xyzMap;
|
|
@@ -33,8 +33,33 @@ const xyzMap = {
|
|
|
33
33
|
"z": ["-z"],
|
|
34
34
|
"": ["-x", "-y"]
|
|
35
35
|
};
|
|
36
|
+
const basePositionMap = [
|
|
37
|
+
"top",
|
|
38
|
+
"top center",
|
|
39
|
+
"top left",
|
|
40
|
+
"top right",
|
|
41
|
+
"bottom",
|
|
42
|
+
"bottom center",
|
|
43
|
+
"bottom left",
|
|
44
|
+
"bottom right",
|
|
45
|
+
"left",
|
|
46
|
+
"left center",
|
|
47
|
+
"left top",
|
|
48
|
+
"left bottom",
|
|
49
|
+
"right",
|
|
50
|
+
"right center",
|
|
51
|
+
"right top",
|
|
52
|
+
"right bottom",
|
|
53
|
+
"center",
|
|
54
|
+
"center top",
|
|
55
|
+
"center bottom",
|
|
56
|
+
"center left",
|
|
57
|
+
"center right",
|
|
58
|
+
"center center"
|
|
59
|
+
];
|
|
60
|
+
const positionMap = Object.assign({}, ...basePositionMap.map((p) => ({ [p.replace(/ /, "-")]: p })), ...basePositionMap.map((p) => ({ [p.replace(/\b(\w)\w+/g, "$1").replace(/ /, "")]: p })));
|
|
36
61
|
|
|
37
|
-
const
|
|
62
|
+
const cssProps = [
|
|
38
63
|
"color",
|
|
39
64
|
"border-color",
|
|
40
65
|
"background-color",
|
|
@@ -51,17 +76,13 @@ const cssBasicProps = [
|
|
|
51
76
|
"zoom",
|
|
52
77
|
"text-shadow",
|
|
53
78
|
"transform",
|
|
54
|
-
"box-shadow"
|
|
55
|
-
];
|
|
56
|
-
const cssPositionProps = [
|
|
79
|
+
"box-shadow",
|
|
57
80
|
"backround-position",
|
|
58
81
|
"left",
|
|
59
82
|
"right",
|
|
60
83
|
"top",
|
|
61
84
|
"bottom",
|
|
62
|
-
"object-position"
|
|
63
|
-
];
|
|
64
|
-
const cssSizeProps = [
|
|
85
|
+
"object-position",
|
|
65
86
|
"max-height",
|
|
66
87
|
"min-height",
|
|
67
88
|
"max-width",
|
|
@@ -79,25 +100,31 @@ const cssSizeProps = [
|
|
|
79
100
|
"vertical-align",
|
|
80
101
|
"border-spacing",
|
|
81
102
|
"letter-spacing",
|
|
82
|
-
"word-spacing"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
103
|
+
"word-spacing",
|
|
104
|
+
"stroke",
|
|
105
|
+
"filter",
|
|
106
|
+
"backdrop-filter",
|
|
107
|
+
"fill",
|
|
108
|
+
"mask",
|
|
109
|
+
"mask-size",
|
|
110
|
+
"mask-border",
|
|
111
|
+
"clip-path",
|
|
112
|
+
"clip"
|
|
90
113
|
];
|
|
91
114
|
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax)?$/i;
|
|
92
115
|
const numberRE = /^(-?[0-9.]+)$/i;
|
|
93
116
|
const unitOnlyRE = /^(px)$/i;
|
|
117
|
+
function round(n) {
|
|
118
|
+
return n.toFixed(10).replace(/\.0+$/, "").replace(/(\.\d+?)0+$/, "$1");
|
|
119
|
+
}
|
|
94
120
|
function numberWithUnit(str) {
|
|
95
121
|
const match = str.match(numberWithUnitRE);
|
|
96
122
|
if (!match)
|
|
97
123
|
return;
|
|
98
|
-
const [, , unit] = match;
|
|
99
|
-
|
|
100
|
-
|
|
124
|
+
const [, n, unit] = match;
|
|
125
|
+
const num = parseFloat(n);
|
|
126
|
+
if (unit && !Number.isNaN(num))
|
|
127
|
+
return `${round(num)}${unit}`;
|
|
101
128
|
}
|
|
102
129
|
function auto(str) {
|
|
103
130
|
if (str === "auto" || str === "a")
|
|
@@ -110,11 +137,9 @@ function rem(str) {
|
|
|
110
137
|
if (!match)
|
|
111
138
|
return;
|
|
112
139
|
const [, n, unit] = match;
|
|
113
|
-
if (unit)
|
|
114
|
-
return str;
|
|
115
140
|
const num = parseFloat(n);
|
|
116
141
|
if (!Number.isNaN(num))
|
|
117
|
-
return `${num / 4}rem`;
|
|
142
|
+
return unit ? `${round(num)}${unit}` : `${round(num / 4)}rem`;
|
|
118
143
|
}
|
|
119
144
|
function px(str) {
|
|
120
145
|
if (str.match(unitOnlyRE))
|
|
@@ -123,25 +148,23 @@ function px(str) {
|
|
|
123
148
|
if (!match)
|
|
124
149
|
return;
|
|
125
150
|
const [, n, unit] = match;
|
|
126
|
-
if (unit)
|
|
127
|
-
return str;
|
|
128
151
|
const num = parseFloat(n);
|
|
129
152
|
if (!Number.isNaN(num))
|
|
130
|
-
return `${num}px`;
|
|
153
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}px`;
|
|
131
154
|
}
|
|
132
155
|
function number(str) {
|
|
133
156
|
if (!numberRE.test(str))
|
|
134
157
|
return;
|
|
135
158
|
const num = parseFloat(str);
|
|
136
159
|
if (!Number.isNaN(num))
|
|
137
|
-
return num;
|
|
160
|
+
return round(num);
|
|
138
161
|
}
|
|
139
162
|
function percent(str) {
|
|
140
163
|
if (str.endsWith("%"))
|
|
141
164
|
str = str.slice(0, -1);
|
|
142
165
|
const num = parseFloat(str);
|
|
143
166
|
if (!Number.isNaN(num))
|
|
144
|
-
return `${num / 100}`;
|
|
167
|
+
return `${round(num / 100)}`;
|
|
145
168
|
}
|
|
146
169
|
function fraction(str) {
|
|
147
170
|
if (str === "full")
|
|
@@ -149,7 +172,7 @@ function fraction(str) {
|
|
|
149
172
|
const [left, right] = str.split("/");
|
|
150
173
|
const num = parseFloat(left) / parseFloat(right);
|
|
151
174
|
if (!Number.isNaN(num))
|
|
152
|
-
return `${num * 100}%`;
|
|
175
|
+
return `${round(num * 100)}%`;
|
|
153
176
|
}
|
|
154
177
|
function bracket(str) {
|
|
155
178
|
if (str && str[0] === "[" && str[str.length - 1] === "]") {
|
|
@@ -163,20 +186,28 @@ function cssvar(str) {
|
|
|
163
186
|
return `var(--${str.slice(1)})`;
|
|
164
187
|
}
|
|
165
188
|
function time(str) {
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
189
|
+
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
190
|
+
if (!match)
|
|
168
191
|
return;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
192
|
+
const [, n, unit] = match;
|
|
193
|
+
const num = parseFloat(n);
|
|
194
|
+
if (!Number.isNaN(num))
|
|
195
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}ms`;
|
|
196
|
+
}
|
|
197
|
+
function degree(str) {
|
|
198
|
+
const match = str.match(/^(-?[0-9.]+)(deg)?$/i);
|
|
199
|
+
if (!match)
|
|
200
|
+
return;
|
|
201
|
+
const [, n, unit] = match;
|
|
202
|
+
const num = parseFloat(n);
|
|
203
|
+
if (!Number.isNaN(num))
|
|
204
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}deg`;
|
|
172
205
|
}
|
|
173
206
|
function global(str) {
|
|
174
207
|
if (["inherit", "initial", "revert", "unset"].includes(str))
|
|
175
208
|
return str;
|
|
176
209
|
}
|
|
177
210
|
function properties(str) {
|
|
178
|
-
if (str === void 0)
|
|
179
|
-
return;
|
|
180
211
|
for (const prop of str.split(",")) {
|
|
181
212
|
if (!cssProps.includes(prop))
|
|
182
213
|
return;
|
|
@@ -196,6 +227,7 @@ const valueHandlers = {
|
|
|
196
227
|
bracket: bracket,
|
|
197
228
|
cssvar: cssvar,
|
|
198
229
|
time: time,
|
|
230
|
+
degree: degree,
|
|
199
231
|
global: global,
|
|
200
232
|
properties: properties
|
|
201
233
|
};
|
|
@@ -223,8 +255,10 @@ const parseColor = (body, theme) => {
|
|
|
223
255
|
const bracketOrMain = bracket || main;
|
|
224
256
|
if (bracketOrMain.startsWith("#"))
|
|
225
257
|
color = bracketOrMain.slice(1);
|
|
226
|
-
if (bracketOrMain.startsWith("hex-"))
|
|
258
|
+
else if (bracketOrMain.startsWith("hex-"))
|
|
227
259
|
color = bracketOrMain.slice(4);
|
|
260
|
+
else if (main.startsWith("$"))
|
|
261
|
+
color = handler.cssvar(main);
|
|
228
262
|
color = color || bracket;
|
|
229
263
|
let no = "DEFAULT";
|
|
230
264
|
if (!color) {
|
|
@@ -245,39 +279,48 @@ const parseColor = (body, theme) => {
|
|
|
245
279
|
else if (no && colorData)
|
|
246
280
|
color = colorData[no];
|
|
247
281
|
}
|
|
282
|
+
const rgba = hex2rgba(color);
|
|
283
|
+
const alpha = opacity ? opacity[0] === "[" ? handler.bracket.percent(opacity) : parseFloat(opacity) / 100 : rgba?.[3];
|
|
284
|
+
const hasAlpha = alpha != null && !Number.isNaN(alpha);
|
|
285
|
+
if (rgba) {
|
|
286
|
+
if (hasAlpha) {
|
|
287
|
+
rgba[3] = typeof alpha === "string" && !alpha.includes("%") ? parseFloat(alpha) : alpha;
|
|
288
|
+
} else {
|
|
289
|
+
rgba.splice(3);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
248
292
|
return {
|
|
249
293
|
opacity,
|
|
250
294
|
name,
|
|
251
295
|
no,
|
|
252
296
|
color,
|
|
253
|
-
rgba
|
|
297
|
+
rgba,
|
|
298
|
+
alpha: hasAlpha ? alpha : void 0
|
|
254
299
|
};
|
|
255
300
|
};
|
|
256
301
|
const colorResolver = (property, varName) => ([, body], { theme }) => {
|
|
257
302
|
const data = parseColor(body, theme);
|
|
258
303
|
if (!data)
|
|
259
304
|
return;
|
|
260
|
-
const { opacity, color, rgba } = data;
|
|
305
|
+
const { alpha, opacity, color, rgba } = data;
|
|
261
306
|
if (!color)
|
|
262
307
|
return;
|
|
263
|
-
const a = opacity ? opacity[0] === "[" ? handler.bracket.percent(opacity) : parseFloat(opacity) / 100 : rgba?.[3];
|
|
264
308
|
if (rgba) {
|
|
265
|
-
if (
|
|
266
|
-
rgba[3] = typeof a === "string" && !a.includes("%") ? parseFloat(a) : a;
|
|
309
|
+
if (alpha != null) {
|
|
267
310
|
return {
|
|
268
311
|
[property]: `rgba(${rgba.join(",")})`
|
|
269
312
|
};
|
|
270
313
|
} else {
|
|
271
314
|
return {
|
|
272
|
-
[`--un-${varName}-opacity`]: 1,
|
|
273
|
-
[property]: `rgba(${rgba.
|
|
315
|
+
[`--un-${varName}-opacity`]: (opacity && handler.cssvar(opacity)) ?? 1,
|
|
316
|
+
[property]: `rgba(${rgba.join(",")},var(--un-${varName}-opacity))`
|
|
274
317
|
};
|
|
275
318
|
}
|
|
276
319
|
} else {
|
|
277
320
|
return {
|
|
278
|
-
[property]: color.replace("%alpha", `${
|
|
321
|
+
[property]: color.replace("%alpha", `${alpha || 1}`)
|
|
279
322
|
};
|
|
280
323
|
}
|
|
281
324
|
};
|
|
282
325
|
|
|
283
|
-
export { cornerMap as a, capitalize as b, colorResolver as c, directionMap as d, directionSize as e,
|
|
326
|
+
export { cornerMap as a, capitalize as b, colorResolver as c, directionMap as d, directionSize as e, positionMap as f, h as g, handler as h, parseColor as p, valueHandlers as v, xyzMap as x };
|
package/dist/chunks/variants.cjs
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const core = require('@unocss/core');
|
|
4
|
+
|
|
3
5
|
const variantMatcher = (name, selector) => {
|
|
4
|
-
const re = new RegExp(
|
|
6
|
+
const re = new RegExp(`^${core.escapeRegExp(name)}[:-]`);
|
|
5
7
|
return (input) => {
|
|
6
8
|
const match = input.match(re);
|
|
7
9
|
if (match) {
|
|
8
10
|
return {
|
|
9
|
-
matcher: input.slice(match[
|
|
11
|
+
matcher: input.slice(match[0].length),
|
|
10
12
|
selector
|
|
11
13
|
};
|
|
12
14
|
}
|
|
13
15
|
};
|
|
14
16
|
};
|
|
17
|
+
const variantParentMatcher = (name, parent) => {
|
|
18
|
+
const re = new RegExp(`^${core.escapeRegExp(name)}[:-]`);
|
|
19
|
+
return (input) => {
|
|
20
|
+
const match = input.match(re);
|
|
21
|
+
if (match) {
|
|
22
|
+
return {
|
|
23
|
+
matcher: input.slice(match[0].length),
|
|
24
|
+
parent
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
15
29
|
|
|
16
30
|
exports.variantMatcher = variantMatcher;
|
|
31
|
+
exports.variantParentMatcher = variantParentMatcher;
|
package/dist/chunks/variants.mjs
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
|
+
import { escapeRegExp } from '@unocss/core';
|
|
2
|
+
|
|
1
3
|
const variantMatcher = (name, selector) => {
|
|
2
|
-
const re = new RegExp(
|
|
4
|
+
const re = new RegExp(`^${escapeRegExp(name)}[:-]`);
|
|
3
5
|
return (input) => {
|
|
4
6
|
const match = input.match(re);
|
|
5
7
|
if (match) {
|
|
6
8
|
return {
|
|
7
|
-
matcher: input.slice(match[
|
|
9
|
+
matcher: input.slice(match[0].length),
|
|
8
10
|
selector
|
|
9
11
|
};
|
|
10
12
|
}
|
|
11
13
|
};
|
|
12
14
|
};
|
|
15
|
+
const variantParentMatcher = (name, parent) => {
|
|
16
|
+
const re = new RegExp(`^${escapeRegExp(name)}[:-]`);
|
|
17
|
+
return (input) => {
|
|
18
|
+
const match = input.match(re);
|
|
19
|
+
if (match) {
|
|
20
|
+
return {
|
|
21
|
+
matcher: input.slice(match[0].length),
|
|
22
|
+
parent
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
};
|
|
13
27
|
|
|
14
|
-
export { variantMatcher as v };
|
|
28
|
+
export { variantParentMatcher as a, variantMatcher as v };
|
package/dist/index.cjs
CHANGED
|
@@ -18,7 +18,7 @@ const presetMini = (options = {}) => {
|
|
|
18
18
|
name: "@unocss/preset-mini",
|
|
19
19
|
theme: _default.theme,
|
|
20
20
|
rules: _default$1.rules,
|
|
21
|
-
variants: _default$2.variants,
|
|
21
|
+
variants: _default$2.variants(options),
|
|
22
22
|
options,
|
|
23
23
|
postprocess: options.variablePrefix && options.variablePrefix !== "un-" ? VarPrefixPostprocessor(options.variablePrefix) : void 0
|
|
24
24
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ const presetMini = (options = {}) => {
|
|
|
15
15
|
name: "@unocss/preset-mini",
|
|
16
16
|
theme,
|
|
17
17
|
rules,
|
|
18
|
-
variants,
|
|
18
|
+
variants: variants(options),
|
|
19
19
|
options,
|
|
20
20
|
postprocess: options.variablePrefix && options.variablePrefix !== "un-" ? VarPrefixPostprocessor(options.variablePrefix) : void 0
|
|
21
21
|
};
|
package/dist/theme.d.ts
CHANGED
|
@@ -77,8 +77,6 @@ declare const baseSize: {
|
|
|
77
77
|
'5xl': string;
|
|
78
78
|
'6xl': string;
|
|
79
79
|
'7xl': string;
|
|
80
|
-
min: string;
|
|
81
|
-
max: string;
|
|
82
80
|
prose: string;
|
|
83
81
|
};
|
|
84
82
|
declare const width: {
|
|
@@ -94,8 +92,6 @@ declare const width: {
|
|
|
94
92
|
'5xl': string;
|
|
95
93
|
'6xl': string;
|
|
96
94
|
'7xl': string;
|
|
97
|
-
min: string;
|
|
98
|
-
max: string;
|
|
99
95
|
prose: string;
|
|
100
96
|
auto: string;
|
|
101
97
|
};
|
|
@@ -112,8 +108,6 @@ declare const maxWidth: {
|
|
|
112
108
|
'5xl': string;
|
|
113
109
|
'6xl': string;
|
|
114
110
|
'7xl': string;
|
|
115
|
-
min: string;
|
|
116
|
-
max: string;
|
|
117
111
|
prose: string;
|
|
118
112
|
none: string;
|
|
119
113
|
};
|
|
@@ -130,8 +124,6 @@ declare const height: {
|
|
|
130
124
|
'5xl': string;
|
|
131
125
|
'6xl': string;
|
|
132
126
|
'7xl': string;
|
|
133
|
-
min: string;
|
|
134
|
-
max: string;
|
|
135
127
|
prose: string;
|
|
136
128
|
auto: string;
|
|
137
129
|
};
|
|
@@ -148,8 +140,6 @@ declare const maxHeight: {
|
|
|
148
140
|
'5xl': string;
|
|
149
141
|
'6xl': string;
|
|
150
142
|
'7xl': string;
|
|
151
|
-
min: string;
|
|
152
|
-
max: string;
|
|
153
143
|
prose: string;
|
|
154
144
|
none: string;
|
|
155
145
|
};
|
package/dist/utils.cjs
CHANGED
|
@@ -16,6 +16,8 @@ exports.directionSize = utilities.directionSize;
|
|
|
16
16
|
exports.h = utilities.h;
|
|
17
17
|
exports.handler = utilities.handler;
|
|
18
18
|
exports.parseColor = utilities.parseColor;
|
|
19
|
+
exports.positionMap = utilities.positionMap;
|
|
19
20
|
exports.valueHandlers = utilities.valueHandlers;
|
|
20
21
|
exports.xyzMap = utilities.xyzMap;
|
|
21
22
|
exports.variantMatcher = variants.variantMatcher;
|
|
23
|
+
exports.variantParentMatcher = variants.variantParentMatcher;
|