Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support virtual Table #1012

Merged
merged 55 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
6fe062f
chore: init
zombieJ Aug 15, 2023
e409a7e
chore: static of columns
zombieJ Aug 15, 2023
d37b0eb
feat: use virtual
zombieJ Aug 15, 2023
e921da7
chore: merge master
zombieJ Aug 15, 2023
015ff4e
refactor: extract func
zombieJ Aug 17, 2023
9a8cf51
chore: use internal hook
zombieJ Aug 17, 2023
e6a3306
test: rm useless test
zombieJ Aug 17, 2023
5348044
chore: support fixed
zombieJ Aug 17, 2023
c7be9c0
chore: scroll support
zombieJ Aug 17, 2023
663037a
chore: scroll sync
zombieJ Aug 17, 2023
441678c
chore: fixed pos
zombieJ Aug 17, 2023
3407012
chore: fix style
zombieJ Aug 17, 2023
81db373
chore: opt flatten
zombieJ Aug 17, 2023
e3e81d8
chore: part of it
zombieJ Aug 17, 2023
3b653f1
chore: collect rows
zombieJ Aug 17, 2023
95d4465
chore: collect rowSpan
zombieJ Aug 17, 2023
5202ecc
refactor: virtual cell
zombieJ Aug 17, 2023
c281263
chore: rowSpan support
zombieJ Aug 18, 2023
68fe6ba
feat: rowSpan & colSpan
zombieJ Aug 18, 2023
36a91a8
chore: row & col span
zombieJ Aug 18, 2023
2db1737
chore: update cal
zombieJ Aug 18, 2023
4daf988
fix: edge logic
zombieJ Aug 18, 2023
382386d
chore: use fixed line
zombieJ Aug 18, 2023
7f36f9a
chore: use line align
zombieJ Aug 18, 2023
4838a9d
chore: bump rc-virtual-list
zombieJ Aug 18, 2023
298024d
chore: clean up
zombieJ Aug 18, 2023
33799fc
chore: refactor name
zombieJ Aug 18, 2023
5b9d13d
chore: use create immutable
zombieJ Aug 19, 2023
b8d839b
chore: clean up
zombieJ Aug 19, 2023
03e33c9
chore: bump rc-virtual-list
zombieJ Aug 19, 2023
e2453e8
refactor: move useRowInfo in a single file
zombieJ Aug 20, 2023
278a471
chore: tmp of columns
zombieJ Aug 20, 2023
3c2ac91
chore: fix sticky expand
zombieJ Aug 20, 2023
2c044ac
refactor: move hooks
zombieJ Aug 20, 2023
ed838a7
refactor: move hooks
zombieJ Aug 20, 2023
a3e7ee9
chore: expanded support
zombieJ Aug 20, 2023
e5c1860
chore: row expandable
zombieJ Aug 20, 2023
3d35faf
chore: refactor name
zombieJ Aug 20, 2023
ba03688
refactor: row in
zombieJ Aug 20, 2023
c9a7126
refactor: move rowClass in
zombieJ Aug 20, 2023
32c8b4a
chore: expanded info
zombieJ Aug 20, 2023
82d959c
chore: virtual
zombieJ Aug 20, 2023
d71d007
Update package.json
zombieJ Aug 20, 2023
b763fd2
chore: update span logic
zombieJ Aug 21, 2023
6d67446
Merge branch 'static-table' of https://github.com/react-component/tab…
zombieJ Aug 21, 2023
9bdcdd4
7.33.0-alpha.0
zombieJ Aug 21, 2023
28d54a6
feat: support listItemHeight
zombieJ Aug 22, 2023
dca77e3
7.33.0-alpha.1
zombieJ Aug 22, 2023
da814ef
chore: nest of cell in row
zombieJ Aug 22, 2023
eb0589b
7.33.0-alpha.2
zombieJ Aug 22, 2023
aa6e206
fix: not render if no data
zombieJ Aug 22, 2023
16ce02b
7.33.0-alpha.3
zombieJ Aug 22, 2023
19c4d96
chore: add empty style
zombieJ Aug 22, 2023
775974d
7.33.0-alpha.4
zombieJ Aug 22, 2023
a03f950
test: update testcase
zombieJ Aug 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions assets/index.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import 'virtual.less';

