UNPKG

1.96 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 backIconButtonProps?: Partial<IconButtonProps>;
21 count: number;
22 labelDisplayedRows?: (paginationInfo: LabelDisplayedRowsArgs) => React.ReactNode;
23 labelRowsPerPage?: React.ReactNode;
24 nextIconButtonProps?: Partial<IconButtonProps>;
25 onChangePage: (event: React.MouseEvent<HTMLButtonElement> | null, page: number) => void;
26 onChangeRowsPerPage?: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
27 page: number;
28 rowsPerPage: number;
29 rowsPerPageOptions?: Array<number | { value: number; label: string }>;
30 SelectProps?: Partial<SelectProps>;
31 };
32 defaultComponent: D;
33 classKey: TablePaginationClassKey;
34}
35
36declare const TablePagination: OverridableComponent<
37 TablePaginationTypeMap<{}, React.ComponentType<TablePaginationBaseProps>>
38>;
39
40export type TablePaginationClassKey =
41 | 'root'
42 | 'toolbar'
43 | 'spacer'
44 | 'menuItem'
45 | 'caption'
46 | 'input'
47 | 'selectRoot'
48 | 'select'
49 | 'selectIcon'
50 | 'actions';
51
52export type TablePaginationBaseProps = Omit<TableCellProps, 'classes' | 'component'>;
53
54export type TablePaginationProps<
55 D extends React.ElementType = React.ComponentType<TablePaginationBaseProps>,
56 P = {}
57> = OverrideProps<TablePaginationTypeMap<P, D>, D>;
58
59export default TablePagination;