@gitlab/ui 68.8.0 → 69.1.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/components/charts/area/area.js +3 -30
  3. package/dist/components/charts/bar/bar.js +2 -2
  4. package/dist/components/charts/column/column.js +2 -2
  5. package/dist/components/charts/discrete_scatter/discrete_scatter.js +1 -0
  6. package/dist/components/charts/heatmap/heatmap.js +2 -2
  7. package/dist/components/charts/line/line.js +3 -3
  8. package/dist/components/charts/stacked_column/stacked_column.js +2 -2
  9. package/dist/components/charts/tooltip/tooltip.js +121 -12
  10. package/dist/tokens/css/tokens.css +1 -1
  11. package/dist/tokens/css/tokens.dark.css +1 -1
  12. package/dist/tokens/js/tokens.dark.js +1 -1
  13. package/dist/tokens/js/tokens.js +1 -1
  14. package/dist/tokens/scss/_tokens.dark.scss +1 -1
  15. package/dist/tokens/scss/_tokens.scss +1 -1
  16. package/dist/utility_classes.css +1 -1
  17. package/dist/utility_classes.css.map +1 -1
  18. package/dist/utils/charts/constants.js +4 -12
  19. package/package.json +2 -2
  20. package/src/components/charts/area/area.spec.js +2 -19
  21. package/src/components/charts/area/area.vue +3 -40
  22. package/src/components/charts/bar/bar.vue +2 -2
  23. package/src/components/charts/column/column.vue +2 -6
  24. package/src/components/charts/discrete_scatter/discrete_scatter.vue +1 -0
  25. package/src/components/charts/heatmap/heatmap.spec.js +1 -2
  26. package/src/components/charts/heatmap/heatmap.vue +2 -2
  27. package/src/components/charts/line/line.vue +2 -4
  28. package/src/components/charts/sparkline/sparkline.spec.js +6 -6
  29. package/src/components/charts/stacked_column/stacked_column.vue +1 -2
  30. package/src/components/charts/tooltip/tooltip.spec.js +158 -11
  31. package/src/components/charts/tooltip/tooltip.vue +117 -23
  32. package/src/scss/utilities.scss +90 -46
  33. package/src/scss/utility-mixins/flex.scss +6 -14
  34. package/src/scss/utility-mixins/sizing.scss +24 -7
  35. package/src/scss/utility-mixins/spacing.scss +18 -8
  36. package/src/utils/charts/constants.js +3 -11
@@ -1,9 +1,10 @@
1
1
  <!-- eslint-disable vue/multi-word-component-names -->
2
2
  <script>
3
3
  import * as echarts from 'echarts';
4
- import { uid } from '../../../utils/utils';
4
+ import { uid, debounceByAnimationFrame } from '../../../utils/utils';
5
5
  import GlPopover from '../../base/popover/popover.vue';
6
6
  import { popoverPlacements } from '../../../utils/constants';
7
+ import { TOOLTIP_LEFT_OFFSET, TOOLTIP_TOP_OFFSET } from '../../../utils/charts/constants';
7
8
 
