@bento-core/table 1.0.0-c3dc.2 → 1.0.0-c3dc.20
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/dist/ExtendedView.js +9 -11
- package/dist/TableView.js +5 -5
- package/dist/assets/downArrow.svg +3 -0
- package/dist/assets/leftArrow.svg +3 -0
- package/dist/assets/rightArrow.svg +3 -0
- package/dist/body/DisplayBodyCell.js +5 -0
- package/dist/body/components/CustomLinkView.js +1 -1
- package/dist/header/ActionHeaderCell.js +2 -1
- package/dist/header/components/CheckBoxView.js +3 -2
- package/dist/pagination/CustomPagination.js +76 -26
- package/dist/toolbar/DownloadButtonView.js +152 -45
- package/dist/util/Types.js +5 -2
- package/dist/util/downloadTable.js +60 -37
- package/package.json +1 -1
- package/src/ExtendedView.js +34 -33
- package/src/TableView.js +11 -8
- package/src/assets/downArrow.svg +3 -0
- package/src/assets/leftArrow.svg +3 -0
- package/src/assets/rightArrow.svg +3 -0
- package/src/body/DisplayBodyCell.js +11 -0
- package/src/body/components/CustomLinkView.js +1 -1
- package/src/header/ActionHeaderCell.js +1 -0
- package/src/header/components/CheckBoxView.js +2 -1
- package/src/pagination/CustomPagination.js +91 -40
- package/src/toolbar/DownloadButtonView.js +168 -55
- package/src/util/Types.js +2 -0
- package/src/util/downloadTable.js +41 -17
package/dist/ExtendedView.js
CHANGED
|
@@ -48,21 +48,14 @@ const ExtendedView = _ref => {
|
|
|
48
48
|
});
|
|
49
49
|
return /*#__PURE__*/_react.default.createElement(_core.ThemeProvider, {
|
|
50
50
|
theme: themeConfig
|
|
51
|
-
}, numSelected === 0 && (download || manageViewColumns) && /*#__PURE__*/_react.default.createElement(
|
|
52
|
-
className: "downloadColumnView"
|
|
53
|
-
}, /*#__PURE__*/_react.default.createElement(_DownloadButtonView.default, {
|
|
54
|
-
count: table.totalRowCount || 0,
|
|
55
|
-
queryVariables: queryVariables,
|
|
56
|
-
table: table,
|
|
57
|
-
buttonConfig: downloadButtonConfig
|
|
58
|
-
}), /*#__PURE__*/_react.default.createElement(_ManageColumnView.default, {
|
|
51
|
+
}, numSelected === 0 && (download || manageViewColumns) && /*#__PURE__*/_react.default.createElement(_ManageColumnView.default, {
|
|
59
52
|
table: table,
|
|
60
53
|
manageViewColumns: manageViewColumns,
|
|
61
54
|
onColumnViewChange: onColumnViewChange
|
|
62
|
-
})
|
|
55
|
+
}), pagination && /*#__PURE__*/_react.default.createElement("div", {
|
|
63
56
|
className: "downloadArea",
|
|
64
|
-
style: downloadAreaStyle
|
|
65
|
-
}, /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
|
|
57
|
+
style: table.paginationCustomStyle && table.paginationCustomStyle.topPagination ? table.paginationCustomStyle.topPagination : downloadAreaStyle
|
|
58
|
+
}, table.showSearchBox && /*#__PURE__*/_react.default.createElement(table.SearchBox, null), /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
|
|
66
59
|
customTheme: customTheme.tblTopPgn,
|
|
67
60
|
rowsPerPageOptions: [10, 25, 50, 100],
|
|
68
61
|
component: "div",
|
|
@@ -73,6 +66,11 @@ const ExtendedView = _ref => {
|
|
|
73
66
|
onRowsPerPageChange: onRowsPerPageChange,
|
|
74
67
|
queryVariables: queryVariables,
|
|
75
68
|
table: table
|
|
69
|
+
}), table.showDownloadIcon !== false && /*#__PURE__*/_react.default.createElement(_DownloadButtonView.default, {
|
|
70
|
+
count: table.totalRowCount || 0,
|
|
71
|
+
queryVariables: queryVariables,
|
|
72
|
+
table: table,
|
|
73
|
+
buttonConfig: downloadButtonConfig
|
|
76
74
|
})));
|
|
77
75
|
};
|
|
78
76
|
var _default = ExtendedView;
|
package/dist/TableView.js
CHANGED
|
@@ -10,9 +10,9 @@ var _CustomTblHeader = _interopRequireDefault(require("./header/CustomTblHeader"
|
|
|
10
10
|
var _CustomPagination = _interopRequireDefault(require("./pagination/CustomPagination"));
|
|
11
11
|
var _CustomTblBody = _interopRequireDefault(require("./body/CustomTblBody"));
|
|
12
12
|
var _CustomToolbar = _interopRequireDefault(require("./toolbar/CustomToolbar"));
|
|
13
|
+
var _DownloadButtonView = _interopRequireDefault(require("./toolbar/DownloadButtonView"));
|
|
13
14
|
var _DisplayErrMsg = _interopRequireDefault(require("./errMsg/DisplayErrMsg"));
|
|
14
15
|
var _ExtendedView = _interopRequireDefault(require("./ExtendedView"));
|
|
15
|
-
var _DownloadButtonView = _interopRequireDefault(require("./toolbar/DownloadButtonView"));
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
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; }
|
|
18
18
|
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; }
|
|
@@ -36,7 +36,6 @@ const CustomTableContainer = props => {
|
|
|
36
36
|
const downloadAreaStyle = {
|
|
37
37
|
display: 'flex',
|
|
38
38
|
borderTop: '1px solid #8A7F7C',
|
|
39
|
-
borderBottom: '1px solid #8A7F7C',
|
|
40
39
|
paddingRight: '41px'
|
|
41
40
|
};
|
|
42
41
|
const cartDownloadAreaStyle = {
|
|
@@ -92,7 +91,7 @@ const TableView = _ref => {
|
|
|
92
91
|
table: table
|
|
93
92
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
94
93
|
className: "downloadArea",
|
|
95
|
-
style: table.paginationAPIField === 'filesInList' ? cartDownloadAreaStyle : downloadAreaStyle
|
|
94
|
+
style: table.paginationAPIField === 'filesInList' ? cartDownloadAreaStyle : table.paginationCustomStyle && table.paginationCustomStyle.bottomPagination ? table.paginationCustomStyle.bottomPagination : downloadAreaStyle
|
|
96
95
|
}, /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
|
|
97
96
|
customTheme: themeConfig.tblPgn,
|
|
98
97
|
rowsPerPageOptions: [10, 25, 50, 100],
|
|
@@ -102,10 +101,11 @@ const TableView = _ref => {
|
|
|
102
101
|
page: table.page || 0,
|
|
103
102
|
onPageChange: onPageChange,
|
|
104
103
|
onRowsPerPageChange: onRowsPerPageChange
|
|
105
|
-
}), /*#__PURE__*/_react.default.createElement(_DownloadButtonView.default, {
|
|
104
|
+
}), table.showDownloadIcon !== false && /*#__PURE__*/_react.default.createElement(_DownloadButtonView.default, {
|
|
106
105
|
count: table.totalRowCount || 0,
|
|
107
106
|
queryVariables: queryVariables,
|
|
108
|
-
table: table
|
|
107
|
+
table: table,
|
|
108
|
+
buttonConfig: table.extendedViewConfig.downloadButtonConfig
|
|
109
109
|
})));
|
|
110
110
|
};
|
|
111
111
|
var _default = TableView;
|
|
@@ -44,6 +44,9 @@ const ViewCell = _ref2 => {
|
|
|
44
44
|
const {
|
|
45
45
|
cellType
|
|
46
46
|
} = column;
|
|
47
|
+
function isNumeric(value) {
|
|
48
|
+
return /^-?\d+\.?\d*$/.test(value);
|
|
49
|
+
}
|
|
47
50
|
switch (cellType) {
|
|
48
51
|
case _Types.cellTypes.FORMAT_DATA:
|
|
49
52
|
return /*#__PURE__*/_react.default.createElement(_DataFormatView.default, {
|
|
@@ -60,6 +63,8 @@ const ViewCell = _ref2 => {
|
|
|
60
63
|
row: row,
|
|
61
64
|
column: column
|
|
62
65
|
});
|
|
66
|
+
case _Types.cellTypes.COMMA:
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement(_core.Typography, null, isNumeric(row[column.dataField]) ? Number(row[column.dataField]).toLocaleString() : row[column.dataField]);
|
|
63
68
|
default:
|
|
64
69
|
return /*#__PURE__*/_react.default.createElement(_core.Typography, null, row[column.dataField]);
|
|
65
70
|
}
|
|
@@ -20,7 +20,7 @@ const CustomLinkView = _ref => {
|
|
|
20
20
|
rootPath,
|
|
21
21
|
pathParams
|
|
22
22
|
} = column === null || column === void 0 ? void 0 : column.linkAttr;
|
|
23
|
-
const url = pathParams.map(attr => "
|
|
23
|
+
const url = pathParams.map(attr => "".concat(rootPath, "/").concat(row[attr]));
|
|
24
24
|
return /*#__PURE__*/_react.default.createElement(_core.Link, {
|
|
25
25
|
href: url,
|
|
26
26
|
className: _Types.cellTypes.LINK
|
|
@@ -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) {
|
|
@@ -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
|
|
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
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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,9 +69,10 @@ 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.
|
|
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
78
|
labelRowsPerPage: "Results per Page:",
|
|
@@ -63,11 +84,40 @@ const CustomPagination = _ref => {
|
|
|
63
84
|
onPageChange: onPageChange,
|
|
64
85
|
onRowsPerPageChange: onRowsPerPageChange,
|
|
65
86
|
SelectProps: {
|
|
66
|
-
IconComponent:
|
|
87
|
+
IconComponent: _icons.ArrowDropDown,
|
|
67
88
|
inputProps: {
|
|
68
89
|
'aria-label': 'Selection dropdown for displaying the number of results per page'
|
|
69
90
|
}
|
|
70
|
-
}
|
|
91
|
+
},
|
|
92
|
+
nextIconButtonProps: {
|
|
93
|
+
'aria-label': 'Next page'
|
|
94
|
+
},
|
|
95
|
+
backIconButtonProps: {
|
|
96
|
+
'aria-label': 'Previous page'
|
|
97
|
+
},
|
|
98
|
+
ActionsComponent: () => /*#__PURE__*/_react.default.createElement("div", {
|
|
99
|
+
className: classes.actionsContainer
|
|
100
|
+
}, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
101
|
+
onClick: event => onPageChange(event, page - 1),
|
|
102
|
+
disabled: page === 0,
|
|
103
|
+
"aria-label": "Previous page"
|
|
104
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
105
|
+
src: _leftArrow.default,
|
|
106
|
+
style: {
|
|
107
|
+
opacity: page === 0 ? 0.2 : 1
|
|
108
|
+
},
|
|
109
|
+
alt: "Left Arrow"
|
|
110
|
+
})), /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
111
|
+
onClick: event => onPageChange(event, page + 1),
|
|
112
|
+
disabled: page >= Math.ceil(count / rowsPerPage) - 1,
|
|
113
|
+
"aria-label": "Next page"
|
|
114
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
115
|
+
src: _rightArrow.default,
|
|
116
|
+
style: {
|
|
117
|
+
opacity: page >= Math.ceil(count / rowsPerPage) - 1 ? 0.2 : 1
|
|
118
|
+
},
|
|
119
|
+
alt: "Right Arrow"
|
|
120
|
+
})))
|
|
71
121
|
}));
|
|
72
122
|
};
|
|
73
123
|
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,43 +18,57 @@ 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
|
-
|
|
21
|
-
|
|
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
|
-
table
|
|
43
|
-
buttonConfig = {},
|
|
44
|
-
isIcon = false
|
|
30
|
+
table
|
|
45
31
|
} = _ref;
|
|
32
|
+
const [listDisplay, setListDisplay] = (0, _react.useState)('none');
|
|
33
|
+
const dropdownSelection = (0, _react.useRef)(null);
|
|
34
|
+
const useOutsideAlerter = ref => {
|
|
35
|
+
(0, _react.useEffect)(() => {
|
|
36
|
+
function handleClickOutside(event) {
|
|
37
|
+
if (!(event.target.getAttribute('id') && event.target.getAttribute('id').includes('dropdownListItem'))) {
|
|
38
|
+
setListDisplay('none');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
42
|
+
return () => {
|
|
43
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
44
|
+
};
|
|
45
|
+
}, [ref]);
|
|
46
|
+
};
|
|
47
|
+
useOutsideAlerter(dropdownSelection);
|
|
46
48
|
if (table.paginationAPIField === 'filesInList') {
|
|
47
49
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const client = (0, _client.useApolloClient)();
|
|
52
|
+
function cleanData(result) {
|
|
53
|
+
function hasHTMLTags(str) {
|
|
54
|
+
const htmlTagPattern = /<\/?[a-z][\s\S]*>/i; // Regex to match HTML tags
|
|
55
|
+
return htmlTagPattern.test(str);
|
|
56
|
+
}
|
|
57
|
+
const cleanedResult = result.map(res => {
|
|
58
|
+
const newObj = {};
|
|
59
|
+
Object.keys(res).forEach(key => {
|
|
60
|
+
if (hasHTMLTags(res[key])) {
|
|
61
|
+
const div = document.createElement('div');
|
|
62
|
+
div.innerHTML = res[key];
|
|
63
|
+
newObj[key] = div.textContent || div.innerText || res[key];
|
|
64
|
+
} else {
|
|
65
|
+
newObj[key] = res[key];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return newObj;
|
|
53
69
|
});
|
|
70
|
+
return cleanedResult;
|
|
54
71
|
}
|
|
55
|
-
const client = (0, _client.useApolloClient)();
|
|
56
72
|
async function downloadSCSVFile() {
|
|
57
73
|
const {
|
|
58
74
|
query,
|
|
@@ -62,7 +78,30 @@ const DownloadButton = _ref => {
|
|
|
62
78
|
query,
|
|
63
79
|
variables: _objectSpread(_objectSpread({}, queryVariables), {}, {
|
|
64
80
|
page: 0,
|
|
65
|
-
first: 10000
|
|
81
|
+
first: 10000,
|
|
82
|
+
order_by: table.sortBy,
|
|
83
|
+
sort_direction: table.sortOrder
|
|
84
|
+
})
|
|
85
|
+
}).then(response => {
|
|
86
|
+
if (paginationAPIField && response && response.data) {
|
|
87
|
+
return response.data[paginationAPIField];
|
|
88
|
+
}
|
|
89
|
+
return response.data;
|
|
90
|
+
});
|
|
91
|
+
(0, _downloadTable.downloadData)(cleanData(result), table, table.downloadFileName, 'csv');
|
|
92
|
+
}
|
|
93
|
+
async function downloadJsonFile() {
|
|
94
|
+
const {
|
|
95
|
+
query,
|
|
96
|
+
paginationAPIField
|
|
97
|
+
} = table;
|
|
98
|
+
const result = await client.query({
|
|
99
|
+
query,
|
|
100
|
+
variables: _objectSpread(_objectSpread({}, queryVariables), {}, {
|
|
101
|
+
page: 0,
|
|
102
|
+
first: 10000,
|
|
103
|
+
order_by: table.sortBy,
|
|
104
|
+
sort_direction: table.sortOrder
|
|
66
105
|
})
|
|
67
106
|
}).then(response => {
|
|
68
107
|
if (paginationAPIField && response && response.data) {
|
|
@@ -70,29 +109,97 @@ const DownloadButton = _ref => {
|
|
|
70
109
|
}
|
|
71
110
|
return response.data;
|
|
72
111
|
});
|
|
73
|
-
(0, _downloadTable.
|
|
112
|
+
(0, _downloadTable.downloadData)(cleanData(result), table, table.downloadFileName, 'json');
|
|
74
113
|
}
|
|
75
114
|
const downloadTableCSV = (0, _react.useCallback)(() => {
|
|
76
115
|
downloadSCSVFile();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
116
|
+
setListDisplay('none');
|
|
117
|
+
}, [queryVariables, table]);
|
|
118
|
+
const downloadTableJson = (0, _react.useCallback)(() => {
|
|
119
|
+
downloadJsonFile();
|
|
120
|
+
setListDisplay('none');
|
|
121
|
+
}, [queryVariables, table]);
|
|
122
|
+
const handleClickButton = () => {
|
|
123
|
+
if (listDisplay === 'none') {
|
|
124
|
+
setListDisplay('block');
|
|
125
|
+
} else {
|
|
126
|
+
setListDisplay('none');
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const useStyles = (0, _core.makeStyles)({
|
|
130
|
+
dropdown: {
|
|
131
|
+
width: '60px',
|
|
132
|
+
height: '25px',
|
|
133
|
+
marginTop: '8px',
|
|
134
|
+
paddingLeft: '5px',
|
|
135
|
+
border: '0.75px solid #606060',
|
|
136
|
+
borderRadius: '5px',
|
|
137
|
+
display: 'inline-block',
|
|
138
|
+
position: 'relative',
|
|
139
|
+
alignSelf: 'center'
|
|
140
|
+
},
|
|
141
|
+
dropdownList: {
|
|
142
|
+
display: 'block',
|
|
143
|
+
position: 'absolute',
|
|
144
|
+
width: '60px',
|
|
145
|
+
marginTop: '3px',
|
|
146
|
+
marginLeft: '-5px',
|
|
147
|
+
overflow: 'auto',
|
|
148
|
+
zIndex: '20',
|
|
149
|
+
border: '1.5px solid #41545E',
|
|
150
|
+
borderRadius: '5px',
|
|
151
|
+
background: '#ffffff'
|
|
152
|
+
},
|
|
153
|
+
dropdownListItem: {
|
|
154
|
+
padding: '2px 4px',
|
|
155
|
+
font: 'Poppins',
|
|
156
|
+
fontSize: '14px',
|
|
157
|
+
fontWeight: 400,
|
|
158
|
+
lineHeight: '21px',
|
|
159
|
+
'&:hover': {
|
|
160
|
+
background: '#D7D7D7',
|
|
161
|
+
cursor: 'pointer'
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
arrowdownIcon: {
|
|
165
|
+
marginLeft: '5px',
|
|
166
|
+
fill: '#606060'
|
|
167
|
+
},
|
|
168
|
+
arrowdownIconDisabled: {
|
|
169
|
+
marginLeft: '5px',
|
|
170
|
+
fill: '#00000042'
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
const classes = useStyles();
|
|
174
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
175
|
+
className: classes.dropdown
|
|
176
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
|
|
177
|
+
title: table.downloadButtonTooltipText || 'Download filtered results'
|
|
178
|
+
}, count !== 0 ? /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
179
|
+
onClick: handleClickButton,
|
|
92
180
|
style: {
|
|
93
|
-
|
|
181
|
+
padding: '0'
|
|
94
182
|
}
|
|
95
|
-
})
|
|
183
|
+
}, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null), /*#__PURE__*/_react.default.createElement(_KeyboardArrowDownOutlined.default, {
|
|
184
|
+
className: classes.arrowdownIcon
|
|
185
|
+
})) : /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
186
|
+
disabled: true
|
|
187
|
+
}, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null), /*#__PURE__*/_react.default.createElement(_KeyboardArrowDownOutlined.default, {
|
|
188
|
+
className: classes.arrowdownIconDisabled
|
|
189
|
+
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
190
|
+
className: classes.dropdownList,
|
|
191
|
+
style: {
|
|
192
|
+
display: listDisplay
|
|
193
|
+
}
|
|
194
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
195
|
+
id: "dropdownListItemCSV",
|
|
196
|
+
className: classes.dropdownListItem,
|
|
197
|
+
onClick: downloadTableCSV
|
|
198
|
+
}, "CSV"), /*#__PURE__*/_react.default.createElement("div", {
|
|
199
|
+
id: "dropdownListItemJSON",
|
|
200
|
+
className: classes.dropdownListItem,
|
|
201
|
+
onClick: downloadTableJson
|
|
202
|
+
}, "JSON")));
|
|
96
203
|
};
|
|
97
204
|
var _default = DownloadButton;
|
|
98
205
|
exports.default = _default;
|
package/dist/util/Types.js
CHANGED
|
@@ -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.COMMA = exports.CHECKBOX = void 0;
|
|
7
7
|
const CHECKBOX = 'CHECKBOX';
|
|
8
8
|
exports.CHECKBOX = CHECKBOX;
|
|
9
9
|
const DELETE = 'DELETE';
|
|
@@ -24,6 +24,8 @@ 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;
|
|
27
29
|
const cellTypes = {
|
|
28
30
|
CUSTOM_ELEM,
|
|
29
31
|
LINK,
|
|
@@ -31,7 +33,8 @@ const cellTypes = {
|
|
|
31
33
|
CHECKBOX,
|
|
32
34
|
DELETE,
|
|
33
35
|
DEFAULT,
|
|
34
|
-
FORMAT_DATA
|
|
36
|
+
FORMAT_DATA,
|
|
37
|
+
COMMA
|
|
35
38
|
};
|
|
36
39
|
exports.cellTypes = cellTypes;
|
|
37
40
|
const cellStyles = {
|