@unocss/preset-mini 0.35.2 → 0.36.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/README.md +64 -0
- package/dist/chunks/default.cjs +8 -1
- package/dist/chunks/default.mjs +8 -2
- package/dist/chunks/default2.cjs +86 -230
- package/dist/chunks/default2.mjs +12 -155
- package/dist/chunks/default3.cjs +34 -12
- package/dist/chunks/default3.mjs +34 -13
- package/dist/chunks/index.cjs +310 -0
- package/dist/chunks/index.mjs +300 -0
- package/dist/chunks/transform.cjs +129 -0
- package/dist/chunks/transform.mjs +126 -0
- package/dist/chunks/utilities.cjs +6 -297
- package/dist/chunks/utilities.mjs +3 -286
- package/dist/{colors-ce2fecb8.d.ts → colors-5590b862.d.ts} +1 -1
- package/dist/colors.d.ts +2 -2
- package/dist/{default-e6d1b2e8.d.ts → default-ee82f36d.d.ts} +1 -1
- package/dist/index.cjs +16 -2
- package/dist/index.d.ts +9 -7
- package/dist/index.mjs +16 -3
- package/dist/rules.cjs +5 -2
- package/dist/rules.d.ts +17 -2
- package/dist/rules.mjs +4 -2
- package/dist/theme.cjs +4 -0
- package/dist/theme.d.ts +21 -5
- package/dist/theme.mjs +4 -1
- package/dist/{types-f7b2c653.d.ts → types-0f7ef446.d.ts} +2 -0
- package/dist/{utilities-e7a7f845.d.ts → utilities-a77178bb.d.ts} +1 -1
- package/dist/utils.cjs +10 -8
- package/dist/utils.d.ts +9 -5
- package/dist/utils.mjs +2 -1
- package/dist/variants.cjs +3 -1
- package/dist/variants.d.ts +7 -6
- package/dist/variants.mjs +2 -1
- package/package.json +2 -2
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index.cjs');
|
|
4
|
+
|
|
5
|
+
const transformCpu = [
|
|
6
|
+
"translateX(var(--un-translate-x))",
|
|
7
|
+
"translateY(var(--un-translate-y))",
|
|
8
|
+
"translateZ(var(--un-translate-z))",
|
|
9
|
+
"rotate(var(--un-rotate))",
|
|
10
|
+
"rotateX(var(--un-rotate-x))",
|
|
11
|
+
"rotateY(var(--un-rotate-y))",
|
|
12
|
+
"rotateZ(var(--un-rotate-z))",
|
|
13
|
+
"skewX(var(--un-skew-x))",
|
|
14
|
+
"skewY(var(--un-skew-y))",
|
|
15
|
+
"scaleX(var(--un-scale-x))",
|
|
16
|
+
"scaleY(var(--un-scale-y))",
|
|
17
|
+
"scaleZ(var(--un-scale-z))"
|
|
18
|
+
].join(" ");
|
|
19
|
+
const transformGpu = [
|
|
20
|
+
"translate3d(var(--un-translate-x), var(--un-translate-y), var(--un-translate-z))",
|
|
21
|
+
"rotate(var(--un-rotate))",
|
|
22
|
+
"rotateX(var(--un-rotate-x))",
|
|
23
|
+
"rotateY(var(--un-rotate-y))",
|
|
24
|
+
"rotateZ(var(--un-rotate-z))",
|
|
25
|
+
"skewX(var(--un-skew-x))",
|
|
26
|
+
"skewY(var(--un-skew-y))",
|
|
27
|
+
"scaleX(var(--un-scale-x))",
|
|
28
|
+
"scaleY(var(--un-scale-y))",
|
|
29
|
+
"scaleZ(var(--un-scale-z))"
|
|
30
|
+
].join(" ");
|
|
31
|
+
const transformBase = {
|
|
32
|
+
"--un-rotate": 0,
|
|
33
|
+
"--un-rotate-x": 0,
|
|
34
|
+
"--un-rotate-y": 0,
|
|
35
|
+
"--un-rotate-z": 0,
|
|
36
|
+
"--un-scale-x": 1,
|
|
37
|
+
"--un-scale-y": 1,
|
|
38
|
+
"--un-scale-z": 1,
|
|
39
|
+
"--un-skew-x": 0,
|
|
40
|
+
"--un-skew-y": 0,
|
|
41
|
+
"--un-translate-x": 0,
|
|
42
|
+
"--un-translate-y": 0,
|
|
43
|
+
"--un-translate-z": 0,
|
|
44
|
+
"--un-transform": transformCpu
|
|
45
|
+
};
|
|
46
|
+
const transforms = [
|
|
47
|
+
[/^(?:transform-)?origin-(.+)$/, ([, s]) => ({ "transform-origin": index.positionMap[s] ?? index.handler.bracket.cssvar(s) }), { autocomplete: [`transform-origin-(${Object.keys(index.positionMap).join("|")})`, `origin-(${Object.keys(index.positionMap).join("|")})`] }],
|
|
48
|
+
[/^(?:transform-)?perspect(?:ive)?-(.+)$/, ([, s]) => {
|
|
49
|
+
const v = index.handler.bracket.cssvar.px.numberWithUnit(s);
|
|
50
|
+
if (v != null) {
|
|
51
|
+
return {
|
|
52
|
+
"-webkit-perspective": v,
|
|
53
|
+
"perspective": v
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}],
|
|
57
|
+
[/^(?:transform-)?perspect(?:ive)?-origin-(.+)$/, ([, s]) => {
|
|
58
|
+
const v = index.handler.bracket.cssvar(s) ?? (s.length >= 3 ? index.positionMap[s] : void 0);
|
|
59
|
+
if (v != null) {
|
|
60
|
+
return {
|
|
61
|
+
"-webkit-perspective-origin": v,
|
|
62
|
+
"perspective-origin": v
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}],
|
|
66
|
+
[/^(?:transform-)?translate-()(.+)$/, handleTranslate],
|
|
67
|
+
[/^(?:transform-)?translate-([xyz])-(.+)$/, handleTranslate],
|
|
68
|
+
[/^(?:transform-)?rotate-()(.+)$/, handleRotate],
|
|
69
|
+
[/^(?:transform-)?rotate-([xyz])-(.+)$/, handleRotate],
|
|
70
|
+
[/^(?:transform-)?skew-([xy])-(.+)$/, handleSkew],
|
|
71
|
+
[/^(?:transform-)?scale-()(.+)$/, handleScale],
|
|
72
|
+
[/^(?:transform-)?scale-([xyz])-(.+)$/, handleScale],
|
|
73
|
+
[/^(?:transform-)?preserve-3d$/, () => ({ "transform-style": "preserve-3d" })],
|
|
74
|
+
[/^(?:transform-)?preserve-flat$/, () => ({ "transform-style": "flat" })],
|
|
75
|
+
["transform", { transform: "var(--un-transform)" }],
|
|
76
|
+
["transform-cpu", { transform: "var(--un-transform)" }],
|
|
77
|
+
["transform-gpu", { transform: transformGpu }],
|
|
78
|
+
["transform-none", { transform: "none" }]
|
|
79
|
+
];
|
|
80
|
+
function handleTranslate([, d, b], { theme }) {
|
|
81
|
+
const v = theme.spacing?.[b] ?? index.handler.bracket.cssvar.fraction.rem(b);
|
|
82
|
+
if (v != null) {
|
|
83
|
+
return [
|
|
84
|
+
...index.xyzMap[d].map((i) => [`--un-translate${i}`, v]),
|
|
85
|
+
["transform", "var(--un-transform)"]
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function handleScale([, d, b]) {
|
|
90
|
+
const v = index.handler.bracket.cssvar.fraction.percent(b);
|
|
91
|
+
if (v != null) {
|
|
92
|
+
return [
|
|
93
|
+
...index.xyzMap[d].map((i) => [`--un-scale${i}`, v]),
|
|
94
|
+
["transform", "var(--un-transform)"]
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function handleRotate([, d = "", b]) {
|
|
99
|
+
const v = index.handler.bracket.cssvar.degree(b);
|
|
100
|
+
if (v != null) {
|
|
101
|
+
if (d) {
|
|
102
|
+
return {
|
|
103
|
+
"--un-rotate": 0,
|
|
104
|
+
[`--un-rotate-${d}`]: v,
|
|
105
|
+
"transform": "var(--un-transform)"
|
|
106
|
+
};
|
|
107
|
+
} else {
|
|
108
|
+
return {
|
|
109
|
+
"--un-rotate-x": 0,
|
|
110
|
+
"--un-rotate-y": 0,
|
|
111
|
+
"--un-rotate-z": 0,
|
|
112
|
+
"--un-rotate": v,
|
|
113
|
+
"transform": "var(--un-transform)"
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function handleSkew([, d, b]) {
|
|
119
|
+
const v = index.handler.bracket.cssvar.degree(b);
|
|
120
|
+
if (v != null) {
|
|
121
|
+
return {
|
|
122
|
+
[`--un-skew-${d}`]: v,
|
|
123
|
+
transform: "var(--un-transform)"
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
exports.transformBase = transformBase;
|
|
129
|
+
exports.transforms = transforms;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { p as positionMap, h as handler, x as xyzMap } from './index.mjs';
|
|
2
|
+
|
|
3
|
+
const transformCpu = [
|
|
4
|
+
"translateX(var(--un-translate-x))",
|
|
5
|
+
"translateY(var(--un-translate-y))",
|
|
6
|
+
"translateZ(var(--un-translate-z))",
|
|
7
|
+
"rotate(var(--un-rotate))",
|
|
8
|
+
"rotateX(var(--un-rotate-x))",
|
|
9
|
+
"rotateY(var(--un-rotate-y))",
|
|
10
|
+
"rotateZ(var(--un-rotate-z))",
|
|
11
|
+
"skewX(var(--un-skew-x))",
|
|
12
|
+
"skewY(var(--un-skew-y))",
|
|
13
|
+
"scaleX(var(--un-scale-x))",
|
|
14
|
+
"scaleY(var(--un-scale-y))",
|
|
15
|
+
"scaleZ(var(--un-scale-z))"
|
|
16
|
+
].join(" ");
|
|
17
|
+
const transformGpu = [
|
|
18
|
+
"translate3d(var(--un-translate-x), var(--un-translate-y), var(--un-translate-z))",
|
|
19
|
+
"rotate(var(--un-rotate))",
|
|
20
|
+
"rotateX(var(--un-rotate-x))",
|
|
21
|
+
"rotateY(var(--un-rotate-y))",
|
|
22
|
+
"rotateZ(var(--un-rotate-z))",
|
|
23
|
+
"skewX(var(--un-skew-x))",
|
|
24
|
+
"skewY(var(--un-skew-y))",
|
|
25
|
+
"scaleX(var(--un-scale-x))",
|
|
26
|
+
"scaleY(var(--un-scale-y))",
|
|
27
|
+
"scaleZ(var(--un-scale-z))"
|
|
28
|
+
].join(" ");
|
|
29
|
+
const transformBase = {
|
|
30
|
+
"--un-rotate": 0,
|
|
31
|
+
"--un-rotate-x": 0,
|
|
32
|
+
"--un-rotate-y": 0,
|
|
33
|
+
"--un-rotate-z": 0,
|
|
34
|
+
"--un-scale-x": 1,
|
|
35
|
+
"--un-scale-y": 1,
|
|
36
|
+
"--un-scale-z": 1,
|
|
37
|
+
"--un-skew-x": 0,
|
|
38
|
+
"--un-skew-y": 0,
|
|
39
|
+
"--un-translate-x": 0,
|
|
40
|
+
"--un-translate-y": 0,
|
|
41
|
+
"--un-translate-z": 0,
|
|
42
|
+
"--un-transform": transformCpu
|
|
43
|
+
};
|
|
44
|
+
const transforms = [
|
|
45
|
+
[/^(?:transform-)?origin-(.+)$/, ([, s]) => ({ "transform-origin": positionMap[s] ?? handler.bracket.cssvar(s) }), { autocomplete: [`transform-origin-(${Object.keys(positionMap).join("|")})`, `origin-(${Object.keys(positionMap).join("|")})`] }],
|
|
46
|
+
[/^(?:transform-)?perspect(?:ive)?-(.+)$/, ([, s]) => {
|
|
47
|
+
const v = handler.bracket.cssvar.px.numberWithUnit(s);
|
|
48
|
+
if (v != null) {
|
|
49
|
+
return {
|
|
50
|
+
"-webkit-perspective": v,
|
|
51
|
+
"perspective": v
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}],
|
|
55
|
+
[/^(?:transform-)?perspect(?:ive)?-origin-(.+)$/, ([, s]) => {
|
|
56
|
+
const v = handler.bracket.cssvar(s) ?? (s.length >= 3 ? positionMap[s] : void 0);
|
|
57
|
+
if (v != null) {
|
|
58
|
+
return {
|
|
59
|
+
"-webkit-perspective-origin": v,
|
|
60
|
+
"perspective-origin": v
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}],
|
|
64
|
+
[/^(?:transform-)?translate-()(.+)$/, handleTranslate],
|
|
65
|
+
[/^(?:transform-)?translate-([xyz])-(.+)$/, handleTranslate],
|
|
66
|
+
[/^(?:transform-)?rotate-()(.+)$/, handleRotate],
|
|
67
|
+
[/^(?:transform-)?rotate-([xyz])-(.+)$/, handleRotate],
|
|
68
|
+
[/^(?:transform-)?skew-([xy])-(.+)$/, handleSkew],
|
|
69
|
+
[/^(?:transform-)?scale-()(.+)$/, handleScale],
|
|
70
|
+
[/^(?:transform-)?scale-([xyz])-(.+)$/, handleScale],
|
|
71
|
+
[/^(?:transform-)?preserve-3d$/, () => ({ "transform-style": "preserve-3d" })],
|
|
72
|
+
[/^(?:transform-)?preserve-flat$/, () => ({ "transform-style": "flat" })],
|
|
73
|
+
["transform", { transform: "var(--un-transform)" }],
|
|
74
|
+
["transform-cpu", { transform: "var(--un-transform)" }],
|
|
75
|
+
["transform-gpu", { transform: transformGpu }],
|
|
76
|
+
["transform-none", { transform: "none" }]
|
|
77
|
+
];
|
|
78
|
+
function handleTranslate([, d, b], { theme }) {
|
|
79
|
+
const v = theme.spacing?.[b] ?? handler.bracket.cssvar.fraction.rem(b);
|
|
80
|
+
if (v != null) {
|
|
81
|
+
return [
|
|
82
|
+
...xyzMap[d].map((i) => [`--un-translate${i}`, v]),
|
|
83
|
+
["transform", "var(--un-transform)"]
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function handleScale([, d, b]) {
|
|
88
|
+
const v = handler.bracket.cssvar.fraction.percent(b);
|
|
89
|
+
if (v != null) {
|
|
90
|
+
return [
|
|
91
|
+
...xyzMap[d].map((i) => [`--un-scale${i}`, v]),
|
|
92
|
+
["transform", "var(--un-transform)"]
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function handleRotate([, d = "", b]) {
|
|
97
|
+
const v = handler.bracket.cssvar.degree(b);
|
|
98
|
+
if (v != null) {
|
|
99
|
+
if (d) {
|
|
100
|
+
return {
|
|
101
|
+
"--un-rotate": 0,
|
|
102
|
+
[`--un-rotate-${d}`]: v,
|
|
103
|
+
"transform": "var(--un-transform)"
|
|
104
|
+
};
|
|
105
|
+
} else {
|
|
106
|
+
return {
|
|
107
|
+
"--un-rotate-x": 0,
|
|
108
|
+
"--un-rotate-y": 0,
|
|
109
|
+
"--un-rotate-z": 0,
|
|
110
|
+
"--un-rotate": v,
|
|
111
|
+
"transform": "var(--un-transform)"
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function handleSkew([, d, b]) {
|
|
117
|
+
const v = handler.bracket.cssvar.degree(b);
|
|
118
|
+
if (v != null) {
|
|
119
|
+
return {
|
|
120
|
+
[`--un-skew-${d}`]: v,
|
|
121
|
+
transform: "var(--un-transform)"
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { transforms as a, transformBase as t };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const core = require('@unocss/core');
|
|
4
|
+
const index = require('./index.cjs');
|
|
4
5
|
|
|
5
6
|
const cssColorFunctions = ["hsl", "hsla", "hwb", "lab", "lch", "oklab", "oklch", "rgb", "rgba"];
|
|
6
7
|
function hex2rgba(hex = "") {
|
|
@@ -221,295 +222,11 @@ function getComponents(str, separator, limit) {
|
|
|
221
222
|
return components;
|
|
222
223
|
}
|
|
223
224
|
|
|
224
|
-
const directionMap = {
|
|
225
|
-
"l": ["-left"],
|
|
226
|
-
"r": ["-right"],
|
|
227
|
-
"t": ["-top"],
|
|
228
|
-
"b": ["-bottom"],
|
|
229
|
-
"s": ["-inline-start"],
|
|
230
|
-
"e": ["-inline-end"],
|
|
231
|
-
"x": ["-left", "-right"],
|
|
232
|
-
"y": ["-top", "-bottom"],
|
|
233
|
-
"": [""],
|
|
234
|
-
"bs": ["-block-start"],
|
|
235
|
-
"be": ["-block-end"],
|
|
236
|
-
"is": ["-inline-start"],
|
|
237
|
-
"ie": ["-inline-end"],
|
|
238
|
-
"block": ["-block-start", "-block-end"],
|
|
239
|
-
"inline": ["-inline-start", "-inline-end"]
|
|
240
|
-
};
|
|
241
|
-
const insetMap = {
|
|
242
|
-
...directionMap,
|
|
243
|
-
s: ["-inset-inline-start"],
|
|
244
|
-
e: ["-inset-inline-end"],
|
|
245
|
-
bs: ["-inset-block-start"],
|
|
246
|
-
be: ["-inset-block-end"],
|
|
247
|
-
is: ["-inset-inline-start"],
|
|
248
|
-
ie: ["-inset-inline-end"],
|
|
249
|
-
block: ["-inset-block-start", "-inset-block-end"],
|
|
250
|
-
inline: ["-inset-inline-start", "-inset-inline-end"]
|
|
251
|
-
};
|
|
252
|
-
const cornerMap = {
|
|
253
|
-
"l": ["-top-left", "-bottom-left"],
|
|
254
|
-
"r": ["-top-right", "-bottom-right"],
|
|
255
|
-
"t": ["-top-left", "-top-right"],
|
|
256
|
-
"b": ["-bottom-left", "-bottom-right"],
|
|
257
|
-
"tl": ["-top-left"],
|
|
258
|
-
"lt": ["-top-left"],
|
|
259
|
-
"tr": ["-top-right"],
|
|
260
|
-
"rt": ["-top-right"],
|
|
261
|
-
"bl": ["-bottom-left"],
|
|
262
|
-
"lb": ["-bottom-left"],
|
|
263
|
-
"br": ["-bottom-right"],
|
|
264
|
-
"rb": ["-bottom-right"],
|
|
265
|
-
"": [""],
|
|
266
|
-
"bs": ["-start-start", "-start-end"],
|
|
267
|
-
"be": ["-end-start", "-end-end"],
|
|
268
|
-
"is": ["-end-start", "-start-start"],
|
|
269
|
-
"ie": ["-start-end", "-end-end"],
|
|
270
|
-
"bs-is": ["-start-start"],
|
|
271
|
-
"is-bs": ["-start-start"],
|
|
272
|
-
"bs-ie": ["-start-end"],
|
|
273
|
-
"ie-bs": ["-start-end"],
|
|
274
|
-
"be-is": ["-end-start"],
|
|
275
|
-
"is-be": ["-end-start"],
|
|
276
|
-
"be-ie": ["-end-end"],
|
|
277
|
-
"ie-be": ["-end-end"]
|
|
278
|
-
};
|
|
279
|
-
const xyzMap = {
|
|
280
|
-
"x": ["-x"],
|
|
281
|
-
"y": ["-y"],
|
|
282
|
-
"z": ["-z"],
|
|
283
|
-
"": ["-x", "-y"]
|
|
284
|
-
};
|
|
285
|
-
const basePositionMap = [
|
|
286
|
-
"top",
|
|
287
|
-
"top center",
|
|
288
|
-
"top left",
|
|
289
|
-
"top right",
|
|
290
|
-
"bottom",
|
|
291
|
-
"bottom center",
|
|
292
|
-
"bottom left",
|
|
293
|
-
"bottom right",
|
|
294
|
-
"left",
|
|
295
|
-
"left center",
|
|
296
|
-
"left top",
|
|
297
|
-
"left bottom",
|
|
298
|
-
"right",
|
|
299
|
-
"right center",
|
|
300
|
-
"right top",
|
|
301
|
-
"right bottom",
|
|
302
|
-
"center",
|
|
303
|
-
"center top",
|
|
304
|
-
"center bottom",
|
|
305
|
-
"center left",
|
|
306
|
-
"center right",
|
|
307
|
-
"center center"
|
|
308
|
-
];
|
|
309
|
-
const positionMap = Object.assign({}, ...basePositionMap.map((p) => ({ [p.replace(/ /, "-")]: p })), ...basePositionMap.map((p) => ({ [p.replace(/\b(\w)\w+/g, "$1").replace(/ /, "")]: p })));
|
|
310
|
-
|
|
311
|
-
const cssProps = [
|
|
312
|
-
"color",
|
|
313
|
-
"border-color",
|
|
314
|
-
"background-color",
|
|
315
|
-
"flex-grow",
|
|
316
|
-
"flex",
|
|
317
|
-
"flex-shrink",
|
|
318
|
-
"caret-color",
|
|
319
|
-
"font",
|
|
320
|
-
"gap",
|
|
321
|
-
"opacity",
|
|
322
|
-
"visibility",
|
|
323
|
-
"z-index",
|
|
324
|
-
"font-weight",
|
|
325
|
-
"zoom",
|
|
326
|
-
"text-shadow",
|
|
327
|
-
"transform",
|
|
328
|
-
"box-shadow",
|
|
329
|
-
"backround-position",
|
|
330
|
-
"left",
|
|
331
|
-
"right",
|
|
332
|
-
"top",
|
|
333
|
-
"bottom",
|
|
334
|
-
"object-position",
|
|
335
|
-
"max-height",
|
|
336
|
-
"min-height",
|
|
337
|
-
"max-width",
|
|
338
|
-
"min-width",
|
|
339
|
-
"height",
|
|
340
|
-
"width",
|
|
341
|
-
"border-width",
|
|
342
|
-
"margin",
|
|
343
|
-
"padding",
|
|
344
|
-
"outline-width",
|
|
345
|
-
"outline-offset",
|
|
346
|
-
"font-size",
|
|
347
|
-
"line-height",
|
|
348
|
-
"text-indent",
|
|
349
|
-
"vertical-align",
|
|
350
|
-
"border-spacing",
|
|
351
|
-
"letter-spacing",
|
|
352
|
-
"word-spacing",
|
|
353
|
-
"stroke",
|
|
354
|
-
"filter",
|
|
355
|
-
"backdrop-filter",
|
|
356
|
-
"fill",
|
|
357
|
-
"mask",
|
|
358
|
-
"mask-size",
|
|
359
|
-
"mask-border",
|
|
360
|
-
"clip-path",
|
|
361
|
-
"clip",
|
|
362
|
-
"border-radius"
|
|
363
|
-
];
|
|
364
|
-
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax|rpx)?$/i;
|
|
365
|
-
const numberRE = /^(-?[0-9.]+)$/i;
|
|
366
|
-
const unitOnlyRE = /^(px)$/i;
|
|
367
|
-
function round(n) {
|
|
368
|
-
return n.toFixed(10).replace(/\.0+$/, "").replace(/(\.\d+?)0+$/, "$1");
|
|
369
|
-
}
|
|
370
|
-
function numberWithUnit(str) {
|
|
371
|
-
const match = str.match(numberWithUnitRE);
|
|
372
|
-
if (!match)
|
|
373
|
-
return;
|
|
374
|
-
const [, n, unit] = match;
|
|
375
|
-
const num = parseFloat(n);
|
|
376
|
-
if (unit && !Number.isNaN(num))
|
|
377
|
-
return `${round(num)}${unit}`;
|
|
378
|
-
}
|
|
379
|
-
function auto(str) {
|
|
380
|
-
if (str === "auto" || str === "a")
|
|
381
|
-
return "auto";
|
|
382
|
-
}
|
|
383
|
-
function rem(str) {
|
|
384
|
-
if (str.match(unitOnlyRE))
|
|
385
|
-
return `1${str}`;
|
|
386
|
-
const match = str.match(numberWithUnitRE);
|
|
387
|
-
if (!match)
|
|
388
|
-
return;
|
|
389
|
-
const [, n, unit] = match;
|
|
390
|
-
const num = parseFloat(n);
|
|
391
|
-
if (!Number.isNaN(num))
|
|
392
|
-
return unit ? `${round(num)}${unit}` : `${round(num / 4)}rem`;
|
|
393
|
-
}
|
|
394
|
-
function px(str) {
|
|
395
|
-
if (str.match(unitOnlyRE))
|
|
396
|
-
return `1${str}`;
|
|
397
|
-
const match = str.match(numberWithUnitRE);
|
|
398
|
-
if (!match)
|
|
399
|
-
return;
|
|
400
|
-
const [, n, unit] = match;
|
|
401
|
-
const num = parseFloat(n);
|
|
402
|
-
if (!Number.isNaN(num))
|
|
403
|
-
return unit ? `${round(num)}${unit}` : `${round(num)}px`;
|
|
404
|
-
}
|
|
405
|
-
function number(str) {
|
|
406
|
-
if (!numberRE.test(str))
|
|
407
|
-
return;
|
|
408
|
-
const num = parseFloat(str);
|
|
409
|
-
if (!Number.isNaN(num))
|
|
410
|
-
return round(num);
|
|
411
|
-
}
|
|
412
|
-
function percent(str) {
|
|
413
|
-
if (str.endsWith("%"))
|
|
414
|
-
str = str.slice(0, -1);
|
|
415
|
-
const num = parseFloat(str);
|
|
416
|
-
if (!Number.isNaN(num))
|
|
417
|
-
return `${round(num / 100)}`;
|
|
418
|
-
}
|
|
419
|
-
function fraction(str) {
|
|
420
|
-
if (str === "full")
|
|
421
|
-
return "100%";
|
|
422
|
-
const [left, right] = str.split("/");
|
|
423
|
-
const num = parseFloat(left) / parseFloat(right);
|
|
424
|
-
if (!Number.isNaN(num))
|
|
425
|
-
return `${round(num * 100)}%`;
|
|
426
|
-
}
|
|
427
|
-
function bracketWithType(str, type) {
|
|
428
|
-
if (str && str.startsWith("[") && str.endsWith("]")) {
|
|
429
|
-
let base;
|
|
430
|
-
const match = str.match(/^\[(color|length|position):/i);
|
|
431
|
-
if (!match)
|
|
432
|
-
base = str.slice(1, -1);
|
|
433
|
-
else if (type && match[1] === type)
|
|
434
|
-
base = str.slice(match[0].length, -1);
|
|
435
|
-
if (base !== void 0) {
|
|
436
|
-
return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/([^\\])_/g, "$1 ").replace(/calc\((.*)/g, (v) => {
|
|
437
|
-
return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
function bracket(str) {
|
|
443
|
-
return bracketWithType(str);
|
|
444
|
-
}
|
|
445
|
-
function bracketOfColor(str) {
|
|
446
|
-
return bracketWithType(str, "color");
|
|
447
|
-
}
|
|
448
|
-
function bracketOfLength(str) {
|
|
449
|
-
return bracketWithType(str, "length");
|
|
450
|
-
}
|
|
451
|
-
function bracketOfPosition(str) {
|
|
452
|
-
return bracketWithType(str, "position");
|
|
453
|
-
}
|
|
454
|
-
function cssvar(str) {
|
|
455
|
-
if (str.match(/^\$\S/))
|
|
456
|
-
return `var(--${core.escapeSelector(str.slice(1))})`;
|
|
457
|
-
}
|
|
458
|
-
function time(str) {
|
|
459
|
-
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
460
|
-
if (!match)
|
|
461
|
-
return;
|
|
462
|
-
const [, n, unit] = match;
|
|
463
|
-
const num = parseFloat(n);
|
|
464
|
-
if (!Number.isNaN(num))
|
|
465
|
-
return unit ? `${round(num)}${unit}` : `${round(num)}ms`;
|
|
466
|
-
}
|
|
467
|
-
function degree(str) {
|
|
468
|
-
const match = str.match(/^(-?[0-9.]+)(deg|rad|grad|turn)?$/i);
|
|
469
|
-
if (!match)
|
|
470
|
-
return;
|
|
471
|
-
const [, n, unit] = match;
|
|
472
|
-
const num = parseFloat(n);
|
|
473
|
-
if (!Number.isNaN(num))
|
|
474
|
-
return unit ? `${round(num)}${unit}` : `${round(num)}deg`;
|
|
475
|
-
}
|
|
476
|
-
function global(str) {
|
|
477
|
-
if (["inherit", "initial", "revert", "unset"].includes(str))
|
|
478
|
-
return str;
|
|
479
|
-
}
|
|
480
|
-
function properties(str) {
|
|
481
|
-
if (str.split(",").every((prop) => cssProps.includes(prop)))
|
|
482
|
-
return str;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
const valueHandlers = {
|
|
486
|
-
__proto__: null,
|
|
487
|
-
numberWithUnit: numberWithUnit,
|
|
488
|
-
auto: auto,
|
|
489
|
-
rem: rem,
|
|
490
|
-
px: px,
|
|
491
|
-
number: number,
|
|
492
|
-
percent: percent,
|
|
493
|
-
fraction: fraction,
|
|
494
|
-
bracket: bracket,
|
|
495
|
-
bracketOfColor: bracketOfColor,
|
|
496
|
-
bracketOfLength: bracketOfLength,
|
|
497
|
-
bracketOfPosition: bracketOfPosition,
|
|
498
|
-
cssvar: cssvar,
|
|
499
|
-
time: time,
|
|
500
|
-
degree: degree,
|
|
501
|
-
global: global,
|
|
502
|
-
properties: properties
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
const handler = core.createValueHandler(valueHandlers);
|
|
506
|
-
const h = handler;
|
|
507
|
-
|
|
508
225
|
const CONTROL_MINI_NO_NEGATIVE = "$$mini-no-negative";
|
|
509
226
|
const directionSize = (propertyPrefix) => ([_, direction, size], { theme }) => {
|
|
510
|
-
const v = theme.spacing?.[size || "DEFAULT"] ?? handler.bracket.cssvar.auto.fraction.rem(size);
|
|
227
|
+
const v = theme.spacing?.[size || "DEFAULT"] ?? index.handler.bracket.cssvar.auto.fraction.rem(size);
|
|
511
228
|
if (v != null)
|
|
512
|
-
return directionMap[direction].map((i) => [`${propertyPrefix}${i}`, v]);
|
|
229
|
+
return index.directionMap[direction].map((i) => [`${propertyPrefix}${i}`, v]);
|
|
513
230
|
};
|
|
514
231
|
const getThemeColor = (theme, colors) => theme.colors?.[colors.join("-").replace(/(-[a-z])/g, (n) => n.slice(1).toUpperCase())];
|
|
515
232
|
const parseColor = (body, theme) => {
|
|
@@ -526,14 +243,14 @@ const parseColor = (body, theme) => {
|
|
|
526
243
|
if (!name)
|
|
527
244
|
return;
|
|
528
245
|
let color;
|
|
529
|
-
const bracket = handler.bracketOfColor(main);
|
|
246
|
+
const bracket = index.handler.bracketOfColor(main);
|
|
530
247
|
const bracketOrMain = bracket || main;
|
|
531
248
|
if (bracketOrMain.startsWith("#"))
|
|
532
249
|
color = bracketOrMain;
|
|
533
250
|
else if (bracketOrMain.startsWith("hex-"))
|
|
534
251
|
color = `#${bracketOrMain.slice(4)}`;
|
|
535
252
|
else if (main.startsWith("$"))
|
|
536
|
-
color = handler.cssvar(main);
|
|
253
|
+
color = index.handler.cssvar(main);
|
|
537
254
|
color = color || bracket;
|
|
538
255
|
let no = "DEFAULT";
|
|
539
256
|
if (!color) {
|
|
@@ -560,7 +277,7 @@ const parseColor = (body, theme) => {
|
|
|
560
277
|
no,
|
|
561
278
|
color,
|
|
562
279
|
cssColor: parseCssColor(color),
|
|
563
|
-
alpha: handler.bracket.cssvar.percent(opacity ?? "")
|
|
280
|
+
alpha: index.handler.bracket.cssvar.percent(opacity ?? "")
|
|
564
281
|
};
|
|
565
282
|
};
|
|
566
283
|
const colorResolver = (property, varName) => ([, body], { theme }) => {
|
|
@@ -623,19 +340,11 @@ exports.CONTROL_MINI_NO_NEGATIVE = CONTROL_MINI_NO_NEGATIVE;
|
|
|
623
340
|
exports.colorResolver = colorResolver;
|
|
624
341
|
exports.colorToString = colorToString;
|
|
625
342
|
exports.colorableShadows = colorableShadows;
|
|
626
|
-
exports.cornerMap = cornerMap;
|
|
627
|
-
exports.directionMap = directionMap;
|
|
628
343
|
exports.directionSize = directionSize;
|
|
629
344
|
exports.getComponents = getComponents;
|
|
630
|
-
exports.h = h;
|
|
631
|
-
exports.handler = handler;
|
|
632
345
|
exports.hasParseableColor = hasParseableColor;
|
|
633
346
|
exports.hex2rgba = hex2rgba;
|
|
634
|
-
exports.insetMap = insetMap;
|
|
635
347
|
exports.parseColor = parseColor;
|
|
636
348
|
exports.parseCssColor = parseCssColor;
|
|
637
|
-
exports.positionMap = positionMap;
|
|
638
349
|
exports.resolveBreakpoints = resolveBreakpoints;
|
|
639
350
|
exports.resolveVerticalBreakpoints = resolveVerticalBreakpoints;
|
|
640
|
-
exports.valueHandlers = valueHandlers;
|
|
641
|
-
exports.xyzMap = xyzMap;
|