@react-aria/overlays 3.31.1 → 3.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +12 -12
- package/dist/main.js +28 -28
- package/dist/main.js.map +1 -1
- package/dist/module.js +12 -12
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +19 -0
- package/package.json +15 -21
- package/src/index.ts +19 -22
- package/dist/DismissButton.main.js +0 -51
- package/dist/DismissButton.main.js.map +0 -1
- package/dist/DismissButton.mjs +0 -46
- package/dist/DismissButton.module.js +0 -46
- package/dist/DismissButton.module.js.map +0 -1
- package/dist/Overlay.main.js +0 -73
- package/dist/Overlay.main.js.map +0 -1
- package/dist/Overlay.mjs +0 -63
- package/dist/Overlay.module.js +0 -63
- package/dist/Overlay.module.js.map +0 -1
- package/dist/PortalProvider.main.js +0 -41
- package/dist/PortalProvider.main.js.map +0 -1
- package/dist/PortalProvider.mjs +0 -31
- package/dist/PortalProvider.module.js +0 -31
- package/dist/PortalProvider.module.js.map +0 -1
- package/dist/ar-AE.main.js +0 -6
- package/dist/ar-AE.main.js.map +0 -1
- package/dist/ar-AE.mjs +0 -8
- package/dist/ar-AE.module.js +0 -8
- package/dist/ar-AE.module.js.map +0 -1
- package/dist/ariaHideOutside.main.js +0 -152
- package/dist/ariaHideOutside.main.js.map +0 -1
- package/dist/ariaHideOutside.mjs +0 -146
- package/dist/ariaHideOutside.module.js +0 -146
- package/dist/ariaHideOutside.module.js.map +0 -1
- package/dist/bg-BG.main.js +0 -6
- package/dist/bg-BG.main.js.map +0 -1
- package/dist/bg-BG.mjs +0 -8
- package/dist/bg-BG.module.js +0 -8
- package/dist/bg-BG.module.js.map +0 -1
- package/dist/calculatePosition.main.js +0 -414
- package/dist/calculatePosition.main.js.map +0 -1
- package/dist/calculatePosition.mjs +0 -408
- package/dist/calculatePosition.module.js +0 -408
- package/dist/calculatePosition.module.js.map +0 -1
- package/dist/cs-CZ.main.js +0 -6
- package/dist/cs-CZ.main.js.map +0 -1
- package/dist/cs-CZ.mjs +0 -8
- package/dist/cs-CZ.module.js +0 -8
- package/dist/cs-CZ.module.js.map +0 -1
- package/dist/da-DK.main.js +0 -6
- package/dist/da-DK.main.js.map +0 -1
- package/dist/da-DK.mjs +0 -8
- package/dist/da-DK.module.js +0 -8
- package/dist/da-DK.module.js.map +0 -1
- package/dist/de-DE.main.js +0 -6
- package/dist/de-DE.main.js.map +0 -1
- package/dist/de-DE.mjs +0 -8
- package/dist/de-DE.module.js +0 -8
- package/dist/de-DE.module.js.map +0 -1
- package/dist/el-GR.main.js +0 -6
- package/dist/el-GR.main.js.map +0 -1
- package/dist/el-GR.mjs +0 -8
- package/dist/el-GR.module.js +0 -8
- package/dist/el-GR.module.js.map +0 -1
- package/dist/en-US.main.js +0 -6
- package/dist/en-US.main.js.map +0 -1
- package/dist/en-US.mjs +0 -8
- package/dist/en-US.module.js +0 -8
- package/dist/en-US.module.js.map +0 -1
- package/dist/es-ES.main.js +0 -6
- package/dist/es-ES.main.js.map +0 -1
- package/dist/es-ES.mjs +0 -8
- package/dist/es-ES.module.js +0 -8
- package/dist/es-ES.module.js.map +0 -1
- package/dist/et-EE.main.js +0 -6
- package/dist/et-EE.main.js.map +0 -1
- package/dist/et-EE.mjs +0 -8
- package/dist/et-EE.module.js +0 -8
- package/dist/et-EE.module.js.map +0 -1
- package/dist/fi-FI.main.js +0 -6
- package/dist/fi-FI.main.js.map +0 -1
- package/dist/fi-FI.mjs +0 -8
- package/dist/fi-FI.module.js +0 -8
- package/dist/fi-FI.module.js.map +0 -1
- package/dist/fr-FR.main.js +0 -6
- package/dist/fr-FR.main.js.map +0 -1
- package/dist/fr-FR.mjs +0 -8
- package/dist/fr-FR.module.js +0 -8
- package/dist/fr-FR.module.js.map +0 -1
- package/dist/he-IL.main.js +0 -6
- package/dist/he-IL.main.js.map +0 -1
- package/dist/he-IL.mjs +0 -8
- package/dist/he-IL.module.js +0 -8
- package/dist/he-IL.module.js.map +0 -1
- package/dist/hr-HR.main.js +0 -6
- package/dist/hr-HR.main.js.map +0 -1
- package/dist/hr-HR.mjs +0 -8
- package/dist/hr-HR.module.js +0 -8
- package/dist/hr-HR.module.js.map +0 -1
- package/dist/hu-HU.main.js +0 -6
- package/dist/hu-HU.main.js.map +0 -1
- package/dist/hu-HU.mjs +0 -8
- package/dist/hu-HU.module.js +0 -8
- package/dist/hu-HU.module.js.map +0 -1
- package/dist/intlStrings.main.js +0 -108
- package/dist/intlStrings.main.js.map +0 -1
- package/dist/intlStrings.mjs +0 -110
- package/dist/intlStrings.module.js +0 -110
- package/dist/intlStrings.module.js.map +0 -1
- package/dist/it-IT.main.js +0 -6
- package/dist/it-IT.main.js.map +0 -1
- package/dist/it-IT.mjs +0 -8
- package/dist/it-IT.module.js +0 -8
- package/dist/it-IT.module.js.map +0 -1
- package/dist/ja-JP.main.js +0 -6
- package/dist/ja-JP.main.js.map +0 -1
- package/dist/ja-JP.mjs +0 -8
- package/dist/ja-JP.module.js +0 -8
- package/dist/ja-JP.module.js.map +0 -1
- package/dist/ko-KR.main.js +0 -6
- package/dist/ko-KR.main.js.map +0 -1
- package/dist/ko-KR.mjs +0 -8
- package/dist/ko-KR.module.js +0 -8
- package/dist/ko-KR.module.js.map +0 -1
- package/dist/lt-LT.main.js +0 -6
- package/dist/lt-LT.main.js.map +0 -1
- package/dist/lt-LT.mjs +0 -8
- package/dist/lt-LT.module.js +0 -8
- package/dist/lt-LT.module.js.map +0 -1
- package/dist/lv-LV.main.js +0 -6
- package/dist/lv-LV.main.js.map +0 -1
- package/dist/lv-LV.mjs +0 -8
- package/dist/lv-LV.module.js +0 -8
- package/dist/lv-LV.module.js.map +0 -1
- package/dist/nb-NO.main.js +0 -6
- package/dist/nb-NO.main.js.map +0 -1
- package/dist/nb-NO.mjs +0 -8
- package/dist/nb-NO.module.js +0 -8
- package/dist/nb-NO.module.js.map +0 -1
- package/dist/nl-NL.main.js +0 -6
- package/dist/nl-NL.main.js.map +0 -1
- package/dist/nl-NL.mjs +0 -8
- package/dist/nl-NL.module.js +0 -8
- package/dist/nl-NL.module.js.map +0 -1
- package/dist/pl-PL.main.js +0 -6
- package/dist/pl-PL.main.js.map +0 -1
- package/dist/pl-PL.mjs +0 -8
- package/dist/pl-PL.module.js +0 -8
- package/dist/pl-PL.module.js.map +0 -1
- package/dist/pt-BR.main.js +0 -6
- package/dist/pt-BR.main.js.map +0 -1
- package/dist/pt-BR.mjs +0 -8
- package/dist/pt-BR.module.js +0 -8
- package/dist/pt-BR.module.js.map +0 -1
- package/dist/pt-PT.main.js +0 -6
- package/dist/pt-PT.main.js.map +0 -1
- package/dist/pt-PT.mjs +0 -8
- package/dist/pt-PT.module.js +0 -8
- package/dist/pt-PT.module.js.map +0 -1
- package/dist/ro-RO.main.js +0 -6
- package/dist/ro-RO.main.js.map +0 -1
- package/dist/ro-RO.mjs +0 -8
- package/dist/ro-RO.module.js +0 -8
- package/dist/ro-RO.module.js.map +0 -1
- package/dist/ru-RU.main.js +0 -6
- package/dist/ru-RU.main.js.map +0 -1
- package/dist/ru-RU.mjs +0 -8
- package/dist/ru-RU.module.js +0 -8
- package/dist/ru-RU.module.js.map +0 -1
- package/dist/sk-SK.main.js +0 -6
- package/dist/sk-SK.main.js.map +0 -1
- package/dist/sk-SK.mjs +0 -8
- package/dist/sk-SK.module.js +0 -8
- package/dist/sk-SK.module.js.map +0 -1
- package/dist/sl-SI.main.js +0 -6
- package/dist/sl-SI.main.js.map +0 -1
- package/dist/sl-SI.mjs +0 -8
- package/dist/sl-SI.module.js +0 -8
- package/dist/sl-SI.module.js.map +0 -1
- package/dist/sr-SP.main.js +0 -6
- package/dist/sr-SP.main.js.map +0 -1
- package/dist/sr-SP.mjs +0 -8
- package/dist/sr-SP.module.js +0 -8
- package/dist/sr-SP.module.js.map +0 -1
- package/dist/sv-SE.main.js +0 -6
- package/dist/sv-SE.main.js.map +0 -1
- package/dist/sv-SE.mjs +0 -8
- package/dist/sv-SE.module.js +0 -8
- package/dist/sv-SE.module.js.map +0 -1
- package/dist/tr-TR.main.js +0 -6
- package/dist/tr-TR.main.js.map +0 -1
- package/dist/tr-TR.mjs +0 -8
- package/dist/tr-TR.module.js +0 -8
- package/dist/tr-TR.module.js.map +0 -1
- package/dist/types.d.ts +0 -355
- package/dist/types.d.ts.map +0 -1
- package/dist/uk-UA.main.js +0 -6
- package/dist/uk-UA.main.js.map +0 -1
- package/dist/uk-UA.mjs +0 -8
- package/dist/uk-UA.module.js +0 -8
- package/dist/uk-UA.module.js.map +0 -1
- package/dist/useCloseOnScroll.main.js +0 -52
- package/dist/useCloseOnScroll.main.js.map +0 -1
- package/dist/useCloseOnScroll.mjs +0 -46
- package/dist/useCloseOnScroll.module.js +0 -46
- package/dist/useCloseOnScroll.module.js.map +0 -1
- package/dist/useModal.main.js +0 -118
- package/dist/useModal.main.js.map +0 -1
- package/dist/useModal.mjs +0 -105
- package/dist/useModal.module.js +0 -105
- package/dist/useModal.module.js.map +0 -1
- package/dist/useModalOverlay.main.js +0 -57
- package/dist/useModalOverlay.main.js.map +0 -1
- package/dist/useModalOverlay.mjs +0 -52
- package/dist/useModalOverlay.module.js +0 -52
- package/dist/useModalOverlay.module.js.map +0 -1
- package/dist/useOverlay.main.js +0 -111
- package/dist/useOverlay.main.js.map +0 -1
- package/dist/useOverlay.mjs +0 -106
- package/dist/useOverlay.module.js +0 -106
- package/dist/useOverlay.module.js.map +0 -1
- package/dist/useOverlayPosition.main.js +0 -225
- package/dist/useOverlayPosition.main.js.map +0 -1
- package/dist/useOverlayPosition.mjs +0 -220
- package/dist/useOverlayPosition.module.js +0 -220
- package/dist/useOverlayPosition.module.js.map +0 -1
- package/dist/useOverlayTrigger.main.js +0 -54
- package/dist/useOverlayTrigger.main.js.map +0 -1
- package/dist/useOverlayTrigger.mjs +0 -49
- package/dist/useOverlayTrigger.module.js +0 -49
- package/dist/useOverlayTrigger.module.js.map +0 -1
- package/dist/usePopover.main.js +0 -77
- package/dist/usePopover.main.js.map +0 -1
- package/dist/usePopover.mjs +0 -72
- package/dist/usePopover.module.js +0 -72
- package/dist/usePopover.module.js.map +0 -1
- package/dist/usePreventScroll.main.js +0 -215
- package/dist/usePreventScroll.main.js.map +0 -1
- package/dist/usePreventScroll.mjs +0 -210
- package/dist/usePreventScroll.module.js +0 -210
- package/dist/usePreventScroll.module.js.map +0 -1
- package/dist/zh-CN.main.js +0 -6
- package/dist/zh-CN.main.js.map +0 -1
- package/dist/zh-CN.mjs +0 -8
- package/dist/zh-CN.module.js +0 -8
- package/dist/zh-CN.module.js.map +0 -1
- package/dist/zh-TW.main.js +0 -6
- package/dist/zh-TW.main.js.map +0 -1
- package/dist/zh-TW.mjs +0 -8
- package/dist/zh-TW.module.js +0 -8
- package/dist/zh-TW.module.js.map +0 -1
- package/src/DismissButton.tsx +0 -52
- package/src/Overlay.tsx +0 -95
- package/src/PortalProvider.tsx +0 -41
- package/src/ariaHideOutside.ts +0 -221
- package/src/calculatePosition.ts +0 -680
- package/src/useCloseOnScroll.ts +0 -65
- package/src/useModal.tsx +0 -197
- package/src/useModalOverlay.ts +0 -69
- package/src/useOverlay.ts +0 -169
- package/src/useOverlayPosition.ts +0 -327
- package/src/useOverlayTrigger.ts +0 -72
- package/src/usePopover.ts +0 -138
- package/src/usePreventScroll.ts +0 -273
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AA0BM,SAAS,0CAAkB,KAA0B,EAAE,KAA0B,EAAE,GAA+B;IACvH,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,eAAgD;IACpD,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, RefObject} from '@react-types/shared';\nimport {onCloseMap} from './useCloseOnScroll';\nimport {OverlayTriggerState} from '@react-stately/overlays';\nimport {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 | null>): 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 | boolean | 'listbox' = 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 : undefined,\n onPress: state.toggle\n },\n overlayProps: {\n id: overlayId\n }\n };\n}\n"],"names":[],"version":3,"file":"useOverlayTrigger.module.js.map"}
|
package/dist/usePopover.main.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
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
|
-
var $jkVOI$react = require("react");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function $parcel$export(e, n, v, s) {
|
|
10
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
$parcel$export(module.exports, "usePopover", () => $6c2dfcdee3e15e20$export$542a6fd13ac93354);
|
|
14
|
-
/*
|
|
15
|
-
* Copyright 2022 Adobe. All rights reserved.
|
|
16
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
17
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
18
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
-
*
|
|
20
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
21
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
22
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
23
|
-
* governing permissions and limitations under the License.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function $6c2dfcdee3e15e20$export$542a6fd13ac93354(props, state) {
|
|
31
|
-
let { triggerRef: triggerRef, popoverRef: popoverRef, groupRef: groupRef, isNonModal: isNonModal, isKeyboardDismissDisabled: isKeyboardDismissDisabled, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside, ...otherProps } = props;
|
|
32
|
-
let isSubmenu = otherProps['trigger'] === 'SubmenuTrigger';
|
|
33
|
-
let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $82711f9cb668ecdb$exports.useOverlay)({
|
|
34
|
-
isOpen: state.isOpen,
|
|
35
|
-
onClose: state.close,
|
|
36
|
-
shouldCloseOnBlur: true,
|
|
37
|
-
isDismissable: !isNonModal || isSubmenu,
|
|
38
|
-
isKeyboardDismissDisabled: isKeyboardDismissDisabled,
|
|
39
|
-
shouldCloseOnInteractOutside: shouldCloseOnInteractOutside
|
|
40
|
-
}, groupRef !== null && groupRef !== void 0 ? groupRef : popoverRef);
|
|
41
|
-
let { overlayProps: positionProps, arrowProps: arrowProps, placement: placement, triggerAnchorPoint: origin } = (0, $cd94b4896dd97759$exports.useOverlayPosition)({
|
|
42
|
-
...otherProps,
|
|
43
|
-
targetRef: triggerRef,
|
|
44
|
-
overlayRef: popoverRef,
|
|
45
|
-
isOpen: state.isOpen,
|
|
46
|
-
onClose: isNonModal && !isSubmenu ? state.close : null
|
|
47
|
-
});
|
|
48
|
-
(0, $5c2f5cd01815d369$exports.usePreventScroll)({
|
|
49
|
-
isDisabled: isNonModal || !state.isOpen
|
|
50
|
-
});
|
|
51
|
-
(0, $jkVOI$react.useEffect)(()=>{
|
|
52
|
-
if (state.isOpen && popoverRef.current) {
|
|
53
|
-
var _groupRef_current, _groupRef_current1;
|
|
54
|
-
if (isNonModal) return (0, $08ef1685902b6011$exports.keepVisible)((_groupRef_current = groupRef === null || groupRef === void 0 ? void 0 : groupRef.current) !== null && _groupRef_current !== void 0 ? _groupRef_current : popoverRef.current);
|
|
55
|
-
else return (0, $08ef1685902b6011$exports.ariaHideOutside)([
|
|
56
|
-
(_groupRef_current1 = groupRef === null || groupRef === void 0 ? void 0 : groupRef.current) !== null && _groupRef_current1 !== void 0 ? _groupRef_current1 : popoverRef.current
|
|
57
|
-
], {
|
|
58
|
-
shouldUseInert: true
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}, [
|
|
62
|
-
isNonModal,
|
|
63
|
-
state.isOpen,
|
|
64
|
-
popoverRef,
|
|
65
|
-
groupRef
|
|
66
|
-
]);
|
|
67
|
-
return {
|
|
68
|
-
popoverProps: (0, $jkVOI$reactariautils.mergeProps)(overlayProps, positionProps),
|
|
69
|
-
arrowProps: arrowProps,
|
|
70
|
-
underlayProps: underlayProps,
|
|
71
|
-
placement: placement,
|
|
72
|
-
triggerAnchorPoint: origin
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
//# sourceMappingURL=usePopover.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAyEM,SAAS,0CAAW,KAAuB,EAAE,KAA0B;IAC5E,IAAI,cACF,UAAU,cACV,UAAU,YACV,QAAQ,cACR,UAAU,6BACV,yBAAyB,gCACzB,4BAA4B,EAC5B,GAAG,YACJ,GAAG;IAEJ,IAAI,YAAY,UAAU,CAAC,UAAU,KAAK;IAE1C,IAAI,gBAAC,YAAY,iBAAE,aAAa,EAAC,GAAG,CAAA,GAAA,oCAAS,EAC3C;QACE,QAAQ,MAAM,MAAM;QACpB,SAAS,MAAM,KAAK;QACpB,mBAAmB;QACnB,eAAe,CAAC,cAAc;mCAC9B;sCACA;IACF,GACA,qBAAA,sBAAA,WAAY;IAGd,IAAI,EAAC,cAAc,aAAa,cAAE,UAAU,aAAE,SAAS,EAAE,oBAAoB,MAAM,EAAC,GAAG,CAAA,GAAA,4CAAiB,EAAE;QACxG,GAAG,UAAU;QACb,WAAW;QACX,YAAY;QACZ,QAAQ,MAAM,MAAM;QACpB,SAAS,cAAc,CAAC,YAAY,MAAM,KAAK,GAAG;IACpD;IAEA,CAAA,GAAA,0CAAe,EAAE;QACf,YAAY,cAAc,CAAC,MAAM,MAAM;IACzC;IAEA,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,MAAM,MAAM,IAAI,WAAW,OAAO,EAAE;gBAEjB,mBAEK;YAH1B,IAAI,YACF,OAAO,CAAA,GAAA,qCAAU,EAAE,CAAA,oBAAA,qBAAA,+BAAA,SAAU,OAAO,cAAjB,+BAAA,oBAAqB,WAAW,OAAO;iBAE1D,OAAO,CAAA,GAAA,yCAAc,EAAE;gBAAC,CAAA,qBAAA,qBAAA,+BAAA,SAAU,OAAO,cAAjB,gCAAA,qBAAqB,WAAW,OAAO;aAAC,EAAE;gBAAC,gBAAgB;YAAI;QAE3F;IACF,GAAG;QAAC;QAAY,MAAM,MAAM;QAAE;QAAY;KAAS;IAEnD,OAAO;QACL,cAAc,CAAA,GAAA,gCAAS,EAAE,cAAc;oBACvC;uBACA;mBACA;QACA,oBAAoB;IACtB;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, keepVisible} from './ariaHideOutside';\nimport {AriaPositionProps, useOverlayPosition} from './useOverlayPosition';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport {OverlayTriggerState} from '@react-stately/overlays';\nimport {PlacementAxis} from '@react-types/overlays';\nimport {useEffect} 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 | null>,\n /**\n * The ref for the popover element.\n */\n popoverRef: RefObject<Element | null>,\n /** A ref for the popover arrow element. */\n arrowRef?: RefObject<Element | null>,\n /**\n * An optional ref for a group of popovers, e.g. submenus.\n * When provided, this element is used to detect outside interactions\n * and hiding elements from assistive technologies instead of the popoverRef.\n */\n groupRef?: RefObject<Element | null>,\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 | null,\n /** The origin of the target in the overlay's coordinate system. Useful for animations. */\n triggerAnchorPoint: {x: number, y: number} | null\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 groupRef,\n isNonModal,\n isKeyboardDismissDisabled,\n shouldCloseOnInteractOutside,\n ...otherProps\n } = props;\n\n let isSubmenu = otherProps['trigger'] === 'SubmenuTrigger';\n\n let {overlayProps, underlayProps} = useOverlay(\n {\n isOpen: state.isOpen,\n onClose: state.close,\n shouldCloseOnBlur: true,\n isDismissable: !isNonModal || isSubmenu,\n isKeyboardDismissDisabled,\n shouldCloseOnInteractOutside\n },\n groupRef ?? popoverRef\n );\n\n let {overlayProps: positionProps, arrowProps, placement, triggerAnchorPoint: origin} = useOverlayPosition({\n ...otherProps,\n targetRef: triggerRef,\n overlayRef: popoverRef,\n isOpen: state.isOpen,\n onClose: isNonModal && !isSubmenu ? state.close : null\n });\n\n usePreventScroll({\n isDisabled: isNonModal || !state.isOpen\n });\n\n useEffect(() => {\n if (state.isOpen && popoverRef.current) {\n if (isNonModal) {\n return keepVisible(groupRef?.current ?? popoverRef.current);\n } else {\n return ariaHideOutside([groupRef?.current ?? popoverRef.current], {shouldUseInert: true});\n }\n }\n }, [isNonModal, state.isOpen, popoverRef, groupRef]);\n\n return {\n popoverProps: mergeProps(overlayProps, positionProps),\n arrowProps,\n underlayProps,\n placement,\n triggerAnchorPoint: origin\n };\n}\n"],"names":[],"version":3,"file":"usePopover.main.js.map"}
|
package/dist/usePopover.mjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {ariaHideOutside as $5e3802645cc19319$export$1c3ebcada18427bf, keepVisible as $5e3802645cc19319$export$1020fa7f77e17884} 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 {mergeProps as $m0yab$mergeProps} from "@react-aria/utils";
|
|
6
|
-
import {useEffect as $m0yab$useEffect} from "react";
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* Copyright 2022 Adobe. All rights reserved.
|
|
10
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
11
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
12
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
15
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
16
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
|
-
* governing permissions and limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function $f2f8a6077418541e$export$542a6fd13ac93354(props, state) {
|
|
25
|
-
let { triggerRef: triggerRef, popoverRef: popoverRef, groupRef: groupRef, isNonModal: isNonModal, isKeyboardDismissDisabled: isKeyboardDismissDisabled, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside, ...otherProps } = props;
|
|
26
|
-
let isSubmenu = otherProps['trigger'] === 'SubmenuTrigger';
|
|
27
|
-
let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $a11501f3d1d39e6c$export$ea8f71083e90600f)({
|
|
28
|
-
isOpen: state.isOpen,
|
|
29
|
-
onClose: state.close,
|
|
30
|
-
shouldCloseOnBlur: true,
|
|
31
|
-
isDismissable: !isNonModal || isSubmenu,
|
|
32
|
-
isKeyboardDismissDisabled: isKeyboardDismissDisabled,
|
|
33
|
-
shouldCloseOnInteractOutside: shouldCloseOnInteractOutside
|
|
34
|
-
}, groupRef !== null && groupRef !== void 0 ? groupRef : popoverRef);
|
|
35
|
-
let { overlayProps: positionProps, arrowProps: arrowProps, placement: placement, triggerAnchorPoint: origin } = (0, $2a41e45df1593e64$export$d39e1813b3bdd0e1)({
|
|
36
|
-
...otherProps,
|
|
37
|
-
targetRef: triggerRef,
|
|
38
|
-
overlayRef: popoverRef,
|
|
39
|
-
isOpen: state.isOpen,
|
|
40
|
-
onClose: isNonModal && !isSubmenu ? state.close : null
|
|
41
|
-
});
|
|
42
|
-
(0, $49c51c25361d4cd2$export$ee0f7cc6afcd1c18)({
|
|
43
|
-
isDisabled: isNonModal || !state.isOpen
|
|
44
|
-
});
|
|
45
|
-
(0, $m0yab$useEffect)(()=>{
|
|
46
|
-
if (state.isOpen && popoverRef.current) {
|
|
47
|
-
var _groupRef_current, _groupRef_current1;
|
|
48
|
-
if (isNonModal) return (0, $5e3802645cc19319$export$1020fa7f77e17884)((_groupRef_current = groupRef === null || groupRef === void 0 ? void 0 : groupRef.current) !== null && _groupRef_current !== void 0 ? _groupRef_current : popoverRef.current);
|
|
49
|
-
else return (0, $5e3802645cc19319$export$1c3ebcada18427bf)([
|
|
50
|
-
(_groupRef_current1 = groupRef === null || groupRef === void 0 ? void 0 : groupRef.current) !== null && _groupRef_current1 !== void 0 ? _groupRef_current1 : popoverRef.current
|
|
51
|
-
], {
|
|
52
|
-
shouldUseInert: true
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}, [
|
|
56
|
-
isNonModal,
|
|
57
|
-
state.isOpen,
|
|
58
|
-
popoverRef,
|
|
59
|
-
groupRef
|
|
60
|
-
]);
|
|
61
|
-
return {
|
|
62
|
-
popoverProps: (0, $m0yab$mergeProps)(overlayProps, positionProps),
|
|
63
|
-
arrowProps: arrowProps,
|
|
64
|
-
underlayProps: underlayProps,
|
|
65
|
-
placement: placement,
|
|
66
|
-
triggerAnchorPoint: origin
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export {$f2f8a6077418541e$export$542a6fd13ac93354 as usePopover};
|
|
72
|
-
//# sourceMappingURL=usePopover.module.js.map
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {ariaHideOutside as $5e3802645cc19319$export$1c3ebcada18427bf, keepVisible as $5e3802645cc19319$export$1020fa7f77e17884} 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 {mergeProps as $m0yab$mergeProps} from "@react-aria/utils";
|
|
6
|
-
import {useEffect as $m0yab$useEffect} from "react";
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* Copyright 2022 Adobe. All rights reserved.
|
|
10
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
11
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
12
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
15
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
16
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
|
-
* governing permissions and limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function $f2f8a6077418541e$export$542a6fd13ac93354(props, state) {
|
|
25
|
-
let { triggerRef: triggerRef, popoverRef: popoverRef, groupRef: groupRef, isNonModal: isNonModal, isKeyboardDismissDisabled: isKeyboardDismissDisabled, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside, ...otherProps } = props;
|
|
26
|
-
let isSubmenu = otherProps['trigger'] === 'SubmenuTrigger';
|
|
27
|
-
let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $a11501f3d1d39e6c$export$ea8f71083e90600f)({
|
|
28
|
-
isOpen: state.isOpen,
|
|
29
|
-
onClose: state.close,
|
|
30
|
-
shouldCloseOnBlur: true,
|
|
31
|
-
isDismissable: !isNonModal || isSubmenu,
|
|
32
|
-
isKeyboardDismissDisabled: isKeyboardDismissDisabled,
|
|
33
|
-
shouldCloseOnInteractOutside: shouldCloseOnInteractOutside
|
|
34
|
-
}, groupRef !== null && groupRef !== void 0 ? groupRef : popoverRef);
|
|
35
|
-
let { overlayProps: positionProps, arrowProps: arrowProps, placement: placement, triggerAnchorPoint: origin } = (0, $2a41e45df1593e64$export$d39e1813b3bdd0e1)({
|
|
36
|
-
...otherProps,
|
|
37
|
-
targetRef: triggerRef,
|
|
38
|
-
overlayRef: popoverRef,
|
|
39
|
-
isOpen: state.isOpen,
|
|
40
|
-
onClose: isNonModal && !isSubmenu ? state.close : null
|
|
41
|
-
});
|
|
42
|
-
(0, $49c51c25361d4cd2$export$ee0f7cc6afcd1c18)({
|
|
43
|
-
isDisabled: isNonModal || !state.isOpen
|
|
44
|
-
});
|
|
45
|
-
(0, $m0yab$useEffect)(()=>{
|
|
46
|
-
if (state.isOpen && popoverRef.current) {
|
|
47
|
-
var _groupRef_current, _groupRef_current1;
|
|
48
|
-
if (isNonModal) return (0, $5e3802645cc19319$export$1020fa7f77e17884)((_groupRef_current = groupRef === null || groupRef === void 0 ? void 0 : groupRef.current) !== null && _groupRef_current !== void 0 ? _groupRef_current : popoverRef.current);
|
|
49
|
-
else return (0, $5e3802645cc19319$export$1c3ebcada18427bf)([
|
|
50
|
-
(_groupRef_current1 = groupRef === null || groupRef === void 0 ? void 0 : groupRef.current) !== null && _groupRef_current1 !== void 0 ? _groupRef_current1 : popoverRef.current
|
|
51
|
-
], {
|
|
52
|
-
shouldUseInert: true
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}, [
|
|
56
|
-
isNonModal,
|
|
57
|
-
state.isOpen,
|
|
58
|
-
popoverRef,
|
|
59
|
-
groupRef
|
|
60
|
-
]);
|
|
61
|
-
return {
|
|
62
|
-
popoverProps: (0, $m0yab$mergeProps)(overlayProps, positionProps),
|
|
63
|
-
arrowProps: arrowProps,
|
|
64
|
-
underlayProps: underlayProps,
|
|
65
|
-
placement: placement,
|
|
66
|
-
triggerAnchorPoint: origin
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export {$f2f8a6077418541e$export$542a6fd13ac93354 as usePopover};
|
|
72
|
-
//# sourceMappingURL=usePopover.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAyEM,SAAS,0CAAW,KAAuB,EAAE,KAA0B;IAC5E,IAAI,cACF,UAAU,cACV,UAAU,YACV,QAAQ,cACR,UAAU,6BACV,yBAAyB,gCACzB,4BAA4B,EAC5B,GAAG,YACJ,GAAG;IAEJ,IAAI,YAAY,UAAU,CAAC,UAAU,KAAK;IAE1C,IAAI,gBAAC,YAAY,iBAAE,aAAa,EAAC,GAAG,CAAA,GAAA,yCAAS,EAC3C;QACE,QAAQ,MAAM,MAAM;QACpB,SAAS,MAAM,KAAK;QACpB,mBAAmB;QACnB,eAAe,CAAC,cAAc;mCAC9B;sCACA;IACF,GACA,qBAAA,sBAAA,WAAY;IAGd,IAAI,EAAC,cAAc,aAAa,cAAE,UAAU,aAAE,SAAS,EAAE,oBAAoB,MAAM,EAAC,GAAG,CAAA,GAAA,yCAAiB,EAAE;QACxG,GAAG,UAAU;QACb,WAAW;QACX,YAAY;QACZ,QAAQ,MAAM,MAAM;QACpB,SAAS,cAAc,CAAC,YAAY,MAAM,KAAK,GAAG;IACpD;IAEA,CAAA,GAAA,yCAAe,EAAE;QACf,YAAY,cAAc,CAAC,MAAM,MAAM;IACzC;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,MAAM,MAAM,IAAI,WAAW,OAAO,EAAE;gBAEjB,mBAEK;YAH1B,IAAI,YACF,OAAO,CAAA,GAAA,yCAAU,EAAE,CAAA,oBAAA,qBAAA,+BAAA,SAAU,OAAO,cAAjB,+BAAA,oBAAqB,WAAW,OAAO;iBAE1D,OAAO,CAAA,GAAA,yCAAc,EAAE;gBAAC,CAAA,qBAAA,qBAAA,+BAAA,SAAU,OAAO,cAAjB,gCAAA,qBAAqB,WAAW,OAAO;aAAC,EAAE;gBAAC,gBAAgB;YAAI;QAE3F;IACF,GAAG;QAAC;QAAY,MAAM,MAAM;QAAE;QAAY;KAAS;IAEnD,OAAO;QACL,cAAc,CAAA,GAAA,iBAAS,EAAE,cAAc;oBACvC;uBACA;mBACA;QACA,oBAAoB;IACtB;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, keepVisible} from './ariaHideOutside';\nimport {AriaPositionProps, useOverlayPosition} from './useOverlayPosition';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport {OverlayTriggerState} from '@react-stately/overlays';\nimport {PlacementAxis} from '@react-types/overlays';\nimport {useEffect} 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 | null>,\n /**\n * The ref for the popover element.\n */\n popoverRef: RefObject<Element | null>,\n /** A ref for the popover arrow element. */\n arrowRef?: RefObject<Element | null>,\n /**\n * An optional ref for a group of popovers, e.g. submenus.\n * When provided, this element is used to detect outside interactions\n * and hiding elements from assistive technologies instead of the popoverRef.\n */\n groupRef?: RefObject<Element | null>,\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 | null,\n /** The origin of the target in the overlay's coordinate system. Useful for animations. */\n triggerAnchorPoint: {x: number, y: number} | null\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 groupRef,\n isNonModal,\n isKeyboardDismissDisabled,\n shouldCloseOnInteractOutside,\n ...otherProps\n } = props;\n\n let isSubmenu = otherProps['trigger'] === 'SubmenuTrigger';\n\n let {overlayProps, underlayProps} = useOverlay(\n {\n isOpen: state.isOpen,\n onClose: state.close,\n shouldCloseOnBlur: true,\n isDismissable: !isNonModal || isSubmenu,\n isKeyboardDismissDisabled,\n shouldCloseOnInteractOutside\n },\n groupRef ?? popoverRef\n );\n\n let {overlayProps: positionProps, arrowProps, placement, triggerAnchorPoint: origin} = useOverlayPosition({\n ...otherProps,\n targetRef: triggerRef,\n overlayRef: popoverRef,\n isOpen: state.isOpen,\n onClose: isNonModal && !isSubmenu ? state.close : null\n });\n\n usePreventScroll({\n isDisabled: isNonModal || !state.isOpen\n });\n\n useEffect(() => {\n if (state.isOpen && popoverRef.current) {\n if (isNonModal) {\n return keepVisible(groupRef?.current ?? popoverRef.current);\n } else {\n return ariaHideOutside([groupRef?.current ?? popoverRef.current], {shouldUseInert: true});\n }\n }\n }, [isNonModal, state.isOpen, popoverRef, groupRef]);\n\n return {\n popoverProps: mergeProps(overlayProps, positionProps),\n arrowProps,\n underlayProps,\n placement,\n triggerAnchorPoint: origin\n };\n}\n"],"names":[],"version":3,"file":"usePopover.module.js.map"}
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
var $59kHH$reactariautils = require("@react-aria/utils");
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function $parcel$export(e, n, v, s) {
|
|
5
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
$parcel$export(module.exports, "usePreventScroll", () => $5c2f5cd01815d369$export$ee0f7cc6afcd1c18);
|
|
9
|
-
/*
|
|
10
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
11
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
-
*
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
-
* governing permissions and limitations under the License.
|
|
19
|
-
*/
|
|
20
|
-
const $5c2f5cd01815d369$var$visualViewport = typeof document !== 'undefined' && window.visualViewport;
|
|
21
|
-
// The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position
|
|
22
|
-
let $5c2f5cd01815d369$var$preventScrollCount = 0;
|
|
23
|
-
let $5c2f5cd01815d369$var$restore;
|
|
24
|
-
function $5c2f5cd01815d369$export$ee0f7cc6afcd1c18(options = {}) {
|
|
25
|
-
let { isDisabled: isDisabled } = options;
|
|
26
|
-
(0, $59kHH$reactariautils.useLayoutEffect)(()=>{
|
|
27
|
-
if (isDisabled) return;
|
|
28
|
-
$5c2f5cd01815d369$var$preventScrollCount++;
|
|
29
|
-
if ($5c2f5cd01815d369$var$preventScrollCount === 1) {
|
|
30
|
-
if ((0, $59kHH$reactariautils.isIOS)()) $5c2f5cd01815d369$var$restore = $5c2f5cd01815d369$var$preventScrollMobileSafari();
|
|
31
|
-
else $5c2f5cd01815d369$var$restore = $5c2f5cd01815d369$var$preventScrollStandard();
|
|
32
|
-
}
|
|
33
|
-
return ()=>{
|
|
34
|
-
$5c2f5cd01815d369$var$preventScrollCount--;
|
|
35
|
-
if ($5c2f5cd01815d369$var$preventScrollCount === 0) $5c2f5cd01815d369$var$restore();
|
|
36
|
-
};
|
|
37
|
-
}, [
|
|
38
|
-
isDisabled
|
|
39
|
-
]);
|
|
40
|
-
}
|
|
41
|
-
// For most browsers, all we need to do is set `overflow: hidden` on the root element, and
|
|
42
|
-
// add some padding to prevent the page from shifting when the scrollbar is hidden.
|
|
43
|
-
function $5c2f5cd01815d369$var$preventScrollStandard() {
|
|
44
|
-
let scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
45
|
-
return (0, $59kHH$reactariautils.chain)(scrollbarWidth > 0 && // Use scrollbar-gutter when supported because it also works for fixed positioned elements.
|
|
46
|
-
('scrollbarGutter' in document.documentElement.style ? $5c2f5cd01815d369$var$setStyle(document.documentElement, 'scrollbarGutter', 'stable') : $5c2f5cd01815d369$var$setStyle(document.documentElement, 'paddingRight', `${scrollbarWidth}px`)), $5c2f5cd01815d369$var$setStyle(document.documentElement, 'overflow', 'hidden'));
|
|
47
|
-
}
|
|
48
|
-
// Mobile Safari is a whole different beast. Even with overflow: hidden,
|
|
49
|
-
// it still scrolls the page in many situations:
|
|
50
|
-
//
|
|
51
|
-
// 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.
|
|
52
|
-
// 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of
|
|
53
|
-
// it, so it becomes scrollable.
|
|
54
|
-
// 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.
|
|
55
|
-
// This may cause even fixed position elements to scroll off the screen.
|
|
56
|
-
// 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always
|
|
57
|
-
// scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.
|
|
58
|
-
//
|
|
59
|
-
// In order to work around these cases, and prevent scrolling without jankiness, we do a few things:
|
|
60
|
-
//
|
|
61
|
-
// 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling
|
|
62
|
-
// on the window.
|
|
63
|
-
// 2. Set `overscroll-behavior: contain` on nested scrollable regions so they do not scroll the page when at
|
|
64
|
-
// the top or bottom. Work around a bug where this does not work when the element does not actually overflow
|
|
65
|
-
// by preventing default in a `touchmove` event. This is best effort: we can't prevent default when pinch
|
|
66
|
-
// zooming or when an element contains text selection, which may allow scrolling in some cases.
|
|
67
|
-
// 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.
|
|
68
|
-
// 4. When focus moves to an input, create an off screen input and focus that temporarily. This prevents
|
|
69
|
-
// Safari from scrolling the page. After a small delay, focus the real input and scroll it into view
|
|
70
|
-
// ourselves, without scrolling the whole page.
|
|
71
|
-
function $5c2f5cd01815d369$var$preventScrollMobileSafari() {
|
|
72
|
-
let scrollable;
|
|
73
|
-
let allowTouchMove = false;
|
|
74
|
-
let onTouchStart = (e)=>{
|
|
75
|
-
// Store the nearest scrollable parent element from the element that the user touched.
|
|
76
|
-
let target = e.target;
|
|
77
|
-
scrollable = (0, $59kHH$reactariautils.isScrollable)(target) ? target : (0, $59kHH$reactariautils.getScrollParent)(target, true);
|
|
78
|
-
allowTouchMove = false;
|
|
79
|
-
// If the target is selected, don't preventDefault in touchmove to allow user to adjust selection.
|
|
80
|
-
let selection = target.ownerDocument.defaultView.getSelection();
|
|
81
|
-
if (selection && !selection.isCollapsed && selection.containsNode(target, true)) allowTouchMove = true;
|
|
82
|
-
// If this is a range input, allow touch move to allow user to adjust the slider value
|
|
83
|
-
if (e.composedPath().some((el)=>el instanceof HTMLInputElement && el.type === 'range')) allowTouchMove = true;
|
|
84
|
-
// If this is a focused input element with a selected range, allow user to drag the selection handles.
|
|
85
|
-
if ('selectionStart' in target && 'selectionEnd' in target && target.selectionStart < target.selectionEnd && target.ownerDocument.activeElement === target) allowTouchMove = true;
|
|
86
|
-
};
|
|
87
|
-
// Prevent scrolling up when at the top and scrolling down when at the bottom
|
|
88
|
-
// of a nested scrollable area, otherwise mobile Safari will start scrolling
|
|
89
|
-
// the window instead.
|
|
90
|
-
// This must be applied before the touchstart event as of iOS 26, so inject it as a <style> element.
|
|
91
|
-
let style = document.createElement('style');
|
|
92
|
-
style.textContent = `
|
|
93
|
-
@layer {
|
|
94
|
-
* {
|
|
95
|
-
overscroll-behavior: contain;
|
|
96
|
-
}
|
|
97
|
-
}`.trim();
|
|
98
|
-
document.head.prepend(style);
|
|
99
|
-
let onTouchMove = (e)=>{
|
|
100
|
-
// Allow pinch-zooming.
|
|
101
|
-
if (e.touches.length === 2 || allowTouchMove) return;
|
|
102
|
-
// Prevent scrolling the window.
|
|
103
|
-
if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
|
|
104
|
-
e.preventDefault();
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
// overscroll-behavior should prevent scroll chaining, but currently does not
|
|
108
|
-
// if the element doesn't actually overflow. https://bugs.webkit.org/show_bug.cgi?id=243452
|
|
109
|
-
// This checks that both the width and height do not overflow, otherwise we might
|
|
110
|
-
// block horizontal scrolling too. In that case, adding `touch-action: pan-x` to
|
|
111
|
-
// the element will prevent vertical page scrolling. We can't add that automatically
|
|
112
|
-
// because it must be set before the touchstart event.
|
|
113
|
-
if (scrollable.scrollHeight === scrollable.clientHeight && scrollable.scrollWidth === scrollable.clientWidth) e.preventDefault();
|
|
114
|
-
};
|
|
115
|
-
let onBlur = (e)=>{
|
|
116
|
-
let target = e.target;
|
|
117
|
-
let relatedTarget = e.relatedTarget;
|
|
118
|
-
if (relatedTarget && (0, $59kHH$reactariautils.willOpenKeyboard)(relatedTarget)) {
|
|
119
|
-
// Focus without scrolling the whole page, and then scroll into view manually.
|
|
120
|
-
relatedTarget.focus({
|
|
121
|
-
preventScroll: true
|
|
122
|
-
});
|
|
123
|
-
$5c2f5cd01815d369$var$scrollIntoViewWhenReady(relatedTarget, (0, $59kHH$reactariautils.willOpenKeyboard)(target));
|
|
124
|
-
} else if (!relatedTarget) {
|
|
125
|
-
var _target_parentElement;
|
|
126
|
-
// When tapping the Done button on the keyboard, focus moves to the body.
|
|
127
|
-
// FocusScope will then restore focus back to the input. Later when tapping
|
|
128
|
-
// the same input again, it is already focused, so no blur event will fire,
|
|
129
|
-
// resulting in the flow above never running and Safari's native scrolling occurring.
|
|
130
|
-
// Instead, move focus to the parent focusable element (e.g. the dialog).
|
|
131
|
-
let focusable = (_target_parentElement = target.parentElement) === null || _target_parentElement === void 0 ? void 0 : _target_parentElement.closest('[tabindex]');
|
|
132
|
-
focusable === null || focusable === void 0 ? void 0 : focusable.focus({
|
|
133
|
-
preventScroll: true
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
// Override programmatic focus to scroll into view without scrolling the whole page.
|
|
138
|
-
let focus = HTMLElement.prototype.focus;
|
|
139
|
-
HTMLElement.prototype.focus = function(opts) {
|
|
140
|
-
// Track whether the keyboard was already visible before.
|
|
141
|
-
let wasKeyboardVisible = document.activeElement != null && (0, $59kHH$reactariautils.willOpenKeyboard)(document.activeElement);
|
|
142
|
-
// Focus the element without scrolling the page.
|
|
143
|
-
focus.call(this, {
|
|
144
|
-
...opts,
|
|
145
|
-
preventScroll: true
|
|
146
|
-
});
|
|
147
|
-
if (!opts || !opts.preventScroll) $5c2f5cd01815d369$var$scrollIntoViewWhenReady(this, wasKeyboardVisible);
|
|
148
|
-
};
|
|
149
|
-
let removeEvents = (0, $59kHH$reactariautils.chain)($5c2f5cd01815d369$var$addEvent(document, 'touchstart', onTouchStart, {
|
|
150
|
-
passive: false,
|
|
151
|
-
capture: true
|
|
152
|
-
}), $5c2f5cd01815d369$var$addEvent(document, 'touchmove', onTouchMove, {
|
|
153
|
-
passive: false,
|
|
154
|
-
capture: true
|
|
155
|
-
}), $5c2f5cd01815d369$var$addEvent(document, 'blur', onBlur, true));
|
|
156
|
-
return ()=>{
|
|
157
|
-
removeEvents();
|
|
158
|
-
style.remove();
|
|
159
|
-
HTMLElement.prototype.focus = focus;
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
// Sets a CSS property on an element, and returns a function to revert it to the previous value.
|
|
163
|
-
function $5c2f5cd01815d369$var$setStyle(element, style, value) {
|
|
164
|
-
let cur = element.style[style];
|
|
165
|
-
element.style[style] = value;
|
|
166
|
-
return ()=>{
|
|
167
|
-
element.style[style] = cur;
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
// Adds an event listener to an element, and returns a function to remove it.
|
|
171
|
-
function $5c2f5cd01815d369$var$addEvent(target, event, handler, options) {
|
|
172
|
-
// internal function, so it's ok to ignore the difficult to fix type error
|
|
173
|
-
// @ts-ignore
|
|
174
|
-
target.addEventListener(event, handler, options);
|
|
175
|
-
return ()=>{
|
|
176
|
-
// @ts-ignore
|
|
177
|
-
target.removeEventListener(event, handler, options);
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
function $5c2f5cd01815d369$var$scrollIntoViewWhenReady(target, wasKeyboardVisible) {
|
|
181
|
-
if (wasKeyboardVisible || !$5c2f5cd01815d369$var$visualViewport) // If the keyboard was already visible, scroll the target into view immediately.
|
|
182
|
-
$5c2f5cd01815d369$var$scrollIntoView(target);
|
|
183
|
-
else // Otherwise, wait for the visual viewport to resize before scrolling so we can
|
|
184
|
-
// measure the correct position to scroll to.
|
|
185
|
-
$5c2f5cd01815d369$var$visualViewport.addEventListener('resize', ()=>$5c2f5cd01815d369$var$scrollIntoView(target), {
|
|
186
|
-
once: true
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
function $5c2f5cd01815d369$var$scrollIntoView(target) {
|
|
190
|
-
let root = document.scrollingElement || document.documentElement;
|
|
191
|
-
let nextTarget = target;
|
|
192
|
-
while(nextTarget && nextTarget !== root){
|
|
193
|
-
// Find the parent scrollable element and adjust the scroll position if the target is not already in view.
|
|
194
|
-
let scrollable = (0, $59kHH$reactariautils.getScrollParent)(nextTarget);
|
|
195
|
-
if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== nextTarget) {
|
|
196
|
-
let scrollableRect = scrollable.getBoundingClientRect();
|
|
197
|
-
let targetRect = nextTarget.getBoundingClientRect();
|
|
198
|
-
if (targetRect.top < scrollableRect.top || targetRect.bottom > scrollableRect.top + nextTarget.clientHeight) {
|
|
199
|
-
let bottom = scrollableRect.bottom;
|
|
200
|
-
if ($5c2f5cd01815d369$var$visualViewport) bottom = Math.min(bottom, $5c2f5cd01815d369$var$visualViewport.offsetTop + $5c2f5cd01815d369$var$visualViewport.height);
|
|
201
|
-
// Center within the viewport.
|
|
202
|
-
let adjustment = targetRect.top - scrollableRect.top - ((bottom - scrollableRect.top) / 2 - targetRect.height / 2);
|
|
203
|
-
scrollable.scrollTo({
|
|
204
|
-
// Clamp to the valid range to prevent over-scrolling.
|
|
205
|
-
top: Math.max(0, Math.min(scrollable.scrollHeight - scrollable.clientHeight, scrollable.scrollTop + adjustment)),
|
|
206
|
-
behavior: 'smooth'
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
nextTarget = scrollable.parentElement;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
//# sourceMappingURL=usePreventScroll.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"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","sources":["packages/@react-aria/overlays/src/usePreventScroll.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 {chain, getScrollParent, isIOS, isScrollable, useLayoutEffect, willOpenKeyboard} from '@react-aria/utils';\n\ninterface PreventScrollOptions {\n /** Whether the scroll lock is disabled. */\n isDisabled?: boolean\n}\n\nconst visualViewport = typeof document !== 'undefined' && window.visualViewport;\n\n// The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position\nlet preventScrollCount = 0;\nlet restore;\n\n/**\n * Prevents scrolling on the document body on mount, and\n * restores it on unmount. Also ensures that content does not\n * shift due to the scrollbars disappearing.\n */\nexport function usePreventScroll(options: PreventScrollOptions = {}): void {\n let {isDisabled} = options;\n\n useLayoutEffect(() => {\n if (isDisabled) {\n return;\n }\n\n preventScrollCount++;\n if (preventScrollCount === 1) {\n if (isIOS()) {\n restore = preventScrollMobileSafari();\n } else {\n restore = preventScrollStandard();\n }\n }\n\n return () => {\n preventScrollCount--;\n if (preventScrollCount === 0) {\n restore();\n }\n };\n }, [isDisabled]);\n}\n\n// For most browsers, all we need to do is set `overflow: hidden` on the root element, and\n// add some padding to prevent the page from shifting when the scrollbar is hidden.\nfunction preventScrollStandard() {\n let scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;\n return chain(\n scrollbarWidth > 0 &&\n // Use scrollbar-gutter when supported because it also works for fixed positioned elements.\n ('scrollbarGutter' in document.documentElement.style\n ? setStyle(document.documentElement, 'scrollbarGutter', 'stable')\n : setStyle(document.documentElement, 'paddingRight', `${scrollbarWidth}px`)),\n setStyle(document.documentElement, 'overflow', 'hidden')\n );\n}\n\n// Mobile Safari is a whole different beast. Even with overflow: hidden,\n// it still scrolls the page in many situations:\n//\n// 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.\n// 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of\n// it, so it becomes scrollable.\n// 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.\n// This may cause even fixed position elements to scroll off the screen.\n// 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always\n// scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.\n//\n// In order to work around these cases, and prevent scrolling without jankiness, we do a few things:\n//\n// 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling\n// on the window.\n// 2. Set `overscroll-behavior: contain` on nested scrollable regions so they do not scroll the page when at\n// the top or bottom. Work around a bug where this does not work when the element does not actually overflow\n// by preventing default in a `touchmove` event. This is best effort: we can't prevent default when pinch\n// zooming or when an element contains text selection, which may allow scrolling in some cases.\n// 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.\n// 4. When focus moves to an input, create an off screen input and focus that temporarily. This prevents \n// Safari from scrolling the page. After a small delay, focus the real input and scroll it into view\n// ourselves, without scrolling the whole page.\nfunction preventScrollMobileSafari() {\n let scrollable: Element;\n let allowTouchMove = false;\n let onTouchStart = (e: TouchEvent) => {\n // Store the nearest scrollable parent element from the element that the user touched.\n let target = e.target as Element;\n scrollable = isScrollable(target) ? target : getScrollParent(target, true);\n allowTouchMove = false;\n \n // If the target is selected, don't preventDefault in touchmove to allow user to adjust selection.\n let selection = target.ownerDocument.defaultView!.getSelection();\n if (selection && !selection.isCollapsed && selection.containsNode(target, true)) {\n allowTouchMove = true;\n }\n\n // If this is a range input, allow touch move to allow user to adjust the slider value\n if (e.composedPath().some((el) =>\n el instanceof HTMLInputElement &&\n el.type === 'range'\n )) {\n allowTouchMove = true;\n }\n\n // If this is a focused input element with a selected range, allow user to drag the selection handles.\n if (\n 'selectionStart' in target && \n 'selectionEnd' in target &&\n (target.selectionStart as number) < (target.selectionEnd as number) &&\n target.ownerDocument.activeElement === target\n ) {\n allowTouchMove = true;\n }\n };\n\n // Prevent scrolling up when at the top and scrolling down when at the bottom\n // of a nested scrollable area, otherwise mobile Safari will start scrolling\n // the window instead.\n // This must be applied before the touchstart event as of iOS 26, so inject it as a <style> element.\n let style = document.createElement('style');\n style.textContent = `\n@layer {\n * {\n overscroll-behavior: contain;\n }\n}`.trim();\n document.head.prepend(style);\n\n let onTouchMove = (e: TouchEvent) => {\n // Allow pinch-zooming.\n if (e.touches.length === 2 || allowTouchMove) {\n return;\n }\n\n // Prevent scrolling the window.\n if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {\n e.preventDefault();\n return;\n }\n\n // overscroll-behavior should prevent scroll chaining, but currently does not\n // if the element doesn't actually overflow. https://bugs.webkit.org/show_bug.cgi?id=243452\n // This checks that both the width and height do not overflow, otherwise we might\n // block horizontal scrolling too. In that case, adding `touch-action: pan-x` to\n // the element will prevent vertical page scrolling. We can't add that automatically\n // because it must be set before the touchstart event.\n if (scrollable.scrollHeight === scrollable.clientHeight && scrollable.scrollWidth === scrollable.clientWidth) {\n e.preventDefault();\n }\n };\n\n let onBlur = (e: FocusEvent) => {\n let target = e.target as HTMLElement;\n let relatedTarget = e.relatedTarget as HTMLElement | null;\n if (relatedTarget && willOpenKeyboard(relatedTarget)) {\n // Focus without scrolling the whole page, and then scroll into view manually.\n relatedTarget.focus({preventScroll: true});\n scrollIntoViewWhenReady(relatedTarget, willOpenKeyboard(target));\n } else if (!relatedTarget) {\n // When tapping the Done button on the keyboard, focus moves to the body.\n // FocusScope will then restore focus back to the input. Later when tapping\n // the same input again, it is already focused, so no blur event will fire,\n // resulting in the flow above never running and Safari's native scrolling occurring.\n // Instead, move focus to the parent focusable element (e.g. the dialog).\n let focusable = target.parentElement?.closest('[tabindex]') as HTMLElement | null;\n focusable?.focus({preventScroll: true});\n }\n };\n\n // Override programmatic focus to scroll into view without scrolling the whole page.\n let focus = HTMLElement.prototype.focus;\n HTMLElement.prototype.focus = function (opts) {\n // Track whether the keyboard was already visible before.\n let wasKeyboardVisible = document.activeElement != null && willOpenKeyboard(document.activeElement);\n\n // Focus the element without scrolling the page.\n focus.call(this, {...opts, preventScroll: true});\n\n if (!opts || !opts.preventScroll) {\n scrollIntoViewWhenReady(this, wasKeyboardVisible);\n }\n };\n\n let removeEvents = chain(\n addEvent(document, 'touchstart', onTouchStart, {passive: false, capture: true}),\n addEvent(document, 'touchmove', onTouchMove, {passive: false, capture: true}),\n addEvent(document, 'blur', onBlur, true)\n );\n\n return () => {\n removeEvents();\n style.remove();\n HTMLElement.prototype.focus = focus;\n };\n}\n\n// Sets a CSS property on an element, and returns a function to revert it to the previous value.\nfunction setStyle(element: HTMLElement, style: string, value: string) {\n let cur = element.style[style];\n element.style[style] = value;\n\n return () => {\n element.style[style] = cur;\n };\n}\n\n// Adds an event listener to an element, and returns a function to remove it.\nfunction addEvent<K extends keyof GlobalEventHandlersEventMap>(\n target: Document | Window,\n event: K,\n handler: (this: Document | Window, ev: GlobalEventHandlersEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n) {\n // internal function, so it's ok to ignore the difficult to fix type error\n // @ts-ignore\n target.addEventListener(event, handler, options);\n return () => {\n // @ts-ignore\n target.removeEventListener(event, handler, options);\n };\n}\n\nfunction scrollIntoViewWhenReady(target: Element, wasKeyboardVisible: boolean) {\n if (wasKeyboardVisible || !visualViewport) {\n // If the keyboard was already visible, scroll the target into view immediately.\n scrollIntoView(target);\n } else {\n // Otherwise, wait for the visual viewport to resize before scrolling so we can\n // measure the correct position to scroll to.\n visualViewport.addEventListener('resize', () => scrollIntoView(target), {once: true});\n }\n}\n\nfunction scrollIntoView(target: Element) {\n let root = document.scrollingElement || document.documentElement;\n let nextTarget: Element | null = target;\n while (nextTarget && nextTarget !== root) {\n // Find the parent scrollable element and adjust the scroll position if the target is not already in view.\n let scrollable = getScrollParent(nextTarget);\n if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== nextTarget) {\n let scrollableRect = scrollable.getBoundingClientRect();\n let targetRect = nextTarget.getBoundingClientRect();\n if (targetRect.top < scrollableRect.top || targetRect.bottom > scrollableRect.top + nextTarget.clientHeight) {\n let bottom = scrollableRect.bottom;\n if (visualViewport) {\n bottom = Math.min(bottom, visualViewport.offsetTop + visualViewport.height);\n }\n\n // Center within the viewport.\n let adjustment = (targetRect.top - scrollableRect.top) - ((bottom - scrollableRect.top) / 2 - targetRect.height / 2);\n scrollable.scrollTo({\n // Clamp to the valid range to prevent over-scrolling.\n top: Math.max(0, Math.min(scrollable.scrollHeight - scrollable.clientHeight, scrollable.scrollTop + adjustment)),\n behavior: 'smooth'\n });\n }\n }\n\n nextTarget = scrollable.parentElement;\n }\n}\n"],"names":[],"version":3,"file":"usePreventScroll.main.js.map"}
|