@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
@@ -28,7 +28,6 @@ var script = {
28
28
  */
29
29
  this.$emit('change', $event);
30
30
  },
31
-
32
31
  input($event) {
33
32
  /**
34
33
  * Emitted when checked state is changed.
@@ -37,7 +36,6 @@ var script = {
37
36
  */
38
37
  this.$emit('input', $event);
39
38
  }
40
-
41
39
  }
42
40
  };
43
41
 
@@ -24,15 +24,12 @@ var script = {
24
24
  node() {
25
25
  return this.tree.getNode(this.option.value);
26
26
  },
27
-
28
27
  label() {
29
28
  return this.node.label || this.node.value;
30
29
  },
31
-
32
30
  rootClass() {
33
31
  return this.isNested ? 'gl-ml-6' : null;
34
32
  },
35
-
36
33
  checkboxClass() {
37
34
  const {
38
35
  isChecked,
@@ -40,7 +37,6 @@ var script = {
40
37
  } = this.node;
41
38
  return [isChecked && 'js-is-checked', isIndeterminate && 'js-is-indeterminate'];
42
39
  }
43
-
44
40
  }
45
41
  };
46
42
 
@@ -11,13 +11,11 @@ var script = {
11
11
  GlFormCheckbox,
12
12
  GlFormCheckboxTreeNode
13
13
  },
14
-
15
14
  provide() {
16
15
  return {
17
16
  tree: this.tree
18
17
  };
19
18
  },
20
-
21
19
  model: {
22
20
  prop: V_MODEL.PROP,
23
21
  event: V_MODEL.EVENT
@@ -35,7 +33,6 @@ var script = {
35
33
  type: Array,
36
34
  required: true
37
35
  },
38
-
39
36
  /**
40
37
  * The selected options as an array of values
41
38
  */
@@ -44,7 +41,6 @@ var script = {
44
41
  required: false,
45
42
  default: () => []
46
43
  },
47
-
48
44
  /**
49
45
  * Set to true to hide the "Select/unselect all" checkbox
50
46
  */
@@ -53,7 +49,6 @@ var script = {
53
49
  required: false,
54
50
  default: false
55
51
  },
56
-
57
52
  /**
58
53
  * Label for the toggle all checkbox when some or all options are unchecked
59
54
  */
@@ -62,7 +57,6 @@ var script = {
62
57
  required: false,
63
58
  default: 'Select all'
64
59
  },
65
-
66
60
  /**
67
61
  * Label for the toggle all checkbox when all options are checked
68
62
  */
@@ -82,18 +76,15 @@ var script = {
82
76
  default: true
83
77
  }
84
78
  },
85
-
86
79
  data() {
87
80
  return {
88
81
  tree: new Tree(this.options, this.value)
89
82
  };
90
83
  },
91
-
92
84
  computed: {
93
85
  toggleAllLabel() {
94
86
  return this.tree.allOptionsChecked ? this.unselectAllLabel : this.selectAllLabel;
95
87
  }
96
-
97
88
  },
98
89
  watch: {
99
90
  'tree.selected': {
@@ -103,7 +94,6 @@ var script = {
103
94
  */
104
95
  this.$emit(V_MODEL.EVENT, selected);
105
96
  }
106
-
107
97
  }
108
98
  }
109
99
  };
@@ -17,44 +17,35 @@ class Node {
17
17
  this.depth = depth;
18
18
  this.checkedState = isChecked ? CHECKED_STATE.CHECKED : CHECKED_STATE.UNCHECKED;
19
19
  }
20
+
20
21
  /**
21
22
  * Sets the node's checked state
22
23
  * @param {number} checkedState
23
24
  */
24
-
25
-
26
25
  setCheckedState(checkedState) {
27
26
  this.checkedState = checkedState;
28
27
  }
29
-
30
28
  get isChild() {
31
29
  return this.parent !== null;
32
30
  }
33
-
34
31
  get isParent() {
35
32
  return this.children.length > 0;
36
33
  }
37
-
38
34
  get isLeaf() {
39
35
  return !this.isParent;
40
36
  }
41
-
42
37
  get isUnchecked() {
43
38
  return this.checkedState === CHECKED_STATE.UNCHECKED;
44
39
  }
45
-
46
40
  get isIndeterminate() {
47
41
  return this.checkedState === CHECKED_STATE.INDETERMINATE;
48
42
  }
49
-
50
43
  get isChecked() {
51
44
  return this.checkedState === CHECKED_STATE.CHECKED;
52
45
  }
