gijl/lv-storage / llama.cpp /tools /ui /src /lib /components /app /dialogs /DialogConfirmation.svelte
gijl's picture
download
raw
1.84 kB
<script lang="ts">
import * as AlertDialog from '$lib/components/ui/alert-dialog';
import { KeyboardKey } from '$lib/enums';
import type { Component, Snippet } from 'svelte';
interface Props {
open: boolean;
title: string;
description: string;
confirmText?: string;
cancelText?: string;
variant?: 'default' | 'destructive';
icon?: Component;
onConfirm: () => void;
onCancel: () => void;
onKeydown?: (event: KeyboardEvent) => void;
children?: Snippet;
}
let {
cancelText = 'Cancel',
children,
confirmText = 'Confirm',
description,
icon,
onCancel,
onConfirm,
onKeydown,
open = $bindable(),
title,
variant = 'default'
}: Props = $props();
function handleKeydown(event: KeyboardEvent) {
if (event.key === KeyboardKey.ENTER) {
event.preventDefault();
onConfirm();
}
onKeydown?.(event);
}
function handleOpenChange(newOpen: boolean) {
if (!newOpen) {
onCancel();
}
}
</script>
<AlertDialog.Root onOpenChange={handleOpenChange} {open}>
<AlertDialog.Content onkeydown={handleKeydown}>
<AlertDialog.Header>
<AlertDialog.Title class="flex items-center gap-2">
{#if icon}
{@const IconComponent = icon}
<IconComponent class="h-5 w-5 {variant === 'destructive' ? 'text-destructive' : ''}" />
{/if}
{title}
</AlertDialog.Title>
<AlertDialog.Description>
{description}
</AlertDialog.Description>
</AlertDialog.Header>
{#if children}
{@render children()}
{/if}
<AlertDialog.Footer>
<AlertDialog.Cancel onclick={onCancel}>{cancelText}</AlertDialog.Cancel>
<AlertDialog.Action
class={variant === 'destructive' ? 'bg-destructive text-white hover:bg-destructive/80' : ''}
onclick={onConfirm}
>
{confirmText}
</AlertDialog.Action>
</AlertDialog.Footer>
</AlertDialog.Content>
</AlertDialog.Root>

Xet Storage Details

Size:
1.84 kB
·
Xet hash:
e1daf7e8403cb6b09bae8e9f95f7970a497814aab205e62acbb8bfc1db3cf9ab

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.