@bento-core/table 1.0.1-ins.3 → 1.0.1-ins.5

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.
@@ -16,16 +16,20 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
16
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; }
17
17
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
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); }
19
+ const downloadAreaStyle = {
20
+ display: 'flex',
21
+ borderTop: '1px solid #8A7F7C',
22
+ paddingRight: '41px'
23
+ };
19
24
  const ExtendedView = _ref => {
20
25
  let {
21
26
  table,
22
- rows,
23
27
  onColumnViewChange,
24
28
  onRowsPerPageChange,
25
29
  onPageChange,
30
+ numSelected = 0,
26
31
  customTheme,
27
- queryVariables,
28
- server
32
+ queryVariables
29
33
  } = _ref;
30
34
  const {
31
35
  extendedViewConfig
@@ -43,19 +47,16 @@ const ExtendedView = _ref => {
43
47
  });
44
48
  return /*#__PURE__*/_react.default.createElement(_core.ThemeProvider, {
45
49
  theme: themeConfig
46
- }, (download || manageViewColumns) && /*#__PURE__*/_react.default.createElement(_core.Toolbar, {
47
- className: "downloadAndColumnView"
48
- }, /*#__PURE__*/_react.default.createElement(_DownloadButtonView.default, {
49
- download: download,
50
- rows: rows,
51
- server: server,
52
- table: table,
53
- queryVariables: queryVariables
54
- }), /*#__PURE__*/_react.default.createElement(_ManageColumnView.default, {
50
+ }, numSelected === 0 && (download || manageViewColumns) && /*#__PURE__*/_react.default.createElement(_core.Toolbar, {
51
+ className: "downloadColumnView"
52
+ }, /*#__PURE__*/_react.default.createElement(_ManageColumnView.default, {
55
53
  table: table,
56
54
  manageViewColumns: manageViewColumns,
57
55
  onColumnViewChange: onColumnViewChange
58
- })), pagination && /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
56
+ })), pagination && /*#__PURE__*/_react.default.createElement("div", {
57
+ className: "downloadArea",
58
+ style: downloadAreaStyle
59
+ }, /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
59
60
  customTheme: customTheme.tblTopPgn,
60
61
  rowsPerPageOptions: [10, 25, 50, 100],
61
62
  component: "div",
@@ -63,8 +64,14 @@ const ExtendedView = _ref => {
63
64
  rowsPerPage: table.rowsPerPage || 10,
64
65
  page: table.page || 0,
65
66
  onPageChange: onPageChange,
66
- onRowsPerPageChange: onRowsPerPageChange
67
- }));
67
+ onRowsPerPageChange: onRowsPerPageChange,
68
+ queryVariables: queryVariables,
69
+ table: table
70
+ }), /*#__PURE__*/_react.default.createElement(_DownloadButtonView.default, {
71
+ count: table.totalRowCount || 0,
72
+ queryVariables: queryVariables,
73
+ table: table
74
+ })));
68
75
  };
69
76
  var _default = ExtendedView;
70
77
  exports.default = _default;
package/dist/TableView.js CHANGED
@@ -12,6 +12,7 @@ var _CustomTblBody = _interopRequireDefault(require("./body/CustomTblBody"));
12
12
  var _CustomToolbar = _interopRequireDefault(require("./toolbar/CustomToolbar"));
13
13
  var _DisplayErrMsg = _interopRequireDefault(require("./errMsg/DisplayErrMsg"));
14
14
  var _ExtendedView = _interopRequireDefault(require("./ExtendedView"));
15
+ var _DownloadButtonView = _interopRequireDefault(require("./toolbar/DownloadButtonView"));
15
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
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; }
17
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; }
@@ -32,11 +33,15 @@ const CustomTableContainer = props => {
32
33
  component: _core.Paper
33
34
  }, children));
34
35
  };
