@bimdata/design-system 2.1.0-rc.2 → 2.1.0-rc.21

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.
Files changed (61) hide show
  1. package/package.json +2 -2
  2. package/src/BIMDataComponents/BIMDataDropdownList/BIMDataDropdownList.vue +10 -0
  3. package/src/BIMDataComponents/BIMDataDropdownList/_BIMDataDropdownList.scss +0 -1
  4. package/src/BIMDataComponents/BIMDataDropdownMenu/_BIMDataDropdownMenu.scss +0 -1
  5. package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconAddGavel.vue +19 -0
  6. package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconAddList.vue +19 -0
  7. package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconCaret.vue +19 -0
  8. package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconCreateSpace.vue +20 -0
  9. package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconCreateZone.vue +20 -0
  10. package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/{BIMDataIconDeploy.vue → BIMDataIconGavel.vue} +3 -3
  11. package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconNamingConvention.vue +20 -0
  12. package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconPlan.vue +20 -0
  13. package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconRotate.vue +20 -0
  14. package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconSpace2.vue +19 -0
  15. package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconZone2.vue +19 -0
  16. package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/index.js +11 -1
  17. package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/AddGavel.vue +21 -0
  18. package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/AddList.vue +27 -0
  19. package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/Caret.vue +3 -0
  20. package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/CreateSpace.vue +17 -0
  21. package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/CreateZone.vue +32 -0
  22. package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/Gavel.vue +5 -0
  23. package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/List.vue +6 -12
  24. package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/NamingConvention.vue +12 -0
  25. package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/Plan.vue +7 -0
  26. package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/Rotate.vue +21 -0
  27. package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/Space2.vue +9 -0
  28. package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/Zone2.vue +24 -0
  29. package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/index.js +22 -2
  30. package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/CreateList.vue +214 -0
  31. package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/EmptyNamingConvention.vue +47 -0
  32. package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ManageList.vue +206 -0
  33. package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/RenameFile.vue +175 -0
  34. package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutMoveDwg.vue +145 -0
  35. package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutMovePlan.vue +181 -0
  36. package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutOpenDwg.vue +142 -0
  37. package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutOpenPlan.vue +178 -0
  38. package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutRotateDwg.vue +123 -0
  39. package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutRotatePlan.vue +159 -0
  40. package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutZoomDwg.vue +100 -0
  41. package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutZoomPlan.vue +136 -0
  42. package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/index.js +26 -2
  43. package/src/BIMDataComponents/BIMDataInput/BIMDataInput.vue +3 -2
  44. package/src/BIMDataComponents/BIMDataInput/_BIMDataInput.scss +8 -8
  45. package/src/BIMDataComponents/BIMDataInputOutlined/BIMDataInputOutlined.vue +182 -0
  46. package/src/BIMDataComponents/BIMDataInputOutlined/_BIMDataInputOutlined.scss +96 -0
  47. package/src/BIMDataComponents/BIMDataSearch/BIMDataSearch.vue +6 -1
  48. package/src/BIMDataComponents/BIMDataSearch/_BIMDataSearch.scss +6 -0
  49. package/src/BIMDataComponents/BIMDataSelect/BIMDataSelectMulti.vue +24 -7
  50. package/src/BIMDataComponents/BIMDataSelect/BIMDataSelectSingle.vue +23 -6
  51. package/src/BIMDataComponents/BIMDataSlider/_BIMDataSlider.scss +2 -0
  52. package/src/BIMDataComponents/BIMDataTable/BIMDataTable.vue +224 -35
  53. package/src/BIMDataComponents/BIMDataTable/_BIMDataTable.scss +4 -0
  54. package/src/BIMDataComponents/BIMDataTable/column-filters/ColumnFilters.vue +91 -0
  55. package/src/BIMDataComponents/BIMDataTable/column-filters/_ColumnFilters.scss +14 -0
  56. package/src/BIMDataComponents/BIMDataTable/column-sorting/ColumnSorting.vue +66 -0
  57. package/src/BIMDataComponents/BIMDataTree/BIMDataTree.vue +123 -0
  58. package/src/BIMDataComponents/BIMDataTree/Node.vue +241 -0
  59. package/src/BIMDataComponents/BIMDataTree/state.js +239 -0
  60. package/src/BIMDataComponents/index.js +2 -0
  61. package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/Deploy.vue +0 -3
