import type { AnchorHTMLAttributes, ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react'; import type { SxProp } from '../Layout/sx.js'; export type SidebarWidth = 'thin' | 'default' | 'wide'; export interface SidebarProps extends HTMLAttributes { width?: SidebarWidth; sticky?: boolean; collapsed?: boolean; /** * Remember `collapsed` in localStorage under this key. The saved value is restored on * mount (shown immediately and reported via `onCollapsedChange`) and updated whenever * the `collapsed` prop changes. */ persistKey?: string; /** Called with the restored value when `persistKey` finds a saved state that differs from `collapsed`. */ onCollapsedChange?: (collapsed: boolean) => void; responsive?: boolean; /** * With `responsive`: below `mobileBreakpoint` the sidebar slides in from the start * edge (left, or right in RTL) as a drawer (over a backdrop) while this is true, * instead of being hidden. Open it from a menu button such as `NavbarToggle`. * Ignored at the breakpoint and wider. */ mobileOpen?: boolean; /** * With `responsive`: the viewport width in px at and below which the sidebar hides * (or becomes the `mobileOpen` drawer). Default `900`, which the core CSS applies with * a media query, so it is right on first paint. Any other value is applied from * `matchMedia` once mounted, so a server-rendered page shows the docked rail until * hydration. */ mobileBreakpoint?: number; /** * While `collapsed`, widen the rail to its full width when the pointer rests on it * (~150ms) or keyboard focus moves inside: an overlay over the page, which doesn't * move. It collapses again on pointer leave, Escape, or choosing an item. A view state * only: `collapsed` and `onCollapsedChange` are not touched. Default `false`. */ expandOnHover?: boolean; /** * Background. `'base'` (default) sits on the page tone; `'raised'` uses the * surface of drawers, dialogs and menus (white in light mode). */ surface?: 'base' | 'raised'; /** * Turns on the mobile drawer for a `responsive` sidebar. Called with `false` when * the backdrop is clicked or Escape is pressed. */ onMobileOpenChange?: (open: boolean) => void; /** * One-off CSS, same as `Box`'s `sx`: each value may be a scalar or a * responsive breakpoint map (`{ base, sm, md, lg, xl }`). Scalar-only sx * merges into inline style; responsive sx injects a scoped class. */ sx?: SxProp; children: ReactNode; } export interface SidebarHeaderProps extends HTMLAttributes { /** One-off CSS, same as `Box`'s `sx` (scalar or responsive `{ base, sm, md, lg, xl }` map). */ sx?: SxProp; children?: ReactNode; } export interface SidebarFooterProps extends HTMLAttributes { /** One-off CSS, same as `Box`'s `sx` (scalar or responsive `{ base, sm, md, lg, xl }` map). */ sx?: SxProp; children?: ReactNode; } export interface SidebarToggleProps extends Omit, 'onClick'> { collapsed?: boolean; onClick?: () => void; /** One-off CSS, same as `Box`'s `sx` (scalar or responsive `{ base, sm, md, lg, xl }` map). */ sx?: SxProp; } export interface SidebarSectionProps extends Omit, 'title'> { title?: ReactNode; /** * Make the title a button (chevron, `aria-expanded`, `aria-controls`) that shows and * hides the section's items. Needs a `title`. Ignored while the sidebar is the * collapsed icon rail, which always shows every item. Default `false`. */ collapsible?: boolean; /** With `collapsible`, uncontrolled: whether the section starts open. Default `true`. */ defaultOpen?: boolean; /** With `collapsible`, controlled: whether the section is open. Pair with `onOpenChange`. */ open?: boolean; /** With `collapsible`: called with the new state when the title is pressed. */ onOpenChange?: (open: boolean) => void; /** One-off CSS, same as `Box`'s `sx` (scalar or responsive `{ base, sm, md, lg, xl }` map). */ sx?: SxProp; children: ReactNode; } export interface SidebarItemProps extends AnchorHTMLAttributes { /** * Render the single child (e.g. Next ``) as the item instead of an ``, * so client-side routing and middle-click keep working. The child's own children * become the label. */ asChild?: boolean; active?: boolean; disabled?: boolean; icon?: ReactNode; badge?: ReactNode; /** Tooltip shown on the icon when the sidebar is collapsed. Defaults to the label when it is a string. */ tooltip?: ReactNode; /** One-off CSS, same as `Box`'s `sx` (scalar or responsive `{ base, sm, md, lg, xl }` map). */ sx?: SxProp; children: ReactNode; }