@bento-core/table 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/babel.config.json +20 -0
  2. package/dist/DefaultThemConfig.js +68 -0
  3. package/dist/ExtendedView.js +64 -0
  4. package/dist/TableView.js +90 -0
  5. package/dist/body/ActionBodyCell.js +37 -0
  6. package/dist/body/CustomTblBody.js +64 -0
  7. package/dist/body/DefaultThemConfig.js +84 -0
  8. package/dist/body/DisplayBodyCell.js +80 -0
  9. package/dist/body/components/CheckBoxView.js +24 -0
  10. package/dist/body/components/CustomLinkView.js +30 -0
  11. package/dist/body/components/DataFormatView.js +43 -0
  12. package/dist/body/components/DeleteCellView.js +29 -0
  13. package/dist/errMsg/DefaultThemConfig.js +19 -0
  14. package/dist/errMsg/DisplayErrMsg.js +44 -0
  15. package/dist/header/ActionHeaderCell.js +42 -0
  16. package/dist/header/CustomCell.js +47 -0
  17. package/dist/header/CustomTblHeader.js +82 -0
  18. package/dist/header/DefaultThemConfig.js +160 -0
  19. package/dist/header/components/CheckBoxView.js +28 -0
  20. package/dist/header/components/DeleteCellView.js +47 -0
  21. package/dist/header/components/RemoveAllDialog.js +36 -0
  22. package/dist/index.js +45 -0
  23. package/dist/pagination/CustomPagination.js +74 -0
  24. package/dist/toolbar/CustomToolbar.js +53 -0
  25. package/dist/toolbar/DownloadButtonView.js +23 -0
  26. package/dist/toolbar/ManageColumnView.js +110 -0
  27. package/dist/util/ClassNames.js +22 -0
  28. package/dist/util/Dataformat.js +14 -0
  29. package/dist/util/Types.js +53 -0
  30. package/package.json +25 -0
  31. package/src/DefaultThemConfig.js +62 -0
  32. package/src/ExtendedView.js +63 -0
  33. package/src/TableView.js +94 -0
  34. package/src/body/ActionBodyCell.js +39 -0
  35. package/src/body/CustomTblBody.js +68 -0
  36. package/src/body/DefaultThemConfig.js +79 -0
  37. package/src/body/DisplayBodyCell.js +78 -0
  38. package/src/body/components/CheckBoxView.js +20 -0
  39. package/src/body/components/CustomLinkView.js +25 -0
  40. package/src/body/components/DataFormatView.js +44 -0
  41. package/src/body/components/DeleteCellView.js +31 -0
  42. package/src/errMsg/DefaultThemConfig.js +13 -0
  43. package/src/errMsg/DisplayErrMsg.js +40 -0
  44. package/src/header/ActionHeaderCell.js +42 -0
  45. package/src/header/CustomCell.js +51 -0
  46. package/src/header/CustomTblHeader.js +87 -0
  47. package/src/header/DefaultThemConfig.js +154 -0
  48. package/src/header/components/CheckBoxView.js +27 -0
  49. package/src/header/components/DeleteCellView.js +61 -0
  50. package/src/header/components/RemoveAllDialog.js +54 -0
  51. package/src/index.js +8 -0
  52. package/src/pagination/CustomPagination.js +66 -0
  53. package/src/toolbar/CustomToolbar.js +52 -0
  54. package/src/toolbar/DownloadButtonView.js +29 -0
  55. package/src/toolbar/ManageColumnView.js +134 -0
  56. package/src/util/ClassNames.js +17 -0
  57. package/src/util/Dataformat.js +8 -0
  58. package/src/util/Types.js +39 -0
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _core = require("@material-ui/core");
9
+ var _icons = require("@material-ui/icons");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ const DownloadButton = _ref => {
12
+ let {
13
+ download
14
+ } = _ref;
15
+ if (!download) {
16
+ return null;
17
+ }
18
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
19
+ title: download.downloadCsv
20
+ }, /*#__PURE__*/_react.default.createElement(_core.IconButton, null, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null))));
21
+ };
22
+ var _default = DownloadButton;
23
+ exports.default = _default;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _core = require("@material-ui/core");
9
+ var _icons = require("@material-ui/icons");
10
+ var _Types = require("../util/Types");
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ const ManageColumnView = _ref => {
14
+ let {
15
+ classes,
16
+ table,
17
+ onColumnViewChange,
18
+ manageViewColumns
19
+ } = _ref;
20
+ if (!manageViewColumns) {
21
+ return null;
22
+ }
23
+ const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
24
+ const handleClick = event => {
25
+ setAnchorEl(event.currentTarget);
26
+ };
27
+ const handleClose = () => setAnchorEl(null);
28
+ const open = Boolean(anchorEl);
29
+ const {
30
+ columns
31
+ } = table;
32
+ const viewColumns = columns.filter(col => col.role === _Types.cellTypes.DISPLAY);
33
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
34
+ title: manageViewColumns.title
35
+ }, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
36
+ variant: "contained",
37
+ onClick: handleClick
38
+ }, /*#__PURE__*/_react.default.createElement(_icons.ViewColumn, null))), /*#__PURE__*/_react.default.createElement(_core.Popover, {
39
+ open: open,
40
+ anchorEl: anchorEl,
41
+ onClose: handleClose,
42
+ anchorOrigin: {
43
+ vertical: 'bottom',
44
+ horizontal: 'left'
45
+ }
46
+ }, /*#__PURE__*/_react.default.createElement(_core.Typography, {
47
+ variant: "caption",
48
+ className: "viewColumnText"
49
+ }, manageViewColumns.title), /*#__PURE__*/_react.default.createElement(_core.IconButton, {
50
+ onClick: handleClose,
51
+ className: "closeIcon"
52
+ }, /*#__PURE__*/_react.default.createElement(_icons.Close, null)), /*#__PURE__*/_react.default.createElement(_core.List, {
53
+ className: "viewColumnList"
54
+ }, viewColumns.map(column => /*#__PURE__*/_react.default.createElement(_core.ListItem, {
55
+ width: 1,
56
+ className: "viewColumnListItem"
57
+ }, /*#__PURE__*/_react.default.createElement(_core.Checkbox, {
58
+ icon: /*#__PURE__*/_react.default.createElement(_icons.CheckBoxOutlineBlank, {
59
+ style: {
60
+ fontSize: 18
61
+ },
62
+ className: "checkBoxIcon"
63
+ }),
64
+ onClick: () => onColumnViewChange(column),
65
+ checked: column.display,
66
+ checkedIcon: /*#__PURE__*/_react.default.createElement(_icons.CheckBox, {
67
+ style: {
68
+ fontSize: 18
69
+ },
70
+ className: "checkBoxIcon"
71
+ }),
72
+ disableRipple: true,
73
+ color: "secondary",
74
+ className: "checkBox"
75
+ }), /*#__PURE__*/_react.default.createElement(_core.Typography, null, column.header))))));
76
+ };
77
+ const styles = () => ({
78
+ root: {
79
+ padding: '16px 24px 16px 24px',
80
+ fontFamily: 'Roboto'
81
+ },
82
+ title: {
83
+ marginRight: '24px',
84
+ fontSize: '14px',
85
+ color: '#0B3556',
86
+ textAlign: 'left',
87
+ fontWeight: 500
88
+ },
89
+ formGroup: {
90
+ marginTop: '8px'
91
+ },
92
+ formControl: {},
93
+ checkbox: {
94
+ padding: '0px',
95
+ width: '32px',
96
+ height: '32px'
97
+ },
98
+ checkboxRoot: {
99
+ '&$checked': {
100
+ color: '#0B3556'
101
+ }
102
+ },
103
+ checked: {},
104
+ label: {
105
+ fontSize: '15px',
106
+ marginLeft: '8px'
107
+ }
108
+ });
109
+ var _default = (0, _core.withStyles)(styles)(ManageColumnView);
110
+ exports.default = _default;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.tableCls = exports.getClsName = void 0;
7
+ const tableCls = {
8
+ HEADER: 'header',
9
+ BODY: 'body',
10
+ ROW: '_row',
11
+ COL: '_col',
12
+ CHECKBOX: '_checkbox',
13
+ CHECKBOX_ACTIVE: '_checkbox_active',
14
+ CHECKBOX_INACTIVE: '_checkbox_in_active',
15
+ TOOLTIP: '_tooltip'
16
+ };
17
+ exports.tableCls = tableCls;
18
+ const getClsName = (prefix, postfix) => {
19
+ const className = "".concat(prefix).replace(' ', '_').toLowerCase().concat("_".concat(postfix));
20
+ return className;
21
+ };
22
+ exports.getClsName = getClsName;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatBytes = formatBytes;
7
+ function formatBytes(bytes) {
8
+ let decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
9
+ if (bytes === 0) return '0 Bytes';
10
+ const dm = decimals < 0 ? 0 : decimals;
11
+ const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
12
+ const i = Math.floor(Math.log(bytes) / Math.log(1024));
13
+ return "".concat(parseFloat((bytes / 1024 ** i).toFixed(dm)), " ").concat(sizes[i]);
14
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.headerTypes = exports.dataFormatTypes = exports.cellTypes = exports.actionCellTypes = exports.LINK = exports.FORMAT_DATA_CELLS = exports.FORMAT_DATA = exports.FORMAT_BYTES = exports.DISPLAY = exports.DELETE = exports.DEFAULT = exports.ComponentTypes = exports.CUSTOM_ELEM = exports.CHECKBOX = void 0;
7
+ const CHECKBOX = 'CHECKBOX';
8
+ exports.CHECKBOX = CHECKBOX;
9
+ const DELETE = 'DELETE';
10
+ exports.DELETE = DELETE;
11
+ const CUSTOM_ELEM = 'CUSTOM_ELEM';
12
+ exports.CUSTOM_ELEM = CUSTOM_ELEM;
13
+ const LINK = 'LINK';
14
+ exports.LINK = LINK;
15
+ const DISPLAY = 'DISPLAY';
16
+ exports.DISPLAY = DISPLAY;
17
+ const DEFAULT = 'DEFAULT';
18
+ exports.DEFAULT = DEFAULT;
19
+ const FORMAT_DATA = 'FORMAT_DATA';
20
+ exports.FORMAT_DATA = FORMAT_DATA;
21
+ const FORMAT_BYTES = 'FORMAT_BYTES';
22
+ exports.FORMAT_BYTES = FORMAT_BYTES;
23
+ const cellTypes = {
24
+ CUSTOM_ELEM: CUSTOM_ELEM,
25
+ LINK: LINK,
26
+ DISPLAY: DISPLAY,
27
+ CHECKBOX: CHECKBOX,
28
+ DELETE: DELETE,
29
+ DEFAULT: DEFAULT,
30
+ FORMAT_DATA: FORMAT_DATA
31
+ };
32
+ exports.cellTypes = cellTypes;
33
+ const actionCellTypes = [CHECKBOX, DELETE];
34
+ exports.actionCellTypes = actionCellTypes;
35
+ const FORMAT_DATA_CELLS = [FORMAT_BYTES];
36
+ exports.FORMAT_DATA_CELLS = FORMAT_DATA_CELLS;
37
+ const dataFormatTypes = {
38
+ FORMAT_BYTES: 'FORMAT_BYTES'
39
+ };
40
+ exports.dataFormatTypes = dataFormatTypes;
41
+ const headerTypes = {
42
+ CUSTOM_ELEM: CUSTOM_ELEM,
43
+ DELETE: DELETE,
44
+ DEFAULT: DEFAULT
45
+ };
46
+ exports.headerTypes = headerTypes;
47
+ const ComponentTypes = {
48
+ PAGINATION: 'PAGINATION',
49
+ MANAGE_VIEW_COLUMNS: 'MANAGE_VIEW_COLUMNS',
50
+ DOWNLOAD_TABLE_BTN: 'DOWNLOAD_TABLE_BTN',
51
+ CUSTOM_ELEM: 'CUSTOM_ELEM'
52
+ };
53
+ exports.ComponentTypes = ComponentTypes;
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@bento-core/table",
3
+ "version": "0.2.0",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "build": "rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "repository": "https://github.com/CBIIT/bento-frontend",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "dependencies": {
15
+ "@material-ui/core": "^4.12.4"
16
+ },
17
+ "peerDependencies": {
18
+ "react": "^17.0.2",
19
+ "react-dom": "^17.0.0",
20
+ "react-redux": "^7.2.1"
21
+ },
22
+ "author": "CTOS Bento Team",
23
+ "license": "ISC",
24
+ "gitHead": "10ee9deeae6dd0f139ecb7a70afc4c96a4e33d74"
25
+ }
@@ -0,0 +1,62 @@
1
+ const defaultTheme = () => ({
2
+ MuiToolbar: {
3
+ root: {
4
+ textAlign: 'right',
5
+ display: 'block',
6
+ },
7
+ },
8
+ MuiPopover: {
9
+ paper: {
10
+ padding: '16px 5px 16px 10px',
11
+ },
12
+ },
13
+ MuiTypography: {
14
+ root: {
15
+ '&.viewColumnText': {
16
+ paddingLeft: '10px',
17
+ color: '#0B3556',
18
+ fontSize: '14px',
19
+ textAlign: 'right',
20
+ fontWeight: '500',
21
+ },
22
+ },
23
+ },
24
+ MuiList: {
25
+ root: {
26
+ '&.viewColumnList': {
27
+ padding: '8px 20px 8px 10px',
28
+ },
29
+ },
30
+ },
31
+ MuiListItem: {
32
+ root: {
33
+ '&.viewColumnListItem': {
34
+ padding: '0',
35
+ },
36
+ },
37
+ },
38
+ MuiIconButton: {
39
+ root: {
40
+ '&.closeIcon': {
41
+ float: 'right',
42
+ padding: '0',
43
+ },
44
+ },
45
+ },
46
+ MuiCheckbox: {
47
+ root: {
48
+ '&.checkBox': {
49
+ padding: '5px 5px 5px 0px',
50
+ },
51
+ },
52
+ },
53
+ MuiSvgIcon: {
54
+ root: {
55
+ '&.checkBoxIcon': {
56
+ color: '#0B3556',
57
+ },
58
+ },
59
+ },
60
+ });
61
+
62
+ export default defaultTheme;
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import {
3
+ ThemeProvider,
4
+ Toolbar,
5
+ createTheme,
6
+ } from '@material-ui/core';
7
+ import CustomPagination from './pagination/CustomPagination';
8
+ import ManageColumnView from './toolbar/ManageColumnView';
9
+ import defaultTheme from './DefaultThemConfig';
10
+ import DownloadButton from './toolbar/DownloadButtonView';
11
+
12
+ const ExtendedView = ({
13
+ table,
14
+ onColumnViewChange,
15
+ onRowsPerPageChange,
16
+ onPageChange,
17
+ numSelected = 0,
18
+ customTheme,
19
+ }) => {
20
+ const { extendedViewConfig } = table;
21
+ if (!extendedViewConfig) {
22
+ return null;
23
+ }
24
+ const {
25
+ download = false,
26
+ manageViewColumns = false,
27
+ pagination = false,
28
+ } = extendedViewConfig;
29
+
30
+ const themeConfig = createTheme({ overrides: { ...defaultTheme(), ...customTheme } });
31
+ return (
32
+ <ThemeProvider theme={themeConfig}>
33
+ {(numSelected === 0 && (download || manageViewColumns)) && (
34
+ <Toolbar className="downloadColumnView">
35
+ <DownloadButton
36
+ download={download}
37
+ />
38
+ <ManageColumnView
39
+ table={table}
40
+ manageViewColumns={manageViewColumns}
41
+ onColumnViewChange={onColumnViewChange}
42
+ />
43
+ </Toolbar>
44
+ )}
45
+ {
46
+ (pagination) && (
47
+ <CustomPagination
48
+ customTheme={themeConfig.tblTopPgn}
49
+ rowsPerPageOptions={[10, 25, 50, 100]}
50
+ component="div"
51
+ count={table.totalRowCount || 0}
52
+ rowsPerPage={table.rowsPerPage || 10}
53
+ page={table.page || 0}
54
+ onPageChange={onPageChange}
55
+ onRowsPerPageChange={onRowsPerPageChange}
56
+ />
57
+ )
58
+ }
59
+ </ThemeProvider>
60
+ );
61
+ };
62
+
63
+ export default ExtendedView;
@@ -0,0 +1,94 @@
1
+ import React from 'react';
2
+ import {
3
+ Paper,
4
+ Table,
5
+ TableContainer,
6
+ ThemeProvider,
7
+ createTheme,
8
+ } from '@material-ui/core';
9
+ import TableHeader from './header/CustomTblHeader';
10
+ import CustomPagination from './pagination/CustomPagination';
11
+ import CustomTableBody from './body/CustomTblBody';
12
+ import CustomToolbar from './toolbar/CustomToolbar';
13
+ import DisplayErrMsg from './errMsg/DisplayErrMsg';
14
+ import ExtendedView from './ExtendedView';
15
+
16
+ const CustomTableContainer = (props) => {
17
+ const { children, customTheme } = props;
18
+ const themeConfig = createTheme({ overrides: { ...customTheme } });
19
+ return (
20
+ <ThemeProvider theme={themeConfig}>
21
+ <TableContainer component={Paper}>
22
+ {children}
23
+ </TableContainer>
24
+ </ThemeProvider>
25
+ );
26
+ };
27
+
28
+ const TableView = ({
29
+ tableRows = [],
30
+ table,
31
+ onRowsPerPageChange,
32
+ onPageChange,
33
+ onRowSelectChange,
34
+ onToggleSelectAll,
35
+ totalRowCount,
36
+ onSortByColumn,
37
+ onColumnViewChange,
38
+ themeConfig = {},
39
+ }) => (
40
+ <>
41
+ <ExtendedView
42
+ table={table}
43
+ onColumnViewChange={onColumnViewChange}
44
+ onRowsPerPageChange={onRowsPerPageChange}
45
+ onPageChange={onPageChange}
46
+ numSelected={table?.selectedRows?.length || 0}
47
+ customTheme={themeConfig.extendedView}
48
+ />
49
+ <CustomToolbar
50
+ numSelected={table?.selectedRows?.length || 0}
51
+ table={table}
52
+ onColumnViewChange={onColumnViewChange}
53
+ customTheme={themeConfig.toolbar}
54
+ />
55
+ <CustomTableContainer
56
+ customTheme={themeConfig.tblContainer || {}}
57
+ >
58
+ <Table>
59
+ <TableHeader
60
+ customTheme={themeConfig.tblHeader}
61
+ table={table}
62
+ rows={tableRows}
63
+ count={totalRowCount}
64
+ toggleSelectAll={onToggleSelectAll}
65
+ sortByColumn={onSortByColumn}
66
+ />
67
+ <CustomTableBody
68
+ customTheme={themeConfig.tblBody}
69
+ rows={tableRows}
70
+ table={table}
71
+ onRowSelectChange={onRowSelectChange}
72
+ />
73
+ </Table>
74
+ </CustomTableContainer>
75
+ {tableRows.length === 0 && (
76
+ <DisplayErrMsg
77
+ customTheme={themeConfig.displayErr}
78
+ table={table}
79
+ />
80
+ )}
81
+ <CustomPagination
82
+ customTheme={themeConfig.tblPgn}
83
+ rowsPerPageOptions={[10, 25, 50, 100]}
84
+ component="div"
85
+ count={table.totalRowCount || 0}
86
+ rowsPerPage={table.rowsPerPage || 10}
87
+ page={table.page || 0}
88
+ onPageChange={onPageChange}
89
+ onRowsPerPageChange={onRowsPerPageChange}
90
+ />
91
+ </>
92
+ );
93
+
94
+ export default TableView;
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import CheckboxView from './components/CheckBoxView';
3
+ import DeleteCellView from './components/DeleteCellView';
4
+ import { Typography } from '@material-ui/core';
5
+ import { cellTypes } from '../util/Types';
6
+
7
+ const ActionCell = ({
8
+ row,
9
+ onRowSelectChange,
10
+ column,
11
+ }) => {
12
+ const { cellType } = column;
13
+
14
+ if (cellTypes.CHECKBOX === cellType) {
15
+ return (
16
+ <CheckboxView
17
+ row={row}
18
+ onRowSelectChange={onRowSelectChange}
19
+ />
20
+ )
21
+ }
22
+
23
+ if (cellTypes.DELETE === cellType) {
24
+ return (
25
+ <DeleteCellView
26
+ row={row}
27
+ column={column}
28
+ />
29
+ );
30
+ }
31
+
32
+ return (
33
+ <Typography>
34
+ {row[column.dataField]}
35
+ </Typography>
36
+ );
37
+ }
38
+
39
+ export default ActionCell;
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import {
4
+ TableBody,
5
+ TableRow,
6
+ ThemeProvider,
7
+ createTheme,
8
+ } from '@material-ui/core';
9
+ import DisplayCell from './DisplayBodyCell';
10
+ import defaultTheme from './DefaultThemConfig';
11
+ import { actionCellTypes } from '../util/Types';
12
+ import ActionCell from './ActionBodyCell';
13
+
14
+ /**
15
+ * 1. Returns cell associated with action (checkbox / delete view)
16
+ * 2. Returns cell associated with display data (DisplayBodyCell)
17
+ */
18
+ const CustomTableBody = ({
19
+ rows = [],
20
+ table,
21
+ onRowSelectChange,
22
+ customTheme = {},
23
+ }) => {
24
+ const { columns } = table;
25
+ const displayColunms = columns.filter((col) => col.display);
26
+ const themeConfig = createTheme({ overrides: { ...defaultTheme(), ...customTheme } });
27
+
28
+ return (
29
+ <ThemeProvider theme={themeConfig}>
30
+ <TableBody>
31
+ {rows
32
+ .map((row) => (
33
+ <TableRow>
34
+ {
35
+ displayColunms.map((column) => {
36
+ const { cellType } = column;
37
+ const isActionCell = actionCellTypes.includes(cellType) || false;
38
+ if (isActionCell) {
39
+ return (
40
+ <ActionCell
41
+ row={row}
42
+ column={column}
43
+ onRowSelectChange={onRowSelectChange}
44
+ />
45
+ );
46
+ }
47
+ return (
48
+ <DisplayCell
49
+ column={column}
50
+ row={row}
51
+ />
52
+ );
53
+ })
54
+ }
55
+ </TableRow>
56
+ ))}
57
+ </TableBody>
58
+ </ThemeProvider>
59
+ );
60
+ };
61
+
62
+ CustomTableBody.propTypes = {
63
+ table: PropTypes.objectOf(PropTypes.object).isRequired,
64
+ rows: PropTypes.arrayOf(PropTypes.object).isRequired,
65
+ onRowSelectChange: PropTypes.func.isRequired,
66
+ };
67
+
68
+ export default CustomTableBody;
@@ -0,0 +1,79 @@
1
+ const defaultTheme = () => ({
2
+ MuiTableRow: {
3
+ head: {
4
+ height: '40px',
5
+ borderBottom: '3px solid #42779a',
6
+ },
7
+ root: {
8
+ '&:nth-child(even)': {
9
+ background: '#f4f5f5',
10
+ },
11
+ },
12
+ },
13
+ MuiTableHead: {
14
+ root: {
15
+ fontWeight: '400',
16
+ lineHeight: '2',
17
+ fontSize: '16px',
18
+ fontStyle: 'normal',
19
+ fontFamily: 'Nunito',
20
+ letterSpacing: '0.0025em',
21
+ },
22
+ },
23
+ MuiTableCell: {
24
+ root: {
25
+ minHeight: '45px',
26
+ padding: '0px 5px 0px 20px',
27
+ color: '#004C73',
28
+ cursor: 'pointer',
29
+ },
30
+ paddingCheckbox: {
31
+ width: '48px',
32
+ padding: '0 0 0 5px',
33
+ },
34
+ body: {
35
+ color: '#004C73',
36
+ },
37
+ },
38
+ MuiLink: {
39
+ root: {
40
+ textDecoration: 'none',
41
+ color: '#0083c6',
42
+ },
43
+ },
44
+ MuiCheckbox: {
45
+ colorSecondary: {
46
+ '&.Mui-checked': {
47
+ color: '#8DCAFF',
48
+ },
49
+ },
50
+ root: {
51
+ color: '#142D64',
52
+ '&:hover': {
53
+ background: 'none',
54
+ },
55
+ },
56
+ },
57
+ MuiButtonBase: {
58
+ root: {
59
+ '&.del_row_btn': {
60
+ width: '29px',
61
+ border: '1px solid #ccc',
62
+ margin: '10px 10px 10px 10px',
63
+ cursor: 'pointer',
64
+ height: '26px',
65
+ padding: '0',
66
+ background: '#fff',
67
+ borderRadius: '15%',
68
+ },
69
+ },
70
+ },
71
+ MuiSvgIcon: {
72
+ root: {
73
+ '&.del_row_btn_icon': {
74
+ },
75
+ },
76
+ },
77
+ });
78
+
79
+ export default defaultTheme;