@bento-core/table 1.0.1-ccdihub.60 → 1.0.1-ccdihub.62
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/TableView.js +36 -2
- package/dist/toolbar/DownloadButtonView.js +18 -11
- package/package.json +1 -1
- package/src/TableView.js +93 -59
- package/src/toolbar/DownloadButtonView.js +26 -13
package/dist/TableView.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _core = require("@material-ui/core");
|
|
9
9
|
var _CustomTblHeader = _interopRequireDefault(require("./header/CustomTblHeader"));
|
|
10
10
|
var _CustomPagination = _interopRequireDefault(require("./pagination/CustomPagination"));
|
|
@@ -14,6 +14,8 @@ var _DisplayErrMsg = _interopRequireDefault(require("./errMsg/DisplayErrMsg"));
|
|
|
14
14
|
var _ExtendedView = _interopRequireDefault(require("./ExtendedView"));
|
|
15
15
|
var _DownloadButtonView = _interopRequireDefault(require("./toolbar/DownloadButtonView"));
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
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); }
|
|
18
|
+
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; }
|
|
17
19
|
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
20
|
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; }
|
|
19
21
|
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; }
|
|
@@ -30,6 +32,7 @@ const CustomTableContainer = props => {
|
|
|
30
32
|
return /*#__PURE__*/_react.default.createElement(_core.ThemeProvider, {
|
|
31
33
|
theme: themeConfig
|
|
32
34
|
}, /*#__PURE__*/_react.default.createElement(_core.TableContainer, {
|
|
35
|
+
id: "tableContainer",
|
|
33
36
|
component: _core.Paper
|
|
34
37
|
}, children));
|
|
35
38
|
};
|
|
@@ -45,6 +48,15 @@ const cartDownloadAreaStyle = {
|
|
|
45
48
|
borderBottom: '3px solid #e7e5e5',
|
|
46
49
|
paddingRight: '40px'
|
|
47
50
|
};
|
|
51
|
+
const addScrollContainerStyle = {
|
|
52
|
+
overflowX: 'auto',
|
|
53
|
+
overflowY: 'hidden',
|
|
54
|
+
width: '100%',
|
|
55
|
+
height: '14px'
|
|
56
|
+
};
|
|
57
|
+
const addScrollStyle = {
|
|
58
|
+
height: '14px'
|
|
59
|
+
};
|
|
48
60
|
const TableView = _ref => {
|
|
49
61
|
var _table$selectedRows, _table$selectedRows2;
|
|
50
62
|
let {
|
|
@@ -60,6 +72,23 @@ const TableView = _ref => {
|
|
|
60
72
|
themeConfig = {},
|
|
61
73
|
queryVariables
|
|
62
74
|
} = _ref;
|
|
75
|
+
(0, _react.useEffect)(() => {
|
|
76
|
+
const tableContainer = document.getElementById('tableContainer');
|
|
77
|
+
const addScrollContainer = document.getElementById('addScrollContainer');
|
|
78
|
+
const targetTable = tableContainer.firstChild;
|
|
79
|
+
const addScroll = addScrollContainer.firstChild;
|
|
80
|
+
const tableWidth = targetTable.clientWidth;
|
|
81
|
+
addScroll.style.width = "".concat(tableWidth, "px");
|
|
82
|
+
tableContainer.onscroll = () => {
|
|
83
|
+
addScrollContainer.scrollLeft = tableContainer.scrollLeft;
|
|
84
|
+
};
|
|
85
|
+
addScrollContainer.onscroll = () => {
|
|
86
|
+
tableContainer.scrollLeft = addScrollContainer.scrollLeft;
|
|
87
|
+
};
|
|
88
|
+
if (!(tableWidth > tableContainer.clientWidth)) {
|
|
89
|
+
addScrollContainer.style.height = '0px';
|
|
90
|
+
}
|
|
91
|
+
});
|
|
63
92
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ExtendedView.default, {
|
|
64
93
|
table: table,
|
|
65
94
|
onColumnViewChange: onColumnViewChange,
|
|
@@ -87,7 +116,12 @@ const TableView = _ref => {
|
|
|
87
116
|
rows: tableRows,
|
|
88
117
|
table: table,
|
|
89
118
|
onRowSelectChange: onRowSelectChange
|
|
90
|
-
}))),
|
|
119
|
+
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
120
|
+
id: "addScrollContainer",
|
|
121
|
+
style: addScrollContainerStyle
|
|
122
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
123
|
+
style: addScrollStyle
|
|
124
|
+
})), tableRows.length === 0 && /*#__PURE__*/_react.default.createElement(_DisplayErrMsg.default, {
|
|
91
125
|
customTheme: themeConfig.displayErr,
|
|
92
126
|
table: table
|
|
93
127
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -18,10 +18,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
18
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; }
|
|
19
19
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
20
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); }
|
|
21
|
-
const downloadButtonStyle = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
21
|
+
// const downloadButtonStyle = {
|
|
22
|
+
// color: '#d1d2d3',
|
|
23
|
+
// marginTop: '7px',
|
|
24
|
+
// };
|
|
25
|
+
|
|
25
26
|
const DownloadButton = _ref => {
|
|
26
27
|
let {
|
|
27
28
|
count,
|
|
@@ -47,12 +48,10 @@ const DownloadButton = _ref => {
|
|
|
47
48
|
if (table.paginationAPIField === 'filesInList') {
|
|
48
49
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
49
50
|
}
|
|
50
|
-
if (count === 0) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
55
|
-
}
|
|
51
|
+
// if (count === 0) {
|
|
52
|
+
// return <CloudDownload className="disableButton" style={downloadButtonStyle} />;
|
|
53
|
+
// }
|
|
54
|
+
|
|
56
55
|
const client = (0, _client.useApolloClient)();
|
|
57
56
|
async function downloadSCSVFile() {
|
|
58
57
|
const {
|
|
@@ -148,6 +147,10 @@ const DownloadButton = _ref => {
|
|
|
148
147
|
arrowdownIcon: {
|
|
149
148
|
marginLeft: '5px',
|
|
150
149
|
fill: '#606060'
|
|
150
|
+
},
|
|
151
|
+
arrowdownIconDisabled: {
|
|
152
|
+
marginLeft: '5px',
|
|
153
|
+
fill: '#00000042'
|
|
151
154
|
}
|
|
152
155
|
});
|
|
153
156
|
const classes = useStyles();
|
|
@@ -155,10 +158,14 @@ const DownloadButton = _ref => {
|
|
|
155
158
|
className: classes.dropdown
|
|
156
159
|
}, /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
|
|
157
160
|
title: "Download filtered results"
|
|
158
|
-
}, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
161
|
+
}, count !== 0 ? /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
159
162
|
onClick: handleClickButton
|
|
160
163
|
}, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null), /*#__PURE__*/_react.default.createElement(_KeyboardArrowDownOutlined.default, {
|
|
161
164
|
className: classes.arrowdownIcon
|
|
165
|
+
})) : /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
166
|
+
disabled: true
|
|
167
|
+
}, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null), /*#__PURE__*/_react.default.createElement(_KeyboardArrowDownOutlined.default, {
|
|
168
|
+
className: classes.arrowdownIconDisabled
|
|
162
169
|
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
163
170
|
className: classes.dropdownList,
|
|
164
171
|
style: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/table",
|
|
3
|
-
"version": "1.0.1-ccdihub.
|
|
3
|
+
"version": "1.0.1-ccdihub.62",
|
|
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",
|
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,
|
|
@@ -19,7 +19,7 @@ const CustomTableContainer = (props) => {
|
|
|
19
19
|
const themeConfig = createTheme({ overrides: { ...customTheme } });
|
|
20
20
|
return (
|
|
21
21
|
<ThemeProvider theme={themeConfig}>
|
|
22
|
-
<TableContainer component={Paper}>
|
|
22
|
+
<TableContainer id="tableContainer" component={Paper}>
|
|
23
23
|
{children}
|
|
24
24
|
</TableContainer>
|
|
25
25
|
</ThemeProvider>
|
|
@@ -40,6 +40,17 @@ const cartDownloadAreaStyle = {
|
|
|
40
40
|
paddingRight: '40px',
|
|
41
41
|
};
|
|
42
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
|
+
|
|
43
54
|
const TableView = ({
|
|
44
55
|
tableRows = [],
|
|
45
56
|
table,
|
|
@@ -52,67 +63,90 @@ const TableView = ({
|
|
|
52
63
|
onColumnViewChange,
|
|
53
64
|
themeConfig = {},
|
|
54
65
|
queryVariables,
|
|
55
|
-
}) =>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
customTheme={themeConfig.tblHeader}
|
|
78
|
-
table={table}
|
|
79
|
-
rows={tableRows}
|
|
80
|
-
count={totalRowCount}
|
|
81
|
-
toggleSelectAll={onToggleSelectAll}
|
|
82
|
-
sortByColumn={onSortByColumn}
|
|
83
|
-
/>
|
|
84
|
-
<CustomTableBody
|
|
85
|
-
customTheme={themeConfig.tblBody}
|
|
86
|
-
rows={tableRows}
|
|
87
|
-
table={table}
|
|
88
|
-
onRowSelectChange={onRowSelectChange}
|
|
89
|
-
/>
|
|
90
|
-
</Table>
|
|
91
|
-
</CustomTableContainer>
|
|
92
|
-
{tableRows.length === 0 && (
|
|
93
|
-
<DisplayErrMsg
|
|
94
|
-
customTheme={themeConfig.displayErr}
|
|
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
|
|
95
88
|
table={table}
|
|
96
|
-
|
|
97
|
-
)}
|
|
98
|
-
<div className="downloadArea" style={table.paginationAPIField === 'filesInList' ? cartDownloadAreaStyle : downloadAreaStyle}>
|
|
99
|
-
<CustomPagination
|
|
100
|
-
customTheme={themeConfig.tblPgn}
|
|
101
|
-
rowsPerPageOptions={[10, 25, 50, 100]}
|
|
102
|
-
component="div"
|
|
103
|
-
count={table.totalRowCount || 0}
|
|
104
|
-
rowsPerPage={table.rowsPerPage || 10}
|
|
105
|
-
page={table.page || 0}
|
|
106
|
-
onPageChange={onPageChange}
|
|
89
|
+
onColumnViewChange={onColumnViewChange}
|
|
107
90
|
onRowsPerPageChange={onRowsPerPageChange}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
91
|
+
onPageChange={onPageChange}
|
|
92
|
+
numSelected={table?.selectedRows?.length || 0}
|
|
93
|
+
customTheme={themeConfig.extendedView}
|
|
111
94
|
queryVariables={queryVariables}
|
|
95
|
+
/>
|
|
96
|
+
<CustomToolbar
|
|
97
|
+
numSelected={table?.selectedRows?.length || 0}
|
|
112
98
|
table={table}
|
|
99
|
+
onColumnViewChange={onColumnViewChange}
|
|
100
|
+
customTheme={themeConfig.toolbar}
|
|
113
101
|
/>
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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}
|
|
128
|
+
table={table}
|
|
129
|
+
/>
|
|
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}
|
|
145
|
+
table={table}
|
|
146
|
+
/>
|
|
147
|
+
</div>
|
|
148
|
+
</>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
117
151
|
|
|
118
152
|
export default TableView;
|
|
@@ -14,10 +14,10 @@ import KeyboardArrowDownOutlinedIcon from '@material-ui/icons/KeyboardArrowDownO
|
|
|
14
14
|
import { CloudDownload } from '@material-ui/icons';
|
|
15
15
|
import { downloadCSV, downloadJson } from '../util/downloadTable';
|
|
16
16
|
|
|
17
|
-
const downloadButtonStyle = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
17
|
+
// const downloadButtonStyle = {
|
|
18
|
+
// color: '#d1d2d3',
|
|
19
|
+
// marginTop: '7px',
|
|
20
|
+
// };
|
|
21
21
|
|
|
22
22
|
const DownloadButton = ({
|
|
23
23
|
count,
|
|
@@ -44,9 +44,9 @@ const DownloadButton = ({
|
|
|
44
44
|
if (table.paginationAPIField === 'filesInList') {
|
|
45
45
|
return <></>;
|
|
46
46
|
}
|
|
47
|
-
if (count === 0) {
|
|
48
|
-
|
|
49
|
-
}
|
|
47
|
+
// if (count === 0) {
|
|
48
|
+
// return <CloudDownload className="disableButton" style={downloadButtonStyle} />;
|
|
49
|
+
// }
|
|
50
50
|
|
|
51
51
|
const client = useApolloClient();
|
|
52
52
|
|
|
@@ -156,6 +156,10 @@ const DownloadButton = ({
|
|
|
156
156
|
marginLeft: '5px',
|
|
157
157
|
fill: '#606060',
|
|
158
158
|
},
|
|
159
|
+
arrowdownIconDisabled: {
|
|
160
|
+
marginLeft: '5px',
|
|
161
|
+
fill: '#00000042',
|
|
162
|
+
},
|
|
159
163
|
});
|
|
160
164
|
|
|
161
165
|
const classes = useStyles();
|
|
@@ -163,12 +167,21 @@ const DownloadButton = ({
|
|
|
163
167
|
return (
|
|
164
168
|
<div className={classes.dropdown}>
|
|
165
169
|
<Tooltip title="Download filtered results">
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
{
|
|
171
|
+
count !== 0
|
|
172
|
+
? (
|
|
173
|
+
<IconButton onClick={handleClickButton}>
|
|
174
|
+
<CloudDownload />
|
|
175
|
+
<KeyboardArrowDownOutlinedIcon className={classes.arrowdownIcon} />
|
|
176
|
+
</IconButton>
|
|
177
|
+
)
|
|
178
|
+
: (
|
|
179
|
+
<IconButton disabled>
|
|
180
|
+
<CloudDownload />
|
|
181
|
+
<KeyboardArrowDownOutlinedIcon className={classes.arrowdownIconDisabled} />
|
|
182
|
+
</IconButton>
|
|
183
|
+
)
|
|
184
|
+
}
|
|
172
185
|
</Tooltip>
|
|
173
186
|
<div className={classes.dropdownList} style={{ display: listDisplay }}>
|
|
174
187
|
<div id="dropdownListItemCSV" className={classes.dropdownListItem} onClick={downloadTableCSV}>CSV</div>
|