@axel669/zephyr 0.2.0-beta.2 → 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 (54) 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 +7 -2
  7. package/src/composed/data-table/th.md +21 -0
  8. package/src/composed/data-table/th.svelte +4 -3
  9. package/src/composed/data-table.md +68 -67
  10. package/src/composed/data-table.svelte +98 -35
  11. package/src/composed/entry-button.md +23 -13
  12. package/src/composed/entry-button.svelte +2 -0
  13. package/src/composed/toast.md +30 -21
  14. package/src/composed/toast.svelte +3 -1
  15. package/src/control/button.svelte +2 -0
  16. package/src/control/input.md +87 -0
  17. package/src/control/input.svelte +5 -3
  18. package/src/control/label.md +0 -1
  19. package/src/control/label.svelte +3 -1
  20. package/src/control/link.svelte +6 -2
  21. package/src/control/radio.svelte +3 -1
  22. package/src/control/select.svelte +4 -2
  23. package/src/control/tabs.svelte +7 -3
  24. package/src/control/toggle.svelte +5 -3
  25. package/src/data-display/avatar.svelte +2 -0
  26. package/src/data-display/badge.svelte +3 -1
  27. package/src/data-display/chip.svelte +3 -1
  28. package/src/data-display/details.md +40 -1
  29. package/src/data-display/details.svelte +3 -1
  30. package/src/data-display/popover.svelte +3 -1
  31. package/src/data-display/progress.svelte +3 -1
  32. package/src/data-display/table.md +56 -4
  33. package/src/data-display/table.svelte +2 -0
  34. package/src/data-display/tooltip.svelte +2 -0
  35. package/src/dialogs/alert.md +40 -1
  36. package/src/dialogs/alert.svelte +3 -1
  37. package/src/dialogs/confirm.md +54 -1
  38. package/src/dialogs/confirm.svelte +3 -1
  39. package/src/functions.md +25 -0
  40. package/src/hash.js +14 -0
  41. package/src/index.mjs +2 -1
  42. package/src/inline-dialog.svelte +1 -1
  43. package/src/layout/dialog.svelte +3 -1
  44. package/src/layout/drawer.svelte +5 -3
  45. package/src/layout/flex.svelte +4 -0
  46. package/src/layout/grid.svelte +4 -0
  47. package/src/layout/modal.svelte +3 -1
  48. package/src/layout/paper.svelte +2 -0
  49. package/src/layout/screen.svelte +4 -2
  50. package/src/spinner/circle-spinner.svelte +4 -2
  51. package/src/spinner/hexagon-spinner.svelte +4 -2
  52. package/src/spinner/spinners.md +20 -1
  53. package/src/text.svelte +2 -0
  54. package/src/wsx.mjs +1 -1
@@ -1,36 +1,45 @@
1
1
  # Toast
2
-
3
- Displays toast notifications along the edge of the screen.
2
+ Displays toast notifications along the edge of the screen. Unlike the Toaster
3
+ component, this has functions for interacting with and generating toast
4
+ messages, where the Toaster component has the programmer manage the content.
4
5
 
5
6
  ## Props
6
7
  See the Toaster component. The Toast component is wrapper around it that
7
8
  also controls the children being shown for convenience.
8
9
 
9
- - ### component
10
- The component to use as a wrapper for the messages. Defaults to the
11
- ToastMessage component.
10
+ ### component
11
+ The component to use as a wrapper for the messages. Defaults to the
12
+ ToastMessage component.
13
+
14
+ ### position
15
+ The position to show modals in. Uses the same positions as the Windstorm
16
+ toaster.
12
17
 
13
18
  ## Functions
14
- - ### show(duration, props)
15
- Shows a toast notification that will disappear after the specified
16
- duration (time in milliseconds). The props provided are passed to an
17
- instance of the component specified in the props.
19
+
20
+ ### show(duration, props)
21
+ Shows a toast notification that will disappear after the specified
22
+ duration (time in milliseconds). The props provided are passed to an
23
+ instance of the component specified in the props.
18
24
 
19
25
  ## Events
