ComponentsDemoPage.tsx
12.2 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
import { useState } from 'react';
import {
Alert,
Avatar,
AvatarGroup,
Badge,
Button,
Card,
Checkbox,
Collapse,
ColorInput,
ColorPicker,
DatePicker,
DateRangePicker,
Drawer,
Empty,
Form,
FormItem,
Input,
Message,
MediaWall,
Modal,
Navigation,
Pagination,
Popconfirm,
Progress,
Radio,
SearchInput,
Select,
Skeleton,
StatePlaceholder,
Steps,
Switch,
Table,
Tabs,
Tag,
Timeline,
Tooltip,
TreeSelect,
Textarea,
UploadDragger,
} 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 [multiSelectValue, setMultiSelectValue] = useState<string[]>(['zhang', 'li']);
const [tagSelectValue, setTagSelectValue] = useState<string[]>(['zhang', 'li']);
const [dateValue, setDateValue] = useState('2026-05-16');
const [showMessage, setShowMessage] = useState(false);
const [modalOpen, setModalOpen] = useState(true);
const mediaImage =
'data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2296%22 height=%2296%22 viewBox=%220 0 96 96%22%3E%3Crect width=%2296%22 height=%2296%22 fill=%22%23dbeafe%22/%3E%3Ccircle cx=%2232%22 cy=%2235%22 r=%2210%22 fill=%22%232468f2%22/%3E%3Cpath d=%22M12 78 39 52l14 13 12-17 19 30Z%22 fill=%22%231f5bd6%22/%3E%3C/svg%3E';
const mediaVideo =
'data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2296%22 height=%2296%22 viewBox=%220 0 96 96%22%3E%3Crect width=%2296%22 height=%2296%22 fill=%22%231f2633%22/%3E%3Cpath d=%22M18 72 38 45l13 12 11-18 16 33Z%22 fill=%22%23667085%22/%3E%3Ccircle cx=%2270%22 cy=%2226%22 r=%2210%22 fill=%22%23f59e0b%22/%3E%3C/svg%3E';
const placeholderStates = [
{ state: 'empty' as const, title: '暂无数据', description: '请先创建项目' },
{
state: 'filtered-empty' as const,
title: '未找到匹配结果',
description: '请调整搜索或筛选条件',
secondaryAction: <Button size="small">清空筛选</Button>,
},
{
state: 'forbidden' as const,
title: '权限受限',
description: '当前账号暂无访问权限',
primaryAction: <Button size="small">申请权限</Button>,
},
{
state: 'offline' as const,
title: '网络不可用',
description: '请检查网络连接后重试',
primaryAction: <Button size="small">重新连接</Button>,
},
];
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 showCount maxLength={20} />
<Textarea aria-label="备注" defaultValue="补充说明" showCount maxLength={120} />
<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' }]} />
<Select
multiple
aria-label="负责人多选"
allowClear
placeholder="请选择负责人"
value={multiSelectValue}
options={[
{ label: '张三', value: 'zhang' },
{ label: '李四', value: 'li' },
{ label: '王五', value: 'wang' },
]}
onChange={setMultiSelectValue}
/>
<Select
multiple
aria-label="负责人标签多选"
allowClear
placeholder="请选择负责人"
value={tagSelectValue}
options={[
{ label: '张三', value: 'zhang' },
{ label: '李四', value: 'li' },
{ label: '王五', value: 'wang' },
]}
onChange={setTagSelectValue}
/>
<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={1} 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={modalOpen} title="编辑项目" onCancel={() => setModalOpen(false)}>内容</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}>
<Navigation
activeKey="agent-list"
items={[
{ key: 'agent-management', label: 'Agent管理', children: [{ key: 'agent-list', label: 'Agent列表' }] },
]}
/>
<Tabs activeKey="base" items={[{ key: 'base', label: '基础信息', children: '基础内容' }, { key: 'advanced', label: '高级配置', children: '高级内容' }]} />
<Steps current={1} items={[{ title: '提交' }, { title: '审批' }, { title: '完成' }]} />
<Empty description="暂无项目" action={<Button>新建项目</Button>} />
<StatePlaceholder
state="error"
title="加载失败"
description="列表请求失败,当前数据状态未知"
primaryAction={<Button size="small">重试</Button>}
/>
<div className={styles.placeholderDemo}>
{placeholderStates.map((item) => (
<StatePlaceholder
key={item.state}
state={item.state}
title={item.title}
description={item.description}
primaryAction={item.primaryAction}
secondaryAction={item.secondaryAction}
/>
))}
</div>
<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 className={styles.group}>
<h3>上传</h3>
<div className={styles.uploadDemo}>
<UploadDragger
title="点击或拖拽业务资料到此上传"
helperText="支持分片断点续传,单文件上限 1GB"
files={[
{ id: 'design', name: 'product_design_v2.fig', size: 12.4 * 1024 * 1024, status: 'success', previewable: true },
{ id: 'doc', name: '需求文档.pdf', size: 3.2 * 1024 * 1024, status: 'progress', progress: 42 },
{ id: 'zip', name: '素材包.zip', size: 18.8 * 1024 * 1024, status: 'fail', errorMessage: '网络异常,请重试' },
]}
onPreview={() => undefined}
onDownload={() => undefined}
onRemove={() => undefined}
onRetry={() => undefined}
onCancel={() => undefined}
/>
<MediaWall
items={[
{ id: 'image', type: 'image', src: mediaImage, alt: '宣传图' },
{ id: 'video', type: 'video', src: mediaVideo, alt: '演示视频' },
]}
helperText="支持 JPG、PNG、MP4、MOV,图片单张不超过 10MB,视频单个不超过 500MB"
onPreview={() => undefined}
/>
</div>
</section>
</section>
);
}