@react-aria/overlays 3.21.0 → 3.22.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 (253) hide show
  1. package/dist/DismissButton.main.js +51 -0
  2. package/dist/DismissButton.main.js.map +1 -0
  3. package/dist/DismissButton.mjs +46 -0
  4. package/dist/DismissButton.module.js +46 -0
  5. package/dist/DismissButton.module.js.map +1 -0
  6. package/dist/Overlay.main.js +73 -0
  7. package/dist/Overlay.main.js.map +1 -0
  8. package/dist/Overlay.mjs +63 -0
  9. package/dist/Overlay.module.js +63 -0
  10. package/dist/Overlay.module.js.map +1 -0
  11. package/dist/PortalProvider.main.js +41 -0
  12. package/dist/PortalProvider.main.js.map +1 -0
  13. package/dist/PortalProvider.mjs +31 -0
  14. package/dist/PortalProvider.module.js +31 -0
  15. package/dist/PortalProvider.module.js.map +1 -0
  16. package/dist/ar-AE.main.js +6 -0
  17. package/dist/ar-AE.main.js.map +1 -0
  18. package/dist/ar-AE.mjs +8 -0
  19. package/dist/ar-AE.module.js +8 -0
  20. package/dist/ar-AE.module.js.map +1 -0
  21. package/dist/ariaHideOutside.main.js +121 -0
  22. package/dist/ariaHideOutside.main.js.map +1 -0
  23. package/dist/ariaHideOutside.mjs +116 -0
  24. package/dist/ariaHideOutside.module.js +116 -0
  25. package/dist/ariaHideOutside.module.js.map +1 -0
  26. package/dist/bg-BG.main.js +6 -0
  27. package/dist/bg-BG.main.js.map +1 -0
  28. package/dist/bg-BG.mjs +8 -0
  29. package/dist/bg-BG.module.js +8 -0
  30. package/dist/bg-BG.module.js.map +1 -0
  31. package/dist/calculatePosition.main.js +355 -0
  32. package/dist/calculatePosition.main.js.map +1 -0
  33. package/dist/calculatePosition.mjs +350 -0
  34. package/dist/calculatePosition.module.js +350 -0
  35. package/dist/calculatePosition.module.js.map +1 -0
  36. package/dist/cs-CZ.main.js +6 -0
  37. package/dist/cs-CZ.main.js.map +1 -0
  38. package/dist/cs-CZ.mjs +8 -0
  39. package/dist/cs-CZ.module.js +8 -0
  40. package/dist/cs-CZ.module.js.map +1 -0
  41. package/dist/da-DK.main.js +6 -0
  42. package/dist/da-DK.main.js.map +1 -0
  43. package/dist/da-DK.mjs +8 -0
  44. package/dist/da-DK.module.js +8 -0
  45. package/dist/da-DK.module.js.map +1 -0
  46. package/dist/de-DE.main.js +6 -0
  47. package/dist/de-DE.main.js.map +1 -0
  48. package/dist/de-DE.mjs +8 -0
  49. package/dist/de-DE.module.js +8 -0
  50. package/dist/de-DE.module.js.map +1 -0
  51. package/dist/el-GR.main.js +6 -0
  52. package/dist/el-GR.main.js.map +1 -0
  53. package/dist/el-GR.mjs +8 -0
  54. package/dist/el-GR.module.js +8 -0
  55. package/dist/el-GR.module.js.map +1 -0
  56. package/dist/en-US.main.js +6 -0
  57. package/dist/en-US.main.js.map +1 -0
  58. package/dist/en-US.mjs +8 -0
  59. package/dist/en-US.module.js +8 -0
  60. package/dist/en-US.module.js.map +1 -0
  61. package/dist/es-ES.main.js +6 -0
  62. package/dist/es-ES.main.js.map +1 -0
  63. package/dist/es-ES.mjs +8 -0
  64. package/dist/es-ES.module.js +8 -0
  65. package/dist/es-ES.module.js.map +1 -0
  66. package/dist/et-EE.main.js +6 -0
  67. package/dist/et-EE.main.js.map +1 -0
  68. package/dist/et-EE.mjs +8 -0
  69. package/dist/et-EE.module.js +8 -0
  70. package/dist/et-EE.module.js.map +1 -0
  71. package/dist/fi-FI.main.js +6 -0
  72. package/dist/fi-FI.main.js.map +1 -0
  73. package/dist/fi-FI.mjs +8 -0
  74. package/dist/fi-FI.module.js +8 -0
  75. package/dist/fi-FI.module.js.map +1 -0
  76. package/dist/fr-FR.main.js +6 -0
  77. package/dist/fr-FR.main.js.map +1 -0
  78. package/dist/fr-FR.mjs +8 -0
  79. package/dist/fr-FR.module.js +8 -0
  80. package/dist/fr-FR.module.js.map +1 -0
  81. package/dist/he-IL.main.js +6 -0
  82. package/dist/he-IL.main.js.map +1 -0
  83. package/dist/he-IL.mjs +8 -0
  84. package/dist/he-IL.module.js +8 -0
  85. package/dist/he-IL.module.js.map +1 -0
  86. package/dist/hr-HR.main.js +6 -0
  87. package/dist/hr-HR.main.js.map +1 -0
  88. package/dist/hr-HR.mjs +8 -0
  89. package/dist/hr-HR.module.js +8 -0
  90. package/dist/hr-HR.module.js.map +1 -0
  91. package/dist/hu-HU.main.js +6 -0
  92. package/dist/hu-HU.main.js.map +1 -0
  93. package/dist/hu-HU.mjs +8 -0
  94. package/dist/hu-HU.module.js +8 -0
  95. package/dist/hu-HU.module.js.map +1 -0
  96. package/dist/import.mjs +12 -1533
  97. package/dist/intlStrings.main.js +108 -0
  98. package/dist/intlStrings.main.js.map +1 -0
  99. package/dist/intlStrings.mjs +110 -0
  100. package/dist/intlStrings.module.js +110 -0
  101. package/dist/intlStrings.module.js.map +1 -0
  102. package/dist/it-IT.main.js +6 -0
  103. package/dist/it-IT.main.js.map +1 -0
  104. package/dist/it-IT.mjs +8 -0
  105. package/dist/it-IT.module.js +8 -0
  106. package/dist/it-IT.module.js.map +1 -0
  107. package/dist/ja-JP.main.js +6 -0
  108. package/dist/ja-JP.main.js.map +1 -0
  109. package/dist/ja-JP.mjs +8 -0
  110. package/dist/ja-JP.module.js +8 -0
  111. package/dist/ja-JP.module.js.map +1 -0
  112. package/dist/ko-KR.main.js +6 -0
  113. package/dist/ko-KR.main.js.map +1 -0
  114. package/dist/ko-KR.mjs +8 -0
  115. package/dist/ko-KR.module.js +8 -0
  116. package/dist/ko-KR.module.js.map +1 -0
  117. package/dist/lt-LT.main.js +6 -0
  118. package/dist/lt-LT.main.js.map +1 -0
  119. package/dist/lt-LT.mjs +8 -0
  120. package/dist/lt-LT.module.js +8 -0
  121. package/dist/lt-LT.module.js.map +1 -0
  122. package/dist/lv-LV.main.js +6 -0
  123. package/dist/lv-LV.main.js.map +1 -0
  124. package/dist/lv-LV.mjs +8 -0
  125. package/dist/lv-LV.module.js +8 -0
  126. package/dist/lv-LV.module.js.map +1 -0
  127. package/dist/main.js +28 -1547
  128. package/dist/main.js.map +1 -1
  129. package/dist/module.js +12 -1533
  130. package/dist/module.js.map +1 -1
  131. package/dist/nb-NO.main.js +6 -0
  132. package/dist/nb-NO.main.js.map +1 -0
  133. package/dist/nb-NO.mjs +8 -0
  134. package/dist/nb-NO.module.js +8 -0
  135. package/dist/nb-NO.module.js.map +1 -0
  136. package/dist/nl-NL.main.js +6 -0
  137. package/dist/nl-NL.main.js.map +1 -0
  138. package/dist/nl-NL.mjs +8 -0
  139. package/dist/nl-NL.module.js +8 -0
  140. package/dist/nl-NL.module.js.map +1 -0
  141. package/dist/pl-PL.main.js +6 -0
  142. package/dist/pl-PL.main.js.map +1 -0
  143. package/dist/pl-PL.mjs +8 -0
  144. package/dist/pl-PL.module.js +8 -0
  145. package/dist/pl-PL.module.js.map +1 -0
  146. package/dist/pt-BR.main.js +6 -0
  147. package/dist/pt-BR.main.js.map +1 -0
  148. package/dist/pt-BR.mjs +8 -0
  149. package/dist/pt-BR.module.js +8 -0
  150. package/dist/pt-BR.module.js.map +1 -0
  151. package/dist/pt-PT.main.js +6 -0
  152. package/dist/pt-PT.main.js.map +1 -0
  153. package/dist/pt-PT.mjs +8 -0
  154. package/dist/pt-PT.module.js +8 -0
  155. package/dist/pt-PT.module.js.map +1 -0
  156. package/dist/ro-RO.main.js +6 -0
  157. package/dist/ro-RO.main.js.map +1 -0
  158. package/dist/ro-RO.mjs +8 -0
  159. package/dist/ro-RO.module.js +8 -0
  160. package/dist/ro-RO.module.js.map +1 -0
  161. package/dist/ru-RU.main.js +6 -0
  162. package/dist/ru-RU.main.js.map +1 -0
  163. package/dist/ru-RU.mjs +8 -0
  164. package/dist/ru-RU.module.js +8 -0
  165. package/dist/ru-RU.module.js.map +1 -0
  166. package/dist/sk-SK.main.js +6 -0
  167. package/dist/sk-SK.main.js.map +1 -0
  168. package/dist/sk-SK.mjs +8 -0
  169. package/dist/sk-SK.module.js +8 -0
  170. package/dist/sk-SK.module.js.map +1 -0
  171. package/dist/sl-SI.main.js +6 -0
  172. package/dist/sl-SI.main.js.map +1 -0
  173. package/dist/sl-SI.mjs +8 -0
  174. package/dist/sl-SI.module.js +8 -0
  175. package/dist/sl-SI.module.js.map +1 -0
  176. package/dist/sr-SP.main.js +6 -0
  177. package/dist/sr-SP.main.js.map +1 -0
  178. package/dist/sr-SP.mjs +8 -0
  179. package/dist/sr-SP.module.js +8 -0
  180. package/dist/sr-SP.module.js.map +1 -0
  181. package/dist/sv-SE.main.js +6 -0
  182. package/dist/sv-SE.main.js.map +1 -0
  183. package/dist/sv-SE.mjs +8 -0
  184. package/dist/sv-SE.module.js +8 -0
  185. package/dist/sv-SE.module.js.map +1 -0
  186. package/dist/tr-TR.main.js +6 -0
  187. package/dist/tr-TR.main.js.map +1 -0
  188. package/dist/tr-TR.mjs +8 -0
  189. package/dist/tr-TR.module.js +8 -0
  190. package/dist/tr-TR.module.js.map +1 -0
  191. package/dist/types.d.ts +8 -1
  192. package/dist/types.d.ts.map +1 -1
  193. package/dist/uk-UA.main.js +6 -0
  194. package/dist/uk-UA.main.js.map +1 -0
  195. package/dist/uk-UA.mjs +8 -0
  196. package/dist/uk-UA.module.js +8 -0
  197. package/dist/uk-UA.module.js.map +1 -0
  198. package/dist/useCloseOnScroll.main.js +46 -0
  199. package/dist/useCloseOnScroll.main.js.map +1 -0
  200. package/dist/useCloseOnScroll.mjs +40 -0
  201. package/dist/useCloseOnScroll.module.js +40 -0
  202. package/dist/useCloseOnScroll.module.js.map +1 -0
  203. package/dist/useModal.main.js +114 -0
  204. package/dist/useModal.main.js.map +1 -0
  205. package/dist/useModal.mjs +101 -0
  206. package/dist/useModal.module.js +101 -0
  207. package/dist/useModal.module.js.map +1 -0
  208. package/dist/useModalOverlay.main.js +55 -0
  209. package/dist/useModalOverlay.main.js.map +1 -0
  210. package/dist/useModalOverlay.mjs +50 -0
  211. package/dist/useModalOverlay.module.js +50 -0
  212. package/dist/useModalOverlay.module.js.map +1 -0
  213. package/dist/useOverlay.main.js +105 -0
  214. package/dist/useOverlay.main.js.map +1 -0
  215. package/dist/useOverlay.mjs +100 -0
  216. package/dist/useOverlay.module.js +100 -0
  217. package/dist/useOverlay.module.js.map +1 -0
  218. package/dist/useOverlayPosition.main.js +181 -0
  219. package/dist/useOverlayPosition.main.js.map +1 -0
  220. package/dist/useOverlayPosition.mjs +176 -0
  221. package/dist/useOverlayPosition.module.js +176 -0
  222. package/dist/useOverlayPosition.module.js.map +1 -0
  223. package/dist/useOverlayTrigger.main.js +54 -0
  224. package/dist/useOverlayTrigger.main.js.map +1 -0
  225. package/dist/useOverlayTrigger.mjs +49 -0
  226. package/dist/useOverlayTrigger.module.js +49 -0
  227. package/dist/useOverlayTrigger.module.js.map +1 -0
  228. package/dist/usePopover.main.js +66 -0
  229. package/dist/usePopover.main.js.map +1 -0
  230. package/dist/usePopover.mjs +61 -0
  231. package/dist/usePopover.module.js +61 -0
  232. package/dist/usePopover.module.js.map +1 -0
  233. package/dist/usePreventScroll.main.js +226 -0
  234. package/dist/usePreventScroll.main.js.map +1 -0
  235. package/dist/usePreventScroll.mjs +221 -0
  236. package/dist/usePreventScroll.module.js +221 -0
  237. package/dist/usePreventScroll.module.js.map +1 -0
  238. package/dist/zh-CN.main.js +6 -0
  239. package/dist/zh-CN.main.js.map +1 -0
  240. package/dist/zh-CN.mjs +8 -0
  241. package/dist/zh-CN.module.js +8 -0
  242. package/dist/zh-CN.module.js.map +1 -0
  243. package/dist/zh-TW.main.js +6 -0
  244. package/dist/zh-TW.main.js.map +1 -0
  245. package/dist/zh-TW.mjs +8 -0
  246. package/dist/zh-TW.module.js +8 -0
  247. package/dist/zh-TW.module.js.map +1 -0
  248. package/package.json +12 -12
  249. package/src/Overlay.tsx +6 -0
  250. package/src/PortalProvider.tsx +34 -0
  251. package/src/index.ts +1 -0
  252. package/src/useModalOverlay.ts +2 -2
  253. package/src/useOverlay.ts +1 -1
