@react-aria/overlays 3.12.0 → 3.12.1
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.
- package/dist/main.js +308 -187
- package/dist/main.js.map +1 -1
- package/dist/module.js +308 -187
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/usePreventScroll.ts +20 -4
package/dist/module.js
CHANGED
|
@@ -10,40 +10,68 @@ import {VisuallyHidden as $k7QOs$VisuallyHidden} from "@react-aria/visually-hidd
|
|
|
10
10
|
function $parcel$interopDefault(a) {
|
|
11
11
|
return a && a.__esModule ? a.default : a;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
/*
|
|
14
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
15
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
17
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
20
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
21
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
22
|
+
* governing permissions and limitations under the License.
|
|
23
|
+
*/ /*
|
|
24
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
25
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
26
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
27
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
30
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
31
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
32
|
+
* governing permissions and limitations under the License.
|
|
33
|
+
*/ /*
|
|
34
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
35
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
36
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
37
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
38
|
+
*
|
|
39
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
40
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
41
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
42
|
+
* governing permissions and limitations under the License.
|
|
43
|
+
*/ const $edcf132a9284368a$var$AXIS = {
|
|
44
|
+
top: "top",
|
|
45
|
+
bottom: "top",
|
|
46
|
+
left: "left",
|
|
47
|
+
right: "left"
|
|
18
48
|
};
|
|
19
49
|
const $edcf132a9284368a$var$FLIPPED_DIRECTION = {
|
|
20
|
-
top:
|
|
21
|
-
bottom:
|
|
22
|
-
left:
|
|
23
|
-
right:
|
|
50
|
+
top: "bottom",
|
|
51
|
+
bottom: "top",
|
|
52
|
+
left: "right",
|
|
53
|
+
right: "left"
|
|
24
54
|
};
|
|
25
55
|
const $edcf132a9284368a$var$CROSS_AXIS = {
|
|
26
|
-
top:
|
|
27
|
-
left:
|
|
56
|
+
top: "left",
|
|
57
|
+
left: "top"
|
|
28
58
|
};
|
|
29
59
|
const $edcf132a9284368a$var$AXIS_SIZE = {
|
|
30
|
-
top:
|
|
31
|
-
left:
|
|
32
|
-
};
|
|
33
|
-
const $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE = {
|
|
60
|
+
top: "height",
|
|
61
|
+
left: "width"
|
|
34
62
|
};
|
|
63
|
+
const $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE = {};
|
|
35
64
|
// @ts-ignore
|
|
36
|
-
let $edcf132a9284368a$var$visualViewport = typeof window !==
|
|
65
|
+
let $edcf132a9284368a$var$visualViewport = typeof window !== "undefined" && window.visualViewport;
|
|
37
66
|
function $edcf132a9284368a$var$getContainerDimensions(containerNode) {
|
|
38
67
|
let width = 0, height = 0, top = 0, left = 0;
|
|
39
|
-
let scroll = {
|
|
40
|
-
|
|
41
|
-
if (containerNode.tagName === 'BODY') {
|
|
68
|
+
let scroll = {};
|
|
69
|
+
if (containerNode.tagName === "BODY") {
|
|
42
70
|
let documentElement = document.documentElement;
|
|
43
|
-
var
|
|
44
|
-
width = (
|
|
45
|
-
var
|
|
46
|
-
height = (
|
|
71
|
+
var _visualViewport_width;
|
|
72
|
+
width = (_visualViewport_width = $edcf132a9284368a$var$visualViewport === null || $edcf132a9284368a$var$visualViewport === void 0 ? void 0 : $edcf132a9284368a$var$visualViewport.width) !== null && _visualViewport_width !== void 0 ? _visualViewport_width : documentElement.clientWidth;
|
|
73
|
+
var _visualViewport_height;
|
|
74
|
+
height = (_visualViewport_height = $edcf132a9284368a$var$visualViewport === null || $edcf132a9284368a$var$visualViewport === void 0 ? void 0 : $edcf132a9284368a$var$visualViewport.height) !== null && _visualViewport_height !== void 0 ? _visualViewport_height : documentElement.clientHeight;
|
|
47
75
|
scroll.top = documentElement.scrollTop || containerNode.scrollTop;
|
|
48
76
|
scroll.left = documentElement.scrollLeft || containerNode.scrollLeft;
|
|
49
77
|
} else {
|
|
@@ -87,10 +115,10 @@ function $edcf132a9284368a$var$getMargins(node) {
|
|
|
87
115
|
}
|
|
88
116
|
function $edcf132a9284368a$var$parsePlacement(input) {
|
|
89
117
|
if ($edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input]) return $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input];
|
|
90
|
-
let [placement, crossPlacement] = input.split(
|
|
91
|
-
let axis = $edcf132a9284368a$var$AXIS[placement] ||
|
|
118
|
+
let [placement, crossPlacement] = input.split(" ");
|
|
119
|
+
let axis = $edcf132a9284368a$var$AXIS[placement] || "right";
|
|
92
120
|
let crossAxis = $edcf132a9284368a$var$CROSS_AXIS[axis];
|
|
93
|
-
if (!$edcf132a9284368a$var$AXIS[crossPlacement]) crossPlacement =
|
|
121
|
+
if (!$edcf132a9284368a$var$AXIS[crossPlacement]) crossPlacement = "center";
|
|
94
122
|
let size = $edcf132a9284368a$var$AXIS_SIZE[axis];
|
|
95
123
|
let crossSize = $edcf132a9284368a$var$AXIS_SIZE[crossAxis];
|
|
96
124
|
$edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input] = {
|
|
@@ -105,11 +133,10 @@ function $edcf132a9284368a$var$parsePlacement(input) {
|
|
|
105
133
|
}
|
|
106
134
|
function $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned) {
|
|
107
135
|
let { placement: placement , crossPlacement: crossPlacement , axis: axis , crossAxis: crossAxis , size: size , crossSize: crossSize } = placementInfo;
|
|
108
|
-
let position = {
|
|
109
|
-
};
|
|
136
|
+
let position = {};
|
|
110
137
|
// button position
|
|
111
138
|
position[crossAxis] = childOffset[crossAxis];
|
|
112
|
-
if (crossPlacement ===
|
|
139
|
+
if (crossPlacement === "center") // + (button size / 2) - (overlay size / 2)
|
|
113
140
|
// at this point the overlay center should match the button center
|
|
114
141
|
position[crossAxis] += (childOffset[crossSize] - overlaySize[crossSize]) / 2;
|
|
115
142
|
else if (crossPlacement !== crossAxis) // + (button size) - (overlay size)
|
|
@@ -138,9 +165,13 @@ function $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions,
|
|
|
138
165
|
return position;
|
|
139
166
|
}
|
|
140
167
|
function $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding) {
|
|
141
|
-
return position.top != null ? Math.max(0, boundaryDimensions.height + boundaryDimensions.top + boundaryDimensions.scroll.top
|
|
142
|
-
|
|
143
|
-
)
|
|
168
|
+
return position.top != null ? Math.max(0, boundaryDimensions.height + boundaryDimensions.top + boundaryDimensions.scroll.top // this is the bottom of the boundary
|
|
169
|
+
- (containerOffsetWithBoundary.top + position.top // this is the top of the overlay
|
|
170
|
+
) - (margins.top + margins.bottom + padding // save additional space for margin and padding
|
|
171
|
+
)) : Math.max(0, childOffset.top + containerOffsetWithBoundary.top // this is the top of the trigger
|
|
172
|
+
- (boundaryDimensions.top + boundaryDimensions.scroll.top // this is the top of the boundary
|
|
173
|
+
) - (margins.top + margins.bottom + padding // save additional space for margin and padding
|
|
174
|
+
));
|
|
144
175
|
}
|
|
145
176
|
function $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding, placementInfo) {
|
|
146
177
|
let { placement: placement , axis: axis , size: size } = placementInfo;
|
|
@@ -173,8 +204,7 @@ function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset,
|
|
|
173
204
|
position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, normalizedOffset, crossOffset, containerOffsetWithBoundary, isContainerPositioned);
|
|
174
205
|
delta = $edcf132a9284368a$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, padding);
|
|
175
206
|
position[crossAxis] += delta;
|
|
176
|
-
let arrowPosition = {
|
|
177
|
-
};
|
|
207
|
+
let arrowPosition = {};
|
|
178
208
|
arrowPosition[crossAxis] = childOffset[crossAxis] - position[crossAxis] + childOffset[crossSize] / 2;
|
|
179
209
|
return {
|
|
180
210
|
position: position,
|
|
@@ -187,9 +217,9 @@ function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset,
|
|
|
187
217
|
function $edcf132a9284368a$export$b3ceb0cbf1056d98(opts) {
|
|
188
218
|
let { placement: placement , targetNode: targetNode , overlayNode: overlayNode , scrollNode: scrollNode , padding: padding , shouldFlip: shouldFlip , boundaryElement: boundaryElement , offset: offset , crossOffset: crossOffset , maxHeight: maxHeight } = opts;
|
|
189
219
|
let container = overlayNode instanceof HTMLElement && overlayNode.offsetParent || document.body;
|
|
190
|
-
let isBodyContainer = container.tagName ===
|
|
220
|
+
let isBodyContainer = container.tagName === "BODY";
|
|
191
221
|
const containerPositionStyle = window.getComputedStyle(container).position;
|
|
192
|
-
let isContainerPositioned = !!containerPositionStyle && containerPositionStyle !==
|
|
222
|
+
let isContainerPositioned = !!containerPositionStyle && containerPositionStyle !== "static";
|
|
193
223
|
let childOffset = isBodyContainer ? $edcf132a9284368a$var$getOffset(targetNode) : $edcf132a9284368a$var$getPosition(targetNode, container);
|
|
194
224
|
if (!isBodyContainer) {
|
|
195
225
|
let { marginTop: marginTop , marginLeft: marginLeft } = window.getComputedStyle(targetNode);
|
|
@@ -202,7 +232,7 @@ function $edcf132a9284368a$export$b3ceb0cbf1056d98(opts) {
|
|
|
202
232
|
overlaySize.height += margins.top + margins.bottom;
|
|
203
233
|
let scrollSize = $edcf132a9284368a$var$getScroll(scrollNode);
|
|
204
234
|
let boundaryDimensions = $edcf132a9284368a$var$getContainerDimensions(boundaryElement);
|
|
205
|
-
let containerOffsetWithBoundary = boundaryElement.tagName ===
|
|
235
|
+
let containerOffsetWithBoundary = boundaryElement.tagName === "BODY" ? $edcf132a9284368a$var$getOffset(container) : $edcf132a9284368a$var$getPosition(container, boundaryElement);
|
|
206
236
|
return $edcf132a9284368a$export$6839422d1f33cee9(placement, childOffset, overlaySize, scrollSize, margins, padding, shouldFlip, boundaryDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, maxHeight);
|
|
207
237
|
}
|
|
208
238
|
function $edcf132a9284368a$var$getOffset(node) {
|
|
@@ -218,7 +248,7 @@ function $edcf132a9284368a$var$getOffset(node) {
|
|
|
218
248
|
function $edcf132a9284368a$var$getPosition(node, parent) {
|
|
219
249
|
let style = window.getComputedStyle(node);
|
|
220
250
|
let offset;
|
|
221
|
-
if (style.position ===
|
|
251
|
+
if (style.position === "fixed") {
|
|
222
252
|
let { top: top , left: left , width: width , height: height } = node.getBoundingClientRect();
|
|
223
253
|
offset = {
|
|
224
254
|
top: top,
|
|
@@ -242,11 +272,21 @@ function $edcf132a9284368a$var$getPosition(node, parent) {
|
|
|
242
272
|
|
|
243
273
|
|
|
244
274
|
|
|
245
|
-
|
|
275
|
+
/*
|
|
276
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
277
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
278
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
279
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
280
|
+
*
|
|
281
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
282
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
283
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
284
|
+
* governing permissions and limitations under the License.
|
|
285
|
+
*/
|
|
246
286
|
const $dd149f63282afbbf$export$f6211563215e3b37 = new WeakMap();
|
|
247
287
|
function $dd149f63282afbbf$export$18fc8428861184da(opts) {
|
|
248
288
|
let { triggerRef: triggerRef , isOpen: isOpen , onClose: onClose } = opts;
|
|
249
|
-
$k7QOs$useEffect(()=>{
|
|
289
|
+
(0, $k7QOs$useEffect)(()=>{
|
|
250
290
|
if (!isOpen || onClose === null) return;
|
|
251
291
|
let onScroll = (e)=>{
|
|
252
292
|
// Ignore if scrolling an scrollable region outside the trigger's tree.
|
|
@@ -256,9 +296,9 @@ function $dd149f63282afbbf$export$18fc8428861184da(opts) {
|
|
|
256
296
|
let onCloseHandler = onClose || $dd149f63282afbbf$export$f6211563215e3b37.get(triggerRef.current);
|
|
257
297
|
if (onCloseHandler) onCloseHandler();
|
|
258
298
|
};
|
|
259
|
-
window.addEventListener(
|
|
299
|
+
window.addEventListener("scroll", onScroll, true);
|
|
260
300
|
return ()=>{
|
|
261
|
-
window.removeEventListener(
|
|
301
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
262
302
|
};
|
|
263
303
|
}, [
|
|
264
304
|
isOpen,
|
|
@@ -271,13 +311,12 @@ function $dd149f63282afbbf$export$18fc8428861184da(opts) {
|
|
|
271
311
|
|
|
272
312
|
|
|
273
313
|
// @ts-ignore
|
|
274
|
-
let $2a41e45df1593e64$var$visualViewport = typeof window !==
|
|
314
|
+
let $2a41e45df1593e64$var$visualViewport = typeof window !== "undefined" && window.visualViewport;
|
|
275
315
|
function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
|
|
276
|
-
let { direction: direction } = $k7QOs$useLocale();
|
|
277
|
-
let { targetRef: targetRef , overlayRef: overlayRef , scrollRef: scrollRef = overlayRef , placement: placement =
|
|
278
|
-
let [position, setPosition] = $k7QOs$useState({
|
|
279
|
-
position: {
|
|
280
|
-
},
|
|
316
|
+
let { direction: direction } = (0, $k7QOs$useLocale)();
|
|
317
|
+
let { 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 } = props;
|
|
318
|
+
let [position, setPosition] = (0, $k7QOs$useState)({
|
|
319
|
+
position: {},
|
|
281
320
|
arrowOffsetLeft: undefined,
|
|
282
321
|
arrowOffsetTop: undefined,
|
|
283
322
|
maxHeight: undefined,
|
|
@@ -298,9 +337,9 @@ function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
|
|
|
298
337
|
direction,
|
|
299
338
|
maxHeight
|
|
300
339
|
];
|
|
301
|
-
let updatePosition = $k7QOs$useCallback(()=>{
|
|
340
|
+
let updatePosition = (0, $k7QOs$useCallback)(()=>{
|
|
302
341
|
if (shouldUpdatePosition === false || !isOpen || !overlayRef.current || !targetRef.current || !scrollRef.current || !boundaryElement) return;
|
|
303
|
-
setPosition($edcf132a9284368a$export$b3ceb0cbf1056d98({
|
|
342
|
+
setPosition((0, $edcf132a9284368a$export$b3ceb0cbf1056d98)({
|
|
304
343
|
placement: $2a41e45df1593e64$var$translateRTL(placement, direction),
|
|
305
344
|
overlayNode: overlayRef.current,
|
|
306
345
|
targetNode: targetRef.current,
|
|
@@ -316,18 +355,18 @@ function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
|
|
|
316
355
|
}, deps);
|
|
317
356
|
// Update position when anything changes
|
|
318
357
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
319
|
-
$k7QOs$useLayoutEffect(updatePosition, deps);
|
|
358
|
+
(0, $k7QOs$useLayoutEffect)(updatePosition, deps);
|
|
320
359
|
// Update position on window resize
|
|
321
360
|
$2a41e45df1593e64$var$useResize(updatePosition);
|
|
322
361
|
// Update position when the overlay changes size (might need to flip).
|
|
323
|
-
$k7QOs$useResizeObserver({
|
|
362
|
+
(0, $k7QOs$useResizeObserver)({
|
|
324
363
|
ref: overlayRef,
|
|
325
364
|
onResize: updatePosition
|
|
326
365
|
});
|
|
327
366
|
// Reposition the overlay and do not close on scroll while the visual viewport is resizing.
|
|
328
367
|
// This will ensure that overlays adjust their positioning when the iOS virtual keyboard appears.
|
|
329
|
-
let isResizing = $k7QOs$useRef(false);
|
|
330
|
-
$k7QOs$useLayoutEffect(()=>{
|
|
368
|
+
let isResizing = (0, $k7QOs$useRef)(false);
|
|
369
|
+
(0, $k7QOs$useLayoutEffect)(()=>{
|
|
331
370
|
let timeout;
|
|
332
371
|
let onResize = ()=>{
|
|
333
372
|
isResizing.current = true;
|
|
@@ -337,14 +376,14 @@ function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
|
|
|
337
376
|
}, 500);
|
|
338
377
|
updatePosition();
|
|
339
378
|
};
|
|
340
|
-
$2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.addEventListener(
|
|
379
|
+
$2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.addEventListener("resize", onResize);
|
|
341
380
|
return ()=>{
|
|
342
|
-
$2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.removeEventListener(
|
|
381
|
+
$2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.removeEventListener("resize", onResize);
|
|
343
382
|
};
|
|
344
383
|
}, [
|
|
345
384
|
updatePosition
|
|
346
385
|
]);
|
|
347
|
-
let close = $k7QOs$useCallback(()=>{
|
|
386
|
+
let close = (0, $k7QOs$useCallback)(()=>{
|
|
348
387
|
if (!isResizing.current) onClose();
|
|
349
388
|
}, [
|
|
350
389
|
onClose,
|
|
@@ -352,7 +391,7 @@ function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
|
|
|
352
391
|
]);
|
|
353
392
|
// When scrolling a parent scrollable region of the trigger (other than the body),
|
|
354
393
|
// we hide the popover. Otherwise, its position would be incorrect.
|
|
355
|
-
$dd149f63282afbbf$export$18fc8428861184da({
|
|
394
|
+
(0, $dd149f63282afbbf$export$18fc8428861184da)({
|
|
356
395
|
triggerRef: targetRef,
|
|
357
396
|
isOpen: isOpen,
|
|
358
397
|
onClose: onClose && close
|
|
@@ -360,7 +399,7 @@ function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
|
|
|
360
399
|
return {
|
|
361
400
|
overlayProps: {
|
|
362
401
|
style: {
|
|
363
|
-
position:
|
|
402
|
+
position: "absolute",
|
|
364
403
|
zIndex: 100000,
|
|
365
404
|
...position.position,
|
|
366
405
|
maxHeight: position.maxHeight
|
|
@@ -377,29 +416,39 @@ function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
|
|
|
377
416
|
};
|
|
378
417
|
}
|
|
379
418
|
function $2a41e45df1593e64$var$useResize(onResize) {
|
|
380
|
-
$k7QOs$useLayoutEffect(()=>{
|
|
381
|
-
window.addEventListener(
|
|
419
|
+
(0, $k7QOs$useLayoutEffect)(()=>{
|
|
420
|
+
window.addEventListener("resize", onResize, false);
|
|
382
421
|
return ()=>{
|
|
383
|
-
window.removeEventListener(
|
|
422
|
+
window.removeEventListener("resize", onResize, false);
|
|
384
423
|
};
|
|
385
424
|
}, [
|
|
386
425
|
onResize
|
|
387
426
|
]);
|
|
388
427
|
}
|
|
389
428
|
function $2a41e45df1593e64$var$translateRTL(position, direction) {
|
|
390
|
-
if (direction ===
|
|
391
|
-
return position.replace(
|
|
429
|
+
if (direction === "rtl") return position.replace("start", "right").replace("end", "left");
|
|
430
|
+
return position.replace("start", "left").replace("end", "right");
|
|
392
431
|
}
|
|
393
432
|
|
|
394
433
|
|
|
395
|
-
|
|
434
|
+
/*
|
|
435
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
436
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
437
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
438
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
439
|
+
*
|
|
440
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
441
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
442
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
443
|
+
* governing permissions and limitations under the License.
|
|
444
|
+
*/
|
|
396
445
|
|
|
397
446
|
|
|
398
447
|
const $a11501f3d1d39e6c$var$visibleOverlays = [];
|
|
399
448
|
function $a11501f3d1d39e6c$export$ea8f71083e90600f(props, ref) {
|
|
400
449
|
let { onClose: onClose , shouldCloseOnBlur: shouldCloseOnBlur , isOpen: isOpen , isDismissable: isDismissable = false , isKeyboardDismissDisabled: isKeyboardDismissDisabled = false , shouldCloseOnInteractOutside: shouldCloseOnInteractOutside } = props;
|
|
401
450
|
// Add the overlay ref to the stack of visible overlays on mount, and remove on unmount.
|
|
402
|
-
$k7QOs$useEffect(()=>{
|
|
451
|
+
(0, $k7QOs$useEffect)(()=>{
|
|
403
452
|
if (isOpen) $a11501f3d1d39e6c$var$visibleOverlays.push(ref);
|
|
404
453
|
return ()=>{
|
|
405
454
|
let index = $a11501f3d1d39e6c$var$visibleOverlays.indexOf(ref);
|
|
@@ -432,25 +481,25 @@ function $a11501f3d1d39e6c$export$ea8f71083e90600f(props, ref) {
|
|
|
432
481
|
};
|
|
433
482
|
// Handle the escape key
|
|
434
483
|
let onKeyDown = (e)=>{
|
|
435
|
-
if (e.key ===
|
|
484
|
+
if (e.key === "Escape" && !isKeyboardDismissDisabled) {
|
|
436
485
|
e.stopPropagation();
|
|
437
486
|
e.preventDefault();
|
|
438
487
|
onHide();
|
|
439
488
|
}
|
|
440
489
|
};
|
|
441
490
|
// Handle clicking outside the overlay to close it
|
|
442
|
-
$k7QOs$useInteractOutside({
|
|
491
|
+
(0, $k7QOs$useInteractOutside)({
|
|
443
492
|
ref: ref,
|
|
444
493
|
onInteractOutside: isDismissable ? onInteractOutside : null,
|
|
445
494
|
onInteractOutsideStart: onInteractOutsideStart
|
|
446
495
|
});
|
|
447
|
-
let { focusWithinProps: focusWithinProps } = $k7QOs$useFocusWithin({
|
|
496
|
+
let { focusWithinProps: focusWithinProps } = (0, $k7QOs$useFocusWithin)({
|
|
448
497
|
isDisabled: !shouldCloseOnBlur,
|
|
449
498
|
onBlurWithin: (e)=>{
|
|
450
499
|
// If focus is moving into a child focus scope (e.g. menu inside a dialog),
|
|
451
500
|
// do not close the outer overlay. At this point, the active scope should
|
|
452
501
|
// still be the outer overlay, since blur events run before focus.
|
|
453
|
-
if (e.relatedTarget && $k7QOs$isElementInChildOfActiveScope(e.relatedTarget)) return;
|
|
502
|
+
if (e.relatedTarget && (0, $k7QOs$isElementInChildOfActiveScope)(e.relatedTarget)) return;
|
|
454
503
|
if (!shouldCloseOnInteractOutside || shouldCloseOnInteractOutside(e.relatedTarget)) onClose();
|
|
455
504
|
}
|
|
456
505
|
});
|
|
@@ -470,7 +519,17 @@ function $a11501f3d1d39e6c$export$ea8f71083e90600f(props, ref) {
|
|
|
470
519
|
}
|
|
471
520
|
|
|
472
521
|
|
|
473
|
-
|
|
522
|
+
/*
|
|
523
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
524
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
525
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
526
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
527
|
+
*
|
|
528
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
529
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
530
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
531
|
+
* governing permissions and limitations under the License.
|
|
532
|
+
*/
|
|
474
533
|
|
|
475
534
|
|
|
476
535
|
function $628037886ba31236$export$f9d5c8beee7d008d(props, state, ref) {
|
|
@@ -478,22 +537,22 @@ function $628037886ba31236$export$f9d5c8beee7d008d(props, state, ref) {
|
|
|
478
537
|
let { isOpen: isOpen } = state;
|
|
479
538
|
// Backward compatibility. Share state close function with useOverlayPosition so it can close on scroll
|
|
480
539
|
// without forcing users to pass onClose.
|
|
481
|
-
$k7QOs$useEffect(()=>{
|
|
482
|
-
if (ref && ref.current) $dd149f63282afbbf$export$f6211563215e3b37.set(ref.current, state.close);
|
|
540
|
+
(0, $k7QOs$useEffect)(()=>{
|
|
541
|
+
if (ref && ref.current) (0, $dd149f63282afbbf$export$f6211563215e3b37).set(ref.current, state.close);
|
|
483
542
|
});
|
|
484
543
|
// Aria 1.1 supports multiple values for aria-haspopup other than just menus.
|
|
485
544
|
// https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup
|
|
486
545
|
// However, we only add it for menus for now because screen readers often
|
|
487
546
|
// announce it as a menu even for other values.
|
|
488
547
|
let ariaHasPopup = undefined;
|
|
489
|
-
if (type ===
|
|
490
|
-
else if (type ===
|
|
491
|
-
let overlayId = $k7QOs$useId();
|
|
548
|
+
if (type === "menu") ariaHasPopup = true;
|
|
549
|
+
else if (type === "listbox") ariaHasPopup = "listbox";
|
|
550
|
+
let overlayId = (0, $k7QOs$useId)();
|
|
492
551
|
return {
|
|
493
552
|
triggerProps: {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
553
|
+
"aria-haspopup": ariaHasPopup,
|
|
554
|
+
"aria-expanded": isOpen,
|
|
555
|
+
"aria-controls": isOpen ? overlayId : null,
|
|
497
556
|
onPress: state.toggle
|
|
498
557
|
},
|
|
499
558
|
overlayProps: {
|
|
@@ -503,28 +562,47 @@ function $628037886ba31236$export$f9d5c8beee7d008d(props, state, ref) {
|
|
|
503
562
|
}
|
|
504
563
|
|
|
505
564
|
|
|
506
|
-
|
|
565
|
+
/*
|
|
566
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
567
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
568
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
569
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
570
|
+
*
|
|
571
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
572
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
573
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
574
|
+
* governing permissions and limitations under the License.
|
|
575
|
+
*/
|
|
507
576
|
// @ts-ignore
|
|
508
|
-
const $49c51c25361d4cd2$var$visualViewport = typeof window !==
|
|
577
|
+
const $49c51c25361d4cd2$var$visualViewport = typeof window !== "undefined" && window.visualViewport;
|
|
509
578
|
// HTML input types that do not cause the software keyboard to appear.
|
|
510
579
|
const $49c51c25361d4cd2$var$nonTextInputTypes = new Set([
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
580
|
+
"checkbox",
|
|
581
|
+
"radio",
|
|
582
|
+
"range",
|
|
583
|
+
"color",
|
|
584
|
+
"file",
|
|
585
|
+
"image",
|
|
586
|
+
"button",
|
|
587
|
+
"submit",
|
|
588
|
+
"reset"
|
|
520
589
|
]);
|
|
521
|
-
|
|
522
|
-
|
|
590
|
+
// The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position
|
|
591
|
+
let $49c51c25361d4cd2$var$preventScrollCount = 0;
|
|
592
|
+
let $49c51c25361d4cd2$var$restore;
|
|
593
|
+
function $49c51c25361d4cd2$export$ee0f7cc6afcd1c18(options = {}) {
|
|
523
594
|
let { isDisabled: isDisabled } = options;
|
|
524
|
-
$k7QOs$useLayoutEffect(()=>{
|
|
595
|
+
(0, $k7QOs$useLayoutEffect)(()=>{
|
|
525
596
|
if (isDisabled) return;
|
|
526
|
-
|
|
527
|
-
|
|
597
|
+
$49c51c25361d4cd2$var$preventScrollCount++;
|
|
598
|
+
if ($49c51c25361d4cd2$var$preventScrollCount === 1) {
|
|
599
|
+
if ((0, $k7QOs$isIOS)()) $49c51c25361d4cd2$var$restore = $49c51c25361d4cd2$var$preventScrollMobileSafari();
|
|
600
|
+
else $49c51c25361d4cd2$var$restore = $49c51c25361d4cd2$var$preventScrollStandard();
|
|
601
|
+
}
|
|
602
|
+
return ()=>{
|
|
603
|
+
$49c51c25361d4cd2$var$preventScrollCount--;
|
|
604
|
+
if ($49c51c25361d4cd2$var$preventScrollCount === 0) $49c51c25361d4cd2$var$restore();
|
|
605
|
+
};
|
|
528
606
|
}, [
|
|
529
607
|
isDisabled
|
|
530
608
|
]);
|
|
@@ -532,7 +610,7 @@ function $49c51c25361d4cd2$export$ee0f7cc6afcd1c18(options = {
|
|
|
532
610
|
// For most browsers, all we need to do is set `overflow: hidden` on the root element, and
|
|
533
611
|
// add some padding to prevent the page from shifting when the scrollbar is hidden.
|
|
534
612
|
function $49c51c25361d4cd2$var$preventScrollStandard() {
|
|
535
|
-
return $k7QOs$chain($49c51c25361d4cd2$var$setStyle(document.documentElement,
|
|
613
|
+
return (0, $k7QOs$chain)($49c51c25361d4cd2$var$setStyle(document.documentElement, "paddingRight", `${window.innerWidth - document.documentElement.clientWidth}px`), $49c51c25361d4cd2$var$setStyle(document.documentElement, "overflow", "hidden"));
|
|
536
614
|
}
|
|
537
615
|
// Mobile Safari is a whole different beast. Even with overflow: hidden,
|
|
538
616
|
// it still scrolls the page in many situations:
|
|
@@ -565,7 +643,7 @@ function $49c51c25361d4cd2$var$preventScrollMobileSafari() {
|
|
|
565
643
|
let lastY = 0;
|
|
566
644
|
let onTouchStart = (e)=>{
|
|
567
645
|
// Store the nearest scrollable parent element from the element that the user touched.
|
|
568
|
-
scrollable = $k7QOs$getScrollParent(e.target);
|
|
646
|
+
scrollable = (0, $k7QOs$getScrollParent)(e.target);
|
|
569
647
|
if (scrollable === document.documentElement && scrollable === document.body) return;
|
|
570
648
|
lastY = e.changedTouches[0].pageY;
|
|
571
649
|
};
|
|
@@ -593,10 +671,10 @@ function $49c51c25361d4cd2$var$preventScrollMobileSafari() {
|
|
|
593
671
|
// Apply a transform to trick Safari into thinking the input is at the top of the page
|
|
594
672
|
// so it doesn't try to scroll it into view. When tapping on an input, this needs to
|
|
595
673
|
// be done before the "focus" event, so we have to focus the element ourselves.
|
|
596
|
-
target.style.transform =
|
|
674
|
+
target.style.transform = "translateY(-2000px)";
|
|
597
675
|
target.focus();
|
|
598
676
|
requestAnimationFrame(()=>{
|
|
599
|
-
target.style.transform =
|
|
677
|
+
target.style.transform = "";
|
|
600
678
|
});
|
|
601
679
|
}
|
|
602
680
|
};
|
|
@@ -607,9 +685,9 @@ function $49c51c25361d4cd2$var$preventScrollMobileSafari() {
|
|
|
607
685
|
// other than tapping on an input directly, e.g. the next/previous buttons in the
|
|
608
686
|
// software keyboard. In these cases, it seems applying the transform in the focus event
|
|
609
687
|
// is good enough, whereas when tapping an input, it must be done before the focus event. 🤷♂️
|
|
610
|
-
target.style.transform =
|
|
688
|
+
target.style.transform = "translateY(-2000px)";
|
|
611
689
|
requestAnimationFrame(()=>{
|
|
612
|
-
target.style.transform =
|
|
690
|
+
target.style.transform = "";
|
|
613
691
|
// This will have prevented the browser from scrolling the focused element into view,
|
|
614
692
|
// so we need to do this ourselves in a way that doesn't cause the whole page to scroll.
|
|
615
693
|
if ($49c51c25361d4cd2$var$visualViewport) {
|
|
@@ -620,8 +698,7 @@ function $49c51c25361d4cd2$var$preventScrollMobileSafari() {
|
|
|
620
698
|
});
|
|
621
699
|
else // Otherwise, wait for the visual viewport to resize before scrolling so we can
|
|
622
700
|
// measure the correct position to scroll to.
|
|
623
|
-
$49c51c25361d4cd2$var$visualViewport.addEventListener(
|
|
624
|
-
, {
|
|
701
|
+
$49c51c25361d4cd2$var$visualViewport.addEventListener("resize", ()=>$49c51c25361d4cd2$var$scrollIntoView(target), {
|
|
625
702
|
once: true
|
|
626
703
|
});
|
|
627
704
|
}
|
|
@@ -638,19 +715,19 @@ function $49c51c25361d4cd2$var$preventScrollMobileSafari() {
|
|
|
638
715
|
// enable us to scroll the window to the top, which is required for the rest of this to work.
|
|
639
716
|
let scrollX = window.pageXOffset;
|
|
640
717
|
let scrollY = window.pageYOffset;
|
|
641
|
-
let restoreStyles = $k7QOs$chain($49c51c25361d4cd2$var$setStyle(document.documentElement,
|
|
718
|
+
let restoreStyles = (0, $k7QOs$chain)($49c51c25361d4cd2$var$setStyle(document.documentElement, "paddingRight", `${window.innerWidth - document.documentElement.clientWidth}px`), $49c51c25361d4cd2$var$setStyle(document.documentElement, "overflow", "hidden"), $49c51c25361d4cd2$var$setStyle(document.body, "marginTop", `-${scrollY}px`));
|
|
642
719
|
// Scroll to the top. The negative margin on the body will make this appear the same.
|
|
643
720
|
window.scrollTo(0, 0);
|
|
644
|
-
let removeEvents = $k7QOs$chain($49c51c25361d4cd2$var$addEvent(document,
|
|
721
|
+
let removeEvents = (0, $k7QOs$chain)($49c51c25361d4cd2$var$addEvent(document, "touchstart", onTouchStart, {
|
|
645
722
|
passive: false,
|
|
646
723
|
capture: true
|
|
647
|
-
}), $49c51c25361d4cd2$var$addEvent(document,
|
|
724
|
+
}), $49c51c25361d4cd2$var$addEvent(document, "touchmove", onTouchMove, {
|
|
648
725
|
passive: false,
|
|
649
726
|
capture: true
|
|
650
|
-
}), $49c51c25361d4cd2$var$addEvent(document,
|
|
727
|
+
}), $49c51c25361d4cd2$var$addEvent(document, "touchend", onTouchEnd, {
|
|
651
728
|
passive: false,
|
|
652
729
|
capture: true
|
|
653
|
-
}), $49c51c25361d4cd2$var$addEvent(document,
|
|
730
|
+
}), $49c51c25361d4cd2$var$addEvent(document, "focus", onFocus, true), $49c51c25361d4cd2$var$addEvent(window, "scroll", onWindowScroll));
|
|
654
731
|
return ()=>{
|
|
655
732
|
// Restore styles and scroll the page back to where it was.
|
|
656
733
|
restoreStyles();
|
|
@@ -677,7 +754,7 @@ function $49c51c25361d4cd2$var$scrollIntoView(target) {
|
|
|
677
754
|
let root = document.scrollingElement || document.documentElement;
|
|
678
755
|
while(target && target !== root){
|
|
679
756
|
// Find the parent scrollable element and adjust the scroll position if the target is not already in view.
|
|
680
|
-
let scrollable = $k7QOs$getScrollParent(target);
|
|
757
|
+
let scrollable = (0, $k7QOs$getScrollParent)(target);
|
|
681
758
|
if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== target) {
|
|
682
759
|
let scrollableTop = scrollable.getBoundingClientRect().top;
|
|
683
760
|
let targetTop = target.getBoundingClientRect().top;
|
|
@@ -691,41 +768,48 @@ function $49c51c25361d4cd2$var$willOpenKeyboard(target) {
|
|
|
691
768
|
}
|
|
692
769
|
|
|
693
770
|
|
|
771
|
+
/*
|
|
772
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
773
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
774
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
775
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
776
|
+
*
|
|
777
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
778
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
779
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
780
|
+
* governing permissions and limitations under the License.
|
|
781
|
+
*/
|
|
694
782
|
|
|
695
783
|
|
|
696
|
-
|
|
697
|
-
const $f57aed4a881a3485$var$Context = /*#__PURE__*/ $k7QOs$react.createContext(null);
|
|
784
|
+
const $f57aed4a881a3485$var$Context = /*#__PURE__*/ (0, $k7QOs$react).createContext(null);
|
|
698
785
|
function $f57aed4a881a3485$export$178405afcd8c5eb(props) {
|
|
699
786
|
let { children: children } = props;
|
|
700
|
-
let parent = $k7QOs$useContext($f57aed4a881a3485$var$Context);
|
|
701
|
-
let [modalCount, setModalCount] = $k7QOs$useState(0);
|
|
702
|
-
let context = $k7QOs$useMemo(()=>({
|
|
787
|
+
let parent = (0, $k7QOs$useContext)($f57aed4a881a3485$var$Context);
|
|
788
|
+
let [modalCount, setModalCount] = (0, $k7QOs$useState)(0);
|
|
789
|
+
let context = (0, $k7QOs$useMemo)(()=>({
|
|
703
790
|
parent: parent,
|
|
704
791
|
modalCount: modalCount,
|
|
705
792
|
addModal () {
|
|
706
|
-
setModalCount((count)=>count + 1
|
|
707
|
-
);
|
|
793
|
+
setModalCount((count)=>count + 1);
|
|
708
794
|
if (parent) parent.addModal();
|
|
709
795
|
},
|
|
710
796
|
removeModal () {
|
|
711
|
-
setModalCount((count)=>count - 1
|
|
712
|
-
);
|
|
797
|
+
setModalCount((count)=>count - 1);
|
|
713
798
|
if (parent) parent.removeModal();
|
|
714
799
|
}
|
|
715
|
-
})
|
|
716
|
-
, [
|
|
800
|
+
}), [
|
|
717
801
|
parent,
|
|
718
802
|
modalCount
|
|
719
803
|
]);
|
|
720
|
-
return
|
|
804
|
+
return /*#__PURE__*/ (0, $k7QOs$react).createElement($f57aed4a881a3485$var$Context.Provider, {
|
|
721
805
|
value: context
|
|
722
|
-
}, children)
|
|
806
|
+
}, children);
|
|
723
807
|
}
|
|
724
808
|
function $f57aed4a881a3485$export$d9aaed4c3ece1bc0() {
|
|
725
|
-
let context = $k7QOs$useContext($f57aed4a881a3485$var$Context);
|
|
809
|
+
let context = (0, $k7QOs$useContext)($f57aed4a881a3485$var$Context);
|
|
726
810
|
return {
|
|
727
811
|
modalProviderProps: {
|
|
728
|
-
|
|
812
|
+
"aria-hidden": context && context.modalCount > 0 ? true : null
|
|
729
813
|
}
|
|
730
814
|
};
|
|
731
815
|
}
|
|
@@ -733,32 +817,32 @@ function $f57aed4a881a3485$export$d9aaed4c3ece1bc0() {
|
|
|
733
817
|
* Creates a root node that will be aria-hidden if there are other modals open.
|
|
734
818
|
*/ function $f57aed4a881a3485$var$OverlayContainerDOM(props) {
|
|
735
819
|
let { modalProviderProps: modalProviderProps } = $f57aed4a881a3485$export$d9aaed4c3ece1bc0();
|
|
736
|
-
return
|
|
820
|
+
return /*#__PURE__*/ (0, $k7QOs$react).createElement("div", {
|
|
737
821
|
"data-overlay-container": true,
|
|
738
822
|
...props,
|
|
739
823
|
...modalProviderProps
|
|
740
|
-
})
|
|
824
|
+
});
|
|
741
825
|
}
|
|
742
826
|
function $f57aed4a881a3485$export$bf688221f59024e5(props) {
|
|
743
|
-
return
|
|
827
|
+
return /*#__PURE__*/ (0, $k7QOs$react).createElement($f57aed4a881a3485$export$178405afcd8c5eb, null, /*#__PURE__*/ (0, $k7QOs$react).createElement($f57aed4a881a3485$var$OverlayContainerDOM, props));
|
|
744
828
|
}
|
|
745
829
|
function $f57aed4a881a3485$export$b47c3594eab58386(props) {
|
|
746
|
-
let isSSR = $k7QOs$useIsSSR();
|
|
830
|
+
let isSSR = (0, $k7QOs$useIsSSR)();
|
|
747
831
|
let { portalContainer: portalContainer = isSSR ? null : document.body , ...rest } = props;
|
|
748
|
-
$k7QOs$react.useEffect(()=>{
|
|
749
|
-
if (portalContainer === null || portalContainer === void 0 ? void 0 : portalContainer.closest(
|
|
832
|
+
(0, $k7QOs$react).useEffect(()=>{
|
|
833
|
+
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.");
|
|
750
834
|
}, [
|
|
751
835
|
portalContainer
|
|
752
836
|
]);
|
|
753
837
|
if (!portalContainer) return null;
|
|
754
|
-
let contents = /*#__PURE__*/ $k7QOs$react.createElement($f57aed4a881a3485$export$bf688221f59024e5, rest);
|
|
755
|
-
return
|
|
838
|
+
let contents = /*#__PURE__*/ (0, $k7QOs$react).createElement($f57aed4a881a3485$export$bf688221f59024e5, rest);
|
|
839
|
+
return /*#__PURE__*/ (0, $k7QOs$reactdom).createPortal(contents, portalContainer);
|
|
756
840
|
}
|
|
757
841
|
function $f57aed4a881a3485$export$33ffd74ebf07f060(options) {
|
|
758
842
|
// Add aria-hidden to all parent providers on mount, and restore on unmount.
|
|
759
|
-
let context = $k7QOs$useContext($f57aed4a881a3485$var$Context);
|
|
760
|
-
if (!context) throw new Error(
|
|
761
|
-
$k7QOs$useEffect(()=>{
|
|
843
|
+
let context = (0, $k7QOs$useContext)($f57aed4a881a3485$var$Context);
|
|
844
|
+
if (!context) throw new Error("Modal is not contained within a provider");
|
|
845
|
+
(0, $k7QOs$useEffect)(()=>{
|
|
762
846
|
if ((options === null || options === void 0 ? void 0 : options.isDisabled) || !context || !context.parent) return;
|
|
763
847
|
// The immediate context is from the provider containing this modal, so we only
|
|
764
848
|
// want to trigger aria-hidden on its parents not on the modal provider itself.
|
|
@@ -773,13 +857,23 @@ function $f57aed4a881a3485$export$33ffd74ebf07f060(options) {
|
|
|
773
857
|
]);
|
|
774
858
|
return {
|
|
775
859
|
modalProps: {
|
|
776
|
-
|
|
860
|
+
"data-ismodal": !(options === null || options === void 0 ? void 0 : options.isDisabled)
|
|
777
861
|
}
|
|
778
862
|
};
|
|
779
863
|
}
|
|
780
864
|
|
|
781
865
|
|
|
782
|
-
|
|
866
|
+
/*
|
|
867
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
868
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
869
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
870
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
871
|
+
*
|
|
872
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
873
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
874
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
875
|
+
* governing permissions and limitations under the License.
|
|
876
|
+
*/ var $61fe14465afefc5e$exports = {};
|
|
783
877
|
var $773d5888b972f1cf$exports = {};
|
|
784
878
|
$773d5888b972f1cf$exports = {
|
|
785
879
|
"dismiss": `تجاهل`
|
|
@@ -1028,16 +1122,16 @@ $61fe14465afefc5e$exports = {
|
|
|
1028
1122
|
|
|
1029
1123
|
function $86ea4cb521eb2e37$export$2317d149ed6f78c4(props) {
|
|
1030
1124
|
let { onDismiss: onDismiss , ...otherProps } = props;
|
|
1031
|
-
let stringFormatter = $k7QOs$useLocalizedStringFormatter((/*@__PURE__*/$parcel$interopDefault($61fe14465afefc5e$exports)));
|
|
1032
|
-
let labels = $k7QOs$useLabels(otherProps, stringFormatter.format(
|
|
1125
|
+
let stringFormatter = (0, $k7QOs$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($61fe14465afefc5e$exports))));
|
|
1126
|
+
let labels = (0, $k7QOs$useLabels)(otherProps, stringFormatter.format("dismiss"));
|
|
1033
1127
|
let onClick = ()=>{
|
|
1034
1128
|
if (onDismiss) onDismiss();
|
|
1035
1129
|
};
|
|
1036
|
-
return
|
|
1130
|
+
return /*#__PURE__*/ (0, $k7QOs$react).createElement((0, $k7QOs$VisuallyHidden), null, /*#__PURE__*/ (0, $k7QOs$react).createElement("button", {
|
|
1037
1131
|
...labels,
|
|
1038
1132
|
tabIndex: -1,
|
|
1039
1133
|
onClick: onClick
|
|
1040
|
-
}))
|
|
1134
|
+
}));
|
|
1041
1135
|
}
|
|
1042
1136
|
|
|
1043
1137
|
|
|
@@ -1061,48 +1155,46 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
|
|
|
1061
1155
|
let walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
|
|
1062
1156
|
acceptNode (node) {
|
|
1063
1157
|
// If this node is a live announcer, add it to the set of nodes to keep visible.
|
|
1064
|
-
if ((node instanceof HTMLElement || node instanceof SVGElement) && node.dataset.liveAnnouncer ===
|
|
1158
|
+
if ((node instanceof HTMLElement || node instanceof SVGElement) && node.dataset.liveAnnouncer === "true") visibleNodes.add(node);
|
|
1065
1159
|
// Skip this node and its children if it is one of the target nodes, or a live announcer.
|
|
1066
1160
|
// Also skip children of already hidden nodes, as aria-hidden is recursive. An exception is
|
|
1067
1161
|
// made for elements with role="row" since VoiceOver on iOS has issues hiding elements with role="row".
|
|
1068
1162
|
// For that case we want to hide the cells inside as well (https://bugs.webkit.org/show_bug.cgi?id=222623).
|
|
1069
|
-
if (visibleNodes.has(node) || hiddenNodes.has(node.parentElement) && node.parentElement.getAttribute(
|
|
1163
|
+
if (visibleNodes.has(node) || hiddenNodes.has(node.parentElement) && node.parentElement.getAttribute("role") !== "row") return NodeFilter.FILTER_REJECT;
|
|
1070
1164
|
// Skip this node but continue to children if one of the targets is inside the node.
|
|
1071
|
-
if (targets.some((target)=>node.contains(target)
|
|
1072
|
-
)) return NodeFilter.FILTER_SKIP;
|
|
1165
|
+
if (targets.some((target)=>node.contains(target))) return NodeFilter.FILTER_SKIP;
|
|
1073
1166
|
return NodeFilter.FILTER_ACCEPT;
|
|
1074
1167
|
}
|
|
1075
1168
|
});
|
|
1076
1169
|
let hide = (node)=>{
|
|
1077
|
-
var
|
|
1078
|
-
let refCount = (
|
|
1170
|
+
var _refCountMap_get;
|
|
1171
|
+
let refCount = (_refCountMap_get = $5e3802645cc19319$var$refCountMap.get(node)) !== null && _refCountMap_get !== void 0 ? _refCountMap_get : 0;
|
|
1079
1172
|
// If already aria-hidden, and the ref count is zero, then this element
|
|
1080
1173
|
// was already hidden and there's nothing for us to do.
|
|
1081
|
-
if (node.getAttribute(
|
|
1082
|
-
if (refCount === 0) node.setAttribute(
|
|
1174
|
+
if (node.getAttribute("aria-hidden") === "true" && refCount === 0) return;
|
|
1175
|
+
if (refCount === 0) node.setAttribute("aria-hidden", "true");
|
|
1083
1176
|
hiddenNodes.add(node);
|
|
1084
1177
|
$5e3802645cc19319$var$refCountMap.set(node, refCount + 1);
|
|
1085
1178
|
};
|
|
1086
1179
|
// If there is already a MutationObserver listening from a previous call,
|
|
1087
1180
|
// disconnect it so the new on takes over.
|
|
1088
1181
|
if ($5e3802645cc19319$var$observerStack.length) $5e3802645cc19319$var$observerStack[$5e3802645cc19319$var$observerStack.length - 1].disconnect();
|
|
1089
|
-
let
|
|
1090
|
-
while(
|
|
1091
|
-
hide(
|
|
1092
|
-
|
|
1182
|
+
let node = walker.nextNode();
|
|
1183
|
+
while(node != null){
|
|
1184
|
+
hide(node);
|
|
1185
|
+
node = walker.nextNode();
|
|
1093
1186
|
}
|
|
1094
1187
|
let observer = new MutationObserver((changes)=>{
|
|
1095
1188
|
for (let change of changes){
|
|
1096
|
-
if (change.type !==
|
|
1189
|
+
if (change.type !== "childList" || change.addedNodes.length === 0) continue;
|
|
1097
1190
|
// If the parent element of the added nodes is not within one of the targets,
|
|
1098
1191
|
// and not already inside a hidden node, hide all of the new children.
|
|
1099
1192
|
if (![
|
|
1100
1193
|
...visibleNodes,
|
|
1101
1194
|
...hiddenNodes
|
|
1102
|
-
].some((node)=>node.contains(change.target)
|
|
1103
|
-
|
|
1104
|
-
if (
|
|
1105
|
-
else if (node2 instanceof Element) hide(node2);
|
|
1195
|
+
].some((node)=>node.contains(change.target))) for (let node of change.addedNodes){
|
|
1196
|
+
if ((node instanceof HTMLElement || node instanceof SVGElement) && node.dataset.liveAnnouncer === "true") visibleNodes.add(node);
|
|
1197
|
+
else if (node instanceof Element) hide(node);
|
|
1106
1198
|
}
|
|
1107
1199
|
}
|
|
1108
1200
|
});
|
|
@@ -1127,7 +1219,7 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
|
|
|
1127
1219
|
for (let node of hiddenNodes){
|
|
1128
1220
|
let count = $5e3802645cc19319$var$refCountMap.get(node);
|
|
1129
1221
|
if (count === 1) {
|
|
1130
|
-
node.removeAttribute(
|
|
1222
|
+
node.removeAttribute("aria-hidden");
|
|
1131
1223
|
$5e3802645cc19319$var$refCountMap.delete(node);
|
|
1132
1224
|
} else $5e3802645cc19319$var$refCountMap.set(node, count - 1);
|
|
1133
1225
|
}
|
|
@@ -1140,7 +1232,17 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
|
|
|
1140
1232
|
}
|
|
1141
1233
|
|
|
1142
1234
|
|
|
1143
|
-
|
|
1235
|
+
/*
|
|
1236
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
1237
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1238
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1239
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1240
|
+
*
|
|
1241
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1242
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1243
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1244
|
+
* governing permissions and limitations under the License.
|
|
1245
|
+
*/
|
|
1144
1246
|
|
|
1145
1247
|
|
|
1146
1248
|
|
|
@@ -1148,14 +1250,14 @@ function $5e3802645cc19319$export$1c3ebcada18427bf(targets, root = document.body
|
|
|
1148
1250
|
|
|
1149
1251
|
function $f2f8a6077418541e$export$542a6fd13ac93354(props, state) {
|
|
1150
1252
|
let { triggerRef: triggerRef , popoverRef: popoverRef , isNonModal: isNonModal , isKeyboardDismissDisabled: isKeyboardDismissDisabled , ...otherProps } = props;
|
|
1151
|
-
let { overlayProps: overlayProps , underlayProps: underlayProps } = $a11501f3d1d39e6c$export$ea8f71083e90600f({
|
|
1253
|
+
let { overlayProps: overlayProps , underlayProps: underlayProps } = (0, $a11501f3d1d39e6c$export$ea8f71083e90600f)({
|
|
1152
1254
|
isOpen: state.isOpen,
|
|
1153
1255
|
onClose: state.close,
|
|
1154
1256
|
shouldCloseOnBlur: true,
|
|
1155
1257
|
isDismissable: !isNonModal,
|
|
1156
1258
|
isKeyboardDismissDisabled: isKeyboardDismissDisabled
|
|
1157
1259
|
}, popoverRef);
|
|
1158
|
-
let { overlayProps: positionProps , arrowProps: arrowProps , placement: placement } = $2a41e45df1593e64$export$d39e1813b3bdd0e1({
|
|
1260
|
+
let { overlayProps: positionProps , arrowProps: arrowProps , placement: placement } = (0, $2a41e45df1593e64$export$d39e1813b3bdd0e1)({
|
|
1159
1261
|
...otherProps,
|
|
1160
1262
|
targetRef: triggerRef,
|
|
1161
1263
|
overlayRef: popoverRef,
|
|
@@ -1165,18 +1267,18 @@ function $f2f8a6077418541e$export$542a6fd13ac93354(props, state) {
|
|
|
1165
1267
|
// Delay preventing scroll until popover is positioned to avoid extra scroll padding.
|
|
1166
1268
|
// This requires a layout effect so that positioning has been committed to the DOM
|
|
1167
1269
|
// by the time usePreventScroll measures the element.
|
|
1168
|
-
let [isPositioned, setPositioned] = $k7QOs$useState(false);
|
|
1169
|
-
$k7QOs$useLayoutEffect(()=>{
|
|
1270
|
+
let [isPositioned, setPositioned] = (0, $k7QOs$useState)(false);
|
|
1271
|
+
(0, $k7QOs$useLayoutEffect)(()=>{
|
|
1170
1272
|
if (!isNonModal && placement) setPositioned(true);
|
|
1171
1273
|
}, [
|
|
1172
1274
|
isNonModal,
|
|
1173
1275
|
placement
|
|
1174
1276
|
]);
|
|
1175
|
-
$49c51c25361d4cd2$export$ee0f7cc6afcd1c18({
|
|
1277
|
+
(0, $49c51c25361d4cd2$export$ee0f7cc6afcd1c18)({
|
|
1176
1278
|
isDisabled: isNonModal || !isPositioned
|
|
1177
1279
|
});
|
|
1178
|
-
$k7QOs$useLayoutEffect(()=>{
|
|
1179
|
-
if (state.isOpen && !isNonModal && popoverRef.current) return $5e3802645cc19319$export$1c3ebcada18427bf([
|
|
1280
|
+
(0, $k7QOs$useLayoutEffect)(()=>{
|
|
1281
|
+
if (state.isOpen && !isNonModal && popoverRef.current) return (0, $5e3802645cc19319$export$1c3ebcada18427bf)([
|
|
1180
1282
|
popoverRef.current
|
|
1181
1283
|
]);
|
|
1182
1284
|
}, [
|
|
@@ -1185,7 +1287,7 @@ function $f2f8a6077418541e$export$542a6fd13ac93354(props, state) {
|
|
|
1185
1287
|
popoverRef
|
|
1186
1288
|
]);
|
|
1187
1289
|
return {
|
|
1188
|
-
popoverProps: $k7QOs$mergeProps(overlayProps, positionProps),
|
|
1290
|
+
popoverProps: (0, $k7QOs$mergeProps)(overlayProps, positionProps),
|
|
1189
1291
|
arrowProps: arrowProps,
|
|
1190
1292
|
underlayProps: underlayProps,
|
|
1191
1293
|
placement: placement
|
|
@@ -1193,41 +1295,60 @@ function $f2f8a6077418541e$export$542a6fd13ac93354(props, state) {
|
|
|
1193
1295
|
}
|
|
1194
1296
|
|
|
1195
1297
|
|
|
1298
|
+
/*
|
|
1299
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
1300
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1301
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1302
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1303
|
+
*
|
|
1304
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1305
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1306
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1307
|
+
* governing permissions and limitations under the License.
|
|
1308
|
+
*/
|
|
1196
1309
|
|
|
1197
1310
|
|
|
1198
1311
|
|
|
1312
|
+
/*
|
|
1313
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
1314
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1315
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1316
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1317
|
+
*
|
|
1318
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1319
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1320
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1321
|
+
* governing permissions and limitations under the License.
|
|
1322
|
+
*/
|
|
1199
1323
|
|
|
1200
1324
|
|
|
1201
1325
|
|
|
1202
1326
|
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
const $337b884510726a0d$export$a2200b96afd16271 = /*#__PURE__*/ $k7QOs$react.createContext(null);
|
|
1327
|
+
const $337b884510726a0d$export$a2200b96afd16271 = /*#__PURE__*/ (0, $k7QOs$react).createContext(null);
|
|
1206
1328
|
function $337b884510726a0d$export$c6fdb837b070b4ff(props) {
|
|
1207
|
-
let isSSR = $k7QOs$useIsSSR();
|
|
1329
|
+
let isSSR = (0, $k7QOs$useIsSSR)();
|
|
1208
1330
|
let { portalContainer: portalContainer = isSSR ? null : document.body } = props;
|
|
1209
|
-
let [contain, setContain] = $k7QOs$useState(false);
|
|
1210
|
-
let contextValue = $k7QOs$useMemo(()=>({
|
|
1331
|
+
let [contain, setContain] = (0, $k7QOs$useState)(false);
|
|
1332
|
+
let contextValue = (0, $k7QOs$useMemo)(()=>({
|
|
1211
1333
|
contain: contain,
|
|
1212
1334
|
setContain: setContain
|
|
1213
|
-
})
|
|
1214
|
-
, [
|
|
1335
|
+
}), [
|
|
1215
1336
|
contain,
|
|
1216
1337
|
setContain
|
|
1217
1338
|
]);
|
|
1218
1339
|
if (!portalContainer) return null;
|
|
1219
|
-
let contents = /*#__PURE__*/ $k7QOs$react.createElement($337b884510726a0d$export$a2200b96afd16271.Provider, {
|
|
1340
|
+
let contents = /*#__PURE__*/ (0, $k7QOs$react).createElement($337b884510726a0d$export$a2200b96afd16271.Provider, {
|
|
1220
1341
|
value: contextValue
|
|
1221
|
-
}, /*#__PURE__*/ $k7QOs$react.createElement($k7QOs$FocusScope, {
|
|
1342
|
+
}, /*#__PURE__*/ (0, $k7QOs$react).createElement((0, $k7QOs$FocusScope), {
|
|
1222
1343
|
restoreFocus: true,
|
|
1223
1344
|
contain: contain
|
|
1224
1345
|
}, props.children));
|
|
1225
|
-
return
|
|
1346
|
+
return /*#__PURE__*/ (0, $k7QOs$reactdom).createPortal(contents, portalContainer);
|
|
1226
1347
|
}
|
|
1227
1348
|
function $337b884510726a0d$export$14c98a7594375490() {
|
|
1228
|
-
let ctx = $k7QOs$useContext($337b884510726a0d$export$a2200b96afd16271);
|
|
1349
|
+
let ctx = (0, $k7QOs$useContext)($337b884510726a0d$export$a2200b96afd16271);
|
|
1229
1350
|
let setContain = ctx === null || ctx === void 0 ? void 0 : ctx.setContain;
|
|
1230
|
-
$k7QOs$useLayoutEffect(()=>{
|
|
1351
|
+
(0, $k7QOs$useLayoutEffect)(()=>{
|
|
1231
1352
|
setContain === null || setContain === void 0 ? void 0 : setContain(true);
|
|
1232
1353
|
}, [
|
|
1233
1354
|
setContain
|
|
@@ -1237,17 +1358,17 @@ function $337b884510726a0d$export$14c98a7594375490() {
|
|
|
1237
1358
|
|
|
1238
1359
|
|
|
1239
1360
|
function $8ac8429251c45e4b$export$dbc0f175b25fb0fb(props, state, ref) {
|
|
1240
|
-
let { overlayProps: overlayProps , underlayProps: underlayProps } = $a11501f3d1d39e6c$export$ea8f71083e90600f({
|
|
1361
|
+
let { overlayProps: overlayProps , underlayProps: underlayProps } = (0, $a11501f3d1d39e6c$export$ea8f71083e90600f)({
|
|
1241
1362
|
...props,
|
|
1242
1363
|
isOpen: state.isOpen,
|
|
1243
1364
|
onClose: state.close
|
|
1244
1365
|
}, ref);
|
|
1245
|
-
$49c51c25361d4cd2$export$ee0f7cc6afcd1c18({
|
|
1366
|
+
(0, $49c51c25361d4cd2$export$ee0f7cc6afcd1c18)({
|
|
1246
1367
|
isDisabled: !state.isOpen
|
|
1247
1368
|
});
|
|
1248
|
-
$337b884510726a0d$export$14c98a7594375490();
|
|
1249
|
-
$k7QOs$useEffect(()=>{
|
|
1250
|
-
if (state.isOpen) return $5e3802645cc19319$export$1c3ebcada18427bf([
|
|
1369
|
+
(0, $337b884510726a0d$export$14c98a7594375490)();
|
|
1370
|
+
(0, $k7QOs$useEffect)(()=>{
|
|
1371
|
+
if (state.isOpen) return (0, $5e3802645cc19319$export$1c3ebcada18427bf)([
|
|
1251
1372
|
ref.current
|
|
1252
1373
|
]);
|
|
1253
1374
|
}, [
|
|
@@ -1255,7 +1376,7 @@ function $8ac8429251c45e4b$export$dbc0f175b25fb0fb(props, state, ref) {
|
|
|
1255
1376
|
ref
|
|
1256
1377
|
]);
|
|
1257
1378
|
return {
|
|
1258
|
-
modalProps: $k7QOs$mergeProps(overlayProps),
|
|
1379
|
+
modalProps: (0, $k7QOs$mergeProps)(overlayProps),
|
|
1259
1380
|
underlayProps: underlayProps
|
|
1260
1381
|
};
|
|
1261
1382
|
}
|