@teamix-evo/ui 0.2.0 → 0.4.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 +184 -184
- package/manifest.json +695 -487
- package/package.json +16 -10
- package/src/components/accordion/accordion.meta.md +5 -9
- package/src/components/accordion/accordion.stories.tsx +3 -3
- package/src/components/accordion/accordion.tsx +104 -8
- package/src/components/affix/affix.meta.md +21 -12
- package/src/components/affix/affix.stories.tsx +101 -26
- package/src/components/affix/affix.tsx +79 -9
- package/src/components/alert/alert.meta.md +52 -26
- package/src/components/alert/alert.stories.tsx +66 -21
- package/src/components/alert/alert.tsx +81 -34
- package/src/components/alert-dialog/alert-dialog.meta.md +48 -16
- package/src/components/alert-dialog/alert-dialog.stories.tsx +145 -3
- package/src/components/alert-dialog/alert-dialog.tsx +60 -13
- package/src/components/anchor/anchor.meta.md +10 -14
- package/src/components/anchor/anchor.stories.tsx +3 -3
- package/src/components/anchor/anchor.tsx +2 -2
- package/src/components/app/app.meta.md +10 -14
- package/src/components/app/app.stories.tsx +6 -6
- package/src/components/aspect-ratio/aspect-ratio.meta.md +4 -8
- package/src/components/aspect-ratio/aspect-ratio.stories.tsx +3 -3
- package/src/components/auto-complete/auto-complete.meta.md +19 -20
- package/src/components/auto-complete/auto-complete.stories.tsx +44 -3
- package/src/components/auto-complete/auto-complete.tsx +119 -71
- package/src/components/avatar/avatar.meta.md +9 -22
- package/src/components/avatar/avatar.stories.tsx +21 -3
- package/src/components/avatar/avatar.tsx +24 -23
- package/src/components/badge/badge.meta.md +14 -18
- package/src/components/badge/badge.stories.tsx +2 -2
- package/src/components/badge/badge.tsx +2 -2
- package/src/components/breadcrumb/breadcrumb.meta.md +29 -20
- package/src/components/breadcrumb/breadcrumb.stories.tsx +120 -5
- package/src/components/breadcrumb/breadcrumb.tsx +22 -8
- package/src/components/button/button.meta.md +261 -29
- package/src/components/button/button.stories.tsx +549 -41
- package/src/components/button/button.tsx +341 -35
- package/src/components/calendar/calendar.meta.md +19 -14
- package/src/components/calendar/calendar.stories.tsx +5 -5
- package/src/components/calendar/calendar.tsx +73 -8
- package/src/components/card/card.meta.md +31 -34
- package/src/components/card/card.stories.tsx +34 -3
- package/src/components/card/card.tsx +147 -63
- package/src/components/carousel/carousel.meta.md +10 -14
- package/src/components/carousel/carousel.stories.tsx +1 -1
- package/src/components/cascader/cascader.meta.md +43 -22
- package/src/components/cascader/cascader.stories.tsx +13 -2
- package/src/components/cascader/cascader.tsx +439 -89
- package/src/components/checkbox/checkbox.meta.md +74 -24
- package/src/components/checkbox/checkbox.stories.tsx +160 -2
- package/src/components/checkbox/checkbox.tsx +79 -9
- package/src/components/collapsible/collapsible.meta.md +7 -6
- package/src/components/collapsible/collapsible.stories.tsx +2 -2
- package/src/components/collapsible/collapsible.tsx +93 -6
- package/src/components/color-picker/color-picker.meta.md +16 -20
- package/src/components/color-picker/color-picker.stories.tsx +86 -7
- package/src/components/color-picker/color-picker.tsx +19 -9
- package/src/components/command/command.meta.md +7 -11
- package/src/components/command/command.stories.tsx +4 -4
- package/src/components/command/command.tsx +18 -7
- package/src/components/context-menu/context-menu.meta.md +5 -25
- package/src/components/context-menu/context-menu.stories.tsx +4 -4
- package/src/components/context-menu/context-menu.tsx +21 -8
- package/src/components/data-table/data-table.meta.md +14 -18
- package/src/components/data-table/data-table.stories.tsx +1 -1
- package/src/components/data-table/data-table.tsx +2 -2
- package/src/components/date-picker/date-picker.meta.md +90 -41
- package/src/components/date-picker/date-picker.stories.tsx +55 -5
- package/src/components/date-picker/date-picker.tsx +1489 -91
- package/src/components/descriptions/descriptions.meta.md +12 -16
- package/src/components/descriptions/descriptions.stories.tsx +2 -2
- package/src/components/descriptions/descriptions.tsx +22 -14
- package/src/components/dialog/dialog.meta.md +67 -17
- package/src/components/dialog/dialog.stories.tsx +182 -20
- package/src/components/dialog/dialog.tsx +67 -15
- package/src/components/dialog/imperative.tsx +252 -0
- package/src/components/drawer/drawer.meta.md +27 -39
- package/src/components/drawer/drawer.stories.tsx +29 -12
- package/src/components/drawer/drawer.tsx +22 -114
- package/src/components/dropdown-menu/dropdown-menu.meta.md +64 -24
- package/src/components/dropdown-menu/dropdown-menu.stories.tsx +81 -3
- package/src/components/dropdown-menu/dropdown-menu.tsx +24 -10
- package/src/components/ellipsis/ellipsis.meta.md +87 -0
- package/src/components/ellipsis/ellipsis.stories.tsx +72 -0
- package/src/components/ellipsis/ellipsis.tsx +153 -0
- package/src/components/empty/empty.meta.md +10 -14
- package/src/components/empty/empty.stories.tsx +3 -3
- package/src/components/empty/empty.tsx +10 -3
- package/src/components/field/field.meta.md +46 -25
- package/src/components/field/field.stories.tsx +380 -3
- package/src/components/field/field.tsx +263 -35
- package/src/components/filter-bar/filter-bar.meta.md +92 -0
- package/src/components/filter-bar/filter-bar.stories.tsx +1086 -0
- package/src/components/filter-bar/filter-bar.tsx +568 -0
- package/src/components/flex/flex.meta.md +59 -20
- package/src/components/flex/flex.stories.tsx +65 -10
- package/src/components/flex/flex.tsx +27 -4
- package/src/components/float-button/float-button.meta.md +10 -29
- package/src/components/float-button/float-button.stories.tsx +6 -6
- package/src/components/form/form.meta.md +31 -52
- package/src/components/form/form.stories.tsx +354 -4
- package/src/components/form/form.tsx +101 -35
- package/src/components/grid/grid.meta.md +4 -24
- package/src/components/grid/grid.stories.tsx +2 -2
- package/src/components/hover-card/hover-card.meta.md +9 -10
- package/src/components/hover-card/hover-card.stories.tsx +29 -4
- package/src/components/hover-card/hover-card.tsx +51 -13
- package/src/components/icon/DEVELOPMENT.md +809 -0
- package/src/components/icon/icon.meta.md +170 -0
- package/src/components/icon/icon.stories.tsx +344 -0
- package/src/components/icon/icon.tsx +248 -0
- package/src/components/image/image.meta.md +14 -18
- package/src/components/image/image.stories.tsx +3 -3
- package/src/components/image/image.tsx +2 -0
- package/src/components/input/input.meta.md +44 -43
- package/src/components/input/input.stories.tsx +62 -35
- package/src/components/input/input.tsx +96 -101
- package/src/components/input-group/input-group.meta.md +53 -39
- package/src/components/input-group/input-group.stories.tsx +49 -16
- package/src/components/input-group/input-group.tsx +45 -10
- package/src/components/input-number/input-number.meta.md +68 -20
- package/src/components/input-number/input-number.stories.tsx +33 -6
- package/src/components/input-number/input-number.tsx +81 -22
- package/src/components/input-otp/input-otp.meta.md +8 -20
- package/src/components/input-otp/input-otp.stories.tsx +3 -3
- package/src/components/input-otp/input-otp.tsx +1 -1
- package/src/components/item/item.meta.md +8 -26
- package/src/components/item/item.stories.tsx +3 -3
- package/src/components/item/item.tsx +7 -6
- package/src/components/kbd/kbd.meta.md +7 -19
- package/src/components/kbd/kbd.stories.tsx +4 -4
- package/src/components/kbd/kbd.tsx +8 -4
- package/src/components/label/label.meta.md +21 -18
- package/src/components/label/label.stories.tsx +64 -6
- package/src/components/label/label.tsx +91 -19
- package/src/components/masonry/masonry.meta.md +8 -12
- package/src/components/masonry/masonry.stories.tsx +4 -4
- package/src/components/mentions/mentions.meta.md +42 -21
- package/src/components/mentions/mentions.stories.tsx +120 -6
- package/src/components/mentions/mentions.tsx +10 -5
- package/src/components/menubar/menubar.meta.md +4 -8
- package/src/components/menubar/menubar.stories.tsx +55 -3
- package/src/components/menubar/menubar.tsx +9 -9
- package/src/components/native-select/native-select.meta.md +7 -11
- package/src/components/native-select/native-select.stories.tsx +4 -4
- package/src/components/native-select/native-select.tsx +2 -2
- package/src/components/navigation-menu/navigation-menu.meta.md +4 -8
- package/src/components/navigation-menu/navigation-menu.stories.tsx +106 -3
- package/src/components/navigation-menu/navigation-menu.tsx +6 -3
- package/src/components/notification/notification.meta.md +41 -8
- package/src/components/notification/notification.stories.tsx +9 -9
- package/src/components/notification/notification.tsx +34 -19
- package/src/components/page-header/DEVELOPMENT.md +842 -0
- package/src/components/page-header/page-header.meta.md +210 -0
- package/src/components/page-header/page-header.stories.tsx +428 -0
- package/src/components/page-header/page-header.tsx +284 -0
- package/src/components/page-shell/page-shell.meta.md +116 -0
- package/src/components/page-shell/page-shell.stories.tsx +149 -0
- package/src/components/page-shell/page-shell.tsx +115 -0
- package/src/components/pagination/pagination.meta.md +122 -50
- package/src/components/pagination/pagination.stories.tsx +227 -11
- package/src/components/pagination/pagination.tsx +345 -63
- package/src/components/popconfirm/popconfirm.meta.md +19 -23
- package/src/components/popconfirm/popconfirm.stories.tsx +2 -2
- package/src/components/popconfirm/popconfirm.tsx +1 -1
- package/src/components/popover/popover.meta.md +64 -12
- package/src/components/popover/popover.stories.tsx +83 -7
- package/src/components/popover/popover.tsx +77 -28
- package/src/components/progress/progress.meta.md +43 -26
- package/src/components/progress/progress.stories.tsx +2 -2
- package/src/components/progress/progress.tsx +19 -11
- package/src/components/radio-group/radio-group.meta.md +78 -11
- package/src/components/radio-group/radio-group.stories.tsx +38 -2
- package/src/components/radio-group/radio-group.tsx +149 -18
- package/src/components/rate/rate.meta.md +41 -19
- package/src/components/rate/rate.stories.tsx +2 -2
- package/src/components/rate/rate.tsx +37 -10
- package/src/components/resizable/resizable.meta.md +4 -12
- package/src/components/resizable/resizable.stories.tsx +5 -5
- package/src/components/resizable/resizable.tsx +1 -1
- package/src/components/result/result.meta.md +10 -14
- package/src/components/result/result.stories.tsx +2 -2
- package/src/components/result/result.tsx +21 -12
- package/src/components/scroll-area/scroll-area.meta.md +4 -8
- package/src/components/scroll-area/scroll-area.stories.tsx +5 -5
- package/src/components/segmented/segmented.meta.md +15 -17
- package/src/components/segmented/segmented.stories.tsx +3 -3
- package/src/components/segmented/segmented.tsx +16 -8
- package/src/components/select/select.meta.md +199 -67
- package/src/components/select/select.stories.tsx +238 -63
- package/src/components/select/select.tsx +718 -171
- package/src/components/separator/separator.meta.md +10 -14
- package/src/components/separator/separator.stories.tsx +2 -2
- package/src/components/separator/separator.tsx +3 -7
- package/src/components/sheet/sheet.meta.md +26 -21
- package/src/components/sheet/sheet.stories.tsx +116 -10
- package/src/components/sheet/sheet.tsx +116 -29
- package/src/components/sidebar/sidebar.meta.md +29 -38
- package/src/components/sidebar/sidebar.stories.tsx +696 -29
- package/src/components/sidebar/sidebar.tsx +643 -141
- package/src/components/skeleton/skeleton.meta.md +7 -31
- package/src/components/skeleton/skeleton.stories.tsx +3 -3
- package/src/components/skeleton/skeleton.tsx +7 -7
- package/src/components/slider/slider.meta.md +60 -13
- package/src/components/slider/slider.stories.tsx +58 -6
- package/src/components/slider/slider.tsx +154 -13
- package/src/components/sonner/sonner.meta.md +54 -8
- package/src/components/sonner/sonner.stories.tsx +79 -11
- package/src/components/sonner/sonner.tsx +137 -8
- package/src/components/spinner/spinner.meta.md +57 -21
- package/src/components/spinner/spinner.stories.tsx +66 -14
- package/src/components/spinner/spinner.tsx +111 -9
- package/src/components/statistic/statistic.meta.md +14 -30
- package/src/components/statistic/statistic.stories.tsx +1 -1
- package/src/components/statistic/statistic.tsx +4 -5
- package/src/components/steps/steps.meta.md +20 -15
- package/src/components/steps/steps.stories.tsx +37 -2
- package/src/components/steps/steps.tsx +15 -12
- package/src/components/switch/switch.meta.md +56 -15
- package/src/components/switch/switch.stories.tsx +5 -5
- package/src/components/switch/switch.tsx +59 -13
- package/src/components/table/table.meta.md +3 -7
- package/src/components/table/table.stories.tsx +1 -1
- package/src/components/table/table.tsx +8 -6
- package/src/components/tabs/tabs.meta.md +40 -32
- package/src/components/tabs/tabs.stories.tsx +104 -26
- package/src/components/tabs/tabs.tsx +125 -54
- package/src/components/tag/tag.meta.md +104 -68
- package/src/components/tag/tag.stories.tsx +183 -15
- package/src/components/tag/tag.tsx +222 -21
- package/src/components/textarea/textarea.meta.md +42 -31
- package/src/components/textarea/textarea.stories.tsx +32 -6
- package/src/components/textarea/textarea.tsx +32 -8
- package/src/components/time-picker/time-picker.meta.md +119 -50
- package/src/components/time-picker/time-picker.stories.tsx +65 -33
- package/src/components/time-picker/time-picker.tsx +889 -101
- package/src/components/timeline/timeline.meta.md +16 -17
- package/src/components/timeline/timeline.stories.tsx +24 -4
- package/src/components/timeline/timeline.tsx +32 -12
- package/src/components/toggle/toggle.meta.md +8 -12
- package/src/components/toggle/toggle.stories.tsx +4 -4
- package/src/components/toggle/toggle.tsx +4 -3
- package/src/components/toggle-group/toggle-group.meta.md +10 -14
- package/src/components/toggle-group/toggle-group.stories.tsx +3 -3
- package/src/components/toggle-group/toggle-group.tsx +2 -2
- package/src/components/tooltip/tooltip.meta.md +63 -18
- package/src/components/tooltip/tooltip.stories.tsx +42 -5
- package/src/components/tooltip/tooltip.tsx +81 -21
- package/src/components/tour/tour.meta.md +16 -20
- package/src/components/tour/tour.stories.tsx +3 -3
- package/src/components/tour/tour.tsx +3 -3
- package/src/components/transfer/transfer.meta.md +18 -22
- package/src/components/transfer/transfer.stories.tsx +2 -2
- package/src/components/transfer/transfer.tsx +28 -21
- package/src/components/tree/tree.meta.md +67 -22
- package/src/components/tree/tree.stories.tsx +1 -1
- package/src/components/tree/tree.tsx +9 -8
- package/src/components/tree-select/tree-select.meta.md +59 -23
- package/src/components/tree-select/tree-select.stories.tsx +2 -2
- package/src/components/tree-select/tree-select.tsx +42 -7
- package/src/components/typography/typography.meta.md +61 -39
- package/src/components/typography/typography.stories.tsx +14 -9
- package/src/components/typography/typography.tsx +38 -25
- package/src/components/upload/upload.meta.md +61 -25
- package/src/components/upload/upload.stories.tsx +69 -3
- package/src/components/upload/upload.tsx +170 -37
- package/src/components/watermark/watermark.meta.md +15 -19
- package/src/components/watermark/watermark.stories.tsx +98 -8
- package/src/hooks/use-breakpoint.ts +117 -0
- package/src/hooks/use-debounce-callback.ts +52 -0
- package/src/hooks/use-mobile.ts +23 -0
- package/src/stories/theme-tokens.stories.tsx +747 -0
- package/src/utils/trigger-input.ts +57 -0
- package/src/components/button/demo/as-child.tsx +0 -24
- package/src/components/button/demo/basic.tsx +0 -8
- package/src/components/button/demo/block.tsx +0 -16
- package/src/components/button/demo/loading.tsx +0 -19
- package/src/components/button/demo/shapes.tsx +0 -18
- package/src/components/button/demo/sizes.tsx +0 -19
- package/src/components/button/demo/variants.tsx +0 -19
- package/src/components/button/demo/with-icon.tsx +0 -20
- package/src/components/button-group/button-group.meta.md +0 -101
- package/src/components/button-group/button-group.stories.tsx +0 -93
- package/src/components/button-group/button-group.tsx +0 -75
- package/src/components/combobox/combobox.meta.md +0 -102
- package/src/components/combobox/combobox.stories.tsx +0 -55
- package/src/components/combobox/combobox.tsx +0 -130
- package/src/components/input/demo/addon.tsx +0 -15
- package/src/components/input/demo/basic.tsx +0 -12
- package/src/components/input/demo/clearable.tsx +0 -21
- package/src/components/input/demo/show-count.tsx +0 -18
- package/src/components/input/demo/sizes.tsx +0 -15
- package/src/components/input/demo/with-prefix-suffix.tsx +0 -19
- package/src/components/space/space.meta.md +0 -103
- package/src/components/space/space.stories.tsx +0 -108
- package/src/components/space/space.tsx +0 -106
|
@@ -2,6 +2,18 @@ import * as React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { cn } from '@/utils/cn';
|
|
4
4
|
|
|
5
|
+
// ─── InputGroup family ──────────────────────────────────────────────────────
|
|
6
|
+
//
|
|
7
|
+
// 复合输入框容器 — shadcn 2025-10 新增,等价 antd `Input` 的
|
|
8
|
+
// `prefix` / `suffix` / `addonBefore` / `addonAfter` 集合,但拆为更通用的
|
|
9
|
+
// **复合插槽**:`<InputGroupAddon position="before|after">`(addon)+
|
|
10
|
+
// `<InputGroupInput>` / `<InputGroupTextarea>`(主体)按需嵌套图标 / 按钮 / 文本。
|
|
11
|
+
//
|
|
12
|
+
// 设计纪律:
|
|
13
|
+
// - 主体高度对齐 Input md(h-8 / 32px),与 Button / Select / Input 同档同行混排
|
|
14
|
+
// - 圆角走 `rounded-md`(Tailwind v4 namespace),与 Input / Button 同档
|
|
15
|
+
// - 由 InputGroup 外壳承担 border + ring + focus-within,内部 input / addon 全去边框
|
|
16
|
+
|
|
5
17
|
export interface InputGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
6
18
|
/**
|
|
7
19
|
* 整组禁用样式(子项请单独传 `disabled`,这里仅影响视觉上的 opacity)。
|
|
@@ -13,7 +25,7 @@ export interface InputGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
13
25
|
* Input + addon 统一容器 — shadcn 2025-10 新增,等价 antd `Input` 的
|
|
14
26
|
* `prefix` / `suffix` / `addonBefore` / `addonAfter` 集合,但拆为更通用的
|
|
15
27
|
* **复合插槽**:`<InputGroupAddon position="before|after">`(addon)+
|
|
16
|
-
* `<InputGroupInput>` / `<InputGroupTextarea>`(主体)
|
|
28
|
+
* `<InputGroupInput>` / `<InputGroupTextarea>`(主体)按需嵌套图标 / 按钮 / 文本。
|
|
17
29
|
*/
|
|
18
30
|
const InputGroup = React.forwardRef<HTMLDivElement, InputGroupProps>(
|
|
19
31
|
({ className, disabled, children, ...props }, ref) => (
|
|
@@ -21,8 +33,8 @@ const InputGroup = React.forwardRef<HTMLDivElement, InputGroupProps>(
|
|
|
21
33
|
ref={ref}
|
|
22
34
|
data-disabled={disabled ? '' : undefined}
|
|
23
35
|
className={cn(
|
|
24
|
-
'flex w-full items-stretch overflow-hidden rounded-md border border-input bg-
|
|
25
|
-
'focus-within:ring-
|
|
36
|
+
'flex w-full items-stretch overflow-hidden rounded-md border border-input bg-card shadow-sm',
|
|
37
|
+
'hover:border-ring focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/10',
|
|
26
38
|
'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50',
|
|
27
39
|
className,
|
|
28
40
|
)}
|
|
@@ -54,15 +66,27 @@ const InputGroupAddon = React.forwardRef<HTMLDivElement, InputGroupAddonProps>(
|
|
|
54
66
|
<div
|
|
55
67
|
ref={ref}
|
|
56
68
|
data-position={position}
|
|
69
|
+
data-variant={variant}
|
|
70
|
+
data-slot="input-group-addon"
|
|
57
71
|
className={cn(
|
|
58
72
|
'flex shrink-0 items-center',
|
|
59
73
|
variant === 'text' &&
|
|
60
|
-
'border-input bg-muted px-3 text-
|
|
61
|
-
|
|
74
|
+
'border-input bg-muted px-3 text-xs text-muted-foreground',
|
|
75
|
+
// icon 形态:容器一侧 `pl-3 / pr-3` 与文本输入边距对齐;另一侧贴向 input,
|
|
76
|
+
// 让 input 自身的 `px-3` 提供 12px 图标-文字间距(总入边 12+16+12 = 40px,
|
|
77
|
+
// 与 shadcn / cd hybridcloud 模式接近)。
|
|
78
|
+
variant === 'icon' && 'text-muted-foreground',
|
|
79
|
+
variant === 'icon' && position === 'before' && 'pl-3 pr-0',
|
|
80
|
+
variant === 'icon' && position === 'after' && 'pl-0 pr-3',
|
|
81
|
+
// variant=button 下,直接子元素(Button / SelectTrigger / 自定义)的 border /
|
|
82
|
+
// 圆角 / 阴影 / hover/focus 反馈一律静默 — 视觉责任由 InputGroup 外壳承担。
|
|
83
|
+
// 用 `!` 锁优先级避免 uni-manager scoped CSS 的 hover-shadow 规则反复覆盖。
|
|
62
84
|
variant === 'button' &&
|
|
63
|
-
'[&>*]
|
|
64
|
-
|
|
65
|
-
|
|
85
|
+
'[&>*]:!rounded-none [&>*]:!border-0 [&>*]:!shadow-none [&>*:hover]:!shadow-none [&>*:focus]:!shadow-none [&>*:focus-visible]:!shadow-none',
|
|
86
|
+
// 仅 variant=text 显示分隔线(与正文 input 区隔):button 自身有 primary 底色
|
|
87
|
+
// 作视觉分隔不需再叠灰条;icon 紧贴正文不分隔。
|
|
88
|
+
position === 'before' && variant === 'text' && 'border-r border-input',
|
|
89
|
+
position === 'after' && variant === 'text' && 'border-l border-input',
|
|
66
90
|
className,
|
|
67
91
|
)}
|
|
68
92
|
{...props}
|
|
@@ -79,8 +103,15 @@ const InputGroupInput = React.forwardRef<
|
|
|
79
103
|
ref={ref}
|
|
80
104
|
type={type}
|
|
81
105
|
className={cn(
|
|
82
|
-
|
|
106
|
+
// 高度与 Input md(h-8 / 32px)对齐 — 容器 InputGroup 不设高度,
|
|
107
|
+
// 由内部 input + addon 自身高度决定;Button 默认 h-8 也是 32px,自然对齐。
|
|
108
|
+
'flex h-8 w-full min-w-0 flex-1 bg-transparent px-3 text-xs placeholder:text-muted-foreground',
|
|
83
109
|
'focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50',
|
|
110
|
+
// 紧贴 icon-before addon 时左 padding 收到 8px(addon pl-3 + 0 + input pl-2 = 20px 总内边距,
|
|
111
|
+
// 等价于 antd `<Input prefix>` 的 px-3 + gap-2 模式)。
|
|
112
|
+
'[[data-slot=input-group-addon][data-variant=icon][data-position=before]+&]:pl-2',
|
|
113
|
+
// 同理:右侧紧贴 icon-after addon 时右 padding 收到 8px。
|
|
114
|
+
'[&:has(+[data-slot=input-group-addon][data-variant=icon][data-position=after])]:pr-2',
|
|
84
115
|
className,
|
|
85
116
|
)}
|
|
86
117
|
{...props}
|
|
@@ -96,8 +127,12 @@ const InputGroupTextarea = React.forwardRef<
|
|
|
96
127
|
ref={ref}
|
|
97
128
|
rows={rows}
|
|
98
129
|
className={cn(
|
|
99
|
-
'flex w-full min-w-0 flex-1 bg-transparent px-3 py-2 text-
|
|
130
|
+
'flex w-full min-w-0 flex-1 bg-transparent px-3 py-2 text-xs placeholder:text-muted-foreground',
|
|
100
131
|
'focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50',
|
|
132
|
+
// 默认关闭原生 resize 手柄 — 嵌在 InputGroup(常配 Send/工具栏按钮)里时,
|
|
133
|
+
// 右下角斜线 grip 会从相邻 addon 边缘 peek 出来视觉脏。
|
|
134
|
+
// 业务确需 resize:`className="resize-y"` 自行 override。
|
|
135
|
+
'resize-none',
|
|
101
136
|
className,
|
|
102
137
|
)}
|
|
103
138
|
{...props}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
id: input-number
|
|
3
3
|
name: InputNumber
|
|
4
4
|
type: component
|
|
5
|
-
category:
|
|
5
|
+
category: data-entry
|
|
6
6
|
since: 0.1.0
|
|
7
7
|
package: '@teamix-evo/ui'
|
|
8
8
|
displayName: 数字输入框
|
|
@@ -28,33 +28,32 @@ displayName: 数字输入框
|
|
|
28
28
|
## Props
|
|
29
29
|
|
|
30
30
|
<!-- auto:props:begin -->
|
|
31
|
-
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
| `value`
|
|
35
|
-
| `defaultValue`
|
|
36
|
-
| `onChange`
|
|
37
|
-
| `min`
|
|
38
|
-
| `max`
|
|
39
|
-
| `step`
|
|
40
|
-
| `precision`
|
|
41
|
-
| `groupSeparator` | `boolean`
|
|
42
|
-
| `controls`
|
|
43
|
-
| `
|
|
44
|
-
|
|
31
|
+
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
32
|
+
| --- | --- | --- | --- | --- |
|
|
33
|
+
| `stringMode` | `boolean` | `false` | – | 大数/高精度字符串模式(antd `stringMode` 并集)。开启后: - `value` / `defaultValue` / `onChange` 使用 `string` 类型(避免 IEEE 754 精度丢失) - 步进 / 夹紧仍用 `parseFloat` 执行算术,但最终返回 string |
|
|
34
|
+
| `value` | `number \| string \| null` | – | – | 受控值 — `null` 等价空输入。`stringMode` 时为 `string \| null`。 |
|
|
35
|
+
| `defaultValue` | `number \| string \| null` | – | – | uncontrolled 初值。`stringMode` 时为 `string \| null`。 |
|
|
36
|
+
| `onChange` | `(value: number \| string \| null) => void` | – | – | 值变化回调 — 输入清空时传 `null`。 `stringMode` 时回调 `(value: string \| null) => void`; 普通模式 `(value: number \| null) => void`。 |
|
|
37
|
+
| `min` | `number` | – | – | 最小值(antd `min` 并集)。 |
|
|
38
|
+
| `max` | `number` | – | – | 最大值(antd `max` 并集)。 |
|
|
39
|
+
| `step` | `number` | `1` | – | 步长(antd `step` 并集) — 增 / 减按钮以及键盘 ↑↓ 都按此步长。 |
|
|
40
|
+
| `precision` | `number` | – | – | 数值精度(antd `precision` 并集) — 保留小数位数(超出会四舍五入)。 |
|
|
41
|
+
| `groupSeparator` | `boolean` | `false` | – | 千分位分隔展示(仅展示用,实际 value 仍是 number)。 |
|
|
42
|
+
| `controls` | `boolean` | `true` | – | 是否显示右侧上下步进按钮(antd `controls` 并集) — `false` 时隐藏。 |
|
|
43
|
+
| `type` | `'normal' \| 'inline'` | `"normal"` | – | 形态(cloud-design `type` 并集) — `"normal"` 右侧叠加 ChevronUp/Down 按钮(默认), `"inline"` 两侧各一个 Plus/Minus 按钮(【−】 value 【+】),适合紧凑表单。 |
|
|
44
|
+
| `size` | `'sm' \| 'md' \| 'default' \| 'lg'` | `"md"` | – | 尺寸。`md` 与 `default` 完全等价,后者作为向后兼容别名保留;新代码请优先使用 `md`, 与 Button / Input / Select 等表单原子的 size enum 一致。 |
|
|
45
45
|
<!-- auto:props:end -->
|
|
46
46
|
|
|
47
47
|
## 依赖
|
|
48
48
|
|
|
49
49
|
<!-- auto:deps:begin -->
|
|
50
|
-
|
|
51
50
|
### 同库依赖
|
|
52
51
|
|
|
53
52
|
> `teamix-evo ui add input-number` 时,以下 entry 会被自动连带安装(无需手动 add)。
|
|
54
53
|
|
|
55
|
-
| Entry | 类型 | 描述
|
|
56
|
-
|
|
|
57
|
-
| `cn`
|
|
54
|
+
| Entry | 类型 | 描述 |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
|
|
58
57
|
|
|
59
58
|
### npm 依赖
|
|
60
59
|
|
|
@@ -63,7 +62,6 @@ displayName: 数字输入框
|
|
|
63
62
|
```bash
|
|
64
63
|
pnpm add lucide-react@^0.460.0
|
|
65
64
|
```
|
|
66
|
-
|
|
67
65
|
<!-- auto:deps:end -->
|
|
68
66
|
|
|
69
67
|
## AI 生成纪律
|
|
@@ -75,6 +73,8 @@ pnpm add lucide-react@^0.460.0
|
|
|
75
73
|
- **`controls=false`** 仅在需要嵌入 InputGroup / 紧凑表格时关闭;默认带步进按钮更直观
|
|
76
74
|
- **键盘 ↑↓ 已实现** — 不要再监听 keydown 加自定义步进
|
|
77
75
|
- **不要传 `type="number"`** — 组件用 `type="text"` 才能支持千分位与精确控制
|
|
76
|
+
- **`type="inline"`(本组件自身的 prop,与原生 input.type 无关)**:两侧 Plus/Minus 按钮适合表格与紧凑表单;`type="normal"`(默认) 右侧叠加 ChevronUp/Down,有更多调试空间
|
|
77
|
+
- **步进 icon 走 lucide-react**:`ChevronUp` / `ChevronDown` (normal) 与 `Plus` / `Minus` (inline),**不要**换成 ▲/▼ 等 unicode 字符
|
|
78
78
|
|
|
79
79
|
## Examples
|
|
80
80
|
|
|
@@ -95,6 +95,54 @@ const [v, setV] = React.useState<number | null>(1);
|
|
|
95
95
|
// 隐藏步进按钮(配合 InputGroup 使用)
|
|
96
96
|
<InputNumber controls={false} defaultValue={1} className="rounded-none" />
|
|
97
97
|
|
|
98
|
+
// inline 模式(Plus/Minus 两侧按钮,对齐 cloud-design)
|
|
99
|
+
<InputNumber type="inline" defaultValue={1} min={0} max={10} className="w-32" />
|
|
100
|
+
|
|
98
101
|
// 小尺寸
|
|
99
102
|
<InputNumber size="sm" defaultValue={0} />
|
|
100
103
|
```
|
|
104
|
+
|
|
105
|
+
## InputNumber 形态 — 旧库 API → 新映射
|
|
106
|
+
|
|
107
|
+
> 决策:**不新增独立组件**,`InputNumber` 已承接 cloud-design `NumberPicker` 所有核心能力。本章节是迁移查表索引,与 [上面 Props 表](#props) 互补。
|
|
108
|
+
|
|
109
|
+
### 命名映射
|
|
110
|
+
|
|
111
|
+
| cloud-design 旧库 (`NumberPicker`) | `@teamix-evo/ui` (`InputNumber`) | 说明 |
|
|
112
|
+
| ---------------------------------- | --------------------------------- | ------------------------------- |
|
|
113
|
+
| 组件名 `NumberPicker` | `InputNumber` | 对齐 antd 命名 |
|
|
114
|
+
| `value: number \| string` | `value: number \| null` | 空态用 `null` 代替空字符串 |
|
|
115
|
+
| `onChange(value, e)` | `onChange(value: number \| null)` | 单参数简化(无 event) |
|
|
116
|
+
| `size="small\|medium\|large"` | `size="sm\|md\|lg"` | 三档 + `default` 兼容别名 |
|
|
117
|
+
| `hasTrigger` | `controls` | 显隐步进按钮 |
|
|
118
|
+
| `type="normal"` | `type="normal"`(默认) | 右侧 Chevron 上下按钮 |
|
|
119
|
+
| `type="inline"` | `type="inline"` | 两侧 Plus/Minus 按钮 |
|
|
120
|
+
| `format`(通用格式化) | `groupSeparator`(仅千分位) | 通用 formatter/parser 待后续 P2 |
|
|
121
|
+
| `editable` | 原生 `readOnly` | 直接用 HTML attr |
|
|
122
|
+
| `stringMode`(大数支持) | `stringMode` | ✅ 已实现 — 规避精度丢失 |
|
|
123
|
+
| `precision` | 同名 | 四舍五入保留小数位 |
|
|
124
|
+
| `min` / `max` / `step` | 同名 | 透传 |
|
|
125
|
+
|
|
126
|
+
### Breaking Changes(从旧库迁移时需改写)
|
|
127
|
+
|
|
128
|
+
1. 组件名 `NumberPicker` → `InputNumber`(import 路径变动)
|
|
129
|
+
2. `value` 类型 `string` → `null` 表示空态
|
|
130
|
+
3. `onChange(value, e)` → `onChange(value: number | null)` 单参数
|
|
131
|
+
4. `hasTrigger` → `controls`
|
|
132
|
+
5. `size` 命名缩写(small→sm / medium→md / large→lg)
|
|
133
|
+
6. `format` → `groupSeparator`(仅千分位;通用 formatter 待后续)
|
|
134
|
+
|
|
135
|
+
### 不修复 / 后续工序清单
|
|
136
|
+
|
|
137
|
+
- **~~stringMode 大数支持~~(P1)**:✅ 已落地 — `stringMode` prop 开启后 `value` 用 string 类型,规避 IEEE 754 精度丢失。报告 §3 标记为缺失为旧版本数据,本波次已纠正
|
|
138
|
+
- **通用 formatter / parser**(P2):当前仅 `groupSeparator`千分位;自定义格式化待后续 slot
|
|
139
|
+
- **size 档位对齐 Input/Button**(本波次):sm h-8 → h-7 / md h-9 → h-8 / lg h-10 → h-9(28/32/36),与表单原子家族同行视觉一致
|
|
140
|
+
- **device/isPreview/upBtnProps/downBtnProps/onCorrect/alwaysShowTrigger**:报告 §5 已列入"保留新库优势",**不修复**
|
|
141
|
+
|
|
142
|
+
### InputNumber 专项 AI 生成纪律
|
|
143
|
+
|
|
144
|
+
- 新代码用 `size="md"`,与 Button / Input / Select 一致;`"default"` 仅向后兼容
|
|
145
|
+
- 空态 = `null`(不要用 0 代表“空”)
|
|
146
|
+
- `min`/`max` 自动夹紧,**不要**在外层再做边界校验
|
|
147
|
+
- `controls=false` 仅在嵌入 InputGroup / 紧凑表格时关闭
|
|
148
|
+
- 不要传 `type="number"`(这里的 `type` 是 InputNumber 自己的 prop,与原生 input.type 无关)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
3
|
import { InputNumber } from './input-number';
|
|
4
4
|
|
|
5
5
|
const meta: Meta<typeof InputNumber> = {
|
|
6
|
-
title: '
|
|
6
|
+
title: '数据录入 · Data Entry/InputNumber',
|
|
7
7
|
component: InputNumber,
|
|
8
8
|
tags: ['autodocs'],
|
|
9
9
|
parameters: {
|
|
@@ -15,13 +15,15 @@ const meta: Meta<typeof InputNumber> = {
|
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
argTypes: {
|
|
18
|
-
size: { control: 'inline-radio', options: ['sm', '
|
|
18
|
+
size: { control: 'inline-radio', options: ['sm', 'md', 'lg'] },
|
|
19
|
+
type: { control: 'inline-radio', options: ['normal', 'inline'] },
|
|
19
20
|
controls: { control: 'boolean' },
|
|
20
21
|
groupSeparator: { control: 'boolean' },
|
|
21
22
|
disabled: { control: 'boolean' },
|
|
22
23
|
},
|
|
23
24
|
args: {
|
|
24
|
-
size: '
|
|
25
|
+
size: 'md',
|
|
26
|
+
type: 'normal',
|
|
25
27
|
controls: true,
|
|
26
28
|
groupSeparator: false,
|
|
27
29
|
disabled: false,
|
|
@@ -64,7 +66,7 @@ export const Controlled: Story = {
|
|
|
64
66
|
<div className="flex items-center gap-3">
|
|
65
67
|
<InputNumber
|
|
66
68
|
value={v}
|
|
67
|
-
onChange={setV}
|
|
69
|
+
onChange={(val) => setV(val as number | null)}
|
|
68
70
|
step={0.5}
|
|
69
71
|
min={0}
|
|
70
72
|
max={5}
|
|
@@ -86,12 +88,37 @@ export const NoControls: Story = {
|
|
|
86
88
|
),
|
|
87
89
|
};
|
|
88
90
|
|
|
91
|
+
export const InlineType: Story = {
|
|
92
|
+
name: 'Inline (Plus/Minus)',
|
|
93
|
+
parameters: { controls: { disable: true } },
|
|
94
|
+
render: () => (
|
|
95
|
+
<div className="flex flex-col gap-3">
|
|
96
|
+
<InputNumber
|
|
97
|
+
type="inline"
|
|
98
|
+
defaultValue={1}
|
|
99
|
+
min={0}
|
|
100
|
+
max={10}
|
|
101
|
+
className="w-32"
|
|
102
|
+
/>
|
|
103
|
+
<InputNumber
|
|
104
|
+
type="inline"
|
|
105
|
+
size="sm"
|
|
106
|
+
defaultValue={3}
|
|
107
|
+
min={0}
|
|
108
|
+
max={10}
|
|
109
|
+
className="w-28"
|
|
110
|
+
/>
|
|
111
|
+
<InputNumber type="inline" disabled defaultValue={1} className="w-32" />
|
|
112
|
+
</div>
|
|
113
|
+
),
|
|
114
|
+
};
|
|
115
|
+
|
|
89
116
|
export const Sizes: Story = {
|
|
90
117
|
parameters: { controls: { disable: true } },
|
|
91
118
|
render: () => (
|
|
92
119
|
<div className="flex items-center gap-3">
|
|
93
120
|
<InputNumber size="sm" defaultValue={0} className="w-28" />
|
|
94
|
-
<InputNumber size="
|
|
121
|
+
<InputNumber size="md" defaultValue={0} className="w-32" />
|
|
95
122
|
<InputNumber size="lg" defaultValue={0} className="w-36" />
|
|
96
123
|
</div>
|
|
97
124
|
),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ChevronDown, ChevronUp } from 'lucide-react';
|
|
2
|
+
import { ChevronDown, ChevronUp, Minus, Plus } from 'lucide-react';
|
|
3
3
|
|
|
4
4
|
import { cn } from '@/utils/cn';
|
|
5
5
|
|
|
@@ -15,14 +15,23 @@ export interface InputNumberProps
|
|
|
15
15
|
| 'type'
|
|
16
16
|
| 'size'
|
|
17
17
|
> {
|
|
18
|
-
/** 受控值 — `null` 等价空输入。 */
|
|
19
|
-
value?: number | null;
|
|
20
|
-
/** uncontrolled 初值。 */
|
|
21
|
-
defaultValue?: number | null;
|
|
22
18
|
/**
|
|
23
|
-
*
|
|
19
|
+
* 大数/高精度字符串模式(antd `stringMode` 并集)。开启后:
|
|
20
|
+
* - `value` / `defaultValue` / `onChange` 使用 `string` 类型(避免 IEEE 754 精度丢失)
|
|
21
|
+
* - 步进 / 夹紧仍用 `parseFloat` 执行算术,但最终返回 string
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
stringMode?: boolean;
|
|
25
|
+
/** 受控值 — `null` 等价空输入。`stringMode` 时为 `string | null`。 */
|
|
26
|
+
value?: number | string | null;
|
|
27
|
+
/** uncontrolled 初值。`stringMode` 时为 `string | null`。 */
|
|
28
|
+
defaultValue?: number | string | null;
|
|
29
|
+
/**
|
|
30
|
+
* 值变化回调 — 输入清空时传 `null`。
|
|
31
|
+
* `stringMode` 时回调 `(value: string | null) => void`;
|
|
32
|
+
* 普通模式 `(value: number | null) => void`。
|
|
24
33
|
*/
|
|
25
|
-
onChange?: (value: number | null) => void;
|
|
34
|
+
onChange?: (value: number | string | null) => void;
|
|
26
35
|
/** 最小值(antd `min` 并集)。 */
|
|
27
36
|
min?: number;
|
|
28
37
|
/** 最大值(antd `max` 并集)。 */
|
|
@@ -47,10 +56,17 @@ export interface InputNumberProps
|
|
|
47
56
|
*/
|
|
48
57
|
controls?: boolean;
|
|
49
58
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
59
|
+
* 形态(cloud-design `type` 并集) — `"normal"` 右侧叠加 ChevronUp/Down 按钮(默认),
|
|
60
|
+
* `"inline"` 两侧各一个 Plus/Minus 按钮(【−】 value 【+】),适合紧凑表单。
|
|
61
|
+
* @default "normal"
|
|
62
|
+
*/
|
|
63
|
+
type?: 'normal' | 'inline';
|
|
64
|
+
/**
|
|
65
|
+
* 尺寸。`md` 与 `default` 完全等价,后者作为向后兼容别名保留;新代码请优先使用 `md`,
|
|
66
|
+
* 与 Button / Input / Select 等表单原子的 size enum 一致。
|
|
67
|
+
* @default "md"
|
|
52
68
|
*/
|
|
53
|
-
size?: 'sm' | 'default' | 'lg';
|
|
69
|
+
size?: 'sm' | 'md' | 'default' | 'lg';
|
|
54
70
|
}
|
|
55
71
|
|
|
56
72
|
function format(
|
|
@@ -67,9 +83,10 @@ function format(
|
|
|
67
83
|
}
|
|
68
84
|
|
|
69
85
|
const sizeMap = {
|
|
70
|
-
sm: 'h-
|
|
71
|
-
|
|
72
|
-
|
|
86
|
+
sm: 'h-6 text-xs',
|
|
87
|
+
md: 'h-8 text-xs',
|
|
88
|
+
default: 'h-8 text-xs',
|
|
89
|
+
lg: 'h-9 text-sm',
|
|
73
90
|
} as const;
|
|
74
91
|
|
|
75
92
|
/**
|
|
@@ -91,7 +108,9 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>(
|
|
|
91
108
|
precision,
|
|
92
109
|
groupSeparator = false,
|
|
93
110
|
controls = true,
|
|
94
|
-
|
|
111
|
+
type = 'normal',
|
|
112
|
+
size = 'md',
|
|
113
|
+
stringMode = false,
|
|
95
114
|
disabled,
|
|
96
115
|
className,
|
|
97
116
|
onBlur,
|
|
@@ -101,10 +120,15 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>(
|
|
|
101
120
|
ref,
|
|
102
121
|
) => {
|
|
103
122
|
const isControlled = value !== undefined;
|
|
123
|
+
const toNum = (v: number | string | null | undefined): number | null => {
|
|
124
|
+
if (v == null) return null;
|
|
125
|
+
const n = typeof v === 'string' ? parseFloat(v) : v;
|
|
126
|
+
return Number.isNaN(n) ? null : n;
|
|
127
|
+
};
|
|
104
128
|
const [internal, setInternal] = React.useState<number | null>(
|
|
105
|
-
defaultValue
|
|
129
|
+
toNum(defaultValue),
|
|
106
130
|
);
|
|
107
|
-
const current = isControlled ? value
|
|
131
|
+
const current = isControlled ? toNum(value) : internal;
|
|
108
132
|
const [editing, setEditing] = React.useState<string | null>(null);
|
|
109
133
|
|
|
110
134
|
const display =
|
|
@@ -120,7 +144,11 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>(
|
|
|
120
144
|
|
|
121
145
|
const commit = (next: number | null) => {
|
|
122
146
|
if (!isControlled) setInternal(next);
|
|
123
|
-
|
|
147
|
+
if (stringMode) {
|
|
148
|
+
onChange?.(next === null ? null : String(next));
|
|
149
|
+
} else {
|
|
150
|
+
onChange?.(next);
|
|
151
|
+
}
|
|
124
152
|
};
|
|
125
153
|
|
|
126
154
|
const handleInput = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
@@ -164,12 +192,27 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>(
|
|
|
164
192
|
return (
|
|
165
193
|
<div
|
|
166
194
|
className={cn(
|
|
167
|
-
'inline-flex items-stretch overflow-hidden rounded-md border border-input bg-
|
|
168
|
-
'focus-within:ring-
|
|
195
|
+
'inline-flex items-stretch overflow-hidden rounded-md border border-input bg-card shadow-sm',
|
|
196
|
+
'hover:border-ring focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/10',
|
|
169
197
|
disabled && 'cursor-not-allowed opacity-50',
|
|
170
198
|
className,
|
|
171
199
|
)}
|
|
172
200
|
>
|
|
201
|
+
{controls && type === 'inline' ? (
|
|
202
|
+
<button
|
|
203
|
+
type="button"
|
|
204
|
+
tabIndex={-1}
|
|
205
|
+
disabled={
|
|
206
|
+
disabled ||
|
|
207
|
+
(typeof min === 'number' && (current ?? Infinity) <= min)
|
|
208
|
+
}
|
|
209
|
+
onClick={() => step1(-1)}
|
|
210
|
+
aria-label="减少"
|
|
211
|
+
className="flex items-center justify-center border-r border-input px-2 text-muted-foreground hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30"
|
|
212
|
+
>
|
|
213
|
+
<Minus className="size-3.5" />
|
|
214
|
+
</button>
|
|
215
|
+
) : null}
|
|
173
216
|
<input
|
|
174
217
|
ref={ref}
|
|
175
218
|
type="text"
|
|
@@ -181,11 +224,27 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>(
|
|
|
181
224
|
onKeyDown={handleKeyDown}
|
|
182
225
|
className={cn(
|
|
183
226
|
'w-full bg-transparent px-3 text-foreground placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed',
|
|
227
|
+
type === 'inline' && 'text-center',
|
|
184
228
|
sizeMap[size],
|
|
185
229
|
)}
|
|
186
230
|
{...props}
|
|
187
231
|
/>
|
|
188
|
-
{controls ? (
|
|
232
|
+
{controls && type === 'inline' ? (
|
|
233
|
+
<button
|
|
234
|
+
type="button"
|
|
235
|
+
tabIndex={-1}
|
|
236
|
+
disabled={
|
|
237
|
+
disabled ||
|
|
238
|
+
(typeof max === 'number' && (current ?? -Infinity) >= max)
|
|
239
|
+
}
|
|
240
|
+
onClick={() => step1(1)}
|
|
241
|
+
aria-label="增加"
|
|
242
|
+
className="flex items-center justify-center border-l border-input px-2 text-muted-foreground hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30"
|
|
243
|
+
>
|
|
244
|
+
<Plus className="size-3.5" />
|
|
245
|
+
</button>
|
|
246
|
+
) : null}
|
|
247
|
+
{controls && type === 'normal' ? (
|
|
189
248
|
<div className="flex flex-col border-l border-input">
|
|
190
249
|
<button
|
|
191
250
|
type="button"
|
|
@@ -198,7 +257,7 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>(
|
|
|
198
257
|
aria-label="增加"
|
|
199
258
|
className="flex h-1/2 items-center justify-center px-1.5 text-muted-foreground hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30"
|
|
200
259
|
>
|
|
201
|
-
<ChevronUp className="size-3" />
|
|
260
|
+
<ChevronUp className="size-3.5" />
|
|
202
261
|
</button>
|
|
203
262
|
<button
|
|
204
263
|
type="button"
|
|
@@ -211,7 +270,7 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>(
|
|
|
211
270
|
aria-label="减少"
|
|
212
271
|
className="flex h-1/2 items-center justify-center border-t border-input px-1.5 text-muted-foreground hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30"
|
|
213
272
|
>
|
|
214
|
-
<ChevronDown className="size-3" />
|
|
273
|
+
<ChevronDown className="size-3.5" />
|
|
215
274
|
</button>
|
|
216
275
|
</div>
|
|
217
276
|
) : null}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
id: input-otp
|
|
3
3
|
name: InputOTP
|
|
4
4
|
type: component
|
|
5
|
-
category:
|
|
5
|
+
category: deprecated
|
|
6
6
|
since: 0.1.0
|
|
7
7
|
package: '@teamix-evo/ui'
|
|
8
8
|
displayName: 验证码输入
|
|
@@ -30,20 +30,10 @@ OTP 验证码输入 — 基于 [`input-otp`](https://github.com/guilhermerodz/in
|
|
|
30
30
|
> 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成。`InputOTP` 透传 `input-otp` 的所有 props。
|
|
31
31
|
|
|
32
32
|
<!-- auto:props:begin -->
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
|
37
|
-
| -------------------- | -------- | ------ | ---- | -------------------------------------------------------------------------------------------- |
|
|
38
|
-
| `className` | `string` | – | – | 输入框 className,作用在隐藏的真实 input 上;通常无需关心。 |
|
|
39
|
-
| `containerClassName` | `string` | – | – | 容器 className,作用在 slot 列表外层 wrapper 上, 用于覆盖默认的 `flex items-center gap-2`。 |
|
|
40
|
-
|
|
41
|
-
#### InputOTPSlot
|
|
42
|
-
|
|
43
|
-
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
44
|
-
| ------- | -------- | ------ | ---- | ------------------------------------------ |
|
|
45
|
-
| `index` | `number` | – | ✔ | Slot 索引(必传)。OTP 的 slots 数组下标。 |
|
|
46
|
-
|
|
33
|
+
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
34
|
+
| --- | --- | --- | --- | --- |
|
|
35
|
+
| `className` | `string` | – | – | 输入框 className,作用在隐藏的真实 input 上;通常无需关心。 |
|
|
36
|
+
| `containerClassName` | `string` | – | – | 容器 className,作用在 slot 列表外层 wrapper 上, 用于覆盖默认的 `flex items-center gap-2`。 |
|
|
47
37
|
<!-- auto:props:end -->
|
|
48
38
|
|
|
49
39
|
## 依赖
|
|
@@ -51,14 +41,13 @@ OTP 验证码输入 — 基于 [`input-otp`](https://github.com/guilhermerodz/in
|
|
|
51
41
|
> 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成,数据源是 [`manifest.json`](../../../manifest.json)。**手工编辑 marker 之间的内容会在下次生成时被覆盖**。
|
|
52
42
|
|
|
53
43
|
<!-- auto:deps:begin -->
|
|
54
|
-
|
|
55
44
|
### 同库依赖
|
|
56
45
|
|
|
57
46
|
> `teamix-evo ui add input-otp` 时,以下 entry 会被自动连带安装(无需手动 add)。
|
|
58
47
|
|
|
59
|
-
| Entry | 类型 | 描述
|
|
60
|
-
|
|
|
61
|
-
| `cn`
|
|
48
|
+
| Entry | 类型 | 描述 |
|
|
49
|
+
| --- | --- | --- |
|
|
50
|
+
| `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
|
|
62
51
|
|
|
63
52
|
### npm 依赖
|
|
64
53
|
|
|
@@ -67,7 +56,6 @@ OTP 验证码输入 — 基于 [`input-otp`](https://github.com/guilhermerodz/in
|
|
|
67
56
|
```bash
|
|
68
57
|
pnpm add input-otp@^1.2.0 lucide-react@^0.460.0
|
|
69
58
|
```
|
|
70
|
-
|
|
71
59
|
<!-- auto:deps:end -->
|
|
72
60
|
|
|
73
61
|
> 子组件:`InputOTP`(Root)/ `InputOTPGroup`(slot 容器)/ `InputOTPSlot`(单 slot,需 `index`)/ `InputOTPSeparator`(分隔符,如 4-4 数字之间的点)。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
3
|
import { REGEXP_ONLY_DIGITS } from 'input-otp';
|
|
4
4
|
import {
|
|
5
5
|
InputOTP,
|
|
@@ -9,14 +9,14 @@ import {
|
|
|
9
9
|
} from './input-otp';
|
|
10
10
|
|
|
11
11
|
const meta: Meta<typeof InputOTP> = {
|
|
12
|
-
title: '
|
|
12
|
+
title: '废弃 · Deprecated/InputOTP',
|
|
13
13
|
component: InputOTP,
|
|
14
14
|
tags: ['autodocs'],
|
|
15
15
|
parameters: {
|
|
16
16
|
docs: {
|
|
17
17
|
description: {
|
|
18
18
|
component:
|
|
19
|
-
'一次性密码输入 — 短信 / 邮箱验证码场景的格式化输入,每位字符独立可视 slot。基于 [`input-otp`](https://input-otp.rodz.dev/) 实现,自动处理粘贴、键盘前后切换、IME 与 SMS autofill;通过 `pattern` 限制输入字符集(数字 / 字母数字)。shadcn 专有能力,填补 antd 未提供的验证码输入场景。',
|
|
19
|
+
'⚠️ **已废弃** — 仅 Storybook 留档,不通过 manifest 对外发布。\n\n一次性密码输入 — 短信 / 邮箱验证码场景的格式化输入,每位字符独立可视 slot。基于 [`input-otp`](https://input-otp.rodz.dev/) 实现,自动处理粘贴、键盘前后切换、IME 与 SMS autofill;通过 `pattern` 限制输入字符集(数字 / 字母数字)。shadcn 专有能力,填补 antd 未提供的验证码输入场景。',
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
22
|
},
|
|
@@ -67,7 +67,7 @@ const InputOTPSlot = React.forwardRef<
|
|
|
67
67
|
<div
|
|
68
68
|
ref={ref}
|
|
69
69
|
className={cn(
|
|
70
|
-
'relative flex size-10 items-center justify-center border-y border-r border-input text-
|
|
70
|
+
'relative flex size-10 items-center justify-center border-y border-r border-input text-xs shadow-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md',
|
|
71
71
|
isActive && 'z-10 ring-1 ring-ring',
|
|
72
72
|
className,
|
|
73
73
|
)}
|