@mixd-id/web-scaffold 0.1.230406004 → 0.1.230406006

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.230406004",
4
+ "version": "0.1.230406006",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -31,19 +31,42 @@ export default{
31
31
 
32
32
  items:{
33
33
  type: Array, Object
34
- }
34
+ },
35
+
36
+ pinned: Function,
35
37
 
36
38
  },
37
39
 
38
40
  computed:{
39
41
 
42
+ sortedItems(){
43
+ if(!Array.isArray(this.items)) return []
44
+
45
+ if(typeof this.pinned === 'function'){
46
+ const pinnedItems = []
47
+ const unpinnedItems = []
48
+ this.items.forEach((item) => {
49
+ if(this.pinned(item))
50
+ pinnedItems.push(item)
51
+ else
52
+ unpinnedItems.push(item)
53
+ })
54
+
55
+ return [
56
+ ...pinnedItems,
57
+ ...unpinnedItems
58
+ ]
59
+ }
60
+ return this.items
61
+ },
62
+
40
63
  visibleStartIndex(){
41
64
  return Math.round(this.scrollTop / this.itemHeight)
42
65
  },
43
66
 
44
67
  visibleItems(){
45
68
  if(this.itemHeight <= 0) return []
46
- return this.items ? this.items.slice(this.visibleStartIndex, this.visibleStartIndex + this.maxVisibleItems) : []
69
+ return this.sortedItems.slice(this.visibleStartIndex, this.visibleStartIndex + this.maxVisibleItems)
47
70
  },
48
71
 
49
72
  spacerStyle(){