53
-
54
46
  get isCheckedOrIndeterminate() {
55
47
  return this.isChecked || this.isIndeterminate;
56
48
  }
57
-
58
49
  }
59
50
 
60
51
  export { Node };
@@ -8,38 +8,35 @@ class Tree {
8
8
  this.initNodes(options, selected);
9
9
  this.initIndeterminateStates();
10
10
  }
11
+
11
12
  /**
12
13
  * @returns {[Node]} The tree as an array of Node instances
13
14
  */
14
-
15
-
16
15
  get nodesList() {
17
16
  return Object.values(this.nodes);
18
17
  }
18
+
19
19
  /**
20
20
  * @returns {array} The values currently selected
21
21
  */
22
-
23
-
24
22
  get selected() {
25
23
  return this.nodesList.filter(node => node.isChecked).map(node => node.value);
26
24
  }
25
+
27
26
  /**
28
27
  * @returns {boolean} Whether all options are checked
29
28
  */
30
-
31
-
32
29
  get allOptionsChecked() {
33
30
  return this.selected.length === this.nodesList.length;
34
31
  }
32
+
35
33
  /**
36
34
  * @returns {boolean} Whether some, but not all options are checked
37
35
  */
38
-
39
-
40
36
  get someOptionsChecked() {
41
37
  return this.selected.length > 0 && !this.allOptionsChecked;
42
38
  }
39
+
43
40
  /**
44
41
  * Creates a flat tree of Node instances.
45
42
  * @param {array} options The options list
@@ -47,22 +44,19 @@ class Tree {
47
44
  * @param {object} parent The options' parent
48
45
  * @param {number} depth The current depth-level in the tree
49
46
  */