8
9
  export default {
9
10
  name: 'GlChartTooltip',
@@ -24,74 +25,167 @@ export default {
24
25
  required: false,
25
26
  default: () => uid(),
26
27
  },
28
+ /**
29
+ * Position of the popover respective to the chart.
30
+ * Sets the `top` style property.
31
+ */
27
32
  top: {
28
33
  type: String,
29
34
  required: false,
30
35
  default: null,
31
36
  },
37
+ /**
38
+ * Position of the popover respective to the chart.
39
+ * Sets the `bottom` style property.
40
+ */
32
41
  bottom: {
33
42
  type: String,
34
43
  required: false,
35
44
  default: null,
36
45
  },
46
+ /**
47
+ * Position of the popover respective to the chart.
48
+ * Sets the `left` style property.
49
+ */
37
50
  left: {
38
51
  type: String,
39
52
  required: false,
40
53
  default: null,
41
54
  },
55
+ /**
56
+ * Position of the popover respective to the chart.
57
+ * Sets the `right` style property.
58
+ */
42
59
  right: {
43
60
  type: String,
44
61
  required: false,
45
62
  default: null,
46
63
  },
64
+ /**
65
+ * Set to `true` to show, set to `false` to not show.
66
+ * Set to `null` to show only when the mouse is in the chart.
67
+ */
68
+ show: {
69
+ type: Boolean,
70
+ required: false,
71
+ default: null,
72
+ },
73
+ /**
74
+ * Popover placement
75
+ */
47
76
  placement: {
48
77
  type: String,
49
78
  required: false,
50
79
  default: popoverPlacements.right,
51
80
  },
81
+ /**
82
+ * Distance between the popover and the pointer when
83
+ * no position is defined
84
+ */
85
+ xOffset: {
86
+ type: Number,
87
+ required: false,
88
+ default: TOOLTIP_LEFT_OFFSET,
89
+ validator(value) {
90
+ // popover target must have a size of at least 1
91
+ return value >= 1;
92
+ },
93
+ },
94
+ /**
95
+ * Distance between the popover and the pointer when
96
+ * no position is defined
97
+ */
98
+ yOffset: {
99
+ type: Number,
100
+ required: false,
101
+ default: TOOLTIP_TOP_OFFSET,
102
+ validator(value) {
103
+ // popover target must have a size of at least 1
104
+ return value >= 1;
105
+ },
106
+ },
107
+ },
108
+ data() {
109
+ return {
110
+ pointerPosition: null,
111
+ isPointerInChart: false,
112
+
113
+ debouncedMouseHandler: debounceByAnimationFrame(this.mouseHandler),
114
+ };
52
115
  },
53
116
  computed: {
54
- containerId() {
117
+ targetId() {
55
118
  // if multiple tooltips are used in a chart component,
56
119
  // `this.id` can be used to uniquely identify them
57
120
  return `${this.chart.getDom().getAttribute('_echarts_instance_')}-tooltip-${this.id}`;
58
121
  },
59
- containerPosition() {
60
- const props = ['top', 'bottom', 'left', 'right'];
122
+ targetStyle() {
123
+ // the target is a rectangular space between cursor and popover
124
+ return {
125
+ marginTop: `${-this.yOffset}px`,
126
+ height: `${this.yOffset * 2}px`,
127
+
128
+ marginLeft: `${-this.xOffset}px`,
129
+ width: `${this.xOffset * 2}px`,
130
+ };
131
+ },
132
+ fixedPosition() {
133
+ const { top, left, bottom, right } = this;
134
+ if (top || left || bottom || right) {
135
+ return { top, left, bottom, right };
136
+ }
137
+ return null;
138
+ },
139
+ shouldShowPopover() {
140
+ if (this.show !== null) {
141
+ return this.show;
142
+ }
143
+ return this.isPointerInChart;
144
+ },
145
+ },
146
+ created() {
147
+ this.chart.getZr().on('mousemove', this.debouncedMouseHandler);
148
+ this.chart.getZr().on('mouseout', this.debouncedMouseHandler);
149
+ },
150
+ beforeDestroy() {
151
+ this.chart.getZr().off('mousemove', this.debouncedMouseHandler);
152
+ this.chart.getZr().off('mouseout', this.debouncedMouseHandler);
153
+ },
154
+ methods: {
155
+ mouseHandler(event) {
156
+ let { zrX: x, zrY: y } = event.event;
61
157
 
62
- return props.reduce((accumulator, prop) => {
63
- const position = this[prop];
64
- if (position) {
65
- accumulator[prop] = position;
66
- }
158
+ if (Number.isFinite(x) && Number.isFinite(y)) {
159
+ x = Math.round(x);
160
+ y = Math.round(y);
67
161
 
68
- return accumulator;
69
- }, {});
162
+ this.pointerPosition = {
163
+ left: `${x}px`,
164
+ top: `${y}px`,
165
+ };
166
+ this.isPointerInChart = this.chart.containPixel('grid', [x, y]);
167
+ }
70
168
  },
71
169
  },
72
170
  };
73
171
  </script>
74
172
 
75
173
  <template>
76
- <div>
77
- <!--
78
- Width and height need to be greater than 0px for the
79
- popover component to render within the following container
80
- -->
174
+ <div v-if="chart" class="gl-pointer-events-none">
81
175
  <div
82
- :id="containerId"
83
- :style="containerPosition"
84
- style="width: 1px; height: 1px"
176
+ :id="targetId"
177
+ :style="{ ...(fixedPosition || pointerPosition), ...targetStyle }"
85
178
  class="gl-chart-tooltip"
86
179
  ></div>
87
180
  <!--
88
- Needs to be triggered programatically using `show` property
89
- This is why `triggers` is currently set to an empty string
181
+ Is shown using `show` property directly so
182
+ `triggers` are set to an empty string
90
183
  -->
91
184
  <gl-popover
92
185
  v-bind="$attrs"
93
- :target="containerId"
94
- :container="containerId"
186
+ :show="shouldShowPopover"
187
+ :target="targetId"
188
+ :container="targetId"
95
189
  :placement="placement"
96
190
  triggers=""
97
191
  >
@@ -3530,18 +3530,6 @@ $gl-animate-skeleton-loader-max-width: 64 * $grid-size;
3530
3530
  flex-direction: column !important;
3531
3531
  }
