@scripso-homepad/ui 0.4.25 → 0.4.27

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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { __commonJS, __require, __toESM, Input, Button } from '../chunk-N73KHOZ4.js';
1
+ import { __commonJS, __require, __toESM, Input, Button } from '../chunk-AOBKWDGW.js';
2
2
  import { ChevronsUpDown, Search, LogOut, PanelLeftClose, PanelLeftOpen, X, Menu, ChevronLeft, ChevronRight } from 'lucide-react';
3
3
  import { clsx } from 'clsx';
4
4
  import { twMerge } from 'tailwind-merge';
@@ -7370,7 +7370,7 @@ var require_react_dom_development = __commonJS({
7370
7370
  var HostPortal = 4;
7371
7371
  var HostComponent = 5;
7372
7372
  var HostText = 6;
7373
- var Fragment4 = 7;
7373
+ var Fragment3 = 7;
7374
7374
  var Mode = 8;
7375
7375
  var ContextConsumer = 9;
7376
7376
  var ContextProvider = 10;
@@ -8525,7 +8525,7 @@ var require_react_dom_development = __commonJS({
8525
8525
  return "DehydratedFragment";
8526
8526
  case ForwardRef:
8527
8527
  return getWrappedName$1(type, type.render, "ForwardRef");
8528
- case Fragment4:
8528
+ case Fragment3:
8529
8529
  return "Fragment";
8530
8530
  case HostComponent:
8531
8531
  return type;
@@ -16950,7 +16950,7 @@ var require_react_dom_development = __commonJS({
16950
16950
  }
16951
16951
  }
16952
16952
  function updateFragment2(returnFiber, current2, fragment, lanes, key) {
16953
- if (current2 === null || current2.tag !== Fragment4) {
16953
+ if (current2 === null || current2.tag !== Fragment3) {
16954
16954
  var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);
16955
16955
  created.return = returnFiber;
16956
16956
  return created;
@@ -17353,7 +17353,7 @@ var require_react_dom_development = __commonJS({
17353
17353
  if (child.key === key) {
17354
17354
  var elementType = element.type;
17355
17355
  if (elementType === REACT_FRAGMENT_TYPE) {
17356
- if (child.tag === Fragment4) {
17356
+ if (child.tag === Fragment3) {
17357
17357
  deleteRemainingChildren(returnFiber, child.sibling);
17358
17358
  var existing = useFiber(child, element.props.children);
17359
17359
  existing.return = returnFiber;
@@ -22827,7 +22827,7 @@ var require_react_dom_development = __commonJS({
22827
22827
  var _resolvedProps2 = workInProgress2.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
22828
22828
  return updateForwardRef(current2, workInProgress2, type, _resolvedProps2, renderLanes2);
22829
22829
  }
22830
- case Fragment4:
22830
+ case Fragment3:
22831
22831
  return updateFragment(current2, workInProgress2, renderLanes2);
22832
22832
  case Mode:
22833
22833
  return updateMode(current2, workInProgress2, renderLanes2);
@@ -23099,7 +23099,7 @@ var require_react_dom_development = __commonJS({
23099
23099
  case SimpleMemoComponent:
23100
23100
  case FunctionComponent:
23101
23101
  case ForwardRef:
23102
- case Fragment4:
23102
+ case Fragment3:
23103
23103
  case Mode:
23104
23104
  case Profiler:
23105
23105
  case ContextConsumer:
@@ -27351,7 +27351,7 @@ var require_react_dom_development = __commonJS({
27351
27351
  return fiber;
27352
27352
  }
27353
27353
  function createFiberFromFragment(elements, mode, lanes, key) {
27354
- var fiber = createFiber(Fragment4, elements, key, mode);
27354
+ var fiber = createFiber(Fragment3, elements, key, mode);
27355
27355
  fiber.lanes = lanes;
27356
27356
  return fiber;
27357
27357
  }
@@ -28932,9 +28932,9 @@ function SidebarNavItem({ item, isOpen, isActive, onNavigate }) {
28932
28932
  tabIndex: item.disabled ? -1 : void 0,
28933
28933
  className: cn(
28934
28934
  "relative flex items-center rounded-xl px-4 py-3 transition-[background-color,color,gap,padding] duration-300 ease-in-out",
28935
- isOpen ? "w-full gap-4" : "justify-center gap-0 px-3",
28935
+ isOpen ? "w-full gap-4" : "w-full justify-center gap-0 px-3",
28936
28936
  item.disabled && "pointer-events-none opacity-50",
28937
- isActive ? "bg-black/12 text-white" : "text-navy-100 hover:bg-white/5"
28937
+ isActive ? "bg-black/12 text-white shadow-none" : "text-navy-100 shadow-none hover:bg-white/5"
28938
28938
  ),
28939
28939
  children: [
28940
28940
  /* @__PURE__ */ jsx(
@@ -28969,6 +28969,7 @@ function getInitials(fullName, email) {
28969
28969
  }
28970
28970
  return email.slice(0, 2).toUpperCase();
28971
28971
  }
28972
+ var avatarCircleClassName = "flex size-11 shrink-0 items-center justify-center rounded-full bg-white/5";
28972
28973
  function SidebarUserCard({
28973
28974
  user,
28974
28975
  isOpen,
@@ -28977,39 +28978,110 @@ function SidebarUserCard({
28977
28978
  className
28978
28979
  }) {
28979
28980
  const initials = user.initials ?? getInitials(user.fullName, user.email);
28981
+ const [logoutOpen, setLogoutOpen] = useState(false);
28982
+ const rootRef = useRef(null);
28983
+ const logoutMenuId = useId();
28984
+ useEffect(() => {
28985
+ if (isOpen) {
28986
+ setLogoutOpen(false);
28987
+ }
28988
+ }, [isOpen]);
28989
+ useEffect(() => {
28990
+ if (isOpen || !logoutOpen) {
28991
+ return;
28992
+ }
28993
+ function handlePointerDown(event) {
28994
+ if (rootRef.current && !rootRef.current.contains(event.target)) {
28995
+ setLogoutOpen(false);
28996
+ }
28997
+ }
28998
+ function handleKeyDown(event) {
28999
+ if (event.key === "Escape") {
29000
+ setLogoutOpen(false);
29001
+ }
29002
+ }
29003
+ document.addEventListener("mousedown", handlePointerDown);
29004
+ document.addEventListener("keydown", handleKeyDown);
29005
+ return () => {
29006
+ document.removeEventListener("mousedown", handlePointerDown);
29007
+ document.removeEventListener("keydown", handleKeyDown);
29008
+ };
29009
+ }, [isOpen, logoutOpen]);
29010
+ const avatar = /* @__PURE__ */ jsx(
29011
+ "div",
29012
+ {
29013
+ className: cn(avatarCircleClassName, "typography-14 font-bold text-white"),
29014
+ "aria-hidden": true,
29015
+ children: initials
29016
+ }
29017
+ );
29018
+ if (!isOpen) {
29019
+ return /* @__PURE__ */ jsxs(
29020
+ "div",
29021
+ {
29022
+ ref: rootRef,
29023
+ className: cn("flex w-full flex-col items-center gap-2", className),
29024
+ children: [
29025
+ logoutOpen ? /* @__PURE__ */ jsx(
29026
+ "button",
29027
+ {
29028
+ type: "button",
29029
+ id: logoutMenuId,
29030
+ onClick: () => {
29031
+ setLogoutOpen(false);
29032
+ onLogout?.();
29033
+ },
29034
+ className: cn(
29035
+ avatarCircleClassName,
29036
+ "cursor-pointer bg-black/20 text-white",
29037
+ "transition-[background-color,transform] duration-300 ease-in-out",
29038
+ "hover:bg-white/10 active:scale-95"
29039
+ ),
29040
+ "aria-label": logoutLabel,
29041
+ children: /* @__PURE__ */ jsx(LogOut, { size: 20, strokeWidth: 1.75 })
29042
+ }
29043
+ ) : null,
29044
+ /* @__PURE__ */ jsx(
29045
+ "button",
29046
+ {
29047
+ type: "button",
29048
+ onClick: () => setLogoutOpen((open) => !open),
29049
+ className: "flex cursor-pointer items-center justify-center transition-transform duration-300 ease-in-out active:scale-95",
29050
+ "aria-expanded": logoutOpen,
29051
+ "aria-haspopup": "true",
29052
+ "aria-controls": logoutOpen ? logoutMenuId : void 0,
29053
+ "aria-label": user.fullName,
29054
+ children: avatar
29055
+ }
29056
+ )
29057
+ ]
29058
+ }
29059
+ );
29060
+ }
28980
29061
  return /* @__PURE__ */ jsxs(
28981
29062
  "div",
28982
29063
  {
28983
29064
  className: cn(
28984
- "flex w-full items-center rounded-xl transition-[background-color,justify-content,gap,padding] duration-300 ease-in-out",
28985
- isOpen ? "justify-between gap-3 bg-black/12 p-3" : "justify-center px-3 py-3",
29065
+ "flex w-full items-center justify-between gap-3 rounded-xl bg-black/12 p-3",
29066
+ "transition-[background-color,justify-content,gap,padding] duration-300 ease-in-out",
28986
29067
  className
28987
29068
  ),
28988
29069
  children: [
29070
+ avatar,
29071
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col overflow-hidden", children: [
29072
+ /* @__PURE__ */ jsx("p", { className: "truncate typography-14 font-bold text-white", children: user.fullName }),
29073
+ /* @__PURE__ */ jsx("p", { className: "truncate typography-12 text-storm-gray-100", children: user.email })
29074
+ ] }),
28989
29075
  /* @__PURE__ */ jsx(
28990
- "div",
29076
+ "button",
28991
29077
  {
28992
- className: "flex size-11 shrink-0 items-center justify-center rounded-full bg-white/5 typography-14 font-bold text-white",
28993
- "aria-hidden": true,
28994
- children: initials
29078
+ type: "button",
29079
+ onClick: () => onLogout?.(),
29080
+ className: "shrink-0 cursor-pointer text-navy-150 transition-[opacity,transform] duration-300 ease-in-out hover:opacity-80 active:scale-95",
29081
+ "aria-label": logoutLabel,
29082
+ children: /* @__PURE__ */ jsx(LogOut, { size: 20, strokeWidth: 1.75 })
28995
29083
  }
28996
- ),
28997
- isOpen ? /* @__PURE__ */ jsxs(Fragment, { children: [
28998
- /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col overflow-hidden", children: [
28999
- /* @__PURE__ */ jsx("p", { className: "truncate typography-14 font-bold text-white", children: user.fullName }),
29000
- /* @__PURE__ */ jsx("p", { className: "truncate typography-12 text-storm-gray-100", children: user.email })
29001
- ] }),
29002
- /* @__PURE__ */ jsx(
29003
- "button",
29004
- {
29005
- type: "button",
29006
- onClick: () => onLogout?.(),
29007
- className: "shrink-0 cursor-pointer text-navy-150 transition-[opacity,transform] duration-300 ease-in-out hover:opacity-80 active:scale-95",
29008
- "aria-label": logoutLabel,
29009
- children: /* @__PURE__ */ jsx(LogOut, { size: 20, strokeWidth: 1.75 })
29010
- }
29011
- )
29012
- ] }) : null
29084
+ )
29013
29085
  ]
29014
29086
  }
29015
29087
  );
@@ -29167,18 +29239,8 @@ function Sidebar({
29167
29239
  ]
29168
29240
  }
29169
29241
  ),
29170
- /* @__PURE__ */ jsx("nav", { className: "flex flex-1 flex-col gap-2 overflow-y-auto overflow-x-hidden", children: visibleNavItems.map((item) => /* @__PURE__ */ jsx(
29171
- SidebarNavItem,
29172
- {
29173
- item,
29174
- isOpen: isExpanded,
29175
- isActive: isNavItemActive(pathname, item),
29176
- onNavigate: handleNavItemNavigate
29177
- },
29178
- item.to
29179
- )) }),
29180
- /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-4", children: [
29181
- visibleFooterNavItems.map((item) => /* @__PURE__ */ jsx(
29242
+ /* @__PURE__ */ jsxs("nav", { className: "flex w-full min-h-0 flex-1 flex-col gap-2 overflow-x-hidden overflow-y-auto", children: [
29243
+ visibleNavItems.map((item) => /* @__PURE__ */ jsx(
29182
29244
  SidebarNavItem,
29183
29245
  {
29184
29246
  item,
@@ -29188,15 +29250,27 @@ function Sidebar({
29188
29250
  },
29189
29251
  item.to
29190
29252
  )),
29191
- user ? /* @__PURE__ */ jsx(
29192
- SidebarUserCard,
29193
- {
29194
- user,
29195
- isOpen: isExpanded,
29196
- logoutLabel: labels.logout,
29197
- onLogout
29198
- }
29199
- ) : null
29253
+ /* @__PURE__ */ jsxs("div", { className: "mt-auto flex w-full flex-col gap-2", children: [
29254
+ visibleFooterNavItems.map((item) => /* @__PURE__ */ jsx(
29255
+ SidebarNavItem,
29256
+ {
29257
+ item,
29258
+ isOpen: isExpanded,
29259
+ isActive: isNavItemActive(pathname, item),
29260
+ onNavigate: handleNavItemNavigate
29261
+ },
29262
+ item.to
29263
+ )),
29264
+ user ? /* @__PURE__ */ jsx(
29265
+ SidebarUserCard,
29266
+ {
29267
+ user,
29268
+ isOpen: isExpanded,
29269
+ logoutLabel: labels.logout,
29270
+ onLogout
29271
+ }
29272
+ ) : null
29273
+ ] })
29200
29274
  ] })
29201
29275
  ]
29202
29276
  }