ant-design/components/table/demo/nest-table-border-debug.tsx
二货爱吃白萝卜 832cffcdf9
feat: ColorPicker support gradient color (#50050)
* refactor: support type update

* chore: update clear style

* chore: bump color picker

* chore: use slider

* chore: bump color picker

* chore: range slider

* chore: layout

* chore: useModeColor

* chore: simplify

* chore: bump color picker

* refactor: event

* chore: tmp lock check

* chore: of it

* chore: update ts def

* chore: update ts def

* chore: remove useless ts

* chore: linear

* chore: adjust style

* chore: rm useless code

* chore: fill color

* chore: basic linear

* chore: support toStr

* chore: limit minCount

* chore: use cache

* chore: drag support:

* chore: yes

* chore: update demo

* chore: useLayoutEffect instead

* chore: fix click to add point

* chore: add smmoth

* chore: support of locale

* chore: add locale

* chore: fix lint

* chore: adjust style

* chore: fix lint

* chore: fix style

* test: fix test case

* chore: fix popover

* test: fix test case

* chore: fix test

* test: clean up

* chore: fix lint

* chore: fix lint

* chore: fix lint

* test: coverage

* test: coverage

* test: coverage

* test: coverage

* test: coverage

* test: coverage

* chore: fix docs

* docs: update demo desc

* chore: enhance hover range

* fix: delete not working

* chore: fix lint

* test: coverage

* test: coverage

* chore: clean up

* chore: adjust

* chore: highlight

* chore: adjust style

* chore: fix lint

* chore: update demo

* chore: memo perf

* refactor: up to down colors

* test: update snapshot
2024-07-29 16:38:50 +08:00

123 lines
3.4 KiB
TypeScript

import React, { useState } from 'react';
import { DownOutlined } from '@ant-design/icons';
import type { TableColumnsType, TableProps } from 'antd';
import { Badge, Dropdown, Form, Space, Switch, Table } from 'antd';
interface DataType {
key: React.Key;
name: string;
platform: string;
version: string;
upgradeNum: number;
creator: string;
createdAt: string;
}
interface ExpandedDataType {
key: React.Key;
date: string;
name: string;
upgradeNum: string;
}
const items = [
{ key: '1', label: 'Action 1' },
{ key: '2', label: 'Action 2' },
];
const App: React.FC = () => {
const createExpandedRowRender = (bordered: boolean) => () => {
const columns: TableProps['columns'] = [
{ title: 'Date', dataIndex: 'date', key: 'date' },
{ title: 'Name', dataIndex: 'name', key: 'name' },
{
title: 'Status',
key: 'state',
render: () => (
<span>
<Badge status="success" />
Finished
</span>
),
},
{ title: 'Upgrade Status', dataIndex: 'upgradeNum', key: 'upgradeNum' },
{
title: 'Action',
dataIndex: 'operation',
key: 'operation',
render: () => (
<Space size="middle">
<a>Pause</a>
<a>Stop</a>
<Dropdown menu={{ items }}>
<a>
More <DownOutlined />
</a>
</Dropdown>
</Space>
),
},
];
const data: ExpandedDataType[] = [];
for (let i = 0; i < 3; ++i) {
data.push({
key: i,
date: '2014-12-24 23:12:00',
name: 'This is production name',
upgradeNum: 'Upgraded: 56',
});
}
return <Table columns={columns} dataSource={data} pagination={false} bordered={bordered} />;
};
const columns: TableColumnsType<DataType> = [
{ title: 'Name', dataIndex: 'name', key: 'name' },
{ title: 'Platform', dataIndex: 'platform', key: 'platform' },
{ title: 'Version', dataIndex: 'version', key: 'version' },
{ title: 'Upgraded', dataIndex: 'upgradeNum', key: 'upgradeNum' },
{ title: 'Creator', dataIndex: 'creator', key: 'creator' },
{ title: 'Date', dataIndex: 'createdAt', key: 'createdAt' },
{ title: 'Action', key: 'operation', render: () => <a>Publish</a> },
];
const data: DataType[] = [];
for (let i = 0; i < 3; ++i) {
data.push({
key: i,
name: 'Screem',
platform: 'iOS',
version: '10.3.4.5654',
upgradeNum: 500,
creator: 'Jack',
createdAt: '2014-12-24 23:12:00',
});
}
const [rootTableBordered, setRootTableBordered] = useState(true);
const [childTableBordered, setChildTableBordered] = useState(true);
return (
<>
<Form layout="inline" className="table-demo-control-bar" style={{ marginBottom: 16 }}>
<Form.Item label="Root Table Bordered">
<Switch checked={rootTableBordered} onChange={(v) => setRootTableBordered(v)} />
</Form.Item>
<Form.Item label="Child Table Bordered">
<Switch checked={childTableBordered} onChange={(v) => setChildTableBordered(v)} />
</Form.Item>
</Form>
<Table
title={() => 'cool'}
footer={() => 'cool'}
columns={columns}
expandable={{ expandedRowRender: createExpandedRowRender(childTableBordered) }}
dataSource={data}
bordered={rootTableBordered}
/>
</>
);
};
export default App;