@bento-core/table 1.0.0-c3dc.17 → 1.0.0-c3dc.18
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 +0 -1
- package/dist/assets/downArrow.svg +3 -0
- package/dist/assets/leftArrow.svg +3 -0
- package/dist/assets/rightArrow.svg +3 -0
- package/dist/pagination/CustomPagination.js +77 -28
- package/dist/toolbar/DownloadButtonView.js +2 -1
- package/package.json +1 -1
- package/src/TableView.js +0 -1
- package/src/assets/downArrow.svg +3 -0
- package/src/assets/leftArrow.svg +3 -0
- package/src/assets/rightArrow.svg +3 -0
- package/src/pagination/CustomPagination.js +92 -41
- package/src/toolbar/DownloadButtonView.js +1 -0
package/dist/TableView.js
CHANGED
|
@@ -7,38 +7,58 @@ 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
|
|
10
|
+
var _icons = require("@material-ui/icons");
|
|
11
|
+
var _rightArrow = _interopRequireDefault(require("../assets/rightArrow.svg"));
|
|
12
|
+
var _leftArrow = _interopRequireDefault(require("../assets/leftArrow.svg"));
|
|
11
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
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; }
|
|
13
15
|
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; }
|
|
14
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; }
|
|
15
17
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
16
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); }
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
toolbar: {
|
|
24
|
-
minHeight: '45px'
|
|
25
|
-
}
|
|
19
|
+
const useStyles = (0, _core.makeStyles)(() => ({
|
|
20
|
+
paginationRoot: {
|
|
21
|
+
display: 'flex',
|
|
22
|
+
justifyContent: 'flex-end',
|
|
23
|
+
// Moves pagination to the right
|
|
24
|
+
paddingRight: '10px' // Optional spacing
|
|
26
25
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
}
|
|
31
45
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
MuiTypography: {
|
|
47
|
+
body2: {
|
|
48
|
+
fontSize: '14px',
|
|
49
|
+
textTransform: 'uppercase'
|
|
50
|
+
},
|
|
51
|
+
root: {
|
|
52
|
+
fontSize: '14px'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
MuiIconButton: {
|
|
56
|
+
root: {
|
|
57
|
+
padding: '2px'
|
|
58
|
+
}
|
|
39
59
|
}
|
|
40
60
|
}
|
|
41
|
-
};
|
|
61
|
+
});
|
|
42
62
|
const CustomPagination = _ref => {
|
|
43
63
|
let {
|
|
44
64
|
rowsPerPageOptions,
|
|
@@ -46,12 +66,12 @@ const CustomPagination = _ref => {
|
|
|
46
66
|
rowsPerPage,
|
|
47
67
|
page,
|
|
48
68
|
onPageChange,
|
|
49
|
-
onRowsPerPageChange
|
|
50
|
-
customTheme = {}
|
|
69
|
+
onRowsPerPageChange
|
|
51
70
|
} = _ref;
|
|
71
|
+
const classes = useStyles();
|
|
52
72
|
return /*#__PURE__*/_react.default.createElement(_core.ThemeProvider, {
|
|
53
|
-
theme: (0, _core.
|
|
54
|
-
overrides: _objectSpread(
|
|
73
|
+
theme: (0, _core.createMuiTheme)({
|
|
74
|
+
overrides: _objectSpread({}, defaultTheme.overrides)
|
|
55
75
|
})
|
|
56
76
|
}, /*#__PURE__*/_react.default.createElement(_core.TablePagination, {
|
|
57
77
|
labelRowsPerPage: "Results per Page:",
|
|
@@ -63,11 +83,40 @@ const CustomPagination = _ref => {
|
|
|
63
83
|
onPageChange: onPageChange,
|
|
64
84
|
onRowsPerPageChange: onRowsPerPageChange,
|
|
65
85
|
SelectProps: {
|
|
66
|
-
IconComponent:
|
|
86
|
+
IconComponent: _icons.ArrowDropDown,
|
|
67
87
|
inputProps: {
|
|
68
88
|
'aria-label': 'Selection dropdown for displaying the number of results per page'
|
|
69
89
|
}
|
|
70
|
-
}
|
|
90
|
+
},
|
|
91
|
+
nextIconButtonProps: {
|
|
92
|
+
'aria-label': 'Next page'
|
|
93
|
+
},
|
|
94
|
+
backIconButtonProps: {
|
|
95
|
+
'aria-label': 'Previous page'
|
|
96
|
+
},
|
|
97
|
+
ActionsComponent: () => /*#__PURE__*/_react.default.createElement("div", {
|
|
98
|
+
className: classes.actionsContainer
|
|
99
|
+
}, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
100
|
+
onClick: event => onPageChange(event, page - 1),
|
|
101
|
+
disabled: page === 0,
|
|
102
|
+
"aria-label": "Previous page"
|
|
103
|
+
}, /*#__PURE__*/_react.default.createElement(_icons.ArrowDropDown, null), /*#__PURE__*/_react.default.createElement("img", {
|
|
104
|
+
src: _leftArrow.default,
|
|
105
|
+
style: {
|
|
106
|
+
opacity: page === 0 ? 0.2 : 1
|
|
107
|
+
},
|
|
108
|
+
alt: "Left Arrow"
|
|
109
|
+
})), /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
110
|
+
onClick: event => onPageChange(event, page + 1),
|
|
111
|
+
disabled: page >= Math.ceil(count / rowsPerPage) - 1,
|
|
112
|
+
"aria-label": "Next page"
|
|
113
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
114
|
+
src: _rightArrow.default,
|
|
115
|
+
style: {
|
|
116
|
+
opacity: page >= Math.ceil(count / rowsPerPage) - 1 ? 0.2 : 1
|
|
117
|
+
},
|
|
118
|
+
alt: "Right Arrow"
|
|
119
|
+
})))
|
|
71
120
|
}));
|
|
72
121
|
};
|
|
73
122
|
CustomPagination.propTypes = {
|
package/package.json
CHANGED
package/src/TableView.js
CHANGED
|
@@ -1,37 +1,59 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
createMuiTheme,
|
|
5
5
|
TablePagination,
|
|
6
6
|
ThemeProvider,
|
|
7
|
+
IconButton,
|
|
8
|
+
makeStyles,
|
|
7
9
|
} from '@material-ui/core';
|
|
8
|
-
import
|
|
10
|
+
import {
|
|
11
|
+
ArrowDropDown,
|
|
12
|
+
} from '@material-ui/icons';
|
|
13
|
+
import rightArrow from '../assets/rightArrow.svg';
|
|
14
|
+
import leftArrow from '../assets/leftArrow.svg';
|
|
9
15
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const useStyles = makeStyles(() => ({
|
|
17
|
+
paginationRoot: {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
justifyContent: 'flex-end', // Moves pagination to the right
|
|
20
|
+
paddingRight: '10px', // Optional spacing
|
|
21
|
+
},
|
|
22
|
+
actionsContainer: {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
justifyContent: 'flex-end', // Align pagination buttons to the right
|
|
19
25
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
const defaultTheme = createMuiTheme({
|
|
29
|
+
overrides: {
|
|
30
|
+
MuiTablePagination: {
|
|
31
|
+
root: {
|
|
32
|
+
paddingRight: '50px',
|
|
33
|
+
width: '100%',
|
|
34
|
+
},
|
|
35
|
+
toolbar: {
|
|
36
|
+
minHeight: '45px',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
},
|
|
24
40
|
},
|
|
25
|
-
|
|
26
|
-
|
|
41
|
+
MuiTypography: {
|
|
42
|
+
body2: {
|
|
43
|
+
fontSize: '14px',
|
|
44
|
+
textTransform: 'uppercase',
|
|
45
|
+
},
|
|
46
|
+
root: {
|
|
47
|
+
fontSize: '14px',
|
|
48
|
+
},
|
|
27
49
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
50
|
+
MuiIconButton: {
|
|
51
|
+
root: {
|
|
52
|
+
padding: '2px',
|
|
53
|
+
},
|
|
32
54
|
},
|
|
33
55
|
},
|
|
34
|
-
};
|
|
56
|
+
});
|
|
35
57
|
|
|
36
58
|
const CustomPagination = ({
|
|
37
59
|
rowsPerPageOptions,
|
|
@@ -40,25 +62,54 @@ const CustomPagination = ({
|
|
|
40
62
|
page,
|
|
41
63
|
onPageChange,
|
|
42
64
|
onRowsPerPageChange,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
}) => {
|
|
66
|
+
const classes = useStyles();
|
|
67
|
+
return (
|
|
68
|
+
<ThemeProvider
|
|
69
|
+
theme={createMuiTheme({ overrides: { ...defaultTheme.overrides } })}
|
|
70
|
+
>
|
|
71
|
+
<TablePagination
|
|
72
|
+
labelRowsPerPage="Results per Page:"
|
|
73
|
+
rowsPerPageOptions={rowsPerPageOptions}
|
|
74
|
+
component="div"
|
|
75
|
+
count={count}
|
|
76
|
+
rowsPerPage={rowsPerPage}
|
|
77
|
+
page={page}
|
|
78
|
+
onPageChange={onPageChange}
|
|
79
|
+
onRowsPerPageChange={onRowsPerPageChange}
|
|
80
|
+
SelectProps={{
|
|
81
|
+
IconComponent: ArrowDropDown,
|
|
82
|
+
inputProps: { 'aria-label': 'Selection dropdown for displaying the number of results per page' },
|
|
83
|
+
}}
|
|
84
|
+
nextIconButtonProps={{
|
|
85
|
+
'aria-label': 'Next page',
|
|
86
|
+
}}
|
|
87
|
+
backIconButtonProps={{
|
|
88
|
+
'aria-label': 'Previous page',
|
|
89
|
+
}}
|
|
90
|
+
ActionsComponent={() => (
|
|
91
|
+
<div className={classes.actionsContainer}>
|
|
92
|
+
<IconButton
|
|
93
|
+
onClick={(event) => onPageChange(event, page - 1)}
|
|
94
|
+
disabled={page === 0}
|
|
95
|
+
aria-label="Previous page"
|
|
96
|
+
>
|
|
97
|
+
<ArrowDropDown />
|
|
98
|
+
<img src={leftArrow} style={{ opacity: page === 0 ? 0.2 : 1 }} alt="Left Arrow" />
|
|
99
|
+
</IconButton>
|
|
100
|
+
<IconButton
|
|
101
|
+
onClick={(event) => onPageChange(event, page + 1)}
|
|
102
|
+
disabled={page >= Math.ceil(count / rowsPerPage) - 1}
|
|
103
|
+
aria-label="Next page"
|
|
104
|
+
>
|
|
105
|
+
<img src={rightArrow} style={{ opacity: page >= Math.ceil(count / rowsPerPage) - 1 ? 0.2 : 1 }} alt="Right Arrow" />
|
|
106
|
+
</IconButton>
|
|
107
|
+
</div>
|
|
108
|
+
)}
|
|
109
|
+
/>
|
|
110
|
+
</ThemeProvider>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
62
113
|
|
|
63
114
|
CustomPagination.propTypes = {
|
|
64
115
|
rowsPerPageOptions: PropTypes.arrayOf(PropTypes.number).isRequired,
|