@axel669/zephyr 0.3.4-beta.0 → 0.3.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 +33 -33
- package/readme.md +63 -63
- package/src/async/button.md +27 -27
- package/src/async/button.svelte +29 -29
- package/src/async/load-zone.md +42 -42
- package/src/async/load-zone.svelte +22 -22
- package/src/composed/data-table/th.md +21 -21
- package/src/composed/data-table/th.svelte +61 -61
- package/src/composed/data-table.md +86 -86
- package/src/composed/data-table.svelte +199 -199
- package/src/composed/entry-button.md +44 -44
- package/src/composed/entry-button.svelte +31 -31
- package/src/composed/table-functions.js +13 -13
- package/src/composed/toast/message.svelte +56 -56
- package/src/composed/toast.md +45 -45
- package/src/composed/toast.svelte +70 -70
- package/src/control/button.md +41 -41
- package/src/control/button.svelte +27 -27
- package/src/control/input.md +87 -87
- package/src/control/input.svelte +109 -109
- package/src/control/label.md +48 -48
- package/src/control/label.svelte +38 -38
- package/src/control/link.md +50 -50
- package/src/control/link.svelte +32 -32
- package/src/control/radio.md +58 -58
- package/src/control/radio.svelte +28 -28
- package/src/control/select.md +70 -70
- package/src/control/select.svelte +64 -64
- package/src/control/tabs.md +47 -47
- package/src/control/tabs.svelte +43 -43
- package/src/control/toggle.md +61 -61
- package/src/control/toggle.svelte +49 -49
- package/src/data-display/avatar.md +36 -36
- package/src/data-display/avatar.svelte +25 -25
- package/src/data-display/badge.md +30 -30
- package/src/data-display/badge.svelte +14 -14
- package/src/data-display/chip.md +36 -36
- package/src/data-display/chip.svelte +28 -28
- package/src/data-display/details.md +42 -42
- package/src/data-display/details.svelte +25 -25
- package/src/data-display/popover.md +32 -32
- package/src/data-display/popover.svelte +25 -25
- package/src/data-display/progress.md +46 -46
- package/src/data-display/progress.svelte +27 -27
- package/src/data-display/table.md +59 -59
- package/src/data-display/table.svelte +38 -38
- package/src/data-display/tooltip.md +29 -29
- package/src/data-display/tooltip.svelte +17 -17
- package/src/dialogs/alert.md +42 -42
- package/src/dialogs/alert.svelte +34 -34
- package/src/dialogs/confirm.md +56 -56
- package/src/dialogs/confirm.svelte +45 -45
- package/src/functions.md +108 -108
- package/src/handler$.mjs +20 -20
- package/src/hash.js +14 -14
- package/src/index.mjs +53 -53
- package/src/info/icon.md +21 -21
- package/src/info/icon.svelte +9 -9
- package/src/info/notification.md +36 -36
- package/src/info/notification.svelte +16 -16
- package/src/info/titlebar.md +75 -75
- package/src/info/titlebar.svelte +18 -18
- package/src/info/toaster.md +26 -26
- package/src/info/toaster.svelte +14 -14
- package/src/inline-dialog.svelte +23 -23
- package/src/layout/dialog.md +43 -43
- package/src/layout/dialog.svelte +26 -26
- package/src/layout/drawer.md +70 -70
- package/src/layout/drawer.svelte +49 -49
- package/src/layout/flex.md +43 -43
- package/src/layout/flex.svelte +26 -26
- package/src/layout/grid.md +61 -61
- package/src/layout/grid.svelte +30 -30
- package/src/layout/modal.md +50 -50
- package/src/layout/modal.svelte +60 -60
- package/src/layout/paper.md +94 -94
- package/src/layout/paper.svelte +47 -47
- package/src/layout/screen.md +33 -33
- package/src/layout/screen.svelte +34 -34
- package/src/spinner/circle-spinner.svelte +15 -15
- package/src/spinner/hexagon-spinner.svelte +15 -15
- package/src/spinner/spinners.md +22 -22
- package/src/text.md +34 -34
- package/src/text.svelte +22 -22
- package/src/variant.mjs +12 -12
- package/src/wsx.mjs +24 -24
package/src/control/link.svelte
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
<svelte:options immutable />
|
|
2
|
-
|
|
3
|
-
<script>
|
|
4
|
-
import wsx from "../wsx.mjs"
|
|
5
|
-
import variant from "../variant.mjs"
|
|
6
|
-
|
|
7
|
-
export let button = false
|
|
8
|
-
export let color = false
|
|
9
|
-
|
|
10
|
-
export let href = ""
|
|
11
|
-
export let rel = "noreferrer"
|
|
12
|
-
export let target = null
|
|
13
|
-
|
|
14
|
-
export let fill = false
|
|
15
|
-
export let outline = false
|
|
16
|
-
export let flat = false
|
|
17
|
-
|
|
18
|
-
export let disabled = null
|
|
19
|
-
|
|
20
|
-
$: type = variant({ fill, outline, flat })
|
|
21
|
-
|
|
22
|
-
$: wind = {
|
|
23
|
-
"@button": button,
|
|
24
|
-
[type]: true,
|
|
25
|
-
"$color": color,
|
|
26
|
-
...$$restProps
|
|
27
|
-
}
|
|
28
|
-
</script>
|
|
29
|
-
|
|
30
|
-
<a {href} {target} {rel} {disabled} use:wsx={wind} on:click>
|
|
31
|
-
<slot />
|
|
32
|
-
</a>
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import wsx from "../wsx.mjs"
|
|
5
|
+
import variant from "../variant.mjs"
|
|
6
|
+
|
|
7
|
+
export let button = false
|
|
8
|
+
export let color = false
|
|
9
|
+
|
|
10
|
+
export let href = ""
|
|
11
|
+
export let rel = "noreferrer"
|
|
12
|
+
export let target = null
|
|
13
|
+
|
|
14
|
+
export let fill = false
|
|
15
|
+
export let outline = false
|
|
16
|
+
export let flat = false
|
|
17
|
+
|
|
18
|
+
export let disabled = null
|
|
19
|
+
|
|
20
|
+
$: type = variant({ fill, outline, flat })
|
|
21
|
+
|
|
22
|
+
$: wind = {
|
|
23
|
+
"@button": button,
|
|
24
|
+
[type]: true,
|
|
25
|
+
"$color": color,
|
|
26
|
+
...$$restProps
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<a {href} {target} {rel} disabled={disabled || null} use:wsx={wind} on:click>
|
|
31
|
+
<slot />
|
|
32
|
+
</a>
|
package/src/control/radio.md
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
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
|
-
import { Radio, Grid } from "@axel669/zephyr"
|
|
48
|
-
|
|
49
|
-
const options = [
|
|
50
|
-
{ label: "first", value: 1 },
|
|
51
|
-
{ label: "second", value: [] },
|
|
52
|
-
{ label: "third", value: "3", "$color": "warning" }
|
|
53
|
-
]
|
|
54
|
-
</script>
|
|
55
|
-
|
|
56
|
-
<Radio {options} bind:value />
|
|
57
|
-
<Radio {options} bind:value={other} layout={Grid} gr.cols="1fr 1fr" />
|
|
58
|
-
```
|
|
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
|
+
import { Radio, Grid } from "@axel669/zephyr"
|
|
48
|
+
|
|
49
|
+
const options = [
|
|
50
|
+
{ label: "first", value: 1 },
|
|
51
|
+
{ label: "second", value: [] },
|
|
52
|
+
{ label: "third", value: "3", "$color": "warning" }
|
|
53
|
+
]
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<Radio {options} bind:value />
|
|
57
|
+
<Radio {options} bind:value={other} layout={Grid} gr.cols="1fr 1fr" />
|
|
58
|
+
```
|
package/src/control/radio.svelte
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
<svelte:options immutable />
|
|
2
|
-
|
|
3
|
-
<script>
|
|
4
|
-
import wsx from "../wsx.mjs"
|
|
5
|
-
import { handler$ } from "../handler$.mjs"
|
|
6
|
-
|
|
7
|
-
import Flex from "../layout/flex.svelte"
|
|
8
|
-
|
|
9
|
-
export let options = []
|
|
10
|
-
export let layout = Flex
|
|
11
|
-
export let value
|
|
12
|
-
|
|
13
|
-
$: valueIndex = options.findIndex(item => item.value === value)
|
|
14
|
-
const set = handler$(
|
|
15
|
-
(newValue) => value = newValue
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
const name = `${Math.random().toString(16)}-${Date.now()}`
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
<svelte:component this={layout} {...$$restProps}>
|
|
22
|
-
{#each options as {value, label, disabled, ...wind}, index (value)}
|
|
23
|
-
<label use:wsx={{"@toggle": true, ...wind}} {disabled}>
|
|
24
|
-
<span>{label}</span>
|
|
25
|
-
<input type="radio" on:input={set(value)} {name} checked={index === valueIndex} />
|
|
26
|
-
</label>
|
|
27
|
-
{/each}
|
|
28
|
-
</svelte:component>
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import wsx from "../wsx.mjs"
|
|
5
|
+
import { handler$ } from "../handler$.mjs"
|
|
6
|
+
|
|
7
|
+
import Flex from "../layout/flex.svelte"
|
|
8
|
+
|
|
9
|
+
export let options = []
|
|
10
|
+
export let layout = Flex
|
|
11
|
+
export let value
|
|
12
|
+
|
|
13
|
+
$: valueIndex = options.findIndex(item => item.value === value)
|
|
14
|
+
const set = handler$(
|
|
15
|
+
(newValue) => value = newValue
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
const name = `${Math.random().toString(16)}-${Date.now()}`
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<svelte:component this={layout} {...$$restProps}>
|
|
22
|
+
{#each options as {value, label, disabled, ...wind}, index (value)}
|
|
23
|
+
<label use:wsx={{"@toggle": true, ...wind}} {disabled}>
|
|
24
|
+
<span>{label}</span>
|
|
25
|
+
<input type="radio" on:input={set(value)} {name} checked={index === valueIndex} />
|
|
26
|
+
</label>
|
|
27
|
+
{/each}
|
|
28
|
+
</svelte:component>
|
package/src/control/select.md
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
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
|
-
import { Select } from "@axel669/zephyr"
|
|
53
|
-
|
|
54
|
-
// Results in:
|
|
55
|
-
// <option>first</option>
|
|
56
|
-
// <optgroup label="Not Numbers">
|
|
57
|
-
// <option>second</option>
|
|
58
|
-
// <option>third</option>
|
|
59
|
-
// </optgroup>
|
|
60
|
-
const options = [
|
|
61
|
-
{ label: "first", value: 1 },
|
|
62
|
-
{ group: "Not numbers" },
|
|
63
|
-
{ label: "second", value: "two" },
|
|
64
|
-
{ label: "third", value: [3] },
|
|
65
|
-
]
|
|
66
|
-
</script>
|
|
67
|
-
|
|
68
|
-
<Select {options} bind:value label="Blep" />
|
|
69
|
-
<Select {options} bind:value color="warning" label="Why" />
|
|
70
|
-
```
|
|
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
|
+
import { Select } from "@axel669/zephyr"
|
|
53
|
+
|
|
54
|
+
// Results in:
|
|
55
|
+
// <option>first</option>
|
|
56
|
+
// <optgroup label="Not Numbers">
|
|
57
|
+
// <option>second</option>
|
|
58
|
+
// <option>third</option>
|
|
59
|
+
// </optgroup>
|
|
60
|
+
const options = [
|
|
61
|
+
{ label: "first", value: 1 },
|
|
62
|
+
{ group: "Not numbers" },
|
|
63
|
+
{ label: "second", value: "two" },
|
|
64
|
+
{ label: "third", value: [3] },
|
|
65
|
+
]
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<Select {options} bind:value label="Blep" />
|
|
69
|
+
<Select {options} bind:value color="warning" label="Why" />
|
|
70
|
+
```
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
<svelte:options immutable />
|
|
2
|
-
|
|
3
|
-
<script context="module">
|
|
4
|
-
const groupOptions = (options) => options.reduce(
|
|
5
|
-
({grouped, target = grouped}, item, pos) => {
|
|
6
|
-
const opt = { ... item, pos }
|
|
7
|
-
if (item.group === undefined) {
|
|
8
|
-
target.push(opt)
|
|
9
|
-
return { grouped, target }
|
|
10
|
-
}
|
|
11
|
-
const next = [opt]
|
|
12
|
-
grouped.push(next)
|
|
13
|
-
return { grouped, target: next }
|
|
14
|
-
},
|
|
15
|
-
{ grouped: [] }
|
|
16
|
-
).grouped
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<script>
|
|
20
|
-
import wsx from "../wsx.mjs"
|
|
21
|
-
|
|
22
|
-
export let options = []
|
|
23
|
-
export let value
|
|
24
|
-
export let color = "default"
|
|
25
|
-
export let outline = false
|
|
26
|
-
export let label = null
|
|
27
|
-
export let disabled = false
|
|
28
|
-
|
|
29
|
-
const update = (evt) => value = options[evt.target.value].value
|
|
30
|
-
|
|
31
|
-
$: indexValue = options.findIndex(item => item.value === value)
|
|
32
|
-
|
|
33
|
-
$: grouped = groupOptions(options)
|
|
34
|
-
|
|
35
|
-
$: wind = {
|
|
36
|
-
"@control": true,
|
|
37
|
-
"$outline": outline,
|
|
38
|
-
"$color": color,
|
|
39
|
-
...$$restProps,
|
|
40
|
-
}
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<label use:wsx={wind}>
|
|
44
|
-
{#if label}
|
|
45
|
-
<span ws-x="[$label-text]">{label}</span>
|
|
46
|
-
{/if}
|
|
47
|
-
<select value={indexValue} on:input={update} {disabled}>
|
|
48
|
-
{#each grouped as item, index}
|
|
49
|
-
{#if Array.isArray(item) === false}
|
|
50
|
-
<option value={item.pos}>
|
|
51
|
-
{item.label}
|
|
52
|
-
</option>
|
|
53
|
-
{:else}
|
|
54
|
-
<optgroup label={item[0].group}>
|
|
55
|
-
{#each item.slice(1) as subitem, subindex}
|
|
56
|
-
<option value={subitem.pos}>
|
|
57
|
-
{subitem.label}
|
|
58
|
-
</option>
|
|
59
|
-
{/each}
|
|
60
|
-
</optgroup>
|
|
61
|
-
{/if}
|
|
62
|
-
{/each}
|
|
63
|
-
</select>
|
|
64
|
-
</label>
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script context="module">
|
|
4
|
+
const groupOptions = (options) => options.reduce(
|
|
5
|
+
({grouped, target = grouped}, item, pos) => {
|
|
6
|
+
const opt = { ... item, pos }
|
|
7
|
+
if (item.group === undefined) {
|
|
8
|
+
target.push(opt)
|
|
9
|
+
return { grouped, target }
|
|
10
|
+
}
|
|
11
|
+
const next = [opt]
|
|
12
|
+
grouped.push(next)
|
|
13
|
+
return { grouped, target: next }
|
|
14
|
+
},
|
|
15
|
+
{ grouped: [] }
|
|
16
|
+
).grouped
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
import wsx from "../wsx.mjs"
|
|
21
|
+
|
|
22
|
+
export let options = []
|
|
23
|
+
export let value
|
|
24
|
+
export let color = "default"
|
|
25
|
+
export let outline = false
|
|
26
|
+
export let label = null
|
|
27
|
+
export let disabled = false
|
|
28
|
+
|
|
29
|
+
const update = (evt) => value = options[evt.target.value].value
|
|
30
|
+
|
|
31
|
+
$: indexValue = options.findIndex(item => item.value === value)
|
|
32
|
+
|
|
33
|
+
$: grouped = groupOptions(options)
|
|
34
|
+
|
|
35
|
+
$: wind = {
|
|
36
|
+
"@control": true,
|
|
37
|
+
"$outline": outline,
|
|
38
|
+
"$color": color,
|
|
39
|
+
...$$restProps,
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<label use:wsx={wind}>
|
|
44
|
+
{#if label}
|
|
45
|
+
<span ws-x="[$label-text]">{label}</span>
|
|
46
|
+
{/if}
|
|
47
|
+
<select value={indexValue} on:input={update} {disabled}>
|
|
48
|
+
{#each grouped as item, index}
|
|
49
|
+
{#if Array.isArray(item) === false}
|
|
50
|
+
<option value={item.pos}>
|
|
51
|
+
{item.label}
|
|
52
|
+
</option>
|
|
53
|
+
{:else}
|
|
54
|
+
<optgroup label={item[0].group}>
|
|
55
|
+
{#each item.slice(1) as subitem, subindex}
|
|
56
|
+
<option value={subitem.pos}>
|
|
57
|
+
{subitem.label}
|
|
58
|
+
</option>
|
|
59
|
+
{/each}
|
|
60
|
+
</optgroup>
|
|
61
|
+
{/if}
|
|
62
|
+
{/each}
|
|
63
|
+
</select>
|
|
64
|
+
</label>
|
package/src/control/tabs.md
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
# Tabs
|
|
2
|
-
|
|
3
|
-
It's tabs, everyone knows what tabs are at this point.
|
|
4
|
-
|
|
5
|
-
## Props
|
|
6
|
-
|
|
7
|
-
### color
|
|
8
|
-
`string`
|
|
9
|
-
|
|
10
|
-
Sets `$color`
|
|
11
|
-
|
|
12
|
-
### options
|
|
13
|
-
`Array[Object]`
|
|
14
|
-
|
|
15
|
-
An array of options where each item is `{ label, value }`. `label`
|
|
16
|
-
should be a string, `value` can be of any type.
|
|
17
|
-
|
|
18
|
-
### vertical
|
|
19
|
-
`bool`
|
|
20
|
-
|
|
21
|
-
Sets `$vert`
|
|
22
|
-
|
|
23
|
-
### solid
|
|
24
|
-
`bool`
|
|
25
|
-
|
|
26
|
-
Sets `$solid`
|
|
27
|
-
|
|
28
|
-
### value
|
|
29
|
-
`any`
|
|
30
|
-
|
|
31
|
-
The value of the currently selected tab. Can be bound to react to
|
|
32
|
-
changes and set to control which tab is selected.
|
|
33
|
-
|
|
34
|
-
## Example
|
|
35
|
-
```svelte
|
|
36
|
-
<script>
|
|
37
|
-
import { Tabs } from "@axel669/zephyr"
|
|
38
|
-
|
|
39
|
-
const options = [
|
|
40
|
-
{ label: "Left", value: "left" },
|
|
41
|
-
{ label: "Right", value: 2 },
|
|
42
|
-
]
|
|
43
|
-
</script>
|
|
44
|
-
|
|
45
|
-
<Tab {options} bind:value color="primary" />
|
|
46
|
-
<Tab {options} bind:value color="secondary" solid vertical />
|
|
47
|
-
```
|
|
1
|
+
# Tabs
|
|
2
|
+
|
|
3
|
+
It's tabs, everyone knows what tabs are at this point.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### color
|
|
8
|
+
`string`
|
|
9
|
+
|
|
10
|
+
Sets `$color`
|
|
11
|
+
|
|
12
|
+
### options
|
|
13
|
+
`Array[Object]`
|
|
14
|
+
|
|
15
|
+
An array of options where each item is `{ label, value }`. `label`
|
|
16
|
+
should be a string, `value` can be of any type.
|
|
17
|
+
|
|
18
|
+
### vertical
|
|
19
|
+
`bool`
|
|
20
|
+
|
|
21
|
+
Sets `$vert`
|
|
22
|
+
|
|
23
|
+
### solid
|
|
24
|
+
`bool`
|
|
25
|
+
|
|
26
|
+
Sets `$solid`
|
|
27
|
+
|
|
28
|
+
### value
|
|
29
|
+
`any`
|
|
30
|
+
|
|
31
|
+
The value of the currently selected tab. Can be bound to react to
|
|
32
|
+
changes and set to control which tab is selected.
|
|
33
|
+
|
|
34
|
+
## Example
|
|
35
|
+
```svelte
|
|
36
|
+
<script>
|
|
37
|
+
import { Tabs } from "@axel669/zephyr"
|
|
38
|
+
|
|
39
|
+
const options = [
|
|
40
|
+
{ label: "Left", value: "left" },
|
|
41
|
+
{ label: "Right", value: 2 },
|
|
42
|
+
]
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<Tab {options} bind:value color="primary" />
|
|
46
|
+
<Tab {options} bind:value color="secondary" solid vertical />
|
|
47
|
+
```
|