1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _extends2 = require('babel-runtime/helpers/extends');
|
8 |
|
9 | var _extends3 = _interopRequireDefault(_extends2);
|
10 |
|
11 | var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
|
12 |
|
13 | var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
14 |
|
15 | var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
16 |
|
17 | var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
18 |
|
19 | var _createClass2 = require('babel-runtime/helpers/createClass');
|
20 |
|
21 | var _createClass3 = _interopRequireDefault(_createClass2);
|
22 |
|
23 | var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
24 |
|
25 | var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
26 |
|
27 | var _inherits2 = require('babel-runtime/helpers/inherits');
|
28 |
|
29 | var _inherits3 = _interopRequireDefault(_inherits2);
|
30 |
|
31 | var _react = require('react');
|
32 |
|
33 | var _react2 = _interopRequireDefault(_react);
|
34 |
|
35 | var _reactRouter = require('react-router');
|
36 |
|
37 | var _CollectionContext = require('./CollectionContext');
|
38 |
|
39 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
40 |
|
41 | var CollectionPageLink = function (_React$Component) {
|
42 | (0, _inherits3.default)(CollectionPageLink, _React$Component);
|
43 |
|
44 | function CollectionPageLink() {
|
45 | (0, _classCallCheck3.default)(this, CollectionPageLink);
|
46 | return (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(CollectionPageLink).apply(this, arguments));
|
47 | }
|
48 |
|
49 | (0, _createClass3.default)(CollectionPageLink, [{
|
50 | key: 'render',
|
51 | value: function render() {
|
52 | var toPage = this.props.toPage;
|
53 | var page = this.context.page;
|
54 |
|
55 | var nextPageNumber = page.collection.pageNumber + toPage;
|
56 | if (nextPageNumber < 1 || nextPageNumber > page.collection.pageCount) {
|
57 | return null;
|
58 | }
|
59 | var to = nextPageNumber === 1 ? page.createPath() : page.createPath('@page', nextPageNumber);
|
60 | return _react2.default.createElement(_reactRouter.Link, (0, _extends3.default)({}, this.props, { to: to }));
|
61 | }
|
62 | }]);
|
63 | return CollectionPageLink;
|
64 | }(_react2.default.Component); |
65 |
|
66 |
|
67 |
|
68 | CollectionPageLink.defaultProps = {
|
69 | toPage: 1
|
70 | };
|
71 | CollectionPageLink.contextTypes = _CollectionContext.contextTypes;
|
72 | exports.default = CollectionPageLink;
|
73 |
|
\ | No newline at end of file |