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

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.0.0",
3
+ "version": "2.1.0-rc.2",
4
4
  "main": "./src/BIMDataComponents/index.js",
5
5
  "module": "./src/BIMDataComponents/index.js",
6
6
  "files": [
@@ -26,24 +26,40 @@
26
26
  <slot name="contentAfterBtn" :isOpen="displayed"></slot>
27
27
  </div>
28
28
  <transition :name="`slide-fade-${transitionName}`">
29
- <BIMDataPaginatedList
30
- :class="`submenu submenu--${directionClass}`"
31
- v-show="displayed"
32
- :list="list"
33
- :perPage="perPage"
34
- :elementKey="elementKey"
35
- @element-click="onElementClick"
36
- :loading="loading"
37
- >
38
- <template #element="{ element }">
39
- <slot
40
- name="element"
41
- :element="element"
42
- :close="away"
43
- :isOpen="displayed"
44
- ></slot>
45
- </template>
46
- </BIMDataPaginatedList>
29
+ <div>
30
+ <BIMDataPaginatedList
31
+ :class="`submenu submenu--${directionClass}`"
32
+ v-show="displayed"
33
+ :list="filteredList"
34
+ :perPage="perPage"
35
+ :elementKey="elementKey"
36
+ @element-click="onElementClick"
37
+ :loading="loading"
38
+ >
39
+ <template #header>
40
+ <BIMDataSearch
41
+ v-if="search"
42
+ width="calc(100% - 12px)"
43
+ color="primary"
44
+ radius
45
+ :placeholder="searchPlaceholder"
46
+ v-model="searchText"
47
+ class="m-6"
48
+ />
49
+ <div v-if="filteredList.length === 0" class="p-x-6 p-b-6">
50
+ <slot name="empty"></slot>
51
+ </div>
52
+ </template>
53
+ <template #element="{ element }">
54
+ <slot
55
+ name="element"
56
+ :element="element"
57
+ :close="away"
58
+ :isOpen="displayed"
59
+ ></slot>
60
+ </template>
61
+ </BIMDataPaginatedList>
62
+ </div>
47
63
  </transition>
48
64
  </div>
49
65
  </template>
@@ -105,11 +121,20 @@ export default {
105
121
  type: String,
106
122
  default: "36px",
107
123
  },
124
+ search: {
125
+ type: Boolean,
126
+ default: false,
127
+ },
128
+ searchPlaceholder: {
129
+ type: String,
130
+ default: "Search",
131
+ },
108
132
  },
109
133
  emits: ["element-click"],
110
134
  data() {
111
135
  return {
112
136
  displayed: false,
137
+ searchText: "",
113
138
  };
114
139
  },
115
140
  computed: {
@@ -122,6 +147,16 @@ export default {
122
147
  iconRotation() {
123
148
  return this.displayed ? (this.directionClass === "up" ? -90 : 90) : 0;
124
149
  },
150
+ filteredList() {
151
+ if (this.searchText === "") {
152
+ return this.list;
153
+ } else {
154
+ const lowerCaseSearchText = this.searchText.toLowerCase();
155
+ return this.list.filter(element =>
156
+ element.toLowerCase().includes(lowerCaseSearchText),
157
+ );
158
+ }
159
+ },
125
160
  },
126
161
  methods: {
127
162
  onHeaderClick() {
@@ -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
- computed: {
64
- selectorComponent() {
65
- return this.multi ? "BIMDataSelectMulti" : "BIMDataSelectSingle";
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="() => (isOpen = false)"
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
- <ul v-show="!disabled && isOpen" class="bimdata-select__option-list">
25
- <li
26
- class="bimdata-select__option-list__entry"
27
- v-for="(option, index) of options"
28
- :key="index"
29
- :class="{
30
- selected: isSelected(option),
31
- disabled: isDisabled(option),
32
- 'option-group': isOptionGroup(option),
33
- }"
34
- @click="onOptionClick(option)"
35
- >
36
- <template v-if="isOptionGroup(option)">
37
- {{ optionLabel(option) }}
38
- </template>
39
- <BIMDataCheckbox
40
- v-else
41
- :modelValue="isSelected(option)"
42
- :disabled="isDisabled(option)"
43
- :text="optionLabel(option)"
44
- ></BIMDataCheckbox>
45
- </li>
46
- </ul>
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="() => (isOpen = false)"
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
- <ul v-show="!disabled && isOpen" class="bimdata-select__option-list">
25
- <li
26
- v-if="nullValue"
27
- class="bimdata-select__option-list__entry"
28
- @click="onNullValueClick()"
29
- >
30
- {{ nullLabel || "None" }}
31
- </li>
32
- <li
33
- class="bimdata-select__option-list__entry"
34
- v-for="(option, index) of options"
35
- :key="index"
36
- :class="{
37
- selected: isSelected(option),
38
- disabled: isDisabled(option),
39
- 'option-group': isOptionGroup(option),
40
- }"
41
- @click="onOptionClick(option)"
42
- >
43
- {{ optionLabel(option) }}
44
- </li>
45
- </ul>
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
  };
@@ -71,7 +71,6 @@
71
71
  top: -3px;
72
72
  width: 100%;
73
73
  max-height: 220px;
74
- padding: calc(var(--spacing-unit) / 2) 0;
75
74
  overflow: auto;
76
75
  box-shadow: var(--box-shadow);
77
76
  background-color: var(--color-white);