svelte-common 4.15.1 → 4.16.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-common",
3
- "version": "4.15.1",
3
+ "version": "4.16.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -40,9 +40,9 @@
40
40
  "@semantic-release/exec": "^6.0.3",
41
41
  "@semantic-release/release-notes-generator": "^10.0.3",
42
42
  "@sveltejs/vite-plugin-svelte": "^1.0.2",
43
- "ava": "^4.3.1",
43
+ "ava": "^4.3.3",
44
44
  "documentation": "^14.0.0",
45
- "mf-styling": "^1.5.5",
45
+ "mf-styling": "^1.7.3",
46
46
  "npm-pkgbuild": "^10.14.8",
47
47
  "semantic-release": "^19.0.5",
48
48
  "stylelint": "^14.11.0",
package/src/filter.mjs ADDED
@@ -0,0 +1,9 @@
1
+ export function filter(filterBy) {
2
+ if (filterBy) {
3
+ for (const [key, value] of Object.entries(filterBy)) {
4
+ return (a) => a && a[key]?.match(value)
5
+ }
6
+ }
7
+
8
+ return () => true;
9
+ }
package/src/index.svelte CHANGED
@@ -53,5 +53,7 @@
53
53
  SORT_ASCENDING,
54
54
  SORT_DESCENDING
55
55
  } from "./sorting.mjs";
56
+ export { filter } from "./filter.mjs";
57
+
56
58
  export { initializeServiceWorker } from "./service-worker.mjs";
57
59
  </script>
package/src/sorting.mjs CHANGED
@@ -20,20 +20,21 @@ export function toggleOrderBy(orderBy) {
20
20
  }
21
21
 
22
22
  /**
23
- * Add sortable toggle button to a node.
23
+ * Add sortable toggle button with img element to a node.
24
24
  * Synchronizes store value with node "aria-sort" attribute.
25
25
  * @param {Node} th header node
26
26
  * @param {WritableStore} to keep in sync with sorting properties
27
27
  */
28
28
  export function sortable(th, store) {
29
- const button = document.createElement("button");
30
- const img = document.createElement("img");
31
- button.appendChild(img);
32
-
29
+
33
30
  store.subscribe(orderBy =>
34
31
  th.setAttribute("aria-sort", orderBy[th.id] || SORT_NONE)
35
32
  );
36
33
 
34
+ const button = document.createElement("button");
35
+ const img = document.createElement("img");
36
+ button.appendChild(img);
37
+
37
38
  button.onclick = () => {
38
39
  const orderBy = {};
39
40