@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,108 +1,68 @@
|
|
|
1
|
-
<script context="module">
|
|
2
|
-
const genID = () => `${Date.now()}:${Math.random().toString(16)}`
|
|
3
|
-
|
|
4
|
-
const delays = {}
|
|
5
|
-
const delay = ({time, action, id}) => {
|
|
6
|
-
const trigger = () => {
|
|
7
|
-
const info = delays[id]
|
|
8
|
-
clearTimeout(info.id)
|
|
9
|
-
action()
|
|
10
|
-
delete delays[id]
|
|
11
|
-
}
|
|
12
|
-
const timeoutID = setTimeout(trigger, time)
|
|
13
|
-
delays[id] = { trigger, id: timeoutID }
|
|
14
|
-
}
|
|
15
|
-
delay.trigger = (id) => delays[id].trigger()
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
|
-
<script>
|
|
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
|
-
export let position = "tc"
|
|
70
|
-
|
|
71
|
-
let items = []
|
|
72
|
-
|
|
73
|
-
const dispatch = createEventDispatcher()
|
|
74
|
-
const act = eventHandler$(
|
|
75
|
-
(evt, id, props) => {
|
|
76
|
-
delay.trigger(id)
|
|
77
|
-
dispatch(
|
|
78
|
-
"action",
|
|
79
|
-
{ value: evt.detail, props }
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
export const show = (duration, props) => {
|
|
85
|
-
const id = genID()
|
|
86
|
-
items = [...items, { id, props }]
|
|
87
|
-
delay({
|
|
88
|
-
action: () => items = items.filter(
|
|
89
|
-
item => item.id !== id
|
|
90
|
-
),
|
|
91
|
-
time: duration,
|
|
92
|
-
id,
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
export const clear = () => items = []
|
|
96
|
-
</script>
|
|
97
|
-
|
|
98
|
-
<Toaster {position} {...$$restProps}>
|
|
99
|
-
{#each items as {props, id} (id)}
|
|
100
|
-
<wsv-toast-wrapper ws-x="grid" transition:fade={{duration: 200}}>
|
|
101
|
-
<svelte:component
|
|
102
|
-
this={component}
|
|
103
|
-
{...props}
|
|
104
|
-
on:action={act(id, props)}
|
|
105
|
-
/>
|
|
106
|
-
</wsv-toast-wrapper>
|
|
107
|
-
{/each}
|
|
108
|
-
</Toaster>
|
|
1
|
+
<script context="module">
|
|
2
|
+
const genID = () => `${Date.now()}:${Math.random().toString(16)}`
|
|
3
|
+
|
|
4
|
+
const delays = {}
|
|
5
|
+
const delay = ({time, action, id}) => {
|
|
6
|
+
const trigger = () => {
|
|
7
|
+
const info = delays[id]
|
|
8
|
+
clearTimeout(info.id)
|
|
9
|
+
action()
|
|
10
|
+
delete delays[id]
|
|
11
|
+
}
|
|
12
|
+
const timeoutID = setTimeout(trigger, time)
|
|
13
|
+
delays[id] = { trigger, id: timeoutID }
|
|
14
|
+
}
|
|
15
|
+
delay.trigger = (id) => delays[id].trigger()
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
import { createEventDispatcher } from "svelte"
|
|
20
|
+
import { fade } from "svelte/transition"
|
|
21
|
+
|
|
22
|
+
import { eventHandler$ } from "../handler$.mjs"
|
|
23
|
+
|
|
24
|
+
import Toaster from "../info/toaster.svelte"
|
|
25
|
+
|
|
26
|
+
import ToastMessage from "./toast/message.svelte"
|
|
27
|
+
|
|
28
|
+
export let component = ToastMessage
|
|
29
|
+
export let position = "tc"
|
|
30
|
+
|
|
31
|
+
let items = []
|
|
32
|
+
|
|
33
|
+
const dispatch = createEventDispatcher()
|
|
34
|
+
const act = eventHandler$(
|
|
35
|
+
(evt, id, props) => {
|
|
36
|
+
delay.trigger(id)
|
|
37
|
+
dispatch(
|
|
38
|
+
"action",
|
|
39
|
+
{ value: evt.detail, props }
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
export const show = (duration, props) => {
|
|
45
|
+
const id = genID()
|
|
46
|
+
items = [...items, { id, props }]
|
|
47
|
+
delay({
|
|
48
|
+
action: () => items = items.filter(
|
|
49
|
+
item => item.id !== id
|
|
50
|
+
),
|
|
51
|
+
time: duration,
|
|
52
|
+
id,
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
export const clear = () => items = []
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<Toaster {position} {...$$restProps}>
|
|
59
|
+
{#each items as {props, id} (id)}
|
|
60
|
+
<zephyr-toast-wrapper ws-x="grid" transition:fade={{duration: 200}}>
|
|
61
|
+
<svelte:component
|
|
62
|
+
this={component}
|
|
63
|
+
{...props}
|
|
64
|
+
on:action={act(id, props)}
|
|
65
|
+
/>
|
|
66
|
+
</zephyr-toast-wrapper>
|
|
67
|
+
{/each}
|
|
68
|
+
</Toaster>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
|
+
Basic clickable component for handling user interaction.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### color
|
|
8
|
+
`string`
|
|
9
|
+
|
|
10
|
+
Sets `$color`
|
|
11
|
+
|
|
12
|
+
### compact
|
|
13
|
+
`bool`
|
|
14
|
+
|
|
15
|
+
Sets `$compact`
|
|
16
|
+
|
|
17
|
+
### fill / outline
|
|
18
|
+
`bool`
|
|
19
|
+
|
|
20
|
+
Sets the button type to `$fill` if fill is true, `$outline` if outline
|
|
21
|
+
is true, or `$flat` if neither is true.
|
|
22
|
+
|
|
23
|
+
## Events
|
|
24
|
+
- click
|
|
25
|
+
|
|
26
|
+
## Example
|
|
27
|
+
```svelte
|
|
28
|
+
<Button on:click={action}>
|
|
29
|
+
Flat Button
|
|
30
|
+
</Button>
|
|
31
|
+
<Button on:click={action} outline>
|
|
32
|
+
Outlined Button
|
|
33
|
+
</Button>
|
|
34
|
+
<Button on:click={action} fill color="danger">
|
|
35
|
+
Filled Button
|
|
36
|
+
</Button>
|
|
37
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import wsx from "../wsx.mjs"
|
|
3
|
+
import variant from "../variant.mjs"
|
|
4
|
+
|
|
5
|
+
export let color = false
|
|
6
|
+
export let compact = false
|
|
7
|
+
export let disabled
|
|
8
|
+
|
|
9
|
+
export let fill = false
|
|
10
|
+
export let outline = false
|
|
11
|
+
export let flat = false
|
|
12
|
+
|
|
13
|
+
$: type = variant({ fill, outline, flat })
|
|
14
|
+
|
|
15
|
+
$: wind = {
|
|
16
|
+
[type]: true,
|
|
17
|
+
"$color": color,
|
|
18
|
+
$compact: compact,
|
|
19
|
+
...$$restProps
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<button use:wsx={wind} {disabled} on:click|stopPropagation>
|
|
24
|
+
<slot />
|
|
25
|
+
</button>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script context="module">
|
|
2
|
+
const parseNumeric = (value) => {
|
|
3
|
+
if (value === "") {
|
|
4
|
+
return null
|
|
5
|
+
}
|
|
6
|
+
return parseFloat(value)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const diff = (type, value, internal) => {
|
|
10
|
+
if ((type !== "number" && type !== "range") || typeof value === "string") {
|
|
11
|
+
return value !== internal
|
|
12
|
+
}
|
|
13
|
+
return parseFloat(internal) !== value
|
|
14
|
+
}
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
import wsx from "../wsx.mjs"
|
|
19
|
+
|
|
20
|
+
export let type = "text"
|
|
21
|
+
|
|
22
|
+
export let flat = false
|
|
23
|
+
export let label
|
|
24
|
+
export let color = "default"
|
|
25
|
+
export let error = null
|
|
26
|
+
export let hint = null
|
|
27
|
+
export let disabled
|
|
28
|
+
|
|
29
|
+
export let value = ""
|
|
30
|
+
export let autocompleteOptions = null
|
|
31
|
+
|
|
32
|
+
export let transform = i => i
|
|
33
|
+
export let tvalue
|
|
34
|
+
export let validate = () => true
|
|
35
|
+
export let valid
|
|
36
|
+
|
|
37
|
+
let input = null
|
|
38
|
+
let internalValue = value
|
|
39
|
+
export const focus = () => input.focus()
|
|
40
|
+
|
|
41
|
+
const id =
|
|
42
|
+
(autocompleteOptions === null)
|
|
43
|
+
? null
|
|
44
|
+
: `${Math.random().toString(16)}_${Date.now()}`
|
|
45
|
+
|
|
46
|
+
$: isNumeric = (type === "number" || type === "range")
|
|
47
|
+
$: if (diff(type, value, internalValue) === true) {
|
|
48
|
+
internalValue = value
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const update = (evt) => {
|
|
52
|
+
internalValue = evt.target.value
|
|
53
|
+
value = (isNumeric === true) ? parseNumeric(internalValue) : internalValue
|
|
54
|
+
tvalue = transform(value)
|
|
55
|
+
valid = validate(tvalue)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
$: restKeys = Object.keys($$restProps)
|
|
59
|
+
$: props = restKeys.reduce(
|
|
60
|
+
(props, key) => {
|
|
61
|
+
const [target, name] =
|
|
62
|
+
(key.startsWith("i-") === true)
|
|
63
|
+
? [props.input, key.slice(2)]
|
|
64
|
+
: [props.wind, key]
|
|
65
|
+
target[name] = $$restProps[key]
|
|
66
|
+
return props
|
|
67
|
+
},
|
|
68
|
+
{wind: {}, input: {}}
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
$: wind = {
|
|
72
|
+
"$flat": flat,
|
|
73
|
+
"$control": true,
|
|
74
|
+
"$color": color,
|
|
75
|
+
...props.wind,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
$: tag = (type === "area") ? "textarea" : "input"
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<label use:wsx={wind} ws-error={error}>
|
|
82
|
+
{#if label}
|
|
83
|
+
<span ws-x="$text" ws-hint={hint}>{label}</span>
|
|
84
|
+
{/if}
|
|
85
|
+
<svelte:element
|
|
86
|
+
this={tag}
|
|
87
|
+
{...props.input}
|
|
88
|
+
{disabled}
|
|
89
|
+
{type}
|
|
90
|
+
value={internalValue}
|
|
91
|
+
list={id}
|
|
92
|
+
on:focus
|
|
93
|
+
on:blur
|
|
94
|
+
on:input={update}
|
|
95
|
+
bind:this={input}
|
|
96
|
+
/>
|
|
97
|
+
|
|
98
|
+
<slot name="start" />
|
|
99
|
+
<slot name="end" />
|
|
100
|
+
{#if autocompleteOptions !== null}
|
|
101
|
+
<datalist {id}>
|
|
102
|
+
{#each autocompleteOptions as value}
|
|
103
|
+
<option {value} />
|
|
104
|
+
{/each}
|
|
105
|
+
</datalist>
|
|
106
|
+
{/if}
|
|
107
|
+
</label>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Label
|
|
2
|
+
|
|
3
|
+
The label component is a wrapper around a `<label>` element.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### button
|
|
8
|
+
`bool`
|
|
9
|
+
|
|
10
|
+
If true, the label will have the button appearance.
|
|
11
|
+
|
|
12
|
+
### color
|
|
13
|
+
`string`
|
|
14
|
+
|
|
15
|
+
Sets `$color`
|
|
16
|
+
|
|
17
|
+
### compact
|
|
18
|
+
`bool`
|
|
19
|
+
|
|
20
|
+
If true, will make the label button be more compact. No effect is `button` is
|
|
21
|
+
`false`.
|
|
22
|
+
|
|
23
|
+
### disabled
|
|
24
|
+
`bool`
|
|
25
|
+
|
|
26
|
+
Disables the label.
|
|
27
|
+
|
|
28
|
+
### fill / outline / flat
|
|
29
|
+
`bool`
|
|
30
|
+
|
|
31
|
+
Sets the button variant of the label when `button` is `true`.
|
|
32
|
+
|
|
33
|
+
### for
|
|
34
|
+
`string`
|
|
35
|
+
|
|
36
|
+
[Label for attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label#for)
|
|
37
|
+
|
|
38
|
+
## Example
|
|
39
|
+
|
|
40
|
+
```svelte
|
|
41
|
+
<Label for="checkbox">Toggle Checkbox</Label>
|
|
42
|
+
<Label for="checkbox" button color="primary" fill>
|
|
43
|
+
Open Menu
|
|
44
|
+
</Label>
|
|
45
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import wsx from "../wsx.mjs"
|
|
3
|
+
import variant from "../variant.mjs"
|
|
4
|
+
|
|
5
|
+
export let color = false
|
|
6
|
+
export let compact = false
|
|
7
|
+
export let disabled
|
|
8
|
+
|
|
9
|
+
export let fill = false
|
|
10
|
+
export let outline = false
|
|
11
|
+
export let flat = false
|
|
12
|
+
|
|
13
|
+
let _for = ""
|
|
14
|
+
export { _for as for }
|
|
15
|
+
export let button = false
|
|
16
|
+
|
|
17
|
+
$: type = variant({ fill, outline, flat })
|
|
18
|
+
$: baseStyles =
|
|
19
|
+
(button === true)
|
|
20
|
+
? {
|
|
21
|
+
$button: true,
|
|
22
|
+
[type]: true,
|
|
23
|
+
"$color": color,
|
|
24
|
+
$compact: compact,
|
|
25
|
+
}
|
|
26
|
+
: {}
|
|
27
|
+
|
|
28
|
+
$: wind = {
|
|
29
|
+
...baseStyles,
|
|
30
|
+
...$$restProps
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<label use:wsx={wind} {disabled} for={_for}>
|
|
35
|
+
<slot />
|
|
36
|
+
</label>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Link
|
|
2
|
+
|
|
3
|
+
Themed and customizale `<a>` tag component.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### button `string`
|
|
8
|
+
|
|
9
|
+
If true, the link will be styled like a button
|
|
10
|
+
|
|
11
|
+
### color
|
|
12
|
+
`string`
|
|
13
|
+
|
|
14
|
+
Sets the color of the button. Applies to both regular links and button
|
|
15
|
+
style links.
|
|
16
|
+
|
|
17
|
+
### href
|
|
18
|
+
`string`
|
|
19
|
+
|
|
20
|
+
Sets the href attribute.
|
|
21
|
+
|
|
22
|
+
### rel
|
|
23
|
+
`string`
|
|
24
|
+
|
|
25
|
+
Sets the rel attribute.
|
|
26
|
+
|
|
27
|
+
### target
|
|
28
|
+
`string`
|
|
29
|
+
|
|
30
|
+
Sets the target attribute.
|
|
31
|
+
|
|
32
|
+
### fill / outline / flat
|
|
33
|
+
`bool`
|
|
34
|
+
|
|
35
|
+
Sets the link-button type to `$fill` if fill is true, `$outline` if outline
|
|
36
|
+
is true, or `$flat` if neither is true.
|
|
37
|
+
|
|
38
|
+
## Example
|
|
39
|
+
```svelte
|
|
40
|
+
<Link color="primary" href="test" target="_blank">
|
|
41
|
+
Test
|
|
42
|
+
</Link>
|
|
43
|
+
<Link color="primary" href="logout" button outline>
|
|
44
|
+
Logout
|
|
45
|
+
</Link>
|
|
46
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import wsx from "../wsx.mjs"
|
|
3
|
+
import variant from "../variant.mjs"
|
|
4
|
+
|
|
5
|
+
export let button = false
|
|
6
|
+
export let color = false
|
|
7
|
+
|
|
8
|
+
export let href = ""
|
|
9
|
+
export let rel = "noreferrer"
|
|
10
|
+
export let target = null
|
|
11
|
+
|
|
12
|
+
export let fill = false
|
|
13
|
+
export let outline = false
|
|
14
|
+
export let flat = false
|
|
15
|
+
|
|
16
|
+
$: type = variant({ fill, outline, flat })
|
|
17
|
+
|
|
18
|
+
$: wind = {
|
|
19
|
+
"@button": button,
|
|
20
|
+
[type]: true,
|
|
21
|
+
"$color": color,
|
|
22
|
+
...$$restProps
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<a {href} {target} {rel} use:wsx={wind}>
|
|
27
|
+
<slot />
|
|
28
|
+
</a>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Radio
|
|
2
|
+
|
|
3
|
+
The radio component displays a list of radio options and provides an
|
|
4
|
+
interface to control which one is selected and react to changes in the
|
|
5
|
+
selected value. It also uses a layout component to decide how the options
|
|
6
|
+
are presented.
|
|
7
|
+
|
|
8
|
+
## Base
|
|
9
|
+
Each radio item rendered is a
|
|
10
|
+
[Windstorm Labeled Toggle](https://windstorm.axel669.net/lib/css/component/toggle)
|
|
11
|
+
that uses a radio input.
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
|
|
15
|
+
The wind functions passed as props to the Radio component are passed directly to
|
|
16
|
+
the layout specified because the Radio does not have a container element of its
|
|
17
|
+
own.
|
|
18
|
+
|
|
19
|
+
### layout
|
|
20
|
+
`Component`
|
|
21
|
+
|
|
22
|
+
The component to use for layout out the options. Default is
|
|
23
|
+
[Flex](../layout/flex.md).
|
|
24
|
+
|
|
25
|
+
### options
|
|
26
|
+
`Array[Object]`
|
|
27
|
+
|
|
28
|
+
An array of objects that defines the options to show. Details below.
|
|
29
|
+
|
|
30
|
+
### value
|
|
31
|
+
`any`
|
|
32
|
+
|
|
33
|
+
The value currently selected. Can be bound to react to selections or change the
|
|
34
|
+
current selection.
|
|
35
|
+
|
|
36
|
+
## Options
|
|
37
|
+
Each object in the options array supplied should have a `value` and `label`
|
|
38
|
+
prop specified. Additionally, any wind functions that should be applied to
|
|
39
|
+
the option can be passed as additional props.
|
|
40
|
+
|
|
41
|
+
Labels should be strings, but values can be any type as long as they are
|
|
42
|
+
unique in the list.
|
|
43
|
+
|
|
44
|
+
## Example
|
|
45
|
+
```svelte
|
|
46
|
+
<script>
|
|
47
|
+
const options = [
|
|
48
|
+
{ label: "first", value: 1 },
|
|
49
|
+
{ label: "second", value: [] },
|
|
50
|
+
{ label: "third", value: "3", "$color": "warning" }
|
|
51
|
+
]
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<Radio {options} bind:value />
|
|
55
|
+
<Radio {options} bind:value={other} layout={Grid} gr-col="1fr 1fr" />
|
|
56
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import wsx from "../wsx.mjs"
|
|
3
|
+
import { handler$ } from "../handler$.mjs"
|
|
4
|
+
|
|
5
|
+
import Flex from "../layout/flex.svelte"
|
|
6
|
+
|
|
7
|
+
export let options = []
|
|
8
|
+
export let layout = Flex
|
|
9
|
+
export let value
|
|
10
|
+
|
|
11
|
+
$: valueIndex = options.findIndex(item => item.value === value)
|
|
12
|
+
const set = handler$(
|
|
13
|
+
(newValue) => value = newValue
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
const name = `${Math.random().toString(16)}-${Date.now()}`
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<svelte:component this={layout} {...$$restProps}>
|
|
20
|
+
{#each options as {value, label, disabled, ...wind}, index (value)}
|
|
21
|
+
<label use:wsx={{"$toggle": true, ...wind}} {disabled}>
|
|
22
|
+
<span>{label}</span>
|
|
23
|
+
<input type="radio" on:input={set(value)} {name} checked={index === valueIndex} />
|
|
24
|
+
</label>
|
|
25
|
+
{/each}
|
|
26
|
+
</svelte:component>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Select
|
|
2
|
+
|
|
3
|
+
A wrapper for select elements to make them look nicer.
|
|
4
|
+
|
|
5
|
+
## Base
|
|
6
|
+
[Windstorm Labeled Control](https://axel669.github.io/lib.windstorm/#components-labeled control)
|
|
7
|
+
using a `<select>`
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
11
|
+
are supported.
|
|
12
|
+
|
|
13
|
+
### color
|
|
14
|
+
`string`
|
|
15
|
+
|
|
16
|
+
Sets `$color`
|
|
17
|
+
|
|
18
|
+
### label
|
|
19
|
+
`string`
|
|
20
|
+
|
|
21
|
+
The text to display as the label
|
|
22
|
+
|
|
23
|
+
### options
|
|
24
|
+
`Array[Object]`
|
|
25
|
+
|
|
26
|
+
An array of options and groups to show in the select. Details below
|
|
27
|
+
|
|
28
|
+
### outline `bool`
|
|
29
|
+
|
|
30
|
+
Sets `$outline`
|
|
31
|
+
### value
|
|
32
|
+
`any`
|
|
33
|
+
|
|
34
|
+
The value currently selected. Can be bound to react to selections or
|
|
35
|
+
change the current selection.
|
|
36
|
+
|
|
37
|
+
## Options
|
|
38
|
+
Each object in the options provided should be in one of 2 forms:
|
|
39
|
+
- `{ label, value }`
|
|
40
|
+
- `{ group }`
|
|
41
|
+
|
|
42
|
+
Items with a label and value are displayed as <option> tags in the select.
|
|
43
|
+
Items with a group defined are used to denote <optgroup> tags. Each option
|
|
44
|
+
after a `{ group }` item until another group item is seen (or the end of the
|
|
45
|
+
array) is put into the optgroup defined by the group item.
|
|
46
|
+
|
|
47
|
+
Labels and group names should be strings, but values can be any type.
|
|
48
|
+
|
|
49
|
+
## Example
|
|
50
|
+
```svelte
|
|
51
|
+
<script>
|
|
52
|
+
// Results in:
|
|
53
|
+
// <option>first</option>
|
|
54
|
+
// <optgroup label="Not Numbers">
|
|
55
|
+
// <option>second</option>
|
|
56
|
+
// <option>third</option>
|
|
57
|
+
// </optgroup>
|
|
58
|
+
const options = [
|
|
59
|
+
{ label: "first", value: 1 },
|
|
60
|
+
{ group: "Not numbers" },
|
|
61
|
+
{ label: "second", value: "two" },
|
|
62
|
+
{ label: "third", value: [3] },
|
|
63
|
+
]
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<Select {options} bind:value label="Blep" />
|
|
67
|
+
<Select {options} bind:value color="warning" label="Why" />
|
|
68
|
+
```
|