svelte-common 5.2.1 → 5.2.2
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 +12 -9
package/package.json
CHANGED
package/src/pagination.mjs
CHANGED
|
@@ -32,8 +32,6 @@ export class Pagination {
|
|
|
32
32
|
this.#subscriptions.forEach(subscription => subscription(this));
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
35
|
get itemsPerPage() {
|
|
38
36
|
return this.#itemsPerPage;
|
|
39
37
|
}
|
|
@@ -72,7 +70,7 @@ export class Pagination {
|
|
|
72
70
|
get numberOfPages() {
|
|
73
71
|
return Math.ceil(
|
|
74
72
|
(Array.isArray(this.#data) ? this.#data.length : this.#data.size) /
|
|
75
|
-
|
|
73
|
+
this.itemsPerPage
|
|
76
74
|
);
|
|
77
75
|
}
|
|
78
76
|
|
|
@@ -81,7 +79,7 @@ export class Pagination {
|
|
|
81
79
|
}
|
|
82
80
|
|
|
83
81
|
*[Symbol.iterator]() {
|
|
84
|
-
const n = this.page - 1;
|
|
82
|
+
const n = this.page - 1;
|
|
85
83
|
|
|
86
84
|
const data = Array.isArray(this.data)
|
|
87
85
|
? this.#data
|
|
@@ -99,7 +97,7 @@ export class Pagination {
|
|
|
99
97
|
* @deprecated
|
|
100
98
|
*/
|
|
101
99
|
*items() {
|
|
102
|
-
const n = this.page - 1;
|
|
100
|
+
const n = this.page - 1;
|
|
103
101
|
|
|
104
102
|
const data = Array.isArray(this.data)
|
|
105
103
|
? this.#data
|
|
@@ -131,12 +129,17 @@ export class Pagination {
|
|
|
131
129
|
a.setAttribute("aria-label", label);
|
|
132
130
|
}
|
|
133
131
|
a.innerText = innerText;
|
|
134
|
-
|
|
132
|
+
|
|
133
|
+
if (targetPage < 1 || targetPage > this.numberOfPages) {
|
|
135
134
|
a.disabled = true;
|
|
136
|
-
a.classList.add("active");
|
|
137
|
-
a.setAttribute("aria-current", "page");
|
|
138
135
|
} else {
|
|
139
|
-
|
|
136
|
+
if (targetPage === this.page) {
|
|
137
|
+
a.disabled = true;
|
|
138
|
+
a.classList.add("active");
|
|
139
|
+
a.setAttribute("aria-current", "page");
|
|
140
|
+
} else {
|
|
141
|
+
a.onclick = () => (this.page = targetPage);
|
|
142
|
+
}
|
|
140
143
|
}
|
|
141
144
|
items.push(a);
|
|
142
145
|
};
|