@tablePrefixCls: rc-table;
@text-color: #666;
@font-size-base: 12px;
Expand Down Expand Up @@ -55,9 +57,11 @@

// ================== Cell ==================
&-cell {
background: #f4f4f4;

&-fix-left,
&-fix-right {
z-index: 1;
z-index: 2;
}

&-fix-right:last-child:not(&-fix-sticky) {
Expand Down Expand Up @@ -137,7 +141,7 @@
}

&&-row-hover {
background: rgba(255, 0, 0, 0.05);
background: #fff4f4;
}
}

Expand Down
23 changes: 23 additions & 0 deletions assets/virtual.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@import (reference) 'index.less';

.@{tablePrefixCls}-tbody-virtual {
* {
box-sizing: border-box;
}

.@{tablePrefixCls}-row {
display: flex;
width: 100%;
border-bottom: 1px solid @border-color;
border-left: 1px solid @border-color;
}

.@{tablePrefixCls}-cell {
flex: 1 0 auto;
padding: 8px 16px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
border-right: 1px solid @border-color;
}
}
8 changes: 8 additions & 0 deletions docs/demo/virtual.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Virtual
nav:
title: Demo
path: /demo
---

<code src="../examples/virtual.tsx"></code>
78 changes: 78 additions & 0 deletions docs/examples/virtual.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React from 'react';
import '../../assets/index.less';
import type { ColumnsType } from '../../src/interface';
import Table from '../../src/StaticTable';

interface RecordType {
a: string;
b?: string;
c?: string;
d: number;
indexKey: string;
}

const columns: ColumnsType = [
{ title: 'title1', dataIndex: 'a', key: 'a', width: 100, fixed: 'left' },
{ title: 'title2', dataIndex: 'b', key: 'b', width: 100, fixed: 'left', ellipsis: true },
{ title: 'title3', dataIndex: 'c', key: 'c' },
// { title: 'title4', dataIndex: 'b', key: 'd' },
// { title: 'title5', dataIndex: 'b', key: 'e' },
{
title: 'title4',
key: 'd',
children: [
// Children columns
{ title: 'title4-1' },
{ title: 'title4-2' },
],
},
{ title: 'title6', dataIndex: 'b', key: 'f' },
{
title: (
<div>
title7
<br />
<br />
<br />
Hello world!
</div>
),
dataIndex: 'b',
key: 'g',
},
{ title: 'title8', dataIndex: 'b' },
{ title: 'title9', dataIndex: 'b', key: 'i' },
{ title: 'title10', dataIndex: 'b', key: 'j' },
{ title: 'title11', dataIndex: 'b', key: 'k', width: 50, fixed: 'right' },
{ title: 'title12', dataIndex: 'b', key: 'l', width: 100, fixed: 'right' },
];

const data: RecordType[] = new Array(1000).fill(null).map((_, index) => ({
a: `a${index}`,
b: `b${index}`,
c: `c${index}`,
d: index,
indexKey: `${index}`,
}));

const Demo = () => {
const [scrollY, setScrollY] = React.useState(true);

return (
<div style={{ width: 800, padding: 64 }}>
<label>
<input type="checkbox" checked={scrollY} onChange={() => setScrollY(!scrollY)} />
Scroll Y
</label>
<Table
columns={columns}
// expandedRowRender={({ b, c }) => b || c}
scroll={{ x: 1200, y: scrollY ? 200 : null }}
data={data}
rowKey="indexKey"
/>
</div>
);
};

export default Demo;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"@rc-component/context": "^1.3.0",
"classnames": "^2.2.5",
"rc-resize-observer": "^1.1.0",
"rc-util": "^5.27.1"
"rc-util": "^5.27.1",
zombieJ marked this conversation as resolved.
Show resolved Hide resolved
"rc-virtual-list": "^3.7.0"
},
"devDependencies": {
"@rc-component/father-plugin": "^1.0.2",
Expand Down
Loading
Loading