@unocss/preset-mini 0.35.4 → 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 +83 -229
- package/dist/chunks/default2.mjs +4 -149
- package/dist/chunks/default3.cjs +17 -3
- package/dist/chunks/default3.mjs +17 -4
- 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 -311
- package/dist/chunks/utilities.mjs +3 -299
- 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 -9
- package/dist/utils.d.ts +4 -4
- 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,300 @@
|
|
|
1
|
+
import { escapeSelector, createValueHandler } from '@unocss/core';
|
|
2
|
+
|
|
3
|
+
const directionMap = {
|
|
4
|
+
"l": ["-left"],
|
|
5
|
+
"r": ["-right"],
|
|
6
|
+
"t": ["-top"],
|
|
7
|
+
"b": ["-bottom"],
|
|
8
|
+
"s": ["-inline-start"],
|
|
9
|
+
"e": ["-inline-end"],
|
|
10
|
+
"x": ["-left", "-right"],
|
|
11
|
+
"y": ["-top", "-bottom"],
|
|
12
|
+
"": [""],
|
|
13
|
+
"bs": ["-block-start"],
|
|
14
|
+
"be": ["-block-end"],
|
|
15
|
+
"is": ["-inline-start"],
|
|
16
|
+
"ie": ["-inline-end"],
|
|
17
|
+
"block": ["-block-start", "-block-end"],
|
|
18
|
+
"inline": ["-inline-start", "-inline-end"]
|
|
19
|
+
};
|
|
20
|
+
const insetMap = {
|
|
21
|
+
...directionMap,
|
|
22
|
+
s: ["-inset-inline-start"],
|
|
23
|
+
e: ["-inset-inline-end"],
|
|
24
|
+
bs: ["-inset-block-start"],
|
|
25
|
+
be: ["-inset-block-end"],
|
|
26
|
+
is: ["-inset-inline-start"],
|
|
27
|
+
ie: ["-inset-inline-end"],
|
|
28
|
+
block: ["-inset-block-start", "-inset-block-end"],
|
|
29
|
+
inline: ["-inset-inline-start", "-inset-inline-end"]
|
|
30
|
+
};
|
|
31
|
+
const cornerMap = {
|
|
32
|
+
"l": ["-top-left", "-bottom-left"],
|
|
33
|
+
"r": ["-top-right", "-bottom-right"],
|
|
34
|
+
"t": ["-top-left", "-top-right"],
|
|
35
|
+
"b": ["-bottom-left", "-bottom-right"],
|
|
36
|
+
"tl": ["-top-left"],
|
|
37
|
+
"lt": ["-top-left"],
|
|
38
|
+
"tr": ["-top-right"],
|
|
39
|
+
"rt": ["-top-right"],
|
|
40
|
+
"bl": ["-bottom-left"],
|
|
41
|
+
"lb": ["-bottom-left"],
|
|
42
|
+
"br": ["-bottom-right"],
|
|
43
|
+
"rb": ["-bottom-right"],
|
|
44
|
+
"": [""],
|
|
45
|
+
"bs": ["-start-start", "-start-end"],
|
|
46
|
+
"be": ["-end-start", "-end-end"],
|
|
47
|
+
"is": ["-end-start", "-start-start"],
|
|
48
|
+
"ie": ["-start-end", "-end-end"],
|
|
49
|
+
"bs-is": ["-start-start"],
|
|
50
|
+
"is-bs": ["-start-start"],
|
|
51
|
+
"bs-ie": ["-start-end"],
|
|
52
|
+
"ie-bs": ["-start-end"],
|
|
53
|
+
"be-is": ["-end-start"],
|
|
54
|
+
"is-be": ["-end-start"],
|
|
55
|
+
"be-ie": ["-end-end"],
|
|
56
|
+
"ie-be": ["-end-end"]
|
|
57
|
+
};
|
|
58
|
+
const xyzMap = {
|
|
59
|
+
"x": ["-x"],
|
|
60
|
+
"y": ["-y"],
|
|
61
|
+
"z": ["-z"],
|
|
62
|
+
"": ["-x", "-y"]
|
|
63
|
+
};
|
|
64
|
+
const basePositionMap = [
|
|
65
|
+
"top",
|
|
66
|
+
"top center",
|
|
67
|
+
"top left",
|
|
68
|
+
"top right",
|
|
69
|
+
"bottom",
|
|
70
|
+
"bottom center",
|
|
71
|
+
"bottom left",
|
|
72
|
+
"bottom right",
|
|
73
|
+
"left",
|
|
74
|
+
"left center",
|
|
75
|
+
"left top",
|
|
76
|
+
"left bottom",
|
|
77
|
+
"right",
|
|
78
|
+
"right center",
|
|
79
|
+
"right top",
|
|
80
|
+
"right bottom",
|
|
81
|
+
"center",
|
|
82
|
+
"center top",
|
|
83
|
+
"center bottom",
|
|
84
|
+
"center left",
|
|
85
|
+
"center right",
|
|
86
|
+
"center center"
|
|
87
|
+
];
|
|
88
|
+
const positionMap = Object.assign({}, ...basePositionMap.map((p) => ({ [p.replace(/ /, "-")]: p })), ...basePositionMap.map((p) => ({ [p.replace(/\b(\w)\w+/g, "$1").replace(/ /, "")]: p })));
|
|
89
|
+
const globalKeywords = [
|
|
90
|
+
"inherit",
|
|
91
|
+
"initial",
|
|
92
|
+
"revert",
|
|
93
|
+
"revert-layer",
|
|
94
|
+
"unset"
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
const cssProps = [
|
|
98
|
+
"color",
|
|
99
|
+
"border-color",
|
|
100
|
+
"background-color",
|
|
101
|
+
"flex-grow",
|
|
102
|
+
"flex",
|
|
103
|
+
"flex-shrink",
|
|
104
|
+
"caret-color",
|
|
105
|
+
"font",
|
|
106
|
+
"gap",
|
|
107
|
+
"opacity",
|
|
108
|
+
"visibility",
|
|
109
|
+
"z-index",
|
|
110
|
+
"font-weight",
|
|
111
|
+
"zoom",
|
|
112
|
+
"text-shadow",
|
|
113
|
+
"transform",
|
|
114
|
+
"box-shadow",
|
|
115
|
+
"backround-position",
|
|
116
|
+
"left",
|
|
117
|
+
"right",
|
|
118
|
+
"top",
|
|
119
|
+
"bottom",
|
|
120
|
+
"object-position",
|
|
121
|
+
"max-height",
|
|
122
|
+
"min-height",
|
|
123
|
+
"max-width",
|
|
124
|
+
"min-width",
|
|
125
|
+
"height",
|
|
126
|
+
"width",
|
|
127
|
+
"border-width",
|
|
128
|
+
"margin",
|
|
129
|
+
"padding",
|
|
130
|
+
"outline-width",
|
|
131
|
+
"outline-offset",
|
|
132
|
+
"font-size",
|
|
133
|
+
"line-height",
|
|
134
|
+
"text-indent",
|
|
135
|
+
"vertical-align",
|
|
136
|
+
"border-spacing",
|
|
137
|
+
"letter-spacing",
|
|
138
|
+
"word-spacing",
|
|
139
|
+
"stroke",
|
|
140
|
+
"filter",
|
|
141
|
+
"backdrop-filter",
|
|
142
|
+
"fill",
|
|
143
|
+
"mask",
|
|
144
|
+
"mask-size",
|
|
145
|
+
"mask-border",
|
|
146
|
+
"clip-path",
|
|
147
|
+
"clip",
|
|
148
|
+
"border-radius"
|
|
149
|
+
];
|
|
150
|
+
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax|rpx)?$/i;
|
|
151
|
+
const numberRE = /^(-?[0-9.]+)$/i;
|
|
152
|
+
const unitOnlyRE = /^(px)$/i;
|
|
153
|
+
function round(n) {
|
|
154
|
+
return n.toFixed(10).replace(/\.0+$/, "").replace(/(\.\d+?)0+$/, "$1");
|
|
155
|
+
}
|
|
156
|
+
function numberWithUnit(str) {
|
|
157
|
+
const match = str.match(numberWithUnitRE);
|
|
158
|
+
if (!match)
|
|
159
|
+
return;
|
|
160
|
+
const [, n, unit] = match;
|
|
161
|
+
const num = parseFloat(n);
|
|
162
|
+
if (unit && !Number.isNaN(num))
|
|
163
|
+
return `${round(num)}${unit}`;
|
|
164
|
+
}
|
|
165
|
+
function auto(str) {
|
|
166
|
+
if (str === "auto" || str === "a")
|
|
167
|
+
return "auto";
|
|
168
|
+
}
|
|
169
|
+
function rem(str) {
|
|
170
|
+
if (str.match(unitOnlyRE))
|
|
171
|
+
return `1${str}`;
|
|
172
|
+
const match = str.match(numberWithUnitRE);
|
|
173
|
+
if (!match)
|
|
174
|
+
return;
|
|
175
|
+
const [, n, unit] = match;
|
|
176
|
+
const num = parseFloat(n);
|
|
177
|
+
if (!Number.isNaN(num))
|
|
178
|
+
return unit ? `${round(num)}${unit}` : `${round(num / 4)}rem`;
|
|
179
|
+
}
|
|
180
|
+
function px(str) {
|
|
181
|
+
if (str.match(unitOnlyRE))
|
|
182
|
+
return `1${str}`;
|
|
183
|
+
const match = str.match(numberWithUnitRE);
|
|
184
|
+
if (!match)
|
|
185
|
+
return;
|
|
186
|
+
const [, n, unit] = match;
|
|
187
|
+
const num = parseFloat(n);
|
|
188
|
+
if (!Number.isNaN(num))
|
|
189
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}px`;
|
|
190
|
+
}
|
|
191
|
+
function number(str) {
|
|
192
|
+
if (!numberRE.test(str))
|
|
193
|
+
return;
|
|
194
|
+
const num = parseFloat(str);
|
|
195
|
+
if (!Number.isNaN(num))
|
|
196
|
+
return round(num);
|
|
197
|
+
}
|
|
198
|
+
function percent(str) {
|
|
199
|
+
if (str.endsWith("%"))
|
|
200
|
+
str = str.slice(0, -1);
|
|
201
|
+
const num = parseFloat(str);
|
|
202
|
+
if (!Number.isNaN(num))
|
|
203
|
+
return `${round(num / 100)}`;
|
|
204
|
+
}
|
|
205
|
+
function fraction(str) {
|
|
206
|
+
if (str === "full")
|
|
207
|
+
return "100%";
|
|
208
|
+
const [left, right] = str.split("/");
|
|
209
|
+
const num = parseFloat(left) / parseFloat(right);
|
|
210
|
+
if (!Number.isNaN(num))
|
|
211
|
+
return `${round(num * 100)}%`;
|
|
212
|
+
}
|
|
213
|
+
const bracketTypeRe = /^\[(color|length|position):/i;
|
|
214
|
+
function bracketWithType(str, type) {
|
|
215
|
+
if (str && str.startsWith("[") && str.endsWith("]")) {
|
|
216
|
+
let base;
|
|
217
|
+
const match = str.match(bracketTypeRe);
|
|
218
|
+
if (!match)
|
|
219
|
+
base = str.slice(1, -1);
|
|
220
|
+
else if (type && match[1] === type)
|
|
221
|
+
base = str.slice(match[0].length, -1);
|
|
222
|
+
if (base !== void 0) {
|
|
223
|
+
return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/([^\\])_/g, "$1 ").replace(/calc\((.*)/g, (v) => {
|
|
224
|
+
return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function bracket(str) {
|
|
230
|
+
return bracketWithType(str);
|
|
231
|
+
}
|
|
232
|
+
function bracketOfColor(str) {
|
|
233
|
+
return bracketWithType(str, "color");
|
|
234
|
+
}
|
|
235
|
+
function bracketOfLength(str) {
|
|
236
|
+
return bracketWithType(str, "length");
|
|
237
|
+
}
|
|
238
|
+
function bracketOfPosition(str) {
|
|
239
|
+
return bracketWithType(str, "position");
|
|
240
|
+
}
|
|
241
|
+
function cssvar(str) {
|
|
242
|
+
if (str.match(/^\$\S/))
|
|
243
|
+
return `var(--${escapeSelector(str.slice(1))})`;
|
|
244
|
+
}
|
|
245
|
+
function time(str) {
|
|
246
|
+
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
247
|
+
if (!match)
|
|
248
|
+
return;
|
|
249
|
+
const [, n, unit] = match;
|
|
250
|
+
const num = parseFloat(n);
|
|
251
|
+
if (!Number.isNaN(num))
|
|
252
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}ms`;
|
|
253
|
+
}
|
|
254
|
+
function degree(str) {
|
|
255
|
+
const match = str.match(/^(-?[0-9.]+)(deg|rad|grad|turn)?$/i);
|
|
256
|
+
if (!match)
|
|
257
|
+
return;
|
|
258
|
+
const [, n, unit] = match;
|
|
259
|
+
const num = parseFloat(n);
|
|
260
|
+
if (!Number.isNaN(num))
|
|
261
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}deg`;
|
|
262
|
+
}
|
|
263
|
+
function global(str) {
|
|
264
|
+
if (globalKeywords.includes(str))
|
|
265
|
+
return str;
|
|
266
|
+
}
|
|
267
|
+
function properties(str) {
|
|
268
|
+
if (str.split(",").every((prop) => cssProps.includes(prop)))
|
|
269
|
+
return str;
|
|
270
|
+
}
|
|
271
|
+
function position(str) {
|
|
272
|
+
if (["top", "left", "right", "bottom", "center"].includes(str))
|
|
273
|
+
return str;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const valueHandlers = {
|
|
277
|
+
__proto__: null,
|
|
278
|
+
numberWithUnit: numberWithUnit,
|
|
279
|
+
auto: auto,
|
|
280
|
+
rem: rem,
|
|
281
|
+
px: px,
|
|
282
|
+
number: number,
|
|
283
|
+
percent: percent,
|
|
284
|
+
fraction: fraction,
|
|
285
|
+
bracket: bracket,
|
|
286
|
+
bracketOfColor: bracketOfColor,
|
|
287
|
+
bracketOfLength: bracketOfLength,
|
|
288
|
+
bracketOfPosition: bracketOfPosition,
|
|
289
|
+
cssvar: cssvar,
|
|
290
|
+
time: time,
|
|
291
|
+
degree: degree,
|
|
292
|
+
global: global,
|
|
293
|
+
properties: properties,
|
|
294
|
+
position: position
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const handler = createValueHandler(valueHandlers);
|
|
298
|
+
const h = handler;
|
|
299
|
+
|
|
300
|
+
export { h as a, cornerMap as c, directionMap as d, globalKeywords as g, handler as h, insetMap as i, positionMap as p, valueHandlers as v, xyzMap as x };
|
|
@@ -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 };
|