@react-aria/overlays 3.31.1 → 3.32.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.
Files changed (263) hide show
  1. package/dist/import.mjs +12 -12
  2. package/dist/main.js +28 -28
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +12 -12
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +19 -0
  7. package/package.json +15 -21
  8. package/src/index.ts +19 -22
  9. package/dist/DismissButton.main.js +0 -51
  10. package/dist/DismissButton.main.js.map +0 -1
  11. package/dist/DismissButton.mjs +0 -46
  12. package/dist/DismissButton.module.js +0 -46
  13. package/dist/DismissButton.module.js.map +0 -1
  14. package/dist/Overlay.main.js +0 -73
  15. package/dist/Overlay.main.js.map +0 -1
  16. package/dist/Overlay.mjs +0 -63
  17. package/dist/Overlay.module.js +0 -63
  18. package/dist/Overlay.module.js.map +0 -1
  19. package/dist/PortalProvider.main.js +0 -41
  20. package/dist/PortalProvider.main.js.map +0 -1
  21. package/dist/PortalProvider.mjs +0 -31
  22. package/dist/PortalProvider.module.js +0 -31
  23. package/dist/PortalProvider.module.js.map +0 -1
  24. package/dist/ar-AE.main.js +0 -6
  25. package/dist/ar-AE.main.js.map +0 -1
  26. package/dist/ar-AE.mjs +0 -8
  27. package/dist/ar-AE.module.js +0 -8
  28. package/dist/ar-AE.module.js.map +0 -1
  29. package/dist/ariaHideOutside.main.js +0 -152
  30. package/dist/ariaHideOutside.main.js.map +0 -1
  31. package/dist/ariaHideOutside.mjs +0 -146
  32. package/dist/ariaHideOutside.module.js +0 -146
  33. package/dist/ariaHideOutside.module.js.map +0 -1
  34. package/dist/bg-BG.main.js +0 -6
  35. package/dist/bg-BG.main.js.map +0 -1
  36. package/dist/bg-BG.mjs +0 -8
  37. package/dist/bg-BG.module.js +0 -8
  38. package/dist/bg-BG.module.js.map +0 -1
  39. package/dist/calculatePosition.main.js +0 -414
  40. package/dist/calculatePosition.main.js.map +0 -1
  41. package/dist/calculatePosition.mjs +0 -408
  42. package/dist/calculatePosition.module.js +0 -408
  43. package/dist/calculatePosition.module.js.map +0 -1
  44. package/dist/cs-CZ.main.js +0 -6
  45. package/dist/cs-CZ.main.js.map +0 -1
  46. package/dist/cs-CZ.mjs +0 -8
  47. package/dist/cs-CZ.module.js +0 -8
  48. package/dist/cs-CZ.module.js.map +0 -1
  49. package/dist/da-DK.main.js +0 -6
  50. package/dist/da-DK.main.js.map +0 -1
  51. package/dist/da-DK.mjs +0 -8
  52. package/dist/da-DK.module.js +0 -8
  53. package/dist/da-DK.module.js.map +0 -1
  54. package/dist/de-DE.main.js +0 -6
  55. package/dist/de-DE.main.js.map +0 -1
  56. package/dist/de-DE.mjs +0 -8
  57. package/dist/de-DE.module.js +0 -8
  58. package/dist/de-DE.module.js.map +0 -1
  59. package/dist/el-GR.main.js +0 -6
  60. package/dist/el-GR.main.js.map +0 -1
  61. package/dist/el-GR.mjs +0 -8
  62. package/dist/el-GR.module.js +0 -8
  63. package/dist/el-GR.module.js.map +0 -1
  64. package/dist/en-US.main.js +0 -6
  65. package/dist/en-US.main.js.map +0 -1
  66. package/dist/en-US.mjs +0 -8
  67. package/dist/en-US.module.js +0 -8
  68. package/dist/en-US.module.js.map +0 -1
  69. package/dist/es-ES.main.js +0 -6
  70. package/dist/es-ES.main.js.map +0 -1
  71. package/dist/es-ES.mjs +0 -8
  72. package/dist/es-ES.module.js +0 -8
  73. package/dist/es-ES.module.js.map +0 -1
  74. package/dist/et-EE.main.js +0 -6
  75. package/dist/et-EE.main.js.map +0 -1
  76. package/dist/et-EE.mjs +0 -8
  77. package/dist/et-EE.module.js +0 -8
  78. package/dist/et-EE.module.js.map +0 -1
  79. package/dist/fi-FI.main.js +0 -6
  80. package/dist/fi-FI.main.js.map +0 -1
  81. package/dist/fi-FI.mjs +0 -8
  82. package/dist/fi-FI.module.js +0 -8
  83. package/dist/fi-FI.module.js.map +0 -1
  84. package/dist/fr-FR.main.js +0 -6
  85. package/dist/fr-FR.main.js.map +0 -1
  86. package/dist/fr-FR.mjs +0 -8
  87. package/dist/fr-FR.module.js +0 -8
  88. package/dist/fr-FR.module.js.map +0 -1
  89. package/dist/he-IL.main.js +0 -6
  90. package/dist/he-IL.main.js.map +0 -1
  91. package/dist/he-IL.mjs +0 -8
  92. package/dist/he-IL.module.js +0 -8
  93. package/dist/he-IL.module.js.map +0 -1
  94. package/dist/hr-HR.main.js +0 -6
  95. package/dist/hr-HR.main.js.map +0 -1
  96. package/dist/hr-HR.mjs +0 -8
  97. package/dist/hr-HR.module.js +0 -8
  98. package/dist/hr-HR.module.js.map +0 -1
  99. package/dist/hu-HU.main.js +0 -6
  100. package/dist/hu-HU.main.js.map +0 -1
  101. package/dist/hu-HU.mjs +0 -8
  102. package/dist/hu-HU.module.js +0 -8
  103. package/dist/hu-HU.module.js.map +0 -1
  104. package/dist/intlStrings.main.js +0 -108
  105. package/dist/intlStrings.main.js.map +0 -1
  106. package/dist/intlStrings.mjs +0 -110
  107. package/dist/intlStrings.module.js +0 -110
  108. package/dist/intlStrings.module.js.map +0 -1
  109. package/dist/it-IT.main.js +0 -6
  110. package/dist/it-IT.main.js.map +0 -1
  111. package/dist/it-IT.mjs +0 -8
  112. package/dist/it-IT.module.js +0 -8
  113. package/dist/it-IT.module.js.map +0 -1
  114. package/dist/ja-JP.main.js +0 -6
  115. package/dist/ja-JP.main.js.map +0 -1
  116. package/dist/ja-JP.mjs +0 -8
  117. package/dist/ja-JP.module.js +0 -8
  118. package/dist/ja-JP.module.js.map +0 -1
  119. package/dist/ko-KR.main.js +0 -6
  120. package/dist/ko-KR.main.js.map +0 -1
  121. package/dist/ko-KR.mjs +0 -8
  122. package/dist/ko-KR.module.js +0 -8
  123. package/dist/ko-KR.module.js.map +0 -1
  124. package/dist/lt-LT.main.js +0 -6
  125. package/dist/lt-LT.main.js.map +0 -1
  126. package/dist/lt-LT.mjs +0 -8
  127. package/dist/lt-LT.module.js +0 -8
  128. package/dist/lt-LT.module.js.map +0 -1
  129. package/dist/lv-LV.main.js +0 -6
  130. package/dist/lv-LV.main.js.map +0 -1
  131. package/dist/lv-LV.mjs +0 -8
  132. package/dist/lv-LV.module.js +0 -8
  133. package/dist/lv-LV.module.js.map +0 -1
  134. package/dist/nb-NO.main.js +0 -6
  135. package/dist/nb-NO.main.js.map +0 -1
  136. package/dist/nb-NO.mjs +0 -8
  137. package/dist/nb-NO.module.js +0 -8
  138. package/dist/nb-NO.module.js.map +0 -1
  139. package/dist/nl-NL.main.js +0 -6
  140. package/dist/nl-NL.main.js.map +0 -1
  141. package/dist/nl-NL.mjs +0 -8
  142. package/dist/nl-NL.module.js +0 -8
  143. package/dist/nl-NL.module.js.map +0 -1
  144. package/dist/pl-PL.main.js +0 -6
  145. package/dist/pl-PL.main.js.map +0 -1
  146. package/dist/pl-PL.mjs +0 -8
  147. package/dist/pl-PL.module.js +0 -8
  148. package/dist/pl-PL.module.js.map +0 -1
  149. package/dist/pt-BR.main.js +0 -6
  150. package/dist/pt-BR.main.js.map +0 -1
  151. package/dist/pt-BR.mjs +0 -8
  152. package/dist/pt-BR.module.js +0 -8
  153. package/dist/pt-BR.module.js.map +0 -1
  154. package/dist/pt-PT.main.js +0 -6
  155. package/dist/pt-PT.main.js.map +0 -1
  156. package/dist/pt-PT.mjs +0 -8
  157. package/dist/pt-PT.module.js +0 -8
  158. package/dist/pt-PT.module.js.map +0 -1
  159. package/dist/ro-RO.main.js +0 -6
  160. package/dist/ro-RO.main.js.map +0 -1
  161. package/dist/ro-RO.mjs +0 -8
  162. package/dist/ro-RO.module.js +0 -8
  163. package/dist/ro-RO.module.js.map +0 -1
  164. package/dist/ru-RU.main.js +0 -6
  165. package/dist/ru-RU.main.js.map +0 -1
  166. package/dist/ru-RU.mjs +0 -8
  167. package/dist/ru-RU.module.js +0 -8
  168. package/dist/ru-RU.module.js.map +0 -1
  169. package/dist/sk-SK.main.js +0 -6
  170. package/dist/sk-SK.main.js.map +0 -1
  171. package/dist/sk-SK.mjs +0 -8
  172. package/dist/sk-SK.module.js +0 -8
  173. package/dist/sk-SK.module.js.map +0 -1
  174. package/dist/sl-SI.main.js +0 -6
  175. package/dist/sl-SI.main.js.map +0 -1
  176. package/dist/sl-SI.mjs +0 -8
  177. package/dist/sl-SI.module.js +0 -8
  178. package/dist/sl-SI.module.js.map +0 -1
  179. package/dist/sr-SP.main.js +0 -6
  180. package/dist/sr-SP.main.js.map +0 -1
  181. package/dist/sr-SP.mjs +0 -8
  182. package/dist/sr-SP.module.js +0 -8
  183. package/dist/sr-SP.module.js.map +0 -1
  184. package/dist/sv-SE.main.js +0 -6
  185. package/dist/sv-SE.main.js.map +0 -1
  186. package/dist/sv-SE.mjs +0 -8
  187. package/dist/sv-SE.module.js +0 -8
  188. package/dist/sv-SE.module.js.map +0 -1
  189. package/dist/tr-TR.main.js +0 -6
  190. package/dist/tr-TR.main.js.map +0 -1
  191. package/dist/tr-TR.mjs +0 -8
  192. package/dist/tr-TR.module.js +0 -8
  193. package/dist/tr-TR.module.js.map +0 -1
  194. package/dist/types.d.ts +0 -355
  195. package/dist/types.d.ts.map +0 -1
  196. package/dist/uk-UA.main.js +0 -6
  197. package/dist/uk-UA.main.js.map +0 -1
  198. package/dist/uk-UA.mjs +0 -8
  199. package/dist/uk-UA.module.js +0 -8
  200. package/dist/uk-UA.module.js.map +0 -1
  201. package/dist/useCloseOnScroll.main.js +0 -52
  202. package/dist/useCloseOnScroll.main.js.map +0 -1
  203. package/dist/useCloseOnScroll.mjs +0 -46
  204. package/dist/useCloseOnScroll.module.js +0 -46
  205. package/dist/useCloseOnScroll.module.js.map +0 -1
  206. package/dist/useModal.main.js +0 -118
  207. package/dist/useModal.main.js.map +0 -1
  208. package/dist/useModal.mjs +0 -105
  209. package/dist/useModal.module.js +0 -105
  210. package/dist/useModal.module.js.map +0 -1
  211. package/dist/useModalOverlay.main.js +0 -57
  212. package/dist/useModalOverlay.main.js.map +0 -1
  213. package/dist/useModalOverlay.mjs +0 -52
  214. package/dist/useModalOverlay.module.js +0 -52
  215. package/dist/useModalOverlay.module.js.map +0 -1
  216. package/dist/useOverlay.main.js +0 -111
  217. package/dist/useOverlay.main.js.map +0 -1
  218. package/dist/useOverlay.mjs +0 -106
  219. package/dist/useOverlay.module.js +0 -106
  220. package/dist/useOverlay.module.js.map +0 -1
  221. package/dist/useOverlayPosition.main.js +0 -225
  222. package/dist/useOverlayPosition.main.js.map +0 -1
  223. package/dist/useOverlayPosition.mjs +0 -220
  224. package/dist/useOverlayPosition.module.js +0 -220
  225. package/dist/useOverlayPosition.module.js.map +0 -1
  226. package/dist/useOverlayTrigger.main.js +0 -54
  227. package/dist/useOverlayTrigger.main.js.map +0 -1
  228. package/dist/useOverlayTrigger.mjs +0 -49
  229. package/dist/useOverlayTrigger.module.js +0 -49
  230. package/dist/useOverlayTrigger.module.js.map +0 -1
  231. package/dist/usePopover.main.js +0 -77
  232. package/dist/usePopover.main.js.map +0 -1
  233. package/dist/usePopover.mjs +0 -72
  234. package/dist/usePopover.module.js +0 -72
  235. package/dist/usePopover.module.js.map +0 -1
  236. package/dist/usePreventScroll.main.js +0 -215
  237. package/dist/usePreventScroll.main.js.map +0 -1
  238. package/dist/usePreventScroll.mjs +0 -210
  239. package/dist/usePreventScroll.module.js +0 -210
  240. package/dist/usePreventScroll.module.js.map +0 -1
  241. package/dist/zh-CN.main.js +0 -6
  242. package/dist/zh-CN.main.js.map +0 -1
  243. package/dist/zh-CN.mjs +0 -8
  244. package/dist/zh-CN.module.js +0 -8
  245. package/dist/zh-CN.module.js.map +0 -1
  246. package/dist/zh-TW.main.js +0 -6
  247. package/dist/zh-TW.main.js.map +0 -1
  248. package/dist/zh-TW.mjs +0 -8
  249. package/dist/zh-TW.module.js +0 -8
  250. package/dist/zh-TW.module.js.map +0 -1
  251. package/src/DismissButton.tsx +0 -52
  252. package/src/Overlay.tsx +0 -95
  253. package/src/PortalProvider.tsx +0 -41
  254. package/src/ariaHideOutside.ts +0 -221
  255. package/src/calculatePosition.ts +0 -680
  256. package/src/useCloseOnScroll.ts +0 -65
  257. package/src/useModal.tsx +0 -197
  258. package/src/useModalOverlay.ts +0 -69
  259. package/src/useOverlay.ts +0 -169
  260. package/src/useOverlayPosition.ts +0 -327
  261. package/src/useOverlayTrigger.ts +0 -72
  262. package/src/usePopover.ts +0 -138
  263. package/src/usePreventScroll.ts +0 -273
