-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
/
Copy pathTablePagination.d.ts
150 lines (144 loc) · 5.35 KB
/
TablePagination.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import * as React from 'react';
import { SxProps } from '@mui/system';
import { Theme } from '../styles';
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
import { TablePaginationActionsProps } from './TablePaginationActions';
import { TableCellProps } from '../TableCell';
import { IconButtonProps } from '../IconButton';
import { SelectProps } from '../Select';
import { TablePaginationClasses } from './tablePaginationClasses';
export interface LabelDisplayedRowsArgs {
from: number;
to: number;
count: number;
page: number;
}
export interface TablePaginationTypeMap<P, D extends React.ElementType> {
props: P &
TablePaginationBaseProps & {
/**
* The component used for displaying the actions.
* Either a string to use a HTML element or a component.
* @default TablePaginationActions
*/
ActionsComponent?: React.ElementType<TablePaginationActionsProps>;
/**
* Props applied to the back arrow [`IconButton`](/api/icon-button/) component.
*/
backIconButtonProps?: Partial<IconButtonProps>;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<TablePaginationClasses>;
/**
* The total number of rows.
*
* To enable server side pagination for an unknown number of items, provide -1.
*/
count: number;
/**
* Accepts a function which returns a string value that provides a user-friendly name for the current page.
* This is important for screen reader users.
*
* For localization purposes, you can use the provided [translations](/guides/localization/).
* @param {string} type The link or button type to format ('first' | 'last' | 'next' | 'previous').
* @returns {string}
* @default function defaultGetAriaLabel(type) {
* return `Go to ${type} page`;
* }
*/
getItemAriaLabel?: (type: 'first' | 'last' | 'next' | 'previous') => string;
/**
* Customize the displayed rows label. Invoked with a `{ from, to, count, page }`
* object.
*
* For localization purposes, you can use the provided [translations](/guides/localization/).
* @default function defaultLabelDisplayedRows({ from, to, count }) {
* return `${from}-${to} of ${count !== -1 ? count : `more than ${to}`}`;
* }
*/
labelDisplayedRows?: (paginationInfo: LabelDisplayedRowsArgs) => React.ReactNode;
/**
* Customize the rows per page label.
*
* For localization purposes, you can use the provided [translations](/guides/localization/).
* @default 'Rows per page:'
*/
labelRowsPerPage?: React.ReactNode;
/**
* Props applied to the next arrow [`IconButton`](/api/icon-button/) element.
*/
nextIconButtonProps?: Partial<IconButtonProps>;
/**
* Callback fired when the page is changed.
*
* @param {React.MouseEvent<HTMLButtonElement> | null} event The event source of the callback.
* @param {number} page The page selected.
*/
onPageChange: (event: React.MouseEvent<HTMLButtonElement> | null, page: number) => void;
/**
* Callback fired when the number of rows per page is changed.
*
* @param {React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>} event The event source of the callback.
*/
onRowsPerPageChange?: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
/**
* The zero-based index of the current page.
*/
page: number;
/**
* The number of rows per page.
*
* Set -1 to display all the rows.
*/
rowsPerPage: number;
/**
* Customizes the options of the rows per page select field. If less than two options are
* available, no select field will be displayed.
* Use -1 for the value with a custom label to show all the rows.
* @default [10, 25, 50, 100]
*/
rowsPerPageOptions?: Array<number | { value: number; label: string }>;
/**
* Props applied to the rows per page [`Select`](/api/select/) element.
* @default {}
*/
SelectProps?: Partial<SelectProps>;
/**
* If `true`, show the first-page button.
* @default false
*/
showFirstButton?: boolean;
/**
* If `true`, show the last-page button.
* @default false
*/
showLastButton?: boolean;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
};
defaultComponent: D;
}
/**
* A `TableCell` based component for placing inside `TableFooter` for pagination.
*
* Demos:
*
* - [Tables](https://mui.com/components/tables/)
*
* API:
*
* - [TablePagination API](https://mui.com/api/table-pagination/)
* - inherits [TableCell API](https://mui.com/api/table-cell/)
*/
declare const TablePagination: OverridableComponent<
TablePaginationTypeMap<{}, React.JSXElementConstructor<TablePaginationBaseProps>>
>;
export type TablePaginationBaseProps = Omit<TableCellProps, 'classes' | 'component' | 'children'>;
export type TablePaginationProps<
D extends React.ElementType = React.JSXElementConstructor<TablePaginationBaseProps>,
P = {},
> = OverrideProps<TablePaginationTypeMap<P, D>, D>;
export default TablePagination;