@gitlab/ui 49.0.0 → 49.0.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.
Files changed (131) 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 +14 -34
  49. package/dist/components/base/new_dropdowns/constants.js +4 -2
  50. package/dist/components/base/new_dropdowns/listbox/listbox.js +14 -81
  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 +3 -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/new_dropdowns/base_dropdown/base_dropdown.spec.js +1 -0
  128. package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.vue +13 -7
  129. package/src/components/base/new_dropdowns/listbox/listbox.spec.js +13 -7
  130. package/src/components/base/new_dropdowns/listbox/listbox.vue +12 -16
  131. package/src/components/base/pagination/pagination.vue +2 -2
@@ -32,7 +32,6 @@ var script = {
32
32
  required: false,
33
33
  default: () => []
34
34
  },
35
-
36
35
  /**
37
36
  * Token configuration with available operators and options.
38
37
  */
@@ -41,7 +40,6 @@ var script = {
41
40
  required: false,
42
41
  default: () => ({})
43
42
  },
44
-
45
43
  /**
46
44
  * Determines if the token is being edited or not.
47
45
  */
@@ -55,7 +53,6 @@ var script = {
55
53
  required: false,
56
54
  default: () => []
57
55
  },
58
-
59
56
  /**
60
57
  * Current token value.
61
58
  */
@@ -67,7 +64,6 @@ var script = {
67
64
  data: ''
68
65
  })
69
66
  },
70
-
71
67
  /**
72
68
  * Display operators' descriptions instead of their values (e.g., "is" instead of "=").
73
69
  */
@@ -88,7 +84,6 @@ var script = {
88
84
  default: false
89
85
  }
90
86
  },
