@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,281 @@
1
+ import * as React from 'react';
2
+ import { ArrowLeft } from 'lucide-react';
3
+
4
+ import { cn } from '@/utils/cn';
5
+ import { Skeleton, SkeletonParagraph } from '@/components/skeleton/skeleton';
6
+
7
+ // ─── PageHeader: 顶层容器(<header>) ─────────────────────────────────────────
8
+
9
+ export interface PageHeaderProps extends React.HTMLAttributes<HTMLElement> {
10
+ /**
11
+ * 右下角背景装饰图 URL — 通过 inline `style.backgroundImage` 注入(Tailwind 不支持
12
+ * 动态 URL)。固定 `bg-no-repeat bg-right-bottom`。
13
+ */
14
+ backgroundImage?: string;
15
+ }
16
+
17
+ const PageHeader = React.forwardRef<HTMLElement, PageHeaderProps>(
18
+ ({ className, backgroundImage, style, children, ...props }, ref) => {
19
+ const bgStyle: React.CSSProperties | undefined = backgroundImage
20
+ ? {
21
+ backgroundImage: `url(${backgroundImage})`,
22
+ backgroundRepeat: 'no-repeat',
23
+ backgroundPosition: 'right bottom',
24
+ ...style,
25
+ }
26
+ : style;
27
+
28
+ return (
29
+ <header
30
+ ref={ref}
31
+ className={cn(
32
+ 'relative flex flex-col gap-4 overflow-hidden bg-background px-6 py-4',
33
+ className,
34
+ )}
35
+ style={bgStyle}
36
+ {...props}
37
+ >
38
+ {children}
39
+ </header>
40
+ );
41
+ },
42
+ );
43
+ PageHeader.displayName = 'PageHeader';
44
+
45
+ // ─── PageHeaderNav: 导航层(面包屑 + 右侧链接)──────────────────────────────
46
+
47
+ const PageHeaderNav = React.forwardRef<
48
+ HTMLDivElement,
49
+ React.HTMLAttributes<HTMLDivElement>
50
+ >(({ className, ...props }, ref) => (
51
+ <div
52
+ ref={ref}
53
+ className={cn(
54
+ 'flex min-h-5 items-center justify-between text-xs',
55
+ className,
56
+ )}
57
+ {...props}
58
+ />
59
+ ));
60
+ PageHeaderNav.displayName = 'PageHeaderNav';
61
+
62
+ // ─── PageHeaderContent: 主内容区(左右双列)─────────────────────────────────
63
+
64
+ const PageHeaderContent = React.forwardRef<
65
+ HTMLDivElement,
66
+ React.HTMLAttributes<HTMLDivElement>
67
+ >(({ className, ...props }, ref) => (
68
+ <div
69
+ ref={ref}
70
+ className={cn(
71
+ 'flex flex-wrap items-start justify-between gap-4',
72
+ className,
73
+ )}
74
+ {...props}
75
+ />
76
+ ));
77
+ PageHeaderContent.displayName = 'PageHeaderContent';
78
+
79
+ // ─── PageHeaderHeading: 标题行 ───────────────────────────────────────────────
80
+
81
+ export interface PageHeaderHeadingProps
82
+ extends React.HTMLAttributes<HTMLDivElement> {
83
+ /**
84
+ * 前置返回按钮。为 `true` 时渲染 `ArrowLeft` 图标按钮,点击触发 `onBack`。
85
+ * @default false
86
+ */
87
+ goBack?: boolean;
88
+ /** 返回按钮点击回调。 */
89
+ onBack?: (e: React.MouseEvent<HTMLButtonElement>) => void;
90
+ }
91
+
92
+ const PageHeaderHeading = React.forwardRef<
93
+ HTMLDivElement,
94
+ PageHeaderHeadingProps
95
+ >(({ className, goBack = false, onBack, children, ...props }, ref) => (
96
+ <div
97
+ ref={ref}
98
+ className={cn('flex items-center gap-3', className)}
99
+ {...props}
100
+ >
101
+ {goBack ? (
102
+ <button
103
+ type="button"
104
+ onClick={onBack}
105
+ aria-label="返回"
106
+ className={cn(
107
+ 'inline-flex size-8 shrink-0 cursor-pointer items-center justify-center text-muted-foreground transition-colors',
108
+ 'hover:text-foreground',
109
+ 'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring',
110
+ )}
111
+ >
112
+ <ArrowLeft className="size-5" aria-hidden="true" />
113
+ </button>
114
+ ) : null}
115
+ {children}
116
+ </div>
117
+ ));
118
+ PageHeaderHeading.displayName = 'PageHeaderHeading';
119
+
120
+ // ─── PageHeaderDescription: 描述文字(<p>) ──────────────────────────────────
121
+
122
+ const PageHeaderDescription = React.forwardRef<
123
+ HTMLParagraphElement,
124
+ React.HTMLAttributes<HTMLParagraphElement>
125
+ >(({ className, ...props }, ref) => (
126
+ <p
127
+ ref={ref}
128
+ className={cn('text-xs text-muted-foreground', className)}
129
+ {...props}
130
+ />
131
+ ));
132
+ PageHeaderDescription.displayName = 'PageHeaderDescription';
133
+
134
+ // ─── PageHeaderActions: 操作按钮区 ───────────────────────────────────────────
135
+
136
+ const PageHeaderActions = React.forwardRef<
137
+ HTMLDivElement,
138
+ React.HTMLAttributes<HTMLDivElement>
139
+ >(({ className, ...props }, ref) => (
140
+ <div
141
+ ref={ref}
142
+ className={cn('flex shrink-0 items-center gap-2', className)}
143
+ {...props}
144
+ />
145
+ ));
146
+ PageHeaderActions.displayName = 'PageHeaderActions';
147
+
148
+ // ─── PageHeaderData / PageHeaderDataItem: 数据概览 ───────────────────────────
149
+
150
+ const PageHeaderData = React.forwardRef<
151
+ HTMLDivElement,
152
+ React.HTMLAttributes<HTMLDivElement>
153
+ >(({ className, ...props }, ref) => (
154
+ <div
155
+ ref={ref}
156
+ className={cn('flex shrink-0 items-end gap-6', className)}
157
+ {...props}
158
+ />
159
+ ));
160
+ PageHeaderData.displayName = 'PageHeaderData';
161
+
162
+ const dataItemColor = {
163
+ default: 'text-foreground',
164
+ primary: 'text-primary',
165
+ success: 'text-success',
166
+ warning: 'text-warning',
167
+ destructive: 'text-destructive',
168
+ } as const;
169
+
170
+ export interface PageHeaderDataItemProps
171
+ extends React.HTMLAttributes<HTMLDivElement> {
172
+ /** 数据标签(上行,muted 小字)。 */
173
+ label: React.ReactNode;
174
+ /**
175
+ * 值的语义色(调色板) — 对齐 [ADR 0021](../../../../../docs/adr/0021-semantic-color-api-unification.md)。
176
+ *
177
+ * 填充背景类场景 default 本身为中性色,省略 muted 档;信息色用 `primary`,不收 `info`。
178
+ * @default "default"
179
+ */
180
+ color?: keyof typeof dataItemColor;
181
+ }
182
+
183
+ const PageHeaderDataItem = React.forwardRef<
184
+ HTMLDivElement,
185
+ PageHeaderDataItemProps
186
+ >(({ className, label, color = 'default', children, ...props }, ref) => (
187
+ <div ref={ref} className={cn('flex flex-col', className)} {...props}>
188
+ <span className="text-xs text-muted-foreground">{label}</span>
189
+ <span
190
+ className={cn(
191
+ 'text-base font-semibold tabular-nums',
192
+ dataItemColor[color],
193
+ )}
194
+ >
195
+ {children}
196
+ </span>
197
+ </div>
198
+ ));
199
+ PageHeaderDataItem.displayName = 'PageHeaderDataItem';
200
+
201
+ // ─── PageHeaderFooter: 底部详情 ──────────────────────────────────────────────
202
+
203
+ const PageHeaderFooter = React.forwardRef<
204
+ HTMLDivElement,
205
+ React.HTMLAttributes<HTMLDivElement>
206
+ >(({ className, ...props }, ref) => (
207
+ <div
208
+ ref={ref}
209
+ className={cn('mt-4 border-t border-t-border pt-4', className)}
210
+ {...props}
211
+ />
212
+ ));
213
+ PageHeaderFooter.displayName = 'PageHeaderFooter';
214
+
215
+ // ─── PageHeaderSkeleton: 骨架屏 ──────────────────────────────────────────────
216
+
217
+ export interface PageHeaderSkeletonProps
218
+ extends React.HTMLAttributes<HTMLDivElement> {
219
+ /**
220
+ * 显示面包屑骨架行。
221
+ * @default true
222
+ */
223
+ showNav?: boolean;
224
+ /**
225
+ * 显示描述骨架行。
226
+ * @default true
227
+ */
228
+ showDescription?: boolean;
229
+ /**
230
+ * 显示底部详情骨架(3 列 × 2 行网格)。
231
+ * @default false
232
+ */
233
+ showFooter?: boolean;
234
+ }
235
+
236
+ const PageHeaderSkeleton = React.forwardRef<
237
+ HTMLDivElement,
238
+ PageHeaderSkeletonProps
239
+ >(
240
+ (
241
+ {
242
+ className,
243
+ showNav = true,
244
+ showDescription = true,
245
+ showFooter = false,
246
+ ...props
247
+ },
248
+ ref,
249
+ ) => (
250
+ <div
251
+ ref={ref}
252
+ className={cn('flex flex-col gap-4 bg-background px-6 py-4', className)}
253
+ aria-busy="true"
254
+ {...props}
255
+ >
256
+ {showNav ? <Skeleton shape="line" className="h-3 w-48" /> : null}
257
+ <div className="flex items-center gap-3">
258
+ <Skeleton shape="rect" className="size-8 rounded-md" />
259
+ <Skeleton shape="line" className="h-6 w-80" />
260
+ </div>
261
+ {showDescription ? <Skeleton shape="line" className="h-4 w-96" /> : null}
262
+ {showFooter ? <SkeletonParagraph rows={2} className="pt-3" /> : null}
263
+ </div>
264
+ ),
265
+ );
266
+ PageHeaderSkeleton.displayName = 'PageHeaderSkeleton';
267
+
268
+ // ─── exports ─────────────────────────────────────────────────────────────────
269
+
270
+ export {
271
+ PageHeader,
272
+ PageHeaderNav,
273
+ PageHeaderContent,
274
+ PageHeaderHeading,
275
+ PageHeaderDescription,
276
+ PageHeaderActions,
277
+ PageHeaderData,
278
+ PageHeaderDataItem,
279
+ PageHeaderFooter,
280
+ PageHeaderSkeleton,
281
+ };
@@ -1,23 +1,27 @@
1
1
  ---
