@react-aria/overlays 3.22.0 → 3.23.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 (90) hide show
  1. package/dist/DismissButton.main.js +2 -2
  2. package/dist/DismissButton.mjs +3 -3
  3. package/dist/DismissButton.module.js +2 -2
  4. package/dist/Overlay.mjs +1 -1
  5. package/dist/PortalProvider.mjs +1 -1
  6. package/dist/ar-AE.mjs +1 -1
  7. package/dist/ariaHideOutside.main.js +7 -7
  8. package/dist/ariaHideOutside.mjs +8 -8
  9. package/dist/ariaHideOutside.module.js +7 -7
  10. package/dist/bg-BG.mjs +1 -1
  11. package/dist/calculatePosition.main.js +40 -40
  12. package/dist/calculatePosition.main.js.map +1 -1
  13. package/dist/calculatePosition.mjs +41 -41
  14. package/dist/calculatePosition.module.js +40 -40
  15. package/dist/calculatePosition.module.js.map +1 -1
  16. package/dist/cs-CZ.mjs +1 -1
  17. package/dist/da-DK.mjs +1 -1
  18. package/dist/de-DE.mjs +1 -1
  19. package/dist/el-GR.mjs +1 -1
  20. package/dist/en-US.mjs +1 -1
  21. package/dist/es-ES.mjs +1 -1
  22. package/dist/et-EE.mjs +1 -1
  23. package/dist/fi-FI.mjs +1 -1
  24. package/dist/fr-FR.mjs +1 -1
  25. package/dist/he-IL.mjs +1 -1
  26. package/dist/hr-HR.mjs +1 -1
  27. package/dist/hu-HU.mjs +1 -1
  28. package/dist/intlStrings.mjs +1 -1
  29. package/dist/it-IT.mjs +1 -1
  30. package/dist/ja-JP.mjs +1 -1
  31. package/dist/ko-KR.mjs +1 -1
  32. package/dist/lt-LT.mjs +1 -1
  33. package/dist/lv-LV.mjs +1 -1
  34. package/dist/nb-NO.mjs +1 -1
  35. package/dist/nl-NL.mjs +1 -1
  36. package/dist/pl-PL.mjs +1 -1
  37. package/dist/pt-BR.mjs +1 -1
  38. package/dist/pt-PT.mjs +1 -1
  39. package/dist/ro-RO.mjs +1 -1
  40. package/dist/ru-RU.mjs +1 -1
  41. package/dist/sk-SK.mjs +1 -1
  42. package/dist/sl-SI.mjs +1 -1
  43. package/dist/sr-SP.mjs +1 -1
  44. package/dist/sv-SE.mjs +1 -1
  45. package/dist/tr-TR.mjs +1 -1
  46. package/dist/types.d.ts +10 -10
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/uk-UA.mjs +1 -1
  49. package/dist/useCloseOnScroll.main.js +6 -2
  50. package/dist/useCloseOnScroll.main.js.map +1 -1
  51. package/dist/useCloseOnScroll.mjs +7 -3
  52. package/dist/useCloseOnScroll.module.js +6 -2
  53. package/dist/useCloseOnScroll.module.js.map +1 -1
  54. package/dist/useModal.main.js +4 -4
  55. package/dist/useModal.mjs +5 -5
  56. package/dist/useModal.module.js +4 -4
  57. package/dist/useModalOverlay.main.js.map +1 -1
  58. package/dist/useModalOverlay.mjs +1 -1
  59. package/dist/useModalOverlay.module.js.map +1 -1
  60. package/dist/useOverlay.main.js +1 -1
  61. package/dist/useOverlay.main.js.map +1 -1
  62. package/dist/useOverlay.mjs +2 -2
  63. package/dist/useOverlay.module.js +1 -1
  64. package/dist/useOverlay.module.js.map +1 -1
  65. package/dist/useOverlayPosition.main.js +62 -19
  66. package/dist/useOverlayPosition.main.js.map +1 -1
  67. package/dist/useOverlayPosition.mjs +63 -20
  68. package/dist/useOverlayPosition.module.js +62 -19
  69. package/dist/useOverlayPosition.module.js.map +1 -1
  70. package/dist/useOverlayTrigger.main.js +5 -5
  71. package/dist/useOverlayTrigger.main.js.map +1 -1
  72. package/dist/useOverlayTrigger.mjs +6 -6
  73. package/dist/useOverlayTrigger.module.js +5 -5
  74. package/dist/useOverlayTrigger.module.js.map +1 -1
  75. package/dist/usePopover.main.js.map +1 -1
  76. package/dist/usePopover.mjs +1 -1
  77. package/dist/usePopover.module.js.map +1 -1
  78. package/dist/usePreventScroll.main.js +22 -22
  79. package/dist/usePreventScroll.mjs +23 -23
  80. package/dist/usePreventScroll.module.js +22 -22
  81. package/dist/zh-CN.mjs +1 -1
  82. package/dist/zh-TW.mjs +1 -1
  83. package/package.json +14 -14
  84. package/src/calculatePosition.ts +3 -3
  85. package/src/useCloseOnScroll.ts +10 -2
  86. package/src/useModalOverlay.ts +3 -3
  87. package/src/useOverlay.ts +4 -4
  88. package/src/useOverlayPosition.ts +58 -11
  89. package/src/useOverlayTrigger.ts +3 -3
  90. package/src/usePopover.ts +3 -4
@@ -31,8 +31,8 @@ $parcel$export(module.exports, "DismissButton", () => $f69bb3e6457495cc$export$2
31
31
 
32
32
  function $f69bb3e6457495cc$export$2317d149ed6f78c4(props) {
33
33
  let { onDismiss: onDismiss, ...otherProps } = props;
34
- let stringFormatter = (0, $21EvL$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($90f032faf016e1fb$exports))), "@react-aria/overlays");
35
- let labels = (0, $21EvL$reactariautils.useLabels)(otherProps, stringFormatter.format("dismiss"));
34
+ let stringFormatter = (0, $21EvL$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($90f032faf016e1fb$exports))), '@react-aria/overlays');
35
+ let labels = (0, $21EvL$reactariautils.useLabels)(otherProps, stringFormatter.format('dismiss'));
36
36
  let onClick = ()=>{
37
37
  if (onDismiss) onDismiss();
38
38
  };
