import { ReactNode } from 'react'; import Controller from './Controller'; import Box from '../Box'; import { Overflow } from '../boxTypes'; import { useDefaultLabelContext } from '../contexts/DefaultLabelProvider'; import Flex from '../Flex'; import InternalIconCompactButton from '../IconButton/InternalIconCompactButton'; import InternalDismissButton from '../sharedSubcomponents/InternalDismissButton'; import useExperimentalTheme from '../utils/useExperimentalTheme'; type Color = 'blue' | 'white' | 'darkGray'; type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'flexible' | number; type Role = 'dialog' | 'listbox' | 'menu' | 'tooltip'; type Props = { accessibilityLabel?: string; accessibilityDismissButtonLabel?: string; anchor: HTMLElement | null | undefined; children?: ReactNode; color?: Color; onKeyDown?: (arg1: { event: React.KeyboardEvent }) => void; id?: string; idealDirection?: 'up' | 'right' | 'down' | 'left'; forceDirection?: boolean; onDismiss: () => void; role?: Role; shouldFocus?: boolean; showCaret?: boolean; showDismissButton?: boolean; size?: Size; disablePortal?: boolean; scrollBoundary?: HTMLElement; hideWhenReferenceHidden?: boolean; onPositioned?: () => void; disableFocusTrap?: boolean; overflow?: Extract; }; export default function InternalPopover({ accessibilityLabel, accessibilityDismissButtonLabel, anchor, children, showDismissButton, onKeyDown, id, idealDirection, forceDirection, onDismiss, color = 'white', role, shouldFocus, showCaret, size = 'sm', disablePortal, scrollBoundary, hideWhenReferenceHidden, onPositioned, disableFocusTrap = false, overflow = 'auto', }: Props) { const { accessibilityDismissButtonLabel: accessibilityDismissButtonLabelDefault } = useDefaultLabelContext('Popover'); const theme = useExperimentalTheme(); if (!anchor) { return null; } return ( {showDismissButton && ( {theme.MAIN ? ( ) : ( )} )} {children} ); }