@@ -1,220 +0,0 @@
1
- import {calculatePosition as $edcf132a9284368a$export$b3ceb0cbf1056d98, getRect as $edcf132a9284368a$export$4b834cebd9e5cebe} from "./calculatePosition.mjs";
2
- import {useCloseOnScroll as $dd149f63282afbbf$export$18fc8428861184da} from "./useCloseOnScroll.mjs";
3
- import {nodeContains as $39EOa$nodeContains, useLayoutEffect as $39EOa$useLayoutEffect, useResizeObserver as $39EOa$useResizeObserver} from "@react-aria/utils";
4
- import {useState as $39EOa$useState, useRef as $39EOa$useRef, useEffect as $39EOa$useEffect, useCallback as $39EOa$useCallback} from "react";
5
- import {useLocale as $39EOa$useLocale} from "@react-aria/i18n";
6
-
7
- /*
8
- * Copyright 2020 Adobe. All rights reserved.
9
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License. You may obtain a copy
11
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software distributed under
14
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
- * OF ANY KIND, either express or implied. See the License for the specific language
16
- * governing permissions and limitations under the License.
17
- */
18
-
19
-
20
-
21
-
22
- let $2a41e45df1593e64$var$visualViewport = typeof document !== 'undefined' ? window.visualViewport : null;
23
- function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
24
- let { direction: direction } = (0, $39EOa$useLocale)();
25
- let { arrowSize: arrowSize, targetRef: targetRef, overlayRef: overlayRef, arrowRef: arrowRef, scrollRef: scrollRef = overlayRef, placement: placement = 'bottom', containerPadding: containerPadding = 12, shouldFlip: shouldFlip = true, boundaryElement: boundaryElement = typeof document !== 'undefined' ? document.body : null, offset: offset = 0, crossOffset: crossOffset = 0, shouldUpdatePosition: shouldUpdatePosition = true, isOpen: isOpen = true, onClose: onClose, maxHeight: maxHeight, arrowBoundaryOffset: arrowBoundaryOffset = 0 } = props;
26
- let [position, setPosition] = (0, $39EOa$useState)(null);
27
- let deps = [
28
- shouldUpdatePosition,
29
- placement,
30
- overlayRef.current,
31
- targetRef.current,
32
- arrowRef === null || arrowRef === void 0 ? void 0 : arrowRef.current,
33
- scrollRef.current,
34
- containerPadding,
35
- shouldFlip,
36
- boundaryElement,
37
- offset,
38
- crossOffset,
39
- isOpen,
40
- direction,
41
- maxHeight,
42
- arrowBoundaryOffset,
43
- arrowSize
44
- ];
45
- // Note, the position freezing breaks if body sizes itself dynamicly with the visual viewport but that might
46
- // just be a non-realistic use case
47
- // Upon opening a overlay, record the current visual viewport scale so we can freeze the overlay styles
48
- let lastScale = (0, $39EOa$useRef)($2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale);
49
- (0, $39EOa$useEffect)(()=>{
50
- if (isOpen) lastScale.current = $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale;
51
- }, [
52
- isOpen
53
- ]);
54
- let updatePosition = (0, $39EOa$useCallback)(()=>{
55
- if (shouldUpdatePosition === false || !isOpen || !overlayRef.current || !targetRef.current || !boundaryElement) return;
56
- if (($2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale) !== lastScale.current) return;
57
- // Determine a scroll anchor based on the focused element.
58
- // This stores the offset of the anchor element from the scroll container
59
- // so it can be restored after repositioning. This way if the overlay height
60
- // changes, the focused element appears to stay in the same position.
61
- let anchor = null;
62
- if (scrollRef.current && (0, $39EOa$nodeContains)(scrollRef.current, document.activeElement)) {
63
- var _document_activeElement;
64
- let anchorRect = (_document_activeElement = document.activeElement) === null || _document_activeElement === void 0 ? void 0 : _document_activeElement.getBoundingClientRect();
65
- let scrollRect = scrollRef.current.getBoundingClientRect();
66
- var _anchorRect_top;
67
- // Anchor from the top if the offset is in the top half of the scrollable element,
68
- // otherwise anchor from the bottom.
69
- anchor = {
70
- type: 'top',
71
- offset: ((_anchorRect_top = anchorRect === null || anchorRect === void 0 ? void 0 : anchorRect.top) !== null && _anchorRect_top !== void 0 ? _anchorRect_top : 0) - scrollRect.top
72
- };
73
- if (anchor.offset > scrollRect.height / 2) {
74
- anchor.type = 'bottom';
75
- var _anchorRect_bottom;
76
- anchor.offset = ((_anchorRect_bottom = anchorRect === null || anchorRect === void 0 ? void 0 : anchorRect.bottom) !== null && _anchorRect_bottom !== void 0 ? _anchorRect_bottom : 0) - scrollRect.bottom;
77
- }
78
- }
79
- // Always reset the overlay's previous max height if not defined by the user so that we can compensate for
80
- // RAC collections populating after a second render and properly set a correct max height + positioning when it populates.
81
- let overlay = overlayRef.current;
82
- if (!maxHeight && overlayRef.current) {
83
- var _window_visualViewport;
84
- overlay.style.top = '0px';
85
- overlay.style.bottom = '';
86
- var _window_visualViewport_height;
87
- overlay.style.maxHeight = ((_window_visualViewport_height = (_window_visualViewport = window.visualViewport) === null || _window_visualViewport === void 0 ? void 0 : _window_visualViewport.height) !== null && _window_visualViewport_height !== void 0 ? _window_visualViewport_height : window.innerHeight) + 'px';
88
- }
89
- let position = (0, $edcf132a9284368a$export$b3ceb0cbf1056d98)({
90
- placement: $2a41e45df1593e64$var$translateRTL(placement, direction),
91
- overlayNode: overlayRef.current,
92
- targetNode: targetRef.current,
93
- scrollNode: scrollRef.current || overlayRef.current,
94
- padding: containerPadding,
95
- shouldFlip: shouldFlip,
96
- boundaryElement: boundaryElement,
97
- offset: offset,
98
- crossOffset: crossOffset,
99
- maxHeight: maxHeight,
100
- arrowSize: arrowSize !== null && arrowSize !== void 0 ? arrowSize : (arrowRef === null || arrowRef === void 0 ? void 0 : arrowRef.current) ? (0, $edcf132a9284368a$export$4b834cebd9e5cebe)(arrowRef.current, true).width : 0,
101
- arrowBoundaryOffset: arrowBoundaryOffset
102
- });
103
- if (!position.position) return;
104
- // Modify overlay styles directly so positioning happens immediately without the need of a second render
105
- // This is so we don't have to delay autoFocus scrolling or delay applying preventScroll for popovers
106
- overlay.style.top = '';
107
- overlay.style.bottom = '';
108
- overlay.style.left = '';
109
- overlay.style.right = '';
110
- Object.keys(position.position).forEach((key)=>overlay.style[key] = position.position[key] + 'px');
111
- overlay.style.maxHeight = position.maxHeight != null ? position.maxHeight + 'px' : '';
112
- // Restore scroll position relative to anchor element.
113
- if (anchor && document.activeElement && scrollRef.current) {
114
- let anchorRect = document.activeElement.getBoundingClientRect();
115
- let scrollRect = scrollRef.current.getBoundingClientRect();
116
- let newOffset = anchorRect[anchor.type] - scrollRect[anchor.type];
117
- scrollRef.current.scrollTop += newOffset - anchor.offset;
118
- }
119
- // Trigger a set state for a second render anyway for arrow positioning
120
- setPosition(position);
121
- // eslint-disable-next-line react-hooks/exhaustive-deps
122
- }, deps);
123
- // Update position when anything changes
124
- // eslint-disable-next-line react-hooks/exhaustive-deps
125
- (0, $39EOa$useLayoutEffect)(updatePosition, deps);
126
- // Update position on window resize
127
- $2a41e45df1593e64$var$useResize(updatePosition);
128
- // Update position when the overlay changes size (might need to flip).
129
- (0, $39EOa$useResizeObserver)({
130
- ref: overlayRef,
131
- onResize: updatePosition
132
- });
133
- // Update position when the target changes size (might need to flip).
134
- (0, $39EOa$useResizeObserver)({
135
- ref: targetRef,
136
- onResize: updatePosition
137
- });
138
- // Reposition the overlay and do not close on scroll while the visual viewport is resizing.
139
- // This will ensure that overlays adjust their positioning when the iOS virtual keyboard appears.
140
- let isResizing = (0, $39EOa$useRef)(false);
141
- (0, $39EOa$useLayoutEffect)(()=>{
142
- let timeout;
143
- let onResize = ()=>{
144
- isResizing.current = true;
145
- clearTimeout(timeout);
146
- timeout = setTimeout(()=>{
147
- isResizing.current = false;
148
- }, 500);
149
- updatePosition();
150
- };
151
- // Only reposition the overlay if a scroll event happens immediately as a result of resize (aka the virtual keyboard has appears)
152
- // We don't want to reposition the overlay if the user has pinch zoomed in and is scrolling the viewport around.
153
- let onScroll = ()=>{
154
- if (isResizing.current) onResize();
155
- };
156
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.addEventListener('resize', onResize);
157
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.addEventListener('scroll', onScroll);
158
- return ()=>{
159
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.removeEventListener('resize', onResize);
160
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.removeEventListener('scroll', onScroll);
161
- };
162
- }, [
163
- updatePosition
164
- ]);
165
- let close = (0, $39EOa$useCallback)(()=>{
166
- if (!isResizing.current) onClose === null || onClose === void 0 ? void 0 : onClose();
167
- }, [
168
- onClose,
169
- isResizing
170
- ]);
171
- // When scrolling a parent scrollable region of the trigger (other than the body),
172
- // we hide the popover. Otherwise, its position would be incorrect.
173
- (0, $dd149f63282afbbf$export$18fc8428861184da)({
174
- triggerRef: targetRef,
175
- isOpen: isOpen,
176
- onClose: onClose && close
177
- });
178
- var _position_maxHeight, _position_placement, _position_triggerAnchorPoint;
179
- return {
180
- overlayProps: {
181
- style: {
182
- position: position ? 'absolute' : 'fixed',
183
- top: !position ? 0 : undefined,
184
- left: !position ? 0 : undefined,
185
- zIndex: 100000,
186
- ...position === null || position === void 0 ? void 0 : position.position,
187
- maxHeight: (_position_maxHeight = position === null || position === void 0 ? void 0 : position.maxHeight) !== null && _position_maxHeight !== void 0 ? _position_maxHeight : '100vh'
188
- }
189
- },
190
- placement: (_position_placement = position === null || position === void 0 ? void 0 : position.placement) !== null && _position_placement !== void 0 ? _position_placement : null,
191
- triggerAnchorPoint: (_position_triggerAnchorPoint = position === null || position === void 0 ? void 0 : position.triggerAnchorPoint) !== null && _position_triggerAnchorPoint !== void 0 ? _position_triggerAnchorPoint : null,
192
- arrowProps: {
193
- 'aria-hidden': 'true',
194
- role: 'presentation',
195
- style: {
196
- left: position === null || position === void 0 ? void 0 : position.arrowOffsetLeft,
197
- top: position === null || position === void 0 ? void 0 : position.arrowOffsetTop
198
- }
199
- },
200
- updatePosition: updatePosition
201
- };
202
- }
203
- function $2a41e45df1593e64$var$useResize(onResize) {
204
- (0, $39EOa$useLayoutEffect)(()=>{
205
- window.addEventListener('resize', onResize, false);
206
- return ()=>{
207
- window.removeEventListener('resize', onResize, false);
208
- };
209
- }, [
210
- onResize
211
- ]);
212
- }
213
- function $2a41e45df1593e64$var$translateRTL(position, direction) {
214
- if (direction === 'rtl') return position.replace('start', 'right').replace('end', 'left');
215
- return position.replace('start', 'left').replace('end', 'right');
216
- }
217
-
218
-
219
- export {$2a41e45df1593e64$export$d39e1813b3bdd0e1 as useOverlayPosition};
220
- //# sourceMappingURL=useOverlayPosition.module.js.map
@@ -1,220 +0,0 @@
1
- import {calculatePosition as $edcf132a9284368a$export$b3ceb0cbf1056d98, getRect as $edcf132a9284368a$export$4b834cebd9e5cebe} from "./calculatePosition.module.js";
2
- import {useCloseOnScroll as $dd149f63282afbbf$export$18fc8428861184da} from "./useCloseOnScroll.module.js";
3
- import {nodeContains as $39EOa$nodeContains, useLayoutEffect as $39EOa$useLayoutEffect, useResizeObserver as $39EOa$useResizeObserver} from "@react-aria/utils";
4
- import {useState as $39EOa$useState, useRef as $39EOa$useRef, useEffect as $39EOa$useEffect, useCallback as $39EOa$useCallback} from "react";
5
- import {useLocale as $39EOa$useLocale} from "@react-aria/i18n";
6
-
7
- /*
8
- * Copyright 2020 Adobe. All rights reserved.
9
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License. You may obtain a copy
11
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software distributed under
14
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
- * OF ANY KIND, either express or implied. See the License for the specific language
16
- * governing permissions and limitations under the License.
17
- */
18
-
19
-
20
-
21
-
22
- let $2a41e45df1593e64$var$visualViewport = typeof document !== 'undefined' ? window.visualViewport : null;
23
- function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
24
- let { direction: direction } = (0, $39EOa$useLocale)();
25
- let { arrowSize: arrowSize, targetRef: targetRef, overlayRef: overlayRef, arrowRef: arrowRef, scrollRef: scrollRef = overlayRef, placement: placement = 'bottom', containerPadding: containerPadding = 12, shouldFlip: shouldFlip = true, boundaryElement: boundaryElement = typeof document !== 'undefined' ? document.body : null, offset: offset = 0, crossOffset: crossOffset = 0, shouldUpdatePosition: shouldUpdatePosition = true, isOpen: isOpen = true, onClose: onClose, maxHeight: maxHeight, arrowBoundaryOffset: arrowBoundaryOffset = 0 } = props;
26
- let [position, setPosition] = (0, $39EOa$useState)(null);
27
- let deps = [
28
- shouldUpdatePosition,
29
- placement,
30
- overlayRef.current,
31
- targetRef.current,
32
- arrowRef === null || arrowRef === void 0 ? void 0 : arrowRef.current,
33
- scrollRef.current,
34
- containerPadding,
35
- shouldFlip,
36
- boundaryElement,
37
- offset,
38
- crossOffset,
39
- isOpen,
40
- direction,
41
- maxHeight,
42
- arrowBoundaryOffset,
43
- arrowSize
44
- ];
45
- // Note, the position freezing breaks if body sizes itself dynamicly with the visual viewport but that might
46
- // just be a non-realistic use case
47
- // Upon opening a overlay, record the current visual viewport scale so we can freeze the overlay styles
48
- let lastScale = (0, $39EOa$useRef)($2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale);
49
- (0, $39EOa$useEffect)(()=>{
50
- if (isOpen) lastScale.current = $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale;
51
- }, [
52
- isOpen
53
- ]);
54
- let updatePosition = (0, $39EOa$useCallback)(()=>{
55
- if (shouldUpdatePosition === false || !isOpen || !overlayRef.current || !targetRef.current || !boundaryElement) return;
56
- if (($2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale) !== lastScale.current) return;
57
- // Determine a scroll anchor based on the focused element.
58
- // This stores the offset of the anchor element from the scroll container
59
- // so it can be restored after repositioning. This way if the overlay height
60
- // changes, the focused element appears to stay in the same position.
61
- let anchor = null;
62
- if (scrollRef.current && (0, $39EOa$nodeContains)(scrollRef.current, document.activeElement)) {
63
- var _document_activeElement;
64
- let anchorRect = (_document_activeElement = document.activeElement) === null || _document_activeElement === void 0 ? void 0 : _document_activeElement.getBoundingClientRect();
65
- let scrollRect = scrollRef.current.getBoundingClientRect();
66
- var _anchorRect_top;
67
- // Anchor from the top if the offset is in the top half of the scrollable element,
68
- // otherwise anchor from the bottom.
69
- anchor = {
70
- type: 'top',
71
- offset: ((_anchorRect_top = anchorRect === null || anchorRect === void 0 ? void 0 : anchorRect.top) !== null && _anchorRect_top !== void 0 ? _anchorRect_top : 0) - scrollRect.top
72
- };
73
- if (anchor.offset > scrollRect.height / 2) {
74
- anchor.type = 'bottom';
75
- var _anchorRect_bottom;
76
- anchor.offset = ((_anchorRect_bottom = anchorRect === null || anchorRect === void 0 ? void 0 : anchorRect.bottom) !== null && _anchorRect_bottom !== void 0 ? _anchorRect_bottom : 0) - scrollRect.bottom;
77
- }
78
- }
79
- // Always reset the overlay's previous max height if not defined by the user so that we can compensate for
80
- // RAC collections populating after a second render and properly set a correct max height + positioning when it populates.
81
- let overlay = overlayRef.current;
82
- if (!maxHeight && overlayRef.current) {
83
- var _window_visualViewport;
84
- overlay.style.top = '0px';
85
- overlay.style.bottom = '';
86
- var _window_visualViewport_height;
87
- overlay.style.maxHeight = ((_window_visualViewport_height = (_window_visualViewport = window.visualViewport) === null || _window_visualViewport === void 0 ? void 0 : _window_visualViewport.height) !== null && _window_visualViewport_height !== void 0 ? _window_visualViewport_height : window.innerHeight) + 'px';
88
- }
89
- let position = (0, $edcf132a9284368a$export$b3ceb0cbf1056d98)({
90
- placement: $2a41e45df1593e64$var$translateRTL(placement, direction),
91
- overlayNode: overlayRef.current,
92
- targetNode: targetRef.current,
93
- scrollNode: scrollRef.current || overlayRef.current,
94
- padding: containerPadding,
95
- shouldFlip: shouldFlip,
96
- boundaryElement: boundaryElement,
97
- offset: offset,
98
- crossOffset: crossOffset,
99
- maxHeight: maxHeight,
100
- arrowSize: arrowSize !== null && arrowSize !== void 0 ? arrowSize : (arrowRef === null || arrowRef === void 0 ? void 0 : arrowRef.current) ? (0, $edcf132a9284368a$export$4b834cebd9e5cebe)(arrowRef.current, true).width : 0,
101
- arrowBoundaryOffset: arrowBoundaryOffset
102
- });
103
- if (!position.position) return;
104
- // Modify overlay styles directly so positioning happens immediately without the need of a second render
105
- // This is so we don't have to delay autoFocus scrolling or delay applying preventScroll for popovers
106
- overlay.style.top = '';
107
- overlay.style.bottom = '';
108
- overlay.style.left = '';
109
- overlay.style.right = '';
110
- Object.keys(position.position).forEach((key)=>overlay.style[key] = position.position[key] + 'px');
111
- overlay.style.maxHeight = position.maxHeight != null ? position.maxHeight + 'px' : '';
112
- // Restore scroll position relative to anchor element.
113
- if (anchor && document.activeElement && scrollRef.current) {
114
- let anchorRect = document.activeElement.getBoundingClientRect();
115
- let scrollRect = scrollRef.current.getBoundingClientRect();
116
- let newOffset = anchorRect[anchor.type] - scrollRect[anchor.type];
117
- scrollRef.current.scrollTop += newOffset - anchor.offset;
118
- }
119
- // Trigger a set state for a second render anyway for arrow positioning
120
- setPosition(position);
121
- // eslint-disable-next-line react-hooks/exhaustive-deps
122
- }, deps);
123
- // Update position when anything changes
124
- // eslint-disable-next-line react-hooks/exhaustive-deps
125
- (0, $39EOa$useLayoutEffect)(updatePosition, deps);
126
- // Update position on window resize
127
- $2a41e45df1593e64$var$useResize(updatePosition);
128
- // Update position when the overlay changes size (might need to flip).
129
- (0, $39EOa$useResizeObserver)({
130
- ref: overlayRef,
131
- onResize: updatePosition
132
- });
133
- // Update position when the target changes size (might need to flip).
134
- (0, $39EOa$useResizeObserver)({
135
- ref: targetRef,
136
- onResize: updatePosition
137
- });
138
- // Reposition the overlay and do not close on scroll while the visual viewport is resizing.
139
- // This will ensure that overlays adjust their positioning when the iOS virtual keyboard appears.
140
- let isResizing = (0, $39EOa$useRef)(false);
141
- (0, $39EOa$useLayoutEffect)(()=>{
142
- let timeout;
143
- let onResize = ()=>{
144
- isResizing.current = true;
145
- clearTimeout(timeout);
146
- timeout = setTimeout(()=>{
147
- isResizing.current = false;
148
- }, 500);
149
- updatePosition();
150
- };
151
- // Only reposition the overlay if a scroll event happens immediately as a result of resize (aka the virtual keyboard has appears)
152
- // We don't want to reposition the overlay if the user has pinch zoomed in and is scrolling the viewport around.
153
- let onScroll = ()=>{
154
- if (isResizing.current) onResize();
155
- };
156
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.addEventListener('resize', onResize);
157
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.addEventListener('scroll', onScroll);
158
- return ()=>{
159
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.removeEventListener('resize', onResize);
160
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.removeEventListener('scroll', onScroll);
161
- };
162
- }, [
163
- updatePosition
164
- ]);
165
- let close = (0, $39EOa$useCallback)(()=>{
166
- if (!isResizing.current) onClose === null || onClose === void 0 ? void 0 : onClose();
167
- }, [
168
- onClose,
169
- isResizing
170
- ]);
171
- // When scrolling a parent scrollable region of the trigger (other than the body),
172
- // we hide the popover. Otherwise, its position would be incorrect.
173
- (0, $dd149f63282afbbf$export$18fc8428861184da)({
174
- triggerRef: targetRef,
175
- isOpen: isOpen,
176
- onClose: onClose && close
177
- });
178
- var _position_maxHeight, _position_placement, _position_triggerAnchorPoint;
179
- return {
180
- overlayProps: {
181
- style: {
182
- position: position ? 'absolute' : 'fixed',
183
- top: !position ? 0 : undefined,
184
- left: !position ? 0 : undefined,
185
- zIndex: 100000,
186
- ...position === null || position === void 0 ? void 0 : position.position,
187
- maxHeight: (_position_maxHeight = position === null || position === void 0 ? void 0 : position.maxHeight) !== null && _position_maxHeight !== void 0 ? _position_maxHeight : '100vh'
188
- }
189
- },
190
- placement: (_position_placement = position === null || position === void 0 ? void 0 : position.placement) !== null && _position_placement !== void 0 ? _position_placement : null,
191
- triggerAnchorPoint: (_position_triggerAnchorPoint = position === null || position === void 0 ? void 0 : position.triggerAnchorPoint) !== null && _position_triggerAnchorPoint !== void 0 ? _position_triggerAnchorPoint : null,
192
- arrowProps: {
193
- 'aria-hidden': 'true',
194
- role: 'presentation',
195
- style: {
196
- left: position === null || position === void 0 ? void 0 : position.arrowOffsetLeft,
197
- top: position === null || position === void 0 ? void 0 : position.arrowOffsetTop
198
- }
199
- },
200
- updatePosition: updatePosition
201
- };
202
- }
203
- function $2a41e45df1593e64$var$useResize(onResize) {
204
- (0, $39EOa$useLayoutEffect)(()=>{
205
- window.addEventListener('resize', onResize, false);
206
- return ()=>{
207
- window.removeEventListener('resize', onResize, false);
208
- };
209
- }, [
210
- onResize
211
- ]);
212
- }
213
- function $2a41e45df1593e64$var$translateRTL(position, direction) {
214
- if (direction === 'rtl') return position.replace('start', 'right').replace('end', 'left');
215
- return position.replace('start', 'left').replace('end', 'right');
216
- }
217
-
218
-
219
- export {$2a41e45df1593e64$export$d39e1813b3bdd0e1 as useOverlayPosition};
220
- //# sourceMappingURL=useOverlayPosition.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":"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","sources":["packages/@react-aria/overlays/src/useOverlayPosition.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {calculatePosition, getRect, PositionResult} from './calculatePosition';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {nodeContains, useLayoutEffect, useResizeObserver} from '@react-aria/utils';\nimport {Placement, PlacementAxis, PositionProps} from '@react-types/overlays';\nimport {useCallback, useEffect, useRef, useState} from 'react';\nimport {useCloseOnScroll} from './useCloseOnScroll';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface AriaPositionProps extends PositionProps {\n /**\n * Cross size of the overlay arrow in pixels.\n * @default 0\n */\n arrowSize?: number,\n /**\n * Element that that serves as the positioning boundary.\n * @default document.body\n */\n boundaryElement?: Element,\n /**\n * The ref for the element which the overlay positions itself with respect to.\n */\n targetRef: RefObject<Element | null>,\n /**\n * The ref for the overlay element.\n */\n overlayRef: RefObject<Element | null>,\n /**\n * The ref for the arrow element.\n */\n arrowRef?: RefObject<Element | null>,\n /**\n * A ref for the scrollable region within the overlay.\n * @default overlayRef\n */\n scrollRef?: RefObject<Element | null>,\n /**\n * Whether the overlay should update its position automatically.\n * @default true\n */\n shouldUpdatePosition?: boolean,\n /** Handler that is called when the overlay should close. */\n onClose?: (() => void) | null,\n /**\n * The maxHeight specified for the overlay element.\n * By default, it will take all space up to the current viewport height.\n */\n maxHeight?: number,\n /**\n * The minimum distance the arrow's edge should be from the edge of the overlay element.\n * @default 0\n */\n arrowBoundaryOffset?: number\n}\n\nexport interface PositionAria {\n /** Props for the overlay container element. */\n overlayProps: DOMAttributes,\n /** Props for the overlay tip arrow if any. */\n arrowProps: DOMAttributes,\n /** Placement of the overlay with respect to the overlay trigger. */\n placement: PlacementAxis | null,\n /** The origin of the target in the overlay's coordinate system. Useful for animations. */\n triggerAnchorPoint: {x: number, y: number} | null,\n /** Updates the position of the overlay. */\n updatePosition(): void\n}\n\ninterface ScrollAnchor {\n type: 'top' | 'bottom',\n offset: number\n}\n\nlet visualViewport = typeof document !== 'undefined' ? window.visualViewport : null;\n\n/**\n * Handles positioning overlays like popovers and menus relative to a trigger\n * element, and updating the position when the window resizes.\n */\nexport function useOverlayPosition(props: AriaPositionProps): PositionAria {\n let {direction} = useLocale();\n let {\n arrowSize,\n targetRef,\n overlayRef,\n arrowRef,\n scrollRef = overlayRef,\n placement = 'bottom' as Placement,\n containerPadding = 12,\n shouldFlip = true,\n boundaryElement = typeof document !== 'undefined' ? document.body : null,\n offset = 0,\n crossOffset = 0,\n shouldUpdatePosition = true,\n isOpen = true,\n onClose,\n maxHeight,\n arrowBoundaryOffset = 0\n } = props;\n let [position, setPosition] = useState<PositionResult | null>(null);\n\n let deps = [\n shouldUpdatePosition,\n placement,\n overlayRef.current,\n targetRef.current,\n arrowRef?.current,\n scrollRef.current,\n containerPadding,\n shouldFlip,\n boundaryElement,\n offset,\n crossOffset,\n isOpen,\n direction,\n maxHeight,\n arrowBoundaryOffset,\n arrowSize\n ];\n\n // Note, the position freezing breaks if body sizes itself dynamicly with the visual viewport but that might\n // just be a non-realistic use case\n // Upon opening a overlay, record the current visual viewport scale so we can freeze the overlay styles\n let lastScale = useRef(visualViewport?.scale);\n useEffect(() => {\n if (isOpen) {\n lastScale.current = visualViewport?.scale;\n }\n }, [isOpen]);\n\n let updatePosition = useCallback(() => {\n if (shouldUpdatePosition === false || !isOpen || !overlayRef.current || !targetRef.current || !boundaryElement) {\n return;\n }\n\n if (visualViewport?.scale !== lastScale.current) {\n return;\n }\n\n // Determine a scroll anchor based on the focused element.\n // This stores the offset of the anchor element from the scroll container\n // so it can be restored after repositioning. This way if the overlay height\n // changes, the focused element appears to stay in the same position.\n let anchor: ScrollAnchor | null = null;\n if (scrollRef.current && nodeContains(scrollRef.current, document.activeElement)) {\n let anchorRect = document.activeElement?.getBoundingClientRect();\n let scrollRect = scrollRef.current.getBoundingClientRect();\n // Anchor from the top if the offset is in the top half of the scrollable element,\n // otherwise anchor from the bottom.\n anchor = {\n type: 'top',\n offset: (anchorRect?.top ?? 0) - scrollRect.top\n };\n if (anchor.offset > scrollRect.height / 2) {\n anchor.type = 'bottom';\n anchor.offset = (anchorRect?.bottom ?? 0) - scrollRect.bottom;\n }\n }\n\n // Always reset the overlay's previous max height if not defined by the user so that we can compensate for\n // RAC collections populating after a second render and properly set a correct max height + positioning when it populates.\n let overlay = (overlayRef.current as HTMLElement);\n if (!maxHeight && overlayRef.current) {\n overlay.style.top = '0px';\n overlay.style.bottom = '';\n overlay.style.maxHeight = (window.visualViewport?.height ?? window.innerHeight) + 'px';\n }\n\n let position = calculatePosition({\n placement: translateRTL(placement, direction),\n overlayNode: overlayRef.current,\n targetNode: targetRef.current,\n scrollNode: scrollRef.current || overlayRef.current,\n padding: containerPadding,\n shouldFlip,\n boundaryElement,\n offset,\n crossOffset,\n maxHeight,\n arrowSize: arrowSize ?? (arrowRef?.current ? getRect(arrowRef.current, true).width : 0),\n arrowBoundaryOffset\n });\n\n if (!position.position) {\n return;\n }\n\n // Modify overlay styles directly so positioning happens immediately without the need of a second render\n // This is so we don't have to delay autoFocus scrolling or delay applying preventScroll for popovers\n overlay.style.top = '';\n overlay.style.bottom = '';\n overlay.style.left = '';\n overlay.style.right = '';\n\n Object.keys(position.position).forEach(key => overlay.style[key] = (position.position!)[key] + 'px');\n overlay.style.maxHeight = position.maxHeight != null ? position.maxHeight + 'px' : '';\n\n // Restore scroll position relative to anchor element.\n if (anchor && document.activeElement && scrollRef.current) {\n let anchorRect = document.activeElement.getBoundingClientRect();\n let scrollRect = scrollRef.current.getBoundingClientRect();\n let newOffset = anchorRect[anchor.type] - scrollRect[anchor.type];\n scrollRef.current.scrollTop += newOffset - anchor.offset;\n }\n\n // Trigger a set state for a second render anyway for arrow positioning\n setPosition(position);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n // Update position when anything changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(updatePosition, deps);\n\n // Update position on window resize\n useResize(updatePosition);\n\n // Update position when the overlay changes size (might need to flip).\n useResizeObserver({\n ref: overlayRef,\n onResize: updatePosition\n });\n\n // Update position when the target changes size (might need to flip).\n useResizeObserver({\n ref: targetRef,\n onResize: updatePosition\n });\n\n // Reposition the overlay and do not close on scroll while the visual viewport is resizing.\n // This will ensure that overlays adjust their positioning when the iOS virtual keyboard appears.\n let isResizing = useRef(false);\n useLayoutEffect(() => {\n let timeout: ReturnType<typeof setTimeout>;\n let onResize = () => {\n isResizing.current = true;\n clearTimeout(timeout);\n\n timeout = setTimeout(() => {\n isResizing.current = false;\n }, 500);\n\n updatePosition();\n };\n\n // Only reposition the overlay if a scroll event happens immediately as a result of resize (aka the virtual keyboard has appears)\n // We don't want to reposition the overlay if the user has pinch zoomed in and is scrolling the viewport around.\n let onScroll = () => {\n if (isResizing.current) {\n onResize();\n }\n };\n\n visualViewport?.addEventListener('resize', onResize);\n visualViewport?.addEventListener('scroll', onScroll);\n return () => {\n visualViewport?.removeEventListener('resize', onResize);\n visualViewport?.removeEventListener('scroll', onScroll);\n };\n }, [updatePosition]);\n\n let close = useCallback(() => {\n if (!isResizing.current) {\n onClose?.();\n }\n }, [onClose, isResizing]);\n\n // When scrolling a parent scrollable region of the trigger (other than the body),\n // we hide the popover. Otherwise, its position would be incorrect.\n useCloseOnScroll({\n triggerRef: targetRef,\n isOpen,\n onClose: onClose && close\n });\n\n return {\n overlayProps: {\n style: {\n position: position ? 'absolute' : 'fixed',\n top: !position ? 0 : undefined,\n left: !position ? 0 : undefined,\n zIndex: 100000, // should match the z-index in ModalTrigger\n ...position?.position,\n maxHeight: position?.maxHeight ?? '100vh'\n }\n },\n placement: position?.placement ?? null,\n triggerAnchorPoint: position?.triggerAnchorPoint ?? null,\n arrowProps: {\n 'aria-hidden': 'true',\n role: 'presentation',\n style: {\n left: position?.arrowOffsetLeft,\n top: position?.arrowOffsetTop\n }\n },\n updatePosition\n };\n}\n\nfunction useResize(onResize) {\n useLayoutEffect(() => {\n window.addEventListener('resize', onResize, false);\n return () => {\n window.removeEventListener('resize', onResize, false);\n };\n }, [onResize]);\n}\n\nfunction translateRTL(position, direction) {\n if (direction === 'rtl') {\n return position.replace('start', 'right').replace('end', 'left');\n }\n return position.replace('start', 'left').replace('end', 'right');\n}\n"],"names":[],"version":3,"file":"useOverlayPosition.module.js.map"}
@@ -1,54 +0,0 @@
1
- var $9a8aa1b0b336ea3a$exports = require("./useCloseOnScroll.main.js");
2
- var $3l9xr$react = require("react");
3
- var $3l9xr$reactariautils = require("@react-aria/utils");
4
-
5
-
6
- function $parcel$export(e, n, v, s) {
7
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
- }
9
-
10
- $parcel$export(module.exports, "useOverlayTrigger", () => $b4878eb6316f670a$export$f9d5c8beee7d008d);
11
- /*
12
- * Copyright 2020 Adobe. All rights reserved.
13
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License. You may obtain a copy
15
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software distributed under
18
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
- * OF ANY KIND, either express or implied. See the License for the specific language
20
- * governing permissions and limitations under the License.
21
- */
22
-
23
-
24
- function $b4878eb6316f670a$export$f9d5c8beee7d008d(props, state, ref) {
25
- let { type: type } = props;
26
- let { isOpen: isOpen } = state;
27
- // Backward compatibility. Share state close function with useOverlayPosition so it can close on scroll
28
- // without forcing users to pass onClose.
29
- (0, $3l9xr$react.useEffect)(()=>{
30
- if (ref && ref.current) (0, $9a8aa1b0b336ea3a$exports.onCloseMap).set(ref.current, state.close);
31
- });
32
- // Aria 1.1 supports multiple values for aria-haspopup other than just menus.
33
- // https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup
34
- // However, we only add it for menus for now because screen readers often
35
- // announce it as a menu even for other values.
36
- let ariaHasPopup = undefined;
37
- if (type === 'menu') ariaHasPopup = true;
38
- else if (type === 'listbox') ariaHasPopup = 'listbox';
39
- let overlayId = (0, $3l9xr$reactariautils.useId)();
40
- return {
41
- triggerProps: {
42
- 'aria-haspopup': ariaHasPopup,
43
- 'aria-expanded': isOpen,
44
- 'aria-controls': isOpen ? overlayId : undefined,
45
- onPress: state.toggle
46
- },
47
- overlayProps: {
48
- id: overlayId
49
- }
50
- };
51
- }
52
-
53
-
54
- //# sourceMappingURL=useOverlayTrigger.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA0BM,SAAS,0CAAkB,KAA0B,EAAE,KAA0B,EAAE,GAA+B;IACvH,IAAI,QAAC,IAAI,EAAC,GAAG;IACb,IAAI,UAAC,MAAM,EAAC,GAAG;IAEf,uGAAuG;IACvG,yCAAyC;IACzC,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,OAAO,IAAI,OAAO,EACpB,CAAA,GAAA,oCAAS,EAAE,GAAG,CAAC,IAAI,OAAO,EAAE,MAAM,KAAK;IAE3C;IAEA,6EAA6E;IAC7E,oDAAoD;IACpD,yEAAyE;IACzE,+CAA+C;IAC/C,IAAI,eAAgD;IACpD,IAAI,SAAS,QACX,eAAe;SACV,IAAI,SAAS,WAClB,eAAe;IAGjB,IAAI,YAAY,CAAA,GAAA,2BAAI;IACpB,OAAO;QACL,cAAc;YACZ,iBAAiB;YACjB,iBAAiB;YACjB,iBAAiB,SAAS,YAAY;YACtC,SAAS,MAAM,MAAM;QACvB;QACA,cAAc;YACZ,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/overlays/src/useOverlayTrigger.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {DOMProps, RefObject} from '@react-types/shared';\nimport {onCloseMap} from './useCloseOnScroll';\nimport {OverlayTriggerState} from '@react-stately/overlays';\nimport {useEffect} from 'react';\nimport {useId} from '@react-aria/utils';\n\nexport interface OverlayTriggerProps {\n /** Type of overlay that is opened by the trigger. */\n type: 'dialog' | 'menu' | 'listbox' | 'tree' | 'grid'\n}\n\nexport interface OverlayTriggerAria {\n /** Props for the trigger element. */\n triggerProps: AriaButtonProps,\n\n /** Props for the overlay container element. */\n overlayProps: DOMProps\n}\n\n/**\n * Handles the behavior and accessibility for an overlay trigger, e.g. a button\n * that opens a popover, menu, or other overlay that is positioned relative to the trigger.\n */\nexport function useOverlayTrigger(props: OverlayTriggerProps, state: OverlayTriggerState, ref?: RefObject<Element | null>): OverlayTriggerAria {\n let {type} = props;\n let {isOpen} = state;\n\n // Backward compatibility. Share state close function with useOverlayPosition so it can close on scroll\n // without forcing users to pass onClose.\n useEffect(() => {\n if (ref && ref.current) {\n onCloseMap.set(ref.current, state.close);\n }\n });\n\n // Aria 1.1 supports multiple values for aria-haspopup other than just menus.\n // https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup\n // However, we only add it for menus for now because screen readers often\n // announce it as a menu even for other values.\n let ariaHasPopup: undefined | boolean | 'listbox' = undefined;\n if (type === 'menu') {\n ariaHasPopup = true;\n } else if (type === 'listbox') {\n ariaHasPopup = 'listbox';\n }\n\n let overlayId = useId();\n return {\n triggerProps: {\n 'aria-haspopup': ariaHasPopup,\n 'aria-expanded': isOpen,\n 'aria-controls': isOpen ? overlayId : undefined,\n onPress: state.toggle\n },\n overlayProps: {\n id: overlayId\n }\n };\n}\n"],"names":[],"version":3,"file":"useOverlayTrigger.main.js.map"}
@@ -1,49 +0,0 @@
1
- import {onCloseMap as $dd149f63282afbbf$export$f6211563215e3b37} from "./useCloseOnScroll.mjs";
2
- import {useEffect as $gMvIk$useEffect} from "react";
3
- import {useId as $gMvIk$useId} from "@react-aria/utils";
4
-
5
- /*
6
- * Copyright 2020 Adobe. All rights reserved.
7
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License. You may obtain a copy
9
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software distributed under
12
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
- * OF ANY KIND, either express or implied. See the License for the specific language
14
- * governing permissions and limitations under the License.
15
- */
16
-
17
-
18
- function $628037886ba31236$export$f9d5c8beee7d008d(props, state, ref) {
19
- let { type: type } = props;
20
- let { isOpen: isOpen } = state;
21
- // Backward compatibility. Share state close function with useOverlayPosition so it can close on scroll
22
- // without forcing users to pass onClose.
23
- (0, $gMvIk$useEffect)(()=>{
24
- if (ref && ref.current) (0, $dd149f63282afbbf$export$f6211563215e3b37).set(ref.current, state.close);
25
- });
26
- // Aria 1.1 supports multiple values for aria-haspopup other than just menus.
27
- // https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup
28
- // However, we only add it for menus for now because screen readers often
29
- // announce it as a menu even for other values.
30
- let ariaHasPopup = undefined;
31
- if (type === 'menu') ariaHasPopup = true;
32
- else if (type === 'listbox') ariaHasPopup = 'listbox';
33
- let overlayId = (0, $gMvIk$useId)();
34
- return {
35
- triggerProps: {
36
- 'aria-haspopup': ariaHasPopup,
37
- 'aria-expanded': isOpen,
38
- 'aria-controls': isOpen ? overlayId : undefined,
39
- onPress: state.toggle
40
- },
41
- overlayProps: {
42
- id: overlayId
43
- }
44
- };
45
- }
46
-
47
-
48
- export {$628037886ba31236$export$f9d5c8beee7d008d as useOverlayTrigger};
49
- //# sourceMappingURL=useOverlayTrigger.module.js.map
@@ -1,49 +0,0 @@
1
- import {onCloseMap as $dd149f63282afbbf$export$f6211563215e3b37} from "./useCloseOnScroll.module.js";
2
- import {useEffect as $gMvIk$useEffect} from "react";
3
- import {useId as $gMvIk$useId} from "@react-aria/utils";
4
-
5
- /*
6
- * Copyright 2020 Adobe. All rights reserved.
7
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License. You may obtain a copy
9
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software distributed under
12
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
- * OF ANY KIND, either express or implied. See the License for the specific language
14
- * governing permissions and limitations under the License.
15
- */
16
-
17
-
18
- function $628037886ba31236$export$f9d5c8beee7d008d(props, state, ref) {
19
- let { type: type } = props;
20
- let { isOpen: isOpen } = state;
21
- // Backward compatibility. Share state close function with useOverlayPosition so it can close on scroll
22
- // without forcing users to pass onClose.
23
- (0, $gMvIk$useEffect)(()=>{
24
- if (ref && ref.current) (0, $dd149f63282afbbf$export$f6211563215e3b37).set(ref.current, state.close);
25
- });
26
- // Aria 1.1 supports multiple values for aria-haspopup other than just menus.
27
- // https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup
28
- // However, we only add it for menus for now because screen readers often
29
- // announce it as a menu even for other values.
30
- let ariaHasPopup = undefined;
31
- if (type === 'menu') ariaHasPopup = true;
32
- else if (type === 'listbox') ariaHasPopup = 'listbox';
33
- let overlayId = (0, $gMvIk$useId)();
34
- return {
35
- triggerProps: {
36
- 'aria-haspopup': ariaHasPopup,
37
- 'aria-expanded': isOpen,
38
- 'aria-controls': isOpen ? overlayId : undefined,
39
- onPress: state.toggle
40
- },
41
- overlayProps: {
42
- id: overlayId
43
- }
44
- };
45
- }
46
-
47
-
48
- export {$628037886ba31236$export$f9d5c8beee7d008d as useOverlayTrigger};
49
- //# sourceMappingURL=useOverlayTrigger.module.js.map