@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
|
Field,
|
|
4
4
|
FieldLabel,
|
|
@@ -7,25 +7,30 @@ import {
|
|
|
7
7
|
FieldGroup,
|
|
8
8
|
FieldSet,
|
|
9
9
|
FieldLegend,
|
|
10
|
+
FieldSection,
|
|
11
|
+
FieldActions,
|
|
10
12
|
} from './field';
|
|
11
13
|
import { Input } from '@/components/input/input';
|
|
12
14
|
import { Switch } from '@/components/switch/switch';
|
|
13
15
|
import { Button } from '@/components/button/button';
|
|
14
16
|
|
|
15
17
|
const meta: Meta<typeof Field> = {
|
|
16
|
-
title: '
|
|
18
|
+
title: '数据录入 · Data Entry/Field',
|
|
17
19
|
component: Field,
|
|
18
20
|
tags: ['autodocs'],
|
|
19
21
|
parameters: {
|
|
20
22
|
docs: {
|
|
21
23
|
description: {
|
|
22
24
|
component:
|
|
23
|
-
'通用表单字段抽象 — 比 Form
|
|
25
|
+
'通用表单字段抽象 — 比 Form 更通用(Form 强绑 RHF;Field 跟任何状态管理都能搭)。7 个语义槽:Field / FieldLabel / FieldDescription / FieldError / FieldGroup / FieldSet / FieldLegend。必填 `*` **后置**在文字和 tooltip icon 右侧(顺序为 `文字 ⓘ *`),对齐设计规范。shadcn 2025-10 新增,与现有 Form 共存。',
|
|
24
26
|
},
|
|
25
27
|
},
|
|
26
28
|
},
|
|
27
29
|
argTypes: {
|
|
28
|
-
orientation: {
|
|
30
|
+
orientation: {
|
|
31
|
+
control: 'inline-radio',
|
|
32
|
+
options: ['vertical', 'horizontal'],
|
|
33
|
+
},
|
|
29
34
|
invalid: { control: 'boolean' },
|
|
30
35
|
},
|
|
31
36
|
args: { orientation: 'vertical', invalid: false },
|
|
@@ -47,6 +52,79 @@ export const Playground: Story = {
|
|
|
47
52
|
),
|
|
48
53
|
};
|
|
49
54
|
|
|
55
|
+
/**
|
|
56
|
+
* **Accessibility(a11y 完整链路)** — `invalid` 是 Field 上的单一真值,
|
|
57
|
+
* 自动驱动 FieldLabel 着色 / FieldError 可见 / 子控件 ring 染红。
|
|
58
|
+
* 业务侧需同时给 input 设置 `aria-invalid` / `aria-required` / `aria-describedby` 确保屏幕阅读器叙述完整。
|
|
59
|
+
*/
|
|
60
|
+
export const Accessibility: Story = {
|
|
61
|
+
parameters: {
|
|
62
|
+
controls: { disable: true },
|
|
63
|
+
docs: {
|
|
64
|
+
description: {
|
|
65
|
+
story:
|
|
66
|
+
'Field 是 a11y 单一真值:`invalid={true}` 自动驱动 FieldLabel 文字色 → destructive、内部所有控件 ring → destructive、FieldError 可见(role="alert")。业务层把 `aria-invalid` / `aria-required` / `aria-describedby` 设在 input 上保证屏幕阅读器叙述完整。',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
render: () => (
|
|
71
|
+
<FieldGroup className="w-80">
|
|
72
|
+
<Field invalid>
|
|
73
|
+
<FieldLabel htmlFor="a11y-email" required>
|
|
74
|
+
邮箱
|
|
75
|
+
</FieldLabel>
|
|
76
|
+
<Input
|
|
77
|
+
id="a11y-email"
|
|
78
|
+
type="email"
|
|
79
|
+
aria-required="true"
|
|
80
|
+
aria-invalid="true"
|
|
81
|
+
aria-describedby="a11y-email-desc a11y-email-err"
|
|
82
|
+
defaultValue="not-an-email"
|
|
83
|
+
/>
|
|
84
|
+
<FieldDescription id="a11y-email-desc">
|
|
85
|
+
用于接收登录验证码与订单通知
|
|
86
|
+
</FieldDescription>
|
|
87
|
+
<FieldError id="a11y-email-err">
|
|
88
|
+
邮箱格式不正确,请检查后重新输入
|
|
89
|
+
</FieldError>
|
|
90
|
+
</Field>
|
|
91
|
+
<Field>
|
|
92
|
+
<FieldLabel htmlFor="a11y-name" required>
|
|
93
|
+
姓名
|
|
94
|
+
</FieldLabel>
|
|
95
|
+
<Input
|
|
96
|
+
id="a11y-name"
|
|
97
|
+
aria-required="true"
|
|
98
|
+
aria-describedby="a11y-name-desc"
|
|
99
|
+
placeholder="请输入真实姓名"
|
|
100
|
+
/>
|
|
101
|
+
<FieldDescription id="a11y-name-desc">
|
|
102
|
+
用于显示在主页与通知中
|
|
103
|
+
</FieldDescription>
|
|
104
|
+
</Field>
|
|
105
|
+
</FieldGroup>
|
|
106
|
+
),
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/** 必填标记 `*` **后置**在文字和 tooltip icon 右侧(顺序为 `文字 ⓘ *`),对齐设计规范。 */
|
|
110
|
+
export const RequiredPosition: Story = {
|
|
111
|
+
parameters: { controls: { disable: true } },
|
|
112
|
+
render: () => (
|
|
113
|
+
<FieldGroup className="w-80">
|
|
114
|
+
<Field>
|
|
115
|
+
<FieldLabel htmlFor="req-name" required>
|
|
116
|
+
必填字段
|
|
117
|
+
</FieldLabel>
|
|
118
|
+
<Input id="req-name" aria-required="true" placeholder="例:张三" />
|
|
119
|
+
</Field>
|
|
120
|
+
<Field>
|
|
121
|
+
<FieldLabel htmlFor="opt-bio">可选字段</FieldLabel>
|
|
122
|
+
<Input id="opt-bio" placeholder="选填" />
|
|
123
|
+
</Field>
|
|
124
|
+
</FieldGroup>
|
|
125
|
+
),
|
|
126
|
+
};
|
|
127
|
+
|
|
50
128
|
export const Horizontal: Story = {
|
|
51
129
|
parameters: { controls: { disable: true } },
|
|
52
130
|
render: () => (
|
|
@@ -92,7 +170,7 @@ export const ServerActionForm: Story = {
|
|
|
92
170
|
onSubmit={(e) => {
|
|
93
171
|
e.preventDefault();
|
|
94
172
|
const fd = new FormData(e.currentTarget);
|
|
95
|
-
|
|
173
|
+
|
|
96
174
|
alert(`提交: ${JSON.stringify(Object.fromEntries(fd.entries()))}`);
|
|
97
175
|
}}
|
|
98
176
|
className="w-96 space-y-4"
|
|
@@ -115,3 +193,305 @@ export const ServerActionForm: Story = {
|
|
|
115
193
|
</form>
|
|
116
194
|
),
|
|
117
195
|
};
|
|
196
|
+
|
|
197
|
+
/** **FieldSection** — 带可选标题的字段分组;多个 section 之间由父容器提供 32px 间距(gap-8)。 */
|
|
198
|
+
export const WithSection: Story = {
|
|
199
|
+
parameters: { controls: { disable: true } },
|
|
200
|
+
render: () => (
|
|
201
|
+
<div className="flex w-[480px] flex-col gap-8">
|
|
202
|
+
<FieldSection title="基本信息">
|
|
203
|
+
<Field>
|
|
204
|
+
<FieldLabel htmlFor="sec-name" required>
|
|
205
|
+
姓名
|
|
206
|
+
</FieldLabel>
|
|
207
|
+
<Input id="sec-name" placeholder="例:张三" />
|
|
208
|
+
</Field>
|
|
209
|
+
<Field>
|
|
210
|
+
<FieldLabel htmlFor="sec-email" required>
|
|
211
|
+
邮箱
|
|
212
|
+
</FieldLabel>
|
|
213
|
+
<Input id="sec-email" type="email" />
|
|
214
|
+
</Field>
|
|
215
|
+
</FieldSection>
|
|
216
|
+
<FieldSection title="通知设置">
|
|
217
|
+
<Field orientation="horizontal">
|
|
218
|
+
<FieldLabel htmlFor="sec-notify" className="min-w-28 pt-2">
|
|
219
|
+
邮件通知
|
|
220
|
+
</FieldLabel>
|
|
221
|
+
<div className="flex-1">
|
|
222
|
+
<Switch id="sec-notify" defaultChecked />
|
|
223
|
+
<FieldDescription className="mt-1">
|
|
224
|
+
有重要事件时给您发邮件
|
|
225
|
+
</FieldDescription>
|
|
226
|
+
</div>
|
|
227
|
+
</Field>
|
|
228
|
+
</FieldSection>
|
|
229
|
+
</div>
|
|
230
|
+
),
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
/** **FieldActions** — 表单底部操作区;支持 `inline`(跟随表单流) 与 `sticky`(吸底带分割线)。 */
|
|
234
|
+
export const WithActions: Story = {
|
|
235
|
+
parameters: { controls: { disable: true } },
|
|
236
|
+
render: () => (
|
|
237
|
+
<div className="flex w-[640px] gap-8">
|
|
238
|
+
<div className="flex-1">
|
|
239
|
+
<p className="mb-3 text-xs text-muted-foreground">position="inline"</p>
|
|
240
|
+
<FieldGroup>
|
|
241
|
+
<Field>
|
|
242
|
+
<FieldLabel htmlFor="act-name">姓名</FieldLabel>
|
|
243
|
+
<Input id="act-name" />
|
|
244
|
+
</Field>
|
|
245
|
+
<FieldActions>
|
|
246
|
+
<Button variant="outline">取消</Button>
|
|
247
|
+
<Button>保存</Button>
|
|
248
|
+
</FieldActions>
|
|
249
|
+
</FieldGroup>
|
|
250
|
+
</div>
|
|
251
|
+
<div className="flex-1">
|
|
252
|
+
<p className="mb-3 text-xs text-muted-foreground">position="sticky"</p>
|
|
253
|
+
<div className="relative h-[260px] overflow-y-auto rounded-md border border-border">
|
|
254
|
+
<div className="flex flex-col gap-5 p-4">
|
|
255
|
+
<Field>
|
|
256
|
+
<FieldLabel htmlFor="sticky-1">字段 A</FieldLabel>
|
|
257
|
+
<Input id="sticky-1" />
|
|
258
|
+
</Field>
|
|
259
|
+
<Field>
|
|
260
|
+
<FieldLabel htmlFor="sticky-2">字段 B</FieldLabel>
|
|
261
|
+
<Input id="sticky-2" />
|
|
262
|
+
</Field>
|
|
263
|
+
<Field>
|
|
264
|
+
<FieldLabel htmlFor="sticky-3">字段 C</FieldLabel>
|
|
265
|
+
<Input id="sticky-3" />
|
|
266
|
+
</Field>
|
|
267
|
+
<Field>
|
|
268
|
+
<FieldLabel htmlFor="sticky-4">字段 D</FieldLabel>
|
|
269
|
+
<Input id="sticky-4" />
|
|
270
|
+
</Field>
|
|
271
|
+
<FieldActions position="sticky" className="-mx-4 px-4">
|
|
272
|
+
<Button variant="outline">取消</Button>
|
|
273
|
+
<Button>保存</Button>
|
|
274
|
+
</FieldActions>
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
),
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
/** **FieldActions.container** — 4 种按钮容器预设,自动配齐 position/align/alignWithInput(对齐规范 §六)。 */
|
|
283
|
+
export const ActionsContainerPresets: Story = {
|
|
284
|
+
parameters: { controls: { disable: true } },
|
|
285
|
+
render: () => {
|
|
286
|
+
const presets: Array<{
|
|
287
|
+
key: 'page' | 'page-stepper' | 'modal' | 'drawer';
|
|
288
|
+
label: string;
|
|
289
|
+
desc: string;
|
|
290
|
+
}> = [
|
|
291
|
+
{
|
|
292
|
+
key: 'page',
|
|
293
|
+
label: 'page',
|
|
294
|
+
desc: '页面基础/分组:inline + start + 基线对齐',
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
key: 'page-stepper',
|
|
298
|
+
label: 'page-stepper',
|
|
299
|
+
desc: '页面分步:sticky + start',
|
|
300
|
+
},
|
|
301
|
+
{ key: 'modal', label: 'modal', desc: '弹窗:inline + end' },
|
|
302
|
+
{ key: 'drawer', label: 'drawer', desc: '抽屉:sticky + start' },
|
|
303
|
+
];
|
|
304
|
+
return (
|
|
305
|
+
<div className="grid w-full grid-cols-2 gap-6">
|
|
306
|
+
{presets.map((p) => (
|
|
307
|
+
<div
|
|
308
|
+
key={p.key}
|
|
309
|
+
className="rounded-md border border-border bg-card p-4"
|
|
310
|
+
>
|
|
311
|
+
<p className="mb-1 text-xs font-medium">{p.label}</p>
|
|
312
|
+
<p className="mb-3 text-xs text-muted-foreground">{p.desc}</p>
|
|
313
|
+
<FieldGroup>
|
|
314
|
+
<Field orientation="horizontal" inputWidth="m">
|
|
315
|
+
<FieldLabel htmlFor={`ct-${p.key}-name`} className="min-w-20">
|
|
316
|
+
名称
|
|
317
|
+
</FieldLabel>
|
|
318
|
+
<Input
|
|
319
|
+
id={`ct-${p.key}-name`}
|
|
320
|
+
style={{ width: 'var(--field-input-width)' }}
|
|
321
|
+
/>
|
|
322
|
+
</Field>
|
|
323
|
+
<FieldActions container={p.key}>
|
|
324
|
+
<Button variant="outline">取消</Button>
|
|
325
|
+
<Button>提交</Button>
|
|
326
|
+
</FieldActions>
|
|
327
|
+
</FieldGroup>
|
|
328
|
+
</div>
|
|
329
|
+
))}
|
|
330
|
+
</div>
|
|
331
|
+
);
|
|
332
|
+
},
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
/** **详情态(density="detail")** — 12px 行距,纯展示无录入(规范 §3.5)。 */
|
|
336
|
+
export const DetailDensity: Story = {
|
|
337
|
+
parameters: { controls: { disable: true } },
|
|
338
|
+
render: () => {
|
|
339
|
+
const rows: Array<{ label: string; value: string }> = [
|
|
340
|
+
{ label: '用户组', value: 'shiyichenyutestgrounp' },
|
|
341
|
+
{ label: '显示名称', value: 'Anthony Edward「Tony」Stark' },
|
|
342
|
+
{ label: '备注', value: 'Iron Man · 这里是备注' },
|
|
343
|
+
{ label: '所属部门', value: 'zhao.yu > 公共部门 > 财务' },
|
|
344
|
+
{ label: 'UID', value: '1231231234567' },
|
|
345
|
+
{ label: '创建时间', value: '2018-09-23 19:34:12' },
|
|
346
|
+
];
|
|
347
|
+
return (
|
|
348
|
+
<div className="grid w-full grid-cols-2 gap-8">
|
|
349
|
+
<div className="rounded-md border border-border bg-card p-4">
|
|
350
|
+
<p className="mb-3 text-xs font-medium">
|
|
351
|
+
density="normal"(20px 行距 · 表单/混合)
|
|
352
|
+
</p>
|
|
353
|
+
<FieldGroup density="normal">
|
|
354
|
+
{rows.map((r) => (
|
|
355
|
+
<Field key={r.label} orientation="horizontal" inputWidth="m">
|
|
356
|
+
<FieldLabel className="min-w-24 shrink-0 text-muted-foreground">
|
|
357
|
+
{r.label}
|
|
358
|
+
</FieldLabel>
|
|
359
|
+
<span className="text-xs">{r.value}</span>
|
|
360
|
+
</Field>
|
|
361
|
+
))}
|
|
362
|
+
</FieldGroup>
|
|
363
|
+
</div>
|
|
364
|
+
<div className="rounded-md border border-border bg-card p-4">
|
|
365
|
+
<p className="mb-3 text-xs font-medium">
|
|
366
|
+
density="detail"(12px 行距 · 详情页)
|
|
367
|
+
</p>
|
|
368
|
+
<FieldGroup density="detail">
|
|
369
|
+
{rows.map((r) => (
|
|
370
|
+
<Field key={r.label} orientation="horizontal" inputWidth="m">
|
|
371
|
+
<FieldLabel className="min-w-24 shrink-0 text-muted-foreground">
|
|
372
|
+
{r.label}
|
|
373
|
+
</FieldLabel>
|
|
374
|
+
<span className="text-xs">{r.value}</span>
|
|
375
|
+
</Field>
|
|
376
|
+
))}
|
|
377
|
+
</FieldGroup>
|
|
378
|
+
</div>
|
|
379
|
+
</div>
|
|
380
|
+
);
|
|
381
|
+
},
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
/** **响应式 orientation** — 拖动 viewport,< 432px 自动改上下结构(规范 §4.2)。 */
|
|
385
|
+
export const ResponsiveOrientation: Story = {
|
|
386
|
+
parameters: {
|
|
387
|
+
controls: { disable: true },
|
|
388
|
+
docs: {
|
|
389
|
+
description: {
|
|
390
|
+
story:
|
|
391
|
+
'orientation 接受 ResponsiveValue:`{ base: "vertical", xs: "horizontal" }` 表示 <432 单栏上下 / ≥432 左右。底层走 useBreakpoint。',
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
render: () => (
|
|
396
|
+
<FieldGroup className="w-full">
|
|
397
|
+
<Field orientation={{ base: 'vertical', xs: 'horizontal' }} inputWidth="m">
|
|
398
|
+
<FieldLabel htmlFor="resp-name" className="min-w-24" required>
|
|
399
|
+
名称
|
|
400
|
+
</FieldLabel>
|
|
401
|
+
<Input
|
|
402
|
+
id="resp-name"
|
|
403
|
+
placeholder="<432 在下,≥432 在右"
|
|
404
|
+
style={{ width: 'var(--field-input-width)' }}
|
|
405
|
+
/>
|
|
406
|
+
</Field>
|
|
407
|
+
<Field orientation={{ base: 'vertical', xs: 'horizontal' }} inputWidth="m">
|
|
408
|
+
<FieldLabel htmlFor="resp-email" className="min-w-24" required>
|
|
409
|
+
邮箱
|
|
410
|
+
</FieldLabel>
|
|
411
|
+
<Input
|
|
412
|
+
id="resp-email"
|
|
413
|
+
type="email"
|
|
414
|
+
placeholder="you@example.com"
|
|
415
|
+
style={{ width: 'var(--field-input-width)' }}
|
|
416
|
+
/>
|
|
417
|
+
</Field>
|
|
418
|
+
</FieldGroup>
|
|
419
|
+
),
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
/** **inputWidth** — 5 档宽度系统(104 / 216 / 328 / 440 / 552 px),子组件可消费 `--field-input-width` CSS 变量。 */
|
|
423
|
+
export const WithInputWidth: Story = {
|
|
424
|
+
parameters: { controls: { disable: true } },
|
|
425
|
+
render: () => (
|
|
426
|
+
<FieldGroup className="w-[600px]">
|
|
427
|
+
{(['xs', 's', 'm', 'l', 'xl'] as const).map((size) => (
|
|
428
|
+
<Field key={size} inputWidth={size}>
|
|
429
|
+
<FieldLabel htmlFor={`w-${size}`}>inputWidth = {size}</FieldLabel>
|
|
430
|
+
<Input
|
|
431
|
+
id={`w-${size}`}
|
|
432
|
+
placeholder={`宽度档位 ${size}`}
|
|
433
|
+
style={{ width: 'var(--field-input-width)' }}
|
|
434
|
+
/>
|
|
435
|
+
</Field>
|
|
436
|
+
))}
|
|
437
|
+
</FieldGroup>
|
|
438
|
+
),
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
/** 组合示例 — Section 分组 + inputWidth 宽度档位 + Actions 操作区。 */
|
|
442
|
+
export const FullFormExample: Story = {
|
|
443
|
+
parameters: { controls: { disable: true } },
|
|
444
|
+
render: () => (
|
|
445
|
+
<div className="flex w-[560px] flex-col gap-8">
|
|
446
|
+
<FieldSection title="账号信息">
|
|
447
|
+
<Field inputWidth="m">
|
|
448
|
+
<FieldLabel htmlFor="full-name" required>
|
|
449
|
+
姓名
|
|
450
|
+
</FieldLabel>
|
|
451
|
+
<Input
|
|
452
|
+
id="full-name"
|
|
453
|
+
placeholder="例:张三"
|
|
454
|
+
style={{ width: 'var(--field-input-width)' }}
|
|
455
|
+
/>
|
|
456
|
+
<FieldDescription>用于显示在主页与通知中</FieldDescription>
|
|
457
|
+
</Field>
|
|
458
|
+
<Field inputWidth="l" invalid>
|
|
459
|
+
<FieldLabel htmlFor="full-email" required>
|
|
460
|
+
邮箱
|
|
461
|
+
</FieldLabel>
|
|
462
|
+
<Input
|
|
463
|
+
id="full-email"
|
|
464
|
+
type="email"
|
|
465
|
+
defaultValue="invalid@"
|
|
466
|
+
style={{ width: 'var(--field-input-width)' }}
|
|
467
|
+
/>
|
|
468
|
+
<FieldError>邮箱格式不正确</FieldError>
|
|
469
|
+
</Field>
|
|
470
|
+
</FieldSection>
|
|
471
|
+
<FieldSection title="偏好设置">
|
|
472
|
+
<Field inputWidth="s">
|
|
473
|
+
<FieldLabel htmlFor="full-nick">昵称</FieldLabel>
|
|
474
|
+
<Input
|
|
475
|
+
id="full-nick"
|
|
476
|
+
style={{ width: 'var(--field-input-width)' }}
|
|
477
|
+
/>
|
|
478
|
+
</Field>
|
|
479
|
+
<Field orientation="horizontal">
|
|
480
|
+
<FieldLabel htmlFor="full-notify" className="min-w-28 pt-2">
|
|
481
|
+
邮件通知
|
|
482
|
+
</FieldLabel>
|
|
483
|
+
<div className="flex-1">
|
|
484
|
+
<Switch id="full-notify" defaultChecked />
|
|
485
|
+
<FieldDescription className="mt-1">
|
|
486
|
+
有重要事件时给您发邮件
|
|
487
|
+
</FieldDescription>
|
|
488
|
+
</div>
|
|
489
|
+
</Field>
|
|
490
|
+
</FieldSection>
|
|
491
|
+
<FieldActions>
|
|
492
|
+
<Button variant="outline">取消</Button>
|
|
493
|
+
<Button>保存</Button>
|
|
494
|
+
</FieldActions>
|
|
495
|
+
</div>
|
|
496
|
+
),
|
|
497
|
+
};
|