@axel669/zephyr 0.1.17 → 0.2.0-beta.1
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/LICENSE +21 -21
- package/package.json +10 -7
- package/readme.md +55 -44
- package/src/async/button.svelte +31 -0
- package/src/async/load-zone.svelte +17 -0
- package/src/composed/data-table/th.svelte +60 -0
- package/src/composed/data-table.md +83 -0
- package/src/composed/data-table.svelte +136 -150
- package/src/composed/entry-button.md +34 -0
- package/src/composed/entry-button.svelte +29 -68
- package/src/composed/table-functions.js +13 -0
- package/src/composed/toast/message.svelte +56 -44
- package/src/composed/toast.md +36 -0
- package/src/composed/toast.svelte +68 -108
- package/src/control/button.md +37 -0
- package/src/control/button.svelte +25 -0
- package/src/control/input.svelte +107 -0
- package/src/control/label.md +45 -0
- package/src/control/label.svelte +36 -0
- package/src/control/link.md +46 -0
- package/src/control/link.svelte +28 -0
- package/src/control/radio.md +56 -0
- package/src/control/radio.svelte +26 -0
- package/src/control/select.md +68 -0
- package/src/control/select.svelte +62 -0
- package/src/control/tabs.md +45 -0
- package/src/control/tabs.svelte +39 -0
- package/src/control/toggle.md +55 -0
- package/src/control/toggle.svelte +47 -0
- package/src/data-display/avatar.md +32 -0
- package/src/data-display/avatar.svelte +23 -0
- package/src/data-display/badge.md +24 -0
- package/src/data-display/badge.svelte +12 -0
- package/src/data-display/chip.md +32 -0
- package/src/data-display/chip.svelte +26 -0
- package/src/data-display/details.md +3 -0
- package/src/{details.svelte → data-display/details.svelte} +3 -3
- package/src/data-display/popover.md +28 -0
- package/src/data-display/popover.svelte +23 -0
- package/src/data-display/progress.md +42 -0
- package/src/data-display/progress.svelte +25 -0
- package/src/data-display/table.md +7 -0
- package/src/data-display/table.svelte +36 -0
- package/src/data-display/tooltip.md +25 -0
- package/src/data-display/tooltip.svelte +15 -0
- package/src/dialogs/alert.md +3 -0
- package/src/dialogs/alert.svelte +4 -4
- package/src/dialogs/confirm.md +3 -0
- package/src/dialogs/confirm.svelte +5 -5
- package/src/functions.md +77 -0
- package/src/handler$.mjs +20 -68
- package/src/index.mjs +58 -92
- package/src/info/icon.md +17 -0
- package/src/info/icon.svelte +9 -0
- package/src/info/notification.md +32 -0
- package/src/info/notification.svelte +16 -0
- package/src/info/titlebar.md +49 -0
- package/src/info/titlebar.svelte +18 -0
- package/src/info/toaster.md +22 -0
- package/src/info/toaster.svelte +14 -0
- package/src/inline-dialog.svelte +23 -23
- package/src/layout/dialog.md +34 -0
- package/src/layout/dialog.svelte +24 -0
- package/src/layout/drawer.md +61 -0
- package/src/layout/drawer.svelte +47 -0
- package/src/layout/flex.md +39 -0
- package/src/layout/flex.svelte +22 -0
- package/src/layout/grid.md +57 -0
- package/src/layout/grid.svelte +26 -0
- package/src/layout/modal.md +47 -0
- package/src/layout/modal.svelte +58 -0
- package/src/layout/paper.md +90 -0
- package/src/layout/paper.svelte +45 -0
- package/src/layout/screen.md +28 -0
- package/src/layout/screen.svelte +32 -0
- package/src/{circle-spinner.svelte → spinner/circle-spinner.svelte} +2 -2
- package/src/{hexagon-spinner.svelte → spinner/hexagon-spinner.svelte} +2 -2
- package/src/spinner/spinners.md +3 -0
- package/src/text.md +34 -0
- package/src/text.svelte +20 -49
- package/src/variant.mjs +12 -12
- package/src/wsx.mjs +24 -45
- package/src/avatar.svelte +0 -54
- package/src/badge.svelte +0 -40
- package/src/button.svelte +0 -86
- package/src/chip.svelte +0 -56
- package/src/dialog.svelte +0 -54
- package/src/drawer.svelte +0 -121
- package/src/flex.svelte +0 -57
- package/src/grid.svelte +0 -66
- package/src/icon.svelte +0 -34
- package/src/input/area.svelte +0 -98
- package/src/input/elems.mjs +0 -7
- package/src/input/email.svelte +0 -104
- package/src/input/file.svelte +0 -82
- package/src/input/number.svelte +0 -104
- package/src/input/password.svelte +0 -101
- package/src/input/search.svelte +0 -104
- package/src/input/text.svelte +0 -104
- package/src/link.svelte +0 -67
- package/src/modal.svelte +0 -73
- package/src/notification.svelte +0 -57
- package/src/paper.svelte +0 -127
- package/src/popover.svelte +0 -60
- package/src/progress.svelte +0 -60
- package/src/radio.svelte +0 -82
- package/src/screen.svelte +0 -69
- package/src/select.svelte +0 -122
- package/src/table.svelte +0 -69
- package/src/tabs.svelte +0 -78
- package/src/titlebar.svelte +0 -69
- package/src/toaster.svelte +0 -42
- package/src/toggle.svelte +0 -94
- package/src/tooltip.svelte +0 -45
- package/src/vars.mjs +0 -61
|
@@ -1,150 +1,136 @@
|
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
</tbody>
|
|
138
|
-
</table>
|
|
139
|
-
<Grid slot="footer" gr-col="min-content min-content min-content 1fr">
|
|
140
|
-
<Button on:click={prev}>
|
|
141
|
-
<Icon name="arrow-big-left" />
|
|
142
|
-
</Button>
|
|
143
|
-
<Button on:click={next}>
|
|
144
|
-
<Icon name="arrow-big-right" />
|
|
145
|
-
</Button>
|
|
146
|
-
<Text adorn t-ws="nowrap">
|
|
147
|
-
Page {page + 1} / {pageCount}
|
|
148
|
-
</Text>
|
|
149
|
-
</Grid>
|
|
150
|
-
</Paper>
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script context="module">
|
|
4
|
+
// find the first filter in the list that returns false
|
|
5
|
+
const applyFilters = (data, filters) => data.filter(
|
|
6
|
+
(row) => {
|
|
7
|
+
for (const [filter, value] of filters) {
|
|
8
|
+
if (filter(row, value) === false) {
|
|
9
|
+
return false
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return true
|
|
13
|
+
}
|
|
14
|
+
)
|
|
15
|
+
const noSort = {
|
|
16
|
+
direction: null,
|
|
17
|
+
func: (a, b) => 0,
|
|
18
|
+
base: null,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const dtContext = Symbol("table key")
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import { createEventDispatcher, setContext } from "svelte"
|
|
26
|
+
import { writable } from "svelte/store"
|
|
27
|
+
|
|
28
|
+
import Button from "../control/button.svelte"
|
|
29
|
+
import Icon from "../info/icon.svelte"
|
|
30
|
+
import Paper from "../layout/paper.svelte"
|
|
31
|
+
import Table from "../data-display/table.svelte"
|
|
32
|
+
import Text from "../text.svelte"
|
|
33
|
+
|
|
34
|
+
import Grid from "../layout/grid.svelte"
|
|
35
|
+
|
|
36
|
+
import wsx from "../wsx.mjs"
|
|
37
|
+
import { handler$, eventHandler$ } from "../handler$.mjs"
|
|
38
|
+
|
|
39
|
+
export let color = false
|
|
40
|
+
export let fillHeader = true
|
|
41
|
+
export let data = []
|
|
42
|
+
export let pageSize = 10
|
|
43
|
+
export let page = 0
|
|
44
|
+
export let rowHeight = "40px"
|
|
45
|
+
|
|
46
|
+
$: rows = Array.from(
|
|
47
|
+
{ length: pageSize },
|
|
48
|
+
(_, i) => filteredData[page * pageSize + i]
|
|
49
|
+
)
|
|
50
|
+
$: rowCount = filteredData.length
|
|
51
|
+
$: pageCount = Math.ceil(rowCount / pageSize)
|
|
52
|
+
$: maxPage = Math.max(pageCount - 1, 0)
|
|
53
|
+
|
|
54
|
+
let sorting = noSort
|
|
55
|
+
let filters = new Map()
|
|
56
|
+
let filterFunctions = []
|
|
57
|
+
|
|
58
|
+
$: filteredData =
|
|
59
|
+
applyFilters(data, filterFunctions)
|
|
60
|
+
.sort(sorting.func)
|
|
61
|
+
|
|
62
|
+
const prev = () => page = Math.max(0, page - 1)
|
|
63
|
+
const next = () => page = Math.min(maxPage, page + 1)
|
|
64
|
+
|
|
65
|
+
const updateSort = (func) => {
|
|
66
|
+
if (sorting.base === func) {
|
|
67
|
+
if (sorting.direction === "desc") {
|
|
68
|
+
sorting = noSort
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
sorting = {
|
|
72
|
+
func: (a, b) => -func(a, b),
|
|
73
|
+
base: func,
|
|
74
|
+
direction: "desc"
|
|
75
|
+
}
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
sorting = {
|
|
79
|
+
func,
|
|
80
|
+
base: func,
|
|
81
|
+
direction: "asc",
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const updateFilter = (func, value) => {
|
|
85
|
+
if (func === null) {
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
filters.set(func, value)
|
|
89
|
+
filterFunctions = [
|
|
90
|
+
...filters.entries()
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const context = writable({})
|
|
95
|
+
$: $context = {
|
|
96
|
+
updateSort,
|
|
97
|
+
fillHeader,
|
|
98
|
+
sorting,
|
|
99
|
+
updateFilter,
|
|
100
|
+
}
|
|
101
|
+
setContext(dtContext, context)
|
|
102
|
+
|
|
103
|
+
const fire = createEventDispatcher()
|
|
104
|
+
const pass = handler$(
|
|
105
|
+
(row) => fire("row-click", row)
|
|
106
|
+
)
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<Paper card {color} l-fl.cross="stretch" l-p="0px">
|
|
110
|
+
<Table data={rows} {color} {fillHeader} {...$$restProps}>
|
|
111
|
+
<tr ws-x="h.min[{rowHeight}]" slot="header">
|
|
112
|
+
<slot name="header">
|
|
113
|
+
<th>No Header Defined</th>
|
|
114
|
+
</slot>
|
|
115
|
+
</tr>
|
|
116
|
+
<tr ws-x="h[{rowHeight}]" slot="row" let:row>
|
|
117
|
+
<slot name="row" {row}>
|
|
118
|
+
<th>No Row Defined</th>
|
|
119
|
+
</slot>
|
|
120
|
+
</tr>
|
|
121
|
+
<tr ws-x="h[{rowHeight}]" slot="empty-row" />
|
|
122
|
+
</Table>
|
|
123
|
+
<Grid slot="footer" gr.cols="min-content min-content min-content 1fr">
|
|
124
|
+
{#if pageCount > 0}
|
|
125
|
+
<Button on:click={prev} disabled={page === 0}>
|
|
126
|
+
<Icon name="arrow-big-left" />
|
|
127
|
+
</Button>
|
|
128
|
+
<Button on:click={next} disabled={page === maxPage}>
|
|
129
|
+
<Icon name="arrow-big-right" />
|
|
130
|
+
</Button>
|
|
131
|
+
<Text adorn t.ws="nowrap">
|
|
132
|
+
Page {page + 1} / {pageCount}
|
|
133
|
+
</Text>
|
|
134
|
+
{/if}
|
|
135
|
+
</Grid>
|
|
136
|
+
</Paper>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# EntryButton
|
|
2
|
+
|
|
3
|
+
The EntryButton is a convenient way to display modals and screens over
|
|
4
|
+
content without needing to bind variables have lots of Modal elements in
|
|
5
|
+
addition to the buttons that show them.
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
- ### component
|
|
10
|
+
The component to show when clicked
|
|
11
|
+
- ### props
|
|
12
|
+
The props to pass to the component when it is shown, or a function that
|
|
13
|
+
generates the props when called
|
|
14
|
+
- ### this
|
|
15
|
+
The wrapper for the component. Default is Modal but any component that
|
|
16
|
+
has the same interface as Modal will work
|
|
17
|
+
|
|
18
|
+
## Events
|
|
19
|
+
- ### entry
|
|
20
|
+
When the component is close the entry event is fired. The detail
|
|
21
|
+
property of the event will have the value from closing it
|
|
22
|
+
|
|
23
|
+
## Example
|
|
24
|
+
```svelte
|
|
25
|
+
<EntryButton component={Subscreen} on:entry={console.log}>
|
|
26
|
+
Open Subscreen
|
|
27
|
+
</EntryButton>
|
|
28
|
+
<EntryButton component={CoolDialog} on:entry={console.log}>
|
|
29
|
+
Open Subscreen
|
|
30
|
+
</EntryButton>
|
|
31
|
+
<EntryButton this={CoolModal} component={CustomThing} on:entry={console.log}>
|
|
32
|
+
Open Subscreen
|
|
33
|
+
</EntryButton>
|
|
34
|
+
```
|
|
@@ -1,68 +1,29 @@
|
|
|
1
|
-
<script>
|
|
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
|
-
Open Subscreen
|
|
31
|
-
</EntryButton>
|
|
32
|
-
<EntryButton component={CoolDialog} on:entry={console.log}>
|
|
33
|
-
Open Subscreen
|
|
34
|
-
</EntryButton>
|
|
35
|
-
<EntryButton this={CoolModal} component={CustomThing} on:entry={console.log}>
|
|
36
|
-
Open Subscreen
|
|
37
|
-
</EntryButton>
|
|
38
|
-
```
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
import { createEventDispatcher } from "svelte"
|
|
42
|
-
|
|
43
|
-
import Button from "../button.svelte"
|
|
44
|
-
import Modal from "../modal.svelte"
|
|
45
|
-
import { handler$ } from "../handler$.mjs"
|
|
46
|
-
|
|
47
|
-
export let component
|
|
48
|
-
export let props
|
|
49
|
-
let wrapper = Modal
|
|
50
|
-
export { wrapper as this }
|
|
51
|
-
|
|
52
|
-
const send = createEventDispatcher()
|
|
53
|
-
|
|
54
|
-
let element = null
|
|
55
|
-
const open = handler$(
|
|
56
|
-
async (props) => {
|
|
57
|
-
const elemProps = (typeof props === "function") ? props() : props
|
|
58
|
-
const result = await element.show(elemProps)
|
|
59
|
-
send("entry", result)
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
</script>
|
|
63
|
-
|
|
64
|
-
<Button {...$$restProps} on:click={open(props)}>
|
|
65
|
-
<slot />
|
|
66
|
-
</Button>
|
|
67
|
-
|
|
68
|
-
<svelte:component this={wrapper} {component} bind:this={element} />
|
|
1
|
+
<script>
|
|
2
|
+
import { createEventDispatcher } from "svelte"
|
|
3
|
+
|
|
4
|
+
import Button from "../control/button.svelte"
|
|
5
|
+
import Modal from "../layout/modal.svelte"
|
|
6
|
+
import { handler$ } from "../handler$.mjs"
|
|
7
|
+
|
|
8
|
+
export let component
|
|
9
|
+
export let props
|
|
10
|
+
let wrapper = Modal
|
|
11
|
+
export { wrapper as this }
|
|
12
|
+
|
|
13
|
+
const send = createEventDispatcher()
|
|
14
|
+
|
|
15
|
+
let element = null
|
|
16
|
+
const open = handler$(
|
|
17
|
+
async (props) => {
|
|
18
|
+
const elemProps = (typeof props === "function") ? props() : props
|
|
19
|
+
const result = await element.show(elemProps)
|
|
20
|
+
send("entry", result)
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<Button {...$$restProps} on:click={open(props)}>
|
|
26
|
+
<slot />
|
|
27
|
+
</Button>
|
|
28
|
+
|
|
29
|
+
<svelte:component this={wrapper} {component} bind:this={element} />
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const filters = {
|
|
2
|
+
text: (propName) =>
|
|
3
|
+
(row, text) =>
|
|
4
|
+
row[propName]
|
|
5
|
+
.toLowerCase()
|
|
6
|
+
.includes(text.toLowerCase())
|
|
7
|
+
}
|
|
8
|
+
export const sorts = {
|
|
9
|
+
natural: (propName) => {
|
|
10
|
+
const comparitor = new Intl.Collator(undefined, { numeric: true })
|
|
11
|
+
return (a, b) => comparitor.compare(a[propName], b[propName])
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,44 +1,56 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/*md
|
|
3
|
-
[@] Components/ToastMessage
|
|
4
|
-
|
|
5
|
-
# ToastMessage
|
|
6
|
-
|
|
7
|
-
The default component for Toast to show messages with
|
|
8
|
-
|
|
9
|
-
## Props
|
|
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
|
-
|
|
1
|
+
<script>
|
|
2
|
+
/*md
|
|
3
|
+
[@] Components/ToastMessage
|
|
4
|
+
|
|
5
|
+
# ToastMessage
|
|
6
|
+
|
|
7
|
+
The default component for Toast to show messages with
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
### actionText
|
|
12
|
+
`string`
|
|
13
|
+
|
|
14
|
+
If given, the message will have a button that can be clicked and will
|
|
15
|
+
use this text for the button text
|
|
16
|
+
|
|
17
|
+
### color
|
|
18
|
+
`string`
|
|
19
|
+
|
|
20
|
+
Sets `$color`
|
|
21
|
+
|
|
22
|
+
### icon
|
|
23
|
+
`string`
|
|
24
|
+
|
|
25
|
+
An icon to show with the message
|
|
26
|
+
|
|
27
|
+
### message
|
|
28
|
+
`string`
|
|
29
|
+
|
|
30
|
+
The message to show
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import { createEventDispatcher } from "svelte"
|
|
34
|
+
|
|
35
|
+
import Button from "../../control/button.svelte"
|
|
36
|
+
import Icon from "../../info/icon.svelte"
|
|
37
|
+
import Notification from "../../info/notification.svelte"
|
|
38
|
+
|
|
39
|
+
export let message = ""
|
|
40
|
+
export let icon = ""
|
|
41
|
+
export let color = false
|
|
42
|
+
export let actionText = null
|
|
43
|
+
|
|
44
|
+
const dispatch = createEventDispatcher()
|
|
45
|
+
const dismiss = () => dispatch("action", null)
|
|
46
|
+
const respond = () => dispatch("action", true)
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<Notification {color} on:click={dismiss}>
|
|
50
|
+
<Icon name={icon}>{message}</Icon>
|
|
51
|
+
{#if actionText}
|
|
52
|
+
<Button {color} variant="fill" on:click={respond}>
|
|
53
|
+
{actionText}
|
|
54
|
+
</Button>
|
|
55
|
+
{/if}
|
|
56
|
+
</Notification>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Toast
|
|
2
|
+
|
|
3
|
+
Displays toast notifications along the edge of the screen.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
See the Toaster component. The Toast component is wrapper around it that
|
|
7
|
+
also controls the children being shown for convenience.
|
|
8
|
+
|
|
9
|
+
- ### component
|
|
10
|
+
The component to use as a wrapper for the messages. Defaults to the
|
|
11
|
+
ToastMessage component.
|
|
12
|
+
|
|
13
|
+
## Functions
|
|
14
|
+
- ### show(duration, props)
|
|
15
|
+
Shows a toast notification that will disappear after the specified
|
|
16
|
+
duration (time in milliseconds). The props provided are passed to an
|
|
17
|
+
instance of the component specified in the props.
|
|
18
|
+
|
|
19
|
+
## Events
|
|
20
|
+
- ### action(info)
|
|
21
|
+
Fired when a toast message is clicked. The info argument contains a
|
|
22
|
+
value property that is provided by the message component, and a copy
|
|
23
|
+
of the props passed to that instace.\\
|
|
24
|
+
For the default messages, the value will be `null` if no button was
|
|
25
|
+
clicked, and `true` if the action button was clicked. This allows
|
|
26
|
+
actions to be taken against interactions in the message without having
|
|
27
|
+
to bind all kinds of events or callbacks.
|
|
28
|
+
|
|
29
|
+
## Example
|
|
30
|
+
```js
|
|
31
|
+
let toast = null
|
|
32
|
+
const notify = () => toast.show(5000, { message: "hi" })
|
|
33
|
+
```
|
|
34
|
+
```svelte
|
|
35
|
+
<Toast bind:this={toast} position="bc" />
|
|
36
|
+
```
|