@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
@@ -47,7 +47,6 @@ var script = {
47
47
  default: null
48
48
  }
49
49
  },
50
-
51
50
  data() {
52
51
  return {
53
52
  chart: null,
@@ -62,14 +61,11 @@ var script = {
62
61
  selectedFormatTooltipText: this.formatTooltipText || this.defaultFormatTooltipText
63
62
  };
64
63
  },
65
-
66
64
  computed: {
67
65
  series() {
68
66
  return this.data.map((series, index) => {
69
67
  const defaultColor = colorFromDefaultPalette(index);
70
-
71
68
  const getColor = type => series[type] && series[type].color ? series[type].color : defaultColor;
72
-
73
69
  return merge({
74
70
  symbolSize: this.symbolSize,
75
71
  lineStyle: {
@@ -81,7 +77,6 @@ var script = {
81
77
  }, series);
82
78
  });
83
79
  },
84
-
85
80
  options() {
86
81
  const mergedOptions = merge({}, defaultChartOptions, {
87
82
  tooltip: {
@@ -109,12 +104,11 @@ var script = {
109
104
  legend: {
110
105
  show: false
111
106
  }
112
- }, this.option, dataZoomAdjustments(this.option.dataZoom), this.toolboxAdjustments); // All chart options can be merged but series
107
+ }, this.option, dataZoomAdjustments(this.option.dataZoom), this.toolboxAdjustments);
108
+ // All chart options can be merged but series
113
109
  // needs to be handled specially
114
-
115
110
  return mergeSeriesToOptions(mergedOptions, this.series);
116
111
  }
117
-
118
112
  },
119
113
  methods: {
120
114
  defaultFormatTooltipText(params) {
@@ -132,24 +126,20 @@ var script = {
132
126
  };
133
127
  this.$set(this, 'tooltipContent', tooltipContent);
134
128
  },
135
-
136
129
  showHideTooltip(mouseEvent) {
137
130
  this.showTooltip = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
138
131
  },
139
-
140
132
  onCreated(chart) {
141
133
  chart.getDom().addEventListener('mousemove', this.debouncedShowHideTooltip);
142
134
  chart.getDom().addEventListener('mouseout', this.debouncedShowHideTooltip);
143
135
  this.chart = chart;
144
136
  this.$emit('created', chart);
145
137
  },
146
-
147
138
  onLabelChange(params) {
148
139
  this.selectedFormatTooltipText(params);
149
140
  const {
150
141
  data = []
151
142
  } = params;
152
-
153
143
  if (data.length) {
154
144
  const [left, top] = this.chart.convertToPixel('grid', data);
155
145
  this.tooltipPosition = {
@@ -158,7 +148,6 @@ var script = {
158
148
  };
159
149
  }
160
150
  }
161
-
162
151
  }
163
152
  };
164
153
 
@@ -14,7 +14,6 @@ const DETAIL_FONT_FAMILY = 'sans-serif';
14
14
  const DETAIL_FONT_WEIGHT = 'bold';
15
15
  const POINTER_LENGTH = '65%';
16
16
  const POINTER_WIDTH_PX = 5;
17
-
18
17
  const gaugeChartSeries = _ref => {
19
18
  let {
20
19
  value,
@@ -61,7 +60,6 @@ const gaugeChartSeries = _ref => {
61
60
  splitNumber
62
61
  }];
63
62
  };
64
-
65
63
  var script = {
66
64
  components: {
67
65
  Chart
@@ -118,10 +116,8 @@ var script = {
118
116
  axisColor: this.axisColor
119
117
  })
120
118
  }, this.option, this.toolboxAdjustments);
121
-
122
119
  return mergedOptions;
123
120
  },
124
-
125
121
  validThresholds() {
126
122
  const {
127
123
  thresholds,
@@ -129,23 +125,17 @@ var script = {
129
125
  max
130
126
  } = this;
131
127
  if (!(thresholds !== null && thresholds !== void 0 && thresholds.length)) return [];
132
-
133
128
  const uniqueThresholds = _uniq(thresholds);
134
-
135
129
  const filteredThresholds = uniqueThresholds.filter(threshold => {
136
130
  return _isFinite(threshold) && threshold > min && threshold < max;
137
131
  });
138
132
  /**
139
133
  * Only the first two thresholds will be used
140
134
  */
141
-
142
135
  const reducedThresholdsList = filteredThresholds.length > 2 ? [filteredThresholds[0], filteredThresholds[1]] : [...filteredThresholds];
143
-
144
136
  const sortedThresholds = _sortBy(reducedThresholdsList);
145
-
146
137
  return sortedThresholds;
147
138
  },
148
-
149
139
  valueIsInLastThreshold() {
150
140
  const {
151
141
  validThresholds,
@@ -153,14 +143,12 @@ var script = {
153
143
  } = this;
154
144
  return validThresholds.length > 0 && value >= validThresholds[validThresholds.length - 1];
155
145
  },
156
-
157
146
  axisColor() {
158
147
  const {
159
148
  validThresholds,
160
149
  max
161
150
  } = this;
162
151
  let color;
163
-
164
152
  if (validThresholds.length === 0) {
165
153
  color = [[1, gaugeSafeHues[0]]];
166
154
  } else if (validThresholds.length === 1) {
@@ -172,16 +160,13 @@ var script = {
172
160
  */
173
161
  color = [[validThresholds[0] / max, gaugeSafeHues[0]], [validThresholds[1] / max, gaugeSafeHues[1]], [1, gaugeWarningHue]];
174
162
  }
175
-
176
163
  return color;
177
164
  }
178
-
179
165
  },
180
166
  methods: {
181
167
  onCreated(chart) {
182
168
  this.$emit('created', chart);
183
169
  }
184
-
185
170
  }
186
171
  };
187
172
 
@@ -26,12 +26,12 @@ const defaultOptions = {
26
26
  type: 'heatmap'
27
27
  }
28
28
  };
29
+
29
30
  /*
30
31
  * The series is an array of arrays containing [x, y, value]
31
32
  * x and y are position, value determines the color
32
33
  * We want the min and max from value field to make the range of colors
33
34
  */
34
-
35
35
  function getRange(series) {
36
36
  return series.reduce((acc, curr) => {
37
37
  const value = curr[2] || 0;
@@ -43,7 +43,6 @@ function getRange(series) {
43
43
  max: 0
44
44
  });
45
45
  }
46
-
47
46
  var script = {
48
47
  components: {
49
48
  Chart,
@@ -103,7 +102,6 @@ var script = {
103
102
  default: true
104
103
  }
105
104
  },
106
-
107
105
  data() {
108
106
  return {
109
107
  chart: null,
@@ -118,7 +116,6 @@ var script = {
118
116
  selectedFormatTooltipText: this.formatTooltipText || this.defaultFormatTooltipText
119
117
  };
120
118
  },
121
-
122
119
  computed: {
123
120
  computedOptions() {
124
121
  const {
@@ -193,18 +190,15 @@ var script = {
193
190
  }
194
191
  }, this.toolboxAdjustments, this.options);
195
192
  },
196
-
197
193
  legendStyle() {
198
194
  return {
199
195
  paddingLeft: this.computedOptions.grid.left,
200
196
  marginTop: '-32px'
201
197
  };
202
198
  },
203
-
204
199
  compiledOptions() {
205
200
  return this.chart ? this.chart.getOption() : null;
206
201
  },
207
-
208
202
  seriesInfo() {
209
203
  const {
210
204
  min,
@@ -221,14 +215,11 @@ var script = {
221
215
  };
222
216
  });
223
217
  }
224
-
225
218
  },
226
-
227
219
  beforeDestroy() {
228
220
  this.chart.getDom().removeEventListener('mousemove', this.debouncedShowHideTooltip);
229
221
  this.chart.getDom().removeEventListener('mouseout', this.debouncedShowHideTooltip);
230
222
  },
231
-
232
223
  methods: {
233
224
  defaultFormatTooltipText(params) {
234
225
  const {
@@ -238,24 +229,20 @@ var script = {
238
229
  this.$set(this.tooltip, 'content', tooltipContent);
239
230
  this.tooltip.title = xLabels.join(', ');
240
231
  },
241
-
242
232
  onCreated(chart) {
243
233
  chart.getDom().addEventListener('mousemove', this.debouncedShowHideTooltip);
244
234
  chart.getDom().addEventListener('mouseout', this.debouncedShowHideTooltip);
245
235
  this.chart = chart;
246
236
  this.$emit('created', chart);
247
237
  },
248
-
249
238
  showHideTooltip(mouseEvent) {
250
239
  this.tooltip.show = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
251
240
  },
252
-
253
241
  onLabelChange(params) {
254
242
  this.selectedFormatTooltipText(params);
255
243
  const {
256
244
  seriesData = []
257
245
  } = params;
258
-
259
246
  if (seriesData.length && seriesData[0].value) {
260
247
  const {
261
248
  seriesId,
@@ -264,13 +251,13 @@ var script = {
264
251
  const [left, top] = this.chart.convertToPixel({
265
252
  seriesId
266
253
  }, value);
267
- this.tooltip = { ...this.tooltip,
254
+ this.tooltip = {
255
+ ...this.tooltip,
268
256
  left: `${left + TOOLTIP_LEFT_OFFSET}px`,
269
257
  top: `${top}px`
270
258
  };
271
259
  }
272
260
  }
273
-
274
261
  }
275
262
  };
276
263
 
@@ -18,27 +18,22 @@ var script = {
18
18
  chart: {
19
19
  type: Object,
20
20
  required: true,
21
-
22
21
  validator(chart) {
23
22
  return Object.is(chart, echarts.getInstanceByDom(chart.getDom()));
24
23
  }
25
-
26
24
  },
27
25
  seriesInfo: {
28
26
  type: Array,
29
27
  required: true,
30
-
31
28
  validator(seriesInfo) {
32
29
  return seriesInfo.every(series => series.type && series.name && series.color);
33
30
  }
34
-
35
31
  },
36
32
  textStyle: {
37
33
  type: Object,
38
34
  required: false,
39
35
  default: () => ({})
40
36
  },
41
-
42
37
  /**
43
38
  * Text for data average (overridden by prop if needed for internationalization)
44
39
  */
@@ -57,7 +52,6 @@ var script = {
57
52
  required: false,
58
53
  default: LEGEND_MIN_TEXT
59
54
  },
60
-
61
55
  /**
62
56
  * Text for max amount (overridden by prop if needed for internationalization)
63
57
  */
@@ -66,7 +60,6 @@ var script = {
66
60
  required: false,
67
61
  default: LEGEND_MAX_TEXT
68
62
  },
69
-
70
63
  /**
71
64
  * Sets the display layout
72
65
  */
@@ -74,20 +67,16 @@ var script = {
74
67
  type: String,
75
68
  required: false,
76
69
  default: LEGEND_LAYOUT_INLINE,
77
-
78
70
  validator(layout) {
79
71
  return [LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE].indexOf(layout) !== -1;
80
72
  }
81
-
82
73
  }
83
74
  },
84
-
85
75
  data() {
86
76
  return {
87
77
  disabledSeries: {}
88
78
  };
89
79
  },
90
-
91
80
  computed: {
92
81
  fontStyle() {
93
82
  return {
@@ -95,67 +84,56 @@ var script = {
95
84
  fontSize: `${this.textStyle.fontSize || defaultFontSize}px`
96
85
  };
97
86
  }
98
-
99
87
  },
100
88
  methods: {
101
89
  sanitizeSeriesData(seriesData) {
102
90
  var _seriesData$filter;
103
-
104
91
  return (_seriesData$filter = seriesData === null || seriesData === void 0 ? void 0 : seriesData.filter(d => !Number.isNaN(d))) !== null && _seriesData$filter !== void 0 ? _seriesData$filter : [];
105
92
  },
106
-
107
93
  seriesAverage(seriesData) {
108
94
  const sanitized = this.sanitizeSeriesData(seriesData);
109
95
  return engineeringNotation(average(...sanitized));
110
96
  },
111
-
112
97
  seriesMax(seriesData) {
113
98
  const sanitized = this.sanitizeSeriesData(seriesData);
114
99
  return engineeringNotation(Math.max(...sanitized));
115
100
  },
116
-
117
101
  seriesMin(seriesData) {
118
102
  const sanitized = this.sanitizeSeriesData(seriesData);
119
103
  return engineeringNotation(Math.min(...sanitized));
120
104
  },
121
-
122
105
  seriesLast(seriesData) {
123
106
  const sanitized = this.sanitizeSeriesData(seriesData);
124
107
  return engineeringNotation(sanitized[sanitized.length - 1]);
125
108
  },
126
-
127
109
  seriesNameIsLong(seriesName) {
128
110
  return seriesName.length > 120;
129
111
  },
130
-
131
112
  handleClick(name, key) {
132
113
  this.chart.dispatchAction({
133
114
  type: 'legendToggleSelect',
134
115
  name
135
116
  });
136
- this.disabledSeries = { ...this.disabledSeries,
117
+ this.disabledSeries = {
118
+ ...this.disabledSeries,
137
119
  [key]: !this.disabledSeries[key]
138
120
  };
139
121
  },
140
-
141
122
  handleMouseEnter(name) {
142
123
  this.chart.dispatchAction({
143
124
  type: 'highlight',
144
125
  seriesName: name
145
126
  });
146
127
  },
147
-
148
128
  handleMouseLeave(name) {
149
129
  this.chart.dispatchAction({
150
130
  type: 'downplay',
151
131
  seriesName: name
152
132
  });
153
133
  },
154
-
155
134
  getColor(color, key) {
156
135
  return this.disabledSeries[key] ? gray200 : color;
157
136
  }
158
-
159
137
  },
160
138
  legendLayoutTypes: {
161
139
  LEGEND_LAYOUT_INLINE,
@@ -77,11 +77,9 @@ var script = {
77
77
  type: String,
78
78
  required: false,
79
79
  default: LEGEND_LAYOUT_INLINE,
80
-
81
80
  validator(layout) {
82
81
  return [LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE].indexOf(layout) !== -1;
83
82
  }
84
-
85
83
  },
86
84
  showLegend: {
87
85
  type: Boolean,
@@ -89,7 +87,6 @@ var script = {
89
87
  default: true
90
88
  }
91
89
  },
92
-
93
90
  data() {
94
91
  // Part of the tooltip related data can be
95
92
  // moved into the tooltip component.
@@ -115,18 +112,14 @@ var script = {
115
112
  selectedFormatTooltipText: this.formatTooltipText || this.defaultFormatTooltipText
116
113
  };
117
114
  },
118
-
119
115
  computed: {
120
116
  series() {
121
117
  const dataSeries = this.data.map((series, index) => {
122
118
  const defaultColor = colorFromDefaultPalette(index);
123
-
124
119
  const getColor = type => {
125
120
  var _series$type$color, _series$type;
126
-
127
121
  return (_series$type$color = (_series$type = series[type]) === null || _series$type === void 0 ? void 0 : _series$type.color) !== null && _series$type$color !== void 0 ? _series$type$color : defaultColor;
128
122
  };
129
-
130
123
  return merge({
131
124
  showSymbol: true,
132
125
  lineStyle: {
@@ -136,20 +129,17 @@ var script = {
136
129
  color: getColor('itemStyle')
137
130
  }
138
131
  }, symbolSize, lineStyle, series, getThresholdConfig(this.thresholds));
139
- }); // if annotation series exists, append it
132
+ });
133
+ // if annotation series exists, append it
140
134
  // along with data series
141
-
142
135
  if (this.annotationSeries) {
143
136
  return [...dataSeries, this.annotationSeries];
144
137
  }
145
-
146
138
  return dataSeries;
147
139
  },
148
-
149
140
  annotationSeries() {
150
141
  return generateAnnotationSeries(this.annotations);
151
142
  },
152
-
153
143
  options() {
154
144
  const defaultLineChartOptions = {
155
145
  xAxis: {
@@ -171,12 +161,11 @@ var script = {
171
161
  show: false
172
162
  }
173
163
  };
174
- const mergedOptions = merge({}, defaultChartOptions, defaultLineChartOptions, this.option, dataZoomAdjustments(this.option.dataZoom), this.toolboxAdjustments); // All chart options can be merged but series
164
+ const mergedOptions = merge({}, defaultChartOptions, defaultLineChartOptions, this.option, dataZoomAdjustments(this.option.dataZoom), this.toolboxAdjustments);
165
+ // All chart options can be merged but series
175
166
  // needs to be handled specially
176
-
177
167
  return mergeSeriesToOptions(mergeAnnotationAxisToOptions(mergedOptions, this.hasAnnotations), this.series);
178
168
  },
179
-
180
169
  /**
181
170
  * Annotations currently are passed as series options in monitoring dashboard.
182
171
  * Once https://gitlab.com/gitlab-org/gitlab/-/issues/213390 is closed,
@@ -187,25 +176,20 @@ var script = {
187
176
  hasAnnotations() {
188
177
  return this.annotations.length !== 0 || seriesHasAnnotations(this.option.series);
189
178
  },
190
-
191
179
  shouldShowAnnotationsTooltip() {
192
180
  return this.chart && this.hasAnnotations;
193
181
  },
194
-
195
182
  compiledOptions() {
196
183
  return this.chart ? this.chart.getOption() : null;
197
184
  },
198
-
199
185
  legendStyle() {
200
186
  return {
201
187
  paddingLeft: `${grid.left}px`
202
188
  };
203
189
  },
204
-
205
190
  hasLegend() {
206
191
  return this.compiledOptions && this.showLegend;
207
192
  },
208
-
209
193
  seriesInfo() {
210
194
  return this.compiledOptions.series.reduce((acc, series, index) => {
211
195
  if (series.type === 'line') {
@@ -216,20 +200,16 @@ var script = {
216
200
  data: this.includeLegendAvgMax ? series.data.map(data => data[1]) : undefined
217
201
  });
218
202
  }
219
-
220
203
  return acc;
221
204
  }, []);
222
205
  }
223
-
224
206
  },
225
-
226
207
  beforeDestroy() {
227
208
  this.chart.getDom().removeEventListener('mousemove', this.debouncedShowHideTooltip);
228
209
  this.chart.getDom().removeEventListener('mouseout', this.debouncedShowHideTooltip);
229
210
  this.chart.off('mouseout', this.onChartDataPointMouseOut);
230
211
  this.chart.off('mouseover', this.onChartDataPointMouseOver);
231
212
  },
232
-
233
213
  methods: {
234
214
  defaultFormatTooltipText(params) {
235
215
  const {
@@ -239,26 +219,26 @@ var script = {
239
219
  this.$set(this, 'dataTooltipContent', tooltipContent);
240
220
  this.dataTooltipTitle = xLabels.join(', ');
241
221
  },
242
-
243
222
  defaultAnnotationTooltipText(params) {
244
223
  var _params$data$tooltipD;
245
-
246
224
  return {
247
225
  title: params.data.xAxis,
248
226
  content: (_params$data$tooltipD = params.data.tooltipData) === null || _params$data$tooltipD === void 0 ? void 0 : _params$data$tooltipD.content
249
227
  };
250
228
  },
251
-
252
229
  onCreated(chart) {
253
230
  // These listeners are used to show/hide data tooltips
254
231
  // when the mouse is hovered over the parent container
255
232
  // of echarts' svg element. This works only for data points
256
233
  // and not markPoints.
257
234
  chart.getDom().addEventListener('mousemove', this.debouncedShowHideTooltip);
258
- chart.getDom().addEventListener('mouseout', this.debouncedShowHideTooltip); // eCharts inbuild mouse events
235
+ chart.getDom().addEventListener('mouseout', this.debouncedShowHideTooltip);
236
+
237
+ // eCharts inbuild mouse events
259
238
  // https://echarts.apache.org/en/api.html#events.Mouse%20events
260
239
  // is used to attach listeners to markPoints. These listeners
261
240
  // are currently used for annotation arrows at the bottom of the chart.
241
+
262
242
  // Because data points and annotations arrows are in different
263
243
  // sections of the charts with their own mouseovers and mouseouts,
264
244
  // there shouldn't be an overlapping situation where both tooltips
@@ -268,11 +248,9 @@ var script = {
268
248
  chart.on('mouseout', this.onChartDataPointMouseOut);
269
249
  chart.on('mouseover', this.onChartDataPointMouseOver);
270
250
  }
271
-
272
251
  this.chart = chart;
273
252
  this.$emit('created', chart);
274
253
  },
275
-
276
254
  showHideTooltip(mouseEvent) {
277
255
  this.showDataTooltip = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
278
256
  this.dataTooltipPosition = {
@@ -280,11 +258,9 @@ var script = {
280
258
  top: `${mouseEvent.zrY}px`
281
259
  };
282
260
  },
283
-
284
261
  onChartDataPointMouseOut() {
285
262
  this.showAnnotationsTooltip = false;
286
263
  },
287
-
288
264
  /**
289
265
  * Check if the hovered data point is an annotation
290
266
  * point to show the annotation tooltip.
@@ -308,11 +284,9 @@ var script = {
308
284
  };
309
285
  }
310
286
  },
311
-
312
287
  onLabelChange(params) {
313
288
  this.selectedFormatTooltipText(params);
314
289
  }
315
-
316
290
  }
317
291
  };
318
292
 
@@ -1,7 +1,6 @@
1
1
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
2
2
 
3
3
  const makePathRect = (startX, startY, width, height) => `M${startX},${startY}H${startX + width}V${startY + height}H${startX}Z`;
4
-
5
4
  var script = {
6
5
  props: {
7
6
  color: {
@@ -14,28 +13,23 @@ var script = {
14
13
  default: 'solid'
15
14
  }
16
15
  },
17
-
18
16
  data() {
19
17
  return {
20
18
  labelLineHeight: 0
21
19
  };
22
20
  },
23
-
24
21
  computed: {
25
22
  pathContent() {
26
23
  const width = this.$options.svgWidth;
27
24
  const height = this.$options.svgHeight;
28
-
29
25
  if (this.type === 'dashed') {
30
26
  const dashWidth = Math.ceil(width / 3);
31
27
  const firstDash = makePathRect(0, 0, dashWidth, height);
32
28
  const secondDash = makePathRect(width - dashWidth, 0, dashWidth, height);
33
29
  return `${firstDash}${secondDash}`;
34
30
  }
35
-
36
31
  return makePathRect(0, 0, width, height);
37
32
  },
38
-
39
33
  svgStyles() {
40
34
  return {
41
35
  fill: this.color,
@@ -43,30 +37,24 @@ var script = {
43
37
  width: 'auto'
44
38
  };
45
39
  },
46
-
47
40
  svgYTranslationValue() {
48
41
  const value = this.labelLineHeight / 2 - this.$options.svgHeight / 2;
49
42
  return Math.round(value) || 0;
50
43
  }
51
-
52
44
  },
53
-
54
45
  mounted() {
55
46
  if (getComputedStyle && this.$refs.label) {
56
47
  const computedStyle = getComputedStyle(this.$refs.label);
57
48
  const lineHeight = computedStyle['line-height'].match(/(\d+)px/);
58
-
59
49
  if (lineHeight !== null) {
60
50
  this.labelLineHeight = parseFloat(lineHeight[1]);
61
51
  }
62
52
  }
63
53
  },
64
-
65
54
  methods: {
66
55
  formatPixelDimension(dimension) {
67
56
  return `${dimension}px`;
68
57
  }
69
-
70
58
  },
71
59
  svgWidth: 16,
72
60
  svgHeight: 4
@@ -56,40 +56,32 @@ var script = {
56
56
  default: 0
57
57
  }
58
58
  },
59
-
60
59
  data() {
61
60
  return {
62
61
  hideUnits: false
63
62
  };
64
63
  },
65
-
66
64
  computed: {
67
65
  showMetaIcon() {
68
66
  return Boolean(this.metaIcon && !this.metaText);
69
67
  },
70
-
71
68
  showBadge() {
72
69
  return Boolean(this.metaText);
73
70
  },
74
-
75
71
  showTitleIcon() {
76
72
  return Boolean(this.titleIcon);
77
73
  },
78
-
79
74
  textColor() {
80
75
  return variantCssColorMap[this.variant];
81
76
  },
82
-
83
77
  canAnimate() {
84
78
  return this.shouldAnimate && !Number.isNaN(Number(this.value));
85
79
  }
86
-
87
80
  },
88
81
  methods: {
89
82
  setHideUnits(flag) {
90
83
  this.hideUnits = flag;
91
84
  }
92
-
93
85
  }
94
86
  };
95
87