1<script lang="ts">
2 import { AlertDialog as AlertDialogPrimitive } from 'bits-ui';
3 import AlertDialogOverlay from './alert-dialog-overlay.svelte';
4 import { cn, type WithoutChild, type WithoutChildrenOrChild } from '$lib/components/ui/utils.js';
5
6 let {
7 ref = $bindable(null),
8 class: className,
9 portalProps,
10 ...restProps
11 }: WithoutChild<AlertDialogPrimitive.ContentProps> & {
12 portalProps?: WithoutChildrenOrChild<AlertDialogPrimitive.PortalProps>;
13 } = $props();
14</script>
15
16<AlertDialogPrimitive.Portal {...portalProps}>
17 <AlertDialogOverlay />
18 <AlertDialogPrimitive.Content
19 bind:ref
20 data-slot="alert-dialog-content"
21 class={cn(
22 'fixed z-[999999] grid w-full gap-4 border bg-background p-6 shadow-lg duration-200',
23 // Mobile: Bottom sheet behavior
24 'right-0 bottom-0 left-0 max-h-[100dvh] translate-x-0 translate-y-0 overflow-y-auto rounded-t-lg',
25 'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-bottom-full',
26 'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:slide-in-from-bottom-full',
27 // Desktop: Centered dialog behavior
28 'sm:top-[50%] sm:right-auto sm:bottom-auto sm:left-[50%] sm:max-h-[100vh] sm:max-w-lg sm:translate-x-[-50%] sm:translate-y-[-50%] sm:rounded-lg',
29 'sm:data-[state=closed]:slide-out-to-bottom-0 sm:data-[state=closed]:zoom-out-95',
30 'sm:data-[state=open]:slide-in-from-bottom-0 sm:data-[state=open]:zoom-in-95',
31 className
32 )}
33 {...restProps}
34 />
35</AlertDialogPrimitive.Portal>