@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.
Files changed (115) hide show
  1. package/LICENSE +21 -21
  2. package/package.json +10 -7
  3. package/readme.md +55 -44
  4. package/src/async/button.svelte +31 -0
  5. package/src/async/load-zone.svelte +17 -0
  6. package/src/composed/data-table/th.svelte +60 -0
  7. package/src/composed/data-table.md +83 -0
  8. package/src/composed/data-table.svelte +136 -150
  9. package/src/composed/entry-button.md +34 -0
  10. package/src/composed/entry-button.svelte +29 -68
  11. package/src/composed/table-functions.js +13 -0
  12. package/src/composed/toast/message.svelte +56 -44
  13. package/src/composed/toast.md +36 -0
  14. package/src/composed/toast.svelte +68 -108
  15. package/src/control/button.md +37 -0
  16. package/src/control/button.svelte +25 -0
  17. package/src/control/input.svelte +107 -0
  18. package/src/control/label.md +45 -0
  19. package/src/control/label.svelte +36 -0
  20. package/src/control/link.md +46 -0
  21. package/src/control/link.svelte +28 -0
  22. package/src/control/radio.md +56 -0
  23. package/src/control/radio.svelte +26 -0
  24. package/src/control/select.md +68 -0
  25. package/src/control/select.svelte +62 -0
  26. package/src/control/tabs.md +45 -0
  27. package/src/control/tabs.svelte +39 -0
  28. package/src/control/toggle.md +55 -0
  29. package/src/control/toggle.svelte +47 -0
  30. package/src/data-display/avatar.md +32 -0
  31. package/src/data-display/avatar.svelte +23 -0
  32. package/src/data-display/badge.md +24 -0
  33. package/src/data-display/badge.svelte +12 -0
  34. package/src/data-display/chip.md +32 -0
  35. package/src/data-display/chip.svelte +26 -0
  36. package/src/data-display/details.md +3 -0
  37. package/src/{details.svelte → data-display/details.svelte} +3 -3
  38. package/src/data-display/popover.md +28 -0
  39. package/src/data-display/popover.svelte +23 -0
  40. package/src/data-display/progress.md +42 -0
  41. package/src/data-display/progress.svelte +25 -0
  42. package/src/data-display/table.md +7 -0
  43. package/src/data-display/table.svelte +36 -0
  44. package/src/data-display/tooltip.md +25 -0
  45. package/src/data-display/tooltip.svelte +15 -0
  46. package/src/dialogs/alert.md +3 -0
  47. package/src/dialogs/alert.svelte +4 -4
  48. package/src/dialogs/confirm.md +3 -0
  49. package/src/dialogs/confirm.svelte +5 -5
  50. package/src/functions.md +77 -0
  51. package/src/handler$.mjs +20 -68
  52. package/src/index.mjs +58 -92
  53. package/src/info/icon.md +17 -0
  54. package/src/info/icon.svelte +9 -0
  55. package/src/info/notification.md +32 -0
  56. package/src/info/notification.svelte +16 -0
  57. package/src/info/titlebar.md +49 -0
  58. package/src/info/titlebar.svelte +18 -0
  59. package/src/info/toaster.md +22 -0
  60. package/src/info/toaster.svelte +14 -0
  61. package/src/inline-dialog.svelte +23 -23
  62. package/src/layout/dialog.md +34 -0
  63. package/src/layout/dialog.svelte +24 -0
  64. package/src/layout/drawer.md +61 -0
  65. package/src/layout/drawer.svelte +47 -0
  66. package/src/layout/flex.md +39 -0
  67. package/src/layout/flex.svelte +22 -0
  68. package/src/layout/grid.md +57 -0
  69. package/src/layout/grid.svelte +26 -0
  70. package/src/layout/modal.md +47 -0
  71. package/src/layout/modal.svelte +58 -0
  72. package/src/layout/paper.md +90 -0
  73. package/src/layout/paper.svelte +45 -0
  74. package/src/layout/screen.md +28 -0
  75. package/src/layout/screen.svelte +32 -0
  76. package/src/{circle-spinner.svelte → spinner/circle-spinner.svelte} +2 -2
  77. package/src/{hexagon-spinner.svelte → spinner/hexagon-spinner.svelte} +2 -2
  78. package/src/spinner/spinners.md +3 -0
  79. package/src/text.md +34 -0
  80. package/src/text.svelte +20 -49
  81. package/src/variant.mjs +12 -12
  82. package/src/wsx.mjs +24 -45
  83. package/src/avatar.svelte +0 -54
  84. package/src/badge.svelte +0 -40
  85. package/src/button.svelte +0 -86
  86. package/src/chip.svelte +0 -56
  87. package/src/dialog.svelte +0 -54
  88. package/src/drawer.svelte +0 -121
  89. package/src/flex.svelte +0 -57
  90. package/src/grid.svelte +0 -66
  91. package/src/icon.svelte +0 -34
  92. package/src/input/area.svelte +0 -98
  93. package/src/input/elems.mjs +0 -7
  94. package/src/input/email.svelte +0 -104
  95. package/src/input/file.svelte +0 -82
  96. package/src/input/number.svelte +0 -104
  97. package/src/input/password.svelte +0 -101
  98. package/src/input/search.svelte +0 -104
  99. package/src/input/text.svelte +0 -104
  100. package/src/link.svelte +0 -67
  101. package/src/modal.svelte +0 -73
  102. package/src/notification.svelte +0 -57
  103. package/src/paper.svelte +0 -127
  104. package/src/popover.svelte +0 -60
  105. package/src/progress.svelte +0 -60
  106. package/src/radio.svelte +0 -82
  107. package/src/screen.svelte +0 -69
  108. package/src/select.svelte +0 -122
  109. package/src/table.svelte +0 -69
  110. package/src/tabs.svelte +0 -78
  111. package/src/titlebar.svelte +0 -69
  112. package/src/toaster.svelte +0 -42
  113. package/src/toggle.svelte +0 -94
  114. package/src/tooltip.svelte +0 -45
  115. package/src/vars.mjs +0 -61
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Chris Morgan
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Chris Morgan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axel669/zephyr",
3
- "version": "0.1.17",
3
+ "version": "0.2.0-beta.1",
4
4
  "description": "",
