@react-aria/aria-modal-polyfill 3.6.3-nightly.3698 → 3.6.3-nightly.3705
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 +80 -0
- package/package.json +8 -3
package/dist/import.mjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {hideOthers as $hRMXz$hideOthers} from "aria-hidden";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
const $0ba7c906f8d7a5d9$var$currentDocument = typeof document !== "undefined" ? document : undefined;
|
|
15
|
+
function $0ba7c906f8d7a5d9$export$11dddb85aae73809(selector = "body", { document: document1 = $0ba7c906f8d7a5d9$var$currentDocument } = {}) {
|
|
16
|
+
/**
|
|
17
|
+
* Listen for additions to the child list of the selected element (defaults to body). This is where providers render modal portals.
|
|
18
|
+
* When one is added, see if there is a modal inside it, if there is, then hide everything else from screen readers.
|
|
19
|
+
* If there was already a modal open and a new one was added, undo everything that the previous modal had hidden and hide based on the new one.
|
|
20
|
+
*
|
|
21
|
+
* If a modal container is removed, then undo the hiding based on the last hide others. Check if there are any other modals still around, and
|
|
22
|
+
* hide based on the last one added.
|
|
23
|
+
*/ if (!document1) return ()=>{};
|
|
24
|
+
let target = document1.querySelector(selector);
|
|
25
|
+
if (!target) return ()=>{};
|
|
26
|
+
let config = {
|
|
27
|
+
childList: true
|
|
28
|
+
};
|
|
29
|
+
let modalContainers = [];
|
|
30
|
+
let undo;
|
|
31
|
+
let observer = new MutationObserver((mutationRecord)=>{
|
|
32
|
+
const liveAnnouncer = document1.querySelector('[data-live-announcer="true"]');
|
|
33
|
+
for (let mutation of mutationRecord){
|
|
34
|
+
if (mutation.type === "childList" && mutation.addedNodes.length > 0) {
|
|
35
|
+
let addNode = Array.from(mutation.addedNodes).find((node)=>{
|
|
36
|
+
var _node_querySelector;
|
|
37
|
+
return (_node_querySelector = node.querySelector) === null || _node_querySelector === void 0 ? void 0 : _node_querySelector.call(node, '[aria-modal="true"], [data-ismodal="true"]');
|
|
38
|
+
});
|
|
39
|
+
if (addNode) {
|
|
40
|
+
modalContainers.push(addNode);
|
|
41
|
+
let modal = addNode.querySelector('[aria-modal="true"], [data-ismodal="true"]');
|
|
42
|
+
undo === null || undo === void 0 ? void 0 : undo();
|
|
43
|
+
let others = [
|
|
44
|
+
modal,
|
|
45
|
+
...liveAnnouncer ? [
|
|
46
|
+
liveAnnouncer
|
|
47
|
+
] : []
|
|
48
|
+
];
|
|
49
|
+
undo = (0, $hRMXz$hideOthers)(others);
|
|
50
|
+
}
|
|
51
|
+
} else if (mutation.type === "childList" && mutation.removedNodes.length > 0) {
|
|
52
|
+
let removedNodes = Array.from(mutation.removedNodes);
|
|
53
|
+
let nodeIndexRemove = modalContainers.findIndex((container)=>removedNodes.includes(container));
|
|
54
|
+
if (nodeIndexRemove >= 0) {
|
|
55
|
+
undo === null || undo === void 0 ? void 0 : undo();
|
|
56
|
+
modalContainers = modalContainers.filter((val, i)=>i !== nodeIndexRemove);
|
|
57
|
+
if (modalContainers.length > 0) {
|
|
58
|
+
let modal1 = modalContainers[modalContainers.length - 1].querySelector('[aria-modal="true"], [data-ismodal="true"]');
|
|
59
|
+
let others1 = [
|
|
60
|
+
modal1,
|
|
61
|
+
...liveAnnouncer ? [
|
|
62
|
+
liveAnnouncer
|
|
63
|
+
] : []
|
|
64
|
+
];
|
|
65
|
+
undo = (0, $hRMXz$hideOthers)(others1);
|
|
66
|
+
} else undo = undefined;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
observer.observe(target, config);
|
|
72
|
+
return ()=>{
|
|
73
|
+
undo === null || undo === void 0 ? void 0 : undo();
|
|
74
|
+
observer.disconnect();
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
export {$0ba7c906f8d7a5d9$export$11dddb85aae73809 as watchModals};
|
|
80
|
+
//# sourceMappingURL=module.js.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/aria-modal-polyfill",
|
|
3
|
-
"version": "3.6.3-nightly.
|
|
3
|
+
"version": "3.6.3-nightly.3705+93b3c951e",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./dist/types.d.ts",
|
|
10
|
+
"import": "./dist/import.mjs",
|
|
11
|
+
"require": "./dist/main.js"
|
|
12
|
+
},
|
|
8
13
|
"types": "dist/types.d.ts",
|
|
9
14
|
"source": "src/index.ts",
|
|
10
15
|
"files": [
|
|
@@ -17,7 +22,7 @@
|
|
|
17
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
18
23
|
},
|
|
19
24
|
"dependencies": {
|
|
20
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
25
|
+
"@react-types/shared": "3.0.0-nightly.2005+93b3c951e",
|
|
21
26
|
"@swc/helpers": "^0.4.14",
|
|
22
27
|
"aria-hidden": "^1.1.1"
|
|
23
28
|
},
|
|
@@ -27,5 +32,5 @@
|
|
|
27
32
|
"publishConfig": {
|
|
28
33
|
"access": "public"
|
|
29
34
|
},
|
|
30
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "93b3c951eb784b14183f9988f2d188b34de8f42d"
|
|
31
36
|
}
|