@itfin/components 2.0.36 → 2.0.38
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
|
@@ -20,16 +20,26 @@
|
|
|
20
20
|
</div>
|
|
21
21
|
</div>
|
|
22
22
|
<div class="facets-list">
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
<div v-for="(group, g) of groupedList">
|
|
24
|
+
<div v-if="group.group" class="dropdown-item ps-1 d-flex align-items-center"
|
|
25
|
+
:class="{'active': isGroupSelected(group.items)}" @click="groupSelected(!isGroupSelected(group.items), group.items)">
|
|
26
|
+
<span class="facet-name text-dark d-flex align-items-center">
|
|
27
|
+
<itf-checkbox ungrouped :value="isGroupSelected(group.items)" @input="groupSelected($event, group.items)" class="m-0" />
|
|
28
|
+
<div class="w-100 text-truncate">{{ group.group }}</div>
|
|
29
|
+
</span>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<div v-for="(val, n) of group.items" :key="n" class="dropdown-item ps-1" :class="{'active': val.isSelected, 'ps-4': group.group}" @click="onFilterClick(val)">
|
|
33
|
+
<span class="facet-name text-dark d-flex align-items-center">
|
|
34
|
+
<itf-checkbox ungrouped :value="val.isSelected" class="m-0" />
|
|
35
|
+
<div class="w-100 text-truncate">{{ val.label }} <span v-if="val.description" class="small"><br/>{{ val.description }}</span></div>
|
|
36
|
+
</span>
|
|
37
|
+
<span v-if="val.count" class="facet-stat">
|
|
38
|
+
{{ val.count }}
|
|
39
|
+
<span class="facet-bar"><span :style="{'--bar-width': `${getPercent(val)}%`}" class="facet-bar-progress" /></span>
|
|
40
|
+
</span>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
33
43
|
</div>
|
|
34
44
|
|
|
35
45
|
<itf-button default class="mt-1" v-if="hasMore" small block @click="toggleMore">
|
|
@@ -111,6 +121,8 @@
|
|
|
111
121
|
}
|
|
112
122
|
</style>
|
|
113
123
|
<script>
|
|
124
|
+
import uniq from 'lodash/uniq';
|
|
125
|
+
import sortBy from 'lodash/sortBy';
|
|
114
126
|
import { Vue, Prop, Model, Component } from 'vue-property-decorator';
|
|
115
127
|
import itfTextField from '../text-field/TextField.vue';
|
|
116
128
|
import itfButton from '../button/Button';
|
|
@@ -149,6 +161,20 @@ class FilterFacetsList extends Vue {
|
|
|
149
161
|
return this.visibleList.length > this.limit;
|
|
150
162
|
}
|
|
151
163
|
|
|
164
|
+
get hasGroups() {
|
|
165
|
+
const groups = uniq(this.items && this.items.map(item => item.group).filter(Boolean));
|
|
166
|
+
return groups.length > 1
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
isGroupSelected(items) {
|
|
170
|
+
return items.every(item => item.isSelected);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
groupSelected(value, items) {
|
|
174
|
+
const newVal = value ? items.map(item => `${item.value}`) : [];
|
|
175
|
+
this.$emit('input', this.multiple ? newVal : (newVal.length > 0 ? newVal[0] : null));
|
|
176
|
+
}
|
|
177
|
+
|
|
152
178
|
get visibleList() {
|
|
153
179
|
let list = this.items.map(val => {
|
|
154
180
|
const isSelected = this.multiple
|
|
@@ -163,7 +189,22 @@ class FilterFacetsList extends Vue {
|
|
|
163
189
|
if (this.isShowSelected) {
|
|
164
190
|
return list.filter((val) => val.isSelected);
|
|
165
191
|
}
|
|
166
|
-
return list;
|
|
192
|
+
return sortBy(list, (item) => this.hasGroups ? item.group || item.label : item.label);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
get groupedList() {
|
|
196
|
+
if (!this.hasGroups) {
|
|
197
|
+
return [{ items: this.mappedValues }];
|
|
198
|
+
}
|
|
199
|
+
const groups = {};
|
|
200
|
+
this.mappedValues.forEach((item) => {
|
|
201
|
+
const group = item.group || '';
|
|
202
|
+
if (!groups[group]) {
|
|
203
|
+
groups[group] = [];
|
|
204
|
+
}
|
|
205
|
+
groups[group].push(item);
|
|
206
|
+
});
|
|
207
|
+
return Object.entries(groups).map(([group, items]) => ({ group, items }));
|
|
167
208
|
}
|
|
168
209
|
|
|
169
210
|
get mappedValues() {
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
</div>
|
|
14
14
|
<div v-if="!nocard" v-show="!collapsed" class="b-panel-header px-3 pt-3 pb-2">
|
|
15
15
|
<slot name="header">
|
|
16
|
-
<div class="d-flex gap-3 align-items-center">
|
|
16
|
+
<div class="d-flex gap-3 align-items-center" style="min-width: 0">
|
|
17
17
|
<itf-button icon default class="d-md-none open-menu-button" @click="$emit('open-menu')">
|
|
18
18
|
<itf-icon name="menu" new />
|
|
19
19
|
</itf-button>
|
|
20
20
|
<slot name="title">
|
|
21
|
-
<div class="b-panel__title fw-bold mb-0 h2 text-truncate" v-text="title"></div>
|
|
21
|
+
<div style="min-width: 0" class="b-panel__title fw-bold mb-0 h2 text-truncate" v-text="title"></div>
|
|
22
22
|
</slot>
|
|
23
23
|
</div>
|
|
24
24
|
<div class="d-flex gap-1">
|