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

@doctolib/react-paginator

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@doctolib/react-paginator - npm Package Compare versions

Comparing version 2.0.2 to 3.0.0

lib/__snapshots__/Paginator.test.js.snap

42

lib/Button.js

@@ -9,5 +9,5 @@ 'use strict';

var _PureComponent2 = require('./PureComponent');
var _propTypes = require('prop-types');
var _PureComponent3 = _interopRequireDefault(_PureComponent2);
var _propTypes2 = _interopRequireDefault(_propTypes);

@@ -24,7 +24,8 @@ var _classnames = require('classnames');

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint-disable jsx-a11y/href-no-hash */
var Button = function (_PureComponent) {
_inherits(Button, _PureComponent);
var Button = function (_React$PureComponent) {
_inherits(Button, _React$PureComponent);
function Button() {

@@ -39,3 +40,3 @@ var _temp, _this, _ret;

return _ret = (_temp = (_this = _possibleConstructorReturn(this, _PureComponent.call.apply(_PureComponent, [this].concat(args))), _this), _this.handleClick = function (event) {
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args))), _this), _this.handleClick = function (event) {
event.preventDefault();

@@ -54,10 +55,10 @@ if (_this.props.onPageChange) _this.props.onPageChange(_this.props.page);

Button.prototype.render = function render() {
var className = (0, _classnames2.default)({
disabled: this.props.disabled,
active: this.props.active
});
return _react2.default.createElement(
'li',
{ className: className },
{
className: (0, _classnames2.default)({
disabled: this.props.disabled,
active: this.props.active
})
},
_react2.default.createElement(

@@ -76,16 +77,15 @@ 'a',

return Button;
}(_PureComponent3.default);
}(_react2.default.PureComponent);
Button.propTypes = {
active: _react.PropTypes.bool.isRequired,
ariaLabel: _react.PropTypes.string,
disabled: _react.PropTypes.bool.isRequired,
label: _react.PropTypes.string.isRequired,
onPageChange: _react.PropTypes.func,
page: _react.PropTypes.number
active: _propTypes2.default.bool.isRequired,
ariaLabel: _propTypes2.default.string,
disabled: _propTypes2.default.bool.isRequired,
label: _propTypes2.default.string.isRequired,
onPageChange: _propTypes2.default.func,
page: _propTypes2.default.number
};
Button.defaultProps = {
active: false,
disabled: false
};
disabled: false };
exports.default = Button;

@@ -9,5 +9,5 @@ 'use strict';

var _PureComponent2 = require('./PureComponent');
var _propTypes = require('prop-types');
var _PureComponent3 = _interopRequireDefault(_PureComponent2);
var _propTypes2 = _interopRequireDefault(_propTypes);

@@ -18,35 +18,21 @@ var _utils = require('./utils');

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Infos = function Infos(_ref) {
var max = _ref.max,
min = _ref.min,
size = _ref.size,
total = _ref.total;
return _react2.default.createElement(
'div',
{ className: 'pagination-infos pagination-infos-' + _utils.SIZE_PREFIXES[size] },
min + '-' + max + ' / ' + total
);
};
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Infos = function (_PureComponent) {
_inherits(Infos, _PureComponent);
function Infos() {
_classCallCheck(this, Infos);
return _possibleConstructorReturn(this, _PureComponent.apply(this, arguments));
}
Infos.prototype.render = function render() {
var className = 'pagination-infos pagination-infos-' + _utils.SIZE_PREFIXES[this.props.size];
return _react2.default.createElement(
'div',
{ className: className },
this.props.min + '-' + this.props.max + ' / ' + this.props.total
);
};
return Infos;
}(_PureComponent3.default);
Infos.propTypes = {
max: _react.PropTypes.number.isRequired,
min: _react.PropTypes.number.isRequired,
size: _react.PropTypes.string.isRequired,
total: _react.PropTypes.number.isRequired
max: _propTypes2.default.number.isRequired,
min: _propTypes2.default.number.isRequired,
size: _propTypes2.default.string.isRequired,
total: _propTypes2.default.number.isRequired
};
exports.default = Infos;

@@ -9,5 +9,5 @@ 'use strict';

var _PureComponent2 = require('./PureComponent');
var _propTypes = require('prop-types');
var _PureComponent3 = _interopRequireDefault(_PureComponent2);
var _propTypes2 = _interopRequireDefault(_propTypes);

@@ -36,4 +36,4 @@ var _lodash = require('lodash.range');

var Paginator = function (_PureComponent) {
_inherits(Paginator, _PureComponent);
var Paginator = function (_React$PureComponent) {
_inherits(Paginator, _React$PureComponent);

@@ -49,3 +49,3 @@ function Paginator() {

return _ret = (_temp = (_this = _possibleConstructorReturn(this, _PureComponent.call.apply(_PureComponent, [this].concat(args))), _this), _this.handlePageChange = function (page) {
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args))), _this), _this.handlePageChange = function (page) {
if (page >= 1 && page <= _this.getNbPages() && !_this.props.disabled) _this.props.onPageChange(page);

@@ -63,15 +63,2 @@ }, _this.renderPage = function (page, index) {

/**
* Called when page change.
*
* @param {number} page
*/
/**
* Get number of pages.
*
* @returns {number}
*/
Paginator.prototype.getNbPages = function getNbPages() {

@@ -82,9 +69,2 @@ var nbPages = Math.ceil(this.props.total / this.props.nbRowsPerPage);

/**
* Get min range.
*
* @returns {number}
*/
Paginator.prototype.getMinRange = function getMinRange() {

@@ -94,9 +74,2 @@ return (Math.ceil(this.props.page / this.props.pageRange) - 1) * this.props.pageRange + 1;

/**
* Get max range.
*
* @returns {number}
*/
Paginator.prototype.getMaxRange = function getMaxRange() {

@@ -107,8 +80,2 @@ var max = this.getMinRange() + this.props.pageRange - 1;

/**
* Render informations.
*
* @returns {ReactElement}
*/
Paginator.prototype.renderInfos = function renderInfos() {

@@ -125,9 +92,2 @@ if (!this.props.showInfos) return null;

/**
* Render pages.
*
* @returns {ReactElement[]}
*/
Paginator.prototype.renderPages = function renderPages() {

@@ -139,17 +99,2 @@ if (this.props.disabled) return _react2.default.createElement(_Button2.default, { disabled: true, label: this.props.breakLabel });

/**
* Render page.
*
* @param {number} page
* @param {number} index
* @returns {ReactElement}
*/
/**
* Render previous button.
*
* @returns {ReactElement}
*/
Paginator.prototype.renderPrevious = function renderPrevious() {

@@ -164,9 +109,2 @@ return this.renderNeighbour({

/**
* Render next button.
*
* @returns {ReactElement}
*/
Paginator.prototype.renderNext = function renderNext() {

@@ -181,19 +119,7 @@ return this.renderNeighbour({

/**
* Render neighbour.
*
* @param {object} options
* @param {string} options.ariaLabel
* @param {boolean} options.disabled
* @param {string} options.label
* @param {number} options.page
* @returns {ReactElement}
*/
Paginator.prototype.renderNeighbour = function renderNeighbour(_ref) {
var ariaLabel = _ref.ariaLabel;
var disabled = _ref.disabled;
var label = _ref.label;
var page = _ref.page;
var ariaLabel = _ref.ariaLabel,
disabled = _ref.disabled,
label = _ref.label,
page = _ref.page;

@@ -209,9 +135,2 @@ return _react2.default.createElement(_Button2.default, {

/**
* Render the last buttton.
*
* @returns {ReactElement}
*/
Paginator.prototype.renderFirst = function renderFirst() {

@@ -225,9 +144,2 @@ return this.renderBoundary({

/**
* Render the last buttton.
*
* @returns {ReactElement}
*/
Paginator.prototype.renderLast = function renderLast() {

@@ -241,17 +153,6 @@ return this.renderBoundary({

/**
* Render boundary.
*
* @param {object} options
* @param {string} options.ariaLabel
* @param {string} options.label
* @param {number} options.page
* @returns {ReactElement}
*/
Paginator.prototype.renderBoundary = function renderBoundary(_ref2) {
var ariaLabel = _ref2.ariaLabel;
var label = _ref2.label;
var page = _ref2.page;
var ariaLabel = _ref2.ariaLabel,
label = _ref2.label,
page = _ref2.page;

@@ -267,9 +168,2 @@ return _react2.default.createElement(_Button2.default, {

/**
* Render previous break.
*
* @returns {ReactElement}
*/
Paginator.prototype.renderPreviousBreak = function renderPreviousBreak() {

@@ -279,9 +173,2 @@ return this.renderBreak(this.getMinRange() - 1);

/**
* Render next break.
*
* @returns {ReactElement}
*/
Paginator.prototype.renderNextBreak = function renderNextBreak() {

@@ -291,18 +178,6 @@ return this.renderBreak(this.getMaxRange() + 1);

/**
* Render break.
*
* @param {number} page
* @returns {ReactElement}
*/
Paginator.prototype.renderBreak = function renderBreak(page) {
if (this.props.disabled || page >= this.getNbPages() || page <= 0) return null;
return _react2.default.createElement(_Button2.default, {
label: this.props.breakLabel,
onPageChange: this.handlePageChange,
page: page
});
return _react2.default.createElement(_Button2.default, { label: this.props.breakLabel, onPageChange: this.handlePageChange, page: page });
};

@@ -314,13 +189,15 @@

if (this.props.condensed) return _react2.default.createElement(
'div',
{ className: this.props.className },
this.renderInfos(),
_react2.default.createElement(
'ul',
{ className: className },
this.renderPrevious(),
this.renderNext()
)
);
if (this.props.condensed) {
return _react2.default.createElement(
'div',
{ className: this.props.className },
this.renderInfos(),
_react2.default.createElement(
'ul',
{ className: className },
this.renderPrevious(),
this.renderNext()
)
);
}

@@ -346,24 +223,24 @@ return _react2.default.createElement(

return Paginator;
}(_PureComponent3.default);
}(_react2.default.PureComponent);
Paginator.propTypes = {
breakLabel: _react.PropTypes.string.isRequired,
className: _react.PropTypes.string,
condensed: _react.PropTypes.bool.isRequired,
disabled: _react.PropTypes.bool.isRequired,
firstAriaLabel: _react.PropTypes.string.isRequired,
firstLabel: _react.PropTypes.string.isRequired,
lastAriaLabel: _react.PropTypes.string.isRequired,
lastLabel: _react.PropTypes.string.isRequired,
nbRowsPerPage: _react.PropTypes.number.isRequired,
nextAriaLabel: _react.PropTypes.string.isRequired,
nextLabel: _react.PropTypes.string.isRequired,
onPageChange: _react.PropTypes.func.isRequired,
page: _react.PropTypes.number.isRequired,
pageRange: _react.PropTypes.number.isRequired,
previousAriaLabel: _react.PropTypes.string.isRequired,
previousLabel: _react.PropTypes.string.isRequired,
showInfos: _react.PropTypes.bool.isRequired,
size: _react.PropTypes.oneOf(['large', 'medium', 'small']).isRequired,
total: _react.PropTypes.number.isRequired
breakLabel: _propTypes2.default.string.isRequired,
className: _propTypes2.default.string,
condensed: _propTypes2.default.bool.isRequired,
disabled: _propTypes2.default.bool.isRequired,
firstAriaLabel: _propTypes2.default.string.isRequired,
firstLabel: _propTypes2.default.string.isRequired,
lastAriaLabel: _propTypes2.default.string.isRequired,
lastLabel: _propTypes2.default.string.isRequired,
nbRowsPerPage: _propTypes2.default.number.isRequired,
nextAriaLabel: _propTypes2.default.string.isRequired,
nextLabel: _propTypes2.default.string.isRequired,
onPageChange: _propTypes2.default.func.isRequired,
page: _propTypes2.default.number.isRequired,
pageRange: _propTypes2.default.number.isRequired,
previousAriaLabel: _propTypes2.default.string.isRequired,
previousLabel: _propTypes2.default.string.isRequired,
showInfos: _propTypes2.default.bool.isRequired,
size: _propTypes2.default.oneOf(['large', 'medium', 'small']).isRequired,
total: _propTypes2.default.number.isRequired
};

@@ -370,0 +247,0 @@ Paginator.defaultProps = {

{
"name": "@doctolib/react-paginator",
"version": "2.0.2",
"version": "3.0.0",
"description": "Basic paginator component for React.",
"main": "lib/index.js",
"files": [
"lib"
],
"scripts": {
"cover": "gulp cover",
"coveralls": "gulp coveralls",
"travis": "npm run lint && npm run coveralls",
"lint": "eslint .",
"test": "gulp test"
"prepublish": "NODE_ENV=production babel -d lib src",
"test": "yarn lint && yarn test:unit",
"test:unit": "jest --coverage && codecov"
},

@@ -31,35 +27,32 @@ "repository": {

"devDependencies": {
"@doctolib/gulp-tasks": "^5.0.0",
"babel-eslint": "^6.0.2",
"babel-preset-doctolib": "^2.0.0",
"chai": "^3.4.0",
"chai-dom": "^1.2.0",
"dirty-chai": "^1.2.2",
"eslint": "^2.7.0",
"eslint-config-doctolib": "^2.0.0",
"eslint-plugin-mocha": "^2.2.0",
"eslint-plugin-react": "^4.3.0",
"gulp": "^3.9.0",
"jsdom": "^8.0.0",
"mocha-jsdom": "^1.0.0",
"babel-cli": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-preset-doctolib": "^3.0.2",
"codecov": "^2.2.0",
"enzyme": "^2.8.2",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.1",
"eslint-config-doctolib": "^5.0.0",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-jsx-a11y": "^5.0.3",
"eslint-plugin-react": "^7.0.1",
"jest": "^20.0.4",
"react": "^15.0.1",
"react-addons-pure-render-mixin": "^15.0.1",
"react-addons-test-utils": "^15.0.1",
"react-dom": "^15.0.1",
"react-prism": "^3.1.1",
"sinon": "^1.17.2",
"sinon-chai": "^2.8.0"
"react-test-renderer": "^15.5.4"
},
"examples": {
"title": "React paginator",
"codeHighlighting": true
},
"dependencies": {
"classnames": "^2.2.0",
"lodash.range": "^3.0.1"
"lodash.range": "^3.0.1",
"prop-types": "^15.5.10"
},
"peerDependencies": {
"react": "^15.0.1",
"react-addons-pure-render-mixin": "^15.0.1"
"react": "^15.0.0"
},
"jest": {
"roots": [
"<rootDir>/src"
],
"coverageDirectory": "./coverage/"
}
}
# react-paginator
[![Build Status](https://travis-ci.org/doctolib/react-paginator.svg?branch=master)](https://travis-ci.org/doctolib/react-paginator)
[![Coverage Status](https://coveralls.io/repos/doctolib/react-paginator/badge.svg?branch=master&service=github)](https://coveralls.io/github/doctolib/react-paginator?branch=master)
[![Dependency Status](https://david-dm.org/doctolib/react-paginator.svg?theme=shields.io)](https://david-dm.org/doctolib/react-paginator)
[![devDependency Status](https://david-dm.org/doctolib/react-paginator/dev-status.svg?theme=shields.io)](https://david-dm.org/doctolib/react-paginator#info=devDependencies)
[![codecov](https://codecov.io/gh/doctolib/react-paginator/branch/master/graph/badge.svg)](https://codecov.io/gh/doctolib/react-paginator)

@@ -21,9 +19,5 @@ Basic paginator component for React. This component is designed to be used with Bootstrap but you can use it with your own style.

class MyComponent extends React.Component {
getInitialState() {
return {page: 1};
},
state = { page: 1 }
onPageChange(page) {
this.setState({page});
},
onPageChange = (page) => this.setState({page})

@@ -30,0 +24,0 @@ render() {

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