3532
3532
 
3533
- .gl-sm-flex-direction-column {
3534
- @include gl-media-breakpoint-down(md) {
3535
- flex-direction: column;
3536
- }
3537
- }
3538
-
3539
- .gl-sm-flex-direction-column\! {
3540
- @include gl-media-breakpoint-down(md) {
3541
- flex-direction: column !important;
3542
- }
3543
- }
3544
-
3545
3533
  .gl-md-flex-direction-column {
3546
3534
  @include gl-media-breakpoint-up(md) {
3547
3535
  flex-direction: column;
@@ -3566,18 +3554,6 @@ $gl-animate-skeleton-loader-max-width: 64 * $grid-size;
3566
3554
  }
3567
3555
  }
3568
3556
 
3569
- .gl-xs-flex-direction-column {
3570
- @include gl-media-breakpoint-down(sm) {
3571
- flex-direction: column;
3572
- }
3573
- }
3574
-
3575
- .gl-xs-flex-direction-column\! {
3576
- @include gl-media-breakpoint-down(sm) {
3577
- flex-direction: column !important;
3578
- }
3579
- }
3580
-
3581
3557
  .gl-flex-direction-column-reverse {
3582
3558
  flex-direction: column-reverse;
3583
3559
  }
@@ -3650,6 +3626,18 @@ $gl-animate-skeleton-loader-max-width: 64 * $grid-size;
3650
3626
  flex-direction: row-reverse !important;
3651
3627
  }
3652
3628
 
3629
+ .gl-sm-flex-direction-row-reverse {
3630
+ @include gl-media-breakpoint-up(sm) {
3631
+ flex-direction: row-reverse;
3632
+ }
3633
+ }
3634
+
3635
+ .gl-sm-flex-direction-row-reverse\! {
3636
+ @include gl-media-breakpoint-up(sm) {
3637
+ flex-direction: row-reverse !important;
3638
+ }
3639
+ }
3640
+
3653
3641
  .gl-flex-shrink-0 {
3654
3642
  flex-shrink: 0;
3655
3643
  }
@@ -4911,18 +4899,6 @@ $gl-animate-skeleton-loader-max-width: 64 * $grid-size;
4911
4899
  width: $grid-size * 40 !important;
4912
4900
  }
4913
4901
 
