UNPKG

3.15 kBJavaScriptView Raw
1import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
2import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
3import _inherits from 'babel-runtime/helpers/inherits';
4import _extends from 'babel-runtime/helpers/extends';
5import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
6/* eslint-disable react/no-multi-comp */
7import classNames from 'classnames';
8import PropTypes from 'prop-types';
9import React from 'react';
10
11import SafeAnchor from './SafeAnchor';
12
13var propTypes = {
14 eventKey: PropTypes.any,
15 className: PropTypes.string,
16 onSelect: PropTypes.func,
17 disabled: PropTypes.bool,
18 active: PropTypes.bool,
19 activeLabel: PropTypes.string.isRequired
20};
21
22var defaultProps = {
23 active: false,
24 disabled: false,
25 activeLabel: '(current)'
26};
27
28export default function PaginationItem(_ref) {
29 var active = _ref.active,
30 disabled = _ref.disabled,
31 className = _ref.className,
32 style = _ref.style,
33 activeLabel = _ref.activeLabel,
34 children = _ref.children,
35 props = _objectWithoutProperties(_ref, ['active', 'disabled', 'className', 'style', 'activeLabel', 'children']);
36
37 var Component = active || disabled ? 'span' : SafeAnchor;
38 return React.createElement(
39 'li',
40 { style: style, className: classNames(className, { active: active, disabled: disabled }) },
41 React.createElement(
42 Component,
43 _extends({ disabled: disabled }, props),
44 children,
45 active && React.createElement(
46 'span',
47 { className: 'sr-only' },
48 activeLabel
49 )
50 )
51 );
52}
53
54PaginationItem.propTypes = propTypes;
55PaginationItem.defaultProps = defaultProps;
56
57function createButton(name, defaultValue) {
58 var _class, _temp;
59
60 var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : name;
61
62 return _temp = _class = function (_React$Component) {
63 _inherits(_class, _React$Component);
64
65 function _class() {
66 _classCallCheck(this, _class);
67
68 return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
69 }
70
71 _class.prototype.render = function render() {
72 var _props = this.props,
73 disabled = _props.disabled,
74 children = _props.children,
75 className = _props.className,
76 props = _objectWithoutProperties(_props, ['disabled', 'children', 'className']);
77
78 var Component = disabled ? 'span' : SafeAnchor;
79
80 return React.createElement(
81 'li',
82 _extends({
83 'aria-label': label,
84 className: classNames(className, { disabled: disabled })
85 }, props),
86 React.createElement(
87 Component,
88 null,
89 children || defaultValue
90 )
91 );
92 };
93
94 return _class;
95 }(React.Component), _class.displayName = name, _class.propTypes = { disabled: PropTypes.bool }, _temp;
96}
97
98export var First = createButton('First', '\xAB');
99export var Prev = createButton('Prev', '\u2039');
100export var Ellipsis = createButton('Ellipsis', '\u2026', 'More');
101export var Next = createButton('Next', '\u203A');
102export var Last = createButton('Last', '\xBB');
\No newline at end of file