{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sidebar-layout",
  "title": "SidebarLayout",
  "description": "The shell of an app with a `Sidebar`: the sidebar beside the page from 640px up, in view while the page scrolls, and a sticky top bar with the sidebar's menu button below 640px.",
  "registryDependencies": [
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-env",
    "@ouro/lib-use-dev-messages"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/sidebar/sidebar-layout.tsx",
      "content": "\"use client\";\n\nimport { useId, useRef, type JSX, type ReactNode, type Ref } from \"react\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\n\n/** Props for {@link SidebarLayout}. */\nexport interface SidebarLayoutProps {\n  /**\n   * The app's `Sidebar`. It sits beside the page from 640px up, and is a menu button in the top bar below.\n   *\n   * @claim \"It sits beside the page from\" registry/ouro/components/ouro/sidebar/sidebar-layout.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar-layout.test.tsx::SidebarLayout > puts the sidebar's menu button in a bar across the top of a phone, with the header beside it)\n   * @claim \"It sits beside the page from\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > becomes a menu button that opens a drawer below 640px)\n   * @claim \"It sits beside the page from\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > hides the menu button from 640px up)\n   */\n  sidebar: ReactNode;\n  /**\n   * A bar above the page: a search field, the page's actions. From 640px up it runs across\n   * the top of the page, beside the sidebar; below, it shares the top bar with the menu button.\n   * It renders in a `<header>`, the page's banner landmark.\n   * @claim \"It renders in a `<header>`, the\" registry/ouro/components/ouro/sidebar/sidebar-layout.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar-layout.test.tsx::SidebarLayout > puts the header in the page's banner landmark, and draws no empty landmark without one)\n   * @claim \"From 640px up it runs across\" registry/ouro/components/ouro/sidebar/sidebar-layout.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar-layout.test.tsx::SidebarLayout > puts the sidebar's menu button in a bar across the top of a phone, with the header beside it)\n   * @claim \"From 640px up it runs across\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > becomes a menu button that opens a drawer below 640px)\n   */\n  header?: ReactNode;\n  /** The page. It renders inside the page's `<main>`. */\n  children: ReactNode;\n  /**\n   * The element around the page. Pass `\"div\"` when the layout renders inside a page that\n   * already has a `<main>`, since a document has one.\n   * @default \"main\"\n   */\n  as?: \"main\" | \"div\" | undefined;\n  /** Removes the padding around the page, for content that runs edge to edge (a map, a cover photo). */\n  bleed?: boolean | undefined;\n  /** The text of the link that skips the sidebar, shown when it has keyboard focus. @default \"Skip to content\" */\n  skipLabel?: string | undefined;\n  /** Layout only: height and margins (`min-h-96`). Appearance classes warn in development. */\n  className?: string | undefined;\n  ref?: Ref<HTMLDivElement> | undefined;\n\n  /** Not a prop. The bar above the page is `header`: `<SidebarLayout sidebar={…} header={…}>`. */\n  navbar?: { \"Use <SidebarLayout sidebar={...} header={...}>\": never };\n}\n\n// Class strings are literal so the app's Tailwind finds them when it compiles.\n\n// The first tab stop: hidden until it has keyboard focus, then shown at the top corner. Its size is\n// set in rem whether or not it has focus, so a hidden link never inherits a px size from its page.\nconst skipClass =\n  \"sr-only text-base leading-5 focus-visible:top-2 focus-visible:start-2 focus-visible:z-20 focus-visible:m-0 focus-visible:size-auto \" +\n  \"focus-visible:overflow-visible focus-visible:[clip-path:none] focus-visible:px-4 focus-visible:py-2.5 focus-visible:whitespace-nowrap \" +\n  \"focus-visible:rounded-ouro-lg focus-visible:bg-background focus-visible:text-foreground focus-visible:font-medium \" +\n  \"focus-visible:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring focus-visible:outline-solid\";\n\n// Two columns and two rows at every width. From 640px the sidebar spans both rows and\n// stays in view; below, it is the start of a sticky top bar and the page spans both columns.\nconst sidebarCell =\n  \"z-10 col-start-1 row-start-1 box-border bg-background \" +\n  \"max-sm:sticky max-sm:top-0 max-sm:flex max-sm:min-h-14 max-sm:items-center max-sm:border-0 max-sm:border-b max-sm:border-solid max-sm:border-border \" +\n  \"max-sm:ps-[max(0.5rem,env(safe-area-inset-left,0px))] sm:sticky sm:top-0 sm:row-span-2 sm:h-dvh\";\nconst headerCell =\n  \"sticky top-0 z-10 col-start-2 row-start-1 box-border flex min-w-0 items-center gap-2 border-0 border-b border-solid border-border bg-background \" +\n  \"ps-2 pe-[max(1rem,env(safe-area-inset-right,0px))] sm:ps-6\";\n\n/**\n * The shell of an app with a `Sidebar`: the sidebar beside the page from 640px up, in view\n * while the page scrolls, and a sticky top bar with the sidebar's menu button below 640px.\n * It renders the page's `<main>` and starts with a \"Skip to content\" link.\n *\n * The phone menu opens once JavaScript has loaded (after hydration);\n * the links are in the server HTML from 640px up.\n *\n * Use `StackedLayout` instead when the navigation is a `Navbar` across the top. Use\n * `AuthLayout` for the sign-in pages.\n *\n * @group Navigation\n * @see https://ui.ouroboros.bot/docs/sidebar-layout\n *\n * @example\n * <SidebarLayout\n *   sidebar={<Sidebar label=\"Main\" sections={sections} currentPath={pathname} />}\n *   header={<TextField label=\"Search\" hideLabel type=\"search\" />}\n * >\n *   <Outlet />\n * </SidebarLayout>\n * @claim \"The shell of an app with\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > becomes a menu button that opens a drawer below 640px)\n * @claim \"The shell of an app with\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > hides the menu button from 640px up)\n * @claim \"The shell of an app with\" registry/ouro/components/ouro/sidebar/sidebar-layout.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar-layout.test.tsx::SidebarLayout > puts the sidebar's menu button in a bar across the top of a phone, with the header beside it)\n * @claim \"The phone menu opens once JavaScript\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > puts the nav and its links in the server HTML)\n */\nexport function SidebarLayout(props: SidebarLayoutProps): JSX.Element {\n  const {\n    sidebar,\n    header,\n    children,\n    as,\n    bleed,\n    skipLabel = \"Skip to content\",\n    className,\n    ref,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    navbar,\n  } = props;\n  useAppearanceClassNameCheck(\n    \"SidebarLayout\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? (token: string) => `remove \"${token}\"; SidebarLayout sets its own look`\n      : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"SidebarLayout\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          sidebar === undefined && [\n            \"sidebar is required\",\n            '<SidebarLayout sidebar={<Sidebar label=\"Main\" sections={[…]} />}>; for a bar across the top use <StackedLayout navbar={…}>',\n          ],\n          navbar !== undefined && [\"navbar is not a prop; the bar above the page is header\", \"<SidebarLayout sidebar={<Sidebar … />} header={…}>\"],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  const mainId = useId();\n  const Page = as === \"div\" ? \"div\" : \"main\";\n  // The header is the page's banner landmark; without one, the cell only draws the phone's bar.\n  const Header = header !== undefined ? \"header\" : \"div\";\n  // The link's address moves focus by itself in most browsers; the handler makes it certain.\n  const main = useRef<HTMLDivElement>(null);\n  return (\n    <div\n      ref={ref}\n      data-ouro=\"sidebar-layout\"\n      className={cn(\"relative grid min-h-dvh grid-cols-[auto_minmax(0,1fr)] grid-rows-[auto_minmax(0,1fr)] bg-background text-foreground\", className)}\n    >\n      <a\n        href={`#${mainId}`}\n        data-ouro-control=\"sidebar-layout\"\n        data-ouro-part=\"skip-link\"\n        // Stryker disable next-line ArrowFunction: the link's address also moves focus, so an empty handler changes nothing a test can see.\n        onClick={() => main.current!.focus()}\n        className={skipClass}\n      >\n        {skipLabel}\n      </a>\n      <div data-ouro-sidebar-layout-sidebar=\"\" className={sidebarCell}>\n        {sidebar}\n      </div>\n      {/* Without a header the cell still draws the rest of the phone's top bar. */}\n      <Header data-ouro-sidebar-layout-header=\"\" className={cn(headerCell, header !== undefined ? \"min-h-14\" : \"sm:hidden\")}>\n        {header}\n      </Header>\n      <Page\n        ref={main}\n        id={mainId}\n        tabIndex={-1}\n        className={cn(\"col-span-2 row-start-2 box-border min-w-0 outline-none sm:col-span-1 sm:col-start-2\", !bleed && \"p-4 sm:p-6\")}\n      >\n        {children}\n      </Page>\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/sidebar/sidebar-layout.tsx"
    }
  ],
  "docs": "The shell of an app with a `Sidebar`: the sidebar beside the page from 640px up, in view while the page scrolls, and a sticky top bar with the sidebar's menu button below 640px. Import: import { SidebarLayout } from \"@/components/ouro/sidebar/sidebar-layout\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: the helpers it imports in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/sidebar-layout.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}