"use client"; /* * Documentation: * Icon Button — https://app.subframe.com/f023064a5ca0/library?component=Icon+Button_af9405b1-8c54-4e01-9786-5aad308224f6 * Logo — https://app.subframe.com/f023064a5ca0/library?component=Logo_609493cb-7054-4018-bcb4-26d43de9ef41 * Sidebar with sections — https://app.subframe.com/f023064a5ca0/library?component=Sidebar+with+sections_f4047c8b-cfb4-4761-b9cf-fbcae8a9b9b5 */ import React from "react"; import { FeatherCircleDashed } from "@subframe/core"; import { FeatherSidebarClose } from "@subframe/core"; import { FeatherSidebarOpen } from "@subframe/core"; import * as SubframeCore from "@subframe/core"; import * as SubframeUtils from "../../utils"; import { useSidebarHoverSweep } from "../../sidebar-hover-sweep"; import { IconButton } from "../IconButton"; import { Logo } from "../Logo"; export interface NavItemProps extends React.HTMLAttributes { icon?: React.ReactNode; children?: React.ReactNode; selected?: boolean; variant?: "icon-and-text" | "icon-only" | "subitem"; className?: string; } const NavItem = React.forwardRef(function NavItem( { icon = , children, selected = false, variant = "icon-and-text", className, ...otherProps }: NavItemProps, ref ) { return (
{icon ? ( {icon} ) : null} {children ? ( {children} ) : null}
); }); export interface NavSectionProps extends React.HTMLAttributes { children?: React.ReactNode; label?: React.ReactNode; variant?: "default" | "subsection"; showLabel?: boolean; showDivider?: boolean; className?: string; } const NavSection = React.forwardRef(function NavSection( { children, label, variant = "default", showLabel = false, showDivider = false, className, ...otherProps }: NavSectionProps, ref ) { return (
{children ? (
{children}
) : null}
); }); export interface NavLabelProps extends React.HTMLAttributes { label?: React.ReactNode; className?: string; } const NavLabel = React.forwardRef(function NavLabel({ label, className, ...otherProps }: NavLabelProps, ref) { return (
{label ? {label} : null}
); }); export interface NavDividerProps extends React.HTMLAttributes { className?: string; } const NavDivider = React.forwardRef(function NavDivider({ className, ...otherProps }: NavDividerProps, ref) { return (
); }); export interface SubcomponentProps extends React.HTMLAttributes { sidebarButton?: "close" | "open"; buttonLabel?: string; onToggle?: () => void; className?: string; } const Subcomponent = React.forwardRef(function Subcomponent( { sidebarButton = "close", buttonLabel, onToggle, className, ...otherProps }: SubcomponentProps, ref ) { return (
: } aria-label={buttonLabel} onClick={onToggle} />
); }); export interface SidebarWithSectionsRootProps extends React.HTMLAttributes { variant?: "open" | "closed"; footer?: React.ReactNode; children?: React.ReactNode; className?: string; // @subframe/sync-disable -- local fix: Collapse-Toggle verdrahtbar machen (App steuert open/closed). onToggleCollapse?: () => void; // @subframe/sync-disable -- local fix: native collapse button needs an accessible, translated name. toggleLabel?: string; // @subframe/sync-disable -- local fix: make the logo a link (click -> dashboard, same target as the Dashboard nav item). logoHref?: string; // @subframe/sync-disable -- logo navigation needs the caller's translated accessible name. logoLabel?: string; // @subframe/sync-disable -- branded surfaces can replace the default mark without forking the canonical sidebar. logoContent?: React.ReactNode; // @subframe/sync-disable -- callback-owned surfaces keep logo navigation client-side. onLogoClick?: () => void; } const SidebarWithSectionsRoot = React.forwardRef(function SidebarWithSectionsRoot( { variant = "open", footer, children, className, onToggleCollapse, toggleLabel, logoHref, logoLabel, logoContent, onLogoClick, onPointerMove, onPointerLeave, ...otherProps }: SidebarWithSectionsRootProps, ref ) { const { handlePointerMove, handlePointerLeave } = useSidebarHoverSweep({ onPointerMove, onPointerLeave }); return ( ); }); export const SidebarWithSections = Object.assign(SidebarWithSectionsRoot, { NavItem, NavSection, NavLabel, NavDivider, Subcomponent, });