@react-aria/overlays 3.21.1 → 3.22.0

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