@axel669/zephyr 0.4.5 → 0.4.6
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 +2 -2
- package/src/composed/element-toast.svelte +96 -0
- package/src/control/button.svelte +9 -1
- package/src/control/input.svelte +14 -2
- package/src/control/label.svelte +8 -1
- package/src/control/link.svelte +10 -1
- package/src/data-display/progress.svelte +7 -13
- package/src/index.mjs +1 -0
- package/src/variant.mjs +7 -9
- package/src/wsx.mjs +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axel669/zephyr",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@axel669/rollup-copy-static": "^0.2.0",
|
|
17
|
-
"@axel669/windstorm": "0.4.
|
|
17
|
+
"@axel669/windstorm": "0.4.6"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@axel669/asuid": "^0.2.1",
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script context="module">
|
|
4
|
+
const genID = () => `${Date.now()}:${Math.random().toString(16)}`
|
|
5
|
+
|
|
6
|
+
const delays = {}
|
|
7
|
+
const delay = ({time, action, id}) => {
|
|
8
|
+
const trigger = () => {
|
|
9
|
+
const info = delays[id]
|
|
10
|
+
clearTimeout(info.id)
|
|
11
|
+
action()
|
|
12
|
+
delete delays[id]
|
|
13
|
+
}
|
|
14
|
+
const timeoutID = setTimeout(trigger, time)
|
|
15
|
+
delays[id] = { trigger, id: timeoutID }
|
|
16
|
+
}
|
|
17
|
+
delay.trigger = (id) => delays[id].trigger()
|
|
18
|
+
|
|
19
|
+
const macros = {
|
|
20
|
+
top: {
|
|
21
|
+
"-y": "100%",
|
|
22
|
+
flex: "column-reverse",
|
|
23
|
+
},
|
|
24
|
+
bottom: {
|
|
25
|
+
"y": "100%",
|
|
26
|
+
flex: "column"
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<script>
|
|
32
|
+
import { createEventDispatcher } from "svelte"
|
|
33
|
+
import { fade } from "svelte/transition"
|
|
34
|
+
|
|
35
|
+
import { eventHandler$ } from "../handler$.mjs"
|
|
36
|
+
import wsx from "../wsx.mjs"
|
|
37
|
+
|
|
38
|
+
import Toaster from "../info/toaster.svelte"
|
|
39
|
+
|
|
40
|
+
import ToastMessage from "./toast/message.svelte"
|
|
41
|
+
|
|
42
|
+
export let component = ToastMessage
|
|
43
|
+
export let position = "top"
|
|
44
|
+
|
|
45
|
+
let items = []
|
|
46
|
+
|
|
47
|
+
const dispatch = createEventDispatcher()
|
|
48
|
+
const act = eventHandler$(
|
|
49
|
+
(evt, id, props) => {
|
|
50
|
+
delay.trigger(id)
|
|
51
|
+
dispatch(
|
|
52
|
+
"action",
|
|
53
|
+
{ value: evt.detail, props }
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
export const show = (duration, props) => {
|
|
59
|
+
const id = genID()
|
|
60
|
+
items = [...items, { id, props }]
|
|
61
|
+
delay({
|
|
62
|
+
action: () => items = items.filter(
|
|
63
|
+
item => item.id !== id
|
|
64
|
+
),
|
|
65
|
+
time: duration,
|
|
66
|
+
id,
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
export const clear = () => items = []
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
$: wind = {
|
|
73
|
+
gap: "8px",
|
|
74
|
+
pos: "absolute",
|
|
75
|
+
x: "50%",
|
|
76
|
+
z: "50",
|
|
77
|
+
tf: "translateX(-50%)",
|
|
78
|
+
...macros[position],
|
|
79
|
+
...$$restProps,
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<zephyr-element-toaster ws-x="[disp inline-grid] [pos relative]">
|
|
84
|
+
<slot {show} />
|
|
85
|
+
<zephyr-element-toast-messages use:wsx={wind}>
|
|
86
|
+
{#each items as {props, id} (id)}
|
|
87
|
+
<zephyr-toast-wrapper ws-x="[grid]" transition:fade={{duration: 200}}>
|
|
88
|
+
<svelte:component
|
|
89
|
+
this={component}
|
|
90
|
+
{...props}
|
|
91
|
+
on:action={act(id, props)}
|
|
92
|
+
/>
|
|
93
|
+
</zephyr-toast-wrapper>
|
|
94
|
+
{/each}
|
|
95
|
+
</zephyr-element-toast-messages>
|
|
96
|
+
</zephyr-element-toaster>
|
|
@@ -6,18 +6,26 @@
|
|
|
6
6
|
|
|
7
7
|
export let color = false
|
|
8
8
|
export let compact = false
|
|
9
|
+
export let ground = false
|
|
9
10
|
export let disabled
|
|
10
11
|
|
|
11
12
|
export let fill = false
|
|
12
13
|
export let outline = false
|
|
13
14
|
export let flat = false
|
|
14
15
|
|
|
15
|
-
$: type = variant({ fill, outline, flat })
|
|
16
|
+
// $: type = variant({ fill, outline, flat })
|
|
17
|
+
$: type = variant(
|
|
18
|
+
"$flat",
|
|
19
|
+
{ fill },
|
|
20
|
+
{ outline },
|
|
21
|
+
{ flat }
|
|
22
|
+
)
|
|
16
23
|
|
|
17
24
|
$: wind = {
|
|
18
25
|
[type]: true,
|
|
19
26
|
"$color": color,
|
|
20
27
|
$compact: compact,
|
|
28
|
+
$ground: ground,
|
|
21
29
|
...$$restProps
|
|
22
30
|
}
|
|
23
31
|
</script>
|
package/src/control/input.svelte
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
<svelte:options immutable />
|
|
2
2
|
|
|
3
3
|
<script>
|
|
4
|
-
import wsx from "../wsx.mjs"
|
|
4
|
+
import wsx, { none } from "../wsx.mjs"
|
|
5
|
+
import variant from "../variant.mjs"
|
|
5
6
|
|
|
6
7
|
export let type = "text"
|
|
7
8
|
|
|
8
9
|
export let flat = false
|
|
10
|
+
export let lined = false
|
|
11
|
+
export let linedFill = false
|
|
12
|
+
export let outline = false
|
|
9
13
|
export let label
|
|
10
14
|
export let color = "@default"
|
|
11
15
|
export let disabled
|
|
@@ -36,8 +40,16 @@
|
|
|
36
40
|
{wind: {}, input: {}}
|
|
37
41
|
)
|
|
38
42
|
|
|
43
|
+
$: variantStyle = variant(
|
|
44
|
+
none,
|
|
45
|
+
{ outline },
|
|
46
|
+
{ linedFill },
|
|
47
|
+
{ lined },
|
|
48
|
+
{ flat }
|
|
49
|
+
)
|
|
50
|
+
|
|
39
51
|
$: wind = {
|
|
40
|
-
|
|
52
|
+
[variantStyle]: true,
|
|
41
53
|
"@@control": true,
|
|
42
54
|
"$color": color,
|
|
43
55
|
...props.wind,
|
package/src/control/label.svelte
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
export let color = false
|
|
8
8
|
export let compact = false
|
|
9
|
+
export let ground = false
|
|
9
10
|
export let disabled
|
|
10
11
|
|
|
11
12
|
export let fill = false
|
|
@@ -16,7 +17,12 @@
|
|
|
16
17
|
export { _for as for }
|
|
17
18
|
export let button = false
|
|
18
19
|
|
|
19
|
-
$: type = variant(
|
|
20
|
+
$: type = variant(
|
|
21
|
+
"$flat",
|
|
22
|
+
{ fill },
|
|
23
|
+
{ outline },
|
|
24
|
+
{ flat }
|
|
25
|
+
)
|
|
20
26
|
$: baseStyles =
|
|
21
27
|
(button === true)
|
|
22
28
|
? {
|
|
@@ -24,6 +30,7 @@
|
|
|
24
30
|
[type]: true,
|
|
25
31
|
"$color": color,
|
|
26
32
|
$compact: compact,
|
|
33
|
+
$ground: ground,
|
|
27
34
|
}
|
|
28
35
|
: {}
|
|
29
36
|
|
package/src/control/link.svelte
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
export let button = false
|
|
8
8
|
export let color = false
|
|
9
|
+
export let compact = false
|
|
10
|
+
export let ground = false
|
|
9
11
|
|
|
10
12
|
export let href = ""
|
|
11
13
|
export let rel = "noreferrer"
|
|
@@ -17,12 +19,19 @@
|
|
|
17
19
|
|
|
18
20
|
export let disabled = null
|
|
19
21
|
|
|
20
|
-
$: type = variant(
|
|
22
|
+
$: type = variant(
|
|
23
|
+
"$flat",
|
|
24
|
+
{ fill },
|
|
25
|
+
{ outline },
|
|
26
|
+
{ flat }
|
|
27
|
+
)
|
|
21
28
|
|
|
22
29
|
$: wind = {
|
|
23
30
|
"@@button": button,
|
|
24
31
|
[type]: true,
|
|
25
32
|
"$color": color,
|
|
33
|
+
$compact: compact,
|
|
34
|
+
$ground: ground,
|
|
26
35
|
...$$restProps
|
|
27
36
|
}
|
|
28
37
|
</script>
|
|
@@ -4,24 +4,18 @@
|
|
|
4
4
|
import wsx from "../wsx.mjs"
|
|
5
5
|
|
|
6
6
|
export let value = 0
|
|
7
|
+
export let min = 0
|
|
7
8
|
export let max = 1
|
|
8
|
-
export let
|
|
9
|
-
export let
|
|
10
|
-
export let
|
|
11
|
-
export let label = null
|
|
9
|
+
export let buffer = 0
|
|
10
|
+
export let busy = false
|
|
11
|
+
export let color = "@default"
|
|
12
12
|
|
|
13
13
|
$: wind = {
|
|
14
|
-
"@@progress": true,
|
|
15
|
-
"$outline": outline,
|
|
16
14
|
"$color": color,
|
|
17
|
-
$row: row,
|
|
18
15
|
...$$restProps,
|
|
19
16
|
}
|
|
17
|
+
|
|
18
|
+
$: busyStatus = (busy === true) ? { busy: true } : {}
|
|
20
19
|
</script>
|
|
21
20
|
|
|
22
|
-
<
|
|
23
|
-
{#if label}
|
|
24
|
-
<span ws-x="[$progress-label] [t.ws nowrap]">{label}</span>
|
|
25
|
-
{/if}
|
|
26
|
-
<progress {value} {max} />
|
|
27
|
-
</label>
|
|
21
|
+
<ws-progress use:wsx={wind} {...busyStatus} {min} {max} {value} {buffer} />
|
package/src/index.mjs
CHANGED
|
@@ -40,6 +40,7 @@ export { default as Confirm } from "./dialogs/confirm.svelte"
|
|
|
40
40
|
|
|
41
41
|
export { default as DataTable } from "./composed/data-table.svelte"
|
|
42
42
|
export { default as TH } from "./composed/data-table/th.svelte"
|
|
43
|
+
export { default as ElementToast } from "./composed/element-toast.svelte"
|
|
43
44
|
export { default as EntryButton } from "./composed/entry-button.svelte"
|
|
44
45
|
export { default as Form } from "./composed/form.svelte"
|
|
45
46
|
export { default as Toast } from "./composed/toast.svelte"
|
package/src/variant.mjs
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
export default (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (flat === true) {
|
|
9
|
-
return "$flat"
|
|
1
|
+
export default (def, ...variants) => {
|
|
2
|
+
for (const variant of variants) {
|
|
3
|
+
const [entry] = Object.entries(variant)
|
|
4
|
+
const [key, value] = entry
|
|
5
|
+
if (value === true) {
|
|
6
|
+
return `$${key.replace(/[A-Z]/g, (s) => `-${s.toLocaleLowerCase()}`)}`
|
|
7
|
+
}
|
|
10
8
|
}
|
|
11
9
|
return def
|
|
12
10
|
}
|
package/src/wsx.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ws from "@axel669/windstorm"
|
|
2
2
|
|
|
3
|
+
export const none = Symbol("none")
|
|
3
4
|
export default (node, props) => {
|
|
4
5
|
const update = (props) => {
|
|
5
6
|
const { slot = null, ...goodProps } = props ?? {}
|
|
@@ -9,7 +10,10 @@ export default (node, props) => {
|
|
|
9
10
|
}
|
|
10
11
|
const formatted = Object.entries(goodProps).reduce(
|
|
11
12
|
(props, [key, value]) => {
|
|
12
|
-
|
|
13
|
+
if (key === none) {
|
|
14
|
+
return props
|
|
15
|
+
}
|
|
16
|
+
const realKey = key.replace(/^!/, "").replaceAll("_", ":")
|
|
13
17
|
props[realKey] = value
|
|
14
18
|
return props
|
|
15
19
|
},
|