@algenium/blocks 1.2.0-rc.1 → 1.2.0-rc.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.d.cts CHANGED
@@ -573,9 +573,11 @@ interface ChatSidebarProps {
573
573
  labels?: ChatSidebarLabels;
574
574
  roleLabel?: (role: string) => string;
575
575
  roomTypeLabel?: (type: string) => string;
576
+ /** Top offset on mobile so the navbar stays visible (e.g. "3.5rem", "4rem"). */
577
+ mobileTopOffset?: string;
576
578
  className?: string;
577
579
  }
578
- declare function ChatSidebar({ currentUserId, config, labels, roleLabel, roomTypeLabel, className, }: ChatSidebarProps): react_jsx_runtime.JSX.Element | null;
580
+ declare function ChatSidebar({ currentUserId, config, labels, roleLabel, roomTypeLabel, mobileTopOffset, className, }: ChatSidebarProps): react_jsx_runtime.JSX.Element | null;
579
581
 
580
582
  declare const buttonVariants: (props?: ({
581
583
  variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
package/dist/index.d.ts CHANGED
@@ -573,9 +573,11 @@ interface ChatSidebarProps {
573
573
  labels?: ChatSidebarLabels;
574
574
  roleLabel?: (role: string) => string;
575
575
  roomTypeLabel?: (type: string) => string;
576
+ /** Top offset on mobile so the navbar stays visible (e.g. "3.5rem", "4rem"). */
577
+ mobileTopOffset?: string;
576
578
  className?: string;
577
579
  }
578
- declare function ChatSidebar({ currentUserId, config, labels, roleLabel, roomTypeLabel, className, }: ChatSidebarProps): react_jsx_runtime.JSX.Element | null;
580
+ declare function ChatSidebar({ currentUserId, config, labels, roleLabel, roomTypeLabel, mobileTopOffset, className, }: ChatSidebarProps): react_jsx_runtime.JSX.Element | null;
579
581
 
580
582
  declare const buttonVariants: (props?: ({
581
583
  variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
package/dist/index.js CHANGED
@@ -6118,7 +6118,8 @@ function ChatSidebarProvider({
6118
6118
  if (conv && conv.rooms.length === 1) {
6119
6119
  setActiveRoomId(conv.rooms[0].id);
6120
6120
  setView("chat");
6121
- } else if (conv && conv.rooms.length > 1) {
6121
+ } else {
6122
+ setActiveRoomId(null);
6122
6123
  setView("list");
6123
6124
  }
6124
6125
  }
@@ -6779,6 +6780,7 @@ function ChatSidebar({
6779
6780
  labels = {},
6780
6781
  roleLabel,
6781
6782
  roomTypeLabel,
6783
+ mobileTopOffset,
6782
6784
  className
6783
6785
  }) {
6784
6786
  const {
@@ -6792,17 +6794,37 @@ function ChatSidebar({
6792
6794
  selectRoom,
6793
6795
  back
6794
6796
  } = useChatSidebar();
6797
+ useEffect(() => {
6798
+ if (!isOpen || typeof window === "undefined") return;
6799
+ const mq = window.matchMedia("(max-width: 639px)");
6800
+ const apply = () => {
6801
+ if (mq.matches) document.body.style.overflow = "hidden";
6802
+ else document.body.style.overflow = "";
6803
+ };
6804
+ apply();
6805
+ mq.addEventListener("change", apply);
6806
+ return () => {
6807
+ mq.removeEventListener("change", apply);
6808
+ document.body.style.overflow = "";
6809
+ };
6810
+ }, [isOpen]);
6795
6811
  if (!isOpen) return null;
6796
6812
  const getRoomTypeLabel = (type) => {
6797
6813
  if (roomTypeLabel) return roomTypeLabel(type);
6798
6814
  return roomTypeLabels[type] ?? type;
6799
6815
  };
6800
6816
  const activeConversation = activeCaseId ? conversations.find((c) => c.caseId === activeCaseId) : null;
6801
- return /* @__PURE__ */ jsx(
6817
+ const cssVars = {
6818
+ "--sidebar-top": mobileTopOffset ?? "0px"
6819
+ };
6820
+ const panel = /* @__PURE__ */ jsx(
6802
6821
  "div",
6803
6822
  {
6823
+ style: cssVars,
6804
6824
  className: cn(
6805
- "flex h-full w-[360px] flex-col border-l bg-background xl:w-[400px]",
6825
+ "flex min-h-0 flex-col bg-background",
6826
+ "fixed top-[var(--sidebar-top)] right-0 bottom-0 left-0 z-[100] w-full max-w-none border-0 shadow-none",
6827
+ "sm:relative sm:inset-auto sm:z-auto sm:h-full sm:w-[360px] sm:max-w-[360px] sm:shrink-0 sm:border-l sm:shadow-none xl:w-[400px] xl:max-w-[400px]",
6806
6828
  className
6807
6829
  ),
6808
6830
  children: view === "list" ? /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -6897,6 +6919,18 @@ function ChatSidebar({
6897
6919
  ] })
6898
6920
  }
6899
6921
  );
6922
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
6923
+ /* @__PURE__ */ jsx(
6924
+ "div",
6925
+ {
6926
+ style: cssVars,
6927
+ className: "fixed top-[var(--sidebar-top)] right-0 bottom-0 left-0 z-[90] bg-black/50 sm:hidden",
6928
+ "aria-hidden": true,
6929
+ onClick: close
6930
+ }
6931
+ ),
6932
+ panel
6933
+ ] });
6900
6934
  }
6901
6935
  function formatRelativeTime(dateStr) {
6902
6936
  const date = new Date(dateStr);