2023-05-18 11:09:31 -07:00
|
|
|
import * as React from 'react';
|
|
|
|
|
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
2023-03-03 15:52:06 -05:00
|
|
|
|
2023-05-18 11:09:31 -07:00
|
|
|
import { cn } from '../../utils';
|
2023-03-03 15:52:06 -05:00
|
|
|
|
2023-05-18 11:09:31 -07:00
|
|
|
const AlertDialog = AlertDialogPrimitive.Root;
|
2023-03-03 15:52:06 -05:00
|
|
|
|
2023-05-18 11:09:31 -07:00
|
|
|
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
2023-03-03 15:52:06 -05:00
|
|
|
|
|
|
|
|
const AlertDialogPortal = ({
|
2023-08-06 21:30:16 -04:00
|
|
|
className = '',
|
2023-03-03 15:52:06 -05:00
|
|
|
children,
|
|
|
|
|
...props
|
|
|
|
|
}: AlertDialogPrimitive.AlertDialogPortalProps) => (
|
|
|
|
|
<AlertDialogPrimitive.Portal className={cn(className)} {...props}>
|
|
|
|
|
<div className="fixed inset-0 z-50 flex items-end justify-center sm:items-center">
|
|
|
|
|
{children}
|
|
|
|
|
</div>
|
|
|
|
|
</AlertDialogPrimitive.Portal>
|
2023-05-18 11:09:31 -07:00
|
|
|
);
|
|
|
|
|
AlertDialogPortal.displayName = AlertDialogPrimitive.Portal.displayName;
|
2023-03-03 15:52:06 -05:00
|
|
|
|
|
|
|
|
const AlertDialogOverlay = React.forwardRef<
|
|
|
|
|
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
|
|
|
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
2023-08-06 21:30:16 -04:00
|
|
|
>(({ className = '', ...props }, ref) => (
|
2023-03-03 15:52:06 -05:00
|
|
|
<AlertDialogPrimitive.Overlay
|
|
|
|
|
className={cn(
|
2023-08-06 21:30:16 -04:00
|
|
|
'fixed inset-0 z-50 bg-gray-500/90 transition-opacity animate-in fade-in dark:bg-gray-800/90',
|
2023-07-14 09:36:49 -04:00
|
|
|
className,
|
2023-03-03 15:52:06 -05:00
|
|
|
)}
|
|
|
|
|
{...props}
|
|
|
|
|
ref={ref}
|
|
|
|
|
/>
|
2023-05-18 11:09:31 -07:00
|
|
|
));
|
|
|
|
|
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
2023-03-03 15:52:06 -05:00
|
|
|
|
|
|
|
|
const AlertDialogContent = React.forwardRef<
|
|
|
|
|
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
|
|
|
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
|
2023-08-06 21:30:16 -04:00
|
|
|
>(({ className = '', ...props }, ref) => (
|
2023-03-03 15:52:06 -05:00
|
|
|
<AlertDialogPortal>
|
|
|
|
|
<AlertDialogOverlay />
|
|
|
|
|
<AlertDialogPrimitive.Content
|
|
|
|
|
ref={ref}
|
|
|
|
|
className={cn(
|
2023-08-06 21:30:16 -04:00
|
|
|
'fixed z-50 grid w-full max-w-lg scale-100 gap-4 bg-white p-6 opacity-100 animate-in fade-in-90 slide-in-from-bottom-10 sm:rounded-lg sm:zoom-in-90 sm:slide-in-from-bottom-0 md:w-full',
|
2023-05-18 11:09:31 -07:00
|
|
|
'dark:bg-slate-900',
|
2023-07-14 09:36:49 -04:00
|
|
|
className,
|
2023-03-03 15:52:06 -05:00
|
|
|
)}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
</AlertDialogPortal>
|
2023-05-18 11:09:31 -07:00
|
|
|
));
|
|
|
|
|
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
2023-03-03 15:52:06 -05:00
|
|
|
|
2023-08-06 21:30:16 -04:00
|
|
|
const AlertDialogHeader = ({ className = '', ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
2023-05-18 11:09:31 -07:00
|
|
|
<div className={cn('flex flex-col space-y-2 text-center sm:text-left', className)} {...props} />
|
|
|
|
|
);
|
|
|
|
|
AlertDialogHeader.displayName = 'AlertDialogHeader';
|
2023-03-03 15:52:06 -05:00
|
|
|
|
2023-08-06 21:30:16 -04:00
|
|
|
const AlertDialogFooter = ({ className = '', ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
2023-03-03 15:52:06 -05:00
|
|
|
<div
|
2023-05-18 11:09:31 -07:00
|
|
|
className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)}
|
2023-03-03 15:52:06 -05:00
|
|
|
{...props}
|
|
|
|
|
/>
|
2023-05-18 11:09:31 -07:00
|
|
|
);
|
|
|
|
|
AlertDialogFooter.displayName = 'AlertDialogFooter';
|
2023-03-03 15:52:06 -05:00
|
|
|
|
|
|
|
|
const AlertDialogTitle = React.forwardRef<
|
|
|
|
|
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
|
|
|
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
|
2023-08-06 21:30:16 -04:00
|
|
|
>(({ className = '', ...props }, ref) => (
|
2023-03-03 15:52:06 -05:00
|
|
|
<AlertDialogPrimitive.Title
|
|
|
|
|
ref={ref}
|
2023-05-18 11:09:31 -07:00
|
|
|
className={cn('text-lg font-semibold text-slate-900', 'dark:text-slate-50', className)}
|
2023-03-03 15:52:06 -05:00
|
|
|
{...props}
|
|
|
|
|
/>
|
2023-05-18 11:09:31 -07:00
|
|
|
));
|
|
|
|
|
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
2023-03-03 15:52:06 -05:00
|
|
|
|
|
|
|
|
const AlertDialogDescription = React.forwardRef<
|
|
|
|
|
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
|
|
|
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
|
2023-08-06 21:30:16 -04:00
|
|
|
>(({ className = '', ...props }, ref) => (
|
2023-03-03 15:52:06 -05:00
|
|
|
<AlertDialogPrimitive.Description
|
|
|
|
|
ref={ref}
|
2023-05-18 11:09:31 -07:00
|
|
|
className={cn('text-sm text-slate-500', 'dark:text-slate-400', className)}
|
2023-03-03 15:52:06 -05:00
|
|
|
{...props}
|
|
|
|
|
/>
|
2023-05-18 11:09:31 -07:00
|
|
|
));
|
|
|
|
|
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
|
2023-03-03 15:52:06 -05:00
|
|
|
|
|
|
|
|
const AlertDialogAction = React.forwardRef<
|
|
|
|
|
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
|
|
|
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
2023-08-06 21:30:16 -04:00
|
|
|
>(({ className = '', ...props }, ref) => (
|
2023-03-03 15:52:06 -05:00
|
|
|
<AlertDialogPrimitive.Action
|
|
|
|
|
ref={ref}
|
|
|
|
|
className={cn(
|
2023-05-19 20:21:34 +05:30
|
|
|
'inline-flex h-10 items-center justify-center rounded-md bg-slate-900 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-slate-200 dark:focus:ring-slate-400 dark:focus:ring-offset-slate-900',
|
2023-07-14 09:36:49 -04:00
|
|
|
className,
|
2023-03-03 15:52:06 -05:00
|
|
|
)}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
2023-05-18 11:09:31 -07:00
|
|
|
));
|
|
|
|
|
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
2023-03-03 15:52:06 -05:00
|
|
|
|
|
|
|
|
const AlertDialogCancel = React.forwardRef<
|
|
|
|
|
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
|
|
|
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
|
2023-08-06 21:30:16 -04:00
|
|
|
>(({ className = '', ...props }, ref) => (
|
2023-03-03 15:52:06 -05:00
|
|
|
<AlertDialogPrimitive.Cancel
|
|
|
|
|
ref={ref}
|
|
|
|
|
className={cn(
|
2023-05-19 20:21:34 +05:30
|
|
|
'mt-2 inline-flex h-10 items-center justify-center rounded-md border border-slate-200 bg-transparent px-4 py-2 text-sm font-semibold text-slate-900 transition-colors hover:bg-slate-100 focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-700 dark:text-slate-100 dark:hover:bg-gray-900 dark:focus:ring-slate-400 dark:focus:ring-offset-slate-900 sm:mt-0',
|
2023-07-14 09:36:49 -04:00
|
|
|
className,
|
2023-03-03 15:52:06 -05:00
|
|
|
)}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
2023-05-18 11:09:31 -07:00
|
|
|
));
|
|
|
|
|
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
2023-03-03 15:52:06 -05:00
|
|
|
|
|
|
|
|
export {
|
|
|
|
|
AlertDialog,
|
|
|
|
|
AlertDialogTrigger,
|
|
|
|
|
AlertDialogContent,
|
|
|
|
|
AlertDialogHeader,
|
|
|
|
|
AlertDialogFooter,
|
|
|
|
|
AlertDialogTitle,
|
|
|
|
|
AlertDialogDescription,
|
|
|
|
|
AlertDialogAction,
|
2023-07-14 09:36:49 -04:00
|
|
|
AlertDialogCancel,
|
2023-05-18 11:09:31 -07:00
|
|
|
};
|