|
1 | 1 | <script lang="ts">
|
2 |
| - import { Button, Form, InputCheckbox } from '$lib/elements/forms'; |
3 |
| - import { Alert, Layout, Modal } from '@appwrite.io/pink-svelte'; |
4 |
| -
|
| 2 | + import { Button, InputCheckbox } from '$lib/elements/forms'; |
| 3 | + import { Layout } from '@appwrite.io/pink-svelte'; |
| 4 | + import { Modal } from '.'; |
5 | 5 | export let open: boolean;
|
6 | 6 | export let title: string;
|
7 | 7 | export let error: string = null;
|
8 | 8 | export let action: string = 'Delete';
|
9 |
| - export let canDelete: boolean = true; |
10 | 9 | export let disabled: boolean = false;
|
11 | 10 | export let submissionLoader = false;
|
12 | 11 | export let confirmDeletion: boolean = false;
|
|
23 | 22 | }
|
24 | 23 | </script>
|
25 | 24 |
|
26 |
| -<Form isModal {onSubmit}> |
27 |
| - <Modal bind:open {title} size="s"> |
28 |
| - <Layout.Stack gap="xl"> |
29 |
| - {#if error} |
30 |
| - <Alert.Inline |
31 |
| - dismissible |
32 |
| - status="error" |
33 |
| - on:dismiss={() => { |
34 |
| - error = null; |
35 |
| - }}> |
36 |
| - {error} |
37 |
| - </Alert.Inline> |
38 |
| - {/if} |
| 25 | +<Modal size="s" bind:show={open} {title} {onSubmit} bind:error> |
| 26 | + <svelte:fragment slot="description"> |
| 27 | + {#if confirmDeletion} |
| 28 | + This action is irreversible. Please confirm to proceed. |
| 29 | + {/if} |
| 30 | + </svelte:fragment> |
39 | 31 |
|
40 |
| - <Layout.Stack gap="l"> |
41 |
| - <slot /> |
| 32 | + <Layout.Stack gap="l"> |
| 33 | + <slot /> |
42 | 34 |
|
43 |
| - {#if confirmDeletion} |
44 |
| - <InputCheckbox |
45 |
| - size="s" |
46 |
| - required |
47 |
| - id={checkboxId} |
48 |
| - bind:checked={confirm} |
49 |
| - label="I understand and confirm" /> |
50 |
| - {/if} |
51 |
| - </Layout.Stack> |
52 |
| - </Layout.Stack> |
| 35 | + {#if confirmDeletion} |
| 36 | + <InputCheckbox |
| 37 | + size="s" |
| 38 | + required |
| 39 | + id={checkboxId} |
| 40 | + bind:checked={confirm} |
| 41 | + label="I understand and confirm" /> |
| 42 | + {/if} |
| 43 | + </Layout.Stack> |
53 | 44 |
|
54 |
| - <svelte:fragment slot="footer"> |
55 |
| - <Layout.Stack direction="row" gap="s" justifyContent="flex-end"> |
56 |
| - <slot name="footer"> |
57 |
| - <Button text on:click={() => (open = false)}>Cancel</Button> |
58 |
| - {#if canDelete} |
59 |
| - <Button |
60 |
| - danger |
61 |
| - submit |
62 |
| - {submissionLoader} |
63 |
| - disabled={disabled || (confirmDeletion ? !confirm : false)} |
64 |
| - >{action}</Button> |
65 |
| - {/if} |
66 |
| - </slot> |
67 |
| - </Layout.Stack> |
68 |
| - </svelte:fragment> |
69 |
| - </Modal> |
70 |
| -</Form> |
| 45 | + <svelte:fragment slot="footer"> |
| 46 | + <Button text on:click={() => (open = false)}>Cancel</Button> |
| 47 | + <Button |
| 48 | + danger |
| 49 | + submit |
| 50 | + {submissionLoader} |
| 51 | + disabled={disabled || (confirmDeletion ? !confirm : false)}> |
| 52 | + {action} |
| 53 | + </Button> |
| 54 | + </svelte:fragment> |
| 55 | +</Modal> |
0 commit comments