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

@uiw/react-pagination

Package Overview
Dependencies
Maintainers
2
Versions
171
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uiw/react-pagination - npm Package Compare versions

Comparing version 4.21.19 to 4.21.20

90

cjs/index.js
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
Object.defineProperty(exports, "__esModule", {

@@ -11,47 +9,37 @@ value: true

exports["default"] = Pagination;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _react = _interopRequireWildcard(require("react"));
var _reactSelect = _interopRequireDefault(require("@uiw/react-select"));
var _jsxRuntime = require("react/jsx-runtime");
var _excluded = ["className", "style", "prefixCls", "alignment", "size", "total", "pageSize", "pageSizeOptions", "current", "onChange", "onShowSizeChange", "divider"];
function Pagination(props) {
var className = props.className,
style = props.style,
_props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === void 0 ? 'w-pagination' : _props$prefixCls,
_props$alignment = props.alignment,
alignment = _props$alignment === void 0 ? 'left' : _props$alignment,
_props$size = props.size,
size = _props$size === void 0 ? 'default' : _props$size,
_props$total = props.total,
total = _props$total === void 0 ? 0 : _props$total,
_props$pageSize = props.pageSize,
pageSize = _props$pageSize === void 0 ? 10 : _props$pageSize,
_props$pageSizeOption = props.pageSizeOptions,
pageSizeOptions = _props$pageSizeOption === void 0 ? [] : _props$pageSizeOption,
_props$current = props.current,
currentNumber = _props$current === void 0 ? 1 : _props$current,
_props$onChange = props.onChange,
onChange = _props$onChange === void 0 ? function () {
return null;
} : _props$onChange,
onShowSizeChange = props.onShowSizeChange,
divider = props.divider,
other = (0, _objectWithoutProperties2["default"])(props, _excluded);
style = props.style,
_props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === void 0 ? 'w-pagination' : _props$prefixCls,
_props$alignment = props.alignment,
alignment = _props$alignment === void 0 ? 'left' : _props$alignment,
_props$size = props.size,
size = _props$size === void 0 ? 'default' : _props$size,
_props$total = props.total,
total = _props$total === void 0 ? 0 : _props$total,
_props$pageSize = props.pageSize,
pageSize = _props$pageSize === void 0 ? 10 : _props$pageSize,
_props$pageSizeOption = props.pageSizeOptions,
pageSizeOptions = _props$pageSizeOption === void 0 ? [] : _props$pageSizeOption,
_props$current = props.current,
currentNumber = _props$current === void 0 ? 1 : _props$current,
_props$onChange = props.onChange,
onChange = _props$onChange === void 0 ? function () {
return null;
} : _props$onChange,
onShowSizeChange = props.onShowSizeChange,
divider = props.divider,
other = (0, _objectWithoutProperties2["default"])(props, _excluded);
var _useState = (0, _react.useState)(currentNumber),
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
current = _useState2[0],
setCurrent = _useState2[1];
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
current = _useState2[0],
setCurrent = _useState2[1];
(0, _react.useEffect)(function () {

@@ -70,3 +58,2 @@ return setCurrent(currentNumber);

var basic = 0;
if (current > 3 && count > 5) {

@@ -77,3 +64,2 @@ data.push({

}
if (current > 4 && count > 6) {

@@ -86,20 +72,14 @@ data.push({

}
while (num < itemCount) {
num += 1;
if (current > 3 && count > 5) {
basic = current - 3;
}
var label = num + basic;
if (count - current === 0 && count > 5) {
label -= 2;
}
if (count - current === 1 && count > 5) {
label -= 1;
}
if (label <= count) {

@@ -112,3 +92,2 @@ data.push({

}
if (current + 3 < count && count > 6) {

@@ -121,3 +100,2 @@ data.push({

}
if (current + 2 < count && count > 5) {

@@ -128,3 +106,2 @@ data.push({

}
data.push({

@@ -134,3 +111,4 @@ type: 'next',

});
return data; // return [
return data;
// return [
// { type: 'prev', disabled: true },

@@ -146,3 +124,2 @@ // { type: 'jumpPrev', label: '•••', goto: 5 },

}, [current, total, pageSize]);
function handleClick(item) {

@@ -152,25 +129,18 @@ if (item.active || item.disabled) {

}
var count = Math.ceil(total / pageSize);
var state = {};
if (item.label) {
state.current = item.label;
}
if (item.type === 'prev') {
state.current = current - 1 > 0 ? current - 1 : 1;
}
if (item.type === 'next') {
state.current = current + 1 <= count ? current + 1 : count;
}
if (/^(jumpPrev|jumpNext)/.test(item.type) && item["goto"]) {
state.current = item.type === 'jumpPrev' ? current - item["goto"] : current + item["goto"];
if (state.current > count) {
state.current = count;
}
if (state.current < 1) {

@@ -180,7 +150,5 @@ state.current = 1;

}
setCurrent(state.current);
onChange && onChange(state.current, total, pageSize);
}
var onSizeChange = function onSizeChange(e) {

@@ -192,3 +160,2 @@ var sizeCount = Number(e.target.value);

};
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("ul", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({

@@ -205,3 +172,2 @@ className: cls,

});
if (/^(prev|next)$/.test(item.type)) {

@@ -213,3 +179,2 @@ // eslint-disable-next-line jsx-a11y/anchor-is-valid

}
return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {

@@ -238,4 +203,3 @@ className: [item.active ? 'active' : null, item.disabled ? 'disabled' : null].filter(Boolean).join(' ').trim(),

}
module.exports = exports.default;
//# sourceMappingURL=index.js.map

@@ -11,18 +11,17 @@ import _extends from "@babel/runtime/helpers/extends";

var {
className,
style,
prefixCls = 'w-pagination',
alignment = 'left',
size = 'default',
total = 0,
pageSize = 10,
// The number of pages displayed.
pageSizeOptions = [],
current: currentNumber = 1,
onChange = () => null,
onShowSizeChange,
divider
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
className,
style,
prefixCls = 'w-pagination',
alignment = 'left',
size = 'default',
total = 0,
pageSize = 10,
// The number of pages displayed.
pageSizeOptions = [],
current: currentNumber = 1,
onChange = () => null,
onShowSizeChange,
divider
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
var [current, setCurrent] = useState(currentNumber);

@@ -40,3 +39,2 @@ useEffect(() => setCurrent(currentNumber), [currentNumber]);

var basic = 0;
if (current > 3 && count > 5) {

@@ -47,3 +45,2 @@ data.push({

}
if (current > 4 && count > 6) {

@@ -56,20 +53,14 @@ data.push({

}
while (num < itemCount) {
num += 1;
if (current > 3 && count > 5) {
basic = current - 3;
}
var label = num + basic;
if (count - current === 0 && count > 5) {
label -= 2;
}
if (count - current === 1 && count > 5) {
label -= 1;
}
if (label <= count) {

@@ -82,3 +73,2 @@ data.push({

}
if (current + 3 < count && count > 6) {

@@ -91,3 +81,2 @@ data.push({

}
if (current + 2 < count && count > 5) {

@@ -98,3 +87,2 @@ data.push({

}
data.push({

@@ -104,3 +92,4 @@ type: 'next',

});
return data; // return [
return data;
// return [
// { type: 'prev', disabled: true },

@@ -116,3 +105,2 @@ // { type: 'jumpPrev', label: '•••', goto: 5 },

}, [current, total, pageSize]);
function handleClick(item) {

@@ -122,25 +110,18 @@ if (item.active || item.disabled) {

}
var count = Math.ceil(total / pageSize);
var state = {};
if (item.label) {
state.current = item.label;
}
if (item.type === 'prev') {
state.current = current - 1 > 0 ? current - 1 : 1;
}
if (item.type === 'next') {
state.current = current + 1 <= count ? current + 1 : count;
}
if (/^(jumpPrev|jumpNext)/.test(item.type) && item.goto) {
state.current = item.type === 'jumpPrev' ? current - item.goto : current + item.goto;
if (state.current > count) {
state.current = count;
}
if (state.current < 1) {

@@ -150,7 +131,5 @@ state.current = 1;

}
setCurrent(state.current);
onChange && onChange(state.current, total, pageSize);
}
var onSizeChange = e => {

@@ -162,3 +141,2 @@ var sizeCount = Number(e.target.value);

};
return /*#__PURE__*/_jsxs("ul", _extends({

@@ -175,3 +153,2 @@ className: cls,

});
if (/^(prev|next)$/.test(item.type)) {

@@ -183,3 +160,2 @@ // eslint-disable-next-line jsx-a11y/anchor-is-valid

}
return /*#__PURE__*/_jsx("li", {

@@ -186,0 +162,0 @@ className: [item.active ? 'active' : null, item.disabled ? 'disabled' : null].filter(Boolean).join(' ').trim(),

{
"name": "@uiw/react-pagination",
"version": "4.21.19",
"version": "4.21.20",
"description": "Pagination component",

@@ -47,5 +47,5 @@ "author": "Kenny Wong <wowohoo@qq.com>",

"dependencies": {
"@uiw/react-select": "^4.21.19",
"@uiw/utils": "^4.21.19"
"@uiw/react-select": "^4.21.20",
"@uiw/utils": "^4.21.20"
}
}

Sorry, the diff of this file is not supported yet

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