@axel669/zephyr 0.2.0-beta.3 → 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.
Files changed (86) hide show
  1. package/package.json +33 -33
  2. package/readme.md +63 -63
  3. package/src/async/button.md +27 -0
  4. package/src/async/button.svelte +29 -31
  5. package/src/async/load-zone.md +42 -0
  6. package/src/async/load-zone.svelte +22 -20
  7. package/src/composed/data-table/th.md +21 -0
  8. package/src/composed/data-table/th.svelte +61 -61
  9. package/src/composed/data-table.md +86 -85
  10. package/src/composed/data-table.svelte +199 -149
  11. package/src/composed/entry-button.md +44 -34
  12. package/src/composed/entry-button.svelte +31 -31
  13. package/src/composed/table-functions.js +13 -13
  14. package/src/composed/toast/message.svelte +56 -56
  15. package/src/composed/toast.md +45 -36
  16. package/src/composed/toast.svelte +70 -70
  17. package/src/control/button.md +41 -41
  18. package/src/control/button.svelte +27 -27
  19. package/src/control/input.md +87 -0
  20. package/src/control/input.svelte +109 -109
  21. package/src/control/label.md +48 -49
  22. package/src/control/label.svelte +38 -38
  23. package/src/control/link.md +50 -50
  24. package/src/control/link.svelte +32 -30
  25. package/src/control/radio.md +58 -58
  26. package/src/control/radio.svelte +28 -28
  27. package/src/control/select.md +70 -70
  28. package/src/control/select.svelte +64 -64
  29. package/src/control/tabs.md +47 -47
  30. package/src/control/tabs.svelte +43 -41
  31. package/src/control/toggle.md +61 -61
  32. package/src/control/toggle.svelte +49 -49
  33. package/src/data-display/avatar.md +36 -36
  34. package/src/data-display/avatar.svelte +25 -25
  35. package/src/data-display/badge.md +30 -30
  36. package/src/data-display/badge.svelte +14 -14
  37. package/src/data-display/chip.md +36 -36
  38. package/src/data-display/chip.svelte +28 -28
  39. package/src/data-display/details.md +42 -3
  40. package/src/data-display/details.svelte +25 -25
  41. package/src/data-display/popover.md +32 -32
  42. package/src/data-display/popover.svelte +25 -25
  43. package/src/data-display/progress.md +46 -46
  44. package/src/data-display/progress.svelte +27 -27
  45. package/src/data-display/table.md +59 -7
  46. package/src/data-display/table.svelte +38 -38
  47. package/src/data-display/tooltip.md +29 -29
  48. package/src/data-display/tooltip.svelte +17 -17
  49. package/src/dialogs/alert.md +42 -3
  50. package/src/dialogs/alert.svelte +34 -34
  51. package/src/dialogs/confirm.md +56 -3
  52. package/src/dialogs/confirm.svelte +45 -45
  53. package/src/functions.md +108 -83
  54. package/src/handler$.mjs +20 -20
  55. package/src/hash.js +14 -0
  56. package/src/index.mjs +53 -52
  57. package/src/info/icon.md +21 -21
  58. package/src/info/icon.svelte +9 -9
  59. package/src/info/notification.md +36 -36
  60. package/src/info/notification.svelte +16 -16
  61. package/src/info/titlebar.md +75 -75
  62. package/src/info/titlebar.svelte +18 -18
  63. package/src/info/toaster.md +26 -26
  64. package/src/info/toaster.svelte +14 -14
  65. package/src/inline-dialog.svelte +23 -23
  66. package/src/layout/dialog.md +43 -43
  67. package/src/layout/dialog.svelte +26 -26
  68. package/src/layout/drawer.md +70 -70
  69. package/src/layout/drawer.svelte +49 -49
  70. package/src/layout/flex.md +43 -43
  71. package/src/layout/flex.svelte +26 -24
  72. package/src/layout/grid.md +61 -61
  73. package/src/layout/grid.svelte +30 -28
  74. package/src/layout/modal.md +50 -50
  75. package/src/layout/modal.svelte +60 -60
  76. package/src/layout/paper.md +94 -94
  77. package/src/layout/paper.svelte +47 -47
  78. package/src/layout/screen.md +33 -33
  79. package/src/layout/screen.svelte +34 -34
  80. package/src/spinner/circle-spinner.svelte +15 -15
  81. package/src/spinner/hexagon-spinner.svelte +15 -15
  82. package/src/spinner/spinners.md +22 -3
  83. package/src/text.md +34 -34
  84. package/src/text.svelte +22 -22
  85. package/src/variant.mjs +12 -12
  86. package/src/wsx.mjs +24 -24