package/dist/import.mjs CHANGED
@@ -1,710 +1,14 @@
1
- import $k7QOs$react, {useState as $k7QOs$useState, useRef as $k7QOs$useRef, useEffect as $k7QOs$useEffect, useCallback as $k7QOs$useCallback, useContext as $k7QOs$useContext, useMemo as $k7QOs$useMemo} from "react";
2
- import {useLayoutEffect as $k7QOs$useLayoutEffect, useResizeObserver as $k7QOs$useResizeObserver, isWebKit as $k7QOs$isWebKit, clamp as $k7QOs$clamp, useId as $k7QOs$useId, isIOS as $k7QOs$isIOS, chain as $k7QOs$chain, getScrollParent as $k7QOs$getScrollParent, useLabels as $k7QOs$useLabels, mergeProps as $k7QOs$mergeProps} from "@react-aria/utils";
3
- import {useLocale as $k7QOs$useLocale, useLocalizedStringFormatter as $k7QOs$useLocalizedStringFormatter} from "@react-aria/i18n";
4
- import {isElementInChildOfActiveScope as $k7QOs$isElementInChildOfActiveScope, FocusScope as $k7QOs$FocusScope} from "@react-aria/focus";
5
- import {useInteractOutside as $k7QOs$useInteractOutside, useFocusWithin as $k7QOs$useFocusWithin, ClearPressResponder as $k7QOs$ClearPressResponder} from "@react-aria/interactions";
6
- import $k7QOs$reactdom from "react-dom";
7
- import {useIsSSR as $k7QOs$useIsSSR} from "@react-aria/ssr";
8
- import {VisuallyHidden as $k7QOs$VisuallyHidden} from "@react-aria/visually-hidden";
9
-
10
-
11
- function $parcel$interopDefault(a) {
12
- return a && a.__esModule ? a.default : a;
13
- }
14
- /*
15
- * Copyright 2020 Adobe. All rights reserved.
16
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
- * you may not use this file except in compliance with the License. You may obtain a copy
18
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
19
- *
20
- * Unless required by applicable law or agreed to in writing, software distributed under
21
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
22
- * OF ANY KIND, either express or implied. See the License for the specific language
23
- * governing permissions and limitations under the License.
24
- */ /*
25
- * Copyright 2020 Adobe. All rights reserved.
26
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
27
- * you may not use this file except in compliance with the License. You may obtain a copy
28
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
29
- *
30
- * Unless required by applicable law or agreed to in writing, software distributed under
31
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
32
- * OF ANY KIND, either express or implied. See the License for the specific language
33
- * governing permissions and limitations under the License.
34
- */ /*
35
- * Copyright 2020 Adobe. All rights reserved.
36
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
37
- * you may not use this file except in compliance with the License. You may obtain a copy
38
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
39
- *
40
- * Unless required by applicable law or agreed to in writing, software distributed under
41
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
42
- * OF ANY KIND, either express or implied. See the License for the specific language
43
- * governing permissions and limitations under the License.
44
- */
45
- const $edcf132a9284368a$var$AXIS = {
46
- top: "top",
47
- bottom: "top",
48
- left: "left",
49
- right: "left"
50
- };
51
- const $edcf132a9284368a$var$FLIPPED_DIRECTION = {
52
- top: "bottom",
53
- bottom: "top",
54
- left: "right",
55
- right: "left"
56
- };
57
- const $edcf132a9284368a$var$CROSS_AXIS = {
58
- top: "left",
59
- left: "top"
60
- };
61
- const $edcf132a9284368a$var$AXIS_SIZE = {
62
- top: "height",
63
- left: "width"
64
- };
65
- const $edcf132a9284368a$var$TOTAL_SIZE = {
66
- width: "totalWidth",
67
- height: "totalHeight"
68
- };
69
- const $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE = {};
70
- // @ts-ignore
71
- let $edcf132a9284368a$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
72
- function $edcf132a9284368a$var$getContainerDimensions(containerNode) {
73
- let width = 0, height = 0, totalWidth = 0, totalHeight = 0, top = 0, left = 0;
74
- let scroll = {};
75
- let isPinchZoomedIn = ($edcf132a9284368a$var$visualViewport === null || $edcf132a9284368a$var$visualViewport === void 0 ? void 0 : $edcf132a9284368a$var$visualViewport.scale) > 1;
76
- if (containerNode.tagName === "BODY") {
77
- let documentElement = document.documentElement;
78
- totalWidth = documentElement.clientWidth;
79
- totalHeight = documentElement.clientHeight;
80
- var _visualViewport_width;
81
- width = (_visualViewport_width = $edcf132a9284368a$var$visualViewport === null || $edcf132a9284368a$var$visualViewport === void 0 ? void 0 : $edcf132a9284368a$var$visualViewport.width) !== null && _visualViewport_width !== void 0 ? _visualViewport_width : totalWidth;
82
- var _visualViewport_height;
83
- height = (_visualViewport_height = $edcf132a9284368a$var$visualViewport === null || $edcf132a9284368a$var$visualViewport === void 0 ? void 0 : $edcf132a9284368a$var$visualViewport.height) !== null && _visualViewport_height !== void 0 ? _visualViewport_height : totalHeight;
84
- scroll.top = documentElement.scrollTop || containerNode.scrollTop;
85
- scroll.left = documentElement.scrollLeft || containerNode.scrollLeft;
86
- // The goal of the below is to get a top/left value that represents the top/left of the visual viewport with
87
- // respect to the layout viewport origin. This combined with the scrollTop/scrollLeft will allow us to calculate
88
- // coordinates/values with respect to the visual viewport or with respect to the layout viewport.
89
- if ($edcf132a9284368a$var$visualViewport) {
90
- top = $edcf132a9284368a$var$visualViewport.offsetTop;
91
- left = $edcf132a9284368a$var$visualViewport.offsetLeft;
92
- }
93
- } else {
94
- ({ width: width, height: height, top: top, left: left } = $edcf132a9284368a$var$getOffset(containerNode));
95
- scroll.top = containerNode.scrollTop;
96
- scroll.left = containerNode.scrollLeft;
97
- totalWidth = width;
98
- totalHeight = height;
99
- }
100
- if ((0, $k7QOs$isWebKit)() && (containerNode.tagName === "BODY" || containerNode.tagName === "HTML") && isPinchZoomedIn) {
101
- // Safari will report a non-zero scrollTop/Left for the non-scrolling body/HTML element when pinch zoomed in unlike other browsers.
102
- // Set to zero for parity calculations so we get consistent positioning of overlays across all browsers.
103
- // Also switch to visualViewport.pageTop/pageLeft so that we still accomodate for scroll positioning for body/HTML elements that are actually scrollable
104
- // before pinch zoom happens
105
- scroll.top = 0;
106
- scroll.left = 0;
107
- top = $edcf132a9284368a$var$visualViewport.pageTop;
108
- left = $edcf132a9284368a$var$visualViewport.pageLeft;
109
- }
110
- return {
111
- width: width,
112
- height: height,
113
- totalWidth: totalWidth,
114
- totalHeight: totalHeight,
115
- scroll: scroll,
116
- top: top,
117
- left: left
118
- };
119
- }
120
- function $edcf132a9284368a$var$getScroll(node) {
121
- return {
122
- top: node.scrollTop,
123
- left: node.scrollLeft,
124
- width: node.scrollWidth,
125
- height: node.scrollHeight
126
- };
127
- }
128
- // Determines the amount of space required when moving the overlay to ensure it remains in the boundary
129
- function $edcf132a9284368a$var$getDelta(axis, offset, size, // The dimensions of the boundary element that the popover is
130
- // positioned within (most of the time this is the <body>).
131
- boundaryDimensions, // The dimensions of the containing block element that the popover is
132
- // positioned relative to (e.g. parent with position: relative).
133
- // Usually this is the same as the boundary element, but if the popover
134
- // is portaled somewhere other than the body and has an ancestor with
135
- // position: relative/absolute, it will be different.
136
- containerDimensions, padding, containerOffsetWithBoundary) {
137
- let containerScroll = containerDimensions.scroll[axis];
138
- // The height/width of the boundary. Matches the axis along which we are adjusting the overlay position
139
- let boundarySize = boundaryDimensions[$edcf132a9284368a$var$AXIS_SIZE[axis]];
140
- // Calculate the edges of the boundary (accomodating for the boundary padding) and the edges of the overlay.
141
- // Note that these values are with respect to the visual viewport (aka 0,0 is the top left of the viewport)
142
- let boundaryStartEdge = boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] + padding;
143
- let boundaryEndEdge = boundarySize + boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] - padding;
144
- let startEdgeOffset = offset - containerScroll + containerOffsetWithBoundary[axis] - boundaryDimensions[$edcf132a9284368a$var$AXIS[axis]];
145
- let endEdgeOffset = offset - containerScroll + size + containerOffsetWithBoundary[axis] - boundaryDimensions[$edcf132a9284368a$var$AXIS[axis]];
146
- // If any of the overlay edges falls outside of the boundary, shift the overlay the required amount to align one of the overlay's
147
- // edges with the closest boundary edge.
148
- if (startEdgeOffset < boundaryStartEdge) return boundaryStartEdge - startEdgeOffset;
149
- else if (endEdgeOffset > boundaryEndEdge) return Math.max(boundaryEndEdge - endEdgeOffset, boundaryStartEdge - startEdgeOffset);
150
- else return 0;
151
- }
152
- function $edcf132a9284368a$var$getMargins(node) {
153
- let style = window.getComputedStyle(node);
154
- return {
155
- top: parseInt(style.marginTop, 10) || 0,
156
- bottom: parseInt(style.marginBottom, 10) || 0,
157
- left: parseInt(style.marginLeft, 10) || 0,
158
- right: parseInt(style.marginRight, 10) || 0
159
- };
160
- }
161
- function $edcf132a9284368a$var$parsePlacement(input) {
162
- if ($edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input]) return $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input];
163
- let [placement, crossPlacement] = input.split(" ");
164
- let axis = $edcf132a9284368a$var$AXIS[placement] || "right";
165
- let crossAxis = $edcf132a9284368a$var$CROSS_AXIS[axis];
166
- if (!$edcf132a9284368a$var$AXIS[crossPlacement]) crossPlacement = "center";
167
- let size = $edcf132a9284368a$var$AXIS_SIZE[axis];
168
- let crossSize = $edcf132a9284368a$var$AXIS_SIZE[crossAxis];
169
- $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input] = {
170
- placement: placement,
171
- crossPlacement: crossPlacement,
172
- axis: axis,
173
- crossAxis: crossAxis,
174
- size: size,
175
- crossSize: crossSize
176
- };
177
- return $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input];
178
- }
179
- function $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset) {
180
- let { placement: placement, crossPlacement: crossPlacement, axis: axis, crossAxis: crossAxis, size: size, crossSize: crossSize } = placementInfo;
181
- let position = {};
182
- // button position
183
- position[crossAxis] = childOffset[crossAxis];
184
- if (crossPlacement === "center") // + (button size / 2) - (overlay size / 2)
185
- // at this point the overlay center should match the button center
186
- position[crossAxis] += (childOffset[crossSize] - overlaySize[crossSize]) / 2;
187
- else if (crossPlacement !== crossAxis) // + (button size) - (overlay size)
188
- // at this point the overlay bottom should match the button bottom
189
- position[crossAxis] += childOffset[crossSize] - overlaySize[crossSize];
190
- /* else {
191
- the overlay top should match the button top
192
- } */
193
- position[crossAxis] += crossOffset;
194
- // overlay top overlapping arrow with button bottom
195
- const minPosition = childOffset[crossAxis] - overlaySize[crossSize] + arrowSize + arrowBoundaryOffset;
196
- // overlay bottom overlapping arrow with button top
197
- const maxPosition = childOffset[crossAxis] + childOffset[crossSize] - arrowSize - arrowBoundaryOffset;
198
- position[crossAxis] = (0, $k7QOs$clamp)(position[crossAxis], minPosition, maxPosition);
199
- // Floor these so the position isn't placed on a partial pixel, only whole pixels. Shouldn't matter if it was floored or ceiled, so chose one.
200
- if (placement === axis) {
201
- // If the container is positioned (non-static), then we use the container's actual
202
- // height, as `bottom` will be relative to this height. But if the container is static,
203
- // then it can only be the `document.body`, and `bottom` will be relative to _its_
204
- // container, which should be as large as boundaryDimensions.
205
- const containerHeight = isContainerPositioned ? containerOffsetWithBoundary[size] : boundaryDimensions[$edcf132a9284368a$var$TOTAL_SIZE[size]];
206
- position[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] = Math.floor(containerHeight - childOffset[axis] + offset);
207
- } else position[axis] = Math.floor(childOffset[axis] + childOffset[size] + offset);
208
- return position;
209
- }
210
- function $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlayHeight, heightGrowthDirection) {
211
- const containerHeight = isContainerPositioned ? containerOffsetWithBoundary.height : boundaryDimensions[$edcf132a9284368a$var$TOTAL_SIZE.height];
212
- // For cases where position is set via "bottom" instead of "top", we need to calculate the true overlay top with respect to the boundary. Reverse calculate this with the same method
213
- // used in computePosition.
214
- let overlayTop = position.top != null ? containerOffsetWithBoundary.top + position.top : containerOffsetWithBoundary.top + (containerHeight - position.bottom - overlayHeight);
215
- let maxHeight = heightGrowthDirection !== "top" ? // We want the distance between the top of the overlay to the bottom of the boundary
216
- Math.max(0, boundaryDimensions.height + boundaryDimensions.top + boundaryDimensions.scroll.top // this is the bottom of the boundary
217
- - overlayTop // this is the top of the overlay
218
- - (margins.top + margins.bottom + padding // save additional space for margin and padding
219
- )) : Math.max(0, overlayTop + overlayHeight // this is the bottom of the overlay
220
- - (boundaryDimensions.top + boundaryDimensions.scroll.top // this is the top of the boundary
221
- ) - (margins.top + margins.bottom + padding // save additional space for margin and padding
222
- ));
223
- return Math.min(boundaryDimensions.height - padding * 2, maxHeight);
224
- }
225
- function $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding, placementInfo) {
226
- let { placement: placement, axis: axis, size: size } = placementInfo;
227
- if (placement === axis) return Math.max(0, childOffset[axis] - boundaryDimensions[axis] - boundaryDimensions.scroll[axis] + containerOffsetWithBoundary[axis] - margins[axis] - margins[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] - padding);
228
- return Math.max(0, boundaryDimensions[size] + boundaryDimensions[axis] + boundaryDimensions.scroll[axis] - containerOffsetWithBoundary[axis] - childOffset[axis] - childOffset[size] - margins[axis] - margins[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] - padding);
229
- }
230
- function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset, overlaySize, scrollSize, margins, padding, flip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, userSetMaxHeight, arrowSize, arrowBoundaryOffset) {
231
- let placementInfo = $edcf132a9284368a$var$parsePlacement(placementInput);
232
- let { size: size, crossAxis: crossAxis, crossSize: crossSize, placement: placement, crossPlacement: crossPlacement } = placementInfo;
233
- let position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
234
- let normalizedOffset = offset;
235
- let space = $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, placementInfo);
236
- // Check if the scroll size of the overlay is greater than the available space to determine if we need to flip
237
- if (flip && scrollSize[size] > space) {
238
- let flippedPlacementInfo = $edcf132a9284368a$var$parsePlacement(`${$edcf132a9284368a$var$FLIPPED_DIRECTION[placement]} ${crossPlacement}`);
239
- let flippedPosition = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, flippedPlacementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
240
- let flippedSpace = $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, flippedPlacementInfo);
241
- // If the available space for the flipped position is greater than the original available space, flip.
242
- if (flippedSpace > space) {
243
- placementInfo = flippedPlacementInfo;
244
- position = flippedPosition;
245
- normalizedOffset = offset;
246
- }
247
- }
248
- // Determine the direction the height of the overlay can grow so that we can choose how to calculate the max height
249
- let heightGrowthDirection = "bottom";
250
- if (placementInfo.axis === "top") {
251
- if (placementInfo.placement === "top") heightGrowthDirection = "top";
252
- else if (placementInfo.placement === "bottom") heightGrowthDirection = "bottom";
253
- } else if (placementInfo.crossAxis === "top") {
254
- if (placementInfo.crossPlacement === "top") heightGrowthDirection = "bottom";
255
- else if (placementInfo.crossPlacement === "bottom") heightGrowthDirection = "top";
256
- }
257
- let delta = $edcf132a9284368a$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);
258
- position[crossAxis] += delta;
259
- let maxHeight = $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlaySize.height, heightGrowthDirection);
260
- if (userSetMaxHeight && userSetMaxHeight < maxHeight) maxHeight = userSetMaxHeight;
261
- overlaySize.height = Math.min(overlaySize.height, maxHeight);
262
- position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, normalizedOffset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
263
- delta = $edcf132a9284368a$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);
264
- position[crossAxis] += delta;
265
- let arrowPosition = {};
266
- // All values are transformed so that 0 is at the top/left of the overlay depending on the orientation
267
- // Prefer the arrow being in the center of the trigger/overlay anchor element
268
- let preferredArrowPosition = childOffset[crossAxis] + .5 * childOffset[crossSize] - overlaySize[crossAxis];
269
- // Min/Max position limits for the arrow with respect to the overlay
270
- const arrowMinPosition = arrowSize / 2 + arrowBoundaryOffset;
271
- const arrowMaxPosition = overlaySize[crossSize] - arrowSize / 2 - arrowBoundaryOffset;
272
- // Min/Max position limits for the arrow with respect to the trigger/overlay anchor element
273
- const arrowOverlappingChildMinEdge = childOffset[crossAxis] - overlaySize[crossAxis] + arrowSize / 2;
274
- const arrowOverlappingChildMaxEdge = childOffset[crossAxis] + childOffset[crossSize] - overlaySize[crossAxis] - arrowSize / 2;
275
- // Clamp the arrow positioning so that it always is within the bounds of the anchor and the overlay
276
- const arrowPositionOverlappingChild = (0, $k7QOs$clamp)(preferredArrowPosition, arrowOverlappingChildMinEdge, arrowOverlappingChildMaxEdge);
277
- arrowPosition[crossAxis] = (0, $k7QOs$clamp)(arrowPositionOverlappingChild, arrowMinPosition, arrowMaxPosition);
278
- return {
279
- position: position,
280
- maxHeight: maxHeight,
281
- arrowOffsetLeft: arrowPosition.left,
282
- arrowOffsetTop: arrowPosition.top,
283
- placement: placementInfo.placement
284
- };
285
- }
286
- function $edcf132a9284368a$export$b3ceb0cbf1056d98(opts) {
287
- let { placement: placement, targetNode: targetNode, overlayNode: overlayNode, scrollNode: scrollNode, padding: padding, shouldFlip: shouldFlip, boundaryElement: boundaryElement, offset: offset, crossOffset: crossOffset, maxHeight: maxHeight, arrowSize: arrowSize = 0, arrowBoundaryOffset: arrowBoundaryOffset = 0 } = opts;
288
- let container = overlayNode instanceof HTMLElement ? $edcf132a9284368a$var$getContainingBlock(overlayNode) : document.documentElement;
289
- let isViewportContainer = container === document.documentElement;
290
- const containerPositionStyle = window.getComputedStyle(container).position;
291
- let isContainerPositioned = !!containerPositionStyle && containerPositionStyle !== "static";
292
- let childOffset = isViewportContainer ? $edcf132a9284368a$var$getOffset(targetNode) : $edcf132a9284368a$var$getPosition(targetNode, container);
293
- if (!isViewportContainer) {
294
- let { marginTop: marginTop, marginLeft: marginLeft } = window.getComputedStyle(targetNode);
295
- childOffset.top += parseInt(marginTop, 10) || 0;
296
- childOffset.left += parseInt(marginLeft, 10) || 0;
297
- }
298
- let overlaySize = $edcf132a9284368a$var$getOffset(overlayNode);
299
- let margins = $edcf132a9284368a$var$getMargins(overlayNode);
300
- overlaySize.width += margins.left + margins.right;
301
- overlaySize.height += margins.top + margins.bottom;
302
- let scrollSize = $edcf132a9284368a$var$getScroll(scrollNode);
303
- let boundaryDimensions = $edcf132a9284368a$var$getContainerDimensions(boundaryElement);
304
- let containerDimensions = $edcf132a9284368a$var$getContainerDimensions(container);
305
- // If the container is the HTML element wrapping the body element, the retrieved scrollTop/scrollLeft will be equal to the
306
- // body element's scroll. Set the container's scroll values to 0 since the overlay's edge position value in getDelta don't then need to be further offset
307
- // by the container scroll since they are essentially the same containing element and thus in the same coordinate system
308
- let containerOffsetWithBoundary = boundaryElement.tagName === "BODY" ? $edcf132a9284368a$var$getOffset(container) : $edcf132a9284368a$var$getPosition(container, boundaryElement);
309
- if (container.tagName === "HTML" && boundaryElement.tagName === "BODY") {
310
- containerDimensions.scroll.top = 0;
311
- containerDimensions.scroll.left = 0;
312
- }
313
- return $edcf132a9284368a$export$6839422d1f33cee9(placement, childOffset, overlaySize, scrollSize, margins, padding, shouldFlip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, maxHeight, arrowSize, arrowBoundaryOffset);
314
- }
315
- function $edcf132a9284368a$var$getOffset(node) {
316
- let { top: top, left: left, width: width, height: height } = node.getBoundingClientRect();
317
- let { scrollTop: scrollTop, scrollLeft: scrollLeft, clientTop: clientTop, clientLeft: clientLeft } = document.documentElement;
318
- return {
319
- top: top + scrollTop - clientTop,
320
- left: left + scrollLeft - clientLeft,
321
- width: width,
322
- height: height
323
- };
324
- }
325
- function $edcf132a9284368a$var$getPosition(node, parent) {
326
- let style = window.getComputedStyle(node);
327
- let offset;
328
- if (style.position === "fixed") {
329
- let { top: top, left: left, width: width, height: height } = node.getBoundingClientRect();
330
- offset = {
331
- top: top,
332
- left: left,
333
- width: width,
334
- height: height
335
- };
336
- } else {
337
- offset = $edcf132a9284368a$var$getOffset(node);
338
- let parentOffset = $edcf132a9284368a$var$getOffset(parent);
339
- let parentStyle = window.getComputedStyle(parent);
340
- parentOffset.top += (parseInt(parentStyle.borderTopWidth, 10) || 0) - parent.scrollTop;
341
- parentOffset.left += (parseInt(parentStyle.borderLeftWidth, 10) || 0) - parent.scrollLeft;
342
- offset.top -= parentOffset.top;
343
- offset.left -= parentOffset.left;
344
- }
345
- offset.top -= parseInt(style.marginTop, 10) || 0;
346
- offset.left -= parseInt(style.marginLeft, 10) || 0;
347
- return offset;
348
- }
349
- // Returns the containing block of an element, which is the element that
350
- // this element will be positioned relative to.
351
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block
352
- function $edcf132a9284368a$var$getContainingBlock(node) {
353
- // The offsetParent of an element in most cases equals the containing block.
354
- // https://w3c.github.io/csswg-drafts/cssom-view/#dom-htmlelement-offsetparent
355
- let offsetParent = node.offsetParent;
356
- // The offsetParent algorithm terminates at the document body,
357
- // even if the body is not a containing block. Double check that
358
- // and use the documentElement if so.
359
- if (offsetParent && offsetParent === document.body && window.getComputedStyle(offsetParent).position === "static" && !$edcf132a9284368a$var$isContainingBlock(offsetParent)) offsetParent = document.documentElement;
360
- // TODO(later): handle table elements?
361
- // The offsetParent can be null if the element has position: fixed, or a few other cases.
362
- // We have to walk up the tree manually in this case because fixed positioned elements
363
- // are still positioned relative to their containing block, which is not always the viewport.
364
- if (offsetParent == null) {
365
- offsetParent = node.parentElement;
366
- while(offsetParent && !$edcf132a9284368a$var$isContainingBlock(offsetParent))offsetParent = offsetParent.parentElement;
367
- }
368
- // Fall back to the viewport.
369
- return offsetParent || document.documentElement;
370
- }
371
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
372
- function $edcf132a9284368a$var$isContainingBlock(node) {
373
- let style = window.getComputedStyle(node);
374
- return style.transform !== "none" || /transform|perspective/.test(style.willChange) || style.filter !== "none" || style.contain === "paint" || // @ts-ignore
375
- "backdropFilter" in style && style.backdropFilter !== "none" || // @ts-ignore
376
- "WebkitBackdropFilter" in style && style.WebkitBackdropFilter !== "none";
377
- }
378
-
379
-
380
-
381
- /*
382
- * Copyright 2020 Adobe. All rights reserved.
383
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
384
- * you may not use this file except in compliance with the License. You may obtain a copy
385
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
386
- *
387
- * Unless required by applicable law or agreed to in writing, software distributed under
388
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
389
- * OF ANY KIND, either express or implied. See the License for the specific language
390
- * governing permissions and limitations under the License.
391
- */
392
- const $dd149f63282afbbf$export$f6211563215e3b37 = new WeakMap();
393
- function $dd149f63282afbbf$export$18fc8428861184da(opts) {
394
- let { triggerRef: triggerRef, isOpen: isOpen, onClose: onClose } = opts;
395
- (0, $k7QOs$useEffect)(()=>{
396
- if (!isOpen || onClose === null) return;
397
- let onScroll = (e)=>{
398
- // Ignore if scrolling an scrollable region outside the trigger's tree.
399
- let target = e.target;
400
- // window is not a Node and doesn't have contain, but window contains everything
401
- if (!triggerRef.current || target instanceof Node && !target.contains(triggerRef.current)) return;
402
- let onCloseHandler = onClose || $dd149f63282afbbf$export$f6211563215e3b37.get(triggerRef.current);
403
- if (onCloseHandler) onCloseHandler();
404
- };
405
- window.addEventListener("scroll", onScroll, true);
406
- return ()=>{
407
- window.removeEventListener("scroll", onScroll, true);
408
- };
409
- }, [
410
- isOpen,
411
- onClose,
412
- triggerRef
413
- ]);
414
- }
415
-
416
-
417
-
418
-
419
- // @ts-ignore
420
- let $2a41e45df1593e64$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
421
- function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
422
- let { direction: direction } = (0, $k7QOs$useLocale)();
423
- let { arrowSize: arrowSize = 0, targetRef: targetRef, overlayRef: overlayRef, 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;
424
- let [position, setPosition] = (0, $k7QOs$useState)({
425
- position: {},
426
- arrowOffsetLeft: undefined,
427
- arrowOffsetTop: undefined,
428
- maxHeight: undefined,
429
- placement: undefined
430
- });
431
- let deps = [
432
- shouldUpdatePosition,
433
- placement,
434
- overlayRef.current,
435
- targetRef.current,
436
- scrollRef.current,
437
- containerPadding,
438
- shouldFlip,
439
- boundaryElement,
440
- offset,
441
- crossOffset,
442
- isOpen,
443
- direction,
444
- maxHeight,
445
- arrowBoundaryOffset,
446
- arrowSize
447
- ];
448
- // Note, the position freezing breaks if body sizes itself dynamicly with the visual viewport but that might
449
- // just be a non-realistic use case
450
- // Upon opening a overlay, record the current visual viewport scale so we can freeze the overlay styles
451
- let lastScale = (0, $k7QOs$useRef)($2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale);
452
- (0, $k7QOs$useEffect)(()=>{
453
- if (isOpen) lastScale.current = $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale;
454
- }, [
455
- isOpen
456
- ]);
457
- let updatePosition = (0, $k7QOs$useCallback)(()=>{
458
- if (shouldUpdatePosition === false || !isOpen || !overlayRef.current || !targetRef.current || !scrollRef.current || !boundaryElement) return;
459
- if (($2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale) !== lastScale.current) return;
460
- // Always reset the overlay's previous max height if not defined by the user so that we can compensate for
461
- // RAC collections populating after a second render and properly set a correct max height + positioning when it populates.
462
- if (!maxHeight && overlayRef.current) overlayRef.current.style.maxHeight = "none";
463
- let position = (0, $edcf132a9284368a$export$b3ceb0cbf1056d98)({
464
- placement: $2a41e45df1593e64$var$translateRTL(placement, direction),
465
- overlayNode: overlayRef.current,
466
- targetNode: targetRef.current,
467
- scrollNode: scrollRef.current,
468
- padding: containerPadding,
469
- shouldFlip: shouldFlip,
470
- boundaryElement: boundaryElement,
471
- offset: offset,
472
- crossOffset: crossOffset,
473
- maxHeight: maxHeight,
474
- arrowSize: arrowSize,
475
- arrowBoundaryOffset: arrowBoundaryOffset
476
- });
477
- // Modify overlay styles directly so positioning happens immediately without the need of a second render
478
- // This is so we don't have to delay autoFocus scrolling or delay applying preventScroll for popovers
479
- Object.keys(position.position).forEach((key)=>overlayRef.current.style[key] = position.position[key] + "px");
480
- overlayRef.current.style.maxHeight = position.maxHeight != null ? position.maxHeight + "px" : undefined;
481
- // Trigger a set state for a second render anyway for arrow positioning
482
- setPosition(position);
483
- // eslint-disable-next-line react-hooks/exhaustive-deps
484
- }, deps);
485
- // Update position when anything changes
486
- // eslint-disable-next-line react-hooks/exhaustive-deps
487
- (0, $k7QOs$useLayoutEffect)(updatePosition, deps);
488
- // Update position on window resize
489
- $2a41e45df1593e64$var$useResize(updatePosition);
490
- // Update position when the overlay changes size (might need to flip).
491
- (0, $k7QOs$useResizeObserver)({
492
- ref: overlayRef,
493
- onResize: updatePosition
494
- });
495
- // Reposition the overlay and do not close on scroll while the visual viewport is resizing.
496
- // This will ensure that overlays adjust their positioning when the iOS virtual keyboard appears.
497
- let isResizing = (0, $k7QOs$useRef)(false);
498
- (0, $k7QOs$useLayoutEffect)(()=>{
499
- let timeout;
500
- let onResize = ()=>{
501
- isResizing.current = true;
502
- clearTimeout(timeout);
503
- timeout = setTimeout(()=>{
504
- isResizing.current = false;
505
- }, 500);
506
- updatePosition();
507
- };
508
- // Only reposition the overlay if a scroll event happens immediately as a result of resize (aka the virtual keyboard has appears)
509
- // We don't want to reposition the overlay if the user has pinch zoomed in and is scrolling the viewport around.
510
- let onScroll = ()=>{
511
- if (isResizing.current) onResize();
512
- };
513
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.addEventListener("resize", onResize);
514
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.addEventListener("scroll", onScroll);
515
- return ()=>{
516
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.removeEventListener("resize", onResize);
517
- $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.removeEventListener("scroll", onScroll);
518
- };
519
- }, [
520
- updatePosition
521
- ]);
522
- let close = (0, $k7QOs$useCallback)(()=>{
523
- if (!isResizing.current) onClose();
524
- }, [
525
- onClose,
526
- isResizing
527
- ]);
528
- // When scrolling a parent scrollable region of the trigger (other than the body),
529
- // we hide the popover. Otherwise, its position would be incorrect.
530
- (0, $dd149f63282afbbf$export$18fc8428861184da)({
531
- triggerRef: targetRef,
532
- isOpen: isOpen,
533
- onClose: onClose && close
534
- });
535
- return {
536
- overlayProps: {
537
- style: {
538
- position: "absolute",
539
- zIndex: 100000,
540
- ...position.position,
541
- maxHeight: position.maxHeight
542
- }
543
- },
544
- placement: position.placement,
545
- arrowProps: {
546
- "aria-hidden": "true",
547
- role: "presentation",
548
- style: {
549
- left: position.arrowOffsetLeft,
550
- top: position.arrowOffsetTop
551
- }
552
- },
553
- updatePosition: updatePosition
554
- };
555
- }
556
- function $2a41e45df1593e64$var$useResize(onResize) {
557
- (0, $k7QOs$useLayoutEffect)(()=>{
558
- window.addEventListener("resize", onResize, false);
559
- return ()=>{
560
- window.removeEventListener("resize", onResize, false);
561
- };
562
- }, [
563
- onResize
564
- ]);
565
- }
566
- function $2a41e45df1593e64$var$translateRTL(position, direction) {
567
- if (direction === "rtl") return position.replace("start", "right").replace("end", "left");
568
- return position.replace("start", "left").replace("end", "right");
569
- }
570
-
571
-
572
- /*
573
- * Copyright 2020 Adobe. All rights reserved.
574
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
575
- * you may not use this file except in compliance with the License. You may obtain a copy
576
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
577
- *
578
- * Unless required by applicable law or agreed to in writing, software distributed under
579
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
580
- * OF ANY KIND, either express or implied. See the License for the specific language
581
- * governing permissions and limitations under the License.
582
- */
583
-
584
-
585
- const $a11501f3d1d39e6c$var$visibleOverlays = [];
586
- function $a11501f3d1d39e6c$export$ea8f71083e90600f(props, ref) {
587
- let { onClose: onClose, shouldCloseOnBlur: shouldCloseOnBlur, isOpen: isOpen, isDismissable: isDismissable = false, isKeyboardDismissDisabled: isKeyboardDismissDisabled = false, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside } = props;
588
- // Add the overlay ref to the stack of visible overlays on mount, and remove on unmount.
589
- (0, $k7QOs$useEffect)(()=>{
590
- if (isOpen) $a11501f3d1d39e6c$var$visibleOverlays.push(ref);
591
- return ()=>{
592
- let index = $a11501f3d1d39e6c$var$visibleOverlays.indexOf(ref);
593
- if (index >= 0) $a11501f3d1d39e6c$var$visibleOverlays.splice(index, 1);
594
- };
595
- }, [
596
- isOpen,
597
- ref
598
- ]);
599
- // Only hide the overlay when it is the topmost visible overlay in the stack
600
- let onHide = ()=>{
601
- if ($a11501f3d1d39e6c$var$visibleOverlays[$a11501f3d1d39e6c$var$visibleOverlays.length - 1] === ref && onClose) onClose();
602
- };
603
- let onInteractOutsideStart = (e)=>{
604
- if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside(e.target)) {
605
- if ($a11501f3d1d39e6c$var$visibleOverlays[$a11501f3d1d39e6c$var$visibleOverlays.length - 1] === ref) {
606
- e.stopPropagation();
607
- e.preventDefault();
608
- }
609
- }
610
- };
611
- let onInteractOutside = (e)=>{
612
- if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside(e.target)) {
613
- if ($a11501f3d1d39e6c$var$visibleOverlays[$a11501f3d1d39e6c$var$visibleOverlays.length - 1] === ref) {
614
- e.stopPropagation();
615
- e.preventDefault();
616
- }
617
- onHide();
618
- }
619
- };
620
- // Handle the escape key
621
- let onKeyDown = (e)=>{
622
- if (e.key === "Escape" && !isKeyboardDismissDisabled) {
623
- e.stopPropagation();
624
- e.preventDefault();
625
- onHide();
626
- }
627
- };
628
- // Handle clicking outside the overlay to close it
629
- (0, $k7QOs$useInteractOutside)({
630
- ref: ref,
631
- onInteractOutside: isDismissable && isOpen ? onInteractOutside : null,
632
- onInteractOutsideStart: onInteractOutsideStart
633
- });
634
- let { focusWithinProps: focusWithinProps } = (0, $k7QOs$useFocusWithin)({
635
- isDisabled: !shouldCloseOnBlur,
636
- onBlurWithin: (e)=>{
637
- // Do not close if relatedTarget is null, which means focus is lost to the body.
638
- // That can happen when switching tabs, or due to a VoiceOver/Chrome bug with Control+Option+Arrow navigation.
639
- // Clicking on the body to close the overlay should already be handled by useInteractOutside.
640
- // https://github.com/adobe/react-spectrum/issues/4130
641
- // https://github.com/adobe/react-spectrum/issues/4922
642
- //
643
- // If focus is moving into a child focus scope (e.g. menu inside a dialog),
644
- // do not close the outer overlay. At this point, the active scope should
645
- // still be the outer overlay, since blur events run before focus.
646
- if (!e.relatedTarget || (0, $k7QOs$isElementInChildOfActiveScope)(e.relatedTarget)) return;
647
- if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside(e.relatedTarget)) onClose();
648
- }
649
- });
650
- let onPointerDownUnderlay = (e)=>{
651
- // fixes a firefox issue that starts text selection https://bugzilla.mozilla.org/show_bug.cgi?id=1675846
652
- if (e.target === e.currentTarget) e.preventDefault();
653
- };
654
- return {
655
- overlayProps: {
656
- onKeyDown: onKeyDown,
657
- ...focusWithinProps
658
- },
659
- underlayProps: {
660
- onPointerDown: onPointerDownUnderlay
661
- }
662
- };
663
- }
664
-
665
-
666
- /*
667
- * Copyright 2020 Adobe. All rights reserved.
668
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
669
- * you may not use this file except in compliance with the License. You may obtain a copy
670
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
671
- *
672
- * Unless required by applicable law or agreed to in writing, software distributed under
673
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
674
- * OF ANY KIND, either express or implied. See the License for the specific language
675
- * governing permissions and limitations under the License.
676
- */
677
-
678
-
679
- function $628037886ba31236$export$f9d5c8beee7d008d(props, state, ref) {
680
- let { type: type } = props;
681
- let { isOpen: isOpen } = state;
682
- // Backward compatibility. Share state close function with useOverlayPosition so it can close on scroll
683
- // without forcing users to pass onClose.
684
- (0, $k7QOs$useEffect)(()=>{
685
- if (ref && ref.current) (0, $dd149f63282afbbf$export$f6211563215e3b37).set(ref.current, state.close);
686
- });
687
- // Aria 1.1 supports multiple values for aria-haspopup other than just menus.
688
- // https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup
689
- // However, we only add it for menus for now because screen readers often
690
- // announce it as a menu even for other values.
691
- let ariaHasPopup = undefined;
692
- if (type === "menu") ariaHasPopup = true;
693
- else if (type === "listbox") ariaHasPopup = "listbox";
694
- let overlayId = (0, $k7QOs$useId)();
695
- return {
696
- triggerProps: {
697
- "aria-haspopup": ariaHasPopup,
698
- "aria-expanded": isOpen,
699
- "aria-controls": isOpen ? overlayId : null,
700
- onPress: state.toggle
701
- },
702
- overlayProps: {
703
- id: overlayId
704
- }
705
- };
706
- }
707
-
1
+ import {useOverlayPosition as $2a41e45df1593e64$export$d39e1813b3bdd0e1} from "./useOverlayPosition.mjs";
2
+ import {useOverlay as $a11501f3d1d39e6c$export$ea8f71083e90600f} from "./useOverlay.mjs";
3
+ import {useOverlayTrigger as $628037886ba31236$export$f9d5c8beee7d008d} from "./useOverlayTrigger.mjs";
4
+ import {usePreventScroll as $49c51c25361d4cd2$export$ee0f7cc6afcd1c18} from "./usePreventScroll.mjs";
5
+ import {ModalProvider as $f57aed4a881a3485$export$178405afcd8c5eb, OverlayContainer as $f57aed4a881a3485$export$b47c3594eab58386, OverlayProvider as $f57aed4a881a3485$export$bf688221f59024e5, useModal as $f57aed4a881a3485$export$33ffd74ebf07f060, useModalProvider as $f57aed4a881a3485$export$d9aaed4c3ece1bc0} from "./useModal.mjs";
6
+ import {DismissButton as $86ea4cb521eb2e37$export$2317d149ed6f78c4} from "./DismissButton.mjs";
7
+ import {ariaHideOutside as $5e3802645cc19319$export$1c3ebcada18427bf} from "./ariaHideOutside.mjs";
8
+ import {usePopover as $f2f8a6077418541e$export$542a6fd13ac93354} from "./usePopover.mjs";
9
+ import {useModalOverlay as $8ac8429251c45e4b$export$dbc0f175b25fb0fb} from "./useModalOverlay.mjs";
10
+ import {Overlay as $337b884510726a0d$export$c6fdb837b070b4ff, useOverlayFocusContain as $337b884510726a0d$export$14c98a7594375490} from "./Overlay.mjs";
11
+ import {UNSTABLE_PortalProvider as $96b38030c423d352$export$db995ea7163b4b67, useUNSTABLE_PortalContext as $96b38030c423d352$export$574e9b0fb070c3b0} from "./PortalProvider.mjs";
708
12
 