36
+ const downloadAreaStyle = {
37
+ display: 'flex',
38
+ borderBottom: '1px solid #8A7F7C',
39
+ paddingRight: '41px'
40
+ };
35
41
  const TableView = _ref => {
36
42
  var _table$selectedRows, _table$selectedRows2;
37
43
  let {
38
44
  tableRows = [],
39
- totalRows = [],
40
45
  table,
41
46
  onRowsPerPageChange,
42
47
  onPageChange,
@@ -46,13 +51,10 @@ const TableView = _ref => {
46
51
  onSortByColumn,
47
52
  onColumnViewChange,
48
53
  themeConfig = {},
49
- queryVariables,
50
- server
54
+ queryVariables
51
55
  } = _ref;
52
56
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ExtendedView.default, {
53
57
  table: table,
54
- rows: totalRows,
55
- server: server,
56
58
  onColumnViewChange: onColumnViewChange,
57
59
  onRowsPerPageChange: onRowsPerPageChange,
58
60
  onPageChange: onPageChange,
@@ -81,7 +83,10 @@ const TableView = _ref => {
81
83
  }))), tableRows.length === 0 && /*#__PURE__*/_react.default.createElement(_DisplayErrMsg.default, {
82
84
  customTheme: themeConfig.displayErr,
83
85
  table: table
84
- }), /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
86
+ }), /*#__PURE__*/_react.default.createElement("div", {
87
+ className: "downloadArea",
88
+ style: downloadAreaStyle
89
+ }, /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
85
90
  customTheme: themeConfig.tblPgn,
86
91
  rowsPerPageOptions: [10, 25, 50, 100],
87
92
  component: "div",
@@ -90,7 +95,11 @@ const TableView = _ref => {
90
95
  page: table.page || 0,
91
96
  onPageChange: onPageChange,
92
97
  onRowsPerPageChange: onRowsPerPageChange
93
- }));
98
+ }), /*#__PURE__*/_react.default.createElement(_DownloadButtonView.default, {
99
+ count: table.totalRowCount || 0,
100
+ queryVariables: queryVariables,
101
+ table: table
102
+ })));
94
103
  };
95
104
  var _default = TableView;
96
105
  exports.default = _default;
@@ -97,6 +97,10 @@ const defaultTheme = {
97
97
  }
98
98
  }
99
99
  };
100
+ const downloadAreaStyle = {
101
+ display: 'flex',
102
+ paddingRight: '41px'
103
+ };
100
104
  const CustomPagination = _ref => {
101
105
  let {
102
106
  rowsPerPageOptions,
@@ -111,6 +115,9 @@ const CustomPagination = _ref => {
111
115
  theme: (0, _core.createTheme)({
112
116
  overrides: _objectSpread(_objectSpread({}, defaultTheme), customTheme)
113
117
  })
118
+ }, /*#__PURE__*/_react.default.createElement("div", {
119
+ className: "downloadArea",
120
+ style: downloadAreaStyle
114
121
  }, /*#__PURE__*/_react.default.createElement(_core.TablePagination, {
115
122
  rowsPerPageOptions: rowsPerPageOptions,
116
123
  component: "div",
@@ -120,7 +127,7 @@ const CustomPagination = _ref => {
120
127
  onPageChange: onPageChange,
121
128
  onRowsPerPageChange: onRowsPerPageChange,
122
129
  ActionsComponent: TablePaginationActions
123
- }));
130
+ })));
124
131
  };
