@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
package/package.json CHANGED
@@ -1,33 +1,33 @@
1
- {
2
- "name": "@axel669/zephyr",
3
- "version": "0.2.0-beta.3",
4
- "description": "",
5
- "main": "src/index.mjs",
6
- "type": "module",
7
- "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1",
9
- "demo": "rollup -c test/rollup.config.mjs"
10
- },
11
- "keywords": [],
12
- "author": "",
13
- "license": "MIT",
14
- "dependencies": {
15
- "@axel669/windstorm": "0.2.3"
16
- },
17
- "devDependencies": {
18
- "@axel669/ipsen": "0.4.0-beta.7",
19
- "@axel669/rollup-html-input": "^0.1.2",
20
- "@rollup/plugin-node-resolve": "^15.0.2",
21
- "@rollup/plugin-terser": "^0.4.0",
22
- "prism-svelte": "^0.5.0",
23
- "rollup": "^3.20.2",
24
- "rollup-plugin-svelte": "^7.1.6",
25
- "svelte": "^4.2.7"
26
- },
27
- "files": [
28
- "src/"
29
- ],
30
- "imports": {
31
- "#lib": "./src/index.mjs"
32
- }
33
- }
1
+ {
2
+ "name": "@axel669/zephyr",
3
+ "version": "0.3.6",
4
+ "description": "",
5
+ "main": "src/index.mjs",
6
+ "type": "module",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "demo": "rollup -c test/rollup.config.mjs"
10
+ },
11
+ "keywords": [],
12
+ "author": "",
13
+ "license": "MIT",
14
+ "dependencies": {
15
+ "@axel669/windstorm": "0.3.6"
16
+ },
17
+ "devDependencies": {
18
+ "@axel669/ipsen": "0.4.0-beta.7",
19
+ "@axel669/rollup-html-input": "^0.1.2",
20
+ "@rollup/plugin-node-resolve": "^15.0.2",
21
+ "@rollup/plugin-terser": "^0.4.0",
22
+ "prism-svelte": "^0.5.0",
23
+ "rollup": "^3.20.2",
24
+ "rollup-plugin-svelte": "^7.1.6",
25
+ "svelte": "^4.2.7"
26
+ },
27
+ "files": [
28
+ "src/"
29
+ ],
30
+ "imports": {
31
+ "#lib": "./src/index.mjs"
32
+ }
33
+ }
package/readme.md CHANGED
@@ -1,63 +1,63 @@
1
- # Zephyr
2
- Zephyr is a svelte binding for the [Windstorm](https://windstorm.axel669.net)
3
- library, with some additional parts to make it look nice in the markup.
4
-
5
- [Docs Here](https://zephyr.axel669.net)
6
-
7
- ## Installation
8
- Zephyr can be installed through npm (or the variants like yarn, pnpm, etc).
9
-
10
- ```bash
11
- npm install @axel669/zephyr@0.2.0-beta.1
12
- ```
13
-
14
- ## Components
15
- Components can be imported individually from the library for tree-shaking, or
16
- the entire lib can imported at once, but I dunno how big that bundle will be.
17
- Components can also take any windstorm function as a prop, using the same rules
18
- as the `wsx` action.
19
-
20
- ### Theming
21
- Windstorm expects a theme to be defined on an ancestor of the html elements
22
- that use it, and Zephyr does not automatically set the theme because it can
23
- used anywhere in the page. This means the wsx action (or setting the ws-x
24
- attribute directly) will be needed for components to look right. Any valid
25
- Windstorm theme is usable, including custom ones.
26
-
27
- ### Example
28
- ```svelte
29
- <script>
30
- // individual import for tree shaking
31
- import {
32
- Button,
33
- wsx
34
- } from "@axel669/zephyr"
35
-
36
- // bring the whole thing to keep it simple
37
- import * as Wind from "@axel669/zephyr"
38
-
39
- const theme = "dark"
40
- const handler = () => {
41
- console.log("button clicked!")
42
- }
43
- </script>
44
-
45
- <!-- the wsx action can be used to setup the ws-x needed for the body -->
46
- <svelte:body use:wsx={{"$theme": theme, "$app": true}} />
47
-
48
- <Button on:click={handler}>
49
- I'm a button!
50
- </Button>
51
-
52
- <Wind.Button on:click={handler}>
53
- I'm also button!
54
- </Wind.Button>
55
- ```
56
-
57
- ## Svelte Config
58
- Zephyr does not output any css of its own, so no configuration is required to
59
- make it styled as expected. For people using Svelte 4+ you will need to make
60
- sure your bundler has the browser conditions set as some components do use
61
- lifecycle functions that will not be bundled without the setting.
62
- [Svelte Docs](https://svelte.dev/docs/v4-migration-guide#browser-conditions-for-bundlers)
63
- about the setting.
1
+ # Zephyr
2
+ Zephyr is a svelte binding for the [Windstorm](https://windstorm.axel669.net)
3
+ library, with some additional parts to make it look nice in the markup.
4
+
5
+ [Docs Here](https://zephyr.axel669.net)
6
+
7
+ ## Installation
8
+ Zephyr can be installed through npm (or the variants like yarn, pnpm, etc).
9
+
10
+ ```bash
11
+ npm install @axel669/zephyr
12
+ ```
13
+
14
+ ## Components
15
+ Components can be imported individually from the library for tree-shaking, or
16
+ the entire lib can imported at once, but I dunno how big that bundle will be.
17
+ Components can also take any windstorm macro as a prop, including custom macros,
18
+ using the same rules as the `wsx` covered in [Functions](./src/functions.md).
19
+
20
+ ### Theming
21
+ Windstorm expects a theme to be defined on an ancestor of the html elements
22
+ that use it, and Zephyr does not automatically set the theme because it can
23
+ used anywhere in the page. This means the wsx action (or setting the ws-x
24
+ attribute directly) will be needed for components to look right. Any valid
25
+ Windstorm theme is usable, including custom ones.
26
+
27
+ ### Example
28
+ ```svelte
29
+ <script>
30
+ // individual import for tree shaking
31
+ import {
32
+ Button,
33
+ wsx
34
+ } from "@axel669/zephyr"
35
+
36
+ // bring the whole thing to keep it simple
37
+ import * as Wind from "@axel669/zephyr"
38
+
39
+ const theme = "dark"
40
+ const handler = () => {
41
+ console.log("button clicked!")
42
+ }
43
+ </script>
44
+
45
+ <!-- the wsx action can be used to setup the ws-x needed for the body -->
46
+ <svelte:body use:wsx={{"@theme": theme, "@app": true}} />
47
+
48
+ <Button on:click={handler}>
49
+ I'm a button!
50
+ </Button>
51
+
52
+ <Wind.Button on:click={handler}>
53
+ I'm also button!
54
+ </Wind.Button>
55
+ ```
56
+
57
+ ## Svelte Config
58
+ Zephyr does not output any css of its own, so no configuration is required to
59
+ make it styled as expected. For people using Svelte 4+ you will need to make
60
+ sure your bundler has the browser conditions set as some components do use
61
+ lifecycle functions that will not be bundled without the setting.
62
+ [Svelte Docs](https://svelte.dev/docs/v4-migration-guide#browser-conditions-for-bundlers)
63
+ about the setting.
@@ -0,0 +1,27 @@
1
+ # AsyncButton
2
+ A button that makes it simpler to fire off async functions in response to button
3
+ clicks. In addition to calling the function, the button will disable itself
4
+ during the function duration and show a load spinner inside the button.
5
+
6
+ ## Props
7
+ The AsyncButton supports all of the [Button](../control/button.md) props.
8
+
9
+ ### handler
10
+ The async function to call when the button is clicked.
11
+
12
+ ## Example
13
+
14
+ ```svelte
15
+ <script>
16
+ import { AsyncButton } from "@axel669/zephyr"
17
+
18
+ const load = async () => {
19
+ const res = await fetch(someURL)
20
+ console.log(await res.text())
21
+ }
22
+ </script>
23
+
24
+ <AsyncButton handler={load} color="@primary">
25
+ Load Things
26
+ </AsyncButton>
27
+ ```
@@ -1,31 +1,29 @@
1
- <script>
2
- import Button from "../control/button.svelte"
3
- import Spinner from "../spinner/circle-spinner.svelte"
4
-
5
- export let handler = null
6
- export let disabled
7
- export let inactiveProps = null
8
-
9
- let running = false
10
- const asyncHandler = async (evt) => {
11
- running = true
12
- await handler(evt)
13
- running = false
14
- }
15
-
16
- $: inactive = (typeof disabled === "boolean") ? disabled : running
17
- $: props = {
18
- ...$$restProps,
19
- ...(running === false ? null : inactiveProps),
20
- disabled: inactive,
21
- }
22
- </script>
23
-
24
- <Button {...props} on:click={asyncHandler}>
25
- <div ws-x="h[20px] m.r:not(:empty)[4px]">
26
- {#if running === true}
27
- <Spinner size="20px" />
28
- {/if}
29
- </div>
30
- <slot />
31
- </Button>
1
+ <script>
2
+ import Button from "../control/button.svelte"
3
+ import Spinner from "../spinner/circle-spinner.svelte"
4
+
5
+ export let handler = null
6
+ export let disabled
7
+
8
+ let running = false
9
+ const asyncHandler = async (evt) => {
10
+ running = true
11
+ await handler(evt)
12
+ running = false
13
+ }
14
+
15
+ $: inactive = disabled || running
16
+ $: props = {
17
+ ...$$restProps,
18
+ disabled: inactive,
19
+ }
20
+ </script>
21
+
22
+ <Button {...props} on:click={asyncHandler}>
23
+ <div ws-x="[h 20px] [m.r:not(:empty) 4px]">
24
+ {#if running === true}
25
+ <Spinner size="20px" />
26
+ {/if}
27
+ </div>
28
+ <slot />
29
+ </Button>
@@ -0,0 +1,42 @@
1
+ # LoadZone
2
+ A component for putting content that is behind an async function.
3
+
4
+ ## Props
5
+
6
+ ### message
7
+ The text to show while the promise is pending.
8
+
9
+ ### source
10
+ `Promise`
11
+
12
+ The promise that will resolve into some kind of content-related information.
13
+
14
+ ## Slots
15
+
16
+ ### default
17
+ The default slot will be shown when the promise resolves.
18
+
19
+ ### loading
20
+ The content to show while the promise is pending. Overrides the default of a
21
+ load spinner with some text.
22
+
23
+ ### error
24
+ The content to show when the promise rejects. Use `let:error` to get the error
25
+ that was thrown.
26
+
27
+ ## Example
28
+
29
+ ```svelte
30
+ <LoadZone source={asyncThing} let:result>
31
+ <div>
32
+ content
33
+ </div>
34
+ <div>
35
+ {JSON.stringify(result)}
36
+ </div>
37
+
38
+ <div slot="error">
39
+ :(
40
+ </div>
41
+ </LoadZone>
42
+ ```
@@ -1,20 +1,22 @@
1
- <svelte:options immutable />
2
-
3
- <script>
4
- import Spinner from "../spinner/hexagon-spinner.svelte"
5
- export let source = null
6
- export let message = "Loading"
7
- </script>
8
-
9
- {#if source !== null}
10
- {#await source}
11
- <slot name="loading">
12
- <ws-flex ws-x="fl.cross[center] fl.main[center]">
13
- <span>{message}</span>
14
- <Spinner size="100px" />
15
- </ws-flex>
16
- </slot>
17
- {:then result}
18
- <slot {result} />
19
- {/await}
20
- {/if}
1
+ <svelte:options immutable />
2
+
3
+ <script>
4
+ import Spinner from "../spinner/hexagon-spinner.svelte"
5
+ export let source = null
6
+ export let message = "Loading"
7
+ </script>
8
+
9
+ {#if source !== null}
10
+ {#await source}
11
+ <slot name="loading">
12
+ <ws-flex ws-x="[fl-center]">
13
+ <span>{message}</span>
14
+ <Spinner size="100px" />
15
+ </ws-flex>
16
+ </slot>
17
+ {:then result}
18
+ <slot {result} />
19
+ {:catch error}
20
+ <slot name="error" {error} />
21
+ {/await}
22
+ {/if}
@@ -0,0 +1,21 @@
1
+ # TH
2
+
3
+ The TH component has no use outside fo the DataTable, but is used to support
4
+ the filter and sorting functionality for that component.
5
+
6
+ ## Props
7
+
8
+ ### sort
9
+ `Function`
10
+
11
+ The sorting function to use for the column defined. Should return values that
12
+ match the expected values for `Array.sort`.
13
+
14
+ ### filter
15
+ `Function`
16
+
17
+ The function to use for filtering based on the column. The function is given
18
+ 2 arguments: a row of data and the text from the filter input field. The
19
+ function should return `true` if the item should be shown. A filter function on
20
+ a specific column does not need to only look at the specified column, but not
21
+ doing could cause confusion for users without proper context.
@@ -1,61 +1,61 @@
1
- <svelte:options immutable />
2
-
3
- <script context="module">
4
- const sortIcons = {
5
- "asc": "arrow-narrow-up",
6
- "desc": "arrow-narrow-down",
7
- }
8
- </script>
9
-
10
- <script>
11
- import { getContext } from "svelte"
12
-
13
- import Button from "../../control/button.svelte"
14
- import Grid from "../../layout/grid.svelte"
15
- import Icon from "../../info/icon.svelte"
16
-
17
- import wsx from "../../wsx.mjs"
18
- import { dtContext } from "../data-table.svelte"
19
-
20
- export let sort = null
21
- export let filter = null
22
-
23
- const context = getContext(dtContext)
24
-
25
- const setSort = () => $context.updateSort(sort)
26
-
27
- let value = ""
28
- $: $context.updateFilter(filter, value)
29
-
30
- $: wind = {
31
- ...$$restProps,
32
- p: "0px",
33
- sel: "none"
34
- }
35
- $: sortIcon =
36
- ($context.sorting.base === sort)
37
- ? sortIcons[$context.sorting.direction]
38
- : "arrows-up-down"
39
- </script>
40
-
41
- <th use:wsx={wind} style="vertical-align: top;">
42
- <Grid rows="40px min-content" p="0px" gap="0px">
43
- {#if sort === null}
44
- <div ws-x="flex fl.cross[center] fl.main[center]">
45
- <slot />
46
- </div>
47
- {:else}
48
- <Button compact r="0px" color="primary" fill={$context.fillHeader}
49
- t.wt="inherit" on:click={setSort}>
50
- <slot />
51
- <Icon name={sortIcon} m.l="4px" t.sz="16px" />
52
- </Button>
53
- {/if}
54
- {#if filter !== null}
55
- <Grid gap="0px" p="0px" cols="min-content 1fr">
56
- <Icon name="filter" />
57
- <input type="text" ws-x="w.min[20px] outline:focus[none]" bind:value />
58
- </Grid>
59
- {/if}
60
- </Grid>
61
- </th>
1
+ <svelte:options immutable />
2
+
3
+ <script context="module">
4
+ const sortIcons = {
5
+ "asc": "arrow-narrow-up",
6
+ "desc": "arrow-narrow-down",
7
+ }
8
+ </script>
9
+
10
+ <script>
11
+ import { getContext } from "svelte"
12
+
13
+ import Button from "../../control/button.svelte"
14
+ import Grid from "../../layout/grid.svelte"
15
+ import Icon from "../../info/icon.svelte"
16
+
17
+ import wsx from "../../wsx.mjs"
18
+ import { dtContext } from "../data-table.svelte"
19
+
20
+ export let sort = null
21
+ export let filter = null
22
+
23
+ const context = getContext(dtContext)
24
+
25
+ const setSort = () => $context.updateSort(sort)
26
+
27
+ let value = ""
28
+ $: $context.updateFilter(filter, value)
29
+
30
+ $: wind = {
31
+ ...$$restProps,
32
+ p: "0px",
33
+ sel: "none"
34
+ }
35
+ $: sortIcon =
36
+ ($context.sorting.base === sort)
37
+ ? sortIcons[$context.sorting.direction]
38
+ : "arrows-up-down"
39
+ </script>
40
+
41
+ <th use:wsx={wind} style="vertical-align: top;">
42
+ <Grid rows="40px min-content" p="0px" gap="0px">
43
+ {#if sort === null}
44
+ <div ws-x="[flex] [fl.cross center] [fl.main center]">
45
+ <slot />
46
+ </div>
47
+ {:else}
48
+ <Button compact r="0px" color="primary" fill={$context.fillHeader}
49
+ t.wt="inherit" on:click={setSort}>
50
+ <slot />
51
+ <Icon name={sortIcon} m.l="4px" t.sz="16px" />
52
+ </Button>
53
+ {/if}
54
+ {#if filter !== null}
55
+ <Grid gap="0px" p="0px" cols="min-content 1fr">
56
+ <Icon name="filter" />
57
+ <input type="text" ws-x="[w.min 20px] [outln:focus none]" bind:value />
58
+ </Grid>
59
+ {/if}
60
+ </Grid>
61
+ </th>