91
-
92
87
  data() {
93
88
  return {
94
89
  activeSegment: null,
@@ -96,33 +91,28 @@ var script = {
96
91
  intendedCursorPosition: this.cursorPosition
97
92
  };
98
93
  },
99
-
100
94
  computed: {
101
95
  operators() {
102
96
  return this.config.operators || DEFAULT_OPERATORS;
103
97
  },
104
-
105
98
  hasDataOrDataSegmentIsCurrentlyActive() {
106
99
  return this.tokenValue.data !== '' || this.isSegmentActive(SEGMENT_DATA);
107
100
  },
108
-
109
101
  availableTokensWithSelf() {
110
- return [this.config, ...this.availableTokens.filter(t => t !== this.config)].map(t => ({ ...t,
102
+ return [this.config, ...this.availableTokens.filter(t => t !== this.config)].map(t => ({
103
+ ...t,
111
104
  value: t.title
112
105
  }));
113
106
  },
114
-
115
107
  operatorDescription() {
116
108
  const operator = this.operators.find(op => op.value === this.tokenValue.operator);
117
109
  return this.showFriendlyText ? operator === null || operator === void 0 ? void 0 : operator.description : operator === null || operator === void 0 ? void 0 : operator.value;
118
110
  },
119
-
120
111
  eventListeners() {
121
112
  return this.viewOnly ? {} : {
122
113
  mousedown: this.destroyByClose
123
114
  };
124
115
  }
125
-
126
116
  },
127
117
  segments: {
128
118
  SEGMENT_TITLE,
@@ -132,7 +122,6 @@ var script = {
132
122
  watch: {
133
123
  tokenValue: {
134
124
  deep: true,
135
-
136
125
  handler(newValue) {
137
126
  /**
138
127
  * Emitted when the token changes its value.
@@ -142,25 +131,20 @@ var script = {
142
131
  */
143
132
  this.$emit('input', newValue);
144
133
  }
145
-
146
134
  },
147
135
  value: {
148
136
  handler(newValue, oldValue) {
149
137
  if ((newValue === null || newValue === void 0 ? void 0 : newValue.data) === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.data) && (newValue === null || newValue === void 0 ? void 0 : newValue.operator) === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.operator)) {
150
138
  return;
151
139
  }
152
-
153
140
  this.tokenValue = _cloneDeep(newValue);
154
141
  }
155
-
156
142
  },
157
143
  active: {
158
144
  immediate: true,
159
-
160
145
  handler(newValue) {
161
146
  if (newValue) {
162
147
  this.intendedCursorPosition = this.cursorPosition;
163
-
164
148
  if (!this.activeSegment) {
165
149
  this.activateSegment(this.tokenValue.data !== '' ? SEGMENT_DATA : SEGMENT_OPERATOR);
166
150
  }
@@ -171,35 +155,32 @@ var script = {
171
155
  *
172
156
  * @event destroy
173
157
  */
174
-
175
158
  this.$emit('destroy');
176
159
  }
177
160
  }
178
-
179
161
  }
180
162
  },
181
-
182
163
  created() {
183
164
  if (!('operator' in this.tokenValue)) {
184
165
  if (this.operators.length === 1) {
185
166
  const operator = this.operators[0].value;
186
- this.$emit('input', { ...this.tokenValue,
167
+ this.$emit('input', {
168
+ ...this.tokenValue,
187
169
  operator
188
170
  });
189
171
  this.activeSegment = SEGMENT_DATA;
190
172
  } else {
191
- this.$emit('input', { ...this.tokenValue,
173
+ this.$emit('input', {
174
+ ...this.tokenValue,
192
175
  operator: ''
193
176
  });
194
177
  }
195
178
  }
196
179
  },
197
-
198
180
  methods: {
199
181
  activateSegment(segment) {
200
182
  if (this.viewOnly) return;
201
183
  this.activeSegment = segment;
202
-
203
184
  if (!this.active) {
204
185
  /**
205
186
  * Emitted when this term token is clicked.
@@ -209,21 +190,17 @@ var script = {
209
190
  this.$emit('activate');
210
191
  }
211
192
  },
212
-
213
193
  getAdditionalSegmentClasses(segment) {
214
194
  if (this.viewOnly) {
215
195
  return 'gl-cursor-text';
216
196
  }
217
-
218
197
  return {
219
198
  'gl-cursor-pointer': !this.isSegmentActive(segment)
220
199
  };
221
200
  },
222
-
223
201
  isSegmentActive(segment) {
224
202
  return this.active && this.activeSegment === segment;
225
203
  },
226
-
227
204
  replaceWithTermIfEmpty() {
228
205
  if (this.tokenValue.operator === '' && this.tokenValue.data === '') {
229
206
  /**
@@ -233,10 +210,8 @@ var script = {
233
210
  this.$emit('replace', createTerm(this.config.title));
234
211
  }
235
212
  },
236
-
237
213
  replaceToken(newTitle) {
238
214
  const newTokenConfig = this.availableTokens.find(t => t.title === newTitle);
239
-
240
215
  if (newTokenConfig === this.config) {
241
216
  this.$nextTick(() => {
242
217
  /**
@@ -248,7 +223,6 @@ var script = {
248
223
  });
249
224
  return;
250
225
  }
251
-
252
226
  if (newTokenConfig) {
253
227
  const isCompatible = this.config.dataType && this.config.dataType === newTokenConfig.dataType;
254
228
  this.$emit('replace', {
@@ -259,7 +233,6 @@ var script = {
259
233
  });
260
234
  }
261
235
  },
262
-
263
236
  handleOperatorKeydown(evt, _ref) {
264
237
  let {
265
238
  inputValue,
@@ -269,14 +242,11 @@ var script = {
269
242
  const {
270
243
  key
271
244
  } = evt;
272
-
273
245
  if (key === ' ' || key === 'Spacebar') {
274
246
  applySuggestion(suggestedValue);
275
247
  return;
276
248
  }
277
-
278
249
  const potentialValue = `${inputValue}${key}`;
279
-
280
250
  if (key.length === 1 && !this.operators.find(_ref2 => {
281
251
  let {
282
252
  value
@@ -290,40 +260,35 @@ var script = {
290
260
  }
291
261
  }
292
262
  },
293
-
294
263
  activateDataSegment() {
295
264
  if (this.config.multiSelect) {
296
- this.$emit('input', { ...this.tokenValue,
265
+ this.$emit('input', {
266
+ ...this.tokenValue,
297
267
  data: ''
298
268
  });
299
269
  }
300
-
301
270
  this.activateSegment(this.$options.segments.SEGMENT_DATA);
302
271
  },
303
-
304
272
  activatePreviousOperatorSegment() {
305
273
  this.activateSegment(this.$options.segments.SEGMENT_OPERATOR);
306
274
  this.intendedCursorPosition = 'end';
307
275
  },
308
-
309
276
  activatePreviousTitleSegment() {
310
277
  this.activateSegment(this.$options.segments.SEGMENT_TITLE);
311
278
  this.intendedCursorPosition = 'end';
312
279
  },
313
-
314
280
  activateNextDataSegment() {
315
281
  this.activateDataSegment();
316
282
  this.intendedCursorPosition = 'start';
317
283
  },
318
-
319
284
  activateNextOperatorSegment() {
320
285
  this.activateSegment(this.$options.segments.SEGMENT_OPERATOR);
321
286
  this.intendedCursorPosition = 'start';
322
287
  },
323
-
324
288
  handleComplete() {
325
289
  if (this.config.multiSelect) {
326
- this.$emit('input', { ...this.tokenValue,
290
+ this.$emit('input', {
291
+ ...this.tokenValue,
327
292
  data: this.multiSelectValues.join(COMMA)
328
293
  });
329
294
  }
@@ -332,11 +297,8 @@ var script = {
332
297
  *
333
298
  * @event complete
334
299
  */
335
-
336
-
337
300
  this.$emit('complete');
338
301
  },
339
-
340
302
  destroyByClose(event) {
341
303
  if (event.target.closest(TOKEN_CLOSE_SELECTOR)) {
342
304
  event.preventDefault();
@@ -344,7 +306,6 @@ var script = {
344
306
  this.$emit('destroy');
345
307
  }
346
308
  }
347
-
348
309
  }
349
310
  };
350
311
 
@@ -6,49 +6,42 @@ import GlFilteredSearchSuggestionList from './filtered_search_suggestion_list';
6
6
  import { splitOnQuotes, wrapTokenInQuotes } from './filtered_search_utils';
7
7
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
8
8
 
9
+ // We need some helpers to ensure @vue/compat compatibility
9
10
  // @vue/compat will render comment nodes for v-if and comments in HTML
10
11
  // Also it makes use of fragments - both comments and nodes are Symbols.
11
12
  // In Vue3 all of them (Comment, Fragment) are exposed as named exports on vue module
12
13
  // However we want to maintain compatibility with Vue2, so taking this hacky approach
13
14
  // relying on Symbol.toString()
15
+
14
16
  // I'm keeping this directly here instead of helper to increase probability of
15
17
  // fixing ASAP and because I don't want this helper to be reused
16
18
  // FIXME: replace with Symbols when we will switch to Vue3
17
19
 
18
20
  const isVue3Comment = vnode => {
19
21
  var _vnode$type, _vnode$type$toString;
20
-
21
22
  return (vnode === null || vnode === void 0 ? void 0 : (_vnode$type = vnode.type) === null || _vnode$type === void 0 ? void 0 : (_vnode$type$toString = _vnode$type.toString) === null || _vnode$type$toString === void 0 ? void 0 : _vnode$type$toString.call(_vnode$type)) === 'Symbol(Comment)';
22
23
  };
23
-
24
24
  const isVue3Fragment = vnode => {
25
25
  var _vnode$type2, _vnode$type2$toString;
26
-
27
26
  return (vnode === null || vnode === void 0 ? void 0 : (_vnode$type2 = vnode.type) === null || _vnode$type2 === void 0 ? void 0 : (_vnode$type2$toString = _vnode$type2.toString) === null || _vnode$type2$toString === void 0 ? void 0 : _vnode$type2$toString.call(_vnode$type2)) === 'Symbol(Fragment)';
28
27
  };
29
-
30
28
  const isVNodeEmpty = vnode => {
31
29
  if (isVue3Fragment(vnode)) {
32
30
  // vnode.children might be an array or single node in edge cases
33
31
  return Array.isArray(vnode.children) ? vnode.children.every(isVNodeEmpty) : isVNodeEmpty(vnode.children);
34
32
  }
35
-
36
33
  if (isVue3Comment(vnode)) {
37
34
  return true;
38
35
  }
39
-
40
36
  return false;
41
37
  };
42
-
43
38
  const isSlotNotEmpty = slot => {
44
39
  if (!slot) {
45
40
  return false;
46
41
  }
47
-
48
42
  const vnodes = typeof slot === 'function' ? slot() : slot;
49
43
  return !(Array.isArray(vnodes) ? vnodes.every(isVNodeEmpty) : isVNodeEmpty(vnodes));
50
44
  };
51
-
52
45
  var script = {
53
46
  name: 'GlFilteredSearchTokenSegment',
54
47
  components: {
@@ -92,7 +85,6 @@ var script = {
92
85
  required: false,
93
86
  default: () => () => false
94
87
  },
95
-
96
88
  /**
97
89
  * Current term value
98
90
  */
@@ -100,7 +92,6 @@ var script = {
100
92
  required: true,
101
93
  validator: () => true
102
94
  },
103
-
104
95
  /**
105
96
  * HTML attributes to add to the search input
106
97
  */
@@ -109,7 +100,6 @@ var script = {
109
100
  required: false,
110
101
  default: () => ({})
111
102
  },
112
-
113
103
  /**
114
104
  * If this is the last token
115
105
  */
@@ -135,32 +125,25 @@ var script = {
135
125
  default: false
136
126
  }
137
127
  },
138
-
139
128
  data() {
140
129
  return {
141
130
  fallbackValue: this.value
142
131
  };
143
132
  },
144
-
145
133
  computed: {
146
134
  matchingOption() {
147
135
  var _this$options;
148
-
149
136
  return (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.find(o => o.value === this.value);
150
137
  },
151
-
152
138
  nonMultipleValue() {
153
139
  return this.multiSelect ? _last(this.value.split(COMMA)) : this.value;
154
140
  },
155
-
156
141
  inputValue: {
157
142
  get() {
158
143
  return this.matchingOption ? this.matchingOption[this.optionTextField] : this.nonMultipleValue;
159
144
  },
160
-
161
145
  set(v) {
162
146
  var _this$getMatchingOpti, _this$getMatchingOpti2;
163
-
164
147
  /**
165
148
  * Emitted when this token segment's value changes.
166
149
  *
@@ -168,43 +151,33 @@ var script = {
168
151
  */
169
152
  this.$emit('input', (_this$getMatchingOpti = (_this$getMatchingOpti2 = this.getMatchingOptionForInputValue(v)) === null || _this$getMatchingOpti2 === void 0 ? void 0 : _this$getMatchingOpti2.value) !== null && _this$getMatchingOpti !== void 0 ? _this$getMatchingOpti : v);
170
153
  }
171
-
172
154
  },
173
-
174
155
  hasOptionsOrSuggestions() {
175
156
  var _this$options2;
176
-
177
157
  // eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
178
158
  return ((_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.length) || isSlotNotEmpty(this.$slots.suggestions);
179
159
  },
180
-
181
160
  defaultSuggestedValue() {
182
161
  var _ref;
183
-
184
162
  if (!this.options) {
185
163
  return this.nonMultipleValue;
186
164
  }
187
-
188
165
  if (this.value) {
189
166
  const match = this.getMatchingOptionForInputValue(this.inputValue) || this.getMatchingOptionForInputValue(this.inputValue, {
190
167
  loose: true
191
168
  });
192
169
  return match === null || match === void 0 ? void 0 : match.value;
193
170
  }
194
-
195
171
  const defaultSuggestion = this.options.find(op => op.default);
196
172
  return (_ref = defaultSuggestion !== null && defaultSuggestion !== void 0 ? defaultSuggestion : this.options[0]) === null || _ref === void 0 ? void 0 : _ref.value;
197
173
  },
198
-
199
174
  containerAttributes() {
200
175
  return this.isLastToken && !this.active && this.currentValue.length > 1 && this.searchInputAttributes;
201
176
  }
202
-
203
177
  },
204
178
  watch: {
205
179
  active: {
206
180
  immediate: true,
207
-
208
181
  handler(newValue) {
209
182
  if (newValue) {
210
183
  this.activate();
@@ -212,21 +185,15 @@ var script = {
212
185
  this.deactivate();
213
186
  }
214
187
  }
215
-
216
188
  },
217
-
218
189
  inputValue(newValue) {
219
190
  var _this$getMatchingOpti3, _this$getMatchingOpti4;
220
-
221
191
  const hasUnclosedQuote = newValue.split('"').length % 2 === 0;
222
-
223
192
  if (newValue.indexOf(' ') === -1 || hasUnclosedQuote) {
224
193
  return;
225
194
  }
226
-
227
195
  const [firstWord, ...otherWords] = splitOnQuotes(newValue).filter((w, idx, arr) => Boolean(w) || idx === arr.length - 1);
228
196
  this.$emit('input', (_this$getMatchingOpti3 = (_this$getMatchingOpti4 = this.getMatchingOptionForInputValue(firstWord)) === null || _this$getMatchingOpti4 === void 0 ? void 0 : _this$getMatchingOpti4.value) !== null && _this$getMatchingOpti3 !== void 0 ? _this$getMatchingOpti3 : firstWord);
229
-
230
197
  if (otherWords.length) {
231
198
  /**
232
199
  * Emitted when Space appears in token segment value
@@ -235,7 +202,6 @@ var script = {
235
202
  this.$emit('split', otherWords);
236
203
  }
237
204
  }
238
-
239
205
  },
240
206
  methods: {
241
207
  emitIfInactive(e) {
@@ -247,10 +213,8 @@ var script = {
247
213
  e.preventDefault();
248
214
  }
249
215
  },
250
-
251
216
  getMatchingOptionForInputValue(v) {
252
217
  var _this$options3;
253
-
254
218
  let {
255
219
  loose
256
220
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
@@ -258,14 +222,12 @@ var script = {
258
222
  };
259
223
  return (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.find(o => loose ? o[this.optionTextField].startsWith(v) : [this.optionTextField] === v);
260
224
  },
261
-
262
225
  activate() {
263
226
  this.fallbackValue = this.value;
264
227
  this.$nextTick(() => {
265
228
  const {
266
229
  input
267
230
  } = this.$refs;
268
-
269
231
  if (input) {
270
232
  input.focus();
271
233
  input.scrollIntoView({
@@ -273,42 +235,35 @@ var script = {
273
235
  inline: 'end'
274
236
  });
275
237
  this.alignSuggestions(input);
276
-
277
238
  if (this.cursorPosition === 'start') {
278
239
  input === null || input === void 0 ? void 0 : input.setSelectionRange(0, 0);
279
240
  }
280
241
  }
281
242
  });
282
243
  },
283
-
284
244
  deactivate() {
285
245
  var _this$matchingOption;
286
-
287
246
  if (!this.options) {
288
247
  return;
289
248
  }
290
-
291
249
  if (((_this$matchingOption = this.matchingOption) === null || _this$matchingOption === void 0 ? void 0 : _this$matchingOption.value) !== this.value) {
292
250
  this.$emit('input', this.fallbackValue);
293
251
  }
294
252
  },
295
-
296
253
  applySuggestion(suggestedValue) {
297
254
  const formattedSuggestedValue = wrapTokenInQuotes(suggestedValue);
255
+
298
256
  /**
299
257
  * Emitted when autocomplete entry is selected.
300
258
  *
301
259
  * @type {string} value The selected value.
302
260
  */
303
-
304
261
  this.$emit('select', formattedSuggestedValue);
305
-
306
262
  if (!this.multiSelect) {
307
263
  this.$emit('input', formattedSuggestedValue);
308
264
  this.$emit('complete', formattedSuggestedValue);
309
265
  }
310
266
  },
311
-
312
267
  handleInputKeydown(e) {
313
268
  const {
314
269
  key
@@ -337,13 +292,11 @@ var script = {
337
292
  /**
338
293
  * Emitted when Backspace is pressed and the value is empty
339
294
  */
340
-
341
295
  this.$emit('backspace');
342
296
  }
343
297
  },
344
298
  Enter: () => {
345
299
  e.preventDefault();
346
-
347
300
  if (suggestedValue != null) {
348
301
  this.applySuggestion(suggestedValue);
349
302
  } else {
@@ -364,7 +317,6 @@ var script = {
364
317
  /**
365
318
  * Emitted when suggestion is selected from the suggestion list
366
319
  */
367
-
368
320
  this.$emit('complete');
369
321
  }
370
322
  };
@@ -374,23 +326,19 @@ var script = {
374
326
  ArrowUp: () => suggestions.prevItem(),
375
327
  Up: () => suggestions.prevItem()
376
328
  };
377
-
378
329
  if (this.hasOptionsOrSuggestions) {
379
330
  Object.assign(handlers, suggestionsHandlers);
380
331
  }
381
-
382
332
  if (Object.keys(handlers).includes(key)) {
383
333
  handlers[key]();
384
334
  return;
385
335
  }
386
-
387
336
  this.customInputKeydownHandler(e, {
388
337
  suggestedValue,
389
338
  inputValue: this.inputValue,
390
339
  applySuggestion: v => this.applySuggestion(v)
391
340
  });
392
341
  },
393
-
394
342
  handleBlur() {
395
343
  if (this.multiSelect) {
396
344
  this.$emit('complete');
@@ -401,7 +349,6 @@ var script = {
401
349
  this.$emit('deactivate');
402
350
  }
403
351
  }
404
-
405
352
  }
406
353
  };
407
354
 
@@ -13,9 +13,9 @@ function normalizeTokens(tokens) {
13
13
  if (isEmptyTerm(token)) {
14
14
  return;
15
15
  }
16
-
17
16
  if (token.type !== TERM_TOKEN_TYPE) {
18
- result.push({ ...token
17
+ result.push({
18
+ ...token
19
19
  });
20
20
  } else if (result.length > 0 && typeof result[result.length - 1] === 'string') {
21
21
  result[result.length - 1] += ` ${token.value.data}`;
@@ -25,23 +25,19 @@ function normalizeTokens(tokens) {
25
25
  });
26
26
  return result;
27
27
  }
28
-
29
28
  function assertValidTokens(tokens) {
30
29
  if (!Array.isArray(tokens) && !typeof tokens === 'string') {
31
30
  throw new TypeError('Either string or array of tokens is expected');
32
31
  }
33
32
  }
34
-
35
33
  function needDenormalization(tokens) {
36
34
  if (typeof tokens === 'string') {
37
35
  return true;
38
36
  }
39
-
40
37
  assertValidTokens(tokens);
41
38
  return tokens.some(t => typeof t === 'string' || !t.id);
42
39
  }
43
40
  let tokenIdCounter = 0;
44
-
45
41
  const getTokenId = () => {
46
42
  const tokenId = `token-${tokenIdCounter}`;
47
43
  tokenIdCounter += 1;
@@ -57,15 +53,13 @@ const getTokenId = () => {
57
53
  * @param {object} token The token to check.
58
54
  * @returns {object} A token with an `id`.
59
55
  */
60
-
61
-
62
56
  function ensureTokenId(token) {
63
57
  if (!token.id) {
64
- return { ...token,
58
+ return {
59
+ ...token,
65
60
  id: getTokenId()
66
61
  };
67
62
  }
68
-
69
63
  return token;
70
64
  }
71
65
  function createTerm() {
@@ -96,20 +90,16 @@ function splitOnQuotes(str) {
96
90
  if (_first(str) === "'" && _last(str) === "'") {
97
91
  return [str];
98
92
  }
99
-
100
93
  if (_first(str) === '"' && _last(str) === '"') {
101
94
  return [str];
102
95
  }
103
-
104
96
  const queue = str.split(' ');
105
97
  const result = [];
106
98
  let waitingForMatchingQuote = false;
107
99
  let quoteContent = '';
108
-
109
100
  while (queue.length) {
110
101
  const part = queue.shift();
111
102
  const quoteIndex = part.indexOf('"');
112
-
113
103
  if (quoteIndex === -1) {
114
104
  if (waitingForMatchingQuote) {
115
105
  quoteContent += ` ${part}`;
@@ -118,30 +108,26 @@ function splitOnQuotes(str) {
118
108
  }
119
109
  } else {
120
110
  const [firstPart, secondPart] = part.split('"', 2);
121
-
122
111
  if (waitingForMatchingQuote) {
123
112
  waitingForMatchingQuote = false;
124
113
  quoteContent += ` ${firstPart}"`;
125
114
  result.push(quoteContent);
126
115
  quoteContent = '';
127
-
128
116
  if (secondPart.length) {
129
117
  queue.unshift(secondPart);
130
118
  }
131
119
  } else {
132
120
  waitingForMatchingQuote = true;
133
-
134
121
  if (firstPart.length) {
135
122
  result.push(firstPart);
136
123
  }
137
-
138
124
  quoteContent = `"${secondPart}`;
139
125
  }
140
126
  }
141
127
  }
142
-
143
128
  return result;
144
129
  }
130
+
145
131
  /**
146
132
  * wraps the incoming token in double quotes.
147
133
  * Eg. Foo Bar becomes "Foo Bar"
@@ -149,22 +135,19 @@ function splitOnQuotes(str) {
149
135
  * 1. token must have space.
150
136
  * 2. token should not already have a quote around it.
151
137
  */
152
-
153
138
  function wrapTokenInQuotes(token) {
154
139
  if (!_isString(token)) {
155
140
  return token;
156
141
  }
157
-
158
142
  if (!token.includes(' ')) {
159
143
  return token;
160
144
  }
145
+ const quotes = ["'", '"'];
161
146
 
162
- const quotes = ["'", '"']; // If the token starts and ends with a quote, eg. "Foo Bar", then return the original token.
163
-
147
+ // If the token starts and ends with a quote, eg. "Foo Bar", then return the original token.
164
148
  if (quotes.some(quote => _first(token) === quote && _last(token) === quote)) {
165
149
  return token;
166
150
  }
167
-
168
151
  return `"${token}"`;
169
152
  }
170
153