@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
|
@@ -68,7 +68,6 @@ var script = {
|
|
|
68
68
|
required: false,
|
|
69
69
|
default: false
|
|
70
70
|
},
|
|
71
|
-
|
|
72
71
|
/**
|
|
73
72
|
* Right align dropdown menu with respect to the toggle button
|
|
74
73
|
*/
|
|
@@ -86,7 +85,6 @@ var script = {
|
|
|
86
85
|
return ['menu', 'listbox', 'tree', 'grid', 'dialog', true, false].includes(value);
|
|
87
86
|
}
|
|
88
87
|
},
|
|
89
|
-
|
|
90
88
|
/**
|
|
91
89
|
* Id that will be referenced by `aria-labelledby` attribute of the dropdown content`
|
|
92
90
|
*/
|
|
@@ -94,7 +92,6 @@ var script = {
|
|
|
94
92
|
type: String,
|
|
95
93
|
required: true
|
|
96
94
|
},
|
|
97
|
-
|
|
98
95
|
/**
|
|
99
96
|
* The `aria-labelledby` attribute value for the toggle `button`
|
|
100
97
|
*/
|
|
@@ -104,26 +101,20 @@ var script = {
|
|
|
104
101
|
default: null
|
|
105
102
|
}
|
|
106
103
|
},
|
|
107
|
-
|
|
108
104
|
data() {
|
|
109
105
|
return {
|
|
110
106
|
visible: false
|
|
111
107
|
};
|
|
112
108
|
},
|
|
113
|
-
|
|
114
109
|
computed: {
|
|
115
110
|
isIconOnly() {
|
|
116
111
|
var _this$toggleText;
|
|
117
|
-
|
|
118
112
|
return Boolean(this.icon && (!((_this$toggleText = this.toggleText) !== null && _this$toggleText !== void 0 && _this$toggleText.length) || this.textSrOnly));
|
|
119
113
|
},
|
|
120
|
-
|
|
121
114
|
isIconWithText() {
|
|
122
115
|
var _this$toggleText2;
|
|
123
|
-
|
|
124
116
|
return Boolean(this.icon && ((_this$toggleText2 = this.toggleText) === null || _this$toggleText2 === void 0 ? void 0 : _this$toggleText2.length) && !this.textSrOnly);
|
|
125
117
|
},
|
|
126
|
-
|
|
127
118
|
toggleButtonClasses() {
|
|
128
119
|
return [this.toggleClass, {
|
|
129
120
|
'gl-dropdown-toggle': true,
|
|
@@ -133,79 +124,68 @@ var script = {
|
|
|
133
124
|
'dropdown-toggle-no-caret': this.noCaret
|
|
134
125
|
}];
|
|
135
126
|
},
|
|
136
|
-
|
|
137
127
|
toggleLabelledBy() {
|
|
138
128
|
return this.ariaLabelledby ? `${this.ariaLabelledby} ${this.toggleId}` : this.toggleId;
|
|
139
129
|
},
|
|
140
|
-
|
|
141
130
|
popperConfig() {
|
|
142
131
|
return {
|
|
143
132
|
placement: this.right ? 'bottom-end' : 'bottom-start',
|
|
144
133
|
...POPPER_CONFIG
|
|
145
134
|
};
|
|
146
135
|
}
|
|
147
|
-
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
updated() {
|
|
151
|
-
if (this.visible) {
|
|
152
|
-
var _this$popper;
|
|
153
|
-
|
|
154
|
-
(_this$popper = this.popper) === null || _this$popper === void 0 ? void 0 : _this$popper.update();
|
|
155
|
-
}
|
|
156
136
|
},
|
|
157
|
-
|
|
158
137
|
mounted() {
|
|
159
138
|
this.$nextTick(() => {
|
|
160
139
|
this.popper = createPopper(this.$refs.toggle.$el, this.$refs.content, this.popperConfig);
|
|
161
140
|
});
|
|
162
141
|
},
|
|
163
|
-
|
|
164
142
|
beforeDestroy() {
|
|
165
143
|
this.popper.destroy();
|
|
166
144
|
},
|
|
167
|
-
|
|
168
145
|
methods: {
|
|
169
|
-
toggle() {
|
|
146
|
+
async toggle() {
|
|
170
147
|
this.visible = !this.visible;
|
|
171
|
-
|
|
172
148
|
if (this.visible) {
|
|
173
|
-
|
|
149
|
+
var _this$popper;
|
|
150
|
+
/* Initially dropdown is hidden with `display="none"`.
|
|
151
|
+
When `visible` prop is toggled ON, with the `nextTick` we wait for the DOM update -
|
|
152
|
+
dropdown's `display="block"` is set (adding CSS class `show`).
|
|
153
|
+
After that we can recalculate its position (calling `popper.update()`).
|
|
154
|
+
https://github.com/floating-ui/floating-ui/issues/630:
|
|
155
|
+
"Unfortunately there's not any way to compute the position of an element not rendered in the document".
|
|
156
|
+
Then we `await` while the new dropdown position is calculated and DOM updated accordingly.
|
|
157
|
+
After we can emit the `GL_DROPDOWN_SHOWN` event to the parent which might interact with updated dropdown,
|
|
158
|
+
e.g. set focus..
|
|
159
|
+
*/
|
|
160
|
+
await this.$nextTick();
|
|
161
|
+
await ((_this$popper = this.popper) === null || _this$popper === void 0 ? void 0 : _this$popper.update());
|
|
174
162
|
this.$emit(GL_DROPDOWN_SHOWN);
|
|
175
163
|
} else {
|
|
176
164
|
this.$emit(GL_DROPDOWN_HIDDEN);
|
|
177
165
|
}
|
|
178
166
|
},
|
|
179
|
-
|
|
180
167
|
open() {
|
|
181
168
|
if (this.visible) {
|
|
182
169
|
return;
|
|
183
170
|
}
|
|
184
|
-
|
|
185
171
|
this.toggle();
|
|
186
172
|
},
|
|
187
|
-
|
|
188
173
|
close() {
|
|
189
174
|
if (!this.visible) {
|
|
190
175
|
return;
|
|
191
176
|
}
|
|
192
|
-
|
|
193
177
|
this.toggle();
|
|
194
178
|
},
|
|
195
|
-
|
|
196
179
|
closeAndFocus() {
|
|
197
180
|
if (!this.visible) {
|
|
198
181
|
return;
|
|
199
182
|
}
|
|
200
|
-
|
|
201
183
|
this.toggle();
|
|
202
184
|
this.focusToggle();
|
|
203
185
|
},
|
|
204
|
-
|
|
205
186
|
focusToggle() {
|
|
206
187
|
this.$refs.toggle.$el.focus();
|
|
207
188
|
}
|
|
208
|
-
|
|
209
189
|
}
|
|
210
190
|
};
|
|
211
191
|
|
|
@@ -5,11 +5,13 @@ const POPPER_CONFIG = {
|
|
|
5
5
|
offset: [0, 4]
|
|
6
6
|
}
|
|
7
7
|
}]
|
|
8
|
-
};
|
|
8
|
+
};
|
|
9
9
|
|
|
10
|
+
// base dropdown events
|
|
10
11
|
const GL_DROPDOWN_SHOWN = 'shown';
|
|
11
|
-
const GL_DROPDOWN_HIDDEN = 'hidden';
|
|
12
|
+
const GL_DROPDOWN_HIDDEN = 'hidden';
|
|
12
13
|
|
|
14
|
+
// KEY Codes
|
|
13
15
|
const HOME = 'Home';
|
|
14
16
|
const END = 'End';
|
|
15
17
|
const ARROW_UP = 'ArrowUp';
|
|
@@ -42,7 +42,6 @@ var script = {
|
|
|
42
42
|
default: () => [],
|
|
43
43
|
validator: itemsValidator
|
|
44
44
|
},
|
|
45
|
-
|
|
46
45
|
/**
|
|
47
46
|
* array of selected items values for multi-select and selected item value for single-select
|
|
48
47
|
*/
|
|
@@ -51,7 +50,6 @@ var script = {
|
|
|
51
50
|
required: false,
|
|
52
51
|
default: () => []
|
|
53
52
|
},
|
|
54
|
-
|
|
55
53
|
/**
|
|
56
54
|
* Allow multi-selection
|
|
57
55
|
*/
|
|
@@ -60,7 +58,6 @@ var script = {
|
|
|
60
58
|
required: false,
|
|
61
59
|
default: false
|
|
62
60
|
},
|
|
63
|
-
|
|
64
61
|
/**
|
|
65
62
|
* Toggle button text
|
|
66
63
|
*/
|
|
@@ -69,7 +66,6 @@ var script = {
|
|
|
69
66
|
required: false,
|
|
70
67
|
default: ''
|
|
71
68
|
},
|
|
72
|
-
|
|
73
69
|
/**
|
|
74
70
|
* Toggle text to be read by screen readers only
|
|
75
71
|
*/
|
|
@@ -78,14 +74,12 @@ var script = {
|
|
|
78
74
|
required: false,
|
|
79
75
|
default: false
|
|
80
76
|
},
|
|
81
|
-
|
|
82
77
|
/** The header text */
|
|
83
78
|
headerText: {
|
|
84
79
|
type: String,
|
|
85
80
|
required: false,
|
|
86
81
|
default: ''
|
|
87
82
|
},
|
|
88
|
-
|
|
89
83
|
/**
|
|
90
84
|
* Styling option - dropdown's toggle category
|
|
91
85
|
*/
|
|
@@ -95,7 +89,6 @@ var script = {
|
|
|
95
89
|
default: buttonCategoryOptions.primary,
|
|
96
90
|
validator: value => Object.keys(buttonCategoryOptions).includes(value)
|
|
97
91
|
},
|
|
98
|
-
|
|
99
92
|
/**
|
|
100
93
|
* Styling option - dropdown's toggle variant
|
|
101
94
|
*/
|
|
@@ -105,7 +98,6 @@ var script = {
|
|
|
105
98
|
default: dropdownVariantOptions.default,
|
|
106
99
|
validator: value => Object.keys(dropdownVariantOptions).includes(value)
|
|
107
100
|
},
|
|
108
|
-
|
|
109
101
|
/**
|
|
110
102
|
* The size of the dropdown toggle
|
|
111
103
|
*/
|
|
@@ -115,7 +107,6 @@ var script = {
|
|
|
115
107
|
default: buttonSizeOptions.medium,
|
|
116
108
|
validator: value => Object.keys(buttonSizeOptions).includes(value)
|
|
117
109
|
},
|
|
118
|
-
|
|
119
110
|
/**
|
|
120
111
|
* Icon name that will be rendered in the toggle button
|
|
121
112
|
*/
|
|
@@ -124,7 +115,6 @@ var script = {
|
|
|
124
115
|
required: false,
|
|
125
116
|
default: ''
|
|
126
117
|
},
|
|
127
|
-
|
|
128
118
|
/**
|
|
129
119
|
* Set to "true" to disable the dropdown
|
|
130
120
|
*/
|
|
@@ -133,7 +123,6 @@ var script = {
|
|
|
133
123
|
required: false,
|
|
134
124
|
default: false
|
|
135
125
|
},
|
|
136
|
-
|
|
137
126
|
/**
|
|
138
127
|
* Set to "true" when dropdown content (items) is loading
|
|
139
128
|
* It will render a small loader in the dropdown toggle and make it disabled
|
|
@@ -143,7 +132,6 @@ var script = {
|
|
|
143
132
|
required: false,
|
|
144
133
|
default: false
|
|
145
134
|
},
|
|
146
|
-
|
|
147
135
|
/**
|
|
148
136
|
* Additional CSS classes to customize toggle appearance
|
|
149
137
|
*/
|
|
@@ -152,7 +140,6 @@ var script = {
|
|
|
152
140
|
required: false,
|
|
153
141
|
default: null
|
|
154
142
|
},
|
|
155
|
-
|
|
156
143
|
/**
|
|
157
144
|
* Set to "true" to hide the caret
|
|
158
145
|
*/
|
|
@@ -161,7 +148,6 @@ var script = {
|
|
|
161
148
|
required: false,
|
|
162
149
|
default: false
|
|
163
150
|
},
|
|
164
|
-
|
|
165
151
|
/**
|
|
166
152
|
* Right align listbox menu with respect to the toggle button
|
|
167
153
|
*/
|
|
@@ -170,7 +156,6 @@ var script = {
|
|
|
170
156
|
required: false,
|
|
171
157
|
default: false
|
|
172
158
|
},
|
|
173
|
-
|
|
174
159
|
/**
|
|
175
160
|
* Center selected item checkmark
|
|
176
161
|
*/
|
|
@@ -179,7 +164,6 @@ var script = {
|
|
|
179
164
|
required: false,
|
|
180
165
|
default: false
|
|
181
166
|
},
|
|
182
|
-
|
|
183
167
|
/**
|
|
184
168
|
* The `aria-labelledby` attribute value for the toggle button
|
|
185
169
|
* Provide the string of ids seperated by space
|
|
@@ -189,7 +173,6 @@ var script = {
|
|
|
189
173
|
required: false,
|
|
190
174
|
default: null
|
|
191
175
|
},
|
|
192
|
-
|
|
193
176
|
/**
|
|
194
177
|
* The `aria-labelledby` attribute value for the list of options
|
|
195
178
|
* Provide the string of ids seperated by space
|
|
@@ -199,7 +182,6 @@ var script = {
|
|
|
199
182
|
required: false,
|
|
200
183
|
default: null
|
|
201
184
|
},
|
|
202
|
-
|
|
203
185
|
/**
|
|
204
186
|
* Enable search
|
|
205
187
|
*/
|
|
@@ -208,7 +190,6 @@ var script = {
|
|
|
208
190
|
required: false,
|
|
209
191
|
default: false
|
|
210
192
|
},
|
|
211
|
-
|
|
212
193
|
/**
|
|
213
194
|
* Set to "true" when items search is in progress.
|
|
214
195
|
* It will display loading icon below the search input
|
|
@@ -218,7 +199,6 @@ var script = {
|
|
|
218
199
|
required: false,
|
|
219
200
|
default: false
|
|
220
201
|
},
|
|
221
|
-
|
|
222
202
|
/**
|
|
223
203
|
* Message to be displayed when filtering produced no results
|
|
224
204
|
*/
|
|
@@ -228,7 +208,6 @@ var script = {
|
|
|
228
208
|
default: 'No results found'
|
|
229
209
|
}
|
|
230
210
|
},
|
|
231
|
-
|
|
232
211
|
data() {
|
|
233
212
|
return {
|
|
234
213
|
selectedValues: [],
|
|
@@ -238,22 +217,18 @@ var script = {
|
|
|
238
217
|
searchStr: ''
|
|
239
218
|
};
|
|
240
219
|
},
|
|
241
|
-
|
|
242
220
|
computed: {
|
|
243
221
|
listboxTag() {
|
|
244
222
|
if (this.items.length === 0 || isOption(this.items[0])) return 'ul';
|
|
245
223
|
return 'div';
|
|
246
224
|
},
|
|
247
|
-
|
|
248
225
|
flattenedOptions() {
|
|
249
226
|
return flattenedOptions(this.items);
|
|
250
227
|
},
|
|
251
|
-
|
|
252
228
|
listboxToggleText() {
|
|
253
229
|
if (!this.toggleText) {
|
|
254
230
|
if (!this.multiple && this.selectedValues.length) {
|
|
255
231
|
var _this$flattenedOption;
|
|
256
|
-
|
|
257
232
|
return (_this$flattenedOption = this.flattenedOptions.find(_ref => {
|
|
258
233
|
let {
|
|
259
234
|
value
|
|
@@ -261,13 +236,10 @@ var script = {
|
|
|
261
236
|
return value === this.selectedValues[0];
|
|
262
237
|
})) === null || _this$flattenedOption === void 0 ? void 0 : _this$flattenedOption.text;
|
|
263
238
|
}
|
|
264
|
-
|
|
265
239
|
return '';
|
|
266
240
|
}
|
|
267
|
-
|
|
268
241
|
return this.toggleText;
|
|
269
242
|
},
|
|
270
|
-
|
|
271
243
|
selectedIndices() {
|
|
272
244
|
return this.selectedValues.map(selected => this.flattenedOptions.findIndex(_ref2 => {
|
|
273
245
|
let {
|
|
@@ -276,75 +248,58 @@ var script = {
|
|
|
276
248
|
return value === selected;
|
|
277
249
|
})).sort();
|
|
278
250
|
},
|
|
279
|
-
|
|
280
251
|
showList() {
|
|
281
252
|
return this.flattenedOptions.length && !this.searching;
|
|
282
253
|
},
|
|
283
|
-
|
|
284
254
|
showNoResultsText() {
|
|
285
255
|
return !this.flattenedOptions.length && !this.searching;
|
|
286
256
|
},
|
|
287
|
-
|
|
288
257
|
announceSRSearchResults() {
|
|
289
258
|
return this.searchable && !this.showNoResultsText && this.$scopedSlots['search-summary-sr-only'];
|
|
290
259
|
},
|
|
291
|
-
|
|
292
260
|
headerId() {
|
|
293
261
|
return this.headerText && _uniqueId('listbox-header-');
|
|
294
262
|
}
|
|
295
|
-
|
|
296
263
|
},
|
|
297
264
|
watch: {
|
|
298
265
|
selected: {
|
|
299
266
|
immediate: true,
|
|
300
|
-
|
|
301
267
|
handler(newSelected) {
|
|
302
268
|
if (Array.isArray(newSelected)) {
|
|
303
269
|
if (!this.multiple && newSelected.length) {
|
|
304
270
|
throw new Error('To allow multi-selection, please, set "multiple" property to "true"');
|
|
305
271
|
}
|
|
306
|
-
|
|
307
272
|
this.selectedValues = [...newSelected];
|
|
308
273
|
} else {
|
|
309
274
|
this.selectedValues = [newSelected];
|
|
310
275
|
}
|
|
311
276
|
}
|
|
312
|
-
|
|
313
277
|
}
|
|
314
278
|
},
|
|
315
279
|
methods: {
|
|
316
280
|
open() {
|
|
317
281
|
this.$refs.baseDropdown.open();
|
|
318
282
|
},
|
|
319
|
-
|
|
320
283
|
close() {
|
|
321
284
|
this.$refs.baseDropdown.close();
|
|
322
285
|
},
|
|
323
|
-
|
|
324
286
|
groupClasses(index) {
|
|
325
287
|
return index === 0 ? null : GROUP_TOP_BORDER_CLASSES;
|
|
326
288
|
},
|
|
327
|
-
|
|
328
289
|
onShow() {
|
|
329
|
-
this
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
*/
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
this.$emit(GL_DROPDOWN_SHOWN);
|
|
345
|
-
});
|
|
290
|
+
if (this.searchable) {
|
|
291
|
+
this.focusSearchInput();
|
|
292
|
+
} else {
|
|
293
|
+
var _this$selectedIndices;
|
|
294
|
+
this.focusItem((_this$selectedIndices = this.selectedIndices[0]) !== null && _this$selectedIndices !== void 0 ? _this$selectedIndices : 0, this.getFocusableListItemElements());
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Emitted when dropdown is shown
|
|
298
|
+
*
|
|
299
|
+
* @event shown
|
|
300
|
+
*/
|
|
301
|
+
this.$emit(GL_DROPDOWN_SHOWN);
|
|
346
302
|
},
|
|
347
|
-
|
|
348
303
|
onHide() {
|
|
349
304
|
/**
|
|
350
305
|
* Emitted when dropdown is hidden
|
|
@@ -354,7 +309,6 @@ var script = {
|
|
|
354
309
|
this.$emit(GL_DROPDOWN_HIDDEN);
|
|
355
310
|
this.nextFocusedItemIndex = null;
|
|
356
311
|
},
|
|
357
|
-
|
|
358
312
|
onKeydown(event) {
|
|
359
313
|
const {
|
|
360
314
|
code,
|
|
@@ -364,7 +318,6 @@ var script = {
|
|
|
364
318
|
if (elements.length < 1) return;
|
|
365
319
|
let stop = true;
|
|
366
320
|
const isSearchInput = target.matches(SEARCH_INPUT_SELECTOR);
|
|
367
|
-
|
|
368
321
|
if (code === HOME) {
|
|
369
322
|
this.focusItem(0, elements);
|
|
370
323
|
} else if (code === END) {
|
|
@@ -373,7 +326,6 @@ var script = {
|
|
|
373
326
|
if (isSearchInput) {
|
|
374
327
|
return;
|
|
375
328
|
}
|
|
376
|
-
|
|
377
329
|
if (this.searchable && elements.indexOf(target) === 0) {
|
|
378
330
|
this.focusSearchInput();
|
|
379
331
|
} else {
|
|
@@ -388,43 +340,31 @@ var script = {
|
|
|
388
340
|
} else {
|
|
389
341
|
stop = false;
|
|
390
342
|
}
|
|
391
|
-
|
|
392
343
|
if (stop) {
|
|
393
344
|
stopEvent(event);
|
|
394
345
|
}
|
|
395
346
|
},
|
|
396
|
-
|
|
397
347
|
getFocusableListItemElements() {
|
|
398
348
|
var _this$$refs$list;
|
|
399
|
-
|
|
400
349
|
const items = (_this$$refs$list = this.$refs.list) === null || _this$$refs$list === void 0 ? void 0 : _this$$refs$list.querySelectorAll(ITEM_SELECTOR);
|
|
401
350
|
return Array.from(items || []);
|
|
402
351
|
},
|
|
403
|
-
|
|
404
352
|
focusNextItem(event, elements, offset) {
|
|
405
353
|
const {
|
|
406
354
|
target
|
|
407
355
|
} = event;
|
|
408
356
|
const currentIndex = elements.indexOf(target);
|
|
409
|
-
|
|
410
357
|
const nextIndex = _clamp(currentIndex + offset, 0, elements.length - 1);
|
|
411
|
-
|
|
412
358
|
this.focusItem(nextIndex, elements);
|
|
413
359
|
},
|
|
414
|
-
|
|
415
360
|
focusItem(index, elements) {
|
|
361
|
+
var _elements$index;
|
|
416
362
|
this.nextFocusedItemIndex = index;
|
|
417
|
-
|
|
418
|
-
var _elements$index;
|
|
419
|
-
|
|
420
|
-
(_elements$index = elements[index]) === null || _elements$index === void 0 ? void 0 : _elements$index.focus();
|
|
421
|
-
});
|
|
363
|
+
(_elements$index = elements[index]) === null || _elements$index === void 0 ? void 0 : _elements$index.focus();
|
|
422
364
|
},
|
|
423
|
-
|
|
424
365
|
focusSearchInput() {
|
|
425
366
|
this.$refs.searchBox.focusInput();
|
|
426
367
|
},
|
|
427
|
-
|
|
428
368
|
onSelect(item, isSelected) {
|
|
429
369
|
if (this.multiple) {
|
|
430
370
|
this.onMultiSelect(item.value, isSelected);
|
|
@@ -432,15 +372,12 @@ var script = {
|
|
|
432
372
|
this.onSingleSelect(item.value, isSelected);
|
|
433
373
|
}
|
|
434
374
|
},
|
|
435
|
-
|
|
436
375
|
isSelected(item) {
|
|
437
376
|
return this.selectedValues.some(value => value === item.value);
|
|
438
377
|
},
|
|
439
|
-
|
|
440
378
|
isFocused(item) {
|
|
441
379
|
return this.nextFocusedItemIndex === this.flattenedOptions.indexOf(item);
|
|
442
380
|
},
|
|
443
|
-
|
|
444
381
|
onSingleSelect(value, isSelected) {
|
|
445
382
|
if (isSelected) {
|
|
446
383
|
/**
|
|
@@ -450,10 +387,8 @@ var script = {
|
|
|
450
387
|
*/
|
|
451
388
|
this.$emit('select', value);
|
|
452
389
|
}
|
|
453
|
-
|
|
454
390
|
this.$refs.baseDropdown.closeAndFocus();
|
|
455
391
|
},
|
|
456
|
-
|
|
457
392
|
onMultiSelect(value, isSelected) {
|
|
458
393
|
if (isSelected) {
|
|
459
394
|
this.$emit('select', [...this.selectedValues, value]);
|
|
@@ -461,7 +396,6 @@ var script = {
|
|
|
461
396
|
this.$emit('select', this.selectedValues.filter(selectedValue => selectedValue !== value));
|
|
462
397
|
}
|
|
463
398
|
},
|
|
464
|
-
|
|
465
399
|
search(searchTerm) {
|
|
466
400
|
/**
|
|
467
401
|
* Emitted when the search query string is changed
|
|
@@ -471,7 +405,6 @@ var script = {
|
|
|
471
405
|
*/
|
|
472
406
|
this.$emit('search', searchTerm);
|
|
473
407
|
},
|
|
474
|
-
|
|
475
408
|
isOption
|
|
476
409
|
}
|
|
477
410
|
};
|
|
@@ -29,27 +29,22 @@ var script = {
|
|
|
29
29
|
if (this.isCheckCentered) {
|
|
30
30
|
return '';
|
|
31
31
|
}
|
|
32
|
-
|
|
33
32
|
return 'gl-mt-3 gl-align-self-start';
|
|
34
33
|
}
|
|
35
|
-
|
|
36
34
|
},
|
|
37
35
|
methods: {
|
|
38
36
|
toggleSelection() {
|
|
39
37
|
this.$emit('select', !this.isSelected);
|
|
40
38
|
},
|
|
41
|
-
|
|
42
39
|
onKeydown(event) {
|
|
43
40
|
const {
|
|
44
41
|
code
|
|
45
42
|
} = event;
|
|
46
|
-
|
|
47
43
|
if (code === ENTER || code === SPACE) {
|
|
48
44
|
stopEvent(event);
|
|
49
45
|
this.toggleSelection();
|
|
50
46
|
}
|
|
51
47
|
}
|
|
52
|
-
|
|
53
48
|
}
|
|
54
49
|
};
|
|
55
50
|
|
|
@@ -1,34 +1,27 @@
|
|
|
1
1
|
import _isString from 'lodash/isString';
|
|
2
2
|
|
|
3
3
|
const isOption = item => Boolean(item) && _isString(item.value);
|
|
4
|
-
|
|
5
4
|
const isGroup = function () {
|
|
6
5
|
let {
|
|
7
6
|
options
|
|
8
7
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
9
8
|
return Array.isArray(options) && options.every(isOption);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
10
|
const hasNoDuplicates = array => array.length === new Set(array).size;
|
|
13
|
-
|
|
14
11
|
const flattenedOptions = items => items.flatMap(item => isOption(item) ? item : item.options);
|
|
15
|
-
|
|
16
12
|
const isAllOptionsOrAllGroups = items => items.every(isOption) || items.every(isGroup);
|
|
17
|
-
|
|
18
13
|
const hasUniqueValues = items => hasNoDuplicates(flattenedOptions(items).map(_ref => {
|
|
19
14
|
let {
|
|
20
15
|
value
|
|
21
16
|
} = _ref;
|
|
22
17
|
return value;
|
|
23
18
|
}));
|
|
24
|
-
|
|
25
19
|
const hasUniqueGroups = items => hasNoDuplicates(items.filter(isGroup).map(_ref2 => {
|
|
26
20
|
let {
|
|
27
21
|
text
|
|
28
22
|
} = _ref2;
|
|
29
23
|
return text;
|
|
30
24
|
}));
|
|
31
|
-
|
|
32
25
|
const itemsValidator = items => isAllOptionsOrAllGroups(items) && hasUniqueValues(items) && hasUniqueGroups(items);
|
|
33
26
|
|
|
34
27
|
export { flattenedOptions, isOption, itemsValidator };
|