@axel669/zephyr 1.0.0-beta.1 → 1.0.0-dev.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/compiler/build.js +13 -0
- package/compiler/parser.js +2973 -0
- package/compiler/rollup.js +28 -0
- package/compiler/transpiler.js +140 -0
- package/dist/zephyr-unstyled.js +587 -0
- package/dist/zephyr-unstyled.min.js +1 -0
- package/dist/zephyr.js +2002 -0
- package/dist/zephyr.min.js +47 -0
- package/package.json +35 -33
- package/readme.md +194 -19
- package/src/changed.svelte.js +0 -23
- package/src/component/adorn.svelte +0 -9
- package/src/component/alert.svelte +0 -32
- package/src/component/application.svelte +0 -17
- package/src/component/async-button.svelte +0 -53
- package/src/component/avatar.svelte +0 -15
- package/src/component/badge.svelte +0 -7
- package/src/component/button.svelte +0 -7
- package/src/component/chip.svelte +0 -10
- package/src/component/circle-spinner.svelte +0 -6
- package/src/component/confirm.svelte +0 -40
- package/src/component/control-label.svelte +0 -41
- package/src/component/data-table.svelte +0 -227
- package/src/component/details.svelte +0 -22
- package/src/component/dialog-element.svelte +0 -36
- package/src/component/dialog.svelte +0 -43
- package/src/component/drawer.svelte +0 -20
- package/src/component/flex.svelte +0 -7
- package/src/component/grid.svelte +0 -7
- package/src/component/hexagon-spinner.svelte +0 -6
- package/src/component/icon.svelte +0 -7
- package/src/component/link.svelte +0 -11
- package/src/component/modal.svelte +0 -32
- package/src/component/paper.svelte +0 -33
- package/src/component/popover.svelte +0 -19
- package/src/component/progress.svelte +0 -6
- package/src/component/prompt.svelte +0 -58
- package/src/component/route.svelte +0 -62
- package/src/component/routing.svelte.js +0 -63
- package/src/component/screen.svelte +0 -30
- package/src/component/select.svelte +0 -40
- package/src/component/suspend.svelte +0 -44
- package/src/component/table.svelte +0 -49
- package/src/component/tabs.svelte +0 -2
- package/src/component/text.svelte +0 -26
- package/src/component/title.svelte +0 -28
- package/src/component/titlebar.svelte +0 -23
- package/src/component/toast.svelte +0 -7
- package/src/component/toaster.svelte +0 -60
- package/src/component/toggle-label.svelte +0 -11
- package/src/component/tooltip.svelte +0 -11
- package/src/handler$.js +0 -20
- package/src/hash.js +0 -14
- package/src/index.js +0 -65
- package/src/internals.js +0 -12
- package/src/main.js +0 -40
- package/src/props.js +0 -24
- package/src/variant.js +0 -10
- package/src/wind.js +0 -4
- package/src/ws.js +0 -10
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Flex from "./flex.svelte"
|
|
3
|
-
|
|
4
|
-
const {
|
|
5
|
-
ws,
|
|
6
|
-
children,
|
|
7
|
-
content,
|
|
8
|
-
header,
|
|
9
|
-
footer,
|
|
10
|
-
layoutWS = "",
|
|
11
|
-
...rest
|
|
12
|
-
} = $props()
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<ws-paper data-ws={ws} {...rest}>
|
|
16
|
-
{#if header}
|
|
17
|
-
<ze-header data-ws="grid; p: 0px; area: header;">
|
|
18
|
-
{@render header()}
|
|
19
|
-
</ze-header>
|
|
20
|
-
{/if}
|
|
21
|
-
{#if content}
|
|
22
|
-
{@render content()}
|
|
23
|
-
{:else}
|
|
24
|
-
<Flex ws={layoutWS}>
|
|
25
|
-
{@render children?.()}
|
|
26
|
-
</Flex>
|
|
27
|
-
{/if}
|
|
28
|
-
{#if footer}
|
|
29
|
-
<ze-footer data-ws="grid; p: 0px; area: footer;">
|
|
30
|
-
{@render footer()}
|
|
31
|
-
</ze-footer>
|
|
32
|
-
{/if}
|
|
33
|
-
</ws-paper>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
const {
|
|
3
|
-
content,
|
|
4
|
-
overlay,
|
|
5
|
-
ws = "",
|
|
6
|
-
...rest
|
|
7
|
-
} = $props()
|
|
8
|
-
|
|
9
|
-
let popover = null
|
|
10
|
-
const show = () => popover.show()
|
|
11
|
-
const hide = () => popover.hide()
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<ws-popover data-ws={ws} {...rest} bind:this={popover}>
|
|
15
|
-
{@render content(show)}
|
|
16
|
-
<ze-popover-overlay slot="popover">
|
|
17
|
-
{@render overlay(hide)}
|
|
18
|
-
</ze-popover-overlay>
|
|
19
|
-
</ws-popover>
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { onMount } from "svelte"
|
|
3
|
-
|
|
4
|
-
import Button from "./button.svelte"
|
|
5
|
-
import Grid from "./grid.svelte"
|
|
6
|
-
import Paper from "./paper.svelte"
|
|
7
|
-
import Text from "./text.svelte"
|
|
8
|
-
import Titlebar from "./titlebar.svelte"
|
|
9
|
-
import ControlLabel from "./control-label.svelte"
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
message,
|
|
13
|
-
close,
|
|
14
|
-
color = "@primary",
|
|
15
|
-
okText = "OK",
|
|
16
|
-
cancelText = "Cancel",
|
|
17
|
-
title = "Prompt",
|
|
18
|
-
} = $props()
|
|
19
|
-
|
|
20
|
-
let value = $state("")
|
|
21
|
-
let input = $state(null)
|
|
22
|
-
onMount(() => input.focus())
|
|
23
|
-
const done = (e) => {
|
|
24
|
-
e.preventDefault()
|
|
25
|
-
close(value)
|
|
26
|
-
}
|
|
27
|
-
</script>
|
|
28
|
-
|
|
29
|
-
<Paper ws="@color: {color}; variant.outline;">
|
|
30
|
-
{#snippet header()}
|
|
31
|
-
<Titlebar ws="@color: {color};">
|
|
32
|
-
<Text header>
|
|
33
|
-
{title}
|
|
34
|
-
</Text>
|
|
35
|
-
</Titlebar>
|
|
36
|
-
{/snippet}
|
|
37
|
-
|
|
38
|
-
<Text ws="p: 8px;">
|
|
39
|
-
{message}
|
|
40
|
-
</Text>
|
|
41
|
-
|
|
42
|
-
<form onsubmit={done} data-ws="grid;">
|
|
43
|
-
<ControlLabel ws="@color: {color};">
|
|
44
|
-
<input type="text" bind:value bind:this={input} />
|
|
45
|
-
</ControlLabel>
|
|
46
|
-
</form>
|
|
47
|
-
|
|
48
|
-
{#snippet footer()}
|
|
49
|
-
<Grid ws="gr.cols: 1fr 1fr; p: 0px;">
|
|
50
|
-
<Button ws="@color: @error;" onclick={() => close(false)}>
|
|
51
|
-
{cancelText}
|
|
52
|
-
</Button>
|
|
53
|
-
<Button ws="@color: @success;" onclick={() => close(value)}>
|
|
54
|
-
{okText}
|
|
55
|
-
</Button>
|
|
56
|
-
</Grid>
|
|
57
|
-
{/snippet}
|
|
58
|
-
</Paper>
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
const urlChars = "[\\w\\-\\%\\(\\)\\.@!\\*\\^\\$]"
|
|
3
|
-
const urlPattern = (path, exact) => {
|
|
4
|
-
const regexSource = path.replace(
|
|
5
|
-
/:([\w\-]+)/g,
|
|
6
|
-
(_, name) => `\(?<${name}>${urlChars}+\)`
|
|
7
|
-
)
|
|
8
|
-
if (exact === true) {
|
|
9
|
-
return new RegExp(`(?<_path>^${regexSource})$`)
|
|
10
|
-
}
|
|
11
|
-
return new RegExp(`(?<_path>^${regexSource})(((?<=\\/)${urlChars})|\\/|$)`)
|
|
12
|
-
}
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<script>
|
|
16
|
-
import { getContext, setContext } from "svelte"
|
|
17
|
-
|
|
18
|
-
import { ctx, resolve, route } from "./routing.svelte.js"
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
path = "",
|
|
22
|
-
component = null,
|
|
23
|
-
props = {},
|
|
24
|
-
exact = false,
|
|
25
|
-
content,
|
|
26
|
-
children,
|
|
27
|
-
} = $props()
|
|
28
|
-
|
|
29
|
-
const parent = getContext(ctx.parent) ?? "/"
|
|
30
|
-
const fullPath = resolve(parent, path)
|
|
31
|
-
|
|
32
|
-
setContext(ctx.parent, fullPath)
|
|
33
|
-
const pattern = $derived(
|
|
34
|
-
urlPattern(fullPath, exact)
|
|
35
|
-
)
|
|
36
|
-
const match = $derived(
|
|
37
|
-
$route.match(pattern)
|
|
38
|
-
)
|
|
39
|
-
const routeParams = $derived(
|
|
40
|
-
Object.fromEntries(
|
|
41
|
-
Object.entries({ ...match?.groups }).map(
|
|
42
|
-
([key, value]) => [key, decodeURIComponent(value)]
|
|
43
|
-
)
|
|
44
|
-
)
|
|
45
|
-
)
|
|
46
|
-
const routeInfo = $derived({
|
|
47
|
-
params: routeParams,
|
|
48
|
-
match: routeParams._path,
|
|
49
|
-
route: $route,
|
|
50
|
-
})
|
|
51
|
-
const Content = $derived(component)
|
|
52
|
-
</script>
|
|
53
|
-
|
|
54
|
-
{#if match !== null}
|
|
55
|
-
{#key routeParams._path}
|
|
56
|
-
{#if Content !== null}
|
|
57
|
-
<Content {...props} {routeInfo} />
|
|
58
|
-
{:else}
|
|
59
|
-
{@render (content ?? children)?.(routeInfo, props)}
|
|
60
|
-
{/if}
|
|
61
|
-
{/key}
|
|
62
|
-
{/if}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { onMount, getContext } from "svelte"
|
|
2
|
-
import { writable, derived } from "svelte/store"
|
|
3
|
-
|
|
4
|
-
import { hash } from "../hash.js"
|
|
5
|
-
|
|
6
|
-
export const route = derived(
|
|
7
|
-
hash,
|
|
8
|
-
hash => {
|
|
9
|
-
if (hash.startsWith("/") === false) {
|
|
10
|
-
return `/${hash}`
|
|
11
|
-
}
|
|
12
|
-
return hash
|
|
13
|
-
}
|
|
14
|
-
)
|
|
15
|
-
route.set = (path) => {
|
|
16
|
-
hash.set(path)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const ctx = {
|
|
20
|
-
router: Symbol("Router Context"),
|
|
21
|
-
parent: Symbol("Route Parent"),
|
|
22
|
-
layout: Symbol("Layout Context"),
|
|
23
|
-
}
|
|
24
|
-
export const resolve = (base, part) => {
|
|
25
|
-
const prt = `/${part}`.replace(/^\/\//, "/")
|
|
26
|
-
if (prt === "/") {
|
|
27
|
-
return base
|
|
28
|
-
}
|
|
29
|
-
if (base === "/" || base === undefined) {
|
|
30
|
-
return prt
|
|
31
|
-
}
|
|
32
|
-
return `${base}${prt}`
|
|
33
|
-
}
|
|
34
|
-
export const relpath = (path) => {
|
|
35
|
-
const base = getContext(ctx.parent)
|
|
36
|
-
return `#${resolve(base, path)}`
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const emptyStack = Symbol("empty stack")
|
|
40
|
-
export const stackStore = (initial = stackStore.empty) => {
|
|
41
|
-
const stack = [writable(initial)]
|
|
42
|
-
const current = writable(initial)
|
|
43
|
-
let attachment = stack[0].subscribe(current.set)
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
subscribe: current.subscribe,
|
|
47
|
-
push: (initial) => {
|
|
48
|
-
const item = writable(initial)
|
|
49
|
-
onMount(() => {
|
|
50
|
-
stack.push(item)
|
|
51
|
-
attachment()
|
|
52
|
-
attachment = item.subscribe(current.set)
|
|
53
|
-
return () => {
|
|
54
|
-
stack.pop()
|
|
55
|
-
attachment()
|
|
56
|
-
attachment = stack[stack.length - 1].subscribe(current.set)
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
return item
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
stackStore.empty = emptyStack
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Paper from "./paper.svelte"
|
|
3
|
-
|
|
4
|
-
const {
|
|
5
|
-
ws,
|
|
6
|
-
children,
|
|
7
|
-
header,
|
|
8
|
-
footer,
|
|
9
|
-
content,
|
|
10
|
-
screenContent,
|
|
11
|
-
paperWS = "",
|
|
12
|
-
layoutWS = "",
|
|
13
|
-
...rest
|
|
14
|
-
} = $props()
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<ws-screen data-ws={ws} {...rest}>
|
|
18
|
-
{#if screenContent}
|
|
19
|
-
{@render screenContent()}
|
|
20
|
-
{:else}
|
|
21
|
-
<Paper
|
|
22
|
-
{header}
|
|
23
|
-
{footer}
|
|
24
|
-
{children}
|
|
25
|
-
{content}
|
|
26
|
-
{layoutWS}
|
|
27
|
-
ws={paperWS}
|
|
28
|
-
/>
|
|
29
|
-
{/if}
|
|
30
|
-
</ws-screen>
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
<script>
|
|
3
|
-
let {
|
|
4
|
-
value = $bindable(null),
|
|
5
|
-
ws,
|
|
6
|
-
options,
|
|
7
|
-
children,
|
|
8
|
-
selected,
|
|
9
|
-
...rest
|
|
10
|
-
} = $props()
|
|
11
|
-
|
|
12
|
-
const update = (evt) => {
|
|
13
|
-
value = evt.target.value
|
|
14
|
-
}
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
{#snippet optionList(options)}
|
|
18
|
-
{#each options as opt (opt)}
|
|
19
|
-
{#if opt.group !== undefined}
|
|
20
|
-
<ws-optgroup label={opt.group}>
|
|
21
|
-
{@render optionList(opt.items)}
|
|
22
|
-
</ws-optgroup>
|
|
23
|
-
{:else}
|
|
24
|
-
<ws-option value={opt.value}>{opt.label}</ws-option>
|
|
25
|
-
{/if}
|
|
26
|
-
{/each}
|
|
27
|
-
{/snippet}
|
|
28
|
-
|
|
29
|
-
<ws-select data-ws={ws} onchange={update} {...rest} {value}>
|
|
30
|
-
{#if selected}
|
|
31
|
-
<div slot="selected">
|
|
32
|
-
{@render selected()}
|
|
33
|
-
</div>
|
|
34
|
-
{/if}
|
|
35
|
-
{#if Array.isArray(options) === true}
|
|
36
|
-
{@render optionList(options)}
|
|
37
|
-
{:else}
|
|
38
|
-
{@render children?.()}
|
|
39
|
-
{/if}
|
|
40
|
-
</ws-select>
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import HexagonSpinner from "./hexagon-spinner.svelte"
|
|
3
|
-
import Flex from "./flex.svelte"
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
component: Component,
|
|
7
|
-
snippet,
|
|
8
|
-
loading,
|
|
9
|
-
error,
|
|
10
|
-
...rest
|
|
11
|
-
} = $props()
|
|
12
|
-
const wait = $derived(
|
|
13
|
-
Promise.all(
|
|
14
|
-
Object.entries(rest).map(
|
|
15
|
-
async (pair) => [pair[0], await pair[1]]
|
|
16
|
-
)
|
|
17
|
-
)
|
|
18
|
-
)
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
{#await wait}
|
|
22
|
-
{#if loading}
|
|
23
|
-
{@render loading()}
|
|
24
|
-
{:else}
|
|
25
|
-
<Flex ws="fl.cn;">
|
|
26
|
-
<HexagonSpinner ws="@size: 48px;" />
|
|
27
|
-
<span>Loading</span>
|
|
28
|
-
</Flex>
|
|
29
|
-
{/if}
|
|
30
|
-
{:then entries}
|
|
31
|
-
{#if Component}
|
|
32
|
-
<Component {...Object.fromEntries(entries)} />
|
|
33
|
-
{:else}
|
|
34
|
-
{@render snippet(Object.fromEntries(entries))}
|
|
35
|
-
{/if}
|
|
36
|
-
{:catch loadError}
|
|
37
|
-
{#if error}
|
|
38
|
-
{@render error(loadError)}
|
|
39
|
-
{:else}
|
|
40
|
-
<Flex ws="b: 1px solid red; fl.cn; p: 8px;">
|
|
41
|
-
{loadError}
|
|
42
|
-
</Flex>
|
|
43
|
-
{/if}
|
|
44
|
-
{/await}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
const {
|
|
3
|
-
data,
|
|
4
|
-
row = Row,
|
|
5
|
-
header = Header,
|
|
6
|
-
ws = "",
|
|
7
|
-
sticky = false
|
|
8
|
-
} = $props()
|
|
9
|
-
|
|
10
|
-
const keys = $derived(
|
|
11
|
-
Object.keys(data?.[0] ?? {})
|
|
12
|
-
)
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
{#snippet Header(keys)}
|
|
16
|
-
<tr>
|
|
17
|
-
{#each keys as key}
|
|
18
|
-
<th>{key}</th>
|
|
19
|
-
{/each}
|
|
20
|
-
</tr>
|
|
21
|
-
{/snippet}
|
|
22
|
-
{#snippet Row(item, keys)}
|
|
23
|
-
<tr>
|
|
24
|
-
{#each keys as key}
|
|
25
|
-
<td>{item[key]}</td>
|
|
26
|
-
{/each}
|
|
27
|
-
</tr>
|
|
28
|
-
{/snippet}
|
|
29
|
-
|
|
30
|
-
<table data-ws={ws} sticky-header={sticky || null}>
|
|
31
|
-
<thead>
|
|
32
|
-
{#if data?.length > 0}
|
|
33
|
-
{@render header(keys)}
|
|
34
|
-
{:else}
|
|
35
|
-
<tr>
|
|
36
|
-
<th>N/A</th>
|
|
37
|
-
</tr>
|
|
38
|
-
{/if}
|
|
39
|
-
</thead>
|
|
40
|
-
<tbody>
|
|
41
|
-
{#each data as item, rowNum}
|
|
42
|
-
{@render row(item, keys, rowNum)}
|
|
43
|
-
{:else}
|
|
44
|
-
<tr>
|
|
45
|
-
<td>No Items</td>
|
|
46
|
-
</tr>
|
|
47
|
-
{/each}
|
|
48
|
-
</tbody>
|
|
49
|
-
</table>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
const sizes = {
|
|
3
|
-
title: "title",
|
|
4
|
-
info: "info",
|
|
5
|
-
header: "header",
|
|
6
|
-
subtitle: "subtitle",
|
|
7
|
-
}
|
|
8
|
-
const {
|
|
9
|
-
ws,
|
|
10
|
-
children,
|
|
11
|
-
size,
|
|
12
|
-
notif,
|
|
13
|
-
...rest
|
|
14
|
-
} = $props()
|
|
15
|
-
const sizeProp = $derived(
|
|
16
|
-
sizes[size]
|
|
17
|
-
)
|
|
18
|
-
const processed = $derived({
|
|
19
|
-
[sizeProp]: "",
|
|
20
|
-
"notif-text": (notif === true) ? "" : undefined,
|
|
21
|
-
})
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<ws-text data-ws={ws} {...rest} {...processed}>
|
|
25
|
-
{@render children?.()}
|
|
26
|
-
</ws-text>
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { writable } from "svelte/store"
|
|
3
|
-
|
|
4
|
-
import { stackStore } from "./routing.svelte.js"
|
|
5
|
-
|
|
6
|
-
const stack = stackStore()
|
|
7
|
-
|
|
8
|
-
const updateTitle = (format, data) => {
|
|
9
|
-
if (format === null || data === stackStore.empty) {
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
document.title = format(data)
|
|
14
|
-
}
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<script>
|
|
18
|
-
import { onMount } from "svelte"
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
data = "",
|
|
22
|
-
format = null,
|
|
23
|
-
} = $props()
|
|
24
|
-
|
|
25
|
-
stack.push(data)
|
|
26
|
-
|
|
27
|
-
$effect(() => updateTitle(format, $stack))
|
|
28
|
-
</script>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
const {
|
|
3
|
-
ws,
|
|
4
|
-
children,
|
|
5
|
-
menu,
|
|
6
|
-
action,
|
|
7
|
-
...rest
|
|
8
|
-
} = $props()
|
|
9
|
-
</script>
|
|
10
|
-
|
|
11
|
-
<ws-titlebar data-ws={ws} {...rest}>
|
|
12
|
-
{#if menu}
|
|
13
|
-
<ze-menu data-ws="grid; p: 0px; area: menu;">
|
|
14
|
-
{@render menu()}
|
|
15
|
-
</ze-menu>
|
|
16
|
-
{/if}
|
|
17
|
-
{@render children?.()}
|
|
18
|
-
{#if action}
|
|
19
|
-
<ze-action data-ws="grid; p: 0px; area: action;">
|
|
20
|
-
{@render action()}
|
|
21
|
-
</ze-action>
|
|
22
|
-
{/if}
|
|
23
|
-
</ws-titlebar>
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
const stacks = $state({
|
|
3
|
-
"top-left": [],
|
|
4
|
-
"top-center": [],
|
|
5
|
-
"top-right": [],
|
|
6
|
-
"center-right": [],
|
|
7
|
-
"center-left": [],
|
|
8
|
-
"bottom-left": [],
|
|
9
|
-
"bottom-center": [],
|
|
10
|
-
"bottom-right": [],
|
|
11
|
-
})
|
|
12
|
-
const notifs = $derived(
|
|
13
|
-
Object.entries(stacks)
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
export const showToast = (options) => {
|
|
17
|
-
const {
|
|
18
|
-
snippet = info,
|
|
19
|
-
pos = "top-center",
|
|
20
|
-
...opts
|
|
21
|
-
} = options
|
|
22
|
-
const id = `${Math.random()}:${Date.now()}`
|
|
23
|
-
const hide = () => {
|
|
24
|
-
stacks[pos] = stacks[pos].filter(
|
|
25
|
-
(notif) => notif[2] !== id
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
stacks[pos].unshift([
|
|
29
|
-
snippet,
|
|
30
|
-
{ ...opts, hide },
|
|
31
|
-
id
|
|
32
|
-
])
|
|
33
|
-
setTimeout(hide, opts.time ?? 5000)
|
|
34
|
-
}
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
|
-
<script>
|
|
38
|
-
import { fade } from "svelte/transition"
|
|
39
|
-
|
|
40
|
-
import Icon from "./icon.svelte"
|
|
41
|
-
import Text from "./text.svelte"
|
|
42
|
-
import Toast from "./toast.svelte"
|
|
43
|
-
</script>
|
|
44
|
-
|
|
45
|
-
{#snippet info(options)}
|
|
46
|
-
<div transition:fade>
|
|
47
|
-
<Toast ws="@color: {options.color ?? "@info"}; {options.ws ?? ""}">
|
|
48
|
-
<Icon name={options.icon ?? "info-hexagon"} />
|
|
49
|
-
<Text notif>{options.message}</Text>
|
|
50
|
-
</Toast>
|
|
51
|
-
</div>
|
|
52
|
-
{/snippet}
|
|
53
|
-
|
|
54
|
-
{#each notifs as [pos, stack] (pos)}
|
|
55
|
-
<ws-toaster {pos}>
|
|
56
|
-
{#each stack as [notif, options, id] (id)}
|
|
57
|
-
{@render notif(options)}
|
|
58
|
-
{/each}
|
|
59
|
-
</ws-toaster>
|
|
60
|
-
{/each}
|
package/src/handler$.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
Wraps a handler function for easy reuse.
|
|
3
|
-
|
|
4
|
-
@param {Function} func The handler function to wrap
|
|
5
|
-
*/
|
|
6
|
-
const handler$ = (func) =>
|
|
7
|
-
(...args) =>
|
|
8
|
-
(_, ...extra) => func(...args, ...extra)
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
Wraps a handler function for easy reuse, and doesn't throw away the event arg
|
|
12
|
-
passed by events firing.
|
|
13
|
-
|
|
14
|
-
@param {Function} func The handler function to wrap
|
|
15
|
-
*/
|
|
16
|
-
const eventHandler$ = (func) =>
|
|
17
|
-
(...args) =>
|
|
18
|
-
(...extra) => func(...extra, ...args)
|
|
19
|
-
|
|
20
|
-
export { handler$, eventHandler$ }
|
package/src/hash.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { readable } from "svelte/store"
|
|
2
|
-
|
|
3
|
-
export const hash = readable(
|
|
4
|
-
location.hash.slice(1),
|
|
5
|
-
(set) => {
|
|
6
|
-
window.addEventListener(
|
|
7
|
-
"popstate",
|
|
8
|
-
() => set(location.hash.slice(1))
|
|
9
|
-
)
|
|
10
|
-
}
|
|
11
|
-
)
|
|
12
|
-
hash.set = (value) => {
|
|
13
|
-
location.hash = value
|
|
14
|
-
}
|