{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "scroll-fade",
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "src/components/watermelon-ui/scroll-fade.tsx",
      "content": "\"use client\";\n\nimport React, { useEffect, useRef, useState, useLayoutEffect, useCallback } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\ntype ScrollAxis = \"horizontal\" | \"vertical\" | \"both\";\n\ninterface ScrollFadeProps {\n  children: React.ReactNode;\n  className?: string;\n  hideScrollbar?: boolean;\n  axis?: ScrollAxis;\n}\n\nexport function ScrollFade({\n  children,\n  className,\n  hideScrollbar = true,\n  axis = \"horizontal\"\n}: ScrollFadeProps) {\n  const containerRef = useRef<HTMLDivElement | null>(null);\n  const contentRef = useRef<HTMLDivElement | null>(null);\n\n  const [showLeft, setShowLeft] = useState(false);\n  const [showRight, setShowRight] = useState(false);\n  const [showTop, setShowTop] = useState(false);\n  const [showBottom, setShowBottom] = useState(false);\n\n  const checkScroll = useCallback(() => {\n    const el = containerRef.current;\n    if (!el) return;\n\n    const {\n      scrollLeft,\n      scrollTop,\n      scrollWidth,\n      scrollHeight,\n      clientWidth,\n      clientHeight\n    } = el;\n\n    if (axis === \"horizontal\" || axis === \"both\") {\n      setShowLeft(scrollLeft > 0);\n      setShowRight(\n        Math.ceil(scrollLeft + clientWidth) < Math.floor(scrollWidth - 1)\n      );\n    }\n\n    if (axis === \"vertical\" || axis === \"both\") {\n      setShowTop(scrollTop > 0);\n      setShowBottom(\n        Math.ceil(scrollTop + clientHeight) < Math.floor(scrollHeight - 1)\n      );\n    }\n  }, [axis]);\n\n  useLayoutEffect(() => {\n    requestAnimationFrame(checkScroll);\n  }, [axis, checkScroll]);\n\n  useEffect(() => {\n    const container = containerRef.current;\n    if (!container) return;\n\n    const onScroll = () => checkScroll();\n    container.addEventListener(\"scroll\", onScroll, { passive: true });\n\n    const ro = new ResizeObserver(() => checkScroll());\n    if (contentRef.current) ro.observe(contentRef.current);\n    ro.observe(container);\n\n    const onResize = () => checkScroll();\n    window.addEventListener(\"resize\", onResize);\n\n    const raf = requestAnimationFrame(checkScroll);\n\n    return () => {\n      container.removeEventListener(\"scroll\", onScroll);\n      window.removeEventListener(\"resize\", onResize);\n      ro.disconnect();\n      cancelAnimationFrame(raf);\n    };\n  }, [axis, checkScroll]);\n\n  return (\n    <div className=\"relative\">\n      <div\n        ref={containerRef}\n        className={cn(\n          hideScrollbar &&\n          \"[scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden\",\n          axis === \"horizontal\" && \"w-full overflow-x-auto overflow-y-hidden\",\n          axis === \"vertical\" && \"h-full overflow-y-auto overflow-x-hidden\",\n          axis === \"both\" && \"overflow-auto\",\n          className\n        )}\n      >\n        <div\n          ref={contentRef}\n          className={cn(\n            axis === \"horizontal\" && \"w-fit min-w-full\",\n            axis === \"vertical\" && \"h-fit min-h-full\",\n            axis === \"both\" && \"min-w-full min-h-full w-fit h-fit\"\n          )}\n        >\n          {children}\n        </div>\n      </div>\n\n      {(axis === \"horizontal\" || axis === \"both\") && showLeft && (\n        <div\n          aria-hidden\n          className=\"pointer-events-none absolute left-0 top-0 h-full w-10 z-10\"\n          style={{\n            background:\n              \"linear-gradient(to right, var(--background) 0%, transparent 100%)\"\n          }}\n        />\n      )}\n\n      {(axis === \"horizontal\" || axis === \"both\") && showRight && (\n        <div\n          aria-hidden\n          className=\"pointer-events-none absolute right-0 top-0 h-full w-10 z-10\"\n          style={{\n            background:\n              \"linear-gradient(to left, var(--background) 0%, transparent 100%)\"\n          }}\n        />\n      )}\n\n      {(axis === \"vertical\" || axis === \"both\") && showTop && (\n        <div\n          aria-hidden\n          className=\"pointer-events-none absolute top-0 left-0 w-full h-10 z-10\"\n          style={{\n            background:\n              \"linear-gradient(to bottom, var(--background) 0%, transparent 100%)\"\n          }}\n        />\n      )}\n\n      {(axis === \"vertical\" || axis === \"both\") && showBottom && (\n        <div\n          aria-hidden\n          className=\"pointer-events-none absolute bottom-0 left-0 w-full h-10 z-10\"\n          style={{\n            background:\n              \"linear-gradient(to top, var(--background) 0%, transparent 100%)\"\n          }}\n        />\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/ui/scroll-fade.tsx"
    }
  ],
  "type": "registry:ui"
}
