diff --git a/src/components/SimpleTable.js b/src/components/SimpleTable.js
index 1416dc5b5..74488f729 100644
--- a/src/components/SimpleTable.js
+++ b/src/components/SimpleTable.js
@@ -1,5 +1,4 @@
-import { isNil } from 'lodash/fp';
-import { div, h } from 'react-hyperscript-helpers';
+import React from 'react';
import { Styles } from '../libs/theme';
import ReactTooltip from 'react-tooltip';
import { ArrowDropUp, ArrowDropDown } from '@mui/icons-material';
@@ -8,58 +7,59 @@ import loadingImage from '../images/loading-indicator.svg';
// Renders spinning circle while table loading
const TableLoading = () => {
- return div({className: 'table-loading-placeholder'},
- [
- h(SpinnerComponent, {
- show: true,
- name: 'loadingSpinner',
- loadingImage
- }, [])
- ]
+ return (
+
+
+
);
};
-//Simple cell text display
+// Simple cell text display
const SimpleTextCell = ({ text, style, keyProp }) => {
- text = isNil(text) ? '- -' : text;
- return div({ style, role: 'cell', key: keyProp }, [text]);
+ text = text ?? '- -';
+ return {text}
;
};
-//Simple cell text that carries onClick functionality
+// Simple cell text that carries onClick functionality
const OnClickTextCell = ({ text, style, onClick, keyProp }) => {
- text = isNil(text) ? '- -' : text;
- return div({ style, onClick, role: 'cell', key: keyProp }, [text]);
+ text = text ?? '- -';
+ return {text}
;
};
//Column component that renders the column row based on column headers
const ColumnRow = ({columnHeaders, baseStyle, columnStyle, sort, onSort}) => {
- const rowStyle = Object.assign({}, baseStyle, columnStyle);
- return div({style: rowStyle, key: 'column-row-container', role:'row'}, columnHeaders.map((header, colIndex) => {
- const {cellStyle, label} = header;
- //style here pertains to styling for individual cells
- //should be used to set dimensions of specific columns
- return div({style: cellStyle, key: `column-row-${label}`, className: 'column-header'}, [
- header.sortable && onSort
- ? div({
- style: Styles.TABLE.HEADER_SORT,
- key: 'data_id_cell',
- className: 'cell-sort',
- onClick: () => {
- onSort({
- colIndex: colIndex,
- dir: sort.colIndex === colIndex ? sort.dir * -1 : 1
- });
- }
- }, [
- label,
- div({className: 'sort-container'}, [
- h(ArrowDropUp, { className: `sort-icon sort-icon-up ${sort.colIndex === colIndex && sort.dir === -1 ? 'active' : ''}` }),
- h(ArrowDropDown, { className: `sort-icon sort-icon-down ${sort.colIndex === colIndex && sort.dir === 1 ? 'active': ''}` })
- ])
- ])
- : label
- ]);
- }));
+ const rowStyle = { ...baseStyle, ...columnStyle };
+ return (
+
+ {columnHeaders.map((header, colIndex) => {
+ const {cellStyle, label} = header;
+ return (
+
+ {header.sortable && onSort
+ ?
{
+ onSort({
+ colIndex: colIndex,
+ dir: sort.colIndex === colIndex ? sort.dir * -1 : 1
+ });
+ }}
+ >
+ {label}
+
+
+ : label
+ }
+
+ );
+ })}
+
+ );
};
//Row component that renders out rows for each element in the provided data collection
@@ -67,30 +67,35 @@ const DataRows = ({rowData, baseStyle, columnHeaders, rowWrapper = ({renderedRow
return rowData.map((row, index) => {
const id = rowData[index][0].id;
const mapKey = id || `noId-index-${index}`;
- const renderedRow = div({style: Object.assign({borderTop: '1px solid #f3f6f7'}, baseStyle), key: `row-data-${mapKey}`, role: 'row', className: `row-data-${index}`},
- row.map(({data, style, onClick, isComponent, id, label}, cellIndex) => {
- let output;
- //columnHeaders determine width of the columns,
- //therefore extract width from columnHeader and apply to cell style
- const columnWidthStyle = columnHeaders[cellIndex].cellStyle;
- const appliedStyle = Object.assign({}, style, columnWidthStyle);
- //assume component is in hyperscript format
- //wrap component in dive with columnWidth applied
- if (isComponent) {
- output = div({role: 'cell', style: columnWidthStyle, key: `${!isNil(data) && !isNil(data.key) ? data.key : 'component-' + index + '-' + cellIndex}-container`}, [data]);
- //if there is no onClick function, render as simple cell
- } else if (isNil(onClick)) {
- output = h(SimpleTextCell, { text: data, style: appliedStyle, keyProp: `filtered-list-${id}-${label}`, cellIndex });
- } else {
+ const renderedRow = (
+
+ {row.map(({data, style, onClick, isComponent, id, label}, cellIndex) => {
+ let output;
+ //columnHeaders determine width of the columns,
+ //therefore extract width from columnHeader and apply to cell style
+ const columnWidthStyle = columnHeaders[cellIndex].cellStyle;
+ //assume component is in hyperscript format
+ //wrap component in dive with columnWidth applied
+ const appliedStyle = {...style, ...columnWidthStyle};
+ if (isComponent) {
+ output = (
+
+ {data}
+
+ );
+ //if there is no onClick function, render as simple cell
+ } else if (!onClick) {
+ output =
;
//otherwise render as on click cell
- output = h(OnClickTextCell, { text: data, style: appliedStyle, onClick: () => onClick(index), keyProp: `filtered-list-${id}-${label}`, cellIndex });
- }
- return output;
- }));
-
+ } else {
+ output =
onClick(index)} keyProp={`filtered-list-${id}-${label}`} cellIndex={cellIndex} />;
+ }
+ return output;
+ })}
+
+ );
return rowWrapper({renderedRow, rowData: row});
});
-
};
//Simple table component, can be used alone, can be built on top of (like with LibraryCardTable)
@@ -112,17 +117,16 @@ export default function SimpleTable(props) {
} = props;
const {baseStyle, columnStyle, containerOverride} = styles;
- const columnRow = h(ColumnRow, {key: 'column-row-container', columnHeaders, baseStyle, columnStyle, sort, onSort});
- const tableTemplate = [columnRow, h(DataRows, {rowData, baseStyle, columnHeaders, rowWrapper, key: 'table-data-rows'})];
- const output = isLoading ? h(TableLoading, {}) : tableTemplate;
- return div([
- div({className: 'table-data', style: containerOverride || Styles.TABLE.CONTAINER, role: 'table'},
- [output, isNil(paginationBar) ? div() : paginationBar]),
- h(ReactTooltip, {
- place: 'left',
- effect: 'solid',
- multiline: true,
- className: 'tooltip-wrapper'
- })
- ]);
+ const columnRow = ;
+ const tableTemplate = [columnRow, ];
+ const output = isLoading ? : tableTemplate;
+ return (
+
+
+ {output}
+ {!paginationBar ?
: paginationBar}
+
+
+
+ );
}