@civicactions/cmsds-open-data-components 2.1.0-alpha.4 → 2.1.1
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/dist/main.css +5 -0
- package/dist/main.css.map +1 -1
- package/dist/main.js +3 -2
- package/dist/main.js.map +1 -1
- package/lib/assets/icons/close.js +4 -0
- package/lib/assets/icons/copy.js +4 -0
- package/lib/assets/icons/download.js +4 -0
- package/lib/assets/icons/settings.js +5 -2
- package/lib/assets/metadataMapping.js +9 -0
- package/lib/commands/index.js +2 -0
- package/lib/commands/templates/footer.js +2 -0
- package/lib/components/ApiDocumentation/index.js +6 -0
- package/lib/components/Breadcrumb/index.js +8 -2
- package/lib/components/DataTableDensity/datatabledensity.test.js +5 -0
- package/lib/components/DataTableDensity/index.js +7 -1
- package/lib/components/DataTableRowChanger/datatablerowchanger.test.js +5 -0
- package/lib/components/DataTableRowChanger/index.js +8 -2
- package/lib/components/DatasetAdditionalInformation/index.js +17 -4
- package/lib/components/DatasetDownloads/datasetdownloads.test.js +5 -0
- package/lib/components/DatasetDownloads/index.js +6 -1
- package/lib/components/DatasetSearchFacets/dataset_search_facets.test.js +14 -0
- package/lib/components/DatasetSearchFacets/index.js +26 -10
- package/lib/components/DatasetSearchListItem/datasetsearchlistitem.test.js +9 -1
- package/lib/components/DatasetSearchListItem/index.js +17 -6
- package/lib/components/DatasetTags/datasettags.test.js +5 -0
- package/lib/components/DatasetTags/index.js +6 -0
- package/lib/components/Hero/index.js +18 -8
- package/lib/components/ManageColumns/index.js +13 -3
- package/lib/components/NavBar/index.js +55 -0
- package/lib/components/NavLink/index.js +11 -2
- package/lib/components/NavLink/navlink.test.js +6 -0
- package/lib/components/Pagination/index.js +46 -4
- package/lib/components/Pagination/pagination.test.js +478 -367
- package/lib/components/ResourceConditionField/ResourceConditionalField.test.js +5 -1
- package/lib/components/ResourceConditionField/index.js +62 -30
- package/lib/components/ResourceFilter/index.js +39 -10
- package/lib/components/ResourceFilter/resourcefilter.test.js +297 -234
- package/lib/components/ResourceFooter/index.js +11 -4
- package/lib/components/ResourceHeader/index.js +54 -30
- package/lib/components/ResourceInformation/index.js +6 -1
- package/lib/components/ResourcePreview/index.js +30 -13
- package/lib/components/SearchModal/index.js +28 -11
- package/lib/components/SubMenu/index.js +20 -5
- package/lib/components/TransformedDate/index.js +7 -1
- package/lib/components/useAddLoginLink/index.js +13 -3
- package/lib/components/useScrollToTop/index.js +6 -1
- package/lib/index.js +247 -0
- package/lib/templates/APIPage/index.js +6 -1
- package/lib/templates/Dataset/DatasetBody.js +42 -12
- package/lib/templates/Dataset/index.js +26 -7
- package/lib/templates/DatasetSearch/datasetsearch.test.js +70 -50
- package/lib/templates/DatasetSearch/index.js +83 -43
- package/lib/templates/DrupalPage/index.js +13 -6
- package/lib/templates/FilteredResource/FilteredResourceBody.js +43 -15
- package/lib/templates/FilteredResource/QueryBuilder.js +59 -17
- package/lib/templates/FilteredResource/QueryRow.js +43 -20
- package/lib/templates/FilteredResource/QueryTitle.js +18 -2
- package/lib/templates/FilteredResource/functions.js +17 -5
- package/lib/templates/FilteredResource/index.js +36 -16
- package/lib/templates/Footer/footer.test.js +7 -2
- package/lib/templates/Footer/index.js +23 -11
- package/lib/templates/PageNotFound/index.js +5 -1
- package/lib/templates/header/index.js +26 -17
- package/lib/templates/mobile_header/index.js +42 -22
- package/package.json +1 -1
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = void 0;
|
|
9
|
+
|
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
9
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
10
14
|
var _reactRouterDom = require("react-router-dom");
|
|
15
|
+
|
|
11
16
|
var DatasetTags = function DatasetTags(_ref) {
|
|
12
17
|
var keywords = _ref.keywords;
|
|
13
18
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -22,6 +27,7 @@ var DatasetTags = function DatasetTags(_ref) {
|
|
|
22
27
|
}, k.data);
|
|
23
28
|
}));
|
|
24
29
|
};
|
|
30
|
+
|
|
25
31
|
DatasetTags.propTypes = {
|
|
26
32
|
keywords: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
27
33
|
data: _propTypes["default"].string.isRequired,
|
|
@@ -1,30 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = void 0;
|
|
9
|
+
|
|
8
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
9
12
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
10
14
|
var _reactRouterDom = require("react-router-dom");
|
|
15
|
+
|
|
11
16
|
var _designSystem = require("@cmsgov/design-system");
|
|
17
|
+
|
|
12
18
|
var Hero = function Hero(_ref) {
|
|
13
19
|
var title = _ref.title,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
description = _ref.description,
|
|
21
|
+
searchUrl = _ref.searchUrl,
|
|
22
|
+
searchKey = _ref.searchKey,
|
|
23
|
+
textfieldLabel = _ref.textfieldLabel,
|
|
24
|
+
searchButtonText = _ref.searchButtonText;
|
|
19
25
|
var navigate = (0, _reactRouterDom.useNavigate)();
|
|
26
|
+
|
|
20
27
|
var _React$useState = _react["default"].useState(''),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
29
|
+
searchValue = _React$useState2[0],
|
|
30
|
+
setSearchValue = _React$useState2[1];
|
|
31
|
+
|
|
24
32
|
function submitHero(e) {
|
|
25
33
|
e.preventDefault();
|
|
26
34
|
navigate("/".concat(searchUrl, "?").concat(searchKey, "=").concat(searchValue));
|
|
27
35
|
}
|
|
36
|
+
|
|
28
37
|
return /*#__PURE__*/_react["default"].createElement("section", {
|
|
29
38
|
className: "dc-c-hero ds-base ds-u-padding--2"
|
|
30
39
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -72,6 +81,7 @@ var Hero = function Hero(_ref) {
|
|
|
72
81
|
className: "full-text ds-u-display--none ds-u-sm-display--inline-block"
|
|
73
82
|
}, searchButtonText))))));
|
|
74
83
|
};
|
|
84
|
+
|
|
75
85
|
Hero.defaultProps = {
|
|
76
86
|
searchKey: 'fulltext',
|
|
77
87
|
searchUrl: 'datasets',
|
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports["default"] = void 0;
|
|
11
|
+
|
|
9
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
10
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
11
16
|
var _designSystem = require("@cmsgov/design-system");
|
|
17
|
+
|
|
12
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
13
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
14
22
|
var ManageColumns = function ManageColumns() {
|
|
15
23
|
var _useState = (0, _react.useState)(false),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
25
|
+
modalOpen = _useState2[0],
|
|
26
|
+
setModalOpen = _useState2[1];
|
|
27
|
+
|
|
19
28
|
return /*#__PURE__*/_react["default"].createElement(_designSystem.Button, {
|
|
20
29
|
onClick: function onClick() {
|
|
21
30
|
return setModalOpen(!modalOpen);
|
|
22
31
|
}
|
|
23
32
|
}, "Manage Columns");
|
|
24
33
|
};
|
|
34
|
+
|
|
25
35
|
var _default = ManageColumns;
|
|
26
36
|
exports["default"] = _default;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _SubMenu = _interopRequireDefault(require("../SubMenu"));
|
|
13
|
+
|
|
14
|
+
var _NavLink = _interopRequireDefault(require("../NavLink"));
|
|
15
|
+
|
|
16
|
+
var NavBar = function NavBar(_ref) {
|
|
17
|
+
var links = _ref.links,
|
|
18
|
+
menuName = _ref.menuName,
|
|
19
|
+
menuId = _ref.menuId,
|
|
20
|
+
menuClasses = _ref.menuClasses,
|
|
21
|
+
linkClasses = _ref.linkClasses,
|
|
22
|
+
wrapLabel = _ref.wrapLabel;
|
|
23
|
+
return /*#__PURE__*/_react["default"].createElement("nav", {
|
|
24
|
+
className: "dc-c-".concat(menuId, "-menu"),
|
|
25
|
+
"aria-labelledby": "dc-c-".concat(menuId, "-menu--heading")
|
|
26
|
+
}, /*#__PURE__*/_react["default"].createElement("h2", {
|
|
27
|
+
id: "dc-c-".concat(menuId, "-menu--heading"),
|
|
28
|
+
className: "ds-u-visibility--screen-reader"
|
|
29
|
+
}, menuName), /*#__PURE__*/_react["default"].createElement("ul", {
|
|
30
|
+
className: menuClasses
|
|
31
|
+
}, links.map(function (link) {
|
|
32
|
+
if (link.submenu) {
|
|
33
|
+
return /*#__PURE__*/_react["default"].createElement(_SubMenu["default"], {
|
|
34
|
+
key: link.id,
|
|
35
|
+
link: link,
|
|
36
|
+
wrapLabel: wrapLabel,
|
|
37
|
+
linkClasses: linkClasses
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
41
|
+
key: link.id
|
|
42
|
+
}, /*#__PURE__*/_react["default"].createElement(_NavLink["default"], {
|
|
43
|
+
link: link,
|
|
44
|
+
className: linkClasses,
|
|
45
|
+
wrapLabel: wrapLabel
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
})));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
NavBar.defaultProps = {
|
|
52
|
+
wrapLabel: false
|
|
53
|
+
};
|
|
54
|
+
var _default = NavBar;
|
|
55
|
+
exports["default"] = _default;
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = void 0;
|
|
9
|
+
|
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
9
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
10
14
|
var _reactRouterDom = require("react-router-dom");
|
|
15
|
+
|
|
11
16
|
var _validator = _interopRequireDefault(require("validator"));
|
|
17
|
+
|
|
12
18
|
var NavLink = function NavLink(_ref) {
|
|
13
19
|
var link = _ref.link,
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
_className = _ref.className,
|
|
21
|
+
wrapLabel = _ref.wrapLabel;
|
|
16
22
|
var innerHtml = wrapLabel ? /*#__PURE__*/_react["default"].createElement("span", null, link.label) : link.label;
|
|
23
|
+
|
|
17
24
|
if (_validator["default"].isURL(link.url, {
|
|
18
25
|
require_protocol: true
|
|
19
26
|
}) || link.nonReactLink) {
|
|
@@ -31,6 +38,7 @@ var NavLink = function NavLink(_ref) {
|
|
|
31
38
|
}, innerHtml);
|
|
32
39
|
}
|
|
33
40
|
};
|
|
41
|
+
|
|
34
42
|
NavLink.defaultProps = {
|
|
35
43
|
wrapLabel: false,
|
|
36
44
|
className: null
|
|
@@ -42,6 +50,7 @@ NavLink.propTypes = {
|
|
|
42
50
|
nonReactLink: _propTypes["default"].bool
|
|
43
51
|
}).isRequired,
|
|
44
52
|
className: _propTypes["default"].string,
|
|
53
|
+
|
|
45
54
|
/**
|
|
46
55
|
* Will wrap the link label in a span for help with styling.
|
|
47
56
|
*/
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
5
7
|
var _react2 = require("@testing-library/react");
|
|
8
|
+
|
|
6
9
|
require("@testing-library/jest-dom/extend-expect");
|
|
10
|
+
|
|
7
11
|
var _jestAxe = require("jest-axe");
|
|
12
|
+
|
|
8
13
|
var _index = _interopRequireDefault(require("./index"));
|
|
14
|
+
|
|
9
15
|
expect.extend(_jestAxe.toHaveNoViolations);
|
|
10
16
|
describe('<NavLink />', function () {
|
|
11
17
|
test('Renders a relative link if no http protocol in url', function () {
|
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports["default"] = void 0;
|
|
11
|
+
|
|
9
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
10
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
11
16
|
var _designSystem = require("@cmsgov/design-system");
|
|
17
|
+
|
|
12
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
13
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
14
22
|
var Pagination = function Pagination(_ref) {
|
|
15
23
|
var totalPages = _ref.totalPages,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var maxLength = 7;
|
|
19
|
-
// Expectation starts at 1
|
|
24
|
+
currentPage = _ref.currentPage,
|
|
25
|
+
buttonAction = _ref.buttonAction;
|
|
26
|
+
var maxLength = 7; // Expectation starts at 1
|
|
20
27
|
// only shows 7 buttons plus prev/next
|
|
21
28
|
|
|
22
29
|
function addFirst() {
|
|
@@ -30,6 +37,7 @@ var Pagination = function Pagination(_ref) {
|
|
|
30
37
|
return [];
|
|
31
38
|
}
|
|
32
39
|
}
|
|
40
|
+
|
|
33
41
|
function addLast() {
|
|
34
42
|
// extra + 1 is number of siblings
|
|
35
43
|
if (currentPage < totalPages) {
|
|
@@ -41,6 +49,7 @@ var Pagination = function Pagination(_ref) {
|
|
|
41
49
|
return [];
|
|
42
50
|
}
|
|
43
51
|
}
|
|
52
|
+
|
|
44
53
|
function addPrev() {
|
|
45
54
|
if (currentPage > 1) {
|
|
46
55
|
return [{
|
|
@@ -48,12 +57,14 @@ var Pagination = function Pagination(_ref) {
|
|
|
48
57
|
text: 'Previous'
|
|
49
58
|
}];
|
|
50
59
|
}
|
|
60
|
+
|
|
51
61
|
return [{
|
|
52
62
|
id: 'previous',
|
|
53
63
|
text: 'Previous',
|
|
54
64
|
disabled: true
|
|
55
65
|
}];
|
|
56
66
|
}
|
|
67
|
+
|
|
57
68
|
function addNext() {
|
|
58
69
|
if (currentPage < totalPages) {
|
|
59
70
|
return [{
|
|
@@ -61,12 +72,14 @@ var Pagination = function Pagination(_ref) {
|
|
|
61
72
|
text: 'Next'
|
|
62
73
|
}];
|
|
63
74
|
}
|
|
75
|
+
|
|
64
76
|
return [{
|
|
65
77
|
id: 'next',
|
|
66
78
|
text: 'Next',
|
|
67
79
|
disabled: true
|
|
68
80
|
}];
|
|
69
81
|
}
|
|
82
|
+
|
|
70
83
|
function buildSiblings() {
|
|
71
84
|
// add check if current page less than totalPages
|
|
72
85
|
var siblings = [{
|
|
@@ -74,23 +87,28 @@ var Pagination = function Pagination(_ref) {
|
|
|
74
87
|
text: currentPage,
|
|
75
88
|
currentPage: true
|
|
76
89
|
}];
|
|
90
|
+
|
|
77
91
|
if (currentPage > 1) {
|
|
78
92
|
siblings.unshift({
|
|
79
93
|
id: currentPage - 1,
|
|
80
94
|
text: currentPage - 1
|
|
81
95
|
});
|
|
82
96
|
}
|
|
97
|
+
|
|
83
98
|
if (currentPage < totalPages - 1) {
|
|
84
99
|
siblings.push({
|
|
85
100
|
id: currentPage + 1,
|
|
86
101
|
text: currentPage + 1
|
|
87
102
|
});
|
|
88
103
|
}
|
|
104
|
+
|
|
89
105
|
return siblings;
|
|
90
106
|
}
|
|
107
|
+
|
|
91
108
|
function buildPreSiblings() {
|
|
92
109
|
var preSiblings = [];
|
|
93
110
|
var remainingSpots = 0;
|
|
111
|
+
|
|
94
112
|
if (currentPage === 4) {
|
|
95
113
|
remainingSpots = 1;
|
|
96
114
|
preSiblings.push({
|
|
@@ -98,6 +116,7 @@ var Pagination = function Pagination(_ref) {
|
|
|
98
116
|
text: 2
|
|
99
117
|
});
|
|
100
118
|
}
|
|
119
|
+
|
|
101
120
|
if (currentPage > 4) {
|
|
102
121
|
remainingSpots = 1;
|
|
103
122
|
preSiblings.push({
|
|
@@ -105,6 +124,7 @@ var Pagination = function Pagination(_ref) {
|
|
|
105
124
|
text: '...'
|
|
106
125
|
});
|
|
107
126
|
}
|
|
127
|
+
|
|
108
128
|
if (currentPage > 4 && currentPage >= totalPages - 2) {
|
|
109
129
|
remainingSpots = 1;
|
|
110
130
|
preSiblings.push({
|
|
@@ -112,6 +132,7 @@ var Pagination = function Pagination(_ref) {
|
|
|
112
132
|
text: totalPages - 4
|
|
113
133
|
});
|
|
114
134
|
}
|
|
135
|
+
|
|
115
136
|
if (currentPage > 4 && currentPage >= totalPages - 1) {
|
|
116
137
|
remainingSpots = 1;
|
|
117
138
|
preSiblings.push({
|
|
@@ -119,6 +140,7 @@ var Pagination = function Pagination(_ref) {
|
|
|
119
140
|
text: totalPages - 3
|
|
120
141
|
});
|
|
121
142
|
}
|
|
143
|
+
|
|
122
144
|
if (currentPage > 4 && currentPage === totalPages) {
|
|
123
145
|
remainingSpots = 1;
|
|
124
146
|
preSiblings.push({
|
|
@@ -126,11 +148,14 @@ var Pagination = function Pagination(_ref) {
|
|
|
126
148
|
text: totalPages - 2
|
|
127
149
|
});
|
|
128
150
|
}
|
|
151
|
+
|
|
129
152
|
return preSiblings;
|
|
130
153
|
}
|
|
154
|
+
|
|
131
155
|
function buildPostSiblings() {
|
|
132
156
|
var postSiblings = [];
|
|
133
157
|
var remainingSpots = maxLength - (currentPage + 1) - 1;
|
|
158
|
+
|
|
134
159
|
if (currentPage < 5) {
|
|
135
160
|
for (var spot = 1; spot < remainingSpots; spot++) {
|
|
136
161
|
// console.log('post-spot', spot)
|
|
@@ -139,34 +164,42 @@ var Pagination = function Pagination(_ref) {
|
|
|
139
164
|
text: currentPage + 1 + spot
|
|
140
165
|
});
|
|
141
166
|
}
|
|
167
|
+
|
|
142
168
|
postSiblings.push({
|
|
143
169
|
id: 'postdots',
|
|
144
170
|
text: '...'
|
|
145
171
|
});
|
|
146
172
|
}
|
|
173
|
+
|
|
147
174
|
if (currentPage >= 5 && currentPage < totalPages - 3) {
|
|
148
175
|
postSiblings.push({
|
|
149
176
|
id: 'postdots',
|
|
150
177
|
text: '...'
|
|
151
178
|
});
|
|
152
179
|
}
|
|
180
|
+
|
|
153
181
|
if (currentPage >= 5 && currentPage === totalPages - 3) {
|
|
154
182
|
postSiblings.push({
|
|
155
183
|
id: totalPages - 1,
|
|
156
184
|
text: totalPages - 1
|
|
157
185
|
});
|
|
158
186
|
}
|
|
187
|
+
|
|
159
188
|
return postSiblings;
|
|
160
189
|
}
|
|
190
|
+
|
|
161
191
|
function buttonValue(item) {
|
|
162
192
|
if (item === 'Previous') {
|
|
163
193
|
return currentPage - 1;
|
|
164
194
|
}
|
|
195
|
+
|
|
165
196
|
if (item === 'Next') {
|
|
166
197
|
return currentPage + 1;
|
|
167
198
|
}
|
|
199
|
+
|
|
168
200
|
return item;
|
|
169
201
|
}
|
|
202
|
+
|
|
170
203
|
function addAll() {
|
|
171
204
|
var items = (0, _toConsumableArray2["default"])(Array(totalPages));
|
|
172
205
|
return items.map(function (item, index) {
|
|
@@ -176,15 +209,19 @@ var Pagination = function Pagination(_ref) {
|
|
|
176
209
|
};
|
|
177
210
|
});
|
|
178
211
|
}
|
|
212
|
+
|
|
179
213
|
function buildAll() {
|
|
180
214
|
if (totalPages > 0 && totalPages <= maxLength) {
|
|
181
215
|
return [].concat((0, _toConsumableArray2["default"])(addPrev()), (0, _toConsumableArray2["default"])(addAll()), (0, _toConsumableArray2["default"])(addNext()));
|
|
182
216
|
}
|
|
217
|
+
|
|
183
218
|
if (totalPages > 0 && totalPages > maxLength) {
|
|
184
219
|
return [].concat((0, _toConsumableArray2["default"])(addPrev()), (0, _toConsumableArray2["default"])(addFirst()), (0, _toConsumableArray2["default"])(buildPreSiblings()), (0, _toConsumableArray2["default"])(buildSiblings()), (0, _toConsumableArray2["default"])(buildPostSiblings()), (0, _toConsumableArray2["default"])(addLast()), (0, _toConsumableArray2["default"])(addNext()));
|
|
185
220
|
}
|
|
221
|
+
|
|
186
222
|
return [];
|
|
187
223
|
}
|
|
224
|
+
|
|
188
225
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
189
226
|
className: "dc-pagination"
|
|
190
227
|
}, /*#__PURE__*/_react["default"].createElement("nav", null, /*#__PURE__*/_react["default"].createElement("ol", {
|
|
@@ -192,17 +229,21 @@ var Pagination = function Pagination(_ref) {
|
|
|
192
229
|
}, buildAll().map(function (item) {
|
|
193
230
|
var buttonClass = '';
|
|
194
231
|
var liClass = '';
|
|
232
|
+
|
|
195
233
|
if (item.text === 'Previous') {
|
|
196
234
|
buttonClass = 'dc-pagination--previous__button';
|
|
197
235
|
liClass = 'dc-pagination--previous';
|
|
198
236
|
}
|
|
237
|
+
|
|
199
238
|
if (item.text === 'Next') {
|
|
200
239
|
buttonClass = 'dc-pagination--next__button';
|
|
201
240
|
liClass = 'dc-pagination--next';
|
|
202
241
|
}
|
|
242
|
+
|
|
203
243
|
if (item.currentPage || item.text === currentPage) {
|
|
204
244
|
buttonClass = 'dc-pagination-current__button';
|
|
205
245
|
}
|
|
246
|
+
|
|
206
247
|
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
207
248
|
key: item.id,
|
|
208
249
|
className: liClass
|
|
@@ -217,5 +258,6 @@ var Pagination = function Pagination(_ref) {
|
|
|
217
258
|
}, item.text));
|
|
218
259
|
}))));
|
|
219
260
|
};
|
|
261
|
+
|
|
220
262
|
var _default = Pagination;
|
|
221
263
|
exports["default"] = _default;
|