"use client"; import { BadgeCheck, BarChart3, Briefcase, ChevronRight, ChevronsUpDown, ClipboardList, Clock3, FileText, Folder, Globe2, HelpCircle, LayoutDashboard, LogOut, Settings, Sparkles, Star, User, Users, } from "lucide-react"; import * as React from "react"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "@/components/ui/collapsible"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarTrigger, useSidebar, } from "@/components/ui/sidebar"; import { cn } from "@/lib/utils"; // Base nav item - used by simple sidebars type NavItem = { label: string; icon: React.ComponentType>; href: string; isActive?: boolean; // Optional children for submenus (Sidebar3+) children?: NavItem[]; }; // Nav group with optional collapsible state type NavGroup = { title: string; items: NavItem[]; // Optional: default collapsed state (Sidebar2+) defaultOpen?: boolean; }; // User data for footer (Sidebar6+) type UserData = { name: string; email: string; avatar: string; }; // Complete sidebar data structure type SidebarData = { // Logo/branding (all sidebars) logo: { src: string; alt: string; title: string; description: string; }; // Main navigation groups (all sidebars) navGroups: NavGroup[]; // Footer navigation group (all sidebars) footerGroup: NavGroup; // User data for user footer (Sidebar6+) user?: UserData; // Workspaces for switcher (Sidebar7+) workspaces?: Array<{ id: string; name: string; logo: string; plan: string; }>; // Currently active workspace (Sidebar7+) activeWorkspace?: string; }; // Shared sidebar data - works with all sidebar variations const sidebarData: SidebarData = { logo: { src: "/block-media/shadcnblocks/block/logos/NovaSales-logo.svg", alt: "شاد‌سی‌ان بلاکس", title: "NovaSales", description: "اپلیکیشن خود را بسازید", }, navGroups: [ { title: "نمای کلی", defaultOpen: true, items: [ { label: "داشبورد", icon: LayoutDashboard, href: "#", isActive: true, }, { label: "وظایف", icon: ClipboardList, href: "#" }, { label: "نقشه راه", icon: BarChart3, href: "#" }, ], }, { title: "پروژه‌ها", defaultOpen: true, items: [ { label: "پروژه‌های فعال", icon: Briefcase, href: "#", children: [ { label: "پروژه آلفا", icon: FileText, href: "#" }, { label: "پروژه بتا", icon: FileText, href: "#" }, { label: "پروژه گاما", icon: FileText, href: "#" }, ], }, { label: "بایگانی", icon: Folder, href: "#", children: [ { label: "بایگانی ۲۲۴", icon: FileText, href: "#" }, { label: "بایگانی ۲۲۳", icon: FileText, href: "#" }, ], }, ], }, { title: "تیم", defaultOpen: false, items: [ { label: "اعضا", icon: Users, href: "#" }, { label: "اسپرینت‌ها", icon: Clock3, href: "#" }, { label: "تأییدها", icon: BadgeCheck, href: "#" }, { label: "بازبینی‌ها", icon: Star, href: "#" }, ], }, { title: "فضای کار", defaultOpen: false, items: [ { label: "یکپارچه‌سازی‌ها", icon: Globe2, href: "#" }, { label: "خودکارسازی‌ها", icon: Sparkles, href: "#" }, ], }, ], footerGroup: { title: "پشتیبانی", items: [ { label: "راهنمای اعضای تیم", icon: HelpCircle, href: "#" }, { label: "تنظیمات", icon: Settings, href: "#" }, ], }, user: { name: "علی رضایی", email: "ali@example.com", avatar: "/block-media/shadcnblocks/block/avatar-8.webp", }, workspaces: [ { id: "1", name: "NovaSales", logo: "/block-media/shadcnblocks/block/logos/NovaSales-logo.svg", plan: "سازمانی", }, { id: "2", name: "ری یو آی قالب‌ها", logo: "/block-media/shadcnblocks/block/logos/NovaSales-logo.svg", plan: "استارتاپ", }, { id: "3", name: "ری یو آی بخش‌ها", logo: "/block-media/shadcnblocks/block/logos/NovaSales-logo.svg", plan: "رایگان", }, ], activeWorkspace: "1", }; const NavMenuItem = ({ item }: { item: NavItem }) => { const Icon = item.icon; const hasChildren = item.children && item.children.length > 0; if (hasChildren) { return ( {item.label} {item.children!.map((child) => { const ChildIcon = child.icon; return ( {child.label} ); })} ); } return ( {item.label} ); }; const NavUser = ({ user }: { user: UserData }) => { return ( {user.name .split(" ") .map((n) => n[0]) .join("")}
{user.name} {user.email}
{user.name .split(" ") .map((n) => n[0]) .join("")}
{user.name} {user.email}
حساب کاربری خروج
); }; // Module tabs (top bar navigation) interface ModuleTabsProps { className?: string; groups: NavGroup[]; activeGroupIndex: number; onChange: (index: number) => void; } const ModuleTabs = ({ className, groups, activeGroupIndex, onChange, }: ModuleTabsProps) => { return ( ); }; // Mobile bottom navigation interface MobileBottomNavProps { className?: string; groups: NavGroup[]; activeGroupIndex: number; onChange: (index: number) => void; } const MobileBottomNav = ({ className, groups, activeGroupIndex, onChange, }: MobileBottomNavProps) => { const { setOpenMobile } = useSidebar(); return ( ); }; interface AppSidebarProps extends React.ComponentProps { activeGroupIndex: number; } const AppSidebar = ({ activeGroupIndex, ...props }: AppSidebarProps) => { const activeGroup = sidebarData.navGroups[activeGroupIndex]; const { isMobile } = useSidebar(); return (
{isMobile ? (
{sidebarData.logo.alt}
{sidebarData.logo.title}
) : ( {activeGroup.title} )}
{activeGroup.title} {activeGroup.items.map((item) => ( ))} {/* Footer group items */} {sidebarData.footerGroup.title} {sidebarData.footerGroup.items.map((item) => { const Icon = item.icon; return ( {item.label} ); })} {sidebarData.user && }
); }; interface ApplicationShell5Props { className?: string; } const ApplicationShell5 = ({ className }: ApplicationShell5Props) => { const [activeGroupIndex, setActiveGroupIndex] = React.useState(0); const activeGroup = sidebarData.navGroups[activeGroupIndex]; return (
{sidebarData.logo.alt}
{sidebarData.logo.title}
{activeGroup.title}
); }; export { ApplicationShell5 };