svelte-common 6.1.1 → 6.2.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 +2 -2
- package/src/pagination.mjs +19 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-common",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"ava": "^5.3.1",
|
|
49
49
|
"c8": "^8.0.0",
|
|
50
50
|
"documentation": "^14.0.2",
|
|
51
|
-
"mf-styling": "^2.0.
|
|
51
|
+
"mf-styling": "^2.0.3",
|
|
52
52
|
"npm-pkgbuild": "^11.8.14",
|
|
53
53
|
"semantic-release": "^21.0.7",
|
|
54
54
|
"stylelint": "^15.10.1",
|
package/src/pagination.mjs
CHANGED
|
@@ -11,6 +11,7 @@ export class Pagination {
|
|
|
11
11
|
#data;
|
|
12
12
|
#unsubscribeData;
|
|
13
13
|
#filter;
|
|
14
|
+
#sorter;
|
|
14
15
|
#itemsPerPage = 20;
|
|
15
16
|
#page = 1;
|
|
16
17
|
|
|
@@ -32,6 +33,18 @@ export class Pagination {
|
|
|
32
33
|
return this.#filter;
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
set sorter(sorter)
|
|
37
|
+
{
|
|
38
|
+
this.#sorter = sorter;
|
|
39
|
+
|
|
40
|
+
this.#subscriptions.forEach(subscription => subscription(this));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get sorter()
|
|
44
|
+
{
|
|
45
|
+
return this.#sorter;
|
|
46
|
+
}
|
|
47
|
+
|
|
35
48
|
set data(data) {
|
|
36
49
|
if (this.#unsubscribeData) {
|
|
37
50
|
this.#unsubscribeData();
|
|
@@ -116,6 +129,10 @@ export class Pagination {
|
|
|
116
129
|
data = data.filter(this.filter);
|
|
117
130
|
}
|
|
118
131
|
|
|
132
|
+
if(this.sorter) {
|
|
133
|
+
data = data.sort(this.sorter);
|
|
134
|
+
}
|
|
135
|
+
|
|
119
136
|
for (const item of data.slice(
|
|
120
137
|
n * this.itemsPerPage,
|
|
121
138
|
(n + 1) * this.itemsPerPage
|
|
@@ -145,10 +162,10 @@ export class Pagination {
|
|
|
145
162
|
a.innerText = innerText;
|
|
146
163
|
|
|
147
164
|
if (targetPage < 1 || targetPage > np) {
|
|
148
|
-
a.
|
|
165
|
+
a.ariaDisabled = "true";
|
|
149
166
|
} else {
|
|
150
167
|
if (targetPage === this.page) {
|
|
151
|
-
a.
|
|
168
|
+
a.ariaDisabled = "true";
|
|
152
169
|
a.classList.add("active");
|
|
153
170
|
a.setAttribute("aria-current", "page");
|
|
154
171
|
} else {
|