{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "scroll-shadow",
  "title": "Scroll Shadow",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-native/components/scroll-shadow/ScrollShadow.tsx",
      "content": "import * as React from 'react'\nimport {\n  ScrollView,\n  View,\n  type LayoutChangeEvent,\n  type NativeScrollEvent,\n  type NativeSyntheticEvent,\n  type ScrollViewProps,\n  type ViewStyle,\n} from 'react-native'\nimport Animated, { useAnimatedStyle, useReducedMotion, useSharedValue, withTiming } from 'react-native-reanimated'\nimport Svg, { Defs, LinearGradient, Rect, Stop } from 'react-native-svg'\nimport { motionDurations } from '@/lib/motion'\nimport { useThemeColors } from '@/lib/theme'\nimport { cn } from '@/lib/utils'\n\nconst DEFAULT_SHADOW_SIZE = 28\nconst OVERFLOW_THRESHOLD = 1\n\nexport type ScrollShadowOrientation = 'vertical' | 'horizontal'\n\nexport interface ScrollShadowProps extends ScrollViewProps {\n  /** Scroll axis for edge fades. Automatically inferred as `'horizontal'` when `horizontal={true}`. */\n  orientation?: ScrollShadowOrientation\n  /** Thickness of each edge fade in pixels. Clamped to `>= 0`. */\n  size?: number\n  /** Fade color; defaults to the active theme's `background` token so edges blend in light and dark modes. */\n  shadowColor?: string\n  /** Hide both edge fades without unmounting the scroll container. */\n  hideShadows?: boolean\n  /** Classes applied to the outer bounded viewport `View`. */\n  className?: string\n  /** Optional classes applied to the inner `ScrollView`. */\n  scrollViewClassName?: string\n}\n\ninterface ShadowVisibility {\n  showLeading: boolean\n  showTrailing: boolean\n}\n\nfunction computeShadowVisibility(viewportSize: number, contentSize: number, offset: number): ShadowVisibility {\n  if (viewportSize <= 0 || contentSize <= viewportSize + OVERFLOW_THRESHOLD) {\n    return { showLeading: false, showTrailing: false }\n  }\n  return {\n    showLeading: offset > OVERFLOW_THRESHOLD,\n    showTrailing: offset + viewportSize < contentSize - OVERFLOW_THRESHOLD,\n  }\n}\n\nfunction sanitizeGradientId(id: string): string {\n  return id.replace(/[^a-zA-Z0-9_-]/g, '')\n}\n\nexport const ScrollShadow = React.forwardRef<React.ComponentRef<typeof ScrollView>, ScrollShadowProps>(\n  (\n    {\n      orientation = 'vertical',\n      horizontal,\n      size = DEFAULT_SHADOW_SIZE,\n      shadowColor,\n      hideShadows = false,\n      className,\n      scrollViewClassName,\n      scrollEventThrottle,\n      onLayout,\n      onContentSizeChange,\n      onScroll,\n      children,\n      ...props\n    },\n    ref,\n  ) => {\n    const isHorizontal = horizontal ?? orientation === 'horizontal'\n    const shadowSize = Number.isFinite(size) ? Math.max(0, size) : DEFAULT_SHADOW_SIZE\n    const themeColors = useThemeColors()\n    const resolvedColor = shadowColor ?? themeColors.background\n    const reduced = useReducedMotion()\n\n    const idPrefix = sanitizeGradientId(React.useId())\n    const leadingGradientId = `scroll-shadow-leading-${idPrefix}`\n    const trailingGradientId = `scroll-shadow-trailing-${idPrefix}`\n\n    const viewportRef = React.useRef({ width: 0, height: 0 })\n    const contentRef = React.useRef({ width: 0, height: 0 })\n    const offsetRef = React.useRef({ x: 0, y: 0 })\n\n    const [visibility, setVisibility] = React.useState<ShadowVisibility>({\n      showLeading: false,\n      showTrailing: false,\n    })\n\n    const syncVisibility = React.useCallback((axisHorizontal: boolean) => {\n      const viewportSize = axisHorizontal ? viewportRef.current.width : viewportRef.current.height\n      const contentSize = axisHorizontal ? contentRef.current.width : contentRef.current.height\n      const offset = axisHorizontal ? offsetRef.current.x : offsetRef.current.y\n      const next = computeShadowVisibility(viewportSize, contentSize, offset)\n      setVisibility((prev) =>\n        prev.showLeading === next.showLeading && prev.showTrailing === next.showTrailing ? prev : next,\n      )\n    }, [])\n\n    React.useEffect(() => {\n      syncVisibility(isHorizontal)\n    }, [isHorizontal, syncVisibility])\n\n    const leadingOpacity = useSharedValue(0)\n    const trailingOpacity = useSharedValue(0)\n\n    React.useEffect(() => {\n      const targetLeading = !hideShadows && shadowSize > 0 && visibility.showLeading ? 1 : 0\n      const targetTrailing = !hideShadows && shadowSize > 0 && visibility.showTrailing ? 1 : 0\n      leadingOpacity.value = reduced ? targetLeading : withTiming(targetLeading, { duration: motionDurations.fast })\n      trailingOpacity.value = reduced ? targetTrailing : withTiming(targetTrailing, { duration: motionDurations.fast })\n    }, [\n      hideShadows,\n      shadowSize,\n      visibility.showLeading,\n      visibility.showTrailing,\n      reduced,\n      leadingOpacity,\n      trailingOpacity,\n    ])\n\n    const leadingStyle = useAnimatedStyle(() => ({ opacity: leadingOpacity.value }))\n    const trailingStyle = useAnimatedStyle(() => ({ opacity: trailingOpacity.value }))\n\n    const handleLayout = (event: LayoutChangeEvent) => {\n      const { width, height } = event.nativeEvent.layout\n      viewportRef.current = { width: Math.max(0, width), height: Math.max(0, height) }\n      syncVisibility(isHorizontal)\n      onLayout?.(event)\n    }\n\n    const handleContentSizeChange = (contentWidth: number, contentHeight: number) => {\n      contentRef.current = { width: Math.max(0, contentWidth), height: Math.max(0, contentHeight) }\n      syncVisibility(isHorizontal)\n      onContentSizeChange?.(contentWidth, contentHeight)\n    }\n\n    const handleScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {\n      const { contentOffset, contentSize, layoutMeasurement } = event.nativeEvent\n      offsetRef.current = { x: contentOffset.x, y: contentOffset.y }\n      if (contentSize) {\n        contentRef.current = { width: Math.max(0, contentSize.width), height: Math.max(0, contentSize.height) }\n      }\n      if (layoutMeasurement) {\n        viewportRef.current = {\n          width: Math.max(0, layoutMeasurement.width),\n          height: Math.max(0, layoutMeasurement.height),\n        }\n      }\n      syncVisibility(isHorizontal)\n      onScroll?.(event)\n    }\n\n    const leadingPositionStyle: ViewStyle = isHorizontal\n      ? { position: 'absolute', top: 0, bottom: 0, left: 0, width: shadowSize }\n      : { position: 'absolute', top: 0, left: 0, right: 0, height: shadowSize }\n\n    const trailingPositionStyle: ViewStyle = isHorizontal\n      ? { position: 'absolute', top: 0, bottom: 0, right: 0, width: shadowSize }\n      : { position: 'absolute', bottom: 0, left: 0, right: 0, height: shadowSize }\n\n    const gradientCoords = isHorizontal\n      ? { x1: '0', y1: '0', x2: '1', y2: '0' }\n      : { x1: '0', y1: '0', x2: '0', y2: '1' }\n\n    const renderOverlays = !hideShadows && shadowSize > 0\n\n    return (\n      <View className={cn('relative overflow-hidden', className)}>\n        <ScrollView\n          {...props}\n          ref={ref}\n          horizontal={isHorizontal}\n          scrollEventThrottle={scrollEventThrottle ?? 16}\n          className={scrollViewClassName}\n          onLayout={handleLayout}\n          onContentSizeChange={handleContentSizeChange}\n          onScroll={handleScroll}\n        >\n          {children}\n        </ScrollView>\n\n        {renderOverlays ? (\n          <>\n            <Animated.View\n              pointerEvents=\"none\"\n              accessibilityElementsHidden\n              importantForAccessibility=\"no-hide-descendants\"\n              style={[leadingPositionStyle, leadingStyle]}\n            >\n              <Svg width=\"100%\" height=\"100%\">\n                <Defs>\n                  <LinearGradient id={leadingGradientId} {...gradientCoords}>\n                    <Stop offset=\"0\" stopColor={resolvedColor} stopOpacity=\"1\" />\n                    <Stop offset=\"1\" stopColor={resolvedColor} stopOpacity=\"0\" />\n                  </LinearGradient>\n                </Defs>\n                <Rect x=\"0\" y=\"0\" width=\"100%\" height=\"100%\" fill={`url(#${leadingGradientId})`} />\n              </Svg>\n            </Animated.View>\n\n            <Animated.View\n              pointerEvents=\"none\"\n              accessibilityElementsHidden\n              importantForAccessibility=\"no-hide-descendants\"\n              style={[trailingPositionStyle, trailingStyle]}\n            >\n              <Svg width=\"100%\" height=\"100%\">\n                <Defs>\n                  <LinearGradient id={trailingGradientId} {...gradientCoords}>\n                    <Stop offset=\"0\" stopColor={resolvedColor} stopOpacity=\"0\" />\n                    <Stop offset=\"1\" stopColor={resolvedColor} stopOpacity=\"1\" />\n                  </LinearGradient>\n                </Defs>\n                <Rect x=\"0\" y=\"0\" width=\"100%\" height=\"100%\" fill={`url(#${trailingGradientId})`} />\n              </Svg>\n            </Animated.View>\n          </>\n        ) : null}\n      </View>\n    )\n  },\n)\nScrollShadow.displayName = 'ScrollShadow'\n",
      "type": "registry:ui",
      "target": "~/components/ui/scroll-shadow/ScrollShadow.tsx"
    },
    {
      "path": "packages/registry-native/components/scroll-shadow/index.ts",
      "content": "export { ScrollShadow, type ScrollShadowOrientation, type ScrollShadowProps } from './ScrollShadow'\n",
      "type": "registry:ui",
      "target": "~/components/ui/scroll-shadow/index.ts"
    }
  ],
  "dependencies": [
    "react-native-reanimated",
    "react-native-svg"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/motion.json",
    "https://native.uipkge.dev/r/native/theme.json",
    "https://native.uipkge.dev/r/native/utils.json"
  ],
  "description": "Bounded scroll viewport with measured SVG edge fades that animate smoothly as content overflows vertically or horizontally.",
  "categories": [
    "layout"
  ]
}