{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "context-menu",
  "title": "Context Menu",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-native/components/context-menu/SubContentPrimitive.tsx",
      "content": "export { SubContent as SubContentPrimitive } from '@rn-primitives/context-menu'\n",
      "type": "registry:ui",
      "target": "~/components/ui/context-menu/SubContentPrimitive.tsx"
    },
    {
      "path": "packages/registry-native/components/context-menu/SubContentPrimitive.web.tsx",
      "content": "import * as React from 'react'\nimport { Pressable, type PressableStateCallbackType } from 'react-native'\nimport { Slot } from '@rn-primitives/slot'\nimport type { SubContentProps, SubContentRef } from '@rn-primitives/context-menu'\nimport * as Radix from '@radix-ui/react-context-menu'\n\n// The registry wrapper owns the scoped Portal; RN Primitives 1.5.2 adds an implicit body portal on web.\nexport const SubContentPrimitive = React.forwardRef<SubContentRef, SubContentProps & { className?: string }>(\n  ({ asChild = false, forceMount, style, ...props }, ref) => {\n    const Component = asChild ? Slot : Pressable\n    const bounds = { width: '100%', maxWidth: '100%', minWidth: 0 } as const\n    return (\n      <Radix.SubContent\n        forceMount={forceMount}\n        avoidCollisions\n        collisionPadding={8}\n        style={{\n          width: 320,\n          maxWidth: 'min(calc(100vw - 16px), var(--radix-context-menu-content-available-width, 320px))',\n          maxHeight: 'min(calc(100vh - 16px), var(--radix-context-menu-content-available-height, 100vh))',\n          overflowX: 'hidden',\n          overflowY: 'auto',\n        }}\n      >\n        <Component\n          ref={ref}\n          {...props}\n          style={\n            typeof style === 'function'\n              ? (state: PressableStateCallbackType) => [bounds, style(state)]\n              : [bounds, style]\n          }\n        />\n      </Radix.SubContent>\n    )\n  },\n)\nSubContentPrimitive.displayName = 'context-menu-SubContentPrimitive'\n",
      "type": "registry:ui",
      "target": "~/components/ui/context-menu/SubContentPrimitive.web.tsx"
    },
    {
      "path": "packages/registry-native/components/context-menu/ContextMenu.tsx",
      "content": "import * as React from 'react'\nimport { Platform, ScrollView, StyleSheet, View, I18nManager, useWindowDimensions } from 'react-native'\nimport * as Primitive from '@rn-primitives/context-menu'\nimport { cssInterop } from 'react-native-css-interop'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { PortalWindow, usePopupDismiss, PopupLayer } from '@/lib/portal'\nimport { renderTextChildren } from '@/lib/label-children'\nimport { cn } from '@/lib/utils'\nimport { Check, ChevronRight } from 'lucide-react-native'\nimport { useThemeColors } from '@/lib/theme'\nimport { SubContentPrimitive } from './SubContentPrimitive'\n\ncssInterop(Primitive.Root, { className: 'style' })\ncssInterop(Primitive.Trigger, { className: 'style' })\ncssInterop(Primitive.Content, { className: 'style' })\ncssInterop(Primitive.Overlay, { className: 'style' })\ncssInterop(Primitive.Item, { className: 'style' })\ncssInterop(Primitive.Group, { className: 'style' })\ncssInterop(Primitive.Label, { className: 'style' })\ncssInterop(Primitive.CheckboxItem, { className: 'style' })\ncssInterop(Primitive.RadioGroup, { className: 'style' })\ncssInterop(Primitive.RadioItem, { className: 'style' })\ncssInterop(Primitive.ItemIndicator, { className: 'style' })\ncssInterop(Primitive.Separator, { className: 'style' })\ncssInterop(Primitive.Sub, { className: 'style' })\ncssInterop(Primitive.SubTrigger, { className: 'style' })\ncssInterop(SubContentPrimitive, { className: 'style' })\n\nexport type ContextMenuProps = Primitive.RootProps & { className?: string }\n\nexport const ContextMenu = React.forwardRef<Primitive.RootRef, ContextMenuProps>(({ className, ...props }, ref) => (\n  <Primitive.Root ref={ref} className={cn('self-start', className)} {...props} />\n))\nContextMenu.displayName = 'ContextMenu'\nexport type ContextMenuTriggerProps = Omit<Primitive.TriggerProps, 'children'> & {\n  children?: React.ReactNode\n  className?: string\n  /** Native tap opens the same actions as long press; web keeps its context-menu gesture. */\n  openOnPress?: boolean\n}\nexport const ContextMenuTrigger = React.forwardRef<Primitive.TriggerRef, ContextMenuTriggerProps>(\n  ({ className, children, asChild, disabled, onPress, openOnPress = true, ...props }, ref) => {\n    const trigger = React.useRef<Primitive.TriggerRef>(null)\n    const setRef = React.useCallback(\n      (node: Primitive.TriggerRef | null) => {\n        trigger.current = node\n        if (typeof ref === 'function') return ref(node)\n        if (ref) ref.current = node\n      },\n      [ref],\n    )\n    return (\n      <Primitive.Trigger\n        accessibilityRole=\"button\"\n        {...props}\n        ref={setRef}\n        asChild={asChild}\n        disabled={disabled}\n        onPress={(event) => {\n          if (disabled) return\n          onPress?.(event)\n          if (Platform.OS !== 'web' && openOnPress && !event.isDefaultPrevented()) trigger.current?.open()\n        }}\n        className={cn(\n          'min-h-[48px] min-w-[48px] flex-row items-center justify-center gap-[8px] rounded-md border border-border bg-background px-[16px] py-[10px] active:bg-accent',\n          disabled && 'opacity-50',\n          className,\n        )}\n      >\n        {asChild ? children : renderTextChildren(children)}\n      </Primitive.Trigger>\n    )\n  },\n)\nContextMenuTrigger.displayName = 'ContextMenuTrigger'\nexport type ContextMenuContentProps = Omit<Primitive.ContentProps, 'children'> & {\n  children?: React.ReactNode\n  className?: string\n}\nexport const ContextMenuContent = React.forwardRef<Primitive.ContentRef, ContextMenuContentProps>(\n  (\n    { className, children, asChild, insets, style, align = 'start', side = 'bottom', sideOffset = 8, ...props },\n    ref,\n  ) => {\n    const root = Primitive.useRootContext()\n    const visible = root.open\n    const popup = usePopupDismiss(visible, () => root.onOpenChange(false))\n    const safe = useSafeAreaInsets()\n    const { width, height } = useWindowDimensions()\n    const bounds = { top: safe.top + 8, bottom: safe.bottom + 8, left: safe.left + 8, right: safe.right + 8, ...insets }\n    const maxWidth = Math.max(0, Math.min(320, width - bounds.left - bounds.right))\n    const maxHeight = Math.max(0, height - bounds.top - bounds.bottom)\n    // Native headless content must unmount to release its platform Back subscription.\n    if (Platform.OS !== 'web' && !visible) return null\n    return (\n      <Primitive.Portal\n        forceMount={props.forceMount}\n        hostName={popup.hostName}\n        {...(Platform.OS === 'web'\n          ? { container: (popup.container ?? undefined) as unknown as Primitive.PortalProps['container'] }\n          : {})}\n      >\n        <PortalWindow layer={popup}>\n          {Platform.OS !== 'web' ? <Primitive.Overlay accessible={false} style={StyleSheet.absoluteFill} /> : null}\n          <Primitive.Content\n            {...props}\n            ref={ref}\n            asChild={asChild}\n            align={align}\n            side={side}\n            sideOffset={sideOffset}\n            insets={bounds}\n            className={cn('gap-[4px] rounded-lg border border-border bg-popover p-[8px]', className)}\n            style={\n              StyleSheet.flatten([\n                { maxWidth, maxHeight, ...(Platform.OS !== 'web' ? { width: maxWidth } : {}) },\n                style,\n              ]) ?? undefined\n            }\n          >\n            {asChild ? (\n              children\n            ) : (\n              <ScrollView bounces={false} keyboardShouldPersistTaps=\"handled\" style={{ maxHeight, flexGrow: 0 }}>\n                {renderTextChildren(children)}\n              </ScrollView>\n            )}\n          </Primitive.Content>\n        </PortalWindow>\n      </Primitive.Portal>\n    )\n  },\n)\nContextMenuContent.displayName = 'ContextMenuContent'\nexport type ContextMenuItemProps = Omit<Primitive.ItemProps, 'children'> & {\n  children?: React.ReactNode\n  className?: string\n}\nexport const ContextMenuItem = React.forwardRef<Primitive.ItemRef, ContextMenuItemProps>(\n  ({ className, children, asChild, disabled, ...props }, ref) => (\n    <Primitive.Item\n      {...props}\n      ref={ref}\n      asChild={asChild}\n      disabled={disabled}\n      className={cn(\n        'min-h-[48px] min-w-[48px] flex-row items-center gap-[8px] rounded-md px-[12px] py-[10px] active:bg-accent',\n        disabled && 'opacity-50',\n        className,\n      )}\n    >\n      {asChild ? children : <View className=\"min-w-0 flex-1\">{renderTextChildren(children)}</View>}\n    </Primitive.Item>\n  ),\n)\nContextMenuItem.displayName = 'ContextMenuItem'\nexport type ContextMenuGroupProps = Primitive.GroupProps & { className?: string }\nexport const ContextMenuGroup = React.forwardRef<Primitive.GroupRef, ContextMenuGroupProps>(\n  ({ className, ...props }, ref) => <Primitive.Group ref={ref} className={cn('gap-[4px]', className)} {...props} />,\n)\nContextMenuGroup.displayName = 'ContextMenuGroup'\nexport type ContextMenuSeparatorProps = Primitive.SeparatorProps & { className?: string }\nexport const ContextMenuSeparator = React.forwardRef<Primitive.SeparatorRef, ContextMenuSeparatorProps>(\n  ({ className, ...props }, ref) => (\n    <Primitive.Separator ref={ref} className={cn('my-[4px] h-[1px] bg-border', className)} {...props} />\n  ),\n)\nContextMenuSeparator.displayName = 'ContextMenuSeparator'\nexport type ContextMenuLabelProps = Primitive.LabelProps & { className?: string }\nexport const ContextMenuLabel = React.forwardRef<Primitive.LabelRef, ContextMenuLabelProps>(\n  ({ className, ...props }, ref) => (\n    <Primitive.Label\n      ref={ref}\n      className={cn('px-[12px] py-[8px] text-[15px] font-medium leading-[21px] text-muted-foreground', className)}\n      {...props}\n    />\n  ),\n)\nContextMenuLabel.displayName = 'ContextMenuLabel'\nexport type ContextMenuItemIndicatorProps = Primitive.ItemIndicatorProps & { className?: string }\nexport const ContextMenuItemIndicator = React.forwardRef<Primitive.ItemIndicatorRef, ContextMenuItemIndicatorProps>(\n  ({ className, children, asChild, ...props }, ref) => {\n    const colors = useThemeColors()\n    return (\n      <Primitive.ItemIndicator\n        ref={ref}\n        asChild={asChild}\n        className={cn('size-[20px] items-center justify-center', className)}\n        {...props}\n      >\n        {asChild ? children : (children ?? <Check size={18} color={colors.foreground} aria-hidden />)}\n      </Primitive.ItemIndicator>\n    )\n  },\n)\nContextMenuItemIndicator.displayName = 'ContextMenuItemIndicator'\nexport type ContextMenuCheckboxItemProps = Omit<Primitive.CheckboxItemProps, 'children'> & {\n  children?: React.ReactNode\n  className?: string\n}\nexport const ContextMenuCheckboxItem = React.forwardRef<Primitive.CheckboxItemRef, ContextMenuCheckboxItemProps>(\n  ({ className, children, asChild, disabled, ...props }, ref) => (\n    <Primitive.CheckboxItem\n      {...props}\n      ref={ref}\n      asChild={asChild}\n      disabled={disabled}\n      className={cn(\n        'min-h-[48px] min-w-[48px] flex-row items-center gap-[8px] rounded-md px-[12px] py-[10px] active:bg-accent',\n        disabled && 'opacity-50',\n        className,\n      )}\n    >\n      {asChild ? (\n        children\n      ) : (\n        <>\n          <View aria-hidden className=\"size-[20px] items-center justify-center\">\n            <ContextMenuItemIndicator />\n          </View>\n          <View className=\"min-w-0 flex-1\">{renderTextChildren(children)}</View>\n        </>\n      )}\n    </Primitive.CheckboxItem>\n  ),\n)\nContextMenuCheckboxItem.displayName = 'ContextMenuCheckboxItem'\nexport type ContextMenuRadioItemProps = Omit<Primitive.RadioItemProps, 'children'> & {\n  children?: React.ReactNode\n  className?: string\n}\nexport const ContextMenuRadioItem = React.forwardRef<Primitive.RadioItemRef, ContextMenuRadioItemProps>(\n  ({ className, children, asChild, disabled, ...props }, ref) => (\n    <Primitive.RadioItem\n      {...props}\n      ref={ref}\n      asChild={asChild}\n      disabled={disabled}\n      className={cn(\n        'min-h-[48px] min-w-[48px] flex-row items-center gap-[8px] rounded-md px-[12px] py-[10px] active:bg-accent',\n        disabled && 'opacity-50',\n        className,\n      )}\n    >\n      {asChild ? (\n        children\n      ) : (\n        <>\n          <View aria-hidden className=\"size-[20px] items-center justify-center\">\n            <ContextMenuItemIndicator />\n          </View>\n          <View className=\"min-w-0 flex-1\">{renderTextChildren(children)}</View>\n        </>\n      )}\n    </Primitive.RadioItem>\n  ),\n)\nContextMenuRadioItem.displayName = 'ContextMenuRadioItem'\nexport const ContextMenuRadioGroup = Primitive.RadioGroup\nexport const ContextMenuSub = Primitive.Sub\nexport type ContextMenuSubTriggerProps = Omit<Primitive.SubTriggerProps, 'children'> & {\n  children?: React.ReactNode\n  className?: string\n}\nexport const ContextMenuSubTrigger = React.forwardRef<Primitive.SubTriggerRef, ContextMenuSubTriggerProps>(\n  ({ className, children, asChild, disabled, ...props }, ref) => {\n    const colors = useThemeColors()\n    return (\n      <Primitive.SubTrigger\n        ref={ref}\n        asChild={asChild}\n        disabled={disabled}\n        className={cn(\n          'min-h-[48px] min-w-[48px] flex-row items-center gap-[8px] rounded-md px-[12px] py-[10px] active:bg-accent',\n          disabled && 'opacity-50',\n          className,\n        )}\n        {...props}\n      >\n        {asChild ? (\n          children\n        ) : (\n          <>\n            <View className=\"min-w-0 flex-1\">{renderTextChildren(children)}</View>\n            <ChevronRight\n              size={20}\n              color={colors.foreground}\n              style={{ transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }] }}\n              aria-hidden\n            />\n          </>\n        )}\n      </Primitive.SubTrigger>\n    )\n  },\n)\nContextMenuSubTrigger.displayName = 'ContextMenuSubTrigger'\n\nexport type ContextMenuSubContentProps = Omit<Primitive.SubContentProps, 'children'> & {\n  children?: React.ReactNode\n  className?: string\n}\nexport const ContextMenuSubContent = React.forwardRef<Primitive.SubContentRef, ContextMenuSubContentProps>(\n  ({ className, children, asChild, ...props }, ref) => {\n    const root = Primitive.useRootContext()\n    const sub = Primitive.useSubContext()\n    const visible = root.open && sub.open\n    const popup = usePopupDismiss(visible, () => sub.onOpenChange(false))\n    if (Platform.OS !== 'web' && !visible) return null\n    const content = (\n      <SubContentPrimitive\n        ref={ref}\n        asChild={asChild}\n        className={cn('gap-[4px] rounded-lg border border-border bg-popover p-[8px]', className)}\n        {...props}\n      >\n        {asChild ? children : renderTextChildren(children)}\n      </SubContentPrimitive>\n    )\n    return (\n      <PopupLayer layer={popup}>\n        {Platform.OS === 'web' ? (\n          <Primitive.Portal\n            forceMount={props.forceMount}\n            hostName={popup.hostName}\n            {...(Platform.OS === 'web'\n              ? { container: (popup.container ?? undefined) as unknown as Primitive.PortalProps['container'] }\n              : {})}\n          >\n            {content}\n          </Primitive.Portal>\n        ) : (\n          content\n        )}\n      </PopupLayer>\n    )\n  },\n)\nContextMenuSubContent.displayName = 'ContextMenuSubContent'\n",
      "type": "registry:ui",
      "target": "~/components/ui/context-menu/ContextMenu.tsx"
    },
    {
      "path": "packages/registry-native/components/context-menu/index.ts",
      "content": "export * from './ContextMenu'\n",
      "type": "registry:ui",
      "target": "~/components/ui/context-menu/index.ts"
    }
  ],
  "dependencies": [
    "@rn-primitives/slot",
    "@radix-ui/react-context-menu@^2.2.16",
    "@rn-primitives/context-menu",
    "react-native-safe-area-context",
    "lucide-react-native",
    "react-native-svg",
    "react-native-css-interop"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/portal.json",
    "https://native.uipkge.dev/r/native/label-children.json"
  ],
  "description": "Touch-ready context-menu with composable actions, checked choices, submenus, and portal positioning.",
  "categories": [
    "overlay",
    "navigation"
  ]
}