@teamix-evo/ui 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/README.md +184 -184
  2. package/manifest.json +680 -492
  3. package/package.json +20 -10
  4. package/src/components/accordion/accordion.meta.md +5 -4
  5. package/src/components/accordion/accordion.stories.tsx +14 -9
  6. package/src/components/accordion/accordion.tsx +104 -8
  7. package/src/components/affix/affix.meta.md +20 -2
  8. package/src/components/affix/affix.stories.tsx +102 -25
  9. package/src/components/affix/affix.tsx +79 -9
  10. package/src/components/alert/alert.meta.md +44 -13
  11. package/src/components/alert/alert.stories.tsx +66 -21
  12. package/src/components/alert/alert.tsx +81 -34
  13. package/src/components/alert-dialog/alert-dialog.meta.md +61 -16
  14. package/src/components/alert-dialog/alert-dialog.stories.tsx +145 -3
  15. package/src/components/alert-dialog/alert-dialog.tsx +60 -13
  16. package/src/components/anchor/anchor.meta.md +8 -3
  17. package/src/components/anchor/anchor.stories.tsx +3 -3
  18. package/src/components/anchor/anchor.tsx +2 -2
  19. package/src/components/app/app.meta.md +9 -4
  20. package/src/components/app/app.stories.tsx +9 -7
  21. package/src/components/aspect-ratio/aspect-ratio.meta.md +4 -3
  22. package/src/components/aspect-ratio/aspect-ratio.stories.tsx +3 -3
  23. package/src/components/auto-complete/auto-complete.meta.md +14 -6
  24. package/src/components/auto-complete/auto-complete.stories.tsx +47 -4
  25. package/src/components/auto-complete/auto-complete.tsx +119 -71
  26. package/src/components/avatar/avatar.meta.md +6 -7
  27. package/src/components/avatar/avatar.stories.tsx +21 -3
  28. package/src/components/avatar/avatar.tsx +24 -23
  29. package/src/components/badge/badge.meta.md +10 -9
  30. package/src/components/badge/badge.stories.tsx +2 -2
  31. package/src/components/badge/badge.tsx +9 -15
  32. package/src/components/breadcrumb/breadcrumb.meta.md +27 -7
  33. package/src/components/breadcrumb/breadcrumb.stories.tsx +127 -4
  34. package/src/components/breadcrumb/breadcrumb.tsx +22 -8
  35. package/src/components/button/button.meta.md +258 -21
  36. package/src/components/button/button.stories.tsx +549 -41
  37. package/src/components/button/button.tsx +335 -33
  38. package/src/components/button/demo/as-child.tsx +24 -0
  39. package/src/components/button/demo/basic.tsx +8 -0
  40. package/src/components/button/demo/block.tsx +16 -0
  41. package/src/components/button/demo/loading.tsx +19 -0
  42. package/src/components/button/demo/shapes.tsx +18 -0
  43. package/src/components/button/demo/sizes.tsx +19 -0
  44. package/src/components/button/demo/variants.tsx +19 -0
  45. package/src/components/button/demo/with-icon.tsx +20 -0
  46. package/src/components/calendar/calendar.meta.md +13 -3
  47. package/src/components/calendar/calendar.stories.tsx +6 -6
  48. package/src/components/calendar/calendar.tsx +73 -8
  49. package/src/components/card/card.meta.md +27 -5
  50. package/src/components/card/card.stories.tsx +42 -3
  51. package/src/components/card/card.tsx +146 -63
  52. package/src/components/carousel/carousel.meta.md +4 -3
  53. package/src/components/carousel/carousel.stories.tsx +11 -6
  54. package/src/components/cascader/cascader.meta.md +47 -17
  55. package/src/components/cascader/cascader.stories.tsx +22 -10
  56. package/src/components/cascader/cascader.tsx +428 -85
  57. package/src/components/checkbox/checkbox.meta.md +75 -7
  58. package/src/components/checkbox/checkbox.stories.tsx +161 -3
  59. package/src/components/checkbox/checkbox.tsx +77 -9
  60. package/src/components/collapsible/collapsible.meta.md +14 -6
  61. package/src/components/collapsible/collapsible.stories.tsx +10 -2
  62. package/src/components/collapsible/collapsible.tsx +93 -6
  63. package/src/components/color-picker/color-picker.meta.md +12 -7
  64. package/src/components/color-picker/color-picker.stories.tsx +86 -7
  65. package/src/components/color-picker/color-picker.tsx +20 -9
  66. package/src/components/command/command.meta.md +29 -13
  67. package/src/components/command/command.stories.tsx +4 -4
  68. package/src/components/command/command.tsx +19 -8
  69. package/src/components/context-menu/context-menu.meta.md +11 -8
  70. package/src/components/context-menu/context-menu.stories.tsx +11 -3
  71. package/src/components/context-menu/context-menu.tsx +21 -8
  72. package/src/components/data-table/data-table.meta.md +6 -5
  73. package/src/components/data-table/data-table.stories.tsx +13 -6
  74. package/src/components/data-table/data-table.tsx +2 -2
  75. package/src/components/date-picker/date-picker.meta.md +88 -19
  76. package/src/components/date-picker/date-picker.stories.tsx +55 -5
  77. package/src/components/date-picker/date-picker.tsx +1489 -91
  78. package/src/components/descriptions/descriptions.meta.md +10 -5
  79. package/src/components/descriptions/descriptions.stories.tsx +3 -3
  80. package/src/components/descriptions/descriptions.tsx +22 -14
  81. package/src/components/dialog/dialog.meta.md +76 -13
  82. package/src/components/dialog/dialog.stories.tsx +182 -20
  83. package/src/components/dialog/dialog.tsx +67 -15
  84. package/src/components/dialog/imperative.tsx +252 -0
  85. package/src/components/drawer/drawer.meta.md +33 -34
  86. package/src/components/drawer/drawer.stories.tsx +29 -12
  87. package/src/components/drawer/drawer.tsx +22 -113
  88. package/src/components/dropdown-menu/dropdown-menu.meta.md +78 -10
  89. package/src/components/dropdown-menu/dropdown-menu.stories.tsx +88 -2
  90. package/src/components/dropdown-menu/dropdown-menu.tsx +24 -10
  91. package/src/components/ellipsis/ellipsis.meta.md +87 -0
  92. package/src/components/ellipsis/ellipsis.stories.tsx +72 -0
  93. package/src/components/ellipsis/ellipsis.tsx +153 -0
  94. package/src/components/empty/empty.meta.md +9 -4
  95. package/src/components/empty/empty.stories.tsx +4 -4
  96. package/src/components/empty/empty.tsx +10 -3
  97. package/src/components/field/field.meta.md +47 -9
  98. package/src/components/field/field.stories.tsx +385 -5
  99. package/src/components/field/field.tsx +263 -35
  100. package/src/components/filter-bar/filter-bar.meta.md +92 -0
  101. package/src/components/filter-bar/filter-bar.stories.tsx +1083 -0
  102. package/src/components/filter-bar/filter-bar.tsx +568 -0
  103. package/src/components/flex/flex.meta.md +54 -6
  104. package/src/components/flex/flex.stories.tsx +107 -20
  105. package/src/components/flex/flex.tsx +27 -4
  106. package/src/components/float-button/float-button.meta.md +8 -3
  107. package/src/components/float-button/float-button.stories.tsx +9 -7
  108. package/src/components/float-button/float-button.tsx +1 -1
  109. package/src/components/form/form.meta.md +39 -17
  110. package/src/components/form/form.stories.tsx +350 -3
  111. package/src/components/form/form.tsx +101 -35
  112. package/src/components/grid/grid.meta.md +7 -2
  113. package/src/components/grid/grid.stories.tsx +6 -4
  114. package/src/components/hover-card/hover-card.meta.md +20 -9
  115. package/src/components/hover-card/hover-card.stories.tsx +34 -5
  116. package/src/components/hover-card/hover-card.tsx +51 -13
  117. package/src/components/icon/DEVELOPMENT.md +809 -0
  118. package/src/components/icon/icon.meta.md +170 -0
  119. package/src/components/icon/icon.stories.tsx +344 -0
  120. package/src/components/icon/icon.tsx +248 -0
  121. package/src/components/image/image.meta.md +9 -4
  122. package/src/components/image/image.stories.tsx +3 -3
  123. package/src/components/image/image.tsx +6 -4
  124. package/src/components/input/demo/basic.tsx +12 -0
  125. package/src/components/input/demo/clearable.tsx +21 -0
  126. package/src/components/input/demo/show-count.tsx +18 -0
  127. package/src/components/input/demo/sizes.tsx +15 -0
  128. package/src/components/input/input.meta.md +39 -33
  129. package/src/components/input/input.stories.tsx +62 -35
  130. package/src/components/input/input.tsx +97 -98
  131. package/src/components/input-group/input-group.meta.md +54 -22
  132. package/src/components/input-group/input-group.stories.tsx +49 -16
  133. package/src/components/input-group/input-group.tsx +44 -8
  134. package/src/components/input-number/input-number.meta.md +64 -7
  135. package/src/components/input-number/input-number.stories.tsx +46 -8
  136. package/src/components/input-number/input-number.tsx +99 -26
  137. package/src/components/input-otp/input-otp.meta.md +4 -3
  138. package/src/components/input-otp/input-otp.stories.tsx +3 -3
  139. package/src/components/input-otp/input-otp.tsx +1 -1
  140. package/src/components/item/item.meta.md +8 -3
  141. package/src/components/item/item.stories.tsx +8 -5
  142. package/src/components/item/item.tsx +7 -6
  143. package/src/components/kbd/kbd.meta.md +13 -4
  144. package/src/components/kbd/kbd.stories.tsx +4 -4
  145. package/src/components/kbd/kbd.tsx +10 -5
  146. package/src/components/label/label.meta.md +18 -10
  147. package/src/components/label/label.stories.tsx +64 -6
  148. package/src/components/label/label.tsx +91 -19
  149. package/src/components/masonry/masonry.meta.md +8 -3
  150. package/src/components/masonry/masonry.stories.tsx +7 -5
  151. package/src/components/masonry/masonry.tsx +1 -0
  152. package/src/components/mentions/mentions.meta.md +36 -6
  153. package/src/components/mentions/mentions.stories.tsx +120 -6
  154. package/src/components/mentions/mentions.tsx +11 -5
  155. package/src/components/menubar/menubar.meta.md +30 -12
  156. package/src/components/menubar/menubar.stories.tsx +62 -2
  157. package/src/components/menubar/menubar.tsx +9 -9
  158. package/src/components/native-select/native-select.meta.md +8 -3
  159. package/src/components/native-select/native-select.stories.tsx +8 -5
  160. package/src/components/native-select/native-select.tsx +1 -1
  161. package/src/components/navigation-menu/navigation-menu.meta.md +19 -9
  162. package/src/components/navigation-menu/navigation-menu.stories.tsx +112 -9
  163. package/src/components/navigation-menu/navigation-menu.tsx +8 -4
  164. package/src/components/notification/notification.meta.md +52 -10
  165. package/src/components/notification/notification.stories.tsx +11 -9
  166. package/src/components/notification/notification.tsx +36 -21
  167. package/src/components/page-header/DEVELOPMENT.md +842 -0
  168. package/src/components/page-header/page-header.meta.md +208 -0
  169. package/src/components/page-header/page-header.stories.tsx +421 -0
  170. package/src/components/page-header/page-header.tsx +281 -0
  171. package/src/components/pagination/pagination.meta.md +140 -37
  172. package/src/components/pagination/pagination.stories.tsx +232 -10
  173. package/src/components/pagination/pagination.tsx +355 -63
  174. package/src/components/popconfirm/popconfirm.meta.md +9 -4
  175. package/src/components/popconfirm/popconfirm.stories.tsx +3 -4
  176. package/src/components/popconfirm/popconfirm.tsx +2 -2
  177. package/src/components/popover/popover.meta.md +62 -5
  178. package/src/components/popover/popover.stories.tsx +83 -7
  179. package/src/components/popover/popover.tsx +77 -28
  180. package/src/components/progress/progress.meta.md +38 -6
  181. package/src/components/progress/progress.stories.tsx +3 -3
  182. package/src/components/progress/progress.tsx +24 -16
  183. package/src/components/radio-group/radio-group.meta.md +79 -7
  184. package/src/components/radio-group/radio-group.stories.tsx +39 -3
  185. package/src/components/radio-group/radio-group.tsx +149 -18
  186. package/src/components/rate/rate.meta.md +35 -4
  187. package/src/components/rate/rate.stories.tsx +13 -5
  188. package/src/components/rate/rate.tsx +37 -10
  189. package/src/components/resizable/resizable.meta.md +7 -4
  190. package/src/components/resizable/resizable.stories.tsx +6 -6
  191. package/src/components/resizable/resizable.tsx +1 -1
  192. package/src/components/result/result.meta.md +7 -2
  193. package/src/components/result/result.stories.tsx +4 -8
  194. package/src/components/result/result.tsx +24 -15
  195. package/src/components/scroll-area/scroll-area.meta.md +4 -3
  196. package/src/components/scroll-area/scroll-area.stories.tsx +12 -4
  197. package/src/components/scroll-area/scroll-area.tsx +3 -3
  198. package/src/components/segmented/segmented.meta.md +7 -4
  199. package/src/components/segmented/segmented.stories.tsx +37 -8
  200. package/src/components/segmented/segmented.tsx +15 -7
  201. package/src/components/select/select.meta.md +197 -52
  202. package/src/components/select/select.stories.tsx +238 -63
  203. package/src/components/select/select.tsx +718 -171
  204. package/src/components/separator/separator.meta.md +4 -3
  205. package/src/components/separator/separator.stories.tsx +3 -3
  206. package/src/components/separator/separator.tsx +3 -7
  207. package/src/components/sheet/sheet.meta.md +32 -16
  208. package/src/components/sheet/sheet.stories.tsx +116 -10
  209. package/src/components/sheet/sheet.tsx +116 -29
  210. package/src/components/sidebar/sidebar.meta.md +37 -18
  211. package/src/components/sidebar/sidebar.stories.tsx +701 -29
  212. package/src/components/sidebar/sidebar.tsx +615 -142
  213. package/src/components/skeleton/skeleton.meta.md +4 -5
  214. package/src/components/skeleton/skeleton.stories.tsx +4 -4
  215. package/src/components/skeleton/skeleton.tsx +7 -7
  216. package/src/components/slider/slider.meta.md +57 -5
  217. package/src/components/slider/slider.stories.tsx +58 -6
  218. package/src/components/slider/slider.tsx +154 -13
  219. package/src/components/sonner/sonner.meta.md +58 -7
  220. package/src/components/sonner/sonner.stories.tsx +78 -5
  221. package/src/components/sonner/sonner.tsx +137 -8
  222. package/src/components/spinner/spinner.meta.md +62 -13
  223. package/src/components/spinner/spinner.stories.tsx +66 -14
  224. package/src/components/spinner/spinner.tsx +111 -9
  225. package/src/components/statistic/statistic.meta.md +7 -2
  226. package/src/components/statistic/statistic.stories.tsx +3 -7
  227. package/src/components/statistic/statistic.tsx +5 -6
  228. package/src/components/steps/steps.meta.md +18 -4
  229. package/src/components/steps/steps.stories.tsx +43 -3
  230. package/src/components/steps/steps.tsx +15 -12
  231. package/src/components/switch/switch.meta.md +51 -5
  232. package/src/components/switch/switch.stories.tsx +6 -6
  233. package/src/components/switch/switch.tsx +109 -41
  234. package/src/components/table/table.meta.md +17 -6
  235. package/src/components/table/table.stories.tsx +10 -5
  236. package/src/components/table/table.tsx +4 -4
  237. package/src/components/tabs/tabs.meta.md +38 -25
  238. package/src/components/tabs/tabs.stories.tsx +111 -25
  239. package/src/components/tabs/tabs.tsx +125 -54
  240. package/src/components/tag/tag.meta.md +105 -40
  241. package/src/components/tag/tag.stories.tsx +189 -16
  242. package/src/components/tag/tag.tsx +222 -21
  243. package/src/components/textarea/textarea.meta.md +35 -19
  244. package/src/components/textarea/textarea.stories.tsx +32 -6
  245. package/src/components/textarea/textarea.tsx +33 -9
  246. package/src/components/time-picker/time-picker.meta.md +124 -32
  247. package/src/components/time-picker/time-picker.stories.tsx +85 -15
  248. package/src/components/time-picker/time-picker.tsx +913 -61
  249. package/src/components/timeline/timeline.meta.md +14 -6
  250. package/src/components/timeline/timeline.stories.tsx +37 -7
  251. package/src/components/timeline/timeline.tsx +35 -14
  252. package/src/components/toggle/toggle.meta.md +5 -4
  253. package/src/components/toggle/toggle.stories.tsx +4 -4
  254. package/src/components/toggle/toggle.tsx +4 -3
  255. package/src/components/toggle-group/toggle-group.meta.md +5 -4
  256. package/src/components/toggle-group/toggle-group.stories.tsx +3 -3
  257. package/src/components/toggle-group/toggle-group.tsx +2 -2
  258. package/src/components/tooltip/tooltip.meta.md +55 -5
  259. package/src/components/tooltip/tooltip.stories.tsx +42 -5
  260. package/src/components/tooltip/tooltip.tsx +81 -21
  261. package/src/components/tour/tour.meta.md +9 -4
  262. package/src/components/tour/tour.stories.tsx +3 -3
  263. package/src/components/tour/tour.tsx +4 -4
  264. package/src/components/transfer/transfer.meta.md +11 -6
  265. package/src/components/transfer/transfer.stories.tsx +4 -8
  266. package/src/components/transfer/transfer.tsx +28 -21
  267. package/src/components/tree/tree.meta.md +63 -5
  268. package/src/components/tree/tree.stories.tsx +31 -12
  269. package/src/components/tree/tree.tsx +9 -8
  270. package/src/components/tree-select/tree-select.meta.md +59 -8
  271. package/src/components/tree-select/tree-select.stories.tsx +3 -3
  272. package/src/components/tree-select/tree-select.tsx +42 -7
  273. package/src/components/typography/typography.meta.md +61 -14
  274. package/src/components/typography/typography.stories.tsx +12 -11
  275. package/src/components/typography/typography.tsx +43 -28
  276. package/src/components/upload/upload.meta.md +49 -4
  277. package/src/components/upload/upload.stories.tsx +72 -12
  278. package/src/components/upload/upload.tsx +170 -37
  279. package/src/components/watermark/watermark.meta.md +7 -2
  280. package/src/components/watermark/watermark.stories.tsx +101 -9
  281. package/src/components/watermark/watermark.tsx +1 -0
  282. package/src/hooks/use-breakpoint.ts +117 -0
  283. package/src/hooks/use-debounce-callback.ts +52 -0
  284. package/src/hooks/use-mobile.ts +23 -0
  285. package/src/stories/theme-tokens.stories.tsx +747 -0
  286. package/src/utils/trigger-input.ts +53 -0
  287. package/src/components/button-group/button-group.meta.md +0 -92
  288. package/src/components/button-group/button-group.stories.tsx +0 -90
  289. package/src/components/button-group/button-group.tsx +0 -75
  290. package/src/components/combobox/combobox.meta.md +0 -93
  291. package/src/components/combobox/combobox.stories.tsx +0 -55
  292. package/src/components/combobox/combobox.tsx +0 -130
  293. package/src/components/space/space.meta.md +0 -94
  294. package/src/components/space/space.stories.tsx +0 -94
  295. package/src/components/space/space.tsx +0 -106
