@react-aria/overlays 3.21.1 → 3.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DismissButton.main.js +51 -0
- package/dist/DismissButton.main.js.map +1 -0
- package/dist/DismissButton.mjs +46 -0
- package/dist/DismissButton.module.js +46 -0
- package/dist/DismissButton.module.js.map +1 -0
- package/dist/Overlay.main.js +73 -0
- package/dist/Overlay.main.js.map +1 -0
- package/dist/Overlay.mjs +63 -0
- package/dist/Overlay.module.js +63 -0
- package/dist/Overlay.module.js.map +1 -0
- package/dist/PortalProvider.main.js +41 -0
- package/dist/PortalProvider.main.js.map +1 -0
- package/dist/PortalProvider.mjs +31 -0
- package/dist/PortalProvider.module.js +31 -0
- package/dist/PortalProvider.module.js.map +1 -0
- package/dist/ar-AE.mjs +1 -1
- package/dist/ariaHideOutside.main.js +121 -0
- package/dist/ariaHideOutside.main.js.map +1 -0
- package/dist/ariaHideOutside.mjs +116 -0
- package/dist/ariaHideOutside.module.js +116 -0
- package/dist/ariaHideOutside.module.js.map +1 -0
- package/dist/bg-BG.mjs +1 -1
- package/dist/calculatePosition.main.js +355 -0
- package/dist/calculatePosition.main.js.map +1 -0
- package/dist/calculatePosition.mjs +350 -0
- package/dist/calculatePosition.module.js +350 -0
- package/dist/calculatePosition.module.js.map +1 -0
- package/dist/cs-CZ.mjs +1 -1
- package/dist/da-DK.mjs +1 -1
- package/dist/de-DE.mjs +1 -1
- package/dist/el-GR.mjs +1 -1
- package/dist/en-US.mjs +1 -1
- package/dist/es-ES.mjs +1 -1
- package/dist/et-EE.mjs +1 -1
- package/dist/fi-FI.mjs +1 -1
- package/dist/fr-FR.mjs +1 -1
- package/dist/he-IL.mjs +1 -1
- package/dist/hr-HR.mjs +1 -1
- package/dist/hu-HU.mjs +1 -1
- package/dist/import.mjs +12 -1397
- package/dist/intlStrings.main.js +108 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +110 -0
- package/dist/intlStrings.module.js +110 -0
- package/dist/intlStrings.module.js.map +1 -0
- package/dist/it-IT.mjs +1 -1
- package/dist/ja-JP.mjs +1 -1
- package/dist/ko-KR.mjs +1 -1
- package/dist/lt-LT.mjs +1 -1
- package/dist/lv-LV.mjs +1 -1
- package/dist/main.js +28 -1411
- package/dist/main.js.map +1 -1
- package/dist/module.js +12 -1397
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.mjs +1 -1
- package/dist/nl-NL.mjs +1 -1
- package/dist/pl-PL.mjs +1 -1
- package/dist/pt-BR.mjs +1 -1
- package/dist/pt-PT.mjs +1 -1
- package/dist/ro-RO.mjs +1 -1
- package/dist/ru-RU.mjs +1 -1
- package/dist/sk-SK.mjs +1 -1
- package/dist/sl-SI.mjs +1 -1
- package/dist/sr-SP.mjs +1 -1
- package/dist/sv-SE.mjs +1 -1
- package/dist/tr-TR.mjs +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.mjs +1 -1
- package/dist/useCloseOnScroll.main.js +46 -0
- package/dist/useCloseOnScroll.main.js.map +1 -0
- package/dist/useCloseOnScroll.mjs +40 -0
- package/dist/useCloseOnScroll.module.js +40 -0
- package/dist/useCloseOnScroll.module.js.map +1 -0
- package/dist/useModal.main.js +114 -0
- package/dist/useModal.main.js.map +1 -0
- package/dist/useModal.mjs +101 -0
- package/dist/useModal.module.js +101 -0
- package/dist/useModal.module.js.map +1 -0
- package/dist/useModalOverlay.main.js +55 -0
- package/dist/useModalOverlay.main.js.map +1 -0
- package/dist/useModalOverlay.mjs +50 -0
- package/dist/useModalOverlay.module.js +50 -0
- package/dist/useModalOverlay.module.js.map +1 -0
- package/dist/useOverlay.main.js +105 -0
- package/dist/useOverlay.main.js.map +1 -0
- package/dist/useOverlay.mjs +100 -0
- package/dist/useOverlay.module.js +100 -0
- package/dist/useOverlay.module.js.map +1 -0
- package/dist/useOverlayPosition.main.js +181 -0
- package/dist/useOverlayPosition.main.js.map +1 -0
- package/dist/useOverlayPosition.mjs +176 -0
- package/dist/useOverlayPosition.module.js +176 -0
- package/dist/useOverlayPosition.module.js.map +1 -0
- package/dist/useOverlayTrigger.main.js +54 -0
- package/dist/useOverlayTrigger.main.js.map +1 -0
- package/dist/useOverlayTrigger.mjs +49 -0
- package/dist/useOverlayTrigger.module.js +49 -0
- package/dist/useOverlayTrigger.module.js.map +1 -0
- package/dist/usePopover.main.js +66 -0
- package/dist/usePopover.main.js.map +1 -0
- package/dist/usePopover.mjs +61 -0
- package/dist/usePopover.module.js +61 -0
- package/dist/usePopover.module.js.map +1 -0
- package/dist/usePreventScroll.main.js +226 -0
- package/dist/usePreventScroll.main.js.map +1 -0
- package/dist/usePreventScroll.mjs +221 -0
- package/dist/usePreventScroll.module.js +221 -0
- package/dist/usePreventScroll.module.js.map +1 -0
- package/dist/zh-CN.mjs +1 -1
- package/dist/zh-TW.mjs +1 -1
- package/package.json +12 -12
- package/src/Overlay.tsx +6 -0
- package/src/PortalProvider.tsx +34 -0
- package/src/index.ts +1 -0
- package/src/useModalOverlay.ts +2 -2
- package/src/useOverlay.ts +1 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import {calculatePosition as $edcf132a9284368a$export$b3ceb0cbf1056d98} from "./calculatePosition.module.js";
|
|
2
|
+
import {useCloseOnScroll as $dd149f63282afbbf$export$18fc8428861184da} from "./useCloseOnScroll.module.js";
|
|
3
|
+
import {useState as $39EOa$useState, useRef as $39EOa$useRef, useEffect as $39EOa$useEffect, useCallback as $39EOa$useCallback} from "react";
|
|
4
|
+
import {useLayoutEffect as $39EOa$useLayoutEffect, useResizeObserver as $39EOa$useResizeObserver} from "@react-aria/utils";
|
|
5
|
+
import {useLocale as $39EOa$useLocale} from "@react-aria/i18n";
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
* governing permissions and limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
let $2a41e45df1593e64$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
|
|
24
|
+
function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
|
|
25
|
+
let { direction: direction } = (0, $39EOa$useLocale)();
|
|
26
|
+
let { arrowSize: arrowSize = 0, targetRef: targetRef, overlayRef: overlayRef, scrollRef: scrollRef = overlayRef, placement: placement = "bottom", containerPadding: containerPadding = 12, shouldFlip: shouldFlip = true, boundaryElement: boundaryElement = typeof document !== "undefined" ? document.body : null, offset: offset = 0, crossOffset: crossOffset = 0, shouldUpdatePosition: shouldUpdatePosition = true, isOpen: isOpen = true, onClose: onClose, maxHeight: maxHeight, arrowBoundaryOffset: arrowBoundaryOffset = 0 } = props;
|
|
27
|
+
let [position, setPosition] = (0, $39EOa$useState)({
|
|
28
|
+
position: {},
|
|
29
|
+
arrowOffsetLeft: undefined,
|
|
30
|
+
arrowOffsetTop: undefined,
|
|
31
|
+
maxHeight: undefined,
|
|
32
|
+
placement: undefined
|
|
33
|
+
});
|
|
34
|
+
let deps = [
|
|
35
|
+
shouldUpdatePosition,
|
|
36
|
+
placement,
|
|
37
|
+
overlayRef.current,
|
|
38
|
+
targetRef.current,
|
|
39
|
+
scrollRef.current,
|
|
40
|
+
containerPadding,
|
|
41
|
+
shouldFlip,
|
|
42
|
+
boundaryElement,
|
|
43
|
+
offset,
|
|
44
|
+
crossOffset,
|
|
45
|
+
isOpen,
|
|
46
|
+
direction,
|
|
47
|
+
maxHeight,
|
|
48
|
+
arrowBoundaryOffset,
|
|
49
|
+
arrowSize
|
|
50
|
+
];
|
|
51
|
+
// Note, the position freezing breaks if body sizes itself dynamicly with the visual viewport but that might
|
|
52
|
+
// just be a non-realistic use case
|
|
53
|
+
// Upon opening a overlay, record the current visual viewport scale so we can freeze the overlay styles
|
|
54
|
+
let lastScale = (0, $39EOa$useRef)($2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale);
|
|
55
|
+
(0, $39EOa$useEffect)(()=>{
|
|
56
|
+
if (isOpen) lastScale.current = $2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale;
|
|
57
|
+
}, [
|
|
58
|
+
isOpen
|
|
59
|
+
]);
|
|
60
|
+
let updatePosition = (0, $39EOa$useCallback)(()=>{
|
|
61
|
+
if (shouldUpdatePosition === false || !isOpen || !overlayRef.current || !targetRef.current || !scrollRef.current || !boundaryElement) return;
|
|
62
|
+
if (($2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.scale) !== lastScale.current) return;
|
|
63
|
+
// Always reset the overlay's previous max height if not defined by the user so that we can compensate for
|
|
64
|
+
// RAC collections populating after a second render and properly set a correct max height + positioning when it populates.
|
|
65
|
+
if (!maxHeight && overlayRef.current) overlayRef.current.style.maxHeight = "none";
|
|
66
|
+
let position = (0, $edcf132a9284368a$export$b3ceb0cbf1056d98)({
|
|
67
|
+
placement: $2a41e45df1593e64$var$translateRTL(placement, direction),
|
|
68
|
+
overlayNode: overlayRef.current,
|
|
69
|
+
targetNode: targetRef.current,
|
|
70
|
+
scrollNode: scrollRef.current,
|
|
71
|
+
padding: containerPadding,
|
|
72
|
+
shouldFlip: shouldFlip,
|
|
73
|
+
boundaryElement: boundaryElement,
|
|
74
|
+
offset: offset,
|
|
75
|
+
crossOffset: crossOffset,
|
|
76
|
+
maxHeight: maxHeight,
|
|
77
|
+
arrowSize: arrowSize,
|
|
78
|
+
arrowBoundaryOffset: arrowBoundaryOffset
|
|
79
|
+
});
|
|
80
|
+
// Modify overlay styles directly so positioning happens immediately without the need of a second render
|
|
81
|
+
// This is so we don't have to delay autoFocus scrolling or delay applying preventScroll for popovers
|
|
82
|
+
Object.keys(position.position).forEach((key)=>overlayRef.current.style[key] = position.position[key] + "px");
|
|
83
|
+
overlayRef.current.style.maxHeight = position.maxHeight != null ? position.maxHeight + "px" : undefined;
|
|
84
|
+
// Trigger a set state for a second render anyway for arrow positioning
|
|
85
|
+
setPosition(position);
|
|
86
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
87
|
+
}, deps);
|
|
88
|
+
// Update position when anything changes
|
|
89
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
90
|
+
(0, $39EOa$useLayoutEffect)(updatePosition, deps);
|
|
91
|
+
// Update position on window resize
|
|
92
|
+
$2a41e45df1593e64$var$useResize(updatePosition);
|
|
93
|
+
// Update position when the overlay changes size (might need to flip).
|
|
94
|
+
(0, $39EOa$useResizeObserver)({
|
|
95
|
+
ref: overlayRef,
|
|
96
|
+
onResize: updatePosition
|
|
97
|
+
});
|
|
98
|
+
// Reposition the overlay and do not close on scroll while the visual viewport is resizing.
|
|
99
|
+
// This will ensure that overlays adjust their positioning when the iOS virtual keyboard appears.
|
|
100
|
+
let isResizing = (0, $39EOa$useRef)(false);
|
|
101
|
+
(0, $39EOa$useLayoutEffect)(()=>{
|
|
102
|
+
let timeout;
|
|
103
|
+
let onResize = ()=>{
|
|
104
|
+
isResizing.current = true;
|
|
105
|
+
clearTimeout(timeout);
|
|
106
|
+
timeout = setTimeout(()=>{
|
|
107
|
+
isResizing.current = false;
|
|
108
|
+
}, 500);
|
|
109
|
+
updatePosition();
|
|
110
|
+
};
|
|
111
|
+
// Only reposition the overlay if a scroll event happens immediately as a result of resize (aka the virtual keyboard has appears)
|
|
112
|
+
// We don't want to reposition the overlay if the user has pinch zoomed in and is scrolling the viewport around.
|
|
113
|
+
let onScroll = ()=>{
|
|
114
|
+
if (isResizing.current) onResize();
|
|
115
|
+
};
|
|
116
|
+
$2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.addEventListener("resize", onResize);
|
|
117
|
+
$2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.addEventListener("scroll", onScroll);
|
|
118
|
+
return ()=>{
|
|
119
|
+
$2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.removeEventListener("resize", onResize);
|
|
120
|
+
$2a41e45df1593e64$var$visualViewport === null || $2a41e45df1593e64$var$visualViewport === void 0 ? void 0 : $2a41e45df1593e64$var$visualViewport.removeEventListener("scroll", onScroll);
|
|
121
|
+
};
|
|
122
|
+
}, [
|
|
123
|
+
updatePosition
|
|
124
|
+
]);
|
|
125
|
+
let close = (0, $39EOa$useCallback)(()=>{
|
|
126
|
+
if (!isResizing.current) onClose();
|
|
127
|
+
}, [
|
|
128
|
+
onClose,
|
|
129
|
+
isResizing
|
|
130
|
+
]);
|
|
131
|
+
// When scrolling a parent scrollable region of the trigger (other than the body),
|
|
132
|
+
// we hide the popover. Otherwise, its position would be incorrect.
|
|
133
|
+
(0, $dd149f63282afbbf$export$18fc8428861184da)({
|
|
134
|
+
triggerRef: targetRef,
|
|
135
|
+
isOpen: isOpen,
|
|
136
|
+
onClose: onClose && close
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
overlayProps: {
|
|
140
|
+
style: {
|
|
141
|
+
position: "absolute",
|
|
142
|
+
zIndex: 100000,
|
|
143
|
+
...position.position,
|
|
144
|
+
maxHeight: position.maxHeight
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
placement: position.placement,
|
|
148
|
+
arrowProps: {
|
|
149
|
+
"aria-hidden": "true",
|
|
150
|
+
role: "presentation",
|
|
151
|
+
style: {
|
|
152
|
+
left: position.arrowOffsetLeft,
|
|
153
|
+
top: position.arrowOffsetTop
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
updatePosition: updatePosition
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function $2a41e45df1593e64$var$useResize(onResize) {
|
|
160
|
+
(0, $39EOa$useLayoutEffect)(()=>{
|
|
161
|
+
window.addEventListener("resize", onResize, false);
|
|
162
|
+
return ()=>{
|
|
163
|
+
window.removeEventListener("resize", onResize, false);
|
|
164
|
+
};
|
|
165
|
+
}, [
|
|
166
|
+
onResize
|
|
167
|
+
]);
|
|
168
|
+
}
|
|
169
|
+
function $2a41e45df1593e64$var$translateRTL(position, direction) {
|
|
170
|
+
if (direction === "rtl") return position.replace("start", "right").replace("end", "left");
|
|
171
|
+
return position.replace("start", "left").replace("end", "right");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
export {$2a41e45df1593e64$export$d39e1813b3bdd0e1 as useOverlayPosition};
|
|
176
|
+
//# sourceMappingURL=useOverlayPosition.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAgED,aAAa;AACb,IAAI,uCAAiB,OAAO,aAAa,eAAe,OAAO,cAAc;AAMtE,SAAS,0CAAmB,KAAwB;IACzD,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,aACF,YAAY,cACZ,SAAS,cACT,UAAU,aACV,YAAY,uBACZ,YAAY,4BACZ,mBAAmB,gBACnB,aAAa,uBACb,kBAAkB,OAAO,aAAa,cAAc,SAAS,IAAI,GAAG,cACpE,SAAS,gBACT,cAAc,yBACd,uBAAuB,cACvB,SAAS,eACT,OAAO,aACP,SAAS,uBACT,sBAAsB,GACvB,GAAG;IACJ,IAAI,CAAC,UAAU,YAAY,GAAG,CAAA,GAAA,eAAO,EAAkB;QACrD,UAAU,CAAC;QACX,iBAAiB;QACjB,gBAAgB;QAChB,WAAW;QACX,WAAW;IACb;IAEA,IAAI,OAAO;QACT;QACA;QACA,WAAW,OAAO;QAClB,UAAU,OAAO;QACjB,UAAU,OAAO;QACjB;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IAED,4GAA4G;IAC5G,mCAAmC;IACnC,uGAAuG;IACvG,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE,iDAAA,2DAAA,qCAAgB,KAAK;IAC5C,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,QACF,UAAU,OAAO,GAAG,iDAAA,2DAAA,qCAAgB,KAAK;IAE7C,GAAG;QAAC;KAAO;IAEX,IAAI,iBAAiB,CAAA,GAAA,kBAAU,EAAE;QAC/B,IAAI,yBAAyB,SAAS,CAAC,UAAU,CAAC,WAAW,OAAO,IAAI,CAAC,UAAU,OAAO,IAAI,CAAC,UAAU,OAAO,IAAI,CAAC,iBACnH;QAGF,IAAI,CAAA,iDAAA,2DAAA,qCAAgB,KAAK,MAAK,UAAU,OAAO,EAC7C;QAGF,0GAA0G;QAC1G,0HAA0H;QAC1H,IAAI,CAAC,aAAa,WAAW,OAAO,EAClC,AAAC,WAAW,OAAO,CAAiB,KAAK,CAAC,SAAS,GAAG;QAGxD,IAAI,WAAW,CAAA,GAAA,yCAAgB,EAAE;YAC/B,WAAW,mCAAa,WAAW;YACnC,aAAa,WAAW,OAAO;YAC/B,YAAY,UAAU,OAAO;YAC7B,YAAY,UAAU,OAAO;YAC7B,SAAS;wBACT;6BACA;oBACA;yBACA;uBACA;uBACA;iCACA;QACF;QAEA,wGAAwG;QACxG,qGAAqG;QACrG,OAAO,IAAI,CAAC,SAAS,QAAQ,EAAE,OAAO,CAAC,CAAA,MAAO,AAAC,WAAW,OAAO,CAAiB,KAAK,CAAC,IAAI,GAAG,SAAS,QAAQ,CAAC,IAAI,GAAG;QACvH,WAAW,OAAO,CAAiB,KAAK,CAAC,SAAS,GAAG,SAAS,SAAS,IAAI,OAAQ,SAAS,SAAS,GAAG,OAAO;QAEhH,uEAAuE;QACvE,YAAY;IACd,uDAAuD;IACvD,GAAG;IAEH,wCAAwC;IACxC,uDAAuD;IACvD,CAAA,GAAA,sBAAc,EAAE,gBAAgB;IAEhC,mCAAmC;IACnC,gCAAU;IAEV,sEAAsE;IACtE,CAAA,GAAA,wBAAgB,EAAE;QAChB,KAAK;QACL,UAAU;IACZ;IAEA,2FAA2F;IAC3F,iGAAiG;IACjG,IAAI,aAAa,CAAA,GAAA,aAAK,EAAE;IACxB,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI;QACJ,IAAI,WAAW;YACb,WAAW,OAAO,GAAG;YACrB,aAAa;YAEb,UAAU,WAAW;gBACnB,WAAW,OAAO,GAAG;YACvB,GAAG;YAEH;QACF;QAEA,iIAAiI;QACjI,gHAAgH;QAChH,IAAI,WAAW;YACb,IAAI,WAAW,OAAO,EACpB;QAEJ;QAEA,iDAAA,2DAAA,qCAAgB,gBAAgB,CAAC,UAAU;QAC3C,iDAAA,2DAAA,qCAAgB,gBAAgB,CAAC,UAAU;QAC3C,OAAO;YACL,iDAAA,2DAAA,qCAAgB,mBAAmB,CAAC,UAAU;YAC9C,iDAAA,2DAAA,qCAAgB,mBAAmB,CAAC,UAAU;QAChD;IACF,GAAG;QAAC;KAAe;IAEnB,IAAI,QAAQ,CAAA,GAAA,kBAAU,EAAE;QACtB,IAAI,CAAC,WAAW,OAAO,EACrB;IAEJ,GAAG;QAAC;QAAS;KAAW;IAExB,kFAAkF;IAClF,mEAAmE;IACnE,CAAA,GAAA,yCAAe,EAAE;QACf,YAAY;gBACZ;QACA,SAAS,WAAW;IACtB;IAEA,OAAO;QACL,cAAc;YACZ,OAAO;gBACL,UAAU;gBACV,QAAQ;gBACR,GAAG,SAAS,QAAQ;gBACpB,WAAW,SAAS,SAAS;YAC/B;QACF;QACA,WAAW,SAAS,SAAS;QAC7B,YAAY;YACV,eAAe;YACf,MAAM;YACN,OAAO;gBACL,MAAM,SAAS,eAAe;gBAC9B,KAAK,SAAS,cAAc;YAC9B;QACF;wBACA;IACF;AACF;AAEA,SAAS,gCAAU,QAAQ;IACzB,CAAA,GAAA,sBAAc,EAAE;QACd,OAAO,gBAAgB,CAAC,UAAU,UAAU;QAC5C,OAAO;YACL,OAAO,mBAAmB,CAAC,UAAU,UAAU;QACjD;IACF,GAAG;QAAC;KAAS;AACf;AAEA,SAAS,mCAAa,QAAQ,EAAE,SAAS;IACvC,IAAI,cAAc,OAChB,OAAO,SAAS,OAAO,CAAC,SAAS,SAAS,OAAO,CAAC,OAAO;IAE3D,OAAO,SAAS,OAAO,CAAC,SAAS,QAAQ,OAAO,CAAC,OAAO;AAC1D","sources":["packages/@react-aria/overlays/src/useOverlayPosition.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {calculatePosition, PositionResult} from './calculatePosition';\nimport {DOMAttributes} from '@react-types/shared';\nimport {Placement, PlacementAxis, PositionProps} from '@react-types/overlays';\nimport {RefObject, useCallback, useEffect, useRef, useState} from 'react';\nimport {useCloseOnScroll} from './useCloseOnScroll';\nimport {useLayoutEffect, useResizeObserver} from '@react-aria/utils';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface AriaPositionProps extends PositionProps {\n /**\n * Cross size of the overlay arrow in pixels.\n * @default 0\n */\n arrowSize?: number,\n /**\n * Element that that serves as the positioning boundary.\n * @default document.body\n */\n boundaryElement?: Element,\n /**\n * The ref for the element which the overlay positions itself with respect to.\n */\n targetRef: RefObject<Element>,\n /**\n * The ref for the overlay element.\n */\n overlayRef: RefObject<Element>,\n /**\n * A ref for the scrollable region within the overlay.\n * @default overlayRef\n */\n scrollRef?: RefObject<Element>,\n /**\n * Whether the overlay should update its position automatically.\n * @default true\n */\n shouldUpdatePosition?: boolean,\n /** Handler that is called when the overlay should close. */\n onClose?: () => void,\n /**\n * The maxHeight specified for the overlay element.\n * By default, it will take all space up to the current viewport height.\n */\n maxHeight?: number,\n /**\n * The minimum distance the arrow's edge should be from the edge of the overlay element.\n * @default 0\n */\n arrowBoundaryOffset?: number\n}\n\nexport interface PositionAria {\n /** Props for the overlay container element. */\n overlayProps: DOMAttributes,\n /** Props for the overlay tip arrow if any. */\n arrowProps: DOMAttributes,\n /** Placement of the overlay with respect to the overlay trigger. */\n placement: PlacementAxis,\n /** Updates the position of the overlay. */\n updatePosition(): void\n}\n\n// @ts-ignore\nlet visualViewport = typeof document !== 'undefined' && window.visualViewport;\n\n/**\n * Handles positioning overlays like popovers and menus relative to a trigger\n * element, and updating the position when the window resizes.\n */\nexport function useOverlayPosition(props: AriaPositionProps): PositionAria {\n let {direction} = useLocale();\n let {\n arrowSize = 0,\n targetRef,\n overlayRef,\n scrollRef = overlayRef,\n placement = 'bottom' as Placement,\n containerPadding = 12,\n shouldFlip = true,\n boundaryElement = typeof document !== 'undefined' ? document.body : null,\n offset = 0,\n crossOffset = 0,\n shouldUpdatePosition = true,\n isOpen = true,\n onClose,\n maxHeight,\n arrowBoundaryOffset = 0\n } = props;\n let [position, setPosition] = useState<PositionResult>({\n position: {},\n arrowOffsetLeft: undefined,\n arrowOffsetTop: undefined,\n maxHeight: undefined,\n placement: undefined\n });\n\n let deps = [\n shouldUpdatePosition,\n placement,\n overlayRef.current,\n targetRef.current,\n scrollRef.current,\n containerPadding,\n shouldFlip,\n boundaryElement,\n offset,\n crossOffset,\n isOpen,\n direction,\n maxHeight,\n arrowBoundaryOffset,\n arrowSize\n ];\n\n // Note, the position freezing breaks if body sizes itself dynamicly with the visual viewport but that might\n // just be a non-realistic use case\n // Upon opening a overlay, record the current visual viewport scale so we can freeze the overlay styles\n let lastScale = useRef(visualViewport?.scale);\n useEffect(() => {\n if (isOpen) {\n lastScale.current = visualViewport?.scale;\n }\n }, [isOpen]);\n\n let updatePosition = useCallback(() => {\n if (shouldUpdatePosition === false || !isOpen || !overlayRef.current || !targetRef.current || !scrollRef.current || !boundaryElement) {\n return;\n }\n\n if (visualViewport?.scale !== lastScale.current) {\n return;\n }\n\n // Always reset the overlay's previous max height if not defined by the user so that we can compensate for\n // RAC collections populating after a second render and properly set a correct max height + positioning when it populates.\n if (!maxHeight && overlayRef.current) {\n (overlayRef.current as HTMLElement).style.maxHeight = 'none';\n }\n\n let position = calculatePosition({\n placement: translateRTL(placement, direction),\n overlayNode: overlayRef.current,\n targetNode: targetRef.current,\n scrollNode: scrollRef.current,\n padding: containerPadding,\n shouldFlip,\n boundaryElement,\n offset,\n crossOffset,\n maxHeight,\n arrowSize,\n arrowBoundaryOffset\n });\n\n // Modify overlay styles directly so positioning happens immediately without the need of a second render\n // This is so we don't have to delay autoFocus scrolling or delay applying preventScroll for popovers\n Object.keys(position.position).forEach(key => (overlayRef.current as HTMLElement).style[key] = position.position[key] + 'px');\n (overlayRef.current as HTMLElement).style.maxHeight = position.maxHeight != null ? position.maxHeight + 'px' : undefined;\n\n // Trigger a set state for a second render anyway for arrow positioning\n setPosition(position);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n // Update position when anything changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(updatePosition, deps);\n\n // Update position on window resize\n useResize(updatePosition);\n\n // Update position when the overlay changes size (might need to flip).\n useResizeObserver({\n ref: overlayRef,\n onResize: updatePosition\n });\n\n // Reposition the overlay and do not close on scroll while the visual viewport is resizing.\n // This will ensure that overlays adjust their positioning when the iOS virtual keyboard appears.\n let isResizing = useRef(false);\n useLayoutEffect(() => {\n let timeout: ReturnType<typeof setTimeout>;\n let onResize = () => {\n isResizing.current = true;\n clearTimeout(timeout);\n\n timeout = setTimeout(() => {\n isResizing.current = false;\n }, 500);\n\n updatePosition();\n };\n\n // Only reposition the overlay if a scroll event happens immediately as a result of resize (aka the virtual keyboard has appears)\n // We don't want to reposition the overlay if the user has pinch zoomed in and is scrolling the viewport around.\n let onScroll = () => {\n if (isResizing.current) {\n onResize();\n }\n };\n\n visualViewport?.addEventListener('resize', onResize);\n visualViewport?.addEventListener('scroll', onScroll);\n return () => {\n visualViewport?.removeEventListener('resize', onResize);\n visualViewport?.removeEventListener('scroll', onScroll);\n };\n }, [updatePosition]);\n\n let close = useCallback(() => {\n if (!isResizing.current) {\n onClose();\n }\n }, [onClose, isResizing]);\n\n // When scrolling a parent scrollable region of the trigger (other than the body),\n // we hide the popover. Otherwise, its position would be incorrect.\n useCloseOnScroll({\n triggerRef: targetRef,\n isOpen,\n onClose: onClose && close\n });\n\n return {\n overlayProps: {\n style: {\n position: 'absolute',\n zIndex: 100000, // should match the z-index in ModalTrigger\n ...position.position,\n maxHeight: position.maxHeight\n }\n },\n placement: position.placement,\n arrowProps: {\n 'aria-hidden': 'true',\n role: 'presentation',\n style: {\n left: position.arrowOffsetLeft,\n top: position.arrowOffsetTop\n }\n },\n updatePosition\n };\n}\n\nfunction useResize(onResize) {\n useLayoutEffect(() => {\n window.addEventListener('resize', onResize, false);\n return () => {\n window.removeEventListener('resize', onResize, false);\n };\n }, [onResize]);\n}\n\nfunction translateRTL(position, direction) {\n if (direction === 'rtl') {\n return position.replace('start', 'right').replace('end', 'left');\n }\n return position.replace('start', 'left').replace('end', 'right');\n}\n"],"names":[],"version":3,"file":"useOverlayPosition.module.js.map"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var $9a8aa1b0b336ea3a$exports = require("./useCloseOnScroll.main.js");
|
|
2
|
+
var $3l9xr$react = require("react");
|
|
3
|
+
var $3l9xr$reactariautils = require("@react-aria/utils");
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function $parcel$export(e, n, v, s) {
|
|
7
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
$parcel$export(module.exports, "useOverlayTrigger", () => $b4878eb6316f670a$export$f9d5c8beee7d008d);
|
|
11
|
+
/*
|
|
12
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
13
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
+
* governing permissions and limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
function $b4878eb6316f670a$export$f9d5c8beee7d008d(props, state, ref) {
|
|
25
|
+
let { type: type } = props;
|
|
26
|
+
let { isOpen: isOpen } = state;
|
|
27
|
+
// Backward compatibility. Share state close function with useOverlayPosition so it can close on scroll
|
|
28
|
+
// without forcing users to pass onClose.
|
|
29
|
+
(0, $3l9xr$react.useEffect)(()=>{
|
|
30
|
+
if (ref && ref.current) (0, $9a8aa1b0b336ea3a$exports.onCloseMap).set(ref.current, state.close);
|
|
31
|
+
});
|
|
32
|
+
// Aria 1.1 supports multiple values for aria-haspopup other than just menus.
|
|
33
|
+
// https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup
|
|
34
|
+
// However, we only add it for menus for now because screen readers often
|
|
35
|
+
// announce it as a menu even for other values.
|
|
36
|
+
let ariaHasPopup = undefined;
|
|
37
|
+
if (type === "menu") ariaHasPopup = true;
|
|
38
|
+
else if (type === "listbox") ariaHasPopup = "listbox";
|
|
39
|
+
let overlayId = (0, $3l9xr$reactariautils.useId)();
|
|
40
|
+
return {
|
|
41
|
+
triggerProps: {
|
|
42
|
+
"aria-haspopup": ariaHasPopup,
|
|
43
|
+
"aria-expanded": isOpen,
|
|
44
|
+
"aria-controls": isOpen ? overlayId : null,
|
|
45
|
+
onPress: state.toggle
|
|
46
|
+
},
|
|
47
|
+
overlayProps: {
|
|
48
|
+
id: overlayId
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=useOverlayTrigger.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA0BM,SAAS,0CAAkB,KAA0B,EAAE,KAA0B,EAAE,GAAwB;IAChH,IAAI,QAAC,IAAI,EAAC,GAAG;IACb,IAAI,UAAC,MAAM,EAAC,GAAG;IAEf,uGAAuG;IACvG,yCAAyC;IACzC,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,OAAO,IAAI,OAAO,EACpB,CAAA,GAAA,oCAAS,EAAE,GAAG,CAAC,IAAI,OAAO,EAAE,MAAM,KAAK;IAE3C;IAEA,6EAA6E;IAC7E,oDAAoD;IACpD,yEAAyE;IACzE,+CAA+C;IAC/C,IAAI,eAAe;IACnB,IAAI,SAAS,QACX,eAAe;SACV,IAAI,SAAS,WAClB,eAAe;IAGjB,IAAI,YAAY,CAAA,GAAA,2BAAI;IACpB,OAAO;QACL,cAAc;YACZ,iBAAiB;YACjB,iBAAiB;YACjB,iBAAiB,SAAS,YAAY;YACtC,SAAS,MAAM,MAAM;QACvB;QACA,cAAc;YACZ,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/overlays/src/useOverlayTrigger.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {DOMProps} from '@react-types/shared';\nimport {onCloseMap} from './useCloseOnScroll';\nimport {OverlayTriggerState} from '@react-stately/overlays';\nimport {RefObject, useEffect} from 'react';\nimport {useId} from '@react-aria/utils';\n\nexport interface OverlayTriggerProps {\n /** Type of overlay that is opened by the trigger. */\n type: 'dialog' | 'menu' | 'listbox' | 'tree' | 'grid'\n}\n\nexport interface OverlayTriggerAria {\n /** Props for the trigger element. */\n triggerProps: AriaButtonProps,\n\n /** Props for the overlay container element. */\n overlayProps: DOMProps\n}\n\n/**\n * Handles the behavior and accessibility for an overlay trigger, e.g. a button\n * that opens a popover, menu, or other overlay that is positioned relative to the trigger.\n */\nexport function useOverlayTrigger(props: OverlayTriggerProps, state: OverlayTriggerState, ref?: RefObject<Element>): OverlayTriggerAria {\n let {type} = props;\n let {isOpen} = state;\n\n // Backward compatibility. Share state close function with useOverlayPosition so it can close on scroll\n // without forcing users to pass onClose.\n useEffect(() => {\n if (ref && ref.current) {\n onCloseMap.set(ref.current, state.close);\n }\n });\n\n // Aria 1.1 supports multiple values for aria-haspopup other than just menus.\n // https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup\n // However, we only add it for menus for now because screen readers often\n // announce it as a menu even for other values.\n let ariaHasPopup = undefined;\n if (type === 'menu') {\n ariaHasPopup = true;\n } else if (type === 'listbox') {\n ariaHasPopup = 'listbox';\n }\n\n let overlayId = useId();\n return {\n triggerProps: {\n 'aria-haspopup': ariaHasPopup,\n 'aria-expanded': isOpen,\n 'aria-controls': isOpen ? overlayId : null,\n onPress: state.toggle\n },\n overlayProps: {\n id: overlayId\n }\n };\n}\n"],"names":[],"version":3,"file":"useOverlayTrigger.main.js.map"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {onCloseMap as $dd149f63282afbbf$export$f6211563215e3b37} from "./useCloseOnScroll.mjs";
|
|
2
|
+
import {useEffect as $gMvIk$useEffect} from "react";
|
|
3
|
+
import {useId as $gMvIk$useId} from "@react-aria/utils";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function $628037886ba31236$export$f9d5c8beee7d008d(props, state, ref) {
|
|
19
|
+
let { type: type } = props;
|
|
20
|
+
let { isOpen: isOpen } = state;
|
|
21
|
+
// Backward compatibility. Share state close function with useOverlayPosition so it can close on scroll
|
|
22
|
+
// without forcing users to pass onClose.
|
|
23
|
+
(0, $gMvIk$useEffect)(()=>{
|
|
24
|
+
if (ref && ref.current) (0, $dd149f63282afbbf$export$f6211563215e3b37).set(ref.current, state.close);
|
|
25
|
+
});
|
|
26
|
+
// Aria 1.1 supports multiple values for aria-haspopup other than just menus.
|
|
27
|
+
// https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup
|
|
28
|
+
// However, we only add it for menus for now because screen readers often
|
|
29
|
+
// announce it as a menu even for other values.
|
|
30
|
+
let ariaHasPopup = undefined;
|
|
31
|
+
if (type === "menu") ariaHasPopup = true;
|
|
32
|
+
else if (type === "listbox") ariaHasPopup = "listbox";
|
|
33
|
+
let overlayId = (0, $gMvIk$useId)();
|
|
34
|
+
return {
|
|
35
|
+
triggerProps: {
|
|
36
|
+
"aria-haspopup": ariaHasPopup,
|
|
37
|
+
"aria-expanded": isOpen,
|
|
38
|
+
"aria-controls": isOpen ? overlayId : null,
|
|
39
|
+
onPress: state.toggle
|
|
40
|
+
},
|
|
41
|
+
overlayProps: {
|
|
42
|
+
id: overlayId
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
export {$628037886ba31236$export$f9d5c8beee7d008d as useOverlayTrigger};
|
|
49
|
+
//# sourceMappingURL=useOverlayTrigger.mjs.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {onCloseMap as $dd149f63282afbbf$export$f6211563215e3b37} from "./useCloseOnScroll.module.js";
|
|
2
|
+
import {useEffect as $gMvIk$useEffect} from "react";
|
|
3
|
+
import {useId as $gMvIk$useId} from "@react-aria/utils";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function $628037886ba31236$export$f9d5c8beee7d008d(props, state, ref) {
|
|
19
|
+
let { type: type } = props;
|
|
20
|
+
let { isOpen: isOpen } = state;
|
|
21
|
+
// Backward compatibility. Share state close function with useOverlayPosition so it can close on scroll
|
|
22
|
+
// without forcing users to pass onClose.
|
|
23
|
+
(0, $gMvIk$useEffect)(()=>{
|
|
24
|
+
if (ref && ref.current) (0, $dd149f63282afbbf$export$f6211563215e3b37).set(ref.current, state.close);
|
|
25
|
+
});
|
|
26
|
+
// Aria 1.1 supports multiple values for aria-haspopup other than just menus.
|
|
27
|
+
// https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup
|
|
28
|
+
// However, we only add it for menus for now because screen readers often
|
|
29
|
+
// announce it as a menu even for other values.
|
|
30
|
+
let ariaHasPopup = undefined;
|
|
31
|
+
if (type === "menu") ariaHasPopup = true;
|
|
32
|
+
else if (type === "listbox") ariaHasPopup = "listbox";
|
|
33
|
+
let overlayId = (0, $gMvIk$useId)();
|
|
34
|
+
return {
|
|
35
|
+
triggerProps: {
|
|
36
|
+
"aria-haspopup": ariaHasPopup,
|
|
37
|
+
"aria-expanded": isOpen,
|
|
38
|
+
"aria-controls": isOpen ? overlayId : null,
|
|
39
|
+
onPress: state.toggle
|
|
40
|
+
},
|
|
41
|
+
overlayProps: {
|
|
42
|
+
id: overlayId
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
export {$628037886ba31236$export$f9d5c8beee7d008d as useOverlayTrigger};
|
|
49
|
+
//# sourceMappingURL=useOverlayTrigger.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AA0BM,SAAS,0CAAkB,KAA0B,EAAE,KAA0B,EAAE,GAAwB;IAChH,IAAI,QAAC,IAAI,EAAC,GAAG;IACb,IAAI,UAAC,MAAM,EAAC,GAAG;IAEf,uGAAuG;IACvG,yCAAyC;IACzC,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,OAAO,IAAI,OAAO,EACpB,CAAA,GAAA,yCAAS,EAAE,GAAG,CAAC,IAAI,OAAO,EAAE,MAAM,KAAK;IAE3C;IAEA,6EAA6E;IAC7E,oDAAoD;IACpD,yEAAyE;IACzE,+CAA+C;IAC/C,IAAI,eAAe;IACnB,IAAI,SAAS,QACX,eAAe;SACV,IAAI,SAAS,WAClB,eAAe;IAGjB,IAAI,YAAY,CAAA,GAAA,YAAI;IACpB,OAAO;QACL,cAAc;YACZ,iBAAiB;YACjB,iBAAiB;YACjB,iBAAiB,SAAS,YAAY;YACtC,SAAS,MAAM,MAAM;QACvB;QACA,cAAc;YACZ,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/overlays/src/useOverlayTrigger.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {DOMProps} from '@react-types/shared';\nimport {onCloseMap} from './useCloseOnScroll';\nimport {OverlayTriggerState} from '@react-stately/overlays';\nimport {RefObject, useEffect} from 'react';\nimport {useId} from '@react-aria/utils';\n\nexport interface OverlayTriggerProps {\n /** Type of overlay that is opened by the trigger. */\n type: 'dialog' | 'menu' | 'listbox' | 'tree' | 'grid'\n}\n\nexport interface OverlayTriggerAria {\n /** Props for the trigger element. */\n triggerProps: AriaButtonProps,\n\n /** Props for the overlay container element. */\n overlayProps: DOMProps\n}\n\n/**\n * Handles the behavior and accessibility for an overlay trigger, e.g. a button\n * that opens a popover, menu, or other overlay that is positioned relative to the trigger.\n */\nexport function useOverlayTrigger(props: OverlayTriggerProps, state: OverlayTriggerState, ref?: RefObject<Element>): OverlayTriggerAria {\n let {type} = props;\n let {isOpen} = state;\n\n // Backward compatibility. Share state close function with useOverlayPosition so it can close on scroll\n // without forcing users to pass onClose.\n useEffect(() => {\n if (ref && ref.current) {\n onCloseMap.set(ref.current, state.close);\n }\n });\n\n // Aria 1.1 supports multiple values for aria-haspopup other than just menus.\n // https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup\n // However, we only add it for menus for now because screen readers often\n // announce it as a menu even for other values.\n let ariaHasPopup = undefined;\n if (type === 'menu') {\n ariaHasPopup = true;\n } else if (type === 'listbox') {\n ariaHasPopup = 'listbox';\n }\n\n let overlayId = useId();\n return {\n triggerProps: {\n 'aria-haspopup': ariaHasPopup,\n 'aria-expanded': isOpen,\n 'aria-controls': isOpen ? overlayId : null,\n onPress: state.toggle\n },\n overlayProps: {\n id: overlayId\n }\n };\n}\n"],"names":[],"version":3,"file":"useOverlayTrigger.module.js.map"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var $08ef1685902b6011$exports = require("./ariaHideOutside.main.js");
|
|
2
|
+
var $cd94b4896dd97759$exports = require("./useOverlayPosition.main.js");
|
|
3
|
+
var $82711f9cb668ecdb$exports = require("./useOverlay.main.js");
|
|
4
|
+
var $5c2f5cd01815d369$exports = require("./usePreventScroll.main.js");
|
|
5
|
+
var $jkVOI$reactariautils = require("@react-aria/utils");
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function $parcel$export(e, n, v, s) {
|
|
9
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
$parcel$export(module.exports, "usePopover", () => $6c2dfcdee3e15e20$export$542a6fd13ac93354);
|
|
13
|
+
/*
|
|
14
|
+
* Copyright 2022 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
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
function $6c2dfcdee3e15e20$export$542a6fd13ac93354(props, state) {
|
|
29
|
+
let { triggerRef: triggerRef, popoverRef: popoverRef, isNonModal: isNonModal, isKeyboardDismissDisabled: isKeyboardDismissDisabled, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside, ...otherProps } = props;
|
|
30
|
+
let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $82711f9cb668ecdb$exports.useOverlay)({
|
|
31
|
+
isOpen: state.isOpen,
|
|
32
|
+
onClose: state.close,
|
|
33
|
+
shouldCloseOnBlur: true,
|
|
34
|
+
isDismissable: !isNonModal,
|
|
35
|
+
isKeyboardDismissDisabled: isKeyboardDismissDisabled,
|
|
36
|
+
shouldCloseOnInteractOutside: shouldCloseOnInteractOutside
|
|
37
|
+
}, popoverRef);
|
|
38
|
+
let { overlayProps: positionProps, arrowProps: arrowProps, placement: placement } = (0, $cd94b4896dd97759$exports.useOverlayPosition)({
|
|
39
|
+
...otherProps,
|
|
40
|
+
targetRef: triggerRef,
|
|
41
|
+
overlayRef: popoverRef,
|
|
42
|
+
isOpen: state.isOpen,
|
|
43
|
+
onClose: isNonModal ? state.close : null
|
|
44
|
+
});
|
|
45
|
+
(0, $5c2f5cd01815d369$exports.usePreventScroll)({
|
|
46
|
+
isDisabled: isNonModal || !state.isOpen
|
|
47
|
+
});
|
|
48
|
+
(0, $jkVOI$reactariautils.useLayoutEffect)(()=>{
|
|
49
|
+
if (state.isOpen && !isNonModal && popoverRef.current) return (0, $08ef1685902b6011$exports.ariaHideOutside)([
|
|
50
|
+
popoverRef.current
|
|
51
|
+
]);
|
|
52
|
+
}, [
|
|
53
|
+
isNonModal,
|
|
54
|
+
state.isOpen,
|
|
55
|
+
popoverRef
|
|
56
|
+
]);
|
|
57
|
+
return {
|
|
58
|
+
popoverProps: (0, $jkVOI$reactariautils.mergeProps)(overlayProps, positionProps),
|
|
59
|
+
arrowProps: arrowProps,
|
|
60
|
+
underlayProps: underlayProps,
|
|
61
|
+
placement: placement
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=usePopover.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA+DM,SAAS,0CAAW,KAAuB,EAAE,KAA0B;IAC5E,IAAI,cACF,UAAU,cACV,UAAU,cACV,UAAU,6BACV,yBAAyB,gCACzB,4BAA4B,EAC5B,GAAG,YACJ,GAAG;IAEJ,IAAI,gBAAC,YAAY,iBAAE,aAAa,EAAC,GAAG,CAAA,GAAA,oCAAS,EAC3C;QACE,QAAQ,MAAM,MAAM;QACpB,SAAS,MAAM,KAAK;QACpB,mBAAmB;QACnB,eAAe,CAAC;mCAChB;sCACA;IACF,GACA;IAGF,IAAI,EAAC,cAAc,aAAa,cAAE,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,4CAAiB,EAAE;QAC5E,GAAG,UAAU;QACb,WAAW;QACX,YAAY;QACZ,QAAQ,MAAM,MAAM;QACpB,SAAS,aAAa,MAAM,KAAK,GAAG;IACtC;IAEA,CAAA,GAAA,0CAAe,EAAE;QACf,YAAY,cAAc,CAAC,MAAM,MAAM;IACzC;IAEA,CAAA,GAAA,qCAAc,EAAE;QACd,IAAI,MAAM,MAAM,IAAI,CAAC,cAAc,WAAW,OAAO,EACnD,OAAO,CAAA,GAAA,yCAAc,EAAE;YAAC,WAAW,OAAO;SAAC;IAE/C,GAAG;QAAC;QAAY,MAAM,MAAM;QAAE;KAAW;IAEzC,OAAO;QACL,cAAc,CAAA,GAAA,gCAAS,EAAE,cAAc;oBACvC;uBACA;mBACA;IACF;AACF","sources":["packages/@react-aria/overlays/src/usePopover.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ariaHideOutside} from './ariaHideOutside';\nimport {AriaPositionProps, useOverlayPosition} from './useOverlayPosition';\nimport {DOMAttributes} from '@react-types/shared';\nimport {mergeProps, useLayoutEffect} from '@react-aria/utils';\nimport {OverlayTriggerState} from '@react-stately/overlays';\nimport {PlacementAxis} from '@react-types/overlays';\nimport {RefObject} from 'react';\nimport {useOverlay} from './useOverlay';\nimport {usePreventScroll} from './usePreventScroll';\n\nexport interface AriaPopoverProps extends Omit<AriaPositionProps, 'isOpen' | 'onClose' | 'targetRef' | 'overlayRef'> {\n /**\n * The ref for the element which the popover positions itself with respect to.\n */\n triggerRef: RefObject<Element>,\n /**\n * The ref for the popover element.\n */\n popoverRef: RefObject<Element>,\n /**\n * Whether the popover is non-modal, i.e. elements outside the popover may be\n * interacted with by assistive technologies.\n *\n * Most popovers should not use this option as it may negatively impact the screen\n * reader experience. Only use with components such as combobox, which are designed\n * to handle this situation carefully.\n */\n isNonModal?: boolean,\n /**\n * Whether pressing the escape key to close the popover should be disabled.\n *\n * Most popovers should not use this option. When set to true, an alternative\n * way to close the popover with a keyboard must be provided.\n *\n * @default false\n */\n isKeyboardDismissDisabled?: boolean,\n /**\n * When user interacts with the argument element outside of the popover ref,\n * return true if onClose should be called. This gives you a chance to filter\n * out interaction with elements that should not dismiss the popover.\n * By default, onClose will always be called on interaction outside the popover ref.\n */\n shouldCloseOnInteractOutside?: (element: Element) => boolean\n}\n\nexport interface PopoverAria {\n /** Props for the popover element. */\n popoverProps: DOMAttributes,\n /** Props for the popover tip arrow if any. */\n arrowProps: DOMAttributes,\n /** Props to apply to the underlay element, if any. */\n underlayProps: DOMAttributes,\n /** Placement of the popover with respect to the trigger. */\n placement: PlacementAxis\n}\n\n/**\n * Provides the behavior and accessibility implementation for a popover component.\n * A popover is an overlay element positioned relative to a trigger.\n */\nexport function usePopover(props: AriaPopoverProps, state: OverlayTriggerState): PopoverAria {\n let {\n triggerRef,\n popoverRef,\n isNonModal,\n isKeyboardDismissDisabled,\n shouldCloseOnInteractOutside,\n ...otherProps\n } = props;\n\n let {overlayProps, underlayProps} = useOverlay(\n {\n isOpen: state.isOpen,\n onClose: state.close,\n shouldCloseOnBlur: true,\n isDismissable: !isNonModal,\n isKeyboardDismissDisabled,\n shouldCloseOnInteractOutside\n },\n popoverRef\n );\n\n let {overlayProps: positionProps, arrowProps, placement} = useOverlayPosition({\n ...otherProps,\n targetRef: triggerRef,\n overlayRef: popoverRef,\n isOpen: state.isOpen,\n onClose: isNonModal ? state.close : null\n });\n\n usePreventScroll({\n isDisabled: isNonModal || !state.isOpen\n });\n\n useLayoutEffect(() => {\n if (state.isOpen && !isNonModal && popoverRef.current) {\n return ariaHideOutside([popoverRef.current]);\n }\n }, [isNonModal, state.isOpen, popoverRef]);\n\n return {\n popoverProps: mergeProps(overlayProps, positionProps),\n arrowProps,\n underlayProps,\n placement\n };\n}\n"],"names":[],"version":3,"file":"usePopover.main.js.map"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {ariaHideOutside as $5e3802645cc19319$export$1c3ebcada18427bf} from "./ariaHideOutside.mjs";
|
|
2
|
+
import {useOverlayPosition as $2a41e45df1593e64$export$d39e1813b3bdd0e1} from "./useOverlayPosition.mjs";
|
|
3
|
+
import {useOverlay as $a11501f3d1d39e6c$export$ea8f71083e90600f} from "./useOverlay.mjs";
|
|
4
|
+
import {usePreventScroll as $49c51c25361d4cd2$export$ee0f7cc6afcd1c18} from "./usePreventScroll.mjs";
|
|
5
|
+
import {useLayoutEffect as $m0yab$useLayoutEffect, mergeProps as $m0yab$mergeProps} from "@react-aria/utils";
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
* governing permissions and limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
function $f2f8a6077418541e$export$542a6fd13ac93354(props, state) {
|
|
23
|
+
let { triggerRef: triggerRef, popoverRef: popoverRef, isNonModal: isNonModal, isKeyboardDismissDisabled: isKeyboardDismissDisabled, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside, ...otherProps } = props;
|
|
24
|
+
let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $a11501f3d1d39e6c$export$ea8f71083e90600f)({
|
|
25
|
+
isOpen: state.isOpen,
|
|
26
|
+
onClose: state.close,
|
|
27
|
+
shouldCloseOnBlur: true,
|
|
28
|
+
isDismissable: !isNonModal,
|
|
29
|
+
isKeyboardDismissDisabled: isKeyboardDismissDisabled,
|
|
30
|
+
shouldCloseOnInteractOutside: shouldCloseOnInteractOutside
|
|
31
|
+
}, popoverRef);
|
|
32
|
+
let { overlayProps: positionProps, arrowProps: arrowProps, placement: placement } = (0, $2a41e45df1593e64$export$d39e1813b3bdd0e1)({
|
|
33
|
+
...otherProps,
|
|
34
|
+
targetRef: triggerRef,
|
|
35
|
+
overlayRef: popoverRef,
|
|
36
|
+
isOpen: state.isOpen,
|
|
37
|
+
onClose: isNonModal ? state.close : null
|
|
38
|
+
});
|
|
39
|
+
(0, $49c51c25361d4cd2$export$ee0f7cc6afcd1c18)({
|
|
40
|
+
isDisabled: isNonModal || !state.isOpen
|
|
41
|
+
});
|
|
42
|
+
(0, $m0yab$useLayoutEffect)(()=>{
|
|
43
|
+
if (state.isOpen && !isNonModal && popoverRef.current) return (0, $5e3802645cc19319$export$1c3ebcada18427bf)([
|
|
44
|
+
popoverRef.current
|
|
45
|
+
]);
|
|
46
|
+
}, [
|
|
47
|
+
isNonModal,
|
|
48
|
+
state.isOpen,
|
|
49
|
+
popoverRef
|
|
50
|
+
]);
|
|
51
|
+
return {
|
|
52
|
+
popoverProps: (0, $m0yab$mergeProps)(overlayProps, positionProps),
|
|
53
|
+
arrowProps: arrowProps,
|
|
54
|
+
underlayProps: underlayProps,
|
|
55
|
+
placement: placement
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
export {$f2f8a6077418541e$export$542a6fd13ac93354 as usePopover};
|
|
61
|
+
//# sourceMappingURL=usePopover.mjs.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {ariaHideOutside as $5e3802645cc19319$export$1c3ebcada18427bf} from "./ariaHideOutside.module.js";
|
|
2
|
+
import {useOverlayPosition as $2a41e45df1593e64$export$d39e1813b3bdd0e1} from "./useOverlayPosition.module.js";
|
|
3
|
+
import {useOverlay as $a11501f3d1d39e6c$export$ea8f71083e90600f} from "./useOverlay.module.js";
|
|
4
|
+
import {usePreventScroll as $49c51c25361d4cd2$export$ee0f7cc6afcd1c18} from "./usePreventScroll.module.js";
|
|
5
|
+
import {useLayoutEffect as $m0yab$useLayoutEffect, mergeProps as $m0yab$mergeProps} from "@react-aria/utils";
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
* governing permissions and limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
function $f2f8a6077418541e$export$542a6fd13ac93354(props, state) {
|
|
23
|
+
let { triggerRef: triggerRef, popoverRef: popoverRef, isNonModal: isNonModal, isKeyboardDismissDisabled: isKeyboardDismissDisabled, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside, ...otherProps } = props;
|
|
24
|
+
let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $a11501f3d1d39e6c$export$ea8f71083e90600f)({
|
|
25
|
+
isOpen: state.isOpen,
|
|
26
|
+
onClose: state.close,
|
|
27
|
+
shouldCloseOnBlur: true,
|
|
28
|
+
isDismissable: !isNonModal,
|
|
29
|
+
isKeyboardDismissDisabled: isKeyboardDismissDisabled,
|
|
30
|
+
shouldCloseOnInteractOutside: shouldCloseOnInteractOutside
|
|
31
|
+
}, popoverRef);
|
|
32
|
+
let { overlayProps: positionProps, arrowProps: arrowProps, placement: placement } = (0, $2a41e45df1593e64$export$d39e1813b3bdd0e1)({
|
|
33
|
+
...otherProps,
|
|
34
|
+
targetRef: triggerRef,
|
|
35
|
+
overlayRef: popoverRef,
|
|
36
|
+
isOpen: state.isOpen,
|
|
37
|
+
onClose: isNonModal ? state.close : null
|
|
38
|
+
});
|
|
39
|
+
(0, $49c51c25361d4cd2$export$ee0f7cc6afcd1c18)({
|
|
40
|
+
isDisabled: isNonModal || !state.isOpen
|
|
41
|
+
});
|
|
42
|
+
(0, $m0yab$useLayoutEffect)(()=>{
|
|
43
|
+
if (state.isOpen && !isNonModal && popoverRef.current) return (0, $5e3802645cc19319$export$1c3ebcada18427bf)([
|
|
44
|
+
popoverRef.current
|
|
45
|
+
]);
|
|
46
|
+
}, [
|
|
47
|
+
isNonModal,
|
|
48
|
+
state.isOpen,
|
|
49
|
+
popoverRef
|
|
50
|
+
]);
|
|
51
|
+
return {
|
|
52
|
+
popoverProps: (0, $m0yab$mergeProps)(overlayProps, positionProps),
|
|
53
|
+
arrowProps: arrowProps,
|
|
54
|
+
underlayProps: underlayProps,
|
|
55
|
+
placement: placement
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
export {$f2f8a6077418541e$export$542a6fd13ac93354 as usePopover};
|
|
61
|
+
//# sourceMappingURL=usePopover.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA+DM,SAAS,0CAAW,KAAuB,EAAE,KAA0B;IAC5E,IAAI,cACF,UAAU,cACV,UAAU,cACV,UAAU,6BACV,yBAAyB,gCACzB,4BAA4B,EAC5B,GAAG,YACJ,GAAG;IAEJ,IAAI,gBAAC,YAAY,iBAAE,aAAa,EAAC,GAAG,CAAA,GAAA,yCAAS,EAC3C;QACE,QAAQ,MAAM,MAAM;QACpB,SAAS,MAAM,KAAK;QACpB,mBAAmB;QACnB,eAAe,CAAC;mCAChB;sCACA;IACF,GACA;IAGF,IAAI,EAAC,cAAc,aAAa,cAAE,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,yCAAiB,EAAE;QAC5E,GAAG,UAAU;QACb,WAAW;QACX,YAAY;QACZ,QAAQ,MAAM,MAAM;QACpB,SAAS,aAAa,MAAM,KAAK,GAAG;IACtC;IAEA,CAAA,GAAA,yCAAe,EAAE;QACf,YAAY,cAAc,CAAC,MAAM,MAAM;IACzC;IAEA,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI,MAAM,MAAM,IAAI,CAAC,cAAc,WAAW,OAAO,EACnD,OAAO,CAAA,GAAA,yCAAc,EAAE;YAAC,WAAW,OAAO;SAAC;IAE/C,GAAG;QAAC;QAAY,MAAM,MAAM;QAAE;KAAW;IAEzC,OAAO;QACL,cAAc,CAAA,GAAA,iBAAS,EAAE,cAAc;oBACvC;uBACA;mBACA;IACF;AACF","sources":["packages/@react-aria/overlays/src/usePopover.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ariaHideOutside} from './ariaHideOutside';\nimport {AriaPositionProps, useOverlayPosition} from './useOverlayPosition';\nimport {DOMAttributes} from '@react-types/shared';\nimport {mergeProps, useLayoutEffect} from '@react-aria/utils';\nimport {OverlayTriggerState} from '@react-stately/overlays';\nimport {PlacementAxis} from '@react-types/overlays';\nimport {RefObject} from 'react';\nimport {useOverlay} from './useOverlay';\nimport {usePreventScroll} from './usePreventScroll';\n\nexport interface AriaPopoverProps extends Omit<AriaPositionProps, 'isOpen' | 'onClose' | 'targetRef' | 'overlayRef'> {\n /**\n * The ref for the element which the popover positions itself with respect to.\n */\n triggerRef: RefObject<Element>,\n /**\n * The ref for the popover element.\n */\n popoverRef: RefObject<Element>,\n /**\n * Whether the popover is non-modal, i.e. elements outside the popover may be\n * interacted with by assistive technologies.\n *\n * Most popovers should not use this option as it may negatively impact the screen\n * reader experience. Only use with components such as combobox, which are designed\n * to handle this situation carefully.\n */\n isNonModal?: boolean,\n /**\n * Whether pressing the escape key to close the popover should be disabled.\n *\n * Most popovers should not use this option. When set to true, an alternative\n * way to close the popover with a keyboard must be provided.\n *\n * @default false\n */\n isKeyboardDismissDisabled?: boolean,\n /**\n * When user interacts with the argument element outside of the popover ref,\n * return true if onClose should be called. This gives you a chance to filter\n * out interaction with elements that should not dismiss the popover.\n * By default, onClose will always be called on interaction outside the popover ref.\n */\n shouldCloseOnInteractOutside?: (element: Element) => boolean\n}\n\nexport interface PopoverAria {\n /** Props for the popover element. */\n popoverProps: DOMAttributes,\n /** Props for the popover tip arrow if any. */\n arrowProps: DOMAttributes,\n /** Props to apply to the underlay element, if any. */\n underlayProps: DOMAttributes,\n /** Placement of the popover with respect to the trigger. */\n placement: PlacementAxis\n}\n\n/**\n * Provides the behavior and accessibility implementation for a popover component.\n * A popover is an overlay element positioned relative to a trigger.\n */\nexport function usePopover(props: AriaPopoverProps, state: OverlayTriggerState): PopoverAria {\n let {\n triggerRef,\n popoverRef,\n isNonModal,\n isKeyboardDismissDisabled,\n shouldCloseOnInteractOutside,\n ...otherProps\n } = props;\n\n let {overlayProps, underlayProps} = useOverlay(\n {\n isOpen: state.isOpen,\n onClose: state.close,\n shouldCloseOnBlur: true,\n isDismissable: !isNonModal,\n isKeyboardDismissDisabled,\n shouldCloseOnInteractOutside\n },\n popoverRef\n );\n\n let {overlayProps: positionProps, arrowProps, placement} = useOverlayPosition({\n ...otherProps,\n targetRef: triggerRef,\n overlayRef: popoverRef,\n isOpen: state.isOpen,\n onClose: isNonModal ? state.close : null\n });\n\n usePreventScroll({\n isDisabled: isNonModal || !state.isOpen\n });\n\n useLayoutEffect(() => {\n if (state.isOpen && !isNonModal && popoverRef.current) {\n return ariaHideOutside([popoverRef.current]);\n }\n }, [isNonModal, state.isOpen, popoverRef]);\n\n return {\n popoverProps: mergeProps(overlayProps, positionProps),\n arrowProps,\n underlayProps,\n placement\n };\n}\n"],"names":[],"version":3,"file":"usePopover.module.js.map"}
|