2022-11-09 12:28:04 +08:00
|
|
|
import type { RadioChangeEvent } from 'antd';
|
|
|
|
import {
|
|
|
|
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,
|
|
|
|
TimePicker,
|
|
|
|
Transfer,
|
|
|
|
} from 'antd';
|
|
|
|
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 = () => {
|
2022-11-09 12:28:04 +08:00
|
|
|
const [open, setOpen] = useState(false);
|
|
|
|
|
|
|
|
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',
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2023-01-19 15:37:54 +08:00
|
|
|
<Space
|
|
|
|
direction="vertical"
|
|
|
|
size={[0, 16]}
|
|
|
|
style={{ width: '100%', paddingTop: 16, borderTop: `1px solid #d9d9d9` }}
|
|
|
|
>
|
|
|
|
<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={[]} />
|
|
|
|
<div style={{ width: 320, border: `1px solid #d9d9d9`, borderRadius: 8 }}>
|
2022-11-09 12:28:04 +08:00
|
|
|
<Calendar fullscreen={false} value={dayjs()} />
|
|
|
|
</div>
|
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-01-19 15:37:54 +08:00
|
|
|
</Space>
|
2022-11-09 12:28:04 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const App: React.FC = () => {
|
|
|
|
const [locale, setLocal] = useState(enUS);
|
|
|
|
|
|
|
|
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;
|