@axel669/zephyr 0.2.0-beta.3 → 0.3.4-beta.0

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 (47) hide show
  1. package/package.json +2 -2
  2. package/readme.md +4 -4
  3. package/src/async/button.md +27 -0
  4. package/src/async/button.svelte +2 -4
  5. package/src/async/load-zone.md +42 -0
  6. package/src/async/load-zone.svelte +3 -1
  7. package/src/composed/data-table/th.md +21 -0
  8. package/src/composed/data-table/th.svelte +2 -2
  9. package/src/composed/data-table.md +68 -67
  10. package/src/composed/data-table.svelte +66 -16
  11. package/src/composed/entry-button.md +23 -13
  12. package/src/composed/toast.md +30 -21
  13. package/src/composed/toast.svelte +1 -1
  14. package/src/control/input.md +87 -0
  15. package/src/control/input.svelte +3 -3
  16. package/src/control/label.md +0 -1
  17. package/src/control/label.svelte +1 -1
  18. package/src/control/link.svelte +4 -2
  19. package/src/control/radio.svelte +1 -1
  20. package/src/control/select.svelte +2 -2
  21. package/src/control/tabs.svelte +4 -2
  22. package/src/control/toggle.svelte +3 -3
  23. package/src/data-display/badge.svelte +1 -1
  24. package/src/data-display/chip.svelte +1 -1
  25. package/src/data-display/details.md +40 -1
  26. package/src/data-display/details.svelte +1 -1
  27. package/src/data-display/popover.svelte +1 -1
  28. package/src/data-display/progress.svelte +2 -2
  29. package/src/data-display/table.md +56 -4
  30. package/src/dialogs/alert.md +40 -1
  31. package/src/dialogs/alert.svelte +1 -1
  32. package/src/dialogs/confirm.md +54 -1
  33. package/src/dialogs/confirm.svelte +1 -1
  34. package/src/functions.md +25 -0
  35. package/src/hash.js +14 -0
  36. package/src/index.mjs +2 -1
  37. package/src/inline-dialog.svelte +1 -1
  38. package/src/layout/dialog.svelte +1 -1
  39. package/src/layout/drawer.svelte +3 -3
  40. package/src/layout/flex.svelte +2 -0
  41. package/src/layout/grid.svelte +2 -0
  42. package/src/layout/modal.svelte +1 -1
  43. package/src/layout/screen.svelte +2 -2
  44. package/src/spinner/circle-spinner.svelte +2 -2
  45. package/src/spinner/hexagon-spinner.svelte +2 -2
  46. package/src/spinner/spinners.md +20 -1
  47. package/src/wsx.mjs +1 -1
@@ -0,0 +1,87 @@
1
+ # Input
2
+ A component that wraps the text-based input tags. Includes optional outline,
3
+ label, hint text, error showing, input validation, input transformation, and
4
+ browser level autocomplete.
5
+
6
+ ## Props
7
+
8
+ ### autoCompleteOptions
9
+ An array of options to show for auto complete. Uses the browser `datalist`
10
+ element to create the auto complete.
11
+
12
+ ### color
13
+ Sets the $color macro.
14
+
15
+ ### disabled
16
+ Disables the input.
17
+
18
+ ### error
19
+ If set, shows an error message under the input.
20
+
21
+ ### flat
22
+ If true, the input will not have a border. Default is false (with a border).
23
+
24
+ ### hint
25
+ Shows a hint under the label of the input.
26
+
27
+ ### type
28
+ The type of input. Default to "text".
29
+
30
+ ### value
31
+ The value of the input. Can be bound the same way a normal text input value is
32
+ bound in Svelte.
33
+
34
+ ### transform
35
+ A function to transform the value of the input automatically. Results are put
36
+ into the tvalue prop.
37
+
38
+ ### tvalue
39
+ The transformed value of the input. Binding should only be used to react to
40
+ the value as it will be overriden while a user is typing into the input.
41
+
42
+ ### validate
43
+ A function to determine if the value of the input is valid. Results are put into
44
+ the `valid` prop. If a transform function is provided, the transformed value
45
+ is given to the validation function.
46
+
47
+ ### valid
48
+ The result of the validation function. Binding should only be used to react to
49
+ the value.
50
+
51
+ ## Instance Functions
52
+
53
+ ### focus
54
+ Focuses the input.
55
+
56
+ ## Slots
57
+
58
+ ### end
59
+ Puts an element at the end of the input.
60
+
61
+ ### start
62
+ Puts an element at the start of the input.
63
+
64
+ ## Example
65
+
66
+ ```svelte
67
+ <script>
68
+ import { Input } from "@axel669/zephyr"
69
+
70
+ let name = ""
71
+ let ageText = ""
72
+ let age = 0
73
+ let ageValid = false
74
+
75
+ $: ageError = ageValid ? "Invalid Age" : null
76
+ </script>
77
+
78
+ <Input bind:value={name} label="Name" />
79
+ <Input
80
+ bind:value={ageText}
81
+ transform={v => parseInt(v)}
82
+ bind:tvalue={age}
83
+ validate={age => age > 0}
84
+ bind:valid={ageValid}
85
+ error={ageError}
86
+ />
87
+ ```
@@ -23,7 +23,7 @@
23
23
 