2
2
  id: pagination
3
3
  name: Pagination
4
+ displayName: 分页
4
5
  type: component
5
6
  category: navigation
6
7
  since: 0.1.0
7
- package: "@teamix-evo/ui"
8
+ package: '@teamix-evo/ui'
8
9
  ---
9
10
 
10
- # Pagination
11
+ # Pagination 分页
12
+
13
+ **分页 — 在大量内容中按页切换浏览,带受控/非受控 + 页码窗口折叠 + 三档密度 + 三种形态**。两套 API:
11
14
 
12
- 分页 — 两套 API:
13
15
  1. **shadcn primitives**(`Pagination / Content / Item / Link / Previous / Next / Ellipsis`)— 完全可组合,适合自定义复杂分页布局
14
- 2. **`SimplePagination`**(antd 风格 props 化高阶包装)— `total / pageSize / current / onChange` 即用,**自动计算页码窗口 + 折叠 ellipsis + 显示总数**
16
+ 2. **`SimplePagination`**(antd 风格 props 化高阶包装)— `total / pageSize / current / onChange` 即用,**自动计算页码窗口 + 折叠 ellipsis + 显示总数**;支持 `size` (`sm`/`md`/`lg`)、`type` (`normal`/`simple`/`mini`)、`pageSizeSelector` + `pageSizeList`、`showJump`、`showFirstLast`
15
17
 
