{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "masonry-grid",
  "type": "registry:item",
  "title": "Masonry Grid",
  "description": "A masonry layout for any items of different heights (cards, notes, photos): packed into columns as wide as `column` allows, while the order stays the reading order, so Tab, screen readers and search see the items left to right, top to bottom, as written. Browsers with native masonry (CSS grid lanes) lay it out themselves; the others get a small script that measures each item.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "display"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/masonry-grid.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/masonry-grid.js",
      "content": "// Generated by zubra from masonry-grid.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { onMount } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"masonry-grid\";\n\nexport default $define(tag, {\n  props: {\n    \"column\": { attribute: \"column\", default: \"16rem\", required: false },\n    \"gap\": { attribute: \"gap\", default: \"1rem\", required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [\"default\"],\n  events: [],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (masonry-grid) to ([data-zb-slotted=\\\"masonry-grid\\\"]) {\\n  :scope { display: block; }\\n  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--column)), 1fr)); grid-auto-rows: 4px; column-gap: var(--gap); }\\n  /* Each item keeps its own height (stretched to its rows, it would measure taller each time). */\\n  \\n  @supports (display: grid-lanes) { .grid { display: grid-lanes; grid-auto-rows: auto; gap: var(--gap); } }\\n}\\n@scope (masonry-grid) {\\n.grid > :where([data-zb-slotted=\\\"masonry-grid\\\"]):is(*) { align-self: start; }\\n}\\n}\\n\",\n  template: \"\\n  <div class=\\\"grid\\\"><!--[--><!--]--></div>\\n\",\n  setup($p, $emit) {\nfunction __zubraAssign(signal, value) { signal.set(value); return value }\nfunction __zubraUpdate(signal, delta, prefix) { const old = signal.get(); signal.set(old + delta); return prefix ? old + delta : old }\n                                          \n\n  const grid = __zubraState(null)\n\n  // Each item spans as many small rows as it is tall (re-measured as it resizes: images loading,\n  // text wrapping), so CSS grid packs the columns without moving anything in the DOM.\n  // Where the browser lays out masonry itself (CSS grid lanes), the style below does it all.\n  onMount(() => {\n    if (globalThis.CSS?.supports?.('display', 'grid-lanes')) return\n    const ROW = 4\n    const fit = (item) => {\n      const gap = parseFloat(getComputedStyle(grid.get()).columnGap) || 0\n      item.style.gridRowEnd = `span ${Math.max(1, Math.ceil((item.getBoundingClientRect().height + gap) / ROW))}`\n    }\n    const sizes = new ResizeObserver((entries) => entries.forEach((entry) => fit(entry.target)))\n    const watch = () => [...grid.get().children].forEach((item) => sizes.observe(item))\n    watch()\n    const added = new MutationObserver(watch)\n    added.observe(grid.get(), { childList: true })\n    return () => { sizes.disconnect(); added.disconnect() }\n  })\n    return [\n      { path: [0], ref: () => (($el) => (__zubraAssign(grid, $el))) },\n      { path: [0], style: \"--column\", value: () => $p.column },\n      { path: [0], style: \"--gap\", value: () => $p.gap },\n      { path: [0, 0], slot: \"default\", fallback: null },\n    ];\n  },\n});\n"
    }
  ]
}
