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