@gitlab/ui 52.2.1 → 52.3.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 +7 -0
- package/dist/components/base/new_dropdowns/listbox/listbox.js +13 -3
- package/dist/components/base/new_dropdowns/listbox/listbox_item.js +1 -1
- package/dist/components/base/new_dropdowns/listbox/listbox_search_input.js +93 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/package.json +1 -1
- package/src/components/base/new_dropdowns/listbox/listbox.scss +48 -0
- package/src/components/base/new_dropdowns/listbox/listbox.spec.js +6 -6
- package/src/components/base/new_dropdowns/listbox/listbox.stories.js +8 -1
- package/src/components/base/new_dropdowns/listbox/listbox.vue +15 -4
- package/src/components/base/new_dropdowns/listbox/listbox_item.vue +1 -1
- package/src/components/base/new_dropdowns/listbox/listbox_search_input.spec.js +64 -0
- package/src/components/base/new_dropdowns/listbox/listbox_search_input.vue +76 -0
- package/src/scss/components.scss +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [52.3.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v52.2.1...v52.3.0) (2022-12-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **GlListbox:** Improve GlListbox's search input ([29d69c8](https://gitlab.com/gitlab-org/gitlab-ui/commit/29d69c898b643849afe08ace9514d1372e26a772))
|
|
7
|
+
|
|
1
8
|
## [52.2.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v52.2.0...v52.2.1) (2022-12-08)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -8,6 +8,7 @@ import GlLoadingIcon from '../../loading_icon/loading_icon';
|
|
|
8
8
|
import GlSearchBoxByType from '../../search_box_by_type/search_box_by_type';
|
|
9
9
|
import GlBaseDropdown from '../base_dropdown/base_dropdown';
|
|
10
10
|
import GlListboxItem from './listbox_item';
|
|
11
|
+
import GlListboxSearchInput from './listbox_search_input';
|
|
11
12
|
import GlListboxGroup from './listbox_group';
|
|
12
13
|
import { itemsValidator, isOption, flattenedOptions } from './utils';
|
|
13
14
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
@@ -15,7 +16,7 @@ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
|
15
16
|
const ITEM_SELECTOR = '[role="option"]';
|
|
16
17
|
const HEADER_ITEMS_BORDER_CLASSES = ['gl-border-b-1', 'gl-border-b-solid', 'gl-border-b-gray-200'];
|
|
17
18
|
const GROUP_TOP_BORDER_CLASSES = ['gl-border-t', 'gl-pt-3', 'gl-mt-3'];
|
|
18
|
-
const SEARCH_INPUT_SELECTOR = '.gl-search-
|
|
19
|
+
const SEARCH_INPUT_SELECTOR = '.gl-listbox-search-input';
|
|
19
20
|
var script = {
|
|
20
21
|
HEADER_ITEMS_BORDER_CLASSES,
|
|
21
22
|
events: {
|
|
@@ -28,6 +29,7 @@ var script = {
|
|
|
28
29
|
GlListboxGroup,
|
|
29
30
|
GlButton,
|
|
30
31
|
GlSearchBoxByType,
|
|
32
|
+
GlListboxSearchInput,
|
|
31
33
|
GlLoadingIcon
|
|
32
34
|
},
|
|
33
35
|
model: {
|
|
@@ -45,7 +47,7 @@ var script = {
|
|
|
45
47
|
validator: itemsValidator
|
|
46
48
|
},
|
|
47
49
|
/**
|
|
48
|
-
*
|
|
50
|
+
* Array of selected items values for multi-select and selected item value for single-select
|
|
49
51
|
*/
|
|
50
52
|
selected: {
|
|
51
53
|
type: [Array, String, Number],
|
|
@@ -209,6 +211,14 @@ var script = {
|
|
|
209
211
|
required: false,
|
|
210
212
|
default: 'No results found'
|
|
211
213
|
},
|
|
214
|
+
/**
|
|
215
|
+
* Search input placeholder text and aria-label
|
|
216
|
+
*/
|
|
217
|
+
searchPlaceholder: {
|
|
218
|
+
type: String,
|
|
219
|
+
required: false,
|
|
220
|
+
default: 'Search'
|
|
221
|
+
},
|
|
212
222
|
/**
|
|
213
223
|
* The reset button's label, to be rendered in the header. If this is omitted, the button is not
|
|
214
224
|
* rendered.
|
|
@@ -455,7 +465,7 @@ var script = {
|
|
|
455
465
|
const __vue_script__ = script;
|
|
456
466
|
|
|
457
467
|
/* template */
|
|
458
|
-
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,"toggle-id":_vm.toggleId,"toggle-text":_vm.listboxToggleText,"toggle-class":_vm.toggleClass,"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,"right":_vm.right},on:_vm._d({},[_vm.$options.events.GL_DROPDOWN_SHOWN,_vm.onShow,_vm.$options.events.GL_DROPDOWN_HIDDEN,_vm.onHide])},[(_vm.headerText)?_c('div',{staticClass:"gl-display-flex gl-align-items-center gl-
|
|
468
|
+
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,"toggle-id":_vm.toggleId,"toggle-text":_vm.listboxToggleText,"toggle-class":_vm.toggleClass,"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,"right":_vm.right},on:_vm._d({},[_vm.$options.events.GL_DROPDOWN_SHOWN,_vm.onShow,_vm.$options.events.GL_DROPDOWN_HIDDEN,_vm.onHide])},[(_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!",attrs:{"category":"tertiary","data-testid":"listbox-reset-button"},on:{"click":_vm.onResetButtonClicked}},[_vm._v("\n "+_vm._s(_vm.resetButtonLabel)+"\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",attrs:{"aria-owns":_vm.listboxId,"data-testid":"listbox-search-input","placeholder":_vm.searchPlaceholder},on:{"input":_vm.search,"keydown":_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-dropdown-contents gl-list-style-none gl-pl-0 gl-mb-0",attrs:{"id":"listbox","aria-labelledby":_vm.listAriaLabelledBy || _vm.headerId || _vm.toggleId,"role":"listbox","tabindex":"-1"},on:{"keydown":_vm.onKeydown}},[_vm._l((_vm.items),function(item,index){return [(_vm.isOption(item))?[_c('gl-listbox-item',{key:item.value,attrs:{"is-selected":_vm.isSelected(item),"is-focused":_vm.isFocused(item),"is-check-centered":_vm.isCheckCentered},on:{"select":function($event){return _vm.onSelect(item, $event)}}},[_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},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:{"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)]]})],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")],2):(_vm.showNoResultsText)?_c('div',{staticClass:"gl-pl-7 gl-pr-5 gl-pt-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)};
|
|
459
469
|
var __vue_staticRenderFns__ = [];
|
|
460
470
|
|
|
461
471
|
/* style */
|
|
@@ -52,7 +52,7 @@ var script = {
|
|
|
52
52
|
const __vue_script__ = script;
|
|
53
53
|
|
|
54
54
|
/* template */
|
|
55
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('li',{staticClass:"gl-dropdown-item",attrs:{"role":"option","tabindex":_vm.isFocused ? 0 : -1,"aria-selected":_vm.isSelected},on:{"click":_vm.toggleSelection,"keydown":_vm.onKeydown}},[_c('span',{staticClass:"dropdown-item"},[_c('gl-icon',{class:[
|
|
55
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('li',{staticClass:"gl-dropdown-item gl-listbox-item",attrs:{"role":"option","tabindex":_vm.isFocused ? 0 : -1,"aria-selected":_vm.isSelected},on:{"click":_vm.toggleSelection,"keydown":_vm.onKeydown}},[_c('span',{staticClass:"dropdown-item"},[_c('gl-icon',{class:[
|
|
56
56
|
'gl-dropdown-item-check-icon',
|
|
57
57
|
{ 'gl-visibility-hidden': !_vm.isSelected },
|
|
58
58
|
_vm.checkedClasses ],attrs:{"name":"mobile-issue-close","data-testid":"dropdown-item-checkbox"}}),_vm._v(" "),_c('span',{staticClass:"gl-dropdown-item-text-wrapper"},[_vm._t("default")],2)],1)])};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import debounce from 'lodash/debounce';
|
|
2
|
+
import GlClearIconButton from '../../../shared_components/clear_icon_button/clear_icon_button';
|
|
3
|
+
import GlIcon from '../../icon/icon';
|
|
4
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
5
|
+
|
|
6
|
+
var script = {
|
|
7
|
+
components: {
|
|
8
|
+
GlClearIconButton,
|
|
9
|
+
GlIcon
|
|
10
|
+
},
|
|
11
|
+
model: {
|
|
12
|
+
prop: 'value',
|
|
13
|
+
event: 'input'
|
|
14
|
+
},
|
|
15
|
+
props: {
|
|
16
|
+
/**
|
|
17
|
+
* If provided, used as value of search input
|
|
18
|
+
*/
|
|
19
|
+
value: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: false,
|
|
22
|
+
default: ''
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* Search input placeholder text and aria-label
|
|
26
|
+
*/
|
|
27
|
+
placeholder: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: false,
|
|
30
|
+
default: 'Search'
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
computed: {
|
|
34
|
+
hasValue() {
|
|
35
|
+
return Boolean(this.value.length);
|
|
36
|
+
},
|
|
37
|
+
inputListeners() {
|
|
38
|
+
return {
|
|
39
|
+
...this.$listeners,
|
|
40
|
+
input: debounce(event => {
|
|
41
|
+
this.$emit('input', event.target.value);
|
|
42
|
+
}, 200)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
methods: {
|
|
47
|
+
clearInput() {
|
|
48
|
+
this.$emit('input', '');
|
|
49
|
+
this.focusInput();
|
|
50
|
+
},
|
|
51
|
+
focusInput() {
|
|
52
|
+
this.$refs.input.focus();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/* script */
|
|
58
|
+
const __vue_script__ = script;
|
|
59
|
+
|
|
60
|
+
/* template */
|
|
61
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-listbox-search"},[_c('gl-icon',{staticClass:"gl-listbox-search-icon",attrs:{"name":"search-sm","size":12}}),_vm._v(" "),_c('input',_vm._g({ref:"input",staticClass:"gl-listbox-search-input",attrs:{"type":"search","aria-label":_vm.placeholder,"placeholder":_vm.placeholder},domProps:{"value":_vm.value}},_vm.inputListeners)),_vm._v(" "),(_vm.hasValue)?_c('gl-clear-icon-button',{staticClass:"gl-listbox-search-clear-button",on:{"click":function($event){$event.stopPropagation();return _vm.clearInput.apply(null, arguments)}}}):_vm._e()],1)};
|
|
62
|
+
var __vue_staticRenderFns__ = [];
|
|
63
|
+
|
|
64
|
+
/* style */
|
|
65
|
+
const __vue_inject_styles__ = undefined;
|
|
66
|
+
/* scoped */
|
|
67
|
+
const __vue_scope_id__ = undefined;
|
|
68
|
+
/* module identifier */
|
|
69
|
+
const __vue_module_identifier__ = undefined;
|
|
70
|
+
/* functional template */
|
|
71
|
+
const __vue_is_functional_template__ = false;
|
|
72
|
+
/* style inject */
|
|
73
|
+
|
|
74
|
+
/* style inject SSR */
|
|
75
|
+
|
|
76
|
+
/* style inject shadow dom */
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
const __vue_component__ = __vue_normalize__(
|
|
81
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
82
|
+
__vue_inject_styles__,
|
|
83
|
+
__vue_script__,
|
|
84
|
+
__vue_scope_id__,
|
|
85
|
+
__vue_is_functional_template__,
|
|
86
|
+
__vue_module_identifier__,
|
|
87
|
+
false,
|
|
88
|
+
undefined,
|
|
89
|
+
undefined,
|
|
90
|
+
undefined
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
export default __vue_component__;
|