File tree Expand file tree Collapse file tree 4 files changed +13
-9
lines changed
Expand file tree Collapse file tree 4 files changed +13
-9
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " frame-one-table" ,
3- "version" : " 0.2.5 " ,
3+ "version" : " 0.2.6 " ,
44 "description" : " A react table with maximum flexibility." ,
55 "main" : " build/index.js" ,
66 "module" : " build/index.es.js" ,
Original file line number Diff line number Diff line change @@ -102,11 +102,11 @@ Primary.args = {
102102 valueFormatter : stringToCaps ,
103103 } ,
104104 {
105- key : "nestedData" ,
105+ key : undefined ,
106106 headerValue : "Nested Test" ,
107107 // sortable: true,
108- cellRender : ( nestedData : { test : number } , data : CellContextDetails ) => {
109- return nestedData . test ;
108+ cellRender : ( row : any ) => {
109+ return row . nestedData ? .test ;
110110 } ,
111111 } ,
112112 {
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ export interface ColumnOption<T = any> {
9696 /**
9797 * Format function to run the values for the column's body cells through before displaying them (ie. (height) => height + "cm"). Does not modify the value used to compare for sorting the column
9898 */
99- valueFormatter ?: ContextFunctionCellWithValue < T , string > ;
99+ valueFormatter ?: ContextFunctionCellWithValue < T , any > ;
100100
101101 /**
102102 * Custom render function for the header cell
@@ -107,7 +107,7 @@ export interface ColumnOption<T = any> {
107107 * Custom render function for the body cells of this column
108108 *
109109 */
110- cellRender ?: ContextFunctionCellWithValue < T , ReactNode > ;
110+ cellRender ?: ContextFunctionCellWithValue < T , any > ;
111111
112112 /**
113113 * className applied to the header cell
Original file line number Diff line number Diff line change @@ -28,8 +28,10 @@ const TableRow: React.FC<ITableRowProps> = (props) => {
2828
2929 // Create the content to be rendered, starting with the cell value found within the data.
3030 // Value is .toString()'d so numbers and booleans will display properly.
31- let content : any = rowData ?. [ column . key ] ; // todo better typing eventually.
32-
31+ let content = rowData ;
32+ if ( column . key ) {
33+ content = rowData ?. [ column . key ] ;
34+ }
3335 // Construct this object with all the details needed for the value formatter / cell render functions
3436 const cellContextDetails : CellContextDetails = {
3537 value : content ,
@@ -57,7 +59,9 @@ const TableRow: React.FC<ITableRowProps> = (props) => {
5759 }
5860
5961 // Generate classes for the header cell.
60- const _rowClassName : string = ( typeof column . rowCellClassName === "string" || ! column . rowCellClassName ) ? column . rowCellClassName as string : column . rowCellClassName ( content , cellContextDetails ) ;
62+ const _rowClassName : string = ( typeof column . rowCellClassName === "string" || ! column . rowCellClassName ) ?
63+ column . rowCellClassName as string :
64+ column . rowCellClassName ( content . toString ( ) , cellContextDetails ) ;
6165 const cellClasses : string = classNames ( rowCellClassName , _rowClassName ) ;
6266
6367 return (
You can’t perform that action at this time.
0 commit comments