Skip to content

Commit 4fab1d2

Browse files
committed
feat: remove columnResizable
1 parent bcd8477 commit 4fab1d2

File tree

7 files changed

+36
-23
lines changed

7 files changed

+36
-23
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ React.render(<Table columns={columns} data={data} />, mountNode);
118118
| sticky | boolean \| {offsetHeader?: number, offsetScroll?: number, getContainer?: () => Window \| HTMLElement } | false | stick header and scroll bar |
119119
| summary | (data: readonly RecordType[]) => React.ReactNode | - | `summary` attribute in `table` component is used to define the summary row. |
120120
| rowHoverable | boolean | true | Table hover interaction |
121-
| columnResizable | boolean | false | Column resizable |
122121

123122
## Column Props
124123

docs/examples/column-resize.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useState } from 'react';
22
import Table from 'rc-table';
3+
import type { ColumnType } from 'rc-table';
34
import '../../assets/index.less';
45

56
const data = [
@@ -22,8 +23,9 @@ const Demo = () => {
2223
{ title: 'title2', dataIndex: 'bbb', key: 'bbb', width: 100 },
2324
].map(i => ({
2425
...i,
26+
resizable: true,
2527
width: widthMap.get(i.key ?? i.dataIndex) ?? i.width,
26-
}));
28+
})) as ColumnType<any>[];
2729

2830
const columns2 = [
2931
{ title: 'title1', dataIndex: 'a', key: 'a', fixed: 'left' },
@@ -40,16 +42,16 @@ const Demo = () => {
4042
{ title: 'title12', dataIndex: 'b', key: 'l', fixed: 'right' },
4143
].map(i => ({
4244
...i,
45+
resizable: true,
4346
width: widthMap.get(i.key ?? i.dataIndex) ?? 150,
44-
}));
47+
})) as ColumnType<any>[];
4548

