@react-aria/overlays 3.22.0 → 3.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DismissButton.main.js +2 -2
- package/dist/DismissButton.mjs +3 -3
- package/dist/DismissButton.module.js +2 -2
- package/dist/Overlay.mjs +1 -1
- package/dist/PortalProvider.mjs +1 -1
- package/dist/ar-AE.mjs +1 -1
- package/dist/ariaHideOutside.main.js +7 -7
- package/dist/ariaHideOutside.mjs +8 -8
- package/dist/ariaHideOutside.module.js +7 -7
- package/dist/bg-BG.mjs +1 -1
- package/dist/calculatePosition.main.js +40 -40
- package/dist/calculatePosition.main.js.map +1 -1
- package/dist/calculatePosition.mjs +41 -41
- package/dist/calculatePosition.module.js +40 -40
- package/dist/calculatePosition.module.js.map +1 -1
- 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/intlStrings.mjs +1 -1
- 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/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.map +1 -1
- package/dist/uk-UA.mjs +1 -1
- package/dist/useCloseOnScroll.main.js +2 -2
- package/dist/useCloseOnScroll.mjs +3 -3
- package/dist/useCloseOnScroll.module.js +2 -2
- package/dist/useModal.main.js +4 -4
- package/dist/useModal.mjs +5 -5
- package/dist/useModal.module.js +4 -4
- package/dist/useModalOverlay.mjs +1 -1
- package/dist/useOverlay.main.js +1 -1
- package/dist/useOverlay.mjs +2 -2
- package/dist/useOverlay.module.js +1 -1
- package/dist/useOverlayPosition.main.js +25 -16
- package/dist/useOverlayPosition.main.js.map +1 -1
- package/dist/useOverlayPosition.mjs +26 -17
- package/dist/useOverlayPosition.module.js +25 -16
- package/dist/useOverlayPosition.module.js.map +1 -1
- package/dist/useOverlayTrigger.main.js +5 -5
- package/dist/useOverlayTrigger.mjs +6 -6
- package/dist/useOverlayTrigger.module.js +5 -5
- package/dist/usePopover.mjs +1 -1
- package/dist/usePreventScroll.main.js +22 -22
- package/dist/usePreventScroll.mjs +23 -23
- package/dist/usePreventScroll.module.js +22 -22
- package/dist/zh-CN.mjs +1 -1
- package/dist/zh-TW.mjs +1 -1
- package/package.json +12 -12
- package/src/calculatePosition.ts +3 -3
- package/src/useOverlayPosition.ts +8 -3
package/dist/hr-HR.mjs
CHANGED
package/dist/hu-HU.mjs
CHANGED
package/dist/intlStrings.mjs
CHANGED
package/dist/it-IT.mjs
CHANGED
package/dist/ja-JP.mjs
CHANGED
package/dist/ko-KR.mjs
CHANGED
package/dist/lt-LT.mjs
CHANGED
package/dist/lv-LV.mjs
CHANGED
package/dist/nb-NO.mjs
CHANGED
package/dist/nl-NL.mjs
CHANGED
package/dist/pl-PL.mjs
CHANGED
package/dist/pt-BR.mjs
CHANGED
package/dist/pt-PT.mjs
CHANGED
package/dist/ro-RO.mjs
CHANGED
package/dist/ru-RU.mjs
CHANGED
package/dist/sk-SK.mjs
CHANGED
package/dist/sl-SI.mjs
CHANGED
package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8B,CAAC;IACnG;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;CACpC;AAED;IACE,mCAAmC;IACnC,UAAU,EAAE,aAAa,CAAC;IAC1B,sCAAsC;IACtC,aAAa,EAAE,aAAa,CAAA;CAC7B;AAED;;;GAGG;AACH,gCAAgC,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,gBAAgB,CAuBvI;ACrCD,YAAY,EAAC,SAAS,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,uBAAuB,CAAC","sources":["packages/@react-aria/overlays/src/packages/@react-aria/overlays/src/calculatePosition.ts","packages/@react-aria/overlays/src/packages/@react-aria/overlays/src/useCloseOnScroll.ts","packages/@react-aria/overlays/src/packages/@react-aria/overlays/src/useOverlayPosition.ts","packages/@react-aria/overlays/src/packages/@react-aria/overlays/src/useOverlay.ts","packages/@react-aria/overlays/src/packages/@react-aria/overlays/src/useOverlayTrigger.ts","packages/@react-aria/overlays/src/packages/@react-aria/overlays/src/usePreventScroll.ts","packages/@react-aria/overlays/src/packages/@react-aria/overlays/src/useModal.tsx","packages/@react-aria/overlays/src/packages/@react-aria/overlays/src/DismissButton.tsx","packages/@react-aria/overlays/src/packages/@react-aria/overlays/src/ariaHideOutside.ts","packages/@react-aria/overlays/src/packages/@react-aria/overlays/src/usePopover.ts","packages/@react-aria/overlays/src/packages/@react-aria/overlays/src/PortalProvider.tsx","packages/@react-aria/overlays/src/packages/@react-aria/overlays/src/Overlay.tsx","packages/@react-aria/overlays/src/packages/@react-aria/overlays/src/useModalOverlay.ts","packages/@react-aria/overlays/src/packages/@react-aria/overlays/src/index.ts","packages/@react-aria/overlays/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,"/*\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 */\nexport {useOverlayPosition} from './useOverlayPosition';\nexport {useOverlay} from './useOverlay';\nexport {useOverlayTrigger} from './useOverlayTrigger';\nexport {usePreventScroll} from './usePreventScroll';\nexport {ModalProvider, useModalProvider, OverlayProvider, OverlayContainer, useModal} from './useModal';\nexport {DismissButton} from './DismissButton';\nexport {ariaHideOutside} from './ariaHideOutside';\nexport {usePopover} from './usePopover';\nexport {useModalOverlay} from './useModalOverlay';\nexport {Overlay, useOverlayFocusContain} from './Overlay';\nexport {UNSTABLE_PortalProvider, useUNSTABLE_PortalContext} from './PortalProvider';\n\nexport type {AriaPositionProps, PositionAria} from './useOverlayPosition';\nexport type {AriaOverlayProps, OverlayAria} from './useOverlay';\nexport type {OverlayTriggerAria, OverlayTriggerProps} from './useOverlayTrigger';\nexport type {AriaModalOptions, ModalAria, ModalProviderAria, ModalProviderProps, OverlayContainerProps} from './useModal';\nexport type {DismissButtonProps} from './DismissButton';\nexport type {AriaPopoverProps, PopoverAria} from './usePopover';\nexport type {AriaModalOverlayProps, ModalOverlayAria} from './useModalOverlay';\nexport type {OverlayProps} from './Overlay';\nexport type {Placement, PlacementAxis, PositionProps} from '@react-types/overlays';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/dist/uk-UA.mjs
CHANGED
|
@@ -31,9 +31,9 @@ function $9a8aa1b0b336ea3a$export$18fc8428861184da(opts) {
|
|
|
31
31
|
let onCloseHandler = onClose || $9a8aa1b0b336ea3a$export$f6211563215e3b37.get(triggerRef.current);
|
|
32
32
|
if (onCloseHandler) onCloseHandler();
|
|
33
33
|
};
|
|
34
|
-
window.addEventListener(
|
|
34
|
+
window.addEventListener('scroll', onScroll, true);
|
|
35
35
|
return ()=>{
|
|
36
|
-
window.removeEventListener(
|
|
36
|
+
window.removeEventListener('scroll', onScroll, true);
|
|
37
37
|
};
|
|
38
38
|
}, [
|
|
39
39
|
isOpen,
|
|
@@ -24,9 +24,9 @@ function $dd149f63282afbbf$export$18fc8428861184da(opts) {
|
|
|
24
24
|
let onCloseHandler = onClose || $dd149f63282afbbf$export$f6211563215e3b37.get(triggerRef.current);
|
|
25
25
|
if (onCloseHandler) onCloseHandler();
|
|
26
26
|
};
|
|
27
|
-
window.addEventListener(
|
|
27
|
+
window.addEventListener('scroll', onScroll, true);
|
|
28
28
|
return ()=>{
|
|
29
|
-
window.removeEventListener(
|
|
29
|
+
window.removeEventListener('scroll', onScroll, true);
|
|
30
30
|
};
|
|
31
31
|
}, [
|
|
32
32
|
isOpen,
|
|
@@ -37,4 +37,4 @@ function $dd149f63282afbbf$export$18fc8428861184da(opts) {
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
export {$dd149f63282afbbf$export$f6211563215e3b37 as onCloseMap, $dd149f63282afbbf$export$18fc8428861184da as useCloseOnScroll};
|
|
40
|
-
//# sourceMappingURL=useCloseOnScroll.
|
|
40
|
+
//# sourceMappingURL=useCloseOnScroll.module.js.map
|
|
@@ -24,9 +24,9 @@ function $dd149f63282afbbf$export$18fc8428861184da(opts) {
|
|
|
24
24
|
let onCloseHandler = onClose || $dd149f63282afbbf$export$f6211563215e3b37.get(triggerRef.current);
|
|
25
25
|
if (onCloseHandler) onCloseHandler();
|
|
26
26
|
};
|
|
27
|
-
window.addEventListener(
|
|
27
|
+
window.addEventListener('scroll', onScroll, true);
|
|
28
28
|
return ()=>{
|
|
29
|
-
window.removeEventListener(
|
|
29
|
+
window.removeEventListener('scroll', onScroll, true);
|
|
30
30
|
};
|
|
31
31
|
}, [
|
|
32
32
|
isOpen,
|
package/dist/useModal.main.js
CHANGED
|
@@ -57,7 +57,7 @@ function $0775ea8ea6a0565e$export$d9aaed4c3ece1bc0() {
|
|
|
57
57
|
let context = (0, $btuAB$react.useContext)($0775ea8ea6a0565e$var$Context);
|
|
58
58
|
return {
|
|
59
59
|
modalProviderProps: {
|
|
60
|
-
|
|
60
|
+
'aria-hidden': context && context.modalCount > 0 ? true : null
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
}
|
|
@@ -78,7 +78,7 @@ function $0775ea8ea6a0565e$export$b47c3594eab58386(props) {
|
|
|
78
78
|
let isSSR = (0, $btuAB$reactariassr.useIsSSR)();
|
|
79
79
|
let { portalContainer: portalContainer = isSSR ? null : document.body, ...rest } = props;
|
|
80
80
|
(0, ($parcel$interopDefault($btuAB$react))).useEffect(()=>{
|
|
81
|
-
if (portalContainer === null || portalContainer === void 0 ? void 0 : portalContainer.closest(
|
|
81
|
+
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.');
|
|
82
82
|
}, [
|
|
83
83
|
portalContainer
|
|
84
84
|
]);
|
|
@@ -89,7 +89,7 @@ function $0775ea8ea6a0565e$export$b47c3594eab58386(props) {
|
|
|
89
89
|
function $0775ea8ea6a0565e$export$33ffd74ebf07f060(options) {
|
|
90
90
|
// Add aria-hidden to all parent providers on mount, and restore on unmount.
|
|
91
91
|
let context = (0, $btuAB$react.useContext)($0775ea8ea6a0565e$var$Context);
|
|
92
|
-
if (!context) throw new Error(
|
|
92
|
+
if (!context) throw new Error('Modal is not contained within a provider');
|
|
93
93
|
(0, $btuAB$react.useEffect)(()=>{
|
|
94
94
|
if ((options === null || options === void 0 ? void 0 : options.isDisabled) || !context || !context.parent) return;
|
|
95
95
|
// The immediate context is from the provider containing this modal, so we only
|
|
@@ -105,7 +105,7 @@ function $0775ea8ea6a0565e$export$33ffd74ebf07f060(options) {
|
|
|
105
105
|
]);
|
|
106
106
|
return {
|
|
107
107
|
modalProps: {
|
|
108
|
-
|
|
108
|
+
'data-ismodal': !(options === null || options === void 0 ? void 0 : options.isDisabled)
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
}
|
package/dist/useModal.mjs
CHANGED
|
@@ -43,7 +43,7 @@ function $f57aed4a881a3485$export$d9aaed4c3ece1bc0() {
|
|
|
43
43
|
let context = (0, $4AOtR$useContext)($f57aed4a881a3485$var$Context);
|
|
44
44
|
return {
|
|
45
45
|
modalProviderProps: {
|
|
46
|
-
|
|
46
|
+
'aria-hidden': context && context.modalCount > 0 ? true : null
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
}
|
|
@@ -64,7 +64,7 @@ function $f57aed4a881a3485$export$b47c3594eab58386(props) {
|
|
|
64
64
|
let isSSR = (0, $4AOtR$useIsSSR)();
|
|
65
65
|
let { portalContainer: portalContainer = isSSR ? null : document.body, ...rest } = props;
|
|
66
66
|
(0, $4AOtR$react).useEffect(()=>{
|
|
67
|
-
if (portalContainer === null || portalContainer === void 0 ? void 0 : portalContainer.closest(
|
|
67
|
+
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.');
|
|
68
68
|
}, [
|
|
69
69
|
portalContainer
|
|
70
70
|
]);
|
|
@@ -75,7 +75,7 @@ function $f57aed4a881a3485$export$b47c3594eab58386(props) {
|
|
|
75
75
|
function $f57aed4a881a3485$export$33ffd74ebf07f060(options) {
|
|
76
76
|
// Add aria-hidden to all parent providers on mount, and restore on unmount.
|
|
77
77
|
let context = (0, $4AOtR$useContext)($f57aed4a881a3485$var$Context);
|
|
78
|
-
if (!context) throw new Error(
|
|
78
|
+
if (!context) throw new Error('Modal is not contained within a provider');
|
|
79
79
|
(0, $4AOtR$useEffect)(()=>{
|
|
80
80
|
if ((options === null || options === void 0 ? void 0 : options.isDisabled) || !context || !context.parent) return;
|
|
81
81
|
// The immediate context is from the provider containing this modal, so we only
|
|
@@ -91,11 +91,11 @@ function $f57aed4a881a3485$export$33ffd74ebf07f060(options) {
|
|
|
91
91
|
]);
|
|
92
92
|
return {
|
|
93
93
|
modalProps: {
|
|
94
|
-
|
|
94
|
+
'data-ismodal': !(options === null || options === void 0 ? void 0 : options.isDisabled)
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
|
|
100
100
|
export {$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};
|
|
101
|
-
//# sourceMappingURL=useModal.
|
|
101
|
+
//# sourceMappingURL=useModal.module.js.map
|
package/dist/useModal.module.js
CHANGED
|
@@ -43,7 +43,7 @@ function $f57aed4a881a3485$export$d9aaed4c3ece1bc0() {
|
|
|
43
43
|
let context = (0, $4AOtR$useContext)($f57aed4a881a3485$var$Context);
|
|
44
44
|
return {
|
|
45
45
|
modalProviderProps: {
|
|
46
|
-
|
|
46
|
+
'aria-hidden': context && context.modalCount > 0 ? true : null
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
}
|
|
@@ -64,7 +64,7 @@ function $f57aed4a881a3485$export$b47c3594eab58386(props) {
|
|
|
64
64
|
let isSSR = (0, $4AOtR$useIsSSR)();
|
|
65
65
|
let { portalContainer: portalContainer = isSSR ? null : document.body, ...rest } = props;
|
|
66
66
|
(0, $4AOtR$react).useEffect(()=>{
|
|
67
|
-
if (portalContainer === null || portalContainer === void 0 ? void 0 : portalContainer.closest(
|
|
67
|
+
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.');
|
|
68
68
|
}, [
|
|
69
69
|
portalContainer
|
|
70
70
|
]);
|
|
@@ -75,7 +75,7 @@ function $f57aed4a881a3485$export$b47c3594eab58386(props) {
|
|
|
75
75
|
function $f57aed4a881a3485$export$33ffd74ebf07f060(options) {
|
|
76
76
|
// Add aria-hidden to all parent providers on mount, and restore on unmount.
|
|
77
77
|
let context = (0, $4AOtR$useContext)($f57aed4a881a3485$var$Context);
|
|
78
|
-
if (!context) throw new Error(
|
|
78
|
+
if (!context) throw new Error('Modal is not contained within a provider');
|
|
79
79
|
(0, $4AOtR$useEffect)(()=>{
|
|
80
80
|
if ((options === null || options === void 0 ? void 0 : options.isDisabled) || !context || !context.parent) return;
|
|
81
81
|
// The immediate context is from the provider containing this modal, so we only
|
|
@@ -91,7 +91,7 @@ function $f57aed4a881a3485$export$33ffd74ebf07f060(options) {
|
|
|
91
91
|
]);
|
|
92
92
|
return {
|
|
93
93
|
modalProps: {
|
|
94
|
-
|
|
94
|
+
'data-ismodal': !(options === null || options === void 0 ? void 0 : options.isDisabled)
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
}
|
package/dist/useModalOverlay.mjs
CHANGED
package/dist/useOverlay.main.js
CHANGED
|
@@ -58,7 +58,7 @@ function $82711f9cb668ecdb$export$ea8f71083e90600f(props, ref) {
|
|
|
58
58
|
};
|
|
59
59
|
// Handle the escape key
|
|
60
60
|
let onKeyDown = (e)=>{
|
|
61
|
-
if (e.key ===
|
|
61
|
+
if (e.key === 'Escape' && !isKeyboardDismissDisabled && !e.nativeEvent.isComposing) {
|
|
62
62
|
e.stopPropagation();
|
|
63
63
|
e.preventDefault();
|
|
64
64
|
onHide();
|
package/dist/useOverlay.mjs
CHANGED
|
@@ -52,7 +52,7 @@ function $a11501f3d1d39e6c$export$ea8f71083e90600f(props, ref) {
|
|
|
52
52
|
};
|
|
53
53
|
// Handle the escape key
|
|
54
54
|
let onKeyDown = (e)=>{
|
|
55
|
-
if (e.key ===
|
|
55
|
+
if (e.key === 'Escape' && !isKeyboardDismissDisabled && !e.nativeEvent.isComposing) {
|
|
56
56
|
e.stopPropagation();
|
|
57
57
|
e.preventDefault();
|
|
58
58
|
onHide();
|
|
@@ -97,4 +97,4 @@ function $a11501f3d1d39e6c$export$ea8f71083e90600f(props, ref) {
|
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
export {$a11501f3d1d39e6c$export$ea8f71083e90600f as useOverlay};
|
|
100
|
-
//# sourceMappingURL=useOverlay.
|
|
100
|
+
//# sourceMappingURL=useOverlay.module.js.map
|
|
@@ -52,7 +52,7 @@ function $a11501f3d1d39e6c$export$ea8f71083e90600f(props, ref) {
|
|
|
52
52
|
};
|
|
53
53
|
// Handle the escape key
|
|
54
54
|
let onKeyDown = (e)=>{
|
|
55
|
-
if (e.key ===
|
|
55
|
+
if (e.key === 'Escape' && !isKeyboardDismissDisabled && !e.nativeEvent.isComposing) {
|
|
56
56
|
e.stopPropagation();
|
|
57
57
|
e.preventDefault();
|
|
58
58
|
onHide();
|
|
@@ -26,10 +26,10 @@ $parcel$export(module.exports, "useOverlayPosition", () => $cd94b4896dd97759$exp
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
// @ts-ignore
|
|
29
|
-
let $cd94b4896dd97759$var$visualViewport = typeof document !==
|
|
29
|
+
let $cd94b4896dd97759$var$visualViewport = typeof document !== 'undefined' && window.visualViewport;
|
|
30
30
|
function $cd94b4896dd97759$export$d39e1813b3bdd0e1(props) {
|
|
31
31
|
let { direction: direction } = (0, $6TXnl$reactariai18n.useLocale)();
|
|
32
|
-
let { arrowSize: arrowSize = 0, targetRef: targetRef, overlayRef: overlayRef, scrollRef: scrollRef = overlayRef, placement: placement =
|
|
32
|
+
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;
|
|
33
33
|
let [position, setPosition] = (0, $6TXnl$react.useState)({
|
|
34
34
|
position: {},
|
|
35
35
|
arrowOffsetLeft: undefined,
|
|
@@ -68,7 +68,14 @@ function $cd94b4896dd97759$export$d39e1813b3bdd0e1(props) {
|
|
|
68
68
|
if (($cd94b4896dd97759$var$visualViewport === null || $cd94b4896dd97759$var$visualViewport === void 0 ? void 0 : $cd94b4896dd97759$var$visualViewport.scale) !== lastScale.current) return;
|
|
69
69
|
// Always reset the overlay's previous max height if not defined by the user so that we can compensate for
|
|
70
70
|
// RAC collections populating after a second render and properly set a correct max height + positioning when it populates.
|
|
71
|
-
|
|
71
|
+
let overlay = overlayRef.current;
|
|
72
|
+
if (!maxHeight && overlayRef.current) {
|
|
73
|
+
var _window_visualViewport;
|
|
74
|
+
overlay.style.top = '0px';
|
|
75
|
+
overlay.style.bottom = '';
|
|
76
|
+
var _window_visualViewport_height;
|
|
77
|
+
overlay.style.maxHeight = ((_window_visualViewport_height = (_window_visualViewport = window.visualViewport) === null || _window_visualViewport === void 0 ? void 0 : _window_visualViewport.height) !== null && _window_visualViewport_height !== void 0 ? _window_visualViewport_height : window.innerHeight) + 'px';
|
|
78
|
+
}
|
|
72
79
|
let position = (0, $5935ba4d7da2c103$exports.calculatePosition)({
|
|
73
80
|
placement: $cd94b4896dd97759$var$translateRTL(placement, direction),
|
|
74
81
|
overlayNode: overlayRef.current,
|
|
@@ -85,8 +92,10 @@ function $cd94b4896dd97759$export$d39e1813b3bdd0e1(props) {
|
|
|
85
92
|
});
|
|
86
93
|
// Modify overlay styles directly so positioning happens immediately without the need of a second render
|
|
87
94
|
// This is so we don't have to delay autoFocus scrolling or delay applying preventScroll for popovers
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
overlay.style.top = '';
|
|
96
|
+
overlay.style.bottom = '';
|
|
97
|
+
Object.keys(position.position).forEach((key)=>overlay.style[key] = position.position[key] + 'px');
|
|
98
|
+
overlay.style.maxHeight = position.maxHeight != null ? position.maxHeight + 'px' : undefined;
|
|
90
99
|
// Trigger a set state for a second render anyway for arrow positioning
|
|
91
100
|
setPosition(position);
|
|
92
101
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -119,11 +128,11 @@ function $cd94b4896dd97759$export$d39e1813b3bdd0e1(props) {
|
|
|
119
128
|
let onScroll = ()=>{
|
|
120
129
|
if (isResizing.current) onResize();
|
|
121
130
|
};
|
|
122
|
-
$cd94b4896dd97759$var$visualViewport === null || $cd94b4896dd97759$var$visualViewport === void 0 ? void 0 : $cd94b4896dd97759$var$visualViewport.addEventListener(
|
|
123
|
-
$cd94b4896dd97759$var$visualViewport === null || $cd94b4896dd97759$var$visualViewport === void 0 ? void 0 : $cd94b4896dd97759$var$visualViewport.addEventListener(
|
|
131
|
+
$cd94b4896dd97759$var$visualViewport === null || $cd94b4896dd97759$var$visualViewport === void 0 ? void 0 : $cd94b4896dd97759$var$visualViewport.addEventListener('resize', onResize);
|
|
132
|
+
$cd94b4896dd97759$var$visualViewport === null || $cd94b4896dd97759$var$visualViewport === void 0 ? void 0 : $cd94b4896dd97759$var$visualViewport.addEventListener('scroll', onScroll);
|
|
124
133
|
return ()=>{
|
|
125
|
-
$cd94b4896dd97759$var$visualViewport === null || $cd94b4896dd97759$var$visualViewport === void 0 ? void 0 : $cd94b4896dd97759$var$visualViewport.removeEventListener(
|
|
126
|
-
$cd94b4896dd97759$var$visualViewport === null || $cd94b4896dd97759$var$visualViewport === void 0 ? void 0 : $cd94b4896dd97759$var$visualViewport.removeEventListener(
|
|
134
|
+
$cd94b4896dd97759$var$visualViewport === null || $cd94b4896dd97759$var$visualViewport === void 0 ? void 0 : $cd94b4896dd97759$var$visualViewport.removeEventListener('resize', onResize);
|
|
135
|
+
$cd94b4896dd97759$var$visualViewport === null || $cd94b4896dd97759$var$visualViewport === void 0 ? void 0 : $cd94b4896dd97759$var$visualViewport.removeEventListener('scroll', onScroll);
|
|
127
136
|
};
|
|
128
137
|
}, [
|
|
129
138
|
updatePosition
|
|
@@ -144,7 +153,7 @@ function $cd94b4896dd97759$export$d39e1813b3bdd0e1(props) {
|
|
|
144
153
|
return {
|
|
145
154
|
overlayProps: {
|
|
146
155
|
style: {
|
|
147
|
-
position:
|
|
156
|
+
position: 'absolute',
|
|
148
157
|
zIndex: 100000,
|
|
149
158
|
...position.position,
|
|
150
159
|
maxHeight: position.maxHeight
|
|
@@ -152,8 +161,8 @@ function $cd94b4896dd97759$export$d39e1813b3bdd0e1(props) {
|
|
|
152
161
|
},
|
|
153
162
|
placement: position.placement,
|
|
154
163
|
arrowProps: {
|
|
155
|
-
|
|
156
|
-
role:
|
|
164
|
+
'aria-hidden': 'true',
|
|
165
|
+
role: 'presentation',
|
|
157
166
|
style: {
|
|
158
167
|
left: position.arrowOffsetLeft,
|
|
159
168
|
top: position.arrowOffsetTop
|
|
@@ -164,17 +173,17 @@ function $cd94b4896dd97759$export$d39e1813b3bdd0e1(props) {
|
|
|
164
173
|
}
|
|
165
174
|
function $cd94b4896dd97759$var$useResize(onResize) {
|
|
166
175
|
(0, $6TXnl$reactariautils.useLayoutEffect)(()=>{
|
|
167
|
-
window.addEventListener(
|
|
176
|
+
window.addEventListener('resize', onResize, false);
|
|
168
177
|
return ()=>{
|
|
169
|
-
window.removeEventListener(
|
|
178
|
+
window.removeEventListener('resize', onResize, false);
|
|
170
179
|
};
|
|
171
180
|
}, [
|
|
172
181
|
onResize
|
|
173
182
|
]);
|
|
174
183
|
}
|
|
175
184
|
function $cd94b4896dd97759$var$translateRTL(position, direction) {
|
|
176
|
-
if (direction ===
|
|
177
|
-
return position.replace(
|
|
185
|
+
if (direction === 'rtl') return position.replace('start', 'right').replace('end', 'left');
|
|
186
|
+
return position.replace('start', 'left').replace('end', 'right');
|
|
178
187
|
}
|
|
179
188
|
|
|
180
189
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAgED,aA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DAAA,qCAAgB,mBAAmB,CAAC,UAAU;QAChD;IACF,GAAG;QAAC;KAAe;IAEnB,IAAI,QAAQ,CAAA,GAAA,wBAAU,EAAE;QACtB,IAAI,CAAC,WAAW,OAAO,EACrB;IAEJ,GAAG;QAAC;QAAS;KAAW;IAExB,kFAAkF;IAClF,mEAAmE;IACnE,CAAA,GAAA,0CAAe,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,qCAAc,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.main.js.map"}
|
|
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,8BAAQ;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,qBAAO,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,mBAAK,EAAE,iDAAA,2DAAA,qCAAgB,KAAK;IAC5C,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,QACF,UAAU,OAAO,GAAG,iDAAA,2DAAA,qCAAgB,KAAK;IAE7C,GAAG;QAAC;KAAO;IAEX,IAAI,iBAAiB,CAA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;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 let overlay = (overlayRef.current as HTMLElement);\n if (!maxHeight && overlayRef.current) {\n overlay.style.top = '0px';\n overlay.style.bottom = '';\n overlay.style.maxHeight = (window.visualViewport?.height ?? window.innerHeight) + 'px';\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 overlay.style.top = '';\n overlay.style.bottom = '';\n Object.keys(position.position).forEach(key => overlay.style[key] = position.position[key] + 'px');\n overlay.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.main.js.map"}
|