@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
|
@@ -14,11 +14,9 @@ var script = {
|
|
|
14
14
|
chart: {
|
|
15
15
|
type: Object,
|
|
16
16
|
required: true,
|
|
17
|
-
|
|
18
17
|
validator(chart) {
|
|
19
18
|
return Object.is(chart, echarts.getInstanceByDom(chart.getDom()));
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
},
|
|
23
21
|
id: {
|
|
24
22
|
type: String,
|
|
@@ -57,20 +55,16 @@ var script = {
|
|
|
57
55
|
// `this.id` can be used to uniquely identify them
|
|
58
56
|
return `${this.chart.getDom().getAttribute('_echarts_instance_')}-tooltip-${this.id}`;
|
|
59
57
|
},
|
|
60
|
-
|
|
61
58
|
containerPosition() {
|
|
62
59
|
const props = ['top', 'bottom', 'left', 'right'];
|
|
63
60
|
return props.reduce((accumulator, prop) => {
|
|
64
61
|
const position = this[prop];
|
|
65
|
-
|
|
66
62
|
if (position) {
|
|
67
63
|
accumulator[prop] = position;
|
|
68
64
|
}
|
|
69
|
-
|
|
70
65
|
return accumulator;
|
|
71
66
|
}, {});
|
|
72
67
|
}
|
|
73
|
-
|
|
74
68
|
}
|
|
75
69
|
};
|
|
76
70
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { tooltipActionEvents } from '../../utils/constants';
|
|
2
2
|
|
|
3
|
+
// eslint-disable-next-line import/no-default-export
|
|
3
4
|
var tooltip_mixin = (tooltipRefName => ({
|
|
4
5
|
mounted() {
|
|
5
6
|
/**
|
|
@@ -12,11 +13,9 @@ var tooltip_mixin = (tooltipRefName => ({
|
|
|
12
13
|
*/
|
|
13
14
|
tooltipActionEvents.forEach(event => this.$on(event, () => this.$refs[tooltipRefName].$emit(event)));
|
|
14
15
|
},
|
|
15
|
-
|
|
16
16
|
beforeDestroy() {
|
|
17
17
|
tooltipActionEvents.forEach(event => this.$off(event));
|
|
18
18
|
}
|
|
19
|
-
|
|
20
19
|
}));
|
|
21
20
|
|
|
22
21
|
export default tooltip_mixin;
|
|
@@ -14,7 +14,6 @@ var script = {
|
|
|
14
14
|
required: false,
|
|
15
15
|
default: null
|
|
16
16
|
},
|
|
17
|
-
|
|
18
17
|
/**
|
|
19
18
|
* The illustration's URL.
|
|
20
19
|
*/
|
|
@@ -23,7 +22,6 @@ var script = {
|
|
|
23
22
|
required: false,
|
|
24
23
|
default: null
|
|
25
24
|
},
|
|
26
|
-
|
|
27
25
|
/**
|
|
28
26
|
* The illustration's height used to prevent content reflow.
|
|
29
27
|
*/
|
|
@@ -32,7 +30,6 @@ var script = {
|
|
|
32
30
|
required: false,
|
|
33
31
|
default: null
|
|
34
32
|
},
|
|
35
|
-
|
|
36
33
|
/**
|
|
37
34
|
* The desciption/body text of the empty state.
|
|
38
35
|
*/
|
|
@@ -41,7 +38,6 @@ var script = {
|
|
|
41
38
|
required: false,
|
|
42
39
|
default: null
|
|
43
40
|
},
|
|
44
|
-
|
|
45
41
|
/**
|
|
46
42
|
* The primary GlButton's href.
|
|
47
43
|
*/
|
|
@@ -50,7 +46,6 @@ var script = {
|
|
|
50
46
|
required: false,
|
|
51
47
|
default: null
|
|
52
48
|
},
|
|
53
|
-
|
|
54
49
|
/**
|
|
55
50
|
* The primary GlButton's text. If falsey, the button is not shown.
|
|
56
51
|
*/
|
|
@@ -59,7 +54,6 @@ var script = {
|
|
|
59
54
|
required: false,
|
|
60
55
|
default: null
|
|
61
56
|
},
|
|
62
|
-
|
|
63
57
|
/**
|
|
64
58
|
* The secondary GlButton's href.
|
|
65
59
|
*/
|
|
@@ -68,7 +62,6 @@ var script = {
|
|
|
68
62
|
required: false,
|
|
69
63
|
default: null
|
|
70
64
|
},
|
|
71
|
-
|
|
72
65
|
/**
|
|
73
66
|
* The secondary GlButton's text. If falsey, the button is not shown.
|
|
74
67
|
*/
|
|
@@ -77,7 +70,6 @@ var script = {
|
|
|
77
70
|
required: false,
|
|
78
71
|
default: null
|
|
79
72
|
},
|
|
80
|
-
|
|
81
73
|
/**
|
|
82
74
|
* Determines whether to render the compact layout.
|
|
83
75
|
*/
|
|
@@ -96,19 +88,15 @@ var script = {
|
|
|
96
88
|
height() {
|
|
97
89
|
return this.shouldPreventImageReflow ? this.svgHeight : null;
|
|
98
90
|
},
|
|
99
|
-
|
|
100
91
|
shouldPreventImageReflow() {
|
|
101
92
|
return Boolean(this.svgHeight);
|
|
102
93
|
},
|
|
103
|
-
|
|
104
94
|
shouldRenderPrimaryButton() {
|
|
105
95
|
return Boolean(this.primaryButtonLink && this.primaryButtonText);
|
|
106
96
|
},
|
|
107
|
-
|
|
108
97
|
shouldRenderSecondaryButton() {
|
|
109
98
|
return Boolean(this.secondaryButtonLink && this.secondaryButtonText);
|
|
110
99
|
}
|
|
111
|
-
|
|
112
100
|
}
|
|
113
101
|
};
|
|
114
102
|
|
|
@@ -7,7 +7,6 @@ var script = {
|
|
|
7
7
|
type: Number,
|
|
8
8
|
required: true
|
|
9
9
|
},
|
|
10
|
-
|
|
11
10
|
/**
|
|
12
11
|
* Controls how long it takes for the animation to complete.
|
|
13
12
|
*/
|
|
@@ -16,7 +15,6 @@ var script = {
|
|
|
16
15
|
required: false,
|
|
17
16
|
default: 2000
|
|
18
17
|
},
|
|
19
|
-
|
|
20
18
|
/**
|
|
21
19
|
* Controls the number of decimal places displayed in the output.
|
|
22
20
|
*/
|
|
@@ -31,32 +29,25 @@ var script = {
|
|
|
31
29
|
default: false
|
|
32
30
|
}
|
|
33
31
|
},
|
|
34
|
-
|
|
35
32
|
data() {
|
|
36
33
|
return {
|
|
37
34
|
displayNumber: 0,
|
|
38
35
|
startTime: null
|
|
39
36
|
};
|
|
40
37
|
},
|
|
41
|
-
|
|
42
38
|
computed: {
|
|
43
39
|
animatedNumber() {
|
|
44
40
|
return this.displayNumber.toFixed(this.decimalPlaces);
|
|
45
41
|
}
|
|
46
|
-
|
|
47
42
|
},
|
|
48
|
-
|
|
49
43
|
ready() {
|
|
50
44
|
this.displayNumber = this.number ? this.number : 0;
|
|
51
45
|
},
|
|
52
|
-
|
|
53
46
|
watch: {
|
|
54
47
|
number() {
|
|
55
48
|
this.animate();
|
|
56
49
|
}
|
|
57
|
-
|
|
58
50
|
},
|
|
59
|
-
|
|
60
51
|
mounted() {
|
|
61
52
|
if (this.animateOnMount) {
|
|
62
53
|
this.animate();
|
|
@@ -64,35 +55,28 @@ var script = {
|
|
|
64
55
|
this.displayNumber = this.number;
|
|
65
56
|
}
|
|
66
57
|
},
|
|
67
|
-
|
|
68
58
|
methods: {
|
|
69
59
|
animate() {
|
|
70
60
|
this.$emit('animating');
|
|
71
61
|
window.requestAnimationFrame(this.count);
|
|
72
62
|
},
|
|
73
|
-
|
|
74
63
|
count(timestamp) {
|
|
75
64
|
if (!this.startTime) {
|
|
76
65
|
this.startTime = timestamp;
|
|
77
66
|
}
|
|
78
|
-
|
|
79
67
|
const progress = timestamp - this.startTime;
|
|
80
|
-
|
|
81
68
|
if (progress < this.duration) {
|
|
82
69
|
if (this.displayNumber !== this.number) {
|
|
83
70
|
const change = (this.number - this.displayNumber) / (this.duration / 100);
|
|
84
71
|
this.displayNumber += change;
|
|
85
72
|
}
|
|
86
|
-
|
|
87
73
|
window.requestAnimationFrame(this.count);
|
|
88
74
|
} else {
|
|
89
75
|
this.displayNumber = this.number; // Ensures that the final number is accurate.
|
|
90
|
-
|
|
91
76
|
this.startTime = null;
|
|
92
77
|
this.$emit('animated');
|
|
93
78
|
}
|
|
94
79
|
}
|
|
95
|
-
|
|
96
80
|
}
|
|
97
81
|
};
|
|
98
82
|
|
|
@@ -12,7 +12,6 @@ var script = {
|
|
|
12
12
|
type: String,
|
|
13
13
|
required: true
|
|
14
14
|
},
|
|
15
|
-
|
|
16
15
|
/**
|
|
17
16
|
* A list of strings representing the break-words.
|
|
18
17
|
*/
|
|
@@ -22,7 +21,6 @@ var script = {
|
|
|
22
21
|
default: () => ['/']
|
|
23
22
|
}
|
|
24
23
|
},
|
|
25
|
-
|
|
26
24
|
render(createElement, _ref) {
|
|
27
25
|
let {
|
|
28
26
|
props
|
|
@@ -37,7 +35,6 @@ var script = {
|
|
|
37
35
|
class: 'text-break'
|
|
38
36
|
}, content);
|
|
39
37
|
}
|
|
40
|
-
|
|
41
38
|
};
|
|
42
39
|
|
|
43
40
|
/* script */
|
|
@@ -6,7 +6,6 @@ const getObserver = _memoize(options => new IntersectionObserver(entries => {
|
|
|
6
6
|
entry.target.$_gl_intersectionHandler(entry);
|
|
7
7
|
});
|
|
8
8
|
}, options || {}));
|
|
9
|
-
|
|
10
9
|
var script = {
|
|
11
10
|
name: 'GlIntersectionObserver',
|
|
12
11
|
props: {
|
|
@@ -19,16 +18,13 @@ var script = {
|
|
|
19
18
|
default: null
|
|
20
19
|
}
|
|
21
20
|
},
|
|
22
|
-
|
|
23
21
|
mounted() {
|
|
24
22
|
const observer = getObserver(this.options);
|
|
25
|
-
|
|
26
23
|
this.$el.$_gl_intersectionHandler = entry => {
|
|
27
24
|
/**
|
|
28
25
|
* Emitted when the element's visibility changes
|
|
29
26
|
*/
|
|
30
27
|
this.$emit('update', entry);
|
|
31
|
-
|
|
32
28
|
if (entry.isIntersecting) {
|
|
33
29
|
/**
|
|
34
30
|
* Emitted when the element appears on the page
|
|
@@ -41,17 +37,14 @@ var script = {
|
|
|
41
37
|
this.$emit('disappear');
|
|
42
38
|
}
|
|
43
39
|
};
|
|
44
|
-
|
|
45
40
|
this.$el.$_gl_intersectionObserver = observer;
|
|
46
41
|
observer.observe(this.$el);
|
|
47
42
|
},
|
|
48
|
-
|
|
49
43
|
destroyed() {
|
|
50
44
|
this.$el.$_gl_intersectionObserver.unobserve(this.$el);
|
|
51
45
|
delete this.$el.$_gl_intersectionHandler;
|
|
52
46
|
delete this.$el.$_gl_intersectionObserver;
|
|
53
47
|
},
|
|
54
|
-
|
|
55
48
|
// Expose getObserver method for tests
|
|
56
49
|
getObserver
|
|
57
50
|
};
|
|
@@ -5,25 +5,21 @@ import { insert, intersperse } from '../../../utils/data_utils';
|
|
|
5
5
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
6
6
|
|
|
7
7
|
//
|
|
8
|
-
|
|
9
8
|
const containsWhitespaceOnly = vNode => vNode.text.trim() === '';
|
|
10
|
-
|
|
11
9
|
const isTag = vNode => typeof vNode.tag === 'string';
|
|
12
|
-
|
|
13
10
|
const filterWhitespaceNodes = filter(vNode => isTag(vNode) || !containsWhitespaceOnly(vNode));
|
|
14
11
|
const insertAfterSecondLastItem = insert(-1);
|
|
15
|
-
const replaceSecondLastItem = fill(-2, -1);
|
|
12
|
+
const replaceSecondLastItem = fill(-2, -1);
|
|
13
|
+
|
|
14
|
+
// handles the addition of the lastSeparator in these two cases:
|
|
16
15
|
// item1, item2, item3 => item1, item2, and item3
|
|
17
16
|
// item1, item2 => item1 and item2
|
|
18
|
-
|
|
19
17
|
const addLastSeparator = lastSeparator => items => {
|
|
20
18
|
if (!lastSeparator) {
|
|
21
19
|
return items;
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
return items.length > 3 ? insertAfterSecondLastItem(lastSeparator, items) : replaceSecondLastItem(lastSeparator, items);
|
|
25
22
|
};
|
|
26
|
-
|
|
27
23
|
var script = {
|
|
28
24
|
functional: true,
|
|
29
25
|
props: {
|
|
@@ -38,7 +34,6 @@ var script = {
|
|
|
38
34
|
required: false
|
|
39
35
|
}
|
|
40
36
|
},
|
|
41
|
-
|
|
42
37
|
render(createElement, context) {
|
|
43
38
|
const {
|
|
44
39
|
props: {
|
|
@@ -51,7 +46,6 @@ var script = {
|
|
|
51
46
|
const filterAndSeparate = compose(addLastSeparator(lastSeparator), intersperse(separator), filterWhitespaceNodes);
|
|
52
47
|
return createElement('span', data, filterAndSeparate(slots().default));
|
|
53
48
|
}
|
|
54
|
-
|
|
55
49
|
};
|
|
56
50
|
|
|
57
51
|
/* script */
|
|
@@ -7,7 +7,6 @@ const SUFFIX = '}';
|
|
|
7
7
|
const START_SUFFIX = 'Start';
|
|
8
8
|
const END_SUFFIX = 'End';
|
|
9
9
|
const PLACE_HOLDER_REGEX = new RegExp(`(${PREFIX}[a-z]+[\\w-]*[a-z0-9]+${SUFFIX})`, 'gi');
|
|
10
|
-
|
|
11
10
|
function groupPlaceholdersByStartTag() {
|
|
12
11
|
let placeholders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
13
12
|
return Object.entries(placeholders).reduce((acc, _ref) => {
|
|
@@ -19,17 +18,15 @@ function groupPlaceholdersByStartTag() {
|
|
|
19
18
|
return acc;
|
|
20
19
|
}, {});
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
function getPlaceholderDefinition(chunk, placeholdersByStartTag) {
|
|
24
22
|
const tagName = chunk.slice(PREFIX.length, -SUFFIX.length);
|
|
25
|
-
|
|
26
23
|
if (_has(placeholdersByStartTag, tagName)) {
|
|
27
24
|
// Use provided custom placeholder definition
|
|
28
|
-
return {
|
|
25
|
+
return {
|
|
26
|
+
...placeholdersByStartTag[tagName],
|
|
29
27
|
tagName
|
|
30
28
|
};
|
|
31
29
|
}
|
|
32
|
-
|
|
33
30
|
if (tagName.endsWith(START_SUFFIX)) {
|
|
34
31
|
// Tag conforms to default start/end tag naming convention
|
|
35
32
|
const slotName = tagName.slice(0, -START_SUFFIX.length);
|
|
@@ -39,14 +36,12 @@ function getPlaceholderDefinition(chunk, placeholdersByStartTag) {
|
|
|
39
36
|
tagName
|
|
40
37
|
};
|
|
41
38
|
}
|
|
42
|
-
|
|
43
39
|
return {
|
|
44
40
|
slotName: tagName,
|
|
45
41
|
endTag: undefined,
|
|
46
42
|
tagName
|
|
47
43
|
};
|
|
48
44
|
}
|
|
49
|
-
|
|
50
45
|
var script = {
|
|
51
46
|
functional: true,
|
|
52
47
|
props: {
|
|
@@ -57,7 +52,6 @@ var script = {
|
|
|
57
52
|
type: String,
|
|
58
53
|
required: true
|
|
59
54
|
},
|
|
60
|
-
|
|
61
55
|
/**
|
|
62
56
|
* An object mapping slot names to custom start/end placeholders. Use this
|
|
63
57
|
* to avoid changing an existing message, and in turn invalidating existing
|
|
@@ -70,7 +64,6 @@ var script = {
|
|
|
70
64
|
validator: value => Object.values(value).every(tagPair => Array.isArray(tagPair) && tagPair.length === 2 && tagPair.every(_isString))
|
|
71
65
|
}
|
|
72
66
|
},
|
|
73
|
-
|
|
74
67
|
/**
|
|
75
68
|
* Available slots are determined by the placeholders in the provided
|
|
76
69
|
* message prop. For example, a message of "Written by %{author}" has
|
|
@@ -88,61 +81,54 @@ var script = {
|
|
|
88
81
|
// This approach is also more performant, as it minimizes (relatively) object
|
|
89
82
|
// creation/garbage collection, which is important given how frequently this
|
|
90
83
|
// code may run on a given page.
|
|
84
|
+
|
|
91
85
|
let i = 0;
|
|
92
86
|
const vnodes = [];
|
|
93
87
|
const slots = context.scopedSlots;
|
|
94
88
|
const chunks = context.props.message.split(PLACE_HOLDER_REGEX);
|
|
95
89
|
const placeholdersByStartTag = groupPlaceholdersByStartTag(context.props.placeholders);
|
|
96
|
-
|
|
97
90
|
while (i < chunks.length) {
|
|
98
|
-
const chunk = chunks[i];
|
|
99
|
-
|
|
91
|
+
const chunk = chunks[i];
|
|
92
|
+
// Skip past this chunk now we have it
|
|
100
93
|
i += 1;
|
|
101
|
-
|
|
102
94
|
if (!PLACE_HOLDER_REGEX.test(chunk)) {
|
|
103
95
|
// Not a placeholder, so pass through as-is
|
|
104
96
|
vnodes.push(chunk);
|
|
105
97
|
continue;
|
|
106
98
|
}
|
|
107
|
-
|
|
108
99
|
const {
|
|
109
100
|
slotName,
|
|
110
101
|
endTag,
|
|
111
102
|
tagName
|
|
112
103
|
} = getPlaceholderDefinition(chunk, placeholdersByStartTag);
|
|
113
|
-
|
|
114
104
|
if (endTag) {
|
|
115
105
|
// Peek ahead to find end placeholder, if any
|
|
116
106
|
const indexOfEnd = chunks.indexOf(`${PREFIX}${endTag}${SUFFIX}`, i);
|
|
117
|
-
|
|
118
107
|
if (indexOfEnd > -1) {
|
|
119
108
|
// We have a valid start/end placeholder pair! Extract the content
|
|
120
109
|
// between them and skip past the end placeholder
|
|
121
110
|
const content = chunks.slice(i, indexOfEnd);
|
|
122
111
|
i = indexOfEnd + 1;
|
|
123
|
-
|
|
124
112
|
if (!_has(slots, slotName)) {
|
|
125
113
|
// Slot hasn't been provided; return placeholders and content as-is
|
|
126
114
|
vnodes.push(chunk, ...content, chunks[indexOfEnd]);
|
|
127
115
|
continue;
|
|
128
|
-
}
|
|
129
|
-
|
|
116
|
+
}
|
|
130
117
|
|
|
118
|
+
// Provide content to provided scoped slot
|
|
131
119
|
vnodes.push(slots[slotName]({
|
|
132
120
|
content: content.join('')
|
|
133
121
|
}));
|
|
134
122
|
continue;
|
|
135
123
|
}
|
|
136
|
-
}
|
|
137
|
-
|
|
124
|
+
}
|
|
138
125
|
|
|
126
|
+
// By process of elimination, chunk must be a plain placeholder
|
|
139
127
|
vnodes.push(_has(slots, tagName) ? slots[tagName]() : chunk);
|
|
140
128
|
continue;
|
|
141
129
|
}
|
|
142
|
-
|
|
143
130
|
return vnodes;
|
|
144
131
|
}
|
|
145
|
-
|
|
146
132
|
};
|
|
147
133
|
|
|
148
134
|
/* script */
|
|
@@ -18,7 +18,6 @@ var script = {
|
|
|
18
18
|
type: String,
|
|
19
19
|
required: true
|
|
20
20
|
},
|
|
21
|
-
|
|
22
21
|
/**
|
|
23
22
|
* Ellipsis position
|
|
24
23
|
*/
|
|
@@ -28,7 +27,6 @@ var script = {
|
|
|
28
27
|
default: POSITION.END,
|
|
29
28
|
validator: value => Object.values(POSITION).includes(value)
|
|
30
29
|
},
|
|
31
|
-
|
|
32
30
|
/**
|
|
33
31
|
* Display the full text in a tooltip only if it is being truncated
|
|
34
32
|
*/
|
|
@@ -38,30 +36,24 @@ var script = {
|
|
|
38
36
|
default: false
|
|
39
37
|
}
|
|
40
38
|
},
|
|
41
|
-
|
|
42
39
|
data() {
|
|
43
40
|
return {
|
|
44
41
|
isTruncated: false
|
|
45
42
|
};
|
|
46
43
|
},
|
|
47
|
-
|
|
48
44
|
computed: {
|
|
49
45
|
middleIndex() {
|
|
50
46
|
return Math.floor(this.text.length / 2);
|
|
51
47
|
},
|
|
52
|
-
|
|
53
48
|
first() {
|
|
54
49
|
return this.text.slice(0, this.middleIndex);
|
|
55
50
|
},
|
|
56
|
-
|
|
57
51
|
last() {
|
|
58
52
|
return this.text.slice(this.middleIndex);
|
|
59
53
|
},
|
|
60
|
-
|
|
61
54
|
isTooltipDisabled() {
|
|
62
55
|
return !this.withTooltip || !this.isTruncated;
|
|
63
56
|
}
|
|
64
|
-
|
|
65
57
|
},
|
|
66
58
|
watch: {
|
|
67
59
|
withTooltip(withTooltip) {
|
|
@@ -69,7 +61,6 @@ var script = {
|
|
|
69
61
|
this.checkTruncationState();
|
|
70
62
|
}
|
|
71
63
|
}
|
|
72
|
-
|
|
73
64
|
},
|
|
74
65
|
methods: {
|
|
75
66
|
checkTruncationState() {
|
|
@@ -77,7 +68,6 @@ var script = {
|
|
|
77
68
|
this.isTruncated = this.$refs.text.scrollWidth > this.$refs.text.offsetWidth;
|
|
78
69
|
}
|
|
79
70
|
}
|
|
80
|
-
|
|
81
71
|
}
|
|
82
72
|
};
|
|
83
73
|
|
package/dist/config.js
CHANGED
|
@@ -9,6 +9,7 @@ const tooltipGlobalConfig = {
|
|
|
9
9
|
customClass: 'gl-tooltip',
|
|
10
10
|
delay: tooltipDelay
|
|
11
11
|
};
|
|
12
|
+
|
|
12
13
|
/**
|
|
13
14
|
* Guard against nonexistent localStorage,
|
|
14
15
|
* or corrupted localStorage
|
|
@@ -17,16 +18,14 @@ const tooltipGlobalConfig = {
|
|
|
17
18
|
* - in iframe usage in Chrome if embedded on another domain
|
|
18
19
|
* - tests / node
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
21
|
try {
|
|
22
22
|
const glTooltipDelay = localStorage.getItem('gl-tooltip-delay');
|
|
23
|
-
|
|
24
23
|
if (glTooltipDelay) {
|
|
25
24
|
tooltipGlobalConfig.delay = JSON.parse(glTooltipDelay);
|
|
26
25
|
}
|
|
27
|
-
} catch (e) {
|
|
26
|
+
} catch (e) {
|
|
27
|
+
// localStorage doesn't exist (or the value is not properly formatted)
|
|
28
28
|
}
|
|
29
|
-
|
|
30
29
|
const setConfigs = () => {
|
|
31
30
|
Vue.use(BVConfigPlugin, {
|
|
32
31
|
BFormText: bFormTextGlobalConfig,
|
|
@@ -3,46 +3,40 @@ import isFunction from 'lodash/isFunction';
|
|
|
3
3
|
const DELAY_ON_HOVER = 100;
|
|
4
4
|
let mouseOverTimer;
|
|
5
5
|
let mouseOverHandler;
|
|
6
|
-
|
|
7
6
|
const bind = (el, _ref) => {
|
|
8
7
|
let {
|
|
9
8
|
value: loadHandler
|
|
10
9
|
} = _ref;
|
|
11
|
-
|
|
12
10
|
if (!isFunction(loadHandler)) {
|
|
13
11
|
throw TypeError('Directive value must be a function');
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
const mouseOutHandler = () => {
|
|
17
14
|
if (mouseOverTimer) {
|
|
18
15
|
clearTimeout(mouseOverTimer);
|
|
19
16
|
mouseOverTimer = undefined;
|
|
20
17
|
}
|
|
21
18
|
};
|
|
22
|
-
|
|
23
19
|
mouseOverHandler = () => {
|
|
24
20
|
el.addEventListener('mouseout', mouseOutHandler, {
|
|
25
21
|
passive: true
|
|
26
22
|
});
|
|
27
23
|
mouseOverTimer = setTimeout(() => {
|
|
28
|
-
loadHandler(el);
|
|
24
|
+
loadHandler(el);
|
|
29
25
|
|
|
26
|
+
// Only execute once
|
|
30
27
|
el.removeEventListener('mouseover', mouseOverHandler, true);
|
|
31
28
|
el.removeEventListener('mouseout', mouseOutHandler);
|
|
32
29
|
mouseOverTimer = undefined;
|
|
33
30
|
}, DELAY_ON_HOVER);
|
|
34
31
|
};
|
|
35
|
-
|
|
36
32
|
el.addEventListener('mouseover', mouseOverHandler, {
|
|
37
33
|
capture: true,
|
|
38
34
|
passive: true
|
|
39
35
|
});
|
|
40
36
|
};
|
|
41
|
-
|
|
42
37
|
const unbind = el => {
|
|
43
38
|
el.removeEventListener('mouseover', mouseOverHandler, true);
|
|
44
39
|
};
|
|
45
|
-
|
|
46
40
|
const HoverLoadDirective = {
|
|
47
41
|
bind,
|
|
48
42
|
unbind
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
*
|
|
5
5
|
* See the LICENSE file in this directory.
|
|
6
6
|
*/
|
|
7
|
+
|
|
7
8
|
const {
|
|
8
9
|
performance
|
|
9
10
|
} = window;
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* Get a current timestamp that can be meaningfully compared to an event's
|
|
12
14
|
* `timeStamp` property.
|
|
@@ -22,8 +24,8 @@ const {
|
|
|
22
24
|
*
|
|
23
25
|
* @returns {number}
|
|
24
26
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
const getEventLikeTimeStamp =
|
|
28
|
+
// If the event timestamp, although evaluated AFTER the Date.now(), is
|
|
27
29
|
// smaller, it means the event is using a hi-res timestamp, and we need to
|
|
28
30
|
// use the hi-res version for event listener timestamps as well.
|
|
29
31
|
typeof (performance === null || performance === void 0 ? void 0 : performance.now) === 'function' && Date.now() > document.createEvent('Event').timeStamp ? () => performance.now() : () => Date.now();
|