2023-01-02 15:22:33 -05:00
|
|
|
<script lang="ts">
|
2024-05-28 09:10:43 +07:00
|
|
|
import FullScreenModal from '../full-screen-modal.svelte';
|
2024-06-04 21:53:00 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2024-11-14 08:43:25 -06:00
|
|
|
import type { Snippet } from 'svelte';
|
2025-03-14 09:37:56 -04:00
|
|
|
import { Button, type Color } from '@immich/ui';
|
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;
|
|
|
|
|
width?: 'wide' | 'narrow';
|
|
|
|
|
onCancel: () => void;
|
|
|
|
|
onConfirm: () => void;
|
|
|
|
|
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,
|
|
|
|
|
width = 'narrow',
|
|
|
|
|
onCancel,
|
|
|
|
|
onConfirm,
|
|
|
|
|
promptSnippet,
|
|
|
|
|
}: Props = $props();
|
2023-06-30 21:53:16 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const handleConfirm = () => {
|
2024-03-07 04:18:53 +01:00
|
|
|
onConfirm();
|
2023-12-05 13:16:37 -06:00
|
|
|
};
|
2023-01-02 15:22:33 -05:00
|
|
|
</script>
|
|
|
|
|
|
2024-06-01 22:58:35 +00:00
|
|
|
<FullScreenModal {title} onClose={onCancel} {width}>
|
2024-04-08 21:02:09 +00:00
|
|
|
<div class="text-md py-5 text-center">
|
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}
|
2024-04-08 21:02:09 +00:00
|
|
|
</div>
|
2023-01-02 15:22:33 -05:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
{#snippet stickyBottom()}
|
2024-04-08 21:02:09 +00:00
|
|
|
{#if !hideCancelButton}
|
2025-03-14 09:37:56 -04:00
|
|
|
<Button shape="round" color={cancelColor} fullWidth onclick={onCancel}>
|
2024-04-08 21:02:09 +00:00
|
|
|
{cancelText}
|
|
|
|
|
</Button>
|
|
|
|
|
{/if}
|
2025-03-14 09:37:56 -04:00
|
|
|
<Button shape="round" color={confirmColor} fullWidth onclick={handleConfirm} {disabled}>
|
2024-04-08 21:02:09 +00:00
|
|
|
{confirmText}
|
|
|
|
|
</Button>
|
2024-11-14 08:43:25 -06:00
|
|
|
{/snippet}
|
2023-01-02 15:22:33 -05:00
|
|
|
</FullScreenModal>
|