Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(AnalyticalTable): enable passing additional props to react-table #131

Merged
merged 4 commits into from
Sep 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: []
};