{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "swipeable-row",
  "title": "Swipeable Row",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-native/components/swipeable-row/SwipeableRow.tsx",
      "content": "import * as React from 'react'\nimport { Pressable, View, type ViewProps } from 'react-native'\nimport { GestureHandlerRootView } from 'react-native-gesture-handler'\nimport NativeSwipeable, {\n  type SwipeableMethods,\n  type SwipeableProps,\n} from 'react-native-gesture-handler/ReanimatedSwipeable'\nimport { Button, type ButtonProps } from '@/components/ui/button'\nimport { renderTextChildren } from '@/lib/label-children'\nimport { cn } from '@/lib/utils'\n\ninterface RowState {\n  disabled: boolean\n  open: boolean\n  canOpen: (direction: 'left' | 'right') => boolean\n  show: (direction: 'left' | 'right') => void\n  close: () => void\n}\nconst Context = React.createContext<RowState | null>(null)\nfunction useRow() {\n  const row = React.useContext(Context)\n  if (!row) throw new Error('SwipeableRow parts must be inside SwipeableRow')\n  return row\n}\nexport interface SwipeableRowProps extends Omit<SwipeableProps, 'ref'> {\n  children?: React.ReactNode\n  disabled?: boolean\n  className?: string\n  style?: ViewProps['style']\n}\nexport const SwipeableRow = React.forwardRef<SwipeableMethods, SwipeableRowProps>(\n  (\n    { children, disabled = false, enabled = true, className, style, onSwipeableOpen, onSwipeableClose, ...props },\n    ref,\n  ) => {\n    const native = React.useRef<SwipeableMethods>(null)\n    const [open, setOpen] = React.useState(false)\n    const isDisabled = disabled || !enabled\n    const canOpen = (direction: 'left' | 'right') =>\n      !isDisabled && !!(direction === 'left' ? props.renderLeftActions : props.renderRightActions)\n    const show = (direction: 'left' | 'right') => {\n      if (!canOpen(direction) || !native.current) return\n      setOpen(true)\n      if (direction === 'left') native.current?.openLeft()\n      else native.current?.openRight()\n    }\n    const close = () => {\n      setOpen(false)\n      native.current?.close()\n    }\n    React.useImperativeHandle(ref, () => ({\n      close,\n      openLeft: () => show('left'),\n      openRight: () => show('right'),\n      reset: () => {\n        native.current?.reset()\n        setOpen(false)\n      },\n    }))\n    React.useEffect(() => {\n      if (isDisabled) {\n        native.current?.reset()\n        setOpen(false)\n      }\n    }, [isDisabled])\n    return (\n      <Context.Provider value={{ disabled: isDisabled, open, canOpen, show, close }}>\n        <View className={cn('w-full overflow-hidden rounded-lg border border-border', className)} style={style}>\n          <GestureHandlerRootView style={{ flex: 0 }}>\n            <NativeSwipeable\n              overshootLeft={false}\n              overshootRight={false}\n              {...props}\n              ref={native}\n              enabled={!isDisabled}\n              onSwipeableOpen={(direction) => {\n                setOpen(true)\n                onSwipeableOpen?.(direction)\n              }}\n              onSwipeableClose={(direction) => {\n                setOpen(false)\n                onSwipeableClose?.(direction)\n              }}\n            >\n              <View className=\"min-h-[48px] bg-card\">{renderTextChildren(children)}</View>\n            </NativeSwipeable>\n          </GestureHandlerRootView>\n        </View>\n      </Context.Provider>\n    )\n  },\n)\nSwipeableRow.displayName = 'SwipeableRow'\nexport interface SwipeableRowOpenProps extends ButtonProps {\n  direction?: 'left' | 'right'\n}\nexport const SwipeableRowOpen = React.forwardRef<React.ComponentRef<typeof Pressable>, SwipeableRowOpenProps>(\n  ({ direction = 'right', children, disabled, onPress, ...props }, ref) => {\n    const row = useRow()\n    const isDisabled = row.disabled || !!disabled || !row.canOpen(direction)\n    return (\n      <Button\n        variant=\"outline\"\n        {...props}\n        ref={ref}\n        disabled={isDisabled}\n        onPress={(event) => {\n          if (isDisabled) return\n          onPress?.(event)\n          if (event.isDefaultPrevented()) return\n          if (row.open) row.close()\n          else row.show(direction)\n        }}\n      >\n        {children ?? (row.open ? 'Close actions' : 'Show actions')}\n      </Button>\n    )\n  },\n)\nSwipeableRowOpen.displayName = 'SwipeableRowOpen'\nexport interface SwipeableRowActionProps extends ButtonProps {\n  closeOnPress?: boolean\n}\nexport const SwipeableRowAction = React.forwardRef<React.ComponentRef<typeof Pressable>, SwipeableRowActionProps>(\n  ({ children, closeOnPress = true, disabled, onPress, ...props }, ref) => {\n    const row = useRow()\n    const isDisabled = row.disabled || !!disabled\n    return (\n      <Button\n        {...props}\n        ref={ref}\n        disabled={isDisabled}\n        onPress={(event) => {\n          if (isDisabled) return\n          onPress?.(event)\n          if (!event.isDefaultPrevented() && closeOnPress) row.close()\n        }}\n      >\n        {children}\n      </Button>\n    )\n  },\n)\nSwipeableRowAction.displayName = 'SwipeableRowAction'\nexport type { SwipeableMethods }\n",
      "type": "registry:ui",
      "target": "~/components/ui/swipeable-row/SwipeableRow.tsx"
    },
    {
      "path": "packages/registry-native/components/swipeable-row/index.ts",
      "content": "export * from './SwipeableRow'\n",
      "type": "registry:ui",
      "target": "~/components/ui/swipeable-row/index.ts"
    }
  ],
  "dependencies": [
    "react-native-gesture-handler",
    "react-native-reanimated",
    "react-native-worklets"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/utils.json",
    "https://native.uipkge.dev/r/native/label-children.json"
  ],
  "description": "Gesture-driven row actions with visible controls and imperative close/open methods."
}