widenarrow-ui 1.0.47 → 1.0.49
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/lib/components/Button/Button.types.d.ts +1 -1
- package/lib/components/DropDownItem/DropDownItem.types.d.ts +1 -1
- package/lib/components/Pagination/Pagination.types.d.ts +18 -7
- package/lib/index.d.ts +74 -64
- package/lib/index.esm.js +26 -31
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +26 -31
- package/lib/index.js.map +1 -1
- package/lib/types/styling.types.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Button/Button.types.ts +1 -1
- package/src/components/DropDownItem/DropDownItem.types.ts +1 -1
- package/src/components/Pagination/Pagination.stories.tsx +3 -1
- package/src/components/Pagination/Pagination.tsx +95 -82
- package/src/components/Pagination/Pagination.types.ts +12 -7
- package/src/types/styling.types.ts +1 -1
package/lib/index.js
CHANGED
|
@@ -2610,9 +2610,7 @@ var styles$b = {"body":"Pagination-module_WRLv5h","container":"Pagination-module
|
|
|
2610
2610
|
var s$b = classNames.bind(styles$b);
|
|
2611
2611
|
var Pagination = function (_a) {
|
|
2612
2612
|
var _b;
|
|
2613
|
-
var className = _a.className, pagination = _a.pagination,
|
|
2614
|
-
t: function (value) { return value; }
|
|
2615
|
-
} : _c;
|
|
2613
|
+
var className = _a.className, pagination = _a.pagination, slim = _a.slim, onChange = _a.onChange, _c = _a.buttonType, buttonType = _c === void 0 ? exports.HierarchyTypes.SECONDARY : _c, _d = _a.pageSizeOptions, pageSizeOptions = _d === void 0 ? [10, 20, 30, 40, 50, 80, 100] : _d, firstPageTitle = _a.firstPageTitle, previousPageTitle = _a.previousPageTitle, nextPageTitle = _a.nextPageTitle, lastPageTitle = _a.lastPageTitle, pageSizeTitleCallback = _a.pageSizeTitleCallback, tableIntervalTitleCallback = _a.tableIntervalTitleCallback, withTablePagination = _a.withTablePagination, withFastForwardButtons = _a.withFastForwardButtons, withPageSizeChange = _a.withPageSizeChange;
|
|
2616
2614
|
if (!pagination) {
|
|
2617
2615
|
return null;
|
|
2618
2616
|
}
|
|
@@ -2628,53 +2626,50 @@ var Pagination = function (_a) {
|
|
|
2628
2626
|
var _a;
|
|
2629
2627
|
return s$b('button', (_a = { button_slim: slim }, _a[additionalClassName] = additionalClassName, _a));
|
|
2630
2628
|
};
|
|
2631
|
-
if (numberOfPages < 2) {
|
|
2632
|
-
return null;
|
|
2633
|
-
}
|
|
2634
2629
|
if (pagination.fetching && !numberOfPages) {
|
|
2635
|
-
return (jsxRuntime.jsx("ul", { className: s$b('container', (_b = {}, _b[className] = className, _b)), children: ramda.times(function (i) { return (jsxRuntime.jsx("li", { className: itemClassName, children: jsxRuntime.jsx("div", { className: buttonClassName(
|
|
2630
|
+
return (jsxRuntime.jsx("ul", { className: s$b('container', (_b = {}, _b[className] = className, _b)), children: ramda.times(function (i) { return (jsxRuntime.jsx("li", { className: itemClassName, children: jsxRuntime.jsx("div", { className: buttonClassName() }) }, i)); }, 5) }));
|
|
2636
2631
|
}
|
|
2637
2632
|
var getPageInfoText = function () {
|
|
2638
2633
|
var start = (pagination.currentPage - 1) * pagination.pageSize + 1;
|
|
2639
2634
|
var end = pagination.currentPage * pagination.pageSize;
|
|
2640
|
-
return (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(Paragraph, { marginBottom: '0', marginLeft: '2', children:
|
|
2641
|
-
start: start,
|
|
2642
|
-
|
|
2643
|
-
total: pagination.numberOfHits
|
|
2644
|
-
}) }) }));
|
|
2635
|
+
return (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(Paragraph, { marginBottom: '0', marginLeft: '2', children: tableIntervalTitleCallback
|
|
2636
|
+
? tableIntervalTitleCallback({ start: start, end: end, total: pagination.numberOfHits })
|
|
2637
|
+
: "".concat(start, " - ").concat(end, " of ").concat(pagination.numberOfHits) }) }));
|
|
2645
2638
|
};
|
|
2639
|
+
var firstPageButton = withFastForwardButtons ? (jsxRuntime.jsx("li", { children: jsxRuntime.jsx("button", { title: firstPageTitle || 'First page', className: buttonClassName(isFirstPage ? 'button_disabled' : undefined), onClick: function () {
|
|
2640
|
+
onChange(__assign(__assign({}, pagination), { currentPage: 1 }));
|
|
2641
|
+
}, disabled: isFirstPage, children: jsxRuntime.jsx(Icon, { icon: exports.IconTypes.ARROW_FIRST_PAGE }) }) })) : null;
|
|
2642
|
+
var previousPageButton = (jsxRuntime.jsx("li", { className: itemClassName, children: jsxRuntime.jsx("button", { title: previousPageTitle || 'Previous page', className: buttonClassName(isFirstPage ? 'button_disabled' : undefined), onClick: function () {
|
|
2643
|
+
!isFirstPage && onChange(__assign(__assign({}, pagination), { currentPage: pagination.currentPage - 1 }));
|
|
2644
|
+
}, disabled: isFirstPage, children: jsxRuntime.jsx(Icon, { icon: exports.IconTypes.CHEVRON_LEFT }) }) }));
|
|
2645
|
+
var nextPageButton = (jsxRuntime.jsx("li", { className: itemClassName, children: jsxRuntime.jsx("button", { title: nextPageTitle || 'Next page', className: buttonClassName(isLastPage ? 'button_disabled' : undefined), onClick: function () {
|
|
2646
|
+
onChange(__assign(__assign({}, pagination), { currentPage: pagination.currentPage + 1 }));
|
|
2647
|
+
}, disabled: isLastPage, children: jsxRuntime.jsx(Icon, { icon: exports.IconTypes.CHEVRON_RIGHT }) }) }));
|
|
2648
|
+
var lastPageButton = withFastForwardButtons ? (jsxRuntime.jsx("li", { children: jsxRuntime.jsx("button", { title: lastPageTitle || 'Last page', className: buttonClassName(isLastPage ? 'button_disabled' : undefined), onClick: function () {
|
|
2649
|
+
onChange(__assign(__assign({}, pagination), { currentPage: pagination.numberOfPages }));
|
|
2650
|
+
}, disabled: isLastPage, children: jsxRuntime.jsx(Icon, { icon: exports.IconTypes.ARROW_LAST_PAGE }) }) })) : null;
|
|
2646
2651
|
/*
|
|
2647
2652
|
paginationMarkup
|
|
2648
2653
|
*/
|
|
2649
2654
|
var paginationMarkup = function () {
|
|
2650
2655
|
var _a, _b;
|
|
2651
|
-
if (
|
|
2652
|
-
return (jsxRuntime.jsxs(Box, { alignItems: 'center', children: [jsxRuntime.jsxs("ul", { className: s$b('container', (_a = {}, _a[className] = className, _a)), children: [
|
|
2653
|
-
!isFirstPage && onPaginate(pagination.currentPage - 1);
|
|
2654
|
-
}, disabled: isFirstPage, children: jsxRuntime.jsx(Icon, { icon: exports.IconTypes.CHEVRON_LEFT }) }) }), jsxRuntime.jsx("li", { className: itemClassName, children: jsxRuntime.jsx("button", { title: i18n.t('Next page'), className: buttonClassName(isLastPage ? 'button_disabled' : undefined), onClick: function () {
|
|
2655
|
-
onPaginate(pagination.currentPage + 1);
|
|
2656
|
-
}, disabled: isLastPage, children: jsxRuntime.jsx(Icon, { icon: exports.IconTypes.CHEVRON_RIGHT }) }) })] }), getPageInfoText()] }));
|
|
2656
|
+
if (withTablePagination) {
|
|
2657
|
+
return (jsxRuntime.jsxs(Box, { alignItems: 'center', children: [jsxRuntime.jsxs("ul", { className: s$b('container', (_a = {}, _a[className] = className, _a)), children: [firstPageButton, previousPageButton, nextPageButton, lastPageButton] }), getPageInfoText()] }));
|
|
2657
2658
|
}
|
|
2658
|
-
return (jsxRuntime.jsxs("ul", { className: s$b('container', (_b = {}, _b[className] = className, _b)), children: [
|
|
2659
|
-
!isFirstPage && onPaginate(pagination.currentPage - 1);
|
|
2660
|
-
}, disabled: isFirstPage, children: jsxRuntime.jsx(Icon, { icon: exports.IconTypes.CHEVRON_LEFT }) }) }), getPaginationArray(pagination).map(function (pageObject, index) {
|
|
2659
|
+
return (jsxRuntime.jsxs("ul", { className: s$b('container', (_b = {}, _b[className] = className, _b)), children: [firstPageButton, previousPageButton, getPaginationArray(pagination).map(function (pageObject, index) {
|
|
2661
2660
|
if (pageObject.type === 'dots') {
|
|
2662
2661
|
return (jsxRuntime.jsx("li", { className: itemClassName, children: jsxRuntime.jsx("div", { className: s$b('dots', { dots_slim: slim }), children: "..." }) }, "".concat(pageObject.type, "-").concat(index)));
|
|
2663
2662
|
}
|
|
2664
|
-
return (jsxRuntime.jsx("li", { className: itemClassName, children: jsxRuntime.jsx("button", { title:
|
|
2665
|
-
|
|
2663
|
+
return (jsxRuntime.jsx("li", { className: itemClassName, children: jsxRuntime.jsx("button", { title: "Go to page ".concat(pageObject.page), className: buttonClassName(pageObject.page === pagination.currentPage ? 'button_isActive' : undefined), onClick: function () {
|
|
2664
|
+
onChange(__assign(__assign({}, pagination), { currentPage: pageObject.page }));
|
|
2666
2665
|
}, children: pageObject.page }) }, "".concat(pageObject.type, "-").concat(index)));
|
|
2667
|
-
}),
|
|
2668
|
-
onPaginate(pagination.currentPage + 1);
|
|
2669
|
-
}, disabled: isLastPage, children: jsxRuntime.jsx(Icon, { icon: exports.IconTypes.CHEVRON_RIGHT }) }) })] }));
|
|
2666
|
+
}), nextPageButton, lastPageButton] }));
|
|
2670
2667
|
};
|
|
2671
|
-
|
|
2672
|
-
pageSizeMarkup
|
|
2673
|
-
*/
|
|
2668
|
+
var sizeTitle = pageSizeTitleCallback ? pageSizeTitleCallback({ pageSize: pagination.pageSize }) : "Page size: ".concat(pagination.pageSize);
|
|
2674
2669
|
var pageSizeMarkup = function () {
|
|
2675
|
-
return
|
|
2670
|
+
return withPageSizeChange ? (jsxRuntime.jsxs(react.Fragment, { children: [jsxRuntime.jsx(Separator, { marginX: '15' }), jsxRuntime.jsx(DropDown, { buttonComponent: jsxRuntime.jsx(InlineButton, { type: buttonType, text: sizeTitle }), title: sizeTitle, children: pageSizeOptions
|
|
2676
2671
|
.filter(function (pageSize) { return pageSize < pagination.numberOfHits; })
|
|
2677
|
-
.map(function (pageSize) { return (jsxRuntime.jsx(DropDownItem, { text: pageSize.toString(), onClickCallback: function () { return
|
|
2672
|
+
.map(function (pageSize) { return (jsxRuntime.jsx(DropDownItem, { text: pageSize.toString(), onClickCallback: function () { return onChange(__assign(__assign({}, pagination), { pageSize: pageSize })); }, active: pagination.pageSize === pageSize, closeDropDownOnClick: true, withEllipsis: true })); }) })] })) : null;
|
|
2678
2673
|
};
|
|
2679
2674
|
return (jsxRuntime.jsxs(Box, { alignItems: 'center', children: [paginationMarkup(), pageSizeMarkup()] }));
|
|
2680
2675
|
};
|