@teamix-evo/ui 0.1.1 → 0.3.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 +680 -492
- package/package.json +20 -10
- package/src/components/accordion/accordion.meta.md +5 -4
- package/src/components/accordion/accordion.stories.tsx +14 -9
- package/src/components/accordion/accordion.tsx +104 -8
- package/src/components/affix/affix.meta.md +20 -2
- package/src/components/affix/affix.stories.tsx +102 -25
- package/src/components/affix/affix.tsx +79 -9
- package/src/components/alert/alert.meta.md +44 -13
- 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 +61 -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 +8 -3
- package/src/components/anchor/anchor.stories.tsx +3 -3
- package/src/components/anchor/anchor.tsx +2 -2
- package/src/components/app/app.meta.md +9 -4
- package/src/components/app/app.stories.tsx +9 -7
- package/src/components/aspect-ratio/aspect-ratio.meta.md +4 -3
- package/src/components/aspect-ratio/aspect-ratio.stories.tsx +3 -3
- package/src/components/auto-complete/auto-complete.meta.md +14 -6
- package/src/components/auto-complete/auto-complete.stories.tsx +47 -4
- package/src/components/auto-complete/auto-complete.tsx +119 -71
- package/src/components/avatar/avatar.meta.md +6 -7
- package/src/components/avatar/avatar.stories.tsx +21 -3
- package/src/components/avatar/avatar.tsx +24 -23
- package/src/components/badge/badge.meta.md +10 -9
- package/src/components/badge/badge.stories.tsx +2 -2
- package/src/components/badge/badge.tsx +9 -15
- package/src/components/breadcrumb/breadcrumb.meta.md +27 -7
- package/src/components/breadcrumb/breadcrumb.stories.tsx +127 -4
- package/src/components/breadcrumb/breadcrumb.tsx +22 -8
- package/src/components/button/button.meta.md +258 -21
- package/src/components/button/button.stories.tsx +549 -41
- package/src/components/button/button.tsx +335 -33
- package/src/components/button/demo/as-child.tsx +24 -0
- package/src/components/button/demo/basic.tsx +8 -0
- package/src/components/button/demo/block.tsx +16 -0
- package/src/components/button/demo/loading.tsx +19 -0
- package/src/components/button/demo/shapes.tsx +18 -0
- package/src/components/button/demo/sizes.tsx +19 -0
- package/src/components/button/demo/variants.tsx +19 -0
- package/src/components/button/demo/with-icon.tsx +20 -0
- package/src/components/calendar/calendar.meta.md +13 -3
- package/src/components/calendar/calendar.stories.tsx +6 -6
- package/src/components/calendar/calendar.tsx +73 -8
- package/src/components/card/card.meta.md +27 -5
- package/src/components/card/card.stories.tsx +42 -3
- package/src/components/card/card.tsx +146 -63
- package/src/components/carousel/carousel.meta.md +4 -3
- package/src/components/carousel/carousel.stories.tsx +11 -6
- package/src/components/cascader/cascader.meta.md +47 -17
- package/src/components/cascader/cascader.stories.tsx +22 -10
- package/src/components/cascader/cascader.tsx +428 -85
- package/src/components/checkbox/checkbox.meta.md +75 -7
- package/src/components/checkbox/checkbox.stories.tsx +161 -3
- package/src/components/checkbox/checkbox.tsx +77 -9
- package/src/components/collapsible/collapsible.meta.md +14 -6
- package/src/components/collapsible/collapsible.stories.tsx +10 -2
- package/src/components/collapsible/collapsible.tsx +93 -6
- package/src/components/color-picker/color-picker.meta.md +12 -7
- package/src/components/color-picker/color-picker.stories.tsx +86 -7
- package/src/components/color-picker/color-picker.tsx +20 -9
- package/src/components/command/command.meta.md +29 -13
- package/src/components/command/command.stories.tsx +4 -4
- package/src/components/command/command.tsx +19 -8
- package/src/components/context-menu/context-menu.meta.md +11 -8
- package/src/components/context-menu/context-menu.stories.tsx +11 -3
- package/src/components/context-menu/context-menu.tsx +21 -8
- package/src/components/data-table/data-table.meta.md +6 -5
- package/src/components/data-table/data-table.stories.tsx +13 -6
- package/src/components/data-table/data-table.tsx +2 -2
- package/src/components/date-picker/date-picker.meta.md +88 -19
- 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 +10 -5
- package/src/components/descriptions/descriptions.stories.tsx +3 -3
- package/src/components/descriptions/descriptions.tsx +22 -14
- package/src/components/dialog/dialog.meta.md +76 -13
- 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 +33 -34
- package/src/components/drawer/drawer.stories.tsx +29 -12
- package/src/components/drawer/drawer.tsx +22 -113
- package/src/components/dropdown-menu/dropdown-menu.meta.md +78 -10
- package/src/components/dropdown-menu/dropdown-menu.stories.tsx +88 -2
- 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 +9 -4
- package/src/components/empty/empty.stories.tsx +4 -4
- package/src/components/empty/empty.tsx +10 -3
- package/src/components/field/field.meta.md +47 -9
- package/src/components/field/field.stories.tsx +385 -5
- 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 +1083 -0
- package/src/components/filter-bar/filter-bar.tsx +568 -0
- package/src/components/flex/flex.meta.md +54 -6
- package/src/components/flex/flex.stories.tsx +107 -20
- package/src/components/flex/flex.tsx +27 -4
- package/src/components/float-button/float-button.meta.md +8 -3
- package/src/components/float-button/float-button.stories.tsx +9 -7
- package/src/components/float-button/float-button.tsx +1 -1
- package/src/components/form/form.meta.md +39 -17
- package/src/components/form/form.stories.tsx +350 -3
- package/src/components/form/form.tsx +101 -35
- package/src/components/grid/grid.meta.md +7 -2
- package/src/components/grid/grid.stories.tsx +6 -4
- package/src/components/hover-card/hover-card.meta.md +20 -9
- package/src/components/hover-card/hover-card.stories.tsx +34 -5
- 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 +9 -4
- package/src/components/image/image.stories.tsx +3 -3
- package/src/components/image/image.tsx +6 -4
- package/src/components/input/demo/basic.tsx +12 -0
- package/src/components/input/demo/clearable.tsx +21 -0
- package/src/components/input/demo/show-count.tsx +18 -0
- package/src/components/input/demo/sizes.tsx +15 -0
- package/src/components/input/input.meta.md +39 -33
- package/src/components/input/input.stories.tsx +62 -35
- package/src/components/input/input.tsx +97 -98
- package/src/components/input-group/input-group.meta.md +54 -22
- package/src/components/input-group/input-group.stories.tsx +49 -16
- package/src/components/input-group/input-group.tsx +44 -8
- package/src/components/input-number/input-number.meta.md +64 -7
- package/src/components/input-number/input-number.stories.tsx +46 -8
- package/src/components/input-number/input-number.tsx +99 -26
- package/src/components/input-otp/input-otp.meta.md +4 -3
- 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 -3
- package/src/components/item/item.stories.tsx +8 -5
- package/src/components/item/item.tsx +7 -6
- package/src/components/kbd/kbd.meta.md +13 -4
- package/src/components/kbd/kbd.stories.tsx +4 -4
- package/src/components/kbd/kbd.tsx +10 -5
- package/src/components/label/label.meta.md +18 -10
- 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 -3
- package/src/components/masonry/masonry.stories.tsx +7 -5
- package/src/components/masonry/masonry.tsx +1 -0
- package/src/components/mentions/mentions.meta.md +36 -6
- package/src/components/mentions/mentions.stories.tsx +120 -6
- package/src/components/mentions/mentions.tsx +11 -5
- package/src/components/menubar/menubar.meta.md +30 -12
- package/src/components/menubar/menubar.stories.tsx +62 -2
- package/src/components/menubar/menubar.tsx +9 -9
- package/src/components/native-select/native-select.meta.md +8 -3
- package/src/components/native-select/native-select.stories.tsx +8 -5
- package/src/components/native-select/native-select.tsx +1 -1
- package/src/components/navigation-menu/navigation-menu.meta.md +19 -9
- package/src/components/navigation-menu/navigation-menu.stories.tsx +112 -9
- package/src/components/navigation-menu/navigation-menu.tsx +8 -4
- package/src/components/notification/notification.meta.md +52 -10
- package/src/components/notification/notification.stories.tsx +11 -9
- package/src/components/notification/notification.tsx +36 -21
- package/src/components/page-header/DEVELOPMENT.md +842 -0
- package/src/components/page-header/page-header.meta.md +208 -0
- package/src/components/page-header/page-header.stories.tsx +421 -0
- package/src/components/page-header/page-header.tsx +281 -0
- package/src/components/pagination/pagination.meta.md +140 -37
- package/src/components/pagination/pagination.stories.tsx +232 -10
- package/src/components/pagination/pagination.tsx +355 -63
- package/src/components/popconfirm/popconfirm.meta.md +9 -4
- package/src/components/popconfirm/popconfirm.stories.tsx +3 -4
- package/src/components/popconfirm/popconfirm.tsx +2 -2
- package/src/components/popover/popover.meta.md +62 -5
- package/src/components/popover/popover.stories.tsx +83 -7
- package/src/components/popover/popover.tsx +77 -28
- package/src/components/progress/progress.meta.md +38 -6
- package/src/components/progress/progress.stories.tsx +3 -3
- package/src/components/progress/progress.tsx +24 -16
- package/src/components/radio-group/radio-group.meta.md +79 -7
- package/src/components/radio-group/radio-group.stories.tsx +39 -3
- package/src/components/radio-group/radio-group.tsx +149 -18
- package/src/components/rate/rate.meta.md +35 -4
- package/src/components/rate/rate.stories.tsx +13 -5
- package/src/components/rate/rate.tsx +37 -10
- package/src/components/resizable/resizable.meta.md +7 -4
- package/src/components/resizable/resizable.stories.tsx +6 -6
- package/src/components/resizable/resizable.tsx +1 -1
- package/src/components/result/result.meta.md +7 -2
- package/src/components/result/result.stories.tsx +4 -8
- package/src/components/result/result.tsx +24 -15
- package/src/components/scroll-area/scroll-area.meta.md +4 -3
- package/src/components/scroll-area/scroll-area.stories.tsx +12 -4
- package/src/components/scroll-area/scroll-area.tsx +3 -3
- package/src/components/segmented/segmented.meta.md +7 -4
- package/src/components/segmented/segmented.stories.tsx +37 -8
- package/src/components/segmented/segmented.tsx +15 -7
- package/src/components/select/select.meta.md +197 -52
- package/src/components/select/select.stories.tsx +238 -63
- package/src/components/select/select.tsx +718 -171
- package/src/components/separator/separator.meta.md +4 -3
- package/src/components/separator/separator.stories.tsx +3 -3
- package/src/components/separator/separator.tsx +3 -7
- package/src/components/sheet/sheet.meta.md +32 -16
- package/src/components/sheet/sheet.stories.tsx +116 -10
- package/src/components/sheet/sheet.tsx +116 -29
- package/src/components/sidebar/sidebar.meta.md +37 -18
- package/src/components/sidebar/sidebar.stories.tsx +701 -29
- package/src/components/sidebar/sidebar.tsx +615 -142
- package/src/components/skeleton/skeleton.meta.md +4 -5
- package/src/components/skeleton/skeleton.stories.tsx +4 -4
- package/src/components/skeleton/skeleton.tsx +7 -7
- package/src/components/slider/slider.meta.md +57 -5
- package/src/components/slider/slider.stories.tsx +58 -6
- package/src/components/slider/slider.tsx +154 -13
- package/src/components/sonner/sonner.meta.md +58 -7
- package/src/components/sonner/sonner.stories.tsx +78 -5
- package/src/components/sonner/sonner.tsx +137 -8
- package/src/components/spinner/spinner.meta.md +62 -13
- package/src/components/spinner/spinner.stories.tsx +66 -14
- package/src/components/spinner/spinner.tsx +111 -9
- package/src/components/statistic/statistic.meta.md +7 -2
- package/src/components/statistic/statistic.stories.tsx +3 -7
- package/src/components/statistic/statistic.tsx +5 -6
- package/src/components/steps/steps.meta.md +18 -4
- package/src/components/steps/steps.stories.tsx +43 -3
- package/src/components/steps/steps.tsx +15 -12
- package/src/components/switch/switch.meta.md +51 -5
- package/src/components/switch/switch.stories.tsx +6 -6
- package/src/components/switch/switch.tsx +109 -41
- package/src/components/table/table.meta.md +17 -6
- package/src/components/table/table.stories.tsx +10 -5
- package/src/components/table/table.tsx +4 -4
- package/src/components/tabs/tabs.meta.md +38 -25
- package/src/components/tabs/tabs.stories.tsx +111 -25
- package/src/components/tabs/tabs.tsx +125 -54
- package/src/components/tag/tag.meta.md +105 -40
- package/src/components/tag/tag.stories.tsx +189 -16
- package/src/components/tag/tag.tsx +222 -21
- package/src/components/textarea/textarea.meta.md +35 -19
- package/src/components/textarea/textarea.stories.tsx +32 -6
- package/src/components/textarea/textarea.tsx +33 -9
- package/src/components/time-picker/time-picker.meta.md +124 -32
- package/src/components/time-picker/time-picker.stories.tsx +85 -15
- package/src/components/time-picker/time-picker.tsx +913 -61
- package/src/components/timeline/timeline.meta.md +14 -6
- package/src/components/timeline/timeline.stories.tsx +37 -7
- package/src/components/timeline/timeline.tsx +35 -14
- package/src/components/toggle/toggle.meta.md +5 -4
- 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 +5 -4
- 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 +55 -5
- package/src/components/tooltip/tooltip.stories.tsx +42 -5
- package/src/components/tooltip/tooltip.tsx +81 -21
- package/src/components/tour/tour.meta.md +9 -4
- package/src/components/tour/tour.stories.tsx +3 -3
- package/src/components/tour/tour.tsx +4 -4
- package/src/components/transfer/transfer.meta.md +11 -6
- package/src/components/transfer/transfer.stories.tsx +4 -8
- package/src/components/transfer/transfer.tsx +28 -21
- package/src/components/tree/tree.meta.md +63 -5
- package/src/components/tree/tree.stories.tsx +31 -12
- package/src/components/tree/tree.tsx +9 -8
- package/src/components/tree-select/tree-select.meta.md +59 -8
- package/src/components/tree-select/tree-select.stories.tsx +3 -3
- package/src/components/tree-select/tree-select.tsx +42 -7
- package/src/components/typography/typography.meta.md +61 -14
- package/src/components/typography/typography.stories.tsx +12 -11
- package/src/components/typography/typography.tsx +43 -28
- package/src/components/upload/upload.meta.md +49 -4
- package/src/components/upload/upload.stories.tsx +72 -12
- package/src/components/upload/upload.tsx +170 -37
- package/src/components/watermark/watermark.meta.md +7 -2
- package/src/components/watermark/watermark.stories.tsx +101 -9
- package/src/components/watermark/watermark.tsx +1 -0
- 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 +53 -0
- package/src/components/button-group/button-group.meta.md +0 -92
- package/src/components/button-group/button-group.stories.tsx +0 -90
- package/src/components/button-group/button-group.tsx +0 -75
- package/src/components/combobox/combobox.meta.md +0 -93
- package/src/components/combobox/combobox.stories.tsx +0 -55
- package/src/components/combobox/combobox.tsx +0 -130
- package/src/components/space/space.meta.md +0 -94
- package/src/components/space/space.stories.tsx +0 -94
- package/src/components/space/space.tsx +0 -106
|
@@ -1,31 +1,56 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
+
import {
|
|
4
|
+
ArrowRight,
|
|
5
|
+
ChevronDown,
|
|
6
|
+
ChevronRight,
|
|
7
|
+
Download,
|
|
8
|
+
Heart,
|
|
9
|
+
Plus,
|
|
10
|
+
Search,
|
|
11
|
+
Trash,
|
|
12
|
+
X,
|
|
13
|
+
} from 'lucide-react';
|
|
14
|
+
import { Button, ButtonGroup, ButtonGroupText } from './button';
|
|
15
|
+
import { Input } from '@/components/input/input';
|
|
16
|
+
import {
|
|
17
|
+
DropdownMenu,
|
|
18
|
+
DropdownMenuTrigger,
|
|
19
|
+
DropdownMenuContent,
|
|
20
|
+
DropdownMenuItem,
|
|
21
|
+
DropdownMenuSeparator,
|
|
22
|
+
DropdownMenuCheckboxItem,
|
|
23
|
+
DropdownMenuRadioGroup,
|
|
24
|
+
DropdownMenuRadioItem,
|
|
25
|
+
DropdownMenuLabel,
|
|
26
|
+
} from '@/components/dropdown-menu/dropdown-menu';
|
|
27
|
+
import * as React from 'react';
|
|
5
28
|
|
|
6
29
|
/**
|
|
7
|
-
* Storybook Controls
|
|
8
|
-
*
|
|
9
|
-
* dropdown of icon names; the underlying prop receives the actual element.
|
|
30
|
+
* Storybook Controls 不能直接编辑 ReactNode,这里用字符串 key 通过 `mapping`
|
|
31
|
+
* 映射到真实 ReactNode — 编辑面板看到的是图标名下拉,实际 prop 收到 element。
|
|
10
32
|
*/
|
|
11
33
|
const iconMap: Record<string, ReactNode> = {
|
|
12
34
|
none: undefined,
|
|
35
|
+
arrowRight: <ArrowRight />,
|
|
13
36
|
chevronRight: <ChevronRight />,
|
|
14
37
|
download: <Download />,
|
|
38
|
+
heart: <Heart />,
|
|
15
39
|
plus: <Plus />,
|
|
40
|
+
search: <Search />,
|
|
16
41
|
trash: <Trash />,
|
|
17
42
|
x: <X />,
|
|
18
43
|
};
|
|
19
44
|
|
|
20
45
|
const meta: Meta<typeof Button> = {
|
|
21
|
-
title: '
|
|
46
|
+
title: '通用 · General/Button',
|
|
22
47
|
component: Button,
|
|
23
48
|
tags: ['autodocs'],
|
|
24
49
|
parameters: {
|
|
25
50
|
docs: {
|
|
26
51
|
description: {
|
|
27
52
|
component:
|
|
28
|
-
'
|
|
53
|
+
'Button 按钮 —— 触发即时动作的最基础交互原子(提交、删除、跳转、加载)。shadcn 实现底座 + cloud-design 能力并集:`variant`(7 档形态)/ `color`(ADR 0021 语义色双 prop,与 variant 组合表达"语义×视觉")/ `size`(sm/md/lg/icon,可由 `<ButtonGroup size>` 注入)/ `shape`(default/round/circle/square)/ `loading`(自动 disabled+aria-busy+spinner)/ `icon` + `iconRight`(双 slot)/ `block`(撑满)/ `asChild`(Radix Slot 渲染为 `<a>` 等)/ `disabledTooltip`(禁用态解释文案,wrapper 拾取 hover)。组件合一:`ButtonGroup` + `ButtonGroupText` 同文件导出,等价 antd `Space.Compact`,支持 SplitButton、Toolbar、Input addon 等组合形态。视觉走 semantic tokens,圆角走 Tailwind 标准 `rounded-md`(消费 `--radius-md`),高度 24/32/36(`h-6/h-8/h-9`)、字重 `font-normal`、padding `px-3`、icon-text `gap-1` 全部直接走 Tailwind utility;uni-manager 主题下对齐 cloud-design hybridcloud 视觉(圆角 2px、字重 400、sm 24px)。',
|
|
29
54
|
},
|
|
30
55
|
},
|
|
31
56
|
},
|
|
@@ -43,15 +68,21 @@ const meta: Meta<typeof Button> = {
|
|
|
43
68
|
'link',
|
|
44
69
|
],
|
|
45
70
|
},
|
|
71
|
+
color: {
|
|
72
|
+
description:
|
|
73
|
+
'语义色(ADR 0021),与 variant 双 prop 组合;outline+destructive 即旧库 warning+outline',
|
|
74
|
+
control: 'inline-radio',
|
|
75
|
+
options: ['default', 'primary', 'destructive'],
|
|
76
|
+
},
|
|
46
77
|
size: {
|
|
47
|
-
description: '尺寸,`icon` 为正方形纯图标按钮',
|
|
78
|
+
description: '尺寸,`md` ≡ `default`,`icon` 为正方形纯图标按钮',
|
|
48
79
|
control: 'select',
|
|
49
|
-
options: ['sm', 'default', 'lg', 'icon'],
|
|
80
|
+
options: ['sm', 'md', 'default', 'lg', 'icon'],
|
|
50
81
|
},
|
|
51
82
|
shape: {
|
|
52
|
-
description: '形状,`circle`
|
|
83
|
+
description: '形状,`circle` / `square` 必须配 `size="icon"`',
|
|
53
84
|
control: 'select',
|
|
54
|
-
options: ['default', 'round', 'circle'],
|
|
85
|
+
options: ['default', 'round', 'circle', 'square'],
|
|
55
86
|
},
|
|
56
87
|
block: {
|
|
57
88
|
description: '`true` 时撑满父容器宽度',
|
|
@@ -62,35 +93,64 @@ const meta: Meta<typeof Button> = {
|
|
|
62
93
|
control: 'boolean',
|
|
63
94
|
},
|
|
64
95
|
iconPosition: {
|
|
65
|
-
description: '
|
|
96
|
+
description: '兼容旧 API,新代码请用 `icon` / `iconRight` 双 slot',
|
|
66
97
|
control: 'inline-radio',
|
|
67
98
|
options: ['start', 'end'],
|
|
68
99
|
},
|
|
69
100
|
icon: {
|
|
70
|
-
description: '
|
|
101
|
+
description: '左侧图标(从 lucide-react 选择,演示用 mapping)',
|
|
102
|
+
options: Object.keys(iconMap),
|
|
103
|
+
mapping: iconMap,
|
|
104
|
+
control: {
|
|
105
|
+
type: 'select',
|
|
106
|
+
labels: {
|
|
107
|
+
none: '无',
|
|
108
|
+
arrowRight: '→ ArrowRight',
|
|
109
|
+
chevronRight: '→ ChevronRight',
|
|
110
|
+
download: '⬇ Download',
|
|
111
|
+
heart: '♥ Heart',
|
|
112
|
+
plus: '+ Plus',
|
|
113
|
+
search: '🔍 Search',
|
|
114
|
+
trash: '🗑 Trash',
|
|
115
|
+
x: '✕ X',
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
iconRight: {
|
|
120
|
+
description: '右侧图标(双 slot,可与 `icon` 共存)',
|
|
71
121
|
options: Object.keys(iconMap),
|
|
72
122
|
mapping: iconMap,
|
|
73
123
|
control: {
|
|
74
124
|
type: 'select',
|
|
75
125
|
labels: {
|
|
76
126
|
none: '无',
|
|
127
|
+
arrowRight: '→ ArrowRight',
|
|
77
128
|
chevronRight: '→ ChevronRight',
|
|
78
129
|
download: '⬇ Download',
|
|
130
|
+
heart: '♥ Heart',
|
|
79
131
|
plus: '+ Plus',
|
|
132
|
+
search: '🔍 Search',
|
|
80
133
|
trash: '🗑 Trash',
|
|
81
134
|
x: '✕ X',
|
|
82
135
|
},
|
|
83
136
|
},
|
|
84
137
|
},
|
|
85
138
|
asChild: {
|
|
86
|
-
description:
|
|
139
|
+
description:
|
|
140
|
+
'用 Radix Slot 渲染为子元素(忽略 loading / icon / iconRight)',
|
|
87
141
|
control: 'boolean',
|
|
88
142
|
},
|
|
89
143
|
disabled: { control: 'boolean' },
|
|
144
|
+
disabledTooltip: {
|
|
145
|
+
description:
|
|
146
|
+
'禁用解释文案,仅在 `disabled` 同时存在时生效,内部用 cursor-not-allowed wrapper + Tooltip 拾取 hover',
|
|
147
|
+
control: 'text',
|
|
148
|
+
},
|
|
90
149
|
},
|
|
91
150
|
args: {
|
|
92
151
|
children: 'Button',
|
|
93
152
|
variant: 'default',
|
|
153
|
+
color: 'default',
|
|
94
154
|
size: 'default',
|
|
95
155
|
shape: 'default',
|
|
96
156
|
block: false,
|
|
@@ -107,37 +167,38 @@ type Story = StoryObj<typeof Button>;
|
|
|
107
167
|
// ─── Single-knob stories: editable via the Controls panel ─────────────────────
|
|
108
168
|
|
|
109
169
|
/**
|
|
110
|
-
*
|
|
111
|
-
* 全部 props,即时预览。这是最常用的演示形态。
|
|
170
|
+
* 默认按钮。Controls 面板可调全部 props,即时预览。
|
|
112
171
|
*/
|
|
113
172
|
export const Playground: Story = {
|
|
114
|
-
args: {
|
|
173
|
+
args: {
|
|
174
|
+
children: 'Submit',
|
|
175
|
+
block: false,
|
|
176
|
+
},
|
|
115
177
|
};
|
|
116
178
|
|
|
117
179
|
/**
|
|
118
|
-
*
|
|
119
|
-
* destructive 配色;不要硬编码 `bg-red-600`。
|
|
180
|
+
* 危险动作按钮 — 视觉用 `destructive` variant,不要硬编码 `bg-red-600`。
|
|
120
181
|
*/
|
|
121
182
|
export const Destructive: Story = {
|
|
122
183
|
args: { children: 'Delete', variant: 'destructive' },
|
|
123
184
|
};
|
|
124
185
|
|
|
125
186
|
/**
|
|
126
|
-
* Loading
|
|
187
|
+
* Loading 态 — 自动 `disabled` + `aria-busy=true` + spinner 替换左侧 icon,
|
|
188
|
+
* 视觉宽度保持以避免布局抖动。
|
|
127
189
|
*/
|
|
128
190
|
export const Loading: Story = {
|
|
129
191
|
args: { children: 'Saving', loading: true },
|
|
130
192
|
};
|
|
131
193
|
|
|
132
194
|
/**
|
|
133
|
-
*
|
|
134
|
-
* 位于文本前(start)还是后(end)。
|
|
195
|
+
* 双 slot icon — `icon` 左、`iconRight` 右,可同时存在。
|
|
135
196
|
*/
|
|
136
|
-
export const
|
|
197
|
+
export const WithIcons: Story = {
|
|
137
198
|
args: {
|
|
138
199
|
children: 'Next step',
|
|
139
|
-
icon: <
|
|
140
|
-
|
|
200
|
+
icon: <Search />,
|
|
201
|
+
iconRight: <ArrowRight />,
|
|
141
202
|
},
|
|
142
203
|
};
|
|
143
204
|
|
|
@@ -149,6 +210,34 @@ export const Block: Story = {
|
|
|
149
210
|
decorators: [(Story) => <div style={{ width: 360 }}>{Story()}</div>],
|
|
150
211
|
};
|
|
151
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Icon-only:无 children 仅传 `icon`,组件自动收紧 padding;
|
|
215
|
+
* 配合 `shape="circle"` / `"square"` + `size="icon"` 得到等宽等高图标按钮。
|
|
216
|
+
*/
|
|
217
|
+
export const IconOnly: Story = {
|
|
218
|
+
parameters: { controls: { disable: true } },
|
|
219
|
+
render: () => (
|
|
220
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
221
|
+
<Button size="icon" aria-label="Add" icon={<Plus />} />
|
|
222
|
+
<Button size="icon" shape="circle" aria-label="Like" icon={<Heart />} />
|
|
223
|
+
<Button
|
|
224
|
+
size="icon"
|
|
225
|
+
shape="square"
|
|
226
|
+
variant="outline"
|
|
227
|
+
aria-label="Search"
|
|
228
|
+
icon={<Search />}
|
|
229
|
+
/>
|
|
230
|
+
<Button
|
|
231
|
+
size="icon"
|
|
232
|
+
shape="circle"
|
|
233
|
+
variant="ghost"
|
|
234
|
+
aria-label="Close"
|
|
235
|
+
icon={<X />}
|
|
236
|
+
/>
|
|
237
|
+
</div>
|
|
238
|
+
),
|
|
239
|
+
};
|
|
240
|
+
|
|
152
241
|
// ─── Visual reference stories: comparison tables, no Controls ─────────────────
|
|
153
242
|
|
|
154
243
|
/**
|
|
@@ -171,24 +260,24 @@ export const VariantsMatrix: Story = {
|
|
|
171
260
|
};
|
|
172
261
|
|
|
173
262
|
/**
|
|
174
|
-
*
|
|
263
|
+
* 三档尺寸(`sm` 24px / `md`(`default`) 32px / `lg` 36px) + `icon`。
|
|
264
|
+
* cva 直接走 `h-6/h-8/h-9` Tailwind utility,与 Input / Select / DatePicker 同档。
|
|
175
265
|
*/
|
|
176
266
|
export const SizesMatrix: Story = {
|
|
177
267
|
parameters: { controls: { disable: true } },
|
|
178
268
|
render: () => (
|
|
179
269
|
<div className="flex flex-wrap items-center gap-3">
|
|
180
|
-
<Button size="sm">Small</Button>
|
|
181
|
-
<Button size="
|
|
182
|
-
<Button size="lg">Large</Button>
|
|
183
|
-
<Button size="icon" aria-label="Add"
|
|
184
|
-
<Plus />
|
|
185
|
-
</Button>
|
|
270
|
+
<Button size="sm">Small (24)</Button>
|
|
271
|
+
<Button size="md">Medium (32)</Button>
|
|
272
|
+
<Button size="lg">Large (36)</Button>
|
|
273
|
+
<Button size="icon" aria-label="Add" icon={<Plus />} />
|
|
186
274
|
</div>
|
|
187
275
|
),
|
|
188
276
|
};
|
|
189
277
|
|
|
190
278
|
/**
|
|
191
|
-
*
|
|
279
|
+
* 四种 shape(`default / round / circle / square`)。
|
|
280
|
+
* `circle` / `square` 必须配 `size="icon"`。
|
|
192
281
|
*/
|
|
193
282
|
export const ShapesMatrix: Story = {
|
|
194
283
|
parameters: { controls: { disable: true } },
|
|
@@ -196,16 +285,20 @@ export const ShapesMatrix: Story = {
|
|
|
196
285
|
<div className="flex flex-wrap items-center gap-3">
|
|
197
286
|
<Button shape="default">Default</Button>
|
|
198
287
|
<Button shape="round">Round</Button>
|
|
199
|
-
<Button size="icon" shape="circle" aria-label="
|
|
200
|
-
|
|
201
|
-
|
|
288
|
+
<Button size="icon" shape="circle" aria-label="Like" icon={<Heart />} />
|
|
289
|
+
<Button
|
|
290
|
+
size="icon"
|
|
291
|
+
shape="square"
|
|
292
|
+
aria-label="Search"
|
|
293
|
+
icon={<Search />}
|
|
294
|
+
/>
|
|
202
295
|
</div>
|
|
203
296
|
),
|
|
204
297
|
};
|
|
205
298
|
|
|
206
299
|
/**
|
|
207
|
-
* 状态对照:常态 / 禁用 /
|
|
208
|
-
* `disabled`。
|
|
300
|
+
* 状态对照:常态 / 禁用 / 加载 / 加载替换 icon。
|
|
301
|
+
* loading 自动 disabled,不要再传 `disabled`。
|
|
209
302
|
*/
|
|
210
303
|
export const StatesMatrix: Story = {
|
|
211
304
|
parameters: { controls: { disable: true } },
|
|
@@ -215,15 +308,39 @@ export const StatesMatrix: Story = {
|
|
|
215
308
|
<Button disabled>Disabled</Button>
|
|
216
309
|
<Button loading>Loading</Button>
|
|
217
310
|
<Button variant="outline" loading icon={<Download />}>
|
|
218
|
-
Loading replaces icon
|
|
311
|
+
Loading replaces left icon
|
|
219
312
|
</Button>
|
|
220
313
|
</div>
|
|
221
314
|
),
|
|
222
315
|
};
|
|
223
316
|
|
|
317
|
+
/**
|
|
318
|
+
* 双 slot 组合演示:同一按钮同时挂左右图标,适合 prefix + suffix 类操作
|
|
319
|
+
* (例如「下载」+「外部链接」)。
|
|
320
|
+
*/
|
|
321
|
+
export const DualSlots: Story = {
|
|
322
|
+
parameters: { controls: { disable: true } },
|
|
323
|
+
render: () => (
|
|
324
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
325
|
+
<Button icon={<Download />} iconRight={<ArrowRight />}>
|
|
326
|
+
Download & continue
|
|
327
|
+
</Button>
|
|
328
|
+
<Button variant="outline" icon={<Search />} iconRight={<ChevronRight />}>
|
|
329
|
+
Search docs
|
|
330
|
+
</Button>
|
|
331
|
+
<Button
|
|
332
|
+
variant="ghost"
|
|
333
|
+
icon={<Heart />}
|
|
334
|
+
iconRight={<Plus />}
|
|
335
|
+
aria-label="Like and add"
|
|
336
|
+
/>
|
|
337
|
+
</div>
|
|
338
|
+
),
|
|
339
|
+
};
|
|
340
|
+
|
|
224
341
|
/**
|
|
225
342
|
* `asChild` 模式:把按钮视觉应用到子元素,常见用法是渲染为 `<a>` 链接。
|
|
226
|
-
* 注意此模式下 `loading`
|
|
343
|
+
* 注意此模式下 `loading` / `icon` / `iconRight` 会被忽略。
|
|
227
344
|
*/
|
|
228
345
|
export const AsChild: Story = {
|
|
229
346
|
parameters: { controls: { disable: true } },
|
|
@@ -233,3 +350,394 @@ export const AsChild: Story = {
|
|
|
233
350
|
</Button>
|
|
234
351
|
),
|
|
235
352
|
};
|
|
353
|
+
|
|
354
|
+
// ─── New stories added during Button MVP 优化对齐 ─────────────────────────────
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* ADR 0021 双 prop 组合 — 用 `variant="outline" color="destructive"` 表达
|
|
358
|
+
* 旧库 cloud-design `type="normal" warning` 的语义,而不是新增 variant。
|
|
359
|
+
* 同样支持 `variant="ghost" color="destructive"`(轻量删除)等组合。
|
|
360
|
+
*/
|
|
361
|
+
export const WarningOutline: Story = {
|
|
362
|
+
parameters: { controls: { disable: true } },
|
|
363
|
+
render: () => (
|
|
364
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
365
|
+
<Button variant="outline" color="destructive" icon={<Trash />}>
|
|
366
|
+
删除
|
|
367
|
+
</Button>
|
|
368
|
+
<Button variant="ghost" color="destructive">
|
|
369
|
+
移除关联
|
|
370
|
+
</Button>
|
|
371
|
+
<Button variant="link" color="destructive">
|
|
372
|
+
解除绑定
|
|
373
|
+
</Button>
|
|
374
|
+
</div>
|
|
375
|
+
),
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* 禁用 + 解释文案 — `disabled` + `disabledTooltip` 触发 cursor-not-allowed
|
|
380
|
+
* wrapper + Tooltip;wrapper 拾取 hover,button 自身 pointer-events 关闭。
|
|
381
|
+
* 不传 `disabledTooltip` 时保持原生 disabled 行为不变。
|
|
382
|
+
*/
|
|
383
|
+
export const DisabledWithTooltip: Story = {
|
|
384
|
+
parameters: { controls: { disable: true } },
|
|
385
|
+
render: () => (
|
|
386
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
387
|
+
<Button disabled disabledTooltip="无权限操作,请联系管理员">
|
|
388
|
+
发布
|
|
389
|
+
</Button>
|
|
390
|
+
<Button
|
|
391
|
+
variant="outline"
|
|
392
|
+
disabled
|
|
393
|
+
disabledTooltip="尚未选中任何条目"
|
|
394
|
+
icon={<Trash />}
|
|
395
|
+
>
|
|
396
|
+
批量删除
|
|
397
|
+
</Button>
|
|
398
|
+
</div>
|
|
399
|
+
),
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* ghost / link text 按钮 — 高度跟随主 size 档(24/32/36),与其他 variant 一致;
|
|
404
|
+
* 区别在于去除背景/边框与收紧水平 padding(ghost px-1 / link px-0)。
|
|
405
|
+
* (早期版本曾使用 18/20px 独立紧凑高度,D1 决策后取消)
|
|
406
|
+
*/
|
|
407
|
+
export const TextCompactSizes: Story = {
|
|
408
|
+
parameters: { controls: { disable: true } },
|
|
409
|
+
render: () => (
|
|
410
|
+
<div className="flex flex-col items-start gap-4">
|
|
411
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
412
|
+
<Button variant="ghost" size="sm">
|
|
413
|
+
Ghost sm (24)
|
|
414
|
+
</Button>
|
|
415
|
+
<Button variant="ghost" size="md">
|
|
416
|
+
Ghost md (32)
|
|
417
|
+
</Button>
|
|
418
|
+
<Button variant="ghost" size="lg">
|
|
419
|
+
Ghost lg (36)
|
|
420
|
+
</Button>
|
|
421
|
+
</div>
|
|
422
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
423
|
+
<Button variant="link" size="sm">
|
|
424
|
+
Link sm
|
|
425
|
+
</Button>
|
|
426
|
+
<Button variant="link" size="md">
|
|
427
|
+
Link md
|
|
428
|
+
</Button>
|
|
429
|
+
<Button variant="link" size="lg">
|
|
430
|
+
Link lg
|
|
431
|
+
</Button>
|
|
432
|
+
</div>
|
|
433
|
+
</div>
|
|
434
|
+
),
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
// ─── ButtonGroup stories (合并自 button-group.stories.tsx) ────────────────────
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* ButtonGroup 基础形态 — 把多个 `Button` / `Input` 包在一起共享边线,
|
|
441
|
+
* `attached`(默认 true)等价 antd `Space.Compact`,`false` 时按钮间留 8px。
|
|
442
|
+
*/
|
|
443
|
+
export const GroupPlayground: StoryObj<typeof ButtonGroup> = {
|
|
444
|
+
args: { orientation: 'horizontal', attached: true },
|
|
445
|
+
argTypes: {
|
|
446
|
+
orientation: {
|
|
447
|
+
control: 'inline-radio',
|
|
448
|
+
options: ['horizontal', 'vertical'],
|
|
449
|
+
},
|
|
450
|
+
attached: { control: 'boolean' },
|
|
451
|
+
},
|
|
452
|
+
render: (args) => (
|
|
453
|
+
<ButtonGroup {...args}>
|
|
454
|
+
<Button variant="outline">左</Button>
|
|
455
|
+
<Button variant="outline">中</Button>
|
|
456
|
+
<Button variant="outline">右</Button>
|
|
457
|
+
</ButtonGroup>
|
|
458
|
+
),
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* SplitButton 简化形态 — 左主操作 + 右下拉箭头(独立 Button)。
|
|
463
|
+
*/
|
|
464
|
+
export const GroupSplitButton: Story = {
|
|
465
|
+
parameters: { controls: { disable: true } },
|
|
466
|
+
render: () => (
|
|
467
|
+
<ButtonGroup>
|
|
468
|
+
<Button>保存</Button>
|
|
469
|
+
<Button shape="square" icon={<ChevronDown />} aria-label="更多保存选项" />
|
|
470
|
+
</ButtonGroup>
|
|
471
|
+
),
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* SplitButton 完整形态 — 右侧 ChevronDown 接 DropdownMenu。主按钮与
|
|
476
|
+
* 下拉触发使用同一 `variant` 保证视觉一致;对齐 cloud-design `SplitButton`
|
|
477
|
+
* 与 antd `Dropdown.Button` 的主场景。
|
|
478
|
+
*/
|
|
479
|
+
export const GroupSplitButtonWithDropdown: Story = {
|
|
480
|
+
parameters: { controls: { disable: true } },
|
|
481
|
+
render: () => (
|
|
482
|
+
<div className="flex flex-col items-start gap-3">
|
|
483
|
+
<ButtonGroup>
|
|
484
|
+
<Button>发布</Button>
|
|
485
|
+
<DropdownMenu>
|
|
486
|
+
<DropdownMenuTrigger asChild>
|
|
487
|
+
<Button
|
|
488
|
+
shape="square"
|
|
489
|
+
icon={<ChevronDown />}
|
|
490
|
+
aria-label="更多发布选项"
|
|
491
|
+
/>
|
|
492
|
+
</DropdownMenuTrigger>
|
|
493
|
+
<DropdownMenuContent align="end">
|
|
494
|
+
<DropdownMenuItem>保存为草稿</DropdownMenuItem>
|
|
495
|
+
<DropdownMenuItem>定时发布</DropdownMenuItem>
|
|
496
|
+
<DropdownMenuSeparator />
|
|
497
|
+
<DropdownMenuItem>发布到多个渠道…</DropdownMenuItem>
|
|
498
|
+
</DropdownMenuContent>
|
|
499
|
+
</DropdownMenu>
|
|
500
|
+
</ButtonGroup>
|
|
501
|
+
<ButtonGroup>
|
|
502
|
+
<Button variant="outline">编辑</Button>
|
|
503
|
+
<DropdownMenu>
|
|
504
|
+
<DropdownMenuTrigger asChild>
|
|
505
|
+
<Button
|
|
506
|
+
variant="outline"
|
|
507
|
+
shape="square"
|
|
508
|
+
icon={<ChevronDown />}
|
|
509
|
+
aria-label="更多编辑选项"
|
|
510
|
+
/>
|
|
511
|
+
</DropdownMenuTrigger>
|
|
512
|
+
<DropdownMenuContent align="end">
|
|
513
|
+
<DropdownMenuItem>复制</DropdownMenuItem>
|
|
514
|
+
<DropdownMenuItem>重命名</DropdownMenuItem>
|
|
515
|
+
<DropdownMenuSeparator />
|
|
516
|
+
<DropdownMenuItem className="text-destructive focus:text-destructive">
|
|
517
|
+
删除
|
|
518
|
+
</DropdownMenuItem>
|
|
519
|
+
</DropdownMenuContent>
|
|
520
|
+
</DropdownMenu>
|
|
521
|
+
</ButtonGroup>
|
|
522
|
+
</div>
|
|
523
|
+
),
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* SplitButton 多选形态 — 对应 cloud-design SplitButton 的 `selectMode="multiple"` +
|
|
528
|
+
* `selectedKeys`。新组合用 `DropdownMenuCheckboxItem` 表达,checked 受控,主按钮
|
|
529
|
+
* 文案随选择动态变化。
|
|
530
|
+
*/
|
|
531
|
+
export const GroupSplitButtonWithCheckbox: Story = {
|
|
532
|
+
parameters: { controls: { disable: true } },
|
|
533
|
+
render: () => {
|
|
534
|
+
const ChannelsSplit = () => {
|
|
535
|
+
const [channels, setChannels] = React.useState<Record<string, boolean>>({
|
|
536
|
+
web: true,
|
|
537
|
+
mobile: true,
|
|
538
|
+
email: false,
|
|
539
|
+
});
|
|
540
|
+
const toggle = (k: string) => (v: boolean) =>
|
|
541
|
+
setChannels((s) => ({ ...s, [k]: v }));
|
|
542
|
+
const count = Object.values(channels).filter(Boolean).length;
|
|
543
|
+
return (
|
|
544
|
+
<ButtonGroup>
|
|
545
|
+
<Button>{`发布到 ${count} 个渠道`}</Button>
|
|
546
|
+
<DropdownMenu>
|
|
547
|
+
<DropdownMenuTrigger asChild>
|
|
548
|
+
<Button
|
|
549
|
+
shape="square"
|
|
550
|
+
icon={<ChevronDown />}
|
|
551
|
+
aria-label="选择发布渠道"
|
|
552
|
+
/>
|
|
553
|
+
</DropdownMenuTrigger>
|
|
554
|
+
<DropdownMenuContent align="end">
|
|
555
|
+
<DropdownMenuLabel>发布渠道</DropdownMenuLabel>
|
|
556
|
+
<DropdownMenuSeparator />
|
|
557
|
+
<DropdownMenuCheckboxItem
|
|
558
|
+
checked={channels.web}
|
|
559
|
+
onCheckedChange={toggle('web')}
|
|
560
|
+
>
|
|
561
|
+
Web 站点
|
|
562
|
+
</DropdownMenuCheckboxItem>
|
|
563
|
+
<DropdownMenuCheckboxItem
|
|
564
|
+
checked={channels.mobile}
|
|
565
|
+
onCheckedChange={toggle('mobile')}
|
|
566
|
+
>
|
|
567
|
+
移动端
|
|
568
|
+
</DropdownMenuCheckboxItem>
|
|
569
|
+
<DropdownMenuCheckboxItem
|
|
570
|
+
checked={channels.email}
|
|
571
|
+
onCheckedChange={toggle('email')}
|
|
572
|
+
>
|
|
573
|
+
邮件订阅
|
|
574
|
+
</DropdownMenuCheckboxItem>
|
|
575
|
+
</DropdownMenuContent>
|
|
576
|
+
</DropdownMenu>
|
|
577
|
+
</ButtonGroup>
|
|
578
|
+
);
|
|
579
|
+
};
|
|
580
|
+
return <ChannelsSplit />;
|
|
581
|
+
},
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* SplitButton 单选形态 — 对应 cloud-design SplitButton 的 `selectMode="single"`。
|
|
586
|
+
* 新组合用 `DropdownMenuRadioGroup` + `DropdownMenuRadioItem` 表达,value 受控,
|
|
587
|
+
* 选中项 ✓ 反馈。
|
|
588
|
+
*/
|
|
589
|
+
export const GroupSplitButtonWithRadio: Story = {
|
|
590
|
+
parameters: { controls: { disable: true } },
|
|
591
|
+
render: () => {
|
|
592
|
+
const EnvSplit = () => {
|
|
593
|
+
const [env, setEnv] = React.useState('staging');
|
|
594
|
+
const envLabel = { dev: '开发', staging: '预发', prod: '生产' }[env];
|
|
595
|
+
return (
|
|
596
|
+
<ButtonGroup>
|
|
597
|
+
<Button>{`部署到 ${envLabel}`}</Button>
|
|
598
|
+
<DropdownMenu>
|
|
599
|
+
<DropdownMenuTrigger asChild>
|
|
600
|
+
<Button
|
|
601
|
+
shape="square"
|
|
602
|
+
icon={<ChevronDown />}
|
|
603
|
+
aria-label="切换部署环境"
|
|
604
|
+
/>
|
|
605
|
+
</DropdownMenuTrigger>
|
|
606
|
+
<DropdownMenuContent align="end">
|
|
607
|
+
<DropdownMenuLabel>部署环境</DropdownMenuLabel>
|
|
608
|
+
<DropdownMenuSeparator />
|
|
609
|
+
<DropdownMenuRadioGroup value={env} onValueChange={setEnv}>
|
|
610
|
+
<DropdownMenuRadioItem value="dev">开发</DropdownMenuRadioItem>
|
|
611
|
+
<DropdownMenuRadioItem value="staging">
|
|
612
|
+
预发
|
|
613
|
+
</DropdownMenuRadioItem>
|
|
614
|
+
<DropdownMenuRadioItem value="prod">生产</DropdownMenuRadioItem>
|
|
615
|
+
</DropdownMenuRadioGroup>
|
|
616
|
+
</DropdownMenuContent>
|
|
617
|
+
</DropdownMenu>
|
|
618
|
+
</ButtonGroup>
|
|
619
|
+
);
|
|
620
|
+
};
|
|
621
|
+
return <EnvSplit />;
|
|
622
|
+
},
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* SplitButton 三档尺寸 — 对应 cloud-design SplitButton 的 `size="small/medium/large"`。
|
|
627
|
+
* 通过 `<ButtonGroup size>` 注入,子 Button 同步继承;同时演示对齐旧库 `autoWidth=true`
|
|
628
|
+
* 的写法 — 用 `style.minWidth` 读 Radix 暴露的 `--radix-dropdown-menu-trigger-width`
|
|
629
|
+
* CSS 变量(避免 Tailwind arbitrary value 规则告警),让弹层最小宽度追平触发按钮宽度。
|
|
630
|
+
*/
|
|
631
|
+
export const GroupSplitButtonSizes: Story = {
|
|
632
|
+
parameters: { controls: { disable: true } },
|
|
633
|
+
render: () => {
|
|
634
|
+
const Demo = ({ size }: { size: 'sm' | 'md' | 'lg' }) => (
|
|
635
|
+
<ButtonGroup size={size}>
|
|
636
|
+
<Button>新建数据库</Button>
|
|
637
|
+
<DropdownMenu>
|
|
638
|
+
<DropdownMenuTrigger asChild>
|
|
639
|
+
<Button
|
|
640
|
+
shape="square"
|
|
641
|
+
icon={<ChevronDown />}
|
|
642
|
+
aria-label="更多新建选项"
|
|
643
|
+
/>
|
|
644
|
+
</DropdownMenuTrigger>
|
|
645
|
+
<DropdownMenuContent
|
|
646
|
+
align="end"
|
|
647
|
+
style={{ minWidth: 'var(--radix-dropdown-menu-trigger-width)' }}
|
|
648
|
+
>
|
|
649
|
+
<DropdownMenuItem>MySQL 实例</DropdownMenuItem>
|
|
650
|
+
<DropdownMenuItem>PostgreSQL 实例</DropdownMenuItem>
|
|
651
|
+
<DropdownMenuItem>Redis 实例</DropdownMenuItem>
|
|
652
|
+
</DropdownMenuContent>
|
|
653
|
+
</DropdownMenu>
|
|
654
|
+
</ButtonGroup>
|
|
655
|
+
);
|
|
656
|
+
return (
|
|
657
|
+
<div className="flex flex-col items-start gap-3">
|
|
658
|
+
<Demo size="sm" />
|
|
659
|
+
<Demo size="md" />
|
|
660
|
+
<Demo size="lg" />
|
|
661
|
+
</div>
|
|
662
|
+
);
|
|
663
|
+
},
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* `<ButtonGroup size="sm">` 自动通过 Context 把 sm 注入未显式传 size 的子 Button。
|
|
668
|
+
* 显式传 `size` 的子 Button 以子值优先,Context 不覆盖。
|
|
669
|
+
*/
|
|
670
|
+
export const GroupSizeInherit: Story = {
|
|
671
|
+
parameters: { controls: { disable: true } },
|
|
672
|
+
render: () => (
|
|
673
|
+
<div className="flex flex-col items-start gap-3">
|
|
674
|
+
<ButtonGroup size="sm">
|
|
675
|
+
<Button variant="outline">继承 sm</Button>
|
|
676
|
+
<Button variant="outline">继承 sm</Button>
|
|
677
|
+
<Button variant="outline" size="lg">
|
|
678
|
+
显式 lg(不继承)
|
|
679
|
+
</Button>
|
|
680
|
+
</ButtonGroup>
|
|
681
|
+
<ButtonGroup size="lg">
|
|
682
|
+
<Button>继承 lg</Button>
|
|
683
|
+
<Button variant="outline">继承 lg</Button>
|
|
684
|
+
<Button variant="outline">继承 lg</Button>
|
|
685
|
+
</ButtonGroup>
|
|
686
|
+
</div>
|
|
687
|
+
),
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* 分页器形态。
|
|
692
|
+
*/
|
|
693
|
+
export const GroupPager: Story = {
|
|
694
|
+
parameters: { controls: { disable: true } },
|
|
695
|
+
render: () => (
|
|
696
|
+
<ButtonGroup>
|
|
697
|
+
<Button variant="outline">上一页</Button>
|
|
698
|
+
<Button variant="outline">1 / 10</Button>
|
|
699
|
+
<Button variant="outline">下一页</Button>
|
|
700
|
+
</ButtonGroup>
|
|
701
|
+
),
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Input + addon 拼装。`ButtonGroupText` 提供 antd-style addon 文字。
|
|
706
|
+
*/
|
|
707
|
+
export const GroupInputAddon: Story = {
|
|
708
|
+
parameters: { controls: { disable: true } },
|
|
709
|
+
render: () => (
|
|
710
|
+
<ButtonGroup>
|
|
711
|
+
<ButtonGroupText>https://</ButtonGroupText>
|
|
712
|
+
<Input defaultValue="example.com" className="rounded-l-none" />
|
|
713
|
+
<Button>访问</Button>
|
|
714
|
+
</ButtonGroup>
|
|
715
|
+
),
|
|
716
|
+
};
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* 垂直方向按钮组。
|
|
720
|
+
*/
|
|
721
|
+
export const GroupVertical: Story = {
|
|
722
|
+
parameters: { controls: { disable: true } },
|
|
723
|
+
render: () => (
|
|
724
|
+
<ButtonGroup orientation="vertical">
|
|
725
|
+
<Button variant="outline">编辑</Button>
|
|
726
|
+
<Button variant="outline">复制</Button>
|
|
727
|
+
<Button variant="outline">删除</Button>
|
|
728
|
+
</ButtonGroup>
|
|
729
|
+
),
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* `attached={false}` — 按钮间保留 8px gap,圆角不被去除。
|
|
734
|
+
*/
|
|
735
|
+
export const GroupNotAttached: Story = {
|
|
736
|
+
parameters: { controls: { disable: true } },
|
|
737
|
+
render: () => (
|
|
738
|
+
<ButtonGroup attached={false}>
|
|
739
|
+
<Button variant="outline">取消</Button>
|
|
740
|
+
<Button>确定</Button>
|
|
741
|
+
</ButtonGroup>
|
|
742
|
+
),
|
|
743
|
+
};
|