{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pressable-feedback",
  "title": "Pressable Feedback",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-native/components/pressable-feedback/PressableFeedback.tsx",
      "content": "import * as React from 'react'\nimport {\n  Pressable,\n  StyleSheet,\n  type GestureResponderEvent,\n  type PressableProps,\n  type StyleProp,\n  type ViewProps,\n  type ViewStyle,\n} from 'react-native'\nimport Animated, {\n  useAnimatedStyle,\n  useReducedMotion,\n  useSharedValue,\n  withSpring,\n  withTiming,\n  type SharedValue,\n} from 'react-native-reanimated'\nimport { motionDurations, motionSprings } from '@/lib/motion'\nimport { cn } from '@/lib/utils'\n\nexport type PressableFeedbackMode = 'scale' | 'spring' | 'none'\n\nexport interface PressableFeedbackContextValue {\n  pressed: boolean\n  disabled: boolean\n  progress: SharedValue<number>\n}\n\nconst PressableFeedbackContext = React.createContext<PressableFeedbackContextValue | null>(null)\n\nexport function usePressableFeedback(): PressableFeedbackContextValue {\n  const ctx = React.useContext(PressableFeedbackContext)\n  const fallbackProgress = useSharedValue(0)\n  return React.useMemo(\n    () =>\n      ctx ?? {\n        pressed: false,\n        disabled: false,\n        progress: fallbackProgress,\n      },\n    [ctx, fallbackProgress],\n  )\n}\n\nfunction readProgressValue(raw: unknown): number {\n  'worklet'\n  if (typeof raw === 'number') return raw\n  if (raw && typeof raw === 'object' && 'value' in raw) {\n    const candidate = (raw as { value: unknown }).value\n    if (typeof candidate === 'number') return candidate\n  }\n  return 0\n}\n\nfunction clampScaleTo(scaleTo: number): number {\n  if (!Number.isFinite(scaleTo)) return 0.98\n  return Math.min(1, Math.max(0.01, scaleTo))\n}\n\nfunction clampOpacity(opacity: number): number {\n  if (!Number.isFinite(opacity)) return 0.08\n  return Math.min(1, Math.max(0, opacity))\n}\n\nexport interface PressableFeedbackProps extends Omit<PressableProps, 'children'> {\n  children?: React.ReactNode\n  className?: string\n  /** Press physics. `scale` uses fast timing, `spring` uses the shared snappy spring, `none` skips scale. */\n  feedback?: PressableFeedbackMode\n  /** Target scale when pressed, clamped to `(0, 1]`. Defaults to `0.98`. */\n  scaleTo?: number\n  disabled?: boolean\n}\n\nconst PressableFeedback = React.forwardRef<React.ComponentRef<typeof Pressable>, PressableFeedbackProps>(\n  (\n    {\n      children,\n      className,\n      feedback = 'scale',\n      scaleTo = 0.98,\n      disabled,\n      onPressIn,\n      onPressOut,\n      accessibilityRole,\n      accessibilityState,\n      ...props\n    },\n    ref,\n  ) => {\n    const reduced = useReducedMotion()\n    const isDisabled = Boolean(disabled)\n    const [pressed, setPressed] = React.useState(false)\n    const progress = useSharedValue(0)\n    const targetScale = clampScaleTo(scaleTo)\n    const shouldAnimateScale = feedback !== 'none' && !reduced && !isDisabled\n\n    React.useEffect(() => {\n      if (isDisabled) {\n        setPressed(false)\n        progress.value = 0\n      }\n    }, [isDisabled, progress])\n\n    const scaleStyle = useAnimatedStyle(() => {\n      const current = readProgressValue(progress.value)\n      return {\n        transform: [{ scale: 1 - (1 - targetScale) * current }],\n      }\n    })\n\n    function handlePressIn(event: GestureResponderEvent) {\n      if (!isDisabled) {\n        setPressed(true)\n        progress.value = reduced\n          ? 1\n          : feedback === 'spring'\n            ? withSpring(1, motionSprings.snappy)\n            : withTiming(1, { duration: motionDurations.fast })\n      }\n      onPressIn?.(event)\n    }\n\n    function handlePressOut(event: GestureResponderEvent) {\n      if (!isDisabled) {\n        setPressed(false)\n        progress.value = reduced\n          ? 0\n          : feedback === 'spring'\n            ? withSpring(0, motionSprings.snappy)\n            : withTiming(0, { duration: motionDurations.fast })\n      }\n      onPressOut?.(event)\n    }\n\n    const contextValue = React.useMemo<PressableFeedbackContextValue>(\n      () => ({\n        pressed: isDisabled ? false : pressed,\n        disabled: isDisabled,\n        progress,\n      }),\n      [isDisabled, pressed, progress],\n    )\n\n    const mergedAccessibilityState =\n      isDisabled || accessibilityState ? { ...accessibilityState, disabled: isDisabled } : undefined\n\n    return (\n      <PressableFeedbackContext.Provider value={contextValue}>\n        <Animated.View style={shouldAnimateScale ? scaleStyle : undefined}>\n          <Pressable\n            ref={ref}\n            disabled={isDisabled}\n            accessibilityRole={accessibilityRole}\n            accessibilityState={mergedAccessibilityState}\n            onPressIn={handlePressIn}\n            onPressOut={handlePressOut}\n            className={cn(isDisabled && 'opacity-50', className)}\n            {...props}\n          >\n            {children}\n          </Pressable>\n        </Animated.View>\n      </PressableFeedbackContext.Provider>\n    )\n  },\n)\nPressableFeedback.displayName = 'PressableFeedback'\n\nexport interface PressableFeedbackHighlightProps extends Omit<ViewProps, 'style' | 'pointerEvents'> {\n  className?: string\n  /** Peak highlight opacity while pressed, clamped to `[0, 1]`. Defaults to `0.08`. */\n  opacity?: number\n  style?: StyleProp<ViewStyle>\n}\n\nconst PressableFeedbackHighlight = React.forwardRef<\n  React.ComponentRef<typeof Animated.View>,\n  PressableFeedbackHighlightProps\n>(({ className, opacity = 0.08, style, ...props }, ref) => {\n  const { pressed, disabled, progress } = usePressableFeedback()\n  const reduced = useReducedMotion()\n  const peakOpacity = clampOpacity(opacity)\n\n  const animatedStyle = useAnimatedStyle(() => {\n    const current = readProgressValue(progress.value)\n    return {\n      opacity: current * peakOpacity,\n    }\n  })\n\n  const resolvedOpacityStyle = reduced ? { opacity: !disabled && pressed ? peakOpacity : 0 } : animatedStyle\n\n  return (\n    <Animated.View\n      ref={ref}\n      pointerEvents=\"none\"\n      accessibilityElementsHidden\n      importantForAccessibility=\"no-hide-descendants\"\n      className={cn('bg-foreground', className)}\n      style={[StyleSheet.absoluteFill, resolvedOpacityStyle, style]}\n      {...props}\n    />\n  )\n})\nPressableFeedbackHighlight.displayName = 'PressableFeedbackHighlight'\n\nexport { PressableFeedback, PressableFeedbackHighlight }\n",
      "type": "registry:ui",
      "target": "~/components/ui/pressable-feedback/PressableFeedback.tsx"
    },
    {
      "path": "packages/registry-native/components/pressable-feedback/index.ts",
      "content": "export {\n  PressableFeedback,\n  PressableFeedbackHighlight,\n  usePressableFeedback,\n  type PressableFeedbackContextValue,\n  type PressableFeedbackHighlightProps,\n  type PressableFeedbackMode,\n  type PressableFeedbackProps,\n} from './PressableFeedback'\n",
      "type": "registry:ui",
      "target": "~/components/ui/pressable-feedback/index.ts"
    }
  ],
  "dependencies": [
    "react-native-reanimated"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/motion.json",
    "https://native.uipkge.dev/r/native/utils.json"
  ],
  "description": "Shared press-state container (Pressable + Reanimated) with optional highlight scrim for cards, tiles, and list rows without forcing button chrome or role.",
  "categories": [
    "control"
  ]
}