UNPKG

@material-ui/core

Version:

React components that implement Google's Material Design.

88 lines (74 loc) 2.68 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; import React from 'react'; import PropTypes from 'prop-types'; import KeyboardArrowLeft from '../internal/svg-icons/KeyboardArrowLeft'; import KeyboardArrowRight from '../internal/svg-icons/KeyboardArrowRight'; import useTheme from '../styles/useTheme'; import IconButton from '../IconButton'; /** * @ignore - internal component. */ var _ref = React.createElement(KeyboardArrowRight, null); var _ref2 = React.createElement(KeyboardArrowLeft, null); var _ref3 = React.createElement(KeyboardArrowLeft, null); var _ref4 = React.createElement(KeyboardArrowRight, null); const TablePaginationActions = React.forwardRef(function TablePaginationActions(props, ref) { const { backIconButtonProps, count, nextIconButtonProps, onChangePage, page, rowsPerPage } = props, other = _objectWithoutPropertiesLoose(props, ["backIconButtonProps", "count", "nextIconButtonProps", "onChangePage", "page", "rowsPerPage"]); const theme = useTheme(); const handleBackButtonClick = event => { onChangePage(event, page - 1); }; const handleNextButtonClick = event => { onChangePage(event, page + 1); }; return React.createElement("div", _extends({ ref: ref }, other), React.createElement(IconButton, _extends({ onClick: handleBackButtonClick, disabled: page === 0, color: "inherit" }, backIconButtonProps), theme.direction === 'rtl' ? _ref : _ref2), React.createElement(IconButton, _extends({ onClick: handleNextButtonClick, disabled: page >= Math.ceil(count / rowsPerPage) - 1, color: "inherit" }, nextIconButtonProps), theme.direction === 'rtl' ? _ref3 : _ref4)); }); process.env.NODE_ENV !== "production" ? TablePaginationActions.propTypes = { /** * Props applied to the back arrow [`IconButton`](/api/icon-button/) element. */ backIconButtonProps: PropTypes.object, /** * The total number of rows. */ count: PropTypes.number.isRequired, /** * Props applied to the next arrow [`IconButton`](/api/icon-button/) element. */ nextIconButtonProps: PropTypes.object, /** * Callback fired when the page is changed. * * @param {object} event The event source of the callback * @param {number} page The page selected */ onChangePage: PropTypes.func.isRequired, /** * The zero-based index of the current page. */ page: PropTypes.number.isRequired, /** * The number of rows per page. */ rowsPerPage: PropTypes.number.isRequired } : void 0; export default TablePaginationActions;