125
132
  CustomPagination.propTypes = {
126
133
  rowsPerPageOptions: _propTypes.default.arrayOf(_propTypes.default.number).isRequired,
@@ -16,28 +16,30 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
16
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; }
17
17
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
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); }
19
+ const downloadButtonStyle = {
20
+ color: '#d1d2d3',
21
+ marginTop: '7px'
22
+ };
19
23
  const DownloadButton = _ref => {
20
24
  let {
21
- download,
22
- rows,
23
- table,
25
+ count,
24
26
  queryVariables,
25
- server
27
+ table
26
28
  } = _ref;
27
- if (!download) {
28
- return null;
29
+ if (count === 0) {
30
+ return /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, {
31
+ className: "disableButton",
32
+ style: downloadButtonStyle
33
+ });
29
34
  }
30
- const {
31
- downloadCsv = 'download',
32
- downloadTable,
33
- downloadFileName
34
- } = download;
35
35
  const client = (0, _client.useApolloClient)();
36
+ const downloadFile = 'INS ';
36
37
  async function downloadSCSVFile() {
37
38
  const {
38
39
  query,
39
40
  paginationAPIField
40
41
  } = table;
42
+ const downloadFileName = downloadFile.concat(paginationAPIField.replace('OverView', ''), ' download');
41
43
  const result = await client.query({
42
44
  query,
43
45
  variables: _objectSpread(_objectSpread({}, queryVariables), {}, {
@@ -53,20 +55,13 @@ const DownloadButton = _ref => {
53
55
  (0, _downloadTable.downloadJson)(result, table, downloadFileName);
54
56
  }
55
57
  const downloadTableCSV = (0, _react.useCallback)(() => {
56
- if (downloadTable) {
57
- downloadTable();
58
- } else if (!downloadTable && !server) {
59
- (0, _downloadTable.downloadJson)(rows, table, downloadFileName);
60
- } else {
61
- downloadSCSVFile();
62
- }
58
+ downloadSCSVFile();
63
59
  }, [queryVariables]);
64
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
65
- title: downloadCsv,
66
- className: "download-icon"
60
+ return /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
61
+ title: "Download Full Table As CSV"
67
62
  }, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
68
63
  onClick: downloadTableCSV
69
- }, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null))));
64
+ }, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null)));
70
65
  };
71
66
  var _default = DownloadButton;
72
67
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/table",
3
- "version": "1.0.1-ins.3",
3
+ "version": "1.0.1-ins.5",
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",
@@ -9,21 +9,25 @@ import ManageColumnView from './toolbar/ManageColumnView';
9
9
  import defaultTheme from './DefaultThemConfig';
10
10
  import DownloadButton from './toolbar/DownloadButtonView';
11
11
 