4914
- .gl-xs-w-full {
4915
- @include gl-media-breakpoint-down(sm) {
4916
- width: 100%;
4917
- }
4918
- }
4919
-
4920
- .gl-xs-w-full\! {
4921
- @include gl-media-breakpoint-down(sm) {
4922
- width: 100% !important;
4923
- }
4924
- }
4925
-
4926
4902
  .gl-sm-w-full {
4927
4903
  @include gl-media-breakpoint-up(sm) {
4928
4904
  width: 100%;
@@ -5127,6 +5103,54 @@ $gl-animate-skeleton-loader-max-width: 64 * $grid-size;
5127
5103
  }
5128
5104
  }
5129
5105
 
5106
+ .gl-sm-w-25p {
5107
+ @include gl-media-breakpoint-up(sm) {
5108
+ width: 25%;
5109
+ }
5110
+ }
5111
+
5112
+ .gl-sm-w-25p\! {
5113
+ @include gl-media-breakpoint-up(sm) {
5114
+ width: 25% !important;
5115
+ }
5116
+ }
5117
+
5118
+ .gl-sm-w-30p {
5119
+ @include gl-media-breakpoint-up(sm) {
5120
+ width: 30%;
5121
+ }
5122
+ }
5123
+
5124
+ .gl-sm-w-30p\! {
5125
+ @include gl-media-breakpoint-up(sm) {
5126
+ width: 30% !important;
5127
+ }
5128
+ }
5129
+
5130
+ .gl-sm-w-40p {
5131
+ @include gl-media-breakpoint-up(sm) {
5132
+ width: 40%;
5133
+ }
5134
+ }
5135
+
5136
+ .gl-sm-w-40p\! {
5137
+ @include gl-media-breakpoint-up(sm) {
5138
+ width: 40% !important;
5139
+ }
5140
+ }
5141
+
5142
+ .gl-sm-w-75p {
5143
+ @include gl-media-breakpoint-up(sm) {
5144
+ width: 75%;
5145
+ }
5146
+ }
5147
+
5148
+ .gl-sm-w-75p\! {
5149
+ @include gl-media-breakpoint-up(sm) {
5150
+ width: 75% !important;
5151
+ }
5152
+ }
5153
+
5130
5154
  .gl-md-w-15 {
5131
5155
  @include gl-media-breakpoint-up(md) {
5132
5156
  width: $gl-spacing-scale-15;
@@ -7102,16 +7126,6 @@ $gl-animate-skeleton-loader-max-width: 64 * $grid-size;
7102
7126
  .gl-row-gap-7\! {
7103
7127
  row-gap: $gl-spacing-scale-7 !important;
7104
7128
  }
7105
- .gl-xs-mb-3 {
7106
- @include gl-media-breakpoint-down(sm) {
7107
- margin-bottom: $gl-spacing-scale-3;
7108
- }
7109
- }
7110
- .gl-xs-mb-3\! {
7111
- @include gl-media-breakpoint-down(sm) {
7112
- margin-bottom: $gl-spacing-scale-3 !important;
7113
- }
7114
- }
7115
7129
  .gl-sm-ml-3 {
7116
7130
  @include gl-media-breakpoint-up(sm) {
7117
7131
  margin-left: $gl-spacing-scale-3;
@@ -7142,6 +7156,16 @@ $gl-animate-skeleton-loader-max-width: 64 * $grid-size;
7142
7156
  margin-left: $gl-spacing-scale-7 !important;
7143
7157
  }
7144
7158
  }
7159
+ .gl-sm-mr-0 {
7160
+ @include gl-media-breakpoint-up(sm) {
7161
+ margin-right: 0;
7162
+ }
7163
+ }
7164
+ .gl-sm-mr-0\! {
7165
+ @include gl-media-breakpoint-up(sm) {
7166
+ margin-right: 0 !important;
7167
+ }
7168
+ }
7145
7169
  .gl-sm-mt-0 {
7146
7170
  @include gl-media-breakpoint-up(sm) {
7147
7171
  margin-top: 0;
@@ -7172,6 +7196,16 @@ $gl-animate-skeleton-loader-max-width: 64 * $grid-size;
7172
7196
  margin-top: $gl-spacing-scale-6 !important;
7173
7197
  }
7174
7198
  }
7199
+ .gl-sm-mb-0 {
7200
+ @include gl-media-breakpoint-up(sm) {
7201
+ margin-bottom: 0;
7202
+ }
7203
+ }
7204
+ .gl-sm-mb-0\! {
7205
+ @include gl-media-breakpoint-up(sm) {
7206
+ margin-bottom: 0 !important;
7207
+ }
7208
+ }
7175
7209
  .gl-sm-mb-7 {
7176
7210
  @include gl-media-breakpoint-up(sm) {
7177
7211
  margin-bottom: $gl-spacing-scale-7;
@@ -7316,6 +7350,16 @@ $gl-animate-skeleton-loader-max-width: 64 * $grid-size;
7316
7350
  margin-left: $gl-spacing-scale-3 !important;
7317
7351
  }
7318
7352
  }
7353
+ .gl-md-mr-0 {
7354
+ @include gl-media-breakpoint-up(md) {
7355
+ margin-right: 0;
7356
+ }
7357
+ }
7358
+ .gl-md-mr-0\! {
7359
+ @include gl-media-breakpoint-up(md) {
7360
+ margin-right: 0 !important;
7361
+ }
7362
+ }
7319
7363
  .gl-md-mr-3 {
7320
7364
  @include gl-media-breakpoint-up(md) {
7321
7365
  margin-right: $gl-spacing-scale-3;
@@ -117,13 +117,6 @@
117
117
  flex-direction: column;
118
118
  }
119
119
 
120
- @mixin gl-sm-flex-direction-column {
121
- // stylelint-disable-next-line @gitlab/no-gl-media-breakpoint-down
122
- @include gl-media-breakpoint-down(md) {
123
- @include gl-flex-direction-column;
124
- }
125
- }
126
-
127
120
  @mixin gl-md-flex-direction-column {
128
121
  @include gl-media-breakpoint-up(md) {
129
122
  @include gl-flex-direction-column;
@@ -136,13 +129,6 @@
136
129
  }
137
130
  }
138
131
 
139
- @mixin gl-xs-flex-direction-column {
140
- // stylelint-disable-next-line @gitlab/no-gl-media-breakpoint-down
141
- @include gl-media-breakpoint-down(sm) {
142
- flex-direction: column;
143
- }
144
- }
145
-
146
132
  @mixin gl-flex-direction-column-reverse {
147
133
  flex-direction: column-reverse;
148
134
  }
@@ -179,6 +165,12 @@
179
165
  flex-direction: row-reverse;
180
166
  }
181
167
 
168
+ @mixin gl-sm-flex-direction-row-reverse {
169
+ @include gl-media-breakpoint-up(sm) {
170
+ flex-direction: row-reverse;
171
+ }
172
+ }
173
+
182
174
  @mixin gl-flex-shrink-0 {
183
175
  flex-shrink: 0;
184
176
  }
@@ -138,13 +138,6 @@
138
138
  width: $grid-size * 40;
139
139
  }
140
140
 
141
- @mixin gl-xs-w-full {
142
- // stylelint-disable-next-line @gitlab/no-gl-media-breakpoint-down
143
- @include gl-media-breakpoint-down(sm) {
144
- @include gl-w-full;
145
- }
146
- }
147
-
148
141
  @mixin gl-sm-w-full {
149
142
  @include gl-media-breakpoint-up(sm) {
150
143
  @include gl-w-full;
@@ -255,6 +248,30 @@
255
248
  }
256
249
  }
257
250
 
251
+ @mixin gl-sm-w-25p {
252
+ @include gl-media-breakpoint-up(sm) {
253
+ width: 25%;
254
+ }
255
+ }
256
+
257
+ @mixin gl-sm-w-30p {
258
+ @include gl-media-breakpoint-up(sm) {
259
+ width: 30%;
260
+ }
261
+ }
262
+
263
+ @mixin gl-sm-w-40p {
264
+ @include gl-media-breakpoint-up(sm) {
265
+ width: 40%;
266
+ }
267
+ }
268
+
269
+ @mixin gl-sm-w-75p {
270
+ @include gl-media-breakpoint-up(sm) {
271
+ width: 75%;
272
+ }
273
+ }
274
+
258
275
  @mixin gl-md-w-15 {
259
276
  @include gl-media-breakpoint-up(md) {
260
277
  @include gl-w-15;
@@ -981,14 +981,6 @@
981
981
  * notes:
982
982
  * - Utilities should strictly follow $gl-spacing-scale
983
983
  */
984
-
985
- @mixin gl-xs-mb-3 {
986
- // stylelint-disable-next-line @gitlab/no-gl-media-breakpoint-down
987
- @include gl-media-breakpoint-down(sm) {
988
- @include gl-mb-3;
989
- }
990
- }
991
-
992
984
  @mixin gl-sm-ml-3 {
993
985
  @include gl-media-breakpoint-up(sm) {
994
986
  @include gl-ml-3;
@@ -1007,6 +999,12 @@
1007
999
  }
1008
1000
  }
1009
1001
 
1002
+ @mixin gl-sm-mr-0 {
1003
+ @include gl-media-breakpoint-up(sm) {
1004
+ @include gl-mr-0;
1005
+ }
1006
+ }
1007
+
1010
1008
  @mixin gl-sm-mt-0 {
1011
1009
  @include gl-media-breakpoint-up(sm) {
1012
1010
  @include gl-mt-0;
@@ -1025,6 +1023,12 @@
1025
1023
  }
1026
1024
  }
1027
1025
 
1026
+ @mixin gl-sm-mb-0 {
1027
+ @include gl-media-breakpoint-up(sm) {
1028
+ margin-bottom: 0;
1029
+ }
1030
+ }
1031
+
1028
1032
  @mixin gl-sm-mb-7 {
1029
1033
  @include gl-media-breakpoint-up(sm) {
1030
1034
  @include gl-mb-7;
@@ -1109,6 +1113,12 @@
1109
1113
  }
1110
1114
  }
1111
1115
 
1116
+ @mixin gl-md-mr-0 {
1117
+ @include gl-media-breakpoint-up(md) {
1118
+ @include gl-mr-0;
1119
+ }
1120
+ }
1121
+
1112
1122
  @mixin gl-md-mr-3 {
1113
1123
  @include gl-media-breakpoint-up(md) {
1114
1124
  @include gl-mr-3;
@@ -17,13 +17,6 @@ export const ANNOTATIONS_SERIES_NAME = 'annotations';
17
17
  */
18
18
  export const ANNOTATIONS_COMPONENT_TYPE = 'markPoint';
19
19
 
20
- /**
21
- * This is so that the mouse doesn't go over the
22
- * tooltip and call mouseout which will hide the
23
- * tooltip.
24
- */
25
- export const ANNOTATION_TOOLTIP_TOP_OFFSET = 10;
26
-
27
20
  /**
28
21
  * This is a slight offset that gets applied to the left
29
22
  * of the chart tooltips to ensure a correct position.
@@ -31,11 +24,10 @@ export const ANNOTATION_TOOLTIP_TOP_OFFSET = 10;
31
24
  export const TOOLTIP_LEFT_OFFSET = 2;
32
25
 
33
26
  /**
34
- * This is an offset that gets applied between the mouse
35
- * cursor and the left of the chart data tooltips to provide
36
- * some spacing.
27
+ * This is a slight offset that gets applied to the left
28
+ * of the chart tooltips to ensure a correct position.
37
29
  */
38
- export const DATA_TOOLTIP_LEFT_OFFSET = 10;
30
+ export const TOOLTIP_TOP_OFFSET = 10;
39
31
 
40
32
  /**
41
33
  * These are the accepted values for the layout prop