@bimdata/design-system 2.0.0 → 2.1.0-rc.1
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 +1 -1
- package/src/BIMDataComponents/BIMDataSelect/BIMDataSelect.vue +13 -13
- package/src/BIMDataComponents/BIMDataSelect/BIMDataSelectMulti.vue +70 -24
- package/src/BIMDataComponents/BIMDataSelect/BIMDataSelectSingle.vue +71 -23
- package/src/BIMDataComponents/BIMDataSelect/_BIMDataSelect.scss +0 -1
package/package.json
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component
|
|
3
|
-
:is="selectorComponent"
|
|
4
|
-
v-bind="$props"
|
|
5
|
-
:modelValue="modelValue"
|
|
6
|
-
@update:modelValue="$emit('update:modelValue', $event)"
|
|
7
|
-
/>
|
|
8
|
-
</template>
|
|
9
|
-
|
|
10
1
|
<script>
|
|
2
|
+
import { h } from "vue";
|
|
11
3
|
// Components
|
|
12
4
|
import BIMDataSelectMulti from "./BIMDataSelectMulti.vue";
|
|
13
5
|
import BIMDataSelectSingle from "./BIMDataSelectSingle.vue";
|
|
@@ -60,10 +52,18 @@ export default {
|
|
|
60
52
|
},
|
|
61
53
|
},
|
|
62
54
|
emits: ["update:modelValue"],
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
setup(props, { emit, slots }) {
|
|
56
|
+
return () =>
|
|
57
|
+
h(
|
|
58
|
+
props.multi ? BIMDataSelectMulti : BIMDataSelectSingle,
|
|
59
|
+
{
|
|
60
|
+
...props,
|
|
61
|
+
"onUpdate:modelValue": event => emit("update:modelValue", event),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
empty: () => slots.empty?.(),
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
67
|
},
|
|
68
68
|
};
|
|
69
69
|
</script>
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
'not-empty': modelValue.length > 0,
|
|
8
8
|
}"
|
|
9
9
|
:style="{ width }"
|
|
10
|
-
v-clickaway="
|
|
10
|
+
v-clickaway="away"
|
|
11
11
|
>
|
|
12
12
|
<div class="bimdata-select__content">
|
|
13
13
|
<div class="bimdata-select__content__value" @click="toggle">
|
|
@@ -21,29 +21,43 @@
|
|
|
21
21
|
</div>
|
|
22
22
|
|
|
23
23
|
<transition name="slide-fade-down">
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
v-
|
|
41
|
-
:
|
|
42
|
-
:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
24
|
+
<div v-show="!disabled && isOpen" class="bimdata-select__option-list">
|
|
25
|
+
<BIMDataSearch
|
|
26
|
+
v-if="search"
|
|
27
|
+
width="calc(100% - 12px)"
|
|
28
|
+
color="primary"
|
|
29
|
+
radius
|
|
30
|
+
:placeholder="searchPlaceholder"
|
|
31
|
+
v-model="searchText"
|
|
32
|
+
class="m-6"
|
|
33
|
+
/>
|
|
34
|
+
<div v-if="filteredOptions.length === 0" class="p-x-6 p-b-6">
|
|
35
|
+
<slot name="empty"></slot>
|
|
36
|
+
</div>
|
|
37
|
+
<ul class="bimdata-list m-b-6">
|
|
38
|
+
<li
|
|
39
|
+
class="bimdata-select__option-list__entry"
|
|
40
|
+
v-for="(option, index) of filteredOptions"
|
|
41
|
+
:key="index"
|
|
42
|
+
:class="{
|
|
43
|
+
selected: isSelected(option),
|
|
44
|
+
disabled: isDisabled(option),
|
|
45
|
+
'option-group': isOptionGroup(option),
|
|
46
|
+
}"
|
|
47
|
+
@click="onOptionClick(option)"
|
|
48
|
+
>
|
|
49
|
+
<template v-if="isOptionGroup(option)">
|
|
50
|
+
{{ optionLabel(option) }}
|
|
51
|
+
</template>
|
|
52
|
+
<BIMDataCheckbox
|
|
53
|
+
v-else
|
|
54
|
+
:modelValue="isSelected(option)"
|
|
55
|
+
:disabled="isDisabled(option)"
|
|
56
|
+
:text="optionLabel(option)"
|
|
57
|
+
></BIMDataCheckbox>
|
|
58
|
+
</li>
|
|
59
|
+
</ul>
|
|
60
|
+
</div>
|
|
47
61
|
</transition>
|
|
48
62
|
</div>
|
|
49
63
|
</template>
|
|
@@ -94,17 +108,40 @@ export default {
|
|
|
94
108
|
type: Boolean,
|
|
95
109
|
default: false,
|
|
96
110
|
},
|
|
111
|
+
search: {
|
|
112
|
+
type: Boolean,
|
|
113
|
+
default: false,
|
|
114
|
+
},
|
|
115
|
+
searchPlaceholder: {
|
|
116
|
+
type: String,
|
|
117
|
+
default: "Search",
|
|
118
|
+
},
|
|
119
|
+
isResetSearch: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
default: false,
|
|
122
|
+
},
|
|
97
123
|
},
|
|
98
124
|
emits: ["update:modelValue"],
|
|
99
125
|
data() {
|
|
100
126
|
return {
|
|
101
127
|
isOpen: false,
|
|
128
|
+
searchText: "",
|
|
102
129
|
};
|
|
103
130
|
},
|
|
104
131
|
computed: {
|
|
105
132
|
displayedValue() {
|
|
106
133
|
return this.modelValue.map(this.optionLabel).join(", ");
|
|
107
134
|
},
|
|
135
|
+
filteredOptions() {
|
|
136
|
+
if (this.searchText === "") {
|
|
137
|
+
return this.options;
|
|
138
|
+
} else {
|
|
139
|
+
const lowerCaseSearchText = this.searchText.toLowerCase();
|
|
140
|
+
return this.options.filter(option =>
|
|
141
|
+
option.toLowerCase().includes(lowerCaseSearchText),
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
108
145
|
},
|
|
109
146
|
methods: {
|
|
110
147
|
toggle() {
|
|
@@ -154,6 +191,15 @@ export default {
|
|
|
154
191
|
}
|
|
155
192
|
this.$emit("update:modelValue", options);
|
|
156
193
|
},
|
|
194
|
+
resetSearch() {
|
|
195
|
+
if (this.isResetSearch) {
|
|
196
|
+
this.searchText = "";
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
away() {
|
|
200
|
+
this.isOpen = false;
|
|
201
|
+
this.resetSearch();
|
|
202
|
+
},
|
|
157
203
|
},
|
|
158
204
|
};
|
|
159
205
|
</script>
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
'not-empty': modelValue !== undefined && modelValue !== null,
|
|
8
8
|
}"
|
|
9
9
|
:style="{ width }"
|
|
10
|
-
v-clickaway="
|
|
10
|
+
v-clickaway="away"
|
|
11
11
|
>
|
|
12
12
|
<div class="bimdata-select__content">
|
|
13
13
|
<div class="bimdata-select__content__value" @click="toggle">
|
|
@@ -21,28 +21,42 @@
|
|
|
21
21
|
</div>
|
|
22
22
|
|
|
23
23
|
<transition name="slide-fade-down">
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
v-if="
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
24
|
+
<div v-show="!disabled && isOpen" class="bimdata-select__option-list">
|
|
25
|
+
<BIMDataSearch
|
|
26
|
+
v-if="search"
|
|
27
|
+
width="calc(100% - 12px)"
|
|
28
|
+
color="primary"
|
|
29
|
+
radius
|
|
30
|
+
:placeholder="searchPlaceholder"
|
|
31
|
+
v-model="searchText"
|
|
32
|
+
class="m-6"
|
|
33
|
+
/>
|
|
34
|
+
<div v-if="filteredOptions.length === 0" class="p-x-6 p-b-6">
|
|
35
|
+
<slot name="empty"></slot>
|
|
36
|
+
</div>
|
|
37
|
+
<ul class="bimdata-list m-y-6">
|
|
38
|
+
<li
|
|
39
|
+
v-if="nullValue"
|
|
40
|
+
class="bimdata-select__option-list__entry"
|
|
41
|
+
@click="onNullValueClick()"
|
|
42
|
+
>
|
|
43
|
+
{{ nullLabel || "None" }}
|
|
44
|
+
</li>
|
|
45
|
+
<li
|
|
46
|
+
class="bimdata-select__option-list__entry"
|
|
47
|
+
v-for="(option, index) of filteredOptions"
|
|
48
|
+
:key="index"
|
|
49
|
+
:class="{
|
|
50
|
+
selected: isSelected(option),
|
|
51
|
+
disabled: isDisabled(option),
|
|
52
|
+
'option-group': isOptionGroup(option),
|
|
53
|
+
}"
|
|
54
|
+
@click="onOptionClick(option)"
|
|
55
|
+
>
|
|
56
|
+
{{ optionLabel(option) }}
|
|
57
|
+
</li>
|
|
58
|
+
</ul>
|
|
59
|
+
</div>
|
|
46
60
|
</transition>
|
|
47
61
|
</div>
|
|
48
62
|
</template>
|
|
@@ -95,17 +109,40 @@ export default {
|
|
|
95
109
|
type: Boolean,
|
|
96
110
|
default: false,
|
|
97
111
|
},
|
|
112
|
+
search: {
|
|
113
|
+
type: Boolean,
|
|
114
|
+
default: false,
|
|
115
|
+
},
|
|
116
|
+
searchPlaceholder: {
|
|
117
|
+
type: String,
|
|
118
|
+
default: "Search",
|
|
119
|
+
},
|
|
120
|
+
isResetSearch: {
|
|
121
|
+
type: Boolean,
|
|
122
|
+
default: false,
|
|
123
|
+
},
|
|
98
124
|
},
|
|
99
125
|
emits: ["update:modelValue"],
|
|
100
126
|
data() {
|
|
101
127
|
return {
|
|
102
128
|
isOpen: false,
|
|
129
|
+
searchText: "",
|
|
103
130
|
};
|
|
104
131
|
},
|
|
105
132
|
computed: {
|
|
106
133
|
displayedValue() {
|
|
107
134
|
return this.optionLabel(this.modelValue);
|
|
108
135
|
},
|
|
136
|
+
filteredOptions() {
|
|
137
|
+
if (this.searchText === "") {
|
|
138
|
+
return this.options;
|
|
139
|
+
} else {
|
|
140
|
+
const lowerCaseSearchText = this.searchText.toLowerCase();
|
|
141
|
+
return this.options.filter(option =>
|
|
142
|
+
option.toLowerCase().includes(lowerCaseSearchText),
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
109
146
|
},
|
|
110
147
|
methods: {
|
|
111
148
|
toggle() {
|
|
@@ -142,16 +179,27 @@ export default {
|
|
|
142
179
|
isOptionGroup(option) {
|
|
143
180
|
return this.optionKey && option && option.optionGroup;
|
|
144
181
|
},
|
|
182
|
+
resetSearch() {
|
|
183
|
+
if (this.isResetSearch) {
|
|
184
|
+
this.searchText = "";
|
|
185
|
+
}
|
|
186
|
+
},
|
|
145
187
|
onOptionClick(option) {
|
|
146
188
|
if (this.optionKey && (option.disabled || option.optionGroup)) {
|
|
147
189
|
return;
|
|
148
190
|
}
|
|
149
191
|
this.$emit("update:modelValue", option);
|
|
192
|
+
this.resetSearch();
|
|
150
193
|
this.isOpen = false;
|
|
151
194
|
},
|
|
152
195
|
onNullValueClick() {
|
|
153
196
|
this.$emit("update:modelValue", null);
|
|
197
|
+
this.resetSearch();
|
|
198
|
+
this.isOpen = false;
|
|
199
|
+
},
|
|
200
|
+
away() {
|
|
154
201
|
this.isOpen = false;
|
|
202
|
+
this.resetSearch();
|
|
155
203
|
},
|
|
156
204
|
},
|
|
157
205
|
};
|