709
13
  /*
710
14
  * Copyright 2020 Adobe. All rights reserved.
@@ -717,842 +21,17 @@ function $628037886ba31236$export$f9d5c8beee7d008d(props, state, ref) {
717
21
  * OF ANY KIND, either express or implied. See the License for the specific language
718
22
  * governing permissions and limitations under the License.
719
23
  */
720
- // @ts-ignore
721
- const $49c51c25361d4cd2$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
722
- // HTML input types that do not cause the software keyboard to appear.
723
- const $49c51c25361d4cd2$var$nonTextInputTypes = new Set([
724
- "checkbox",
725
- "radio",
726
- "range",
727
- "color",
728
- "file",
729
- "image",
730
- "button",
731
- "submit",
732
- "reset"
733
- ]);
734
- // The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position
735
- let $49c51c25361d4cd2$var$preventScrollCount = 0;
736
- let $49c51c25361d4cd2$var$restore;
737
- function $49c51c25361d4cd2$export$ee0f7cc6afcd1c18(options = {}) {
738
- let { isDisabled: isDisabled } = options;
739
- (0, $k7QOs$useLayoutEffect)(()=>{
740
- if (isDisabled) return;
741
- $49c51c25361d4cd2$var$preventScrollCount++;
742
- if ($49c51c25361d4cd2$var$preventScrollCount === 1) {
743
- if ((0, $k7QOs$isIOS)()) $49c51c25361d4cd2$var$restore = $49c51c25361d4cd2$var$preventScrollMobileSafari();
744
- else $49c51c25361d4cd2$var$restore = $49c51c25361d4cd2$var$preventScrollStandard();
745
- }
746
- return ()=>{
747
- $49c51c25361d4cd2$var$preventScrollCount--;
748
- if ($49c51c25361d4cd2$var$preventScrollCount === 0) $49c51c25361d4cd2$var$restore();
749
- };
750
- }, [
751
- isDisabled
752
- ]);
753
- }
754
- // For most browsers, all we need to do is set `overflow: hidden` on the root element, and
755
- // add some padding to prevent the page from shifting when the scrollbar is hidden.
756
- function $49c51c25361d4cd2$var$preventScrollStandard() {
757
- return (0, $k7QOs$chain)($49c51c25361d4cd2$var$setStyle(document.documentElement, "paddingRight", `${window.innerWidth - document.documentElement.clientWidth}px`), $49c51c25361d4cd2$var$setStyle(document.documentElement, "overflow", "hidden"));
758
- }
759
- // Mobile Safari is a whole different beast. Even with overflow: hidden,
760
- // it still scrolls the page in many situations:
761
- //
762
- // 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.
763
- // 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of
764
- // it, so it becomes scrollable.
765
- // 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.
766
- // This may cause even fixed position elements to scroll off the screen.
767
- // 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always
768
- // scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.
769
- //
770
- // In order to work around these cases, and prevent scrolling without jankiness, we do a few things:
771
- //
772
- // 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling
773
- // on the window.
774
- // 2. Set `overscroll-behavior: contain` on nested scrollable regions so they do not scroll the page when at
775
- // the top or bottom. Work around a bug where this does not work when the element does not actually overflow
776
- // by preventing default in a `touchmove` event.
777
- // 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.
778
- // 4. When focusing an input, apply a transform to trick Safari into thinking the input is at the top
779
- // of the page, which prevents it from scrolling the page. After the input is focused, scroll the element
780
- // into view ourselves, without scrolling the whole page.
781
- // 5. Offset the body by the scroll position using a negative margin and scroll to the top. This should appear the
782
- // same visually, but makes the actual scroll position always zero. This is required to make all of the
783
- // above work or Safari will still try to scroll the page when focusing an input.
784
- // 6. As a last resort, handle window scroll events, and scroll back to the top. This can happen when attempting
785
- // to navigate to an input with the next/previous buttons that's outside a modal.
786
- function $49c51c25361d4cd2$var$preventScrollMobileSafari() {
787
- let scrollable;
788
- let restoreScrollableStyles;
789
- let onTouchStart = (e)=>{
790
- // Store the nearest scrollable parent element from the element that the user touched.
791
- scrollable = (0, $k7QOs$getScrollParent)(e.target, true);
792
- if (scrollable === document.documentElement && scrollable === document.body) return;
793
- // Prevent scrolling up when at the top and scrolling down when at the bottom
794
- // of a nested scrollable area, otherwise mobile Safari will start scrolling
795
- // the window instead.
796
- if (scrollable instanceof HTMLElement && window.getComputedStyle(scrollable).overscrollBehavior === "auto") restoreScrollableStyles = $49c51c25361d4cd2$var$setStyle(scrollable, "overscrollBehavior", "contain");
797
- };
798
- let onTouchMove = (e)=>{
799
- // Prevent scrolling the window.
800
- if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
801
- e.preventDefault();
802
- return;
803
- }
804
- // overscroll-behavior should prevent scroll chaining, but currently does not
805
- // if the element doesn't actually overflow. https://bugs.webkit.org/show_bug.cgi?id=243452
806
- // This checks that both the width and height do not overflow, otherwise we might
807
- // block horizontal scrolling too. In that case, adding `touch-action: pan-x` to
808
- // the element will prevent vertical page scrolling. We can't add that automatically
809
- // because it must be set before the touchstart event.
810
- if (scrollable.scrollHeight === scrollable.clientHeight && scrollable.scrollWidth === scrollable.clientWidth) e.preventDefault();
811
- };
812
- let onTouchEnd = (e)=>{
813
- let target = e.target;
814
- // Apply this change if we're not already focused on the target element
815
- if ($49c51c25361d4cd2$var$willOpenKeyboard(target) && target !== document.activeElement) {
816
- e.preventDefault();
817
- setupStyles();
818
- // Apply a transform to trick Safari into thinking the input is at the top of the page
819
- // so it doesn't try to scroll it into view. When tapping on an input, this needs to
820
- // be done before the "focus" event, so we have to focus the element ourselves.
821
- target.style.transform = "translateY(-2000px)";
822
- target.focus();
823
- requestAnimationFrame(()=>{
824
- target.style.transform = "";
825
- });
826
- }
827
- if (restoreScrollableStyles) restoreScrollableStyles();
828
- };
829
- let onFocus = (e)=>{
830
- let target = e.target;
831
- if ($49c51c25361d4cd2$var$willOpenKeyboard(target)) {
832
- setupStyles();
833
- // Transform also needs to be applied in the focus event in cases where focus moves
834
- // other than tapping on an input directly, e.g. the next/previous buttons in the
835
- // software keyboard. In these cases, it seems applying the transform in the focus event
836
- // is good enough, whereas when tapping an input, it must be done before the focus event. 🤷‍♂️
837
- target.style.transform = "translateY(-2000px)";
838
- requestAnimationFrame(()=>{
839
- target.style.transform = "";
840
- // This will have prevented the browser from scrolling the focused element into view,
841
- // so we need to do this ourselves in a way that doesn't cause the whole page to scroll.
842
- if ($49c51c25361d4cd2$var$visualViewport) {
843
- if ($49c51c25361d4cd2$var$visualViewport.height < window.innerHeight) // If the keyboard is already visible, do this after one additional frame
844
- // to wait for the transform to be removed.
845
- requestAnimationFrame(()=>{
846
- $49c51c25361d4cd2$var$scrollIntoView(target);
847
- });
848
- else // Otherwise, wait for the visual viewport to resize before scrolling so we can
849
- // measure the correct position to scroll to.
850
- $49c51c25361d4cd2$var$visualViewport.addEventListener("resize", ()=>$49c51c25361d4cd2$var$scrollIntoView(target), {
851
- once: true
852
- });
853
- }
854
- });
855
- }
856
- };
857
- let restoreStyles = null;
858
- let setupStyles = ()=>{
859
- if (restoreStyles) return;
860
- let onWindowScroll = ()=>{
861
- // Last resort. If the window scrolled, scroll it back to the top.
862
- // It should always be at the top because the body will have a negative margin (see below).
863
- window.scrollTo(0, 0);
864
- };
865
- // Record the original scroll position so we can restore it.
866
- // Then apply a negative margin to the body to offset it by the scroll position. This will
867
- // enable us to scroll the window to the top, which is required for the rest of this to work.
868
- let scrollX = window.pageXOffset;
869
- let scrollY = window.pageYOffset;
870
- restoreStyles = (0, $k7QOs$chain)($49c51c25361d4cd2$var$addEvent(window, "scroll", onWindowScroll), $49c51c25361d4cd2$var$setStyle(document.documentElement, "paddingRight", `${window.innerWidth - document.documentElement.clientWidth}px`), $49c51c25361d4cd2$var$setStyle(document.documentElement, "overflow", "hidden"), $49c51c25361d4cd2$var$setStyle(document.body, "marginTop", `-${scrollY}px`), ()=>{
871
- window.scrollTo(scrollX, scrollY);
872
- });
873
- // Scroll to the top. The negative margin on the body will make this appear the same.
874
- window.scrollTo(0, 0);
875
- };
876
- let removeEvents = (0, $k7QOs$chain)($49c51c25361d4cd2$var$addEvent(document, "touchstart", onTouchStart, {
877
- passive: false,
878
- capture: true
879
- }), $49c51c25361d4cd2$var$addEvent(document, "touchmove", onTouchMove, {
880
- passive: false,
881
- capture: true
882
- }), $49c51c25361d4cd2$var$addEvent(document, "touchend", onTouchEnd, {
883
- passive: false,
884
- capture: true
885
- }), $49c51c25361d4cd2$var$addEvent(document, "focus", onFocus, true));
886
- return ()=>{
887
- // Restore styles and scroll the page back to where it was.
888
- restoreScrollableStyles === null || restoreScrollableStyles === void 0 ? void 0 : restoreScrollableStyles();
889
- restoreStyles === null || restoreStyles === void 0 ? void 0 : restoreStyles();
890
- removeEvents();
891
- };
892
- }
893
- // Sets a CSS property on an element, and returns a function to revert it to the previous value.
894
- function $49c51c25361d4cd2$var$setStyle(element, style, value) {
895
- let cur = element.style[style];
896
- element.style[style] = value;
897
- return ()=>{
898
- element.style[style] = cur;
899
- };
900
- }
901
- // Adds an event listener to an element, and returns a function to remove it.
902
- function $49c51c25361d4cd2$var$addEvent(target, event, handler, options) {
903
- target.addEventListener(event, handler, options);
904
- return ()=>{
905
- target.removeEventListener(event, handler, options);
906
- };
907
- }
908
- function $49c51c25361d4cd2$var$scrollIntoView(target) {
909
- let root = document.scrollingElement || document.documentElement;
910
- while(target && target !== root){
911
- // Find the parent scrollable element and adjust the scroll position if the target is not already in view.
912
- let scrollable = (0, $k7QOs$getScrollParent)(target);
913
- if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== target) {
914
- let scrollableTop = scrollable.getBoundingClientRect().top;
915
- let targetTop = target.getBoundingClientRect().top;
916
- if (targetTop > scrollableTop + target.clientHeight) scrollable.scrollTop += targetTop - scrollableTop;
917
- }
918
- target = scrollable.parentElement;
919
- }
920
- }
921
- function $49c51c25361d4cd2$var$willOpenKeyboard(target) {
922
- return target instanceof HTMLInputElement && !$49c51c25361d4cd2$var$nonTextInputTypes.has(target.type) || target instanceof HTMLTextAreaElement || target instanceof HTMLElement && target.isContentEditable;
923
- }
924
-
925
-
926
- /*
927
- * Copyright 2020 Adobe. All rights reserved.
928
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
929
- * you may not use this file except in compliance with the License. You may obtain a copy
930
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
931
- *
932
- * Unless required by applicable law or agreed to in writing, software distributed under
933
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
934
- * OF ANY KIND, either express or implied. See the License for the specific language
935
- * governing permissions and limitations under the License.
936
- */
937
-
938
-
939
- const $f57aed4a881a3485$var$Context = /*#__PURE__*/ (0, $k7QOs$react).createContext(null);
940
- function $f57aed4a881a3485$export$178405afcd8c5eb(props) {
941
- let { children: children } = props;
942
- let parent = (0, $k7QOs$useContext)($f57aed4a881a3485$var$Context);
943
- let [modalCount, setModalCount] = (0, $k7QOs$useState)(0);
944
- let context = (0, $k7QOs$useMemo)(()=>({
945
- parent: parent,
946
- modalCount: modalCount,
947
- addModal () {
948
- setModalCount((count)=>count + 1);
949
- if (parent) parent.addModal();
950
- },
951
- removeModal () {
952
- setModalCount((count)=>count - 1);
953
- if (parent) parent.removeModal();
954
- }
955
- }), [
956
- parent,
957
- modalCount
958
- ]);
959
- return /*#__PURE__*/ (0, $k7QOs$react).createElement($f57aed4a881a3485$var$Context.Provider, {
960
- value: context
961
- }, children);
962
- }
963
- function $f57aed4a881a3485$export$d9aaed4c3ece1bc0() {
964
- let context = (0, $k7QOs$useContext)($f57aed4a881a3485$var$Context);
965
- return {
966
- modalProviderProps: {
967
- "aria-hidden": context && context.modalCount > 0 ? true : null
968
- }
969
- };
970
- }
971
- /**
972
- * Creates a root node that will be aria-hidden if there are other modals open.
973
- */ function $f57aed4a881a3485$var$OverlayContainerDOM(props) {
974
- let { modalProviderProps: modalProviderProps } = $f57aed4a881a3485$export$d9aaed4c3ece1bc0();
975
- return /*#__PURE__*/ (0, $k7QOs$react).createElement("div", {
976
- "data-overlay-container": true,
977
- ...props,
978
- ...modalProviderProps
979
- });
980
- }
981
- function $f57aed4a881a3485$export$bf688221f59024e5(props) {
982
- return /*#__PURE__*/ (0, $k7QOs$react).createElement($f57aed4a881a3485$export$178405afcd8c5eb, null, /*#__PURE__*/ (0, $k7QOs$react).createElement($f57aed4a881a3485$var$OverlayContainerDOM, props));
983
- }
984
- function $f57aed4a881a3485$export$b47c3594eab58386(props) {
985
- let isSSR = (0, $k7QOs$useIsSSR)();
986
- let { portalContainer: portalContainer = isSSR ? null : document.body, ...rest } = props;
987
- (0, $k7QOs$react).useEffect(()=>{
988
- if (portalContainer === null || portalContainer === void 0 ? void 0 : portalContainer.closest("[data-overlay-container]")) throw new Error("An OverlayContainer must not be inside another container. Please change the portalContainer prop.");
989
- }, [
990
- portalContainer
991
- ]);
992
- if (!portalContainer) return null;
993
- let contents = /*#__PURE__*/ (0, $k7QOs$react).createElement($f57aed4a881a3485$export$bf688221f59024e5, rest);
994
- return /*#__PURE__*/ (0, $k7QOs$reactdom).createPortal(contents, portalContainer);
995
- }
996
- function $f57aed4a881a3485$export$33ffd74ebf07f060(options) {
997
- // Add aria-hidden to all parent providers on mount, and restore on unmount.
998
- let context = (0, $k7QOs$useContext)($f57aed4a881a3485$var$Context);
999
- if (!context) throw new Error("Modal is not contained within a provider");
1000
- (0, $k7QOs$useEffect)(()=>{
1001
- if ((options === null || options === void 0 ? void 0 : options.isDisabled) || !context || !context.parent) return;
1002
- // The immediate context is from the provider containing this modal, so we only
1003
- // want to trigger aria-hidden on its parents not on the modal provider itself.
1004
- context.parent.addModal();
1005
- return ()=>{
1006
- if (context && context.parent) context.parent.removeModal();
1007
- };
1008
- }, [
1009
- context,
1010
- context.parent,
1011
- options === null || options === void 0 ? void 0 : options.isDisabled
1012
- ]);
1013
- return {
1014
- modalProps: {
1015
- "data-ismodal": !(options === null || options === void 0 ? void 0 : options.isDisabled)
1016
- }
1017
- };
1018
- }
1019
-
1020
-
1021
- /*
1022
- * Copyright 2020 Adobe. All rights reserved.
1023
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1024
- * you may not use this file except in compliance with the License. You may obtain a copy
1025
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1026
- *
1027
- * Unless required by applicable law or agreed to in writing, software distributed under
1028
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1029
- * OF ANY KIND, either express or implied. See the License for the specific language
1030
- * governing permissions and limitations under the License.
1031
- */ var $a2f21f5f14f60553$exports = {};
1032
- var $773d5888b972f1cf$exports = {};
1033
- $773d5888b972f1cf$exports = {
1034
- "dismiss": `\u{62A}\u{62C}\u{627}\u{647}\u{644}`
1035
- };
1036
-
1037
-
1038
- var $d11f19852b941573$exports = {};
1039
- $d11f19852b941573$exports = {
1040
- "dismiss": `\u{41E}\u{442}\u{445}\u{432}\u{44A}\u{440}\u{43B}\u{44F}\u{43D}\u{435}`
1041
- };
1042
-
1043
-
1044
- var $b983974c2ee1efb3$exports = {};
1045
- $b983974c2ee1efb3$exports = {
1046
- "dismiss": `Odstranit`
1047
- };
1048
-
1049
-
1050
- var $5809cc9d4e92de73$exports = {};
1051
- $5809cc9d4e92de73$exports = {
1052
- "dismiss": `Luk`
1053
- };
1054
-
1055
-
1056
- var $c68c2e4fc74398d1$exports = {};
1057
- $c68c2e4fc74398d1$exports = {
1058
- "dismiss": `Schlie\xdfen`
1059
- };
1060
-
1061
-
1062
- var $0898b4c153db2b77$exports = {};
1063
- $0898b4c153db2b77$exports = {
1064
- "dismiss": `\u{391}\u{3C0}\u{3CC}\u{3C1}\u{3C1}\u{3B9}\u{3C8}\u{3B7}`
1065
- };
1066
-
1067
-
1068
- var $6d74810286a15183$exports = {};
1069
- $6d74810286a15183$exports = {
1070
- "dismiss": `Dismiss`
1071
- };
1072
-
1073
-
1074
- var $309d73dc65f78055$exports = {};
1075
- $309d73dc65f78055$exports = {
1076
- "dismiss": `Descartar`
1077
- };
1078
-
1079
-
1080
- var $44ad94f7205cf593$exports = {};
1081
- $44ad94f7205cf593$exports = {
1082
- "dismiss": `L\xf5peta`
1083
- };
1084
-
1085
-
1086
- var $7c28f5687f0779a9$exports = {};
1087
- $7c28f5687f0779a9$exports = {
1088
- "dismiss": `Hylk\xe4\xe4`
1089
- };
1090
-
1091
-
1092
- var $e6d75df4b68bd73a$exports = {};
1093
- $e6d75df4b68bd73a$exports = {
1094
- "dismiss": `Rejeter`
1095
- };
1096
-
1097
-
1098
- var $87505c9dab186d0f$exports = {};
1099
- $87505c9dab186d0f$exports = {
1100
- "dismiss": `\u{5D4}\u{5EA}\u{5E2}\u{5DC}\u{5DD}`
1101
- };
1102
-
1103
-
1104
- var $553439c3ffb3e492$exports = {};
1105
- $553439c3ffb3e492$exports = {
1106
- "dismiss": `Odbaci`
1107
- };
1108
-
1109
-
1110
- var $74cf411061b983a2$exports = {};
1111
- $74cf411061b983a2$exports = {
1112
- "dismiss": `Elutas\xedt\xe1s`
1113
- };
1114
-
1115
-
1116
- var $e933f298574dc435$exports = {};
1117
- $e933f298574dc435$exports = {
1118
- "dismiss": `Ignora`
1119
- };
1120
-
1121
-
1122
- var $ac91fc9fe02f71f6$exports = {};
1123
- $ac91fc9fe02f71f6$exports = {
1124
- "dismiss": `\u{9589}\u{3058}\u{308B}`
1125
- };
1126
-
1127
-
1128
- var $52b96f86422025af$exports = {};
1129
- $52b96f86422025af$exports = {
1130
- "dismiss": `\u{BB34}\u{C2DC}`
1131
- };
1132
-
1133
-
1134
- var $c0d724c3e51dafa6$exports = {};
1135
- $c0d724c3e51dafa6$exports = {
1136
- "dismiss": `Atmesti`
1137
- };
1138
-
1139
-
1140
- var $c92899672a3fe72e$exports = {};
1141
- $c92899672a3fe72e$exports = {
1142
- "dismiss": `Ner\u{101}d\u{12B}t`
1143
- };
1144
-
1145
-
1146
- var $9f576b39d8e7a9d6$exports = {};
1147
- $9f576b39d8e7a9d6$exports = {
1148
- "dismiss": `Lukk`
1149
- };
1150
-
1151
-
1152
- var $9d025808aeec81a7$exports = {};
1153
- $9d025808aeec81a7$exports = {
1154
- "dismiss": `Negeren`
1155
- };
1156
-
1157
-
1158
- var $fce709921e2c0fa6$exports = {};
1159
- $fce709921e2c0fa6$exports = {
1160
- "dismiss": `Zignoruj`
1161
- };
1162
-
1163
-
1164
- var $2599cf0c4ab37f59$exports = {};
1165
- $2599cf0c4ab37f59$exports = {
1166
- "dismiss": `Descartar`
1167
- };
1168
-
1169
-
1170
- var $3c220ae7ef8a35fd$exports = {};
1171
- $3c220ae7ef8a35fd$exports = {
1172
- "dismiss": `Dispensar`
1173
- };
1174
-
1175
-
1176
- var $93562b5094072f54$exports = {};
1177
- $93562b5094072f54$exports = {
1178
- "dismiss": `Revocare`
1179
- };
1180
-
1181
-
1182
- var $cd9e2abd0d06c7b4$exports = {};
1183
- $cd9e2abd0d06c7b4$exports = {
1184
- "dismiss": `\u{41F}\u{440}\u{43E}\u{43F}\u{443}\u{441}\u{442}\u{438}\u{442}\u{44C}`
1185
- };
1186
-
1187
-
1188
- var $45375701f409adf1$exports = {};
1189
- $45375701f409adf1$exports = {
1190
- "dismiss": `Zru\u{161}i\u{165}`
1191
- };
1192
-
1193
-
1194
- var $27fab53a576de9dd$exports = {};
1195
- $27fab53a576de9dd$exports = {
1196
- "dismiss": `Opusti`
1197
- };
1198
-
1199
-
1200
- var $4438748d9952e7c7$exports = {};
1201
- $4438748d9952e7c7$exports = {
1202
- "dismiss": `Odbaci`
1203
- };
1204
-
1205
-
1206
- var $0936d7347ef4da4c$exports = {};
1207
- $0936d7347ef4da4c$exports = {
1208
- "dismiss": `Avvisa`
1209
- };
1210
-
1211
-
1212
- var $29700c92185d38f8$exports = {};
1213
- $29700c92185d38f8$exports = {
1214
- "dismiss": `Kapat`
1215
- };
1216
-
1217
-
1218
- var $662ccaf2be4c25b3$exports = {};
1219
- $662ccaf2be4c25b3$exports = {
1220
- "dismiss": `\u{421}\u{43A}\u{430}\u{441}\u{443}\u{432}\u{430}\u{442}\u{438}`
1221
- };
1222
-
1223
-
1224
- var $d80a27deda7cdb3c$exports = {};
1225
- $d80a27deda7cdb3c$exports = {
1226
- "dismiss": `\u{53D6}\u{6D88}`
1227
- };
1228
-
1229
-
1230
- var $2b2734393847c884$exports = {};
1231
- $2b2734393847c884$exports = {
1232
- "dismiss": `\u{95DC}\u{9589}`
1233
- };
1234
-
1235
-
1236
- $a2f21f5f14f60553$exports = {
1237
- "ar-AE": $773d5888b972f1cf$exports,
1238
- "bg-BG": $d11f19852b941573$exports,
1239
- "cs-CZ": $b983974c2ee1efb3$exports,
1240
- "da-DK": $5809cc9d4e92de73$exports,
1241
- "de-DE": $c68c2e4fc74398d1$exports,
1242
- "el-GR": $0898b4c153db2b77$exports,
1243
- "en-US": $6d74810286a15183$exports,
1244
- "es-ES": $309d73dc65f78055$exports,
1245
- "et-EE": $44ad94f7205cf593$exports,
1246
- "fi-FI": $7c28f5687f0779a9$exports,
1247
- "fr-FR": $e6d75df4b68bd73a$exports,
1248
- "he-IL": $87505c9dab186d0f$exports,
1249
- "hr-HR": $553439c3ffb3e492$exports,
1250
- "hu-HU": $74cf411061b983a2$exports,
1251
- "it-IT": $e933f298574dc435$exports,
1252
- "ja-JP": $ac91fc9fe02f71f6$exports,
1253
- "ko-KR": $52b96f86422025af$exports,
1254
- "lt-LT": $c0d724c3e51dafa6$exports,
1255
- "lv-LV": $c92899672a3fe72e$exports,
1256
- "nb-NO": $9f576b39d8e7a9d6$exports,
1257
- "nl-NL": $9d025808aeec81a7$exports,
1258
- "pl-PL": $fce709921e2c0fa6$exports,
1259
- "pt-BR": $2599cf0c4ab37f59$exports,
1260
- "pt-PT": $3c220ae7ef8a35fd$exports,
1261
- "ro-RO": $93562b5094072f54$exports,
1262
- "ru-RU": $cd9e2abd0d06c7b4$exports,
1263
- "sk-SK": $45375701f409adf1$exports,
1264
- "sl-SI": $27fab53a576de9dd$exports,
1265
- "sr-SP": $4438748d9952e7c7$exports,
1266
- "sv-SE": $0936d7347ef4da4c$exports,
1267
- "tr-TR": $29700c92185d38f8$exports,
1268
- "uk-UA": $662ccaf2be4c25b3$exports,
1269
- "zh-CN": $d80a27deda7cdb3c$exports,
1270
- "zh-TW": $2b2734393847c884$exports
1271
- };
1272
-
1273
-
1274
-
1275
-
1276
-
1277
-
1278
- function $86ea4cb521eb2e37$export$2317d149ed6f78c4(props) {
1279
- let { onDismiss: onDismiss, ...otherProps } = props;
1280
- let stringFormatter = (0, $k7QOs$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($a2f21f5f14f60553$exports))), "@react-aria/overlays");
1281
- let labels = (0, $k7QOs$useLabels)(otherProps, stringFormatter.format("dismiss"));
1282
- let onClick = ()=>{
1283
- if (onDismiss) onDismiss();
1284
- };
1285
- return /*#__PURE__*/ (0, $k7QOs$react).createElement((0, $k7QOs$VisuallyHidden), null, /*#__PURE__*/ (0, $k7QOs$react).createElement("button", {
1286
- ...labels,
1287
- tabIndex: -1,
1288
- onClick: onClick,
1289
- style: {
1290
- width: 1,
1291
- height: 1
1292
- }
1293
- }));
1294
- }
1295
-
1296
-
1297
- /*
1298
- * Copyright 2020 Adobe. All rights reserved.
1299
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1300
- * you may not use this file except in compliance with the License. You may obtain a copy
1301
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1302
- *
1303
- * Unless required by applicable law or agreed to in writing, software distributed under
1304
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1305
- * OF ANY KIND, either express or implied. See the License for the specific language
1306
- * governing permissions and limitations under the License.
1307
- */ // Keeps a ref count of all hidden elements. Added to when hiding an element, and
1308
- // subtracted from when showing it again. When it reaches zero, aria-hidden is removed.
1309
- let $5e3802645cc19319$var$refCountMap = new WeakMap();
1310
- let $5e3802645cc19319$var$observerStack = [];
1311
- function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body) {
1312
- let visibleNodes = new Set(targets);
1313
- let hiddenNodes = new Set();
1314
- let walk = (root)=>{
1315
- // Keep live announcer and top layer elements (e.g. toasts) visible.
1316
- for (let element of root.querySelectorAll("[data-live-announcer], [data-react-aria-top-layer]"))visibleNodes.add(element);
1317
- let acceptNode = (node)=>{
1318
- // Skip this node and its children if it is one of the target nodes, or a live announcer.
1319
- // Also skip children of already hidden nodes, as aria-hidden is recursive. An exception is
1320
- // made for elements with role="row" since VoiceOver on iOS has issues hiding elements with role="row".
1321
- // For that case we want to hide the cells inside as well (https://bugs.webkit.org/show_bug.cgi?id=222623).
1322
- if (visibleNodes.has(node) || hiddenNodes.has(node.parentElement) && node.parentElement.getAttribute("role") !== "row") return NodeFilter.FILTER_REJECT;
1323
- // Skip this node but continue to children if one of the targets is inside the node.
1324
- for (let target of visibleNodes){
1325
- if (node.contains(target)) return NodeFilter.FILTER_SKIP;
1326
- }
1327
- return NodeFilter.FILTER_ACCEPT;
1328
- };
1329
- let walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
1330
- acceptNode: acceptNode
1331
- });
1332
- // TreeWalker does not include the root.
1333
- let acceptRoot = acceptNode(root);
1334
- if (acceptRoot === NodeFilter.FILTER_ACCEPT) hide(root);
1335
- if (acceptRoot !== NodeFilter.FILTER_REJECT) {
1336
- let node = walker.nextNode();
1337
- while(node != null){
1338
- hide(node);
1339
- node = walker.nextNode();
1340
- }
1341
- }
1342
- };
1343
- let hide = (node)=>{
1344
- var _refCountMap_get;
1345
- let refCount = (_refCountMap_get = $5e3802645cc19319$var$refCountMap.get(node)) !== null && _refCountMap_get !== void 0 ? _refCountMap_get : 0;
1346
- // If already aria-hidden, and the ref count is zero, then this element
1347
- // was already hidden and there's nothing for us to do.
1348
- if (node.getAttribute("aria-hidden") === "true" && refCount === 0) return;
1349
- if (refCount === 0) node.setAttribute("aria-hidden", "true");
1350
- hiddenNodes.add(node);
1351
- $5e3802645cc19319$var$refCountMap.set(node, refCount + 1);
1352
- };
1353
- // If there is already a MutationObserver listening from a previous call,
1354
- // disconnect it so the new on takes over.
1355
- if ($5e3802645cc19319$var$observerStack.length) $5e3802645cc19319$var$observerStack[$5e3802645cc19319$var$observerStack.length - 1].disconnect();
1356
- walk(root);
1357
- let observer = new MutationObserver((changes)=>{
1358
- for (let change of changes){
1359
- if (change.type !== "childList" || change.addedNodes.length === 0) continue;
1360
- // If the parent element of the added nodes is not within one of the targets,
1361
- // and not already inside a hidden node, hide all of the new children.
1362
- if (![
1363
- ...visibleNodes,
1364
- ...hiddenNodes
1365
- ].some((node)=>node.contains(change.target))) {
1366
- for (let node of change.removedNodes)if (node instanceof Element) {
1367
- visibleNodes.delete(node);
1368
- hiddenNodes.delete(node);
1369
- }
1370
- for (let node of change.addedNodes){
1371
- if ((node instanceof HTMLElement || node instanceof SVGElement) && (node.dataset.liveAnnouncer === "true" || node.dataset.reactAriaTopLayer === "true")) visibleNodes.add(node);
1372
- else if (node instanceof Element) walk(node);
1373
- }
1374
- }
1375
- }
1376
- });
1377
- observer.observe(root, {
1378
- childList: true,
1379
- subtree: true
1380
- });
1381
- let observerWrapper = {
1382
- observe () {
1383
- observer.observe(root, {
1384
- childList: true,
1385
- subtree: true
1386
- });
1387
- },
1388
- disconnect () {
1389
- observer.disconnect();
1390
- }
1391
- };
1392
- $5e3802645cc19319$var$observerStack.push(observerWrapper);
1393
- return ()=>{
1394
- observer.disconnect();
1395
- for (let node of hiddenNodes){
1396
- let count = $5e3802645cc19319$var$refCountMap.get(node);
1397
- if (count === 1) {
1398
- node.removeAttribute("aria-hidden");
1399
- $5e3802645cc19319$var$refCountMap.delete(node);
1400
- } else $5e3802645cc19319$var$refCountMap.set(node, count - 1);
1401
- }
1402
- // Remove this observer from the stack, and start the previous one.
1403
- if (observerWrapper === $5e3802645cc19319$var$observerStack[$5e3802645cc19319$var$observerStack.length - 1]) {
1404
- $5e3802645cc19319$var$observerStack.pop();
1405
- if ($5e3802645cc19319$var$observerStack.length) $5e3802645cc19319$var$observerStack[$5e3802645cc19319$var$observerStack.length - 1].observe();
1406
- } else $5e3802645cc19319$var$observerStack.splice($5e3802645cc19319$var$observerStack.indexOf(observerWrapper), 1);
1407
- };
1408
- }
1409
-
1410
-
1411
- /*
1412
- * Copyright 2022 Adobe. All rights reserved.
1413
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1414
- * you may not use this file except in compliance with the License. You may obtain a copy
1415
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1416
- *
1417
- * Unless required by applicable law or agreed to in writing, software distributed under
1418
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1419
- * OF ANY KIND, either express or implied. See the License for the specific language
1420
- * governing permissions and limitations under the License.
1421
- */
1422
-
1423
-
1424
-
1425
-
1426
- function $f2f8a6077418541e$export$542a6fd13ac93354(props, state) {
1427
- let { triggerRef: triggerRef, popoverRef: popoverRef, isNonModal: isNonModal, isKeyboardDismissDisabled: isKeyboardDismissDisabled, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside, ...otherProps } = props;
1428
- let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $a11501f3d1d39e6c$export$ea8f71083e90600f)({
1429
- isOpen: state.isOpen,
1430
- onClose: state.close,
1431
- shouldCloseOnBlur: true,
1432
- isDismissable: !isNonModal,
1433
- isKeyboardDismissDisabled: isKeyboardDismissDisabled,
1434
- shouldCloseOnInteractOutside: shouldCloseOnInteractOutside
1435
- }, popoverRef);
1436
- let { overlayProps: positionProps, arrowProps: arrowProps, placement: placement } = (0, $2a41e45df1593e64$export$d39e1813b3bdd0e1)({
1437
- ...otherProps,
1438
- targetRef: triggerRef,
1439
- overlayRef: popoverRef,
1440
- isOpen: state.isOpen,
1441
- onClose: isNonModal ? state.close : null
1442
- });
1443
- (0, $49c51c25361d4cd2$export$ee0f7cc6afcd1c18)({
1444
- isDisabled: isNonModal || !state.isOpen
1445
- });
1446
- (0, $k7QOs$useLayoutEffect)(()=>{
1447
- if (state.isOpen && !isNonModal && popoverRef.current) return (0, $5e3802645cc19319$export$1c3ebcada18427bf)([
1448
- popoverRef.current
1449
- ]);
1450
- }, [
1451
- isNonModal,
1452
- state.isOpen,
1453
- popoverRef
1454
- ]);
1455
- return {
1456
- popoverProps: (0, $k7QOs$mergeProps)(overlayProps, positionProps),
1457
- arrowProps: arrowProps,
1458
- underlayProps: underlayProps,
1459
- placement: placement
1460
- };
1461
- }
1462
-
1463
-
1464
- /*
1465
- * Copyright 2022 Adobe. All rights reserved.
1466
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1467
- * you may not use this file except in compliance with the License. You may obtain a copy
1468
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1469
- *
1470
- * Unless required by applicable law or agreed to in writing, software distributed under
1471
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1472
- * OF ANY KIND, either express or implied. See the License for the specific language
1473
- * governing permissions and limitations under the License.
1474
- */
1475
-
1476
-
1477
-
1478
- /*
1479
- * Copyright 2022 Adobe. All rights reserved.
1480
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1481
- * you may not use this file except in compliance with the License. You may obtain a copy
1482
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1483
- *
1484
- * Unless required by applicable law or agreed to in writing, software distributed under
1485
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1486
- * OF ANY KIND, either express or implied. See the License for the specific language
1487
- * governing permissions and limitations under the License.
1488
- */
1489
-
1490
24
 
