1 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
2 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
3 | import _inherits from 'babel-runtime/helpers/inherits';
|
4 | import _extends from 'babel-runtime/helpers/extends';
|
5 | import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
6 |
|
7 | import classNames from 'classnames';
|
8 | import PropTypes from 'prop-types';
|
9 | import React from 'react';
|
10 |
|
11 | import SafeAnchor from './SafeAnchor';
|
12 |
|
13 | var 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 |
|
22 | var defaultProps = {
|
23 | active: false,
|
24 | disabled: false,
|
25 | activeLabel: '(current)'
|
26 | };
|
27 |
|
28 | export 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 |
|
54 | PaginationItem.propTypes = propTypes;
|
55 | PaginationItem.defaultProps = defaultProps;
|
56 |
|
57 | function 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 |
|
98 | export var First = createButton('First', '\xAB');
|
99 | export var Prev = createButton('Prev', '\u2039');
|
100 | export var Ellipsis = createButton('Ellipsis', '\u2026', 'More');
|
101 | export var Next = createButton('Next', '\u203A');
|
102 | export var Last = createButton('Last', '\xBB'); |
\ | No newline at end of file |