@@ -31,7 +31,7 @@
31
31
  v-model="searchText"
32
32
  class="m-6"
33
33
  />
34
- <div v-if="filteredOptions.length === 0" class="p-x-6 p-b-6">
34
+ <div v-if="filteredOptions.length === 0">
35
35
  <slot name="empty"></slot>
36
36
  </div>
37
37
  <ul class="bimdata-list m-y-6">
@@ -117,7 +117,7 @@ export default {
117
117
  type: String,
118
118
  default: "Search",
119
119
  },
120
- isResetSearch: {
120
+ clearSearchOnLeave: {
121
121
  type: Boolean,
122
122
  default: false,
123
123
  },
@@ -138,9 +138,26 @@ export default {
138
138
  return this.options;
139
139
  } else {
140
140
  const lowerCaseSearchText = this.searchText.toLowerCase();
141
- return this.options.filter(option =>
142
- option.toLowerCase().includes(lowerCaseSearchText),
143
- );
141
+ if (this.optionLabelKey) {
142
+ return this.options.filter(option =>
143
+ option[this.optionLabelKey]
144
+ .toLowerCase()
145
+ .includes(lowerCaseSearchText),
146
+ );
147
+ }
148
+ if (this.optionKey) {
149
+ return this.options.filter(
150
+ option =>
151
+ option.optionGroup ||
152
+ option[this.optionKey]
153
+ .toLowerCase()
154
+ .includes(lowerCaseSearchText),
155
+ );
156
+ } else {
157
+ return this.options.filter(option =>
158
+ option.toLowerCase().includes(lowerCaseSearchText),
159
+ );
160
+ }
144
161
  }
145
162
  },
146
163
  },
@@ -180,7 +197,7 @@ export default {
180
197
  return this.optionKey && option && option.optionGroup;
181
198
  },
