@gitlab/ui 42.4.0 → 42.6.0

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.
@@ -31,9 +31,19 @@ export default {
31
31
  required: true,
32
32
  },
33
33
  value: {
34
- type: String,
34
+ type: [String, Object],
35
35
  required: true,
36
36
  },
37
+ matchValueToAttr: {
38
+ type: String,
39
+ required: false,
40
+ default: undefined,
41
+ },
42
+ autofocus: {
43
+ type: Boolean,
44
+ required: false,
45
+ default: false,
46
+ },
37
47
  },
38
48
  data() {
39
49
  return {
@@ -54,6 +64,11 @@ export default {
54
64
  showSuggestions() {
55
65
  return this.results.length > 0;
56
66
  },
67
+ displayedValue() {
68
+ return this.matchValueToAttr && this.value[this.matchValueToAttr]
69
+ ? this.value[this.matchValueToAttr]
70
+ : this.value;
71
+ },
57
72
  },
58
73
  mounted() {
59
74
  document.addEventListener('click', this.handleClickOutside);
@@ -112,9 +127,12 @@ export default {
112
127
  return;
113
128
  }
114
129
 
115
- const filteredTokens = this.tokenList.filter((token) =>
116
- token.toLowerCase().includes(value.toLowerCase())
117
- );
130
+ const filteredTokens = this.tokenList.filter((token) => {
131
+ if (this.matchValueToAttr) {
132
+ return token[this.matchValueToAttr].toLowerCase().includes(value.toLowerCase());
133
+ }
134
+ return token.toLowerCase().includes(value.toLowerCase());
135
+ });
118
136
 
119
137
  if (filteredTokens.length) {
120
138
  this.openSuggestions(filteredTokens);
@@ -147,13 +165,14 @@ export default {
147
165
  <gl-form-group :label="labelText" :label-for="inputId" :label-sr-only="labelSrOnly">
148
166
  <gl-form-input
149
167
  :id="inputId"
150
- :value="value"
168
+ :value="displayedValue"
151
169
  type="text"
152
170
  role="searchbox"
153
171
  :autocomplete="showAutocomplete"
154
172
  aria-autocomplete="list"
155
173
  :aria-controls="suggestionsId"
156
174
  aria-haspopup="listbox"
175
+ :autofocus="autofocus"
157
176
  @input="onEntry"
158
177
  @keydown.down="onArrowDown"
159
178
  @keydown.up="onArrowUp"
@@ -163,11 +182,11 @@ export default {
163
182
  />
164
183
  </gl-form-group>
165
184
 
166
- <div
185
+ <ul
167
186
  v-show="showSuggestions && !userDismissedResults"
168
187
  :id="suggestionsId"
169
188
  data-testid="combobox-dropdown"
170
- class="dropdown-menu dropdown-full-width"
189
+ class="dropdown-menu dropdown-full-width gl-list-style-none gl-pl-0 gl-mb-0 gl-overflow-y-auto"
171
190
  :class="{ 'show-dropdown': showSuggestions }"
172
191
  >
173
192
  <gl-dropdown-item
@@ -179,8 +198,8 @@ export default {
179
198
  tabindex="-1"
180
199
  @click="selectToken(result)"
181
200
  >
182
- {{ result }}
201
+ <slot name="result" :item="result">{{ result }}</slot>
183
202
  </gl-dropdown-item>
184
- </div>
203
+ </ul>
185
204
  </div>
186
205
  </template>
@@ -73,6 +73,7 @@ export default {
73
73
  },
74
74
  size: {
75
75
  options: labelSizeOptions,
76
+ control: 'select',
76
77
  },
77
78
  tooltipPlacement: {
78
79
  options: tooltipPlacements,