@react-aria/overlays 3.21.1 → 3.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/DismissButton.main.js +51 -0
  2. package/dist/DismissButton.main.js.map +1 -0
  3. package/dist/DismissButton.mjs +46 -0
  4. package/dist/DismissButton.module.js +46 -0
  5. package/dist/DismissButton.module.js.map +1 -0
  6. package/dist/Overlay.main.js +73 -0
  7. package/dist/Overlay.main.js.map +1 -0
  8. package/dist/Overlay.mjs +63 -0
  9. package/dist/Overlay.module.js +63 -0
  10. package/dist/Overlay.module.js.map +1 -0
  11. package/dist/PortalProvider.main.js +41 -0
  12. package/dist/PortalProvider.main.js.map +1 -0
  13. package/dist/PortalProvider.mjs +31 -0
  14. package/dist/PortalProvider.module.js +31 -0
  15. package/dist/PortalProvider.module.js.map +1 -0
  16. package/dist/ar-AE.mjs +1 -1
  17. package/dist/ariaHideOutside.main.js +121 -0
  18. package/dist/ariaHideOutside.main.js.map +1 -0
  19. package/dist/ariaHideOutside.mjs +116 -0
  20. package/dist/ariaHideOutside.module.js +116 -0
  21. package/dist/ariaHideOutside.module.js.map +1 -0
  22. package/dist/bg-BG.mjs +1 -1
  23. package/dist/calculatePosition.main.js +355 -0
  24. package/dist/calculatePosition.main.js.map +1 -0
  25. package/dist/calculatePosition.mjs +350 -0
  26. package/dist/calculatePosition.module.js +350 -0
  27. package/dist/calculatePosition.module.js.map +1 -0
  28. package/dist/cs-CZ.mjs +1 -1
  29. package/dist/da-DK.mjs +1 -1
  30. package/dist/de-DE.mjs +1 -1
  31. package/dist/el-GR.mjs +1 -1
  32. package/dist/en-US.mjs +1 -1
  33. package/dist/es-ES.mjs +1 -1
  34. package/dist/et-EE.mjs +1 -1
  35. package/dist/fi-FI.mjs +1 -1
  36. package/dist/fr-FR.mjs +1 -1
  37. package/dist/he-IL.mjs +1 -1
  38. package/dist/hr-HR.mjs +1 -1
  39. package/dist/hu-HU.mjs +1 -1
  40. package/dist/import.mjs +12 -1397
  41. package/dist/intlStrings.main.js +108 -0
  42. package/dist/intlStrings.main.js.map +1 -0
  43. package/dist/intlStrings.mjs +110 -0
  44. package/dist/intlStrings.module.js +110 -0
  45. package/dist/intlStrings.module.js.map +1 -0
  46. package/dist/it-IT.mjs +1 -1
  47. package/dist/ja-JP.mjs +1 -1
  48. package/dist/ko-KR.mjs +1 -1
  49. package/dist/lt-LT.mjs +1 -1
  50. package/dist/lv-LV.mjs +1 -1
  51. package/dist/main.js +28 -1411
  52. package/dist/main.js.map +1 -1
  53. package/dist/module.js +12 -1397
  54. package/dist/module.js.map +1 -1
  55. package/dist/nb-NO.mjs +1 -1
  56. package/dist/nl-NL.mjs +1 -1
  57. package/dist/pl-PL.mjs +1 -1
  58. package/dist/pt-BR.mjs +1 -1
  59. package/dist/pt-PT.mjs +1 -1
  60. package/dist/ro-RO.mjs +1 -1
  61. package/dist/ru-RU.mjs +1 -1
  62. package/dist/sk-SK.mjs +1 -1
  63. package/dist/sl-SI.mjs +1 -1
  64. package/dist/sr-SP.mjs +1 -1
  65. package/dist/sv-SE.mjs +1 -1
  66. package/dist/tr-TR.mjs +1 -1
  67. package/dist/types.d.ts +8 -1
  68. package/dist/types.d.ts.map +1 -1
  69. package/dist/uk-UA.mjs +1 -1
  70. package/dist/useCloseOnScroll.main.js +46 -0
  71. package/dist/useCloseOnScroll.main.js.map +1 -0
  72. package/dist/useCloseOnScroll.mjs +40 -0
  73. package/dist/useCloseOnScroll.module.js +40 -0
  74. package/dist/useCloseOnScroll.module.js.map +1 -0
  75. package/dist/useModal.main.js +114 -0
  76. package/dist/useModal.main.js.map +1 -0
  77. package/dist/useModal.mjs +101 -0
  78. package/dist/useModal.module.js +101 -0
  79. package/dist/useModal.module.js.map +1 -0
  80. package/dist/useModalOverlay.main.js +55 -0
  81. package/dist/useModalOverlay.main.js.map +1 -0
  82. package/dist/useModalOverlay.mjs +50 -0
  83. package/dist/useModalOverlay.module.js +50 -0
  84. package/dist/useModalOverlay.module.js.map +1 -0
  85. package/dist/useOverlay.main.js +105 -0
  86. package/dist/useOverlay.main.js.map +1 -0
  87. package/dist/useOverlay.mjs +100 -0
  88. package/dist/useOverlay.module.js +100 -0
  89. package/dist/useOverlay.module.js.map +1 -0
  90. package/dist/useOverlayPosition.main.js +181 -0
  91. package/dist/useOverlayPosition.main.js.map +1 -0
  92. package/dist/useOverlayPosition.mjs +176 -0
  93. package/dist/useOverlayPosition.module.js +176 -0
  94. package/dist/useOverlayPosition.module.js.map +1 -0
  95. package/dist/useOverlayTrigger.main.js +54 -0
  96. package/dist/useOverlayTrigger.main.js.map +1 -0
  97. package/dist/useOverlayTrigger.mjs +49 -0
  98. package/dist/useOverlayTrigger.module.js +49 -0
  99. package/dist/useOverlayTrigger.module.js.map +1 -0
  100. package/dist/usePopover.main.js +66 -0
  101. package/dist/usePopover.main.js.map +1 -0
  102. package/dist/usePopover.mjs +61 -0
  103. package/dist/usePopover.module.js +61 -0
  104. package/dist/usePopover.module.js.map +1 -0
  105. package/dist/usePreventScroll.main.js +226 -0
  106. package/dist/usePreventScroll.main.js.map +1 -0
  107. package/dist/usePreventScroll.mjs +221 -0
  108. package/dist/usePreventScroll.module.js +221 -0
  109. package/dist/usePreventScroll.module.js.map +1 -0
  110. package/dist/zh-CN.mjs +1 -1
  111. package/dist/zh-TW.mjs +1 -1
  112. package/package.json +12 -12
  113. package/src/Overlay.tsx +6 -0
  114. package/src/PortalProvider.tsx +34 -0
  115. package/src/index.ts +1 -0
  116. package/src/useModalOverlay.ts +2 -2
  117. package/src/useOverlay.ts +1 -1
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAED,iFAAiF;AACjF,uFAAuF;AACvF,IAAI,oCAAc,IAAI;AACtB,IAAI,sCAAgB,EAAE;AAUf,SAAS,0CAAgB,OAAkB,EAAE,OAAO,SAAS,IAAI;IACtE,IAAI,eAAe,IAAI,IAAa;IACpC,IAAI,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AC,oCAAc,MAAM,GAAG,EAAE,CAAC,OAAO;QAEnD,OACE,oCAAc,MAAM,CAAC,oCAAc,OAAO,CAAC,kBAAkB;IAEjE;AACF","sources":["packages/@react-aria/overlays/src/ariaHideOutside.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\n// Keeps a ref count of all hidden elements. Added to when hiding an element, and\n// subtracted from when showing it again. When it reaches zero, aria-hidden is removed.\nlet refCountMap = new WeakMap<Element, number>();\nlet observerStack = [];\n\n/**\n * Hides all elements in the DOM outside the given targets from screen readers using aria-hidden,\n * and returns a function to revert these changes. In addition, changes to the DOM are watched\n * and new elements outside the targets are automatically hidden.\n * @param targets - The elements that should remain visible.\n * @param root - Nothing will be hidden above this element.\n * @returns - A function to restore all hidden elements.\n */\nexport function ariaHideOutside(targets: Element[], root = document.body) {\n let visibleNodes = new Set<Element>(targets);\n let hiddenNodes = new Set<Element>();\n\n let walk = (root: Element) => {\n // Keep live announcer and top layer elements (e.g. toasts) visible.\n for (let element of root.querySelectorAll('[data-live-announcer], [data-react-aria-top-layer]')) {\n visibleNodes.add(element);\n }\n\n let acceptNode = (node: Element) => {\n // Skip this node and its children if it is one of the target nodes, or a live announcer.\n // Also skip children of already hidden nodes, as aria-hidden is recursive. An exception is\n // made for elements with role=\"row\" since VoiceOver on iOS has issues hiding elements with role=\"row\".\n // For that case we want to hide the cells inside as well (https://bugs.webkit.org/show_bug.cgi?id=222623).\n if (\n visibleNodes.has(node) ||\n (hiddenNodes.has(node.parentElement) && node.parentElement.getAttribute('role') !== 'row')\n ) {\n return NodeFilter.FILTER_REJECT;\n }\n\n // Skip this node but continue to children if one of the targets is inside the node.\n for (let target of visibleNodes) {\n if (node.contains(target)) {\n return NodeFilter.FILTER_SKIP;\n }\n }\n\n return NodeFilter.FILTER_ACCEPT;\n };\n\n let walker = document.createTreeWalker(\n root,\n NodeFilter.SHOW_ELEMENT,\n {acceptNode}\n );\n\n // TreeWalker does not include the root.\n let acceptRoot = acceptNode(root);\n if (acceptRoot === NodeFilter.FILTER_ACCEPT) {\n hide(root);\n }\n\n if (acceptRoot !== NodeFilter.FILTER_REJECT) {\n let node = walker.nextNode() as Element;\n while (node != null) {\n hide(node);\n node = walker.nextNode() as Element;\n }\n }\n };\n\n let hide = (node: Element) => {\n let refCount = refCountMap.get(node) ?? 0;\n\n // If already aria-hidden, and the ref count is zero, then this element\n // was already hidden and there's nothing for us to do.\n if (node.getAttribute('aria-hidden') === 'true' && refCount === 0) {\n return;\n }\n\n if (refCount === 0) {\n node.setAttribute('aria-hidden', 'true');\n }\n\n hiddenNodes.add(node);\n refCountMap.set(node, refCount + 1);\n };\n\n // If there is already a MutationObserver listening from a previous call,\n // disconnect it so the new on takes over.\n if (observerStack.length) {\n observerStack[observerStack.length - 1].disconnect();\n }\n\n walk(root);\n\n let observer = new MutationObserver(changes => {\n for (let change of changes) {\n if (change.type !== 'childList' || change.addedNodes.length === 0) {\n continue;\n }\n\n // If the parent element of the added nodes is not within one of the targets,\n // and not already inside a hidden node, hide all of the new children.\n if (![...visibleNodes, ...hiddenNodes].some(node => node.contains(change.target))) {\n for (let node of change.removedNodes) {\n if (node instanceof Element) {\n visibleNodes.delete(node);\n hiddenNodes.delete(node);\n }\n }\n\n for (let node of change.addedNodes) {\n if (\n (node instanceof HTMLElement || node instanceof SVGElement) &&\n (node.dataset.liveAnnouncer === 'true' || node.dataset.reactAriaTopLayer === 'true')\n ) {\n visibleNodes.add(node);\n } else if (node instanceof Element) {\n walk(node);\n }\n }\n }\n }\n });\n\n observer.observe(root, {childList: true, subtree: true});\n\n let observerWrapper = {\n observe() {\n observer.observe(root, {childList: true, subtree: true});\n },\n disconnect() {\n observer.disconnect();\n }\n };\n\n observerStack.push(observerWrapper);\n\n return () => {\n observer.disconnect();\n\n for (let node of hiddenNodes) {\n let count = refCountMap.get(node);\n if (count === 1) {\n node.removeAttribute('aria-hidden');\n refCountMap.delete(node);\n } else {\n refCountMap.set(node, count - 1);\n }\n }\n\n // Remove this observer from the stack, and start the previous one.\n if (observerWrapper === observerStack[observerStack.length - 1]) {\n observerStack.pop();\n if (observerStack.length) {\n observerStack[observerStack.length - 1].observe();\n }\n } else {\n observerStack.splice(observerStack.indexOf(observerWrapper), 1);\n }\n };\n}\n"],"names":[],"version":3,"file":"ariaHideOutside.main.js.map"}
@@ -0,0 +1,116 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ // Keeps a ref count of all hidden elements. Added to when hiding an element, and
12
+ // subtracted from when showing it again. When it reaches zero, aria-hidden is removed.
13
+ let $5e3802645cc19319$var$refCountMap = new WeakMap();
14
+ let $5e3802645cc19319$var$observerStack = [];
15
+ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body) {
16
+ let visibleNodes = new Set(targets);
17
+ let hiddenNodes = new Set();
18
+ let walk = (root)=>{
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);
21
+ let acceptNode = (node)=>{
22
+ // Skip this node and its children if it is one of the target nodes, or a live announcer.
23
+ // Also skip children of already hidden nodes, as aria-hidden is recursive. An exception is
24
+ // made for elements with role="row" since VoiceOver on iOS has issues hiding elements with role="row".
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;
27
+ // Skip this node but continue to children if one of the targets is inside the node.
28
+ for (let target of visibleNodes){
29
+ if (node.contains(target)) return NodeFilter.FILTER_SKIP;
30
+ }
31
+ return NodeFilter.FILTER_ACCEPT;
32
+ };
33
+ let walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
34
+ acceptNode: acceptNode
35
+ });
36
+ // TreeWalker does not include the root.
37
+ let acceptRoot = acceptNode(root);
38
+ if (acceptRoot === NodeFilter.FILTER_ACCEPT) hide(root);
39
+ if (acceptRoot !== NodeFilter.FILTER_REJECT) {
40
+ let node = walker.nextNode();
41
+ while(node != null){
42
+ hide(node);
43
+ node = walker.nextNode();
44
+ }
45
+ }
46
+ };
47
+ let hide = (node)=>{
48
+ var _refCountMap_get;
49
+ let refCount = (_refCountMap_get = $5e3802645cc19319$var$refCountMap.get(node)) !== null && _refCountMap_get !== void 0 ? _refCountMap_get : 0;
50
+ // If already aria-hidden, and the ref count is zero, then this element
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");
54
+ hiddenNodes.add(node);
55
+ $5e3802645cc19319$var$refCountMap.set(node, refCount + 1);
56
+ };
57
+ // If there is already a MutationObserver listening from a previous call,
58
+ // disconnect it so the new on takes over.
59
+ if ($5e3802645cc19319$var$observerStack.length) $5e3802645cc19319$var$observerStack[$5e3802645cc19319$var$observerStack.length - 1].disconnect();
60
+ walk(root);
61
+ let observer = new MutationObserver((changes)=>{
62
+ for (let change of changes){
63
+ if (change.type !== "childList" || change.addedNodes.length === 0) continue;
64
+ // If the parent element of the added nodes is not within one of the targets,
65
+ // and not already inside a hidden node, hide all of the new children.
66
+ if (![
67
+ ...visibleNodes,
68
+ ...hiddenNodes
69
+ ].some((node)=>node.contains(change.target))) {
70
+ for (let node of change.removedNodes)if (node instanceof Element) {
71
+ visibleNodes.delete(node);
72
+ hiddenNodes.delete(node);
73
+ }
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);
76
+ else if (node instanceof Element) walk(node);
77
+ }
78
+ }
79
+ }
80
+ });
81
+ observer.observe(root, {
82
+ childList: true,
83
+ subtree: true
84
+ });
85
+ let observerWrapper = {
86
+ observe () {
87
+ observer.observe(root, {
88
+ childList: true,
89
+ subtree: true
90
+ });
91
+ },
92
+ disconnect () {
93
+ observer.disconnect();
94
+ }
95
+ };
96
+ $5e3802645cc19319$var$observerStack.push(observerWrapper);
97
+ return ()=>{
98
+ observer.disconnect();
99
+ for (let node of hiddenNodes){
100
+ let count = $5e3802645cc19319$var$refCountMap.get(node);
101
+ if (count === 1) {
102
+ node.removeAttribute("aria-hidden");
103
+ $5e3802645cc19319$var$refCountMap.delete(node);
104
+ } else $5e3802645cc19319$var$refCountMap.set(node, count - 1);
105
+ }
106
+ // Remove this observer from the stack, and start the previous one.
107
+ if (observerWrapper === $5e3802645cc19319$var$observerStack[$5e3802645cc19319$var$observerStack.length - 1]) {
108
+ $5e3802645cc19319$var$observerStack.pop();
109
+ if ($5e3802645cc19319$var$observerStack.length) $5e3802645cc19319$var$observerStack[$5e3802645cc19319$var$observerStack.length - 1].observe();
110
+ } else $5e3802645cc19319$var$observerStack.splice($5e3802645cc19319$var$observerStack.indexOf(observerWrapper), 1);
111
+ };
112
+ }
113
+
114
+
115
+ export {$5e3802645cc19319$export$1c3ebcada18427bf as ariaHideOutside};
116
+ //# sourceMappingURL=ariaHideOutside.mjs.map
@@ -0,0 +1,116 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ // Keeps a ref count of all hidden elements. Added to when hiding an element, and
12
+ // subtracted from when showing it again. When it reaches zero, aria-hidden is removed.
13
+ let $5e3802645cc19319$var$refCountMap = new WeakMap();
14
+ let $5e3802645cc19319$var$observerStack = [];
15
+ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body) {
16
+ let visibleNodes = new Set(targets);
17
+ let hiddenNodes = new Set();
18
+ let walk = (root)=>{
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);
21
+ let acceptNode = (node)=>{
22
+ // Skip this node and its children if it is one of the target nodes, or a live announcer.
23
+ // Also skip children of already hidden nodes, as aria-hidden is recursive. An exception is
24
+ // made for elements with role="row" since VoiceOver on iOS has issues hiding elements with role="row".
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;
27
+ // Skip this node but continue to children if one of the targets is inside the node.
28
+ for (let target of visibleNodes){
29
+ if (node.contains(target)) return NodeFilter.FILTER_SKIP;
30
+ }
31
+ return NodeFilter.FILTER_ACCEPT;
32
+ };
33
+ let walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
34
+ acceptNode: acceptNode
35
+ });
36
+ // TreeWalker does not include the root.
37
+ let acceptRoot = acceptNode(root);
38
+ if (acceptRoot === NodeFilter.FILTER_ACCEPT) hide(root);
39
+ if (acceptRoot !== NodeFilter.FILTER_REJECT) {
40
+ let node = walker.nextNode();
41
+ while(node != null){
42
+ hide(node);
43
+ node = walker.nextNode();
44
+ }
45
+ }
46
+ };
47
+ let hide = (node)=>{
48
+ var _refCountMap_get;
49
+ let refCount = (_refCountMap_get = $5e3802645cc19319$var$refCountMap.get(node)) !== null && _refCountMap_get !== void 0 ? _refCountMap_get : 0;
50
+ // If already aria-hidden, and the ref count is zero, then this element
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");
54
+ hiddenNodes.add(node);
55
+ $5e3802645cc19319$var$refCountMap.set(node, refCount + 1);
56
+ };
57
+ // If there is already a MutationObserver listening from a previous call,
58
+ // disconnect it so the new on takes over.
59
+ if ($5e3802645cc19319$var$observerStack.length) $5e3802645cc19319$var$observerStack[$5e3802645cc19319$var$observerStack.length - 1].disconnect();
60
+ walk(root);
61
+ let observer = new MutationObserver((changes)=>{
62
+ for (let change of changes){
63
+ if (change.type !== "childList" || change.addedNodes.length === 0) continue;
64
+ // If the parent element of the added nodes is not within one of the targets,
65
+ // and not already inside a hidden node, hide all of the new children.
66
+ if (![
67
+ ...visibleNodes,
68
+ ...hiddenNodes
69
+ ].some((node)=>node.contains(change.target))) {
70
+ for (let node of change.removedNodes)if (node instanceof Element) {
71
+ visibleNodes.delete(node);
72
+ hiddenNodes.delete(node);
73
+ }
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);
76
+ else if (node instanceof Element) walk(node);
77
+ }
78
+ }
79
+ }
80
+ });
81
+ observer.observe(root, {
82
+ childList: true,
83
+ subtree: true
84
+ });
85
+ let observerWrapper = {
86
+ observe () {
87
+ observer.observe(root, {
88
+ childList: true,
89
+ subtree: true
90
+ });
91
+ },
92
+ disconnect () {
93
+ observer.disconnect();
94
+ }
95
+ };
96
+ $5e3802645cc19319$var$observerStack.push(observerWrapper);
97
+ return ()=>{
98
+ observer.disconnect();
99
+ for (let node of hiddenNodes){
100
+ let count = $5e3802645cc19319$var$refCountMap.get(node);
101
+ if (count === 1) {
102
+ node.removeAttribute("aria-hidden");
103
+ $5e3802645cc19319$var$refCountMap.delete(node);
104
+ } else $5e3802645cc19319$var$refCountMap.set(node, count - 1);
105
+ }
106
+ // Remove this observer from the stack, and start the previous one.
107
+ if (observerWrapper === $5e3802645cc19319$var$observerStack[$5e3802645cc19319$var$observerStack.length - 1]) {
108
+ $5e3802645cc19319$var$observerStack.pop();
109
+ if ($5e3802645cc19319$var$observerStack.length) $5e3802645cc19319$var$observerStack[$5e3802645cc19319$var$observerStack.length - 1].observe();
110
+ } else $5e3802645cc19319$var$observerStack.splice($5e3802645cc19319$var$observerStack.indexOf(observerWrapper), 1);
111
+ };
112
+ }
113
+
114
+
115
+ export {$5e3802645cc19319$export$1c3ebcada18427bf as ariaHideOutside};
116
+ //# sourceMappingURL=ariaHideOutside.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAED,iFAAiF;AACjF,uFAAuF;AACvF,IAAI,oCAAc,IAAI;AACtB,IAAI,sCAAgB,EAAE;AAUf,SAAS,0CAAgB,OAAkB,EAAE,OAAO,SAAS,IAAI;IACtE,IAAI,eAAe,IAAI,IAAa;IACpC,IAAI,cAAc,IAAI;IAEtB,IAAI,OAAO,CAAC;QACV,oEAAoE;QACpE,KAAK,IAAI,WAAW,KAAK,gBAAgB,CAAC,sDACxC,aAAa,GAAG,CAAC;QAGnB,IAAI,aAAa,CAAC;YAChB,yFAAyF;YACzF,2FAA2F;YAC3F,uGAAuG;YACvG,2GAA2G;YAC3G,IACE,aAAa,GAAG,CAAC,SAChB,YAAY,GAAG,CAAC,KAAK,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gBACjF,KAAK,IAAI,QAAQ,OAAO,YAAY,CAClC,IAAI,gBAAgB,SAAS;oBAC3B,aAAa,MAAM,CAAC;oBACpB,YAAY,MAAM,CAAC;gBACrB;gBAGF,KAAK,IAAI,QAAQ,OAAO,UAAU,CAAE;oBAClC,IACE,AAAC,CAAA,gBAAgB,eAAe,gBAAgB,UAAS,KACxD,CAAA,KAAK,OAAO,CAAC,aAAa,KAAK,UAAU,KAAK,OAAO,CAAC,iBAAiB,KAAK,MAAK,GAElF,aAAa,GAAG,CAAC;yBACZ,IAAI,gBAAgB,SACzB,KAAK;gBAET;YACF;QACF;IACF;IAEA,SAAS,OAAO,CAAC,MAAM;QAAC,WAAW;QAAM,SAAS;IAAI;IAEtD,IAAI,kBAAkB;QACpB;YACE,SAAS,OAAO,CAAC,MAAM;gBAAC,WAAW;gBAAM,SAAS;YAAI;QACxD;QACA;YACE,SAAS,UAAU;QACrB;IACF;IAEA,oCAAc,IAAI,CAAC;IAEnB,OAAO;QACL,SAAS,UAAU;QAEnB,KAAK,IAAI,QAAQ,YAAa;YAC5B,IAAI,QAAQ,kCAAY,GAAG,CAAC;YAC5B,IAAI,UAAU,GAAG;gBACf,KAAK,eAAe,CAAC;gBACrB,kCAAY,MAAM,CAAC;YACrB,OACE,kCAAY,GAAG,CAAC,MAAM,QAAQ;QAElC;QAEA,mEAAmE;QACnE,IAAI,oBAAoB,mCAAa,CAAC,oCAAc,MAAM,GAAG,EAAE,EAAE;YAC/D,oCAAc,GAAG;YACjB,IAAI,oCAAc,MAAM,EACtB,mCAAa,CAAC,oCAAc,MAAM,GAAG,EAAE,CAAC,OAAO;QAEnD,OACE,oCAAc,MAAM,CAAC,oCAAc,OAAO,CAAC,kBAAkB;IAEjE;AACF","sources":["packages/@react-aria/overlays/src/ariaHideOutside.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\n// Keeps a ref count of all hidden elements. Added to when hiding an element, and\n// subtracted from when showing it again. When it reaches zero, aria-hidden is removed.\nlet refCountMap = new WeakMap<Element, number>();\nlet observerStack = [];\n\n/**\n * Hides all elements in the DOM outside the given targets from screen readers using aria-hidden,\n * and returns a function to revert these changes. In addition, changes to the DOM are watched\n * and new elements outside the targets are automatically hidden.\n * @param targets - The elements that should remain visible.\n * @param root - Nothing will be hidden above this element.\n * @returns - A function to restore all hidden elements.\n */\nexport function ariaHideOutside(targets: Element[], root = document.body) {\n let visibleNodes = new Set<Element>(targets);\n let hiddenNodes = new Set<Element>();\n\n let walk = (root: Element) => {\n // Keep live announcer and top layer elements (e.g. toasts) visible.\n for (let element of root.querySelectorAll('[data-live-announcer], [data-react-aria-top-layer]')) {\n visibleNodes.add(element);\n }\n\n let acceptNode = (node: Element) => {\n // Skip this node and its children if it is one of the target nodes, or a live announcer.\n // Also skip children of already hidden nodes, as aria-hidden is recursive. An exception is\n // made for elements with role=\"row\" since VoiceOver on iOS has issues hiding elements with role=\"row\".\n // For that case we want to hide the cells inside as well (https://bugs.webkit.org/show_bug.cgi?id=222623).\n if (\n visibleNodes.has(node) ||\n (hiddenNodes.has(node.parentElement) && node.parentElement.getAttribute('role') !== 'row')\n ) {\n return NodeFilter.FILTER_REJECT;\n }\n\n // Skip this node but continue to children if one of the targets is inside the node.\n for (let target of visibleNodes) {\n if (node.contains(target)) {\n return NodeFilter.FILTER_SKIP;\n }\n }\n\n return NodeFilter.FILTER_ACCEPT;\n };\n\n let walker = document.createTreeWalker(\n root,\n NodeFilter.SHOW_ELEMENT,\n {acceptNode}\n );\n\n // TreeWalker does not include the root.\n let acceptRoot = acceptNode(root);\n if (acceptRoot === NodeFilter.FILTER_ACCEPT) {\n hide(root);\n }\n\n if (acceptRoot !== NodeFilter.FILTER_REJECT) {\n let node = walker.nextNode() as Element;\n while (node != null) {\n hide(node);\n node = walker.nextNode() as Element;\n }\n }\n };\n\n let hide = (node: Element) => {\n let refCount = refCountMap.get(node) ?? 0;\n\n // If already aria-hidden, and the ref count is zero, then this element\n // was already hidden and there's nothing for us to do.\n if (node.getAttribute('aria-hidden') === 'true' && refCount === 0) {\n return;\n }\n\n if (refCount === 0) {\n node.setAttribute('aria-hidden', 'true');\n }\n\n hiddenNodes.add(node);\n refCountMap.set(node, refCount + 1);\n };\n\n // If there is already a MutationObserver listening from a previous call,\n // disconnect it so the new on takes over.\n if (observerStack.length) {\n observerStack[observerStack.length - 1].disconnect();\n }\n\n walk(root);\n\n let observer = new MutationObserver(changes => {\n for (let change of changes) {\n if (change.type !== 'childList' || change.addedNodes.length === 0) {\n continue;\n }\n\n // If the parent element of the added nodes is not within one of the targets,\n // and not already inside a hidden node, hide all of the new children.\n if (![...visibleNodes, ...hiddenNodes].some(node => node.contains(change.target))) {\n for (let node of change.removedNodes) {\n if (node instanceof Element) {\n visibleNodes.delete(node);\n hiddenNodes.delete(node);\n }\n }\n\n for (let node of change.addedNodes) {\n if (\n (node instanceof HTMLElement || node instanceof SVGElement) &&\n (node.dataset.liveAnnouncer === 'true' || node.dataset.reactAriaTopLayer === 'true')\n ) {\n visibleNodes.add(node);\n } else if (node instanceof Element) {\n walk(node);\n }\n }\n }\n }\n });\n\n observer.observe(root, {childList: true, subtree: true});\n\n let observerWrapper = {\n observe() {\n observer.observe(root, {childList: true, subtree: true});\n },\n disconnect() {\n observer.disconnect();\n }\n };\n\n observerStack.push(observerWrapper);\n\n return () => {\n observer.disconnect();\n\n for (let node of hiddenNodes) {\n let count = refCountMap.get(node);\n if (count === 1) {\n node.removeAttribute('aria-hidden');\n refCountMap.delete(node);\n } else {\n refCountMap.set(node, count - 1);\n }\n }\n\n // Remove this observer from the stack, and start the previous one.\n if (observerWrapper === observerStack[observerStack.length - 1]) {\n observerStack.pop();\n if (observerStack.length) {\n observerStack[observerStack.length - 1].observe();\n }\n } else {\n observerStack.splice(observerStack.indexOf(observerWrapper), 1);\n }\n };\n}\n"],"names":[],"version":3,"file":"ariaHideOutside.module.js.map"}
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.module.js.map
8
+ //# sourceMappingURL=bg-BG.mjs.map
@@ -0,0 +1,355 @@
1
+ var $6E71I$reactariautils = require("@react-aria/utils");
2
+
3
+
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
+ }
7
+
8
+ $parcel$export(module.exports, "calculatePosition", () => $5935ba4d7da2c103$export$b3ceb0cbf1056d98);
9
+ /*
10
+ * Copyright 2020 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
20
+ const $5935ba4d7da2c103$var$AXIS = {
21
+ top: "top",
22
+ bottom: "top",
23
+ left: "left",
24
+ right: "left"
25
+ };
26
+ const $5935ba4d7da2c103$var$FLIPPED_DIRECTION = {
27
+ top: "bottom",
28
+ bottom: "top",
29
+ left: "right",
30
+ right: "left"
31
+ };
32
+ const $5935ba4d7da2c103$var$CROSS_AXIS = {
33
+ top: "left",
34
+ left: "top"
35
+ };
36
+ const $5935ba4d7da2c103$var$AXIS_SIZE = {
37
+ top: "height",
38
+ left: "width"
39
+ };
40
+ const $5935ba4d7da2c103$var$TOTAL_SIZE = {
41
+ width: "totalWidth",
42
+ height: "totalHeight"
43
+ };
44
+ const $5935ba4d7da2c103$var$PARSED_PLACEMENT_CACHE = {};
45
+ // @ts-ignore
46
+ let $5935ba4d7da2c103$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
47
+ function $5935ba4d7da2c103$var$getContainerDimensions(containerNode) {
48
+ let width = 0, height = 0, totalWidth = 0, totalHeight = 0, top = 0, left = 0;
49
+ let scroll = {};
50
+ let isPinchZoomedIn = ($5935ba4d7da2c103$var$visualViewport === null || $5935ba4d7da2c103$var$visualViewport === void 0 ? void 0 : $5935ba4d7da2c103$var$visualViewport.scale) > 1;
51
+ if (containerNode.tagName === "BODY") {
52
+ let documentElement = document.documentElement;
53
+ totalWidth = documentElement.clientWidth;
54
+ totalHeight = documentElement.clientHeight;
55
+ var _visualViewport_width;
56
+ width = (_visualViewport_width = $5935ba4d7da2c103$var$visualViewport === null || $5935ba4d7da2c103$var$visualViewport === void 0 ? void 0 : $5935ba4d7da2c103$var$visualViewport.width) !== null && _visualViewport_width !== void 0 ? _visualViewport_width : totalWidth;
57
+ var _visualViewport_height;
58
+ height = (_visualViewport_height = $5935ba4d7da2c103$var$visualViewport === null || $5935ba4d7da2c103$var$visualViewport === void 0 ? void 0 : $5935ba4d7da2c103$var$visualViewport.height) !== null && _visualViewport_height !== void 0 ? _visualViewport_height : totalHeight;
59
+ scroll.top = documentElement.scrollTop || containerNode.scrollTop;
60
+ scroll.left = documentElement.scrollLeft || containerNode.scrollLeft;
61
+ // The goal of the below is to get a top/left value that represents the top/left of the visual viewport with
62
+ // respect to the layout viewport origin. This combined with the scrollTop/scrollLeft will allow us to calculate
63
+ // coordinates/values with respect to the visual viewport or with respect to the layout viewport.
64
+ if ($5935ba4d7da2c103$var$visualViewport) {
65
+ top = $5935ba4d7da2c103$var$visualViewport.offsetTop;
66
+ left = $5935ba4d7da2c103$var$visualViewport.offsetLeft;
67
+ }
68
+ } else {
69
+ ({ width: width, height: height, top: top, left: left } = $5935ba4d7da2c103$var$getOffset(containerNode));
70
+ scroll.top = containerNode.scrollTop;
71
+ scroll.left = containerNode.scrollLeft;
72
+ totalWidth = width;
73
+ totalHeight = height;
74
+ }
75
+ if ((0, $6E71I$reactariautils.isWebKit)() && (containerNode.tagName === "BODY" || containerNode.tagName === "HTML") && isPinchZoomedIn) {
76
+ // Safari will report a non-zero scrollTop/Left for the non-scrolling body/HTML element when pinch zoomed in unlike other browsers.
77
+ // Set to zero for parity calculations so we get consistent positioning of overlays across all browsers.
78
+ // Also switch to visualViewport.pageTop/pageLeft so that we still accomodate for scroll positioning for body/HTML elements that are actually scrollable
79
+ // before pinch zoom happens
80
+ scroll.top = 0;
81
+ scroll.left = 0;
82
+ top = $5935ba4d7da2c103$var$visualViewport.pageTop;
83
+ left = $5935ba4d7da2c103$var$visualViewport.pageLeft;
84
+ }
85
+ return {
86
+ width: width,
87
+ height: height,
88
+ totalWidth: totalWidth,
89
+ totalHeight: totalHeight,
90
+ scroll: scroll,
91
+ top: top,
92
+ left: left
93
+ };
94
+ }
95
+ function $5935ba4d7da2c103$var$getScroll(node) {
96
+ return {
97
+ top: node.scrollTop,
98
+ left: node.scrollLeft,
99
+ width: node.scrollWidth,
100
+ height: node.scrollHeight
101
+ };
102
+ }
103
+ // Determines the amount of space required when moving the overlay to ensure it remains in the boundary
104
+ function $5935ba4d7da2c103$var$getDelta(axis, offset, size, // The dimensions of the boundary element that the popover is
105
+ // positioned within (most of the time this is the <body>).
106
+ boundaryDimensions, // The dimensions of the containing block element that the popover is
107
+ // positioned relative to (e.g. parent with position: relative).
108
+ // Usually this is the same as the boundary element, but if the popover
109
+ // is portaled somewhere other than the body and has an ancestor with
110
+ // position: relative/absolute, it will be different.
111
+ containerDimensions, padding, containerOffsetWithBoundary) {
112
+ let containerScroll = containerDimensions.scroll[axis];
113
+ // The height/width of the boundary. Matches the axis along which we are adjusting the overlay position
114
+ let boundarySize = boundaryDimensions[$5935ba4d7da2c103$var$AXIS_SIZE[axis]];
115
+ // Calculate the edges of the boundary (accomodating for the boundary padding) and the edges of the overlay.
116
+ // Note that these values are with respect to the visual viewport (aka 0,0 is the top left of the viewport)
117
+ let boundaryStartEdge = boundaryDimensions.scroll[$5935ba4d7da2c103$var$AXIS[axis]] + padding;
118
+ let boundaryEndEdge = boundarySize + boundaryDimensions.scroll[$5935ba4d7da2c103$var$AXIS[axis]] - padding;
119
+ let startEdgeOffset = offset - containerScroll + containerOffsetWithBoundary[axis] - boundaryDimensions[$5935ba4d7da2c103$var$AXIS[axis]];
120
+ let endEdgeOffset = offset - containerScroll + size + containerOffsetWithBoundary[axis] - boundaryDimensions[$5935ba4d7da2c103$var$AXIS[axis]];
121
+ // If any of the overlay edges falls outside of the boundary, shift the overlay the required amount to align one of the overlay's
122
+ // edges with the closest boundary edge.
123
+ if (startEdgeOffset < boundaryStartEdge) return boundaryStartEdge - startEdgeOffset;
124
+ else if (endEdgeOffset > boundaryEndEdge) return Math.max(boundaryEndEdge - endEdgeOffset, boundaryStartEdge - startEdgeOffset);
125
+ else return 0;
126
+ }
127
+ function $5935ba4d7da2c103$var$getMargins(node) {
128
+ let style = window.getComputedStyle(node);
129
+ return {
130
+ top: parseInt(style.marginTop, 10) || 0,
131
+ bottom: parseInt(style.marginBottom, 10) || 0,
132
+ left: parseInt(style.marginLeft, 10) || 0,
133
+ right: parseInt(style.marginRight, 10) || 0
134
+ };
135
+ }
136
+ function $5935ba4d7da2c103$var$parsePlacement(input) {
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";
140
+ let crossAxis = $5935ba4d7da2c103$var$CROSS_AXIS[axis];
141
+ if (!$5935ba4d7da2c103$var$AXIS[crossPlacement]) crossPlacement = "center";
142
+ let size = $5935ba4d7da2c103$var$AXIS_SIZE[axis];
143
+ let crossSize = $5935ba4d7da2c103$var$AXIS_SIZE[crossAxis];
144
+ $5935ba4d7da2c103$var$PARSED_PLACEMENT_CACHE[input] = {
145
+ placement: placement,
146
+ crossPlacement: crossPlacement,
147
+ axis: axis,
148
+ crossAxis: crossAxis,
149
+ size: size,
150
+ crossSize: crossSize
151
+ };
152
+ return $5935ba4d7da2c103$var$PARSED_PLACEMENT_CACHE[input];
153
+ }
154
+ function $5935ba4d7da2c103$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset) {
155
+ let { placement: placement, crossPlacement: crossPlacement, axis: axis, crossAxis: crossAxis, size: size, crossSize: crossSize } = placementInfo;
156
+ let position = {};
157
+ // button position
158
+ position[crossAxis] = childOffset[crossAxis];
159
+ if (crossPlacement === "center") // + (button size / 2) - (overlay size / 2)
160
+ // at this point the overlay center should match the button center
161
+ position[crossAxis] += (childOffset[crossSize] - overlaySize[crossSize]) / 2;
162
+ else if (crossPlacement !== crossAxis) // + (button size) - (overlay size)
163
+ // at this point the overlay bottom should match the button bottom
164
+ position[crossAxis] += childOffset[crossSize] - overlaySize[crossSize];
165
+ /* else {
166
+ the overlay top should match the button top
167
+ } */
168
+ position[crossAxis] += crossOffset;
169
+ // overlay top overlapping arrow with button bottom
170
+ const minPosition = childOffset[crossAxis] - overlaySize[crossSize] + arrowSize + arrowBoundaryOffset;
171
+ // overlay bottom overlapping arrow with button top
172
+ const maxPosition = childOffset[crossAxis] + childOffset[crossSize] - arrowSize - arrowBoundaryOffset;
173
+ position[crossAxis] = (0, $6E71I$reactariautils.clamp)(position[crossAxis], minPosition, maxPosition);
174
+ // 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
+ if (placement === axis) {
176
+ // If the container is positioned (non-static), then we use the container's actual
177
+ // height, as `bottom` will be relative to this height. But if the container is static,
178
+ // then it can only be the `document.body`, and `bottom` will be relative to _its_
179
+ // container, which should be as large as boundaryDimensions.
180
+ const containerHeight = isContainerPositioned ? containerOffsetWithBoundary[size] : boundaryDimensions[$5935ba4d7da2c103$var$TOTAL_SIZE[size]];
181
+ position[$5935ba4d7da2c103$var$FLIPPED_DIRECTION[axis]] = Math.floor(containerHeight - childOffset[axis] + offset);
182
+ } else position[axis] = Math.floor(childOffset[axis] + childOffset[size] + offset);
183
+ return position;
184
+ }
185
+ function $5935ba4d7da2c103$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlayHeight, heightGrowthDirection) {
186
+ const containerHeight = isContainerPositioned ? containerOffsetWithBoundary.height : boundaryDimensions[$5935ba4d7da2c103$var$TOTAL_SIZE.height];
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 - overlayHeight);
190
+ let maxHeight = heightGrowthDirection !== "top" ? // We want the distance between the top of the overlay to the bottom of the boundary
191
+ Math.max(0, boundaryDimensions.height + boundaryDimensions.top + boundaryDimensions.scroll.top // this is the bottom of the boundary
192
+ - overlayTop // this is the top of the overlay
193
+ - (margins.top + margins.bottom + padding // save additional space for margin and padding
194
+ )) : Math.max(0, overlayTop + overlayHeight // this is the bottom of the overlay
195
+ - (boundaryDimensions.top + boundaryDimensions.scroll.top // this is the top of the boundary
196
+ ) - (margins.top + margins.bottom + padding // save additional space for margin and padding
197
+ ));
198
+ return Math.min(boundaryDimensions.height - padding * 2, maxHeight);
199
+ }
200
+ function $5935ba4d7da2c103$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding, placementInfo) {
201
+ let { placement: placement, axis: axis, size: size } = placementInfo;
202
+ if (placement === axis) return Math.max(0, childOffset[axis] - boundaryDimensions[axis] - boundaryDimensions.scroll[axis] + containerOffsetWithBoundary[axis] - margins[axis] - margins[$5935ba4d7da2c103$var$FLIPPED_DIRECTION[axis]] - padding);
203
+ return Math.max(0, boundaryDimensions[size] + boundaryDimensions[axis] + boundaryDimensions.scroll[axis] - containerOffsetWithBoundary[axis] - childOffset[axis] - childOffset[size] - margins[axis] - margins[$5935ba4d7da2c103$var$FLIPPED_DIRECTION[axis]] - padding);
204
+ }
205
+ function $5935ba4d7da2c103$export$6839422d1f33cee9(placementInput, childOffset, overlaySize, scrollSize, margins, padding, flip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, userSetMaxHeight, arrowSize, arrowBoundaryOffset) {
206
+ let placementInfo = $5935ba4d7da2c103$var$parsePlacement(placementInput);
207
+ let { size: size, crossAxis: crossAxis, crossSize: crossSize, placement: placement, crossPlacement: crossPlacement } = placementInfo;
208
+ let position = $5935ba4d7da2c103$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
209
+ let normalizedOffset = offset;
210
+ let space = $5935ba4d7da2c103$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, placementInfo);
211
+ // Check if the scroll size of the overlay is greater than the available space to determine if we need to flip
212
+ if (flip && scrollSize[size] > space) {
213
+ let flippedPlacementInfo = $5935ba4d7da2c103$var$parsePlacement(`${$5935ba4d7da2c103$var$FLIPPED_DIRECTION[placement]} ${crossPlacement}`);
214
+ let flippedPosition = $5935ba4d7da2c103$var$computePosition(childOffset, boundaryDimensions, overlaySize, flippedPlacementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
215
+ let flippedSpace = $5935ba4d7da2c103$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, flippedPlacementInfo);
216
+ // If the available space for the flipped position is greater than the original available space, flip.
217
+ if (flippedSpace > space) {
218
+ placementInfo = flippedPlacementInfo;
219
+ position = flippedPosition;
220
+ normalizedOffset = offset;
221
+ }
222
+ }
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";
231
+ }
232
+ let delta = $5935ba4d7da2c103$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);
233
+ position[crossAxis] += delta;
234
+ let maxHeight = $5935ba4d7da2c103$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlaySize.height, heightGrowthDirection);
235
+ if (userSetMaxHeight && userSetMaxHeight < maxHeight) maxHeight = userSetMaxHeight;
236
+ overlaySize.height = Math.min(overlaySize.height, maxHeight);
237
+ position = $5935ba4d7da2c103$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, normalizedOffset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
238
+ delta = $5935ba4d7da2c103$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);
239
+ position[crossAxis] += delta;
240
+ let arrowPosition = {};
241
+ // All values are transformed so that 0 is at the top/left of the overlay depending on the orientation
242
+ // Prefer the arrow being in the center of the trigger/overlay anchor element
243
+ let preferredArrowPosition = childOffset[crossAxis] + .5 * childOffset[crossSize] - overlaySize[crossAxis];
244
+ // Min/Max position limits for the arrow with respect to the overlay
245
+ const arrowMinPosition = arrowSize / 2 + arrowBoundaryOffset;
246
+ const arrowMaxPosition = overlaySize[crossSize] - arrowSize / 2 - arrowBoundaryOffset;
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;
250
+ // Clamp the arrow positioning so that it always is within the bounds of the anchor and the overlay
251
+ const arrowPositionOverlappingChild = (0, $6E71I$reactariautils.clamp)(preferredArrowPosition, arrowOverlappingChildMinEdge, arrowOverlappingChildMaxEdge);
252
+ arrowPosition[crossAxis] = (0, $6E71I$reactariautils.clamp)(arrowPositionOverlappingChild, arrowMinPosition, arrowMaxPosition);
253
+ return {
254
+ position: position,
255
+ maxHeight: maxHeight,
256
+ arrowOffsetLeft: arrowPosition.left,
257
+ arrowOffsetTop: arrowPosition.top,
258
+ placement: placementInfo.placement
259
+ };
260
+ }
261
+ function $5935ba4d7da2c103$export$b3ceb0cbf1056d98(opts) {
262
+ 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;
263
+ let container = overlayNode instanceof HTMLElement ? $5935ba4d7da2c103$var$getContainingBlock(overlayNode) : document.documentElement;
264
+ let isViewportContainer = container === document.documentElement;
265
+ const containerPositionStyle = window.getComputedStyle(container).position;
266
+ let isContainerPositioned = !!containerPositionStyle && containerPositionStyle !== "static";
267
+ let childOffset = isViewportContainer ? $5935ba4d7da2c103$var$getOffset(targetNode) : $5935ba4d7da2c103$var$getPosition(targetNode, container);
268
+ if (!isViewportContainer) {
269
+ let { marginTop: marginTop, marginLeft: marginLeft } = window.getComputedStyle(targetNode);
270
+ childOffset.top += parseInt(marginTop, 10) || 0;
271
+ childOffset.left += parseInt(marginLeft, 10) || 0;
272
+ }
273
+ let overlaySize = $5935ba4d7da2c103$var$getOffset(overlayNode);
274
+ let margins = $5935ba4d7da2c103$var$getMargins(overlayNode);
275
+ overlaySize.width += margins.left + margins.right;
276
+ overlaySize.height += margins.top + margins.bottom;
277
+ let scrollSize = $5935ba4d7da2c103$var$getScroll(scrollNode);
278
+ let boundaryDimensions = $5935ba4d7da2c103$var$getContainerDimensions(boundaryElement);
279
+ let containerDimensions = $5935ba4d7da2c103$var$getContainerDimensions(container);
280
+ // If the container is the HTML element wrapping the body element, the retrieved scrollTop/scrollLeft will be equal to the
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
+ // 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") {
285
+ containerDimensions.scroll.top = 0;
286
+ containerDimensions.scroll.left = 0;
287
+ }
288
+ return $5935ba4d7da2c103$export$6839422d1f33cee9(placement, childOffset, overlaySize, scrollSize, margins, padding, shouldFlip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, maxHeight, arrowSize, arrowBoundaryOffset);
289
+ }
290
+ function $5935ba4d7da2c103$var$getOffset(node) {
291
+ let { top: top, left: left, width: width, height: height } = node.getBoundingClientRect();
292
+ let { scrollTop: scrollTop, scrollLeft: scrollLeft, clientTop: clientTop, clientLeft: clientLeft } = document.documentElement;
293
+ return {
294
+ top: top + scrollTop - clientTop,
295
+ left: left + scrollLeft - clientLeft,
296
+ width: width,
297
+ height: height
298
+ };
299
+ }
300
+ function $5935ba4d7da2c103$var$getPosition(node, parent) {
301
+ let style = window.getComputedStyle(node);
302
+ let offset;
303
+ if (style.position === "fixed") {
304
+ let { top: top, left: left, width: width, height: height } = node.getBoundingClientRect();
305
+ offset = {
306
+ top: top,
307
+ left: left,
308
+ width: width,
309
+ height: height
310
+ };
311
+ } else {
312
+ offset = $5935ba4d7da2c103$var$getOffset(node);
313
+ let parentOffset = $5935ba4d7da2c103$var$getOffset(parent);
314
+ let parentStyle = window.getComputedStyle(parent);
315
+ parentOffset.top += (parseInt(parentStyle.borderTopWidth, 10) || 0) - parent.scrollTop;
316
+ parentOffset.left += (parseInt(parentStyle.borderLeftWidth, 10) || 0) - parent.scrollLeft;
317
+ offset.top -= parentOffset.top;
318
+ offset.left -= parentOffset.left;
319
+ }
320
+ offset.top -= parseInt(style.marginTop, 10) || 0;
321
+ offset.left -= parseInt(style.marginLeft, 10) || 0;
322
+ return offset;
323
+ }
324
+ // Returns the containing block of an element, which is the element that
325
+ // this element will be positioned relative to.
326
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block
327
+ function $5935ba4d7da2c103$var$getContainingBlock(node) {
328
+ // The offsetParent of an element in most cases equals the containing block.
329
+ // https://w3c.github.io/csswg-drafts/cssom-view/#dom-htmlelement-offsetparent
330
+ let offsetParent = node.offsetParent;
331
+ // The offsetParent algorithm terminates at the document body,
332
+ // even if the body is not a containing block. Double check that
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;
335
+ // TODO(later): handle table elements?
336
+ // The offsetParent can be null if the element has position: fixed, or a few other cases.
337
+ // We have to walk up the tree manually in this case because fixed positioned elements
338
+ // are still positioned relative to their containing block, which is not always the viewport.
339
+ if (offsetParent == null) {
340
+ offsetParent = node.parentElement;
341
+ while(offsetParent && !$5935ba4d7da2c103$var$isContainingBlock(offsetParent))offsetParent = offsetParent.parentElement;
342
+ }
343
+ // Fall back to the viewport.
344
+ return offsetParent || document.documentElement;
345
+ }
346
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
347
+ function $5935ba4d7da2c103$var$isContainingBlock(node) {
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";
352
+ }
353
+
354
+
355
+ //# sourceMappingURL=calculatePosition.main.js.map