2023-01-02 15:22:33 -05:00
|
|
|
<script lang="ts">
|
2025-05-03 00:41:42 +02:00
|
|
|
import { Button, Modal, ModalBody, ModalFooter, type Color } from '@immich/ui';
|
2025-05-02 19:34:53 +02:00
|
|
|
import type { Snippet } from 'svelte';
|
|
|
|
|
import { t } from 'svelte-i18n';
|
2023-01-02 15:22:33 -05:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
|
|
|
|
title?: string;
|
|
|
|
|
prompt?: string;
|
|
|
|
|
confirmText?: string;
|
|
|
|
|
confirmColor?: Color;
|
|
|
|
|
cancelText?: string;
|
|
|
|
|
cancelColor?: Color;
|
|
|
|
|
hideCancelButton?: boolean;
|
|
|
|
|
disabled?: boolean;
|
2025-05-03 00:41:42 +02:00
|
|
|
size?: 'small' | 'medium';
|
2025-05-02 19:34:53 +02:00
|
|
|
onClose: (confirmed: boolean) => void;
|
2024-11-14 08:43:25 -06:00
|
|
|
promptSnippet?: Snippet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let {
|
|
|
|
|
title = $t('confirm'),
|
|
|
|
|
prompt = $t('are_you_sure_to_do_this'),
|
|
|
|
|
confirmText = $t('confirm'),
|
2025-03-14 09:37:56 -04:00
|
|
|
confirmColor = 'danger',
|
2024-11-14 08:43:25 -06:00
|
|
|
cancelText = $t('cancel'),
|
|
|
|
|
cancelColor = 'secondary',
|
|
|
|
|
hideCancelButton = false,
|
|
|
|
|
disabled = false,
|
2025-05-03 00:41:42 +02:00
|
|
|
size = 'small',
|
2025-05-02 19:34:53 +02:00
|
|
|
onClose,
|
2024-11-14 08:43:25 -06:00
|
|
|
promptSnippet,
|
|
|
|
|
}: Props = $props();
|
2023-06-30 21:53:16 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const handleConfirm = () => {
|
2025-05-02 19:34:53 +02:00
|
|
|
onClose(true);
|
2023-12-05 13:16:37 -06:00
|
|
|
};
|
2023-01-02 15:22:33 -05:00
|
|
|
</script>
|
|
|
|
|
|
2025-05-03 00:41:42 +02:00
|
|
|
<Modal {title} onClose={() => onClose(false)} {size} class="bg-light text-dark">
|
|
|
|
|
<ModalBody>
|
2024-11-14 08:43:25 -06:00
|
|
|
{#if promptSnippet}{@render promptSnippet()}{:else}
|
2024-04-08 21:02:09 +00:00
|
|
|
<p>{prompt}</p>
|
2024-11-14 08:43:25 -06:00
|
|
|
{/if}
|
2025-05-03 00:41:42 +02:00
|
|
|
</ModalBody>
|
2023-01-02 15:22:33 -05:00
|
|
|
|
2025-05-03 00:41:42 +02:00
|
|
|
<ModalFooter>
|
2025-05-12 16:50:26 -04:00
|
|
|
<div class="flex gap-3 w-full">
|
2025-05-03 00:41:42 +02:00
|
|
|
{#if !hideCancelButton}
|
|
|
|
|
<Button shape="round" color={cancelColor} fullWidth onclick={() => onClose(false)}>
|
|
|
|
|
{cancelText}
|
|
|
|
|
</Button>
|
|
|
|
|
{/if}
|
|
|
|
|
<Button shape="round" color={confirmColor} fullWidth onclick={handleConfirm} {disabled}>
|
|
|
|
|
{confirmText}
|
2024-04-08 21:02:09 +00:00
|
|
|
</Button>
|
2025-05-03 00:41:42 +02:00
|
|
|
</div>
|
|
|
|
|
</ModalFooter>
|
|
|
|
|
</Modal>
|