@bento-core/table 1.0.0-c3dc.3 → 1.0.0-c3dc.31

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 (41) hide show
  1. package/dist/ExtendedView.js +9 -11
  2. package/dist/TableView.js +7 -4
  3. package/dist/assets/cpi_icon.svg +22 -0
  4. package/dist/assets/downArrow.svg +3 -0
  5. package/dist/assets/leftArrow.svg +3 -0
  6. package/dist/assets/rightArrow.svg +3 -0
  7. package/dist/body/CustomTblBody.js +9 -4
  8. package/dist/body/DisplayBodyCell.js +18 -3
  9. package/dist/body/components/CPIModal.js +210 -0
  10. package/dist/body/components/CPIView.js +115 -0
  11. package/dist/body/components/CustomLinkView.js +1 -1
  12. package/dist/body/components/ModalStyle.js +121 -0
  13. package/dist/header/ActionHeaderCell.js +2 -1
  14. package/dist/header/CustomCell.js +8 -5
  15. package/dist/header/CustomTblHeader.js +3 -1
  16. package/dist/header/components/CheckBoxView.js +3 -2
  17. package/dist/pagination/CustomPagination.js +84 -28
  18. package/dist/toolbar/DownloadButtonView.js +254 -51
  19. package/dist/util/Types.js +8 -2
  20. package/dist/util/downloadTable.js +72 -37
  21. package/package.json +2 -2
  22. package/src/ExtendedView.js +34 -33
  23. package/src/TableView.js +11 -8
  24. package/src/assets/cpi_icon.svg +22 -0
  25. package/src/assets/downArrow.svg +3 -0
  26. package/src/assets/leftArrow.svg +3 -0
  27. package/src/assets/rightArrow.svg +3 -0
  28. package/src/body/CustomTblBody.js +6 -1
  29. package/src/body/DisplayBodyCell.js +23 -0
  30. package/src/body/components/CPIModal.js +243 -0
  31. package/src/body/components/CPIView.js +133 -0
  32. package/src/body/components/CustomLinkView.js +1 -1
  33. package/src/body/components/ModalStyle.js +115 -0
  34. package/src/header/ActionHeaderCell.js +1 -0
  35. package/src/header/CustomCell.js +6 -3
  36. package/src/header/CustomTblHeader.js +3 -1
  37. package/src/header/components/CheckBoxView.js +2 -1
  38. package/src/pagination/CustomPagination.js +97 -40
  39. package/src/toolbar/DownloadButtonView.js +257 -73
  40. package/src/util/Types.js +4 -0
  41. package/src/util/downloadTable.js +51 -17