50
-
51
-
52
47
  initNodes() {
53
48
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
54
49
  let selected = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
55
50
  let parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
56
51
  let depth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
57
-
58
52
  if (!options.length) {
59
53
  return;
60
54
  }
61
-
62
55
  this.treeDepth = depth > this.treeDepth ? depth : this.treeDepth;
63
56
  options.forEach(option => {
64
57
  const isChecked = selected.includes(option.value);
65
- this.nodes[option.value] = new Node({ ...option,
58
+ this.nodes[option.value] = new Node({
59
+ ...option,
66
60
  parent,
67
61
  isChecked,
68
62
  depth
@@ -70,16 +64,14 @@ class Tree {
70
64
  this.initNodes(option.children, selected, option, depth + 1);
71
65
  });
72
66
  }
67
+
73
68
  /**
74
69
  * Looks for UNCHECKED nodes and sets their checked state to INDETERMINATE if needed. We start
75
70
  * with the deepest leaves and we go up level by level to propagate the correct INDETERMINATE
76
71
  * states to each parent node.
77
72
  */
78
-
79
-
80
73
  initIndeterminateStates() {
81
74
  const nodes = [...this.nodesList];
82
-
83
75
  for (let i = this.treeDepth; i >= 0; i -= 1) {
84
76
  const removeIndices = [];
85
77
  nodes.forEach((node, nodeIndex) => {
@@ -93,16 +85,16 @@ class Tree {
93
85
  });
94
86
  }
95
87
  }
88
+
96
89
  /**
97
90
  * Returns true if all of the option's children are checked, false otherwise.
98
91
  * @param {object} option
99
92
  * @returns {boolean}
100
93
  */
101
-
102
-
103
94
  optionHasAllChildrenChecked(option) {
104
95
  return this.getOptionChildren(option).every(child => child.isChecked);
105
96
  }
97
+
106
98
  /**
107
99
  * Returns true if at least one of the option's children is in a checked or indeterminate state,
108
100
  * returns false otherwise.
@@ -111,28 +103,24 @@ class Tree {
111
103
  * @param {object} option
112
104
  * @returns {boolean}
113
105
  */
114
-
115
-
116
106
  optionHasSomeChildrenChecked(option) {
117
107
  return this.getOptionChildren(option).some(child => child.isCheckedOrIndeterminate);
118
108
  }
109
+
119
110
  /**
120
111
  * Returns the Node instance for a given option's value.
121
112
  * @param {number|string} value The option's value
122
113
  * @returns {Node}
123
114
  */
124
-
125
-
126
115
  getNode(value) {
127
116
  return this.nodes[value];
128
117
  }
118
+
129
119
  /**
130
120
  * Returns the option's children as Node instances.
131
121
  * @param {object} option
132
122
  * @returns {[Node]}
133
123
  */
134
-
135
-
136
124
  getOptionChildren(option) {
137
125
  return option.children.map(_ref => {
138
126
  let {
@@ -141,27 +129,26 @@ class Tree {
141
129
  return this.getNode(value);
142
130
  });
143
131
  }
132
+
144
133
  /**
145
134
  * Sets a node's state based on whether it got checked or unchecked
146
135
  * @param {Node} node The node to be toggled
147
136
  * @param {boolean} checked Whether the node should be checked
148
137
  */
149
-
150
-
151
138
  static toggleNodeState(node, checked) {
152
139
  node.setCheckedState(checked ? CHECKED_STATE.CHECKED : CHECKED_STATE.UNCHECKED);
153
140
  }
141
+
154
142
  /**
155
143
  * Toggles all options.
156
144
  * @param {boolean} checked Whether the options should be checked or unchecked
157
145
  */
158
-
159
-
160
146
  toggleAllOptions(checked) {
161
147
  this.nodesList.forEach(node => {
162
148
  Tree.toggleNodeState(node, checked);
163
149
  });
164
150
  }
151
+
165
152
  /**
166
153
  * Toggles an option's checked state and propagates the state change to the
167
154
  * option's parents and children.
@@ -169,8 +156,6 @@ class Tree {
169
156
  * @param {boolean} checked Whether the option is checked
170
157
  * @param {boolean} propagateToParent Whether the state should be propagated to the parents
171
158
  */
172
-
173
-
174
159
  toggleOption(_ref2, checked) {
175
160
  let {
176
161
  value
@@ -178,15 +163,14 @@ class Tree {
178
163
  let propagateToParent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
179
164
  const node = this.getNode(value);
180
165
  Tree.toggleNodeState(node, checked);
181
-
182
166
  if (node.isChild && propagateToParent) {
183
167
  this.toggleParentOption(node.parent);
184
168
  }
185
-
186
169
  if (node.isParent) {
187
170
  node.children.forEach(child => this.toggleOption(child, checked, false));
188
171
  }
189
172
  }
173
+
190
174
  /**
191
175
  * Toggles a parent option's checked state. This is called as a result of a child option being
192
176
  * toggled by the user and the change being propagated to that option's parents. This method
@@ -194,14 +178,11 @@ class Tree {
194
178
  * tree's trunk.
195
179
  * @param {object} param0 The option to be toggled
196
180
  */
197
-
198
-
199
181
  toggleParentOption(_ref3) {
200
182
  let {
201
183
  value
202
184
  } = _ref3;
203
185
  const node = this.getNode(value);
204
-
205
186
  if (this.optionHasAllChildrenChecked(node)) {
206
187
  node.checkedState = CHECKED_STATE.CHECKED;
207
188
  } else if (this.optionHasSomeChildrenChecked(node)) {
@@ -209,12 +190,10 @@ class Tree {
209
190
  } else {
210
191
  node.checkedState = CHECKED_STATE.UNCHECKED;
211
192
  }
212
-
213
193
  if (node.isChild) {
214
194
  this.toggleParentOption(node.parent);
215
195
  }
216
196
  }
217
-
218
197
  }
219
198
 
220
199
  export { Tree };
@@ -31,7 +31,6 @@ var script = {
31
31
  type: Array,
32
32
  required: true
33
33
  },
34
-
35
34
  /**
36
35
  * List of action functions to display at the bottom of the dropdown
37
36
  */
@@ -54,7 +53,6 @@ var script = {
54
53
  required: false,
55
54
  default: false
56
55
  },
57
-
58
56
  /**
59
57
  * Placeholder text for input field
60
58
  */
@@ -64,7 +62,6 @@ var script = {
64
62
  default: undefined
65
63
  }
66
64
  },
67
-
68
65
  data() {
69
66
  return {
70
67
  results: [],
@@ -74,32 +71,25 @@ var script = {
74
71
  inputId: _uniqueId('token-input-')
75
72
  };
76
73
  },
77
-
78
74
  computed: {
79
75
  ariaExpanded() {
80
76
  return this.showSuggestions.toString();
81
77
  },
82
-
83
78
  showAutocomplete() {
84
79
  return this.showSuggestions ? 'off' : 'on';
85
80
  },
86
-
87
81
  showSuggestions() {
88
82
  return this.value.length > 0 && this.allItems.length > 0;
89
83
  },
90
-
91
84
  displayedValue() {
92
85
  return this.matchValueToAttr && this.value[this.matchValueToAttr] ? this.value[this.matchValueToAttr] : this.value;
93
86
  },
94
-
95
87
  resultsLength() {
96
88
  return this.results.length;
97
89
  },
98
-
99
90
  allItems() {
100
91
  return [...this.results, ...this.actionList];
101
92
  }
102
-
103
93
  },
104
94
  watch: {
105
95
  tokenList(newList) {
@@ -110,85 +100,67 @@ var script = {
110
100
  this.arrowCounter = -1;
111
101
  }
112
102
  }
113
-
114
103
  },
115
-
116
104
  mounted() {
117
105
  document.addEventListener('click', this.handleClickOutside);
118
106
  },
119
-
120
107
  destroyed() {
121
108
  document.removeEventListener('click', this.handleClickOutside);
122
109
  },
123
-
124
110
  methods: {
125
111
  closeSuggestions() {
126
112
  this.results = [];
127
113
  this.arrowCounter = -1;
128
114
  this.userDismissedResults = true;
129
115
  },
130
-
131
116
  handleClickOutside(event) {
132
117
  if (!this.$el.contains(event.target)) {
133
118
  this.closeSuggestions();
134
119
  }
135
120
  },
136
-
137
121
  focusItem(index) {
138
122
  var _this$$refs$suggestio;
139
-
140
123
  (_this$$refs$suggestio = this.$refs.suggestionsMenu.querySelectorAll('.gl-new-dropdown-item')[index]) === null || _this$$refs$suggestio === void 0 ? void 0 : _this$$refs$suggestio.querySelector('button').focus();
141
124
  },
142
-
143
125
  onArrowDown(e) {
144
126
  e.preventDefault();
145
127
  let newCount = this.arrowCounter + 1;
146
-
147
128
  if (newCount >= this.allItems.length) {
148
129
  newCount = 0;
149
130
  }
150
-
151
131
  this.arrowCounter = newCount;
152
132
  this.focusItem(newCount);
153
133
  },
154
-
155
134
  onArrowUp(e) {
156
135
  e.preventDefault();
157
136
  let newCount = this.arrowCounter - 1;
158
-
159
137
  if (newCount < 0) {
160
138
  newCount = this.allItems.length - 1;
161
139
  }
162
-
163
140
  this.arrowCounter = newCount;
164
141
  this.focusItem(newCount);
165
142
  },
166
-
167
143
  onEsc() {
168
144
  if (!this.showSuggestions) {
169
145
  this.$emit('input', '');
170
146
  }
171
-
172
147
  this.closeSuggestions();
173
148
  },
174
-
175
149
  onEntry(value) {
176
150
  this.$emit('input', value);
177
- this.userDismissedResults = false; // short circuit so that we don't false match on empty string
151
+ this.userDismissedResults = false;
178
152
 
153
+ // short circuit so that we don't false match on empty string
179
154
  if (value.length < 1) {
180
155
  this.closeSuggestions();
181
156
  return;
182
157
  }
183
-
184
158
  const filteredTokens = this.tokenList.filter(token => {
185
159
  if (this.matchValueToAttr) {
186
160
  return token[this.matchValueToAttr].toLowerCase().includes(value.toLowerCase());
187
161
  }
188
-
189
162
  return token.toLowerCase().includes(value.toLowerCase());
190
163
  });
191
-
192
164
  if (filteredTokens.length) {
193
165
  this.openSuggestions(filteredTokens);
194
166
  } else {
@@ -196,11 +168,9 @@ var script = {
196
168
  this.arrowCounter = -1;
197
169
  }
198
170
  },
199
-
200
171
  openSuggestions(filteredResults) {
201
172
  this.results = filteredResults;
202
173
  },
203
-
204
174
  selectToken(value) {
205
175
  this.$emit('input', value);
206
176
  this.closeSuggestions();
@@ -208,20 +178,16 @@ var script = {
208
178
  * Emitted when a value is selected.
209
179
  * @event value-selected
210
180
  */
211
-
212
181
  this.$emit('value-selected', value);
213
182
  },
214
-
215
183
  selectAction(value) {
216
184
  value.fn();
217
185
  this.$emit('input', this.value);
218
186
  this.closeSuggestions();
219
187
  },
220
-
221
188
  resetCounter() {
222
189
  this.arrowCounter = -1;
223
190
  }
224
-
225
191
  }
226
192
  };
227
193
 
@@ -39,29 +39,24 @@ var script = {
39
39
  labelClass
40
40
  } = this;
41
41
  const defaultClass = 'col-form-label';
42
-
43
42
  if (_isString(labelClass)) {
44
43
  return `${labelClass} ${defaultClass}`;
45
44
  }
46
-
47
45
  if (_isArray(labelClass)) {
48
46
  return [...labelClass, defaultClass];
49
47
  }
50
-
51
48
  if (_isPlainObject(labelClass)) {
52
- return { ...labelClass,
49
+ return {
50
+ ...labelClass,
53
51
  [defaultClass]: true
54
52
  };
55
53
  }
56
-
57
54
  return defaultClass;
58
55
  },
59
-
60
56
  hasLabelDescription() {
61
57
  // eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
62
58
  return Boolean(this.labelDescription || this.$slots['label-description']);
63
59
  }
64
-
65
60
  }
66
61
  };
67
62
 
@@ -33,7 +33,6 @@ var script = {
33
33
  if (this.size === null) {
34
34
  return [];
35
35
  }
36
-
37
36
  if (_isObject(this.size)) {
38
37
  const {
39
38
  default: defaultSize,
@@ -44,21 +43,18 @@ var script = {
44
43
  return `gl-${breakpoint}-form-input-${size}`;
45
44
  })];
46
45
  }
47
-
48
46
  return [`gl-form-input-${this.size}`];
49
47
  },
50
-
51
48
  listeners() {
52
49
  var _this = this;
53
-
54
- return { ...this.$listeners,
50
+ return {
51
+ ...this.$listeners,
55
52
  // Swap purpose of input and update events from underlying BFormInput.
56
53
  // See https://gitlab.com/gitlab-org/gitlab-ui/-/issues/631.
57
54
  input: function () {
58
55
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
59
56
  args[_key] = arguments[_key];
60
57
  }
61
-
62
58
  /**
63
59
  * Emitted to update the v-model
64
60
  *
@@ -71,7 +67,6 @@ var script = {
71
67
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
72
68
  args[_key2] = arguments[_key2];
73
69
  }
74
-
75
70
  /**
76
71
  * Triggered by user interaction. Emitted after any formatting (not including 'trim' or 'number' props).
77
72
  * Useful for getting the currently entered value when the 'debounce' or 'lazy' props are set.
@@ -83,7 +78,6 @@ var script = {
83
78
  }
84
79
  };
85
80
  }
86
-
87
81
  }
88
82
  };
89
83
 
@@ -24,7 +24,6 @@ var script = {
24
24
  required: false,
25
25
  default: false
26
26
  },
27
-
28
27
  /**
29
28
  * Array of options. Each option should have `name` and `value` information: {name: "Foo", value: "Bar"})
30
29
  */
@@ -48,20 +47,17 @@ var script = {
48
47
  default: ''
49
48
  }
50
49
  },
51
-
52
50
  data() {
53
51
  return {
54
52
  activeOption: this.predefinedOptions && this.predefinedOptions[0].name
55
53
  };
56
54
  },
57
-
58
55
  methods: {
59
56
  handleClick() {
60
57
  if (this.selectOnClick) {
61
58
  this.$refs.input.$el.select();
62
59
  }
63
60
  },
64
-
65
61
  updateValue(option) {
66
62
  const {
67
63
  name,
@@ -70,7 +66,6 @@ var script = {
70
66
  this.activeOption = name;
71
67
  this.localValue = value;
72
68
  }
73
-
74
69
  }
75
70
  };
76
71
 
@@ -5,31 +5,25 @@ const InputGroupMixin = {
5
5
  default: ''
6
6
  }
7
7
  },
8
-
9
8
  data() {
10
9
  return {
11
10
  localValue: this.stringifyValue(this.value)
12
11
  };
13
12
  },
14
-
15
13
  watch: {
16
14
  value(newVal) {
17
15
  if (newVal !== this.localValue) {
18
16
  this.localValue = this.stringifyValue(newVal);
19
17
  }
20
18
  },
21
-
22
19
  localValue(newVal) {
23
20
  if (newVal !== this.value) {
24
21
  this.$emit('input', newVal);
25
22
  }
26
23
  }
27
-
28
24
  },
29
-
30
25
  mounted() {
31
26
  const value = this.stringifyValue(this.value);
32
-
33
27
  if (this.activeOption) {
34
28
  const activeOption = this.predefinedOptions.find(opt => opt.name === this.activeOption);
35
29
  this.localValue = activeOption.value;
@@ -37,12 +31,10 @@ const InputGroupMixin = {
37
31
  this.localValue = value;
38
32
  }
39
33
  },
40
-
41
34
  methods: {
42
35
  stringifyValue(value) {
43
36
  return value === undefined || value === null ? '' : String(value);
44
37
  }
45
-
46
38
  }
47
39
  };
48
40