@gitlab/ui 85.4.0 → 85.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [85.5.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v85.4.1...v85.5.0) (2024-06-27)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlTooltip:** Use color design tokens ([d62b0fc](https://gitlab.com/gitlab-org/gitlab-ui/commit/d62b0fcc07ccefc438e289cf84f5f9cbf6963c62))
7
+
8
+ ## [85.4.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v85.4.0...v85.4.1) (2024-06-26)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **GlSparklineChart:** Prevent rendering blank or invalid tooltips ([e462352](https://gitlab.com/gitlab-org/gitlab-ui/commit/e46235217c576aaaed63ca38b30f3fdee3c54a63))
14
+
1
15
  # [85.4.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v85.3.1...v85.4.0) (2024-06-26)
2
16
 
3
17
 
@@ -84,6 +84,7 @@ var script = {
84
84
  return {
85
85
  chartInstance: null,
86
86
  tooltip: {
87
+ show: false,
87
88
  title: '',
88
89
  content: '',
89
90
  position: {
@@ -177,6 +178,8 @@ var script = {
177
178
  methods: {
178
179
  onChartCreated(chartInstance) {
179
180
  this.chartInstance = chartInstance;
181
+ this.tooltip.show = false;
182
+
180
183
  /**
181
184
  * Emitted when the chart is created.
182
185
  * The payload contains the echarts instance.
@@ -188,6 +191,9 @@ var script = {
188
191
  handleResize() {
189
192
  this.chartInstance.resize();
190
193
  },
194
+ isNilOrBlank(text) {
195
+ return isNil(text) || typeof text === 'string' && text.trim() === '';
196
+ },
191
197
  setTooltipPosition(data) {
192
198
  const [left, top] = this.chartInstance.convertToPixel('grid', data);
193
199
  this.tooltip.position = {
@@ -202,6 +208,8 @@ var script = {
202
208
  let {
203
209
  seriesData = []
204
210
  } = _ref;
211
+ this.tooltip.show = false;
212
+
205
213
  // seriesData is an array of nearby data point coordinates
206
214
  // seriesData[0] is the nearest point at which the tooltip is displayed
207
215
  // https://echarts.apache.org/en/option.html#xAxis.axisPointer.label.formatter
@@ -211,10 +219,11 @@ var script = {
211
219
  } = firstEntry;
212
220
  if (!data) return;
213
221
  const [title, content] = data;
214
- if (isNil(title) || isNil(content)) return;
222
+ if (this.isNilOrBlank(title) || this.isNilOrBlank(content)) return;
215
223
  this.tooltip.title = title;
216
224
  this.tooltip.content = content;
217
225
  this.setTooltipPosition(data);
226
+ this.tooltip.show = null;
218
227
  }
219
228
  },
220
229
  HEIGHT_AUTO_HORIZONTAL_LAYOUT_CLASSES
@@ -226,7 +235,7 @@ const __vue_script__ = script;
226
235
  /* template */
227
236
  var __vue_render__ = function () {
228
237
  var _obj;
229
- var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:"resize-observer",rawName:"v-resize-observer",value:(_vm.handleResize),expression:"handleResize"}],staticClass:"gl-display-flex gl-align-items-center",class:{ 'gl-h-full': _vm.autoHeight }},[_vm._t("default"),_vm._v(" "),_c('div',{staticClass:"gl-flex-grow-1 gl-relative",class:( _obj = {}, _obj[_vm.$options.HEIGHT_AUTO_HORIZONTAL_LAYOUT_CLASSES] = _vm.autoHeight, _obj ),attrs:{"data-testid":"chart-container"}},[_c('chart',_vm._g(_vm._b({class:{ 'gl-flex-grow-1': _vm.autoHeight },attrs:{"height":_vm.height,"options":_vm.options},on:{"created":_vm.onChartCreated}},'chart',_vm.$attrs,false),_vm.$listeners)),_vm._v(" "),(_vm.chartInstance)?_c('chart-tooltip',{attrs:{"chart":_vm.chartInstance,"top":_vm.tooltip.position.top,"left":_vm.tooltip.position.left,"placement":"top"},scopedSlots:_vm._u([{key:"title",fn:function(){return [_c('div',{staticClass:"gl-white-space-nowrap",attrs:{"data-testid":"tooltip-title"}},[_vm._v("\n "+_vm._s(_vm.tooltip.title)+"\n ")])]},proxy:true},{key:"default",fn:function(){return [_c('div',{staticClass:"gl-display-flex",attrs:{"data-testid":"tooltip-content"}},[(_vm.tooltipLabel)?_c('span',{staticClass:"gl-pr-6 gl-mr-auto"},[_vm._v(_vm._s(_vm.tooltipLabel))]):_vm._e(),_vm._v(" "),_c('strong',[_vm._v(_vm._s(_vm.tooltip.content))])])]},proxy:true}],null,false,2830367259)}):_vm._e()],1),_vm._v(" "),(_vm.showLastYValue)?_c('span',{staticClass:"gl-display-inline-flex gl-justify-content-center gl-ml-5",attrs:{"data-testid":"last-y-value"}},[_vm._v("\n "+_vm._s(_vm.lastYValue)+"\n ")]):_vm._e()],2)};
238
+ var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:"resize-observer",rawName:"v-resize-observer",value:(_vm.handleResize),expression:"handleResize"}],staticClass:"gl-display-flex gl-align-items-center",class:{ 'gl-h-full': _vm.autoHeight }},[_vm._t("default"),_vm._v(" "),_c('div',{staticClass:"gl-flex-grow-1 gl-relative",class:( _obj = {}, _obj[_vm.$options.HEIGHT_AUTO_HORIZONTAL_LAYOUT_CLASSES] = _vm.autoHeight, _obj ),attrs:{"data-testid":"chart-container"}},[_c('chart',_vm._g(_vm._b({class:{ 'gl-flex-grow-1': _vm.autoHeight },attrs:{"height":_vm.height,"options":_vm.options},on:{"created":_vm.onChartCreated}},'chart',_vm.$attrs,false),_vm.$listeners)),_vm._v(" "),(_vm.chartInstance)?_c('chart-tooltip',{attrs:{"show":_vm.tooltip.show,"chart":_vm.chartInstance,"top":_vm.tooltip.position.top,"left":_vm.tooltip.position.left,"placement":"top"},scopedSlots:_vm._u([{key:"title",fn:function(){return [_c('div',{staticClass:"gl-white-space-nowrap",attrs:{"data-testid":"tooltip-title"}},[_vm._v("\n "+_vm._s(_vm.tooltip.title)+"\n ")])]},proxy:true},{key:"default",fn:function(){return [_c('div',{staticClass:"gl-display-flex",attrs:{"data-testid":"tooltip-content"}},[(_vm.tooltipLabel)?_c('span',{staticClass:"gl-pr-6 gl-mr-auto"},[_vm._v(_vm._s(_vm.tooltipLabel))]):_vm._e(),_vm._v(" "),_c('strong',[_vm._v(_vm._s(_vm.tooltip.content))])])]},proxy:true}],null,false,2830367259)}):_vm._e()],1),_vm._v(" "),(_vm.showLastYValue)?_c('span',{staticClass:"gl-display-inline-flex gl-justify-content-center gl-ml-5",attrs:{"data-testid":"last-y-value"}},[_vm._v("\n "+_vm._s(_vm.lastYValue)+"\n ")]):_vm._e()],2)};
230
239
  var __vue_staticRenderFns__ = [];
231
240
 
232
241
  /* style */