@bento-core/table 0.2.0

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.
Files changed (58) hide show
  1. package/babel.config.json +20 -0
  2. package/dist/DefaultThemConfig.js +68 -0
  3. package/dist/ExtendedView.js +64 -0
  4. package/dist/TableView.js +90 -0
  5. package/dist/body/ActionBodyCell.js +37 -0
  6. package/dist/body/CustomTblBody.js +64 -0
  7. package/dist/body/DefaultThemConfig.js +84 -0
  8. package/dist/body/DisplayBodyCell.js +80 -0
  9. package/dist/body/components/CheckBoxView.js +24 -0
  10. package/dist/body/components/CustomLinkView.js +30 -0
  11. package/dist/body/components/DataFormatView.js +43 -0
  12. package/dist/body/components/DeleteCellView.js +29 -0
  13. package/dist/errMsg/DefaultThemConfig.js +19 -0
  14. package/dist/errMsg/DisplayErrMsg.js +44 -0
  15. package/dist/header/ActionHeaderCell.js +42 -0
  16. package/dist/header/CustomCell.js +47 -0
  17. package/dist/header/CustomTblHeader.js +82 -0
  18. package/dist/header/DefaultThemConfig.js +160 -0
  19. package/dist/header/components/CheckBoxView.js +28 -0
  20. package/dist/header/components/DeleteCellView.js +47 -0
  21. package/dist/header/components/RemoveAllDialog.js +36 -0
  22. package/dist/index.js +45 -0
  23. package/dist/pagination/CustomPagination.js +74 -0
  24. package/dist/toolbar/CustomToolbar.js +53 -0
  25. package/dist/toolbar/DownloadButtonView.js +23 -0
  26. package/dist/toolbar/ManageColumnView.js +110 -0
  27. package/dist/util/ClassNames.js +22 -0
  28. package/dist/util/Dataformat.js +14 -0
  29. package/dist/util/Types.js +53 -0
  30. package/package.json +25 -0
  31. package/src/DefaultThemConfig.js +62 -0
  32. package/src/ExtendedView.js +63 -0
  33. package/src/TableView.js +94 -0
  34. package/src/body/ActionBodyCell.js +39 -0
  35. package/src/body/CustomTblBody.js +68 -0
  36. package/src/body/DefaultThemConfig.js +79 -0
  37. package/src/body/DisplayBodyCell.js +78 -0
  38. package/src/body/components/CheckBoxView.js +20 -0
  39. package/src/body/components/CustomLinkView.js +25 -0
  40. package/src/body/components/DataFormatView.js +44 -0
  41. package/src/body/components/DeleteCellView.js +31 -0
  42. package/src/errMsg/DefaultThemConfig.js +13 -0
  43. package/src/errMsg/DisplayErrMsg.js +40 -0
  44. package/src/header/ActionHeaderCell.js +42 -0
  45. package/src/header/CustomCell.js +51 -0
  46. package/src/header/CustomTblHeader.js +87 -0
  47. package/src/header/DefaultThemConfig.js +154 -0
  48. package/src/header/components/CheckBoxView.js +27 -0
  49. package/src/header/components/DeleteCellView.js +61 -0
  50. package/src/header/components/RemoveAllDialog.js +54 -0
  51. package/src/index.js +8 -0
  52. package/src/pagination/CustomPagination.js +66 -0
  53. package/src/toolbar/CustomToolbar.js +52 -0
  54. package/src/toolbar/DownloadButtonView.js +29 -0
  55. package/src/toolbar/ManageColumnView.js +134 -0
  56. package/src/util/ClassNames.js +17 -0
  57. package/src/util/Dataformat.js +8 -0
  58. package/src/util/Types.js +39 -0
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import {
3
+ Dialog,
4
+ DialogActions,
5
+ DialogContent,
6
+ DialogContentText,
7
+ Button,
8
+ } from '@material-ui/core';
9
+
10
+ function RemoveAllDialogView(props) {
11
+ const {
12
+ open,
13
+ toggleDisplay,
14
+ count,
15
+ removeAllFiles,
16
+ } = props;
17
+ const deleteAllFiles = () => {
18
+ removeAllFiles();
19
+ toggleDisplay();
20
+ };
21
+ return (
22
+ <>
23
+ <Dialog
24
+ open={open}
25
+ aria-labelledby="alert-dialog-title"
26
+ aria-describedby="alert-dialog-description"
27
+ >
28
+ <DialogContent>
29
+ <DialogContentText id="alert-dialog-description">
30
+ Remove
31
+ {' '}
32
+ <b>
33
+ All files
34
+ {' ('}
35
+ {count}
36
+ {') '}
37
+ </b>
38
+ From Cart
39
+ </DialogContentText>
40
+ </DialogContent>
41
+ <DialogActions>
42
+ <Button className="okBtn" onClick={deleteAllFiles}>
43
+ Ok
44
+ </Button>
45
+ <Button className="cancelBtn" onClick={() => toggleDisplay()}>
46
+ Cancel
47
+ </Button>
48
+ </DialogActions>
49
+ </Dialog>
50
+ </>
51
+ );
52
+ }
53
+
54
+ export default RemoveAllDialogView;
package/src/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export { default as TableView } from './TableView';
2
+ export {
3
+ cellTypes,
4
+ headerTypes,
5
+ ComponentTypes,
6
+ dataFormatTypes,
7
+ } from './util/Types';
8
+ export { formatBytes } from './util/Dataformat';
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import {
4
+ createTheme,
5
+ TablePagination,
6
+ ThemeProvider,
7
+ } from '@material-ui/core';
8
+
9
+ const defaultTheme = {
10
+ MuiTablePagination: {
11
+ root: {
12
+ paddingRight: '50px',
13
+ borderTop: '3px solid #42779a',
14
+ },
15
+ toolbar: {
16
+ minHeight: '45px',
17
+ },
18
+ },
19
+ MuiTypography: {
20
+ body2: {
21
+ fontSize: '14px',
22
+ textTransform: 'uppercase',
23
+ },
24
+ root: {
25
+ fontSize: '14px',
26
+ },
27
+ },
28
+ MuiIconButton: {
29
+ root: {
30
+ padding: '2px',
31
+ },
32
+ },
33
+ };
34
+
35
+ const CustomPagination = ({
36
+ rowsPerPageOptions,
37
+ count,
38
+ rowsPerPage,
39
+ page,
40
+ onPageChange,
41
+ onRowsPerPageChange,
42
+ customTheme = {},
43
+ }) => (
44
+ <ThemeProvider theme={createTheme({ overrides: { ...defaultTheme, ...customTheme } })}>
45
+ <TablePagination
46
+ rowsPerPageOptions={rowsPerPageOptions}
47
+ component="div"
48
+ count={count}
49
+ rowsPerPage={rowsPerPage}
50
+ page={page}
51
+ onPageChange={onPageChange}
52
+ onRowsPerPageChange={onRowsPerPageChange}
53
+ />
54
+ </ThemeProvider>
55
+ );
56
+
57
+ CustomPagination.propTypes = {
58
+ rowsPerPageOptions: PropTypes.arrayOf(PropTypes.number).isRequired,
59
+ count: PropTypes.number.isRequired,
60
+ rowsPerPage: PropTypes.number.isRequired,
61
+ page: PropTypes.number.isRequired,
62
+ onPageChange: PropTypes.func.isRequired,
63
+ onRowsPerPageChange: PropTypes.func.isRequired,
64
+ };
65
+
66
+ export default CustomPagination;
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import {
4
+ createTheme,
5
+ ThemeProvider,
6
+ Toolbar,
7
+ Typography,
8
+ } from '@material-ui/core';
9
+
10
+ const defaultTheme = {
11
+ MuiToolbar: {
12
+ root: {
13
+ display: 'flex',
14
+ zIndex: '120',
15
+ minHeight: '25px',
16
+ borderTop: '2px solid #e7e5e5',
17
+ alignItems: 'center',
18
+ paddingTop: '8px',
19
+ paddingBottom: '8px',
20
+ justifyContent: 'space-between',
21
+ backgroundColor: '#ffffff',
22
+ },
23
+ regular: {
24
+ '@media (min-width: 600px)': {
25
+ minHeight: '25px',
26
+ },
27
+ },
28
+ },
29
+ };
30
+
31
+ const CustomToolbar = ({
32
+ numSelected,
33
+ customTheme = {},
34
+ }) => (
35
+ <ThemeProvider theme={createTheme({ overrides: { ...defaultTheme, ...customTheme } })}>
36
+ {numSelected > 0 && (
37
+ <Toolbar>
38
+ <Typography
39
+ component="div"
40
+ >
41
+ {`${numSelected} row(s) selected`}
42
+ </Typography>
43
+ </Toolbar>
44
+ )}
45
+ </ThemeProvider>
46
+ );
47
+
48
+ CustomToolbar.propTypes = {
49
+ numSelected: PropTypes.number.isRequired,
50
+ };
51
+
52
+ export default CustomToolbar;
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import {
3
+ IconButton,
4
+ Tooltip,
5
+ } from '@material-ui/core';
6
+ import {
7
+ CloudDownload,
8
+ } from '@material-ui/icons';
9
+
10
+ const DownloadButton = ({
11
+ download
12
+ }) => {
13
+ if (!download) {
14
+ return null;
15
+ }
16
+
17
+ return (
18
+ <>
19
+ <Tooltip title={download.downloadCsv}>
20
+ <IconButton
21
+ >
22
+ <CloudDownload />
23
+ </IconButton>
24
+ </Tooltip>
25
+ </>
26
+ )
27
+ }
28
+
29
+ export default DownloadButton;
@@ -0,0 +1,134 @@
1
+ import React, { useState } from 'react';
2
+ import {
3
+ Checkbox,
4
+ IconButton,
5
+ List,
6
+ ListItem,
7
+ Popover,
8
+ Tooltip,
9
+ Typography,
10
+ withStyles,
11
+ } from '@material-ui/core';
12
+ import {
13
+ ViewColumn,
14
+ CheckBox as CheckBoxIcon,
15
+ CheckBoxOutlineBlank as CheckBoxBlankIcon,
16
+ Close,
17
+ } from '@material-ui/icons';
18
+ import { cellTypes } from '../util/Types';
19
+
20
+ const ManageColumnView = ({
21
+ classes,
22
+ table,
23
+ onColumnViewChange,
24
+ manageViewColumns,
25
+ }) => {
26
+ if (!manageViewColumns) {
27
+ return null;
28
+ }
29
+ const [anchorEl, setAnchorEl] = useState(null);
30
+ const handleClick = (event) => {
31
+ setAnchorEl(event.currentTarget);
32
+ };
33
+
34
+ const handleClose = () => setAnchorEl(null);
35
+
36
+ const open = Boolean(anchorEl);
37
+ const { columns } = table;
38
+ const viewColumns = columns.filter((col) => col.role === cellTypes.DISPLAY);
39
+
40
+ return (
41
+ <>
42
+ <Tooltip title={manageViewColumns.title}>
43
+ <IconButton variant="contained" onClick={handleClick}>
44
+ <ViewColumn />
45
+ </IconButton>
46
+ </Tooltip>
47
+ <Popover
48
+ open={open}
49
+ anchorEl={anchorEl}
50
+ onClose={handleClose}
51
+ anchorOrigin={{
52
+ vertical: 'bottom',
53
+ horizontal: 'left',
54
+ }}
55
+ >
56
+ <Typography variant="caption" className="viewColumnText">
57
+ {manageViewColumns.title}
58
+ </Typography>
59
+ <IconButton
60
+ onClick={handleClose}
61
+ className="closeIcon"
62
+ >
63
+ <Close />
64
+ </IconButton>
65
+ <List className="viewColumnList">
66
+ {viewColumns.map((column) => (
67
+ <ListItem
68
+ width={1}
69
+ className="viewColumnListItem"
70
+ >
71
+ <Checkbox
72
+ icon={
73
+ <CheckBoxBlankIcon
74
+ style={{ fontSize: 18 }}
75
+ className="checkBoxIcon"
76
+ />
77
+ }
78
+ onClick={() => onColumnViewChange(column)}
79
+ checked={column.display}
80
+ checkedIcon={(
81
+ <CheckBoxIcon
82
+ style={{
83
+ fontSize: 18,
84
+ }}
85
+ className="checkBoxIcon"
86
+ />
87
+ )}
88
+ disableRipple
89
+ color="secondary"
90
+ className="checkBox"
91
+ />
92
+ <Typography>{column.header}</Typography>
93
+ </ListItem>
94
+ ))}
95
+ </List>
96
+ </Popover>
97
+ </>
98
+ );
99
+ };
100
+
101
+ const styles = () => ({
102
+ root: {
103
+ padding: '16px 24px 16px 24px',
104
+ fontFamily: 'Roboto',
105
+ },
106
+ title: {
107
+ marginRight: '24px',
108
+ fontSize: '14px',
109
+ color: '#0B3556',
110
+ textAlign: 'left',
111
+ fontWeight: 500,
112
+ },
113
+ formGroup: {
114
+ marginTop: '8px',
115
+ },
116
+ formControl: {},
117
+ checkbox: {
118
+ padding: '0px',
119
+ width: '32px',
120
+ height: '32px',
121
+ },
122
+ checkboxRoot: {
123
+ '&$checked': {
124
+ color: '#0B3556',
125
+ },
126
+ },
127
+ checked: {},
128
+ label: {
129
+ fontSize: '15px',
130
+ marginLeft: '8px',
131
+ },
132
+ });
133
+
134
+ export default withStyles(styles)(ManageColumnView);
@@ -0,0 +1,17 @@
1
+ export const tableCls = {
2
+ HEADER: 'header',
3
+ BODY: 'body',
4
+ ROW: '_row',
5
+ COL: '_col',
6
+ CHECKBOX: '_checkbox',
7
+ CHECKBOX_ACTIVE: '_checkbox_active',
8
+ CHECKBOX_INACTIVE: '_checkbox_in_active',
9
+ TOOLTIP: '_tooltip',
10
+ };
11
+
12
+ export const getClsName = (prefix, postfix) => {
13
+ const className = `${prefix}`
14
+ .replace(' ', '_')
15
+ .toLowerCase().concat(`_${postfix}`);
16
+ return className;
17
+ };
@@ -0,0 +1,8 @@
1
+
2
+ export function formatBytes(bytes, decimals = 2) {
3
+ if (bytes === 0) return '0 Bytes';
4
+ const dm = decimals < 0 ? 0 : decimals;
5
+ const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
6
+ const i = Math.floor(Math.log(bytes) / Math.log(1024));
7
+ return `${parseFloat((bytes / (1024 ** i)).toFixed(dm))} ${sizes[i]}`;
8
+ }
@@ -0,0 +1,39 @@
1
+ export const CHECKBOX = 'CHECKBOX';
2
+ export const DELETE = 'DELETE';
3
+ export const CUSTOM_ELEM = 'CUSTOM_ELEM';
4
+ export const LINK = 'LINK';
5
+ export const DISPLAY = 'DISPLAY';
6
+ export const DEFAULT = 'DEFAULT';
7
+ export const FORMAT_DATA = 'FORMAT_DATA';
8
+ export const FORMAT_BYTES = 'FORMAT_BYTES';
9
+
10
+ export const cellTypes = {
11
+ CUSTOM_ELEM: CUSTOM_ELEM,
12
+ LINK: LINK,
13
+ DISPLAY: DISPLAY,
14
+ CHECKBOX: CHECKBOX,
15
+ DELETE: DELETE,
16
+ DEFAULT: DEFAULT,
17
+ FORMAT_DATA: FORMAT_DATA,
18
+ };
19
+
20
+ export const actionCellTypes = [CHECKBOX, DELETE];
21
+
22
+ export const FORMAT_DATA_CELLS = [FORMAT_BYTES];
23
+
24
+ export const dataFormatTypes = {
25
+ FORMAT_BYTES: 'FORMAT_BYTES',
26
+ }
27
+
28
+ export const headerTypes = {
29
+ CUSTOM_ELEM: CUSTOM_ELEM,
30
+ DELETE: DELETE,
31
+ DEFAULT: DEFAULT,
32
+ };
33
+
34
+ export const ComponentTypes = {
35
+ PAGINATION: 'PAGINATION',
36
+ MANAGE_VIEW_COLUMNS: 'MANAGE_VIEW_COLUMNS',
37
+ DOWNLOAD_TABLE_BTN: 'DOWNLOAD_TABLE_BTN',
38
+ CUSTOM_ELEM: 'CUSTOM_ELEM',
39
+ };