@depup/react-aria__overlays 3.31.2-depup.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 (265) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +31 -0
  3. package/changes.json +10 -0
  4. package/dist/DismissButton.main.js +51 -0
  5. package/dist/DismissButton.main.js.map +1 -0
  6. package/dist/DismissButton.mjs +46 -0
  7. package/dist/DismissButton.module.js +46 -0
  8. package/dist/DismissButton.module.js.map +1 -0
  9. package/dist/Overlay.main.js +73 -0
  10. package/dist/Overlay.main.js.map +1 -0
  11. package/dist/Overlay.mjs +63 -0
  12. package/dist/Overlay.module.js +63 -0
  13. package/dist/Overlay.module.js.map +1 -0
  14. package/dist/PortalProvider.main.js +41 -0
  15. package/dist/PortalProvider.main.js.map +1 -0
  16. package/dist/PortalProvider.mjs +31 -0
  17. package/dist/PortalProvider.module.js +31 -0
  18. package/dist/PortalProvider.module.js.map +1 -0
  19. package/dist/ar-AE.main.js +6 -0
  20. package/dist/ar-AE.main.js.map +1 -0
  21. package/dist/ar-AE.mjs +8 -0
  22. package/dist/ar-AE.module.js +8 -0
  23. package/dist/ar-AE.module.js.map +1 -0
  24. package/dist/ariaHideOutside.main.js +203 -0
  25. package/dist/ariaHideOutside.main.js.map +1 -0
  26. package/dist/ariaHideOutside.mjs +197 -0
  27. package/dist/ariaHideOutside.module.js +197 -0
  28. package/dist/ariaHideOutside.module.js.map +1 -0
  29. package/dist/bg-BG.main.js +6 -0
  30. package/dist/bg-BG.main.js.map +1 -0
  31. package/dist/bg-BG.mjs +8 -0
  32. package/dist/bg-BG.module.js +8 -0
  33. package/dist/bg-BG.module.js.map +1 -0
  34. package/dist/calculatePosition.main.js +438 -0
  35. package/dist/calculatePosition.main.js.map +1 -0
  36. package/dist/calculatePosition.mjs +432 -0
  37. package/dist/calculatePosition.module.js +432 -0
  38. package/dist/calculatePosition.module.js.map +1 -0
  39. package/dist/cs-CZ.main.js +6 -0
  40. package/dist/cs-CZ.main.js.map +1 -0
  41. package/dist/cs-CZ.mjs +8 -0
  42. package/dist/cs-CZ.module.js +8 -0
  43. package/dist/cs-CZ.module.js.map +1 -0
  44. package/dist/da-DK.main.js +6 -0
  45. package/dist/da-DK.main.js.map +1 -0
  46. package/dist/da-DK.mjs +8 -0
  47. package/dist/da-DK.module.js +8 -0
  48. package/dist/da-DK.module.js.map +1 -0
  49. package/dist/de-DE.main.js +6 -0
  50. package/dist/de-DE.main.js.map +1 -0
  51. package/dist/de-DE.mjs +8 -0
  52. package/dist/de-DE.module.js +8 -0
  53. package/dist/de-DE.module.js.map +1 -0
  54. package/dist/el-GR.main.js +6 -0
  55. package/dist/el-GR.main.js.map +1 -0
  56. package/dist/el-GR.mjs +8 -0
  57. package/dist/el-GR.module.js +8 -0
  58. package/dist/el-GR.module.js.map +1 -0
  59. package/dist/en-US.main.js +6 -0
  60. package/dist/en-US.main.js.map +1 -0
  61. package/dist/en-US.mjs +8 -0
  62. package/dist/en-US.module.js +8 -0
  63. package/dist/en-US.module.js.map +1 -0
  64. package/dist/es-ES.main.js +6 -0
  65. package/dist/es-ES.main.js.map +1 -0
  66. package/dist/es-ES.mjs +8 -0
  67. package/dist/es-ES.module.js +8 -0
  68. package/dist/es-ES.module.js.map +1 -0
  69. package/dist/et-EE.main.js +6 -0
  70. package/dist/et-EE.main.js.map +1 -0
  71. package/dist/et-EE.mjs +8 -0
  72. package/dist/et-EE.module.js +8 -0
  73. package/dist/et-EE.module.js.map +1 -0
  74. package/dist/fi-FI.main.js +6 -0
  75. package/dist/fi-FI.main.js.map +1 -0
  76. package/dist/fi-FI.mjs +8 -0
  77. package/dist/fi-FI.module.js +8 -0
  78. package/dist/fi-FI.module.js.map +1 -0
  79. package/dist/fr-FR.main.js +6 -0
  80. package/dist/fr-FR.main.js.map +1 -0
  81. package/dist/fr-FR.mjs +8 -0
  82. package/dist/fr-FR.module.js +8 -0
  83. package/dist/fr-FR.module.js.map +1 -0
  84. package/dist/he-IL.main.js +6 -0
  85. package/dist/he-IL.main.js.map +1 -0
  86. package/dist/he-IL.mjs +8 -0
  87. package/dist/he-IL.module.js +8 -0
  88. package/dist/he-IL.module.js.map +1 -0
  89. package/dist/hr-HR.main.js +6 -0
  90. package/dist/hr-HR.main.js.map +1 -0
  91. package/dist/hr-HR.mjs +8 -0
  92. package/dist/hr-HR.module.js +8 -0
  93. package/dist/hr-HR.module.js.map +1 -0
  94. package/dist/hu-HU.main.js +6 -0
  95. package/dist/hu-HU.main.js.map +1 -0
  96. package/dist/hu-HU.mjs +8 -0
  97. package/dist/hu-HU.module.js +8 -0
  98. package/dist/hu-HU.module.js.map +1 -0
  99. package/dist/import.mjs +37 -0
  100. package/dist/intlStrings.main.js +108 -0
  101. package/dist/intlStrings.main.js.map +1 -0
  102. package/dist/intlStrings.mjs +110 -0
  103. package/dist/intlStrings.module.js +110 -0
  104. package/dist/intlStrings.module.js.map +1 -0
  105. package/dist/it-IT.main.js +6 -0
  106. package/dist/it-IT.main.js.map +1 -0
  107. package/dist/it-IT.mjs +8 -0
  108. package/dist/it-IT.module.js +8 -0
  109. package/dist/it-IT.module.js.map +1 -0
  110. package/dist/ja-JP.main.js +6 -0
  111. package/dist/ja-JP.main.js.map +1 -0
  112. package/dist/ja-JP.mjs +8 -0
  113. package/dist/ja-JP.module.js +8 -0
  114. package/dist/ja-JP.module.js.map +1 -0
  115. package/dist/ko-KR.main.js +6 -0
  116. package/dist/ko-KR.main.js.map +1 -0
  117. package/dist/ko-KR.mjs +8 -0
  118. package/dist/ko-KR.module.js +8 -0
  119. package/dist/ko-KR.module.js.map +1 -0
  120. package/dist/lt-LT.main.js +6 -0
  121. package/dist/lt-LT.main.js.map +1 -0
  122. package/dist/lt-LT.mjs +8 -0
  123. package/dist/lt-LT.module.js +8 -0
  124. package/dist/lt-LT.module.js.map +1 -0
  125. package/dist/lv-LV.main.js +6 -0
  126. package/dist/lv-LV.main.js.map +1 -0
  127. package/dist/lv-LV.mjs +8 -0
  128. package/dist/lv-LV.module.js +8 -0
  129. package/dist/lv-LV.module.js.map +1 -0
  130. package/dist/main.js +58 -0
  131. package/dist/main.js.map +1 -0
  132. package/dist/module.js +37 -0
  133. package/dist/module.js.map +1 -0
  134. package/dist/nb-NO.main.js +6 -0
  135. package/dist/nb-NO.main.js.map +1 -0
  136. package/dist/nb-NO.mjs +8 -0
  137. package/dist/nb-NO.module.js +8 -0
  138. package/dist/nb-NO.module.js.map +1 -0
  139. package/dist/nl-NL.main.js +6 -0
  140. package/dist/nl-NL.main.js.map +1 -0
  141. package/dist/nl-NL.mjs +8 -0
  142. package/dist/nl-NL.module.js +8 -0
  143. package/dist/nl-NL.module.js.map +1 -0
  144. package/dist/pl-PL.main.js +6 -0
  145. package/dist/pl-PL.main.js.map +1 -0
  146. package/dist/pl-PL.mjs +8 -0
  147. package/dist/pl-PL.module.js +8 -0
  148. package/dist/pl-PL.module.js.map +1 -0
  149. package/dist/pt-BR.main.js +6 -0
  150. package/dist/pt-BR.main.js.map +1 -0
  151. package/dist/pt-BR.mjs +8 -0
  152. package/dist/pt-BR.module.js +8 -0
  153. package/dist/pt-BR.module.js.map +1 -0
  154. package/dist/pt-PT.main.js +6 -0
  155. package/dist/pt-PT.main.js.map +1 -0
  156. package/dist/pt-PT.mjs +8 -0
  157. package/dist/pt-PT.module.js +8 -0
  158. package/dist/pt-PT.module.js.map +1 -0
  159. package/dist/ro-RO.main.js +6 -0
  160. package/dist/ro-RO.main.js.map +1 -0
  161. package/dist/ro-RO.mjs +8 -0
  162. package/dist/ro-RO.module.js +8 -0
  163. package/dist/ro-RO.module.js.map +1 -0
  164. package/dist/ru-RU.main.js +6 -0
  165. package/dist/ru-RU.main.js.map +1 -0
  166. package/dist/ru-RU.mjs +8 -0
  167. package/dist/ru-RU.module.js +8 -0
  168. package/dist/ru-RU.module.js.map +1 -0
  169. package/dist/sk-SK.main.js +6 -0
  170. package/dist/sk-SK.main.js.map +1 -0
  171. package/dist/sk-SK.mjs +8 -0
  172. package/dist/sk-SK.module.js +8 -0
  173. package/dist/sk-SK.module.js.map +1 -0
  174. package/dist/sl-SI.main.js +6 -0
  175. package/dist/sl-SI.main.js.map +1 -0
  176. package/dist/sl-SI.mjs +8 -0
  177. package/dist/sl-SI.module.js +8 -0
  178. package/dist/sl-SI.module.js.map +1 -0
  179. package/dist/sr-SP.main.js +6 -0
  180. package/dist/sr-SP.main.js.map +1 -0
  181. package/dist/sr-SP.mjs +8 -0
  182. package/dist/sr-SP.module.js +8 -0
  183. package/dist/sr-SP.module.js.map +1 -0
  184. package/dist/sv-SE.main.js +6 -0
  185. package/dist/sv-SE.main.js.map +1 -0
  186. package/dist/sv-SE.mjs +8 -0
  187. package/dist/sv-SE.module.js +8 -0
  188. package/dist/sv-SE.module.js.map +1 -0
  189. package/dist/tr-TR.main.js +6 -0
  190. package/dist/tr-TR.main.js.map +1 -0
  191. package/dist/tr-TR.mjs +8 -0
  192. package/dist/tr-TR.module.js +8 -0
  193. package/dist/tr-TR.module.js.map +1 -0
  194. package/dist/types.d.ts +355 -0
  195. package/dist/types.d.ts.map +1 -0
  196. package/dist/uk-UA.main.js +6 -0
  197. package/dist/uk-UA.main.js.map +1 -0
  198. package/dist/uk-UA.mjs +8 -0
  199. package/dist/uk-UA.module.js +8 -0
  200. package/dist/uk-UA.module.js.map +1 -0
  201. package/dist/useCloseOnScroll.main.js +52 -0
  202. package/dist/useCloseOnScroll.main.js.map +1 -0
  203. package/dist/useCloseOnScroll.mjs +46 -0
  204. package/dist/useCloseOnScroll.module.js +46 -0
  205. package/dist/useCloseOnScroll.module.js.map +1 -0
  206. package/dist/useModal.main.js +118 -0
  207. package/dist/useModal.main.js.map +1 -0
  208. package/dist/useModal.mjs +105 -0
  209. package/dist/useModal.module.js +105 -0
  210. package/dist/useModal.module.js.map +1 -0
  211. package/dist/useModalOverlay.main.js +57 -0
  212. package/dist/useModalOverlay.main.js.map +1 -0
  213. package/dist/useModalOverlay.mjs +52 -0
  214. package/dist/useModalOverlay.module.js +52 -0
  215. package/dist/useModalOverlay.module.js.map +1 -0
  216. package/dist/useOverlay.main.js +113 -0
  217. package/dist/useOverlay.main.js.map +1 -0
  218. package/dist/useOverlay.mjs +108 -0
  219. package/dist/useOverlay.module.js +108 -0
  220. package/dist/useOverlay.module.js.map +1 -0
  221. package/dist/useOverlayPosition.main.js +226 -0
  222. package/dist/useOverlayPosition.main.js.map +1 -0
  223. package/dist/useOverlayPosition.mjs +221 -0
  224. package/dist/useOverlayPosition.module.js +221 -0
  225. package/dist/useOverlayPosition.module.js.map +1 -0
  226. package/dist/useOverlayTrigger.main.js +54 -0
  227. package/dist/useOverlayTrigger.main.js.map +1 -0
  228. package/dist/useOverlayTrigger.mjs +49 -0
  229. package/dist/useOverlayTrigger.module.js +49 -0
  230. package/dist/useOverlayTrigger.module.js.map +1 -0
  231. package/dist/usePopover.main.js +77 -0
  232. package/dist/usePopover.main.js.map +1 -0
  233. package/dist/usePopover.mjs +72 -0
  234. package/dist/usePopover.module.js +72 -0
  235. package/dist/usePopover.module.js.map +1 -0
  236. package/dist/usePreventScroll.main.js +220 -0
  237. package/dist/usePreventScroll.main.js.map +1 -0
  238. package/dist/usePreventScroll.mjs +215 -0
  239. package/dist/usePreventScroll.module.js +215 -0
  240. package/dist/usePreventScroll.module.js.map +1 -0
  241. package/dist/zh-CN.main.js +6 -0
  242. package/dist/zh-CN.main.js.map +1 -0
  243. package/dist/zh-CN.mjs +8 -0
  244. package/dist/zh-CN.module.js +8 -0
  245. package/dist/zh-CN.module.js.map +1 -0
  246. package/dist/zh-TW.main.js +6 -0
  247. package/dist/zh-TW.main.js.map +1 -0
  248. package/dist/zh-TW.mjs +8 -0
  249. package/dist/zh-TW.module.js +8 -0
  250. package/dist/zh-TW.module.js.map +1 -0
  251. package/package.json +70 -0
  252. package/src/DismissButton.tsx +52 -0
  253. package/src/Overlay.tsx +95 -0
  254. package/src/PortalProvider.tsx +41 -0
  255. package/src/ariaHideOutside.ts +300 -0
  256. package/src/calculatePosition.ts +702 -0
  257. package/src/index.ts +33 -0
  258. package/src/useCloseOnScroll.ts +65 -0
  259. package/src/useModal.tsx +197 -0
  260. package/src/useModalOverlay.ts +69 -0
  261. package/src/useOverlay.ts +170 -0
  262. package/src/useOverlayPosition.ts +328 -0
  263. package/src/useOverlayTrigger.ts +72 -0
  264. package/src/usePopover.ts +138 -0
  265. package/src/usePreventScroll.ts +279 -0
