@bento-core/table 1.0.1-ccdihub.6 → 1.0.1-ccdihub.61

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/table",
3
- "version": "1.0.1-ccdihub.6",
3
+ "version": "1.0.1-ccdihub.61",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
@@ -28,5 +28,8 @@
28
28
  "url": "https://github.com/CBIIT/bento-frontend/issues"
29
29
  },
30
30
  "homepage": "https://github.com/CBIIT/bento-frontend#readme",
31
+ "dependencies": {
32
+ "@apollo/client": "^3.8.3"
33
+ },
31
34
  "description": ""
32
35
  }
@@ -9,6 +9,12 @@ import ManageColumnView from './toolbar/ManageColumnView';
9
9
  import defaultTheme from './DefaultThemConfig';
10
10
  import DownloadButton from './toolbar/DownloadButtonView';
11
11
 
12
+ const downloadAreaStyle = {
13
+ display: 'flex',
14
+ borderTop: '1px solid #8A7F7C',
15
+ paddingRight: '41px',
16
+ };
17
+
12
18
  const ExtendedView = ({
13
19
  table,
14
20
  onColumnViewChange,
@@ -16,6 +22,7 @@ const ExtendedView = ({
16
22
  onPageChange,
17
23
  numSelected = 0,
18
24
  customTheme,
25
+ queryVariables,
19
26
  }) => {
20
27
  const { extendedViewConfig } = table;
21
28
  if (!extendedViewConfig) {
@@ -32,9 +39,9 @@ const ExtendedView = ({
32
39
  <ThemeProvider theme={themeConfig}>
33
40
  {(numSelected === 0 && (download || manageViewColumns)) && (
34
41
  <Toolbar className="downloadColumnView">
35
- <DownloadButton
42
+ {/* <DownloadButton
36
43
  download={download}
37
- />
44
+ /> */}
38
45
  <ManageColumnView
39
46
  table={table}
40
47
  manageViewColumns={manageViewColumns}
@@ -44,16 +51,25 @@ const ExtendedView = ({
44
51
  )}
45
52
  {
46
53
  (pagination) && (
47
- <CustomPagination
48
- customTheme={customTheme.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
- />
54
+ <div className="downloadArea" style={downloadAreaStyle}>
55
+ <CustomPagination
56
+ customTheme={customTheme.tblTopPgn}
57
+ rowsPerPageOptions={[10, 25, 50, 100]}
58
+ component="div"
59
+ count={table.totalRowCount || 0}
60
+ rowsPerPage={table.rowsPerPage || 10}
61
+ page={table.page || 0}
62
+ onPageChange={onPageChange}
63
+ onRowsPerPageChange={onRowsPerPageChange}
64
+ queryVariables={queryVariables}
65
+ table={table}
66
+ />
67
+ <DownloadButton
68
+ count={table.totalRowCount || 0}
69
+ queryVariables={queryVariables}
70
+ table={table}
71
+ />
72
+ </div>
57
73
  )
58
74
  }
59
75
  </ThemeProvider>
package/src/TableView.js CHANGED
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useEffect } from 'react';
2
2
  import {
3
3
  Paper,
4
4
  Table,
@@ -12,19 +12,45 @@ import CustomTableBody from './body/CustomTblBody';
12
12
  import CustomToolbar from './toolbar/CustomToolbar';
13
13
  import DisplayErrMsg from './errMsg/DisplayErrMsg';
14
14
  import ExtendedView from './ExtendedView';
15
+ import DownloadButton from './toolbar/DownloadButtonView';
15
16
 
16
17
  const CustomTableContainer = (props) => {
17
18
  const { children, customTheme } = props;
18
19
  const themeConfig = createTheme({ overrides: { ...customTheme } });
19
20
  return (
20
21
  <ThemeProvider theme={themeConfig}>
21
- <TableContainer component={Paper}>
22
+ <TableContainer id="tableContainer" component={Paper}>
22
23
  {children}
23
24
  </TableContainer>
24
25
  </ThemeProvider>
25
26
  );
26
27
  };
27
28
 
29
+ const downloadAreaStyle = {
30
+ display: 'flex',
31
+ borderTop: '1px solid #8A7F7C',
32
+ borderBottom: '1px solid #8A7F7C',
33
+ paddingRight: '41px',
34
+ };
35
+
36
+ const cartDownloadAreaStyle = {
37
+ display: 'flex',
38
+ borderTop: '5px solid #e7e5e5',
39
+ borderBottom: '3px solid #e7e5e5',
40
+ paddingRight: '40px',
41
+ };
42
+
43
+ const addScrollContainerStyle = {
44
+ overflowX: 'auto',
45
+ overflowY: 'hidden',
46
+ width: '100%',
47
+ height: '14px',
48
+ };
49
+
50
+ const addScrollStyle = {
51
+ height: '14px',
52
+ };
53
+
28
54
  const TableView = ({
29
55
  tableRows = [],
30
56
  table,
@@ -36,59 +62,91 @@ const TableView = ({
36
62
  onSortByColumn,
37
63
  onColumnViewChange,
38
64
  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}
65
+ queryVariables,
66
+ }) => {
67
+ useEffect(() => {
68
+ const tableContainer = document.getElementById('tableContainer');
69
+ const addScrollContainer = document.getElementById('addScrollContainer');
70
+ const targetTable = tableContainer.firstChild;
71
+ const addScroll = addScrollContainer.firstChild;
72
+ const tableWidth = targetTable.clientWidth;
73
+ addScroll.style.width = `${tableWidth}px`;
74
+ tableContainer.onscroll = () => {
75
+ addScrollContainer.scrollLeft = tableContainer.scrollLeft;
76
+ };
77
+ addScrollContainer.onscroll = () => {
78
+ tableContainer.scrollLeft = addScrollContainer.scrollLeft;
79
+ };
80
+ if (!(tableWidth > tableContainer.clientWidth)) {
81
+ addScrollContainer.style.height = '0px';
82
+ }
83
+ });
84
+
85
+ return (
86
+ <>
87
+ <ExtendedView
88
+ table={table}
89
+ onColumnViewChange={onColumnViewChange}
90
+ onRowsPerPageChange={onRowsPerPageChange}
91
+ onPageChange={onPageChange}
92
+ numSelected={table?.selectedRows?.length || 0}
93
+ customTheme={themeConfig.extendedView}
94
+ queryVariables={queryVariables}
95
+ />
96
+ <CustomToolbar
97
+ numSelected={table?.selectedRows?.length || 0}
98
+ table={table}
99
+ onColumnViewChange={onColumnViewChange}
100
+ customTheme={themeConfig.toolbar}
101
+ />
102
+ <CustomTableContainer
103
+ customTheme={themeConfig.tblContainer || {}}
104
+ >
105
+ <Table>
106
+ <TableHeader
107
+ customTheme={themeConfig.tblHeader}
108
+ table={table}
109
+ rows={tableRows}
110
+ count={totalRowCount}
111
+ toggleSelectAll={onToggleSelectAll}
112
+ sortByColumn={onSortByColumn}
113
+ />
114
+ <CustomTableBody
115
+ customTheme={themeConfig.tblBody}
116
+ rows={tableRows}
117
+ table={table}
118
+ onRowSelectChange={onRowSelectChange}
119
+ />
120
+ </Table>
121
+ </CustomTableContainer>
122
+ <div id="addScrollContainer" style={addScrollContainerStyle}>
123
+ <div style={addScrollStyle} />
124
+ </div>
125
+ {tableRows.length === 0 && (
126
+ <DisplayErrMsg
127
+ customTheme={themeConfig.displayErr}
61
128
  table={table}
62
- rows={tableRows}
63
- count={totalRowCount}
64
- toggleSelectAll={onToggleSelectAll}
65
- sortByColumn={onSortByColumn}
66
129
  />
67
- <CustomTableBody
68
- customTheme={themeConfig.tblBody}
69
- rows={tableRows}
130
+ )}
131
+ <div className="downloadArea" style={table.paginationAPIField === 'filesInList' ? cartDownloadAreaStyle : downloadAreaStyle}>
132
+ <CustomPagination
133
+ customTheme={themeConfig.tblPgn}
134
+ rowsPerPageOptions={[10, 25, 50, 100]}
135
+ component="div"
136
+ count={table.totalRowCount || 0}
137
+ rowsPerPage={table.rowsPerPage || 10}
138
+ page={table.page || 0}
139
+ onPageChange={onPageChange}
140
+ onRowsPerPageChange={onRowsPerPageChange}
141
+ />
142
+ <DownloadButton
143
+ count={table.totalRowCount || 0}
144
+ queryVariables={queryVariables}
70
145
  table={table}
71
- onRowSelectChange={onRowSelectChange}
72
146
  />
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
- );
147
+ </div>
148
+ </>
149
+ );
150
+ };
93
151
 
94
152
  export default TableView;
@@ -46,7 +46,7 @@ const CustomHeaderCell = ({
46
46
  return <>{children}</>;
47
47
  }, []);
48
48
 
49
- if (!sortable) {
49
+ if (sortable !== undefined && !sortable) {
50
50
  return (
51
51
  <TableCell
52
52
  scope="col"
@@ -4,7 +4,7 @@ import {
4
4
  Checkbox,
5
5
  } from '@material-ui/core';
6
6
 
7
- const label = { inputProps: { 'aria-label': 'Checkbox item' } };
7
+ const label = { inputProps: { 'aria-label': 'Select all checkbox' } };
8
8
 
9
9
  const CheckboxView = ({
10
10
  includeSelectedIds,
@@ -12,6 +12,7 @@ const CheckboxView = ({
12
12
  Ids,
13
13
  }) => (
14
14
  <TableCell padding="checkbox">
15
+ <span style={{ display: 'none' }}>Select all</span>
15
16
  <Checkbox
16
17
  {...label}
17
18
  color="primary"
package/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { default as TableView } from './TableView';
2
2
  export {
3
3
  cellTypes,
4
+ cellStyles,
4
5
  headerTypes,
5
6
  ComponentTypes,
6
7
  dataFormatTypes,
@@ -5,6 +5,7 @@ import {
5
5
  TablePagination,
6
6
  ThemeProvider,
7
7
  } from '@material-ui/core';
8
+ import KeyboardArrowDownOutlinedIcon from '@material-ui/icons/KeyboardArrowDownOutlined';
8
9
 
9
10
  const defaultTheme = {
10
11
  MuiTablePagination: {
@@ -43,6 +44,7 @@ const CustomPagination = ({
43
44
  }) => (
44
45
  <ThemeProvider theme={createTheme({ overrides: { ...defaultTheme, ...customTheme } })}>
45
46
  <TablePagination
47
+ labelRowsPerPage="Results per Page:"
46
48
  rowsPerPageOptions={rowsPerPageOptions}
47
49
  component="div"
48
50
  count={count}
@@ -51,8 +53,8 @@ const CustomPagination = ({
51
53
  onPageChange={onPageChange}
52
54
  onRowsPerPageChange={onRowsPerPageChange}
53
55
  SelectProps={{
56
+ IconComponent: KeyboardArrowDownOutlinedIcon,
54
57
  inputProps: { 'aria-label': 'Selection dropdown for displaying the number of results per page' },
55
- native: true,
56
58
  }}
57
59
  />
58
60
  </ThemeProvider>
@@ -1,25 +1,180 @@
1
- import React from 'react';
1
+ import React, {
2
+ useState,
3
+ useEffect,
4
+ useRef,
5
+ useCallback,
6
+ } from 'react';
7
+ import { useApolloClient } from '@apollo/client';
2
8
  import {
3
9
  IconButton,
4
10
  Tooltip,
11
+ makeStyles,
5
12
  } from '@material-ui/core';
13
+ import KeyboardArrowDownOutlinedIcon from '@material-ui/icons/KeyboardArrowDownOutlined';
6
14
  import { CloudDownload } from '@material-ui/icons';
15
+ import { downloadCSV, downloadJson } from '../util/downloadTable';
16
+
17
+ const downloadButtonStyle = {
18
+ color: '#d1d2d3',
19
+ marginTop: '7px',
20
+ };
7
21
 
8
22
  const DownloadButton = ({
9
- download,
23
+ count,
24
+ queryVariables,
25
+ table,
10
26
  }) => {
11
- if (!download) {
12
- return null;
27
+ const [listDisplay, setListDisplay] = useState('none');
28
+ const dropdownSelection = useRef(null);
29
+ const useOutsideAlerter = (ref) => {
30
+ useEffect(() => {
31
+ function handleClickOutside(event) {
32
+ if (!(event.target.getAttribute('id') && event.target.getAttribute('id').includes('dropdownListItem'))) {
33
+ setListDisplay('none');
34
+ }
35
+ }
36
+ document.addEventListener('mousedown', handleClickOutside);
37
+ return () => {
38
+ document.removeEventListener('mousedown', handleClickOutside);
39
+ };
40
+ }, [ref]);
41
+ };
42
+ useOutsideAlerter(dropdownSelection);
43
+
44
+ if (table.paginationAPIField === 'filesInList') {
45
+ return <></>;
46
+ }
47
+ if (count === 0) {
48
+ return <CloudDownload className="disableButton" style={downloadButtonStyle} />;
49
+ }
50
+
51
+ const client = useApolloClient();
52
+
53
+ async function downloadSCSVFile() {
54
+ const {
55
+ query,
56
+ paginationAPIField,
57
+ } = table;
58
+
59
+ const result = await client.query({
60
+ query,
61
+ variables: {
62
+ ...queryVariables,
63
+ page: 0,
64
+ first: 10000,
65
+ order_by: table.sortBy,
66
+ sort_direction: table.sortOrder,
67
+ },
68
+ })
69
+ .then((response) => {
70
+ if (paginationAPIField && response && response.data) {
71
+ return response.data[paginationAPIField];
72
+ }
73
+ return response.data;
74
+ });
75
+ downloadCSV(result, table, table.downloadFileName);
13
76
  }
14
77
 
78
+ async function downloadJsonFile() {
79
+ const {
80
+ query,
81
+ paginationAPIField,
82
+ } = table;
83
+
84
+ const result = await client.query({
85
+ query,
86
+ variables: {
87
+ ...queryVariables,
88
+ page: 0,
89
+ first: 10000,
90
+ order_by: table.sortBy,
91
+ sort_direction: table.sortOrder,
92
+ },
93
+ })
94
+ .then((response) => {
95
+ if (paginationAPIField && response && response.data) {
96
+ return response.data[paginationAPIField];
97
+ }
98
+ return response.data;
99
+ });
100
+ downloadJson(result, table, table.downloadFileName);
101
+ }
102
+
103
+ const downloadTableCSV = useCallback(() => {
104
+ downloadSCSVFile();
105
+ setListDisplay('none');
106
+ }, [queryVariables, table]);
107
+
108
+ const downloadTableJson = useCallback(() => {
109
+ downloadJsonFile();
110
+ setListDisplay('none');
111
+ }, [queryVariables, table]);
112
+
113
+ const handleClickButton = () => {
114
+ if (listDisplay === 'none') {
115
+ setListDisplay('block');
116
+ } else {
117
+ setListDisplay('none');
118
+ }
119
+ };
120
+
121
+ const useStyles = makeStyles({
122
+ dropdown: {
123
+ width: '60px',
124
+ height: '25px',
125
+ marginTop: '8px',
126
+ paddingLeft: '5px',
127
+ border: '0.75px solid #606060',
128
+ borderRadius: '5px',
129
+ display: 'inline-block',
130
+ position: 'relative',
131
+ },
132
+ dropdownList: {
133
+ display: 'block',
134
+ position: 'absolute',
135
+ width: '60px',
136
+ marginTop: '3px',
137
+ marginLeft: '-5px',
138
+ overflow: 'auto',
139
+ zIndex: '5',
140
+ border: '1.5px solid #41545E',
141
+ borderRadius: '5px',
142
+ background: '#ffffff',
143
+ },
144
+ dropdownListItem: {
145
+ padding: '2px 4px',
146
+ font: 'Poppins',
147
+ fontSize: '14px',
148
+ fontWeight: 400,
149
+ lineHeight: '21px',
150
+ '&:hover': {
151
+ background: '#D7D7D7',
152
+ cursor: 'pointer',
153
+ },
154
+ },
155
+ arrowdownIcon: {
156
+ marginLeft: '5px',
157
+ fill: '#606060',
158
+ },
159
+ });
160
+
161
+ const classes = useStyles();
162
+
15
163
  return (
16
- <>
17
- <Tooltip title={download.downloadCsv}>
18
- <IconButton>
164
+ <div className={classes.dropdown}>
165
+ <Tooltip title="Download filtered results">
166
+ <IconButton
167
+ onClick={handleClickButton}
168
+ >
19
169
  <CloudDownload />
170
+ <KeyboardArrowDownOutlinedIcon className={classes.arrowdownIcon} />
20
171
  </IconButton>
21
172
  </Tooltip>
22
- </>
173
+ <div className={classes.dropdownList} style={{ display: listDisplay }}>
174
+ <div id="dropdownListItemCSV" className={classes.dropdownListItem} onClick={downloadTableCSV}>CSV</div>
175
+ <div id="dropdownListItemJSON" className={classes.dropdownListItem} onClick={downloadTableJson}>JSON</div>
176
+ </div>
177
+ </div>
23
178
  );
24
179
  };
25
180
 
@@ -6,3 +6,28 @@ export function formatBytes(bytes, decimals = 2) {
6
6
  const i = Math.floor(Math.log(bytes) / Math.log(1024));
7
7
  return `${parseFloat((bytes / (1024 ** i)).toFixed(dm))} ${sizes[i]}`;
8
8
  }
9
+
10
+ /**
11
+ * convert zero (0) value to custom val
12
+ * @param {*} columns
13
+ * @param {*} data
14
+ * @returns
15
+ */
16
+ export const formatColumnValues = (columns, data) => {
17
+ const formatColumns = columns.filter(({ columnDefaultValues }) => columnDefaultValues);
18
+ if (formatColumns.length > 0) {
19
+ const formatCoumnData = [...data].reduce((acc, item) => {
20
+ const updateRow = { ...item };
21
+ formatColumns.forEach((col) => {
22
+ const { columnDefaultValues, dataField } = col;
23
+ if (columnDefaultValues[item[dataField]]) {
24
+ updateRow[dataField] = columnDefaultValues[item[dataField]];
25
+ }
26
+ });
27
+ acc.push(updateRow);
28
+ return acc;
29
+ }, []);
30
+ return formatCoumnData;
31
+ }
32
+ return data;
33
+ };
package/src/util/Types.js CHANGED
@@ -6,6 +6,8 @@ export const DISPLAY = 'DISPLAY';
6
6
  export const DEFAULT = 'DEFAULT';
7
7
  export const FORMAT_DATA = 'FORMAT_DATA';
8
8
  export const FORMAT_BYTES = 'FORMAT_BYTES';
9
+ export const TRANSFORM = 'TRANSFORM';
10
+ export const EXPAND = 'EXPAND';
9
11
 
10
12
  export const cellTypes = {
11
13
  CUSTOM_ELEM,
@@ -17,6 +19,11 @@ export const cellTypes = {
17
19
  FORMAT_DATA,
18
20
  };
19
21
 
22
+ export const cellStyles = {
23
+ TRANSFORM,
24
+ EXPAND,
25
+ };
26
+
20
27
  export const actionCellTypes = [CHECKBOX, DELETE];
21
28
 
22
29
  export const FORMAT_DATA_CELLS = [FORMAT_BYTES];
@@ -0,0 +1,100 @@
1
+ import { formatBytes, formatColumnValues } from './Dataformat';
2
+ import { actionCellTypes } from './Types';
3
+
4
+ export function createFileName(fileName, type) {
5
+ const date = new Date();
6
+ const yyyy = date.getFullYear();
7
+ let dd = date.getDate();
8
+ let mm = (date.getMonth() + 1);
9
+
10
+ if (dd < 10) { dd = `0${dd}`; }
11
+
12
+ if (mm < 10) { mm = `0${mm}`; }
13
+
14
+ const todaysDate = `${yyyy}-${mm}-${dd}`;
15
+
16
+ let hours = date.getHours();
17
+ let minutes = date.getMinutes();
18
+ let seconds = date.getSeconds();
19
+
20
+ if (hours < 10) { hours = `0${hours}`; }
21
+
22
+ if (minutes < 10) { minutes = `0${minutes}`; }
23
+
24
+ if (seconds < 10) { seconds = `0${seconds}`; }
25
+
26
+ if (type === 'csv') {
27
+ return `${fileName} ${todaysDate} ${hours}-${minutes}-${seconds}${'.csv'}`;
28
+ }
29
+ return `${fileName} ${todaysDate} ${hours}-${minutes}-${seconds}${'.json'}`;
30
+ }
31
+
32
+ export function convertToCSV(jsonse, keysToInclude, header) {
33
+ const objArray = jsonse;
34
+ // To Do empty object just print headers
35
+ const array = typeof objArray !== 'object' ? JSON.parse(objArray) : objArray;
36
+ let str = header.join(',');
37
+ array.map((entry, index) => {
38
+ let line = '';
39
+ keysToInclude.map((keyName) => {
40
+ if (line !== '') line += ',';
41
+ if (keyName === 'file_size') {
42
+ line += entry[keyName] !== null ? `"${formatBytes(entry[keyName])}"` : ' ';
43
+ } else if (keyName === 'age_at_diagnosis' || keyName === 'participant_age_at_collection') {
44
+ if (entry[keyName] === -999) {
45
+ line += 'Not Reported';
46
+ } else {
47
+ line += entry[keyName] !== null ? `"${entry[keyName]}"` : ' ';
48
+ }
49
+ } else {
50
+ line += entry[keyName] !== null ? `"${entry[keyName]}"` : ' ';
51
+ }
52
+ return line;
53
+ });
54
+ if (index === 0) {
55
+ // str = header.join(',');
56
+ str += `\r\n${line}\r\n`;
57
+ } else {
58
+ str += `${line}\r\n`;
59
+ }
60
+ return str;
61
+ });
62
+ return str;
63
+ }
64
+
65
+ export function downloadCSV(tableData, table, downloadFileName) {
66
+ const { columns = [] } = table;
67
+ const filterColumns = columns.filter(({ cellType }) => !actionCellTypes.includes(cellType));
68
+ const formatDataVal = formatColumnValues(filterColumns, tableData);
69
+ const jsonse = JSON.stringify(formatDataVal);
70
+ const keysToInclude = columns.filter(({ dataField }) => dataField)
71
+ .map(({ dataField }) => dataField);
72
+ const headers = columns.filter(({ dataField }) => dataField)
73
+ .map(({ header, downloadHeader }) => (downloadHeader || header));
74
+ const csv = convertToCSV(jsonse, keysToInclude, headers);
75
+ const exportData = new Blob([csv], { type: 'text/csv' });
76
+ const JsonURL = window.URL.createObjectURL(exportData);
77
+ let tempLink = '';
78
+ tempLink = document.createElement('a');
79
+ tempLink.setAttribute('href', JsonURL);
80
+ tempLink.setAttribute('download', createFileName(downloadFileName || '', 'csv'));
81
+ document.body.appendChild(tempLink);
82
+ tempLink.click();
83
+ document.body.removeChild(tempLink);
84
+ }
85
+
86
+ export function downloadJson(tableData, table, downloadFileName) {
87
+ const { columns = [] } = table;
88
+ const filterColumns = columns.filter(({ cellType }) => !actionCellTypes.includes(cellType));
89
+ const formatDataVal = formatColumnValues(filterColumns, tableData);
90
+ const jsonse = JSON.stringify(formatDataVal);
91
+ const exportData = new Blob([jsonse], { type: 'application/json' });
92
+ const JsonURL = window.URL.createObjectURL(exportData);
93
+ let tempLink = '';
94
+ tempLink = document.createElement('a');
95
+ tempLink.setAttribute('href', JsonURL);
96
+ tempLink.setAttribute('download', createFileName(downloadFileName || '', 'json'));
97
+ document.body.appendChild(tempLink);
98
+ tempLink.click();
99
+ document.body.removeChild(tempLink);
100
+ }