@react-aria/overlays 3.30.0 → 3.31.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.
@@ -36,28 +36,31 @@ const $edcf132a9284368a$var$TOTAL_SIZE = {
36
36
  height: 'totalHeight'
37
37
  };
38
38
  const $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE = {};
39
- let $edcf132a9284368a$var$visualViewport = typeof document !== 'undefined' ? window.visualViewport : null;
40
- function $edcf132a9284368a$var$getContainerDimensions(containerNode) {
39
+ let $edcf132a9284368a$var$getVisualViewport = ()=>typeof document !== 'undefined' ? window.visualViewport : null;
40
+ function $edcf132a9284368a$var$getContainerDimensions(containerNode, visualViewport) {
41
41
  let width = 0, height = 0, totalWidth = 0, totalHeight = 0, top = 0, left = 0;
42
42
  let scroll = {};
43
43
  var _visualViewport_scale;
44
- let isPinchZoomedIn = ((_visualViewport_scale = $edcf132a9284368a$var$visualViewport === null || $edcf132a9284368a$var$visualViewport === void 0 ? void 0 : $edcf132a9284368a$var$visualViewport.scale) !== null && _visualViewport_scale !== void 0 ? _visualViewport_scale : 1) > 1;
45
- if (containerNode.tagName === 'BODY') {
44
+ let isPinchZoomedIn = ((_visualViewport_scale = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.scale) !== null && _visualViewport_scale !== void 0 ? _visualViewport_scale : 1) > 1;
45
+ // In the case where the container is `html` or `body` and the container doesn't have something like `position: relative`,
46
+ // then position absolute will be positioned relative to the viewport, also known as the `initial containing block`.
47
+ // That's why we use the visual viewport instead.
48
+ if (containerNode.tagName === 'BODY' || containerNode.tagName === 'HTML') {
46
49
  let documentElement = document.documentElement;
47
50
  totalWidth = documentElement.clientWidth;
48
51
  totalHeight = documentElement.clientHeight;
49
52
  var _visualViewport_width;
50
- 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;
53
+ width = (_visualViewport_width = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.width) !== null && _visualViewport_width !== void 0 ? _visualViewport_width : totalWidth;
51
54
  var _visualViewport_height;
52
- 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;
55
+ height = (_visualViewport_height = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.height) !== null && _visualViewport_height !== void 0 ? _visualViewport_height : totalHeight;
53
56
  scroll.top = documentElement.scrollTop || containerNode.scrollTop;
54
57
  scroll.left = documentElement.scrollLeft || containerNode.scrollLeft;
55
58
  // The goal of the below is to get a top/left value that represents the top/left of the visual viewport with
56
59
  // respect to the layout viewport origin. This combined with the scrollTop/scrollLeft will allow us to calculate
57
60
  // coordinates/values with respect to the visual viewport or with respect to the layout viewport.
58
- if ($edcf132a9284368a$var$visualViewport) {
59
- top = $edcf132a9284368a$var$visualViewport.offsetTop;
60
- left = $edcf132a9284368a$var$visualViewport.offsetLeft;
61
+ if (visualViewport) {
62
+ top = visualViewport.offsetTop;
63
+ left = visualViewport.offsetLeft;
61
64
  }
62
65
  } else {
63
66
  ({ width: width, height: height, top: top, left: left } = $edcf132a9284368a$var$getOffset(containerNode, false));
@@ -74,9 +77,9 @@ function $edcf132a9284368a$var$getContainerDimensions(containerNode) {
74
77
  scroll.top = 0;
75
78
  scroll.left = 0;
76
79
  var _visualViewport_pageTop;
77
- top = (_visualViewport_pageTop = $edcf132a9284368a$var$visualViewport === null || $edcf132a9284368a$var$visualViewport === void 0 ? void 0 : $edcf132a9284368a$var$visualViewport.pageTop) !== null && _visualViewport_pageTop !== void 0 ? _visualViewport_pageTop : 0;
80
+ top = (_visualViewport_pageTop = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.pageTop) !== null && _visualViewport_pageTop !== void 0 ? _visualViewport_pageTop : 0;
78
81
  var _visualViewport_pageLeft;
79
- left = (_visualViewport_pageLeft = $edcf132a9284368a$var$visualViewport === null || $edcf132a9284368a$var$visualViewport === void 0 ? void 0 : $edcf132a9284368a$var$visualViewport.pageLeft) !== null && _visualViewport_pageLeft !== void 0 ? _visualViewport_pageLeft : 0;
82
+ left = (_visualViewport_pageLeft = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.pageLeft) !== null && _visualViewport_pageLeft !== void 0 ? _visualViewport_pageLeft : 0;
80
83
  }
81
84
  return {
82
85
  width: width,
@@ -111,10 +114,12 @@ containerDimensions, padding, containerOffsetWithBoundary) {
111
114
  let boundarySize = boundaryDimensions[$edcf132a9284368a$var$AXIS_SIZE[axis]];
112
115
  // Calculate the edges of the boundary (accomodating for the boundary padding) and the edges of the overlay.
113
116
  // Note that these values are with respect to the visual viewport (aka 0,0 is the top left of the viewport)
114
- let boundaryStartEdge = boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] + padding;
115
- let boundaryEndEdge = boundarySize + boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] - padding;
116
- let startEdgeOffset = offset - containerScroll + containerOffsetWithBoundary[axis] - boundaryDimensions[$edcf132a9284368a$var$AXIS[axis]];
117
- let endEdgeOffset = offset - containerScroll + size + containerOffsetWithBoundary[axis] - boundaryDimensions[$edcf132a9284368a$var$AXIS[axis]];
117
+ let boundaryStartEdge = containerOffsetWithBoundary[axis] + boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] + padding;
118
+ let boundaryEndEdge = containerOffsetWithBoundary[axis] + boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] + boundarySize - padding;
119
+ // transformed value of the left edge of the overlay
120
+ let startEdgeOffset = offset - containerScroll + boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] + containerOffsetWithBoundary[axis] - boundaryDimensions[$edcf132a9284368a$var$AXIS[axis]];
121
+ // transformed value of the right edge of the overlay
122
+ let endEdgeOffset = offset - containerScroll + size + boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] + containerOffsetWithBoundary[axis] - boundaryDimensions[$edcf132a9284368a$var$AXIS[axis]];
118
123
  // If any of the overlay edges falls outside of the boundary, shift the overlay the required amount to align one of the overlay's
