{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "app-sidebar",
  "title": "App Sidebar",
  "description": "The Notra dashboard sidebar: project switcher, search, grouped navigation with sub-rows and a rail flyout, and the account menu.",
  "dependencies": [
    "@hugeicons/core-free-icons",
    "@hugeicons/react",
    "cn"
  ],
  "registryDependencies": [
    "https://ui.usenotra.com/r/notra-sidebar.json",
    "https://ui.usenotra.com/r/notra-dropdown-menu.json",
    "avatar",
    "kbd"
  ],
  "files": [
    {
      "path": "registry/notra/app-sidebar/components/sidebar-nav.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"cn\";\n\nimport {\n  DropdownMenu,\n  DropdownMenuContent,\n  DropdownMenuGroup,\n  DropdownMenuItem,\n  DropdownMenuTrigger,\n} from \"../../dropdown-menu/components/dropdown-menu\";\nimport {\n  SidebarLabel,\n  SidebarMenu,\n  SidebarMenuButton,\n  SidebarMenuCollapsible,\n  SidebarMenuSub,\n  SidebarMenuSubButton,\n  SidebarMenuSubItem,\n  SidebarMenuSubPanel,\n} from \"../../sidebar/components/sidebar\";\nimport { SIDEBAR_NAV_BADGE_CLASS_NAME } from \"../constants/app-sidebar\";\nimport { useSidebarCollapseSettled } from \"../hooks/use-sidebar-settled\";\nimport type {\n  SidebarLinkRender,\n  SidebarNavGroup,\n  SidebarNavProps,\n} from \"../types/app-sidebar\";\n\nconst defaultLinkRender: SidebarLinkRender = ({ children, ...props }) => (\n  <a {...props}>{children}</a>\n);\n\nfunction NavBadge({ children }: { children?: string }) {\n  if (!children) {\n    return null;\n  }\n  return <span className={SIDEBAR_NAV_BADGE_CLASS_NAME}>{children}</span>;\n}\n\nfunction SidebarNavRow({\n  group,\n  activeHref,\n  linkRender,\n  collapsed,\n}: {\n  group: SidebarNavGroup;\n  activeHref?: string | null;\n  linkRender: SidebarLinkRender;\n  collapsed: boolean;\n}) {\n  const items = group.items ?? [];\n  const listsOwnPage = items.some((item) => item.href === group.href);\n  const groupActive =\n    group.href === activeHref || items.some((item) => item.href === activeHref);\n  const ownPageActive = group.href === activeHref && !listsOwnPage;\n\n  if (collapsed && items.length > 0) {\n    const flyoutItems = listsOwnPage ? items : [group, ...items];\n\n    return (\n      <SidebarMenuCollapsible>\n        <DropdownMenu>\n          <DropdownMenuTrigger\n            render={\n              <SidebarMenuButton\n                aria-label={group.title}\n                isActive={groupActive}\n              >\n                {group.icon}\n                <SidebarLabel>{group.title}</SidebarLabel>\n              </SidebarMenuButton>\n            }\n          />\n          <DropdownMenuContent className=\"min-w-48\" side=\"right\" align=\"start\">\n            <DropdownMenuGroup>\n              {flyoutItems.map((item) => (\n                <DropdownMenuItem\n                  key={item.href}\n                  nativeButton={false}\n                  render={(props) => linkRender({ ...props, href: item.href })}\n                  aria-current={item.href === activeHref ? \"page\" : undefined}\n                  className=\"aria-[current=page]:font-medium\"\n                >\n                  <span className=\"min-w-0 flex-1 truncate\">{item.title}</span>\n                  <NavBadge>{item.badge}</NavBadge>\n                </DropdownMenuItem>\n              ))}\n            </DropdownMenuGroup>\n          </DropdownMenuContent>\n        </DropdownMenu>\n      </SidebarMenuCollapsible>\n    );\n  }\n\n  return (\n    <SidebarMenuCollapsible open={groupActive && items.length > 0}>\n      <SidebarMenuButton\n        isActive={ownPageActive}\n        aria-current={ownPageActive ? \"page\" : undefined}\n        className={cn(\n          groupActive && !ownPageActive && \"text-foreground font-medium\"\n        )}\n        render={(props) => linkRender({ ...props, href: group.href })}\n        tooltip={group.title}\n      >\n        {group.icon}\n        <SidebarLabel>{group.title}</SidebarLabel>\n        <NavBadge>\n          {groupActive && items.length > 0 ? undefined : group.badge}\n        </NavBadge>\n      </SidebarMenuButton>\n      {items.length > 0 ? (\n        <SidebarMenuSubPanel>\n          <SidebarMenuSub>\n            {items.map((item) => (\n              <SidebarMenuSubItem key={item.href}>\n                <SidebarMenuSubButton\n                  isActive={item.href === activeHref}\n                  aria-current={item.href === activeHref ? \"page\" : undefined}\n                  render={(props) => linkRender({ ...props, href: item.href })}\n                >\n                  <span>{item.title}</span>\n                  <NavBadge>{item.badge}</NavBadge>\n                </SidebarMenuSubButton>\n              </SidebarMenuSubItem>\n            ))}\n          </SidebarMenuSub>\n        </SidebarMenuSubPanel>\n      ) : null}\n    </SidebarMenuCollapsible>\n  );\n}\n\n/**\n * Grouped navigation from the Notra dashboard. Each row reveals its related\n * pages while one of them is active. Collapsed to the icon rail, rows keep a\n * tooltip and rows with pages open them in a flyout menu.\n */\nexport function SidebarNav({\n  groups,\n  activeHref,\n  linkRender = defaultLinkRender,\n  className,\n}: SidebarNavProps) {\n  const collapsed = useSidebarCollapseSettled();\n\n  return (\n    <SidebarMenu className={className}>\n      {groups.map((group) => (\n        <SidebarNavRow\n          key={group.href}\n          activeHref={activeHref}\n          collapsed={collapsed}\n          group={group}\n          linkRender={linkRender}\n        />\n      ))}\n    </SidebarMenu>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/app-sidebar/components/sidebar-nav.tsx"
    },
    {
      "path": "registry/notra/app-sidebar/components/sidebar-search.tsx",
      "content": "\"use client\";\n\nimport { SearchIcon } from \"@hugeicons/core-free-icons\";\nimport { HugeiconsIcon } from \"@hugeicons/react\";\n\nimport { Kbd } from \"@/components/ui/kbd\";\n\nimport {\n  SidebarLabel,\n  SidebarMenu,\n  SidebarMenuButton,\n  SidebarMenuItem,\n} from \"../../sidebar/components/sidebar\";\nimport type { SidebarSearchProps } from \"../types/app-sidebar\";\n\n/**\n * A search row styled like a field that opens your command palette. On the\n * icon rail it becomes a plain icon button with a tooltip.\n */\nexport function SidebarSearch({\n  label = \"Search\",\n  shortcut = \"⌘K\",\n  onClick,\n}: SidebarSearchProps) {\n  return (\n    <SidebarMenu>\n      <SidebarMenuItem>\n        <SidebarMenuButton\n          aria-label={label}\n          aria-keyshortcuts={shortcut === \"⌘K\" ? \"Meta+K\" : undefined}\n          className=\"border-sidebar-border text-muted-foreground hover:text-sidebar-foreground group-data-[collapsible=icon]:text-sidebar-foreground h-9 cursor-pointer rounded-lg border transition-[height] group-data-[collapsible=icon]:h-8 group-data-[collapsible=icon]:border-transparent\"\n          onClick={onClick}\n          tooltip={label}\n        >\n          <HugeiconsIcon icon={SearchIcon} />\n          <SidebarLabel>{`${label}…`}</SidebarLabel>\n          {shortcut ? (\n            <Kbd className=\"border-sidebar-border ml-auto rounded-[5px] border bg-transparent px-1.5\">\n              {shortcut}\n            </Kbd>\n          ) : null}\n        </SidebarMenuButton>\n      </SidebarMenuItem>\n    </SidebarMenu>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/app-sidebar/components/sidebar-search.tsx"
    },
    {
      "path": "registry/notra/app-sidebar/components/sidebar-switcher.tsx",
      "content": "\"use client\";\n\nimport { UnfoldMoreIcon } from \"@hugeicons/core-free-icons\";\nimport { HugeiconsIcon } from \"@hugeicons/react\";\nimport type { ReactNode } from \"react\";\n\nimport {\n  DropdownMenu,\n  DropdownMenuContent,\n  DropdownMenuGroup,\n  DropdownMenuLabel,\n  DropdownMenuRadioGroup,\n  DropdownMenuRadioItem,\n  DropdownMenuSeparator,\n  DropdownMenuTrigger,\n} from \"../../dropdown-menu/components/dropdown-menu\";\nimport {\n  SidebarLabel,\n  SidebarMenu,\n  SidebarMenuButton,\n  SidebarMenuItem,\n  useSidebar,\n} from \"../../sidebar/components/sidebar\";\nimport type { SidebarSwitcherProps } from \"../types/app-sidebar\";\n\n/**\n * The project switcher at the top of the sidebar. Put the trigger beside it\n * with `SidebarHeaderRow`, which moves it under the switcher when collapsed.\n */\nexport function SidebarSwitcher({\n  options,\n  value,\n  onValueChange,\n  label = \"Projects\",\n  actions,\n}: SidebarSwitcherProps) {\n  const active = options.find((option) => option.value === value) ?? options[0];\n  if (!active) {\n    return null;\n  }\n\n  return (\n    <SidebarMenu>\n      <SidebarMenuItem>\n        <DropdownMenu>\n          <DropdownMenuTrigger\n            render={\n              <SidebarMenuButton\n                size=\"lg\"\n                tooltip={active.label}\n                className=\"data-popup-open:bg-sidebar-accent cursor-pointer [--sidebar-lg-icon:1.75rem]\"\n              />\n            }\n          >\n            <SwitcherIcon>{active.icon}</SwitcherIcon>\n            <div className=\"grid min-w-0 flex-1 leading-tight\">\n              <SidebarLabel className=\"text-sm font-medium\">\n                {active.label}\n              </SidebarLabel>\n              {active.description ? (\n                <SidebarLabel className=\"text-muted-foreground text-xs\">\n                  {active.description}\n                </SidebarLabel>\n              ) : null}\n            </div>\n            <HugeiconsIcon\n              className=\"text-muted-foreground ml-auto\"\n              icon={UnfoldMoreIcon}\n            />\n          </DropdownMenuTrigger>\n          <DropdownMenuContent className=\"min-w-56\" align=\"start\">\n            <DropdownMenuGroup>\n              <DropdownMenuLabel>{label}</DropdownMenuLabel>\n              <DropdownMenuRadioGroup\n                value={value}\n                onValueChange={onValueChange}\n              >\n                {options.map((option) => (\n                  <DropdownMenuRadioItem\n                    key={option.value}\n                    value={option.value}\n                  >\n                    <SwitcherIcon small>{option.icon}</SwitcherIcon>\n                    <span className=\"min-w-0 flex-1 truncate\">\n                      {option.label}\n                    </span>\n                  </DropdownMenuRadioItem>\n                ))}\n              </DropdownMenuRadioGroup>\n            </DropdownMenuGroup>\n            {actions ? (\n              <>\n                <DropdownMenuSeparator />\n                {actions}\n              </>\n            ) : null}\n          </DropdownMenuContent>\n        </DropdownMenu>\n      </SidebarMenuItem>\n    </SidebarMenu>\n  );\n}\n\nfunction SwitcherIcon({\n  children,\n  small = false,\n}: {\n  children?: ReactNode;\n  small?: boolean;\n}) {\n  return (\n    <span\n      className={\n        small\n          ? \"bg-sidebar-accent flex size-5 shrink-0 items-center justify-center overflow-hidden rounded-md text-[0.625rem] font-semibold\"\n          : \"bg-sidebar-accent flex size-7 shrink-0 items-center justify-center overflow-hidden rounded-lg text-xs font-semibold\"\n      }\n    >\n      {children}\n    </span>\n  );\n}\n\n/**\n * Holds the switcher with the sidebar trigger. The trigger sits beside the\n * switcher while expanded and moves below it on the icon rail, animated with\n * the sidebar width instead of jumping when the header reflows.\n */\nexport function SidebarHeaderRow({\n  children,\n  trigger,\n}: {\n  children: ReactNode;\n  trigger: ReactNode;\n}) {\n  const { isMobile } = useSidebar();\n  if (isMobile) {\n    return children;\n  }\n\n  return (\n    <div className=\"relative pr-8 transition-[padding] duration-(--sidebar-duration) ease-(--sidebar-ease) group-data-[collapsible=icon]:pr-0 group-data-[collapsible=icon]:pb-8 motion-reduce:transition-none\">\n      {children}\n      <div className=\"absolute top-2.5 left-[calc(100%-1.75rem)] flex transition-[left,top] duration-(--sidebar-duration) ease-(--sidebar-ease) group-data-[collapsible=icon]:top-13 group-data-[collapsible=icon]:left-0.5 motion-reduce:transition-none\">\n        {trigger}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/app-sidebar/components/sidebar-switcher.tsx"
    },
    {
      "path": "registry/notra/app-sidebar/components/sidebar-user-menu.tsx",
      "content": "\"use client\";\n\nimport { Avatar, AvatarFallback, AvatarImage } from \"@/components/ui/avatar\";\n\nimport {\n  DropdownMenu,\n  DropdownMenuContent,\n  DropdownMenuSeparator,\n  DropdownMenuTrigger,\n} from \"../../dropdown-menu/components/dropdown-menu\";\nimport {\n  SidebarMenu,\n  SidebarMenuButton,\n  SidebarMenuItem,\n  useSidebar,\n} from \"../../sidebar/components/sidebar\";\nimport type { SidebarUserMenuProps } from \"../types/app-sidebar\";\n\n/** The account row at the bottom of the sidebar with its menu. */\nexport function SidebarUserMenu({\n  name,\n  email,\n  avatarSrc,\n  children,\n}: SidebarUserMenuProps) {\n  const { isMobile, state } = useSidebar();\n  let side: \"bottom\" | \"right\" | \"top\" = \"top\";\n  if (isMobile) {\n    side = \"bottom\";\n  } else if (state === \"collapsed\") {\n    side = \"right\";\n  }\n\n  return (\n    <SidebarMenu>\n      <SidebarMenuItem>\n        <DropdownMenu>\n          <DropdownMenuTrigger\n            render={\n              <SidebarMenuButton\n                size=\"lg\"\n                tooltip={name}\n                className=\"data-popup-open:bg-sidebar-accent/90 data-popup-open:text-sidebar-accent-foreground data-popup-open:ring-sidebar-border/70 min-w-0 cursor-pointer group-data-[collapsible=icon]:bg-transparent! group-data-[collapsible=icon]:ring-0! data-popup-open:ring-1\"\n              />\n            }\n          >\n            <Avatar className=\"size-8 shrink-0 rounded-lg transition-opacity group-data-[collapsible=icon]:group-hover/menu-button:opacity-80 after:rounded-lg\">\n              {avatarSrc ? (\n                <AvatarImage className=\"rounded-lg\" src={avatarSrc} alt=\"\" />\n              ) : null}\n              <AvatarFallback className=\"bg-sidebar-accent rounded-lg\">\n                {name.trim().charAt(0).toUpperCase()}\n              </AvatarFallback>\n            </Avatar>\n            <span className=\"min-w-0 flex-1 truncate text-left text-sm font-medium\">\n              {name}\n            </span>\n          </DropdownMenuTrigger>\n          <DropdownMenuContent\n            align=\"start\"\n            className=\"w-64\"\n            side={side}\n            sideOffset={6}\n          >\n            <div className=\"grid gap-0.5 px-2 py-1.5\">\n              <span className=\"truncate text-sm font-medium\">{name}</span>\n              {email ? (\n                <span className=\"text-muted-foreground truncate text-xs\">\n                  {email}\n                </span>\n              ) : null}\n            </div>\n            <DropdownMenuSeparator />\n            {children}\n          </DropdownMenuContent>\n        </DropdownMenu>\n      </SidebarMenuItem>\n    </SidebarMenu>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/app-sidebar/components/sidebar-user-menu.tsx"
    },
    {
      "path": "registry/notra/app-sidebar/constants/app-sidebar.ts",
      "content": "/** Matches `--sidebar-duration`, the width transition of the sidebar. */\nexport const SIDEBAR_COLLAPSE_MS = 300;\n\nexport const SIDEBAR_NAV_BADGE_CLASS_NAME =\n  \"bg-secondary text-muted-foreground ml-auto inline-flex h-[1.125rem] shrink-0 items-center rounded-full px-1.5 text-[0.625rem] font-medium\";\n",
      "type": "registry:lib",
      "target": "components/app-sidebar/constants/app-sidebar.ts"
    },
    {
      "path": "registry/notra/app-sidebar/hooks/use-sidebar-settled.ts",
      "content": "import { useEffect, useState } from \"react\";\n\nimport { useSidebar } from \"../../sidebar/components/sidebar\";\nimport { SIDEBAR_COLLAPSE_MS } from \"../constants/app-sidebar\";\n\n/**\n * True once the sidebar has finished collapsing to the icon rail. Swapping\n * sub-rows for a flyout any earlier would cut their fold-away animation.\n */\nexport function useSidebarCollapseSettled() {\n  const { isMobile, state } = useSidebar();\n  const collapsed = state === \"collapsed\" && !isMobile;\n  const [settled, setSettled] = useState(collapsed);\n\n  useEffect(() => {\n    if (!collapsed) {\n      setSettled(false);\n      return;\n    }\n    const timeout = window.setTimeout(\n      () => setSettled(true),\n      SIDEBAR_COLLAPSE_MS\n    );\n    return () => window.clearTimeout(timeout);\n  }, [collapsed]);\n\n  return collapsed && settled;\n}\n",
      "type": "registry:hook",
      "target": "components/app-sidebar/hooks/use-sidebar-settled.ts"
    },
    {
      "path": "registry/notra/app-sidebar/hooks/use-scroll-more.ts",
      "content": "import { useCallback, useEffect, useState } from \"react\";\n\n/**\n * True while a scroll container has content below its visible area, so the\n * sidebar can fade the last rows into the footer instead of cutting them off.\n */\nexport function useScrollMore<T extends HTMLElement>() {\n  const [element, setElement] = useState<T | null>(null);\n  const [hasMore, setHasMore] = useState(false);\n\n  const update = useCallback(() => {\n    if (!element) {\n      return;\n    }\n    const { clientHeight, scrollHeight, scrollTop } = element;\n    setHasMore(scrollTop + clientHeight < scrollHeight - 1);\n  }, [element]);\n\n  useEffect(() => {\n    if (!element) {\n      return;\n    }\n    update();\n    element.addEventListener(\"scroll\", update, { passive: true });\n    const observer = new ResizeObserver(update);\n    observer.observe(element);\n    for (const child of element.children) {\n      observer.observe(child);\n    }\n    return () => {\n      element.removeEventListener(\"scroll\", update);\n      observer.disconnect();\n    };\n  }, [element, update]);\n\n  return { hasMore, ref: setElement };\n}\n",
      "type": "registry:hook",
      "target": "components/app-sidebar/hooks/use-scroll-more.ts"
    },
    {
      "path": "registry/notra/app-sidebar/types/app-sidebar.ts",
      "content": "import type { ComponentProps, ReactElement, ReactNode } from \"react\";\n\nexport interface SidebarNavLink {\n  title: string;\n  href: string;\n  /** A short tag after the label, such as \"Beta\". */\n  badge?: string;\n}\n\n/**\n * One row per job. The row opens `href`, and its `items` are revealed\n * underneath while the row or one of them is the active page. In the\n * collapsed rail a row with items opens them in a flyout instead.\n */\nexport interface SidebarNavGroup extends SidebarNavLink {\n  /** A 16px icon element, such as `<HugeiconsIcon icon={Home01Icon} />`. */\n  icon: ReactNode;\n  items?: readonly SidebarNavLink[];\n}\n\n/**\n * Renders a row's link. Spread the props onto your router's link, for example\n * `({ href, ...props }) => <Link {...props} to={href} />`.\n */\nexport type SidebarLinkRender = (\n  props: ComponentProps<\"a\"> & { href: string }\n) => ReactElement;\n\nexport interface SidebarNavProps {\n  groups: readonly SidebarNavGroup[];\n  activeHref?: string | null;\n  linkRender?: SidebarLinkRender;\n  className?: string;\n}\n\nexport interface SidebarSwitcherOption {\n  value: string;\n  label: string;\n  description?: string;\n  /** A 28px square, such as a logo or an initial. */\n  icon?: ReactNode;\n}\n\nexport interface SidebarSwitcherProps {\n  options: readonly SidebarSwitcherOption[];\n  value: string;\n  onValueChange: (value: string) => void;\n  /** Heading above the options in the menu. */\n  label?: string;\n  /** Extra menu items under the options, such as \"New project\". */\n  actions?: ReactNode;\n}\n\nexport interface SidebarSearchProps {\n  label?: string;\n  shortcut?: string;\n  onClick?: () => void;\n}\n\nexport interface SidebarUserMenuProps {\n  name: string;\n  /** Shown under the name at the top of the menu. */\n  email?: string;\n  avatarSrc?: string;\n  /** Menu items. */\n  children: ReactNode;\n}\n",
      "type": "registry:lib",
      "target": "components/app-sidebar/types/app-sidebar.ts"
    }
  ],
  "type": "registry:block"
}