@bento-core/table 1.0.0-c3dc.23 → 1.0.0-c3dc.25
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 +16 -23
- package/dist/TableView.js +12 -24
- package/dist/body/ActionBodyCell.js +4 -1
- package/dist/body/CustomTblBody.js +6 -2
- package/dist/body/DisplayBodyCell.js +0 -5
- package/dist/body/components/CheckBoxView.js +11 -10
- package/dist/body/components/CustomLinkView.js +1 -1
- package/dist/body/components/DeleteCellView.js +7 -2
- package/dist/header/ActionHeaderCell.js +4 -3
- package/dist/header/ColumnGrouping.js +52 -0
- package/dist/header/CustomCell.js +4 -9
- package/dist/header/CustomTblHeader.js +10 -3
- package/dist/header/DefaultThemConfig.js +1 -1
- package/dist/header/components/CheckBoxView.js +16 -18
- package/dist/header/components/DeleteCellView.js +50 -9
- package/dist/header/components/RemoveAllDialog.js +7 -3
- package/dist/index.js +0 -6
- package/dist/pagination/CustomPagination.js +32 -78
- package/dist/toolbar/DownloadButtonView.js +27 -157
- package/dist/toolbar/ManageColumnView.js +11 -9
- package/dist/util/Types.js +2 -14
- package/dist/util/downloadTable.js +36 -78
- package/package.json +2 -2
- package/src/pagination/CustomPagination.js +8 -2
- package/src/util/downloadTable.js +6 -9
- package/dist/assets/downArrow.svg +0 -3
- package/dist/assets/leftArrow.svg +0 -3
- package/dist/assets/rightArrow.svg +0 -3
|
@@ -7,58 +7,37 @@ 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 _icons = require("@material-ui/icons");
|
|
11
|
-
var _rightArrow = _interopRequireDefault(require("../assets/rightArrow.svg"));
|
|
12
|
-
var _leftArrow = _interopRequireDefault(require("../assets/leftArrow.svg"));
|
|
13
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
11
|
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; }
|
|
15
12
|
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; }
|
|
16
13
|
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
14
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
18
15
|
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
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
paddingRight: '10px' // Optional spacing
|
|
25
|
-
},
|
|
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
|
-
}
|
|
16
|
+
const defaultTheme = {
|
|
17
|
+
MuiTablePagination: {
|
|
18
|
+
root: {
|
|
19
|
+
paddingRight: '50px',
|
|
20
|
+
borderTop: '3px solid #42779a'
|
|
45
21
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
22
|
+
toolbar: {
|
|
23
|
+
minHeight: '45px'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
MuiTypography: {
|
|
27
|
+
body2: {
|
|
28
|
+
fontSize: '14px',
|
|
29
|
+
textTransform: 'uppercase'
|
|
54
30
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
31
|
+
root: {
|
|
32
|
+
fontSize: '14px'
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
MuiIconButton: {
|
|
36
|
+
root: {
|
|
37
|
+
padding: '2px'
|
|
59
38
|
}
|
|
60
39
|
}
|
|
61
|
-
}
|
|
40
|
+
};
|
|
62
41
|
const CustomPagination = _ref => {
|
|
63
42
|
let {
|
|
64
43
|
rowsPerPageOptions,
|
|
@@ -69,13 +48,11 @@ const CustomPagination = _ref => {
|
|
|
69
48
|
onRowsPerPageChange,
|
|
70
49
|
customTheme = {}
|
|
71
50
|
} = _ref;
|
|
72
|
-
const classes = useStyles();
|
|
73
51
|
return /*#__PURE__*/_react.default.createElement(_core.ThemeProvider, {
|
|
74
|
-
theme: (0, _core.
|
|
75
|
-
overrides: _objectSpread(_objectSpread({}, defaultTheme
|
|
52
|
+
theme: (0, _core.createTheme)({
|
|
53
|
+
overrides: _objectSpread(_objectSpread({}, defaultTheme), customTheme)
|
|
76
54
|
})
|
|
77
55
|
}, /*#__PURE__*/_react.default.createElement(_core.TablePagination, {
|
|
78
|
-
labelRowsPerPage: "Results per Page:",
|
|
79
56
|
rowsPerPageOptions: rowsPerPageOptions,
|
|
80
57
|
component: "div",
|
|
81
58
|
count: count,
|
|
@@ -83,41 +60,18 @@ const CustomPagination = _ref => {
|
|
|
83
60
|
page: page,
|
|
84
61
|
onPageChange: onPageChange,
|
|
85
62
|
onRowsPerPageChange: onRowsPerPageChange,
|
|
63
|
+
labelRowsPerPage: /*#__PURE__*/_react.default.createElement("span", {
|
|
64
|
+
id: "rows-per-page-label"
|
|
65
|
+
}, "Rows per page:"),
|
|
86
66
|
SelectProps: {
|
|
87
|
-
IconComponent: _icons.ArrowDropDown,
|
|
88
67
|
inputProps: {
|
|
89
|
-
'aria-label': '
|
|
68
|
+
'aria-label': 'rows per page dropdown selector',
|
|
69
|
+
'aria-labelledby': 'rows-per-page-label',
|
|
70
|
+
style: {
|
|
71
|
+
visibility: 'hidden'
|
|
72
|
+
}
|
|
90
73
|
}
|
|
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
|
-
})))
|
|
74
|
+
}
|
|
121
75
|
}));
|
|
122
76
|
};
|
|
123
77
|
CustomPagination.propTypes = {
|
|
@@ -7,10 +7,8 @@ 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"));
|
|
11
10
|
var _icons = require("@material-ui/icons");
|
|
12
11
|
var _downloadTable = require("../util/downloadTable");
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
12
|
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); }
|
|
15
13
|
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; }
|
|
16
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; }
|
|
@@ -18,57 +16,23 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
18
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; }
|
|
19
17
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
20
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); }
|
|
21
|
-
// const downloadButtonStyle = {
|
|
22
|
-
// color: '#d1d2d3',
|
|
23
|
-
// marginTop: '7px',
|
|
24
|
-
// };
|
|
25
|
-
|
|
26
19
|
const DownloadButton = _ref => {
|
|
27
20
|
let {
|
|
28
|
-
|
|
21
|
+
download,
|
|
22
|
+
rows,
|
|
23
|
+
table,
|
|
29
24
|
queryVariables,
|
|
30
|
-
|
|
25
|
+
server
|
|
31
26
|
} = _ref;
|
|
32
|
-
|
|
33
|
-
|
|
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);
|
|
48
|
-
if (table.paginationAPIField === 'filesInList') {
|
|
49
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
27
|
+
if (!download) {
|
|
28
|
+
return null;
|
|
50
29
|
}
|
|
30
|
+
const {
|
|
31
|
+
downloadCsv = 'download',
|
|
32
|
+
downloadTable,
|
|
33
|
+
downloadFileName
|
|
34
|
+
} = download;
|
|
51
35
|
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;
|
|
69
|
-
});
|
|
70
|
-
return cleanedResult;
|
|
71
|
-
}
|
|
72
36
|
async function downloadSCSVFile() {
|
|
73
37
|
const {
|
|
74
38
|
query,
|
|
@@ -78,9 +42,7 @@ const DownloadButton = _ref => {
|
|
|
78
42
|
query,
|
|
79
43
|
variables: _objectSpread(_objectSpread({}, queryVariables), {}, {
|
|
80
44
|
page: 0,
|
|
81
|
-
first: 10000
|
|
82
|
-
order_by: table.sortBy,
|
|
83
|
-
sort_direction: table.sortOrder
|
|
45
|
+
first: 10000
|
|
84
46
|
})
|
|
85
47
|
}).then(response => {
|
|
86
48
|
if (paginationAPIField && response && response.data) {
|
|
@@ -88,118 +50,26 @@ const DownloadButton = _ref => {
|
|
|
88
50
|
}
|
|
89
51
|
return response.data;
|
|
90
52
|
});
|
|
91
|
-
(0, _downloadTable.
|
|
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
|
|
105
|
-
})
|
|
106
|
-
}).then(response => {
|
|
107
|
-
if (paginationAPIField && response && response.data) {
|
|
108
|
-
return response.data[paginationAPIField];
|
|
109
|
-
}
|
|
110
|
-
return response.data;
|
|
111
|
-
});
|
|
112
|
-
(0, _downloadTable.downloadData)(cleanData(result), table, table.downloadFileName, 'json');
|
|
53
|
+
(0, _downloadTable.downloadJson)(result, table, downloadFileName);
|
|
113
54
|
}
|
|
114
55
|
const downloadTableCSV = (0, _react.useCallback)(() => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}, [queryVariables, table]);
|
|
122
|
-
const handleClickButton = () => {
|
|
123
|
-
if (listDisplay === 'none') {
|
|
124
|
-
setListDisplay('block');
|
|
56
|
+
// custom download from bento app
|
|
57
|
+
if (downloadTable) {
|
|
58
|
+
downloadTable(queryVariables);
|
|
59
|
+
} else if (!downloadTable && !server) {
|
|
60
|
+
// download client table
|
|
61
|
+
(0, _downloadTable.downloadJson)(rows, table, downloadFileName);
|
|
125
62
|
} else {
|
|
126
|
-
|
|
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,
|
|
180
|
-
style: {
|
|
181
|
-
padding: '0'
|
|
182
|
-
}
|
|
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
|
|
63
|
+
// donwload server table
|
|
64
|
+
downloadSCSVFile();
|
|
193
65
|
}
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
|
|
66
|
+
}, [queryVariables]);
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
|
|
68
|
+
title: downloadCsv,
|
|
69
|
+
className: "download-icon"
|
|
70
|
+
}, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
197
71
|
onClick: downloadTableCSV
|
|
198
|
-
},
|
|
199
|
-
id: "dropdownListItemJSON",
|
|
200
|
-
className: classes.dropdownListItem,
|
|
201
|
-
onClick: downloadTableJson
|
|
202
|
-
}, "JSON")));
|
|
72
|
+
}, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null))));
|
|
203
73
|
};
|
|
204
74
|
var _default = DownloadButton;
|
|
205
75
|
exports.default = _default;
|
|
@@ -20,7 +20,7 @@ const ManageColumnView = _ref => {
|
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
22
|
const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
|
|
23
|
-
const
|
|
23
|
+
const toggleDisplay = event => {
|
|
24
24
|
setAnchorEl(event.currentTarget);
|
|
25
25
|
};
|
|
26
26
|
const handleClose = () => setAnchorEl(null);
|
|
@@ -33,7 +33,8 @@ const ManageColumnView = _ref => {
|
|
|
33
33
|
title: manageViewColumns.title
|
|
34
34
|
}, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
35
35
|
variant: "contained",
|
|
36
|
-
onClick:
|
|
36
|
+
onClick: toggleDisplay,
|
|
37
|
+
className: "manageViewColumnBtn"
|
|
37
38
|
}, /*#__PURE__*/_react.default.createElement(_icons.ViewColumn, null))), /*#__PURE__*/_react.default.createElement(_core.Popover, {
|
|
38
39
|
open: open,
|
|
39
40
|
anchorEl: anchorEl,
|
|
@@ -55,22 +56,23 @@ const ManageColumnView = _ref => {
|
|
|
55
56
|
className: "viewColumnListItem"
|
|
56
57
|
}, /*#__PURE__*/_react.default.createElement(_core.Checkbox, {
|
|
57
58
|
icon: /*#__PURE__*/_react.default.createElement(_icons.CheckBoxOutlineBlank, {
|
|
58
|
-
style: {
|
|
59
|
-
fontSize: 18
|
|
60
|
-
},
|
|
61
59
|
className: "checkBoxIcon"
|
|
62
60
|
}),
|
|
63
61
|
onClick: () => onColumnViewChange(column),
|
|
64
62
|
checked: column.display,
|
|
65
63
|
checkedIcon: /*#__PURE__*/_react.default.createElement(_icons.CheckBox, {
|
|
66
|
-
style: {
|
|
67
|
-
fontSize: 18
|
|
68
|
-
},
|
|
69
64
|
className: "checkBoxIcon"
|
|
70
65
|
}),
|
|
71
66
|
disableRipple: true,
|
|
72
67
|
color: "secondary",
|
|
73
|
-
className: "checkBox"
|
|
68
|
+
className: "checkBox",
|
|
69
|
+
inputProps: {
|
|
70
|
+
'aria-label': 'checkbox'
|
|
71
|
+
}
|
|
72
|
+
}), column.icon && /*#__PURE__*/_react.default.createElement("img", {
|
|
73
|
+
src: column.icon,
|
|
74
|
+
alt: column.header,
|
|
75
|
+
className: column.dataField
|
|
74
76
|
}), /*#__PURE__*/_react.default.createElement(_core.Typography, null, column.header))))));
|
|
75
77
|
};
|
|
76
78
|
const styles = () => ({
|
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.
|
|
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
7
|
const CHECKBOX = 'CHECKBOX';
|
|
8
8
|
exports.CHECKBOX = CHECKBOX;
|
|
9
9
|
const DELETE = 'DELETE';
|
|
@@ -20,12 +20,6 @@ const FORMAT_DATA = 'FORMAT_DATA';
|
|
|
20
20
|
exports.FORMAT_DATA = FORMAT_DATA;
|
|
21
21
|
const FORMAT_BYTES = 'FORMAT_BYTES';
|
|
22
22
|
exports.FORMAT_BYTES = FORMAT_BYTES;
|
|
23
|
-
const TRANSFORM = 'TRANSFORM';
|
|
24
|
-
exports.TRANSFORM = TRANSFORM;
|
|
25
|
-
const EXPAND = 'EXPAND';
|
|
26
|
-
exports.EXPAND = EXPAND;
|
|
27
|
-
const COMMA = 'COMMA';
|
|
28
|
-
exports.COMMA = COMMA;
|
|
29
23
|
const cellTypes = {
|
|
30
24
|
CUSTOM_ELEM,
|
|
31
25
|
LINK,
|
|
@@ -33,15 +27,9 @@ const cellTypes = {
|
|
|
33
27
|
CHECKBOX,
|
|
34
28
|
DELETE,
|
|
35
29
|
DEFAULT,
|
|
36
|
-
FORMAT_DATA
|
|
37
|
-
COMMA
|
|
30
|
+
FORMAT_DATA
|
|
38
31
|
};
|
|
39
32
|
exports.cellTypes = cellTypes;
|
|
40
|
-
const cellStyles = {
|
|
41
|
-
TRANSFORM,
|
|
42
|
-
EXPAND
|
|
43
|
-
};
|
|
44
|
-
exports.cellStyles = cellStyles;
|
|
45
33
|
const actionCellTypes = [CHECKBOX, DELETE];
|
|
46
34
|
exports.actionCellTypes = actionCellTypes;
|
|
47
35
|
const FORMAT_DATA_CELLS = [FORMAT_BYTES];
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.convertToCSV = convertToCSV;
|
|
7
7
|
exports.createFileName = createFileName;
|
|
8
|
-
exports.
|
|
8
|
+
exports.downloadJson = downloadJson;
|
|
9
9
|
var _Dataformat = require("./Dataformat");
|
|
10
10
|
var _Types = require("./Types");
|
|
11
11
|
function createFileName(fileName) {
|
|
@@ -32,7 +32,7 @@ function createFileName(fileName) {
|
|
|
32
32
|
if (seconds < 10) {
|
|
33
33
|
seconds = "0".concat(seconds);
|
|
34
34
|
}
|
|
35
|
-
return "".concat(fileName, " ").concat(todaysDate, " ").concat(hours, "-").concat(minutes, "-").concat(seconds);
|
|
35
|
+
return "".concat(fileName, " ").concat(todaysDate, " ").concat(hours, "-").concat(minutes, "-").concat(seconds, '.csv');
|
|
36
36
|
}
|
|
37
37
|
function convertToCSV(jsonse, keysToInclude, header) {
|
|
38
38
|
const objArray = jsonse;
|
|
@@ -45,17 +45,8 @@ function convertToCSV(jsonse, keysToInclude, header) {
|
|
|
45
45
|
if (line !== '') line += ',';
|
|
46
46
|
if (keyName === 'file_size') {
|
|
47
47
|
line += entry[keyName] !== null ? "\"".concat((0, _Dataformat.formatBytes)(entry[keyName]), "\"") : ' ';
|
|
48
|
-
} else if (keyName === 'age_at_diagnosis' || keyName === 'participant_age_at_collection') {
|
|
49
|
-
if (entry[keyName] === -999) {
|
|
50
|
-
line += 'Not Reported';
|
|
51
|
-
} else {
|
|
52
|
-
line += entry[keyName] !== null ? "\"".concat(entry[keyName], "\"") : ' ';
|
|
53
|
-
}
|
|
54
|
-
} else if (keyName === 'participant') {
|
|
55
|
-
line += entry[keyName].participant_id;
|
|
56
48
|
} else {
|
|
57
|
-
|
|
58
|
-
line += "\"".concat(newLine, "\"");
|
|
49
|
+
line += entry[keyName] !== null ? "\"".concat(entry[keyName], "\"") : ' ';
|
|
59
50
|
}
|
|
60
51
|
return line;
|
|
61
52
|
});
|
|
@@ -69,81 +60,48 @@ function convertToCSV(jsonse, keysToInclude, header) {
|
|
|
69
60
|
});
|
|
70
61
|
return str;
|
|
71
62
|
}
|
|
72
|
-
function
|
|
73
|
-
let format = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'csv';
|
|
63
|
+
function downloadJson(tableData, table, downloadFileName) {
|
|
74
64
|
const {
|
|
75
65
|
columns = []
|
|
76
66
|
} = table;
|
|
77
67
|
const filterColumns = columns.filter(_ref => {
|
|
78
68
|
let {
|
|
79
|
-
cellType
|
|
80
|
-
doNotDownload
|
|
69
|
+
cellType
|
|
81
70
|
} = _ref;
|
|
82
|
-
return !_Types.actionCellTypes.includes(cellType)
|
|
71
|
+
return !_Types.actionCellTypes.includes(cellType);
|
|
83
72
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
const formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
|
|
74
|
+
const jsonse = JSON.stringify(formatDataVal);
|
|
75
|
+
const keysToInclude = columns.filter(_ref2 => {
|
|
76
|
+
let {
|
|
77
|
+
dataField
|
|
78
|
+
} = _ref2;
|
|
79
|
+
return dataField;
|
|
80
|
+
}).map(_ref3 => {
|
|
81
|
+
let {
|
|
82
|
+
dataField
|
|
83
|
+
} = _ref3;
|
|
84
|
+
return dataField;
|
|
94
85
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
formatDataVal = JSON.parse(JSON.stringify(formatDataVal).split("\"".concat(column.dataField, "\":")).join("\"".concat(column.header, "\":")));
|
|
110
|
-
});
|
|
111
|
-
fileContent = JSON.stringify(formatDataVal);
|
|
112
|
-
fileType = 'application/json';
|
|
113
|
-
} else {
|
|
114
|
-
const jsonse = JSON.stringify(formatDataVal);
|
|
115
|
-
const keysToInclude = filterColumns.filter(_ref3 => {
|
|
116
|
-
let {
|
|
117
|
-
dataField
|
|
118
|
-
} = _ref3;
|
|
119
|
-
return dataField;
|
|
120
|
-
}).map(_ref4 => {
|
|
121
|
-
let {
|
|
122
|
-
dataField
|
|
123
|
-
} = _ref4;
|
|
124
|
-
return dataField;
|
|
125
|
-
});
|
|
126
|
-
const headers = filterColumns.filter(_ref5 => {
|
|
127
|
-
let {
|
|
128
|
-
dataField
|
|
129
|
-
} = _ref5;
|
|
130
|
-
return dataField;
|
|
131
|
-
}).map(_ref6 => {
|
|
132
|
-
let {
|
|
133
|
-
header,
|
|
134
|
-
downloadHeader
|
|
135
|
-
} = _ref6;
|
|
136
|
-
return downloadHeader || header;
|
|
137
|
-
});
|
|
138
|
-
fileContent = convertToCSV(jsonse, keysToInclude, headers);
|
|
139
|
-
fileType = 'text/csv';
|
|
140
|
-
}
|
|
141
|
-
const exportData = new Blob([fileContent], {
|
|
142
|
-
type: fileType
|
|
86
|
+
const headers = columns.filter(_ref4 => {
|
|
87
|
+
let {
|
|
88
|
+
dataField
|
|
89
|
+
} = _ref4;
|
|
90
|
+
return dataField;
|
|
91
|
+
}).map(_ref5 => {
|
|
92
|
+
let {
|
|
93
|
+
header
|
|
94
|
+
} = _ref5;
|
|
95
|
+
return header;
|
|
96
|
+
});
|
|
97
|
+
const csv = convertToCSV(jsonse, keysToInclude, headers);
|
|
98
|
+
const exportData = new Blob([csv], {
|
|
99
|
+
type: 'text/csv'
|
|
143
100
|
});
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
tempLink.
|
|
101
|
+
const JsonURL = window.URL.createObjectURL(exportData);
|
|
102
|
+
let tempLink = '';
|
|
103
|
+
tempLink = document.createElement('a');
|
|
104
|
+
tempLink.setAttribute('href', JsonURL);
|
|
147
105
|
tempLink.setAttribute('download', createFileName(downloadFileName || ''));
|
|
148
106
|
document.body.appendChild(tempLink);
|
|
149
107
|
tempLink.click();
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/table",
|
|
3
|
-
"version": "1.0.0-c3dc.
|
|
3
|
+
"version": "1.0.0-c3dc.25",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "
|
|
6
|
+
"build": "cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
8
|
"lint": "eslint src"
|
|
9
9
|
},
|
|
@@ -70,7 +70,7 @@ const CustomPagination = ({
|
|
|
70
70
|
theme={createMuiTheme({ overrides: { ...defaultTheme.overrides, ...customTheme } })}
|
|
71
71
|
>
|
|
72
72
|
<TablePagination
|
|
73
|
-
labelRowsPerPage="
|
|
73
|
+
labelRowsPerPage={<span id="rows-per-page-label">Rows per page:</span>}
|
|
74
74
|
rowsPerPageOptions={rowsPerPageOptions}
|
|
75
75
|
component="div"
|
|
76
76
|
count={count}
|
|
@@ -80,7 +80,13 @@ const CustomPagination = ({
|
|
|
80
80
|
onRowsPerPageChange={onRowsPerPageChange}
|
|
81
81
|
SelectProps={{
|
|
82
82
|
IconComponent: ArrowDropDown,
|
|
83
|
-
inputProps: {
|
|
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
|
+
},
|
|
84
90
|
}}
|
|
85
91
|
nextIconButtonProps={{
|
|
86
92
|
'aria-label': 'Next page',
|
|
@@ -80,16 +80,13 @@ export function downloadData(tableData, table, downloadFileName, format = 'csv')
|
|
|
80
80
|
|
|
81
81
|
if (format === 'json') {
|
|
82
82
|
filterColumns.forEach((column) => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return dataObject;
|
|
89
|
-
};
|
|
90
|
-
formatDataVal = formatDataVal.map(mapData);
|
|
83
|
+
let jsonKey = column.dataField;
|
|
84
|
+
|
|
85
|
+
if (column.useKey) {
|
|
86
|
+
jsonKey = column.header;
|
|
87
|
+
}
|
|
91
88
|
formatDataVal = JSON.parse(
|
|
92
|
-
JSON.stringify(formatDataVal).split(`"${
|
|
89
|
+
JSON.stringify(formatDataVal).split(`"${jsonKey}":`).join(`"${column.header}":`),
|
|
93
90
|
);
|
|
94
91
|
});
|
|
95
92
|
fileContent = JSON.stringify(formatDataVal);
|