@gpa-gemstone/react-table 1.2.50 → 1.2.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Paging.js +13 -3
- package/package.json +1 -1
package/lib/Paging.js
CHANGED
|
@@ -27,8 +27,18 @@ var React = require("react");
|
|
|
27
27
|
function default_1(props) {
|
|
28
28
|
var _a = React.useState([]), pages = _a[0], setPages = _a[1];
|
|
29
29
|
var nPages = 7;
|
|
30
|
-
var minPg = React.useMemo(function () {
|
|
31
|
-
|
|
30
|
+
var minPg = React.useMemo(function () {
|
|
31
|
+
var min = Math.min.apply(Math, pages);
|
|
32
|
+
if (isFinite(min) && !isNaN(min))
|
|
33
|
+
return min;
|
|
34
|
+
return 0;
|
|
35
|
+
}, [pages]);
|
|
36
|
+
var maxPg = React.useMemo(function () {
|
|
37
|
+
var max = Math.max.apply(Math, pages);
|
|
38
|
+
if (isFinite(max) && !isNaN(max))
|
|
39
|
+
return max;
|
|
40
|
+
return 0;
|
|
41
|
+
}, [pages]);
|
|
32
42
|
React.useEffect(function () {
|
|
33
43
|
var display = [];
|
|
34
44
|
var p = Math.max(props.Current - Math.floor(nPages / 2), 1);
|
|
@@ -41,7 +51,7 @@ function default_1(props) {
|
|
|
41
51
|
setPages(display);
|
|
42
52
|
}, [props.Total, props.Current]);
|
|
43
53
|
return React.createElement("ul", { className: "pagination justify-content-center" },
|
|
44
|
-
React.createElement("li", { className: "page-item" + (minPg
|
|
54
|
+
React.createElement("li", { className: "page-item" + (minPg <= 1 ? ' disabled' : ""), key: "previous" },
|
|
45
55
|
React.createElement("a", { className: "page-link", onClick: function () {
|
|
46
56
|
if (minPg > 1)
|
|
47
57
|
props.SetPage(Math.max(props.Current - nPages, 1));
|