119
124
  // edges with the closest boundary edge.
120
125
  if (startEdgeOffset < boundaryStartEdge) return boundaryStartEdge - startEdgeOffset;
@@ -148,7 +153,7 @@ function $edcf132a9284368a$var$parsePlacement(input) {
148
153
  };
149
154
  return $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input];
150
155
  }
151
- function $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset) {
156
+ function $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset, containerDimensions) {
152
157
  let { placement: placement, crossPlacement: crossPlacement, axis: axis, crossAxis: crossAxis, size: size, crossSize: crossSize } = placementInfo;
153
158
  let position = {};
154
159
  var _childOffset_crossAxis;
@@ -165,9 +170,9 @@ function $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions,
165
170
  the overlay top should match the button top
166
171
  } */
167
172
  position[crossAxis] += crossOffset;
168
- // overlay top overlapping arrow with button bottom
173
+ // overlay top or left overlapping arrow with button bottom or right
169
174
  const minPosition = childOffset[crossAxis] - overlaySize[crossSize] + arrowSize + arrowBoundaryOffset;
170
- // overlay bottom overlapping arrow with button top
175
+ // overlay bottom or right overlapping arrow with button top or left
171
176
  const maxPosition = childOffset[crossAxis] + childOffset[crossSize] - arrowSize - arrowBoundaryOffset;
172
177
  position[crossAxis] = (0, $fZVmS$clamp)(position[crossAxis], minPosition, maxPosition);
173
178
  // 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.
@@ -175,46 +180,61 @@ function $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions,
175
180
  // If the container is positioned (non-static), then we use the container's actual
176
181
  // height, as `bottom` will be relative to this height. But if the container is static,
177
182
  // then it can only be the `document.body`, and `bottom` will be relative to _its_
178
- // container, which should be as large as boundaryDimensions.
179
- const containerHeight = isContainerPositioned ? containerOffsetWithBoundary[size] : boundaryDimensions[$edcf132a9284368a$var$TOTAL_SIZE[size]];
183
+ // container.
184
+ let containerHeight = isContainerPositioned ? containerDimensions[size] : containerDimensions[$edcf132a9284368a$var$TOTAL_SIZE[size]];
180
185
  position[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] = Math.floor(containerHeight - childOffset[axis] + offset);
181
186
  } else position[axis] = Math.floor(childOffset[axis] + childOffset[size] + offset);
182
187
  return position;
183
188
  }
