Skip to content

Commit

Permalink
[Pagination] Leverage @default over default values
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Mar 3, 2020
1 parent 3b3e9b9 commit a26e9e7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
30 changes: 19 additions & 11 deletions packages/material-ui-lab/src/Pagination/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,27 @@ function defaultGetAriaLabel(type, page, selected) {
}

const Pagination = React.forwardRef(function Pagination(props, ref) {
/* eslint-disable no-unused-vars */
const {
boundaryCount = 1,
boundaryCount,
children,
classes,
className,
color = 'standard',
count = 1,
defaultPage = 1,
disabled = false,
count,
defaultPage,
disabled,
getItemAriaLabel: getAriaLabel = defaultGetAriaLabel,
hideNextButton = false,
hidePrevButton = false,
hideNextButton,
hidePrevButton,
renderItem = item => <PaginationItem {...item} />,
shape = 'round',
showFirstButton = false,
showLastButton = false,
siblingCount = 1,
showFirstButton,
showLastButton,
siblingCount,
size = 'medium',
variant = 'text',
...other
} = props;
/* eslint-enable no-unused-vars */

const { items } = usePagination({ ...props, componentName: 'Pagination' });

Expand Down Expand Up @@ -79,9 +77,11 @@ const Pagination = React.forwardRef(function Pagination(props, ref) {
);
});

// @default tags synced with default values from usePagination
Pagination.propTypes = {
/**
* Number of always visible pages at the beginning and end.
* @default 1
*/
boundaryCount: PropTypes.number,
/**
Expand All @@ -103,14 +103,17 @@ Pagination.propTypes = {
color: PropTypes.oneOf(['default', 'primary', 'secondary']),
/**
* The total number of pages.
* @default 1
*/
count: PropTypes.number,
/**
* The page selected by default when the component is uncontrolled.
* @default 1
*/
defaultPage: PropTypes.number,
/**
* If `true`, all the pagination component will be disabled.
* @default false
*/
disabled: PropTypes.bool,
/**
Expand All @@ -126,10 +129,12 @@ Pagination.propTypes = {
getItemAriaLabel: PropTypes.func,
/**
* If `true`, hide the next-page button.
* @default false
*/
hideNextButton: PropTypes.bool,
/**
* If `true`, hide the previous-page button.
* @default false
*/
hidePrevButton: PropTypes.bool,
/**
Expand All @@ -156,14 +161,17 @@ Pagination.propTypes = {
shape: PropTypes.oneOf(['round', 'rounded']),
/**
* If `true`, show the first-page button.
* @default false
*/
showFirstButton: PropTypes.bool,
/**
* If `true`, show the last-page button.
* @default false
*/
showLastButton: PropTypes.bool,
/**
* Number of always visible pages before and after the current page.
* @default 1
*/
siblingCount: PropTypes.number,
/**
Expand Down
1 change: 1 addition & 0 deletions packages/material-ui-lab/src/Pagination/usePagination.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useControlled } from '@material-ui/core/utils';

export default function usePagination(props = {}) {
// keep default values in sync with @defaul tags in Pagination.propTypes
const {
boundaryCount: boundaryCountProp = 1,
componentName = 'usePagination',
Expand Down

0 comments on commit a26e9e7

Please sign in to comment.