@skeletonlabs/skeleton 1.7.1-dev.702244cb → 1.7.1-dev.b93a512b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -69,18 +69,6 @@ function onAction(index) {
|
|
|
69
69
|
$toastStore[index]?.action?.response();
|
|
70
70
|
toastStore.close($toastStore[index].id);
|
|
71
71
|
}
|
|
72
|
-
function onMouseEnter(index) {
|
|
73
|
-
if ($toastStore[index]?.hoverable) {
|
|
74
|
-
toastStore.freeze(index);
|
|
75
|
-
classesSnackbar += " scale-[105%]";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function onMouseLeave(index) {
|
|
79
|
-
if ($toastStore[index]?.hoverable) {
|
|
80
|
-
toastStore.unfreeze(index);
|
|
81
|
-
classesSnackbar = classesSnackbar.replace(" scale-[105%]", "");
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
72
|
$:
|
|
85
73
|
classesWrapper = `${cWrapper} ${cPosition} ${zIndex} ${$$props.class || ""}`;
|
|
86
74
|
$:
|
|
@@ -112,13 +100,7 @@ const [send, receive] = crossfade({
|
|
|
112
100
|
<!-- List -->
|
|
113
101
|
<div class="snackbar {classesSnackbar}">
|
|
114
102
|
{#each filteredToasts as t, i (t)}
|
|
115
|
-
<div
|
|
116
|
-
animate:flip={{ duration }}
|
|
117
|
-
in:receive={{ key: t.id }}
|
|
118
|
-
out:send={{ key: t.id }}
|
|
119
|
-
on:mouseenter={() => onMouseEnter(i)}
|
|
120
|
-
on:mouseleave={() => onMouseLeave(i)}
|
|
121
|
-
>
|
|
103
|
+
<div animate:flip={{ duration }} in:receive={{ key: t.id }} out:send={{ key: t.id }}>
|
|
122
104
|
<!-- Toast -->
|
|
123
105
|
<div
|
|
124
106
|
class="toast {classesToast} {t.background ?? background} {t.classes ?? ''}"
|
|
@@ -127,12 +109,10 @@ const [send, receive] = crossfade({
|
|
|
127
109
|
data-testid="toast"
|
|
128
110
|
>
|
|
129
111
|
<div class="text-base">{@html t.message}</div>
|
|
130
|
-
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
</div>
|
|
135
|
-
{/if}
|
|
112
|
+
<div class="toast-actions {cToastActions}">
|
|
113
|
+
{#if t.action}<button class={buttonAction} on:click={() => onAction(i)}>{@html t.action.label}</button>{/if}
|
|
114
|
+
<button class={buttonDismiss} on:click={() => toastStore.close(t.id)}>{buttonDismissLabel}</button>
|
|
115
|
+
</div>
|
|
136
116
|
</div>
|
|
137
117
|
</div>
|
|
138
118
|
{/each}
|
|
@@ -2,13 +2,9 @@ import type { ToastSettings, Toast } from './types.js';
|
|
|
2
2
|
export declare const toastStore: {
|
|
3
3
|
subscribe: (this: void, run: import("svelte/store").Subscriber<Toast[]>, invalidate?: ((value?: Toast[] | undefined) => void) | undefined) => import("svelte/store").Unsubscriber;
|
|
4
4
|
/** Add a new toast to the queue. */
|
|
5
|
-
trigger: (toast: ToastSettings) =>
|
|
6
|
-
/** Remove toast in queue*/
|
|
5
|
+
trigger: (toast: ToastSettings) => void;
|
|
6
|
+
/** Remove first toast in queue */
|
|
7
7
|
close: (id: string) => void;
|
|
8
|
-
/** remain visible on hover */
|
|
9
|
-
freeze: (index: number) => void;
|
|
10
|
-
/** cancel remain visible on leave */
|
|
11
|
-
unfreeze: (index: number) => void;
|
|
12
8
|
/** Remove all toasts from queue */
|
|
13
9
|
clear: () => void;
|
|
14
10
|
};
|
|
@@ -19,27 +19,21 @@ function toastService() {
|
|
|
19
19
|
return {
|
|
20
20
|
subscribe,
|
|
21
21
|
/** Add a new toast to the queue. */
|
|
22
|
-
trigger: (toast) => {
|
|
22
|
+
trigger: (toast) => update((tStore) => {
|
|
23
23
|
const id = randomUUID();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// Return
|
|
38
|
-
return tStore;
|
|
39
|
-
});
|
|
40
|
-
return id;
|
|
41
|
-
},
|
|
42
|
-
/** Remove toast in queue*/
|
|
24
|
+
// Trigger Callback
|
|
25
|
+
if (toast && toast.callback)
|
|
26
|
+
toast.callback({ id, status: 'queued' });
|
|
27
|
+
// Merge with defaults
|
|
28
|
+
const tMerged = { ...toastDefaults, ...toast, id };
|
|
29
|
+
// Handle auto-hide, if needed
|
|
30
|
+
tMerged.timeoutId = handleAutoHide(tMerged);
|
|
31
|
+
// Push into store
|
|
32
|
+
tStore.push(tMerged);
|
|
33
|
+
// Return
|
|
34
|
+
return tStore;
|
|
35
|
+
}),
|
|
36
|
+
/** Remove first toast in queue */
|
|
43
37
|
close: (id) => update((tStore) => {
|
|
44
38
|
if (tStore.length > 0) {
|
|
45
39
|
const index = tStore.findIndex((t) => t.id === id);
|
|
@@ -57,18 +51,6 @@ function toastService() {
|
|
|
57
51
|
}
|
|
58
52
|
return tStore;
|
|
59
53
|
}),
|
|
60
|
-
/** remain visible on hover */
|
|
61
|
-
freeze: (index) => update((tStore) => {
|
|
62
|
-
if (tStore.length > 0)
|
|
63
|
-
clearTimeout(tStore[index].timeoutId);
|
|
64
|
-
return tStore;
|
|
65
|
-
}),
|
|
66
|
-
/** cancel remain visible on leave */
|
|
67
|
-
unfreeze: (index) => update((tStore) => {
|
|
68
|
-
if (tStore.length > 0)
|
|
69
|
-
tStore[index].timeoutId = handleAutoHide(tStore[index]);
|
|
70
|
-
return tStore;
|
|
71
|
-
}),
|
|
72
54
|
/** Remove all toasts from queue */
|
|
73
55
|
clear: () => set([])
|
|
74
56
|
};
|
|
@@ -14,10 +14,6 @@ export interface ToastSettings {
|
|
|
14
14
|
/** The function triggered when the button is pressed. */
|
|
15
15
|
response: () => void;
|
|
16
16
|
};
|
|
17
|
-
/** Hide dismiss button */
|
|
18
|
-
hideDismiss?: boolean;
|
|
19
|
-
/** Remain visible on Hover */
|
|
20
|
-
hoverable?: boolean;
|
|
21
17
|
/** Provide arbitrary CSS classes to style the toast. */
|
|
22
18
|
classes?: string;
|
|
23
19
|
/** Callback function that fires on trigger and close. */
|