@axel669/zephyr 0.3.8 → 0.4.5
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 +40 -33
- package/src/async/button.svelte +16 -8
- package/src/composed/data-table/th.svelte +2 -2
- package/src/composed/data-table.svelte +4 -3
- package/src/composed/form.svelte +60 -0
- package/src/composed/table-functions.js +3 -1
- package/src/composed/toast/message.svelte +15 -38
- package/src/control/input.svelte +21 -41
- package/src/control/label.svelte +1 -1
- package/src/control/link.svelte +1 -1
- package/src/control/radio-group.svelte +21 -0
- package/src/control/select.svelte +5 -5
- package/src/control/tabs.svelte +9 -21
- package/src/control/toggle.svelte +2 -2
- package/src/data-display/avatar.svelte +4 -1
- package/src/data-display/badge.svelte +1 -1
- package/src/data-display/chip.svelte +1 -1
- package/src/data-display/popover.svelte +1 -1
- package/src/data-display/progress.svelte +2 -2
- package/src/data-display/table.svelte +1 -1
- package/src/dialogs/confirm.svelte +3 -3
- package/src/hash.js +3 -3
- package/src/index.mjs +11 -1
- package/src/info/notification.svelte +13 -1
- package/src/info/titlebar.svelte +21 -5
- package/src/layout/dialog.svelte +1 -1
- package/src/layout/drawer.svelte +4 -4
- package/src/layout/flex.svelte +0 -4
- package/src/layout/grid.svelte +4 -4
- package/src/layout/paper.svelte +13 -4
- package/src/routing/route.svelte +48 -0
- package/src/routing/routing.js +62 -0
- package/src/routing/title.svelte +26 -0
- package/src/spinner/circle-spinner.svelte +2 -1
- package/src/spinner/hexagon-spinner.svelte +2 -1
- package/src/text.svelte +2 -4
- package/src/wsx.mjs +9 -8
- package/src/async/button.md +0 -27
- package/src/async/load-zone.md +0 -42
- package/src/composed/data-table/th.md +0 -21
- package/src/composed/data-table.md +0 -86
- package/src/composed/entry-button.md +0 -44
- package/src/composed/toast.md +0 -45
- package/src/control/button.md +0 -41
- package/src/control/input.md +0 -87
- package/src/control/label.md +0 -48
- package/src/control/link.md +0 -50
- package/src/control/radio.md +0 -58
- package/src/control/radio.svelte +0 -28
- package/src/control/select.md +0 -70
- package/src/control/tabs.md +0 -47
- package/src/control/toggle.md +0 -61
- package/src/data-display/avatar.md +0 -36
- package/src/data-display/badge.md +0 -30
- package/src/data-display/chip.md +0 -36
- package/src/data-display/details.md +0 -42
- package/src/data-display/popover.md +0 -32
- package/src/data-display/progress.md +0 -46
- package/src/data-display/table.md +0 -59
- package/src/data-display/tooltip.md +0 -29
- package/src/dialogs/alert.md +0 -42
- package/src/dialogs/confirm.md +0 -56
- package/src/functions.md +0 -108
- package/src/info/icon.md +0 -21
- package/src/info/notification.md +0 -36
- package/src/info/titlebar.md +0 -75
- package/src/info/toaster.md +0 -26
- package/src/layout/dialog.md +0 -43
- package/src/layout/drawer.md +0 -70
- package/src/layout/flex.md +0 -43
- package/src/layout/grid.md +0 -61
- package/src/layout/modal.md +0 -50
- package/src/layout/paper.md +0 -94
- package/src/layout/screen.md +0 -33
- package/src/spinner/spinners.md +0 -22
- package/src/text.md +0 -34
package/src/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { default as Button } from "./control/button.svelte"
|
|
2
2
|
export { default as Input } from "./control/input.svelte"
|
|
3
|
+
export { default as Label } from "./control/label.svelte"
|
|
3
4
|
export { default as Link } from "./control/link.svelte"
|
|
4
|
-
export { default as
|
|
5
|
+
export { default as RadioGroup } from "./control/radio-group.svelte"
|
|
5
6
|
export { default as Select } from "./control/select.svelte"
|
|
6
7
|
export { default as Tabs } from "./control/tabs.svelte"
|
|
7
8
|
export { default as Toggle } from "./control/toggle.svelte"
|
|
@@ -40,14 +41,23 @@ export { default as Confirm } from "./dialogs/confirm.svelte"
|
|
|
40
41
|
export { default as DataTable } from "./composed/data-table.svelte"
|
|
41
42
|
export { default as TH } from "./composed/data-table/th.svelte"
|
|
42
43
|
export { default as EntryButton } from "./composed/entry-button.svelte"
|
|
44
|
+
export { default as Form } from "./composed/form.svelte"
|
|
43
45
|
export { default as Toast } from "./composed/toast.svelte"
|
|
44
46
|
|
|
45
47
|
export { default as AsyncButton } from "./async/button.svelte"
|
|
46
48
|
export { default as LoadZone } from "./async/load-zone.svelte"
|
|
47
49
|
|
|
50
|
+
export { default as Route } from "./routing/route.svelte"
|
|
51
|
+
export { default as Title } from "./routing/title.svelte"
|
|
52
|
+
|
|
48
53
|
export { default as wsx } from "./wsx.mjs"
|
|
49
54
|
|
|
50
55
|
export { hash } from "./hash.js"
|
|
51
56
|
|
|
57
|
+
export {
|
|
58
|
+
route,
|
|
59
|
+
stackStore,
|
|
60
|
+
relpath,
|
|
61
|
+
} from "./routing/routing.js"
|
|
52
62
|
export * from "./handler$.mjs"
|
|
53
63
|
export * from "./composed/table-functions.js"
|
|
@@ -12,5 +12,17 @@
|
|
|
12
12
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
13
13
|
<!-- svelte-ignore a11y-interactive-supports-focus -->
|
|
14
14
|
<ws-notification use:wsx={wind} on:click role="button">
|
|
15
|
-
|
|
15
|
+
{#if $$slots.start}
|
|
16
|
+
<div ws-x="[$start] [grid]">
|
|
17
|
+
<slot name="start" />
|
|
18
|
+
</div>
|
|
19
|
+
{/if}
|
|
20
|
+
<div ws-x="[$notif-text]">
|
|
21
|
+
<slot />
|
|
22
|
+
</div>
|
|
23
|
+
{#if $$slots.end}
|
|
24
|
+
<div ws-x="[$end] [grid]">
|
|
25
|
+
<slot name="end" />
|
|
26
|
+
</div>
|
|
27
|
+
{/if}
|
|
16
28
|
</ws-notification>
|
package/src/info/titlebar.svelte
CHANGED
|
@@ -4,15 +4,31 @@
|
|
|
4
4
|
export let color
|
|
5
5
|
export let fill = false
|
|
6
6
|
|
|
7
|
-
$:
|
|
7
|
+
$: titleProps = {
|
|
8
8
|
"$color": color,
|
|
9
9
|
"$fill": fill,
|
|
10
|
-
|
|
10
|
+
$title: true,
|
|
11
|
+
}
|
|
12
|
+
$: wind = {
|
|
13
|
+
...$$restProps,
|
|
11
14
|
}
|
|
12
15
|
</script>
|
|
13
16
|
|
|
14
17
|
<ws-titlebar use:wsx={wind}>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
{#if $$slots.title}
|
|
19
|
+
<div use:wsx={titleProps}>
|
|
20
|
+
<slot name="title" />
|
|
21
|
+
</div>
|
|
22
|
+
{/if}
|
|
23
|
+
|
|
24
|
+
{#if $$slots.menu}
|
|
25
|
+
<div ws-x="[$menu] [grid] [p 0px]">
|
|
26
|
+
<slot name="menu" />
|
|
27
|
+
</div>
|
|
28
|
+
{/if}
|
|
29
|
+
{#if $$slots.action}
|
|
30
|
+
<div ws-x="[$action] [grid] [p 0px]">
|
|
31
|
+
<slot name="action" />
|
|
32
|
+
</div>
|
|
33
|
+
{/if}
|
|
18
34
|
</ws-titlebar>
|
package/src/layout/dialog.svelte
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
18
18
|
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
|
19
|
-
<wind-wrapper transition:trick ws-x="
|
|
19
|
+
<wind-wrapper transition:trick ws-x="@@dialog [grid]" on:click|stopPropagation
|
|
20
20
|
role="dialog">
|
|
21
21
|
<Paper {...$$props}>
|
|
22
22
|
<slot name="header" slot="header" />
|
package/src/layout/drawer.svelte
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
<script context="module">
|
|
4
4
|
const defs = {
|
|
5
5
|
select: {
|
|
6
|
-
"
|
|
6
|
+
"@@select": true,
|
|
7
7
|
"w.min": "35vw",
|
|
8
8
|
grid: true,
|
|
9
9
|
over: "hidden"
|
|
10
10
|
},
|
|
11
11
|
menu: {
|
|
12
|
-
"
|
|
12
|
+
"@@menu": true,
|
|
13
13
|
},
|
|
14
14
|
action: {
|
|
15
|
-
"
|
|
15
|
+
"@@action": true,
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
</script>
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
<!-- svelte-ignore a11y-interactive-supports-focus -->
|
|
42
42
|
<wind-drawer-container use:wsx={container} on:click|stopPropagation
|
|
43
43
|
role="menubar" transition:trick>
|
|
44
|
-
<Paper {...$$restProps}>
|
|
44
|
+
<Paper r="0px" {...$$restProps}>
|
|
45
45
|
<slot name="header" slot="header" />
|
|
46
46
|
<slot />
|
|
47
47
|
<slot name="footer" slot="footer" />
|
package/src/layout/flex.svelte
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
import wsx from "../wsx.mjs"
|
|
5
5
|
|
|
6
6
|
export let direction = false
|
|
7
|
-
export let pad = false
|
|
8
|
-
export let gap = false
|
|
9
7
|
export let cross = "stretch"
|
|
10
8
|
export let main = "start"
|
|
11
9
|
export let scrollable = false
|
|
@@ -14,8 +12,6 @@
|
|
|
14
12
|
"fl.dir": direction,
|
|
15
13
|
"fl.cross": cross,
|
|
16
14
|
"fl.main": main,
|
|
17
|
-
p: pad,
|
|
18
|
-
gap: gap,
|
|
19
15
|
over: (scrollable === true) ? "auto" : null,
|
|
20
16
|
...$$restProps
|
|
21
17
|
}
|
package/src/layout/grid.svelte
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
import wsx from "../wsx.mjs"
|
|
5
5
|
|
|
6
6
|
export let direction = false
|
|
7
|
-
export let pad = false
|
|
8
|
-
export let gap = false
|
|
9
7
|
export let cols = null
|
|
10
8
|
export let rows = null
|
|
11
9
|
export let autoCol = false
|
|
12
10
|
export let autoRow = false
|
|
11
|
+
export let colsFit = false
|
|
12
|
+
export let colsFill = false
|
|
13
13
|
export let scrollable = false
|
|
14
14
|
|
|
15
15
|
$: wind = {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"gr.rows": rows?.join?.(" ") ?? rows ?? false,
|
|
19
19
|
"gr.cols.a": autoCol,
|
|
20
20
|
"gr.rows.a": autoRow,
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
"gr.cols-fit": colsFit,
|
|
22
|
+
"gr.cols-fill": colsFill,
|
|
23
23
|
over: (scrollable === true) ? "auto" : null,
|
|
24
24
|
...$$restProps
|
|
25
25
|
}
|
package/src/layout/paper.svelte
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
$: layoutProps = {
|
|
26
26
|
over: scrollable ? "auto" : false,
|
|
27
|
+
$content: true,
|
|
27
28
|
...props.layout,
|
|
28
29
|
}
|
|
29
30
|
$: wind = {
|
|
@@ -35,13 +36,21 @@
|
|
|
35
36
|
</script>
|
|
36
37
|
|
|
37
38
|
<ws-paper use:wsx={wind}>
|
|
38
|
-
|
|
39
|
+
{#if $$slots.header}
|
|
40
|
+
<div ws-x="[$header] [grid] [p 0px]">
|
|
41
|
+
<slot name="header" />
|
|
42
|
+
</div>
|
|
43
|
+
{/if}
|
|
39
44
|
{#if $$slots.content}
|
|
40
|
-
<slot name="content"
|
|
45
|
+
<slot name="content" />
|
|
41
46
|
{:else}
|
|
42
|
-
<svelte:component this={layout} {...layoutProps}
|
|
47
|
+
<svelte:component this={layout} {...layoutProps}>
|
|
43
48
|
<slot />
|
|
44
49
|
</svelte:component>
|
|
45
50
|
{/if}
|
|
46
|
-
|
|
51
|
+
{#if $$slots.footer}
|
|
52
|
+
<div ws-x="[$footer] [grid] [p 0px]">
|
|
53
|
+
<slot name="footer" />
|
|
54
|
+
</div>
|
|
55
|
+
{/if}
|
|
47
56
|
</ws-paper>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script context="module">
|
|
2
|
+
const urlPattern = (path, exact) => {
|
|
3
|
+
const regexSource = path.replace(
|
|
4
|
+
/:([\w\-]+)/g,
|
|
5
|
+
(_, name) => `\(?<${name}>[\\w\\-\\%]+\)`
|
|
6
|
+
)
|
|
7
|
+
if (exact === true) {
|
|
8
|
+
return new RegExp(`(?<_path>^${regexSource})$`)
|
|
9
|
+
}
|
|
10
|
+
return new RegExp(`(?<_path>^${regexSource})(((?<=\\/)[\\w\\-\\%])|\\/|$)`)
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
import { getContext, setContext } from "svelte"
|
|
16
|
+
|
|
17
|
+
import { ctx, resolve, route } from "./routing.js"
|
|
18
|
+
|
|
19
|
+
export let path = ""
|
|
20
|
+
export let component = null
|
|
21
|
+
export let props = {}
|
|
22
|
+
export let exact = false
|
|
23
|
+
|
|
24
|
+
const parent = getContext(ctx.parent) ?? "/"
|
|
25
|
+
const fullPath = resolve(parent, path)
|
|
26
|
+
|
|
27
|
+
setContext(ctx.parent, fullPath)
|
|
28
|
+
$: pattern = urlPattern(fullPath, exact)
|
|
29
|
+
$: match = $route.match(pattern)
|
|
30
|
+
$: routeParams = Object.fromEntries(
|
|
31
|
+
Object.entries({ ...match?.groups }).map(
|
|
32
|
+
([key, value]) => [key, decodeURIComponent(value)]
|
|
33
|
+
)
|
|
34
|
+
)
|
|
35
|
+
$: routeInfo = {
|
|
36
|
+
params: routeParams,
|
|
37
|
+
match: routeParams._path,
|
|
38
|
+
route: $route,
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
{#if match !== null}
|
|
43
|
+
{#key routeParams._path}
|
|
44
|
+
<slot {routeInfo}>
|
|
45
|
+
<svelte:component this={component} {...props} {routeInfo} />
|
|
46
|
+
</slot>
|
|
47
|
+
{/key}
|
|
48
|
+
{/if}
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
|
|
16
|
+
export const ctx = {
|
|
17
|
+
router: Symbol("Router Context"),
|
|
18
|
+
parent: Symbol("Route Parent"),
|
|
19
|
+
layout: Symbol("Layout Context"),
|
|
20
|
+
}
|
|
21
|
+
export const resolve = (base, part) => {
|
|
22
|
+
if (part === "" || part === "/") {
|
|
23
|
+
return base
|
|
24
|
+
}
|
|
25
|
+
if (base === "/" || base === undefined) {
|
|
26
|
+
return `/${part}`
|
|
27
|
+
}
|
|
28
|
+
if (part.startsWith("/") === true) {
|
|
29
|
+
return `${base}${part}`
|
|
30
|
+
}
|
|
31
|
+
return `${base}/${part}`
|
|
32
|
+
}
|
|
33
|
+
export const relpath = (path) => {
|
|
34
|
+
const base = getContext(ctx.parent)
|
|
35
|
+
return `#${resolve(base, path)}`
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const emptyStack = Symbol("empty stack")
|
|
39
|
+
export const stackStore = (initial = stackStore.empty) => {
|
|
40
|
+
const stack = [writable(initial)]
|
|
41
|
+
const current = writable(initial)
|
|
42
|
+
let attachment = stack[0].subscribe(current.set)
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
subscribe: current.subscribe,
|
|
46
|
+
push: (initial) => {
|
|
47
|
+
const item = writable(initial)
|
|
48
|
+
onMount(() => {
|
|
49
|
+
stack.push(item)
|
|
50
|
+
attachment()
|
|
51
|
+
attachment = item.subscribe(current.set)
|
|
52
|
+
return () => {
|
|
53
|
+
stack.pop()
|
|
54
|
+
attachment()
|
|
55
|
+
attachment = stack[stack.length - 1].subscribe(current.set)
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
return item
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
stackStore.empty = emptyStack
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script context="module">
|
|
2
|
+
import { writable } from "svelte/store"
|
|
3
|
+
|
|
4
|
+
import { stackStore } from "./routing.js"
|
|
5
|
+
|
|
6
|
+
// const stack = writable([])
|
|
7
|
+
const stack = stackStore()
|
|
8
|
+
|
|
9
|
+
const updateTitle = (format, data) => {
|
|
10
|
+
if (format === null || data === stackStore.empty) {
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
document.title = format(data)
|
|
15
|
+
}
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
import { onMount } from "svelte"
|
|
20
|
+
export let data = ""
|
|
21
|
+
export let format = null
|
|
22
|
+
|
|
23
|
+
stack.push(data)
|
|
24
|
+
|
|
25
|
+
$: updateTitle(format, $stack)
|
|
26
|
+
</script>
|
package/src/text.svelte
CHANGED
|
@@ -5,14 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
export let title = false
|
|
7
7
|
export let subtitle = false
|
|
8
|
-
export let block = false
|
|
9
8
|
export let adorn = false
|
|
10
9
|
|
|
11
10
|
$: wind = {
|
|
12
|
-
"$title": title,
|
|
13
|
-
"$subtitle": subtitle,
|
|
11
|
+
"$title-text": title,
|
|
12
|
+
"$subtitle-text": subtitle,
|
|
14
13
|
"$adorn": adorn,
|
|
15
|
-
block,
|
|
16
14
|
...$$restProps
|
|
17
15
|
}
|
|
18
16
|
</script>
|
package/src/wsx.mjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import ws from "@axel669/windstorm"
|
|
2
2
|
|
|
3
|
-
// ws.custom("outline", (o) => ws.prop("outline", o))
|
|
4
|
-
|
|
5
3
|
export default (node, props) => {
|
|
6
4
|
const update = (props) => {
|
|
7
5
|
const { slot = null, ...goodProps } = props ?? {}
|
|
@@ -9,15 +7,18 @@ export default (node, props) => {
|
|
|
9
7
|
node.setAttribute("ws-x", null)
|
|
10
8
|
return
|
|
11
9
|
}
|
|
10
|
+
const formatted = Object.entries(goodProps).reduce(
|
|
11
|
+
(props, [key, value]) => {
|
|
12
|
+
const realKey = key.replaceAll("--", ":").replace(/^\-/, "$")
|
|
13
|
+
props[realKey] = value
|
|
14
|
+
return props
|
|
15
|
+
},
|
|
16
|
+
{}
|
|
17
|
+
)
|
|
12
18
|
node.setAttribute(
|
|
13
19
|
"ws-x",
|
|
14
|
-
ws.x(
|
|
20
|
+
ws.x(formatted)
|
|
15
21
|
)
|
|
16
|
-
if (slot === null) {
|
|
17
|
-
node.removeAttribute("slot")
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
node.setAttribute("slot", slot)
|
|
21
22
|
}
|
|
22
23
|
update(props)
|
|
23
24
|
return { update }
|
package/src/async/button.md
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# AsyncButton
|
|
2
|
-
A button that makes it simpler to fire off async functions in response to button
|
|
3
|
-
clicks. In addition to calling the function, the button will disable itself
|
|
4
|
-
during the function duration and show a load spinner inside the button.
|
|
5
|
-
|
|
6
|
-
## Props
|
|
7
|
-
The AsyncButton supports all of the [Button](../control/button.md) props.
|
|
8
|
-
|
|
9
|
-
### handler
|
|
10
|
-
The async function to call when the button is clicked.
|
|
11
|
-
|
|
12
|
-
## Example
|
|
13
|
-
|
|
14
|
-
```svelte
|
|
15
|
-
<script>
|
|
16
|
-
import { AsyncButton } from "@axel669/zephyr"
|
|
17
|
-
|
|
18
|
-
const load = async () => {
|
|
19
|
-
const res = await fetch(someURL)
|
|
20
|
-
console.log(await res.text())
|
|
21
|
-
}
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<AsyncButton handler={load} color="@primary">
|
|
25
|
-
Load Things
|
|
26
|
-
</AsyncButton>
|
|
27
|
-
```
|
package/src/async/load-zone.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# LoadZone
|
|
2
|
-
A component for putting content that is behind an async function.
|
|
3
|
-
|
|
4
|
-
## Props
|
|
5
|
-
|
|
6
|
-
### message
|
|
7
|
-
The text to show while the promise is pending.
|
|
8
|
-
|
|
9
|
-
### source
|
|
10
|
-
`Promise`
|
|
11
|
-
|
|
12
|
-
The promise that will resolve into some kind of content-related information.
|
|
13
|
-
|
|
14
|
-
## Slots
|
|
15
|
-
|
|
16
|
-
### default
|
|
17
|
-
The default slot will be shown when the promise resolves.
|
|
18
|
-
|
|
19
|
-
### loading
|
|
20
|
-
The content to show while the promise is pending. Overrides the default of a
|
|
21
|
-
load spinner with some text.
|
|
22
|
-
|
|
23
|
-
### error
|
|
24
|
-
The content to show when the promise rejects. Use `let:error` to get the error
|
|
25
|
-
that was thrown.
|
|
26
|
-
|
|
27
|
-
## Example
|
|
28
|
-
|
|
29
|
-
```svelte
|
|
30
|
-
<LoadZone source={asyncThing} let:result>
|
|
31
|
-
<div>
|
|
32
|
-
content
|
|
33
|
-
</div>
|
|
34
|
-
<div>
|
|
35
|
-
{JSON.stringify(result)}
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
<div slot="error">
|
|
39
|
-
:(
|
|
40
|
-
</div>
|
|
41
|
-
</LoadZone>
|
|
42
|
-
```
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# TH
|
|
2
|
-
|
|
3
|
-
The TH component has no use outside fo the DataTable, but is used to support
|
|
4
|
-
the filter and sorting functionality for that component.
|
|
5
|
-
|
|
6
|
-
## Props
|
|
7
|
-
|
|
8
|
-
### sort
|
|
9
|
-
`Function`
|
|
10
|
-
|
|
11
|
-
The sorting function to use for the column defined. Should return values that
|
|
12
|
-
match the expected values for `Array.sort`.
|
|
13
|
-
|
|
14
|
-
### filter
|
|
15
|
-
`Function`
|
|
16
|
-
|
|
17
|
-
The function to use for filtering based on the column. The function is given
|
|
18
|
-
2 arguments: a row of data and the text from the filter input field. The
|
|
19
|
-
function should return `true` if the item should be shown. A filter function on
|
|
20
|
-
a specific column does not need to only look at the specified column, but not
|
|
21
|
-
doing could cause confusion for users without proper context.
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
# DataTable
|
|
2
|
-
|
|
3
|
-
The DataTable is a more advanced way to show data on screen. Underneath is
|
|
4
|
-
a [Table](../data-display/table.md) component, but with additional functionality
|
|
5
|
-
for pagination, sorting, and fitering.
|
|
6
|
-
|
|
7
|
-
> If pagination is not needed, the DataTable may not be necessary as it will
|
|
8
|
-
> only be shortcutting data formatting at that point.
|
|
9
|
-
|
|
10
|
-
## Props
|
|
11
|
-
|
|
12
|
-
### color
|
|
13
|
-
Sets `$color`
|
|
14
|
-
|
|
15
|
-
### data
|
|
16
|
-
`Array`
|
|
17
|
-
|
|
18
|
-
The data to display. Each item in the array can be in either the same
|
|
19
|
-
format as the Table, or any kind of object if column format functions
|
|
20
|
-
are used.
|
|
21
|
-
|
|
22
|
-
### page
|
|
23
|
-
`Number`
|
|
24
|
-
|
|
25
|
-
The current page of data being viewed. Can be bound, or set to control
|
|
26
|
-
which page is displayed
|
|
27
|
-
|
|
28
|
-
### pageSize
|
|
29
|
-
`Number`
|
|
30
|
-
|
|
31
|
-
The number of items to show on each page. Default is 10.
|
|
32
|
-
|
|
33
|
-
### rowHeight
|
|
34
|
-
The height of each row. The component uses this to make empty rows the same
|
|
35
|
-
height as rows with data so that the pagination doesnt randomly resize the
|
|
36
|
-
visual area of the table.
|
|
37
|
-
|
|
38
|
-
## Slots
|
|
39
|
-
|
|
40
|
-
### header
|
|
41
|
-
A fragment that should contain the header cells for the table header. A standard
|
|
42
|
-
`th` can be used, but the [TH](./data-table/th.md) element from zephyr has
|
|
43
|
-
additional configuration to handle more complex header-related actions.
|
|
44
|
-
|
|
45
|
-
### row
|
|
46
|
-
A fragment that should use regular `td` elements to define how a row should be
|
|
47
|
-
layed out. The fragment will need `let:row` to access each row's data for
|
|
48
|
-
displaying it.
|
|
49
|
-
|
|
50
|
-
## Example
|
|
51
|
-
```svelte
|
|
52
|
-
<script>
|
|
53
|
-
import { DataTable, TH, sorts } from "@axel669/zephyr"
|
|
54
|
-
|
|
55
|
-
let page
|
|
56
|
-
const data = [
|
|
57
|
-
{ a: 1, b: 1 ** 2, c: 1 ** 3 },
|
|
58
|
-
{ a: 2, b: 2 ** 2, c: 2 ** 3 },
|
|
59
|
-
{ a: 3, b: 3 ** 2, c: 3 ** 3 },
|
|
60
|
-
{ a: 4, b: 4 ** 2, c: 4 ** 3 },
|
|
61
|
-
{ a: 5, b: 5 ** 2, c: 5 ** 3 },
|
|
62
|
-
{ a: 6, b: 6 ** 2, c: 6 ** 3 },
|
|
63
|
-
{ a: 7, b: 7 ** 2, c: 7 ** 3 },
|
|
64
|
-
{ a: 8, b: 8 ** 2, c: 8 ** 3 },
|
|
65
|
-
{ a: 9, b: 9 ** 2, c: 9 ** 3 },
|
|
66
|
-
{ a: 10, b: 10 ** 2, c: 10 ** 3 },
|
|
67
|
-
{ a: 11, b: 11 ** 2, c: 11 ** 3 },
|
|
68
|
-
{ a: 12, b: 12 ** 2, c: 12 ** 3 },
|
|
69
|
-
{ a: 13, b: 13 ** 2, c: 13 ** 3 },
|
|
70
|
-
]
|
|
71
|
-
</script>
|
|
72
|
-
|
|
73
|
-
<DataTable {cols} {data} color="warning" pageSize={3} bind:page>
|
|
74
|
-
<svelte:fragment slot="header">
|
|
75
|
-
<TH sort={sorts.natural}>N</TH>
|
|
76
|
-
<th>Squared</th>
|
|
77
|
-
<th>Cubed</th>
|
|
78
|
-
</svelte:fragment>
|
|
79
|
-
|
|
80
|
-
<svelte:fragment slot="row" let:row>
|
|
81
|
-
<td>{row.a}</td>
|
|
82
|
-
<td>{row.b}</td>
|
|
83
|
-
<td>^3 = {row.c}</td>
|
|
84
|
-
</svelte:fragment>
|
|
85
|
-
</DataTable>
|
|
86
|
-
```
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
|
|
12
|
-
### props
|
|
13
|
-
The props to pass to the component when it is shown, or a function that
|
|
14
|
-
generates the props when called.
|
|
15
|
-
|
|
16
|
-
### this
|
|
17
|
-
The wrapper for the component. Default is [Modal](../layout/modal.md) but any
|
|
18
|
-
component that has the same interface as Modal will work.
|
|
19
|
-
|
|
20
|
-
## Events
|
|
21
|
-
|
|
22
|
-
### entry
|
|
23
|
-
When the component is closed the entry event is fired. The detail
|
|
24
|
-
property of the event will have the value from closing it.
|
|
25
|
-
|
|
26
|
-
## Example
|
|
27
|
-
```svelte
|
|
28
|
-
<script>
|
|
29
|
-
const propsFunc = () => ({
|
|
30
|
-
now: Date.now(),
|
|
31
|
-
rand: Math.random(),
|
|
32
|
-
})
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
<EntryButton component={Subscreen} on:entry={console.log}>
|
|
36
|
-
Open Subscreen
|
|
37
|
-
</EntryButton>
|
|
38
|
-
<EntryButton component={CoolDialog} props={{ thing: true }} on:entry={console.log}>
|
|
39
|
-
Open Subscreen
|
|
40
|
-
</EntryButton>
|
|
41
|
-
<EntryButton this={CoolModal} component={CustomThing} on:entry={console.log} props={propsFunc}>
|
|
42
|
-
Open Subscreen
|
|
43
|
-
</EntryButton>
|
|
44
|
-
```
|