@react-aria/aria-modal-polyfill 3.7.13 → 3.7.15

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/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAMD,MAAM,wCAAkB,OAAO,aAAa,cAAc,WAAW;AAK9D,SAAS,0CAAY,WAAkB,MAAM,EAAE,EAAC,UAAA,YAAW,qCAAe,EAAC,GAAG,CAAC,CAAC;IACrF;;;;;;;GAOC,GACD,IAAI,CAAC,WACH,OAAO,KAAO;IAEhB,IAAI,SAAS,UAAS,aAAa,CAAC;IACpC,IAAI,CAAC,QACH,OAAO,KAAO;IAEhB,IAAI,SAAS;QAAC,WAAW;IAAI;IAC7B,IAAI,kBAAkC,EAAE;IACxC,IAAI;IAEJ,IAAI,WAAW,IAAI,iBAAiB,CAAC;QACnC,MAAM,gBAAiB,UAAS,aAAa,CAAC;QAC9C,KAAK,IAAI,YAAY,eAAgB;YACnC,IAAI,SAAS,IAAI,KAAK,eAAe,SAAS,UAAU,CAAC,MAAM,GAAG,GAAG;gBACnE,IAAI,UAAoB,MAAM,IAAI,CAAC,SAAS,UAAU,EAAE,IAAI,CAAC,CAAC;wBAAc;4BAAA,sBAAA,KAAK,aAAa,cAAlB,0CAAA,yBAAA,MAAqB;;gBACjG,IAAI,SAAS;oBACX,gBAAgB,IAAI,CAAC;oBACrB,IAAI,QAAQ,QAAQ,aAAa,CAAC;oBAClC,iBAAA,2BAAA;oBACA,IAAI,SAAS;wBAAC;2BAAW,gBAAgB;4BAAC;yBAA6B,GAAG,EAAE;qBAAC;oBAC7E,OAAO,CAAA,GAAA,4BAAS,EAAE;gBACpB;YACF,OAAO,IAAI,SAAS,IAAI,KAAK,eAAe,SAAS,YAAY,CAAC,MAAM,GAAG,GAAG;gBAC5E,IAAI,eAAe,MAAM,IAAI,CAAC,SAAS,YAAY;gBACnD,IAAI,kBAAkB,gBAAgB,SAAS,CAAC,CAAA,YAAa,aAAa,QAAQ,CAAC;gBACnF,IAAI,mBAAmB,GAAG;oBACxB,iBAAA,2BAAA;oBACA,kBAAkB,gBAAgB,MAAM,CAAC,CAAC,KAAK,IAAM,MAAM;oBAC3D,IAAI,gBAAgB,MAAM,GAAG,GAAG;wBAC9B,IAAI,QAAQ,eAAe,CAAC,gBAAgB,MAAM,GAAG,EAAE,CAAC,aAAa,CAAC;wBACtE,IAAI,SAAS;4BAAC;+BAAW,gBAAgB;gCAAC;6BAA6B,GAAG,EAAE;yBAAC;wBAC7E,OAAO,CAAA,GAAA,4BAAS,EAAE;oBACpB,OACE,OAAO;gBAEX;YACF;QACF;IACF;IACA,SAAS,OAAO,CAAC,QAAQ;IACzB,OAAO;QACL,iBAAA,2BAAA;QACA,SAAS,UAAU;IACrB;AACF","sources":["packages/@react-aria/aria-modal-polyfill/src/index.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 {hideOthers} from 'aria-hidden';\n\ntype Revert = () => void;\n\nconst currentDocument = typeof document !== 'undefined' ? document : undefined;\n\n/**\n * Acts as a polyfill for `aria-modal` by watching for added modals and hiding any surrounding DOM elements with `aria-hidden`.\n */\nexport function watchModals(selector:string = 'body', {document = currentDocument} = {}): Revert {\n /**\n * Listen for additions to the child list of the selected element (defaults to body). This is where providers render modal portals.\n * When one is added, see if there is a modal inside it, if there is, then hide everything else from screen readers.\n * 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.\n *\n * 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\n * hide based on the last one added.\n */\n if (!document) {\n return () => {};\n }\n let target = document.querySelector(selector);\n if (!target) {\n return () => {};\n }\n let config = {childList: true};\n let modalContainers: Array<Element> = [];\n let undo: Revert | undefined;\n\n let observer = new MutationObserver((mutationRecord) => {\n const liveAnnouncer = document.querySelector('[data-live-announcer=\"true\"]');\n for (let mutation of mutationRecord) {\n if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {\n let addNode: Element = (Array.from(mutation.addedNodes).find((node: any) => node.querySelector?.('[aria-modal=\"true\"], [data-ismodal=\"true\"]')) as HTMLElement);\n if (addNode) {\n modalContainers.push(addNode);\n let modal = addNode.querySelector('[aria-modal=\"true\"], [data-ismodal=\"true\"]') as HTMLElement;\n undo?.();\n let others = [modal, ... liveAnnouncer ? [liveAnnouncer as HTMLElement] : []];\n undo = hideOthers(others);\n }\n } else if (mutation.type === 'childList' && mutation.removedNodes.length > 0) {\n let removedNodes = Array.from(mutation.removedNodes);\n let nodeIndexRemove = modalContainers.findIndex(container => removedNodes.includes(container));\n if (nodeIndexRemove >= 0) {\n undo?.();\n modalContainers = modalContainers.filter((val, i) => i !== nodeIndexRemove);\n if (modalContainers.length > 0) {\n let modal = modalContainers[modalContainers.length - 1].querySelector('[aria-modal=\"true\"], [data-ismodal=\"true\"]') as HTMLElement;\n let others = [modal, ... liveAnnouncer ? [liveAnnouncer as HTMLElement] : []];\n undo = hideOthers(others);\n } else {\n undo = undefined;\n }\n }\n }\n }\n });\n observer.observe(target, config);\n return () => {\n undo?.();\n observer.disconnect();\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAMD,MAAM,wCAAkB,OAAO,aAAa,cAAc,WAAW;AAK9D,SAAS,0CAAY,WAAkB,MAAM,EAAE,EAAC,UAAA,YAAW,qCAAe,EAAwB,GAAG,CAAC,CAAC;IAC5G;;;;;;;GAOC,GACD,IAAI,CAAC,WACH,OAAO,KAAO;IAEhB,IAAI,SAAS,UAAS,aAAa,CAAC;IACpC,IAAI,CAAC,QACH,OAAO,KAAO;IAEhB,IAAI,SAAS;QAAC,WAAW;IAAI;IAC7B,IAAI,kBAAkC,EAAE;IACxC,IAAI;IAEJ,IAAI,WAAW,IAAI,iBAAiB,CAAC;QACnC,MAAM,gBAAiB,UAAS,aAAa,CAAC;QAC9C,KAAK,IAAI,YAAY,eAAgB;YACnC,IAAI,SAAS,IAAI,KAAK,eAAe,SAAS,UAAU,CAAC,MAAM,GAAG,GAAG;gBACnE,IAAI,UAAoB,MAAM,IAAI,CAAC,SAAS,UAAU,EAAE,IAAI,CAAC,CAAC;wBAAc;4BAAA,sBAAA,KAAK,aAAa,cAAlB,0CAAA,yBAAA,MAAqB;;gBACjG,IAAI,SAAS;oBACX,gBAAgB,IAAI,CAAC;oBACrB,IAAI,QAAQ,QAAQ,aAAa,CAAC;oBAClC,iBAAA,2BAAA;oBACA,IAAI,SAAS;wBAAC;2BAAW,gBAAgB;4BAAC;yBAA6B,GAAG,EAAE;qBAAC;oBAC7E,OAAO,CAAA,GAAA,4BAAS,EAAE;gBACpB;YACF,OAAO,IAAI,SAAS,IAAI,KAAK,eAAe,SAAS,YAAY,CAAC,MAAM,GAAG,GAAG;gBAC5E,IAAI,eAAe,MAAM,IAAI,CAAC,SAAS,YAAY;gBACnD,IAAI,kBAAkB,gBAAgB,SAAS,CAAC,CAAA,YAAa,aAAa,QAAQ,CAAC;gBACnF,IAAI,mBAAmB,GAAG;oBACxB,iBAAA,2BAAA;oBACA,kBAAkB,gBAAgB,MAAM,CAAC,CAAC,KAAK,IAAM,MAAM;oBAC3D,IAAI,gBAAgB,MAAM,GAAG,GAAG;wBAC9B,IAAI,QAAQ,eAAe,CAAC,gBAAgB,MAAM,GAAG,EAAE,CAAC,aAAa,CAAC;wBACtE,IAAI,SAAS;4BAAC;+BAAW,gBAAgB;gCAAC;6BAA6B,GAAG,EAAE;yBAAC;wBAC7E,OAAO,CAAA,GAAA,4BAAS,EAAE;oBACpB,OACE,OAAO;gBAEX;YACF;QACF;IACF;IACA,SAAS,OAAO,CAAC,QAAQ;IACzB,OAAO;QACL,iBAAA,2BAAA;QACA,SAAS,UAAU;IACrB;AACF","sources":["packages/@react-aria/aria-modal-polyfill/src/index.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 {hideOthers} from 'aria-hidden';\n\ntype Revert = () => void;\n\nconst currentDocument = typeof document !== 'undefined' ? document : undefined;\n\n/**\n * Acts as a polyfill for `aria-modal` by watching for added modals and hiding any surrounding DOM elements with `aria-hidden`.\n */\nexport function watchModals(selector:string = 'body', {document = currentDocument}: {document?: Document} = {}): Revert {\n /**\n * Listen for additions to the child list of the selected element (defaults to body). This is where providers render modal portals.\n * When one is added, see if there is a modal inside it, if there is, then hide everything else from screen readers.\n * 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.\n *\n * 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\n * hide based on the last one added.\n */\n if (!document) {\n return () => {};\n }\n let target = document.querySelector(selector);\n if (!target) {\n return () => {};\n }\n let config = {childList: true};\n let modalContainers: Array<Element> = [];\n let undo: Revert | undefined;\n\n let observer = new MutationObserver((mutationRecord) => {\n const liveAnnouncer = document.querySelector('[data-live-announcer=\"true\"]');\n for (let mutation of mutationRecord) {\n if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {\n let addNode: Element = (Array.from(mutation.addedNodes).find((node: any) => node.querySelector?.('[aria-modal=\"true\"], [data-ismodal=\"true\"]')) as HTMLElement);\n if (addNode) {\n modalContainers.push(addNode);\n let modal = addNode.querySelector('[aria-modal=\"true\"], [data-ismodal=\"true\"]') as HTMLElement;\n undo?.();\n let others = [modal, ... liveAnnouncer ? [liveAnnouncer as HTMLElement] : []];\n undo = hideOthers(others);\n }\n } else if (mutation.type === 'childList' && mutation.removedNodes.length > 0) {\n let removedNodes = Array.from(mutation.removedNodes);\n let nodeIndexRemove = modalContainers.findIndex(container => removedNodes.includes(container));\n if (nodeIndexRemove >= 0) {\n undo?.();\n modalContainers = modalContainers.filter((val, i) => i !== nodeIndexRemove);\n if (modalContainers.length > 0) {\n let modal = modalContainers[modalContainers.length - 1].querySelector('[aria-modal=\"true\"], [data-ismodal=\"true\"]') as HTMLElement;\n let others = [modal, ... liveAnnouncer ? [liveAnnouncer as HTMLElement] : []];\n undo = hideOthers(others);\n } else {\n undo = undefined;\n }\n }\n }\n }\n });\n observer.observe(target, config);\n return () => {\n undo?.();\n observer.disconnect();\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAMD,MAAM,wCAAkB,OAAO,aAAa,cAAc,WAAW;AAK9D,SAAS,0CAAY,WAAkB,MAAM,EAAE,EAAC,UAAA,YAAW,qCAAe,EAAC,GAAG,CAAC,CAAC;IACrF;;;;;;;GAOC,GACD,IAAI,CAAC,WACH,OAAO,KAAO;IAEhB,IAAI,SAAS,UAAS,aAAa,CAAC;IACpC,IAAI,CAAC,QACH,OAAO,KAAO;IAEhB,IAAI,SAAS;QAAC,WAAW;IAAI;IAC7B,IAAI,kBAAkC,EAAE;IACxC,IAAI;IAEJ,IAAI,WAAW,IAAI,iBAAiB,CAAC;QACnC,MAAM,gBAAiB,UAAS,aAAa,CAAC;QAC9C,KAAK,IAAI,YAAY,eAAgB;YACnC,IAAI,SAAS,IAAI,KAAK,eAAe,SAAS,UAAU,CAAC,MAAM,GAAG,GAAG;gBACnE,IAAI,UAAoB,MAAM,IAAI,CAAC,SAAS,UAAU,EAAE,IAAI,CAAC,CAAC;wBAAc;4BAAA,sBAAA,KAAK,aAAa,cAAlB,0CAAA,yBAAA,MAAqB;;gBACjG,IAAI,SAAS;oBACX,gBAAgB,IAAI,CAAC;oBACrB,IAAI,QAAQ,QAAQ,aAAa,CAAC;oBAClC,iBAAA,2BAAA;oBACA,IAAI,SAAS;wBAAC;2BAAW,gBAAgB;4BAAC;yBAA6B,GAAG,EAAE;qBAAC;oBAC7E,OAAO,CAAA,GAAA,iBAAS,EAAE;gBACpB;YACF,OAAO,IAAI,SAAS,IAAI,KAAK,eAAe,SAAS,YAAY,CAAC,MAAM,GAAG,GAAG;gBAC5E,IAAI,eAAe,MAAM,IAAI,CAAC,SAAS,YAAY;gBACnD,IAAI,kBAAkB,gBAAgB,SAAS,CAAC,CAAA,YAAa,aAAa,QAAQ,CAAC;gBACnF,IAAI,mBAAmB,GAAG;oBACxB,iBAAA,2BAAA;oBACA,kBAAkB,gBAAgB,MAAM,CAAC,CAAC,KAAK,IAAM,MAAM;oBAC3D,IAAI,gBAAgB,MAAM,GAAG,GAAG;wBAC9B,IAAI,QAAQ,eAAe,CAAC,gBAAgB,MAAM,GAAG,EAAE,CAAC,aAAa,CAAC;wBACtE,IAAI,SAAS;4BAAC;+BAAW,gBAAgB;gCAAC;6BAA6B,GAAG,EAAE;yBAAC;wBAC7E,OAAO,CAAA,GAAA,iBAAS,EAAE;oBACpB,OACE,OAAO;gBAEX;YACF;QACF;IACF;IACA,SAAS,OAAO,CAAC,QAAQ;IACzB,OAAO;QACL,iBAAA,2BAAA;QACA,SAAS,UAAU;IACrB;AACF","sources":["packages/@react-aria/aria-modal-polyfill/src/index.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 {hideOthers} from 'aria-hidden';\n\ntype Revert = () => void;\n\nconst currentDocument = typeof document !== 'undefined' ? document : undefined;\n\n/**\n * Acts as a polyfill for `aria-modal` by watching for added modals and hiding any surrounding DOM elements with `aria-hidden`.\n */\nexport function watchModals(selector:string = 'body', {document = currentDocument} = {}): Revert {\n /**\n * Listen for additions to the child list of the selected element (defaults to body). This is where providers render modal portals.\n * When one is added, see if there is a modal inside it, if there is, then hide everything else from screen readers.\n * 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.\n *\n * 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\n * hide based on the last one added.\n */\n if (!document) {\n return () => {};\n }\n let target = document.querySelector(selector);\n if (!target) {\n return () => {};\n }\n let config = {childList: true};\n let modalContainers: Array<Element> = [];\n let undo: Revert | undefined;\n\n let observer = new MutationObserver((mutationRecord) => {\n const liveAnnouncer = document.querySelector('[data-live-announcer=\"true\"]');\n for (let mutation of mutationRecord) {\n if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {\n let addNode: Element = (Array.from(mutation.addedNodes).find((node: any) => node.querySelector?.('[aria-modal=\"true\"], [data-ismodal=\"true\"]')) as HTMLElement);\n if (addNode) {\n modalContainers.push(addNode);\n let modal = addNode.querySelector('[aria-modal=\"true\"], [data-ismodal=\"true\"]') as HTMLElement;\n undo?.();\n let others = [modal, ... liveAnnouncer ? [liveAnnouncer as HTMLElement] : []];\n undo = hideOthers(others);\n }\n } else if (mutation.type === 'childList' && mutation.removedNodes.length > 0) {\n let removedNodes = Array.from(mutation.removedNodes);\n let nodeIndexRemove = modalContainers.findIndex(container => removedNodes.includes(container));\n if (nodeIndexRemove >= 0) {\n undo?.();\n modalContainers = modalContainers.filter((val, i) => i !== nodeIndexRemove);\n if (modalContainers.length > 0) {\n let modal = modalContainers[modalContainers.length - 1].querySelector('[aria-modal=\"true\"], [data-ismodal=\"true\"]') as HTMLElement;\n let others = [modal, ... liveAnnouncer ? [liveAnnouncer as HTMLElement] : []];\n undo = hideOthers(others);\n } else {\n undo = undefined;\n }\n }\n }\n }\n });\n observer.observe(target, config);\n return () => {\n undo?.();\n observer.disconnect();\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAMD,MAAM,wCAAkB,OAAO,aAAa,cAAc,WAAW;AAK9D,SAAS,0CAAY,WAAkB,MAAM,EAAE,EAAC,UAAA,YAAW,qCAAe,EAAwB,GAAG,CAAC,CAAC;IAC5G;;;;;;;GAOC,GACD,IAAI,CAAC,WACH,OAAO,KAAO;IAEhB,IAAI,SAAS,UAAS,aAAa,CAAC;IACpC,IAAI,CAAC,QACH,OAAO,KAAO;IAEhB,IAAI,SAAS;QAAC,WAAW;IAAI;IAC7B,IAAI,kBAAkC,EAAE;IACxC,IAAI;IAEJ,IAAI,WAAW,IAAI,iBAAiB,CAAC;QACnC,MAAM,gBAAiB,UAAS,aAAa,CAAC;QAC9C,KAAK,IAAI,YAAY,eAAgB;YACnC,IAAI,SAAS,IAAI,KAAK,eAAe,SAAS,UAAU,CAAC,MAAM,GAAG,GAAG;gBACnE,IAAI,UAAoB,MAAM,IAAI,CAAC,SAAS,UAAU,EAAE,IAAI,CAAC,CAAC;wBAAc;4BAAA,sBAAA,KAAK,aAAa,cAAlB,0CAAA,yBAAA,MAAqB;;gBACjG,IAAI,SAAS;oBACX,gBAAgB,IAAI,CAAC;oBACrB,IAAI,QAAQ,QAAQ,aAAa,CAAC;oBAClC,iBAAA,2BAAA;oBACA,IAAI,SAAS;wBAAC;2BAAW,gBAAgB;4BAAC;yBAA6B,GAAG,EAAE;qBAAC;oBAC7E,OAAO,CAAA,GAAA,iBAAS,EAAE;gBACpB;YACF,OAAO,IAAI,SAAS,IAAI,KAAK,eAAe,SAAS,YAAY,CAAC,MAAM,GAAG,GAAG;gBAC5E,IAAI,eAAe,MAAM,IAAI,CAAC,SAAS,YAAY;gBACnD,IAAI,kBAAkB,gBAAgB,SAAS,CAAC,CAAA,YAAa,aAAa,QAAQ,CAAC;gBACnF,IAAI,mBAAmB,GAAG;oBACxB,iBAAA,2BAAA;oBACA,kBAAkB,gBAAgB,MAAM,CAAC,CAAC,KAAK,IAAM,MAAM;oBAC3D,IAAI,gBAAgB,MAAM,GAAG,GAAG;wBAC9B,IAAI,QAAQ,eAAe,CAAC,gBAAgB,MAAM,GAAG,EAAE,CAAC,aAAa,CAAC;wBACtE,IAAI,SAAS;4BAAC;+BAAW,gBAAgB;gCAAC;6BAA6B,GAAG,EAAE;yBAAC;wBAC7E,OAAO,CAAA,GAAA,iBAAS,EAAE;oBACpB,OACE,OAAO;gBAEX;YACF;QACF;IACF;IACA,SAAS,OAAO,CAAC,QAAQ;IACzB,OAAO;QACL,iBAAA,2BAAA;QACA,SAAS,UAAU;IACrB;AACF","sources":["packages/@react-aria/aria-modal-polyfill/src/index.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 {hideOthers} from 'aria-hidden';\n\ntype Revert = () => void;\n\nconst currentDocument = typeof document !== 'undefined' ? document : undefined;\n\n/**\n * Acts as a polyfill for `aria-modal` by watching for added modals and hiding any surrounding DOM elements with `aria-hidden`.\n */\nexport function watchModals(selector:string = 'body', {document = currentDocument}: {document?: Document} = {}): Revert {\n /**\n * Listen for additions to the child list of the selected element (defaults to body). This is where providers render modal portals.\n * When one is added, see if there is a modal inside it, if there is, then hide everything else from screen readers.\n * 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.\n *\n * 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\n * hide based on the last one added.\n */\n if (!document) {\n return () => {};\n }\n let target = document.querySelector(selector);\n if (!target) {\n return () => {};\n }\n let config = {childList: true};\n let modalContainers: Array<Element> = [];\n let undo: Revert | undefined;\n\n let observer = new MutationObserver((mutationRecord) => {\n const liveAnnouncer = document.querySelector('[data-live-announcer=\"true\"]');\n for (let mutation of mutationRecord) {\n if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {\n let addNode: Element = (Array.from(mutation.addedNodes).find((node: any) => node.querySelector?.('[aria-modal=\"true\"], [data-ismodal=\"true\"]')) as HTMLElement);\n if (addNode) {\n modalContainers.push(addNode);\n let modal = addNode.querySelector('[aria-modal=\"true\"], [data-ismodal=\"true\"]') as HTMLElement;\n undo?.();\n let others = [modal, ... liveAnnouncer ? [liveAnnouncer as HTMLElement] : []];\n undo = hideOthers(others);\n }\n } else if (mutation.type === 'childList' && mutation.removedNodes.length > 0) {\n let removedNodes = Array.from(mutation.removedNodes);\n let nodeIndexRemove = modalContainers.findIndex(container => removedNodes.includes(container));\n if (nodeIndexRemove >= 0) {\n undo?.();\n modalContainers = modalContainers.filter((val, i) => i !== nodeIndexRemove);\n if (modalContainers.length > 0) {\n let modal = modalContainers[modalContainers.length - 1].querySelector('[aria-modal=\"true\"], [data-ismodal=\"true\"]') as HTMLElement;\n let others = [modal, ... liveAnnouncer ? [liveAnnouncer as HTMLElement] : []];\n undo = hideOthers(others);\n } else {\n undo = undefined;\n }\n }\n }\n }\n });\n observer.observe(target, config);\n return () => {\n undo?.();\n observer.disconnect();\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
package/dist/types.d.ts CHANGED
@@ -3,7 +3,7 @@ type Revert = () => void;
3
3
  * Acts as a polyfill for `aria-modal` by watching for added modals and hiding any surrounding DOM elements with `aria-hidden`.
4
4
  */
5
5
  export function watchModals(selector?: string, { document }?: {
6
- document?: Document | undefined;
6
+ document?: Document;
7
7
  }): Revert;
8
8
 
9
9
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"mappings":"AAcA,cAAc,MAAM,IAAI,CAAC;AAIzB;;GAEG;AACH,4BAA4B,QAAQ,GAAC,MAAe,EAAE,EAAC,QAA0B,EAAC;;CAAK,GAAG,MAAM,CAsD/F","sources":["packages/@react-aria/aria-modal-polyfill/src/packages/@react-aria/aria-modal-polyfill/src/index.ts","packages/@react-aria/aria-modal-polyfill/src/index.ts"],"sourcesContent":[null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {hideOthers} from 'aria-hidden';\n\ntype Revert = () => void;\n\nconst currentDocument = typeof document !== 'undefined' ? document : undefined;\n\n/**\n * Acts as a polyfill for `aria-modal` by watching for added modals and hiding any surrounding DOM elements with `aria-hidden`.\n */\nexport function watchModals(selector:string = 'body', {document = currentDocument} = {}): Revert {\n /**\n * Listen for additions to the child list of the selected element (defaults to body). This is where providers render modal portals.\n * When one is added, see if there is a modal inside it, if there is, then hide everything else from screen readers.\n * 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.\n *\n * 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\n * hide based on the last one added.\n */\n if (!document) {\n return () => {};\n }\n let target = document.querySelector(selector);\n if (!target) {\n return () => {};\n }\n let config = {childList: true};\n let modalContainers: Array<Element> = [];\n let undo: Revert | undefined;\n\n let observer = new MutationObserver((mutationRecord) => {\n const liveAnnouncer = document.querySelector('[data-live-announcer=\"true\"]');\n for (let mutation of mutationRecord) {\n if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {\n let addNode: Element = (Array.from(mutation.addedNodes).find((node: any) => node.querySelector?.('[aria-modal=\"true\"], [data-ismodal=\"true\"]')) as HTMLElement);\n if (addNode) {\n modalContainers.push(addNode);\n let modal = addNode.querySelector('[aria-modal=\"true\"], [data-ismodal=\"true\"]') as HTMLElement;\n undo?.();\n let others = [modal, ... liveAnnouncer ? [liveAnnouncer as HTMLElement] : []];\n undo = hideOthers(others);\n }\n } else if (mutation.type === 'childList' && mutation.removedNodes.length > 0) {\n let removedNodes = Array.from(mutation.removedNodes);\n let nodeIndexRemove = modalContainers.findIndex(container => removedNodes.includes(container));\n if (nodeIndexRemove >= 0) {\n undo?.();\n modalContainers = modalContainers.filter((val, i) => i !== nodeIndexRemove);\n if (modalContainers.length > 0) {\n let modal = modalContainers[modalContainers.length - 1].querySelector('[aria-modal=\"true\"], [data-ismodal=\"true\"]') as HTMLElement;\n let others = [modal, ... liveAnnouncer ? [liveAnnouncer as HTMLElement] : []];\n undo = hideOthers(others);\n } else {\n undo = undefined;\n }\n }\n }\n }\n });\n observer.observe(target, config);\n return () => {\n undo?.();\n observer.disconnect();\n };\n}\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":"AAcA,cAAc,MAAM,IAAI,CAAC;AAIzB;;GAEG;AACH,4BAA4B,QAAQ,GAAC,MAAe,EAAE,EAAC,QAA0B,EAAC,GAAE;IAAC,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAAM,GAAG,MAAM,CAsDtH","sources":["packages/@react-aria/aria-modal-polyfill/src/packages/@react-aria/aria-modal-polyfill/src/index.ts","packages/@react-aria/aria-modal-polyfill/src/index.ts"],"sourcesContent":[null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {hideOthers} from 'aria-hidden';\n\ntype Revert = () => void;\n\nconst currentDocument = typeof document !== 'undefined' ? document : undefined;\n\n/**\n * Acts as a polyfill for `aria-modal` by watching for added modals and hiding any surrounding DOM elements with `aria-hidden`.\n */\nexport function watchModals(selector:string = 'body', {document = currentDocument}: {document?: Document} = {}): Revert {\n /**\n * Listen for additions to the child list of the selected element (defaults to body). This is where providers render modal portals.\n * When one is added, see if there is a modal inside it, if there is, then hide everything else from screen readers.\n * 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.\n *\n * 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\n * hide based on the last one added.\n */\n if (!document) {\n return () => {};\n }\n let target = document.querySelector(selector);\n if (!target) {\n return () => {};\n }\n let config = {childList: true};\n let modalContainers: Array<Element> = [];\n let undo: Revert | undefined;\n\n let observer = new MutationObserver((mutationRecord) => {\n const liveAnnouncer = document.querySelector('[data-live-announcer=\"true\"]');\n for (let mutation of mutationRecord) {\n if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {\n let addNode: Element = (Array.from(mutation.addedNodes).find((node: any) => node.querySelector?.('[aria-modal=\"true\"], [data-ismodal=\"true\"]')) as HTMLElement);\n if (addNode) {\n modalContainers.push(addNode);\n let modal = addNode.querySelector('[aria-modal=\"true\"], [data-ismodal=\"true\"]') as HTMLElement;\n undo?.();\n let others = [modal, ... liveAnnouncer ? [liveAnnouncer as HTMLElement] : []];\n undo = hideOthers(others);\n }\n } else if (mutation.type === 'childList' && mutation.removedNodes.length > 0) {\n let removedNodes = Array.from(mutation.removedNodes);\n let nodeIndexRemove = modalContainers.findIndex(container => removedNodes.includes(container));\n if (nodeIndexRemove >= 0) {\n undo?.();\n modalContainers = modalContainers.filter((val, i) => i !== nodeIndexRemove);\n if (modalContainers.length > 0) {\n let modal = modalContainers[modalContainers.length - 1].querySelector('[aria-modal=\"true\"], [data-ismodal=\"true\"]') as HTMLElement;\n let others = [modal, ... liveAnnouncer ? [liveAnnouncer as HTMLElement] : []];\n undo = hideOthers(others);\n } else {\n undo = undefined;\n }\n }\n }\n }\n });\n observer.observe(target, config);\n return () => {\n undo?.();\n observer.disconnect();\n };\n}\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@react-aria/aria-modal-polyfill",
3
- "version": "3.7.13",
3
+ "version": "3.7.15",
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
8
  "exports": {
9
- "types": "./dist/types.d.ts",
9
+ "source": "./src/index.ts",
10
+ "types": [
11
+ "./dist/types.d.ts",
12
+ "./src/index.ts"
13
+ ],
10
14
  "import": "./dist/import.mjs",
11
15
  "require": "./dist/main.js"
12
16
  },
@@ -31,5 +35,5 @@
31
35
  "publishConfig": {
32
36
  "access": "public"
33
37
  },
34
- "gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
38
+ "gitHead": "8b9348ff255e018b2dd9b27e2a45507cadfa1d35"
35
39
  }
package/src/index.ts CHANGED
@@ -19,7 +19,7 @@ const currentDocument = typeof document !== 'undefined' ? document : undefined;
19
19
  /**
20
20
  * Acts as a polyfill for `aria-modal` by watching for added modals and hiding any surrounding DOM elements with `aria-hidden`.
21
21
  */
22
- export function watchModals(selector:string = 'body', {document = currentDocument} = {}): Revert {
22
+ export function watchModals(selector:string = 'body', {document = currentDocument}: {document?: Document} = {}): Revert {
23
23
  /**
24
24
  * Listen for additions to the child list of the selected element (defaults to body). This is where providers render modal portals.
25
25
  * When one is added, see if there is a modal inside it, if there is, then hide everything else from screen readers.