svelte-common 6.2.5 → 6.2.7

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 (2) hide show
  1. package/package.json +7 -4
  2. package/src/sorting.mjs +11 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-common",
3
- "version": "6.2.5",
3
+ "version": "6.2.7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -15,7 +15,10 @@
15
15
  "component",
16
16
  "svelte",
17
17
  "vite",
18
- "web"
18
+ "web",
19
+ "sorting",
20
+ "filtering",
21
+ "paginator"
19
22
  ],
20
23
  "contributors": [
21
24
  {
@@ -39,7 +42,7 @@
39
42
  },
40
43
  "dependencies": {
41
44
  "svelte-command": "^1.1.44",
42
- "svelte-entitlement": "^1.2.58"
45
+ "svelte-entitlement": "^1.2.59"
43
46
  },
44
47
  "devDependencies": {
45
48
  "@semantic-release/commit-analyzer": "^10.0.1",
@@ -49,7 +52,7 @@
49
52
  "ava": "^5.3.1",
50
53
  "c8": "^8.0.0",
51
54
  "documentation": "^14.0.2",
52
- "mf-styling": "^2.0.4",
55
+ "mf-styling": "^2.1.0",
53
56
  "npm-pkgbuild": "^11.8.14",
54
57
  "semantic-release": "^21.0.7",
55
58
  "stylelint": "^15.10.1",
package/src/sorting.mjs CHANGED
@@ -30,7 +30,7 @@ export function toggleOrderBy(orderBy) {
30
30
  * @param {WritableStore} store keep in sync with sorting properties
31
31
  */
32
32
  export function sortable(th, store) {
33
- const storeSubscription = store.subscribe(orderBy =>
33
+ const unsubscribe = store.subscribe(orderBy =>
34
34
  th.setAttribute(ARIA_SORT, orderBy[th.id] || SORT_NONE)
35
35
  );
36
36
 
@@ -50,11 +50,9 @@ export function sortable(th, store) {
50
50
  let sort = peer.getAttribute(ARIA_SORT);
51
51
 
52
52
  if (sort) {
53
- if (peer !== th) {
54
- if (sort !== SORT_NONE) {
55
- sort = SORT_NONE;
56
- peer.setAttribute(ARIA_SORT, sort);
57
- }
53
+ if (peer !== th && sort !== SORT_NONE) {
54
+ sort = SORT_NONE;
55
+ peer.setAttribute(ARIA_SORT, sort);
58
56
  }
59
57
 
60
58
  if (sort !== SORT_NONE) {
@@ -69,7 +67,7 @@ export function sortable(th, store) {
69
67
 
70
68
  return {
71
69
  destroy() {
72
- storeSubscription();
70
+ unsubscribe();
73
71
  }
74
72
  };
75
73
  }
@@ -96,14 +94,10 @@ export function sorter(sortBy, getters) {
96
94
  let av = getter(a, key);
97
95
  let bv = getter(b, key);
98
96
 
99
- if (av === undefined) {
100
- return bv === undefined ? 0 : -rev;
101
- }
102
- if (bv === undefined) {
103
- return rev;
104
- }
105
-
106
97
  switch (typeof av) {
98
+ case "undefined":
99
+ return bv === undefined ? 0 : -rev;
100
+
107
101
  case "string":
108
102
  switch (typeof bv) {
109
103
  case "number":
@@ -113,6 +107,9 @@ export function sorter(sortBy, getters) {
113
107
  }
114
108
  }
115
109
 
110
+ if (bv === undefined) {
111
+ return rev;
112
+ }
116
113
  if (av instanceof Date) {
117
114
  av = av.getTime();
118
115
  }