@votodigital-onpeui/react 0.1.13 → 0.1.14
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/{chunk-TNUNWG4S.mjs → chunk-7CLKQHKZ.mjs} +48 -8
- package/dist/chunk-7CLKQHKZ.mjs.map +1 -0
- package/dist/components.js +46 -6
- package/dist/components.js.map +1 -1
- package/dist/components.mjs +1 -1
- package/dist/index.js +46 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-TNUNWG4S.mjs.map +0 -1
package/dist/components.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BrowserRecommended, Button, Footer, Modal, ModalBrowserIncompatible, ModalConfirm, ModalDnieVersions, ModalLoading, ModalNfc, ModalSystemIncompatible, NotRecommended, Overlay, Portal, Show } from './chunk-
|
|
1
|
+
export { BrowserRecommended, Button, Footer, Modal, ModalBrowserIncompatible, ModalConfirm, ModalDnieVersions, ModalLoading, ModalNfc, ModalSystemIncompatible, NotRecommended, Overlay, Portal, Show } from './chunk-7CLKQHKZ.mjs';
|
|
2
2
|
import './chunk-UEKVXFZK.mjs';
|
|
3
3
|
//# sourceMappingURL=components.mjs.map
|
|
4
4
|
//# sourceMappingURL=components.mjs.map
|
package/dist/index.js
CHANGED
|
@@ -1573,6 +1573,8 @@ var Modal = ({
|
|
|
1573
1573
|
[10, 50, 100, 200].forEach((d) => setTimeout(resetScroll, d));
|
|
1574
1574
|
}, [isOpen]);
|
|
1575
1575
|
react.useEffect(() => {
|
|
1576
|
+
let focusOutWrapper = null;
|
|
1577
|
+
const pendingTasks = [];
|
|
1576
1578
|
const isElementVisible = (element) => {
|
|
1577
1579
|
const style = window.getComputedStyle(element);
|
|
1578
1580
|
return style.visibility !== "hidden" && style.display !== "none" && element.offsetParent !== null;
|
|
@@ -1697,22 +1699,60 @@ var Modal = ({
|
|
|
1697
1699
|
};
|
|
1698
1700
|
if (isOpen && !disableFocus) {
|
|
1699
1701
|
previousActiveElement.current = document.activeElement;
|
|
1700
|
-
|
|
1702
|
+
const labelledById = props["aria-labelledby"];
|
|
1703
|
+
const focusInitial = (wrapper) => {
|
|
1704
|
+
if (labelledById) {
|
|
1705
|
+
const labelEl = document.getElementById(labelledById);
|
|
1706
|
+
if (labelEl instanceof HTMLElement) {
|
|
1707
|
+
if (!labelEl.hasAttribute("tabindex")) labelEl.setAttribute("tabindex", "-1");
|
|
1708
|
+
labelEl.focus({ preventScroll: true });
|
|
1709
|
+
return;
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
const focusable = getFocusableElements(wrapper);
|
|
1713
|
+
const first = focusable[0];
|
|
1714
|
+
if (first) first.focus({ preventScroll: true });
|
|
1715
|
+
else wrapper.focus();
|
|
1716
|
+
};
|
|
1717
|
+
const bindFocusManagement = (attempt = 0) => {
|
|
1718
|
+
const wrapper = modalRef.current;
|
|
1719
|
+
if (!wrapper) {
|
|
1720
|
+
if (attempt < 10) {
|
|
1721
|
+
pendingTasks.push(
|
|
1722
|
+
globalThis.setTimeout(() => bindFocusManagement(attempt + 1), 25)
|
|
1723
|
+
);
|
|
1724
|
+
}
|
|
1725
|
+
return;
|
|
1726
|
+
}
|
|
1727
|
+
if (focusOutWrapper !== wrapper) {
|
|
1728
|
+
focusOutWrapper?.removeEventListener("focusout", handleFocusOut);
|
|
1729
|
+
wrapper.addEventListener("focusout", handleFocusOut);
|
|
1730
|
+
focusOutWrapper = wrapper;
|
|
1731
|
+
}
|
|
1732
|
+
focusInitial(wrapper);
|
|
1733
|
+
};
|
|
1701
1734
|
document.addEventListener("keydown", handleKeyDown);
|
|
1702
|
-
|
|
1703
|
-
if (wrapper) wrapper.addEventListener("focusout", handleFocusOut);
|
|
1735
|
+
pendingTasks.push(globalThis.setTimeout(() => bindFocusManagement(), 0));
|
|
1704
1736
|
} else if (isOpen && disableFocus) {
|
|
1705
1737
|
document.addEventListener("keydown", handleKeyDown);
|
|
1706
1738
|
}
|
|
1707
1739
|
return () => {
|
|
1740
|
+
pendingTasks.forEach((task) => globalThis.clearTimeout(task));
|
|
1708
1741
|
document.removeEventListener("keydown", handleKeyDown);
|
|
1709
|
-
|
|
1710
|
-
if (wrapper) wrapper.removeEventListener("focusout", handleFocusOut);
|
|
1742
|
+
focusOutWrapper?.removeEventListener("focusout", handleFocusOut);
|
|
1711
1743
|
if (!disableFocus && !disableFocusRestore && previousActiveElement.current) {
|
|
1712
1744
|
previousActiveElement.current.focus();
|
|
1713
1745
|
}
|
|
1714
1746
|
};
|
|
1715
|
-
}, [
|
|
1747
|
+
}, [
|
|
1748
|
+
isOpen,
|
|
1749
|
+
onClose,
|
|
1750
|
+
closeDisabled,
|
|
1751
|
+
escapeToClose,
|
|
1752
|
+
disableFocus,
|
|
1753
|
+
disableFocusRestore,
|
|
1754
|
+
props["aria-labelledby"]
|
|
1755
|
+
]);
|
|
1716
1756
|
if (!mounted) return null;
|
|
1717
1757
|
const contentClass = [
|
|
1718
1758
|
"relative flex flex-col items-center justify-start",
|