1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
3 |
|
4 | var _LastPageIcon, _FirstPageIcon, _KeyboardArrowRight, _KeyboardArrowLeft, _KeyboardArrowLeft2, _KeyboardArrowRight2, _FirstPageIcon2, _LastPageIcon2;
|
5 |
|
6 | import * as React from 'react';
|
7 | import PropTypes from 'prop-types';
|
8 | import KeyboardArrowLeft from '../internal/svg-icons/KeyboardArrowLeft';
|
9 | import KeyboardArrowRight from '../internal/svg-icons/KeyboardArrowRight';
|
10 | import useTheme from '../styles/useTheme';
|
11 | import IconButton from '../IconButton';
|
12 | import LastPageIcon from '../internal/svg-icons/LastPage';
|
13 | import FirstPageIcon from '../internal/svg-icons/FirstPage';
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | import { jsx as _jsx } from "react/jsx-runtime";
|
19 | import { jsxs as _jsxs } from "react/jsx-runtime";
|
20 | var TablePaginationActions = React.forwardRef(function TablePaginationActions(props, ref) {
|
21 | var backIconButtonProps = props.backIconButtonProps,
|
22 | count = props.count,
|
23 | getItemAriaLabel = props.getItemAriaLabel,
|
24 | nextIconButtonProps = props.nextIconButtonProps,
|
25 | onPageChange = props.onPageChange,
|
26 | page = props.page,
|
27 | rowsPerPage = props.rowsPerPage,
|
28 | showFirstButton = props.showFirstButton,
|
29 | showLastButton = props.showLastButton,
|
30 | other = _objectWithoutProperties(props, ["backIconButtonProps", "count", "getItemAriaLabel", "nextIconButtonProps", "onPageChange", "page", "rowsPerPage", "showFirstButton", "showLastButton"]);
|
31 |
|
32 | var theme = useTheme();
|
33 |
|
34 | var handleFirstPageButtonClick = function handleFirstPageButtonClick(event) {
|
35 | onPageChange(event, 0);
|
36 | };
|
37 |
|
38 | var handleBackButtonClick = function handleBackButtonClick(event) {
|
39 | onPageChange(event, page - 1);
|
40 | };
|
41 |
|
42 | var handleNextButtonClick = function handleNextButtonClick(event) {
|
43 | onPageChange(event, page + 1);
|
44 | };
|
45 |
|
46 | var handleLastPageButtonClick = function handleLastPageButtonClick(event) {
|
47 | onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
|
48 | };
|
49 |
|
50 | return _jsxs("div", _extends({
|
51 | ref: ref
|
52 | }, other, {
|
53 | children: [showFirstButton && _jsx(IconButton, {
|
54 | onClick: handleFirstPageButtonClick,
|
55 | disabled: page === 0,
|
56 | "aria-label": getItemAriaLabel('first', page),
|
57 | title: getItemAriaLabel('first', page),
|
58 | children: theme.direction === 'rtl' ? _LastPageIcon || (_LastPageIcon = _jsx(LastPageIcon, {})) : _FirstPageIcon || (_FirstPageIcon = _jsx(FirstPageIcon, {}))
|
59 | }), _jsx(IconButton, _extends({
|
60 | onClick: handleBackButtonClick,
|
61 | disabled: page === 0,
|
62 | color: "inherit",
|
63 | "aria-label": getItemAriaLabel('previous', page),
|
64 | title: getItemAriaLabel('previous', page)
|
65 | }, backIconButtonProps, {
|
66 | children: theme.direction === 'rtl' ? _KeyboardArrowRight || (_KeyboardArrowRight = _jsx(KeyboardArrowRight, {})) : _KeyboardArrowLeft || (_KeyboardArrowLeft = _jsx(KeyboardArrowLeft, {}))
|
67 | })), _jsx(IconButton, _extends({
|
68 | onClick: handleNextButtonClick,
|
69 | disabled: count !== -1 ? page >= Math.ceil(count / rowsPerPage) - 1 : false,
|
70 | color: "inherit",
|
71 | "aria-label": getItemAriaLabel('next', page),
|
72 | title: getItemAriaLabel('next', page)
|
73 | }, nextIconButtonProps, {
|
74 | children: theme.direction === 'rtl' ? _KeyboardArrowLeft2 || (_KeyboardArrowLeft2 = _jsx(KeyboardArrowLeft, {})) : _KeyboardArrowRight2 || (_KeyboardArrowRight2 = _jsx(KeyboardArrowRight, {}))
|
75 | })), showLastButton && _jsx(IconButton, {
|
76 | onClick: handleLastPageButtonClick,
|
77 | disabled: page >= Math.ceil(count / rowsPerPage) - 1,
|
78 | "aria-label": getItemAriaLabel('last', page),
|
79 | title: getItemAriaLabel('last', page),
|
80 | children: theme.direction === 'rtl' ? _FirstPageIcon2 || (_FirstPageIcon2 = _jsx(FirstPageIcon, {})) : _LastPageIcon2 || (_LastPageIcon2 = _jsx(LastPageIcon, {}))
|
81 | })]
|
82 | }));
|
83 | });
|
84 | process.env.NODE_ENV !== "production" ? TablePaginationActions.propTypes = {
|
85 | |
86 |
|
87 |
|
88 | backIconButtonProps: PropTypes.object,
|
89 |
|
90 | |
91 |
|
92 |
|
93 | count: PropTypes.number.isRequired,
|
94 |
|
95 | |
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 | getItemAriaLabel: PropTypes.func.isRequired,
|
105 |
|
106 | |
107 |
|
108 |
|
109 | nextIconButtonProps: PropTypes.object,
|
110 |
|
111 | |
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 | onPageChange: PropTypes.func.isRequired,
|
118 |
|
119 | |
120 |
|
121 |
|
122 | page: PropTypes.number.isRequired,
|
123 |
|
124 | |
125 |
|
126 |
|
127 | rowsPerPage: PropTypes.number.isRequired,
|
128 |
|
129 | |
130 |
|
131 |
|
132 | showFirstButton: PropTypes.bool.isRequired,
|
133 |
|
134 | |
135 |
|
136 |
|
137 | showLastButton: PropTypes.bool.isRequired
|
138 | } : void 0;
|
139 | export default TablePaginationActions; |
\ | No newline at end of file |