2023-02-28 16:32:49 +08:00
|
|
|
import { EllipsisOutlined } from '@ant-design/icons';
|
|
|
|
import type { RadioChangeEvent, TourProps, UploadFile } from 'antd';
|
2022-11-09 12:28:04 +08:00
|
|
|
import {
|
2023-02-28 16:32:49 +08:00
|
|
|
Upload,
|
|
|
|
Tour,
|
|
|
|
Input,
|
|
|
|
Form,
|
|
|
|
QRCode,
|
2022-11-09 12:28:04 +08:00
|
|
|
Button,
|
|
|
|
Calendar,
|
|
|
|
ConfigProvider,
|
|
|
|
DatePicker,
|
|
|
|
Modal,
|
|
|
|
Pagination,
|
|
|
|
Popconfirm,
|
|
|
|
Radio,
|
|
|
|
Select,
|
2023-01-19 15:37:54 +08:00
|
|
|
Space,
|
2022-11-09 12:28:04 +08:00
|
|
|
Table,
|
2023-02-27 10:12:32 +08:00
|
|
|
theme,
|
2022-11-09 12:28:04 +08:00
|
|
|
TimePicker,
|
|
|
|
Transfer,
|
2023-02-28 16:32:49 +08:00
|
|
|
Image,
|
|
|
|
InputNumber,
|
|
|
|
Divider,
|
2022-11-09 12:28:04 +08:00
|
|
|
} from 'antd';
|
2023-02-27 10:12:32 +08:00
|
|
|
import type { Locale } from 'antd/es/locale';
|
2022-11-09 12:28:04 +08:00
|
|
|
import enUS from 'antd/locale/en_US';
|
|
|
|
import zhCN from 'antd/locale/zh_CN';
|
2023-01-19 15:37:54 +08:00
|
|
|
import dayjs from 'dayjs';
|
|
|
|
import 'dayjs/locale/zh-cn';
|
|
|
|
import React, { useState } from 'react';
|
2022-11-09 12:28:04 +08:00
|
|
|
|
|
|
|
dayjs.locale('en');
|
|
|
|
|
|
|
|
const { Option } = Select;
|
|
|
|
const { RangePicker } = DatePicker;
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
{
|
|
|
|
title: 'Name',
|
|
|
|
dataIndex: 'name',
|
2023-01-19 15:37:54 +08:00
|
|
|
filters: [{ text: 'filter1', value: 'filter1' }],
|
2022-11-09 12:28:04 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Age',
|
|
|
|
dataIndex: 'age',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2023-01-19 15:37:54 +08:00
|
|
|
const Page: React.FC = () => {
|
2023-02-27 10:12:32 +08:00
|
|
|
const { token } = theme.useToken();
|
|
|
|
|
2022-11-09 12:28:04 +08:00
|
|
|
const [open, setOpen] = useState(false);
|
2023-02-28 16:32:49 +08:00
|
|
|
const [tourOpen, setTourOpen] = useState(false);
|
|
|
|
const tourRefs = React.useRef<HTMLElement[]>([]);
|
2022-11-09 12:28:04 +08:00
|
|
|
|
|
|
|
const showModal = () => {
|
|
|
|
setOpen(true);
|
|
|
|
};
|
|
|
|
|
|
|
|
const hideModal = () => {
|
|
|
|
setOpen(false);
|
|
|
|
};
|
|
|
|
|
|
|
|
const info = () => {
|
|
|
|
Modal.info({
|
|
|
|
title: 'some info',
|
|
|
|
content: 'some info',
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const confirm = () => {
|
|
|
|
Modal.confirm({
|
|
|
|
title: 'some info',
|
|
|
|
content: 'some info',
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-02-28 16:32:49 +08:00
|
|
|
const steps: TourProps['steps'] = [
|
|
|
|
{
|
|
|
|
title: 'Upload File',
|
|
|
|
description: 'Put your files here.',
|
|
|
|
target: () => tourRefs.current[0],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Save',
|
|
|
|
description: 'Save your changes.',
|
|
|
|
target: () => tourRefs.current[1],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Other Actions',
|
|
|
|
description: 'Click to see other actions.',
|
|
|
|
target: () => tourRefs.current[2],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const fileList: UploadFile[] = [
|
|
|
|
{
|
|
|
|
uid: '-1',
|
|
|
|
name: 'image.png',
|
|
|
|
status: 'done',
|
|
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
uid: '-2',
|
|
|
|
percent: 50,
|
|
|
|
name: 'image.png',
|
|
|
|
status: 'uploading',
|
|
|
|
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
uid: '-3',
|
|
|
|
name: 'image.png',
|
|
|
|
status: 'error',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2022-11-09 12:28:04 +08:00
|
|
|
return (
|
2023-01-19 15:37:54 +08:00
|
|
|
<Space
|
|
|
|
direction="vertical"
|
|
|
|
size={[0, 16]}
|
2023-02-28 16:32:49 +08:00
|
|
|
style={{ width: '100%', paddingTop: 16, borderTop: `1px solid ${token.colorBorder}` }}
|
2023-01-19 15:37:54 +08:00
|
|
|
>
|
|
|
|
<Pagination defaultCurrent={1} total={50} showSizeChanger />
|
|
|
|
<Space wrap>
|
2022-11-09 12:28:04 +08:00
|
|
|
<Select showSearch style={{ width: 200 }}>
|
|
|
|
<Option value="jack">jack</Option>
|
|
|
|
<Option value="lucy">lucy</Option>
|
|
|
|
</Select>
|
|
|
|
<DatePicker />
|
|
|
|
<TimePicker />
|
|
|
|
<RangePicker style={{ width: 200 }} />
|
2023-01-19 15:37:54 +08:00
|
|
|
</Space>
|
|
|
|
<Space wrap>
|
2022-11-09 12:28:04 +08:00
|
|
|
<Button type="primary" onClick={showModal}>
|
|
|
|
Show Modal
|
|
|
|
</Button>
|
|
|
|
<Button onClick={info}>Show info</Button>
|
|
|
|
<Button onClick={confirm}>Show confirm</Button>
|
|
|
|
<Popconfirm title="Question?">
|
|
|
|
<a href="#">Click to confirm</a>
|
|
|
|
</Popconfirm>
|
2023-01-19 15:37:54 +08:00
|
|
|
</Space>
|
|
|
|
<Transfer dataSource={[]} showSearch targetKeys={[]} />
|
2023-02-27 10:12:32 +08:00
|
|
|
<div style={{ width: 320, border: `1px solid ${token.colorBorder}`, borderRadius: 8 }}>
|
2022-11-09 12:28:04 +08:00
|
|
|
<Calendar fullscreen={false} value={dayjs()} />
|
|
|
|
</div>
|
2023-02-28 16:32:49 +08:00
|
|
|
<Form name="basic" autoComplete="off" labelCol={{ sm: { span: 4 } }} wrapperCol={{ span: 6 }}>
|
|
|
|
<Form.Item label="Username" name="username" rules={[{ required: true }]}>
|
|
|
|
<Input width={200} />
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item
|
|
|
|
label="Age"
|
|
|
|
name="age"
|
|
|
|
rules={[{ type: 'number', min: 0, max: 99 }]}
|
|
|
|
initialValue={100}
|
|
|
|
>
|
|
|
|
<InputNumber width={200} />
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item wrapperCol={{ offset: 2, span: 6 }}>
|
|
|
|
<Button type="primary" htmlType="submit">
|
|
|
|
Submit
|
|
|
|
</Button>
|
|
|
|
</Form.Item>
|
|
|
|
</Form>
|
2023-01-19 15:37:54 +08:00
|
|
|
<Table dataSource={[]} columns={columns} />
|
2022-11-09 12:28:04 +08:00
|
|
|
<Modal title="Locale Modal" open={open} onCancel={hideModal}>
|
|
|
|
<p>Locale Modal</p>
|
|
|
|
</Modal>
|
2023-02-28 16:32:49 +08:00
|
|
|
<Space wrap size={80}>
|
|
|
|
<QRCode
|
|
|
|
value="https://ant.design/"
|
|
|
|
status="expired"
|
|
|
|
onRefresh={() => console.log('refresh')}
|
|
|
|
/>
|
|
|
|
<Image
|
|
|
|
width={160}
|
|
|
|
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
|
|
|
|
/>
|
|
|
|
</Space>
|
|
|
|
<Upload listType="picture-card" fileList={fileList} />
|
|
|
|
<Divider orientation="left">Tour</Divider>
|
|
|
|
<Button type="primary" onClick={() => setTourOpen(true)}>
|
|
|
|
Begin Tour
|
|
|
|
</Button>
|
|
|
|
<Space>
|
|
|
|
<Button ref={(node) => node && tourRefs.current.splice(0, 0, node)}> Upload</Button>
|
|
|
|
<Button ref={(node) => node && tourRefs.current.splice(1, 0, node)} type="primary">
|
|
|
|
Save
|
|
|
|
</Button>
|
|
|
|
<Button
|
|
|
|
ref={(node) => node && tourRefs.current.splice(2, 0, node)}
|
|
|
|
icon={<EllipsisOutlined />}
|
|
|
|
/>
|
|
|
|
</Space>
|
|
|
|
<Tour open={tourOpen} steps={steps} onClose={() => setTourOpen(false)} />
|
2023-01-19 15:37:54 +08:00
|
|
|
</Space>
|
2022-11-09 12:28:04 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const App: React.FC = () => {
|
2023-02-27 10:12:32 +08:00
|
|
|
const [locale, setLocal] = useState<Locale>(enUS);
|
2022-11-09 12:28:04 +08:00
|
|
|
|
|
|
|
const changeLocale = (e: RadioChangeEvent) => {
|
|
|
|
const localeValue = e.target.value;
|
|
|
|
setLocal(localeValue);
|
|
|
|
if (!localeValue) {
|
|
|
|
dayjs.locale('en');
|
|
|
|
} else {
|
|
|
|
dayjs.locale('zh-cn');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2023-01-19 18:05:54 +08:00
|
|
|
<>
|
2023-01-19 15:37:54 +08:00
|
|
|
<div style={{ marginBottom: 16 }}>
|
2023-01-19 18:05:54 +08:00
|
|
|
<span style={{ marginRight: 16 }}>Change locale of components:</span>
|
2022-11-09 12:28:04 +08:00
|
|
|
<Radio.Group value={locale} onChange={changeLocale}>
|
|
|
|
<Radio.Button key="en" value={enUS}>
|
|
|
|
English
|
|
|
|
</Radio.Button>
|
|
|
|
<Radio.Button key="cn" value={zhCN}>
|
|
|
|
中文
|
|
|
|
</Radio.Button>
|
|
|
|
</Radio.Group>
|
|
|
|
</div>
|
|
|
|
<ConfigProvider locale={locale}>
|
2023-01-19 18:05:54 +08:00
|
|
|
<Page />
|
2022-11-09 12:28:04 +08:00
|
|
|
</ConfigProvider>
|
2023-01-19 18:05:54 +08:00
|
|
|
</>
|
2022-11-09 12:28:04 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default App;
|