16
18
  ## When to use
17
19
 
18
20
  - 列表 / 表格分页(配 Data Table)
19
21
  - 长内容多页阅读
20
22
  - 搜索结果分页
23
+ - **空间紧凑场景** → `type="mini"`(仅前后箭头 + 页号/总页)
24
+ - **移动端 / 卡片右下角** → `type="simple"`(prev + 当前/总 + next)
21
25
 
22
26
  ## When NOT to use
23
27
 
@@ -26,19 +30,27 @@ package: "@teamix-evo/ui"
26
30
 
27
31
  ## Props
28
32
 
29
- > 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成。下表是 `SimplePagination` 的 props(高阶 API);primitives 的 props 详见 [`pagination.tsx`](./pagination.tsx)。
33
+ > 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成。
30
34
 
31
35
  <!-- auto:props:begin -->
32
36
  | 名称 | 类型 | 默认值 | 必填 | 说明 |
33
37
  | --- | --- | --- | --- | --- |
34
- | `current` | `number` | – | – | 当前页(1-based) |
35
- | `onChange` | `(page: number) => void` | | – | 受控变化回调。 |
38
+ | `current` | `number` | – | – | 当前页(1-based,受控)。与 `defaultCurrent` 互斥。 |
39
+ | `defaultCurrent` | `number` | `1` | – | 默认当前页(非受控)。 |
40
+ | `onChange` | `(page: number, pageSize: number) => void` | – | – | 页码 / pageSize 变化回调。第二参为变化后的 pageSize。 |
36
41
  | `total` | `number` | – | ✓ | 总条数。 |