182
199
  resetSearch() {
183
- if (this.isResetSearch) {
200
+ if (this.clearSearchOnLeave) {
184
201
  this.searchText = "";
185
202
  }
186
203
  },
@@ -1,6 +1,8 @@
1
1
  .bimdata-slider {
2
2
  position: relative;
3
3
  .bimdata-slider-input {
4
+ cursor: pointer;
5
+ height: 12px;
4
6
  &::-webkit-slider-runnable-track {
5
7
  height: 3px;
6
8
  background: linear-gradient(
@@ -26,7 +26,60 @@
26
26
  textAlign: column.align || 'left',
27
27
  }"
28
28
  >
29
- {{ column.id ? column.label || column.id : column }}
29
+ <div :style="{ display: 'inline-flex', 'align-items': 'center' }">
30
+ {{ column.id ? column.label || column.id : column }}
31
+ <slot name="column-header-right"></slot>
32
+ <ColumnSorting
33
+ v-if="column.sortable"
34
+ :sortOrder="
35
+ !sortObject.order || sortObject.column !== column
36
+ ? 'asc'
37
+ : sortObject.order
38
+ "
39
+ :index="j"
40
+ :active="j === activeHeadercolumnKey"
41
+ @click="toggleSorting(column)"
42
+ @set-active="activeHeadercolumnKey = $event"
43
+ />
44
+ <div
45
+ v-if="column.filter"
46
+ v-clickaway="() => awayFromFilter(column)"
47
+ >
48
+ <BIMDataButton
49
+ color="primary"
50
+ ghost
51
+ rounded
52
+ icon
53
+ class="m-l-6"
54
+ :class="{
55
+ active: filters.some(
56
+ filter => filter.columnKey === column.id,
57
+ ),
58
+ }"
59
+ @click="toggleFiltersMenu(column)"
60
+ >
61
+ <BIMDataIconCaret size="xxxs" fill color="default" />
62
+ </BIMDataButton>
63
+ <ColumnFilters
64
+ v-if="displayedColumnFilterId === column.id"
65
+ :column="column"
66
+ :columnData="
67
+ computedRows.map(
68
+ computedRow => computedRow.data[column.id],
69
+ )
70
+ "
71
+ :filters="
72
+ filters.find(filter => filter.columnKey === column.id)
73
+ ?.columnFilters ?? []
74
+ "
75
+ @filter="updateFilters(column, $event)"
76
+ >
77
+ <template #column-filter-empty>
78
+ <slot name="column-filter-empty"></slot>
79
+ </template>
80
+ </ColumnFilters>
81
+ </div>
82
+ </div>
30
83
  </th>
31
84
  </tr>
32
85
  <tr key="head-row-1">
@@ -37,9 +90,9 @@
37
90
  </thead>
38
91
  <tbody @dragleave="onDragleave">
39
92
  <tr
40
- v-for="{ key, data } of computedRows"
93
+ v-for="{ key, data } of displayedRows"
41
94
  :key="`body-row-${key}`"
42
- v-show="displayedRows.includes(key)"
95
+ v-show="paginatedRows.includes(key)"
43
96
  :style="{ height: `${rowHeight}px` }"
44
97
  @drop="onDrop(data, $event)"
45
98
  @dragover="onDragover(key, data, $event)"
@@ -83,7 +136,9 @@
83
136
  <div
84
137
  class="bimdata-table__page-nav"
85
138
  v-if="paginated"
86
- :style="{ visibility: rows.length > perPage ? 'visible' : 'hidden' }"
139
+ :style="{
140
+ visibility: displayedRows.length > perPage ? 'visible' : 'hidden',
141
+ }"
87
142
  >
88
143
  <BIMDataButton
89
144
  ghost
@@ -95,13 +150,13 @@
95
150
  <BIMDataIconChevron size="s" :rotate="180" />
96
151
  </BIMDataButton>
97
152
  <span class="bimdata-table__page-nav__text">
98
- {{ `${pageIndexStart} - ${pageIndexEnd} / ${rows.length}` }}
153
+ {{ `${pageIndexStart} - ${pageIndexEnd} / ${displayedRows.length}` }}
99
154
  </span>
100
155
  <BIMDataButton
101
156
  ghost
102
157
  rounded
103
158
  icon
104
- :disabled="pageIndexEnd === rows.length"
159
+ :disabled="pageIndexEnd === displayedRows.length"
105
160
  @click="pageIndex++"
106
161
  >
107
162
  <BIMDataIconChevron size="s" />
@@ -111,19 +166,28 @@
111
166
  </template>
112
167
 
113
168
  <script>
114
- import { computed, ref, watch } from "vue";
169
+ import { computed, ref, watch, shallowReactive } from "vue";
115
170
  import { useRowSelection } from "./table-row-selection.js";
171
+ import clickaway from "../../BIMDataDirectives/click-away.js";
172
+
116
173
  // Components
117
174
  import BIMDataButton from "../BIMDataButton/BIMDataButton.vue";
118
175
  import BIMDataCheckbox from "../BIMDataCheckbox/BIMDataCheckbox.vue";
176
+ import BIMDataIconCaret from "../BIMDataIcon/BIMDataIconStandalone/BIMDataIconCaret.vue";
119
177
  import BIMDataIconChevron from "../BIMDataIcon/BIMDataIconStandalone/BIMDataIconChevron.vue";
178
+ import ColumnSorting from "./column-sorting/ColumnSorting.vue";
179
+ import ColumnFilters from "./column-filters/ColumnFilters.vue";
120
180
 
121
181
  export default {
122
182
  components: {
123
183
  BIMDataButton,
124
184
  BIMDataCheckbox,
185
+ BIMDataIconCaret,
125
186
  BIMDataIconChevron,
187
+ ColumnSorting,
188
+ ColumnFilters,
126
189
  },
190
+ directives: { clickaway },
127
191
  props: {
128
192
  columns: {
129
193
  type: Array,
@@ -185,7 +249,7 @@ export default {
185
249
  setup(props, { emit }) {
186
250
  // Compute rows keys based on props values.
187
251
  const computedRows = computed(() =>
188
- props.rows.map((row, i) => ({ key: row[props.rowKey] ?? i, data: row }))
252
+ props.rows.map((row, i) => ({ key: row[props.rowKey] ?? i, data: row })),
189
253
  );
190
254
 
191
255
  const { rowSelection, toggleRowSelection, toggleFullSelection } =
@@ -211,7 +275,7 @@ export default {
211
275
  emit("all-deselected");
212
276
  }
213
277
  },
214
- }
278
+ },
215
279
  );
216
280
 
217
281
  const toggleRow = row => {
@@ -225,70 +289,195 @@ export default {
225
289
  }
226
290
  };
227
291
 
228
- const displayedRows = ref([]);
292
+ const onDrop = (data, event) => {
293
+ if (props.canDragOverRow(data)) {
294
+ emit("row-drop", { data, event });
295
+ dragOveredRowKey.value = null;
296
+ }
297
+ };
298
+ const dragOveredRowKey = ref(null);
299
+ const onDragover = (key, data, event) => {
300
+ if (props.canDragOverRow(data)) {
301
+ event.preventDefault();
302
+ dragOveredRowKey.value = key;
303
+ }
304
+ };
305
+ const onDragleave = () => {
306
+ dragOveredRowKey.value = null;
307
+ };
308
+
309
+ const displayedColumnFilterId = ref(null);
310
+
311
+ const toggleFiltersMenu = column => {
312
+ if (displayedColumnFilterId.value === column.id) {
313
+ displayedColumnFilterId.value = null;
314
+ } else {
315
+ displayedColumnFilterId.value = column.id;
316
+ }
317
+ };
318
+
319
+ const awayFromFilter = column => {
320
+ if (column.id === displayedColumnFilterId.value) {
321
+ displayedColumnFilterId.value = null;
322
+ }
323
+ };
324
+
325
+ const sortObject = shallowReactive({ column: null, order: null });
326
+ const filteringColumns = ref([]);
327
+ const sortedRows = computed(() => {
328
+ if (sortObject.column) {
329
+ // by default, sort in ascending order
330
+ const sortOrder = sortObject.order !== "desc" ? 1 : -1;
331
+ if (sortObject.column.sortFunction) {
332
+ const sortFunction = (a, b) => {
333
+ return sortObject.column.sortFunction(a.data, b.data) * sortOrder;
334
+ };
335
+ return Array.from(computedRows.value).sort(sortFunction);
336
+ } else {
337
+ return Array.from(computedRows.value).sort((a, b) => {
338
+ if (a.data[sortObject.column.id] < b.data[sortObject.column.id]) {
339
+ return sortOrder;
340
+ }
341
+ if (a.data[sortObject.column.id] > b.data[sortObject.column.id]) {
342
+ return -sortOrder;
343
+ }
344
+ return 0;
345
+ });
346
+ }
347
+ }
348
+ if (filteringColumns.value.length > 0) {
349
+ return Array.from(computedRows.value).filter(row => {
350
+ return (
351
+ row.data[filteringColumns.value[0].id] ===
352
+ filteringColumns.value[0].text
353
+ );
354
+ });
355
+ }
356
+
357
+ return computedRows.value;
358
+ });
359
+
360
+ const toggleSorting = column => {
361
+ if (sortObject.column === column) {
362
+ sortObject.order = sortObject.order === "asc" ? "desc" : "asc";
363
+ } else {
364
+ sortObject.column = column;
365
+ sortObject.order = column.defaultSortOrder ?? "asc";
366
+ }
367
+ };
368
+
369
+ /**
370
+ * @typedef {Object} ColumnFilter
371
+ * @property {number} columnKey
372
+ * @property {any[]} columnFilters
373
+ */
374
+
375
+ /**
376
+ * @type { { value: ColumnFilter[] } }
377
+ */
378
+ const filters = ref([]);
379
+
380
+ const displayedRows = computed(() => {
381
+ return sortedRows.value.filter(row => {
382
+ return filters.value.every(filter => {
383
+ const column = props.columns.find(
384
+ column => column.id === filter.columnKey,
385
+ );
386
+ const columnRowData = row.data[filter.columnKey];
387
+
388
+ if (columnRowData === null) return;
389
+
390
+ if (Array.isArray(columnRowData)) {
391
+ return columnRowData.some(columnRowDataElement =>
392
+ filter.columnFilters.includes(
393
+ column.filterKey
394
+ ? columnRowDataElement[column.filterKey]
395
+ : columnRowDataElement,
396
+ ),
397
+ );
398
+ } else {
399
+ return filter.columnFilters.includes(
400
+ column.filterKey
401
+ ? columnRowData[column.filterKey]
402
+ : columnRowData,
403
+ );
404
+ }
405
+ });
406
+ });
407
+ });
408
+
409
+ /**
410
+ * @param {ColumnFilter} columnFilter
411
+ */
412
+ const updateFilters = (column, columnFilters) => {
413
+ filters.value = filters.value.filter(
414
+ filter => filter.columnKey !== column.id,
415
+ );
416
+ if (columnFilters.length > 0) {
417
+ filters.value.push({
418
+ columnKey: column.id,
419
+ columnFilters,
420
+ });
421
+ }
422
+ };
423
+
424
+ const paginatedRows = ref([]);
229
425
  const pageIndex = ref(0);
230
426
  const pageIndexStart = ref(1);
231
427
  const pageIndexEnd = ref(props.perPage);
232
428
 
233
429
  // Reset `pageIndex` when rows array or the number of rows per page change.
234
430
  watch(
235
- [computedRows, () => props.perPage],
431
+ [displayedRows, () => props.perPage],
236
432
  () => {
237
433
  pageIndex.value = 0;
238
434
  },
239
- { immediate: true }
435
+ { immediate: true },
240
436
  );
241
- // Compute `displayedRows` according to rows array and pagination settings.
437
+ // Compute `paginatedRows` according to rows array and pagination settings.
242
438
  watch(
243
- [computedRows, () => props.paginated, () => props.perPage, pageIndex],
439
+ [displayedRows, () => props.paginated, () => props.perPage, pageIndex],
244
440
  ([rows, paginated, perPage, index]) => {
245
441
  const rowKeys = rows.map(r => r.key);
246
442
  if (paginated) {
247
443
  const start = perPage * index;
248
444
  const end = start + perPage;
249
445
 
250
- displayedRows.value = rowKeys.slice(start, end);
446
+ paginatedRows.value = rowKeys.slice(start, end);
251
447
  pageIndexStart.value = start + 1;
252
448
  pageIndexEnd.value = Math.min(end, rows.length);
253
449
  } else {
254
- displayedRows.value = rowKeys;
450
+ paginatedRows.value = rowKeys;
255
451
  }
256
452
  },
257
- { immediate: true }
453
+ { immediate: true },
258
454
  );
259
455
 
260
- const onDrop = (data, event) => {
261
- if (props.canDragOverRow(data)) {
262
- emit("row-drop", { data, event });
263
- dragOveredRowKey.value = null;
264
- }
265
- };
266
- const dragOveredRowKey = ref(null);
267
- const onDragover = (key, data, event) => {
268
- if (props.canDragOverRow(data)) {
269
- event.preventDefault();
270
- dragOveredRowKey.value = key;
271
- }
272
- };
273
- const onDragleave = () => {
274
- dragOveredRowKey.value = null;
275
- };
276
-
277
456
  return {
278
457
  // References
458
+ activeHeadercolumnKey: null,
279
459
  computedRows,
280
- displayedRows,
460
+ paginatedRows,
281
461
  pageIndex,
282
462
  pageIndexEnd,
283
463
  pageIndexStart,
284
464
  rowSelection,
285
465
  dragOveredRowKey,
466
+ displayedColumnFilterId,
467
+ filteringColumns,
468
+ filters,
469
+ sortObject,
286
470
  // Methods
471
+ awayFromFilter,
287
472
  onDrop,
288
473
  onDragover,
289
474
  onDragleave,
290
475
  toggleAll,
291
476
  toggleRow,
477
+ toggleSorting,
478
+ updateFilters,
479
+ toggleFiltersMenu,
480
+ displayedRows,
292
481
  };
293
482
  },
294
483
  };
@@ -25,6 +25,7 @@
25
25
  }
