'use client'; import React from 'react'; import { createAlertDialog } from '@gluestack-ui/alert-dialog'; import { tva } from '@gluestack-ui/nativewind-utils/tva'; import { withStyleContext, useStyleContext, } from '@gluestack-ui/nativewind-utils/withStyleContext'; import { cssInterop } from 'nativewind'; import type { VariantProps } from '@gluestack-ui/nativewind-utils'; import { Motion, AnimatePresence, createMotionAnimatedComponent, MotionComponentProps, } from '@legendapp/motion'; import { View, Pressable, ScrollView, ViewStyle } from 'react-native'; const SCOPE = 'ALERT_DIALOG'; const RootComponent = withStyleContext(View, SCOPE); type IMotionViewProps = React.ComponentProps & MotionComponentProps; const MotionView = Motion.View as React.ComponentType; type IAnimatedPressableProps = React.ComponentProps & MotionComponentProps; const AnimatedPressable = createMotionAnimatedComponent( Pressable ) as React.ComponentType; const UIAccessibleAlertDialog = createAlertDialog({ Root: RootComponent, Body: ScrollView, Content: MotionView, CloseButton: Pressable, Header: View, Footer: View, Backdrop: AnimatedPressable, AnimatePresence: AnimatePresence, }); cssInterop(MotionView, { className: 'style' }); cssInterop(AnimatedPressable, { className: 'style' }); const alertDialogStyle = tva({ base: 'group/modal w-full h-full justify-center items-center web:pointer-events-none', parentVariants: { size: { xs: '', sm: '', md: '', lg: '', full: '', }, }, }); const alertDialogContentStyle = tva({ base: 'bg-background-0 rounded-lg overflow-hidden border border-outline-100 p-6', parentVariants: { size: { xs: 'w-[60%] max-w-[360px]', sm: 'w-[70%] max-w-[420px]', md: 'w-[80%] max-w-[510px]', lg: 'w-[90%] max-w-[640px]', full: 'w-full', }, }, }); const alertDialogCloseButtonStyle = tva({ base: 'group/alert-dialog-close-button z-10 rounded-sm p-2 data-[focus-visible=true]:bg-background-100 web:cursor-pointer outline-0', }); const alertDialogHeaderStyle = tva({ base: 'justify-between items-center flex-row', }); const alertDialogFooterStyle = tva({ base: 'flex-row justify-end items-center gap-3', }); const alertDialogBodyStyle = tva({ base: '' }); const alertDialogBackdropStyle = tva({ base: 'absolute left-0 top-0 right-0 bottom-0 bg-background-dark web:cursor-default', }); type IAlertDialogProps = React.ComponentPropsWithoutRef< typeof UIAccessibleAlertDialog > & VariantProps; type IAlertDialogContentProps = React.ComponentPropsWithoutRef< typeof UIAccessibleAlertDialog.Content > & VariantProps & { className?: string }; type IAlertDialogCloseButtonProps = React.ComponentPropsWithoutRef< typeof UIAccessibleAlertDialog.CloseButton > & VariantProps; type IAlertDialogHeaderProps = React.ComponentPropsWithoutRef< typeof UIAccessibleAlertDialog.Header > & VariantProps; type IAlertDialogFooterProps = React.ComponentPropsWithoutRef< typeof UIAccessibleAlertDialog.Footer > & VariantProps; type IAlertDialogBodyProps = React.ComponentPropsWithoutRef< typeof UIAccessibleAlertDialog.Body > & VariantProps; type IAlertDialogBackdropProps = React.ComponentPropsWithoutRef< typeof UIAccessibleAlertDialog.Backdrop > & VariantProps & { className?: string }; const AlertDialog = React.forwardRef< React.ComponentRef, IAlertDialogProps >(function AlertDialog({ className, size = 'md', ...props }, ref) { return ( ); }); const AlertDialogContent = React.forwardRef< React.ComponentRef, IAlertDialogContentProps >(function AlertDialogContent({ className, size, ...props }, ref) { const { size: parentSize } = useStyleContext(SCOPE); return ( ); }); const AlertDialogCloseButton = React.forwardRef< React.ComponentRef, IAlertDialogCloseButtonProps >(function AlertDialogCloseButton({ className, ...props }, ref) { return ( ); }); const AlertDialogHeader = React.forwardRef< React.ComponentRef, IAlertDialogHeaderProps >(function AlertDialogHeader({ className, ...props }, ref) { return ( ); }); const AlertDialogFooter = React.forwardRef< React.ComponentRef, IAlertDialogFooterProps >(function AlertDialogFooter({ className, ...props }, ref) { return ( ); }); const AlertDialogBody = React.forwardRef< React.ComponentRef, IAlertDialogBodyProps >(function AlertDialogBody({ className, ...props }, ref) { return ( ); }); const AlertDialogBackdrop = React.forwardRef< React.ComponentRef, IAlertDialogBackdropProps >(function AlertDialogBackdrop({ className, ...props }, ref) { return ( ); }); AlertDialog.displayName = 'AlertDialog'; AlertDialogContent.displayName = 'AlertDialogContent'; AlertDialogCloseButton.displayName = 'AlertDialogCloseButton'; AlertDialogHeader.displayName = 'AlertDialogHeader'; AlertDialogFooter.displayName = 'AlertDialogFooter'; AlertDialogBody.displayName = 'AlertDialogBody'; AlertDialogBackdrop.displayName = 'AlertDialogBackdrop'; export { AlertDialog, AlertDialogContent, AlertDialogCloseButton, AlertDialogHeader, AlertDialogFooter, AlertDialogBody, AlertDialogBackdrop, };