svelte-common 6.6.12 → 6.7.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 -6
- package/src/filter.mjs +10 -0
- package/src/pagination.mjs +14 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-common",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.7.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -45,22 +45,22 @@
|
|
|
45
45
|
"svelte-entitlement": "^1.2.65"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@semantic-release/commit-analyzer": "^
|
|
48
|
+
"@semantic-release/commit-analyzer": "^11.0.0",
|
|
49
49
|
"@semantic-release/exec": "^6.0.3",
|
|
50
|
-
"@semantic-release/release-notes-generator": "^
|
|
50
|
+
"@semantic-release/release-notes-generator": "^12.0.0",
|
|
51
51
|
"@sveltejs/vite-plugin-svelte": "^2.4.6",
|
|
52
52
|
"ava": "^5.3.1",
|
|
53
53
|
"c8": "^8.0.1",
|
|
54
54
|
"documentation": "^14.0.2",
|
|
55
55
|
"mf-styling": "^3.0.5",
|
|
56
56
|
"npm-pkgbuild": "^12.1.1",
|
|
57
|
-
"semantic-release": "^
|
|
57
|
+
"semantic-release": "^22.0.0",
|
|
58
58
|
"stylelint": "^15.10.3",
|
|
59
59
|
"stylelint-config-standard": "^34.0.0",
|
|
60
|
-
"svelte": "^4.2.
|
|
60
|
+
"svelte": "^4.2.1",
|
|
61
61
|
"testcafe": "^3.3.0",
|
|
62
62
|
"vite": "^4.4.9",
|
|
63
|
-
"vite-plugin-compression2": "^0.10.
|
|
63
|
+
"vite-plugin-compression2": "^0.10.5"
|
|
64
64
|
},
|
|
65
65
|
"optionalDependencies": {
|
|
66
66
|
"mf-hosting-cloudflare": "^1.0.5",
|
package/src/filter.mjs
CHANGED
|
@@ -50,10 +50,20 @@ function allOp(value, against, op) {
|
|
|
50
50
|
if (value instanceof Date) {
|
|
51
51
|
return dateOp(value, new Date(against), op);
|
|
52
52
|
}
|
|
53
|
+
break;
|
|
54
|
+
case "boolean":
|
|
55
|
+
return numberOp(value ? true : false, against, op);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (against instanceof RegExp) {
|
|
59
|
+
return against.test(value.toString());
|
|
53
60
|
}
|
|
61
|
+
|
|
54
62
|
return value.toString().match(against);
|
|
55
63
|
case "string":
|
|
56
64
|
switch (typeof against) {
|
|
65
|
+
case "boolean":
|
|
66
|
+
return numberOp(value.length !== 0, against, op);
|
|
57
67
|
case "bigint":
|
|
58
68
|
case "number":
|
|
59
69
|
return numberOp(value, against, op);
|
package/src/pagination.mjs
CHANGED
|
@@ -109,22 +109,25 @@ export class Pagination {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
+
* Total number of items (filtered).
|
|
112
113
|
* @return {number}
|
|
113
114
|
*/
|
|
114
|
-
get
|
|
115
|
-
let n;
|
|
116
|
-
|
|
115
|
+
get numberOfItems() {
|
|
117
116
|
if (this.filter) {
|
|
118
|
-
|
|
117
|
+
const data = Array.isArray(this.data)
|
|
119
118
|
? this.#data
|
|
120
119
|
: [...this.#data.values()];
|
|
121
|
-
|
|
122
|
-
n = data.length;
|
|
123
|
-
} else {
|
|
124
|
-
n = Array.isArray(this.#data) ? this.#data.length : this.#data.size;
|
|
120
|
+
return data.filter(this.filter).length;
|
|
125
121
|
}
|
|
126
122
|
|
|
127
|
-
return
|
|
123
|
+
return Array.isArray(this.#data) ? this.#data.length : this.#data.size;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @return {number}
|
|
128
|
+
*/
|
|
129
|
+
get numberOfPages() {
|
|
130
|
+
return Math.ceil(this.numberOfItems / this.itemsPerPage);
|
|
128
131
|
}
|
|
129
132
|
|
|
130
133
|
/**
|
|
@@ -247,7 +250,8 @@ export function* navigationItems(
|
|
|
247
250
|
) {
|
|
248
251
|
const edge = 2;
|
|
249
252
|
const side = 1;
|
|
250
|
-
const step =
|
|
253
|
+
const step =
|
|
254
|
+
numberOfPages >= 100 ? Math.floor(numberOfPages / 10) : undefined;
|
|
251
255
|
|
|
252
256
|
for (let n = 1; n <= numberOfPages; n++) {
|
|
253
257
|
if (
|