@gitlab/ui 59.3.2 → 59.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "59.3.2",
3
+ "version": "59.5.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -23,12 +23,13 @@ describe('area component', () => {
23
23
 
24
24
  const emitChartCreated = () => findChart().vm.$emit('created', mockChartInstance);
25
25
 
26
- const createShallowWrapper = (props = {}) => {
26
+ const createShallowWrapper = ({ props = {}, slots = {} } = {}) => {
27
27
  wrapper = shallowMount(AreaChart, {
28
28
  propsData: { option: { series: [] }, data: [], ...props },
29
29
  stubs: {
30
30
  'chart-tooltip': ChartTooltipStub,
31
31
  },
32
+ slots,
32
33
  });
33
34
  emitChartCreated();
34
35
  };
@@ -57,12 +58,14 @@ describe('area component', () => {
57
58
 
58
59
  it('are displayed if passed via annotations props', async () => {
59
60
  createShallowWrapper({
60
- annotations: [
61
- {
62
- min: '',
63
- max: '',
64
- },
65
- ],
61
+ props: {
62
+ annotations: [
63
+ {
64
+ min: '',
65
+ max: '',
66
+ },
67
+ ],
68
+ },
66
69
  });
67
70
 
68
71
  await wrapper.vm.$nextTick();
@@ -72,20 +75,22 @@ describe('area component', () => {
72
75
 
73
76
  it('are displayed if passed via option props', async () => {
74
77
  createShallowWrapper({
75
- option: {
76
- series: [
77
- {
78
- name: 'annotations',
79
- markPoint: {
80
- data: [
81
- {
82
- xAxis: 10,
83
- },
84
- ],
78
+ props: {
79
+ option: {
80
+ series: [
81
+ {
82
+ name: 'annotations',
83
+ markPoint: {
84
+ data: [
85
+ {
86
+ xAxis: 10,
87
+ },
88
+ ],
89
+ },
90
+ data: [],
85
91
  },
86
- data: [],
87
- },
88
- ],
92
+ ],
93
+ },
89
94
  },
90
95
  });
91
96
 
@@ -111,12 +116,14 @@ describe('area component', () => {
111
116
  };
112
117
 
113
118
  createShallowWrapper({
114
- annotations: [
115
- {
116
- min: '',
117
- max: '',
118
- },
119
- ],
119
+ props: {
120
+ annotations: [
121
+ {
122
+ min: '',
123
+ max: '',
124
+ },
125
+ ],
126
+ },
120
127
  });
121
128
 
122
129
  wrapper.vm.onChartDataPointMouseOver(params);
@@ -166,7 +173,9 @@ describe('area component', () => {
166
173
 
167
174
  it('is inline if correct prop value is set', async () => {
168
175
  createShallowWrapper({
169
- legendLayout: LEGEND_LAYOUT_INLINE,
176
+ props: {
177
+ legendLayout: LEGEND_LAYOUT_INLINE,
178
+ },
170
179
  });
171
180
 
172
181
  await wrapper.vm.$nextTick();
@@ -176,18 +185,41 @@ describe('area component', () => {
176
185
 
177
186
  it('is tabular if correct prop value is set', async () => {
178
187
  createShallowWrapper({
179
- legendLayout: LEGEND_LAYOUT_TABLE,
188
+ props: {
189
+ legendLayout: LEGEND_LAYOUT_TABLE,
190
+ },
180
191
  });
181
192
 
182
193
  await wrapper.vm.$nextTick();
183
194
 
184
195
  expect(findLegend().props('layout')).toBe(LEGEND_LAYOUT_TABLE);
185
196
  });
197
+
198
+ it('displays custom series info when prop is set', async () => {
199
+ const legendSeriesInfo = [
200
+ {
201
+ name: 'Custom Legend Item',
202
+ type: 'solid',
203
+ color: '#000',
204
+ data: [10, 20, 30],
205
+ },
206
+ ];
207
+
208
+ createShallowWrapper({
209
+ props: {
210
+ legendSeriesInfo,
211
+ },
212
+ });
213
+
214
+ await wrapper.vm.$nextTick();
215
+
216
+ expect(findLegend().props('seriesInfo')).toEqual(expect.arrayContaining(legendSeriesInfo));
217
+ });
186
218
  });
187
219
 
188
220
  describe('height', () => {
189
221
  expectHeightAutoClasses({
190
- createComponent: createShallowWrapper,
222
+ createComponent: (props) => createShallowWrapper({ props: { ...props } }),
191
223
  findContainer: () => wrapper,
192
224
  findChart,
193
225
  });
@@ -2,6 +2,7 @@ import times from 'lodash/times';
2
2
  import { GlAreaChart } from '../../../charts';
3
3
  import { mockAnnotationsSeries, mockAnnotationsConfigs } from '../../../utils/charts/mock_data';
4
4
  import { toolbox } from '../../../utils/charts/story_config';
5
+ import { dataVizAqua500, dataVizOrange600 } from '../../../../scss_to_js/scss_variables';
5
6
  import { timeSeriesDateFormatter } from '../../../utils/charts/utils';
6
7
  import { generateTimeSeries } from '../../../utils/data_utils';
7
8
  import { disableControls } from '../../../utils/stories_utils';
@@ -35,6 +36,7 @@ const template = `<gl-area-chart
35
36
  :annotations="annotations"
36
37
  :includeLegendAvgMax="includeLegendAvgMax"
37
38
  :height="height"
39
+ :legendSeriesInfo="legendSeriesInfo"
38
40
  />`;
39
41
 
40
42
  const generateProps = ({
@@ -44,6 +46,7 @@ const generateProps = ({
44
46
  annotations = [],
45
47
  includeLegendAvgMax = true,
46
48
  height = null,
49
+ legendSeriesInfo = [],
47
50
  } = {}) => ({
48
51
  data,
49
52
  option,
@@ -51,6 +54,7 @@ const generateProps = ({
51
54
  annotations,
52
55
  includeLegendAvgMax,
53
56
  height,
57
+ legendSeriesInfo,
54
58
  });
55
59
 
56
60
  const Template = (args, { argTypes }) => ({
@@ -153,6 +157,24 @@ MultSeries.args = generateProps({
153
157
  })),
154
158
  });
155
159
 
160
+ export const WithCustomLegendItems = Template.bind({});
161
+ WithCustomLegendItems.args = generateProps({
162
+ legendSeriesInfo: [
163
+ {
164
+ name: 'Custom Legend Item 1',
165
+ type: 'solid',
166
+ color: dataVizOrange600,
167
+ data: [10, 20],
168
+ },
169
+ {
170
+ name: 'Custom Legend Item 2',
171
+ type: 'solid',
172
+ color: dataVizAqua500,
173
+ data: [30, 50],
174
+ },
175
+ ],
176
+ });
177
+
156
178
  export default {
157
179
  title: 'charts/area-chart',
158
180
  component: GlAreaChart,
@@ -127,6 +127,11 @@ export default {
127
127
  required: false,
128
128
  default: null,
129
129
  },
130
+ legendSeriesInfo: {
131
+ type: Array,
132
+ required: false,
133
+ default: () => [],
134
+ },
130
135
  },
131
136
  data() {
132
137
  // Part of the tooltip related data can be
@@ -244,6 +249,8 @@ export default {
244
249
  return { paddingLeft: `${grid.left}px` };
245
250
  },
246
251
  seriesInfo() {
252
+ if (this.legendSeriesInfo.length > 0) return this.legendSeriesInfo;
253
+
247
254
  return this.compiledOptions.series.reduce((acc, series, index) => {
248
255
  if (series.type === 'line') {
249
256
  acc.push({
@@ -3343,6 +3343,34 @@
3343
3343
  }
3344
3344
  }
3345
3345
 
3346
+ .gl-flex-wrap-reverse {
3347
+ flex-wrap: wrap-reverse;
3348
+ }
3349
+
3350
+ .gl-flex-wrap-reverse\! {
3351
+ flex-wrap: wrap-reverse !important;
3352
+ }
3353
+
3354
+ .gl-flex-nowrap {
3355
+ flex-wrap: nowrap;
3356
+ }
3357
+
3358
+ .gl-flex-nowrap\! {
3359
+ flex-wrap: nowrap !important;
3360
+ }
3361
+
3362
+ .gl-sm-flex-nowrap {
3363
+ @include gl-media-breakpoint-up(sm) {
3364
+ flex-wrap: nowrap;
3365
+ }
3366
+ }
3367
+
3368
+ .gl-sm-flex-nowrap\! {
3369
+ @include gl-media-breakpoint-up(sm) {
3370
+ flex-wrap: nowrap !important;
3371
+ }
3372
+ }
3373
+
3346
3374
  .gl-flex-wrap-wrap {
3347
3375
  flex-wrap: wrap;
3348
3376
  }
@@ -3415,14 +3443,6 @@
3415
3443
  }
3416
3444
  }
3417
3445
 
3418
- .gl-flex-nowrap {
3419
- flex-wrap: nowrap;
3420
- }
3421
-
3422
- .gl-flex-nowrap\! {
3423
- flex-wrap: nowrap !important;
3424
- }
3425
-
3426
3446
  .gl-flex-direction-column {
3427
3447
  flex-direction: column;
3428
3448
  }
@@ -65,11 +65,6 @@
65
65
  }
66
66
  }
67
67
 
68
- /**
69
- * `gl-*flex-wrap` is deprecated; use `gl-*flex-wrap-wrap` instead.
70
- * TODO: delete `gl-*flex-wrap` utilities classes, see
71
- * https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1951
72
- */
73
68
  @mixin gl-flex-wrap {
74
69
  flex-wrap: wrap;
75
70
  }
@@ -92,6 +87,25 @@
92
87
  }
93
88
  }
94
89
 
90
+ @mixin gl-flex-wrap-reverse {
91
+ flex-wrap: wrap-reverse;
92
+ }
93
+
94
+ @mixin gl-flex-nowrap {
95
+ flex-wrap: nowrap;
96
+ }
97
+
98
+ @mixin gl-sm-flex-nowrap {
99
+ @include gl-media-breakpoint-up(sm) {
100
+ @include gl-flex-nowrap;
101
+ }
102
+ }
103
+
104
+ /**
105
+ * `gl-*flex-wrap-wrap` is deprecated; use `gl-*flex-wrap` instead.
106
+ * TODO: delete `gl-*flex-wrap-wrap` utilities classes, see
107
+ * https://gitlab.com/gitlab-org/gitlab-ui/-/issues/2204
108
+ */
95
109
  @mixin gl-flex-wrap-wrap {
96
110
  flex-wrap: wrap;
97
111
  }
@@ -128,15 +142,6 @@
128
142
  }
129
143
  }
130
144
 
131
- /**
132
- * `gl-flex-nowrap` is deprecated; use `gl-flex-wrap-nowrap` instead.
133
- * TODO: delete `gl-flex-wrap-nowrap` utility class, see
134
- * https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1951
135
- */
136
- @mixin gl-flex-nowrap {
137
- flex-wrap: nowrap;
138
- }
139
-
140
145
  @mixin gl-flex-direction-column {
141
146
  flex-direction: column;
142
147
  }