2021-03-17 11:45:49 +00:00
|
|
|
import React, { useRef } from "react";
|
2021-07-07 05:52:10 +00:00
|
|
|
import { reduce } from "lodash";
|
2020-06-03 10:50:10 +00:00
|
|
|
import {
|
|
|
|
|
useTable,
|
|
|
|
|
usePagination,
|
2021-02-11 06:00:36 +00:00
|
|
|
useBlockLayout,
|
2020-06-03 10:50:10 +00:00
|
|
|
useResizeColumns,
|
|
|
|
|
useRowSelect,
|
2021-07-07 05:52:10 +00:00
|
|
|
Row,
|
2020-06-03 10:50:10 +00:00
|
|
|
} from "react-table";
|
2021-04-15 05:01:06 +00:00
|
|
|
import {
|
|
|
|
|
TableWrapper,
|
|
|
|
|
TableHeaderWrapper,
|
|
|
|
|
TableHeaderInnerWrapper,
|
|
|
|
|
} from "./TableStyledWrappers";
|
2021-07-07 05:52:10 +00:00
|
|
|
import {
|
|
|
|
|
TableHeaderCell,
|
|
|
|
|
renderEmptyRows,
|
|
|
|
|
renderCheckBoxCell,
|
|
|
|
|
renderCheckBoxHeaderCell,
|
|
|
|
|
} from "./TableUtilities";
|
2020-07-02 06:26:01 +00:00
|
|
|
import TableHeader from "./TableHeader";
|
|
|
|
|
import { Classes } from "@blueprintjs/core";
|
2020-08-10 10:01:36 +00:00
|
|
|
import {
|
2021-02-16 10:29:08 +00:00
|
|
|
ReactTableColumnProps,
|
2021-07-20 05:18:58 +00:00
|
|
|
ReactTableFilter,
|
2020-08-10 11:16:13 +00:00
|
|
|
TABLE_SIZES,
|
2020-08-10 10:01:36 +00:00
|
|
|
CompactMode,
|
|
|
|
|
CompactModeTypes,
|
2021-09-09 15:10:22 +00:00
|
|
|
} from "./Constants";
|
2021-02-16 10:29:08 +00:00
|
|
|
import { Colors } from "constants/Colors";
|
|
|
|
|
|
2021-04-15 05:33:09 +00:00
|
|
|
import ScrollIndicator from "components/ads/ScrollIndicator";
|
2021-03-30 05:29:03 +00:00
|
|
|
import { EventType } from "constants/AppsmithActionConstants/ActionConstants";
|
2021-04-05 09:22:55 +00:00
|
|
|
import { Scrollbars } from "react-custom-scrollbars";
|
2020-07-16 10:39:07 +00:00
|
|
|
|
2020-06-03 10:50:10 +00:00
|
|
|
interface TableProps {
|
|
|
|
|
width: number;
|
|
|
|
|
height: number;
|
|
|
|
|
pageSize: number;
|
|
|
|
|
widgetId: string;
|
2020-07-20 06:04:05 +00:00
|
|
|
widgetName: string;
|
2020-07-03 08:26:04 +00:00
|
|
|
searchKey: string;
|
2020-07-02 06:26:01 +00:00
|
|
|
isLoading: boolean;
|
2021-02-11 06:00:36 +00:00
|
|
|
columnSizeMap?: { [key: string]: number };
|
2020-06-03 10:50:10 +00:00
|
|
|
columns: ReactTableColumnProps[];
|
2020-10-28 15:40:33 +00:00
|
|
|
data: Array<Record<string, unknown>>;
|
2021-08-30 09:24:59 +00:00
|
|
|
totalRecordsCount?: number;
|
2020-08-20 09:30:19 +00:00
|
|
|
editMode: boolean;
|
2020-08-10 06:45:31 +00:00
|
|
|
sortTableColumn: (columnIndex: number, asc: boolean) => void;
|
2021-02-11 06:00:36 +00:00
|
|
|
handleResizeColumn: (columnSizeMap: { [key: string]: number }) => void;
|
2021-02-24 10:29:19 +00:00
|
|
|
selectTableRow: (row: {
|
|
|
|
|
original: Record<string, unknown>;
|
|
|
|
|
index: number;
|
|
|
|
|
}) => void;
|
2020-06-03 10:50:10 +00:00
|
|
|
pageNo: number;
|
2020-11-06 11:15:47 +00:00
|
|
|
updatePageNo: (pageNo: number, event?: EventType) => void;
|
2021-07-07 05:52:10 +00:00
|
|
|
multiRowSelection?: boolean;
|
2021-11-09 05:08:39 +00:00
|
|
|
isSortable?: boolean;
|
2020-06-03 10:50:10 +00:00
|
|
|
nextPageClick: () => void;
|
|
|
|
|
prevPageClick: () => void;
|
|
|
|
|
serverSidePaginationEnabled: boolean;
|
|
|
|
|
selectedRowIndex: number;
|
2020-09-09 07:12:15 +00:00
|
|
|
selectedRowIndices: number[];
|
2020-06-03 10:50:10 +00:00
|
|
|
disableDrag: () => void;
|
|
|
|
|
enableDrag: () => void;
|
2021-07-07 05:52:10 +00:00
|
|
|
toggleAllRowSelect: (
|
|
|
|
|
isSelect: boolean,
|
|
|
|
|
pageData: Row<Record<string, unknown>>[],
|
|
|
|
|
) => void;
|
2021-01-22 10:12:34 +00:00
|
|
|
triggerRowSelection: boolean;
|
2020-07-03 08:26:04 +00:00
|
|
|
searchTableData: (searchKey: any) => void;
|
2020-08-10 11:16:13 +00:00
|
|
|
filters?: ReactTableFilter[];
|
|
|
|
|
applyFilter: (filters: ReactTableFilter[]) => void;
|
2020-08-10 10:01:36 +00:00
|
|
|
compactMode?: CompactMode;
|
2021-05-11 07:32:58 +00:00
|
|
|
isVisibleDownload?: boolean;
|
|
|
|
|
isVisibleFilters?: boolean;
|
|
|
|
|
isVisiblePagination?: boolean;
|
|
|
|
|
isVisibleSearch?: boolean;
|
2021-08-18 10:33:26 +00:00
|
|
|
delimiter: string;
|
2020-06-03 10:50:10 +00:00
|
|
|
}
|
|
|
|
|
|
2020-08-10 10:01:36 +00:00
|
|
|
const defaultColumn = {
|
|
|
|
|
minWidth: 30,
|
|
|
|
|
width: 150,
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-28 20:12:47 +00:00
|
|
|
function ScrollbarVerticalThumb(props: any) {
|
|
|
|
|
return <div {...props} className="thumb-vertical" />;
|
|
|
|
|
}
|
2021-04-22 04:43:54 +00:00
|
|
|
|
2021-04-28 20:12:47 +00:00
|
|
|
function ScrollbarHorizontalThumb(props: any) {
|
|
|
|
|
return <div {...props} className="thumb-horizontal" />;
|
|
|
|
|
}
|
2021-04-22 04:43:54 +00:00
|
|
|
|
2021-04-28 10:28:39 +00:00
|
|
|
export function Table(props: TableProps) {
|
2021-02-11 06:00:36 +00:00
|
|
|
const isResizingColumn = React.useRef(false);
|
2021-03-15 12:17:56 +00:00
|
|
|
|
2021-02-11 06:00:36 +00:00
|
|
|
const handleResizeColumn = (columnWidths: Record<string, number>) => {
|
|
|
|
|
const columnSizeMap = {
|
|
|
|
|
...props.columnSizeMap,
|
|
|
|
|
...columnWidths,
|
|
|
|
|
};
|
|
|
|
|
for (const i in columnSizeMap) {
|
|
|
|
|
if (columnSizeMap[i] < 60) {
|
|
|
|
|
columnSizeMap[i] = 60;
|
|
|
|
|
} else if (columnSizeMap[i] === undefined) {
|
|
|
|
|
const columnCounts = props.columns.filter((column) => !column.isHidden)
|
|
|
|
|
.length;
|
|
|
|
|
columnSizeMap[i] = props.width / columnCounts;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
props.handleResizeColumn(columnSizeMap);
|
|
|
|
|
};
|
2020-08-18 11:30:26 +00:00
|
|
|
const data = React.useMemo(() => props.data, [props.data]);
|
2020-08-10 11:16:13 +00:00
|
|
|
const columnString = JSON.stringify({
|
2020-08-10 10:01:36 +00:00
|
|
|
columns: props.columns,
|
|
|
|
|
compactMode: props.compactMode,
|
2021-02-11 06:00:36 +00:00
|
|
|
columnSizeMap: props.columnSizeMap,
|
2020-08-10 10:01:36 +00:00
|
|
|
});
|
2020-08-10 11:16:13 +00:00
|
|
|
const columns = React.useMemo(() => props.columns, [columnString]);
|
2021-04-22 04:43:54 +00:00
|
|
|
const tableHeadercolumns = React.useMemo(
|
|
|
|
|
() =>
|
|
|
|
|
props.columns.filter((column: ReactTableColumnProps) => {
|
|
|
|
|
return column.accessor !== "actions";
|
|
|
|
|
}),
|
|
|
|
|
[columnString],
|
|
|
|
|
);
|
2021-08-30 09:24:59 +00:00
|
|
|
const pageCount =
|
|
|
|
|
props.serverSidePaginationEnabled && props.totalRecordsCount
|
|
|
|
|
? Math.ceil(props.totalRecordsCount / props.pageSize)
|
|
|
|
|
: Math.ceil(props.data.length / props.pageSize);
|
2020-08-10 11:16:13 +00:00
|
|
|
const currentPageIndex = props.pageNo < pageCount ? props.pageNo : 0;
|
2020-06-03 10:50:10 +00:00
|
|
|
const {
|
|
|
|
|
getTableBodyProps,
|
2021-05-13 08:35:39 +00:00
|
|
|
getTableProps,
|
2020-06-03 10:50:10 +00:00
|
|
|
headerGroups,
|
|
|
|
|
page,
|
|
|
|
|
pageOptions,
|
2021-05-13 08:35:39 +00:00
|
|
|
prepareRow,
|
2021-02-11 06:00:36 +00:00
|
|
|
state,
|
2020-06-03 10:50:10 +00:00
|
|
|
} = useTable(
|
|
|
|
|
{
|
2020-07-20 06:04:05 +00:00
|
|
|
columns: columns,
|
2020-06-03 10:50:10 +00:00
|
|
|
data,
|
|
|
|
|
defaultColumn,
|
|
|
|
|
initialState: {
|
|
|
|
|
pageIndex: currentPageIndex,
|
|
|
|
|
pageSize: props.pageSize,
|
|
|
|
|
},
|
|
|
|
|
manualPagination: true,
|
|
|
|
|
pageCount,
|
|
|
|
|
},
|
2021-02-11 06:00:36 +00:00
|
|
|
useBlockLayout,
|
2020-06-03 10:50:10 +00:00
|
|
|
useResizeColumns,
|
|
|
|
|
usePagination,
|
|
|
|
|
useRowSelect,
|
|
|
|
|
);
|
2021-02-11 06:00:36 +00:00
|
|
|
//Set isResizingColumn as true when column is resizing using table state
|
|
|
|
|
if (state.columnResizing.isResizingColumn) {
|
|
|
|
|
isResizingColumn.current = true;
|
|
|
|
|
} else {
|
|
|
|
|
// We are updating column size since the drag is complete when we are changing value of isResizing from true to false
|
|
|
|
|
if (isResizingColumn.current) {
|
|
|
|
|
//update isResizingColumn in next event loop so that dragEnd event does not trigger click event.
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
isResizingColumn.current = false;
|
|
|
|
|
handleResizeColumn(state.columnResizing.columnWidths);
|
|
|
|
|
}, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-03 10:50:10 +00:00
|
|
|
let startIndex = currentPageIndex * props.pageSize;
|
|
|
|
|
let endIndex = startIndex + props.pageSize;
|
2021-06-29 09:31:41 +00:00
|
|
|
if (props.serverSidePaginationEnabled) {
|
2020-06-03 10:50:10 +00:00
|
|
|
startIndex = 0;
|
2020-07-14 07:55:46 +00:00
|
|
|
endIndex = props.data.length;
|
2020-06-03 10:50:10 +00:00
|
|
|
}
|
|
|
|
|
const subPage = page.slice(startIndex, endIndex);
|
|
|
|
|
const selectedRowIndex = props.selectedRowIndex;
|
2020-11-03 16:46:44 +00:00
|
|
|
const selectedRowIndices = props.selectedRowIndices || [];
|
2020-08-10 10:01:36 +00:00
|
|
|
const tableSizes = TABLE_SIZES[props.compactMode || CompactModeTypes.DEFAULT];
|
2021-03-17 11:45:49 +00:00
|
|
|
const tableWrapperRef = useRef<HTMLDivElement | null>(null);
|
|
|
|
|
const tableBodyRef = useRef<HTMLDivElement | null>(null);
|
2021-03-25 16:16:22 +00:00
|
|
|
const tableHeaderWrapperRef = React.createRef<HTMLDivElement>();
|
2021-07-07 05:52:10 +00:00
|
|
|
const rowSelectionState = React.useMemo(() => {
|
|
|
|
|
// return : 0; no row selected | 1; all row selected | 2: some rows selected
|
|
|
|
|
if (!props.multiRowSelection) return null;
|
|
|
|
|
const selectedRowCount = reduce(
|
2021-08-11 14:06:26 +00:00
|
|
|
page,
|
2021-07-07 05:52:10 +00:00
|
|
|
(count, row) => {
|
|
|
|
|
return selectedRowIndices.includes(row.index) ? count + 1 : count;
|
|
|
|
|
},
|
|
|
|
|
0,
|
|
|
|
|
);
|
|
|
|
|
const result =
|
2021-08-11 14:06:26 +00:00
|
|
|
selectedRowCount === 0 ? 0 : selectedRowCount === page.length ? 1 : 2;
|
2021-07-07 05:52:10 +00:00
|
|
|
return result;
|
2021-08-11 14:06:26 +00:00
|
|
|
}, [selectedRowIndices, page]);
|
2021-07-07 05:52:10 +00:00
|
|
|
const handleAllRowSelectClick = (
|
|
|
|
|
e: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
|
|
|
|
) => {
|
|
|
|
|
// if all / some rows are selected we remove selection on click
|
|
|
|
|
// else select all rows
|
2021-08-11 14:06:26 +00:00
|
|
|
props.toggleAllRowSelect(!Boolean(rowSelectionState), page);
|
2021-07-07 05:52:10 +00:00
|
|
|
// loop over subPage rows and toggleRowSelected if required
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
};
|
2021-05-19 09:25:19 +00:00
|
|
|
const isHeaderVisible =
|
|
|
|
|
props.isVisibleSearch ||
|
|
|
|
|
props.isVisibleFilters ||
|
|
|
|
|
props.isVisibleDownload ||
|
|
|
|
|
props.isVisiblePagination;
|
|
|
|
|
|
2020-06-03 10:50:10 +00:00
|
|
|
return (
|
|
|
|
|
<TableWrapper
|
2021-04-28 10:28:39 +00:00
|
|
|
backgroundColor={Colors.ATHENS_GRAY_DARKER}
|
2020-06-03 10:50:10 +00:00
|
|
|
height={props.height}
|
|
|
|
|
id={`table${props.widgetId}`}
|
2021-05-14 09:39:57 +00:00
|
|
|
isHeaderVisible={isHeaderVisible}
|
2021-04-28 10:28:39 +00:00
|
|
|
tableSizes={tableSizes}
|
2021-01-22 10:12:34 +00:00
|
|
|
triggerRowSelection={props.triggerRowSelection}
|
2021-04-28 10:28:39 +00:00
|
|
|
width={props.width}
|
2020-06-03 10:50:10 +00:00
|
|
|
>
|
2021-06-03 07:43:08 +00:00
|
|
|
{isHeaderVisible && (
|
2021-05-11 07:32:58 +00:00
|
|
|
<TableHeaderWrapper
|
|
|
|
|
backgroundColor={Colors.WHITE}
|
|
|
|
|
ref={tableHeaderWrapperRef}
|
|
|
|
|
serverSidePaginationEnabled={props.serverSidePaginationEnabled}
|
|
|
|
|
tableSizes={tableSizes}
|
|
|
|
|
width={props.width}
|
2021-04-15 05:01:06 +00:00
|
|
|
>
|
2021-05-11 07:32:58 +00:00
|
|
|
<Scrollbars
|
2021-11-24 09:57:26 +00:00
|
|
|
autoHide
|
2021-05-11 07:32:58 +00:00
|
|
|
renderThumbHorizontal={ScrollbarHorizontalThumb}
|
|
|
|
|
renderThumbVertical={ScrollbarVerticalThumb}
|
2021-11-24 09:57:26 +00:00
|
|
|
style={{
|
|
|
|
|
width: props.width,
|
|
|
|
|
height: 38,
|
|
|
|
|
}}
|
2021-04-15 05:01:06 +00:00
|
|
|
>
|
2021-05-11 07:32:58 +00:00
|
|
|
<TableHeaderInnerWrapper
|
|
|
|
|
backgroundColor={Colors.WHITE}
|
2021-04-15 05:01:06 +00:00
|
|
|
serverSidePaginationEnabled={props.serverSidePaginationEnabled}
|
|
|
|
|
tableSizes={tableSizes}
|
2021-05-11 07:32:58 +00:00
|
|
|
width={props.width}
|
|
|
|
|
>
|
|
|
|
|
<TableHeader
|
|
|
|
|
applyFilter={props.applyFilter}
|
|
|
|
|
columns={tableHeadercolumns}
|
|
|
|
|
currentPageIndex={currentPageIndex}
|
2021-08-18 10:33:26 +00:00
|
|
|
delimiter={props.delimiter}
|
2021-05-11 07:32:58 +00:00
|
|
|
filters={props.filters}
|
|
|
|
|
isVisibleDownload={props.isVisibleDownload}
|
|
|
|
|
isVisibleFilters={props.isVisibleFilters}
|
|
|
|
|
isVisiblePagination={props.isVisiblePagination}
|
|
|
|
|
isVisibleSearch={props.isVisibleSearch}
|
|
|
|
|
nextPageClick={props.nextPageClick}
|
|
|
|
|
pageCount={pageCount}
|
|
|
|
|
pageNo={props.pageNo}
|
|
|
|
|
pageOptions={pageOptions}
|
|
|
|
|
prevPageClick={props.prevPageClick}
|
|
|
|
|
searchKey={props.searchKey}
|
|
|
|
|
searchTableData={props.searchTableData}
|
|
|
|
|
serverSidePaginationEnabled={props.serverSidePaginationEnabled}
|
|
|
|
|
tableColumns={columns}
|
|
|
|
|
tableData={props.data}
|
|
|
|
|
tableSizes={tableSizes}
|
2021-08-30 09:24:59 +00:00
|
|
|
totalRecordsCount={props.totalRecordsCount}
|
2021-05-11 07:32:58 +00:00
|
|
|
updatePageNo={props.updatePageNo}
|
2021-07-20 05:18:58 +00:00
|
|
|
widgetId={props.widgetId}
|
2021-05-11 07:32:58 +00:00
|
|
|
widgetName={props.widgetName}
|
|
|
|
|
/>
|
|
|
|
|
</TableHeaderInnerWrapper>
|
|
|
|
|
</Scrollbars>
|
|
|
|
|
</TableHeaderWrapper>
|
|
|
|
|
)}
|
2021-03-17 11:45:49 +00:00
|
|
|
<div
|
|
|
|
|
className={props.isLoading ? Classes.SKELETON : "tableWrap"}
|
|
|
|
|
ref={tableWrapperRef}
|
|
|
|
|
>
|
2021-04-09 07:04:31 +00:00
|
|
|
<Scrollbars
|
2021-04-22 04:43:54 +00:00
|
|
|
renderThumbHorizontal={ScrollbarHorizontalThumb}
|
2021-05-14 09:39:57 +00:00
|
|
|
style={{
|
|
|
|
|
width: props.width,
|
|
|
|
|
height: isHeaderVisible ? props.height - 48 : props.height,
|
|
|
|
|
}}
|
2021-04-09 07:04:31 +00:00
|
|
|
>
|
2021-04-05 09:22:55 +00:00
|
|
|
<div {...getTableProps()} className="table">
|
|
|
|
|
<div
|
|
|
|
|
className="thead"
|
2021-04-28 20:12:47 +00:00
|
|
|
onMouseLeave={props.enableDrag}
|
|
|
|
|
onMouseOver={props.disableDrag}
|
2021-04-05 09:22:55 +00:00
|
|
|
>
|
2021-07-07 05:52:10 +00:00
|
|
|
{headerGroups.map((headerGroup: any, index: number) => {
|
|
|
|
|
const headerRowProps = {
|
|
|
|
|
...headerGroup.getHeaderGroupProps(),
|
|
|
|
|
style: { display: "flex" },
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<div {...headerRowProps} className="tr" key={index}>
|
|
|
|
|
{props.multiRowSelection &&
|
|
|
|
|
renderCheckBoxHeaderCell(
|
|
|
|
|
handleAllRowSelectClick,
|
|
|
|
|
rowSelectionState,
|
|
|
|
|
)}
|
|
|
|
|
{headerGroup.headers.map(
|
|
|
|
|
(column: any, columnIndex: number) => {
|
|
|
|
|
return (
|
|
|
|
|
<TableHeaderCell
|
|
|
|
|
column={column}
|
|
|
|
|
columnIndex={columnIndex}
|
|
|
|
|
columnName={column.Header}
|
2021-11-09 05:08:39 +00:00
|
|
|
editMode={props.editMode}
|
2021-07-07 05:52:10 +00:00
|
|
|
isAscOrder={column.isAscOrder}
|
|
|
|
|
isHidden={column.isHidden}
|
|
|
|
|
isResizingColumn={isResizingColumn.current}
|
2021-11-09 05:08:39 +00:00
|
|
|
isSortable={props.isSortable}
|
2021-07-07 05:52:10 +00:00
|
|
|
key={columnIndex}
|
|
|
|
|
sortTableColumn={props.sortTableColumn}
|
2022-03-04 08:56:16 +00:00
|
|
|
width={props.width}
|
2021-07-07 05:52:10 +00:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2021-04-05 09:22:55 +00:00
|
|
|
{headerGroups.length === 0 &&
|
|
|
|
|
renderEmptyRows(
|
|
|
|
|
1,
|
|
|
|
|
props.columns,
|
|
|
|
|
props.width,
|
|
|
|
|
subPage,
|
|
|
|
|
prepareRow,
|
2021-07-07 05:52:10 +00:00
|
|
|
props.multiRowSelection,
|
2021-04-05 09:22:55 +00:00
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
{...getTableBodyProps()}
|
|
|
|
|
className={`tbody ${
|
2021-06-29 09:31:41 +00:00
|
|
|
props.pageSize > subPage.length ? "no-scroll" : ""
|
2021-04-05 09:22:55 +00:00
|
|
|
}`}
|
|
|
|
|
ref={tableBodyRef}
|
|
|
|
|
>
|
|
|
|
|
{subPage.map((row, rowIndex) => {
|
|
|
|
|
prepareRow(row);
|
2021-07-07 05:52:10 +00:00
|
|
|
const rowProps = {
|
|
|
|
|
...row.getRowProps(),
|
|
|
|
|
style: { display: "flex" },
|
|
|
|
|
};
|
|
|
|
|
const isRowSelected =
|
|
|
|
|
row.index === selectedRowIndex ||
|
|
|
|
|
selectedRowIndices.includes(row.index);
|
2021-04-05 09:22:55 +00:00
|
|
|
return (
|
|
|
|
|
<div
|
2021-07-07 05:52:10 +00:00
|
|
|
{...rowProps}
|
|
|
|
|
className={"tr" + `${isRowSelected ? " selected-row" : ""}`}
|
2021-04-28 20:12:47 +00:00
|
|
|
key={rowIndex}
|
2021-04-05 09:22:55 +00:00
|
|
|
onClick={(e) => {
|
|
|
|
|
row.toggleRowSelected();
|
|
|
|
|
props.selectTableRow(row);
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
}}
|
|
|
|
|
>
|
2021-07-07 05:52:10 +00:00
|
|
|
{props.multiRowSelection &&
|
|
|
|
|
renderCheckBoxCell(isRowSelected)}
|
2021-04-05 09:22:55 +00:00
|
|
|
{row.cells.map((cell, cellIndex) => {
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
{...cell.getCellProps()}
|
|
|
|
|
className="td"
|
|
|
|
|
data-colindex={cellIndex}
|
2021-04-28 20:12:47 +00:00
|
|
|
data-rowindex={rowIndex}
|
|
|
|
|
key={cellIndex}
|
2021-04-05 09:22:55 +00:00
|
|
|
>
|
|
|
|
|
{cell.render("Cell")}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2021-06-29 09:31:41 +00:00
|
|
|
{props.pageSize > subPage.length &&
|
2021-04-05 09:22:55 +00:00
|
|
|
renderEmptyRows(
|
2021-06-29 09:31:41 +00:00
|
|
|
props.pageSize - subPage.length,
|
2021-04-05 09:22:55 +00:00
|
|
|
props.columns,
|
|
|
|
|
props.width,
|
|
|
|
|
subPage,
|
|
|
|
|
prepareRow,
|
2021-07-07 05:52:10 +00:00
|
|
|
props.multiRowSelection,
|
2021-04-05 09:22:55 +00:00
|
|
|
)}
|
|
|
|
|
</div>
|
2020-06-03 10:50:10 +00:00
|
|
|
</div>
|
2021-04-05 09:22:55 +00:00
|
|
|
</Scrollbars>
|
2020-06-03 10:50:10 +00:00
|
|
|
</div>
|
2021-04-15 05:33:09 +00:00
|
|
|
<ScrollIndicator
|
2021-03-25 16:16:22 +00:00
|
|
|
containerRef={tableBodyRef}
|
|
|
|
|
mode="LIGHT"
|
|
|
|
|
top={props.editMode ? "70px" : "73px"}
|
2021-04-15 05:01:06 +00:00
|
|
|
/>
|
2020-06-03 10:50:10 +00:00
|
|
|
</TableWrapper>
|
|
|
|
|
);
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
2020-06-03 10:50:10 +00:00
|
|
|
|
|
|
|
|
export default Table;
|