12
+ const downloadAreaStyle = {
13
+ display: 'flex',
14
+ borderTop: '1px solid #8A7F7C',
15
+ paddingRight: '41px',
16
+ };
17
+
12
18
  const ExtendedView = ({
13
19
  table,
14
- rows,
15
20
  onColumnViewChange,
16
21
  onRowsPerPageChange,
17
22
  onPageChange,
23
+ numSelected = 0,
18
24
  customTheme,
19
25
  queryVariables,
20
- server,
21
26
  }) => {
22
27
  const { extendedViewConfig } = table;
23
28
  if (!extendedViewConfig) {
24
29
  return null;
25
30
  }
26
-
27
31
  const {
28
32
  download = false,
29
33
  manageViewColumns = false,
@@ -31,41 +35,43 @@ const ExtendedView = ({
31
35
  } = extendedViewConfig;
32
36
 
33
37
  const themeConfig = createTheme({ overrides: { ...defaultTheme(), ...customTheme } });
34
-
35
38
  return (
36
39
  <ThemeProvider theme={themeConfig}>
37
- {(download || manageViewColumns) && (
38
- <Toolbar
39
- className="downloadAndColumnView"
40
- >
41
- <DownloadButton
42
- download={download}
43
- rows={rows}
44
- server={server}
45
- table={table}
46
- queryVariables={queryVariables}
47
- />
48
- <ManageColumnView
49
- table={table}
50
- manageViewColumns={manageViewColumns}
51
- onColumnViewChange={onColumnViewChange}
52
- />
53
- </Toolbar>
40
+ {(numSelected === 0 && (download || manageViewColumns)) && (
41
+ <Toolbar className="downloadColumnView">
42
+ {/* <DownloadButton
43
+ download={download}
44
+ /> */}
45
+ <ManageColumnView
46
+ table={table}
47
+ manageViewColumns={manageViewColumns}
48
+ onColumnViewChange={onColumnViewChange}
49
+ />
50
+ </Toolbar>
54
51
  )}
55
52
  {
56
- (pagination) && (
57
- <CustomPagination
58
- customTheme={customTheme.tblTopPgn}
59
- rowsPerPageOptions={[10, 25, 50, 100]}
60
- component="div"
61
- count={table.totalRowCount || 0}
62
- rowsPerPage={table.rowsPerPage || 10}
63
- page={table.page || 0}
64
- onPageChange={onPageChange}
65
- onRowsPerPageChange={onRowsPerPageChange}
66
- />
67
- )
68
- }
53
+ (pagination) && (
54
+ <div className="downloadArea" style={downloadAreaStyle}>
55
+ <CustomPagination
56
+ customTheme={customTheme.tblTopPgn}
57
+ rowsPerPageOptions={[10, 25, 50, 100]}
58
+ component="div"
59
+ count={table.totalRowCount || 0}
60
+ rowsPerPage={table.rowsPerPage || 10}
61
+ page={table.page || 0}
62
+ onPageChange={onPageChange}
63
+ onRowsPerPageChange={onRowsPerPageChange}
64
+ queryVariables={queryVariables}
65
+ table={table}
66
+ />
67
+ <DownloadButton
68
+ count={table.totalRowCount || 0}
69
+ queryVariables={queryVariables}
70
+ table={table}
71
+ />
72
+ </div>
73
+ )
74
+ }
69
75
  </ThemeProvider>
70
76
  );
71
77
  };
package/src/TableView.js CHANGED
@@ -12,6 +12,7 @@ import CustomTableBody from './body/CustomTblBody';
12
12
  import CustomToolbar from './toolbar/CustomToolbar';
13
13
  import DisplayErrMsg from './errMsg/DisplayErrMsg';
14
14
  import ExtendedView from './ExtendedView';
15
+ import DownloadButton from './toolbar/DownloadButtonView';
15
16
 
16
17
  const CustomTableContainer = (props) => {
17
18
  const { children, customTheme } = props;
@@ -25,9 +26,14 @@ const CustomTableContainer = (props) => {
25
26
  );
26
27
  };
27
28
 
29
+ const downloadAreaStyle = {
30
+ display: 'flex',
31
+ borderBottom: '1px solid #8A7F7C',
32
+ paddingRight: '41px',
33
+ };
34
+
28
35
  const TableView = ({
29
36
  tableRows = [],
30
- totalRows = [],
31
37
  table,
32
38
  onRowsPerPageChange,
33
39
  onPageChange,
@@ -38,13 +44,10 @@ const TableView = ({
38
44
  onColumnViewChange,
39
45
  themeConfig = {},
40
46
  queryVariables,
41
- server,
42
47
  }) => (
43
48
  <>
44
49
  <ExtendedView
45
50
  table={table}
46
- rows={totalRows}
47
- server={server}
48
51
  onColumnViewChange={onColumnViewChange}
49
52
  onRowsPerPageChange={onRowsPerPageChange}
50
53
  onPageChange={onPageChange}
@@ -84,16 +87,23 @@ const TableView = ({
84
87
  table={table}
85
88
  />
86
89
  )}
87
- <CustomPagination
88
- customTheme={themeConfig.tblPgn}
89
- rowsPerPageOptions={[10, 25, 50, 100]}
90
- component="div"
91
- count={table.totalRowCount || 0}
92
- rowsPerPage={table.rowsPerPage || 10}
93
- page={table.page || 0}
94
- onPageChange={onPageChange}
95
- onRowsPerPageChange={onRowsPerPageChange}
96
- />
90
+ <div className="downloadArea" style={downloadAreaStyle}>
91
+ <CustomPagination
92
+ customTheme={themeConfig.tblPgn}
93
+ rowsPerPageOptions={[10, 25, 50, 100]}
94
+ component="div"
95
+ count={table.totalRowCount || 0}
96
+ rowsPerPage={table.rowsPerPage || 10}
97
+ page={table.page || 0}
98
+ onPageChange={onPageChange}
99
+ onRowsPerPageChange={onRowsPerPageChange}
100
+ />
101
+ <DownloadButton
102
+ count={table.totalRowCount || 0}
103
+ queryVariables={queryVariables}
104
+ table={table}
105
+ />
106
+ </div>
97
107
  </>
98
108
  );
99
109
 
@@ -105,6 +105,11 @@ const defaultTheme = {
105
105
  },
106
106
  };
107
107
 
108
+ const downloadAreaStyle = {
109
+ display: 'flex',
110
+ paddingRight: '41px',
111
+ };
112
+
108
113
  const CustomPagination = ({
109
114
  rowsPerPageOptions,
110
115
  count,
@@ -115,16 +120,18 @@ const CustomPagination = ({
115
120
  customTheme = {},
116
121
  }) => (
117
122
  <ThemeProvider theme={createTheme({ overrides: { ...defaultTheme, ...customTheme } })}>
118
- <TablePagination
119
- rowsPerPageOptions={rowsPerPageOptions}
120
- component="div"
121
- count={count}
122
- rowsPerPage={rowsPerPage}
123
- page={page}
124
- onPageChange={onPageChange}
125
- onRowsPerPageChange={onRowsPerPageChange}
126
- ActionsComponent={TablePaginationActions}
127
- />
123
+ <div className="downloadArea" style={downloadAreaStyle}>
124
+ <TablePagination
125
+ rowsPerPageOptions={rowsPerPageOptions}
126
+ component="div"
127
+ count={count}
128
+ rowsPerPage={rowsPerPage}
129
+ page={page}
130
+ onPageChange={onPageChange}
131
+ onRowsPerPageChange={onRowsPerPageChange}
132
+ ActionsComponent={TablePaginationActions}
133
+ />
134
+ </div>
128
135
  </ThemeProvider>
129
136
  );
130
137
 
@@ -7,30 +7,32 @@ import {
7
7
  import { CloudDownload } from '@material-ui/icons';
8
8
  import { downloadJson } from '../util/downloadTable';
9
9
 
10
+ const downloadButtonStyle = {
11
+ color: '#d1d2d3',
12
+ marginTop: '7px',
13
+ };
14
+
10
15
  const DownloadButton = ({
11
- download,
12
- rows,
13
- table,
16
+ count,
14
17
  queryVariables,
15
- server,
18
+ table,
16
19
  }) => {
17
- if (!download) {
18
- return null;
20
+ if (count === 0) {
21
+ return <CloudDownload className="disableButton" style={downloadButtonStyle} />;
19
22
  }
20
- const {
21
- downloadCsv = 'download',
22
- downloadTable,
23
- downloadFileName,
24
- } = download;
25
23
 
26
24
  const client = useApolloClient();
27
25
 
26
+ const downloadFile = 'INS ';
27
+
28
28
  async function downloadSCSVFile() {
29
29
  const {
30
30
  query,
31
31
  paginationAPIField,
32
32
  } = table;
33
33
 
34
+ const downloadFileName = downloadFile.concat(paginationAPIField.replace('OverView', ''), ' download');
35
+
34
36
  const result = await client.query({
35
37
  query,
36
38
  variables: {
@@ -49,28 +51,17 @@ const DownloadButton = ({
49
51
  }
50
52
 
51
53
  const downloadTableCSV = useCallback(() => {
52
- if (downloadTable) {
53
- downloadTable();
54
- } else if (!downloadTable && !server) {
55
- downloadJson(rows, table, downloadFileName);
56
- } else {
57
- downloadSCSVFile();
58
- }
54
+ downloadSCSVFile();
59
55
  }, [queryVariables]);
60
56
 
61
57
  return (
62
- <>
63
- <Tooltip
64
- title={downloadCsv}
65
- className="download-icon"
58
+ <Tooltip title="Download Full Table As CSV">
59
+ <IconButton
60
+ onClick={downloadTableCSV}
66
61
  >
67
- <IconButton
68
- onClick={downloadTableCSV}
69
- >
70
- <CloudDownload />
71
- </IconButton>
72
- </Tooltip>
73
- </>
62
+ <CloudDownload />
63
+ </IconButton>
64
+ </Tooltip>
74
65
  );
75
66
  };
76
67