@gitlab/ui 49.0.1 → 49.0.3

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 (128) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/base/accordion/accordion.js +2 -8
  3. package/dist/components/base/accordion/accordion_item.js +0 -14
  4. package/dist/components/base/alert/alert.js +4 -22
  5. package/dist/components/base/avatar/avatar.js +0 -7
  6. package/dist/components/base/avatar_labeled/avatar_labeled.js +0 -2
  7. package/dist/components/base/avatars_inline/avatars_inline.js +2 -10
  8. package/dist/components/base/badge/badge.js +0 -8
  9. package/dist/components/base/banner/banner.js +0 -10
  10. package/dist/components/base/breadcrumb/breadcrumb.js +0 -12
  11. package/dist/components/base/breadcrumb/breadcrumb_item.js +0 -2
  12. package/dist/components/base/broadcast_message/broadcast_message.js +0 -3
  13. package/dist/components/base/button/button.js +0 -11
  14. package/dist/components/base/card/card.js +1 -2
  15. package/dist/components/base/datepicker/datepicker.js +7 -42
  16. package/dist/components/base/daterange_picker/daterange_picker.js +0 -23
  17. package/dist/components/base/drawer/drawer.js +0 -13
  18. package/dist/components/base/dropdown/dropdown.js +3 -17
  19. package/dist/components/base/dropdown/dropdown_item.js +2 -8
  20. package/dist/components/base/filtered_search/common_story_options.js +1 -2
  21. package/dist/components/base/filtered_search/filtered_search.js +9 -61
  22. package/dist/components/base/filtered_search/filtered_search_suggestion.js +0 -6
  23. package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +0 -16
  24. package/dist/components/base/filtered_search/filtered_search_term.js +0 -9
  25. package/dist/components/base/filtered_search/filtered_search_token.js +10 -49
  26. package/dist/components/base/filtered_search/filtered_search_token_segment.js +3 -56
  27. package/dist/components/base/filtered_search/filtered_search_utils.js +7 -24
  28. package/dist/components/base/form/form_checkbox/form_checkbox.js +0 -2
  29. package/dist/components/base/form/form_checkbox_tree/checkbox_tree_node.js +0 -4
  30. package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.js +0 -10
  31. package/dist/components/base/form/form_checkbox_tree/models/node.js +1 -10
  32. package/dist/components/base/form/form_checkbox_tree/models/tree.js +16 -37
  33. package/dist/components/base/form/form_combobox/form_combobox.js +2 -36
  34. package/dist/components/base/form/form_group/form_group.js +2 -7
  35. package/dist/components/base/form/form_input/form_input.js +2 -8
  36. package/dist/components/base/form/form_input_group/form_input_group.js +0 -5
  37. package/dist/components/base/form/form_input_group/form_input_group_mixin.js +0 -8
  38. package/dist/components/base/form/form_radio_group/form_radio_group.js +0 -2
  39. package/dist/components/base/form/form_select/form_select.js +0 -3
  40. package/dist/components/base/form/form_textarea/form_textarea.js +2 -7
  41. package/dist/components/base/icon/icon.js +4 -14
  42. package/dist/components/base/infinite_scroll/infinite_scroll.js +7 -21
  43. package/dist/components/base/keyset_pagination/keyset_pagination.js +0 -9
  44. package/dist/components/base/label/label.js +0 -12
  45. package/dist/components/base/loading_icon/loading_icon.js +7 -10
  46. package/dist/components/base/markdown/markdown.js +1 -0
  47. package/dist/components/base/modal/modal.js +7 -27
  48. package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +0 -25
  49. package/dist/components/base/new_dropdowns/constants.js +4 -2
  50. package/dist/components/base/new_dropdowns/listbox/listbox.js +0 -63
  51. package/dist/components/base/new_dropdowns/listbox/listbox_group.js +0 -2
  52. package/dist/components/base/new_dropdowns/listbox/listbox_item.js +0 -5
  53. package/dist/components/base/new_dropdowns/listbox/utils.js +0 -7
  54. package/dist/components/base/paginated_list/paginated_list.js +0 -15
  55. package/dist/components/base/pagination/pagination.js +14 -72
  56. package/dist/components/base/path/path.js +0 -29
  57. package/dist/components/base/popover/popover.js +0 -5
  58. package/dist/components/base/search_box_by_click/search_box_by_click.js +1 -26
  59. package/dist/components/base/search_box_by_type/search_box_by_type.js +2 -12
  60. package/dist/components/base/segmented_control/segmented_control.js +0 -10
  61. package/dist/components/base/skeleton_loader/skeleton_loader.js +0 -19
  62. package/dist/components/base/skeleton_loading/skeleton_loading.js +0 -3
  63. package/dist/components/base/sorting/sorting.js +1 -9
  64. package/dist/components/base/sorting/sorting_item.js +4 -6
  65. package/dist/components/base/table/table.js +0 -4
  66. package/dist/components/base/tabs/tab/tab.js +2 -6
  67. package/dist/components/base/tabs/tabs/scrollable_tabs.js +0 -21
  68. package/dist/components/base/tabs/tabs/tabs.js +8 -33
  69. package/dist/components/base/toast/toast.js +4 -15
  70. package/dist/components/base/toggle/toggle.js +0 -18
  71. package/dist/components/base/token/token.js +0 -4
  72. package/dist/components/base/token_selector/token_container.js +0 -24
  73. package/dist/components/base/token_selector/token_selector.js +10 -61
  74. package/dist/components/base/token_selector/token_selector_dropdown.js +4 -32
  75. package/dist/components/charts/area/area.js +8 -32
  76. package/dist/components/charts/bar/bar.js +7 -19
  77. package/dist/components/charts/chart/chart.js +1 -22
  78. package/dist/components/charts/column/column.js +8 -18
  79. package/dist/components/charts/discrete_scatter/discrete_scatter.js +2 -13
  80. package/dist/components/charts/gauge/gauge.js +0 -15
  81. package/dist/components/charts/heatmap/heatmap.js +3 -16
  82. package/dist/components/charts/legend/legend.js +2 -24
  83. package/dist/components/charts/line/line.js +8 -34
  84. package/dist/components/charts/series_label/series_label.js +0 -12
  85. package/dist/components/charts/single_stat/single_stat.js +0 -8
  86. package/dist/components/charts/sparkline/sparkline.js +1 -16
  87. package/dist/components/charts/stacked_column/stacked_column.js +8 -26
  88. package/dist/components/charts/tooltip/tooltip.js +0 -6
  89. package/dist/components/mixins/button_mixin.js +0 -1
  90. package/dist/components/mixins/safe_link_mixin.js +0 -1
  91. package/dist/components/mixins/toolbox_mixin.js +0 -1
  92. package/dist/components/mixins/tooltip_mixin.js +1 -2
  93. package/dist/components/regions/empty_state/empty_state.js +0 -12
  94. package/dist/components/utilities/animated_number/animated_number.js +0 -16
  95. package/dist/components/utilities/friendly_wrap/friendly_wrap.js +0 -3
  96. package/dist/components/utilities/intersection_observer/intersection_observer.js +0 -7
  97. package/dist/components/utilities/intersperse/intersperse.js +3 -9
  98. package/dist/components/utilities/sprintf/sprintf.js +9 -23
  99. package/dist/components/utilities/truncate/truncate.js +0 -10
  100. package/dist/config.js +3 -4
  101. package/dist/directives/hover_load/hover_load.js +2 -8
  102. package/dist/directives/outside/get_event_like_time_stamp.js +4 -2
  103. package/dist/directives/outside/outside.js +5 -20
  104. package/dist/directives/resize_observer/resize_observer.js +0 -10
  105. package/dist/directives/safe_html/safe_html.js +5 -6
  106. package/dist/directives/safe_link/mock_data.js +1 -1
  107. package/dist/directives/safe_link/safe_link.js +0 -13
  108. package/dist/utils/breakpoints.js +0 -3
  109. package/dist/utils/charts/config.js +29 -42
  110. package/dist/utils/charts/constants.js +8 -8
  111. package/dist/utils/charts/mock_data.js +2 -2
  112. package/dist/utils/charts/story_config.js +1 -1
  113. package/dist/utils/charts/theme.js +1 -3
  114. package/dist/utils/charts/utils.js +2 -6
  115. package/dist/utils/constants.js +10 -7
  116. package/dist/utils/data_utils.js +5 -4
  117. package/dist/utils/datetime_utility.js +4 -4
  118. package/dist/utils/number_utils.js +7 -11
  119. package/dist/utils/stories_utils.js +1 -1
  120. package/dist/utils/story_decorators/container.js +0 -1
  121. package/dist/utils/string_utils.js +0 -14
  122. package/dist/utils/test_utils.js +3 -2
  123. package/dist/utils/use_fake_date.js +0 -4
  124. package/dist/utils/use_mock_intersection_observer.js +4 -19
  125. package/dist/utils/utils.js +5 -14
  126. package/package.json +3 -3
  127. package/src/components/base/pagination/pagination.vue +2 -2
  128. package/src/components/base/toast/toast.js +1 -0
