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