@gitlab/ui 39.3.2 → 39.5.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 +26 -0
- package/dist/components/base/alert/alert.js +1 -1
- package/dist/components/base/filtered_search/filtered_search_term.js +2 -1
- package/dist/components/base/filtered_search/filtered_search_token.js +3 -2
- package/dist/components/base/filtered_search/filtered_search_token_segment.js +3 -2
- package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +240 -0
- package/dist/components/base/new_dropdowns/constants.js +20 -0
- package/dist/components/base/new_dropdowns/listbox/listbox.js +381 -0
- package/dist/components/base/new_dropdowns/listbox/listbox_item.js +77 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +2 -0
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/dist/utils/utils.js +24 -1
- package/package.json +5 -4
- package/src/components/base/alert/alert.spec.js +3 -1
- package/src/components/base/alert/alert.vue +1 -1
- package/src/components/base/dropdown/dropdown.scss +10 -3
- package/src/components/base/dropdown/dropdown_item.scss +1 -0
- package/src/components/base/filtered_search/filtered_search_term.vue +9 -1
- package/src/components/base/filtered_search/filtered_search_token.vue +16 -3
- package/src/components/base/filtered_search/filtered_search_token_segment.vue +5 -4
- package/src/components/base/link/link.stories.js +9 -7
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.spec.js +171 -0
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.vue +221 -0
- package/src/components/base/new_dropdowns/constants.js +22 -0
- package/src/components/base/new_dropdowns/listbox/listbox.md +71 -0
- package/src/components/base/new_dropdowns/listbox/listbox.spec.js +236 -0
- package/src/components/base/new_dropdowns/listbox/listbox.stories.js +276 -0
- package/src/components/base/new_dropdowns/listbox/listbox.vue +348 -0
- package/src/components/base/new_dropdowns/listbox/listbox_item.spec.js +104 -0
- package/src/components/base/new_dropdowns/listbox/listbox_item.vue +59 -0
- package/src/components/utilities/friendly_wrap/friendly_wrap.stories.js +10 -11
- package/src/components/utilities/sprintf/sprintf.stories.js +11 -9
- package/src/index.js +4 -0
- package/src/scss/utilities.scss +10 -0
- package/src/scss/utility-mixins/composite.scss +20 -0
- package/src/scss/utility-mixins/index.scss +1 -0
- package/src/utils/data_utils.js +2 -21
- package/src/utils/utils.js +18 -0
- package/src/utils/utils.spec.js +41 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## [39.5.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v39.5.0...v39.5.1) (2022-05-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **GlFilteredSearch:** cursorPosition prop not required ([ff3b3e0](https://gitlab.com/gitlab-org/gitlab-ui/commit/ff3b3e03199d703d0251e1b751bee30a942852cf))
|
|
7
|
+
|
|
8
|
+
# [39.5.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v39.4.0...v39.5.0) (2022-05-02)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **Alert:** Change title heading level from 4 to 2 ([0d69125](https://gitlab.com/gitlab-org/gitlab-ui/commit/0d69125fd7ef23ef6fe8eeb2d5395b6dc5dbde09))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* Add gl--flex-center composite class ([d1b3153](https://gitlab.com/gitlab-org/gitlab-ui/commit/d1b315356dfb07e718d67df0c16d0e43c48c1f55))
|
|
19
|
+
|
|
20
|
+
# [39.4.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v39.3.2...v39.4.0) (2022-04-28)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* **GlListbox:** create listbox component ([dcc7eae](https://gitlab.com/gitlab-org/gitlab-ui/commit/dcc7eae54db81de1c922857c990f89ceb0e1c694))
|
|
26
|
+
|
|
1
27
|
## [39.3.2](https://gitlab.com/gitlab-org/gitlab-ui/compare/v39.3.1...v39.3.2) (2022-04-27)
|
|
2
28
|
|
|
3
29
|
|
|
@@ -185,7 +185,7 @@ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=
|
|
|
185
185
|
{ 'gl-alert-sticky': _vm.sticky },
|
|
186
186
|
{ 'gl-alert-not-dismissible': !_vm.dismissible },
|
|
187
187
|
{ 'gl-alert-no-icon': !_vm.showIcon },
|
|
188
|
-
_vm.variantClass ]},[(_vm.showIcon)?_c('gl-icon',{class:{ 'gl-alert-icon': true, 'gl-alert-icon-no-title': !_vm.title },attrs:{"name":_vm.iconName}}):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-alert-content",attrs:{"role":"alert"}},[(_vm.title)?_c('
|
|
188
|
+
_vm.variantClass ]},[(_vm.showIcon)?_c('gl-icon',{class:{ 'gl-alert-icon': true, 'gl-alert-icon-no-title': !_vm.title },attrs:{"name":_vm.iconName}}):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-alert-content",attrs:{"role":"alert"}},[(_vm.title)?_c('h2',{staticClass:"gl-alert-title"},[_vm._v(_vm._s(_vm.title))]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-alert-body"},[_vm._t("default")],2),_vm._v(" "),(_vm.shouldRenderActions)?_c('div',{staticClass:"gl-alert-actions"},[_vm._t("actions",_vm._l((_vm.actionButtons),function(actionButton,index){return _c('gl-button',_vm._g(_vm._b({key:index,staticClass:"gl-alert-action"},'gl-button',actionButton.attrs,false),actionButton.listeners),[_vm._v("\n "+_vm._s(actionButton.text)+"\n ")])}))],2):_vm._e()]),_vm._v(" "),(_vm.dismissible)?_c('close-button',{ref:"dismiss",staticClass:"gl-dismiss-btn",attrs:{"label":_vm.dismissLabel},on:{"click":_vm.onDismiss}}):_vm._e()],1)};
|
|
189
189
|
var __vue_staticRenderFns__ = [];
|
|
190
190
|
|
|
191
191
|
/* style */
|
|
@@ -76,7 +76,8 @@ var script = {
|
|
|
76
76
|
},
|
|
77
77
|
cursorPosition: {
|
|
78
78
|
type: String,
|
|
79
|
-
required:
|
|
79
|
+
required: false,
|
|
80
|
+
default: 'end',
|
|
80
81
|
validator: value => ['start', 'end'].includes(value)
|
|
81
82
|
}
|
|
82
83
|
},
|
|
@@ -335,7 +336,7 @@ const __vue_script__ = script;
|
|
|
335
336
|
/* template */
|
|
336
337
|
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-filtered-search-token",class:{ 'gl-filtered-search-token-active': _vm.active },attrs:{"data-testid":"filtered-search-token"}},[_c('gl-filtered-search-token-segment',{key:"title-segment",attrs:{"value":_vm.config.title,"active":_vm.isSegmentActive(_vm.$options.segments.SEGMENT_TITLE),"cursor-position":_vm.intendedCursorPosition,"options":_vm.availableTokensWithSelf},on:{"activate":function($event){return _vm.activateSegment(_vm.$options.segments.SEGMENT_TITLE)},"deactivate":function($event){return _vm.$emit('deactivate')},"complete":_vm.replaceToken,"backspace":function($event){return _vm.$emit('destroy')},"submit":function($event){return _vm.$emit('submit')},"previous":function($event){return _vm.$emit('previous')},"next":_vm.activateNextOperatorSegment},scopedSlots:_vm._u([{key:"view",fn:function(ref){
|
|
337
338
|
var inputValue = ref.inputValue;
|
|
338
|
-
return [_c('gl-token',{staticClass:"gl-filtered-search-token-type",class:_vm.getAdditionalSegmentClasses(_vm.$options.segments.SEGMENT_TITLE),attrs:{"view-only":""}},[_vm._v(_vm._s(inputValue))])]}}])}),_vm._v(" "),_c('gl-filtered-search-token-segment',{key:"operator-segment",attrs:{"active":_vm.isSegmentActive(_vm.$options.segments.SEGMENT_OPERATOR),"cursor-position":_vm.intendedCursorPosition,"options":_vm.operators,"custom-input-keydown-handler":_vm.handleOperatorKeydown,"view-only":""},on:{"activate":function($event){return _vm.activateSegment(_vm.$options.segments.SEGMENT_OPERATOR)},"backspace":_vm.replaceWithTermIfEmpty,"complete":function($event){return _vm.activateSegment(_vm.$options.segments.SEGMENT_DATA)},"deactivate":function($event){return _vm.$emit('deactivate')},"previous":_vm.activatePreviousTitleSegment,"next":_vm.activateNextDataSegment},scopedSlots:_vm._u([{key:"view",fn:function(){return [_c('gl-token',{staticClass:"gl-filtered-search-token-operator",class:_vm.getAdditionalSegmentClasses(_vm.$options.segments.SEGMENT_OPERATOR),attrs:{"variant":"search-value","view-only":""}},[_vm._v(_vm._s(_vm.operatorDescription))])]},proxy:true},{key:"option",fn:function(ref){
|
|
339
|
+
return [_c('gl-token',{staticClass:"gl-filtered-search-token-type",class:_vm.getAdditionalSegmentClasses(_vm.$options.segments.SEGMENT_TITLE),attrs:{"view-only":""}},[_vm._v("\n "+_vm._s(inputValue)+"\n ")])]}}])}),_vm._v(" "),_c('gl-filtered-search-token-segment',{key:"operator-segment",attrs:{"active":_vm.isSegmentActive(_vm.$options.segments.SEGMENT_OPERATOR),"cursor-position":_vm.intendedCursorPosition,"options":_vm.operators,"custom-input-keydown-handler":_vm.handleOperatorKeydown,"view-only":""},on:{"activate":function($event){return _vm.activateSegment(_vm.$options.segments.SEGMENT_OPERATOR)},"backspace":_vm.replaceWithTermIfEmpty,"complete":function($event){return _vm.activateSegment(_vm.$options.segments.SEGMENT_DATA)},"deactivate":function($event){return _vm.$emit('deactivate')},"previous":_vm.activatePreviousTitleSegment,"next":_vm.activateNextDataSegment},scopedSlots:_vm._u([{key:"view",fn:function(){return [_c('gl-token',{staticClass:"gl-filtered-search-token-operator",class:_vm.getAdditionalSegmentClasses(_vm.$options.segments.SEGMENT_OPERATOR),attrs:{"variant":"search-value","view-only":""}},[_vm._v("\n "+_vm._s(_vm.operatorDescription)+"\n ")])]},proxy:true},{key:"option",fn:function(ref){
|
|
339
340
|
var option = ref.option;
|
|
340
341
|
return [_c('div',{staticClass:"gl-display-flex"},[_vm._v("\n "+_vm._s(option.value)+"\n "),(option.description)?_c('span',{staticClass:"gl-filtered-search-token-operator-description"},[_vm._v("\n "+_vm._s(option.description)+"\n ")]):_vm._e()])]}}]),model:{value:(_vm.tokenValue.operator),callback:function ($$v) {_vm.$set(_vm.tokenValue, "operator", $$v);},expression:"tokenValue.operator"}}),_vm._v(" "),(_vm.hasDataOrDataSegmentIsCurrentlyActive)?_c('gl-filtered-search-token-segment',{key:"data-segment",attrs:{"active":_vm.isSegmentActive(_vm.$options.segments.SEGMENT_DATA),"cursor-position":_vm.intendedCursorPosition,"multi-select":_vm.config.multiSelect,"options":_vm.config.options,"option-text-field":"title"},on:{"activate":_vm.activateDataSegment,"backspace":function($event){return _vm.activateSegment(_vm.$options.segments.SEGMENT_OPERATOR)},"complete":_vm.handleComplete,"select":function($event){return _vm.$emit('select', $event)},"submit":function($event){return _vm.$emit('submit')},"deactivate":function($event){return _vm.$emit('deactivate')},"split":function($event){return _vm.$emit('split', $event)},"previous":_vm.activatePreviousOperatorSegment,"next":function($event){return _vm.$emit('next')}},scopedSlots:_vm._u([{key:"suggestions",fn:function(){return [_vm._t("suggestions")]},proxy:true},{key:"view",fn:function(ref){
|
|
341
342
|
var inputValue = ref.inputValue;
|
|
@@ -82,7 +82,8 @@ var script = {
|
|
|
82
82
|
},
|
|
83
83
|
cursorPosition: {
|
|
84
84
|
type: String,
|
|
85
|
-
required:
|
|
85
|
+
required: false,
|
|
86
|
+
default: 'end',
|
|
86
87
|
validator: value => ['start', 'end'].includes(value)
|
|
87
88
|
}
|
|
88
89
|
},
|
|
@@ -361,7 +362,7 @@ const __vue_script__ = script;
|
|
|
361
362
|
/* template */
|
|
362
363
|
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',_vm._b({staticClass:"gl-filtered-search-token-segment",class:{
|
|
363
364
|
'gl-filtered-search-token-segment-active': _vm.active,
|
|
364
|
-
},attrs:{"data-testid":"filtered-search-token-segment"},on:{"mousedown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"left",37,$event.key,["Left","ArrowLeft"])){ return null; }if('button' in $event && $event.button !== 0){ return null; }return _vm.emitIfInactive($event)}}},'div',_vm.containerAttributes,false),[(_vm.active)?[(((_vm.searchInputAttributes).type)==='checkbox')?_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",attrs:{"aria-label":_vm.label,"type":"checkbox"},domProps:{"checked":Array.isArray(_vm.inputValue)?_vm._i(_vm.inputValue,null)>-1:(_vm.inputValue)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"change":function($event){var $$a=_vm.inputValue,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=null,$$i=_vm._i($$a,$$v);if($$el.checked){$$i<0&&(_vm.inputValue=$$a.concat([$$v]));}else {$$i>-1&&(_vm.inputValue=$$a.slice(0,$$i).concat($$a.slice($$i+1)));}}else {_vm.inputValue=$$c;}}}},'input',_vm.searchInputAttributes,false)):(((_vm.searchInputAttributes).type)==='radio')?_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",attrs:{"aria-label":_vm.label,"type":"radio"},domProps:{"checked":_vm._q(_vm.inputValue,null)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"change":function($event){_vm.inputValue=null;}}},'input',_vm.searchInputAttributes,false)):_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",attrs:{"aria-label":_vm.label,"type":(_vm.searchInputAttributes).type},domProps:{"value":(_vm.inputValue)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"input":function($event){if($event.target.composing){ return; }_vm.inputValue=$event.target.value;}}},'input',_vm.searchInputAttributes,false)),_vm._v(" "),_c('portal',{key:("operator-" + _vm._uid),attrs:{"to":_vm.portalName}},[(_vm.hasOptionsOrSuggestions)?_c('gl-filtered-search-suggestion-list',{key:("operator-" + _vm._uid),ref:"suggestions",attrs:{"initial-value":_vm.defaultSuggestedValue},on:{"suggestion":_vm.applySuggestion}},[(_vm.options)?_vm._l((_vm.options),function(option,idx){return _c('gl-filtered-search-suggestion',{key:((option.value) + "-" + idx),attrs:{"value":option.value,"icon-name":option.icon}},[_vm._t("option",[_vm._v("
|
|
365
|
+
},attrs:{"data-testid":"filtered-search-token-segment"},on:{"mousedown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"left",37,$event.key,["Left","ArrowLeft"])){ return null; }if('button' in $event && $event.button !== 0){ return null; }return _vm.emitIfInactive($event)}}},'div',_vm.containerAttributes,false),[(_vm.active)?[(((_vm.searchInputAttributes).type)==='checkbox')?_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",attrs:{"aria-label":_vm.label,"type":"checkbox"},domProps:{"checked":Array.isArray(_vm.inputValue)?_vm._i(_vm.inputValue,null)>-1:(_vm.inputValue)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"change":function($event){var $$a=_vm.inputValue,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=null,$$i=_vm._i($$a,$$v);if($$el.checked){$$i<0&&(_vm.inputValue=$$a.concat([$$v]));}else {$$i>-1&&(_vm.inputValue=$$a.slice(0,$$i).concat($$a.slice($$i+1)));}}else {_vm.inputValue=$$c;}}}},'input',_vm.searchInputAttributes,false)):(((_vm.searchInputAttributes).type)==='radio')?_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",attrs:{"aria-label":_vm.label,"type":"radio"},domProps:{"checked":_vm._q(_vm.inputValue,null)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"change":function($event){_vm.inputValue=null;}}},'input',_vm.searchInputAttributes,false)):_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",attrs:{"aria-label":_vm.label,"type":(_vm.searchInputAttributes).type},domProps:{"value":(_vm.inputValue)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"input":function($event){if($event.target.composing){ return; }_vm.inputValue=$event.target.value;}}},'input',_vm.searchInputAttributes,false)),_vm._v(" "),_c('portal',{key:("operator-" + _vm._uid),attrs:{"to":_vm.portalName}},[(_vm.hasOptionsOrSuggestions)?_c('gl-filtered-search-suggestion-list',{key:("operator-" + _vm._uid),ref:"suggestions",attrs:{"initial-value":_vm.defaultSuggestedValue},on:{"suggestion":_vm.applySuggestion}},[(_vm.options)?_vm._l((_vm.options),function(option,idx){return _c('gl-filtered-search-suggestion',{key:((option.value) + "-" + idx),attrs:{"value":option.value,"icon-name":option.icon}},[_vm._t("option",[_vm._v(" "+_vm._s(option[_vm.optionTextField])+" ")],null,{ option: option })],2)}):_vm._t("suggestions")],2):_vm._e()],1)]:_vm._t("view",[_vm._v(_vm._s(_vm.inputValue))],null,{ inputValue: _vm.inputValue })],2)};
|
|
365
366
|
var __vue_staticRenderFns__ = [];
|
|
366
367
|
|
|
367
368
|
/* style */
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { createPopper } from '@popperjs/core';
|
|
2
|
+
import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions } from '../../../../utils/constants';
|
|
3
|
+
import { POPPER_CONFIG, GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN } from '../constants';
|
|
4
|
+
import GlButton from '../../button/button';
|
|
5
|
+
import GlIcon from '../../icon/icon';
|
|
6
|
+
import { OutsideDirective } from '../../../../directives/outside/outside';
|
|
7
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
8
|
+
|
|
9
|
+
var script = {
|
|
10
|
+
components: {
|
|
11
|
+
GlButton,
|
|
12
|
+
GlIcon
|
|
13
|
+
},
|
|
14
|
+
directives: {
|
|
15
|
+
Outside: OutsideDirective
|
|
16
|
+
},
|
|
17
|
+
props: {
|
|
18
|
+
toggleText: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: false,
|
|
21
|
+
default: ''
|
|
22
|
+
},
|
|
23
|
+
textSrOnly: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
required: false,
|
|
26
|
+
default: false
|
|
27
|
+
},
|
|
28
|
+
category: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: false,
|
|
31
|
+
default: buttonCategoryOptions.primary,
|
|
32
|
+
validator: value => Object.keys(buttonCategoryOptions).includes(value)
|
|
33
|
+
},
|
|
34
|
+
variant: {
|
|
35
|
+
type: String,
|
|
36
|
+
required: false,
|
|
37
|
+
default: dropdownVariantOptions.default,
|
|
38
|
+
validator: value => Object.keys(dropdownVariantOptions).includes(value)
|
|
39
|
+
},
|
|
40
|
+
size: {
|
|
41
|
+
type: String,
|
|
42
|
+
required: false,
|
|
43
|
+
default: buttonSizeOptions.medium,
|
|
44
|
+
validator: value => Object.keys(buttonSizeOptions).includes(value)
|
|
45
|
+
},
|
|
46
|
+
icon: {
|
|
47
|
+
type: String,
|
|
48
|
+
required: false,
|
|
49
|
+
default: ''
|
|
50
|
+
},
|
|
51
|
+
disabled: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
required: false,
|
|
54
|
+
default: false
|
|
55
|
+
},
|
|
56
|
+
loading: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
required: false,
|
|
59
|
+
default: false
|
|
60
|
+
},
|
|
61
|
+
toggleClass: {
|
|
62
|
+
type: [String, Array, Object],
|
|
63
|
+
required: false,
|
|
64
|
+
default: null
|
|
65
|
+
},
|
|
66
|
+
noCaret: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
required: false,
|
|
69
|
+
default: false
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Right align dropdown menu with respect to the toggle button
|
|
74
|
+
*/
|
|
75
|
+
right: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
required: false,
|
|
78
|
+
default: false
|
|
79
|
+
},
|
|
80
|
+
// ARIA props
|
|
81
|
+
ariaHaspopup: {
|
|
82
|
+
type: [String, Boolean],
|
|
83
|
+
required: false,
|
|
84
|
+
default: false,
|
|
85
|
+
validator: value => {
|
|
86
|
+
return ['menu', 'listbox', 'tree', 'grid', 'dialog', true, false].includes(value);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Id that will be referenced by `aria-labelledby` attribute of the dropdown content`
|
|
92
|
+
*/
|
|
93
|
+
toggleId: {
|
|
94
|
+
type: String,
|
|
95
|
+
required: true
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The `aria-labelledby` attribute value for the toggle `button`
|
|
100
|
+
*/
|
|
101
|
+
ariaLabelledby: {
|
|
102
|
+
type: String,
|
|
103
|
+
required: false,
|
|
104
|
+
default: null
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
data() {
|
|
109
|
+
return {
|
|
110
|
+
visible: false
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
computed: {
|
|
115
|
+
isIconOnly() {
|
|
116
|
+
var _this$toggleText;
|
|
117
|
+
|
|
118
|
+
return Boolean(this.icon && (!((_this$toggleText = this.toggleText) !== null && _this$toggleText !== void 0 && _this$toggleText.length) || this.textSrOnly));
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
isIconWithText() {
|
|
122
|
+
var _this$toggleText2;
|
|
123
|
+
|
|
124
|
+
return Boolean(this.icon && ((_this$toggleText2 = this.toggleText) === null || _this$toggleText2 === void 0 ? void 0 : _this$toggleText2.length) && !this.textSrOnly);
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
toggleButtonClasses() {
|
|
128
|
+
return [this.toggleClass, {
|
|
129
|
+
'gl-dropdown-toggle': true,
|
|
130
|
+
'dropdown-toggle': true,
|
|
131
|
+
'dropdown-icon-only': this.isIconOnly,
|
|
132
|
+
'dropdown-icon-text': this.isIconWithText,
|
|
133
|
+
'dropdown-toggle-no-caret': this.noCaret
|
|
134
|
+
}];
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
toggleLabelledBy() {
|
|
138
|
+
return this.ariaLabelledby ? `${this.ariaLabelledby} ${this.toggleId}` : this.toggleId;
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
popperConfig() {
|
|
142
|
+
return {
|
|
143
|
+
placement: this.right ? 'bottom-end' : 'bottom-start',
|
|
144
|
+
...POPPER_CONFIG
|
|
145
|
+
};
|
|
146
|
+
}
|
|
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
|
+
},
|
|
157
|
+
|
|
158
|
+
mounted() {
|
|
159
|
+
this.$nextTick(() => {
|
|
160
|
+
this.popper = createPopper(this.$refs.toggle.$el, this.$refs.content, this.popperConfig);
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
beforeDestroy() {
|
|
165
|
+
this.popper.destroy();
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
methods: {
|
|
169
|
+
toggle() {
|
|
170
|
+
this.visible = !this.visible;
|
|
171
|
+
|
|
172
|
+
if (this.visible) {
|
|
173
|
+
this.popper.update();
|
|
174
|
+
this.$emit(GL_DROPDOWN_SHOWN);
|
|
175
|
+
} else {
|
|
176
|
+
this.$emit(GL_DROPDOWN_HIDDEN);
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
close() {
|
|
181
|
+
if (!this.visible) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
this.toggle();
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
closeAndFocus() {
|
|
189
|
+
if (!this.visible) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
this.toggle();
|
|
194
|
+
this.focusToggle();
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
focusToggle() {
|
|
198
|
+
this.$refs.toggle.$el.focus();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/* script */
|
|
205
|
+
const __vue_script__ = script;
|
|
206
|
+
|
|
207
|
+
/* template */
|
|
208
|
+
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"}],staticClass:"gl-new-dropdown dropdown btn-group"},[_c('gl-button',{ref:"toggle",class:_vm.toggleButtonClasses,attrs:{"id":_vm.toggleId,"data-testid":"base-dropdown-toggle","icon":_vm.icon,"category":_vm.category,"variant":_vm.variant,"size":_vm.size,"disabled":_vm.disabled,"loading":_vm.loading,"aria-haspopup":_vm.ariaHaspopup,"aria-expanded":_vm.visible,"aria-labelledby":_vm.toggleLabelledBy},on:{"click":_vm.toggle}},[_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 dropdown-chevron",attrs:{"name":"chevron-down"}}):_vm._e()],1),_vm._v(" "),_c('div',{ref:"content",staticClass:"dropdown-menu",class:{ show: _vm.visible },attrs:{"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($event)}}},[_c('div',{staticClass:"gl-new-dropdown-inner"},[_vm._t("default")],2)])],1)};
|
|
209
|
+
var __vue_staticRenderFns__ = [];
|
|
210
|
+
|
|
211
|
+
/* style */
|
|
212
|
+
const __vue_inject_styles__ = undefined;
|
|
213
|
+
/* scoped */
|
|
214
|
+
const __vue_scope_id__ = undefined;
|
|
215
|
+
/* module identifier */
|
|
216
|
+
const __vue_module_identifier__ = undefined;
|
|
217
|
+
/* functional template */
|
|
218
|
+
const __vue_is_functional_template__ = false;
|
|
219
|
+
/* style inject */
|
|
220
|
+
|
|
221
|
+
/* style inject SSR */
|
|
222
|
+
|
|
223
|
+
/* style inject shadow dom */
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
const __vue_component__ = __vue_normalize__(
|
|
228
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
229
|
+
__vue_inject_styles__,
|
|
230
|
+
__vue_script__,
|
|
231
|
+
__vue_scope_id__,
|
|
232
|
+
__vue_is_functional_template__,
|
|
233
|
+
__vue_module_identifier__,
|
|
234
|
+
false,
|
|
235
|
+
undefined,
|
|
236
|
+
undefined,
|
|
237
|
+
undefined
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
export default __vue_component__;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const POPPER_CONFIG = {
|
|
2
|
+
modifiers: [{
|
|
3
|
+
name: 'offset',
|
|
4
|
+
options: {
|
|
5
|
+
offset: [0, 4]
|
|
6
|
+
}
|
|
7
|
+
}]
|
|
8
|
+
}; // base dropdown events
|
|
9
|
+
|
|
10
|
+
const GL_DROPDOWN_SHOWN = 'shown';
|
|
11
|
+
const GL_DROPDOWN_HIDDEN = 'hidden'; // KEY Codes
|
|
12
|
+
|
|
13
|
+
const HOME = 'Home';
|
|
14
|
+
const END = 'End';
|
|
15
|
+
const ARROW_UP = 'ArrowUp';
|
|
16
|
+
const ARROW_DOWN = 'ArrowDown';
|
|
17
|
+
const ENTER = 'Enter';
|
|
18
|
+
const SPACE = 'Space';
|
|
19
|
+
|
|
20
|
+
export { ARROW_DOWN, ARROW_UP, END, ENTER, GL_DROPDOWN_HIDDEN, GL_DROPDOWN_SHOWN, HOME, POPPER_CONFIG, SPACE };
|