1- import type { CalculatedColumn , CalculatedColumnOrColumnGroup , Maybe } from '../types' ;
1+ import type { CalculatedColumnOrColumnGroup , Maybe } from '../types' ;
22
33export * from './colSpanUtils' ;
44export * from './domUtils' ;
@@ -17,53 +17,10 @@ export function assertIsValidKeyGetter<R, K extends React.Key>(
1717 throw new Error ( 'Please specify the rowKeyGetter prop to use selection' ) ;
1818 }
1919}
20- export function getColumnWidthForMeasurement < R , SR > (
21- width : number | string ,
22- { minWidth, maxWidth } : CalculatedColumn < R , SR >
23- ) {
24- const widthWithUnit = typeof width === 'number' ? `${ width } px` : width ;
25-
26- // don't break in Node.js (SSR) and jsdom
27- if ( typeof CSS === 'undefined' ) {
28- return widthWithUnit ;
29- }
30-
31- const hasMaxWidth = maxWidth != null ;
32- const clampedWidth = hasMaxWidth
33- ? `clamp(${ minWidth } px, ${ widthWithUnit } , ${ maxWidth } px)`
34- : `max(${ minWidth } px, ${ widthWithUnit } )` ;
35-
36- // clamp() and max() do not handle all the css grid column width values
37- if ( isValidCSSGridColumnWidth ( clampedWidth ) ) {
38- return clampedWidth ;
39- }
40-
41- if (
42- hasMaxWidth &&
43- // ignore maxWidth if it less than minWidth
44- maxWidth >= minWidth &&
45- // we do not want to use minmax with max-content as it
46- // can result in width being larger than max-content
47- widthWithUnit !== 'max-content'
48- ) {
49- // We are setting maxWidth on the measuring cell but the browser only applies
50- // it after all the widths are calculated. This results in left over space in some cases.
51- const minMaxWidth = `minmax(${ widthWithUnit } , ${ maxWidth } px)` ;
52- if ( isValidCSSGridColumnWidth ( minMaxWidth ) ) {
53- return minMaxWidth ;
54- }
55- }
56-
57- return isValidCSSGridColumnWidth ( widthWithUnit ) ? widthWithUnit : 'auto' ;
58- }
5920
6021export function getHeaderCellRowSpan < R , SR > (
6122 column : CalculatedColumnOrColumnGroup < R , SR > ,
6223 rowIdx : number
6324) {
6425 return column . parent === undefined ? rowIdx : column . level - column . parent . level ;
6526}
66-
67- function isValidCSSGridColumnWidth ( width : string ) {
68- return CSS . supports ( 'grid-template-columns' , width ) ;
69- }
0 commit comments