Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-js-pagination

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-js-pagination - npm Package Compare versions

Comparing version 3.0.2 to 3.0.3

src/components/Page.test.js

124

dist/Page.js

@@ -1,1 +0,123 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),_react=require("react"),_react2=_interopRequireDefault(_react),_propTypes=require("prop-types"),_propTypes2=_interopRequireDefault(_propTypes),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var Page=function(e){function t(){return _classCallCheck(this,t),_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return _inherits(t,_react.Component),_createClass(t,[{key:"handleClick",value:function(e){var t=this.props,r=t.isDisabled,a=t.pageNumber;e.preventDefault(),r||this.props.onClick(a)}},{key:"render",value:function(){var e,t=this.props,r=t.pageText,a=(t.pageNumber,t.activeClass),n=t.itemClass,s=t.linkClass,i=t.activeLinkClass,o=t.disabledClass,l=t.isActive,c=t.isDisabled,u=t.href,p=(0,_classnames2.default)(n,(_defineProperty(e={},a,l),_defineProperty(e,o,c),e)),f=(0,_classnames2.default)(s,_defineProperty({},i,l));return _react2.default.createElement("li",{className:p,onClick:this.handleClick.bind(this)},_react2.default.createElement("a",{className:f,href:u},r))}}]),t}();Page.defaultProps={activeClass:"active",disabledClass:"disabled",itemClass:void 0,linkClass:void 0,activeLinkCLass:void 0,isActive:!1,isDisabled:!1,href:"#"},exports.default=Page;
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var Page =
/*#__PURE__*/
function (_Component) {
_inherits(Page, _Component);
function Page() {
_classCallCheck(this, Page);
return _possibleConstructorReturn(this, _getPrototypeOf(Page).apply(this, arguments));
}
_createClass(Page, [{
key: "handleClick",
value: function handleClick(e) {
var _this$props = this.props,
isDisabled = _this$props.isDisabled,
pageNumber = _this$props.pageNumber;
e.preventDefault();
if (isDisabled) {
return;
}
this.props.onClick(pageNumber);
}
}, {
key: "render",
value: function render() {
var _cx;
var _this$props2 = this.props,
pageText = _this$props2.pageText,
pageNumber = _this$props2.pageNumber,
activeClass = _this$props2.activeClass,
itemClass = _this$props2.itemClass,
linkClass = _this$props2.linkClass,
activeLinkClass = _this$props2.activeLinkClass,
disabledClass = _this$props2.disabledClass,
isActive = _this$props2.isActive,
isDisabled = _this$props2.isDisabled,
href = _this$props2.href,
ariaLabel = _this$props2.ariaLabel;
var css = (0, _classnames["default"])(itemClass, (_cx = {}, _defineProperty(_cx, activeClass, isActive), _defineProperty(_cx, disabledClass, isDisabled), _cx));
var linkCss = (0, _classnames["default"])(linkClass, _defineProperty({}, activeLinkClass, isActive));
return _react["default"].createElement("li", {
className: css,
onClick: this.handleClick.bind(this)
}, _react["default"].createElement("a", {
className: linkCss,
href: href,
"aria-label": ariaLabel
}, pageText));
}
}]);
return Page;
}(_react.Component);
exports["default"] = Page;
_defineProperty(Page, "propTypes", {
pageText: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].element]),
pageNumber: _propTypes["default"].number.isRequired,
onClick: _propTypes["default"].func.isRequired,
isActive: _propTypes["default"].bool.isRequired,
isDisabled: _propTypes["default"].bool,
activeClass: _propTypes["default"].string,
activeLinkClass: _propTypes["default"].string,
itemClass: _propTypes["default"].string,
linkClass: _propTypes["default"].string,
disabledClass: _propTypes["default"].string,
href: _propTypes["default"].string
});
_defineProperty(Page, "defaultProps", {
activeClass: "active",
disabledClass: "disabled",
itemClass: undefined,
linkClass: undefined,
activeLinkCLass: undefined,
isActive: false,
isDisabled: false,
href: "#"
});