@@ -0,0 +1,52 @@
1
+ import {ariaHideOutside as $5e3802645cc19319$export$1c3ebcada18427bf} from "./ariaHideOutside.mjs";
2
+ import {useOverlay as $a11501f3d1d39e6c$export$ea8f71083e90600f} from "./useOverlay.mjs";
3
+ import {useOverlayFocusContain as $337b884510726a0d$export$14c98a7594375490} from "./Overlay.mjs";
4
+ import {usePreventScroll as $49c51c25361d4cd2$export$ee0f7cc6afcd1c18} from "./usePreventScroll.mjs";
5
+ import {mergeProps as $7Dhkr$mergeProps} from "@react-aria/utils";
6
+ import {useEffect as $7Dhkr$useEffect} from "react";
7
+
8
+ /*
9
+ * Copyright 2022 Adobe. All rights reserved.
10
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software distributed under
15
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
+ * OF ANY KIND, either express or implied. See the License for the specific language
17
+ * governing permissions and limitations under the License.
18
+ */
19
+
20
+
21
+
22
+
23
+
24
+ function $8ac8429251c45e4b$export$dbc0f175b25fb0fb(props, state, ref) {
25
+ let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $a11501f3d1d39e6c$export$ea8f71083e90600f)({
26
+ ...props,
27
+ isOpen: state.isOpen,
28
+ onClose: state.close
29
+ }, ref);
30
+ (0, $49c51c25361d4cd2$export$ee0f7cc6afcd1c18)({
31
+ isDisabled: !state.isOpen
32
+ });
33
+ (0, $337b884510726a0d$export$14c98a7594375490)();
34
+ (0, $7Dhkr$useEffect)(()=>{
35
+ if (state.isOpen && ref.current) return (0, $5e3802645cc19319$export$1c3ebcada18427bf)([
36
+ ref.current
37
+ ], {
38
+ shouldUseInert: true
39
+ });
40
+ }, [
41
+ state.isOpen,
42
+ ref
43
+ ]);
44
+ return {
45
+ modalProps: (0, $7Dhkr$mergeProps)(overlayProps),
46
+ underlayProps: underlayProps
47
+ };
48
+ }
49
+
50
+
51
+ export {$8ac8429251c45e4b$export$dbc0f175b25fb0fb as useModalOverlay};
52
+ //# sourceMappingURL=useModalOverlay.module.js.map
@@ -0,0 +1,52 @@
1
+ import {ariaHideOutside as $5e3802645cc19319$export$1c3ebcada18427bf} from "./ariaHideOutside.module.js";
2
+ import {useOverlay as $a11501f3d1d39e6c$export$ea8f71083e90600f} from "./useOverlay.module.js";
3
+ import {useOverlayFocusContain as $337b884510726a0d$export$14c98a7594375490} from "./Overlay.module.js";
4
+ import {usePreventScroll as $49c51c25361d4cd2$export$ee0f7cc6afcd1c18} from "./usePreventScroll.module.js";
5
+ import {mergeProps as $7Dhkr$mergeProps} from "@react-aria/utils";
6
+ import {useEffect as $7Dhkr$useEffect} from "react";
7
+
8
+ /*
9
+ * Copyright 2022 Adobe. All rights reserved.
10
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software distributed under
15
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
+ * OF ANY KIND, either express or implied. See the License for the specific language
17
+ * governing permissions and limitations under the License.
18
+ */
19
+
20
+
21
+
22
+
23
+
24
+ function $8ac8429251c45e4b$export$dbc0f175b25fb0fb(props, state, ref) {
25
+ let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $a11501f3d1d39e6c$export$ea8f71083e90600f)({
26
+ ...props,
27
+ isOpen: state.isOpen,
28
+ onClose: state.close
29
+ }, ref);
30
+ (0, $49c51c25361d4cd2$export$ee0f7cc6afcd1c18)({
31
+ isDisabled: !state.isOpen
32
+ });
33
+ (0, $337b884510726a0d$export$14c98a7594375490)();
34
+ (0, $7Dhkr$useEffect)(()=>{
35
+ if (state.isOpen && ref.current) return (0, $5e3802645cc19319$export$1c3ebcada18427bf)([
36
+ ref.current
37
+ ], {
38
+ shouldUseInert: true
39
+ });
40
+ }, [
41
+ state.isOpen,
42
+ ref
43
+ ]);
44
+ return {
45
+ modalProps: (0, $7Dhkr$mergeProps)(overlayProps),
46
+ underlayProps: underlayProps
47
+ };
48
+ }
49
+
50
+
51
+ export {$8ac8429251c45e4b$export$dbc0f175b25fb0fb as useModalOverlay};
52
+ //# sourceMappingURL=useModalOverlay.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAmCM,SAAS,0CAAgB,KAA4B,EAAE,KAA0B,EAAE,GAAkC;IAC1H,IAAI,gBAAC,YAAY,iBAAE,aAAa,EAAC,GAAG,CAAA,GAAA,yCAAS,EAAE;QAC7C,GAAG,KAAK;QACR,QAAQ,MAAM,MAAM;QACpB,SAAS,MAAM,KAAK;IACtB,GAAG;IAEH,CAAA,GAAA,yCAAe,EAAE;QACf,YAAY,CAAC,MAAM,MAAM;IAC3B;IAEA,CAAA,GAAA,yCAAqB;IAErB,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,MAAM,MAAM,IAAI,IAAI,OAAO,EAC7B,OAAO,CAAA,GAAA,yCAAc,EAAE;YAAC,IAAI,OAAO;SAAC,EAAE;YAAC,gBAAgB;QAAI;IAE/D,GAAG;QAAC,MAAM,MAAM;QAAE;KAAI;IAEtB,OAAO;QACL,YAAY,CAAA,GAAA,iBAAS,EAAE;uBACvB;IACF;AACF","sources":["packages/@react-aria/overlays/src/useModalOverlay.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ariaHideOutside} from './ariaHideOutside';\nimport {AriaOverlayProps, useOverlay} from './useOverlay';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport {OverlayTriggerState} from '@react-stately/overlays';\nimport {useEffect} from 'react';\nimport {useOverlayFocusContain} from './Overlay';\nimport {usePreventScroll} from './usePreventScroll';\n\nexport interface AriaModalOverlayProps extends Pick<AriaOverlayProps, 'shouldCloseOnInteractOutside'> {\n /**\n * Whether to close the modal when the user interacts outside it.\n * @default false\n */\n isDismissable?: boolean,\n /**\n * Whether pressing the escape key to close the modal should be disabled.\n * @default false\n */\n isKeyboardDismissDisabled?: boolean\n}\n\nexport interface ModalOverlayAria {\n /** Props for the modal element. */\n modalProps: DOMAttributes,\n /** Props for the underlay element. */\n underlayProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a modal component.\n * A modal is an overlay element which blocks interaction with elements outside it.\n */\nexport function useModalOverlay(props: AriaModalOverlayProps, state: OverlayTriggerState, ref: RefObject<HTMLElement | null>): ModalOverlayAria {\n let {overlayProps, underlayProps} = useOverlay({\n ...props,\n isOpen: state.isOpen,\n onClose: state.close\n }, ref);\n\n usePreventScroll({\n isDisabled: !state.isOpen\n });\n\n useOverlayFocusContain();\n\n useEffect(() => {\n if (state.isOpen && ref.current) {\n return ariaHideOutside([ref.current], {shouldUseInert: true});\n }\n }, [state.isOpen, ref]);\n\n return {\n modalProps: mergeProps(overlayProps),\n underlayProps\n };\n}\n"],"names":[],"version":3,"file":"useModalOverlay.module.js.map"}
@@ -0,0 +1,113 @@
1
+ var $eQbp7$reactariautils = require("@react-aria/utils");
2
+ var $eQbp7$reactariafocus = require("@react-aria/focus");
3
+ var $eQbp7$react = require("react");
4
+ var $eQbp7$reactariainteractions = require("@react-aria/interactions");
5
+
6
+
7
+ function $parcel$export(e, n, v, s) {
8
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
+ }
10
+
11
+ $parcel$export(module.exports, "useOverlay", () => $82711f9cb668ecdb$export$ea8f71083e90600f);
12
+ /*
13
+ * Copyright 2020 Adobe. All rights reserved.
14
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License. You may obtain a copy
16
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software distributed under
19
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
20
+ * OF ANY KIND, either express or implied. See the License for the specific language
21
+ * governing permissions and limitations under the License.
22
+ */
23
+
24
+
25
+
26
+ const $82711f9cb668ecdb$var$visibleOverlays = [];
27
+ function $82711f9cb668ecdb$export$ea8f71083e90600f(props, ref) {
28
+ let { onClose: onClose, shouldCloseOnBlur: shouldCloseOnBlur, isOpen: isOpen, isDismissable: isDismissable = false, isKeyboardDismissDisabled: isKeyboardDismissDisabled = false, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside } = props;
29
+ let lastVisibleOverlay = (0, $eQbp7$react.useRef)(undefined);
30
+ // Add the overlay ref to the stack of visible overlays on mount, and remove on unmount.
31
+ (0, $eQbp7$react.useEffect)(()=>{
32
+ if (isOpen && !$82711f9cb668ecdb$var$visibleOverlays.includes(ref)) {
33
+ $82711f9cb668ecdb$var$visibleOverlays.push(ref);
34
+ return ()=>{
35
+ let index = $82711f9cb668ecdb$var$visibleOverlays.indexOf(ref);
36
+ if (index >= 0) $82711f9cb668ecdb$var$visibleOverlays.splice(index, 1);
37
+ };
38
+ }
39
+ }, [
40
+ isOpen,
41
+ ref
42
+ ]);
43
+ // Only hide the overlay when it is the topmost visible overlay in the stack
44
+ let onHide = ()=>{
45
+ if ($82711f9cb668ecdb$var$visibleOverlays[$82711f9cb668ecdb$var$visibleOverlays.length - 1] === ref && onClose) onClose();
46
+ };
47
+ let onInteractOutsideStart = (e)=>{
48
+ const topMostOverlay = $82711f9cb668ecdb$var$visibleOverlays[$82711f9cb668ecdb$var$visibleOverlays.length - 1];
49
+ lastVisibleOverlay.current = topMostOverlay;
50
+ if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside((0, $eQbp7$reactariautils.getEventTarget)(e))) {
51
+ if (topMostOverlay === ref) {
52
+ e.stopPropagation();
53
+ e.preventDefault();
54
+ }
55
+ }
56
+ };
57
+ let onInteractOutside = (e)=>{
58
+ if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside((0, $eQbp7$reactariautils.getEventTarget)(e))) {
59
+ if ($82711f9cb668ecdb$var$visibleOverlays[$82711f9cb668ecdb$var$visibleOverlays.length - 1] === ref) {
60
+ e.stopPropagation();
61
+ e.preventDefault();
62
+ }
63
+ if (lastVisibleOverlay.current === ref) onHide();
64
+ }
65
+ lastVisibleOverlay.current = undefined;
66
+ };
67
+ // Handle the escape key
68
+ let onKeyDown = (e)=>{
69
+ if (e.key === 'Escape' && !isKeyboardDismissDisabled && !e.nativeEvent.isComposing) {
70
+ e.stopPropagation();
71
+ e.preventDefault();
72
+ onHide();
73
+ }
74
+ };
75
+ // Handle clicking outside the overlay to close it
76
+ (0, $eQbp7$reactariainteractions.useInteractOutside)({
77
+ ref: ref,
78
+ onInteractOutside: isDismissable && isOpen ? onInteractOutside : undefined,
79
+ onInteractOutsideStart: onInteractOutsideStart
80
+ });
81
+ let { focusWithinProps: focusWithinProps } = (0, $eQbp7$reactariainteractions.useFocusWithin)({
82
+ isDisabled: !shouldCloseOnBlur,
83
+ onBlurWithin: (e)=>{
84
+ // Do not close if relatedTarget is null, which means focus is lost to the body.
85
+ // That can happen when switching tabs, or due to a VoiceOver/Chrome bug with Control+Option+Arrow navigation.
86
+ // Clicking on the body to close the overlay should already be handled by useInteractOutside.
87
+ // https://github.com/adobe/react-spectrum/issues/4130
88
+ // https://github.com/adobe/react-spectrum/issues/4922
89
+ //
90
+ // If focus is moving into a child focus scope (e.g. menu inside a dialog),
91
+ // do not close the outer overlay. At this point, the active scope should
92
+ // still be the outer overlay, since blur events run before focus.
93
+ if (!e.relatedTarget || (0, $eQbp7$reactariafocus.isElementInChildOfActiveScope)(e.relatedTarget)) return;
94
+ if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside(e.relatedTarget)) onClose === null || onClose === void 0 ? void 0 : onClose();
95
+ }
96
+ });
97
+ let onPointerDownUnderlay = (e)=>{
98
+ // fixes a firefox issue that starts text selection https://bugzilla.mozilla.org/show_bug.cgi?id=1675846
99
+ if ((0, $eQbp7$reactariautils.getEventTarget)(e) === e.currentTarget) e.preventDefault();
100
+ };
101
+ return {
102
+ overlayProps: {
103
+ onKeyDown: onKeyDown,
104
+ ...focusWithinProps
105
+ },
106
+ underlayProps: {
107
+ onPointerDown: onPointerDownUnderlay
108
+ }
109
+ };
110
+ }
111
+
112
+
113
+ //# sourceMappingURL=useOverlay.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA8CD,MAAM,wCAA+C,EAAE;AAOhD,SAAS,0CAAW,KAAuB,EAAE,GAA8B;IAChF,IAAI,WACF,OAAO,qBACP,iBAAiB,UACjB,MAAM,iBACN,gBAAgB,kCAChB,4BAA4B,qCAC5B,4BAA4B,EAC7B,GAAG;IAEJ,IAAI,qBAAqB,CAAA,GAAA,mBAAK,EAA6B;IAE3D,wFAAwF;IACxF,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,UAAU,CAAC,sCAAgB,QAAQ,CAAC,MAAM;YAC5C,sCAAgB,IAAI,CAAC;YACrB,OAAO;gBACL,IAAI,QAAQ,sCAAgB,OAAO,CAAC;gBACpC,IAAI,SAAS,GACX,sCAAgB,MAAM,CAAC,OAAO;YAElC;QACF;IACF,GAAG;QAAC;QAAQ;KAAI;IAEhB,4EAA4E;IAC5E,IAAI,SAAS;QACX,IAAI,qCAAe,CAAC,sCAAgB,MAAM,GAAG,EAAE,KAAK,OAAO,SACzD;IAEJ;IAEA,IAAI,yBAAyB,CAAC;QAC5B,MAAM,iBAAiB,qCAAe,CAAC,sCAAgB,MAAM,GAAG,EAAE;QAClE,mBAAmB,OAAO,GAAG;QAC7B,IAAI,CAAC,gCAAgC,6BAA6B,CAAA,GAAA,oCAAa,EAAE,KAC/E;YAAA,IAAI,mBAAmB,KAAK;gBAC1B,EAAE,eAAe;gBACjB,EAAE,cAAc;YAClB;QAAA;IAEJ;IAEA,IAAI,oBAAoB,CAAC;QACvB,IAAI,CAAC,gCAAgC,6BAA6B,CAAA,GAAA,oCAAa,EAAE,KAAgB;YAC/F,IAAI,qCAAe,CAAC,sCAAgB,MAAM,GAAG,EAAE,KAAK,KAAK;gBACvD,EAAE,eAAe;gBACjB,EAAE,cAAc;YAClB;YACA,IAAI,mBAAmB,OAAO,KAAK,KACjC;QAEJ;QACA,mBAAmB,OAAO,GAAG;IAC/B;IAEA,wBAAwB;IACxB,IAAI,YAAY,CAAC;QACf,IAAI,EAAE,GAAG,KAAK,YAAY,CAAC,6BAA6B,CAAC,EAAE,WAAW,CAAC,WAAW,EAAE;YAClF,EAAE,eAAe;YACjB,EAAE,cAAc;YAChB;QACF;IACF;IAEA,kDAAkD;IAClD,CAAA,GAAA,+CAAiB,EAAE;aAAC;QAAK,mBAAmB,iBAAiB,SAAS,oBAAoB;gCAAW;IAAsB;IAE3H,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,2CAAa,EAAE;QACtC,YAAY,CAAC;QACb,cAAc,CAAC;YACb,gFAAgF;YAChF,8GAA8G;YAC9G,6FAA6F;YAC7F,sDAAsD;YACtD,sDAAsD;YACtD,EAAE;YACF,2EAA2E;YAC3E,yEAAyE;YACzE,kEAAkE;YAClE,IAAI,CAAC,EAAE,aAAa,IAAI,CAAA,GAAA,mDAA4B,EAAE,EAAE,aAAa,GACnE;YAGF,IAAI,CAAC,gCAAgC,6BAA6B,EAAE,aAAa,GAC/E,oBAAA,8BAAA;QAEJ;IACF;IAEA,IAAI,wBAAwB,CAAA;QAC1B,wGAAwG;QACxG,IAAI,CAAA,GAAA,oCAAa,EAAE,OAAO,EAAE,aAAa,EACvC,EAAE,cAAc;IAEpB;IAEA,OAAO;QACL,cAAc;uBACZ;YACA,GAAG,gBAAgB;QACrB;QACA,eAAe;YACb,eAAe;QACjB;IACF;AACF","sources":["packages/@react-aria/overlays/src/useOverlay.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {getEventTarget} from '@react-aria/utils';\nimport {isElementInChildOfActiveScope} from '@react-aria/focus';\nimport {useEffect, useRef} from 'react';\nimport {useFocusWithin, useInteractOutside} from '@react-aria/interactions';\n\nexport interface AriaOverlayProps {\n /** Whether the overlay is currently open. */\n isOpen?: boolean,\n\n /** Handler that is called when the overlay should close. */\n onClose?: () => void,\n\n /**\n * Whether to close the overlay when the user interacts outside it.\n * @default false\n */\n isDismissable?: boolean,\n\n /** Whether the overlay should close when focus is lost or moves outside it. */\n shouldCloseOnBlur?: boolean,\n\n /**\n * Whether pressing the escape key to close the overlay should be disabled.\n * @default false\n */\n isKeyboardDismissDisabled?: boolean,\n\n /**\n * When user interacts with the argument element outside of the overlay ref,\n * return true if onClose should be called. This gives you a chance to filter\n * out interaction with elements that should not dismiss the overlay.\n * By default, onClose will always be called on interaction outside the overlay ref.\n */\n shouldCloseOnInteractOutside?: (element: Element) => boolean\n}\n\nexport interface OverlayAria {\n /** Props to apply to the overlay container element. */\n overlayProps: DOMAttributes,\n /** Props to apply to the underlay element, if any. */\n underlayProps: DOMAttributes\n}\n\nconst visibleOverlays: RefObject<Element | null>[] = [];\n\n/**\n * Provides the behavior for overlays such as dialogs, popovers, and menus.\n * Hides the overlay when the user interacts outside it, when the Escape key is pressed,\n * or optionally, on blur. Only the top-most overlay will close at once.\n */\nexport function useOverlay(props: AriaOverlayProps, ref: RefObject<Element | null>): OverlayAria {\n let {\n onClose,\n shouldCloseOnBlur,\n isOpen,\n isDismissable = false,\n isKeyboardDismissDisabled = false,\n shouldCloseOnInteractOutside\n } = props;\n\n let lastVisibleOverlay = useRef<RefObject<Element | null>>(undefined);\n\n // Add the overlay ref to the stack of visible overlays on mount, and remove on unmount.\n useEffect(() => {\n if (isOpen && !visibleOverlays.includes(ref)) {\n visibleOverlays.push(ref);\n return () => {\n let index = visibleOverlays.indexOf(ref);\n if (index >= 0) {\n visibleOverlays.splice(index, 1);\n }\n };\n }\n }, [isOpen, ref]);\n\n // Only hide the overlay when it is the topmost visible overlay in the stack\n let onHide = () => {\n if (visibleOverlays[visibleOverlays.length - 1] === ref && onClose) {\n onClose();\n }\n };\n\n let onInteractOutsideStart = (e: PointerEvent) => {\n const topMostOverlay = visibleOverlays[visibleOverlays.length - 1];\n lastVisibleOverlay.current = topMostOverlay;\n if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside(getEventTarget(e) as Element)) {\n if (topMostOverlay === ref) {\n e.stopPropagation();\n e.preventDefault();\n }\n }\n };\n\n let onInteractOutside = (e: PointerEvent) => {\n if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside(getEventTarget(e) as Element)) {\n if (visibleOverlays[visibleOverlays.length - 1] === ref) {\n e.stopPropagation();\n e.preventDefault();\n }\n if (lastVisibleOverlay.current === ref) {\n onHide();\n }\n }\n lastVisibleOverlay.current = undefined;\n };\n\n // Handle the escape key\n let onKeyDown = (e) => {\n if (e.key === 'Escape' && !isKeyboardDismissDisabled && !e.nativeEvent.isComposing) {\n e.stopPropagation();\n e.preventDefault();\n onHide();\n }\n };\n\n // Handle clicking outside the overlay to close it\n useInteractOutside({ref, onInteractOutside: isDismissable && isOpen ? onInteractOutside : undefined, onInteractOutsideStart});\n\n let {focusWithinProps} = useFocusWithin({\n isDisabled: !shouldCloseOnBlur,\n onBlurWithin: (e) => {\n // Do not close if relatedTarget is null, which means focus is lost to the body.\n // That can happen when switching tabs, or due to a VoiceOver/Chrome bug with Control+Option+Arrow navigation.\n // Clicking on the body to close the overlay should already be handled by useInteractOutside.\n // https://github.com/adobe/react-spectrum/issues/4130\n // https://github.com/adobe/react-spectrum/issues/4922\n //\n // If focus is moving into a child focus scope (e.g. menu inside a dialog),\n // do not close the outer overlay. At this point, the active scope should\n // still be the outer overlay, since blur events run before focus.\n if (!e.relatedTarget || isElementInChildOfActiveScope(e.relatedTarget)) {\n return;\n }\n\n if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside(e.relatedTarget as Element)) {\n onClose?.();\n }\n }\n });\n\n let onPointerDownUnderlay = e => {\n // fixes a firefox issue that starts text selection https://bugzilla.mozilla.org/show_bug.cgi?id=1675846\n if (getEventTarget(e) === e.currentTarget) {\n e.preventDefault();\n }\n };\n\n return {\n overlayProps: {\n onKeyDown,\n ...focusWithinProps\n },\n underlayProps: {\n onPointerDown: onPointerDownUnderlay\n }\n };\n}\n"],"names":[],"version":3,"file":"useOverlay.main.js.map"}
@@ -0,0 +1,108 @@
1
+ import {getEventTarget as $jtpZv$getEventTarget} from "@react-aria/utils";
2
+ import {isElementInChildOfActiveScope as $jtpZv$isElementInChildOfActiveScope} from "@react-aria/focus";
3
+ import {useRef as $jtpZv$useRef, useEffect as $jtpZv$useEffect} from "react";
4
+ import {useInteractOutside as $jtpZv$useInteractOutside, useFocusWithin as $jtpZv$useFocusWithin} from "@react-aria/interactions";
5
+
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */
17
+
18
+
19
+
20
+ const $a11501f3d1d39e6c$var$visibleOverlays = [];
21
+ function $a11501f3d1d39e6c$export$ea8f71083e90600f(props, ref) {
22
+ let { onClose: onClose, shouldCloseOnBlur: shouldCloseOnBlur, isOpen: isOpen, isDismissable: isDismissable = false, isKeyboardDismissDisabled: isKeyboardDismissDisabled = false, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside } = props;
23
+ let lastVisibleOverlay = (0, $jtpZv$useRef)(undefined);
24
+ // Add the overlay ref to the stack of visible overlays on mount, and remove on unmount.
25
+ (0, $jtpZv$useEffect)(()=>{
26
+ if (isOpen && !$a11501f3d1d39e6c$var$visibleOverlays.includes(ref)) {
27
+ $a11501f3d1d39e6c$var$visibleOverlays.push(ref);
28
+ return ()=>{
29
+ let index = $a11501f3d1d39e6c$var$visibleOverlays.indexOf(ref);
30
+ if (index >= 0) $a11501f3d1d39e6c$var$visibleOverlays.splice(index, 1);
31
+ };
32
+ }
33
+ }, [
34
+ isOpen,
35
+ ref
36
+ ]);
37
+ // Only hide the overlay when it is the topmost visible overlay in the stack
38
+ let onHide = ()=>{
39
+ if ($a11501f3d1d39e6c$var$visibleOverlays[$a11501f3d1d39e6c$var$visibleOverlays.length - 1] === ref && onClose) onClose();
40
+ };
41
+ let onInteractOutsideStart = (e)=>{
42
+ const topMostOverlay = $a11501f3d1d39e6c$var$visibleOverlays[$a11501f3d1d39e6c$var$visibleOverlays.length - 1];
43
+ lastVisibleOverlay.current = topMostOverlay;
44
+ if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside((0, $jtpZv$getEventTarget)(e))) {
45
+ if (topMostOverlay === ref) {
46
+ e.stopPropagation();
47
+ e.preventDefault();
48
+ }
49
+ }
50
+ };
51
+ let onInteractOutside = (e)=>{
52
+ if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside((0, $jtpZv$getEventTarget)(e))) {
53
+ if ($a11501f3d1d39e6c$var$visibleOverlays[$a11501f3d1d39e6c$var$visibleOverlays.length - 1] === ref) {
54
+ e.stopPropagation();
55
+ e.preventDefault();
56
+ }
57
+ if (lastVisibleOverlay.current === ref) onHide();
58
+ }
59
+ lastVisibleOverlay.current = undefined;
60
+ };
61
+ // Handle the escape key
62
+ let onKeyDown = (e)=>{
63
+ if (e.key === 'Escape' && !isKeyboardDismissDisabled && !e.nativeEvent.isComposing) {
64
+ e.stopPropagation();
65
+ e.preventDefault();
66
+ onHide();
67
+ }
68
+ };
69
+ // Handle clicking outside the overlay to close it
70
+ (0, $jtpZv$useInteractOutside)({
71
+ ref: ref,
72
+ onInteractOutside: isDismissable && isOpen ? onInteractOutside : undefined,
73
+ onInteractOutsideStart: onInteractOutsideStart
74
+ });
75
+ let { focusWithinProps: focusWithinProps } = (0, $jtpZv$useFocusWithin)({
76
+ isDisabled: !shouldCloseOnBlur,
77
+ onBlurWithin: (e)=>{
78
+ // Do not close if relatedTarget is null, which means focus is lost to the body.
79
+ // That can happen when switching tabs, or due to a VoiceOver/Chrome bug with Control+Option+Arrow navigation.
80
+ // Clicking on the body to close the overlay should already be handled by useInteractOutside.
81
+ // https://github.com/adobe/react-spectrum/issues/4130
82
+ // https://github.com/adobe/react-spectrum/issues/4922
83
+ //
84
+ // If focus is moving into a child focus scope (e.g. menu inside a dialog),
85
+ // do not close the outer overlay. At this point, the active scope should
86
+ // still be the outer overlay, since blur events run before focus.
87
+ if (!e.relatedTarget || (0, $jtpZv$isElementInChildOfActiveScope)(e.relatedTarget)) return;
88
+ if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside(e.relatedTarget)) onClose === null || onClose === void 0 ? void 0 : onClose();
89
+ }
90
+ });
91
+ let onPointerDownUnderlay = (e)=>{
92
+ // fixes a firefox issue that starts text selection https://bugzilla.mozilla.org/show_bug.cgi?id=1675846
93
+ if ((0, $jtpZv$getEventTarget)(e) === e.currentTarget) e.preventDefault();
94
+ };
95
+ return {
96
+ overlayProps: {
97
+ onKeyDown: onKeyDown,
98
+ ...focusWithinProps
99
+ },
100
+ underlayProps: {
101
+ onPointerDown: onPointerDownUnderlay
102
+ }
103
+ };
104
+ }
105
+
106
+
107
+ export {$a11501f3d1d39e6c$export$ea8f71083e90600f as useOverlay};
108
+ //# sourceMappingURL=useOverlay.module.js.map
@@ -0,0 +1,108 @@
1
+ import {getEventTarget as $jtpZv$getEventTarget} from "@react-aria/utils";
2
+ import {isElementInChildOfActiveScope as $jtpZv$isElementInChildOfActiveScope} from "@react-aria/focus";
3
+ import {useRef as $jtpZv$useRef, useEffect as $jtpZv$useEffect} from "react";
4
+ import {useInteractOutside as $jtpZv$useInteractOutside, useFocusWithin as $jtpZv$useFocusWithin} from "@react-aria/interactions";
5
+
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */
17
+
18
+
19
+
20
+ const $a11501f3d1d39e6c$var$visibleOverlays = [];
21
+ function $a11501f3d1d39e6c$export$ea8f71083e90600f(props, ref) {
22
+ let { onClose: onClose, shouldCloseOnBlur: shouldCloseOnBlur, isOpen: isOpen, isDismissable: isDismissable = false, isKeyboardDismissDisabled: isKeyboardDismissDisabled = false, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside } = props;
23
+ let lastVisibleOverlay = (0, $jtpZv$useRef)(undefined);
24
+ // Add the overlay ref to the stack of visible overlays on mount, and remove on unmount.
25
+ (0, $jtpZv$useEffect)(()=>{
26
+ if (isOpen && !$a11501f3d1d39e6c$var$visibleOverlays.includes(ref)) {
27
+ $a11501f3d1d39e6c$var$visibleOverlays.push(ref);
28
+ return ()=>{
29
+ let index = $a11501f3d1d39e6c$var$visibleOverlays.indexOf(ref);
30
+ if (index >= 0) $a11501f3d1d39e6c$var$visibleOverlays.splice(index, 1);
31
+ };
32
+ }
33
+ }, [
34
+ isOpen,
35
+ ref
36
+ ]);
37
+ // Only hide the overlay when it is the topmost visible overlay in the stack
38
+ let onHide = ()=>{
39
+ if ($a11501f3d1d39e6c$var$visibleOverlays[$a11501f3d1d39e6c$var$visibleOverlays.length - 1] === ref && onClose) onClose();
40
+ };
41
+ let onInteractOutsideStart = (e)=>{
42
+ const topMostOverlay = $a11501f3d1d39e6c$var$visibleOverlays[$a11501f3d1d39e6c$var$visibleOverlays.length - 1];
43
+ lastVisibleOverlay.current = topMostOverlay;
44
+ if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside((0, $jtpZv$getEventTarget)(e))) {
45
+ if (topMostOverlay === ref) {
46
+ e.stopPropagation();
47
+ e.preventDefault();
48
+ }
49
+ }
50
+ };
51
+ let onInteractOutside = (e)=>{
52
+ if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside((0, $jtpZv$getEventTarget)(e))) {
53
+ if ($a11501f3d1d39e6c$var$visibleOverlays[$a11501f3d1d39e6c$var$visibleOverlays.length - 1] === ref) {
54
+ e.stopPropagation();
55
+ e.preventDefault();
56
+ }
57
+ if (lastVisibleOverlay.current === ref) onHide();
58
+ }
59
+ lastVisibleOverlay.current = undefined;
60
+ };
61
+ // Handle the escape key
62
+ let onKeyDown = (e)=>{
63
+ if (e.key === 'Escape' && !isKeyboardDismissDisabled && !e.nativeEvent.isComposing) {
64
+ e.stopPropagation();
65
+ e.preventDefault();
66
+ onHide();
67
+ }
68
+ };
69
+ // Handle clicking outside the overlay to close it
70
+ (0, $jtpZv$useInteractOutside)({
71
+ ref: ref,
72
+ onInteractOutside: isDismissable && isOpen ? onInteractOutside : undefined,
73
+ onInteractOutsideStart: onInteractOutsideStart
74
+ });
75
+ let { focusWithinProps: focusWithinProps } = (0, $jtpZv$useFocusWithin)({
76
+ isDisabled: !shouldCloseOnBlur,
77
+ onBlurWithin: (e)=>{
78
+ // Do not close if relatedTarget is null, which means focus is lost to the body.
79
+ // That can happen when switching tabs, or due to a VoiceOver/Chrome bug with Control+Option+Arrow navigation.
80
+ // Clicking on the body to close the overlay should already be handled by useInteractOutside.
81
+ // https://github.com/adobe/react-spectrum/issues/4130
82
+ // https://github.com/adobe/react-spectrum/issues/4922
83
+ //
84
+ // If focus is moving into a child focus scope (e.g. menu inside a dialog),
85
+ // do not close the outer overlay. At this point, the active scope should
86
+ // still be the outer overlay, since blur events run before focus.
87
+ if (!e.relatedTarget || (0, $jtpZv$isElementInChildOfActiveScope)(e.relatedTarget)) return;
88
+ if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside(e.relatedTarget)) onClose === null || onClose === void 0 ? void 0 : onClose();
89
+ }
90
+ });
91
+ let onPointerDownUnderlay = (e)=>{
92
+ // fixes a firefox issue that starts text selection https://bugzilla.mozilla.org/show_bug.cgi?id=1675846
93
+ if ((0, $jtpZv$getEventTarget)(e) === e.currentTarget) e.preventDefault();
94
+ };
95
+ return {
96
+ overlayProps: {
97
+ onKeyDown: onKeyDown,
98
+ ...focusWithinProps
99
+ },
100
+ underlayProps: {
101
+ onPointerDown: onPointerDownUnderlay
102
+ }
103
+ };
104
+ }
105
+
106
+
107
+ export {$a11501f3d1d39e6c$export$ea8f71083e90600f as useOverlay};
108
+ //# sourceMappingURL=useOverlay.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AA8CD,MAAM,wCAA+C,EAAE;AAOhD,SAAS,0CAAW,KAAuB,EAAE,GAA8B;IAChF,IAAI,WACF,OAAO,qBACP,iBAAiB,UACjB,MAAM,iBACN,gBAAgB,kCAChB,4BAA4B,qCAC5B,4BAA4B,EAC7B,GAAG;IAEJ,IAAI,qBAAqB,CAAA,GAAA,aAAK,EAA6B;IAE3D,wFAAwF;IACxF,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,UAAU,CAAC,sCAAgB,QAAQ,CAAC,MAAM;YAC5C,sCAAgB,IAAI,CAAC;YACrB,OAAO;gBACL,IAAI,QAAQ,sCAAgB,OAAO,CAAC;gBACpC,IAAI,SAAS,GACX,sCAAgB,MAAM,CAAC,OAAO;YAElC;QACF;IACF,GAAG;QAAC;QAAQ;KAAI;IAEhB,4EAA4E;IAC5E,IAAI,SAAS;QACX,IAAI,qCAAe,CAAC,sCAAgB,MAAM,GAAG,EAAE,KAAK,OAAO,SACzD;IAEJ;IAEA,IAAI,yBAAyB,CAAC;QAC5B,MAAM,iBAAiB,qCAAe,CAAC,sCAAgB,MAAM,GAAG,EAAE;QAClE,mBAAmB,OAAO,GAAG;QAC7B,IAAI,CAAC,gCAAgC,6BAA6B,CAAA,GAAA,qBAAa,EAAE,KAC/E;YAAA,IAAI,mBAAmB,KAAK;gBAC1B,EAAE,eAAe;gBACjB,EAAE,cAAc;YAClB;QAAA;IAEJ;IAEA,IAAI,oBAAoB,CAAC;QACvB,IAAI,CAAC,gCAAgC,6BAA6B,CAAA,GAAA,qBAAa,EAAE,KAAgB;YAC/F,IAAI,qCAAe,CAAC,sCAAgB,MAAM,GAAG,EAAE,KAAK,KAAK;gBACvD,EAAE,eAAe;gBACjB,EAAE,cAAc;YAClB;YACA,IAAI,mBAAmB,OAAO,KAAK,KACjC;QAEJ;QACA,mBAAmB,OAAO,GAAG;IAC/B;IAEA,wBAAwB;IACxB,IAAI,YAAY,CAAC;QACf,IAAI,EAAE,GAAG,KAAK,YAAY,CAAC,6BAA6B,CAAC,EAAE,WAAW,CAAC,WAAW,EAAE;YAClF,EAAE,eAAe;YACjB,EAAE,cAAc;YAChB;QACF;IACF;IAEA,kDAAkD;IAClD,CAAA,GAAA,yBAAiB,EAAE;aAAC;QAAK,mBAAmB,iBAAiB,SAAS,oBAAoB;gCAAW;IAAsB;IAE3H,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QACtC,YAAY,CAAC;QACb,cAAc,CAAC;YACb,gFAAgF;YAChF,8GAA8G;YAC9G,6FAA6F;YAC7F,sDAAsD;YACtD,sDAAsD;YACtD,EAAE;YACF,2EAA2E;YAC3E,yEAAyE;YACzE,kEAAkE;YAClE,IAAI,CAAC,EAAE,aAAa,IAAI,CAAA,GAAA,oCAA4B,EAAE,EAAE,aAAa,GACnE;YAGF,IAAI,CAAC,gCAAgC,6BAA6B,EAAE,aAAa,GAC/E,oBAAA,8BAAA;QAEJ;IACF;IAEA,IAAI,wBAAwB,CAAA;QAC1B,wGAAwG;QACxG,IAAI,CAAA,GAAA,qBAAa,EAAE,OAAO,EAAE,aAAa,EACvC,EAAE,cAAc;IAEpB;IAEA,OAAO;QACL,cAAc;uBACZ;YACA,GAAG,gBAAgB;QACrB;QACA,eAAe;YACb,eAAe;QACjB;IACF;AACF","sources":["packages/@react-aria/overlays/src/useOverlay.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {getEventTarget} from '@react-aria/utils';\nimport {isElementInChildOfActiveScope} from '@react-aria/focus';\nimport {useEffect, useRef} from 'react';\nimport {useFocusWithin, useInteractOutside} from '@react-aria/interactions';\n\nexport interface AriaOverlayProps {\n /** Whether the overlay is currently open. */\n isOpen?: boolean,\n\n /** Handler that is called when the overlay should close. */\n onClose?: () => void,\n\n /**\n * Whether to close the overlay when the user interacts outside it.\n * @default false\n */\n isDismissable?: boolean,\n\n /** Whether the overlay should close when focus is lost or moves outside it. */\n shouldCloseOnBlur?: boolean,\n\n /**\n * Whether pressing the escape key to close the overlay should be disabled.\n * @default false\n */\n isKeyboardDismissDisabled?: boolean,\n\n /**\n * When user interacts with the argument element outside of the overlay ref,\n * return true if onClose should be called. This gives you a chance to filter\n * out interaction with elements that should not dismiss the overlay.\n * By default, onClose will always be called on interaction outside the overlay ref.\n */\n shouldCloseOnInteractOutside?: (element: Element) => boolean\n}\n\nexport interface OverlayAria {\n /** Props to apply to the overlay container element. */\n overlayProps: DOMAttributes,\n /** Props to apply to the underlay element, if any. */\n underlayProps: DOMAttributes\n}\n\nconst visibleOverlays: RefObject<Element | null>[] = [];\n\n/**\n * Provides the behavior for overlays such as dialogs, popovers, and menus.\n * Hides the overlay when the user interacts outside it, when the Escape key is pressed,\n * or optionally, on blur. Only the top-most overlay will close at once.\n */\nexport function useOverlay(props: AriaOverlayProps, ref: RefObject<Element | null>): OverlayAria {\n let {\n onClose,\n shouldCloseOnBlur,\n isOpen,\n isDismissable = false,\n isKeyboardDismissDisabled = false,\n shouldCloseOnInteractOutside\n } = props;\n\n let lastVisibleOverlay = useRef<RefObject<Element | null>>(undefined);\n\n // Add the overlay ref to the stack of visible overlays on mount, and remove on unmount.\n useEffect(() => {\n if (isOpen && !visibleOverlays.includes(ref)) {\n visibleOverlays.push(ref);\n return () => {\n let index = visibleOverlays.indexOf(ref);\n if (index >= 0) {\n visibleOverlays.splice(index, 1);\n }\n };\n }\n }, [isOpen, ref]);\n\n // Only hide the overlay when it is the topmost visible overlay in the stack\n let onHide = () => {\n if (visibleOverlays[visibleOverlays.length - 1] === ref && onClose) {\n onClose();\n }\n };\n\n let onInteractOutsideStart = (e: PointerEvent) => {\n const topMostOverlay = visibleOverlays[visibleOverlays.length - 1];\n lastVisibleOverlay.current = topMostOverlay;\n if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside(getEventTarget(e) as Element)) {\n if (topMostOverlay === ref) {\n e.stopPropagation();\n e.preventDefault();\n }\n }\n };\n\n let onInteractOutside = (e: PointerEvent) => {\n if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside(getEventTarget(e) as Element)) {\n if (visibleOverlays[visibleOverlays.length - 1] === ref) {\n e.stopPropagation();\n e.preventDefault();\n }\n if (lastVisibleOverlay.current === ref) {\n onHide();\n }\n }\n lastVisibleOverlay.current = undefined;\n };\n\n // Handle the escape key\n let onKeyDown = (e) => {\n if (e.key === 'Escape' && !isKeyboardDismissDisabled && !e.nativeEvent.isComposing) {\n e.stopPropagation();\n e.preventDefault();\n onHide();\n }\n };\n\n // Handle clicking outside the overlay to close it\n useInteractOutside({ref, onInteractOutside: isDismissable && isOpen ? onInteractOutside : undefined, onInteractOutsideStart});\n\n let {focusWithinProps} = useFocusWithin({\n isDisabled: !shouldCloseOnBlur,\n onBlurWithin: (e) => {\n // Do not close if relatedTarget is null, which means focus is lost to the body.\n // That can happen when switching tabs, or due to a VoiceOver/Chrome bug with Control+Option+Arrow navigation.\n // Clicking on the body to close the overlay should already be handled by useInteractOutside.\n // https://github.com/adobe/react-spectrum/issues/4130\n // https://github.com/adobe/react-spectrum/issues/4922\n //\n // If focus is moving into a child focus scope (e.g. menu inside a dialog),\n // do not close the outer overlay. At this point, the active scope should\n // still be the outer overlay, since blur events run before focus.\n if (!e.relatedTarget || isElementInChildOfActiveScope(e.relatedTarget)) {\n return;\n }\n\n if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside(e.relatedTarget as Element)) {\n onClose?.();\n }\n }\n });\n\n let onPointerDownUnderlay = e => {\n // fixes a firefox issue that starts text selection https://bugzilla.mozilla.org/show_bug.cgi?id=1675846\n if (getEventTarget(e) === e.currentTarget) {\n e.preventDefault();\n }\n };\n\n return {\n overlayProps: {\n onKeyDown,\n ...focusWithinProps\n },\n underlayProps: {\n onPointerDown: onPointerDownUnderlay\n }\n };\n}\n"],"names":[],"version":3,"file":"useOverlay.module.js.map"}