@react-aria/overlays 3.8.2 → 3.10.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.
@@ -11,31 +11,32 @@
11
11
  */
12
12
 
13
13
  import {calculatePosition, PositionResult} from './calculatePosition';
14
- import {HTMLAttributes, RefObject, useCallback, useRef, useState} from 'react';
14
+ import {DOMAttributes} from '@react-types/shared';
15
15
  import {Placement, PlacementAxis, PositionProps} from '@react-types/overlays';
16
+ import {RefObject, useCallback, useRef, useState} from 'react';
16
17
  import {useCloseOnScroll} from './useCloseOnScroll';
17
18
  import {useLayoutEffect} from '@react-aria/utils';
18
19
  import {useLocale} from '@react-aria/i18n';
19
20
 
20
- interface AriaPositionProps extends PositionProps {
21
+ export interface AriaPositionProps extends PositionProps {
21
22
  /**
22
23
  * Element that that serves as the positioning boundary.
23
24
  * @default document.body
24
25
  */
25
- boundaryElement?: HTMLElement,
26
+ boundaryElement?: Element,
26
27
  /**
27
28
  * The ref for the element which the overlay positions itself with respect to.
28
29
  */
29
- targetRef: RefObject<HTMLElement>,
30
+ targetRef: RefObject<Element>,
30
31
  /**
31
32
  * The ref for the overlay element.
32
33
  */
33
- overlayRef: RefObject<HTMLElement>,
34
+ overlayRef: RefObject<Element>,
34
35
  /**
35
36
  * A ref for the scrollable region within the overlay.
36
37
  * @default overlayRef
37
38
  */
38
- scrollRef?: RefObject<HTMLElement>,
39
+ scrollRef?: RefObject<Element>,
39
40
  /**
40
41
  * Whether the overlay should update its position automatically.
41
42
  * @default true
@@ -44,17 +45,17 @@ interface AriaPositionProps extends PositionProps {
44
45
  /** Handler that is called when the overlay should close. */
45
46
  onClose?: () => void,
46
47
  /**
47
- * The maxHeight specified for the overlay element.
48
+ * The maxHeight specified for the overlay element.
48
49
  * By default, it will take all space up to the current viewport height.
49
50
  */
50
51
  maxHeight?: number
51
52
  }
52
53
 
53
- interface PositionAria {
54
+ export interface PositionAria {
54
55
  /** Props for the overlay container element. */
55
- overlayProps: HTMLAttributes<Element>,
56
+ overlayProps: DOMAttributes,
56
57
  /** Props for the overlay tip arrow if any. */
57
- arrowProps: HTMLAttributes<Element>,
58
+ arrowProps: DOMAttributes,
58
59
  /** Placement of the overlay with respect to the overlay trigger. */
59
60
  placement: PlacementAxis,
60
61
  /** Updates the position of the overlay. */
@@ -140,7 +141,7 @@ export function useOverlayPosition(props: AriaPositionProps): PositionAria {
140
141
  // This will ensure that overlays adjust their positioning when the iOS virtual keyboard appears.
141
142
  let isResizing = useRef(false);
142
143
  useLayoutEffect(() => {
143
- let timeout: NodeJS.Timeout;
144
+ let timeout: ReturnType<typeof setTimeout>;
144
145
  let onResize = () => {
145
146
  isResizing.current = true;
146
147
  clearTimeout(timeout);
@@ -11,29 +11,30 @@
11
11
  */
12
12
 
13
13
  import {AriaButtonProps} from '@react-types/button';
14
- import {HTMLAttributes, RefObject, useEffect} from 'react';
14
+ import {DOMAttributes} from '@react-types/shared';
15
15
  import {onCloseMap} from './useCloseOnScroll';
16
16
  import {OverlayTriggerState} from '@react-stately/overlays';
17
+ import {RefObject, useEffect} from 'react';
17
18
  import {useId} from '@react-aria/utils';
18
19
 
19
- interface OverlayTriggerProps {
20
+ export interface OverlayTriggerProps {
20
21
  /** Type of overlay that is opened by the trigger. */
21
22
  type: 'dialog' | 'menu' | 'listbox' | 'tree' | 'grid'
22
23
  }
23
24
 
24
- interface OverlayTriggerAria {
25
+ export interface OverlayTriggerAria {
25
26
  /** Props for the trigger element. */
26
27
  triggerProps: AriaButtonProps,
27
28
 
28
29
  /** Props for the overlay container element. */
29
- overlayProps: HTMLAttributes<HTMLElement>
30
+ overlayProps: DOMAttributes
30
31
  }
31
32
 
32
33
  /**
33
34
  * Handles the behavior and accessibility for an overlay trigger, e.g. a button
34
35
  * that opens a popover, menu, or other overlay that is positioned relative to the trigger.
35
36
  */
36
- export function useOverlayTrigger(props: OverlayTriggerProps, state: OverlayTriggerState, ref: RefObject<HTMLElement>): OverlayTriggerAria {
37
+ export function useOverlayTrigger(props: OverlayTriggerProps, state: OverlayTriggerState, ref: RefObject<Element>): OverlayTriggerAria {
37
38
  let {type} = props;
38
39
  let {isOpen} = state;
39
40
 
@@ -61,7 +62,8 @@ export function useOverlayTrigger(props: OverlayTriggerProps, state: OverlayTrig
61
62
  triggerProps: {
62
63
  'aria-haspopup': ariaHasPopup,
63
64
  'aria-expanded': isOpen,
64
- 'aria-controls': isOpen ? overlayId : null
65
+ 'aria-controls': isOpen ? overlayId : null,
66
+ onPress: state.toggle
65
67
  },
66
68
  overlayProps: {
67
69
  id: overlayId