@bento-core/table 1.0.1-icdc.1 → 1.0.1-icdc.11

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.
@@ -0,0 +1,4 @@
1
+ Refer to [PaginatedTable](../paginated-table/README.md)
2
+ <br>
3
+ Table view
4
+ ![image info](./table_components.png)
@@ -28,7 +28,8 @@ const ExtendedView = _ref => {
28
28
  server
29
29
  } = _ref;
30
30
  const {
31
- extendedViewConfig
31
+ extendedViewConfig,
32
+ rowsPerPageOptions
32
33
  } = table;
33
34
  if (!extendedViewConfig) {
34
35
  return null;
@@ -57,7 +58,7 @@ const ExtendedView = _ref => {
57
58
  onColumnViewChange: onColumnViewChange
58
59
  })), pagination && /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
59
60
  customTheme: customTheme.tblTopPgn,
60
- rowsPerPageOptions: [10, 25, 50, 100],
61
+ rowsPerPageOptions: rowsPerPageOptions || [10, 25, 50, 100],
61
62
  component: "div",
62
63
  count: table.totalRowCount || 0,
63
64
  rowsPerPage: table.rowsPerPage || 10,
package/dist/TableView.js CHANGED
@@ -68,7 +68,9 @@ const TableView = _ref => {
68
68
  customTheme: themeConfig.toolbar
69
69
  }), /*#__PURE__*/_react.default.createElement(CustomTableContainer, {
70
70
  customTheme: themeConfig.tblContainer || {}
71
- }, /*#__PURE__*/_react.default.createElement(_core.Table, null, /*#__PURE__*/_react.default.createElement(_CustomTblHeader.default, {
71
+ }, /*#__PURE__*/_react.default.createElement(_core.TableContainer, {
72
+ component: _core.Paper
73
+ }, /*#__PURE__*/_react.default.createElement(_core.Table, table.tblAttr, /*#__PURE__*/_react.default.createElement(_CustomTblHeader.default, {
72
74
  customTheme: themeConfig.tblHeader,
73
75
  table: table,
74
76
  rows: tableRows,
@@ -82,12 +84,12 @@ const TableView = _ref => {
82
84
  table: table,
83
85
  onRowSelectChange: onRowSelectChange,
84
86
  onDeleteRow: onDeleteRow
85
- }))), tableRows.length === 0 && /*#__PURE__*/_react.default.createElement(_DisplayErrMsg.default, {
87
+ })))), tableRows.length === 0 && /*#__PURE__*/_react.default.createElement(_DisplayErrMsg.default, {
86
88
  customTheme: themeConfig.displayErr,
87
89
  table: table
88
90
  }), /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
89
91
  customTheme: themeConfig.tblPgn,
90
- rowsPerPageOptions: [10, 25, 50, 100],
92
+ rowsPerPageOptions: table.rowsPerPageOptions || [10, 25, 50, 100],
91
93
  component: "div",
92
94
  count: table.totalRowCount || 0,
93
95
  rowsPerPage: table.rowsPerPage || 10,
@@ -21,7 +21,10 @@ const CheckboxView = _ref => {
21
21
  }, /*#__PURE__*/_react.default.createElement(_core.Checkbox, {
22
22
  disableRipple: true,
23
23
  onClick: event => onRowSelectChange(event, row),
24
- checked: row.isChecked
24
+ checked: row.isChecked,
25
+ inputProps: {
26
+ 'aria-label': 'checkbox'
27
+ }
25
28
  })));
26
29
  };
27
30
  var _default = CheckboxView;
