@seasketch/geoprocessing
Version:
Geoprocessing and reporting framework for SeaSketch 2.0
65 lines (64 loc) • 4.48 kB
TypeScript
import React, { ReactElement, ReactNode } from "react";
import { DataDownloadProps } from "../DataDownload.js";
import { TableOptions } from "react-table";
/**
* Adapted from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-table/react-table-tests.tsx
* For more inspiration see https://codesandbox.io/s/github/ggascoigne/react-table-example?file=/src/Table/Table.tsx:0-62
* See react-table-config.d.ts for full merged types
* @types/react-table README has more info on this approach
*/
declare module "react-table" {
/**
* Types for Table component. As the library is plugin-based, so are the community types
* This module combines the @types/react-table base and plugin types and re-exports them with the same name
* This is possible through "interface merging", as long as the type signature stays the same
* The Table component that imports 'react-table' will find and use this extended module automatically
* Custom properties we support on our Table component are also included.
* Adjust this module as feature needs change or if react-library has breaking changes!
* Unused plugings are commented out
*/
interface TableOptions<D extends object = {}> extends UseExpandedOptions<D>, UseGlobalFiltersOptions<D>, UsePaginationOptions<D>, UseSortByOptions<D> {
/** Optional method to pass style. Added to table element */
className?: string;
data: D[];
/** Function called for each table header allowing style/className/role props to be overridden */
headerProps?: (header: HeaderGroup<D>) => TableCommonProps;
/** Function called for each table column allowing style/className/role props to be overridden */
columnProps?: (column: Column<D>) => TableCommonProps;
/** Function called for each table row allowing style/className/role props to be overridden */
rowProps?: (row: Row<D>) => TableCommonProps;
/** Function called for each table cell allowing style/className/role props to be overridden */
cellProps?: (cell: Cell<D>) => TableCommonProps;
/** Toolbar title */
title?: string | ReactNode;
/** Enable toolbar with download option */
downloadEnabled?: boolean;
downloadFilename?: DataDownloadProps["filename"];
downloadFormats?: DataDownloadProps["formats"];
}
interface Hooks<D extends object = {}> extends UseExpandedHooks<D>, UseGroupByHooks<D>, UseRowSelectHooks<D>, UseSortByHooks<D> {
}
interface TableInstance<D extends object = {}> extends UseColumnOrderInstanceProps<D>, UseExpandedInstanceProps<D>, UseFiltersInstanceProps<D>, UseGlobalFiltersInstanceProps<D>, UseGroupByInstanceProps<D>, UsePaginationInstanceProps<D>, UseRowSelectInstanceProps<D>, UseRowStateInstanceProps<D>, UseSortByInstanceProps<D> {
}
interface TableState<D extends object = {}> extends UseColumnOrderState<D>, UseExpandedState<D>, UseFiltersState<D>, UseGlobalFiltersState<D>, UseGroupByState<D>, UsePaginationState<D>, UseResizeColumnsState<D>, UseRowSelectState<D>, UseRowStateState<D>, UseSortByState<D> {
}
interface ColumnInterface<D extends object = {}> extends UseFiltersColumnOptions<D>, UseGlobalFiltersColumnOptions<D>, UseGroupByColumnOptions<D>, UseResizeColumnsColumnOptions<D>, UseSortByColumnOptions<D>, TableCommonProps {
}
interface ColumnInstance<D extends object = {}> extends UseFiltersColumnProps<D>, UseGroupByColumnProps<D>, UseResizeColumnsColumnProps<D>, UseSortByColumnProps<D>, TableCommonProps {
}
interface Cell<D extends object = {}, V = any> extends UseGroupByCellProps<D>, UseRowStateCellProps<D> {
}
interface Row<D extends object = {}> extends UseExpandedRowProps<D>, UseGroupByRowProps<D>, UseRowSelectRowProps<D>, UseRowStateRowProps<D> {
}
}
export { Column, Row, TableOptions } from "react-table";
export declare const TableStyled: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
/**
* Table component suited to geoprocessing client reports.
* Builds on the `react-table` useTable hook and re-exports its interface,
* so reference those API docs to suit your needs.
* @param props
* @returns
*/
export declare function Table<D extends object>(props: TableOptions<D>): ReactElement;
export default Table;