@citygross/components 0.7.180 → 0.7.181
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.
|
@@ -5,5 +5,6 @@ export declare type TPagination = {
|
|
|
5
5
|
currentPage: number;
|
|
6
6
|
itemsPerPage?: number;
|
|
7
7
|
setPage?: (page: number) => void;
|
|
8
|
+
numOfPaginationsToShow?: number;
|
|
8
9
|
};
|
|
9
|
-
export declare function Pagination({ totalItems, currentPage, fetchItems, itemsPerPage, setPage }: TPagination): JSX.Element;
|
|
10
|
+
export declare function Pagination({ totalItems, currentPage, fetchItems, itemsPerPage, setPage, numOfPaginationsToShow }: TPagination): JSX.Element;
|
|
@@ -11,7 +11,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
11
11
|
|
|
12
12
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
13
|
|
|
14
|
-
function createPagination(totalItems, itemsPerPage) {
|
|
14
|
+
function createPagination(totalItems, itemsPerPage, numOfPaginationsToShow) {
|
|
15
15
|
var amountOfPages = Math.ceil((totalItems || 0) / (itemsPerPage !== null && itemsPerPage !== void 0 ? itemsPerPage : 6));
|
|
16
16
|
if (amountOfPages === 0 || itemsPerPage === 0) {
|
|
17
17
|
return [];
|
|
@@ -20,7 +20,7 @@ function createPagination(totalItems, itemsPerPage) {
|
|
|
20
20
|
var block = [];
|
|
21
21
|
var counter = 0;
|
|
22
22
|
new Array(amountOfPages).fill(0).map(function (_, index) {
|
|
23
|
-
if (counter <
|
|
23
|
+
if (counter < (numOfPaginationsToShow !== null && numOfPaginationsToShow !== void 0 ? numOfPaginationsToShow : 4) - 1) {
|
|
24
24
|
counter++;
|
|
25
25
|
block.push(index);
|
|
26
26
|
if (index === amountOfPages - 1) {
|
|
@@ -38,9 +38,9 @@ function createPagination(totalItems, itemsPerPage) {
|
|
|
38
38
|
return pagination;
|
|
39
39
|
}
|
|
40
40
|
function Pagination(_a) {
|
|
41
|
-
var totalItems = _a.totalItems, currentPage = _a.currentPage, fetchItems = _a.fetchItems, itemsPerPage = _a.itemsPerPage, setPage = _a.setPage;
|
|
42
|
-
var
|
|
43
|
-
var pagination = createPagination(totalItems, itemsPerPage);
|
|
41
|
+
var totalItems = _a.totalItems, currentPage = _a.currentPage, fetchItems = _a.fetchItems, itemsPerPage = _a.itemsPerPage, setPage = _a.setPage, _b = _a.numOfPaginationsToShow, numOfPaginationsToShow = _b === void 0 ? 4 : _b;
|
|
42
|
+
var _c = React.useState(Math.floor((currentPage - 1) / numOfPaginationsToShow)), currentIndex = _c[0], setIndex = _c[1];
|
|
43
|
+
var pagination = createPagination(totalItems, itemsPerPage, numOfPaginationsToShow);
|
|
44
44
|
return (React__default["default"].createElement(Box.Box, null, pagination && pagination.length > 0 && (React__default["default"].createElement(Pagination_styles.Flex, null,
|
|
45
45
|
currentIndex > 0 && (React__default["default"].createElement(Pagination_styles.PaginationButtonWrapper, null,
|
|
46
46
|
React__default["default"].createElement(PaginationButton.PaginationButton, { color: 'white', onClick: function () {
|
|
@@ -3,7 +3,7 @@ import { PaginationButton } from '../Button/PaginationButton.js';
|
|
|
3
3
|
import { Box } from '../Box/Box.js';
|
|
4
4
|
import { Flex, PaginationButtonWrapper } from './Pagination.styles.js';
|
|
5
5
|
|
|
6
|
-
function createPagination(totalItems, itemsPerPage) {
|
|
6
|
+
function createPagination(totalItems, itemsPerPage, numOfPaginationsToShow) {
|
|
7
7
|
var amountOfPages = Math.ceil((totalItems || 0) / (itemsPerPage !== null && itemsPerPage !== void 0 ? itemsPerPage : 6));
|
|
8
8
|
if (amountOfPages === 0 || itemsPerPage === 0) {
|
|
9
9
|
return [];
|
|
@@ -12,7 +12,7 @@ function createPagination(totalItems, itemsPerPage) {
|
|
|
12
12
|
var block = [];
|
|
13
13
|
var counter = 0;
|
|
14
14
|
new Array(amountOfPages).fill(0).map(function (_, index) {
|
|
15
|
-
if (counter <
|
|
15
|
+
if (counter < (numOfPaginationsToShow !== null && numOfPaginationsToShow !== void 0 ? numOfPaginationsToShow : 4) - 1) {
|
|
16
16
|
counter++;
|
|
17
17
|
block.push(index);
|
|
18
18
|
if (index === amountOfPages - 1) {
|
|
@@ -30,9 +30,9 @@ function createPagination(totalItems, itemsPerPage) {
|
|
|
30
30
|
return pagination;
|
|
31
31
|
}
|
|
32
32
|
function Pagination(_a) {
|
|
33
|
-
var totalItems = _a.totalItems, currentPage = _a.currentPage, fetchItems = _a.fetchItems, itemsPerPage = _a.itemsPerPage, setPage = _a.setPage;
|
|
34
|
-
var
|
|
35
|
-
var pagination = createPagination(totalItems, itemsPerPage);
|
|
33
|
+
var totalItems = _a.totalItems, currentPage = _a.currentPage, fetchItems = _a.fetchItems, itemsPerPage = _a.itemsPerPage, setPage = _a.setPage, _b = _a.numOfPaginationsToShow, numOfPaginationsToShow = _b === void 0 ? 4 : _b;
|
|
34
|
+
var _c = useState(Math.floor((currentPage - 1) / numOfPaginationsToShow)), currentIndex = _c[0], setIndex = _c[1];
|
|
35
|
+
var pagination = createPagination(totalItems, itemsPerPage, numOfPaginationsToShow);
|
|
36
36
|
return (React.createElement(Box, null, pagination && pagination.length > 0 && (React.createElement(Flex, null,
|
|
37
37
|
currentIndex > 0 && (React.createElement(PaginationButtonWrapper, null,
|
|
38
38
|
React.createElement(PaginationButton, { color: 'white', onClick: function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@citygross/components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.181",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./build/cjs/components/src/index.js",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"moment": "^2.29.1",
|
|
72
72
|
"react-loading-skeleton": "^2.2.0"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "0de768dd9217e69431a6a581b19cb578d83ef837"
|
|
75
75
|
}
|