1491
25
 
1492
26
 
1493
27
 
1494
- const $337b884510726a0d$export$a2200b96afd16271 = /*#__PURE__*/ (0, $k7QOs$react).createContext(null);
1495
- function $337b884510726a0d$export$c6fdb837b070b4ff(props) {
1496
- let isSSR = (0, $k7QOs$useIsSSR)();
1497
- let { portalContainer: portalContainer = isSSR ? null : document.body, isExiting: isExiting } = props;
1498
- let [contain, setContain] = (0, $k7QOs$useState)(false);
1499
- let contextValue = (0, $k7QOs$useMemo)(()=>({
1500
- contain: contain,
1501
- setContain: setContain
1502
- }), [
1503
- contain,
1504
- setContain
1505
- ]);
1506
- if (!portalContainer) return null;
1507
- let contents = props.children;
1508
- if (!props.disableFocusManagement) contents = /*#__PURE__*/ (0, $k7QOs$react).createElement((0, $k7QOs$FocusScope), {
1509
- restoreFocus: true,
1510
- contain: contain && !isExiting
1511
- }, contents);
1512
- contents = /*#__PURE__*/ (0, $k7QOs$react).createElement($337b884510726a0d$export$a2200b96afd16271.Provider, {
1513
- value: contextValue
1514
- }, /*#__PURE__*/ (0, $k7QOs$react).createElement((0, $k7QOs$ClearPressResponder), null, contents));
1515
- return /*#__PURE__*/ (0, $k7QOs$reactdom).createPortal(contents, portalContainer);
1516
- }
1517
- function $337b884510726a0d$export$14c98a7594375490() {
1518
- let ctx = (0, $k7QOs$useContext)($337b884510726a0d$export$a2200b96afd16271);
1519
- let setContain = ctx === null || ctx === void 0 ? void 0 : ctx.setContain;
1520
- (0, $k7QOs$useLayoutEffect)(()=>{
1521
- setContain === null || setContain === void 0 ? void 0 : setContain(true);
1522
- }, [
1523
- setContain
1524
- ]);
1525
- }
1526
28
 
