mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-21 04:48:02 +08:00
23870913b1
* fix: resize & border logic * fix: auto width * chore: clean up * fix: lint * chore: cov * chore: lint
21 lines
603 B
TypeScript
21 lines
603 B
TypeScript
import type { TableProps } from 'rc-table';
|
|
|
|
export default function useContainerWidth(prefixCls: string) {
|
|
const getContainerWidth: TableProps['getContainerWidth'] = (ele, width) => {
|
|
const container = ele.querySelector(`.${prefixCls}-container`);
|
|
let returnWidth = width;
|
|
|
|
if (container) {
|
|
const style = getComputedStyle(container);
|
|
const borderLeft = parseInt(style.borderLeftWidth, 10);
|
|
const borderRight = parseInt(style.borderRightWidth, 10);
|
|
|
|
returnWidth = width - borderLeft - borderRight;
|
|
}
|
|
|
|
return returnWidth;
|
|
};
|
|
|
|
return getContainerWidth;
|
|
}
|