@gitlab/ui 42.15.0 → 42.18.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 +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/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/package.json +1 -1
- 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/src/scss/utilities.scss +6 -0
- package/src/scss/utility-mixins/spacing.scss +4 -0
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
$gl-drawer-width: 400px;
|
|
2
2
|
$gl-sidebar-width: 290px;
|
|
3
|
+
$gl-drawer-scrim-gradient: linear-gradient(to bottom, $transparent-rgba, $white);
|
|
3
4
|
|
|
4
5
|
.gl-drawer {
|
|
5
6
|
@include gl-right-0;
|
|
@@ -61,6 +62,20 @@ $gl-sidebar-width: 290px;
|
|
|
61
62
|
@include gl-py-5;
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
.gl-drawer-body-scrim-on-footer {
|
|
66
|
+
&::before {
|
|
67
|
+
background: $gl-drawer-scrim-gradient;
|
|
68
|
+
top: -$gl-border-size-1;
|
|
69
|
+
@include gl-translate-y-n100;
|
|
70
|
+
@include gl-content-empty;
|
|
71
|
+
@include gl-left-0;
|
|
72
|
+
@include gl-absolute;
|
|
73
|
+
@include gl-pointer-events-none;
|
|
74
|
+
@include gl-w-full;
|
|
75
|
+
@include gl-h-7;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
64
79
|
.gl-drawer-footer-sticky {
|
|
65
80
|
@include gl-bg-white;
|
|
66
81
|
@include gl-bottom-0;
|
|
@@ -94,6 +109,18 @@ $gl-sidebar-width: 290px;
|
|
|
94
109
|
@include gl-flex-grow-1;
|
|
95
110
|
}
|
|
96
111
|
|
|
112
|
+
.gl-drawer-body-scrim {
|
|
113
|
+
&::after {
|
|
114
|
+
background: $gl-drawer-scrim-gradient;
|
|
115
|
+
@include gl-content-empty;
|
|
116
|
+
@include gl-bottom-0;
|
|
117
|
+
@include gl-pointer-events-none;
|
|
118
|
+
@include gl-w-full;
|
|
119
|
+
@include gl-fixed;
|
|
120
|
+
@include gl-h-7;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
97
124
|
.gl-drawer-body > * {
|
|
98
125
|
@include gl-border-b-solid;
|
|
99
126
|
@include gl-border-b-gray-100;
|
|
@@ -101,6 +101,28 @@ describe('drawer component', () => {
|
|
|
101
101
|
expect(wrapper.find(parentSelector).find(`[data-testid="${slot}"]`).exists()).toBe(true);
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
+
it('should add scrim to footer', () => {
|
|
105
|
+
mountWithOpts({
|
|
106
|
+
slots: {
|
|
107
|
+
footer: `<div data-testid="footer" />`,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
expect(wrapper.find('.gl-drawer-footer').classes()).toContain('gl-drawer-body-scrim-on-footer');
|
|
112
|
+
expect(wrapper.find('.gl-drawer-body').classes()).not.toContain('gl-drawer-body-scrim');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should add scrim to scrollable container', () => {
|
|
116
|
+
mountWithOpts({
|
|
117
|
+
slots: {
|
|
118
|
+
default: `<div data-testid="default" />`,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
expect(wrapper.find('.gl-drawer-footer').exists()).toBe(false);
|
|
123
|
+
expect(wrapper.find('.gl-drawer-body').classes()).toContain('gl-drawer-body-scrim');
|
|
124
|
+
});
|
|
125
|
+
|
|
104
126
|
it.each`
|
|
105
127
|
variant | variantClass
|
|
106
128
|
${'default'} | ${'gl-drawer-default'}
|
|
@@ -1,8 +1,33 @@
|
|
|
1
|
-
import { GlDrawer, GlButton } from '../../../index';
|
|
1
|
+
import { GlDrawer, GlButton, GlMarkdown } from '../../../index';
|
|
2
2
|
import { drawerVariants } from '../../../utils/constants';
|
|
3
3
|
import readme from './drawer.md';
|
|
4
4
|
|
|
5
|
-
const components = { GlDrawer, GlButton };
|
|
5
|
+
const components = { GlDrawer, GlButton, GlMarkdown };
|
|
6
|
+
|
|
7
|
+
const generateStaticContent = (number = 1) =>
|
|
8
|
+
Array.from(
|
|
9
|
+
Array(number),
|
|
10
|
+
(_, index) => `
|
|
11
|
+
<div class="gl-mb-8">
|
|
12
|
+
<h4 class="gl-mb-4">View jobs in a pipeline ${index}</h4>
|
|
13
|
+
<p>
|
|
14
|
+
Pipeline configuration begins with jobs. Jobs are the most fundamental element of a .gitlab-ci.yml file.
|
|
15
|
+
</p>
|
|
16
|
+
<p>Jobs are:</p>
|
|
17
|
+
<ul>
|
|
18
|
+
<li>Defined with constraints stating under what conditions they should be executed. </li>
|
|
19
|
+
<li>Top-level elements with an arbitrary name and must contain at least the script clause.</li>
|
|
20
|
+
<li>Not limited in how many can be defined.</li>
|
|
21
|
+
</ul>
|
|
22
|
+
<p>For example:</p>
|
|
23
|
+
<gl-markdown compact>
|
|
24
|
+
<code>job1: script: "execute-script-for-job1"</code>
|
|
25
|
+
<br />
|
|
26
|
+
<code>job2: script: "execute-script-for-job2"</code>
|
|
27
|
+
</gl-markdown>
|
|
28
|
+
</div>
|
|
29
|
+
`
|
|
30
|
+
).join('');
|
|
6
31
|
|
|
7
32
|
const generateDrawerContent = (items) =>
|
|
8
33
|
items
|
|
@@ -145,6 +170,24 @@ export const WithStickyFooter = (_args, { viewMode }) => ({
|
|
|
145
170
|
|
|
146
171
|
WithStickyFooter.args = generateProps();
|
|
147
172
|
|
|
173
|
+
export const WithScrimAndStaticContent = (_args, { viewMode }) => ({
|
|
174
|
+
...storyOptions(viewMode),
|
|
175
|
+
template: `
|
|
176
|
+
<div>
|
|
177
|
+
<gl-button @click="toggle">Toggle Drawer</gl-button>
|
|
178
|
+
${createSidebarTemplate(`
|
|
179
|
+
<template #title>List Settings</template>
|
|
180
|
+
<div>
|
|
181
|
+
${generateStaticContent(3)}
|
|
182
|
+
</div>
|
|
183
|
+
`)}
|
|
184
|
+
</div>`,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
WithScrimAndStaticContent.args = generateProps({
|
|
188
|
+
headerSticky: true,
|
|
189
|
+
});
|
|
190
|
+
|
|
148
191
|
export const SidebarVariant = (_args, { viewMode }) => ({
|
|
149
192
|
...storyOptions(viewMode),
|
|
150
193
|
template: `
|
|
@@ -110,12 +110,13 @@ export default {
|
|
|
110
110
|
</span>
|
|
111
111
|
<slot name="header"></slot>
|
|
112
112
|
</div>
|
|
113
|
-
<div class="gl-drawer-body">
|
|
113
|
+
<div class="gl-drawer-body" :class="{ 'gl-drawer-body-scrim': !shouldRenderFooter }">
|
|
114
114
|
<slot></slot>
|
|
115
115
|
</div>
|
|
116
116
|
<div
|
|
117
117
|
v-if="shouldRenderFooter"
|
|
118
118
|
class="gl-drawer-footer gl-drawer-footer-sticky"
|
|
119
|
+
:class="{ 'gl-drawer-body-scrim-on-footer': shouldRenderFooter }"
|
|
119
120
|
:style="{ zIndex }"
|
|
120
121
|
>
|
|
121
122
|
<slot name="footer"></slot>
|
|
@@ -29,3 +29,22 @@ export const objectTokenList = [
|
|
|
29
29
|
{ id: '11', title: 'whale' },
|
|
30
30
|
{ id: '12', title: 'xenarthra' },
|
|
31
31
|
];
|
|
32
|
+
|
|
33
|
+
export const oneTokenList = ['dog'];
|
|
34
|
+
|
|
35
|
+
export const actionsList = [
|
|
36
|
+
{
|
|
37
|
+
label: 'Create',
|
|
38
|
+
fn: () => {
|
|
39
|
+
// eslint-disable-next-line no-alert
|
|
40
|
+
window.alert('Create action');
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: 'Edit',
|
|
45
|
+
fn: () => {
|
|
46
|
+
// eslint-disable-next-line no-alert
|
|
47
|
+
window.alert('Edit action');
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
];
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { mount } from '@vue/test-utils';
|
|
2
2
|
import GlDropdownItem from '../../dropdown/dropdown_item.vue';
|
|
3
3
|
import GlFormInput from '../form_input/form_input.vue';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
stringTokenList,
|
|
6
|
+
labelText,
|
|
7
|
+
objectTokenList,
|
|
8
|
+
oneTokenList,
|
|
9
|
+
actionsList,
|
|
10
|
+
} from './constants';
|
|
5
11
|
import GlFormCombobox from './form_combobox.vue';
|
|
6
12
|
|
|
7
13
|
const partialToken = 'do';
|
|
@@ -22,7 +28,11 @@ const doTimes = (num, fn) => {
|
|
|
22
28
|
describe('GlFormCombobox', () => {
|
|
23
29
|
let wrapper;
|
|
24
30
|
|
|
25
|
-
const createComponent = ({
|
|
31
|
+
const createComponent = ({
|
|
32
|
+
tokens = stringTokenList,
|
|
33
|
+
matchValueToAttr = undefined,
|
|
34
|
+
actionList = [],
|
|
35
|
+
} = {}) => {
|
|
26
36
|
wrapper = mount({
|
|
27
37
|
data() {
|
|
28
38
|
return {
|
|
@@ -30,6 +40,7 @@ describe('GlFormCombobox', () => {
|
|
|
30
40
|
tokens,
|
|
31
41
|
labelText,
|
|
32
42
|
matchValueToAttr,
|
|
43
|
+
actionList,
|
|
33
44
|
};
|
|
34
45
|
},
|
|
35
46
|
components: { GlFormCombobox },
|
|
@@ -40,6 +51,7 @@ describe('GlFormCombobox', () => {
|
|
|
40
51
|
:token-list="tokens"
|
|
41
52
|
:label-text="labelText"
|
|
42
53
|
:match-value-to-attr="matchValueToAttr"
|
|
54
|
+
:action-list="actionList"
|
|
43
55
|
/>
|
|
44
56
|
</div>
|
|
45
57
|
`,
|
|
@@ -54,6 +66,19 @@ describe('GlFormCombobox', () => {
|
|
|
54
66
|
const findInputValue = () => findInput().element.value;
|
|
55
67
|
const setInput = (val) => findInput().setValue(val);
|
|
56
68
|
const arrowDown = () => findInput().trigger('keydown.down');
|
|
69
|
+
const findFirstAction = () => wrapper.find('[data-testid="combobox-action"]');
|
|
70
|
+
|
|
71
|
+
beforeAll(() => {
|
|
72
|
+
if (!HTMLElement.prototype.scrollIntoView) {
|
|
73
|
+
HTMLElement.prototype.scrollIntoView = jest.fn();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
afterAll(() => {
|
|
78
|
+
if (HTMLElement.prototype.scrollIntoView.mock) {
|
|
79
|
+
delete HTMLElement.prototype.scrollIntoView;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
57
82
|
|
|
58
83
|
describe.each`
|
|
59
84
|
valueType | tokens | matchValueToAttr | partialTokenMatch
|
|
@@ -216,4 +241,47 @@ describe('GlFormCombobox', () => {
|
|
|
216
241
|
});
|
|
217
242
|
});
|
|
218
243
|
});
|
|
244
|
+
|
|
245
|
+
describe('with action items', () => {
|
|
246
|
+
let actionSpy;
|
|
247
|
+
const windowAlert = window.alert;
|
|
248
|
+
|
|
249
|
+
beforeEach(() => {
|
|
250
|
+
createComponent({ tokens: oneTokenList, actionList: actionsList });
|
|
251
|
+
actionSpy = jest.spyOn(wrapper.vm.actionList[0], 'fn');
|
|
252
|
+
window.alert = jest.fn();
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
afterEach(() => {
|
|
256
|
+
window.alert = windowAlert;
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('click on action item executes its function', async () => {
|
|
260
|
+
await setInput(partialToken);
|
|
261
|
+
expect(findDropdown().isVisible()).toBe(true);
|
|
262
|
+
|
|
263
|
+
await findFirstAction().trigger('click');
|
|
264
|
+
|
|
265
|
+
expect(actionSpy).toHaveBeenCalled();
|
|
266
|
+
expect(findDropdown().isVisible()).toBe(false);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it('keyboard navigation and executes function on enter', async () => {
|
|
270
|
+
await setInput('dog');
|
|
271
|
+
findInput().trigger('keydown.down');
|
|
272
|
+
findInput().trigger('keydown.down');
|
|
273
|
+
await findInput().trigger('keydown.enter');
|
|
274
|
+
|
|
275
|
+
expect(actionSpy).toHaveBeenCalled();
|
|
276
|
+
expect(findDropdown().isVisible()).toBe(false);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('displays only action items when no result match input value', async () => {
|
|
280
|
+
await setInput('doNotMatchAnything');
|
|
281
|
+
expect(findDropdown().isVisible()).toBe(true);
|
|
282
|
+
|
|
283
|
+
expect(findFirstAction().exists()).toBe(true);
|
|
284
|
+
expect(findDropdownOptions().length).toBe(2);
|
|
285
|
+
});
|
|
286
|
+
});
|
|
219
287
|
});
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { makeContainer } from '../../../../utils/story_decorators/container';
|
|
2
|
+
import { stringTokenList, labelText, objectTokenList, actionsList } from './constants';
|
|
2
3
|
import readme from './form_combobox.md';
|
|
3
4
|
import GlFormCombobox from './form_combobox.vue';
|
|
4
5
|
|
|
5
6
|
const template = `
|
|
6
7
|
<gl-form-combobox
|
|
7
8
|
v-model="value"
|
|
9
|
+
ref="combobox"
|
|
8
10
|
:token-list="tokenList"
|
|
9
11
|
:label-text="labelText"
|
|
10
12
|
:match-value-to-attr="matchValueToAttr"
|
|
13
|
+
:action-list="actionList"
|
|
11
14
|
/>`;
|
|
12
15
|
|
|
13
|
-
const generateProps = ({
|
|
16
|
+
const generateProps = ({
|
|
17
|
+
tokenList = stringTokenList,
|
|
18
|
+
matchValueToAttr,
|
|
19
|
+
actionList = undefined,
|
|
20
|
+
} = {}) => ({
|
|
14
21
|
tokenList,
|
|
15
22
|
labelText,
|
|
16
23
|
matchValueToAttr,
|
|
24
|
+
actionList,
|
|
17
25
|
});
|
|
18
26
|
|
|
19
27
|
const Template = (args) => ({
|
|
@@ -34,16 +42,17 @@ export const WithObjectValue = (args, { argTypes }) => ({
|
|
|
34
42
|
components: { GlFormCombobox },
|
|
35
43
|
props: Object.keys(argTypes),
|
|
36
44
|
mounted() {
|
|
37
|
-
|
|
45
|
+
this.$nextTick(() => this.$refs.combobox.openSuggestions(objectTokenList));
|
|
38
46
|
},
|
|
39
47
|
data: () => {
|
|
40
48
|
return {
|
|
41
|
-
value: '',
|
|
49
|
+
value: ' ',
|
|
42
50
|
};
|
|
43
51
|
},
|
|
44
52
|
template: `
|
|
45
53
|
<gl-form-combobox
|
|
46
54
|
v-model="value"
|
|
55
|
+
ref="combobox"
|
|
47
56
|
:token-list="tokenList"
|
|
48
57
|
:label-text="labelText"
|
|
49
58
|
:match-value-to-attr="matchValueToAttr"
|
|
@@ -58,6 +67,26 @@ export const WithObjectValue = (args, { argTypes }) => ({
|
|
|
58
67
|
`,
|
|
59
68
|
});
|
|
60
69
|
WithObjectValue.args = generateProps({ tokenList: objectTokenList, matchValueToAttr: 'title' });
|
|
70
|
+
WithObjectValue.decorators = [makeContainer({ height: '370px' })];
|
|
71
|
+
|
|
72
|
+
export const WithActions = (args, { argTypes }) => ({
|
|
73
|
+
components: { GlFormCombobox },
|
|
74
|
+
props: Object.keys(argTypes),
|
|
75
|
+
mounted() {
|
|
76
|
+
this.$nextTick(() => this.$refs.combobox.openSuggestions(['dog']));
|
|
77
|
+
},
|
|
78
|
+
data: () => {
|
|
79
|
+
return {
|
|
80
|
+
value: 'dog',
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
template,
|
|
84
|
+
});
|
|
85
|
+
WithActions.args = generateProps({
|
|
86
|
+
tokenList: stringTokenList,
|
|
87
|
+
actionList: actionsList,
|
|
88
|
+
});
|
|
89
|
+
WithActions.decorators = [makeContainer({ height: '180px' })];
|
|
61
90
|
|
|
62
91
|
export default {
|
|
63
92
|
title: 'base/form/form-combobox',
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { uniqueId } from 'lodash';
|
|
3
3
|
|
|
4
4
|
import GlDropdownItem from '../../dropdown/dropdown_item.vue';
|
|
5
|
+
import GlDropdownDivider from '../../dropdown/dropdown_divider.vue';
|
|
5
6
|
import GlFormGroup from '../form_group/form_group.vue';
|
|
6
7
|
import GlFormInput from '../form_input/form_input.vue';
|
|
7
8
|
|
|
@@ -9,6 +10,7 @@ export default {
|
|
|
9
10
|
name: 'GlFormCombobox',
|
|
10
11
|
components: {
|
|
11
12
|
GlDropdownItem,
|
|
13
|
+
GlDropdownDivider,
|
|
12
14
|
GlFormGroup,
|
|
13
15
|
GlFormInput,
|
|
14
16
|
},
|
|
@@ -30,6 +32,14 @@ export default {
|
|
|
30
32
|
type: Array,
|
|
31
33
|
required: true,
|
|
32
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
|
+
},
|
|
33
43
|
value: {
|
|
34
44
|
type: [String, Object],
|
|
35
45
|
required: true,
|
|
@@ -62,13 +72,37 @@ export default {
|
|
|
62
72
|
return this.showSuggestions ? 'off' : 'on';
|
|
63
73
|
},
|
|
64
74
|
showSuggestions() {
|
|
65
|
-
return this.
|
|
75
|
+
return this.value.length > 0 && this.allItems.length > 0;
|
|
66
76
|
},
|
|
67
77
|
displayedValue() {
|
|
68
78
|
return this.matchValueToAttr && this.value[this.matchValueToAttr]
|
|
69
79
|
? this.value[this.matchValueToAttr]
|
|
70
80
|
: this.value;
|
|
71
81
|
},
|
|
82
|
+
resultsLength() {
|
|
83
|
+
return this.results.length;
|
|
84
|
+
},
|
|
85
|
+
allItems() {
|
|
86
|
+
return [...this.results, ...this.actionList];
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
watch: {
|
|
90
|
+
tokenList(newList) {
|
|
91
|
+
const filteredTokens = newList.filter((token) => {
|
|
92
|
+
if (this.matchValueToAttr) {
|
|
93
|
+
// For API driven tokens, we don't need extra filtering
|
|
94
|
+
return token;
|
|
95
|
+
}
|
|
96
|
+
return token.toLowerCase().includes(this.value.toLowerCase());
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
if (filteredTokens.length) {
|
|
100
|
+
this.openSuggestions(filteredTokens);
|
|
101
|
+
} else {
|
|
102
|
+
this.results = [];
|
|
103
|
+
this.arrowCounter = -1;
|
|
104
|
+
}
|
|
105
|
+
},
|
|
72
106
|
},
|
|
73
107
|
mounted() {
|
|
74
108
|
document.addEventListener('click', this.handleClickOutside);
|
|
@@ -80,6 +114,7 @@ export default {
|
|
|
80
114
|
closeSuggestions() {
|
|
81
115
|
this.results = [];
|
|
82
116
|
this.arrowCounter = -1;
|
|
117
|
+
this.userDismissedResults = true;
|
|
83
118
|
},
|
|
84
119
|
handleClickOutside(event) {
|
|
85
120
|
if (!this.$el.contains(event.target)) {
|
|
@@ -89,33 +124,38 @@ export default {
|
|
|
89
124
|
onArrowDown() {
|
|
90
125
|
const newCount = this.arrowCounter + 1;
|
|
91
126
|
|
|
92
|
-
if (newCount >= this.
|
|
127
|
+
if (newCount >= this.allItems.length) {
|
|
93
128
|
this.arrowCounter = 0;
|
|
94
129
|
return;
|
|
95
130
|
}
|
|
96
131
|
|
|
97
132
|
this.arrowCounter = newCount;
|
|
133
|
+
this.$refs.results[newCount]?.$el.scrollIntoView(false);
|
|
98
134
|
},
|
|
99
135
|
onArrowUp() {
|
|
100
136
|
const newCount = this.arrowCounter - 1;
|
|
101
137
|
|
|
102
138
|
if (newCount < 0) {
|
|
103
|
-
this.arrowCounter = this.
|
|
139
|
+
this.arrowCounter = this.allItems.length - 1;
|
|
104
140
|
return;
|
|
105
141
|
}
|
|
106
142
|
|
|
107
143
|
this.arrowCounter = newCount;
|
|
144
|
+
this.$refs.results[newCount]?.$el.scrollIntoView(true);
|
|
108
145
|
},
|
|
109
146
|
onEnter() {
|
|
110
|
-
const
|
|
111
|
-
|
|
147
|
+
const focusedItem = this.allItems[this.arrowCounter] || this.value;
|
|
148
|
+
if (focusedItem.fn) {
|
|
149
|
+
this.selectAction(focusedItem);
|
|
150
|
+
} else {
|
|
151
|
+
this.selectToken(focusedItem);
|
|
152
|
+
}
|
|
112
153
|
},
|
|
113
154
|
onEsc() {
|
|
114
155
|
if (!this.showSuggestions) {
|
|
115
156
|
this.$emit('input', '');
|
|
116
157
|
}
|
|
117
158
|
this.closeSuggestions();
|
|
118
|
-
this.userDismissedResults = true;
|
|
119
159
|
},
|
|
120
160
|
onEntry(value) {
|
|
121
161
|
this.$emit('input', value);
|
|
@@ -137,7 +177,8 @@ export default {
|
|
|
137
177
|
if (filteredTokens.length) {
|
|
138
178
|
this.openSuggestions(filteredTokens);
|
|
139
179
|
} else {
|
|
140
|
-
this.
|
|
180
|
+
this.results = [];
|
|
181
|
+
this.arrowCounter = -1;
|
|
141
182
|
}
|
|
142
183
|
},
|
|
143
184
|
openSuggestions(filteredResults) {
|
|
@@ -152,6 +193,11 @@ export default {
|
|
|
152
193
|
*/
|
|
153
194
|
this.$emit('value-selected', value);
|
|
154
195
|
},
|
|
196
|
+
selectAction(value) {
|
|
197
|
+
value.fn();
|
|
198
|
+
this.$emit('input', this.value);
|
|
199
|
+
this.closeSuggestions();
|
|
200
|
+
},
|
|
155
201
|
},
|
|
156
202
|
};
|
|
157
203
|
</script>
|
|
@@ -186,20 +232,43 @@ export default {
|
|
|
186
232
|
v-show="showSuggestions && !userDismissedResults"
|
|
187
233
|
:id="suggestionsId"
|
|
188
234
|
data-testid="combobox-dropdown"
|
|
189
|
-
class="dropdown-menu dropdown-full-width gl-list-style-none gl-pl-0 gl-mb-0 gl-
|
|
190
|
-
:class="{ 'show-dropdown': showSuggestions }"
|
|
235
|
+
class="dropdown-menu dropdown-full-width show-dropdown gl-list-style-none gl-pl-0 gl-mb-0 gl-display-flex gl-flex-direction-column"
|
|
191
236
|
>
|
|
192
|
-
<gl-dropdown
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
237
|
+
<li class="gl-overflow-y-auto show-dropdown">
|
|
238
|
+
<ul class="gl-list-style-none gl-pl-0 gl-mb-0">
|
|
239
|
+
<gl-dropdown-item
|
|
240
|
+
v-for="(result, i) in results"
|
|
241
|
+
ref="results"
|
|
242
|
+
:key="i"
|
|
243
|
+
role="option"
|
|
244
|
+
:class="{ 'gl-bg-gray-50': i === arrowCounter }"
|
|
245
|
+
:aria-selected="i === arrowCounter"
|
|
246
|
+
tabindex="-1"
|
|
247
|
+
@click="selectToken(result)"
|
|
248
|
+
>
|
|
249
|
+
<!-- @slot The suggestion result item to display. -->
|
|
250
|
+
<slot name="result" :item="result">{{ result }}</slot>
|
|
251
|
+
</gl-dropdown-item>
|
|
252
|
+
</ul>
|
|
253
|
+
</li>
|
|
254
|
+
<gl-dropdown-divider v-if="resultsLength > 0 && actionList.length > 0" />
|
|
255
|
+
<li>
|
|
256
|
+
<ul class="gl-list-style-none gl-pl-0 gl-mb-0">
|
|
257
|
+
<gl-dropdown-item
|
|
258
|
+
v-for="(action, i) in actionList"
|
|
259
|
+
:key="i + resultsLength"
|
|
260
|
+
role="option"
|
|
261
|
+
:class="{ 'gl-bg-gray-50': i + resultsLength === arrowCounter }"
|
|
262
|
+
:aria-selected="i + resultsLength === arrowCounter"
|
|
263
|
+
tabindex="-1"
|
|
264
|
+
data-testid="combobox-action"
|
|
265
|
+
@click="selectAction(action)"
|
|
266
|
+
>
|
|
267
|
+
<!-- @slot The action item to display. -->
|
|
268
|
+
<slot name="action" :item="action">{{ action.label }}</slot>
|
|
269
|
+
</gl-dropdown-item>
|
|
270
|
+
</ul>
|
|
271
|
+
</li>
|
|
203
272
|
</ul>
|
|
204
273
|
</div>
|
|
205
274
|
</template>
|
package/src/scss/utilities.scss
CHANGED
|
@@ -6178,6 +6178,12 @@
|
|
|
6178
6178
|
.gl-gap-3\! {
|
|
6179
6179
|
gap: $gl-spacing-scale-3 !important;
|
|
6180
6180
|
}
|
|
6181
|
+
.gl-gap-5 {
|
|
6182
|
+
gap: $gl-spacing-scale-5;
|
|
6183
|
+
}
|
|
6184
|
+
.gl-gap-5\! {
|
|
6185
|
+
gap: $gl-spacing-scale-5 !important;
|
|
6186
|
+
}
|
|
6181
6187
|
.gl-gap-6 {
|
|
6182
6188
|
gap: $gl-spacing-scale-6;
|
|
6183
6189
|
}
|