@gitlab/ui 38.10.1 → 38.10.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [38.10.2](https://gitlab.com/gitlab-org/gitlab-ui/compare/v38.10.1...v38.10.2) (2022-04-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **ChartTooltip:** restore right placement by default ([4dfed07](https://gitlab.com/gitlab-org/gitlab-ui/commit/4dfed07d69cc50b59c950f85cda2fe8ef11b7a03))
7
+
1
8
  ## [38.10.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v38.10.0...v38.10.1) (2022-04-14)
2
9
 
3
10
 
@@ -1,6 +1,7 @@
1
1
  import * as echarts from 'echarts';
2
2
  import { uid } from '../../../utils/utils';
3
3
  import GlPopover from '../../base/popover/popover';
4
+ import { popoverPlacements } from '../../../utils/constants';
4
5
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
5
6
 
6
7
  var script = {
@@ -42,6 +43,11 @@ var script = {
42
43
  type: String,
43
44
  required: false,
44
45
  default: null
46
+ },
47
+ placement: {
48
+ type: String,
49
+ required: false,
50
+ default: popoverPlacements.right
45
51
  }
46
52
  },
47
53
  computed: {
@@ -71,7 +77,7 @@ var script = {
71
77
  const __vue_script__ = script;
72
78
 
73
79
  /* template */
74
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('div',{staticClass:"gl-chart-tooltip",staticStyle:{"width":"1px","height":"1px"},style:(_vm.containerPosition),attrs:{"id":_vm.containerId}}),_vm._v(" "),_c('gl-popover',_vm._b({attrs:{"target":_vm.containerId,"container":_vm.containerId,"triggers":""},scopedSlots:_vm._u([(_vm.$scopedSlots.title)?{key:"title",fn:function(){return [_vm._t("title")]},proxy:true}:null],null,true)},'gl-popover',_vm.$attrs,false),[_vm._v(" "),_vm._t("default")],2)],1)};
80
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('div',{staticClass:"gl-chart-tooltip",staticStyle:{"width":"1px","height":"1px"},style:(_vm.containerPosition),attrs:{"id":_vm.containerId}}),_vm._v(" "),_c('gl-popover',_vm._b({attrs:{"target":_vm.containerId,"container":_vm.containerId,"placement":_vm.placement,"triggers":""},scopedSlots:_vm._u([(_vm.$scopedSlots.title)?{key:"title",fn:function(){return [_vm._t("title")]},proxy:true}:null],null,true)},'gl-popover',_vm.$attrs,false),[_vm._v(" "),_vm._t("default")],2)],1)};
75
81
  var __vue_staticRenderFns__ = [];
76
82
 
77
83
  /* style */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "38.10.1",
3
+ "version": "38.10.2",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,42 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import GlPopover from '../../base/popover/popover.vue';
3
+ import { popoverPlacements } from '../../../utils/constants';
4
+ import ChartTooltip from './tooltip.vue';
5
+ import { createMockChartInstance } from '~helpers/chart_stubs';
6
+
7
+ let mockChartInstance;
8
+
9
+ jest.mock('echarts', () => ({
10
+ getInstanceByDom: () => mockChartInstance,
11
+ }));
12
+
13
+ describe('ChartTooltip', () => {
14
+ let wrapper;
15
+
16
+ const findGlPopover = () => wrapper.findComponent(GlPopover);
17
+
18
+ const createWrapper = (props = {}) => {
19
+ mockChartInstance = createMockChartInstance();
20
+ wrapper = shallowMount(ChartTooltip, {
21
+ propsData: {
22
+ chart: mockChartInstance,
23
+ ...props,
24
+ },
25
+ });
26
+ };
27
+
28
+ describe('GlPopover', () => {
29
+ it('is right-positioned by default', () => {
30
+ createWrapper();
31
+
32
+ expect(findGlPopover().props('placement')).toBe(popoverPlacements.right);
33
+ });
34
+
35
+ it('applies passed placement if any', () => {
36
+ const placement = popoverPlacements.bottom;
37
+ createWrapper({ placement });
38
+
39
+ expect(findGlPopover().props('placement')).toBe(placement);
40
+ });
41
+ });
42
+ });
@@ -2,6 +2,7 @@
2
2
  import * as echarts from 'echarts';
3
3
  import { uid } from '../../../utils/utils';
4
4
  import GlPopover from '../../base/popover/popover.vue';
5
+ import { popoverPlacements } from '../../../utils/constants';
5
6
 
6
7
  export default {
7
8
  components: {
@@ -41,6 +42,11 @@ export default {
41
42
  required: false,
42
43
  default: null,
43
44
  },
45
+ placement: {
46
+ type: String,
47
+ required: false,
48
+ default: popoverPlacements.right,
49
+ },
44
50
  },
45
51
  computed: {
46
52
  containerId() {
@@ -80,7 +86,13 @@ export default {
80
86
  Needs to be triggered programatically using `show` property
81
87
  This is why `triggers` is currently set to an empty string
82
88
  -->
83
- <gl-popover v-bind="$attrs" :target="containerId" :container="containerId" triggers="">
89
+ <gl-popover
90
+ v-bind="$attrs"
91
+ :target="containerId"
92
+ :container="containerId"
93
+ :placement="placement"
94
+ triggers=""
95
+ >
84
96
  <template v-if="$scopedSlots.title" #title>
85
97
  <slot name="title"></slot>
86
98
  </template>