FactuGES_ERP/packages/shadcn-ui/src/components/alert-dialog.tsx

188 lines
5.1 KiB
TypeScript
Raw Normal View History

2026-04-12 10:07:54 +00:00
"use client"
2026-05-04 18:33:24 +00:00
import type * as React from "react"
2026-04-12 10:07:54 +00:00
import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog"
2025-05-05 17:11:44 +00:00
import { cn } from "@repo/shadcn-ui/lib/utils"
2026-03-17 17:49:54 +00:00
import { Button } from "@repo/shadcn-ui/components/button"
2025-05-05 17:11:44 +00:00
2026-04-12 10:07:54 +00:00
function AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props) {
2025-05-05 17:11:44 +00:00
return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
}
2026-04-12 10:07:54 +00:00
function AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props) {
2025-05-05 17:11:44 +00:00
return (
<AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />
)
}
2026-04-12 10:07:54 +00:00
function AlertDialogPortal({ ...props }: AlertDialogPrimitive.Portal.Props) {
2025-05-05 17:11:44 +00:00
return (
<AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
)
}
function AlertDialogOverlay({
className,
...props
2026-04-12 10:07:54 +00:00
}: AlertDialogPrimitive.Backdrop.Props) {
2025-05-05 17:11:44 +00:00
return (
2026-04-12 10:07:54 +00:00
<AlertDialogPrimitive.Backdrop
2025-05-05 17:11:44 +00:00
data-slot="alert-dialog-overlay"
className={cn(
2026-04-12 10:07:54 +00:00
"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
2025-05-05 17:11:44 +00:00
className
)}
{...props}
/>
)
}
function AlertDialogContent({
className,
2026-03-17 17:49:54 +00:00
size = "default",
2025-05-05 17:11:44 +00:00
...props
2026-04-12 10:07:54 +00:00
}: AlertDialogPrimitive.Popup.Props & {
2026-03-17 17:49:54 +00:00
size?: "default" | "sm"
}) {
2025-05-05 17:11:44 +00:00
return (
<AlertDialogPortal>
<AlertDialogOverlay />
2026-04-12 10:07:54 +00:00
<AlertDialogPrimitive.Popup
2025-05-05 17:11:44 +00:00
data-slot="alert-dialog-content"
2026-03-17 17:49:54 +00:00
data-size={size}
2025-05-05 17:11:44 +00:00
className={cn(
2026-04-12 10:07:54 +00:00
"group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-popover p-6 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
2025-05-05 17:11:44 +00:00
className
)}
{...props}
/>
</AlertDialogPortal>
)
}
function AlertDialogHeader({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-header"
2026-03-17 17:49:54 +00:00
className={cn(
2026-04-12 10:07:54 +00:00
"grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",
2026-03-17 17:49:54 +00:00
className
)}
2025-05-05 17:11:44 +00:00
{...props}
/>
)
}
function AlertDialogFooter({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-footer"
className={cn(
2026-04-12 10:07:54 +00:00
"flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",
2026-03-17 17:49:54 +00:00
className
)}
{...props}
/>
)
}
function AlertDialogMedia({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-media"
className={cn(
2026-04-12 10:07:54 +00:00
"mb-2 inline-flex size-16 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-8",
2025-05-05 17:11:44 +00:00
className
)}
{...props}
/>
)
}
function AlertDialogTitle({
className,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
return (
<AlertDialogPrimitive.Title
data-slot="alert-dialog-title"
2026-03-17 17:49:54 +00:00
className={cn(
2026-04-12 10:07:54 +00:00
"text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",
2026-03-17 17:49:54 +00:00
className
)}
2025-05-05 17:11:44 +00:00
{...props}
/>
)
}
function AlertDialogDescription({
className,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
return (
<AlertDialogPrimitive.Description
data-slot="alert-dialog-description"
2026-03-17 17:49:54 +00:00
className={cn(
"text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
className
)}
2025-05-05 17:11:44 +00:00
{...props}
/>
)
}
function AlertDialogAction({
className,
...props
2026-04-12 10:07:54 +00:00
}: React.ComponentProps<typeof Button>) {
2025-05-05 17:11:44 +00:00
return (
2026-04-12 10:07:54 +00:00
<Button
data-slot="alert-dialog-action"
className={cn(className)}
{...props}
/>
2025-05-05 17:11:44 +00:00
)
}
function AlertDialogCancel({
className,
2026-03-17 17:49:54 +00:00
variant = "outline",
size = "default",
2025-05-05 17:11:44 +00:00
...props
2026-04-12 10:07:54 +00:00
}: AlertDialogPrimitive.Close.Props &
2026-03-17 17:49:54 +00:00
Pick<React.ComponentProps<typeof Button>, "variant" | "size">) {
2025-05-05 17:11:44 +00:00
return (
2026-04-12 10:07:54 +00:00
<AlertDialogPrimitive.Close
data-slot="alert-dialog-cancel"
className={cn(className)}
render={<Button variant={variant} size={size} />}
{...props}
/>
2025-05-05 17:11:44 +00:00
)
}
export {
AlertDialog,
2026-03-17 17:49:54 +00:00
AlertDialogAction,
AlertDialogCancel,
2025-05-05 17:11:44 +00:00
AlertDialogContent,
2026-03-17 17:49:54 +00:00
AlertDialogDescription,
2025-05-05 17:11:44 +00:00
AlertDialogFooter,
2026-03-17 17:49:54 +00:00
AlertDialogHeader,
AlertDialogMedia,
AlertDialogOverlay,
AlertDialogPortal,
2025-05-05 17:11:44 +00:00
AlertDialogTitle,
2026-03-17 17:49:54 +00:00
AlertDialogTrigger,
2025-05-05 17:11:44 +00:00
}