@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,976 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 筛选栏 FilterBar
|
|
3
|
+
*
|
|
4
|
+
* 表格 / 列表页顶部的组合式筛选区域。形态由子组件组合决定:
|
|
5
|
+
* - `FilterBarHeader` 行内多字段并排(截图 1)
|
|
6
|
+
* - `FilterBarHeader` + `FilterBarTrigger` + `FilterBarContent` 行内+折叠面板(截图 2)
|
|
7
|
+
* - 仅 `FilterBarTrigger` + `FilterBarContent` 纯面板(截图 3)
|
|
8
|
+
* - `FilterBarSearch` 紧凑搜索条 + 高级筛选面板(截图 4 / 5)
|
|
9
|
+
*
|
|
10
|
+
* 内置 react-hook-form `FormProvider`,行内字段防抖触发 `onFilter`,
|
|
11
|
+
* 面板字段需点击搜索或 Enter 触发。
|
|
12
|
+
*
|
|
13
|
+
* @when
|
|
14
|
+
* - 列表页 / 表格页顶部多条件筛选
|
|
15
|
+
* - 需要 RHF 表单托管的查询区域
|
|
16
|
+
* - 需要"行内 + 高级筛选面板"两段式 UX
|
|
17
|
+
*/
|
|
18
|
+
'use client';
|
|
19
|
+
|
|
20
|
+
import * as React from 'react';
|
|
21
|
+
import { ChevronDown, Search } from 'lucide-react';
|
|
22
|
+
import {
|
|
23
|
+
Controller,
|
|
24
|
+
FormProvider,
|
|
25
|
+
useController,
|
|
26
|
+
type Control,
|
|
27
|
+
type ControllerFieldState,
|
|
28
|
+
type ControllerRenderProps,
|
|
29
|
+
type FieldPath,
|
|
30
|
+
type FieldValues,
|
|
31
|
+
type SubmitHandler,
|
|
32
|
+
type UseFormReturn,
|
|
33
|
+
type UseFormStateReturn,
|
|
34
|
+
} from 'react-hook-form';
|
|
35
|
+
|
|
36
|
+
import { cn } from '@/lib/utils';
|
|
37
|
+
import { Button } from '@/components/button';
|
|
38
|
+
import {
|
|
39
|
+
Field,
|
|
40
|
+
FieldInsetBox,
|
|
41
|
+
FieldLabel,
|
|
42
|
+
FieldDescription,
|
|
43
|
+
} from '@/components/field';
|
|
44
|
+
import {
|
|
45
|
+
Collapsible,
|
|
46
|
+
CollapsibleContent,
|
|
47
|
+
CollapsibleTrigger,
|
|
48
|
+
} from '@/components/collapsible';
|
|
49
|
+
import { Input } from '@/components/input';
|
|
50
|
+
import {
|
|
51
|
+
Select,
|
|
52
|
+
SelectContent,
|
|
53
|
+
SelectItem,
|
|
54
|
+
SelectTrigger,
|
|
55
|
+
SelectValue,
|
|
56
|
+
} from '@/components/select';
|
|
57
|
+
|
|
58
|
+
// ─── Types ──────────────────────────────────────────────────────────────────
|
|
59
|
+
|
|
60
|
+
/** 列数:纯数字或响应式断点对象。 */
|
|
61
|
+
export type FilterBarColumns =
|
|
62
|
+
| number
|
|
63
|
+
| {
|
|
64
|
+
base?: number;
|
|
65
|
+
sm?: number;
|
|
66
|
+
md?: number;
|
|
67
|
+
lg?: number;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** FilterBarSearchKey 的可切换字段选项。 */
|
|
71
|
+
export interface FilterBarSearchOption {
|
|
72
|
+
/** RHF 字段名。 */
|
|
73
|
+
name: string;
|
|
74
|
+
/** 字段标签(出现在选择器与 placeholder)。 */
|
|
75
|
+
label: string;
|
|
76
|
+
/** 自定义 placeholder,缺省为 "请输入{label}"。 */
|
|
77
|
+
placeholder?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface FilterBarSearchContextValue {
|
|
81
|
+
activeName: string | undefined;
|
|
82
|
+
setActiveName: (name: string) => void;
|
|
83
|
+
exclusive: boolean;
|
|
84
|
+
options: FilterBarSearchOption[];
|
|
85
|
+
setOptions: (opts: FilterBarSearchOption[]) => void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const FilterBarSearchContext =
|
|
89
|
+
React.createContext<FilterBarSearchContextValue | null>(null);
|
|
90
|
+
|
|
91
|
+
function useFilterBarSearch(): FilterBarSearchContextValue {
|
|
92
|
+
const ctx = React.useContext(FilterBarSearchContext);
|
|
93
|
+
if (!ctx) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
'FilterBarSearchKey / FilterBarSearchValue / FilterBarSearchAction 必须在 <FilterBarSearch> 内部使用',
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
return ctx;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface FilterBarContextValue {
|
|
102
|
+
form: UseFormReturn<FieldValues>;
|
|
103
|
+
debounceMs: number;
|
|
104
|
+
clearOnReset: boolean;
|
|
105
|
+
open: boolean;
|
|
106
|
+
setOpen: (next: boolean) => void;
|
|
107
|
+
addonBefore?: React.ReactNode;
|
|
108
|
+
addonAfter?: React.ReactNode;
|
|
109
|
+
columns: FilterBarColumns;
|
|
110
|
+
triggerFilter: () => void;
|
|
111
|
+
triggerReset: () => void;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const FilterBarContext = React.createContext<FilterBarContextValue | null>(
|
|
115
|
+
null,
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
function useFilterBar(): FilterBarContextValue {
|
|
119
|
+
const ctx = React.useContext(FilterBarContext);
|
|
120
|
+
if (!ctx) {
|
|
121
|
+
throw new Error('FilterBar.* 必须在 <FilterBar> 内部使用');
|
|
122
|
+
}
|
|
123
|
+
return ctx;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** 子区上下文:决定 FilterBarField / FilterBarFooter 的布局形态。 */
|
|
127
|
+
type FilterBarSection = 'header' | 'content';
|
|
128
|
+
const FilterBarSectionContext = React.createContext<FilterBarSection>('header');
|
|
129
|
+
|
|
130
|
+
// ─── Tailwind 静态映射(grid 类名禁止动态拼接) ────────────────────────────
|
|
131
|
+
|
|
132
|
+
const COLS_BASE: Record<number, string> = {
|
|
133
|
+
1: 'grid-cols-1',
|
|
134
|
+
2: 'grid-cols-2',
|
|
135
|
+
3: 'grid-cols-3',
|
|
136
|
+
4: 'grid-cols-4',
|
|
137
|
+
5: 'grid-cols-5',
|
|
138
|
+
6: 'grid-cols-6',
|
|
139
|
+
};
|
|
140
|
+
const COLS_SM: Record<number, string> = {
|
|
141
|
+
1: 'sm:grid-cols-1',
|
|
142
|
+
2: 'sm:grid-cols-2',
|
|
143
|
+
3: 'sm:grid-cols-3',
|
|
144
|
+
4: 'sm:grid-cols-4',
|
|
145
|
+
5: 'sm:grid-cols-5',
|
|
146
|
+
6: 'sm:grid-cols-6',
|
|
147
|
+
};
|
|
148
|
+
const COLS_MD: Record<number, string> = {
|
|
149
|
+
1: 'md:grid-cols-1',
|
|
150
|
+
2: 'md:grid-cols-2',
|
|
151
|
+
3: 'md:grid-cols-3',
|
|
152
|
+
4: 'md:grid-cols-4',
|
|
153
|
+
5: 'md:grid-cols-5',
|
|
154
|
+
6: 'md:grid-cols-6',
|
|
155
|
+
};
|
|
156
|
+
const COLS_LG: Record<number, string> = {
|
|
157
|
+
1: 'lg:grid-cols-1',
|
|
158
|
+
2: 'lg:grid-cols-2',
|
|
159
|
+
3: 'lg:grid-cols-3',
|
|
160
|
+
4: 'lg:grid-cols-4',
|
|
161
|
+
5: 'lg:grid-cols-5',
|
|
162
|
+
6: 'lg:grid-cols-6',
|
|
163
|
+
};
|
|
164
|
+
const COLSPAN: Record<number, string> = {
|
|
165
|
+
1: '',
|
|
166
|
+
2: 'col-span-2',
|
|
167
|
+
3: 'col-span-3',
|
|
168
|
+
4: 'col-span-4',
|
|
169
|
+
5: 'col-span-5',
|
|
170
|
+
6: 'col-span-6',
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
function clamp(n: number, min = 1, max = 6) {
|
|
174
|
+
return Math.max(min, Math.min(max, Math.floor(n)));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function resolveColumnsClass(columns: FilterBarColumns): string {
|
|
178
|
+
if (typeof columns === 'number') {
|
|
179
|
+
return COLS_BASE[clamp(columns)] ?? 'grid-cols-3';
|
|
180
|
+
}
|
|
181
|
+
const cls: string[] = [];
|
|
182
|
+
if (columns.base) cls.push(COLS_BASE[clamp(columns.base)] ?? '');
|
|
183
|
+
if (columns.sm) cls.push(COLS_SM[clamp(columns.sm)] ?? '');
|
|
184
|
+
if (columns.md) cls.push(COLS_MD[clamp(columns.md)] ?? '');
|
|
185
|
+
if (columns.lg) cls.push(COLS_LG[clamp(columns.lg)] ?? '');
|
|
186
|
+
const joined = cls.filter(Boolean).join(' ');
|
|
187
|
+
return joined || 'grid-cols-3';
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// ─── FilterBar (Root) ───────────────────────────────────────────────────────
|
|
191
|
+
|
|
192
|
+
export interface FilterBarProps<TForm extends FieldValues = FieldValues>
|
|
193
|
+
extends Omit<
|
|
194
|
+
React.ComponentProps<'form'>,
|
|
195
|
+
'onSubmit' | 'onReset' | 'onChange' | 'children'
|
|
196
|
+
> {
|
|
197
|
+
/** RHF 表单实例(必传),通常来自 `useForm()`。 */
|
|
198
|
+
form: UseFormReturn<TForm>;
|
|
199
|
+
/** 提交筛选回调(点击搜索 / 行内防抖 / Enter 触发)。 */
|
|
200
|
+
onFilter?: SubmitHandler<TForm>;
|
|
201
|
+
/** 重置回调(在 form.reset 之后触发)。 */
|
|
202
|
+
onReset?: () => void;
|
|
203
|
+
/** 表单值变化回调(任意字段变化即触发,未防抖)。 */
|
|
204
|
+
onChange?: (values: TForm) => void;
|
|
205
|
+
/** 首次挂载回调,可在此调 `form.setValue` 注入异步默认值。 */
|
|
206
|
+
onInit?: (form: UseFormReturn<TForm>) => void;
|
|
207
|
+
/** 高级筛选面板默认是否展开。 @default false */
|
|
208
|
+
defaultOpen?: boolean;
|
|
209
|
+
/** 高级筛选面板展开状态(受控)。 */
|
|
210
|
+
open?: boolean;
|
|
211
|
+
/** 展开状态变化回调。 */
|
|
212
|
+
onOpenChange?: (open: boolean) => void;
|
|
213
|
+
/** 行内字段防抖触发 onFilter 的延迟(毫秒)。 @default 300 */
|
|
214
|
+
debounceMs?: number;
|
|
215
|
+
/** 重置时是否丢弃 defaultValues(true=完全清空)。 @default false */
|
|
216
|
+
clearOnReset?: boolean;
|
|
217
|
+
/** 是否在行内字段变化时自动触发 onFilter(防抖)。 @default false */
|
|
218
|
+
autoFilter?: boolean;
|
|
219
|
+
/** Header 左侧槽位,常用于"+创建任务"等主操作按钮。 */
|
|
220
|
+
addonBefore?: React.ReactNode;
|
|
221
|
+
/** Header 右侧槽位,常用于⚙️等次要操作。 */
|
|
222
|
+
addonAfter?: React.ReactNode;
|
|
223
|
+
/** 面板栅格列数,默认 3。 */
|
|
224
|
+
columns?: FilterBarColumns;
|
|
225
|
+
children?: React.ReactNode;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function FilterBar<TForm extends FieldValues = FieldValues>({
|
|
229
|
+
form,
|
|
230
|
+
onFilter,
|
|
231
|
+
onReset,
|
|
232
|
+
onChange,
|
|
233
|
+
onInit,
|
|
234
|
+
defaultOpen = false,
|
|
235
|
+
open: openProp,
|
|
236
|
+
onOpenChange,
|
|
237
|
+
debounceMs = 300,
|
|
238
|
+
clearOnReset = false,
|
|
239
|
+
autoFilter = false,
|
|
240
|
+
addonBefore,
|
|
241
|
+
addonAfter,
|
|
242
|
+
columns = 3,
|
|
243
|
+
className,
|
|
244
|
+
children,
|
|
245
|
+
...rest
|
|
246
|
+
}: FilterBarProps<TForm>) {
|
|
247
|
+
const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
|
|
248
|
+
const open = openProp ?? internalOpen;
|
|
249
|
+
const setOpen = React.useCallback(
|
|
250
|
+
(next: boolean) => {
|
|
251
|
+
if (openProp === undefined) setInternalOpen(next);
|
|
252
|
+
onOpenChange?.(next);
|
|
253
|
+
},
|
|
254
|
+
[openProp, onOpenChange],
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
// onInit — 仅在首次挂载执行一次
|
|
258
|
+
const initRef = React.useRef(false);
|
|
259
|
+
React.useEffect(() => {
|
|
260
|
+
if (initRef.current) return;
|
|
261
|
+
initRef.current = true;
|
|
262
|
+
onInit?.(form);
|
|
263
|
+
}, [form, onInit]);
|
|
264
|
+
|
|
265
|
+
// onChange — 订阅 form watch
|
|
266
|
+
React.useEffect(() => {
|
|
267
|
+
if (!onChange) return;
|
|
268
|
+
const sub = form.watch((values) => onChange(values as TForm));
|
|
269
|
+
return () => sub.unsubscribe();
|
|
270
|
+
}, [form, onChange]);
|
|
271
|
+
|
|
272
|
+
const triggerFilter = React.useCallback(() => {
|
|
273
|
+
void form.handleSubmit((values) => {
|
|
274
|
+
onFilter?.(values as TForm);
|
|
275
|
+
})();
|
|
276
|
+
}, [form, onFilter]);
|
|
277
|
+
|
|
278
|
+
const triggerReset = React.useCallback(() => {
|
|
279
|
+
if (clearOnReset) {
|
|
280
|
+
form.reset(undefined, { keepDefaultValues: false });
|
|
281
|
+
} else {
|
|
282
|
+
form.reset();
|
|
283
|
+
}
|
|
284
|
+
onReset?.();
|
|
285
|
+
triggerFilter();
|
|
286
|
+
}, [form, clearOnReset, onReset, triggerFilter]);
|
|
287
|
+
|
|
288
|
+
// autoFilter — 行内字段防抖触发 onFilter
|
|
289
|
+
React.useEffect(() => {
|
|
290
|
+
if (!autoFilter) return;
|
|
291
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
292
|
+
const sub = form.watch(() => {
|
|
293
|
+
if (timer) clearTimeout(timer);
|
|
294
|
+
timer = setTimeout(triggerFilter, debounceMs);
|
|
295
|
+
});
|
|
296
|
+
return () => {
|
|
297
|
+
if (timer) clearTimeout(timer);
|
|
298
|
+
sub.unsubscribe();
|
|
299
|
+
};
|
|
300
|
+
}, [form, autoFilter, debounceMs, triggerFilter]);
|
|
301
|
+
|
|
302
|
+
const ctx = React.useMemo<FilterBarContextValue>(
|
|
303
|
+
() => ({
|
|
304
|
+
form: form as unknown as UseFormReturn<FieldValues>,
|
|
305
|
+
debounceMs,
|
|
306
|
+
clearOnReset,
|
|
307
|
+
open,
|
|
308
|
+
setOpen,
|
|
309
|
+
addonBefore,
|
|
310
|
+
addonAfter,
|
|
311
|
+
columns,
|
|
312
|
+
triggerFilter,
|
|
313
|
+
triggerReset,
|
|
314
|
+
}),
|
|
315
|
+
[
|
|
316
|
+
form,
|
|
317
|
+
debounceMs,
|
|
318
|
+
clearOnReset,
|
|
319
|
+
open,
|
|
320
|
+
setOpen,
|
|
321
|
+
addonBefore,
|
|
322
|
+
addonAfter,
|
|
323
|
+
columns,
|
|
324
|
+
triggerFilter,
|
|
325
|
+
triggerReset,
|
|
326
|
+
],
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
return (
|
|
330
|
+
<FilterBarContext.Provider value={ctx}>
|
|
331
|
+
<FormProvider {...form}>
|
|
332
|
+
<Collapsible open={open} onOpenChange={setOpen} asChild>
|
|
333
|
+
<form
|
|
334
|
+
data-slot="filter-bar"
|
|
335
|
+
onSubmit={(e) => {
|
|
336
|
+
e.preventDefault();
|
|
337
|
+
triggerFilter();
|
|
338
|
+
}}
|
|
339
|
+
className={cn('flex flex-col', className)}
|
|
340
|
+
{...rest}
|
|
341
|
+
>
|
|
342
|
+
{children}
|
|
343
|
+
</form>
|
|
344
|
+
</Collapsible>
|
|
345
|
+
</FormProvider>
|
|
346
|
+
</FilterBarContext.Provider>
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// ─── FilterBarHeader ────────────────────────────────────────────────────────
|
|
351
|
+
|
|
352
|
+
function FilterBarHeader({
|
|
353
|
+
className,
|
|
354
|
+
children,
|
|
355
|
+
...props
|
|
356
|
+
}: React.ComponentProps<'div'>) {
|
|
357
|
+
const { addonBefore, addonAfter } = useFilterBar();
|
|
358
|
+
return (
|
|
359
|
+
<FilterBarSectionContext.Provider value="header">
|
|
360
|
+
<div
|
|
361
|
+
data-slot="filter-bar-header"
|
|
362
|
+
className={cn('flex flex-wrap items-center gap-3', className)}
|
|
363
|
+
{...props}
|
|
364
|
+
>
|
|
365
|
+
{addonBefore && (
|
|
366
|
+
<div
|
|
367
|
+
data-slot="filter-bar-addon-before"
|
|
368
|
+
className="flex shrink-0 items-center"
|
|
369
|
+
>
|
|
370
|
+
{addonBefore}
|
|
371
|
+
</div>
|
|
372
|
+
)}
|
|
373
|
+
<div className="flex min-w-0 flex-1 flex-wrap items-center gap-3">
|
|
374
|
+
{children}
|
|
375
|
+
</div>
|
|
376
|
+
{addonAfter && (
|
|
377
|
+
<div
|
|
378
|
+
data-slot="filter-bar-addon-after"
|
|
379
|
+
className="flex shrink-0 items-center"
|
|
380
|
+
>
|
|
381
|
+
{addonAfter}
|
|
382
|
+
</div>
|
|
383
|
+
)}
|
|
384
|
+
</div>
|
|
385
|
+
</FilterBarSectionContext.Provider>
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// ─── FilterBarSearch ────────────────────────────────────────────────────────
|
|
390
|
+
|
|
391
|
+
export interface FilterBarSearchProps
|
|
392
|
+
extends Omit<React.ComponentProps<'div'>, 'children'> {
|
|
393
|
+
/** 切换搜索字段时是否清空其它字段。 @default true */
|
|
394
|
+
exclusive?: boolean;
|
|
395
|
+
/** 三段 children:`FilterBarSearchKey` + `FilterBarSearchValue` + `FilterBarSearchAction`。 */
|
|
396
|
+
children?: React.ReactNode;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function FilterBarSearch({
|
|
400
|
+
exclusive = true,
|
|
401
|
+
className,
|
|
402
|
+
children,
|
|
403
|
+
...props
|
|
404
|
+
}: FilterBarSearchProps) {
|
|
405
|
+
const [activeName, setActiveName] = React.useState<string | undefined>(
|
|
406
|
+
undefined,
|
|
407
|
+
);
|
|
408
|
+
const [options, setOptions] = React.useState<FilterBarSearchOption[]>([]);
|
|
409
|
+
|
|
410
|
+
const ctx = React.useMemo<FilterBarSearchContextValue>(
|
|
411
|
+
() => ({ activeName, setActiveName, exclusive, options, setOptions }),
|
|
412
|
+
[activeName, exclusive, options],
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
return (
|
|
416
|
+
<FilterBarSearchContext.Provider value={ctx}>
|
|
417
|
+
<div
|
|
418
|
+
data-slot="filter-bar-search"
|
|
419
|
+
className={cn(
|
|
420
|
+
'flex h-8 items-center overflow-hidden rounded-md border border-input bg-card',
|
|
421
|
+
'focus-within:border-ring focus-within:ring-1 focus-within:ring-ring',
|
|
422
|
+
className,
|
|
423
|
+
)}
|
|
424
|
+
{...props}
|
|
425
|
+
>
|
|
426
|
+
{children}
|
|
427
|
+
</div>
|
|
428
|
+
</FilterBarSearchContext.Provider>
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// ─── FilterBarSearchKey ─────────────────────────────────────
|
|
433
|
+
|
|
434
|
+
export interface FilterBarSearchKeyProps {
|
|
435
|
+
/** 可切换的字段选项。 */
|
|
436
|
+
options: FilterBarSearchOption[];
|
|
437
|
+
className?: string;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function FilterBarSearchKey({ options, className }: FilterBarSearchKeyProps) {
|
|
441
|
+
const search = useFilterBarSearch();
|
|
442
|
+
const { form } = useFilterBar();
|
|
443
|
+
|
|
444
|
+
// 注册 options 到 SearchContext + 默认 active 首项
|
|
445
|
+
React.useEffect(() => {
|
|
446
|
+
search.setOptions(options);
|
|
447
|
+
if (!search.activeName && options[0]) {
|
|
448
|
+
search.setActiveName(options[0].name);
|
|
449
|
+
}
|
|
450
|
+
}, [options]);
|
|
451
|
+
|
|
452
|
+
const active =
|
|
453
|
+
options.find((o) => o.name === search.activeName) ?? options[0];
|
|
454
|
+
|
|
455
|
+
const onChange = (name: string) => {
|
|
456
|
+
if (search.exclusive) {
|
|
457
|
+
options.forEach((o) => {
|
|
458
|
+
if (o.name !== name) {
|
|
459
|
+
form.setValue(o.name as FieldPath<FieldValues>, '');
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
search.setActiveName(name);
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
if (!active) return null;
|
|
467
|
+
|
|
468
|
+
return (
|
|
469
|
+
<Select value={active.name} onValueChange={onChange}>
|
|
470
|
+
<SelectTrigger
|
|
471
|
+
size="sm"
|
|
472
|
+
className={cn(
|
|
473
|
+
'h-full rounded-none border-0 border-r border-input bg-transparent shadow-none focus-visible:ring-0',
|
|
474
|
+
className,
|
|
475
|
+
)}
|
|
476
|
+
>
|
|
477
|
+
<SelectValue />
|
|
478
|
+
</SelectTrigger>
|
|
479
|
+
<SelectContent>
|
|
480
|
+
{options.map((o) => (
|
|
481
|
+
<SelectItem key={o.name} value={o.name}>
|
|
482
|
+
{o.label}
|
|
483
|
+
</SelectItem>
|
|
484
|
+
))}
|
|
485
|
+
</SelectContent>
|
|
486
|
+
</Select>
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// ─── FilterBarSearchValue ───────────────────────────────────
|
|
491
|
+
|
|
492
|
+
export interface FilterBarSearchValueProps
|
|
493
|
+
extends Omit<
|
|
494
|
+
React.ComponentProps<typeof Input>,
|
|
495
|
+
'name' | 'value' | 'onChange'
|
|
496
|
+
> {
|
|
497
|
+
/** 自定义 placeholder(缺省取 active option 的 placeholder 或「请输入{label}」)。 */
|
|
498
|
+
placeholder?: string;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function FilterBarSearchValue({
|
|
502
|
+
placeholder,
|
|
503
|
+
className,
|
|
504
|
+
...props
|
|
505
|
+
}: FilterBarSearchValueProps) {
|
|
506
|
+
const search = useFilterBarSearch();
|
|
507
|
+
const { form, triggerFilter } = useFilterBar();
|
|
508
|
+
const active = search.options.find((o) => o.name === search.activeName);
|
|
509
|
+
|
|
510
|
+
if (!active) return null;
|
|
511
|
+
|
|
512
|
+
const ph = placeholder ?? active.placeholder ?? `请输入${active.label}`;
|
|
513
|
+
|
|
514
|
+
return (
|
|
515
|
+
<Controller
|
|
516
|
+
control={form.control}
|
|
517
|
+
name={active.name as FieldPath<FieldValues>}
|
|
518
|
+
render={({ field }) => (
|
|
519
|
+
<Input
|
|
520
|
+
{...props}
|
|
521
|
+
value={(field.value as string | undefined) ?? ''}
|
|
522
|
+
onChange={field.onChange}
|
|
523
|
+
onBlur={field.onBlur}
|
|
524
|
+
onKeyDown={(e) => {
|
|
525
|
+
if (e.key === 'Enter') {
|
|
526
|
+
e.preventDefault();
|
|
527
|
+
triggerFilter();
|
|
528
|
+
}
|
|
529
|
+
}}
|
|
530
|
+
placeholder={ph}
|
|
531
|
+
className={cn(
|
|
532
|
+
'h-full flex-1 rounded-none border-0 shadow-none focus-visible:border-0 focus-visible:ring-0',
|
|
533
|
+
className,
|
|
534
|
+
)}
|
|
535
|
+
/>
|
|
536
|
+
)}
|
|
537
|
+
/>
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// ─── FilterBarSearchAction ──────────────────────────────────
|
|
542
|
+
|
|
543
|
+
export interface FilterBarSearchActionProps
|
|
544
|
+
extends React.ComponentProps<'button'> {}
|
|
545
|
+
|
|
546
|
+
function FilterBarSearchAction({
|
|
547
|
+
className,
|
|
548
|
+
children,
|
|
549
|
+
onClick,
|
|
550
|
+
...props
|
|
551
|
+
}: FilterBarSearchActionProps) {
|
|
552
|
+
const { triggerFilter } = useFilterBar();
|
|
553
|
+
return (
|
|
554
|
+
<button
|
|
555
|
+
type="button"
|
|
556
|
+
aria-label="搜索"
|
|
557
|
+
onClick={(e) => {
|
|
558
|
+
onClick?.(e);
|
|
559
|
+
if (!e.defaultPrevented) triggerFilter();
|
|
560
|
+
}}
|
|
561
|
+
className={cn(
|
|
562
|
+
'flex h-full w-8 cursor-pointer items-center justify-center border-l border-input text-muted-foreground transition-colors hover:bg-muted hover:text-foreground',
|
|
563
|
+
className,
|
|
564
|
+
)}
|
|
565
|
+
{...props}
|
|
566
|
+
>
|
|
567
|
+
{children ?? <Search className="size-3.5" />}
|
|
568
|
+
</button>
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// ─── FilterBarTrigger ───────────────────────────────────────────────────────
|
|
573
|
+
|
|
574
|
+
export interface FilterBarTriggerProps
|
|
575
|
+
extends React.ComponentProps<typeof Button> {}
|
|
576
|
+
|
|
577
|
+
function FilterBarTrigger({
|
|
578
|
+
className,
|
|
579
|
+
children,
|
|
580
|
+
...props
|
|
581
|
+
}: FilterBarTriggerProps) {
|
|
582
|
+
const { open } = useFilterBar();
|
|
583
|
+
return (
|
|
584
|
+
<CollapsibleTrigger asChild>
|
|
585
|
+
<Button
|
|
586
|
+
type="button"
|
|
587
|
+
variant="outline"
|
|
588
|
+
data-slot="filter-bar-trigger"
|
|
589
|
+
className={className}
|
|
590
|
+
{...props}
|
|
591
|
+
>
|
|
592
|
+
{children ?? '高级筛选'}
|
|
593
|
+
<ChevronDown
|
|
594
|
+
className={cn('transition-transform', open && 'rotate-180')}
|
|
595
|
+
/>
|
|
596
|
+
</Button>
|
|
597
|
+
</CollapsibleTrigger>
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// ─── FilterBarContent ───────────────────────────────────────────────────────
|
|
602
|
+
|
|
603
|
+
export interface FilterBarContentProps
|
|
604
|
+
extends React.ComponentProps<typeof CollapsibleContent> {
|
|
605
|
+
/** 覆盖 Root 的 columns 配置。 */
|
|
606
|
+
columns?: FilterBarColumns;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function FilterBarContent({
|
|
610
|
+
columns: columnsProp,
|
|
611
|
+
className,
|
|
612
|
+
children,
|
|
613
|
+
...props
|
|
614
|
+
}: FilterBarContentProps) {
|
|
615
|
+
const { columns: ctxColumns } = useFilterBar();
|
|
616
|
+
const columns = columnsProp ?? ctxColumns;
|
|
617
|
+
const colClass = resolveColumnsClass(columns);
|
|
618
|
+
return (
|
|
619
|
+
<FilterBarSectionContext.Provider value="content">
|
|
620
|
+
<CollapsibleContent
|
|
621
|
+
data-slot="filter-bar-content"
|
|
622
|
+
className={cn('overflow-hidden pt-2', className)}
|
|
623
|
+
{...props}
|
|
624
|
+
>
|
|
625
|
+
<div
|
|
626
|
+
className={cn(
|
|
627
|
+
'grid gap-x-4 gap-y-3 rounded-md bg-muted px-4 py-4',
|
|
628
|
+
'[&_[data-slot=input]]:bg-card [&_[data-slot=select-trigger]]:bg-card [&_[data-slot=input-number]]:bg-card [&_[data-slot=textarea]]:bg-card',
|
|
629
|
+
// 面板内表单控件统一全宽(仅作用于 FilterBarContent 子树)
|
|
630
|
+
'[&_[data-slot=input]]:w-full [&_[data-slot=input-group]]:w-full [&_[data-slot=input-number]]:w-full [&_[data-slot=input-ip]]:w-full [&_[data-slot=textarea]]:w-full',
|
|
631
|
+
'[&_[data-slot=select-trigger]]:w-full [&_[data-slot=cascader-select-trigger]]:w-full [&_[data-slot=tree-select-trigger]]:w-full',
|
|
632
|
+
'[&_[data-slot=date-picker]]:w-full [&_[data-slot=date-range-picker]]:w-full [&_[data-slot=time-picker]]:w-full [&_[data-slot=time-range-picker]]:w-full [&_[data-slot=mentions]]:w-full',
|
|
633
|
+
colClass,
|
|
634
|
+
)}
|
|
635
|
+
>
|
|
636
|
+
{children}
|
|
637
|
+
</div>
|
|
638
|
+
</CollapsibleContent>
|
|
639
|
+
</FilterBarSectionContext.Provider>
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// ─── FilterBarFooter ────────────────────────────────────────────────────────
|
|
644
|
+
|
|
645
|
+
export interface FilterBarActionsProps extends React.ComponentProps<'div'> {
|
|
646
|
+
/**
|
|
647
|
+
* 自定义按钮组(完全替换默认「重置 + 搜索」)。
|
|
648
|
+
* 不传时默认渲染重置与搜索两按钮。
|
|
649
|
+
*/
|
|
650
|
+
children?: React.ReactNode;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
function FilterBarActions({
|
|
654
|
+
className,
|
|
655
|
+
children,
|
|
656
|
+
...props
|
|
657
|
+
}: FilterBarActionsProps) {
|
|
658
|
+
const section = React.useContext(FilterBarSectionContext);
|
|
659
|
+
const { triggerFilter, triggerReset } = useFilterBar();
|
|
660
|
+
const inContent = section === 'content';
|
|
661
|
+
return (
|
|
662
|
+
<div
|
|
663
|
+
data-slot="filter-bar-actions"
|
|
664
|
+
className={cn(
|
|
665
|
+
'flex items-center justify-end gap-2',
|
|
666
|
+
inContent ? 'col-span-full' : 'shrink-0',
|
|
667
|
+
className,
|
|
668
|
+
)}
|
|
669
|
+
{...props}
|
|
670
|
+
>
|
|
671
|
+
{children ?? (
|
|
672
|
+
<>
|
|
673
|
+
<Button
|
|
674
|
+
type="button"
|
|
675
|
+
variant="outline"
|
|
676
|
+
style={{ minWidth: 60 }}
|
|
677
|
+
onClick={triggerReset}
|
|
678
|
+
>
|
|
679
|
+
重置
|
|
680
|
+
</Button>
|
|
681
|
+
<Button
|
|
682
|
+
type="button"
|
|
683
|
+
style={{ minWidth: 60 }}
|
|
684
|
+
onClick={triggerFilter}
|
|
685
|
+
>
|
|
686
|
+
搜索
|
|
687
|
+
</Button>
|
|
688
|
+
</>
|
|
689
|
+
)}
|
|
690
|
+
</div>
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
// ─── FilterBarField ─────────────────────────────────────────────────────────
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* children 模式下的 prop 桥接适配表(ADR 0037 v2.1)。
|
|
698
|
+
*
|
|
699
|
+
* 用 child element 的 `type.displayName || type.name` 识别身份,决定注入的 prop 形态。
|
|
700
|
+
* 不在表中的子元素退化为 `value` + `onChange` 默认对。
|
|
701
|
+
*/
|
|
702
|
+
function getControlBindings(
|
|
703
|
+
child: React.ReactElement,
|
|
704
|
+
field: ControllerRenderProps<FieldValues>,
|
|
705
|
+
): Record<string, unknown> {
|
|
706
|
+
const type = child.type as { displayName?: string; name?: string } | string;
|
|
707
|
+
const id =
|
|
708
|
+
typeof type === 'string' ? type : type?.displayName || type?.name || '';
|
|
709
|
+
|
|
710
|
+
// boolean 二态:checked + onCheckedChange
|
|
711
|
+
if (id === 'Checkbox' || id === 'Switch') {
|
|
712
|
+
return {
|
|
713
|
+
checked: field.value as boolean | undefined,
|
|
714
|
+
onCheckedChange: field.onChange,
|
|
715
|
+
name: field.name,
|
|
716
|
+
ref: field.ref,
|
|
717
|
+
onBlur: field.onBlur,
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
// value-by-value(Radix 风格 onValueChange)
|
|
722
|
+
if (
|
|
723
|
+
id === 'Select' ||
|
|
724
|
+
id === 'RadioGroup' ||
|
|
725
|
+
id === 'Slider' ||
|
|
726
|
+
id === 'ToggleGroup'
|
|
727
|
+
) {
|
|
728
|
+
return {
|
|
729
|
+
value: field.value,
|
|
730
|
+
onValueChange: field.onChange,
|
|
731
|
+
name: field.name,
|
|
732
|
+
ref: field.ref,
|
|
733
|
+
onBlur: field.onBlur,
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// 默认:value + event-style onChange(Input/Textarea/InputNumber/未知)
|
|
738
|
+
if (
|
|
739
|
+
process.env.NODE_ENV !== 'production' &&
|
|
740
|
+
id &&
|
|
741
|
+
!['Input', 'Textarea', 'InputNumber'].includes(id)
|
|
742
|
+
) {
|
|
743
|
+
// 兜底匹配但提示用户:未识别控件请考虑用 render prop
|
|
744
|
+
|
|
745
|
+
console.warn(
|
|
746
|
+
`[FilterBarField] 未识别的受控控件 (displayName=${id}),已默认注入 value + onChange。如行为不符,请改用 render prop。`,
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
return {
|
|
750
|
+
value: field.value,
|
|
751
|
+
onChange: field.onChange,
|
|
752
|
+
name: field.name,
|
|
753
|
+
ref: field.ref,
|
|
754
|
+
onBlur: field.onBlur,
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/** FilterBarField 布局模式(ADR 0037 v2.3)。 */
|
|
759
|
+
export type FilterBarFieldLayout =
|
|
760
|
+
| 'inline'
|
|
761
|
+
| 'outline'
|
|
762
|
+
| 'vertical'
|
|
763
|
+
| 'horizontal';
|
|
764
|
+
|
|
765
|
+
export interface FilterBarFieldProps<
|
|
766
|
+
TForm extends FieldValues = FieldValues,
|
|
767
|
+
TName extends FieldPath<TForm> = FieldPath<TForm>,
|
|
768
|
+
> {
|
|
769
|
+
/** RHF 字段名。 */
|
|
770
|
+
name: TName;
|
|
771
|
+
/** 字段标签。outline 模式必填(主视觉元素)。 */
|
|
772
|
+
label?: React.ReactNode;
|
|
773
|
+
/** 字段说明(仅 vertical / horizontal 布局显示)。 */
|
|
774
|
+
description?: React.ReactNode;
|
|
775
|
+
/** 容器自定义 className。 */
|
|
776
|
+
className?: string;
|
|
777
|
+
/**
|
|
778
|
+
* 布局模式。不传时按 section 推断:Header → `outline`;Content → `horizontal`。
|
|
779
|
+
*
|
|
780
|
+
* - `inline`:label 左外 + 控件横向(控件自带边框)
|
|
781
|
+
* - `outline`:label 嵌入外框内左侧(控件去边框)
|
|
782
|
+
* - `vertical`:label 上 + 控件下
|
|
783
|
+
* - `horizontal`:label 左外 + 控件右
|
|
784
|
+
*/
|
|
785
|
+
layout?: FilterBarFieldLayout;
|
|
786
|
+
/** 占用栅格列数(仅 Content section 生效)。 @default 1 */
|
|
787
|
+
colSpan?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
788
|
+
/** Header 形态(inline / outline)下控件最大宽度(px)。 @default 240 */
|
|
789
|
+
inlineMaxWidth?: number;
|
|
790
|
+
/** 显式指定 RHF control(默认从 FilterBar 上下文取)。 */
|
|
791
|
+
control?: Control<TForm>;
|
|
792
|
+
/**
|
|
793
|
+
* 静态 JSX 子元素(首选,AI 友好)。内部按子元素身份自动桥接 RHF field 到 `value`/`checked` + 对应 onChange。
|
|
794
|
+
* 适配 Input / Select / Checkbox / Switch / RadioGroup / Slider / Textarea;
|
|
795
|
+
* 不在适配表中的自定义控件请改用 `render` prop。
|
|
796
|
+
*/
|
|
797
|
+
children?: React.ReactElement;
|
|
798
|
+
/** 渲染输入控件(逆出舱,适配表不覆盖时使用)。 */
|
|
799
|
+
render?: (props: {
|
|
800
|
+
field: ControllerRenderProps<TForm, TName>;
|
|
801
|
+
fieldState: ControllerFieldState;
|
|
802
|
+
formState: UseFormStateReturn<TForm>;
|
|
803
|
+
}) => React.ReactElement;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* children 模式下的内部桥接组件:用 useController 拿 field,再 cloneElement 注入 prop。
|
|
808
|
+
* 必须在 FormProvider 子树内调用(FilterBar Root 已提供)。
|
|
809
|
+
*/
|
|
810
|
+
function FilterBarFieldChildBridge({
|
|
811
|
+
name,
|
|
812
|
+
control,
|
|
813
|
+
child,
|
|
814
|
+
}: {
|
|
815
|
+
name: string;
|
|
816
|
+
control?: Control<FieldValues>;
|
|
817
|
+
child: React.ReactElement;
|
|
818
|
+
}) {
|
|
819
|
+
const { field } = useController({ name, control });
|
|
820
|
+
return React.cloneElement(child, getControlBindings(child, field));
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
function FilterBarField<
|
|
824
|
+
TForm extends FieldValues = FieldValues,
|
|
825
|
+
TName extends FieldPath<TForm> = FieldPath<TForm>,
|
|
826
|
+
>({
|
|
827
|
+
name,
|
|
828
|
+
label,
|
|
829
|
+
description,
|
|
830
|
+
className,
|
|
831
|
+
layout: layoutProp,
|
|
832
|
+
colSpan = 1,
|
|
833
|
+
inlineMaxWidth = 240,
|
|
834
|
+
control,
|
|
835
|
+
children,
|
|
836
|
+
render,
|
|
837
|
+
}: FilterBarFieldProps<TForm, TName>) {
|
|
838
|
+
const { form } = useFilterBar();
|
|
839
|
+
const section = React.useContext(FilterBarSectionContext);
|
|
840
|
+
const ctrl = control ?? (form.control as unknown as Control<TForm>);
|
|
841
|
+
|
|
842
|
+
// 默认推断:Header → outline;Content → horizontal
|
|
843
|
+
const layout: FilterBarFieldLayout =
|
|
844
|
+
layoutProp ?? (section === 'header' ? 'outline' : 'horizontal');
|
|
845
|
+
const inHeader = section === 'header';
|
|
846
|
+
const colSpanClass = inHeader ? '' : COLSPAN[colSpan] ?? '';
|
|
847
|
+
const useMaxWidth = layout === 'inline' || layout === 'outline';
|
|
848
|
+
|
|
849
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
850
|
+
if (children && render) {
|
|
851
|
+
console.warn(
|
|
852
|
+
'[FilterBarField] children 与 render 同时传入,children 优先生效。',
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
if (layout === 'outline' && !label) {
|
|
856
|
+
console.warn(
|
|
857
|
+
`[FilterBarField name="${String(
|
|
858
|
+
name,
|
|
859
|
+
)}"] outline 布局下 label 为主视觉元素,必须传 label。`,
|
|
860
|
+
);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
// 控件渲染体:children(首选) > render(逆出舱)
|
|
865
|
+
let control$: React.ReactNode;
|
|
866
|
+
if (children) {
|
|
867
|
+
const only = React.Children.only(children) as React.ReactElement;
|
|
868
|
+
control$ = (
|
|
869
|
+
<FilterBarFieldChildBridge
|
|
870
|
+
name={name as string}
|
|
871
|
+
control={ctrl as unknown as Control<FieldValues>}
|
|
872
|
+
child={only}
|
|
873
|
+
/>
|
|
874
|
+
);
|
|
875
|
+
} else if (render) {
|
|
876
|
+
control$ = (
|
|
877
|
+
<Controller control={ctrl} name={name} render={(p) => render(p)} />
|
|
878
|
+
);
|
|
879
|
+
} else {
|
|
880
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
881
|
+
console.warn(
|
|
882
|
+
`[FilterBarField name="${String(
|
|
883
|
+
name,
|
|
884
|
+
)}"] 必须提供 children 或 render 之一。`,
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
control$ = null;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
const showDescription =
|
|
891
|
+
description && (layout === 'vertical' || layout === 'horizontal');
|
|
892
|
+
|
|
893
|
+
// outline → Field inset + FieldInsetBox(共享 INSET_INNER_RESET,覆盖所有控件)
|
|
894
|
+
if (layout === 'outline') {
|
|
895
|
+
return (
|
|
896
|
+
<Field
|
|
897
|
+
orientation="inset"
|
|
898
|
+
data-slot="filter-bar-field"
|
|
899
|
+
data-layout="outline"
|
|
900
|
+
className={cn(colSpanClass, className)}
|
|
901
|
+
style={useMaxWidth ? { maxWidth: inlineMaxWidth } : undefined}
|
|
902
|
+
>
|
|
903
|
+
<FieldInsetBox>
|
|
904
|
+
{label && <FieldLabel>{label}</FieldLabel>}
|
|
905
|
+
<div className="flex h-full min-w-0 flex-1 items-center">
|
|
906
|
+
{control$}
|
|
907
|
+
</div>
|
|
908
|
+
</FieldInsetBox>
|
|
909
|
+
</Field>
|
|
910
|
+
);
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
// vertical → Field vertical + FieldLabel + FieldDescription
|
|
914
|
+
if (layout === 'vertical') {
|
|
915
|
+
return (
|
|
916
|
+
<Field
|
|
917
|
+
orientation="vertical"
|
|
918
|
+
data-slot="filter-bar-field"
|
|
919
|
+
data-layout="vertical"
|
|
920
|
+
className={cn(colSpanClass, className)}
|
|
921
|
+
>
|
|
922
|
+
{label && <FieldLabel>{label}</FieldLabel>}
|
|
923
|
+
{control$}
|
|
924
|
+
{showDescription && <FieldDescription>{description}</FieldDescription>}
|
|
925
|
+
</Field>
|
|
926
|
+
);
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
// horizontal / inline → FieldLabel + FieldDescription(无对应 Field orientation)
|
|
930
|
+
return (
|
|
931
|
+
<div
|
|
932
|
+
data-slot="filter-bar-field"
|
|
933
|
+
data-layout={layout}
|
|
934
|
+
className={cn(
|
|
935
|
+
layout === 'inline'
|
|
936
|
+
? 'flex items-center gap-2'
|
|
937
|
+
: 'grid grid-cols-[1fr_3fr] items-center gap-4',
|
|
938
|
+
colSpanClass,
|
|
939
|
+
className,
|
|
940
|
+
)}
|
|
941
|
+
style={useMaxWidth ? { maxWidth: inlineMaxWidth } : undefined}
|
|
942
|
+
>
|
|
943
|
+
{label && (
|
|
944
|
+
<FieldLabel
|
|
945
|
+
className={cn(
|
|
946
|
+
'shrink-0',
|
|
947
|
+
layout === 'horizontal' && 'w-full justify-end',
|
|
948
|
+
)}
|
|
949
|
+
>
|
|
950
|
+
{label}
|
|
951
|
+
</FieldLabel>
|
|
952
|
+
)}
|
|
953
|
+
<div className="min-w-0">{control$}</div>
|
|
954
|
+
{showDescription && (
|
|
955
|
+
<FieldDescription className="col-start-2">
|
|
956
|
+
{description}
|
|
957
|
+
</FieldDescription>
|
|
958
|
+
)}
|
|
959
|
+
</div>
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// ─── Exports ────────────────────────────────────────────────────────────────
|
|
964
|
+
|
|
965
|
+
export {
|
|
966
|
+
FilterBar,
|
|
967
|
+
FilterBarHeader,
|
|
968
|
+
FilterBarSearch,
|
|
969
|
+
FilterBarSearchKey,
|
|
970
|
+
FilterBarSearchValue,
|
|
971
|
+
FilterBarSearchAction,
|
|
972
|
+
FilterBarTrigger,
|
|
973
|
+
FilterBarContent,
|
|
974
|
+
FilterBarActions,
|
|
975
|
+
FilterBarField,
|
|
976
|
+
};
|