svelte-common 4.6.14 → 4.8.1

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
@@ -28,6 +28,8 @@ or the [live example](https://arlac77.github.io/components/svelte-common/example
28
28
 
29
29
  * [initializeServiceWorker](#initializeserviceworker)
30
30
  * [Parameters](#parameters)
31
+ * [toggleOrdeBy](#toggleordeby)
32
+ * [Parameters](#parameters-1)
31
33
 
32
34
  ## initializeServiceWorker
33
35
 
@@ -40,6 +42,16 @@ Create a store holding a service worker
40
42
 
41
43
  Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** store holding the service worker
42
44
 
45
+ ## toggleOrdeBy
46
+
47
+ Deliver next value in the order by cycle.
48
+
49
+ ### Parameters
50
+
51
+ * `orderBy` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
52
+
53
+ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** new order either SORT_NONE, SORT_ASCENDING or SORT_DESCENDING
54
+
43
55
  # install
44
56
 
45
57
  With [npm](http://npmjs.org) do:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-common",
3
- "version": "4.6.14",
3
+ "version": "4.8.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,7 +32,7 @@
32
32
  "preview": "vite preview"
33
33
  },
34
34
  "dependencies": {
35
- "svelte-command": "^1.1.22",
35
+ "svelte-command": "^1.1.23",
36
36
  "svelte-entitlement": "^1.2.30"
37
37
  },
38
38
  "devDependencies": {
package/src/index.svelte CHANGED
@@ -44,5 +44,13 @@
44
44
  formatDurationISO,
45
45
  formatSecondsSinceEpoch
46
46
  } from "./util.mjs";
47
+ export {
48
+ sortable,
49
+ toggleOrdeBy,
50
+ orderByCycle,
51
+ SORT_NONE,
52
+ SORT_ASCENDING,
53
+ SORT_DESCENDING
54
+ } from "./sorting.mjs";
47
55
  export { initializeServiceWorker } from "./service-worker.mjs";
48
56
  </script>
@@ -0,0 +1,26 @@
1
+ export const SORT_NONE = "none";
2
+ export const SORT_ASCENDING = "ascending";
3
+ export const SORT_DESCENDING = "descending";
4
+
5
+ export const orderByCycle = {
6
+ [SORT_NONE]: SORT_ASCENDING,
7
+ [SORT_ASCENDING]: SORT_DESCENDING,
8
+ [SORT_DESCENDING]: SORT_NONE
9
+ };
10
+
11
+ /**
12
+ * Deliver next value in the order by cycle.
13
+ * SORT_NONE -> SORT_ASCENDING -> SORT_DESCENDING -> SORT_NONE ...
14
+ * @param {string} orderBy
15
+ * @returns {string} new order either SORT_NONE, SORT_ASCENDING or SORT_DESCENDING
16
+ */
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
+ }