Skip to content

Commit 0b23bca

Browse files
committed
man
1 parent 76c317e commit 0b23bca

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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",

src/TableGenerator.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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
{

src/TableGenerator.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

src/TableRow.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff 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 (

0 commit comments

Comments
 (0)