184
- function $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlayHeight, heightGrowthDirection) {
185
- const containerHeight = isContainerPositioned ? containerOffsetWithBoundary.height : boundaryDimensions[$edcf132a9284368a$var$TOTAL_SIZE.height];
186
- var _position_bottom;
187
- // 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
188
- // used in computePosition.
189
- let overlayTop = position.top != null ? containerOffsetWithBoundary.top + position.top : containerOffsetWithBoundary.top + (containerHeight - ((_position_bottom = position.bottom) !== null && _position_bottom !== void 0 ? _position_bottom : 0) - overlayHeight);
190
- var _boundaryDimensions_scroll_top, _margins_top, _margins_bottom, _boundaryDimensions_scroll_top1, _margins_top1, _margins_bottom1;
189
+ function $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlayHeight, heightGrowthDirection, containerDimensions, isContainerDescendentOfBoundary, visualViewport) {
190
+ var _position_bottom, _containerDimensions_scroll_top;
191
+ // For cases where position is set via "bottom" instead of "top", we need to calculate the true overlay top
192
+ // with respect to the container.
193
+ let overlayTop = (position.top != null ? position.top : containerDimensions[$edcf132a9284368a$var$TOTAL_SIZE.height] - ((_position_bottom = position.bottom) !== null && _position_bottom !== void 0 ? _position_bottom : 0) - overlayHeight) - ((_containerDimensions_scroll_top = containerDimensions.scroll.top) !== null && _containerDimensions_scroll_top !== void 0 ? _containerDimensions_scroll_top : 0);
194
+ // calculate the dimentions of the "boundingRect" which is most restrictive top/bottom of the boundaryRect and the visual view port
195
+ let boundaryToContainerTransformOffset = isContainerDescendentOfBoundary ? containerOffsetWithBoundary.top : 0;
196
+ var _visualViewport_offsetTop, _visualViewport_offsetTop1, _visualViewport_height;
197
+ let boundingRect = {
198
+ // This should be boundary top in container coord system vs viewport top in container coord system
199
+ // For the viewport top, there are several cases
200
+ // 1. pinchzoom case where we want the viewports offset top as top here
201
+ // 2. case where container is offset from the boundary and is contained by the boundary. In this case the top we want here is NOT 0, we want to take boundary's top even though is is a negative number OR the visual viewport, whichever is more restrictive
202
+ top: Math.max(boundaryDimensions.top + boundaryToContainerTransformOffset, ((_visualViewport_offsetTop = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.offsetTop) !== null && _visualViewport_offsetTop !== void 0 ? _visualViewport_offsetTop : boundaryDimensions.top) + boundaryToContainerTransformOffset),
203
+ bottom: Math.min(boundaryDimensions.top + boundaryDimensions.height + boundaryToContainerTransformOffset, ((_visualViewport_offsetTop1 = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.offsetTop) !== null && _visualViewport_offsetTop1 !== void 0 ? _visualViewport_offsetTop1 : 0) + ((_visualViewport_height = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.height) !== null && _visualViewport_height !== void 0 ? _visualViewport_height : 0))
204
+ };
205
+ var _margins_top, _margins_bottom, _margins_top1, _margins_bottom1;
191
206
  let maxHeight = heightGrowthDirection !== 'top' ? // We want the distance between the top of the overlay to the bottom of the boundary
192
- Math.max(0, boundaryDimensions.height + boundaryDimensions.top + ((_boundaryDimensions_scroll_top = boundaryDimensions.scroll.top) !== null && _boundaryDimensions_scroll_top !== void 0 ? _boundaryDimensions_scroll_top : 0) - overlayTop // this is the top of the overlay
207
+ Math.max(0, boundingRect.bottom // this is the bottom of the boundary
208
+ - overlayTop // this is the top of the overlay
193
209
  - (((_margins_top = margins.top) !== null && _margins_top !== void 0 ? _margins_top : 0) + ((_margins_bottom = margins.bottom) !== null && _margins_bottom !== void 0 ? _margins_bottom : 0) + padding // save additional space for margin and padding
194
210
  )) : Math.max(0, overlayTop + overlayHeight // this is the bottom of the overlay
195
- - (boundaryDimensions.top + ((_boundaryDimensions_scroll_top1 = boundaryDimensions.scroll.top) !== null && _boundaryDimensions_scroll_top1 !== void 0 ? _boundaryDimensions_scroll_top1 : 0) // this is the top of the boundary
196
- ) - (((_margins_top1 = margins.top) !== null && _margins_top1 !== void 0 ? _margins_top1 : 0) + ((_margins_bottom1 = margins.bottom) !== null && _margins_bottom1 !== void 0 ? _margins_bottom1 : 0) + padding // save additional space for margin and padding
211
+ - boundingRect.top // this is the top of the boundary
212
+ - (((_margins_top1 = margins.top) !== null && _margins_top1 !== void 0 ? _margins_top1 : 0) + ((_margins_bottom1 = margins.bottom) !== null && _margins_bottom1 !== void 0 ? _margins_bottom1 : 0) + padding // save additional space for margin and padding
197
213
  ));
198
- return Math.min(boundaryDimensions.height - padding * 2, maxHeight);
214
+ return maxHeight;
199
215
  }
200
- function $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding, placementInfo) {
216
+ function $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding, placementInfo, containerDimensions, isContainerDescendentOfBoundary) {
201
217
  let { placement: placement, axis: axis, size: size } = placementInfo;
202
- var _boundaryDimensions_scroll_axis, _margins_axis;
203
- if (placement === axis) return Math.max(0, childOffset[axis] - boundaryDimensions[axis] - ((_boundaryDimensions_scroll_axis = boundaryDimensions.scroll[axis]) !== null && _boundaryDimensions_scroll_axis !== void 0 ? _boundaryDimensions_scroll_axis : 0) + containerOffsetWithBoundary[axis] - ((_margins_axis = margins[axis]) !== null && _margins_axis !== void 0 ? _margins_axis : 0) - margins[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] - padding);
204
- var _margins_axis1;
205
- return Math.max(0, boundaryDimensions[size] + boundaryDimensions[axis] + boundaryDimensions.scroll[axis] - containerOffsetWithBoundary[axis] - childOffset[axis] - childOffset[size] - ((_margins_axis1 = margins[axis]) !== null && _margins_axis1 !== void 0 ? _margins_axis1 : 0) - margins[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] - padding);
218
+ var _containerDimensions_scroll_axis, _margins_axis;
219
+ if (placement === axis) return Math.max(0, childOffset[axis] // trigger start
220
+ - ((_containerDimensions_scroll_axis = containerDimensions.scroll[axis]) !== null && _containerDimensions_scroll_axis !== void 0 ? _containerDimensions_scroll_axis : 0 // transform trigger position to be with respect to viewport 0,0
221
+ ) - (boundaryDimensions[axis] + (isContainerDescendentOfBoundary ? containerOffsetWithBoundary[axis] : 0) // boundary start
222
+ ) - ((_margins_axis = margins[axis]) !== null && _margins_axis !== void 0 ? _margins_axis : 0 // margins usually for arrows or other decorations
223
+ ) - margins[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] - padding); // padding between overlay and boundary
224
+ var _containerDimensions_scroll_axis1, _margins_axis1;
225
+ return Math.max(0, boundaryDimensions[size] + boundaryDimensions[axis] + (isContainerDescendentOfBoundary ? containerOffsetWithBoundary[axis] : 0) - childOffset[axis] - childOffset[size] + ((_containerDimensions_scroll_axis1 = containerDimensions.scroll[axis]) !== null && _containerDimensions_scroll_axis1 !== void 0 ? _containerDimensions_scroll_axis1 : 0) - ((_margins_axis1 = margins[axis]) !== null && _margins_axis1 !== void 0 ? _margins_axis1 : 0) - margins[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] - padding);
206
226
  }
207
- function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset, overlaySize, scrollSize, margins, padding, flip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, userSetMaxHeight, arrowSize, arrowBoundaryOffset) {
227
+ function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset, overlaySize, scrollSize, margins, padding, flip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, userSetMaxHeight, arrowSize, arrowBoundaryOffset, isContainerDescendentOfBoundary, visualViewport) {
208
228
  let placementInfo = $edcf132a9284368a$var$parsePlacement(placementInput);
209
229
  let { size: size, crossAxis: crossAxis, crossSize: crossSize, placement: placement, crossPlacement: crossPlacement } = placementInfo;
210
- let position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
230
+ let position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset, containerDimensions);
211
231
  let normalizedOffset = offset;
