Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TablePagination] Add SelectProps property #10629

Merged
merged 2 commits into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pages/api/table-pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ A `TableCell` based component for placing inside `TableFooter` for pagination.
| <span class="prop-name required">count *</span> | <span class="prop-type">number | | The total number of rows. |
| <span class="prop-name">labelDisplayedRows</span> | <span class="prop-type">func | <span class="prop-default">({ from, to, count }) => `${from}-${to} of ${count}`</span> | Useful to customize the displayed rows label. |
| <span class="prop-name">labelRowsPerPage</span> | <span class="prop-type">node | <span class="prop-default">'Rows per page:'</span> | Useful to customize the rows per page label. Invoked with a `{ from, to, count, page }` object. |
| <span class="prop-name">nextIconButtonProps</span> | <span class="prop-type">object | | Properties applied to the next arrow `IconButton` component. |
| <span class="prop-name">nextIconButtonProps</span> | <span class="prop-type">object | | Properties applied to the next arrow `IconButton` element. |
| <span class="prop-name required">onChangePage *</span> | <span class="prop-type">func | | Callback fired when the page is changed.<br><br>**Signature:**<br>`function(event: object, page: number) => void`<br>*event:* The event source of the callback<br>*page:* The page selected |
| <span class="prop-name">onChangeRowsPerPage</span> | <span class="prop-type">func | | Callback fired when the number of rows per page is changed.<br><br>**Signature:**<br>`function(event: object) => void`<br>*event:* The event source of the callback |
| <span class="prop-name required">page *</span> | <span class="prop-type">number | | The zero-based index of the current page. |
| <span class="prop-name required">rowsPerPage *</span> | <span class="prop-type">number | | The number of rows per page. |
| <span class="prop-name">rowsPerPageOptions</span> | <span class="prop-type">array | <span class="prop-default">[5, 10, 25]</span> | Customizes the options of the rows per page select field. If less than two options are available, no select field will be displayed. |
| <span class="prop-name">SelectProps</span> | <span class="prop-type">object | | Properties applied to the rows per page `Select` element. |

Any other properties supplied will be [spread to the root element](/guides/api#spread).

Expand Down
2 changes: 2 additions & 0 deletions src/Table/TablePagination.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import { StandardProps } from '..';
import { TableCellProps, TableCellClassKey } from './TableCell.d';
import { IconButtonProps } from '../IconButton/IconButton';
import { SelectProps } from '../Select/Select';

export interface LabelDisplayedRowsArgs {
from: number;
Expand All @@ -24,6 +25,7 @@ export interface TablePaginationProps
page: number;
rowsPerPage: number;
rowsPerPageOptions?: number[];
SelectProps?: Partial<SelectProps>;
}

export type TablePaginationBaseProps = TableCellProps;
Expand Down
8 changes: 7 additions & 1 deletion src/Table/TablePagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class TablePagination extends React.Component {
page,
rowsPerPage,
rowsPerPageOptions,
SelectProps,
...other
} = this.props;

Expand Down Expand Up @@ -108,6 +109,7 @@ class TablePagination extends React.Component {
input={<Input className={classes.input} disableUnderline />}
value={rowsPerPage}
onChange={onChangeRowsPerPage}
{...SelectProps}
>
{rowsPerPageOptions.map(rowsPerPageOption => (
<MenuItem key={rowsPerPageOption} value={rowsPerPageOption}>
Expand Down Expand Up @@ -175,7 +177,7 @@ TablePagination.propTypes = {
*/
labelRowsPerPage: PropTypes.node,
/**
* Properties applied to the next arrow `IconButton` component.
* Properties applied to the next arrow `IconButton` element.
*/
nextIconButtonProps: PropTypes.object,
/**
Expand Down Expand Up @@ -204,6 +206,10 @@ TablePagination.propTypes = {
* available, no select field will be displayed.
*/
rowsPerPageOptions: PropTypes.array,
/**
* Properties applied to the rows per page `Select` element.
*/
SelectProps: PropTypes.object,
};

TablePagination.defaultProps = {
Expand Down
4 changes: 2 additions & 2 deletions src/Table/TablePaginationActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class TablePaginationActions extends React.Component {

TablePaginationActions.propTypes = {
/**
* Properties applied to the back arrow `IconButton` component.
* Properties applied to the back arrow `IconButton` element.
*/
backIconButtonProps: PropTypes.object,
/**
Expand All @@ -73,7 +73,7 @@ TablePaginationActions.propTypes = {
*/
count: PropTypes.number.isRequired,
/**
* Properties applied to the next arrow `IconButton` component.
* Properties applied to the next arrow `IconButton` element.
*/
nextIconButtonProps: PropTypes.object,
/**
Expand Down