@teamix-evo/ui 0.4.0 → 0.5.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.
- package/README.md +46 -50
- package/manifest.json +406 -653
- package/package.json +15 -34
- package/src/_design-system/theme-tokens/stories.tsx +1474 -0
- package/src/components/accordion/index.tsx +139 -0
- package/src/components/accordion/meta.md +162 -0
- package/src/components/accordion/stories.tsx +145 -0
- package/src/components/affix/index.tsx +149 -0
- package/src/components/affix/meta.md +23 -0
- package/src/components/affix/stories.tsx +70 -0
- package/src/components/alert/index.tsx +220 -0
- package/src/components/alert/meta.md +133 -0
- package/src/components/alert/stories.tsx +126 -0
- package/src/components/alert-dialog/index.tsx +282 -0
- package/src/components/alert-dialog/meta.md +86 -0
- package/src/components/alert-dialog/stories.tsx +163 -0
- package/src/components/avatar/index.tsx +159 -0
- package/src/components/avatar/meta.md +242 -0
- package/src/components/avatar/stories.tsx +241 -0
- package/src/components/badge/index.tsx +299 -0
- package/src/components/badge/meta.md +237 -0
- package/src/components/badge/stories.tsx +275 -0
- package/src/components/breadcrumb/index.tsx +137 -0
- package/src/components/breadcrumb/meta.md +64 -0
- package/src/components/breadcrumb/stories.tsx +86 -0
- package/src/components/button/index.tsx +202 -0
- package/src/components/button/meta.md +209 -0
- package/src/components/button/stories.tsx +215 -0
- package/src/components/button-group/index.tsx +211 -0
- package/src/components/button-group/meta.md +190 -0
- package/src/components/button-group/stories.tsx +182 -0
- package/src/components/calendar/index.tsx +240 -0
- package/src/components/calendar/meta.md +36 -0
- package/src/components/calendar/stories.tsx +36 -0
- package/src/components/card/index.tsx +262 -0
- package/src/components/card/meta.md +194 -0
- package/src/components/card/stories.tsx +202 -0
- package/src/components/carousel/index.tsx +481 -0
- package/src/components/carousel/meta.md +208 -0
- package/src/components/carousel/stories.tsx +271 -0
- package/src/components/cascader-select/index.tsx +308 -0
- package/src/components/cascader-select/meta.md +28 -0
- package/src/components/cascader-select/stories.tsx +118 -0
- package/src/components/checkbox/index.tsx +208 -0
- package/src/components/checkbox/meta.md +166 -0
- package/src/components/checkbox/stories.tsx +206 -0
- package/src/components/collapsible/index.tsx +72 -0
- package/src/components/collapsible/meta.md +87 -0
- package/src/components/collapsible/stories.tsx +97 -0
- package/src/components/color-picker/index.tsx +677 -0
- package/src/components/color-picker/meta.md +83 -0
- package/src/components/color-picker/stories.tsx +172 -0
- package/src/components/combobox/index.tsx +687 -0
- package/src/components/combobox/meta.md +83 -0
- package/src/components/combobox/stories.tsx +179 -0
- package/src/components/command/index.tsx +238 -0
- package/src/components/command/meta.md +48 -0
- package/src/components/command/stories.tsx +83 -0
- package/src/components/data-table/index.tsx +1537 -0
- package/src/components/data-table/meta.md +107 -0
- package/src/components/data-table/stories.tsx +1234 -0
- package/src/components/date-picker/index.tsx +1492 -0
- package/src/components/date-picker/meta.md +103 -0
- package/src/components/date-picker/stories.tsx +125 -0
- package/src/components/descriptions/index.tsx +535 -0
- package/src/components/descriptions/meta.md +104 -0
- package/src/components/descriptions/stories.tsx +389 -0
- package/src/components/dialog/index.tsx +255 -0
- package/src/components/dialog/meta.md +244 -0
- package/src/components/dialog/stories.tsx +330 -0
- package/src/components/dropdown-menu/index.tsx +301 -0
- package/src/components/dropdown-menu/meta.md +93 -0
- package/src/components/dropdown-menu/stories.tsx +124 -0
- package/src/components/empty/index.tsx +431 -0
- package/src/components/empty/meta.md +274 -0
- package/src/components/empty/stories.tsx +278 -0
- package/src/components/field/index.tsx +374 -0
- package/src/components/field/meta.md +283 -0
- package/src/components/field/stories.tsx +327 -0
- package/src/components/filter-bar/index.tsx +976 -0
- package/src/components/filter-bar/meta.md +57 -0
- package/src/components/filter-bar/stories.tsx +496 -0
- package/src/components/float-button/index.tsx +163 -0
- package/src/components/float-button/meta.md +73 -0
- package/src/components/float-button/stories.tsx +68 -0
- package/src/components/form/index.tsx +218 -0
- package/src/components/form/meta.md +16 -0
- package/src/components/form/stories.tsx +301 -0
- package/src/components/hover-card/index.tsx +103 -0
- package/src/components/hover-card/meta.md +71 -0
- package/src/components/hover-card/stories.tsx +107 -0
- package/src/components/icon/index.tsx +225 -0
- package/src/components/icon/meta.md +102 -0
- package/src/components/icon/stories.tsx +127 -0
- package/src/components/image/index.tsx +147 -0
- package/src/components/image/meta.md +55 -0
- package/src/components/image/stories.tsx +48 -0
- package/src/components/input/index.tsx +63 -0
- package/src/components/input/meta.md +57 -0
- package/src/components/input/stories.tsx +66 -0
- package/src/components/input-group/index.tsx +292 -0
- package/src/components/input-group/meta.md +108 -0
- package/src/components/input-group/stories.tsx +258 -0
- package/src/components/input-ip/index.tsx +288 -0
- package/src/components/input-ip/meta.md +48 -0
- package/src/components/input-ip/stories.tsx +69 -0
- package/src/components/input-number/index.tsx +360 -0
- package/src/components/input-number/meta.md +156 -0
- package/src/components/input-number/stories.tsx +187 -0
- package/src/components/item/index.tsx +368 -0
- package/src/components/item/meta.md +395 -0
- package/src/components/item/stories.tsx +432 -0
- package/src/components/label/index.tsx +44 -0
- package/src/components/label/meta.md +68 -0
- package/src/components/label/stories.tsx +64 -0
- package/src/components/mentions/index.tsx +369 -0
- package/src/components/mentions/meta.md +118 -0
- package/src/components/mentions/stories.tsx +153 -0
- package/src/components/menubar/index.tsx +313 -0
- package/src/components/menubar/meta.md +52 -0
- package/src/components/menubar/stories.tsx +99 -0
- package/src/components/navigation-menu/index.tsx +216 -0
- package/src/components/navigation-menu/meta.md +66 -0
- package/src/components/navigation-menu/stories.tsx +137 -0
- package/src/components/page-header/index.tsx +218 -0
- package/src/components/page-header/meta.md +211 -0
- package/src/components/page-header/stories.tsx +290 -0
- package/src/components/page-shell/index.tsx +119 -0
- package/src/components/page-shell/meta.md +115 -0
- package/src/components/page-shell/stories.tsx +154 -0
- package/src/components/pagination/index.tsx +580 -0
- package/src/components/pagination/meta.md +39 -0
- package/src/components/pagination/stories.tsx +319 -0
- package/src/components/popconfirm/index.tsx +477 -0
- package/src/components/popconfirm/meta.md +164 -0
- package/src/components/popconfirm/stories.tsx +231 -0
- package/src/components/popover/index.tsx +181 -0
- package/src/components/popover/meta.md +97 -0
- package/src/components/popover/stories.tsx +169 -0
- package/src/components/progress/index.tsx +176 -0
- package/src/components/progress/meta.md +95 -0
- package/src/components/progress/stories.tsx +115 -0
- package/src/components/radio-group/index.tsx +78 -0
- package/src/components/radio-group/meta.md +137 -0
- package/src/components/radio-group/stories.tsx +285 -0
- package/src/components/rate/index.tsx +284 -0
- package/src/components/rate/meta.md +63 -0
- package/src/components/rate/stories.tsx +107 -0
- package/src/components/resizable/index.tsx +122 -0
- package/src/components/resizable/meta.md +142 -0
- package/src/components/resizable/stories.tsx +105 -0
- package/src/components/scroll-area/index.tsx +83 -0
- package/src/components/scroll-area/meta.md +85 -0
- package/src/components/scroll-area/stories.tsx +82 -0
- package/src/components/select/index.tsx +325 -0
- package/src/components/select/meta.md +183 -0
- package/src/components/select/stories.tsx +210 -0
- package/src/components/separator/index.tsx +51 -0
- package/src/components/separator/meta.md +68 -0
- package/src/components/separator/stories.tsx +53 -0
- package/src/components/sheet/index.tsx +293 -0
- package/src/components/sheet/meta.md +226 -0
- package/src/components/sheet/stories.tsx +405 -0
- package/src/components/sidebar/index.tsx +715 -0
- package/src/components/sidebar/meta.md +14 -0
- package/src/components/sidebar/{sidebar.stories.tsx → stories.tsx} +250 -330
- package/src/components/skeleton/index.tsx +415 -0
- package/src/components/skeleton/meta.md +210 -0
- package/src/components/skeleton/stories.tsx +197 -0
- package/src/components/slider/index.tsx +222 -0
- package/src/components/slider/meta.md +125 -0
- package/src/components/slider/stories.tsx +109 -0
- package/src/components/sonner/index.tsx +149 -0
- package/src/components/sonner/meta.md +156 -0
- package/src/components/sonner/stories.tsx +285 -0
- package/src/components/spinner/index.tsx +335 -0
- package/src/components/spinner/meta.md +172 -0
- package/src/components/spinner/stories.tsx +197 -0
- package/src/components/statistic/{statistic.tsx → index.tsx} +25 -26
- package/src/components/statistic/meta.md +94 -0
- package/src/components/statistic/stories.tsx +85 -0
- package/src/components/steps/index.tsx +500 -0
- package/src/components/steps/meta.md +245 -0
- package/src/components/steps/stories.tsx +287 -0
- package/src/components/switch/index.tsx +175 -0
- package/src/components/switch/meta.md +107 -0
- package/src/components/switch/stories.tsx +154 -0
- package/src/components/table/index.tsx +350 -0
- package/src/components/table/meta.md +148 -0
- package/src/components/table/stories.tsx +189 -0
- package/src/components/tabs/index.tsx +379 -0
- package/src/components/tabs/meta.md +244 -0
- package/src/components/tabs/stories.tsx +312 -0
- package/src/components/tag/index.tsx +774 -0
- package/src/components/tag/meta.md +256 -0
- package/src/components/tag/stories.tsx +431 -0
- package/src/components/textarea/index.tsx +62 -0
- package/src/components/textarea/meta.md +77 -0
- package/src/components/textarea/stories.tsx +112 -0
- package/src/components/time-picker/index.tsx +887 -0
- package/src/components/time-picker/meta.md +102 -0
- package/src/components/time-picker/stories.tsx +125 -0
- package/src/components/timeline/index.tsx +422 -0
- package/src/components/timeline/meta.md +352 -0
- package/src/components/timeline/stories.tsx +369 -0
- package/src/components/toggle/index.tsx +74 -0
- package/src/components/toggle/meta.md +76 -0
- package/src/components/toggle/stories.tsx +66 -0
- package/src/components/toggle-group/index.tsx +167 -0
- package/src/components/toggle-group/meta.md +141 -0
- package/src/components/toggle-group/stories.tsx +124 -0
- package/src/components/tooltip/index.tsx +144 -0
- package/src/components/tooltip/meta.md +186 -0
- package/src/components/tooltip/stories.tsx +212 -0
- package/src/components/transfer/index.tsx +639 -0
- package/src/components/transfer/meta.md +76 -0
- package/src/components/transfer/stories.tsx +221 -0
- package/src/components/tree/index.tsx +764 -0
- package/src/components/tree/meta.md +96 -0
- package/src/components/tree/stories.tsx +385 -0
- package/src/components/tree/utils.ts +269 -0
- package/src/components/tree-select/index.tsx +400 -0
- package/src/components/tree-select/meta.md +78 -0
- package/src/components/tree-select/stories.tsx +234 -0
- package/src/components/typography/index.tsx +290 -0
- package/src/components/typography/meta.md +151 -0
- package/src/components/typography/stories.tsx +151 -0
- package/src/components/upload/index.tsx +858 -0
- package/src/components/upload/meta.md +122 -0
- package/src/components/upload/stories.tsx +261 -0
- package/src/components/watermark/index.tsx +152 -0
- package/src/components/watermark/meta.md +67 -0
- package/src/components/watermark/stories.tsx +59 -0
- package/src/hooks/use-mobile.ts +9 -11
- package/src/lib/color.ts +243 -0
- package/src/{utils/cn.ts → lib/utils.ts} +1 -1
- package/src/components/accordion/accordion.meta.md +0 -88
- package/src/components/accordion/accordion.stories.tsx +0 -72
- package/src/components/accordion/accordion.tsx +0 -154
- package/src/components/affix/affix.meta.md +0 -98
- package/src/components/affix/affix.stories.tsx +0 -134
- package/src/components/affix/affix.tsx +0 -167
- package/src/components/alert/alert.meta.md +0 -132
- package/src/components/alert/alert.stories.tsx +0 -138
- package/src/components/alert/alert.tsx +0 -179
- package/src/components/alert-dialog/alert-dialog.meta.md +0 -152
- package/src/components/alert-dialog/alert-dialog.stories.tsx +0 -223
- package/src/components/alert-dialog/alert-dialog.tsx +0 -183
- package/src/components/anchor/anchor.meta.md +0 -92
- package/src/components/anchor/anchor.stories.tsx +0 -74
- package/src/components/anchor/anchor.tsx +0 -130
- package/src/components/app/app.meta.md +0 -91
- package/src/components/app/app.stories.tsx +0 -64
- package/src/components/app/app.tsx +0 -58
- package/src/components/aspect-ratio/aspect-ratio.meta.md +0 -82
- package/src/components/aspect-ratio/aspect-ratio.stories.tsx +0 -59
- package/src/components/aspect-ratio/aspect-ratio.tsx +0 -22
- package/src/components/auto-complete/auto-complete.meta.md +0 -110
- package/src/components/auto-complete/auto-complete.stories.tsx +0 -136
- package/src/components/auto-complete/auto-complete.tsx +0 -253
- package/src/components/avatar/avatar.meta.md +0 -93
- package/src/components/avatar/avatar.stories.tsx +0 -98
- package/src/components/avatar/avatar.tsx +0 -127
- package/src/components/badge/badge.meta.md +0 -120
- package/src/components/badge/badge.stories.tsx +0 -153
- package/src/components/badge/badge.tsx +0 -204
- package/src/components/breadcrumb/breadcrumb.meta.md +0 -127
- package/src/components/breadcrumb/breadcrumb.stories.tsx +0 -207
- package/src/components/breadcrumb/breadcrumb.tsx +0 -136
- package/src/components/button/button.meta.md +0 -335
- package/src/components/button/button.stories.tsx +0 -743
- package/src/components/button/button.tsx +0 -466
- package/src/components/calendar/calendar.meta.md +0 -128
- package/src/components/calendar/calendar.stories.tsx +0 -68
- package/src/components/calendar/calendar.tsx +0 -172
- package/src/components/card/card.meta.md +0 -139
- package/src/components/card/card.stories.tsx +0 -151
- package/src/components/card/card.tsx +0 -306
- package/src/components/carousel/carousel.meta.md +0 -118
- package/src/components/carousel/carousel.stories.tsx +0 -89
- package/src/components/carousel/carousel.tsx +0 -224
- package/src/components/cascader/cascader.meta.md +0 -140
- package/src/components/cascader/cascader.stories.tsx +0 -120
- package/src/components/cascader/cascader.tsx +0 -548
- package/src/components/checkbox/checkbox.meta.md +0 -167
- package/src/components/checkbox/checkbox.stories.tsx +0 -288
- package/src/components/checkbox/checkbox.tsx +0 -195
- package/src/components/collapsible/collapsible.meta.md +0 -88
- package/src/components/collapsible/collapsible.stories.tsx +0 -43
- package/src/components/collapsible/collapsible.tsx +0 -105
- package/src/components/color-picker/color-picker.meta.md +0 -89
- package/src/components/color-picker/color-picker.stories.tsx +0 -159
- package/src/components/color-picker/color-picker.tsx +0 -171
- package/src/components/command/command.meta.md +0 -120
- package/src/components/command/command.stories.tsx +0 -59
- package/src/components/command/command.tsx +0 -158
- package/src/components/context-menu/context-menu.meta.md +0 -93
- package/src/components/context-menu/context-menu.stories.tsx +0 -54
- package/src/components/context-menu/context-menu.tsx +0 -204
- package/src/components/data-table/data-table.meta.md +0 -150
- package/src/components/data-table/data-table.stories.tsx +0 -132
- package/src/components/data-table/data-table.tsx +0 -185
- package/src/components/date-picker/date-picker.meta.md +0 -175
- package/src/components/date-picker/date-picker.stories.tsx +0 -108
- package/src/components/date-picker/date-picker.tsx +0 -1554
- package/src/components/descriptions/descriptions.meta.md +0 -83
- package/src/components/descriptions/descriptions.stories.tsx +0 -60
- package/src/components/descriptions/descriptions.tsx +0 -137
- package/src/components/dialog/dialog.meta.md +0 -168
- package/src/components/dialog/dialog.stories.tsx +0 -255
- package/src/components/dialog/dialog.tsx +0 -180
- package/src/components/dialog/imperative.tsx +0 -252
- package/src/components/drawer/drawer.meta.md +0 -95
- package/src/components/drawer/drawer.stories.tsx +0 -71
- package/src/components/drawer/drawer.tsx +0 -23
- package/src/components/dropdown-menu/dropdown-menu.meta.md +0 -171
- package/src/components/dropdown-menu/dropdown-menu.stories.tsx +0 -198
- package/src/components/dropdown-menu/dropdown-menu.tsx +0 -209
- package/src/components/ellipsis/ellipsis.meta.md +0 -87
- package/src/components/ellipsis/ellipsis.stories.tsx +0 -72
- package/src/components/ellipsis/ellipsis.tsx +0 -153
- package/src/components/empty/empty.meta.md +0 -86
- package/src/components/empty/empty.stories.tsx +0 -46
- package/src/components/empty/empty.tsx +0 -54
- package/src/components/field/field.meta.md +0 -154
- package/src/components/field/field.stories.tsx +0 -497
- package/src/components/field/field.tsx +0 -392
- package/src/components/filter-bar/filter-bar.meta.md +0 -92
- package/src/components/filter-bar/filter-bar.stories.tsx +0 -1086
- package/src/components/filter-bar/filter-bar.tsx +0 -568
- package/src/components/flex/flex.meta.md +0 -142
- package/src/components/flex/flex.stories.tsx +0 -199
- package/src/components/flex/flex.tsx +0 -145
- package/src/components/float-button/float-button.meta.md +0 -92
- package/src/components/float-button/float-button.stories.tsx +0 -80
- package/src/components/float-button/float-button.tsx +0 -143
- package/src/components/form/form.meta.md +0 -153
- package/src/components/form/form.stories.tsx +0 -472
- package/src/components/form/form.tsx +0 -260
- package/src/components/grid/grid.meta.md +0 -92
- package/src/components/grid/grid.stories.tsx +0 -101
- package/src/components/grid/grid.tsx +0 -130
- package/src/components/hover-card/hover-card.meta.md +0 -103
- package/src/components/hover-card/hover-card.stories.tsx +0 -97
- package/src/components/hover-card/hover-card.tsx +0 -67
- package/src/components/icon/DEVELOPMENT.md +0 -809
- package/src/components/icon/icon.meta.md +0 -170
- package/src/components/icon/icon.stories.tsx +0 -344
- package/src/components/icon/icon.tsx +0 -248
- package/src/components/image/image.meta.md +0 -99
- package/src/components/image/image.stories.tsx +0 -55
- package/src/components/image/image.tsx +0 -140
- package/src/components/input/input.meta.md +0 -115
- package/src/components/input/input.stories.tsx +0 -144
- package/src/components/input/input.tsx +0 -212
- package/src/components/input-group/input-group.meta.md +0 -124
- package/src/components/input-group/input-group.stories.tsx +0 -121
- package/src/components/input-group/input-group.tsx +0 -143
- package/src/components/input-number/input-number.meta.md +0 -148
- package/src/components/input-number/input-number.stories.tsx +0 -125
- package/src/components/input-number/input-number.tsx +0 -283
- package/src/components/input-otp/input-otp.meta.md +0 -106
- package/src/components/input-otp/input-otp.stories.tsx +0 -65
- package/src/components/input-otp/input-otp.tsx +0 -97
- package/src/components/item/item.meta.md +0 -121
- package/src/components/item/item.stories.tsx +0 -116
- package/src/components/item/item.tsx +0 -172
- package/src/components/kbd/kbd.meta.md +0 -94
- package/src/components/kbd/kbd.stories.tsx +0 -70
- package/src/components/kbd/kbd.tsx +0 -86
- package/src/components/label/label.meta.md +0 -99
- package/src/components/label/label.stories.tsx +0 -145
- package/src/components/label/label.tsx +0 -138
- package/src/components/masonry/masonry.meta.md +0 -90
- package/src/components/masonry/masonry.stories.tsx +0 -68
- package/src/components/masonry/masonry.tsx +0 -60
- package/src/components/mentions/mentions.meta.md +0 -119
- package/src/components/mentions/mentions.stories.tsx +0 -189
- package/src/components/mentions/mentions.tsx +0 -243
- package/src/components/menubar/menubar.meta.md +0 -118
- package/src/components/menubar/menubar.stories.tsx +0 -141
- package/src/components/menubar/menubar.tsx +0 -232
- package/src/components/native-select/native-select.meta.md +0 -93
- package/src/components/native-select/native-select.stories.tsx +0 -83
- package/src/components/native-select/native-select.tsx +0 -54
- package/src/components/navigation-menu/navigation-menu.meta.md +0 -118
- package/src/components/navigation-menu/navigation-menu.stories.tsx +0 -215
- package/src/components/navigation-menu/navigation-menu.tsx +0 -129
- package/src/components/notification/notification.meta.md +0 -133
- package/src/components/notification/notification.stories.tsx +0 -98
- package/src/components/notification/notification.tsx +0 -99
- package/src/components/page-header/DEVELOPMENT.md +0 -842
- package/src/components/page-header/page-header.meta.md +0 -210
- package/src/components/page-header/page-header.stories.tsx +0 -428
- package/src/components/page-header/page-header.tsx +0 -284
- package/src/components/page-shell/page-shell.meta.md +0 -116
- package/src/components/page-shell/page-shell.stories.tsx +0 -149
- package/src/components/page-shell/page-shell.tsx +0 -115
- package/src/components/pagination/pagination.meta.md +0 -230
- package/src/components/pagination/pagination.stories.tsx +0 -284
- package/src/components/pagination/pagination.tsx +0 -567
- package/src/components/popconfirm/popconfirm.meta.md +0 -114
- package/src/components/popconfirm/popconfirm.stories.tsx +0 -75
- package/src/components/popconfirm/popconfirm.tsx +0 -134
- package/src/components/popover/popover.meta.md +0 -154
- package/src/components/popover/popover.stories.tsx +0 -158
- package/src/components/popover/popover.tsx +0 -104
- package/src/components/progress/progress.meta.md +0 -118
- package/src/components/progress/progress.stories.tsx +0 -75
- package/src/components/progress/progress.tsx +0 -203
- package/src/components/radio-group/radio-group.meta.md +0 -175
- package/src/components/radio-group/radio-group.stories.tsx +0 -113
- package/src/components/radio-group/radio-group.tsx +0 -209
- package/src/components/rate/rate.meta.md +0 -118
- package/src/components/rate/rate.stories.tsx +0 -89
- package/src/components/rate/rate.tsx +0 -180
- package/src/components/resizable/resizable.meta.md +0 -95
- package/src/components/resizable/resizable.stories.tsx +0 -104
- package/src/components/resizable/resizable.tsx +0 -56
- package/src/components/result/result.meta.md +0 -95
- package/src/components/result/result.stories.tsx +0 -67
- package/src/components/result/result.tsx +0 -100
- package/src/components/scroll-area/scroll-area.meta.md +0 -85
- package/src/components/scroll-area/scroll-area.stories.tsx +0 -49
- package/src/components/scroll-area/scroll-area.tsx +0 -51
- package/src/components/segmented/segmented.meta.md +0 -106
- package/src/components/segmented/segmented.stories.tsx +0 -130
- package/src/components/segmented/segmented.tsx +0 -146
- package/src/components/select/select.meta.md +0 -255
- package/src/components/select/select.stories.tsx +0 -275
- package/src/components/select/select.tsx +0 -735
- package/src/components/separator/separator.meta.md +0 -75
- package/src/components/separator/separator.stories.tsx +0 -71
- package/src/components/separator/separator.tsx +0 -100
- package/src/components/sheet/sheet.meta.md +0 -113
- package/src/components/sheet/sheet.stories.tsx +0 -188
- package/src/components/sheet/sheet.tsx +0 -226
- package/src/components/sidebar/sidebar.meta.md +0 -151
- package/src/components/sidebar/sidebar.tsx +0 -853
- package/src/components/skeleton/skeleton.meta.md +0 -94
- package/src/components/skeleton/skeleton.stories.tsx +0 -79
- package/src/components/skeleton/skeleton.tsx +0 -144
- package/src/components/slider/slider.meta.md +0 -146
- package/src/components/slider/slider.stories.tsx +0 -121
- package/src/components/slider/slider.tsx +0 -227
- package/src/components/sonner/sonner.meta.md +0 -147
- package/src/components/sonner/sonner.stories.tsx +0 -164
- package/src/components/sonner/sonner.tsx +0 -169
- package/src/components/spinner/spinner.meta.md +0 -125
- package/src/components/spinner/spinner.stories.tsx +0 -123
- package/src/components/spinner/spinner.tsx +0 -166
- package/src/components/statistic/statistic.meta.md +0 -104
- package/src/components/statistic/statistic.stories.tsx +0 -67
- package/src/components/steps/steps.meta.md +0 -116
- package/src/components/steps/steps.stories.tsx +0 -115
- package/src/components/steps/steps.tsx +0 -173
- package/src/components/switch/switch.meta.md +0 -138
- package/src/components/switch/switch.stories.tsx +0 -75
- package/src/components/switch/switch.tsx +0 -169
- package/src/components/table/table.meta.md +0 -106
- package/src/components/table/table.stories.tsx +0 -80
- package/src/components/table/table.tsx +0 -124
- package/src/components/tabs/tabs.meta.md +0 -111
- package/src/components/tabs/tabs.stories.tsx +0 -156
- package/src/components/tabs/tabs.tsx +0 -190
- package/src/components/tag/tag.meta.md +0 -159
- package/src/components/tag/tag.stories.tsx +0 -250
- package/src/components/tag/tag.tsx +0 -386
- package/src/components/textarea/textarea.meta.md +0 -99
- package/src/components/textarea/textarea.stories.tsx +0 -89
- package/src/components/textarea/textarea.tsx +0 -137
- package/src/components/time-picker/time-picker.meta.md +0 -175
- package/src/components/time-picker/time-picker.stories.tsx +0 -129
- package/src/components/time-picker/time-picker.tsx +0 -946
- package/src/components/timeline/timeline.meta.md +0 -110
- package/src/components/timeline/timeline.stories.tsx +0 -134
- package/src/components/timeline/timeline.tsx +0 -168
- package/src/components/toggle/toggle.meta.md +0 -89
- package/src/components/toggle/toggle.stories.tsx +0 -66
- package/src/components/toggle/toggle.tsx +0 -54
- package/src/components/toggle-group/toggle-group.meta.md +0 -91
- package/src/components/toggle-group/toggle-group.stories.tsx +0 -83
- package/src/components/toggle-group/toggle-group.tsx +0 -78
- package/src/components/tooltip/tooltip.meta.md +0 -149
- package/src/components/tooltip/tooltip.stories.tsx +0 -108
- package/src/components/tooltip/tooltip.tsx +0 -153
- package/src/components/tour/tour.meta.md +0 -121
- package/src/components/tour/tour.stories.tsx +0 -66
- package/src/components/tour/tour.tsx +0 -242
- package/src/components/transfer/transfer.meta.md +0 -95
- package/src/components/transfer/transfer.stories.tsx +0 -64
- package/src/components/transfer/transfer.tsx +0 -258
- package/src/components/tree/tree.meta.md +0 -169
- package/src/components/tree/tree.stories.tsx +0 -128
- package/src/components/tree/tree.tsx +0 -368
- package/src/components/tree-select/tree-select.meta.md +0 -151
- package/src/components/tree-select/tree-select.stories.tsx +0 -80
- package/src/components/tree-select/tree-select.tsx +0 -206
- package/src/components/typography/typography.meta.md +0 -149
- package/src/components/typography/typography.stories.tsx +0 -116
- package/src/components/typography/typography.tsx +0 -260
- package/src/components/upload/upload.meta.md +0 -156
- package/src/components/upload/upload.stories.tsx +0 -135
- package/src/components/upload/upload.tsx +0 -398
- package/src/components/watermark/watermark.meta.md +0 -100
- package/src/components/watermark/watermark.stories.tsx +0 -170
- package/src/components/watermark/watermark.tsx +0 -166
- package/src/hooks/use-breakpoint.ts +0 -117
- package/src/hooks/use-debounce-callback.ts +0 -52
- package/src/stories/theme-tokens.stories.tsx +0 -747
- package/src/utils/trigger-input.ts +0 -57
|
@@ -0,0 +1,1234 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { RefreshCw, Rows3, Settings2 } from 'lucide-react';
|
|
4
|
+
import { useForm } from 'react-hook-form';
|
|
5
|
+
|
|
6
|
+
import { Avatar, AvatarFallback, AvatarImage } from '@/components/avatar';
|
|
7
|
+
import { Button } from '@/components/button';
|
|
8
|
+
import {
|
|
9
|
+
ButtonGroup,
|
|
10
|
+
ButtonGroupOverflow,
|
|
11
|
+
ButtonGroupSeparator,
|
|
12
|
+
} from '@/components/button-group';
|
|
13
|
+
import { Checkbox } from '@/components/checkbox';
|
|
14
|
+
import { DropdownMenuItem } from '@/components/dropdown-menu';
|
|
15
|
+
import {
|
|
16
|
+
FilterBar,
|
|
17
|
+
FilterBarHeader,
|
|
18
|
+
FilterBarSearch,
|
|
19
|
+
FilterBarSearchKey,
|
|
20
|
+
FilterBarSearchValue,
|
|
21
|
+
FilterBarSearchAction,
|
|
22
|
+
FilterBarTrigger,
|
|
23
|
+
FilterBarContent,
|
|
24
|
+
FilterBarActions,
|
|
25
|
+
FilterBarField,
|
|
26
|
+
} from '@/components/filter-bar';
|
|
27
|
+
import { Input } from '@/components/input';
|
|
28
|
+
import { Popover, PopoverContent, PopoverTrigger } from '@/components/popover';
|
|
29
|
+
import {
|
|
30
|
+
Select,
|
|
31
|
+
SelectContent,
|
|
32
|
+
SelectItem,
|
|
33
|
+
SelectTrigger,
|
|
34
|
+
SelectValue,
|
|
35
|
+
} from '@/components/select';
|
|
36
|
+
import { Tag } from '@/components/tag';
|
|
37
|
+
import { Title, Paragraph } from '@/components/typography';
|
|
38
|
+
import { DataTable, EditableCell, type DataTableColumn } from './index';
|
|
39
|
+
|
|
40
|
+
const meta: Meta<typeof DataTable> = {
|
|
41
|
+
title: '数据展示 · Data Display/DataTable 数据表格',
|
|
42
|
+
component: DataTable,
|
|
43
|
+
tags: ['autodocs'],
|
|
44
|
+
};
|
|
45
|
+
export default meta;
|
|
46
|
+
|
|
47
|
+
type Story = StoryObj<typeof meta>;
|
|
48
|
+
|
|
49
|
+
interface User {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
age: number;
|
|
53
|
+
role: '管理员' | '开发' | '运维' | '产品';
|
|
54
|
+
status: 'active' | 'paused' | 'banned';
|
|
55
|
+
city: string;
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const users: User[] = [
|
|
60
|
+
{
|
|
61
|
+
id: '1',
|
|
62
|
+
name: '张三',
|
|
63
|
+
age: 28,
|
|
64
|
+
role: '管理员',
|
|
65
|
+
status: 'active',
|
|
66
|
+
city: '北京',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: '2',
|
|
70
|
+
name: '李四',
|
|
71
|
+
age: 35,
|
|
72
|
+
role: '开发',
|
|
73
|
+
status: 'active',
|
|
74
|
+
city: '上海',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: '3',
|
|
78
|
+
name: '王五',
|
|
79
|
+
age: 24,
|
|
80
|
+
role: '运维',
|
|
81
|
+
status: 'paused',
|
|
82
|
+
city: '杭州',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: '4',
|
|
86
|
+
name: '赵六',
|
|
87
|
+
age: 41,
|
|
88
|
+
role: '产品',
|
|
89
|
+
status: 'active',
|
|
90
|
+
city: '深圳',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: '5',
|
|
94
|
+
name: '钱七',
|
|
95
|
+
age: 30,
|
|
96
|
+
role: '开发',
|
|
97
|
+
status: 'banned',
|
|
98
|
+
city: '北京',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: '6',
|
|
102
|
+
name: '孙八',
|
|
103
|
+
age: 27,
|
|
104
|
+
role: '开发',
|
|
105
|
+
status: 'active',
|
|
106
|
+
city: '成都',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: '7',
|
|
110
|
+
name: '周九',
|
|
111
|
+
age: 33,
|
|
112
|
+
role: '运维',
|
|
113
|
+
status: 'active',
|
|
114
|
+
city: '上海',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: '8',
|
|
118
|
+
name: '吴十',
|
|
119
|
+
age: 22,
|
|
120
|
+
role: '产品',
|
|
121
|
+
status: 'paused',
|
|
122
|
+
city: '广州',
|
|
123
|
+
},
|
|
124
|
+
];
|
|
125
|
+
|
|
126
|
+
const baseColumns: DataTableColumn<User>[] = [
|
|
127
|
+
{ key: 'name', dataIndex: 'name', title: '姓名', width: 100 },
|
|
128
|
+
{ key: 'age', dataIndex: 'age', title: '年龄', width: 80, align: 'right' },
|
|
129
|
+
{ key: 'role', dataIndex: 'role', title: '角色', width: 100 },
|
|
130
|
+
{ key: 'status', dataIndex: 'status', title: '状态', width: 100 },
|
|
131
|
+
{ key: 'city', dataIndex: 'city', title: '城市' },
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
// ─── Default story 真实业务数据 (实例列表) ───────────────────────────────
|
|
135
|
+
|
|
136
|
+
interface Instance {
|
|
137
|
+
id: string;
|
|
138
|
+
name: string;
|
|
139
|
+
instanceId: string;
|
|
140
|
+
tags: string[];
|
|
141
|
+
creator: string;
|
|
142
|
+
avatar?: string;
|
|
143
|
+
org: string;
|
|
144
|
+
ip: string;
|
|
145
|
+
spec: string;
|
|
146
|
+
status: string;
|
|
147
|
+
[key: string]: unknown;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const instances: Instance[] = [
|
|
151
|
+
{
|
|
152
|
+
id: '1',
|
|
153
|
+
name: 'Kvbkqv(置花计红子从省)',
|
|
154
|
+
instanceId: 'c4b7BFeC-e57f-80CC-d65B-E4A...',
|
|
155
|
+
tags: ['开发', '测试'],
|
|
156
|
+
creator: '必此机利',
|
|
157
|
+
org: '组织名称 连毛须系林利军',
|
|
158
|
+
ip: '私 237.11.254.139',
|
|
159
|
+
spec: '4核16G',
|
|
160
|
+
status: 'processing',
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: '2',
|
|
164
|
+
name: 'Siqqqoeh(她组术意办了住八众)',
|
|
165
|
+
instanceId: 'e1DDfb4a-b592-47db-309F-Ba9...',
|
|
166
|
+
tags: ['生产'],
|
|
167
|
+
creator: '百江四角',
|
|
168
|
+
org: '组织名称 金照二把切根',
|
|
169
|
+
ip: '私 170.113.46.126',
|
|
170
|
+
spec: '2核8G',
|
|
171
|
+
status: 'processing',
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
id: '3',
|
|
175
|
+
name: 'Kmdnqzlxi(强周压见之听调存)',
|
|
176
|
+
instanceId: '31845E5A-9c7B-Ca0F-73bd-fBCa...',
|
|
177
|
+
tags: ['开发', '线上'],
|
|
178
|
+
creator: '向八志省理',
|
|
179
|
+
org: '组织名称 见任地速了上快商',
|
|
180
|
+
ip: '私 14.218.57.70',
|
|
181
|
+
spec: '8核32G',
|
|
182
|
+
status: 'pause',
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
id: '4',
|
|
186
|
+
name: 'Ekkwbbiux(地由约求马性安)',
|
|
187
|
+
instanceId: 'd1bDe3ed-531A-c4Cb-5f95-5cF3...',
|
|
188
|
+
tags: ['测试', '预发'],
|
|
189
|
+
creator: '张它将高学什',
|
|
190
|
+
org: '组织名称 位住照志党元',
|
|
191
|
+
ip: '私 138.82.89.83',
|
|
192
|
+
spec: '4核16G',
|
|
193
|
+
status: 'processing',
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
id: '5',
|
|
197
|
+
name: 'Jbweksdc(点常头离加素)',
|
|
198
|
+
instanceId: 'd810277F-EB8A-A31E-f9Bf-e9A9...',
|
|
199
|
+
tags: ['生产', '核心'],
|
|
200
|
+
creator: '这次打眼又',
|
|
201
|
+
org: '组织名称 时石内响儿克术会',
|
|
202
|
+
ip: '私 131.167.88.128',
|
|
203
|
+
spec: '2核4G',
|
|
204
|
+
status: 'success',
|
|
205
|
+
},
|
|
206
|
+
];
|
|
207
|
+
|
|
208
|
+
const instanceColumns: DataTableColumn<Instance>[] = [
|
|
209
|
+
{
|
|
210
|
+
key: 'name',
|
|
211
|
+
dataIndex: 'name',
|
|
212
|
+
title: '实例ID/实例名称',
|
|
213
|
+
width: 280,
|
|
214
|
+
render: (_val, record) => (
|
|
215
|
+
<div className="flex flex-col gap-0.5">
|
|
216
|
+
<a
|
|
217
|
+
href="#"
|
|
218
|
+
className="font-medium text-primary"
|
|
219
|
+
onClick={(e) => e.preventDefault()}
|
|
220
|
+
>
|
|
221
|
+
{record.name}
|
|
222
|
+
</a>
|
|
223
|
+
<span className="text-muted-foreground">{record.instanceId}</span>
|
|
224
|
+
</div>
|
|
225
|
+
),
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
key: 'tags',
|
|
229
|
+
dataIndex: 'tags',
|
|
230
|
+
title: '标签',
|
|
231
|
+
width: 140,
|
|
232
|
+
render: (val) => {
|
|
233
|
+
const tags = val as string[];
|
|
234
|
+
return (
|
|
235
|
+
<span className="inline-flex flex-wrap items-center gap-1">
|
|
236
|
+
{tags.map((t) => (
|
|
237
|
+
<Tag key={t} size="sm">
|
|
238
|
+
{t}
|
|
239
|
+
</Tag>
|
|
240
|
+
))}
|
|
241
|
+
</span>
|
|
242
|
+
);
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
key: 'status',
|
|
247
|
+
dataIndex: 'status',
|
|
248
|
+
title: '状态',
|
|
249
|
+
width: 140,
|
|
250
|
+
render: (val) => (
|
|
251
|
+
<Tag
|
|
252
|
+
variant="status"
|
|
253
|
+
status={val as 'processing' | 'success' | 'pause'}
|
|
254
|
+
showIcon
|
|
255
|
+
>
|
|
256
|
+
{val === 'processing'
|
|
257
|
+
? '运行中'
|
|
258
|
+
: val === 'success'
|
|
259
|
+
? '已完成'
|
|
260
|
+
: '已停止'}
|
|
261
|
+
</Tag>
|
|
262
|
+
),
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
key: 'ip',
|
|
266
|
+
dataIndex: 'ip',
|
|
267
|
+
title: 'IP 地址',
|
|
268
|
+
width: 180,
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
key: 'spec',
|
|
272
|
+
dataIndex: 'spec',
|
|
273
|
+
title: '规格',
|
|
274
|
+
width: 120,
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
key: 'creator',
|
|
278
|
+
dataIndex: 'creator',
|
|
279
|
+
title: '创建者',
|
|
280
|
+
width: 160,
|
|
281
|
+
render: (val) => (
|
|
282
|
+
<span className="inline-flex items-center gap-2">
|
|
283
|
+
<Avatar className="size-6">
|
|
284
|
+
<AvatarImage alt="@shadcn" src="https://github.com/shadcn.png" />
|
|
285
|
+
<AvatarFallback>{(val as string).slice(0, 1)}</AvatarFallback>
|
|
286
|
+
</Avatar>
|
|
287
|
+
<span>{val as string}</span>
|
|
288
|
+
</span>
|
|
289
|
+
),
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
key: 'org',
|
|
293
|
+
dataIndex: 'org',
|
|
294
|
+
title: '组织',
|
|
295
|
+
width: 240,
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
key: 'actions',
|
|
299
|
+
title: '操作',
|
|
300
|
+
width: 220,
|
|
301
|
+
fixed: 'right',
|
|
302
|
+
render: () => (
|
|
303
|
+
<ButtonGroup className="h-4 gap-3">
|
|
304
|
+
<Button variant="link">管理</Button>
|
|
305
|
+
<ButtonGroupSeparator />
|
|
306
|
+
<Button variant="link">编辑</Button>
|
|
307
|
+
<ButtonGroupSeparator />
|
|
308
|
+
<Button variant="link">远程连接</Button>
|
|
309
|
+
<ButtonGroupSeparator />
|
|
310
|
+
<ButtonGroupOverflow variant="link">
|
|
311
|
+
<DropdownMenuItem>释放</DropdownMenuItem>
|
|
312
|
+
<DropdownMenuItem>暂停</DropdownMenuItem>
|
|
313
|
+
<DropdownMenuItem variant="destructive">删除</DropdownMenuItem>
|
|
314
|
+
</ButtonGroupOverflow>
|
|
315
|
+
</ButtonGroup>
|
|
316
|
+
),
|
|
317
|
+
},
|
|
318
|
+
];
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* 默认用法:实例列表场景 — 小尺寸 + 锁列 + 富单元格渲染 + 分页。
|
|
322
|
+
*
|
|
323
|
+
* 外层工具栏(按钮、搜索、高级筛选)和筛选面板不属于 DataTable,由页面级组合实现。
|
|
324
|
+
* 右侧操作列 `fixed: 'right'` 产生的左侧边框是锁列指示器,横向滚动时可见。
|
|
325
|
+
*/
|
|
326
|
+
export const Default: Story = {
|
|
327
|
+
render: () => (
|
|
328
|
+
<DataTable<Instance>
|
|
329
|
+
columns={instanceColumns}
|
|
330
|
+
data={instances}
|
|
331
|
+
pagination={{
|
|
332
|
+
total: 100,
|
|
333
|
+
defaultPageSize: 5,
|
|
334
|
+
pageSizeOptions: [5, 10, 20],
|
|
335
|
+
showSizeChanger: true,
|
|
336
|
+
showTotal: true,
|
|
337
|
+
}}
|
|
338
|
+
/>
|
|
339
|
+
),
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
// ─── 完整页面组合示例 ─────────────────────────────────────────
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* 完整页面组合:展示 DataTable 在真实业务页面中的使用方式。
|
|
346
|
+
*
|
|
347
|
+
* 体现 shadcn 组合式理念:页面级布局由多个独立组件自由组合,DataTable 只负责表格渲染,
|
|
348
|
+
* Toolbar / FilterBar / Typography 等是兄弟组件,通过外部 state 与 DataTable 通信。
|
|
349
|
+
*/
|
|
350
|
+
export const Full: Story = {
|
|
351
|
+
render: () => {
|
|
352
|
+
const form = useForm({
|
|
353
|
+
defaultValues: { instanceId: '', resourceGroup: '', region: '' },
|
|
354
|
+
});
|
|
355
|
+
const [size, setSize] = React.useState<'sm' | 'md'>('sm');
|
|
356
|
+
const [visibility, setVisibility] = React.useState<Record<string, boolean>>(
|
|
357
|
+
{},
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
return (
|
|
361
|
+
<div className="flex flex-col gap-4">
|
|
362
|
+
{/* 页头:标题 + 描述 */}
|
|
363
|
+
<div className="flex items-center gap-2">
|
|
364
|
+
<Title level={4}>实例列表</Title>
|
|
365
|
+
<Paragraph color="muted">
|
|
366
|
+
展示 DataTable 在完整页面中的组合使用方式
|
|
367
|
+
</Paragraph>
|
|
368
|
+
</div>
|
|
369
|
+
|
|
370
|
+
{/* FilterBar:搜索 + 高级筛选 + Toolbar */}
|
|
371
|
+
<FilterBar
|
|
372
|
+
form={form}
|
|
373
|
+
onFilter={(values) => console.log('filter:', values)}
|
|
374
|
+
addonBefore={
|
|
375
|
+
<div className="flex items-center gap-2">
|
|
376
|
+
<Button>数据请求</Button>
|
|
377
|
+
<Button variant="outline">二次确认</Button>
|
|
378
|
+
</div>
|
|
379
|
+
}
|
|
380
|
+
addonAfter={
|
|
381
|
+
<div className="flex items-center gap-1">
|
|
382
|
+
<Button variant="outline" size="icon">
|
|
383
|
+
<RefreshCw />
|
|
384
|
+
</Button>
|
|
385
|
+
<Button
|
|
386
|
+
variant="outline"
|
|
387
|
+
size="icon"
|
|
388
|
+
onClick={() => setSize(size === 'sm' ? 'md' : 'sm')}
|
|
389
|
+
>
|
|
390
|
+
<Rows3 />
|
|
391
|
+
</Button>
|
|
392
|
+
<Popover>
|
|
393
|
+
<PopoverTrigger asChild>
|
|
394
|
+
<Button variant="outline" size="icon">
|
|
395
|
+
<Settings2 />
|
|
396
|
+
</Button>
|
|
397
|
+
</PopoverTrigger>
|
|
398
|
+
<PopoverContent align="end" className="w-40 p-2">
|
|
399
|
+
<div className="flex flex-col gap-1.5">
|
|
400
|
+
{instanceColumns.map((col) => {
|
|
401
|
+
const id = col.key!;
|
|
402
|
+
const checked = visibility[id] !== false;
|
|
403
|
+
return (
|
|
404
|
+
<label
|
|
405
|
+
key={id}
|
|
406
|
+
className="flex cursor-pointer items-center gap-2 text-xs"
|
|
407
|
+
>
|
|
408
|
+
<Checkbox
|
|
409
|
+
checked={checked}
|
|
410
|
+
onCheckedChange={(c) =>
|
|
411
|
+
setVisibility((prev) => ({
|
|
412
|
+
...prev,
|
|
413
|
+
[id]: c === true,
|
|
414
|
+
}))
|
|
415
|
+
}
|
|
416
|
+
/>
|
|
417
|
+
<span>
|
|
418
|
+
{typeof col.title === 'string' ? col.title : id}
|
|
419
|
+
</span>
|
|
420
|
+
</label>
|
|
421
|
+
);
|
|
422
|
+
})}
|
|
423
|
+
</div>
|
|
424
|
+
</PopoverContent>
|
|
425
|
+
</Popover>
|
|
426
|
+
</div>
|
|
427
|
+
}
|
|
428
|
+
>
|
|
429
|
+
<FilterBarHeader>
|
|
430
|
+
<FilterBarSearch>
|
|
431
|
+
<FilterBarSearchKey
|
|
432
|
+
options={[{ name: 'instanceId', label: '实例ID' }]}
|
|
433
|
+
/>
|
|
434
|
+
<FilterBarSearchValue placeholder="请输入实例ID" />
|
|
435
|
+
<FilterBarSearchAction />
|
|
436
|
+
</FilterBarSearch>
|
|
437
|
+
<FilterBarTrigger />
|
|
438
|
+
</FilterBarHeader>
|
|
439
|
+
<FilterBarContent>
|
|
440
|
+
<FilterBarField name="instanceId" label="实例ID">
|
|
441
|
+
<Input placeholder="请输入" />
|
|
442
|
+
</FilterBarField>
|
|
443
|
+
<FilterBarField name="resourceGroup" label="资源集">
|
|
444
|
+
<Select>
|
|
445
|
+
<SelectTrigger>
|
|
446
|
+
<SelectValue placeholder="全部" />
|
|
447
|
+
</SelectTrigger>
|
|
448
|
+
<SelectContent>
|
|
449
|
+
<SelectItem value="teamix">Teamix</SelectItem>
|
|
450
|
+
<SelectItem value="default">默认</SelectItem>
|
|
451
|
+
</SelectContent>
|
|
452
|
+
</Select>
|
|
453
|
+
</FilterBarField>
|
|
454
|
+
<FilterBarField name="region" label="区域">
|
|
455
|
+
<Select>
|
|
456
|
+
<SelectTrigger>
|
|
457
|
+
<SelectValue placeholder="全部区域" />
|
|
458
|
+
</SelectTrigger>
|
|
459
|
+
<SelectContent>
|
|
460
|
+
<SelectItem value="cn-hangzhou">华东1</SelectItem>
|
|
461
|
+
<SelectItem value="cn-beijing">华北1</SelectItem>
|
|
462
|
+
</SelectContent>
|
|
463
|
+
</Select>
|
|
464
|
+
</FilterBarField>
|
|
465
|
+
<FilterBarActions />
|
|
466
|
+
</FilterBarContent>
|
|
467
|
+
</FilterBar>
|
|
468
|
+
|
|
469
|
+
{/* DataTable:接收外部 state 控制 */}
|
|
470
|
+
<DataTable<Instance>
|
|
471
|
+
columns={instanceColumns}
|
|
472
|
+
data={instances}
|
|
473
|
+
size={size}
|
|
474
|
+
columnVisibility={visibility}
|
|
475
|
+
onColumnVisibilityChange={setVisibility}
|
|
476
|
+
pagination={{
|
|
477
|
+
total: 100,
|
|
478
|
+
defaultPageSize: 5,
|
|
479
|
+
pageSizeOptions: [5, 10, 20],
|
|
480
|
+
showSizeChanger: true,
|
|
481
|
+
showTotal: true,
|
|
482
|
+
}}
|
|
483
|
+
/>
|
|
484
|
+
</div>
|
|
485
|
+
);
|
|
486
|
+
},
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
/** 列显隐:外部 Toolbar 通过 `columnVisibility` + `onColumnVisibilityChange` 控制列显示/隐藏。 */
|
|
490
|
+
export const ColumnVisibility: Story = {
|
|
491
|
+
render: () => {
|
|
492
|
+
const [visibility, setVisibility] = React.useState<Record<string, boolean>>(
|
|
493
|
+
{},
|
|
494
|
+
);
|
|
495
|
+
const [size, setSize] = React.useState<'sm' | 'md'>('sm');
|
|
496
|
+
const columns: DataTableColumn<User>[] = [
|
|
497
|
+
{ key: 'name', dataIndex: 'name', title: '姓名', width: 100 },
|
|
498
|
+
{
|
|
499
|
+
key: 'age',
|
|
500
|
+
dataIndex: 'age',
|
|
501
|
+
title: '年龄',
|
|
502
|
+
width: 80,
|
|
503
|
+
align: 'right',
|
|
504
|
+
},
|
|
505
|
+
{ key: 'role', dataIndex: 'role', title: '角色', width: 120 },
|
|
506
|
+
{ key: 'status', dataIndex: 'status', title: '状态', width: 100 },
|
|
507
|
+
{ key: 'city', dataIndex: 'city', title: '城市' },
|
|
508
|
+
];
|
|
509
|
+
return (
|
|
510
|
+
<div className="flex flex-col gap-3">
|
|
511
|
+
{/* 外部 Toolbar — 密度切换 + 列配置 */}
|
|
512
|
+
<div className="flex items-center justify-end gap-2">
|
|
513
|
+
<Button
|
|
514
|
+
size="sm"
|
|
515
|
+
variant={size === 'sm' ? 'default' : 'outline'}
|
|
516
|
+
onClick={() => setSize('sm')}
|
|
517
|
+
>
|
|
518
|
+
紧凑
|
|
519
|
+
</Button>
|
|
520
|
+
<Button
|
|
521
|
+
size="sm"
|
|
522
|
+
variant={size === 'md' ? 'default' : 'outline'}
|
|
523
|
+
onClick={() => setSize('md')}
|
|
524
|
+
>
|
|
525
|
+
宽松
|
|
526
|
+
</Button>
|
|
527
|
+
<Popover>
|
|
528
|
+
<PopoverTrigger asChild>
|
|
529
|
+
<Button size="sm" variant="outline">
|
|
530
|
+
列配置
|
|
531
|
+
</Button>
|
|
532
|
+
</PopoverTrigger>
|
|
533
|
+
<PopoverContent align="end" className="w-40 p-2">
|
|
534
|
+
<div className="flex flex-col gap-1.5">
|
|
535
|
+
{columns.map((col) => {
|
|
536
|
+
const id = col.key!;
|
|
537
|
+
const checked = visibility[id] !== false;
|
|
538
|
+
return (
|
|
539
|
+
<label
|
|
540
|
+
key={id}
|
|
541
|
+
className="flex cursor-pointer items-center gap-2 text-xs"
|
|
542
|
+
>
|
|
543
|
+
<Checkbox
|
|
544
|
+
checked={checked}
|
|
545
|
+
onCheckedChange={(c) =>
|
|
546
|
+
setVisibility((prev) => ({
|
|
547
|
+
...prev,
|
|
548
|
+
[id]: c === true,
|
|
549
|
+
}))
|
|
550
|
+
}
|
|
551
|
+
/>
|
|
552
|
+
<span>
|
|
553
|
+
{typeof col.title === 'string' ? col.title : id}
|
|
554
|
+
</span>
|
|
555
|
+
</label>
|
|
556
|
+
);
|
|
557
|
+
})}
|
|
558
|
+
</div>
|
|
559
|
+
</PopoverContent>
|
|
560
|
+
</Popover>
|
|
561
|
+
</div>
|
|
562
|
+
{/* DataTable 接收受控 props */}
|
|
563
|
+
<DataTable
|
|
564
|
+
columns={columns}
|
|
565
|
+
data={users}
|
|
566
|
+
size={size}
|
|
567
|
+
columnVisibility={visibility}
|
|
568
|
+
onColumnVisibilityChange={setVisibility}
|
|
569
|
+
/>
|
|
570
|
+
</div>
|
|
571
|
+
);
|
|
572
|
+
},
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
/** 列排序:通过 `sortable: true` 启用,单击表头切换 asc / desc / 无。 */
|
|
576
|
+
export const WithSorting: Story = {
|
|
577
|
+
render: () => {
|
|
578
|
+
const columns: DataTableColumn<User>[] = [
|
|
579
|
+
{ key: 'name', dataIndex: 'name', title: '姓名', width: 100 },
|
|
580
|
+
{
|
|
581
|
+
key: 'age',
|
|
582
|
+
dataIndex: 'age',
|
|
583
|
+
title: '年龄',
|
|
584
|
+
width: 100,
|
|
585
|
+
align: 'right',
|
|
586
|
+
sortable: true,
|
|
587
|
+
},
|
|
588
|
+
{ key: 'role', dataIndex: 'role', title: '角色', width: 120 },
|
|
589
|
+
{ key: 'city', dataIndex: 'city', title: '城市' },
|
|
590
|
+
];
|
|
591
|
+
return <DataTable columns={columns} data={users} />;
|
|
592
|
+
},
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
/** 列过滤:`filters` 提供候选项,单击表头过滤图标弹出 Popover 选择。 */
|
|
596
|
+
export const WithFiltering: Story = {
|
|
597
|
+
render: () => {
|
|
598
|
+
const columns: DataTableColumn<User>[] = [
|
|
599
|
+
{ key: 'name', dataIndex: 'name', title: '姓名', width: 100 },
|
|
600
|
+
{
|
|
601
|
+
key: 'age',
|
|
602
|
+
dataIndex: 'age',
|
|
603
|
+
title: '年龄',
|
|
604
|
+
width: 80,
|
|
605
|
+
align: 'right',
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
key: 'role',
|
|
609
|
+
dataIndex: 'role',
|
|
610
|
+
title: '角色',
|
|
611
|
+
width: 120,
|
|
612
|
+
filters: [
|
|
613
|
+
{ label: '管理员', value: '管理员' },
|
|
614
|
+
{ label: '开发', value: '开发' },
|
|
615
|
+
{ label: '运维', value: '运维' },
|
|
616
|
+
{ label: '产品', value: '产品' },
|
|
617
|
+
],
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
key: 'status',
|
|
621
|
+
dataIndex: 'status',
|
|
622
|
+
title: '状态',
|
|
623
|
+
width: 100,
|
|
624
|
+
filterMode: 'single',
|
|
625
|
+
filters: [
|
|
626
|
+
{ label: '活跃', value: 'active' },
|
|
627
|
+
{ label: '暂停', value: 'paused' },
|
|
628
|
+
{ label: '已封', value: 'banned' },
|
|
629
|
+
],
|
|
630
|
+
},
|
|
631
|
+
{ key: 'city', dataIndex: 'city', title: '城市' },
|
|
632
|
+
];
|
|
633
|
+
return <DataTable columns={columns} data={users} />;
|
|
634
|
+
},
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
/** 分页:默认开启分页,可通过 `pagination` 配置 pageSize / showSizeChanger / showTotal。 */
|
|
638
|
+
export const WithPagination: Story = {
|
|
639
|
+
render: () => {
|
|
640
|
+
const data: User[] = Array.from({ length: 36 }, (_, i) => ({
|
|
641
|
+
id: String(i + 1),
|
|
642
|
+
name: `用户 ${i + 1}`,
|
|
643
|
+
age: 20 + (i % 30),
|
|
644
|
+
role: (['管理员', '开发', '运维', '产品'] as const)[i % 4]!,
|
|
645
|
+
status: (['active', 'paused', 'banned'] as const)[i % 3]!,
|
|
646
|
+
city: (['北京', '上海', '杭州', '深圳', '成都', '广州'] as const)[i % 6]!,
|
|
647
|
+
}));
|
|
648
|
+
return (
|
|
649
|
+
<DataTable
|
|
650
|
+
columns={baseColumns}
|
|
651
|
+
data={data}
|
|
652
|
+
pagination={{
|
|
653
|
+
defaultPageSize: 10,
|
|
654
|
+
pageSizeOptions: [5, 10, 20],
|
|
655
|
+
showSizeChanger: true,
|
|
656
|
+
showTotal: true,
|
|
657
|
+
}}
|
|
658
|
+
/>
|
|
659
|
+
);
|
|
660
|
+
},
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
/** 多选行:`rowSelection` 多选模式(默认),表头全选 / 半选。 */
|
|
664
|
+
export const RowSelectionMultiple: Story = {
|
|
665
|
+
render: () => {
|
|
666
|
+
const [keys, setKeys] = React.useState<string[]>([]);
|
|
667
|
+
return (
|
|
668
|
+
<div className="flex flex-col gap-2">
|
|
669
|
+
<p className="text-xs text-muted-foreground">
|
|
670
|
+
已选:{keys.length} 项 — {keys.join(', ') || '无'}
|
|
671
|
+
</p>
|
|
672
|
+
<DataTable
|
|
673
|
+
columns={baseColumns}
|
|
674
|
+
data={users}
|
|
675
|
+
rowSelection={{
|
|
676
|
+
selectedRowKeys: keys,
|
|
677
|
+
onChange: (k) => setKeys(k),
|
|
678
|
+
}}
|
|
679
|
+
/>
|
|
680
|
+
</div>
|
|
681
|
+
);
|
|
682
|
+
},
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
/** 单选行:`rowSelection.mode = 'single'`。 */
|
|
686
|
+
export const RowSelectionSingle: Story = {
|
|
687
|
+
render: () => {
|
|
688
|
+
const [keys, setKeys] = React.useState<string[]>([]);
|
|
689
|
+
return (
|
|
690
|
+
<div className="flex flex-col gap-2">
|
|
691
|
+
<p className="text-xs text-muted-foreground">
|
|
692
|
+
当前选中:{keys[0] ?? '无'}
|
|
693
|
+
</p>
|
|
694
|
+
<DataTable
|
|
695
|
+
columns={baseColumns}
|
|
696
|
+
data={users}
|
|
697
|
+
rowSelection={{
|
|
698
|
+
mode: 'single',
|
|
699
|
+
selectedRowKeys: keys,
|
|
700
|
+
onChange: (k) => setKeys(k),
|
|
701
|
+
}}
|
|
702
|
+
/>
|
|
703
|
+
</div>
|
|
704
|
+
);
|
|
705
|
+
},
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
/** 行展开:`expandable.expandedRowRender` 渲染额外区域。 */
|
|
709
|
+
export const ExpandedRow: Story = {
|
|
710
|
+
render: () => (
|
|
711
|
+
<DataTable
|
|
712
|
+
columns={baseColumns}
|
|
713
|
+
data={users.slice(0, 4)}
|
|
714
|
+
expandable={{
|
|
715
|
+
expandedRowRender: (record) => (
|
|
716
|
+
<div className="flex flex-col gap-1 text-xs">
|
|
717
|
+
<p>姓名:{record.name}</p>
|
|
718
|
+
<p>城市:{record.city}</p>
|
|
719
|
+
<p>状态:{record.status}</p>
|
|
720
|
+
</div>
|
|
721
|
+
),
|
|
722
|
+
}}
|
|
723
|
+
/>
|
|
724
|
+
),
|
|
725
|
+
};
|
|
726
|
+
|
|
727
|
+
/** Loading 与 Empty 状态。 */
|
|
728
|
+
export const LoadingAndEmpty: Story = {
|
|
729
|
+
render: () => (
|
|
730
|
+
<div className="flex flex-col gap-6">
|
|
731
|
+
<div>
|
|
732
|
+
<p className="mb-2 text-xs text-muted-foreground">loading</p>
|
|
733
|
+
<DataTable columns={baseColumns} data={users.slice(0, 3)} loading />
|
|
734
|
+
</div>
|
|
735
|
+
<div>
|
|
736
|
+
<p className="mb-2 text-xs text-muted-foreground">empty</p>
|
|
737
|
+
<DataTable columns={baseColumns} data={[]} />
|
|
738
|
+
</div>
|
|
739
|
+
</div>
|
|
740
|
+
),
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
/** 自定义单元格渲染 + 操作列。 */
|
|
744
|
+
export const CustomCell: Story = {
|
|
745
|
+
render: () => {
|
|
746
|
+
const columns: DataTableColumn<User>[] = [
|
|
747
|
+
{ key: 'name', dataIndex: 'name', title: '姓名', width: 100 },
|
|
748
|
+
{
|
|
749
|
+
key: 'age',
|
|
750
|
+
dataIndex: 'age',
|
|
751
|
+
title: '年龄',
|
|
752
|
+
width: 80,
|
|
753
|
+
align: 'right',
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
key: 'status',
|
|
757
|
+
dataIndex: 'status',
|
|
758
|
+
title: '状态',
|
|
759
|
+
width: 100,
|
|
760
|
+
render: (val) => {
|
|
761
|
+
const v = val as User['status'];
|
|
762
|
+
const map = {
|
|
763
|
+
active: { label: '活跃', status: 'success' as const },
|
|
764
|
+
paused: { label: '暂停', status: 'warning' as const },
|
|
765
|
+
banned: { label: '已封', status: 'error' as const },
|
|
766
|
+
};
|
|
767
|
+
return (
|
|
768
|
+
<Tag variant="status" status={map[v].status} showIcon>
|
|
769
|
+
{map[v].label}
|
|
770
|
+
</Tag>
|
|
771
|
+
);
|
|
772
|
+
},
|
|
773
|
+
},
|
|
774
|
+
{ key: 'city', dataIndex: 'city', title: '城市' },
|
|
775
|
+
{
|
|
776
|
+
key: 'actions',
|
|
777
|
+
title: '操作',
|
|
778
|
+
width: 120,
|
|
779
|
+
align: 'right',
|
|
780
|
+
cell: () => (
|
|
781
|
+
<ButtonGroup className="h-4 gap-3">
|
|
782
|
+
<Button variant="link">编辑</Button>
|
|
783
|
+
<ButtonGroupSeparator />
|
|
784
|
+
<Button variant="link" color="destructive">
|
|
785
|
+
删除
|
|
786
|
+
</Button>
|
|
787
|
+
</ButtonGroup>
|
|
788
|
+
),
|
|
789
|
+
},
|
|
790
|
+
];
|
|
791
|
+
return <DataTable columns={columns} data={users.slice(0, 5)} />;
|
|
792
|
+
},
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
// ─── P1 进阶能力 ───────────────────────────────────────────────────────────
|
|
796
|
+
|
|
797
|
+
interface TreeUser extends User {
|
|
798
|
+
children?: TreeUser[];
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
const treeUsers: TreeUser[] = [
|
|
802
|
+
{
|
|
803
|
+
id: '1',
|
|
804
|
+
name: '产品中心',
|
|
805
|
+
age: 0,
|
|
806
|
+
role: '产品',
|
|
807
|
+
status: 'active',
|
|
808
|
+
city: '北京',
|
|
809
|
+
children: [
|
|
810
|
+
{
|
|
811
|
+
id: '1-1',
|
|
812
|
+
name: '前端组',
|
|
813
|
+
age: 0,
|
|
814
|
+
role: '开发',
|
|
815
|
+
status: 'active',
|
|
816
|
+
city: '北京',
|
|
817
|
+
children: [
|
|
818
|
+
{
|
|
819
|
+
id: '1-1-1',
|
|
820
|
+
name: '张三',
|
|
821
|
+
age: 28,
|
|
822
|
+
role: '开发',
|
|
823
|
+
status: 'active',
|
|
824
|
+
city: '北京',
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
id: '1-1-2',
|
|
828
|
+
name: '李四',
|
|
829
|
+
age: 35,
|
|
830
|
+
role: '开发',
|
|
831
|
+
status: 'active',
|
|
832
|
+
city: '上海',
|
|
833
|
+
},
|
|
834
|
+
],
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
id: '1-2',
|
|
838
|
+
name: '后端组',
|
|
839
|
+
age: 0,
|
|
840
|
+
role: '开发',
|
|
841
|
+
status: 'active',
|
|
842
|
+
city: '杭州',
|
|
843
|
+
children: [
|
|
844
|
+
{
|
|
845
|
+
id: '1-2-1',
|
|
846
|
+
name: '王五',
|
|
847
|
+
age: 24,
|
|
848
|
+
role: '运维',
|
|
849
|
+
status: 'paused',
|
|
850
|
+
city: '杭州',
|
|
851
|
+
},
|
|
852
|
+
],
|
|
853
|
+
},
|
|
854
|
+
],
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
id: '2',
|
|
858
|
+
name: '运维中心',
|
|
859
|
+
age: 0,
|
|
860
|
+
role: '运维',
|
|
861
|
+
status: 'active',
|
|
862
|
+
city: '上海',
|
|
863
|
+
children: [
|
|
864
|
+
{
|
|
865
|
+
id: '2-1',
|
|
866
|
+
name: '钱七',
|
|
867
|
+
age: 30,
|
|
868
|
+
role: '运维',
|
|
869
|
+
status: 'active',
|
|
870
|
+
city: '上海',
|
|
871
|
+
},
|
|
872
|
+
],
|
|
873
|
+
},
|
|
874
|
+
];
|
|
875
|
+
|
|
876
|
+
const wideUsers: User[] = Array.from({ length: 8 }, (_, i) => ({
|
|
877
|
+
id: String(i + 1),
|
|
878
|
+
name: `用户 ${i + 1}`,
|
|
879
|
+
age: 20 + (i % 30),
|
|
880
|
+
role: (['管理员', '开发', '运维', '产品'] as const)[i % 4]!,
|
|
881
|
+
status: (['active', 'paused', 'banned'] as const)[i % 3]!,
|
|
882
|
+
city: (['北京', '上海', '杭州', '深圳', '成都', '广州'] as const)[i % 6]!,
|
|
883
|
+
email: `user${i + 1}@example.com`,
|
|
884
|
+
phone: `1380000${String(i + 1).padStart(4, '0')}`,
|
|
885
|
+
department: (['研发', '测试', '运维', '产品', '设计'] as const)[i % 5]!,
|
|
886
|
+
level: `P${5 + (i % 4)}`,
|
|
887
|
+
}));
|
|
888
|
+
|
|
889
|
+
/** 锁列:通过 `fixed: 'left' | 'right'` 让列在水平滚动时保持位置。 */
|
|
890
|
+
export const LockColumns: Story = {
|
|
891
|
+
render: () => {
|
|
892
|
+
const columns: DataTableColumn<User>[] = [
|
|
893
|
+
{
|
|
894
|
+
key: 'name',
|
|
895
|
+
dataIndex: 'name',
|
|
896
|
+
title: '姓名',
|
|
897
|
+
width: 120,
|
|
898
|
+
fixed: 'left',
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
key: 'age',
|
|
902
|
+
dataIndex: 'age',
|
|
903
|
+
title: '年龄',
|
|
904
|
+
width: 80,
|
|
905
|
+
align: 'right',
|
|
906
|
+
},
|
|
907
|
+
{ key: 'role', dataIndex: 'role', title: '角色', width: 120 },
|
|
908
|
+
{ key: 'status', dataIndex: 'status', title: '状态', width: 120 },
|
|
909
|
+
{ key: 'city', dataIndex: 'city', title: '城市', width: 160 },
|
|
910
|
+
{
|
|
911
|
+
key: 'department',
|
|
912
|
+
dataIndex: 'department' as keyof User & string,
|
|
913
|
+
title: '部门',
|
|
914
|
+
width: 160,
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
key: 'level',
|
|
918
|
+
dataIndex: 'level' as keyof User & string,
|
|
919
|
+
title: '职级',
|
|
920
|
+
width: 100,
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
key: 'email',
|
|
924
|
+
dataIndex: 'email' as keyof User & string,
|
|
925
|
+
title: '邮箱',
|
|
926
|
+
width: 220,
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
key: 'phone',
|
|
930
|
+
dataIndex: 'phone' as keyof User & string,
|
|
931
|
+
title: '电话',
|
|
932
|
+
width: 160,
|
|
933
|
+
},
|
|
934
|
+
{
|
|
935
|
+
key: 'actions',
|
|
936
|
+
title: '操作',
|
|
937
|
+
width: 120,
|
|
938
|
+
align: 'right',
|
|
939
|
+
fixed: 'right',
|
|
940
|
+
cell: () => <Button variant="link">编辑</Button>,
|
|
941
|
+
},
|
|
942
|
+
];
|
|
943
|
+
return (
|
|
944
|
+
<div style={{ width: 720 }}>
|
|
945
|
+
<DataTable columns={columns} data={wideUsers} />
|
|
946
|
+
</div>
|
|
947
|
+
);
|
|
948
|
+
},
|
|
949
|
+
};
|
|
950
|
+
|
|
951
|
+
/** 列宽拖拽:`enableColumnResizing` 全局开启,列上 `resizable: true` 启用,鼠标拖拽列右侧分隔线。 */
|
|
952
|
+
export const ResizableColumns: Story = {
|
|
953
|
+
render: () => {
|
|
954
|
+
const [sizing, setSizing] = React.useState<Record<string, number>>({});
|
|
955
|
+
const columns: DataTableColumn<User>[] = [
|
|
956
|
+
{
|
|
957
|
+
key: 'name',
|
|
958
|
+
dataIndex: 'name',
|
|
959
|
+
title: '姓名',
|
|
960
|
+
width: 120,
|
|
961
|
+
resizable: true,
|
|
962
|
+
},
|
|
963
|
+
{
|
|
964
|
+
key: 'age',
|
|
965
|
+
dataIndex: 'age',
|
|
966
|
+
title: '年龄',
|
|
967
|
+
width: 80,
|
|
968
|
+
align: 'right',
|
|
969
|
+
resizable: true,
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
key: 'role',
|
|
973
|
+
dataIndex: 'role',
|
|
974
|
+
title: '角色',
|
|
975
|
+
width: 160,
|
|
976
|
+
resizable: true,
|
|
977
|
+
},
|
|
978
|
+
{
|
|
979
|
+
key: 'status',
|
|
980
|
+
dataIndex: 'status',
|
|
981
|
+
title: '状态',
|
|
982
|
+
width: 120,
|
|
983
|
+
resizable: true,
|
|
984
|
+
},
|
|
985
|
+
{ key: 'city', dataIndex: 'city', title: '城市', width: 200 },
|
|
986
|
+
];
|
|
987
|
+
return (
|
|
988
|
+
<div className="flex flex-col gap-2">
|
|
989
|
+
<p className="text-xs text-muted-foreground">
|
|
990
|
+
当前列宽:{JSON.stringify(sizing)}
|
|
991
|
+
</p>
|
|
992
|
+
<DataTable
|
|
993
|
+
columns={columns}
|
|
994
|
+
data={users}
|
|
995
|
+
enableColumnResizing
|
|
996
|
+
columnSizing={sizing}
|
|
997
|
+
onColumnSizingChange={setSizing}
|
|
998
|
+
/>
|
|
999
|
+
</div>
|
|
1000
|
+
);
|
|
1001
|
+
},
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
/** 树形数据:`isTree` + `children` 字段递归渲染,子行通过缩进 + 展开按钮表达层级。 */
|
|
1005
|
+
export const TreeData: Story = {
|
|
1006
|
+
render: () => {
|
|
1007
|
+
const columns: DataTableColumn<TreeUser>[] = [
|
|
1008
|
+
{ key: 'name', dataIndex: 'name', title: '姓名', width: 220 },
|
|
1009
|
+
{ key: 'role', dataIndex: 'role', title: '角色', width: 120 },
|
|
1010
|
+
{ key: 'status', dataIndex: 'status', title: '状态', width: 120 },
|
|
1011
|
+
{ key: 'city', dataIndex: 'city', title: '城市' },
|
|
1012
|
+
];
|
|
1013
|
+
return (
|
|
1014
|
+
<DataTable
|
|
1015
|
+
columns={columns}
|
|
1016
|
+
data={treeUsers}
|
|
1017
|
+
isTree
|
|
1018
|
+
indentSize={20}
|
|
1019
|
+
pagination={false}
|
|
1020
|
+
/>
|
|
1021
|
+
);
|
|
1022
|
+
},
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
/** 固定表头:`stickyHeader` + `maxBodyHeight` 让表头滚动吸顶。 */
|
|
1026
|
+
export const FixedHeader: Story = {
|
|
1027
|
+
render: () => {
|
|
1028
|
+
const data: User[] = Array.from({ length: 50 }, (_, i) => ({
|
|
1029
|
+
id: String(i + 1),
|
|
1030
|
+
name: `用户 ${i + 1}`,
|
|
1031
|
+
age: 20 + (i % 30),
|
|
1032
|
+
role: (['管理员', '开发', '运维', '产品'] as const)[i % 4]!,
|
|
1033
|
+
status: (['active', 'paused', 'banned'] as const)[i % 3]!,
|
|
1034
|
+
city: (['北京', '上海', '杭州', '深圳', '成都', '广州'] as const)[i % 6]!,
|
|
1035
|
+
}));
|
|
1036
|
+
return (
|
|
1037
|
+
<DataTable
|
|
1038
|
+
columns={baseColumns}
|
|
1039
|
+
data={data}
|
|
1040
|
+
stickyHeader
|
|
1041
|
+
maxBodyHeight={320}
|
|
1042
|
+
pagination={false}
|
|
1043
|
+
/>
|
|
1044
|
+
);
|
|
1045
|
+
},
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
/** 十字辅助轴:`crossline` 同时高亮 hover 行与列,便于宽表格定位。 */
|
|
1049
|
+
export const Crossline: Story = {
|
|
1050
|
+
render: () => {
|
|
1051
|
+
const columns: DataTableColumn<User>[] = [
|
|
1052
|
+
{ key: 'name', dataIndex: 'name', title: '姓名', width: 120 },
|
|
1053
|
+
{
|
|
1054
|
+
key: 'age',
|
|
1055
|
+
dataIndex: 'age',
|
|
1056
|
+
title: '年龄',
|
|
1057
|
+
width: 80,
|
|
1058
|
+
align: 'right',
|
|
1059
|
+
},
|
|
1060
|
+
{ key: 'role', dataIndex: 'role', title: '角色', width: 120 },
|
|
1061
|
+
{ key: 'status', dataIndex: 'status', title: '状态', width: 120 },
|
|
1062
|
+
{ key: 'city', dataIndex: 'city', title: '城市', width: 120 },
|
|
1063
|
+
];
|
|
1064
|
+
return <DataTable columns={columns} data={users} crossline />;
|
|
1065
|
+
},
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
// ─── P2 高阶能力 ──────────────────────────────────────────────────────────
|
|
1069
|
+
|
|
1070
|
+
/** 虚拟滚动:`virtual` 开启后只渲染可视区域的行,适合千条以上数据。需同时设置 `maxBodyHeight`。 */
|
|
1071
|
+
export const Virtual: Story = {
|
|
1072
|
+
render: () => {
|
|
1073
|
+
const data: User[] = Array.from({ length: 2000 }, (_, i) => ({
|
|
1074
|
+
id: String(i + 1),
|
|
1075
|
+
name: `用户 ${i + 1}`,
|
|
1076
|
+
age: 20 + (i % 40),
|
|
1077
|
+
role: (['管理员', '开发', '运维', '产品'] as const)[i % 4]!,
|
|
1078
|
+
status: (['active', 'paused', 'banned'] as const)[i % 3]!,
|
|
1079
|
+
city: (['北京', '上海', '杭州', '深圳', '成都', '广州'] as const)[i % 6]!,
|
|
1080
|
+
}));
|
|
1081
|
+
return (
|
|
1082
|
+
<div className="flex flex-col gap-2">
|
|
1083
|
+
<p className="text-xs text-muted-foreground">
|
|
1084
|
+
总计 {data.length} 条,开启虚拟滚动后仅渲染可见区域。
|
|
1085
|
+
</p>
|
|
1086
|
+
<DataTable
|
|
1087
|
+
columns={baseColumns}
|
|
1088
|
+
data={data}
|
|
1089
|
+
virtual
|
|
1090
|
+
stickyHeader
|
|
1091
|
+
maxBodyHeight={400}
|
|
1092
|
+
estimateRowHeight={40}
|
|
1093
|
+
pagination={false}
|
|
1094
|
+
/>
|
|
1095
|
+
</div>
|
|
1096
|
+
);
|
|
1097
|
+
},
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
/** 多级表头:列定义中传入 `children` 数组即可表示分组,头部渲染为两层 `<thead><tr>`。 */
|
|
1101
|
+
export const MultiHeader: Story = {
|
|
1102
|
+
render: () => {
|
|
1103
|
+
const columns: DataTableColumn<User>[] = [
|
|
1104
|
+
{ key: 'name', dataIndex: 'name', title: '姓名', width: 120 },
|
|
1105
|
+
{
|
|
1106
|
+
key: 'profile',
|
|
1107
|
+
title: '个人信息',
|
|
1108
|
+
children: [
|
|
1109
|
+
{
|
|
1110
|
+
key: 'age',
|
|
1111
|
+
dataIndex: 'age',
|
|
1112
|
+
title: '年龄',
|
|
1113
|
+
width: 80,
|
|
1114
|
+
align: 'right',
|
|
1115
|
+
},
|
|
1116
|
+
{ key: 'city', dataIndex: 'city', title: '城市', width: 120 },
|
|
1117
|
+
],
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
key: 'work',
|
|
1121
|
+
title: '工作信息',
|
|
1122
|
+
children: [
|
|
1123
|
+
{ key: 'role', dataIndex: 'role', title: '角色', width: 120 },
|
|
1124
|
+
{ key: 'status', dataIndex: 'status', title: '状态', width: 120 },
|
|
1125
|
+
],
|
|
1126
|
+
},
|
|
1127
|
+
];
|
|
1128
|
+
return <DataTable columns={columns} data={users} />;
|
|
1129
|
+
},
|
|
1130
|
+
};
|
|
1131
|
+
|
|
1132
|
+
/** 合并单元格:`cellProps` 返回 `{ rowSpan, colSpan }`,返回 0 则跳过该 td(与 TanStack 原生渲染拼接)。 */
|
|
1133
|
+
export const MergedCells: Story = {
|
|
1134
|
+
render: () => {
|
|
1135
|
+
const columns: DataTableColumn<User>[] = [
|
|
1136
|
+
{ key: 'name', dataIndex: 'name', title: '姓名', width: 100 },
|
|
1137
|
+
{ key: 'role', dataIndex: 'role', title: '角色', width: 120 },
|
|
1138
|
+
{ key: 'city', dataIndex: 'city', title: '城市', width: 120 },
|
|
1139
|
+
{ key: 'status', dataIndex: 'status', title: '状态', width: 120 },
|
|
1140
|
+
];
|
|
1141
|
+
// 示例:头三行 “角色” 同为 “管理员” 时合并 rowSpan=3;后面两行返回 rowSpan=0 跳过。
|
|
1142
|
+
const cellProps = (rowIndex: number, colIndex: number) => {
|
|
1143
|
+
// colIndex 1 对应 role 列
|
|
1144
|
+
if (colIndex !== 1) return undefined;
|
|
1145
|
+
if (rowIndex === 0) return { rowSpan: 3 };
|
|
1146
|
+
if (rowIndex === 1 || rowIndex === 2) return { rowSpan: 0 };
|
|
1147
|
+
return undefined;
|
|
1148
|
+
};
|
|
1149
|
+
const data = [
|
|
1150
|
+
{ ...users[0]!, role: '管理员' as const },
|
|
1151
|
+
{ ...users[1]!, role: '管理员' as const },
|
|
1152
|
+
{ ...users[2]!, role: '管理员' as const },
|
|
1153
|
+
...users.slice(3),
|
|
1154
|
+
];
|
|
1155
|
+
return <DataTable columns={columns} data={data} cellProps={cellProps} />;
|
|
1156
|
+
},
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
/** 可编辑单元格:`EditableCell` helper 双击切入输入框,Enter / blur 提交,Esc 取消。 */
|
|
1160
|
+
export const EditableCellStory: Story = {
|
|
1161
|
+
name: 'EditableCell',
|
|
1162
|
+
render: () => {
|
|
1163
|
+
const [data, setData] = React.useState<User[]>(users.slice(0, 4));
|
|
1164
|
+
const updateField = (
|
|
1165
|
+
id: string,
|
|
1166
|
+
field: keyof User,
|
|
1167
|
+
value: string | number,
|
|
1168
|
+
) => {
|
|
1169
|
+
setData((prev) =>
|
|
1170
|
+
prev.map((u) => (u.id === id ? { ...u, [field]: value } : u)),
|
|
1171
|
+
);
|
|
1172
|
+
};
|
|
1173
|
+
const columns: DataTableColumn<User>[] = [
|
|
1174
|
+
{
|
|
1175
|
+
key: 'name',
|
|
1176
|
+
dataIndex: 'name',
|
|
1177
|
+
title: '姓名 (可编辑)',
|
|
1178
|
+
width: 160,
|
|
1179
|
+
cell: ({ row }) => (
|
|
1180
|
+
<EditableCell
|
|
1181
|
+
value={row.original.name}
|
|
1182
|
+
onCommit={(v) => updateField(row.original.id, 'name', v)}
|
|
1183
|
+
/>
|
|
1184
|
+
),
|
|
1185
|
+
},
|
|
1186
|
+
{
|
|
1187
|
+
key: 'age',
|
|
1188
|
+
dataIndex: 'age',
|
|
1189
|
+
title: '年龄 (可编辑)',
|
|
1190
|
+
width: 120,
|
|
1191
|
+
align: 'right',
|
|
1192
|
+
cell: ({ row }) => (
|
|
1193
|
+
<EditableCell
|
|
1194
|
+
type="number"
|
|
1195
|
+
value={row.original.age}
|
|
1196
|
+
onCommit={(v) => updateField(row.original.id, 'age', v)}
|
|
1197
|
+
/>
|
|
1198
|
+
),
|
|
1199
|
+
},
|
|
1200
|
+
{ key: 'role', dataIndex: 'role', title: '角色', width: 120 },
|
|
1201
|
+
{ key: 'city', dataIndex: 'city', title: '城市' },
|
|
1202
|
+
];
|
|
1203
|
+
return (
|
|
1204
|
+
<div className="flex flex-col gap-2">
|
|
1205
|
+
<p className="text-xs text-muted-foreground">
|
|
1206
|
+
双击 “姓名” 或 “年龄” 单元格可进入编辑态。
|
|
1207
|
+
</p>
|
|
1208
|
+
<DataTable columns={columns} data={data} pagination={false} />
|
|
1209
|
+
</div>
|
|
1210
|
+
);
|
|
1211
|
+
},
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1214
|
+
/** 行拖拽排序:`draggable` 开启后,首列出现拖拽手柄,拖拽排序后触发 `onDragEnd`。 */
|
|
1215
|
+
export const DraggableRow: Story = {
|
|
1216
|
+
render: () => {
|
|
1217
|
+
const [data, setData] = React.useState<User[]>(users.slice(0, 6));
|
|
1218
|
+
return (
|
|
1219
|
+
<div className="flex flex-col gap-2">
|
|
1220
|
+
<p className="text-xs text-muted-foreground">
|
|
1221
|
+
拖拽首列手柄调整行顺序。
|
|
1222
|
+
</p>
|
|
1223
|
+
<DataTable
|
|
1224
|
+
columns={baseColumns}
|
|
1225
|
+
data={data}
|
|
1226
|
+
rowKey="id"
|
|
1227
|
+
draggable
|
|
1228
|
+
onDragEnd={({ data: next }) => setData(next)}
|
|
1229
|
+
pagination={false}
|
|
1230
|
+
/>
|
|
1231
|
+
</div>
|
|
1232
|
+
);
|
|
1233
|
+
},
|
|
1234
|
+
};
|