svelte-common 6.2.6 → 6.3.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 +6 -3
- package/src/pagination.mjs +10 -3
- package/src/sorting.mjs +6 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-common",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
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
|
{
|
|
@@ -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": "^
|
|
55
|
+
"mf-styling": "^3.0.0",
|
|
53
56
|
"npm-pkgbuild": "^11.8.14",
|
|
54
57
|
"semantic-release": "^21.0.7",
|
|
55
58
|
"stylelint": "^15.10.1",
|
package/src/pagination.mjs
CHANGED
|
@@ -73,9 +73,15 @@ export class Pagination {
|
|
|
73
73
|
* @param {number} n
|
|
74
74
|
*/
|
|
75
75
|
set page(n) {
|
|
76
|
-
if
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
if(n < 0) {
|
|
77
|
+
n = this.numberOfPages + n + 1;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (this.#page !== n) {
|
|
81
|
+
if (n >= 1 && n <= this.numberOfPages) {
|
|
82
|
+
this.#page = n;
|
|
83
|
+
this.#subscriptions.forEach(subscription => subscription(this));
|
|
84
|
+
}
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
|
|
@@ -165,6 +171,7 @@ export class Pagination {
|
|
|
165
171
|
} else {
|
|
166
172
|
a.onclick = e => {
|
|
167
173
|
e.preventDefault();
|
|
174
|
+
e.stopPropagation();
|
|
168
175
|
this.page = targetPage;
|
|
169
176
|
};
|
|
170
177
|
}
|
package/src/sorting.mjs
CHANGED
|
@@ -94,14 +94,10 @@ export function sorter(sortBy, getters) {
|
|
|
94
94
|
let av = getter(a, key);
|
|
95
95
|
let bv = getter(b, key);
|
|
96
96
|
|
|
97
|
-
if (av === undefined) {
|
|
98
|
-
return bv === undefined ? 0 : -rev;
|
|
99
|
-
}
|
|
100
|
-
if (bv === undefined) {
|
|
101
|
-
return rev;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
97
|
switch (typeof av) {
|
|
98
|
+
case "undefined":
|
|
99
|
+
return bv === undefined ? 0 : -rev;
|
|
100
|
+
|
|
105
101
|
case "string":
|
|
106
102
|
switch (typeof bv) {
|
|
107
103
|
case "number":
|
|
@@ -111,6 +107,9 @@ export function sorter(sortBy, getters) {
|
|
|
111
107
|
}
|
|
112
108
|
}
|
|
113
109
|
|
|
110
|
+
if (bv === undefined) {
|
|
111
|
+
return rev;
|
|
112
|
+
}
|
|
114
113
|
if (av instanceof Date) {
|
|
115
114
|
av = av.getTime();
|
|
116
115
|
}
|