@@ -2,6 +2,7 @@ import React, {ReactNode} from "react";
22import { ColumnOption , TableGeneratorProps } from "./TableGenerator" ;
33import classNames from "classnames" ;
44import { ISortStyle , SortOrder } from "./utils/sorting" ;
5+ import { CellContextDetails } from "./contextTypes" ;
56
67export interface ITableHeaderProps extends Partial < TableGeneratorProps > {
78 sortConfiguration : ISortStyle ;
@@ -39,7 +40,6 @@ const TableHeader: React.FC<ITableHeaderProps> = (props) => {
3940 return null ;
4041 }
4142
42-
4343 // Determine if the column is sortable. First check if table sorting is true & this column is not disabled,
4444 // then if that doesn't evaluate true, just check if this column is set as sortable.
4545 const isSortable : boolean = ( props . sortable && column . sortable !== false ) || column . sortable ;
@@ -48,23 +48,30 @@ const TableHeader: React.FC<ITableHeaderProps> = (props) => {
4848 // then if that doesn't evaluate true, just check if this column has them enabled.
4949 const showSortIcons : boolean = ( props . showSortIcons && column . showSortIcons !== false ) || column . showSortIcons ;
5050
51-
5251 // Create the content to be rendered, starting with the headerValue.
53- let content : ReactNode = column . headerValue ;
52+ let content : any = column . headerValue ;
53+
54+ // Construct this object with all the details needed for the value formatter / cell render functions
55+ const cellContextDetails : CellContextDetails = {
56+ value : content ,
57+ row : undefined ,
58+ key : column . key ,
59+ data : props . data ,
60+ column,
61+ index : undefined ,
62+ } ;
5463
5564 // Reassign the content to the custom render function if it exists.
5665 if ( column . headerRender ) {
57- content = column . headerRender ( column . headerValue , undefined , column . key , props . data , column , i ) ;
66+ content = column . headerRender ( column . headerValue , cellContextDetails ) ;
5867 }
5968
60-
6169 // Generate classes for the header cell.
6270 const thClasses : string = classNames ( column . headerCellClassName , {
6371 "sortable-th" : isSortable ,
6472 "sortable-th-with-icons" : isSortable && showSortIcons ,
6573 } ) ;
6674
67-
6875 // Handle sorting, if enabled.
6976 function handleSort ( ) : void {
7077 if ( ! isSortable ) {
0 commit comments