@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,258 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { Loader2Icon, MailIcon, SearchIcon } from 'lucide-react';
|
|
4
|
+
import {
|
|
5
|
+
InputGroup,
|
|
6
|
+
InputGroupAddon,
|
|
7
|
+
InputGroupClear,
|
|
8
|
+
InputGroupInput,
|
|
9
|
+
InputGroupPasswordToggle,
|
|
10
|
+
InputGroupShowCount,
|
|
11
|
+
InputGroupText,
|
|
12
|
+
InputGroupTextarea,
|
|
13
|
+
} from './index';
|
|
14
|
+
|
|
15
|
+
const meta: Meta<typeof InputGroup> = {
|
|
16
|
+
title: '数据录入 · Data Entry/InputGroup 输入框组合',
|
|
17
|
+
component: InputGroup,
|
|
18
|
+
tags: ['autodocs'],
|
|
19
|
+
parameters: {
|
|
20
|
+
docs: {
|
|
21
|
+
description: {
|
|
22
|
+
component:
|
|
23
|
+
'复合输入容器:通过 `InputGroupAddon` + `InputGroupInput | InputGroupTextarea` 自由组合图标 / 按钮 / 文本插槽。配套 helper 原子 `InputGroupClear` / `InputGroupPasswordToggle` / `InputGroupShowCount` 覆盖清除、密码切换、字符计数高频场景。',
|
|
24
|
+
},
|
|
25
|
+
source: { type: 'dynamic' },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export default meta;
|
|
30
|
+
|
|
31
|
+
type Story = StoryObj<typeof meta>;
|
|
32
|
+
|
|
33
|
+
/** 前置图标插槽,聚焦时整体高亮。 */
|
|
34
|
+
export const WithLeadingIcon: Story = {
|
|
35
|
+
render: () => (
|
|
36
|
+
<InputGroup className="w-64">
|
|
37
|
+
<InputGroupAddon>
|
|
38
|
+
<InputGroupText>
|
|
39
|
+
<SearchIcon />
|
|
40
|
+
</InputGroupText>
|
|
41
|
+
</InputGroupAddon>
|
|
42
|
+
<InputGroupInput placeholder="搜索..." />
|
|
43
|
+
</InputGroup>
|
|
44
|
+
),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 搜索场景:左侧 SearchIcon + 右侧 InputGroupClear 受控清除按钮。
|
|
49
|
+
* 仅当 value 非空时显示清除按钮。
|
|
50
|
+
*/
|
|
51
|
+
export const Search: Story = {
|
|
52
|
+
render: function SearchStory() {
|
|
53
|
+
const [value, setValue] = useState('');
|
|
54
|
+
return (
|
|
55
|
+
<InputGroup className="w-64">
|
|
56
|
+
<InputGroupAddon>
|
|
57
|
+
<InputGroupText>
|
|
58
|
+
<SearchIcon />
|
|
59
|
+
</InputGroupText>
|
|
60
|
+
</InputGroupAddon>
|
|
61
|
+
<InputGroupInput
|
|
62
|
+
placeholder="搜索..."
|
|
63
|
+
value={value}
|
|
64
|
+
onChange={(e) => setValue(e.target.value)}
|
|
65
|
+
/>
|
|
66
|
+
<InputGroupAddon align="inline-end">
|
|
67
|
+
<InputGroupClear
|
|
68
|
+
visible={value.length > 0}
|
|
69
|
+
onClick={() => setValue('')}
|
|
70
|
+
/>
|
|
71
|
+
</InputGroupAddon>
|
|
72
|
+
</InputGroup>
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 一键清除:使用 `InputGroupClear` helper 受控显示清除按钮,
|
|
79
|
+
* 仅当 `visible` 为 true 时渲染,点击由父级清空 `value`。
|
|
80
|
+
*/
|
|
81
|
+
export const Clear: Story = {
|
|
82
|
+
render: function ClearStory() {
|
|
83
|
+
const [value, setValue] = useState('hello world');
|
|
84
|
+
return (
|
|
85
|
+
<InputGroup className="w-64">
|
|
86
|
+
<InputGroupInput
|
|
87
|
+
placeholder="输入后展示清除按钮"
|
|
88
|
+
value={value}
|
|
89
|
+
onChange={(e) => setValue(e.target.value)}
|
|
90
|
+
/>
|
|
91
|
+
<InputGroupAddon align="inline-end">
|
|
92
|
+
<InputGroupClear
|
|
93
|
+
visible={value.length > 0}
|
|
94
|
+
onClick={() => setValue('')}
|
|
95
|
+
/>
|
|
96
|
+
</InputGroupAddon>
|
|
97
|
+
</InputGroup>
|
|
98
|
+
);
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 密码输入:使用 `InputGroupPasswordToggle` 受控版,由父级同时控制 `type` 与 `visible`。
|
|
104
|
+
*/
|
|
105
|
+
export const Password: Story = {
|
|
106
|
+
render: function PasswordStory() {
|
|
107
|
+
const [visible, setVisible] = useState(false);
|
|
108
|
+
return (
|
|
109
|
+
<InputGroup className="w-64">
|
|
110
|
+
<InputGroupInput
|
|
111
|
+
type={visible ? 'text' : 'password'}
|
|
112
|
+
placeholder="请输入密码"
|
|
113
|
+
/>
|
|
114
|
+
<InputGroupAddon align="inline-end">
|
|
115
|
+
<InputGroupPasswordToggle
|
|
116
|
+
visible={visible}
|
|
117
|
+
onVisibleChange={setVisible}
|
|
118
|
+
/>
|
|
119
|
+
</InputGroupAddon>
|
|
120
|
+
</InputGroup>
|
|
121
|
+
);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/** 金额输入:后置货币符号,展示带格式化的数值输入。 */
|
|
126
|
+
export const Currency: Story = {
|
|
127
|
+
render: function CurrencyStory() {
|
|
128
|
+
const [value, setValue] = useState('1234.56');
|
|
129
|
+
const format = (v: string) => {
|
|
130
|
+
const num = parseFloat(v.replace(/,/g, ''));
|
|
131
|
+
if (isNaN(num)) return v;
|
|
132
|
+
return num.toLocaleString('en-US', {
|
|
133
|
+
minimumFractionDigits: 2,
|
|
134
|
+
maximumFractionDigits: 2,
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
return (
|
|
138
|
+
<InputGroup className="w-64">
|
|
139
|
+
<InputGroupInput
|
|
140
|
+
placeholder="请输入金额"
|
|
141
|
+
value={format(value)}
|
|
142
|
+
onChange={(e) => setValue(e.target.value.replace(/,/g, ''))}
|
|
143
|
+
/>
|
|
144
|
+
<InputGroupAddon align="inline-end">
|
|
145
|
+
<InputGroupText>¥</InputGroupText>
|
|
146
|
+
</InputGroupAddon>
|
|
147
|
+
</InputGroup>
|
|
148
|
+
);
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** 邮箱输入:左侧邮件图标 + 右侧域名后缀文本。 */
|
|
153
|
+
export const Email: Story = {
|
|
154
|
+
render: () => (
|
|
155
|
+
<InputGroup className="w-80">
|
|
156
|
+
<InputGroupAddon>
|
|
157
|
+
<InputGroupText>
|
|
158
|
+
<MailIcon />
|
|
159
|
+
</InputGroupText>
|
|
160
|
+
</InputGroupAddon>
|
|
161
|
+
<InputGroupInput placeholder="username" />
|
|
162
|
+
<InputGroupAddon align="inline-end">
|
|
163
|
+
<InputGroupText>@example.com</InputGroupText>
|
|
164
|
+
</InputGroupAddon>
|
|
165
|
+
</InputGroup>
|
|
166
|
+
),
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/** 校验中:右侧旋转 loading 图标,对齐 cloud-design `state="loading"`。 */
|
|
170
|
+
export const Loading: Story = {
|
|
171
|
+
render: () => (
|
|
172
|
+
<InputGroup className="w-64">
|
|
173
|
+
<InputGroupInput placeholder="校验中..." defaultValue="abc@" />
|
|
174
|
+
<InputGroupAddon align="inline-end">
|
|
175
|
+
<InputGroupText>
|
|
176
|
+
<Loader2Icon className="animate-spin" />
|
|
177
|
+
</InputGroupText>
|
|
178
|
+
</InputGroupAddon>
|
|
179
|
+
</InputGroup>
|
|
180
|
+
),
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* 单行字符计数:使用 `InputGroupShowCount` 显示 `current/max`。
|
|
185
|
+
* 超过 maxLength 时计数自动转 destructive 色。
|
|
186
|
+
*/
|
|
187
|
+
export const WithCount: Story = {
|
|
188
|
+
render: function WithCountStory() {
|
|
189
|
+
const [value, setValue] = useState('');
|
|
190
|
+
const max = 20;
|
|
191
|
+
return (
|
|
192
|
+
<InputGroup className="w-80">
|
|
193
|
+
<InputGroupInput
|
|
194
|
+
placeholder="请输入标题"
|
|
195
|
+
value={value}
|
|
196
|
+
onChange={(e) => setValue(e.target.value)}
|
|
197
|
+
maxLength={max}
|
|
198
|
+
/>
|
|
199
|
+
<InputGroupAddon align="inline-end">
|
|
200
|
+
<InputGroupShowCount current={value.length} max={max} />
|
|
201
|
+
</InputGroupAddon>
|
|
202
|
+
</InputGroup>
|
|
203
|
+
);
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 多行 + 字符计数:textarea 配合 `block-end` 对齐的计数行,
|
|
209
|
+
* 对齐 cloud-design `hasLimitHint` 的视觉位置。
|
|
210
|
+
*/
|
|
211
|
+
export const MultilineWithCount: Story = {
|
|
212
|
+
render: function MultilineWithCountStory() {
|
|
213
|
+
const [value, setValue] = useState('');
|
|
214
|
+
const max = 100;
|
|
215
|
+
return (
|
|
216
|
+
<InputGroup className="w-80">
|
|
217
|
+
<InputGroupTextarea
|
|
218
|
+
placeholder="请输入备注..."
|
|
219
|
+
value={value}
|
|
220
|
+
onChange={(e) => setValue(e.target.value)}
|
|
221
|
+
rows={4}
|
|
222
|
+
className="field-sizing-fixed"
|
|
223
|
+
/>
|
|
224
|
+
<InputGroupAddon align="block-end" className="justify-end">
|
|
225
|
+
<InputGroupShowCount current={value.length} max={max} />
|
|
226
|
+
</InputGroupAddon>
|
|
227
|
+
</InputGroup>
|
|
228
|
+
);
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
/** 禁用状态的输入框组合。 */
|
|
233
|
+
export const Disabled: Story = {
|
|
234
|
+
render: () => (
|
|
235
|
+
<InputGroup className="w-64">
|
|
236
|
+
<InputGroupAddon>
|
|
237
|
+
<InputGroupText>
|
|
238
|
+
<SearchIcon />
|
|
239
|
+
</InputGroupText>
|
|
240
|
+
</InputGroupAddon>
|
|
241
|
+
<InputGroupInput placeholder="不可编辑" disabled />
|
|
242
|
+
</InputGroup>
|
|
243
|
+
),
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
/** 错误态:内部 `InputGroupInput` 透传 `aria-invalid`,整体边框转 destructive 色。 */
|
|
247
|
+
export const Invalid: Story = {
|
|
248
|
+
render: () => (
|
|
249
|
+
<InputGroup className="w-64">
|
|
250
|
+
<InputGroupAddon>
|
|
251
|
+
<InputGroupText>
|
|
252
|
+
<MailIcon />
|
|
253
|
+
</InputGroupText>
|
|
254
|
+
</InputGroupAddon>
|
|
255
|
+
<InputGroupInput placeholder="请输入邮箱" aria-invalid="true" />
|
|
256
|
+
</InputGroup>
|
|
257
|
+
),
|
|
258
|
+
};
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IP 地址输入框 InputIP
|
|
3
|
+
*
|
|
4
|
+
* 分段式 IPv4 地址输入,支持自动跳段、范围校验和可选 CIDR 掩码选择。
|
|
5
|
+
*
|
|
6
|
+
* @when
|
|
7
|
+
* - 需要用户输入 IPv4 地址时
|
|
8
|
+
* - 需要带 CIDR 前缀长度的网段输入时(如 192.168.1.0/24)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
13
|
+
|
|
14
|
+
import { cn } from '@/lib/utils';
|
|
15
|
+
import {
|
|
16
|
+
Select,
|
|
17
|
+
SelectContent,
|
|
18
|
+
SelectItem,
|
|
19
|
+
SelectTrigger,
|
|
20
|
+
SelectValue,
|
|
21
|
+
} from '@/components/select';
|
|
22
|
+
|
|
23
|
+
// ─── Variants ───────────────────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
const inputIpVariants = cva(
|
|
26
|
+
[
|
|
27
|
+
// `w-fit` 显式锁定“宽度 = 内容”,避免被 flex/grid 父容器 cross-axis stretch 拉满。
|
|
28
|
+
// 消费方需要铺满父容器时,可通过 className="w-full" 覆盖。
|
|
29
|
+
'inline-flex w-fit items-center rounded-md border border-input bg-transparent transition-colors',
|
|
30
|
+
'focus-within:border-ring focus-within:ring-1 focus-within:ring-ring',
|
|
31
|
+
'aria-[invalid=true]:border-destructive aria-[invalid=true]:ring-1 aria-[invalid=true]:ring-destructive/20',
|
|
32
|
+
].join(' '),
|
|
33
|
+
{
|
|
34
|
+
variants: {
|
|
35
|
+
size: {
|
|
36
|
+
sm: 'h-6 text-xs',
|
|
37
|
+
default: 'h-8 text-xs',
|
|
38
|
+
lg: 'h-9 text-sm',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: { size: 'default' },
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export type InputIPSize = NonNullable<
|
|
46
|
+
VariantProps<typeof inputIpVariants>['size']
|
|
47
|
+
>;
|
|
48
|
+
|
|
49
|
+
export interface InputIPProps
|
|
50
|
+
extends Omit<
|
|
51
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
52
|
+
'onChange' | 'defaultValue'
|
|
53
|
+
> {
|
|
54
|
+
/** 尺寸。 @default "default" */
|
|
55
|
+
size?: InputIPSize;
|
|
56
|
+
/** 受控值,格式 "x.x.x.x" 或 "x.x.x.x/prefix"。 */
|
|
57
|
+
value?: string;
|
|
58
|
+
/** 非受控初值。 */
|
|
59
|
+
defaultValue?: string;
|
|
60
|
+
/** 值变化回调。 */
|
|
61
|
+
onChange?: (value: string) => void;
|
|
62
|
+
/** 是否显示 CIDR 前缀选择。 @default false */
|
|
63
|
+
showCidr?: boolean;
|
|
64
|
+
/** CIDR 前缀可选范围。 @default [0..32] */
|
|
65
|
+
cidrOptions?: number[];
|
|
66
|
+
/** 禁用态。 @default false */
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
/** placeholder,按段用 "." 分隔。 @default "0.0.0.0" */
|
|
69
|
+
placeholder?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function parseIp(val: string | undefined): { octets: string[]; cidr: string } {
|
|
73
|
+
if (!val) return { octets: ['', '', '', ''], cidr: '' };
|
|
74
|
+
const parts = val.split('/');
|
|
75
|
+
const ip = parts[0] || '';
|
|
76
|
+
const cidr = parts[1] ?? '';
|
|
77
|
+
const segs = ip.split('.');
|
|
78
|
+
return {
|
|
79
|
+
octets: [segs[0] ?? '', segs[1] ?? '', segs[2] ?? '', segs[3] ?? ''],
|
|
80
|
+
cidr,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function clampOctet(val: string): string {
|
|
85
|
+
if (val === '') return '';
|
|
86
|
+
const num = parseInt(val, 10);
|
|
87
|
+
if (isNaN(num)) return '';
|
|
88
|
+
return String(Math.min(255, Math.max(0, num)));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const DEFAULT_CIDR_OPTIONS = Array.from({ length: 33 }, (_, i) => i);
|
|
92
|
+
|
|
93
|
+
const InputIP = React.forwardRef<HTMLDivElement, InputIPProps>(
|
|
94
|
+
(
|
|
95
|
+
{
|
|
96
|
+
className,
|
|
97
|
+
size = 'default',
|
|
98
|
+
value: controlledValue,
|
|
99
|
+
defaultValue,
|
|
100
|
+
onChange,
|
|
101
|
+
showCidr = false,
|
|
102
|
+
cidrOptions = DEFAULT_CIDR_OPTIONS,
|
|
103
|
+
disabled = false,
|
|
104
|
+
placeholder = '0.0.0.0',
|
|
105
|
+
'aria-invalid': ariaInvalid,
|
|
106
|
+
...props
|
|
107
|
+
},
|
|
108
|
+
ref,
|
|
109
|
+
) => {
|
|
110
|
+
const isControlled = controlledValue !== undefined;
|
|
111
|
+
const parsed = parseIp(isControlled ? controlledValue : undefined);
|
|
112
|
+
const [internalOctets, setInternalOctets] = React.useState<string[]>(
|
|
113
|
+
() => parseIp(defaultValue).octets,
|
|
114
|
+
);
|
|
115
|
+
const [internalCidr, setInternalCidr] = React.useState<string>(
|
|
116
|
+
() => parseIp(defaultValue).cidr,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const octets = isControlled ? parsed.octets : internalOctets;
|
|
120
|
+
const cidr = isControlled ? parsed.cidr : internalCidr;
|
|
121
|
+
|
|
122
|
+
const inputRefs = React.useRef<(HTMLInputElement | null)[]>([]);
|
|
123
|
+
const placeholderParts = placeholder.split('.');
|
|
124
|
+
|
|
125
|
+
function emitChange(newOctets: string[], newCidr: string) {
|
|
126
|
+
const ip = newOctets.join('.');
|
|
127
|
+
const full = showCidr && newCidr ? `${ip}/${newCidr}` : ip;
|
|
128
|
+
onChange?.(full);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function handleOctetChange(index: number, rawValue: string) {
|
|
132
|
+
const numeric = rawValue.replace(/[^0-9]/g, '').slice(0, 3);
|
|
133
|
+
const clamped = clampOctet(numeric);
|
|
134
|
+
const next = [...octets];
|
|
135
|
+
next[index] = clamped;
|
|
136
|
+
|
|
137
|
+
if (!isControlled) setInternalOctets(next);
|
|
138
|
+
emitChange(next, cidr);
|
|
139
|
+
|
|
140
|
+
if (
|
|
141
|
+
clamped.length === 3 ||
|
|
142
|
+
(clamped.length > 0 && parseInt(clamped, 10) > 25)
|
|
143
|
+
) {
|
|
144
|
+
if (index < 3) {
|
|
145
|
+
inputRefs.current[index + 1]?.focus();
|
|
146
|
+
inputRefs.current[index + 1]?.select();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function handleKeyDown(index: number, e: React.KeyboardEvent) {
|
|
152
|
+
const currentValue = octets[index] ?? '';
|
|
153
|
+
if (e.key === '.' || e.key === 'ArrowRight') {
|
|
154
|
+
if (
|
|
155
|
+
e.key === '.' ||
|
|
156
|
+
(e.key === 'ArrowRight' &&
|
|
157
|
+
(e.currentTarget as HTMLInputElement).selectionStart ===
|
|
158
|
+
currentValue.length)
|
|
159
|
+
) {
|
|
160
|
+
if (index < 3) {
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
inputRefs.current[index + 1]?.focus();
|
|
163
|
+
inputRefs.current[index + 1]?.select();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
} else if (e.key === 'ArrowLeft') {
|
|
167
|
+
if (
|
|
168
|
+
(e.currentTarget as HTMLInputElement).selectionStart === 0 &&
|
|
169
|
+
index > 0
|
|
170
|
+
) {
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
inputRefs.current[index - 1]?.focus();
|
|
173
|
+
}
|
|
174
|
+
} else if (e.key === 'Backspace') {
|
|
175
|
+
if (currentValue === '' && index > 0) {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
inputRefs.current[index - 1]?.focus();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function handleCidrChange(newCidr: string) {
|
|
183
|
+
if (!isControlled) setInternalCidr(newCidr);
|
|
184
|
+
emitChange(octets, newCidr);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function handlePaste(e: React.ClipboardEvent) {
|
|
188
|
+
const text = e.clipboardData.getData('text').trim();
|
|
189
|
+
const ipMatch = text.match(
|
|
190
|
+
/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(?:\/(\d{1,2}))?$/,
|
|
191
|
+
);
|
|
192
|
+
if (ipMatch) {
|
|
193
|
+
e.preventDefault();
|
|
194
|
+
const newOctets = [
|
|
195
|
+
clampOctet(ipMatch[1]!),
|
|
196
|
+
clampOctet(ipMatch[2]!),
|
|
197
|
+
clampOctet(ipMatch[3]!),
|
|
198
|
+
clampOctet(ipMatch[4]!),
|
|
199
|
+
];
|
|
200
|
+
const newCidr = ipMatch[5] ?? cidr;
|
|
201
|
+
if (!isControlled) {
|
|
202
|
+
setInternalOctets(newOctets);
|
|
203
|
+
setInternalCidr(newCidr);
|
|
204
|
+
}
|
|
205
|
+
emitChange(newOctets, newCidr);
|
|
206
|
+
inputRefs.current[3]?.focus();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<div
|
|
212
|
+
ref={ref}
|
|
213
|
+
data-slot="input-ip"
|
|
214
|
+
aria-invalid={ariaInvalid}
|
|
215
|
+
data-disabled={disabled || undefined}
|
|
216
|
+
className={cn(
|
|
217
|
+
inputIpVariants({ size }),
|
|
218
|
+
disabled && 'cursor-not-allowed opacity-50',
|
|
219
|
+
className,
|
|
220
|
+
)}
|
|
221
|
+
onPaste={handlePaste}
|
|
222
|
+
{...props}
|
|
223
|
+
>
|
|
224
|
+
{octets.map((octet, i) => (
|
|
225
|
+
<React.Fragment key={i}>
|
|
226
|
+
{i > 0 && (
|
|
227
|
+
<span className="select-none text-muted-foreground">.</span>
|
|
228
|
+
)}
|
|
229
|
+
<input
|
|
230
|
+
ref={(el) => {
|
|
231
|
+
inputRefs.current[i] = el;
|
|
232
|
+
}}
|
|
233
|
+
type="text"
|
|
234
|
+
inputMode="numeric"
|
|
235
|
+
aria-label={`IP 地址第 ${i + 1} 段`}
|
|
236
|
+
className={cn(
|
|
237
|
+
'w-10 cursor-text border-0 bg-transparent text-center outline-none placeholder:text-muted-foreground/60',
|
|
238
|
+
size === 'sm' && 'w-8',
|
|
239
|
+
size === 'lg' && 'w-12',
|
|
240
|
+
)}
|
|
241
|
+
value={octet}
|
|
242
|
+
placeholder={placeholderParts[i] ?? '0'}
|
|
243
|
+
disabled={disabled}
|
|
244
|
+
onChange={(e) => handleOctetChange(i, e.target.value)}
|
|
245
|
+
onKeyDown={(e) => handleKeyDown(i, e)}
|
|
246
|
+
/>
|
|
247
|
+
</React.Fragment>
|
|
248
|
+
))}
|
|
249
|
+
{showCidr && (
|
|
250
|
+
<>
|
|
251
|
+
<span className="select-none px-0.5 text-muted-foreground">/</span>
|
|
252
|
+
<Select
|
|
253
|
+
value={cidr || undefined}
|
|
254
|
+
onValueChange={handleCidrChange}
|
|
255
|
+
disabled={disabled}
|
|
256
|
+
>
|
|
257
|
+
<SelectTrigger
|
|
258
|
+
aria-label="CIDR 前缀长度"
|
|
259
|
+
data-embedded="true"
|
|
260
|
+
className={cn(
|
|
261
|
+
// 内嵌于 InputIP:去除自身 border / shadow / focus ring,
|
|
262
|
+
// 由外层容器的 focus-within 状态统一接管。
|
|
263
|
+
// `data-embedded="true"` 使 uni-manager 主题的全局 hover 阴影规则豁免。
|
|
264
|
+
'gap-0.5 border-0 bg-transparent px-1 shadow-none ring-0 focus-visible:border-0 focus-visible:ring-0 data-[size=default]:h-full data-[size=sm]:h-full',
|
|
265
|
+
size === 'sm' && 'min-w-9 text-xs',
|
|
266
|
+
size === 'default' && 'min-w-10 text-xs',
|
|
267
|
+
size === 'lg' && 'min-w-11 text-sm',
|
|
268
|
+
)}
|
|
269
|
+
>
|
|
270
|
+
<SelectValue placeholder="/" />
|
|
271
|
+
</SelectTrigger>
|
|
272
|
+
<SelectContent>
|
|
273
|
+
{cidrOptions.map((n) => (
|
|
274
|
+
<SelectItem key={n} value={String(n)}>
|
|
275
|
+
{n}
|
|
276
|
+
</SelectItem>
|
|
277
|
+
))}
|
|
278
|
+
</SelectContent>
|
|
279
|
+
</Select>
|
|
280
|
+
</>
|
|
281
|
+
)}
|
|
282
|
+
</div>
|
|
283
|
+
);
|
|
284
|
+
},
|
|
285
|
+
);
|
|
286
|
+
InputIP.displayName = 'InputIP';
|
|
287
|
+
|
|
288
|
+
export { InputIP };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# InputIP
|
|
2
|
+
|
|
3
|
+
> 本文件由 `pnpm gen:meta` 自动生成,**请勿手动编辑**。
|
|
4
|
+
|
|
5
|
+
## 描述
|
|
6
|
+
|
|
7
|
+
IP 地址输入框 InputIP
|
|
8
|
+
分段式 IPv4 地址输入,支持自动跳段、范围校验和可选 CIDR 掩码选择。
|
|
9
|
+
|
|
10
|
+
## 使用场景
|
|
11
|
+
|
|
12
|
+
- 需要用户输入 IPv4 地址时
|
|
13
|
+
- 需要带 CIDR 前缀长度的网段输入时(如 192.168.1.0/24)
|
|
14
|
+
|
|
15
|
+
## Props
|
|
16
|
+
|
|
17
|
+
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
18
|
+
| --- | --- | --- | --- | --- |
|
|
19
|
+
| `size` | `InputIPSize` | `"default"` | – | 尺寸。 |
|
|
20
|
+
| `value` | `string` | – | – | 受控值,格式 "x.x.x.x" 或 "x.x.x.x/prefix"。 |
|
|
21
|
+
| `defaultValue` | `string` | – | – | 非受控初值。 |
|
|
22
|
+
| `onChange` | `(value: string) => void` | – | – | 值变化回调。 |
|
|
23
|
+
| `showCidr` | `boolean` | `false` | – | 是否显示 CIDR 前缀选择。 |
|
|
24
|
+
| `cidrOptions` | `number[]` | `[0..32]` | – | CIDR 前缀可选范围。 |
|
|
25
|
+
| `disabled` | `boolean` | `false` | – | 禁用态。 |
|
|
26
|
+
| `placeholder` | `string` | `"0.0.0.0"` | – | placeholder,按段用 "." 分隔。 |
|
|
27
|
+
|
|
28
|
+
## 示例
|
|
29
|
+
|
|
30
|
+
### Sizes
|
|
31
|
+
|
|
32
|
+
三种尺寸。
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
<div className="flex flex-col gap-3">
|
|
36
|
+
<InputIP size="sm" className="w-44" defaultValue="10.0.0.1" />
|
|
37
|
+
<InputIP size="default" className="w-52" defaultValue="172.16.0.1" />
|
|
38
|
+
<InputIP size="lg" className="w-60" defaultValue="192.168.1.1" />
|
|
39
|
+
</div>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Invalid
|
|
43
|
+
|
|
44
|
+
错误态(校验失败)。
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
<InputIP className="w-52" defaultValue="999.0.0.1" aria-invalid="true" />
|
|
48
|
+
```
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { InputIP } from './index';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof InputIP> = {
|
|
6
|
+
title: '数据录入 · Data Entry/InputIP IP地址输入',
|
|
7
|
+
component: InputIP,
|
|
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
|
+
/** 基础 IPv4 地址输入。容器 inline-flex 自适应宽度,不需额外设定。 */
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
render: () => <InputIP />,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** 受控模式,外部管理 value。 */
|
|
23
|
+
export const Controlled: Story = {
|
|
24
|
+
render: function ControlledStory() {
|
|
25
|
+
const [value, setValue] = useState('192.168.1.1');
|
|
26
|
+
return (
|
|
27
|
+
<div className="flex flex-col gap-2">
|
|
28
|
+
<InputIP value={value} onChange={setValue} />
|
|
29
|
+
<span className="text-xs text-muted-foreground">当前值:{value}</span>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** 带 CIDR 前缀选择的网段输入。右侧 CIDR 选择器使用 ui Select。 */
|
|
36
|
+
export const WithCidr: Story = {
|
|
37
|
+
render: function CidrStory() {
|
|
38
|
+
const [value, setValue] = useState('192.168.1.0/24');
|
|
39
|
+
return (
|
|
40
|
+
<div className="flex flex-col gap-2">
|
|
41
|
+
<InputIP showCidr value={value} onChange={setValue} />
|
|
42
|
+
<span className="text-xs text-muted-foreground">当前值:{value}</span>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** 三种尺寸。 */
|
|
49
|
+
export const Sizes: Story = {
|
|
50
|
+
render: () => (
|
|
51
|
+
<div className="flex flex-col gap-3">
|
|
52
|
+
<InputIP size="sm" className="w-44" defaultValue="10.0.0.1" />
|
|
53
|
+
<InputIP size="default" className="w-52" defaultValue="172.16.0.1" />
|
|
54
|
+
<InputIP size="lg" className="w-60" defaultValue="192.168.1.1" />
|
|
55
|
+
</div>
|
|
56
|
+
),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** 禁用态。 */
|
|
60
|
+
export const Disabled: Story = {
|
|
61
|
+
render: () => <InputIP className="w-52" defaultValue="10.0.0.1" disabled />,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** 错误态(校验失败)。 */
|
|
65
|
+
export const Invalid: Story = {
|
|
66
|
+
render: () => (
|
|
67
|
+
<InputIP className="w-52" defaultValue="999.0.0.1" aria-invalid="true" />
|
|
68
|
+
),
|
|
69
|
+
};
|