26
26
 
27
27
  th {
28
+ position: relative;
28
29
  font-weight: bold;
29
30
  color: var(--color-primary);
30
31
 
@@ -35,6 +36,9 @@
35
36
  font-weight: normal;
36
37
  color: var(--color-granite-lightest);
37
38
  }
39
+ .active {
40
+ background-color: #e0eef9;
41
+ }
38
42
  }
39
43
 
40
44
  td {
@@ -0,0 +1,91 @@
1
+ <template>
2
+ <div class="column-filters p-12">
3
+ <div
4
+ v-if="columnElements.length === 0"
5
+ class="column-filters__element flex align-center"
6
+ >
7
+ <slot name="column-filter-empty"></slot>
8
+ </div>
9
+ <div
10
+ v-for="element in columnElements"
11
+ :key="element.data"
12
+ class="column-filters__element flex align-center"
13
+ >
14
+ <BIMDataCheckbox
15
+ :text="element.data"
16
+ :modelValue="element.checked"
17
+ @update:modelValue="toggle(element.data, $event)"
18
+ />
19
+ </div>
20
+ </div>
21
+ </template>
22
+ <script>
23
+ import { computed } from "vue";
24
+ import BIMDataCheckbox from "../../BIMDataCheckbox/BIMDataCheckbox.vue";
25
+ export default {
26
+ components: {
27
+ BIMDataCheckbox,
28
+ },
29
+ props: {
30
+ column: {
31
+ type: Object,
32
+ required: true,
33
+ },
34
+ columnData: {
35
+ type: Array,
36
+ required: true,
37
+ },
38
+ filters: {
39
+ type: Array,
40
+ required: true,
41
+ },
42
+ },
43
+ emits: ["filter"],
44
+ setup(props, { emit }) {
45
+ const column = props.column;
46
+
47
+ const elements = computed(() => {
48
+ const columnData = props.columnData;
49
+ const newColumnData = columnData.filter(data => data !== null);
50
+ return [
51
+ ...new Set(
52
+ newColumnData.flatMap(data => {
53
+ if (!Array.isArray(data)) {
54
+ data = [data];
55
+ }
56
+ return column?.filterKey
57
+ ? data.map(d => d[column?.filterKey])
58
+ : data;
59
+ }),
60
+ ),
61
+ ];
62
+ });
63
+
64
+ const columnElements = computed(() =>
65
+ elements.value.map(element => ({
66
+ data: element,
67
+ checked: props.filters.includes(element),
68
+ })),
69
+ );
70
+
71
+ const toggle = (element, checked) => {
72
+ const newFilters = new Set(props.filters);
73
+
74
+ if (checked) {
75
+ newFilters.add(element);
76
+ } else {
77
+ newFilters.delete(element);
78
+ }
79
+
80
+ emit("filter", [...newFilters]);
81
+ };
82
+
83
+ return {
84
+ columnElements,
85
+ toggle,
86
+ };
87
+ },
88
+ };
89
+ </script>
90
+
91
+ <style scoped lang="scss" src="./_ColumnFilters.scss"></style>
@@ -0,0 +1,14 @@
1
+ .column-filters {
2
+ width: 100%;
3
+ display: grid;
4
+ position: absolute;
5
+ left: 0;
6
+ background-color: var(--color-white);
7
+ box-shadow: var(--box-shadow);
8
+ gap: calc(var(--spacing-unit) / 2);
9
+ border-radius: calc(var(--spacing-unit) / 2);
10
+ z-index: 1;
11
+ .bimdata-checkbox {
12
+ font-weight: 400;
13
+ }
14
+ }
@@ -0,0 +1,66 @@
1
+ <template>
2
+ <span
3
+ :class="[sortOrder === 'asc' ? 'asc' : 'desc', 'm-l-6']"
4
+ @mousedown.prevent
5
+ >
6
+ <BIMDataButton
7
+ color="primary"
8
+ ghost
9
+ rounded
10
+ icon
11
+ :class="{ active: active }"
12
+ @click="toggleActive"
13
+ >
14
+ <BIMDataIconCaret
15
+ :rotate="sortOrder === 'desc' ? 180 : 0"
16
+ size="xxxs"
17
+ fill
18
+ color="default"
19
+ />
20
+ </BIMDataButton>
21
+ </span>
22
+ </template>
23
+
24
+ <script>
25
+ // Components
26
+ import BIMDataButton from "../../BIMDataButton/BIMDataButton.vue";
27
+ import BIMDataIconCaret from "../../BIMDataIcon/BIMDataIconStandalone/BIMDataIconCaret.vue";
28
+ export default {
29
+ components: {
30
+ BIMDataButton,
31
+ BIMDataIconCaret,
32
+ },
33
+ props: {
34
+ sortOrder: {
35
+ type: String,
36
+ required: true,
37
+ validator: value => ["asc", "desc"].includes(value),
38
+ },
39
+ index: {
40
+ type: Number,
41
+ required: true,
42
+ },
43
+ active: {
44
+ type: Boolean,
45
+ required: true,
46
+ },
47
+ },
48
+ setup(props, { emit }) {
49
+ const toggleActive = () => {
50
+ emit("set-active", props.index);
51
+ };
52
+ return {
53
+ toggleActive,
54
+ };
55
+ },
56
+ };
57
+ </script>
58
+
59
+ <style scoped lang="scss">
60
+ span {
61
+ cursor: pointer;
62
+ }
63
+ .active {
64
+ background-color: #e0eef9;
65
+ }
66
+ </style>