@gitlab/ui 49.0.0 → 49.0.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 +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 +14 -34
- package/dist/components/base/new_dropdowns/constants.js +4 -2
- package/dist/components/base/new_dropdowns/listbox/listbox.js +14 -81
- 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 +3 -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/new_dropdowns/base_dropdown/base_dropdown.spec.js +1 -0
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.vue +13 -7
- package/src/components/base/new_dropdowns/listbox/listbox.spec.js +13 -7
- package/src/components/base/new_dropdowns/listbox/listbox.vue +12 -16
- package/src/components/base/pagination/pagination.vue +2 -2
|
@@ -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 };
|
|
@@ -4,42 +4,39 @@
|
|
|
4
4
|
* @param {Number} b
|
|
5
5
|
*/
|
|
6
6
|
const addition = (a, b) => a + b;
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* Returns the sum of all arguments
|
|
9
10
|
* @param {...Number} numbers
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
12
|
const sum = function () {
|
|
13
13
|
for (var _len = arguments.length, numbers = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
14
14
|
numbers[_key] = arguments[_key];
|
|
15
15
|
}
|
|
16
|
-
|
|
17
16
|
return numbers.reduce(addition);
|
|
18
17
|
};
|
|
18
|
+
|
|
19
19
|
/**
|
|
20
20
|
* Returns the average of all arguments
|
|
21
21
|
* @param {...Number} numbers
|
|
22
22
|
*/
|
|
23
|
-
|
|
24
23
|
const average = function () {
|
|
25
24
|
return sum(...arguments) / arguments.length;
|
|
26
25
|
};
|
|
26
|
+
|
|
27
27
|
/**
|
|
28
28
|
* Convert number to engineering format, using SI suffix
|
|
29
29
|
* @param {Number|String} value - Number or Number-convertible String
|
|
30
30
|
* @param {Number} precision
|
|
31
31
|
* @return {String} number, possibly with a suffix
|
|
32
32
|
*/
|
|
33
|
-
|
|
34
33
|
const engineeringNotation = function (value) {
|
|
35
34
|
let precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
36
35
|
const invalidValues = [NaN, Infinity, -Infinity];
|
|
37
36
|
const num = Number(value);
|
|
38
|
-
|
|
39
37
|
if (invalidValues.includes(num) || invalidValues.includes(Number(precision))) {
|
|
40
38
|
return num.toString();
|
|
41
39
|
}
|
|
42
|
-
|
|
43
40
|
const allYourBase = {
|
|
44
41
|
'-24': 'y',
|
|
45
42
|
'-21': 'z',
|
|
@@ -61,19 +58,18 @@ const engineeringNotation = function (value) {
|
|
|
61
58
|
};
|
|
62
59
|
const exponentialNotation = num.toExponential(precision);
|
|
63
60
|
const power = exponentialNotation.split('e').map(Number)[1] || 0;
|
|
64
|
-
|
|
65
61
|
if (power < -24 || power > 24) {
|
|
66
62
|
return exponentialNotation;
|
|
67
63
|
}
|
|
68
|
-
|
|
69
64
|
const scaledPower = 3 * Math.floor(power / 3);
|
|
70
|
-
const scaledMantissa = (exponentialNotation / 10 ** scaledPower
|
|
71
|
-
|
|
65
|
+
const scaledMantissa = (exponentialNotation / 10 ** scaledPower
|
|
66
|
+
// strip trailing decimals from floating point rounding errors
|
|
67
|
+
).toFixed(precision)
|
|
68
|
+
// strip trailing 0s after a decimal point
|
|
72
69
|
.replace(/\.([1-9]*)0+$/, (_, fractionalDigits) => {
|
|
73
70
|
if (fractionalDigits) {
|
|
74
71
|
return `.${fractionalDigits}`;
|
|
75
72
|
}
|
|
76
|
-
|
|
77
73
|
return '';
|
|
78
74
|
});
|
|
79
75
|
return `${scaledMantissa}${allYourBase[scaledPower]}`;
|
|
@@ -9,10 +9,10 @@ const SERIES_NAME = {
|
|
|
9
9
|
[SERIES_NAME_LONG]: 'Series name long. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt interdum sapien ut blandit. Nulla fermentum nisi id euismod vulputate. END',
|
|
10
10
|
[SERIES_NAME_LONG_WITHOUT_SPACES]: 'Series_name_long._Lorem_ipsum_dolor_sit_amet,_consectetur_adipiscing_elit._Sed_tincidunt_interdum_sapien_ut_blandit._Nulla_fermentum_nisi_id_euismod_vulputate._END'
|
|
11
11
|
};
|
|
12
|
+
|
|
12
13
|
/**
|
|
13
14
|
* Builds the parameters object disable one or multiple controls.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
16
|
const disableControls = function () {
|
|
17
17
|
let controls = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
18
18
|
return Object.fromEntries(controls.map(control => [control, {
|
|
@@ -18,28 +18,21 @@ import emojiRegexFactory from 'emoji-regex';
|
|
|
18
18
|
* @param {string} string The string to split.
|
|
19
19
|
* @returns {string[]} The resulting strings.
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
21
|
const splitAfterSymbols = (symbols, string) => {
|
|
23
22
|
const textParts = [];
|
|
24
23
|
let textPartStartIndex = 0;
|
|
25
|
-
|
|
26
24
|
if (string.length === 0) {
|
|
27
25
|
return [string];
|
|
28
26
|
}
|
|
29
|
-
|
|
30
27
|
for (let i = 0; i < string.length;) {
|
|
31
28
|
let symbolFound = false;
|
|
32
|
-
|
|
33
29
|
for (let j = 0; j < symbols.length; j += 1) {
|
|
34
30
|
const symbol = symbols[j];
|
|
35
|
-
|
|
36
31
|
if (!symbol) {
|
|
37
32
|
// eslint-disable-next-line no-continue
|
|
38
33
|
continue;
|
|
39
34
|
}
|
|
40
|
-
|
|
41
35
|
symbolFound = string.slice(i, i + symbol.length) === symbol;
|
|
42
|
-
|
|
43
36
|
if (symbolFound) {
|
|
44
37
|
const textPartEndIndex = i + symbol.length;
|
|
45
38
|
const textPart = string.slice(textPartStartIndex, textPartEndIndex);
|
|
@@ -49,18 +42,14 @@ const splitAfterSymbols = (symbols, string) => {
|
|
|
49
42
|
break;
|
|
50
43
|
}
|
|
51
44
|
}
|
|
52
|
-
|
|
53
45
|
if (!symbolFound) {
|
|
54
46
|
i += 1;
|
|
55
47
|
}
|
|
56
48
|
}
|
|
57
|
-
|
|
58
49
|
const final = string.slice(textPartStartIndex);
|
|
59
|
-
|
|
60
50
|
if (final) {
|
|
61
51
|
textParts.push(final);
|
|
62
52
|
}
|
|
63
|
-
|
|
64
53
|
return textParts;
|
|
65
54
|
};
|
|
66
55
|
const startsWithEmojiRegex = `^(${emojiRegexFactory().source})`;
|
|
@@ -68,15 +57,12 @@ const getAvatarChar = name => {
|
|
|
68
57
|
if (name) {
|
|
69
58
|
// Check if string starts with an emoji (which could be multiple characters and zero-width joined)
|
|
70
59
|
const match = name.match(startsWithEmojiRegex);
|
|
71
|
-
|
|
72
60
|
if (match) {
|
|
73
61
|
// Return the first match
|
|
74
62
|
return match[0];
|
|
75
63
|
}
|
|
76
|
-
|
|
77
64
|
return name.charAt(0).toUpperCase();
|
|
78
65
|
}
|
|
79
|
-
|
|
80
66
|
return '';
|
|
81
67
|
};
|
|
82
68
|
|
package/dist/utils/test_utils.js
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
function setStoryTimeout(fn, timeout) {
|
|
6
6
|
return setTimeout(fn, process.env.IS_VISUAL_TEST ? 0 : timeout);
|
|
7
|
-
}
|
|
8
|
-
// https://github.com/bootstrap-vue/bootstrap-vue/blob/2fd03f0b1d0cc41f9930078ba8b1c16b10e4ac2f/tests/utils.js#L6
|
|
7
|
+
}
|
|
9
8
|
|
|
9
|
+
// adopted this method from Bootstraps utils
|
|
10
|
+
// https://github.com/bootstrap-vue/bootstrap-vue/blob/2fd03f0b1d0cc41f9930078ba8b1c16b10e4ac2f/tests/utils.js#L6
|
|
10
11
|
const waitForAnimationFrame = () => new Promise(resolve => {
|
|
11
12
|
requestAnimationFrame(resolve);
|
|
12
13
|
});
|
|
@@ -12,21 +12,17 @@ import MockDate from 'mockdate';
|
|
|
12
12
|
* mixins: [useFakeDate()],
|
|
13
13
|
* })
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
15
|
const useFakeDate = () => {
|
|
17
16
|
if (process.env.IS_VISUAL_TEST) {
|
|
18
17
|
return {
|
|
19
18
|
created() {
|
|
20
19
|
MockDate.set('2020-01-10', 0);
|
|
21
20
|
},
|
|
22
|
-
|
|
23
21
|
destroyed() {
|
|
24
22
|
MockDate.reset();
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
};
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
return {};
|
|
31
27
|
};
|
|
32
28
|
|
|
@@ -15,19 +15,16 @@ class MockObserver {
|
|
|
15
15
|
this.$_cb = cb;
|
|
16
16
|
this.$_observers = [];
|
|
17
17
|
}
|
|
18
|
-
|
|
19
18
|
observe(node) {
|
|
20
19
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
21
20
|
this.$_observers.push([node, options]);
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
disconnect() {
|
|
25
23
|
this.$_observers = [];
|
|
26
24
|
}
|
|
25
|
+
takeRecords() {}
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
// eslint-disable-next-line camelcase
|
|
31
28
|
$_triggerObserve(nodeParam) {
|
|
32
29
|
let {
|
|
33
30
|
entry = {},
|
|
@@ -42,9 +39,9 @@ class MockObserver {
|
|
|
42
39
|
}]);
|
|
43
40
|
}
|
|
44
41
|
});
|
|
45
|
-
}
|
|
46
|
-
|
|
42
|
+
}
|
|
47
43
|
|
|
44
|
+
// eslint-disable-next-line camelcase
|
|
48
45
|
$_hasObserver(node) {
|
|
49
46
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
50
47
|
return this.$_observers.some(_ref => {
|
|
@@ -52,7 +49,6 @@ class MockObserver {
|
|
|
52
49
|
return node === obvNode && _isMatch(options, obvOptions);
|
|
53
50
|
});
|
|
54
51
|
}
|
|
55
|
-
|
|
56
52
|
$_getNodesFromParam(nodeParam) {
|
|
57
53
|
if (!nodeParam) {
|
|
58
54
|
return this.$_observers.map(_ref2 => {
|
|
@@ -60,16 +56,12 @@ class MockObserver {
|
|
|
60
56
|
return node;
|
|
61
57
|
});
|
|
62
58
|
}
|
|
63
|
-
|
|
64
59
|
if (!_isArray(nodeParam)) {
|
|
65
60
|
return [nodeParam];
|
|
66
61
|
}
|
|
67
|
-
|
|
68
62
|
return nodeParam;
|
|
69
63
|
}
|
|
70
|
-
|
|
71
64
|
}
|
|
72
|
-
|
|
73
65
|
class MockIntersectionObserver extends MockObserver {
|
|
74
66
|
unobserve(node) {
|
|
75
67
|
this.$_observers = this.$_observers.filter(_ref3 => {
|
|
@@ -77,9 +69,7 @@ class MockIntersectionObserver extends MockObserver {
|
|
|
77
69
|
return node !== obvNode;
|
|
78
70
|
});
|
|
79
71
|
}
|
|
80
|
-
|
|
81
72
|
}
|
|
82
|
-
|
|
83
73
|
const useMockIntersectionObserver = () => {
|
|
84
74
|
let instances;
|
|
85
75
|
let origObserver;
|
|
@@ -90,7 +80,6 @@ const useMockIntersectionObserver = () => {
|
|
|
90
80
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
91
81
|
args[_key] = arguments[_key];
|
|
92
82
|
}
|
|
93
|
-
|
|
94
83
|
const mockObserver = new MockIntersectionObserver(...args);
|
|
95
84
|
instances.push(mockObserver);
|
|
96
85
|
return mockObserver;
|
|
@@ -100,19 +89,15 @@ const useMockIntersectionObserver = () => {
|
|
|
100
89
|
instances = [];
|
|
101
90
|
global.IntersectionObserver = origObserver;
|
|
102
91
|
});
|
|
103
|
-
|
|
104
92
|
const trigger = function (observer) {
|
|
105
93
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
106
94
|
args[_key2 - 1] = arguments[_key2];
|
|
107
95
|
}
|
|
108
|
-
|
|
109
96
|
observer.$_triggerObserve(...args);
|
|
110
97
|
};
|
|
111
|
-
|
|
112
98
|
const getInstances = () => {
|
|
113
99
|
return instances;
|
|
114
100
|
};
|
|
115
|
-
|
|
116
101
|
return {
|
|
117
102
|
getInstances,
|
|
118
103
|
trigger
|
package/dist/utils/utils.js
CHANGED
|
@@ -6,11 +6,9 @@ function debounceByAnimationFrame(fn) {
|
|
|
6
6
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
7
7
|
args[_key] = arguments[_key];
|
|
8
8
|
}
|
|
9
|
-
|
|
10
9
|
if (requestId) {
|
|
11
10
|
window.cancelAnimationFrame(requestId);
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
requestId = window.requestAnimationFrame(() => fn.apply(this, args));
|
|
15
13
|
};
|
|
16
14
|
}
|
|
@@ -20,11 +18,9 @@ function throttle(fn) {
|
|
|
20
18
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
21
19
|
args[_key2] = arguments[_key2];
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
if (frameId) {
|
|
25
22
|
return;
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
frameId = window.requestAnimationFrame(() => {
|
|
29
25
|
fn(...args);
|
|
30
26
|
frameId = null;
|
|
@@ -51,7 +47,6 @@ function colorFromBackground(backgroundColor) {
|
|
|
51
47
|
let r;
|
|
52
48
|
let g;
|
|
53
49
|
let b;
|
|
54
|
-
|
|
55
50
|
if (backgroundColor.startsWith('#')) {
|
|
56
51
|
[r, g, b] = rgbFromHex(backgroundColor);
|
|
57
52
|
} else if (backgroundColor.startsWith('rgba(')) {
|
|
@@ -59,16 +54,15 @@ function colorFromBackground(backgroundColor) {
|
|
|
59
54
|
} else if (backgroundColor.startsWith('rgb(')) {
|
|
60
55
|
[r, g, b] = rgbFromString(backgroundColor, 4);
|
|
61
56
|
}
|
|
62
|
-
|
|
63
57
|
if (r + g + b <= 500) {
|
|
64
58
|
return labelColorOptions.light;
|
|
65
59
|
}
|
|
66
|
-
|
|
67
60
|
return labelColorOptions.dark;
|
|
68
61
|
}
|
|
69
62
|
function uid() {
|
|
70
63
|
return Math.random().toString(36).substring(2);
|
|
71
64
|
}
|
|
65
|
+
|
|
72
66
|
/**
|
|
73
67
|
* Receives an element and validates that it can be focused
|
|
74
68
|
* @param { HTMLElement } The element we want to validate
|
|
@@ -87,6 +81,7 @@ function isElementFocusable(elt) {
|
|
|
87
81
|
const isInvalidAnchorTag = tagName === 'A' && !elt.getAttribute('href');
|
|
88
82
|
return isValidTag && hasValidType && !isDisabled && hasValidZIndex && !isInvalidAnchorTag;
|
|
89
83
|
}
|
|
84
|
+
|
|
90
85
|
/**
|
|
91
86
|
* Receives an array of HTML elements and focus the first one possible
|
|
92
87
|
* @param { Array.<HTMLElement> } An array of element to potentially focus
|
|
@@ -97,47 +92,43 @@ function focusFirstFocusableElement(elts) {
|
|
|
97
92
|
const focusableElt = elts.find(el => isElementFocusable(el));
|
|
98
93
|
if (focusableElt) focusableElt.focus();
|
|
99
94
|
}
|
|
95
|
+
|
|
100
96
|
/**
|
|
101
97
|
* Returns true if the current environment is considered a development environment (it's not
|
|
102
98
|
* production or test).
|
|
103
99
|
*
|
|
104
100
|
* @returns {boolean}
|
|
105
101
|
*/
|
|
106
|
-
|
|
107
102
|
function isDev() {
|
|
108
103
|
return !['test', 'production'].includes(process.env.NODE_ENV);
|
|
109
104
|
}
|
|
105
|
+
|
|
110
106
|
/**
|
|
111
107
|
* Prints a warning message to the console in non-test and non-production environments.
|
|
112
108
|
* @param {string} message message to print to the console
|
|
113
109
|
*/
|
|
114
|
-
|
|
115
110
|
function logWarning() {
|
|
116
111
|
let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
117
|
-
|
|
118
112
|
if (message.length && isDev()) {
|
|
119
113
|
console.warn(message); // eslint-disable-line no-console
|
|
120
114
|
}
|
|
121
115
|
}
|
|
116
|
+
|
|
122
117
|
/**
|
|
123
118
|
* Stop default event handling and propagation
|
|
124
119
|
*/
|
|
125
|
-
|
|
126
120
|
function stopEvent(event) {
|
|
127
121
|
let {
|
|
128
122
|
preventDefault = true,
|
|
129
123
|
stopPropagation = true,
|
|
130
124
|
stopImmediatePropagation = false
|
|
131
125
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
132
|
-
|
|
133
126
|
if (preventDefault) {
|
|
134
127
|
event.preventDefault();
|
|
135
128
|
}
|
|
136
|
-
|
|
137
129
|
if (stopPropagation) {
|
|
138
130
|
event.stopPropagation();
|
|
139
131
|
}
|
|
140
|
-
|
|
141
132
|
if (stopImmediatePropagation) {
|
|
142
133
|
event.stopImmediatePropagation();
|
|
143
134
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "49.0.
|
|
3
|
+
"version": "49.0.2",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@arkweid/lefthook": "0.7.7",
|
|
80
|
-
"@babel/core": "^7.19.
|
|
80
|
+
"@babel/core": "^7.19.6",
|
|
81
81
|
"@babel/preset-env": "^7.19.4",
|
|
82
82
|
"@gitlab/eslint-plugin": "18.1.0",
|
|
83
83
|
"@gitlab/stylelint-config": "4.1.0",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"bootstrap": "4.5.3",
|
|
105
105
|
"cypress": "^10.10.0",
|
|
106
106
|
"emoji-regex": "^10.0.0",
|
|
107
|
-
"eslint": "8.
|
|
107
|
+
"eslint": "8.26.0",
|
|
108
108
|
"eslint-import-resolver-jest": "3.0.2",
|
|
109
109
|
"eslint-plugin-cypress": "2.12.1",
|
|
110
110
|
"eslint-plugin-storybook": "0.6.6",
|
|
@@ -144,6 +144,7 @@ describe('base dropdown', () => {
|
|
|
144
144
|
await toggle.trigger('click');
|
|
145
145
|
expect(menu.classes('show')).toBe(true);
|
|
146
146
|
expect(toggle.attributes('aria-expanded')).toBe('true');
|
|
147
|
+
await nextTick();
|
|
147
148
|
expect(wrapper.emitted(GL_DROPDOWN_SHOWN).length).toBe(1);
|
|
148
149
|
|
|
149
150
|
// close menu clicking toggle btn again
|