svelte-common 6.7.4 → 6.7.5
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 +1 -1
- package/src/pagination.mjs +7 -28
package/package.json
CHANGED
package/src/pagination.mjs
CHANGED
|
@@ -28,6 +28,7 @@ export class Pagination {
|
|
|
28
28
|
|
|
29
29
|
set filter(filter) {
|
|
30
30
|
this.#filter = filter;
|
|
31
|
+
this.recalibrateCurrentPage();
|
|
31
32
|
this.fireSubscriptions();
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -44,11 +45,15 @@ export class Pagination {
|
|
|
44
45
|
return this.#sorter;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
this.#data = data;
|
|
48
|
+
recalibrateCurrentPage() {
|
|
49
49
|
if (this.page > this.numberOfPages) {
|
|
50
50
|
this.page = this.numberOfPages;
|
|
51
51
|
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
set _data(data) {
|
|
55
|
+
this.#data = data;
|
|
56
|
+
this.recalibrateCurrentPage();
|
|
52
57
|
this.fireSubscriptions();
|
|
53
58
|
}
|
|
54
59
|
|
|
@@ -261,30 +266,4 @@ export function* navigationItems(
|
|
|
261
266
|
yield n;
|
|
262
267
|
}
|
|
263
268
|
}
|
|
264
|
-
|
|
265
|
-
/*
|
|
266
|
-
const pageJumps = [
|
|
267
|
-
{ maxPages: 10, stepping: [1] },
|
|
268
|
-
{ maxPages: 100, stepping: [1, 10] },
|
|
269
|
-
{ maxPages: 1000, stepping: [1, 10, 100] },
|
|
270
|
-
{ maxPages: 10000, stepping: [1, 100, 1000] },
|
|
271
|
-
{ maxPages: 100000, stepping: [1, 1000, 10000] }
|
|
272
|
-
];
|
|
273
|
-
|
|
274
|
-
for (const j of pageJumps) {
|
|
275
|
-
if (numberOfPages <= j.maxPages) {
|
|
276
|
-
yield 1;
|
|
277
|
-
for (const s of j.stepping) {
|
|
278
|
-
for (let n = currentPage - s; n < currentPage + s; n++) {
|
|
279
|
-
yield n;
|
|
280
|
-
}
|
|
281
|
-
yield currentPage;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
yield numberOfPages;
|
|
285
|
-
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
*/
|
|
290
269
|
}
|