{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "lib-scroll-region",
  "title": "Scrolling table region",
  "description": "A wide table's own named, keyboard-reachable scrolling region, with a soft shadow on each edge that has more content behind it.",
  "files": [
    {
      "path": "lib/scroll-region.tsx",
      "content": "import { useEffect, useRef, type ReactNode } from \"react\";\n\n/**\n * A wide table's own scrolling region: named, reachable by keyboard, and\n * marked with a soft shadow on each edge that has more behind it. The outer\n * element carries `data-more-before` and `data-more-after` while content lies\n * past that edge; the stylesheet draws the shadows over the content, so an\n * opaque header cell cannot hide them.\n */\nexport function ScrollRegion({\n  label,\n  className,\n  children,\n}: {\n  label: string;\n  className?: string;\n  children: ReactNode;\n}) {\n  const edge = useRef<HTMLDivElement>(null);\n  const region = useRef<HTMLDivElement>(null);\n  useEffect(() => {\n    const outer = edge.current;\n    const inner = region.current;\n    if (!outer || !inner) return;\n    const update = () => {\n      const hidden = inner.scrollWidth - inner.clientWidth;\n      const at = Math.abs(inner.scrollLeft);\n      outer.toggleAttribute(\"data-more-before\", hidden > 1 && at > 1);\n      outer.toggleAttribute(\"data-more-after\", hidden > 1 && at < hidden - 1);\n    };\n    update();\n    inner.addEventListener(\"scroll\", update, { passive: true });\n    const observer = new ResizeObserver(update);\n    observer.observe(inner);\n    if (inner.firstElementChild) observer.observe(inner.firstElementChild);\n    return () => {\n      inner.removeEventListener(\"scroll\", update);\n      observer.disconnect();\n    };\n  }, []);\n  return (\n    <div className=\"scroll-edge\" ref={edge}>\n      <div\n        className={className}\n        ref={region}\n        tabIndex={0}\n        role=\"region\"\n        aria-label={label}\n      >\n        {children}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:lib",
      "target": "@lib/scroll-region.tsx"
    }
  ],
  "type": "registry:lib"
}