1- import PropTypes from 'prop-types' ;
21import { CSSProperties , ReactElement , RefCallback } from 'react' ;
32
4- import useOverlay , { OverlayOptions , ReferenceElement } from './useOverlay' ;
5-
6- import { ALIGN_VALUES } from '../../constants' ;
7- import { noop } from '../../utils' ;
8-
9- // `Element` is not defined during server-side rendering, so shim it here.
10- /* istanbul ignore next */
11- const SafeElement = typeof Element === 'undefined' ? noop : Element ;
12-
13- const propTypes = {
14- /**
15- * Specify menu alignment. The default value is `justify`, which makes the
16- * menu as wide as the input and truncates long values. Specifying `left`
17- * or `right` will align the menu to that side and the width will be
18- * determined by the length of menu item values.
19- */
20- align : PropTypes . oneOf ( ALIGN_VALUES ) ,
21- children : PropTypes . func . isRequired ,
22- /**
23- * Specify whether the menu should appear above the input.
24- */
25- dropup : PropTypes . bool ,
26- /**
27- * Whether or not to automatically adjust the position of the menu when it
28- * reaches the viewport boundaries.
29- */
30- flip : PropTypes . bool ,
31- isMenuShown : PropTypes . bool ,
32- positionFixed : PropTypes . bool ,
33- // @ts -ignore
34- referenceElement : PropTypes . instanceOf ( SafeElement ) ,
35- } ;
3+ import { OverlayOptions , ReferenceElement , useOverlay } from '../../core' ;
364
375export interface OverlayRenderProps {
386 innerRef : RefCallback < HTMLElement > ;
@@ -45,16 +13,17 @@ export interface OverlayProps extends OverlayOptions {
4513 referenceElement : ReferenceElement ;
4614}
4715
48- const Overlay = ( { referenceElement, isMenuShown, ...props } : OverlayProps ) => {
16+ /**
17+ * The component is mainly for testing purposes.
18+ */
19+ function Overlay ( { referenceElement, isMenuShown, ...props } : OverlayProps ) {
4920 const overlayProps = useOverlay ( referenceElement , props ) ;
5021
5122 if ( ! isMenuShown ) {
5223 return null ;
5324 }
5425
5526 return props . children ( overlayProps ) ;
56- } ;
57-
58- Overlay . propTypes = propTypes ;
27+ }
5928
6029export default Overlay ;
0 commit comments