@snowui-design-system/components 0.2.0-alpha.7 → 0.2.0-alpha.8

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.
Files changed (96) hide show
  1. package/README.md +27 -22
  2. package/package.json +8 -4
  3. package/src/assets/gradient-avatar/blue.svg +1 -0
  4. package/src/assets/gradient-avatar/cyan.svg +1 -0
  5. package/src/assets/gradient-avatar/green.svg +1 -0
  6. package/src/assets/gradient-avatar/orange.svg +1 -0
  7. package/src/assets/gradient-avatar/purple.svg +1 -0
  8. package/src/assets/gradient-avatar/red.svg +1 -0
  9. package/src/components/Accordion.md +1 -1
  10. package/src/components/Accordion.svelte +5 -1
  11. package/src/components/Avatar.md +95 -58
  12. package/src/components/Avatar.svelte +286 -92
  13. package/src/components/Avatar.test.ts +24 -3
  14. package/src/components/Badge.md +31 -2
  15. package/src/components/Badge.svelte +38 -3
  16. package/src/components/Badge.test.ts +14 -1
  17. package/src/components/Button.svelte +7 -1
  18. package/src/components/CodeBlock.md +8 -7
  19. package/src/components/CodeBlock.svelte +59 -25
  20. package/src/components/CodeBlock.test.ts +24 -2
  21. package/src/components/Dialog.svelte +1 -0
  22. package/src/components/Gradient.md +278 -0
  23. package/src/components/Gradient.svelte +1283 -0
  24. package/src/components/Gradient.test.ts +77 -0
  25. package/src/components/Icon.svelte +3 -1
  26. package/src/components/Image.svelte +11 -8
  27. package/src/components/Indicator.md +18 -4
  28. package/src/components/Indicator.svelte +151 -11
  29. package/src/components/Indicator.test.ts +25 -0
  30. package/src/components/Listbox.md +5 -0
  31. package/src/components/Listbox.svelte +26 -0
  32. package/src/components/Listbox.test.ts +14 -0
  33. package/src/components/MenuItem.md +5 -0
  34. package/src/components/MenuItem.svelte +6 -0
  35. package/src/components/Popover.md +5 -0
  36. package/src/components/Popover.svelte +25 -0
  37. package/src/components/Popover.test.ts +14 -0
  38. package/src/components/ScrollArea.md +7 -3
  39. package/src/components/ScrollArea.test.ts +3 -2
  40. package/src/components/SelectButton.svelte +8 -2
  41. package/src/components/Skeleton.md +13 -1
  42. package/src/components/Skeleton.svelte +30 -2
  43. package/src/components/Slider.md +68 -6
  44. package/src/components/Slider.svelte +329 -21
  45. package/src/components/Slider.test.ts +65 -0
  46. package/src/components/SnowUILogo.md +210 -0
  47. package/src/components/SnowUILogo.svelte +478 -0
  48. package/src/components/SnowUILogo.test.ts +62 -0
  49. package/src/components/Table.md +21 -5
  50. package/src/components/Table.svelte +18 -0
  51. package/src/components/TableBody.md +12 -1
  52. package/src/components/TableBody.svelte +26 -2
  53. package/src/components/TableBody.test.ts +3 -0
  54. package/src/components/TableCell.md +9 -3
  55. package/src/components/TableCell.svelte +108 -74
  56. package/src/components/TableCell.test.ts +2 -2
  57. package/src/components/TableHead.md +9 -3
  58. package/src/components/TableHead.svelte +36 -39
  59. package/src/components/TableHead.test.ts +5 -5
  60. package/src/components/TableRow.md +15 -5
  61. package/src/components/TableRow.svelte +47 -10
  62. package/src/components/TableRow.test.ts +2 -2
  63. package/src/components/TableToolbar.svelte +8 -3
  64. package/src/components/Text.md +7 -1
  65. package/src/components/Text.svelte +15 -7
  66. package/src/components/Tooltip.md +13 -4
  67. package/src/components/Tooltip.svelte +45 -7
  68. package/src/components/Tooltip.test.ts +27 -3
  69. package/src/index.ts +7 -0
  70. package/src/lib/color.md +2 -2
  71. package/src/lib/edge-fade.md +1 -0
  72. package/src/lib/overlay-scrollbar.md +6 -1
  73. package/src/lib/table-context.svelte.ts +11 -0
  74. package/src/lib/table-role-blur.ts +46 -0
  75. package/src/lib/table-truncation.md +14 -0
  76. package/src/lib/table-truncation.ts +83 -0
  77. package/src/lib/tooltip-motion-dismiss.md +18 -0
  78. package/src/lib/tooltip-motion-dismiss.ts +148 -0
  79. package/src/lib/tooltip-overlay.ts +9 -0
  80. package/src/logic/README.md +4 -1
  81. package/src/logic/continuous-hover.svelte.md +22 -0
  82. package/src/logic/continuous-hover.svelte.ts +436 -0
  83. package/src/logic/frame-truncation.md +9 -3
  84. package/src/logic/frame-truncation.svelte.ts +6 -0
  85. package/src/logic/layout-flip.ts +182 -5
  86. package/src/motion/presets/README.md +1 -0
  87. package/src/motion/presets/continuous-hover.md +11 -0
  88. package/src/motion/presets/continuous-hover.ts +18 -0
  89. package/src/motion/tokens.md +3 -1
  90. package/src/motion/tokens.ts +2 -0
  91. package/src/styles/README.md +16 -2
  92. package/src/styles/components.css +911 -0
  93. package/src/styles/index.css +3 -1
  94. package/src/styles/layout.css +44 -0
  95. package/src/styles/scrollbar.css +27 -7
  96. package/src/styles/themes.css +146 -0
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # SnowUI Components 项目说明
2
2
 
