@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,4 +1,4 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import {
|
|
3
3
|
AlertDialog,
|
|
4
4
|
AlertDialogTrigger,
|
|
@@ -13,23 +13,60 @@ import {
|
|
|
13
13
|
import { Button, buttonVariants } from '@/components/button/button';
|
|
14
14
|
|
|
15
15
|
const meta: Meta<typeof AlertDialogContent> = {
|
|
16
|
-
title: '
|
|
16
|
+
title: '反馈 · Feedback/AlertDialog',
|
|
17
17
|
component: AlertDialogContent,
|
|
18
18
|
tags: ['autodocs'],
|
|
19
19
|
parameters: {
|
|
20
20
|
docs: {
|
|
21
21
|
description: {
|
|
22
22
|
component:
|
|
23
|
-
'
|
|
23
|
+
'确认对话框 —— 对高风险、不可逆的操作做二次拦截,强制用户在「确认 / 取消」之间做出选择。基于 Radix AlertDialog 内核(焦点陷阱 + ESC 行为受控 + `role="alertdialog"`)+ 对齐 antd `Modal.confirm` / `Modal.alert` 的双按钮范式(`AlertDialogAction` / `AlertDialogCancel`);视觉上与 `Dialog` 同源(`--radius-dialog` 16px、无 border、纯白 + shadow 分界),`size` 四档绑定 `--layout-dialog-{sm|md|lg|xl}`,默认 `sm`(确认场景信息密度低)。视觉走 OpenTrek semantic tokens,所有样式来自 `@teamix-evo/tokens`,无 mock。',
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
26
|
},
|
|
27
|
+
argTypes: {
|
|
28
|
+
size: {
|
|
29
|
+
control: 'inline-radio',
|
|
30
|
+
options: ['sm', 'md', 'lg', 'xl'],
|
|
31
|
+
description:
|
|
32
|
+
'宽度档位,绑定 `--layout-dialog-{sm|md|lg|xl}`(OpenTrek 400/600/800/1200px)',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
args: { size: 'sm' },
|
|
27
36
|
};
|
|
28
37
|
|
|
29
38
|
export default meta;
|
|
30
39
|
type Story = StoryObj<typeof AlertDialogContent>;
|
|
31
40
|
|
|
41
|
+
export const Playground: Story = {
|
|
42
|
+
render: (args) => (
|
|
43
|
+
<AlertDialog>
|
|
44
|
+
<AlertDialogTrigger asChild>
|
|
45
|
+
<Button variant="destructive">删除项目</Button>
|
|
46
|
+
</AlertDialogTrigger>
|
|
47
|
+
<AlertDialogContent {...args}>
|
|
48
|
+
<AlertDialogHeader>
|
|
49
|
+
<AlertDialogTitle>确认删除项目?</AlertDialogTitle>
|
|
50
|
+
<AlertDialogDescription>
|
|
51
|
+
将永久删除 <b>"运营后台"</b> 项目及其下 142 个资源。此操作不可撤销。
|
|
52
|
+
</AlertDialogDescription>
|
|
53
|
+
</AlertDialogHeader>
|
|
54
|
+
<AlertDialogFooter>
|
|
55
|
+
<AlertDialogCancel>取消</AlertDialogCancel>
|
|
56
|
+
<AlertDialogAction
|
|
57
|
+
className={buttonVariants({ variant: 'destructive' })}
|
|
58
|
+
>
|
|
59
|
+
删除
|
|
60
|
+
</AlertDialogAction>
|
|
61
|
+
</AlertDialogFooter>
|
|
62
|
+
</AlertDialogContent>
|
|
63
|
+
</AlertDialog>
|
|
64
|
+
),
|
|
65
|
+
};
|
|
66
|
+
|
|
32
67
|
export const Destructive: Story = {
|
|
68
|
+
name: '高危删除(destructive)',
|
|
69
|
+
parameters: { controls: { disable: true } },
|
|
33
70
|
render: () => (
|
|
34
71
|
<AlertDialog>
|
|
35
72
|
<AlertDialogTrigger asChild>
|
|
@@ -58,6 +95,7 @@ export const Destructive: Story = {
|
|
|
58
95
|
};
|
|
59
96
|
|
|
60
97
|
export const NormalConfirm: Story = {
|
|
98
|
+
name: '业务确认(primary action)',
|
|
61
99
|
parameters: { controls: { disable: true } },
|
|
62
100
|
render: () => (
|
|
63
101
|
<AlertDialog>
|
|
@@ -79,3 +117,107 @@ export const NormalConfirm: Story = {
|
|
|
79
117
|
</AlertDialog>
|
|
80
118
|
),
|
|
81
119
|
};
|
|
120
|
+
|
|
121
|
+
export const AlertOnly: Story = {
|
|
122
|
+
name: 'Alert(单一确认,模拟 Modal.alert)',
|
|
123
|
+
parameters: {
|
|
124
|
+
controls: { disable: true },
|
|
125
|
+
docs: {
|
|
126
|
+
description: {
|
|
127
|
+
story:
|
|
128
|
+
'只展示单个 Action 按钮 — 模拟 antd `Modal.alert` 的单确认形态。适用于"已完成"、"权限不足"等仅需告知的场景。',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
render: () => (
|
|
133
|
+
<AlertDialog>
|
|
134
|
+
<AlertDialogTrigger asChild>
|
|
135
|
+
<Button variant="outline">查看通知</Button>
|
|
136
|
+
</AlertDialogTrigger>
|
|
137
|
+
<AlertDialogContent>
|
|
138
|
+
<AlertDialogHeader>
|
|
139
|
+
<AlertDialogTitle>升级完成</AlertDialogTitle>
|
|
140
|
+
<AlertDialogDescription>
|
|
141
|
+
已切换到企业版,新功能将在下次刷新页面后生效。
|
|
142
|
+
</AlertDialogDescription>
|
|
143
|
+
</AlertDialogHeader>
|
|
144
|
+
<AlertDialogFooter>
|
|
145
|
+
<AlertDialogAction>知道了</AlertDialogAction>
|
|
146
|
+
</AlertDialogFooter>
|
|
147
|
+
</AlertDialogContent>
|
|
148
|
+
</AlertDialog>
|
|
149
|
+
),
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const SizeMatrix: Story = {
|
|
153
|
+
name: 'Size 档位 · sm / md / lg / xl',
|
|
154
|
+
parameters: {
|
|
155
|
+
controls: { disable: true },
|
|
156
|
+
docs: {
|
|
157
|
+
description: {
|
|
158
|
+
story:
|
|
159
|
+
'依次触发四档尺寸 — 确认对话框默认 `sm` 即可,只有当需要列出资源清单 / 影响图谱时才升档。',
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
render: () => (
|
|
164
|
+
<div className="flex flex-wrap gap-2">
|
|
165
|
+
{(['sm', 'md', 'lg', 'xl'] as const).map((size) => (
|
|
166
|
+
<AlertDialog key={size}>
|
|
167
|
+
<AlertDialogTrigger asChild>
|
|
168
|
+
<Button variant="outline">size = {size}</Button>
|
|
169
|
+
</AlertDialogTrigger>
|
|
170
|
+
<AlertDialogContent size={size}>
|
|
171
|
+
<AlertDialogHeader>
|
|
172
|
+
<AlertDialogTitle>确认操作?({size})</AlertDialogTitle>
|
|
173
|
+
<AlertDialogDescription>
|
|
174
|
+
宽度绑定 `--layout-dialog-{size}`,实际像素由当前主题变体的
|
|
175
|
+
tokens 决定。
|
|
176
|
+
</AlertDialogDescription>
|
|
177
|
+
</AlertDialogHeader>
|
|
178
|
+
<AlertDialogFooter>
|
|
179
|
+
<AlertDialogCancel>取消</AlertDialogCancel>
|
|
180
|
+
<AlertDialogAction>确认</AlertDialogAction>
|
|
181
|
+
</AlertDialogFooter>
|
|
182
|
+
</AlertDialogContent>
|
|
183
|
+
</AlertDialog>
|
|
184
|
+
))}
|
|
185
|
+
</div>
|
|
186
|
+
),
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export const BorderlessShowcase: Story = {
|
|
190
|
+
name: '无 border border-border · 16px 圆角',
|
|
191
|
+
parameters: {
|
|
192
|
+
controls: { disable: true },
|
|
193
|
+
docs: {
|
|
194
|
+
description: {
|
|
195
|
+
story:
|
|
196
|
+
'与 `Dialog` 同源 — `AlertDialogContent` 已 `border-0`,16px 圆角(`--radius-dialog`)由 tokens 提供。请不要在 `className` 里加 `border *` 或覆盖 `rounded-*`。',
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
render: () => (
|
|
201
|
+
<AlertDialog>
|
|
202
|
+
<AlertDialogTrigger asChild>
|
|
203
|
+
<Button variant="destructive">释放实例</Button>
|
|
204
|
+
</AlertDialogTrigger>
|
|
205
|
+
<AlertDialogContent>
|
|
206
|
+
<AlertDialogHeader>
|
|
207
|
+
<AlertDialogTitle>确认释放实例?</AlertDialogTitle>
|
|
208
|
+
<AlertDialogDescription>
|
|
209
|
+
释放后实例及挂载数据将无法恢复。请确认已完成数据备份。
|
|
210
|
+
</AlertDialogDescription>
|
|
211
|
+
</AlertDialogHeader>
|
|
212
|
+
<AlertDialogFooter>
|
|
213
|
+
<AlertDialogCancel>取消</AlertDialogCancel>
|
|
214
|
+
<AlertDialogAction
|
|
215
|
+
className={buttonVariants({ variant: 'destructive' })}
|
|
216
|
+
>
|
|
217
|
+
确认释放
|
|
218
|
+
</AlertDialogAction>
|
|
219
|
+
</AlertDialogFooter>
|
|
220
|
+
</AlertDialogContent>
|
|
221
|
+
</AlertDialog>
|
|
222
|
+
),
|
|
223
|
+
};
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
4
|
|
|
4
5
|
import { cn } from '@/utils/cn';
|
|
5
6
|
import { buttonVariants } from '@/components/button/button';
|
|
6
7
|
|
|
7
8
|
const AlertDialog = AlertDialogPrimitive.Root;
|
|
8
|
-
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
|
9
9
|
const AlertDialogPortal = AlertDialogPrimitive.Portal;
|
|
10
10
|
|
|
11
|
+
const AlertDialogTrigger = React.forwardRef<
|
|
12
|
+
React.ElementRef<typeof AlertDialogPrimitive.Trigger>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Trigger>
|
|
14
|
+
>(({ className, ...props }, ref) => (
|
|
15
|
+
<AlertDialogPrimitive.Trigger
|
|
16
|
+
ref={ref}
|
|
17
|
+
className={cn('cursor-pointer', className)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
));
|
|
21
|
+
AlertDialogTrigger.displayName = AlertDialogPrimitive.Trigger.displayName;
|
|
22
|
+
|
|
11
23
|
const AlertDialogOverlay = React.forwardRef<
|
|
12
24
|
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
|
13
25
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
|
@@ -23,21 +35,53 @@ const AlertDialogOverlay = React.forwardRef<
|
|
|
23
35
|
));
|
|
24
36
|
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
|
25
37
|
|
|
38
|
+
/**
|
|
39
|
+
* AlertDialog content 变体 — 与 Dialog 保持同源视觉。
|
|
40
|
+
* - 圆角 `--radius-dialog`(16px)
|
|
41
|
+
* - 无 border,纯白 + shadow 作为视觉分界
|
|
42
|
+
* - size 绑定 `--layout-dialog-{sm|md|lg|xl}` tokens(确认类默认 `sm`,更紧凑)
|
|
43
|
+
*/
|
|
44
|
+
const alertDialogContentVariants = cva(
|
|
45
|
+
'fixed left-1/2 top-1/2 z-50 grid w-full translate-x-[-50%] translate-y-[-50%] gap-4 border-0 bg-background p-6 shadow-lg duration-200 rounded-[var(--radius-dialog)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
|
46
|
+
{
|
|
47
|
+
variants: {
|
|
48
|
+
size: {
|
|
49
|
+
sm: 'max-w-[var(--layout-dialog-sm)]',
|
|
50
|
+
md: 'max-w-[var(--layout-dialog-md)]',
|
|
51
|
+
lg: 'max-w-[var(--layout-dialog-lg)]',
|
|
52
|
+
xl: 'max-w-[var(--layout-dialog-xl)]',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
defaultVariants: { size: 'sm' },
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
export type AlertDialogSize = NonNullable<
|
|
60
|
+
VariantProps<typeof alertDialogContentVariants>['size']
|
|
61
|
+
>;
|
|
62
|
+
|
|
26
63
|
export interface AlertDialogContentProps
|
|
27
|
-
extends React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content
|
|
64
|
+
extends React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>,
|
|
65
|
+
VariantProps<typeof alertDialogContentVariants> {
|
|
66
|
+
/**
|
|
67
|
+
* 确认对话框尺寸 — 绑定 design tokens `--layout-dialog-{sm|md|lg|xl}`。
|
|
68
|
+
* OpenTrek 基准:sm=400 / md=600 / lg=800 / xl=1200。
|
|
69
|
+
* 确认场景文案短、信息少,默认 `sm`。
|
|
70
|
+
* @default "sm"
|
|
71
|
+
*/
|
|
72
|
+
size?: AlertDialogSize;
|
|
73
|
+
}
|
|
28
74
|
|
|
29
75
|
const AlertDialogContent = React.forwardRef<
|
|
30
76
|
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
|
31
77
|
AlertDialogContentProps
|
|
32
|
-
>(({ className, ...props }, ref) => (
|
|
78
|
+
>(({ className, size = 'sm', ...props }, ref) => (
|
|
33
79
|
<AlertDialogPortal>
|
|
34
80
|
<AlertDialogOverlay />
|
|
35
81
|
<AlertDialogPrimitive.Content
|
|
36
82
|
ref={ref}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
className,
|
|
40
|
-
)}
|
|
83
|
+
data-slot="dialog-content"
|
|
84
|
+
className={cn(alertDialogContentVariants({ size }), className)}
|
|
41
85
|
{...props}
|
|
42
86
|
/>
|
|
43
87
|
</AlertDialogPortal>
|
|
@@ -49,10 +93,7 @@ const AlertDialogHeader = ({
|
|
|
49
93
|
...props
|
|
50
94
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
51
95
|
<div
|
|
52
|
-
className={cn(
|
|
53
|
-
'flex flex-col space-y-2 text-center sm:text-left',
|
|
54
|
-
className,
|
|
55
|
-
)}
|
|
96
|
+
className={cn('flex flex-col gap-2 text-center sm:text-left', className)}
|
|
56
97
|
{...props}
|
|
57
98
|
/>
|
|
58
99
|
);
|
|
@@ -78,6 +119,7 @@ const AlertDialogTitle = React.forwardRef<
|
|
|
78
119
|
>(({ className, ...props }, ref) => (
|
|
79
120
|
<AlertDialogPrimitive.Title
|
|
80
121
|
ref={ref}
|
|
122
|
+
data-slot="dialog-title"
|
|
81
123
|
className={cn('text-lg font-semibold', className)}
|
|
82
124
|
{...props}
|
|
83
125
|
/>
|
|
@@ -90,7 +132,7 @@ const AlertDialogDescription = React.forwardRef<
|
|
|
90
132
|
>(({ className, ...props }, ref) => (
|
|
91
133
|
<AlertDialogPrimitive.Description
|
|
92
134
|
ref={ref}
|
|
93
|
-
className={cn('text-
|
|
135
|
+
className={cn('text-xs text-muted-foreground', className)}
|
|
94
136
|
{...props}
|
|
95
137
|
/>
|
|
96
138
|
));
|
|
@@ -115,7 +157,11 @@ const AlertDialogCancel = React.forwardRef<
|
|
|
115
157
|
>(({ className, ...props }, ref) => (
|
|
116
158
|
<AlertDialogPrimitive.Cancel
|
|
117
159
|
ref={ref}
|
|
118
|
-
className={cn(
|
|
160
|
+
className={cn(
|
|
161
|
+
buttonVariants({ variant: 'outline' }),
|
|
162
|
+
'mt-2 sm:mt-0',
|
|
163
|
+
className,
|
|
164
|
+
)}
|
|
119
165
|
{...props}
|
|
120
166
|
/>
|
|
121
167
|
));
|
|
@@ -133,4 +179,5 @@ export {
|
|
|
133
179
|
AlertDialogDescription,
|
|
134
180
|
AlertDialogAction,
|
|
135
181
|
AlertDialogCancel,
|
|
182
|
+
alertDialogContentVariants,
|
|
136
183
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: anchor
|
|
3
3
|
name: Anchor
|
|
4
|
+
displayName: 锚点
|
|
4
5
|
type: component
|
|
5
|
-
category:
|
|
6
|
+
category: deprecated
|
|
6
7
|
since: 0.1.0
|
|
7
|
-
package:
|
|
8
|
+
package: '@teamix-evo/ui'
|
|
8
9
|
---
|
|
9
10
|
|
|
10
|
-
# Anchor
|
|
11
|
+
# Anchor 锚点
|
|
11
12
|
|
|
12
13
|
锚点导航 — antd 独有补足。**等价 antd `Anchor`**。长文档 / 详情页侧边的目录,点击锚点滚动到对应 `id` 节点,滚动时自动高亮当前可见的锚点(IntersectionObserver)。支持嵌套两层缩进。
|
|
13
14
|
|
|
@@ -23,6 +24,8 @@ package: "@teamix-evo/ui"
|
|
|
23
24
|
- 主导航(顶部 / 侧栏菜单)→ `NavigationMenu` / `Sidebar`
|
|
24
25
|
- 步骤导航(顺序操作)→ `Steps`
|
|
25
26
|
|
|
27
|
+
## Props
|
|
28
|
+
|
|
26
29
|
<!-- auto:props:begin -->
|
|
27
30
|
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
28
31
|
| --- | --- | --- | --- | --- |
|
|
@@ -32,6 +35,8 @@ package: "@teamix-evo/ui"
|
|
|
32
35
|
| `onChange` | `(key: string) => void` | – | – | 当前高亮变化回调。 |
|
|
33
36
|
<!-- auto:props:end -->
|
|
34
37
|
|
|
38
|
+
## 依赖
|
|
39
|
+
|
|
35
40
|
<!-- auto:deps:begin -->
|
|
36
41
|
### 同库依赖
|
|
37
42
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { Anchor } from './anchor';
|
|
3
3
|
|
|
4
4
|
const meta: Meta<typeof Anchor> = {
|
|
5
|
-
title: '
|
|
5
|
+
title: '废弃 · Deprecated/Anchor',
|
|
6
6
|
component: Anchor,
|
|
7
7
|
tags: ['autodocs'],
|
|
8
8
|
parameters: {
|
|
9
9
|
docs: {
|
|
10
10
|
description: {
|
|
11
11
|
component:
|
|
12
|
-
'锚点导航 — 长文档 / 详情页侧边目录,点击滚动到 id 节点,滚动时 IntersectionObserver 自动高亮。等价 antd `Anchor
|
|
12
|
+
'⚠️ **已废弃** — 仅 Storybook 留档,不通过 manifest 对外发布。\n\n锚点导航 — 长文档 / 详情页侧边目录,点击滚动到 id 节点,滚动时 IntersectionObserver 自动高亮。等价 antd `Anchor`。',
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
15
|
},
|
|
@@ -98,7 +98,7 @@ const Anchor = React.forwardRef<HTMLElement, AnchorProps>(
|
|
|
98
98
|
href={`#${it.key}`}
|
|
99
99
|
onClick={(e) => handleClick(e, it.key)}
|
|
100
100
|
className={cn(
|
|
101
|
-
'block border-l-2 py-1 pr-2 text-
|
|
101
|
+
'block border-l-2 py-1 pr-2 text-xs transition-colors',
|
|
102
102
|
depth === 0 ? 'pl-3' : depth === 1 ? 'pl-6' : 'pl-9',
|
|
103
103
|
active === it.key
|
|
104
104
|
? 'border-primary text-primary'
|
|
@@ -117,7 +117,7 @@ const Anchor = React.forwardRef<HTMLElement, AnchorProps>(
|
|
|
117
117
|
<nav
|
|
118
118
|
ref={ref}
|
|
119
119
|
aria-label="目录"
|
|
120
|
-
className={cn('text-
|
|
120
|
+
className={cn('text-xs', className)}
|
|
121
121
|
{...props}
|
|
122
122
|
>
|
|
123
123
|
<ul>{items.map((it) => renderItem(it, 0))}</ul>
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
id: app
|
|
3
3
|
name: App
|
|
4
4
|
type: component
|
|
5
|
-
category:
|
|
5
|
+
category: deprecated
|
|
6
6
|
since: 0.1.0
|
|
7
|
-
package:
|
|
7
|
+
package: '@teamix-evo/ui'
|
|
8
|
+
displayName: 应用容器
|
|
8
9
|
---
|
|
9
10
|
|
|
10
|
-
# App
|
|
11
|
+
# App 应用容器
|
|
11
12
|
|
|
12
13
|
应用根容器 — antd 独有补足。**对标 antd `App`** 的核心职责:挂全局 Toaster + 设置 dir / lang + 承载根级 className。**与 antd 区别**:不接管主题(本库主题靠 design tokens / CSS vars,**不引入 runtime ConfigProvider**),也不收敛 `useApp()` hook(toast / notification 直接 import 即可)。
|
|
13
14
|
|
|
@@ -23,6 +24,8 @@ package: "@teamix-evo/ui"
|
|
|
23
24
|
- 需要 runtime 切换主题色 → 改 CSS variables(design tokens),**不要**通过 ConfigProvider
|
|
24
25
|
- 单独需要 Toaster → 直接挂 `<Toaster />`
|
|
25
26
|
|
|
27
|
+
## Props
|
|
28
|
+
|
|
26
29
|
<!-- auto:props:begin -->
|
|
27
30
|
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
28
31
|
| --- | --- | --- | --- | --- |
|
|
@@ -31,6 +34,8 @@ package: "@teamix-evo/ui"
|
|
|
31
34
|
| `dir` | `'ltr' \| 'rtl'` | `"ltr"` | – | 文字方向 — 设到根容器的 `dir` 属性,Radix 等组件会自动适配。 |
|
|
32
35
|
<!-- auto:props:end -->
|
|
33
36
|
|
|
37
|
+
## 依赖
|
|
38
|
+
|
|
34
39
|
<!-- auto:deps:begin -->
|
|
35
40
|
### 同库依赖
|
|
36
41
|
|
|
@@ -39,7 +44,7 @@ package: "@teamix-evo/ui"
|
|
|
39
44
|
| Entry | 类型 | 描述 |
|
|
40
45
|
| --- | --- | --- |
|
|
41
46
|
| `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
|
|
42
|
-
| `sonner` | component | Toast 通知 — sonner 包装,等价 antd message + notification 并集(toast() 函数式 API + Toaster
|
|
47
|
+
| `sonner` | component | Toast 通知 — sonner 包装,等价 antd message + notification 并集(toast() 函数式 API + Toaster 容器,面性 5 状态图标 + 无边框) |
|
|
43
48
|
|
|
44
49
|
### npm 依赖
|
|
45
50
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { App } from './app';
|
|
3
3
|
import { Button } from '@/components/button/button';
|
|
4
4
|
import { toast } from '@/components/sonner/sonner';
|
|
5
5
|
import { notification } from '@/components/notification/notification';
|
|
6
6
|
|
|
7
7
|
const meta: Meta<typeof App> = {
|
|
8
|
-
title: '
|
|
8
|
+
title: '废弃 · Deprecated/App',
|
|
9
9
|
component: App,
|
|
10
10
|
tags: ['autodocs'],
|
|
11
11
|
parameters: {
|
|
12
12
|
docs: {
|
|
13
13
|
description: {
|
|
14
14
|
component:
|
|
15
|
-
'应用根容器 — 挂全局 Toaster + 设置 dir / lang + 承载根级 className。对标 antd `App
|
|
15
|
+
'⚠️ **已废弃** — 仅 Storybook 留档,不通过 manifest 对外发布。\n\n应用根容器 — 挂全局 Toaster + 设置 dir / lang + 承载根级 className。对标 antd `App`,但不接管主题(主题靠 design tokens / CSS vars),也不收敛 useApp() hook。',
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
18
|
},
|
|
@@ -28,15 +28,17 @@ type Story = StoryObj<typeof App>;
|
|
|
28
28
|
|
|
29
29
|
export const Playground: Story = {
|
|
30
30
|
render: (args) => (
|
|
31
|
-
<App {...args} className="rounded-md border p-6">
|
|
31
|
+
<App {...args} className="rounded-md border border-border p-6">
|
|
32
32
|
<div className="flex flex-col gap-3">
|
|
33
|
-
<span className="text-sm text-muted-foreground">
|
|
33
|
+
<span className="text-sm text-muted-foreground">
|
|
34
|
+
App 内挂载了 Toaster,可直接触发:
|
|
35
|
+
</span>
|
|
34
36
|
<div className="flex gap-2">
|
|
35
37
|
<Button onClick={() => toast.success('已保存')}>触发 toast</Button>
|
|
36
38
|
<Button
|
|
37
39
|
variant="outline"
|
|
38
40
|
onClick={() =>
|
|
39
|
-
notification.
|
|
41
|
+
notification.primary({
|
|
40
42
|
title: 'App 容器在生效',
|
|
41
43
|
description: '右上角 Toaster 是 App 默认挂载的',
|
|
42
44
|
})
|
|
@@ -53,7 +55,7 @@ export const Playground: Story = {
|
|
|
53
55
|
export const RTL: Story = {
|
|
54
56
|
parameters: { controls: { disable: true } },
|
|
55
57
|
render: () => (
|
|
56
|
-
<App dir="rtl" className="rounded-md border p-6">
|
|
58
|
+
<App dir="rtl" className="rounded-md border border-border p-6">
|
|
57
59
|
<div className="text-sm">
|
|
58
60
|
当前方向: <strong>rtl</strong> — 你会看到自然的右到左流向
|
|
59
61
|
</div>
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: aspect-ratio
|
|
3
3
|
name: AspectRatio
|
|
4
|
+
displayName: 宽高比
|
|
4
5
|
type: component
|
|
5
|
-
category:
|
|
6
|
+
category: deprecated
|
|
6
7
|
since: 0.1.0
|
|
7
|
-
package:
|
|
8
|
+
package: '@teamix-evo/ui'
|
|
8
9
|
---
|
|
9
10
|
|
|
10
|
-
# AspectRatio
|
|
11
|
+
# AspectRatio 宽高比
|
|
11
12
|
|
|
12
13
|
容器保持宽高比 — 基于 `@radix-ui/react-aspect-ratio`,内部用 padding-bottom 技巧实现,**无 layout shift**。
|
|
13
14
|
shadcn-only,antd 无对标。
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { AspectRatio } from './aspect-ratio';
|
|
3
3
|
|
|
4
4
|
const meta: Meta<typeof AspectRatio> = {
|
|
5
|
-
title: '
|
|
5
|
+
title: '废弃 · Deprecated/AspectRatio',
|
|
6
6
|
component: AspectRatio,
|
|
7
7
|
tags: ['autodocs'],
|
|
8
8
|
parameters: {
|
|
9
9
|
docs: {
|
|
10
10
|
description: {
|
|
11
11
|
component:
|
|
12
|
-
'宽高比容器 — 强制子元素按指定比例渲染,常用于图片 / 视频 / iframe 等响应式封面容器。基于 Radix AspectRatio,通过 `ratio` prop
|
|
12
|
+
'⚠️ **已废弃** — 仅 Storybook 留档,不通过 manifest 对外发布。\n\n宽高比容器 — 强制子元素按指定比例渲染,常用于图片 / 视频 / iframe 等响应式封面容器。基于 Radix AspectRatio,通过 `ratio` prop 传入任意宽高比。shadcn 专有,填补了 antd 未提供的纯布局能力。',
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
15
|
},
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
id: auto-complete
|
|
3
3
|
name: AutoComplete
|
|
4
4
|
type: component
|
|
5
|
-
category:
|
|
5
|
+
category: data-entry
|
|
6
6
|
since: 0.1.0
|
|
7
|
-
package:
|
|
7
|
+
package: '@teamix-evo/ui'
|
|
8
|
+
displayName: 自动补全
|
|
8
9
|
---
|
|
9
10
|
|
|
10
|
-
# AutoComplete
|
|
11
|
+
# AutoComplete 自动补全
|
|
11
12
|
|
|
12
13
|
输入即建议 — antd 独有补足。**等价 antd `AutoComplete`**。键入触发候选下拉,可选可改;**最终 value 可以是任意字符串**(不强制为选项之一),与 `Combobox`(必选)互补。配 `onSearch` 实现异步建议。
|
|
13
14
|
|
|
@@ -23,6 +24,8 @@ package: "@teamix-evo/ui"
|
|
|
23
24
|
- 多选 → `Select multiple`
|
|
24
25
|
- @提及输入 → `Mentions`
|
|
25
26
|
|
|
27
|
+
## Props
|
|
28
|
+
|
|
26
29
|
<!-- auto:props:begin -->
|
|
27
30
|
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
28
31
|
| --- | --- | --- | --- | --- |
|
|
@@ -30,13 +33,16 @@ package: "@teamix-evo/ui"
|
|
|
30
33
|
| `value` | `string` | – | – | 受控值。 |
|
|
31
34
|
| `defaultValue` | `string` | – | – | uncontrolled 初值。 |
|
|
32
35
|
| `onChange` | `(value: string) => void` | – | – | 值变化回调 — 用户键入 / 选中候选时触发。 |
|
|
33
|
-
| `onSearch` | `(query: string) => void` | – | – | 用户输入时回调,用于刷新 `options`(异步建议)。 |
|
|
36
|
+
| `onSearch` | `(query: string) => void` | – | – | 用户输入时回调,用于刷新 `options`(异步建议)。 提供该回调后,内部不再对 `options` 做本地过滤(由外部按 query 自行刷新)。 |
|
|
34
37
|
| `onSelect` | `(value: string, option: AutoCompleteOption) => void` | – | – | 选中候选时回调。 |
|
|
35
38
|
| `openOnFocus` | `boolean` | `false` | – | 是否在输入框聚焦但 query 为空时显示完整 `options`(antd `defaultActiveFirstOption` 行为的近似)。 |
|
|
36
39
|
| `emptyText` | `string` | `"无匹配项"` | – | 无匹配时的提示文本。 |
|
|
37
|
-
| `size` | `'sm' \| 'default' \| 'lg'` | `"
|
|
40
|
+
| `size` | `'sm' \| 'md' \| 'default' \| 'lg'` | `"md"` | – | 容器尺寸 — 透传 Input.size。 |
|
|
41
|
+
| `error` | `boolean` | `false` | – | 错误态视觉(校验失败) — 透传给内部 Input,红色 border + ring,自动写 `aria-invalid="true"`。 |
|
|
38
42
|
<!-- auto:props:end -->
|
|
39
43
|
|
|
44
|
+
## 依赖
|
|
45
|
+
|
|
40
46
|
<!-- auto:deps:begin -->
|
|
41
47
|
### 同库依赖
|
|
42
48
|
|
|
@@ -45,7 +51,9 @@ package: "@teamix-evo/ui"
|
|
|
45
51
|
| Entry | 类型 | 描述 |
|
|
46
52
|
| --- | --- | --- |
|
|
47
53
|
| `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
|
|
48
|
-
| `input` | component |
|
|
54
|
+
| `input` | component | 单行文本输入 — clearable / showCount / size(sm 24 / md 32 / lg 36,与 Button 同档)/ error 四档内建能力。前缀/后缀/addon 等复合形态已拆出独立 InputGroup;多行已拆出独立 Textarea |
|
|
55
|
+
| `popover` | component | 可交互浮层 — Radix Popover + antd arrow 并集,使用 showArrow 控制尖角(与 Tooltip / HoverCard 命名统一) |
|
|
56
|
+
| `command` | component | 命令面板 / 下拉底座 — cmdk(Linear / Raycast 风格)提供过滤 / 键盘导航 / a11y;同时为 Combobox / Select / AutoComplete 提供同源下拉内核 |
|
|
49
57
|
|
|
50
58
|
### npm 依赖
|
|
51
59
|
|
|
@@ -1,16 +1,16 @@
|
|
|
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 { AutoComplete } from './auto-complete';
|
|
4
4
|
|
|
5
5
|
const meta: Meta<typeof AutoComplete> = {
|
|
6
|
-
title: '
|
|
6
|
+
title: '数据录入 · Data Entry/AutoComplete',
|
|
7
7
|
component: AutoComplete,
|
|
8
8
|
tags: ['autodocs'],
|
|
9
9
|
parameters: {
|
|
10
10
|
docs: {
|
|
11
11
|
description: {
|
|
12
12
|
component:
|
|
13
|
-
'
|
|
13
|
+
'自动补全 — 输入即建议,键入触发候选下拉,可选可改,最终 value 是自由文本(不强制为选项之一)。**Input 为底** + antd `AutoComplete` 的人机交互并集:`options` / `onSearch` / `onSelect` / `openOnFocus` / `size` / `error`,与 Combobox(必选)互补。视觉走 OpenTrek semantic tokens,所有样式来自 `@teamix-evo/tokens`,无 mock。',
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
},
|
|
@@ -38,6 +38,47 @@ export const Playground: Story = {
|
|
|
38
38
|
),
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
export const Sizes: Story = {
|
|
42
|
+
parameters: { controls: { disable: true } },
|
|
43
|
+
render: () => (
|
|
44
|
+
<div className="flex flex-col gap-3">
|
|
45
|
+
<AutoComplete
|
|
46
|
+
size="sm"
|
|
47
|
+
options={frameworks}
|
|
48
|
+
placeholder="sm"
|
|
49
|
+
className="w-64"
|
|
50
|
+
/>
|
|
51
|
+
<AutoComplete
|
|
52
|
+
options={frameworks}
|
|
53
|
+
placeholder="default"
|
|
54
|
+
className="w-64"
|
|
55
|
+
/>
|
|
56
|
+
<AutoComplete
|
|
57
|
+
size="lg"
|
|
58
|
+
options={frameworks}
|
|
59
|
+
placeholder="lg"
|
|
60
|
+
className="w-64"
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
),
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const ErrorState: Story = {
|
|
67
|
+
name: 'Error 错误态',
|
|
68
|
+
parameters: { controls: { disable: true } },
|
|
69
|
+
render: () => (
|
|
70
|
+
<div className="flex flex-col gap-1">
|
|
71
|
+
<AutoComplete
|
|
72
|
+
options={frameworks}
|
|
73
|
+
placeholder="输入框架名(必填)"
|
|
74
|
+
error
|
|
75
|
+
className="w-64"
|
|
76
|
+
/>
|
|
77
|
+
<span className="text-xs text-destructive">该字段为必填项</span>
|
|
78
|
+
</div>
|
|
79
|
+
),
|
|
80
|
+
};
|
|
81
|
+
|
|
41
82
|
export const OpenOnFocus: Story = {
|
|
42
83
|
parameters: { controls: { disable: true } },
|
|
43
84
|
render: () => (
|
|
@@ -81,7 +122,9 @@ export const AsyncSearch: Story = {
|
|
|
81
122
|
options={opts}
|
|
82
123
|
onSearch={(q) => {
|
|
83
124
|
window.setTimeout(() => {
|
|
84
|
-
setOpts(
|
|
125
|
+
setOpts(
|
|
126
|
+
all.filter((v) => v.includes(q)).map((v) => ({ value: v })),
|
|
127
|
+
);
|
|
85
128
|
}, 80);
|
|
86
129
|
}}
|
|
87
130
|
placeholder="搜索城市(模拟异步)..."
|