@unocss/preset-mini 0.25.0 → 0.26.2
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 +42 -6
- package/dist/chunks/default.mjs +39 -7
- package/dist/chunks/default2.cjs +88 -85
- package/dist/chunks/default2.mjs +90 -86
- package/dist/chunks/utilities.cjs +42 -12
- package/dist/chunks/utilities.mjs +42 -13
- package/dist/{colors-0db1b382.d.ts → colors-ce2fecb8.d.ts} +1 -1
- package/dist/colors.d.ts +2 -2
- package/dist/{default-3eaf5bb0.d.ts → default-e6d1b2e8.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/rules.cjs +0 -1
- package/dist/rules.d.ts +7 -14
- package/dist/rules.mjs +1 -1
- package/dist/theme.cjs +4 -0
- package/dist/theme.d.ts +34 -6
- package/dist/theme.mjs +1 -1
- package/dist/{types-ef1d7462.d.ts → types-f7b2c653.d.ts} +10 -0
- package/dist/{utilities-43c87ad4.d.ts → utilities-820bcff8.d.ts} +13 -13
- package/dist/utils.cjs +1 -0
- package/dist/utils.d.ts +10 -4
- package/dist/utils.mjs +1 -1
- package/dist/variants.d.ts +4 -4
- package/package.json +2 -2
package/dist/chunks/default2.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as handler, c as colorResolver, d as directionMap, p as parseColor,
|
|
1
|
+
import { h as handler, c as colorResolver, d as directionMap, a as hasParseableColor, p as parseColor, b as colorToString, e as cornerMap, f as colorableShadows, i as insetMap, g as directionSize, j as positionMap, x as xyzMap } from './utilities.mjs';
|
|
2
2
|
import { toArray, CONTROL_SHORTCUT_NO_MERGE } from '@unocss/core';
|
|
3
3
|
|
|
4
4
|
const verticalAlignAlias = {
|
|
@@ -17,9 +17,9 @@ const textAligns = [
|
|
|
17
17
|
];
|
|
18
18
|
|
|
19
19
|
const outline = [
|
|
20
|
-
[/^outline-(?:width-|size-)?(.+)$/, ([, d]) => ({ "outline-width": handler.bracket.cssvar.px(d) })],
|
|
20
|
+
[/^outline-(?:width-|size-)?(.+)$/, ([, d], { theme }) => ({ "outline-width": theme.lineWidth?.[d] ?? handler.bracket.cssvar.px(d) })],
|
|
21
21
|
[/^outline-(?:color-)?(.+)$/, colorResolver("outline-color", "outline-color")],
|
|
22
|
-
[/^outline-offset-(.+)$/, ([, d]) => ({ "outline-offset": handler.bracket.cssvar.px(d) })],
|
|
22
|
+
[/^outline-offset-(.+)$/, ([, d], { theme }) => ({ "outline-offset": theme.lineWidth?.[d] ?? handler.bracket.cssvar.px(d) })],
|
|
23
23
|
["outline", { "outline-style": "solid" }],
|
|
24
24
|
[/^outline-(auto|dashed|dotted|double|hidden|solid|groove|ridge|inset|outset|inherit|initial|revert|unset)$/, ([, c]) => ({ "outline-style": c })],
|
|
25
25
|
["outline-none", { "outline": "2px solid transparent", "outline-offset": "2px" }]
|
|
@@ -73,10 +73,7 @@ const borders = [
|
|
|
73
73
|
["border-hidden", { "border-style": "hidden" }],
|
|
74
74
|
["border-none", { "border-style": "none" }]
|
|
75
75
|
];
|
|
76
|
-
const
|
|
77
|
-
return color !== void 0 && !!parseColor(color, theme)?.color;
|
|
78
|
-
};
|
|
79
|
-
const borderColorResolver = (direction) => ([, body], { theme }) => {
|
|
76
|
+
const borderColorResolver = (direction) => ([, body], theme) => {
|
|
80
77
|
const data = parseColor(body, theme);
|
|
81
78
|
if (!data)
|
|
82
79
|
return;
|
|
@@ -105,8 +102,8 @@ const borderColorResolver = (direction) => ([, body], { theme }) => {
|
|
|
105
102
|
};
|
|
106
103
|
}
|
|
107
104
|
};
|
|
108
|
-
function handlerBorder(m) {
|
|
109
|
-
const borderSizes = handlerBorderSize(m);
|
|
105
|
+
function handlerBorder(m, ctx) {
|
|
106
|
+
const borderSizes = handlerBorderSize(m, ctx);
|
|
110
107
|
if (borderSizes) {
|
|
111
108
|
return [
|
|
112
109
|
...borderSizes,
|
|
@@ -114,14 +111,14 @@ function handlerBorder(m) {
|
|
|
114
111
|
];
|
|
115
112
|
}
|
|
116
113
|
}
|
|
117
|
-
function handlerBorderSize([, a = "", b
|
|
118
|
-
const v = handler.bracket.cssvar.px(b);
|
|
114
|
+
function handlerBorderSize([, a = "", b], { theme }) {
|
|
115
|
+
const v = theme.lineWidth?.[b || "DEFAULT"] ?? handler.bracket.cssvar.px(b || "1");
|
|
119
116
|
if (a in directionMap && v != null)
|
|
120
117
|
return directionMap[a].map((i) => [`border${i}-width`, v]);
|
|
121
118
|
}
|
|
122
|
-
function handlerBorderColor([, a = "", c],
|
|
123
|
-
if (a in directionMap &&
|
|
124
|
-
return Object.assign({}, ...directionMap[a].map((i) => borderColorResolver(i)(["", c],
|
|
119
|
+
function handlerBorderColor([, a = "", c], { theme }) {
|
|
120
|
+
if (a in directionMap && hasParseableColor(c, theme)) {
|
|
121
|
+
return Object.assign({}, ...directionMap[a].map((i) => borderColorResolver(i)(["", c], theme)));
|
|
125
122
|
}
|
|
126
123
|
}
|
|
127
124
|
function handlerBorderOpacity([, a = "", opacity]) {
|
|
@@ -129,8 +126,8 @@ function handlerBorderOpacity([, a = "", opacity]) {
|
|
|
129
126
|
if (a in directionMap && v != null)
|
|
130
127
|
return directionMap[a].map((i) => [`--un-border${i}-opacity`, v]);
|
|
131
128
|
}
|
|
132
|
-
function handlerRounded([, a = "", s
|
|
133
|
-
const v = theme.borderRadius?.[s] || handler.bracket.cssvar.fraction.rem(s);
|
|
129
|
+
function handlerRounded([, a = "", s], { theme }) {
|
|
130
|
+
const v = theme.borderRadius?.[s || "DEFAULT"] || handler.bracket.cssvar.fraction.rem(s || "1");
|
|
134
131
|
if (a in cornerMap && v != null)
|
|
135
132
|
return cornerMap[a].map((i) => [`border${i}-radius`, v]);
|
|
136
133
|
}
|
|
@@ -159,18 +156,19 @@ const transitionProperty = (prop) => {
|
|
|
159
156
|
return handler.properties(prop) ?? transitionPropertyGroup[prop];
|
|
160
157
|
};
|
|
161
158
|
const transitions = [
|
|
162
|
-
[/^transition(?:-([a-z-]+(?:,[a-z-]+)*))?(?:-(\d+))?$/, ([, prop,
|
|
159
|
+
[/^transition(?:-([a-z-]+(?:,[a-z-]+)*))?(?:-(\d+))?$/, ([, prop, d], { theme }) => {
|
|
163
160
|
const p = prop != null ? transitionProperty(prop) : [transitionPropertyGroup.colors, "opacity", "box-shadow", "transform", "filter", "backdrop-filter"].join(",");
|
|
164
161
|
if (p) {
|
|
162
|
+
const duration = theme.duration?.[d || "DEFAULT"] ?? handler.time(d || "150");
|
|
165
163
|
return {
|
|
166
164
|
"transition-property": p,
|
|
167
165
|
"transition-timing-function": "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
168
|
-
"transition-duration":
|
|
166
|
+
"transition-duration": duration
|
|
169
167
|
};
|
|
170
168
|
}
|
|
171
169
|
}],
|
|
172
|
-
[/^(?:transition-)?duration-(.+)$/, ([, d]) => ({ "transition-duration": handler.bracket.cssvar.time(d) })],
|
|
173
|
-
[/^(?:transition-)?delay-(.+)$/, ([, d]) => ({ "transition-delay": handler.bracket.cssvar.time(d) })],
|
|
170
|
+
[/^(?:transition-)?duration-(.+)$/, ([, d], { theme }) => ({ "transition-duration": theme.duration?.[d || "DEFAULT"] ?? handler.bracket.cssvar.time(d) })],
|
|
171
|
+
[/^(?:transition-)?delay-(.+)$/, ([, d], { theme }) => ({ "transition-delay": theme.duration?.[d || "DEFAULT"] ?? handler.bracket.cssvar.time(d) })],
|
|
174
172
|
[/^(?:transition-)?ease(?:-(.+))?$/, ([, d], { theme }) => ({ "transition-timing-function": theme.easing?.[d || "DEFAULT"] ?? handler.bracket.cssvar(d) })],
|
|
175
173
|
[/^(?:transition-)?property-(.+)$/, ([, v]) => ({ "transition-property": handler.global(v) || transitionProperty(v) })],
|
|
176
174
|
["transition-none", { transition: "none" }]
|
|
@@ -189,7 +187,7 @@ const flex = [
|
|
|
189
187
|
[/^(?:flex-)?shrink-0$/, () => ({ "flex-shrink": 0 })],
|
|
190
188
|
[/^(?:flex-)?grow$/, () => ({ "flex-grow": 1 })],
|
|
191
189
|
[/^(?:flex-)?grow-0$/, () => ({ "flex-grow": 0 })],
|
|
192
|
-
[/^(?:flex-)?basis-(.+)$/, ([, d]) => ({ "flex-basis": handler.bracket.cssvar.auto.fraction.rem(d) })],
|
|
190
|
+
[/^(?:flex-)?basis-(.+)$/, ([, d], { theme }) => ({ "flex-basis": theme.spacing?.[d] ?? handler.bracket.cssvar.auto.fraction.rem(d) })],
|
|
193
191
|
["flex-row", { "flex-direction": "row" }],
|
|
194
192
|
["flex-row-reverse", { "flex-direction": "row-reverse" }],
|
|
195
193
|
["flex-col", { "flex-direction": "column" }],
|
|
@@ -221,9 +219,14 @@ const fonts = [
|
|
|
221
219
|
"line-height": height
|
|
222
220
|
};
|
|
223
221
|
}
|
|
224
|
-
return { "font-size": handler.
|
|
222
|
+
return { "font-size": handler.bracketOfLength.rem(s) };
|
|
223
|
+
}],
|
|
224
|
+
[/^text-size-(.+)$/, ([, s], { theme }) => {
|
|
225
|
+
const themed = toArray(theme.fontSize?.[s]);
|
|
226
|
+
const size = themed?.[0] ?? handler.bracket.cssvar.rem(s);
|
|
227
|
+
if (size != null)
|
|
228
|
+
return { "font-size": size };
|
|
225
229
|
}],
|
|
226
|
-
[/^text-size-(.+)$/, ([, s]) => ({ "font-size": handler.bracket.cssvar.rem(s) })],
|
|
227
230
|
[/^(?:font|fw)-?([^-]+)$/, ([, s]) => ({ "font-weight": weightMap[s] || handler.number(s) })],
|
|
228
231
|
[/^(?:leading|lh)-(.+)$/, ([, s], { theme }) => ({ "line-height": theme.lineHeight?.[s] || handler.bracket.cssvar.rem(s) })],
|
|
229
232
|
[/^tracking-(.+)$/, ([, s], { theme }) => ({ "letter-spacing": theme.letterSpacing?.[s] || handler.bracket.cssvar.rem(s) })],
|
|
@@ -269,8 +272,8 @@ const directions = {
|
|
|
269
272
|
"x": "column-",
|
|
270
273
|
"y": "row-"
|
|
271
274
|
};
|
|
272
|
-
const handleGap = ([, d = "", s]) => {
|
|
273
|
-
const v = handler.bracket.cssvar.rem(s);
|
|
275
|
+
const handleGap = ([, d = "", s], { theme }) => {
|
|
276
|
+
const v = theme.spacing?.[s] ?? handler.bracket.cssvar.rem(s);
|
|
274
277
|
if (v != null) {
|
|
275
278
|
return {
|
|
276
279
|
[`grid-${directions[d]}gap`]: v,
|
|
@@ -279,16 +282,17 @@ const handleGap = ([, d = "", s]) => {
|
|
|
279
282
|
}
|
|
280
283
|
};
|
|
281
284
|
const gaps = [
|
|
282
|
-
[/^(?:flex-|grid-)?gap-()(
|
|
283
|
-
[/^(?:flex-|grid-)?gap-([xy])-(
|
|
285
|
+
[/^(?:flex-|grid-)?gap-()(.+)$/, handleGap],
|
|
286
|
+
[/^(?:flex-|grid-)?gap-([xy])-(.+)$/, handleGap]
|
|
284
287
|
];
|
|
285
288
|
|
|
286
289
|
const rowCol = (s) => s.replace("col", "column");
|
|
287
|
-
const
|
|
288
|
-
|
|
290
|
+
const rowColTheme = (s) => s[0] === "r" ? "Row" : "Column";
|
|
291
|
+
const autoDirection = (c, theme, prop) => {
|
|
292
|
+
const v = theme[`gridAuto${rowColTheme(c)}`]?.[prop];
|
|
289
293
|
if (v != null)
|
|
290
|
-
return
|
|
291
|
-
switch (
|
|
294
|
+
return v;
|
|
295
|
+
switch (prop) {
|
|
292
296
|
case "min":
|
|
293
297
|
return "min-content";
|
|
294
298
|
case "max":
|
|
@@ -296,12 +300,14 @@ const autoDirection = (selector, theme) => {
|
|
|
296
300
|
case "fr":
|
|
297
301
|
return "minmax(0,1fr)";
|
|
298
302
|
}
|
|
299
|
-
return handler.bracket.cssvar.auto.rem(
|
|
303
|
+
return handler.bracket.cssvar.auto.rem(prop);
|
|
300
304
|
};
|
|
301
305
|
const grids = [
|
|
302
306
|
["grid", { display: "grid" }],
|
|
303
307
|
["inline-grid", { display: "inline-grid" }],
|
|
304
|
-
[/^(?:grid-)?(row|col)-(.+)$/, ([, c, v]) => ({
|
|
308
|
+
[/^(?:grid-)?(row|col)-(.+)$/, ([, c, v], { theme }) => ({
|
|
309
|
+
[`grid-${rowCol(c)}`]: theme[`grid${rowColTheme(c)}`]?.[v] ?? handler.bracket.cssvar.auto(v)
|
|
310
|
+
})],
|
|
305
311
|
[/^(?:grid-)?(row|col)-span-(.+)$/, ([, c, s]) => {
|
|
306
312
|
if (s === "full")
|
|
307
313
|
return { [`grid-${rowCol(c)}`]: "1/-1" };
|
|
@@ -311,10 +317,12 @@ const grids = [
|
|
|
311
317
|
}],
|
|
312
318
|
[/^(?:grid-)?(row|col)-start-(.+)$/, ([, c, v]) => ({ [`grid-${rowCol(c)}-start`]: handler.bracket.cssvar(v) ?? v })],
|
|
313
319
|
[/^(?:grid-)?(row|col)-end-(.+)$/, ([, c, v]) => ({ [`grid-${rowCol(c)}-end`]: handler.bracket.cssvar(v) ?? v })],
|
|
314
|
-
[/^(?:grid-)?auto-(rows|cols)-(.+)$/, ([, c, v], { theme }) => ({ [`grid-auto-${rowCol(c)}`]: autoDirection(
|
|
320
|
+
[/^(?:grid-)?auto-(rows|cols)-(.+)$/, ([, c, v], { theme }) => ({ [`grid-auto-${rowCol(c)}`]: autoDirection(c, theme, v) })],
|
|
315
321
|
[/^(?:grid-auto-flow|auto-flow|grid-flow)-(.+)$/, ([, v]) => ({ "grid-auto-flow": handler.bracket.cssvar(v) })],
|
|
316
322
|
[/^(?:grid-auto-flow|auto-flow|grid-flow)-((?:row|col)(?:-dense)?)$/, ([, v]) => ({ "grid-auto-flow": rowCol(v).replace("-", " ") })],
|
|
317
|
-
[/^grid-(rows|cols)-(.+)$/, ([, c, v]) => ({
|
|
323
|
+
[/^grid-(rows|cols)-(.+)$/, ([, c, v], { theme }) => ({
|
|
324
|
+
[`grid-template-${rowCol(c)}`]: theme[`gridTemplate${rowColTheme(c)}`]?.[v] ?? handler.bracket.cssvar(v)
|
|
325
|
+
})],
|
|
318
326
|
[/^grid-(rows|cols)-minmax-([\w.-]+)$/, ([, c, d]) => ({ [`grid-template-${rowCol(c)}`]: `repeat(auto-fill,minmax(${d},1fr))` })],
|
|
319
327
|
[/^grid-(rows|cols)-(\d+)$/, ([, c, d]) => ({ [`grid-template-${rowCol(c)}`]: `repeat(${d},minmax(0,1fr))` })],
|
|
320
328
|
["grid-rows-none", { "grid-template-rows": "none" }],
|
|
@@ -397,21 +405,21 @@ const placements = [
|
|
|
397
405
|
["place-self-center", { "place-self": "center" }],
|
|
398
406
|
["place-self-stretch", { "place-self": "stretch" }]
|
|
399
407
|
];
|
|
400
|
-
function handleInsetValue(v) {
|
|
401
|
-
return handler.bracket.cssvar.auto.fraction.rem(v);
|
|
408
|
+
function handleInsetValue(v, { theme }) {
|
|
409
|
+
return theme.spacing?.[v] ?? handler.bracket.cssvar.auto.fraction.rem(v);
|
|
402
410
|
}
|
|
403
|
-
function handleInsetValues([, d, v]) {
|
|
404
|
-
const r = handleInsetValue(v);
|
|
411
|
+
function handleInsetValues([, d, v], ctx) {
|
|
412
|
+
const r = handleInsetValue(v, ctx);
|
|
405
413
|
if (r != null && d in insetMap)
|
|
406
414
|
return insetMap[d].map((i) => [i.slice(1), r]);
|
|
407
415
|
}
|
|
408
416
|
const insets = [
|
|
409
|
-
[/^(?:position-|pos-)?inset-(.+)$/, ([, v]) => ({ inset: handleInsetValue(v) })],
|
|
417
|
+
[/^(?:position-|pos-)?inset-(.+)$/, ([, v], ctx) => ({ inset: handleInsetValue(v, ctx) })],
|
|
410
418
|
[/^(?:position-|pos-)?inset-([xy])-(.+)$/, handleInsetValues],
|
|
411
419
|
[/^(?:position-|pos-)?inset-([rltbse])-(.+)$/, handleInsetValues],
|
|
412
420
|
[/^(?:position-|pos-)?inset-(block|inline)-(.+)$/, handleInsetValues],
|
|
413
421
|
[/^(?:position-|pos-)?inset-([bi][se])-(.+)$/, handleInsetValues],
|
|
414
|
-
[/^(?:position-|pos-)?(top|left|right|bottom)-(.+)$/, ([, d, v]) => ({ [d]: handleInsetValue(v) })]
|
|
422
|
+
[/^(?:position-|pos-)?(top|left|right|bottom)-(.+)$/, ([, d, v], ctx) => ({ [d]: handleInsetValue(v, ctx) })]
|
|
415
423
|
];
|
|
416
424
|
const floats = [
|
|
417
425
|
["float-left", { float: "left" }],
|
|
@@ -507,45 +515,19 @@ const fontSmoothings = [
|
|
|
507
515
|
}]
|
|
508
516
|
];
|
|
509
517
|
|
|
510
|
-
const shadowBase = {
|
|
511
|
-
[CONTROL_SHORTCUT_NO_MERGE]: "",
|
|
512
|
-
"--un-ring-offset-shadow": "0 0 #0000",
|
|
513
|
-
"--un-ring-shadow": "0 0 #0000",
|
|
514
|
-
"--un-shadow-inset": varEmpty,
|
|
515
|
-
"--un-shadow": "0 0 #0000"
|
|
516
|
-
};
|
|
517
|
-
const boxShadows = [
|
|
518
|
-
[/^shadow(?:-(.+))?$/, ([, d], { theme }) => {
|
|
519
|
-
const v = theme.boxShadow?.[d || "DEFAULT"];
|
|
520
|
-
if (v) {
|
|
521
|
-
return [
|
|
522
|
-
shadowBase,
|
|
523
|
-
{
|
|
524
|
-
"--un-shadow": colorableShadows(v, "--un-shadow-color").join(","),
|
|
525
|
-
"box-shadow": "var(--un-ring-offset-shadow, 0 0 #0000), var(--un-ring-shadow, 0 0 #0000), var(--un-shadow)"
|
|
526
|
-
}
|
|
527
|
-
];
|
|
528
|
-
}
|
|
529
|
-
}],
|
|
530
|
-
[/^shadow-(.+)$/, colorResolver("--un-shadow-color", "shadow")],
|
|
531
|
-
[/^shadow-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-shadow-opacity": handler.bracket.percent(opacity) })],
|
|
532
|
-
["shadow-inset", { "--un-shadow-inset": "inset" }]
|
|
533
|
-
];
|
|
534
|
-
|
|
535
|
-
const ringBase = {
|
|
536
|
-
...shadowBase,
|
|
537
|
-
"--un-ring-inset": varEmpty,
|
|
538
|
-
"--un-ring-offset-width": "0px",
|
|
539
|
-
"--un-ring-offset-color": "#fff",
|
|
540
|
-
"--un-ring-width": "0px",
|
|
541
|
-
"--un-ring-color": "rgba(147,197,253,0.5)"
|
|
542
|
-
};
|
|
543
518
|
const rings = [
|
|
544
|
-
[/^ring(?:-(.+))?$/, ([, d]) => {
|
|
545
|
-
const value = handler.px(d || "1");
|
|
519
|
+
[/^ring(?:-(.+))?$/, ([, d], { theme }) => {
|
|
520
|
+
const value = theme.ringWidth?.[d || "DEFAULT"] ?? handler.px(d || "1");
|
|
546
521
|
if (value) {
|
|
547
522
|
return [
|
|
548
|
-
|
|
523
|
+
{
|
|
524
|
+
[CONTROL_SHORTCUT_NO_MERGE]: "",
|
|
525
|
+
"--un-ring-inset": varEmpty,
|
|
526
|
+
"--un-ring-offset-width": "0px",
|
|
527
|
+
"--un-ring-offset-color": "#fff",
|
|
528
|
+
"--un-ring-width": "0px",
|
|
529
|
+
"--un-ring-color": "rgba(147,197,253,0.5)"
|
|
530
|
+
},
|
|
549
531
|
{
|
|
550
532
|
"--un-ring-width": value,
|
|
551
533
|
"--un-ring-offset-shadow": "var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color)",
|
|
@@ -555,9 +537,9 @@ const rings = [
|
|
|
555
537
|
];
|
|
556
538
|
}
|
|
557
539
|
}],
|
|
558
|
-
[/^ring-(?:width-|size-)(.+)$/, ([, d]) => ({ "--un-ring-width": handler.bracket.cssvar.px(d) })],
|
|
540
|
+
[/^ring-(?:width-|size-)(.+)$/, ([, d], { theme }) => ({ "--un-ring-width": theme.lineWidth?.[d] ?? handler.bracket.cssvar.px(d) })],
|
|
559
541
|
["ring-offset", { "--un-ring-offset-width": "1px" }],
|
|
560
|
-
[/^ring-offset-(?:width-|size-)?(.+)$/, ([, d]) => ({ "--un-ring-offset-width": handler.bracket.cssvar.px(d) })],
|
|
542
|
+
[/^ring-offset-(?:width-|size-)?(.+)$/, ([, d], { theme }) => ({ "--un-ring-offset-width": theme.lineWidth?.[d] ?? handler.bracket.cssvar.px(d) })],
|
|
561
543
|
[/^ring-(.+)$/, colorResolver("--un-ring-color", "ring")],
|
|
562
544
|
[/^ring-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-ring-opacity": handler.bracket.percent(opacity) })],
|
|
563
545
|
[/^ring-offset-(.+)$/, colorResolver("--un-ring-offset-color", "ring-offset")],
|
|
@@ -565,6 +547,28 @@ const rings = [
|
|
|
565
547
|
["ring-inset", { "--un-ring-inset": "inset" }]
|
|
566
548
|
];
|
|
567
549
|
|
|
550
|
+
const boxShadows = [
|
|
551
|
+
[/^shadow(?:-(.+))?$/, ([, d], { theme }) => {
|
|
552
|
+
const v = theme.boxShadow?.[d || "DEFAULT"];
|
|
553
|
+
if (v) {
|
|
554
|
+
return [
|
|
555
|
+
{
|
|
556
|
+
[CONTROL_SHORTCUT_NO_MERGE]: "",
|
|
557
|
+
"--un-shadow-inset": varEmpty,
|
|
558
|
+
"--un-shadow": "0 0 #0000"
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
"--un-shadow": colorableShadows(v, "--un-shadow-color").join(","),
|
|
562
|
+
"box-shadow": "var(--un-ring-offset-shadow, 0 0 #0000), var(--un-ring-shadow, 0 0 #0000), var(--un-shadow)"
|
|
563
|
+
}
|
|
564
|
+
];
|
|
565
|
+
}
|
|
566
|
+
}],
|
|
567
|
+
[/^shadow-(.+)$/, colorResolver("--un-shadow-color", "shadow")],
|
|
568
|
+
[/^shadow-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-shadow-opacity": handler.bracket.percent(opacity) })],
|
|
569
|
+
["shadow-inset", { "--un-shadow-inset": "inset" }]
|
|
570
|
+
];
|
|
571
|
+
|
|
568
572
|
const sizeMapping = {
|
|
569
573
|
h: "height",
|
|
570
574
|
w: "width",
|
|
@@ -706,8 +710,8 @@ const transforms = [
|
|
|
706
710
|
["transform-cpu", transformCpu],
|
|
707
711
|
["transform-none", { transform: "none" }]
|
|
708
712
|
];
|
|
709
|
-
function handleTranslate([, d, b]) {
|
|
710
|
-
const v = handler.bracket.cssvar.fraction.rem(b);
|
|
713
|
+
function handleTranslate([, d, b], { theme }) {
|
|
714
|
+
const v = theme.spacing?.[b] ?? handler.bracket.cssvar.fraction.rem(b);
|
|
711
715
|
if (v != null) {
|
|
712
716
|
return [
|
|
713
717
|
transformBase,
|
|
@@ -809,7 +813,7 @@ ${constructCSS({ animation: "__un_qm 0.5s ease-in-out alternate infinite" })}`;
|
|
|
809
813
|
|
|
810
814
|
const textDecorations = [
|
|
811
815
|
[/^(?:decoration-)?(underline|overline|line-through)$/, ([, s]) => ({ "text-decoration-line": s })],
|
|
812
|
-
[/^(?:underline|decoration)-(?:size-)?(.+)$/, ([, s]) => ({ "text-decoration-thickness": handler.bracket.cssvar.px(s) })],
|
|
816
|
+
[/^(?:underline|decoration)-(?:size-)?(.+)$/, ([, s], { theme }) => ({ "text-decoration-thickness": theme.lineWidth?.[s] ?? handler.bracket.cssvar.px(s) })],
|
|
813
817
|
[/^(?:underline|decoration)-(auto|from-font)$/, ([, s]) => ({ "text-decoration-thickness": s })],
|
|
814
818
|
[/^(?:underline|decoration)-(.+)$/, (match, ctx) => {
|
|
815
819
|
const result = colorResolver("text-decoration-color", "line")(match, ctx);
|
|
@@ -821,7 +825,7 @@ const textDecorations = [
|
|
|
821
825
|
}
|
|
822
826
|
}],
|
|
823
827
|
[/^(?:underline|decoration)-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-line-opacity": handler.bracket.percent(opacity) })],
|
|
824
|
-
[/^(?:underline|decoration)-offset-(.+)$/, ([, s]) => ({ "text-underline-offset": handler.auto.bracket.cssvar.px(s) })],
|
|
828
|
+
[/^(?:underline|decoration)-offset-(.+)$/, ([, s], { theme }) => ({ "text-underline-offset": theme.lineWidth?.[s] ?? handler.auto.bracket.cssvar.px(s) })],
|
|
825
829
|
[/^(?:underline|decoration)-(solid|double|dotted|dashed|wavy|inherit|initial|revert|unset)$/, ([, d]) => ({ "text-decoration-style": d })],
|
|
826
830
|
["no-underline", { "text-decoration": "none" }],
|
|
827
831
|
["decoration-none", { "text-decoration": "none" }]
|
|
@@ -831,9 +835,9 @@ const svgUtilities = [
|
|
|
831
835
|
[/^fill-(.+)$/, colorResolver("fill", "fill")],
|
|
832
836
|
[/^fill-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-fill-opacity": handler.bracket.percent(opacity) })],
|
|
833
837
|
["fill-none", { fill: "none" }],
|
|
834
|
-
[/^stroke-(?:width-|size-)?(.+)$/, ([, s]) => ({ "stroke-width": handler.bracket.cssvar.fraction.px.number(s) })],
|
|
838
|
+
[/^stroke-(?:width-|size-)?(.+)$/, ([, s], { theme }) => ({ "stroke-width": theme.lineWidth?.[s] ?? handler.bracket.cssvar.fraction.px.number(s) })],
|
|
835
839
|
[/^stroke-dash-(.+)$/, ([, s]) => ({ "stroke-dasharray": handler.bracket.cssvar.number(s) })],
|
|
836
|
-
[/^stroke-offset-(.+)$/, ([, s]) => ({ "stroke-dashoffset": handler.bracket.cssvar.px.numberWithUnit(s) })],
|
|
840
|
+
[/^stroke-offset-(.+)$/, ([, s], { theme }) => ({ "stroke-dashoffset": theme.lineWidth?.[s] ?? handler.bracket.cssvar.px.numberWithUnit(s) })],
|
|
837
841
|
[/^stroke-(.+)$/, colorResolver("stroke", "stroke")],
|
|
838
842
|
[/^stroke-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-stroke-opacity": handler.bracket.percent(opacity) })],
|
|
839
843
|
["stroke-cap-square", { "stroke-linecap": "square" }],
|
|
@@ -904,4 +908,4 @@ const rules = [
|
|
|
904
908
|
questionMark
|
|
905
909
|
].flat(1);
|
|
906
910
|
|
|
907
|
-
export {
|
|
911
|
+
export { cssProperty as $, sizes as A, aspectRatio as B, paddings as C, margins as D, varEmpty as E, displays as F, appearances as G, cursors as H, pointerEvents as I, resizes as J, userSelects as K, whitespaces as L, contents as M, breaks as N, textOverflows as O, textTransforms as P, fontStyles as Q, fontSmoothings as R, svgUtilities as S, transforms as T, transitions as U, fonts as V, tabSizes as W, textIndents as X, textStrokes as Y, textShadows as Z, cssVariables as _, appearance as a, textDecorations as a0, borders as b, opacity as c, textColors as d, bgColors as e, flex as f, gaps as g, grids as h, overflows as i, justifies as j, orders as k, alignments as l, placements as m, insets as n, outline as o, positions as p, floats as q, rules as r, boxSizing as s, textAligns as t, questionMark as u, verticalAligns as v, willChange as w, rings as x, boxShadows as y, zIndexes as z };
|
|
@@ -7,7 +7,7 @@ function hex2rgba(hex = "") {
|
|
|
7
7
|
const color = parseHexColor(hex);
|
|
8
8
|
if (color != null) {
|
|
9
9
|
const { components, alpha } = color;
|
|
10
|
-
if (alpha
|
|
10
|
+
if (alpha == null)
|
|
11
11
|
return components;
|
|
12
12
|
return [...components, alpha];
|
|
13
13
|
}
|
|
@@ -20,7 +20,7 @@ function parseCssColor(str = "") {
|
|
|
20
20
|
const type = casedType.toLowerCase();
|
|
21
21
|
if (components.length === 0)
|
|
22
22
|
return;
|
|
23
|
-
if (["rgba", "hsla"].includes(type) && alpha
|
|
23
|
+
if (["rgba", "hsla"].includes(type) && alpha == null)
|
|
24
24
|
return;
|
|
25
25
|
if (cssColorFunctions.includes(type) && components.length !== 3)
|
|
26
26
|
return;
|
|
@@ -420,13 +420,30 @@ function fraction(str) {
|
|
|
420
420
|
if (!Number.isNaN(num))
|
|
421
421
|
return `${round(num * 100)}%`;
|
|
422
422
|
}
|
|
423
|
-
function
|
|
424
|
-
if (str && str
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
423
|
+
function bracketWithType(str, type) {
|
|
424
|
+
if (str && str.startsWith("[") && str.endsWith("]")) {
|
|
425
|
+
let base;
|
|
426
|
+
const match = str.match(/^\[(color|length):/i);
|
|
427
|
+
if (!match)
|
|
428
|
+
base = str.slice(1, -1);
|
|
429
|
+
else if (type && match[1] === type)
|
|
430
|
+
base = str.slice(match[0].length, -1);
|
|
431
|
+
if (base !== void 0) {
|
|
432
|
+
return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/([^\\])_/g, "$1 ").replace(/calc\((.*)/g, (v) => {
|
|
433
|
+
return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
|
|
434
|
+
});
|
|
435
|
+
}
|
|
428
436
|
}
|
|
429
437
|
}
|
|
438
|
+
function bracket(str) {
|
|
439
|
+
return bracketWithType(str);
|
|
440
|
+
}
|
|
441
|
+
function bracketOfColor(str) {
|
|
442
|
+
return bracketWithType(str, "color");
|
|
443
|
+
}
|
|
444
|
+
function bracketOfLength(str) {
|
|
445
|
+
return bracketWithType(str, "length");
|
|
446
|
+
}
|
|
430
447
|
function cssvar(str) {
|
|
431
448
|
if (str.match(/^\$\S/))
|
|
432
449
|
return `var(--${core.escapeSelector(str.slice(1))})`;
|
|
@@ -471,6 +488,8 @@ const valueHandlers = {
|
|
|
471
488
|
percent: percent,
|
|
472
489
|
fraction: fraction,
|
|
473
490
|
bracket: bracket,
|
|
491
|
+
bracketOfColor: bracketOfColor,
|
|
492
|
+
bracketOfLength: bracketOfLength,
|
|
474
493
|
cssvar: cssvar,
|
|
475
494
|
time: time,
|
|
476
495
|
degree: degree,
|
|
@@ -481,20 +500,27 @@ const valueHandlers = {
|
|
|
481
500
|
const handler = core.createValueHandler(valueHandlers);
|
|
482
501
|
const h = handler;
|
|
483
502
|
|
|
484
|
-
const directionSize = (propertyPrefix) => ([_, direction, size]) => {
|
|
485
|
-
const v = handler.bracket.cssvar.auto.fraction.rem(size);
|
|
486
|
-
if (v
|
|
503
|
+
const directionSize = (propertyPrefix) => ([_, direction, size], { theme }) => {
|
|
504
|
+
const v = theme.spacing?.[size || "DEFAULT"] ?? handler.bracket.cssvar.auto.fraction.rem(size);
|
|
505
|
+
if (v != null)
|
|
487
506
|
return directionMap[direction].map((i) => [`${propertyPrefix}${i}`, v]);
|
|
488
507
|
};
|
|
489
508
|
const getThemeColor = (theme, colors) => theme.colors?.[colors.join("-").replace(/(-[a-z])/g, (n) => n.slice(1).toUpperCase())];
|
|
490
509
|
const parseColor = (body, theme) => {
|
|
491
|
-
const
|
|
510
|
+
const split = body.split(/(?:\/|:)/);
|
|
511
|
+
let main, opacity;
|
|
512
|
+
if (split[0] === "[color") {
|
|
513
|
+
main = split.slice(0, 2).join(":");
|
|
514
|
+
opacity = split[2];
|
|
515
|
+
} else {
|
|
516
|
+
[main, opacity] = split;
|
|
517
|
+
}
|
|
492
518
|
const colors = main.replace(/([a-z])([0-9])/g, "$1-$2").split(/-/g);
|
|
493
519
|
const [name] = colors;
|
|
494
520
|
if (!name)
|
|
495
521
|
return;
|
|
496
522
|
let color;
|
|
497
|
-
const bracket = handler.
|
|
523
|
+
const bracket = handler.bracketOfColor(main);
|
|
498
524
|
const bracketOrMain = bracket || main;
|
|
499
525
|
if (bracketOrMain.startsWith("#"))
|
|
500
526
|
color = bracketOrMain;
|
|
@@ -567,6 +593,9 @@ const colorableShadows = (shadows, colorVar) => {
|
|
|
567
593
|
}
|
|
568
594
|
return colored;
|
|
569
595
|
};
|
|
596
|
+
const hasParseableColor = (color, theme) => {
|
|
597
|
+
return color != null && !!parseColor(color, theme)?.color;
|
|
598
|
+
};
|
|
570
599
|
|
|
571
600
|
exports.colorResolver = colorResolver;
|
|
572
601
|
exports.colorToString = colorToString;
|
|
@@ -577,6 +606,7 @@ exports.directionSize = directionSize;
|
|
|
577
606
|
exports.getComponents = getComponents;
|
|
578
607
|
exports.h = h;
|
|
579
608
|
exports.handler = handler;
|
|
609
|
+
exports.hasParseableColor = hasParseableColor;
|
|
580
610
|
exports.hex2rgba = hex2rgba;
|
|
581
611
|
exports.insetMap = insetMap;
|
|
582
612
|
exports.parseColor = parseColor;
|
|
@@ -5,7 +5,7 @@ function hex2rgba(hex = "") {
|
|
|
5
5
|
const color = parseHexColor(hex);
|
|
6
6
|
if (color != null) {
|
|
7
7
|
const { components, alpha } = color;
|
|
8
|
-
if (alpha
|
|
8
|
+
if (alpha == null)
|
|
9
9
|
return components;
|
|
10
10
|
return [...components, alpha];
|
|
11
11
|
}
|
|
@@ -18,7 +18,7 @@ function parseCssColor(str = "") {
|
|
|
18
18
|
const type = casedType.toLowerCase();
|
|
19
19
|
if (components.length === 0)
|
|
20
20
|
return;
|
|
21
|
-
if (["rgba", "hsla"].includes(type) && alpha
|
|
21
|
+
if (["rgba", "hsla"].includes(type) && alpha == null)
|
|
22
22
|
return;
|
|
23
23
|
if (cssColorFunctions.includes(type) && components.length !== 3)
|
|
24
24
|
return;
|
|
@@ -418,13 +418,30 @@ function fraction(str) {
|
|
|
418
418
|
if (!Number.isNaN(num))
|
|
419
419
|
return `${round(num * 100)}%`;
|
|
420
420
|
}
|
|
421
|
-
function
|
|
422
|
-
if (str && str
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
421
|
+
function bracketWithType(str, type) {
|
|
422
|
+
if (str && str.startsWith("[") && str.endsWith("]")) {
|
|
423
|
+
let base;
|
|
424
|
+
const match = str.match(/^\[(color|length):/i);
|
|
425
|
+
if (!match)
|
|
426
|
+
base = str.slice(1, -1);
|
|
427
|
+
else if (type && match[1] === type)
|
|
428
|
+
base = str.slice(match[0].length, -1);
|
|
429
|
+
if (base !== void 0) {
|
|
430
|
+
return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/([^\\])_/g, "$1 ").replace(/calc\((.*)/g, (v) => {
|
|
431
|
+
return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
|
|
432
|
+
});
|
|
433
|
+
}
|
|
426
434
|
}
|
|
427
435
|
}
|
|
436
|
+
function bracket(str) {
|
|
437
|
+
return bracketWithType(str);
|
|
438
|
+
}
|
|
439
|
+
function bracketOfColor(str) {
|
|
440
|
+
return bracketWithType(str, "color");
|
|
441
|
+
}
|
|
442
|
+
function bracketOfLength(str) {
|
|
443
|
+
return bracketWithType(str, "length");
|
|
444
|
+
}
|
|
428
445
|
function cssvar(str) {
|
|
429
446
|
if (str.match(/^\$\S/))
|
|
430
447
|
return `var(--${escapeSelector(str.slice(1))})`;
|
|
@@ -469,6 +486,8 @@ const valueHandlers = {
|
|
|
469
486
|
percent: percent,
|
|
470
487
|
fraction: fraction,
|
|
471
488
|
bracket: bracket,
|
|
489
|
+
bracketOfColor: bracketOfColor,
|
|
490
|
+
bracketOfLength: bracketOfLength,
|
|
472
491
|
cssvar: cssvar,
|
|
473
492
|
time: time,
|
|
474
493
|
degree: degree,
|
|
@@ -479,20 +498,27 @@ const valueHandlers = {
|
|
|
479
498
|
const handler = createValueHandler(valueHandlers);
|
|
480
499
|
const h = handler;
|
|
481
500
|
|
|
482
|
-
const directionSize = (propertyPrefix) => ([_, direction, size]) => {
|
|
483
|
-
const v = handler.bracket.cssvar.auto.fraction.rem(size);
|
|
484
|
-
if (v
|
|
501
|
+
const directionSize = (propertyPrefix) => ([_, direction, size], { theme }) => {
|
|
502
|
+
const v = theme.spacing?.[size || "DEFAULT"] ?? handler.bracket.cssvar.auto.fraction.rem(size);
|
|
503
|
+
if (v != null)
|
|
485
504
|
return directionMap[direction].map((i) => [`${propertyPrefix}${i}`, v]);
|
|
486
505
|
};
|
|
487
506
|
const getThemeColor = (theme, colors) => theme.colors?.[colors.join("-").replace(/(-[a-z])/g, (n) => n.slice(1).toUpperCase())];
|
|
488
507
|
const parseColor = (body, theme) => {
|
|
489
|
-
const
|
|
508
|
+
const split = body.split(/(?:\/|:)/);
|
|
509
|
+
let main, opacity;
|
|
510
|
+
if (split[0] === "[color") {
|
|
511
|
+
main = split.slice(0, 2).join(":");
|
|
512
|
+
opacity = split[2];
|
|
513
|
+
} else {
|
|
514
|
+
[main, opacity] = split;
|
|
515
|
+
}
|
|
490
516
|
const colors = main.replace(/([a-z])([0-9])/g, "$1-$2").split(/-/g);
|
|
491
517
|
const [name] = colors;
|
|
492
518
|
if (!name)
|
|
493
519
|
return;
|
|
494
520
|
let color;
|
|
495
|
-
const bracket = handler.
|
|
521
|
+
const bracket = handler.bracketOfColor(main);
|
|
496
522
|
const bracketOrMain = bracket || main;
|
|
497
523
|
if (bracketOrMain.startsWith("#"))
|
|
498
524
|
color = bracketOrMain;
|
|
@@ -565,5 +591,8 @@ const colorableShadows = (shadows, colorVar) => {
|
|
|
565
591
|
}
|
|
566
592
|
return colored;
|
|
567
593
|
};
|
|
594
|
+
const hasParseableColor = (color, theme) => {
|
|
595
|
+
return color != null && !!parseColor(color, theme)?.color;
|
|
596
|
+
};
|
|
568
597
|
|
|
569
|
-
export {
|
|
598
|
+
export { hasParseableColor as a, colorToString as b, colorResolver as c, directionMap as d, cornerMap as e, colorableShadows as f, directionSize as g, handler as h, insetMap as i, positionMap as j, hex2rgba as k, parseCssColor as l, getComponents as m, h as n, 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-ce2fecb8';
|
|
2
|
+
import './types-f7b2c653';
|
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-f7b2c653';
|
|
3
|
+
export { T as Theme, a as ThemeAnimation } from './types-f7b2c653';
|
|
4
|
+
export { t as theme } from './default-e6d1b2e8';
|
|
5
|
+
export { c as colors } from './colors-ce2fecb8';
|
|
6
|
+
export { p as parseColor } from './utilities-820bcff8';
|
|
7
7
|
|
|
8
8
|
interface PresetMiniOptions extends PresetOptions {
|
|
9
9
|
/**
|
package/dist/rules.cjs
CHANGED
|
@@ -44,7 +44,6 @@ exports.questionMark = _default.questionMark;
|
|
|
44
44
|
exports.resizes = _default.resizes;
|
|
45
45
|
exports.rings = _default.rings;
|
|
46
46
|
exports.rules = _default.rules;
|
|
47
|
-
exports.shadowBase = _default.shadowBase;
|
|
48
47
|
exports.sizes = _default.sizes;
|
|
49
48
|
exports.svgUtilities = _default.svgUtilities;
|
|
50
49
|
exports.tabSizes = _default.tabSizes;
|