From 2b29909b7b73abf184d311894fc7300fc27a81a6 Mon Sep 17 00:00:00 2001 From: Viktor Bersch Date: Wed, 18 Sep 2019 16:33:06 +0200 Subject: [PATCH 1/2] feat(AnalyticalTable): enable passing useTableProps and additional tableHooks to react-table --- .../src/components/AnalyticalTable/index.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/main/src/components/AnalyticalTable/index.tsx b/packages/main/src/components/AnalyticalTable/index.tsx index e456d4608f3..7b63d4d9bae 100644 --- a/packages/main/src/components/AnalyticalTable/index.tsx +++ b/packages/main/src/components/AnalyticalTable/index.tsx @@ -22,7 +22,6 @@ export interface ColumnConfiguration { vAlign?: VerticalAlign; canResize?: boolean; minWidth?: number; - [key: string]: any; } @@ -65,6 +64,8 @@ export interface TableProps extends CommonProps { noDataText?: string; stickyHeader?: boolean; onSort?: (e?: Event) => void; + useTableProps?: object; + tableHooks?: Array<() => any>; } const useStyles = createUseStyles>(styles); @@ -100,7 +101,9 @@ export const AnalyticalTable: FC = forwardRef((props: TableProps, re selectable, onRowSelected, stickyHeader, - onSort + onSort, + useTableProps, + tableHooks } = props; const [selectedRow, setSelectedRow] = useState(null); @@ -188,13 +191,15 @@ export const AnalyticalTable: FC = forwardRef((props: TableProps, re columns, data, defaultColumn, - state: tableState + state: tableState, + ...useTableProps }, useFilters, useGroupBy, useSortBy, useExpanded, - useTableStyling + useTableStyling, + ...tableHooks ); const minimumRows = useMemo(() => { @@ -333,5 +338,7 @@ AnalyticalTable.defaultProps = { pivotBy: [], NoDataComponent: DefaultNoDataComponent, noDataText: 'No Data', - stickyHeader: true + stickyHeader: true, + useTableProps: {}, + tableHooks: [] }; From 860af42758cf835c04cfb7d35f81330f343acd3b Mon Sep 17 00:00:00 2001 From: Viktor Bersch Date: Wed, 18 Sep 2019 16:43:06 +0200 Subject: [PATCH 2/2] rename useTableProps to reactTableOptions --- .../main/src/components/AnalyticalTable/index.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/main/src/components/AnalyticalTable/index.tsx b/packages/main/src/components/AnalyticalTable/index.tsx index 7b63d4d9bae..c95e9794569 100644 --- a/packages/main/src/components/AnalyticalTable/index.tsx +++ b/packages/main/src/components/AnalyticalTable/index.tsx @@ -64,7 +64,10 @@ export interface TableProps extends CommonProps { noDataText?: string; stickyHeader?: boolean; onSort?: (e?: Event) => void; - useTableProps?: object; + /** + * 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>; } @@ -102,7 +105,7 @@ export const AnalyticalTable: FC = forwardRef((props: TableProps, re onRowSelected, stickyHeader, onSort, - useTableProps, + reactTableOptions, tableHooks } = props; @@ -192,7 +195,7 @@ export const AnalyticalTable: FC = forwardRef((props: TableProps, re data, defaultColumn, state: tableState, - ...useTableProps + ...reactTableOptions }, useFilters, useGroupBy, @@ -339,6 +342,6 @@ AnalyticalTable.defaultProps = { NoDataComponent: DefaultNoDataComponent, noDataText: 'No Data', stickyHeader: true, - useTableProps: {}, + reactTableOptions: {}, tableHooks: [] };