@@ -6,7 +6,15 @@ import type { CSSProperties, ReactNode } from 'react'
66import { forwardRef } from 'react'
77import { useColumnProvider } from './ColumnProvider'
88import { listCell } from './styles.css'
9- import { maxWidthCell , minWidthCell , widthCell } from './variables.css'
9+ import {
10+ listCellPadding ,
11+ maxWidthCell ,
12+ maxWidthChildrenCell ,
13+ minWidthCell ,
14+ minWidthChildrenCell ,
15+ widthCell ,
16+ widthChildrenCell ,
17+ } from './variables.css'
1018
1119type CellProps = {
1220 children ?: ReactNode
@@ -20,6 +28,17 @@ export const Cell = forwardRef<HTMLTableCellElement, CellProps>(
2028 ( { children, className, 'data-testid' : dataTestid , colSpan, style } , ref ) => {
2129 const { maxWidth, minWidth, width } = useColumnProvider ( )
2230
31+ /** Remove padding from width to avoid overflow since boxSizing = 'content-box' */
32+ const widthChildren = width ?. includes ( '%' )
33+ ? '100%'
34+ : `calc(${ widthCell } - ${ listCellPadding } - ${ listCellPadding } )`
35+ const maxWidthChildren = maxWidth ?. includes ( '%' )
36+ ? '100%'
37+ : `calc(${ maxWidth } - ${ listCellPadding } - ${ listCellPadding } )`
38+ const minWidthChildren = minWidth ?. includes ( '%' )
39+ ? '100%'
40+ : `calc(${ minWidth } - ${ listCellPadding } - ${ listCellPadding } )`
41+
2342 return (
2443 < td
2544 className = { cn ( className , listCell ) }
@@ -28,9 +47,12 @@ export const Cell = forwardRef<HTMLTableCellElement, CellProps>(
2847 ref = { ref }
2948 style = { {
3049 ...assignInlineVars ( {
31- [ widthCell ] : width ,
32- [ minWidthCell ] : minWidth ,
33- [ maxWidthCell ] : maxWidth ,
50+ [ widthCell ] : width ?? 'auto' ,
51+ [ minWidthCell ] : minWidth ?? 'auto' ,
52+ [ maxWidthCell ] : maxWidth ?? 'none' ,
53+ [ widthChildrenCell ] : width ? widthChildren : 'auto' ,
54+ [ maxWidthChildrenCell ] : maxWidth ? maxWidthChildren : 'none' ,
55+ [ minWidthChildrenCell ] : minWidth ? minWidthChildren : 'auto' ,
3456 } ) ,
3557 ...style ,
3658 } }
0 commit comments