20
- - ### action(info)
21
- Fired when a toast message is clicked. The info argument contains a
22
- value property that is provided by the message component, and a copy
23
- of the props passed to that instace.\\
24
- For the default messages, the value will be `null` if no button was
25
- clicked, and `true` if the action button was clicked. This allows
26
- actions to be taken against interactions in the message without having
27
- to bind all kinds of events or callbacks.
26
+
27
+ ### action
28
+ Fired when a toast message is clicked. The info argument contains a
29
+ value property that is provided by the message component, and a copy
30
+ of the props passed to that instace.
31
+
32
+ For the default messages, the value will be `null` if no button was
33
+ clicked, and `true` if the action button was clicked. This allows
34
+ actions to be taken against interactions in the message without having
35
+ to bind all kinds of events or callbacks.
28
36
 
29
37
  ## Example
30
- ```js
31
- let toast = null
32
- const notify = () => toast.show(5000, { message: "hi" })
33
- ```
34
38
  ```svelte
39
+ <script>
40
+ let toast = null
41
+ const notify = () => toast.show(5000, { message: "hi" })
42
+ </script>
43
+
35
44
  <Toast bind:this={toast} position="bc" />
36
45
  ```
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script context="module">
2
4
  const genID = () => `${Date.now()}:${Math.random().toString(16)}`
3
5
 
@@ -57,7 +59,7 @@
57
59
 
58
60
  <Toaster {position} {...$$restProps}>