3
- > **版本**: v1.1.0
4
- > **更新**: 2026-02-05
3
+ > **版本**: v2.0.0
4
+ > **更新**: 2026-07-13
5
5
  > **职责**: 项目结构与开发环境说明
6
6
 
7
7
  ## 1. 项目概览
@@ -9,15 +9,15 @@
9
9
  ### 技术方案
10
10
  - **框架**: Svelte 5 (Runes API)
11
11
  - **构建**: Vite + TypeScript
12
- - **包管理**: npm workspaces
13
- - **样式**: 原生 CSS + `snowui.css` (Design System)
12
+ - **包管理**: pnpm 独立 workspace
13
+ - **样式**: 包内 `src/styles/`,不依赖 `SnowUI/home` 或上级 `styles/`
14
14
 
15
15
  ### 依赖关系
16
16
  - **@snowui-design-system/resource-svelte**:
17
17
  - **用途**: 提供图标、头像、插画等静态资源组件。
18
18
  - **引用方式**:
19
19
  - 生产代码: `import { IconName } from "@snowui-design-system/resource-svelte";`
20
- - Vite 配置: 开发环境已通过 `alias` 映射到本地 workspace 源码。
20
+ - Vite 配置: 使用已发布 npm 包。
21
21
 
22
22
  ---
23
23
 
@@ -27,9 +27,9 @@
27
27
  | :--- | :--- |
28
28
  | `src/components/` | 组件源码 (`.svelte`)、文档 (`.md`)、测试 (`.test.ts`) |
29
29
  | `src/logic/` | 共享 TypeScript 逻辑 (`Frame Context`, `Context`) |
30
- | `src/styles/` | 共享 CSS (`layout.css`, `skeleton.css`) |
31
- | `src/test/` | 组件预览和测试环境 |
32
- | `src/demo/` | AI 调试用 Demo 文件 (不提交生产) |
30
+ | `src/styles/` | Components 完整共享 CSS(含 `themes.css`、`components.css`、layout、tokens、scale、scrollbar) |
31
+ | `.github/workflows/` | 独立 CI 与 npm tag 发布流程 |
32
+ | `scripts/` | OSS 边界与样式自包含检查 |
33
33
 
34
34
  ---
35
35
 
@@ -44,27 +44,32 @@ Frame 是所有 SnowUI 组件的基石。**开发任何组件前,必须了解
44
44
 
45
45
  ## 4. 开发规范
46
46
 
47
- > **核心文档**: 所有开发活动必须遵循 [AI_GUIDELINES.md](../AI_GUIDELINES.md) 和 [ComponentGuidelines.md](../specs/ComponentGuidelines.md)。
47
+ > **核心文档**: 完整规范位于本机聚合目录的 `../specs/`,不属于本 GitHub 仓库。
48
48
 
49
- ### 样式系统 (snowui.css)
49
+ ### 样式系统
50
50
 
51
- 本项目**严禁使用 Tailwind CSS**。必须使用 `snowui.css` 提供的 Token 变量与工具类。
51
+ 本项目**严禁使用 Tailwind CSS**。组件样式只消费 `src/styles/`。
52
52
 
53
- - **Token 映射**: 参考 [FigmaToSnowUI.md](../specs/FigmaToSnowUI.md)
54
- - **样式规范**: 参考 [StyleGuide.md](../specs/StyleGuide.md)
53
+ 消费方引入完整组件样式:
54
+
55
+ ```css
56
+ @import "@snowui-design-system/components/styles";
57
+ ```
58
+
59
+ - `src/styles/themes.css`:包内主题;只允许项目所有者与 `../styles/snowui-themes.css` 手工同步。
60
+ - `src/styles/components.css`:公开 override 变量入口。
61
+ - AI、CI 与脚本只能验证主题一致性,不得自动复制或覆盖。
55
62
 
56
63
  ---
57
64
 
58
65
  ## 5. 测试与验证
59
66
 
60
- ### 测试项目 (`src/test`)
61
- - **启动**: `npm run dev`
62
- - **组件注册**: 新组件必须在 `src/test/component-registry.ts` 注册,并在 `src/index.ts` 导出
63
-
64
- ### 调试 Playground
65
- - **用户测试**: `src/Playground.svelte` (不要修改)
66
- - **AI 调试**: `src/demo/Demo.svelte` (不提交生产)
67
- - **测试列表**: 访问 `/?page=test-list`
67
+ - **安装**: `pnpm install --frozen-lockfile`
68
+ - **样式自包含**: `pnpm verify:styles`
69
+ - **OSS 边界**: `pnpm check:oss`
70
+ - **类型检查**: `node_modules/.bin/svelte-check --tsconfig tsconfig.json`
71
+ - **构建**: `pnpm build`
72
+ - **打包预览**: `npm pack --dry-run`
68
73
 
69
74
  ---
70
75
 
@@ -78,4 +83,4 @@ Frame 是所有 SnowUI 组件的基石。**开发任何组件前,必须了解
78
83
  ## 7. 评审与发布
79
84
 
80
85
  - **Review**: 组件开发完成后,调用 `review` 技能进行自我审查
81
- - **发布**: 遵循语义化版本 (SemVer)
86
+ - **发布**: 在本仓库推送与 `package.json` 一致的 `v*` tag,由 GitHub Actions 发布 npm。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowui-design-system/components",
3
- "version": "0.2.0-alpha.7",
3
+ "version": "0.2.0-alpha.8",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,7 +19,9 @@
19
19
  "./logic/*.svelte": "./src/logic/*.svelte.ts",
