You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import { PluginHook, TableInstance, TableOptions, useTable } from "react-table";
|
|
|
|
import BaseTable, { TableStyleProps } from "./BaseTable";
|
|
|
|
import { useDefaultSettings } from "./plugins";
|
|
|
|
|
|
|
|
export type SimpleTableProps<T extends object> = TableOptions<T> & {
|
|
|
|
plugins?: PluginHook<T>[];
|
|
|
|
instanceRef?: React.MutableRefObject<TableInstance<T> | null>;
|
|
|
|
tableStyles?: TableStyleProps<T>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function SimpleTable<T extends object>(
|
|
|
|
props: SimpleTableProps<T>
|
|
|
|
) {
|
|
|
|
const { plugins, instanceRef, tableStyles, ...options } = props;
|
|
|
|
|
|
|
|
const instance = useTable(options, useDefaultSettings, ...(plugins ?? []));
|
|
|
|
|
|
|
|
if (instanceRef) {
|
|
|
|
instanceRef.current = instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
return <BaseTable tableStyles={tableStyles} {...instance}></BaseTable>;
|
|
|
|
}
|