@dloizides/ui-layout 1.40.0 → 1.40.2
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/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -376,14 +376,25 @@ var StickyPreview = ({
|
|
|
376
376
|
)
|
|
377
377
|
] });
|
|
378
378
|
};
|
|
379
|
+
var ESCAPE_KEY = "Escape";
|
|
380
|
+
var OPEN_MENU_SELECTOR = '[aria-expanded="true"][aria-haspopup],[aria-expanded="true"][role="combobox"],[role="menu"],[role="listbox"]';
|
|
381
|
+
function isInsideOpenMenu(target) {
|
|
382
|
+
return target instanceof Element && target.closest(OPEN_MENU_SELECTOR) !== null;
|
|
383
|
+
}
|
|
379
384
|
function useEscapeKey(enabled, onClose) {
|
|
385
|
+
const isEscapeForMenu = useRef(false);
|
|
380
386
|
useEffect(() => {
|
|
381
387
|
if (Platform.OS !== "web" || !enabled) return;
|
|
388
|
+
const onKeyDownCapture = (event) => {
|
|
389
|
+
if (event.key === ESCAPE_KEY) isEscapeForMenu.current = isInsideOpenMenu(event.target);
|
|
390
|
+
};
|
|
382
391
|
const onKeyDown = (event) => {
|
|
383
|
-
if (event.key ===
|
|
392
|
+
if (event.key === ESCAPE_KEY && !isEscapeForMenu.current) onClose();
|
|
384
393
|
};
|
|
394
|
+
document.addEventListener("keydown", onKeyDownCapture, true);
|
|
385
395
|
document.addEventListener("keydown", onKeyDown);
|
|
386
396
|
return () => {
|
|
397
|
+
document.removeEventListener("keydown", onKeyDownCapture, true);
|
|
387
398
|
document.removeEventListener("keydown", onKeyDown);
|
|
388
399
|
};
|
|
389
400
|
}, [enabled, onClose]);
|
|
@@ -1866,7 +1877,8 @@ var SideSheet = ({
|
|
|
1866
1877
|
useFocusTrap(sheetRef, visible && panel.mounted, initialFocusTestID);
|
|
1867
1878
|
useEscapeKey(visible, onClose);
|
|
1868
1879
|
useScrollLock(visible);
|
|
1869
|
-
|
|
1880
|
+
const hardwareBackClose = Platform.OS === "web" ? void 0 : onClose;
|
|
1881
|
+
return /* @__PURE__ */ jsx(Modal$1, { transparent: true, visible: panel.mounted || backdrop.mounted, onRequestClose: hardwareBackClose, children: /* @__PURE__ */ jsxs(View, { style: styles16.root, children: [
|
|
1870
1882
|
/* @__PURE__ */ jsx(Animated.View, { style: [StyleSheet.absoluteFill, styles16.scrim, { opacity: backdrop.style.opacity }] }),
|
|
1871
1883
|
/* @__PURE__ */ jsx(
|
|
1872
1884
|
Pressable,
|
|
@@ -1951,7 +1963,8 @@ var BottomSheet = ({
|
|
|
1951
1963
|
useFocusTrap(panelRef, visible && panel.mounted, initialFocusTestID);
|
|
1952
1964
|
useEscapeKey(visible, onClose);
|
|
1953
1965
|
useScrollLock(visible);
|
|
1954
|
-
|
|
1966
|
+
const hardwareBackClose = Platform.OS === "web" ? void 0 : onClose;
|
|
1967
|
+
return /* @__PURE__ */ jsx(Modal$1, { transparent: true, visible: panel.mounted || backdrop.mounted, onRequestClose: hardwareBackClose, children: /* @__PURE__ */ jsxs(View, { style: styles17.root, children: [
|
|
1955
1968
|
/* @__PURE__ */ jsx(Animated.View, { style: [StyleSheet.absoluteFill, styles17.backdrop, { opacity: backdrop.style.opacity }] }),
|
|
1956
1969
|
/* @__PURE__ */ jsx(
|
|
1957
1970
|
Pressable,
|