59
61
  {#each items as {props, id} (id)}
60
- <zephyr-toast-wrapper ws-x="grid" transition:fade={{duration: 200}}>
62
+ <zephyr-toast-wrapper ws-x="[grid]" transition:fade={{duration: 200}}>
61
63
  <svelte:component
62
64
  this={component}
63
65
  {...props}
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
  import variant from "../variant.mjs"
@@ -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
+ ```
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script context="module">
2
4
  const parseNumeric = (value) => {
3
5
  if (value === "") {
@@ -21,7 +23,7 @@
21
23
 
22
24
  export let flat = false
23
25
  export let label
24
- export let color = "default"
26
+ export let color = "@default"
25
27
  export let error = null
26
28
  export let hint = null
27
29
  export let disabled
@@ -70,7 +72,7 @@
70
72
 
71
73
  $: wind = {
72
74
  "$flat": flat,
73
- "$control": true,
75
+ "@control": true,
74
76
  "$color": color,
75
77
  ...props.wind,
76
78
  }
@@ -80,7 +82,7 @@
80
82
 
81
83
  <label use:wsx={wind} ws-error={error}>
82
84
  {#if label}
83
- <span ws-x="$text" ws-hint={hint}>{label}</span>
85
+ <span use:wsx={{ slot: "label-text" }} ws-hint={hint}>{label}</span>
84
86
  {/if}
85
87
  <svelte:element
86
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
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
  import variant from "../variant.mjs"
@@ -18,7 +20,7 @@
18
20
  $: baseStyles =
19
21
  (button === true)
20
22
  ? {
21
- $button: true,
23
+ "@button": true,
22
24
  [type]: true,
23
25
  "$color": color,
24
26
  $compact: compact,
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
  import variant from "../variant.mjs"
@@ -13,16 +15,18 @@
13
15
  export let outline = false
14
16
  export let flat = false
15
17
 
18
+ export let disabled = null
19
+
16
20
  $: type = variant({ fill, outline, flat })
17
21
 
18
22
  $: wind = {
19
- "$button": button,
23
+ "@button": button,
20
24
  [type]: true,
21
25
  "$color": color,
22
26
  ...$$restProps
23
27
  }
24
28
  </script>
25
29
 
26
- <a {href} {target} {rel} use:wsx={wind}>
30
+ <a {href} {target} {rel} {disabled} use:wsx={wind} on:click>
27
31
  <slot />
28
32
  </a>
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
  import { handler$ } from "../handler$.mjs"
@@ -18,7 +20,7 @@
18
20
 
19
21
  <svelte:component this={layout} {...$$restProps}>
20
22
  {#each options as {value, label, disabled, ...wind}, index (value)}
21
- <label use:wsx={{"$toggle": true, ...wind}} {disabled}>
23
+ <label use:wsx={{"@toggle": true, ...wind}} {disabled}>
22
24
  <span>{label}</span>
23
25
  <input type="radio" on:input={set(value)} {name} checked={index === valueIndex} />
24
26
  </label>
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script context="module">
2
4
  const groupOptions = (options) => options.reduce(
3
5
  ({grouped, target = grouped}, item, pos) => {
@@ -31,7 +33,7 @@
31
33
  $: grouped = groupOptions(options)
32
34
 
33
35
  $: wind = {
34
- "$control": true,
36
+ "@control": true,
35
37
  "$outline": outline,
36
38
  "$color": color,
37
39
  ...$$restProps,
@@ -40,7 +42,7 @@
40
42
 
41
43
  <label use:wsx={wind}>
42
44
  {#if label}
43
- <span ws-x="$text">{label}</span>
45
+ <span ws-x="[$label-text]">{label}</span>
44
46
  {/if}
45
47
  <select value={indexValue} on:input={update} {disabled}>
46
48
  {#each grouped as item, index}
@@ -1,8 +1,10 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
  import { handler$ } from "../handler$.mjs"
4
6
 
5
- export let color = "primary"
7
+ export let color = "@primary"
6
8
  export let options = []
7
9
  export let vertical = false
8
10
  export let solid = false
@@ -20,7 +22,7 @@
20
22
  )
21
23
 
22
24
  $: wind = {
23
- "@solid": solid,
25
+ "$solid": solid,
24
26
  "$color": color,
25
27
  $vert: vertical,
26
28
  ...$$restProps,
@@ -33,7 +35,9 @@
33
35
  <!-- svelte-ignore a11y-interactive-supports-focus -->
34
36
  <ws-tab use:wsx={{"$tab-selected": index === i}}
35
37
  on:click={set(tab.value)} role="tab">
36
- {tab.label}
38
+ <slot {tab} selected={index === i}>
39
+ {tab.label}
40
+ </slot>
37
41
  </ws-tab>
38
42
  {/each}
39
43
  </ws-tabs>
@@ -1,8 +1,10 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
4
6
  export let label = ""
5
- export let color = "default"
7
+ export let color = "@default"
6
8
  export let checked = false
7
9
  export let flat = false
8
10
  export let value
@@ -11,14 +13,14 @@
11
13
  export let reverse = false
12
14
 
13
15
  $: container = {
14
- "$toggle": true,
16
+ "@toggle": true,
15
17
  "$flat": flat,
16
18
  "$color": color,
17
19
  "fl.dir": reverse ? "row-reverse" : false,
18
20
  ...$$restProps,
19
21
  }
20
22
  $: input = {
21
- "$switch": checkbox === false
23
+ "@switch": checkbox === false
22
24
  }
23
25
 
24
26
  const updateGroup = (checked) => {
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
@@ -1,7 +1,9 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
4
- export let color = "default"
6
+ export let color = "@default"
5
7
  export let text = ""
6
8
 
7
9
  $: wind = { "$color": color, ...$$restProps }
@@ -1,8 +1,10 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
  import variant from "../variant.mjs"
4
6
 
5
- export let color = "default"
7
+ export let color = "@default"
6
8
  export let clickable = false
7
9
 
8
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
+ ```
@@ -1,9 +1,11 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
4
6
  export let label
5
7
  export let outline
6
- export let color = "default"
8
+ export let color = "@default"
7
9
  export let open = false
8
10
 
9
11
  $: wind = {
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import { fade } from "svelte/transition"
3
5
  import wsx from "../wsx.mjs"
@@ -16,7 +18,7 @@
16
18
  <ws-popover use:wsx={wind}>
17
19
  <slot {show} />
18
20
  {#if visible}
19
- <wind-content slot="content" ws-x="inset[0px]" transition:fade={anim}>
21
+ <wind-content slot="content" ws-x="[inset 0px]" transition:fade={anim}>
20
22
  <slot name="content" {hide} />
21
23
  </wind-content>
22
24
  {/if}
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
@@ -19,7 +21,7 @@
19
21
 
20
22
  <label use:wsx={wind}>
21
23
  {#if label}
22
- <span ws-x="$text t-ws[nowrap]">{label}</span>
24
+ <span ws-x="[$progress-label] [t-ws nowrap]">{label}</span>
23
25
  {/if}
24
26
  <progress {value} {max} />
25
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,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import wsx from "../wsx.mjs"
3
5
 
@@ -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
+ ```
@@ -1,3 +1,5 @@
1
+ <svelte:options immutable />
2
+
1
3
  <script>
2
4
  import Button from "../control/button.svelte"
3
5
  import Dialog from "../layout/dialog.svelte"
@@ -10,7 +12,7 @@
10
12
  export let icon
11
13
  export let message
12
14
  export let okText = "OK"
13
- export let color = "primary"
15
+ export let color = "@primary"
14
16
  </script>
15
17
 
16
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
+ ```