1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import KeyboardArrowLeft from '../internal/svg-icons/KeyboardArrowLeft';
|
6 | import KeyboardArrowRight from '../internal/svg-icons/KeyboardArrowRight';
|
7 | import useTheme from '../styles/useTheme';
|
8 | import IconButton from '../IconButton';
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | var _ref = React.createElement(KeyboardArrowRight, null);
|
14 |
|
15 | var _ref2 = React.createElement(KeyboardArrowLeft, null);
|
16 |
|
17 | var _ref3 = React.createElement(KeyboardArrowLeft, null);
|
18 |
|
19 | var _ref4 = React.createElement(KeyboardArrowRight, null);
|
20 |
|
21 | const TablePaginationActions = React.forwardRef(function TablePaginationActions(props, ref) {
|
22 | const {
|
23 | backIconButtonProps,
|
24 | count,
|
25 | nextIconButtonProps,
|
26 | onChangePage = () => {},
|
27 | onPageChange = () => {},
|
28 | page,
|
29 | rowsPerPage
|
30 | } = props,
|
31 | other = _objectWithoutPropertiesLoose(props, ["backIconButtonProps", "count", "nextIconButtonProps", "onChangePage", "onPageChange", "page", "rowsPerPage"]);
|
32 |
|
33 | const theme = useTheme();
|
34 |
|
35 | const handleBackButtonClick = event => {
|
36 | onChangePage(event, page - 1);
|
37 | onPageChange(event, page - 1);
|
38 | };
|
39 |
|
40 | const handleNextButtonClick = event => {
|
41 | onChangePage(event, page + 1);
|
42 | onPageChange(event, page + 1);
|
43 | };
|
44 |
|
45 | return React.createElement("div", _extends({
|
46 | ref: ref
|
47 | }, other), React.createElement(IconButton, _extends({
|
48 | onClick: handleBackButtonClick,
|
49 | disabled: page === 0,
|
50 | color: "inherit"
|
51 | }, backIconButtonProps), theme.direction === 'rtl' ? _ref : _ref2), React.createElement(IconButton, _extends({
|
52 | onClick: handleNextButtonClick,
|
53 | disabled: count !== -1 ? page >= Math.ceil(count / rowsPerPage) - 1 : false,
|
54 | color: "inherit"
|
55 | }, nextIconButtonProps), theme.direction === 'rtl' ? _ref3 : _ref4));
|
56 | });
|
57 | process.env.NODE_ENV !== "production" ? TablePaginationActions.propTypes = {
|
58 | |
59 |
|
60 |
|
61 | backIconButtonProps: PropTypes.object,
|
62 |
|
63 | |
64 |
|
65 |
|
66 | count: PropTypes.number.isRequired,
|
67 |
|
68 | |
69 |
|
70 |
|
71 | nextIconButtonProps: PropTypes.object,
|
72 |
|
73 | |
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | onChangePage: PropTypes.func,
|
80 |
|
81 | |
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 | onPageChange: PropTypes.func,
|
88 |
|
89 | |
90 |
|
91 |
|
92 | page: PropTypes.number.isRequired,
|
93 |
|
94 | |
95 |
|
96 |
|
97 | rowsPerPage: PropTypes.number.isRequired
|
98 | } : void 0;
|
99 | export default TablePaginationActions; |
\ | No newline at end of file |