@@ -61,8 +61,8 @@ export const SearchFilter = ({ value, onChange, placeholder, inputClassName = ""
6161export const renderTableHeader = ( headerGroups ) => {
6262 return (
6363 < >
64- { headerGroups . map ( ( headerGroup ) => (
65- < tr { ...headerGroup . getHeaderGroupProps ( ) } key = { headerGroup . id } >
64+ { headerGroups . map ( ( headerGroup , index ) => (
65+ < tr { ...headerGroup . getHeaderGroupProps ( ) } key = { `header-row- ${ headerGroup . id || index } ` } >
6666 { headerGroup . headers . map ( ( column ) => {
6767 const headerProps = column . getHeaderProps ( ) ;
6868 const sortByProps = column . getSortByToggleProps ? column . getSortByToggleProps ( ) : { } ;
@@ -76,15 +76,14 @@ export const renderTableHeader = (headerGroups) => {
7676
7777 return (
7878 < th
79- key = { column . id }
79+ key = { `header-cell- ${ column . id } ` }
8080 className = { `${ headerStyles } ${ ! column . disableSortBy ? sortableHeaderStyles : "" } ` }
8181 { ...headerProps }
8282 onClick = { onHeaderClick }
8383 style = { {
8484 ...headerProps . style ,
8585 width : column . width ,
8686 minWidth : column . minWidth ,
87- maxWidth : column . width ,
8887 position : "relative" ,
8988 } }
9089 >
@@ -130,15 +129,14 @@ export const renderTableHeader = (headerGroups) => {
130129 ) ) }
131130
132131 { /* Add a separate row for filters */ }
133- { headerGroups . map ( ( headerGroup ) => (
134- < tr key = { `filter-${ headerGroup . id } ` } >
132+ { headerGroups . map ( ( headerGroup , index ) => (
133+ < tr key = { `filter-row- ${ headerGroup . id } - ${ index } ` } >
135134 { headerGroup . headers . map ( ( column ) => (
136135 < td
137- key = { `filter-${ column . id } ` }
136+ key = { `filter-cell- ${ column . id } ` }
138137 style = { {
139138 width : column . width ,
140139 minWidth : column . minWidth ,
141- maxWidth : column . width ,
142140 } }
143141 >
144142 { column . canFilter && (
@@ -172,3 +170,37 @@ export const TableWrapper = ({ children, className = "" }) => (
172170 < div className = "mr-inline-block mr-min-w-full" > { children } </ div >
173171 </ div >
174172) ;
173+
174+ /**
175+ * Renders a table cell with nowrap styling
176+ * @param {Object } cell - The react-table cell object
177+ * @param {Object } options - Additional styling options
178+ * @returns {JSX.Element } - The rendered table cell
179+ */
180+ export const renderTableCell = ( cell , options = { } ) => {
181+ return (
182+ < td
183+ { ...cell . getCellProps ( ) }
184+ style = { {
185+ ...cell . getCellProps ( ) . style ,
186+ whiteSpace : "nowrap !important" ,
187+ overflow : "hidden !important" ,
188+ textOverflow : "ellipsis !important" ,
189+ minWidth : cell . column . minWidth ,
190+ ...options ,
191+ } }
192+ >
193+ < div
194+ style = { {
195+ overflow : "hidden !important" ,
196+ textOverflow : "ellipsis !important" ,
197+ whiteSpace : "nowrap !important" ,
198+ width : "100%" ,
199+ display : "block" ,
200+ } }
201+ >
202+ { cell . render ( "Cell" ) }
203+ </ div >
204+ </ td >
205+ ) ;
206+ } ;
0 commit comments