// // "use client"; import { type ReactNode } from "react"; import { Fragment } from "react/jsx-runtime"; import { SidebarGroupDto } from "~/application/sidebar/SidebarGroupDto"; import { SidebarGroup, SidebarGroupLabel, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, } from "~/components/ui/sidebar"; import SidebarIcon from "../../icons/SidebarIcon"; import { getUiIdAttributes } from "~/application/ui/uiRegistry"; type SidebarNavItem = SidebarGroupDto["items"][number]; function getEnabledItems(items: SidebarNavItem[] = []): SidebarNavItem[] { return items.filter((item) => !item.disabled); } function hasConfiguredChildren(item: SidebarNavItem) { return (item.items?.length ?? 0) > 0; } function SidebarLink({ to, children, ...props }: { to: string; children: ReactNode } & Record) { return ( {children} ); } function SidebarItemContent({ item }: { item: SidebarNavItem }) { return ( <> {item.icon !== undefined && } {item.title} ); } // Subframe SidebarWithSections is flat: a parent that groups children is a // (non-interactive) section header — like Subframe's NavSection label — with its // sub-items always visible beneath it. No collapse/accordion, no chevron, and // the parent is not a link (these parents never navigated; they were toggles). function NavMainExpandedItem({ item }: { item: SidebarNavItem }) { const subItems = getEnabledItems(item.items); return ( <>
{subItems.map((subItem) => ( {subItem.title} ))} ); } export function NavMain({ items }: { items: SidebarGroupDto[] }) { return ( {items.map((group, idxGroup) => ( {group.title && {group.title}} {getEnabledItems(group.items).map((item, idx) => { const enabledChildren = getEnabledItems(item.items); if (hasConfiguredChildren(item) && enabledChildren.length === 0) { return null; } return ( {enabledChildren.length === 0 ? ( ) : ( )} ); })} ))} ); }