UNPKG

3.13 kBJavaScriptView Raw
1var _excluded = ["className", "listClassName", "cssModule", "size", "tag", "listTag", "aria-label"];
2function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
5function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6import React from 'react';
7import PropTypes from 'prop-types';
8import classNames from 'classnames';
9import { mapToCssModules, tagPropType } from './utils';
10var propTypes = {
11 children: PropTypes.node,
12 /** Add custom class */
13 className: PropTypes.string,
14 /** Add custom class for list */
15 listClassName: PropTypes.string,
16 /** Change underlying component's CSS base class name */
17 cssModule: PropTypes.object,
18 /** Make the Pagination bigger or smaller */
19 size: PropTypes.string,
20 /** Set a custom element for this component */
21 tag: tagPropType,
22 /** Set a custom element for list component */
23 listTag: tagPropType,
24 'aria-label': PropTypes.string
25};
26function Pagination(props) {
27 var className = props.className,
28 listClassName = props.listClassName,
29 cssModule = props.cssModule,
30 size = props.size,
31 _props$tag = props.tag,
32 Tag = _props$tag === void 0 ? 'nav' : _props$tag,
33 _props$listTag = props.listTag,
34 ListTag = _props$listTag === void 0 ? 'ul' : _props$listTag,
35 _props$ariaLabel = props['aria-label'],
36 label = _props$ariaLabel === void 0 ? 'pagination' : _props$ariaLabel,
37 attributes = _objectWithoutProperties(props, _excluded);
38 var classes = mapToCssModules(classNames(className), cssModule);
39 var listClasses = mapToCssModules(classNames(listClassName, 'pagination', _defineProperty({}, "pagination-".concat(size), !!size)), cssModule);
40 return /*#__PURE__*/React.createElement(Tag, {
41 className: classes,
42 "aria-label": label
43 }, /*#__PURE__*/React.createElement(ListTag, _extends({}, attributes, {
44 className: listClasses
45 })));
46}
47Pagination.propTypes = propTypes;
48export default Pagination;
\No newline at end of file