212
- let space = $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, placementInfo);
232
+ let space = $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, placementInfo, containerDimensions, isContainerDescendentOfBoundary);
213
233
  // Check if the scroll size of the overlay is greater than the available space to determine if we need to flip
214
- if (flip && scrollSize[size] > space) {
234
+ if (flip && overlaySize[size] > space) {
215
235
  let flippedPlacementInfo = $edcf132a9284368a$var$parsePlacement(`${$edcf132a9284368a$var$FLIPPED_DIRECTION[placement]} ${crossPlacement}`);
216
- let flippedPosition = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, flippedPlacementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
217
- let flippedSpace = $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, flippedPlacementInfo);
236
+ let flippedPosition = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, flippedPlacementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset, containerDimensions);
237
+ let flippedSpace = $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, flippedPlacementInfo, containerDimensions, isContainerDescendentOfBoundary);
218
238
  // If the available space for the flipped position is greater than the original available space, flip.
219
239
  if (flippedSpace > space) {
220
240
  placementInfo = flippedPlacementInfo;
@@ -233,10 +253,10 @@ function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset,
233
253
  }
234
254
  let delta = $edcf132a9284368a$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);
235
255
  position[crossAxis] += delta;
236
- let maxHeight = $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlaySize.height, heightGrowthDirection);
256
+ let maxHeight = $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlaySize.height, heightGrowthDirection, containerDimensions, isContainerDescendentOfBoundary, visualViewport);
237
257
  if (userSetMaxHeight && userSetMaxHeight < maxHeight) maxHeight = userSetMaxHeight;
238
258
  overlaySize.height = Math.min(overlaySize.height, maxHeight);
239
- position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, normalizedOffset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
259
+ position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, normalizedOffset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset, containerDimensions);
240
260
  delta = $edcf132a9284368a$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);
241
261
  position[crossAxis] += delta;
242
262
  let arrowPosition = {};
@@ -282,6 +302,7 @@ function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset,
282
302
  }
