Skip to content

Commit 063c06f

Browse files
authored
fix: table resizable not work && type error (#6514)
1 parent 43009f0 commit 063c06f

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

components/table/Table.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export interface TableProps<RecordType = DefaultRecordType>
106106
sorter: SorterResult<RecordType> | SorterResult<RecordType>[],
107107
extra: TableCurrentDataSource<RecordType>,
108108
) => void;
109+
onResizeColumn?: (w: number, col: ColumnType) => void;
109110
rowSelection?: TableRowSelection<RecordType>;
110111

111112
getPopupContainer?: GetPopupContainer;

components/table/style/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import genRadiusStyle from './radius';
1313
import genRtlStyle from './rtl';
1414
import genSelectionStyle from './selection';
1515
import genSizeStyle from './size';
16+
import genResizeStyle from './resize';
1617
import genSorterStyle from './sorter';
1718
import genStickyStyle from './sticky';
1819
import genSummaryStyle from './summary';
@@ -404,6 +405,7 @@ export default genComponentStyleHook('Table', token => {
404405
genStickyStyle(tableToken),
405406
genEllipsisStyle(tableToken),
406407
genSizeStyle(tableToken),
408+
genResizeStyle(tableToken),
407409
genRtlStyle(tableToken),
408410
];
409411
});

components/table/style/resize.ts

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// 此样式是vue版本独有样式,react版本没有拖拽改变列宽度功能
2+
import type { CSSObject } from '../../_util/cssinjs';
3+
import type { GenerateStyle } from '../../theme/internal';
4+
import type { TableToken } from './index';
5+
6+
const genResizeStyle: GenerateStyle<TableToken, CSSObject> = token => {
7+
const { componentCls } = token;
8+
9+
return {
10+
[`${componentCls}-wrapper ${componentCls}-resize-handle`]: {
11+
position: 'absolute',
12+
top: 0,
13+
height: '100% !important',
14+
bottom: 0,
15+
left: ' auto !important',
16+
right: ' -8px',
17+
cursor: 'col-resize',
18+
touchAction: 'none',
19+
userSelect: 'auto',
20+
width: '16px',
21+
zIndex: 1,
22+
[`&-line`]: {
23+
display: 'block',
24+
width: '1px',
25+
marginLeft: '7px',
26+
height: '100% !important',
27+
backgroundColor: token.colorPrimary,
28+
opacity: 0,
29+
},
30+
[`&:hover &-line`]: {
31+
opacity: 1,
32+
},
33+
},
34+
[`${componentCls}-wrapper ${componentCls}-resize-handle.dragging`]: {
35+
overflow: 'hidden',
36+
[`${componentCls}-resize-handle-line`]: {
37+
opacity: 1,
38+
},
39+
[`&:before`]: {
40+
position: 'absolute',
41+
top: 0,
42+
bottom: 0,
43+
content: '" "',
44+
width: '200vw',
45+
transform: 'translateX(-50%)',
46+
opacity: 0,
47+
},
48+
},
49+
};
50+
};
51+
52+
export default genResizeStyle;

0 commit comments

Comments
 (0)