{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "docs-layout",
  "title": "Docs Layout",
  "description": "A documentation screen from a list of pages: nav, page and table of contents, one column for a short guide, or text beside its code. Collapses on phones.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "utils",
    "https://miseui.junsu4621.workers.dev/r/code-block.json",
    "https://miseui.junsu4621.workers.dev/r/collapsible.json",
    "https://miseui.junsu4621.workers.dev/r/sidebar.json",
    "https://miseui.junsu4621.workers.dev/r/table-of-contents.json"
  ],
  "files": [
    {
      "path": "registry/miseui/blocks/docs-layout.tsx",
      "content": "import type * as React from \"react\"\nimport { DocsCentered } from \"./docs-layout-centered\"\nimport { DocsReference } from \"./docs-layout-reference\"\nimport { SAMPLE_GROUPS } from \"./docs-layout-sample\"\nimport { DocsSidebar } from \"./docs-layout-sidebar\"\nimport { useDocsPages, type DocsCode, type DocsGroup, type DocsPage, type DocsSection } from \"./docs-layout-state\"\n\ntype DocsLayoutVariant = \"sidebar\" | \"centered\" | \"reference\"\n\ninterface DocsLayoutProps extends React.ComponentProps<\"section\"> {\n  /** `sidebar` nav, page and table of contents, `centered` one column for a short guide, `reference` text beside its code. Anything else is `sidebar`. */\n  variant?: DocsLayoutVariant\n  /** Pages in their nav groups. `centered` and `reference` show no group list, and move between pages with the links at the end. */\n  groups?: readonly DocsGroup[]\n  /** The page showing, if your router owns it. */\n  current?: string\n  defaultCurrent?: string\n  /** Fires when someone picks a page. Pages with an `href` still follow the link. */\n  onNavigate?: (id: string) => void\n  brandName?: React.ReactNode\n  brandHref?: string\n}\n\n/** `sidebar` and `reference` scroll inside themselves at a fixed height. Set the height through className, for example h-dvh. */\nfunction DocsLayout({ variant, groups = SAMPLE_GROUPS, current, defaultCurrent, onNavigate, brandName = \"Paperline docs\", brandHref = \"#docs\", ...props }: DocsLayoutProps) {\n  const docs = useDocsPages({ groups, current, defaultCurrent, onNavigate })\n  const shared = { docs, brandName, brandHref, ...props }\n  if (variant === \"centered\") return <DocsCentered {...shared} />\n  if (variant === \"reference\") return <DocsReference {...shared} />\n  return <DocsSidebar {...shared} groups={groups} />\n}\n\nexport { DocsLayout, type DocsCode, type DocsGroup, type DocsLayoutProps, type DocsLayoutVariant, type DocsPage, type DocsSection }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/docs-layout-centered.tsx",
      "content": "import { cn } from \"@/registry/miseui/lib/utils\"\r\nimport { TableOfContents } from \"@/registry/miseui/ui/table-of-contents\"\r\nimport { DocsBrand, DocsEmpty, DocsPager, DocsTopBar, PageHeading, SectionCode, SectionText } from \"./docs-layout-parts\"\r\nimport { usePageArrival } from \"./docs-layout-state\"\r\nimport type { DocsCommonProps } from \"./docs-layout-sidebar\"\r\n\r\n/** The sticky bar's 56 px plus a little air, so a heading does not land under it after a jump. */\r\nconst BAR_OFFSET_PX = 72\r\n\r\n/** One column and no chrome, for a short guide read once from top to bottom. The page itself scrolls, so a phone's browser bar can collapse. */\r\nfunction DocsCentered({ docs, brandName, brandHref, className, ...props }: DocsCommonProps) {\r\n  const titleRef = usePageArrival(docs.page?.id, undefined)\r\n  const page = docs.page\r\n  return (\r\n    <section data-slot=\"docs-layout\" data-variant=\"centered\" className={cn(\"@container relative flex min-h-[640px] w-full flex-col bg-background\", className)} {...props}>\r\n      <div className=\"sticky top-0 z-10\">\r\n        <DocsTopBar>\r\n          <DocsBrand name={brandName} href={brandHref} />\r\n        </DocsTopBar>\r\n      </div>\r\n      {page ? (\r\n        <main className=\"mx-auto flex w-full max-w-2xl min-w-0 flex-col gap-12 px-4 py-12 @3xl:py-16\">\r\n          <div className=\"flex min-w-0 flex-col gap-8\">\r\n            <PageHeading page={page} titleRef={titleRef} />\r\n            <div className=\"rounded-2xl bg-muted p-4\">\r\n              <TableOfContents variant=\"dots\" title=\"In this guide\" label=\"In this guide\" items={page.sections} scrollOffset={BAR_OFFSET_PX} />\r\n            </div>\r\n          </div>\r\n          {page.sections.map((section) => (\r\n            <section key={section.id} className=\"flex min-w-0 flex-col gap-3\">\r\n              <SectionText section={section} scrollMargin=\"scroll-mt-20\" />\r\n              {section.code ? <SectionCode code={section.code} /> : null}\r\n            </section>\r\n          ))}\r\n          <DocsPager docs={docs} />\r\n        </main>\r\n      ) : (\r\n        <DocsEmpty />\r\n      )}\r\n    </section>\r\n  )\r\n}\r\n\r\nexport { DocsCentered }\r\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/docs-layout-parts.tsx",
      "content": "import type * as React from \"react\"\nimport { ArrowLeft, ArrowRight } from \"lucide-react\"\nimport { cn } from \"@/registry/miseui/lib/utils\"\nimport { CodeBlock } from \"@/registry/miseui/ui/code-block\"\nimport { Collapsible, CollapsibleContent, CollapsibleTrigger } from \"@/registry/miseui/ui/collapsible\"\nimport { TableOfContents } from \"@/registry/miseui/ui/table-of-contents\"\nimport type { DocsCode, DocsPage, DocsPages, DocsSection } from \"./docs-layout-state\"\n\nconst PROSE_CLASS = \"flex flex-col gap-3 text-[15px] leading-relaxed text-pretty text-foreground/85\"\n\nfunction DocsBrand({ name, href }: { name: React.ReactNode; href: string }) {\n  return (\n    <a href={href} className=\"inline-flex min-h-10 items-center rounded-md text-[15px] font-medium outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50\">\n      {name}\n    </a>\n  )\n}\n\nfunction DocsTopBar({ start, children }: { start?: React.ReactNode; children: React.ReactNode }) {\n  return (\n    <header data-slot=\"docs-layout-bar\" className=\"flex h-14 shrink-0 items-center gap-2 border-b bg-background px-4\">\n      {start}\n      {children}\n    </header>\n  )\n}\n\n/** Two tones in one sentence. The heading is focusable so a new page can announce itself. */\nfunction PageHeading({ page, titleRef }: { page: DocsPage; titleRef: React.RefObject<HTMLHeadingElement | null> }) {\n  return (\n    <h1 ref={titleRef} tabIndex={-1} className=\"text-display text-3xl leading-[1.12]! text-balance outline-none @3xl:text-4xl\">\n      {page.lead ? (\n        <>\n          {page.title}. <span className=\"text-muted-foreground\">{page.lead}</span>\n        </>\n      ) : (\n        page.title\n      )}\n    </h1>\n  )\n}\n\nfunction SectionCode({ code }: { code: DocsCode }) {\n  return <CodeBlock variant=\"window\" title={code.title} label={code.title ?? \"Code\"} code={code.code} language={code.language} />\n}\n\nfunction SectionText({ section, scrollMargin = \"scroll-mt-4\" }: { section: DocsSection; scrollMargin?: string }) {\n  return (\n    <>\n      <h2 id={section.id} className={cn(\"text-title text-xl text-balance outline-none\", scrollMargin)}>\n        {section.title}\n      </h2>\n      <div className={PROSE_CLASS}>{section.body}</div>\n    </>\n  )\n}\n\n/** Folds into one row above the article when the side column has no room. Stays open after a jump: closing it would move the text being scrolled to. */\nfunction PageTocFold({ page, scrollRef, className }: { page: DocsPage; scrollRef?: React.RefObject<HTMLElement | null>; className?: string }) {\n  return (\n    <Collapsible variant=\"card\" className={cn(\"min-w-0 rounded-2xl\", className)}>\n      <CollapsibleTrigger className=\"rounded-2xl pointer-coarse:min-h-10\">On this page</CollapsibleTrigger>\n      <CollapsibleContent>\n        <TableOfContents variant=\"plain\" items={page.sections} scrollRef={scrollRef} />\n      </CollapsibleContent>\n    </Collapsible>\n  )\n}\n\nfunction PagerLink({ page, direction, onSelect }: { page: DocsPage; direction: \"previous\" | \"next\"; onSelect: (id: string) => void }) {\n  const next = direction === \"next\"\n  const className = cn(\n    \"flex min-h-14 min-w-0 flex-col justify-center gap-0.5 rounded-2xl border px-4 py-2 text-start outline-none\",\n    \"transition-colors duration-(--duration-fast) ease-(--ease-mise) hover:bg-accent/60 focus-visible:ring-[3px] focus-visible:ring-ring/50\",\n    next && \"col-start-2 items-end text-end\",\n  )\n  const body = (\n    <>\n      <span className=\"inline-flex items-center gap-1 text-[13px] text-muted-foreground\">\n        {next ? null : <ArrowLeft aria-hidden=\"true\" className=\"size-3\" />}\n        {next ? \"Next\" : \"Previous\"}\n        {next ? <ArrowRight aria-hidden=\"true\" className=\"size-3\" /> : null}\n      </span>\n      <span className=\"max-w-full text-sm font-medium wrap-break-word\">{page.title}</span>\n    </>\n  )\n  if (page.href) {\n    return (\n      <a href={page.href} className={className} onClick={() => onSelect(page.id)}>\n        {body}\n      </a>\n    )\n  }\n  return (\n    <button type=\"button\" className={className} onClick={() => onSelect(page.id)}>\n      {body}\n    </button>\n  )\n}\n\nfunction DocsPager({ docs }: { docs: DocsPages }) {\n  if (!docs.previous && !docs.next) return null\n  return (\n    <nav aria-label=\"Pages\" className=\"grid grid-cols-2 gap-3 border-t pt-8\">\n      {docs.previous ? <PagerLink page={docs.previous} direction=\"previous\" onSelect={docs.select} /> : null}\n      {docs.next ? <PagerLink page={docs.next} direction=\"next\" onSelect={docs.select} /> : null}\n    </nav>\n  )\n}\n\n/** A docs block with no pages yet still says so, instead of a blank frame. */\nfunction DocsEmpty() {\n  return (\n    <div className=\"flex flex-1 items-center justify-center px-4 py-16 text-center\">\n      <p className=\"text-[15px] text-muted-foreground\">There are no pages here yet.</p>\n    </div>\n  )\n}\n\nexport { DocsBrand, DocsEmpty, DocsPager, DocsTopBar, PageHeading, PageTocFold, SectionCode, SectionText }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/docs-layout-reference.tsx",
      "content": "import { useRef } from \"react\"\nimport { cn } from \"@/registry/miseui/lib/utils\"\nimport { TableOfContents } from \"@/registry/miseui/ui/table-of-contents\"\nimport { DocsBrand, DocsEmpty, DocsPager, DocsTopBar, PageHeading, PageTocFold, SectionCode, SectionText } from \"./docs-layout-parts\"\nimport type { DocsCommonProps } from \"./docs-layout-sidebar\"\nimport { usePageArrival, type DocsPages } from \"./docs-layout-state\"\n\nfunction ReferenceBody({ docs }: { docs: DocsPages }) {\n  const scrollRef = useRef<HTMLElement>(null)\n  const titleRef = usePageArrival(docs.page?.id, scrollRef)\n  const page = docs.page\n  if (!page) return <DocsEmpty />\n  return (\n    <div className=\"flex min-h-0 flex-1\">\n      <div className=\"hidden w-56 shrink-0 overflow-y-auto border-e p-4 @4xl:block\">\n        <TableOfContents variant=\"line\" effect=\"spring\" label=\"On this page\" title={page.title} items={page.sections} scrollRef={scrollRef} />\n      </div>\n      {/* relative: anything sr-only inside stays clipped by this scroller instead of widening the page. */}\n      <main ref={scrollRef} className=\"relative min-w-0 flex-1 overflow-y-auto\">\n        <div className=\"flex min-w-0 flex-col gap-8 px-4 py-8 @3xl:px-8\">\n          <PageHeading page={page} titleRef={titleRef} />\n          <PageTocFold page={page} scrollRef={scrollRef} className=\"@4xl:hidden\" />\n          {page.sections.map((section) => (\n            <section key={section.id} data-testid=\"reference-row\" className=\"grid min-w-0 grid-cols-[minmax(0,1fr)] items-start gap-4 border-t pt-8 @5xl:grid-cols-2 @5xl:gap-8\">\n              <div className=\"flex min-w-0 flex-col gap-3\">\n                <SectionText section={section} />\n              </div>\n              {/* Stays beside its text while a long explanation scrolls, which is the whole reason for two columns. */}\n              {section.code ? (\n                <div className=\"min-w-0 @5xl:sticky @5xl:top-4\">\n                  <SectionCode code={section.code} />\n                </div>\n              ) : null}\n            </section>\n          ))}\n          <DocsPager docs={docs} />\n        </div>\n      </main>\n    </div>\n  )\n}\n\n/** Text beside its code, for people who came to copy something and want the explanation in the same glance. */\nfunction DocsReference({ docs, brandName, brandHref, className, ...props }: DocsCommonProps) {\n  return (\n    <section data-slot=\"docs-layout\" data-variant=\"reference\" className={cn(\"@container flex h-[720px] max-h-dvh w-full flex-col bg-background\", className)} {...props}>\n      <DocsTopBar>\n        <DocsBrand name={brandName} href={brandHref} />\n      </DocsTopBar>\n      <ReferenceBody docs={docs} />\n    </section>\n  )\n}\n\nexport { DocsReference }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/docs-layout-sample.tsx",
      "content": "import type * as React from \"react\"\nimport type { DocsGroup } from \"./docs-layout-state\"\n\nfunction Term({ children }: { children: React.ReactNode }) {\n  return <code className=\"rounded bg-muted px-1 font-mono text-[13px]\">{children}</code>\n}\n\nconst CURL_INVOICE = `curl https://api.paperline.example/v1/invoices \\\\\n  -H \"Authorization: Bearer pl_test_example\" \\\\\n  -d customer=cus_example \\\\\n  -d amount=128000`\n\nconst SDK_SETUP = `import { Paperline } from \"paperline\"\n\nconst client = new Paperline(process.env.PAPERLINE_KEY)`\n\nconst CREATE_INVOICE = `const invoice = await client.invoices.create({\n  customer: \"cus_example\",\n  amount: 128000,\n  dueInDays: 14,\n})`\n\nconst INVOICE_JSON = `{\n  \"id\": \"inv_example\",\n  \"status\": \"open\",\n  \"amount\": 128000,\n  \"hostedUrl\": \"https://pay.paperline.example/inv_example\"\n}`\n\nconst WEBHOOK_HANDLER = `export async function POST(request: Request) {\n  const body = await request.text()\n  const signature = request.headers.get(\"paperline-signature\")\n  const event = client.webhooks.verify(body, signature)\n  return new Response(null, { status: 200 })\n}`\n\n/** Every key, id and amount here is an example; none of it reaches a real service. */\nconst SAMPLE_GROUPS: readonly DocsGroup[] = [\n  {\n    label: \"Get started\",\n    pages: [\n      {\n        id: \"quick-start\",\n        title: \"Quick start\",\n        lead: \"Send your first invoice in about five minutes.\",\n        sections: [\n          {\n            id: \"quick-start-install\",\n            title: \"Install the library\",\n            body: <p>Add the package to your project. It works in Node 20 and later, and in any runtime with a standard fetch.</p>,\n            code: { title: \"Terminal\", code: \"npm install paperline\", language: \"bash\" },\n          },\n          {\n            id: \"quick-start-client\",\n            title: \"Create a client\",\n            body: <p>Read the key from your environment, so it never lands in your repository. Test keys start with <Term>pl_test_</Term> and never move real money.</p>,\n            code: { title: \"client.ts\", code: SDK_SETUP, language: \"ts\" },\n          },\n          {\n            id: \"quick-start-invoice\",\n            title: \"Send an invoice\",\n            body: <p>Amounts are in the smallest unit of the currency, so 128000 means 1,280.00. The customer gets an email with a link to pay.</p>,\n            code: { title: \"send.ts\", code: CREATE_INVOICE, language: \"ts\" },\n          },\n          {\n            id: \"quick-start-next\",\n            title: \"Where to go next\",\n            body: <p>Keep the invoice id. You will need it to read the status, and webhooks use it to tell you when the invoice is paid.</p>,\n          },\n        ],\n      },\n      {\n        id: \"authentication\",\n        title: \"Authentication\",\n        lead: \"One key per environment, sent as a bearer token.\",\n        sections: [\n          {\n            id: \"authentication-keys\",\n            title: \"Test and live keys\",\n            body: <p>A test key only reaches test data. Create a live key once you are ready, and keep the two in separate environments.</p>,\n          },\n          {\n            id: \"authentication-request\",\n            title: \"Sending a request\",\n            body: <p>Put the key in the <Term>Authorization</Term> header. A request without one gets a 401 and nothing else happens.</p>,\n            code: { title: \"Terminal\", code: CURL_INVOICE, language: \"bash\" },\n          },\n        ],\n      },\n    ],\n  },\n  {\n    label: \"Guides\",\n    pages: [\n      {\n        id: \"invoices\",\n        title: \"Invoices\",\n        lead: \"What an invoice holds, and the states it moves through.\",\n        sections: [\n          {\n            id: \"invoices-object\",\n            title: \"The invoice object\",\n            body: <p>Status starts at <Term>open</Term> and moves to <Term>paid</Term> or <Term>void</Term>. The hosted link stays valid until then.</p>,\n            code: { title: \"Response\", code: INVOICE_JSON, language: \"json\" },\n          },\n          {\n            id: \"invoices-reminders\",\n            title: \"Reminders\",\n            body: <p>By default a reminder goes out three days before the due date and again on the day. Turn either off per invoice.</p>,\n          },\n        ],\n      },\n      {\n        id: \"webhooks\",\n        title: \"Webhooks\",\n        lead: \"Hear about a payment without asking for it.\",\n        sections: [\n          {\n            id: \"webhooks-receive\",\n            title: \"Receive an event\",\n            body: <p>Verify the signature before you trust the body, then answer quickly with a 200. Do slow work after the response.</p>,\n            code: { title: \"route.ts\", code: WEBHOOK_HANDLER, language: \"ts\" },\n          },\n          {\n            id: \"webhooks-retries\",\n            title: \"Retries\",\n            body: <p>An event that does not get a 200 is sent again, up to five times over a day. The same event can arrive twice, so treat the id as the key.</p>,\n          },\n        ],\n      },\n    ],\n  },\n]\n\nexport { SAMPLE_GROUPS }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/docs-layout-sidebar.tsx",
      "content": "import type * as React from \"react\"\nimport { useEffect, useRef } from \"react\"\nimport { cn } from \"@/registry/miseui/lib/utils\"\nimport { Sidebar, SidebarContent, SidebarGroup, SidebarItem, SidebarProvider, SidebarTrigger, useSidebar } from \"@/registry/miseui/ui/sidebar\"\nimport { TableOfContents } from \"@/registry/miseui/ui/table-of-contents\"\nimport { DocsBrand, DocsEmpty, DocsPager, DocsTopBar, PageHeading, PageTocFold, SectionCode, SectionText } from \"./docs-layout-parts\"\nimport { useNarrowerThan, usePageArrival, type DocsGroup, type DocsPages } from \"./docs-layout-state\"\n\n/** Matches @3xl, where the column appears. */\nconst DRAWER_BELOW_PX = 768\n\ninterface DocsCommonProps extends React.ComponentProps<\"section\"> {\n  docs: DocsPages\n  brandName: React.ReactNode\n  brandHref: string\n}\n\nfunction DocsNav({ docs, groups }: { docs: DocsPages; groups: readonly DocsGroup[] }) {\n  return (\n    <Sidebar label=\"Documentation\" width={248}>\n      <SidebarContent label=\"Documentation\" className=\"p-3\">\n        {groups.map((group) => (\n          <SidebarGroup key={group.label} label={group.label}>\n            {group.pages.map((page) => (\n              <SidebarItem key={page.id} href={page.href} active={page.id === docs.page?.id} onClick={() => docs.select(page.id)}>\n                {page.title}\n              </SidebarItem>\n            ))}\n          </SidebarGroup>\n        ))}\n      </SidebarContent>\n    </Sidebar>\n  )\n}\n\n/**\n * The sidebar's drawer has no Radix trigger, so Radix has nothing to hand focus back to after Escape.\n * Skipped when focus already moved on: choosing a page sends it to the new title.\n */\nfunction useDrawerFocusReturn(triggerRef: React.RefObject<HTMLButtonElement | null>) {\n  const { drawerOpen } = useSidebar()\n  const wasOpenRef = useRef(drawerOpen)\n  useEffect(() => {\n    const closed = wasOpenRef.current && !drawerOpen\n    wasOpenRef.current = drawerOpen\n    if (!closed) return\n    const id = window.setTimeout(() => {\n      const active = document.activeElement\n      const stranded = !active || active === document.body || active.closest(\"[data-slot='drawer']\") !== null\n      if (stranded) triggerRef.current?.focus()\n    })\n    return () => window.clearTimeout(id)\n  }, [drawerOpen, triggerRef])\n}\n\nfunction NavTrigger() {\n  const triggerRef = useRef<HTMLButtonElement>(null)\n  useDrawerFocusReturn(triggerRef)\n  return <SidebarTrigger ref={triggerRef} aria-label=\"Pages\" className=\"-ms-2 @3xl:hidden\" />\n}\n\nfunction SidebarArticle({ docs }: { docs: DocsPages }) {\n  const scrollRef = useRef<HTMLElement>(null)\n  const titleRef = usePageArrival(docs.page?.id, scrollRef)\n  const page = docs.page\n  if (!page) return <DocsEmpty />\n  return (\n    // relative: anything sr-only inside stays clipped by this scroller instead of widening the page.\n    <main ref={scrollRef} className=\"relative min-w-0 flex-1 overflow-y-auto\">\n      <div className=\"mx-auto grid max-w-5xl grid-cols-[minmax(0,1fr)] items-start gap-8 px-4 py-8 @3xl:px-8 @5xl:grid-cols-[minmax(0,1fr)_200px] @5xl:gap-12\">\n        <article className=\"flex min-w-0 flex-col gap-8\">\n          <PageHeading page={page} titleRef={titleRef} />\n          <PageTocFold page={page} scrollRef={scrollRef} className=\"@5xl:hidden\" />\n          {page.sections.map((section) => (\n            <section key={section.id} className=\"flex min-w-0 flex-col gap-3\">\n              <SectionText section={section} />\n              {section.code ? <SectionCode code={section.code} /> : null}\n            </section>\n          ))}\n          <DocsPager docs={docs} />\n        </article>\n        <aside className=\"sticky top-8 hidden min-w-0 @5xl:block\">\n          <TableOfContents variant=\"line\" effect=\"spring\" title=\"On this page\" items={page.sections} scrollRef={scrollRef} />\n        </aside>\n      </div>\n    </main>\n  )\n}\n\n/** Three columns, for a product with enough pages that people move around: where you are, what you are reading, and what is on this page. */\nfunction DocsSidebar({ docs, groups, brandName, brandHref, className, ...props }: DocsCommonProps & { groups: readonly DocsGroup[] }) {\n  const rootRef = useRef<HTMLElement>(null)\n  const narrow = useNarrowerThan(rootRef, DRAWER_BELOW_PX)\n  return (\n    <section ref={rootRef} data-slot=\"docs-layout\" data-variant=\"sidebar\" className={cn(\"@container flex h-[720px] max-h-dvh w-full flex-col bg-background\", className)} {...props}>\n      {/* The shortcut stays off: Mod+B belongs to the page, and a docs page has no reason to take it. */}\n      <SidebarProvider mobile={narrow} shortcut={false}>\n        <DocsTopBar start={<NavTrigger />}>\n          <DocsBrand name={brandName} href={brandHref} />\n        </DocsTopBar>\n        <div className=\"flex min-h-0 flex-1\">\n          <DocsNav docs={docs} groups={groups} />\n          <SidebarArticle docs={docs} />\n        </div>\n      </SidebarProvider>\n    </section>\n  )\n}\n\nexport { DocsSidebar, type DocsCommonProps }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/docs-layout-state.ts",
      "content": "import type * as React from \"react\"\nimport { useLayoutEffect, useEffect, useRef, useState } from \"react\"\nimport type { CodeLanguage } from \"@/registry/miseui/ui/code-block\"\n\ninterface DocsCode {\n  code: string\n  language?: CodeLanguage\n  /** A file name, or a word such as Terminal. */\n  title?: string\n}\n\ninterface DocsSection {\n  /** Becomes the heading id and the address of the jump, so keep it unique across the document. */\n  id: string\n  title: string\n  body: React.ReactNode\n  code?: DocsCode\n}\n\ninterface DocsPage {\n  id: string\n  title: string\n  /** Continues the title in the heading, one tone quieter. */\n  lead?: string\n  /** A real address, if your router owns the page. Left out, the block swaps the page itself. */\n  href?: string\n  sections: readonly DocsSection[]\n}\n\ninterface DocsGroup {\n  label: string\n  pages: readonly DocsPage[]\n}\n\nfunction flattenPages(groups: readonly DocsGroup[]) {\n  return groups.flatMap((group) => group.pages)\n}\n\n/** The page to show and its neighbours. An unknown id falls back to the first page, not a blank screen. */\nfunction locatePage(pages: readonly DocsPage[], id: string | undefined) {\n  const found = pages.findIndex((page) => page.id === id)\n  const index = Math.max(found, 0)\n  return { page: pages[index] as DocsPage | undefined, previous: pages[index - 1] as DocsPage | undefined, next: pages[index + 1] as DocsPage | undefined }\n}\n\ninterface DocsPagesOptions {\n  groups: readonly DocsGroup[]\n  current?: string\n  defaultCurrent?: string\n  onNavigate?: (id: string) => void\n}\n\nfunction useDocsPages({ groups, current, defaultCurrent, onNavigate }: DocsPagesOptions) {\n  const pages = flattenPages(groups)\n  const [uncontrolled, setUncontrolled] = useState(defaultCurrent)\n  const located = locatePage(pages, current ?? uncontrolled)\n  const select = (id: string) => {\n    setUncontrolled(id)\n    onNavigate?.(id)\n  }\n  return { ...located, select }\n}\n\ntype DocsPages = ReturnType<typeof useDocsPages>\n\n/** A new page starts at its top, and the title takes focus so a screen reader hears where it landed. Not on arrival: that would steal focus from the page. */\nfunction usePageArrival(pageId: string | undefined, scrollRef: React.RefObject<HTMLElement | null> | undefined) {\n  const titleRef = useRef<HTMLHeadingElement>(null)\n  const lastRef = useRef(pageId)\n  useEffect(() => {\n    if (lastRef.current === pageId) return\n    lastRef.current = pageId\n    scrollRef?.current?.scrollTo({ top: 0 })\n    titleRef.current?.focus({ preventScroll: Boolean(scrollRef) })\n  }, [pageId, scrollRef])\n  return titleRef\n}\n\n/** Measured so the sidebar's drawer can follow the block's own width, which a media query cannot see inside a frame. */\nfunction useNarrowerThan(ref: React.RefObject<HTMLElement | null>, width: number) {\n  const [narrower, setNarrower] = useState(false)\n  useLayoutEffect(() => {\n    const element = ref.current\n    if (!element || typeof ResizeObserver === \"undefined\") return\n    const observer = new ResizeObserver(([entry]) => setNarrower(entry.contentRect.width < width))\n    observer.observe(element)\n    return () => observer.disconnect()\n  }, [ref, width])\n  return narrower\n}\n\nexport { flattenPages, locatePage, useDocsPages, useNarrowerThan, usePageArrival, type DocsCode, type DocsGroup, type DocsPage, type DocsPages, type DocsPagesOptions, type DocsSection }\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "blocks"
  ],
  "type": "registry:block"
}