@unocss/preset-mini 0.58.0 → 0.58.1
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/colors.d.cts +1 -1
- package/dist/colors.d.mts +1 -1
- package/dist/colors.d.ts +1 -1
- package/dist/index.cjs +11 -11
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +6 -6
- package/dist/rules.cjs +50 -1008
- package/dist/rules.d.cts +1 -1
- package/dist/rules.d.mts +1 -1
- package/dist/rules.d.ts +1 -1
- package/dist/rules.mjs +5 -968
- package/dist/shared/{preset-mini.qLxuqSG-.cjs → preset-mini.-3Qybdh5.cjs} +38 -38
- package/dist/shared/preset-mini.0CcynBZx.mjs +537 -0
- package/dist/shared/{preset-mini.5jRPR_fm.mjs → preset-mini.0UJFjS_1.mjs} +2 -2
- package/dist/shared/{preset-mini.WoiFygE2.d.cts → preset-mini.20fUBpHS.d.cts} +1 -1
- package/dist/shared/{preset-mini.zVYE2D2j.d.ts → preset-mini.8w2rXvMk.d.ts} +1 -1
- package/dist/shared/preset-mini.AVP8I7_j.mjs +747 -0
- package/dist/shared/preset-mini.ORVb5Lu8.mjs +978 -0
- package/dist/shared/preset-mini.UhMMbd34.cjs +560 -0
- package/dist/shared/{preset-mini.4DxDu2I8.d.mts → preset-mini.YxT4AwuI.d.cts} +1 -1
- package/dist/shared/preset-mini.fgwIVvur.cjs +322 -0
- package/dist/shared/preset-mini.g6cWGZM2.cjs +1021 -0
- package/dist/shared/{preset-mini.5daNC9yh.d.ts → preset-mini.gVNz4b9u.d.ts} +1 -1
- package/dist/shared/{preset-mini.7XoWRZIl.d.cts → preset-mini.hpPpX7ws.d.cts} +1 -1
- package/dist/shared/{preset-mini.7XoWRZIl.d.mts → preset-mini.hpPpX7ws.d.mts} +1 -1
- package/dist/shared/{preset-mini.7XoWRZIl.d.ts → preset-mini.hpPpX7ws.d.ts} +1 -1
- package/dist/shared/preset-mini.jXC5Sr98.cjs +772 -0
- package/dist/shared/{preset-mini.WMGBnRDa.d.mts → preset-mini.nzD7Hw_0.d.mts} +1 -1
- package/dist/shared/{preset-mini.5-XKlNyK.d.cts → preset-mini.vMrmsD3H.d.mts} +1 -1
- package/dist/shared/preset-mini.zC_vZg74.mjs +291 -0
- package/dist/theme.cjs +34 -318
- package/dist/theme.d.cts +3 -3
- package/dist/theme.d.mts +3 -3
- package/dist/theme.d.ts +3 -3
- package/dist/theme.mjs +5 -293
- package/dist/utils.cjs +28 -545
- package/dist/utils.d.cts +4 -4
- package/dist/utils.d.mts +4 -4
- package/dist/utils.d.ts +4 -4
- package/dist/utils.mjs +2 -524
- package/dist/variants.cjs +31 -770
- package/dist/variants.d.cts +3 -3
- package/dist/variants.d.mts +3 -3
- package/dist/variants.d.ts +3 -3
- package/dist/variants.mjs +4 -747
- package/package.json +4 -4
package/dist/utils.cjs
CHANGED
|
@@ -1,550 +1,33 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const utilities = require('./shared/preset-mini.UhMMbd34.cjs');
|
|
3
4
|
const ruleUtils = require('@unocss/rule-utils');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
be: ["-inset-block-end"],
|
|
31
|
-
is: ["-inset-inline-start"],
|
|
32
|
-
ie: ["-inset-inline-end"],
|
|
33
|
-
block: ["-inset-block-start", "-inset-block-end"],
|
|
34
|
-
inline: ["-inset-inline-start", "-inset-inline-end"]
|
|
35
|
-
};
|
|
36
|
-
const cornerMap = {
|
|
37
|
-
"l": ["-top-left", "-bottom-left"],
|
|
38
|
-
"r": ["-top-right", "-bottom-right"],
|
|
39
|
-
"t": ["-top-left", "-top-right"],
|
|
40
|
-
"b": ["-bottom-left", "-bottom-right"],
|
|
41
|
-
"tl": ["-top-left"],
|
|
42
|
-
"lt": ["-top-left"],
|
|
43
|
-
"tr": ["-top-right"],
|
|
44
|
-
"rt": ["-top-right"],
|
|
45
|
-
"bl": ["-bottom-left"],
|
|
46
|
-
"lb": ["-bottom-left"],
|
|
47
|
-
"br": ["-bottom-right"],
|
|
48
|
-
"rb": ["-bottom-right"],
|
|
49
|
-
"": [""],
|
|
50
|
-
"bs": ["-start-start", "-start-end"],
|
|
51
|
-
"be": ["-end-start", "-end-end"],
|
|
52
|
-
"s": ["-end-start", "-start-start"],
|
|
53
|
-
"is": ["-end-start", "-start-start"],
|
|
54
|
-
"e": ["-start-end", "-end-end"],
|
|
55
|
-
"ie": ["-start-end", "-end-end"],
|
|
56
|
-
"ss": ["-start-start"],
|
|
57
|
-
"bs-is": ["-start-start"],
|
|
58
|
-
"is-bs": ["-start-start"],
|
|
59
|
-
"se": ["-start-end"],
|
|
60
|
-
"bs-ie": ["-start-end"],
|
|
61
|
-
"ie-bs": ["-start-end"],
|
|
62
|
-
"es": ["-end-start"],
|
|
63
|
-
"be-is": ["-end-start"],
|
|
64
|
-
"is-be": ["-end-start"],
|
|
65
|
-
"ee": ["-end-end"],
|
|
66
|
-
"be-ie": ["-end-end"],
|
|
67
|
-
"ie-be": ["-end-end"]
|
|
68
|
-
};
|
|
69
|
-
const xyzMap = {
|
|
70
|
-
"x": ["-x"],
|
|
71
|
-
"y": ["-y"],
|
|
72
|
-
"z": ["-z"],
|
|
73
|
-
"": ["-x", "-y"]
|
|
74
|
-
};
|
|
75
|
-
const basePositionMap = [
|
|
76
|
-
"top",
|
|
77
|
-
"top center",
|
|
78
|
-
"top left",
|
|
79
|
-
"top right",
|
|
80
|
-
"bottom",
|
|
81
|
-
"bottom center",
|
|
82
|
-
"bottom left",
|
|
83
|
-
"bottom right",
|
|
84
|
-
"left",
|
|
85
|
-
"left center",
|
|
86
|
-
"left top",
|
|
87
|
-
"left bottom",
|
|
88
|
-
"right",
|
|
89
|
-
"right center",
|
|
90
|
-
"right top",
|
|
91
|
-
"right bottom",
|
|
92
|
-
"center",
|
|
93
|
-
"center top",
|
|
94
|
-
"center bottom",
|
|
95
|
-
"center left",
|
|
96
|
-
"center right",
|
|
97
|
-
"center center"
|
|
98
|
-
];
|
|
99
|
-
const positionMap = Object.assign(
|
|
100
|
-
{},
|
|
101
|
-
...basePositionMap.map((p) => ({ [p.replace(/ /, "-")]: p })),
|
|
102
|
-
...basePositionMap.map((p) => ({ [p.replace(/\b(\w)\w+/g, "$1").replace(/ /, "")]: p }))
|
|
103
|
-
);
|
|
104
|
-
const globalKeywords = [
|
|
105
|
-
"inherit",
|
|
106
|
-
"initial",
|
|
107
|
-
"revert",
|
|
108
|
-
"revert-layer",
|
|
109
|
-
"unset"
|
|
110
|
-
];
|
|
111
|
-
const cssMathFnRE = /^(calc|clamp|min|max)\s*\((.+)\)(.*)/;
|
|
112
|
-
|
|
113
|
-
const numberWithUnitRE = /^(-?\d*(?:\.\d+)?)(px|pt|pc|%|r?(?:em|ex|lh|cap|ch|ic)|(?:[sld]?v|cq)(?:[whib]|min|max)|in|cm|mm|rpx)?$/i;
|
|
114
|
-
const numberRE = /^(-?\d*(?:\.\d+)?)$/i;
|
|
115
|
-
const unitOnlyRE = /^(px)$/i;
|
|
116
|
-
const bracketTypeRe = /^\[(color|length|position|quoted|string):/i;
|
|
117
|
-
|
|
118
|
-
const cssProps = [
|
|
119
|
-
// basic props
|
|
120
|
-
"color",
|
|
121
|
-
"border-color",
|
|
122
|
-
"background-color",
|
|
123
|
-
"flex-grow",
|
|
124
|
-
"flex",
|
|
125
|
-
"flex-shrink",
|
|
126
|
-
"caret-color",
|
|
127
|
-
"font",
|
|
128
|
-
"gap",
|
|
129
|
-
"opacity",
|
|
130
|
-
"visibility",
|
|
131
|
-
"z-index",
|
|
132
|
-
"font-weight",
|
|
133
|
-
"zoom",
|
|
134
|
-
"text-shadow",
|
|
135
|
-
"transform",
|
|
136
|
-
"box-shadow",
|
|
137
|
-
// positions
|
|
138
|
-
"background-position",
|
|
139
|
-
"left",
|
|
140
|
-
"right",
|
|
141
|
-
"top",
|
|
142
|
-
"bottom",
|
|
143
|
-
"object-position",
|
|
144
|
-
// sizes
|
|
145
|
-
"max-height",
|
|
146
|
-
"min-height",
|
|
147
|
-
"max-width",
|
|
148
|
-
"min-width",
|
|
149
|
-
"height",
|
|
150
|
-
"width",
|
|
151
|
-
"border-width",
|
|
152
|
-
"margin",
|
|
153
|
-
"padding",
|
|
154
|
-
"outline-width",
|
|
155
|
-
"outline-offset",
|
|
156
|
-
"font-size",
|
|
157
|
-
"line-height",
|
|
158
|
-
"text-indent",
|
|
159
|
-
"vertical-align",
|
|
160
|
-
"border-spacing",
|
|
161
|
-
"letter-spacing",
|
|
162
|
-
"word-spacing",
|
|
163
|
-
// enhances
|
|
164
|
-
"stroke",
|
|
165
|
-
"filter",
|
|
166
|
-
"backdrop-filter",
|
|
167
|
-
"fill",
|
|
168
|
-
"mask",
|
|
169
|
-
"mask-size",
|
|
170
|
-
"mask-border",
|
|
171
|
-
"clip-path",
|
|
172
|
-
"clip",
|
|
173
|
-
"border-radius"
|
|
174
|
-
];
|
|
175
|
-
function round(n) {
|
|
176
|
-
return n.toFixed(10).replace(/\.0+$/, "").replace(/(\.\d+?)0+$/, "$1");
|
|
177
|
-
}
|
|
178
|
-
function numberWithUnit(str) {
|
|
179
|
-
const match = str.match(numberWithUnitRE);
|
|
180
|
-
if (!match)
|
|
181
|
-
return;
|
|
182
|
-
const [, n, unit] = match;
|
|
183
|
-
const num = Number.parseFloat(n);
|
|
184
|
-
if (unit && !Number.isNaN(num))
|
|
185
|
-
return `${round(num)}${unit}`;
|
|
186
|
-
}
|
|
187
|
-
function auto(str) {
|
|
188
|
-
if (str === "auto" || str === "a")
|
|
189
|
-
return "auto";
|
|
190
|
-
}
|
|
191
|
-
function rem(str) {
|
|
192
|
-
if (unitOnlyRE.test(str))
|
|
193
|
-
return `1${str}`;
|
|
194
|
-
const match = str.match(numberWithUnitRE);
|
|
195
|
-
if (!match)
|
|
196
|
-
return;
|
|
197
|
-
const [, n, unit] = match;
|
|
198
|
-
const num = Number.parseFloat(n);
|
|
199
|
-
if (!Number.isNaN(num)) {
|
|
200
|
-
if (num === 0)
|
|
201
|
-
return "0";
|
|
202
|
-
return unit ? `${round(num)}${unit}` : `${round(num / 4)}rem`;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
function px(str) {
|
|
206
|
-
if (unitOnlyRE.test(str))
|
|
207
|
-
return `1${str}`;
|
|
208
|
-
const match = str.match(numberWithUnitRE);
|
|
209
|
-
if (!match)
|
|
210
|
-
return;
|
|
211
|
-
const [, n, unit] = match;
|
|
212
|
-
const num = Number.parseFloat(n);
|
|
213
|
-
if (!Number.isNaN(num))
|
|
214
|
-
return unit ? `${round(num)}${unit}` : `${round(num)}px`;
|
|
215
|
-
}
|
|
216
|
-
function number(str) {
|
|
217
|
-
if (!numberRE.test(str))
|
|
218
|
-
return;
|
|
219
|
-
const num = Number.parseFloat(str);
|
|
220
|
-
if (!Number.isNaN(num))
|
|
221
|
-
return round(num);
|
|
222
|
-
}
|
|
223
|
-
function percent(str) {
|
|
224
|
-
if (str.endsWith("%"))
|
|
225
|
-
str = str.slice(0, -1);
|
|
226
|
-
if (!numberRE.test(str))
|
|
227
|
-
return;
|
|
228
|
-
const num = Number.parseFloat(str);
|
|
229
|
-
if (!Number.isNaN(num))
|
|
230
|
-
return `${round(num / 100)}`;
|
|
231
|
-
}
|
|
232
|
-
function fraction(str) {
|
|
233
|
-
if (str === "full")
|
|
234
|
-
return "100%";
|
|
235
|
-
const [left, right] = str.split("/");
|
|
236
|
-
const num = Number.parseFloat(left) / Number.parseFloat(right);
|
|
237
|
-
if (!Number.isNaN(num)) {
|
|
238
|
-
if (num === 0)
|
|
239
|
-
return "0";
|
|
240
|
-
return `${round(num * 100)}%`;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
function bracketWithType(str, requiredType) {
|
|
244
|
-
if (str && str.startsWith("[") && str.endsWith("]")) {
|
|
245
|
-
let base;
|
|
246
|
-
let hintedType;
|
|
247
|
-
const match = str.match(bracketTypeRe);
|
|
248
|
-
if (!match) {
|
|
249
|
-
base = str.slice(1, -1);
|
|
250
|
-
} else {
|
|
251
|
-
if (!requiredType)
|
|
252
|
-
hintedType = match[1];
|
|
253
|
-
base = str.slice(match[0].length, -1);
|
|
254
|
-
}
|
|
255
|
-
if (!base)
|
|
256
|
-
return;
|
|
257
|
-
if (base === '=""')
|
|
258
|
-
return;
|
|
259
|
-
if (base.startsWith("--"))
|
|
260
|
-
base = `var(${base})`;
|
|
261
|
-
let curly = 0;
|
|
262
|
-
for (const i of base) {
|
|
263
|
-
if (i === "[") {
|
|
264
|
-
curly += 1;
|
|
265
|
-
} else if (i === "]") {
|
|
266
|
-
curly -= 1;
|
|
267
|
-
if (curly < 0)
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
if (curly)
|
|
272
|
-
return;
|
|
273
|
-
switch (hintedType) {
|
|
274
|
-
case "string":
|
|
275
|
-
return base.replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_");
|
|
276
|
-
case "quoted":
|
|
277
|
-
return base.replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(["\\])/g, "\\$1").replace(/^(.+)$/, '"$1"');
|
|
278
|
-
}
|
|
279
|
-
return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(?:calc|clamp|max|min)\((.*)/g, (match2) => {
|
|
280
|
-
const vars = [];
|
|
281
|
-
return match2.replace(/var\((--.+?)[,)]/g, (match3, g1) => {
|
|
282
|
-
vars.push(g1);
|
|
283
|
-
return match3.replace(g1, "--un-calc");
|
|
284
|
-
}).replace(/(-?\d*\.?\d(?!\b-\d.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ").replace(/--un-calc/g, () => vars.shift());
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
function bracket(str) {
|
|
289
|
-
return bracketWithType(str);
|
|
290
|
-
}
|
|
291
|
-
function bracketOfColor(str) {
|
|
292
|
-
return bracketWithType(str, "color");
|
|
293
|
-
}
|
|
294
|
-
function bracketOfLength(str) {
|
|
295
|
-
return bracketWithType(str, "length");
|
|
296
|
-
}
|
|
297
|
-
function bracketOfPosition(str) {
|
|
298
|
-
return bracketWithType(str, "position");
|
|
299
|
-
}
|
|
300
|
-
function cssvar(str) {
|
|
301
|
-
if (/^\$[^\s'"`;{}]/.test(str))
|
|
302
|
-
return `var(--${core.escapeSelector(str.slice(1))})`;
|
|
303
|
-
}
|
|
304
|
-
function time(str) {
|
|
305
|
-
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
306
|
-
if (!match)
|
|
307
|
-
return;
|
|
308
|
-
const [, n, unit] = match;
|
|
309
|
-
const num = Number.parseFloat(n);
|
|
310
|
-
if (!Number.isNaN(num)) {
|
|
311
|
-
if (num === 0 && !unit)
|
|
312
|
-
return "0s";
|
|
313
|
-
return unit ? `${round(num)}${unit}` : `${round(num)}ms`;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
function degree(str) {
|
|
317
|
-
const match = str.match(/^(-?[0-9.]+)(deg|rad|grad|turn)?$/i);
|
|
318
|
-
if (!match)
|
|
319
|
-
return;
|
|
320
|
-
const [, n, unit] = match;
|
|
321
|
-
const num = Number.parseFloat(n);
|
|
322
|
-
if (!Number.isNaN(num)) {
|
|
323
|
-
if (num === 0)
|
|
324
|
-
return "0";
|
|
325
|
-
return unit ? `${round(num)}${unit}` : `${round(num)}deg`;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
function global(str) {
|
|
329
|
-
if (globalKeywords.includes(str))
|
|
330
|
-
return str;
|
|
331
|
-
}
|
|
332
|
-
function properties(str) {
|
|
333
|
-
if (str.split(",").every((prop) => cssProps.includes(prop)))
|
|
334
|
-
return str;
|
|
335
|
-
}
|
|
336
|
-
function position(str) {
|
|
337
|
-
if (["top", "left", "right", "bottom", "center"].includes(str))
|
|
338
|
-
return str;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
const valueHandlers = {
|
|
342
|
-
__proto__: null,
|
|
343
|
-
auto: auto,
|
|
344
|
-
bracket: bracket,
|
|
345
|
-
bracketOfColor: bracketOfColor,
|
|
346
|
-
bracketOfLength: bracketOfLength,
|
|
347
|
-
bracketOfPosition: bracketOfPosition,
|
|
348
|
-
cssvar: cssvar,
|
|
349
|
-
degree: degree,
|
|
350
|
-
fraction: fraction,
|
|
351
|
-
global: global,
|
|
352
|
-
number: number,
|
|
353
|
-
numberWithUnit: numberWithUnit,
|
|
354
|
-
percent: percent,
|
|
355
|
-
position: position,
|
|
356
|
-
properties: properties,
|
|
357
|
-
px: px,
|
|
358
|
-
rem: rem,
|
|
359
|
-
time: time
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
const handler = ruleUtils.createValueHandler(valueHandlers);
|
|
363
|
-
const h = handler;
|
|
364
|
-
|
|
365
|
-
const CONTROL_MINI_NO_NEGATIVE = "$$mini-no-negative";
|
|
366
|
-
function directionSize(propertyPrefix) {
|
|
367
|
-
return ([_, direction, size], { theme }) => {
|
|
368
|
-
const v = theme.spacing?.[size || "DEFAULT"] ?? h.bracket.cssvar.global.auto.fraction.rem(size);
|
|
369
|
-
if (v != null)
|
|
370
|
-
return directionMap[direction].map((i) => [`${propertyPrefix}${i}`, v]);
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
function getThemeColorForKey(theme, colors, key = "colors") {
|
|
374
|
-
let obj = theme[key];
|
|
375
|
-
let index = -1;
|
|
376
|
-
for (const c of colors) {
|
|
377
|
-
index += 1;
|
|
378
|
-
if (obj && typeof obj !== "string") {
|
|
379
|
-
const camel = colors.slice(index).join("-").replace(/(-[a-z])/g, (n) => n.slice(1).toUpperCase());
|
|
380
|
-
if (obj[camel])
|
|
381
|
-
return obj[camel];
|
|
382
|
-
if (obj[c]) {
|
|
383
|
-
obj = obj[c];
|
|
384
|
-
continue;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
return void 0;
|
|
388
|
-
}
|
|
389
|
-
return obj;
|
|
390
|
-
}
|
|
391
|
-
function getThemeColor(theme, colors, key) {
|
|
392
|
-
return getThemeColorForKey(theme, colors, key) || getThemeColorForKey(theme, colors, "colors");
|
|
393
|
-
}
|
|
394
|
-
function splitShorthand(body, type) {
|
|
395
|
-
const [front, rest] = ruleUtils.getStringComponent(body, "[", "]", ["/", ":"]) ?? [];
|
|
396
|
-
if (front != null) {
|
|
397
|
-
const match = (front.match(bracketTypeRe) ?? [])[1];
|
|
398
|
-
if (match == null || match === type)
|
|
399
|
-
return [front, rest];
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
function parseColor(body, theme, key) {
|
|
403
|
-
const split = splitShorthand(body, "color");
|
|
404
|
-
if (!split)
|
|
405
|
-
return;
|
|
406
|
-
const [main, opacity] = split;
|
|
407
|
-
const colors = main.replace(/([a-z])([0-9])/g, "$1-$2").split(/-/g);
|
|
408
|
-
const [name] = colors;
|
|
409
|
-
if (!name)
|
|
410
|
-
return;
|
|
411
|
-
let color;
|
|
412
|
-
const bracket = h.bracketOfColor(main);
|
|
413
|
-
const bracketOrMain = bracket || main;
|
|
414
|
-
if (h.numberWithUnit(bracketOrMain))
|
|
415
|
-
return;
|
|
416
|
-
if (/^#[\da-fA-F]+/.test(bracketOrMain))
|
|
417
|
-
color = bracketOrMain;
|
|
418
|
-
else if (/^hex-[\da-fA-F]+/.test(bracketOrMain))
|
|
419
|
-
color = `#${bracketOrMain.slice(4)}`;
|
|
420
|
-
else if (main.startsWith("$"))
|
|
421
|
-
color = h.cssvar(main);
|
|
422
|
-
color = color || bracket;
|
|
423
|
-
if (!color) {
|
|
424
|
-
const colorData = getThemeColor(theme, [main], key);
|
|
425
|
-
if (typeof colorData === "string")
|
|
426
|
-
color = colorData;
|
|
427
|
-
}
|
|
428
|
-
let no = "DEFAULT";
|
|
429
|
-
if (!color) {
|
|
430
|
-
let colorData;
|
|
431
|
-
const [scale] = colors.slice(-1);
|
|
432
|
-
if (/^\d+$/.test(scale)) {
|
|
433
|
-
no = scale;
|
|
434
|
-
colorData = getThemeColor(theme, colors.slice(0, -1), key);
|
|
435
|
-
if (!colorData || typeof colorData === "string")
|
|
436
|
-
color = void 0;
|
|
437
|
-
else
|
|
438
|
-
color = colorData[no];
|
|
439
|
-
} else {
|
|
440
|
-
colorData = getThemeColor(theme, colors, key);
|
|
441
|
-
if (!colorData && colors.length <= 2) {
|
|
442
|
-
[, no = no] = colors;
|
|
443
|
-
colorData = getThemeColor(theme, [name], key);
|
|
444
|
-
}
|
|
445
|
-
if (typeof colorData === "string")
|
|
446
|
-
color = colorData;
|
|
447
|
-
else if (no && colorData)
|
|
448
|
-
color = colorData[no];
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
return {
|
|
452
|
-
opacity,
|
|
453
|
-
name,
|
|
454
|
-
no,
|
|
455
|
-
color,
|
|
456
|
-
cssColor: ruleUtils.parseCssColor(color),
|
|
457
|
-
alpha: h.bracket.cssvar.percent(opacity ?? "")
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
function colorResolver(property, varName, key, shouldPass) {
|
|
461
|
-
return ([, body], { theme }) => {
|
|
462
|
-
const data = parseColor(body, theme, key);
|
|
463
|
-
if (!data)
|
|
464
|
-
return;
|
|
465
|
-
const { alpha, color, cssColor } = data;
|
|
466
|
-
const css = {};
|
|
467
|
-
if (cssColor) {
|
|
468
|
-
if (alpha != null) {
|
|
469
|
-
css[property] = ruleUtils.colorToString(cssColor, alpha);
|
|
470
|
-
} else {
|
|
471
|
-
css[`--un-${varName}-opacity`] = ruleUtils.colorOpacityToString(cssColor);
|
|
472
|
-
css[property] = ruleUtils.colorToString(cssColor, `var(--un-${varName}-opacity)`);
|
|
473
|
-
}
|
|
474
|
-
} else if (color) {
|
|
475
|
-
css[property] = ruleUtils.colorToString(color, alpha);
|
|
476
|
-
}
|
|
477
|
-
if (shouldPass?.(css) !== false)
|
|
478
|
-
return css;
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
function colorableShadows(shadows, colorVar) {
|
|
482
|
-
const colored = [];
|
|
483
|
-
shadows = core.toArray(shadows);
|
|
484
|
-
for (let i = 0; i < shadows.length; i++) {
|
|
485
|
-
const components = ruleUtils.getStringComponents(shadows[i], " ", 6);
|
|
486
|
-
if (!components || components.length < 3)
|
|
487
|
-
return shadows;
|
|
488
|
-
if (ruleUtils.parseCssColor(components.at(0)))
|
|
489
|
-
return shadows;
|
|
490
|
-
let colorVarValue = "";
|
|
491
|
-
if (ruleUtils.parseCssColor(components.at(-1))) {
|
|
492
|
-
const color = ruleUtils.parseCssColor(components.pop());
|
|
493
|
-
if (color)
|
|
494
|
-
colorVarValue = `, ${ruleUtils.colorToString(color)}`;
|
|
495
|
-
}
|
|
496
|
-
colored.push(`${components.join(" ")} var(${colorVar}${colorVarValue})`);
|
|
497
|
-
}
|
|
498
|
-
return colored;
|
|
499
|
-
}
|
|
500
|
-
function hasParseableColor(color, theme, key) {
|
|
501
|
-
return color != null && !!parseColor(color, theme, key)?.color;
|
|
502
|
-
}
|
|
503
|
-
function resolveBreakpoints({ theme, generator }, key = "breakpoints") {
|
|
504
|
-
let breakpoints;
|
|
505
|
-
if (generator.userConfig && generator.userConfig.theme)
|
|
506
|
-
breakpoints = generator.userConfig.theme[key];
|
|
507
|
-
if (!breakpoints)
|
|
508
|
-
breakpoints = theme[key];
|
|
509
|
-
return breakpoints ? Object.entries(breakpoints).sort((a, b) => Number.parseInt(a[1].replace(/[a-z]+/gi, "")) - Number.parseInt(b[1].replace(/[a-z]+/gi, ""))).map(([point, size]) => ({ point, size })) : void 0;
|
|
510
|
-
}
|
|
511
|
-
function resolveVerticalBreakpoints(context) {
|
|
512
|
-
return resolveBreakpoints(context, "verticalBreakpoints");
|
|
513
|
-
}
|
|
514
|
-
function makeGlobalStaticRules(prefix, property) {
|
|
515
|
-
return globalKeywords.map((keyword) => [`${prefix}-${keyword}`, { [property ?? prefix]: keyword }]);
|
|
516
|
-
}
|
|
517
|
-
function isCSSMathFn(value) {
|
|
518
|
-
return value != null && cssMathFnRE.test(value);
|
|
519
|
-
}
|
|
520
|
-
function isSize(str) {
|
|
521
|
-
if (str[0] === "[" && str.slice(-1) === "]")
|
|
522
|
-
str = str.slice(1, -1);
|
|
523
|
-
return cssMathFnRE.test(str) || numberWithUnitRE.test(str);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
exports.CONTROL_MINI_NO_NEGATIVE = CONTROL_MINI_NO_NEGATIVE;
|
|
527
|
-
exports.colorResolver = colorResolver;
|
|
528
|
-
exports.colorableShadows = colorableShadows;
|
|
529
|
-
exports.cornerMap = cornerMap;
|
|
530
|
-
exports.cssMathFnRE = cssMathFnRE;
|
|
531
|
-
exports.directionMap = directionMap;
|
|
532
|
-
exports.directionSize = directionSize;
|
|
533
|
-
exports.globalKeywords = globalKeywords;
|
|
534
|
-
exports.h = h;
|
|
535
|
-
exports.handler = handler;
|
|
536
|
-
exports.hasParseableColor = hasParseableColor;
|
|
537
|
-
exports.insetMap = insetMap;
|
|
538
|
-
exports.isCSSMathFn = isCSSMathFn;
|
|
539
|
-
exports.isSize = isSize;
|
|
540
|
-
exports.makeGlobalStaticRules = makeGlobalStaticRules;
|
|
541
|
-
exports.parseColor = parseColor;
|
|
542
|
-
exports.positionMap = positionMap;
|
|
543
|
-
exports.resolveBreakpoints = resolveBreakpoints;
|
|
544
|
-
exports.resolveVerticalBreakpoints = resolveVerticalBreakpoints;
|
|
545
|
-
exports.splitShorthand = splitShorthand;
|
|
546
|
-
exports.valueHandlers = valueHandlers;
|
|
547
|
-
exports.xyzMap = xyzMap;
|
|
5
|
+
require('@unocss/core');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.CONTROL_MINI_NO_NEGATIVE = utilities.CONTROL_MINI_NO_NEGATIVE;
|
|
10
|
+
exports.colorResolver = utilities.colorResolver;
|
|
11
|
+
exports.colorableShadows = utilities.colorableShadows;
|
|
12
|
+
exports.cornerMap = utilities.cornerMap;
|
|
13
|
+
exports.cssMathFnRE = utilities.cssMathFnRE;
|
|
14
|
+
exports.directionMap = utilities.directionMap;
|
|
15
|
+
exports.directionSize = utilities.directionSize;
|
|
16
|
+
exports.globalKeywords = utilities.globalKeywords;
|
|
17
|
+
exports.h = utilities.h;
|
|
18
|
+
exports.handler = utilities.handler;
|
|
19
|
+
exports.hasParseableColor = utilities.hasParseableColor;
|
|
20
|
+
exports.insetMap = utilities.insetMap;
|
|
21
|
+
exports.isCSSMathFn = utilities.isCSSMathFn;
|
|
22
|
+
exports.isSize = utilities.isSize;
|
|
23
|
+
exports.makeGlobalStaticRules = utilities.makeGlobalStaticRules;
|
|
24
|
+
exports.parseColor = utilities.parseColor;
|
|
25
|
+
exports.positionMap = utilities.positionMap;
|
|
26
|
+
exports.resolveBreakpoints = utilities.resolveBreakpoints;
|
|
27
|
+
exports.resolveVerticalBreakpoints = utilities.resolveVerticalBreakpoints;
|
|
28
|
+
exports.splitShorthand = utilities.splitShorthand;
|
|
29
|
+
exports.valueHandlers = utilities.valueHandlers;
|
|
30
|
+
exports.xyzMap = utilities.xyzMap;
|
|
548
31
|
Object.keys(ruleUtils).forEach(function (k) {
|
|
549
|
-
|
|
32
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = ruleUtils[k];
|
|
550
33
|
});
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _unocss_rule_utils from '@unocss/rule-utils';
|
|
2
2
|
export * from '@unocss/rule-utils';
|
|
3
|
-
export { C as CONTROL_MINI_NO_NEGATIVE, c as colorResolver, a as colorableShadows, d as directionSize, h as hasParseableColor, i as isCSSMathFn, e as isSize, m as makeGlobalStaticRules, p as parseColor, r as resolveBreakpoints, b as resolveVerticalBreakpoints, s as splitShorthand } from './shared/preset-mini.
|
|
3
|
+
export { C as CONTROL_MINI_NO_NEGATIVE, c as colorResolver, a as colorableShadows, d as directionSize, h as hasParseableColor, i as isCSSMathFn, e as isSize, m as makeGlobalStaticRules, p as parseColor, r as resolveBreakpoints, b as resolveVerticalBreakpoints, s as splitShorthand } from './shared/preset-mini.20fUBpHS.cjs';
|
|
4
4
|
import '@unocss/core';
|
|
5
|
-
import './shared/preset-mini.
|
|
5
|
+
import './shared/preset-mini.hpPpX7ws.cjs';
|
|
6
6
|
|
|
7
7
|
declare const directionMap: Record<string, string[]>;
|
|
8
8
|
declare const insetMap: Record<string, string[]>;
|
|
@@ -51,7 +51,7 @@ declare namespace handlers {
|
|
|
51
51
|
export { handlers_auto as auto, handlers_bracket as bracket, handlers_bracketOfColor as bracketOfColor, handlers_bracketOfLength as bracketOfLength, handlers_bracketOfPosition as bracketOfPosition, handlers_cssvar as cssvar, handlers_degree as degree, handlers_fraction as fraction, handlers_global as global, handlers_number as number, handlers_numberWithUnit as numberWithUnit, handlers_percent as percent, handlers_position as position, handlers_properties as properties, handlers_px as px, handlers_rem as rem, handlers_time as time };
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
declare const handler: _unocss_rule_utils.ValueHandler<"number" | "
|
|
55
|
-
declare const h: _unocss_rule_utils.ValueHandler<"number" | "
|
|
54
|
+
declare const handler: _unocss_rule_utils.ValueHandler<"number" | "auto" | "position" | "global" | "numberWithUnit" | "rem" | "px" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "bracketOfPosition" | "cssvar" | "time" | "degree" | "properties">;
|
|
55
|
+
declare const h: _unocss_rule_utils.ValueHandler<"number" | "auto" | "position" | "global" | "numberWithUnit" | "rem" | "px" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "bracketOfPosition" | "cssvar" | "time" | "degree" | "properties">;
|
|
56
56
|
|
|
57
57
|
export { cornerMap, cssMathFnRE, directionMap, globalKeywords, h, handler, insetMap, positionMap, handlers as valueHandlers, xyzMap };
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _unocss_rule_utils from '@unocss/rule-utils';
|
|
2
2
|
export * from '@unocss/rule-utils';
|
|
3
|
-
export { C as CONTROL_MINI_NO_NEGATIVE, c as colorResolver, a as colorableShadows, d as directionSize, h as hasParseableColor, i as isCSSMathFn, e as isSize, m as makeGlobalStaticRules, p as parseColor, r as resolveBreakpoints, b as resolveVerticalBreakpoints, s as splitShorthand } from './shared/preset-mini.
|
|
3
|
+
export { C as CONTROL_MINI_NO_NEGATIVE, c as colorResolver, a as colorableShadows, d as directionSize, h as hasParseableColor, i as isCSSMathFn, e as isSize, m as makeGlobalStaticRules, p as parseColor, r as resolveBreakpoints, b as resolveVerticalBreakpoints, s as splitShorthand } from './shared/preset-mini.nzD7Hw_0.mjs';
|
|
4
4
|
import '@unocss/core';
|
|
5
|
-
import './shared/preset-mini.
|
|
5
|
+
import './shared/preset-mini.hpPpX7ws.mjs';
|
|
6
6
|
|
|
7
7
|
declare const directionMap: Record<string, string[]>;
|
|
8
8
|
declare const insetMap: Record<string, string[]>;
|
|
@@ -51,7 +51,7 @@ declare namespace handlers {
|
|
|
51
51
|
export { handlers_auto as auto, handlers_bracket as bracket, handlers_bracketOfColor as bracketOfColor, handlers_bracketOfLength as bracketOfLength, handlers_bracketOfPosition as bracketOfPosition, handlers_cssvar as cssvar, handlers_degree as degree, handlers_fraction as fraction, handlers_global as global, handlers_number as number, handlers_numberWithUnit as numberWithUnit, handlers_percent as percent, handlers_position as position, handlers_properties as properties, handlers_px as px, handlers_rem as rem, handlers_time as time };
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
declare const handler: _unocss_rule_utils.ValueHandler<"number" | "
|
|
55
|
-
declare const h: _unocss_rule_utils.ValueHandler<"number" | "
|
|
54
|
+
declare const handler: _unocss_rule_utils.ValueHandler<"number" | "auto" | "position" | "global" | "numberWithUnit" | "rem" | "px" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "bracketOfPosition" | "cssvar" | "time" | "degree" | "properties">;
|
|
55
|
+
declare const h: _unocss_rule_utils.ValueHandler<"number" | "auto" | "position" | "global" | "numberWithUnit" | "rem" | "px" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "bracketOfPosition" | "cssvar" | "time" | "degree" | "properties">;
|
|
56
56
|
|
|
57
57
|
export { cornerMap, cssMathFnRE, directionMap, globalKeywords, h, handler, insetMap, positionMap, handlers as valueHandlers, xyzMap };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _unocss_rule_utils from '@unocss/rule-utils';
|
|
2
2
|
export * from '@unocss/rule-utils';
|
|
3
|
-
export { C as CONTROL_MINI_NO_NEGATIVE, c as colorResolver, a as colorableShadows, d as directionSize, h as hasParseableColor, i as isCSSMathFn, e as isSize, m as makeGlobalStaticRules, p as parseColor, r as resolveBreakpoints, b as resolveVerticalBreakpoints, s as splitShorthand } from './shared/preset-mini.
|
|
3
|
+
export { C as CONTROL_MINI_NO_NEGATIVE, c as colorResolver, a as colorableShadows, d as directionSize, h as hasParseableColor, i as isCSSMathFn, e as isSize, m as makeGlobalStaticRules, p as parseColor, r as resolveBreakpoints, b as resolveVerticalBreakpoints, s as splitShorthand } from './shared/preset-mini.8w2rXvMk.js';
|
|
4
4
|
import '@unocss/core';
|
|
5
|
-
import './shared/preset-mini.
|
|
5
|
+
import './shared/preset-mini.hpPpX7ws.js';
|
|
6
6
|
|
|
7
7
|
declare const directionMap: Record<string, string[]>;
|
|
8
8
|
declare const insetMap: Record<string, string[]>;
|
|
@@ -51,7 +51,7 @@ declare namespace handlers {
|
|
|
51
51
|
export { handlers_auto as auto, handlers_bracket as bracket, handlers_bracketOfColor as bracketOfColor, handlers_bracketOfLength as bracketOfLength, handlers_bracketOfPosition as bracketOfPosition, handlers_cssvar as cssvar, handlers_degree as degree, handlers_fraction as fraction, handlers_global as global, handlers_number as number, handlers_numberWithUnit as numberWithUnit, handlers_percent as percent, handlers_position as position, handlers_properties as properties, handlers_px as px, handlers_rem as rem, handlers_time as time };
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
declare const handler: _unocss_rule_utils.ValueHandler<"number" | "
|
|
55
|
-
declare const h: _unocss_rule_utils.ValueHandler<"number" | "
|
|
54
|
+
declare const handler: _unocss_rule_utils.ValueHandler<"number" | "auto" | "position" | "global" | "numberWithUnit" | "rem" | "px" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "bracketOfPosition" | "cssvar" | "time" | "degree" | "properties">;
|
|
55
|
+
declare const h: _unocss_rule_utils.ValueHandler<"number" | "auto" | "position" | "global" | "numberWithUnit" | "rem" | "px" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "bracketOfPosition" | "cssvar" | "time" | "degree" | "properties">;
|
|
56
56
|
|
|
57
57
|
export { cornerMap, cssMathFnRE, directionMap, globalKeywords, h, handler, insetMap, positionMap, handlers as valueHandlers, xyzMap };
|