@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;;AAWM,MAAM,4CAA2C,IAAI;AASrD,SAAS,0CAAiB,IAA0B;IACzD,IAAI,cAAC,UAAU,UAAE,MAAM,WAAE,OAAO,EAAC,GAAG;IAEpC,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,CAAC,UAAU,YAAY,MACzB;QAGF,IAAI,WAAW,CAAC;YACd,uEAAuE;YACvE,IAAI,SAAS,EAAE,MAAM;YACrB,gFAAgF;YAChF,IAAI,CAAC,WAAW,OAAO,IAAK,AAAC,kBAAkB,QAAS,CAAC,CAAA,GAAA,mBAAW,EAAE,QAAQ,WAAW,OAAO,GAC9F;YAGF,8FAA8F;YAC9F,4FAA4F;YAC5F,2GAA2G;YAC3G,IAAI,EAAE,MAAM,YAAY,oBAAoB,EAAE,MAAM,YAAY,qBAC9D;YAGF,IAAI,iBAAiB,WAAW,0CAAW,GAAG,CAAC,WAAW,OAAO;YACjE,IAAI,gBACF;QAEJ;QAEA,OAAO,gBAAgB,CAAC,UAAU,UAAU;QAC5C,OAAO;YACL,OAAO,mBAAmB,CAAC,UAAU,UAAU;QACjD;IACF,GAAG;QAAC;QAAQ;QAAS;KAAW;AAClC","sources":["packages/@react-aria/overlays/src/useCloseOnScroll.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 {nodeContains} from '@react-aria/utils';\nimport {RefObject} from '@react-types/shared';\nimport {useEffect} from 'react';\n\n// This behavior moved from useOverlayTrigger to useOverlayPosition.\n// For backward compatibility, where useOverlayTrigger handled hiding the popover on close,\n// it sets a close function here mapped from the trigger element. This way we can avoid\n// forcing users to pass an onClose function to useOverlayPosition which could be considered\n// a breaking change.\nexport const onCloseMap: WeakMap<Element, () => void> = new WeakMap();\n\ninterface CloseOnScrollOptions {\n triggerRef: RefObject<Element | null>,\n isOpen?: boolean,\n onClose?: (() => void) | null\n}\n\n/** @private */\nexport function useCloseOnScroll(opts: CloseOnScrollOptions): void {\n let {triggerRef, isOpen, onClose} = opts;\n\n useEffect(() => {\n if (!isOpen || onClose === null) {\n return;\n }\n\n let onScroll = (e: Event) => {\n // Ignore if scrolling an scrollable region outside the trigger's tree.\n let target = e.target;\n // window is not a Node and doesn't have contain, but window contains everything\n if (!triggerRef.current || ((target instanceof Node) && !nodeContains(target, triggerRef.current))) {\n return;\n }\n\n // Ignore scroll events on any input or textarea as the cursor position can cause it to scroll\n // such as in a combobox. Clicking the dropdown button places focus on the input, and if the\n // text inside the input extends beyond the 'end', then it will scroll so the cursor is visible at the end.\n if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {\n return;\n }\n\n let onCloseHandler = onClose || onCloseMap.get(triggerRef.current);\n if (onCloseHandler) {\n onCloseHandler();\n }\n };\n\n window.addEventListener('scroll', onScroll, true);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n };\n }, [isOpen, onClose, triggerRef]);\n}\n"],"names":[],"version":3,"file":"useCloseOnScroll.module.js.map"}
|
package/dist/useModal.main.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
var $d7347c25ab757295$exports = require("./PortalProvider.main.js");
|
|
2
|
-
var $btuAB$react = require("react");
|
|
3
|
-
var $btuAB$reactdom = require("react-dom");
|
|
4
|
-
var $btuAB$reactariassr = require("@react-aria/ssr");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function $parcel$interopDefault(a) {
|
|
8
|
-
return a && a.__esModule ? a.default : a;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function $parcel$export(e, n, v, s) {
|
|
12
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
$parcel$export(module.exports, "ModalProvider", () => $0775ea8ea6a0565e$export$178405afcd8c5eb);
|
|
16
|
-
$parcel$export(module.exports, "useModalProvider", () => $0775ea8ea6a0565e$export$d9aaed4c3ece1bc0);
|
|
17
|
-
$parcel$export(module.exports, "OverlayProvider", () => $0775ea8ea6a0565e$export$bf688221f59024e5);
|
|
18
|
-
$parcel$export(module.exports, "OverlayContainer", () => $0775ea8ea6a0565e$export$b47c3594eab58386);
|
|
19
|
-
$parcel$export(module.exports, "useModal", () => $0775ea8ea6a0565e$export$33ffd74ebf07f060);
|
|
20
|
-
/*
|
|
21
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
22
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
23
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
24
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
-
*
|
|
26
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
27
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
28
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
29
|
-
* governing permissions and limitations under the License.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const $0775ea8ea6a0565e$var$Context = /*#__PURE__*/ (0, ($parcel$interopDefault($btuAB$react))).createContext(null);
|
|
35
|
-
function $0775ea8ea6a0565e$export$178405afcd8c5eb(props) {
|
|
36
|
-
let { children: children } = props;
|
|
37
|
-
let parent = (0, $btuAB$react.useContext)($0775ea8ea6a0565e$var$Context);
|
|
38
|
-
let [modalCount, setModalCount] = (0, $btuAB$react.useState)(0);
|
|
39
|
-
let context = (0, $btuAB$react.useMemo)(()=>({
|
|
40
|
-
parent: parent,
|
|
41
|
-
modalCount: modalCount,
|
|
42
|
-
addModal () {
|
|
43
|
-
setModalCount((count)=>count + 1);
|
|
44
|
-
if (parent) parent.addModal();
|
|
45
|
-
},
|
|
46
|
-
removeModal () {
|
|
47
|
-
setModalCount((count)=>count - 1);
|
|
48
|
-
if (parent) parent.removeModal();
|
|
49
|
-
}
|
|
50
|
-
}), [
|
|
51
|
-
parent,
|
|
52
|
-
modalCount
|
|
53
|
-
]);
|
|
54
|
-
return /*#__PURE__*/ (0, ($parcel$interopDefault($btuAB$react))).createElement($0775ea8ea6a0565e$var$Context.Provider, {
|
|
55
|
-
value: context
|
|
56
|
-
}, children);
|
|
57
|
-
}
|
|
58
|
-
function $0775ea8ea6a0565e$export$d9aaed4c3ece1bc0() {
|
|
59
|
-
let context = (0, $btuAB$react.useContext)($0775ea8ea6a0565e$var$Context);
|
|
60
|
-
return {
|
|
61
|
-
modalProviderProps: {
|
|
62
|
-
'aria-hidden': context && context.modalCount > 0 ? true : undefined
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Creates a root node that will be aria-hidden if there are other modals open.
|
|
68
|
-
*/ function $0775ea8ea6a0565e$var$OverlayContainerDOM(props) {
|
|
69
|
-
let { modalProviderProps: modalProviderProps } = $0775ea8ea6a0565e$export$d9aaed4c3ece1bc0();
|
|
70
|
-
return /*#__PURE__*/ (0, ($parcel$interopDefault($btuAB$react))).createElement("div", {
|
|
71
|
-
"data-overlay-container": true,
|
|
72
|
-
...props,
|
|
73
|
-
...modalProviderProps
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
function $0775ea8ea6a0565e$export$bf688221f59024e5(props) {
|
|
77
|
-
return /*#__PURE__*/ (0, ($parcel$interopDefault($btuAB$react))).createElement($0775ea8ea6a0565e$export$178405afcd8c5eb, null, /*#__PURE__*/ (0, ($parcel$interopDefault($btuAB$react))).createElement($0775ea8ea6a0565e$var$OverlayContainerDOM, props));
|
|
78
|
-
}
|
|
79
|
-
function $0775ea8ea6a0565e$export$b47c3594eab58386(props) {
|
|
80
|
-
let isSSR = (0, $btuAB$reactariassr.useIsSSR)();
|
|
81
|
-
let { portalContainer: portalContainer = isSSR ? null : document.body, ...rest } = props;
|
|
82
|
-
let { getContainer: getContainer } = (0, $d7347c25ab757295$exports.useUNSAFE_PortalContext)();
|
|
83
|
-
if (!props.portalContainer && getContainer) portalContainer = getContainer();
|
|
84
|
-
(0, ($parcel$interopDefault($btuAB$react))).useEffect(()=>{
|
|
85
|
-
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.');
|
|
86
|
-
}, [
|
|
87
|
-
portalContainer
|
|
88
|
-
]);
|
|
89
|
-
if (!portalContainer) return null;
|
|
90
|
-
let contents = /*#__PURE__*/ (0, ($parcel$interopDefault($btuAB$react))).createElement($0775ea8ea6a0565e$export$bf688221f59024e5, rest);
|
|
91
|
-
return /*#__PURE__*/ (0, ($parcel$interopDefault($btuAB$reactdom))).createPortal(contents, portalContainer);
|
|
92
|
-
}
|
|
93
|
-
function $0775ea8ea6a0565e$export$33ffd74ebf07f060(options) {
|
|
94
|
-
// Add aria-hidden to all parent providers on mount, and restore on unmount.
|
|
95
|
-
let context = (0, $btuAB$react.useContext)($0775ea8ea6a0565e$var$Context);
|
|
96
|
-
if (!context) throw new Error('Modal is not contained within a provider');
|
|
97
|
-
(0, $btuAB$react.useEffect)(()=>{
|
|
98
|
-
if ((options === null || options === void 0 ? void 0 : options.isDisabled) || !context || !context.parent) return;
|
|
99
|
-
// The immediate context is from the provider containing this modal, so we only
|
|
100
|
-
// want to trigger aria-hidden on its parents not on the modal provider itself.
|
|
101
|
-
context.parent.addModal();
|
|
102
|
-
return ()=>{
|
|
103
|
-
if (context && context.parent) context.parent.removeModal();
|
|
104
|
-
};
|
|
105
|
-
}, [
|
|
106
|
-
context,
|
|
107
|
-
context.parent,
|
|
108
|
-
options === null || options === void 0 ? void 0 : options.isDisabled
|
|
109
|
-
]);
|
|
110
|
-
return {
|
|
111
|
-
modalProps: {
|
|
112
|
-
'data-ismodal': !(options === null || options === void 0 ? void 0 : options.isDisabled)
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
//# sourceMappingURL=useModal.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAmBD,MAAM,8CAAU,CAAA,GAAA,sCAAI,EAAE,aAAa,CAAsB;AAUlD,SAAS,yCAAc,KAAyB;IACrD,IAAI,YAAC,QAAQ,EAAC,GAAG;IACjB,IAAI,SAAS,CAAA,GAAA,uBAAS,EAAE;IACxB,IAAI,CAAC,YAAY,cAAc,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC3C,IAAI,UAAU,CAAA,GAAA,oBAAM,EAAE,IAAO,CAAA;oBAC3B;wBACA;YACA;gBACE,cAAc,CAAA,QAAS,QAAQ;gBAC/B,IAAI,QACF,OAAO,QAAQ;YAEnB;YACA;gBACE,cAAc,CAAA,QAAS,QAAQ;gBAC/B,IAAI,QACF,OAAO,WAAW;YAEtB;QACF,CAAA,GAAI;QAAC;QAAQ;KAAW;IAExB,qBACE,0DAAC,8BAAQ,QAAQ;QAAC,OAAO;OACtB;AAGP;AAaO,SAAS;IACd,IAAI,UAAU,CAAA,GAAA,uBAAS,EAAE;IACzB,OAAO;QACL,oBAAoB;YAClB,eAAe,WAAW,QAAQ,UAAU,GAAG,IAAI,OAAO;QAC5D;IACF;AACF;AAEA;;CAEC,GACD,SAAS,0CAAoB,KAAyB;IACpD,IAAI,sBAAC,kBAAkB,EAAC,GAAG;IAC3B,qBAAO,0DAAC;QAAI,0BAAA;QAAwB,GAAG,KAAK;QAAG,GAAG,kBAAkB;;AACtE;AAUO,SAAS,0CAAgB,KAAyB;IACvD,qBACE,0DAAC,8DACC,0DAAC,2CAAwB;AAG/B;AAkBO,SAAS,0CAAiB,KAA4B;IAC3D,IAAI,QAAQ,CAAA,GAAA,4BAAO;IACnB,IAAI,mBAAC,kBAAkB,QAAQ,OAAO,SAAS,IAAI,EAAE,GAAG,MAAK,GAAG;IAChE,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,iDAAsB;IAC3C,IAAI,CAAC,MAAM,eAAe,IAAI,cAC5B,kBAAkB;IAGpB,CAAA,GAAA,sCAAI,EAAE,SAAS,CAAC;QACd,IAAI,4BAAA,sCAAA,gBAAiB,OAAO,CAAC,6BAC3B,MAAM,IAAI,MAAM;IAEpB,GAAG;QAAC;KAAgB;IAEpB,IAAI,CAAC,iBACH,OAAO;IAGT,IAAI,yBAAW,0DAAC,2CAAoB;IACpC,qBAAO,CAAA,GAAA,yCAAO,EAAE,YAAY,CAAC,UAAU;AACzC;AAsBO,SAAS,0CAAS,OAA0B;IACjD,4EAA4E;IAC5E,IAAI,UAAU,CAAA,GAAA,uBAAS,EAAE;IACzB,IAAI,CAAC,SACH,MAAM,IAAI,MAAM;IAGlB,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,CAAA,oBAAA,8BAAA,QAAS,UAAU,KAAI,CAAC,WAAW,CAAC,QAAQ,MAAM,EACpD;QAGF,+EAA+E;QAC/E,+EAA+E;QAC/E,QAAQ,MAAM,CAAC,QAAQ;QACvB,OAAO;YACL,IAAI,WAAW,QAAQ,MAAM,EAC3B,QAAQ,MAAM,CAAC,WAAW;QAE9B;IACF,GAAG;QAAC;QAAS,QAAQ,MAAM;QAAE,oBAAA,8BAAA,QAAS,UAAU;KAAC;IAEjD,OAAO;QACL,YAAY;YACV,gBAAgB,EAAC,oBAAA,8BAAA,QAAS,UAAU;QACtC;IACF;AACF","sources":["packages/@react-aria/overlays/src/useModal.tsx"],"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 {DOMAttributes} from '@react-types/shared';\nimport React, {AriaAttributes, JSX, ReactNode, useContext, useEffect, useMemo, useState} from 'react';\nimport ReactDOM from 'react-dom';\nimport {useIsSSR} from '@react-aria/ssr';\nimport {useUNSAFE_PortalContext} from './PortalProvider';\n\nexport interface ModalProviderProps extends DOMAttributes {\n children: ReactNode\n}\n\ninterface ModalContext {\n parent: ModalContext | null,\n modalCount: number,\n addModal: () => void,\n removeModal: () => void\n}\n\nconst Context = React.createContext<ModalContext | null>(null);\n\n/**\n * Each ModalProvider tracks how many modals are open in its subtree. On mount, the modals\n * trigger `addModal` to increment the count, and trigger `removeModal` on unmount to decrement it.\n * This is done recursively so that all parent providers are incremented and decremented.\n * If the modal count is greater than zero, we add `aria-hidden` to this provider to hide its\n * subtree from screen readers. This is done using React context in order to account for things\n * like portals, which can cause the React tree and the DOM tree to differ significantly in structure.\n */\nexport function ModalProvider(props: ModalProviderProps): JSX.Element {\n let {children} = props;\n let parent = useContext(Context);\n let [modalCount, setModalCount] = useState(0);\n let context = useMemo(() => ({\n parent,\n modalCount,\n addModal() {\n setModalCount(count => count + 1);\n if (parent) {\n parent.addModal();\n }\n },\n removeModal() {\n setModalCount(count => count - 1);\n if (parent) {\n parent.removeModal();\n }\n }\n }), [parent, modalCount]);\n\n return (\n <Context.Provider value={context}>\n {children}\n </Context.Provider>\n );\n}\n\nexport interface ModalProviderAria {\n /**\n * Props to be spread on the container element.\n */\n modalProviderProps: AriaAttributes\n}\n\n/**\n * Used to determine if the tree should be aria-hidden based on how many\n * modals are open.\n */\nexport function useModalProvider(): ModalProviderAria {\n let context = useContext(Context);\n return {\n modalProviderProps: {\n 'aria-hidden': context && context.modalCount > 0 ? true : undefined\n }\n };\n}\n\n/**\n * Creates a root node that will be aria-hidden if there are other modals open.\n */\nfunction OverlayContainerDOM(props: ModalProviderProps) {\n let {modalProviderProps} = useModalProvider();\n return <div data-overlay-container {...props} {...modalProviderProps} />;\n}\n\n/**\n * An OverlayProvider acts as a container for the top-level application.\n * Any application that uses modal dialogs or other overlays should\n * be wrapped in a `<OverlayProvider>`. This is used to ensure that\n * the main content of the application is hidden from screen readers\n * if a modal or other overlay is opened. Only the top-most modal or\n * overlay should be accessible at once.\n */\nexport function OverlayProvider(props: ModalProviderProps): JSX.Element {\n return (\n <ModalProvider>\n <OverlayContainerDOM {...props} />\n </ModalProvider>\n );\n}\n\nexport interface OverlayContainerProps extends ModalProviderProps {\n /**\n * The container element in which the overlay portal will be placed.\n * @default document.body\n * @deprecated - Use a parent UNSAFE_PortalProvider to set your portal container instead.\n */\n portalContainer?: Element\n}\n\n/**\n * A container for overlays like modals and popovers. Renders the overlay\n * into a Portal which is placed at the end of the document body.\n * Also ensures that the overlay is hidden from screen readers if a\n * nested modal is opened. Only the top-most modal or overlay should\n * be accessible at once.\n */\nexport function OverlayContainer(props: OverlayContainerProps): React.ReactPortal | null {\n let isSSR = useIsSSR();\n let {portalContainer = isSSR ? null : document.body, ...rest} = props;\n let {getContainer} = useUNSAFE_PortalContext();\n if (!props.portalContainer && getContainer) {\n portalContainer = getContainer();\n }\n\n React.useEffect(() => {\n if (portalContainer?.closest('[data-overlay-container]')) {\n throw new Error('An OverlayContainer must not be inside another container. Please change the portalContainer prop.');\n }\n }, [portalContainer]);\n\n if (!portalContainer) {\n return null;\n }\n\n let contents = <OverlayProvider {...rest} />;\n return ReactDOM.createPortal(contents, portalContainer);\n}\n\ninterface ModalAriaProps extends DOMAttributes {\n /** Data attribute marks the dom node as a modal for the aria-modal-polyfill. */\n 'data-ismodal': boolean\n}\n\nexport interface AriaModalOptions {\n isDisabled?: boolean\n}\n\nexport interface ModalAria {\n /** Props for the modal content element. */\n modalProps: ModalAriaProps\n}\n\n/**\n * Hides content outside the current `<OverlayContainer>` from screen readers\n * on mount and restores it on unmount. Typically used by modal dialogs and\n * other types of overlays to ensure that only the top-most modal is\n * accessible at once.\n */\nexport function useModal(options?: AriaModalOptions): ModalAria {\n // Add aria-hidden to all parent providers on mount, and restore on unmount.\n let context = useContext(Context);\n if (!context) {\n throw new Error('Modal is not contained within a provider');\n }\n\n useEffect(() => {\n if (options?.isDisabled || !context || !context.parent) {\n return;\n }\n\n // The immediate context is from the provider containing this modal, so we only\n // want to trigger aria-hidden on its parents not on the modal provider itself.\n context.parent.addModal();\n return () => {\n if (context && context.parent) {\n context.parent.removeModal();\n }\n };\n }, [context, context.parent, options?.isDisabled]);\n\n return {\n modalProps: {\n 'data-ismodal': !options?.isDisabled\n }\n };\n}\n"],"names":[],"version":3,"file":"useModal.main.js.map"}
|
package/dist/useModal.mjs
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import {useUNSAFE_PortalContext as $96b38030c423d352$export$9fc1347d4195ccb3} from "./PortalProvider.mjs";
|
|
2
|
-
import $4AOtR$react, {useContext as $4AOtR$useContext, useState as $4AOtR$useState, useMemo as $4AOtR$useMemo, useEffect as $4AOtR$useEffect} from "react";
|
|
3
|
-
import $4AOtR$reactdom from "react-dom";
|
|
4
|
-
import {useIsSSR as $4AOtR$useIsSSR} from "@react-aria/ssr";
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
8
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
9
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
10
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
13
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
14
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
15
|
-
* governing permissions and limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const $f57aed4a881a3485$var$Context = /*#__PURE__*/ (0, $4AOtR$react).createContext(null);
|
|
21
|
-
function $f57aed4a881a3485$export$178405afcd8c5eb(props) {
|
|
22
|
-
let { children: children } = props;
|
|
23
|
-
let parent = (0, $4AOtR$useContext)($f57aed4a881a3485$var$Context);
|
|
24
|
-
let [modalCount, setModalCount] = (0, $4AOtR$useState)(0);
|
|
25
|
-
let context = (0, $4AOtR$useMemo)(()=>({
|
|
26
|
-
parent: parent,
|
|
27
|
-
modalCount: modalCount,
|
|
28
|
-
addModal () {
|
|
29
|
-
setModalCount((count)=>count + 1);
|
|
30
|
-
if (parent) parent.addModal();
|
|
31
|
-
},
|
|
32
|
-
removeModal () {
|
|
33
|
-
setModalCount((count)=>count - 1);
|
|
34
|
-
if (parent) parent.removeModal();
|
|
35
|
-
}
|
|
36
|
-
}), [
|
|
37
|
-
parent,
|
|
38
|
-
modalCount
|
|
39
|
-
]);
|
|
40
|
-
return /*#__PURE__*/ (0, $4AOtR$react).createElement($f57aed4a881a3485$var$Context.Provider, {
|
|
41
|
-
value: context
|
|
42
|
-
}, children);
|
|
43
|
-
}
|
|
44
|
-
function $f57aed4a881a3485$export$d9aaed4c3ece1bc0() {
|
|
45
|
-
let context = (0, $4AOtR$useContext)($f57aed4a881a3485$var$Context);
|
|
46
|
-
return {
|
|
47
|
-
modalProviderProps: {
|
|
48
|
-
'aria-hidden': context && context.modalCount > 0 ? true : undefined
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Creates a root node that will be aria-hidden if there are other modals open.
|
|
54
|
-
*/ function $f57aed4a881a3485$var$OverlayContainerDOM(props) {
|
|
55
|
-
let { modalProviderProps: modalProviderProps } = $f57aed4a881a3485$export$d9aaed4c3ece1bc0();
|
|
56
|
-
return /*#__PURE__*/ (0, $4AOtR$react).createElement("div", {
|
|
57
|
-
"data-overlay-container": true,
|
|
58
|
-
...props,
|
|
59
|
-
...modalProviderProps
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function $f57aed4a881a3485$export$bf688221f59024e5(props) {
|
|
63
|
-
return /*#__PURE__*/ (0, $4AOtR$react).createElement($f57aed4a881a3485$export$178405afcd8c5eb, null, /*#__PURE__*/ (0, $4AOtR$react).createElement($f57aed4a881a3485$var$OverlayContainerDOM, props));
|
|
64
|
-
}
|
|
65
|
-
function $f57aed4a881a3485$export$b47c3594eab58386(props) {
|
|
66
|
-
let isSSR = (0, $4AOtR$useIsSSR)();
|
|
67
|
-
let { portalContainer: portalContainer = isSSR ? null : document.body, ...rest } = props;
|
|
68
|
-
let { getContainer: getContainer } = (0, $96b38030c423d352$export$9fc1347d4195ccb3)();
|
|
69
|
-
if (!props.portalContainer && getContainer) portalContainer = getContainer();
|
|
70
|
-
(0, $4AOtR$react).useEffect(()=>{
|
|
71
|
-
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.');
|
|
72
|
-
}, [
|
|
73
|
-
portalContainer
|
|
74
|
-
]);
|
|
75
|
-
if (!portalContainer) return null;
|
|
76
|
-
let contents = /*#__PURE__*/ (0, $4AOtR$react).createElement($f57aed4a881a3485$export$bf688221f59024e5, rest);
|
|
77
|
-
return /*#__PURE__*/ (0, $4AOtR$reactdom).createPortal(contents, portalContainer);
|
|
78
|
-
}
|
|
79
|
-
function $f57aed4a881a3485$export$33ffd74ebf07f060(options) {
|
|
80
|
-
// Add aria-hidden to all parent providers on mount, and restore on unmount.
|
|
81
|
-
let context = (0, $4AOtR$useContext)($f57aed4a881a3485$var$Context);
|
|
82
|
-
if (!context) throw new Error('Modal is not contained within a provider');
|
|
83
|
-
(0, $4AOtR$useEffect)(()=>{
|
|
84
|
-
if ((options === null || options === void 0 ? void 0 : options.isDisabled) || !context || !context.parent) return;
|
|
85
|
-
// The immediate context is from the provider containing this modal, so we only
|
|
86
|
-
// want to trigger aria-hidden on its parents not on the modal provider itself.
|
|
87
|
-
context.parent.addModal();
|
|
88
|
-
return ()=>{
|
|
89
|
-
if (context && context.parent) context.parent.removeModal();
|
|
90
|
-
};
|
|
91
|
-
}, [
|
|
92
|
-
context,
|
|
93
|
-
context.parent,
|
|
94
|
-
options === null || options === void 0 ? void 0 : options.isDisabled
|
|
95
|
-
]);
|
|
96
|
-
return {
|
|
97
|
-
modalProps: {
|
|
98
|
-
'data-ismodal': !(options === null || options === void 0 ? void 0 : options.isDisabled)
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
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};
|
|
105
|
-
//# sourceMappingURL=useModal.module.js.map
|
package/dist/useModal.module.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import {useUNSAFE_PortalContext as $96b38030c423d352$export$9fc1347d4195ccb3} from "./PortalProvider.module.js";
|
|
2
|
-
import $4AOtR$react, {useContext as $4AOtR$useContext, useState as $4AOtR$useState, useMemo as $4AOtR$useMemo, useEffect as $4AOtR$useEffect} from "react";
|
|
3
|
-
import $4AOtR$reactdom from "react-dom";
|
|
4
|
-
import {useIsSSR as $4AOtR$useIsSSR} from "@react-aria/ssr";
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
8
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
9
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
10
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
13
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
14
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
15
|
-
* governing permissions and limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const $f57aed4a881a3485$var$Context = /*#__PURE__*/ (0, $4AOtR$react).createContext(null);
|
|
21
|
-
function $f57aed4a881a3485$export$178405afcd8c5eb(props) {
|
|
22
|
-
let { children: children } = props;
|
|
23
|
-
let parent = (0, $4AOtR$useContext)($f57aed4a881a3485$var$Context);
|
|
24
|
-
let [modalCount, setModalCount] = (0, $4AOtR$useState)(0);
|
|
25
|
-
let context = (0, $4AOtR$useMemo)(()=>({
|
|
26
|
-
parent: parent,
|
|
27
|
-
modalCount: modalCount,
|
|
28
|
-
addModal () {
|
|
29
|
-
setModalCount((count)=>count + 1);
|
|
30
|
-
if (parent) parent.addModal();
|
|
31
|
-
},
|
|
32
|
-
removeModal () {
|
|
33
|
-
setModalCount((count)=>count - 1);
|
|
34
|
-
if (parent) parent.removeModal();
|
|
35
|
-
}
|
|
36
|
-
}), [
|
|
37
|
-
parent,
|
|
38
|
-
modalCount
|
|
39
|
-
]);
|
|
40
|
-
return /*#__PURE__*/ (0, $4AOtR$react).createElement($f57aed4a881a3485$var$Context.Provider, {
|
|
41
|
-
value: context
|
|
42
|
-
}, children);
|
|
43
|
-
}
|
|
44
|
-
function $f57aed4a881a3485$export$d9aaed4c3ece1bc0() {
|
|
45
|
-
let context = (0, $4AOtR$useContext)($f57aed4a881a3485$var$Context);
|
|
46
|
-
return {
|
|
47
|
-
modalProviderProps: {
|
|
48
|
-
'aria-hidden': context && context.modalCount > 0 ? true : undefined
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Creates a root node that will be aria-hidden if there are other modals open.
|
|
54
|
-
*/ function $f57aed4a881a3485$var$OverlayContainerDOM(props) {
|
|
55
|
-
let { modalProviderProps: modalProviderProps } = $f57aed4a881a3485$export$d9aaed4c3ece1bc0();
|
|
56
|
-
return /*#__PURE__*/ (0, $4AOtR$react).createElement("div", {
|
|
57
|
-
"data-overlay-container": true,
|
|
58
|
-
...props,
|
|
59
|
-
...modalProviderProps
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function $f57aed4a881a3485$export$bf688221f59024e5(props) {
|
|
63
|
-
return /*#__PURE__*/ (0, $4AOtR$react).createElement($f57aed4a881a3485$export$178405afcd8c5eb, null, /*#__PURE__*/ (0, $4AOtR$react).createElement($f57aed4a881a3485$var$OverlayContainerDOM, props));
|
|
64
|
-
}
|
|
65
|
-
function $f57aed4a881a3485$export$b47c3594eab58386(props) {
|
|
66
|
-
let isSSR = (0, $4AOtR$useIsSSR)();
|
|
67
|
-
let { portalContainer: portalContainer = isSSR ? null : document.body, ...rest } = props;
|
|
68
|
-
let { getContainer: getContainer } = (0, $96b38030c423d352$export$9fc1347d4195ccb3)();
|
|
69
|
-
if (!props.portalContainer && getContainer) portalContainer = getContainer();
|
|
70
|
-
(0, $4AOtR$react).useEffect(()=>{
|
|
71
|
-
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.');
|
|
72
|
-
}, [
|
|
73
|
-
portalContainer
|
|
74
|
-
]);
|
|
75
|
-
if (!portalContainer) return null;
|
|
76
|
-
let contents = /*#__PURE__*/ (0, $4AOtR$react).createElement($f57aed4a881a3485$export$bf688221f59024e5, rest);
|
|
77
|
-
return /*#__PURE__*/ (0, $4AOtR$reactdom).createPortal(contents, portalContainer);
|
|
78
|
-
}
|
|
79
|
-
function $f57aed4a881a3485$export$33ffd74ebf07f060(options) {
|
|
80
|
-
// Add aria-hidden to all parent providers on mount, and restore on unmount.
|
|
81
|
-
let context = (0, $4AOtR$useContext)($f57aed4a881a3485$var$Context);
|
|
82
|
-
if (!context) throw new Error('Modal is not contained within a provider');
|
|
83
|
-
(0, $4AOtR$useEffect)(()=>{
|
|
84
|
-
if ((options === null || options === void 0 ? void 0 : options.isDisabled) || !context || !context.parent) return;
|
|
85
|
-
// The immediate context is from the provider containing this modal, so we only
|
|
86
|
-
// want to trigger aria-hidden on its parents not on the modal provider itself.
|
|
87
|
-
context.parent.addModal();
|
|
88
|
-
return ()=>{
|
|
89
|
-
if (context && context.parent) context.parent.removeModal();
|
|
90
|
-
};
|
|
91
|
-
}, [
|
|
92
|
-
context,
|
|
93
|
-
context.parent,
|
|
94
|
-
options === null || options === void 0 ? void 0 : options.isDisabled
|
|
95
|
-
]);
|
|
96
|
-
return {
|
|
97
|
-
modalProps: {
|
|
98
|
-
'data-ismodal': !(options === null || options === void 0 ? void 0 : options.isDisabled)
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
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};
|
|
105
|
-
//# sourceMappingURL=useModal.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAmBD,MAAM,8CAAU,CAAA,GAAA,YAAI,EAAE,aAAa,CAAsB;AAUlD,SAAS,yCAAc,KAAyB;IACrD,IAAI,YAAC,QAAQ,EAAC,GAAG;IACjB,IAAI,SAAS,CAAA,GAAA,iBAAS,EAAE;IACxB,IAAI,CAAC,YAAY,cAAc,GAAG,CAAA,GAAA,eAAO,EAAE;IAC3C,IAAI,UAAU,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;oBAC3B;wBACA;YACA;gBACE,cAAc,CAAA,QAAS,QAAQ;gBAC/B,IAAI,QACF,OAAO,QAAQ;YAEnB;YACA;gBACE,cAAc,CAAA,QAAS,QAAQ;gBAC/B,IAAI,QACF,OAAO,WAAW;YAEtB;QACF,CAAA,GAAI;QAAC;QAAQ;KAAW;IAExB,qBACE,gCAAC,8BAAQ,QAAQ;QAAC,OAAO;OACtB;AAGP;AAaO,SAAS;IACd,IAAI,UAAU,CAAA,GAAA,iBAAS,EAAE;IACzB,OAAO;QACL,oBAAoB;YAClB,eAAe,WAAW,QAAQ,UAAU,GAAG,IAAI,OAAO;QAC5D;IACF;AACF;AAEA;;CAEC,GACD,SAAS,0CAAoB,KAAyB;IACpD,IAAI,sBAAC,kBAAkB,EAAC,GAAG;IAC3B,qBAAO,gCAAC;QAAI,0BAAA;QAAwB,GAAG,KAAK;QAAG,GAAG,kBAAkB;;AACtE;AAUO,SAAS,0CAAgB,KAAyB;IACvD,qBACE,gCAAC,8DACC,gCAAC,2CAAwB;AAG/B;AAkBO,SAAS,0CAAiB,KAA4B;IAC3D,IAAI,QAAQ,CAAA,GAAA,eAAO;IACnB,IAAI,mBAAC,kBAAkB,QAAQ,OAAO,SAAS,IAAI,EAAE,GAAG,MAAK,GAAG;IAChE,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,yCAAsB;IAC3C,IAAI,CAAC,MAAM,eAAe,IAAI,cAC5B,kBAAkB;IAGpB,CAAA,GAAA,YAAI,EAAE,SAAS,CAAC;QACd,IAAI,4BAAA,sCAAA,gBAAiB,OAAO,CAAC,6BAC3B,MAAM,IAAI,MAAM;IAEpB,GAAG;QAAC;KAAgB;IAEpB,IAAI,CAAC,iBACH,OAAO;IAGT,IAAI,yBAAW,gCAAC,2CAAoB;IACpC,qBAAO,CAAA,GAAA,eAAO,EAAE,YAAY,CAAC,UAAU;AACzC;AAsBO,SAAS,0CAAS,OAA0B;IACjD,4EAA4E;IAC5E,IAAI,UAAU,CAAA,GAAA,iBAAS,EAAE;IACzB,IAAI,CAAC,SACH,MAAM,IAAI,MAAM;IAGlB,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,CAAA,oBAAA,8BAAA,QAAS,UAAU,KAAI,CAAC,WAAW,CAAC,QAAQ,MAAM,EACpD;QAGF,+EAA+E;QAC/E,+EAA+E;QAC/E,QAAQ,MAAM,CAAC,QAAQ;QACvB,OAAO;YACL,IAAI,WAAW,QAAQ,MAAM,EAC3B,QAAQ,MAAM,CAAC,WAAW;QAE9B;IACF,GAAG;QAAC;QAAS,QAAQ,MAAM;QAAE,oBAAA,8BAAA,QAAS,UAAU;KAAC;IAEjD,OAAO;QACL,YAAY;YACV,gBAAgB,EAAC,oBAAA,8BAAA,QAAS,UAAU;QACtC;IACF;AACF","sources":["packages/@react-aria/overlays/src/useModal.tsx"],"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 {DOMAttributes} from '@react-types/shared';\nimport React, {AriaAttributes, JSX, ReactNode, useContext, useEffect, useMemo, useState} from 'react';\nimport ReactDOM from 'react-dom';\nimport {useIsSSR} from '@react-aria/ssr';\nimport {useUNSAFE_PortalContext} from './PortalProvider';\n\nexport interface ModalProviderProps extends DOMAttributes {\n children: ReactNode\n}\n\ninterface ModalContext {\n parent: ModalContext | null,\n modalCount: number,\n addModal: () => void,\n removeModal: () => void\n}\n\nconst Context = React.createContext<ModalContext | null>(null);\n\n/**\n * Each ModalProvider tracks how many modals are open in its subtree. On mount, the modals\n * trigger `addModal` to increment the count, and trigger `removeModal` on unmount to decrement it.\n * This is done recursively so that all parent providers are incremented and decremented.\n * If the modal count is greater than zero, we add `aria-hidden` to this provider to hide its\n * subtree from screen readers. This is done using React context in order to account for things\n * like portals, which can cause the React tree and the DOM tree to differ significantly in structure.\n */\nexport function ModalProvider(props: ModalProviderProps): JSX.Element {\n let {children} = props;\n let parent = useContext(Context);\n let [modalCount, setModalCount] = useState(0);\n let context = useMemo(() => ({\n parent,\n modalCount,\n addModal() {\n setModalCount(count => count + 1);\n if (parent) {\n parent.addModal();\n }\n },\n removeModal() {\n setModalCount(count => count - 1);\n if (parent) {\n parent.removeModal();\n }\n }\n }), [parent, modalCount]);\n\n return (\n <Context.Provider value={context}>\n {children}\n </Context.Provider>\n );\n}\n\nexport interface ModalProviderAria {\n /**\n * Props to be spread on the container element.\n */\n modalProviderProps: AriaAttributes\n}\n\n/**\n * Used to determine if the tree should be aria-hidden based on how many\n * modals are open.\n */\nexport function useModalProvider(): ModalProviderAria {\n let context = useContext(Context);\n return {\n modalProviderProps: {\n 'aria-hidden': context && context.modalCount > 0 ? true : undefined\n }\n };\n}\n\n/**\n * Creates a root node that will be aria-hidden if there are other modals open.\n */\nfunction OverlayContainerDOM(props: ModalProviderProps) {\n let {modalProviderProps} = useModalProvider();\n return <div data-overlay-container {...props} {...modalProviderProps} />;\n}\n\n/**\n * An OverlayProvider acts as a container for the top-level application.\n * Any application that uses modal dialogs or other overlays should\n * be wrapped in a `<OverlayProvider>`. This is used to ensure that\n * the main content of the application is hidden from screen readers\n * if a modal or other overlay is opened. Only the top-most modal or\n * overlay should be accessible at once.\n */\nexport function OverlayProvider(props: ModalProviderProps): JSX.Element {\n return (\n <ModalProvider>\n <OverlayContainerDOM {...props} />\n </ModalProvider>\n );\n}\n\nexport interface OverlayContainerProps extends ModalProviderProps {\n /**\n * The container element in which the overlay portal will be placed.\n * @default document.body\n * @deprecated - Use a parent UNSAFE_PortalProvider to set your portal container instead.\n */\n portalContainer?: Element\n}\n\n/**\n * A container for overlays like modals and popovers. Renders the overlay\n * into a Portal which is placed at the end of the document body.\n * Also ensures that the overlay is hidden from screen readers if a\n * nested modal is opened. Only the top-most modal or overlay should\n * be accessible at once.\n */\nexport function OverlayContainer(props: OverlayContainerProps): React.ReactPortal | null {\n let isSSR = useIsSSR();\n let {portalContainer = isSSR ? null : document.body, ...rest} = props;\n let {getContainer} = useUNSAFE_PortalContext();\n if (!props.portalContainer && getContainer) {\n portalContainer = getContainer();\n }\n\n React.useEffect(() => {\n if (portalContainer?.closest('[data-overlay-container]')) {\n throw new Error('An OverlayContainer must not be inside another container. Please change the portalContainer prop.');\n }\n }, [portalContainer]);\n\n if (!portalContainer) {\n return null;\n }\n\n let contents = <OverlayProvider {...rest} />;\n return ReactDOM.createPortal(contents, portalContainer);\n}\n\ninterface ModalAriaProps extends DOMAttributes {\n /** Data attribute marks the dom node as a modal for the aria-modal-polyfill. */\n 'data-ismodal': boolean\n}\n\nexport interface AriaModalOptions {\n isDisabled?: boolean\n}\n\nexport interface ModalAria {\n /** Props for the modal content element. */\n modalProps: ModalAriaProps\n}\n\n/**\n * Hides content outside the current `<OverlayContainer>` from screen readers\n * on mount and restores it on unmount. Typically used by modal dialogs and\n * other types of overlays to ensure that only the top-most modal is\n * accessible at once.\n */\nexport function useModal(options?: AriaModalOptions): ModalAria {\n // Add aria-hidden to all parent providers on mount, and restore on unmount.\n let context = useContext(Context);\n if (!context) {\n throw new Error('Modal is not contained within a provider');\n }\n\n useEffect(() => {\n if (options?.isDisabled || !context || !context.parent) {\n return;\n }\n\n // The immediate context is from the provider containing this modal, so we only\n // want to trigger aria-hidden on its parents not on the modal provider itself.\n context.parent.addModal();\n return () => {\n if (context && context.parent) {\n context.parent.removeModal();\n }\n };\n }, [context, context.parent, options?.isDisabled]);\n\n return {\n modalProps: {\n 'data-ismodal': !options?.isDisabled\n }\n };\n}\n"],"names":[],"version":3,"file":"useModal.module.js.map"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
var $08ef1685902b6011$exports = require("./ariaHideOutside.main.js");
|
|
2
|
-
var $82711f9cb668ecdb$exports = require("./useOverlay.main.js");
|
|
3
|
-
var $745edbb83ab4296f$exports = require("./Overlay.main.js");
|
|
4
|
-
var $5c2f5cd01815d369$exports = require("./usePreventScroll.main.js");
|
|
5
|
-
var $9ziDi$reactariautils = require("@react-aria/utils");
|
|
6
|
-
var $9ziDi$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, "useModalOverlay", () => $11b7e0b04b421e95$export$dbc0f175b25fb0fb);
|
|
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 $11b7e0b04b421e95$export$dbc0f175b25fb0fb(props, state, ref) {
|
|
31
|
-
let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $82711f9cb668ecdb$exports.useOverlay)({
|
|
32
|
-
...props,
|
|
33
|
-
isOpen: state.isOpen,
|
|
34
|
-
onClose: state.close
|
|
35
|
-
}, ref);
|
|
36
|
-
(0, $5c2f5cd01815d369$exports.usePreventScroll)({
|
|
37
|
-
isDisabled: !state.isOpen
|
|
38
|
-
});
|
|
39
|
-
(0, $745edbb83ab4296f$exports.useOverlayFocusContain)();
|
|
40
|
-
(0, $9ziDi$react.useEffect)(()=>{
|
|
41
|
-
if (state.isOpen && ref.current) return (0, $08ef1685902b6011$exports.ariaHideOutside)([
|
|
42
|
-
ref.current
|
|
43
|
-
], {
|
|
44
|
-
shouldUseInert: true
|
|
45
|
-
});
|
|
46
|
-
}, [
|
|
47
|
-
state.isOpen,
|
|
48
|
-
ref
|
|
49
|
-
]);
|
|
50
|
-
return {
|
|
51
|
-
modalProps: (0, $9ziDi$reactariautils.mergeProps)(overlayProps),
|
|
52
|
-
underlayProps: underlayProps
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
//# sourceMappingURL=useModalOverlay.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAmCM,SAAS,0CAAgB,KAA4B,EAAE,KAA0B,EAAE,GAAkC;IAC1H,IAAI,gBAAC,YAAY,iBAAE,aAAa,EAAC,GAAG,CAAA,GAAA,oCAAS,EAAE;QAC7C,GAAG,KAAK;QACR,QAAQ,MAAM,MAAM;QACpB,SAAS,MAAM,KAAK;IACtB,GAAG;IAEH,CAAA,GAAA,0CAAe,EAAE;QACf,YAAY,CAAC,MAAM,MAAM;IAC3B;IAEA,CAAA,GAAA,gDAAqB;IAErB,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,MAAM,MAAM,IAAI,IAAI,OAAO,EAC7B,OAAO,CAAA,GAAA,yCAAc,EAAE;YAAC,IAAI,OAAO;SAAC,EAAE;YAAC,gBAAgB;QAAI;IAE/D,GAAG;QAAC,MAAM,MAAM;QAAE;KAAI;IAEtB,OAAO;QACL,YAAY,CAAA,GAAA,gCAAS,EAAE;uBACvB;IACF;AACF","sources":["packages/@react-aria/overlays/src/useModalOverlay.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ariaHideOutside} from './ariaHideOutside';\nimport {AriaOverlayProps, useOverlay} from './useOverlay';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport {OverlayTriggerState} from '@react-stately/overlays';\nimport {useEffect} from 'react';\nimport {useOverlayFocusContain} from './Overlay';\nimport {usePreventScroll} from './usePreventScroll';\n\nexport interface AriaModalOverlayProps extends Pick<AriaOverlayProps, 'shouldCloseOnInteractOutside'> {\n /**\n * Whether to close the modal when the user interacts outside it.\n * @default false\n */\n isDismissable?: boolean,\n /**\n * Whether pressing the escape key to close the modal should be disabled.\n * @default false\n */\n isKeyboardDismissDisabled?: boolean\n}\n\nexport interface ModalOverlayAria {\n /** Props for the modal element. */\n modalProps: DOMAttributes,\n /** Props for the underlay element. */\n underlayProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a modal component.\n * A modal is an overlay element which blocks interaction with elements outside it.\n */\nexport function useModalOverlay(props: AriaModalOverlayProps, state: OverlayTriggerState, ref: RefObject<HTMLElement | null>): ModalOverlayAria {\n let {overlayProps, underlayProps} = useOverlay({\n ...props,\n isOpen: state.isOpen,\n onClose: state.close\n }, ref);\n\n usePreventScroll({\n isDisabled: !state.isOpen\n });\n\n useOverlayFocusContain();\n\n useEffect(() => {\n if (state.isOpen && ref.current) {\n return ariaHideOutside([ref.current], {shouldUseInert: true});\n }\n }, [state.isOpen, ref]);\n\n return {\n modalProps: mergeProps(overlayProps),\n underlayProps\n };\n}\n"],"names":[],"version":3,"file":"useModalOverlay.main.js.map"}
|
package/dist/useModalOverlay.mjs
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import {ariaHideOutside as $5e3802645cc19319$export$1c3ebcada18427bf} from "./ariaHideOutside.mjs";
|
|
2
|
-
import {useOverlay as $a11501f3d1d39e6c$export$ea8f71083e90600f} from "./useOverlay.mjs";
|
|
3
|
-
import {useOverlayFocusContain as $337b884510726a0d$export$14c98a7594375490} from "./Overlay.mjs";
|
|
4
|
-
import {usePreventScroll as $49c51c25361d4cd2$export$ee0f7cc6afcd1c18} from "./usePreventScroll.mjs";
|
|
5
|
-
import {mergeProps as $7Dhkr$mergeProps} from "@react-aria/utils";
|
|
6
|
-
import {useEffect as $7Dhkr$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 $8ac8429251c45e4b$export$dbc0f175b25fb0fb(props, state, ref) {
|
|
25
|
-
let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $a11501f3d1d39e6c$export$ea8f71083e90600f)({
|
|
26
|
-
...props,
|
|
27
|
-
isOpen: state.isOpen,
|
|
28
|
-
onClose: state.close
|
|
29
|
-
}, ref);
|
|
30
|
-
(0, $49c51c25361d4cd2$export$ee0f7cc6afcd1c18)({
|
|
31
|
-
isDisabled: !state.isOpen
|
|
32
|
-
});
|
|
33
|
-
(0, $337b884510726a0d$export$14c98a7594375490)();
|
|
34
|
-
(0, $7Dhkr$useEffect)(()=>{
|
|
35
|
-
if (state.isOpen && ref.current) return (0, $5e3802645cc19319$export$1c3ebcada18427bf)([
|
|
36
|
-
ref.current
|
|
37
|
-
], {
|
|
38
|
-
shouldUseInert: true
|
|
39
|
-
});
|
|
40
|
-
}, [
|
|
41
|
-
state.isOpen,
|
|
42
|
-
ref
|
|
43
|
-
]);
|
|
44
|
-
return {
|
|
45
|
-
modalProps: (0, $7Dhkr$mergeProps)(overlayProps),
|
|
46
|
-
underlayProps: underlayProps
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export {$8ac8429251c45e4b$export$dbc0f175b25fb0fb as useModalOverlay};
|
|
52
|
-
//# sourceMappingURL=useModalOverlay.module.js.map
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import {ariaHideOutside as $5e3802645cc19319$export$1c3ebcada18427bf} from "./ariaHideOutside.module.js";
|
|
2
|
-
import {useOverlay as $a11501f3d1d39e6c$export$ea8f71083e90600f} from "./useOverlay.module.js";
|
|
3
|
-
import {useOverlayFocusContain as $337b884510726a0d$export$14c98a7594375490} from "./Overlay.module.js";
|
|
4
|
-
import {usePreventScroll as $49c51c25361d4cd2$export$ee0f7cc6afcd1c18} from "./usePreventScroll.module.js";
|
|
5
|
-
import {mergeProps as $7Dhkr$mergeProps} from "@react-aria/utils";
|
|
6
|
-
import {useEffect as $7Dhkr$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 $8ac8429251c45e4b$export$dbc0f175b25fb0fb(props, state, ref) {
|
|
25
|
-
let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $a11501f3d1d39e6c$export$ea8f71083e90600f)({
|
|
26
|
-
...props,
|
|
27
|
-
isOpen: state.isOpen,
|
|
28
|
-
onClose: state.close
|
|
29
|
-
}, ref);
|
|
30
|
-
(0, $49c51c25361d4cd2$export$ee0f7cc6afcd1c18)({
|
|
31
|
-
isDisabled: !state.isOpen
|
|
32
|
-
});
|
|
33
|
-
(0, $337b884510726a0d$export$14c98a7594375490)();
|
|
34
|
-
(0, $7Dhkr$useEffect)(()=>{
|
|
35
|
-
if (state.isOpen && ref.current) return (0, $5e3802645cc19319$export$1c3ebcada18427bf)([
|
|
36
|
-
ref.current
|
|
37
|
-
], {
|
|
38
|
-
shouldUseInert: true
|
|
39
|
-
});
|
|
40
|
-
}, [
|
|
41
|
-
state.isOpen,
|
|
42
|
-
ref
|
|
43
|
-
]);
|
|
44
|
-
return {
|
|
45
|
-
modalProps: (0, $7Dhkr$mergeProps)(overlayProps),
|
|
46
|
-
underlayProps: underlayProps
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export {$8ac8429251c45e4b$export$dbc0f175b25fb0fb as useModalOverlay};
|
|
52
|
-
//# sourceMappingURL=useModalOverlay.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAmCM,SAAS,0CAAgB,KAA4B,EAAE,KAA0B,EAAE,GAAkC;IAC1H,IAAI,gBAAC,YAAY,iBAAE,aAAa,EAAC,GAAG,CAAA,GAAA,yCAAS,EAAE;QAC7C,GAAG,KAAK;QACR,QAAQ,MAAM,MAAM;QACpB,SAAS,MAAM,KAAK;IACtB,GAAG;IAEH,CAAA,GAAA,yCAAe,EAAE;QACf,YAAY,CAAC,MAAM,MAAM;IAC3B;IAEA,CAAA,GAAA,yCAAqB;IAErB,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,MAAM,MAAM,IAAI,IAAI,OAAO,EAC7B,OAAO,CAAA,GAAA,yCAAc,EAAE;YAAC,IAAI,OAAO;SAAC,EAAE;YAAC,gBAAgB;QAAI;IAE/D,GAAG;QAAC,MAAM,MAAM;QAAE;KAAI;IAEtB,OAAO;QACL,YAAY,CAAA,GAAA,iBAAS,EAAE;uBACvB;IACF;AACF","sources":["packages/@react-aria/overlays/src/useModalOverlay.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ariaHideOutside} from './ariaHideOutside';\nimport {AriaOverlayProps, useOverlay} from './useOverlay';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport {OverlayTriggerState} from '@react-stately/overlays';\nimport {useEffect} from 'react';\nimport {useOverlayFocusContain} from './Overlay';\nimport {usePreventScroll} from './usePreventScroll';\n\nexport interface AriaModalOverlayProps extends Pick<AriaOverlayProps, 'shouldCloseOnInteractOutside'> {\n /**\n * Whether to close the modal when the user interacts outside it.\n * @default false\n */\n isDismissable?: boolean,\n /**\n * Whether pressing the escape key to close the modal should be disabled.\n * @default false\n */\n isKeyboardDismissDisabled?: boolean\n}\n\nexport interface ModalOverlayAria {\n /** Props for the modal element. */\n modalProps: DOMAttributes,\n /** Props for the underlay element. */\n underlayProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a modal component.\n * A modal is an overlay element which blocks interaction with elements outside it.\n */\nexport function useModalOverlay(props: AriaModalOverlayProps, state: OverlayTriggerState, ref: RefObject<HTMLElement | null>): ModalOverlayAria {\n let {overlayProps, underlayProps} = useOverlay({\n ...props,\n isOpen: state.isOpen,\n onClose: state.close\n }, ref);\n\n usePreventScroll({\n isDisabled: !state.isOpen\n });\n\n useOverlayFocusContain();\n\n useEffect(() => {\n if (state.isOpen && ref.current) {\n return ariaHideOutside([ref.current], {shouldUseInert: true});\n }\n }, [state.isOpen, ref]);\n\n return {\n modalProps: mergeProps(overlayProps),\n underlayProps\n };\n}\n"],"names":[],"version":3,"file":"useModalOverlay.module.js.map"}
|