svelte-common 5.0.5 → 5.1.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/README.md CHANGED
@@ -134,7 +134,7 @@ Pages go from 1 ... numberOfPages
134
134
 
135
135
  ### Parameters
136
136
 
137
- * `source`  
137
+ * `data`  
138
138
  * `itemsPerPage` (optional, default `10`)
139
139
 
140
140
  ### page
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "svelte-common",
3
- "version": "5.0.5",
3
+ "version": "5.1.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "svelte": "./src/index.svelte",
7
+ "exports": {
8
+ ".": {
9
+ "svelte": "./src/index.svelte"
10
+ }
11
+ },
8
12
  "description": "common components and utils used in svelte apps",
9
13
  "keywords": [
10
14
  "component",
@@ -33,24 +37,24 @@
33
37
  "preview": "vite preview"
34
38
  },
35
39
  "dependencies": {
36
- "svelte-command": "^1.1.42",
37
- "svelte-entitlement": "^1.2.54"
40
+ "svelte-command": "^1.1.43",
41
+ "svelte-entitlement": "^1.2.56"
38
42
  },
39
43
  "devDependencies": {
40
44
  "@semantic-release/commit-analyzer": "^10.0.1",
41
45
  "@semantic-release/exec": "^6.0.3",
42
- "@semantic-release/release-notes-generator": "^11.0.3",
46
+ "@semantic-release/release-notes-generator": "^11.0.4",
43
47
  "@sveltejs/vite-plugin-svelte": "^2.4.2",
44
48
  "ava": "^5.3.1",
45
49
  "c8": "^8.0.0",
46
50
  "documentation": "^14.0.2",
47
51
  "mf-styling": "^2.0.1",
48
- "npm-pkgbuild": "^11.8.9",
49
- "semantic-release": "^21.0.5",
50
- "stylelint": "^15.9.0",
51
- "stylelint-config-standard": "^33.0.0",
52
- "svelte": "^4.0.0",
53
- "testcafe": "^3.0.0",
52
+ "npm-pkgbuild": "^11.8.11",
53
+ "semantic-release": "^21.0.7",
54
+ "stylelint": "^15.10.0",
55
+ "stylelint-config-standard": "^34.0.0",
56
+ "svelte": "^4.0.4",
57
+ "testcafe": "^3.0.1",
54
58
  "vite": "^4.3.9"
55
59
  },
56
60
  "optionalDependencies": {
@@ -5,16 +5,30 @@
5
5
  export class Pagination {
6
6
  #subscriptions = new Set();
7
7
  #data;
8
+ #unsubscribeData;
9
+
8
10
  #itemsPerPage = 1;
9
11
  #page = 1;
10
12
 
11
13
  constructor(data, itemsPerPage = 10) {
12
- this.#data = data;
14
+ this.data = data;
13
15
  this.itemsPerPage = itemsPerPage;
14
16
  }
15
17
 
16
18
  set data(data) {
17
- this.#data = data;
19
+ if (this.#unsubscribeData) {
20
+ this.#unsubscribeData();
21
+ this.#unsubscribeData = undefined;
22
+ }
23
+
24
+ if (data?.subscribe) {
25
+ this.#unsubscribeData = data.subscribe(newData => {
26
+ this.#data = newData;
27
+ });
28
+ } else {
29
+ this.#data = data;
30
+ }
31
+
18
32
  this.#subscriptions.forEach(subscription => subscription(this));
19
33
  }
20
34
 
@@ -63,7 +77,9 @@ export class Pagination {
63
77
  *items() {
64
78
  const n = this.page - 1;
65
79
 
66
- const data = Array.isArray(this.data) ? this.#data : [...this.#data.values()];
80
+ const data = Array.isArray(this.data)
81
+ ? this.#data
82
+ : [...this.#data.values()];
67
83
 
68
84
  for (const item of data.slice(
69
85
  n * this.itemsPerPage,