Repository navigation
Expand file tree
/
Copy pathalert-dialog.tsx
More file actions
150 lines (138 loc) · 4.02 KB
/
Copy pathalert-dialog.tsx
File metadata and controls
150 lines (138 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog";
import { cn } from "~/lib/utils";
import {
DIALOG_BACKDROP_CLASS,
DIALOG_MOBILE_SHEET_CLASS,
DIALOG_POPUP_CLASS,
} from "~/components/ui/dialog-styles";
import { ControlledOpenContext, renderRetainedPopup } from "~/components/ui/dialog";
function AlertDialog<Payload>(props: AlertDialogPrimitive.Root.Props<Payload>) {
return (
<ControlledOpenContext value={props.open}>
<AlertDialogPrimitive.Root {...props} />
</ControlledOpenContext>
);
}
const AlertDialogPortal = AlertDialogPrimitive.Portal;
function AlertDialogBackdrop({ className, ...props }: AlertDialogPrimitive.Backdrop.Props) {
return (
<AlertDialogPrimitive.Backdrop
forceRender
className={cn(DIALOG_BACKDROP_CLASS, className)}
data-slot="alert-dialog-backdrop"
{...props}
/>
);
}
function AlertDialogViewport({ className, ...props }: AlertDialogPrimitive.Viewport.Props) {
return (
<AlertDialogPrimitive.Viewport
className={cn(
"fixed inset-0 z-50 grid grid-rows-[1fr_auto_1fr] justify-items-center p-4",
className,
)}
data-slot="alert-dialog-viewport"
{...props}
/>
);
}
function AlertDialogPopup({
className,
bottomStickOnMobile = true,
portalContainer,
...props
}: AlertDialogPrimitive.Popup.Props & {
bottomStickOnMobile?: boolean;
portalContainer?: AlertDialogPrimitive.Portal.Props["container"];
}) {
return (
<AlertDialogPortal container={portalContainer}>
<AlertDialogBackdrop />
<AlertDialogViewport
className={cn(bottomStickOnMobile && "max-sm:grid-rows-[1fr_auto] max-sm:p-0 max-sm:pt-12")}
>
<AlertDialogPrimitive.Popup
className={cn(
DIALOG_POPUP_CLASS,
"row-start-2 max-h-full max-w-lg text-popover-foreground",
bottomStickOnMobile && DIALOG_MOBILE_SHEET_CLASS,
className,
)}
data-slot="alert-dialog-popup"
render={renderRetainedPopup}
{...props}
/>
</AlertDialogViewport>
</AlertDialogPortal>
);
}
function AlertDialogHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn(
"flex min-h-0 flex-col gap-2 p-6 text-center max-sm:pb-4 sm:text-left",
className,
)}
data-slot="alert-dialog-header"
{...props}
/>
);
}
function AlertDialogFooter({
className,
variant = "default",
...props
}: React.ComponentProps<"div"> & {
variant?: "default" | "bare";
}) {
return (
<div
className={cn(
"flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]",
variant === "default" && "border-t bg-muted/72 py-4",
variant === "bare" && "pb-6",
className,
)}
data-slot="alert-dialog-footer"
{...props}
/>
);
}
function AlertDialogTitle({ className, ...props }: AlertDialogPrimitive.Title.Props) {
return (
<AlertDialogPrimitive.Title
className={cn("wrap-anywhere shrink-0 font-semibold text-xl leading-none", className)}
data-slot="alert-dialog-title"
{...props}
/>
);
}
function AlertDialogDescription({ className, ...props }: AlertDialogPrimitive.Description.Props) {
return (
<AlertDialogPrimitive.Description
className={cn(
"wrap-anywhere max-h-[min(24rem,60dvh)] min-h-0 overflow-y-auto overscroll-contain text-muted-foreground text-sm select-text",
className,
)}
data-slot="alert-dialog-description"
{...props}
/>
);
}
function AlertDialogClose(props: AlertDialogPrimitive.Close.Props) {
return <AlertDialogPrimitive.Close data-slot="alert-dialog-close" {...props} />;
}
export {
AlertDialog,
AlertDialogPortal,
AlertDialogBackdrop,
AlertDialogBackdrop as AlertDialogOverlay,
AlertDialogPopup,
AlertDialogPopup as AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogClose,
AlertDialogViewport,
};