1527
29
 
1528
30
 
1529
- function $8ac8429251c45e4b$export$dbc0f175b25fb0fb(props, state, ref) {
1530
- let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $a11501f3d1d39e6c$export$ea8f71083e90600f)({
1531
- ...props,
1532
- isOpen: state.isOpen,
1533
- onClose: state.close
1534
- }, ref);
1535
- (0, $49c51c25361d4cd2$export$ee0f7cc6afcd1c18)({
1536
- isDisabled: !state.isOpen
1537
- });
1538
- (0, $337b884510726a0d$export$14c98a7594375490)();
1539
- (0, $k7QOs$useEffect)(()=>{
1540
- if (state.isOpen) return (0, $5e3802645cc19319$export$1c3ebcada18427bf)([
1541
- ref.current
1542
- ]);
1543
- }, [
1544
- state.isOpen,
1545
- ref
1546
- ]);
1547
- return {
1548
- modalProps: (0, $k7QOs$mergeProps)(overlayProps),
1549
- underlayProps: underlayProps
1550
- };
1551
- }
1552
31
 
1553
32
 
1554
33
 
1555
34
 
1556
35
 
1557
- export {$2a41e45df1593e64$export$d39e1813b3bdd0e1 as useOverlayPosition, $a11501f3d1d39e6c$export$ea8f71083e90600f as useOverlay, $628037886ba31236$export$f9d5c8beee7d008d as useOverlayTrigger, $49c51c25361d4cd2$export$ee0f7cc6afcd1c18 as usePreventScroll, $f57aed4a881a3485$export$178405afcd8c5eb as ModalProvider, $f57aed4a881a3485$export$d9aaed4c3ece1bc0 as useModalProvider, $f57aed4a881a3485$export$bf688221f59024e5 as OverlayProvider, $f57aed4a881a3485$export$b47c3594eab58386 as OverlayContainer, $f57aed4a881a3485$export$33ffd74ebf07f060 as useModal, $86ea4cb521eb2e37$export$2317d149ed6f78c4 as DismissButton, $5e3802645cc19319$export$1c3ebcada18427bf as ariaHideOutside, $f2f8a6077418541e$export$542a6fd13ac93354 as usePopover, $8ac8429251c45e4b$export$dbc0f175b25fb0fb as useModalOverlay, $337b884510726a0d$export$c6fdb837b070b4ff as Overlay, $337b884510726a0d$export$14c98a7594375490 as useOverlayFocusContain};
36
+ export {$2a41e45df1593e64$export$d39e1813b3bdd0e1 as useOverlayPosition, $a11501f3d1d39e6c$export$ea8f71083e90600f as useOverlay, $628037886ba31236$export$f9d5c8beee7d008d as useOverlayTrigger, $49c51c25361d4cd2$export$ee0f7cc6afcd1c18 as usePreventScroll, $f57aed4a881a3485$export$178405afcd8c5eb as ModalProvider, $f57aed4a881a3485$export$d9aaed4c3ece1bc0 as useModalProvider, $f57aed4a881a3485$export$bf688221f59024e5 as OverlayProvider, $f57aed4a881a3485$export$b47c3594eab58386 as OverlayContainer, $f57aed4a881a3485$export$33ffd74ebf07f060 as useModal, $86ea4cb521eb2e37$export$2317d149ed6f78c4 as DismissButton, $5e3802645cc19319$export$1c3ebcada18427bf as ariaHideOutside, $f2f8a6077418541e$export$542a6fd13ac93354 as usePopover, $8ac8429251c45e4b$export$dbc0f175b25fb0fb as useModalOverlay, $337b884510726a0d$export$c6fdb837b070b4ff as Overlay, $337b884510726a0d$export$14c98a7594375490 as useOverlayFocusContain, $96b38030c423d352$export$db995ea7163b4b67 as UNSTABLE_PortalProvider, $96b38030c423d352$export$574e9b0fb070c3b0 as useUNSTABLE_PortalContext};
1558
37
  //# sourceMappingURL=module.js.map