返回 JoyAI-Echo
alert-dialog.tsx
根目录 / echo_longvideo / Director_Agent / webui / src / components / ui / alert-dialog.tsx
1 import * as React from "react";
2 import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
3
4 import { cn } from "@/lib/utils";
5 import { buttonVariants } from "@/components/ui/button";
6
7 const AlertDialog = AlertDialogPrimitive.Root;
8 const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
9 const AlertDialogPortal = AlertDialogPrimitive.Portal;
10
11 const AlertDialogOverlay = React.forwardRef<
12 React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
13 React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
14 >(({ className, ...props }, ref) => (
15 <AlertDialogPrimitive.Overlay
16 ref={ref}
17 className={cn(
18 "fixed inset-0 z-50 bg-black/60 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
19 className,
20 )}
21 {...props}
22 />
23 ));
24 AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
25
26 const AlertDialogContent = React.forwardRef<
27 React.ElementRef<typeof AlertDialogPrimitive.Content>,
28 React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
29 >(({ className, ...props }, ref) => (
30 <AlertDialogPortal>
31 <AlertDialogOverlay />
32 <AlertDialogPrimitive.Content
33 ref={ref}
34 className={cn(
35 "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",
36 className,
37 )}
38 {...props}
39 />
40 </AlertDialogPortal>
41 ));
42 AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
43
44 const AlertDialogHeader = ({
45 className,
46 ...props
47 }: React.HTMLAttributes<HTMLDivElement>) => (
48 <div
49 className={cn("flex flex-col space-y-2 text-center sm:text-left", className)}
50 {...props}
51 />
52 );
53 AlertDialogHeader.displayName = "AlertDialogHeader";
54
55 const AlertDialogFooter = ({
56 className,
57 ...props
58 }: React.HTMLAttributes<HTMLDivElement>) => (
59 <div
60 className={cn(
61 "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
62 className,
63 )}
64 {...props}
65 />
66 );
67 AlertDialogFooter.displayName = "AlertDialogFooter";
68
69 const AlertDialogTitle = React.forwardRef<
70 React.ElementRef<typeof AlertDialogPrimitive.Title>,
71 React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
72 >(({ className, ...props }, ref) => (
73 <AlertDialogPrimitive.Title
74 ref={ref}
75 className={cn("text-lg font-semibold", className)}
76 {...props}
77 />
78 ));
79 AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
80
81 const AlertDialogDescription = React.forwardRef<
82 React.ElementRef<typeof AlertDialogPrimitive.Description>,
83 React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
84 >(({ className, ...props }, ref) => (
85 <AlertDialogPrimitive.Description
86 ref={ref}
87 className={cn("text-sm text-muted-foreground", className)}
88 {...props}
89 />
90 ));
91 AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
92
93 const AlertDialogAction = React.forwardRef<
94 React.ElementRef<typeof AlertDialogPrimitive.Action>,
95 React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
96 >(({ className, ...props }, ref) => (
97 <AlertDialogPrimitive.Action
98 ref={ref}
99 className={cn(buttonVariants(), className)}
100 {...props}
101 />
102 ));
103 AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
104
105 const AlertDialogCancel = React.forwardRef<
106 React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
107 React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
108 >(({ className, ...props }, ref) => (
109 <AlertDialogPrimitive.Cancel
110 ref={ref}
111 className={cn(
112 buttonVariants({ variant: "outline" }),
113 "mt-2 sm:mt-0",
114 className,
115 )}
116 {...props}
117 />
118 ));
119 AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
120
121 export {
122 AlertDialog,
123 AlertDialogAction,
124 AlertDialogCancel,
125 AlertDialogContent,
126 AlertDialogDescription,
127 AlertDialogFooter,
128 AlertDialogHeader,
129 AlertDialogOverlay,
130 AlertDialogPortal,
131 AlertDialogTitle,
132 AlertDialogTrigger,
133 };
134
134 lines Plain Text