-
-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathAlertDialogContent.svelte
64 lines (57 loc) · 1.89 KB
/
AlertDialogContent.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<script lang="ts">
import { melt } from "@melt-ui/svelte";
import type { Transition } from "$lib/internal/index.js";
import { getCtx, getAttrs } from "../ctx.js";
import type { ContentProps } from "../types.js";
type T = $$Generic<Transition>;
type In = $$Generic<Transition>;
type Out = $$Generic<Transition>;
type $$Props = ContentProps<T, In, Out>;
export let transition: $$Props["transition"] = undefined;
export let transitionConfig: $$Props["transitionConfig"] = undefined;
export let inTransition: $$Props["inTransition"] = undefined;
export let inTransitionConfig: $$Props["inTransitionConfig"] = undefined;
export let outTransition: $$Props["outTransition"] = undefined;
export let outTransitionConfig: $$Props["outTransitionConfig"] = undefined;
export let id: $$Props["id"] = undefined;
export let asChild: $$Props["asChild"] = false;
const {
elements: { content },
states: { open },
ids
} = getCtx();
$: if (id) {
ids.content.set(id);
}
$: builder = $content;
const attrs = getAttrs("content");
</script>
{#if asChild && $open}
<slot {builder} {attrs} />
{:else if transition && $open}
<div transition:transition={transitionConfig} use:melt={builder} {...$$restProps} {...attrs}>
<slot {builder} {attrs} />
</div>
{:else if inTransition && outTransition && $open}
<div
in:inTransition={inTransitionConfig}
out:outTransition={outTransitionConfig}
use:melt={builder}
{...$$restProps}
{...attrs}
>
<slot {builder} {attrs} />
</div>
{:else if inTransition && $open}
<div in:inTransition={inTransitionConfig} use:melt={builder} {...$$restProps} {...attrs}>
<slot {builder} {attrs} />
</div>
{:else if outTransition && $open}
<div out:outTransition={outTransitionConfig} use:melt={builder} {...$$restProps} {...attrs}>
<slot {builder} {attrs} />
</div>
{:else if $open}
<div use:melt={builder} {...$$restProps} {...attrs}>
<slot {builder} {attrs} />
</div>
{/if}