37
- | `pageSize` | `number` | `10` | – | 每页大小。 |
38
- | `showFirstLast` | `boolean` | `false` | – | 是否显示首末页快捷按钮。 |
39
- | `showTotal` | `boolean` | `true` | – | 是否显示总数文本(antd `showTotal` 并集,简化版)。 |
40
- | `totalRender` | `(total: number, range: [number, number]) => React.ReactNode` | – | | 自定义总数渲染。返回字符串或 ReactNode。 |
41
- | `siblingCount` | `number` | `5` | – | 显示页号窗口大小(中间显示几个页号)。 |
42
+ | `pageSize` | `number` | | – | 每页大小(受控)。与 `defaultPageSize` 互斥。 |
43
+ | `defaultPageSize` | `number` | `10` | – | 默认每页大小(非受控)。 |
44
+ | `pageSizeList` | `number[]` | `[10, 20, 50, 100]` | – | 每页大小可选项(用于 `pageSizeSelector`)。 |
45
+ | `pageSizeSelector` | `boolean` | `false` | – | 显示每页大小选择器(对齐 antd `showSizeChanger` / cloud-design `pageSizeSelector`)。 |
46
+ | `onPageSizeChange` | `(pageSize: number) => void` | | – | pageSize 变化回调。 |
47
+ | `size` | `PaginationSize` | `"md"` | – | 组件大小,对齐 Button / Input 的 sm(h-7) / md(h-8) / lg(h-9) 三档。 |
48
+ | `type` | `PaginationType` | `"normal"` | – | 组件类型 — `normal` 完整 / `simple` 简化(prev + 页码/总页 + next) / `mini` 极简(仅前后箭头)。 |
49
+ | `showFirstLast` | `boolean` | `false` | – | `normal` 类型下,显示首末页快捷按钮。 |
50
+ | `showTotal` | `boolean` | `true` | – | 显示总数文本(`mini` 类型默认不显示)。 |
51
+ | `totalRender` | `(total: number, range: [number, number]) => React.ReactNode` | – | – | 自定义总数渲染。 |
52
+ | `showJump` | `boolean` | `false` | – | `normal` 类型下,显示跳转输入框。 |
53
+ | `siblingCount` | `number` | `5` | – | 中间显示几个页号。建议奇数。 |
42
54
  | `className` | `string` | – | – | 容器 className。 |
