@gitlab/ui 72.11.0 → 72.12.0
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/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/package.json +1 -1
- package/src/directives/safe_html/safe_html.js +5 -0
- package/src/directives/safe_html/safe_html.spec.js +17 -0
- package/src/internal/color_contrast/color_contrast.md +8 -0
- package/src/internal/color_contrast/color_contrast.spec.js +34 -0
- package/src/internal/color_contrast/color_contrast.stories.js +41 -0
- package/src/internal/color_contrast/color_contrast.vue +52 -0
- package/src/tokens/color.dark.tokens.stories.js +36 -22
- package/src/tokens/color.data_viz.dark.tokens.stories.js +13 -30
- package/src/tokens/color.data_viz.tokens.stories.js +13 -30
- package/src/tokens/color.theme.dark.tokens.stories.js +15 -30
- package/src/tokens/color.theme.tokens.stories.js +15 -30
- package/src/tokens/color.tokens.stories.js +36 -22
- package/src/tokens/color.transparency.tokens.stories.js +9 -12
- package/src/tokens/common_story_options.js +22 -80
- package/src/utils/constants.js +25 -0
- package/src/utils/utils.js +21 -1
- package/dist/charts.js +0 -14
- package/dist/components/base/accordion/accordion.js +0 -73
- package/dist/components/base/accordion/accordion_item.js +0 -133
- package/dist/components/base/alert/alert.js +0 -222
- package/dist/components/base/avatar/avatar.js +0 -160
- package/dist/components/base/avatar_labeled/avatar_labeled.js +0 -107
- package/dist/components/base/avatar_link/avatar_link.js +0 -47
- package/dist/components/base/avatars_inline/avatars_inline.js +0 -119
- package/dist/components/base/badge/badge.js +0 -105
- package/dist/components/base/banner/banner.js +0 -139
- package/dist/components/base/breadcrumb/breadcrumb.js +0 -122
- package/dist/components/base/breadcrumb/breadcrumb_item.js +0 -73
- package/dist/components/base/broadcast_message/broadcast_message.js +0 -112
- package/dist/components/base/broadcast_message/constants.js +0 -5
- package/dist/components/base/button/button.js +0 -151
- package/dist/components/base/button_group/button_group.js +0 -47
- package/dist/components/base/card/card.js +0 -71
- package/dist/components/base/carousel/carousel.js +0 -48
- package/dist/components/base/carousel/carousel_slide.js +0 -47
- package/dist/components/base/collapse/collapse.js +0 -59
- package/dist/components/base/datepicker/datepicker.js +0 -386
- package/dist/components/base/daterange_picker/daterange_picker.js +0 -288
- package/dist/components/base/drawer/drawer.js +0 -127
- package/dist/components/base/dropdown/dropdown.js +0 -261
- package/dist/components/base/dropdown/dropdown_divider.js +0 -48
- package/dist/components/base/dropdown/dropdown_form.js +0 -48
- package/dist/components/base/dropdown/dropdown_item.js +0 -131
- package/dist/components/base/dropdown/dropdown_section_header.js +0 -48
- package/dist/components/base/dropdown/dropdown_text.js +0 -48
- package/dist/components/base/filtered_search/common_story_options.js +0 -14
- package/dist/components/base/filtered_search/filtered_search.js +0 -388
- package/dist/components/base/filtered_search/filtered_search_suggestion.js +0 -89
- package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +0 -138
- package/dist/components/base/filtered_search/filtered_search_term.js +0 -203
- package/dist/components/base/filtered_search/filtered_search_token.js +0 -384
- package/dist/components/base/filtered_search/filtered_search_token_segment.js +0 -420
- package/dist/components/base/filtered_search/filtered_search_utils.js +0 -242
- package/dist/components/base/form/form.js +0 -49
- package/dist/components/base/form/form_checkbox/form_checkbox.js +0 -78
- package/dist/components/base/form/form_checkbox/form_checkbox_group.js +0 -60
- package/dist/components/base/form/form_checkbox_tree/checkbox_tree_node.js +0 -79
- package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.js +0 -138
- package/dist/components/base/form/form_checkbox_tree/models/constants.js +0 -12
- package/dist/components/base/form/form_checkbox_tree/models/node.js +0 -51
- package/dist/components/base/form/form_checkbox_tree/models/tree.js +0 -199
- package/dist/components/base/form/form_combobox/constants.js +0 -55
- package/dist/components/base/form/form_combobox/form_combobox.js +0 -230
- package/dist/components/base/form/form_date/form_date.js +0 -143
- package/dist/components/base/form/form_fields/form_field_validator.js +0 -93
- package/dist/components/base/form/form_fields/form_fields.js +0 -214
- package/dist/components/base/form/form_fields/mappers.js +0 -13
- package/dist/components/base/form/form_fields/validators.js +0 -48
- package/dist/components/base/form/form_group/form_group.js +0 -97
- package/dist/components/base/form/form_input/form_input.js +0 -121
- package/dist/components/base/form/form_input_group/form_input_group.js +0 -108
- package/dist/components/base/form/form_input_group/form_input_group_mixin.js +0 -41
- package/dist/components/base/form/form_radio/form_radio.js +0 -65
- package/dist/components/base/form/form_radio_group/form_radio_group.js +0 -78
- package/dist/components/base/form/form_select/constants.js +0 -12
- package/dist/components/base/form/form_select/form_select.js +0 -82
- package/dist/components/base/form/form_text/form_text.js +0 -38
- package/dist/components/base/form/form_textarea/form_textarea.js +0 -112
- package/dist/components/base/form/input_group_text/input_group_text.js +0 -48
- package/dist/components/base/icon/icon.js +0 -111
- package/dist/components/base/infinite_scroll/infinite_scroll.js +0 -197
- package/dist/components/base/keyset_pagination/keyset_pagination.js +0 -151
- package/dist/components/base/label/label.js +0 -163
- package/dist/components/base/link/link.js +0 -50
- package/dist/components/base/loading_icon/loading_icon.js +0 -111
- package/dist/components/base/markdown/markdown.js +0 -52
- package/dist/components/base/modal/modal.js +0 -204
- package/dist/components/base/nav/nav.js +0 -48
- package/dist/components/base/nav/nav_item.js +0 -48
- package/dist/components/base/nav/nav_item_dropdown.js +0 -62
- package/dist/components/base/navbar/navbar.js +0 -48
- package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +0 -453
- package/dist/components/base/new_dropdowns/base_dropdown/constants.js +0 -4
- package/dist/components/base/new_dropdowns/constants.js +0 -21
- package/dist/components/base/new_dropdowns/disclosure/constants.js +0 -8
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown.js +0 -370
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_group.js +0 -110
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_item.js +0 -143
- package/dist/components/base/new_dropdowns/disclosure/mock_data.js +0 -147
- package/dist/components/base/new_dropdowns/disclosure/utils.js +0 -39
- package/dist/components/base/new_dropdowns/listbox/listbox.js +0 -767
- package/dist/components/base/new_dropdowns/listbox/listbox_group.js +0 -58
- package/dist/components/base/new_dropdowns/listbox/listbox_item.js +0 -91
- package/dist/components/base/new_dropdowns/listbox/listbox_search_input.js +0 -93
- package/dist/components/base/new_dropdowns/listbox/mock_data.js +0 -118
- package/dist/components/base/new_dropdowns/listbox/utils.js +0 -34
- package/dist/components/base/paginated_list/paginated_list.js +0 -180
- package/dist/components/base/pagination/pagination.js +0 -399
- package/dist/components/base/path/data.js +0 -34
- package/dist/components/base/path/path.js +0 -189
- package/dist/components/base/popover/popover.js +0 -110
- package/dist/components/base/progress_bar/progress_bar.js +0 -48
- package/dist/components/base/search_box_by_click/search_box_by_click.js +0 -235
- package/dist/components/base/search_box_by_type/search_box_by_type.js +0 -167
- package/dist/components/base/segmented_control/segmented_control.js +0 -109
- package/dist/components/base/skeleton_loader/skeleton_loader.js +0 -224
- package/dist/components/base/sorting/sorting.js +0 -171
- package/dist/components/base/sorting/sorting_item.js +0 -109
- package/dist/components/base/table/constants.js +0 -5
- package/dist/components/base/table/table.js +0 -89
- package/dist/components/base/table_lite/table_lite.js +0 -72
- package/dist/components/base/tabs/constants.js +0 -3
- package/dist/components/base/tabs/tab/tab.js +0 -83
- package/dist/components/base/tabs/tabs/scrollable_tabs.js +0 -143
- package/dist/components/base/tabs/tabs/tabs.js +0 -224
- package/dist/components/base/toast/toast.js +0 -82
- package/dist/components/base/toggle/toggle.js +0 -180
- package/dist/components/base/token/token.js +0 -85
- package/dist/components/base/token_selector/helpers.js +0 -5
- package/dist/components/base/token_selector/token_container.js +0 -165
- package/dist/components/base/token_selector/token_selector.js +0 -403
- package/dist/components/base/token_selector/token_selector_dropdown.js +0 -199
- package/dist/components/base/tooltip/tooltip.js +0 -55
- package/dist/components/charts/area/area.js +0 -311
- package/dist/components/charts/bar/bar.js +0 -253
- package/dist/components/charts/chart/chart.js +0 -215
- package/dist/components/charts/column/column.js +0 -226
- package/dist/components/charts/discrete_scatter/discrete_scatter.js +0 -203
- package/dist/components/charts/gauge/gauge.js +0 -208
- package/dist/components/charts/heatmap/heatmap.js +0 -295
- package/dist/components/charts/heatmap/index.js +0 -2
- package/dist/components/charts/legend/legend.js +0 -228
- package/dist/components/charts/line/line.js +0 -308
- package/dist/components/charts/series_label/series_label.js +0 -100
- package/dist/components/charts/single_stat/single_stat.js +0 -152
- package/dist/components/charts/sparkline/sparkline.js +0 -261
- package/dist/components/charts/stacked_column/stacked_column.js +0 -335
- package/dist/components/charts/tooltip/tooltip.js +0 -251
- package/dist/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.js +0 -83
- package/dist/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.js +0 -100
- package/dist/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.js +0 -35
- package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +0 -115
- package/dist/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.js +0 -104
- package/dist/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.js +0 -64
- package/dist/components/experimental/duo/chat/constants.js +0 -23
- package/dist/components/experimental/duo/chat/duo_chat.js +0 -359
- package/dist/components/experimental/duo/chat/mock_data.js +0 -83
- package/dist/components/experimental/duo/user_feedback/user_feedback.js +0 -94
- package/dist/components/experimental/duo/user_feedback/user_feedback_modal.js +0 -124
- package/dist/components/experimental/experiment_badge/constants.js +0 -4
- package/dist/components/experimental/experiment_badge/experiment_badge.js +0 -107
- package/dist/components/mixins/button_mixin.js +0 -11
- package/dist/components/mixins/safe_link_mixin.js +0 -30
- package/dist/components/mixins/tooltip_mixin.js +0 -21
- package/dist/components/regions/dashboard_skeleton/dashboard_skeleton.js +0 -53
- package/dist/components/regions/empty_state/empty_state.js +0 -154
- package/dist/components/shared_components/charts/tooltip_default_format.js +0 -53
- package/dist/components/shared_components/clear_icon_button/clear_icon_button.js +0 -64
- package/dist/components/shared_components/close_button/close_button.js +0 -54
- package/dist/components/utilities/animated_number/animated_number.js +0 -131
- package/dist/components/utilities/friendly_wrap/friendly_wrap.js +0 -75
- package/dist/components/utilities/intersection_observer/intersection_observer.js +0 -88
- package/dist/components/utilities/intersperse/intersperse.js +0 -86
- package/dist/components/utilities/sprintf/sprintf.js +0 -172
- package/dist/components/utilities/truncate/constants.js +0 -7
- package/dist/components/utilities/truncate/truncate.js +0 -111
- package/dist/components/utilities/truncate_text/constants.js +0 -7
- package/dist/components/utilities/truncate_text/truncate_text.js +0 -146
- package/dist/config.js +0 -86
- package/dist/directives/collapse_toggle.js +0 -1
- package/dist/directives/hover_load/hover_load.js +0 -45
- package/dist/directives/modal.js +0 -1
- package/dist/directives/outside/get_event_like_time_stamp.js +0 -33
- package/dist/directives/outside/outside.js +0 -106
- package/dist/directives/resize_observer/resize_observer.js +0 -51
- package/dist/directives/safe_html/constants.js +0 -6
- package/dist/directives/safe_html/safe_html.js +0 -35
- package/dist/directives/safe_link/mock_data.js +0 -10
- package/dist/directives/safe_link/safe_link.js +0 -65
- package/dist/directives/tooltip.js +0 -1
- package/dist/index.css +0 -7
- package/dist/index.css.map +0 -1
- package/dist/index.js +0 -105
- package/dist/tokens/common_story_options.js +0 -109
- package/dist/utils/breakpoints.js +0 -20
- package/dist/utils/charts/config.js +0 -556
- package/dist/utils/charts/constants.js +0 -63
- package/dist/utils/charts/mock_data.js +0 -211
- package/dist/utils/charts/story_config.js +0 -42
- package/dist/utils/charts/theme.js +0 -192
- package/dist/utils/charts/utils.js +0 -54
- package/dist/utils/constants.js +0 -270
- package/dist/utils/data_utils.js +0 -21
- package/dist/utils/datetime_utility.js +0 -61
- package/dist/utils/i18n.js +0 -15
- package/dist/utils/is_slot_empty.js +0 -38
- package/dist/utils/number_utils.js +0 -124
- package/dist/utils/stories_constants.js +0 -29
- package/dist/utils/stories_utils.js +0 -13
- package/dist/utils/story_decorators/container.js +0 -16
- package/dist/utils/string_utils.js +0 -69
- package/dist/utils/svgs/svg_paths.js +0 -7
- package/dist/utils/test_utils.js +0 -33
- package/dist/utils/use_fake_date.js +0 -29
- package/dist/utils/use_mock_intersection_observer.js +0 -108
- package/dist/utils/utils.js +0 -177
- package/dist/utils.js +0 -5
|
@@ -1,453 +0,0 @@
|
|
|
1
|
-
import uniqueId from 'lodash/uniqueId';
|
|
2
|
-
import { offset, autoPlacement, size, autoUpdate, computePosition } from '@floating-ui/dom';
|
|
3
|
-
import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions, dropdownPlacements, dropdownAllowedAutoPlacements } from '../../../../utils/constants';
|
|
4
|
-
import { POSITION_ABSOLUTE, POSITION_FIXED, GL_DROPDOWN_CONTENTS_CLASS, GL_DROPDOWN_BEFORE_CLOSE, GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, ENTER, SPACE, ARROW_DOWN, GL_DROPDOWN_FOCUS_CONTENT } from '../constants';
|
|
5
|
-
import { isElementFocusable, isElementTabbable, logWarning } from '../../../../utils/utils';
|
|
6
|
-
import GlButton from '../../button/button';
|
|
7
|
-
import GlIcon from '../../icon/icon';
|
|
8
|
-
import { OutsideDirective } from '../../../../directives/outside/outside';
|
|
9
|
-
import { DEFAULT_OFFSET, FIXED_WIDTH_CLASS } from './constants';
|
|
10
|
-
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
11
|
-
|
|
12
|
-
const BASE_DROPDOWN_CLASS = 'gl-new-dropdown';
|
|
13
|
-
var script = {
|
|
14
|
-
name: 'BaseDropdown',
|
|
15
|
-
BASE_DROPDOWN_CLASS,
|
|
16
|
-
components: {
|
|
17
|
-
GlButton,
|
|
18
|
-
GlIcon
|
|
19
|
-
},
|
|
20
|
-
directives: {
|
|
21
|
-
Outside: OutsideDirective
|
|
22
|
-
},
|
|
23
|
-
props: {
|
|
24
|
-
toggleText: {
|
|
25
|
-
type: String,
|
|
26
|
-
required: false,
|
|
27
|
-
default: ''
|
|
28
|
-
},
|
|
29
|
-
textSrOnly: {
|
|
30
|
-
type: Boolean,
|
|
31
|
-
required: false,
|
|
32
|
-
default: false
|
|
33
|
-
},
|
|
34
|
-
block: {
|
|
35
|
-
type: Boolean,
|
|
36
|
-
required: false,
|
|
37
|
-
default: false
|
|
38
|
-
},
|
|
39
|
-
category: {
|
|
40
|
-
type: String,
|
|
41
|
-
required: false,
|
|
42
|
-
default: buttonCategoryOptions.primary,
|
|
43
|
-
validator: value => Object.keys(buttonCategoryOptions).includes(value)
|
|
44
|
-
},
|
|
45
|
-
variant: {
|
|
46
|
-
type: String,
|
|
47
|
-
required: false,
|
|
48
|
-
default: dropdownVariantOptions.default,
|
|
49
|
-
validator: value => Object.keys(dropdownVariantOptions).includes(value)
|
|
50
|
-
},
|
|
51
|
-
size: {
|
|
52
|
-
type: String,
|
|
53
|
-
required: false,
|
|
54
|
-
default: 'medium',
|
|
55
|
-
validator: value => Object.keys(buttonSizeOptions).includes(value)
|
|
56
|
-
},
|
|
57
|
-
icon: {
|
|
58
|
-
type: String,
|
|
59
|
-
required: false,
|
|
60
|
-
default: ''
|
|
61
|
-
},
|
|
62
|
-
disabled: {
|
|
63
|
-
type: Boolean,
|
|
64
|
-
required: false,
|
|
65
|
-
default: false
|
|
66
|
-
},
|
|
67
|
-
loading: {
|
|
68
|
-
type: Boolean,
|
|
69
|
-
required: false,
|
|
70
|
-
default: false
|
|
71
|
-
},
|
|
72
|
-
toggleClass: {
|
|
73
|
-
type: [String, Array, Object],
|
|
74
|
-
required: false,
|
|
75
|
-
default: null
|
|
76
|
-
},
|
|
77
|
-
noCaret: {
|
|
78
|
-
type: Boolean,
|
|
79
|
-
required: false,
|
|
80
|
-
default: false
|
|
81
|
-
},
|
|
82
|
-
placement: {
|
|
83
|
-
type: String,
|
|
84
|
-
required: false,
|
|
85
|
-
default: 'left',
|
|
86
|
-
validator: value => Object.keys(dropdownPlacements).includes(value)
|
|
87
|
-
},
|
|
88
|
-
// ARIA props
|
|
89
|
-
ariaHaspopup: {
|
|
90
|
-
type: [String, Boolean],
|
|
91
|
-
required: false,
|
|
92
|
-
default: false,
|
|
93
|
-
validator: value => {
|
|
94
|
-
return ['menu', 'listbox', 'tree', 'grid', 'dialog', true, false].includes(value);
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
/**
|
|
98
|
-
* Id that will be referenced by `aria-labelledby` attribute of the dropdown content`
|
|
99
|
-
*/
|
|
100
|
-
toggleId: {
|
|
101
|
-
type: String,
|
|
102
|
-
required: true
|
|
103
|
-
},
|
|
104
|
-
/**
|
|
105
|
-
* The `aria-labelledby` attribute value for the toggle `button`
|
|
106
|
-
*/
|
|
107
|
-
ariaLabelledby: {
|
|
108
|
-
type: String,
|
|
109
|
-
required: false,
|
|
110
|
-
default: null
|
|
111
|
-
},
|
|
112
|
-
/**
|
|
113
|
-
* Custom value to be passed to the offset middleware.
|
|
114
|
-
* https://floating-ui.com/docs/offset
|
|
115
|
-
*/
|
|
116
|
-
offset: {
|
|
117
|
-
type: [Number, Object],
|
|
118
|
-
required: false,
|
|
119
|
-
default: () => ({
|
|
120
|
-
mainAxis: DEFAULT_OFFSET
|
|
121
|
-
})
|
|
122
|
-
},
|
|
123
|
-
fluidWidth: {
|
|
124
|
-
type: Boolean,
|
|
125
|
-
required: false,
|
|
126
|
-
default: false
|
|
127
|
-
},
|
|
128
|
-
/**
|
|
129
|
-
* Strategy to be applied by computePosition. If this is set to fixed, the dropdown's position
|
|
130
|
-
* needs to be set to fixed in CSS as well.
|
|
131
|
-
* https://floating-ui.com/docs/computePosition#strategy
|
|
132
|
-
*/
|
|
133
|
-
positioningStrategy: {
|
|
134
|
-
type: String,
|
|
135
|
-
required: false,
|
|
136
|
-
default: POSITION_ABSOLUTE,
|
|
137
|
-
validator: strategy => [POSITION_ABSOLUTE, POSITION_FIXED].includes(strategy)
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
data() {
|
|
141
|
-
return {
|
|
142
|
-
openedYet: false,
|
|
143
|
-
visible: false,
|
|
144
|
-
baseDropdownId: uniqueId('base-dropdown-')
|
|
145
|
-
};
|
|
146
|
-
},
|
|
147
|
-
computed: {
|
|
148
|
-
isIconOnly() {
|
|
149
|
-
var _this$toggleText;
|
|
150
|
-
return Boolean(this.icon && (!((_this$toggleText = this.toggleText) !== null && _this$toggleText !== void 0 && _this$toggleText.length) || this.textSrOnly));
|
|
151
|
-
},
|
|
152
|
-
ariaAttributes() {
|
|
153
|
-
return {
|
|
154
|
-
'aria-haspopup': this.ariaHaspopup,
|
|
155
|
-
'aria-expanded': this.visible,
|
|
156
|
-
'aria-controls': this.baseDropdownId,
|
|
157
|
-
'aria-labelledby': this.toggleLabelledBy
|
|
158
|
-
};
|
|
159
|
-
},
|
|
160
|
-
toggleButtonClasses() {
|
|
161
|
-
return [this.toggleClass, {
|
|
162
|
-
'gl-new-dropdown-toggle': true,
|
|
163
|
-
'gl-new-dropdown-icon-only btn-icon': this.isIconOnly,
|
|
164
|
-
'gl-new-dropdown-toggle-no-caret': this.noCaret
|
|
165
|
-
}];
|
|
166
|
-
},
|
|
167
|
-
toggleButtonTextClasses() {
|
|
168
|
-
return this.block ? 'gl-w-full' : '';
|
|
169
|
-
},
|
|
170
|
-
toggleLabelledBy() {
|
|
171
|
-
return this.ariaLabelledby ? `${this.ariaLabelledby} ${this.toggleId}` : this.toggleId;
|
|
172
|
-
},
|
|
173
|
-
isDefaultToggle() {
|
|
174
|
-
return !this.$scopedSlots.toggle;
|
|
175
|
-
},
|
|
176
|
-
toggleOptions() {
|
|
177
|
-
if (this.isDefaultToggle) {
|
|
178
|
-
return {
|
|
179
|
-
is: GlButton,
|
|
180
|
-
icon: this.icon,
|
|
181
|
-
block: this.block,
|
|
182
|
-
buttonTextClasses: this.toggleButtonTextClasses,
|
|
183
|
-
category: this.category,
|
|
184
|
-
variant: this.variant,
|
|
185
|
-
size: this.size,
|
|
186
|
-
disabled: this.disabled,
|
|
187
|
-
loading: this.loading,
|
|
188
|
-
class: this.toggleButtonClasses,
|
|
189
|
-
...this.ariaAttributes,
|
|
190
|
-
listeners: {
|
|
191
|
-
keydown: event => this.onKeydown(event),
|
|
192
|
-
click: event => this.toggle(event)
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
return {
|
|
197
|
-
is: 'div',
|
|
198
|
-
class: 'gl-new-dropdown-custom-toggle',
|
|
199
|
-
listeners: {
|
|
200
|
-
keydown: event => this.onKeydown(event),
|
|
201
|
-
click: event => this.toggle(event)
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
},
|
|
205
|
-
toggleListeners() {
|
|
206
|
-
return this.toggleOptions.listeners;
|
|
207
|
-
},
|
|
208
|
-
toggleAttributes() {
|
|
209
|
-
const {
|
|
210
|
-
listeners,
|
|
211
|
-
is,
|
|
212
|
-
...attributes
|
|
213
|
-
} = this.toggleOptions;
|
|
214
|
-
return attributes;
|
|
215
|
-
},
|
|
216
|
-
toggleComponent() {
|
|
217
|
-
return this.toggleOptions.is;
|
|
218
|
-
},
|
|
219
|
-
toggleElement() {
|
|
220
|
-
var _this$$refs$toggle;
|
|
221
|
-
return this.$refs.toggle.$el || ((_this$$refs$toggle = this.$refs.toggle) === null || _this$$refs$toggle === void 0 ? void 0 : _this$$refs$toggle.firstElementChild);
|
|
222
|
-
},
|
|
223
|
-
panelClasses() {
|
|
224
|
-
return {
|
|
225
|
-
'gl-display-block!': this.visible,
|
|
226
|
-
[FIXED_WIDTH_CLASS]: !this.fluidWidth,
|
|
227
|
-
'gl-fixed': this.openedYet && this.isFixed,
|
|
228
|
-
'gl-absolute': this.openedYet && !this.isFixed
|
|
229
|
-
};
|
|
230
|
-
},
|
|
231
|
-
isFixed() {
|
|
232
|
-
return this.positioningStrategy === POSITION_FIXED;
|
|
233
|
-
},
|
|
234
|
-
floatingUIConfig() {
|
|
235
|
-
const placement = dropdownPlacements[this.placement];
|
|
236
|
-
const [, alignment] = placement.split('-');
|
|
237
|
-
return {
|
|
238
|
-
placement,
|
|
239
|
-
strategy: this.positioningStrategy,
|
|
240
|
-
middleware: [offset(this.offset), autoPlacement({
|
|
241
|
-
alignment,
|
|
242
|
-
allowedPlacements: dropdownAllowedAutoPlacements[this.placement]
|
|
243
|
-
}), size({
|
|
244
|
-
apply: _ref => {
|
|
245
|
-
var _this$nonScrollableCo;
|
|
246
|
-
let {
|
|
247
|
-
availableHeight,
|
|
248
|
-
elements
|
|
249
|
-
} = _ref;
|
|
250
|
-
const contentsEl = elements.floating.querySelector(`.${GL_DROPDOWN_CONTENTS_CLASS}`);
|
|
251
|
-
if (!contentsEl) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
const contentsAvailableHeight = availableHeight - ((_this$nonScrollableCo = this.nonScrollableContentHeight) !== null && _this$nonScrollableCo !== void 0 ? _this$nonScrollableCo : 0) - DEFAULT_OFFSET;
|
|
255
|
-
Object.assign(contentsEl.style, {
|
|
256
|
-
maxHeight: `${Math.max(contentsAvailableHeight, 0)}px`
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
})]
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
},
|
|
263
|
-
watch: {
|
|
264
|
-
ariaAttributes: {
|
|
265
|
-
deep: true,
|
|
266
|
-
handler(ariaAttributes) {
|
|
267
|
-
if (this.$scopedSlots.toggle) {
|
|
268
|
-
Object.keys(ariaAttributes).forEach(key => {
|
|
269
|
-
this.toggleElement.setAttribute(key, ariaAttributes[key]);
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
},
|
|
275
|
-
mounted() {
|
|
276
|
-
this.checkToggleFocusable();
|
|
277
|
-
},
|
|
278
|
-
beforeDestroy() {
|
|
279
|
-
this.stopFloating();
|
|
280
|
-
},
|
|
281
|
-
methods: {
|
|
282
|
-
checkToggleFocusable() {
|
|
283
|
-
if (!isElementFocusable(this.toggleElement) && !isElementTabbable(this.toggleElement)) {
|
|
284
|
-
logWarning(`GlDisclosureDropdown/GlCollapsibleListbox: Toggle is missing a 'tabindex' and cannot be focused.
|
|
285
|
-
Use 'a' or 'button' element instead or make sure to add 'role="button"' along with 'tabindex' otherwise.`, this.$el);
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
async startFloating() {
|
|
289
|
-
this.calculateNonScrollableAreaHeight();
|
|
290
|
-
this.observer = new MutationObserver(this.calculateNonScrollableAreaHeight);
|
|
291
|
-
this.observer.observe(this.$refs.content, {
|
|
292
|
-
attributes: false,
|
|
293
|
-
childList: true,
|
|
294
|
-
subtree: true
|
|
295
|
-
});
|
|
296
|
-
this.stopAutoUpdate = autoUpdate(this.toggleElement, this.$refs.content, async () => {
|
|
297
|
-
const {
|
|
298
|
-
x,
|
|
299
|
-
y
|
|
300
|
-
} = await computePosition(this.toggleElement, this.$refs.content, this.floatingUIConfig);
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Due to the asynchronous nature of computePosition, it's technically possible for the
|
|
304
|
-
* component to have been destroyed by the time the promise resolves. In such case, we exit
|
|
305
|
-
* early to prevent a TypeError.
|
|
306
|
-
*/
|
|
307
|
-
if (!this.$refs.content) return;
|
|
308
|
-
Object.assign(this.$refs.content.style, {
|
|
309
|
-
left: `${x}px`,
|
|
310
|
-
top: `${y}px`
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
},
|
|
314
|
-
stopFloating() {
|
|
315
|
-
var _this$observer, _this$stopAutoUpdate;
|
|
316
|
-
(_this$observer = this.observer) === null || _this$observer === void 0 ? void 0 : _this$observer.disconnect();
|
|
317
|
-
(_this$stopAutoUpdate = this.stopAutoUpdate) === null || _this$stopAutoUpdate === void 0 ? void 0 : _this$stopAutoUpdate.call(this);
|
|
318
|
-
},
|
|
319
|
-
async toggle(event) {
|
|
320
|
-
if (event && this.visible) {
|
|
321
|
-
let prevented = false;
|
|
322
|
-
this.$emit(GL_DROPDOWN_BEFORE_CLOSE, {
|
|
323
|
-
originalEvent: event,
|
|
324
|
-
preventDefault() {
|
|
325
|
-
prevented = true;
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
if (prevented) return false;
|
|
329
|
-
}
|
|
330
|
-
this.visible = !this.visible;
|
|
331
|
-
if (this.visible) {
|
|
332
|
-
// The dropdown needs to be actually visible before we compute its position with Floating UI.
|
|
333
|
-
await this.$nextTick();
|
|
334
|
-
this.openedYet = true;
|
|
335
|
-
/**
|
|
336
|
-
* We wait until the dropdown's position has been computed before emitting the `shown` event.
|
|
337
|
-
* This ensures that, if the parent component attempts to focus an inner element, the dropdown
|
|
338
|
-
* is already properly placed in the page. Otherwise, the page would scroll back to the top.
|
|
339
|
-
*/
|
|
340
|
-
this.startFloating();
|
|
341
|
-
this.$emit(GL_DROPDOWN_SHOWN);
|
|
342
|
-
} else {
|
|
343
|
-
this.stopFloating();
|
|
344
|
-
this.$emit(GL_DROPDOWN_HIDDEN);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// this is to check whether `toggle` was prevented or not
|
|
348
|
-
return true;
|
|
349
|
-
},
|
|
350
|
-
open() {
|
|
351
|
-
if (this.visible) {
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
this.toggle();
|
|
355
|
-
},
|
|
356
|
-
close(event) {
|
|
357
|
-
if (!this.visible) {
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
this.toggle(event);
|
|
361
|
-
},
|
|
362
|
-
/**
|
|
363
|
-
* Closes the dropdown and returns the focus to the toggle unless it has has moved outside
|
|
364
|
-
* of the dropdown, meaning that the consumer needed to put some other element in focus.
|
|
365
|
-
*
|
|
366
|
-
* @param {KeyboardEvent?} event The keyboard event that caused the dropdown to close.
|
|
367
|
-
*/
|
|
368
|
-
async closeAndFocus(event) {
|
|
369
|
-
if (!this.visible) {
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
const hasToggled = await this.toggle(event);
|
|
373
|
-
if (!this.$el.contains(document.activeElement)) {
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
if (hasToggled) {
|
|
377
|
-
this.focusToggle();
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
-
focusToggle() {
|
|
381
|
-
this.toggleElement.focus();
|
|
382
|
-
},
|
|
383
|
-
onKeydown(event) {
|
|
384
|
-
const {
|
|
385
|
-
code,
|
|
386
|
-
target: {
|
|
387
|
-
tagName
|
|
388
|
-
}
|
|
389
|
-
} = event;
|
|
390
|
-
let toggleOnEnter = true;
|
|
391
|
-
let toggleOnSpace = true;
|
|
392
|
-
if (tagName === 'BUTTON') {
|
|
393
|
-
toggleOnEnter = false;
|
|
394
|
-
toggleOnSpace = false;
|
|
395
|
-
} else if (tagName === 'A') {
|
|
396
|
-
toggleOnEnter = false;
|
|
397
|
-
}
|
|
398
|
-
if (code === ENTER && toggleOnEnter || code === SPACE && toggleOnSpace) {
|
|
399
|
-
this.toggle(event);
|
|
400
|
-
}
|
|
401
|
-
if (code === ARROW_DOWN) {
|
|
402
|
-
this.$emit(GL_DROPDOWN_FOCUS_CONTENT, event);
|
|
403
|
-
}
|
|
404
|
-
},
|
|
405
|
-
calculateNonScrollableAreaHeight() {
|
|
406
|
-
var _this$$refs$content;
|
|
407
|
-
const scrollableArea = (_this$$refs$content = this.$refs.content) === null || _this$$refs$content === void 0 ? void 0 : _this$$refs$content.querySelector(`.${GL_DROPDOWN_CONTENTS_CLASS}`);
|
|
408
|
-
if (!scrollableArea) return;
|
|
409
|
-
const floatingElementBoundingBox = this.$refs.content.getBoundingClientRect();
|
|
410
|
-
const scrollableAreaBoundingBox = scrollableArea.getBoundingClientRect();
|
|
411
|
-
this.nonScrollableContentHeight = floatingElementBoundingBox.height - scrollableAreaBoundingBox.height;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
/* script */
|
|
417
|
-
const __vue_script__ = script;
|
|
418
|
-
|
|
419
|
-
/* template */
|
|
420
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:"outside",rawName:"v-outside",value:(_vm.close),expression:"close"}],class:[_vm.$options.BASE_DROPDOWN_CLASS, { 'gl-display-block!': _vm.block }]},[_c(_vm.toggleComponent,_vm._g(_vm._b({ref:"toggle",tag:"component",attrs:{"id":_vm.toggleId,"data-testid":"base-dropdown-toggle"}},'component',_vm.toggleAttributes,false),_vm.toggleListeners),[_vm._t("toggle",function(){return [_c('span',{staticClass:"gl-new-dropdown-button-text",class:{ 'gl-sr-only': _vm.textSrOnly }},[_vm._v("\n "+_vm._s(_vm.toggleText)+"\n ")]),_vm._v(" "),(!_vm.noCaret)?_c('gl-icon',{staticClass:"gl-button-icon gl-new-dropdown-chevron",attrs:{"name":"chevron-down"}}):_vm._e()]})],2),_vm._v(" "),_c('div',{ref:"content",staticClass:"gl-new-dropdown-panel",class:_vm.panelClasses,attrs:{"id":_vm.baseDropdownId,"data-testid":"base-dropdown-menu"},on:{"keydown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"esc",27,$event.key,["Esc","Escape"])){ return null; }$event.stopPropagation();$event.preventDefault();return _vm.closeAndFocus.apply(null, arguments)}}},[_c('div',{staticClass:"gl-new-dropdown-inner"},[_vm._t("default")],2)])],1)};
|
|
421
|
-
var __vue_staticRenderFns__ = [];
|
|
422
|
-
|
|
423
|
-
/* style */
|
|
424
|
-
const __vue_inject_styles__ = undefined;
|
|
425
|
-
/* scoped */
|
|
426
|
-
const __vue_scope_id__ = undefined;
|
|
427
|
-
/* module identifier */
|
|
428
|
-
const __vue_module_identifier__ = undefined;
|
|
429
|
-
/* functional template */
|
|
430
|
-
const __vue_is_functional_template__ = false;
|
|
431
|
-
/* style inject */
|
|
432
|
-
|
|
433
|
-
/* style inject SSR */
|
|
434
|
-
|
|
435
|
-
/* style inject shadow dom */
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
const __vue_component__ = __vue_normalize__(
|
|
440
|
-
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
441
|
-
__vue_inject_styles__,
|
|
442
|
-
__vue_script__,
|
|
443
|
-
__vue_scope_id__,
|
|
444
|
-
__vue_is_functional_template__,
|
|
445
|
-
__vue_module_identifier__,
|
|
446
|
-
false,
|
|
447
|
-
undefined,
|
|
448
|
-
undefined,
|
|
449
|
-
undefined
|
|
450
|
-
);
|
|
451
|
-
|
|
452
|
-
export default __vue_component__;
|
|
453
|
-
export { BASE_DROPDOWN_CLASS };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// base dropdown events
|
|
2
|
-
const GL_DROPDOWN_SHOWN = 'shown';
|
|
3
|
-
const GL_DROPDOWN_HIDDEN = 'hidden';
|
|
4
|
-
const GL_DROPDOWN_BEFORE_CLOSE = 'beforeClose';
|
|
5
|
-
const GL_DROPDOWN_FOCUS_CONTENT = 'focusContent';
|
|
6
|
-
|
|
7
|
-
// KEY Codes
|
|
8
|
-
const ARROW_DOWN = 'ArrowDown';
|
|
9
|
-
const ARROW_UP = 'ArrowUp';
|
|
10
|
-
const END = 'End';
|
|
11
|
-
const ENTER = 'Enter';
|
|
12
|
-
const HOME = 'Home';
|
|
13
|
-
const SPACE = 'Space';
|
|
14
|
-
|
|
15
|
-
// Positioning strategies
|
|
16
|
-
// https://floating-ui.com/docs/computePosition#strategy
|
|
17
|
-
const POSITION_ABSOLUTE = 'absolute';
|
|
18
|
-
const POSITION_FIXED = 'fixed';
|
|
19
|
-
const GL_DROPDOWN_CONTENTS_CLASS = 'gl-new-dropdown-contents';
|
|
20
|
-
|
|
21
|
-
export { ARROW_DOWN, ARROW_UP, END, ENTER, GL_DROPDOWN_BEFORE_CLOSE, GL_DROPDOWN_CONTENTS_CLASS, GL_DROPDOWN_FOCUS_CONTENT, GL_DROPDOWN_HIDDEN, GL_DROPDOWN_SHOWN, HOME, POSITION_ABSOLUTE, POSITION_FIXED, SPACE };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const DISCLOSURE_DROPDOWN_ITEM_NAME = 'GlDisclosureDropdownItem';
|
|
2
|
-
const DISCLOSURE_DROPDOWN_GROUP_NAME = 'GlDisclosureDropdownGroup';
|
|
3
|
-
const DISCLOSURE_DROPDOWN_GROUP_BORDER_POSITIONS = {
|
|
4
|
-
top: 'top',
|
|
5
|
-
bottom: 'bottom'
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export { DISCLOSURE_DROPDOWN_GROUP_BORDER_POSITIONS, DISCLOSURE_DROPDOWN_GROUP_NAME, DISCLOSURE_DROPDOWN_ITEM_NAME };
|