@@ -1,1 +0,253 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,a){for(var t=0;t<a.length;t++){var s=a[t];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}return function(a,t,s){return t&&e(a.prototype,t),s&&e(a,s),a}}(),_react=require("react"),_react2=_interopRequireDefault(_react),_propTypes=require("prop-types"),_propTypes2=_interopRequireDefault(_propTypes),_paginator=require("paginator"),_paginator2=_interopRequireDefault(_paginator),_Page=require("./Page"),_Page2=_interopRequireDefault(_Page),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,a){if(!(e instanceof a))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,a){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!=typeof a&&"function"!=typeof a?e:a}function _inherits(e,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function, not "+typeof a);e.prototype=Object.create(a&&a.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),a&&(Object.setPrototypeOf?Object.setPrototypeOf(e,a):e.__proto__=a)}var Pagination=function(e){function a(){return _classCallCheck(this,a),_possibleConstructorReturn(this,(a.__proto__||Object.getPrototypeOf(a)).apply(this,arguments))}return _inherits(a,_react2.default.Component),_createClass(a,[{key:"isFirstPageVisible",value:function(e){var a=this.props,t=a.hideDisabled;a.hideNavigation;return!(a.hideFirstLastPages||t&&!e)}},{key:"isPrevPageVisible",value:function(e){var a=this.props,t=a.hideDisabled;return!(a.hideNavigation||t&&!e)}},{key:"isNextPageVisible",value:function(e){var a=this.props,t=a.hideDisabled;return!(a.hideNavigation||t&&!e)}},{key:"isLastPageVisible",value:function(e){var a=this.props,t=a.hideDisabled;a.hideNavigation;return!(a.hideFirstLastPages||t&&!e)}},{key:"buildPages",value:function(){for(var e=[],a=this.props,t=a.itemsCountPerPage,s=a.pageRangeDisplayed,i=a.activePage,r=a.prevPageText,l=a.nextPageText,n=a.firstPageText,u=a.lastPageText,o=a.totalItemsCount,p=a.onChange,c=a.activeClass,g=a.itemClass,_=a.itemClassFirst,f=a.itemClassPrev,d=a.itemClassNext,h=a.itemClassLast,C=a.activeLinkClass,P=a.disabledClass,b=(a.hideDisabled,a.hideNavigation,a.linkClass),v=a.linkClassFirst,m=a.linkClassPrev,k=a.linkClassNext,y=a.linkClassLast,x=(a.hideFirstLastPages,a.getPageUrl),T=new _paginator2.default(t,s).build(o,i),D=T.first_page;D<=T.last_page;D++)e.push(_react2.default.createElement(_Page2.default,{isActive:D===i,key:D,href:x(D),pageNumber:D,pageText:D+"",onClick:p,itemClass:g,linkClass:b,activeClass:c,activeLinkClass:C}));return this.isPrevPageVisible(T.has_previous_page)&&e.unshift(_react2.default.createElement(_Page2.default,{key:"prev"+T.previous_page,pageNumber:T.previous_page,onClick:p,pageText:r,isDisabled:!T.has_previous_page,itemClass:(0,_classnames2.default)(g,f),linkClass:(0,_classnames2.default)(b,m),disabledClass:P})),this.isFirstPageVisible(T.has_previous_page)&&e.unshift(_react2.default.createElement(_Page2.default,{key:"first",pageNumber:1,onClick:p,pageText:n,isDisabled:!T.has_previous_page,itemClass:(0,_classnames2.default)(g,_),linkClass:(0,_classnames2.default)(b,v),disabledClass:P})),this.isNextPageVisible(T.has_next_page)&&e.push(_react2.default.createElement(_Page2.default,{key:"next"+T.next_page,pageNumber:T.next_page,onClick:p,pageText:l,isDisabled:!T.has_next_page,itemClass:(0,_classnames2.default)(g,d),linkClass:(0,_classnames2.default)(b,k),disabledClass:P})),this.isLastPageVisible(T.has_next_page)&&e.push(_react2.default.createElement(_Page2.default,{key:"last",pageNumber:T.total_pages,onClick:p,pageText:u,isDisabled:T.current_page===T.total_pages,itemClass:(0,_classnames2.default)(g,h),linkClass:(0,_classnames2.default)(b,y),disabledClass:P})),e}},{key:"render",value:function(){var e=this.buildPages();return _react2.default.createElement("ul",{className:this.props.innerClass},e)}}]),a}();Pagination.defaultProps={itemsCountPerPage:10,pageRangeDisplayed:5,activePage:1,prevPageText:"⟨",firstPageText:"«",nextPageText:"⟩",lastPageText:"»",innerClass:"pagination",itemClass:void 0,linkClass:void 0,activeLinkClass:void 0,hideFirstLastPages:!1,getPageUrl:function(e){return"#"}},exports.default=Pagination;
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _paginator = _interopRequireDefault(require("paginator"));
var _Page = _interopRequireDefault(require("./Page"));
var _classnames = _interopRequireDefault(require("classnames"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var Pagination =
/*#__PURE__*/
function (_React$Component) {
_inherits(Pagination, _React$Component);
function Pagination() {
_classCallCheck(this, Pagination);
return _possibleConstructorReturn(this, _getPrototypeOf(Pagination).apply(this, arguments));
}
_createClass(Pagination, [{
key: "isFirstPageVisible",
value: function isFirstPageVisible(has_previous_page) {
var _this$props = this.props,
hideDisabled = _this$props.hideDisabled,
hideNavigation = _this$props.hideNavigation,
hideFirstLastPages = _this$props.hideFirstLastPages;
if (hideFirstLastPages || hideDisabled && !has_previous_page) return false;
return true;
}
}, {
key: "isPrevPageVisible",
value: function isPrevPageVisible(has_previous_page) {
var _this$props2 = this.props,
hideDisabled = _this$props2.hideDisabled,
hideNavigation = _this$props2.hideNavigation;
if (hideNavigation || hideDisabled && !has_previous_page) return false;
return true;
}
}, {
key: "isNextPageVisible",
value: function isNextPageVisible(has_next_page) {
var _this$props3 = this.props,
hideDisabled = _this$props3.hideDisabled,
hideNavigation = _this$props3.hideNavigation;
if (hideNavigation || hideDisabled && !has_next_page) return false;
return true;
}
}, {
key: "isLastPageVisible",
value: function isLastPageVisible(has_next_page) {
var _this$props4 = this.props,
hideDisabled = _this$props4.hideDisabled,
hideNavigation = _this$props4.hideNavigation,
hideFirstLastPages = _this$props4.hideFirstLastPages;
if (hideFirstLastPages || hideDisabled && !has_next_page) return false;
return true;
}
}, {
key: "buildPages",
value: function buildPages() {
var pages = [];
var _this$props5 = this.props,
itemsCountPerPage = _this$props5.itemsCountPerPage,
pageRangeDisplayed = _this$props5.pageRangeDisplayed,
activePage = _this$props5.activePage,
prevPageText = _this$props5.prevPageText,
nextPageText = _this$props5.nextPageText,
firstPageText = _this$props5.firstPageText,
lastPageText = _this$props5.lastPageText,
totalItemsCount = _this$props5.totalItemsCount,
onChange = _this$props5.onChange,
activeClass = _this$props5.activeClass,
itemClass = _this$props5.itemClass,
itemClassFirst = _this$props5.itemClassFirst,
itemClassPrev = _this$props5.itemClassPrev,
itemClassNext = _this$props5.itemClassNext,
itemClassLast = _this$props5.itemClassLast,
activeLinkClass = _this$props5.activeLinkClass,
disabledClass = _this$props5.disabledClass,
hideDisabled = _this$props5.hideDisabled,
hideNavigation = _this$props5.hideNavigation,
linkClass = _this$props5.linkClass,
linkClassFirst = _this$props5.linkClassFirst,
linkClassPrev = _this$props5.linkClassPrev,
linkClassNext = _this$props5.linkClassNext,
linkClassLast = _this$props5.linkClassLast,
hideFirstLastPages = _this$props5.hideFirstLastPages,
getPageUrl = _this$props5.getPageUrl;
var paginationInfo = new _paginator["default"](itemsCountPerPage, pageRangeDisplayed).build(totalItemsCount, activePage);
for (var i = paginationInfo.first_page; i <= paginationInfo.last_page; i++) {
pages.push(_react["default"].createElement(_Page["default"], {
isActive: i === activePage,
key: i,
href: getPageUrl(i),
pageNumber: i,
pageText: i + "",
onClick: onChange,
itemClass: itemClass,
linkClass: linkClass,
activeClass: activeClass,
activeLinkClass: activeLinkClass,
ariaLabel: "Go to page number ".concat(i)
}));
}
this.isPrevPageVisible(paginationInfo.has_previous_page) && pages.unshift(_react["default"].createElement(_Page["default"], {
key: "prev" + paginationInfo.previous_page,
href: getPageUrl(paginationInfo.previous_page),
pageNumber: paginationInfo.previous_page,
onClick: onChange,
pageText: prevPageText,
isDisabled: !paginationInfo.has_previous_page,
itemClass: (0, _classnames["default"])(itemClass, itemClassPrev),
linkClass: (0, _classnames["default"])(linkClass, linkClassPrev),
disabledClass: disabledClass,
ariaLabel: "Go to previous page"
}));
this.isFirstPageVisible(paginationInfo.has_previous_page) && pages.unshift(_react["default"].createElement(_Page["default"], {
key: "first",
href: getPageUrl(1),
pageNumber: 1,
onClick: onChange,
pageText: firstPageText,
isDisabled: !paginationInfo.has_previous_page,
itemClass: (0, _classnames["default"])(itemClass, itemClassFirst),
linkClass: (0, _classnames["default"])(linkClass, linkClassFirst),
disabledClass: disabledClass,
ariaLabel: "Go to first page"
}));
this.isNextPageVisible(paginationInfo.has_next_page) && pages.push(_react["default"].createElement(_Page["default"], {
key: "next" + paginationInfo.next_page,
href: getPageUrl(paginationInfo.next_page),
pageNumber: paginationInfo.next_page,
onClick: onChange,
pageText: nextPageText,
isDisabled: !paginationInfo.has_next_page,
itemClass: (0, _classnames["default"])(itemClass, itemClassNext),
linkClass: (0, _classnames["default"])(linkClass, linkClassNext),
disabledClass: disabledClass,
ariaLabel: "Go to next page"
}));
this.isLastPageVisible(paginationInfo.has_next_page) && pages.push(_react["default"].createElement(_Page["default"], {
key: "last",
href: getPageUrl(paginationInfo.total_pages),
pageNumber: paginationInfo.total_pages,
onClick: onChange,
pageText: lastPageText,
isDisabled: paginationInfo.current_page === paginationInfo.total_pages,
itemClass: (0, _classnames["default"])(itemClass, itemClassLast),
linkClass: (0, _classnames["default"])(linkClass, linkClassLast),
disabledClass: disabledClass,
ariaLabel: "Go to last page"
}));
return pages;
}
}, {
key: "render",
value: function render() {
var pages = this.buildPages();
return _react["default"].createElement("ul", {
className: this.props.innerClass
}, pages);
}
}]);
return Pagination;
}(_react["default"].Component);
exports["default"] = Pagination;
_defineProperty(Pagination, "propTypes", {
totalItemsCount: _propTypes["default"].number.isRequired,
onChange: _propTypes["default"].func.isRequired,
activePage: _propTypes["default"].number,
itemsCountPerPage: _propTypes["default"].number,
pageRangeDisplayed: _propTypes["default"].number,
prevPageText: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].element]),
nextPageText: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].element]),
lastPageText: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].element]),
firstPageText: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].element]),
disabledClass: _propTypes["default"].string,
hideDisabled: _propTypes["default"].bool,
hideNavigation: _propTypes["default"].bool,
innerClass: _propTypes["default"].string,
itemClass: _propTypes["default"].string,
itemClassFirst: _propTypes["default"].string,
itemClassPrev: _propTypes["default"].string,
itemClassNext: _propTypes["default"].string,
itemClassLast: _propTypes["default"].string,
linkClass: _propTypes["default"].string,
activeClass: _propTypes["default"].string,
activeLinkClass: _propTypes["default"].string,
linkClassFirst: _propTypes["default"].string,
linkClassPrev: _propTypes["default"].string,
linkClassNext: _propTypes["default"].string,
linkClassLast: _propTypes["default"].string,
hideFirstLastPages: _propTypes["default"].bool,
getPageUrl: _propTypes["default"].func
});
_defineProperty(Pagination, "defaultProps", {
itemsCountPerPage: 10,
pageRangeDisplayed: 5,
activePage: 1,
prevPageText: "⟨",
firstPageText: "«",
nextPageText: "⟩",
lastPageText: "»",
innerClass: "pagination",
itemClass: undefined,
linkClass: undefined,
activeLinkClass: undefined,
hideFirstLastPages: false,
getPageUrl: function getPageUrl(i) {
return "#";
}
});

