@dloizides/ui-layout 1.40.1 → 1.40.3
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]);
|
|
@@ -527,7 +538,8 @@ var Modal = ({
|
|
|
527
538
|
[theme.colors.surface, size]
|
|
528
539
|
);
|
|
529
540
|
const hasHeader = title !== void 0 || showClose;
|
|
530
|
-
|
|
541
|
+
const hardwareBackClose = Platform.OS === "web" ? void 0 : onClose;
|
|
542
|
+
return /* @__PURE__ */ jsx(Modal$1, { transparent: true, visible: mounted, onRequestClose: hardwareBackClose, children: /* @__PURE__ */ jsxs(View, { style: styles6.overlay, children: [
|
|
531
543
|
/* @__PURE__ */ jsx(
|
|
532
544
|
Animated.View,
|
|
533
545
|
{
|
|
@@ -1866,7 +1878,8 @@ var SideSheet = ({
|
|
|
1866
1878
|
useFocusTrap(sheetRef, visible && panel.mounted, initialFocusTestID);
|
|
1867
1879
|
useEscapeKey(visible, onClose);
|
|
1868
1880
|
useScrollLock(visible);
|
|
1869
|
-
|
|
1881
|
+
const hardwareBackClose = Platform.OS === "web" ? void 0 : onClose;
|
|
1882
|
+
return /* @__PURE__ */ jsx(Modal$1, { transparent: true, visible: panel.mounted || backdrop.mounted, onRequestClose: hardwareBackClose, children: /* @__PURE__ */ jsxs(View, { style: styles16.root, children: [
|
|
1870
1883
|
/* @__PURE__ */ jsx(Animated.View, { style: [StyleSheet.absoluteFill, styles16.scrim, { opacity: backdrop.style.opacity }] }),
|
|
1871
1884
|
/* @__PURE__ */ jsx(
|
|
1872
1885
|
Pressable,
|