{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "alert-dialog", "type": "registry:ui", "title": "Alert Dialog", "description": "Confirm/cancel modal dialog (non-dismissable on backdrop).", "registryDependencies": [ "https://raw.githubusercontent.com/truongnat/rnui/main/registry/dist/nativewind/utils.json", "https://raw.githubusercontent.com/truongnat/rnui/main/registry/dist/nativewind/text.json", "https://raw.githubusercontent.com/truongnat/rnui/main/registry/dist/nativewind/theme.json" ], "files": [ { "path": "registry/shared/ui/alert-dialog.tsx", "type": "registry:ui", "target": "components/ui/alert-dialog.tsx", "content": "import { createContext, type ReactNode, useContext } from 'react';\nimport { Modal, Pressable, View, type ViewProps } from 'react-native';\nimport { Text, type TextProps } from '@/components/ui/text';\nimport { cn } from '@/lib/utils';\n\nconst AlertDialogContext = createContext<((open: boolean) => void) | null>(\n null\n);\n\nexport interface AlertDialogProps {\n open: boolean;\n onOpenChange?: (open: boolean) => void;\n children?: ReactNode;\n}\n\nexport function AlertDialog({\n open,\n onOpenChange,\n children,\n}: AlertDialogProps) {\n return (\n onOpenChange?.(false)}\n >\n {/* Backdrop stays non-pressable: AlertDialog requires an explicit choice. */}\n \n \n \n {children}\n \n \n \n \n );\n}\n\nexport function AlertDialogTitle({ className, ...props }: TextProps) {\n return (\n \n );\n}\n\nexport function AlertDialogDescription({ className, ...props }: TextProps) {\n return (\n \n );\n}\n\nexport function AlertDialogFooter({\n className,\n ...props\n}: ViewProps & { className?: string }) {\n return (\n \n );\n}\n\nexport interface AlertDialogActionProps {\n onPress?: () => void;\n children?: ReactNode;\n className?: string;\n}\n\nexport function AlertDialogAction({\n onPress,\n children,\n className,\n}: AlertDialogActionProps) {\n const onOpenChange = useContext(AlertDialogContext);\n return (\n {\n onPress?.();\n onOpenChange?.(false);\n }}\n className={cn(\n 'rounded-md bg-primary px-4 py-2 active:opacity-80',\n className\n )}\n >\n \n {children}\n \n \n );\n}\n\nexport function AlertDialogCancel({\n onPress,\n children,\n className,\n}: AlertDialogActionProps) {\n const onOpenChange = useContext(AlertDialogContext);\n return (\n {\n onPress?.();\n onOpenChange?.(false);\n }}\n className={cn(\n 'rounded-md border border-border bg-background px-4 py-2 active:opacity-80',\n className\n )}\n >\n {children}\n \n );\n}\n" } ] }