24
24
  export let flat = false
25
25
  export let label
26
- export let color = "default"
26
+ export let color = "@default"
27
27
  export let error = null
28
28
  export let hint = null
29
29
  export let disabled
@@ -72,7 +72,7 @@
72
72
 
73
73
  $: wind = {
74
74
  "$flat": flat,
75
- "$control": true,
75
+ "@control": true,
76
76
  "$color": color,
77
77
  ...props.wind,
78
78
  }
@@ -82,7 +82,7 @@
82
82
 
83
83
  <label use:wsx={wind} ws-error={error}>
84
84
  {#if label}
85
- <span ws-x="$text" ws-hint={hint}>{label}</span>
85
+ <span use:wsx={{ slot: "label-text" }} ws-hint={hint}>{label}</span>
86
86
  {/if}
87
87
  <svelte:element
88
88
  this={tag}
@@ -1,5 +1,4 @@
1
1
  # Label
2
-
3
2
  The label component is a wrapper around a `<label>` element.
4
3
 
5
4
  ## Props
@@ -20,7 +20,7 @@
20
20
  $: baseStyles =
21
21
  (button === true)
22
22
  ? {
23
- $button: true,
23
+ "@button": true,
24
24
  [type]: true,
25
25
  "$color": color,
26
26
  $compact: compact,
@@ -15,16 +15,18 @@
15
15
  export let outline = false
16
16
  export let flat = false
17
17
 
18
+ export let disabled = null
19
+
18
20
  $: type = variant({ fill, outline, flat })
19
21
 
20
22
  $: wind = {
21
- "$button": button,
23
+ "@button": button,
22
24
  [type]: true,
23
25
  "$color": color,
24
26
  ...$$restProps
25
27
  }
26
28
  </script>
27
29
 
28
- <a {href} {target} {rel} use:wsx={wind}>
30
+ <a {href} {target} {rel} {disabled} use:wsx={wind} on:click>
29
31
  <slot />
30
32
  </a>
@@ -20,7 +20,7 @@
20
20
 
21
21
  <svelte:component this={layout} {...$$restProps}>
22
22
  {#each options as {value, label, disabled, ...wind}, index (value)}
23
- <label use:wsx={{"$toggle": true, ...wind}} {disabled}>
23
+ <label use:wsx={{"@toggle": true, ...wind}} {disabled}>
24
24
  <span>{label}</span>
25
25
  <input type="radio" on:input={set(value)} {name} checked={index === valueIndex} />
26
26
  </label>
@@ -33,7 +33,7 @@
33
33
  $: grouped = groupOptions(options)
34
34
 
35
35
  $: wind = {
36
- "$control": true,
36
+ "@control": true,
37
37
  "$outline": outline,
38
38
  "$color": color,
39
39
  ...$$restProps,
@@ -42,7 +42,7 @@
42
42
 
43
43
  <label use:wsx={wind}>
44
44
  {#if label}
45
- <span ws-x="$text">{label}</span>
45
+ <span ws-x="[$label-text]">{label}</span>
46
46
  {/if}
47
47
  <select value={indexValue} on:input={update} {disabled}>
48
48
  {#each grouped as item, index}
@@ -4,7 +4,7 @@
4
4
  import wsx from "../wsx.mjs"
5
5
  import { handler$ } from "../handler$.mjs"
6
6
 
7
- export let color = "primary"
7
+ export let color = "@primary"
8
8
  export let options = []
9
9
  export let vertical = false
10
10
  export let solid = false
@@ -35,7 +35,9 @@
35
35
  <!-- svelte-ignore a11y-interactive-supports-focus -->
36
36
  <ws-tab use:wsx={{"$tab-selected": index === i}}
37
37
  on:click={set(tab.value)} role="tab">
38
- {tab.label}
38
+ <slot {tab} selected={index === i}>
39
+ {tab.label}
40
+ </slot>
39
41
  </ws-tab>
40
42
  {/each}
41
43
  </ws-tabs>
@@ -4,7 +4,7 @@
4
4
  import wsx from "../wsx.mjs"
5
5
 
6
6
  export let label = ""
7
- export let color = "default"
7
+ export let color = "@default"
8
8
  export let checked = false
9
9
  export let flat = false
10
10
  export let value
@@ -13,14 +13,14 @@
13
13
  export let reverse = false
14
14
 
15
15
  $: container = {
16
- "$toggle": true,
16
+ "@toggle": true,
17
17
  "$flat": flat,
18
18
  "$color": color,
19
19
  "fl.dir": reverse ? "row-reverse" : false,
20
20
  ...$$restProps,
21
21
  }
22
22
  $: input = {
23
- "$switch": checkbox === false
23
+ "@switch": checkbox === false
24
24
  }
25
25
 
26
26
  const updateGroup = (checked) => {
@@ -3,7 +3,7 @@
3
3
  <script>
4
4
  import wsx from "../wsx.mjs"
5
5
 
6
- export let color = "default"
6
+ export let color = "@default"
7
7
  export let text = ""
8
8
 
9
9
  $: wind = { "$color": color, ...$$restProps }
@@ -4,7 +4,7 @@
4
4
  import wsx from "../wsx.mjs"
5
5
  import variant from "../variant.mjs"
6
6
 
7
- export let color = "default"
7
+ export let color = "@default"
8
8
  export let clickable = false
9
9
 
10
10
  export let fill = false
@@ -1,3 +1,42 @@
1
1
  # Details
2
+ A component that has some baseline content that is shown, then expands to reveal
3
+ more content (like the html details element).
2
4
 
3
- Still working on this one.
5
+ ## Props
6
+
7
+ ### color
8
+ Sets the $color macro.
9
+
10
+ ### label
11
+ The text for the content that is always shown.
12
+
13
+ ### open
14
+ Controls whether the Details is showing the extended content. Can be bound to.
15
+
16
+ ### outline
17
+ If true, will put an outline around the component, including the extended
18
+ content.
19
+
20
+ ## Slots
21
+
22
+ ### default
23
+ The content to show when the Details is open.
24
+
25
+ ### label
26
+ Can be used for more complex labels (things that need nested elements). If used,
27
+ the label prop will be ignored.
28
+
29
+ ## Example
30
+
31
+ ```svelte
32
+ <script>
33
+ import { Details } from "@axel669/zephyr"
34
+
35
+ let open = false
36
+ </script>
37
+
38
+ <div>Open: {open}</div>
39
+ <Details label="Info" bind:open>
40
+ Look, more info could go here!
41
+ </Details>
42
+ ```
@@ -5,7 +5,7 @@
5
5
 
6
6
  export let label
7
7
  export let outline
8
- export let color = "default"
8
+ export let color = "@default"
9
9
  export let open = false
10
10
 
11
11
  $: wind = {
@@ -18,7 +18,7 @@
18
18
  <ws-popover use:wsx={wind}>
19
19
  <slot {show} />
20
20
  {#if visible}
21
- <wind-content slot="content" ws-x="inset[0px]" transition:fade={anim}>
21
+ <wind-content slot="content" ws-x="[inset 0px]" transition:fade={anim}>
22
22
  <slot name="content" {hide} />
23
23
  </wind-content>
24
24
  {/if}
@@ -11,7 +11,7 @@
11
11
  export let label = null
12
12
 
13
13
  $: wind = {
14
- "$progress": true,
14
+ "@progress": true,
15
15
  "$outline": outline,
16
16
  "$color": color,
17
17
  $row: row,
@@ -21,7 +21,7 @@
21
21
 
22
22
  <label use:wsx={wind}>
23
23
  {#if label}
24
- <span ws-x="$text t-ws[nowrap]">{label}</span>
24
+ <span ws-x="[$progress-label] [t-ws nowrap]">{label}</span>
25
25
  {/if}
26
26
  <progress {value} {max} />
27
27
  </label>
@@ -1,7 +1,59 @@
1
1
  # Table
2
+ Wrapper for making tables in a way that is easy to maintain.
2
3
 
3
- Under construction.
4
+ ## Props
4
5
 
5
- <!-- Displays data using html tables with some nice styling. This version of the
6
- table is fairly simple and intended for basic data displays. For more
7
- complex data displays the DataTable should be used. -->
6
+ ### color
7
+ `string`
8
+
9
+ Sets the $color macro.
10
+
11
+ ### data
12
+ `Array`
13
+
14
+ The data to display in the table.
15
+
16
+ ### fillHeader
17
+ `bool`
18
+
19
+ If true, the header row will have the background filled instead of just the
20
+ colored border.
21
+
22
+ ## Slots
23
+
24
+ ### header
25
+ Used to render the header for the table. Needs to include the `tr`.
26
+
27
+ ### row
28
+ Used to render an item that is not `undefined`. Needs to include the `tr`. Uses
29
+ `let:row` for the row data, and `let:rowNum` for the row number (0-based).
30
+
31
+ ### empty-row
32
+ If given, will render when the item in the array is `undefined`. Uses
33
+ `let:rowNum` for the row number (0-based).
34
+
35
+ ## Example
36
+ ```svelte
37
+ <script>
38
+ import { Table } from "@axel669/zephyr"
39
+
40
+ const data = Array.from(
41
+ { length: 20 },
42
+ (_, i) => [i, i ** 2, i ** 3]
43
+ )
44
+ </script>
45
+
46
+ <Table>
47
+ <tr slot="header">
48
+ <th>N</th>
49
+ <th>Squared</th>
50
+ <th>Cubed</th>
51
+ </tr>
52
+
53
+ <tr slot="row" let:row>
54
+ <td>{row[0]}</td>
55
+ <td>{row[1]}</td>
56
+ <td>{row[2]}</td>
57
+ </tr>
58
+ </Table>
59
+ ```
@@ -1,3 +1,42 @@
1
1
  # Alert Dialog
2
+ A nicer alert dialog to use with [Modal](../layout/dialog.md).
2
3
 
3
- Under construction.
4
+ ## Props
5
+
6
+ ### color
7
+ Sets the $color macro.
8
+
9
+ ### icon
10
+ The name of an icon to show with the title of the alert.
11
+
12
+ ### message
13
+ The message to shwo in the alert.
14
+
15
+ ### okText
16
+ The text for the button that closes the alert.
17
+
18
+ ### title
19
+ The title for the alert.
20
+
21
+ ## Example
22
+ ```svelte
23
+ <script>
24
+ import { Alert, Button, EntryButton, Modal } from "@axel669/zephyr"
25
+
26
+ let alertModal = null
27
+ const alertProps = {
28
+ title: "Alert Example",
29
+ message: "This is an alert!"
30
+ }
31
+ const show = () => alertModal.show(alertProps)
32
+ </script>
33
+
34
+ <Modal component={Alert} bind:this={alertModal} />
35
+ <Button on:click={show}>
36
+ Show Alert
37
+ </Button>
38
+
39
+ <EntryButton props={alertProps}>
40
+ Show Alert
41
+ </EntryButton>
42
+ ```
@@ -12,7 +12,7 @@
12
12
  export let icon
13
13
  export let message
14
14
  export let okText = "OK"
15
- export let color = "primary"
15
+ export let color = "@primary"
16
16
  </script>
17
17
 
18
18
  <Dialog card {color}>
@@ -1,3 +1,56 @@
1
1
  # Confirm Dialog
2
+ A nicer confirm dialog to use with [Modal](../layout/dialog.md).
2
3
 
3
- Under construction.
4
+ ## Props
5
+
6
+ ### color
7
+ Sets the $color macro.
8
+
9
+ ### icon
10
+ The name of an icon to show with the title of the dialog.
11
+
12
+ ### message
13
+ The message to shwo in the confirm.
14
+
15
+ ### cancelText
16
+ The text for the button that cancels the dialog.
17
+
18
+ ### okText
19
+ The text for the button that confirms the dialog.
20
+
21
+ ### title
22
+ The title for the dialog.
23
+
24
+ ## Return Values
25
+ The Confirm component will return `true` from the `Modal.show` function if the
26
+ OK button is clicked, and false if the Cancel button is clicked.
27
+
28
+ ## Example
29
+ ```svelte
30
+ <script>
31
+ import { Confirm, Button, EntryButton, Modal } from "@axel669/zephyr"
32
+
33
+ let confirmModal = null
34
+ const confirmProps = {
35
+ title: "Confirm Example",
36
+ message: "This is an confirm!"
37
+ }
38
+ const show = async () => {
39
+ const result = await confirmModal.show(confirmProps)
40
+ if (result === true) {
41
+ console.log("confirmed!")
42
+ return
43
+ }
44
+ console.log("cancelled :(")
45
+ }
46
+ </script>
47
+
48
+ <Modal component={Confirm} bind:this={confirmModal} />
49
+ <Button on:click={show}>
50
+ Show Confirm
51
+ </Button>
52
+
53
+ <EntryButton props={confirmProps}>
54
+ Show Confirm
55
+ </EntryButton>
56
+ ```
@@ -16,7 +16,7 @@
16
16
  export let message
17
17
  export let okText = "OK"
18
18
  export let cancelText = "Cancel"
19
- export let color = "primary"
19
+ export let color = "@primary"
20
20
 
21
21
  const cls = handler$(close)
22
22
  </script>
package/src/functions.md CHANGED
@@ -81,3 +81,28 @@ directly.
81
81
  <span>Content</span>
82
82
  </div>
83
83
  ```
84
+
85
+ ## hash store
86
+ A svelte store that has the current value of the browser page hash. It uses
87
+ polling to check the value several times a second (it's a cheap check) so the
88
+ weird browser issues around hash change events don't affect it. Can also be used
89
+ to set the browser hash.
90
+
91
+ ### Example
92
+ ```svelte
93
+ <script>
94
+ import { hash } from "@axel669/zephyr"
95
+ </script>
96
+
97
+ <div>
98
+ Browser hash: {$hash}
99
+ </div>
100
+ ```
101
+
102
+ ## sorts
103
+ A collection fo sorting functions for use with the DataTable. Currently only
104
+ has natural sort as `sorts.natural(colProp)`.
105
+
106
+ ## filters
107
+ A collection of filter functions for use with the DataTable. Currently only has
108
+ a text filter function as `filter.text(colProp)`.
package/src/hash.js ADDED
@@ -0,0 +1,14 @@
1
+ import { readable } from "svelte/store"
2
+
3
+ export const hash = readable(
4
+ location.hash.slice(1),
5
+ (set) => {
6
+ setInterval(
7
+ () => set(location.hash.slice(1)),
8
+ 50
9
+ )
10
+ }
11
+ )
12
+ hash.set = (value) => {
13
+ location.hash = value
14
+ }
package/src/index.mjs CHANGED
@@ -38,7 +38,7 @@ export { default as Alert } from "./dialogs/alert.svelte"
38
38
  export { default as Confirm } from "./dialogs/confirm.svelte"
39
39
 
40
40
  export { default as DataTable } from "./composed/data-table.svelte"
41
- export { default as Th } from "./composed/data-table/th.svelte"
41
+ export { default as TH } from "./composed/data-table/th.svelte"
42
42
  export { default as EntryButton } from "./composed/entry-button.svelte"
43
43
  export { default as Toast } from "./composed/toast.svelte"
44
44
 
@@ -47,6 +47,7 @@ export { default as LoadZone } from "./async/load-zone.svelte"
47
47
 
48
48
  export { default as wsx } from "./wsx.mjs"
49
49
 
50
+ export { hash } from "./hash.js"
50
51
 
51
52
  export * from "./handler$.mjs"
52
53
  export * from "./composed/table-functions.js"
@@ -13,7 +13,7 @@
13
13
  </script>
14
14
 
15
15
  <slot name="toggle" {id} />
16
- <input type="checkbox" ws-x="hide" {id} />
16
+ <input type="checkbox" ws-x="[hide]" {id} />
17
17
  <ws-modal>
18
18
  <ws-paper use:wsx={paper}>
19
19
  <slot name="header" {id} />
@@ -16,7 +16,7 @@
16
16
 
17
17
  <!-- svelte-ignore a11y-click-events-have-key-events -->
18
18
  <!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
19
- <wind-wrapper transition:trick ws-x="$dialog grid" on:click|stopPropagation
19
+ <wind-wrapper transition:trick ws-x="@dialog [grid]" on:click|stopPropagation
20
20
  role="dialog">
21
21
  <Paper {...$$props}>
22
22
  <slot name="header" slot="header" />
@@ -3,16 +3,16 @@
3
3
  <script context="module">
4
4
  const defs = {
5
5
  select: {
6
- "$select": true,
6
+ "@select": true,
7
7
  "w.min": "35vw",
8
8
  grid: true,
9
9
  over: "hidden"
10
10
  },
11
11
  menu: {
12
- "$menu": true,
12
+ "@menu": true,
13
13
  },
14
14
  action: {
15
- "$action": true,
15
+ "@action": true,
16
16
  }
17
17
  }
18
18
  </script>
@@ -8,6 +8,7 @@
8
8
  export let gap = false
9
9
  export let cross = "stretch"
10
10
  export let main = "start"
11
+ export let scrollable = false
11
12
 
12
13
  $: wind = {
13
14
  "fl.dir": direction,
@@ -15,6 +16,7 @@
15
16
  "fl.main": main,
16
17
  p: pad,
17
18
  gap: gap,
19
+ over: (scrollable === true) ? "auto" : null,
18
20
  ...$$restProps
19
21
  }
20
22
  </script>
@@ -10,6 +10,7 @@
10
10
  export let rows = null
11
11
  export let autoCol = false
12
12
  export let autoRow = false
13
+ export let scrollable = false
13
14
 
14
15
  $: wind = {
15
16
  "gr.flow": direction,
@@ -19,6 +20,7 @@
19
20
  "gr.rows.a": autoRow,
20
21
  p: pad,
21
22
  gap: gap,
23
+ over: (scrollable === true) ? "auto" : null,
22
24
  ...$$restProps
23
25
  }
24
26
  </script>
@@ -44,7 +44,7 @@
44
44
  let visible = null
45
45
  </script>
46
46
 
47
- <input type="checkbox" bind:this={visible} ws-x="disp[none]" />
47
+ <input type="checkbox" bind:this={visible} ws-x="[disp none]" />
48
48
  {#if resolver !== null}
49
49
  <!-- svelte-ignore a11y-click-events-have-key-events -->
50
50
  <!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
@@ -22,8 +22,8 @@
22
22
  setContext(ctxStack, stack + 1)
23
23
 
24
24
  $: wind = {
25
- "&stack": stack.toString(),
26
- "&screen-width": width,
25
+ "@stack": stack.toString(),
26
+ "@screen-width": width,
27
27
  "bg.c": "transparent",
28
28
  ...$$restProps
29
29
  }