{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "photo-grid-viewer",
  "title": "Photo Grid Viewer",
  "description": "A thumbnail grid whose items open a full-screen viewer at the tapped photo, and return focus to that thumbnail when the viewer closes. Use this when a phone gallery, album or post shows photos in a grid and people expect to open, swipe and pinch them.",
  "registryDependencies": [
    "@tealmac/image-viewer"
  ],
  "files": [
    {
      "path": "registry/patterns/photo-grid-viewer/photo-grid-viewer.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { ImageViewer, type ViewerImage } from \"@/components/ui/image-viewer\"\n\nexport interface PhotoGridViewerProps {\n  images: ViewerImage[]\n  columns?: number\n}\n\nexport function PhotoGridViewer({ images, columns = 3 }: PhotoGridViewerProps) {\n  const [open, setOpen] = React.useState(false)\n  const [index, setIndex] = React.useState(0)\n  const buttons = React.useRef<(HTMLButtonElement | null)[]>([])\n\n  return (\n    <>\n      <ul\n        aria-label={`Photos, ${images.length}`}\n        className=\"grid gap-1\"\n        style={{ gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` }}\n      >\n        {images.map((image, i) => (\n          <li key={image.src}>\n            <button\n              ref={(el) => {\n                buttons.current[i] = el\n              }}\n              type=\"button\"\n              onClick={() => {\n                setIndex(i)\n                setOpen(true)\n              }}\n              className=\"focus-visible:ring-ring block aspect-square w-full overflow-hidden rounded-md outline-none focus-visible:ring-2\"\n            >\n              <img\n                src={image.src}\n                alt={image.alt}\n                className=\"size-full object-cover\"\n              />\n            </button>\n          </li>\n        ))}\n      </ul>\n      <ImageViewer\n        images={images}\n        open={open}\n        onOpenChange={(next) => {\n          setOpen(next)\n          if (!next)\n            requestAnimationFrame(() => buttons.current[index]?.focus())\n        }}\n        index={index}\n        onIndexChange={setIndex}\n      />\n    </>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}