carbon-react 146.4.1 → 146.4.3
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/select/__internal__/select-list/select-list.component.js +20 -1
- package/esm/components/select/__internal__/select-list/select-list.style.d.ts +5 -2
- package/esm/components/select/__internal__/select-list/select-list.style.js +3 -1
- package/esm/components/tabs/__internal__/tabs-header/tabs-header.component.js +2 -0
- package/lib/components/select/__internal__/select-list/select-list.component.js +20 -1
- package/lib/components/select/__internal__/select-list/select-list.style.d.ts +5 -2
- package/lib/components/select/__internal__/select-list/select-list.style.js +3 -1
- package/lib/components/tabs/__internal__/tabs-header/tabs-header.component.js +2 -0
- package/package.json +1 -1
|
@@ -49,9 +49,11 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
49
49
|
}, listContainerRef) => {
|
|
50
50
|
const [currentOptionsListIndex, setCurrentOptionsListIndex] = useState(-1);
|
|
51
51
|
const [scrollbarWidth, setScrollbarWidth] = useState(0);
|
|
52
|
+
const [actualPlacement, setActualPlacement] = useState(listPlacement);
|
|
52
53
|
const lastFilter = useRef("");
|
|
53
54
|
const listRef = useRef(null);
|
|
54
55
|
const tableRef = useRef(null);
|
|
56
|
+
const listWrapperRef = useRef(null);
|
|
55
57
|
const listActionButtonRef = useRef(null);
|
|
56
58
|
const {
|
|
57
59
|
blockScroll,
|
|
@@ -386,6 +388,21 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
386
388
|
}), ...(flipEnabled ? [flip({
|
|
387
389
|
fallbackStrategy: "initialPlacement"
|
|
388
390
|
})] : /* istanbul ignore next: covered by Playwright tests for reliable positioning in a real browser */[])], [listWidth, flipEnabled]);
|
|
391
|
+
|
|
392
|
+
// set the placement of the list based on the floating placement
|
|
393
|
+
const setPlacement = useCallback(() => {
|
|
394
|
+
if (isOpen) {
|
|
395
|
+
const floatingPlacement = listWrapperRef.current?.getAttribute("data-floating-placement");
|
|
396
|
+
setActualPlacement(floatingPlacement);
|
|
397
|
+
}
|
|
398
|
+
}, [isOpen]);
|
|
399
|
+
useEffect(() => {
|
|
400
|
+
setPlacement();
|
|
401
|
+
window.addEventListener("resize", setPlacement);
|
|
402
|
+
return () => {
|
|
403
|
+
window.removeEventListener("resize", setPlacement);
|
|
404
|
+
};
|
|
405
|
+
}, [setPlacement]);
|
|
389
406
|
const loader = isLoading ? /*#__PURE__*/React.createElement(StyledSelectLoaderContainer, {
|
|
390
407
|
key: "loader"
|
|
391
408
|
}, /*#__PURE__*/React.createElement(Loader, null)) : undefined;
|
|
@@ -424,9 +441,11 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
424
441
|
disableBackgroundUI: true,
|
|
425
442
|
animationFrame: true
|
|
426
443
|
}, /*#__PURE__*/React.createElement(StyledSelectListContainer, _extends({
|
|
444
|
+
ref: listWrapperRef,
|
|
427
445
|
"data-element": "select-list-wrapper",
|
|
428
446
|
"data-role": "select-list-wrapper",
|
|
429
|
-
isLoading: isLoading
|
|
447
|
+
isLoading: isLoading,
|
|
448
|
+
placement: actualPlacement
|
|
430
449
|
}, listProps), /*#__PURE__*/React.createElement(StyledScrollableContainer, {
|
|
431
450
|
ref: listContainerRef,
|
|
432
451
|
maxHeight: listMaxHeight,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SelectListProps } from ".";
|
|
2
1
|
interface StyledSelectListProps {
|
|
3
2
|
listHeight?: number;
|
|
4
3
|
}
|
|
@@ -10,7 +9,11 @@ interface StyledSelectListTableHeaderProps {
|
|
|
10
9
|
}
|
|
11
10
|
declare const StyledSelectListTableHeader: import("styled-components").StyledComponent<"thead", any, StyledSelectListTableHeaderProps, never>;
|
|
12
11
|
declare const StyledSelectListTableBody: import("styled-components").StyledComponent<"tbody", any, StyledSelectListProps, never>;
|
|
13
|
-
|
|
12
|
+
interface StyledSelectListContainerProps {
|
|
13
|
+
isLoading?: boolean;
|
|
14
|
+
placement?: string;
|
|
15
|
+
}
|
|
16
|
+
declare const StyledSelectListContainer: import("styled-components").StyledComponent<"div", any, StyledSelectListContainerProps, never>;
|
|
14
17
|
declare const StyledScrollableContainer: import("styled-components").StyledComponent<"div", any, {
|
|
15
18
|
maxHeight: number;
|
|
16
19
|
hasActionButton: boolean;
|
|
@@ -94,7 +94,9 @@ const StyledSelectListTableBody = styled.tbody`
|
|
|
94
94
|
`;
|
|
95
95
|
const StyledSelectListContainer = styled.div`
|
|
96
96
|
background-color: white;
|
|
97
|
-
box-shadow:
|
|
97
|
+
box-shadow: ${({
|
|
98
|
+
placement
|
|
99
|
+
}) => placement?.includes("top") ? "0 -5px 5px 0 #00141e33, 0 -10px 10px 0 #00141e1a" : "var(--boxShadow100)"};
|
|
98
100
|
animation: fadeIn 250ms ease-out;
|
|
99
101
|
position: absolute;
|
|
100
102
|
z-index: ${({
|
|
@@ -81,6 +81,7 @@ const TabsHeader = ({
|
|
|
81
81
|
title: "Scroll Tabs Left",
|
|
82
82
|
id: "tab-navigation-button-left",
|
|
83
83
|
"data-role": "tab-navigation-button-left",
|
|
84
|
+
type: "button",
|
|
84
85
|
onClick: () => {
|
|
85
86
|
/* istanbul ignore if */
|
|
86
87
|
if (current) {
|
|
@@ -107,6 +108,7 @@ const TabsHeader = ({
|
|
|
107
108
|
title: "Scroll Tabs Right",
|
|
108
109
|
id: "tab-navigation-button-right",
|
|
109
110
|
"data-role": "tab-navigation-button-right",
|
|
111
|
+
type: "button",
|
|
110
112
|
onClick: () => {
|
|
111
113
|
/* istanbul ignore if */
|
|
112
114
|
if (current) {
|
|
@@ -58,9 +58,11 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
58
58
|
}, listContainerRef) => {
|
|
59
59
|
const [currentOptionsListIndex, setCurrentOptionsListIndex] = (0, _react.useState)(-1);
|
|
60
60
|
const [scrollbarWidth, setScrollbarWidth] = (0, _react.useState)(0);
|
|
61
|
+
const [actualPlacement, setActualPlacement] = (0, _react.useState)(listPlacement);
|
|
61
62
|
const lastFilter = (0, _react.useRef)("");
|
|
62
63
|
const listRef = (0, _react.useRef)(null);
|
|
63
64
|
const tableRef = (0, _react.useRef)(null);
|
|
65
|
+
const listWrapperRef = (0, _react.useRef)(null);
|
|
64
66
|
const listActionButtonRef = (0, _react.useRef)(null);
|
|
65
67
|
const {
|
|
66
68
|
blockScroll,
|
|
@@ -395,6 +397,21 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
395
397
|
}), ...(flipEnabled ? [(0, _dom.flip)({
|
|
396
398
|
fallbackStrategy: "initialPlacement"
|
|
397
399
|
})] : /* istanbul ignore next: covered by Playwright tests for reliable positioning in a real browser */[])], [listWidth, flipEnabled]);
|
|
400
|
+
|
|
401
|
+
// set the placement of the list based on the floating placement
|
|
402
|
+
const setPlacement = (0, _react.useCallback)(() => {
|
|
403
|
+
if (isOpen) {
|
|
404
|
+
const floatingPlacement = listWrapperRef.current?.getAttribute("data-floating-placement");
|
|
405
|
+
setActualPlacement(floatingPlacement);
|
|
406
|
+
}
|
|
407
|
+
}, [isOpen]);
|
|
408
|
+
(0, _react.useEffect)(() => {
|
|
409
|
+
setPlacement();
|
|
410
|
+
window.addEventListener("resize", setPlacement);
|
|
411
|
+
return () => {
|
|
412
|
+
window.removeEventListener("resize", setPlacement);
|
|
413
|
+
};
|
|
414
|
+
}, [setPlacement]);
|
|
398
415
|
const loader = isLoading ? /*#__PURE__*/_react.default.createElement(_selectList.StyledSelectLoaderContainer, {
|
|
399
416
|
key: "loader"
|
|
400
417
|
}, /*#__PURE__*/_react.default.createElement(_loader.default, null)) : undefined;
|
|
@@ -433,9 +450,11 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
433
450
|
disableBackgroundUI: true,
|
|
434
451
|
animationFrame: true
|
|
435
452
|
}, /*#__PURE__*/_react.default.createElement(_selectList.StyledSelectListContainer, _extends({
|
|
453
|
+
ref: listWrapperRef,
|
|
436
454
|
"data-element": "select-list-wrapper",
|
|
437
455
|
"data-role": "select-list-wrapper",
|
|
438
|
-
isLoading: isLoading
|
|
456
|
+
isLoading: isLoading,
|
|
457
|
+
placement: actualPlacement
|
|
439
458
|
}, listProps), /*#__PURE__*/_react.default.createElement(_selectList.StyledScrollableContainer, {
|
|
440
459
|
ref: listContainerRef,
|
|
441
460
|
maxHeight: listMaxHeight,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SelectListProps } from ".";
|
|
2
1
|
interface StyledSelectListProps {
|
|
3
2
|
listHeight?: number;
|
|
4
3
|
}
|
|
@@ -10,7 +9,11 @@ interface StyledSelectListTableHeaderProps {
|
|
|
10
9
|
}
|
|
11
10
|
declare const StyledSelectListTableHeader: import("styled-components").StyledComponent<"thead", any, StyledSelectListTableHeaderProps, never>;
|
|
12
11
|
declare const StyledSelectListTableBody: import("styled-components").StyledComponent<"tbody", any, StyledSelectListProps, never>;
|
|
13
|
-
|
|
12
|
+
interface StyledSelectListContainerProps {
|
|
13
|
+
isLoading?: boolean;
|
|
14
|
+
placement?: string;
|
|
15
|
+
}
|
|
16
|
+
declare const StyledSelectListContainer: import("styled-components").StyledComponent<"div", any, StyledSelectListContainerProps, never>;
|
|
14
17
|
declare const StyledScrollableContainer: import("styled-components").StyledComponent<"div", any, {
|
|
15
18
|
maxHeight: number;
|
|
16
19
|
hasActionButton: boolean;
|
|
@@ -102,7 +102,9 @@ const StyledSelectListTableBody = exports.StyledSelectListTableBody = _styledCom
|
|
|
102
102
|
`;
|
|
103
103
|
const StyledSelectListContainer = exports.StyledSelectListContainer = _styledComponents.default.div`
|
|
104
104
|
background-color: white;
|
|
105
|
-
box-shadow:
|
|
105
|
+
box-shadow: ${({
|
|
106
|
+
placement
|
|
107
|
+
}) => placement?.includes("top") ? "0 -5px 5px 0 #00141e33, 0 -10px 10px 0 #00141e1a" : "var(--boxShadow100)"};
|
|
106
108
|
animation: fadeIn 250ms ease-out;
|
|
107
109
|
position: absolute;
|
|
108
110
|
z-index: ${({
|
|
@@ -90,6 +90,7 @@ const TabsHeader = ({
|
|
|
90
90
|
title: "Scroll Tabs Left",
|
|
91
91
|
id: "tab-navigation-button-left",
|
|
92
92
|
"data-role": "tab-navigation-button-left",
|
|
93
|
+
type: "button",
|
|
93
94
|
onClick: () => {
|
|
94
95
|
/* istanbul ignore if */
|
|
95
96
|
if (current) {
|
|
@@ -116,6 +117,7 @@ const TabsHeader = ({
|
|
|
116
117
|
title: "Scroll Tabs Right",
|
|
117
118
|
id: "tab-navigation-button-right",
|
|
118
119
|
"data-role": "tab-navigation-button-right",
|
|
120
|
+
type: "button",
|
|
119
121
|
onClick: () => {
|
|
120
122
|
/* istanbul ignore if */
|
|
121
123
|
if (current) {
|