@@ -0,0 +1,170 @@
1
+ ---
2
+ id: icon
3
+ name: Icon
4
+ displayName: 图标
5
+ type: component
6
+ category: general
7
+ since: 0.1.0
8
+ package: '@teamix-evo/ui'
9
+ ---
10
+
11
+ # Icon 图标
12
+
13
+ 图标容器 — 纯样式包裹层。**单一 children 通道**(对齐 Mantine ThemeIcon),不再提供 `icon` prop;**`variant`(形态) + `color`(颜色) 双 prop**(对齐 [ADR 0021](../../../../../docs/adr/0021-semantic-color-api-unification.md) 业界最大公约数),不再有 `withBackground/shape/bgTone` 三轨。**7 档 size**(xs/sm/md/lg/xl/2xl/3xl)依托 Tailwind v4 spacing scale,无需新增 design token。承接 cloud-design Icon 的"圆形/方形 + 彩色背景"为 `variant="circle"|"square"` + `color`。类名/样式 在所有分支均完整透传到外层根节点。
14
+
15
+ ## When to use
16
+
17
+ - **状态指示** — `color="success / warning / destructive"` + 状态图标
18
+ - **带背景容器的入口图标** — `variant="circle"|"square"` + `color`(PageHeader / 卡片头 / 数据概览)
19
+ - **iconfont / 业务图集** — 通过 children 通道接 v0.2 `createIconfontIcon` 工厂返回的组件
20
+ - **Slot 包装** — 给 `<a>` / `<button>` 一次性套上统一图标样式
21
+
22
+ ## When NOT to use
23
+
24
+ - **常规 loading 全屏 / 局部** → 用 [`Spinner`](../spinner/spinner.meta.md),自带 `role="status"` + `sr-only` 文案
25
+ - **纯 lucide 直用 + className 控样式即可** → 不需要包 `<Icon>`,shadcn 工程理念就是 `import { Smile } from 'lucide-react'` 直用
26
+ - **用户头像 / 品牌 Logo** → 用 [`Avatar`](../avatar/avatar.meta.md)
27
+
28
+ ## Props
29
+
30
+ > 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成。
31
+
32
+ <!-- auto:props:begin -->
33
+ | 名称 | 类型 | 默认值 | 必填 | 说明 |
34
+ | --- | --- | --- | --- | --- |
35
+ | `children` | `React.ReactNode` | – | ✓ | 渲染目标 — 必填。lucide-react / 自定义 svg / iconfont 工厂返回的组件均可。 单一 children 通道,不再提供 `icon` prop(避免 `<Icon icon=...>` 组件名 + 同名 prop 的语义冗余)。 |
36
+ | `variant` | `IconVariant` | `"plain"` | – | 形态 — 决定是否带背景容器。 - `plain`:无背景,size 直接控前景 svg(默认) - `circle` / `square`:带 `color` 配色的背景容器,inner svg 自动小一档 |
37
+ | `color` | `IconColor` | `"default"` | – | 语义色 — 6 档枚举,字面与 OpenTrek tokens 对齐(见 [ADR 0021](../../../../../docs/adr/0021-semantic-color-api-unification.md))。 - `variant=plain` 时控前景色 - `variant=circle/square` 时同时控容器背景 + 前景(浅底深字) |
38
+ | `size` | `IconSize` | `"md"` | – | 尺寸 — 7 档枚举 + inherit。`inherit` 走 `1em`,跟随父级字号(用于 Title / Button 内联场景)。 当 `variant!=plain` 时,该 size 指容器尺寸,inner svg 自动用对应小一档。 |
39
+ | `spin` | `boolean` | `false` | – | 旋转动效 — 与 antd Icon `spin` 对齐,Tailwind `animate-spin` 实现。 |
40
+ | `rotate` | `number` | – | – | 静态旋转角度(度数)— 与 antd Icon `rotate` 对齐,通过 inline transform 实现。 与 `spin` 同时使用语义模糊,不建议同用。 |
41
+ | `asChild` | `boolean` | `false` | – | Slot 模式 — 把渲染目标交给消费方提供的子元素。开启时 `variant` 强制走 plain。 |
42
+ | `decorative` | `boolean` | `true` | – | 装饰性图标(默认 true,自动 `aria-hidden="true"`)。 当图标承载语义信息时设为 false,**必须**同时提供 `aria-label` 或被 `<button aria-label>` 包裹。 |
43
+ <!-- auto:props:end -->
44
+
45
+ ## 依赖
46
+
47
+ > 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成,数据源是 [`manifest.json`](../../../manifest.json)。**手工编辑 marker 之间的内容会在下次生成时被覆盖**。
48
+
49
+ <!-- auto:deps:begin -->
50
+ ### 同库依赖
51
+
52
+ > `teamix-evo ui add icon` 时,以下 entry 会被自动连带安装(无需手动 add)。
53
+
54
+ | Entry | 类型 | 描述 |
55
+ | --- | --- | --- |
56
+ | `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
57
+
58
+ ### npm 依赖
59
+
60
+ > 业务侧需要先 `pnpm add` / `npm install` 这些包。CLI 在 `ui add` 完成后会列出此提示。
61
+
62
+ ```bash
63
+ pnpm add @radix-ui/react-slot@^1.1.0 class-variance-authority@^0.7.0 lucide-react@^0.460.0
64
+ ```
65
+ <!-- auto:deps:end -->
66
+
67
+ ## AI 生成纪律
68
+
69
+ ### 硬约束
70
+
71
+ - **走 children 通道,不重发明 `icon` prop** — `<Icon><Smile /></Icon>`,不要再试图传 `<Icon icon={Smile} />`(该 prop 已下线)
72
+ - **禁止内联 `<svg>`** — 用 lucide 现成图标,特殊场景才走 children 通道传自定义 svg
73
+ - **禁止从 `@ant-design/icons` / `@alifd/next` Icon 引入** — 由 `@teamix-evo/eslint-config` 的 `teamix-evo/icon-from-lucide` 规则强制
74
+ - **禁止给 Icon 加 arbitrary `size-[Xpx]`** — 用 7 档枚举 size,真有特殊像素诉求走 lint warn 路径用 `className`,且每处需 review
75
+ - **禁止颜色字面量** — `style={{ color: '#1DC11D' }}` 是 cloud-design 老写法,现在走 `color` 枚举或父级 currentColor
76
+ - **禁止给 Icon 加点击事件后忘记加 `decorative={false}` + `aria-label`** — 装饰性图标不应承担交互;要交互必须语义化(包 `<button>`)
77
+
78
+ ### 推荐范式
79
+
80
+ - 基础用法:`<Icon><Smile /></Icon>`(默认装饰性,默认 md size,跟随父色)
81
+ - 状态色:`<Icon color="success" size="lg"><CheckCircle2 /></Icon>`
82
+ - 背景容器:`<Icon variant="circle" color="warning" size="lg"><AlertTriangle /></Icon>`
83
+ - 加载:`<Icon spin color="muted"><Loader2 /></Icon>`(常规 loading 优先用 `<Spinner>`)
84
+ - 可点击:`<button aria-label="删除"><Icon><Trash2 /></Icon></button>`(图标装饰性,语义靠 button)
85
+ - Slot 包裹:`<Icon asChild size="lg" color="primary"><a href="..."><MyCustomLogo /></a></Icon>`
86
+
87
+ ### 反例
88
+
89
+ - ❌ `<Icon icon={Smile} />` — `icon` prop 已下线,一律走 children
90
+ - ❌ `<Icon><Smile /><Heart /></Icon>` — 只能传单一 children(svg/lucide 组件),多个子元素语义不明
91
+ - ❌ `<Icon onClick={...}><Trash2 /></Icon>` — 装饰性图标不应承担交互;要交互包 `<button>`
92
+ - ❌ `<Icon spin rotate={45}><Loader2 /></Icon>` — spin 与 rotate 同用语义模糊,选一个
93
+ - ❌ 全屏 loading 用 `<Icon spin size="3xl"><Loader2 /></Icon>` — 用 `<Spinner size="xl" />`,后者带读屏文案
94
+
95
+ ## Examples
96
+
97
+ ```tsx
98
+ import { Icon } from '@/components/icon';
99
+ import {
100
+ AlertTriangle,
101
+ CheckCircle2,
102
+ Info,
103
+ Loader2,
104
+ Search,
105
+ Smile,
106
+ Trash2,
107
+ } from 'lucide-react';
108
+
109
+ // 基础(装饰性,跟随父色)
110
+ <Icon><Smile /></Icon>
111
+
112
+ // 状态色
113
+ <Icon color="success" size="lg"><CheckCircle2 /></Icon>
114
+
115
+ // 旋转动效
116
+ <Icon spin color="muted"><Loader2 /></Icon>
117
+
118
+ // 静态旋转
119
+ <Icon rotate={90} size="lg"><AlertTriangle /></Icon>
120
+
121
+ // 背景容器
122
+ <Icon variant="circle" color="warning" size="lg"><AlertTriangle /></Icon>
123
+ <Icon variant="square" color="primary" size="2xl"><Smile /></Icon>
124
+
125
+ // 非装饰(承载语义,必须 aria-label)
126
+ <Icon decorative={false} aria-label="提示信息"><Info /></Icon>
127
+
128
+ // 装饰图标 + 交互按钮(语义靠 button)
129
+ <button type="button" aria-label="删除">
130
+ <Icon><Trash2 /></Icon>
131
+ </button>
132
+
133
+ // Slot 包裹
134
+ <Icon asChild size="lg" color="primary">
135
+ <a href="/search" aria-label="搜索">
136
+ <Search />
137
+ </a>
138
+ </Icon>
139
+
140
+ // 自定义 svg / iconfont 工厂
141
+ <Icon size="lg" color="primary">
142
+ <svg viewBox="0 0 24 24" fill="currentColor">
143
+ <path d="M12 2 L22 22 L2 22 Z" />
144
+ </svg>
145
+ </Icon>
146
+
147
+ // className / style 透传(所有分支均合并到外层根节点)
148
+ <Icon variant="circle" color="warning" size="lg"
149
+ className="ring-2 ring-warning ring-offset-2"
150
+ style={{ marginLeft: 8 }}>
151
+ <AlertTriangle />
152
+ </Icon>
153
+ ```
154
+
155
+ ## 路线图
156
+
157
+ | 阶段 | 能力 |
158
+ | ----------- | ------------------------------------------------------------------------ |
159
+ | v0.1 (本期) | children 通道 + variant + color + 7 档 size + spin/rotate/Slot/无障碍 |
160
+ | v0.2 | iconfont 工厂 `createIconfontIcon({ scriptUrl })`,API 对 `<Icon>` 不破坏 |
161
+ | v0.3+ | 多 icon set 工厂(heroicons / tabler 等),组件本身仍保持 lucide 默认源 |
162
+
163
+ > **API 在 v0.1 就稳定** — 后续加源不破坏现有 prop。`icon` / `withBackground` / `shape` / `bgTone` 在 v0.1 进入 stable 前一次性由 `children` + `variant` + `color` 取代,后续不再变动。
164
+
165
+ ## 关联
166
+
167
+ - 范本组件:[Spinner](../spinner/spinner.meta.md) — lucide 轻封装的最简范本
168
+ - 关联组件:[PageHeader](../page-header/page-header.meta.md) — `withBackground` 能力的首个消费者
169
+ - 关联 ADR:[ADR 0008](../../../../../docs/adr/0008-eslint-visual-rules-warn-baseline.md) — visual rules warn baseline(success / warning token 缺口处置)
170
+ - 设计文档:[DEVELOPMENT.md](./DEVELOPMENT.md)
@@ -0,0 +1,344 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import {
3
+ AlertTriangle,
4
+ Bell,
5
+ Check,
6
+ CheckCircle2,
7
+ Heart,
8
+ Info,
9
+ Loader2,
10
+ Search,
11
+ Server,
12
+ Settings,
13
+ Smile,
14
+ Trash2,
15
+ XCircle,
16
+ } from 'lucide-react';
17
+
18
+ import { Icon } from './icon';
19
+
20
+ // 让 Storybook controls 能选 children 渲染哪个 lucide 组件。
21
+ const iconMapping = {
22
+ Smile: <Smile />,
23
+ Check: <Check />,
24
+ CheckCircle2: <CheckCircle2 />,
25
+ AlertTriangle: <AlertTriangle />,
26
+ Loader2: <Loader2 />,
27
+ Search: <Search />,
28
+ Trash2: <Trash2 />,
29
+ Settings: <Settings />,
30
+ Info: <Info />,
31
+ Bell: <Bell />,
32
+ Heart: <Heart />,
33
+ Server: <Server />,
34
+ XCircle: <XCircle />,
35
+ };
36
+
37
+ const SIZES = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'] as const;
38
+ const COLORS = [
39
+ 'default',
40
+ 'muted',
41
+ 'primary',
42
+ 'success',
43
+ 'warning',
44
+ 'destructive',
45
+ ] as const;
46
+
47
+ const meta: Meta<typeof Icon> = {
48
+ title: '通用 · General/Icon',
49
+ component: Icon,
50
+ tags: ['autodocs'],
51
+ parameters: {
52
+ docs: {
53
+ description: {
54
+ component:
55
+ 'Icon 图标容器 —— 纯样式包裹层。**单一 children 通道**(对齐 Mantine ThemeIcon),没有 `icon` prop;**`variant` + `color` 双轴**(对齐 [ADR 0021](../../../../../docs/adr/0021-semantic-color-api-unification.md) 双 prop 治理),没有 `withBackground/shape/bgTone` 三轨。**7 档 size**(xs/sm/md/lg/xl/2xl/3xl) + `inherit`,Tailwind v4 spacing scale 直接覆盖,无需新增 design token。承接 cloud-design Icon 的"圆形/方形 + 彩色背景"能力为 `variant="circle"|"square"` + `color`;antd `@ant-design/icons` 的 `spin/rotate` 对齐保留;`asChild` 走 Slot 模式。className / style 在所有分支均完整透传到外层根节点。视觉走 OpenTrek semantic tokens。',
56
+ },
57
+ },
58
+ },
59
+ argTypes: {
60
+ children: {
61
+ control: 'select',
62
+ options: Object.keys(iconMapping),
63
+ mapping: iconMapping,
64
+ },
65
+ variant: {
66
+ control: 'inline-radio',
67
+ options: ['plain', 'circle', 'square'],
68
+ },
69
+ size: { control: 'select', options: [...SIZES, 'inherit'] },
70
+ color: { control: 'inline-radio', options: [...COLORS] },
71
+ spin: { control: 'boolean' },
72
+ rotate: { control: { type: 'number', min: 0, max: 360, step: 15 } },
73
+ decorative: { control: 'boolean' },
74
+ asChild: { control: 'boolean' },
75
+ },
76
+ args: {
77
+ children: <Smile />,
78
+ variant: 'plain',
79
+ color: 'default',
80
+ size: 'md',
81
+ spin: false,
82
+ decorative: true,
83
+ asChild: false,
84
+ },
85
+ };
86
+
87
+ export default meta;
88
+ type Story = StoryObj<typeof meta>;
89
+
90
+ // ─── 1. Playground ──────────────────────────────────────────────────────────
91
+
92
+ export const Playground: Story = {
93
+ parameters: {
94
+ docs: {
95
+ description: {
96
+ story:
97
+ '互动场:在右侧 Controls 切换 children / variant / color / size / spin / rotate,实时观察组合效果。',
98
+ },
99
+ },
100
+ },
101
+ };
102
+
103
+ // ─── 2. Sizes(7 档 + inherit)─────────────────────────────────────────────
104
+
105
+ export const Sizes: Story = {
106
+ parameters: {
107
+ docs: {
108
+ description: {
109
+ story:
110
+ '7 档尺寸刻度:xs(12) / sm(16) / md(20,默认) / lg(24) / xl(28) / 2xl(36) / 3xl(48)。`inherit` 走 `1em` 跟随父字号,适合 Title / Button 内联。',
111
+ },
112
+ },
113
+ },
114
+ render: () => (
115
+ <div className="flex items-end gap-6">
116
+ {SIZES.map((s) => (
117
+ <div key={s} className="flex flex-col items-center gap-2">
118
+ <Icon size={s}>
119
+ <Smile />
120
+ </Icon>
121
+ <span className="text-xs text-muted-foreground">{s}</span>
122
+ </div>
123
+ ))}
124
+ <div className="flex flex-col items-center gap-2 text-2xl">
125
+ <Icon size="inherit">
126
+ <Smile />
127
+ </Icon>
128
+ <span className="text-xs text-muted-foreground">inherit · 1em</span>
129
+ </div>
130
+ </div>
131
+ ),
132
+ };
133
+
134
+ // ─── 3. Colors(6 档语义色)───────────────────────────────────────────────
135
+
136
+ export const Colors: Story = {
137
+ parameters: {
138
+ docs: {
139
+ description: {
140
+ story:
141
+ '6 档语义 color(对齐 [ADR 0021](../../../../../docs/adr/0021-semantic-color-api-unification.md)):default / muted / primary / success / warning / destructive。`default` 走 currentColor,跟随父级。',
142
+ },
143
+ },
144
+ },
145
+ render: () => (
146
+ <div className="flex items-center gap-6">
147
+ {COLORS.map((c) => (
148
+ <div key={c} className="flex flex-col items-center gap-2">
149
+ <Icon color={c} size="lg">
150
+ <Heart />
151
+ </Icon>
152
+ <span className="text-xs text-muted-foreground">{c}</span>
153
+ </div>
154
+ ))}
155
+ </div>
156
+ ),
157
+ };
158
+
159
+ // ─── 4. Variants(plain / circle / square)─────────────────────────────────
160
+
161
+ export const Variants: Story = {
162
+ parameters: {
163
+ docs: {
164
+ description: {
165
+ story:
166
+ '三种形态:`plain`(无背景,默认)、`circle`(圆形容器)、`square`(方形容器)。带背景容器时 `color` 同时驱动 bg(浅底)+ 前景(深字)。',
167
+ },
168
+ },
169
+ },
170
+ render: () => (
171
+ <div className="flex items-center gap-8">
172
+ {(['plain', 'circle', 'square'] as const).map((v) => (
173
+ <div key={v} className="flex flex-col items-center gap-2">
174
+ <Icon variant={v} color="primary" size="lg">
175
+ <Server />
176
+ </Icon>
177
+ <span className="text-xs text-muted-foreground">{v}</span>
178
+ </div>
179
+ ))}
180
+ </div>
181
+ ),
182
+ };
183
+
184
+ // ─── 5. Variant × Color 矩阵 ──────────────────────────────────────────────────
185
+
186
+ export const VariantColorMatrix: Story = {
187
+ parameters: {
188
+ docs: {
189
+ description: {
190
+ story:
191
+ '形态 × 语义色全矩阵 — 跨变体回归确认 token 与尺寸联动正确(success-subtle / warning-subtle / accent / destructive 透明度叠加)。',
192
+ },
193
+ },
194
+ },
195
+ render: () => (
196
+ <div className="flex flex-col gap-6">
197
+ {(['circle', 'square'] as const).map((v) => (
198
+ <div key={v} className="flex flex-col gap-2">
199
+ <div className="text-xs font-medium text-muted-foreground">
200
+ variant = {v}
201
+ </div>
202
+ <div className="grid grid-cols-6 gap-4">
203
+ {COLORS.map((c) => (
204
+ <div key={c} className="flex flex-col items-center gap-2">
205
+ <Icon variant={v} color={c} size="lg">
206
+ <Bell />
207
+ </Icon>
208
+ <span className="text-xs text-muted-foreground">{c}</span>
209
+ </div>
210
+ ))}
211
+ </div>
212
+ </div>
213
+ ))}
214
+ </div>
215
+ ),
216
+ };
217
+
218
+ // ─── 6. Spinning ────────────────────────────────────────────────────────────
219
+
220
+ export const Spinning: Story = {
221
+ parameters: {
222
+ docs: {
223
+ description: {
224
+ story:
225
+ '`spin` 启用 `animate-spin` 旋转动效,典型用于 Loader2。常规 loading 优先用 `<Spinner>`(自带 `role="status"` + 读屏文案)。',
226
+ },
227
+ },
228
+ },
229
+ render: () => (
230
+ <div className="flex items-center gap-6">
231
+ <Icon spin color="muted" size="lg">
232
+ <Loader2 />
233
+ </Icon>
234
+ <Icon spin color="primary" size="xl">
235
+ <Loader2 />
236
+ </Icon>
237
+ <Icon spin variant="circle" color="primary" size="lg">
238
+ <Loader2 />
239
+ </Icon>
240
+ </div>
241
+ ),
242
+ };
243
+
244
+ // ─── 7. Rotated ─────────────────────────────────────────────────────────────
245
+
246
+ export const Rotated: Story = {
247
+ parameters: {
248
+ docs: {
249
+ description: {
250
+ story:
251
+ '`rotate` 静态旋转(度数)。inline transform 实现,与 `spin` 同时使用语义模糊。',
252
+ },
253
+ },
254
+ },
255
+ render: () => (
256
+ <div className="flex items-center gap-6">
257
+ {[0, 45, 90, 135, 180].map((deg) => (
258
+ <div key={deg} className="flex flex-col items-center gap-2">
259
+ <Icon rotate={deg} size="lg">
260
+ <AlertTriangle />
261
+ </Icon>
262
+ <span className="text-xs text-muted-foreground">{deg}°</span>
263
+ </div>
264
+ ))}
265
+ </div>
266
+ ),
267
+ };
268
+
269
+ // ─── 8. AsChild(Slot 模式)───────────────────────────────────────────────
270
+
271
+ export const AsChild: Story = {
272
+ parameters: {
273
+ docs: {
274
+ description: {
275
+ story:
276
+ 'Slot 模式 — 把 size / color / spin 类合并到 children 根节点,适合给 `<a>` / 自定义 logo 一次性套上统一 Icon 样式。开启 asChild 时强制走 plain。',
277
+ },
278
+ },
279
+ },
280
+ args: {
281
+ asChild: true,
282
+ size: 'lg',
283
+ color: 'primary',
284
+ children: (
285
+ <a href="#search" aria-label="搜索">
286
+ <Search />
287
+ </a>
288
+ ),
289
+ },
290
+ };
291
+
292
+ // ─── 9. WithAriaLabel(非装饰)──────────────────────────────────────────
293
+
294
+ export const WithAriaLabel: Story = {
295
+ parameters: {
296
+ docs: {
297
+ description: {
298
+ story:
299
+ '非装饰图标 — `decorative={false}` 自动加 `role="img"`,**必须**同时提供 `aria-label`。读屏会把 label 当成内容朗读。',
300
+ },
301
+ },
302
+ },
303
+ args: {
304
+ decorative: false,
305
+ 'aria-label': '提示信息',
306
+ color: 'primary',
307
+ size: 'lg',
308
+ children: <Info />,
309
+ },
310
+ };
311
+
312
+ // ─── 10. ClassName / Style 透传 ─────────────────────────────────────────────
313
+
314
+ export const ClassNameAndStyle: Story = {
315
+ parameters: {
316
+ docs: {
317
+ description: {
318
+ story:
319
+ 'className / style 在所有分支均合并到外层根节点。这里展示 plain / circle 两种形态下用 className 加 hover 缩放、用 style 加外边距,与组件内置样式正确叠加(tailwind-merge 处理冲突)。',
320
+ },
321
+ },
322
+ },
323
+ render: () => (
324
+ <div className="flex items-center gap-6">
325
+ <Icon
326
+ size="lg"
327
+ color="primary"
328
+ className="transition-transform hover:scale-125"
329
+ style={{ marginRight: 8 }}
330
+ >
331
+ <Heart />
332
+ </Icon>
333
+ <Icon
334
+ variant="circle"
335
+ color="warning"
336
+ size="lg"
337
+ className="ring-2 ring-warning ring-offset-2"
338
+ style={{ marginLeft: 8 }}
339
+ >
340
+ <AlertTriangle />
341
+ </Icon>
342
+ </div>
343
+ ),
344
+ };