43
55
  <!-- auto:props:end -->
44
56
 
@@ -54,27 +66,33 @@ package: "@teamix-evo/ui"
54
66
  | Entry | 类型 | 描述 |
55
67
  | --- | --- | --- |
56
68
  | `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
57
- | `button` | component | 通用按钮 — shadcn 实现 + antd 功能扩展(loading / icon / shape / block / dashed variant) |
69
+ | `button` | component | 通用按钮 — shadcn 实现 + cloud-design 能力并集(loading / icon / shape / block / dashed variant / color 语义双 prop / disabledTooltip)。同文件合一导出 ButtonGroup + ButtonGroupText(等价 antd Space.Compact + cd SplitButton)。 |
58
70
 
59
71
  ### npm 依赖
60
72
 
61
73
  > 业务侧需要先 `pnpm add` / `npm install` 这些包。CLI 在 `ui add` 完成后会列出此提示。
62
74
 
63
75
  ```bash
64
- pnpm add lucide-react@^0.460.0
76
+ pnpm add class-variance-authority@^0.7.0 lucide-react@^0.460.0
65
77
  ```
66
78
  <!-- auto:deps:end -->
67
79
 
68
- > 子组件(primitives):`Pagination`(nav)/ `PaginationContent`(ul)/ `PaginationItem`(li)/ `PaginationLink`(支持 `isActive`)/ `PaginationPrevious` / `PaginationNext` / `PaginationEllipsis`。
69
-
70
80
  ## AI 生成纪律
71
81
 
72
82
  - **业务侧用 `SimplePagination`**:除非要完全自定义布局,默认走高阶 API
83
+ - **`size` 三档对齐 Button/Input**:`sm`(h-7) / `md`(h-8,默认) / `lg`(h-9);**不要**自己加 `h-[28px]` 等 arbitrary value
84
+ - **`type` 三态语义清晰**:
85
+ - `normal` = 完整(页码列表 + prev/next + 可选 pageSizeSelector / showJump / showFirstLast)
86
+ - `simple` = 简化(prev + 当前页/总页 + next),适合卡片角落
87
+ - `mini` = 极简(仅 prev/next 图标 + 页号/总页文本),适合表格行内 / 工具条
88
+ - **`pageSizeSelector` 仅 normal 生效**:`simple` / `mini` 形态下传入会被忽略
73
89
  - **当前页 1-based**:antd 惯例,与 0-based 数组索引区分清楚
74
- - **`pageSize` 默认 10**:与 antd / Web 主流一致
90
+ - **`pageSize` 默认 10**:与 antd / Web 主流一致;`pageSizeList` 默认 `[10, 20, 50, 100]`
75
91
  - **`siblingCount` 控制中间窗口**:奇数(5/7)效果好,偶数会产生不对称
76
- - **`showSizeChanger` / `showQuickJumper` v0.x**:本版不内置(简化 props),需要时业务侧组合 Select + Input
92
+ - **`onChange` 第二参为 pageSize**:`(page, pageSize) => void` 切换 pageSize 时会回到第 1 页并触发一次 `onChange(1, newSize)`
77
93
  - **不要嵌套 Pagination**:同一容器只一组分页
94
+ - **不要传 antd 的 `defaultPageSize` 同时传 `pageSize`**:受控/非受控择一(运行时以受控值为准)
95
+ - **跳转输入框**:`showJump` 默认 `false`,启用后回车提交;非数字静默忽略
78
96
 
79
97
  ## Examples
80
98
 
@@ -82,46 +100,131 @@ pnpm add lucide-react@^0.460.0
82
100
  import { SimplePagination } from '@/components/ui/pagination';
83
101
  import * as React from 'react';
84
102
 
85
- // 高阶 API(推荐)
103
+ // 受控 + 默认 normal × md
86
104
  const [page, setPage] = React.useState(1);
87
105
  <SimplePagination
88
106
  total={245}
89
107
  current={page}
90
108
  pageSize={10}
91
- onChange={setPage}
109
+ onChange={(p) => setPage(p)}
110
+ />
111
+
112
+ // 三档尺寸
113
+ <SimplePagination total={245} size="sm" current={page} onChange={(p) => setPage(p)} />
114
+ <SimplePagination total={245} size="md" current={page} onChange={(p) => setPage(p)} />
115
+ <SimplePagination total={245} size="lg" current={page} onChange={(p) => setPage(p)} />
116
+
117
+ // 简化形态(卡片右下角)
118
+ <SimplePagination
119
+ type="simple"
120
+ total={245}
121
+ current={page}
122
+ onChange={(p) => setPage(p)}
123
+ />
124
+
125
+ // 极简形态(表格行内 / 工具条)
126
+ <SimplePagination
127
+ type="mini"
128
+ total={245}
129
+ current={page}
130
+ onChange={(p) => setPage(p)}
131
+ />
132
+
133
+ // 完整能力 — pageSizeSelector + showJump + showFirstLast
134
+ <SimplePagination
135
+ total={1234}
136
+ current={page}
137
+ pageSizeSelector
138
+ pageSizeList={[10, 20, 50, 100]}
139
+ showJump
140
+ showFirstLast
141
+ onChange={(p, s) => {
142
+ setPage(p);
143
+ /* s 是当前 pageSize */
144
+ }}
145
+ onPageSizeChange={(s) => console.log('pageSize →', s)}
92
146
  />
93
147
 
94
148
  // 自定义总数文本
95
149
  <SimplePagination
96
150
  total={245}
97
- pageSize={10}
98
151
  current={page}
99
- onChange={setPage}
152
+ onChange={(p) => setPage(p)}
100
153
  totalRender={(t, [s, e]) => `${s}-${e} of ${t}`}
101
154
  />
102
155
 
103
- // 显示首末快捷
104
- <SimplePagination total={500} current={page} onChange={setPage} showFirstLast />
105
-
106
- // 不显示总数
107
- <SimplePagination total={245} current={page} onChange={setPage} showTotal={false} />
156
+ // 非受控 — defaultCurrent + defaultPageSize
157
+ <SimplePagination total={245} defaultCurrent={2} defaultPageSize={20} pageSizeSelector />
108
158
  ```
