svelte-common 5.3.0 → 6.0.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/package.json +3 -3
- package/src/pagination.mjs +16 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"c8": "^8.0.0",
|
|
50
50
|
"documentation": "^14.0.2",
|
|
51
51
|
"mf-styling": "^2.0.1",
|
|
52
|
-
"npm-pkgbuild": "^11.8.
|
|
52
|
+
"npm-pkgbuild": "^11.8.14",
|
|
53
53
|
"semantic-release": "^21.0.7",
|
|
54
54
|
"stylelint": "^15.10.1",
|
|
55
55
|
"stylelint-config-standard": "^34.0.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"optionalDependencies": {
|
|
61
61
|
"mf-hosting-cloudflare": "^1.0.5",
|
|
62
|
-
"mf-hosting-frontend": "^1.
|
|
62
|
+
"mf-hosting-frontend": "^1.10.0"
|
|
63
63
|
},
|
|
64
64
|
"repository": {
|
|
65
65
|
"type": "git",
|
package/src/pagination.mjs
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pagination support store.
|
|
3
3
|
* Pages go from 1 ... numberOfPages
|
|
4
|
+
* @param {Map|Array|Store} data
|
|
5
|
+
* @param {Object} options
|
|
6
|
+
* @param {number} [options.itemsPerPage]
|
|
4
7
|
*/
|
|
5
8
|
export class Pagination {
|
|
6
9
|
#subscriptions = new Set();
|
|
7
10
|
#data;
|
|
8
11
|
#unsubscribeData;
|
|
9
12
|
|
|
10
|
-
#itemsPerPage =
|
|
13
|
+
#itemsPerPage = 20;
|
|
11
14
|
#page = 1;
|
|
12
15
|
|
|
13
|
-
constructor(data,
|
|
16
|
+
constructor(data, options) {
|
|
14
17
|
this.data = data;
|
|
15
|
-
|
|
18
|
+
if (options?.itemsPerPage) {
|
|
19
|
+
this.itemsPerPage = options.itemsPerPage;
|
|
20
|
+
}
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
set data(data) {
|
|
@@ -158,10 +163,13 @@ export function pageNavigation(elem, pg) {
|
|
|
158
163
|
*/
|
|
159
164
|
export function* navigationItems(nunmberOfPages, currentPage) {
|
|
160
165
|
const pageJumps = [
|
|
161
|
-
{ maxPages: 10,
|
|
162
|
-
{ maxPages: 100,
|
|
163
|
-
{ maxPages: 1000,
|
|
164
|
-
{ maxPages:
|
|
166
|
+
{ maxPages: 10, side: 1, edge: 2 },
|
|
167
|
+
{ maxPages: 100, side: 1, edge: 2, step: 10 },
|
|
168
|
+
{ maxPages: 1000, side: 1, edge: 2, step: 100 },
|
|
169
|
+
{ maxPages: 10000, side: 1, edge: 2, step: 1000 },
|
|
170
|
+
{ maxPages: 100000, side: 1, edge: 2, step: 10000 },
|
|
171
|
+
{ maxPages: 1000000, side: 1, edge: 2, step: 100000 },
|
|
172
|
+
{ maxPages: 10000000, side: 1, edge: 2, step: 1000000 }
|
|
165
173
|
];
|
|
166
174
|
|
|
167
175
|
for (const j of pageJumps) {
|
|
@@ -175,9 +183,8 @@ export function* navigationItems(nunmberOfPages, currentPage) {
|
|
|
175
183
|
) {
|
|
176
184
|
yield n;
|
|
177
185
|
}
|
|
178
|
-
}
|
|
186
|
+
}
|
|
179
187
|
break;
|
|
180
188
|
}
|
|
181
189
|
}
|
|
182
|
-
|
|
183
190
|
}
|