Skip to content

Commit bb6e0ed

Browse files
committed
chore: init
1 parent d218893 commit bb6e0ed

File tree

4 files changed

+92
-20
lines changed

4 files changed

+92
-20
lines changed

docs/demo/stack-columns.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Stack Columns
3+
nav:
4+
title: Demo
5+
path: /demo
6+
---
7+
8+
<code src="../examples/stack-columns.tsx"></code>

docs/examples/stack-columns.tsx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import type { ColumnType } from 'rc-table';
2+
import Table from 'rc-table';
3+
import React from 'react';
4+
import '../../assets/index.less';
5+
6+
interface RecordType {
7+
a: string;
8+
b?: string;
9+
c?: string;
10+
d: number;
11+
key: string;
12+
}
13+
14+
const columns: ColumnType<RecordType>[] = [
15+
{ title: 'title1', dataIndex: 'a', key: 'a', width: 100, fixed: 'left' },
16+
{ title: 'title2', dataIndex: 'b', key: 'b', width: 50 },
17+
{ title: 'title3', dataIndex: 'c', key: 'c', fixed: 'left' },
18+
{ title: 'title4', dataIndex: 'b', key: 'd' },
19+
{ title: 'title5', dataIndex: 'b', key: 'e' },
20+
{ title: 'title6', dataIndex: 'b', key: 'f' },
21+
{
22+
title: 'title7',
23+
dataIndex: 'b',
24+
key: 'g',
25+
},
26+
{ title: 'title8', dataIndex: 'b', key: 'h' },
27+
{ title: 'title9', dataIndex: 'b', key: 'i' },
28+
{ title: 'title10', dataIndex: 'b', key: 'j', fixed: 'right' },
29+
{ title: 'title11', dataIndex: 'b', key: 'k', width: 50 },
30+
{ title: 'title12', dataIndex: 'b', key: 'l', width: 100, fixed: 'right' },
31+
];
32+
33+
const data: RecordType[] = [
34+
{
35+
a: '123',
36+
b: 'x',
37+
d: 3,
38+
key: '1',
39+
},
40+
];
41+
42+
const Demo = () => {
43+
const [scrollY, setScrollY] = React.useState(true);
44+
45+
return (
46+
<div style={{ width: 800 }}>
47+
<label>
48+
<input type="checkbox" checked={scrollY} onChange={() => setScrollY(!scrollY)} />
49+
Scroll Y
50+
</label>
51+
<Table
52+
// direction="rtl"
53+
columns={columns}
54+
scroll={{ x: 1200 }}
55+
data={data}
56+
/>
57+
</div>
58+
);
59+
};
60+
61+
export default Demo;

src/interface.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ import type { DeepNamePath } from './namePathType';
2020

2121
export type Key = React.Key;
2222

23-
export type FixedType = 'left' | 'right' | boolean;
23+
/**
24+
* Use `start` or `end` instead. `left` or `right` is deprecated.
25+
*/
26+
export type FixedType = 'start' | 'end' | 'left' | 'right' | boolean;
2427

2528
export type DefaultRecordType = Record<string, any>;
2629

src/utils/fixUtil.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,26 @@ export function getCellFixedInfo(
4242
const prevColumn = columns[colStart - 1];
4343

4444
// need show shadow only when canLastFix is true
45-
const canLastFix =
46-
(nextColumn && !nextColumn.fixed) ||
47-
(prevColumn && !prevColumn.fixed) ||
48-
columns.every(col => col.fixed === 'left');
45+
// const canLastFix =
46+
// (nextColumn && !nextColumn.fixed) ||
47+
// (prevColumn && !prevColumn.fixed) ||
48+
// columns.every(col => col.fixed === 'left');
4949

50-
if (direction === 'rtl') {
51-
if (fixLeft !== undefined) {
52-
const prevFixLeft = prevColumn && prevColumn.fixed === 'left';
53-
firstFixLeft = !prevFixLeft && canLastFix;
54-
} else if (fixRight !== undefined) {
55-
const nextFixRight = nextColumn && nextColumn.fixed === 'right';
56-
lastFixRight = !nextFixRight && canLastFix;
57-
}
58-
} else if (fixLeft !== undefined) {
59-
const nextFixLeft = nextColumn && nextColumn.fixed === 'left';
60-
lastFixLeft = !nextFixLeft && canLastFix;
61-
} else if (fixRight !== undefined) {
62-
const prevFixRight = prevColumn && prevColumn.fixed === 'right';
63-
firstFixRight = !prevFixRight && canLastFix;
64-
}
50+
// if (direction === 'rtl') {
51+
// if (fixLeft !== undefined) {
52+
// const prevFixLeft = prevColumn && prevColumn.fixed === 'left';
53+
// firstFixLeft = !prevFixLeft && canLastFix;
54+
// } else if (fixRight !== undefined) {
55+
// const nextFixRight = nextColumn && nextColumn.fixed === 'right';
56+
// lastFixRight = !nextFixRight && canLastFix;
57+
// }
58+
// } else if (fixLeft !== undefined) {
59+
// const nextFixLeft = nextColumn && nextColumn.fixed === 'left';
60+
// lastFixLeft = !nextFixLeft && canLastFix;
61+
// } else if (fixRight !== undefined) {
62+
// const prevFixRight = prevColumn && prevColumn.fixed === 'right';
63+
// firstFixRight = !prevFixRight && canLastFix;
64+
// }
6565

6666
return {
6767
fixLeft,

0 commit comments

Comments
 (0)