@citygross/components 0.7.36 → 0.7.37
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/build/@types/index.d.ts +1 -0
- package/build/cjs/components/src/components/Pagination/Pagination.js +54 -0
- package/build/cjs/components/src/components/Pagination/Pagination.js.map +1 -0
- package/build/cjs/components/src/components/Pagination/Pagination.styles.js +18 -0
- package/build/cjs/components/src/components/Pagination/Pagination.styles.js.map +1 -0
- package/build/cjs/components/src/index.js +2 -0
- package/build/cjs/components/src/index.js.map +1 -1
- package/build/es/components/src/components/Pagination/Pagination.js +46 -0
- package/build/es/components/src/components/Pagination/Pagination.js.map +1 -0
- package/build/es/components/src/components/Pagination/Pagination.styles.js +9 -0
- package/build/es/components/src/components/Pagination/Pagination.styles.js.map +1 -0
- package/build/es/components/src/index.js +1 -0
- package/build/es/components/src/index.js.map +1 -1
- package/package.json +2 -2
package/build/@types/index.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export * from './components/Table/';
|
|
|
46
46
|
export * from './components/Timeline/Timeline';
|
|
47
47
|
export * from './components/ToolTip/ToolTip';
|
|
48
48
|
export * from './components/QuantitySelector/QuantitySelector';
|
|
49
|
+
export * from './components/Pagination/Pagination';
|
|
49
50
|
export * from './containers/PageContainer/PageContainer';
|
|
50
51
|
export * from './containers/TwoColumnsContainer/TwoColumnsPageContainer';
|
|
51
52
|
export * from './components/UnorderedList';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var PaginationButton = require('../Button/PaginationButton.js');
|
|
7
|
+
var Box = require('../Box/Box.js');
|
|
8
|
+
var Pagination_styles = require('./Pagination.styles.js');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
|
+
|
|
14
|
+
function createPagination(totalItems, itemsPerPage) {
|
|
15
|
+
var amountOfPages = Math.ceil((totalItems || 0) / (itemsPerPage !== null && itemsPerPage !== void 0 ? itemsPerPage : 6));
|
|
16
|
+
if (amountOfPages === 0 || itemsPerPage === 0) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
var pagination = [];
|
|
20
|
+
var block = [];
|
|
21
|
+
var counter = 0;
|
|
22
|
+
new Array(amountOfPages).fill(0).map(function (_, index) {
|
|
23
|
+
if (counter < 3) {
|
|
24
|
+
counter++;
|
|
25
|
+
block.push(index);
|
|
26
|
+
if (index === amountOfPages - 1) {
|
|
27
|
+
pagination.push(block);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
counter = 0;
|
|
32
|
+
block.push(index);
|
|
33
|
+
pagination.push(block);
|
|
34
|
+
block = [];
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
});
|
|
38
|
+
return pagination;
|
|
39
|
+
}
|
|
40
|
+
function Pagination(_a) {
|
|
41
|
+
var totalItems = _a.totalItems, currentPage = _a.currentPage, fetchItems = _a.fetchItems, itemsPerPage = _a.itemsPerPage;
|
|
42
|
+
var _b = React.useState(Math.floor((currentPage - 1) / 4)), currentIndex = _b[0], setIndex = _b[1];
|
|
43
|
+
var pagination = createPagination(totalItems, itemsPerPage);
|
|
44
|
+
return (React__default['default'].createElement(Box.Box, null, pagination && pagination.length > 0 && (React__default['default'].createElement(Pagination_styles.Flex, null,
|
|
45
|
+
currentIndex > 0 && (React__default['default'].createElement(Pagination_styles.PaginationButtonWrapper, null,
|
|
46
|
+
React__default['default'].createElement(PaginationButton.PaginationButton, { color: 'white', onClick: function () { return setIndex(currentIndex - 1); }, width: 36, height: 36 }, '...'))),
|
|
47
|
+
pagination[currentIndex].map(function (page) { return (React__default['default'].createElement(Pagination_styles.PaginationButtonWrapper, { key: page },
|
|
48
|
+
React__default['default'].createElement(PaginationButton.PaginationButton, { color: currentPage === page + 1 ? 'primary' : 'white', width: 36, height: 36, onClick: function () { return fetchItems(page + 1); } }, page + 1))); }),
|
|
49
|
+
pagination.length > 1 && currentIndex < pagination.length - 1 && (React__default['default'].createElement(Pagination_styles.PaginationButtonWrapper, null,
|
|
50
|
+
React__default['default'].createElement(PaginationButton.PaginationButton, { color: 'white', onClick: function () { return setIndex(currentIndex + 1); }, width: 36, height: 36 }, '...')))))));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
exports.Pagination = Pagination;
|
|
54
|
+
//# sourceMappingURL=Pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pagination.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../../../_virtual/_tslib.js');
|
|
6
|
+
var styled = require('styled-components');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
11
|
+
|
|
12
|
+
var PaginationButtonWrapper = styled__default['default'].div(templateObject_1 || (templateObject_1 = _tslib.__makeTemplateObject(["\n padding: 0 ", "px;\n"], ["\n padding: 0 ", "px;\n"])), function (props) { var _a; return (_a = props.theme.spacings) === null || _a === void 0 ? void 0 : _a.xxs; });
|
|
13
|
+
var Flex = styled__default['default'].div(templateObject_2 || (templateObject_2 = _tslib.__makeTemplateObject(["\n display: flex;\n align-items: flex-start;\n justify-content: center;\n"], ["\n display: flex;\n align-items: flex-start;\n justify-content: center;\n"])));
|
|
14
|
+
var templateObject_1, templateObject_2;
|
|
15
|
+
|
|
16
|
+
exports.Flex = Flex;
|
|
17
|
+
exports.PaginationButtonWrapper = PaginationButtonWrapper;
|
|
18
|
+
//# sourceMappingURL=Pagination.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pagination.styles.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -51,6 +51,7 @@ var Table_styles = require('./components/Table/Table.styles.js');
|
|
|
51
51
|
var Timeline = require('./components/Timeline/Timeline.js');
|
|
52
52
|
var ToolTip = require('./components/ToolTip/ToolTip.js');
|
|
53
53
|
var QuantitySelector = require('./components/QuantitySelector/QuantitySelector.js');
|
|
54
|
+
var Pagination = require('./components/Pagination/Pagination.js');
|
|
54
55
|
var PageContainer = require('./containers/PageContainer/PageContainer.js');
|
|
55
56
|
var TwoColumnsPageContainer = require('./containers/TwoColumnsContainer/TwoColumnsPageContainer.js');
|
|
56
57
|
var UnorderedList_styles = require('./components/UnorderedList/UnorderedList.styles.js');
|
|
@@ -140,6 +141,7 @@ exports.Tr = Table_styles.Tr;
|
|
|
140
141
|
exports.Timeline = Timeline.Timeline;
|
|
141
142
|
exports.ToolTip = ToolTip.ToolTip;
|
|
142
143
|
exports.QuantitySelector = QuantitySelector.QuantitySelector;
|
|
144
|
+
exports.Pagination = Pagination.Pagination;
|
|
143
145
|
exports.PageContainer = PageContainer.PageContainer;
|
|
144
146
|
exports.TwoColumnsPageContainer = TwoColumnsPageContainer.TwoColumnsPageContainer;
|
|
145
147
|
exports.UnorderedList = UnorderedList_styles.UnorderedList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { PaginationButton } from '../Button/PaginationButton.js';
|
|
3
|
+
import { Box } from '../Box/Box.js';
|
|
4
|
+
import { Flex, PaginationButtonWrapper } from './Pagination.styles.js';
|
|
5
|
+
|
|
6
|
+
function createPagination(totalItems, itemsPerPage) {
|
|
7
|
+
var amountOfPages = Math.ceil((totalItems || 0) / (itemsPerPage !== null && itemsPerPage !== void 0 ? itemsPerPage : 6));
|
|
8
|
+
if (amountOfPages === 0 || itemsPerPage === 0) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
var pagination = [];
|
|
12
|
+
var block = [];
|
|
13
|
+
var counter = 0;
|
|
14
|
+
new Array(amountOfPages).fill(0).map(function (_, index) {
|
|
15
|
+
if (counter < 3) {
|
|
16
|
+
counter++;
|
|
17
|
+
block.push(index);
|
|
18
|
+
if (index === amountOfPages - 1) {
|
|
19
|
+
pagination.push(block);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
counter = 0;
|
|
24
|
+
block.push(index);
|
|
25
|
+
pagination.push(block);
|
|
26
|
+
block = [];
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
});
|
|
30
|
+
return pagination;
|
|
31
|
+
}
|
|
32
|
+
function Pagination(_a) {
|
|
33
|
+
var totalItems = _a.totalItems, currentPage = _a.currentPage, fetchItems = _a.fetchItems, itemsPerPage = _a.itemsPerPage;
|
|
34
|
+
var _b = useState(Math.floor((currentPage - 1) / 4)), currentIndex = _b[0], setIndex = _b[1];
|
|
35
|
+
var pagination = createPagination(totalItems, itemsPerPage);
|
|
36
|
+
return (React.createElement(Box, null, pagination && pagination.length > 0 && (React.createElement(Flex, null,
|
|
37
|
+
currentIndex > 0 && (React.createElement(PaginationButtonWrapper, null,
|
|
38
|
+
React.createElement(PaginationButton, { color: 'white', onClick: function () { return setIndex(currentIndex - 1); }, width: 36, height: 36 }, '...'))),
|
|
39
|
+
pagination[currentIndex].map(function (page) { return (React.createElement(PaginationButtonWrapper, { key: page },
|
|
40
|
+
React.createElement(PaginationButton, { color: currentPage === page + 1 ? 'primary' : 'white', width: 36, height: 36, onClick: function () { return fetchItems(page + 1); } }, page + 1))); }),
|
|
41
|
+
pagination.length > 1 && currentIndex < pagination.length - 1 && (React.createElement(PaginationButtonWrapper, null,
|
|
42
|
+
React.createElement(PaginationButton, { color: 'white', onClick: function () { return setIndex(currentIndex + 1); }, width: 36, height: 36 }, '...')))))));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { Pagination };
|
|
46
|
+
//# sourceMappingURL=Pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pagination.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { __makeTemplateObject } from '../../../../_virtual/_tslib.js';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
var PaginationButtonWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 0 ", "px;\n"], ["\n padding: 0 ", "px;\n"])), function (props) { var _a; return (_a = props.theme.spacings) === null || _a === void 0 ? void 0 : _a.xxs; });
|
|
5
|
+
var Flex = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n align-items: flex-start;\n justify-content: center;\n"], ["\n display: flex;\n align-items: flex-start;\n justify-content: center;\n"])));
|
|
6
|
+
var templateObject_1, templateObject_2;
|
|
7
|
+
|
|
8
|
+
export { Flex, PaginationButtonWrapper };
|
|
9
|
+
//# sourceMappingURL=Pagination.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pagination.styles.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -47,6 +47,7 @@ export { Table, Td, Th, Thead, Tr } from './components/Table/Table.styles.js';
|
|
|
47
47
|
export { Timeline } from './components/Timeline/Timeline.js';
|
|
48
48
|
export { ToolTip } from './components/ToolTip/ToolTip.js';
|
|
49
49
|
export { QuantitySelector } from './components/QuantitySelector/QuantitySelector.js';
|
|
50
|
+
export { Pagination } from './components/Pagination/Pagination.js';
|
|
50
51
|
export { PageContainer } from './containers/PageContainer/PageContainer.js';
|
|
51
52
|
export { TwoColumnsPageContainer } from './containers/TwoColumnsContainer/TwoColumnsPageContainer.js';
|
|
52
53
|
export { UnorderedList, UnorderedListItem } from './components/UnorderedList/UnorderedList.styles.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@citygross/components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.37",
|
|
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": "78b244982105ec4218731adcd38003b606505caf"
|
|
75
75
|
}
|