109
159
 
110
160
  ```tsx
111
- // 自由组合(primitives)
161
+ // 自由组合(primitives)— 自定义任意布局
112
162
  import {
113
- Pagination, PaginationContent, PaginationItem, PaginationLink,
114
- PaginationPrevious, PaginationNext, PaginationEllipsis,
163
+ Pagination,
164
+ PaginationContent,
165
+ PaginationItem,
166
+ PaginationLink,
167
+ PaginationPrevious,
168
+ PaginationNext,
169
+ PaginationEllipsis,
115
170
  } from '@/components/ui/pagination';
116
171
 
117
172
  <Pagination>
118
173
  <PaginationContent>
119
- <PaginationItem><PaginationPrevious href="#" /></PaginationItem>
120
- <PaginationItem><PaginationLink href="#">1</PaginationLink></PaginationItem>
121
- <PaginationItem><PaginationLink href="#" isActive>2</PaginationLink></PaginationItem>
122
- <PaginationItem><PaginationLink href="#">3</PaginationLink></PaginationItem>
123
- <PaginationItem><PaginationEllipsis /></PaginationItem>
124
- <PaginationItem><PaginationNext href="#" /></PaginationItem>
174
+ <PaginationItem>
175
+ <PaginationPrevious size="md" onClick={...} />
176
+ </PaginationItem>
177
+ <PaginationItem>
178
+ <PaginationLink size="md" onClick={...}>1</PaginationLink>
179
+ </PaginationItem>
180
+ <PaginationItem>
181
+ <PaginationLink size="md" isActive>2</PaginationLink>
182
+ </PaginationItem>
183
+ <PaginationItem>
184
+ <PaginationLink size="md" onClick={...}>3</PaginationLink>
185
+ </PaginationItem>
186
+ <PaginationItem>
187
+ <PaginationEllipsis size="md" />
188
+ </PaginationItem>
189
+ <PaginationItem>
190
+ <PaginationNext size="md" onClick={...} />
191
+ </PaginationItem>
125
192
  </PaginationContent>
126
- </Pagination>
193
+ </Pagination>;
127
194
  ```