@@ -68,7 +68,6 @@ var script = {
68
68
  required: false,
69
69
  default: false
70
70
  },
71
-
72
71
  /**
73
72
  * Right align dropdown menu with respect to the toggle button
74
73
  */
@@ -86,7 +85,6 @@ var script = {
86
85
  return ['menu', 'listbox', 'tree', 'grid', 'dialog', true, false].includes(value);
87
86
  }
88
87
  },
89
-
90
88
  /**
91
89
  * Id that will be referenced by `aria-labelledby` attribute of the dropdown content`
92
90
  */
@@ -94,7 +92,6 @@ var script = {
94
92
  type: String,
95
93
  required: true
96
94
  },
97
-
98
95
  /**
99
96
  * The `aria-labelledby` attribute value for the toggle `button`
100
97
  */
@@ -104,26 +101,20 @@ var script = {
104
101
  default: null
105
102
  }
106
103
  },
107
-
108
104
  data() {
109
105
  return {
110
106
  visible: false
111
107
  };
112
108
  },
113
-
114
109
  computed: {
115
110
  isIconOnly() {
116
111
  var _this$toggleText;
117
-
118
112
  return Boolean(this.icon && (!((_this$toggleText = this.toggleText) !== null && _this$toggleText !== void 0 && _this$toggleText.length) || this.textSrOnly));
119
113
  },
120
-
121
114
  isIconWithText() {
122
115
  var _this$toggleText2;
123
-
124
116
  return Boolean(this.icon && ((_this$toggleText2 = this.toggleText) === null || _this$toggleText2 === void 0 ? void 0 : _this$toggleText2.length) && !this.textSrOnly);
125
117
  },
126
-
127
118
  toggleButtonClasses() {
128
119
  return [this.toggleClass, {
129
120
  'gl-dropdown-toggle': true,
@@ -133,37 +124,29 @@ var script = {
133
124
  'dropdown-toggle-no-caret': this.noCaret
134
125
  }];
135
126
  },
136
-
137
127
  toggleLabelledBy() {
138
128
  return this.ariaLabelledby ? `${this.ariaLabelledby} ${this.toggleId}` : this.toggleId;
139
129
  },
140
-
141
130
  popperConfig() {
142
131
  return {
143
132
  placement: this.right ? 'bottom-end' : 'bottom-start',
144
133
  ...POPPER_CONFIG
145
134
  };
146
135
  }
147
-
148
136
  },
149
-
150
137
  mounted() {
151
138
  this.$nextTick(() => {
152
139
  this.popper = createPopper(this.$refs.toggle.$el, this.$refs.content, this.popperConfig);
153
140
  });
154
141
  },
155
-
156
142
  beforeDestroy() {
157
143
  this.popper.destroy();
158
144
  },
159
-
160
145
  methods: {
161
146
  async toggle() {
162
147
  this.visible = !this.visible;
163
-
164
148
  if (this.visible) {
165
149
  var _this$popper;
166
-
167
150
  /* Initially dropdown is hidden with `display="none"`.
168
151
  When `visible` prop is toggled ON, with the `nextTick` we wait for the DOM update -
169
152
  dropdown's `display="block"` is set (adding CSS class `show`).
@@ -181,36 +164,28 @@ var script = {
181
164
  this.$emit(GL_DROPDOWN_HIDDEN);
182
165
  }
183
166
  },
184
-
185
167
  open() {
186
168
  if (this.visible) {
187
169
  return;
188
170
  }
189
-
190
171
  this.toggle();
191
172
  },
192
-
193
173
  close() {
194
174
  if (!this.visible) {
195
175
  return;
196
176
  }
197
-
198
177
  this.toggle();
199
178
  },
200
-
201
179
  closeAndFocus() {
202
180
  if (!this.visible) {
203
181
  return;
204
182
  }
205
-
206
183
  this.toggle();
207
184
  this.focusToggle();
208
185
  },
209
-
210
186
  focusToggle() {
211
187
  this.$refs.toggle.$el.focus();
212
188
  }
213
-
214
189
  }
215
190
  };
216
191
 
@@ -5,11 +5,13 @@ const POPPER_CONFIG = {
5
5
  offset: [0, 4]
6
6
  }
7
7
  }]
8
- }; // base dropdown events
8
+ };
9
9
 
10
+ // base dropdown events
10
11
  const GL_DROPDOWN_SHOWN = 'shown';
11
- const GL_DROPDOWN_HIDDEN = 'hidden'; // KEY Codes
12
+ const GL_DROPDOWN_HIDDEN = 'hidden';
12
13
 
14
+ // KEY Codes
13
15
  const HOME = 'Home';
14
16
  const END = 'End';
15
17
  const ARROW_UP = 'ArrowUp';
@@ -42,7 +42,6 @@ var script = {
42
42
  default: () => [],
43
43
  validator: itemsValidator
44
44
  },
45
-
46
45
  /**
47
46
  * array of selected items values for multi-select and selected item value for single-select
48
47
  */
@@ -51,7 +50,6 @@ var script = {
51
50
  required: false,
52
51
  default: () => []
53
52
  },
54
-
55
53
  /**
56
54
  * Allow multi-selection
57
55
  */
@@ -60,7 +58,6 @@ var script = {
60
58
  required: false,
61
59
  default: false
62
60
  },
63
-
64
61
  /**
65
62
  * Toggle button text
66
63
  */
@@ -69,7 +66,6 @@ var script = {
69
66
  required: false,
70
67
  default: ''
71
68
  },
72
-
73
69
  /**
74
70
  * Toggle text to be read by screen readers only
75
71
  */
@@ -78,14 +74,12 @@ var script = {
78
74
  required: false,
79
75
  default: false
80
76
  },
81
-
82
77
  /** The header text */
83
78
  headerText: {
84
79
  type: String,
85
80
  required: false,
86
81
  default: ''
87
82
  },
88
-
89
83
  /**
90
84
  * Styling option - dropdown's toggle category
91
85
  */
@@ -95,7 +89,6 @@ var script = {
95
89
  default: buttonCategoryOptions.primary,
96
90
  validator: value => Object.keys(buttonCategoryOptions).includes(value)
97
91
  },
98
-
99
92
  /**
100
93
  * Styling option - dropdown's toggle variant
101
94
  */
@@ -105,7 +98,6 @@ var script = {
105
98
  default: dropdownVariantOptions.default,
106
99
  validator: value => Object.keys(dropdownVariantOptions).includes(value)
107
100
  },
108
-
109
101
  /**
110
102
  * The size of the dropdown toggle
111
103
  */
@@ -115,7 +107,6 @@ var script = {
115
107
  default: buttonSizeOptions.medium,
116
108
  validator: value => Object.keys(buttonSizeOptions).includes(value)
117
109
  },
118
-
119
110
  /**
120
111
  * Icon name that will be rendered in the toggle button
121
112
  */
@@ -124,7 +115,6 @@ var script = {
124
115
  required: false,
125
116
  default: ''
126
117
  },
127
-
128
118
  /**
129
119
  * Set to "true" to disable the dropdown
130
120
  */
@@ -133,7 +123,6 @@ var script = {
133
123
  required: false,
134
124
  default: false
135
125
  },
136
-
137
126
  /**
138
127
  * Set to "true" when dropdown content (items) is loading
139
128
  * It will render a small loader in the dropdown toggle and make it disabled
@@ -143,7 +132,6 @@ var script = {
143
132
  required: false,
144
133
  default: false
145
134
  },
146
-
147
135
  /**
148
136
  * Additional CSS classes to customize toggle appearance
149
137
  */
@@ -152,7 +140,6 @@ var script = {
152
140
  required: false,
153
141
  default: null
154
142
  },
155
-
156
143
  /**
157
144
  * Set to "true" to hide the caret
158
145
  */
@@ -161,7 +148,6 @@ var script = {
161
148
  required: false,
162
149
  default: false
163
150
  },
164
-
165
151
  /**
166
152
  * Right align listbox menu with respect to the toggle button
167
153
  */
@@ -170,7 +156,6 @@ var script = {
170
156
  required: false,
171
157
  default: false
172
158
  },
173
-
174
159
  /**
175
160
  * Center selected item checkmark
176
161
  */
@@ -179,7 +164,6 @@ var script = {
179
164
  required: false,
180
165
  default: false
181
166
  },
182
-
183
167
  /**
184
168
  * The `aria-labelledby` attribute value for the toggle button
185
169
  * Provide the string of ids seperated by space
@@ -189,7 +173,6 @@ var script = {
189
173
  required: false,
190
174
  default: null
191
175
  },
192
-
193
176
  /**
194
177
  * The `aria-labelledby` attribute value for the list of options
195
178
  * Provide the string of ids seperated by space
@@ -199,7 +182,6 @@ var script = {
199
182
  required: false,
200
183
  default: null
201
184
  },
202
-
203
185
  /**
204
186
  * Enable search
205
187
  */
@@ -208,7 +190,6 @@ var script = {
208
190
  required: false,
209
191
  default: false
210
192
  },
211
-
212
193
  /**
213
194
  * Set to "true" when items search is in progress.
214
195
  * It will display loading icon below the search input
@@ -218,7 +199,6 @@ var script = {
218
199
  required: false,
219
200
  default: false
220
201
  },
221
-
222
202
  /**
223
203
  * Message to be displayed when filtering produced no results
224
204
  */
@@ -228,7 +208,6 @@ var script = {
228
208
  default: 'No results found'
229
209
  }
230
210
  },
231
-
232
211
  data() {
233
212
  return {
234
213
  selectedValues: [],
@@ -238,22 +217,18 @@ var script = {
238
217
  searchStr: ''
239
218
  };
240
219
  },
241
-
242
220
  computed: {
243
221
  listboxTag() {
244
222
  if (this.items.length === 0 || isOption(this.items[0])) return 'ul';
245
223
  return 'div';
246
224
  },
247
-
248
225
  flattenedOptions() {
249
226
  return flattenedOptions(this.items);
250
227
  },
251
-
252
228
  listboxToggleText() {
253
229
  if (!this.toggleText) {
254
230
  if (!this.multiple && this.selectedValues.length) {
255
231
  var _this$flattenedOption;
256
-
257
232
  return (_this$flattenedOption = this.flattenedOptions.find(_ref => {
258
233
  let {
259
234
  value
@@ -261,13 +236,10 @@ var script = {
261
236
  return value === this.selectedValues[0];
262
237
  })) === null || _this$flattenedOption === void 0 ? void 0 : _this$flattenedOption.text;
263
238
  }
264
-
265
239
  return '';
266
240
  }
267
-
268
241
  return this.toggleText;
269
242
  },
270
-
271
243
  selectedIndices() {
272
244
  return this.selectedValues.map(selected => this.flattenedOptions.findIndex(_ref2 => {
273
245
  let {
@@ -276,61 +248,49 @@ var script = {
276
248
  return value === selected;
277
249
  })).sort();
278
250
  },
279
-
280
251
  showList() {
281
252
  return this.flattenedOptions.length && !this.searching;
282
253
  },
283
-
284
254
  showNoResultsText() {
285
255
  return !this.flattenedOptions.length && !this.searching;
286
256
  },
287
-
288
257
  announceSRSearchResults() {
289
258
  return this.searchable && !this.showNoResultsText && this.$scopedSlots['search-summary-sr-only'];
290
259
  },
291
-
292
260
  headerId() {
293
261
  return this.headerText && _uniqueId('listbox-header-');
294
262
  }
295
-
296
263
  },
297
264
  watch: {
298
265
  selected: {
299
266
  immediate: true,
300
-
301
267
  handler(newSelected) {
302
268
  if (Array.isArray(newSelected)) {
303
269
  if (!this.multiple && newSelected.length) {
304
270
  throw new Error('To allow multi-selection, please, set "multiple" property to "true"');
305
271
  }
306
-
307
272
  this.selectedValues = [...newSelected];
308
273
  } else {
309
274
  this.selectedValues = [newSelected];
310
275
  }
311
276
  }
312
-
313
277
  }
314
278
  },
315
279
  methods: {
316
280
  open() {
317
281
  this.$refs.baseDropdown.open();
318
282
  },
319
-
320
283
  close() {
321
284
  this.$refs.baseDropdown.close();
322
285
  },
323
-
324
286
  groupClasses(index) {
325
287
  return index === 0 ? null : GROUP_TOP_BORDER_CLASSES;
326
288
  },
327
-
328
289
  onShow() {
329
290
  if (this.searchable) {
330
291
  this.focusSearchInput();
331
292
  } else {
332
293
  var _this$selectedIndices;
333
-
334
294
  this.focusItem((_this$selectedIndices = this.selectedIndices[0]) !== null && _this$selectedIndices !== void 0 ? _this$selectedIndices : 0, this.getFocusableListItemElements());
335
295
  }
336
296
  /**
@@ -338,11 +298,8 @@ var script = {
338
298
  *
339
299
  * @event shown
340
300
  */
341
-
342
-
343
301
  this.$emit(GL_DROPDOWN_SHOWN);
344
302
  },
345
-
346
303
  onHide() {
347
304
  /**
348
305
  * Emitted when dropdown is hidden
@@ -352,7 +309,6 @@ var script = {
352
309
  this.$emit(GL_DROPDOWN_HIDDEN);
353
310
  this.nextFocusedItemIndex = null;
354
311
  },
355
-
356
312
  onKeydown(event) {
357
313
  const {
358
314
  code,
@@ -362,7 +318,6 @@ var script = {
362
318
  if (elements.length < 1) return;
363
319
  let stop = true;
364
320
  const isSearchInput = target.matches(SEARCH_INPUT_SELECTOR);
365
-
366
321
  if (code === HOME) {
367
322
  this.focusItem(0, elements);
368
323
  } else if (code === END) {
@@ -371,7 +326,6 @@ var script = {
371
326
  if (isSearchInput) {
372
327
  return;
373
328
  }
374
-
375
329
  if (this.searchable && elements.indexOf(target) === 0) {
376
330
  this.focusSearchInput();
377
331
  } else {
@@ -386,41 +340,31 @@ var script = {
386
340
  } else {
387
341
  stop = false;
388
342
  }
389
-
390
343
  if (stop) {
391
344
  stopEvent(event);
392
345
  }
393
346
  },
394
-
395
347
  getFocusableListItemElements() {
396
348
  var _this$$refs$list;
397
-
398
349
  const items = (_this$$refs$list = this.$refs.list) === null || _this$$refs$list === void 0 ? void 0 : _this$$refs$list.querySelectorAll(ITEM_SELECTOR);
399
350
  return Array.from(items || []);
400
351
  },
401
-
402
352
  focusNextItem(event, elements, offset) {
403
353
  const {
404
354
  target
405
355
  } = event;
406
356
  const currentIndex = elements.indexOf(target);
407
-
408
357
  const nextIndex = _clamp(currentIndex + offset, 0, elements.length - 1);
409
-
410
358
  this.focusItem(nextIndex, elements);
411
359
  },
412
-
413
360
  focusItem(index, elements) {
414
361
  var _elements$index;
415
-
416
362
  this.nextFocusedItemIndex = index;
417
363
  (_elements$index = elements[index]) === null || _elements$index === void 0 ? void 0 : _elements$index.focus();
418
364
  },
419
-
420
365
  focusSearchInput() {
421
366
  this.$refs.searchBox.focusInput();
422
367
  },
423
-
424
368
  onSelect(item, isSelected) {
425
369
  if (this.multiple) {
426
370
  this.onMultiSelect(item.value, isSelected);
@@ -428,15 +372,12 @@ var script = {
428
372
  this.onSingleSelect(item.value, isSelected);
429
373
  }
430
374
  },
431
-
432
375
  isSelected(item) {
433
376
  return this.selectedValues.some(value => value === item.value);
434
377
  },
435
-
436
378
  isFocused(item) {
437
379
  return this.nextFocusedItemIndex === this.flattenedOptions.indexOf(item);
438
380
  },
439
-
440
381
  onSingleSelect(value, isSelected) {
441
382
  if (isSelected) {
442
383
  /**
@@ -446,10 +387,8 @@ var script = {
446
387
  */
447
388
  this.$emit('select', value);
448
389
  }
449
-
450
390
  this.$refs.baseDropdown.closeAndFocus();
451
391
  },
452
-
453
392
  onMultiSelect(value, isSelected) {
454
393
  if (isSelected) {
455
394
  this.$emit('select', [...this.selectedValues, value]);
@@ -457,7 +396,6 @@ var script = {
457
396
  this.$emit('select', this.selectedValues.filter(selectedValue => selectedValue !== value));
458
397
  }
459
398
  },
460
-
461
399
  search(searchTerm) {
462
400
  /**
463
401
  * Emitted when the search query string is changed
@@ -467,7 +405,6 @@ var script = {
467
405
  */
468
406
  this.$emit('search', searchTerm);
469
407
  },
470
-
471
408
  isOption
472
409
  }
473
410
  };
@@ -8,11 +8,9 @@ var script = {
8
8
  required: true
9
9
  }
10
10
  },
11
-
12
11
  created() {
13
12
  this.nameId = _uniqueId('gl-listbox-group-');
14
13
  }
15
-
16
14
  };
17
15
 
18
16
  /* script */
@@ -29,27 +29,22 @@ var script = {
29
29
  if (this.isCheckCentered) {
30
30
  return '';
31
31
  }
32
-
33
32
  return 'gl-mt-3 gl-align-self-start';
34
33
  }
35
-
36
34
  },
37
35
  methods: {
38
36
  toggleSelection() {
39
37
  this.$emit('select', !this.isSelected);
40
38
  },
41
-
42
39
  onKeydown(event) {
43
40
  const {
44
41
  code
45
42
  } = event;
46
-
47
43
  if (code === ENTER || code === SPACE) {
48
44
  stopEvent(event);
49
45
  this.toggleSelection();
50
46
  }
51
47
  }
52
-
53
48
  }
54
49
  };
55
50
 
@@ -1,34 +1,27 @@
1
1
  import _isString from 'lodash/isString';
2
2
 
3
3
  const isOption = item => Boolean(item) && _isString(item.value);
4
-
5
4
  const isGroup = function () {
6
5
  let {
7
6
  options
8
7
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9
8
  return Array.isArray(options) && options.every(isOption);
10
9
  };
11
-
12
10
  const hasNoDuplicates = array => array.length === new Set(array).size;
13
-
14
11
  const flattenedOptions = items => items.flatMap(item => isOption(item) ? item : item.options);
15
-
16
12
  const isAllOptionsOrAllGroups = items => items.every(isOption) || items.every(isGroup);
17
-
18
13
  const hasUniqueValues = items => hasNoDuplicates(flattenedOptions(items).map(_ref => {
19
14
  let {
20
15
  value
21
16
  } = _ref;
22
17
  return value;
23
18
  }));
24
-
25
19
  const hasUniqueGroups = items => hasNoDuplicates(items.filter(isGroup).map(_ref2 => {
26
20
  let {
27
21
  text
28
22
  } = _ref2;
29
23
  return text;
30
24
  }));
31
-
32
25
  const itemsValidator = items => isAllOptionsOrAllGroups(items) && hasUniqueValues(items) && hasUniqueGroups(items);
33
26
 
34
27
  export { flattenedOptions, isOption, itemsValidator };
@@ -48,28 +48,23 @@ var script = {
48
48
  default: 'Sorry, your filter produced no results.'
49
49
  }
50
50
  },
51
-
52
51
  data() {
53
52
  return {
54
53
  pageIndex: this.page,
55
54
  queryStr: ''
56
55
  };
57
56
  },
58
-
59
57
  computed: {
60
58
  filteredList() {
61
59
  if (typeof this.filter === 'function') {
62
60
  return this.list.filter(listItem => this.filter(listItem, this.queryStr));
63
61
  }
64
-
65
62
  return this.list.filter(listItem => listItem[this.filter].toLowerCase().includes(this.queryStr.toLowerCase()));
66
63
  },
67
-
68
64
  paginatedList() {
69
65
  const offset = (this.pageIndex - 1) * this.perPage;
70
66
  return this.filteredList.slice(offset, offset + this.perPage);
71
67
  },
72
-
73
68
  pageInfo() {
74
69
  return {
75
70
  perPage: this.perPage,
@@ -77,15 +72,12 @@ var script = {
77
72
  page: this.pageIndex
78
73
  };
79
74
  },
80
-
81
75
  total() {
82
76
  return this.list.length;
83
77
  },
84
-
85
78
  filterTotal() {
86
79
  return this.filteredList.length;
87
80
  },
88
-
89
81
  /**
90
82
  * Determine if the original list had 0 items
91
83
  *
@@ -95,7 +87,6 @@ var script = {
95
87
  zeroTotal() {
96
88
  return this.total === 0;
97
89
  },
98
-
99
90
  /**
100
91
  * Determine if our search yields an empty list
101
92
  *
@@ -105,7 +96,6 @@ var script = {
105
96
  zeroSearchResults() {
106
97
  return this.total > 0 && this.filterTotal === 0;
107
98
  },
108
-
109
99
  /**
110
100
  * Determine if we originally had 0 results or 0 search results
111
101
  *
@@ -115,7 +105,6 @@ var script = {
115
105
  emptyList() {
116
106
  return this.zeroTotal || this.zeroSearchResults;
117
107
  }
118
-
119
108
  },
120
109
  watch: {
121
110
  /**
@@ -129,7 +118,6 @@ var script = {
129
118
  page(newPage) {
130
119
  this.pageIndex = newPage;
131
120
  },
132
-
133
121
  /**
134
122
  * In GitLab UI storybook, when a user changes the perPage knob,
135
123
  * we reset the paginated list to the first page.
@@ -140,18 +128,15 @@ var script = {
140
128
  perPage() {
141
129
  this.pageIndex = 1;
142
130
  }
143
-
144
131
  },
145
132
  methods: {
146
133
  change(page) {
147
134
  this.pageIndex = page;
148
135
  },
149
-
150
136
  query(queryStr) {
151
137
  this.pageIndex = 1;
152
138
  this.queryStr = queryStr;
153
139
  }
154
-
155
140
  }
156
141
  };
157
142