@axel669/zephyr 0.4.7 → 0.5.4

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 (58) hide show
  1. package/package.json +12 -10
  2. package/readme.md +8 -1
  3. package/src/async/button.svelte +17 -13
  4. package/src/async/suspend.svelte +38 -0
  5. package/src/changed.js +10 -0
  6. package/src/composed/data-table/th.svelte +2 -2
  7. package/src/composed/data-table.svelte +154 -180
  8. package/src/composed/entry-button.svelte +13 -16
  9. package/src/control/button.svelte +26 -22
  10. package/src/control/input.svelte +52 -50
  11. package/src/control/label.svelte +28 -24
  12. package/src/control/link.svelte +36 -30
  13. package/src/control/radio-group.svelte +13 -10
  14. package/src/control/select.svelte +21 -16
  15. package/src/control/tabs.svelte +18 -14
  16. package/src/control/toggle.svelte +33 -22
  17. package/src/custom-macros.js +9 -0
  18. package/src/data-display/avatar.svelte +12 -11
  19. package/src/data-display/badge.svelte +9 -7
  20. package/src/data-display/chip.svelte +27 -17
  21. package/src/data-display/details.svelte +22 -14
  22. package/src/data-display/popover.svelte +12 -9
  23. package/src/data-display/progress.svelte +17 -13
  24. package/src/data-display/table.svelte +29 -17
  25. package/src/data-display/tooltip.svelte +11 -9
  26. package/src/dialogs/alert.svelte +18 -12
  27. package/src/dialogs/confirm.svelte +22 -16
  28. package/src/{hash.js → hash.svelte.js} +9 -0
  29. package/src/{index.mjs → index.js} +10 -10
  30. package/src/{composed/element-toast.svelte → info/element-toaster.svelte} +41 -27
  31. package/src/info/icon.svelte +4 -4
  32. package/src/info/titlebar.svelte +20 -14
  33. package/src/info/toast.svelte +35 -0
  34. package/src/info/toaster/message.svelte +42 -0
  35. package/src/info/toaster.svelte +64 -6
  36. package/src/layout/dialog.svelte +10 -12
  37. package/src/layout/drawer.svelte +45 -18
  38. package/src/layout/flex.svelte +13 -11
  39. package/src/layout/grid.svelte +17 -15
  40. package/src/layout/modal.svelte +34 -26
  41. package/src/layout/paper.svelte +31 -33
  42. package/src/layout/screen.svelte +13 -9
  43. package/src/props.js +24 -0
  44. package/src/routing/route.svelte +29 -16
  45. package/src/routing/{routing.js → routing.svelte.js} +10 -1
  46. package/src/routing/title.svelte +8 -6
  47. package/src/spinner/circle-spinner.svelte +10 -8
  48. package/src/spinner/hexagon-spinner.svelte +10 -8
  49. package/src/text.svelte +6 -10
  50. package/src/wind.js +4 -0
  51. package/src/{wsx.mjs → wsx.js} +1 -1
  52. package/src/async/load-zone.svelte +0 -22
  53. package/src/composed/toast/message.svelte +0 -33
  54. package/src/composed/toast.svelte +0 -70
  55. package/src/info/notification.svelte +0 -28
  56. package/src/inline-dialog.svelte +0 -23
  57. /package/src/{handler$.mjs → handler$.js} +0 -0
  58. /package/src/{variant.mjs → variant.js} +0 -0
@@ -1,23 +1,31 @@
1
- <svelte:options immutable />
2
-
3
1
  <script>
4
- import wsx, { none } from "../wsx.mjs"
5
- import variant from "../variant.mjs"
2
+ import wsx, { none } from "../wsx.js"
3
+ import variant from "../variant.js"
4
+ import { splitProps } from "../props.js"
5
+
6
+ let {
7
+ type = "text",
8
+
9
+ flat = false,
10
+ lined = false,
11
+ linedFill = false,
12
+ outline = false,
13
+ label,
14
+ color = "@default",
15
+ disabled,
6
16
 
7
- export let type = "text"
17
+ value = $bindable(""),
18
+ autocompleteOptions = null,
8
19
 
9
- export let flat = false
10
- export let lined = false
11
- export let linedFill = false
12
- export let outline = false
13
- export let label
14
- export let color = "@default"
15
- export let disabled
20
+ start,
21
+ end,
22
+ extra,
16
23
 
17
- export let value = ""
18
- export let autocompleteOptions = null
24
+ oninput,
25
+ ...rest
26
+ } = $props()
19
27
 
