@budibase/bbui 1.0.49-alpha.15 → 1.0.49-alpha.16
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.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/bbui",
|
|
3
3
|
"description": "A UI solution used in the different Budibase projects.",
|
|
4
|
-
"version": "1.0.49-alpha.
|
|
4
|
+
"version": "1.0.49-alpha.16",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"svelte": "src/index.js",
|
|
7
7
|
"module": "dist/bbui.es.js",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"svelte-flatpickr": "^3.2.3",
|
|
84
84
|
"svelte-portal": "^1.0.0"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "75bc7555b185e8eceb40f842186b79c1f49f6d11"
|
|
87
87
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
import { createEventDispatcher } from "svelte"
|
|
3
|
+
|
|
2
4
|
export let type = "info"
|
|
3
5
|
export let icon = "Info"
|
|
4
6
|
export let message = ""
|
|
7
|
+
export let dismissable = false
|
|
8
|
+
|
|
9
|
+
const dispatch = createEventDispatcher()
|
|
5
10
|
</script>
|
|
6
11
|
|
|
7
12
|
<div class="spectrum-Toast spectrum-Toast--{type}">
|
|
@@ -17,4 +22,28 @@
|
|
|
17
22
|
<div class="spectrum-Toast-body">
|
|
18
23
|
<div class="spectrum-Toast-content">{message || ""}</div>
|
|
19
24
|
</div>
|
|
25
|
+
{#if dismissable}
|
|
26
|
+
<div class="spectrum-Toast-buttons">
|
|
27
|
+
<button
|
|
28
|
+
class="spectrum-ClearButton spectrum-ClearButton--overBackground spectrum-ClearButton--sizeM"
|
|
29
|
+
on:click={() => dispatch("dismiss")}
|
|
30
|
+
>
|
|
31
|
+
<div class="spectrum-ClearButton-fill">
|
|
32
|
+
<svg
|
|
33
|
+
class="spectrum-ClearButton-icon spectrum-Icon spectrum-UIIcon-Cross100"
|
|
34
|
+
focusable="false"
|
|
35
|
+
aria-hidden="true"
|
|
36
|
+
>
|
|
37
|
+
<use xlink:href="#spectrum-css-icon-Cross100" />
|
|
38
|
+
</svg>
|
|
39
|
+
</div>
|
|
40
|
+
</button>
|
|
41
|
+
</div>
|
|
42
|
+
{/if}
|
|
20
43
|
</div>
|
|
44
|
+
|
|
45
|
+
<style>
|
|
46
|
+
.spectrum-Toast {
|
|
47
|
+
pointer-events: all;
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import "@spectrum-css/toast/dist/index-vars.css"
|
|
3
3
|
import Portal from "svelte-portal"
|
|
4
|
-
import { flip } from "svelte/animate"
|
|
5
4
|
import { notifications } from "../Stores/notifications"
|
|
6
5
|
import Notification from "./Notification.svelte"
|
|
7
6
|
import { fly } from "svelte/transition"
|
|
@@ -9,9 +8,15 @@
|
|
|
9
8
|
|
|
10
9
|
<Portal target=".modal-container">
|
|
11
10
|
<div class="notifications">
|
|
12
|
-
{#each $notifications as { type, icon, message, id } (id)}
|
|
13
|
-
<div
|
|
14
|
-
<Notification
|
|
11
|
+
{#each $notifications as { type, icon, message, id, dismissable } (id)}
|
|
12
|
+
<div transition:fly={{ y: -30 }}>
|
|
13
|
+
<Notification
|
|
14
|
+
{type}
|
|
15
|
+
{icon}
|
|
16
|
+
{message}
|
|
17
|
+
{dismissable}
|
|
18
|
+
on:dismiss={() => notifications.dismiss(id)}
|
|
19
|
+
/>
|
|
15
20
|
</div>
|
|
16
21
|
{/each}
|
|
17
22
|
</div>
|
|
@@ -20,20 +20,29 @@ export const createNotificationStore = () => {
|
|
|
20
20
|
setTimeout(() => (block = false), timeout)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const send = (message, type = "default", icon = "") => {
|
|
23
|
+
const send = (message, type = "default", icon = "", autoDismiss = true) => {
|
|
24
24
|
if (block) {
|
|
25
25
|
return
|
|
26
26
|
}
|
|
27
27
|
let _id = id()
|
|
28
28
|
_notifications.update(state => {
|
|
29
|
-
return [
|
|
29
|
+
return [
|
|
30
|
+
...state,
|
|
31
|
+
{ id: _id, type, message, icon, dismissable: !autoDismiss },
|
|
32
|
+
]
|
|
33
|
+
})
|
|
34
|
+
if (autoDismiss) {
|
|
35
|
+
const timeoutId = setTimeout(() => {
|
|
36
|
+
dismissNotification(_id)
|
|
37
|
+
}, NOTIFICATION_TIMEOUT)
|
|
38
|
+
timeoutIds.add(timeoutId)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const dismissNotification = id => {
|
|
43
|
+
_notifications.update(state => {
|
|
44
|
+
return state.filter(n => n.id !== id)
|
|
30
45
|
})
|
|
31
|
-
const timeoutId = setTimeout(() => {
|
|
32
|
-
_notifications.update(state => {
|
|
33
|
-
return state.filter(({ id }) => id !== _id)
|
|
34
|
-
})
|
|
35
|
-
}, NOTIFICATION_TIMEOUT)
|
|
36
|
-
timeoutIds.add(timeoutId)
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
const { subscribe } = _notifications
|
|
@@ -42,10 +51,11 @@ export const createNotificationStore = () => {
|
|
|
42
51
|
subscribe,
|
|
43
52
|
send,
|
|
44
53
|
info: msg => send(msg, "info", "Info"),
|
|
45
|
-
error: msg => send(msg, "error", "Alert"),
|
|
54
|
+
error: msg => send(msg, "error", "Alert", false),
|
|
46
55
|
warning: msg => send(msg, "warning", "Alert"),
|
|
47
56
|
success: msg => send(msg, "success", "CheckmarkCircle"),
|
|
48
57
|
blockNotifications,
|
|
58
|
+
dismiss: dismissNotification,
|
|
49
59
|
}
|
|
50
60
|
}
|
|
51
61
|
|