1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import { withStyles } from '@material-ui/core/styles';
|
7 | import usePagination from './usePagination';
|
8 | import PaginationItem from '../PaginationItem';
|
9 | export const styles = {
|
10 |
|
11 | root: {},
|
12 |
|
13 |
|
14 | ul: {
|
15 | display: 'flex',
|
16 | flexWrap: 'wrap',
|
17 | alignItems: 'center',
|
18 | padding: 0,
|
19 | margin: 0,
|
20 | listStyle: 'none'
|
21 | }
|
22 | };
|
23 |
|
24 | function defaultGetAriaLabel(type, page, selected) {
|
25 | if (type === 'page') {
|
26 | return `${selected ? '' : 'Go to '}page ${page}`;
|
27 | }
|
28 |
|
29 | return `Go to ${type} page`;
|
30 | }
|
31 |
|
32 | const Pagination = React.forwardRef(function Pagination(props, ref) {
|
33 | const {
|
34 | classes,
|
35 | className,
|
36 | color = 'standard',
|
37 | getItemAriaLabel = defaultGetAriaLabel,
|
38 | renderItem = item => React.createElement(PaginationItem, item),
|
39 | shape = 'round',
|
40 | size = 'medium',
|
41 | variant = 'text'
|
42 | } = props,
|
43 | other = _objectWithoutPropertiesLoose(props, ["boundaryCount", "classes", "className", "color", "count", "defaultPage", "disabled", "getItemAriaLabel", "hideNextButton", "hidePrevButton", "onChange", "page", "renderItem", "shape", "showFirstButton", "showLastButton", "siblingCount", "size", "variant"]);
|
44 |
|
45 | const {
|
46 | items
|
47 | } = usePagination(_extends({}, props, {
|
48 | componentName: 'Pagination'
|
49 | }));
|
50 | return React.createElement("nav", _extends({
|
51 | "aria-label": "pagination navigation",
|
52 | className: clsx(classes.root, className),
|
53 | ref: ref
|
54 | }, other), React.createElement("ul", {
|
55 | className: classes.ul
|
56 | }, items.map((item, index) => React.createElement("li", {
|
57 | key: index
|
58 | }, renderItem(_extends({}, item, {
|
59 | color,
|
60 | 'aria-label': getItemAriaLabel(item.type, item.page, item.selected),
|
61 | shape,
|
62 | size,
|
63 | variant
|
64 | }))))));
|
65 | });
|
66 |
|
67 | process.env.NODE_ENV !== "production" ? Pagination.propTypes = {
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | |
74 |
|
75 |
|
76 |
|
77 | boundaryCount: PropTypes.number,
|
78 |
|
79 | |
80 |
|
81 |
|
82 |
|
83 | classes: PropTypes.object,
|
84 |
|
85 | |
86 |
|
87 |
|
88 | className: PropTypes.string,
|
89 |
|
90 | |
91 |
|
92 |
|
93 | color: PropTypes.oneOf(['primary', 'secondary', 'standard']),
|
94 |
|
95 | |
96 |
|
97 |
|
98 |
|
99 | count: PropTypes.number,
|
100 |
|
101 | |
102 |
|
103 |
|
104 |
|
105 | defaultPage: PropTypes.number,
|
106 |
|
107 | |
108 |
|
109 |
|
110 |
|
111 | disabled: PropTypes.bool,
|
112 |
|
113 | |
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 | getItemAriaLabel: PropTypes.func,
|
124 |
|
125 | |
126 |
|
127 |
|
128 |
|
129 | hideNextButton: PropTypes.bool,
|
130 |
|
131 | |
132 |
|
133 |
|
134 |
|
135 | hidePrevButton: PropTypes.bool,
|
136 |
|
137 | |
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 | onChange: PropTypes.func,
|
144 |
|
145 | |
146 |
|
147 |
|
148 | page: PropTypes.number,
|
149 |
|
150 | |
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 | renderItem: PropTypes.func,
|
157 |
|
158 | |
159 |
|
160 |
|
161 | shape: PropTypes.oneOf(['round', 'rounded']),
|
162 |
|
163 | |
164 |
|
165 |
|
166 |
|
167 | showFirstButton: PropTypes.bool,
|
168 |
|
169 | |
170 |
|
171 |
|
172 |
|
173 | showLastButton: PropTypes.bool,
|
174 |
|
175 | |
176 |
|
177 |
|
178 |
|
179 | siblingCount: PropTypes.number,
|
180 |
|
181 | |
182 |
|
183 |
|
184 | size: PropTypes.oneOf(['large', 'medium', 'small']),
|
185 |
|
186 | |
187 |
|
188 |
|
189 | variant: PropTypes.oneOf(['outlined', 'text'])
|
190 | } : void 0;
|
191 | export default withStyles(styles, {
|
192 | name: 'MuiPagination'
|
193 | })(Pagination); |
\ | No newline at end of file |