283
303
  function $edcf132a9284368a$export$b3ceb0cbf1056d98(opts) {
284
304
  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;
305
+ let visualViewport = $edcf132a9284368a$var$getVisualViewport();
285
306
  let container = overlayNode instanceof HTMLElement ? $edcf132a9284368a$var$getContainingBlock(overlayNode) : document.documentElement;
286
307
  let isViewportContainer = container === document.documentElement;
287
308
  const containerPositionStyle = window.getComputedStyle(container).position;
@@ -299,21 +320,22 @@ function $edcf132a9284368a$export$b3ceb0cbf1056d98(opts) {
299
320
  var _margins_top, _margins_bottom;
300
321
  overlaySize.height += ((_margins_top = margins.top) !== null && _margins_top !== void 0 ? _margins_top : 0) + ((_margins_bottom = margins.bottom) !== null && _margins_bottom !== void 0 ? _margins_bottom : 0);
301
322
  let scrollSize = $edcf132a9284368a$var$getScroll(scrollNode);
302
- let boundaryDimensions = $edcf132a9284368a$var$getContainerDimensions(boundaryElement);
303
- let containerDimensions = $edcf132a9284368a$var$getContainerDimensions(container);
323
+ // Note that due to logic inside getContainerDimensions, for cases where the boundary element is the body, we will return
324
+ // a height/width that matches the visual viewport size rather than the body's height/width (aka for zoom it will be zoom adjusted size)
325
+ // and a top/left that is adjusted as well (will return the top/left of the zoomed in viewport, or 0,0 for a non-zoomed body)
326
+ // Otherwise this returns the height/width of a arbitrary boundary element, and its top/left with respect to the viewport (NOTE THIS MEANS IT DOESNT INCLUDE SCROLL)
327
+ let boundaryDimensions = $edcf132a9284368a$var$getContainerDimensions(boundaryElement, visualViewport);
328
+ let containerDimensions = $edcf132a9284368a$var$getContainerDimensions(container, visualViewport);
304
329
  // If the container is the HTML element wrapping the body element, the retrieved scrollTop/scrollLeft will be equal to the
305
330
  // 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
306
331
  // by the container scroll since they are essentially the same containing element and thus in the same coordinate system
307
- let containerOffsetWithBoundary = boundaryElement.tagName === 'BODY' ? $edcf132a9284368a$var$getOffset(container, false) : $edcf132a9284368a$var$getPosition(container, boundaryElement, false);
308
- if (container.tagName === 'HTML' && boundaryElement.tagName === 'BODY') {
309
- containerDimensions.scroll.top = 0;
310
- containerDimensions.scroll.left = 0;
311
- }
312
- return $edcf132a9284368a$export$6839422d1f33cee9(placement, childOffset, overlaySize, scrollSize, margins, padding, shouldFlip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, maxHeight, arrowSize, arrowBoundaryOffset);
332
+ let containerOffsetWithBoundary = $edcf132a9284368a$var$getPosition(boundaryElement, container, false);
333
+ let isContainerDescendentOfBoundary = boundaryElement.contains(container);
334
+ return $edcf132a9284368a$export$6839422d1f33cee9(placement, childOffset, overlaySize, scrollSize, margins, padding, shouldFlip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, maxHeight, arrowSize, arrowBoundaryOffset, isContainerDescendentOfBoundary, visualViewport);
313
335
  }
314
336
  function $edcf132a9284368a$export$4b834cebd9e5cebe(node, ignoreScale) {
315
337
  let { top: top, left: left, width: width, height: height } = node.getBoundingClientRect();
316
- // Use offsetWidth and offsetHeight if this is an HTML element, so that
338
+ // Use offsetWidth and offsetHeight if this is an HTML element, so that
317
339
  // the size is not affected by scale transforms.
318
340
  if (ignoreScale && node instanceof node.ownerDocument.defaultView.HTMLElement) {
319
341
  width = node.offsetWidth;
@@ -36,28 +36,31 @@ const $edcf132a9284368a$var$TOTAL_SIZE = {
36
36
  height: 'totalHeight'
37
37
  };
38
38
  const $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE = {};
39
- let $edcf132a9284368a$var$visualViewport = typeof document !== 'undefined' ? window.visualViewport : null;
40
- function $edcf132a9284368a$var$getContainerDimensions(containerNode) {
39
+ let $edcf132a9284368a$var$getVisualViewport = ()=>typeof document !== 'undefined' ? window.visualViewport : null;
40
+ function $edcf132a9284368a$var$getContainerDimensions(containerNode, visualViewport) {
41
41
  let width = 0, height = 0, totalWidth = 0, totalHeight = 0, top = 0, left = 0;
42
42
  let scroll = {};
43
43
  var _visualViewport_scale;
44
- let isPinchZoomedIn = ((_visualViewport_scale = $edcf132a9284368a$var$visualViewport === null || $edcf132a9284368a$var$visualViewport === void 0 ? void 0 : $edcf132a9284368a$var$visualViewport.scale) !== null && _visualViewport_scale !== void 0 ? _visualViewport_scale : 1) > 1;
45
- if (containerNode.tagName === 'BODY') {
44
+ let isPinchZoomedIn = ((_visualViewport_scale = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.scale) !== null && _visualViewport_scale !== void 0 ? _visualViewport_scale : 1) > 1;
45
+ // In the case where the container is `html` or `body` and the container doesn't have something like `position: relative`,
46
+ // then position absolute will be positioned relative to the viewport, also known as the `initial containing block`.
47
+ // That's why we use the visual viewport instead.
48
+ if (containerNode.tagName === 'BODY' || containerNode.tagName === 'HTML') {
46
49
  let documentElement = document.documentElement;
47
50
  totalWidth = documentElement.clientWidth;
48
51
  totalHeight = documentElement.clientHeight;
49
52
  var _visualViewport_width;
50
- 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;
53
+ width = (_visualViewport_width = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.width) !== null && _visualViewport_width !== void 0 ? _visualViewport_width : totalWidth;
51
54
  var _visualViewport_height;
52
- 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;
55
+ height = (_visualViewport_height = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.height) !== null && _visualViewport_height !== void 0 ? _visualViewport_height : totalHeight;
53
56
  scroll.top = documentElement.scrollTop || containerNode.scrollTop;
54
57
  scroll.left = documentElement.scrollLeft || containerNode.scrollLeft;
55
58
  // The goal of the below is to get a top/left value that represents the top/left of the visual viewport with
56
59
  // respect to the layout viewport origin. This combined with the scrollTop/scrollLeft will allow us to calculate
57
60
  // coordinates/values with respect to the visual viewport or with respect to the layout viewport.
58
- if ($edcf132a9284368a$var$visualViewport) {
59
- top = $edcf132a9284368a$var$visualViewport.offsetTop;
60
- left = $edcf132a9284368a$var$visualViewport.offsetLeft;
61
+ if (visualViewport) {
62
+ top = visualViewport.offsetTop;
63
+ left = visualViewport.offsetLeft;
61
64
  }
62
65
  } else {
63
66
  ({ width: width, height: height, top: top, left: left } = $edcf132a9284368a$var$getOffset(containerNode, false));
@@ -74,9 +77,9 @@ function $edcf132a9284368a$var$getContainerDimensions(containerNode) {
74
77
  scroll.top = 0;
75
78
  scroll.left = 0;
76
79
  var _visualViewport_pageTop;
77
- top = (_visualViewport_pageTop = $edcf132a9284368a$var$visualViewport === null || $edcf132a9284368a$var$visualViewport === void 0 ? void 0 : $edcf132a9284368a$var$visualViewport.pageTop) !== null && _visualViewport_pageTop !== void 0 ? _visualViewport_pageTop : 0;
80
+ top = (_visualViewport_pageTop = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.pageTop) !== null && _visualViewport_pageTop !== void 0 ? _visualViewport_pageTop : 0;
78
81
  var _visualViewport_pageLeft;
79
- left = (_visualViewport_pageLeft = $edcf132a9284368a$var$visualViewport === null || $edcf132a9284368a$var$visualViewport === void 0 ? void 0 : $edcf132a9284368a$var$visualViewport.pageLeft) !== null && _visualViewport_pageLeft !== void 0 ? _visualViewport_pageLeft : 0;
82
+ left = (_visualViewport_pageLeft = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.pageLeft) !== null && _visualViewport_pageLeft !== void 0 ? _visualViewport_pageLeft : 0;
80
83
  }
81
84
  return {
82
85
  width: width,
@@ -111,10 +114,12 @@ containerDimensions, padding, containerOffsetWithBoundary) {
111
114
  let boundarySize = boundaryDimensions[$edcf132a9284368a$var$AXIS_SIZE[axis]];
112
115
  // Calculate the edges of the boundary (accomodating for the boundary padding) and the edges of the overlay.
113
116
  // Note that these values are with respect to the visual viewport (aka 0,0 is the top left of the viewport)
114
- let boundaryStartEdge = boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] + padding;
115
- let boundaryEndEdge = boundarySize + boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] - padding;
116
- let startEdgeOffset = offset - containerScroll + containerOffsetWithBoundary[axis] - boundaryDimensions[$edcf132a9284368a$var$AXIS[axis]];
117
- let endEdgeOffset = offset - containerScroll + size + containerOffsetWithBoundary[axis] - boundaryDimensions[$edcf132a9284368a$var$AXIS[axis]];
117
+ let boundaryStartEdge = containerOffsetWithBoundary[axis] + boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] + padding;
118
+ let boundaryEndEdge = containerOffsetWithBoundary[axis] + boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] + boundarySize - padding;
119
+ // transformed value of the left edge of the overlay
120
+ let startEdgeOffset = offset - containerScroll + boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] + containerOffsetWithBoundary[axis] - boundaryDimensions[$edcf132a9284368a$var$AXIS[axis]];
121
+ // transformed value of the right edge of the overlay
122
+ let endEdgeOffset = offset - containerScroll + size + boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] + containerOffsetWithBoundary[axis] - boundaryDimensions[$edcf132a9284368a$var$AXIS[axis]];
118
123
  // If any of the overlay edges falls outside of the boundary, shift the overlay the required amount to align one of the overlay's
119
124
  // edges with the closest boundary edge.
120
125
  if (startEdgeOffset < boundaryStartEdge) return boundaryStartEdge - startEdgeOffset;
@@ -148,7 +153,7 @@ function $edcf132a9284368a$var$parsePlacement(input) {
148
153
  };
149
154
  return $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input];
150
155
  }
151
- function $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset) {
156
+ function $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset, containerDimensions) {
152
157
  let { placement: placement, crossPlacement: crossPlacement, axis: axis, crossAxis: crossAxis, size: size, crossSize: crossSize } = placementInfo;
153
158
  let position = {};
154
159
  var _childOffset_crossAxis;
@@ -165,9 +170,9 @@ function $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions,
165
170
  the overlay top should match the button top
166
171
  } */
