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