@starweave-lab/unocss-preset 0.0.2 → 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 +32 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.en.md
CHANGED
package/README.md
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -239,21 +239,33 @@ function toPercentage(value) {
|
|
|
239
239
|
return `${raw.includes(".") && number <= 1 ? number * 100 : number}%`;
|
|
240
240
|
}
|
|
241
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
|
+
/**
|
|
242
253
|
* Resolves theme colors, opacity modifiers and arbitrary values.
|
|
243
254
|
*
|
|
244
255
|
* - `primary` → theme color
|
|
245
256
|
* - `blue-500` → nested theme color
|
|
246
257
|
* - `primary/50` → `color-mix(...)`
|
|
247
258
|
* - `[#fff]` → `#fff`
|
|
259
|
+
* - `[border-regular]` → the `regular` theme color
|
|
248
260
|
* - `red` / `rgb(1,2,3)` → raw CSS colors
|
|
249
261
|
*/
|
|
250
|
-
function resolveColor(input,
|
|
262
|
+
function resolveColor(input, theme) {
|
|
251
263
|
const [raw, opacity] = splitOpacity(input);
|
|
252
264
|
let resolved;
|
|
253
265
|
if (raw.startsWith("[") && raw.endsWith("]")) {
|
|
254
266
|
const inner = raw.slice(1, -1);
|
|
255
|
-
resolved =
|
|
256
|
-
} else resolved =
|
|
267
|
+
resolved = resolveThemeColor(inner, theme) ?? inner.replaceAll("_", " ");
|
|
268
|
+
} else resolved = resolveThemeColor(raw, theme) ?? (namedColors.has(raw.toLowerCase()) || isColorFunction(raw) ? raw : void 0);
|
|
257
269
|
if (!resolved) return;
|
|
258
270
|
if (opacity === void 0) return resolved;
|
|
259
271
|
const percent = toPercentage(opacity);
|
|
@@ -275,15 +287,12 @@ function resolveColor(input, colors) {
|
|
|
275
287
|
*/
|
|
276
288
|
const borderRules = [[/^b-(?:(all|[trblxy])-)?(?:(solid|dashed|dotted|double)-)?(\d+)-(.+)$/, ([, direction, style, width, color], { theme }) => {
|
|
277
289
|
if (!width || !color) return;
|
|
278
|
-
const
|
|
279
|
-
const resolvedColor = resolveColor(color, theme.colors);
|
|
290
|
+
const resolvedColor = resolveColor(color, theme);
|
|
280
291
|
if (!resolvedColor) return;
|
|
292
|
+
const shorthand = `${width}px ${style ?? "solid"} ${resolvedColor}`;
|
|
281
293
|
const declarations = {};
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
declarations[`border-${s}-style`] = style ?? "solid";
|
|
285
|
-
declarations[`border-${s}-color`] = resolvedColor;
|
|
286
|
-
}
|
|
294
|
+
if (!direction || direction === "all") declarations.border = shorthand;
|
|
295
|
+
else for (const s of borderDirections[direction]) declarations[`border-${s}`] = shorthand;
|
|
287
296
|
return declarations;
|
|
288
297
|
}]];
|
|
289
298
|
const contentVisibilityRules = [
|
|
@@ -338,20 +347,20 @@ const sizes = {
|
|
|
338
347
|
color: "rgba(0, 0, 0, 0.25)"
|
|
339
348
|
}
|
|
340
349
|
};
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
}, {});
|
|
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}`;
|
|
353
361
|
}
|
|
354
|
-
const
|
|
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) }])));
|
|
355
364
|
/**
|
|
356
365
|
* 规则格式: shadow-[方向][-尺寸]
|
|
357
366
|
*
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\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 [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 = lookupColor(colors, inner.split('-')) ?? inner.replaceAll('_', ' ')\n } else {\n resolved =\n lookupColor(colors, raw.split('-')) ??\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 properties = borderDirections[(direction ?? 'all') as BorderDirection]\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 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\nfunction generateBoxShadows() {\n return directions.reduce((acc: BoxShadowStyles, direction: Direction) => {\n Object.keys(sizes).forEach((sizeKey: string) => {\n const size = sizes[sizeKey as SizeKey]\n const key = `${direction}${sizeKey ? '-' + sizeKey : sizeKey}`\n let boxShadow: string\n\n if (direction === 'all') {\n boxShadow = `0px 0px ${size.blur}px ${size.spread}px ${size.color}`\n } else {\n const horizontalOffset = ['l', 'r'].includes(direction)\n ? direction === 'r'\n ? size.offset\n : -size.offset\n : 0\n const verticalOffset = ['t', 'b'].includes(direction)\n ? direction === 'b'\n ? size.offset\n : -size.offset\n : 0\n boxShadow = `${horizontalOffset}px ${verticalOffset}px ${size.blur}px ${size.spread}px ${size.color}`\n }\n acc[key] = { 'box-shadow': boxShadow }\n })\n return acc\n }, {} as BoxShadowStyles)\n}\n\nconst shadows = generateBoxShadows()\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;A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K,KAAK;GAEhG,IAAI,OAAO,EAAE,cAAc,UAAU;EACvC,CAAC;EACD,OAAO;CACT,GAAG,CAAC,CAAoB;AAC1B;AAEA,MAAM,UAAU,mBAAmB;;;;;;;AAQnC,MAAa,cAAsB,CACjC,CACE,uEACC,GAAG,WAAW,MAAM,cAAc;CACjC,MAAM,eAAe,QAAQ;CAC7B,MAAM,MAAM,GAAG,aAAa,QAAQ,eAAe,IAAI,iBAAiB;CACxE,OAAO,QAAQ;AACjB,CACF,CACF;;;AC/DA,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"}
|
|
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;CA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