@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.js
CHANGED
|
@@ -382,14 +382,25 @@ var StickyPreview = ({
|
|
|
382
382
|
)
|
|
383
383
|
] });
|
|
384
384
|
};
|
|
385
|
+
var ESCAPE_KEY = "Escape";
|
|
386
|
+
var OPEN_MENU_SELECTOR = '[aria-expanded="true"][aria-haspopup],[aria-expanded="true"][role="combobox"],[role="menu"],[role="listbox"]';
|
|
387
|
+
function isInsideOpenMenu(target) {
|
|
388
|
+
return target instanceof Element && target.closest(OPEN_MENU_SELECTOR) !== null;
|
|
389
|
+
}
|
|
385
390
|
function useEscapeKey(enabled, onClose) {
|
|
391
|
+
const isEscapeForMenu = React14.useRef(false);
|
|
386
392
|
React14.useEffect(() => {
|
|
387
393
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
394
|
+
const onKeyDownCapture = (event) => {
|
|
395
|
+
if (event.key === ESCAPE_KEY) isEscapeForMenu.current = isInsideOpenMenu(event.target);
|
|
396
|
+
};
|
|
388
397
|
const onKeyDown = (event) => {
|
|
389
|
-
if (event.key ===
|
|
398
|
+
if (event.key === ESCAPE_KEY && !isEscapeForMenu.current) onClose();
|
|
390
399
|
};
|
|
400
|
+
document.addEventListener("keydown", onKeyDownCapture, true);
|
|
391
401
|
document.addEventListener("keydown", onKeyDown);
|
|
392
402
|
return () => {
|
|
403
|
+
document.removeEventListener("keydown", onKeyDownCapture, true);
|
|
393
404
|
document.removeEventListener("keydown", onKeyDown);
|
|
394
405
|
};
|
|
395
406
|
}, [enabled, onClose]);
|
|
@@ -533,7 +544,8 @@ var Modal = ({
|
|
|
533
544
|
[theme.colors.surface, size]
|
|
534
545
|
);
|
|
535
546
|
const hasHeader = title !== void 0 || showClose;
|
|
536
|
-
|
|
547
|
+
const hardwareBackClose = reactNative.Platform.OS === "web" ? void 0 : onClose;
|
|
548
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: mounted, onRequestClose: hardwareBackClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles6.overlay, children: [
|
|
537
549
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
538
550
|
reactNative.Animated.View,
|
|
539
551
|
{
|
|
@@ -1872,7 +1884,8 @@ var SideSheet = ({
|
|
|
1872
1884
|
useFocusTrap(sheetRef, visible && panel.mounted, initialFocusTestID);
|
|
1873
1885
|
useEscapeKey(visible, onClose);
|
|
1874
1886
|
useScrollLock(visible);
|
|
1875
|
-
|
|
1887
|
+
const hardwareBackClose = reactNative.Platform.OS === "web" ? void 0 : onClose;
|
|
1888
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: panel.mounted || backdrop.mounted, onRequestClose: hardwareBackClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles16.root, children: [
|
|
1876
1889
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [reactNative.StyleSheet.absoluteFill, styles16.scrim, { opacity: backdrop.style.opacity }] }),
|
|
1877
1890
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1878
1891
|
reactNative.Pressable,
|