{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sitemap",
  "title": "Sitemap",
  "author": "Tori Bryan",
  "description": "A human-readable sitemap: a location search, popular picks, and every destination grouped by job, in columns that fold to cards on a phone.",
  "dependencies": [
    "@base-ui/react",
    "lucide-react"
  ],
  "registryDependencies": [
    "https://fibo.toribryan.com/r/button.json",
    "https://fibo.toribryan.com/r/input-group.json",
    "utils"
  ],
  "files": [
    {
      "path": "registry/blocks/sitemap/data.ts",
      "content": "// Placeholder content for the Sitemap block: a directory of care homes, the\n// shape it was first sketched for. Swap it for your own site's pages.\n\n/** A link, or a group of links when it has `links`, such as a state and its cities. */\ntype SitemapEntry = {\n  label: string\n  href: string\n  links?: SitemapEntry[]\n}\n\ntype SitemapContent = {\n  title: string\n  description: string\n  placeholder: string\n  /** Popular destinations shown under the search. */\n  suggestions: { label: string; href: string }[]\n  /** Columns of the directory, each a job someone came to do. */\n  sections: { title: string; entries: SitemapEntry[] }[]\n}\n\nconst LOCATIONS = [\n  { state: \"Arizona\", cities: [\"Phoenix\", \"Scottsdale\", \"Mesa\", \"Tucson\"] },\n  { state: \"Colorado\", cities: [\"Denver\", \"Boulder\", \"Fort Collins\"] },\n  { state: \"Oregon\", cities: [\"Portland\", \"Eugene\", \"Bend\"] },\n]\n\nconst slug = (text: string) =>\n  `#${text.toLowerCase().replace(/[^a-z0-9]+/g, \"-\")}`\n\nconst content: SitemapContent = {\n  title: \"Explore care homes\",\n  description: \"Find a community near you, or browse the directory below.\",\n  placeholder: \"Search city, state or ZIP code\",\n  suggestions: [\n    { label: \"Phoenix, AZ\", href: \"#phoenix-arizona\" },\n    { label: \"Scottsdale, AZ\", href: \"#scottsdale-arizona\" },\n    { label: \"Denver, CO\", href: \"#denver-colorado\" },\n  ],\n  sections: [\n    {\n      title: \"Find a home\",\n      entries: [\n        { label: \"Browse all homes\", href: \"#homes\" },\n        { label: \"Available now\", href: \"#available\" },\n        { label: \"Browse by state\", href: \"#states\" },\n        { label: \"Browse by city\", href: \"#cities\" },\n      ],\n    },\n    {\n      title: \"Browse locations\",\n      entries: [\n        ...LOCATIONS.map(({ state, cities }) => ({\n          label: state,\n          href: slug(state),\n          links: cities.map((city) => ({\n            label: city,\n            href: slug(`${city} ${state}`),\n          })),\n        })),\n        { label: \"All locations\", href: \"#locations\" },\n      ],\n    },\n    {\n      title: \"Care resources\",\n      entries: [\n        { label: \"Care options\", href: \"#care-options\" },\n        { label: \"Choosing care\", href: \"#choosing-care\" },\n        { label: \"Cost and affordability\", href: \"#cost\" },\n        { label: \"Caregiver resources\", href: \"#caregivers\" },\n      ],\n    },\n    {\n      title: \"About\",\n      entries: [\n        { label: \"About us\", href: \"#about\" },\n        { label: \"Contact\", href: \"#contact\" },\n        { label: \"List a home\", href: \"#list\" },\n        { label: \"Privacy\", href: \"#privacy\" },\n      ],\n    },\n  ],\n}\n\nexport { content }\nexport type { SitemapContent, SitemapEntry }\n",
      "type": "registry:component",
      "target": "components/blocks/sitemap/data.ts"
    },
    {
      "path": "registry/blocks/sitemap/parts.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Collapsible as CollapsiblePrimitive } from \"@base-ui/react/collapsible\"\nimport { mergeProps } from \"@base-ui/react/merge-props\"\nimport { useRender } from \"@base-ui/react/use-render\"\nimport { ChevronRightIcon, SearchIcon } from \"lucide-react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport {\n  InputGroup,\n  InputGroupAddon,\n  InputGroupInput,\n} from \"@/components/ui/input-group\"\nimport { cn } from \"@/lib/utils\"\n\n/**\n * The page frame: a header, a search, then every destination grouped by job.\n * Its layout follows its own width, not the window's, so it reads the same in\n * a full page, a docs canvas or a preview pane.\n */\nfunction SitemapLayout({\n  className,\n  children,\n  ...props\n}: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"sitemap\"\n      className={cn(\"@container/sitemap w-full\", className)}\n      {...props}\n    >\n      <div className=\"mx-auto flex w-full max-w-6xl flex-col gap-6 px-4 py-10 @3xl/sitemap:px-12 @3xl/sitemap:py-14\">\n        {children}\n      </div>\n    </div>\n  )\n}\n\nfunction SitemapHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"sitemap-header\"\n      className={cn(\"flex flex-col gap-2\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction SitemapTitle({ className, ...props }: React.ComponentProps<\"h1\">) {\n  return (\n    <h1\n      data-slot=\"sitemap-title\"\n      className={cn(\n        \"text-2xl font-semibold tracking-tight text-foreground @3xl/sitemap:text-4xl\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction SitemapDescription({\n  className,\n  ...props\n}: React.ComponentProps<\"p\">) {\n  return (\n    <p\n      data-slot=\"sitemap-description\"\n      className={cn(\n        \"text-base text-muted-foreground @3xl/sitemap:text-lg\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/**\n * A search form for the page. Give it `onSearch` to handle the query in the\n * app, or an `action` to send it to an existing results route as `?q=`.\n */\nfunction SitemapSearch({\n  label = \"Search locations\",\n  placeholder = \"Search city, state or ZIP code\",\n  submitLabel = \"Search\",\n  name = \"q\",\n  defaultValue,\n  sticky = false,\n  onSearch,\n  onSubmit,\n  className,\n  ...props\n}: Omit<React.ComponentProps<\"form\">, \"onSubmit\"> & {\n  /** Names the field for screen readers, and the search landmark. */\n  label?: string\n  /** Hint text inside the empty field. */\n  placeholder?: string\n  /** The submit button's text. */\n  submitLabel?: string\n  /** The query parameter the field submits as. */\n  name?: string\n  /** The query the field starts with. */\n  defaultValue?: string\n  /** Pins the search under the page's own header as the page scrolls. Set `top` through `--sitemap-sticky-top`. */\n  sticky?: boolean\n  /** Called with the trimmed query on submit, in place of a page load. */\n  onSearch?: (query: string) => void\n  /** Called on submit before `onSearch`. */\n  onSubmit?: React.FormEventHandler<HTMLFormElement>\n}) {\n  return (\n    <form\n      data-slot=\"sitemap-search\"\n      data-sticky={sticky || undefined}\n      role=\"search\"\n      aria-label={label}\n      onSubmit={(event) => {\n        onSubmit?.(event)\n        if (!onSearch || event.defaultPrevented) return\n        event.preventDefault()\n        const query = new FormData(event.currentTarget).get(name)\n        onSearch(String(query ?? \"\").trim())\n      }}\n      className={cn(\n        \"flex flex-col gap-2 @2xl/sitemap:flex-row\",\n        // On a phone the pinned bar stays one row high, so it never takes\n        // over the screen it is helping someone scroll.\n        \"data-sticky:sticky data-sticky:top-(--sitemap-sticky-top,0px) data-sticky:z-10 data-sticky:-mx-4 data-sticky:flex-row data-sticky:bg-background data-sticky:px-4 data-sticky:py-3 @3xl/sitemap:data-sticky:-mx-12 @3xl/sitemap:data-sticky:px-12\",\n        className\n      )}\n      {...props}\n    >\n      <InputGroup className=\"h-11 min-h-11 flex-1\">\n        <InputGroupAddon>\n          <SearchIcon aria-hidden=\"true\" />\n        </InputGroupAddon>\n        <InputGroupInput\n          type=\"search\"\n          name={name}\n          defaultValue={defaultValue}\n          placeholder={placeholder}\n          aria-label={label}\n          autoComplete=\"off\"\n        />\n      </InputGroup>\n      <Button type=\"submit\" size=\"lg\" className=\"h-11 px-5\">\n        {submitLabel}\n      </Button>\n    </form>\n  )\n}\n\n/** A short row of popular destinations under the search. */\nfunction SitemapSuggestions({\n  label = \"Popular locations\",\n  className,\n  children,\n  ...props\n}: React.ComponentProps<\"div\"> & {\n  /** Says what the suggestions are, above them and to screen readers. */\n  label?: string\n}) {\n  const id = React.useId()\n  return (\n    <div\n      data-slot=\"sitemap-suggestions\"\n      className={cn(\"flex flex-col gap-2\", className)}\n      {...props}\n    >\n      <span id={id} className=\"text-sm text-muted-foreground\">\n        {label}\n      </span>\n      <ul\n        aria-labelledby={id}\n        className=\"m-0 flex list-none flex-wrap gap-2 p-0\"\n      >\n        {children}\n      </ul>\n    </div>\n  )\n}\n\n/** One suggestion, a link shaped like a chip. `render` swaps in a router link. */\nfunction SitemapSuggestion({\n  className,\n  render,\n  ...props\n}: useRender.ComponentProps<\"a\">) {\n  const element = useRender({\n    render: render ?? <a />,\n    props: mergeProps<\"a\">(\n      {\n        \"data-slot\": \"sitemap-suggestion\",\n        className: cn(\n          \"inline-flex h-8 items-center rounded-full bg-secondary px-3 text-sm font-medium text-secondary-foreground no-underline transition-colors outline-none hover:bg-secondary-hover focus-visible:ring-[3px] focus-visible:ring-ring-subtle\",\n          className\n        ),\n      } as React.ComponentProps<\"a\">,\n      props\n    ),\n  })\n  return <li className=\"m-0 p-0\">{element}</li>\n}\n\n/**\n * The directory: one column on a phone, two on a tablet and four on a\n * desktop. It is the page's sitemap landmark.\n */\nfunction SitemapSections({\n  \"aria-label\": ariaLabel = \"Sitemap\",\n  className,\n  ...props\n}: React.ComponentProps<\"nav\">) {\n  return (\n    <nav\n      data-slot=\"sitemap-sections\"\n      aria-label={ariaLabel}\n      className={cn(\n        \"grid grid-cols-1 gap-4 border-border pt-2 @2xl/sitemap:grid-cols-2 @2xl/sitemap:gap-x-8 @2xl/sitemap:gap-y-10 @2xl/sitemap:border-t @2xl/sitemap:pt-10 @5xl/sitemap:grid-cols-4\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/**\n * One group of destinations under a heading. A card on a phone, so each\n * group reads as its own stop while scrolling; a plain column wider up.\n */\nfunction SitemapSection({\n  title,\n  className,\n  children,\n  ...props\n}: Omit<React.ComponentProps<\"section\">, \"title\"> & {\n  /** The group's heading, such as \"Find a home\". */\n  title: React.ReactNode\n}) {\n  const id = React.useId()\n  return (\n    <section\n      data-slot=\"sitemap-section\"\n      aria-labelledby={id}\n      className={cn(\n        \"flex min-w-0 flex-col rounded-xl border border-border bg-card @2xl/sitemap:rounded-none @2xl/sitemap:border-0 @2xl/sitemap:bg-transparent\",\n        className\n      )}\n      {...props}\n    >\n      <h2\n        id={id}\n        data-slot=\"sitemap-section-title\"\n        className=\"m-0 border-b border-border px-4 py-3 text-base font-semibold text-foreground @2xl/sitemap:border-0 @2xl/sitemap:px-0 @2xl/sitemap:pt-0 @2xl/sitemap:pb-2 @3xl/sitemap:text-lg\"\n      >\n        {title}\n      </h2>\n      <ul\n        data-slot=\"sitemap-list\"\n        className=\"m-0 flex list-none flex-col p-0 px-4 pb-1 @2xl/sitemap:px-0\"\n      >\n        {children}\n      </ul>\n    </section>\n  )\n}\n\nconst linkClassName =\n  \"flex min-h-11 flex-1 items-center rounded-sm py-2 text-sm text-foreground no-underline underline-offset-4 outline-none hover:underline focus-visible:ring-[3px] focus-visible:ring-ring-subtle @3xl/sitemap:text-base\"\n\n/** One destination in a section or group. `render` swaps in a router link. */\nfunction SitemapLink({\n  className,\n  render,\n  ...props\n}: useRender.ComponentProps<\"a\">) {\n  const element = useRender({\n    render: render ?? <a />,\n    props: mergeProps<\"a\">(\n      {\n        \"data-slot\": \"sitemap-link\",\n        className: cn(linkClassName, className),\n      } as React.ComponentProps<\"a\">,\n      props\n    ),\n  })\n  return (\n    <li className=\"m-0 flex border-b border-border p-0 last:border-0 [[data-slot=sitemap-group-list]_&]:border-0\">\n      {element}\n    </li>\n  )\n}\n\n/**\n * A destination with destinations under it, such as a state and its cities.\n * `collapsible` folds the children behind a toggle, for long lists on a\n * phone.\n */\nfunction SitemapGroup({\n  title,\n  href,\n  collapsible = false,\n  defaultOpen = true,\n  open,\n  onOpenChange,\n  className,\n  children,\n  ...props\n}: Omit<React.ComponentProps<\"li\">, \"title\"> & {\n  /** The parent destination's name, such as a state. */\n  title: string\n  /** Where the parent itself goes. Leave it out for a plain label. */\n  href?: string\n  /** Puts the children behind a toggle beside the title. */\n  collapsible?: boolean\n  /** Whether a collapsible group starts open. */\n  defaultOpen?: boolean\n  /** Whether a collapsible group is open, when you control it. */\n  open?: boolean\n  /** Called when a collapsible group opens or closes. */\n  onOpenChange?: (open: boolean) => void\n}) {\n  const heading = href ? (\n    <a data-slot=\"sitemap-group-title\" href={href} className={linkClassName}>\n      {title}\n    </a>\n  ) : (\n    <span\n      data-slot=\"sitemap-group-title\"\n      className=\"flex min-h-11 flex-1 items-center py-2 text-sm text-foreground @3xl/sitemap:text-base\"\n    >\n      {title}\n    </span>\n  )\n  const list = (\n    <ul\n      data-slot=\"sitemap-group-list\"\n      className=\"m-0 mb-2 ml-1 flex list-none flex-col border-l border-border p-0 pl-4\"\n    >\n      {children}\n    </ul>\n  )\n\n  if (!collapsible) {\n    return (\n      <li\n        data-slot=\"sitemap-group\"\n        className={cn(\n          \"m-0 flex flex-col border-b border-border p-0 last:border-0\",\n          className\n        )}\n        {...props}\n      >\n        {heading}\n        {list}\n      </li>\n    )\n  }\n\n  return (\n    <li\n      data-slot=\"sitemap-group\"\n      className={cn(\"m-0 border-b border-border p-0 last:border-0\", className)}\n      {...props}\n    >\n      <CollapsiblePrimitive.Root\n        defaultOpen={defaultOpen}\n        open={open}\n        onOpenChange={onOpenChange}\n        className=\"flex flex-col\"\n      >\n        <div className=\"flex items-center gap-2\">\n          {heading}\n          <CollapsiblePrimitive.Trigger\n            data-slot=\"sitemap-group-trigger\"\n            aria-label={`Show places in ${title}`}\n            className=\"flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring-subtle [&_svg]:size-4 [&_svg]:transition-transform data-panel-open:[&_svg]:rotate-90 motion-reduce:[&_svg]:transition-none\"\n          >\n            <ChevronRightIcon aria-hidden=\"true\" />\n          </CollapsiblePrimitive.Trigger>\n        </div>\n        <CollapsiblePrimitive.Panel data-slot=\"sitemap-group-panel\">\n          {list}\n        </CollapsiblePrimitive.Panel>\n      </CollapsiblePrimitive.Root>\n    </li>\n  )\n}\n\nexport {\n  SitemapLayout,\n  SitemapDescription,\n  SitemapGroup,\n  SitemapHeader,\n  SitemapLink,\n  SitemapSearch,\n  SitemapSection,\n  SitemapSections,\n  SitemapSuggestion,\n  SitemapSuggestions,\n  SitemapTitle,\n}\n",
      "type": "registry:component",
      "target": "components/blocks/sitemap/parts.tsx"
    },
    {
      "path": "registry/blocks/sitemap/sitemap.tsx",
      "content": "import * as React from \"react\"\n\nimport { content as defaultContent, type SitemapContent } from \"./data\"\nimport {\n  SitemapDescription,\n  SitemapGroup,\n  SitemapHeader,\n  SitemapLayout,\n  SitemapLink,\n  SitemapSearch,\n  SitemapSection,\n  SitemapSections,\n  SitemapSuggestion,\n  SitemapSuggestions,\n  SitemapTitle,\n} from \"./parts\"\n\ntype SitemapProps = Omit<\n  React.ComponentProps<\"div\">,\n  \"children\" | \"content\"\n> & {\n  /** The page's words and links. Defaults to the placeholder in `data.ts`. */\n  content?: SitemapContent\n  /** Folds each group, such as a state's cities, behind a toggle. The first stays open. */\n  collapsible?: boolean\n  /** Pins the search as the page scrolls. Set `top` through `--sitemap-sticky-top`. */\n  sticky?: boolean\n  /** Handles the query in the app. Without it, the search loads `searchAction` with `?q=`. */\n  onSearch?: (query: string) => void\n  /** The results route the search submits to when there's no `onSearch`. */\n  searchAction?: string\n}\n\n/**\n * A human-readable sitemap: a location search, popular picks, and every\n * destination grouped by job, in columns that fold to cards on a phone.\n */\nfunction Sitemap({\n  content = defaultContent,\n  collapsible = true,\n  sticky = false,\n  onSearch,\n  searchAction = \"/search\",\n  ...props\n}: SitemapProps) {\n  return (\n    <SitemapLayout {...props}>\n      <SitemapHeader>\n        <SitemapTitle>{content.title}</SitemapTitle>\n        <SitemapDescription>{content.description}</SitemapDescription>\n      </SitemapHeader>\n      <SitemapSearch\n        placeholder={content.placeholder}\n        sticky={sticky}\n        onSearch={onSearch}\n        action={onSearch ? undefined : searchAction}\n      />\n      {content.suggestions.length ? (\n        <SitemapSuggestions>\n          {content.suggestions.map((suggestion) => (\n            <SitemapSuggestion key={suggestion.href} href={suggestion.href}>\n              {suggestion.label}\n            </SitemapSuggestion>\n          ))}\n        </SitemapSuggestions>\n      ) : null}\n      <SitemapSections>\n        {content.sections.map((section) => {\n          const firstGroup = section.entries.findIndex((entry) => entry.links)\n          return (\n            <SitemapSection key={section.title} title={section.title}>\n              {section.entries.map((entry, index) =>\n                entry.links ? (\n                  <SitemapGroup\n                    key={entry.href}\n                    title={entry.label}\n                    href={entry.href}\n                    collapsible={collapsible}\n                    defaultOpen={!collapsible || index === firstGroup}\n                  >\n                    {entry.links.map((link) => (\n                      <SitemapLink key={link.href} href={link.href}>\n                        {link.label}\n                      </SitemapLink>\n                    ))}\n                  </SitemapGroup>\n                ) : (\n                  <SitemapLink key={entry.href} href={entry.href}>\n                    {entry.label}\n                  </SitemapLink>\n                )\n              )}\n            </SitemapSection>\n          )\n        })}\n      </SitemapSections>\n    </SitemapLayout>\n  )\n}\n\nexport { Sitemap }\nexport type { SitemapProps }\n",
      "type": "registry:component",
      "target": "components/blocks/sitemap/sitemap.tsx"
    }
  ],
  "cssVars": {
    "theme": {
      "color-secondary-hover": "var(--secondary-hover)",
      "color-ring-subtle": "var(--ring-subtle)"
    },
    "light": {
      "secondary-hover": "var(--color-neutral-200)",
      "ring-subtle": "color-mix(in oklch, var(--color-neutral-400) 50%, transparent)"
    },
    "dark": {
      "secondary-hover": "var(--color-neutral-700)",
      "ring-subtle": "color-mix(in oklch, var(--color-neutral-500) 50%, transparent)"
    }
  },
  "meta": {
    "tier": "blocks",
    "group": "Pages",
    "docs": "https://fibo.toribryan.com/?path=/docs/blocks-sitemap--docs"
  },
  "docs": "Installed into components/blocks/sitemap. Render <Sitemap /> where the screen goes, then edit it: it's yours. Docs: https://fibo.toribryan.com/?path=/docs/blocks-sitemap--docs",
  "categories": [
    "blocks",
    "pages"
  ],
  "type": "registry:block"
}