@scripso-homepad/ui 0.4.16 → 0.4.17
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/web/index.cjs +28 -13
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.js +28 -13
- package/dist/web/index.js.map +1 -1
- package/package.json +1 -1
- package/src/web/components/Drawer.tsx +31 -3
- package/src/web/layout/SidebarNavItem.tsx +7 -16
package/dist/web/index.js
CHANGED
|
@@ -28882,32 +28882,26 @@ function isNavItemActive(pathname, item) {
|
|
|
28882
28882
|
}
|
|
28883
28883
|
return pathname === item.to || pathname.startsWith(`${item.to}/`);
|
|
28884
28884
|
}
|
|
28885
|
-
function isModifiedClick(event) {
|
|
28886
|
-
return event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0;
|
|
28887
|
-
}
|
|
28888
28885
|
function SidebarNavItem({ item, isOpen, isActive, onNavigate }) {
|
|
28889
28886
|
if (item.hidden) {
|
|
28890
28887
|
return null;
|
|
28891
28888
|
}
|
|
28892
28889
|
const handleClick = (event) => {
|
|
28890
|
+
event.preventDefault();
|
|
28893
28891
|
if (item.disabled) {
|
|
28894
|
-
event.preventDefault();
|
|
28895
28892
|
return;
|
|
28896
28893
|
}
|
|
28897
|
-
if (event.defaultPrevented || isModifiedClick(event)) {
|
|
28898
|
-
return;
|
|
28899
|
-
}
|
|
28900
|
-
event.preventDefault();
|
|
28901
28894
|
item.onClick?.();
|
|
28902
28895
|
onNavigate?.(item);
|
|
28903
28896
|
};
|
|
28904
28897
|
return /* @__PURE__ */ jsxs(
|
|
28905
|
-
"
|
|
28898
|
+
"button",
|
|
28906
28899
|
{
|
|
28907
|
-
|
|
28900
|
+
type: "button",
|
|
28908
28901
|
onClick: handleClick,
|
|
28909
28902
|
"aria-current": isActive ? "page" : void 0,
|
|
28910
28903
|
"aria-disabled": item.disabled,
|
|
28904
|
+
disabled: item.disabled,
|
|
28911
28905
|
tabIndex: item.disabled ? -1 : void 0,
|
|
28912
28906
|
className: cn(
|
|
28913
28907
|
"relative flex items-center rounded-xl px-4 py-3 transition-[background-color,color,gap,padding] duration-300 ease-in-out",
|
|
@@ -30433,6 +30427,28 @@ function Modal({
|
|
|
30433
30427
|
return typeof document !== "undefined" ? (0, import_react_dom2.createPortal)(modal, document.body) : modal;
|
|
30434
30428
|
}
|
|
30435
30429
|
var DRAWER_TRANSITION_MS = 300;
|
|
30430
|
+
var bodyScrollLockCount = 0;
|
|
30431
|
+
var previousBodyOverflow = "";
|
|
30432
|
+
function lockBodyScroll() {
|
|
30433
|
+
if (typeof document === "undefined") {
|
|
30434
|
+
return;
|
|
30435
|
+
}
|
|
30436
|
+
if (bodyScrollLockCount === 0) {
|
|
30437
|
+
previousBodyOverflow = document.body.style.overflow;
|
|
30438
|
+
document.body.style.overflow = "hidden";
|
|
30439
|
+
}
|
|
30440
|
+
bodyScrollLockCount += 1;
|
|
30441
|
+
}
|
|
30442
|
+
function unlockBodyScroll() {
|
|
30443
|
+
if (typeof document === "undefined") {
|
|
30444
|
+
return;
|
|
30445
|
+
}
|
|
30446
|
+
bodyScrollLockCount = Math.max(0, bodyScrollLockCount - 1);
|
|
30447
|
+
if (bodyScrollLockCount === 0) {
|
|
30448
|
+
document.body.style.overflow = previousBodyOverflow;
|
|
30449
|
+
previousBodyOverflow = "";
|
|
30450
|
+
}
|
|
30451
|
+
}
|
|
30436
30452
|
function Drawer({
|
|
30437
30453
|
open,
|
|
30438
30454
|
title,
|
|
@@ -30473,8 +30489,7 @@ function Drawer({
|
|
|
30473
30489
|
if (!isPresent) {
|
|
30474
30490
|
return;
|
|
30475
30491
|
}
|
|
30476
|
-
|
|
30477
|
-
document.body.style.overflow = "hidden";
|
|
30492
|
+
lockBodyScroll();
|
|
30478
30493
|
const handleKeyDown = (event) => {
|
|
30479
30494
|
if (event.key === "Escape") {
|
|
30480
30495
|
onClose();
|
|
@@ -30482,7 +30497,7 @@ function Drawer({
|
|
|
30482
30497
|
};
|
|
30483
30498
|
window.addEventListener("keydown", handleKeyDown);
|
|
30484
30499
|
return () => {
|
|
30485
|
-
|
|
30500
|
+
unlockBodyScroll();
|
|
30486
30501
|
window.removeEventListener("keydown", handleKeyDown);
|
|
30487
30502
|
};
|
|
30488
30503
|
}, [isPresent, onClose]);
|