@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
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
4
|
+
|
|
5
|
+
import { cn } from '@/utils/cn';
|
|
6
|
+
|
|
7
|
+
// ─── cva: 内层 svg 样式(承担 size + color + spin)─────────────────────────────
|
|
8
|
+
//
|
|
9
|
+
// `[&>svg]:size-full` 让 size class 应用到 span 后,svg 自动撑满容器。
|
|
10
|
+
// 这样 ref / aria 类型都统一为 HTMLSpanElement,与 spinner 范本一致。
|
|
11
|
+
|
|
12
|
+
export const iconInnerVariants = cva(
|
|
13
|
+
'inline-block shrink-0 align-[-0.125em] [&>svg]:size-full',
|
|
14
|
+
{
|
|
15
|
+
variants: {
|
|
16
|
+
size: {
|
|
17
|
+
xs: 'size-3', // 12px
|
|
18
|
+
sm: 'size-4', // 16px
|
|
19
|
+
md: 'size-5', // 20px(默认)
|
|
20
|
+
lg: 'size-6', // 24px
|
|
21
|
+
xl: 'size-7', // 28px
|
|
22
|
+
'2xl': 'size-9', // 36px
|
|
23
|
+
'3xl': 'size-12', // 48px
|
|
24
|
+
// eslint-disable-next-line teamix-evo/no-arbitrary-tw-value -- `inherit` 档语义为跟随父级字号(em 单位),无法用 Tailwind token 刻度表达。
|
|
25
|
+
inherit: 'size-[1em]',
|
|
26
|
+
},
|
|
27
|
+
color: {
|
|
28
|
+
default: 'text-current',
|
|
29
|
+
muted: 'text-muted-foreground',
|
|
30
|
+
primary: 'text-primary',
|
|
31
|
+
success: 'text-success',
|
|
32
|
+
warning: 'text-warning',
|
|
33
|
+
destructive: 'text-destructive',
|
|
34
|
+
},
|
|
35
|
+
spin: { true: 'animate-spin' },
|
|
36
|
+
},
|
|
37
|
+
defaultVariants: { size: 'md', color: 'default' },
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// ─── cva: 外层带背景容器(variant=circle/square 启用)──────────────────────
|
|
42
|
+
//
|
|
43
|
+
// 容器 size = inner size + 内边距,预留视觉舒适空间;inner svg 进入容器后什么都不变(1:1 联动),
|
|
44
|
+
// 容器外边距由 size class 差(容器 size N → inner size N-2 → 单侧 padding 约 6–18px)推导。
|
|
45
|
+
|
|
46
|
+
export const iconContainerVariants = cva(
|
|
47
|
+
'inline-flex items-center justify-center shrink-0',
|
|
48
|
+
{
|
|
49
|
+
variants: {
|
|
50
|
+
variant: {
|
|
51
|
+
plain: '',
|
|
52
|
+
circle: 'rounded-full',
|
|
53
|
+
square: 'rounded-md',
|
|
54
|
+
},
|
|
55
|
+
color: {
|
|
56
|
+
default: 'bg-muted text-foreground',
|
|
57
|
+
muted: 'bg-muted text-muted-foreground',
|
|
58
|
+
primary: 'bg-accent text-accent-foreground',
|
|
59
|
+
success: 'bg-success-subtle text-success',
|
|
60
|
+
warning: 'bg-warning-subtle text-warning',
|
|
61
|
+
destructive: 'bg-destructive/10 text-destructive',
|
|
62
|
+
},
|
|
63
|
+
size: {
|
|
64
|
+
xs: 'size-5', // 20px → inner xs(12px)
|
|
65
|
+
sm: 'size-6', // 24px → inner sm(16px)
|
|
66
|
+
md: 'size-8', // 32px → inner md(20px)
|
|
67
|
+
lg: 'size-10', // 40px → inner lg(24px)
|
|
68
|
+
xl: 'size-12', // 48px → inner xl(28px)
|
|
69
|
+
'2xl': 'size-14', // 56px → inner 2xl(36px)
|
|
70
|
+
'3xl': 'size-16', // 64px → inner 3xl(48px)
|
|
71
|
+
// eslint-disable-next-line teamix-evo/no-arbitrary-tw-value -- `inherit` 档容器尺寸跟随父级字号(em 单位),无法用 Tailwind token 刻度表达。
|
|
72
|
+
inherit: 'size-[1.75em]',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
defaultVariants: { variant: 'plain', color: 'default', size: 'md' },
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
export type IconInnerVariants = VariantProps<typeof iconInnerVariants>;
|
|
80
|
+
export type IconContainerVariants = VariantProps<typeof iconContainerVariants>;
|
|
81
|
+
|
|
82
|
+
// ─── Props ──────────────────────────────────────────────────────────────────
|
|
83
|
+
|
|
84
|
+
type IconSize = NonNullable<IconInnerVariants['size']>;
|
|
85
|
+
type IconColor = NonNullable<IconInnerVariants['color']>;
|
|
86
|
+
type IconVariant = 'plain' | 'circle' | 'square';
|
|
87
|
+
|
|
88
|
+
export interface IconProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
89
|
+
/**
|
|
90
|
+
* 渲染目标 — 必填。lucide-react / 自定义 svg / iconfont 工厂返回的组件均可。
|
|
91
|
+
* 单一 children 通道,不再提供 `icon` prop(避免 `<Icon icon=...>` 组件名 + 同名 prop 的语义冗余)。
|
|
92
|
+
*/
|
|
93
|
+
children: React.ReactNode;
|
|
94
|
+
/**
|
|
95
|
+
* 形态 — 决定是否带背景容器。
|
|
96
|
+
* - `plain`:无背景,size 直接控前景 svg(默认)
|
|
97
|
+
* - `circle` / `square`:带 `color` 配色的背景容器,inner svg 自动小一档
|
|
98
|
+
* @default "plain"
|
|
99
|
+
*/
|
|
100
|
+
variant?: IconVariant;
|
|
101
|
+
/**
|
|
102
|
+
* 语义色 — 6 档枚举,字面与 OpenTrek tokens 对齐(见 [ADR 0021](../../../../../docs/adr/0021-semantic-color-api-unification.md))。
|
|
103
|
+
* - `variant=plain` 时控前景色
|
|
104
|
+
* - `variant=circle/square` 时同时控容器背景 + 前景(浅底深字)
|
|
105
|
+
* @default "default"
|
|
106
|
+
*/
|
|
107
|
+
color?: IconColor;
|
|
108
|
+
/**
|
|
109
|
+
* 尺寸 — 7 档枚举 + inherit。`inherit` 走 `1em`,跟随父级字号(用于 Title / Button 内联场景)。
|
|
110
|
+
* 当 `variant!=plain` 时,该 size 指容器尺寸,inner svg 自动用对应小一档。
|
|
111
|
+
* @default "md"
|
|
112
|
+
*/
|
|
113
|
+
size?: IconSize;
|
|
114
|
+
/**
|
|
115
|
+
* 旋转动效 — 与 antd Icon `spin` 对齐,Tailwind `animate-spin` 实现。
|
|
116
|
+
* @default false
|
|
117
|
+
*/
|
|
118
|
+
spin?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* 静态旋转角度(度数)— 与 antd Icon `rotate` 对齐,通过 inline transform 实现。
|
|
121
|
+
* 与 `spin` 同时使用语义模糊,不建议同用。
|
|
122
|
+
*/
|
|
123
|
+
rotate?: number;
|
|
124
|
+
/**
|
|
125
|
+
* Slot 模式 — 把渲染目标交给消费方提供的子元素。开启时 `variant` 强制走 plain。
|
|
126
|
+
* @default false
|
|
127
|
+
*/
|
|
128
|
+
asChild?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* 装饰性图标(默认 true,自动 `aria-hidden="true"`)。
|
|
131
|
+
* 当图标承载语义信息时设为 false,**必须**同时提供 `aria-label` 或被 `<button aria-label>` 包裹。
|
|
132
|
+
* @default true
|
|
133
|
+
*/
|
|
134
|
+
decorative?: boolean;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// inner svg size class— 在带背景容器内使用(外层容器已提供 padding、flex 居中、color 前景色继承)。
|
|
138
|
+
|
|
139
|
+
const innerSizeClass: Record<IconSize, string> = {
|
|
140
|
+
xs: 'size-3',
|
|
141
|
+
sm: 'size-4',
|
|
142
|
+
md: 'size-5',
|
|
143
|
+
lg: 'size-6',
|
|
144
|
+
xl: 'size-7',
|
|
145
|
+
'2xl': 'size-9',
|
|
146
|
+
'3xl': 'size-12',
|
|
147
|
+
// eslint-disable-next-line teamix-evo/no-arbitrary-tw-value -- `inherit` 档跟随父级字号(em 单位),无法用 Tailwind token 表达。
|
|
148
|
+
inherit: 'size-[1em]',
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Icon 图标容器 — 纯样式包裹层。
|
|
153
|
+
*
|
|
154
|
+
* 单一 children 通道(对齐 Mantine ThemeIcon),不再有 `icon` prop;
|
|
155
|
+
* `variant + color` 双轴(对齐 ADR 0021),不再有 `withBackground/shape/bgTone` 三轨。
|
|
156
|
+
* 7 档 size + spin/rotate + Slot + 装饰/非装饰无障碍。
|
|
157
|
+
*
|
|
158
|
+
* className / style 在所有分支均合并到外层根节点,完整透传。
|
|
159
|
+
*/
|
|
160
|
+
const Icon = React.forwardRef<HTMLSpanElement, IconProps>(
|
|
161
|
+
(
|
|
162
|
+
{
|
|
163
|
+
children,
|
|
164
|
+
variant = 'plain',
|
|
165
|
+
color = 'default',
|
|
166
|
+
size = 'md',
|
|
167
|
+
spin,
|
|
168
|
+
rotate,
|
|
169
|
+
asChild = false,
|
|
170
|
+
decorative = true,
|
|
171
|
+
className,
|
|
172
|
+
style,
|
|
173
|
+
...rest
|
|
174
|
+
},
|
|
175
|
+
ref,
|
|
176
|
+
) => {
|
|
177
|
+
const ariaProps: React.AriaAttributes & { role?: string } = decorative
|
|
178
|
+
? { 'aria-hidden': true }
|
|
179
|
+
: { role: rest.role ?? 'img' };
|
|
180
|
+
|
|
181
|
+
const rotateStyle: React.CSSProperties | undefined = rotate
|
|
182
|
+
? { transform: `rotate(${rotate}deg)` }
|
|
183
|
+
: undefined;
|
|
184
|
+
const mergedStyle: React.CSSProperties | undefined =
|
|
185
|
+
rotateStyle || style ? { ...rotateStyle, ...style } : undefined;
|
|
186
|
+
|
|
187
|
+
// 分支 C:Slot 模式 — 强制走 plain 形态,把所有 className / style / aria 合并到子元素根节点。
|
|
188
|
+
if (asChild) {
|
|
189
|
+
return (
|
|
190
|
+
<Slot
|
|
191
|
+
ref={ref}
|
|
192
|
+
className={cn(iconInnerVariants({ size, color, spin }), className)}
|
|
193
|
+
style={mergedStyle}
|
|
194
|
+
{...ariaProps}
|
|
195
|
+
{...rest}
|
|
196
|
+
>
|
|
197
|
+
{children}
|
|
198
|
+
</Slot>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// 分支 B:带背景容器(variant=circle/square)— 双 span 嵌套。
|
|
203
|
+
// 外层接 className / style / aria / ...rest 并提供背景 + color 前景色;
|
|
204
|
+
// inner span 只承担 svg size,color 从外层 `text-*` 继承(currentColor)。
|
|
205
|
+
if (variant !== 'plain') {
|
|
206
|
+
return (
|
|
207
|
+
<span
|
|
208
|
+
ref={ref}
|
|
209
|
+
className={cn(
|
|
210
|
+
iconContainerVariants({ variant, color, size }),
|
|
211
|
+
className,
|
|
212
|
+
)}
|
|
213
|
+
style={mergedStyle}
|
|
214
|
+
{...ariaProps}
|
|
215
|
+
{...rest}
|
|
216
|
+
>
|
|
217
|
+
<span
|
|
218
|
+
className={cn(
|
|
219
|
+
'inline-flex shrink-0 [&>svg]:size-full',
|
|
220
|
+
innerSizeClass[size],
|
|
221
|
+
spin && 'animate-spin',
|
|
222
|
+
)}
|
|
223
|
+
>
|
|
224
|
+
{children}
|
|
225
|
+
</span>
|
|
226
|
+
</span>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// 分支 A:plain — 单 span 包裹,size class 与 [&>svg]:size-full 直接生效。
|
|
231
|
+
if (children == null) return null;
|
|
232
|
+
|
|
233
|
+
return (
|
|
234
|
+
<span
|
|
235
|
+
ref={ref}
|
|
236
|
+
className={cn(iconInnerVariants({ size, color, spin }), className)}
|
|
237
|
+
style={mergedStyle}
|
|
238
|
+
{...ariaProps}
|
|
239
|
+
{...rest}
|
|
240
|
+
>
|
|
241
|
+
{children}
|
|
242
|
+
</span>
|
|
243
|
+
);
|
|
244
|
+
},
|
|
245
|
+
);
|
|
246
|
+
Icon.displayName = 'Icon';
|
|
247
|
+
|
|
248
|
+
export { Icon };
|
|
@@ -3,7 +3,7 @@ id: image
|
|
|
3
3
|
name: Image
|
|
4
4
|
displayName: 图片
|
|
5
5
|
type: component
|
|
6
|
-
category:
|
|
6
|
+
category: deprecated
|
|
7
7
|
since: 0.1.0
|
|
8
8
|
package: '@teamix-evo/ui'
|
|
9
9
|
---
|
|
@@ -27,31 +27,28 @@ package: '@teamix-evo/ui'
|
|
|
27
27
|
## Props
|
|
28
28
|
|
|
29
29
|
<!-- auto:props:begin -->
|
|
30
|
-
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
| `
|
|
34
|
-
| `
|
|
35
|
-
| `
|
|
36
|
-
| `
|
|
37
|
-
| `
|
|
38
|
-
| `
|
|
39
|
-
| `imgClassName` | `string` | – | – | 真实 `<img>` 的 className(尺寸 / 圆角 / object-fit)。 |
|
|
40
|
-
|
|
30
|
+
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
31
|
+
| --- | --- | --- | --- | --- |
|
|
32
|
+
| `src` | `string` | – | ✓ | – |
|
|
33
|
+
| `alt` | `string` | – | ✓ | – |
|
|
34
|
+
| `preview` | `boolean` | `true` | – | 是否启用点击预览(antd `preview` 并集) — 点击后弹模态展示原图。 |
|
|
35
|
+
| `fallback` | `React.ReactNode` | – | – | 加载失败时显示的占位元素;不传则用默认 `ImageOff` 图标。 |
|
|
36
|
+
| `placeholder` | `React.ReactNode` | – | – | 加载中显示的占位 — 默认 Skeleton 占位与图片同尺寸。 |
|
|
37
|
+
| `className` | `string` | – | – | 容器 className(图片本身用 `imgClassName`)。 |
|
|
38
|
+
| `imgClassName` | `string` | – | – | 真实 `<img>` 的 className(尺寸 / 圆角 / object-fit)。 |
|
|
41
39
|
<!-- auto:props:end -->
|
|
42
40
|
|
|
43
41
|
## 依赖
|
|
44
42
|
|
|
45
43
|
<!-- auto:deps:begin -->
|
|
46
|
-
|
|
47
44
|
### 同库依赖
|
|
48
45
|
|
|
49
46
|
> `teamix-evo ui add image` 时,以下 entry 会被自动连带安装(无需手动 add)。
|
|
50
47
|
|
|
51
|
-
| Entry
|
|
52
|
-
|
|
|
53
|
-
| `cn`
|
|
54
|
-
| `dialog`
|
|
48
|
+
| Entry | 类型 | 描述 |
|
|
49
|
+
| --- | --- | --- |
|
|
50
|
+
| `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
|
|
51
|
+
| `dialog` | component | 模态对话框 — Radix Dialog + antd Modal 并集(组合式 Header/Footer/Title/Description,size sm/md/lg/xl 绑定 layout-dialog tokens,圆角 radius-dialog 16px,无 border) |
|
|
55
52
|
| `skeleton` | component | 骨架屏 — shadcn pulse 单元素 + antd Avatar/Image/Button/Input/Paragraph 子家族,自动 motion-reduce |
|
|
56
53
|
|
|
57
54
|
### npm 依赖
|
|
@@ -61,7 +58,6 @@ package: '@teamix-evo/ui'
|
|
|
61
58
|
```bash
|
|
62
59
|
pnpm add lucide-react@^0.460.0
|
|
63
60
|
```
|
|
64
|
-
|
|
65
61
|
<!-- auto:deps:end -->
|
|
66
62
|
|
|
67
63
|
## AI 生成纪律
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { Image } from './image';
|
|
3
3
|
|
|
4
4
|
const meta: Meta<typeof Image> = {
|
|
5
|
-
title: '
|
|
5
|
+
title: '废弃 · Deprecated/Image',
|
|
6
6
|
component: Image,
|
|
7
7
|
tags: ['autodocs'],
|
|
8
8
|
parameters: {
|
|
9
9
|
docs: {
|
|
10
10
|
description: {
|
|
11
11
|
component:
|
|
12
|
-
'图片 — 自动处理加载(Skeleton 占位)+ 失败(图标占位)+ 点击预览(Dialog 模态原图)。alt 必填(无障碍)。等价 antd Image。',
|
|
12
|
+
'⚠️ **已废弃** — 仅 Storybook 留档,不通过 manifest 对外发布。\n\n图片 — 自动处理加载(Skeleton 占位)+ 失败(图标占位)+ 点击预览(Dialog 模态原图)。alt 必填(无障碍)。等价 antd Image。',
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
15
|
},
|
|
@@ -5,6 +5,7 @@ import { cn } from '@/utils/cn';
|
|
|
5
5
|
import {
|
|
6
6
|
Dialog,
|
|
7
7
|
DialogContent,
|
|
8
|
+
DialogTitle,
|
|
8
9
|
DialogTrigger,
|
|
9
10
|
} from '@/components/dialog/dialog';
|
|
10
11
|
import { Skeleton } from '@/components/skeleton/skeleton';
|
|
@@ -118,6 +119,7 @@ const Image = React.forwardRef<HTMLImageElement, ImageProps>(
|
|
|
118
119
|
className="max-w-image-preview border-0 bg-transparent p-0 shadow-none"
|
|
119
120
|
showClose={false}
|
|
120
121
|
>
|
|
122
|
+
<DialogTitle className="sr-only">{alt}</DialogTitle>
|
|
121
123
|
<div className="relative">
|
|
122
124
|
<img
|
|
123
125
|
src={src}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
id: input
|
|
3
3
|
name: Input
|
|
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: 输入框
|
|
@@ -10,42 +10,38 @@ displayName: 输入框
|
|
|
10
10
|
|
|
11
11
|
# Input 输入框
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
单行文本输入 — shadcn 简洁基底 + antd 并集中保留为内建逻辑能力的子集:`size` 三档(sm/md/lg,与 `Button` 同档)、`clearable` 一键清空、`showCount` + `maxLength` 字数计数、`error` / `aria-invalid` 错误态。
|
|
14
|
+
|
|
15
|
+
> **2026-06 BREAKING**:`prefix` / `suffix` / `addonBefore` / `addonAfter` 4 个快捷 prop 已移除(ADR 0029)。"装饰类"前后缀(图标 / 文本 / 单位 / 协议头 / 内嵌按钮)统一改用同库独立组件 [`InputGroup`](../input-group/input-group.meta.md) 的复合插槽。`Textarea` 也已拆为 [独立 entry](../textarea/textarea.meta.md)。
|
|
15
16
|
|
|
16
17
|
## When to use
|
|
17
18
|
|
|
18
|
-
-
|
|
19
|
-
- 配合 `prefix` 加搜索图标
|
|
20
|
-
- 配合 `addonBefore="https://"` 输入域名
|
|
19
|
+
- 任何单行文本输入(text / email / password / number / search / tel / url)
|
|
21
20
|
- 配合 `clearable` 给搜索框一键清空
|
|
22
21
|
- 配合 `showCount + maxLength` 给社媒发文限制字数
|
|
22
|
+
- 配合 `error`(或 `aria-invalid`)给表单校验失败的字段加红边
|
|
23
23
|
|
|
24
24
|
## When NOT to use
|
|
25
25
|
|
|
26
|
-
- 多行文本 → `Textarea`
|
|
27
|
-
- 数字微调 → `
|
|
28
|
-
-
|
|
29
|
-
- OTP 验证码 → `InputOTP`
|
|
26
|
+
- 多行文本 → [`Textarea`](../textarea/textarea.meta.md)
|
|
27
|
+
- 数字微调(含步进按钮) → `InputNumber`
|
|
28
|
+
- 选择类输入 → `Select`
|
|
29
|
+
- OTP 验证码 → `InputOTP`
|
|
30
|
+
- 输入框前后需要图标 / 文本 / 协议头 / 单位 / 内嵌按钮 → [`InputGroup`](../input-group/input-group.meta.md)
|
|
30
31
|
|
|
31
32
|
## Props
|
|
32
33
|
|
|
33
34
|
> 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成。
|
|
34
35
|
|
|
35
36
|
<!-- auto:props:begin -->
|
|
36
|
-
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
| `
|
|
40
|
-
| `
|
|
41
|
-
| `
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
44
|
-
| `addonAfter` | `React.ReactNode` | – | – | 输入框后置标签(antd `addonAfter` 并集)。 |
|
|
45
|
-
| `size` | `'sm' \| 'default' \| 'lg'` | `"default"` | – | 尺寸。 |
|
|
46
|
-
| `value` | `string` | – | – | 受控值,用于 clearable / showCount 的逻辑;未传时回退到 uncontrolled 行为。 |
|
|
47
|
-
| `defaultValue` | `string` | – | – | uncontrolled 初始值。 |
|
|
48
|
-
|
|
37
|
+
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
38
|
+
| --- | --- | --- | --- | --- |
|
|
39
|
+
| `clearable` | `boolean` | `false` | – | 显示清除按钮,有内容时点击清空(antd `allowClear` 并集)。 注:仅"快捷一键清空"逻辑保留为 Input 内建能力 — 复合的前后缀(图标 / 文本 / 按钮) 请用 `InputGroup` 系列。 |
|
|
40
|
+
| `showCount` | `boolean` | `false` | – | 显示字符计数(antd `showCount` 并集);需配合 `maxLength` 一起使用。 |
|
|
41
|
+
| `size` | `'sm' \| 'md' \| 'lg' \| 'default'` | `"md"` | – | 尺寸三档,与 `Button` 同档:`sm`(24px) / `md`(32px,默认) / `lg`(36px)。 `"default"` 为兼容旧调用的别名,等价于 `"md"`,新代码请用 `"md"`。 |
|
|
42
|
+
| `error` | `boolean` | `false` | – | 错误态(快捷开关),会同时设置 `aria-invalid`,渲染 destructive 边框 / ring。 也可以直接传 `aria-invalid` 原生属性达到同效果。 |
|
|
43
|
+
| `value` | `string` | – | – | 受控值,用于 clearable / showCount 的逻辑;未传时回退到 uncontrolled 行为。 |
|
|
44
|
+
| `defaultValue` | `string` | – | – | uncontrolled 初始值。 |
|
|
49
45
|
<!-- auto:props:end -->
|
|
50
46
|
|
|
51
47
|
## 依赖
|
|
@@ -53,14 +49,13 @@ displayName: 输入框
|
|
|
53
49
|
> 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成,数据源是 [`manifest.json`](../../../manifest.json)。**手工编辑 marker 之间的内容会在下次生成时被覆盖**。
|
|
54
50
|
|
|
55
51
|
<!-- auto:deps:begin -->
|
|
56
|
-
|
|
57
52
|
### 同库依赖
|
|
58
53
|
|
|
59
54
|
> `teamix-evo ui add input` 时,以下 entry 会被自动连带安装(无需手动 add)。
|
|
60
55
|
|
|
61
|
-
| Entry | 类型 | 描述
|
|
62
|
-
|
|
|
63
|
-
| `cn`
|
|
56
|
+
| Entry | 类型 | 描述 |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
|
|
64
59
|
|
|
65
60
|
### npm 依赖
|
|
66
61
|
|
|
@@ -69,25 +64,35 @@ displayName: 输入框
|
|
|
69
64
|
```bash
|
|
70
65
|
pnpm add lucide-react@^0.460.0
|
|
71
66
|
```
|
|
72
|
-
|
|
73
67
|
<!-- auto:deps:end -->
|
|
74
68
|
|
|
75
69
|
> 透传所有 `<input>` 原生属性(`type` / `placeholder` / `name` / `id` / `aria-*` / `onChange` / ...)。
|
|
76
70
|
|
|
77
71
|
## AI 生成纪律
|
|
78
72
|
|
|
79
|
-
-
|
|
80
|
-
- **`showCount` 必须配 `maxLength`**:无 maxLength 时 showCount
|
|
81
|
-
- **`
|
|
82
|
-
- **
|
|
83
|
-
-
|
|
84
|
-
-
|
|
73
|
+
- **禁止使用已移除的 `prefix` / `suffix` / `addonBefore` / `addonAfter`**:这 4 个 prop 在 v0.x major 中**整段移除**,改用 `InputGroup` 复合插槽(见下方迁移示例)。
|
|
74
|
+
- **`showCount` 必须配 `maxLength`**:无 maxLength 时 showCount 不渲染。
|
|
75
|
+
- **`error` prop 自动设置 `aria-invalid`**:推荐传 `error`,也可直接传原生 `aria-invalid`;**不要**手动拼 `border-destructive`。
|
|
76
|
+
- **size 档位严格三档**:`sm`(h-6/text-xs/24px)/ `md`(h-8/text-xs,默认/32px)/ `lg`(h-9/text-sm/36px);`"default"` 仅作向后兼容别名,**新代码**统一写 `"md"`,与 `Button` 同档便于同行混排。
|
|
77
|
+
- **不要硬编码颜色**:`bg-background` / `border-input` / `placeholder:text-muted-foreground` 都是 design token,**不要**改成 `bg-white`。
|
|
78
|
+
- **圆角走 `rounded-md`**(Tailwind v4 namespace token):uni-manager 2px / opentrek 6px;**禁止** `rounded-lg` / 自定义半径,确保与 Button / Select / DatePicker 同行视觉一致。
|
|
79
|
+
|
|
80
|
+
## 用 InputGroup 替代 prefix / suffix / addon
|
|
81
|
+
|
|
82
|
+
下表是从 `Input` 旧 4 个 prop 到 `InputGroup` 复合插槽的等价改写(ADR 0029 §Decision 2):
|
|
83
|
+
|
|
84
|
+
| 旧写法 | 新写法 |
|
|
85
|
+
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
86
|
+
| `<Input prefix={<Search />} />` | `<InputGroup><InputGroupAddon position="before" variant="icon"><Search /></InputGroupAddon><InputGroupInput /></InputGroup>` |
|
|
87
|
+
| `<Input suffix={<Mail />} />` | `<InputGroup><InputGroupInput /><InputGroupAddon position="after" variant="icon"><Mail /></InputGroupAddon></InputGroup>` |
|
|
88
|
+
| `<Input addonBefore="https://" addonAfter=".com" />` | `<InputGroup><InputGroupAddon position="before">https://</InputGroupAddon><InputGroupInput /><InputGroupAddon position="after">.com</InputGroupAddon></InputGroup>` |
|
|
89
|
+
| `<Input prefix="¥" suffix="USD" />` | `<InputGroup><InputGroupAddon position="before">¥</InputGroupAddon><InputGroupInput /><InputGroupAddon position="after">USD</InputGroupAddon></InputGroup>` |
|
|
90
|
+
| `<Input addonAfter={<Button>搜索</Button>} />` | `<InputGroup><InputGroupInput /><InputGroupAddon position="after" variant="button"><Button variant="ghost">搜索</Button></InputGroupAddon></InputGroup>` |
|
|
85
91
|
|
|
86
92
|
## Examples
|
|
87
93
|
|
|
88
94
|
```tsx
|
|
89
95
|
import { Input } from '@/components/ui/input';
|
|
90
|
-
import { Search, Mail } from 'lucide-react';
|
|
91
96
|
|
|
92
97
|
// 基础
|
|
93
98
|
<Input placeholder="请输入..." />
|
|
@@ -96,19 +101,15 @@ import { Search, Mail } from 'lucide-react';
|
|
|
96
101
|
const [v, setV] = React.useState('');
|
|
97
102
|
<Input value={v} onChange={(e) => setV(e.target.value)} />
|
|
98
103
|
|
|
99
|
-
// 前置图标
|
|
100
|
-
<Input prefix={<Search />} placeholder="搜索..." />
|
|
101
|
-
|
|
102
104
|
// 可清除 + 字数统计
|
|
103
105
|
<Input clearable showCount maxLength={140} placeholder="动态..." />
|
|
104
106
|
|
|
105
|
-
//
|
|
106
|
-
<Input
|
|
107
|
-
|
|
108
|
-
// 邮箱 + suffix
|
|
109
|
-
<Input type="email" suffix={<Mail />} placeholder="you@example.com" />
|
|
107
|
+
// 错误态
|
|
108
|
+
<Input error placeholder="必填" />
|
|
110
109
|
|
|
111
110
|
// 尺寸
|
|
112
111
|
<Input size="sm" placeholder="紧凑" />
|
|
113
112
|
<Input size="lg" placeholder="宽松" />
|
|
114
113
|
```
|
|
114
|
+
|
|
115
|
+
需要图标 / 协议头 / 内嵌按钮 → 见 [`InputGroup`](../input-group/input-group.meta.md) 与 Storybook `WithInputGroup` 示例。
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import {
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
+
import { Search } from 'lucide-react';
|
|
4
4
|
import { Input } from './input';
|
|
5
|
+
import {
|
|
6
|
+
InputGroup,
|
|
7
|
+
InputGroupAddon,
|
|
8
|
+
InputGroupInput,
|
|
9
|
+
} from '@/components/input-group/input-group';
|
|
5
10
|
|
|
6
11
|
const meta: Meta<typeof Input> = {
|
|
7
|
-
title: '
|
|
12
|
+
title: '数据录入 · Data Entry/Input',
|
|
8
13
|
component: Input,
|
|
9
14
|
tags: ['autodocs'],
|
|
10
15
|
parameters: {
|
|
11
16
|
docs: {
|
|
12
17
|
description: {
|
|
13
18
|
component:
|
|
14
|
-
'输入框 —
|
|
19
|
+
'输入框 — shadcn 简洁基底 + antd 并集中保留为内建逻辑能力的:`size` 三档(sm/md/lg,与 `Button` 同档)、`clearable` 一键清空、`showCount` + `maxLength` 字数统计、`error` / `aria-invalid` 错误态。**前后缀 / 单位 / 协议头 / 内嵌按钮**等"装饰类"形态请用同库 `InputGroup` 复合插槽(见下方 `WithInputGroup` 示例)— 单一职责更清晰,与 shadcn 2025-10 拆分对齐(ADR 0029)。',
|
|
15
20
|
},
|
|
16
21
|
},
|
|
17
22
|
},
|
|
18
23
|
argTypes: {
|
|
19
|
-
size: { control: 'inline-radio', options: ['sm', '
|
|
24
|
+
size: { control: 'inline-radio', options: ['sm', 'md', 'lg'] },
|
|
20
25
|
type: {
|
|
21
26
|
control: 'select',
|
|
22
27
|
options: ['text', 'email', 'password', 'search', 'tel', 'url'],
|
|
@@ -24,15 +29,17 @@ const meta: Meta<typeof Input> = {
|
|
|
24
29
|
clearable: { control: 'boolean' },
|
|
25
30
|
showCount: { control: 'boolean' },
|
|
26
31
|
disabled: { control: 'boolean' },
|
|
32
|
+
error: { control: 'boolean' },
|
|
27
33
|
placeholder: { control: 'text' },
|
|
28
34
|
maxLength: { control: 'number' },
|
|
29
35
|
},
|
|
30
36
|
args: {
|
|
31
|
-
size: '
|
|
37
|
+
size: 'md',
|
|
32
38
|
type: 'text',
|
|
33
39
|
clearable: false,
|
|
34
40
|
showCount: false,
|
|
35
41
|
disabled: false,
|
|
42
|
+
error: false,
|
|
36
43
|
placeholder: '请输入...',
|
|
37
44
|
},
|
|
38
45
|
decorators: [
|
|
@@ -53,35 +60,9 @@ export const Sizes: Story = {
|
|
|
53
60
|
parameters: { controls: { disable: true } },
|
|
54
61
|
render: () => (
|
|
55
62
|
<div className="flex flex-col gap-3">
|
|
56
|
-
<Input size="sm" placeholder="Small" />
|
|
57
|
-
<Input size="
|
|
58
|
-
<Input size="lg" placeholder="Large" />
|
|
59
|
-
</div>
|
|
60
|
-
),
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const PrefixSuffix: Story = {
|
|
64
|
-
parameters: { controls: { disable: true } },
|
|
65
|
-
render: () => (
|
|
66
|
-
<div className="flex flex-col gap-3">
|
|
67
|
-
<Input prefix={<Search />} placeholder="搜索..." />
|
|
68
|
-
<Input type="email" suffix={<Mail />} placeholder="you@example.com" />
|
|
69
|
-
<Input prefix="¥" suffix="USD" placeholder="0.00" />
|
|
70
|
-
</div>
|
|
71
|
-
),
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const Addon: Story = {
|
|
75
|
-
parameters: { controls: { disable: true } },
|
|
76
|
-
render: () => (
|
|
77
|
-
<div className="flex flex-col gap-3">
|
|
78
|
-
<Input
|
|
79
|
-
addonBefore="https://"
|
|
80
|
-
defaultValue="teamix-evo"
|
|
81
|
-
addonAfter=".com"
|
|
82
|
-
/>
|
|
83
|
-
<Input addonBefore="@" placeholder="username" />
|
|
84
|
-
<Input addonAfter="kg" defaultValue="42" />
|
|
63
|
+
<Input size="sm" placeholder="Small (h-6 / text-xs / 24px)" />
|
|
64
|
+
<Input size="md" placeholder="Medium (h-8 / text-xs / 32px)" />
|
|
65
|
+
<Input size="lg" placeholder="Large (h-9 / text-sm / 36px)" />
|
|
85
66
|
</div>
|
|
86
67
|
),
|
|
87
68
|
};
|
|
@@ -106,6 +87,16 @@ export const ShowCount: Story = {
|
|
|
106
87
|
render: () => <Input showCount maxLength={140} placeholder="发布动态" />,
|
|
107
88
|
};
|
|
108
89
|
|
|
90
|
+
export const Error: Story = {
|
|
91
|
+
parameters: { controls: { disable: true } },
|
|
92
|
+
render: () => (
|
|
93
|
+
<div className="flex flex-col gap-3">
|
|
94
|
+
<Input error placeholder="必填" />
|
|
95
|
+
<Input error defaultValue="非法值" />
|
|
96
|
+
</div>
|
|
97
|
+
),
|
|
98
|
+
};
|
|
99
|
+
|
|
109
100
|
export const Disabled: Story = {
|
|
110
101
|
parameters: { controls: { disable: true } },
|
|
111
102
|
render: () => (
|
|
@@ -115,3 +106,39 @@ export const Disabled: Story = {
|
|
|
115
106
|
</div>
|
|
116
107
|
),
|
|
117
108
|
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 想加图标 / 单位 / 协议头?用 `InputGroup` 复合插槽 — 不再用已废弃的
|
|
112
|
+
* `prefix` / `suffix` / `addonBefore` / `addonAfter` 快捷 prop(ADR 0029)。
|
|
113
|
+
*
|
|
114
|
+
* 详细演示与 API 见 `数据录入 · Data Entry/InputGroup` 故事集。
|
|
115
|
+
*/
|
|
116
|
+
export const WithInputGroup: Story = {
|
|
117
|
+
name: '配合 InputGroup(替代旧 prefix/suffix/addon)',
|
|
118
|
+
parameters: { controls: { disable: true } },
|
|
119
|
+
render: () => (
|
|
120
|
+
<div className="flex w-80 flex-col gap-3">
|
|
121
|
+
{/* 图标前缀(替代旧 prefix={<Search />}) */}
|
|
122
|
+
<InputGroup>
|
|
123
|
+
<InputGroupAddon position="before" variant="icon">
|
|
124
|
+
<Search className="size-4" />
|
|
125
|
+
</InputGroupAddon>
|
|
126
|
+
<InputGroupInput placeholder="搜索..." />
|
|
127
|
+
</InputGroup>
|
|
128
|
+
|
|
129
|
+
{/* URL 协议头/后缀(替代旧 addonBefore="https://" addonAfter=".com") */}
|
|
130
|
+
<InputGroup>
|
|
131
|
+
<InputGroupAddon position="before">https://</InputGroupAddon>
|
|
132
|
+
<InputGroupInput defaultValue="example" />
|
|
133
|
+
<InputGroupAddon position="after">.com</InputGroupAddon>
|
|
134
|
+
</InputGroup>
|
|
135
|
+
|
|
136
|
+
{/* 金额/单位(替代旧 prefix="¥" suffix="USD") */}
|
|
137
|
+
<InputGroup>
|
|
138
|
+
<InputGroupAddon position="before">¥</InputGroupAddon>
|
|
139
|
+
<InputGroupInput type="number" defaultValue={199} />
|
|
140
|
+
<InputGroupAddon position="after">/ 月</InputGroupAddon>
|
|
141
|
+
</InputGroup>
|
|
142
|
+
</div>
|
|
143
|
+
),
|
|
144
|
+
};
|