167
172
  position[crossAxis] += crossOffset;
168
- // overlay top overlapping arrow with button bottom
173
+ // overlay top or left overlapping arrow with button bottom or right
169
174
  const minPosition = childOffset[crossAxis] - overlaySize[crossSize] + arrowSize + arrowBoundaryOffset;
170
- // overlay bottom overlapping arrow with button top
175
+ // overlay bottom or right overlapping arrow with button top or left
171
176
  const maxPosition = childOffset[crossAxis] + childOffset[crossSize] - arrowSize - arrowBoundaryOffset;
172
177
  position[crossAxis] = (0, $fZVmS$clamp)(position[crossAxis], minPosition, maxPosition);
173
178
  // 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.
@@ -175,46 +180,61 @@ function $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions,
175
180
  // If the container is positioned (non-static), then we use the container's actual
176
181
  // height, as `bottom` will be relative to this height. But if the container is static,
177
182
  // then it can only be the `document.body`, and `bottom` will be relative to _its_
178
- // container, which should be as large as boundaryDimensions.
179
- const containerHeight = isContainerPositioned ? containerOffsetWithBoundary[size] : boundaryDimensions[$edcf132a9284368a$var$TOTAL_SIZE[size]];
183
+ // container.
184
+ let containerHeight = isContainerPositioned ? containerDimensions[size] : containerDimensions[$edcf132a9284368a$var$TOTAL_SIZE[size]];
180
185
  position[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] = Math.floor(containerHeight - childOffset[axis] + offset);
181
186
  } else position[axis] = Math.floor(childOffset[axis] + childOffset[size] + offset);
182
187
  return position;
183
188
  }