20
- let input = null
28
+ let input = $state(null)
21
29
  export const focus = () => input.focus()
22
30
 
23
31
  const id =
@@ -25,37 +33,33 @@
25
33
  ? null
26
34
  : `${Math.random().toString(16)}_${Date.now()}`
27
35
 
28
- const update = (evt) => value = evt.target.value
29
-
30
- $: restKeys = Object.keys($$restProps)
31
- $: props = restKeys.reduce(
32
- (props, key) => {
33
- const [target, name] =
34
- (key.startsWith("i-") === true)
35
- ? [props.input, key.slice(2)]
36
- : [props.wind, key]
37
- target[name] = $$restProps[key]
38
- return props
39
- },
40
- {wind: {}, input: {}}
41
- )
36
+ const prop = splitProps(rest, "i!")
42
37
 
43
- $: variantStyle = variant(
44
- none,
45
- { outline },
46
- { linedFill },
47
- { lined },
48
- { flat }
38
+ const variantStyle = $derived(
39
+ variant(
40
+ none,
41
+ { outline },
42
+ { linedFill },
43
+ { lined },
44
+ { flat }
45
+ )
49
46
  )
50
47
 
51
- $: wind = {
48
+ const wind = $derived({
52
49
  [variantStyle]: true,
53
50
  "@@control": true,
54
51
  "$color": color,
55
- ...props.wind,
56
- }
52
+ ...prop.rest,
53
+ })
54
+
55
+ const tag = $derived(
56
+ (type === "area") ? "textarea" : "input"
57
+ )
57
58
 
58
- $: tag = (type === "area") ? "textarea" : "input"
59
+ const update = (evt) => {
60
+ value = evt.target.value
61
+ oninput?.(evt)
62
+ }
59
63
  </script>
60
64
 
61
65
  <label use:wsx={wind}>
@@ -64,37 +68,35 @@
64
68
  {/if}
65
69
  <svelte:element
66
70
  this={tag}
67
- {...props.input}
71
+ {...prop.input}
68
72
  {disabled}
69
73
  {type}
70
74
  {value}
75
+ oninput={update}
71
76
  list={id}
72
- on:focus
73
- on:blur
74
- on:input={update}
75
77
  bind:this={input}
76
78
  />
77
79
 
78
- {#if $$slots.start}
80
+ {#if start}
79
81
  <span use:wsx={{ "$start": true }}>
80
- <slot name="start" />
82
+ {@render start()}
81
83
  </span>
82
84
  {/if}
83
- {#if $$slots.end}
85
+ {#if end}
84
86
  <span use:wsx={{ "$end": true }}>
85
- <slot name="end" />
87
+ {@render end()}
86
88
  </span>
87
89
  {/if}
88
- {#if $$slots.extra}
90
+ {#if extra}
89
91
  <span use:wsx={{ "$extra": true }}>
90
- <slot name="extra" />
92
+ {@render extra()}
91
93
  </span>
92
94
  {/if}
93
95
 
94
96
  {#if autocompleteOptions !== null}
95
97
  <datalist {id}>
96
98
  {#each autocompleteOptions as value}
97
- <option {value} />
99
+ <option {value}>{value}</option>
98
100
  {/each}
99
101
  </datalist>
100
102
  {/if}
@@ -1,29 +1,32 @@
1
- <svelte:options immutable />
2
-
3
1
  <script>
4
- import wsx from "../wsx.mjs"
5
- import variant from "../variant.mjs"
2
+ import wsx from "../wsx.js"
3
+ import variant from "../variant.js"
6
4
 
7
- export let color = false
8
- export let compact = false
9
- export let ground = false
10
- export let disabled
5
+ const {
6
+ color = false,
7
+ compact = false,
8
+ ground = false,
9
+ disabled,
11
10
 
12
- export let fill = false
13
- export let outline = false
14
- export let flat = false
11
+ button = false,
12
+ fill = false,
13
+ outline = false,
14
+ flat = false,
15
+ for:_for = "",
15
16
 
16
- let _for = ""
17
- export { _for as for }
18
- export let button = false
17
+ children,
18
+ ...rest
19
+ } = $props()
19
20
 
20
- $: type = variant(
21
- "$flat",
22
- { fill },
23
- { outline },
24
- { flat }
21
+ const type = $derived(
22
+ variant(
23
+ "$flat",
24
+ { fill },
25
+ { outline },
26
+ { flat }
27
+ )
25
28
  )
26
- $: baseStyles =
29
+ const baseStyles = $derived(
27
30
  (button === true)
28
31
  ? {
29
32
  "@@button": true,
@@ -33,13 +36,14 @@
33
36
  $ground: ground,
34
37
  }
35
38
  : {}
39
+ )
36
40
 
37
- $: wind = {
41
+ const wind = $derived({
38
42
  ...baseStyles,
39
- ...$$restProps
40
- }
43
+ ...rest
44
+ })
41
45
  </script>
42
46
 
43
47
  <label use:wsx={wind} {disabled} for={_for}>
44
- <slot />
48
+ {@render children?.()}
45
49
  </label>
@@ -1,41 +1,47 @@
1
- <svelte:options immutable />
2
-
3
1
  <script>
4
- import wsx from "../wsx.mjs"
5
- import variant from "../variant.mjs"
6
-
7
- export let button = false
8
- export let color = false
9
- export let compact = false
10
- export let ground = false
11
-
12
- export let href = ""
13
- export let rel = "noreferrer"
14
- export let target = null
15
-
16
- export let fill = false
17
- export let outline = false
18
- export let flat = false
19
-
20
- export let disabled = null
21
-
22
- $: type = variant(
23
- "$flat",
24
- { fill },
25
- { outline },
26
- { flat }
2
+ import wsx from "../wsx.js"
3
+ import variant from "../variant.js"
4
+
5
+ const {
6
+ button = false,
7
+ color = false,
8
+ compact = false,
9
+ ground = false,
10
+
11
+ href = "",
12
+ rel = "noreferrer",
13
+ target = null,
14
+
15
+ fill = false,
16
+ outline = false,
17
+ flat = false,
18
+
19
+ disabled = null,
20
+
21
+ onclick,
22
+ children,
23
+ ...rest
24
+ } = $props()
25
+
26
+ const type = $derived(
27
+ variant(
28
+ "$flat",
29
+ { fill },
30
+ { outline },
31
+ { flat }
32
+ )
27
33
  )
28
34
 
29
- $: wind = {
35
+ const wind = $derived({
30
36
  "@@button": button,
31
37
  [type]: true,
32
38
  "$color": color,
33
39
  $compact: compact,
34
40
  $ground: ground,
35
- ...$$restProps
36
- }
41
+ ...rest
42
+ })
37
43
  </script>
38
44
 
39
- <a {href} {target} {rel} disabled={disabled || null} use:wsx={wind} on:click>
40
- <slot />
45
+ <a {href} {target} {rel} disabled={disabled || null} use:wsx={wind} {onclick}>
46
+ {@render children?.()}
41
47
  </a>
@@ -1,21 +1,24 @@
1
- <svelte:options immutable />
2
-
3
1
  <script>
4
- import wsx from "../wsx.mjs"
5
- import { handler$ } from "../handler$.mjs"
2
+ import wsx from "../wsx.js"
3
+ import { handler$ } from "../handler$.js"
6
4
 
7
5
  import Flex from "../layout/flex.svelte"
8
6
 
9
- export let options = []
10
- export let layout = Flex
11
- export let value
7
+ let {
8
+ layout = Flex,
9
+ options = [],
10
+ value = $bindable(),
11
+ ...rest
12
+ } = $props()
13
+
14
+ const Layout = $derived(layout)
12
15
  </script>
13
16
 
14
- <svelte:component this={layout} {...$$restProps}>
15
- {#each options as {value: itemValue, label, disabled, ...wind}, index (value)}
17
+ <Layout {...rest}>
18
+ {#each options as {value: itemValue, label, disabled, ...wind}, index (itemValue)}
16
19
  <label use:wsx={{"@@toggle": true, ...wind}} {disabled}>
17
20
  <span>{label}</span>
18
21
  <input type="radio" value={itemValue} bind:group={value} />
19
22
  </label>
20
23
  {/each}
21
- </svelte:component>
24
+ </Layout>
@@ -1,6 +1,4 @@
1
- <svelte:options immutable />
2
-
3
- <script context="module">
1
+ <script module>
4
2
  const groupOptions = (options) => options.reduce(
5
3
  ({grouped, target = grouped}, item, pos) => {
6
4
  const opt = { ... item, pos }
@@ -17,34 +15,41 @@
17
15
  </script>
18
16
 
19
17
  <script>
20
- import wsx from "../wsx.mjs"
18
+ import wsx from "../wsx.js"
21
19
 
22
- export let options = []
23
- export let value
24
- export let color = "@default"
25
- export let flat = false
26
- export let label = null
27
- export let disabled = false
20
+ let {
21
+ disabled = false,
22
+ color = "@default",
23
+ flat = false,
24
+ label = null,
25
+ options = [],
26
+ value = $bindable(),
27
+ ...rest
28
+ } = $props()
28
29
 
29
30
  const update = (evt) => value = options[evt.target.value].value
30
31
 
31
- $: indexValue = options.findIndex(item => item.value === value)
32
+ const indexValue = $derived(
33
+ options.findIndex(item => item.value === value)
34
+ )
32
35
 
33
- $: grouped = groupOptions(options)
36
+ const grouped = $derived(
37
+ groupOptions(options)
38
+ )
34
39
 
35
- $: wind = {
40
+ const wind = $derived({
36
41
  "@@control": true,
37
42
  "$flat": flat,
38
43
  "$color": color,
39
- ...$$restProps,
40
- }
44
+ ...rest,
45
+ })
41
46
  </script>
42
47
 
43
48
  <label use:wsx={wind}>
44
49
  {#if label}
45
50
  <span ws-x="[$label]">{label}</span>
46
51
  {/if}
47
- <select value={indexValue} on:input={update} {disabled}>
52
+ <select value={indexValue} oninput={update} {disabled}>
48
53
  {#each grouped as item, index}
49
54
  {#if Array.isArray(item) === false}
50
55
  <option value={item.pos}>
@@ -1,31 +1,35 @@
1
- <svelte:options immutable />
2
-
3
1
  <script>
4
2
  import { writable } from "svelte/store"
5
3
 
6
- import wsx from "../wsx.mjs"
7
- import { handler$ } from "../handler$.mjs"
4
+ import wsx from "../wsx.js"
5
+ import { handler$ } from "../handler$.js"
6
+ import { splitProps } from "../props.js"
8
7
 
9
- export let color = "@default"
10
- export let options = []
11
- export let vertical = false
12
- export let fill = false
13
- export let value
8
+ let {
9
+ color = "@default",
10
+ fill = false,
11
+ options = [],
12
+ value = $bindable(),
13
+ vertical = false,
14
+ ...rest
15
+ } = $props()
14
16
 
15
- $: wind = {
17
+ const props = $derived(
18
+ splitProps(rest, "t!")
19
+ )
20
+ const wind = $derived({
16
21
  "$fill": fill,
17
22
  "$color": color,
18
23
  $vert: vertical,
19
- ...$$restProps,
20
- }
24
+ ...props.rest,
25
+ })
21
26
  </script>
22
27
 
23
- <!-- svelte-ignore a11y-click-events-have-key-events -->
24
28
  <ws-tabs use:wsx={wind} role="tablist">
25
29
  {#each options as tab, i}
26
30
  <label>
27
31
  <input type="radio" value={tab.value} bind:group={value} />
28
- <ws-tab>{tab.label}</ws-tab>
32
+ <ws-tab use:wsx={props["t!"]}>{tab.label}</ws-tab>
29
33
  </label>
30
34
  {/each}
31
35
  </ws-tabs>
@@ -1,49 +1,60 @@
1
- <svelte:options immutable />
2
-
3
1
  <script>
4
- import wsx from "../wsx.mjs"
2
+ import wsx from "../wsx.js"
5
3
 
6
- export let label = ""
7
- export let color = "@default"
8
- export let checked = false
9
- export let flat = false
10
- export let value
11
- export let group = []
12
- export let checkbox = false
13
- export let reverse = false
4
+ let {
5
+ color = "@default",
6
+ checkbox = false,
7
+ checked = $bindable(),
8
+ flat = false,
9
+ group = $bindable(),
10
+ label = "",
11
+ reverse = false,
12
+ value,
13
+ children,
14
+ ...rest
15
+ } = $props()
14
16
 
15
- $: container = {
17
+ const container = $derived({
16
18
  "@@toggle": true,
17
19
  "$flat": flat,
18
20
  "$color": color,
19
21
  "fl.dir": reverse ? "row-reverse" : false,
20
- ...$$restProps,
21
- }
22
- $: input = {
22
+ ...rest,
23
+ })
24
+ const input = $derived({
23
25
  "@@switch": checkbox === false
24
- }
26
+ })
25
27
 
26
28
  const updateGroup = (checked) => {
29
+ if (Array.isArray(group) === false) {
30
+ return
31
+ }
27
32
  if (checked === true) {
28
33
  if (group.includes(value) === true) {
29
34
  return
30
35
  }
31
- group = [...group, value]
36
+ group.push(value)
32
37
  return
33
38
  }
34
39
  if (group.includes(value) === false) {
35
40
  return
36
41
  }
37
- group = group.filter(item => item !== value)
42
+ group.splice(group.indexOf(value), 1)
43
+ }
44
+ const get = () => checked
45
+ const set = (next) => {
46
+ checked = next
47
+ updateGroup(next)
38
48
  }
39
- $: updateGroup(checked)
40
49
  </script>
41
50
 
42
51
  <label use:wsx={container}>
43
52
  <div>
44
- <slot>
53
+ {#if children}
54
+ {@render children()}
55
+ {:else}
45
56
  {label}
46
- </slot>
57
+ {/if}
47
58
  </div>
48
- <input type="checkbox" bind:checked use:wsx={input} />
59
+ <input type="checkbox" bind:checked={get,set} use:wsx={input} />
49
60
  </label>
@@ -0,0 +1,9 @@
1
+ const head = document.head
2
+ const macros = document.createElement("style")
3
+ macros.setAttribute("ws-root", "")
4
+ macros.innerHTML = `
5
+ .ws-style {
6
+ --con: "contain: {$}";
7
+ }
8
+ `
9
+ head.append(macros)
@@ -1,24 +1,25 @@
1
- <svelte:options immutable />
2
-
3
1
  <script>
4
- import wsx from "../wsx.mjs"
2
+ import wsx from "../wsx.js"
5
3
 
6
- export let alt = ""
7
- export let image = null
4
+ let {
5
+ alt = "",
6
+ image = null,
8
7
 
9
- export let text = ""
8
+ text = "",
10
9
 
11
- export let color = false
10
+ color = false,
11
+ ...rest
12
+ } = $props()
12
13
 
13
- $: wind = {
14
+ const wind = $derived({
14
15
  "$color": color,
15
- ...$$restProps
16
- }
16
+ ...rest
17
+ })
17
18
  </script>
18
19
 
19
20
  <ws-avatar use:wsx={wind}>
20
21
  {#if image !== null}
21
- <!-- svelte-ignore a11y-missing-attribute -->
22
+ <!-- svelte-ignore a11y_missing_attribute -->
22
23
  <object data={image} type="image/png">
23
24
  {alt}
24
25
  </object>
@@ -1,14 +1,16 @@
1
- <svelte:options immutable />
2
-
3
1
  <script>
4
- import wsx from "../wsx.mjs"
2
+ import wsx from "../wsx.js"
5
3
 
6
- export let color = null
7
- export let text = ""
4
+ let {
5
+ color = null,
6
+ text = "",
7
+ children,
8
+ ...rest
9
+ } = $props()
8
10
 
9
- $: wind = { "$color": color, ...$$restProps }
11
+ const wind = $derived({ "$color": color, ...rest })
10
12
  </script>
11
13
 
12
14
  <ws-badge ws-text={text} use:wsx={wind}>
13
- <slot />
15
+ {@render children?.()}
14
16
  </ws-badge>
@@ -1,28 +1,38 @@
1
- <svelte:options immutable />
2
-
3
1
  <script>
4
- import wsx from "../wsx.mjs"
5
- import variant from "../variant.mjs"
2
+ import wsx from "../wsx.js"
3
+ import variant from "../variant.js"
6
4
 
7
- export let color = "@default"
8
- export let clickable = false
5
+ let {
6
+ color = "@default",
7
+ clickable = false,
9
8
 
10
- export let fill = false
11
- export let outline = false
12
- export let flat = false
9
+ fill = false,
10
+ outline = false,
11
+ flat = false,
12
+ children,
13
+ onclick,
14
+ ...rest
15
+ } = $props()
13
16
 
14
- $: type = variant({ fill, flat, outline }, "$outline")
17
+ const type = $derived(
18
+ variant(
19
+ "$outline",
20
+ { fill },
21
+ { outline },
22
+ { flat },
23
+ )
24
+ )
15
25
 
16
- $: wind = {
26
+ const wind = $derived({
17
27
  [type]: true,
18
28
  "$color": color,
19
29
  "@@click": clickable,
20
- ...$$restProps
21
- }
30
+ ...rest
31
+ })
22
32
  </script>
23
33
 
24
- <!-- svelte-ignore a11y-click-events-have-key-events -->
25
- <!-- svelte-ignore a11y-interactive-supports-focus -->
26
- <ws-chip use:wsx={wind} on:click role="button">
27
- <slot />
34
+ <!-- svelte-ignore a11y_interactive_supports_focus -->
35
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
36
+ <ws-chip use:wsx={wind} {onclick} role="button">
37
+ {@render children?.()}
28
38
  </ws-chip>