20
20
  "./logic/*": "./src/logic/*.ts",
21
21
  "./motion/*.css": "./src/motion/*.css",
22
- "./motion/*": "./src/motion/*.ts"
22
+ "./motion/*": "./src/motion/*.ts",
23
+ "./styles": "./src/styles/index.css",
24
+ "./styles/*": "./src/styles/*"
23
25
  },
24
26
  "files": [
25
27
  "src",
@@ -51,7 +53,9 @@
51
53
  "dev": "vite",
52
54
  "build": "vite build",
53
55
  "preview": "vite preview",
54
- "check:standards": "node ../../scripts/check-standards.js",
55
- "fix:standards": "node ../../scripts/check-standards.js --fix"
56
+ "check:standards": "node ../scripts/check-standards.js",
57
+ "fix:standards": "node ../scripts/check-standards.js --fix",
58
+ "check:oss": "node scripts/check-oss-deps.mjs",
59
+ "verify:styles": "node scripts/verify-styles.mjs"
56
60
  }
57
61
  }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 360" preserveAspectRatio="none"><defs><filter id="v4" x="-245.611" y="-286.49" width="921.128" height="796.487" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="60"/></filter><filter id="v3" x="-29.5047" y="-133.435" width="624.294" height="621.927" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="60"/></filter><filter id="s1" x="-16.1127" y="-99.2028" width="555.729" height="639.235" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="40"/></filter><filter id="s2" x="-93.4444" y="-230.518" width="734.724" height="616.471" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="50"/></filter><clipPath id="c"><rect width="360" height="360"/></clipPath></defs><g clip-path="url(#c)"><rect width="360" height="360" fill="#290082"/><g filter="url(#v4)"><ellipse cx="214.952" cy="111.754" rx="384.575" ry="213.162" transform="rotate(-146.037 214.952 111.754)" fill="#58B7FF"/></g><g filter="url(#v3)"><ellipse cx="282.642" cy="177.528" rx="223.026" ry="153.731" transform="rotate(-135.496 282.642 177.528)" fill="#6560FF"/></g><g filter="url(#s1)"><path d="M63.8873-19.2028C116.398 1.25526 169.035 25.0829 221.278 52.3178 285.966 86.04 346.709 123.243 403 163.081 584.414 291.473 271.178 628.302 278.61 357.5 282.932 200.002 197.822 55.4726 63.8873-19.2028Z" fill="#3AF2FC"/></g><g filter="url(#s2)"><path d="M417.77-97.6118C594.82 20.5018 571.194 414.723 412.576 243.5 361.565 188.436 300.326 136.413 230.397 90.6631 173.62 53.5181 115.35 23.2776 57.5.00434098-138.842-78.9842 286.515-185.174 417.77-97.6118Z" fill="#D4E6FE"/></g></g></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 360" preserveAspectRatio="none"><defs><filter id="v4" x="-245.611" y="-286.49" width="921.128" height="796.487" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="60"/></filter><filter id="v3" x="-29.5047" y="-133.435" width="624.294" height="621.927" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="60"/></filter><filter id="s1" x="-16.1127" y="-99.2028" width="555.729" height="639.235" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="40"/></filter><filter id="s2" x="-93.4444" y="-230.518" width="734.724" height="616.471" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="50"/></filter><clipPath id="c"><rect width="360" height="360"/></clipPath></defs><g clip-path="url(#c)"><rect width="360" height="360" fill="#0B005A"/><g filter="url(#v4)"><ellipse cx="214.952" cy="111.754" rx="384.575" ry="213.162" transform="rotate(-146.037 214.952 111.754)" fill="#5BE4FF"/></g><g filter="url(#v3)"><ellipse cx="282.642" cy="177.528" rx="223.026" ry="153.731" transform="rotate(-135.496 282.642 177.528)" fill="#00A5BE"/></g><g filter="url(#s1)"><path d="M63.8873-19.2028C116.398 1.25526 169.035 25.0829 221.278 52.3178 285.966 86.04 346.709 123.243 403 163.081 584.414 291.473 271.178 628.302 278.61 357.5 282.932 200.002 197.822 55.4726 63.8873-19.2028Z" fill="#31FF83"/></g><g filter="url(#s2)"><path d="M417.77-97.6118C594.82 20.5018 571.194 414.723 412.576 243.5 361.565 188.436 300.326 136.413 230.397 90.6631 173.62 53.5181 115.35 23.2776 57.5.00434098-138.842-78.9842 286.515-185.174 417.77-97.6118Z" fill="#D4FEEF"/></g></g></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 360" preserveAspectRatio="none"><defs><filter id="v4" x="-245.611" y="-286.49" width="921.128" height="796.487" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="60"/></filter><filter id="v3" x="-29.5047" y="-133.435" width="624.294" height="621.927" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="60"/></filter><filter id="s1" x="-16.1127" y="-99.2028" width="555.729" height="639.235" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="40"/></filter><filter id="s2" x="-93.4444" y="-230.518" width="734.724" height="616.471" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="50"/></filter><clipPath id="c"><rect width="360" height="360"/></clipPath></defs><g clip-path="url(#c)"><rect width="360" height="360" fill="#000A4E"/><g filter="url(#v4)"><ellipse cx="214.952" cy="111.754" rx="384.575" ry="213.162" transform="rotate(-146.037 214.952 111.754)" fill="#3DE680"/></g><g filter="url(#v3)"><ellipse cx="282.642" cy="177.528" rx="223.026" ry="153.731" transform="rotate(-135.496 282.642 177.528)" fill="#16B335"/></g><g filter="url(#s1)"><path d="M63.8873-19.2028C116.398 1.25526 169.035 25.0829 221.278 52.3178 285.966 86.04 346.709 123.243 403 163.081 584.414 291.473 271.178 628.302 278.61 357.5 282.932 200.002 197.822 55.4726 63.8873-19.2028Z" fill="#C6F94F"/></g><g filter="url(#s2)"><path d="M417.77-97.6118C594.82 20.5018 571.194 414.723 412.576 243.5 361.565 188.436 300.326 136.413 230.397 90.6631 173.62 53.5181 115.35 23.2776 57.5.00434098-138.842-78.9842 286.515-185.174 417.77-97.6118Z" fill="#DFFED4"/></g></g></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 360" preserveAspectRatio="none"><defs><filter id="v4" x="-245.611" y="-286.49" width="921.128" height="796.487" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="60"/></filter><filter id="v3" x="-29.5047" y="-133.435" width="624.294" height="621.927" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="60"/></filter><filter id="s1" x="-16.1127" y="-99.2028" width="555.729" height="639.235" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="40"/></filter><filter id="s2" x="-93.4444" y="-230.518" width="734.724" height="616.471" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="50"/></filter><clipPath id="c"><rect width="360" height="360"/></clipPath></defs><g clip-path="url(#c)"><rect width="360" height="360" fill="#EC2300"/><g filter="url(#v4)"><ellipse cx="214.952" cy="111.754" rx="384.575" ry="213.162" transform="rotate(-146.037 214.952 111.754)" fill="#FFC654"/></g><g filter="url(#v3)"><ellipse cx="282.642" cy="177.528" rx="223.026" ry="153.731" transform="rotate(-135.496 282.642 177.528)" fill="#FF6C04"/></g><g filter="url(#s1)"><path d="M63.8873-19.2028C116.398 1.25526 169.035 25.0829 221.278 52.3178 285.966 86.04 346.709 123.243 403 163.081 584.414 291.473 271.178 628.302 278.61 357.5 282.932 200.002 197.822 55.4726 63.8873-19.2028Z" fill="#FF14AD"/></g><g filter="url(#s2)"><path d="M417.77-97.6118C594.82 20.5018 571.194 414.723 412.576 243.5 361.565 188.436 300.326 136.413 230.397 90.6631 173.62 53.5181 115.35 23.2776 57.5.00434098-138.842-78.9842 286.515-185.174 417.77-97.6118Z" fill="#FEF0D4"/></g></g></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 360" preserveAspectRatio="none"><defs><filter id="v4" x="-245.611" y="-286.49" width="921.128" height="796.487" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="60"/></filter><filter id="v3" x="-29.5047" y="-133.435" width="624.294" height="621.927" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="60"/></filter><filter id="s1" x="-16.1127" y="-99.2028" width="555.729" height="639.235" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="40"/></filter><filter id="s2" x="-93.4444" y="-230.518" width="734.724" height="616.471" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="50"/></filter><clipPath id="c"><rect width="360" height="360"/></clipPath></defs><g clip-path="url(#c)"><rect width="360" height="360" fill="#1E0069"/><g filter="url(#v4)"><ellipse cx="214.952" cy="111.754" rx="384.575" ry="213.162" transform="rotate(-146.037 214.952 111.754)" fill="#C6BAFF"/></g><g filter="url(#v3)"><ellipse cx="282.642" cy="177.528" rx="223.026" ry="153.731" transform="rotate(-135.496 282.642 177.528)" fill="#F935FC"/></g><g filter="url(#s1)"><path d="M63.8873-19.2028C116.398 1.25526 169.035 25.0829 221.278 52.3178 285.966 86.04 346.709 123.243 403 163.081 584.414 291.473 271.178 628.302 278.61 357.5 282.932 200.002 197.822 55.4726 63.8873-19.2028Z" fill="#FFF78E"/></g><g filter="url(#s2)"><path d="M417.77-97.6118C594.82 20.5018 571.194 414.723 412.576 243.5 361.565 188.436 300.326 136.413 230.397 90.6631 173.62 53.5181 115.35 23.2776 57.5.00434098-138.842-78.9842 286.515-185.174 417.77-97.6118Z" fill="#FED4F5"/></g></g></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 360" preserveAspectRatio="none"><defs><filter id="v4" x="-245.611" y="-286.49" width="921.128" height="796.487" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="60"/></filter><filter id="v3" x="-29.5047" y="-133.435" width="624.294" height="621.927" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="60"/></filter><filter id="s1" x="-16.1127" y="-99.2028" width="555.729" height="639.235" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="40"/></filter><filter id="s2" x="-93.4444" y="-230.518" width="734.724" height="616.471" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="b"/><feBlend in="SourceGraphic" in2="b"/><feGaussianBlur stdDeviation="50"/></filter><clipPath id="c"><rect width="360" height="360"/></clipPath></defs><g clip-path="url(#c)"><rect width="360" height="360" fill="#320061"/><g filter="url(#v4)"><ellipse cx="214.952" cy="111.754" rx="384.575" ry="213.162" transform="rotate(-146.037 214.952 111.754)" fill="#FF7CB0"/></g><g filter="url(#v3)"><ellipse cx="282.642" cy="177.528" rx="223.026" ry="153.731" transform="rotate(-135.496 282.642 177.528)" fill="#FC3551"/></g><g filter="url(#s1)"><path d="M63.8873-19.2028C116.398 1.25526 169.035 25.0829 221.278 52.3178 285.966 86.04 346.709 123.243 403 163.081 584.414 291.473 271.178 628.302 278.61 357.5 282.932 200.002 197.822 55.4726 63.8873-19.2028Z" fill="#F9E84F"/></g><g filter="url(#s2)"><path d="M417.77-97.6118C594.82 20.5018 571.194 414.723 412.576 243.5 361.565 188.436 300.326 136.413 230.397 90.6631 173.62 53.5181 115.35 23.2776 57.5.00434098-138.842-78.9842 286.515-185.174 417.77-97.6118Z" fill="#FED4D5"/></g></g></svg>
@@ -94,7 +94,7 @@ gap 归属:Root 通过 `--snowui-accordion-gap` 管理子项间距;Title 与
94
94
  | `--snowui-accordion-icon-size` | `var(--size-5)` | md 图标尺寸;sm/lg 分别为 `--size-4` / `--size-6` |
95
95
  | `--snowui-accordion-content-max-block-size-override` | `100vh` | Content 展开时的最大高度覆盖入口,用于极长内容场景 |
96
96
 
97
- 公开覆盖入口见 [../../../styles/snowui-components.css](../../../styles/snowui-components.css) 的 Accordion 段。
97
+ 公开覆盖入口见 [components.css](../styles/components.css) 的 Accordion 段。
98
98
 
99
99
  ## 无障碍
100
100
 
@@ -90,7 +90,11 @@
90
90
  return type === "multiple" ? values : (values[0] ?? "");
91
91
  }
