Skip to content

Commit

Permalink
feat(AnalyticalTable): enable passing additional props to react-table (
Browse files Browse the repository at this point in the history
  • Loading branch information
vbersch authored and MarcusNotheis committed Sep 18, 2019
1 parent 8cc9ec3 commit 61cd83f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/main/src/components/AnalyticalTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export interface ColumnConfiguration {
vAlign?: VerticalAlign;
canResize?: boolean;
minWidth?: number;

[key: string]: any;
}

Expand Down Expand Up @@ -65,6 +64,11 @@ export interface TableProps extends CommonProps {
noDataText?: string;
stickyHeader?: boolean;
onSort?: (e?: Event) => void;
/**
* additional options which will be passed to [react-table´s useTable hook](https://github.com/tannerlinsley/react-table/blob/master/docs/api.md#table-options)
*/
reactTableOptions?: object;
tableHooks?: Array<() => any>;
}

const useStyles = createUseStyles<JSSTheme, keyof ReturnType<typeof styles>>(styles);
Expand Down Expand Up @@ -100,7 +104,9 @@ export const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, re
selectable,
onRowSelected,
stickyHeader,
onSort
onSort,
reactTableOptions,
tableHooks
} = props;

const [selectedRow, setSelectedRow] = useState(null);
Expand Down Expand Up @@ -188,13 +194,15 @@ export const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, re
columns,
data,
defaultColumn,
state: tableState
state: tableState,
...reactTableOptions
},
useFilters,
useGroupBy,
useSortBy,
useExpanded,
useTableStyling
useTableStyling,
...tableHooks
);

const minimumRows = useMemo(() => {
Expand Down Expand Up @@ -333,5 +341,7 @@ AnalyticalTable.defaultProps = {
pivotBy: [],
NoDataComponent: DefaultNoDataComponent,
noDataText: 'No Data',
stickyHeader: true
stickyHeader: true,
reactTableOptions: {},
tableHooks: []
};

0 comments on commit 61cd83f

Please sign in to comment.