195
+
196
+ ---
197
+
198
+ ## Pagination 形态 — 旧库 API → 新映射
199
+
200
+ > 旧库 `Pagination`(hybridcloud) → 新库 `SimplePagination`(高阶 API) + Pagination Primitives(自由组合)。
201
+ > 新库提供两层架构:SimplePagination 开箱即用;Primitives 用于自定义布局。
202
+
203
+ ### 命名 & 结构映射
204
+
205
+ | 旧库 | 新库 | 说明 |
206
+ | ---------------------------------- | ---------------------------------- | ---------------------------- |
207
+ | `Pagination` | `SimplePagination` | 高阶封装(开箱即用) |
208
+ | — | `Pagination` + Primitives | 新库新增自由组合层 |
209
+ | `type: 'normal'\|'simple'\|'mini'` | `type: 'normal'\|'simple'\|'mini'` | 保持一致 |
210
+ | `size: small/medium/large` | `size: 'sm' \| 'md' \| 'lg'` | md = medium |
211
+ | `onChange(current, e)` | `onChange(page, pageSize)` | 签名变更,第二参改为 pageSize |
212
+ | `pageSizeSelector='dropdown'` | `pageSizeSelector={true}` | 简化为布尔 |
213
+ | `pageShowCount` | `siblingCount` | 当前页两侧显示页数 |
214
+ | `showJump` | `showJump` | 跳转输入框 |
215
+ | `totalRender` | `totalRender` | 总条数自定义渲染 |
216
+ | `hideOnlyOnePage` | 不复刻 | 业务层条件渲染更灵活 |
217
+ | `link` (链接模式) | 不复刻 | Primitives 自行用 `<a>` |
218
+ | `shape` | 不复刻 | 不再设计多种箭头变体 |
219
+ | `pageSizePosition` | 不复刻 | 固定右侧 |
220
+ | `useFloatLayout` | 不复刻 | 用 flexbox 替代 |
221
+ | `pageNumberRender` | 不复刻 | 通过 Primitives 自行实现 |
222
+
223
+ ### 迁移 FAQ
224
+
225
+ | 问题 | 回答 |
226
+ | ---------------------------- | ------------------------------------------------------------------------------ |
227
+ | onChange 签名差异? | 旧: `(current, event)` → 新: `(page, pageSize)` — 第二参从 event 改为 pageSize |
228
+ | 怎么做自定义布局? | 用 Primitives(Pagination + PaginationContent + PaginationLink + …) |
229
+ | showFirstLast? | SimplePagination 已内置首/末页按钮(P0 新增能力) |
230
+ | pageSizeSelector 选项怎么配? | `pageSizeList` prop 传入 `[10, 20, 50, 100]` 数组 |