58

package.json
{
"name": "react-js-pagination",
"version": "3.0.2",
"version": "3.0.3",
"description": "Simple, easy to use component for pagination. Compatible with bootstrap paginator stylesheets",

@@ -9,3 +9,3 @@ "main": "./dist/Pagination.js",

"clean-example": "rimraf src/example/dist",
"build": "npm run clean && cross-env NODE_ENV=production node build.js",
"build": "npm run clean && babel src/components --out-dir dist --ignore 'src/components/*.test.js'",
"build-example": "npm run clean-example && npm run build:webpack",

@@ -15,5 +15,5 @@ "build:webpack": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js",

"lint": "eslint 'src/components/**/*.js'",
"test": "mocha --compilers js:babel-register --require ./test-setup.js 'src/**/*-test.js'",
"validate": "npm-run-all lint test",
"test:watch": "mocha -w --compilers js:babel-register --require ./test-setup.js 'src/**/*-test.js'"
"test": "jest",
"test:watch": "jest --watch --runInBand"
},

@@ -24,2 +24,15 @@ "repository": {

},
"jest": {
"moduleDirectories": [
"node_modules",
"<rootDir>"
],
"verbose": false,
"transform": {
"^.+\\.jsx?$": "babel-jest"
},
"setupFiles": [
"./test-setup.js"
]
},
"keywords": [

@@ -44,12 +57,12 @@ "react",

"devDependencies": {
"babel-core": "6.18.2",
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/polyfill": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.4.4",
"babel-eslint": "7.1.1",
"babel-loader": "6.2.8",
"babel-plugin-transform-react-remove-prop-types": "^0.4.9",
"babel-preset-es2015": "6.18.0",
"babel-preset-react": "6.16.0",
"babel-preset-stage-0": "^6.16.0",
"babel-register": "^6.18.0",
"babel-loader": "^8.0.6",
"bootstrap": "^3.3.5",
"chai": "^3.5.0",
"cross-env": "^1.0.7",

@@ -64,7 +77,7 @@ "css-loader": "^0.19.0",

"file-loader": "^0.8.4",
"jest": "^24.8.0",
"jsdom": "^8.0.4",
"less": "^2.5.3",
"less-loader": "^2.2.1",
"less": "^3.9.0",
"less-loader": "^5.0.0",
"mkdirp": "^0.5.1",
"mocha": "^2.4.5",
"npm-run-all": "^4.0.2",

@@ -78,7 +91,8 @@ "prettier": "^1.7.4",

"rimraf": "^2.4.3",
"style-loader": "^0.12.4",
"uglify-js": "^3.1.3",
"url-loader": "^0.5.6",
"webpack": "^1.12.14",
"webpack-dev-middleware": "^1.2.0",
"style-loader": "^0.23.1",
"uglify-js": "^3.6.0",
"url-loader": "^1.1.2",
"webpack": "^4.32.2",
"webpack-cli": "^3.3.2",
"webpack-dev-middleware": "^3.7.0",
"webpack-hot-middleware": "^2.0.0"

@@ -88,6 +102,8 @@ },

"classnames": "^2.2.5",
"fstream": "1.0.12",
"paginator": "^1.0.0",
"prop-types": "15.x.x - 16.x.x",
"react": "15.x.x - 16.x.x"
"react": "15.x.x - 16.x.x",
"tar": "2.2.2"
}
}

