@kws3/ui 2.2.2 → 2.2.3

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/CHANGELOG.mdx CHANGED
@@ -1,3 +1,6 @@
1
+ # 2.2.3
2
+ - `ScrollableList` - add support for custom iteration key for keyed each block
3
+
1
4
  # 2.2.2
2
5
  - `ScrollableList` - fix jumping issue when edge of scrollable regions are reached
3
6
 
@@ -3,6 +3,7 @@
3
3
 
4
4
 
5
5
  @param {array} [items=[]] - Array of items, Default: `[]`
6
+ @param {object} [iteration_key=null] - Iteration key - by default it uses the index of the array inside the keyed each block, Default: `null`
6
7
  @param {string} [height="100%"] - Height of the wrapper, CSS String, Default: `"100%"`
7
8
  @param {number | null} [item_height=null] - Height of each list item. If not set, height will be calculated automatically based on each item's offsetHeight, Default: `null`
8
9
  @param {number} [start=0] - First item index rendered inside viewport - readonly, Default: `0`
@@ -89,6 +90,10 @@ while more items are loading
89
90
  * Array of items
90
91
  */
91
92
  export let items = [],
93
+ /**
94
+ * Iteration key - by default it uses the index of the array inside the keyed each block
95
+ */
96
+ iteration_key = null,
92
97
  /**
93
98
  * Height of the wrapper, CSS String
94
99
  */
@@ -140,9 +145,10 @@ while more items are loading
140
145
 
141
146
  $: padStart = start > padding_threshold ? start - padding_threshold : start;
142
147
  $: padEnd = end + padding_threshold;
143
- $: visible = items
144
- .slice(padStart, padEnd)
145
- .map((data, i) => ({ index: i + padStart, data }));
148
+ $: visible = items.slice(padStart, padEnd).map((data, i) => ({
149
+ index: iteration_key ? data[iteration_key] : i + padStart,
150
+ data,
151
+ }));
146
152
 
147
153
  // whenever `items` changes, invalidate the current heightmap
148
154
  $: items, viewport_height, item_height, mounted, refresh();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kws3/ui",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "UI components for use with Svelte v3 applications.",
5
5
  "main": "index.js",
6
6
  "svelte": "index.js",
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "typescript": "^5.0.4"
37
37
  },
38
- "gitHead": "a4a85bf945292245105ccbe4057943bcea1e080f"
38
+ "gitHead": "77b76e0e8ecbd1d9f282c67b62d944efafa5949b"
39
39
  }