4649
return (
4750
<div>
4851
table width: 800px {'columns=[{width: 100, width: 100}]'} 情况
4952
<Table
50-
columnResizable
5153
style={{ width: 800 }}
52-
scroll={{ y: 300, x: columns1.reduce((t, c) => t + c.width, 0) }}
54+
scroll={{ y: 300, x: columns1.reduce((t, c) => t + (c.width as number), 0) }}
5355
columns={columns1}
5456
data={data}
5557
onColumnResizeComplete={({ columnKeyWidths }) => {
@@ -65,9 +67,8 @@ const Demo = () => {
6567
<br />
6668
大多数情况
6769
<Table
68-
columnResizable
6970
style={{ width: 800 }}
70-
scroll={{ y: 300, x: columns2.reduce((t, c) => t + c.width, 0) }}
71+
scroll={{ y: 300, x: columns2.reduce((t, c) => t + (c.width as number), 0) }}
7172
columns={columns2}
7273
data={data}
7374
onColumnResizeComplete={({ columnKeyWidths }) => {

docs/examples/virtual.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,24 @@ const data: RecordType[] = new Array(4 * 10000).fill(null).map((_, index) => ({
188188
// ],
189189
}));
190190

191+
const Row = React.forwardRef((props, ref) => {
192+
console.log('render Row');
193+
return (
194+
<div
195+
{...props}
196+
ref={r => {
197+
if (r) {
198+
if (typeof ref === 'function') {
199+
ref(r);
200+
} else {
201+
// ref.current = r;
202+
}
203+
}
204+
}}
205+
/>
206+
);
207+
});
208+
191209
const Demo = () => {
192210
const tblRef = React.useRef<Reference>();
193211

@@ -218,6 +236,11 @@ const Demo = () => {
218236
// expandedRowRender={({ b, c }) => b || c}
219237
scroll={{ x: 1300, y: 200 }}
220238
data={data}
239+
components={{
240+
body: {
241+
row: Row,
242+
},
243+
}}
221244
// data={[]}
222245
rowKey="indexKey"
223246
expandable={{

src/Cell/useCellResize.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export default function useCelResize(
1010
resizable?: boolean | { minWidth?: number },
1111
) {
1212
const {
13-
columnResizable,
1413
colsWidths,
1514
colsKeys,
1615
colWidths,
@@ -19,7 +18,6 @@ export default function useCelResize(
1918
onColumnResizeComplete,
2019
onResizingChange,
2120
} = useContext(TableContext, [
22-
'columnResizable',
2321
'colWidths',
2422
'colsKeys',
2523
'colsWidths',
@@ -109,7 +107,7 @@ export default function useCelResize(
109107
setIsResizing(true);
110108
};
111109

112-
const resizeHandle = columnResizable && resizable !== false && (
110+
const resizeHandle = resizable && (
113111
<>
114112
<div
115113
className={`${cellPrefixCls}-resize-handle`}

src/Table.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export interface TableProps<RecordType = any>
9494
columns?: ColumnsType<RecordType>;
9595
rowKey?: string | keyof RecordType | GetRowKey<RecordType>;
9696
tableLayout?: TableLayout;
97-
columnResizable?: boolean;
9897

9998
// Fixed Columns
10099
scroll?: { x?: number | true | string; y?: number | string };
@@ -200,7 +199,6 @@ function Table<RecordType extends DefaultRecordType>(
200199
scroll,
201200
tableLayout,
202201
direction,
203-
columnResizable,
204202

205203
// Additional Part
206204
title,
@@ -855,7 +853,6 @@ function Table<RecordType extends DefaultRecordType>(
855853
colsWidths,
856854
colsKeys,
857855
colWidths,
858-
columnResizable,
859856
onColumnResizeComplete,
860857
onResizingChange: setIsResizing,
861858
}),
@@ -895,7 +892,6 @@ function Table<RecordType extends DefaultRecordType>(
895892
columns,
896893
flattenColumns,
897894
onColumnWidthChange,
898-
columnResizable,
899895
colsWidths,
900896
colsKeys,
901897
colWidths,

src/context/TableContext.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export interface TableContextProps<RecordType = any> {
6969

7070
rowHoverable?: boolean;
7171
fullTableRef: React.MutableRefObject<HTMLDivElement>;
72-
columnResizable?: boolean;
7372
colsWidths: Map<React.Key, number>;
7473
colWidths: number[];
7574
colsKeys: React.Key[];

tests/Resizable.spec.jsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ describe('Table.resizable', () => {
3535
const [widthMap, setWidthMap] = React.useState(new Map());
3636

3737
const columns = [
38-
{ key: 'a', dataIndex: 'a', width: 400 },
39-
{ key: 'b', dataIndex: 'b', width: 400 },
38+
{ key: 'a', dataIndex: 'a', width: 400, resizable: true },
39+
{ key: 'b', dataIndex: 'b', width: 400, resizable: true },
4040
].map(col => ({ ...col, width: widthMap.get(col.key ?? col.dataIndex) || col.width }));
4141

4242
return (
4343
<Table
44-
columnResizable
4544
data={[{ a: '123', b: '123', key: '1' }]}
4645
columns={columns}
4746
scroll={{ x: columns.reduce((t, c) => t + c.width, 0) }}
@@ -117,13 +116,12 @@ describe('Table.resizable', () => {
117116
const [widthMap, setWidthMap] = React.useState(new Map());
118117

119118
const columns = [
120-
{ key: 'a', dataIndex: 'a', width: 100 },
121-
{ key: 'b', dataIndex: 'b', width: 100 },
119+
{ key: 'a', dataIndex: 'a', width: 100, resizable: true },
120+
{ key: 'b', dataIndex: 'b', width: 100, resizable: true },
122121
].map(col => ({ ...col, width: widthMap.get(col.key ?? col.dataIndex) || col.width || 100 }));
123122

124123
return (
125124
<Table
126-
columnResizable
127125
style={{ width: 800 }}
128126
data={[{ a: '123', b: 'xxxxxxxx', key: '1' }]}
129127
columns={columns}
@@ -203,12 +201,11 @@ describe('Table.resizable', () => {
203201

204202
const columns = [
205203
{ key: 'a', dataIndex: 'a', width: 800, resizable: { minWidth: 400 } },
206-
{ key: 'b', dataIndex: 'b', width: 800 },
204+
{ key: 'b', dataIndex: 'b', width: 800, resizable: true },
207205
].map(col => ({ ...col, width: widthMap.get(col.key ?? col.dataIndex) || col.width }));
208206

209207
return (
210208
<Table
211-
columnResizable
212209
data={[{ a: '123', b: '123', key: '1' }]}
213210
columns={columns}
214211
scroll={{ x: columns.reduce((t, c) => t + c.width, 0) }}

0 commit comments

Comments
 (0)