carbon-react 107.2.1 → 108.0.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/esm/components/popover-container/index.d.ts +2 -1
- package/esm/components/popover-container/popover-container.component.d.ts +56 -0
- package/esm/components/popover-container/popover-container.component.js +234 -106
- package/esm/components/popover-container/popover-container.style.d.ts +18 -0
- package/esm/style/utils/filter-styled-system-padding-props.d.ts +1 -1
- package/esm/style/utils/filter-styled-system-padding-props.js +4 -2
- package/lib/components/popover-container/index.d.ts +2 -1
- package/lib/components/popover-container/popover-container.component.d.ts +56 -0
- package/lib/components/popover-container/popover-container.component.js +234 -108
- package/lib/components/popover-container/popover-container.style.d.ts +18 -0
- package/lib/style/utils/filter-styled-system-padding-props.d.ts +1 -1
- package/lib/style/utils/filter-styled-system-padding-props.js +4 -2
- package/package.json +2 -1
- package/esm/components/popover-container/popover-container.d.ts +0 -35
- package/lib/components/popover-container/popover-container.d.ts +0 -35
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./popover-container";
|
|
1
|
+
export { default } from "./popover-container.component";
|
|
2
|
+
export type { PopoverContainerProps, RenderCloseProps, RenderOpenProps, } from "./popover-container.component";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { PaddingProps } from "styled-system";
|
|
3
|
+
export interface RenderOpenProps {
|
|
4
|
+
tabIndex: number;
|
|
5
|
+
isOpen?: boolean;
|
|
6
|
+
"data-element": string;
|
|
7
|
+
onClick: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
8
|
+
ref: React.RefObject<HTMLButtonElement>;
|
|
9
|
+
"aria-label"?: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface RenderCloseProps {
|
|
13
|
+
"data-element": string;
|
|
14
|
+
tabIndex: number;
|
|
15
|
+
onClick: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
16
|
+
ref: React.RefObject<HTMLButtonElement>;
|
|
17
|
+
"aria-label": string;
|
|
18
|
+
}
|
|
19
|
+
export interface PopoverContainerProps extends PaddingProps {
|
|
20
|
+
/** A function that will render the open component
|
|
21
|
+
*
|
|
22
|
+
* `({tabIndex, isOpen, data-element, onClick, ref, aria-label}) => ()`
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
renderOpenComponent?: (args: RenderOpenProps) => JSX.Element;
|
|
26
|
+
/** A function that will render the close component
|
|
27
|
+
*
|
|
28
|
+
* `({data-element, tabIndex, onClick, ref, aria-label}) => ()`
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
renderCloseComponent?: (args: RenderCloseProps) => JSX.Element;
|
|
32
|
+
/** The content of the popover-container */
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
/** Sets rendering position of dialog */
|
|
35
|
+
position?: "left" | "right";
|
|
36
|
+
/** Sets the popover container dialog header name */
|
|
37
|
+
title?: string;
|
|
38
|
+
/** Callback fires when close icon clicked */
|
|
39
|
+
onClose?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
40
|
+
/** if `true` the popover-container is open */
|
|
41
|
+
open?: boolean;
|
|
42
|
+
/** Callback fires when open component is clicked */
|
|
43
|
+
onOpen?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
44
|
+
/** if `true` the popover-container will cover open button */
|
|
45
|
+
shouldCoverButton?: boolean;
|
|
46
|
+
/** The id of the element that describe the dialog. */
|
|
47
|
+
ariaDescribedBy?: string;
|
|
48
|
+
/** Open button aria label */
|
|
49
|
+
openButtonAriaLabel?: string;
|
|
50
|
+
/** Close button aria label */
|
|
51
|
+
closeButtonAriaLabel?: string;
|
|
52
|
+
/** Container aria label */
|
|
53
|
+
containerAriaLabel?: string;
|
|
54
|
+
}
|
|
55
|
+
export declare const PopoverContainer: ({ children, title, position, open, onOpen, onClose, renderOpenComponent, renderCloseComponent, shouldCoverButton, ariaDescribedBy, openButtonAriaLabel, closeButtonAriaLabel, containerAriaLabel, ...rest }: PopoverContainerProps) => JSX.Element;
|
|
56
|
+
export default PopoverContainer;
|
|
@@ -2,25 +2,74 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
2
2
|
|
|
3
3
|
import React, { useEffect, useRef, useState } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
-
import styledSystemPropTypes from "@styled-system/prop-types";
|
|
6
5
|
import { Transition } from "react-transition-group";
|
|
7
6
|
import { PopoverContainerWrapperStyle, PopoverContainerHeaderStyle, PopoverContainerContentStyle, PopoverContainerCloseIcon, PopoverContainerTitleStyle, PopoverContainerOpenIcon } from "./popover-container.style";
|
|
8
7
|
import Icon from "../icon";
|
|
9
8
|
import createGuid from "../../__internal__/utils/helpers/guid";
|
|
10
9
|
import { filterStyledSystemPaddingProps } from "../../style/utils";
|
|
11
10
|
import ClickAwayWrapper from "../../__internal__/click-away-wrapper";
|
|
12
|
-
|
|
11
|
+
|
|
12
|
+
const renderOpen = ({
|
|
13
|
+
tabIndex,
|
|
14
|
+
onClick,
|
|
15
|
+
"data-element": dataElement,
|
|
16
|
+
ref,
|
|
17
|
+
"aria-label": ariaLabel,
|
|
18
|
+
id
|
|
19
|
+
}) => /*#__PURE__*/React.createElement(PopoverContainerOpenIcon, {
|
|
20
|
+
tabIndex: tabIndex,
|
|
21
|
+
onAction: onClick,
|
|
22
|
+
"data-element": dataElement,
|
|
23
|
+
ref: ref,
|
|
24
|
+
"aria-label": ariaLabel,
|
|
25
|
+
"aria-haspopup": true,
|
|
26
|
+
id: id
|
|
27
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
28
|
+
type: "settings"
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
renderOpen.propTypes = {
|
|
32
|
+
"aria-label": PropTypes.string,
|
|
33
|
+
"data-element": PropTypes.string.isRequired,
|
|
34
|
+
"id": PropTypes.string,
|
|
35
|
+
"isOpen": PropTypes.bool,
|
|
36
|
+
"onClick": PropTypes.func.isRequired,
|
|
37
|
+
"tabIndex": PropTypes.number.isRequired
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const renderClose = ({
|
|
41
|
+
"data-element": dataElement,
|
|
42
|
+
tabIndex,
|
|
43
|
+
onClick,
|
|
44
|
+
ref,
|
|
45
|
+
"aria-label": ariaLabel
|
|
46
|
+
}) => /*#__PURE__*/React.createElement(PopoverContainerCloseIcon, {
|
|
47
|
+
"data-element": dataElement,
|
|
48
|
+
tabIndex: tabIndex,
|
|
49
|
+
onAction: onClick,
|
|
50
|
+
ref: ref,
|
|
51
|
+
"aria-label": ariaLabel
|
|
52
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
53
|
+
type: "close"
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
renderClose.propTypes = {
|
|
57
|
+
"aria-label": PropTypes.string.isRequired,
|
|
58
|
+
"data-element": PropTypes.string.isRequired,
|
|
59
|
+
"onClick": PropTypes.func.isRequired,
|
|
60
|
+
"tabIndex": PropTypes.number.isRequired
|
|
61
|
+
};
|
|
13
62
|
|
|
14
63
|
const PopoverContainer = ({
|
|
15
64
|
children,
|
|
16
65
|
title,
|
|
17
|
-
position,
|
|
66
|
+
position = "right",
|
|
18
67
|
open,
|
|
19
68
|
onOpen,
|
|
20
69
|
onClose,
|
|
21
|
-
renderOpenComponent,
|
|
22
|
-
renderCloseComponent,
|
|
23
|
-
shouldCoverButton,
|
|
70
|
+
renderOpenComponent = renderOpen,
|
|
71
|
+
renderCloseComponent = renderClose,
|
|
72
|
+
shouldCoverButton = false,
|
|
24
73
|
ariaDescribedBy,
|
|
25
74
|
openButtonAriaLabel,
|
|
26
75
|
closeButtonAriaLabel = "close",
|
|
@@ -29,11 +78,11 @@ const PopoverContainer = ({
|
|
|
29
78
|
}) => {
|
|
30
79
|
const isControlled = open !== undefined;
|
|
31
80
|
const [isOpenInternal, setIsOpenInternal] = useState(false);
|
|
32
|
-
const ref = useRef();
|
|
33
|
-
const closeButtonRef = useRef();
|
|
34
|
-
const openButtonRef = useRef();
|
|
81
|
+
const ref = useRef(null);
|
|
82
|
+
const closeButtonRef = useRef(null);
|
|
83
|
+
const openButtonRef = useRef(null);
|
|
35
84
|
const guid = useRef(createGuid());
|
|
36
|
-
const popoverContentNodeRef = useRef();
|
|
85
|
+
const popoverContentNodeRef = useRef(null);
|
|
37
86
|
const popoverContainerId = title ? `PopoverContainer_${guid.current}` : undefined;
|
|
38
87
|
const isOpen = isControlled ? open : isOpenInternal;
|
|
39
88
|
useEffect(() => {
|
|
@@ -57,19 +106,20 @@ const PopoverContainer = ({
|
|
|
57
106
|
const renderOpenComponentProps = {
|
|
58
107
|
tabIndex: isOpen ? -1 : 0,
|
|
59
108
|
isOpen,
|
|
60
|
-
|
|
109
|
+
"data-element": "popover-container-open-component",
|
|
61
110
|
onClick: handleOpenButtonClick,
|
|
62
111
|
ref: openButtonRef,
|
|
63
|
-
|
|
112
|
+
"aria-label": openButtonAriaLabel || title,
|
|
64
113
|
id: isOpen ? undefined : popoverContainerId
|
|
65
114
|
};
|
|
66
115
|
const renderCloseComponentProps = {
|
|
67
|
-
|
|
116
|
+
"data-element": "popover-container-close-component",
|
|
68
117
|
tabIndex: 0,
|
|
69
118
|
onClick: handleCloseButtonClick,
|
|
70
119
|
ref: closeButtonRef,
|
|
71
|
-
|
|
72
|
-
};
|
|
120
|
+
"aria-label": closeButtonAriaLabel
|
|
121
|
+
}; // TODO: Assign proper type after ClickAwayWrapper has been refactored
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
123
|
|
|
74
124
|
const handleClickAway = e => {
|
|
75
125
|
if (!isControlled) setIsOpenInternal(false);
|
|
@@ -111,96 +161,174 @@ const PopoverContainer = ({
|
|
|
111
161
|
}, title), renderCloseComponent(renderCloseComponentProps)), children))));
|
|
112
162
|
};
|
|
113
163
|
|
|
114
|
-
PopoverContainer.propTypes = {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
"
|
|
180
|
-
|
|
181
|
-
"
|
|
182
|
-
"
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
"
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
"
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
164
|
+
PopoverContainer.propTypes = {
|
|
165
|
+
"ariaDescribedBy": PropTypes.string,
|
|
166
|
+
"children": PropTypes.node,
|
|
167
|
+
"closeButtonAriaLabel": PropTypes.string,
|
|
168
|
+
"containerAriaLabel": PropTypes.string,
|
|
169
|
+
"onClose": PropTypes.func,
|
|
170
|
+
"onOpen": PropTypes.func,
|
|
171
|
+
"open": PropTypes.bool,
|
|
172
|
+
"openButtonAriaLabel": PropTypes.string,
|
|
173
|
+
"p": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
174
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
175
|
+
"description": PropTypes.string,
|
|
176
|
+
"toString": PropTypes.func.isRequired,
|
|
177
|
+
"valueOf": PropTypes.func.isRequired
|
|
178
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
179
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
180
|
+
"description": PropTypes.string,
|
|
181
|
+
"toString": PropTypes.func.isRequired,
|
|
182
|
+
"valueOf": PropTypes.func.isRequired
|
|
183
|
+
}), PropTypes.string]),
|
|
184
|
+
"padding": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
185
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
186
|
+
"description": PropTypes.string,
|
|
187
|
+
"toString": PropTypes.func.isRequired,
|
|
188
|
+
"valueOf": PropTypes.func.isRequired
|
|
189
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
190
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
191
|
+
"description": PropTypes.string,
|
|
192
|
+
"toString": PropTypes.func.isRequired,
|
|
193
|
+
"valueOf": PropTypes.func.isRequired
|
|
194
|
+
}), PropTypes.string]),
|
|
195
|
+
"paddingBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
196
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
197
|
+
"description": PropTypes.string,
|
|
198
|
+
"toString": PropTypes.func.isRequired,
|
|
199
|
+
"valueOf": PropTypes.func.isRequired
|
|
200
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
201
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
202
|
+
"description": PropTypes.string,
|
|
203
|
+
"toString": PropTypes.func.isRequired,
|
|
204
|
+
"valueOf": PropTypes.func.isRequired
|
|
205
|
+
}), PropTypes.string]),
|
|
206
|
+
"paddingLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
207
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
208
|
+
"description": PropTypes.string,
|
|
209
|
+
"toString": PropTypes.func.isRequired,
|
|
210
|
+
"valueOf": PropTypes.func.isRequired
|
|
211
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
212
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
213
|
+
"description": PropTypes.string,
|
|
214
|
+
"toString": PropTypes.func.isRequired,
|
|
215
|
+
"valueOf": PropTypes.func.isRequired
|
|
216
|
+
}), PropTypes.string]),
|
|
217
|
+
"paddingRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
218
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
219
|
+
"description": PropTypes.string,
|
|
220
|
+
"toString": PropTypes.func.isRequired,
|
|
221
|
+
"valueOf": PropTypes.func.isRequired
|
|
222
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
223
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
224
|
+
"description": PropTypes.string,
|
|
225
|
+
"toString": PropTypes.func.isRequired,
|
|
226
|
+
"valueOf": PropTypes.func.isRequired
|
|
227
|
+
}), PropTypes.string]),
|
|
228
|
+
"paddingTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
229
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
230
|
+
"description": PropTypes.string,
|
|
231
|
+
"toString": PropTypes.func.isRequired,
|
|
232
|
+
"valueOf": PropTypes.func.isRequired
|
|
233
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
234
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
235
|
+
"description": PropTypes.string,
|
|
236
|
+
"toString": PropTypes.func.isRequired,
|
|
237
|
+
"valueOf": PropTypes.func.isRequired
|
|
238
|
+
}), PropTypes.string]),
|
|
239
|
+
"paddingX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
240
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
241
|
+
"description": PropTypes.string,
|
|
242
|
+
"toString": PropTypes.func.isRequired,
|
|
243
|
+
"valueOf": PropTypes.func.isRequired
|
|
244
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
245
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
246
|
+
"description": PropTypes.string,
|
|
247
|
+
"toString": PropTypes.func.isRequired,
|
|
248
|
+
"valueOf": PropTypes.func.isRequired
|
|
249
|
+
}), PropTypes.string]),
|
|
250
|
+
"paddingY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
251
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
252
|
+
"description": PropTypes.string,
|
|
253
|
+
"toString": PropTypes.func.isRequired,
|
|
254
|
+
"valueOf": PropTypes.func.isRequired
|
|
255
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
256
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
257
|
+
"description": PropTypes.string,
|
|
258
|
+
"toString": PropTypes.func.isRequired,
|
|
259
|
+
"valueOf": PropTypes.func.isRequired
|
|
260
|
+
}), PropTypes.string]),
|
|
261
|
+
"pb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
262
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
263
|
+
"description": PropTypes.string,
|
|
264
|
+
"toString": PropTypes.func.isRequired,
|
|
265
|
+
"valueOf": PropTypes.func.isRequired
|
|
266
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
267
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
268
|
+
"description": PropTypes.string,
|
|
269
|
+
"toString": PropTypes.func.isRequired,
|
|
270
|
+
"valueOf": PropTypes.func.isRequired
|
|
271
|
+
}), PropTypes.string]),
|
|
272
|
+
"pl": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
273
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
274
|
+
"description": PropTypes.string,
|
|
275
|
+
"toString": PropTypes.func.isRequired,
|
|
276
|
+
"valueOf": PropTypes.func.isRequired
|
|
277
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
278
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
279
|
+
"description": PropTypes.string,
|
|
280
|
+
"toString": PropTypes.func.isRequired,
|
|
281
|
+
"valueOf": PropTypes.func.isRequired
|
|
282
|
+
}), PropTypes.string]),
|
|
283
|
+
"position": PropTypes.oneOf(["left", "right"]),
|
|
284
|
+
"pr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
285
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
286
|
+
"description": PropTypes.string,
|
|
287
|
+
"toString": PropTypes.func.isRequired,
|
|
288
|
+
"valueOf": PropTypes.func.isRequired
|
|
289
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
290
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
291
|
+
"description": PropTypes.string,
|
|
292
|
+
"toString": PropTypes.func.isRequired,
|
|
293
|
+
"valueOf": PropTypes.func.isRequired
|
|
294
|
+
}), PropTypes.string]),
|
|
295
|
+
"pt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
296
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
297
|
+
"description": PropTypes.string,
|
|
298
|
+
"toString": PropTypes.func.isRequired,
|
|
299
|
+
"valueOf": PropTypes.func.isRequired
|
|
300
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
301
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
302
|
+
"description": PropTypes.string,
|
|
303
|
+
"toString": PropTypes.func.isRequired,
|
|
304
|
+
"valueOf": PropTypes.func.isRequired
|
|
305
|
+
}), PropTypes.string]),
|
|
306
|
+
"px": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
307
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
308
|
+
"description": PropTypes.string,
|
|
309
|
+
"toString": PropTypes.func.isRequired,
|
|
310
|
+
"valueOf": PropTypes.func.isRequired
|
|
311
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
312
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
313
|
+
"description": PropTypes.string,
|
|
314
|
+
"toString": PropTypes.func.isRequired,
|
|
315
|
+
"valueOf": PropTypes.func.isRequired
|
|
316
|
+
}), PropTypes.string]),
|
|
317
|
+
"py": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
318
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
319
|
+
"description": PropTypes.string,
|
|
320
|
+
"toString": PropTypes.func.isRequired,
|
|
321
|
+
"valueOf": PropTypes.func.isRequired
|
|
322
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
323
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
324
|
+
"description": PropTypes.string,
|
|
325
|
+
"toString": PropTypes.func.isRequired,
|
|
326
|
+
"valueOf": PropTypes.func.isRequired
|
|
327
|
+
}), PropTypes.string]),
|
|
328
|
+
"renderCloseComponent": PropTypes.func,
|
|
329
|
+
"renderOpenComponent": PropTypes.func,
|
|
330
|
+
"shouldCoverButton": PropTypes.bool,
|
|
331
|
+
"title": PropTypes.string
|
|
205
332
|
};
|
|
333
|
+
export { PopoverContainer };
|
|
206
334
|
export default PopoverContainer;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TransitionStatus } from "react-transition-group";
|
|
2
|
+
import IconButton from "../icon-button";
|
|
3
|
+
declare const PopoverContainerWrapperStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
declare const PopoverContainerHeaderStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
declare type PopoverContainerContentStyleProps = {
|
|
6
|
+
shouldCoverButton?: boolean;
|
|
7
|
+
position?: "left" | "right";
|
|
8
|
+
animationState?: TransitionStatus;
|
|
9
|
+
};
|
|
10
|
+
declare const PopoverContainerContentStyle: import("styled-components").StyledComponent<"div", any, PopoverContainerContentStyleProps, never>;
|
|
11
|
+
declare type AdditionalIconButtonProps = {
|
|
12
|
+
tabIndex?: number;
|
|
13
|
+
id?: string;
|
|
14
|
+
};
|
|
15
|
+
declare const PopoverContainerOpenIcon: import("styled-components").StyledComponent<typeof IconButton, any, AdditionalIconButtonProps, never>;
|
|
16
|
+
declare const PopoverContainerCloseIcon: import("styled-components").StyledComponent<typeof IconButton, any, AdditionalIconButtonProps, never>;
|
|
17
|
+
declare const PopoverContainerTitleStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
18
|
+
export { PopoverContainerWrapperStyle, PopoverContainerHeaderStyle, PopoverContainerContentStyle, PopoverContainerCloseIcon, PopoverContainerTitleStyle, PopoverContainerOpenIcon, };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PaddingProps } from "styled-system";
|
|
2
2
|
export declare const paddingPropertyNames: string[];
|
|
3
|
-
export default function filterStyledSystemPaddingProps(
|
|
3
|
+
export default function filterStyledSystemPaddingProps(props: Record<string, any>): PaddingProps;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import filterObjectProperties from "../../__internal__/filter-object-properties";
|
|
2
2
|
export const paddingPropertyNames = ["padding", "p", "paddingLeft", "pl", "paddingRight", "pr", "paddingTop", "pt", "paddingBottom", "pb", "paddingX", "px", "paddingY", "py"];
|
|
3
|
-
export default function filterStyledSystemPaddingProps(
|
|
4
|
-
|
|
3
|
+
export default function filterStyledSystemPaddingProps( // method should accept any react prop
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
props) {
|
|
6
|
+
return filterObjectProperties(props, paddingPropertyNames);
|
|
5
7
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./popover-container";
|
|
1
|
+
export { default } from "./popover-container.component";
|
|
2
|
+
export type { PopoverContainerProps, RenderCloseProps, RenderOpenProps, } from "./popover-container.component";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { PaddingProps } from "styled-system";
|
|
3
|
+
export interface RenderOpenProps {
|
|
4
|
+
tabIndex: number;
|
|
5
|
+
isOpen?: boolean;
|
|
6
|
+
"data-element": string;
|
|
7
|
+
onClick: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
8
|
+
ref: React.RefObject<HTMLButtonElement>;
|
|
9
|
+
"aria-label"?: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface RenderCloseProps {
|
|
13
|
+
"data-element": string;
|
|
14
|
+
tabIndex: number;
|
|
15
|
+
onClick: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
16
|
+
ref: React.RefObject<HTMLButtonElement>;
|
|
17
|
+
"aria-label": string;
|
|
18
|
+
}
|
|
19
|
+
export interface PopoverContainerProps extends PaddingProps {
|
|
20
|
+
/** A function that will render the open component
|
|
21
|
+
*
|
|
22
|
+
* `({tabIndex, isOpen, data-element, onClick, ref, aria-label}) => ()`
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
renderOpenComponent?: (args: RenderOpenProps) => JSX.Element;
|
|
26
|
+
/** A function that will render the close component
|
|
27
|
+
*
|
|
28
|
+
* `({data-element, tabIndex, onClick, ref, aria-label}) => ()`
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
renderCloseComponent?: (args: RenderCloseProps) => JSX.Element;
|
|
32
|
+
/** The content of the popover-container */
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
/** Sets rendering position of dialog */
|
|
35
|
+
position?: "left" | "right";
|
|
36
|
+
/** Sets the popover container dialog header name */
|
|
37
|
+
title?: string;
|
|
38
|
+
/** Callback fires when close icon clicked */
|
|
39
|
+
onClose?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
40
|
+
/** if `true` the popover-container is open */
|
|
41
|
+
open?: boolean;
|
|
42
|
+
/** Callback fires when open component is clicked */
|
|
43
|
+
onOpen?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
44
|
+
/** if `true` the popover-container will cover open button */
|
|
45
|
+
shouldCoverButton?: boolean;
|
|
46
|
+
/** The id of the element that describe the dialog. */
|
|
47
|
+
ariaDescribedBy?: string;
|
|
48
|
+
/** Open button aria label */
|
|
49
|
+
openButtonAriaLabel?: string;
|
|
50
|
+
/** Close button aria label */
|
|
51
|
+
closeButtonAriaLabel?: string;
|
|
52
|
+
/** Container aria label */
|
|
53
|
+
containerAriaLabel?: string;
|
|
54
|
+
}
|
|
55
|
+
export declare const PopoverContainer: ({ children, title, position, open, onOpen, onClose, renderOpenComponent, renderCloseComponent, shouldCoverButton, ariaDescribedBy, openButtonAriaLabel, closeButtonAriaLabel, containerAriaLabel, ...rest }: PopoverContainerProps) => JSX.Element;
|
|
56
|
+
export default PopoverContainer;
|
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.PopoverContainer = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
-
var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
|
|
13
|
-
|
|
14
12
|
var _reactTransitionGroup = require("react-transition-group");
|
|
15
13
|
|
|
16
14
|
var _popoverContainer = require("./popover-container.style");
|
|
@@ -31,18 +29,67 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
31
29
|
|
|
32
30
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
33
31
|
|
|
34
|
-
const
|
|
32
|
+
const renderOpen = ({
|
|
33
|
+
tabIndex,
|
|
34
|
+
onClick,
|
|
35
|
+
"data-element": dataElement,
|
|
36
|
+
ref,
|
|
37
|
+
"aria-label": ariaLabel,
|
|
38
|
+
id
|
|
39
|
+
}) => /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerOpenIcon, {
|
|
40
|
+
tabIndex: tabIndex,
|
|
41
|
+
onAction: onClick,
|
|
42
|
+
"data-element": dataElement,
|
|
43
|
+
ref: ref,
|
|
44
|
+
"aria-label": ariaLabel,
|
|
45
|
+
"aria-haspopup": true,
|
|
46
|
+
id: id
|
|
47
|
+
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
48
|
+
type: "settings"
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
renderOpen.propTypes = {
|
|
52
|
+
"aria-label": _propTypes.default.string,
|
|
53
|
+
"data-element": _propTypes.default.string.isRequired,
|
|
54
|
+
"id": _propTypes.default.string,
|
|
55
|
+
"isOpen": _propTypes.default.bool,
|
|
56
|
+
"onClick": _propTypes.default.func.isRequired,
|
|
57
|
+
"tabIndex": _propTypes.default.number.isRequired
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const renderClose = ({
|
|
61
|
+
"data-element": dataElement,
|
|
62
|
+
tabIndex,
|
|
63
|
+
onClick,
|
|
64
|
+
ref,
|
|
65
|
+
"aria-label": ariaLabel
|
|
66
|
+
}) => /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerCloseIcon, {
|
|
67
|
+
"data-element": dataElement,
|
|
68
|
+
tabIndex: tabIndex,
|
|
69
|
+
onAction: onClick,
|
|
70
|
+
ref: ref,
|
|
71
|
+
"aria-label": ariaLabel
|
|
72
|
+
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
73
|
+
type: "close"
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
renderClose.propTypes = {
|
|
77
|
+
"aria-label": _propTypes.default.string.isRequired,
|
|
78
|
+
"data-element": _propTypes.default.string.isRequired,
|
|
79
|
+
"onClick": _propTypes.default.func.isRequired,
|
|
80
|
+
"tabIndex": _propTypes.default.number.isRequired
|
|
81
|
+
};
|
|
35
82
|
|
|
36
83
|
const PopoverContainer = ({
|
|
37
84
|
children,
|
|
38
85
|
title,
|
|
39
|
-
position,
|
|
86
|
+
position = "right",
|
|
40
87
|
open,
|
|
41
88
|
onOpen,
|
|
42
89
|
onClose,
|
|
43
|
-
renderOpenComponent,
|
|
44
|
-
renderCloseComponent,
|
|
45
|
-
shouldCoverButton,
|
|
90
|
+
renderOpenComponent = renderOpen,
|
|
91
|
+
renderCloseComponent = renderClose,
|
|
92
|
+
shouldCoverButton = false,
|
|
46
93
|
ariaDescribedBy,
|
|
47
94
|
openButtonAriaLabel,
|
|
48
95
|
closeButtonAriaLabel = "close",
|
|
@@ -51,11 +98,11 @@ const PopoverContainer = ({
|
|
|
51
98
|
}) => {
|
|
52
99
|
const isControlled = open !== undefined;
|
|
53
100
|
const [isOpenInternal, setIsOpenInternal] = (0, _react.useState)(false);
|
|
54
|
-
const ref = (0, _react.useRef)();
|
|
55
|
-
const closeButtonRef = (0, _react.useRef)();
|
|
56
|
-
const openButtonRef = (0, _react.useRef)();
|
|
101
|
+
const ref = (0, _react.useRef)(null);
|
|
102
|
+
const closeButtonRef = (0, _react.useRef)(null);
|
|
103
|
+
const openButtonRef = (0, _react.useRef)(null);
|
|
57
104
|
const guid = (0, _react.useRef)((0, _guid.default)());
|
|
58
|
-
const popoverContentNodeRef = (0, _react.useRef)();
|
|
105
|
+
const popoverContentNodeRef = (0, _react.useRef)(null);
|
|
59
106
|
const popoverContainerId = title ? `PopoverContainer_${guid.current}` : undefined;
|
|
60
107
|
const isOpen = isControlled ? open : isOpenInternal;
|
|
61
108
|
(0, _react.useEffect)(() => {
|
|
@@ -79,19 +126,20 @@ const PopoverContainer = ({
|
|
|
79
126
|
const renderOpenComponentProps = {
|
|
80
127
|
tabIndex: isOpen ? -1 : 0,
|
|
81
128
|
isOpen,
|
|
82
|
-
|
|
129
|
+
"data-element": "popover-container-open-component",
|
|
83
130
|
onClick: handleOpenButtonClick,
|
|
84
131
|
ref: openButtonRef,
|
|
85
|
-
|
|
132
|
+
"aria-label": openButtonAriaLabel || title,
|
|
86
133
|
id: isOpen ? undefined : popoverContainerId
|
|
87
134
|
};
|
|
88
135
|
const renderCloseComponentProps = {
|
|
89
|
-
|
|
136
|
+
"data-element": "popover-container-close-component",
|
|
90
137
|
tabIndex: 0,
|
|
91
138
|
onClick: handleCloseButtonClick,
|
|
92
139
|
ref: closeButtonRef,
|
|
93
|
-
|
|
94
|
-
};
|
|
140
|
+
"aria-label": closeButtonAriaLabel
|
|
141
|
+
}; // TODO: Assign proper type after ClickAwayWrapper has been refactored
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
143
|
|
|
96
144
|
const handleClickAway = e => {
|
|
97
145
|
if (!isControlled) setIsOpenInternal(false);
|
|
@@ -133,97 +181,175 @@ const PopoverContainer = ({
|
|
|
133
181
|
}, title), renderCloseComponent(renderCloseComponentProps)), children))));
|
|
134
182
|
};
|
|
135
183
|
|
|
136
|
-
PopoverContainer
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
"
|
|
204
|
-
"
|
|
205
|
-
|
|
206
|
-
},
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
"
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
184
|
+
exports.PopoverContainer = PopoverContainer;
|
|
185
|
+
PopoverContainer.propTypes = {
|
|
186
|
+
"ariaDescribedBy": _propTypes.default.string,
|
|
187
|
+
"children": _propTypes.default.node,
|
|
188
|
+
"closeButtonAriaLabel": _propTypes.default.string,
|
|
189
|
+
"containerAriaLabel": _propTypes.default.string,
|
|
190
|
+
"onClose": _propTypes.default.func,
|
|
191
|
+
"onOpen": _propTypes.default.func,
|
|
192
|
+
"open": _propTypes.default.bool,
|
|
193
|
+
"openButtonAriaLabel": _propTypes.default.string,
|
|
194
|
+
"p": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
195
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
196
|
+
"description": _propTypes.default.string,
|
|
197
|
+
"toString": _propTypes.default.func.isRequired,
|
|
198
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
199
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
200
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
201
|
+
"description": _propTypes.default.string,
|
|
202
|
+
"toString": _propTypes.default.func.isRequired,
|
|
203
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
204
|
+
}), _propTypes.default.string]),
|
|
205
|
+
"padding": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
206
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
207
|
+
"description": _propTypes.default.string,
|
|
208
|
+
"toString": _propTypes.default.func.isRequired,
|
|
209
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
210
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
211
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
212
|
+
"description": _propTypes.default.string,
|
|
213
|
+
"toString": _propTypes.default.func.isRequired,
|
|
214
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
215
|
+
}), _propTypes.default.string]),
|
|
216
|
+
"paddingBottom": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
217
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
218
|
+
"description": _propTypes.default.string,
|
|
219
|
+
"toString": _propTypes.default.func.isRequired,
|
|
220
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
221
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
222
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
223
|
+
"description": _propTypes.default.string,
|
|
224
|
+
"toString": _propTypes.default.func.isRequired,
|
|
225
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
226
|
+
}), _propTypes.default.string]),
|
|
227
|
+
"paddingLeft": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
228
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
229
|
+
"description": _propTypes.default.string,
|
|
230
|
+
"toString": _propTypes.default.func.isRequired,
|
|
231
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
232
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
233
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
234
|
+
"description": _propTypes.default.string,
|
|
235
|
+
"toString": _propTypes.default.func.isRequired,
|
|
236
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
237
|
+
}), _propTypes.default.string]),
|
|
238
|
+
"paddingRight": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
239
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
240
|
+
"description": _propTypes.default.string,
|
|
241
|
+
"toString": _propTypes.default.func.isRequired,
|
|
242
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
243
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
244
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
245
|
+
"description": _propTypes.default.string,
|
|
246
|
+
"toString": _propTypes.default.func.isRequired,
|
|
247
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
248
|
+
}), _propTypes.default.string]),
|
|
249
|
+
"paddingTop": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
250
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
251
|
+
"description": _propTypes.default.string,
|
|
252
|
+
"toString": _propTypes.default.func.isRequired,
|
|
253
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
254
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
255
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
256
|
+
"description": _propTypes.default.string,
|
|
257
|
+
"toString": _propTypes.default.func.isRequired,
|
|
258
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
259
|
+
}), _propTypes.default.string]),
|
|
260
|
+
"paddingX": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
261
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
262
|
+
"description": _propTypes.default.string,
|
|
263
|
+
"toString": _propTypes.default.func.isRequired,
|
|
264
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
265
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
266
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
267
|
+
"description": _propTypes.default.string,
|
|
268
|
+
"toString": _propTypes.default.func.isRequired,
|
|
269
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
270
|
+
}), _propTypes.default.string]),
|
|
271
|
+
"paddingY": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
272
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
273
|
+
"description": _propTypes.default.string,
|
|
274
|
+
"toString": _propTypes.default.func.isRequired,
|
|
275
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
276
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
277
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
278
|
+
"description": _propTypes.default.string,
|
|
279
|
+
"toString": _propTypes.default.func.isRequired,
|
|
280
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
281
|
+
}), _propTypes.default.string]),
|
|
282
|
+
"pb": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
283
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
284
|
+
"description": _propTypes.default.string,
|
|
285
|
+
"toString": _propTypes.default.func.isRequired,
|
|
286
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
287
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
288
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
289
|
+
"description": _propTypes.default.string,
|
|
290
|
+
"toString": _propTypes.default.func.isRequired,
|
|
291
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
292
|
+
}), _propTypes.default.string]),
|
|
293
|
+
"pl": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
294
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
295
|
+
"description": _propTypes.default.string,
|
|
296
|
+
"toString": _propTypes.default.func.isRequired,
|
|
297
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
298
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
299
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
300
|
+
"description": _propTypes.default.string,
|
|
301
|
+
"toString": _propTypes.default.func.isRequired,
|
|
302
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
303
|
+
}), _propTypes.default.string]),
|
|
304
|
+
"position": _propTypes.default.oneOf(["left", "right"]),
|
|
305
|
+
"pr": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
306
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
307
|
+
"description": _propTypes.default.string,
|
|
308
|
+
"toString": _propTypes.default.func.isRequired,
|
|
309
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
310
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
311
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
312
|
+
"description": _propTypes.default.string,
|
|
313
|
+
"toString": _propTypes.default.func.isRequired,
|
|
314
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
315
|
+
}), _propTypes.default.string]),
|
|
316
|
+
"pt": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
317
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
318
|
+
"description": _propTypes.default.string,
|
|
319
|
+
"toString": _propTypes.default.func.isRequired,
|
|
320
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
321
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
322
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
323
|
+
"description": _propTypes.default.string,
|
|
324
|
+
"toString": _propTypes.default.func.isRequired,
|
|
325
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
326
|
+
}), _propTypes.default.string]),
|
|
327
|
+
"px": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
328
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
329
|
+
"description": _propTypes.default.string,
|
|
330
|
+
"toString": _propTypes.default.func.isRequired,
|
|
331
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
332
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
333
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
334
|
+
"description": _propTypes.default.string,
|
|
335
|
+
"toString": _propTypes.default.func.isRequired,
|
|
336
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
337
|
+
}), _propTypes.default.string]),
|
|
338
|
+
"py": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
339
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
340
|
+
"description": _propTypes.default.string,
|
|
341
|
+
"toString": _propTypes.default.func.isRequired,
|
|
342
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
343
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
344
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
345
|
+
"description": _propTypes.default.string,
|
|
346
|
+
"toString": _propTypes.default.func.isRequired,
|
|
347
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
348
|
+
}), _propTypes.default.string]),
|
|
349
|
+
"renderCloseComponent": _propTypes.default.func,
|
|
350
|
+
"renderOpenComponent": _propTypes.default.func,
|
|
351
|
+
"shouldCoverButton": _propTypes.default.bool,
|
|
352
|
+
"title": _propTypes.default.string
|
|
227
353
|
};
|
|
228
354
|
var _default = PopoverContainer;
|
|
229
355
|
exports.default = _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TransitionStatus } from "react-transition-group";
|
|
2
|
+
import IconButton from "../icon-button";
|
|
3
|
+
declare const PopoverContainerWrapperStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
declare const PopoverContainerHeaderStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
declare type PopoverContainerContentStyleProps = {
|
|
6
|
+
shouldCoverButton?: boolean;
|
|
7
|
+
position?: "left" | "right";
|
|
8
|
+
animationState?: TransitionStatus;
|
|
9
|
+
};
|
|
10
|
+
declare const PopoverContainerContentStyle: import("styled-components").StyledComponent<"div", any, PopoverContainerContentStyleProps, never>;
|
|
11
|
+
declare type AdditionalIconButtonProps = {
|
|
12
|
+
tabIndex?: number;
|
|
13
|
+
id?: string;
|
|
14
|
+
};
|
|
15
|
+
declare const PopoverContainerOpenIcon: import("styled-components").StyledComponent<typeof IconButton, any, AdditionalIconButtonProps, never>;
|
|
16
|
+
declare const PopoverContainerCloseIcon: import("styled-components").StyledComponent<typeof IconButton, any, AdditionalIconButtonProps, never>;
|
|
17
|
+
declare const PopoverContainerTitleStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
18
|
+
export { PopoverContainerWrapperStyle, PopoverContainerHeaderStyle, PopoverContainerContentStyle, PopoverContainerCloseIcon, PopoverContainerTitleStyle, PopoverContainerOpenIcon, };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PaddingProps } from "styled-system";
|
|
2
2
|
export declare const paddingPropertyNames: string[];
|
|
3
|
-
export default function filterStyledSystemPaddingProps(
|
|
3
|
+
export default function filterStyledSystemPaddingProps(props: Record<string, any>): PaddingProps;
|
|
@@ -13,6 +13,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
13
13
|
const paddingPropertyNames = ["padding", "p", "paddingLeft", "pl", "paddingRight", "pr", "paddingTop", "pt", "paddingBottom", "pb", "paddingX", "px", "paddingY", "py"];
|
|
14
14
|
exports.paddingPropertyNames = paddingPropertyNames;
|
|
15
15
|
|
|
16
|
-
function filterStyledSystemPaddingProps(
|
|
17
|
-
|
|
16
|
+
function filterStyledSystemPaddingProps( // method should accept any react prop
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
props) {
|
|
19
|
+
return (0, _filterObjectProperties.default)(props, paddingPropertyNames);
|
|
18
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "108.0.0",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"engineStrict": true,
|
|
6
6
|
"engines": {
|
|
@@ -99,6 +99,7 @@
|
|
|
99
99
|
"@types/react-dom": "16.9.8",
|
|
100
100
|
"@types/react-is": "^17.0.3",
|
|
101
101
|
"@types/react-test-renderer": "^17.0.1",
|
|
102
|
+
"@types/react-transition-group": "^4.4.4",
|
|
102
103
|
"@types/sprintf-js": "^1.1.2",
|
|
103
104
|
"@types/styled-components": "^5.1.9",
|
|
104
105
|
"@types/uuid": "^8.3.3",
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { PaddingProps } from "styled-system";
|
|
3
|
-
|
|
4
|
-
export interface PopoverContainerProps extends PaddingProps {
|
|
5
|
-
/** The element that will open popover-container */
|
|
6
|
-
renderOpenComponent?: React.ReactNode | Node;
|
|
7
|
-
/** The element that will close popover-container */
|
|
8
|
-
renderCloseComponent?: React.ReactNode | Node;
|
|
9
|
-
/** The content of the popover-container */
|
|
10
|
-
children?: React.ReactNode;
|
|
11
|
-
/** Sets rendering position of dialog */
|
|
12
|
-
position?: "left" | "right";
|
|
13
|
-
/** Sets the popover container dialog header name */
|
|
14
|
-
title?: string;
|
|
15
|
-
/** Callback fires when close icon clicked */
|
|
16
|
-
onClose?: () => void;
|
|
17
|
-
/** if `true` the popover-container is open */
|
|
18
|
-
open?: boolean;
|
|
19
|
-
/** Callback fires when open component is clicked */
|
|
20
|
-
onOpen?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
21
|
-
/** if `true` the popover-container will cover open button */
|
|
22
|
-
shouldCoverButton?: boolean;
|
|
23
|
-
/** The id of the element that describe the dialog. */
|
|
24
|
-
ariaDescribedBy?: string;
|
|
25
|
-
/** Open button aria label */
|
|
26
|
-
openButtonAriaLabel?: string;
|
|
27
|
-
/** Close button aria label */
|
|
28
|
-
closeButtonAriaLabel?: string;
|
|
29
|
-
/** Container aria label */
|
|
30
|
-
containerAriaLabel?: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
declare function PopoverContainer(props: PopoverContainerProps): JSX.Element;
|
|
34
|
-
|
|
35
|
-
export default PopoverContainer;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { PaddingProps } from "styled-system";
|
|
3
|
-
|
|
4
|
-
export interface PopoverContainerProps extends PaddingProps {
|
|
5
|
-
/** The element that will open popover-container */
|
|
6
|
-
renderOpenComponent?: React.ReactNode | Node;
|
|
7
|
-
/** The element that will close popover-container */
|
|
8
|
-
renderCloseComponent?: React.ReactNode | Node;
|
|
9
|
-
/** The content of the popover-container */
|
|
10
|
-
children?: React.ReactNode;
|
|
11
|
-
/** Sets rendering position of dialog */
|
|
12
|
-
position?: "left" | "right";
|
|
13
|
-
/** Sets the popover container dialog header name */
|
|
14
|
-
title?: string;
|
|
15
|
-
/** Callback fires when close icon clicked */
|
|
16
|
-
onClose?: () => void;
|
|
17
|
-
/** if `true` the popover-container is open */
|
|
18
|
-
open?: boolean;
|
|
19
|
-
/** Callback fires when open component is clicked */
|
|
20
|
-
onOpen?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
21
|
-
/** if `true` the popover-container will cover open button */
|
|
22
|
-
shouldCoverButton?: boolean;
|
|
23
|
-
/** The id of the element that describe the dialog. */
|
|
24
|
-
ariaDescribedBy?: string;
|
|
25
|
-
/** Open button aria label */
|
|
26
|
-
openButtonAriaLabel?: string;
|
|
27
|
-
/** Close button aria label */
|
|
28
|
-
closeButtonAriaLabel?: string;
|
|
29
|
-
/** Container aria label */
|
|
30
|
-
containerAriaLabel?: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
declare function PopoverContainer(props: PopoverContainerProps): JSX.Element;
|
|
34
|
-
|
|
35
|
-
export default PopoverContainer;
|