@starweave-lab/unocss-preset 0.0.1 → 0.0.3
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.en.md +0 -2
- package/README.md +0 -2
- package/dist/index.mjs +154 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -22
package/README.en.md
CHANGED
package/README.md
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { definePreset } from "@unocss/core";
|
|
|
8
8
|
* - `max-full` — `max-w-full max-h-full`
|
|
9
9
|
* - `full-flex` — full width, flexible height (`flex-1`, `min-h-0`)
|
|
10
10
|
*/
|
|
11
|
-
const sizes = {
|
|
11
|
+
const sizes$1 = {
|
|
12
12
|
full: "w-full h-full",
|
|
13
13
|
"min-full": "min-w-full min-h-full",
|
|
14
14
|
"max-full": "max-w-full max-h-full",
|
|
@@ -103,7 +103,7 @@ const effects = {
|
|
|
103
103
|
//#endregion
|
|
104
104
|
//#region src/shortcuts/index.ts
|
|
105
105
|
const shortcuts = {
|
|
106
|
-
...sizes,
|
|
106
|
+
...sizes$1,
|
|
107
107
|
...elements,
|
|
108
108
|
...layouts,
|
|
109
109
|
...motions,
|
|
@@ -167,7 +167,13 @@ const borderDirections = {
|
|
|
167
167
|
b: ["bottom"],
|
|
168
168
|
l: ["left"],
|
|
169
169
|
x: ["left", "right"],
|
|
170
|
-
y: ["top", "bottom"]
|
|
170
|
+
y: ["top", "bottom"],
|
|
171
|
+
all: [
|
|
172
|
+
"top",
|
|
173
|
+
"right",
|
|
174
|
+
"bottom",
|
|
175
|
+
"left"
|
|
176
|
+
]
|
|
171
177
|
};
|
|
172
178
|
/**
|
|
173
179
|
* Resolves a theme color path such as `primary`, `blue-500` or `light-blue-500`.
|
|
@@ -190,58 +196,103 @@ function lookupColor(colors, parts) {
|
|
|
190
196
|
function isColorFunction(value) {
|
|
191
197
|
return /^(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|var)\(/i.test(value);
|
|
192
198
|
}
|
|
199
|
+
const namedColors = new Set(`aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue
|
|
200
|
+
blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk
|
|
201
|
+
crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki
|
|
202
|
+
darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen
|
|
203
|
+
darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue
|
|
204
|
+
dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite
|
|
205
|
+
gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki
|
|
206
|
+
lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan
|
|
207
|
+
lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen
|
|
208
|
+
lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen
|
|
209
|
+
magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen
|
|
210
|
+
mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream
|
|
211
|
+
mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid
|
|
212
|
+
palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum
|
|
213
|
+
powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown
|
|
214
|
+
seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen
|
|
215
|
+
steelblue tan teal thistle tomato transparent turquoise violet wheat white whitesmoke
|
|
216
|
+
yellow yellowgreen currentcolor`.split(/\s+/));
|
|
217
|
+
/**
|
|
218
|
+
* Splits the opacity modifier from the color at a `/` outside any brackets or
|
|
219
|
+
* parentheses, so arbitrary values such as `[rgb(1_2_3_/_50%)]` stay intact.
|
|
220
|
+
*/
|
|
221
|
+
function splitOpacity(input) {
|
|
222
|
+
let depth = 0;
|
|
223
|
+
let slash = -1;
|
|
224
|
+
for (let i = 0; i < input.length; i++) {
|
|
225
|
+
const char = input[i];
|
|
226
|
+
if (char === "[" || char === "(") depth++;
|
|
227
|
+
else if (char === "]" || char === ")") depth--;
|
|
228
|
+
else if (char === "/" && depth === 0) slash = i;
|
|
229
|
+
}
|
|
230
|
+
if (slash < 0) return [input, void 0];
|
|
231
|
+
return [input.slice(0, slash), input.slice(slash + 1)];
|
|
232
|
+
}
|
|
193
233
|
function toPercentage(value) {
|
|
194
234
|
const raw = value.startsWith("[") && value.endsWith("]") ? value.slice(1, -1) : value;
|
|
195
|
-
if (
|
|
235
|
+
if (/^(?:\d+(?:\.\d+)?|\.\d+)%$/.test(raw)) return raw;
|
|
236
|
+
if (!raw) return;
|
|
196
237
|
const number = Number(raw);
|
|
197
|
-
if (!Number.isFinite(number)) return;
|
|
238
|
+
if (!Number.isFinite(number) || number < 0) return;
|
|
198
239
|
return `${raw.includes(".") && number <= 1 ? number * 100 : number}%`;
|
|
199
240
|
}
|
|
200
241
|
/**
|
|
242
|
+
* Looks a color up in the theme. A leading `border-` is ignored so that
|
|
243
|
+
* `border-regular` resolves the `regular` token.
|
|
244
|
+
*/
|
|
245
|
+
function resolveThemeColor(input, theme) {
|
|
246
|
+
const lookup = (key) => {
|
|
247
|
+
const parts = key.split("-");
|
|
248
|
+
return lookupColor(theme.colors, parts) ?? lookupColor(theme.borderColor, parts);
|
|
249
|
+
};
|
|
250
|
+
return lookup(input) ?? (input.startsWith("border-") ? lookup(input.slice(7)) : void 0);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
201
253
|
* Resolves theme colors, opacity modifiers and arbitrary values.
|
|
202
254
|
*
|
|
203
255
|
* - `primary` → theme color
|
|
204
256
|
* - `blue-500` → nested theme color
|
|
205
257
|
* - `primary/50` → `color-mix(...)`
|
|
206
258
|
* - `[#fff]` → `#fff`
|
|
259
|
+
* - `[border-regular]` → the `regular` theme color
|
|
207
260
|
* - `red` / `rgb(1,2,3)` → raw CSS colors
|
|
208
261
|
*/
|
|
209
|
-
function resolveColor(input,
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
262
|
+
function resolveColor(input, theme) {
|
|
263
|
+
const [raw, opacity] = splitOpacity(input);
|
|
264
|
+
let resolved;
|
|
265
|
+
if (raw.startsWith("[") && raw.endsWith("]")) {
|
|
266
|
+
const inner = raw.slice(1, -1);
|
|
267
|
+
resolved = resolveThemeColor(inner, theme) ?? inner.replaceAll("_", " ");
|
|
268
|
+
} else resolved = resolveThemeColor(raw, theme) ?? (namedColors.has(raw.toLowerCase()) || isColorFunction(raw) ? raw : void 0);
|
|
215
269
|
if (!resolved) return;
|
|
216
|
-
if (
|
|
270
|
+
if (opacity === void 0) return resolved;
|
|
217
271
|
const percent = toPercentage(opacity);
|
|
218
272
|
if (!percent) return;
|
|
219
273
|
return `color-mix(in srgb, ${resolved} ${percent}, transparent)`;
|
|
220
274
|
}
|
|
221
275
|
/**
|
|
222
|
-
* 边框规则,格式为: b
|
|
276
|
+
* 边框规则,格式为: b-边框方向(不写默认生成所有方向)-边框样式(不写默认为solid)-边框长度(必须写)-边框颜色, 例子:
|
|
223
277
|
*
|
|
224
278
|
* @examples
|
|
225
279
|
*
|
|
226
|
-
* b-
|
|
227
|
-
* b-
|
|
228
|
-
* b-
|
|
229
|
-
* b-t-primary
|
|
230
|
-
* b-
|
|
280
|
+
* b-1-primary → 所有方向 1px solid primary
|
|
281
|
+
* b-all-1-primary → 所有方向 1px solid primary
|
|
282
|
+
* b-t-1-primary → border-top: 1px solid primary
|
|
283
|
+
* b-t-dashed-1-primary → border-top: 1px dashed primary
|
|
284
|
+
* b-b-dashed-2-red → border-bottom: 2px dashed red
|
|
285
|
+
* b-1-primary/50 → 所有方向 1px solid color-mix(primary 50%, transparent)
|
|
286
|
+
* b-t-1-[#fff] → border-top: 1px solid #fff
|
|
231
287
|
*/
|
|
232
|
-
const borderRules = [[/^b-(
|
|
233
|
-
if (!
|
|
234
|
-
|
|
235
|
-
const properties = borderDirections[direction];
|
|
236
|
-
if (!properties) return;
|
|
237
|
-
const resolvedColor = resolveColor(color, theme.colors);
|
|
288
|
+
const borderRules = [[/^b-(?:(all|[trblxy])-)?(?:(solid|dashed|dotted|double)-)?(\d+)-(.+)$/, ([, direction, style, width, color], { theme }) => {
|
|
289
|
+
if (!width || !color) return;
|
|
290
|
+
const resolvedColor = resolveColor(color, theme);
|
|
238
291
|
if (!resolvedColor) return;
|
|
292
|
+
const shorthand = `${width}px ${style ?? "solid"} ${resolvedColor}`;
|
|
239
293
|
const declarations = {};
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
declarations[`border-${s}-style`] = style ?? "solid";
|
|
243
|
-
declarations[`border-${s}-color`] = resolvedColor;
|
|
244
|
-
}
|
|
294
|
+
if (!direction || direction === "all") declarations.border = shorthand;
|
|
295
|
+
else for (const s of borderDirections[direction]) declarations[`border-${s}`] = shorthand;
|
|
245
296
|
return declarations;
|
|
246
297
|
}]];
|
|
247
298
|
const contentVisibilityRules = [
|
|
@@ -250,11 +301,84 @@ const contentVisibilityRules = [
|
|
|
250
301
|
"visible"
|
|
251
302
|
].map((value) => [`cv-${value}`, { "content-visibility": value }]);
|
|
252
303
|
//#endregion
|
|
304
|
+
//#region src/rules/shadow.ts
|
|
305
|
+
const directions = [
|
|
306
|
+
"t",
|
|
307
|
+
"r",
|
|
308
|
+
"b",
|
|
309
|
+
"l",
|
|
310
|
+
"all"
|
|
311
|
+
];
|
|
312
|
+
const sizes = {
|
|
313
|
+
sm: {
|
|
314
|
+
offset: 1,
|
|
315
|
+
blur: 2,
|
|
316
|
+
spread: 0,
|
|
317
|
+
color: "rgba(0, 0, 0, 0.05)"
|
|
318
|
+
},
|
|
319
|
+
"": {
|
|
320
|
+
offset: 1,
|
|
321
|
+
blur: 3,
|
|
322
|
+
spread: 0,
|
|
323
|
+
color: "rgba(0, 0, 0, 0.1)"
|
|
324
|
+
},
|
|
325
|
+
md: {
|
|
326
|
+
offset: 4,
|
|
327
|
+
blur: 6,
|
|
328
|
+
spread: -1,
|
|
329
|
+
color: "rgba(0, 0, 0, 0.1)"
|
|
330
|
+
},
|
|
331
|
+
lg: {
|
|
332
|
+
offset: 10,
|
|
333
|
+
blur: 15,
|
|
334
|
+
spread: -3,
|
|
335
|
+
color: "rgba(0, 0, 0, 0.1)"
|
|
336
|
+
},
|
|
337
|
+
xl: {
|
|
338
|
+
offset: 20,
|
|
339
|
+
blur: 25,
|
|
340
|
+
spread: -5,
|
|
341
|
+
color: "rgba(0, 0, 0, 0.1)"
|
|
342
|
+
},
|
|
343
|
+
"2xl": {
|
|
344
|
+
offset: 25,
|
|
345
|
+
blur: 50,
|
|
346
|
+
spread: -12,
|
|
347
|
+
color: "rgba(0, 0, 0, 0.25)"
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
/** X/Y multipliers for each direction; `all` is centered. */
|
|
351
|
+
const offsets = {
|
|
352
|
+
t: [0, -1],
|
|
353
|
+
r: [1, 0],
|
|
354
|
+
b: [0, 1],
|
|
355
|
+
l: [-1, 0],
|
|
356
|
+
all: [0, 0]
|
|
357
|
+
};
|
|
358
|
+
function createBoxShadow(direction, size) {
|
|
359
|
+
const [x, y] = offsets[direction];
|
|
360
|
+
return `${x * size.offset}px ${y * size.offset}px ${size.blur}px ${size.spread}px ${size.color}`;
|
|
361
|
+
}
|
|
362
|
+
const sizeEntries = Object.entries(sizes);
|
|
363
|
+
const shadows = Object.fromEntries(directions.flatMap((direction) => sizeEntries.map(([sizeKey, size]) => [`${direction}${sizeKey ? `-${sizeKey}` : ""}`, { "box-shadow": createBoxShadow(direction, size) }])));
|
|
364
|
+
/**
|
|
365
|
+
* 规则格式: shadow-[方向][-尺寸]
|
|
366
|
+
*
|
|
367
|
+
* - 方向: `t` / `r` / `b` / `l` / `all`,不写时等同于 `all`
|
|
368
|
+
* - 尺寸: `sm` / `md` / `lg` / `xl` / `2xl`,不写时为默认尺寸
|
|
369
|
+
*/
|
|
370
|
+
const shadowRules = [[/^shadow-(?:([trbl]|all)(?:-(sm|md|lg|xl|2xl))?|(sm|md|lg|xl|2xl))$/, ([, direction, size, sizeOnly]) => {
|
|
371
|
+
const resolvedSize = size ?? sizeOnly;
|
|
372
|
+
const key = `${direction ?? "all"}${resolvedSize ? `-${resolvedSize}` : ""}`;
|
|
373
|
+
return shadows[key];
|
|
374
|
+
}]];
|
|
375
|
+
//#endregion
|
|
253
376
|
//#region src/rules/index.ts
|
|
254
377
|
const rules = [
|
|
255
378
|
...borderRules,
|
|
256
379
|
...textSizeRules,
|
|
257
|
-
...contentVisibilityRules
|
|
380
|
+
...contentVisibilityRules,
|
|
381
|
+
...shadowRules
|
|
258
382
|
];
|
|
259
383
|
//#endregion
|
|
260
384
|
//#region src/index.ts
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/shortcuts/size.ts","../src/shortcuts/element.ts","../src/shortcuts/layout.ts","../src/shortcuts/motion.ts","../src/shortcuts/effect.ts","../src/shortcuts/index.ts","../src/rules/text.ts","../src/rules/border.ts","../src/rules/content-visibility.ts","../src/rules/index.ts","../src/index.ts"],"sourcesContent":["/**\n * Sizing shortcuts for filling a container.\n *\n * - `full` — `w-full h-full`\n * - `min-full` — `min-w-full min-h-full`\n * - `max-full` — `max-w-full max-h-full`\n * - `full-flex` — full width, flexible height (`flex-1`, `min-h-0`)\n */\nexport const sizes = {\n full: 'w-full h-full',\n 'min-full': 'min-w-full min-h-full',\n 'max-full': 'max-w-full max-h-full',\n 'full-flex': 'w-full min-h-0 flex-1',\n}\n","// Overlays only fade, so a standard easing curve fits better than a spring.\nconst easeOverlay = 'ease-[cubic-bezier(0.4,0,0.2,1)]'\nexport const elements = {\n // button\n button:\n 'flex items-center justify-center grow-0 shrink-0 bg-transparent border-none outline-none appearance-none touch-none cursor-pointer select-none focus-visible:outline-none',\n 'reset-button':\n 'p-0 m-0 bg-transparent border-none outline-none appearance-none touch-none cursor-pointer select-none focus-visible:outline-none',\n 'block-button':\n 'block w-full bg-transparent border-0 border-none outline-none appearance-none box-border cursor-pointer select-none',\n\n link: 'text-primary cursor-pointer hover:underline',\n 'img-cover': 'block w-full h-full object-cover',\n 'img-contain': 'block w-full h-full object-contain',\n avatar: 'inline-block rounded-full object-cover shrink-0 bg-gray-100',\n clickable: 'cursor-pointer select-none',\n\n // 悬浮层\n overlay: `absolute inset-0 w-full h-full z-50 bg-black/30 backdrop-blur-sm transition-opacity duration-200 ${easeOverlay}`,\n 'overlay-full': `fixed inset-0 w-full h-full z-50 bg-black/30 backdrop-blur-sm transition-opacity duration-200 ${easeOverlay}`,\n}\n","/**\n * Flex layout shortcuts.\n *\n * - `flex-center` / `flex-x-center` / `flex-y-center`\n * - `flex-between` / `flex-between-center` / `flex-center-between`\n */\nconst flexLayouts = {\n 'flex-center': 'flex justify-center items-center',\n 'flex-x-center': 'flex justify-center',\n 'flex-y-center': 'flex items-center',\n 'flex-between': 'flex justify-between',\n 'flex-between-center': 'flex justify-between items-center',\n 'flex-center-between': 'flex justify-center items-stretch',\n}\n\n/**\n * Grid layout shortcuts, including `grid-equal-cols` which auto-fits\n * equal-width columns.\n */\nconst gridLayouts = {\n 'grid-center': 'grid place-content-center',\n 'grid-x-center': 'grid justify-center',\n 'grid-y-center': 'grid items-center',\n 'grid-stretch': 'grid items-stretch',\n 'grid-between': 'grid justify-between',\n 'grid-between-center': 'grid justify-between items-center',\n 'grid-center-between': 'grid place-content-between',\n 'grid-equal-cols': 'grid grid-cols-[repeat(auto-fit,minmax(0,1fr))]',\n}\n\n/**\n * Absolute/fixed centering shortcuts, aligned on both axes or a single axis.\n */\nconst positionLayouts = {\n 'absolute-center': 'absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2',\n 'absolute-x-center': 'absolute left-1/2 transform -translate-x-1/2',\n 'absolute-y-center': 'absolute top-1/2 transform -translate-y-1/2',\n 'fixed-center': 'fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2',\n 'fixed-x-center': 'fixed left-1/2 transform -translate-x-1/2',\n 'fixed-y-center': 'fixed top-1/2 transform -translate-y-1/2',\n}\n\nexport const layouts = {\n ...flexLayouts,\n ...gridLayouts,\n ...positionLayouts,\n}\n","// Spring easing gives movement shortcuts their bounce.\nconst easeMotion = 'ease-[cubic-bezier(0.34,1.56,0.64,1)]'\n\nexport const motions = {\n // 按下弹簧效果\n 'motion-press': `transition-transform duration-300 ${easeMotion} active:scale-[0.96] motion-reduce:transition-none`,\n // 悬浮浮起\n 'motion-float': `transition-transform duration-200 ${easeMotion} hover:-translate-y-1`,\n // 悬浮放大\n 'motion-scale': `transition-transform duration-200 ${easeMotion} hover:scale-[1.02]`,\n // 悬浮缩小\n 'motion-shrink': `transition-transform duration-200 ${easeMotion} hover:scale-[0.98]`,\n // 悬浮旋转\n 'motion-rotate': `transition-transform duration-200 ${easeMotion} hover:rotate-3`,\n // 悬浮透明度变化\n 'motion-fade': `transition-opacity duration-200 ${easeMotion} hover:opacity-70`,\n}\n","// Effects are subtle feedback, so use a simple ease-out instead of a spring.\nconst easeEffect = 'ease-out'\n\nexport const effects = {\n // 选中状态\n 'effect-selected': 'bg-primary/10 text-primary',\n // 输入框聚焦反馈\n 'effect-focus': `transition duration-200 ${easeEffect} focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20`,\n // 通用交互反馈\n 'effect-interactive': `cursor-pointer transition-colors duration-200 ${easeEffect} hover:bg-gray-100 active:bg-gray-200`,\n // 聚焦轮廓\n 'effect-outline-ring': `transition duration-200 ${easeEffect} outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2`,\n // 禁用状态\n 'effect-disabled': 'disabled:cursor-not-allowed disabled:opacity-50',\n // 骨架屏基础样式\n 'effect-skeleton': 'animate-pulse rounded-md bg-gray-200 dark:bg-gray-800',\n // 悬浮阴影\n 'effect-shadow': `transition-shadow duration-200 ${easeEffect} hover:shadow-md`,\n // 悬浮边框高亮\n 'effect-border': `transition-colors duration-200 ${easeEffect} hover:border-primary`,\n // 悬浮高亮\n 'effect-highlight': `transition-colors duration-200 ${easeEffect} hover:bg-primary/10 hover:border-primary`,\n}\n","import { sizes } from './size'\nimport { elements } from './element'\nimport { layouts } from './layout'\nimport { motions } from './motion'\nimport { effects } from './effect'\n\nexport const shortcuts = {\n ...sizes,\n ...elements,\n ...layouts,\n ...motions,\n ...effects,\n}\n","import type { Rule } from '@unocss/core'\n\nconst textSizes = {\n xs: {\n 'font-size': '12px',\n 'line-height': '14px',\n },\n sm: {\n 'font-size': '14px',\n 'line-height': '18px',\n },\n base: {\n 'font-size': '16px',\n 'line-height': '24px',\n },\n md: {\n 'font-size': '18px',\n 'line-height': '28px',\n },\n '2md': {\n 'font-size': '20px',\n 'line-height': '32px',\n },\n lg: {\n 'font-size': '24px',\n 'line-height': '34px',\n },\n xl: {\n 'font-size': '28px',\n 'line-height': '40px',\n },\n '2xl': {\n 'font-size': '36px',\n 'line-height': '42px',\n },\n '3xl': {\n 'font-size': '48px',\n 'line-height': '56px',\n },\n '4xl': {\n 'font-size': '60px',\n 'line-height': '72px',\n },\n '5xl': {\n 'font-size': '72px',\n 'line-height': '80px',\n },\n} as const\nexport type TextSizeKeys = keyof typeof textSizes\nconst textSizePattern = Object.keys(textSizes).join('|')\n\nexport const textSizeRules: Rule[] = [\n [new RegExp(`^text-(${textSizePattern})$`), ([, key]) => textSizes[key as TextSizeKeys]],\n]\n","import type { Rule } from '@unocss/core'\n\ntype BorderDirection = 't' | 'r' | 'b' | 'l' | 'x' | 'y'\n\nconst borderDirections: Record<BorderDirection, string[]> = {\n t: ['top'],\n r: ['right'],\n b: ['bottom'],\n l: ['left'],\n x: ['left', 'right'],\n y: ['top', 'bottom'],\n}\n\n/**\n * Resolves a theme color path such as `primary`, `blue-500` or `light-blue-500`.\n * Longer keys win so theme entries containing hyphens still work.\n */\nfunction lookupColor(colors: unknown, parts: string[]): string | undefined {\n if (!colors || typeof colors !== 'object') return\n\n for (let size = parts.length; size > 0; size--) {\n const key = parts.slice(0, size).join('-')\n if (!(key in colors)) continue\n\n const value = (colors as Record<string, unknown>)[key]\n if (size === parts.length) {\n if (typeof value === 'string') return value\n continue\n }\n\n const nested = lookupColor(value, parts.slice(size))\n if (nested) return nested\n }\n}\n\nfunction isColorFunction(value: string): boolean {\n return /^(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|var)\\(/i.test(value)\n}\n\nfunction toPercentage(value: string): string | undefined {\n const raw = value.startsWith('[') && value.endsWith(']') ? value.slice(1, -1) : value\n if (/^\\d+(?:\\.\\d+)?%$/.test(raw)) return raw\n\n const number = Number(raw)\n if (!Number.isFinite(number)) return\n\n const percent = raw.includes('.') && number <= 1 ? number * 100 : number\n return `${percent}%`\n}\n\n/**\n * Resolves theme colors, opacity modifiers and arbitrary values.\n *\n * - `primary` → theme color\n * - `blue-500` → nested theme color\n * - `primary/50` → `color-mix(...)`\n * - `[#fff]` → `#fff`\n * - `red` / `rgb(1,2,3)` → raw CSS colors\n */\nfunction resolveColor(input: string, colors: unknown): string | undefined {\n const slash = input.lastIndexOf('/')\n const withOpacity = slash > 0\n const raw = withOpacity ? input.slice(0, slash) : input\n const opacity = withOpacity ? input.slice(slash + 1) : undefined\n\n const resolved =\n raw.startsWith('[') && raw.endsWith(']')\n ? raw.slice(1, -1)\n : (lookupColor(colors, raw.split('-')) ??\n (/^[a-z]+$/i.test(raw) || isColorFunction(raw) ? raw : undefined))\n\n if (!resolved) return\n if (!opacity) return resolved\n\n const percent = toPercentage(opacity)\n if (!percent) return\n\n return `color-mix(in srgb, ${resolved} ${percent}, transparent)`\n}\n\n/**\n * 边框规则,格式为: b-边框方向-边框样式(不写默认为solid)+边框长度(不写默认为1)+边框颜色, 例子:\n *\n * @examples\n *\n * b-t-primary → border-top: 1px solid primary\n * b-t-dashed-primary → border-top: 1px dashed primary\n * b-b-dashed-2-red → border-bottom: 2px dashed red\n * b-t-primary/50 → border-top: 1px solid color-mix(primary 50%, transparent)\n * b-t-[#fff] → border-top: 1px solid #fff\n */\nexport const borderRules: Rule[] = [\n [\n /^b-(t|r|b|l|x|y)-(?:(solid|dashed|dotted|double)-)?(?:(\\d+)-)?(.+)$/,\n ([, direction, style, width = '1', color], { theme }) => {\n if (!direction || !color) return\n\n // Reject unsupported styles, e.g. `b-t-wavy-2-red`, instead of treating\n // the rest of the utility as a color.\n if (!style && /^[a-z]+-\\d+-.+$/.test(color)) return\n\n const properties = borderDirections[direction as BorderDirection]\n if (!properties) return\n\n const resolvedColor = resolveColor(color, (theme as { colors?: unknown }).colors)\n if (!resolvedColor) return\n\n const declarations: Record<string, string> = {}\n for (const s of properties) {\n declarations[`border-${s}-width`] = `${width}px`\n declarations[`border-${s}-style`] = style ?? 'solid'\n declarations[`border-${s}-color`] = resolvedColor\n }\n return declarations\n },\n ],\n]\n","import type { Rule } from '@unocss/core'\nconst values = ['auto', 'hidden', 'visible'] as const\n\nexport const contentVisibilityRules: Rule[] = values.map((value) => [\n `cv-${value}`,\n { 'content-visibility': value },\n])\n","import { textSizeRules } from './text'\nimport { borderRules } from './border'\nimport { contentVisibilityRules } from './content-visibility'\n\nexport const rules = [...borderRules, ...textSizeRules, ...contentVisibilityRules]\n","import type { Preset, Variant } from '@unocss/core'\nimport { definePreset } from '@unocss/core'\nimport { shortcuts } from './shortcuts'\nimport { rules } from './rules'\n\n/**\n * Options accepted by {@link presetUnocss}.\n */\nexport interface PresetUnocssOptions {\n /**\n * Prefix applied to every generated utility, for example `u-`.\n * @default undefined\n */\n prefix?: string\n}\n\n/**\n * `hocus:` variant matching both `:hover` and `:focus-visible`.\n */\nconst hocusVariant: Variant = {\n name: 'hocus',\n match: (matcher) => {\n if (!matcher.startsWith('hocus:')) return\n return {\n matcher: matcher.slice('hocus:'.length),\n selector: (selector) => `${selector}:hover, ${selector}:focus-visible`,\n }\n },\n}\n\n/**\n *\n * @example\n * ```ts\n * import presetUnocss from '@starweave-lab/unocss-preset'\n *\n * export default defineConfig({\n * presets: [presetWind4(), presetUnocss()],\n * })\n * ```\n */\nexport const presetUnocss = definePreset<PresetUnocssOptions>((options = {}) => {\n const { prefix } = options\n const preset: Preset = {\n name: 'unocss-preset',\n rules,\n variants: [hocusVariant],\n shortcuts,\n prefix: prefix,\n }\n return preset\n})\n\nexport default presetUnocss\n"],"mappings":";;;;;;;;;;AAQA,MAAa,QAAQ;CACnB,MAAM;CACN,YAAY;CACZ,YAAY;CACZ,aAAa;AACf;;;ACZA,MAAM,cAAc;AACpB,MAAa,WAAW;CAEtB,QACE;CACF,gBACE;CACF,gBACE;CAEF,MAAM;CACN,aAAa;CACb,eAAe;CACf,QAAQ;CACR,WAAW;CAGX,SAAS,oGAAoG;CAC7G,gBAAgB,iGAAiG;AACnH;;;;;;;;;ACdA,MAAM,cAAc;CAClB,eAAe;CACf,iBAAiB;CACjB,iBAAiB;CACjB,gBAAgB;CAChB,uBAAuB;CACvB,uBAAuB;AACzB;;;;;AAMA,MAAM,cAAc;CAClB,eAAe;CACf,iBAAiB;CACjB,iBAAiB;CACjB,gBAAgB;CAChB,gBAAgB;CAChB,uBAAuB;CACvB,uBAAuB;CACvB,mBAAmB;AACrB;;;;AAKA,MAAM,kBAAkB;CACtB,mBAAmB;CACnB,qBAAqB;CACrB,qBAAqB;CACrB,gBAAgB;CAChB,kBAAkB;CAClB,kBAAkB;AACpB;AAEA,MAAa,UAAU;CACrB,GAAG;CACH,GAAG;CACH,GAAG;AACL;;;AC7CA,MAAM,aAAa;AAEnB,MAAa,UAAU;CAErB,gBAAgB,qCAAqC,WAAW;CAEhE,gBAAgB,qCAAqC,WAAW;CAEhE,gBAAgB,qCAAqC,WAAW;CAEhE,iBAAiB,qCAAqC,WAAW;CAEjE,iBAAiB,qCAAqC,WAAW;CAEjE,eAAe,mCAAmC,WAAW;AAC/D;;;ACfA,MAAM,aAAa;AAEnB,MAAa,UAAU;CAErB,mBAAmB;C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AAS,GAAG,QAAQ;AACnD;;;;;;;;;;;;AAaA,MAAa,cAAsB,CACjC,CACE,wEACC,GAAG,WAAW,OAAO,QAAQ,KAAK,QAAQ,EAAE,YAAY;CACvD,IAAI,CAAC,aAAa,CAAC,OAAO;CAI1B,IAAI,CAAC,SAAS,kBAAkB,KAAK,KAAK,GAAG;CAE7C,MAAM,aAAa,iBAAiB;CACpC,IAAI,CAAC,YAAY;CAEjB,MAAM,gBAAgB,aAAa,OAAQ,MAA+B,MAAM;CAChF,IAAI,CAAC,eAAe;CAEpB,MAAM,eAAuC,CAAC;CAC9C,KAAK,MAAM,KAAK,YAAY;EAC1B,aAAa,UAAU,EAAE,WAAW,GAAG,MAAM;EAC7C,aAAa,UAAU,EAAE,WAAW,SAAS;EAC7C,aAAa,UAAU,EAAE,WAAW;CACtC;CACA,OAAO;AACT,CACF,CACF;ACjHA,MAAa,yBAAiC;CAF9B;CAAQ;CAAU;AAEY,CAAA,CAAO,KAAK,UAAU,CAClE,MAAM,SACN,EAAE,sBAAsB,MAAM,CAChC,CAAC;;;ACFD,MAAa,QAAQ;CAAC,GAAG;CAAa,GAAG;CAAe,GAAG;AAAsB;;;;;;ACejF,MAAM,eAAwB;CAC5B,MAAM;CACN,QAAQ,YAAY;EAClB,IAAI,CAAC,QAAQ,WAAW,QAAQ,GAAG;EACnC,OAAO;GACL,SAAS,QAAQ,MAAM,CAAe;GACtC,WAAW,aAAa,GAAG,SAAS,UAAU,SAAS;EACzD;CACF;AACF;;;;;;;;;;;;AAaA,MAAa,eAAe,cAAmC,UAAU,CAAC,MAAM;CAC9E,MAAM,EAAE,WAAW;CAQnB,OAAO;EANL,MAAM;EACN;EACA,UAAU,CAAC,YAAY;EACvB;EACQ;CAEE;AACd,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["sizes","sizes"],"sources":["../src/shortcuts/size.ts","../src/shortcuts/element.ts","../src/shortcuts/layout.ts","../src/shortcuts/motion.ts","../src/shortcuts/effect.ts","../src/shortcuts/index.ts","../src/rules/text.ts","../src/rules/border.ts","../src/rules/content-visibility.ts","../src/rules/shadow.ts","../src/rules/index.ts","../src/index.ts"],"sourcesContent":["/**\n * Sizing shortcuts for filling a container.\n *\n * - `full` — `w-full h-full`\n * - `min-full` — `min-w-full min-h-full`\n * - `max-full` — `max-w-full max-h-full`\n * - `full-flex` — full width, flexible height (`flex-1`, `min-h-0`)\n */\nexport const sizes = {\n full: 'w-full h-full',\n 'min-full': 'min-w-full min-h-full',\n 'max-full': 'max-w-full max-h-full',\n 'full-flex': 'w-full min-h-0 flex-1',\n}\n","// Overlays only fade, so a standard easing curve fits better than a spring.\nconst easeOverlay = 'ease-[cubic-bezier(0.4,0,0.2,1)]'\nexport const elements = {\n // button\n button:\n 'flex items-center justify-center grow-0 shrink-0 bg-transparent border-none outline-none appearance-none touch-none cursor-pointer select-none focus-visible:outline-none',\n 'reset-button':\n 'p-0 m-0 bg-transparent border-none outline-none appearance-none touch-none cursor-pointer select-none focus-visible:outline-none',\n 'block-button':\n 'block w-full bg-transparent border-0 border-none outline-none appearance-none box-border cursor-pointer select-none',\n\n link: 'text-primary cursor-pointer hover:underline',\n 'img-cover': 'block w-full h-full object-cover',\n 'img-contain': 'block w-full h-full object-contain',\n avatar: 'inline-block rounded-full object-cover shrink-0 bg-gray-100',\n clickable: 'cursor-pointer select-none',\n\n // 悬浮层\n overlay: `absolute inset-0 w-full h-full z-50 bg-black/30 backdrop-blur-sm transition-opacity duration-200 ${easeOverlay}`,\n 'overlay-full': `fixed inset-0 w-full h-full z-50 bg-black/30 backdrop-blur-sm transition-opacity duration-200 ${easeOverlay}`,\n}\n","/**\n * Flex layout shortcuts.\n *\n * - `flex-center` / `flex-x-center` / `flex-y-center`\n * - `flex-between` / `flex-between-center` / `flex-center-between`\n */\nconst flexLayouts = {\n 'flex-center': 'flex justify-center items-center',\n 'flex-x-center': 'flex justify-center',\n 'flex-y-center': 'flex items-center',\n 'flex-between': 'flex justify-between',\n 'flex-between-center': 'flex justify-between items-center',\n 'flex-center-between': 'flex justify-center items-stretch',\n}\n\n/**\n * Grid layout shortcuts, including `grid-equal-cols` which auto-fits\n * equal-width columns.\n */\nconst gridLayouts = {\n 'grid-center': 'grid place-content-center',\n 'grid-x-center': 'grid justify-center',\n 'grid-y-center': 'grid items-center',\n 'grid-stretch': 'grid items-stretch',\n 'grid-between': 'grid justify-between',\n 'grid-between-center': 'grid justify-between items-center',\n 'grid-center-between': 'grid place-content-between',\n 'grid-equal-cols': 'grid grid-cols-[repeat(auto-fit,minmax(0,1fr))]',\n}\n\n/**\n * Absolute/fixed centering shortcuts, aligned on both axes or a single axis.\n */\nconst positionLayouts = {\n 'absolute-center': 'absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2',\n 'absolute-x-center': 'absolute left-1/2 transform -translate-x-1/2',\n 'absolute-y-center': 'absolute top-1/2 transform -translate-y-1/2',\n 'fixed-center': 'fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2',\n 'fixed-x-center': 'fixed left-1/2 transform -translate-x-1/2',\n 'fixed-y-center': 'fixed top-1/2 transform -translate-y-1/2',\n}\n\nexport const layouts = {\n ...flexLayouts,\n ...gridLayouts,\n ...positionLayouts,\n}\n","// Spring easing gives movement shortcuts their bounce.\nconst easeMotion = 'ease-[cubic-bezier(0.34,1.56,0.64,1)]'\n\nexport const motions = {\n // 按下弹簧效果\n 'motion-press': `transition-transform duration-300 ${easeMotion} active:scale-[0.96] motion-reduce:transition-none`,\n // 悬浮浮起\n 'motion-float': `transition-transform duration-200 ${easeMotion} hover:-translate-y-1`,\n // 悬浮放大\n 'motion-scale': `transition-transform duration-200 ${easeMotion} hover:scale-[1.02]`,\n // 悬浮缩小\n 'motion-shrink': `transition-transform duration-200 ${easeMotion} hover:scale-[0.98]`,\n // 悬浮旋转\n 'motion-rotate': `transition-transform duration-200 ${easeMotion} hover:rotate-3`,\n // 悬浮透明度变化\n 'motion-fade': `transition-opacity duration-200 ${easeMotion} hover:opacity-70`,\n}\n","// Effects are subtle feedback, so use a simple ease-out instead of a spring.\nconst easeEffect = 'ease-out'\n\nexport const effects = {\n // 选中状态\n 'effect-selected': 'bg-primary/10 text-primary',\n // 输入框聚焦反馈\n 'effect-focus': `transition duration-200 ${easeEffect} focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20`,\n // 通用交互反馈\n 'effect-interactive': `cursor-pointer transition-colors duration-200 ${easeEffect} hover:bg-gray-100 active:bg-gray-200`,\n // 聚焦轮廓\n 'effect-outline-ring': `transition duration-200 ${easeEffect} outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2`,\n // 禁用状态\n 'effect-disabled': 'disabled:cursor-not-allowed disabled:opacity-50',\n // 骨架屏基础样式\n 'effect-skeleton': 'animate-pulse rounded-md bg-gray-200 dark:bg-gray-800',\n // 悬浮阴影\n 'effect-shadow': `transition-shadow duration-200 ${easeEffect} hover:shadow-md`,\n // 悬浮边框高亮\n 'effect-border': `transition-colors duration-200 ${easeEffect} hover:border-primary`,\n // 悬浮高亮\n 'effect-highlight': `transition-colors duration-200 ${easeEffect} hover:bg-primary/10 hover:border-primary`,\n}\n","import { sizes } from './size'\nimport { elements } from './element'\nimport { layouts } from './layout'\nimport { motions } from './motion'\nimport { effects } from './effect'\n\nexport const shortcuts = {\n ...sizes,\n ...elements,\n ...layouts,\n ...motions,\n ...effects,\n}\n","import type { Rule } from '@unocss/core'\n\nconst textSizes = {\n xs: {\n 'font-size': '12px',\n 'line-height': '14px',\n },\n sm: {\n 'font-size': '14px',\n 'line-height': '18px',\n },\n base: {\n 'font-size': '16px',\n 'line-height': '24px',\n },\n md: {\n 'font-size': '18px',\n 'line-height': '28px',\n },\n '2md': {\n 'font-size': '20px',\n 'line-height': '32px',\n },\n lg: {\n 'font-size': '24px',\n 'line-height': '34px',\n },\n xl: {\n 'font-size': '28px',\n 'line-height': '40px',\n },\n '2xl': {\n 'font-size': '36px',\n 'line-height': '42px',\n },\n '3xl': {\n 'font-size': '48px',\n 'line-height': '56px',\n },\n '4xl': {\n 'font-size': '60px',\n 'line-height': '72px',\n },\n '5xl': {\n 'font-size': '72px',\n 'line-height': '80px',\n },\n} as const\nexport type TextSizeKeys = keyof typeof textSizes\nconst textSizePattern = Object.keys(textSizes).join('|')\n\nexport const textSizeRules: Rule[] = [\n [new RegExp(`^text-(${textSizePattern})$`), ([, key]) => textSizes[key as TextSizeKeys]],\n]\n","import type { Rule } from '@unocss/core'\n\ntype BorderDirection = 't' | 'r' | 'b' | 'l' | 'x' | 'y' | 'all'\n\nconst borderDirections: Record<BorderDirection, string[]> = {\n t: ['top'],\n r: ['right'],\n b: ['bottom'],\n l: ['left'],\n x: ['left', 'right'],\n y: ['top', 'bottom'],\n all: ['top', 'right', 'bottom', 'left'],\n}\n\n/**\n * Resolves a theme color path such as `primary`, `blue-500` or `light-blue-500`.\n * Longer keys win so theme entries containing hyphens still work.\n */\nfunction lookupColor(colors: unknown, parts: string[]): string | undefined {\n if (!colors || typeof colors !== 'object') return\n for (let size = parts.length; size > 0; size--) {\n const key = parts.slice(0, size).join('-')\n if (!(key in colors)) continue\n const value = (colors as Record<string, unknown>)[key]\n if (size === parts.length) {\n if (typeof value === 'string') return value\n continue\n }\n const nested = lookupColor(value, parts.slice(size))\n if (nested) return nested\n }\n}\n\nfunction isColorFunction(value: string): boolean {\n return /^(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|var)\\(/i.test(value)\n}\n\nconst namedColors = new Set(\n `aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue\n blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk\n crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki\n darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen\n darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue\n dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite\n gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki\n lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan\n lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen\n lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen\n magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen\n mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream\n mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid\n palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum\n powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown\n seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen\n steelblue tan teal thistle tomato transparent turquoise violet wheat white whitesmoke\n yellow yellowgreen currentcolor`.split(/\\s+/),\n)\n\n/**\n * Splits the opacity modifier from the color at a `/` outside any brackets or\n * parentheses, so arbitrary values such as `[rgb(1_2_3_/_50%)]` stay intact.\n */\nfunction splitOpacity(input: string): [string, string | undefined] {\n let depth = 0\n let slash = -1\n\n for (let i = 0; i < input.length; i++) {\n const char = input[i]\n if (char === '[' || char === '(') depth++\n else if (char === ']' || char === ')') depth--\n else if (char === '/' && depth === 0) slash = i\n }\n\n if (slash < 0) return [input, undefined]\n return [input.slice(0, slash), input.slice(slash + 1)]\n}\n\nfunction toPercentage(value: string): string | undefined {\n const raw = value.startsWith('[') && value.endsWith(']') ? value.slice(1, -1) : value\n if (/^(?:\\d+(?:\\.\\d+)?|\\.\\d+)%$/.test(raw)) return raw\n if (!raw) return\n\n const number = Number(raw)\n if (!Number.isFinite(number) || number < 0) return\n\n const percent = raw.includes('.') && number <= 1 ? number * 100 : number\n return `${percent}%`\n}\n\ninterface ColorTheme {\n colors?: unknown\n borderColor?: unknown\n}\n\n/**\n * Looks a color up in the theme. A leading `border-` is ignored so that\n * `border-regular` resolves the `regular` token.\n */\nfunction resolveThemeColor(input: string, theme: ColorTheme): string | undefined {\n const lookup = (key: string) => {\n const parts = key.split('-')\n return lookupColor(theme.colors, parts) ?? lookupColor(theme.borderColor, parts)\n }\n\n return (\n lookup(input) ??\n (input.startsWith('border-') ? lookup(input.slice('border-'.length)) : undefined)\n )\n}\n\n/**\n * Resolves theme colors, opacity modifiers and arbitrary values.\n *\n * - `primary` → theme color\n * - `blue-500` → nested theme color\n * - `primary/50` → `color-mix(...)`\n * - `[#fff]` → `#fff`\n * - `[border-regular]` → the `regular` theme color\n * - `red` / `rgb(1,2,3)` → raw CSS colors\n */\nfunction resolveColor(input: string, theme: ColorTheme): string | undefined {\n const [raw, opacity] = splitOpacity(input)\n\n let resolved: string | undefined\n if (raw.startsWith('[') && raw.endsWith(']')) {\n const inner = raw.slice(1, -1)\n // Arbitrary values still resolve theme colors, e.g. `[primary]` → `#3b82f6`.\n resolved = resolveThemeColor(inner, theme) ?? inner.replaceAll('_', ' ')\n } else {\n resolved =\n resolveThemeColor(raw, theme) ??\n (namedColors.has(raw.toLowerCase()) || isColorFunction(raw) ? raw : undefined)\n }\n\n if (!resolved) return\n if (opacity === undefined) return resolved\n\n const percent = toPercentage(opacity)\n if (!percent) return\n\n return `color-mix(in srgb, ${resolved} ${percent}, transparent)`\n}\n\n/**\n * 边框规则,格式为: b-边框方向(不写默认生成所有方向)-边框样式(不写默认为solid)-边框长度(必须写)-边框颜色, 例子:\n *\n * @examples\n *\n * b-1-primary → 所有方向 1px solid primary\n * b-all-1-primary → 所有方向 1px solid primary\n * b-t-1-primary → border-top: 1px solid primary\n * b-t-dashed-1-primary → border-top: 1px dashed primary\n * b-b-dashed-2-red → border-bottom: 2px dashed red\n * b-1-primary/50 → 所有方向 1px solid color-mix(primary 50%, transparent)\n * b-t-1-[#fff] → border-top: 1px solid #fff\n */\nexport const borderRules: Rule[] = [\n [\n /^b-(?:(all|[trblxy])-)?(?:(solid|dashed|dotted|double)-)?(\\d+)-(.+)$/,\n ([, direction, style, width, color], { theme }) => {\n if (!width || !color) return\n const resolvedColor = resolveColor(color, theme as ColorTheme)\n if (!resolvedColor) return\n\n const shorthand = `${width}px ${style ?? 'solid'} ${resolvedColor}`\n const declarations: Record<string, string> = {}\n if (!direction || direction === 'all') {\n declarations.border = shorthand\n } else {\n for (const s of borderDirections[direction as BorderDirection]) {\n declarations[`border-${s}`] = shorthand\n }\n }\n return declarations\n },\n ],\n]\n","import type { Rule } from '@unocss/core'\nconst values = ['auto', 'hidden', 'visible'] as const\n\nexport const contentVisibilityRules: Rule[] = values.map((value) => [\n `cv-${value}`,\n { 'content-visibility': value },\n])\n","import type { Rule } from '@unocss/core'\n\ntype Direction = 't' | 'r' | 'b' | 'l' | 'all'\ntype SizeKey = 'sm' | 'md' | '' | 'lg' | 'xl' | '2xl'\n\ninterface Size {\n offset: number\n blur: number\n spread: number\n color: string\n}\ntype BoxShadowStyles = Record<string, { 'box-shadow': string }>\n\nconst directions: Direction[] = ['t', 'r', 'b', 'l', 'all']\nconst sizes: Record<SizeKey, Size> = {\n sm: { offset: 1, blur: 2, spread: 0, color: 'rgba(0, 0, 0, 0.05)' },\n '': { offset: 1, blur: 3, spread: 0, color: 'rgba(0, 0, 0, 0.1)' },\n md: { offset: 4, blur: 6, spread: -1, color: 'rgba(0, 0, 0, 0.1)' },\n lg: { offset: 10, blur: 15, spread: -3, color: 'rgba(0, 0, 0, 0.1)' },\n xl: { offset: 20, blur: 25, spread: -5, color: 'rgba(0, 0, 0, 0.1)' },\n '2xl': { offset: 25, blur: 50, spread: -12, color: 'rgba(0, 0, 0, 0.25)' },\n}\n\n/** X/Y multipliers for each direction; `all` is centered. */\nconst offsets: Record<Direction, [number, number]> = {\n t: [0, -1],\n r: [1, 0],\n b: [0, 1],\n l: [-1, 0],\n all: [0, 0],\n}\n\nfunction createBoxShadow(direction: Direction, size: Size): string {\n const [x, y] = offsets[direction]\n return `${x * size.offset}px ${y * size.offset}px ${size.blur}px ${size.spread}px ${size.color}`\n}\n\nconst sizeEntries = Object.entries(sizes) as Array<[SizeKey, Size]>\n\nconst shadows: BoxShadowStyles = Object.fromEntries(\n directions.flatMap((direction) =>\n sizeEntries.map(([sizeKey, size]) => [\n `${direction}${sizeKey ? `-${sizeKey}` : ''}`,\n { 'box-shadow': createBoxShadow(direction, size) },\n ]),\n ),\n)\n\n/**\n * 规则格式: shadow-[方向][-尺寸]\n *\n * - 方向: `t` / `r` / `b` / `l` / `all`,不写时等同于 `all`\n * - 尺寸: `sm` / `md` / `lg` / `xl` / `2xl`,不写时为默认尺寸\n */\nexport const shadowRules: Rule[] = [\n [\n /^shadow-(?:([trbl]|all)(?:-(sm|md|lg|xl|2xl))?|(sm|md|lg|xl|2xl))$/,\n ([, direction, size, sizeOnly]) => {\n const resolvedSize = size ?? sizeOnly\n const key = `${direction ?? 'all'}${resolvedSize ? `-${resolvedSize}` : ''}`\n return shadows[key]\n },\n ],\n]\n","import { textSizeRules } from './text'\nimport { borderRules } from './border'\nimport { contentVisibilityRules } from './content-visibility'\nimport { shadowRules } from './shadow'\n\nexport const rules = [...borderRules, ...textSizeRules, ...contentVisibilityRules, ...shadowRules]\n","import type { Preset, Variant } from '@unocss/core'\nimport { definePreset } from '@unocss/core'\nimport { shortcuts } from './shortcuts'\nimport { rules } from './rules'\n\n/**\n * Options accepted by {@link presetUnocss}.\n */\nexport interface PresetUnocssOptions {\n /**\n * Prefix applied to every generated utility, for example `u-`.\n * @default undefined\n */\n prefix?: string\n}\n\n/**\n * `hocus:` variant matching both `:hover` and `:focus-visible`.\n */\nconst hocusVariant: Variant = {\n name: 'hocus',\n match: (matcher) => {\n if (!matcher.startsWith('hocus:')) return\n return {\n matcher: matcher.slice('hocus:'.length),\n selector: (selector) => `${selector}:hover, ${selector}:focus-visible`,\n }\n },\n}\n\n/**\n *\n * @example\n * ```ts\n * import presetUnocss from '@starweave-lab/unocss-preset'\n *\n * export default defineConfig({\n * presets: [presetWind4(), presetUnocss()],\n * })\n * ```\n */\nexport const presetUnocss = definePreset<PresetUnocssOptions>((options = {}) => {\n const { prefix } = options\n const preset: Preset = {\n name: 'unocss-preset',\n rules,\n variants: [hocusVariant],\n shortcuts,\n prefix: prefix,\n }\n return preset\n})\n\nexport default presetUnocss\n"],"mappings":";;;;;;;;;;AAQA,MAAaA,UAAQ;CACnB,MAAM;CACN,YAAY;CACZ,YAAY;CACZ,aAAa;AACf;;;ACZA,MAAM,cAAc;AACpB,MAAa,WAAW;CAEtB,QACE;CACF,gBACE;CACF,gBACE;CAEF,MAAM;CACN,aAAa;CACb,eAAe;CACf,QAAQ;CACR,WAAW;CAGX,SAAS,oGAAoG;CAC7G,gBAAgB,iGAAiG;AACnH;;;;;;;;;ACdA,MAAM,cAAc;CAClB,eAAe;CACf,iBAAiB;CACjB,iBAAiB;CACjB,gBAAgB;CAChB,uBAAuB;CACvB,uBAAuB;AACzB;;;;;AAMA,MAAM,cAAc;CAClB,eAAe;CACf,iBAAiB;CACjB,iBAAiB;CACjB,gBAAgB;CAChB,gBAAgB;CAChB,uBAAuB;CACvB,uBAAuB;CACvB,mBAAmB;AACrB;;;;AAKA,MAAM,kBAAkB;CACtB,mBAAmB;CACnB,qBAAqB;CACrB,qBAAqB;CACrB,gBAAgB;CAChB,kBAAkB;CAClB,kBAAkB;AACpB;AAEA,MAAa,UAAU;CACrB,GAAG;CACH,GAAG;CACH,GAAG;AACL;;;AC7CA,MAAM,aAAa;AAEnB,MAAa,UAAU;CAErB,gBAAgB,qCAAqC,WAAW;CAEhE,gBAAgB,qCAAqC,WAAW;CAEhE,gBAAgB,qCAAqC,WAAW;CAEhE,iBAAiB,qCAAqC,WAAW;CAEjE,iBAAiB,qCAAqC,WAAW;CAEjE,eAAe,mCAAmC,WAAW;AAC/D;;;ACfA,MAAM,aAAa;AAEnB,MAAa,UAAU;CAErB,mBAAmB;CAEnB,gBAAgB,2BAA2B,WAAW;CAEtD,sBAAsB,iDAAiD,WAAW;CAElF,uBAAuB,2BAA2B,WAAW;CAE7D,mBAAmB;CAEnB,mBAAmB;CAEnB,iBAAiB,kCAAkC,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iB;CACxE,OAAO,QAAQ;AACjB,CACF,CACF;;;AC1DA,MAAa,QAAQ;CAAC,GAAG;CAAa,GAAG;CAAe,GAAG;CAAwB,GAAG;AAAW;;;;;;ACcjG,MAAM,eAAwB;CAC5B,MAAM;CACN,QAAQ,YAAY;EAClB,IAAI,CAAC,QAAQ,WAAW,QAAQ,GAAG;EACnC,OAAO;GACL,SAAS,QAAQ,MAAM,CAAe;GACtC,WAAW,aAAa,GAAG,SAAS,UAAU,SAAS;EACzD;CACF;AACF;;;;;;;;;;;;AAaA,MAAa,eAAe,cAAmC,UAAU,CAAC,MAAM;CAC9E,MAAM,EAAE,WAAW;CAQnB,OAAO;EANL,MAAM;EACN;EACA,UAAU,CAAC,YAAY;EACvB;EACQ;CAEE;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starweave-lab/unocss-preset",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "A useful UnoCSS preset.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atomic-css",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/yibird/unocss-preset.git"
|
|
16
16
|
},
|
|
17
|
+
"funding": "https://github.com/sponsors/unocss-preset",
|
|
17
18
|
"files": [
|
|
18
19
|
"dist",
|
|
19
20
|
"README.md",
|
|
@@ -35,25 +36,6 @@
|
|
|
35
36
|
"publishConfig": {
|
|
36
37
|
"access": "public"
|
|
37
38
|
},
|
|
38
|
-
"scripts": {
|
|
39
|
-
"dev": "vp pack --watch",
|
|
40
|
-
"build": "vp pack",
|
|
41
|
-
"prepack": "pnpm build",
|
|
42
|
-
"test": "vp test",
|
|
43
|
-
"test:watch": "vp test watch",
|
|
44
|
-
"lint": "vp lint .",
|
|
45
|
-
"lint:fix": "vp lint . --fix",
|
|
46
|
-
"format": "vp fmt --write .",
|
|
47
|
-
"format:check": "vp fmt --check .",
|
|
48
|
-
"typecheck": "tsc --noEmit",
|
|
49
|
-
"check": "pnpm typecheck && vp check && vp test && vp pack",
|
|
50
|
-
"commit": "czg",
|
|
51
|
-
"changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -o CHANGELOG.md -r 0",
|
|
52
|
-
"docs:dev": "pnpm -C docs dev",
|
|
53
|
-
"docs:build": "pnpm -C docs build",
|
|
54
|
-
"docs:preview": "pnpm -C docs preview",
|
|
55
|
-
"prepare": "simple-git-hooks"
|
|
56
|
-
},
|
|
57
39
|
"dependencies": {
|
|
58
40
|
"@unocss/core": "^66.11.0"
|
|
59
41
|
},
|
|
@@ -92,5 +74,21 @@
|
|
|
92
74
|
"engines": {
|
|
93
75
|
"node": ">=20.19.0"
|
|
94
76
|
},
|
|
95
|
-
"
|
|
96
|
-
|
|
77
|
+
"scripts": {
|
|
78
|
+
"dev": "vp pack --watch",
|
|
79
|
+
"build": "vp pack",
|
|
80
|
+
"test": "vp test",
|
|
81
|
+
"test:watch": "vp test watch",
|
|
82
|
+
"lint": "vp lint .",
|
|
83
|
+
"lint:fix": "vp lint . --fix",
|
|
84
|
+
"format": "vp fmt --write .",
|
|
85
|
+
"format:check": "vp fmt --check .",
|
|
86
|
+
"typecheck": "tsc --noEmit",
|
|
87
|
+
"check": "pnpm typecheck && vp check && vp test && vp pack",
|
|
88
|
+
"commit": "czg",
|
|
89
|
+
"changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -o CHANGELOG.md -r 0",
|
|
90
|
+
"docs:dev": "pnpm -C docs dev",
|
|
91
|
+
"docs:build": "pnpm -C docs build",
|
|
92
|
+
"docs:preview": "pnpm -C docs preview"
|
|
93
|
+
}
|
|
94
|
+
}
|