@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
@@ -25,7 +25,8 @@ const ActionHeaderCell = _ref => {
25
25
  return /*#__PURE__*/_react.default.createElement(_CheckBoxView.default, {
26
26
  includeSelectedIds: includeSelectedIds,
27
27
  toggleSelectAll: toggleSelectAll,
28
- Ids: Ids
28
+ Ids: Ids,
29
+ rows: rows
29
30
  });
30
31
  }
31
32
  if (_Types.cellTypes.DELETE === cellType) {
@@ -22,13 +22,15 @@ const CustomHeaderCell = _ref => {
22
22
  sortBy,
23
23
  column,
24
24
  components = {},
25
- toggleSort
25
+ toggleSort,
26
+ style
26
27
  } = _ref;
27
28
  const {
28
29
  dataField,
29
30
  tooltipText,
30
31
  header,
31
32
  headerType,
33
+ sortField,
32
34
  customColHeaderRender,
33
35
  sortable
34
36
  } = column;
@@ -59,11 +61,12 @@ const CustomHeaderCell = _ref => {
59
61
  return /*#__PURE__*/_react.default.createElement(_TableCell.default, {
60
62
  scope: "col",
61
63
  active: sortBy === dataField,
62
- direction: sortOrder
64
+ direction: sortOrder,
65
+ style: style
63
66
  }, /*#__PURE__*/_react.default.createElement(Tooltip, null, /*#__PURE__*/_react.default.createElement(_TableSortLabel.default, {
64
- active: sortBy === dataField,
65
- hideSortIcon: sortBy !== dataField,
66
- direction: sortBy === dataField ? sortOrder : 'asc',
67
+ active: sortBy === (sortField ? sortField : dataField),
68
+ hideSortIcon: sortBy !== (sortField ? sortField : dataField),
69
+ direction: sortBy === (sortField ? sortField : dataField) ? sortOrder : 'asc',
67
70
  onClick: toggleSort
68
71
  }, headerType === _Types.headerTypes.CUSTOM_ELEM && customColHeaderRender ? customColHeaderRender(column) : header)));
69
72
  };
@@ -66,7 +66,9 @@ const CustomTableHeader = _ref => {
66
66
  column: column,
67
67
  sortBy: sortBy,
68
68
  sortOrder: sortOrder,
69
- toggleSort: () => sortByColumn(column.dataField, sortOrder)
69
+ toggleSort: () => {
70
+ sortByColumn(column.sortField ? column.sortField : column.dataField, sortOrder);
71
+ }
70
72
  });
71
73
  }))));
72
74
  };
@@ -17,7 +17,8 @@ const CheckboxView = _ref => {
17
17
  let {
18
18
  includeSelectedIds,
19
19
  toggleSelectAll,
20
- Ids
20
+ Ids,
21
+ rows
21
22
  } = _ref;
22
23
  return /*#__PURE__*/_react.default.createElement(_core.TableCell, {
23
24
  padding: "checkbox"
@@ -29,7 +30,7 @@ const CheckboxView = _ref => {
29
30
  color: "primary",
30
31
  indeterminate: includeSelectedIds,
31
32
  checked: includeSelectedIds,
32
- onChange: event => toggleSelectAll(event, Ids, includeSelectedIds)
33
+ onChange: event => toggleSelectAll(event, Ids, includeSelectedIds, rows)
33
34
  })));
34
35
  };
35
36
  var _default = CheckboxView;
