carbon-react 146.4.6 → 146.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/components/popover-container/index.d.ts +1 -1
- package/esm/components/popover-container/popover-container.component.d.ts +6 -1
- package/esm/components/popover-container/popover-container.component.js +199 -6
- package/esm/components/popover-container/popover-container.style.d.ts +4 -1
- package/esm/components/popover-container/popover-container.style.js +26 -1
- package/esm/components/search/search.component.js +2 -2
- package/esm/hooks/__internal__/useFocusPortalContent/useFocusPortalContent.js +6 -5
- package/lib/components/popover-container/index.d.ts +1 -1
- package/lib/components/popover-container/popover-container.component.d.ts +6 -1
- package/lib/components/popover-container/popover-container.component.js +197 -6
- package/lib/components/popover-container/popover-container.style.d.ts +4 -1
- package/lib/components/popover-container/popover-container.style.js +26 -1
- package/lib/components/search/search.component.js +2 -2
- package/lib/hooks/__internal__/useFocusPortalContent/useFocusPortalContent.js +6 -5
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from "./popover-container.component";
|
|
2
|
-
export type { PopoverContainerProps, RenderCloseProps, RenderOpenProps, } from "./popover-container.component";
|
|
2
|
+
export type { PopoverContainerProps, RenderCloseProps, RenderOpenProps, PopoverContainerHandle, } from "./popover-container.component";
|
|
@@ -61,6 +61,11 @@ export interface PopoverContainerProps extends PaddingProps {
|
|
|
61
61
|
containerAriaLabel?: string;
|
|
62
62
|
/** Disables the animation for the component */
|
|
63
63
|
disableAnimation?: boolean;
|
|
64
|
+
/** Flag to enable fullWidth Button styles */
|
|
65
|
+
hasFullWidth?: boolean;
|
|
64
66
|
}
|
|
65
|
-
export declare
|
|
67
|
+
export declare type PopoverContainerHandle = {
|
|
68
|
+
focusButton: () => void;
|
|
69
|
+
} | null;
|
|
70
|
+
export declare const PopoverContainer: React.ForwardRefExoticComponent<PopoverContainerProps & React.RefAttributes<PopoverContainerHandle>>;
|
|
66
71
|
export default PopoverContainer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React, { useCallback, useEffect, useRef, useState, useMemo } from "react";
|
|
2
|
+
import React, { useCallback, useEffect, useRef, useState, useMemo, useImperativeHandle, forwardRef } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { CSSTransition } from "react-transition-group";
|
|
5
5
|
import { flip, offset } from "@floating-ui/dom";
|
|
@@ -66,7 +66,7 @@ function usePopoverMiddleware(shouldCoverButton) {
|
|
|
66
66
|
fallbackStrategy: "initialPlacement"
|
|
67
67
|
})], [shouldCoverButton]);
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
const PopoverContainer = /*#__PURE__*/forwardRef(({
|
|
70
70
|
children,
|
|
71
71
|
title,
|
|
72
72
|
position = "right",
|
|
@@ -82,8 +82,9 @@ export const PopoverContainer = ({
|
|
|
82
82
|
containerAriaLabel,
|
|
83
83
|
closeButtonDataProps,
|
|
84
84
|
disableAnimation = false,
|
|
85
|
+
hasFullWidth = false,
|
|
85
86
|
...rest
|
|
86
|
-
}) => {
|
|
87
|
+
}, ref) => {
|
|
87
88
|
const isControlled = open !== undefined;
|
|
88
89
|
const [isOpenInternal, setIsOpenInternal] = useState(false);
|
|
89
90
|
const closeButtonRef = useRef(null);
|
|
@@ -117,6 +118,13 @@ export const PopoverContainer = ({
|
|
|
117
118
|
document.removeEventListener("keydown", handleEscKey);
|
|
118
119
|
};
|
|
119
120
|
}, [handleEscKey]);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (!shouldCoverButton && isOpen) {
|
|
123
|
+
popoverContentNodeRef.current?.focus({
|
|
124
|
+
preventScroll: true
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}, [isOpen, shouldCoverButton, popoverContentNodeRef]);
|
|
120
128
|
const handleOpenButtonClick = e => {
|
|
121
129
|
/* istanbul ignore else */
|
|
122
130
|
if (!isControlled) setIsOpenInternal(!isOpen);
|
|
@@ -171,6 +179,11 @@ export const PopoverContainer = ({
|
|
|
171
179
|
};
|
|
172
180
|
const handleClick = useClickAwayListener(handleClickAway, "mousedown");
|
|
173
181
|
const [isAnimationComplete, setIsAnimationComplete] = useState(false);
|
|
182
|
+
useImperativeHandle(ref, () => ({
|
|
183
|
+
focusButton() {
|
|
184
|
+
openButtonRef.current?.focus();
|
|
185
|
+
}
|
|
186
|
+
}), []);
|
|
174
187
|
const popover = () => /*#__PURE__*/React.createElement(PopoverContainerContentStyle, _extends({
|
|
175
188
|
"data-element": "popover-container-content",
|
|
176
189
|
role: "dialog",
|
|
@@ -179,7 +192,7 @@ export const PopoverContainer = ({
|
|
|
179
192
|
"aria-describedby": ariaDescribedBy,
|
|
180
193
|
p: "16px 24px",
|
|
181
194
|
ref: popoverContentNodeRef,
|
|
182
|
-
tabIndex:
|
|
195
|
+
tabIndex: -1,
|
|
183
196
|
disableAnimation: disableAnimation || reduceMotion
|
|
184
197
|
}, filterStyledSystemPaddingProps(rest)), /*#__PURE__*/React.createElement(PopoverContainerHeaderStyle, null, /*#__PURE__*/React.createElement(PopoverContainerTitleStyle, {
|
|
185
198
|
id: popoverContainerId,
|
|
@@ -209,7 +222,9 @@ export const PopoverContainer = ({
|
|
|
209
222
|
}));
|
|
210
223
|
return /*#__PURE__*/React.createElement(PopoverContainerWrapperStyle, {
|
|
211
224
|
"data-component": "popover-container",
|
|
212
|
-
|
|
225
|
+
"data-role": "popover-container",
|
|
226
|
+
onMouseDown: handleClick,
|
|
227
|
+
hasFullWidth: hasFullWidth
|
|
213
228
|
}, /*#__PURE__*/React.createElement("div", {
|
|
214
229
|
ref: popoverReference
|
|
215
230
|
}, renderOpenComponent(renderOpenComponentProps)), /*#__PURE__*/React.createElement(CSSTransition, {
|
|
@@ -228,5 +243,183 @@ export const PopoverContainer = ({
|
|
|
228
243
|
middleware: popoverMiddleware,
|
|
229
244
|
childRefOverride: popoverContentNodeRef
|
|
230
245
|
}, childrenToRender())));
|
|
231
|
-
};
|
|
246
|
+
});
|
|
247
|
+
if (process.env.NODE_ENV !== "production") {
|
|
248
|
+
PopoverContainer.propTypes = {
|
|
249
|
+
"ariaDescribedBy": PropTypes.string,
|
|
250
|
+
"children": PropTypes.node,
|
|
251
|
+
"closeButtonAriaLabel": PropTypes.string,
|
|
252
|
+
"closeButtonDataProps": PropTypes.shape({
|
|
253
|
+
"data-element": PropTypes.string,
|
|
254
|
+
"data-role": PropTypes.string
|
|
255
|
+
}),
|
|
256
|
+
"containerAriaLabel": PropTypes.string,
|
|
257
|
+
"disableAnimation": PropTypes.bool,
|
|
258
|
+
"hasFullWidth": PropTypes.bool,
|
|
259
|
+
"onClose": PropTypes.func,
|
|
260
|
+
"onOpen": PropTypes.func,
|
|
261
|
+
"open": PropTypes.bool,
|
|
262
|
+
"openButtonAriaLabel": PropTypes.string,
|
|
263
|
+
"p": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
264
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
265
|
+
"description": PropTypes.string,
|
|
266
|
+
"toString": PropTypes.func.isRequired,
|
|
267
|
+
"valueOf": PropTypes.func.isRequired
|
|
268
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
269
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
270
|
+
"description": PropTypes.string,
|
|
271
|
+
"toString": PropTypes.func.isRequired,
|
|
272
|
+
"valueOf": PropTypes.func.isRequired
|
|
273
|
+
}), PropTypes.string]),
|
|
274
|
+
"padding": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
275
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
276
|
+
"description": PropTypes.string,
|
|
277
|
+
"toString": PropTypes.func.isRequired,
|
|
278
|
+
"valueOf": PropTypes.func.isRequired
|
|
279
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
280
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
281
|
+
"description": PropTypes.string,
|
|
282
|
+
"toString": PropTypes.func.isRequired,
|
|
283
|
+
"valueOf": PropTypes.func.isRequired
|
|
284
|
+
}), PropTypes.string]),
|
|
285
|
+
"paddingBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
286
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
287
|
+
"description": PropTypes.string,
|
|
288
|
+
"toString": PropTypes.func.isRequired,
|
|
289
|
+
"valueOf": PropTypes.func.isRequired
|
|
290
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
291
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
292
|
+
"description": PropTypes.string,
|
|
293
|
+
"toString": PropTypes.func.isRequired,
|
|
294
|
+
"valueOf": PropTypes.func.isRequired
|
|
295
|
+
}), PropTypes.string]),
|
|
296
|
+
"paddingLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
297
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
298
|
+
"description": PropTypes.string,
|
|
299
|
+
"toString": PropTypes.func.isRequired,
|
|
300
|
+
"valueOf": PropTypes.func.isRequired
|
|
301
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
302
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
303
|
+
"description": PropTypes.string,
|
|
304
|
+
"toString": PropTypes.func.isRequired,
|
|
305
|
+
"valueOf": PropTypes.func.isRequired
|
|
306
|
+
}), PropTypes.string]),
|
|
307
|
+
"paddingRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
308
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
309
|
+
"description": PropTypes.string,
|
|
310
|
+
"toString": PropTypes.func.isRequired,
|
|
311
|
+
"valueOf": PropTypes.func.isRequired
|
|
312
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
313
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
314
|
+
"description": PropTypes.string,
|
|
315
|
+
"toString": PropTypes.func.isRequired,
|
|
316
|
+
"valueOf": PropTypes.func.isRequired
|
|
317
|
+
}), PropTypes.string]),
|
|
318
|
+
"paddingTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
319
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
320
|
+
"description": PropTypes.string,
|
|
321
|
+
"toString": PropTypes.func.isRequired,
|
|
322
|
+
"valueOf": PropTypes.func.isRequired
|
|
323
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
324
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
325
|
+
"description": PropTypes.string,
|
|
326
|
+
"toString": PropTypes.func.isRequired,
|
|
327
|
+
"valueOf": PropTypes.func.isRequired
|
|
328
|
+
}), PropTypes.string]),
|
|
329
|
+
"paddingX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
330
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
331
|
+
"description": PropTypes.string,
|
|
332
|
+
"toString": PropTypes.func.isRequired,
|
|
333
|
+
"valueOf": PropTypes.func.isRequired
|
|
334
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
335
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
336
|
+
"description": PropTypes.string,
|
|
337
|
+
"toString": PropTypes.func.isRequired,
|
|
338
|
+
"valueOf": PropTypes.func.isRequired
|
|
339
|
+
}), PropTypes.string]),
|
|
340
|
+
"paddingY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
341
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
342
|
+
"description": PropTypes.string,
|
|
343
|
+
"toString": PropTypes.func.isRequired,
|
|
344
|
+
"valueOf": PropTypes.func.isRequired
|
|
345
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
346
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
347
|
+
"description": PropTypes.string,
|
|
348
|
+
"toString": PropTypes.func.isRequired,
|
|
349
|
+
"valueOf": PropTypes.func.isRequired
|
|
350
|
+
}), PropTypes.string]),
|
|
351
|
+
"pb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
352
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
353
|
+
"description": PropTypes.string,
|
|
354
|
+
"toString": PropTypes.func.isRequired,
|
|
355
|
+
"valueOf": PropTypes.func.isRequired
|
|
356
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
357
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
358
|
+
"description": PropTypes.string,
|
|
359
|
+
"toString": PropTypes.func.isRequired,
|
|
360
|
+
"valueOf": PropTypes.func.isRequired
|
|
361
|
+
}), PropTypes.string]),
|
|
362
|
+
"pl": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
363
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
364
|
+
"description": PropTypes.string,
|
|
365
|
+
"toString": PropTypes.func.isRequired,
|
|
366
|
+
"valueOf": PropTypes.func.isRequired
|
|
367
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
368
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
369
|
+
"description": PropTypes.string,
|
|
370
|
+
"toString": PropTypes.func.isRequired,
|
|
371
|
+
"valueOf": PropTypes.func.isRequired
|
|
372
|
+
}), PropTypes.string]),
|
|
373
|
+
"position": PropTypes.oneOf(["left", "right"]),
|
|
374
|
+
"pr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
375
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
376
|
+
"description": PropTypes.string,
|
|
377
|
+
"toString": PropTypes.func.isRequired,
|
|
378
|
+
"valueOf": PropTypes.func.isRequired
|
|
379
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
380
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
381
|
+
"description": PropTypes.string,
|
|
382
|
+
"toString": PropTypes.func.isRequired,
|
|
383
|
+
"valueOf": PropTypes.func.isRequired
|
|
384
|
+
}), PropTypes.string]),
|
|
385
|
+
"pt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
386
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
387
|
+
"description": PropTypes.string,
|
|
388
|
+
"toString": PropTypes.func.isRequired,
|
|
389
|
+
"valueOf": PropTypes.func.isRequired
|
|
390
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
391
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
392
|
+
"description": PropTypes.string,
|
|
393
|
+
"toString": PropTypes.func.isRequired,
|
|
394
|
+
"valueOf": PropTypes.func.isRequired
|
|
395
|
+
}), PropTypes.string]),
|
|
396
|
+
"px": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
397
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
398
|
+
"description": PropTypes.string,
|
|
399
|
+
"toString": PropTypes.func.isRequired,
|
|
400
|
+
"valueOf": PropTypes.func.isRequired
|
|
401
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
402
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
403
|
+
"description": PropTypes.string,
|
|
404
|
+
"toString": PropTypes.func.isRequired,
|
|
405
|
+
"valueOf": PropTypes.func.isRequired
|
|
406
|
+
}), PropTypes.string]),
|
|
407
|
+
"py": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
408
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
409
|
+
"description": PropTypes.string,
|
|
410
|
+
"toString": PropTypes.func.isRequired,
|
|
411
|
+
"valueOf": PropTypes.func.isRequired
|
|
412
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
413
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
414
|
+
"description": PropTypes.string,
|
|
415
|
+
"toString": PropTypes.func.isRequired,
|
|
416
|
+
"valueOf": PropTypes.func.isRequired
|
|
417
|
+
}), PropTypes.string]),
|
|
418
|
+
"renderCloseComponent": PropTypes.func,
|
|
419
|
+
"renderOpenComponent": PropTypes.func,
|
|
420
|
+
"shouldCoverButton": PropTypes.bool,
|
|
421
|
+
"title": PropTypes.string
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
export { PopoverContainer };
|
|
232
425
|
export default PopoverContainer;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TransitionStatus } from "react-transition-group";
|
|
3
|
-
declare
|
|
3
|
+
declare type PopoverContainerWrapperProps = {
|
|
4
|
+
hasFullWidth?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare const PopoverContainerWrapperStyle: import("styled-components").StyledComponent<"div", any, PopoverContainerWrapperProps, never>;
|
|
4
7
|
declare const PopoverContainerHeaderStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
8
|
declare type PopoverContainerContentStyleProps = {
|
|
6
9
|
animationState?: TransitionStatus;
|
|
@@ -3,10 +3,16 @@ import { padding } from "styled-system";
|
|
|
3
3
|
import { baseTheme } from "../../style/themes";
|
|
4
4
|
import IconButton from "../icon-button";
|
|
5
5
|
import StyledIcon from "../icon/icon.style";
|
|
6
|
+
import { StyledForm, StyledFormContent, StyledFormFooter } from "../form/form.style";
|
|
6
7
|
const PopoverContainerWrapperStyle = styled.div`
|
|
7
8
|
position: relative;
|
|
8
9
|
display: inline-block;
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
${({
|
|
12
|
+
hasFullWidth
|
|
13
|
+
}) => hasFullWidth && css`
|
|
14
|
+
width: 100%;
|
|
15
|
+
`}
|
|
10
16
|
`;
|
|
11
17
|
const PopoverContainerHeaderStyle = styled.div`
|
|
12
18
|
display: flex;
|
|
@@ -60,6 +66,25 @@ const PopoverContainerContentStyle = styled.div`
|
|
|
60
66
|
:focus {
|
|
61
67
|
outline: none;
|
|
62
68
|
}
|
|
69
|
+
|
|
70
|
+
&:has(${StyledForm}.sticky) {
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
padding: 0;
|
|
74
|
+
|
|
75
|
+
${StyledForm}.sticky {
|
|
76
|
+
${StyledFormContent} {
|
|
77
|
+
flex-grow: 1;
|
|
78
|
+
min-height: 0;
|
|
79
|
+
overflow-y: auto;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
${StyledFormFooter} {
|
|
83
|
+
border-bottom-right-radius: var(--borderRadius200);
|
|
84
|
+
border-bottom-left-radius: var(--borderRadius200);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
63
88
|
`;
|
|
64
89
|
const PopoverContainerOpenIcon = styled(IconButton)`
|
|
65
90
|
${StyledIcon} {
|
|
@@ -24,7 +24,7 @@ const Search = /*#__PURE__*/React.forwardRef(({
|
|
|
24
24
|
searchWidth,
|
|
25
25
|
maxWidth,
|
|
26
26
|
searchButton,
|
|
27
|
-
searchButtonAriaLabel
|
|
27
|
+
searchButtonAriaLabel,
|
|
28
28
|
placeholder,
|
|
29
29
|
variant = "default",
|
|
30
30
|
"aria-label": ariaLabel = "search",
|
|
@@ -168,7 +168,7 @@ const Search = /*#__PURE__*/React.forwardRef(({
|
|
|
168
168
|
}) : undefined,
|
|
169
169
|
tooltipPosition: tooltipPosition
|
|
170
170
|
}), searchButton && /*#__PURE__*/React.createElement(StyledSearchButton, null, /*#__PURE__*/React.createElement(Button, _extends({
|
|
171
|
-
"aria-label": searchButtonAriaLabel,
|
|
171
|
+
"aria-label": searchButtonAriaLabel || searchButtonText,
|
|
172
172
|
size: "medium",
|
|
173
173
|
px: 2,
|
|
174
174
|
buttonType: "primary",
|
|
@@ -6,20 +6,21 @@ export default (container, target, focusCallback) => {
|
|
|
6
6
|
const handleFocusPortalContent = ev => {
|
|
7
7
|
if (container?.current && target?.current) {
|
|
8
8
|
const focusableElementsInContainer = Array.from(container.current?.querySelectorAll(defaultFocusableSelectors) || /* istanbul ignore next */[]);
|
|
9
|
+
const filteredFocusableElements = focusableElementsInContainer.filter(el => Number(el.tabIndex) !== -1);
|
|
9
10
|
if (target?.current === document.activeElement) {
|
|
10
|
-
if (Events.isTabKey(ev) && !Events.isShiftKey(ev) &&
|
|
11
|
+
if (Events.isTabKey(ev) && !Events.isShiftKey(ev) && filteredFocusableElements[0]) {
|
|
11
12
|
ev.preventDefault();
|
|
12
|
-
|
|
13
|
+
filteredFocusableElements[0]?.focus();
|
|
13
14
|
}
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
/* istanbul ignore if */
|
|
18
|
-
if (!
|
|
19
|
+
if (!filteredFocusableElements.length) {
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
|
-
const lastElementFocused =
|
|
22
|
-
const firstElementFocused =
|
|
22
|
+
const lastElementFocused = filteredFocusableElements[filteredFocusableElements.length - 1] === document.activeElement;
|
|
23
|
+
const firstElementFocused = filteredFocusableElements[0] === document.activeElement;
|
|
23
24
|
if (Events.isTabKey(ev)) {
|
|
24
25
|
// last element focused inside portal navigate to next element in DOM after the target/ trigger element
|
|
25
26
|
if (lastElementFocused && !Events.isShiftKey(ev)) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from "./popover-container.component";
|
|
2
|
-
export type { PopoverContainerProps, RenderCloseProps, RenderOpenProps, } from "./popover-container.component";
|
|
2
|
+
export type { PopoverContainerProps, RenderCloseProps, RenderOpenProps, PopoverContainerHandle, } from "./popover-container.component";
|
|
@@ -61,6 +61,11 @@ export interface PopoverContainerProps extends PaddingProps {
|
|
|
61
61
|
containerAriaLabel?: string;
|
|
62
62
|
/** Disables the animation for the component */
|
|
63
63
|
disableAnimation?: boolean;
|
|
64
|
+
/** Flag to enable fullWidth Button styles */
|
|
65
|
+
hasFullWidth?: boolean;
|
|
64
66
|
}
|
|
65
|
-
export declare
|
|
67
|
+
export declare type PopoverContainerHandle = {
|
|
68
|
+
focusButton: () => void;
|
|
69
|
+
} | null;
|
|
70
|
+
export declare const PopoverContainer: React.ForwardRefExoticComponent<PopoverContainerProps & React.RefAttributes<PopoverContainerHandle>>;
|
|
66
71
|
export default PopoverContainer;
|
|
@@ -77,7 +77,7 @@ function usePopoverMiddleware(shouldCoverButton) {
|
|
|
77
77
|
fallbackStrategy: "initialPlacement"
|
|
78
78
|
})], [shouldCoverButton]);
|
|
79
79
|
}
|
|
80
|
-
const PopoverContainer = ({
|
|
80
|
+
const PopoverContainer = exports.PopoverContainer = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
81
81
|
children,
|
|
82
82
|
title,
|
|
83
83
|
position = "right",
|
|
@@ -93,8 +93,9 @@ const PopoverContainer = ({
|
|
|
93
93
|
containerAriaLabel,
|
|
94
94
|
closeButtonDataProps,
|
|
95
95
|
disableAnimation = false,
|
|
96
|
+
hasFullWidth = false,
|
|
96
97
|
...rest
|
|
97
|
-
}) => {
|
|
98
|
+
}, ref) => {
|
|
98
99
|
const isControlled = open !== undefined;
|
|
99
100
|
const [isOpenInternal, setIsOpenInternal] = (0, _react.useState)(false);
|
|
100
101
|
const closeButtonRef = (0, _react.useRef)(null);
|
|
@@ -128,6 +129,13 @@ const PopoverContainer = ({
|
|
|
128
129
|
document.removeEventListener("keydown", handleEscKey);
|
|
129
130
|
};
|
|
130
131
|
}, [handleEscKey]);
|
|
132
|
+
(0, _react.useEffect)(() => {
|
|
133
|
+
if (!shouldCoverButton && isOpen) {
|
|
134
|
+
popoverContentNodeRef.current?.focus({
|
|
135
|
+
preventScroll: true
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}, [isOpen, shouldCoverButton, popoverContentNodeRef]);
|
|
131
139
|
const handleOpenButtonClick = e => {
|
|
132
140
|
/* istanbul ignore else */
|
|
133
141
|
if (!isControlled) setIsOpenInternal(!isOpen);
|
|
@@ -182,6 +190,11 @@ const PopoverContainer = ({
|
|
|
182
190
|
};
|
|
183
191
|
const handleClick = (0, _useClickAwayListener.default)(handleClickAway, "mousedown");
|
|
184
192
|
const [isAnimationComplete, setIsAnimationComplete] = (0, _react.useState)(false);
|
|
193
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
194
|
+
focusButton() {
|
|
195
|
+
openButtonRef.current?.focus();
|
|
196
|
+
}
|
|
197
|
+
}), []);
|
|
185
198
|
const popover = () => /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerContentStyle, _extends({
|
|
186
199
|
"data-element": "popover-container-content",
|
|
187
200
|
role: "dialog",
|
|
@@ -190,7 +203,7 @@ const PopoverContainer = ({
|
|
|
190
203
|
"aria-describedby": ariaDescribedBy,
|
|
191
204
|
p: "16px 24px",
|
|
192
205
|
ref: popoverContentNodeRef,
|
|
193
|
-
tabIndex:
|
|
206
|
+
tabIndex: -1,
|
|
194
207
|
disableAnimation: disableAnimation || reduceMotion
|
|
195
208
|
}, (0, _utils.filterStyledSystemPaddingProps)(rest)), /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerHeaderStyle, null, /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerTitleStyle, {
|
|
196
209
|
id: popoverContainerId,
|
|
@@ -220,7 +233,9 @@ const PopoverContainer = ({
|
|
|
220
233
|
}));
|
|
221
234
|
return /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerWrapperStyle, {
|
|
222
235
|
"data-component": "popover-container",
|
|
223
|
-
|
|
236
|
+
"data-role": "popover-container",
|
|
237
|
+
onMouseDown: handleClick,
|
|
238
|
+
hasFullWidth: hasFullWidth
|
|
224
239
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
225
240
|
ref: popoverReference
|
|
226
241
|
}, renderOpenComponent(renderOpenComponentProps)), /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.CSSTransition, {
|
|
@@ -239,6 +254,182 @@ const PopoverContainer = ({
|
|
|
239
254
|
middleware: popoverMiddleware,
|
|
240
255
|
childRefOverride: popoverContentNodeRef
|
|
241
256
|
}, childrenToRender())));
|
|
242
|
-
};
|
|
243
|
-
|
|
257
|
+
});
|
|
258
|
+
if (process.env.NODE_ENV !== "production") {
|
|
259
|
+
PopoverContainer.propTypes = {
|
|
260
|
+
"ariaDescribedBy": _propTypes.default.string,
|
|
261
|
+
"children": _propTypes.default.node,
|
|
262
|
+
"closeButtonAriaLabel": _propTypes.default.string,
|
|
263
|
+
"closeButtonDataProps": _propTypes.default.shape({
|
|
264
|
+
"data-element": _propTypes.default.string,
|
|
265
|
+
"data-role": _propTypes.default.string
|
|
266
|
+
}),
|
|
267
|
+
"containerAriaLabel": _propTypes.default.string,
|
|
268
|
+
"disableAnimation": _propTypes.default.bool,
|
|
269
|
+
"hasFullWidth": _propTypes.default.bool,
|
|
270
|
+
"onClose": _propTypes.default.func,
|
|
271
|
+
"onOpen": _propTypes.default.func,
|
|
272
|
+
"open": _propTypes.default.bool,
|
|
273
|
+
"openButtonAriaLabel": _propTypes.default.string,
|
|
274
|
+
"p": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
275
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
276
|
+
"description": _propTypes.default.string,
|
|
277
|
+
"toString": _propTypes.default.func.isRequired,
|
|
278
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
279
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
280
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
281
|
+
"description": _propTypes.default.string,
|
|
282
|
+
"toString": _propTypes.default.func.isRequired,
|
|
283
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
284
|
+
}), _propTypes.default.string]),
|
|
285
|
+
"padding": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
286
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
287
|
+
"description": _propTypes.default.string,
|
|
288
|
+
"toString": _propTypes.default.func.isRequired,
|
|
289
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
290
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
291
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
292
|
+
"description": _propTypes.default.string,
|
|
293
|
+
"toString": _propTypes.default.func.isRequired,
|
|
294
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
295
|
+
}), _propTypes.default.string]),
|
|
296
|
+
"paddingBottom": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
297
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
298
|
+
"description": _propTypes.default.string,
|
|
299
|
+
"toString": _propTypes.default.func.isRequired,
|
|
300
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
301
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
302
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
303
|
+
"description": _propTypes.default.string,
|
|
304
|
+
"toString": _propTypes.default.func.isRequired,
|
|
305
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
306
|
+
}), _propTypes.default.string]),
|
|
307
|
+
"paddingLeft": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
308
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
309
|
+
"description": _propTypes.default.string,
|
|
310
|
+
"toString": _propTypes.default.func.isRequired,
|
|
311
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
312
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
313
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
314
|
+
"description": _propTypes.default.string,
|
|
315
|
+
"toString": _propTypes.default.func.isRequired,
|
|
316
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
317
|
+
}), _propTypes.default.string]),
|
|
318
|
+
"paddingRight": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
319
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
320
|
+
"description": _propTypes.default.string,
|
|
321
|
+
"toString": _propTypes.default.func.isRequired,
|
|
322
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
323
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
324
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
325
|
+
"description": _propTypes.default.string,
|
|
326
|
+
"toString": _propTypes.default.func.isRequired,
|
|
327
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
328
|
+
}), _propTypes.default.string]),
|
|
329
|
+
"paddingTop": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
330
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
331
|
+
"description": _propTypes.default.string,
|
|
332
|
+
"toString": _propTypes.default.func.isRequired,
|
|
333
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
334
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
335
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
336
|
+
"description": _propTypes.default.string,
|
|
337
|
+
"toString": _propTypes.default.func.isRequired,
|
|
338
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
339
|
+
}), _propTypes.default.string]),
|
|
340
|
+
"paddingX": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
341
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
342
|
+
"description": _propTypes.default.string,
|
|
343
|
+
"toString": _propTypes.default.func.isRequired,
|
|
344
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
345
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
346
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
347
|
+
"description": _propTypes.default.string,
|
|
348
|
+
"toString": _propTypes.default.func.isRequired,
|
|
349
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
350
|
+
}), _propTypes.default.string]),
|
|
351
|
+
"paddingY": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
352
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
353
|
+
"description": _propTypes.default.string,
|
|
354
|
+
"toString": _propTypes.default.func.isRequired,
|
|
355
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
356
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
357
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
358
|
+
"description": _propTypes.default.string,
|
|
359
|
+
"toString": _propTypes.default.func.isRequired,
|
|
360
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
361
|
+
}), _propTypes.default.string]),
|
|
362
|
+
"pb": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
363
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
364
|
+
"description": _propTypes.default.string,
|
|
365
|
+
"toString": _propTypes.default.func.isRequired,
|
|
366
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
367
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
368
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
369
|
+
"description": _propTypes.default.string,
|
|
370
|
+
"toString": _propTypes.default.func.isRequired,
|
|
371
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
372
|
+
}), _propTypes.default.string]),
|
|
373
|
+
"pl": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
374
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
375
|
+
"description": _propTypes.default.string,
|
|
376
|
+
"toString": _propTypes.default.func.isRequired,
|
|
377
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
378
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
379
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
380
|
+
"description": _propTypes.default.string,
|
|
381
|
+
"toString": _propTypes.default.func.isRequired,
|
|
382
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
383
|
+
}), _propTypes.default.string]),
|
|
384
|
+
"position": _propTypes.default.oneOf(["left", "right"]),
|
|
385
|
+
"pr": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
386
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
387
|
+
"description": _propTypes.default.string,
|
|
388
|
+
"toString": _propTypes.default.func.isRequired,
|
|
389
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
390
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
391
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
392
|
+
"description": _propTypes.default.string,
|
|
393
|
+
"toString": _propTypes.default.func.isRequired,
|
|
394
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
395
|
+
}), _propTypes.default.string]),
|
|
396
|
+
"pt": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
397
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
398
|
+
"description": _propTypes.default.string,
|
|
399
|
+
"toString": _propTypes.default.func.isRequired,
|
|
400
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
401
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
402
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
403
|
+
"description": _propTypes.default.string,
|
|
404
|
+
"toString": _propTypes.default.func.isRequired,
|
|
405
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
406
|
+
}), _propTypes.default.string]),
|
|
407
|
+
"px": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
408
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
409
|
+
"description": _propTypes.default.string,
|
|
410
|
+
"toString": _propTypes.default.func.isRequired,
|
|
411
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
412
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
413
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
414
|
+
"description": _propTypes.default.string,
|
|
415
|
+
"toString": _propTypes.default.func.isRequired,
|
|
416
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
417
|
+
}), _propTypes.default.string]),
|
|
418
|
+
"py": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
419
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
420
|
+
"description": _propTypes.default.string,
|
|
421
|
+
"toString": _propTypes.default.func.isRequired,
|
|
422
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
423
|
+
}), _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.shape({
|
|
424
|
+
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
425
|
+
"description": _propTypes.default.string,
|
|
426
|
+
"toString": _propTypes.default.func.isRequired,
|
|
427
|
+
"valueOf": _propTypes.default.func.isRequired
|
|
428
|
+
}), _propTypes.default.string]),
|
|
429
|
+
"renderCloseComponent": _propTypes.default.func,
|
|
430
|
+
"renderOpenComponent": _propTypes.default.func,
|
|
431
|
+
"shouldCoverButton": _propTypes.default.bool,
|
|
432
|
+
"title": _propTypes.default.string
|
|
433
|
+
};
|
|
434
|
+
}
|
|
244
435
|
var _default = exports.default = PopoverContainer;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TransitionStatus } from "react-transition-group";
|
|
3
|
-
declare
|
|
3
|
+
declare type PopoverContainerWrapperProps = {
|
|
4
|
+
hasFullWidth?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare const PopoverContainerWrapperStyle: import("styled-components").StyledComponent<"div", any, PopoverContainerWrapperProps, never>;
|
|
4
7
|
declare const PopoverContainerHeaderStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
8
|
declare type PopoverContainerContentStyleProps = {
|
|
6
9
|
animationState?: TransitionStatus;
|
|
@@ -9,13 +9,19 @@ var _styledSystem = require("styled-system");
|
|
|
9
9
|
var _themes = require("../../style/themes");
|
|
10
10
|
var _iconButton = _interopRequireDefault(require("../icon-button"));
|
|
11
11
|
var _icon = _interopRequireDefault(require("../icon/icon.style"));
|
|
12
|
+
var _form = require("../form/form.style");
|
|
12
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
16
|
const PopoverContainerWrapperStyle = exports.PopoverContainerWrapperStyle = _styledComponents.default.div`
|
|
16
17
|
position: relative;
|
|
17
18
|
display: inline-block;
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
${({
|
|
21
|
+
hasFullWidth
|
|
22
|
+
}) => hasFullWidth && (0, _styledComponents.css)`
|
|
23
|
+
width: 100%;
|
|
24
|
+
`}
|
|
19
25
|
`;
|
|
20
26
|
const PopoverContainerHeaderStyle = exports.PopoverContainerHeaderStyle = _styledComponents.default.div`
|
|
21
27
|
display: flex;
|
|
@@ -69,6 +75,25 @@ const PopoverContainerContentStyle = exports.PopoverContainerContentStyle = _sty
|
|
|
69
75
|
:focus {
|
|
70
76
|
outline: none;
|
|
71
77
|
}
|
|
78
|
+
|
|
79
|
+
&:has(${_form.StyledForm}.sticky) {
|
|
80
|
+
display: flex;
|
|
81
|
+
flex-direction: column;
|
|
82
|
+
padding: 0;
|
|
83
|
+
|
|
84
|
+
${_form.StyledForm}.sticky {
|
|
85
|
+
${_form.StyledFormContent} {
|
|
86
|
+
flex-grow: 1;
|
|
87
|
+
min-height: 0;
|
|
88
|
+
overflow-y: auto;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
${_form.StyledFormFooter} {
|
|
92
|
+
border-bottom-right-radius: var(--borderRadius200);
|
|
93
|
+
border-bottom-left-radius: var(--borderRadius200);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
72
97
|
`;
|
|
73
98
|
const PopoverContainerOpenIcon = exports.PopoverContainerOpenIcon = (0, _styledComponents.default)(_iconButton.default)`
|
|
74
99
|
${_icon.default} {
|
|
@@ -33,7 +33,7 @@ const Search = exports.Search = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
33
33
|
searchWidth,
|
|
34
34
|
maxWidth,
|
|
35
35
|
searchButton,
|
|
36
|
-
searchButtonAriaLabel
|
|
36
|
+
searchButtonAriaLabel,
|
|
37
37
|
placeholder,
|
|
38
38
|
variant = "default",
|
|
39
39
|
"aria-label": ariaLabel = "search",
|
|
@@ -177,7 +177,7 @@ const Search = exports.Search = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
177
177
|
}) : undefined,
|
|
178
178
|
tooltipPosition: tooltipPosition
|
|
179
179
|
}), searchButton && /*#__PURE__*/_react.default.createElement(_searchButton.default, null, /*#__PURE__*/_react.default.createElement(_button.default, _extends({
|
|
180
|
-
"aria-label": searchButtonAriaLabel,
|
|
180
|
+
"aria-label": searchButtonAriaLabel || searchButtonText,
|
|
181
181
|
size: "medium",
|
|
182
182
|
px: 2,
|
|
183
183
|
buttonType: "primary",
|
|
@@ -13,20 +13,21 @@ var _default = (container, target, focusCallback) => {
|
|
|
13
13
|
const handleFocusPortalContent = ev => {
|
|
14
14
|
if (container?.current && target?.current) {
|
|
15
15
|
const focusableElementsInContainer = Array.from(container.current?.querySelectorAll(_focusTrapUtils.defaultFocusableSelectors) || /* istanbul ignore next */[]);
|
|
16
|
+
const filteredFocusableElements = focusableElementsInContainer.filter(el => Number(el.tabIndex) !== -1);
|
|
16
17
|
if (target?.current === document.activeElement) {
|
|
17
|
-
if (_events.default.isTabKey(ev) && !_events.default.isShiftKey(ev) &&
|
|
18
|
+
if (_events.default.isTabKey(ev) && !_events.default.isShiftKey(ev) && filteredFocusableElements[0]) {
|
|
18
19
|
ev.preventDefault();
|
|
19
|
-
|
|
20
|
+
filteredFocusableElements[0]?.focus();
|
|
20
21
|
}
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
/* istanbul ignore if */
|
|
25
|
-
if (!
|
|
26
|
+
if (!filteredFocusableElements.length) {
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
|
-
const lastElementFocused =
|
|
29
|
-
const firstElementFocused =
|
|
29
|
+
const lastElementFocused = filteredFocusableElements[filteredFocusableElements.length - 1] === document.activeElement;
|
|
30
|
+
const firstElementFocused = filteredFocusableElements[0] === document.activeElement;
|
|
30
31
|
if (_events.default.isTabKey(ev)) {
|
|
31
32
|
// last element focused inside portal navigate to next element in DOM after the target/ trigger element
|
|
32
33
|
if (lastElementFocused && !_events.default.isShiftKey(ev)) {
|