@axel669/zephyr 0.5.5 → 1.0.0-beta.0
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 +48 -42
- package/readme.md +0 -44
- package/src/changed.svelte.js +23 -0
- package/src/component/adorn.svelte +9 -0
- package/src/component/alert.svelte +32 -0
- package/src/component/application.svelte +17 -0
- package/src/component/async-button.svelte +53 -0
- package/src/component/avatar.svelte +15 -0
- package/src/component/badge.svelte +7 -0
- package/src/component/button.svelte +7 -0
- package/src/component/chip.svelte +10 -0
- package/src/component/circle-spinner.svelte +6 -0
- package/src/component/confirm.svelte +40 -0
- package/src/component/control-label.svelte +41 -0
- package/src/component/data-table.svelte +227 -0
- package/src/component/details.svelte +22 -0
- package/src/component/dialog-element.svelte +35 -0
- package/src/component/dialog.svelte +43 -0
- package/src/component/drawer.svelte +20 -0
- package/src/component/flex.svelte +7 -0
- package/src/component/grid.svelte +7 -0
- package/src/component/hexagon-spinner.svelte +6 -0
- package/src/component/icon.svelte +7 -0
- package/src/component/link.svelte +11 -0
- package/src/component/modal.svelte +32 -0
- package/src/component/paper.svelte +33 -0
- package/src/component/popover.svelte +19 -0
- package/src/component/progress.svelte +6 -0
- package/src/component/prompt.svelte +58 -0
- package/src/{routing → component}/routing.svelte.js +4 -6
- package/src/component/screen.svelte +30 -0
- package/src/component/select.svelte +40 -0
- package/src/{async → component}/suspend.svelte +14 -8
- package/src/component/table.svelte +49 -0
- package/src/component/tabs.svelte +2 -0
- package/src/component/text.svelte +26 -0
- package/src/component/titlebar.svelte +23 -0
- package/src/component/toast.svelte +7 -0
- package/src/component/toaster.svelte +60 -0
- package/src/component/toggle-label.svelte +11 -0
- package/src/component/tooltip.svelte +11 -0
- package/src/custom-macros.js +11 -9
- package/src/main.js +47 -0
- package/src/ws.js +10 -0
- package/src/async/button.svelte +0 -41
- package/src/changed.js +0 -10
- package/src/composed/data-table/th.svelte +0 -61
- package/src/composed/data-table.svelte +0 -174
- package/src/composed/entry-button.svelte +0 -29
- package/src/composed/form.svelte +0 -60
- package/src/composed/table-functions.js +0 -15
- package/src/control/button.svelte +0 -39
- package/src/control/input.svelte +0 -103
- package/src/control/label.svelte +0 -49
- package/src/control/link.svelte +0 -47
- package/src/control/radio-group.svelte +0 -24
- package/src/control/select.svelte +0 -69
- package/src/control/tabs.svelte +0 -35
- package/src/control/toggle.svelte +0 -60
- package/src/data-display/avatar.svelte +0 -29
- package/src/data-display/badge.svelte +0 -16
- package/src/data-display/chip.svelte +0 -38
- package/src/data-display/details.svelte +0 -33
- package/src/data-display/popover.svelte +0 -28
- package/src/data-display/progress.svelte +0 -25
- package/src/data-display/table.svelte +0 -50
- package/src/data-display/tooltip.svelte +0 -19
- package/src/dialogs/alert.svelte +0 -41
- package/src/dialogs/confirm.svelte +0 -52
- package/src/dialogs/prompt.svelte +0 -67
- package/src/info/element-toaster.svelte +0 -110
- package/src/info/icon.svelte +0 -9
- package/src/info/titlebar.svelte +0 -40
- package/src/info/toast.svelte +0 -35
- package/src/info/toaster/message.svelte +0 -42
- package/src/info/toaster.svelte +0 -72
- package/src/layout/dialog.svelte +0 -25
- package/src/layout/drawer.svelte +0 -70
- package/src/layout/flex.svelte +0 -24
- package/src/layout/grid.svelte +0 -32
- package/src/layout/modal.svelte +0 -71
- package/src/layout/paper.svelte +0 -54
- package/src/layout/screen.svelte +0 -38
- package/src/spinner/circle-spinner.svelte +0 -18
- package/src/spinner/hexagon-spinner.svelte +0 -18
- package/src/text.svelte +0 -16
- package/src/wsx.js +0 -29
- /package/src/{routing → component}/route.svelte +0 -0
- /package/src/{routing → component}/title.svelte +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount } from "svelte"
|
|
3
|
+
import Modal from "./modal.svelte"
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
options,
|
|
7
|
+
dialog,
|
|
8
|
+
} = $props()
|
|
9
|
+
|
|
10
|
+
let open = $state(false)
|
|
11
|
+
|
|
12
|
+
onMount(() => open = true)
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
tIn,
|
|
16
|
+
tOut,
|
|
17
|
+
close,
|
|
18
|
+
ws = "",
|
|
19
|
+
persistent,
|
|
20
|
+
...opts
|
|
21
|
+
} = options
|
|
22
|
+
const dialogClose = (value) => {
|
|
23
|
+
open = false
|
|
24
|
+
setTimeout(
|
|
25
|
+
() => close(value),
|
|
26
|
+
tOut.duration
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<Modal bind:open inTime={0} outTime={tOut.duration} onclose={() => dialogClose(null)} {persistent}>
|
|
32
|
+
<ws-dialog in:tIn.func={tIn} out:tOut.func={tOut} data-ws={ws} tabindex="-1">
|
|
33
|
+
{@render dialog({ ...opts, close: dialogClose })}
|
|
34
|
+
</ws-dialog>
|
|
35
|
+
</Modal>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { fade } from "svelte/transition"
|
|
3
|
+
|
|
4
|
+
import DialogElement from "./dialog-element.svelte"
|
|
5
|
+
let stack = $state([])
|
|
6
|
+
|
|
7
|
+
const defTf = {
|
|
8
|
+
duration: 250,
|
|
9
|
+
func: fade
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const showDialog = (options) => new Promise(
|
|
13
|
+
(resolve) => {
|
|
14
|
+
const {
|
|
15
|
+
dialog = null,
|
|
16
|
+
transition = defTf,
|
|
17
|
+
transitionIn = transition,
|
|
18
|
+
transitionOut = transition,
|
|
19
|
+
...opts
|
|
20
|
+
} = options
|
|
21
|
+
if (dialog === null) {
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const id = `${Math.random()}:${Date.now()}`
|
|
26
|
+
const close = (value) => {
|
|
27
|
+
stack = stack.filter(
|
|
28
|
+
(dia) => dia[2] !== id
|
|
29
|
+
)
|
|
30
|
+
resolve(value)
|
|
31
|
+
}
|
|
32
|
+
stack.push([
|
|
33
|
+
dialog,
|
|
34
|
+
{ ...opts, tIn: transitionIn, tOut: transitionOut, close },
|
|
35
|
+
id
|
|
36
|
+
])
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
{#each stack as [dialog, options, id] (id)}
|
|
42
|
+
<DialogElement {options} {dialog} />
|
|
43
|
+
{/each}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { fly } from "svelte/transition"
|
|
3
|
+
import Modal from "./modal.svelte"
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
open = $bindable(false),
|
|
7
|
+
ws = "",
|
|
8
|
+
children,
|
|
9
|
+
onclose,
|
|
10
|
+
animTime = 250,
|
|
11
|
+
tr = fly,
|
|
12
|
+
trArgs = { x: "-100%" }
|
|
13
|
+
} = $props()
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Modal bind:open {onclose} {animTime}>
|
|
17
|
+
<ws-drawer transition:tr={{ ...trArgs, duration: animTime }} data-ws={ws}>
|
|
18
|
+
{@render children?.()}
|
|
19
|
+
</ws-drawer>
|
|
20
|
+
</Modal>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
let {
|
|
3
|
+
open = $bindable(false),
|
|
4
|
+
children,
|
|
5
|
+
ws = "",
|
|
6
|
+
onclose,
|
|
7
|
+
animTime,
|
|
8
|
+
inTime = animTime,
|
|
9
|
+
outTime = animTime,
|
|
10
|
+
persistent = false,
|
|
11
|
+
} = $props()
|
|
12
|
+
|
|
13
|
+
const vis = (node, opts) => {
|
|
14
|
+
const { duration } = opts
|
|
15
|
+
return {
|
|
16
|
+
duration,
|
|
17
|
+
css: (t, u) => "visibility: visible;"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const close = (evt) => {
|
|
22
|
+
open = false
|
|
23
|
+
onclose?.(evt)
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
{#if open === true}
|
|
28
|
+
<ws-modal open data-ws={ws} onclose={close} {persistent}
|
|
29
|
+
in:vis={{ duration: inTime }} out:vis={{ duration: outTime }}>
|
|
30
|
+
{@render children?.()}
|
|
31
|
+
</ws-modal>
|
|
32
|
+
{/if}
|
|
@@ -0,0 +1,33 @@
|
|
|
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>
|
|
@@ -0,0 +1,19 @@
|
|
|
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>
|
|
@@ -0,0 +1,58 @@
|
|
|
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>
|
|
@@ -22,16 +22,14 @@ export const ctx = {
|
|
|
22
22
|
layout: Symbol("Layout Context"),
|
|
23
23
|
}
|
|
24
24
|
export const resolve = (base, part) => {
|
|
25
|
-
|
|
25
|
+
const prt = `/${part}`.replace(/^\/\//, "/")
|
|
26
|
+
if (prt === "/") {
|
|
26
27
|
return base
|
|
27
28
|
}
|
|
28
29
|
if (base === "/" || base === undefined) {
|
|
29
|
-
return
|
|
30
|
+
return prt
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
return `${base}${part}`
|
|
33
|
-
}
|
|
34
|
-
return `${base}/${part}`
|
|
32
|
+
return `${base}${prt}`
|
|
35
33
|
}
|
|
36
34
|
export const relpath = (path) => {
|
|
37
35
|
const base = getContext(ctx.parent)
|
|
@@ -0,0 +1,30 @@
|
|
|
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>
|
|
@@ -0,0 +1,40 @@
|
|
|
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,8 +1,10 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import
|
|
2
|
+
import HexagonSpinner from "./hexagon-spinner.svelte"
|
|
3
|
+
import Flex from "./flex.svelte"
|
|
3
4
|
|
|
4
5
|
const {
|
|
5
|
-
|
|
6
|
+
component: Component,
|
|
7
|
+
snippet,
|
|
6
8
|
loading,
|
|
7
9
|
error,
|
|
8
10
|
...rest
|
|
@@ -20,19 +22,23 @@
|
|
|
20
22
|
{#if loading}
|
|
21
23
|
{@render loading()}
|
|
22
24
|
{:else}
|
|
23
|
-
<
|
|
24
|
-
<
|
|
25
|
+
<Flex ws="fl.cn;">
|
|
26
|
+
<HexagonSpinner ws="@size: 48px;" />
|
|
25
27
|
<span>Loading</span>
|
|
26
|
-
</
|
|
28
|
+
</Flex>
|
|
27
29
|
{/if}
|
|
28
30
|
{:then entries}
|
|
29
|
-
|
|
31
|
+
{#if Component}
|
|
32
|
+
<Component {...Object.fromEntries(entries)} />
|
|
33
|
+
{:else}
|
|
34
|
+
{@render snippet(Object.fromEntries(entries))}
|
|
35
|
+
{/if}
|
|
30
36
|
{:catch loadError}
|
|
31
37
|
{#if error}
|
|
32
38
|
{@render error(loadError)}
|
|
33
39
|
{:else}
|
|
34
|
-
<
|
|
40
|
+
<Flex ws="b: 1px solid red; fl.cn; p: 8px;">
|
|
35
41
|
{loadError}
|
|
36
|
-
</
|
|
42
|
+
</Flex>
|
|
37
43
|
{/if}
|
|
38
44
|
{/await}
|
|
@@ -0,0 +1,49 @@
|
|
|
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>
|
|
@@ -0,0 +1,26 @@
|
|
|
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>
|
|
@@ -0,0 +1,23 @@
|
|
|
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>
|
|
@@ -0,0 +1,60 @@
|
|
|
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/custom-macros.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
macros
|
|
5
|
-
.ws-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { ws } from "./ws.js"
|
|
2
|
+
|
|
3
|
+
// const head = document.head
|
|
4
|
+
// const macros = document.createElement("style")
|
|
5
|
+
// macros.setAttribute("ws-root", "")
|
|
6
|
+
// macros.innerHTML = `
|
|
7
|
+
// .ws-style {
|
|
8
|
+
// --con: "contain: {$}";
|
|
9
|
+
// }
|
|
10
|
+
// `
|
|
11
|
+
// head.append(macros)
|