@gitlab/ui 72.12.0 → 72.12.1
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 +7 -0
- package/dist/charts.js +14 -0
- package/dist/components/base/accordion/accordion.js +73 -0
- package/dist/components/base/accordion/accordion_item.js +133 -0
- package/dist/components/base/alert/alert.js +222 -0
- package/dist/components/base/avatar/avatar.js +160 -0
- package/dist/components/base/avatar_labeled/avatar_labeled.js +107 -0
- package/dist/components/base/avatar_link/avatar_link.js +47 -0
- package/dist/components/base/avatars_inline/avatars_inline.js +119 -0
- package/dist/components/base/badge/badge.js +105 -0
- package/dist/components/base/banner/banner.js +139 -0
- package/dist/components/base/breadcrumb/breadcrumb.js +122 -0
- package/dist/components/base/breadcrumb/breadcrumb_item.js +73 -0
- package/dist/components/base/broadcast_message/broadcast_message.js +112 -0
- package/dist/components/base/broadcast_message/constants.js +5 -0
- package/dist/components/base/button/button.js +151 -0
- package/dist/components/base/button_group/button_group.js +47 -0
- package/dist/components/base/card/card.js +71 -0
- package/dist/components/base/carousel/carousel.js +48 -0
- package/dist/components/base/carousel/carousel_slide.js +47 -0
- package/dist/components/base/collapse/collapse.js +59 -0
- package/dist/components/base/datepicker/datepicker.js +386 -0
- package/dist/components/base/daterange_picker/daterange_picker.js +288 -0
- package/dist/components/base/drawer/drawer.js +127 -0
- package/dist/components/base/dropdown/dropdown.js +261 -0
- package/dist/components/base/dropdown/dropdown_divider.js +48 -0
- package/dist/components/base/dropdown/dropdown_form.js +48 -0
- package/dist/components/base/dropdown/dropdown_item.js +131 -0
- package/dist/components/base/dropdown/dropdown_section_header.js +48 -0
- package/dist/components/base/dropdown/dropdown_text.js +48 -0
- package/dist/components/base/filtered_search/common_story_options.js +14 -0
- package/dist/components/base/filtered_search/filtered_search.js +388 -0
- package/dist/components/base/filtered_search/filtered_search_suggestion.js +89 -0
- package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +138 -0
- package/dist/components/base/filtered_search/filtered_search_term.js +203 -0
- package/dist/components/base/filtered_search/filtered_search_token.js +384 -0
- package/dist/components/base/filtered_search/filtered_search_token_segment.js +420 -0
- package/dist/components/base/filtered_search/filtered_search_utils.js +242 -0
- package/dist/components/base/form/form.js +49 -0
- package/dist/components/base/form/form_checkbox/form_checkbox.js +78 -0
- package/dist/components/base/form/form_checkbox/form_checkbox_group.js +60 -0
- package/dist/components/base/form/form_checkbox_tree/checkbox_tree_node.js +79 -0
- package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.js +138 -0
- package/dist/components/base/form/form_checkbox_tree/models/constants.js +12 -0
- package/dist/components/base/form/form_checkbox_tree/models/node.js +51 -0
- package/dist/components/base/form/form_checkbox_tree/models/tree.js +199 -0
- package/dist/components/base/form/form_combobox/constants.js +55 -0
- package/dist/components/base/form/form_combobox/form_combobox.js +230 -0
- package/dist/components/base/form/form_date/form_date.js +143 -0
- package/dist/components/base/form/form_fields/form_field_validator.js +93 -0
- package/dist/components/base/form/form_fields/form_fields.js +214 -0
- package/dist/components/base/form/form_fields/mappers.js +13 -0
- package/dist/components/base/form/form_fields/validators.js +48 -0
- package/dist/components/base/form/form_group/form_group.js +97 -0
- package/dist/components/base/form/form_input/form_input.js +121 -0
- package/dist/components/base/form/form_input_group/form_input_group.js +108 -0
- package/dist/components/base/form/form_input_group/form_input_group_mixin.js +41 -0
- package/dist/components/base/form/form_radio/form_radio.js +65 -0
- package/dist/components/base/form/form_radio_group/form_radio_group.js +78 -0
- package/dist/components/base/form/form_select/constants.js +12 -0
- package/dist/components/base/form/form_select/form_select.js +82 -0
- package/dist/components/base/form/form_text/form_text.js +38 -0
- package/dist/components/base/form/form_textarea/form_textarea.js +112 -0
- package/dist/components/base/form/input_group_text/input_group_text.js +48 -0
- package/dist/components/base/icon/icon.js +111 -0
- package/dist/components/base/infinite_scroll/infinite_scroll.js +197 -0
- package/dist/components/base/keyset_pagination/keyset_pagination.js +151 -0
- package/dist/components/base/label/label.js +163 -0
- package/dist/components/base/link/link.js +50 -0
- package/dist/components/base/loading_icon/loading_icon.js +111 -0
- package/dist/components/base/markdown/markdown.js +52 -0
- package/dist/components/base/modal/modal.js +204 -0
- package/dist/components/base/nav/nav.js +48 -0
- package/dist/components/base/nav/nav_item.js +48 -0
- package/dist/components/base/nav/nav_item_dropdown.js +62 -0
- package/dist/components/base/navbar/navbar.js +48 -0
- package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +453 -0
- package/dist/components/base/new_dropdowns/base_dropdown/constants.js +4 -0
- package/dist/components/base/new_dropdowns/constants.js +21 -0
- package/dist/components/base/new_dropdowns/disclosure/constants.js +8 -0
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown.js +370 -0
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_group.js +110 -0
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_item.js +143 -0
- package/dist/components/base/new_dropdowns/disclosure/mock_data.js +147 -0
- package/dist/components/base/new_dropdowns/disclosure/utils.js +39 -0
- package/dist/components/base/new_dropdowns/listbox/listbox.js +767 -0
- package/dist/components/base/new_dropdowns/listbox/listbox_group.js +58 -0
- package/dist/components/base/new_dropdowns/listbox/listbox_item.js +91 -0
- package/dist/components/base/new_dropdowns/listbox/listbox_search_input.js +93 -0
- package/dist/components/base/new_dropdowns/listbox/mock_data.js +118 -0
- package/dist/components/base/new_dropdowns/listbox/utils.js +34 -0
- package/dist/components/base/paginated_list/paginated_list.js +180 -0
- package/dist/components/base/pagination/pagination.js +399 -0
- package/dist/components/base/path/data.js +34 -0
- package/dist/components/base/path/path.js +189 -0
- package/dist/components/base/popover/popover.js +110 -0
- package/dist/components/base/progress_bar/progress_bar.js +48 -0
- package/dist/components/base/search_box_by_click/search_box_by_click.js +235 -0
- package/dist/components/base/search_box_by_type/search_box_by_type.js +167 -0
- package/dist/components/base/segmented_control/segmented_control.js +109 -0
- package/dist/components/base/skeleton_loader/skeleton_loader.js +224 -0
- package/dist/components/base/sorting/sorting.js +171 -0
- package/dist/components/base/sorting/sorting_item.js +109 -0
- package/dist/components/base/table/constants.js +5 -0
- package/dist/components/base/table/table.js +89 -0
- package/dist/components/base/table_lite/table_lite.js +72 -0
- package/dist/components/base/tabs/constants.js +3 -0
- package/dist/components/base/tabs/tab/tab.js +83 -0
- package/dist/components/base/tabs/tabs/scrollable_tabs.js +143 -0
- package/dist/components/base/tabs/tabs/tabs.js +224 -0
- package/dist/components/base/toast/toast.js +82 -0
- package/dist/components/base/toggle/toggle.js +180 -0
- package/dist/components/base/token/token.js +85 -0
- package/dist/components/base/token_selector/helpers.js +5 -0
- package/dist/components/base/token_selector/token_container.js +165 -0
- package/dist/components/base/token_selector/token_selector.js +403 -0
- package/dist/components/base/token_selector/token_selector_dropdown.js +199 -0
- package/dist/components/base/tooltip/tooltip.js +55 -0
- package/dist/components/charts/area/area.js +311 -0
- package/dist/components/charts/bar/bar.js +253 -0
- package/dist/components/charts/chart/chart.js +215 -0
- package/dist/components/charts/column/column.js +226 -0
- package/dist/components/charts/discrete_scatter/discrete_scatter.js +203 -0
- package/dist/components/charts/gauge/gauge.js +208 -0
- package/dist/components/charts/heatmap/heatmap.js +295 -0
- package/dist/components/charts/heatmap/index.js +2 -0
- package/dist/components/charts/legend/legend.js +228 -0
- package/dist/components/charts/line/line.js +308 -0
- package/dist/components/charts/series_label/series_label.js +100 -0
- package/dist/components/charts/single_stat/single_stat.js +152 -0
- package/dist/components/charts/sparkline/sparkline.js +261 -0
- package/dist/components/charts/stacked_column/stacked_column.js +335 -0
- package/dist/components/charts/tooltip/tooltip.js +251 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.js +83 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.js +100 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.js +35 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +115 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.js +104 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.js +64 -0
- package/dist/components/experimental/duo/chat/constants.js +23 -0
- package/dist/components/experimental/duo/chat/duo_chat.js +359 -0
- package/dist/components/experimental/duo/chat/mock_data.js +83 -0
- package/dist/components/experimental/duo/user_feedback/user_feedback.js +94 -0
- package/dist/components/experimental/duo/user_feedback/user_feedback_modal.js +124 -0
- package/dist/components/experimental/experiment_badge/constants.js +4 -0
- package/dist/components/experimental/experiment_badge/experiment_badge.js +107 -0
- package/dist/components/mixins/button_mixin.js +11 -0
- package/dist/components/mixins/safe_link_mixin.js +30 -0
- package/dist/components/mixins/tooltip_mixin.js +21 -0
- package/dist/components/regions/dashboard_skeleton/dashboard_skeleton.js +53 -0
- package/dist/components/regions/empty_state/empty_state.js +154 -0
- package/dist/components/shared_components/charts/tooltip_default_format.js +53 -0
- package/dist/components/shared_components/clear_icon_button/clear_icon_button.js +64 -0
- package/dist/components/shared_components/close_button/close_button.js +54 -0
- package/dist/components/utilities/animated_number/animated_number.js +131 -0
- package/dist/components/utilities/friendly_wrap/friendly_wrap.js +75 -0
- package/dist/components/utilities/intersection_observer/intersection_observer.js +88 -0
- package/dist/components/utilities/intersperse/intersperse.js +86 -0
- package/dist/components/utilities/sprintf/sprintf.js +172 -0
- package/dist/components/utilities/truncate/constants.js +7 -0
- package/dist/components/utilities/truncate/truncate.js +111 -0
- package/dist/components/utilities/truncate_text/constants.js +7 -0
- package/dist/components/utilities/truncate_text/truncate_text.js +146 -0
- package/dist/config.js +86 -0
- package/dist/directives/collapse_toggle.js +1 -0
- package/dist/directives/hover_load/hover_load.js +45 -0
- package/dist/directives/modal.js +1 -0
- package/dist/directives/outside/get_event_like_time_stamp.js +33 -0
- package/dist/directives/outside/outside.js +106 -0
- package/dist/directives/resize_observer/resize_observer.js +51 -0
- package/dist/directives/safe_html/constants.js +6 -0
- package/dist/directives/safe_html/safe_html.js +39 -0
- package/dist/directives/safe_link/mock_data.js +10 -0
- package/dist/directives/safe_link/safe_link.js +65 -0
- package/dist/directives/tooltip.js +1 -0
- package/dist/index.css +7 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +105 -0
- package/dist/tokens/common_story_options.js +54 -0
- package/dist/tokens/css/tokens.css +1 -1
- package/dist/tokens/css/tokens.dark.css +1 -1
- package/dist/tokens/js/tokens.dark.js +1 -1
- package/dist/tokens/js/tokens.js +1 -1
- package/dist/tokens/scss/_tokens.dark.scss +1 -1
- package/dist/tokens/scss/_tokens.scss +1 -1
- package/dist/utils/breakpoints.js +20 -0
- package/dist/utils/charts/config.js +556 -0
- package/dist/utils/charts/constants.js +63 -0
- package/dist/utils/charts/mock_data.js +211 -0
- package/dist/utils/charts/story_config.js +42 -0
- package/dist/utils/charts/theme.js +192 -0
- package/dist/utils/charts/utils.js +54 -0
- package/dist/utils/constants.js +288 -0
- package/dist/utils/data_utils.js +21 -0
- package/dist/utils/datetime_utility.js +61 -0
- package/dist/utils/i18n.js +15 -0
- package/dist/utils/is_slot_empty.js +38 -0
- package/dist/utils/number_utils.js +124 -0
- package/dist/utils/stories_constants.js +29 -0
- package/dist/utils/stories_utils.js +13 -0
- package/dist/utils/story_decorators/container.js +16 -0
- package/dist/utils/string_utils.js +69 -0
- package/dist/utils/svgs/svg_paths.js +7 -0
- package/dist/utils/test_utils.js +33 -0
- package/dist/utils/use_fake_date.js +29 -0
- package/dist/utils/use_mock_intersection_observer.js +108 -0
- package/dist/utils/utils.js +197 -0
- package/dist/utils.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,767 @@
|
|
|
1
|
+
import clamp from 'lodash/clamp';
|
|
2
|
+
import uniqueId from 'lodash/uniqueId';
|
|
3
|
+
import isNil from 'lodash/isNil';
|
|
4
|
+
import { stopEvent } from '../../../../utils/utils';
|
|
5
|
+
import { GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, POSITION_ABSOLUTE, POSITION_FIXED, GL_DROPDOWN_CONTENTS_CLASS, HOME, END, ARROW_UP, ARROW_DOWN } from '../constants';
|
|
6
|
+
import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions, dropdownPlacements } from '../../../../utils/constants';
|
|
7
|
+
import GlButton from '../../button/button';
|
|
8
|
+
import GlLoadingIcon from '../../loading_icon/loading_icon';
|
|
9
|
+
import GlIntersectionObserver from '../../../utilities/intersection_observer/intersection_observer';
|
|
10
|
+
import GlSearchBoxByType from '../../search_box_by_type/search_box_by_type';
|
|
11
|
+
import GlBaseDropdown from '../base_dropdown/base_dropdown';
|
|
12
|
+
import { translate } from '../../../../utils/i18n';
|
|
13
|
+
import GlListboxItem from './listbox_item';
|
|
14
|
+
import GlListboxSearchInput from './listbox_search_input';
|
|
15
|
+
import GlListboxGroup from './listbox_group';
|
|
16
|
+
import { itemsValidator, isOption, flattenedOptions } from './utils';
|
|
17
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
18
|
+
|
|
19
|
+
//
|
|
20
|
+
const ITEM_SELECTOR = '[role="option"]';
|
|
21
|
+
const HEADER_ITEMS_BORDER_CLASSES = ['gl-border-b-1', 'gl-border-b-solid', 'gl-border-b-gray-200'];
|
|
22
|
+
const GROUP_TOP_BORDER_CLASSES = ['gl-border-t', 'gl-border-t-gray-200', 'gl-pt-1', 'gl-mt-2'];
|
|
23
|
+
const SEARCH_INPUT_SELECTOR = '.gl-listbox-search-input';
|
|
24
|
+
var script = {
|
|
25
|
+
name: 'GlCollapsibleListbox',
|
|
26
|
+
HEADER_ITEMS_BORDER_CLASSES,
|
|
27
|
+
events: {
|
|
28
|
+
GL_DROPDOWN_SHOWN,
|
|
29
|
+
GL_DROPDOWN_HIDDEN
|
|
30
|
+
},
|
|
31
|
+
components: {
|
|
32
|
+
GlBaseDropdown,
|
|
33
|
+
GlListboxItem,
|
|
34
|
+
GlListboxGroup,
|
|
35
|
+
GlButton,
|
|
36
|
+
GlSearchBoxByType,
|
|
37
|
+
GlListboxSearchInput,
|
|
38
|
+
GlLoadingIcon,
|
|
39
|
+
GlIntersectionObserver
|
|
40
|
+
},
|
|
41
|
+
model: {
|
|
42
|
+
prop: 'selected',
|
|
43
|
+
event: 'select'
|
|
44
|
+
},
|
|
45
|
+
props: {
|
|
46
|
+
/**
|
|
47
|
+
* Items to display in the dropdown
|
|
48
|
+
*/
|
|
49
|
+
items: {
|
|
50
|
+
type: Array,
|
|
51
|
+
required: false,
|
|
52
|
+
default: () => [],
|
|
53
|
+
validator: itemsValidator
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Array of selected items values for multi-select and selected item value for single-select
|
|
57
|
+
*/
|
|
58
|
+
selected: {
|
|
59
|
+
type: [Array, String, Number],
|
|
60
|
+
required: false,
|
|
61
|
+
default: () => []
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* Allow multi-selection
|
|
65
|
+
*/
|
|
66
|
+
multiple: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
required: false,
|
|
69
|
+
default: false
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* Toggle button text
|
|
73
|
+
*/
|
|
74
|
+
toggleText: {
|
|
75
|
+
type: String,
|
|
76
|
+
required: false,
|
|
77
|
+
default: ''
|
|
78
|
+
},
|
|
79
|
+
/**
|
|
80
|
+
* Toggle text to be read by screen readers only
|
|
81
|
+
*/
|
|
82
|
+
textSrOnly: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
required: false,
|
|
85
|
+
default: false
|
|
86
|
+
},
|
|
87
|
+
/** The header text */
|
|
88
|
+
headerText: {
|
|
89
|
+
type: String,
|
|
90
|
+
required: false,
|
|
91
|
+
default: ''
|
|
92
|
+
},
|
|
93
|
+
/**
|
|
94
|
+
* Styling option - dropdown's toggle category
|
|
95
|
+
*/
|
|
96
|
+
category: {
|
|
97
|
+
type: String,
|
|
98
|
+
required: false,
|
|
99
|
+
default: buttonCategoryOptions.primary,
|
|
100
|
+
validator: value => value in buttonCategoryOptions
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* Styling option - dropdown's toggle variant
|
|
104
|
+
*/
|
|
105
|
+
variant: {
|
|
106
|
+
type: String,
|
|
107
|
+
required: false,
|
|
108
|
+
default: dropdownVariantOptions.default,
|
|
109
|
+
validator: value => value in dropdownVariantOptions
|
|
110
|
+
},
|
|
111
|
+
/**
|
|
112
|
+
* The size of the dropdown toggle
|
|
113
|
+
*/
|
|
114
|
+
size: {
|
|
115
|
+
type: String,
|
|
116
|
+
required: false,
|
|
117
|
+
default: 'medium',
|
|
118
|
+
validator: value => value in buttonSizeOptions
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* Icon name that will be rendered in the toggle button
|
|
122
|
+
*/
|
|
123
|
+
icon: {
|
|
124
|
+
type: String,
|
|
125
|
+
required: false,
|
|
126
|
+
default: ''
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* Set to "true" to disable the dropdown
|
|
130
|
+
*/
|
|
131
|
+
disabled: {
|
|
132
|
+
type: Boolean,
|
|
133
|
+
required: false,
|
|
134
|
+
default: false
|
|
135
|
+
},
|
|
136
|
+
/**
|
|
137
|
+
* Set to "true" when dropdown content (items) is loading
|
|
138
|
+
* It will render a small loader in the dropdown toggle and make it disabled
|
|
139
|
+
*/
|
|
140
|
+
loading: {
|
|
141
|
+
type: Boolean,
|
|
142
|
+
required: false,
|
|
143
|
+
default: false
|
|
144
|
+
},
|
|
145
|
+
/**
|
|
146
|
+
* Additional CSS classes to customize toggle appearance
|
|
147
|
+
*/
|
|
148
|
+
toggleClass: {
|
|
149
|
+
type: [String, Array, Object],
|
|
150
|
+
required: false,
|
|
151
|
+
default: null
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
* Set to "true" to hide the caret
|
|
155
|
+
*/
|
|
156
|
+
noCaret: {
|
|
157
|
+
type: Boolean,
|
|
158
|
+
required: false,
|
|
159
|
+
default: false
|
|
160
|
+
},
|
|
161
|
+
/**
|
|
162
|
+
* Align listbox menu with respect to the toggle button
|
|
163
|
+
*/
|
|
164
|
+
placement: {
|
|
165
|
+
type: String,
|
|
166
|
+
required: false,
|
|
167
|
+
default: 'left',
|
|
168
|
+
validator: value => Object.keys(dropdownPlacements).includes(value)
|
|
169
|
+
},
|
|
170
|
+
/**
|
|
171
|
+
* Center selected item checkmark
|
|
172
|
+
*/
|
|
173
|
+
isCheckCentered: {
|
|
174
|
+
type: Boolean,
|
|
175
|
+
required: false,
|
|
176
|
+
default: false
|
|
177
|
+
},
|
|
178
|
+
/**
|
|
179
|
+
* The `aria-labelledby` attribute value for the toggle button
|
|
180
|
+
* Provide the string of ids seperated by space
|
|
181
|
+
*/
|
|
182
|
+
toggleAriaLabelledBy: {
|
|
183
|
+
type: String,
|
|
184
|
+
required: false,
|
|
185
|
+
default: null
|
|
186
|
+
},
|
|
187
|
+
/**
|
|
188
|
+
* The `aria-labelledby` attribute value for the list of options
|
|
189
|
+
* Provide the string of ids seperated by space
|
|
190
|
+
*/
|
|
191
|
+
listAriaLabelledBy: {
|
|
192
|
+
type: String,
|
|
193
|
+
required: false,
|
|
194
|
+
default: null
|
|
195
|
+
},
|
|
196
|
+
/**
|
|
197
|
+
* Enable search
|
|
198
|
+
*/
|
|
199
|
+
searchable: {
|
|
200
|
+
type: Boolean,
|
|
201
|
+
required: false,
|
|
202
|
+
default: false
|
|
203
|
+
},
|
|
204
|
+
/**
|
|
205
|
+
* Set to "true" when items search is in progress.
|
|
206
|
+
* It will display loading icon below the search input
|
|
207
|
+
*/
|
|
208
|
+
searching: {
|
|
209
|
+
type: Boolean,
|
|
210
|
+
required: false,
|
|
211
|
+
default: false
|
|
212
|
+
},
|
|
213
|
+
/**
|
|
214
|
+
* Enables infinite scroll.
|
|
215
|
+
* When set to `true`, the `@bottom-reached` event will be fired when
|
|
216
|
+
* the bottom of the listbox is scrolled to.
|
|
217
|
+
* Does not support groups.
|
|
218
|
+
*/
|
|
219
|
+
infiniteScroll: {
|
|
220
|
+
type: Boolean,
|
|
221
|
+
required: false,
|
|
222
|
+
default: false
|
|
223
|
+
},
|
|
224
|
+
/**
|
|
225
|
+
* This prop is used for infinite scroll.
|
|
226
|
+
* It represents the total number of items that exist,
|
|
227
|
+
* even if they have not yet been loaded.
|
|
228
|
+
* Do not set this prop if the total number of items is unknown.
|
|
229
|
+
*/
|
|
230
|
+
totalItems: {
|
|
231
|
+
type: Number,
|
|
232
|
+
required: false,
|
|
233
|
+
default: null
|
|
234
|
+
},
|
|
235
|
+
/**
|
|
236
|
+
* This prop is used for infinite scroll.
|
|
237
|
+
* Set to `true` when more items are being loaded.
|
|
238
|
+
*/
|
|
239
|
+
infiniteScrollLoading: {
|
|
240
|
+
type: Boolean,
|
|
241
|
+
required: false,
|
|
242
|
+
default: false
|
|
243
|
+
},
|
|
244
|
+
/**
|
|
245
|
+
* Message to be displayed when filtering produced no results
|
|
246
|
+
*/
|
|
247
|
+
noResultsText: {
|
|
248
|
+
type: String,
|
|
249
|
+
required: false,
|
|
250
|
+
default: 'No results found'
|
|
251
|
+
},
|
|
252
|
+
/**
|
|
253
|
+
* Search input placeholder text and aria-label
|
|
254
|
+
*/
|
|
255
|
+
searchPlaceholder: {
|
|
256
|
+
type: String,
|
|
257
|
+
required: false,
|
|
258
|
+
default: 'Search'
|
|
259
|
+
},
|
|
260
|
+
/**
|
|
261
|
+
* The reset button's label, to be rendered in the header. If this is omitted, the button is not
|
|
262
|
+
* rendered.
|
|
263
|
+
* The reset button requires a header to be set, so this prop should be used in conjunction with
|
|
264
|
+
* headerText.
|
|
265
|
+
*/
|
|
266
|
+
resetButtonLabel: {
|
|
267
|
+
type: String,
|
|
268
|
+
required: false,
|
|
269
|
+
default: ''
|
|
270
|
+
},
|
|
271
|
+
/**
|
|
272
|
+
* The select all button's label, to be rendered in the header. If this is omitted, the button is not
|
|
273
|
+
* rendered.
|
|
274
|
+
* The select all button requires a header to be set, so this prop should be used in conjunction with
|
|
275
|
+
* headerText.
|
|
276
|
+
*/
|
|
277
|
+
showSelectAllButtonLabel: {
|
|
278
|
+
type: String,
|
|
279
|
+
required: false,
|
|
280
|
+
default: ''
|
|
281
|
+
},
|
|
282
|
+
/**
|
|
283
|
+
* Render the toggle button as a block element
|
|
284
|
+
*/
|
|
285
|
+
block: {
|
|
286
|
+
type: Boolean,
|
|
287
|
+
required: false,
|
|
288
|
+
default: false
|
|
289
|
+
},
|
|
290
|
+
/**
|
|
291
|
+
* Custom offset to be applied to Floating UI's offset middleware.
|
|
292
|
+
* https://floating-ui.com/docs/offset
|
|
293
|
+
*/
|
|
294
|
+
dropdownOffset: {
|
|
295
|
+
type: [Number, Object],
|
|
296
|
+
required: false,
|
|
297
|
+
default: undefined
|
|
298
|
+
},
|
|
299
|
+
/**
|
|
300
|
+
* Lets the dropdown extend to match its content's width, up to a maximum width
|
|
301
|
+
* defined by the `$gl-new-dropdown-max-width` variable.
|
|
302
|
+
*/
|
|
303
|
+
fluidWidth: {
|
|
304
|
+
type: Boolean,
|
|
305
|
+
required: false,
|
|
306
|
+
default: false
|
|
307
|
+
},
|
|
308
|
+
/**
|
|
309
|
+
* Strategy to be applied by computePosition. If the dropdown's container is too short for it to
|
|
310
|
+
* fit in, setting this to fixed will let it position itself above its container.
|
|
311
|
+
* https://floating-ui.com/docs/computePosition#strategy
|
|
312
|
+
*/
|
|
313
|
+
positioningStrategy: {
|
|
314
|
+
type: String,
|
|
315
|
+
required: false,
|
|
316
|
+
default: POSITION_ABSOLUTE,
|
|
317
|
+
validator: strategy => [POSITION_ABSOLUTE, POSITION_FIXED].includes(strategy)
|
|
318
|
+
},
|
|
319
|
+
/**
|
|
320
|
+
* Opens dropdown on render
|
|
321
|
+
*/
|
|
322
|
+
startOpened: {
|
|
323
|
+
type: Boolean,
|
|
324
|
+
required: false,
|
|
325
|
+
default: false
|
|
326
|
+
},
|
|
327
|
+
srOnlyResultsLabel: {
|
|
328
|
+
type: Function,
|
|
329
|
+
required: false,
|
|
330
|
+
default: count => {
|
|
331
|
+
const fn = translate('GlCollapsibleListbox.srOnlyResultsLabel', 'Results count');
|
|
332
|
+
if (typeof fn === 'function') {
|
|
333
|
+
return fn(count);
|
|
334
|
+
}
|
|
335
|
+
return `${count} result${count > 1 ? 's' : ''}`;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
data() {
|
|
340
|
+
return {
|
|
341
|
+
selectedValues: [],
|
|
342
|
+
toggleId: uniqueId('dropdown-toggle-btn-'),
|
|
343
|
+
listboxId: uniqueId('listbox-'),
|
|
344
|
+
nextFocusedItemIndex: null,
|
|
345
|
+
searchStr: '',
|
|
346
|
+
topBoundaryVisible: true,
|
|
347
|
+
bottomBoundaryVisible: true
|
|
348
|
+
};
|
|
349
|
+
},
|
|
350
|
+
computed: {
|
|
351
|
+
listboxTag() {
|
|
352
|
+
if (!this.hasItems || isOption(this.items[0])) return 'ul';
|
|
353
|
+
return 'div';
|
|
354
|
+
},
|
|
355
|
+
listboxClasses() {
|
|
356
|
+
return {
|
|
357
|
+
'top-scrim-visible': !this.topBoundaryVisible,
|
|
358
|
+
'bottom-scrim-visible': !this.bottomBoundaryVisible,
|
|
359
|
+
[GL_DROPDOWN_CONTENTS_CLASS]: true
|
|
360
|
+
};
|
|
361
|
+
},
|
|
362
|
+
itemTag() {
|
|
363
|
+
return this.listboxTag === 'ul' ? 'li' : 'div';
|
|
364
|
+
},
|
|
365
|
+
flattenedOptions() {
|
|
366
|
+
return flattenedOptions(this.items);
|
|
367
|
+
},
|
|
368
|
+
hasItems() {
|
|
369
|
+
return this.items.length > 0;
|
|
370
|
+
},
|
|
371
|
+
listboxToggleText() {
|
|
372
|
+
if (!this.toggleText) {
|
|
373
|
+
if (!this.multiple && this.selectedValues.length) {
|
|
374
|
+
var _this$flattenedOption;
|
|
375
|
+
return (_this$flattenedOption = this.flattenedOptions.find(_ref => {
|
|
376
|
+
let {
|
|
377
|
+
value
|
|
378
|
+
} = _ref;
|
|
379
|
+
return value === this.selectedValues[0];
|
|
380
|
+
})) === null || _this$flattenedOption === void 0 ? void 0 : _this$flattenedOption.text;
|
|
381
|
+
}
|
|
382
|
+
return '';
|
|
383
|
+
}
|
|
384
|
+
return this.toggleText;
|
|
385
|
+
},
|
|
386
|
+
selectedIndices() {
|
|
387
|
+
return this.selectedValues.map(selected => this.flattenedOptions.findIndex(_ref2 => {
|
|
388
|
+
let {
|
|
389
|
+
value
|
|
390
|
+
} = _ref2;
|
|
391
|
+
return value === selected;
|
|
392
|
+
})).sort();
|
|
393
|
+
},
|
|
394
|
+
showList() {
|
|
395
|
+
return this.flattenedOptions.length && !this.searching;
|
|
396
|
+
},
|
|
397
|
+
showNoResultsText() {
|
|
398
|
+
return !this.flattenedOptions.length && !this.searching;
|
|
399
|
+
},
|
|
400
|
+
announceSRSearchResults() {
|
|
401
|
+
return this.searchable && !this.showNoResultsText;
|
|
402
|
+
},
|
|
403
|
+
headerId() {
|
|
404
|
+
return this.headerText && uniqueId('listbox-header-');
|
|
405
|
+
},
|
|
406
|
+
showResetButton() {
|
|
407
|
+
if (!this.resetButtonLabel) {
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* if dropdown has no items
|
|
413
|
+
* reset all should be hidden
|
|
414
|
+
*/
|
|
415
|
+
if (!this.hasItems) {
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// hide if no selection
|
|
420
|
+
if (!this.selected || this.selected.length === 0) {
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// only show reset button if show all button is not there
|
|
425
|
+
return !this.showSelectAllButton;
|
|
426
|
+
},
|
|
427
|
+
showSelectAllButton() {
|
|
428
|
+
if (!this.showSelectAllButtonLabel) {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
if (!this.multiple) {
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* if dropdown has no items
|
|
437
|
+
* select all should be hidden
|
|
438
|
+
*/
|
|
439
|
+
if (!this.hasItems) {
|
|
440
|
+
return false;
|
|
441
|
+
}
|
|
442
|
+
return this.selected.length !== this.flattenedOptions.length;
|
|
443
|
+
},
|
|
444
|
+
showIntersectionObserver() {
|
|
445
|
+
return this.infiniteScroll && !this.infiniteScrollLoading && !this.loading && !this.searching;
|
|
446
|
+
},
|
|
447
|
+
hasCustomToggle() {
|
|
448
|
+
return Boolean(this.$scopedSlots.toggle);
|
|
449
|
+
},
|
|
450
|
+
hasSelection() {
|
|
451
|
+
return Boolean(this.selectedValues.length);
|
|
452
|
+
},
|
|
453
|
+
toggleButtonClasses() {
|
|
454
|
+
const toggleClasses = [this.toggleClass];
|
|
455
|
+
if (!this.hasSelection) {
|
|
456
|
+
toggleClasses.push('gl-text-gray-500!');
|
|
457
|
+
}
|
|
458
|
+
return toggleClasses;
|
|
459
|
+
},
|
|
460
|
+
hasHeader() {
|
|
461
|
+
return this.headerText || this.searchable;
|
|
462
|
+
},
|
|
463
|
+
hasFooter() {
|
|
464
|
+
return Boolean(this.$scopedSlots.footer);
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
watch: {
|
|
468
|
+
selected: {
|
|
469
|
+
immediate: true,
|
|
470
|
+
handler(newSelected) {
|
|
471
|
+
if (Array.isArray(newSelected)) {
|
|
472
|
+
if (process.env.NODE_ENV !== 'production' && !this.multiple && newSelected.length) {
|
|
473
|
+
throw new Error('To allow multi-selection, please, set "multiple" property to "true"');
|
|
474
|
+
}
|
|
475
|
+
this.selectedValues = [...newSelected];
|
|
476
|
+
} else {
|
|
477
|
+
this.selectedValues = isNil(newSelected) ? [] : [newSelected];
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
items: {
|
|
482
|
+
handler() {
|
|
483
|
+
this.$nextTick(() => {
|
|
484
|
+
/* Every time the list of items changes (on search),
|
|
485
|
+
* the observed elements are recreated, thus we need to start obesrving them again */
|
|
486
|
+
this.observeScroll();
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
...(process.env.NODE_ENV !== 'production' ? {
|
|
491
|
+
resetButtonLabel: {
|
|
492
|
+
immediate: true,
|
|
493
|
+
handler(newResetButtonLabel) {
|
|
494
|
+
if (newResetButtonLabel && !this.headerText) {
|
|
495
|
+
throw new Error('The reset button cannot be rendered without a header. Either provide a header via the headerText prop, or do not provide the resetButtonLabel prop.');
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
showSelectAllButtonLabel: {
|
|
500
|
+
immediate: true,
|
|
501
|
+
handler(showSelectAllButtonLabel) {
|
|
502
|
+
if (showSelectAllButtonLabel && !this.headerText) {
|
|
503
|
+
throw new Error('The select all button cannot be rendered without a header. Either provide a header via the headerText prop, or do not provide the showSelectAllButtonLabel prop.');
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
infiniteScroll: {
|
|
508
|
+
immediate: true,
|
|
509
|
+
handler(newValue) {
|
|
510
|
+
if (newValue && this.items.some(item => !isOption(item))) {
|
|
511
|
+
throw new Error('Infinite scroll does not support groups. Please set the "infiniteScroll" prop to "false"');
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
} : {})
|
|
516
|
+
},
|
|
517
|
+
mounted() {
|
|
518
|
+
if (this.startOpened) {
|
|
519
|
+
this.open();
|
|
520
|
+
}
|
|
521
|
+
this.observeScroll();
|
|
522
|
+
},
|
|
523
|
+
beforeDestroy() {
|
|
524
|
+
var _this$scrollObserver;
|
|
525
|
+
(_this$scrollObserver = this.scrollObserver) === null || _this$scrollObserver === void 0 ? void 0 : _this$scrollObserver.disconnect();
|
|
526
|
+
},
|
|
527
|
+
methods: {
|
|
528
|
+
open() {
|
|
529
|
+
this.$refs.baseDropdown.open();
|
|
530
|
+
},
|
|
531
|
+
close() {
|
|
532
|
+
this.$refs.baseDropdown.close();
|
|
533
|
+
},
|
|
534
|
+
groupClasses(index) {
|
|
535
|
+
return index === 0 ? null : GROUP_TOP_BORDER_CLASSES;
|
|
536
|
+
},
|
|
537
|
+
onShow() {
|
|
538
|
+
if (this.searchable) {
|
|
539
|
+
this.focusSearchInput();
|
|
540
|
+
} else {
|
|
541
|
+
var _this$selectedIndices;
|
|
542
|
+
this.focusItem((_this$selectedIndices = this.selectedIndices[0]) !== null && _this$selectedIndices !== void 0 ? _this$selectedIndices : 0, this.getFocusableListItemElements());
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Emitted when dropdown is shown
|
|
546
|
+
*
|
|
547
|
+
* @event shown
|
|
548
|
+
*/
|
|
549
|
+
this.$emit(GL_DROPDOWN_SHOWN);
|
|
550
|
+
},
|
|
551
|
+
onHide() {
|
|
552
|
+
/**
|
|
553
|
+
* Emitted when dropdown is hidden
|
|
554
|
+
*
|
|
555
|
+
* @event hidden
|
|
556
|
+
*/
|
|
557
|
+
this.$emit(GL_DROPDOWN_HIDDEN);
|
|
558
|
+
this.nextFocusedItemIndex = null;
|
|
559
|
+
},
|
|
560
|
+
onKeydown(event) {
|
|
561
|
+
const {
|
|
562
|
+
code,
|
|
563
|
+
target
|
|
564
|
+
} = event;
|
|
565
|
+
const elements = this.getFocusableListItemElements();
|
|
566
|
+
if (elements.length < 1) return;
|
|
567
|
+
let stop = true;
|
|
568
|
+
const isSearchInput = target.matches(SEARCH_INPUT_SELECTOR);
|
|
569
|
+
if (code === HOME) {
|
|
570
|
+
if (isSearchInput) {
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
this.focusItem(0, elements);
|
|
574
|
+
} else if (code === END) {
|
|
575
|
+
if (isSearchInput) {
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
this.focusItem(elements.length - 1, elements);
|
|
579
|
+
} else if (code === ARROW_UP) {
|
|
580
|
+
if (isSearchInput) {
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
if (this.searchable && elements.indexOf(target) === 0) {
|
|
584
|
+
this.focusSearchInput();
|
|
585
|
+
} else {
|
|
586
|
+
this.focusNextItem(event, elements, -1);
|
|
587
|
+
}
|
|
588
|
+
} else if (code === ARROW_DOWN) {
|
|
589
|
+
if (isSearchInput) {
|
|
590
|
+
this.focusItem(0, elements);
|
|
591
|
+
} else {
|
|
592
|
+
this.focusNextItem(event, elements, 1);
|
|
593
|
+
}
|
|
594
|
+
} else {
|
|
595
|
+
stop = false;
|
|
596
|
+
}
|
|
597
|
+
if (stop) {
|
|
598
|
+
stopEvent(event);
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
getFocusableListItemElements() {
|
|
602
|
+
var _this$$refs$list;
|
|
603
|
+
const items = (_this$$refs$list = this.$refs.list) === null || _this$$refs$list === void 0 ? void 0 : _this$$refs$list.querySelectorAll(ITEM_SELECTOR);
|
|
604
|
+
return Array.from(items || []);
|
|
605
|
+
},
|
|
606
|
+
focusNextItem(event, elements, offset) {
|
|
607
|
+
const {
|
|
608
|
+
target
|
|
609
|
+
} = event;
|
|
610
|
+
const currentIndex = elements.indexOf(target);
|
|
611
|
+
const nextIndex = clamp(currentIndex + offset, 0, elements.length - 1);
|
|
612
|
+
this.focusItem(nextIndex, elements);
|
|
613
|
+
},
|
|
614
|
+
focusItem(index, elements) {
|
|
615
|
+
var _elements$index;
|
|
616
|
+
this.nextFocusedItemIndex = index;
|
|
617
|
+
(_elements$index = elements[index]) === null || _elements$index === void 0 ? void 0 : _elements$index.focus();
|
|
618
|
+
},
|
|
619
|
+
focusSearchInput() {
|
|
620
|
+
this.$refs.searchBox.focusInput();
|
|
621
|
+
},
|
|
622
|
+
onSelect(item, isSelected) {
|
|
623
|
+
if (this.multiple) {
|
|
624
|
+
this.onMultiSelect(item.value, isSelected);
|
|
625
|
+
} else {
|
|
626
|
+
this.onSingleSelect(item.value, isSelected);
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
isSelected(item) {
|
|
630
|
+
return this.selectedValues.some(value => value === item.value);
|
|
631
|
+
},
|
|
632
|
+
isFocused(item) {
|
|
633
|
+
return this.nextFocusedItemIndex === this.flattenedOptions.indexOf(item);
|
|
634
|
+
},
|
|
635
|
+
onSingleSelect(value, isSelected) {
|
|
636
|
+
if (isSelected) {
|
|
637
|
+
/**
|
|
638
|
+
* Emitted when selection is changed
|
|
639
|
+
*
|
|
640
|
+
* @event select
|
|
641
|
+
*/
|
|
642
|
+
this.$emit('select', value);
|
|
643
|
+
}
|
|
644
|
+
this.closeAndFocus();
|
|
645
|
+
},
|
|
646
|
+
onMultiSelect(value, isSelected) {
|
|
647
|
+
if (isSelected) {
|
|
648
|
+
this.$emit('select', [...this.selectedValues, value]);
|
|
649
|
+
} else {
|
|
650
|
+
this.$emit('select', this.selectedValues.filter(selectedValue => selectedValue !== value));
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
search(searchTerm) {
|
|
654
|
+
/**
|
|
655
|
+
* Emitted when the search query string is changed
|
|
656
|
+
*
|
|
657
|
+
* @event search
|
|
658
|
+
* @type {string}
|
|
659
|
+
*/
|
|
660
|
+
this.$emit('search', searchTerm);
|
|
661
|
+
},
|
|
662
|
+
onResetButtonClicked() {
|
|
663
|
+
/**
|
|
664
|
+
* Emitted when the reset button is clicked
|
|
665
|
+
*
|
|
666
|
+
* @event reset
|
|
667
|
+
*/
|
|
668
|
+
this.$emit('reset');
|
|
669
|
+
},
|
|
670
|
+
onSelectAllButtonClicked() {
|
|
671
|
+
/**
|
|
672
|
+
* Emitted when the select all button is clicked
|
|
673
|
+
*
|
|
674
|
+
* @event select-all
|
|
675
|
+
*/
|
|
676
|
+
this.$emit('select-all');
|
|
677
|
+
},
|
|
678
|
+
closeAndFocus() {
|
|
679
|
+
this.$refs.baseDropdown.closeAndFocus();
|
|
680
|
+
},
|
|
681
|
+
onIntersectionObserverAppear() {
|
|
682
|
+
/**
|
|
683
|
+
* Emitted when bottom of listbox has been scrolled to.
|
|
684
|
+
* Used for infinite scroll.
|
|
685
|
+
*
|
|
686
|
+
* @event bottom-reached
|
|
687
|
+
*/
|
|
688
|
+
this.$emit('bottom-reached');
|
|
689
|
+
},
|
|
690
|
+
listboxItemMoreItemsAriaAttributes(index) {
|
|
691
|
+
if (this.totalItems === null) {
|
|
692
|
+
return {};
|
|
693
|
+
}
|
|
694
|
+
return {
|
|
695
|
+
'aria-setsize': this.totalItems,
|
|
696
|
+
'aria-posinset': index + 1
|
|
697
|
+
};
|
|
698
|
+
},
|
|
699
|
+
observeScroll() {
|
|
700
|
+
var _this$scrollObserver2;
|
|
701
|
+
const root = this.$refs.list;
|
|
702
|
+
const options = {
|
|
703
|
+
rootMargin: '8px',
|
|
704
|
+
root,
|
|
705
|
+
threshold: 1.0
|
|
706
|
+
};
|
|
707
|
+
(_this$scrollObserver2 = this.scrollObserver) === null || _this$scrollObserver2 === void 0 ? void 0 : _this$scrollObserver2.disconnect();
|
|
708
|
+
const observer = new IntersectionObserver(entries => {
|
|
709
|
+
entries.forEach(entry => {
|
|
710
|
+
var _entry$target;
|
|
711
|
+
this[(_entry$target = entry.target) === null || _entry$target === void 0 ? void 0 : _entry$target.$__visibilityProp] = entry.isIntersecting;
|
|
712
|
+
});
|
|
713
|
+
}, options);
|
|
714
|
+
const topBoundary = this.$refs['top-boundary'];
|
|
715
|
+
const bottomBoundary = this.$refs['bottom-boundary'];
|
|
716
|
+
if (topBoundary) {
|
|
717
|
+
topBoundary.$__visibilityProp = 'topBoundaryVisible';
|
|
718
|
+
observer.observe(topBoundary);
|
|
719
|
+
}
|
|
720
|
+
if (bottomBoundary) {
|
|
721
|
+
bottomBoundary.$__visibilityProp = 'bottomBoundaryVisible';
|
|
722
|
+
observer.observe(bottomBoundary);
|
|
723
|
+
}
|
|
724
|
+
this.scrollObserver = observer;
|
|
725
|
+
},
|
|
726
|
+
isOption
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
/* script */
|
|
731
|
+
const __vue_script__ = script;
|
|
732
|
+
|
|
733
|
+
/* template */
|
|
734
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-base-dropdown',{ref:"baseDropdown",attrs:{"aria-haspopup":"listbox","aria-labelledby":_vm.toggleAriaLabelledBy,"block":_vm.block,"toggle-id":_vm.toggleId,"toggle-text":_vm.listboxToggleText,"toggle-class":_vm.toggleButtonClasses,"text-sr-only":_vm.textSrOnly,"category":_vm.category,"variant":_vm.variant,"size":_vm.size,"icon":_vm.icon,"disabled":_vm.disabled,"loading":_vm.loading,"no-caret":_vm.noCaret,"placement":_vm.placement,"offset":_vm.dropdownOffset,"fluid-width":_vm.fluidWidth,"positioning-strategy":_vm.positioningStrategy},on:_vm._d({},[_vm.$options.events.GL_DROPDOWN_SHOWN,_vm.onShow,_vm.$options.events.GL_DROPDOWN_HIDDEN,_vm.onHide]),scopedSlots:_vm._u([(_vm.hasCustomToggle)?{key:"toggle",fn:function(){return [_vm._t("toggle")]},proxy:true}:null],null,true)},[_vm._v(" "),(_vm.headerText)?_c('div',{staticClass:"gl-display-flex gl-align-items-center gl-p-4! gl-min-h-8",class:_vm.$options.HEADER_ITEMS_BORDER_CLASSES},[_c('div',{staticClass:"gl-flex-grow-1 gl-font-weight-bold gl-font-sm gl-pr-2",attrs:{"id":_vm.headerId,"data-testid":"listbox-header-text"}},[_vm._v("\n "+_vm._s(_vm.headerText)+"\n ")]),_vm._v(" "),(_vm.showResetButton)?_c('gl-button',{staticClass:"gl-focus-inset-border-2-blue-400! gl-flex-shrink-0 gl-font-sm! gl-px-2! gl-py-2! gl-w-auto! gl-m-0! gl-max-w-50p gl-text-overflow-ellipsis",attrs:{"category":"tertiary","data-testid":"listbox-reset-button"},on:{"click":_vm.onResetButtonClicked}},[_vm._v("\n "+_vm._s(_vm.resetButtonLabel)+"\n ")]):_vm._e(),_vm._v(" "),(_vm.showSelectAllButton)?_c('gl-button',{staticClass:"gl-focus-inset-border-2-blue-400! gl-flex-shrink-0 gl-font-sm! gl-px-2! gl-py-2! gl-w-auto! gl-m-0! gl-max-w-50p gl-text-overflow-ellipsis",attrs:{"category":"tertiary","data-testid":"listbox-select-all-button"},on:{"click":_vm.onSelectAllButtonClicked}},[_vm._v("\n "+_vm._s(_vm.showSelectAllButtonLabel)+"\n ")]):_vm._e()],1):_vm._e(),_vm._v(" "),(_vm.searchable)?_c('div',{class:_vm.$options.HEADER_ITEMS_BORDER_CLASSES},[_c('gl-listbox-search-input',{ref:"searchBox",class:{ 'gl-listbox-topmost': !_vm.headerText },attrs:{"aria-owns":_vm.listboxId,"data-testid":"listbox-search-input","placeholder":_vm.searchPlaceholder},on:{"input":_vm.search,"keydown":[function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }$event.preventDefault();},_vm.onKeydown]},model:{value:(_vm.searchStr),callback:function ($$v) {_vm.searchStr=$$v;},expression:"searchStr"}}),_vm._v(" "),(_vm.searching)?_c('gl-loading-icon',{staticClass:"gl-my-3",attrs:{"data-testid":"listbox-search-loader","size":"md"}}):_vm._e()],1):_vm._e(),_vm._v(" "),(_vm.showList)?_c(_vm.listboxTag,{ref:"list",tag:"component",staticClass:"gl-new-dropdown-contents gl-new-dropdown-contents-with-scrim-overlay",class:_vm.listboxClasses,attrs:{"id":_vm.listboxId,"aria-labelledby":_vm.listAriaLabelledBy || _vm.headerId || _vm.toggleId,"role":"listbox","tabindex":"0"},on:{"keydown":_vm.onKeydown}},[_c(_vm.itemTag,{tag:"component",staticClass:"top-scrim-wrapper",attrs:{"aria-hidden":"true","data-testid":"top-scrim"}},[_c('div',{staticClass:"top-scrim",class:{ 'top-scrim-light': !_vm.hasHeader, 'top-scrim-dark': _vm.hasHeader }})]),_vm._v(" "),_c(_vm.itemTag,{ref:"top-boundary",tag:"component",attrs:{"aria-hidden":"true"}}),_vm._v(" "),_vm._l((_vm.items),function(item,index){return [(_vm.isOption(item))?[_c('gl-listbox-item',_vm._b({key:item.value,attrs:{"data-testid":("listbox-item-" + (item.value)),"is-selected":_vm.isSelected(item),"is-focused":_vm.isFocused(item),"is-check-centered":_vm.isCheckCentered},on:{"select":function($event){return _vm.onSelect(item, $event)}}},'gl-listbox-item',_vm.listboxItemMoreItemsAriaAttributes(index),false),[_vm._t("list-item",function(){return [_vm._v("\n "+_vm._s(item.text)+"\n ")]},{"item":item})],2)]:[_c('gl-listbox-group',{key:item.text,class:_vm.groupClasses(index),attrs:{"name":item.text,"text-sr-only":item.textSrOnly},scopedSlots:_vm._u([(_vm.$scopedSlots['group-label'])?{key:"group-label",fn:function(){return [_vm._t("group-label",null,{"group":item})]},proxy:true}:null],null,true)},[_vm._v(" "),_vm._l((item.options),function(option){return _c('gl-listbox-item',{key:option.value,attrs:{"data-testid":("listbox-item-" + (option.value)),"is-selected":_vm.isSelected(option),"is-focused":_vm.isFocused(option),"is-check-centered":_vm.isCheckCentered},on:{"select":function($event){return _vm.onSelect(option, $event)}}},[_vm._t("list-item",function(){return [_vm._v("\n "+_vm._s(option.text)+"\n ")]},{"item":option})],2)})],2)]]}),_vm._v(" "),(_vm.infiniteScrollLoading)?_c(_vm.itemTag,{tag:"component"},[_c('gl-loading-icon',{staticClass:"gl-my-3",attrs:{"data-testid":"listbox-infinite-scroll-loader","size":"md"}})],1):_vm._e(),_vm._v(" "),(_vm.showIntersectionObserver)?_c('gl-intersection-observer',{on:{"appear":_vm.onIntersectionObserverAppear}}):_vm._e(),_vm._v(" "),_c(_vm.itemTag,{ref:"bottom-boundary",tag:"component",attrs:{"aria-hidden":"true"}}),_vm._v(" "),_c(_vm.itemTag,{tag:"component",staticClass:"bottom-scrim-wrapper",attrs:{"aria-hidden":"true","data-testid":"bottom-scrim"}},[_c('div',{staticClass:"bottom-scrim",class:{ 'gl-rounded-0!': _vm.hasFooter }})])],2):_vm._e(),_vm._v(" "),(_vm.announceSRSearchResults)?_c('span',{staticClass:"gl-sr-only",attrs:{"data-testid":"listbox-number-of-results","aria-live":"assertive"}},[_vm._t("search-summary-sr-only",function(){return [_vm._v("\n "+_vm._s(_vm.srOnlyResultsLabel(_vm.flattenedOptions.length))+"\n ")]})],2):(_vm.showNoResultsText)?_c('div',{staticClass:"gl-pl-7 gl-pr-5 gl-py-3 gl-font-base gl-text-gray-600",attrs:{"aria-live":"assertive","data-testid":"listbox-no-results-text"}},[_vm._v("\n "+_vm._s(_vm.noResultsText)+"\n ")]):_vm._e(),_vm._v(" "),_vm._t("footer")],2)};
|
|
735
|
+
var __vue_staticRenderFns__ = [];
|
|
736
|
+
|
|
737
|
+
/* style */
|
|
738
|
+
const __vue_inject_styles__ = undefined;
|
|
739
|
+
/* scoped */
|
|
740
|
+
const __vue_scope_id__ = undefined;
|
|
741
|
+
/* module identifier */
|
|
742
|
+
const __vue_module_identifier__ = undefined;
|
|
743
|
+
/* functional template */
|
|
744
|
+
const __vue_is_functional_template__ = false;
|
|
745
|
+
/* style inject */
|
|
746
|
+
|
|
747
|
+
/* style inject SSR */
|
|
748
|
+
|
|
749
|
+
/* style inject shadow dom */
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
const __vue_component__ = __vue_normalize__(
|
|
754
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
755
|
+
__vue_inject_styles__,
|
|
756
|
+
__vue_script__,
|
|
757
|
+
__vue_scope_id__,
|
|
758
|
+
__vue_is_functional_template__,
|
|
759
|
+
__vue_module_identifier__,
|
|
760
|
+
false,
|
|
761
|
+
undefined,
|
|
762
|
+
undefined,
|
|
763
|
+
undefined
|
|
764
|
+
);
|
|
765
|
+
|
|
766
|
+
export default __vue_component__;
|
|
767
|
+
export { ITEM_SELECTOR, SEARCH_INPUT_SELECTOR };
|