@@ -25,8 +25,8 @@ function $parcel$interopDefault(a) {
25
25
 
26
26
  function $86ea4cb521eb2e37$export$2317d149ed6f78c4(props) {
27
27
  let { onDismiss: onDismiss, ...otherProps } = props;
28
- let stringFormatter = (0, $iYaQO$useLocalizedStringFormatter)((0, ($parcel$interopDefault($iYaQO$intlStringsmodulejs))), "@react-aria/overlays");
29
- let labels = (0, $iYaQO$useLabels)(otherProps, stringFormatter.format("dismiss"));
28
+ let stringFormatter = (0, $iYaQO$useLocalizedStringFormatter)((0, ($parcel$interopDefault($iYaQO$intlStringsmodulejs))), '@react-aria/overlays');
29
+ let labels = (0, $iYaQO$useLabels)(otherProps, stringFormatter.format('dismiss'));
30
30
  let onClick = ()=>{
31
31
  if (onDismiss) onDismiss();
32
32
  };
@@ -43,4 +43,4 @@ function $86ea4cb521eb2e37$export$2317d149ed6f78c4(props) {
43
43
 
44
44
 
45
45
  export {$86ea4cb521eb2e37$export$2317d149ed6f78c4 as DismissButton};
46
- //# sourceMappingURL=DismissButton.mjs.map
46
+ //# sourceMappingURL=DismissButton.module.js.map
@@ -25,8 +25,8 @@ function $parcel$interopDefault(a) {
25
25
 
26
26
  function $86ea4cb521eb2e37$export$2317d149ed6f78c4(props) {
27
27
  let { onDismiss: onDismiss, ...otherProps } = props;
28
- let stringFormatter = (0, $iYaQO$useLocalizedStringFormatter)((0, ($parcel$interopDefault($iYaQO$intlStringsmodulejs))), "@react-aria/overlays");
29
- let labels = (0, $iYaQO$useLabels)(otherProps, stringFormatter.format("dismiss"));
28
+ let stringFormatter = (0, $iYaQO$useLocalizedStringFormatter)((0, ($parcel$interopDefault($iYaQO$intlStringsmodulejs))), '@react-aria/overlays');
29
+ let labels = (0, $iYaQO$useLabels)(otherProps, stringFormatter.format('dismiss'));
30
30
  let onClick = ()=>{
31
31
  if (onDismiss) onDismiss();
32
32
  };
package/dist/Overlay.mjs CHANGED
@@ -60,4 +60,4 @@ function $337b884510726a0d$export$14c98a7594375490() {
60
60
 
61
61
 
62
62
  export {$337b884510726a0d$export$a2200b96afd16271 as OverlayContext, $337b884510726a0d$export$c6fdb837b070b4ff as Overlay, $337b884510726a0d$export$14c98a7594375490 as useOverlayFocusContain};
63
- //# sourceMappingURL=Overlay.mjs.map
63
+ //# sourceMappingURL=Overlay.module.js.map
@@ -28,4 +28,4 @@ function $96b38030c423d352$export$574e9b0fb070c3b0() {
28
28
 
29
29
 
30
30
  export {$96b38030c423d352$export$60d741e20e0aa309 as PortalContext, $96b38030c423d352$export$db995ea7163b4b67 as UNSTABLE_PortalProvider, $96b38030c423d352$export$574e9b0fb070c3b0 as useUNSTABLE_PortalContext};
31
- //# sourceMappingURL=PortalProvider.mjs.map
31
+ //# sourceMappingURL=PortalProvider.module.js.map
package/dist/ar-AE.mjs CHANGED
@@ -5,4 +5,4 @@ $773d5888b972f1cf$exports = {
5
5
 
6
6
 
7
7
  export {$773d5888b972f1cf$exports as default};
8
- //# sourceMappingURL=ar-AE.mjs.map
8
+ //# sourceMappingURL=ar-AE.module.js.map
@@ -23,13 +23,13 @@ function $08ef1685902b6011$export$1c3ebcada18427bf(targets, root = document.body
23
23
  let hiddenNodes = new Set();
24
24
  let walk = (root)=>{
25
25
  // Keep live announcer and top layer elements (e.g. toasts) visible.
26
- for (let element of root.querySelectorAll("[data-live-announcer], [data-react-aria-top-layer]"))visibleNodes.add(element);
26
+ for (let element of root.querySelectorAll('[data-live-announcer], [data-react-aria-top-layer]'))visibleNodes.add(element);
27
27
  let acceptNode = (node)=>{
28
28
  // Skip this node and its children if it is one of the target nodes, or a live announcer.
29
29
  // Also skip children of already hidden nodes, as aria-hidden is recursive. An exception is
30
30
  // made for elements with role="row" since VoiceOver on iOS has issues hiding elements with role="row".
31
31
  // For that case we want to hide the cells inside as well (https://bugs.webkit.org/show_bug.cgi?id=222623).
32
- if (visibleNodes.has(node) || hiddenNodes.has(node.parentElement) && node.parentElement.getAttribute("role") !== "row") return NodeFilter.FILTER_REJECT;
32
+ if (visibleNodes.has(node) || hiddenNodes.has(node.parentElement) && node.parentElement.getAttribute('role') !== 'row') return NodeFilter.FILTER_REJECT;
33
33
  // Skip this node but continue to children if one of the targets is inside the node.
34
34
  for (let target of visibleNodes){
35
35
  if (node.contains(target)) return NodeFilter.FILTER_SKIP;
@@ -55,8 +55,8 @@ function $08ef1685902b6011$export$1c3ebcada18427bf(targets, root = document.body
55
55
  let refCount = (_refCountMap_get = $08ef1685902b6011$var$refCountMap.get(node)) !== null && _refCountMap_get !== void 0 ? _refCountMap_get : 0;
56
56
  // If already aria-hidden, and the ref count is zero, then this element
57
57
  // was already hidden and there's nothing for us to do.
58
- if (node.getAttribute("aria-hidden") === "true" && refCount === 0) return;
59
- if (refCount === 0) node.setAttribute("aria-hidden", "true");
58
+ if (node.getAttribute('aria-hidden') === 'true' && refCount === 0) return;
59
+ if (refCount === 0) node.setAttribute('aria-hidden', 'true');
60
60
  hiddenNodes.add(node);
61
61
  $08ef1685902b6011$var$refCountMap.set(node, refCount + 1);
62
62
  };
@@ -66,7 +66,7 @@ function $08ef1685902b6011$export$1c3ebcada18427bf(targets, root = document.body
66
66
  walk(root);
67
67
  let observer = new MutationObserver((changes)=>{
68
68
  for (let change of changes){
69
- if (change.type !== "childList" || change.addedNodes.length === 0) continue;
69
+ if (change.type !== 'childList' || change.addedNodes.length === 0) continue;
70
70
  // If the parent element of the added nodes is not within one of the targets,
71
71
  // and not already inside a hidden node, hide all of the new children.
72
72
  if (![
@@ -78,7 +78,7 @@ function $08ef1685902b6011$export$1c3ebcada18427bf(targets, root = document.body
78
78
  hiddenNodes.delete(node);
79
79
  }
80
80
  for (let node of change.addedNodes){
81
- if ((node instanceof HTMLElement || node instanceof SVGElement) && (node.dataset.liveAnnouncer === "true" || node.dataset.reactAriaTopLayer === "true")) visibleNodes.add(node);
81
+ if ((node instanceof HTMLElement || node instanceof SVGElement) && (node.dataset.liveAnnouncer === 'true' || node.dataset.reactAriaTopLayer === 'true')) visibleNodes.add(node);
82
82
  else if (node instanceof Element) walk(node);
83
83
  }
84
84
  }
@@ -105,7 +105,7 @@ function $08ef1685902b6011$export$1c3ebcada18427bf(targets, root = document.body
105
105
  for (let node of hiddenNodes){
106
106
  let count = $08ef1685902b6011$var$refCountMap.get(node);
107
107
  if (count === 1) {
108
- node.removeAttribute("aria-hidden");
108
+ node.removeAttribute('aria-hidden');
109
109
  $08ef1685902b6011$var$refCountMap.delete(node);
110
110
  } else $08ef1685902b6011$var$refCountMap.set(node, count - 1);
111
111
  }
@@ -17,13 +17,13 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
17
17
  let hiddenNodes = new Set();
18
18
  let walk = (root)=>{
19
19
  // Keep live announcer and top layer elements (e.g. toasts) visible.
20
- for (let element of root.querySelectorAll("[data-live-announcer], [data-react-aria-top-layer]"))visibleNodes.add(element);
20
+ for (let element of root.querySelectorAll('[data-live-announcer], [data-react-aria-top-layer]'))visibleNodes.add(element);
21
21
  let acceptNode = (node)=>{
22
22
  // Skip this node and its children if it is one of the target nodes, or a live announcer.
23
23
  // Also skip children of already hidden nodes, as aria-hidden is recursive. An exception is
24
24
  // made for elements with role="row" since VoiceOver on iOS has issues hiding elements with role="row".
25
25
  // For that case we want to hide the cells inside as well (https://bugs.webkit.org/show_bug.cgi?id=222623).
26
- if (visibleNodes.has(node) || hiddenNodes.has(node.parentElement) && node.parentElement.getAttribute("role") !== "row") return NodeFilter.FILTER_REJECT;
26
+ if (visibleNodes.has(node) || hiddenNodes.has(node.parentElement) && node.parentElement.getAttribute('role') !== 'row') return NodeFilter.FILTER_REJECT;
27
27
  // Skip this node but continue to children if one of the targets is inside the node.
28
28
  for (let target of visibleNodes){
29
29
  if (node.contains(target)) return NodeFilter.FILTER_SKIP;
@@ -49,8 +49,8 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
49
49
  let refCount = (_refCountMap_get = $5e3802645cc19319$var$refCountMap.get(node)) !== null && _refCountMap_get !== void 0 ? _refCountMap_get : 0;
50
50
  // If already aria-hidden, and the ref count is zero, then this element
51
51
  // was already hidden and there's nothing for us to do.
52
- if (node.getAttribute("aria-hidden") === "true" && refCount === 0) return;
53
- if (refCount === 0) node.setAttribute("aria-hidden", "true");
52
+ if (node.getAttribute('aria-hidden') === 'true' && refCount === 0) return;
53
+ if (refCount === 0) node.setAttribute('aria-hidden', 'true');
54
54
  hiddenNodes.add(node);
55
55
  $5e3802645cc19319$var$refCountMap.set(node, refCount + 1);
56
56
  };
@@ -60,7 +60,7 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
60
60
  walk(root);
61
61
  let observer = new MutationObserver((changes)=>{
62
62
  for (let change of changes){
63
- if (change.type !== "childList" || change.addedNodes.length === 0) continue;
63
+ if (change.type !== 'childList' || change.addedNodes.length === 0) continue;
64
64
  // If the parent element of the added nodes is not within one of the targets,
65
65
  // and not already inside a hidden node, hide all of the new children.
66
66
  if (![
@@ -72,7 +72,7 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
72
72
  hiddenNodes.delete(node);
73
73
  }
74
74
  for (let node of change.addedNodes){
75
- if ((node instanceof HTMLElement || node instanceof SVGElement) && (node.dataset.liveAnnouncer === "true" || node.dataset.reactAriaTopLayer === "true")) visibleNodes.add(node);
75
+ if ((node instanceof HTMLElement || node instanceof SVGElement) && (node.dataset.liveAnnouncer === 'true' || node.dataset.reactAriaTopLayer === 'true')) visibleNodes.add(node);
76
76
  else if (node instanceof Element) walk(node);
77
77
  }
78
78
  }
@@ -99,7 +99,7 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
99
99
  for (let node of hiddenNodes){
100
100
  let count = $5e3802645cc19319$var$refCountMap.get(node);
101
101
  if (count === 1) {
102
- node.removeAttribute("aria-hidden");
102
+ node.removeAttribute('aria-hidden');
103
103
  $5e3802645cc19319$var$refCountMap.delete(node);
104
104
  } else $5e3802645cc19319$var$refCountMap.set(node, count - 1);
105
105
  }
@@ -113,4 +113,4 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
113
113
 
114
114
 
115
115
  export {$5e3802645cc19319$export$1c3ebcada18427bf as ariaHideOutside};
116
- //# sourceMappingURL=ariaHideOutside.mjs.map
116
+ //# sourceMappingURL=ariaHideOutside.module.js.map
@@ -17,13 +17,13 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
17
17
  let hiddenNodes = new Set();
18
18
  let walk = (root)=>{
19
19
  // Keep live announcer and top layer elements (e.g. toasts) visible.
20
- for (let element of root.querySelectorAll("[data-live-announcer], [data-react-aria-top-layer]"))visibleNodes.add(element);
20
+ for (let element of root.querySelectorAll('[data-live-announcer], [data-react-aria-top-layer]'))visibleNodes.add(element);
21
21
  let acceptNode = (node)=>{
22
22
  // Skip this node and its children if it is one of the target nodes, or a live announcer.
23
23
  // Also skip children of already hidden nodes, as aria-hidden is recursive. An exception is
24
24
  // made for elements with role="row" since VoiceOver on iOS has issues hiding elements with role="row".
25
25
  // For that case we want to hide the cells inside as well (https://bugs.webkit.org/show_bug.cgi?id=222623).
26
- if (visibleNodes.has(node) || hiddenNodes.has(node.parentElement) && node.parentElement.getAttribute("role") !== "row") return NodeFilter.FILTER_REJECT;
26
+ if (visibleNodes.has(node) || hiddenNodes.has(node.parentElement) && node.parentElement.getAttribute('role') !== 'row') return NodeFilter.FILTER_REJECT;
27
27
  // Skip this node but continue to children if one of the targets is inside the node.
28
28
  for (let target of visibleNodes){
29
29
  if (node.contains(target)) return NodeFilter.FILTER_SKIP;
@@ -49,8 +49,8 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
49
49
  let refCount = (_refCountMap_get = $5e3802645cc19319$var$refCountMap.get(node)) !== null && _refCountMap_get !== void 0 ? _refCountMap_get : 0;
50
50
  // If already aria-hidden, and the ref count is zero, then this element
51
51
  // was already hidden and there's nothing for us to do.
52
- if (node.getAttribute("aria-hidden") === "true" && refCount === 0) return;
53
- if (refCount === 0) node.setAttribute("aria-hidden", "true");
52
+ if (node.getAttribute('aria-hidden') === 'true' && refCount === 0) return;
53
+ if (refCount === 0) node.setAttribute('aria-hidden', 'true');
54
54
  hiddenNodes.add(node);
55
55
  $5e3802645cc19319$var$refCountMap.set(node, refCount + 1);
56
56
  };
@@ -60,7 +60,7 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
60
60
  walk(root);
61
61
  let observer = new MutationObserver((changes)=>{
62
62
  for (let change of changes){
63
- if (change.type !== "childList" || change.addedNodes.length === 0) continue;
63
+ if (change.type !== 'childList' || change.addedNodes.length === 0) continue;
64
64
  // If the parent element of the added nodes is not within one of the targets,
65
65
  // and not already inside a hidden node, hide all of the new children.
66
66
  if (![
@@ -72,7 +72,7 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
72
72
  hiddenNodes.delete(node);
73
73
  }
74
74
  for (let node of change.addedNodes){
75
- if ((node instanceof HTMLElement || node instanceof SVGElement) && (node.dataset.liveAnnouncer === "true" || node.dataset.reactAriaTopLayer === "true")) visibleNodes.add(node);
75
+ if ((node instanceof HTMLElement || node instanceof SVGElement) && (node.dataset.liveAnnouncer === 'true' || node.dataset.reactAriaTopLayer === 'true')) visibleNodes.add(node);
76
76
  else if (node instanceof Element) walk(node);
77
77
  }
78
78
  }
@@ -99,7 +99,7 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
99
99
  for (let node of hiddenNodes){
100
100
  let count = $5e3802645cc19319$var$refCountMap.get(node);
101
101
  if (count === 1) {
102
- node.removeAttribute("aria-hidden");
102
+ node.removeAttribute('aria-hidden');
103
103
  $5e3802645cc19319$var$refCountMap.delete(node);
104
104
  } else $5e3802645cc19319$var$refCountMap.set(node, count - 1);
105
105
  }
package/dist/bg-BG.mjs CHANGED
@@ -5,4 +5,4 @@ $d11f19852b941573$exports = {
5
5
 
6
6
 
7
7
  export {$d11f19852b941573$exports as default};
8
- //# sourceMappingURL=bg-BG.mjs.map
8
+ //# sourceMappingURL=bg-BG.module.js.map
@@ -18,37 +18,37 @@ $parcel$export(module.exports, "calculatePosition", () => $5935ba4d7da2c103$expo
18
18
  * governing permissions and limitations under the License.
19
19
  */
20
20
  const $5935ba4d7da2c103$var$AXIS = {
21
- top: "top",
22
- bottom: "top",
23
- left: "left",
24
- right: "left"
21
+ top: 'top',
22
+ bottom: 'top',
23
+ left: 'left',
24
+ right: 'left'
25
25
  };
26
26
  const $5935ba4d7da2c103$var$FLIPPED_DIRECTION = {
27
- top: "bottom",
28
- bottom: "top",
29
- left: "right",
30
- right: "left"
27
+ top: 'bottom',
28
+ bottom: 'top',
29
+ left: 'right',
30
+ right: 'left'
31
31
  };
32
32
  const $5935ba4d7da2c103$var$CROSS_AXIS = {
33
- top: "left",
34
- left: "top"
33
+ top: 'left',
34
+ left: 'top'
35
35
  };
36
36
  const $5935ba4d7da2c103$var$AXIS_SIZE = {
37
- top: "height",
38
- left: "width"
37
+ top: 'height',
38
+ left: 'width'
39
39
  };
40
40
  const $5935ba4d7da2c103$var$TOTAL_SIZE = {
41
- width: "totalWidth",
42
- height: "totalHeight"
41
+ width: 'totalWidth',
42
+ height: 'totalHeight'
43
43
  };
44
44
  const $5935ba4d7da2c103$var$PARSED_PLACEMENT_CACHE = {};
45
45
  // @ts-ignore
46
- let $5935ba4d7da2c103$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
46
+ let $5935ba4d7da2c103$var$visualViewport = typeof document !== 'undefined' && window.visualViewport;
47
47
  function $5935ba4d7da2c103$var$getContainerDimensions(containerNode) {
48
48
  let width = 0, height = 0, totalWidth = 0, totalHeight = 0, top = 0, left = 0;
49
49
  let scroll = {};
50
50
  let isPinchZoomedIn = ($5935ba4d7da2c103$var$visualViewport === null || $5935ba4d7da2c103$var$visualViewport === void 0 ? void 0 : $5935ba4d7da2c103$var$visualViewport.scale) > 1;
51
- if (containerNode.tagName === "BODY") {
51
+ if (containerNode.tagName === 'BODY') {
52
52
  let documentElement = document.documentElement;
53
53
  totalWidth = documentElement.clientWidth;
54
54
  totalHeight = documentElement.clientHeight;
@@ -72,7 +72,7 @@ function $5935ba4d7da2c103$var$getContainerDimensions(containerNode) {
72
72
  totalWidth = width;
73
73
  totalHeight = height;
74
74
  }
75
- if ((0, $6E71I$reactariautils.isWebKit)() && (containerNode.tagName === "BODY" || containerNode.tagName === "HTML") && isPinchZoomedIn) {
75
+ if ((0, $6E71I$reactariautils.isWebKit)() && (containerNode.tagName === 'BODY' || containerNode.tagName === 'HTML') && isPinchZoomedIn) {
76
76
  // Safari will report a non-zero scrollTop/Left for the non-scrolling body/HTML element when pinch zoomed in unlike other browsers.
77
77
  // Set to zero for parity calculations so we get consistent positioning of overlays across all browsers.
78
78
  // Also switch to visualViewport.pageTop/pageLeft so that we still accomodate for scroll positioning for body/HTML elements that are actually scrollable
@@ -135,10 +135,10 @@ function $5935ba4d7da2c103$var$getMargins(node) {
135
135
  }
136
136
  function $5935ba4d7da2c103$var$parsePlacement(input) {
137
137
  if ($5935ba4d7da2c103$var$PARSED_PLACEMENT_CACHE[input]) return $5935ba4d7da2c103$var$PARSED_PLACEMENT_CACHE[input];
138
- let [placement, crossPlacement] = input.split(" ");
139
- let axis = $5935ba4d7da2c103$var$AXIS[placement] || "right";
138
+ let [placement, crossPlacement] = input.split(' ');
139
+ let axis = $5935ba4d7da2c103$var$AXIS[placement] || 'right';
140
140
  let crossAxis = $5935ba4d7da2c103$var$CROSS_AXIS[axis];
141
- if (!$5935ba4d7da2c103$var$AXIS[crossPlacement]) crossPlacement = "center";
141
+ if (!$5935ba4d7da2c103$var$AXIS[crossPlacement]) crossPlacement = 'center';
142
142
  let size = $5935ba4d7da2c103$var$AXIS_SIZE[axis];
143
143
  let crossSize = $5935ba4d7da2c103$var$AXIS_SIZE[crossAxis];
144
144
  $5935ba4d7da2c103$var$PARSED_PLACEMENT_CACHE[input] = {
@@ -156,7 +156,7 @@ function $5935ba4d7da2c103$var$computePosition(childOffset, boundaryDimensions,
156
156
  let position = {};
157
157
  // button position
158
158
  position[crossAxis] = childOffset[crossAxis];
159
- if (crossPlacement === "center") // + (button size / 2) - (overlay size / 2)
159
+ if (crossPlacement === 'center') // + (button size / 2) - (overlay size / 2)
160
160
  // at this point the overlay center should match the button center
161
161
  position[crossAxis] += (childOffset[crossSize] - overlaySize[crossSize]) / 2;
162
162
  else if (crossPlacement !== crossAxis) // + (button size) - (overlay size)
@@ -187,7 +187,7 @@ function $5935ba4d7da2c103$var$getMaxHeight(position, boundaryDimensions, contai
187
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
188
  // used in computePosition.
189
189
  let overlayTop = position.top != null ? containerOffsetWithBoundary.top + position.top : containerOffsetWithBoundary.top + (containerHeight - position.bottom - overlayHeight);
190
- let maxHeight = heightGrowthDirection !== "top" ? // We want the distance between the top of the overlay to the bottom of the boundary
190
+ let maxHeight = heightGrowthDirection !== 'top' ? // We want the distance between the top of the overlay to the bottom of the boundary
191
191
  Math.max(0, boundaryDimensions.height + boundaryDimensions.top + boundaryDimensions.scroll.top // this is the bottom of the boundary
192
192
  - overlayTop // this is the top of the overlay
193
193
  - (margins.top + margins.bottom + padding // save additional space for margin and padding
@@ -221,13 +221,13 @@ function $5935ba4d7da2c103$export$6839422d1f33cee9(placementInput, childOffset,
221
221
  }
222
222
  }
223
223
  // Determine the direction the height of the overlay can grow so that we can choose how to calculate the max height
224
- let heightGrowthDirection = "bottom";
225
- if (placementInfo.axis === "top") {
226
- if (placementInfo.placement === "top") heightGrowthDirection = "top";
227
- else if (placementInfo.placement === "bottom") heightGrowthDirection = "bottom";
228
- } else if (placementInfo.crossAxis === "top") {
229
- if (placementInfo.crossPlacement === "top") heightGrowthDirection = "bottom";
230
- else if (placementInfo.crossPlacement === "bottom") heightGrowthDirection = "top";
224
+ let heightGrowthDirection = 'bottom';
225
+ if (placementInfo.axis === 'top') {
226
+ if (placementInfo.placement === 'top') heightGrowthDirection = 'top';
227
+ else if (placementInfo.placement === 'bottom') heightGrowthDirection = 'bottom';
228
+ } else if (placementInfo.crossAxis === 'top') {
229
+ if (placementInfo.crossPlacement === 'top') heightGrowthDirection = 'bottom';
230
+ else if (placementInfo.crossPlacement === 'bottom') heightGrowthDirection = 'top';
231
231
  }
232
232
  let delta = $5935ba4d7da2c103$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);
233
233
  position[crossAxis] += delta;
@@ -240,13 +240,13 @@ function $5935ba4d7da2c103$export$6839422d1f33cee9(placementInput, childOffset,
240
240
  let arrowPosition = {};
241
241
  // All values are transformed so that 0 is at the top/left of the overlay depending on the orientation
242
242
  // Prefer the arrow being in the center of the trigger/overlay anchor element
243
- let preferredArrowPosition = childOffset[crossAxis] + .5 * childOffset[crossSize] - overlaySize[crossAxis];
243
+ let preferredArrowPosition = childOffset[crossAxis] + .5 * childOffset[crossSize] - position[crossAxis];
244
244
  // Min/Max position limits for the arrow with respect to the overlay
245
245
  const arrowMinPosition = arrowSize / 2 + arrowBoundaryOffset;
246
246
  const arrowMaxPosition = overlaySize[crossSize] - arrowSize / 2 - arrowBoundaryOffset;
247
247
  // Min/Max position limits for the arrow with respect to the trigger/overlay anchor element
248
- const arrowOverlappingChildMinEdge = childOffset[crossAxis] - overlaySize[crossAxis] + arrowSize / 2;
249
- const arrowOverlappingChildMaxEdge = childOffset[crossAxis] + childOffset[crossSize] - overlaySize[crossAxis] - arrowSize / 2;
248
+ const arrowOverlappingChildMinEdge = childOffset[crossAxis] - position[crossAxis] + arrowSize / 2;
249
+ const arrowOverlappingChildMaxEdge = childOffset[crossAxis] + childOffset[crossSize] - position[crossAxis] - arrowSize / 2;
250
250
  // Clamp the arrow positioning so that it always is within the bounds of the anchor and the overlay
251
251
  const arrowPositionOverlappingChild = (0, $6E71I$reactariautils.clamp)(preferredArrowPosition, arrowOverlappingChildMinEdge, arrowOverlappingChildMaxEdge);
252
252
  arrowPosition[crossAxis] = (0, $6E71I$reactariautils.clamp)(arrowPositionOverlappingChild, arrowMinPosition, arrowMaxPosition);
@@ -263,7 +263,7 @@ function $5935ba4d7da2c103$export$b3ceb0cbf1056d98(opts) {
263
263
  let container = overlayNode instanceof HTMLElement ? $5935ba4d7da2c103$var$getContainingBlock(overlayNode) : document.documentElement;
264
264
  let isViewportContainer = container === document.documentElement;
265
265
  const containerPositionStyle = window.getComputedStyle(container).position;
266
- let isContainerPositioned = !!containerPositionStyle && containerPositionStyle !== "static";
266
+ let isContainerPositioned = !!containerPositionStyle && containerPositionStyle !== 'static';
267
267
  let childOffset = isViewportContainer ? $5935ba4d7da2c103$var$getOffset(targetNode) : $5935ba4d7da2c103$var$getPosition(targetNode, container);
268
268
  if (!isViewportContainer) {
269
269
  let { marginTop: marginTop, marginLeft: marginLeft } = window.getComputedStyle(targetNode);
@@ -280,8 +280,8 @@ function $5935ba4d7da2c103$export$b3ceb0cbf1056d98(opts) {
280
280
  // If the container is the HTML element wrapping the body element, the retrieved scrollTop/scrollLeft will be equal to the
281
281
  // 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
282
282
  // by the container scroll since they are essentially the same containing element and thus in the same coordinate system
283
- let containerOffsetWithBoundary = boundaryElement.tagName === "BODY" ? $5935ba4d7da2c103$var$getOffset(container) : $5935ba4d7da2c103$var$getPosition(container, boundaryElement);
284
- if (container.tagName === "HTML" && boundaryElement.tagName === "BODY") {
283
+ let containerOffsetWithBoundary = boundaryElement.tagName === 'BODY' ? $5935ba4d7da2c103$var$getOffset(container) : $5935ba4d7da2c103$var$getPosition(container, boundaryElement);
284
+ if (container.tagName === 'HTML' && boundaryElement.tagName === 'BODY') {
285
285
  containerDimensions.scroll.top = 0;
286
286
  containerDimensions.scroll.left = 0;
287
287
  }
@@ -300,7 +300,7 @@ function $5935ba4d7da2c103$var$getOffset(node) {
300
300
  function $5935ba4d7da2c103$var$getPosition(node, parent) {
301
301
  let style = window.getComputedStyle(node);
302
302
  let offset;
303
- if (style.position === "fixed") {
303
+ if (style.position === 'fixed') {
304
304
  let { top: top, left: left, width: width, height: height } = node.getBoundingClientRect();
305
305
  offset = {
306
306
  top: top,
@@ -331,7 +331,7 @@ function $5935ba4d7da2c103$var$getContainingBlock(node) {
331
331
  // The offsetParent algorithm terminates at the document body,
332
332
  // even if the body is not a containing block. Double check that
333
333
  // and use the documentElement if so.
334
- if (offsetParent && offsetParent === document.body && window.getComputedStyle(offsetParent).position === "static" && !$5935ba4d7da2c103$var$isContainingBlock(offsetParent)) offsetParent = document.documentElement;
334
+ if (offsetParent && offsetParent === document.body && window.getComputedStyle(offsetParent).position === 'static' && !$5935ba4d7da2c103$var$isContainingBlock(offsetParent)) offsetParent = document.documentElement;
335
335
  // TODO(later): handle table elements?
336
336
  // The offsetParent can be null if the element has position: fixed, or a few other cases.
337
337
  // We have to walk up the tree manually in this case because fixed positioned elements
@@ -346,9 +346,9 @@ function $5935ba4d7da2c103$var$getContainingBlock(node) {
346
346
  // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
347
347
  function $5935ba4d7da2c103$var$isContainingBlock(node) {
348
348
  let style = window.getComputedStyle(node);
349
- return style.transform !== "none" || /transform|perspective/.test(style.willChange) || style.filter !== "none" || style.contain === "paint" || // @ts-ignore
350
- "backdropFilter" in style && style.backdropFilter !== "none" || // @ts-ignore
351
- "WebkitBackdropFilter" in style && style.WebkitBackdropFilter !== "none";
349
+ return style.transform !== 'none' || /transform|perspective/.test(style.willChange) || style.filter !== 'none' || style.contain === 'paint' || // @ts-ignore
350
+ 'backdropFilter' in style && style.backdropFilter !== 'none' || // @ts-ignore
351
+ 'WebkitBackdropFilter' in style && style.WebkitBackdropFilter !== 'none';
352
352
  }
353
353
 
354
354
 
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AA+DD,MAAM,6BAAO;IACX,KAAK;IACL,QAAQ;IACR,MAAM;IACN,OAAO;AACT;AAEA,MAAM,0CAAoB;IACxB,KAAK;IACL,QAAQ;IACR,MAAM;IACN,OAAO;AACT;AAEA,MAAM,mCAAa;IACjB,KAAK;IACL,MAAM;AACR;AAEA,MAAM,kCAAY;IAChB,KAAK;IACL,MAAM;AACR;AAEA,MAAM,mCAAa;IACjB,OAAO;IACP,QAAQ;AACV;AAEA,MAAM,+CAAyB,CAAC;AAEhC,aAAa;AACb,IAAI,uCAAiB,OAAO,aAAa,eAAe,OAAO,cAAc;AAE7E,SAAS,6CAAuB,aAAsB;IACpD,IAAI,QAAQ,GAAG,SAAS,GAAG,aAAa,GAAG,cAAc,GAAG,MAAM,GAAG,OAAO;IAC5E,IAAI,SAAmB,CAAC;IACxB,IAAI,kBAAkB,CAAA,iDAAA,2DAAA,qCAAgB,KAAK,IAAG;IAE9C,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AQ,OAAO,gBAAgB,CAAC;IACpC,OACE,MAAM,SAAS,KAAK,UACpB,wBAAwB,IAAI,CAAC,MAAM,UAAU,KAC7C,MAAM,MAAM,KAAK,UACjB,MAAM,OAAO,KAAK,WAClB,aAAa;IACZ,oBAAoB,SAAS,MAAM,cAAc,KAAK,UACvD,aAAa;IACZ,0BAA0B,SAAS,MAAM,oBAAoB,KAAK;AAEvE","sources":["packages/@react-aria/overlays/src/calculatePosition.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Axis, Placement, PlacementAxis, SizeAxis} from '@react-types/overlays';\nimport {clamp, isWebKit} from '@react-aria/utils';\n\ninterface Position {\n top?: number,\n left?: number,\n bottom?: number,\n right?: number\n}\n\ninterface Dimensions {\n width: number,\n height: number,\n totalWidth: number,\n totalHeight: number,\n top: number,\n left: number,\n scroll: Position\n}\n\ninterface ParsedPlacement {\n placement: PlacementAxis,\n crossPlacement: PlacementAxis,\n axis: Axis,\n crossAxis: Axis,\n size: SizeAxis,\n crossSize: SizeAxis\n}\n\ninterface Offset {\n top: number,\n left: number,\n width: number,\n height: number\n}\n\ninterface PositionOpts {\n arrowSize: number,\n placement: Placement,\n targetNode: Element,\n overlayNode: Element,\n scrollNode: Element,\n padding: number,\n shouldFlip: boolean,\n boundaryElement: Element,\n offset: number,\n crossOffset: number,\n maxHeight?: number,\n arrowBoundaryOffset?: number\n}\n\ntype HeightGrowthDirection = 'top' | 'bottom';\n\nexport interface PositionResult {\n position?: Position,\n arrowOffsetLeft?: number,\n arrowOffsetTop?: number,\n maxHeight?: number,\n placement: PlacementAxis\n}\n\nconst AXIS = {\n top: 'top',\n bottom: 'top',\n left: 'left',\n right: 'left'\n};\n\nconst FLIPPED_DIRECTION = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left'\n};\n\nconst CROSS_AXIS = {\n top: 'left',\n left: 'top'\n};\n\nconst AXIS_SIZE = {\n top: 'height',\n left: 'width'\n};\n\nconst TOTAL_SIZE = {\n width: 'totalWidth',\n height: 'totalHeight'\n};\n\nconst PARSED_PLACEMENT_CACHE = {};\n\n// @ts-ignore\nlet visualViewport = typeof document !== 'undefined' && window.visualViewport;\n\nfunction getContainerDimensions(containerNode: Element): Dimensions {\n let width = 0, height = 0, totalWidth = 0, totalHeight = 0, top = 0, left = 0;\n let scroll: Position = {};\n let isPinchZoomedIn = visualViewport?.scale > 1;\n\n if (containerNode.tagName === 'BODY') {\n let documentElement = document.documentElement;\n totalWidth = documentElement.clientWidth;\n totalHeight = documentElement.clientHeight;\n width = visualViewport?.width ?? totalWidth;\n height = visualViewport?.height ?? totalHeight;\n scroll.top = documentElement.scrollTop || containerNode.scrollTop;\n scroll.left = documentElement.scrollLeft || containerNode.scrollLeft;\n\n // The goal of the below is to get a top/left value that represents the top/left of the visual viewport with\n // respect to the layout viewport origin. This combined with the scrollTop/scrollLeft will allow us to calculate\n // coordinates/values with respect to the visual viewport or with respect to the layout viewport.\n if (visualViewport) {\n top = visualViewport.offsetTop;\n left = visualViewport.offsetLeft;\n }\n } else {\n ({width, height, top, left} = getOffset(containerNode));\n scroll.top = containerNode.scrollTop;\n scroll.left = containerNode.scrollLeft;\n totalWidth = width;\n totalHeight = height;\n }\n\n if (isWebKit() && (containerNode.tagName === 'BODY' || containerNode.tagName === 'HTML') && isPinchZoomedIn) {\n // Safari will report a non-zero scrollTop/Left for the non-scrolling body/HTML element when pinch zoomed in unlike other browsers.\n // Set to zero for parity calculations so we get consistent positioning of overlays across all browsers.\n // Also switch to visualViewport.pageTop/pageLeft so that we still accomodate for scroll positioning for body/HTML elements that are actually scrollable\n // before pinch zoom happens\n scroll.top = 0;\n scroll.left = 0;\n top = visualViewport.pageTop;\n left = visualViewport.pageLeft;\n }\n\n return {width, height, totalWidth, totalHeight, scroll, top, left};\n}\n\nfunction getScroll(node: Element): Offset {\n return {\n top: node.scrollTop,\n left: node.scrollLeft,\n width: node.scrollWidth,\n height: node.scrollHeight\n };\n}\n\n// Determines the amount of space required when moving the overlay to ensure it remains in the boundary\nfunction getDelta(\n axis: Axis,\n offset: number,\n size: number,\n // The dimensions of the boundary element that the popover is\n // positioned within (most of the time this is the <body>).\n boundaryDimensions: Dimensions,\n // The dimensions of the containing block element that the popover is\n // positioned relative to (e.g. parent with position: relative).\n // Usually this is the same as the boundary element, but if the popover\n // is portaled somewhere other than the body and has an ancestor with\n // position: relative/absolute, it will be different.\n containerDimensions: Dimensions,\n padding: number,\n containerOffsetWithBoundary: Offset\n) {\n let containerScroll = containerDimensions.scroll[axis];\n // The height/width of the boundary. Matches the axis along which we are adjusting the overlay position\n let boundarySize = boundaryDimensions[AXIS_SIZE[axis]];\n // Calculate the edges of the boundary (accomodating for the boundary padding) and the edges of the overlay.\n // Note that these values are with respect to the visual viewport (aka 0,0 is the top left of the viewport)\n let boundaryStartEdge = boundaryDimensions.scroll[AXIS[axis]] + padding;\n let boundaryEndEdge = boundarySize + boundaryDimensions.scroll[AXIS[axis]] - padding;\n let startEdgeOffset = offset - containerScroll + containerOffsetWithBoundary[axis] - boundaryDimensions[AXIS[axis]];\n let endEdgeOffset = offset - containerScroll + size + containerOffsetWithBoundary[axis] - boundaryDimensions[AXIS[axis]];\n\n // If any of the overlay edges falls outside of the boundary, shift the overlay the required amount to align one of the overlay's\n // edges with the closest boundary edge.\n if (startEdgeOffset < boundaryStartEdge) {\n return boundaryStartEdge - startEdgeOffset;\n } else if (endEdgeOffset > boundaryEndEdge) {\n return Math.max(boundaryEndEdge - endEdgeOffset, boundaryStartEdge - startEdgeOffset);\n } else {\n return 0;\n }\n}\n\nfunction getMargins(node: Element): Position {\n let style = window.getComputedStyle(node);\n return {\n top: parseInt(style.marginTop, 10) || 0,\n bottom: parseInt(style.marginBottom, 10) || 0,\n left: parseInt(style.marginLeft, 10) || 0,\n right: parseInt(style.marginRight, 10) || 0\n };\n}\n\nfunction parsePlacement(input: Placement): ParsedPlacement {\n if (PARSED_PLACEMENT_CACHE[input]) {\n return PARSED_PLACEMENT_CACHE[input];\n }\n\n let [placement, crossPlacement] = input.split(' ');\n let axis: Axis = AXIS[placement] || 'right';\n let crossAxis: Axis = CROSS_AXIS[axis];\n\n if (!AXIS[crossPlacement]) {\n crossPlacement = 'center';\n }\n\n let size = AXIS_SIZE[axis];\n let crossSize = AXIS_SIZE[crossAxis];\n PARSED_PLACEMENT_CACHE[input] = {placement, crossPlacement, axis, crossAxis, size, crossSize};\n return PARSED_PLACEMENT_CACHE[input];\n}\n\nfunction computePosition(\n childOffset: Offset,\n boundaryDimensions: Dimensions,\n overlaySize: Offset,\n placementInfo: ParsedPlacement,\n offset: number,\n crossOffset: number,\n containerOffsetWithBoundary: Offset,\n isContainerPositioned: boolean,\n arrowSize: number,\n arrowBoundaryOffset: number\n) {\n let {placement, crossPlacement, axis, crossAxis, size, crossSize} = placementInfo;\n let position: Position = {};\n\n // button position\n position[crossAxis] = childOffset[crossAxis];\n if (crossPlacement === 'center') {\n // + (button size / 2) - (overlay size / 2)\n // at this point the overlay center should match the button center\n position[crossAxis] += (childOffset[crossSize] - overlaySize[crossSize]) / 2;\n } else if (crossPlacement !== crossAxis) {\n // + (button size) - (overlay size)\n // at this point the overlay bottom should match the button bottom\n position[crossAxis] += (childOffset[crossSize] - overlaySize[crossSize]);\n }/* else {\n the overlay top should match the button top\n } */\n\n position[crossAxis] += crossOffset;\n\n // overlay top overlapping arrow with button bottom\n const minPosition = childOffset[crossAxis] - overlaySize[crossSize] + arrowSize + arrowBoundaryOffset;\n // overlay bottom overlapping arrow with button top\n const maxPosition = childOffset[crossAxis] + childOffset[crossSize] - arrowSize - arrowBoundaryOffset;\n position[crossAxis] = clamp(position[crossAxis], minPosition, maxPosition);\n\n // 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.\n if (placement === axis) {\n // If the container is positioned (non-static), then we use the container's actual\n // height, as `bottom` will be relative to this height. But if the container is static,\n // then it can only be the `document.body`, and `bottom` will be relative to _its_\n // container, which should be as large as boundaryDimensions.\n const containerHeight = (isContainerPositioned ? containerOffsetWithBoundary[size] : boundaryDimensions[TOTAL_SIZE[size]]);\n position[FLIPPED_DIRECTION[axis]] = Math.floor(containerHeight - childOffset[axis] + offset);\n } else {\n position[axis] = Math.floor(childOffset[axis] + childOffset[size] + offset);\n }\n return position;\n}\n\nfunction getMaxHeight(\n position: Position,\n boundaryDimensions: Dimensions,\n containerOffsetWithBoundary: Offset,\n isContainerPositioned: boolean,\n margins: Position,\n padding: number,\n overlayHeight: number,\n heightGrowthDirection: HeightGrowthDirection\n) {\n const containerHeight = (isContainerPositioned ? containerOffsetWithBoundary.height : boundaryDimensions[TOTAL_SIZE.height]);\n // 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\n // used in computePosition.\n let overlayTop = position.top != null ? containerOffsetWithBoundary.top + position.top : containerOffsetWithBoundary.top + (containerHeight - position.bottom - overlayHeight);\n let maxHeight = heightGrowthDirection !== 'top' ?\n // We want the distance between the top of the overlay to the bottom of the boundary\n Math.max(0,\n (boundaryDimensions.height + boundaryDimensions.top + boundaryDimensions.scroll.top) // this is the bottom of the boundary\n - overlayTop // this is the top of the overlay\n - (margins.top + margins.bottom + padding) // save additional space for margin and padding\n )\n // We want the distance between the bottom of the overlay to the top of the boundary\n : Math.max(0,\n (overlayTop + overlayHeight) // this is the bottom of the overlay\n - (boundaryDimensions.top + boundaryDimensions.scroll.top) // this is the top of the boundary\n - (margins.top + margins.bottom + padding) // save additional space for margin and padding\n );\n return Math.min(boundaryDimensions.height - (padding * 2), maxHeight);\n}\n\nfunction getAvailableSpace(\n boundaryDimensions: Dimensions,\n containerOffsetWithBoundary: Offset,\n childOffset: Offset,\n margins: Position,\n padding: number,\n placementInfo: ParsedPlacement\n) {\n let {placement, axis, size} = placementInfo;\n if (placement === axis) {\n return Math.max(0, childOffset[axis] - boundaryDimensions[axis] - boundaryDimensions.scroll[axis] + containerOffsetWithBoundary[axis] - margins[axis] - margins[FLIPPED_DIRECTION[axis]] - padding);\n }\n\n return Math.max(0, boundaryDimensions[size] + boundaryDimensions[axis] + boundaryDimensions.scroll[axis] - containerOffsetWithBoundary[axis] - childOffset[axis] - childOffset[size] - margins[axis] - margins[FLIPPED_DIRECTION[axis]] - padding);\n}\n\nexport function calculatePositionInternal(\n placementInput: Placement,\n childOffset: Offset,\n overlaySize: Offset,\n scrollSize: Offset,\n margins: Position,\n padding: number,\n flip: boolean,\n boundaryDimensions: Dimensions,\n containerDimensions: Dimensions,\n containerOffsetWithBoundary: Offset,\n offset: number,\n crossOffset: number,\n isContainerPositioned: boolean,\n userSetMaxHeight: number | undefined,\n arrowSize: number,\n arrowBoundaryOffset: number\n): PositionResult {\n let placementInfo = parsePlacement(placementInput);\n let {size, crossAxis, crossSize, placement, crossPlacement} = placementInfo;\n let position = computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);\n let normalizedOffset = offset;\n let space = getAvailableSpace(\n boundaryDimensions,\n containerOffsetWithBoundary,\n childOffset,\n margins,\n padding + offset,\n placementInfo\n );\n\n // Check if the scroll size of the overlay is greater than the available space to determine if we need to flip\n if (flip && scrollSize[size] > space) {\n let flippedPlacementInfo = parsePlacement(`${FLIPPED_DIRECTION[placement]} ${crossPlacement}` as Placement);\n let flippedPosition = computePosition(childOffset, boundaryDimensions, overlaySize, flippedPlacementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);\n let flippedSpace = getAvailableSpace(\n boundaryDimensions,\n containerOffsetWithBoundary,\n childOffset,\n margins,\n padding + offset,\n flippedPlacementInfo\n );\n\n // If the available space for the flipped position is greater than the original available space, flip.\n if (flippedSpace > space) {\n placementInfo = flippedPlacementInfo;\n position = flippedPosition;\n normalizedOffset = offset;\n }\n }\n\n // Determine the direction the height of the overlay can grow so that we can choose how to calculate the max height\n let heightGrowthDirection: HeightGrowthDirection = 'bottom';\n if (placementInfo.axis === 'top') {\n if (placementInfo.placement === 'top') {\n heightGrowthDirection = 'top';\n } else if (placementInfo.placement === 'bottom') {\n heightGrowthDirection = 'bottom';\n }\n } else if (placementInfo.crossAxis === 'top') {\n if (placementInfo.crossPlacement === 'top') {\n heightGrowthDirection = 'bottom';\n } else if (placementInfo.crossPlacement === 'bottom') {\n heightGrowthDirection = 'top';\n }\n }\n\n let delta = getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);\n position[crossAxis] += delta;\n\n let maxHeight = getMaxHeight(\n position,\n boundaryDimensions,\n containerOffsetWithBoundary,\n isContainerPositioned,\n margins,\n padding,\n overlaySize.height,\n heightGrowthDirection\n );\n\n if (userSetMaxHeight && userSetMaxHeight < maxHeight) {\n maxHeight = userSetMaxHeight;\n }\n\n overlaySize.height = Math.min(overlaySize.height, maxHeight);\n\n position = computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, normalizedOffset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);\n delta = getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);\n position[crossAxis] += delta;\n\n let arrowPosition: Position = {};\n\n // All values are transformed so that 0 is at the top/left of the overlay depending on the orientation\n // Prefer the arrow being in the center of the trigger/overlay anchor element\n let preferredArrowPosition = childOffset[crossAxis] + .5 * childOffset[crossSize] - overlaySize[crossAxis];\n\n // Min/Max position limits for the arrow with respect to the overlay\n const arrowMinPosition = arrowSize / 2 + arrowBoundaryOffset;\n const arrowMaxPosition = overlaySize[crossSize] - (arrowSize / 2) - arrowBoundaryOffset;\n\n // Min/Max position limits for the arrow with respect to the trigger/overlay anchor element\n const arrowOverlappingChildMinEdge = childOffset[crossAxis] - overlaySize[crossAxis] + (arrowSize / 2);\n const arrowOverlappingChildMaxEdge = childOffset[crossAxis] + childOffset[crossSize] - overlaySize[crossAxis] - (arrowSize / 2);\n\n // Clamp the arrow positioning so that it always is within the bounds of the anchor and the overlay\n const arrowPositionOverlappingChild = clamp(preferredArrowPosition, arrowOverlappingChildMinEdge, arrowOverlappingChildMaxEdge);\n arrowPosition[crossAxis] = clamp(arrowPositionOverlappingChild, arrowMinPosition, arrowMaxPosition);\n\n return {\n position,\n maxHeight: maxHeight,\n arrowOffsetLeft: arrowPosition.left,\n arrowOffsetTop: arrowPosition.top,\n placement: placementInfo.placement\n };\n}\n\n/**\n * Determines where to place the overlay with regards to the target and the position of an optional indicator.\n */\nexport function calculatePosition(opts: PositionOpts): PositionResult {\n let {\n placement,\n targetNode,\n overlayNode,\n scrollNode,\n padding,\n shouldFlip,\n boundaryElement,\n offset,\n crossOffset,\n maxHeight,\n arrowSize = 0,\n arrowBoundaryOffset = 0\n } = opts;\n\n let container = overlayNode instanceof HTMLElement ? getContainingBlock(overlayNode) : document.documentElement;\n let isViewportContainer = container === document.documentElement;\n const containerPositionStyle = window.getComputedStyle(container).position;\n let isContainerPositioned = !!containerPositionStyle && containerPositionStyle !== 'static';\n let childOffset: Offset = isViewportContainer ? getOffset(targetNode) : getPosition(targetNode, container);\n\n if (!isViewportContainer) {\n let {marginTop, marginLeft} = window.getComputedStyle(targetNode);\n childOffset.top += parseInt(marginTop, 10) || 0;\n childOffset.left += parseInt(marginLeft, 10) || 0;\n }\n\n let overlaySize: Offset = getOffset(overlayNode);\n let margins = getMargins(overlayNode);\n overlaySize.width += margins.left + margins.right;\n overlaySize.height += margins.top + margins.bottom;\n\n let scrollSize = getScroll(scrollNode);\n let boundaryDimensions = getContainerDimensions(boundaryElement);\n let containerDimensions = getContainerDimensions(container);\n // If the container is the HTML element wrapping the body element, the retrieved scrollTop/scrollLeft will be equal to the\n // 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\n // by the container scroll since they are essentially the same containing element and thus in the same coordinate system\n let containerOffsetWithBoundary: Offset = boundaryElement.tagName === 'BODY' ? getOffset(container) : getPosition(container, boundaryElement);\n if (container.tagName === 'HTML' && boundaryElement.tagName === 'BODY') {\n containerDimensions.scroll.top = 0;\n containerDimensions.scroll.left = 0;\n }\n\n return calculatePositionInternal(\n placement,\n childOffset,\n overlaySize,\n scrollSize,\n margins,\n padding,\n shouldFlip,\n boundaryDimensions,\n containerDimensions,\n containerOffsetWithBoundary,\n offset,\n crossOffset,\n isContainerPositioned,\n maxHeight,\n arrowSize,\n arrowBoundaryOffset\n );\n}\n\nfunction getOffset(node: Element): Offset {\n let {top, left, width, height} = node.getBoundingClientRect();\n let {scrollTop, scrollLeft, clientTop, clientLeft} = document.documentElement;\n return {\n top: top + scrollTop - clientTop,\n left: left + scrollLeft - clientLeft,\n width,\n height\n };\n}\n\nfunction getPosition(node: Element, parent: Element): Offset {\n let style = window.getComputedStyle(node);\n let offset: Offset;\n if (style.position === 'fixed') {\n let {top, left, width, height} = node.getBoundingClientRect();\n offset = {top, left, width, height};\n } else {\n offset = getOffset(node);\n let parentOffset = getOffset(parent);\n let parentStyle = window.getComputedStyle(parent);\n parentOffset.top += (parseInt(parentStyle.borderTopWidth, 10) || 0) - parent.scrollTop;\n parentOffset.left += (parseInt(parentStyle.borderLeftWidth, 10) || 0) - parent.scrollLeft;\n offset.top -= parentOffset.top;\n offset.left -= parentOffset.left;\n }\n\n offset.top -= parseInt(style.marginTop, 10) || 0;\n offset.left -= parseInt(style.marginLeft, 10) || 0;\n return offset;\n}\n\n// Returns the containing block of an element, which is the element that\n// this element will be positioned relative to.\n// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block\nfunction getContainingBlock(node: HTMLElement): Element {\n // The offsetParent of an element in most cases equals the containing block.\n // https://w3c.github.io/csswg-drafts/cssom-view/#dom-htmlelement-offsetparent\n let offsetParent = node.offsetParent;\n\n // The offsetParent algorithm terminates at the document body,\n // even if the body is not a containing block. Double check that\n // and use the documentElement if so.\n if (\n offsetParent &&\n offsetParent === document.body &&\n window.getComputedStyle(offsetParent).position === 'static' &&\n !isContainingBlock(offsetParent)\n ) {\n offsetParent = document.documentElement;\n }\n\n // TODO(later): handle table elements?\n\n // The offsetParent can be null if the element has position: fixed, or a few other cases.\n // We have to walk up the tree manually in this case because fixed positioned elements\n // are still positioned relative to their containing block, which is not always the viewport.\n if (offsetParent == null) {\n offsetParent = node.parentElement;\n while (offsetParent && !isContainingBlock(offsetParent)) {\n offsetParent = offsetParent.parentElement;\n }\n }\n\n // Fall back to the viewport.\n return offsetParent || document.documentElement;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\nfunction isContainingBlock(node: Element): boolean {\n let style = window.getComputedStyle(node);\n return (\n style.transform !== 'none' ||\n /transform|perspective/.test(style.willChange) ||\n style.filter !== 'none' ||\n style.contain === 'paint' ||\n // @ts-ignore\n ('backdropFilter' in style && style.backdropFilter !== 'none') ||\n // @ts-ignore\n ('WebkitBackdropFilter' in style && style.WebkitBackdropFilter !== 'none')\n );\n}\n"],"names":[],"version":3,"file":"calculatePosition.main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AA+DD,MAAM,6BAAO;IACX,KAAK;IACL,QAAQ;IACR,MAAM;IACN,OAAO;AACT;AAEA,MAAM,0CAAoB;IACxB,KAAK;IACL,QAAQ;IACR,MAAM;IACN,OAAO;AACT;AAEA,MAAM,mCAAa;IACjB,KAAK;IACL,MAAM;AACR;AAEA,MAAM,kCAAY;IAChB,KAAK;IACL,MAAM;AACR;AAEA,MAAM,mCAAa;IACjB,OAAO;IACP,QAAQ;AACV;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S,eAAe;IAGzC,sCAAsC;IAEtC,yFAAyF;IACzF,sFAAsF;IACtF,6FAA6F;IAC7F,IAAI,gBAAgB,MAAM;QACxB,eAAe,KAAK,aAAa;QACjC,MAAO,gBAAgB,CAAC,wCAAkB,cACxC,eAAe,aAAa,aAAa;IAE7C;IAEA,6BAA6B;IAC7B,OAAO,gBAAgB,SAAS,eAAe;AACjD;AAEA,qGAAqG;AACrG,SAAS,wCAAkB,IAAa;IACtC,IAAI,QAAQ,OAAO,gBAAgB,CAAC;IACpC,OACE,MAAM,SAAS,KAAK,UACpB,wBAAwB,IAAI,CAAC,MAAM,UAAU,KAC7C,MAAM,MAAM,KAAK,UACjB,MAAM,OAAO,KAAK,WAClB,aAAa;IACZ,oBAAoB,SAAS,MAAM,cAAc,KAAK,UACvD,aAAa;IACZ,0BAA0B,SAAS,MAAM,oBAAoB,KAAK;AAEvE","sources":["packages/@react-aria/overlays/src/calculatePosition.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Axis, Placement, PlacementAxis, SizeAxis} from '@react-types/overlays';\nimport {clamp, isWebKit} from '@react-aria/utils';\n\ninterface Position {\n top?: number,\n left?: number,\n bottom?: number,\n right?: number\n}\n\ninterface Dimensions {\n width: number,\n height: number,\n totalWidth: number,\n totalHeight: number,\n top: number,\n left: number,\n scroll: Position\n}\n\ninterface ParsedPlacement {\n placement: PlacementAxis,\n crossPlacement: PlacementAxis,\n axis: Axis,\n crossAxis: Axis,\n size: SizeAxis,\n crossSize: SizeAxis\n}\n\ninterface Offset {\n top: number,\n left: number,\n width: number,\n height: number\n}\n\ninterface PositionOpts {\n arrowSize: number,\n placement: Placement,\n targetNode: Element,\n overlayNode: Element,\n scrollNode: Element,\n padding: number,\n shouldFlip: boolean,\n boundaryElement: Element,\n offset: number,\n crossOffset: number,\n maxHeight?: number,\n arrowBoundaryOffset?: number\n}\n\ntype HeightGrowthDirection = 'top' | 'bottom';\n\nexport interface PositionResult {\n position?: Position,\n arrowOffsetLeft?: number,\n arrowOffsetTop?: number,\n maxHeight?: number,\n placement: PlacementAxis\n}\n\nconst AXIS = {\n top: 'top',\n bottom: 'top',\n left: 'left',\n right: 'left'\n};\n\nconst FLIPPED_DIRECTION = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left'\n};\n\nconst CROSS_AXIS = {\n top: 'left',\n left: 'top'\n};\n\nconst AXIS_SIZE = {\n top: 'height',\n left: 'width'\n};\n\nconst TOTAL_SIZE = {\n width: 'totalWidth',\n height: 'totalHeight'\n};\n\nconst PARSED_PLACEMENT_CACHE = {};\n\n// @ts-ignore\nlet visualViewport = typeof document !== 'undefined' && window.visualViewport;\n\nfunction getContainerDimensions(containerNode: Element): Dimensions {\n let width = 0, height = 0, totalWidth = 0, totalHeight = 0, top = 0, left = 0;\n let scroll: Position = {};\n let isPinchZoomedIn = visualViewport?.scale > 1;\n\n if (containerNode.tagName === 'BODY') {\n let documentElement = document.documentElement;\n totalWidth = documentElement.clientWidth;\n totalHeight = documentElement.clientHeight;\n width = visualViewport?.width ?? totalWidth;\n height = visualViewport?.height ?? totalHeight;\n scroll.top = documentElement.scrollTop || containerNode.scrollTop;\n scroll.left = documentElement.scrollLeft || containerNode.scrollLeft;\n\n // The goal of the below is to get a top/left value that represents the top/left of the visual viewport with\n // respect to the layout viewport origin. This combined with the scrollTop/scrollLeft will allow us to calculate\n // coordinates/values with respect to the visual viewport or with respect to the layout viewport.\n if (visualViewport) {\n top = visualViewport.offsetTop;\n left = visualViewport.offsetLeft;\n }\n } else {\n ({width, height, top, left} = getOffset(containerNode));\n scroll.top = containerNode.scrollTop;\n scroll.left = containerNode.scrollLeft;\n totalWidth = width;\n totalHeight = height;\n }\n\n if (isWebKit() && (containerNode.tagName === 'BODY' || containerNode.tagName === 'HTML') && isPinchZoomedIn) {\n // Safari will report a non-zero scrollTop/Left for the non-scrolling body/HTML element when pinch zoomed in unlike other browsers.\n // Set to zero for parity calculations so we get consistent positioning of overlays across all browsers.\n // Also switch to visualViewport.pageTop/pageLeft so that we still accomodate for scroll positioning for body/HTML elements that are actually scrollable\n // before pinch zoom happens\n scroll.top = 0;\n scroll.left = 0;\n top = visualViewport.pageTop;\n left = visualViewport.pageLeft;\n }\n\n return {width, height, totalWidth, totalHeight, scroll, top, left};\n}\n\nfunction getScroll(node: Element): Offset {\n return {\n top: node.scrollTop,\n left: node.scrollLeft,\n width: node.scrollWidth,\n height: node.scrollHeight\n };\n}\n\n// Determines the amount of space required when moving the overlay to ensure it remains in the boundary\nfunction getDelta(\n axis: Axis,\n offset: number,\n size: number,\n // The dimensions of the boundary element that the popover is\n // positioned within (most of the time this is the <body>).\n boundaryDimensions: Dimensions,\n // The dimensions of the containing block element that the popover is\n // positioned relative to (e.g. parent with position: relative).\n // Usually this is the same as the boundary element, but if the popover\n // is portaled somewhere other than the body and has an ancestor with\n // position: relative/absolute, it will be different.\n containerDimensions: Dimensions,\n padding: number,\n containerOffsetWithBoundary: Offset\n) {\n let containerScroll = containerDimensions.scroll[axis];\n // The height/width of the boundary. Matches the axis along which we are adjusting the overlay position\n let boundarySize = boundaryDimensions[AXIS_SIZE[axis]];\n // Calculate the edges of the boundary (accomodating for the boundary padding) and the edges of the overlay.\n // Note that these values are with respect to the visual viewport (aka 0,0 is the top left of the viewport)\n let boundaryStartEdge = boundaryDimensions.scroll[AXIS[axis]] + padding;\n let boundaryEndEdge = boundarySize + boundaryDimensions.scroll[AXIS[axis]] - padding;\n let startEdgeOffset = offset - containerScroll + containerOffsetWithBoundary[axis] - boundaryDimensions[AXIS[axis]];\n let endEdgeOffset = offset - containerScroll + size + containerOffsetWithBoundary[axis] - boundaryDimensions[AXIS[axis]];\n\n // If any of the overlay edges falls outside of the boundary, shift the overlay the required amount to align one of the overlay's\n // edges with the closest boundary edge.\n if (startEdgeOffset < boundaryStartEdge) {\n return boundaryStartEdge - startEdgeOffset;\n } else if (endEdgeOffset > boundaryEndEdge) {\n return Math.max(boundaryEndEdge - endEdgeOffset, boundaryStartEdge - startEdgeOffset);\n } else {\n return 0;\n }\n}\n\nfunction getMargins(node: Element): Position {\n let style = window.getComputedStyle(node);\n return {\n top: parseInt(style.marginTop, 10) || 0,\n bottom: parseInt(style.marginBottom, 10) || 0,\n left: parseInt(style.marginLeft, 10) || 0,\n right: parseInt(style.marginRight, 10) || 0\n };\n}\n\nfunction parsePlacement(input: Placement): ParsedPlacement {\n if (PARSED_PLACEMENT_CACHE[input]) {\n return PARSED_PLACEMENT_CACHE[input];\n }\n\n let [placement, crossPlacement] = input.split(' ');\n let axis: Axis = AXIS[placement] || 'right';\n let crossAxis: Axis = CROSS_AXIS[axis];\n\n if (!AXIS[crossPlacement]) {\n crossPlacement = 'center';\n }\n\n let size = AXIS_SIZE[axis];\n let crossSize = AXIS_SIZE[crossAxis];\n PARSED_PLACEMENT_CACHE[input] = {placement, crossPlacement, axis, crossAxis, size, crossSize};\n return PARSED_PLACEMENT_CACHE[input];\n}\n\nfunction computePosition(\n childOffset: Offset,\n boundaryDimensions: Dimensions,\n overlaySize: Offset,\n placementInfo: ParsedPlacement,\n offset: number,\n crossOffset: number,\n containerOffsetWithBoundary: Offset,\n isContainerPositioned: boolean,\n arrowSize: number,\n arrowBoundaryOffset: number\n) {\n let {placement, crossPlacement, axis, crossAxis, size, crossSize} = placementInfo;\n let position: Position = {};\n\n // button position\n position[crossAxis] = childOffset[crossAxis];\n if (crossPlacement === 'center') {\n // + (button size / 2) - (overlay size / 2)\n // at this point the overlay center should match the button center\n position[crossAxis] += (childOffset[crossSize] - overlaySize[crossSize]) / 2;\n } else if (crossPlacement !== crossAxis) {\n // + (button size) - (overlay size)\n // at this point the overlay bottom should match the button bottom\n position[crossAxis] += (childOffset[crossSize] - overlaySize[crossSize]);\n }/* else {\n the overlay top should match the button top\n } */\n\n position[crossAxis] += crossOffset;\n\n // overlay top overlapping arrow with button bottom\n const minPosition = childOffset[crossAxis] - overlaySize[crossSize] + arrowSize + arrowBoundaryOffset;\n // overlay bottom overlapping arrow with button top\n const maxPosition = childOffset[crossAxis] + childOffset[crossSize] - arrowSize - arrowBoundaryOffset;\n position[crossAxis] = clamp(position[crossAxis], minPosition, maxPosition);\n\n // 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.\n if (placement === axis) {\n // If the container is positioned (non-static), then we use the container's actual\n // height, as `bottom` will be relative to this height. But if the container is static,\n // then it can only be the `document.body`, and `bottom` will be relative to _its_\n // container, which should be as large as boundaryDimensions.\n const containerHeight = (isContainerPositioned ? containerOffsetWithBoundary[size] : boundaryDimensions[TOTAL_SIZE[size]]);\n position[FLIPPED_DIRECTION[axis]] = Math.floor(containerHeight - childOffset[axis] + offset);\n } else {\n position[axis] = Math.floor(childOffset[axis] + childOffset[size] + offset);\n }\n return position;\n}\n\nfunction getMaxHeight(\n position: Position,\n boundaryDimensions: Dimensions,\n containerOffsetWithBoundary: Offset,\n isContainerPositioned: boolean,\n margins: Position,\n padding: number,\n overlayHeight: number,\n heightGrowthDirection: HeightGrowthDirection\n) {\n const containerHeight = (isContainerPositioned ? containerOffsetWithBoundary.height : boundaryDimensions[TOTAL_SIZE.height]);\n // 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\n // used in computePosition.\n let overlayTop = position.top != null ? containerOffsetWithBoundary.top + position.top : containerOffsetWithBoundary.top + (containerHeight - position.bottom - overlayHeight);\n let maxHeight = heightGrowthDirection !== 'top' ?\n // We want the distance between the top of the overlay to the bottom of the boundary\n Math.max(0,\n (boundaryDimensions.height + boundaryDimensions.top + boundaryDimensions.scroll.top) // this is the bottom of the boundary\n - overlayTop // this is the top of the overlay\n - (margins.top + margins.bottom + padding) // save additional space for margin and padding\n )\n // We want the distance between the bottom of the overlay to the top of the boundary\n : Math.max(0,\n (overlayTop + overlayHeight) // this is the bottom of the overlay\n - (boundaryDimensions.top + boundaryDimensions.scroll.top) // this is the top of the boundary\n - (margins.top + margins.bottom + padding) // save additional space for margin and padding\n );\n return Math.min(boundaryDimensions.height - (padding * 2), maxHeight);\n}\n\nfunction getAvailableSpace(\n boundaryDimensions: Dimensions,\n containerOffsetWithBoundary: Offset,\n childOffset: Offset,\n margins: Position,\n padding: number,\n placementInfo: ParsedPlacement\n) {\n let {placement, axis, size} = placementInfo;\n if (placement === axis) {\n return Math.max(0, childOffset[axis] - boundaryDimensions[axis] - boundaryDimensions.scroll[axis] + containerOffsetWithBoundary[axis] - margins[axis] - margins[FLIPPED_DIRECTION[axis]] - padding);\n }\n\n return Math.max(0, boundaryDimensions[size] + boundaryDimensions[axis] + boundaryDimensions.scroll[axis] - containerOffsetWithBoundary[axis] - childOffset[axis] - childOffset[size] - margins[axis] - margins[FLIPPED_DIRECTION[axis]] - padding);\n}\n\nexport function calculatePositionInternal(\n placementInput: Placement,\n childOffset: Offset,\n overlaySize: Offset,\n scrollSize: Offset,\n margins: Position,\n padding: number,\n flip: boolean,\n boundaryDimensions: Dimensions,\n containerDimensions: Dimensions,\n containerOffsetWithBoundary: Offset,\n offset: number,\n crossOffset: number,\n isContainerPositioned: boolean,\n userSetMaxHeight: number | undefined,\n arrowSize: number,\n arrowBoundaryOffset: number\n): PositionResult {\n let placementInfo = parsePlacement(placementInput);\n let {size, crossAxis, crossSize, placement, crossPlacement} = placementInfo;\n let position = computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);\n let normalizedOffset = offset;\n let space = getAvailableSpace(\n boundaryDimensions,\n containerOffsetWithBoundary,\n childOffset,\n margins,\n padding + offset,\n placementInfo\n );\n\n // Check if the scroll size of the overlay is greater than the available space to determine if we need to flip\n if (flip && scrollSize[size] > space) {\n let flippedPlacementInfo = parsePlacement(`${FLIPPED_DIRECTION[placement]} ${crossPlacement}` as Placement);\n let flippedPosition = computePosition(childOffset, boundaryDimensions, overlaySize, flippedPlacementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);\n let flippedSpace = getAvailableSpace(\n boundaryDimensions,\n containerOffsetWithBoundary,\n childOffset,\n margins,\n padding + offset,\n flippedPlacementInfo\n );\n\n // If the available space for the flipped position is greater than the original available space, flip.\n if (flippedSpace > space) {\n placementInfo = flippedPlacementInfo;\n position = flippedPosition;\n normalizedOffset = offset;\n }\n }\n\n // Determine the direction the height of the overlay can grow so that we can choose how to calculate the max height\n let heightGrowthDirection: HeightGrowthDirection = 'bottom';\n if (placementInfo.axis === 'top') {\n if (placementInfo.placement === 'top') {\n heightGrowthDirection = 'top';\n } else if (placementInfo.placement === 'bottom') {\n heightGrowthDirection = 'bottom';\n }\n } else if (placementInfo.crossAxis === 'top') {\n if (placementInfo.crossPlacement === 'top') {\n heightGrowthDirection = 'bottom';\n } else if (placementInfo.crossPlacement === 'bottom') {\n heightGrowthDirection = 'top';\n }\n }\n\n let delta = getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);\n position[crossAxis] += delta;\n\n let maxHeight = getMaxHeight(\n position,\n boundaryDimensions,\n containerOffsetWithBoundary,\n isContainerPositioned,\n margins,\n padding,\n overlaySize.height,\n heightGrowthDirection\n );\n\n if (userSetMaxHeight && userSetMaxHeight < maxHeight) {\n maxHeight = userSetMaxHeight;\n }\n\n overlaySize.height = Math.min(overlaySize.height, maxHeight);\n\n position = computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, normalizedOffset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);\n delta = getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);\n position[crossAxis] += delta;\n\n let arrowPosition: Position = {};\n\n // All values are transformed so that 0 is at the top/left of the overlay depending on the orientation\n // Prefer the arrow being in the center of the trigger/overlay anchor element\n let preferredArrowPosition = childOffset[crossAxis] + .5 * childOffset[crossSize] - position[crossAxis];\n\n // Min/Max position limits for the arrow with respect to the overlay\n const arrowMinPosition = arrowSize / 2 + arrowBoundaryOffset;\n const arrowMaxPosition = overlaySize[crossSize] - (arrowSize / 2) - arrowBoundaryOffset;\n\n // Min/Max position limits for the arrow with respect to the trigger/overlay anchor element\n const arrowOverlappingChildMinEdge = childOffset[crossAxis] - position[crossAxis] + (arrowSize / 2);\n const arrowOverlappingChildMaxEdge = childOffset[crossAxis] + childOffset[crossSize] - position[crossAxis] - (arrowSize / 2);\n\n // Clamp the arrow positioning so that it always is within the bounds of the anchor and the overlay\n const arrowPositionOverlappingChild = clamp(preferredArrowPosition, arrowOverlappingChildMinEdge, arrowOverlappingChildMaxEdge);\n arrowPosition[crossAxis] = clamp(arrowPositionOverlappingChild, arrowMinPosition, arrowMaxPosition);\n\n return {\n position,\n maxHeight: maxHeight,\n arrowOffsetLeft: arrowPosition.left,\n arrowOffsetTop: arrowPosition.top,\n placement: placementInfo.placement\n };\n}\n\n/**\n * Determines where to place the overlay with regards to the target and the position of an optional indicator.\n */\nexport function calculatePosition(opts: PositionOpts): PositionResult {\n let {\n placement,\n targetNode,\n overlayNode,\n scrollNode,\n padding,\n shouldFlip,\n boundaryElement,\n offset,\n crossOffset,\n maxHeight,\n arrowSize = 0,\n arrowBoundaryOffset = 0\n } = opts;\n\n let container = overlayNode instanceof HTMLElement ? getContainingBlock(overlayNode) : document.documentElement;\n let isViewportContainer = container === document.documentElement;\n const containerPositionStyle = window.getComputedStyle(container).position;\n let isContainerPositioned = !!containerPositionStyle && containerPositionStyle !== 'static';\n let childOffset: Offset = isViewportContainer ? getOffset(targetNode) : getPosition(targetNode, container);\n\n if (!isViewportContainer) {\n let {marginTop, marginLeft} = window.getComputedStyle(targetNode);\n childOffset.top += parseInt(marginTop, 10) || 0;\n childOffset.left += parseInt(marginLeft, 10) || 0;\n }\n\n let overlaySize: Offset = getOffset(overlayNode);\n let margins = getMargins(overlayNode);\n overlaySize.width += margins.left + margins.right;\n overlaySize.height += margins.top + margins.bottom;\n\n let scrollSize = getScroll(scrollNode);\n let boundaryDimensions = getContainerDimensions(boundaryElement);\n let containerDimensions = getContainerDimensions(container);\n // If the container is the HTML element wrapping the body element, the retrieved scrollTop/scrollLeft will be equal to the\n // 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\n // by the container scroll since they are essentially the same containing element and thus in the same coordinate system\n let containerOffsetWithBoundary: Offset = boundaryElement.tagName === 'BODY' ? getOffset(container) : getPosition(container, boundaryElement);\n if (container.tagName === 'HTML' && boundaryElement.tagName === 'BODY') {\n containerDimensions.scroll.top = 0;\n containerDimensions.scroll.left = 0;\n }\n\n return calculatePositionInternal(\n placement,\n childOffset,\n overlaySize,\n scrollSize,\n margins,\n padding,\n shouldFlip,\n boundaryDimensions,\n containerDimensions,\n containerOffsetWithBoundary,\n offset,\n crossOffset,\n isContainerPositioned,\n maxHeight,\n arrowSize,\n arrowBoundaryOffset\n );\n}\n\nfunction getOffset(node: Element): Offset {\n let {top, left, width, height} = node.getBoundingClientRect();\n let {scrollTop, scrollLeft, clientTop, clientLeft} = document.documentElement;\n return {\n top: top + scrollTop - clientTop,\n left: left + scrollLeft - clientLeft,\n width,\n height\n };\n}\n\nfunction getPosition(node: Element, parent: Element): Offset {\n let style = window.getComputedStyle(node);\n let offset: Offset;\n if (style.position === 'fixed') {\n let {top, left, width, height} = node.getBoundingClientRect();\n offset = {top, left, width, height};\n } else {\n offset = getOffset(node);\n let parentOffset = getOffset(parent);\n let parentStyle = window.getComputedStyle(parent);\n parentOffset.top += (parseInt(parentStyle.borderTopWidth, 10) || 0) - parent.scrollTop;\n parentOffset.left += (parseInt(parentStyle.borderLeftWidth, 10) || 0) - parent.scrollLeft;\n offset.top -= parentOffset.top;\n offset.left -= parentOffset.left;\n }\n\n offset.top -= parseInt(style.marginTop, 10) || 0;\n offset.left -= parseInt(style.marginLeft, 10) || 0;\n return offset;\n}\n\n// Returns the containing block of an element, which is the element that\n// this element will be positioned relative to.\n// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block\nfunction getContainingBlock(node: HTMLElement): Element {\n // The offsetParent of an element in most cases equals the containing block.\n // https://w3c.github.io/csswg-drafts/cssom-view/#dom-htmlelement-offsetparent\n let offsetParent = node.offsetParent;\n\n // The offsetParent algorithm terminates at the document body,\n // even if the body is not a containing block. Double check that\n // and use the documentElement if so.\n if (\n offsetParent &&\n offsetParent === document.body &&\n window.getComputedStyle(offsetParent).position === 'static' &&\n !isContainingBlock(offsetParent)\n ) {\n offsetParent = document.documentElement;\n }\n\n // TODO(later): handle table elements?\n\n // The offsetParent can be null if the element has position: fixed, or a few other cases.\n // We have to walk up the tree manually in this case because fixed positioned elements\n // are still positioned relative to their containing block, which is not always the viewport.\n if (offsetParent == null) {\n offsetParent = node.parentElement;\n while (offsetParent && !isContainingBlock(offsetParent)) {\n offsetParent = offsetParent.parentElement;\n }\n }\n\n // Fall back to the viewport.\n return offsetParent || document.documentElement;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\nfunction isContainingBlock(node: Element): boolean {\n let style = window.getComputedStyle(node);\n return (\n style.transform !== 'none' ||\n /transform|perspective/.test(style.willChange) ||\n style.filter !== 'none' ||\n style.contain === 'paint' ||\n // @ts-ignore\n ('backdropFilter' in style && style.backdropFilter !== 'none') ||\n // @ts-ignore\n ('WebkitBackdropFilter' in style && style.WebkitBackdropFilter !== 'none')\n );\n}\n"],"names":[],"version":3,"file":"calculatePosition.main.js.map"}