widenarrow-ui 1.0.48 → 1.0.50
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/Pagination/Pagination.types.d.ts +7 -3
- package/lib/index.d.ts +8 -7
- package/lib/index.esm.js +20 -22
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +20 -22
- package/lib/index.js.map +1 -1
- package/lib/types/common.types.d.ts +1 -4
- package/package.json +1 -1
- package/src/components/Pagination/Pagination.tsx +82 -65
- package/src/components/Pagination/Pagination.types.ts +7 -3
- package/src/types/common.types.ts +1 -4
|
@@ -2,14 +2,18 @@ import { HierarchyTypes } from 'src/constants';
|
|
|
2
2
|
import { SearchResultInterface } from '../../types/common.types';
|
|
3
3
|
export interface PaginationProps {
|
|
4
4
|
pagination: SearchResultInterface;
|
|
5
|
-
|
|
6
|
-
onPageSizeChange?: (pageSize: number) => void;
|
|
5
|
+
onChange: (searchResult: SearchResultInterface) => void;
|
|
7
6
|
slim?: boolean;
|
|
8
|
-
|
|
7
|
+
withPageSizeChange?: boolean;
|
|
8
|
+
withTablePagination?: boolean;
|
|
9
|
+
withFastForwardButtons?: boolean;
|
|
10
|
+
pageSizeOptions?: Array<number>;
|
|
9
11
|
buttonType?: HierarchyTypes.PRIMARY | HierarchyTypes.SECONDARY;
|
|
10
12
|
className?: string;
|
|
11
13
|
nextPageTitle?: string;
|
|
12
14
|
previousPageTitle?: string;
|
|
15
|
+
firstPageTitle?: string;
|
|
16
|
+
lastPageTitle?: string;
|
|
13
17
|
pageSizeTitleCallback?: (args: {
|
|
14
18
|
pageSize: number;
|
|
15
19
|
}) => string;
|
package/lib/index.d.ts
CHANGED
|
@@ -497,27 +497,28 @@ declare const FacetButton: FC<FacetButtonProps>;
|
|
|
497
497
|
interface SearchResultInterface {
|
|
498
498
|
currentPage: number;
|
|
499
499
|
numberOfPages: number;
|
|
500
|
+
pages: number;
|
|
500
501
|
pageSize: number;
|
|
501
502
|
numberOfHits: number;
|
|
502
503
|
sortOrder: number;
|
|
503
504
|
fetching?: boolean;
|
|
504
|
-
pages: number;
|
|
505
|
-
fetched?: boolean;
|
|
506
505
|
searchTerm?: string;
|
|
507
|
-
ids?: Array<number>;
|
|
508
|
-
pending?: boolean;
|
|
509
506
|
}
|
|
510
507
|
|
|
511
508
|
interface PaginationProps {
|
|
512
509
|
pagination: SearchResultInterface;
|
|
513
|
-
|
|
514
|
-
onPageSizeChange?: (pageSize: number) => void;
|
|
510
|
+
onChange: (searchResult: SearchResultInterface) => void;
|
|
515
511
|
slim?: boolean;
|
|
516
|
-
|
|
512
|
+
withPageSizeChange?: boolean;
|
|
513
|
+
withTablePagination?: boolean;
|
|
514
|
+
withFastForwardButtons?: boolean;
|
|
515
|
+
pageSizeOptions?: Array<number>;
|
|
517
516
|
buttonType?: HierarchyTypes$1.PRIMARY | HierarchyTypes$1.SECONDARY;
|
|
518
517
|
className?: string;
|
|
519
518
|
nextPageTitle?: string;
|
|
520
519
|
previousPageTitle?: string;
|
|
520
|
+
firstPageTitle?: string;
|
|
521
|
+
lastPageTitle?: string;
|
|
521
522
|
pageSizeTitleCallback?: (args: {
|
|
522
523
|
pageSize: number;
|
|
523
524
|
}) => string;
|
package/lib/index.esm.js
CHANGED
|
@@ -2608,7 +2608,7 @@ var styles$b = {"body":"Pagination-module_WRLv5h","container":"Pagination-module
|
|
|
2608
2608
|
var s$b = classNames.bind(styles$b);
|
|
2609
2609
|
var Pagination = function (_a) {
|
|
2610
2610
|
var _b;
|
|
2611
|
-
var className = _a.className, pagination = _a.pagination,
|
|
2611
|
+
var className = _a.className, pagination = _a.pagination, slim = _a.slim, onChange = _a.onChange, _c = _a.buttonType, buttonType = _c === void 0 ? 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;
|
|
2612
2612
|
if (!pagination) {
|
|
2613
2613
|
return null;
|
|
2614
2614
|
}
|
|
@@ -2624,9 +2624,6 @@ var Pagination = function (_a) {
|
|
|
2624
2624
|
var _a;
|
|
2625
2625
|
return s$b('button', (_a = { button_slim: slim }, _a[additionalClassName] = additionalClassName, _a));
|
|
2626
2626
|
};
|
|
2627
|
-
if (numberOfPages < 2) {
|
|
2628
|
-
return null;
|
|
2629
|
-
}
|
|
2630
2627
|
if (pagination.fetching && !numberOfPages) {
|
|
2631
2628
|
return (jsx("ul", { className: s$b('container', (_b = {}, _b[className] = className, _b)), children: times(function (i) { return (jsx("li", { className: itemClassName, children: jsx("div", { className: buttonClassName() }) }, i)); }, 5) }));
|
|
2632
2629
|
}
|
|
@@ -2637,39 +2634,40 @@ var Pagination = function (_a) {
|
|
|
2637
2634
|
? tableIntervalTitleCallback({ start: start, end: end, total: pagination.numberOfHits })
|
|
2638
2635
|
: "".concat(start, " - ").concat(end, " of ").concat(pagination.numberOfHits) }) }));
|
|
2639
2636
|
};
|
|
2637
|
+
var firstPageButton = withFastForwardButtons ? (jsx("li", { children: jsx("button", { title: firstPageTitle || 'First page', className: buttonClassName(isFirstPage ? 'button_disabled' : undefined), onClick: function () {
|
|
2638
|
+
onChange(__assign(__assign({}, pagination), { currentPage: 1 }));
|
|
2639
|
+
}, disabled: isFirstPage, children: jsx(Icon, { icon: IconTypes.ARROW_FIRST_PAGE }) }) })) : null;
|
|
2640
|
+
var previousPageButton = (jsx("li", { className: itemClassName, children: jsx("button", { title: previousPageTitle || 'Previous page', className: buttonClassName(isFirstPage ? 'button_disabled' : undefined), onClick: function () {
|
|
2641
|
+
!isFirstPage && onChange(__assign(__assign({}, pagination), { currentPage: pagination.currentPage - 1 }));
|
|
2642
|
+
}, disabled: isFirstPage, children: jsx(Icon, { icon: IconTypes.CHEVRON_LEFT }) }) }));
|
|
2643
|
+
var nextPageButton = (jsx("li", { className: itemClassName, children: jsx("button", { title: nextPageTitle || 'Next page', className: buttonClassName(isLastPage ? 'button_disabled' : undefined), onClick: function () {
|
|
2644
|
+
onChange(__assign(__assign({}, pagination), { currentPage: pagination.currentPage + 1 }));
|
|
2645
|
+
}, disabled: isLastPage, children: jsx(Icon, { icon: IconTypes.CHEVRON_RIGHT }) }) }));
|
|
2646
|
+
var lastPageButton = withFastForwardButtons ? (jsx("li", { children: jsx("button", { title: lastPageTitle || 'Last page', className: buttonClassName(isLastPage ? 'button_disabled' : undefined), onClick: function () {
|
|
2647
|
+
onChange(__assign(__assign({}, pagination), { currentPage: numberOfPages }));
|
|
2648
|
+
}, disabled: isLastPage, children: jsx(Icon, { icon: IconTypes.ARROW_LAST_PAGE }) }) })) : null;
|
|
2640
2649
|
/*
|
|
2641
2650
|
paginationMarkup
|
|
2642
2651
|
*/
|
|
2643
2652
|
var paginationMarkup = function () {
|
|
2644
2653
|
var _a, _b;
|
|
2645
|
-
if (
|
|
2646
|
-
return (jsxs(Box, { alignItems: 'center', children: [jsxs("ul", { className: s$b('container', (_a = {}, _a[className] = className, _a)), children: [
|
|
2647
|
-
!isFirstPage && onPaginate(pagination.currentPage - 1);
|
|
2648
|
-
}, disabled: isFirstPage, children: jsx(Icon, { icon: IconTypes.CHEVRON_LEFT }) }) }), jsx("li", { className: itemClassName, children: jsx("button", { title: nextPageTitle || 'Next page', className: buttonClassName(isLastPage ? 'button_disabled' : undefined), onClick: function () {
|
|
2649
|
-
onPaginate(pagination.currentPage + 1);
|
|
2650
|
-
}, disabled: isLastPage, children: jsx(Icon, { icon: IconTypes.CHEVRON_RIGHT }) }) })] }), getPageInfoText()] }));
|
|
2654
|
+
if (withTablePagination) {
|
|
2655
|
+
return (jsxs(Box, { alignItems: 'center', children: [jsxs("ul", { className: s$b('container', (_a = {}, _a[className] = className, _a)), children: [firstPageButton, previousPageButton, nextPageButton, lastPageButton] }), getPageInfoText()] }));
|
|
2651
2656
|
}
|
|
2652
|
-
return (jsxs("ul", { className: s$b('container', (_b = {}, _b[className] = className, _b)), children: [
|
|
2653
|
-
!isFirstPage && onPaginate(pagination.currentPage - 1);
|
|
2654
|
-
}, disabled: isFirstPage, children: jsx(Icon, { icon: IconTypes.CHEVRON_LEFT }) }) }), getPaginationArray(pagination).map(function (pageObject, index) {
|
|
2657
|
+
return (jsxs("ul", { className: s$b('container', (_b = {}, _b[className] = className, _b)), children: [firstPageButton, previousPageButton, getPaginationArray(pagination).map(function (pageObject, index) {
|
|
2655
2658
|
if (pageObject.type === 'dots') {
|
|
2656
2659
|
return (jsx("li", { className: itemClassName, children: jsx("div", { className: s$b('dots', { dots_slim: slim }), children: "..." }) }, "".concat(pageObject.type, "-").concat(index)));
|
|
2657
2660
|
}
|
|
2658
2661
|
return (jsx("li", { className: itemClassName, children: jsx("button", { title: "Go to page ".concat(pageObject.page), className: buttonClassName(pageObject.page === pagination.currentPage ? 'button_isActive' : undefined), onClick: function () {
|
|
2659
|
-
|
|
2662
|
+
onChange(__assign(__assign({}, pagination), { currentPage: pageObject.page }));
|
|
2660
2663
|
}, children: pageObject.page }) }, "".concat(pageObject.type, "-").concat(index)));
|
|
2661
|
-
}),
|
|
2662
|
-
onPaginate(pagination.currentPage + 1);
|
|
2663
|
-
}, disabled: isLastPage, children: jsx(Icon, { icon: IconTypes.CHEVRON_RIGHT }) }) })] }));
|
|
2664
|
+
}), nextPageButton, lastPageButton] }));
|
|
2664
2665
|
};
|
|
2665
|
-
/*
|
|
2666
|
-
pageSizeMarkup
|
|
2667
|
-
*/
|
|
2668
2666
|
var sizeTitle = pageSizeTitleCallback ? pageSizeTitleCallback({ pageSize: pagination.pageSize }) : "Page size: ".concat(pagination.pageSize);
|
|
2669
2667
|
var pageSizeMarkup = function () {
|
|
2670
|
-
return
|
|
2668
|
+
return withPageSizeChange ? (jsxs(Fragment, { children: [jsx(Separator, { marginX: '15' }), jsx(DropDown, { buttonComponent: jsx(InlineButton, { type: buttonType, text: sizeTitle }), title: sizeTitle, children: pageSizeOptions
|
|
2671
2669
|
.filter(function (pageSize) { return pageSize < pagination.numberOfHits; })
|
|
2672
|
-
.map(function (pageSize) { return (jsx(DropDownItem, { text: pageSize.toString(), onClickCallback: function () { return
|
|
2670
|
+
.map(function (pageSize) { return (jsx(DropDownItem, { text: pageSize.toString(), onClickCallback: function () { return onChange(__assign(__assign({}, pagination), { pageSize: pageSize })); }, active: pagination.pageSize === pageSize, closeDropDownOnClick: true, withEllipsis: true })); }) })] })) : null;
|
|
2673
2671
|
};
|
|
2674
2672
|
return (jsxs(Box, { alignItems: 'center', children: [paginationMarkup(), pageSizeMarkup()] }));
|
|
2675
2673
|
};
|