UNPKG

2.35 kBTypeScriptView Raw
1import * as React from 'react';
2import { OverridableComponent, OverrideProps } from '../OverridableComponent';
3import { Omit } from '@material-ui/types';
4import { TablePaginationActionsProps } from './TablePaginationActions';
5import { TableCellProps } from '../TableCell';
6import { IconButtonProps } from '../IconButton';
7import { SelectProps } from '../Select';
8
9export interface LabelDisplayedRowsArgs {
10 from: number;
11 to: number;
12 count: number;
13 page: number;
14}
15
16export interface TablePaginationTypeMap<P, D extends React.ElementType> {
17 props: P &
18 TablePaginationBaseProps & {
19 ActionsComponent?: React.ElementType<TablePaginationActionsProps>;
20 backIconButtonText?: string;
21 backIconButtonProps?: Partial<IconButtonProps>;
22 count: number;
23 labelDisplayedRows?: (paginationInfo: LabelDisplayedRowsArgs) => React.ReactNode;
24 labelRowsPerPage?: React.ReactNode;
25 nextIconButtonProps?: Partial<IconButtonProps>;
26 nextIconButtonText?: string;
27 onChangePage: (event: React.MouseEvent<HTMLButtonElement> | null, page: number) => void;
28 onChangeRowsPerPage?: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
29 page: number;
30 rowsPerPage: number;
31 rowsPerPageOptions?: Array<number | { value: number; label: string }>;
32 SelectProps?: Partial<SelectProps>;
33 };
34 defaultComponent: D;
35 classKey: TablePaginationClassKey;
36}
37
38/**
39 * A `TableCell` based component for placing inside `TableFooter` for pagination.
40 * Demos:
41 *
42 * - [Tables](https://material-ui.com/components/tables/)
43 *
44 * API:
45 *
46 * - [TablePagination API](https://material-ui.com/api/table-pagination/)
47 * - inherits [TableCell API](https://material-ui.com/api/table-cell/)
48 */
49declare const TablePagination: OverridableComponent<TablePaginationTypeMap<
50 {},
51 React.ComponentType<TablePaginationBaseProps>
52>>;
53
54export type TablePaginationClassKey =
55 | 'root'
56 | 'toolbar'
57 | 'spacer'
58 | 'menuItem'
59 | 'caption'
60 | 'input'
61 | 'selectRoot'
62 | 'select'
63 | 'selectIcon'
64 | 'actions';
65
66export type TablePaginationBaseProps = Omit<TableCellProps, 'classes' | 'component'>;
67
68export type TablePaginationProps<
69 D extends React.ElementType = React.ComponentType<TablePaginationBaseProps>,
70 P = {}
71> = OverrideProps<TablePaginationTypeMap<P, D>, D>;
72
73export default TablePagination;