@@ -9,4 +9,10 @@ [![Build Status](https://travis-ci.org/vayser/react-js-pagination.svg?branch=master)](https://travis-ci.org/vayser/react-js-pagination)

The component comes with no built-in styles. HTML layout compatible with [Bootstrap](http://getbootstrap.com/components/#pagination) pagination stylesheets.
The component comes with no built-in styles. HTML layout compatible with [Bootstrap 3](https://getbootstrap.com/docs/3.4/components/#pagination) pagination stylesheets.
If you would like it to work for Bootstrap 4, you will need to add 2 additional props when using this component:
```
itemClass="page-item"
linkClass="page-link"
```
## Installation

@@ -51,3 +57,3 @@

pageRangeDisplayed={5}
onChange={::this.handlePageChange}
onChange={this.handlePageChange.bind(this)}
/>

@@ -54,0 +60,0 @@ </div>

@@ -51,3 +51,4 @@ import React, { Component } from "react";

isDisabled,
href
href,
ariaLabel
} = this.props;

@@ -65,4 +66,4 @@

return (
<li className={css} onClick={::this.handleClick}>
<a className={linkCss} href={href}>
<li className={css} onClick={this.handleClick.bind(this)}>
<a className={linkCss} href={href} aria-label={ariaLabel}>
{pageText}

@@ -69,0 +70,0 @@ </a>

@@ -131,2 +131,3 @@ import React, { Component } from "react";

activeLinkClass={activeLinkClass}
ariaLabel={`Go to page number ${i}`}
/>

@@ -136,6 +137,7 @@ );

this.isPrevPageVisible(paginationInfo.has_previous_page) &&
this.isPrevPageVisible(paginationInfo.has_previous_page) &&
pages.unshift(
<Page
key={"prev" + paginationInfo.previous_page}
href={getPageUrl(paginationInfo.previous_page)}
pageNumber={paginationInfo.previous_page}

@@ -148,9 +150,11 @@ onClick={onChange}

disabledClass={disabledClass}
ariaLabel="Go to previous page"
/>
);
this.isFirstPageVisible(paginationInfo.has_previous_page) &&
this.isFirstPageVisible(paginationInfo.has_previous_page) &&
pages.unshift(
<Page
key={"first"}
href={getPageUrl(1)}
pageNumber={1}

@@ -163,2 +167,3 @@ onClick={onChange}

disabledClass={disabledClass}
ariaLabel="Go to first page"
/>

@@ -171,2 +176,3 @@ );

key={"next" + paginationInfo.next_page}
href={getPageUrl(paginationInfo.next_page)}
pageNumber={paginationInfo.next_page}

@@ -179,2 +185,3 @@ onClick={onChange}

disabledClass={disabledClass}
ariaLabel="Go to next page"
/>

@@ -187,2 +194,3 @@ );

key={"last"}
href={getPageUrl(paginationInfo.total_pages)}
pageNumber={paginationInfo.total_pages}

@@ -197,2 +205,3 @@ onClick={onChange}

disabledClass={disabledClass}
ariaLabel="Go to last page"
/>

@@ -199,0 +208,0 @@ );

@@ -17,3 +17,3 @@ import React, { Component } from "react";

};
this.handlePageChange = ::this._handlePageChange;
this.handlePageChange = this._handlePageChange.bind(this);
}