184
- function $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlayHeight, heightGrowthDirection) {
185
- const containerHeight = isContainerPositioned ? containerOffsetWithBoundary.height : boundaryDimensions[$edcf132a9284368a$var$TOTAL_SIZE.height];
186
- var _position_bottom;
187
- // 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
188
- // used in computePosition.
189
- let overlayTop = position.top != null ? containerOffsetWithBoundary.top + position.top : containerOffsetWithBoundary.top + (containerHeight - ((_position_bottom = position.bottom) !== null && _position_bottom !== void 0 ? _position_bottom : 0) - overlayHeight);
190
- var _boundaryDimensions_scroll_top, _margins_top, _margins_bottom, _boundaryDimensions_scroll_top1, _margins_top1, _margins_bottom1;
189
+ function $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlayHeight, heightGrowthDirection, containerDimensions, isContainerDescendentOfBoundary, visualViewport) {
190
+ var _position_bottom, _containerDimensions_scroll_top;
191
+ // For cases where position is set via "bottom" instead of "top", we need to calculate the true overlay top
192
+ // with respect to the container.
193
+ let overlayTop = (position.top != null ? position.top : containerDimensions[$edcf132a9284368a$var$TOTAL_SIZE.height] - ((_position_bottom = position.bottom) !== null && _position_bottom !== void 0 ? _position_bottom : 0) - overlayHeight) - ((_containerDimensions_scroll_top = containerDimensions.scroll.top) !== null && _containerDimensions_scroll_top !== void 0 ? _containerDimensions_scroll_top : 0);
194
+ // calculate the dimentions of the "boundingRect" which is most restrictive top/bottom of the boundaryRect and the visual view port
195
+ let boundaryToContainerTransformOffset = isContainerDescendentOfBoundary ? containerOffsetWithBoundary.top : 0;
196
+ var _visualViewport_offsetTop, _visualViewport_offsetTop1, _visualViewport_height;
197
+ let boundingRect = {
198
+ // This should be boundary top in container coord system vs viewport top in container coord system
199
+ // For the viewport top, there are several cases
200
+ // 1. pinchzoom case where we want the viewports offset top as top here
201
+ // 2. case where container is offset from the boundary and is contained by the boundary. In this case the top we want here is NOT 0, we want to take boundary's top even though is is a negative number OR the visual viewport, whichever is more restrictive
202
+ top: Math.max(boundaryDimensions.top + boundaryToContainerTransformOffset, ((_visualViewport_offsetTop = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.offsetTop) !== null && _visualViewport_offsetTop !== void 0 ? _visualViewport_offsetTop : boundaryDimensions.top) + boundaryToContainerTransformOffset),
203
+ bottom: Math.min(boundaryDimensions.top + boundaryDimensions.height + boundaryToContainerTransformOffset, ((_visualViewport_offsetTop1 = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.offsetTop) !== null && _visualViewport_offsetTop1 !== void 0 ? _visualViewport_offsetTop1 : 0) + ((_visualViewport_height = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.height) !== null && _visualViewport_height !== void 0 ? _visualViewport_height : 0))
204
+ };
205
+ var _margins_top, _margins_bottom, _margins_top1, _margins_bottom1;
191
206
  let maxHeight = heightGrowthDirection !== 'top' ? // We want the distance between the top of the overlay to the bottom of the boundary
192
- Math.max(0, boundaryDimensions.height + boundaryDimensions.top + ((_boundaryDimensions_scroll_top = boundaryDimensions.scroll.top) !== null && _boundaryDimensions_scroll_top !== void 0 ? _boundaryDimensions_scroll_top : 0) - overlayTop // this is the top of the overlay
207
+ Math.max(0, boundingRect.bottom // this is the bottom of the boundary
208
+ - overlayTop // this is the top of the overlay
193
209
  - (((_margins_top = margins.top) !== null && _margins_top !== void 0 ? _margins_top : 0) + ((_margins_bottom = margins.bottom) !== null && _margins_bottom !== void 0 ? _margins_bottom : 0) + padding // save additional space for margin and padding
194
210
  )) : Math.max(0, overlayTop + overlayHeight // this is the bottom of the overlay
195
- - (boundaryDimensions.top + ((_boundaryDimensions_scroll_top1 = boundaryDimensions.scroll.top) !== null && _boundaryDimensions_scroll_top1 !== void 0 ? _boundaryDimensions_scroll_top1 : 0) // this is the top of the boundary
196
- ) - (((_margins_top1 = margins.top) !== null && _margins_top1 !== void 0 ? _margins_top1 : 0) + ((_margins_bottom1 = margins.bottom) !== null && _margins_bottom1 !== void 0 ? _margins_bottom1 : 0) + padding // save additional space for margin and padding
211
+ - boundingRect.top // this is the top of the boundary
212
+ - (((_margins_top1 = margins.top) !== null && _margins_top1 !== void 0 ? _margins_top1 : 0) + ((_margins_bottom1 = margins.bottom) !== null && _margins_bottom1 !== void 0 ? _margins_bottom1 : 0) + padding // save additional space for margin and padding
197
213
  ));
198
- return Math.min(boundaryDimensions.height - padding * 2, maxHeight);
214
+ return maxHeight;
199
215
  }
200
- function $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding, placementInfo) {
216
+ function $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding, placementInfo, containerDimensions, isContainerDescendentOfBoundary) {
201
217
  let { placement: placement, axis: axis, size: size } = placementInfo;
202
- var _boundaryDimensions_scroll_axis, _margins_axis;
203
- if (placement === axis) return Math.max(0, childOffset[axis] - boundaryDimensions[axis] - ((_boundaryDimensions_scroll_axis = boundaryDimensions.scroll[axis]) !== null && _boundaryDimensions_scroll_axis !== void 0 ? _boundaryDimensions_scroll_axis : 0) + containerOffsetWithBoundary[axis] - ((_margins_axis = margins[axis]) !== null && _margins_axis !== void 0 ? _margins_axis : 0) - margins[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] - padding);
204
- var _margins_axis1;
205
- return Math.max(0, boundaryDimensions[size] + boundaryDimensions[axis] + boundaryDimensions.scroll[axis] - containerOffsetWithBoundary[axis] - childOffset[axis] - childOffset[size] - ((_margins_axis1 = margins[axis]) !== null && _margins_axis1 !== void 0 ? _margins_axis1 : 0) - margins[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] - padding);
218
+ var _containerDimensions_scroll_axis, _margins_axis;
219
+ if (placement === axis) return Math.max(0, childOffset[axis] // trigger start
220
+ - ((_containerDimensions_scroll_axis = containerDimensions.scroll[axis]) !== null && _containerDimensions_scroll_axis !== void 0 ? _containerDimensions_scroll_axis : 0 // transform trigger position to be with respect to viewport 0,0
221
+ ) - (boundaryDimensions[axis] + (isContainerDescendentOfBoundary ? containerOffsetWithBoundary[axis] : 0) // boundary start
222
+ ) - ((_margins_axis = margins[axis]) !== null && _margins_axis !== void 0 ? _margins_axis : 0 // margins usually for arrows or other decorations
223
+ ) - margins[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] - padding); // padding between overlay and boundary
224
+ var _containerDimensions_scroll_axis1, _margins_axis1;
225
+ return Math.max(0, boundaryDimensions[size] + boundaryDimensions[axis] + (isContainerDescendentOfBoundary ? containerOffsetWithBoundary[axis] : 0) - childOffset[axis] - childOffset[size] + ((_containerDimensions_scroll_axis1 = containerDimensions.scroll[axis]) !== null && _containerDimensions_scroll_axis1 !== void 0 ? _containerDimensions_scroll_axis1 : 0) - ((_margins_axis1 = margins[axis]) !== null && _margins_axis1 !== void 0 ? _margins_axis1 : 0) - margins[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] - padding);
206
226
  }
207
- function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset, overlaySize, scrollSize, margins, padding, flip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, userSetMaxHeight, arrowSize, arrowBoundaryOffset) {
227
+ function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset, overlaySize, scrollSize, margins, padding, flip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, userSetMaxHeight, arrowSize, arrowBoundaryOffset, isContainerDescendentOfBoundary, visualViewport) {
208
228
  let placementInfo = $edcf132a9284368a$var$parsePlacement(placementInput);
209
229
  let { size: size, crossAxis: crossAxis, crossSize: crossSize, placement: placement, crossPlacement: crossPlacement } = placementInfo;
210
- let position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
230
+ let position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset, containerDimensions);
211
231
  let normalizedOffset = offset;
