@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
package/src/select.svelte
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
<script context="module">
|
|
2
|
-
const groupOptions = (options) => options.reduce(
|
|
3
|
-
({grouped, target = grouped}, item, pos) => {
|
|
4
|
-
const opt = { ... item, pos }
|
|
5
|
-
if (item.group === undefined) {
|
|
6
|
-
target.push(opt)
|
|
7
|
-
return { grouped, target }
|
|
8
|
-
}
|
|
9
|
-
const next = [opt]
|
|
10
|
-
grouped.push(next)
|
|
11
|
-
return { grouped, target: next }
|
|
12
|
-
},
|
|
13
|
-
{ grouped: [] }
|
|
14
|
-
).grouped
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<script>
|
|
18
|
-
/*md
|
|
19
|
-
[@] Components/Input/Select
|
|
20
|
-
|
|
21
|
-
# Select
|
|
22
|
-
|
|
23
|
-
A wrapper for select elements to make them look nicer.
|
|
24
|
-
|
|
25
|
-
## Base
|
|
26
|
-
[Windstorm Labeled Control](https://axel669.github.io/lib.windstorm/#components-labeled control)
|
|
27
|
-
using a `<select>`
|
|
28
|
-
|
|
29
|
-
## Props
|
|
30
|
-
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
31
|
-
are supported.
|
|
32
|
-
|
|
33
|
-
- ### color `string`
|
|
34
|
-
Sets `$color`
|
|
35
|
-
- ### label `string`
|
|
36
|
-
The text to display as the label
|
|
37
|
-
- ### options `Array[Object]`
|
|
38
|
-
An array of options and groups to show in the select. Details below
|
|
39
|
-
- ### outline `bool`
|
|
40
|
-
Sets `@outline`
|
|
41
|
-
- ### value `any`
|
|
42
|
-
The value currently selected. Can be bound to react to selections or
|
|
43
|
-
change the current selection.
|
|
44
|
-
|
|
45
|
-
## Options
|
|
46
|
-
Each object in the options provided should be in one of 2 forms:
|
|
47
|
-
- `{ label, value }`
|
|
48
|
-
- `{ group }`
|
|
49
|
-
|
|
50
|
-
Items with a label and value are displayed as <option> tags in the select.
|
|
51
|
-
Items with a group defined are used to denote <optgroup> tags. Each option
|
|
52
|
-
after a `{ group }` item until another group item is seen (or the end of the
|
|
53
|
-
array) is put into the optgroup defined by the group item.
|
|
54
|
-
|
|
55
|
-
Labels and group names should be strings, but values can be any type.
|
|
56
|
-
|
|
57
|
-
## Usage
|
|
58
|
-
```js
|
|
59
|
-
// Results in:
|
|
60
|
-
// <option>first</option>
|
|
61
|
-
// <optgroup label="Not Numbers">
|
|
62
|
-
// <option>second</option>
|
|
63
|
-
// <option>third</option>
|
|
64
|
-
// </optgroup>
|
|
65
|
-
const options = [
|
|
66
|
-
{ label: "first", value: 1 },
|
|
67
|
-
{ group: "Not numbers" },
|
|
68
|
-
{ label: "second", value: "two" },
|
|
69
|
-
{ label: "third", value: [3] },
|
|
70
|
-
]
|
|
71
|
-
```
|
|
72
|
-
```svelte
|
|
73
|
-
<Select {options} bind:value label="Blep" />
|
|
74
|
-
<Select {options} bind:value color="warning" label="Why" />
|
|
75
|
-
```
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
import wsx from "./wsx.mjs"
|
|
79
|
-
|
|
80
|
-
export let options = []
|
|
81
|
-
export let value
|
|
82
|
-
export let color = "default"
|
|
83
|
-
export let outline = false
|
|
84
|
-
export let label = null
|
|
85
|
-
export let disabled = false
|
|
86
|
-
|
|
87
|
-
const update = (evt) => value = options[evt.target.value].value
|
|
88
|
-
|
|
89
|
-
$: indexValue = options.findIndex(item => item.value === value)
|
|
90
|
-
|
|
91
|
-
$: grouped = groupOptions(options)
|
|
92
|
-
|
|
93
|
-
$: wind = {
|
|
94
|
-
"@control": true,
|
|
95
|
-
"@outline": outline,
|
|
96
|
-
$color: color,
|
|
97
|
-
...$$restProps,
|
|
98
|
-
}
|
|
99
|
-
</script>
|
|
100
|
-
|
|
101
|
-
<label use:wsx={wind}>
|
|
102
|
-
{#if label}
|
|
103
|
-
<span ws-x="$text">{label}</span>
|
|
104
|
-
{/if}
|
|
105
|
-
<select value={indexValue} on:input={update} {disabled}>
|
|
106
|
-
{#each grouped as item, index}
|
|
107
|
-
{#if Array.isArray(item) === false}
|
|
108
|
-
<option value={item.pos}>
|
|
109
|
-
{item.label}
|
|
110
|
-
</option>
|
|
111
|
-
{:else}
|
|
112
|
-
<optgroup label={item[0].group}>
|
|
113
|
-
{#each item.slice(1) as subitem, subindex}
|
|
114
|
-
<option value={subitem.pos}>
|
|
115
|
-
{subitem.label}
|
|
116
|
-
</option>
|
|
117
|
-
{/each}
|
|
118
|
-
</optgroup>
|
|
119
|
-
{/if}
|
|
120
|
-
{/each}
|
|
121
|
-
</select>
|
|
122
|
-
</label>
|
package/src/table.svelte
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/*md
|
|
3
|
-
[@] Components/Data Display/Table
|
|
4
|
-
|
|
5
|
-
# Table
|
|
6
|
-
|
|
7
|
-
Displays data using html tables with some nice styling. This version of the
|
|
8
|
-
table is fairly simple and intended for basic data displays. For more
|
|
9
|
-
complex data displays the DataTable should be used.
|
|
10
|
-
|
|
11
|
-
## Base
|
|
12
|
-
[Windstorm Table](https://axel669.github.io/lib.windstorm/#components-table)
|
|
13
|
-
|
|
14
|
-
## Props
|
|
15
|
-
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
16
|
-
are supported.
|
|
17
|
-
|
|
18
|
-
- ### color `string`
|
|
19
|
-
Sets `$color`
|
|
20
|
-
- ### cols `Array`
|
|
21
|
-
The columns that should be displayed. Should be in the format of
|
|
22
|
-
`{ label, width? }`
|
|
23
|
-
- ### data `Array[Array]`
|
|
24
|
-
The data to display. The data should be an array where each item is a
|
|
25
|
-
row, and each item in the row is the value for a column.
|
|
26
|
-
- ### cellWSX `function`
|
|
27
|
-
If given, this function will be called for each cell, and should return
|
|
28
|
-
an object that will be passed to the `wsx` action for each <td>
|
|
29
|
-
generated. The function is passed `(cellValue, rowNum, colNum)`.
|
|
30
|
-
- ### rowWSX `function`
|
|
31
|
-
If given, this function will be called for each row, and should return
|
|
32
|
-
an object that will be passed to the `wsx` action for each <tr>
|
|
33
|
-
generated. The function is passed `(rowValue, rowNum)`.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
import wsx from "./wsx.mjs"
|
|
37
|
-
|
|
38
|
-
export let color = false
|
|
39
|
-
export let data = []
|
|
40
|
-
export let cols = []
|
|
41
|
-
export let rowWSX = null
|
|
42
|
-
export let cellWSX = null
|
|
43
|
-
|
|
44
|
-
$: wind = {
|
|
45
|
-
$color: color,
|
|
46
|
-
...$$restProps,
|
|
47
|
-
}
|
|
48
|
-
</script>
|
|
49
|
-
|
|
50
|
-
<table use:wsx={wind}>
|
|
51
|
-
<thead>
|
|
52
|
-
<tr>
|
|
53
|
-
{#each cols as col}
|
|
54
|
-
<th use:wsx={{ w: col.width }}>{col.label}</th>
|
|
55
|
-
{/each}
|
|
56
|
-
</tr>
|
|
57
|
-
</thead>
|
|
58
|
-
<tbody>
|
|
59
|
-
{#each data as row, rowNum}
|
|
60
|
-
<tr use:wsx={rowWSX?.(row, rowNum)}>
|
|
61
|
-
{#each row as cell, colNum}
|
|
62
|
-
<td use:wsx={cellWSX?.(cell, rowNum, colNum)}>
|
|
63
|
-
{cell}
|
|
64
|
-
</td>
|
|
65
|
-
{/each}
|
|
66
|
-
</tr>
|
|
67
|
-
{/each}
|
|
68
|
-
</tbody>
|
|
69
|
-
</table>
|
package/src/tabs.svelte
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/*md
|
|
3
|
-
[@] Components/Tabs
|
|
4
|
-
|
|
5
|
-
# Tabs
|
|
6
|
-
|
|
7
|
-
It's tabs, everyone knows what tabs are at this point.
|
|
8
|
-
|
|
9
|
-
## Base
|
|
10
|
-
[Windstorm Tabs](https://axel669.github.io/lib.windstorm/#components-tabs)
|
|
11
|
-
|
|
12
|
-
## Props
|
|
13
|
-
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
14
|
-
are supported.
|
|
15
|
-
|
|
16
|
-
- ### color `string`
|
|
17
|
-
Sets `$color`
|
|
18
|
-
- ### options `Array[Object]`
|
|
19
|
-
An array of options where each item is `{ label, value }`. `label`
|
|
20
|
-
should be a string, `value` can be of any type.
|
|
21
|
-
- ### vertical `bool`
|
|
22
|
-
Sets `$vert`
|
|
23
|
-
- ### solid `bool`
|
|
24
|
-
Sets `$solid`
|
|
25
|
-
- ### value `any`
|
|
26
|
-
The value of the currently selected tab. Can be bound to react to
|
|
27
|
-
changes and set to control which tab is selected.
|
|
28
|
-
|
|
29
|
-
## Usage
|
|
30
|
-
```js
|
|
31
|
-
const options = [
|
|
32
|
-
{ label: "Left", value: "left" },
|
|
33
|
-
{ label: "Right", value: 2 },
|
|
34
|
-
]
|
|
35
|
-
```
|
|
36
|
-
```svelte
|
|
37
|
-
<Tab {options} bind:value color="primary" />
|
|
38
|
-
<Tab {options} bind:value color="secondary" solid vertical />
|
|
39
|
-
```
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
import wsx from "./wsx.mjs"
|
|
43
|
-
import { handler$ } from "./handler$.mjs"
|
|
44
|
-
|
|
45
|
-
export let color = "primary"
|
|
46
|
-
export let options = []
|
|
47
|
-
export let vertical = false
|
|
48
|
-
export let solid = false
|
|
49
|
-
export let value
|
|
50
|
-
|
|
51
|
-
$: index = options.findIndex(item => item.value === value)
|
|
52
|
-
|
|
53
|
-
const set = handler$(
|
|
54
|
-
(next) => {
|
|
55
|
-
if (value === next) {
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
value = next
|
|
59
|
-
}
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
$: wind = {
|
|
63
|
-
"@solid": solid,
|
|
64
|
-
$color: color,
|
|
65
|
-
$vert: vertical,
|
|
66
|
-
...$$restProps,
|
|
67
|
-
}
|
|
68
|
-
</script>
|
|
69
|
-
|
|
70
|
-
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
71
|
-
<ws-tabs use:wsx={wind}>
|
|
72
|
-
{#each options as tab, i}
|
|
73
|
-
<ws-tab use:wsx={{"$tab-selected": index === i}}
|
|
74
|
-
on:click={set(tab.value)}>
|
|
75
|
-
{tab.label}
|
|
76
|
-
</ws-tab>
|
|
77
|
-
{/each}
|
|
78
|
-
</ws-tabs>
|
package/src/titlebar.svelte
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/*md
|
|
3
|
-
[@] Components/Titlebar
|
|
4
|
-
|
|
5
|
-
# Titlebar
|
|
6
|
-
|
|
7
|
-
The titlebar is used to set section titles with some style, and provides
|
|
8
|
-
slots for buttons on either side of the title text. Works well as a header
|
|
9
|
-
for Paper components.
|
|
10
|
-
|
|
11
|
-
## Base
|
|
12
|
-
[Windstorm Titlebar](https://axel669.github.io/lib.windstorm/#components-titlebar)
|
|
13
|
-
|
|
14
|
-
## Props
|
|
15
|
-
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
16
|
-
are supported.
|
|
17
|
-
|
|
18
|
-
- ### color `string`
|
|
19
|
-
Sets `$color`
|
|
20
|
-
- ### fill `bool`
|
|
21
|
-
Sets `@fill`
|
|
22
|
-
|
|
23
|
-
## Slots
|
|
24
|
-
- title\\
|
|
25
|
-
The center of the titlebar, where the text usually goes
|
|
26
|
-
- menu\\
|
|
27
|
-
The area on the left of the titlebar (where drawer menus tend to open)
|
|
28
|
-
- action\\
|
|
29
|
-
The area on the right of the titlebar
|
|
30
|
-
|
|
31
|
-
## Usage
|
|
32
|
-
```svelte
|
|
33
|
-
<Titlebar color="primary" fill>
|
|
34
|
-
<Text title slot="title">
|
|
35
|
-
Some Title
|
|
36
|
-
</Text>
|
|
37
|
-
|
|
38
|
-
<Button slot="menu" color={false}>
|
|
39
|
-
<Icon name="menu" />
|
|
40
|
-
</Button>
|
|
41
|
-
</Titlebar>
|
|
42
|
-
|
|
43
|
-
<Paper>
|
|
44
|
-
<Titlebar color="secondary" slot="header">
|
|
45
|
-
<Text title slot="title">
|
|
46
|
-
Paper Title
|
|
47
|
-
</Text>
|
|
48
|
-
</Titlebar>
|
|
49
|
-
</Paper>
|
|
50
|
-
```
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
import wsx from "./wsx.mjs"
|
|
54
|
-
|
|
55
|
-
export let color
|
|
56
|
-
export let fill = false
|
|
57
|
-
|
|
58
|
-
$: wind = {
|
|
59
|
-
$color: color,
|
|
60
|
-
"@fill": fill,
|
|
61
|
-
...$$restProps
|
|
62
|
-
}
|
|
63
|
-
</script>
|
|
64
|
-
|
|
65
|
-
<ws-titlebar use:wsx={wind}>
|
|
66
|
-
<slot name="menu" />
|
|
67
|
-
<slot name="title" />
|
|
68
|
-
<slot name="action" />
|
|
69
|
-
</ws-titlebar>
|
package/src/toaster.svelte
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/*md
|
|
3
|
-
[@] Components/Containers/Toaster
|
|
4
|
-
|
|
5
|
-
# Toaster
|
|
6
|
-
|
|
7
|
-
The Toaster component is used for building popup notifications along the
|
|
8
|
-
edges of the window.
|
|
9
|
-
|
|
10
|
-
## Base
|
|
11
|
-
[Windstorm Toaster](https://axel669.github.io/lib.windstorm/#components-toaster)
|
|
12
|
-
|
|
13
|
-
## Props
|
|
14
|
-
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
15
|
-
are supported, but probably not very meaningful for this container.
|
|
16
|
-
|
|
17
|
-
- ### position
|
|
18
|
-
Sets position of the toaster. See the windstorm base for values.
|
|
19
|
-
|
|
20
|
-
## Usage
|
|
21
|
-
<Toaster position="$tc">
|
|
22
|
-
<Notification>
|
|
23
|
-
<Icon name="info">
|
|
24
|
-
Some kind of notification of things
|
|
25
|
-
</Icon>
|
|
26
|
-
</Notification>
|
|
27
|
-
</Toaster>
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
import wsx from "./wsx.mjs"
|
|
31
|
-
|
|
32
|
-
export let position = "tc"
|
|
33
|
-
|
|
34
|
-
$: wind = {
|
|
35
|
-
[`$${position}`]: true,
|
|
36
|
-
...$$restProps,
|
|
37
|
-
}
|
|
38
|
-
</script>
|
|
39
|
-
|
|
40
|
-
<ws-toaster use:wsx={wind}>
|
|
41
|
-
<slot />
|
|
42
|
-
</ws-toaster>
|
package/src/toggle.svelte
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/*md
|
|
3
|
-
[@] Components/Input/Toggle
|
|
4
|
-
|
|
5
|
-
# Toggle
|
|
6
|
-
|
|
7
|
-
The Toggle component is used to display checkboxes and switches.
|
|
8
|
-
|
|
9
|
-
## Base
|
|
10
|
-
[Windstorm Labeled Toggle](https://axel669.github.io/lib.windstorm/#components-labeled-toggle)
|
|
11
|
-
using a checkbox input
|
|
12
|
-
|
|
13
|
-
## Props
|
|
14
|
-
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
15
|
-
are supported.
|
|
16
|
-
|
|
17
|
-
- ### color `string`
|
|
18
|
-
Sets `$color`
|
|
19
|
-
- ### checkbox `bool`
|
|
20
|
-
If true, the toggle is displayed as a checkbox. Default is false
|
|
21
|
-
(shown as a switch)
|
|
22
|
-
- ### checked `bool`
|
|
23
|
-
Controls if the toggle is checked or not. Can be bound
|
|
24
|
-
- ### group
|
|
25
|
-
Used for binding, see the Svelte bind:group for details
|
|
26
|
-
- ### label `string`
|
|
27
|
-
The text to use for the label
|
|
28
|
-
- ### flat `bool`
|
|
29
|
-
Sets `@flat`
|
|
30
|
-
- ### reverse `bool`
|
|
31
|
-
If true, the input being toggled will be on the left instead of the
|
|
32
|
-
right. Default is false (label is on the left)
|
|
33
|
-
- ### value
|
|
34
|
-
Only used in conjunction with bind:group, see Svelte docs
|
|
35
|
-
|
|
36
|
-
## Usage
|
|
37
|
-
```svelte
|
|
38
|
-
<Toggle label="Active" bind:checked />
|
|
39
|
-
<Toggle label="Active" checkbox bind:checked />
|
|
40
|
-
<Toggle label="Active" checkbox reverse bind:checked />
|
|
41
|
-
<Toggle label="Active" checkbox flat color="danger" bind:checked />
|
|
42
|
-
```
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
import wsx from "./wsx.mjs"
|
|
46
|
-
|
|
47
|
-
export let label = ""
|
|
48
|
-
export let color = "default"
|
|
49
|
-
export let checked = false
|
|
50
|
-
export let flat = false
|
|
51
|
-
export let value
|
|
52
|
-
export let group = []
|
|
53
|
-
export let checkbox = false
|
|
54
|
-
export let reverse = false
|
|
55
|
-
|
|
56
|
-
$: container = {
|
|
57
|
-
"@toggle": true,
|
|
58
|
-
"@flat": flat,
|
|
59
|
-
$color: color,
|
|
60
|
-
...$$restProps,
|
|
61
|
-
}
|
|
62
|
-
$: input = {
|
|
63
|
-
"$switch": checkbox === false
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const updateGroup = (checked) => {
|
|
67
|
-
if (checked === true) {
|
|
68
|
-
if (group.includes(value) === true) {
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
group = [...group, value]
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
if (group.includes(value) === false) {
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
group = group.filter(item => item !== value)
|
|
78
|
-
}
|
|
79
|
-
$: updateGroup(checked)
|
|
80
|
-
</script>
|
|
81
|
-
|
|
82
|
-
<label use:wsx={container}>
|
|
83
|
-
{#if reverse !== true}
|
|
84
|
-
{#if $$slots.default}
|
|
85
|
-
<slot />
|
|
86
|
-
{:else}
|
|
87
|
-
<span>{label}</span>
|
|
88
|
-
{/if}
|
|
89
|
-
{/if}
|
|
90
|
-
<input type="checkbox" bind:checked use:wsx={input} />
|
|
91
|
-
{#if reverse === true}
|
|
92
|
-
<span>{label}</span>
|
|
93
|
-
{/if}
|
|
94
|
-
</label>
|
package/src/tooltip.svelte
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/*md
|
|
3
|
-
[@] Components/Data Display/Tooltip
|
|
4
|
-
|
|
5
|
-
# Tooltip
|
|
6
|
-
|
|
7
|
-
Displays a tooltip above (or below) some content when it's hovered.
|
|
8
|
-
|
|
9
|
-
## Base
|
|
10
|
-
[Windstorm Tooltip](https://axel669.github.io/lib.windstorm/#components-tooltip)
|
|
11
|
-
|
|
12
|
-
## Props
|
|
13
|
-
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
14
|
-
are supported.
|
|
15
|
-
|
|
16
|
-
- ### text `string`
|
|
17
|
-
The text to display in the tooltip.
|
|
18
|
-
- ### bottom `bool`
|
|
19
|
-
If true, the tooltip will be shown under the content instead of over.
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
```svelte
|
|
23
|
-
<Tooltip text="This is a button">
|
|
24
|
-
<Button>Do Thing</Button>
|
|
25
|
-
</Tooltip>
|
|
26
|
-
<Tooltip text="This shows under" bottom>
|
|
27
|
-
Just some text content
|
|
28
|
-
</Tooltip>
|
|
29
|
-
```
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
import wsx from "./wsx.mjs"
|
|
33
|
-
|
|
34
|
-
export let text = ""
|
|
35
|
-
export let bottom = false
|
|
36
|
-
|
|
37
|
-
$: wind = {
|
|
38
|
-
$bottom: bottom,
|
|
39
|
-
...$$restProps,
|
|
40
|
-
}
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<ws-tooltip ws-text={text} use:wsx={wind}>
|
|
44
|
-
<slot />
|
|
45
|
-
</ws-tooltip>
|
package/src/vars.mjs
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/*md
|
|
2
|
-
[@] Actions/vars
|
|
3
|
-
|
|
4
|
-
# vars Action
|
|
5
|
-
|
|
6
|
-
The vars action is used to set css variables on dom elements using a simple
|
|
7
|
-
object to maintain the values instead of needing to do string interpolation and
|
|
8
|
-
falsey checks manually.
|
|
9
|
-
|
|
10
|
-
## Usage
|
|
11
|
-
```js
|
|
12
|
-
// Sets --screen-widt to 100% and unsets --other-thing
|
|
13
|
-
$: settings = {
|
|
14
|
-
"screen-width": "100%",
|
|
15
|
-
"other-thing": null,
|
|
16
|
-
}
|
|
17
|
-
```
|
|
18
|
-
```svelte
|
|
19
|
-
<ws-screen use:vars={settings}>
|
|
20
|
-
</ws-screen>
|
|
21
|
-
```
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
const calcValue = value => {
|
|
25
|
-
if (Array.isArray(value) === false) {
|
|
26
|
-
return value
|
|
27
|
-
}
|
|
28
|
-
if (value[0] === null || value[0] === undefined) {
|
|
29
|
-
return null
|
|
30
|
-
}
|
|
31
|
-
return value.join("")
|
|
32
|
-
}
|
|
33
|
-
const udpateVars = (node, current, next) => {
|
|
34
|
-
const keys = new Set([
|
|
35
|
-
...Object.keys(current),
|
|
36
|
-
...Object.keys(next),
|
|
37
|
-
])
|
|
38
|
-
for (const key of keys) {
|
|
39
|
-
const varName = `--${key}`
|
|
40
|
-
const currentValue = calcValue(current[key])
|
|
41
|
-
const nextValue = calcValue(next[key])
|
|
42
|
-
if (nextValue === undefined || nextValue === null) {
|
|
43
|
-
node.style.removeProperty(varName)
|
|
44
|
-
}
|
|
45
|
-
if (currentValue !== nextValue) {
|
|
46
|
-
node.style.setProperty(varName, nextValue)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
const vars = (node, vars) => {
|
|
51
|
-
let currentVars = vars
|
|
52
|
-
udpateVars(node, {}, currentVars)
|
|
53
|
-
return {
|
|
54
|
-
update(newVars) {
|
|
55
|
-
udpateVars(node, currentVars, newVars)
|
|
56
|
-
currentVars = newVars
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export default vars
|