@@ -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>
@@ -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="$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>
@@ -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
+ ```
@@ -1,41 +1,43 @@
1
- <svelte:options immutable />
2
-
3
- <script>
4
- import wsx from "../wsx.mjs"
5
- import { handler$ } from "../handler$.mjs"
6
-
7
- export let color = "primary"
8
- export let options = []
9
- export let vertical = false
10
- export let solid = false
11
- export let value
12
-
13
- $: index = options.findIndex(item => item.value === value)
14
-
15
- const set = handler$(
16
- (next) => {
17
- if (value === next) {
18
- return
19
- }
20
- value = next
21
- }
22
- )
23
-
24
- $: wind = {
25
- "$solid": solid,
26
- "$color": color,
27
- $vert: vertical,
28
- ...$$restProps,
29
- }
30
- </script>
31
-
32
- <!-- svelte-ignore a11y-click-events-have-key-events -->
33
- <ws-tabs use:wsx={wind} role="tablist">
34
- {#each options as tab, i}
35
- <!-- svelte-ignore a11y-interactive-supports-focus -->
36
- <ws-tab use:wsx={{"$tab-selected": index === i}}
37
- on:click={set(tab.value)} role="tab">
38
- {tab.label}
39
- </ws-tab>
40
- {/each}
41
- </ws-tabs>
1
+ <svelte:options immutable />
2
+
3
+ <script>
4
+ import wsx from "../wsx.mjs"
5
+ import { handler$ } from "../handler$.mjs"
6
+
7
+ export let color = "@primary"
8
+ export let options = []
9
+ export let vertical = false
10
+ export let solid = false
11
+ export let value
12
+
13
+ $: index = options.findIndex(item => item.value === value)
14
+
15
+ const set = handler$(
16
+ (next) => {
17
+ if (value === next) {
18
+ return
19
+ }
20
+ value = next
21
+ }
22
+ )
23
+
24
+ $: wind = {
25
+ "$solid": solid,
26
+ "$color": color,
27
+ $vert: vertical,
28
+ ...$$restProps,
29
+ }
30
+ </script>
31
+
32
+ <!-- svelte-ignore a11y-click-events-have-key-events -->
33
+ <ws-tabs use:wsx={wind} role="tablist">
34
+ {#each options as tab, i}
35
+ <!-- svelte-ignore a11y-interactive-supports-focus -->
36
+ <ws-tab use:wsx={{"$tab-selected": index === i}}
37
+ on:click={set(tab.value)} role="tab">
38
+ <slot {tab} selected={index === i}>
39
+ {tab.label}
40
+ </slot>
41
+ </ws-tab>
42
+ {/each}
43
+ </ws-tabs>
@@ -1,61 +1,61 @@
1
- # Toggle
2
-
3
- The Toggle component is used to display checkboxes and switches.
4
-
5
- ## Props
6
-
7
- ### color
8
- `string`
9
-
10
- Sets `$color`
11
-
12
- ### checkbox
13
- `bool`
14
-
15
- If true, the toggle is displayed as a checkbox. Default is false
16
- (shown as a switch)
17
-
18
- ### checked
19
- `bool`
20
-
21
- Controls if the toggle is checked or not. Can be bound.
22
-
23
- ### group
24
- Used for binding, see the
25
- [Svelte bind:group](https://svelte.dev/docs/element-directives#bind-group)
26
- for details.
27
-
28
- ### label
29
- `string`
30
-
31
- The text to use for the label
32
-
33
- ### flat
34
- `bool`
35
-
36
- Sets `$flat`
37
-
38
- ### reverse
39
- `bool`
40
-
41
- If true, the input being toggled will be on the left instead of the
42
- right. Default is false (label is on the left)
43
-
44
- ### value
45
- `any`
46
-
47
- Only used in conjunction with bind:group, see Svelte docs
48
-
49
- ## Example
50
- ```svelte
51
- <script>
52
- import { Toggle } from "@axel669/zephyr"
53
-
54
- let checked = false
55
- </script>
56
-
57
- <Toggle label="Active" bind:checked />
58
- <Toggle label="Active" checkbox bind:checked />
59
- <Toggle label="Active" checkbox reverse bind:checked />
60
- <Toggle label="Active" checkbox flat color="danger" bind:checked />
61
- ```
1
+ # Toggle
2
+
3
+ The Toggle component is used to display checkboxes and switches.
4
+
5
+ ## Props
6
+
7
+ ### color
8
+ `string`
9
+
10
+ Sets `$color`
11
+
12
+ ### checkbox
13
+ `bool`
14
+
15
+ If true, the toggle is displayed as a checkbox. Default is false
16
+ (shown as a switch)
17
+
18
+ ### checked
19
+ `bool`
20
+
21
+ Controls if the toggle is checked or not. Can be bound.
22
+
23
+ ### group
24
+ Used for binding, see the
25
+ [Svelte bind:group](https://svelte.dev/docs/element-directives#bind-group)
26
+ for details.
27
+
28
+ ### label
29
+ `string`
30
+
31
+ The text to use for the label
32
+
33
+ ### flat
34
+ `bool`
35
+
36
+ Sets `$flat`
37
+
38
+ ### reverse
39
+ `bool`
40
+
41
+ If true, the input being toggled will be on the left instead of the
42
+ right. Default is false (label is on the left)
43
+
44
+ ### value
45
+ `any`
46
+
47
+ Only used in conjunction with bind:group, see Svelte docs
48
+
49
+ ## Example
50
+ ```svelte
51
+ <script>
52
+ import { Toggle } from "@axel669/zephyr"
53
+
54
+ let checked = false
55
+ </script>
56
+
57
+ <Toggle label="Active" bind:checked />
58
+ <Toggle label="Active" checkbox bind:checked />
59
+ <Toggle label="Active" checkbox reverse bind:checked />
60
+ <Toggle label="Active" checkbox flat color="danger" bind:checked />
61
+ ```