{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "scroll-area",
  "type": "registry:ui",
  "title": "Scroll Area",
  "description": "The scroll-area primitive.",
  "dependencies": [],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/theme.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/ui/scroll-area.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/ui/scroll-area.tsx",
      "content": "import { forwardRef, useCallback, useEffect, useRef, useState, type HTMLAttributes, type ReactNode } from 'react';\nimport { cn } from '../lib/utils';\n\nexport interface ScrollAreaProps extends Omit<HTMLAttributes<HTMLDivElement>, 'aria-label'> {\n  /** Required: names the region, which is a tab stop so a keyboard can scroll it. */\n  'aria-label': string;\n  /** Which way it scrolls. Default vertical. Give the height or width with a class (max-h-64). */\n  orientation?: 'vertical' | 'horizontal' | 'both';\n  children: ReactNode;\n}\n\ntype Edge = { start: boolean; end: boolean };\n\n/**\n * Content that scrolls inside a fixed box. It is a named region and a tab stop (arrow keys, Page Up and Page Down, Space and Home\n * and End scroll it natively), the scrollbar is drawn thin but always as wide as it needs to be to grab, and a soft edge shows where\n * there is more to see. Use it for a list in a card, a code block or a table that must not push the page.\n */\nexport const ScrollArea = forwardRef<HTMLDivElement, ScrollAreaProps>(function ScrollArea({ orientation = 'vertical', className, children, onScroll, ...rest }, ref) {\n  const inner = useRef<HTMLDivElement | null>(null);\n  const [edge, setEdge] = useState<Edge>({ start: false, end: false });\n  const horizontal = orientation === 'horizontal';\n  const measure = useCallback(() => {\n    const el = inner.current;\n    if (!el) return;\n    const [pos, size, view] = horizontal ? [el.scrollLeft, el.scrollWidth, el.clientWidth] : [el.scrollTop, el.scrollHeight, el.clientHeight];\n    setEdge({ start: pos > 1, end: size - view - pos > 1 });\n  }, [horizontal]);\n  useEffect(() => {\n    measure();\n    const el = inner.current;\n    if (!el || typeof ResizeObserver === 'undefined') return;\n    const ro = new ResizeObserver(measure);\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, [measure]);\n  return (\n    <div className=\"relative min-w-0\">\n      <div\n        ref={(el) => {\n          inner.current = el;\n          if (typeof ref === 'function') ref(el);\n          else if (ref) ref.current = el;\n        }}\n        role=\"region\"\n        tabIndex={0}\n        onScroll={(e) => {\n          measure();\n          onScroll?.(e);\n        }}\n        className={cn(\n          'rounded-kh focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--kh-focus)',\n          '[scrollbar-color:var(--kh-line-strong)_transparent] [scrollbar-width:thin] [&::-webkit-scrollbar]:size-2.5 [&::-webkit-scrollbar-thumb]:rounded-kh-pill [&::-webkit-scrollbar-thumb]:bg-kh-line-strong [&::-webkit-scrollbar-track]:bg-transparent',\n          orientation === 'vertical' && 'overflow-y-auto overflow-x-hidden',\n          horizontal && 'overflow-x-auto overflow-y-hidden',\n          orientation === 'both' && 'overflow-auto',\n          className,\n        )}\n        {...rest}\n      >\n        {children}\n      </div>\n      {orientation !== 'both' && (\n        <>\n          <span aria-hidden data-edge=\"start\" hidden={!edge.start} className={cn('pointer-events-none absolute from-kh-surface to-transparent', horizontal ? 'inset-y-0 left-0 w-6 bg-linear-to-r' : 'inset-x-0 top-0 h-6 bg-linear-to-b')} />\n          <span aria-hidden data-edge=\"end\" hidden={!edge.end} className={cn('pointer-events-none absolute from-kh-surface to-transparent', horizontal ? 'inset-y-0 right-0 w-6 bg-linear-to-l' : 'inset-x-0 bottom-0 h-6 bg-linear-to-t')} />\n        </>\n      )}\n    </div>\n  );\n});\n"
    }
  ]
}