@@ -23,6 +23,7 @@ const DeleteCellView = _ref => {
23
23
  }, customCellRender ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, customCellRender(row, onDeleteRow)) : /*#__PURE__*/_react.default.createElement(_core.IconButton, {
24
24
  disableRipple: true,
25
25
  className: "del_row_btn",
26
+ "aria-label": "delete",
26
27
  onClick: () => column.cellEventHandler(row)
27
28
  }, /*#__PURE__*/_react.default.createElement(_icons.DeleteOutline, {
28
29
  className: "del_row_btn_icon",
@@ -26,7 +26,8 @@ const ActionHeaderCell = _ref => {
26
26
  return /*#__PURE__*/_react.default.createElement(_CheckBoxView.default, {
27
27
  includeSelectedIds: includeSelectedIds,
28
28
  toggleSelectAll: toggleSelectAll,
29
- Ids: Ids
29
+ Ids: Ids,
30
+ rows: rows
30
31
  });
31
32
  }
32
33
  if (_Types.cellTypes.DELETE === cellType) {
@@ -42,7 +42,8 @@ const ColumnGrouping = _ref => {
42
42
  if (colSpan > 0) {
43
43
  return /*#__PURE__*/_react.default.createElement(_core.TableCell, {
44
44
  colSpan: colSpan,
45
- className: clsName
45
+ className: clsName,
46
+ component: !title || !customViewRender ? 'td' : 'th'
46
47
  }, customViewRender ? customViewRender() : title);
47
48
  }
48
49
  return null;
@@ -7,20 +7,33 @@ exports.default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _core = require("@material-ui/core");
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ const useStyles = (0, _core.makeStyles)({
11
+ label: {
12
+ opacity: '0'
13
+ }
14
+ });
10
15
  const CheckboxView = _ref => {
11
16
  let {
12
17
  includeSelectedIds,
13
18
  toggleSelectAll,
14
- Ids
19
+ Ids,
20
+ rows
15
21
  } = _ref;
22
+ const {
23
+ label
24
+ } = useStyles();
16
25
  return /*#__PURE__*/_react.default.createElement(_core.TableCell, {
17
- padding: "checkbox"
26
+ padding: "checkbox",
27
+ component: "td"
18
28
  }, /*#__PURE__*/_react.default.createElement(_core.FormControlLabel, {
29
+ classes: {
30
+ label
31
+ },
19
32
  control: /*#__PURE__*/_react.default.createElement(_core.Checkbox, {
20
33
  color: "primary",
21
34
  indeterminate: includeSelectedIds,
22
35
  checked: includeSelectedIds,
23
- onChange: event => toggleSelectAll(event, Ids, includeSelectedIds)
36
+ onChange: event => toggleSelectAll(event, Ids, includeSelectedIds, rows)
24
37
  })
25
38
  }));
26
39
  };
@@ -55,6 +55,12 @@ const CustomPagination = _ref => {
55
55
  }, /*#__PURE__*/_react.default.createElement(_core.TablePagination, {
56
56
  rowsPerPageOptions: rowsPerPageOptions,
57
57
  component: "div",
58
+ SelectProps: {
59
+ inputProps: {
60
+ title: 'checkbox',
61
+ 'aria-label': 'checkbox'
62
+ }
63
+ },
58
64
  count: count,
59
65
  rowsPerPage: rowsPerPage,
60
66
  page: page,
@@ -53,11 +53,14 @@ const DownloadButton = _ref => {
53
53
  (0, _downloadTable.downloadJson)(result, table, downloadFileName);
54
54
  }
55
55
  const downloadTableCSV = (0, _react.useCallback)(() => {
56
+ // custom download from bento app
56
57
  if (downloadTable) {
57
- downloadTable();
58
+ downloadTable(queryVariables);
58
59
  } else if (!downloadTable && !server) {
60
+ // download client table
59
61
  (0, _downloadTable.downloadJson)(rows, table, downloadFileName);
60
62
  } else {
63
+ // donwload server table
61
64
  downloadSCSVFile();
62
65
  }
63
66
  }, [queryVariables]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/table",
3
- "version": "1.0.1-icdc.1",
3
+ "version": "1.0.1-icdc.11",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -12,9 +12,6 @@
12
12
  "publishConfig": {
13
13
  "access": "public"
14
14
  },
15
- "dependencies": {
16
- "@bento-core/util": "^1.0.0"
17
- },
18
15
  "peerDependencies": {
19
16
  "@material-ui/core": "^4.12.4",
20
17
  "@material-ui/icons": "^4.9.1",
@@ -23,8 +20,9 @@
23
20
  "react-dom": "^17.0.0",
24
21
  "react-redux": "^7.2.1",
25
22
  "@apollo/client": "^3.6.9",
26
- "clsx": "^1.2.1"
23
+ "clsx": "^1.2.1",
24
+ "@bento-core/util": "^1.0.0"
27
25
  },
28
26
  "author": "CTOS Bento Team",
29
27
  "license": "ISC"
30
- }
28
+ }
@@ -19,7 +19,7 @@ const ExtendedView = ({
19
19
  queryVariables,
20
20
  server,
21
21
  }) => {
22
- const { extendedViewConfig } = table;
22
+ const { extendedViewConfig, rowsPerPageOptions } = table;
23
23
  if (!extendedViewConfig) {
24
24
  return null;
25
25
  }
@@ -56,7 +56,7 @@ const ExtendedView = ({
56
56
  (pagination) && (
57
57
  <CustomPagination
58
58
  customTheme={customTheme.tblTopPgn}
59
- rowsPerPageOptions={[10, 25, 50, 100]}
59
+ rowsPerPageOptions={rowsPerPageOptions || [10, 25, 50, 100]}
60
60
  component="div"
61
61
  count={table.totalRowCount || 0}
62
62
  rowsPerPage={table.rowsPerPage || 10}
package/src/TableView.js CHANGED
@@ -63,24 +63,28 @@ const TableView = ({
63
63
  <CustomTableContainer
64
64
  customTheme={themeConfig.tblContainer || {}}
65
65
  >
66
- <Table>
67
- <TableHeader
68
- customTheme={themeConfig.tblHeader}
69
- table={table}
70
- rows={tableRows}
71
- count={totalRowCount}
72
- toggleSelectAll={onToggleSelectAll}
73
- onDeleteAllFiles={onDeleteAllFiles}
74
- sortByColumn={onSortByColumn}
75
- />
76
- <CustomTableBody
77
- customTheme={themeConfig.tblBody}
78
- rows={tableRows}
79
- table={table}
80
- onRowSelectChange={onRowSelectChange}
81
- onDeleteRow={onDeleteRow}
82
- />
83
- </Table>
66
+ <TableContainer
67
+ component={Paper}
68
+ >
69
+ <Table {...table.tblAttr}>
70
+ <TableHeader
71
+ customTheme={themeConfig.tblHeader}
72
+ table={table}
73
+ rows={tableRows}
74
+ count={totalRowCount}
75
+ toggleSelectAll={onToggleSelectAll}
76
+ onDeleteAllFiles={onDeleteAllFiles}
77
+ sortByColumn={onSortByColumn}
78
+ />
79
+ <CustomTableBody
80
+ customTheme={themeConfig.tblBody}
81
+ rows={tableRows}
82
+ table={table}
83
+ onRowSelectChange={onRowSelectChange}
84
+ onDeleteRow={onDeleteRow}
85
+ />
86
+ </Table>
87
+ </TableContainer>
84
88
  </CustomTableContainer>
85
89
  {tableRows.length === 0 && (
86
90
  <DisplayErrMsg
@@ -90,7 +94,7 @@ const TableView = ({
90
94
  )}
91
95
  <CustomPagination
92
96
  customTheme={themeConfig.tblPgn}
93
- rowsPerPageOptions={[10, 25, 50, 100]}
97
+ rowsPerPageOptions={table.rowsPerPageOptions || [10, 25, 50, 100]}
94
98
  component="div"
95
99
  count={table.totalRowCount || 0}
96
100
  rowsPerPage={table.rowsPerPage || 10}
@@ -23,6 +23,9 @@ const CheckboxView = ({
23
23
  disableRipple
24
24
  onClick={(event) => onRowSelectChange(event, row)}
25
25
  checked={row.isChecked}
26
+ inputProps={{
27
+ 'aria-label': 'checkbox',
28
+ }}
26
29
  />
27
30
  </TableCell>
28
31
  )
@@ -27,6 +27,7 @@ const DeleteCellView = ({
27
27
  <IconButton
28
28
  disableRipple
29
29
  className="del_row_btn"
30
+ aria-label="delete"
30
31
  onClick={() => column.cellEventHandler(row)}
31
32
  >
32
33
  <DeleteOutlineIcon
@@ -20,6 +20,7 @@ const ActionHeaderCell = ({
20
20
  includeSelectedIds={includeSelectedIds}
21
21
  toggleSelectAll={toggleSelectAll}
22
22
  Ids={Ids}
23
+ rows={rows}
23
24
  />
24
25
  );
25
26
  }
@@ -41,7 +41,7 @@ const ColumnGrouping = ({
41
41
  const colSpan = getColSpan(columnIndexes);
42
42
  if (colSpan > 0) {
43
43
  return (
44
- <TableCell colSpan={colSpan} className={clsName}>
44
+ <TableCell colSpan={colSpan} className={clsName} component={!title || !customViewRender ? 'td' : 'th'}>
45
45
  {customViewRender ? customViewRender() : title}
46
46
  </TableCell>
47
47
  );
@@ -3,25 +3,39 @@ import {
3
3
  TableCell,
4
4
  Checkbox,
5
5
  FormControlLabel,
6
+ makeStyles,
6
7
  } from '@material-ui/core';
7
8
 
9
+ const useStyles = makeStyles({
10
+ label: {
11
+ opacity: '0',
12
+ },
13
+ });
14
+
8
15
  const CheckboxView = ({
9
16
  includeSelectedIds,
10
17
  toggleSelectAll,
11
18
  Ids,
12
- }) => (
13
- <TableCell padding="checkbox">
14
- <FormControlLabel
15
- control={(
16
- <Checkbox
17
- color="primary"
18
- indeterminate={includeSelectedIds}
19
- checked={includeSelectedIds}
20
- onChange={(event) => toggleSelectAll(event, Ids, includeSelectedIds)}
21
- />
22
- )}
23
- />
24
- </TableCell>
25
- );
19
+ rows,
20
+ }) => {
21
+ const { label } = useStyles();
22
+ return (
23
+ <TableCell padding="checkbox" component="td">
24
+ <FormControlLabel
25
+ classes={{
26
+ label,
27
+ }}
28
+ control={(
29
+ <Checkbox
30
+ color="primary"
31
+ indeterminate={includeSelectedIds}
32
+ checked={includeSelectedIds}
33
+ onChange={(event) => toggleSelectAll(event, Ids, includeSelectedIds, rows)}
34
+ />
35
+ )}
36
+ />
37
+ </TableCell>
38
+ );
39
+ };
26
40
 
27
41
  export default CheckboxView;
@@ -45,6 +45,12 @@ const CustomPagination = ({
45
45
  <TablePagination
46
46
  rowsPerPageOptions={rowsPerPageOptions}
47
47
  component="div"
48
+ SelectProps={{
49
+ inputProps: {
50
+ title: 'checkbox',
51
+ 'aria-label': 'checkbox',
52
+ },
53
+ }}
48
54
  count={count}
49
55
  rowsPerPage={rowsPerPage}
50
56
  page={page}
@@ -49,11 +49,14 @@ const DownloadButton = ({
49
49
  }
50
50
 
51
51
  const downloadTableCSV = useCallback(() => {
52
+ // custom download from bento app
52
53
  if (downloadTable) {
53
- downloadTable();
54
+ downloadTable(queryVariables);
54
55
  } else if (!downloadTable && !server) {
56
+ // download client table
55
57
  downloadJson(rows, table, downloadFileName);
56
58
  } else {
59
+ // donwload server table
57
60
  downloadSCSVFile();
58
61
  }
59
62
  }, [queryVariables]);
Binary file