{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "share-button",
  "title": "Share Button",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-native/components/share-button/ShareButton.tsx",
      "content": "import * as React from 'react'\nimport { Share, type GestureResponderEvent, type ShareAction, type ShareContent, type ShareOptions } from 'react-native'\nimport { Button, type ButtonProps } from '@/components/ui/button'\n\nexport interface ShareButtonProps extends ButtonProps {\n  /** Payload passed to `Share.share`. */\n  content: ShareContent\n  /** Optional platform share options passed to `Share.share`. */\n  options?: ShareOptions\n  /**\n   * Receives the raw `ShareAction` returned by `Share.share`, or `undefined` on React Native Web.\n   *\n   * On Android, `Share.share` always resolves with `Share.sharedAction` even when the chooser is\n   * dismissed. On iOS, cancelling the sheet resolves with `Share.dismissedAction`.\n   */\n  onResult?: (result: ShareAction | undefined) => void\n  /** Called when `Share.share` rejects. */\n  onError?: (error: Error) => void\n}\n\n/**\n * Triggers the system share sheet via React Native `Share.share`.\n *\n * Platform note: Android always resolves `Share.sharedAction` even if the user dismisses the\n * chooser; iOS can resolve `Share.dismissedAction`; React Native Web may resolve `undefined`.\n */\nconst ShareButton = React.forwardRef<React.ComponentRef<typeof Button>, ShareButtonProps>(\n  ({ content, options, onResult, onError, onPress, disabled, loading = false, children = 'Share', ...props }, ref) => {\n    const [pending, setPending] = React.useState(false)\n    const mountedRef = React.useRef(true)\n    const pendingRef = React.useRef(false)\n\n    React.useEffect(() => {\n      mountedRef.current = true\n      return () => {\n        mountedRef.current = false\n      }\n    }, [])\n\n    async function handlePress(event: GestureResponderEvent) {\n      if (disabled || loading || pendingRef.current) return\n      onPress?.(event)\n      if (event?.defaultPrevented) return\n\n      pendingRef.current = true\n      setPending(true)\n      let result: ShareAction | undefined\n      let nativeError: Error | undefined\n      try {\n        result = (await Share.share(content, options)) as ShareAction | undefined\n      } catch (error) {\n        nativeError = error instanceof Error ? error : new Error(String(error))\n      }\n\n      pendingRef.current = false\n      if (!mountedRef.current) return\n      setPending(false)\n\n      if (nativeError) {\n        onError?.(nativeError)\n        return\n      }\n      onResult?.(result)\n    }\n\n    return (\n      <Button ref={ref} disabled={disabled} loading={loading || pending} onPress={handlePress} {...props}>\n        {children}\n      </Button>\n    )\n  },\n)\nShareButton.displayName = 'ShareButton'\n\nexport { ShareButton }\n",
      "type": "registry:ui",
      "target": "~/components/ui/share-button/ShareButton.tsx"
    },
    {
      "path": "packages/registry-native/components/share-button/index.ts",
      "content": "export { ShareButton, type ShareButtonProps } from './ShareButton'\n",
      "type": "registry:ui",
      "target": "~/components/ui/share-button/index.ts"
    }
  ],
  "dependencies": [],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/button.json"
  ],
  "description": "Action Button wrapping React Native Share.share with rapid-press guards and raw platform ShareAction reporting.",
  "categories": [
    "control"
  ]
}