carbon-react 109.1.2 → 109.1.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/popover-container/popover-container.component.js +26 -5
- package/esm/components/popover-container/popover-container.style.d.ts +0 -2
- package/esm/components/popover-container/popover-container.style.js +0 -8
- package/lib/components/popover-container/popover-container.component.js +27 -5
- package/lib/components/popover-container/popover-container.style.d.ts +0 -2
- package/lib/components/popover-container/popover-container.style.js +0 -8
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import PropTypes from "prop-types";
|
|
|
5
5
|
import { Transition } from "react-transition-group";
|
|
6
6
|
import { PopoverContainerWrapperStyle, PopoverContainerHeaderStyle, PopoverContainerContentStyle, PopoverContainerCloseIcon, PopoverContainerTitleStyle, PopoverContainerOpenIcon } from "./popover-container.style";
|
|
7
7
|
import Icon from "../icon";
|
|
8
|
+
import Popover from "../../__internal__/popover";
|
|
8
9
|
import createGuid from "../../__internal__/utils/helpers/guid";
|
|
9
10
|
import { filterStyledSystemPaddingProps } from "../../style/utils";
|
|
10
11
|
import useClickAwayListener from "../../hooks/__internal__/useClickAwayListener";
|
|
@@ -60,6 +61,19 @@ renderClose.propTypes = {
|
|
|
60
61
|
"tabIndex": PropTypes.number.isRequired
|
|
61
62
|
};
|
|
62
63
|
|
|
64
|
+
const offset = ({
|
|
65
|
+
reference
|
|
66
|
+
}) => {
|
|
67
|
+
return [0, -reference.height];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const popperModifiers = [{
|
|
71
|
+
name: "offset",
|
|
72
|
+
options: {
|
|
73
|
+
offset
|
|
74
|
+
}
|
|
75
|
+
}];
|
|
76
|
+
|
|
63
77
|
const PopoverContainer = ({
|
|
64
78
|
children,
|
|
65
79
|
title,
|
|
@@ -86,7 +100,11 @@ const PopoverContainer = ({
|
|
|
86
100
|
const popoverContainerId = title ? `PopoverContainer_${guid.current}` : undefined;
|
|
87
101
|
const isOpen = isControlled ? open : isOpenInternal;
|
|
88
102
|
useEffect(() => {
|
|
89
|
-
if (isOpen && closeButtonRef.current)
|
|
103
|
+
if (isOpen && closeButtonRef.current) setTimeout(() => {
|
|
104
|
+
var _closeButtonRef$curre;
|
|
105
|
+
|
|
106
|
+
return (_closeButtonRef$curre = closeButtonRef.current) === null || _closeButtonRef$curre === void 0 ? void 0 : _closeButtonRef$curre.focus();
|
|
107
|
+
}, 0);
|
|
90
108
|
}, [isOpen]);
|
|
91
109
|
|
|
92
110
|
const handleOpenButtonClick = e => {
|
|
@@ -140,12 +158,15 @@ const PopoverContainer = ({
|
|
|
140
158
|
mountOnEnter: true,
|
|
141
159
|
unmountOnExit: true,
|
|
142
160
|
nodeRef: popoverContentNodeRef
|
|
143
|
-
}, state => /*#__PURE__*/React.createElement(
|
|
161
|
+
}, state => isOpen && /*#__PURE__*/React.createElement(Popover, _extends({
|
|
162
|
+
reference: openButtonRef,
|
|
163
|
+
placement: position === "right" ? "bottom-start" : "bottom-end"
|
|
164
|
+
}, shouldCoverButton && {
|
|
165
|
+
modifiers: popperModifiers
|
|
166
|
+
}), /*#__PURE__*/React.createElement(PopoverContainerContentStyle, _extends({
|
|
144
167
|
"data-element": "popover-container-content",
|
|
145
168
|
role: "dialog",
|
|
146
169
|
animationState: state,
|
|
147
|
-
position: position,
|
|
148
|
-
shouldCoverButton: shouldCoverButton,
|
|
149
170
|
"aria-labelledby": popoverContainerId,
|
|
150
171
|
"aria-label": containerAriaLabel,
|
|
151
172
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -154,7 +175,7 @@ const PopoverContainer = ({
|
|
|
154
175
|
}, filterStyledSystemPaddingProps(rest)), /*#__PURE__*/React.createElement(PopoverContainerHeaderStyle, null, /*#__PURE__*/React.createElement(PopoverContainerTitleStyle, {
|
|
155
176
|
id: popoverContainerId,
|
|
156
177
|
"data-element": "popover-container-title"
|
|
157
|
-
}, title), renderCloseComponent(renderCloseComponentProps)), children)));
|
|
178
|
+
}, title), renderCloseComponent(renderCloseComponentProps)), children))));
|
|
158
179
|
};
|
|
159
180
|
|
|
160
181
|
PopoverContainer.propTypes = {
|
|
@@ -3,8 +3,6 @@ import IconButton from "../icon-button";
|
|
|
3
3
|
declare const PopoverContainerWrapperStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
4
|
declare const PopoverContainerHeaderStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
5
|
declare type PopoverContainerContentStyleProps = {
|
|
6
|
-
shouldCoverButton?: boolean;
|
|
7
|
-
position?: "left" | "right";
|
|
8
6
|
animationState?: TransitionStatus;
|
|
9
7
|
};
|
|
10
8
|
declare const PopoverContainerContentStyle: import("styled-components").StyledComponent<"div", any, PopoverContainerContentStyleProps, never>;
|
|
@@ -24,14 +24,6 @@ const PopoverContainerContentStyle = styled.div`
|
|
|
24
24
|
theme
|
|
25
25
|
}) => theme.zIndex.popover};
|
|
26
26
|
|
|
27
|
-
${({
|
|
28
|
-
shouldCoverButton
|
|
29
|
-
}) => shouldCoverButton && "top: 0"}
|
|
30
|
-
|
|
31
|
-
${({
|
|
32
|
-
position
|
|
33
|
-
}) => position === "left" ? "right: 0" : "left: 0"};
|
|
34
|
-
|
|
35
27
|
${({
|
|
36
28
|
animationState
|
|
37
29
|
}) => {
|
|
@@ -15,6 +15,8 @@ var _popoverContainer = require("./popover-container.style");
|
|
|
15
15
|
|
|
16
16
|
var _icon = _interopRequireDefault(require("../icon"));
|
|
17
17
|
|
|
18
|
+
var _popover = _interopRequireDefault(require("../../__internal__/popover"));
|
|
19
|
+
|
|
18
20
|
var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
|
|
19
21
|
|
|
20
22
|
var _utils = require("../../style/utils");
|
|
@@ -80,6 +82,19 @@ renderClose.propTypes = {
|
|
|
80
82
|
"tabIndex": _propTypes.default.number.isRequired
|
|
81
83
|
};
|
|
82
84
|
|
|
85
|
+
const offset = ({
|
|
86
|
+
reference
|
|
87
|
+
}) => {
|
|
88
|
+
return [0, -reference.height];
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const popperModifiers = [{
|
|
92
|
+
name: "offset",
|
|
93
|
+
options: {
|
|
94
|
+
offset
|
|
95
|
+
}
|
|
96
|
+
}];
|
|
97
|
+
|
|
83
98
|
const PopoverContainer = ({
|
|
84
99
|
children,
|
|
85
100
|
title,
|
|
@@ -106,7 +121,11 @@ const PopoverContainer = ({
|
|
|
106
121
|
const popoverContainerId = title ? `PopoverContainer_${guid.current}` : undefined;
|
|
107
122
|
const isOpen = isControlled ? open : isOpenInternal;
|
|
108
123
|
(0, _react.useEffect)(() => {
|
|
109
|
-
if (isOpen && closeButtonRef.current)
|
|
124
|
+
if (isOpen && closeButtonRef.current) setTimeout(() => {
|
|
125
|
+
var _closeButtonRef$curre;
|
|
126
|
+
|
|
127
|
+
return (_closeButtonRef$curre = closeButtonRef.current) === null || _closeButtonRef$curre === void 0 ? void 0 : _closeButtonRef$curre.focus();
|
|
128
|
+
}, 0);
|
|
110
129
|
}, [isOpen]);
|
|
111
130
|
|
|
112
131
|
const handleOpenButtonClick = e => {
|
|
@@ -160,12 +179,15 @@ const PopoverContainer = ({
|
|
|
160
179
|
mountOnEnter: true,
|
|
161
180
|
unmountOnExit: true,
|
|
162
181
|
nodeRef: popoverContentNodeRef
|
|
163
|
-
}, state => /*#__PURE__*/_react.default.createElement(
|
|
182
|
+
}, state => isOpen && /*#__PURE__*/_react.default.createElement(_popover.default, _extends({
|
|
183
|
+
reference: openButtonRef,
|
|
184
|
+
placement: position === "right" ? "bottom-start" : "bottom-end"
|
|
185
|
+
}, shouldCoverButton && {
|
|
186
|
+
modifiers: popperModifiers
|
|
187
|
+
}), /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerContentStyle, _extends({
|
|
164
188
|
"data-element": "popover-container-content",
|
|
165
189
|
role: "dialog",
|
|
166
190
|
animationState: state,
|
|
167
|
-
position: position,
|
|
168
|
-
shouldCoverButton: shouldCoverButton,
|
|
169
191
|
"aria-labelledby": popoverContainerId,
|
|
170
192
|
"aria-label": containerAriaLabel,
|
|
171
193
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -174,7 +196,7 @@ const PopoverContainer = ({
|
|
|
174
196
|
}, (0, _utils.filterStyledSystemPaddingProps)(rest)), /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerHeaderStyle, null, /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerTitleStyle, {
|
|
175
197
|
id: popoverContainerId,
|
|
176
198
|
"data-element": "popover-container-title"
|
|
177
|
-
}, title), renderCloseComponent(renderCloseComponentProps)), children)));
|
|
199
|
+
}, title), renderCloseComponent(renderCloseComponentProps)), children))));
|
|
178
200
|
};
|
|
179
201
|
|
|
180
202
|
exports.PopoverContainer = PopoverContainer;
|
|
@@ -3,8 +3,6 @@ import IconButton from "../icon-button";
|
|
|
3
3
|
declare const PopoverContainerWrapperStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
4
|
declare const PopoverContainerHeaderStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
5
|
declare type PopoverContainerContentStyleProps = {
|
|
6
|
-
shouldCoverButton?: boolean;
|
|
7
|
-
position?: "left" | "right";
|
|
8
6
|
animationState?: TransitionStatus;
|
|
9
7
|
};
|
|
10
8
|
declare const PopoverContainerContentStyle: import("styled-components").StyledComponent<"div", any, PopoverContainerContentStyleProps, never>;
|
|
@@ -40,14 +40,6 @@ const PopoverContainerContentStyle = _styledComponents.default.div`
|
|
|
40
40
|
theme
|
|
41
41
|
}) => theme.zIndex.popover};
|
|
42
42
|
|
|
43
|
-
${({
|
|
44
|
-
shouldCoverButton
|
|
45
|
-
}) => shouldCoverButton && "top: 0"}
|
|
46
|
-
|
|
47
|
-
${({
|
|
48
|
-
position
|
|
49
|
-
}) => position === "left" ? "right: 0" : "left: 0"};
|
|
50
|
-
|
|
51
43
|
${({
|
|
52
44
|
animationState
|
|
53
45
|
}) => {
|