1 import type { Ref } from 'react';
2 import { forwardRef, useRef } from 'react';
3 import * as React from 'react';
5 import { useFocusTrap, useHotkeys } from '@proton/components';
6 import { useCombinedRefs } from '@proton/hooks';
7 import clsx from '@proton/utils/clsx';
9 interface Props extends React.HTMLAttributes<HTMLDivElement> {
14 const PopoverContainer = (
15 { children, className, isOpen = true, onClose, ...rest }: Props,
16 ref: Ref<HTMLDivElement>
18 const rootRef = useRef<HTMLDivElement>(null);
19 const combinedRefs = useCombinedRefs<HTMLDivElement>(ref, rootRef);
20 const focusTrapProps = useFocusTrap({ active: isOpen, rootRef });
32 <div ref={combinedRefs} className={clsx([className, 'outline-none'])} {...rest} {...focusTrapProps}>
38 const ForwardPopoverContainer = forwardRef(PopoverContainer);
40 export default ForwardPopoverContainer;