@twreporter/react-components 8.26.0-rc.4 → 8.27.0-rc.0
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/CHANGELOG.md +21 -0
- package/lib/pagination/index.js +51 -12
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [8.27.0-rc.0](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/react-components@8.26.0...@twreporter/react-components@8.27.0-rc.0) (2024-03-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add className prop ([f2d85fa](https://github.com/twreporter/twreporter-npm-packages/commit/f2d85fa1fcfc4afa4feddb6a001946580fe0d6cb))
|
|
12
|
+
* add mobile pagination ([d128cba](https://github.com/twreporter/twreporter-npm-packages/commit/d128cbafea8459eb03cdac22614e8ec067a89bad))
|
|
13
|
+
* adjust mobile pagination logic ([708f41b](https://github.com/twreporter/twreporter-npm-packages/commit/708f41bb9df638f1b41a15528c73aec7b24639f3))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# [8.26.0](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/react-components@8.26.0-rc.4...@twreporter/react-components@8.26.0) (2024-03-13)
|
|
20
|
+
|
|
21
|
+
**Note:** Version bump only for package @twreporter/react-components
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
6
27
|
# [8.26.0-rc.4](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/react-components@8.26.0-rc.3...@twreporter/react-components@8.26.0-rc.4) (2024-03-12)
|
|
7
28
|
|
|
8
29
|
|
package/lib/pagination/index.js
CHANGED
|
@@ -21,11 +21,13 @@ var _css = require("@twreporter/core/lib/utils/css");
|
|
|
21
21
|
|
|
22
22
|
var _color = require("@twreporter/core/lib/constants/color");
|
|
23
23
|
|
|
24
|
+
var _rwd = require("@twreporter/react-components/lib/rwd");
|
|
25
|
+
|
|
24
26
|
var _concat = _interopRequireDefault(require("lodash/concat"));
|
|
25
27
|
|
|
26
28
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
27
29
|
|
|
28
|
-
var _templateObject, _templateObject2, _templateObject3
|
|
30
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
29
31
|
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
31
33
|
|
|
@@ -121,17 +123,15 @@ var Box = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
121
123
|
var PageNumberBox = /*#__PURE__*/(0, _styledComponents["default"])(Box).withConfig({
|
|
122
124
|
displayName: "pagination__PageNumberBox",
|
|
123
125
|
componentId: "sc-17bqftr-3"
|
|
124
|
-
})(["border:solid 1px ", ";border-radius:50%;line-height:", "px;background-color:", ";> span{color:", ";}"
|
|
126
|
+
})(["border:solid 1px ", ";border-radius:50%;line-height:", "px;background-color:", ";> span{color:", ";}"], _color.colorSupportive.heavy, styles.btnBoxSize.desktop, function (props) {
|
|
125
127
|
return props.isCurrent ? _color.colorSupportive.heavy : 'transparent';
|
|
126
128
|
}, function (props) {
|
|
127
129
|
return props.isCurrent ? _color.colorGrayscale.white : _color.colorSupportive.heavy;
|
|
128
|
-
}
|
|
129
|
-
return props.isCurrent ? '' : 'none';
|
|
130
|
-
}));
|
|
130
|
+
});
|
|
131
131
|
var EllipsisBox = /*#__PURE__*/(0, _styledComponents["default"])(Box).withConfig({
|
|
132
132
|
displayName: "pagination__EllipsisBox",
|
|
133
133
|
componentId: "sc-17bqftr-4"
|
|
134
|
-
})(["cursor:default;padding:", ";", ""], (0, _css.arrayToCssShorthand)(styles.ellipsisBoxPadding), _mediaQuery["default"].mobileOnly(
|
|
134
|
+
})(["cursor:default;padding:", ";", ""], (0, _css.arrayToCssShorthand)(styles.ellipsisBoxPadding), _mediaQuery["default"].mobileOnly(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: none;\n "]))));
|
|
135
135
|
var PrevNextBtn = /*#__PURE__*/(0, _styledComponents["default"])(Box).withConfig({
|
|
136
136
|
displayName: "pagination__PrevNextBtn",
|
|
137
137
|
componentId: "sc-17bqftr-5"
|
|
@@ -269,6 +269,30 @@ var Pagination = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
269
269
|
var length = nOfCenterPages;
|
|
270
270
|
return _.concat(leftMarginJSX, leftEllipsisJSX, this._buildCenterJSX(startAt, length, currentPage), rightEllipsisJSX, rightMarginJSX);
|
|
271
271
|
}
|
|
272
|
+
}, {
|
|
273
|
+
key: "_buildMobilePagesArray",
|
|
274
|
+
value: function _buildMobilePagesArray(currentPage, totalPages) {
|
|
275
|
+
var pagesArrayMaxLength = 5;
|
|
276
|
+
|
|
277
|
+
if (totalPages <= pagesArrayMaxLength) {
|
|
278
|
+
return this._buildCenterJSX(1, totalPages, currentPage);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
var startPage; // Check if currentPage is within the first two pages or the last two pages
|
|
282
|
+
|
|
283
|
+
if (currentPage <= 2) {
|
|
284
|
+
// If in the first two pages, start from page 1
|
|
285
|
+
startPage = 1;
|
|
286
|
+
} else if (currentPage >= totalPages - 1) {
|
|
287
|
+
// If in the last two pages, adjust startPage to ensure the array is fully populated
|
|
288
|
+
startPage = totalPages - pagesArrayMaxLength + 1;
|
|
289
|
+
} else {
|
|
290
|
+
// Otherwise, center currentPage by adjusting startPage accordingly
|
|
291
|
+
startPage = currentPage - 2;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return this._buildCenterJSX(startPage, pagesArrayMaxLength, currentPage);
|
|
295
|
+
}
|
|
272
296
|
}, {
|
|
273
297
|
key: "render",
|
|
274
298
|
value: function render() {
|
|
@@ -276,20 +300,33 @@ var Pagination = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
276
300
|
currentPage = _this$props2.currentPage,
|
|
277
301
|
totalPages = _this$props2.totalPages,
|
|
278
302
|
handleClickPrev = _this$props2.handleClickPrev,
|
|
279
|
-
handleClickNext = _this$props2.handleClickNext
|
|
280
|
-
|
|
303
|
+
handleClickNext = _this$props2.handleClickNext,
|
|
304
|
+
className = _this$props2.className;
|
|
305
|
+
if (!totalPages || !currentPage) return /*#__PURE__*/_react["default"].createElement(PaginationContainer, {
|
|
306
|
+
className: className
|
|
307
|
+
}, /*#__PURE__*/_react["default"].createElement(Boxes, null));
|
|
281
308
|
|
|
282
309
|
var pagesArrayJSX = this._buildPagesArray(currentPage, totalPages);
|
|
283
310
|
|
|
311
|
+
var mobilePagesArrayJSX = this._buildMobilePagesArray(currentPage, totalPages);
|
|
312
|
+
|
|
284
313
|
var belowFirstPage = currentPage <= 1;
|
|
285
314
|
var aboveFinalPage = currentPage >= totalPages;
|
|
286
|
-
return /*#__PURE__*/_react["default"].createElement(PaginationContainer,
|
|
315
|
+
return /*#__PURE__*/_react["default"].createElement(PaginationContainer, {
|
|
316
|
+
className: className
|
|
317
|
+
}, /*#__PURE__*/_react["default"].createElement(_rwd.TabletAndAbove, null, /*#__PURE__*/_react["default"].createElement(Boxes, null, belowFirstPage ? null : /*#__PURE__*/_react["default"].createElement(PrevNextBtn, {
|
|
287
318
|
key: "prev-btn",
|
|
288
319
|
onClick: handleClickPrev
|
|
289
320
|
}, /*#__PURE__*/_react["default"].createElement(PageUpIcon, null)), pagesArrayJSX, aboveFinalPage ? null : /*#__PURE__*/_react["default"].createElement(PrevNextBtn, {
|
|
290
321
|
key: "next-btn",
|
|
291
322
|
onClick: handleClickNext
|
|
292
|
-
}, /*#__PURE__*/_react["default"].createElement(PageDownIcon, null))))
|
|
323
|
+
}, /*#__PURE__*/_react["default"].createElement(PageDownIcon, null)))), /*#__PURE__*/_react["default"].createElement(_rwd.MobileOnly, null, /*#__PURE__*/_react["default"].createElement(Boxes, null, belowFirstPage ? null : /*#__PURE__*/_react["default"].createElement(PrevNextBtn, {
|
|
324
|
+
key: "prev-btn",
|
|
325
|
+
onClick: handleClickPrev
|
|
326
|
+
}, /*#__PURE__*/_react["default"].createElement(PageUpIcon, null)), mobilePagesArrayJSX, aboveFinalPage ? null : /*#__PURE__*/_react["default"].createElement(PrevNextBtn, {
|
|
327
|
+
key: "next-btn",
|
|
328
|
+
onClick: handleClickNext
|
|
329
|
+
}, /*#__PURE__*/_react["default"].createElement(PageDownIcon, null)))));
|
|
293
330
|
}
|
|
294
331
|
}]);
|
|
295
332
|
|
|
@@ -304,14 +341,16 @@ Pagination.propTypes = {
|
|
|
304
341
|
handleClickPrev: _propTypes["default"].func.isRequired,
|
|
305
342
|
nOfCenterPages: _propTypes["default"].number.isRequired,
|
|
306
343
|
nOfMarginPages: _propTypes["default"].number.isRequired,
|
|
307
|
-
totalPages: _propTypes["default"].number.isRequired
|
|
344
|
+
totalPages: _propTypes["default"].number.isRequired,
|
|
345
|
+
className: _propTypes["default"].string
|
|
308
346
|
};
|
|
309
347
|
Pagination.defaultProps = {
|
|
310
348
|
currentPage: 1,
|
|
311
349
|
totalPages: 1,
|
|
312
350
|
ellipsis: '…',
|
|
313
351
|
nOfCenterPages: 4,
|
|
314
|
-
nOfMarginPages: 1
|
|
352
|
+
nOfMarginPages: 1,
|
|
353
|
+
className: ''
|
|
315
354
|
};
|
|
316
355
|
var _default = Pagination;
|
|
317
356
|
exports["default"] = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twreporter/react-components",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.27.0-rc.0",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"repository": "https://github.com/twreporter/twreporter-npm-packages.git",
|
|
6
6
|
"author": "twreporter <developer@twreporter.org>",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"chromatic": "npx chromatic --exit-zero-on-changes"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@twreporter/core": "^1.19.0
|
|
19
|
-
"@twreporter/redux": "^7.11.2
|
|
18
|
+
"@twreporter/core": "^1.19.0",
|
|
19
|
+
"@twreporter/redux": "^7.11.2",
|
|
20
20
|
"fontfaceobserver-es": "^3.3.3",
|
|
21
21
|
"hoist-non-react-statics": "^2.3.1",
|
|
22
22
|
"lodash": "^4.0.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"react-dom": "^16.0.0",
|
|
52
52
|
"storybook": "^7.5.2"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "1a9c3f4ba2a3e44721879710fa268791bd961a1a"
|
|
55
55
|
}
|