@@ -7,38 +7,58 @@ exports.default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _core = require("@material-ui/core");
10
- var _KeyboardArrowDownOutlined = _interopRequireDefault(require("@material-ui/icons/KeyboardArrowDownOutlined"));
10
+ var _icons = require("@material-ui/icons");
11
+ var _rightArrow = _interopRequireDefault(require("../assets/rightArrow.svg"));
12
+ var _leftArrow = _interopRequireDefault(require("../assets/leftArrow.svg"));
11
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
14
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
15
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14
16
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
17
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
16
18
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
17
- const defaultTheme = {
18
- MuiTablePagination: {
19
- root: {
20
- paddingRight: '50px',
21
- borderTop: '3px solid #42779a'
22
- },
23
- toolbar: {
24
- minHeight: '45px'
25
- }
19
+ const useStyles = (0, _core.makeStyles)(() => ({
20
+ paginationRoot: {
21
+ display: 'flex',
22
+ justifyContent: 'flex-end',
23
+ // Moves pagination to the right
24
+ paddingRight: '10px' // Optional spacing
26
25
  },
27
- MuiTypography: {
28
- body2: {
29
- fontSize: '14px',
30
- textTransform: 'uppercase'
26
+
27
+ actionsContainer: {
28
+ display: 'flex',
29
+ justifyContent: 'flex-end' // Align pagination buttons to the right
30
+ }
31
+ }));
32
+
33
+ const defaultTheme = (0, _core.createMuiTheme)({
34
+ overrides: {
35
+ MuiTablePagination: {
36
+ root: {
37
+ paddingRight: '50px',
38
+ width: '100%'
39
+ },
40
+ toolbar: {
41
+ minHeight: '45px',
42
+ display: 'flex',
43
+ alignItems: 'center'
44
+ }
31
45
  },
32
- root: {
33
- fontSize: '14px'
34
- }
35
- },
36
- MuiIconButton: {
37
- root: {
38
- padding: '2px'
46
+ MuiTypography: {
47
+ body2: {
48
+ fontSize: '14px',
49
+ textTransform: 'uppercase'
50
+ },
51
+ root: {
52
+ fontSize: '14px'
53
+ }
54
+ },
55
+ MuiIconButton: {
56
+ root: {
57
+ padding: '2px'
58
+ }
39
59
  }
40
60
  }
41
- };
61
+ });
42
62
  const CustomPagination = _ref => {
43
63
  let {
44
64
  rowsPerPageOptions,
@@ -49,12 +69,15 @@ const CustomPagination = _ref => {
49
69
  onRowsPerPageChange,
50
70
  customTheme = {}
51
71
  } = _ref;
72
+ const classes = useStyles();
52
73
  return /*#__PURE__*/_react.default.createElement(_core.ThemeProvider, {
53
- theme: (0, _core.createTheme)({
54
- overrides: _objectSpread(_objectSpread({}, defaultTheme), customTheme)
74
+ theme: (0, _core.createMuiTheme)({
75
+ overrides: _objectSpread(_objectSpread({}, defaultTheme.overrides), customTheme)
55
76
  })
56
77
  }, /*#__PURE__*/_react.default.createElement(_core.TablePagination, {
57
- labelRowsPerPage: "Results per Page:",
78
+ labelRowsPerPage: /*#__PURE__*/_react.default.createElement("span", {
79
+ id: "rows-per-page-label"
80
+ }, "Rows per page:"),
58
81
  rowsPerPageOptions: rowsPerPageOptions,
59
82
  component: "div",
60
83
  count: count,
@@ -63,11 +86,44 @@ const CustomPagination = _ref => {
63
86
  onPageChange: onPageChange,
64
87
  onRowsPerPageChange: onRowsPerPageChange,
65
88
  SelectProps: {
66
- IconComponent: _KeyboardArrowDownOutlined.default,
89
+ IconComponent: _icons.ArrowDropDown,
67
90
  inputProps: {
68
- 'aria-label': 'Selection dropdown for displaying the number of results per page'
91
+ 'aria-label': 'Selection dropdown for displaying the number of results per page',
92
+ 'aria-labelledby': 'rows-per-page-label',
93
+ style: {
94
+ visibility: 'hidden'
95
+ }
69
96
  }
70
- }
97
+ },
98
+ nextIconButtonProps: {
99
+ 'aria-label': 'Next page'
100
+ },
101
+ backIconButtonProps: {
102
+ 'aria-label': 'Previous page'
103
+ },
104
+ ActionsComponent: () => /*#__PURE__*/_react.default.createElement("div", {
105
+ className: classes.actionsContainer
106
+ }, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
107
+ onClick: event => onPageChange(event, page - 1),
108
+ disabled: page === 0,
109
+ "aria-label": "Previous page"
110
+ }, /*#__PURE__*/_react.default.createElement("img", {
111
+ src: _leftArrow.default,
112
+ style: {
113
+ opacity: page === 0 ? 0.2 : 1
114
+ },
115
+ alt: "Left Arrow"
116
+ })), /*#__PURE__*/_react.default.createElement(_core.IconButton, {
117
+ onClick: event => onPageChange(event, page + 1),
118
+ disabled: page >= Math.ceil(count / rowsPerPage) - 1,
119
+ "aria-label": "Next page"
120
+ }, /*#__PURE__*/_react.default.createElement("img", {
121
+ src: _rightArrow.default,
122
+ style: {
123
+ opacity: page >= Math.ceil(count / rowsPerPage) - 1 ? 0.2 : 1
124
+ },
125
+ alt: "Right Arrow"
126
+ })))
71
127
  }));
72
128
  };
73
129
  CustomPagination.propTypes = {
@@ -7,8 +7,10 @@ exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _client = require("@apollo/client");
9
9
  var _core = require("@material-ui/core");
10
+ var _KeyboardArrowDownOutlined = _interopRequireDefault(require("@material-ui/icons/KeyboardArrowDownOutlined"));
10
11
  var _icons = require("@material-ui/icons");
11
12
  var _downloadTable = require("../util/downloadTable");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
14
  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); }
13
15
  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; }
14
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -16,83 +18,284 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
16
18
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
19
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
20
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
19
- const downloadButtonStyle = {
20
- color: '#d1d2d3',
21
- marginTop: '7px'
22
- };
21
+ // const downloadButtonStyle = {
22
+ // color: '#d1d2d3',
23
+ // marginTop: '7px',
24
+ // };
23
25
 
24
- // Default style for Download Button with Text.
25
- const DEFAULT_BUTTON_STYLE = {
26
- width: '223px',
27
- height: '41px',
28
- borderRadius: '5px',
29
- backgroundColor: '#2A6E93',
30
- color: '#fff',
31
- marginTop: '10px',
32
- fontFamily: 'poppins',
33
- '& #cloudIcon': {
34
- margin: '10px',
35
- marginTop: '6px'
36
- }
37
- };
38
26
  const DownloadButton = _ref => {
39
27
  let {
40
28
  count,
41
29
  queryVariables,
42
30
  table,
43
- buttonConfig = {},
44
- isIcon = false
31
+ buttonConfig
45
32
  } = _ref;
33
+ const [listDisplay, setListDisplay] = (0, _react.useState)('none');
34
+ const [isDownloading, setIsDownloading] = (0, _react.useState)(false);
35
+ const dropdownSelection = (0, _react.useRef)(null);
36
+ const useOutsideAlerter = ref => {
37
+ (0, _react.useEffect)(() => {
38
+ function handleClickOutside(event) {
39
+ if (!(event.target.getAttribute('id') && event.target.getAttribute('id').includes('dropdownListItem'))) {
40
+ setListDisplay('none');
41
+ }
42
+ }
43
+ document.addEventListener('mousedown', handleClickOutside);
44
+ return () => {
45
+ document.removeEventListener('mousedown', handleClickOutside);
46
+ };
47
+ }, [ref]);
48
+ };
49
+ useOutsideAlerter(dropdownSelection);
46
50
  if (table.paginationAPIField === 'filesInList') {
47
51
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
48
52
  }
49
- if (count === 0) {
50
- return /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, {
51
- className: "disableButton",
52
- style: downloadButtonStyle
53
+ const client = (0, _client.useApolloClient)();
54
+ const downloadLimit = buttonConfig === null || buttonConfig === void 0 ? void 0 : buttonConfig.downloadLimit;
55
+ function cleanData(result) {
56
+ function hasHTMLTags(str) {
57
+ const htmlTagPattern = /<\/?[a-z][\s\S]*>/i; // Regex to match HTML tags
58
+ return htmlTagPattern.test(str);
59
+ }
60
+ const cleanedResult = result.map(res => {
61
+ const newObj = {};
62
+ Object.keys(res).forEach(key => {
63
+ if (hasHTMLTags(res[key])) {
64
+ const div = document.createElement('div');
65
+ div.innerHTML = res[key];
66
+ newObj[key] = div.textContent || div.innerText || res[key];
67
+ } else {
68
+ newObj[key] = res[key];
69
+ }
70
+ });
71
+ return newObj;
53
72
  });
73
+ return cleanedResult;
54
74
  }
55
- const client = (0, _client.useApolloClient)();
56
- async function downloadSCSVFile() {
75
+
76
+ // --- retry helper (recursive ESLINT no await-in-loop — we want this to be sequential) ---
77
+ async function retry(fn) {
78
+ let retries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
79
+ let attempt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
80
+ try {
81
+ return await fn();
82
+ } catch (err) {
83
+ if (attempt >= retries) throw err;
84
+ return retry(fn, retries, attempt + 1);
85
+ }
86
+ }
87
+ async function fetchCountWithRetry() {
88
+ const {
89
+ statsQuery,
90
+ statsQueryName,
91
+ statsField
92
+ } = table;
93
+ return retry(() => client.query({
94
+ query: statsQuery,
95
+ variables: queryVariables
96
+ }).then(_ref2 => {
97
+ let {
98
+ data
99
+ } = _ref2;
100
+ const queryResponse = data[statsQueryName];
101
+ return {
102
+ totalCount: queryResponse[statsField],
103
+ pageSize: downloadLimit || queryResponse.pageSize || 5000
104
+ };
105
+ }));
106
+ }
107
+ async function fetchDownloadWithRetry(variables) {
57
108
  const {
58
109
  query,
59
110
  paginationAPIField
60
111
  } = table;
61
- const result = await client.query({
112
+ return retry(() => client.query({
62
113
  query,
63
- variables: _objectSpread(_objectSpread({}, queryVariables), {}, {
64
- page: 0,
65
- first: 10000
66
- })
114
+ variables
67
115
  }).then(response => {
68
116
  if (paginationAPIField && response && response.data) {
69
117
  return response.data[paginationAPIField];
70
118
  }
71
119
  return response.data;
72
- });
73
- (0, _downloadTable.downloadJson)(result, table, table.downloadFileName);
120
+ }));
121
+ }
122
+ async function downloadFile(type) {
123
+ setIsDownloading(true);
124
+ try {
125
+ const {
126
+ totalCount,
127
+ pageSize
128
+ } = await fetchCountWithRetry();
129
+ let completedEntries = 0;
130
+ let allData = [];
131
+ while (completedEntries < totalCount) {
132
+ const variables = _objectSpread(_objectSpread({}, queryVariables), {}, {
133
+ offset: Math.floor(completedEntries / pageSize) * pageSize,
134
+ first: Math.min(pageSize, totalCount - completedEntries),
135
+ order_by: table.sortBy,
136
+ sort_direction: table.sortOrder
137
+ });
138
+ // eslint-disable-next-line no-await-in-loop
139
+ const data = await fetchDownloadWithRetry(variables);
140
+ allData = allData.concat(data);
141
+ completedEntries += data.length;
142
+ }
143
+ (0, _downloadTable.downloadData)(cleanData(allData), table, table.downloadFileName, type);
144
+ } catch (error) {
145
+ console.error('Error fetching count:', error);
146
+ } finally {
147
+ setIsDownloading(false);
148
+ }
149
+ }
150
+ async function downloadFileParallel(type) {
151
+ let concurrency = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
152
+ setIsDownloading(true);
153
+ try {
154
+ const {
155
+ totalCount,
156
+ pageSize
157
+ } = await fetchCountWithRetry();
158
+ const totalChunks = Math.ceil(totalCount / pageSize);
159
+ const results = new Array(totalChunks);
160
+ for (let i = 0; i < totalChunks; i += concurrency) {
161
+ const batch = [];
162
+ for (let j = i; j < Math.min(i + concurrency, totalChunks); j += 1) {
163
+ const offset = j * pageSize;
164
+ const first = Math.min(pageSize, totalCount - offset);
165
+ const variables = _objectSpread(_objectSpread({}, queryVariables), {}, {
166
+ offset,
167
+ first,
168
+ order_by: table.sortBy,
169
+ sort_direction: table.sortOrder
170
+ });
171
+ batch.push(fetchDownloadWithRetry(variables).then(data => ({
172
+ index: j,
173
+ data
174
+ })));
175
+ }
176
+
177
+ // eslint-disable-next-line no-await-in-loop
178
+ const batchResults = await Promise.all(batch);
179
+ batchResults.forEach(_ref3 => {
180
+ let {
181
+ index,
182
+ data
183
+ } = _ref3;
184
+ results[index] = data;
185
+ });
186
+ }
187
+ const allData = results.flat();
188
+ (0, _downloadTable.downloadData)(cleanData(allData), table, table.downloadFileName, type);
189
+ } catch (error) {
190
+ console.error('Error fetching count:', error);
191
+ } finally {
192
+ setIsDownloading(false);
193
+ }
74
194
  }
75
195
  const downloadTableCSV = (0, _react.useCallback)(() => {
76
- downloadSCSVFile();
77
- }, [queryVariables]);
78
- const {
79
- buttonStyle,
80
- title = 'DOWNLOAD CSV',
81
- cloudIcon = false
82
- } = buttonConfig;
83
- return isIcon ? /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
84
- title: "Download filtered results as a CSV"
85
- }, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
86
- onClick: downloadTableCSV
87
- }, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Button, {
88
- onClick: downloadTableCSV,
89
- style: buttonStyle || DEFAULT_BUTTON_STYLE,
90
- disableRipple: true
91
- }, title, ' ', cloudIcon ? /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, {
196
+ if (isDownloading) return;
197
+ if (table.asyncDownload) {
198
+ downloadFileParallel('csv');
199
+ } else {
200
+ downloadFile('csv');
201
+ }
202
+ setListDisplay('none');
203
+ }, [queryVariables, table, isDownloading]);
204
+ const downloadTableJson = (0, _react.useCallback)(() => {
205
+ if (isDownloading) return;
206
+ if (table.asyncDownload) {
207
+ downloadFileParallel('json');
208
+ } else {
209
+ downloadFile('json');
210
+ }
211
+ setListDisplay('none');
212
+ }, [queryVariables, table, isDownloading]);
213
+ const handleClickButton = () => {
214
+ if (isDownloading) return;
215
+ if (listDisplay === 'none') {
216
+ setListDisplay('block');
217
+ } else {
218
+ setListDisplay('none');
219
+ }
220
+ };
221
+ const useStyles = (0, _core.makeStyles)({
222
+ dropdown: {
223
+ width: '60px',
224
+ height: '25px',
225
+ marginTop: '8px',
226
+ paddingLeft: '5px',
227
+ border: '0.75px solid #606060',
228
+ borderRadius: '5px',
229
+ display: 'inline-block',
230
+ position: 'relative',
231
+ alignSelf: 'center'
232
+ },
233
+ dropdownList: {
234
+ display: 'block',
235
+ position: 'absolute',
236
+ width: '60px',
237
+ marginTop: '3px',
238
+ marginLeft: '-5px',
239
+ overflow: 'auto',
240
+ zIndex: '20',
241
+ border: '1.5px solid #41545E',
242
+ borderRadius: '5px',
243
+ background: '#ffffff'
244
+ },
245
+ dropdownListItem: {
246
+ padding: '2px 4px',
247
+ font: 'Poppins',
248
+ fontSize: '14px',
249
+ fontWeight: 400,
250
+ lineHeight: '21px',
251
+ '&:hover': {
252
+ background: '#D7D7D7',
253
+ cursor: 'pointer'
254
+ }
255
+ },
256
+ arrowdownIcon: {
257
+ marginLeft: '5px',
258
+ fill: '#606060'
259
+ },
260
+ arrowdownIconDisabled: {
261
+ marginLeft: '5px',
262
+ fill: '#00000042'
263
+ }
264
+ });
265
+ const classes = useStyles();
266
+ return /*#__PURE__*/_react.default.createElement("div", {
267
+ className: classes.dropdown,
268
+ style: isDownloading ? {
269
+ cursor: 'wait'
270
+ } : {}
271
+ }, /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
272
+ title: isDownloading ? 'Download in progress...' : table.downloadButtonTooltipText || 'Download filtered results'
273
+ }, count !== 0 ? /*#__PURE__*/_react.default.createElement(_core.IconButton, {
274
+ onClick: handleClickButton,
275
+ style: {
276
+ padding: '0'
277
+ },
278
+ disabled: isDownloading
279
+ }, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null), /*#__PURE__*/_react.default.createElement(_KeyboardArrowDownOutlined.default, {
280
+ className: classes.arrowdownIcon
281
+ })) : /*#__PURE__*/_react.default.createElement(_core.IconButton, {
282
+ disabled: true
283
+ }, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null), /*#__PURE__*/_react.default.createElement(_KeyboardArrowDownOutlined.default, {
284
+ className: classes.arrowdownIconDisabled
285
+ }))), /*#__PURE__*/_react.default.createElement("div", {
286
+ className: classes.dropdownList,
92
287
  style: {
93
- margin: '6px 0px 10px 10px'
288
+ display: listDisplay
94
289
  }
95
- }) : ''));
290
+ }, /*#__PURE__*/_react.default.createElement("div", {
291
+ id: "dropdownListItemCSV",
292
+ className: classes.dropdownListItem,
293
+ onClick: downloadTableCSV
294
+ }, "CSV"), /*#__PURE__*/_react.default.createElement("div", {
295
+ id: "dropdownListItemJSON",
296
+ className: classes.dropdownListItem,
297
+ onClick: downloadTableJson
298
+ }, "JSON")));
96
299
  };
