carbon-react 111.22.4 → 112.0.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/esm/components/batch-selection/batch-selection.component.d.ts +15 -0
- package/esm/components/batch-selection/batch-selection.component.js +7 -18
- package/esm/components/batch-selection/batch-selection.style.d.ts +4 -0
- package/esm/components/batch-selection/index.d.ts +2 -1
- package/esm/components/pager/__internal__/pager-navigation-link.component.d.ts +17 -0
- package/esm/components/pager/__internal__/pager-navigation-link.component.js +16 -25
- package/esm/components/pager/__internal__/pager-navigation.component.d.ts +28 -0
- package/esm/components/pager/__internal__/pager-navigation.component.js +22 -43
- package/esm/components/pager/index.d.ts +2 -2
- package/esm/components/pager/pager.component.d.ts +43 -0
- package/esm/components/pager/pager.component.js +33 -66
- package/esm/components/pager/pager.style.d.ts +12 -0
- package/esm/components/pager/pager.style.js +2 -2
- package/esm/components/select/__internal__/select-text/select-text.style.d.ts +2 -0
- package/esm/components/select/option/index.d.ts +5 -0
- package/esm/components/tabs/tabs.component.js +1 -5
- package/esm/locales/locale.d.ts +1 -1
- package/lib/components/batch-selection/batch-selection.component.d.ts +15 -0
- package/lib/components/batch-selection/batch-selection.component.js +8 -19
- package/lib/components/batch-selection/batch-selection.style.d.ts +4 -0
- package/lib/components/batch-selection/index.d.ts +2 -1
- package/lib/components/pager/__internal__/pager-navigation-link.component.d.ts +17 -0
- package/lib/components/pager/__internal__/pager-navigation-link.component.js +15 -24
- package/lib/components/pager/__internal__/pager-navigation.component.d.ts +28 -0
- package/lib/components/pager/__internal__/pager-navigation.component.js +22 -43
- package/lib/components/pager/index.d.ts +2 -2
- package/lib/components/pager/pager.component.d.ts +43 -0
- package/lib/components/pager/pager.component.js +34 -68
- package/lib/components/pager/pager.style.d.ts +12 -0
- package/lib/components/pager/pager.style.js +3 -3
- package/lib/components/select/__internal__/select-text/select-text.style.d.ts +2 -0
- package/lib/components/select/option/index.d.ts +5 -0
- package/lib/components/tabs/tabs.component.js +1 -5
- package/lib/locales/locale.d.ts +1 -1
- package/package.json +1 -1
- package/esm/components/batch-selection/batch-selection.d.ts +0 -18
- package/esm/components/pager/pager.d.ts +0 -42
- package/lib/components/batch-selection/batch-selection.d.ts +0 -18
- package/lib/components/pager/pager.d.ts +0 -42
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface BatchSelectionProps {
|
|
3
|
+
/** Content to be rendered after selected count */
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/** Color of the background, transparent if not defined */
|
|
6
|
+
colorTheme?: "dark" | "light" | "white" | "transparent";
|
|
7
|
+
/** If true disables all user interaction */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** Hidden if true */
|
|
10
|
+
hidden?: boolean;
|
|
11
|
+
/** Number of selected elements */
|
|
12
|
+
selectedCount: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const BatchSelection: ({ disabled, children, colorTheme, selectedCount, hidden, }: BatchSelectionProps) => JSX.Element;
|
|
15
|
+
export default BatchSelection;
|
|
@@ -6,7 +6,7 @@ import { StyledBatchSelection, StyledSelectionCount } from "./batch-selection.st
|
|
|
6
6
|
const BatchSelection = ({
|
|
7
7
|
disabled,
|
|
8
8
|
children,
|
|
9
|
-
colorTheme,
|
|
9
|
+
colorTheme = "transparent",
|
|
10
10
|
selectedCount,
|
|
11
11
|
hidden
|
|
12
12
|
}) => {
|
|
@@ -22,22 +22,11 @@ const BatchSelection = ({
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
BatchSelection.propTypes = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
selectedCount: PropTypes.number.isRequired
|
|
30
|
-
|
|
31
|
-
/** Color of the background, transparent if not defined */
|
|
32
|
-
colorTheme: PropTypes.oneOf(["dark", "light", "white", "transparent"]),
|
|
33
|
-
|
|
34
|
-
/** If true disables all user interaction */
|
|
35
|
-
disabled: PropTypes.bool,
|
|
36
|
-
|
|
37
|
-
/** Hidden if true */
|
|
38
|
-
hidden: PropTypes.bool
|
|
39
|
-
};
|
|
40
|
-
BatchSelection.defaultProps = {
|
|
41
|
-
colorTheme: "transparent"
|
|
25
|
+
"children": PropTypes.node,
|
|
26
|
+
"colorTheme": PropTypes.oneOf(["dark", "light", "transparent", "white"]),
|
|
27
|
+
"disabled": PropTypes.bool,
|
|
28
|
+
"hidden": PropTypes.bool,
|
|
29
|
+
"selectedCount": PropTypes.number.isRequired
|
|
42
30
|
};
|
|
31
|
+
export { BatchSelection };
|
|
43
32
|
export default BatchSelection;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BatchSelectionProps } from ".";
|
|
2
|
+
declare const StyledBatchSelection: import("styled-components").StyledComponent<"div", any, Pick<BatchSelectionProps, "disabled" | "hidden" | "colorTheme">, never>;
|
|
3
|
+
declare const StyledSelectionCount: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
4
|
+
export { StyledBatchSelection, StyledSelectionCount };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./batch-selection";
|
|
1
|
+
export { default } from "./batch-selection.component";
|
|
2
|
+
export type { BatchSelectionProps } from "./batch-selection.component";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface PagerNavigationLinkProps {
|
|
3
|
+
/** Type of Pagination link to be allowed for navigation */
|
|
4
|
+
type: "next" | "previous" | "first" | "last";
|
|
5
|
+
/** Current visible page */
|
|
6
|
+
currentPage: number;
|
|
7
|
+
/** Count of all the pages */
|
|
8
|
+
pageCount: number;
|
|
9
|
+
/** Pagination page size */
|
|
10
|
+
pageSize: number;
|
|
11
|
+
/** onClick Callback function */
|
|
12
|
+
onClick?: (ev: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
13
|
+
/** onPagination Callback to process pagination */
|
|
14
|
+
onPagination?: (pageSize: number, currentPage: number, origin: string) => void;
|
|
15
|
+
}
|
|
16
|
+
declare const PagerNavigationLink: ({ type, currentPage, pageCount, pageSize, onClick, onPagination, }: PagerNavigationLinkProps) => JSX.Element;
|
|
17
|
+
export default PagerNavigationLink;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useRef, useEffect, useCallback } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
|
-
import {
|
|
3
|
+
import { StyledPagerLink } from "../pager.style";
|
|
4
4
|
import useLocale from "../../../hooks/__internal__/useLocale";
|
|
5
5
|
|
|
6
6
|
const PagerNavigationLink = ({
|
|
@@ -12,11 +12,11 @@ const PagerNavigationLink = ({
|
|
|
12
12
|
onPagination
|
|
13
13
|
}) => {
|
|
14
14
|
const l = useLocale();
|
|
15
|
-
const linkRef = useRef();
|
|
15
|
+
const linkRef = useRef(null);
|
|
16
16
|
const navLinkConfig = {
|
|
17
17
|
first: {
|
|
18
18
|
text: l.pager.first(),
|
|
19
|
-
destination:
|
|
19
|
+
destination: 1
|
|
20
20
|
},
|
|
21
21
|
last: {
|
|
22
22
|
text: l.pager.last(),
|
|
@@ -48,39 +48,30 @@ const PagerNavigationLink = ({
|
|
|
48
48
|
}
|
|
49
49
|
}, [disabled]);
|
|
50
50
|
|
|
51
|
-
const handleOnCLick =
|
|
52
|
-
onClick(
|
|
53
|
-
onPagination(navLinkConfig[type].destination, pageSize, type);
|
|
51
|
+
const handleOnCLick = ev => {
|
|
52
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(ev);
|
|
53
|
+
onPagination === null || onPagination === void 0 ? void 0 : onPagination(navLinkConfig[type].destination, pageSize, type);
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
const {
|
|
57
57
|
text
|
|
58
58
|
} = navLinkConfig[type];
|
|
59
|
-
return /*#__PURE__*/React.createElement(
|
|
59
|
+
return /*#__PURE__*/React.createElement(StyledPagerLink, {
|
|
60
60
|
"data-element": `pager-link-${type}`,
|
|
61
61
|
disabled: disabled(),
|
|
62
|
-
onClick:
|
|
62
|
+
onClick: // Type assertion due to the fact that StyledPagerLink
|
|
63
|
+
// will always return a button element
|
|
64
|
+
handleOnCLick,
|
|
63
65
|
ref: linkRef
|
|
64
66
|
}, text);
|
|
65
67
|
};
|
|
66
68
|
|
|
67
69
|
PagerNavigationLink.propTypes = {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
/** Count of all the pages */
|
|
75
|
-
pageCount: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
76
|
-
|
|
77
|
-
/** Pagination page size */
|
|
78
|
-
pageSize: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
79
|
-
|
|
80
|
-
/** onClick Callback function */
|
|
81
|
-
onClick: PropTypes.func,
|
|
82
|
-
|
|
83
|
-
/** onPagination Callback to process pagination */
|
|
84
|
-
onPagination: PropTypes.func
|
|
70
|
+
"currentPage": PropTypes.number.isRequired,
|
|
71
|
+
"onClick": PropTypes.func,
|
|
72
|
+
"onPagination": PropTypes.func,
|
|
73
|
+
"pageCount": PropTypes.number.isRequired,
|
|
74
|
+
"pageSize": PropTypes.number.isRequired,
|
|
75
|
+
"type": PropTypes.oneOf(["first", "last", "next", "previous"]).isRequired
|
|
85
76
|
};
|
|
86
77
|
export default PagerNavigationLink;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface PagerNavigationProps {
|
|
3
|
+
/** Current visible page */
|
|
4
|
+
currentPage: number;
|
|
5
|
+
/** Pagination page size */
|
|
6
|
+
pageSize: number;
|
|
7
|
+
pageCount: number;
|
|
8
|
+
/** Sets the current page being shown */
|
|
9
|
+
setCurrentPage: (page: number) => void;
|
|
10
|
+
/** Callback function for next link */
|
|
11
|
+
onNext?: (ev: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
12
|
+
/** Callback function for first link */
|
|
13
|
+
onFirst?: (ev: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
14
|
+
/** Callback function for previous link */
|
|
15
|
+
onPrevious?: (ev: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
16
|
+
/** Callback function for last link */
|
|
17
|
+
onLast?: (ev: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
18
|
+
/** onPagination Callback triggered when a change is triggered */
|
|
19
|
+
onPagination: (pageSize: number, currentPage: number, origin: string) => void;
|
|
20
|
+
/** Should the `First` and `Last` navigation buttons be shown */
|
|
21
|
+
showFirstAndLastButtons?: boolean;
|
|
22
|
+
/** Should the `Next` and `Previous` navigation buttons be shown */
|
|
23
|
+
showPreviousAndNextButtons?: boolean;
|
|
24
|
+
/** Should the page count input be shown */
|
|
25
|
+
showPageCount?: boolean;
|
|
26
|
+
}
|
|
27
|
+
declare const PagerNavigation: ({ pageSize, currentPage, setCurrentPage, onNext, onPrevious, onFirst, onLast, onPagination, pageCount, showFirstAndLastButtons, showPreviousAndNextButtons, showPageCount, }: PagerNavigationProps) => JSX.Element;
|
|
28
|
+
export default PagerNavigation;
|
|
@@ -36,31 +36,33 @@ const PagerNavigation = ({
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
const handlePageInputChange = ev => {
|
|
39
|
+
const pageNumber = +ev.target.value;
|
|
40
|
+
|
|
39
41
|
if (pageCount === 0) {
|
|
40
42
|
setCurrentPage(0);
|
|
41
43
|
onPagination(0, pageSize, "input");
|
|
42
|
-
return
|
|
44
|
+
return 0;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
if (
|
|
47
|
+
if (pageNumber <= 0 || Number.isNaN(pageNumber)) {
|
|
46
48
|
setCurrentPage(1);
|
|
47
49
|
onPagination(1, pageSize, "input");
|
|
48
|
-
return
|
|
50
|
+
return 1;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
if (
|
|
53
|
+
if (pageNumber > pageCount) {
|
|
52
54
|
setCurrentPage(pageCount);
|
|
53
55
|
onPagination(pageCount, pageSize, "input");
|
|
54
56
|
return pageCount;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
setCurrentPage(
|
|
58
|
-
onPagination(
|
|
59
|
-
return
|
|
59
|
+
setCurrentPage(pageNumber);
|
|
60
|
+
onPagination(pageNumber, pageSize, "input");
|
|
61
|
+
return pageNumber;
|
|
60
62
|
};
|
|
61
63
|
|
|
62
64
|
const handleCurrentPageChange = e => {
|
|
63
|
-
setCurrentPage(e.target.value);
|
|
65
|
+
setCurrentPage(+e.target.value);
|
|
64
66
|
};
|
|
65
67
|
|
|
66
68
|
const renderButtonsBeforeCount = () => /*#__PURE__*/React.createElement(React.Fragment, null, !hasTwoPages && showFirstAndLastButtons && /*#__PURE__*/React.createElement(PagerNavigationLink, _extends({
|
|
@@ -92,40 +94,17 @@ const PagerNavigation = ({
|
|
|
92
94
|
};
|
|
93
95
|
|
|
94
96
|
PagerNavigation.propTypes = {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
/** onFirst Callback triggered when first link is triggered */
|
|
108
|
-
onFirst: PropTypes.func,
|
|
109
|
-
|
|
110
|
-
/** onPrevious Callback triggered when previous link is triggered */
|
|
111
|
-
onPrevious: PropTypes.func,
|
|
112
|
-
|
|
113
|
-
/** onNext Callback triggered when next link is triggered */
|
|
114
|
-
onNext: PropTypes.func,
|
|
115
|
-
|
|
116
|
-
/** onLast Callback triggered when last link is triggered */
|
|
117
|
-
onLast: PropTypes.func,
|
|
118
|
-
|
|
119
|
-
/** onPagination Callback triggered when a change is triggered */
|
|
120
|
-
onPagination: PropTypes.func,
|
|
121
|
-
|
|
122
|
-
/** Should the `First` and `Last` navigation buttons be shown */
|
|
123
|
-
showFirstAndLastButtons: PropTypes.bool,
|
|
124
|
-
|
|
125
|
-
/** Should the `Next` and `Previous` navigation buttons be shown */
|
|
126
|
-
showPreviousAndNextButtons: PropTypes.bool,
|
|
127
|
-
|
|
128
|
-
/** Should the page count input be shown */
|
|
129
|
-
showPageCount: PropTypes.bool
|
|
97
|
+
"currentPage": PropTypes.number.isRequired,
|
|
98
|
+
"onFirst": PropTypes.func,
|
|
99
|
+
"onLast": PropTypes.func,
|
|
100
|
+
"onNext": PropTypes.func,
|
|
101
|
+
"onPagination": PropTypes.func.isRequired,
|
|
102
|
+
"onPrevious": PropTypes.func,
|
|
103
|
+
"pageCount": PropTypes.number.isRequired,
|
|
104
|
+
"pageSize": PropTypes.number.isRequired,
|
|
105
|
+
"setCurrentPage": PropTypes.func.isRequired,
|
|
106
|
+
"showFirstAndLastButtons": PropTypes.bool,
|
|
107
|
+
"showPageCount": PropTypes.bool,
|
|
108
|
+
"showPreviousAndNextButtons": PropTypes.bool
|
|
130
109
|
};
|
|
131
110
|
export default PagerNavigation;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "./pager";
|
|
2
|
-
export
|
|
1
|
+
export { default } from "./pager.component";
|
|
2
|
+
export type { PagerProps } from "./pager.component";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare type PageSizeOption = {
|
|
3
|
+
id: string;
|
|
4
|
+
name: number;
|
|
5
|
+
};
|
|
6
|
+
export interface PagerProps {
|
|
7
|
+
/** Function called when pager changes (PageSize, Current Page) */
|
|
8
|
+
onPagination: (pageSize: number, currentPage: number, origin: string) => void;
|
|
9
|
+
/** Callback function for next link */
|
|
10
|
+
onNext?: (ev: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
11
|
+
/** Callback function for first link */
|
|
12
|
+
onFirst?: (ev: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
13
|
+
/** Callback function for previous link */
|
|
14
|
+
onPrevious?: (ev: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
15
|
+
/** Callback function for last link */
|
|
16
|
+
onLast?: (ev: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
17
|
+
/** Current visible page */
|
|
18
|
+
currentPage?: number | string;
|
|
19
|
+
/** Total number of records */
|
|
20
|
+
totalRecords?: number | string;
|
|
21
|
+
/** Pagination page size */
|
|
22
|
+
pageSize?: number | string;
|
|
23
|
+
/** Should the page size selection dropdown be shown */
|
|
24
|
+
showPageSizeSelection?: boolean;
|
|
25
|
+
/** Set of page size options */
|
|
26
|
+
pageSizeSelectionOptions?: PageSizeOption[];
|
|
27
|
+
/** Should the label before the page size selection dropdown be shown */
|
|
28
|
+
showPageSizeLabelBefore?: boolean;
|
|
29
|
+
/** Should the label after the page size selection dropdown be shown */
|
|
30
|
+
showPageSizeLabelAfter?: boolean;
|
|
31
|
+
/** Should the total records label be shown */
|
|
32
|
+
showTotalRecords?: boolean;
|
|
33
|
+
/** Should the `First` and `Last` navigation button be shown */
|
|
34
|
+
showFirstAndLastButtons?: boolean;
|
|
35
|
+
/** Should the `Previous` and `Next` navigation button be shown */
|
|
36
|
+
showPreviousAndNextButtons?: boolean;
|
|
37
|
+
/** Should the page count input be shown */
|
|
38
|
+
showPageCount?: boolean;
|
|
39
|
+
/** What variant the Pager background should be */
|
|
40
|
+
variant?: "default" | "alternate";
|
|
41
|
+
}
|
|
42
|
+
export declare const Pager: ({ currentPage, pageSizeSelectionOptions, pageSize, showPageSizeSelection, totalRecords, onPagination, onNext, onFirst, onPrevious, onLast, showPageSizeLabelBefore, showPageSizeLabelAfter, showTotalRecords, showFirstAndLastButtons, showPreviousAndNextButtons, showPageCount, variant, ...rest }: PagerProps) => JSX.Element;
|
|
43
|
+
export default Pager;
|
|
@@ -2,9 +2,8 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
2
2
|
|
|
3
3
|
import React, { useState, useCallback, useEffect, useRef } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
-
import { Select } from "../select";
|
|
5
|
+
import { Select, Option } from "../select";
|
|
6
6
|
import PagerNavigation from "./__internal__/pager-navigation.component";
|
|
7
|
-
import Option from "../select/option/option.component";
|
|
8
7
|
import useLocale from "../../hooks/__internal__/useLocale";
|
|
9
8
|
import createGuid from "../../__internal__/utils/helpers/guid";
|
|
10
9
|
import { StyledPagerContainer, StyledPagerSizeOptions, StyledPagerSummary, StyledPagerSizeOptionsInner, StyledSelectContainer } from "./pager.style";
|
|
@@ -43,31 +42,31 @@ const Pager = ({
|
|
|
43
42
|
...rest
|
|
44
43
|
}) => {
|
|
45
44
|
const l = useLocale();
|
|
46
|
-
const [page, setPage] = useState(currentPage);
|
|
47
|
-
const [currentPageSize, setCurrentPageSize] = useState(pageSize);
|
|
48
|
-
const [value, setValue] = useState(pageSize);
|
|
45
|
+
const [page, setPage] = useState(+currentPage);
|
|
46
|
+
const [currentPageSize, setCurrentPageSize] = useState(+pageSize);
|
|
47
|
+
const [value, setValue] = useState(+pageSize);
|
|
49
48
|
const guid = useRef(createGuid());
|
|
50
49
|
const pageSizeSelectId = `Pager_size_selector_${guid.current}`;
|
|
51
50
|
const getPageCount = useCallback(() => {
|
|
52
|
-
if (
|
|
51
|
+
if (+totalRecords < 0 || Number.isNaN(+totalRecords)) {
|
|
53
52
|
return 1;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
return Math.ceil(totalRecords / currentPageSize);
|
|
55
|
+
return Math.ceil(+totalRecords / currentPageSize);
|
|
57
56
|
}, [totalRecords, currentPageSize]);
|
|
58
57
|
const [pageCount, setPageCount] = useState(getPageCount());
|
|
59
58
|
useEffect(() => {
|
|
60
|
-
setCurrentPageSize(
|
|
61
|
-
setValue(pageSize);
|
|
59
|
+
setCurrentPageSize(+pageSize);
|
|
60
|
+
setValue(+pageSize);
|
|
62
61
|
}, [pageSize]);
|
|
63
62
|
useEffect(() => {
|
|
64
63
|
const maxPage = getPageCount();
|
|
65
64
|
setPageCount(maxPage);
|
|
66
65
|
|
|
67
|
-
if (
|
|
66
|
+
if (+currentPage > maxPage) {
|
|
68
67
|
setPage(maxPage);
|
|
69
68
|
} else {
|
|
70
|
-
setPage(
|
|
69
|
+
setPage(+currentPage);
|
|
71
70
|
}
|
|
72
71
|
}, [currentPageSize, pageCount, currentPage, totalRecords, getPageCount]);
|
|
73
72
|
const handleOnFirst = useCallback(e => {
|
|
@@ -102,15 +101,15 @@ const Pager = ({
|
|
|
102
101
|
}, [page, onPrevious]);
|
|
103
102
|
const handleOnPagination = useCallback(e => {
|
|
104
103
|
setValue(e.target.value);
|
|
105
|
-
setCurrentPageSize(
|
|
106
|
-
onPagination(1,
|
|
104
|
+
setCurrentPageSize(+e.target.value);
|
|
105
|
+
onPagination(1, +e.target.value, "page-select");
|
|
107
106
|
}, [onPagination]);
|
|
108
107
|
const handleKeyDown = useCallback(e => Events.isEnterKey(e) && handleOnPagination(e), [handleOnPagination]);
|
|
109
108
|
|
|
110
109
|
const sizeSelector = () => {
|
|
111
110
|
return /*#__PURE__*/React.createElement(StyledSelectContainer, null, /*#__PURE__*/React.createElement(Select, {
|
|
112
111
|
value: String(value),
|
|
113
|
-
onChange: ev => setValue(ev.target.value),
|
|
112
|
+
onChange: ev => setValue(+ev.target.value),
|
|
114
113
|
onBlur: () => setValue(currentPageSize),
|
|
115
114
|
onKeyDown: handleKeyDown,
|
|
116
115
|
"data-element": "page-select",
|
|
@@ -151,58 +150,26 @@ const Pager = ({
|
|
|
151
150
|
};
|
|
152
151
|
|
|
153
152
|
Pager.propTypes = {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
onPrevious: PropTypes.func,
|
|
165
|
-
|
|
166
|
-
/** Callback function for last link */
|
|
167
|
-
onLast: PropTypes.func,
|
|
168
|
-
|
|
169
|
-
/** Current visible page */
|
|
170
|
-
currentPage: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
171
|
-
|
|
172
|
-
/** Total number of records */
|
|
173
|
-
totalRecords: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
174
|
-
|
|
175
|
-
/** Pagination page size */
|
|
176
|
-
pageSize: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
177
|
-
|
|
178
|
-
/** Set of page size options */
|
|
179
|
-
pageSizeSelectionOptions: PropTypes.arrayOf(PropTypes.shape({
|
|
180
|
-
id: PropTypes.string,
|
|
181
|
-
name: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
153
|
+
"currentPage": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
154
|
+
"onFirst": PropTypes.func,
|
|
155
|
+
"onLast": PropTypes.func,
|
|
156
|
+
"onNext": PropTypes.func,
|
|
157
|
+
"onPagination": PropTypes.func.isRequired,
|
|
158
|
+
"onPrevious": PropTypes.func,
|
|
159
|
+
"pageSize": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
160
|
+
"pageSizeSelectionOptions": PropTypes.arrayOf(PropTypes.shape({
|
|
161
|
+
"id": PropTypes.string.isRequired,
|
|
162
|
+
"name": PropTypes.number.isRequired
|
|
182
163
|
})),
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
/** Should the total records label be shown */
|
|
194
|
-
showTotalRecords: PropTypes.bool,
|
|
195
|
-
|
|
196
|
-
/** Should the `First` and `Last` navigation button be shown */
|
|
197
|
-
showFirstAndLastButtons: PropTypes.bool,
|
|
198
|
-
|
|
199
|
-
/** Should the `Previous` and `Next` navigation button be shown */
|
|
200
|
-
showPreviousAndNextButtons: PropTypes.bool,
|
|
201
|
-
|
|
202
|
-
/** Should the page count input be shown */
|
|
203
|
-
showPageCount: PropTypes.bool,
|
|
204
|
-
|
|
205
|
-
/** What variant the Pager background should be */
|
|
206
|
-
variant: PropTypes.oneOf(["default", "alternate"])
|
|
164
|
+
"showFirstAndLastButtons": PropTypes.bool,
|
|
165
|
+
"showPageCount": PropTypes.bool,
|
|
166
|
+
"showPageSizeLabelAfter": PropTypes.bool,
|
|
167
|
+
"showPageSizeLabelBefore": PropTypes.bool,
|
|
168
|
+
"showPageSizeSelection": PropTypes.bool,
|
|
169
|
+
"showPreviousAndNextButtons": PropTypes.bool,
|
|
170
|
+
"showTotalRecords": PropTypes.bool,
|
|
171
|
+
"totalRecords": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
172
|
+
"variant": PropTypes.oneOf(["alternate", "default"])
|
|
207
173
|
};
|
|
174
|
+
export { Pager };
|
|
208
175
|
export default Pager;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PagerProps } from ".";
|
|
3
|
+
declare const StyledSelectContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
declare const StyledPagerContainer: import("styled-components").StyledComponent<"div", any, Pick<PagerProps, "variant">, never>;
|
|
5
|
+
declare const StyledPagerSizeOptions: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
+
declare const StyledPagerSizeOptionsInner: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
+
declare const StyledPagerNavigation: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
+
declare const StyledPagerNavInner: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
declare const StyledPagerLink: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../link").LinkProps & import("react").RefAttributes<HTMLButtonElement | HTMLLinkElement>>, any, {}, never>;
|
|
10
|
+
declare const StyledPagerNoSelect: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
|
+
declare const StyledPagerSummary: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
|
+
export { StyledPagerContainer, StyledPagerSizeOptions, StyledPagerSizeOptionsInner, StyledPagerNavigation, StyledPagerNavInner, StyledPagerLink, StyledPagerNoSelect, StyledPagerSummary, StyledSelectContainer, };
|
|
@@ -95,7 +95,7 @@ const StyledPagerNavInner = styled.div`
|
|
|
95
95
|
margin-bottom: 0;
|
|
96
96
|
}
|
|
97
97
|
`;
|
|
98
|
-
const
|
|
98
|
+
const StyledPagerLink = styled(Link)`
|
|
99
99
|
padding: 0 10px;
|
|
100
100
|
margin-left: 7px;
|
|
101
101
|
margin-right: 7px;
|
|
@@ -110,4 +110,4 @@ const StyledPagerSummary = styled.div`
|
|
|
110
110
|
flex: 1 1 30%;
|
|
111
111
|
justify-content: flex-end;
|
|
112
112
|
`;
|
|
113
|
-
export { StyledPagerContainer, StyledPagerSizeOptions, StyledPagerSizeOptionsInner, StyledPagerNavigation, StyledPagerNavInner,
|
|
113
|
+
export { StyledPagerContainer, StyledPagerSizeOptions, StyledPagerSizeOptionsInner, StyledPagerNavigation, StyledPagerNavInner, StyledPagerLink, StyledPagerNoSelect, StyledPagerSummary, StyledSelectContainer };
|
|
@@ -11,6 +11,11 @@ export interface OptionProps {
|
|
|
11
11
|
borderColor?: string;
|
|
12
12
|
/** MultiSelect only - fill Pill background with color */
|
|
13
13
|
fill?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* @private
|
|
16
|
+
* @ignore
|
|
17
|
+
* OnClick callback */
|
|
18
|
+
onClick?: (ev: React.MouseEvent<HTMLLIElement>) => void;
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
declare function Option(
|
|
@@ -104,12 +104,8 @@ const Tabs = ({
|
|
|
104
104
|
previousSelectedTabId.current = selectedTabId;
|
|
105
105
|
}
|
|
106
106
|
}, [blurPreviousSelectedTab, previousSelectedTabId, selectedTabId, selectedTabIdState]);
|
|
107
|
-
/** Determines if the tab titles are in a vertical format. */
|
|
108
|
-
|
|
109
|
-
const isVertical = currentPosition => currentPosition === "left";
|
|
110
107
|
/** Handles the changing of tabs with the mouse */
|
|
111
108
|
|
|
112
|
-
|
|
113
109
|
const handleTabClick = ev => {
|
|
114
110
|
if (Event.isEventType(ev, "keydown")) {
|
|
115
111
|
return;
|
|
@@ -147,7 +143,7 @@ const Tabs = ({
|
|
|
147
143
|
|
|
148
144
|
const handleKeyDown = index => {
|
|
149
145
|
return event => {
|
|
150
|
-
const isTabVertical =
|
|
146
|
+
const isTabVertical = isInSidebar || position === "left";
|
|
151
147
|
const isUp = isTabVertical && Event.isUpKey(event);
|
|
152
148
|
const isDown = isTabVertical && Event.isDownKey(event);
|
|
153
149
|
const isLeft = !isTabVertical && Event.isLeftKey(event);
|
package/esm/locales/locale.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ interface Locale {
|
|
|
48
48
|
};
|
|
49
49
|
pager: {
|
|
50
50
|
show: () => string;
|
|
51
|
-
records: (count: number | string, showNumber
|
|
51
|
+
records: (count: number | string, showNumber?: boolean) => string;
|
|
52
52
|
first: () => string;
|
|
53
53
|
last: () => string;
|
|
54
54
|
next: () => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface BatchSelectionProps {
|
|
3
|
+
/** Content to be rendered after selected count */
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/** Color of the background, transparent if not defined */
|
|
6
|
+
colorTheme?: "dark" | "light" | "white" | "transparent";
|
|
7
|
+
/** If true disables all user interaction */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** Hidden if true */
|
|
10
|
+
hidden?: boolean;
|
|
11
|
+
/** Number of selected elements */
|
|
12
|
+
selectedCount: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const BatchSelection: ({ disabled, children, colorTheme, selectedCount, hidden, }: BatchSelectionProps) => JSX.Element;
|
|
15
|
+
export default BatchSelection;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.BatchSelection = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -18,7 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
18
|
const BatchSelection = ({
|
|
19
19
|
disabled,
|
|
20
20
|
children,
|
|
21
|
-
colorTheme,
|
|
21
|
+
colorTheme = "transparent",
|
|
22
22
|
selectedCount,
|
|
23
23
|
hidden
|
|
24
24
|
}) => {
|
|
@@ -33,24 +33,13 @@ const BatchSelection = ({
|
|
|
33
33
|
}, l.batchSelection.selected(selectedCount)), children);
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
exports.BatchSelection = BatchSelection;
|
|
36
37
|
BatchSelection.propTypes = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
selectedCount: _propTypes.default.number.isRequired
|
|
42
|
-
|
|
43
|
-
/** Color of the background, transparent if not defined */
|
|
44
|
-
colorTheme: _propTypes.default.oneOf(["dark", "light", "white", "transparent"]),
|
|
45
|
-
|
|
46
|
-
/** If true disables all user interaction */
|
|
47
|
-
disabled: _propTypes.default.bool,
|
|
48
|
-
|
|
49
|
-
/** Hidden if true */
|
|
50
|
-
hidden: _propTypes.default.bool
|
|
51
|
-
};
|
|
52
|
-
BatchSelection.defaultProps = {
|
|
53
|
-
colorTheme: "transparent"
|
|
38
|
+
"children": _propTypes.default.node,
|
|
39
|
+
"colorTheme": _propTypes.default.oneOf(["dark", "light", "transparent", "white"]),
|
|
40
|
+
"disabled": _propTypes.default.bool,
|
|
41
|
+
"hidden": _propTypes.default.bool,
|
|
42
|
+
"selectedCount": _propTypes.default.number.isRequired
|
|
54
43
|
};
|
|
55
44
|
var _default = BatchSelection;
|
|
56
45
|
exports.default = _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BatchSelectionProps } from ".";
|
|
2
|
+
declare const StyledBatchSelection: import("styled-components").StyledComponent<"div", any, Pick<BatchSelectionProps, "disabled" | "hidden" | "colorTheme">, never>;
|
|
3
|
+
declare const StyledSelectionCount: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
4
|
+
export { StyledBatchSelection, StyledSelectionCount };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./batch-selection";
|
|
1
|
+
export { default } from "./batch-selection.component";
|
|
2
|
+
export type { BatchSelectionProps } from "./batch-selection.component";
|