@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
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
id: data-table
|
|
3
|
-
name: DataTable
|
|
4
|
-
displayName: 数据表格
|
|
5
|
-
type: component
|
|
6
|
-
category: data-display
|
|
7
|
-
since: 0.1.0
|
|
8
|
-
package: '@teamix-evo/ui'
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# DataTable 数据表格
|
|
12
|
-
|
|
13
|
-
数据表 — 基于 [`@tanstack/react-table`](https://tanstack.com/table) + 基础 `Table` primitives + `SimplePagination`。
|
|
14
|
-
**等价 antd `Table` 的核心交互合集**:`sorter` + `filter` + `pagination` + `rowSelection`,声明式 `columns + data` 即可。
|
|
15
|
-
|
|
16
|
-
## When to use
|
|
17
|
-
|
|
18
|
-
- 需要排序 / 筛选 / 分页 / 多选的列表(用户管理 / 订单 / 资源)
|
|
19
|
-
- 大数据量(配 TanStack 的 virtualizer 可接百万行,本组件目前未集成)
|
|
20
|
-
- 需要复杂列(多列分组、可拖拽列宽、嵌套行)— 用户可在 columns 里自由扩展
|
|
21
|
-
|
|
22
|
-
## When NOT to use
|
|
23
|
-
|
|
24
|
-
- 简单静态展示 → 基础 `Table`
|
|
25
|
-
- 键值对详情 → `Descriptions`(v0.x)
|
|
26
|
-
- 树结构 → `Tree`(v0.x)
|
|
27
|
-
|
|
28
|
-
## Props
|
|
29
|
-
|
|
30
|
-
> 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成。
|
|
31
|
-
|
|
32
|
-
<!-- auto:props:begin -->
|
|
33
|
-
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
34
|
-
| --- | --- | --- | --- | --- |
|
|
35
|
-
| `columns` | `ColumnDef<TData, TValue>[]` | – | ✓ | 列定义(TanStack ColumnDef)。 |
|
|
36
|
-
| `data` | `TData[]` | – | ✓ | 行数据。 |
|
|
37
|
-
| `pagination` | `boolean \| { pageSize?: number; siblingCount?: number }` | `true` | – | 是否启用分页(antd `pagination` 并集)。 传 `true` 用默认配置;传对象自定义 pageSize / siblingCount。 |
|
|
38
|
-
| `sorting` | `boolean` | `true` | – | 是否启用排序(列定义里的 `enableSorting` 也要打开;默认列已开)。 |
|
|
39
|
-
| `filtering` | `boolean` | `true` | – | 是否启用列过滤(每列 `header` 配 input 单独使用;此 flag 控制 columnFilters 状态)。 |
|
|
40
|
-
| `onRowSelectionChange` | `(selectedRows: TData[]) => void` | – | – | 行选择回调(antd `rowSelection.onChange` 并集)。传入即启用 selection。 Selected rows 的原始 data 通过 `getRowId(row)` 推断,默认是 row.index。 |
|
|
41
|
-
| `emptyText` | `React.ReactNode` | – | – | 空数据时显示的内容。 |
|
|
42
|
-
| `className` | `string` | – | – | 容器 className。 |
|
|
43
|
-
<!-- auto:props:end -->
|
|
44
|
-
|
|
45
|
-
## 依赖
|
|
46
|
-
|
|
47
|
-
> 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成,数据源是 [`manifest.json`](../../../manifest.json)。**手工编辑 marker 之间的内容会在下次生成时被覆盖**。
|
|
48
|
-
|
|
49
|
-
<!-- auto:deps:begin -->
|
|
50
|
-
### 同库依赖
|
|
51
|
-
|
|
52
|
-
> `teamix-evo ui add data-table` 时,以下 entry 会被自动连带安装(无需手动 add)。
|
|
53
|
-
|
|
54
|
-
| Entry | 类型 | 描述 |
|
|
55
|
-
| --- | --- | --- |
|
|
56
|
-
| `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
|
|
57
|
-
| `table` | component | 基础表格 — 原生 HTML 元素薄包装(视觉骨架,无交互,交互见 DataTable) |
|
|
58
|
-
| `pagination` | component | 分页 — shadcn primitives + 高阶 SimplePagination(antd 风格 total/pageSize/current/onChange,自动页码窗口 + 折叠) |
|
|
59
|
-
|
|
60
|
-
### npm 依赖
|
|
61
|
-
|
|
62
|
-
> 业务侧需要先 `pnpm add` / `npm install` 这些包。CLI 在 `ui add` 完成后会列出此提示。
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
pnpm add @tanstack/react-table@^8.0.0
|
|
66
|
-
```
|
|
67
|
-
<!-- auto:deps:end -->
|
|
68
|
-
|
|
69
|
-
> 透传 TanStack Table 的核心能力。需要更精细控制(可控 state、virtualizer、column visibility / resizing 等),请直接用 `useReactTable` + 基础 `Table` primitives 自行拼装。
|
|
70
|
-
|
|
71
|
-
## AI 生成纪律
|
|
72
|
-
|
|
73
|
-
- **`columns` 用 `ColumnDef<TData>` 类型**:从本模块 re-export,业务侧 `import { type ColumnDef }`
|
|
74
|
-
- **`accessorKey` 必稳定**:用对象的字段名,不要 index
|
|
75
|
-
- **排序触发器**:`header: ({ column }) => <Button onClick={() => column.toggleSorting()}>...</Button>`
|
|
76
|
-
- **筛选**:在 column header 里渲染 Input 调 `column.setFilterValue`
|
|
77
|
-
- **rowSelection 用 `<Checkbox>`**:第一列加 `<Checkbox checked={row.getIsSelected()} onCheckedChange={(v) => row.toggleSelected(!!v)} />`
|
|
78
|
-
- **不要在每个 cell 内独立请求数据**:在父组件聚合后传 `data`
|
|
79
|
-
- **大数据量 → virtualizer**:本组件未集成,> 1000 行需自行加 `@tanstack/react-virtual`
|
|
80
|
-
|
|
81
|
-
## Examples
|
|
82
|
-
|
|
83
|
-
```tsx
|
|
84
|
-
import { DataTable, type ColumnDef } from '@/components/ui/data-table';
|
|
85
|
-
import { Button } from '@/components/ui/button';
|
|
86
|
-
import { Checkbox } from '@/components/ui/checkbox';
|
|
87
|
-
import { Badge } from '@/components/ui/badge';
|
|
88
|
-
import { ArrowUpDown } from 'lucide-react';
|
|
89
|
-
|
|
90
|
-
interface User {
|
|
91
|
-
id: string;
|
|
92
|
-
name: string;
|
|
93
|
-
email: string;
|
|
94
|
-
status: 'active' | 'invited';
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const columns: ColumnDef<User>[] = [
|
|
98
|
-
{
|
|
99
|
-
id: 'select',
|
|
100
|
-
header: ({ table }) => (
|
|
101
|
-
<Checkbox
|
|
102
|
-
checked={
|
|
103
|
-
table.getIsAllPageRowsSelected()
|
|
104
|
-
? true
|
|
105
|
-
: table.getIsSomePageRowsSelected()
|
|
106
|
-
? 'indeterminate'
|
|
107
|
-
: false
|
|
108
|
-
}
|
|
109
|
-
onCheckedChange={(v) => table.toggleAllPageRowsSelected(!!v)}
|
|
110
|
-
/>
|
|
111
|
-
),
|
|
112
|
-
cell: ({ row }) => (
|
|
113
|
-
<Checkbox
|
|
114
|
-
checked={row.getIsSelected()}
|
|
115
|
-
onCheckedChange={(v) => row.toggleSelected(!!v)}
|
|
116
|
-
/>
|
|
117
|
-
),
|
|
118
|
-
},
|
|
119
|
-
{ accessorKey: 'name', header: '姓名' },
|
|
120
|
-
{
|
|
121
|
-
accessorKey: 'email',
|
|
122
|
-
header: ({ column }) => (
|
|
123
|
-
<Button
|
|
124
|
-
variant="ghost"
|
|
125
|
-
size="sm"
|
|
126
|
-
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
|
127
|
-
>
|
|
128
|
-
邮箱 <ArrowUpDown className="ml-1" />
|
|
129
|
-
</Button>
|
|
130
|
-
),
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
accessorKey: 'status',
|
|
134
|
-
header: '状态',
|
|
135
|
-
cell: ({ row }) =>
|
|
136
|
-
row.original.status === 'active' ? (
|
|
137
|
-
<Badge variant="success">活跃</Badge>
|
|
138
|
-
) : (
|
|
139
|
-
<Badge>已邀请</Badge>
|
|
140
|
-
),
|
|
141
|
-
},
|
|
142
|
-
];
|
|
143
|
-
|
|
144
|
-
<DataTable
|
|
145
|
-
columns={columns}
|
|
146
|
-
data={users}
|
|
147
|
-
pagination={{ pageSize: 10 }}
|
|
148
|
-
onRowSelectionChange={(selected) => console.log(selected)}
|
|
149
|
-
/>;
|
|
150
|
-
```
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { ArrowUpDown } from 'lucide-react';
|
|
4
|
-
import { DataTable, type ColumnDef } from './data-table';
|
|
5
|
-
import { Button } from '@/components/button/button';
|
|
6
|
-
import { Checkbox } from '@/components/checkbox/checkbox';
|
|
7
|
-
import { Badge } from '@/components/badge/badge';
|
|
8
|
-
|
|
9
|
-
interface User {
|
|
10
|
-
id: string;
|
|
11
|
-
name: string;
|
|
12
|
-
email: string;
|
|
13
|
-
status: 'active' | 'invited' | 'disabled';
|
|
14
|
-
amount: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const data: User[] = Array.from({ length: 35 }).map((_, i) => ({
|
|
18
|
-
id: `u-${i + 1}`,
|
|
19
|
-
name: ['Alice', 'Bob', 'Carol', 'David', 'Eve'][i % 5] + ' ' + (i + 1),
|
|
20
|
-
email: `user${i + 1}@example.com`,
|
|
21
|
-
status:
|
|
22
|
-
(['active', 'invited', 'disabled'] as const)[i % 3] ?? ('active' as const),
|
|
23
|
-
amount: Math.round(Math.random() * 1000),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
const columns: ColumnDef<User>[] = [
|
|
27
|
-
{
|
|
28
|
-
id: 'select',
|
|
29
|
-
header: ({ table }) => (
|
|
30
|
-
<Checkbox
|
|
31
|
-
checked={
|
|
32
|
-
table.getIsAllPageRowsSelected()
|
|
33
|
-
? true
|
|
34
|
-
: table.getIsSomePageRowsSelected()
|
|
35
|
-
? 'indeterminate'
|
|
36
|
-
: false
|
|
37
|
-
}
|
|
38
|
-
onCheckedChange={(v) => table.toggleAllPageRowsSelected(!!v)}
|
|
39
|
-
aria-label="全选"
|
|
40
|
-
/>
|
|
41
|
-
),
|
|
42
|
-
cell: ({ row }) => (
|
|
43
|
-
<Checkbox
|
|
44
|
-
checked={row.getIsSelected()}
|
|
45
|
-
onCheckedChange={(v) => row.toggleSelected(!!v)}
|
|
46
|
-
aria-label="选中行"
|
|
47
|
-
/>
|
|
48
|
-
),
|
|
49
|
-
},
|
|
50
|
-
{ accessorKey: 'name', header: '姓名' },
|
|
51
|
-
{
|
|
52
|
-
accessorKey: 'email',
|
|
53
|
-
header: ({ column }) => (
|
|
54
|
-
<Button
|
|
55
|
-
variant="ghost"
|
|
56
|
-
size="sm"
|
|
57
|
-
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
|
58
|
-
>
|
|
59
|
-
邮箱
|
|
60
|
-
<ArrowUpDown className="ml-1" />
|
|
61
|
-
</Button>
|
|
62
|
-
),
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
accessorKey: 'status',
|
|
66
|
-
header: '状态',
|
|
67
|
-
cell: ({ row }) => {
|
|
68
|
-
const s = row.original.status;
|
|
69
|
-
return s === 'active' ? (
|
|
70
|
-
<Badge variant="success">活跃</Badge>
|
|
71
|
-
) : s === 'invited' ? (
|
|
72
|
-
<Badge>已邀请</Badge>
|
|
73
|
-
) : (
|
|
74
|
-
<Badge variant="destructive">已禁用</Badge>
|
|
75
|
-
);
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
accessorKey: 'amount',
|
|
80
|
-
header: ({ column }) => (
|
|
81
|
-
<Button
|
|
82
|
-
variant="ghost"
|
|
83
|
-
size="sm"
|
|
84
|
-
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
|
85
|
-
className="float-right"
|
|
86
|
-
>
|
|
87
|
-
金额
|
|
88
|
-
<ArrowUpDown className="ml-1" />
|
|
89
|
-
</Button>
|
|
90
|
-
),
|
|
91
|
-
cell: ({ row }) => (
|
|
92
|
-
<div className="text-right tabular-nums">¥{row.original.amount}</div>
|
|
93
|
-
),
|
|
94
|
-
},
|
|
95
|
-
];
|
|
96
|
-
|
|
97
|
-
const meta: Meta<typeof DataTable<User, unknown>> = {
|
|
98
|
-
title: '数据展示 · Data Display/DataTable',
|
|
99
|
-
component: DataTable,
|
|
100
|
-
tags: ['autodocs'],
|
|
101
|
-
parameters: {
|
|
102
|
-
layout: 'fullscreen',
|
|
103
|
-
docs: {
|
|
104
|
-
description: {
|
|
105
|
-
component:
|
|
106
|
-
'数据表 — 基于 TanStack Table + 基础 Table 原语 + SimplePagination。声明式 columns + data 即可实现排序 / 筛选 / 分页 / 多选,等价 antd `Table` 的核心交互合集。',
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export default meta;
|
|
113
|
-
type Story = StoryObj<typeof DataTable<User, unknown>>;
|
|
114
|
-
|
|
115
|
-
export const Default: Story = {
|
|
116
|
-
render: () => {
|
|
117
|
-
const [selected, setSelected] = React.useState<User[]>([]);
|
|
118
|
-
return (
|
|
119
|
-
<div className="p-6">
|
|
120
|
-
<DataTable
|
|
121
|
-
columns={columns}
|
|
122
|
-
data={data}
|
|
123
|
-
pagination={{ pageSize: 8 }}
|
|
124
|
-
onRowSelectionChange={setSelected}
|
|
125
|
-
/>
|
|
126
|
-
<p className="mt-3 text-sm text-muted-foreground">
|
|
127
|
-
已选 {selected.length} 行
|
|
128
|
-
</p>
|
|
129
|
-
</div>
|
|
130
|
-
);
|
|
131
|
-
},
|
|
132
|
-
};
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
flexRender,
|
|
4
|
-
getCoreRowModel,
|
|
5
|
-
getFilteredRowModel,
|
|
6
|
-
getPaginationRowModel,
|
|
7
|
-
getSortedRowModel,
|
|
8
|
-
useReactTable,
|
|
9
|
-
type ColumnDef,
|
|
10
|
-
type ColumnFiltersState,
|
|
11
|
-
type RowSelectionState,
|
|
12
|
-
type SortingState,
|
|
13
|
-
type Table as ReactTable,
|
|
14
|
-
type Updater,
|
|
15
|
-
type VisibilityState,
|
|
16
|
-
} from '@tanstack/react-table';
|
|
17
|
-
|
|
18
|
-
import { cn } from '@/utils/cn';
|
|
19
|
-
import {
|
|
20
|
-
Table,
|
|
21
|
-
TableBody,
|
|
22
|
-
TableCell,
|
|
23
|
-
TableHead,
|
|
24
|
-
TableHeader,
|
|
25
|
-
TableRow,
|
|
26
|
-
} from '@/components/table/table';
|
|
27
|
-
import { SimplePagination } from '@/components/pagination/pagination';
|
|
28
|
-
|
|
29
|
-
export interface DataTableProps<TData, TValue> {
|
|
30
|
-
/** 列定义(TanStack ColumnDef)。 */
|
|
31
|
-
columns: ColumnDef<TData, TValue>[];
|
|
32
|
-
/** 行数据。 */
|
|
33
|
-
data: TData[];
|
|
34
|
-
/**
|
|
35
|
-
* 是否启用分页(antd `pagination` 并集)。
|
|
36
|
-
* 传 `true` 用默认配置;传对象自定义 pageSize / siblingCount。
|
|
37
|
-
* @default true
|
|
38
|
-
*/
|
|
39
|
-
pagination?: boolean | { pageSize?: number; siblingCount?: number };
|
|
40
|
-
/**
|
|
41
|
-
* 是否启用排序(列定义里的 `enableSorting` 也要打开;默认列已开)。
|
|
42
|
-
* @default true
|
|
43
|
-
*/
|
|
44
|
-
sorting?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* 是否启用列过滤(每列 `header` 配 input 单独使用;此 flag 控制 columnFilters 状态)。
|
|
47
|
-
* @default true
|
|
48
|
-
*/
|
|
49
|
-
filtering?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* 行选择回调(antd `rowSelection.onChange` 并集)。传入即启用 selection。
|
|
52
|
-
* Selected rows 的原始 data 通过 `getRowId(row)` 推断,默认是 row.index。
|
|
53
|
-
*/
|
|
54
|
-
onRowSelectionChange?: (selectedRows: TData[]) => void;
|
|
55
|
-
/** 空数据时显示的内容。 */
|
|
56
|
-
emptyText?: React.ReactNode;
|
|
57
|
-
/** 容器 className。 */
|
|
58
|
-
className?: string;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* 高阶数据表 — 在基础 Table 之上叠加 TanStack 的 sorting / filtering / pagination /
|
|
63
|
-
* rowSelection 能力,等价 antd `Table` 的核心交互合集。
|
|
64
|
-
*
|
|
65
|
-
* 业务方需要更细粒度时(可控 state、virtualizer、column resizing 等),直接用
|
|
66
|
-
* `useReactTable` + 基础 Table primitives 自行拼装。
|
|
67
|
-
*/
|
|
68
|
-
function DataTable<TData, TValue>({
|
|
69
|
-
columns,
|
|
70
|
-
data,
|
|
71
|
-
pagination = true,
|
|
72
|
-
sorting: enableSorting = true,
|
|
73
|
-
filtering: enableFiltering = true,
|
|
74
|
-
onRowSelectionChange,
|
|
75
|
-
emptyText = '暂无数据',
|
|
76
|
-
className,
|
|
77
|
-
}: DataTableProps<TData, TValue>) {
|
|
78
|
-
const [sorting, setSorting] = React.useState<SortingState>([]);
|
|
79
|
-
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
|
|
80
|
-
[],
|
|
81
|
-
);
|
|
82
|
-
const [rowSelection, setRowSelection] = React.useState<RowSelectionState>({});
|
|
83
|
-
const [columnVisibility] = React.useState<VisibilityState>({});
|
|
84
|
-
|
|
85
|
-
const handleSelectionChange = (updater: Updater<RowSelectionState>) => {
|
|
86
|
-
setRowSelection(updater);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const pageCfg =
|
|
90
|
-
typeof pagination === 'object' ? pagination : { pageSize: 10 };
|
|
91
|
-
const pageSize = pageCfg.pageSize ?? 10;
|
|
92
|
-
|
|
93
|
-
const table = useReactTable({
|
|
94
|
-
data,
|
|
95
|
-
columns,
|
|
96
|
-
state: { sorting, columnFilters, columnVisibility, rowSelection },
|
|
97
|
-
onSortingChange: enableSorting ? setSorting : undefined,
|
|
98
|
-
onColumnFiltersChange: enableFiltering ? setColumnFilters : undefined,
|
|
99
|
-
onRowSelectionChange: onRowSelectionChange
|
|
100
|
-
? handleSelectionChange
|
|
101
|
-
: undefined,
|
|
102
|
-
enableRowSelection: !!onRowSelectionChange,
|
|
103
|
-
getCoreRowModel: getCoreRowModel(),
|
|
104
|
-
getSortedRowModel: enableSorting ? getSortedRowModel() : undefined,
|
|
105
|
-
getFilteredRowModel: enableFiltering ? getFilteredRowModel() : undefined,
|
|
106
|
-
getPaginationRowModel: pagination ? getPaginationRowModel() : undefined,
|
|
107
|
-
initialState: pagination ? { pagination: { pageSize } } : undefined,
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// Surface selected raw rows whenever rowSelection changes
|
|
111
|
-
React.useEffect(() => {
|
|
112
|
-
if (!onRowSelectionChange) return;
|
|
113
|
-
const selectedRows = table
|
|
114
|
-
.getSelectedRowModel()
|
|
115
|
-
.rows.map((r) => r.original);
|
|
116
|
-
onRowSelectionChange(selectedRows);
|
|
117
|
-
}, [rowSelection]);
|
|
118
|
-
|
|
119
|
-
const total = table.getFilteredRowModel().rows.length;
|
|
120
|
-
|
|
121
|
-
return (
|
|
122
|
-
<div className={cn('flex flex-col gap-3', className)}>
|
|
123
|
-
<div className="rounded-md border border-border">
|
|
124
|
-
<Table>
|
|
125
|
-
<TableHeader>
|
|
126
|
-
{table.getHeaderGroups().map((headerGroup) => (
|
|
127
|
-
<TableRow key={headerGroup.id}>
|
|
128
|
-
{headerGroup.headers.map((header) => (
|
|
129
|
-
<TableHead key={header.id}>
|
|
130
|
-
{header.isPlaceholder
|
|
131
|
-
? null
|
|
132
|
-
: flexRender(
|
|
133
|
-
header.column.columnDef.header,
|
|
134
|
-
header.getContext(),
|
|
135
|
-
)}
|
|
136
|
-
</TableHead>
|
|
137
|
-
))}
|
|
138
|
-
</TableRow>
|
|
139
|
-
))}
|
|
140
|
-
</TableHeader>
|
|
141
|
-
<TableBody>
|
|
142
|
-
{table.getRowModel().rows.length > 0 ? (
|
|
143
|
-
table.getRowModel().rows.map((row) => (
|
|
144
|
-
<TableRow
|
|
145
|
-
key={row.id}
|
|
146
|
-
data-state={row.getIsSelected() && 'selected'}
|
|
147
|
-
>
|
|
148
|
-
{row.getVisibleCells().map((cell) => (
|
|
149
|
-
<TableCell key={cell.id}>
|
|
150
|
-
{flexRender(
|
|
151
|
-
cell.column.columnDef.cell,
|
|
152
|
-
cell.getContext(),
|
|
153
|
-
)}
|
|
154
|
-
</TableCell>
|
|
155
|
-
))}
|
|
156
|
-
</TableRow>
|
|
157
|
-
))
|
|
158
|
-
) : (
|
|
159
|
-
<TableRow>
|
|
160
|
-
<TableCell
|
|
161
|
-
colSpan={columns.length}
|
|
162
|
-
className="h-24 text-center text-muted-foreground"
|
|
163
|
-
>
|
|
164
|
-
{emptyText}
|
|
165
|
-
</TableCell>
|
|
166
|
-
</TableRow>
|
|
167
|
-
)}
|
|
168
|
-
</TableBody>
|
|
169
|
-
</Table>
|
|
170
|
-
</div>
|
|
171
|
-
{pagination ? (
|
|
172
|
-
<SimplePagination
|
|
173
|
-
total={total}
|
|
174
|
-
pageSize={pageSize}
|
|
175
|
-
siblingCount={pageCfg.siblingCount}
|
|
176
|
-
current={table.getState().pagination.pageIndex + 1}
|
|
177
|
-
onChange={(p) => table.setPageIndex(p - 1)}
|
|
178
|
-
/>
|
|
179
|
-
) : null}
|
|
180
|
-
</div>
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export { DataTable };
|
|
185
|
-
export type { ColumnDef, ReactTable };
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
id: date-picker
|
|
3
|
-
name: DatePicker
|
|
4
|
-
displayName: 日期选择
|
|
5
|
-
type: component
|
|
6
|
-
category: data-entry
|
|
7
|
-
since: 0.1.0
|
|
8
|
-
package: '@teamix-evo/ui'
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# DatePicker 日期选择
|
|
12
|
-
|
|
13
|
-
日期选择器 — `Calendar + Popover` 复合,提供两种形态:
|
|
14
|
-
|
|
15
|
-
- `<DatePicker />` — 单日(对应 antd `DatePicker`)
|
|
16
|
-
- `<DateRangePicker />` — 范围(对应 antd `DatePicker.RangePicker`)
|
|
17
|
-
|
|
18
|
-
通过 `showTime` 可在右侧追加 `TimePickerPanel`,组合出日期 + 时间选择器(对齐 antd `DatePicker showTime`)。格式化用 `date-fns`(轻量、模块化、tree-shake 友好)。
|
|
19
|
-
|
|
20
|
-
## When to use
|
|
21
|
-
|
|
22
|
-
- 表单中的单日 / 范围选择
|
|
23
|
-
- 报表 / 数据筛选的时间维度
|
|
24
|
-
- 预约 / 计划 / 日程
|
|
25
|
-
- 需要精确到时分秒的时间戳 → `showTime`
|
|
26
|
-
|
|
27
|
-
## When NOT to use
|
|
28
|
-
|
|
29
|
-
- 仅显示日期(只读)→ `<time>{format(d, '...')}</time>`
|
|
30
|
-
- 内联日历 → 直接用 `Calendar`
|
|
31
|
-
- 仅时间(无日期)→ `TimePicker`
|
|
32
|
-
|
|
33
|
-
## Props
|
|
34
|
-
|
|
35
|
-
> 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成。
|
|
36
|
-
|
|
37
|
-
<!-- auto:props:begin -->
|
|
38
|
-
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
39
|
-
| --- | --- | --- | --- | --- |
|
|
40
|
-
| `picker` | `'date' \| 'month' \| 'year'` | `"date"` | – | 选择粒度(antd `picker` 并集) — 决定弹出面板类型: - `'date'`(默认) — 日历面板(选择具体日期) - `'month'` — 月份网格(选择到月) - `'year'` — 年份网格(选择到年) |
|
|
41
|
-
| `value` | `Date` | – | – | 受控值 — 当前选中日期(`showTime` 时含时间)。 |
|
|
42
|
-
| `defaultValue` | `Date` | – | – | 非受控初始值(对齐 antd / cd `defaultValue`)。仅在未传 `value` 时生效。 |
|
|
43
|
-
| `onChange` | `(value: Date \| undefined) => void` | – | – | 选中变化回调。`showTime` 时点击「确定」才触发,否则点击日期立即触发。 |
|
|
44
|
-
| `placeholder` | `string` | `"选择日期"` | – | 占位文本。 |
|
|
45
|
-
| `format` | `string` | `"yyyy-MM-dd"` | – | 显示格式(date-fns 语法)。`showTime` 时建议含时间 token,如 `yyyy-MM-dd HH:mm:ss`。 |
|
|
46
|
-
| `size` | `'sm' \| 'md' \| 'default' \| 'lg'` | `"md"` | – | 触发器尺寸。 |
|
|
47
|
-
| `className` | `string` | – | – | 触发器 className。 |
|
|
48
|
-
| `disabled` | `boolean` | – | – | 是否禁用。 |
|
|
49
|
-
| `disabledDates` | `(date: Date) => boolean` | – | – | 不可选日期 predicate。 |
|
|
50
|
-
| `showTime` | `boolean \| ShowTimeConfig` | `false` | – | 显示时间选择器(antd `showTime` 并集)。 - `true` — 启用,使用默认 `HH:mm:ss` 格式 - `ShowTimeConfig` — 详细配置(format / 默认值 / 步长 / 禁用回调) - `false` / 缺省 — 仅日期(默认行为,向后兼容) |
|
|
51
|
-
| `presets` | `boolean \| DatePickerPreset[]` | `false` | – | 弹层底部快捷 preset 链接(对齐 antd / cloud-design DatePicker2 的 `presets` 能力)。 - `true` — 启用内置默认集(今天 / 昨天) - `DatePickerPreset[]` — 自定义集 - `false` / 缺省 — 不显示 |
|
|
52
|
-
| `hasClear` | `boolean` | `true` | – | 显示清除按钮(antd `allowClear` 并集);有值时显示 X 替代日历图标,点击清空 value。 |
|
|
53
|
-
| `status` | `'default' \| 'error' \| 'warning'` | `"default"` | – | 校验状态(对齐 antd `status`) — 控制触发器边框 / 字体颜色: - `'error'` — 红色 destructive 边框 + `aria-invalid="true"` - `'warning'` — 警告色边框 - `'default'` / 缺省 — 中性边框 |
|
|
54
|
-
| `open` | `boolean` | – | – | 受控弹层显隐(对齐 antd `open`)。 业务侧需要"程序化打开 / 关闭"时使用;不传则组件内部自管。 |
|
|
55
|
-
| `onOpenChange` | `(open: boolean) => void` | – | – | 弹层显隐变化回调(对齐 antd `onOpenChange`)。 |
|
|
56
|
-
| `footer` | `React.ReactNode` | – | – | 弹层底部自定义 footer(对齐 antd `footer / renderExtraFooter`)。 与 `presets` 共存时,footer 渲染在 presets 之下。 |
|
|
57
|
-
| `inputReadOnly` | `boolean` | `false` | – | 输入框只读 — 仅能通过点击弹层选择,不能直接键入(对齐 antd `inputReadOnly`)。 |
|
|
58
|
-
<!-- auto:props:end -->
|
|
59
|
-
|
|
60
|
-
## 依赖
|
|
61
|
-
|
|
62
|
-
> 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成,数据源是 [`manifest.json`](../../../manifest.json)。**手工编辑 marker 之间的内容会在下次生成时被覆盖**。
|
|
63
|
-
|
|
64
|
-
<!-- auto:deps:begin -->
|
|
65
|
-
### 同库依赖
|
|
66
|
-
|
|
67
|
-
> `teamix-evo ui add date-picker` 时,以下 entry 会被自动连带安装(无需手动 add)。
|
|
68
|
-
|
|
69
|
-
| Entry | 类型 | 描述 |
|
|
70
|
-
| --- | --- | --- |
|
|
71
|
-
| `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
|
|
72
|
-
| `button` | component | 通用按钮 — shadcn 实现 + cloud-design 能力并集(loading / icon / shape / block / dashed variant / color 语义双 prop / disabledTooltip)。同文件合一导出 ButtonGroup + ButtonGroupText(等价 antd Space.Compact + cd SplitButton)。 |
|
|
73
|
-
| `calendar` | component | 日期选择面板 — react-day-picker,mode=single|multiple|range,与 design tokens 对齐 |
|
|
74
|
-
| `popover` | component | 可交互浮层 — Radix Popover + antd arrow 并集,使用 showArrow 控制尖角(与 Tooltip / HoverCard 命名统一) |
|
|
75
|
-
| `time-picker` | component | 时间选择 — Popover + 滚动列(TimeColumn)面板,含 TimePicker / TimeRangePicker / TimePickerPanel(对齐 antd TimePicker / TimePicker.RangePicker) |
|
|
76
|
-
|
|
77
|
-
### npm 依赖
|
|
78
|
-
|
|
79
|
-
> 业务侧需要先 `pnpm add` / `npm install` 这些包。CLI 在 `ui add` 完成后会列出此提示。
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
pnpm add date-fns@^3.0.0 react-day-picker@^9.0.0 lucide-react@^0.460.0
|
|
83
|
-
```
|
|
84
|
-
<!-- auto:deps:end -->
|
|
85
|
-
|
|
86
|
-
## AI 生成纪律
|
|
87
|
-
|
|
88
|
-
- **`format` 用 date-fns 字符串**:`yyyy-MM-dd` / `yyyy 年 M 月 d 日` 等;**不要**用旧 moment 写法(`YYYY-MM-DD` 大写在 date-fns 是年的"week year",非"calendar year")
|
|
89
|
-
- **`showTime` 启用后默认 `format` 自动变为 `yyyy-MM-dd HH:mm:ss`**:如自定义 `showTime={{ format: 'HH:mm' }}`,记得**同时**调整外层 `format`,否则触发器显示 `:00` 秒位
|
|
90
|
-
- **`showTime` 模式下点「确定」才触发 `onChange`**:面板内调整日期/时间只更新内部 draft;关闭等价于「取消」(对齐 antd 行为)
|
|
91
|
-
- **`disabledDates` 而非外部过滤**:把禁用判断 push 给 Calendar,避免选完再被刷掉的尴尬
|
|
92
|
-
- **范围选择默认 2 个月**:`numberOfMonths={2}` 是行业惯例(antd / shadcn / Material 都是);`showTime` 时建议 `numberOfMonths={1}` 节省横向空间
|
|
93
|
-
- **空态文案**:`placeholder` 简短,**不要**写 "请选择 / Please select" 之类无信息词;直接 "选择日期" / "下单时间"
|
|
94
|
-
|
|
95
|
-
## Examples
|
|
96
|
-
|
|
97
|
-
```tsx
|
|
98
|
-
import { DatePicker, DateRangePicker } from '@/components/ui/date-picker';
|
|
99
|
-
import * as React from 'react';
|
|
100
|
-
|
|
101
|
-
// 单日
|
|
102
|
-
const [d, setD] = React.useState<Date>();
|
|
103
|
-
<DatePicker value={d} onChange={setD} placeholder="选择日期" />
|
|
104
|
-
|
|
105
|
-
// 自定义格式
|
|
106
|
-
<DatePicker value={d} onChange={setD} format="yyyy 年 M 月 d 日" />
|
|
107
|
-
|
|
108
|
-
// 禁用过去
|
|
109
|
-
import { startOfDay } from 'date-fns';
|
|
110
|
-
<DatePicker
|
|
111
|
-
value={d}
|
|
112
|
-
onChange={setD}
|
|
113
|
-
disabledDates={(date) => date < startOfDay(new Date())}
|
|
114
|
-
/>
|
|
115
|
-
|
|
116
|
-
// 范围
|
|
117
|
-
const [r, setR] = React.useState<{ from?: Date; to?: Date }>();
|
|
118
|
-
<DateRangePicker value={r} onChange={setR} placeholder="选择范围" />
|
|
119
|
-
|
|
120
|
-
// showTime — 日期 + 时间
|
|
121
|
-
const [dt, setDt] = React.useState<Date>();
|
|
122
|
-
<DatePicker value={dt} onChange={setDt} showTime />
|
|
123
|
-
|
|
124
|
-
// showTime 自定义时间格式 + 步长
|
|
125
|
-
<DatePicker
|
|
126
|
-
value={dt}
|
|
127
|
-
onChange={setDt}
|
|
128
|
-
showTime={{ format: 'HH:mm', minuteStep: 5 }}
|
|
129
|
-
format="yyyy-MM-dd HH:mm"
|
|
130
|
-
/>
|
|
131
|
-
|
|
132
|
-
// 范围 + showTime
|
|
133
|
-
<DateRangePicker value={r} onChange={setR} showTime numberOfMonths={1} />
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
## DatePicker 形态 — 旧库 API → 新映射
|
|
139
|
-
|
|
140
|
-
> 旧库 `DatePicker2`(hybridcloud,含 MonthPicker / YearPicker / RangePicker 子组件) → 新库 `DatePicker` + `DateRangePicker`(独立导出)。
|
|
141
|
-
> 新库用 `react-day-picker v9` + `date-fns`,不依赖 moment / dayjs。
|
|
142
|
-
|
|
143
|
-
### 命名 & 结构映射
|
|
144
|
-
|
|
145
|
-
| 旧库 | 新库 | 说明 |
|
|
146
|
-
| --------------------------------------- | ----------------------------------------- | -------------------------- |
|
|
147
|
-
| `DatePicker2` | `DatePicker` | 组件名简化 |
|
|
148
|
-
| `DatePicker.RangePicker` | `DateRangePicker` | 独立导出(非挂载) |
|
|
149
|
-
| `MonthPicker / YearPicker / WeekPicker` | _(未来 P1: picker prop)_ | MVP 仅支持 date mode |
|
|
150
|
-
| `value` (Dayjs) | `value` (Date) | 类型变更,无日期库依赖 |
|
|
151
|
-
| `onChange(Dayjs, strVal)` | `onChange(Date \| undefined)` | 去掉字符串参数 |
|
|
152
|
-
| `format` (YYYY-MM-DD) | `format` (yyyy-MM-dd) | date-fns 语法(小写 y/d) |
|
|
153
|
-
| `size: small/medium/large` | `size: 'sm' \| 'md' \| 'default' \| 'lg'` | md = medium = default |
|
|
154
|
-
| `disabledDate(d)` | `disabledDates(d)` | 复数 |
|
|
155
|
-
| `preset` | `presets` (boolean \| array) | 复数 + 支持 true 用内置集 |
|
|
156
|
-
| `showTime` | `showTime` (boolean \| ShowTimeConfig) | API 对齐,细节配置结构一致 |
|
|
157
|
-
| `hasClear` | `hasClear` | 命名保留 |
|
|
158
|
-
| `visible / onVisibleChange` | _(未来 P2: open / onOpenChange)_ | MVP 不含弹层受控 |
|
|
159
|
-
| `state` | _(未来 P2: status)_ | MVP 无校验状态 |
|
|
160
|
-
| `dateCellRender` | _(未来 P3)_ | MVP 无自定义单元格 |
|
|
161
|
-
| `footerRender` | _(未来 P2: footer)_ | MVP 无自定义页脚 |
|
|
162
|
-
| `inputReadOnly` | _(未来 P2)_ | MVP 输入框可编辑 |
|
|
163
|
-
| `outputFormat` | 不复刻 | 应用层自行 format |
|
|
164
|
-
| `popupTriggerType="hover"` | 不复刻 | hover 触发不合理 |
|
|
165
|
-
| `isPreview / renderPreview` | 不复刻 | 新库无预览态 |
|
|
166
|
-
|
|
167
|
-
### 迁移 FAQ
|
|
168
|
-
|
|
169
|
-
| 问题 | 回答 |
|
|
170
|
-
| -------------------------- | ----------------------------------------------------------------------- |
|
|
171
|
-
| Dayjs → Date 怎么转? | `dayjs.toDate()` 即可;反向 `dayjs(date)` |
|
|
172
|
-
| format 大小写区别? | moment `YYYY` = date-fns `yyyy`; moment `DD` = date-fns `dd`; `MM` 相同 |
|
|
173
|
-
| RangePicker 值结构? | 旧: `[Dayjs, Dayjs]` → 新: `{ from?: Date, to?: Date }` |
|
|
174
|
-
| 怎么实现 MonthPicker? | MVP 暂不支持;待 picker prop 迭代;当前可用 Select 替代 |
|
|
175
|
-
| showTime 的“确定”按钮在哪? | 面板底部自带“确定”按钮;仅 showTime 模式有(对齐 antd) |
|