mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
* Bump react-data-table-component from 6.11.8 to 7.5.2 Bumps [react-data-table-component](https://github.com/jbetancur/react-data-table-component) from 6.11.8 to 7.5.2. - [Release notes](https://github.com/jbetancur/react-data-table-component/releases) - [Commits](https://github.com/jbetancur/react-data-table-component/compare/v6.11.8...v7.5.2) --- updated-dependencies: - dependency-name: react-data-table-component dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * refactor for new major versions * fully typed styles * border fix Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import React, { ReactElement } from 'react'
|
|
import DataTable, { TableProps, TableColumn } from 'react-data-table-component'
|
|
import Loader from '../Loader'
|
|
import Pagination from '@shared/Pagination'
|
|
import { PaginationComponent } from 'react-data-table-component/dist/src/DataTable/types'
|
|
import Empty from './Empty'
|
|
import { customStyles } from './_styles'
|
|
|
|
// Hack in support for returning components for each row, as this works,
|
|
// but is not supported by the typings.
|
|
export interface TableOceanColumn<T> extends TableColumn<T> {
|
|
selector?: (row: T) => any
|
|
}
|
|
|
|
export interface TableOceanProps<T> extends TableProps<T> {
|
|
columns: TableOceanColumn<T>[]
|
|
isLoading?: boolean
|
|
emptyMessage?: string
|
|
sortField?: string
|
|
sortAsc?: boolean
|
|
className?: string
|
|
}
|
|
|
|
export default function Table({
|
|
data,
|
|
columns,
|
|
isLoading,
|
|
emptyMessage,
|
|
pagination,
|
|
paginationPerPage,
|
|
sortField,
|
|
sortAsc,
|
|
className,
|
|
...props
|
|
}: TableOceanProps<any>): ReactElement {
|
|
return (
|
|
<div className={className}>
|
|
<DataTable
|
|
columns={columns}
|
|
data={data}
|
|
pagination={pagination || data?.length >= 9}
|
|
paginationPerPage={paginationPerPage || 10}
|
|
noDataComponent={<Empty message={emptyMessage} />}
|
|
progressPending={isLoading}
|
|
progressComponent={<Loader />}
|
|
paginationComponent={Pagination as unknown as PaginationComponent}
|
|
defaultSortFieldId={sortField}
|
|
defaultSortAsc={sortAsc}
|
|
theme="ocean"
|
|
customStyles={customStyles}
|
|
{...props}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|