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 _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
13 |
|
14 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
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 _ButtonBase = _interopRequireDefault(require("@material-ui/core/ButtonBase"));
|
25 |
|
26 | var _FirstPage = _interopRequireDefault(require("../internal/svg-icons/FirstPage"));
|
27 |
|
28 | var _LastPage = _interopRequireDefault(require("../internal/svg-icons/LastPage"));
|
29 |
|
30 | var _NavigateBefore = _interopRequireDefault(require("../internal/svg-icons/NavigateBefore"));
|
31 |
|
32 | var _NavigateNext = _interopRequireDefault(require("../internal/svg-icons/NavigateNext"));
|
33 |
|
34 | var _utils = require("@material-ui/core/utils");
|
35 |
|
36 | var styles = function styles(theme) {
|
37 | return {
|
38 |
|
39 | root: (0, _extends2.default)({}, theme.typography.body2, {
|
40 | borderRadius: 32 / 2,
|
41 | textAlign: 'center',
|
42 | boxSizing: 'border-box',
|
43 | minWidth: 32,
|
44 | height: 32,
|
45 | padding: '0 6px',
|
46 | margin: '0 3px',
|
47 | color: theme.palette.text.primary
|
48 | }),
|
49 |
|
50 |
|
51 | page: {
|
52 | transition: theme.transitions.create(['color', 'background-color'], {
|
53 | duration: theme.transitions.duration.short
|
54 | }),
|
55 | '&:hover': {
|
56 | backgroundColor: theme.palette.action.hover,
|
57 |
|
58 | '@media (hover: none)': {
|
59 | backgroundColor: 'transparent'
|
60 | }
|
61 | },
|
62 | '&$focusVisible': {
|
63 | backgroundColor: theme.palette.action.focus
|
64 | },
|
65 | '&$selected': {
|
66 | backgroundColor: theme.palette.action.selected,
|
67 | '&:hover, &$focusVisible': {
|
68 | backgroundColor: (0, _styles.alpha)(theme.palette.action.selected, theme.palette.action.selectedOpacity + theme.palette.action.hoverOpacity),
|
69 |
|
70 | '@media (hover: none)': {
|
71 | backgroundColor: theme.palette.action.selected
|
72 | }
|
73 | },
|
74 | '&$disabled': {
|
75 | opacity: 1,
|
76 | color: theme.palette.action.disabled,
|
77 | backgroundColor: theme.palette.action.selected
|
78 | }
|
79 | },
|
80 | '&$disabled': {
|
81 | opacity: theme.palette.action.disabledOpacity
|
82 | }
|
83 | },
|
84 |
|
85 |
|
86 | sizeSmall: {
|
87 | minWidth: 26,
|
88 | height: 26,
|
89 | borderRadius: 26 / 2,
|
90 | margin: '0 1px',
|
91 | padding: '0 4px',
|
92 | '& $icon': {
|
93 | fontSize: theme.typography.pxToRem(18)
|
94 | }
|
95 | },
|
96 |
|
97 |
|
98 | sizeLarge: {
|
99 | minWidth: 40,
|
100 | height: 40,
|
101 | borderRadius: 40 / 2,
|
102 | padding: '0 10px',
|
103 | fontSize: theme.typography.pxToRem(15),
|
104 | '& $icon': {
|
105 | fontSize: theme.typography.pxToRem(22)
|
106 | }
|
107 | },
|
108 |
|
109 |
|
110 | textPrimary: {
|
111 | '&$selected': {
|
112 | color: theme.palette.primary.contrastText,
|
113 | backgroundColor: theme.palette.primary.main,
|
114 | '&:hover, &$focusVisible': {
|
115 | backgroundColor: theme.palette.primary.dark,
|
116 |
|
117 | '@media (hover: none)': {
|
118 | backgroundColor: theme.palette.primary.main
|
119 | }
|
120 | },
|
121 | '&$disabled': {
|
122 | color: theme.palette.action.disabled
|
123 | }
|
124 | }
|
125 | },
|
126 |
|
127 |
|
128 | textSecondary: {
|
129 | '&$selected': {
|
130 | color: theme.palette.secondary.contrastText,
|
131 | backgroundColor: theme.palette.secondary.main,
|
132 | '&:hover, &$focusVisible': {
|
133 | backgroundColor: theme.palette.secondary.dark,
|
134 |
|
135 | '@media (hover: none)': {
|
136 | backgroundColor: theme.palette.secondary.main
|
137 | }
|
138 | },
|
139 | '&$disabled': {
|
140 | color: theme.palette.action.disabled
|
141 | }
|
142 | }
|
143 | },
|
144 |
|
145 |
|
146 | outlined: {
|
147 | border: "1px solid ".concat(theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)'),
|
148 | '&$selected': {
|
149 | '&$disabled': {
|
150 | border: "1px solid ".concat(theme.palette.action.disabledBackground)
|
151 | }
|
152 | }
|
153 | },
|
154 |
|
155 |
|
156 | outlinedPrimary: {
|
157 | '&$selected': {
|
158 | color: theme.palette.primary.main,
|
159 | border: "1px solid ".concat((0, _styles.alpha)(theme.palette.primary.main, 0.5)),
|
160 | backgroundColor: (0, _styles.alpha)(theme.palette.primary.main, theme.palette.action.activatedOpacity),
|
161 | '&:hover, &$focusVisible': {
|
162 | backgroundColor: (0, _styles.alpha)(theme.palette.primary.main, theme.palette.action.activatedOpacity + theme.palette.action.hoverOpacity),
|
163 |
|
164 | '@media (hover: none)': {
|
165 | backgroundColor: 'transparent'
|
166 | }
|
167 | },
|
168 | '&$disabled': {
|
169 | color: theme.palette.action.disabled
|
170 | }
|
171 | }
|
172 | },
|
173 |
|
174 |
|
175 | outlinedSecondary: {
|
176 | '&$selected': {
|
177 | color: theme.palette.secondary.main,
|
178 | border: "1px solid ".concat((0, _styles.alpha)(theme.palette.secondary.main, 0.5)),
|
179 | backgroundColor: (0, _styles.alpha)(theme.palette.secondary.main, theme.palette.action.activatedOpacity),
|
180 | '&:hover, &$focusVisible': {
|
181 | backgroundColor: (0, _styles.alpha)(theme.palette.secondary.main, theme.palette.action.activatedOpacity + theme.palette.action.hoverOpacity),
|
182 |
|
183 | '@media (hover: none)': {
|
184 | backgroundColor: 'transparent'
|
185 | }
|
186 | },
|
187 | '&$disabled': {
|
188 | color: theme.palette.action.disabled
|
189 | }
|
190 | }
|
191 | },
|
192 |
|
193 |
|
194 | rounded: {
|
195 | borderRadius: theme.shape.borderRadius
|
196 | },
|
197 |
|
198 |
|
199 | ellipsis: {
|
200 | height: 'auto',
|
201 | '&$disabled': {
|
202 | opacity: theme.palette.action.disabledOpacity
|
203 | }
|
204 | },
|
205 |
|
206 |
|
207 | focusVisible: {},
|
208 |
|
209 |
|
210 | disabled: {},
|
211 |
|
212 |
|
213 | selected: {},
|
214 |
|
215 |
|
216 | icon: {
|
217 | fontSize: theme.typography.pxToRem(20),
|
218 | margin: '0 -8px'
|
219 | }
|
220 | };
|
221 | };
|
222 |
|
223 | exports.styles = styles;
|
224 | var PaginationItem = React.forwardRef(function PaginationItem(props, ref) {
|
225 | var classes = props.classes,
|
226 | className = props.className,
|
227 | _props$color = props.color,
|
228 | color = _props$color === void 0 ? 'standard' : _props$color,
|
229 | component = props.component,
|
230 | _props$disabled = props.disabled,
|
231 | disabled = _props$disabled === void 0 ? false : _props$disabled,
|
232 | page = props.page,
|
233 | _props$selected = props.selected,
|
234 | selected = _props$selected === void 0 ? false : _props$selected,
|
235 | _props$shape = props.shape,
|
236 | shape = _props$shape === void 0 ? 'round' : _props$shape,
|
237 | _props$size = props.size,
|
238 | size = _props$size === void 0 ? 'medium' : _props$size,
|
239 | _props$type = props.type,
|
240 | type = _props$type === void 0 ? 'page' : _props$type,
|
241 | _props$variant = props.variant,
|
242 | variant = _props$variant === void 0 ? 'text' : _props$variant,
|
243 | other = (0, _objectWithoutProperties2.default)(props, ["classes", "className", "color", "component", "disabled", "page", "selected", "shape", "size", "type", "variant"]);
|
244 | var theme = (0, _styles.useTheme)();
|
245 | var normalizedIcons = theme.direction === 'rtl' ? {
|
246 | previous: _NavigateNext.default,
|
247 | next: _NavigateBefore.default,
|
248 | last: _FirstPage.default,
|
249 | first: _LastPage.default
|
250 | } : {
|
251 | previous: _NavigateBefore.default,
|
252 | next: _NavigateNext.default,
|
253 | first: _FirstPage.default,
|
254 | last: _LastPage.default
|
255 | };
|
256 | var Icon = normalizedIcons[type];
|
257 | return type === 'start-ellipsis' || type === 'end-ellipsis' ? React.createElement("div", {
|
258 | ref: ref,
|
259 | className: (0, _clsx.default)(classes.root, classes.ellipsis, disabled && classes.disabled, size !== 'medium' && classes["size".concat((0, _utils.capitalize)(size))])
|
260 | }, "\u2026") : React.createElement(_ButtonBase.default, (0, _extends2.default)({
|
261 | ref: ref,
|
262 | component: component,
|
263 | disabled: disabled,
|
264 | focusVisibleClassName: classes.focusVisible,
|
265 | className: (0, _clsx.default)(classes.root, classes.page, classes[variant], classes[shape], className, color !== 'standard' && classes["".concat(variant).concat((0, _utils.capitalize)(color))], disabled && classes.disabled, selected && classes.selected, size !== 'medium' && classes["size".concat((0, _utils.capitalize)(size))])
|
266 | }, other), type === 'page' && page, Icon ? React.createElement(Icon, {
|
267 | className: classes.icon
|
268 | }) : null);
|
269 | });
|
270 | process.env.NODE_ENV !== "production" ? PaginationItem.propTypes = {
|
271 | |
272 |
|
273 |
|
274 | classes: _propTypes.default.object.isRequired,
|
275 |
|
276 | |
277 |
|
278 |
|
279 | className: _propTypes.default.string,
|
280 |
|
281 | |
282 |
|
283 |
|
284 | color: _propTypes.default.oneOf(['standard', 'primary', 'secondary']),
|
285 |
|
286 | |
287 |
|
288 |
|
289 |
|
290 | component: _propTypes.default
|
291 |
|
292 | .elementType,
|
293 |
|
294 | |
295 |
|
296 |
|
297 | disabled: _propTypes.default.bool,
|
298 |
|
299 | |
300 |
|
301 |
|
302 | page: _propTypes.default.number,
|
303 |
|
304 | |
305 |
|
306 |
|
307 | selected: _propTypes.default.bool,
|
308 |
|
309 | |
310 |
|
311 |
|
312 | shape: _propTypes.default.oneOf(['round', 'rounded']),
|
313 |
|
314 | |
315 |
|
316 |
|
317 | size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
318 |
|
319 | |
320 |
|
321 |
|
322 | type: _propTypes.default.oneOf(['page', 'first', 'last', 'next', 'previous', 'start-ellipsis', 'end-ellipsis']),
|
323 |
|
324 | |
325 |
|
326 |
|
327 | variant: _propTypes.default.oneOf(['text', 'outlined'])
|
328 | } : void 0;
|
329 |
|
330 | var _default = (0, _styles.withStyles)(styles, {
|
331 | name: 'MuiPaginationItem'
|
332 | })(PaginationItem);
|
333 |
|
334 | exports.default = _default; |
\ | No newline at end of file |