212
- let space = $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, placementInfo);
232
+ let space = $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, placementInfo, containerDimensions, isContainerDescendentOfBoundary);
213
233
  // Check if the scroll size of the overlay is greater than the available space to determine if we need to flip
214
- if (flip && scrollSize[size] > space) {
234
+ if (flip && overlaySize[size] > space) {
215
235
  let flippedPlacementInfo = $edcf132a9284368a$var$parsePlacement(`${$edcf132a9284368a$var$FLIPPED_DIRECTION[placement]} ${crossPlacement}`);
216
- let flippedPosition = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, flippedPlacementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
217
- let flippedSpace = $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, flippedPlacementInfo);
236
+ let flippedPosition = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, flippedPlacementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset, containerDimensions);
237
+ let flippedSpace = $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, flippedPlacementInfo, containerDimensions, isContainerDescendentOfBoundary);
218
238
  // If the available space for the flipped position is greater than the original available space, flip.
219
239
  if (flippedSpace > space) {
220
240
  placementInfo = flippedPlacementInfo;
@@ -233,10 +253,10 @@ function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset,
233
253
  }
234
254
  let delta = $edcf132a9284368a$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);
235
255
  position[crossAxis] += delta;
236
- let maxHeight = $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlaySize.height, heightGrowthDirection);
256
+ let maxHeight = $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlaySize.height, heightGrowthDirection, containerDimensions, isContainerDescendentOfBoundary, visualViewport);
237
257
  if (userSetMaxHeight && userSetMaxHeight < maxHeight) maxHeight = userSetMaxHeight;
238
258
  overlaySize.height = Math.min(overlaySize.height, maxHeight);
239
- position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, normalizedOffset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
259
+ position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, normalizedOffset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset, containerDimensions);
240
260
  delta = $edcf132a9284368a$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);
241
261
  position[crossAxis] += delta;
242
262
  let arrowPosition = {};
@@ -282,6 +302,7 @@ function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset,
282
302
  }
283
303
  function $edcf132a9284368a$export$b3ceb0cbf1056d98(opts) {
284
304
  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;
305
+ let visualViewport = $edcf132a9284368a$var$getVisualViewport();
285
306
  let container = overlayNode instanceof HTMLElement ? $edcf132a9284368a$var$getContainingBlock(overlayNode) : document.documentElement;
286
307
  let isViewportContainer = container === document.documentElement;
287
308
  const containerPositionStyle = window.getComputedStyle(container).position;
@@ -299,21 +320,22 @@ function $edcf132a9284368a$export$b3ceb0cbf1056d98(opts) {
299
320
  var _margins_top, _margins_bottom;
300
321
  overlaySize.height += ((_margins_top = margins.top) !== null && _margins_top !== void 0 ? _margins_top : 0) + ((_margins_bottom = margins.bottom) !== null && _margins_bottom !== void 0 ? _margins_bottom : 0);
301
322
  let scrollSize = $edcf132a9284368a$var$getScroll(scrollNode);
302
- let boundaryDimensions = $edcf132a9284368a$var$getContainerDimensions(boundaryElement);
303
- let containerDimensions = $edcf132a9284368a$var$getContainerDimensions(container);
323
+ // Note that due to logic inside getContainerDimensions, for cases where the boundary element is the body, we will return
324
+ // a height/width that matches the visual viewport size rather than the body's height/width (aka for zoom it will be zoom adjusted size)
325
+ // and a top/left that is adjusted as well (will return the top/left of the zoomed in viewport, or 0,0 for a non-zoomed body)
326
+ // Otherwise this returns the height/width of a arbitrary boundary element, and its top/left with respect to the viewport (NOTE THIS MEANS IT DOESNT INCLUDE SCROLL)
327
+ let boundaryDimensions = $edcf132a9284368a$var$getContainerDimensions(boundaryElement, visualViewport);
328
+ let containerDimensions = $edcf132a9284368a$var$getContainerDimensions(container, visualViewport);
304
329
  // If the container is the HTML element wrapping the body element, the retrieved scrollTop/scrollLeft will be equal to the
305
330
  // 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
306
331
  // by the container scroll since they are essentially the same containing element and thus in the same coordinate system
307
- let containerOffsetWithBoundary = boundaryElement.tagName === 'BODY' ? $edcf132a9284368a$var$getOffset(container, false) : $edcf132a9284368a$var$getPosition(container, boundaryElement, false);
308
- if (container.tagName === 'HTML' && boundaryElement.tagName === 'BODY') {
309
- containerDimensions.scroll.top = 0;
310
- containerDimensions.scroll.left = 0;
311
- }
312
- return $edcf132a9284368a$export$6839422d1f33cee9(placement, childOffset, overlaySize, scrollSize, margins, padding, shouldFlip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, maxHeight, arrowSize, arrowBoundaryOffset);
332
+ let containerOffsetWithBoundary = $edcf132a9284368a$var$getPosition(boundaryElement, container, false);
333
+ let isContainerDescendentOfBoundary = boundaryElement.contains(container);
334
+ return $edcf132a9284368a$export$6839422d1f33cee9(placement, childOffset, overlaySize, scrollSize, margins, padding, shouldFlip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, maxHeight, arrowSize, arrowBoundaryOffset, isContainerDescendentOfBoundary, visualViewport);
313
335
  }
314
336
  function $edcf132a9284368a$export$4b834cebd9e5cebe(node, ignoreScale) {
315
337
  let { top: top, left: left, width: width, height: height } = node.getBoundingClientRect();
316
- // Use offsetWidth and offsetHeight if this is an HTML element, so that
338
+ // Use offsetWidth and offsetHeight if this is an HTML element, so that
317
339
  // the size is not affected by scale transforms.
318
340
  if (ignoreScale && node instanceof node.ownerDocument.defaultView.HTMLElement) {
319
341
  width = node.offsetWidth;