@@ -0,0 +1,133 @@
1
+ import React, { useState } from 'react';
2
+ import {
3
+ Typography,
4
+ Tooltip,
5
+ makeStyles,
6
+ } from '@material-ui/core';
7
+ import { cellTypes } from '../../util/Types';
8
+ import cpiIcon from '../../assets/cpi_icon.svg';
9
+ import CPIModal from './CPIModal';
10
+
11
+ /**
12
+ * Custom Link component
13
+ */
14
+
15
+ const CPIView = ({
16
+ column,
17
+ row,
18
+ themeConfig,
19
+ }) => {
20
+ const useStyles = makeStyles(() => ({
21
+ arrow: {
22
+ '&:before': {
23
+ border: '1px solid black',
24
+ },
25
+ color: 'white',
26
+ },
27
+ tooltip: {
28
+ backgroundColor: 'white',
29
+ border: '1px solid black',
30
+ color: 'black',
31
+ font: 'Poppins',
32
+ fontWeight: 400,
33
+ fontSize: '13px',
34
+ lineHeight: '17.5px',
35
+ },
36
+ }));
37
+
38
+ const classes = useStyles();
39
+
40
+ const [modalOpen, setModalOpen] = useState(false);
41
+ const cpiData = row.cpi_data;
42
+ const internalData = cpiData.filter((e) => (e.data_type === 'internal'));
43
+ const externalData = cpiData.filter((e) => (e.data_type === 'external'));
44
+
45
+ const handleModalOpen = () => {
46
+ setModalOpen(true);
47
+ };
48
+
49
+ const handleModalClose = () => {
50
+ setModalOpen(false);
51
+ };
52
+
53
+ const button = {
54
+ color: '#07679C',
55
+ textDecoration: 'underline',
56
+ fontWeight: 700,
57
+ cursor: 'pointer',
58
+ padding: 0,
59
+ marginLeft: '3px',
60
+ };
61
+
62
+ const icon = {
63
+ marginLeft: '10px',
64
+ position: 'relative',
65
+ top: '5px',
66
+ cursor: 'pointer',
67
+ };
68
+
69
+ return (
70
+ <Typography className={cellTypes.CPI}>
71
+ {row[column?.dataField]}
72
+ {cpiData.length
73
+ ? (
74
+ <>
75
+ <CPIModal
76
+ row={row}
77
+ open={modalOpen}
78
+ onClose={handleModalClose}
79
+ themeConfig={themeConfig}
80
+ />
81
+ <Tooltip
82
+ interactive
83
+ placement="top"
84
+ arrow
85
+ disableFocusListener
86
+ disableTouchListener
87
+ style={{
88
+ pointerEvents: 'auto',
89
+ backgroundColor: 'transparent',
90
+ font: 'Poppins',
91
+ fontSize: '13px',
92
+ }}
93
+ classes={{ arrow: classes.arrow, tooltip: classes.tooltip }}
94
+ title={
95
+ (externalData.length && internalData.length === 0
96
+ ? (
97
+ <div>
98
+ All mapped identifiers in the CCDI Participant Index (CPI) are available
99
+ <span role="button" onClick={handleModalOpen} tabIndex={0} style={button}>here.</span>
100
+ </div>
101
+ )
102
+ : (
103
+ <div>
104
+ <div style={{ marginBottom: '3px' }}>Identifier mapped in CCDI Hub:</div>
105
+ {internalData.map((e) => (
106
+ <div>{`${e.associated_id}, ${e.repository_of_synonym_id}`}</div>
107
+ ))}
108
+ <p>
109
+ All mapped identifiers in the CCDI Participant Index (CPI) are available
110
+ <span role="button" onClick={handleModalOpen} tabIndex={0} style={button}>here.</span>
111
+ </p>
112
+ </div>
113
+ )
114
+ )
115
+ }
116
+ >
117
+ <span style={icon}>
118
+ <img
119
+ src={cpiIcon}
120
+ height={21}
121
+ width={23}
122
+ alt="cpi-icon"
123
+ />
124
+ </span>
125
+ </Tooltip>
126
+ </>
127
+ )
128
+ : <></>}
129
+ </Typography>
130
+ );
131
+ };
132
+
133
+ export default CPIView;
@@ -12,7 +12,7 @@ const CustomLinkView = ({
12
12
  row,
13
13
  }) => {
14
14
  const { rootPath, pathParams } = column?.linkAttr;
15
- const url = pathParams.map((attr) => `#${rootPath}/`.concat(row[attr]));
15
+ const url = pathParams.map((attr) => `${rootPath}/`.concat(row[attr]));
16
16
  return (
17
17
  <Link href={url} className={cellTypes.LINK}>
18
18
  <Typography>
@@ -0,0 +1,115 @@
1
+ export default () => ({
2
+ header: {
3
+ display: 'flex',
4
+ justifyContent: 'center',
5
+ alignItems: 'center',
6
+ height: '55px',
7
+ },
8
+ closeButton: {
9
+ marginLeft: '769px',
10
+ position: 'absolute',
11
+ },
12
+ resetIcon: {
13
+ marginLeft: '10px',
14
+ minWidth: '5px',
15
+ width: '5px',
16
+ borderRadius: '9px',
17
+ height: '30px',
18
+ },
19
+ modalTitle: {
20
+ fontFamily: 'Poppins',
21
+ fontSize: '19px',
22
+ fontWeight: '400',
23
+ lineHeight: '21px',
24
+ letterSpacing: '0.02em',
25
+ textAlign: 'center',
26
+ color: '#000000',
27
+ },
28
+ modalBody: {
29
+ position: 'absolute',
30
+ top: '5%',
31
+ left: '25%',
32
+ width: '840px',
33
+ height: '671px',
34
+ background: '#FFFFFF',
35
+ border: '1px solid #505050',
36
+ borderRadius: '40px',
37
+ overflow: 'hidden',
38
+ },
39
+ tableContainer: {
40
+ '&::-webkit-scrollbar': {
41
+ width: '6px',
42
+ borderWidth: '0px 1px 1px 1px',
43
+ borderStyle: 'solid',
44
+ borderColor: '#B0B0B0',
45
+ },
46
+ '&::-webkit-scrollbar-track': {
47
+ backgroundColor: '#CECECE',
48
+ },
49
+ '&::-webkit-scrollbar-thumb': {
50
+ backgroundColor: '#003F74',
51
+ },
52
+ },
53
+ searchContainer: {
54
+ display: 'flex',
55
+ justifyContent: 'center',
56
+ alignItems: 'center',
57
+ borderTop: '3px solid #939393',
58
+ borderBottom: '3px solid #939393',
59
+ height: '51px',
60
+ },
61
+ searchInputbox: {
62
+ marginRight: '10px',
63
+ fontFamily: 'Poppins',
64
+ fontSize: '18px',
65
+ fontWeight: '600',
66
+ lineHeight: '27px',
67
+ letterSpacing: '-0.02em',
68
+ textAlign: 'left',
69
+ color: '#7A437A',
70
+ },
71
+ highlight: {
72
+ color: '#b2c6d6',
73
+ },
74
+ sortGroup: {
75
+ paddingTop: '10px',
76
+ marginBottom: '5px',
77
+ borderTop: '1px solid #B1B1B1',
78
+ textAlign: 'left',
79
+ marginLeft: '-5px',
80
+ },
81
+ sortGroupIcon: {
82
+ cursor: 'pointer',
83
+ fontFamily: 'Nunito',
84
+ fontSize: '10px',
85
+ marginRight: '12px',
86
+ marginLeft: '24px',
87
+ },
88
+ sortGroupItem: {
89
+ cursor: 'pointer',
90
+ fontFamily: 'Nunito',
91
+ fontSize: '10px',
92
+ marginRight: '32px',
93
+ },
94
+ NonSortGroup: {
95
+ marginBottom: '5px',
96
+ borderTop: '1px solid #B1B1B1',
97
+ textAlign: 'left',
98
+ paddingLeft: '10px',
99
+ },
100
+ NonSortGroupItem: {
101
+ fontFamily: 'Nunito',
102
+ fontSize: '10px',
103
+ marginRight: '32px',
104
+ },
105
+ sortGroupItemCounts: {
106
+ cursor: 'pointer',
107
+ fontFamily: 'Nunito',
108
+ fontSize: '10px',
109
+ float: 'right',
110
+ marginRight: '10px',
111
+ marginTop: '5px',
112
+ },
113
+ itemContainer: {
114
+ },
115
+ });
@@ -19,6 +19,7 @@ const ActionHeaderCell = ({
19
19
  includeSelectedIds={includeSelectedIds}
20
20
  toggleSelectAll={toggleSelectAll}
21
21
  Ids={Ids}
22
+ rows={rows}
22
23
  />
23
24
  );
24
25
  }
@@ -14,12 +14,14 @@ const CustomHeaderCell = ({
14
14
  column,
15
15
  components = {},
16
16
  toggleSort,
17
+ style,
17
18
  }) => {
18
19
  const {
19
20
  dataField,
20
21
  tooltipText,
21
22
  header,
22
23
  headerType,
24
+ sortField,
23
25
  customColHeaderRender,
24
26
  sortable,
25
27
  } = column;
@@ -61,12 +63,13 @@ const CustomHeaderCell = ({
61
63
  scope="col"
62
64
  active={sortBy === dataField}
63
65
  direction={sortOrder}
66
+ style={style}
64
67
  >
65
68
  <Tooltip>
66
69
  <TableSortLabel
67
- active={sortBy === dataField}
68
- hideSortIcon={sortBy !== dataField}
69
- direction={sortBy === dataField ? sortOrder : 'asc'}
70
+ active={sortBy === ( sortField ? sortField : dataField)}
71
+ hideSortIcon={sortBy !== ( sortField ? sortField : dataField)}
72
+ direction={sortBy === ( sortField ? sortField : dataField) ? sortOrder : 'asc'}
70
73
  onClick={toggleSort}
71
74
  >
72
75
  {(headerType === headerTypes.CUSTOM_ELEM && customColHeaderRender)
@@ -65,7 +65,9 @@ const CustomTableHeader = ({
65
65
  column={column}
66
66
  sortBy={sortBy}
67
67
  sortOrder={sortOrder}
68
- toggleSort={() => sortByColumn(column.dataField, sortOrder)}
68
+ toggleSort={() => {
69
+ sortByColumn(column.sortField ? column.sortField : column.dataField, sortOrder);
70
+ }}
69
71
  />
70
72
  );
71
73
  })
@@ -10,6 +10,7 @@ const CheckboxView = ({
10
10
  includeSelectedIds,
11
11
  toggleSelectAll,
12
12
  Ids,
13
+ rows,
13
14
  }) => (
14
15
  <TableCell padding="checkbox">
15
16
  <span style={{ display: 'none' }}>Select all</span>
@@ -18,7 +19,7 @@ const CheckboxView = ({
18
19
  color="primary"
19
20
  indeterminate={includeSelectedIds}
20
21
  checked={includeSelectedIds}
21
- onChange={(event) => toggleSelectAll(event, Ids, includeSelectedIds)}
22
+ onChange={(event) => toggleSelectAll(event, Ids, includeSelectedIds, rows)}
22
23
  />
23
24
  </TableCell>
24
25
  );
@@ -1,37 +1,59 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import {
4
- createTheme,
4
+ createMuiTheme,
5
5
  TablePagination,
6
6
  ThemeProvider,
7
+ IconButton,
8
+ makeStyles,
7
9
  } from '@material-ui/core';
8
- import KeyboardArrowDownOutlinedIcon from '@material-ui/icons/KeyboardArrowDownOutlined';
10
+ import {
11
+ ArrowDropDown,
12
+ } from '@material-ui/icons';
13
+ import rightArrow from '../assets/rightArrow.svg';
14
+ import leftArrow from '../assets/leftArrow.svg';
9
15
 
10
- const defaultTheme = {
11
- MuiTablePagination: {
12
- root: {
13
- paddingRight: '50px',
14
- borderTop: '3px solid #42779a',
15
- },
16
- toolbar: {
17
- minHeight: '45px',
18
- },
16
+ const useStyles = makeStyles(() => ({
17
+ paginationRoot: {
18
+ display: 'flex',
19
+ justifyContent: 'flex-end', // Moves pagination to the right
20
+ paddingRight: '10px', // Optional spacing
21
+ },
22
+ actionsContainer: {
23
+ display: 'flex',
24
+ justifyContent: 'flex-end', // Align pagination buttons to the right
19
25
  },
20
- MuiTypography: {
21
- body2: {
22
- fontSize: '14px',
23
- textTransform: 'uppercase',
26
+ }));
27
+
28
+ const defaultTheme = createMuiTheme({
29
+ overrides: {
30
+ MuiTablePagination: {
31
+ root: {
32
+ paddingRight: '50px',
33
+ width: '100%',
34
+ },
35
+ toolbar: {
36
+ minHeight: '45px',
37
+ display: 'flex',
38
+ alignItems: 'center',
39
+ },
24
40
  },
25
- root: {
26
- fontSize: '14px',
41
+ MuiTypography: {
42
+ body2: {
43
+ fontSize: '14px',
44
+ textTransform: 'uppercase',
45
+ },
46
+ root: {
47
+ fontSize: '14px',
48
+ },
27
49
  },
28
- },
29
- MuiIconButton: {
30
- root: {
31
- padding: '2px',
50
+ MuiIconButton: {
51
+ root: {
52
+ padding: '2px',
53
+ },
32
54
  },
33
55
  },
34
- };
56
+ });
35
57
 
36
58
  const CustomPagination = ({
37
59
  rowsPerPageOptions,
@@ -41,24 +63,59 @@ const CustomPagination = ({
41
63
  onPageChange,
42
64
  onRowsPerPageChange,
43
65
  customTheme = {},
44
- }) => (
45
- <ThemeProvider theme={createTheme({ overrides: { ...defaultTheme, ...customTheme } })}>
46
- <TablePagination
47
- labelRowsPerPage="Results per Page:"
48
- rowsPerPageOptions={rowsPerPageOptions}
49
- component="div"
50
- count={count}
51
- rowsPerPage={rowsPerPage}
52
- page={page}
53
- onPageChange={onPageChange}
54
- onRowsPerPageChange={onRowsPerPageChange}
55
- SelectProps={{
56
- IconComponent: KeyboardArrowDownOutlinedIcon,
57
- inputProps: { 'aria-label': 'Selection dropdown for displaying the number of results per page' },
58
- }}
59
- />
60
- </ThemeProvider>
61
- );
66
+ }) => {
67
+ const classes = useStyles();
68
+ return (
69
+ <ThemeProvider
70
+ theme={createMuiTheme({ overrides: { ...defaultTheme.overrides, ...customTheme } })}
71
+ >
72
+ <TablePagination
73
+ labelRowsPerPage={<span id="rows-per-page-label">Rows per page:</span>}
74
+ rowsPerPageOptions={rowsPerPageOptions}
75
+ component="div"
76
+ count={count}
77
+ rowsPerPage={rowsPerPage}
78
+ page={page}
79
+ onPageChange={onPageChange}
80
+ onRowsPerPageChange={onRowsPerPageChange}
81
+ SelectProps={{
82
+ IconComponent: ArrowDropDown,
83
+ inputProps: {
84
+ 'aria-label': 'Selection dropdown for displaying the number of results per page',
85
+ 'aria-labelledby': 'rows-per-page-label',
86
+ style: {
87
+ visibility: 'hidden',
88
+ },
89
+ },
90
+ }}
91
+ nextIconButtonProps={{
92
+ 'aria-label': 'Next page',
93
+ }}
94
+ backIconButtonProps={{
95
+ 'aria-label': 'Previous page',
96
+ }}
97
+ ActionsComponent={() => (
98
+ <div className={classes.actionsContainer}>
99
+ <IconButton
100
+ onClick={(event) => onPageChange(event, page - 1)}
101
+ disabled={page === 0}
102
+ aria-label="Previous page"
103
+ >
104
+ <img src={leftArrow} style={{ opacity: page === 0 ? 0.2 : 1 }} alt="Left Arrow" />
105
+ </IconButton>
106
+ <IconButton
107
+ onClick={(event) => onPageChange(event, page + 1)}
108
+ disabled={page >= Math.ceil(count / rowsPerPage) - 1}
109
+ aria-label="Next page"
110
+ >
111
+ <img src={rightArrow} style={{ opacity: page >= Math.ceil(count / rowsPerPage) - 1 ? 0.2 : 1 }} alt="Right Arrow" />
112
+ </IconButton>
113
+ </div>
114
+ )}
115
+ />
116
+ </ThemeProvider>
117
+ );
118
+ };
62
119
 
63
120
  CustomPagination.propTypes = {
64
121
  rowsPerPageOptions: PropTypes.arrayOf(PropTypes.number).isRequired,