From f736e785b970f181bc8278e8284f95d304a5ebc8 Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 7 Dec 2023 12:18:49 +0100 Subject: [PATCH] feat(Table): use `` to set cells width (#831) --- src/components/Table/Table.tsx | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/components/Table/Table.tsx b/src/components/Table/Table.tsx index 60abbee193..5a93c038a1 100644 --- a/src/components/Table/Table.tsx +++ b/src/components/Table/Table.tsx @@ -346,6 +346,23 @@ export class Table> extends Rea ); } + private renderColgroup() { + const {columns} = this.props; + const {columnsStyles} = this.state; + + if (!columnsStyles.length) { + return null; + } + + return ( + + {columnsStyles.map(({width}, index) => ( + + ))} + + ); + } + private renderHead() { const {columns, edgePadding, wordWrap} = this.props; const {columnsStyles} = this.state; @@ -363,7 +380,7 @@ export class Table> extends Rea > extends Rea private renderTable() { return ( + {this.renderColgroup()} {this.renderHead()} {this.renderBody()}
@@ -458,7 +476,7 @@ export class Table> extends Rea return ( > extends Rea return style; } + private getCellStyles({ + width: _width, + ...styles + }: React.CSSProperties): React.CSSProperties | undefined { + return Object.keys(styles).length ? styles : undefined; + } + private handleScrollContainerMouseenter = () => { this.setState({activeScrollElement: 'scrollContainer'}); };