svelte-common 6.18.9 → 6.19.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 +8 -8
- package/src/index.svelte +1 -1
- package/src/module.mjs +1 -1
- package/types/module.d.mts +1 -1
- package/src/filter.mjs +0 -228
- package/types/filter.d.mts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-common",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.19.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"preview": "vite preview"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"pacc": "^3.4.
|
|
52
|
-
"svelte-command": "^3.0.
|
|
53
|
-
"svelte-entitlement": "^2.0.
|
|
51
|
+
"pacc": "^3.4.1",
|
|
52
|
+
"svelte-command": "^3.0.27",
|
|
53
|
+
"svelte-entitlement": "^2.0.37"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
@@ -62,18 +62,18 @@
|
|
|
62
62
|
"c8": "^10.1.3",
|
|
63
63
|
"documentation": "^14.0.3",
|
|
64
64
|
"mf-styling": "^3.2.12",
|
|
65
|
-
"npm-pkgbuild": "^
|
|
65
|
+
"npm-pkgbuild": "^18.1.1",
|
|
66
66
|
"semantic-release": "^24.2.3",
|
|
67
67
|
"stylelint": "^16.18.0",
|
|
68
68
|
"stylelint-config-standard": "^38.0.0",
|
|
69
|
-
"svelte": "^5.
|
|
69
|
+
"svelte": "^5.28.2",
|
|
70
70
|
"testcafe": "^3.7.2",
|
|
71
71
|
"typescript": "^5.8.3",
|
|
72
|
-
"vite": "^6.2
|
|
72
|
+
"vite": "^6.3.2",
|
|
73
73
|
"vite-plugin-compression2": "^1.3.3"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"svelte": "^5.
|
|
76
|
+
"svelte": "^5.28.2"
|
|
77
77
|
},
|
|
78
78
|
"optionalDependencies": {
|
|
79
79
|
"mf-hosting-cloudflare": "^1.0.7",
|
package/src/index.svelte
CHANGED
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
SORT_ASCENDING,
|
|
55
55
|
SORT_DESCENDING
|
|
56
56
|
} from "./sorting.mjs";
|
|
57
|
-
export { filter } from "./filter.mjs";
|
|
58
57
|
export { Pagination, pageNavigation } from "./pagination.mjs";
|
|
59
58
|
export { initializeServiceWorker } from "./service-worker.mjs";
|
|
59
|
+
export { filter } from "pacc";
|
|
60
60
|
</script>
|
package/src/module.mjs
CHANGED
package/types/module.d.mts
CHANGED
package/src/filter.mjs
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getAttributeAndOperator,
|
|
3
|
-
EQUAL,
|
|
4
|
-
NOT_EQUAL,
|
|
5
|
-
LESS,
|
|
6
|
-
LESS_EQUAL,
|
|
7
|
-
GREATER,
|
|
8
|
-
GREATER_EQUAL
|
|
9
|
-
} from "pacc";
|
|
10
|
-
|
|
11
|
-
function dateOp(value, against, op) {
|
|
12
|
-
return numberOp(value.getTime(), against.getTime(), op);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function collectionOp(value, against, op) {
|
|
16
|
-
for (const v of value) {
|
|
17
|
-
if (allOp(v, against, op)) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function allOp(value, against, op) {
|
|
26
|
-
switch (typeof value) {
|
|
27
|
-
case "undefined":
|
|
28
|
-
return false;
|
|
29
|
-
|
|
30
|
-
case "object":
|
|
31
|
-
if (value === null) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (value instanceof Map) {
|
|
36
|
-
return collectionOp(value.keys(), against, op);
|
|
37
|
-
}
|
|
38
|
-
if (value instanceof RegExp) {
|
|
39
|
-
return value.test(against);
|
|
40
|
-
}
|
|
41
|
-
if (value[Symbol.iterator]) {
|
|
42
|
-
return collectionOp(value, against, op);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
switch (typeof against) {
|
|
46
|
-
case "object":
|
|
47
|
-
if (value instanceof Date) {
|
|
48
|
-
if (
|
|
49
|
-
Array.isArray(against) &&
|
|
50
|
-
against[0] instanceof Date &&
|
|
51
|
-
against[1] instanceof Date
|
|
52
|
-
) {
|
|
53
|
-
return dateOp(value, against[0], GREATER_EQUAL) && dateOp(value, against[1], LESS_EQUAL);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (against instanceof Date) {
|
|
57
|
-
return dateOp(value, against, op);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (value[Symbol.toPrimitive] && against[Symbol.toPrimitive]) {
|
|
62
|
-
return numberOp(
|
|
63
|
-
value[Symbol.toPrimitive]("number"),
|
|
64
|
-
against[Symbol.toPrimitive]("number"),
|
|
65
|
-
op
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
break;
|
|
69
|
-
|
|
70
|
-
case "bigint":
|
|
71
|
-
case "number":
|
|
72
|
-
return allOp(value[Symbol.toPrimitive]("number"), against, op);
|
|
73
|
-
|
|
74
|
-
case "string":
|
|
75
|
-
if (against.length === 0) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (value instanceof Date) {
|
|
80
|
-
return dateOp(value, new Date(against), op);
|
|
81
|
-
}
|
|
82
|
-
break;
|
|
83
|
-
case "boolean":
|
|
84
|
-
return numberOp(value ? true : false, against, op);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (against instanceof RegExp) {
|
|
88
|
-
return against.test(value.toString());
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return value.toString().match(against);
|
|
92
|
-
case "string":
|
|
93
|
-
switch (typeof against) {
|
|
94
|
-
case "boolean":
|
|
95
|
-
return numberOp(value.length !== 0, against, op);
|
|
96
|
-
case "string":
|
|
97
|
-
if (
|
|
98
|
-
op === EQUAL &&
|
|
99
|
-
(against.length === 0 || value.indexOf(against) >= 0)
|
|
100
|
-
) {
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (!value.match(/^-?\d/)) {
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
case "bigint":
|
|
108
|
-
case "number":
|
|
109
|
-
return value.length ? numberOp(value, against, op) : true;
|
|
110
|
-
case "object":
|
|
111
|
-
if (value.length === 0) {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (against instanceof Date) {
|
|
116
|
-
return dateOp(new Date(value), against, op);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (against instanceof RegExp) {
|
|
120
|
-
return against.test(value);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (against instanceof Map) {
|
|
124
|
-
for (const [k, v] of against) {
|
|
125
|
-
if (allOp(value, k, op) || allOp(value, v, op)) {
|
|
126
|
-
return true;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (against[Symbol.iterator]) {
|
|
132
|
-
for (const i of against) {
|
|
133
|
-
if (allOp(value, i, op)) {
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return value.match(against);
|
|
142
|
-
case "bigint":
|
|
143
|
-
case "number":
|
|
144
|
-
switch (typeof against) {
|
|
145
|
-
case "object":
|
|
146
|
-
if (against instanceof RegExp) {
|
|
147
|
-
return against.test(String(value));
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (against instanceof Map) {
|
|
151
|
-
for (const [k, v] of against) {
|
|
152
|
-
if (numberOp(value, k, op) || numberOp(value, v, op)) {
|
|
153
|
-
return true;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (against[Symbol.iterator]) {
|
|
160
|
-
for (const i of against) {
|
|
161
|
-
if (numberOp(value, i, op)) {
|
|
162
|
-
return true;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return numberOp(value, against, op);
|
|
169
|
-
case "boolean":
|
|
170
|
-
switch (typeof against) {
|
|
171
|
-
case "object":
|
|
172
|
-
if (against[Symbol.iterator]) {
|
|
173
|
-
for (const i of against) {
|
|
174
|
-
if (allOp(value, i, op)) {
|
|
175
|
-
return true;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return value == against;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function numberOp(value, against, op) {
|
|
189
|
-
switch (op) {
|
|
190
|
-
case NOT_EQUAL:
|
|
191
|
-
return value != against;
|
|
192
|
-
case EQUAL:
|
|
193
|
-
return value == against;
|
|
194
|
-
case GREATER:
|
|
195
|
-
return value > against;
|
|
196
|
-
case LESS:
|
|
197
|
-
return value < against;
|
|
198
|
-
case GREATER_EQUAL:
|
|
199
|
-
return value >= against;
|
|
200
|
-
case LESS_EQUAL:
|
|
201
|
-
return value <= against;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Generate filter function.
|
|
207
|
-
* @param {Object} [filterBy]
|
|
208
|
-
* @returns {Function}
|
|
209
|
-
*/
|
|
210
|
-
export function filter(filterBy) {
|
|
211
|
-
if (filterBy) {
|
|
212
|
-
const filters = Object.entries(filterBy).map(([key, against]) => {
|
|
213
|
-
return a => {
|
|
214
|
-
const [value, op] = getAttributeAndOperator(a, key);
|
|
215
|
-
return allOp(value, against, op);
|
|
216
|
-
};
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
if (filters.length === 1) {
|
|
220
|
-
return filters[0];
|
|
221
|
-
}
|
|
222
|
-
if (filters.length > 1) {
|
|
223
|
-
return a => !filters.some(f => !f(a));
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return () => true;
|
|
228
|
-
}
|