@absreim/react-bootstrap-data-grid-pro 4.4.0 → 4.5.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/common/pagination/PageSelector.js +28 -18
- package/common/pagination/PageSizeSelector.d.ts +1 -0
- package/common/pagination/PageSizeSelector.js +20 -7
- package/common/pagination/Pagination.js +3 -3
- package/common/pagination/internalTypes.d.ts +1 -1
- package/common/pagination/types.d.ts +12 -1
- package/common/pipeline/useCombinedPipeline/useCurrentPageRows.js +1 -0
- package/common.css +1 -0
- package/common.scss +7 -0
- package/grid/main/Grid.js +1 -1
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ import classNames from "classnames";
|
|
|
14
14
|
* @param size - Size variant of the <ul> element
|
|
15
15
|
*/
|
|
16
16
|
const PageSelector = ({ numPages, numButtons, pageNum, setPageNum, ariaLabel, alignment, size, }) => {
|
|
17
|
-
const ulClasses = ["pagination"];
|
|
17
|
+
const ulClasses = ["pagination", "mb-0"];
|
|
18
18
|
if (size === "small") {
|
|
19
19
|
ulClasses.push("pagination-sm");
|
|
20
20
|
}
|
|
@@ -43,39 +43,49 @@ const PageSelector = ({ numPages, numButtons, pageNum, setPageNum, ariaLabel, al
|
|
|
43
43
|
}
|
|
44
44
|
return indices;
|
|
45
45
|
}, [lowerBound, upperBound]);
|
|
46
|
+
const leftArrowButtonsDisabled = pageNum === 1;
|
|
47
|
+
const rightArrowButtonsDisabled = pageNum === numPages;
|
|
46
48
|
function getFirstArrowButton() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return (_jsx("li", { className: "page-item", children: _jsx("a", { className: "page-link", href: "#", "aria-label": "First", onClick: (event) => {
|
|
49
|
+
return (_jsx("li", { className: classNames("page-item", {
|
|
50
|
+
disabled: leftArrowButtonsDisabled,
|
|
51
|
+
}), children: _jsx("a", { className: "page-link", href: "#", "aria-label": "First", tabIndex: leftArrowButtonsDisabled ? -1 : 0, onClick: (event) => {
|
|
51
52
|
event.preventDefault();
|
|
53
|
+
if (leftArrowButtonsDisabled) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
52
56
|
setPageNum(1);
|
|
53
57
|
}, children: _jsx("span", { "aria-hidden": "true", children: "<<" }) }) }));
|
|
54
58
|
}
|
|
55
59
|
function getPrevArrowButton() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return (_jsx("li", { className: "page-item", children: _jsx("a", { className: "page-link", href: "#", "aria-label": "Previous", onClick: (event) => {
|
|
60
|
+
return (_jsx("li", { className: classNames("page-item", {
|
|
61
|
+
disabled: leftArrowButtonsDisabled,
|
|
62
|
+
}), children: _jsx("a", { className: "page-link", href: "#", "aria-label": "Previous", tabIndex: leftArrowButtonsDisabled ? -1 : 0, onClick: (event) => {
|
|
60
63
|
event.preventDefault();
|
|
64
|
+
if (leftArrowButtonsDisabled) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
61
67
|
setPageNum(pageNum - 1);
|
|
62
68
|
}, children: _jsx("span", { "aria-hidden": "true", children: "<" }) }) }));
|
|
63
69
|
}
|
|
64
70
|
function getNextArrowButton() {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return (_jsx("li", { className: "page-item", children: _jsx("a", { className: "page-link", href: "#", "aria-label": "Next", onClick: (event) => {
|
|
71
|
+
return (_jsx("li", { className: classNames("page-item", {
|
|
72
|
+
disabled: rightArrowButtonsDisabled,
|
|
73
|
+
}), children: _jsx("a", { className: "page-link", href: "#", "aria-label": "Next", tabIndex: rightArrowButtonsDisabled ? -1 : 0, onClick: (event) => {
|
|
69
74
|
event.preventDefault();
|
|
75
|
+
if (rightArrowButtonsDisabled) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
70
78
|
setPageNum(pageNum + 1);
|
|
71
79
|
}, children: _jsx("span", { "aria-hidden": "true", children: ">" }) }) }));
|
|
72
80
|
}
|
|
73
81
|
function getLastArrowButton() {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return (_jsx("li", { className: "page-item", children: _jsx("a", { className: "page-link", href: "#", "aria-label": "Last", onClick: (event) => {
|
|
82
|
+
return (_jsx("li", { className: classNames("page-item", {
|
|
83
|
+
disabled: rightArrowButtonsDisabled,
|
|
84
|
+
}), children: _jsx("a", { className: "page-link", href: "#", "aria-label": "Last", tabIndex: rightArrowButtonsDisabled ? -1 : 0, onClick: (event) => {
|
|
78
85
|
event.preventDefault();
|
|
86
|
+
if (rightArrowButtonsDisabled) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
79
89
|
setPageNum(numPages);
|
|
80
90
|
}, children: _jsx("span", { "aria-hidden": "true", children: ">>" }) }) }));
|
|
81
91
|
}
|
|
@@ -86,6 +96,6 @@ const PageSelector = ({ numPages, numButtons, pageNum, setPageNum, ariaLabel, al
|
|
|
86
96
|
event.preventDefault();
|
|
87
97
|
setPageNum(buttonIndex);
|
|
88
98
|
}, children: buttonIndex }) }, buttonIndex)));
|
|
89
|
-
return (_jsx("nav", { "aria-label": ariaLabel, "data-testid": "rbdg-page-selector", children: _jsxs("ul", { className: classNames(ulClasses), children: [getFirstArrowButton(), getPrevArrowButton(), indexButtons, getNextArrowButton(), getLastArrowButton()] }) }));
|
|
99
|
+
return (_jsx("nav", { "aria-label": ariaLabel === undefined ? "Select page" : ariaLabel, "data-testid": "rbdg-page-selector", children: _jsxs("ul", { className: classNames(ulClasses), children: [getFirstArrowButton(), getPrevArrowButton(), indexButtons, getNextArrowButton(), getLastArrowButton()] }) }));
|
|
90
100
|
};
|
|
91
101
|
export default PageSelector;
|
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
2
3
|
import classNames from "classnames";
|
|
3
|
-
const
|
|
4
|
+
const labelText = "Rows per page";
|
|
5
|
+
const PageSizeSelector = ({ componentSize, pageSizeOptions, pageSizeIndex, handleSetPageSize, showTextLabel, }) => {
|
|
6
|
+
const id = useId();
|
|
4
7
|
const onChange = (event) => {
|
|
5
8
|
const pageSizeIndex = Number(event.target.value);
|
|
6
9
|
handleSetPageSize(pageSizeIndex);
|
|
7
10
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
11
|
+
function getTextSizeClass() {
|
|
12
|
+
switch (componentSize) {
|
|
13
|
+
case "small":
|
|
14
|
+
return "rbdg-input-label-sm";
|
|
15
|
+
case "large":
|
|
16
|
+
return "rbdg-input-label-lg";
|
|
17
|
+
default:
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return (_jsxs("div", { "data-testid": "rbdg-page-size-selector", className: "d-flex align-items-center gap-2 flex-shrink-0", children: [showTextLabel && (_jsx("label", { htmlFor: id, className: classNames("flex-shrink-0", getTextSizeClass()), children: labelText })), _jsx("select", { "aria-label": showTextLabel ? undefined : labelText, id: id, name: "rowsPerPage", className: classNames({
|
|
22
|
+
"form-select": true,
|
|
23
|
+
"form-select-lg": componentSize === "large",
|
|
24
|
+
"form-select-sm": componentSize === "small",
|
|
25
|
+
}, "flex-shrink-0", "w-auto"), value: pageSizeIndex, onChange: onChange, children: pageSizeOptions.map((numRows, index) => (_jsx("option", { value: index, children: numRows }, index))) })] }));
|
|
13
26
|
};
|
|
14
27
|
export default PageSizeSelector;
|
|
@@ -2,8 +2,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import PageSizeSelector from "./PageSizeSelector";
|
|
3
3
|
import PageSelector from "./PageSelector";
|
|
4
4
|
import classNames from "classnames";
|
|
5
|
-
const Pagination = ({ normalizedModel, prePagingNumRows, containerDivClasses, sizeSelectAfterPageSelect }) => {
|
|
6
|
-
const { pageSizeOptions, pageSizeIndex, currentPage, setCurrentPage, setPageSizeIndex, componentSize, maxPageButtons, pageSelectorAriaLabel, pageSelectorJustifyContent, } = normalizedModel;
|
|
5
|
+
const Pagination = ({ normalizedModel, prePagingNumRows, containerDivClasses, sizeSelectAfterPageSelect, }) => {
|
|
6
|
+
const { pageSizeOptions, pageSizeIndex, currentPage, setCurrentPage, setPageSizeIndex, componentSize, maxPageButtons, pageSelectorAriaLabel, pageSelectorJustifyContent, showTextLabel, } = normalizedModel;
|
|
7
7
|
const numPages = Math.ceil(prePagingNumRows / pageSizeOptions[pageSizeIndex]);
|
|
8
8
|
const pageIndexAwarePageSizeSetter = (newPageSizeIndex) => {
|
|
9
9
|
const newPageSize = pageSizeOptions[newPageSizeIndex];
|
|
@@ -16,7 +16,7 @@ const Pagination = ({ normalizedModel, prePagingNumRows, containerDivClasses, si
|
|
|
16
16
|
setCurrentPage(maxPages);
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
const pageSizeSelect = (_jsx(PageSizeSelector, { componentSize: componentSize, pageSizeOptions: pageSizeOptions, pageSizeIndex: pageSizeIndex, handleSetPageSize: pageIndexAwarePageSizeSetter }));
|
|
19
|
+
const pageSizeSelect = (_jsx(PageSizeSelector, { componentSize: componentSize, pageSizeOptions: pageSizeOptions, pageSizeIndex: pageSizeIndex, handleSetPageSize: pageIndexAwarePageSizeSetter, showTextLabel: !!showTextLabel }));
|
|
20
20
|
const pageSelect = (_jsx(PageSelector, { numPages: numPages, pageNum: currentPage, numButtons: maxPageButtons, setPageNum: setCurrentPage, size: componentSize, ariaLabel: pageSelectorAriaLabel, alignment: pageSelectorJustifyContent }));
|
|
21
21
|
return (_jsx("div", { "data-testid": "rdbg-pagination-ui-container", className: classNames(containerDivClasses || [
|
|
22
22
|
"d-flex",
|
|
@@ -5,4 +5,4 @@ import { ControlledPaginationModel } from "./types";
|
|
|
5
5
|
*
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
export type NormalizedPaginationModel = Required<Omit<ControlledPaginationModel, "type" | "pageSelectorAriaLabel" | "pageSelectorJustifyContent">> & Pick<ControlledPaginationModel, "pageSelectorAriaLabel" | "pageSelectorJustifyContent">;
|
|
8
|
+
export type NormalizedPaginationModel = Required<Omit<ControlledPaginationModel, "type" | "pageSelectorAriaLabel" | "pageSelectorJustifyContent" | "showTextLabel">> & Pick<ControlledPaginationModel, "pageSelectorAriaLabel" | "pageSelectorJustifyContent" | "showTextLabel">;
|
|
@@ -43,7 +43,7 @@ export interface PaginationOptions {
|
|
|
43
43
|
* The ARIA label for the nav element that represents the pagination
|
|
44
44
|
* component.
|
|
45
45
|
*
|
|
46
|
-
* @defaultValue `
|
|
46
|
+
* @defaultValue `"Select page"`
|
|
47
47
|
*/
|
|
48
48
|
pageSelectorAriaLabel?: string;
|
|
49
49
|
/**
|
|
@@ -53,8 +53,19 @@ export interface PaginationOptions {
|
|
|
53
53
|
* @defaultValue `undefined` - no justify-content property is specified, which
|
|
54
54
|
* acts like "start" based on CSS standards. See
|
|
55
55
|
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/justify-content#syntax}.
|
|
56
|
+
*
|
|
57
|
+
* @deprecated This property has no effect under normal circumstances because
|
|
58
|
+
* the enclosing nav element is using the block display type. It is kept
|
|
59
|
+
* around only to avoid breaking existing code.
|
|
56
60
|
*/
|
|
57
61
|
pageSelectorJustifyContent?: JustifyContentSetting;
|
|
62
|
+
/**
|
|
63
|
+
* Configures whether to show a text label for the page size selector
|
|
64
|
+
* dropdown.
|
|
65
|
+
*
|
|
66
|
+
* @defaultValue `undefined` - the text label is not displayed.
|
|
67
|
+
*/
|
|
68
|
+
showTextLabel?: boolean;
|
|
58
69
|
}
|
|
59
70
|
/**
|
|
60
71
|
* Properties specific to configuring pagination in a controlled manner.
|
|
@@ -36,6 +36,7 @@ const useCurrentPageRows = (sortedRows, paginationModel) => {
|
|
|
36
36
|
componentSize,
|
|
37
37
|
pageSelectorAriaLabel: paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.pageSelectorAriaLabel,
|
|
38
38
|
pageSelectorJustifyContent: paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.pageSelectorJustifyContent,
|
|
39
|
+
showTextLabel: paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.showTextLabel,
|
|
39
40
|
};
|
|
40
41
|
const pageSize = pageSizeOptions[pageSizeIndex];
|
|
41
42
|
const lowerIndex = pageSize * (currentPage - 1);
|
package/common.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.rbdg-input-label-lg{font-size:1.25rem}.rbdg-input-label-sm{font-size:.875rem}
|
package/common.scss
ADDED
package/grid/main/Grid.js
CHANGED
|
@@ -32,7 +32,7 @@ const Grid = ({ rows, cols, sortModel, pagination, width, height, variant, strip
|
|
|
32
32
|
if (typeof width === "number") {
|
|
33
33
|
return width;
|
|
34
34
|
}
|
|
35
|
-
return "
|
|
35
|
+
return "max-content";
|
|
36
36
|
}
|
|
37
37
|
const widthProperty = getWidthProperty(width);
|
|
38
38
|
function getHeightProperties(height) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absreim/react-bootstrap-data-grid-pro",
|
|
3
3
|
"description": "Pro Version of data grid UI component for use with web apps using React and Bootstrap",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.5.0",
|
|
5
5
|
"license": "Commercial. See LICENSE file.",
|
|
6
6
|
"author": "Brook Li",
|
|
7
7
|
"homepage": "https://react-bootstrap-data-grid.vercel.app/",
|