2026-01-08 19:10:40 +02:00
|
|
|
"use client";
|
|
|
|
|
|
2026-02-06 18:59:52 +05:30
|
|
|
import { PanelRightClose, Plus } from "lucide-react";
|
2026-01-08 19:10:40 +02:00
|
|
|
import { Button } from "@/components/ui/button";
|
2026-02-06 18:35:29 +05:30
|
|
|
import { ScrollArea } from "@/components/ui/scroll-area";
|
2026-01-08 19:10:40 +02:00
|
|
|
import { Sheet, SheetContent, SheetTitle } from "@/components/ui/sheet";
|
2026-01-13 00:17:12 -08:00
|
|
|
import type { ChatItem, NavItem, PageUsage, SearchSpace, User } from "../../types/layout.types";
|
|
|
|
|
import { SearchSpaceAvatar } from "../icon-rail/SearchSpaceAvatar";
|
2026-01-08 19:10:40 +02:00
|
|
|
import { Sidebar } from "./Sidebar";
|
|
|
|
|
|
|
|
|
|
interface MobileSidebarProps {
|
|
|
|
|
isOpen: boolean;
|
|
|
|
|
onOpenChange: (open: boolean) => void;
|
2026-01-12 15:47:56 +02:00
|
|
|
searchSpaces: SearchSpace[];
|
|
|
|
|
activeSearchSpaceId: number | null;
|
|
|
|
|
onSearchSpaceSelect: (id: number) => void;
|
2026-01-13 01:45:58 -08:00
|
|
|
onSearchSpaceDelete?: (searchSpace: SearchSpace) => void;
|
|
|
|
|
onSearchSpaceSettings?: (searchSpace: SearchSpace) => void;
|
2026-01-12 15:47:56 +02:00
|
|
|
onAddSearchSpace: () => void;
|
|
|
|
|
searchSpace: SearchSpace | null;
|
2026-01-08 19:10:40 +02:00
|
|
|
navItems: NavItem[];
|
|
|
|
|
onNavItemClick?: (item: NavItem) => void;
|
|
|
|
|
chats: ChatItem[];
|
2026-01-13 00:17:12 -08:00
|
|
|
sharedChats?: ChatItem[];
|
2026-01-08 19:10:40 +02:00
|
|
|
activeChatId?: number | null;
|
|
|
|
|
onNewChat: () => void;
|
|
|
|
|
onChatSelect: (chat: ChatItem) => void;
|
2026-02-03 20:47:18 -05:00
|
|
|
onChatRename?: (chat: ChatItem) => void;
|
2026-01-08 19:10:40 +02:00
|
|
|
onChatDelete?: (chat: ChatItem) => void;
|
2026-01-24 15:17:35 +05:30
|
|
|
onChatArchive?: (chat: ChatItem) => void;
|
2026-01-13 00:17:12 -08:00
|
|
|
onViewAllSharedChats?: () => void;
|
|
|
|
|
onViewAllPrivateChats?: () => void;
|
2026-01-08 19:10:40 +02:00
|
|
|
user: User;
|
|
|
|
|
onSettings?: () => void;
|
2026-01-12 15:47:56 +02:00
|
|
|
onManageMembers?: () => void;
|
2026-01-12 17:22:05 +02:00
|
|
|
onUserSettings?: () => void;
|
2026-01-08 19:10:40 +02:00
|
|
|
onLogout?: () => void;
|
|
|
|
|
pageUsage?: PageUsage;
|
2026-01-20 16:04:56 +05:30
|
|
|
theme?: string;
|
|
|
|
|
setTheme?: (theme: "light" | "dark" | "system") => void;
|
2026-02-04 20:13:33 +05:30
|
|
|
isLoadingChats?: boolean;
|
2026-01-08 19:10:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function MobileSidebarTrigger({ onClick }: { onClick: () => void }) {
|
|
|
|
|
return (
|
|
|
|
|
<Button variant="ghost" size="icon" className="md:hidden h-8 w-8" onClick={onClick}>
|
2026-02-06 18:59:52 +05:30
|
|
|
<PanelRightClose className="h-5 w-5" />
|
2026-01-08 19:10:40 +02:00
|
|
|
<span className="sr-only">Open menu</span>
|
|
|
|
|
</Button>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function MobileSidebar({
|
|
|
|
|
isOpen,
|
|
|
|
|
onOpenChange,
|
2026-01-12 15:47:56 +02:00
|
|
|
searchSpaces,
|
|
|
|
|
activeSearchSpaceId,
|
|
|
|
|
onSearchSpaceSelect,
|
2026-01-13 01:45:58 -08:00
|
|
|
onSearchSpaceDelete,
|
|
|
|
|
onSearchSpaceSettings,
|
2026-01-12 15:47:56 +02:00
|
|
|
onAddSearchSpace,
|
|
|
|
|
searchSpace,
|
2026-01-08 19:10:40 +02:00
|
|
|
navItems,
|
|
|
|
|
onNavItemClick,
|
|
|
|
|
chats,
|
2026-01-13 00:17:12 -08:00
|
|
|
sharedChats,
|
2026-01-08 19:10:40 +02:00
|
|
|
activeChatId,
|
|
|
|
|
onNewChat,
|
|
|
|
|
onChatSelect,
|
2026-02-03 20:47:18 -05:00
|
|
|
onChatRename,
|
2026-01-08 19:10:40 +02:00
|
|
|
onChatDelete,
|
2026-01-24 15:17:35 +05:30
|
|
|
onChatArchive,
|
2026-01-13 00:17:12 -08:00
|
|
|
onViewAllSharedChats,
|
|
|
|
|
onViewAllPrivateChats,
|
2026-01-08 19:10:40 +02:00
|
|
|
user,
|
|
|
|
|
onSettings,
|
2026-01-12 15:47:56 +02:00
|
|
|
onManageMembers,
|
2026-01-12 17:22:05 +02:00
|
|
|
onUserSettings,
|
2026-01-08 19:10:40 +02:00
|
|
|
onLogout,
|
|
|
|
|
pageUsage,
|
2026-01-20 16:04:56 +05:30
|
|
|
theme,
|
|
|
|
|
setTheme,
|
2026-02-04 20:13:33 +05:30
|
|
|
isLoadingChats = false,
|
2026-01-08 19:10:40 +02:00
|
|
|
}: MobileSidebarProps) {
|
2026-01-12 15:47:56 +02:00
|
|
|
const handleSearchSpaceSelect = (id: number) => {
|
|
|
|
|
onSearchSpaceSelect(id);
|
2026-01-08 19:10:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleNavItemClick = (item: NavItem) => {
|
|
|
|
|
onNavItemClick?.(item);
|
|
|
|
|
onOpenChange(false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleChatSelect = (chat: ChatItem) => {
|
|
|
|
|
onChatSelect(chat);
|
|
|
|
|
onOpenChange(false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Sheet open={isOpen} onOpenChange={onOpenChange}>
|
2026-02-06 18:35:29 +05:30
|
|
|
<SheetContent side="left" className="w-[340px] p-0 flex flex-row gap-0 [&>button]:hidden">
|
2026-01-08 19:10:40 +02:00
|
|
|
<SheetTitle className="sr-only">Navigation</SheetTitle>
|
|
|
|
|
|
2026-02-06 18:35:29 +05:30
|
|
|
{/* Vertical Search Spaces Rail - left side */}
|
|
|
|
|
<div className="flex h-full w-14 shrink-0 flex-col items-center bg-muted/40 border-r">
|
|
|
|
|
<ScrollArea className="w-full flex-1">
|
|
|
|
|
<div className="flex flex-col items-center gap-2 px-1.5 py-3">
|
|
|
|
|
{searchSpaces.map((space) => (
|
2026-01-13 00:17:12 -08:00
|
|
|
<SearchSpaceAvatar
|
2026-02-06 18:35:29 +05:30
|
|
|
key={space.id}
|
2026-01-13 00:17:12 -08:00
|
|
|
name={space.name}
|
|
|
|
|
isActive={space.id === activeSearchSpaceId}
|
2026-01-13 01:45:58 -08:00
|
|
|
isShared={space.memberCount > 1}
|
|
|
|
|
isOwner={space.isOwner}
|
2026-01-13 00:17:12 -08:00
|
|
|
onClick={() => handleSearchSpaceSelect(space.id)}
|
|
|
|
|
size="md"
|
2026-02-06 18:35:29 +05:30
|
|
|
disableTooltip
|
2026-01-13 00:17:12 -08:00
|
|
|
/>
|
2026-02-06 18:35:29 +05:30
|
|
|
))}
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="icon"
|
|
|
|
|
onClick={onAddSearchSpace}
|
|
|
|
|
className="h-10 w-10 shrink-0 rounded-lg border-2 border-dashed border-muted-foreground/30 hover:border-muted-foreground/50"
|
|
|
|
|
>
|
|
|
|
|
<Plus className="h-5 w-5 text-muted-foreground" />
|
|
|
|
|
<span className="sr-only">Add search space</span>
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</ScrollArea>
|
2026-01-08 19:10:40 +02:00
|
|
|
</div>
|
|
|
|
|
|
2026-02-06 18:35:29 +05:30
|
|
|
{/* Sidebar Content - right side */}
|
2026-02-22 00:24:49 +05:30
|
|
|
<div className="flex-1 overflow-hidden flex flex-col [&>*]:!w-full">
|
2026-01-13 01:45:58 -08:00
|
|
|
<Sidebar
|
|
|
|
|
searchSpace={searchSpace}
|
|
|
|
|
isCollapsed={false}
|
2026-02-06 18:59:52 +05:30
|
|
|
onToggleCollapse={() => onOpenChange(false)}
|
2026-01-13 01:45:58 -08:00
|
|
|
navItems={navItems}
|
|
|
|
|
onNavItemClick={handleNavItemClick}
|
|
|
|
|
chats={chats}
|
|
|
|
|
sharedChats={sharedChats}
|
|
|
|
|
activeChatId={activeChatId}
|
|
|
|
|
onNewChat={() => {
|
|
|
|
|
onNewChat();
|
|
|
|
|
onOpenChange(false);
|
|
|
|
|
}}
|
|
|
|
|
onChatSelect={handleChatSelect}
|
2026-02-03 20:47:18 -05:00
|
|
|
onChatRename={onChatRename}
|
2026-01-13 01:45:58 -08:00
|
|
|
onChatDelete={onChatDelete}
|
2026-01-24 15:17:35 +05:30
|
|
|
onChatArchive={onChatArchive}
|
2026-02-06 23:35:02 +05:30
|
|
|
onViewAllSharedChats={
|
|
|
|
|
onViewAllSharedChats
|
|
|
|
|
? () => {
|
|
|
|
|
onOpenChange(false);
|
|
|
|
|
onViewAllSharedChats();
|
|
|
|
|
}
|
|
|
|
|
: undefined
|
|
|
|
|
}
|
|
|
|
|
onViewAllPrivateChats={
|
|
|
|
|
onViewAllPrivateChats
|
|
|
|
|
? () => {
|
|
|
|
|
onOpenChange(false);
|
|
|
|
|
onViewAllPrivateChats();
|
|
|
|
|
}
|
|
|
|
|
: undefined
|
|
|
|
|
}
|
2026-01-13 01:45:58 -08:00
|
|
|
user={user}
|
2026-03-08 20:34:12 +05:30
|
|
|
onSettings={
|
|
|
|
|
onSettings
|
|
|
|
|
? () => {
|
|
|
|
|
onOpenChange(false);
|
|
|
|
|
onSettings();
|
|
|
|
|
}
|
|
|
|
|
: undefined
|
|
|
|
|
}
|
|
|
|
|
onManageMembers={
|
|
|
|
|
onManageMembers
|
|
|
|
|
? () => {
|
|
|
|
|
onOpenChange(false);
|
|
|
|
|
onManageMembers();
|
|
|
|
|
}
|
|
|
|
|
: undefined
|
|
|
|
|
}
|
|
|
|
|
onUserSettings={
|
|
|
|
|
onUserSettings
|
|
|
|
|
? () => {
|
|
|
|
|
onOpenChange(false);
|
|
|
|
|
onUserSettings();
|
|
|
|
|
}
|
|
|
|
|
: undefined
|
|
|
|
|
}
|
2026-01-13 01:45:58 -08:00
|
|
|
onLogout={onLogout}
|
|
|
|
|
pageUsage={pageUsage}
|
2026-01-20 16:04:56 +05:30
|
|
|
theme={theme}
|
|
|
|
|
setTheme={setTheme}
|
2026-01-13 01:45:58 -08:00
|
|
|
className="w-full border-none"
|
2026-02-04 20:13:33 +05:30
|
|
|
isLoadingChats={isLoadingChats}
|
2026-02-06 18:59:52 +05:30
|
|
|
disableTooltips
|
2026-01-13 01:45:58 -08:00
|
|
|
/>
|
|
|
|
|
</div>
|
2026-01-08 19:10:40 +02:00
|
|
|
</SheetContent>
|
|
|
|
|
</Sheet>
|
|
|
|
|
);
|
|
|
|
|
}
|