@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.cjs
CHANGED
|
@@ -29431,32 +29431,26 @@ function isNavItemActive(pathname, item) {
|
|
|
29431
29431
|
}
|
|
29432
29432
|
return pathname === item.to || pathname.startsWith(`${item.to}/`);
|
|
29433
29433
|
}
|
|
29434
|
-
function isModifiedClick(event) {
|
|
29435
|
-
return event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0;
|
|
29436
|
-
}
|
|
29437
29434
|
function SidebarNavItem({ item, isOpen, isActive, onNavigate }) {
|
|
29438
29435
|
if (item.hidden) {
|
|
29439
29436
|
return null;
|
|
29440
29437
|
}
|
|
29441
29438
|
const handleClick = (event) => {
|
|
29439
|
+
event.preventDefault();
|
|
29442
29440
|
if (item.disabled) {
|
|
29443
|
-
event.preventDefault();
|
|
29444
29441
|
return;
|
|
29445
29442
|
}
|
|
29446
|
-
if (event.defaultPrevented || isModifiedClick(event)) {
|
|
29447
|
-
return;
|
|
29448
|
-
}
|
|
29449
|
-
event.preventDefault();
|
|
29450
29443
|
item.onClick?.();
|
|
29451
29444
|
onNavigate?.(item);
|
|
29452
29445
|
};
|
|
29453
29446
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
29454
|
-
"
|
|
29447
|
+
"button",
|
|
29455
29448
|
{
|
|
29456
|
-
|
|
29449
|
+
type: "button",
|
|
29457
29450
|
onClick: handleClick,
|
|
29458
29451
|
"aria-current": isActive ? "page" : void 0,
|
|
29459
29452
|
"aria-disabled": item.disabled,
|
|
29453
|
+
disabled: item.disabled,
|
|
29460
29454
|
tabIndex: item.disabled ? -1 : void 0,
|
|
29461
29455
|
className: cn(
|
|
29462
29456
|
"relative flex items-center rounded-xl px-4 py-3 transition-[background-color,color,gap,padding] duration-300 ease-in-out",
|
|
@@ -31176,6 +31170,28 @@ function Modal({
|
|
|
31176
31170
|
return typeof document !== "undefined" ? (0, import_react_dom2.createPortal)(modal, document.body) : modal;
|
|
31177
31171
|
}
|
|
31178
31172
|
var DRAWER_TRANSITION_MS = 300;
|
|
31173
|
+
var bodyScrollLockCount = 0;
|
|
31174
|
+
var previousBodyOverflow = "";
|
|
31175
|
+
function lockBodyScroll() {
|
|
31176
|
+
if (typeof document === "undefined") {
|
|
31177
|
+
return;
|
|
31178
|
+
}
|
|
31179
|
+
if (bodyScrollLockCount === 0) {
|
|
31180
|
+
previousBodyOverflow = document.body.style.overflow;
|
|
31181
|
+
document.body.style.overflow = "hidden";
|
|
31182
|
+
}
|
|
31183
|
+
bodyScrollLockCount += 1;
|
|
31184
|
+
}
|
|
31185
|
+
function unlockBodyScroll() {
|
|
31186
|
+
if (typeof document === "undefined") {
|
|
31187
|
+
return;
|
|
31188
|
+
}
|
|
31189
|
+
bodyScrollLockCount = Math.max(0, bodyScrollLockCount - 1);
|
|
31190
|
+
if (bodyScrollLockCount === 0) {
|
|
31191
|
+
document.body.style.overflow = previousBodyOverflow;
|
|
31192
|
+
previousBodyOverflow = "";
|
|
31193
|
+
}
|
|
31194
|
+
}
|
|
31179
31195
|
function Drawer({
|
|
31180
31196
|
open,
|
|
31181
31197
|
title,
|
|
@@ -31216,8 +31232,7 @@ function Drawer({
|
|
|
31216
31232
|
if (!isPresent) {
|
|
31217
31233
|
return;
|
|
31218
31234
|
}
|
|
31219
|
-
|
|
31220
|
-
document.body.style.overflow = "hidden";
|
|
31235
|
+
lockBodyScroll();
|
|
31221
31236
|
const handleKeyDown = (event) => {
|
|
31222
31237
|
if (event.key === "Escape") {
|
|
31223
31238
|
onClose();
|
|
@@ -31225,7 +31240,7 @@ function Drawer({
|
|
|
31225
31240
|
};
|
|
31226
31241
|
window.addEventListener("keydown", handleKeyDown);
|
|
31227
31242
|
return () => {
|
|
31228
|
-
|
|
31243
|
+
unlockBodyScroll();
|
|
31229
31244
|
window.removeEventListener("keydown", handleKeyDown);
|
|
31230
31245
|
};
|
|
31231
31246
|
}, [isPresent, onClose]);
|