@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.
- package/CHANGELOG.md +14 -0
- package/dist/components/base/accordion/accordion.js +2 -8
- package/dist/components/base/accordion/accordion_item.js +0 -14
- package/dist/components/base/alert/alert.js +4 -22
- package/dist/components/base/avatar/avatar.js +0 -7
- package/dist/components/base/avatar_labeled/avatar_labeled.js +0 -2
- package/dist/components/base/avatars_inline/avatars_inline.js +2 -10
- package/dist/components/base/badge/badge.js +0 -8
- package/dist/components/base/banner/banner.js +0 -10
- package/dist/components/base/breadcrumb/breadcrumb.js +0 -12
- package/dist/components/base/breadcrumb/breadcrumb_item.js +0 -2
- package/dist/components/base/broadcast_message/broadcast_message.js +0 -3
- package/dist/components/base/button/button.js +0 -11
- package/dist/components/base/card/card.js +1 -2
- package/dist/components/base/datepicker/datepicker.js +7 -42
- package/dist/components/base/daterange_picker/daterange_picker.js +0 -23
- package/dist/components/base/drawer/drawer.js +0 -13
- package/dist/components/base/dropdown/dropdown.js +3 -17
- package/dist/components/base/dropdown/dropdown_item.js +2 -8
- package/dist/components/base/filtered_search/common_story_options.js +1 -2
- package/dist/components/base/filtered_search/filtered_search.js +9 -61
- package/dist/components/base/filtered_search/filtered_search_suggestion.js +0 -6
- package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +0 -16
- package/dist/components/base/filtered_search/filtered_search_term.js +0 -9
- package/dist/components/base/filtered_search/filtered_search_token.js +10 -49
- package/dist/components/base/filtered_search/filtered_search_token_segment.js +3 -56
- package/dist/components/base/filtered_search/filtered_search_utils.js +7 -24
- package/dist/components/base/form/form_checkbox/form_checkbox.js +0 -2
- package/dist/components/base/form/form_checkbox_tree/checkbox_tree_node.js +0 -4
- package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.js +0 -10
- package/dist/components/base/form/form_checkbox_tree/models/node.js +1 -10
- package/dist/components/base/form/form_checkbox_tree/models/tree.js +16 -37
- package/dist/components/base/form/form_combobox/form_combobox.js +2 -36
- package/dist/components/base/form/form_group/form_group.js +2 -7
- package/dist/components/base/form/form_input/form_input.js +2 -8
- package/dist/components/base/form/form_input_group/form_input_group.js +0 -5
- package/dist/components/base/form/form_input_group/form_input_group_mixin.js +0 -8
- package/dist/components/base/form/form_radio_group/form_radio_group.js +0 -2
- package/dist/components/base/form/form_select/form_select.js +0 -3
- package/dist/components/base/form/form_textarea/form_textarea.js +2 -7
- package/dist/components/base/icon/icon.js +4 -14
- package/dist/components/base/infinite_scroll/infinite_scroll.js +7 -21
- package/dist/components/base/keyset_pagination/keyset_pagination.js +0 -9
- package/dist/components/base/label/label.js +0 -12
- package/dist/components/base/loading_icon/loading_icon.js +7 -10
- package/dist/components/base/markdown/markdown.js +1 -0
- package/dist/components/base/modal/modal.js +7 -27
- package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +0 -25
- package/dist/components/base/new_dropdowns/constants.js +4 -2
- package/dist/components/base/new_dropdowns/listbox/listbox.js +0 -63
- package/dist/components/base/new_dropdowns/listbox/listbox_group.js +0 -2
- package/dist/components/base/new_dropdowns/listbox/listbox_item.js +0 -5
- package/dist/components/base/new_dropdowns/listbox/utils.js +0 -7
- package/dist/components/base/paginated_list/paginated_list.js +0 -15
- package/dist/components/base/pagination/pagination.js +14 -72
- package/dist/components/base/path/path.js +0 -29
- package/dist/components/base/popover/popover.js +0 -5
- package/dist/components/base/search_box_by_click/search_box_by_click.js +1 -26
- package/dist/components/base/search_box_by_type/search_box_by_type.js +2 -12
- package/dist/components/base/segmented_control/segmented_control.js +0 -10
- package/dist/components/base/skeleton_loader/skeleton_loader.js +0 -19
- package/dist/components/base/skeleton_loading/skeleton_loading.js +0 -3
- package/dist/components/base/sorting/sorting.js +1 -9
- package/dist/components/base/sorting/sorting_item.js +4 -6
- package/dist/components/base/table/table.js +0 -4
- package/dist/components/base/tabs/tab/tab.js +2 -6
- package/dist/components/base/tabs/tabs/scrollable_tabs.js +0 -21
- package/dist/components/base/tabs/tabs/tabs.js +8 -33
- package/dist/components/base/toast/toast.js +4 -15
- package/dist/components/base/toggle/toggle.js +0 -18
- package/dist/components/base/token/token.js +0 -4
- package/dist/components/base/token_selector/token_container.js +0 -24
- package/dist/components/base/token_selector/token_selector.js +10 -61
- package/dist/components/base/token_selector/token_selector_dropdown.js +4 -32
- package/dist/components/charts/area/area.js +8 -32
- package/dist/components/charts/bar/bar.js +7 -19
- package/dist/components/charts/chart/chart.js +1 -22
- package/dist/components/charts/column/column.js +8 -18
- package/dist/components/charts/discrete_scatter/discrete_scatter.js +2 -13
- package/dist/components/charts/gauge/gauge.js +0 -15
- package/dist/components/charts/heatmap/heatmap.js +3 -16
- package/dist/components/charts/legend/legend.js +2 -24
- package/dist/components/charts/line/line.js +8 -34
- package/dist/components/charts/series_label/series_label.js +0 -12
- package/dist/components/charts/single_stat/single_stat.js +0 -8
- package/dist/components/charts/sparkline/sparkline.js +1 -16
- package/dist/components/charts/stacked_column/stacked_column.js +8 -26
- package/dist/components/charts/tooltip/tooltip.js +0 -6
- package/dist/components/mixins/button_mixin.js +0 -1
- package/dist/components/mixins/safe_link_mixin.js +0 -1
- package/dist/components/mixins/toolbox_mixin.js +0 -1
- package/dist/components/mixins/tooltip_mixin.js +1 -2
- package/dist/components/regions/empty_state/empty_state.js +0 -12
- package/dist/components/utilities/animated_number/animated_number.js +0 -16
- package/dist/components/utilities/friendly_wrap/friendly_wrap.js +0 -3
- package/dist/components/utilities/intersection_observer/intersection_observer.js +0 -7
- package/dist/components/utilities/intersperse/intersperse.js +3 -9
- package/dist/components/utilities/sprintf/sprintf.js +9 -23
- package/dist/components/utilities/truncate/truncate.js +0 -10
- package/dist/config.js +3 -4
- package/dist/directives/hover_load/hover_load.js +2 -8
- package/dist/directives/outside/get_event_like_time_stamp.js +4 -2
- package/dist/directives/outside/outside.js +5 -20
- package/dist/directives/resize_observer/resize_observer.js +0 -10
- package/dist/directives/safe_html/safe_html.js +5 -6
- package/dist/directives/safe_link/mock_data.js +1 -1
- package/dist/directives/safe_link/safe_link.js +0 -13
- package/dist/utils/breakpoints.js +0 -3
- package/dist/utils/charts/config.js +29 -42
- package/dist/utils/charts/constants.js +8 -8
- package/dist/utils/charts/mock_data.js +2 -2
- package/dist/utils/charts/story_config.js +1 -1
- package/dist/utils/charts/theme.js +1 -3
- package/dist/utils/charts/utils.js +2 -6
- package/dist/utils/constants.js +10 -7
- package/dist/utils/data_utils.js +5 -4
- package/dist/utils/datetime_utility.js +4 -4
- package/dist/utils/number_utils.js +7 -11
- package/dist/utils/stories_utils.js +1 -1
- package/dist/utils/story_decorators/container.js +0 -1
- package/dist/utils/string_utils.js +0 -14
- package/dist/utils/test_utils.js +3 -2
- package/dist/utils/use_fake_date.js +0 -4
- package/dist/utils/use_mock_intersection_observer.js +4 -19
- package/dist/utils/utils.js +5 -14
- package/package.json +3 -3
- package/src/components/base/pagination/pagination.vue +2 -2
- package/src/components/base/toast/toast.js +1 -0
|
@@ -38,7 +38,8 @@ const grid = {
|
|
|
38
38
|
left: 64,
|
|
39
39
|
right: 32
|
|
40
40
|
};
|
|
41
|
-
const gridWithSecondaryYAxis = {
|
|
41
|
+
const gridWithSecondaryYAxis = {
|
|
42
|
+
...grid,
|
|
42
43
|
right: 64
|
|
43
44
|
};
|
|
44
45
|
const lineStyle = {
|
|
@@ -46,13 +47,13 @@ const lineStyle = {
|
|
|
46
47
|
type: 'line',
|
|
47
48
|
width: 2
|
|
48
49
|
};
|
|
50
|
+
|
|
49
51
|
/**
|
|
50
52
|
* Annotations series consists of annotations lines
|
|
51
53
|
* along with markers. Annotations co-exist with data
|
|
52
54
|
* series but have their own virtual coords so that they stay put
|
|
53
55
|
* irrespective of data series extents.
|
|
54
56
|
*/
|
|
55
|
-
|
|
56
57
|
const annotationsYAxisCoords = {
|
|
57
58
|
min: 0,
|
|
58
59
|
pos: 3,
|
|
@@ -61,22 +62,23 @@ const annotationsYAxisCoords = {
|
|
|
61
62
|
show: false
|
|
62
63
|
};
|
|
63
64
|
const symbolSize = 6;
|
|
65
|
+
|
|
64
66
|
/**
|
|
65
67
|
* These comparison operators are currently in monitoring
|
|
66
68
|
* charts that have alerting related data.
|
|
67
69
|
*
|
|
68
70
|
* {Array} Possible values for greater than
|
|
69
71
|
*/
|
|
70
|
-
|
|
71
72
|
const GREATER_THAN = ['>', '>'];
|
|
73
|
+
|
|
72
74
|
/**
|
|
73
75
|
* These comparison operators are currently in monitoring
|
|
74
76
|
* charts that have alerting related data.
|
|
75
77
|
*
|
|
76
78
|
* {Array} Possible values for less than
|
|
77
79
|
*/
|
|
78
|
-
|
|
79
80
|
const LESS_THAN = ['<', '<'];
|
|
81
|
+
|
|
80
82
|
/**
|
|
81
83
|
* All default dataZoom configs will have slider & inside
|
|
82
84
|
* (for reference, see https://gitlab.com/gitlab-org/gitlab-ui/issues/240)
|
|
@@ -84,7 +86,6 @@ const LESS_THAN = ['<', '<'];
|
|
|
84
86
|
* and is specifically to enable touch zoom for mobile devices
|
|
85
87
|
* @param {Object} options
|
|
86
88
|
*/
|
|
87
|
-
|
|
88
89
|
const getDataZoomConfig = function () {
|
|
89
90
|
let {
|
|
90
91
|
filterMode = 'none'
|
|
@@ -111,20 +112,23 @@ const getDataZoomConfig = function () {
|
|
|
111
112
|
disabled
|
|
112
113
|
}]
|
|
113
114
|
};
|
|
114
|
-
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// All chart options can be merged but series
|
|
115
118
|
// needs to be concatenated.
|
|
116
119
|
// Series can be an object for single series or
|
|
117
120
|
// an array of objects.
|
|
118
|
-
|
|
119
121
|
const mergeSeriesToOptions = function (options) {
|
|
120
122
|
let series = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
121
123
|
const {
|
|
122
124
|
series: optSeries = []
|
|
123
125
|
} = options;
|
|
124
|
-
return {
|
|
126
|
+
return {
|
|
127
|
+
...options,
|
|
125
128
|
series: [...castArray(series), ...castArray(optSeries)]
|
|
126
129
|
};
|
|
127
130
|
};
|
|
131
|
+
|
|
128
132
|
/**
|
|
129
133
|
* If an annotation series exists, the chart options should have an
|
|
130
134
|
* array of yAxis settings so that the series can exist in its own
|
|
@@ -134,10 +138,10 @@ const mergeSeriesToOptions = function (options) {
|
|
|
134
138
|
* @param {Boolean} hasAnnotations if annotation series yAxis should be merged
|
|
135
139
|
* @returns {Object} options
|
|
136
140
|
*/
|
|
137
|
-
|
|
138
141
|
const mergeAnnotationAxisToOptions = function (options) {
|
|
139
142
|
let hasAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
140
|
-
return {
|
|
143
|
+
return {
|
|
144
|
+
...options,
|
|
141
145
|
...(hasAnnotations && {
|
|
142
146
|
yAxis: [options.yAxis, annotationsYAxisCoords]
|
|
143
147
|
})
|
|
@@ -162,19 +166,16 @@ const getToolboxConfig = function () {
|
|
|
162
166
|
feature: {}
|
|
163
167
|
}
|
|
164
168
|
};
|
|
165
|
-
|
|
166
169
|
if (restoreIconPath.length) {
|
|
167
170
|
toolboxConfig.toolbox.feature.restore = {
|
|
168
171
|
icon: restoreIconPath
|
|
169
172
|
};
|
|
170
173
|
}
|
|
171
|
-
|
|
172
174
|
if (saveImageIconPath.length) {
|
|
173
175
|
toolboxConfig.toolbox.feature.saveAsImage = {
|
|
174
176
|
icon: restoreIconPath
|
|
175
177
|
};
|
|
176
178
|
}
|
|
177
|
-
|
|
178
179
|
if (zoomIconPath.length && backIconPath.length) {
|
|
179
180
|
toolboxConfig.toolbox.feature.dataZoom = {
|
|
180
181
|
icon: {
|
|
@@ -183,9 +184,9 @@ const getToolboxConfig = function () {
|
|
|
183
184
|
}
|
|
184
185
|
};
|
|
185
186
|
}
|
|
186
|
-
|
|
187
187
|
return toolboxConfig;
|
|
188
188
|
};
|
|
189
|
+
|
|
189
190
|
/**
|
|
190
191
|
* Generate eCharts markArea arrays for thresholds and annotations.
|
|
191
192
|
*
|
|
@@ -204,7 +205,6 @@ const getToolboxConfig = function () {
|
|
|
204
205
|
* @param {String} axis markArea is generated against this axis
|
|
205
206
|
* @returns {Array}
|
|
206
207
|
*/
|
|
207
|
-
|
|
208
208
|
const generateMarkArea = function (_ref) {
|
|
209
209
|
let {
|
|
210
210
|
min,
|
|
@@ -217,6 +217,7 @@ const generateMarkArea = function (_ref) {
|
|
|
217
217
|
[axis]: max
|
|
218
218
|
}];
|
|
219
219
|
};
|
|
220
|
+
|
|
220
221
|
/**
|
|
221
222
|
* Generate eCharts markLine objects for thresholds and annotations.
|
|
222
223
|
*
|
|
@@ -239,25 +240,22 @@ const generateMarkArea = function (_ref) {
|
|
|
239
240
|
* @param {String} axis markLine is generated against this axis
|
|
240
241
|
* @returns {Object}
|
|
241
242
|
*/
|
|
242
|
-
|
|
243
|
-
|
|
244
243
|
const generateMarkLines = function (_ref2) {
|
|
245
244
|
let {
|
|
246
245
|
min,
|
|
247
246
|
max
|
|
248
247
|
} = _ref2;
|
|
249
248
|
let axis = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yAxis';
|
|
250
|
-
|
|
251
249
|
if (min) {
|
|
252
250
|
return {
|
|
253
251
|
[axis]: min
|
|
254
252
|
};
|
|
255
253
|
}
|
|
256
|
-
|
|
257
254
|
return {
|
|
258
255
|
[axis]: max
|
|
259
256
|
};
|
|
260
257
|
};
|
|
258
|
+
|
|
261
259
|
/**
|
|
262
260
|
* Generates markPoints that are placed under the markLines.
|
|
263
261
|
*
|
|
@@ -268,8 +266,6 @@ const generateMarkLines = function (_ref2) {
|
|
|
268
266
|
* @param {Object} annotation object
|
|
269
267
|
* @return {Object}
|
|
270
268
|
*/
|
|
271
|
-
|
|
272
|
-
|
|
273
269
|
const generateMarkPoints = _ref3 => {
|
|
274
270
|
let {
|
|
275
271
|
min,
|
|
@@ -282,6 +278,7 @@ const generateMarkPoints = _ref3 => {
|
|
|
282
278
|
tooltipData
|
|
283
279
|
};
|
|
284
280
|
};
|
|
281
|
+
|
|
285
282
|
/**
|
|
286
283
|
* Generate set of markAreas and markLines to draw on charts
|
|
287
284
|
* as alert thresholds.
|
|
@@ -291,19 +288,15 @@ const generateMarkPoints = _ref3 => {
|
|
|
291
288
|
* @param {Array} thresholds Array of alert thresholds
|
|
292
289
|
* @returns {Object} markAreas and markLines
|
|
293
290
|
*/
|
|
294
|
-
|
|
295
|
-
|
|
296
291
|
function getThresholdConfig(thresholds) {
|
|
297
292
|
if (!thresholds.length) {
|
|
298
293
|
return {};
|
|
299
294
|
}
|
|
300
|
-
|
|
301
295
|
const data = thresholds.reduce((acc, alert) => {
|
|
302
296
|
const {
|
|
303
297
|
threshold,
|
|
304
298
|
operator
|
|
305
299
|
} = alert;
|
|
306
|
-
|
|
307
300
|
if (GREATER_THAN.includes(operator)) {
|
|
308
301
|
acc.areas.push(generateMarkArea({
|
|
309
302
|
min: threshold,
|
|
@@ -315,7 +308,6 @@ function getThresholdConfig(thresholds) {
|
|
|
315
308
|
max: threshold
|
|
316
309
|
}));
|
|
317
310
|
}
|
|
318
|
-
|
|
319
311
|
acc.lines.push(generateMarkLines({
|
|
320
312
|
max: threshold
|
|
321
313
|
}));
|
|
@@ -334,6 +326,7 @@ function getThresholdConfig(thresholds) {
|
|
|
334
326
|
}
|
|
335
327
|
};
|
|
336
328
|
}
|
|
329
|
+
|
|
337
330
|
/**
|
|
338
331
|
* This method is only for testing both markLines and markAreas
|
|
339
332
|
* that are used for annotations.
|
|
@@ -344,7 +337,6 @@ function getThresholdConfig(thresholds) {
|
|
|
344
337
|
* @param {Array} annotations Array of annotation objects
|
|
345
338
|
* @returns {Object} { areas, lines, points }
|
|
346
339
|
*/
|
|
347
|
-
|
|
348
340
|
const parseAnnotations = annotations => annotations.reduce((acc, annotation) => {
|
|
349
341
|
// because only markLines are supported all cases will
|
|
350
342
|
// satisfy this condition. This is more of a sanity check
|
|
@@ -355,7 +347,6 @@ const parseAnnotations = annotations => annotations.reduce((acc, annotation) =>
|
|
|
355
347
|
acc.points.push(generateMarkPoints(annotation));
|
|
356
348
|
return acc;
|
|
357
349
|
}
|
|
358
|
-
|
|
359
350
|
acc.areas.push(generateMarkArea(annotation, 'xAxis'));
|
|
360
351
|
return acc;
|
|
361
352
|
}, {
|
|
@@ -363,6 +354,7 @@ const parseAnnotations = annotations => annotations.reduce((acc, annotation) =>
|
|
|
363
354
|
lines: [],
|
|
364
355
|
points: []
|
|
365
356
|
});
|
|
357
|
+
|
|
366
358
|
/**
|
|
367
359
|
* Generate set of markAreas and markLines to draw on charts
|
|
368
360
|
* as annotations.
|
|
@@ -374,14 +366,13 @@ const parseAnnotations = annotations => annotations.reduce((acc, annotation) =>
|
|
|
374
366
|
* @param {Array} annotations Array of annotations
|
|
375
367
|
* @returns {Object} { markLines }
|
|
376
368
|
*/
|
|
377
|
-
|
|
378
369
|
const getAnnotationsConfig = annotations => {
|
|
379
370
|
if (!annotations.length) {
|
|
380
371
|
return {};
|
|
381
|
-
}
|
|
382
|
-
// for markLines and markAreas.
|
|
383
|
-
|
|
372
|
+
}
|
|
384
373
|
|
|
374
|
+
// annotations parsing is moved out so that it can be tested
|
|
375
|
+
// for markLines and markAreas.
|
|
385
376
|
const {
|
|
386
377
|
lines,
|
|
387
378
|
points
|
|
@@ -405,6 +396,7 @@ const getAnnotationsConfig = annotations => {
|
|
|
405
396
|
}
|
|
406
397
|
};
|
|
407
398
|
};
|
|
399
|
+
|
|
408
400
|
/**
|
|
409
401
|
* Given thresholds and annotations options, this method generates
|
|
410
402
|
* an annotation series that co-exists along with the data series.
|
|
@@ -416,14 +408,11 @@ const getAnnotationsConfig = annotations => {
|
|
|
416
408
|
* @param {Object} params Thresholds, annotations and yAxis options
|
|
417
409
|
* @returns {Object} Annotation series
|
|
418
410
|
*/
|
|
419
|
-
|
|
420
411
|
const generateAnnotationSeries = function (annotations) {
|
|
421
412
|
let yAxisIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
422
|
-
|
|
423
413
|
if (!annotations.length) {
|
|
424
414
|
return null;
|
|
425
415
|
}
|
|
426
|
-
|
|
427
416
|
return merge({
|
|
428
417
|
name: ANNOTATIONS_SERIES_NAME,
|
|
429
418
|
yAxisIndex,
|
|
@@ -431,6 +420,7 @@ const generateAnnotationSeries = function (annotations) {
|
|
|
431
420
|
data: []
|
|
432
421
|
}, getAnnotationsConfig(annotations));
|
|
433
422
|
};
|
|
423
|
+
|
|
434
424
|
/**
|
|
435
425
|
* This method generates the data series and relevant defaults for a bar chart
|
|
436
426
|
*
|
|
@@ -442,7 +432,6 @@ const generateAnnotationSeries = function (annotations) {
|
|
|
442
432
|
* @param {number} [options.yAxisIndex] - specifies the yAxis to use (if there are multiple)
|
|
443
433
|
* @returns {Object} Bar chart series
|
|
444
434
|
*/
|
|
445
|
-
|
|
446
435
|
const generateBarSeries = _ref4 => {
|
|
447
436
|
let {
|
|
448
437
|
name,
|
|
@@ -470,6 +459,7 @@ const generateBarSeries = _ref4 => {
|
|
|
470
459
|
}
|
|
471
460
|
};
|
|
472
461
|
};
|
|
462
|
+
|
|
473
463
|
/**
|
|
474
464
|
* This method generates the data series and relevant defaults for a line chart
|
|
475
465
|
*
|
|
@@ -480,7 +470,6 @@ const generateBarSeries = _ref4 => {
|
|
|
480
470
|
* @param {number} [options.yAxisIndex] - specifies the yAxis to use (if there are multiple)
|
|
481
471
|
* @returns {Object} Line chart series
|
|
482
472
|
*/
|
|
483
|
-
|
|
484
473
|
const generateLineSeries = _ref5 => {
|
|
485
474
|
let {
|
|
486
475
|
name,
|
|
@@ -501,6 +490,7 @@ const generateLineSeries = _ref5 => {
|
|
|
501
490
|
}
|
|
502
491
|
};
|
|
503
492
|
};
|
|
493
|
+
|
|
504
494
|
/**
|
|
505
495
|
* The method works well if tooltip content should be against y-axis values.
|
|
506
496
|
* However, for bar charts, the tooltip should be against x-axis values.
|
|
@@ -511,7 +501,6 @@ const generateLineSeries = _ref5 => {
|
|
|
511
501
|
* @param {String} yAxisTitle y-axis title
|
|
512
502
|
* @returns {Object} tooltip title and content
|
|
513
503
|
*/
|
|
514
|
-
|
|
515
504
|
const getDefaultTooltipContent = function (params) {
|
|
516
505
|
let yAxisTitle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
517
506
|
const seriesDataLength = params.seriesData.length;
|
|
@@ -519,20 +508,18 @@ const getDefaultTooltipContent = function (params) {
|
|
|
519
508
|
xLabels,
|
|
520
509
|
tooltipContent
|
|
521
510
|
} = params.seriesData.reduce((acc, chartItem) => {
|
|
522
|
-
const [title, value] = chartItem.value || [];
|
|
511
|
+
const [title, value] = chartItem.value || [];
|
|
512
|
+
// Let's use the y axis title as series name when only one series exists
|
|
523
513
|
// This way, TooltipDefaultFormat will display the y axis title as label
|
|
524
|
-
|
|
525
514
|
const seriesName = seriesDataLength === 1 && yAxisTitle ? yAxisTitle : chartItem.seriesName;
|
|
526
515
|
const color = seriesDataLength === 1 ? '' : chartItem.color;
|
|
527
516
|
acc.tooltipContent[seriesName] = {
|
|
528
517
|
value,
|
|
529
518
|
color
|
|
530
519
|
};
|
|
531
|
-
|
|
532
520
|
if (!acc.xLabels.includes(title)) {
|
|
533
521
|
acc.xLabels.push(title);
|
|
534
522
|
}
|
|
535
|
-
|
|
536
523
|
return acc;
|
|
537
524
|
}, {
|
|
538
525
|
xLabels: [],
|
|
@@ -15,52 +15,52 @@ const ANNOTATIONS_SERIES_NAME = 'annotations';
|
|
|
15
15
|
*
|
|
16
16
|
* All markPoints have this component type
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
18
|
const ANNOTATIONS_COMPONENT_TYPE = 'markPoint';
|
|
19
|
+
|
|
20
20
|
/**
|
|
21
21
|
* This is so that the mouse doesn't go over the
|
|
22
22
|
* tooltip and call mouseout which will hide the
|
|
23
23
|
* tooltip.
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
25
|
const ANNOTATION_TOOLTIP_TOP_OFFSET = 10;
|
|
26
|
+
|
|
27
27
|
/**
|
|
28
28
|
* This is a slight offset that gets applied to the left
|
|
29
29
|
* of the chart tooltips to ensure a correct position.
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
31
|
const TOOLTIP_LEFT_OFFSET = 2;
|
|
32
|
+
|
|
33
33
|
/**
|
|
34
34
|
* This is an offset that gets applied between the mouse
|
|
35
35
|
* cursor and the left of the chart data tooltips to provide
|
|
36
36
|
* some spacing.
|
|
37
37
|
*/
|
|
38
|
-
|
|
39
38
|
const DATA_TOOLTIP_LEFT_OFFSET = 10;
|
|
39
|
+
|
|
40
40
|
/**
|
|
41
41
|
* These are the accepted values for the layout prop
|
|
42
42
|
* of the chart legend component
|
|
43
43
|
*/
|
|
44
|
-
|
|
45
44
|
const LEGEND_LAYOUT_INLINE = 'inline';
|
|
46
45
|
const LEGEND_LAYOUT_TABLE = 'table';
|
|
46
|
+
|
|
47
47
|
/**
|
|
48
48
|
* Default values for the chart legend field labels
|
|
49
49
|
*/
|
|
50
|
-
|
|
51
50
|
const LEGEND_AVERAGE_TEXT = 'Avg';
|
|
52
51
|
const LEGEND_CURRENT_TEXT = 'Current';
|
|
53
52
|
const LEGEND_MIN_TEXT = 'Min';
|
|
54
53
|
const LEGEND_MAX_TEXT = 'Max';
|
|
54
|
+
|
|
55
55
|
/**
|
|
56
56
|
* These arrow symbols are used as markPoints under the annotations lines
|
|
57
57
|
* within area and line charts. This icon doesn't exist in the svg
|
|
58
58
|
* library yet. The below issue is to track the progress of the svg icon
|
|
59
59
|
* https://gitlab.com/gitlab-org/gitlab-svgs/-/issues/118
|
|
60
60
|
*/
|
|
61
|
+
const arrowSymbol = 'path://m5 229 5 8h-10z';
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
// Constants for the type property of charts
|
|
64
64
|
const CHART_TYPE_BAR = 'bar';
|
|
65
65
|
const CHART_TYPE_LINE = 'line';
|
|
66
66
|
|
|
@@ -59,10 +59,10 @@ const mockDefaultChartOptions = {
|
|
|
59
59
|
show: false
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
+
|
|
62
63
|
/**
|
|
63
64
|
* This is currently used in area.stories.js and line.stories.js
|
|
64
65
|
*/
|
|
65
|
-
|
|
66
66
|
const mockAnnotationsSeries = {
|
|
67
67
|
series: [{
|
|
68
68
|
type: 'scatter',
|
|
@@ -112,10 +112,10 @@ const mockAnnotationsSeries = {
|
|
|
112
112
|
}
|
|
113
113
|
}]
|
|
114
114
|
};
|
|
115
|
+
|
|
115
116
|
/**
|
|
116
117
|
* This is currently used in area.stories.js and line.stories.js
|
|
117
118
|
*/
|
|
118
|
-
|
|
119
119
|
const mockAnnotationsConfigs = {
|
|
120
120
|
annotations: [{
|
|
121
121
|
min: '2018-01-25T01:00:00.000Z',
|
|
@@ -19,6 +19,7 @@ const toolbox = {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
+
|
|
22
23
|
/**
|
|
23
24
|
* Generates series data for usage in chart examples
|
|
24
25
|
*
|
|
@@ -26,7 +27,6 @@ const toolbox = {
|
|
|
26
27
|
* @param {String} nameType type of names - how long they should be
|
|
27
28
|
* @returns {Array} generated series data
|
|
28
29
|
*/
|
|
29
|
-
|
|
30
30
|
const generateSeriesData = function () {
|
|
31
31
|
let amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
32
32
|
let nameType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SERIES_NAME_SHORT;
|
|
@@ -49,13 +49,13 @@ const heatmapHues = [gray100, dataVizBlue200, dataVizBlue400, dataVizBlue600, da
|
|
|
49
49
|
const gaugeNeutralHues = [gray900, gray500];
|
|
50
50
|
const gaugeSafeHues = [dataVizBlue500, dataVizBlue900];
|
|
51
51
|
const gaugeWarningHue = dataVizOrange500;
|
|
52
|
+
|
|
52
53
|
/**
|
|
53
54
|
* The default palette is based on the Categorical data palette
|
|
54
55
|
* Categorical data (also known as qualitative or thematic) uses hue to
|
|
55
56
|
* differentiate qualitative data, and lightness to differentiate quantitive data.
|
|
56
57
|
* More info: https://gitlab.com/gitlab-org/gitlab-design/-/issues/719#categorical
|
|
57
58
|
*/
|
|
58
|
-
|
|
59
59
|
const colorPaletteDefault = [dataVizBlue500, dataVizOrange600, dataVizAqua500, dataVizGreen700, dataVizMagenta800, dataVizBlue700, dataVizOrange800, dataVizAqua700, dataVizGreen900, dataVizMagenta950, dataVizBlue900, dataVizOrange950, dataVizAqua900, dataVizGreen600, dataVizMagenta700, dataVizBlue600, dataVizOrange700, dataVizAqua600, dataVizGreen800, dataVizMagenta900, dataVizBlue800, dataVizOrange900, dataVizAqua800, dataVizGreen950, dataVizMagenta500, dataVizBlue950, dataVizOrange500, dataVizAqua950, dataVizGreen500, dataVizMagenta600];
|
|
60
60
|
const colorFromDefaultPalette = index => colorPaletteDefault[index % colorPaletteDefault.length];
|
|
61
61
|
const axes = {
|
|
@@ -100,9 +100,7 @@ const axes = {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
-
|
|
104
103
|
const isLineChartWithoutArea = options => Array.isArray(options === null || options === void 0 ? void 0 : options.series) && options.series.some(series => series.type === 'line' && !series.areaStyle);
|
|
105
|
-
|
|
106
104
|
const createTheme = function () {
|
|
107
105
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
108
106
|
return {
|
|
@@ -8,15 +8,14 @@ import { ANNOTATIONS_SERIES_NAME, ANNOTATIONS_COMPONENT_TYPE } from './constants
|
|
|
8
8
|
* @param {Array} series Array of series
|
|
9
9
|
* @returns {Boolean}
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
11
|
const seriesHasAnnotations = function () {
|
|
13
12
|
let series = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
14
13
|
return (series || []).filter(seriesData => {
|
|
15
14
|
var _seriesData$ANNOTATIO, _seriesData$ANNOTATIO2;
|
|
16
|
-
|
|
17
15
|
return seriesData.name === ANNOTATIONS_SERIES_NAME && ((_seriesData$ANNOTATIO = seriesData[ANNOTATIONS_COMPONENT_TYPE]) === null || _seriesData$ANNOTATIO === void 0 ? void 0 : (_seriesData$ANNOTATIO2 = _seriesData$ANNOTATIO.data) === null || _seriesData$ANNOTATIO2 === void 0 ? void 0 : _seriesData$ANNOTATIO2.length);
|
|
18
16
|
}).length !== 0;
|
|
19
17
|
};
|
|
18
|
+
|
|
20
19
|
/**
|
|
21
20
|
* Check if a data point is from an annotation series.
|
|
22
21
|
*
|
|
@@ -26,11 +25,11 @@ const seriesHasAnnotations = function () {
|
|
|
26
25
|
* @param {Object} params data point object
|
|
27
26
|
* @returns {boolean}
|
|
28
27
|
*/
|
|
29
|
-
|
|
30
28
|
const isDataPointAnnotation = function () {
|
|
31
29
|
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
32
30
|
return params.name === ANNOTATIONS_SERIES_NAME && params.componentType === ANNOTATIONS_COMPONENT_TYPE;
|
|
33
31
|
};
|
|
32
|
+
|
|
34
33
|
/**
|
|
35
34
|
* Date formatter to make date strings more
|
|
36
35
|
* readable.
|
|
@@ -41,14 +40,11 @@ const isDataPointAnnotation = function () {
|
|
|
41
40
|
* @param {String} d date string
|
|
42
41
|
* @returns {String}
|
|
43
42
|
*/
|
|
44
|
-
|
|
45
43
|
const timeSeriesDateFormatter = function () {
|
|
46
44
|
let d = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
47
|
-
|
|
48
45
|
if (!d) {
|
|
49
46
|
return '';
|
|
50
47
|
}
|
|
51
|
-
|
|
52
48
|
const date = new Date(d);
|
|
53
49
|
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
54
50
|
const day = date.getDate().toString().padStart(2, '0');
|
package/dist/utils/constants.js
CHANGED
|
@@ -3,11 +3,11 @@ import { POSITION } from '../components/utilities/truncate/constants';
|
|
|
3
3
|
const glIconSizes = '8 12 14 16 24 32 48 72';
|
|
4
4
|
|
|
5
5
|
function appendDefaultOption(options) {
|
|
6
|
-
return {
|
|
6
|
+
return {
|
|
7
|
+
...options,
|
|
7
8
|
default: ''
|
|
8
9
|
};
|
|
9
10
|
}
|
|
10
|
-
|
|
11
11
|
const COMMA = ',';
|
|
12
12
|
const LEFT_MOUSE_BUTTON = 0;
|
|
13
13
|
const glThemes = ['indigo', 'blue', 'light-blue', 'green', 'red', 'light-red'];
|
|
@@ -52,7 +52,8 @@ const viewModeOptions = {
|
|
|
52
52
|
dark: 'dark',
|
|
53
53
|
light: 'light'
|
|
54
54
|
};
|
|
55
|
-
const labelColorOptions = {
|
|
55
|
+
const labelColorOptions = {
|
|
56
|
+
...viewModeOptions
|
|
56
57
|
};
|
|
57
58
|
const avatarSizeOptions = [96, 64, 48, 32, 24, 16];
|
|
58
59
|
const avatarsInlineSizeOptions = [32, 24];
|
|
@@ -78,7 +79,6 @@ const buttonVariantOptions = {
|
|
|
78
79
|
danger: 'danger',
|
|
79
80
|
dashed: 'dashed',
|
|
80
81
|
link: 'link',
|
|
81
|
-
|
|
82
82
|
/**
|
|
83
83
|
* The "reset" variant can be used when customization of GlButton styles is required
|
|
84
84
|
* (e.g. for the "close" button in GlLabel).
|
|
@@ -107,8 +107,9 @@ const buttonSizeOptions = {
|
|
|
107
107
|
const buttonSizeOptionsMap = {
|
|
108
108
|
small: 'sm',
|
|
109
109
|
medium: 'md'
|
|
110
|
-
};
|
|
110
|
+
};
|
|
111
111
|
|
|
112
|
+
// size options all have corresponding styles (e.g. .s12 defined in icon.scss)
|
|
112
113
|
const iconSizeOptions = glIconSizes.split(' ').map(Number);
|
|
113
114
|
const triggerVariantOptions = {
|
|
114
115
|
click: 'click',
|
|
@@ -120,8 +121,9 @@ const tooltipPlacements = {
|
|
|
120
121
|
left: 'left',
|
|
121
122
|
right: 'right',
|
|
122
123
|
bottom: 'bottom'
|
|
123
|
-
};
|
|
124
|
+
};
|
|
124
125
|
|
|
126
|
+
// in milliseconds
|
|
125
127
|
const tooltipDelay = {
|
|
126
128
|
show: 500,
|
|
127
129
|
hide: 0
|
|
@@ -196,8 +198,9 @@ const tabsButtonDefaults = {
|
|
|
196
198
|
};
|
|
197
199
|
const tokenVariants = ['default', 'search-type', 'search-value'];
|
|
198
200
|
const resizeDebounceTime = 200;
|
|
199
|
-
const variantOptionsWithNoDefault = appendDefaultOption(variantOptions);
|
|
201
|
+
const variantOptionsWithNoDefault = appendDefaultOption(variantOptions);
|
|
200
202
|
|
|
203
|
+
// Datetime constants
|
|
201
204
|
const defaultDateFormat = 'YYYY-MM-DD';
|
|
202
205
|
const bannerVariants = ['promotion', 'introduction'];
|
|
203
206
|
const maxZIndex = 10;
|
package/dist/utils/data_utils.js
CHANGED
|
@@ -4,17 +4,18 @@ const getRepeatingValue = index => {
|
|
|
4
4
|
const values = [100, 500, 400, 200, 100, 800, 400, 500, 600, 300, 800, 900, 110, 700, 400, 300, 500, 300, 400, 600, 700];
|
|
5
5
|
return index < values.length ? values[index] : values[index % values.length];
|
|
6
6
|
};
|
|
7
|
+
const generateTimeSeries = () => new Array(100).fill(0).map((el, i) => [new Date(2018, 0, i), getRepeatingValue(i)]);
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
// takes an element and a list and `intersperses' that element between the elements of the list.
|
|
9
10
|
// (',' ['a', 'b', 'c']) -> ['a', ',', 'b', ',', 'c']
|
|
10
|
-
|
|
11
11
|
const intersperse = curry((separator, items) => {
|
|
12
12
|
const [head, ...rest] = items;
|
|
13
13
|
const separatorFactory = typeof separator === 'function' ? separator : () => separator;
|
|
14
14
|
return [head, ...rest.flatMap(item => [separatorFactory(), item], rest)];
|
|
15
|
-
});
|
|
16
|
-
// (1, 2, [1, 3, 4]) -> [1, 2, 3, 4]
|
|
15
|
+
});
|
|
17
16
|
|
|
17
|
+
// inserts a value at a given index into an array
|
|
18
|
+
// (1, 2, [1, 3, 4]) -> [1, 2, 3, 4]
|
|
18
19
|
const insert = curry((index, newItem, items) => [...items.slice(0, index), newItem, ...items.slice(index)]);
|
|
19
20
|
|
|
20
21
|
export { generateTimeSeries, insert, intersperse };
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @param {Date} date
|
|
8
8
|
*/
|
|
9
9
|
const newDate = date => date instanceof Date ? new Date(date.getTime()) : new Date();
|
|
10
|
+
|
|
10
11
|
/**
|
|
11
12
|
* Computes the difference between 2 date objects.
|
|
12
13
|
*
|
|
@@ -17,13 +18,13 @@ const newDate = date => date instanceof Date ? new Date(date.getTime()) : new Da
|
|
|
17
18
|
* getDayDifference(new Date('2020-08-10'), new Date('2020-08-15'));
|
|
18
19
|
* @returns {Number} Number of days between the 2 dates
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
21
|
const getDayDifference = (a, b) => {
|
|
22
22
|
const millisecondsPerDay = 1000 * 60 * 60 * 24;
|
|
23
23
|
const date1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());
|
|
24
24
|
const date2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());
|
|
25
25
|
return Math.floor((date2 - date1) / millisecondsPerDay);
|
|
26
26
|
};
|
|
27
|
+
|
|
27
28
|
/**
|
|
28
29
|
* Subtracts a given number of days from a given date and returns the new date.
|
|
29
30
|
*
|
|
@@ -34,8 +35,8 @@ const getDayDifference = (a, b) => {
|
|
|
34
35
|
* getDateInPast(new Date('2020-08-15'), 5);
|
|
35
36
|
* @returns {Date} Date in past as Date object
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
38
|
const getDateInPast = (date, daysInPast) => new Date(newDate(date).setDate(date.getDate() - daysInPast));
|
|
39
|
+
|
|
39
40
|
/**
|
|
40
41
|
* Adds a given number of days to a given date and returns the new date.
|
|
41
42
|
*
|
|
@@ -46,8 +47,8 @@ const getDateInPast = (date, daysInPast) => new Date(newDate(date).setDate(date.
|
|
|
46
47
|
* getDateInFuture(new Date('2020-08-10'), 5);
|
|
47
48
|
* @returns {Date} Date in future as Date object
|
|
48
49
|
*/
|
|
49
|
-
|
|
50
50
|
const getDateInFuture = (date, daysInFuture) => new Date(newDate(date).setDate(date.getDate() + daysInFuture));
|
|
51
|
+
|
|
51
52
|
/**
|
|
52
53
|
* Are the given two dates equal
|
|
53
54
|
*
|
|
@@ -55,7 +56,6 @@ const getDateInFuture = (date, daysInFuture) => new Date(newDate(date).setDate(d
|
|
|
55
56
|
* @param {Date} date2
|
|
56
57
|
* @returns {Boolean}
|
|
57
58
|
*/
|
|
58
|
-
|
|
59
59
|
const areDatesEqual = (date1, date2) => Boolean(date1 && date2 && new Date(date1).getTime() === new Date(date2).getTime());
|
|
60
60
|
|
|
61
61
|
export { areDatesEqual, getDateInFuture, getDateInPast, getDayDifference, newDate };
|