@@ -20,0 +20,0 @@

@@ -1,20 +0,5 @@

import React from "react";
import {expect} from "chai";
import jsdom from "jsdom";
import "@babel/polyfill";
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
const doc = jsdom.jsdom("<!doctype html><html><body></body></html>");
const win = doc.defaultView;
global.document = doc;
global.window = win;
Object.keys(window).forEach(key => {
if (!(key in global)) {
global[key] = window[key];
}
});
global.React = React;
global.expect = expect;
global.window.__config = {};
configure({ adapter: new Adapter() });

@@ -6,2 +6,3 @@ var path = require("path");

devtool: "cheap-module-source-map",
mode: "development",
entry: [

@@ -18,24 +19,34 @@ "react-hot-loader/patch",

plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
new webpack.HotModuleReplacementPlugin()
],
resolveLoader: { root: path.join(__dirname, "node_modules") },
resolve: {
modules: [__dirname, "node_modules"],
},
module: {
loaders: [
{
test: /\.js$/,
loader: "babel",
include: path.join(__dirname, "src"),
exclude: /(node_modules|bower_components)/
},
{
test: /\.less$/,
loader: "style!css!less"
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: "url-loader?limit=100000"
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
]
}, {
test: /\.less$/,
use: [
{
loader: "style-loader", // creates style nodes from JS strings
},
{
loader: "css-loader", // translates CSS into CommonJS
},
{
loader: "less-loader", // compiles Less to CSS
},
],
}, {
test: /\.(otf|eot|png|svg|ttf|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [{
loader: "url-loader"
}]
}]
}
};

@@ -15,3 +15,2 @@ var path = require("path");

plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({

@@ -21,26 +20,31 @@ "process.env": {

}
}),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
})
],
module: {
loaders: [
{
test: /\.js$/,
loader: "babel",
include: path.join(__dirname, "src"),
exclude: /(node_modules|bower_components)/
},
{
test: /\.less$/,
loader: "style!css!less"
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: "url-loader?limit=100000"
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
]
}, {
test: /\.less$/,
use: [
{
loader: "style-loader", // creates style nodes from JS strings
},
{
loader: "css-loader", // translates CSS into CommonJS
},
{
loader: "less-loader", // compiles Less to CSS
},
],
}, {
test: /\.(otf|eot|png|svg|ttf|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [{
loader: "url-loader"
}]
}]
}
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc