UNPKG

1.9 kBJavaScriptView Raw
1import _extends from 'babel-runtime/helpers/extends';
2import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
3import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
4import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
5import _inherits from 'babel-runtime/helpers/inherits';
6import classNames from 'classnames';
7import React, { cloneElement } from 'react';
8import PropTypes from 'prop-types';
9
10import PagerItem from './PagerItem';
11import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
12import createChainedFunction from './utils/createChainedFunction';
13import ValidComponentChildren from './utils/ValidComponentChildren';
14
15var propTypes = {
16 onSelect: PropTypes.func
17};
18
19var Pager = function (_React$Component) {
20 _inherits(Pager, _React$Component);
21
22 function Pager() {
23 _classCallCheck(this, Pager);
24
25 return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
26 }
27
28 Pager.prototype.render = function render() {
29 var _props = this.props,
30 onSelect = _props.onSelect,
31 className = _props.className,
32 children = _props.children,
33 props = _objectWithoutProperties(_props, ['onSelect', 'className', 'children']);
34
35 var _splitBsProps = splitBsProps(props),
36 bsProps = _splitBsProps[0],
37 elementProps = _splitBsProps[1];
38
39 var classes = getClassSet(bsProps);
40
41 return React.createElement(
42 'ul',
43 _extends({}, elementProps, { className: classNames(className, classes) }),
44 ValidComponentChildren.map(children, function (child) {
45 return cloneElement(child, {
46 onSelect: createChainedFunction(child.props.onSelect, onSelect)
47 });
48 })
49 );
50 };
51
52 return Pager;
53}(React.Component);
54
55Pager.propTypes = propTypes;
56
57Pager.Item = PagerItem;
58
59export default bsClass('pager', Pager);
\No newline at end of file