97
300
  var _default = DownloadButton;
98
301
  exports.default = _default;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.headerTypes = exports.dataFormatTypes = exports.cellTypes = exports.cellStyles = exports.actionCellTypes = exports.TRANSFORM = exports.LINK = exports.FORMAT_DATA_CELLS = exports.FORMAT_DATA = exports.FORMAT_BYTES = exports.EXPAND = exports.DISPLAY = exports.DELETE = exports.DEFAULT = exports.ComponentTypes = exports.CUSTOM_ELEM = exports.CHECKBOX = void 0;
6
+ exports.headerTypes = exports.dataFormatTypes = exports.cellTypes = exports.cellStyles = exports.actionCellTypes = exports.TRANSFORM = exports.LINK = exports.FORMAT_DATA_CELLS = exports.FORMAT_DATA = exports.FORMAT_BYTES = exports.EXPAND = exports.DISPLAY = exports.DELETE = exports.DEFAULT = exports.ComponentTypes = exports.CUSTOM_ELEM = exports.CPI = exports.COMMA = exports.CHECKBOX = void 0;
7
7
  const CHECKBOX = 'CHECKBOX';
8
8
  exports.CHECKBOX = CHECKBOX;
9
9
  const DELETE = 'DELETE';
@@ -24,6 +24,10 @@ const TRANSFORM = 'TRANSFORM';
24
24
  exports.TRANSFORM = TRANSFORM;
25
25
  const EXPAND = 'EXPAND';
26
26
  exports.EXPAND = EXPAND;
27
+ const COMMA = 'COMMA';
28
+ exports.COMMA = COMMA;
29
+ const CPI = 'CPI';
30
+ exports.CPI = CPI;
27
31
  const cellTypes = {
28
32
  CUSTOM_ELEM,
29
33
  LINK,
@@ -31,7 +35,9 @@ const cellTypes = {
31
35
  CHECKBOX,
32
36
  DELETE,
33
37
  DEFAULT,
34
- FORMAT_DATA
38
+ FORMAT_DATA,
39
+ COMMA,
40
+ CPI
35
41
  };
36
42
  exports.cellTypes = cellTypes;
37
43
  const cellStyles = {