@gitlab/ui 42.16.0 → 42.18.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 +23 -0
- package/dist/components/base/drawer/drawer.js +1 -1
- package/dist/components/base/form/form_combobox/constants.js +15 -1
- package/dist/components/base/form/form_combobox/form_combobox.js +65 -8
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/package.json +3 -3
- package/src/components/base/drawer/drawer.scss +27 -0
- package/src/components/base/drawer/drawer.spec.js +22 -0
- package/src/components/base/drawer/drawer.stories.js +45 -2
- package/src/components/base/drawer/drawer.vue +2 -1
- package/src/components/base/form/form_combobox/constants.js +19 -0
- package/src/components/base/form/form_combobox/form_combobox.scss +0 -5
- package/src/components/base/form/form_combobox/form_combobox.spec.js +70 -2
- package/src/components/base/form/form_combobox/form_combobox.stories.js +33 -4
- package/src/components/base/form/form_combobox/form_combobox.vue +89 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
## [42.18.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v42.18.0...v42.18.1) (2022-07-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency dompurify to ^2.3.9 ([9148ae8](https://gitlab.com/gitlab-org/gitlab-ui/commit/9148ae8d607498ea444d8dcde9653d8ae017bc60))
|
|
7
|
+
|
|
8
|
+
# [42.18.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v42.17.0...v42.18.0) (2022-07-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **GlCombobox:** Add action items ([297ed28](https://gitlab.com/gitlab-org/gitlab-ui/commit/297ed28588558229d0e2e5629875e80ec52edc32))
|
|
14
|
+
* **GlCombobox:** Add action items ([af4eba0](https://gitlab.com/gitlab-org/gitlab-ui/commit/af4eba02c5345e6709ef0359feeeed63659acb27))
|
|
15
|
+
* **GlCombobox:** Add action items ([cae7a7e](https://gitlab.com/gitlab-org/gitlab-ui/commit/cae7a7ecc7552cda29c41eb7c04dd3c59db1be0c))
|
|
16
|
+
|
|
17
|
+
# [42.17.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v42.16.0...v42.17.0) (2022-07-08)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **GlDrawer:** add scrim for scrollable content ([c303d42](https://gitlab.com/gitlab-org/gitlab-ui/commit/c303d4225fd053bfd150e5f169ba9a595c1ba8db))
|
|
23
|
+
|
|
1
24
|
# [42.16.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v42.15.0...v42.16.0) (2022-07-07)
|
|
2
25
|
|
|
3
26
|
|
|
@@ -103,7 +103,7 @@ var script = {
|
|
|
103
103
|
const __vue_script__ = script;
|
|
104
104
|
|
|
105
105
|
/* template */
|
|
106
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('transition',{attrs:{"name":"gl-drawer"}},[(_vm.open)?_c('aside',{staticClass:"gl-drawer",class:_vm.variantClass,style:(_vm.drawerStyles)},[_c('div',{staticClass:"gl-drawer-header",class:{ 'gl-drawer-header-sticky': _vm.headerSticky },style:(_vm.drawerHeaderStyles)},[_c('span',{staticClass:"gl-drawer-title"},[_vm._t("title"),_vm._v(" "),_c('gl-button',{staticClass:"gl-drawer-close-button",attrs:{"category":"tertiary","size":"small","icon":"close","aria-label":"Close drawer"},on:{"click":function($event){return _vm.$emit('close')}}})],2),_vm._v(" "),_vm._t("header")],2),_vm._v(" "),_c('div',{staticClass:"gl-drawer-body"},[_vm._t("default")],2),_vm._v(" "),(_vm.shouldRenderFooter)?_c('div',{staticClass:"gl-drawer-footer gl-drawer-footer-sticky",style:({ zIndex: _vm.zIndex })},[_vm._t("footer")],2):_vm._e()]):_vm._e()])};
|
|
106
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('transition',{attrs:{"name":"gl-drawer"}},[(_vm.open)?_c('aside',{staticClass:"gl-drawer",class:_vm.variantClass,style:(_vm.drawerStyles)},[_c('div',{staticClass:"gl-drawer-header",class:{ 'gl-drawer-header-sticky': _vm.headerSticky },style:(_vm.drawerHeaderStyles)},[_c('span',{staticClass:"gl-drawer-title"},[_vm._t("title"),_vm._v(" "),_c('gl-button',{staticClass:"gl-drawer-close-button",attrs:{"category":"tertiary","size":"small","icon":"close","aria-label":"Close drawer"},on:{"click":function($event){return _vm.$emit('close')}}})],2),_vm._v(" "),_vm._t("header")],2),_vm._v(" "),_c('div',{staticClass:"gl-drawer-body",class:{ 'gl-drawer-body-scrim': !_vm.shouldRenderFooter }},[_vm._t("default")],2),_vm._v(" "),(_vm.shouldRenderFooter)?_c('div',{staticClass:"gl-drawer-footer gl-drawer-footer-sticky",class:{ 'gl-drawer-body-scrim-on-footer': _vm.shouldRenderFooter },style:({ zIndex: _vm.zIndex })},[_vm._t("footer")],2):_vm._e()]):_vm._e()])};
|
|
107
107
|
var __vue_staticRenderFns__ = [];
|
|
108
108
|
|
|
109
109
|
/* style */
|
|
@@ -37,5 +37,19 @@ const objectTokenList = [{
|
|
|
37
37
|
id: '12',
|
|
38
38
|
title: 'xenarthra'
|
|
39
39
|
}];
|
|
40
|
+
const oneTokenList = ['dog'];
|
|
41
|
+
const actionsList = [{
|
|
42
|
+
label: 'Create',
|
|
43
|
+
fn: () => {
|
|
44
|
+
// eslint-disable-next-line no-alert
|
|
45
|
+
window.alert('Create action');
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
label: 'Edit',
|
|
49
|
+
fn: () => {
|
|
50
|
+
// eslint-disable-next-line no-alert
|
|
51
|
+
window.alert('Edit action');
|
|
52
|
+
}
|
|
53
|
+
}];
|
|
40
54
|
|
|
41
|
-
export { labelText, objectTokenList, stringTokenList };
|
|
55
|
+
export { actionsList, labelText, objectTokenList, oneTokenList, stringTokenList };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _uniqueId from 'lodash/uniqueId';
|
|
2
2
|
import GlDropdownItem from '../../dropdown/dropdown_item';
|
|
3
|
+
import GlDropdownDivider from '../../dropdown/dropdown_divider';
|
|
3
4
|
import GlFormGroup from '../form_group/form_group';
|
|
4
5
|
import GlFormInput from '../form_input/form_input';
|
|
5
6
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
@@ -8,6 +9,7 @@ var script = {
|
|
|
8
9
|
name: 'GlFormCombobox',
|
|
9
10
|
components: {
|
|
10
11
|
GlDropdownItem,
|
|
12
|
+
GlDropdownDivider,
|
|
11
13
|
GlFormGroup,
|
|
12
14
|
GlFormInput
|
|
13
15
|
},
|
|
@@ -29,6 +31,15 @@ var script = {
|
|
|
29
31
|
type: Array,
|
|
30
32
|
required: true
|
|
31
33
|
},
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* List of action functions to display at the bottom of the dropdown
|
|
37
|
+
*/
|
|
38
|
+
actionList: {
|
|
39
|
+
type: Array,
|
|
40
|
+
required: false,
|
|
41
|
+
default: () => []
|
|
42
|
+
},
|
|
32
43
|
value: {
|
|
33
44
|
type: [String, Object],
|
|
34
45
|
required: true
|
|
@@ -65,11 +76,39 @@ var script = {
|
|
|
65
76
|
},
|
|
66
77
|
|
|
67
78
|
showSuggestions() {
|
|
68
|
-
return this.
|
|
79
|
+
return this.value.length > 0 && this.allItems.length > 0;
|
|
69
80
|
},
|
|
70
81
|
|
|
71
82
|
displayedValue() {
|
|
72
83
|
return this.matchValueToAttr && this.value[this.matchValueToAttr] ? this.value[this.matchValueToAttr] : this.value;
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
resultsLength() {
|
|
87
|
+
return this.results.length;
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
allItems() {
|
|
91
|
+
return [...this.results, ...this.actionList];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
},
|
|
95
|
+
watch: {
|
|
96
|
+
tokenList(newList) {
|
|
97
|
+
const filteredTokens = newList.filter(token => {
|
|
98
|
+
if (this.matchValueToAttr) {
|
|
99
|
+
// For API driven tokens, we don't need extra filtering
|
|
100
|
+
return token;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return token.toLowerCase().includes(this.value.toLowerCase());
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
if (filteredTokens.length) {
|
|
107
|
+
this.openSuggestions(filteredTokens);
|
|
108
|
+
} else {
|
|
109
|
+
this.results = [];
|
|
110
|
+
this.arrowCounter = -1;
|
|
111
|
+
}
|
|
73
112
|
}
|
|
74
113
|
|
|
75
114
|
},
|
|
@@ -86,6 +125,7 @@ var script = {
|
|
|
86
125
|
closeSuggestions() {
|
|
87
126
|
this.results = [];
|
|
88
127
|
this.arrowCounter = -1;
|
|
128
|
+
this.userDismissedResults = true;
|
|
89
129
|
},
|
|
90
130
|
|
|
91
131
|
handleClickOutside(event) {
|
|
@@ -95,30 +135,41 @@ var script = {
|
|
|
95
135
|
},
|
|
96
136
|
|
|
97
137
|
onArrowDown() {
|
|
138
|
+
var _this$$refs$results$n;
|
|
139
|
+
|
|
98
140
|
const newCount = this.arrowCounter + 1;
|
|
99
141
|
|
|
100
|
-
if (newCount >= this.
|
|
142
|
+
if (newCount >= this.allItems.length) {
|
|
101
143
|
this.arrowCounter = 0;
|
|
102
144
|
return;
|
|
103
145
|
}
|
|
104
146
|
|
|
105
147
|
this.arrowCounter = newCount;
|
|
148
|
+
(_this$$refs$results$n = this.$refs.results[newCount]) === null || _this$$refs$results$n === void 0 ? void 0 : _this$$refs$results$n.$el.scrollIntoView(false);
|
|
106
149
|
},
|
|
107
150
|
|
|
108
151
|
onArrowUp() {
|
|
152
|
+
var _this$$refs$results$n2;
|
|
153
|
+
|
|
109
154
|
const newCount = this.arrowCounter - 1;
|
|
110
155
|
|
|
111
156
|
if (newCount < 0) {
|
|
112
|
-
this.arrowCounter = this.
|
|
157
|
+
this.arrowCounter = this.allItems.length - 1;
|
|
113
158
|
return;
|
|
114
159
|
}
|
|
115
160
|
|
|
116
161
|
this.arrowCounter = newCount;
|
|
162
|
+
(_this$$refs$results$n2 = this.$refs.results[newCount]) === null || _this$$refs$results$n2 === void 0 ? void 0 : _this$$refs$results$n2.$el.scrollIntoView(true);
|
|
117
163
|
},
|
|
118
164
|
|
|
119
165
|
onEnter() {
|
|
120
|
-
const
|
|
121
|
-
|
|
166
|
+
const focusedItem = this.allItems[this.arrowCounter] || this.value;
|
|
167
|
+
|
|
168
|
+
if (focusedItem.fn) {
|
|
169
|
+
this.selectAction(focusedItem);
|
|
170
|
+
} else {
|
|
171
|
+
this.selectToken(focusedItem);
|
|
172
|
+
}
|
|
122
173
|
},
|
|
123
174
|
|
|
124
175
|
onEsc() {
|
|
@@ -127,7 +178,6 @@ var script = {
|
|
|
127
178
|
}
|
|
128
179
|
|
|
129
180
|
this.closeSuggestions();
|
|
130
|
-
this.userDismissedResults = true;
|
|
131
181
|
},
|
|
132
182
|
|
|
133
183
|
onEntry(value) {
|
|
@@ -150,7 +200,8 @@ var script = {
|
|
|
150
200
|
if (filteredTokens.length) {
|
|
151
201
|
this.openSuggestions(filteredTokens);
|
|
152
202
|
} else {
|
|
153
|
-
this.
|
|
203
|
+
this.results = [];
|
|
204
|
+
this.arrowCounter = -1;
|
|
154
205
|
}
|
|
155
206
|
},
|
|
156
207
|
|
|
@@ -167,6 +218,12 @@ var script = {
|
|
|
167
218
|
*/
|
|
168
219
|
|
|
169
220
|
this.$emit('value-selected', value);
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
selectAction(value) {
|
|
224
|
+
value.fn();
|
|
225
|
+
this.$emit('input', this.value);
|
|
226
|
+
this.closeSuggestions();
|
|
170
227
|
}
|
|
171
228
|
|
|
172
229
|
}
|
|
@@ -176,7 +233,7 @@ var script = {
|
|
|
176
233
|
const __vue_script__ = script;
|
|
177
234
|
|
|
178
235
|
/* template */
|
|
179
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-form-combobox dropdown",attrs:{"role":"combobox","aria-owns":_vm.suggestionsId,"aria-expanded":_vm.ariaExpanded}},[_c('gl-form-group',{attrs:{"label":_vm.labelText,"label-for":_vm.inputId,"label-sr-only":_vm.labelSrOnly}},[_c('gl-form-input',{attrs:{"id":_vm.inputId,"value":_vm.displayedValue,"type":"text","role":"searchbox","autocomplete":_vm.showAutocomplete,"aria-autocomplete":"list","aria-controls":_vm.suggestionsId,"aria-haspopup":"listbox","autofocus":_vm.autofocus},on:{"input":_vm.onEntry,"keydown":[function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){ return null; }return _vm.onArrowDown($event)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){ return null; }return _vm.onArrowUp($event)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }$event.preventDefault();return _vm.onEnter($event)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"esc",27,$event.key,["Esc","Escape"])){ return null; }$event.stopPropagation();return _vm.onEsc($event)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"tab",9,$event.key,"Tab")){ return null; }return _vm.closeSuggestions($event)}]}})],1),_vm._v(" "),_c('ul',{directives:[{name:"show",rawName:"v-show",value:(_vm.showSuggestions && !_vm.userDismissedResults),expression:"showSuggestions && !userDismissedResults"}],staticClass:"dropdown-menu dropdown-full-width gl-list-style-none gl-pl-0 gl-mb-0 gl-overflow-y-auto",
|
|
236
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-form-combobox dropdown",attrs:{"role":"combobox","aria-owns":_vm.suggestionsId,"aria-expanded":_vm.ariaExpanded}},[_c('gl-form-group',{attrs:{"label":_vm.labelText,"label-for":_vm.inputId,"label-sr-only":_vm.labelSrOnly}},[_c('gl-form-input',{attrs:{"id":_vm.inputId,"value":_vm.displayedValue,"type":"text","role":"searchbox","autocomplete":_vm.showAutocomplete,"aria-autocomplete":"list","aria-controls":_vm.suggestionsId,"aria-haspopup":"listbox","autofocus":_vm.autofocus},on:{"input":_vm.onEntry,"keydown":[function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){ return null; }return _vm.onArrowDown($event)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){ return null; }return _vm.onArrowUp($event)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }$event.preventDefault();return _vm.onEnter($event)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"esc",27,$event.key,["Esc","Escape"])){ return null; }$event.stopPropagation();return _vm.onEsc($event)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"tab",9,$event.key,"Tab")){ return null; }return _vm.closeSuggestions($event)}]}})],1),_vm._v(" "),_c('ul',{directives:[{name:"show",rawName:"v-show",value:(_vm.showSuggestions && !_vm.userDismissedResults),expression:"showSuggestions && !userDismissedResults"}],staticClass:"dropdown-menu dropdown-full-width show-dropdown gl-list-style-none gl-pl-0 gl-mb-0 gl-display-flex gl-flex-direction-column",attrs:{"id":_vm.suggestionsId,"data-testid":"combobox-dropdown"}},[_c('li',{staticClass:"gl-overflow-y-auto show-dropdown"},[_c('ul',{staticClass:"gl-list-style-none gl-pl-0 gl-mb-0"},_vm._l((_vm.results),function(result,i){return _c('gl-dropdown-item',{key:i,ref:"results",refInFor:true,class:{ 'gl-bg-gray-50': i === _vm.arrowCounter },attrs:{"role":"option","aria-selected":i === _vm.arrowCounter,"tabindex":"-1"},on:{"click":function($event){return _vm.selectToken(result)}}},[_vm._t("result",[_vm._v(_vm._s(result))],{"item":result})],2)}),1)]),_vm._v(" "),(_vm.resultsLength > 0 && _vm.actionList.length > 0)?_c('gl-dropdown-divider'):_vm._e(),_vm._v(" "),_c('li',[_c('ul',{staticClass:"gl-list-style-none gl-pl-0 gl-mb-0"},_vm._l((_vm.actionList),function(action,i){return _c('gl-dropdown-item',{key:i + _vm.resultsLength,class:{ 'gl-bg-gray-50': i + _vm.resultsLength === _vm.arrowCounter },attrs:{"role":"option","aria-selected":i + _vm.resultsLength === _vm.arrowCounter,"tabindex":"-1","data-testid":"combobox-action"},on:{"click":function($event){return _vm.selectAction(action)}}},[_vm._t("action",[_vm._v(_vm._s(action.label))],{"item":action})],2)}),1)])],1)],1)};
|
|
180
237
|
var __vue_staticRenderFns__ = [];
|
|
181
238
|
|
|
182
239
|
/* style */
|