92
92
 
93
- let internalValues = $state<string[]>(normalizeValue(defaultValue));
93
+ function resolveInitialValues() {
94
+ return normalizeValue(defaultValue);
95
+ }
96
+
97
+ let internalValues = $state<string[]>(resolveInitialValues());
94
98
  const selectedValues = $derived(normalizeValue(value ?? internalValues));
95
99
 
96
100
  function isOpen(itemValue: string): boolean {
@@ -1,6 +1,11 @@
1
1
  # Avatar.svelte 文档
2
2
 
3
- > **版本**: v2.4.19
3
+ > **版本**: v2.12.0
4
+ > **变更记录 (2026-08-06)**: 默认 Gradient 头像常态改为轻量共享静态图;仅 hover 或 `gradientMotion` 开启时挂载完整 Gradient 组件,降低长表格中的组件、响应式状态与 SVG 资源开销。
5
+ > **变更记录 (2026-08-03)**: 修复外部 Badge / Icon 子内容被内部 Frame 片段遮蔽的问题;Avatar 根盒统一使用中线对齐,确保 `empty` 与图片、Gradient 头像同排等高。
6
+ > **变更记录 (2026-08-03)**: 默认 Gradient 头像 hover 使用七段非对称路径;每次进入随机切换且不重复上一组相位 / 方向配置。
7
+ > **变更记录 (2026-08-02)**: 默认头像改为随机 Gradient;原灰色用户图标改为 `empty` 空头像变体;Avatar 单色 hover 通过像素 alpha 仅叠加实际图形。
8
+ > **变更记录 (2026-08-02)**: Avatar 默认 hover 使用单层 Overlay;每次进入随机六色之一,同一次 hover 内颜色不变,默认文字与用户图标位于叠加层上方。
4
9
  > **变更记录 (2026-06-10)**: 新增 `fallback` 组件入口,允许 PRO `GradientMotion` 等视觉组件作为默认头像;补充 `as="avatar-image"` 头像图片层组合规则。
5
10
  > **变更记录 (2026-05-20)**: 点击型 Avatar 补齐 `cursor: pointer`,与 hover 视觉反馈保持一致。
6
11
  > **变更记录 (2026-03-10)**: 补全文档中的 hover 实现方式与样式定义,明确有图 / 首字母 / 默认回退三种 hover 分支。
@@ -17,7 +22,8 @@
17
22
  主布局模型:内禀原子布局。
18
23
 
19
24
  - Avatar 的根节点只暴露一个由 `size` / 父级尺寸上下文 / `renderHints` 决定的头像盒,作为 Button、MenuItem、Field 等外部布局的子项时表现为 Hug。
20
- - 内部图片层、首字母层、默认图标层、hover 层与 badge 切割遮罩都属于 Avatar 私有布局,不对外暴露 Leading / Content / Trailing 槽位。
25
+ - Avatar 作为 inline-level 原子盒时统一使用中线对齐,内部图片、Gradient 与 `empty` 图标不得改变同排头像的垂直位置。
26
+ - 内部图片层、默认 Gradient / empty 图标层、hover 滤镜与 badge 切割遮罩都属于 Avatar 私有布局,不对外暴露 Leading / Content / Trailing 槽位。
21
27
  - `as="badge"` 只用于 Avatar 内部识别角标角色;Avatar 自身不会输出 `data-auto-layout`,也不会接管子组件的通用排列能力。
22
28
  - 外部需要排列多个头像时应使用 `AvatarGroup`,不要把 Avatar 改造成集合布局。
23
29
 
@@ -27,7 +33,9 @@
27
33
  | :--- | :--- | :--- | :--- |
28
34
  | src | string \| Component | undefined | 头像图片 URL 或图标组件 |
29
35
  | size | 12\|16\|20\|24\|28\|32\|40\|48\|80 | 16 | 头像尺寸。未显式设置时,自动继承父级 `Frame` (如 `AvatarGroup`) 提供的尺寸上下文。 |
30
- | fallback | Component | undefined | 无 `src` 或图片不可用时渲染的默认头像组件。PRO 场景可传 `GradientMotion`,Avatar 会传入 `as="avatar-image"`、`size="100%"`、`radius="inherit"` 与基于名称的 `seed`。 |
36
+ | fallback | Component | undefined | 无 `src` 或图片不可用时渲染的自定义头像组件;未传时默认内置 Gradient。PRO 场景可传 `GradientMotion`,Avatar 会传入 `as="avatar-image"`、`size="100%"`、`radius="inherit"` 与基于名称的 `seed`。 |
37
+ | variant | `'default' \| 'empty'` | `'default'` | `default` 使用按实例 / 名称稳定分散的 Gradient 配色;`empty` 使用灰色背景与默认用户图标。 |
38
+ | gradientMotion | boolean | false | 是否常驻运行默认 Gradient fallback 的四层基础矢量形变;为 false 时 Gradient 仍会在 hover 期间按需运行水波形变和多色 Overlay |
31
39
  | badgePosition | 'top'\|'bottom' | 'top' | 徽章位置 |
32
40
 
33
41
  ## 关键字 (Keyword)
@@ -47,9 +55,15 @@
47
55
  <!-- 使用图标资源 -->
48
56
  <Avatar src={User} />
49
57
 
50
- <!-- 无 src:显示默认头像图标 -->
58
+ <!-- 无 src:显示默认随机 Gradient 头像 -->
51
59
  <Avatar />
52
60
 
61
+ <!-- 显式开启默认 Gradient 的基础矢量形变 -->
62
+ <Avatar gradientMotion />
63
+
64
+ <!-- 空头像:显示灰色背景与用户图标 -->
65
+ <Avatar variant="empty" />
66
+
53
67
  <!-- PRO 默认头像:使用 GradientMotion 作为默认头像 -->
54
68
  <Avatar fallback={GradientMotion} data-name="Ada Lovelace" />
55
69
 
@@ -67,12 +81,12 @@
67
81
 
68
82
  ## 智能行为
69
83
 
70
- 1. **默认回退**: 无图片或图片加载失败时,优先显示 `fallback` 组件;未传 `fallback` 时显示首字母;无首字母时显示默认用户图标。
84
+ 1. **默认回退**: 无图片或图片加载失败时,优先显示显式 `fallback` 组件;未传时 `default` 使用 Gradient,`empty` 使用灰色用户图标。名称只作为 Gradient seed,不再生成首字母;Gradient 常态基础形变默认关闭,可用 `gradientMotion` 常驻开启,或由 hover 按需运行。
71
85
  2. **回退延迟**: 内部固定延迟显示回退图标,减少加载闪烁。
72
86
  3. **角色识别**: 内部组件 (`Badge`, `Icon`) 若设置 `as="badge"` 将自动获得定位与尺寸逻辑。
73
87
  4. **子组件定位**: 提供基于 `em` 的自适应 Context 渲染样式。
74
88
  5. **智能分辨率选择**: 自动将解析后的尺寸(Resolved Size)传递给资源组件(如 `AvatarByewind`),资源组件会根据该尺寸选择 **3x 分辨率** 的高精图片(例如 80px 尺寸选择 240px 图片)。
75
- 6. **Hover 分支**: Avatar 的 hover 由组件自身维护,不走全局统一样式;根据有图、首字母、默认回退三种状态命中不同节点。
89
+ 6. **默认 Hover**: 非 disabled 图片与普通组件头像每次进入时随机选择 blue / cyan / green / red / orange / purple 之一,并只对实际图形 alpha 单层叠加;Gradient fallback 无论常态基础形变是否开启,都保持原有五色循环,并按需运行不同周期的四层水波形变。
76
90
 
77
91
  ## 样式规范 (Style Spec)
78
92
 
@@ -135,63 +149,29 @@
135
149
  - 默认文字颜色:`color: currentColor`
136
150
  - 图片模式(`snowui-avatar-has-image`):`background-color: transparent`
137
151
 
138
- **Frame Hover 集成**
139
- - Avatar 保留默认 `.snowui-hoverable`,继续继承点击型语义与默认点击动效。
140
- - 组件通过自身 hover 选择器关闭 `Surface` 的默认 hover 背景叠加层,不再在 Avatar 内部定义 Frame 命名空间变量。
141
- - Avatar 的 hover 视觉规则定义在组件内,不再放在 `src/styles/layout.css`。
142
- - Avatar 的 hover 视觉只作用于内部视觉层或背景层,不直接改写根节点几何属性,也不使用命令式 JS 状态。
143
- - 所有 hover 规则必须排除 `.snowui-disabled`、`[data-disabled="true"]` 与 `:disabled`。
144
-
145
- **首字母回退 `.snowui-avatar-initials`**
146
- - 触发条件:无图片且具备 `aria-label` / `data-name` / `title`
147
- - 仅显示 **1 个首字母**(大写)
148
- - 字体大小:`0.375em`(与默认图标大小一致)
149
- - 字重:`600`
150
- - 字体颜色:`var(--static-white-100, #ffffff)`
151
- - 背景色:从次要色 token 随机选择(见下方 `secondaryColors` 列表)
152
-
153
- **次要色候选 `secondaryColors`**
154
- - `var(--secondary-purple, #7c3aed)`
155
- - `var(--secondary-indigo, #4f46e5)`
156
- - `var(--secondary-blue, #3b82f6)`
157
- - `var(--secondary-cyan, #06b6d4)`
158
- - `var(--secondary-mint, #10b981)`
159
- - `var(--secondary-green, #22c55e)`
160
- - `var(--secondary-yellow, #eab308)`
161
- - `var(--secondary-orange, #f97316)`
162
- - `var(--secondary-red, #ef4444)`
163
-
164
- ### 5. Hover 规范 (Hover Spec)
165
-
166
- > **v2026-05-20 起 Hover 实现迁移至共享工具类**:Avatar 与 Image 共用 [`components/src/styles/layout.css`](../styles/layout.css) 中的 `.snowui-media-hoverable` 工具类家族,组件不再在 .svelte 内自定义 hover 选择器。具体行为由根类组合决定。
167
-
168
- **根类组合规则(由组件 JS 条件挂载)**
152
+ **Avatar Hover 集成**
153
+ - 非 disabled 根节点挂 `.snowui-avatar-interactive`,由 Avatar 自身提供 pointer cursor 与单层颜色 Overlay;默认 Gradient 头像是唯一例外,恢复认可版本的 `.snowui-media-hoverable` / `.snowui-media-hoverable-has-visual` 与 `brightness(0.92)` 组合。
154
+ - Overlay 位于 `.snowui-avatar-container` 内、完整视觉内容上方和外部 Badge 下方,继承头像圆角与裁切。
155
+ - 每次 pointer enter 从六种 Gradient 中心主色中等概率随机选择一种;同一次 hover 内不运行颜色变化动画。
156
+ - Avatar 单色 Overlay 通过 SVG alpha composite 只作用于图片或组件实际绘制的非透明图形,透明区域保持不变;fallbackText 与 empty 用户图标不参与染色。
157
+ - Gradient fallback 自行拥有多色循环 hover,并在常态静态模式下按需淡入实时 SVG 水波形变;Avatar 不再对其重复叠加单色层。
158
+ - 只过渡一个小画布纯色层的 opacity,默认峰值 `58%`、入口 / 退出 `0.5s`。
159
+ - 所有 hover 规则排除 `.snowui-disabled`、`[data-disabled="true"]` 与 `:disabled`;reduced-motion 下关闭淡入淡出并保留静态随机色反馈。
169
160
 
170
- | Avatar 状态 | 根挂的工具类组合 | hover 视觉效果(由工具类提供) |
171
- | :--- | :--- | :--- |
172
- | 有图模式(`isImageMode`) | `.snowui-media-hoverable` + `.snowui-media-hoverable-has-visual` | `.snowui-avatar-visual` 层 `filter: brightness(0.92)`(媒体本身压暗) |
173
- | 首字母模式(`hasInitials` 且非有图) | `.snowui-media-hoverable` + `.snowui-media-hoverable-tinted-bg` | `.snowui-avatar-background` 层 `filter: brightness(0.92)`(有色填充背景压暗) |
174
- | 默认回退(空 fallback) | 只挂 `.snowui-media-hoverable` | `.snowui-avatar-background` 层 `background-color: var(--black-10)`(灰底变深) |
175
- | fallback 组件模式 | `.snowui-media-hoverable` + `.snowui-media-hoverable-has-visual` | fallback 组件作为 `.snowui-avatar-visual` 内容,视觉层 `filter: brightness(0.92)` |
176
- | disabled | 都不挂 | 无 hover 反馈 + cursor: default |
161
+ **默认 / 空头像**
162
+ - `default`:常态直接渲染按 seed 选择的共享 Gradient 静态图,seed 优先使用 `aria-label` / `data-name` / `title`,无名称时使用实例 ID,使同屏默认头像自然分散到六种配色。完整 Gradient 组件只在 hover 期间按需挂载并在退出动效完成后释放;`gradientMotion` 开启时保持常驻。
163
+ - `empty`:保留 `var(--black-4)` 灰色背景与 resource-svelte `user` 图标,明确表达尚无头像内容。
177
164
 
178
- > **两种技术分工**:`has-visual` 和 `tinted-bg` 用 `filter: brightness(0.92)` 压暗目标层(媒体或有色背景);空 fallback 用 `background-color: var(--black-10)` 替换灰底色(灰底直接改背景色最直接,brightness 在浅灰上几乎不可见)。三者完全由 layout.css 工具类家族统一管理,Avatar 组件不再自定义 hover 选择器。
179
-
180
- **内部分层标记(由组件模板始终挂载)**
165
+ ### 5. Hover 规范 (Hover Spec)
181
166
 
182
- | 内部层 | 工具类标记 |
167
+ | 状态 | 默认效果 |
183
168
  | :--- | :--- |
184
- | `.snowui-avatar-background` | 同时挂 `.snowui-media-hoverable-background` |
185
- | `.snowui-avatar-visual`(仅有图态 `imageStatus === "loaded"`) | 同时挂 `.snowui-media-hoverable-visual` |
169
+ | 图片 / Component src | 每次进入随机六色之一,通过 alpha composite 只叠加实际非透明图形 |
170
+ | fallback 组件 | Avatar 单色层只染实际图形;Gradient fallback 改由 Gradient 自身播放多色循环 |
171
+ | fallbackText / empty 用户图标 | 不叠加颜色,保持原色 |
172
+ | disabled | 不创建可运行 hover 状态,不显示 Overlay,cursor 为 default |
186
173
 
187
- **目的**:
188
- - 兼容规则和不规则图片(brightness filter 不会染色透明区)
189
- - 避免黑色遮罩把透明区域整块盖黑
190
- - 只影响头像视觉层,不影响角标区域
191
- - 首字母文本本身不变色,只让背景变暗
192
- - 默认头像图标或回退文本不变色,只让背景加深
193
-
194
- **覆盖入口**:`--snowui-media-hover-brightness`(默认 `0.92`,同时用于 has-visual 与 tinted-bg)
174
+ 覆盖入口:`--snowui-avatar-hover-entry-duration`(默认 `0.5s`)、`--snowui-avatar-hover-entry-easing`、`--snowui-avatar-hover-color-opacity`(默认 `0.58`)。
195
175
 
196
176
  **图片层 `.snowui-avatar-image`**
197
177
  - `width/height: 100%`,`object-fit: cover`
@@ -225,8 +205,65 @@
225
205
 
226
206
  ## 更新日志
227
207
 
208
+ ### v2.12.0 (2026-08-06)
209
+
210
+ - 默认 Gradient fallback 常态不再为每个 Avatar 创建完整 Gradient 组件、实例 ID、hover 状态与响应式派生链,只渲染共享静态图。
211
+ - hover 时按需挂载完整 Gradient 水波与五色 Overlay,退出 0.5 秒后回收;`gradientMotion` 继续显式常驻完整 Gradient。
212
+ - 静态图使用原生 lazy loading、异步解码和低请求优先级,长表格只优先处理视口附近头像。
213
+
214
+ ### v2.11.1 (2026-08-03)
215
+
216
+ - 修复外部传入的 Badge / Icon 子内容被内部 Frame `children` 片段同名遮蔽、未进入 DOM 的问题。
217
+ - Avatar 根盒统一使用 `vertical-align: middle`,使 `empty`、图片与 Gradient 头像在同一行保持一致的垂直位置。
218
+
219
+ ### v2.11.0 (2026-08-03)
220
+
221
+ - 默认 Gradient fallback 的四层水波改为七段非对称闭环路径,避免可见的 A→B→A 原路折返。
222
+ - 每次 hover 从六组相位 / 方向组合中随机选择且不重复上一组;不增加活动图层、filter 或逐帧 JavaScript。
223
+
224
+ ### v2.10.0 (2026-08-02)
225
+
226
+ - 默认 Gradient Avatar 常态继续使用缓存静态图,hover 时由 Gradient 按需淡入四层独立周期的水波形变;离开后释放实时 SVG 与 filter。
227
+ - `gradientMotion` 语义收窄为“是否常驻运行”,不再阻止默认 hover 的按需水波形变。
228
+
229
+ ### v2.9.1 (2026-08-02)
230
+
231
+ - 默认 Gradient fallback 的四层基础矢量形变改为关闭,新增 `gradientMotion` 显式开启入口。
232
+ - Gradient 自有的认可版本五色 Overlay hover 不受基础形变开关影响。
233
+
234
+ ### v2.9.0 (2026-08-02)
235
+
236
+ - 根据认可版本的原始运行条件,默认 Gradient 头像恢复 `.snowui-media-hoverable`、`.snowui-media-hoverable-has-visual` 与 `.snowui-media-hoverable-visual` 三层契约。
237
+ - Gradient 重新位于普通 visual 容器内并同时获得旧版 `brightness(0.92)` 反馈;仍跳过 Avatar 当前的单色 alpha filter,图片、Logo 与其他 fallback 保持现状。
238
+
239
+ ### v2.8.0 (2026-08-02)
240
+
241
+ - 默认 Gradient fallback 改用专用直连渲染路径,不再经过普通 `.snowui-avatar-visual` 与 Avatar SVG 单色滤镜合成层。
242
+ - Gradient 直接成为圆形裁切容器的视觉内容;Avatar 只负责尺寸、最外层裁切、hover 状态与 Badge,Gradient 自行管理 SVG、颜色顺序和双层 Overlay。
243
+ - 图片、Logo 与其他组件 fallback 继续使用 Avatar 原有 visual / alpha filter hover,不受此分支影响。
244
+
228
245
  - **Avatar-Docs.2026-05-25** 源码顶部历史变更记录已归档;后续新增变更统一写入本文档 Changelog,源码顶部只保留职责、当前关键架构与文档路径。
229
246
 
247
+ ### v2.7.0 (2026-08-02)
248
+
249
+ - 删除自动首字母生成;无显式图片 / fallback / fallbackText 时默认渲染按名称或实例 seed 分散配色的 Gradient。
250
+ - 新增 `variant="empty"`,承接原灰色背景与用户图标空头像视觉。
251
+ - Avatar 单色随机 hover 改用 SVG flood + alpha composite,只染图片或普通组件实际绘制的非透明像素。
252
+ - Gradient fallback 恢复自身多色循环,Avatar 对其跳过单色滤镜,避免双重叠加。
253
+
254
+ ### v2.6.0 (2026-08-02)
255
+
256
+ - 默认 hover 从五色双层持续循环简化为单层 Overlay;每次 pointer enter 随机六色之一,同一次 hover 内颜色固定。
257
+ - 每次 pointer enter 都独立从六种颜色中等概率抽取,同一次 hover 内颜色固定。
258
+ - 默认首字母、fallbackText 和用户图标提升到 Overlay 上方,避免文字与图标被染色。
259
+ - 删除十层 opacity 动画,只保留一个 0.5s opacity 过渡层。
260
+
261
+ ### v2.5.0 (2026-08-02)
262
+
263
+ - 将 Gradient avatar-image 专用 hover 完整迁移到 Avatar,作为所有 Avatar 视觉状态的默认 hover。
264
+ - 删除 Avatar 对共享 media-hoverable brightness / 背景加深分支的消费,避免双重反馈。
265
+ - Avatar 自行管理随机五色、双层 Overlay、10s 循环、0.5s 入口缓冲、disabled 与 reduced-motion。
266
+
230
267
  ### v2.4.19 (2026-06-10)
231
268
 
232
269
  #### 新功能