From c1e08b35eaf02fd7a149056031201cc08fc0c829 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 3 Feb 2016 14:59:11 -0500 Subject: [PATCH 1/4] [DASH-814] We should provide the method for linking from outside This makes react-router a bit happier in 0.14 land --- dist/PageView.js | 14 ++++---------- dist/PaginationBoxView.js | 19 +++++-------------- dist/PaginationListView.js | 9 ++++++--- package.json | 11 +++++++---- react_components/PaginationListView.js | 2 ++ 5 files changed, 24 insertions(+), 31 deletions(-) diff --git a/dist/PageView.js b/dist/PageView.js index 4a8e40f7..1fa3b777 100755 --- a/dist/PageView.js +++ b/dist/PageView.js @@ -3,9 +3,6 @@ var _extends = Object.assign || 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; }; var React = require('react'); -var Router = require('react-router'); - -var Link = Router.Link; var PageView = React.createClass({ displayName: 'PageView', @@ -23,15 +20,12 @@ var PageView = React.createClass({ return React.createElement( 'li', { className: cssClass }, - React.createElement( - Link, - _extends({}, this.props, { + this.props.generateLinkFor( + _extends({}, this.props, { to: this.props.location, - query: query }), - this.props.page - ) + query: query }), this.props.page) ); } }); -module.exports = PageView; \ No newline at end of file +module.exports = PageView; diff --git a/dist/PaginationBoxView.js b/dist/PaginationBoxView.js index 2767108b..e31c30c9 100755 --- a/dist/PaginationBoxView.js +++ b/dist/PaginationBoxView.js @@ -1,12 +1,9 @@ 'use strict'; var React = require('react'); -var Router = require('react-router'); var classNames = require('classnames'); var PaginationListView = require('./PaginationListView'); -var Link = Router.Link; - var PaginationBoxView = React.createClass({ displayName: 'PaginationBoxView', @@ -17,6 +14,7 @@ var PaginationBoxView = React.createClass({ previousLabel: React.PropTypes.node, nextLabel: React.PropTypes.node, breakLabel: React.PropTypes.node, + generateLinkFor: React.PropTypes.func.isRequired, clickCallback: React.PropTypes.func, initialSelected: React.PropTypes.number, forceSelected: React.PropTypes.number, @@ -90,11 +88,7 @@ var PaginationBoxView = React.createClass({ return React.createElement( 'li', { onClick: this.handlePreviousPage, className: previousClasses }, - React.createElement( - Link, - { query: previousQuery, to: location.pathname }, - this.props.previousLabel - ) + this.props.generateLinkFor({ query: previousQuery, to: location.pathname }, this.props.previousLabel) ); }, @@ -118,11 +112,7 @@ var PaginationBoxView = React.createClass({ return React.createElement( 'li', { onClick: this.handleNextPage, className: nextClasses }, - React.createElement( - Link, - { query: nextQuery, to: location.pathname }, - this.props.nextLabel - ) + this.props.generateLinkFor({ query: nextQuery, to: location.pathname }, this.props.nextLabel) ); }, @@ -136,6 +126,7 @@ var PaginationBoxView = React.createClass({ pageNum: this.props.pageNum, pageRangeDisplayed: this.props.pageRangeDisplayed, marginPagesDisplayed: this.props.marginPagesDisplayed, + generateLinkFor: this.props.generateLinkFor, breakLabel: this.props.breakLabel, subContainerClassName: this.props.subContainerClassName, activeClass: this.props.activeClass, @@ -160,4 +151,4 @@ var PaginationBoxView = React.createClass({ } }); -module.exports = PaginationBoxView; \ No newline at end of file +module.exports = PaginationBoxView; diff --git a/dist/PaginationListView.js b/dist/PaginationListView.js index fc6db42f..cef9c14c 100755 --- a/dist/PaginationListView.js +++ b/dist/PaginationListView.js @@ -1,8 +1,9 @@ 'use strict'; var _ = require('underscore'); -var React = require('react/addons'); +var React = require('react'); var PageView = require('./PageView'); +var createFragment = require('react-addons-create-fragment'); var PaginationListView = React.createClass({ displayName: 'PaginationListView', @@ -16,6 +17,7 @@ var PaginationListView = React.createClass({ return React.createElement(PageView, { onClick: this.props.onPageSelected.bind(null, page), selected: this.props.selected === page, + generateLinkFor: this.props.generateLinkFor, activeClass: this.props.activeClass, page: page + 1, location: this.props.location, @@ -48,6 +50,7 @@ var PaginationListView = React.createClass({ var pageView = React.createElement(PageView, { onClick: this.props.onPageSelected.bind(null, index), selected: this.props.selected === index, + generateLinkFor: this.props.generateLinkFor, activeClass: this.props.activeClass, page: index + 1, location: this.props.location, @@ -81,9 +84,9 @@ var PaginationListView = React.createClass({ return React.createElement( 'ul', { className: this.props.subContainerClassName }, - React.addons.createFragment(items) + createFragment(items) ); } }); -module.exports = PaginationListView; \ No newline at end of file +module.exports = PaginationListView; diff --git a/package.json b/package.json index 3bc5b784..8b4262ed 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,12 @@ "url": "https://github.com/AdeleD/react-paginate/issues" }, "dependencies": { - "underscore": "^1.7.0", - "classnames": "^1.2.0" + "babel": "^5.8.35", + "babel-core": "^5.8.35", + "babel-loader": "^5.4.0", + "classnames": "^1.2.0", + "react-addons-create-fragment": "^0.14.7", + "underscore": "^1.7.0" }, "devDependencies": { "babelify": "^6.0.2", @@ -34,9 +38,8 @@ "gulp-uglify": "^1.1.0", "jest-cli": "^0.2.2", "jquery": "^2.1.3", - "react": "~0.13.1", + "react": "0.14.7", "react-router": "^0.13.3", - "react-tools": "~0.12.2", "serve-static": "^1.9.1", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "~1.0.0", diff --git a/react_components/PaginationListView.js b/react_components/PaginationListView.js index 2c8a9a87..6286f171 100755 --- a/react_components/PaginationListView.js +++ b/react_components/PaginationListView.js @@ -14,6 +14,7 @@ var PaginationListView = React.createClass({ return ( Date: Wed, 16 Mar 2016 14:04:55 -0400 Subject: [PATCH 2/4] [react-router-v2-bandaid] More bandaids for react-router 2.x --- dist/PaginationBoxView.js | 4 ++-- react_components/PageView.js | 3 +-- react_components/PaginationBoxView.js | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dist/PaginationBoxView.js b/dist/PaginationBoxView.js index e31c30c9..109d83ba 100755 --- a/dist/PaginationBoxView.js +++ b/dist/PaginationBoxView.js @@ -88,7 +88,7 @@ var PaginationBoxView = React.createClass({ return React.createElement( 'li', { onClick: this.handlePreviousPage, className: previousClasses }, - this.props.generateLinkFor({ query: previousQuery, to: location.pathname }, this.props.previousLabel) + this.props.generateLinkFor({ query: previousQuery, pathname: location.pathname }, this.props.previousLabel) ); }, @@ -112,7 +112,7 @@ var PaginationBoxView = React.createClass({ return React.createElement( 'li', { onClick: this.handleNextPage, className: nextClasses }, - this.props.generateLinkFor({ query: nextQuery, to: location.pathname }, this.props.nextLabel) + this.props.generateLinkFor({ query: nextQuery, pathname: location.pathname }, this.props.nextLabel) ); }, diff --git a/react_components/PageView.js b/react_components/PageView.js index 0855b65b..dfb37cdb 100755 --- a/react_components/PageView.js +++ b/react_components/PageView.js @@ -19,8 +19,7 @@ var PageView = React.createClass({ return (
  • + to={{ pathname: this.props.location, query }}> {this.props.page}
  • diff --git a/react_components/PaginationBoxView.js b/react_components/PaginationBoxView.js index 5d4827e6..525beab9 100755 --- a/react_components/PaginationBoxView.js +++ b/react_components/PaginationBoxView.js @@ -89,7 +89,7 @@ var PaginationBoxView = React.createClass({ } return (
  • - + {this.props.previousLabel}
  • @@ -115,7 +115,7 @@ var PaginationBoxView = React.createClass({ } return (
  • - + {this.props.nextLabel}
  • From b89d26313b879bfd1416621b99e034ced560c187 Mon Sep 17 00:00:00 2001 From: Rick Runyon Date: Wed, 23 Mar 2016 15:28:38 -0400 Subject: [PATCH 3/4] [react-router-v2-bandaid] Upgrade react-router to v2 --- dist/PageView.js | 15 ++++++++++----- dist/PaginationBoxView.js | 27 ++++++++++++++++++--------- dist/PaginationListView.js | 11 +++++------ package.json | 2 +- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/dist/PageView.js b/dist/PageView.js index 1fa3b777..c4f5793e 100755 --- a/dist/PageView.js +++ b/dist/PageView.js @@ -3,6 +3,9 @@ var _extends = Object.assign || 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; }; var React = require('react'); +var Router = require('react-router'); + +var Link = Router.Link; var PageView = React.createClass({ displayName: 'PageView', @@ -20,12 +23,14 @@ var PageView = React.createClass({ return React.createElement( 'li', { className: cssClass }, - this.props.generateLinkFor( - _extends({}, this.props, { - to: this.props.location, - query: query }), this.props.page) + React.createElement( + Link, + _extends({}, this.props, { + to: { pathname: this.props.location, query: query } }), + this.props.page + ) ); } }); -module.exports = PageView; +module.exports = PageView; \ No newline at end of file diff --git a/dist/PaginationBoxView.js b/dist/PaginationBoxView.js index 109d83ba..ba4613b3 100755 --- a/dist/PaginationBoxView.js +++ b/dist/PaginationBoxView.js @@ -1,9 +1,12 @@ 'use strict'; var React = require('react'); +var Router = require('react-router'); var classNames = require('classnames'); var PaginationListView = require('./PaginationListView'); +var Link = Router.Link; + var PaginationBoxView = React.createClass({ displayName: 'PaginationBoxView', @@ -14,7 +17,6 @@ var PaginationBoxView = React.createClass({ previousLabel: React.PropTypes.node, nextLabel: React.PropTypes.node, breakLabel: React.PropTypes.node, - generateLinkFor: React.PropTypes.func.isRequired, clickCallback: React.PropTypes.func, initialSelected: React.PropTypes.number, forceSelected: React.PropTypes.number, @@ -30,9 +32,9 @@ var PaginationBoxView = React.createClass({ pageNum: 10, pageRangeDisplayed: 2, marginPagesDisplayed: 3, - previousLabel: 'Previous', - nextLabel: 'Next', - breakLabel: '...' + previousLabel: "Previous", + nextLabel: "Next", + breakLabel: "..." }; }, @@ -49,7 +51,7 @@ var PaginationBoxView = React.createClass({ this.setState({ selected: selected }); - if (typeof this.props.clickCallback !== 'undefined' && typeof this.props.clickCallback === 'function') { + if (typeof this.props.clickCallback !== "undefined" && typeof this.props.clickCallback === "function") { this.props.clickCallback({ selected: selected }); } }, @@ -88,7 +90,11 @@ var PaginationBoxView = React.createClass({ return React.createElement( 'li', { onClick: this.handlePreviousPage, className: previousClasses }, - this.props.generateLinkFor({ query: previousQuery, pathname: location.pathname }, this.props.previousLabel) + React.createElement( + Link, + { to: { pathname: location.pathname, query: previousQuery } }, + this.props.previousLabel + ) ); }, @@ -112,7 +118,11 @@ var PaginationBoxView = React.createClass({ return React.createElement( 'li', { onClick: this.handleNextPage, className: nextClasses }, - this.props.generateLinkFor({ query: nextQuery, pathname: location.pathname }, this.props.nextLabel) + React.createElement( + Link, + { to: { pathname: location.pathname, query: nextQuery } }, + this.props.nextLabel + ) ); }, @@ -126,7 +136,6 @@ var PaginationBoxView = React.createClass({ pageNum: this.props.pageNum, pageRangeDisplayed: this.props.pageRangeDisplayed, marginPagesDisplayed: this.props.marginPagesDisplayed, - generateLinkFor: this.props.generateLinkFor, breakLabel: this.props.breakLabel, subContainerClassName: this.props.subContainerClassName, activeClass: this.props.activeClass, @@ -151,4 +160,4 @@ var PaginationBoxView = React.createClass({ } }); -module.exports = PaginationBoxView; +module.exports = PaginationBoxView; \ No newline at end of file diff --git a/dist/PaginationListView.js b/dist/PaginationListView.js index cef9c14c..2a5becfa 100755 --- a/dist/PaginationListView.js +++ b/dist/PaginationListView.js @@ -1,9 +1,8 @@ 'use strict'; var _ = require('underscore'); -var React = require('react'); +var React = require('react/addons'); var PageView = require('./PageView'); -var createFragment = require('react-addons-create-fragment'); var PaginationListView = React.createClass({ displayName: 'PaginationListView', @@ -16,8 +15,8 @@ var PaginationListView = React.createClass({ var pageViews = _.range(0, this.props.pageNum).map((function (page) { return React.createElement(PageView, { onClick: this.props.onPageSelected.bind(null, page), - selected: this.props.selected === page, generateLinkFor: this.props.generateLinkFor, + selected: this.props.selected === page, activeClass: this.props.activeClass, page: page + 1, location: this.props.location, @@ -49,8 +48,8 @@ var PaginationListView = React.createClass({ var pageView = React.createElement(PageView, { onClick: this.props.onPageSelected.bind(null, index), - selected: this.props.selected === index, generateLinkFor: this.props.generateLinkFor, + selected: this.props.selected === index, activeClass: this.props.activeClass, page: index + 1, location: this.props.location, @@ -84,9 +83,9 @@ var PaginationListView = React.createClass({ return React.createElement( 'ul', { className: this.props.subContainerClassName }, - createFragment(items) + React.addons.createFragment(items) ); } }); -module.exports = PaginationListView; +module.exports = PaginationListView; \ No newline at end of file diff --git a/package.json b/package.json index 8b4262ed..4734ca8f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "jest-cli": "^0.2.2", "jquery": "^2.1.3", "react": "0.14.7", - "react-router": "^0.13.3", + "react-router": "^2.0.1", "serve-static": "^1.9.1", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "~1.0.0", From 44bef29ba8187fe934fc8d9ad1d66704adc57688 Mon Sep 17 00:00:00 2001 From: Rick Runyon Date: Thu, 24 Mar 2016 09:37:35 -0400 Subject: [PATCH 4/4] [react-router-v2-bandaid] Use addon package --- dist/PaginationListView.js | 6 ++++-- package.json | 1 + react_components/PaginationListView.js | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dist/PaginationListView.js b/dist/PaginationListView.js index 2a5becfa..2f5231b9 100755 --- a/dist/PaginationListView.js +++ b/dist/PaginationListView.js @@ -1,9 +1,11 @@ 'use strict'; var _ = require('underscore'); -var React = require('react/addons'); +var React = require('react'); var PageView = require('./PageView'); +var createFragment = require('react-addons-create-fragment'); + var PaginationListView = React.createClass({ displayName: 'PaginationListView', @@ -83,7 +85,7 @@ var PaginationListView = React.createClass({ return React.createElement( 'ul', { className: this.props.subContainerClassName }, - React.addons.createFragment(items) + createFragment(items) ); } }); diff --git a/package.json b/package.json index 4734ca8f..83c2a748 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "jest-cli": "^0.2.2", "jquery": "^2.1.3", "react": "0.14.7", + "react-addons-create-fragment": "^0.14.7", "react-router": "^2.0.1", "serve-static": "^1.9.1", "vinyl-buffer": "^1.0.0", diff --git a/react_components/PaginationListView.js b/react_components/PaginationListView.js index 6286f171..3fe2cb72 100755 --- a/react_components/PaginationListView.js +++ b/react_components/PaginationListView.js @@ -1,9 +1,11 @@ 'use strict'; var _ = require('underscore'); -var React = require('react/addons'); +var React = require('react'); var PageView = require('./PageView'); +var createFragment = require('react-addons-create-fragment'); + var PaginationListView = React.createClass({ render: function() { var items = {}; @@ -86,7 +88,7 @@ var PaginationListView = React.createClass({ return (
      - {React.addons.createFragment(items)} + {createFragment(items)}
    ); }