- "content": "import { buttonTextVariants, buttonVariants } from '@/registry/default/components/ui/button';\nimport { NativeOnlyAnimatedView } from '@/registry/default/components/ui/native-only-animated-view';\nimport { TextClassContext } from '@/registry/default/components/ui/text';\nimport { cn } from '@/registry/default/lib/utils';\nimport * as AlertDialogPrimitive from '@rn-primitives/alert-dialog';\nimport * as React from 'react';\nimport { Platform, View, type ViewProps } from 'react-native';\nimport { FadeIn, FadeOut } from 'react-native-reanimated';\nimport { FullWindowOverlay as RNFullWindowOverlay } from 'react-native-screens';\n\nconst AlertDialog = AlertDialogPrimitive.Root;\n\nconst AlertDialogTrigger = AlertDialogPrimitive.Trigger;\n\nconst AlertDialogPortal = AlertDialogPrimitive.Portal;\n\nconst FullWindowOverlay = Platform.OS === 'ios' ? RNFullWindowOverlay : React.Fragment;\n\nfunction AlertDialogOverlay({\n className,\n children,\n ...props\n}: Omit<AlertDialogPrimitive.OverlayProps, 'asChild'> & {\n ref?: React.RefObject<AlertDialogPrimitive.OverlayRef | null>;\n}) {\n return (\n <FullWindowOverlay>\n <AlertDialogPrimitive.Overlay\n className={cn(\n 'absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center bg-black/80 p-2',\n Platform.select({\n web: 'animate-in fade-in-0 fixed',\n }),\n className\n )}\n {...props}>\n <NativeOnlyAnimatedView\n entering={FadeIn.duration(200).delay(50)}\n exiting={FadeOut.duration(150)}>\n <>{children}</>\n </NativeOnlyAnimatedView>\n </AlertDialogPrimitive.Overlay>\n </FullWindowOverlay>\n );\n}\n\nfunction AlertDialogContent({\n className,\n portalHost,\n ...props\n}: AlertDialogPrimitive.ContentProps & {\n ref?: React.RefObject<AlertDialogPrimitive.ContentRef | null>;\n portalHost?: string;\n}) {\n return (\n <AlertDialogPortal hostName={portalHost}>\n <AlertDialogOverlay>\n <AlertDialogPrimitive.Content\n className={cn(\n 'bg-background border-border z-50 flex max-w-lg flex-col gap-4 rounded-lg border p-6 shadow-lg shadow-black/5',\n Platform.select({\n web: 'animate-in fade-in-0 zoom-in-95 duration-200',\n }),\n className\n )}\n {...props}\n />\n </AlertDialogOverlay>\n </AlertDialogPortal>\n );\n}\n\nfunction AlertDialogHeader({ className, ...props }: ViewProps) {\n return (\n <TextClassContext.Provider value=\"text-center sm:text-left\">\n <View className={cn('flex flex-col gap-2', className)} {...props} />\n </TextClassContext.Provider>\n );\n}\n\nfunction AlertDialogFooter({ className, ...props }: ViewProps) {\n return (\n <View\n className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-2', className)}\n {...props}\n />\n );\n}\n\nfunction AlertDialogTitle({\n className,\n ...props\n}: AlertDialogPrimitive.TitleProps & {\n ref?: React.RefObject<AlertDialogPrimitive.TitleRef | null>;\n}) {\n return (\n <AlertDialogPrimitive.Title\n className={cn('text-foreground text-lg font-semibold', className)}\n {...props}\n />\n );\n}\n\nfunction AlertDialogDescription({\n className,\n ...props\n}: AlertDialogPrimitive.DescriptionProps & {\n ref?: React.RefObject<AlertDialogPrimitive.DescriptionRef | null>;\n}) {\n return (\n <AlertDialogPrimitive.Description\n className={cn('text-muted-foreground text-sm', className)}\n {...props}\n />\n );\n}\n\nfunction AlertDialogAction({\n className,\n ...props\n}: AlertDialogPrimitive.ActionProps & {\n ref?: React.RefObject<AlertDialogPrimitive.ActionRef | null>;\n}) {\n return (\n <TextClassContext.Provider value={buttonTextVariants({ className })}>\n <AlertDialogPrimitive.Action className={cn(buttonVariants(), className)} {...props} />\n </TextClassContext.Provider>\n );\n}\n\nfunction AlertDialogCancel({\n className,\n ...props\n}: AlertDialogPrimitive.CancelProps & {\n ref?: React.RefObject<AlertDialogPrimitive.CancelRef | null>;\n}) {\n return (\n <TextClassContext.Provider value={buttonTextVariants({ className, variant: 'outline' })}>\n <AlertDialogPrimitive.Cancel\n className={cn(buttonVariants({ variant: 'outline' }), 'mt-2 sm:mt-0', className)}\n {...props}\n />\n </TextClassContext.Provider>\n );\n}\n\nexport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogOverlay,\n AlertDialogPortal,\n AlertDialogTitle,\n AlertDialogTrigger,\n};\n",
0 commit comments