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';
|
|
|
|
|
import Button from '../../elements/buttons/button.svelte';
|
2023-07-01 00:50:47 -04:00
|
|
|
import type { Color } from '$lib/components/elements/buttons/button.svelte';
|
2023-01-02 15:22:33 -05:00
|
|
|
|
2024-05-28 09:10:43 +07:00
|
|
|
export let id: string = 'confirm-dialog';
|
2023-07-01 00:50:47 -04:00
|
|
|
export let title = 'Confirm';
|
|
|
|
|
export let prompt = 'Are you sure you want to do this?';
|
|
|
|
|
export let confirmText = 'Confirm';
|
|
|
|
|
export let confirmColor: Color = 'red';
|
|
|
|
|
export let cancelText = 'Cancel';
|
2024-04-16 05:06:15 +00:00
|
|
|
export let cancelColor: Color = 'secondary';
|
2023-07-01 00:50:47 -04:00
|
|
|
export let hideCancelButton = false;
|
2023-11-30 04:52:28 +01:00
|
|
|
export let disabled = false;
|
2024-04-08 21:02:09 +00:00
|
|
|
export let width: 'wide' | 'narrow' = 'narrow';
|
2024-05-28 09:10:43 +07:00
|
|
|
export let onCancel: () => void;
|
2024-03-07 04:18:53 +01:00
|
|
|
export let onConfirm: () => void;
|
2023-06-30 21:53:16 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
let isConfirmButtonDisabled = false;
|
2023-06-30 21:53:16 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const handleConfirm = () => {
|
|
|
|
|
isConfirmButtonDisabled = true;
|
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-05-28 09:10:43 +07:00
|
|
|
<FullScreenModal {title} {id} onClose={onCancel} {width}>
|
2024-04-08 21:02:09 +00:00
|
|
|
<div class="text-md py-5 text-center">
|
|
|
|
|
<slot name="prompt">
|
|
|
|
|
<p>{prompt}</p>
|
|
|
|
|
</slot>
|
|
|
|
|
</div>
|
2023-01-02 15:22:33 -05:00
|
|
|
|
2024-04-16 05:06:15 +00:00
|
|
|
<svelte:fragment slot="sticky-bottom">
|
2024-04-08 21:02:09 +00:00
|
|
|
{#if !hideCancelButton}
|
2024-05-28 09:10:43 +07:00
|
|
|
<Button color={cancelColor} fullwidth on:click={onCancel}>
|
2024-04-08 21:02:09 +00:00
|
|
|
{cancelText}
|
|
|
|
|
</Button>
|
|
|
|
|
{/if}
|
|
|
|
|
<Button color={confirmColor} fullwidth on:click={handleConfirm} disabled={disabled || isConfirmButtonDisabled}>
|
|
|
|
|
{confirmText}
|
|
|
|
|
</Button>
|
2024-04-16 05:06:15 +00:00
|
|
|
</svelte:fragment>
|
2023-01-02 15:22:33 -05:00
|
|
|
</FullScreenModal>
|