svelte-common 4.7.0 → 4.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-common",
3
- "version": "4.7.0",
3
+ "version": "4.8.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/index.svelte CHANGED
@@ -45,8 +45,9 @@
45
45
  formatSecondsSinceEpoch
46
46
  } from "./util.mjs";
47
47
  export {
48
+ sortable,
48
49
  toggleOrdeBy,
49
- orderByCycle,
50
+ orderByCycle,
50
51
  SORT_NONE,
51
52
  SORT_ASCENDING,
52
53
  SORT_DESCENDING
package/src/sorting.mjs CHANGED
@@ -10,7 +10,17 @@ export const orderByCycle = {
10
10
 
11
11
  /**
12
12
  * Deliver next value in the order by cycle.
13
+ * SORT_NONE -> SORT_ASCENDING -> SORT_DESCENDING -> SORT_NONE ...
13
14
  * @param {string} orderBy
14
15
  * @returns {string} new order either SORT_NONE, SORT_ASCENDING or SORT_DESCENDING
15
16
  */
16
- export function toggleOrdeBy(orderBy) { return orderByCycle[orderBy] || "none"; }
17
+ export function toggleOrdeBy(orderBy) { return orderByCycle[orderBy] || "none"; }
18
+
19
+
20
+ /**
21
+ * Add sortable toggle to a node.
22
+ * @param {Node} node
23
+ */
24
+ export function sortable(node) {
25
+ node.click = () => { node.sortable = toggleOrderBy(node.sortable); };
26
+ }