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