5
5
  "main": "src/index.mjs",
6
6
  "type": "module",
@@ -12,19 +12,22 @@
12
12
  "author": "",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@axel669/windstorm": "0.1.17",
16
- "@labyrinthos/asuid": "^0.2.0",
17
- "svelte": "^3.58.0"
15
+ "@axel669/windstorm": "0.2.3"
18
16
  },
19
17
  "devDependencies": {
20
- "@axel669/ipsen": "^0.3.1",
18
+ "@axel669/ipsen": "0.4.0-beta.6",
21
19
  "@axel669/rollup-html-input": "^0.1.2",
22
20
  "@rollup/plugin-node-resolve": "^15.0.2",
23
21
  "@rollup/plugin-terser": "^0.4.0",
22
+ "prism-svelte": "^0.5.0",
24
23
  "rollup": "^3.20.2",
25
- "rollup-plugin-svelte": "^7.1.4"
24
+ "rollup-plugin-svelte": "^7.1.6",
25
+ "svelte": "^4.2.7"
26
26
  },
27
27
  "files": [
28
28
  "src/"
29
- ]
29
+ ],
30
+ "imports": {
31
+ "#lib": "./src/index.mjs"
32
+ }
30
33
  }
package/readme.md CHANGED
@@ -1,44 +1,55 @@
1
-
2
-
3
- # Zephyr
4
- Zephyr is a svelte binding for the
5
- [Windstorm](https://www.npmjs.com/package/@axel669/windstorm)
6
- library.
7
-
8
- [Docs Here](https://svelte-wind.axel669.net)
9
-
10
- ## Installation
11
- Zephyr can be installed through npm (or the variants like yarn, pnpm, etc).
12
-
13
- ```bash
14
- npm install @axel669/svelte-wind
15
- ```
16
-
17
- ## Usage
18
- Components can be imported individually from the library for tree-shaking, or
19
- the entire lib can imported at once, but I dunno how big that bundle will be.
20
-
21
- ```svelte
22
- <script>
23
- // individual import for tree shaking
24
- import { Button } from "@axel69/svelte-wind"
25
-
26
- // bring the whole thing to keep it simple
27
- import * as Wind from "@axel69/svelte-wind"
28
- </script>
29
-
30
- <!-- the wsx action can be used to setup the ws-x needed for the body -->
31
- <svelte:body use:wsx={{theme, "@app": true}} />
32
-
33
- <Button on:click={stuff}>
34
- I'm a button!
35
- </Button>
36
-
37
- <Wind.Button on:click={stuff}>
38
- I'm also button!
39
- </Wind.Button>
40
- ```
41
-
42
- ### Svelte Config
43
- No special configuration of svelte is required, nor is there a separate plugin
44
- that needs to be added. Just have svelte and you're good to go.
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 { Button } from "@axel669/zephyr"
32
+
33
+ // bring the whole thing to keep it simple
34
+ import * as Wind from "@axel669/zephyr"
35
+ </script>
36
+
37
+ <!-- the wsx action can be used to setup the ws-x needed for the body -->
38
+ <svelte:body use:wsx={{"$theme": theme, "$app": true}} />
39
+
40
+ <Button on:click={stuff}>
41
+ I'm a button!
42
+ </Button>
43
+
44
+ <Wind.Button on:click={stuff}>
45
+ I'm also button!
46
+ </Wind.Button>
47
+ ```
48
+
49
+ ## Svelte Config
50
+ Zephyr does not output any css of its own, so no configuration is required to
51
+ make it styled as expected. For people using Svelte 4+ you will need to make
52
+ sure your bundler has the browser conditions set as some components do use
53
+ lifecycle functions that will not be bundled without the setting.
54
+ [Svelte Docs](https://svelte.dev/docs/v4-migration-guide#browser-conditions-for-bundlers)
55
+ about the setting.
@@ -0,0 +1,31 @@
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>
@@ -0,0 +1,17 @@
1
+ <script>
2
+ import Spinner from "../spinner/hexagon-spinner.svelte"
3
+ export let source = null
4
+ </script>
5
+
6
+ {#if source !== null}
7
+ {#await source}
8
+ <slot name="loading">
9
+ <ws-flex ws-x="fl.cross[center] fl.main[center]">
10
+ <span>Loading</span>
11
+ <Spinner size="100px" />
12
+ </ws-flex>
13
+ </slot>
14
+ {:then result}
15
+ <slot {result} />
16
+ {/await}
17
+ {/if}
@@ -0,0 +1,60 @@
1
+ <script context="module">
2
+ const sortIcons = {
3
+ "asc": "arrow-narrow-up",
4
+ "desc": "arrow-narrow-down",
5
+ }
6
+ </script>
7
+
8
+ <script>
9
+ import { getContext } from "svelte"
10
+
11
+ import Button from "../../control/button.svelte"
12
+ import Grid from "../../layout/grid.svelte"
13
+ import Icon from "../../info/icon.svelte"
14
+
15
+ import wsx from "../../wsx.mjs"
16
+ import { dtContext } from "../data-table.svelte"
17
+
18
+ export let sort = null
19
+ export let filter = null
20
+
21
+ const context = getContext(dtContext)
22
+
23
+ const setSort = () => $context.updateSort(sort)
24
+
25
+ let value = ""
26
+ $: $context.updateFilter(filter, value)
27
+
28
+ $: wind = {
29
+ ...$$restProps,
30
+ p: "0px",
31
+ sel: "none"
32
+ }
33
+ $: console.log($context.sorting)
34
+ $: sortIcon =
35
+ ($context.sorting.base === sort)
36
+ ? sortIcons[$context.sorting.direction]
37
+ : "arrows-up-down"
38
+ </script>
39
+
40
+ <th use:wsx={wind} style="vertical-align: top;">
41
+ <Grid rows="40px min-content" p="0px" gap="0px">
42
+ {#if sort === null}
43
+ <div ws-x="flex fl.cross[center] fl.main[center]">
44
+ <slot />
45
+ </div>
46
+ {:else}
47
+ <Button compact r="0px" color="primary" fill={$context.fillHeader}
48
+ t.wt="inherit" on:click={setSort}>
49
+ <slot />
50
+ <Icon name={sortIcon} m.l="4px" t.sz="16px" />
51
+ </Button>
52
+ {/if}
53
+ {#if filter !== null}
54
+ <Grid gap="0px" p="0px" cols="min-content 1fr">
55
+ <Icon name="filter" />
56
+ <input type="text" ws-x="w.min[20px] outline:focus[none]" bind:value />
57
+ </Grid>
58
+ {/if}
59
+ </Grid>
60
+ </th>
@@ -0,0 +1,83 @@
1
+ # DataTable
2
+
3
+ The DataTable is a more advanced way to show data on screen. Underneath is
4
+ a table element like the Table component, but the DataTable supports
5
+ more fine-grained control over how data is passed, how rows are displayed,
6
+ and pagination.
7
+
8
+ > If pagination is not needed, the DataTable may not be necessary as it will
9
+ > only be shortcutting data formatting at that point.
10
+
11
+ ## Props
12
+ All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
13
+ are supported.
14
+
15
+ - ### color
16
+ Sets `$color`
17
+
18
+ ### cols
19
+ `Array`
20
+
21
+ The columns that should be displayed. Should be in the format of
22
+ `{ label, width?, format?, prop? }`. If a format function is provided,
23
+ it is called on each cell to determine a cells value as
24
+ `format(rowItem)`, otherwise the property defined in prop will be used
25
+ as the cell value.
26
+
27
+ ### data
28
+ `Array`
29
+
30
+ The data to display. Each item in the array can be in either the same
31
+ format as the Table, or any kind of object if column format functions
32
+ are used.
33
+
34
+ ### cellWSX
35
+ `function`
36
+
37
+ If given, this function will be called for each cell, and should return
38
+ an object that will be passed to the `wsx` action for each <td>
39
+ generated. The function is passed `(rowvalue, rowNum, col)`.
40
+
41
+ ### rowWSX
42
+ `function`
43
+
44
+ If given, this function will be called for each row, and should return
45
+ an object that will be passed to the `wsx` action for each <tr>
46
+ generated. The function is passed `(rowValue, rowNum)`.
47
+ - ### page
48
+ The current page of data being viewed. Can be bound, or set to control
49
+ which page is displayed
50
+ - ### pageSize
51
+ The number of items to show on each page. Default is 10
52
+ - ### rowHeight
53
+ The height of each row. Can be set individually through rowWSX, but
54
+ that may lead to a degraded user experience if the rows change size
55
+ while paging through the data
56
+
57
+ ## Example
58
+ ```js
59
+ let page
60
+ const cols = [
61
+ { label: "N", prop: "a" },
62
+ { label: "Squared", prop: "b" },
63
+ { label: "Cubed", format: row => `^3 = ${row.c}` },
64
+ ]
65
+ const data = [
66
+ { a: 1, b: 1 ** 2, c: 1 ** 3 },
67
+ { a: 2, b: 2 ** 2, c: 2 ** 3 },
68
+ { a: 3, b: 3 ** 2, c: 3 ** 3 },
69
+ { a: 4, b: 4 ** 2, c: 4 ** 3 },
70
+ { a: 5, b: 5 ** 2, c: 5 ** 3 },
71
+ { a: 6, b: 6 ** 2, c: 6 ** 3 },
72
+ { a: 7, b: 7 ** 2, c: 7 ** 3 },
73
+ { a: 8, b: 8 ** 2, c: 8 ** 3 },
74
+ { a: 9, b: 9 ** 2, c: 9 ** 3 },
75
+ { a: 10, b: 10 ** 2, c: 10 ** 3 },
76
+ { a: 11, b: 11 ** 2, c: 11 ** 3 },
77
+ { a: 12, b: 12 ** 2, c: 12 ** 3 },
78
+ { a: 13, b: 13 ** 2, c: 13 ** 3 },
79
+ ]
80
+ ```
81
+ ```svelte
82
+ <DataTable {cols} {data} color="warning" pageSize={3} bind:page />
83
+ ```