svelte-common 4.19.5 → 4.19.8

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.
package/README.md CHANGED
@@ -61,8 +61,8 @@ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
61
61
 
62
62
  ## sortable
63
63
 
64
- Add sortable toggle button with img element to a node.
65
- Synchronizes store value with node "aria-sort" attribute.
64
+ Add sortable toggle button to a th node.
65
+ Synchronizes store value with th nodes "aria-sort" attribute.
66
66
 
67
67
  ### Parameters
68
68
 
@@ -84,7 +84,9 @@ Returns **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference
84
84
 
85
85
  ## keyPrefixStore
86
86
 
87
- Create a store where all the object keys are prefixed.
87
+ Create a derived store where all the object keys are prefixed.
88
+
89
+ { a: 1, b: 2 } -> { prefix_a: 1 prefix_b: 2 }
88
90
 
89
91
  ### Parameters
90
92
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-common",
3
- "version": "4.19.5",
3
+ "version": "4.19.8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,17 +39,17 @@
39
39
  "@semantic-release/commit-analyzer": "^9.0.2",
40
40
  "@semantic-release/exec": "^6.0.3",
41
41
  "@semantic-release/release-notes-generator": "^10.0.3",
42
- "@sveltejs/vite-plugin-svelte": "^1.0.4",
42
+ "@sveltejs/vite-plugin-svelte": "^1.0.5",
43
43
  "ava": "^4.3.3",
44
44
  "documentation": "^14.0.0",
45
- "mf-styling": "^1.7.12",
45
+ "mf-styling": "^1.7.14",
46
46
  "npm-pkgbuild": "^10.14.8",
47
47
  "semantic-release": "^19.0.5",
48
48
  "stylelint": "^14.11.0",
49
49
  "stylelint-config-standard": "^28.0.0",
50
50
  "svelte": "^3.50.0",
51
51
  "testcafe": "^2.0.0",
52
- "vite": "^3.0.9"
52
+ "vite": "^3.1.0"
53
53
  },
54
54
  "optionalDependencies": {
55
55
  "mf-hosting": "^1.7.3"
@@ -10,7 +10,7 @@
10
10
  <tr>
11
11
  <td />
12
12
  <td>Username</td>
13
- <td>{session.username}</td>
13
+ <td>{session.username ? session.username : ""}</td>
14
14
  </tr>
15
15
  <tr>
16
16
  <td />
@@ -3,7 +3,17 @@
3
3
 
4
4
  export let id;
5
5
 
6
+ let header, content;
6
7
  const tabs = getContext("TABS");
8
+ tabs.tab[id] = { header, content };
7
9
  </script>
8
10
 
9
- <slot />
11
+ {#if false}
12
+ <div bind:this={header}>
13
+ <slot name="header" />
14
+ </div>
15
+
16
+ <div bind:this={content}>
17
+ <slot />
18
+ </div>
19
+ {/if}
@@ -1,9 +1,14 @@
1
1
  <script>
2
2
  import { setContext } from "svelte";
3
3
 
4
- const tabs = {};
4
+ const tabs = { tab: {}};
5
5
 
6
6
  setContext("TABS", tabs);
7
7
  </script>
8
8
 
9
9
  <slot />
10
+
11
+ {#each Object.entries(tabs.tab) as t}
12
+ {t[0]}
13
+ <svelte:component this={t[1].header}/>
14
+ {/each}
package/src/sorting.mjs CHANGED
@@ -20,13 +20,13 @@ export function toggleOrderBy(orderBy) {
20
20
  }
21
21
 
22
22
  /**
23
- * Add sortable toggle button to a node.
24
- * Synchronizes store value with node "aria-sort" attribute.
23
+ * Add sortable toggle button to a th node.
24
+ * Synchronizes store value with th nodes "aria-sort" attribute.
25
25
  * @param {Node} the header node
26
26
  * @param {WritableStore} to keep in sync with sorting properties
27
27
  */
28
28
  export function sortable(th, store) {
29
- store.subscribe(orderBy =>
29
+ const storeSubscription = store.subscribe(orderBy =>
30
30
  th.setAttribute("aria-sort", orderBy[th.id] || SORT_NONE)
31
31
  );
32
32
 
@@ -37,7 +37,6 @@ export function sortable(th, store) {
37
37
  const button = document.createElement("button");
38
38
  button.setAttribute("aria-label", `toggle sort of ${th.id}`);
39
39
  button.setAttribute("class", "alter-sorting");
40
-
41
40
  button.onclick = () => {
42
41
  const orderBy = {};
43
42
 
@@ -54,9 +53,7 @@ export function sortable(th, store) {
54
53
  }
55
54
  }
56
55
 
57
- if (sort === SORT_NONE) {
58
- delete orderBy[peer.id];
59
- } else {
56
+ if (sort !== SORT_NONE) {
60
57
  orderBy[peer.id] = sort;
61
58
  }
62
59
  }
@@ -65,6 +62,12 @@ export function sortable(th, store) {
65
62
  };
66
63
 
67
64
  th.appendChild(button);
65
+
66
+ return {
67
+ destroy() {
68
+ storeSubscription();
69
+ }
70
+ };
68
71
  }
69
72
 
70
73
  /**
package/src/util.mjs CHANGED
@@ -96,7 +96,10 @@ function liveDuration(seconds) {
96
96
  */
97
97
 
98
98
  /**
99
- * Create a store where all the object keys are prefixed.
99
+ * Create a derived store where all the object keys are prefixed.
100
+ * ```
101
+ * { a: 1, b: 2 } -> { prefix_a: 1 prefix_b: 2 }
102
+ * ```
100
103
  * @param {WriteableStore} store
101
104
  * @param {string} prefix
102
105
  * @returns {WriteableStore}