-
-
Notifications
You must be signed in to change notification settings - Fork 606
/
Copy pathMeasureRow.tsx
33 lines (31 loc) · 980 Bytes
/
MeasureRow.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import ResizeObserver from 'rc-resize-observer';
import * as React from 'react';
import MeasureCell from './MeasureCell';
export interface MeasureCellProps {
prefixCls: string;
onColumnResize: (key: React.Key, width: number) => void;
columnsKey: React.Key[];
}
export default function MeasureRow({ prefixCls, columnsKey, onColumnResize }: MeasureCellProps) {
const onBatchResize = React.useCallback(
infoList => {
infoList.forEach(({ data: columnKey, size }) => {
onColumnResize(columnKey, size.offsetWidth);
});
},
[onColumnResize],
);
return (
<tr
aria-hidden="true"
className={`${prefixCls}-measure-row`}
style={{ height: 0, fontSize: 0 }}
>
<ResizeObserver.Collection onBatchResize={onBatchResize}>
{columnsKey.map(columnKey => (
<MeasureCell key={columnKey} columnKey={columnKey} onColumnResize={onColumnResize} />
))}
</ResizeObserver.Collection>
</tr>
);
}