@bimdata/design-system 2.1.0-rc.29 → 2.1.0-rc.30

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": "@bimdata/design-system",
3
- "version": "2.1.0-rc.29",
3
+ "version": "2.1.0-rc.30",
4
4
  "main": "./src/BIMDataComponents/index.js",
5
5
  "module": "./src/BIMDataComponents/index.js",
6
6
  "files": [
@@ -0,0 +1,118 @@
1
+ <template>
2
+ <div
3
+ class="bimdata-list"
4
+ @scroll="computeIndexes"
5
+ :style="`--bimdata-list--item-height: ${itemHeight}px`"
6
+ >
7
+ <div
8
+ class="bimdata-list__placeholder"
9
+ :style="`height: ${items.length * itemHeight}px;`"
10
+ ></div>
11
+ <div
12
+ class="bimdata-list__element"
13
+ v-for="(item, index) in displayedItems"
14
+ :key="itemKey ? item[itemKey] : item"
15
+ :style="`height: ${itemHeight}px; top: ${
16
+ (offsetedStartIndex + index) * itemHeight
17
+ }px`"
18
+ >
19
+ <slot :item="item" :index="offsetedStartIndex + index">
20
+ {{ item }}
21
+ </slot>
22
+ </div>
23
+ </div>
24
+ </template>
25
+
26
+ <script>
27
+ export default {
28
+ name: "BIMDataList",
29
+ props: {
30
+ items: {
31
+ type: Array,
32
+ required: true,
33
+ },
34
+ itemHeight: {
35
+ type: Number,
36
+ default: 30,
37
+ },
38
+ offset: {
39
+ type: Number,
40
+ default: 20,
41
+ },
42
+ itemKey: {
43
+ type: String,
44
+ default: null,
45
+ },
46
+ },
47
+ data() {
48
+ return {
49
+ startIndex: 0,
50
+ endIndex: 0,
51
+ };
52
+ },
53
+ computed: {
54
+ offsetedStartIndex() {
55
+ return Math.max(this.startIndex - this.offset, 0);
56
+ },
57
+ offsetedEndIndex() {
58
+ return Math.min(this.endIndex + this.offset, this.items.length - 1);
59
+ },
60
+ displayedItems() {
61
+ return this.items.slice(
62
+ this.offsetedStartIndex,
63
+ this.offsetedEndIndex + 1
64
+ );
65
+ },
66
+ },
67
+ mounted() {
68
+ this.computeIndexes();
69
+ },
70
+ methods: {
71
+ computeIndexes() {
72
+ const { itemHeight, items, $el } = this;
73
+ const { scrollTop, clientHeight } = $el;
74
+
75
+ const startIndex = Math.floor(scrollTop / itemHeight);
76
+
77
+ const endIndex = Math.min(
78
+ startIndex + Math.ceil(clientHeight / itemHeight),
79
+ items.length - 1
80
+ );
81
+
82
+ this.startIndex = startIndex;
83
+ this.endIndex = endIndex;
84
+ },
85
+ },
86
+ };
87
+ </script>
88
+
89
+ <style scoped lang="scss">
90
+ .bimdata-list {
91
+ margin: 0;
92
+ padding: 0;
93
+ list-style: none;
94
+ border: 1px solid #ccc;
95
+
96
+ width: 100%;
97
+ height: 100%;
98
+ overflow: auto;
99
+
100
+ position: relative;
101
+
102
+ &__element {
103
+ overflow: hidden;
104
+ position: absolute;
105
+ width: 100%;
106
+ }
107
+
108
+ &__placeholder {
109
+ background: repeating-linear-gradient(
110
+ #ffffff,
111
+ #ffffff calc(var(--bimdata-list--item-height, 30px) - 1px),
112
+ var(--color-silver, #000000)
113
+ calc(var(--bimdata-list--item-height, 30px) - 1px),
114
+ var(--color-silver, #000000) var(--bimdata-list--item-height, 30px)
115
+ );
116
+ }
117
+ }
118
+ </style>
@@ -22,6 +22,7 @@ export * from "./BIMDataIcon/BIMDataIconStandalone/index.js";
22
22
  export { default as BIMDataIllustration } from "./BIMDataIllustration/BIMDataIllustration.vue";
23
23
  export { default as BIMDataInput } from "./BIMDataInput/BIMDataInput.vue";
24
24
  export { default as BIMDataInputOutlined } from "./BIMDataInputOutlined/BIMDataInputOutlined.vue";
25
+ export { default as BIMDataList } from "./BIMDataList/BIMDataList.vue";
25
26
  export { default as BIMDataLoading } from "./BIMDataLoading/BIMDataLoading.vue";
26
27
  export { default as BIMDataMenu } from "./BIMDataMenu/BIMDataMenu.vue";
27
28
  export { default as BIMDataMenuInline } from "./BIMDataMenuInline/BIMDataMenuInline.vue";