1 | "use strict";
|
2 |
|
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
4 |
|
5 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = exports.styles = void 0;
|
11 |
|
12 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13 |
|
14 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
15 |
|
16 | var React = _interopRequireWildcard(require("react"));
|
17 |
|
18 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
19 |
|
20 | var _clsx = _interopRequireDefault(require("clsx"));
|
21 |
|
22 | var _styles = require("@material-ui/core/styles");
|
23 |
|
24 | var _usePagination2 = _interopRequireDefault(require("./usePagination"));
|
25 |
|
26 | var _PaginationItem = _interopRequireDefault(require("../PaginationItem"));
|
27 |
|
28 | var styles = {
|
29 |
|
30 | root: {},
|
31 |
|
32 |
|
33 | ul: {
|
34 | display: 'flex',
|
35 | flexWrap: 'wrap',
|
36 | alignItems: 'center',
|
37 | padding: 0,
|
38 | margin: 0,
|
39 | listStyle: 'none'
|
40 | }
|
41 | };
|
42 | exports.styles = styles;
|
43 |
|
44 | function defaultGetAriaLabel(type, page, selected) {
|
45 | if (type === 'page') {
|
46 | return "".concat(selected ? '' : 'Go to ', "page ").concat(page);
|
47 | }
|
48 |
|
49 | return "Go to ".concat(type, " page");
|
50 | }
|
51 |
|
52 | var Pagination = React.forwardRef(function Pagination(props, ref) {
|
53 | var boundaryCount = props.boundaryCount,
|
54 | classes = props.classes,
|
55 | className = props.className,
|
56 | _props$color = props.color,
|
57 | color = _props$color === void 0 ? 'standard' : _props$color,
|
58 | count = props.count,
|
59 | defaultPage = props.defaultPage,
|
60 | disabled = props.disabled,
|
61 | _props$getItemAriaLab = props.getItemAriaLabel,
|
62 | getItemAriaLabel = _props$getItemAriaLab === void 0 ? defaultGetAriaLabel : _props$getItemAriaLab,
|
63 | hideNextButton = props.hideNextButton,
|
64 | hidePrevButton = props.hidePrevButton,
|
65 | onChange = props.onChange,
|
66 | page = props.page,
|
67 | _props$renderItem = props.renderItem,
|
68 | renderItem = _props$renderItem === void 0 ? function (item) {
|
69 | return React.createElement(_PaginationItem.default, item);
|
70 | } : _props$renderItem,
|
71 | _props$shape = props.shape,
|
72 | shape = _props$shape === void 0 ? 'round' : _props$shape,
|
73 | showFirstButton = props.showFirstButton,
|
74 | showLastButton = props.showLastButton,
|
75 | siblingCount = props.siblingCount,
|
76 | _props$size = props.size,
|
77 | size = _props$size === void 0 ? 'medium' : _props$size,
|
78 | _props$variant = props.variant,
|
79 | variant = _props$variant === void 0 ? 'text' : _props$variant,
|
80 | other = (0, _objectWithoutProperties2.default)(props, ["boundaryCount", "classes", "className", "color", "count", "defaultPage", "disabled", "getItemAriaLabel", "hideNextButton", "hidePrevButton", "onChange", "page", "renderItem", "shape", "showFirstButton", "showLastButton", "siblingCount", "size", "variant"]);
|
81 |
|
82 | var _usePagination = (0, _usePagination2.default)((0, _extends2.default)({}, props, {
|
83 | componentName: 'Pagination'
|
84 | })),
|
85 | items = _usePagination.items;
|
86 |
|
87 | return React.createElement("nav", (0, _extends2.default)({
|
88 | "aria-label": "pagination navigation",
|
89 | className: (0, _clsx.default)(classes.root, className),
|
90 | ref: ref
|
91 | }, other), React.createElement("ul", {
|
92 | className: classes.ul
|
93 | }, items.map(function (item, index) {
|
94 | return React.createElement("li", {
|
95 | key: index
|
96 | }, renderItem((0, _extends2.default)({}, item, {
|
97 | color: color,
|
98 | 'aria-label': getItemAriaLabel(item.type, item.page, item.selected),
|
99 | shape: shape,
|
100 | size: size,
|
101 | variant: variant
|
102 | })));
|
103 | })));
|
104 | });
|
105 |
|
106 | process.env.NODE_ENV !== "production" ? Pagination.propTypes = {
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 | |
113 |
|
114 |
|
115 |
|
116 | boundaryCount: _propTypes.default.number,
|
117 |
|
118 | |
119 |
|
120 |
|
121 |
|
122 | classes: _propTypes.default.object,
|
123 |
|
124 | |
125 |
|
126 |
|
127 | className: _propTypes.default.string,
|
128 |
|
129 | |
130 |
|
131 |
|
132 | color: _propTypes.default.oneOf(['primary', 'secondary', 'standard']),
|
133 |
|
134 | |
135 |
|
136 |
|
137 |
|
138 | count: _propTypes.default.number,
|
139 |
|
140 | |
141 |
|
142 |
|
143 |
|
144 | defaultPage: _propTypes.default.number,
|
145 |
|
146 | |
147 |
|
148 |
|
149 |
|
150 | disabled: _propTypes.default.bool,
|
151 |
|
152 | |
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 | getItemAriaLabel: _propTypes.default.func,
|
163 |
|
164 | |
165 |
|
166 |
|
167 |
|
168 | hideNextButton: _propTypes.default.bool,
|
169 |
|
170 | |
171 |
|
172 |
|
173 |
|
174 | hidePrevButton: _propTypes.default.bool,
|
175 |
|
176 | |
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 | onChange: _propTypes.default.func,
|
183 |
|
184 | |
185 |
|
186 |
|
187 | page: _propTypes.default.number,
|
188 |
|
189 | |
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 | renderItem: _propTypes.default.func,
|
196 |
|
197 | |
198 |
|
199 |
|
200 | shape: _propTypes.default.oneOf(['round', 'rounded']),
|
201 |
|
202 | |
203 |
|
204 |
|
205 |
|
206 | showFirstButton: _propTypes.default.bool,
|
207 |
|
208 | |
209 |
|
210 |
|
211 |
|
212 | showLastButton: _propTypes.default.bool,
|
213 |
|
214 | |
215 |
|
216 |
|
217 |
|
218 | siblingCount: _propTypes.default.number,
|
219 |
|
220 | |
221 |
|
222 |
|
223 | size: _propTypes.default.oneOf(['large', 'medium', 'small']),
|
224 |
|
225 | |
226 |
|
227 |
|
228 | variant: _propTypes.default.oneOf(['outlined', 'text'])
|
229 | } : void 0;
|
230 |
|
231 | var _default = (0, _styles.withStyles)(styles, {
|
232 | name: 'MuiPagination'
|
233 | })(Pagination);
|
234 |
|
235 | exports.default = _default; |
\ | No newline at end of file |