@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
|
@@ -5,11 +5,11 @@ import CloseButton from '../../shared_components/close_button/close_button';
|
|
|
5
5
|
const DEFAULT_OPTIONS = {
|
|
6
6
|
autoHideDelay: 5000,
|
|
7
7
|
toastClass: 'gl-toast',
|
|
8
|
+
isStatus: true,
|
|
8
9
|
noCloseButton: true,
|
|
9
10
|
toaster: 'b-toaster-bottom-left'
|
|
10
11
|
};
|
|
11
12
|
let toastsCount = 0;
|
|
12
|
-
|
|
13
13
|
function renderTitle(h, toast, options) {
|
|
14
14
|
const nodes = [h(CloseButton, {
|
|
15
15
|
class: ['gl-toast-close-button', 'gl-close-btn-color-inherit'],
|
|
@@ -17,7 +17,6 @@ function renderTitle(h, toast, options) {
|
|
|
17
17
|
click: toast.hide
|
|
18
18
|
}
|
|
19
19
|
})];
|
|
20
|
-
|
|
21
20
|
if (options.action) {
|
|
22
21
|
nodes.splice(0, 0, h('a', {
|
|
23
22
|
role: 'button',
|
|
@@ -27,24 +26,19 @@ function renderTitle(h, toast, options) {
|
|
|
27
26
|
}
|
|
28
27
|
}, options.action.text));
|
|
29
28
|
}
|
|
30
|
-
|
|
31
29
|
return nodes;
|
|
32
30
|
}
|
|
33
|
-
|
|
34
31
|
function showToast(message) {
|
|
35
32
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
36
33
|
const id = `gl-toast-${toastsCount}`;
|
|
37
34
|
toastsCount += 1;
|
|
38
|
-
|
|
39
35
|
const hide = () => {
|
|
40
36
|
this.$bvToast.hide(id);
|
|
41
37
|
};
|
|
42
|
-
|
|
43
38
|
const toast = {
|
|
44
39
|
id,
|
|
45
40
|
hide
|
|
46
41
|
};
|
|
47
|
-
|
|
48
42
|
if (_isFunction(options.onComplete)) {
|
|
49
43
|
const toastHiddenCallback = e => {
|
|
50
44
|
if (e.componentId === id) {
|
|
@@ -52,24 +46,22 @@ function showToast(message) {
|
|
|
52
46
|
options.onComplete(e);
|
|
53
47
|
}
|
|
54
48
|
};
|
|
55
|
-
|
|
56
49
|
this.$root.$on('bv::toast:hidden', toastHiddenCallback);
|
|
57
50
|
}
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
this.$bvToast.toast(message, {
|
|
52
|
+
...DEFAULT_OPTIONS,
|
|
60
53
|
id,
|
|
61
54
|
title: renderTitle(this.$createElement, toast, options)
|
|
62
55
|
});
|
|
63
56
|
return toast;
|
|
64
57
|
}
|
|
58
|
+
|
|
65
59
|
/**
|
|
66
60
|
* Note: This is not a typical Vue component and needs to be registered before instantiating a Vue app.
|
|
67
61
|
* Once registered, the toast will be globally available throughout your app.
|
|
68
62
|
*
|
|
69
63
|
* See https://gitlab-org.gitlab.io/gitlab-ui/ for detailed documentation.
|
|
70
64
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
65
|
var toast = {
|
|
74
66
|
install(Vue) {
|
|
75
67
|
Vue.use(ToastPlugin);
|
|
@@ -78,15 +70,12 @@ var toast = {
|
|
|
78
70
|
if (this.$toast) {
|
|
79
71
|
return;
|
|
80
72
|
}
|
|
81
|
-
|
|
82
73
|
this.$toast = {
|
|
83
74
|
show: showToast.bind(this)
|
|
84
75
|
};
|
|
85
76
|
}
|
|
86
|
-
|
|
87
77
|
});
|
|
88
78
|
}
|
|
89
|
-
|
|
90
79
|
};
|
|
91
80
|
|
|
92
81
|
export default toast;
|
|
@@ -20,7 +20,6 @@ var script = {
|
|
|
20
20
|
required: false,
|
|
21
21
|
default: null
|
|
22
22
|
},
|
|
23
|
-
|
|
24
23
|
/**
|
|
25
24
|
* The toggle's state.
|
|
26
25
|
* @model
|
|
@@ -30,7 +29,6 @@ var script = {
|
|
|
30
29
|
required: false,
|
|
31
30
|
default: null
|
|
32
31
|
},
|
|
33
|
-
|
|
34
32
|
/**
|
|
35
33
|
* Whether the toggle should be disabled.
|
|
36
34
|
*/
|
|
@@ -39,7 +37,6 @@ var script = {
|
|
|
39
37
|
required: false,
|
|
40
38
|
default: false
|
|
41
39
|
},
|
|
42
|
-
|
|
43
40
|
/**
|
|
44
41
|
* Whether the toggle is in the loading state.
|
|
45
42
|
*/
|
|
@@ -48,7 +45,6 @@ var script = {
|
|
|
48
45
|
required: false,
|
|
49
46
|
default: false
|
|
50
47
|
},
|
|
51
|
-
|
|
52
48
|
/**
|
|
53
49
|
* The toggle's label.
|
|
54
50
|
*/
|
|
@@ -56,7 +52,6 @@ var script = {
|
|
|
56
52
|
type: String,
|
|
57
53
|
required: true
|
|
58
54
|
},
|
|
59
|
-
|
|
60
55
|
/**
|
|
61
56
|
* A help text to be shown below the toggle.
|
|
62
57
|
*/
|
|
@@ -65,7 +60,6 @@ var script = {
|
|
|
65
60
|
required: false,
|
|
66
61
|
default: undefined
|
|
67
62
|
},
|
|
68
|
-
|
|
69
63
|
/**
|
|
70
64
|
* The label's position relative to the toggle. If 'hidden', the toggle will add the .gl-sr-only class so the label is still accessible to screen readers.
|
|
71
65
|
*/
|
|
@@ -73,49 +67,38 @@ var script = {
|
|
|
73
67
|
type: String,
|
|
74
68
|
required: false,
|
|
75
69
|
default: 'top',
|
|
76
|
-
|
|
77
70
|
validator(position) {
|
|
78
71
|
return Object.values(toggleLabelPosition).includes(position);
|
|
79
72
|
}
|
|
80
|
-
|
|
81
73
|
}
|
|
82
74
|
},
|
|
83
|
-
|
|
84
75
|
data() {
|
|
85
76
|
return {
|
|
86
77
|
labelId: _uniqueId('toggle-label-')
|
|
87
78
|
};
|
|
88
79
|
},
|
|
89
|
-
|
|
90
80
|
computed: {
|
|
91
81
|
shouldRenderHelp() {
|
|
92
82
|
// eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
|
|
93
83
|
return Boolean(this.$slots.help || this.help) && this.isVerticalLayout;
|
|
94
84
|
},
|
|
95
|
-
|
|
96
85
|
icon() {
|
|
97
86
|
return this.value ? 'mobile-issue-close' : 'close';
|
|
98
87
|
},
|
|
99
|
-
|
|
100
88
|
helpId() {
|
|
101
89
|
return this.shouldRenderHelp ? `toggle-help-${this.uuid}` : undefined;
|
|
102
90
|
},
|
|
103
|
-
|
|
104
91
|
isChecked() {
|
|
105
92
|
return this.value ? 'true' : 'false';
|
|
106
93
|
},
|
|
107
|
-
|
|
108
94
|
isVerticalLayout() {
|
|
109
95
|
return this.labelPosition === 'top' || this.labelPosition === 'hidden';
|
|
110
96
|
}
|
|
111
|
-
|
|
112
97
|
},
|
|
113
|
-
|
|
114
98
|
beforeCreate() {
|
|
115
99
|
this.uuid = uuid;
|
|
116
100
|
uuid += 1;
|
|
117
101
|
},
|
|
118
|
-
|
|
119
102
|
methods: {
|
|
120
103
|
toggleFeature() {
|
|
121
104
|
if (!this.disabled) {
|
|
@@ -128,7 +111,6 @@ var script = {
|
|
|
128
111
|
this.$emit('change', !this.value);
|
|
129
112
|
}
|
|
130
113
|
}
|
|
131
|
-
|
|
132
114
|
}
|
|
133
115
|
};
|
|
134
116
|
|
|
@@ -13,7 +13,6 @@ var script = {
|
|
|
13
13
|
required: false,
|
|
14
14
|
default: false
|
|
15
15
|
},
|
|
16
|
-
|
|
17
16
|
/**
|
|
18
17
|
* Token visual variants: default, search-type, and search-value.
|
|
19
18
|
*/
|
|
@@ -28,13 +27,11 @@ var script = {
|
|
|
28
27
|
variantClass() {
|
|
29
28
|
return `gl-token-${this.variant}-variant`;
|
|
30
29
|
},
|
|
31
|
-
|
|
32
30
|
viewOnlyClass() {
|
|
33
31
|
return {
|
|
34
32
|
'gl-token-view-only': this.viewOnly
|
|
35
33
|
};
|
|
36
34
|
}
|
|
37
|
-
|
|
38
35
|
},
|
|
39
36
|
methods: {
|
|
40
37
|
close($event) {
|
|
@@ -45,7 +42,6 @@ var script = {
|
|
|
45
42
|
*/
|
|
46
43
|
this.$emit('close', $event);
|
|
47
44
|
}
|
|
48
|
-
|
|
49
45
|
}
|
|
50
46
|
};
|
|
51
47
|
|
|
@@ -36,30 +36,24 @@ var script = {
|
|
|
36
36
|
default: false
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
-
|
|
40
39
|
data() {
|
|
41
40
|
return {
|
|
42
41
|
bindFocusEvent: true,
|
|
43
42
|
focusedTokenIndex: null
|
|
44
43
|
};
|
|
45
44
|
},
|
|
46
|
-
|
|
47
45
|
computed: {
|
|
48
46
|
focusedToken() {
|
|
49
47
|
return this.tokens[this.focusedTokenIndex] || null;
|
|
50
48
|
}
|
|
51
|
-
|
|
52
49
|
},
|
|
53
50
|
watch: {
|
|
54
51
|
focusedToken(newValue) {
|
|
55
52
|
var _this$$refs$tokens;
|
|
56
|
-
|
|
57
53
|
if (newValue === null) {
|
|
58
54
|
return;
|
|
59
55
|
}
|
|
60
|
-
|
|
61
56
|
const tokenRef = (_this$$refs$tokens = this.$refs.tokens) === null || _this$$refs$tokens === void 0 ? void 0 : _this$$refs$tokens.find(ref => ref.dataset.tokenId === newValue.id.toString());
|
|
62
|
-
|
|
63
57
|
if (tokenRef) {
|
|
64
58
|
// Prevent `handleTokenFocus` from being called when we manually focus on a token
|
|
65
59
|
this.bindFocusEvent = false;
|
|
@@ -67,19 +61,15 @@ var script = {
|
|
|
67
61
|
this.bindFocusEvent = true;
|
|
68
62
|
}
|
|
69
63
|
}
|
|
70
|
-
|
|
71
64
|
},
|
|
72
|
-
|
|
73
65
|
created() {
|
|
74
66
|
this.registerFocusOnToken(this.focusOnToken);
|
|
75
67
|
},
|
|
76
|
-
|
|
77
68
|
methods: {
|
|
78
69
|
handleClose(token) {
|
|
79
70
|
this.$emit('token-remove', token);
|
|
80
71
|
this.focusedTokenIndex = null;
|
|
81
72
|
},
|
|
82
|
-
|
|
83
73
|
handleLeftArrow() {
|
|
84
74
|
if (this.focusedTokenIndex === 0) {
|
|
85
75
|
this.focusLastToken();
|
|
@@ -87,7 +77,6 @@ var script = {
|
|
|
87
77
|
this.focusPrevToken();
|
|
88
78
|
}
|
|
89
79
|
},
|
|
90
|
-
|
|
91
80
|
handleRightArrow() {
|
|
92
81
|
if (this.focusedTokenIndex === this.tokens.length - 1) {
|
|
93
82
|
this.focusFirstToken();
|
|
@@ -95,58 +84,45 @@ var script = {
|
|
|
95
84
|
this.focusNextToken();
|
|
96
85
|
}
|
|
97
86
|
},
|
|
98
|
-
|
|
99
87
|
handleHome() {
|
|
100
88
|
this.focusFirstToken();
|
|
101
89
|
},
|
|
102
|
-
|
|
103
90
|
handleEnd() {
|
|
104
91
|
this.focusLastToken();
|
|
105
92
|
},
|
|
106
|
-
|
|
107
93
|
handleDelete() {
|
|
108
94
|
this.$emit('token-remove', this.focusedToken);
|
|
109
|
-
|
|
110
95
|
if (this.focusedTokenIndex > 0) {
|
|
111
96
|
this.focusPrevToken();
|
|
112
97
|
}
|
|
113
98
|
},
|
|
114
|
-
|
|
115
99
|
handleEscape() {
|
|
116
100
|
this.focusedTokenIndex = null;
|
|
117
101
|
this.$emit('cancel-focus');
|
|
118
102
|
},
|
|
119
|
-
|
|
120
103
|
handleTab() {
|
|
121
104
|
this.$emit('cancel-focus');
|
|
122
105
|
},
|
|
123
|
-
|
|
124
106
|
// Only called when a token is focused by a click/tap
|
|
125
107
|
handleTokenFocus(index) {
|
|
126
108
|
this.focusedTokenIndex = index;
|
|
127
109
|
},
|
|
128
|
-
|
|
129
110
|
focusLastToken() {
|
|
130
111
|
this.focusedTokenIndex = this.tokens.length - 1;
|
|
131
112
|
},
|
|
132
|
-
|
|
133
113
|
focusFirstToken() {
|
|
134
114
|
this.focusedTokenIndex = 0;
|
|
135
115
|
},
|
|
136
|
-
|
|
137
116
|
focusNextToken() {
|
|
138
117
|
this.focusedTokenIndex += 1;
|
|
139
118
|
},
|
|
140
|
-
|
|
141
119
|
focusPrevToken() {
|
|
142
120
|
this.focusedTokenIndex -= 1;
|
|
143
121
|
},
|
|
144
|
-
|
|
145
122
|
focusOnToken() {
|
|
146
123
|
let tokenIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
147
124
|
this.focusedTokenIndex = tokenIndex;
|
|
148
125
|
}
|
|
149
|
-
|
|
150
126
|
}
|
|
151
127
|
};
|
|
152
128
|
|
|
@@ -26,7 +26,6 @@ var script = {
|
|
|
26
26
|
required: false,
|
|
27
27
|
default: () => []
|
|
28
28
|
},
|
|
29
|
-
|
|
30
29
|
/**
|
|
31
30
|
* Should users be allowed to add tokens that are not in `dropdown-items`
|
|
32
31
|
*/
|
|
@@ -35,7 +34,6 @@ var script = {
|
|
|
35
34
|
required: false,
|
|
36
35
|
default: false
|
|
37
36
|
},
|
|
38
|
-
|
|
39
37
|
/**
|
|
40
38
|
* Dropdown items are loading, can be used when requesting new dropdown items
|
|
41
39
|
*/
|
|
@@ -44,7 +42,6 @@ var script = {
|
|
|
44
42
|
required: false,
|
|
45
43
|
default: false
|
|
46
44
|
},
|
|
47
|
-
|
|
48
45
|
/**
|
|
49
46
|
* Hide the dropdown if `dropdown-items` is empty. Will show `no-results-content` slot if this is `false`
|
|
50
47
|
*/
|
|
@@ -53,7 +50,6 @@ var script = {
|
|
|
53
50
|
required: false,
|
|
54
51
|
default: false
|
|
55
52
|
},
|
|
56
|
-
|
|
57
53
|
/**
|
|
58
54
|
* CSS classes to add to the main token selector container (`.gl-token-selector`)
|
|
59
55
|
*/
|
|
@@ -62,7 +58,6 @@ var script = {
|
|
|
62
58
|
required: false,
|
|
63
59
|
default: ''
|
|
64
60
|
},
|
|
65
|
-
|
|
66
61
|
/**
|
|
67
62
|
* CSS classes to add to dropdown menu `ul` element
|
|
68
63
|
*/
|
|
@@ -71,7 +66,6 @@ var script = {
|
|
|
71
66
|
required: false,
|
|
72
67
|
default: ''
|
|
73
68
|
},
|
|
74
|
-
|
|
75
69
|
/**
|
|
76
70
|
* The autocomplete attribute value for the underlying `input` element
|
|
77
71
|
*/
|
|
@@ -80,7 +74,6 @@ var script = {
|
|
|
80
74
|
required: false,
|
|
81
75
|
default: 'off'
|
|
82
76
|
},
|
|
83
|
-
|
|
84
77
|
/**
|
|
85
78
|
* The `aria-labelledby` attribute value for the underlying `input` element
|
|
86
79
|
*/
|
|
@@ -89,7 +82,6 @@ var script = {
|
|
|
89
82
|
required: false,
|
|
90
83
|
default: null
|
|
91
84
|
},
|
|
92
|
-
|
|
93
85
|
/**
|
|
94
86
|
* The `placeholder` attribute value for the underlying `input` element
|
|
95
87
|
*/
|
|
@@ -98,7 +90,6 @@ var script = {
|
|
|
98
90
|
required: false,
|
|
99
91
|
default: null
|
|
100
92
|
},
|
|
101
|
-
|
|
102
93
|
/**
|
|
103
94
|
* HTML attributes to add to the text input. Helpful for adding `data-testid` and `data-qa-selector` attributes
|
|
104
95
|
*/
|
|
@@ -107,7 +98,6 @@ var script = {
|
|
|
107
98
|
required: false,
|
|
108
99
|
default: null
|
|
109
100
|
},
|
|
110
|
-
|
|
111
101
|
/**
|
|
112
102
|
* Controls the validation state appearance of the component. `true` for valid, `false` for invalid, or `null` for no validation state
|
|
113
103
|
*/
|
|
@@ -116,7 +106,6 @@ var script = {
|
|
|
116
106
|
required: false,
|
|
117
107
|
default: null
|
|
118
108
|
},
|
|
119
|
-
|
|
120
109
|
/**
|
|
121
110
|
* Tokens that are selected. This prop will automatically be added when using `v-model`
|
|
122
111
|
*/
|
|
@@ -126,7 +115,6 @@ var script = {
|
|
|
126
115
|
validator: tokensValidator,
|
|
127
116
|
required: true
|
|
128
117
|
},
|
|
129
|
-
|
|
130
118
|
/**
|
|
131
119
|
* Controls the `view-only` mode for the tokens
|
|
132
120
|
*/
|
|
@@ -135,7 +123,6 @@ var script = {
|
|
|
135
123
|
required: false,
|
|
136
124
|
default: false
|
|
137
125
|
},
|
|
138
|
-
|
|
139
126
|
/**
|
|
140
127
|
* Allows user to bulk delete tokens when enabled
|
|
141
128
|
*/
|
|
@@ -145,7 +132,6 @@ var script = {
|
|
|
145
132
|
default: false
|
|
146
133
|
}
|
|
147
134
|
},
|
|
148
|
-
|
|
149
135
|
data() {
|
|
150
136
|
return {
|
|
151
137
|
inputText: '',
|
|
@@ -164,52 +150,40 @@ var script = {
|
|
|
164
150
|
focusOnToken: () => {}
|
|
165
151
|
};
|
|
166
152
|
},
|
|
167
|
-
|
|
168
153
|
computed: {
|
|
169
154
|
filteredDropdownItems() {
|
|
170
155
|
return this.dropdownItems.filter(dropdownItem => this.selectedTokens.findIndex(token => token.id === dropdownItem.id) === -1);
|
|
171
156
|
},
|
|
172
|
-
|
|
173
157
|
dropdownHasNoItems() {
|
|
174
158
|
return !this.filteredDropdownItems.length;
|
|
175
159
|
},
|
|
176
|
-
|
|
177
160
|
userDefinedTokenCanBeAdded() {
|
|
178
161
|
return this.allowUserDefinedTokens && this.dropdownHasNoItems && this.inputText !== '';
|
|
179
162
|
},
|
|
180
|
-
|
|
181
163
|
hideDropdown() {
|
|
182
164
|
if (this.userDefinedTokenCanBeAdded) {
|
|
183
165
|
return false;
|
|
184
166
|
}
|
|
185
|
-
|
|
186
167
|
if (this.hideDropdownWithNoItems && this.dropdownHasNoItems) {
|
|
187
168
|
return true;
|
|
188
169
|
}
|
|
189
|
-
|
|
190
170
|
return false;
|
|
191
171
|
},
|
|
192
|
-
|
|
193
172
|
stateClass() {
|
|
194
173
|
if (this.state === null) {
|
|
195
174
|
return 'gl-inset-border-1-gray-400!';
|
|
196
175
|
}
|
|
197
|
-
|
|
198
176
|
return this.state ? 'is-valid gl-inset-border-1-gray-400!' : 'is-invalid gl-inset-border-1-red-500!';
|
|
199
177
|
},
|
|
200
|
-
|
|
201
178
|
hasSelectedTokens() {
|
|
202
179
|
return this.selectedTokens.length > 0;
|
|
203
180
|
},
|
|
204
|
-
|
|
205
181
|
showEmptyPlaceholder() {
|
|
206
182
|
return !this.hasSelectedTokens && !this.inputFocused;
|
|
207
183
|
},
|
|
208
|
-
|
|
209
184
|
showClearAllButton() {
|
|
210
185
|
return this.hasSelectedTokens && this.allowClearAll;
|
|
211
186
|
}
|
|
212
|
-
|
|
213
187
|
},
|
|
214
188
|
watch: {
|
|
215
189
|
inputText(newValue, oldValue) {
|
|
@@ -221,16 +195,15 @@ var script = {
|
|
|
221
195
|
*/
|
|
222
196
|
this.$emit('text-input', newValue);
|
|
223
197
|
this.resetFocusedDropdownItem();
|
|
224
|
-
|
|
225
198
|
if (newValue !== '') {
|
|
226
199
|
this.triggerTokenFocusNextBackspace = false;
|
|
227
200
|
} else {
|
|
228
201
|
this.triggerTokenFocusNextBackspace = true;
|
|
229
|
-
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Wait a tick so `text-input` event can be used to validate
|
|
230
205
|
// the value and change the `allowUserDefinedTokens` and/or
|
|
231
206
|
// `hideDropdownWithNoItems` props
|
|
232
|
-
|
|
233
|
-
|
|
234
207
|
this.$nextTick(() => {
|
|
235
208
|
if (this.hideDropdown) {
|
|
236
209
|
this.closeDropdown();
|
|
@@ -240,7 +213,6 @@ var script = {
|
|
|
240
213
|
});
|
|
241
214
|
}
|
|
242
215
|
}
|
|
243
|
-
|
|
244
216
|
},
|
|
245
217
|
methods: {
|
|
246
218
|
handleFocus(event) {
|
|
@@ -253,12 +225,10 @@ var script = {
|
|
|
253
225
|
this.openDropdown();
|
|
254
226
|
this.inputFocused = true;
|
|
255
227
|
this.focusOnToken();
|
|
256
|
-
|
|
257
228
|
if (this.inputText === '') {
|
|
258
229
|
this.triggerTokenFocusNextBackspace = true;
|
|
259
230
|
}
|
|
260
231
|
},
|
|
261
|
-
|
|
262
232
|
handleBlur(event) {
|
|
263
233
|
/**
|
|
264
234
|
* Fired when the token selector is blurred
|
|
@@ -266,20 +236,19 @@ var script = {
|
|
|
266
236
|
* @property {FocusEvent} event
|
|
267
237
|
*/
|
|
268
238
|
this.$emit('blur', event);
|
|
269
|
-
this.inputFocused = false;
|
|
239
|
+
this.inputFocused = false;
|
|
240
|
+
|
|
241
|
+
// `event.relatedTarget` returns `null` on Safari because buttons are not focused on click (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus)
|
|
270
242
|
// Workaround is to:
|
|
271
243
|
// 1. Explicitly focus the dropdown menu item button on `mousedown` event. (see './token_selector_dropdown.vue')
|
|
272
244
|
// 2. Use `nextTick` so `blur` event is fired after the `mousedown` event
|
|
273
|
-
|
|
274
245
|
this.$nextTick(() => {
|
|
275
246
|
var _event$relatedTarget, _event$relatedTarget$;
|
|
276
|
-
|
|
277
247
|
if (!((_event$relatedTarget = event.relatedTarget) !== null && _event$relatedTarget !== void 0 && (_event$relatedTarget$ = _event$relatedTarget.closest) !== null && _event$relatedTarget$ !== void 0 && _event$relatedTarget$.call(_event$relatedTarget, '.dropdown-item'))) {
|
|
278
248
|
this.closeDropdown();
|
|
279
249
|
}
|
|
280
250
|
});
|
|
281
251
|
},
|
|
282
|
-
|
|
283
252
|
handleEnter() {
|
|
284
253
|
if (this.userDefinedTokenCanBeAdded) {
|
|
285
254
|
this.addToken();
|
|
@@ -287,20 +256,17 @@ var script = {
|
|
|
287
256
|
this.addToken(this.focusedDropdownItem);
|
|
288
257
|
}
|
|
289
258
|
},
|
|
290
|
-
|
|
291
259
|
handleEscape() {
|
|
292
260
|
this.inputText = '';
|
|
293
261
|
this.closeDropdown();
|
|
294
262
|
},
|
|
295
|
-
|
|
296
263
|
handleBackspace(event) {
|
|
297
264
|
if (this.inputText !== '' || !this.selectedTokens.length) {
|
|
298
265
|
return;
|
|
299
|
-
}
|
|
300
|
-
|
|
266
|
+
}
|
|
301
267
|
|
|
268
|
+
// Prevent triggering the browser back button
|
|
302
269
|
event.preventDefault();
|
|
303
|
-
|
|
304
270
|
if (this.triggerTokenFocusNextBackspace) {
|
|
305
271
|
this.$refs.textInput.blur();
|
|
306
272
|
this.focusOnToken(this.selectedTokens.length - 1);
|
|
@@ -308,51 +274,45 @@ var script = {
|
|
|
308
274
|
this.triggerTokenFocusNextBackspace = true;
|
|
309
275
|
}
|
|
310
276
|
},
|
|
311
|
-
|
|
312
277
|
handleInputClick() {
|
|
313
278
|
// Open the dropdown if the user clicks an already focused input
|
|
314
279
|
if (this.inputFocused && this.inputText === '' && !this.dropdownIsOpen) {
|
|
315
280
|
this.openDropdown();
|
|
316
281
|
}
|
|
317
282
|
},
|
|
318
|
-
|
|
319
283
|
handleContainerClick(event) {
|
|
320
284
|
// Bail if token is clicked
|
|
321
285
|
const {
|
|
322
286
|
target
|
|
323
287
|
} = event;
|
|
324
|
-
|
|
325
288
|
if ((target === null || target === void 0 ? void 0 : target.closest('.gl-token')) !== null || this.inputFocused) {
|
|
326
289
|
return;
|
|
327
290
|
}
|
|
328
|
-
|
|
329
291
|
this.focusTextInput();
|
|
330
292
|
},
|
|
331
|
-
|
|
332
293
|
addToken() {
|
|
333
294
|
let dropdownItem = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
334
295
|
const token = dropdownItem !== null ? dropdownItem : {
|
|
335
296
|
id: _uniqueId('user-defined-token'),
|
|
336
297
|
name: this.inputText
|
|
337
298
|
};
|
|
299
|
+
|
|
338
300
|
/**
|
|
339
301
|
* Fired when a token is added or removed
|
|
340
302
|
*
|
|
341
303
|
* @property {array} selectedTokens
|
|
342
304
|
*/
|
|
343
|
-
|
|
344
305
|
this.$emit('input', [...this.selectedTokens, token]);
|
|
345
306
|
this.inputText = '';
|
|
346
307
|
this.closeDropdown();
|
|
308
|
+
|
|
347
309
|
/**
|
|
348
310
|
* Fired when a token is added
|
|
349
311
|
*
|
|
350
312
|
* @property {object} token
|
|
351
313
|
*/
|
|
352
|
-
|
|
353
314
|
this.$emit('token-add', token);
|
|
354
315
|
},
|
|
355
|
-
|
|
356
316
|
removeToken(token) {
|
|
357
317
|
/**
|
|
358
318
|
* Fired when user types in the token selector
|
|
@@ -365,49 +325,38 @@ var script = {
|
|
|
365
325
|
*
|
|
366
326
|
* @property {object} token
|
|
367
327
|
*/
|
|
368
|
-
|
|
369
328
|
this.$emit('token-remove', token);
|
|
370
329
|
},
|
|
371
|
-
|
|
372
330
|
cancelTokenFocus() {
|
|
373
331
|
this.focusTextInput();
|
|
374
332
|
},
|
|
375
|
-
|
|
376
333
|
closeDropdown() {
|
|
377
334
|
this.dropdownIsOpen = false;
|
|
378
335
|
this.resetFocusedDropdownItem();
|
|
379
336
|
},
|
|
380
|
-
|
|
381
337
|
openDropdown() {
|
|
382
338
|
if (this.hideDropdown) {
|
|
383
339
|
return;
|
|
384
340
|
}
|
|
385
|
-
|
|
386
341
|
this.dropdownIsOpen = true;
|
|
387
342
|
},
|
|
388
|
-
|
|
389
343
|
focusTextInput() {
|
|
390
344
|
this.$refs.textInput.focus();
|
|
391
345
|
},
|
|
392
|
-
|
|
393
346
|
// Register methods passed as props from child components
|
|
394
347
|
registerDropdownEventHandlers(dropdownEventHandlers) {
|
|
395
348
|
this.dropdownEventHandlers = dropdownEventHandlers;
|
|
396
349
|
},
|
|
397
|
-
|
|
398
350
|
registerResetFocusedDropdownItem(resetFocusedDropdownItem) {
|
|
399
351
|
this.resetFocusedDropdownItem = resetFocusedDropdownItem;
|
|
400
352
|
},
|
|
401
|
-
|
|
402
353
|
registerFocusOnToken(focusOnToken) {
|
|
403
354
|
this.focusOnToken = focusOnToken;
|
|
404
355
|
},
|
|
405
|
-
|
|
406
356
|
clearAll() {
|
|
407
357
|
this.$emit('input', []);
|
|
408
358
|
this.focusTextInput();
|
|
409
359
|
}
|
|
410
|
-
|
|
411
360
|
}
|
|
412
361
|
};
|
|
413
362
|
|