{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ds-image-gallery",
  "title": "ImageGallery",
  "description": "Galeria de imagens flexível — grid, masonry ou linha com scroll-snap — com legenda/overlay opcional por item.",
  "dependencies": [
    "class-variance-authority"
  ],
  "registryDependencies": [
    "@lema-ds/skeleton"
  ],
  "files": [
    {
      "path": "components/ds/ds-image-gallery.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/components/ui/skeleton\"\n\n// ── Types ──\n\nexport type ImageGalleryLayout = \"grid\" | \"masonry\" | \"row\"\nexport type ImageGalleryColumns = 2 | 3 | 4\nexport type ImageGalleryAspect = \"square\" | \"video\" | \"portrait\" | \"auto\"\n\nexport interface ImageGalleryItem {\n  src: string\n  alt: string\n  /** Rendered in a bottom gradient scrim over the image. */\n  caption?: React.ReactNode\n  /** Overrides `caption` entirely (e.g. a play button, a like count). */\n  overlay?: React.ReactNode\n  href?: string\n  onClick?: () => void\n}\n\nexport interface ImageGalleryProps\n  extends\n    Omit<React.HTMLAttributes<HTMLDivElement>, \"onClick\">,\n    VariantProps<typeof imageGalleryRootVariants> {\n  items: ImageGalleryItem[]\n  aspect?: ImageGalleryAspect\n  loading?: boolean\n  /** Number of skeleton tiles shown while loading. */\n  skeletonCount?: number\n}\n\n// ── Variants ──\n\nexport const imageGalleryRootVariants = cva(\"\", {\n  variants: {\n    layout: {\n      grid: \"grid gap-4\",\n      masonry: \"columns-2 gap-4 md:columns-3 lg:columns-4\",\n      row: \"flex snap-x snap-mandatory gap-4 overflow-x-auto pb-2\",\n    },\n    columns: {\n      2: \"\",\n      3: \"\",\n      4: \"\",\n    },\n  },\n  compoundVariants: [\n    { layout: \"grid\", columns: 2, className: \"grid-cols-2\" },\n    { layout: \"grid\", columns: 3, className: \"grid-cols-2 sm:grid-cols-3\" },\n    { layout: \"grid\", columns: 4, className: \"grid-cols-2 md:grid-cols-4\" },\n  ],\n  defaultVariants: { layout: \"grid\", columns: 3 },\n})\n\nexport const imageGalleryItemVariants = cva(\n  \"group/gallery-item relative block overflow-hidden rounded-2xl bg-muted transition-transform duration-200 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none\",\n  {\n    variants: {\n      layout: {\n        grid: \"\",\n        masonry: \"mb-4 w-full break-inside-avoid\",\n        row: \"w-72 shrink-0 snap-start\",\n      },\n      aspect: {\n        square: \"aspect-square\",\n        video: \"aspect-video\",\n        portrait: \"aspect-3/4\",\n        auto: \"\",\n      },\n      interactive: {\n        true: \"cursor-pointer hover:-translate-y-0.5\",\n        false: \"\",\n      },\n    },\n    defaultVariants: { layout: \"grid\", aspect: \"square\", interactive: false },\n  }\n)\n\n// ── Component ──\n\n/**\n * A flexible image gallery — grid, masonry (CSS columns) or a horizontal\n * scroll-snap row — with an optional bottom-scrim caption/overlay per item.\n * Pass `href` or `onClick` on an item to make it interactive (e.g. to open a\n * `Lightbox`).\n */\nexport function ImageGallery({\n  items,\n  layout = \"grid\",\n  columns = 3,\n  aspect = \"square\",\n  loading = false,\n  skeletonCount,\n  className,\n  ...props\n}: ImageGalleryProps) {\n  if (loading) {\n    return (\n      <div\n        className={cn(imageGalleryRootVariants({ layout, columns }), className)}\n        data-slot=\"image-gallery-skeleton\"\n        {...props}\n      >\n        {Array.from({ length: skeletonCount ?? (items.length || 6) }).map(\n          (_, index) => (\n            <Skeleton\n              key={index}\n              className={cn(\n                imageGalleryItemVariants({ layout, aspect }),\n                \"bg-muted\"\n              )}\n            />\n          )\n        )}\n      </div>\n    )\n  }\n\n  return (\n    <div\n      className={cn(imageGalleryRootVariants({ layout, columns }), className)}\n      data-slot=\"image-gallery\"\n      {...props}\n    >\n      {items.map((item, index) => {\n        const interactive = Boolean(item.href || item.onClick)\n        const content = (\n          <>\n            {/* eslint-disable-next-line @next/next/no-img-element */}\n            <img\n              src={item.src}\n              alt={item.alt}\n              loading=\"lazy\"\n              decoding=\"async\"\n              className=\"size-full object-cover transition-transform duration-300 group-hover/gallery-item:scale-105\"\n            />\n            {(item.caption || item.overlay) && (\n              <span className=\"absolute inset-x-0 bottom-0 flex items-end bg-gradient-to-t from-foreground/70 via-foreground/10 to-transparent p-4 text-sm font-medium text-background\">\n                {item.overlay ?? item.caption}\n              </span>\n            )}\n          </>\n        )\n\n        const itemClassName = cn(\n          imageGalleryItemVariants({ layout, aspect, interactive })\n        )\n\n        if (item.onClick) {\n          return (\n            <button\n              key={index}\n              type=\"button\"\n              onClick={item.onClick}\n              aria-label={item.alt}\n              className={itemClassName}\n            >\n              {content}\n            </button>\n          )\n        }\n\n        if (item.href) {\n          return (\n            <a\n              key={index}\n              href={item.href}\n              aria-label={item.alt}\n              className={itemClassName}\n            >\n              {content}\n            </a>\n          )\n        }\n\n        return (\n          <figure key={index} className={itemClassName}>\n            {content}\n          </figure>\n        )\n      })}\n    </div>\n  )\n}\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
