@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,360 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 数字输入框 InputNumber
|
|
3
|
+
*
|
|
4
|
+
* 通过步进按钮、键盘或滚轮精确录入数值,支持范围夹紧、精度控制、自定义格式化与反解析。
|
|
5
|
+
*
|
|
6
|
+
* @when
|
|
7
|
+
* - 需要用户输入精确数值时(价格、数量、年龄、占比等)
|
|
8
|
+
* - 需要范围约束(min/max)与精度(precision)自动订正时
|
|
9
|
+
* - 需要步进按钮、键盘 ↑↓、滚轮等多种调值方式时
|
|
10
|
+
* - 需要展示百分号 / 千分位 / 货币等自定义格式时(formatter + parser)
|
|
11
|
+
* - 需要装饰位(前后缀图标、单位标签)时请改用 [InputGroup](../input-group/index.tsx) 或 [Field](../field/index.tsx)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import * as React from 'react';
|
|
15
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
16
|
+
import { ChevronDown, ChevronUp, Minus, Plus } from 'lucide-react';
|
|
17
|
+
|
|
18
|
+
import { cn } from '@/lib/utils';
|
|
19
|
+
|
|
20
|
+
// ─── Variants ───────────────────────────────────────────────────────────────
|
|
21
|
+
|
|
22
|
+
const inputNumberVariants = cva(
|
|
23
|
+
[
|
|
24
|
+
'inline-flex w-full min-w-0 items-stretch overflow-hidden rounded-md border border-input bg-transparent transition-colors',
|
|
25
|
+
'focus-within:border-ring focus-within:ring-1 focus-within:ring-ring',
|
|
26
|
+
'has-[input:disabled]:cursor-not-allowed has-[input:disabled]:bg-input/50 has-[input:disabled]:opacity-50',
|
|
27
|
+
'has-[input[aria-invalid=true]]:border-destructive has-[input[aria-invalid=true]]:ring-1 has-[input[aria-invalid=true]]:ring-destructive/20',
|
|
28
|
+
].join(' '),
|
|
29
|
+
{
|
|
30
|
+
variants: {
|
|
31
|
+
size: {
|
|
32
|
+
sm: 'h-6 text-xs',
|
|
33
|
+
default: 'h-8 text-xs',
|
|
34
|
+
lg: 'h-9 text-sm',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
defaultVariants: { size: 'default' },
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export type InputNumberSize = NonNullable<
|
|
42
|
+
VariantProps<typeof inputNumberVariants>['size']
|
|
43
|
+
>;
|
|
44
|
+
export type InputNumberVariant = 'default' | 'inline';
|
|
45
|
+
|
|
46
|
+
// ─── Props ──────────────────────────────────────────────────────────────────
|
|
47
|
+
|
|
48
|
+
export interface InputNumberProps
|
|
49
|
+
extends Omit<
|
|
50
|
+
React.InputHTMLAttributes<HTMLInputElement>,
|
|
51
|
+
| 'onChange'
|
|
52
|
+
| 'value'
|
|
53
|
+
| 'defaultValue'
|
|
54
|
+
| 'min'
|
|
55
|
+
| 'max'
|
|
56
|
+
| 'step'
|
|
57
|
+
| 'type'
|
|
58
|
+
| 'size'
|
|
59
|
+
> {
|
|
60
|
+
/** 形态。`default` 右侧叠加上下箭头;`inline` 两侧加减按钮。 @default default */
|
|
61
|
+
variant?: InputNumberVariant;
|
|
62
|
+
/** 尺寸。 @default default */
|
|
63
|
+
size?: InputNumberSize;
|
|
64
|
+
/** 受控值。`null` 等价空输入。 */
|
|
65
|
+
value?: number | string | null;
|
|
66
|
+
/** 非受控初值。 */
|
|
67
|
+
defaultValue?: number | string | null;
|
|
68
|
+
/** 大数/高精度字符串模式。开启后 value/onChange 使用 string。 @default false */
|
|
69
|
+
stringMode?: boolean;
|
|
70
|
+
/** 值变化回调,输入清空时传 `null`。 */
|
|
71
|
+
onChange?: (value: number | string | null) => void;
|
|
72
|
+
/** 最小值。 */
|
|
73
|
+
min?: number;
|
|
74
|
+
/** 最大值。 */
|
|
75
|
+
max?: number;
|
|
76
|
+
/** 步长。 @default 1 */
|
|
77
|
+
step?: number;
|
|
78
|
+
/** 数值精度(小数位数)。 */
|
|
79
|
+
precision?: number;
|
|
80
|
+
/** 是否渲染步进按钮。 @default true */
|
|
81
|
+
controls?: boolean;
|
|
82
|
+
/** 是否启用键盘 ↑↓ 步进。 @default true */
|
|
83
|
+
keyboard?: boolean;
|
|
84
|
+
/** 是否启用滚轮调整(仅在聚焦时生效)。 @default false */
|
|
85
|
+
changeOnWheel?: boolean;
|
|
86
|
+
/** 是否仅在 blur/Enter 时提交 onChange。关闭后输入即触发。 @default true */
|
|
87
|
+
changeOnBlur?: boolean;
|
|
88
|
+
/** 只读:可聚焦/复制但不可编辑、不可步进。 */
|
|
89
|
+
readOnly?: boolean;
|
|
90
|
+
/** 显示格式化器。返回值用于显示,不影响内部数值。 */
|
|
91
|
+
formatter?: (value: number | null) => string;
|
|
92
|
+
/** 输入文本反解析(清洗千分位、单位、百分号等),返回纯数字字符串。 */
|
|
93
|
+
parser?: (text: string) => string;
|
|
94
|
+
/** 回车提交回调,会先订正并 commit。 */
|
|
95
|
+
onPressEnter?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
99
|
+
|
|
100
|
+
function defaultFormat(raw: number | null, precision?: number): string {
|
|
101
|
+
if (raw === null || Number.isNaN(raw)) return '';
|
|
102
|
+
return precision !== undefined ? raw.toFixed(precision) : String(raw);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function defaultParse(raw: string): string {
|
|
106
|
+
// 保守清洗:保留数字、负号、小数点
|
|
107
|
+
return raw.replace(/[^\d.\-]/g, '');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function toNumber(v: number | string | null | undefined): number | null {
|
|
111
|
+
if (v === null || v === undefined || v === '') return null;
|
|
112
|
+
const n = typeof v === 'string' ? parseFloat(v) : v;
|
|
113
|
+
return Number.isNaN(n) ? null : n;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ─── InputNumber ────────────────────────────────────────────────────────────
|
|
117
|
+
|
|
118
|
+
const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>(
|
|
119
|
+
(
|
|
120
|
+
{
|
|
121
|
+
variant = 'default',
|
|
122
|
+
size = 'default',
|
|
123
|
+
value,
|
|
124
|
+
defaultValue,
|
|
125
|
+
stringMode = false,
|
|
126
|
+
onChange,
|
|
127
|
+
min,
|
|
128
|
+
max,
|
|
129
|
+
step = 1,
|
|
130
|
+
precision,
|
|
131
|
+
controls = true,
|
|
132
|
+
keyboard = true,
|
|
133
|
+
changeOnWheel = false,
|
|
134
|
+
changeOnBlur = true,
|
|
135
|
+
readOnly = false,
|
|
136
|
+
formatter,
|
|
137
|
+
parser,
|
|
138
|
+
disabled,
|
|
139
|
+
className,
|
|
140
|
+
onBlur,
|
|
141
|
+
onKeyDown,
|
|
142
|
+
onWheel,
|
|
143
|
+
onPressEnter,
|
|
144
|
+
...props
|
|
145
|
+
},
|
|
146
|
+
ref,
|
|
147
|
+
) => {
|
|
148
|
+
const isControlled = value !== undefined;
|
|
149
|
+
const [internal, setInternal] = React.useState<number | null>(
|
|
150
|
+
toNumber(defaultValue),
|
|
151
|
+
);
|
|
152
|
+
const current = isControlled ? toNumber(value) : internal;
|
|
153
|
+
const [editing, setEditing] = React.useState<string | null>(null);
|
|
154
|
+
|
|
155
|
+
const display =
|
|
156
|
+
editing !== null
|
|
157
|
+
? editing
|
|
158
|
+
: formatter
|
|
159
|
+
? formatter(current)
|
|
160
|
+
: defaultFormat(current, precision);
|
|
161
|
+
|
|
162
|
+
const clamp = React.useCallback(
|
|
163
|
+
(n: number): number => {
|
|
164
|
+
let v = n;
|
|
165
|
+
if (typeof min === 'number') v = Math.max(min, v);
|
|
166
|
+
if (typeof max === 'number') v = Math.min(max, v);
|
|
167
|
+
if (typeof precision === 'number') v = Number(v.toFixed(precision));
|
|
168
|
+
return v;
|
|
169
|
+
},
|
|
170
|
+
[min, max, precision],
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const commit = React.useCallback(
|
|
174
|
+
(next: number | null) => {
|
|
175
|
+
if (!isControlled) setInternal(next);
|
|
176
|
+
if (stringMode) {
|
|
177
|
+
onChange?.(next === null ? null : String(next));
|
|
178
|
+
} else {
|
|
179
|
+
onChange?.(next);
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
[isControlled, stringMode, onChange],
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
const parse = React.useCallback(
|
|
186
|
+
(raw: string): number | null => {
|
|
187
|
+
const cleaned = parser ? parser(raw) : defaultParse(raw);
|
|
188
|
+
if (cleaned === '' || cleaned === '-' || cleaned === '.') return null;
|
|
189
|
+
const n = Number(cleaned);
|
|
190
|
+
return Number.isNaN(n) ? null : n;
|
|
191
|
+
},
|
|
192
|
+
[parser],
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
const handleInput = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
196
|
+
const raw = e.target.value;
|
|
197
|
+
setEditing(raw);
|
|
198
|
+
if (!changeOnBlur) {
|
|
199
|
+
const parsed = parse(raw);
|
|
200
|
+
if (parsed !== null) commit(clamp(parsed));
|
|
201
|
+
else if (raw === '') commit(null);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
206
|
+
setEditing(null);
|
|
207
|
+
const raw = e.target.value;
|
|
208
|
+
if (raw === '') {
|
|
209
|
+
commit(null);
|
|
210
|
+
} else {
|
|
211
|
+
const parsed = parse(raw);
|
|
212
|
+
commit(parsed === null ? current : clamp(parsed));
|
|
213
|
+
}
|
|
214
|
+
onBlur?.(e);
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const stepBy = (sign: 1 | -1) => {
|
|
218
|
+
if (disabled || readOnly) return;
|
|
219
|
+
const base = current ?? 0;
|
|
220
|
+
commit(clamp(base + sign * step));
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
224
|
+
if (keyboard && (e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
|
|
225
|
+
e.preventDefault();
|
|
226
|
+
stepBy(e.key === 'ArrowUp' ? 1 : -1);
|
|
227
|
+
} else if (e.key === 'Enter') {
|
|
228
|
+
// 回车主动提交:把 editing 解析并订正
|
|
229
|
+
const raw = e.currentTarget.value;
|
|
230
|
+
setEditing(null);
|
|
231
|
+
if (raw === '') {
|
|
232
|
+
commit(null);
|
|
233
|
+
} else {
|
|
234
|
+
const parsed = parse(raw);
|
|
235
|
+
commit(parsed === null ? current : clamp(parsed));
|
|
236
|
+
}
|
|
237
|
+
onPressEnter?.(e);
|
|
238
|
+
}
|
|
239
|
+
onKeyDown?.(e);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const handleWheel = (e: React.WheelEvent<HTMLInputElement>) => {
|
|
243
|
+
if (
|
|
244
|
+
changeOnWheel &&
|
|
245
|
+
!disabled &&
|
|
246
|
+
!readOnly &&
|
|
247
|
+
document.activeElement === e.currentTarget
|
|
248
|
+
) {
|
|
249
|
+
e.preventDefault();
|
|
250
|
+
stepBy(e.deltaY < 0 ? 1 : -1);
|
|
251
|
+
}
|
|
252
|
+
onWheel?.(e);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const stepBtnClass =
|
|
256
|
+
'flex cursor-pointer items-center justify-center text-muted-foreground hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-muted-foreground';
|
|
257
|
+
|
|
258
|
+
const upDisabled =
|
|
259
|
+
disabled ||
|
|
260
|
+
readOnly ||
|
|
261
|
+
(typeof max === 'number' && (current ?? -Infinity) >= max);
|
|
262
|
+
const downDisabled =
|
|
263
|
+
disabled ||
|
|
264
|
+
readOnly ||
|
|
265
|
+
(typeof min === 'number' && (current ?? Infinity) <= min);
|
|
266
|
+
|
|
267
|
+
return (
|
|
268
|
+
<div
|
|
269
|
+
data-slot="input-number"
|
|
270
|
+
data-variant={variant}
|
|
271
|
+
data-size={size}
|
|
272
|
+
data-disabled={disabled ? '' : undefined}
|
|
273
|
+
data-readonly={readOnly ? '' : undefined}
|
|
274
|
+
className={cn(inputNumberVariants({ size }), className)}
|
|
275
|
+
>
|
|
276
|
+
{controls && variant === 'inline' ? (
|
|
277
|
+
<button
|
|
278
|
+
type="button"
|
|
279
|
+
tabIndex={-1}
|
|
280
|
+
disabled={downDisabled}
|
|
281
|
+
onClick={() => stepBy(-1)}
|
|
282
|
+
aria-label="减少"
|
|
283
|
+
data-slot="input-number-decrement"
|
|
284
|
+
className={cn(stepBtnClass, 'border-r border-input px-2')}
|
|
285
|
+
>
|
|
286
|
+
<Minus className="size-3.5" />
|
|
287
|
+
</button>
|
|
288
|
+
) : null}
|
|
289
|
+
<input
|
|
290
|
+
ref={ref}
|
|
291
|
+
type="text"
|
|
292
|
+
inputMode="decimal"
|
|
293
|
+
role="spinbutton"
|
|
294
|
+
aria-valuenow={current ?? undefined}
|
|
295
|
+
aria-valuemin={min}
|
|
296
|
+
aria-valuemax={max}
|
|
297
|
+
aria-readonly={readOnly || undefined}
|
|
298
|
+
value={display}
|
|
299
|
+
disabled={disabled}
|
|
300
|
+
readOnly={readOnly}
|
|
301
|
+
onChange={handleInput}
|
|
302
|
+
onBlur={handleBlur}
|
|
303
|
+
onKeyDown={handleKeyDown}
|
|
304
|
+
onWheel={handleWheel}
|
|
305
|
+
data-slot="input-number-control"
|
|
306
|
+
className={cn(
|
|
307
|
+
'w-full bg-transparent px-2.5 text-foreground placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed read-only:cursor-default',
|
|
308
|
+
variant === 'inline' && 'text-center',
|
|
309
|
+
)}
|
|
310
|
+
{...props}
|
|
311
|
+
/>
|
|
312
|
+
{controls && variant === 'inline' ? (
|
|
313
|
+
<button
|
|
314
|
+
type="button"
|
|
315
|
+
tabIndex={-1}
|
|
316
|
+
disabled={upDisabled}
|
|
317
|
+
onClick={() => stepBy(1)}
|
|
318
|
+
aria-label="增加"
|
|
319
|
+
data-slot="input-number-increment"
|
|
320
|
+
className={cn(stepBtnClass, 'border-l border-input px-2')}
|
|
321
|
+
>
|
|
322
|
+
<Plus className="size-3.5" />
|
|
323
|
+
</button>
|
|
324
|
+
) : null}
|
|
325
|
+
{controls && variant === 'default' ? (
|
|
326
|
+
<div
|
|
327
|
+
data-slot="input-number-handlers"
|
|
328
|
+
className="flex flex-col border-l border-input"
|
|
329
|
+
>
|
|
330
|
+
<button
|
|
331
|
+
type="button"
|
|
332
|
+
tabIndex={-1}
|
|
333
|
+
disabled={upDisabled}
|
|
334
|
+
onClick={() => stepBy(1)}
|
|
335
|
+
aria-label="增加"
|
|
336
|
+
data-slot="input-number-increment"
|
|
337
|
+
className={cn(stepBtnClass, 'h-1/2 px-1.5')}
|
|
338
|
+
>
|
|
339
|
+
<ChevronUp className="size-3.5" />
|
|
340
|
+
</button>
|
|
341
|
+
<button
|
|
342
|
+
type="button"
|
|
343
|
+
tabIndex={-1}
|
|
344
|
+
disabled={downDisabled}
|
|
345
|
+
onClick={() => stepBy(-1)}
|
|
346
|
+
aria-label="减少"
|
|
347
|
+
data-slot="input-number-decrement"
|
|
348
|
+
className={cn(stepBtnClass, 'h-1/2 border-t border-input px-1.5')}
|
|
349
|
+
>
|
|
350
|
+
<ChevronDown className="size-3.5" />
|
|
351
|
+
</button>
|
|
352
|
+
</div>
|
|
353
|
+
) : null}
|
|
354
|
+
</div>
|
|
355
|
+
);
|
|
356
|
+
},
|
|
357
|
+
);
|
|
358
|
+
InputNumber.displayName = 'InputNumber';
|
|
359
|
+
|
|
360
|
+
export { InputNumber, inputNumberVariants };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# InputNumber
|
|
2
|
+
|
|
3
|
+
> 本文件由 `pnpm gen:meta` 自动生成,**请勿手动编辑**。
|
|
4
|
+
|
|
5
|
+
## 描述
|
|
6
|
+
|
|
7
|
+
数字输入框 InputNumber
|
|
8
|
+
通过步进按钮、键盘或滚轮精确录入数值,支持范围夹紧、精度控制、自定义格式化与反解析。
|
|
9
|
+
|
|
10
|
+
## 使用场景
|
|
11
|
+
|
|
12
|
+
- 需要用户输入精确数值时(价格、数量、年龄、占比等)
|
|
13
|
+
- 需要范围约束(min/max)与精度(precision)自动订正时
|
|
14
|
+
- 需要步进按钮、键盘 ↑↓、滚轮等多种调值方式时
|
|
15
|
+
- 需要展示百分号 / 千分位 / 货币等自定义格式时(formatter + parser)
|
|
16
|
+
- 需要装饰位(前后缀图标、单位标签)时请改用 [InputGroup](../input-group/index.tsx) 或 [Field](../field/index.tsx)
|
|
17
|
+
|
|
18
|
+
## Props
|
|
19
|
+
|
|
20
|
+
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
21
|
+
| --- | --- | --- | --- | --- |
|
|
22
|
+
| `variant` | `InputNumberVariant` | `default` | – | 形态。`default` 右侧叠加上下箭头;`inline` 两侧加减按钮。 |
|
|
23
|
+
| `size` | `InputNumberSize` | `default` | – | 尺寸。 |
|
|
24
|
+
| `value` | `number \| string \| null` | – | – | 受控值。`null` 等价空输入。 |
|
|
25
|
+
| `defaultValue` | `number \| string \| null` | – | – | 非受控初值。 |
|
|
26
|
+
| `stringMode` | `boolean` | `false` | – | 大数/高精度字符串模式。开启后 value/onChange 使用 string。 |
|
|
27
|
+
| `onChange` | `(value: number \| string \| null) => void` | – | – | 值变化回调,输入清空时传 `null`。 |
|
|
28
|
+
| `min` | `number` | – | – | 最小值。 |
|
|
29
|
+
| `max` | `number` | – | – | 最大值。 |
|
|
30
|
+
| `step` | `number` | `1` | – | 步长。 |
|
|
31
|
+
| `precision` | `number` | – | – | 数值精度(小数位数)。 |
|
|
32
|
+
| `controls` | `boolean` | `true` | – | 是否渲染步进按钮。 |
|
|
33
|
+
| `keyboard` | `boolean` | `true` | – | 是否启用键盘 ↑↓ 步进。 |
|
|
34
|
+
| `changeOnWheel` | `boolean` | `false` | – | 是否启用滚轮调整(仅在聚焦时生效)。 |
|
|
35
|
+
| `changeOnBlur` | `boolean` | `true` | – | 是否仅在 blur/Enter 时提交 onChange。关闭后输入即触发。 |
|
|
36
|
+
| `readOnly` | `boolean` | – | – | 只读:可聚焦/复制但不可编辑、不可步进。 |
|
|
37
|
+
| `formatter` | `(value: number \| null) => string` | – | – | 显示格式化器。返回值用于显示,不影响内部数值。 |
|
|
38
|
+
| `parser` | `(text: string) => string` | – | – | 输入文本反解析(清洗千分位、单位、百分号等),返回纯数字字符串。 |
|
|
39
|
+
| `onPressEnter` | `(event: React.KeyboardEvent<HTMLInputElement>) => void` | – | – | 回车提交回调,会先订正并 commit。 |
|
|
40
|
+
|
|
41
|
+
## 示例
|
|
42
|
+
|
|
43
|
+
### Sizes
|
|
44
|
+
|
|
45
|
+
通过 `size` 控制尺寸,两种 `variant` 都支持。
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
<div className="flex flex-col gap-3">
|
|
49
|
+
<div className="flex items-center gap-3">
|
|
50
|
+
<InputNumber size="sm" placeholder="小" className="w-40" />
|
|
51
|
+
<InputNumber placeholder="中(默认)" className="w-40" />
|
|
52
|
+
<InputNumber size="lg" placeholder="大" className="w-40" />
|
|
53
|
+
</div>
|
|
54
|
+
<div className="flex items-center gap-3">
|
|
55
|
+
<InputNumber
|
|
56
|
+
size="sm"
|
|
57
|
+
variant="inline"
|
|
58
|
+
defaultValue={3}
|
|
59
|
+
className="w-32"
|
|
60
|
+
/>
|
|
61
|
+
<InputNumber variant="inline" defaultValue={3} className="w-32" />
|
|
62
|
+
<InputNumber
|
|
63
|
+
size="lg"
|
|
64
|
+
variant="inline"
|
|
65
|
+
defaultValue={3}
|
|
66
|
+
className="w-32"
|
|
67
|
+
/>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### MinMax
|
|
73
|
+
|
|
74
|
+
通过 `min` / `max` 限制输入范围,超出时自动夹紧;步进按钮在边界自动禁用。
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
<InputNumber min={0} max={100} defaultValue={50} className="w-40" />
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### StepPrecision
|
|
81
|
+
|
|
82
|
+
`step` 控制每次步进增量,`precision` 控制小数位。
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
<div className="flex flex-col gap-3">
|
|
86
|
+
<InputNumber
|
|
87
|
+
step={0.01}
|
|
88
|
+
precision={2}
|
|
89
|
+
defaultValue={1.0}
|
|
90
|
+
className="w-40"
|
|
91
|
+
/>
|
|
92
|
+
<InputNumber step={5} defaultValue={0} className="w-40" />
|
|
93
|
+
</div>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Formatter
|
|
97
|
+
|
|
98
|
+
`formatter` 自定义显示,`parser` 反解析输入文本。可表达百分号、千分位、货币等场景。
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
<div className="flex flex-col gap-3">
|
|
102
|
+
<InputNumber
|
|
103
|
+
defaultValue={85}
|
|
104
|
+
min={0}
|
|
105
|
+
max={100}
|
|
106
|
+
formatter={(v) => (v === null ? '' : `${v}%`)}
|
|
107
|
+
parser={(t) => t.replace(/%/g, '')}
|
|
108
|
+
className="w-40"
|
|
109
|
+
/>
|
|
110
|
+
<InputNumber
|
|
111
|
+
defaultValue={1234567.89}
|
|
112
|
+
precision={2}
|
|
113
|
+
formatter={(v) =>
|
|
114
|
+
v === null ? '' : new Intl.NumberFormat('en-US').format(v)
|
|
115
|
+
}
|
|
116
|
+
parser={(t) => t.replace(/,/g, '')}
|
|
117
|
+
className="w-48"
|
|
118
|
+
/>
|
|
119
|
+
<InputNumber
|
|
120
|
+
defaultValue={2999}
|
|
121
|
+
formatter={(v) => (v === null ? '' : `¥ ${v}`)}
|
|
122
|
+
parser={(t) => t.replace(/[^\d.\-]/g, '')}
|
|
123
|
+
className="w-40"
|
|
124
|
+
/>
|
|
125
|
+
</div>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Inline
|
|
129
|
+
|
|
130
|
+
`variant="inline"` 两侧加减按钮,适合紧凑场景。
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
<InputNumber
|
|
134
|
+
variant="inline"
|
|
135
|
+
min={1}
|
|
136
|
+
max={10}
|
|
137
|
+
defaultValue={3}
|
|
138
|
+
className="w-32"
|
|
139
|
+
/>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### NoControls
|
|
143
|
+
|
|
144
|
+
设置 `controls={false}` 隐藏步进按钮,键盘 ↑↓ 仍可用。
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
<InputNumber controls={false} placeholder="纯输入" className="w-40" />
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Keyboard
|
|
151
|
+
|
|
152
|
+
`keyboard={false}` 关闭键盘 ↑↓ 步进。
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
<InputNumber keyboard={false} defaultValue={0} className="w-40" />
|
|
156
|
+
```
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { InputNumber } from './index';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof InputNumber> = {
|
|
6
|
+
title: '数据录入 · Data Entry/InputNumber 数字输入框',
|
|
7
|
+
component: InputNumber,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
parameters: {
|
|
10
|
+
docs: { source: { type: 'dynamic' } },
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
|
|
15
|
+
type Story = StoryObj<typeof meta>;
|
|
16
|
+
|
|
17
|
+
export const Default: Story = {
|
|
18
|
+
render: () => <InputNumber placeholder="请输入数字" className="w-40" />,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** 通过 `size` 控制尺寸,两种 `variant` 都支持。 */
|
|
22
|
+
export const Sizes: Story = {
|
|
23
|
+
render: () => (
|
|
24
|
+
<div className="flex flex-col gap-3">
|
|
25
|
+
<div className="flex items-center gap-3">
|
|
26
|
+
<InputNumber size="sm" placeholder="小" className="w-40" />
|
|
27
|
+
<InputNumber placeholder="中(默认)" className="w-40" />
|
|
28
|
+
<InputNumber size="lg" placeholder="大" className="w-40" />
|
|
29
|
+
</div>
|
|
30
|
+
<div className="flex items-center gap-3">
|
|
31
|
+
<InputNumber
|
|
32
|
+
size="sm"
|
|
33
|
+
variant="inline"
|
|
34
|
+
defaultValue={3}
|
|
35
|
+
className="w-32"
|
|
36
|
+
/>
|
|
37
|
+
<InputNumber variant="inline" defaultValue={3} className="w-32" />
|
|
38
|
+
<InputNumber
|
|
39
|
+
size="lg"
|
|
40
|
+
variant="inline"
|
|
41
|
+
defaultValue={3}
|
|
42
|
+
className="w-32"
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** 通过 `min` / `max` 限制输入范围,超出时自动夹紧;步进按钮在边界自动禁用。 */
|
|
50
|
+
export const MinMax: Story = {
|
|
51
|
+
render: () => (
|
|
52
|
+
<InputNumber min={0} max={100} defaultValue={50} className="w-40" />
|
|
53
|
+
),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/** `step` 控制每次步进增量,`precision` 控制小数位。 */
|
|
57
|
+
export const StepPrecision: Story = {
|
|
58
|
+
render: () => (
|
|
59
|
+
<div className="flex flex-col gap-3">
|
|
60
|
+
<InputNumber
|
|
61
|
+
step={0.01}
|
|
62
|
+
precision={2}
|
|
63
|
+
defaultValue={1.0}
|
|
64
|
+
className="w-40"
|
|
65
|
+
/>
|
|
66
|
+
<InputNumber step={5} defaultValue={0} className="w-40" />
|
|
67
|
+
</div>
|
|
68
|
+
),
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** `formatter` 自定义显示,`parser` 反解析输入文本。可表达百分号、千分位、货币等场景。 */
|
|
72
|
+
export const Formatter: Story = {
|
|
73
|
+
render: () => (
|
|
74
|
+
<div className="flex flex-col gap-3">
|
|
75
|
+
<InputNumber
|
|
76
|
+
defaultValue={85}
|
|
77
|
+
min={0}
|
|
78
|
+
max={100}
|
|
79
|
+
formatter={(v) => (v === null ? '' : `${v}%`)}
|
|
80
|
+
parser={(t) => t.replace(/%/g, '')}
|
|
81
|
+
className="w-40"
|
|
82
|
+
/>
|
|
83
|
+
<InputNumber
|
|
84
|
+
defaultValue={1234567.89}
|
|
85
|
+
precision={2}
|
|
86
|
+
formatter={(v) =>
|
|
87
|
+
v === null ? '' : new Intl.NumberFormat('en-US').format(v)
|
|
88
|
+
}
|
|
89
|
+
parser={(t) => t.replace(/,/g, '')}
|
|
90
|
+
className="w-48"
|
|
91
|
+
/>
|
|
92
|
+
<InputNumber
|
|
93
|
+
defaultValue={2999}
|
|
94
|
+
formatter={(v) => (v === null ? '' : `¥ ${v}`)}
|
|
95
|
+
parser={(t) => t.replace(/[^\d.\-]/g, '')}
|
|
96
|
+
className="w-40"
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
),
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/** `readOnly` 只读:可聚焦/复制但不可编辑、不可步进。 */
|
|
103
|
+
export const ReadOnly: Story = {
|
|
104
|
+
render: () => <InputNumber readOnly defaultValue={42} className="w-40" />,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** `variant="inline"` 两侧加减按钮,适合紧凑场景。 */
|
|
108
|
+
export const Inline: Story = {
|
|
109
|
+
render: () => (
|
|
110
|
+
<InputNumber
|
|
111
|
+
variant="inline"
|
|
112
|
+
min={1}
|
|
113
|
+
max={10}
|
|
114
|
+
defaultValue={3}
|
|
115
|
+
className="w-32"
|
|
116
|
+
/>
|
|
117
|
+
),
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/** 设置 `controls={false}` 隐藏步进按钮,键盘 ↑↓ 仍可用。 */
|
|
121
|
+
export const NoControls: Story = {
|
|
122
|
+
render: () => (
|
|
123
|
+
<InputNumber controls={false} placeholder="纯输入" className="w-40" />
|
|
124
|
+
),
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/** `changeOnBlur={false}` 让 onChange 在每次有效输入时触发,否则仅 blur/Enter 提交。 */
|
|
128
|
+
export const ChangeOnBlur: Story = {
|
|
129
|
+
render: function ChangeOnBlurDemo() {
|
|
130
|
+
const [a, setA] = useState<number | string | null>(0);
|
|
131
|
+
const [b, setB] = useState<number | string | null>(0);
|
|
132
|
+
return (
|
|
133
|
+
<div className="flex flex-col gap-3 text-xs">
|
|
134
|
+
<div className="flex items-center gap-3">
|
|
135
|
+
<InputNumber value={a} onChange={setA} className="w-40" />
|
|
136
|
+
<span className="text-muted-foreground">
|
|
137
|
+
默认(仅 blur/Enter 触发):{String(a)}
|
|
138
|
+
</span>
|
|
139
|
+
</div>
|
|
140
|
+
<div className="flex items-center gap-3">
|
|
141
|
+
<InputNumber
|
|
142
|
+
value={b}
|
|
143
|
+
onChange={setB}
|
|
144
|
+
changeOnBlur={false}
|
|
145
|
+
className="w-40"
|
|
146
|
+
/>
|
|
147
|
+
<span className="text-muted-foreground">实时触发:{String(b)}</span>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
);
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/** `changeOnWheel` 启用滚轮调整(仅在聚焦时生效,默认关闭防误触)。 */
|
|
155
|
+
export const ChangeOnWheel: Story = {
|
|
156
|
+
render: () => <InputNumber changeOnWheel defaultValue={0} className="w-40" />,
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/** `keyboard={false}` 关闭键盘 ↑↓ 步进。 */
|
|
160
|
+
export const Keyboard: Story = {
|
|
161
|
+
render: () => (
|
|
162
|
+
<InputNumber keyboard={false} defaultValue={0} className="w-40" />
|
|
163
|
+
),
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/** `aria-invalid` 视觉与 Input 一致。 */
|
|
167
|
+
export const Invalid: Story = {
|
|
168
|
+
render: () => <InputNumber aria-invalid defaultValue={42} className="w-40" />,
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/** 禁用状态。 */
|
|
172
|
+
export const Disabled: Story = {
|
|
173
|
+
render: () => <InputNumber disabled defaultValue={42} className="w-40" />,
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/** 受控模式。 */
|
|
177
|
+
export const Controlled: Story = {
|
|
178
|
+
render: function ControlledDemo() {
|
|
179
|
+
const [val, setVal] = useState<number | string | null>(10);
|
|
180
|
+
return (
|
|
181
|
+
<div className="flex items-center gap-3">
|
|
182
|
+
<InputNumber value={val} onChange={setVal} className="w-40" />
|
|
183
|
+
<span className="text-xs text-muted-foreground">值: {String(val)}</span>
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
},
|
|
187
|
+
};
|