{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "lightbox-grid",
  "title": "Lightbox Grid",
  "description": "Responsive image galleries with configurable row and column counts, image zoom, and captioned dialogs in grid, bento, or masonry layouts.",
  "dependencies": [
    "cn"
  ],
  "registryDependencies": [
    "@gnostic/lightbox",
    "@gnostic/masonry-grid"
  ],
  "files": [
    {
      "path": "packages/ui/src/components/ui/lightbox-grid/index.ts",
      "content": "export { default as LightboxGrid } from './lightbox-grid.astro'\nexport { default as LightboxGridItem } from './lightbox-grid-item.astro'\nexport type { LightboxGridProps, LightboxGridItemProps } from './types.ts'\n",
      "type": "registry:file",
      "target": "~/src/components/ui/lightbox-grid/index.ts"
    },
    {
      "path": "packages/ui/src/components/ui/lightbox-grid/types.ts",
      "content": "import type { LightboxItemImage } from '@/components/ui/lightbox/types.ts'\n\nexport interface LightboxGridProps {\n    /**\n     * Full rows of equal-height tiles, mixed bento spans, or natural-height masonry items.\n     * @default 'grid'\n     */\n    layout?: 'grid' | 'bento' | 'masonry'\n    /**\n     * Minimum column count. Use a positive integer.\n     *\n     * @default 1\n     */\n    minCols?: number\n    /**\n     * Minimum row count for grid and bento. Use a positive integer.\n     *\n     * @default 1\n     */\n    minRows?: number\n    /**\n     * The height of each row in the grid as a CSS value\n     *\n     * @default '14rem' // 224px\n     */\n    rowHeight?: string\n    /**\n     * A valid CSS gap value\n     *\n     * @default '0.5rem'\n     */\n    gap?: string\n}\n\n/** One image in the gallery. */\nexport interface LightboxGridItemProps {\n    /** Shared image source and description, with optional Astro Image props for each view. */\n    image: LightboxItemImage\n    /** Show this text below the image in a dialog. Omit it for image zoom. */\n    caption?: string\n    /** Number of cells the tile occupies in a bento grid. */\n    span?: 'auto' | 'square' | 'wide' | 'tall' | 'large'\n    /**\n     * Scale the thumbnail on hover.\n     * The preview uses `hover:scale-105`.\n     *\n     * @default true\n     */\n    hoverZoom?: boolean\n}\n",
      "type": "registry:file",
      "target": "~/src/components/ui/lightbox-grid/types.ts"
    },
    {
      "path": "packages/ui/src/components/ui/lightbox-grid/lightbox-grid.astro",
      "content": "---\nimport type { HTMLAttributes } from \"astro/types\"\nimport { cn } from \"cn\"\n\nimport { MasonryGrid } from \"@/components/ui/masonry-grid\"\n\nimport type { LightboxGridProps } from \"./types.ts\"\n\ntype Props = HTMLAttributes<\"div\"> & LightboxGridProps\n\nconst {\n  layout = \"grid\",\n  minCols = 1,\n  minRows = 1,\n  rowHeight = \"14rem\",\n  gap = \"0.5rem\",\n  class: className,\n  style,\n  ...props\n} = Astro.props\n\nif (!Number.isSafeInteger(minCols) || minCols < 1) {\n  throw new RangeError(\"LightboxGrid minCols must be a positive integer.\")\n}\nif (!Number.isSafeInteger(minRows) || minRows < 1) {\n  throw new RangeError(\"LightboxGrid minRows must be a positive integer.\")\n}\n// Six tracks can hold three equal tiles or two equal tiles in a row.\n// Twelve tracks also allow four equal tiles when the caller requests them.\nconst gridColumns: Record<number, string> = {\n  1: \"grid-cols-1 @min-sm/lightbox-grid:grid-cols-2 @min-sm/lightbox-grid:[container-name:lightbox-pairs] @min-lg/lightbox-grid:grid-cols-6 @min-lg/lightbox-grid:[container-name:lightbox-triples]\",\n  2: \"grid-cols-2 [container-name:lightbox-pairs] @min-lg/lightbox-grid:grid-cols-6 @min-lg/lightbox-grid:[container-name:lightbox-triples]\",\n  3: \"grid-cols-6 [container-name:lightbox-triples]\",\n  4: \"grid-cols-12 [container-name:lightbox-quads]\",\n}\nconst variables = {\n  \"--lightbox-grid-row-height\": rowHeight,\n  \"--lightbox-grid-gap\": gap,\n  ...(layout === \"bento\" && {\n    \"--lightbox-bento-cols\": minCols,\n    \"--lightbox-bento-rows\": minRows,\n  }),\n}\n// Preserve CSS values that contain colons or semicolons.\nconst mergedStyle =\n  typeof style === \"string\"\n    ? Object.entries(variables)\n        .map(([key, value]) => `${key}:${value};`)\n        .join(\"\") + style\n    : { ...variables, ...style }\n---\n\n<div\n  data-slot=\"lightbox-grid\"\n  data-lightbox-layout={layout}\n  class={cn(\n    \"@container/lightbox-grid\",\n    layout === \"bento\" &&\n      \"grid grid-flow-dense auto-rows-(--lightbox-grid-row-height) grid-cols-[repeat(auto-fill,minmax(var(--lightbox-bento-track),1fr))] grid-rows-[repeat(var(--lightbox-bento-rows),var(--lightbox-grid-row-height))] gap-(--lightbox-grid-gap)\",\n    className,\n  )}\n  style={mergedStyle}\n  {...props}\n>\n  {layout === \"bento\" ? (\n    <slot />\n  ) : layout === \"masonry\" ? (\n    <MasonryGrid minCols={minCols} gap=\"var(--lightbox-grid-gap)\">\n      <slot />\n    </MasonryGrid>\n  ) : minCols > 4 ? (\n    <div\n      data-lightbox-wrap\n      class=\"flex flex-wrap content-start gap-(--lightbox-grid-gap)\"\n      style={`--lightbox-cols:${minCols};min-height:calc(${minRows} * var(--lightbox-grid-row-height) + ${minRows - 1} * var(--lightbox-grid-gap))`}\n    >\n      <slot />\n    </div>\n  ) : (\n    <div\n      class={cn(\n        \"grid auto-rows-(--lightbox-grid-row-height) gap-(--lightbox-grid-gap)\",\n        \"[container-type:inline-size]\",\n        gridColumns[minCols],\n      )}\n      data-lightbox-rows\n      style={`grid-template-rows:repeat(${minRows},var(--lightbox-grid-row-height))`}\n    >\n      <slot />\n    </div>\n  )}\n</div>\n\n<style is:global>\n  [data-lightbox-layout=\"bento\"] {\n    /* Two default tracks fit at 24rem. Smaller tracks can satisfy minCols. */\n    --lightbox-bento-track: min(\n      calc((24rem - var(--lightbox-grid-gap)) / 2),\n      calc(\n        (100% + var(--lightbox-grid-gap)) / var(--lightbox-bento-cols) -\n          var(--lightbox-grid-gap)\n      )\n    );\n  }\n\n  /* Let each incomplete row share its remaining width without a track map. */\n  [data-lightbox-wrap] > [data-lightbox-span] {\n    flex: 1 1\n      calc(\n        (100% + var(--lightbox-grid-gap)) / var(--lightbox-cols) -\n          var(--lightbox-grid-gap)\n      );\n    height: var(--lightbox-grid-row-height);\n  }\n\n  /* Each LightboxGridItem renders one div. Count its siblings of the same\n     type so a script between two tiles does not affect their placement. */\n  @container lightbox-pairs (min-width: 0px) {\n    [data-lightbox-rows] > [data-lightbox-span]:last-of-type:nth-of-type(odd) {\n      grid-column: 1 / -1;\n    }\n  }\n\n  @container lightbox-triples (min-width: 0px) {\n    [data-lightbox-rows] > [data-lightbox-span] {\n      grid-column: span 2;\n    }\n\n    /* A remainder of one becomes two pairs. A remainder of two is one pair. */\n    [data-lightbox-rows]:has(\n        > [data-lightbox-span]:last-of-type:nth-of-type(3n + 4)\n      )\n      > [data-lightbox-span]:nth-last-of-type(-n + 4),\n    [data-lightbox-rows]:has(\n        > [data-lightbox-span]:last-of-type:nth-of-type(3n + 2)\n      )\n      > [data-lightbox-span]:nth-last-of-type(-n + 2) {\n      grid-column: span 3;\n    }\n  }\n\n  @container lightbox-quads (min-width: 0px) {\n    [data-lightbox-rows] > [data-lightbox-span] {\n      grid-column: span 3;\n    }\n\n    [data-lightbox-rows]:has(\n        > [data-lightbox-span]:last-of-type:nth-of-type(4n + 3)\n      )\n      > [data-lightbox-span]:nth-last-of-type(-n + 3) {\n      grid-column: span 4;\n    }\n\n    [data-lightbox-rows]:has(\n        > [data-lightbox-span]:last-of-type:nth-of-type(4n + 2)\n      )\n      > [data-lightbox-span]:nth-last-of-type(-n + 2) {\n      grid-column: span 6;\n    }\n\n    [data-lightbox-rows]\n      > [data-lightbox-span]:last-of-type:nth-of-type(4n + 1) {\n      grid-column: 1 / -1;\n    }\n  }\n\n  [data-lightbox-rows] > [data-lightbox-span]:only-of-type {\n    grid-column: 1 / -1;\n  }\n</style>\n",
      "type": "registry:file",
      "target": "~/src/components/ui/lightbox-grid/lightbox-grid.astro"
    },
    {
      "path": "packages/ui/src/components/ui/lightbox-grid/lightbox-grid-item.astro",
      "content": "---\nimport type { HTMLAttributes } from \"astro/types\"\nimport { Image } from \"astro:assets\"\nimport { cn } from \"cn\"\n\nimport {\n  Lightbox,\n  LightboxContent,\n  LightboxImage,\n  LightboxTrigger,\n} from \"@/components/ui/lightbox\"\nimport { getLightboxImages } from \"@/components/ui/lightbox/lightbox-item-images.ts\"\n\nimport type { LightboxGridItemProps } from \"./types.ts\"\n\ntype Props = HTMLAttributes<\"div\"> & LightboxGridItemProps\n\nconst {\n  image,\n  caption,\n  class: className,\n  hoverZoom = true,\n  span = \"auto\",\n  ...props\n} = Astro.props\n\nconst hasCaption = Boolean(caption?.trim())\nconst Root = hasCaption ? Lightbox : \"div\"\nconst { preview, enlarged } = getLightboxImages(\n  image,\n  hasCaption ? \"dialog\" : \"zoom\",\n)\nconst thumbnailClass = cn(\n  \"block h-auto w-full object-cover in-data-[lightbox-layout=bento]:h-full in-data-[lightbox-layout=grid]:h-full\",\n  preview.class,\n)\n---\n\n<Root\n  class={cn(\n    \"min-h-0 min-w-0\",\n    (span === \"tall\" || span === \"large\") &&\n      \"in-data-[lightbox-layout=bento]:@sm/lightbox-grid:row-span-2\",\n    (span === \"wide\" || span === \"large\") &&\n      \"in-data-[lightbox-layout=bento]:@sm/lightbox-grid:col-span-2\",\n    !hasCaption &&\n      \"has-focus-visible:outline-ring overflow-hidden rounded-xl has-focus-visible:outline-2 has-focus-visible:outline-offset-3\",\n    className,\n  )}\n  data-lightbox-span={span}\n  {...props}\n>\n  {hasCaption ? (\n    <>\n      <LightboxTrigger\n        hoverZoom={hoverZoom}\n        class=\"w-full in-data-[lightbox-layout=bento]:h-full in-data-[lightbox-layout=grid]:h-full\"\n        aria-label={`View image: ${image.alt}`}\n      >\n        <Image {...preview} class={thumbnailClass} />\n      </LightboxTrigger>\n      <LightboxContent label={image.alt} caption={caption}>\n        <Image {...enlarged} />\n      </LightboxContent>\n    </>\n  ) : (\n    <LightboxImage\n      {...preview}\n      zoomImage={image.content ? enlarged : undefined}\n      class={cn(\n        thumbnailClass,\n        hoverZoom &&\n          \"motion-safe:transition-transform motion-safe:duration-300 motion-safe:hover:scale-105\",\n      )}\n    />\n  )}\n</Root>\n",
      "type": "registry:file",
      "target": "~/src/components/ui/lightbox-grid/lightbox-grid-item.astro"
    }
  ],
  "meta": {
    "framework": "astro",
    "source": "@gnostic/ui",
    "testedDependencies": {
      "cn": "0.5.2"
    }
  },
  "docs": "https://gnosticai.com/ui/components/lightbox-grid",
  "categories": [
    "ui"
  ],
  "type": "registry:ui"
}
