ComponentsDemoPage.tsx
7.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import { useState } from 'react';
import {
Alert,
Avatar,
AvatarGroup,
Badge,
Button,
Card,
Checkbox,
Collapse,
ColorInput,
ColorPicker,
DatePicker,
DateRangePicker,
Drawer,
Empty,
Form,
FormItem,
Input,
Message,
Modal,
Pagination,
Popconfirm,
Progress,
Radio,
SearchInput,
Select,
Skeleton,
Steps,
Switch,
Table,
Tabs,
Tag,
Timeline,
Tooltip,
TreeSelect,
} from '../../../packages/ui/src';
import { Icon } from '../../../packages/ui/src/components/Icon';
import styles from './ComponentsDemoPage.module.css';
export function ComponentsDemoPage() {
const tableRows = [{ id: '1', name: '项目A', status: '启用' }];
const [checkboxChecked, setCheckboxChecked] = useState(true);
const [switchChecked, setSwitchChecked] = useState(true);
const [treeValue, setTreeValue] = useState<string | undefined>();
const [dateValue, setDateValue] = useState('2026-05-16');
const [showMessage, setShowMessage] = useState(false);
return (
<section className={styles.page}>
<div className={styles.heading}>
<p className={styles.eyebrow}>Component Library</p>
<h2>组件库 Demo</h2>
<p>全局 UI 组件库展示入口</p>
</div>
<section className={styles.group}>
<h3>基础交互</h3>
<div className={styles.grid}>
<div className={styles.buttonDemo}>
<Button variant="primary">主按钮</Button>
<Button>普通按钮</Button>
<Button variant="outline">描边按钮</Button>
<Button variant="text">文字按钮</Button>
<Button variant="danger">危险按钮</Button>
</div>
<div className={styles.buttonDemo}>
<Button size="small">小按钮</Button>
<Button size="medium">中按钮</Button>
<Button size="large">大按钮</Button>
<Button icon={<Icon name="search" size={14} />}>图标按钮</Button>
<Button disabled>禁用按钮</Button>
<Button loading>加载中</Button>
</div>
<Input aria-label="名称" defaultValue="项目名称" allowClear />
<SearchInput aria-label="搜索" defaultValue="合同" />
<Checkbox label="Demo 启用" checked={checkboxChecked} onChange={setCheckboxChecked} />
<Radio label="按项目" name="demo-radio" checked value="project" />
<Switch aria-label="Demo 启用审批" checked={switchChecked} onChange={setSwitchChecked} />
</div>
</section>
<section className={styles.group}>
<h3>选择与日期</h3>
<div className={styles.grid}>
<Select aria-label="负责人" options={[{ label: '张三', value: 'zhang' }, { label: '李四', value: 'li' }]} />
<TreeSelect aria-label="组织" value={treeValue} onChange={setTreeValue} treeData={[{ label: '总部', value: 'root', children: [{ label: '财务部', value: 'finance' }] }]} />
<DatePicker aria-label="计划日期" value={dateValue} onChange={setDateValue} />
<DateRangePicker aria-label="周期" />
</div>
</section>
<section className={styles.group}>
<h3>表格与分页</h3>
<Table
rowKey="id"
columns={[
{ title: '名称', dataIndex: 'name' },
{ title: '状态', dataIndex: 'status', render: (value) => <Tag status="success">{String(value)}</Tag> },
]}
dataSource={tableRows}
/>
<Table
rowKey="id"
columns={[
{ title: '名称', dataIndex: 'name' },
{ title: '状态', dataIndex: 'status' },
]}
dataSource={[]}
empty={{ description: '暂无审批记录', action: <Button size="small">新建审批</Button> }}
/>
<Pagination current={1} pageSize={10} total={42} />
</section>
<section className={styles.group}>
<h3>反馈与浮层</h3>
<div className={styles.grid}>
<Form className={styles.formDemo} columns={2} initialValues={{ projectName: '', role: '驻店销售岗', remark: '' }}>
<FormItem
label="项目名称"
layout="horizontal"
name="projectName"
required
rules={[{ required: true, message: '请输入项目名称' }]}
>
<Input aria-label="项目名称" />
</FormItem>
<FormItem label="所属岗位" layout="horizontal" name="role" tips="从 Agent 管理自动带入,不可修改">
<Input aria-label="所属岗位" disabled />
</FormItem>
<FormItem label="备注" layout="horizontal" name="remark" span={2}>
<Input aria-label="备注" />
</FormItem>
<Button type="submit" variant="primary">提交表单</Button>
</Form>
{/* <Alert type="info" title="提示">保存后立即生效</Alert> */}
{/* <Button variant="primary" onClick={() => setShowMessage(true)}>展示消息提示</Button> */}
{showMessage ? (
<Message
items={[
{ key: 'demo-save-success', type: 'success', content: '保存成功', duration: 0, closable: true, onClose: () => setShowMessage(false) },
{ key: 'demo-approval-warning', type: 'warning', content: '请补充审批人', duration: 0 },
{ key: 'demo-delete-error', type: 'error', content: '删除失败', duration: 0 },
]}
/>
) : null}
<Tooltip content="补充说明"><Button>帮助</Button></Tooltip>
<Popconfirm title="确认删除?"><Button variant="danger">删除</Button></Popconfirm>
<Modal open={false} title="编辑项目">内容</Modal>
<Drawer open={false} title="详情">内容</Drawer>
</div>
</section>
<section className={styles.group}>
<h3>数据展示</h3>
<div className={styles.grid}>
<Card title="概览" extra={<Button size="small">刷新</Button>}>卡片内容</Card>
<Badge count={12}><Button>消息</Button></Badge>
<AvatarGroup maxCount={2}><Avatar name="张三" /><Avatar name="李四" /><Avatar name="王五" /></AvatarGroup>
<Progress percent={68} percentPosition="top-right" />
<Timeline items={[{ title: '提交', time: '09:00' }, { title: '审批', time: '10:00', description: '处理中' }]} />
</div>
</section>
<section className={styles.group}>
<h3>导航与占位</h3>
<div className={styles.grid}>
<Tabs activeKey="base" items={[{ key: 'base', label: '基础信息', children: '基础内容' }, { key: 'advanced', label: '高级配置', children: '高级内容' }]} />
<Steps current={1} items={[{ title: '提交' }, { title: '审批' }, { title: '完成' }]} />
<Empty description="暂无项目" action={<Button>新建项目</Button>} />
<Skeleton active />
<Collapse activeKeys={['one']} items={[{ key: 'one', title: '基础设置', children: '设置内容' }]} />
</div>
</section>
<section className={styles.group}>
<h3>颜色能力</h3>
<div className={styles.grid}>
<ColorPicker value="#2468f2" />
<ColorInput aria-label="主题色" value="#2468f2" />
</div>
</section>
</section>
);
}