@gitlab/ui 87.2.0 → 87.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 +14 -0
- package/dist/components/base/token_selector/token_selector.js +19 -16
- package/dist/components/base/token_selector/token_selector_dropdown.js +29 -5
- package/dist/index.css.map +1 -1
- package/dist/tokens/build/js/tokens.dark.js +1 -1
- package/dist/tokens/build/js/tokens.js +1 -1
- 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/json/tokens.dark.json +2 -2
- package/dist/tokens/json/tokens.json +2 -2
- package/dist/tokens/scss/_tokens.dark.scss +1 -1
- package/dist/tokens/scss/_tokens.scss +1 -1
- package/package.json +4 -4
- package/src/components/base/token_selector/token_selector.md +33 -0
- package/src/components/base/token_selector/token_selector.vue +21 -19
- package/src/components/base/token_selector/token_selector_dropdown.vue +74 -43
- package/src/tokens/action.tokens.json +1 -1
- package/src/tokens/build/css/tokens.css +1 -1
- package/src/tokens/build/css/tokens.dark.css +1 -1
- package/src/tokens/build/js/tokens.dark.js +1 -1
- package/src/tokens/build/js/tokens.js +1 -1
- package/src/tokens/build/json/tokens.dark.json +2 -2
- package/src/tokens/build/json/tokens.json +2 -2
- package/src/tokens/build/scss/_tokens.dark.scss +1 -1
- package/src/tokens/build/scss/_tokens.scss +1 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
const GL_ACTION_DISABLED_FOREGROUND_COLOR = '#737278'; // Used for the foreground of a disabled action.
|
|
7
7
|
const GL_ACTION_DISABLED_BACKGROUND_COLOR = '#28272d'; // Used for the background of a disabled action.
|
|
8
8
|
const GL_ACTION_DISABLED_BORDER_COLOR = '#3a383f'; // Used for the border of a disabled action.
|
|
9
|
-
const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT = '#ececef'; // Used for the foreground of
|
|
9
|
+
const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT = '#ececef'; // Used for the foreground of a neutral action in the default state.
|
|
10
10
|
const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_HOVER = '#ececef'; // Used for the foreground of a neutral action in the hover state.
|
|
11
11
|
const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_FOCUS = '#ececef'; // Used for the foreground of a neutral action in the focus state.
|
|
12
12
|
const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_ACTIVE = '#ececef'; // Used for the foreground of a neutral action in the active state.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
const GL_ACTION_DISABLED_FOREGROUND_COLOR = '#89888d'; // Used for the foreground of a disabled action.
|
|
7
7
|
const GL_ACTION_DISABLED_BACKGROUND_COLOR = '#ececef'; // Used for the background of a disabled action.
|
|
8
8
|
const GL_ACTION_DISABLED_BORDER_COLOR = '#dcdcde'; // Used for the border of a disabled action.
|
|
9
|
-
const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT = '#28272d'; // Used for the foreground of
|
|
9
|
+
const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT = '#28272d'; // Used for the foreground of a neutral action in the default state.
|
|
10
10
|
const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_HOVER = '#28272d'; // Used for the foreground of a neutral action in the hover state.
|
|
11
11
|
const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_FOCUS = '#28272d'; // Used for the foreground of a neutral action in the focus state.
|
|
12
12
|
const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_ACTIVE = '#28272d'; // Used for the foreground of a neutral action in the active state.
|
|
@@ -595,7 +595,7 @@
|
|
|
595
595
|
--gl-action-confirm-foreground-color-default: var(--gl-color-blue-500); /* Used for the foreground of a confirm (positive) action in the default state. */
|
|
596
596
|
--gl-action-neutral-border-color-default: var(--gl-color-alpha-0); /* Used for the border of a neutral action in the default state. */
|
|
597
597
|
--gl-action-neutral-background-color-focus: var(--gl-action-neutral-background-color-hover); /* Used for the background of a neutral action in the focus state. */
|
|
598
|
-
--gl-action-neutral-foreground-color-default: var(--gl-color-neutral-900); /* Used for the foreground of
|
|
598
|
+
--gl-action-neutral-foreground-color-default: var(--gl-color-neutral-900); /* Used for the foreground of a neutral action in the default state. */
|
|
599
599
|
--gl-action-disabled-border-color: var(--gl-color-neutral-100); /* Used for the border of a disabled action. */
|
|
600
600
|
--gl-action-disabled-background-color: var(--gl-color-neutral-50); /* Used for the background of a disabled action. */
|
|
601
601
|
--gl-action-disabled-foreground-color: var(--gl-color-neutral-400); /* Used for the foreground of a disabled action. */
|
|
@@ -595,7 +595,7 @@
|
|
|
595
595
|
--gl-action-confirm-foreground-color-default: var(--gl-color-blue-400); /* Used for the foreground of a confirm (positive) action in the default state. */
|
|
596
596
|
--gl-action-neutral-border-color-default: var(--gl-color-alpha-0); /* Used for the border of a neutral action in the default state. */
|
|
597
597
|
--gl-action-neutral-background-color-focus: var(--gl-action-neutral-background-color-hover); /* Used for the background of a neutral action in the focus state. */
|
|
598
|
-
--gl-action-neutral-foreground-color-default: var(--gl-color-neutral-50); /* Used for the foreground of
|
|
598
|
+
--gl-action-neutral-foreground-color-default: var(--gl-color-neutral-50); /* Used for the foreground of a neutral action in the default state. */
|
|
599
599
|
--gl-action-disabled-border-color: var(--gl-color-neutral-800); /* Used for the border of a disabled action. */
|
|
600
600
|
--gl-action-disabled-background-color: var(--gl-color-neutral-900); /* Used for the background of a disabled action. */
|
|
601
601
|
--gl-action-disabled-foreground-color: var(--gl-color-neutral-500); /* Used for the foreground of a disabled action. */
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export const GL_ACTION_DISABLED_FOREGROUND_COLOR = '#737278'; // Used for the foreground of a disabled action.
|
|
7
7
|
export const GL_ACTION_DISABLED_BACKGROUND_COLOR = '#28272d'; // Used for the background of a disabled action.
|
|
8
8
|
export const GL_ACTION_DISABLED_BORDER_COLOR = '#3a383f'; // Used for the border of a disabled action.
|
|
9
|
-
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT = '#ececef'; // Used for the foreground of
|
|
9
|
+
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT = '#ececef'; // Used for the foreground of a neutral action in the default state.
|
|
10
10
|
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_HOVER = '#ececef'; // Used for the foreground of a neutral action in the hover state.
|
|
11
11
|
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_FOCUS = '#ececef'; // Used for the foreground of a neutral action in the focus state.
|
|
12
12
|
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_ACTIVE = '#ececef'; // Used for the foreground of a neutral action in the active state.
|
package/dist/tokens/js/tokens.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export const GL_ACTION_DISABLED_FOREGROUND_COLOR = '#89888d'; // Used for the foreground of a disabled action.
|
|
7
7
|
export const GL_ACTION_DISABLED_BACKGROUND_COLOR = '#ececef'; // Used for the background of a disabled action.
|
|
8
8
|
export const GL_ACTION_DISABLED_BORDER_COLOR = '#dcdcde'; // Used for the border of a disabled action.
|
|
9
|
-
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT = '#28272d'; // Used for the foreground of
|
|
9
|
+
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT = '#28272d'; // Used for the foreground of a neutral action in the default state.
|
|
10
10
|
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_HOVER = '#28272d'; // Used for the foreground of a neutral action in the hover state.
|
|
11
11
|
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_FOCUS = '#28272d'; // Used for the foreground of a neutral action in the focus state.
|
|
12
12
|
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_ACTIVE = '#28272d'; // Used for the foreground of a neutral action in the active state.
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"default": {
|
|
84
84
|
"value": "#ececef",
|
|
85
85
|
"$type": "color",
|
|
86
|
-
"comment": "Used for the foreground of
|
|
86
|
+
"comment": "Used for the foreground of a neutral action in the default state.",
|
|
87
87
|
"filePath": "src/tokens/action.tokens.json",
|
|
88
88
|
"isSource": true,
|
|
89
89
|
"original": {
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"dark": "{color.neutral.50}"
|
|
93
93
|
},
|
|
94
94
|
"$type": "color",
|
|
95
|
-
"comment": "Used for the foreground of
|
|
95
|
+
"comment": "Used for the foreground of a neutral action in the default state."
|
|
96
96
|
},
|
|
97
97
|
"name": "ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT",
|
|
98
98
|
"attributes": {},
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"default": {
|
|
84
84
|
"value": "#28272d",
|
|
85
85
|
"$type": "color",
|
|
86
|
-
"comment": "Used for the foreground of
|
|
86
|
+
"comment": "Used for the foreground of a neutral action in the default state.",
|
|
87
87
|
"filePath": "src/tokens/action.tokens.json",
|
|
88
88
|
"isSource": true,
|
|
89
89
|
"original": {
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"dark": "{color.neutral.50}"
|
|
93
93
|
},
|
|
94
94
|
"$type": "color",
|
|
95
|
-
"comment": "Used for the foreground of
|
|
95
|
+
"comment": "Used for the foreground of a neutral action in the default state."
|
|
96
96
|
},
|
|
97
97
|
"name": "ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT",
|
|
98
98
|
"attributes": {},
|
|
@@ -593,7 +593,7 @@ $gl-action-confirm-foreground-color-hover: $gl-color-blue-200; // Used for the f
|
|
|
593
593
|
$gl-action-confirm-foreground-color-default: $gl-color-blue-400; // Used for the foreground of a confirm (positive) action in the default state.
|
|
594
594
|
$gl-action-neutral-border-color-default: $gl-color-alpha-0; // Used for the border of a neutral action in the default state.
|
|
595
595
|
$gl-action-neutral-background-color-focus: $gl-action-neutral-background-color-hover; // Used for the background of a neutral action in the focus state.
|
|
596
|
-
$gl-action-neutral-foreground-color-default: $gl-color-neutral-50; // Used for the foreground of
|
|
596
|
+
$gl-action-neutral-foreground-color-default: $gl-color-neutral-50; // Used for the foreground of a neutral action in the default state.
|
|
597
597
|
$gl-action-disabled-border-color: $gl-color-neutral-800; // Used for the border of a disabled action.
|
|
598
598
|
$gl-action-disabled-background-color: $gl-color-neutral-900; // Used for the background of a disabled action.
|
|
599
599
|
$gl-action-disabled-foreground-color: $gl-color-neutral-500; // Used for the foreground of a disabled action.
|
|
@@ -593,7 +593,7 @@ $gl-action-confirm-foreground-color-hover: $gl-color-blue-700; // Used for the f
|
|
|
593
593
|
$gl-action-confirm-foreground-color-default: $gl-color-blue-500; // Used for the foreground of a confirm (positive) action in the default state.
|
|
594
594
|
$gl-action-neutral-border-color-default: $gl-color-alpha-0; // Used for the border of a neutral action in the default state.
|
|
595
595
|
$gl-action-neutral-background-color-focus: $gl-action-neutral-background-color-hover; // Used for the background of a neutral action in the focus state.
|
|
596
|
-
$gl-action-neutral-foreground-color-default: $gl-color-neutral-900; // Used for the foreground of
|
|
596
|
+
$gl-action-neutral-foreground-color-default: $gl-color-neutral-900; // Used for the foreground of a neutral action in the default state.
|
|
597
597
|
$gl-action-disabled-border-color: $gl-color-neutral-100; // Used for the border of a disabled action.
|
|
598
598
|
$gl-action-disabled-background-color: $gl-color-neutral-50; // Used for the background of a disabled action.
|
|
599
599
|
$gl-action-disabled-foreground-color: $gl-color-neutral-400; // Used for the foreground of a disabled action.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "87.
|
|
3
|
+
"version": "87.3.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -108,13 +108,13 @@
|
|
|
108
108
|
"@babel/core": "^7.24.9",
|
|
109
109
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
|
110
110
|
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
|
|
111
|
-
"@babel/preset-env": "^7.
|
|
111
|
+
"@babel/preset-env": "^7.25.0",
|
|
112
112
|
"@babel/preset-react": "^7.24.7",
|
|
113
113
|
"@cypress/grep": "^4.0.1",
|
|
114
114
|
"@gitlab/eslint-plugin": "19.6.0",
|
|
115
115
|
"@gitlab/fonts": "^1.3.0",
|
|
116
116
|
"@gitlab/stylelint-config": "6.1.0",
|
|
117
|
-
"@gitlab/svgs": "3.
|
|
117
|
+
"@gitlab/svgs": "3.110.0",
|
|
118
118
|
"@jest/test-sequencer": "^29.7.0",
|
|
119
119
|
"@rollup/plugin-commonjs": "^11.1.0",
|
|
120
120
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"esbuild": "^0.18.0",
|
|
157
157
|
"eslint": "8.57.0",
|
|
158
158
|
"eslint-import-resolver-jest": "3.0.2",
|
|
159
|
-
"eslint-plugin-cypress": "3.
|
|
159
|
+
"eslint-plugin-cypress": "3.4.0",
|
|
160
160
|
"eslint-plugin-storybook": "0.8.0",
|
|
161
161
|
"gitlab-api-async-iterator": "^1.3.1",
|
|
162
162
|
"glob": "10.3.3",
|
|
@@ -43,3 +43,36 @@ export default {
|
|
|
43
43
|
</div>
|
|
44
44
|
</template>
|
|
45
45
|
```
|
|
46
|
+
|
|
47
|
+
## User created tokens
|
|
48
|
+
|
|
49
|
+
This component allows for users to create their own tokens when configured to do so.
|
|
50
|
+
There are two props that support this functionality: `allowUserDefinedTokens` and `showAddNewAlways`.
|
|
51
|
+
|
|
52
|
+
`allowUserDefinedTokens` is required to enable the functionality
|
|
53
|
+
|
|
54
|
+
When set to `true` and a user's search text returns nothing,
|
|
55
|
+
they will be presented with an additional dropdown item `Add ...`
|
|
56
|
+
that takes their current search input and emits `@input`.
|
|
57
|
+
The parent component can then handle the event accordingly.
|
|
58
|
+
|
|
59
|
+
Additionally, there are scenarios where the user may want the ability to add a new token
|
|
60
|
+
even if some search results are returned. This functionality can be enabled by additionally
|
|
61
|
+
setting `showAddNewAlways` to `true`.
|
|
62
|
+
This will allow for the `Add ...` dropdown item to appear at all times
|
|
63
|
+
whenever a user has inputted text, regardless if results are found.
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<template>
|
|
67
|
+
<div>
|
|
68
|
+
<gl-token-selector
|
|
69
|
+
v-model="selectedTokens"
|
|
70
|
+
:dropdown-items="dropdownItems"
|
|
71
|
+
allow-user-defined-items
|
|
72
|
+
show-ad-new-always
|
|
73
|
+
@input="onTokenUpdate"
|
|
74
|
+
/>
|
|
75
|
+
{{ selectedTokens }}
|
|
76
|
+
</div>
|
|
77
|
+
</template>
|
|
78
|
+
```
|
|
@@ -34,6 +34,14 @@ export default {
|
|
|
34
34
|
required: false,
|
|
35
35
|
default: false,
|
|
36
36
|
},
|
|
37
|
+
/**
|
|
38
|
+
* Shows 'Add new token option' in dropdown even if results are present, requires allowUserDefinedTokens to be true
|
|
39
|
+
*/
|
|
40
|
+
showAddNewAlways: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
required: false,
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
37
45
|
/**
|
|
38
46
|
* Dropdown items are loading, can be used when requesting new dropdown items
|
|
39
47
|
*/
|
|
@@ -161,7 +169,11 @@ export default {
|
|
|
161
169
|
return !this.filteredDropdownItems.length;
|
|
162
170
|
},
|
|
163
171
|
userDefinedTokenCanBeAdded() {
|
|
164
|
-
|
|
172
|
+
if (!this.allowUserDefinedTokens || !this.inputText) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return this.showAddNewAlways || this.dropdownHasNoItems;
|
|
165
177
|
},
|
|
166
178
|
hideDropdown() {
|
|
167
179
|
if (this.userDefinedTokenCanBeAdded) {
|
|
@@ -262,9 +274,7 @@ export default {
|
|
|
262
274
|
});
|
|
263
275
|
},
|
|
264
276
|
handleEnter() {
|
|
265
|
-
if (this.
|
|
266
|
-
this.addToken();
|
|
267
|
-
} else if (this.focusedDropdownItem && this.dropdownIsOpen) {
|
|
277
|
+
if (this.focusedDropdownItem && this.dropdownIsOpen) {
|
|
268
278
|
this.addToken(this.focusedDropdownItem);
|
|
269
279
|
}
|
|
270
280
|
},
|
|
@@ -302,21 +312,13 @@ export default {
|
|
|
302
312
|
|
|
303
313
|
this.focusTextInput();
|
|
304
314
|
},
|
|
305
|
-
addToken(dropdownItem
|
|
306
|
-
const token =
|
|
307
|
-
dropdownItem !== null
|
|
308
|
-
? dropdownItem
|
|
309
|
-
: {
|
|
310
|
-
id: uniqueId('user-defined-token'),
|
|
311
|
-
name: this.inputText,
|
|
312
|
-
};
|
|
313
|
-
|
|
315
|
+
addToken(dropdownItem) {
|
|
314
316
|
/**
|
|
315
317
|
* Fired when a token is added or removed
|
|
316
318
|
*
|
|
317
319
|
* @property {array} selectedTokens
|
|
318
320
|
*/
|
|
319
|
-
this.$emit('input', [...this.selectedTokens,
|
|
321
|
+
this.$emit('input', [...this.selectedTokens, dropdownItem]);
|
|
320
322
|
|
|
321
323
|
this.inputText = '';
|
|
322
324
|
this.closeDropdown();
|
|
@@ -326,13 +328,13 @@ export default {
|
|
|
326
328
|
*
|
|
327
329
|
* @property {object} token
|
|
328
330
|
*/
|
|
329
|
-
this.$emit('token-add',
|
|
331
|
+
this.$emit('token-add', dropdownItem);
|
|
330
332
|
},
|
|
331
333
|
removeToken(token) {
|
|
332
334
|
/**
|
|
333
|
-
* Fired when
|
|
335
|
+
* Fired when a token is added or removed
|
|
334
336
|
*
|
|
335
|
-
* @property {
|
|
337
|
+
* @property {array} selectedTokens
|
|
336
338
|
*/
|
|
337
339
|
this.$emit(
|
|
338
340
|
'input',
|
|
@@ -446,7 +448,7 @@ export default {
|
|
|
446
448
|
:dropdown-items="filteredDropdownItems"
|
|
447
449
|
:selected-tokens="selectedTokens"
|
|
448
450
|
:input-text="inputText"
|
|
449
|
-
:
|
|
451
|
+
:user-defined-token-can-be-added="userDefinedTokenCanBeAdded"
|
|
450
452
|
:component-id="$options.componentId"
|
|
451
453
|
:register-dropdown-event-handlers="registerDropdownEventHandlers"
|
|
452
454
|
:register-reset-focused-dropdown-item="registerResetFocusedDropdownItem"
|
|
@@ -466,7 +468,7 @@ export default {
|
|
|
466
468
|
</template>
|
|
467
469
|
<template #no-results-content>
|
|
468
470
|
<!-- @slot Content to display when `dropdown-items` is empty and
|
|
469
|
-
`allow-user-defined-tokens` is `false`. Default content is "No matches found". -->
|
|
471
|
+
both `allow-user-defined-tokens` and `show-add-new-always` is `false`. Default content is "No matches found". -->
|
|
470
472
|
<slot name="no-results-content"></slot>
|
|
471
473
|
</template>
|
|
472
474
|
<template #dropdown-item-content="{ dropdownItem }">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
import uniqueId from 'lodash/uniqueId';
|
|
2
3
|
import GlDropdownItem from '../dropdown/dropdown_item.vue';
|
|
3
4
|
import { tokensValidator } from './helpers';
|
|
4
5
|
|
|
@@ -30,7 +31,7 @@ export default {
|
|
|
30
31
|
type: String,
|
|
31
32
|
required: true,
|
|
32
33
|
},
|
|
33
|
-
|
|
34
|
+
userDefinedTokenCanBeAdded: {
|
|
34
35
|
type: Boolean,
|
|
35
36
|
required: true,
|
|
36
37
|
},
|
|
@@ -53,7 +54,30 @@ export default {
|
|
|
53
54
|
};
|
|
54
55
|
},
|
|
55
56
|
computed: {
|
|
57
|
+
userDefinedToken() {
|
|
58
|
+
return {
|
|
59
|
+
id: uniqueId('user-defined-token'),
|
|
60
|
+
name: this.inputText,
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
dropdownLength() {
|
|
64
|
+
// Adds an additional dropdown item for the 'Add ... dropdown' item
|
|
65
|
+
return this.userDefinedTokenCanBeAdded
|
|
66
|
+
? this.dropdownItems.length
|
|
67
|
+
: this.dropdownItems.length - 1;
|
|
68
|
+
},
|
|
69
|
+
focusedLastDropdownItem() {
|
|
70
|
+
return this.focusedDropdownItemIndex === this.dropdownLength;
|
|
71
|
+
},
|
|
72
|
+
focusedUserDefinedToken() {
|
|
73
|
+
// User defined tokens are always the last in the list
|
|
74
|
+
return this.userDefinedTokenCanBeAdded && this.focusedLastDropdownItem;
|
|
75
|
+
},
|
|
56
76
|
focusedDropdownItem() {
|
|
77
|
+
if (this.focusedUserDefinedToken) {
|
|
78
|
+
return this.userDefinedToken;
|
|
79
|
+
}
|
|
80
|
+
|
|
57
81
|
return this.dropdownItems[this.focusedDropdownItemIndex];
|
|
58
82
|
},
|
|
59
83
|
},
|
|
@@ -92,10 +116,7 @@ export default {
|
|
|
92
116
|
handleMousedown(dropdownItem) {
|
|
93
117
|
// `event.relatedTarget` returns `null` on Safari because buttons are not focused on click (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus)
|
|
94
118
|
// Because of this we need to manually focus on the button. We do this in `mousedown` because it is fired before the `blur` event
|
|
95
|
-
const dropdownItemRef =
|
|
96
|
-
dropdownItem === null
|
|
97
|
-
? this.$refs.userDefinedTokenDropdownItem
|
|
98
|
-
: this.getDropdownItemRef(dropdownItem);
|
|
119
|
+
const dropdownItemRef = this.getDropdownItemRef(dropdownItem);
|
|
99
120
|
|
|
100
121
|
if (dropdownItemRef?.$el) {
|
|
101
122
|
dropdownItemRef.$el.querySelector('button').focus();
|
|
@@ -121,7 +142,7 @@ export default {
|
|
|
121
142
|
}
|
|
122
143
|
|
|
123
144
|
// Last dropdown item has been reached
|
|
124
|
-
if (this.
|
|
145
|
+
if (this.focusedLastDropdownItem) {
|
|
125
146
|
return;
|
|
126
147
|
}
|
|
127
148
|
|
|
@@ -138,7 +159,7 @@ export default {
|
|
|
138
159
|
this.focusLastDropdownItem();
|
|
139
160
|
},
|
|
140
161
|
focusLastDropdownItem() {
|
|
141
|
-
this.focusedDropdownItemIndex = this.
|
|
162
|
+
this.focusedDropdownItemIndex = this.dropdownLength;
|
|
142
163
|
},
|
|
143
164
|
focusFirstDropdownItem() {
|
|
144
165
|
this.focusedDropdownItemIndex = 0;
|
|
@@ -160,6 +181,10 @@ export default {
|
|
|
160
181
|
return dropdownItem.id === this.focusedDropdownItem.id;
|
|
161
182
|
},
|
|
162
183
|
getDropdownItemRef(dropdownItem) {
|
|
184
|
+
if (this.focusedUserDefinedToken) {
|
|
185
|
+
return this.$refs[this.userDefinedToken.id];
|
|
186
|
+
}
|
|
187
|
+
|
|
163
188
|
return this.$refs.dropdownItems?.find(
|
|
164
189
|
(ref) => ref.$attrs['data-dropdown-item-id'] === dropdownItem.id
|
|
165
190
|
);
|
|
@@ -183,43 +208,49 @@ export default {
|
|
|
183
208
|
<gl-dropdown-item v-if="loading" disabled>
|
|
184
209
|
<slot name="loading-content">Searching...</slot>
|
|
185
210
|
</gl-dropdown-item>
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
<
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
|
|
212
|
+
<gl-dropdown-item
|
|
213
|
+
v-for="dropdownItem in dropdownItems"
|
|
214
|
+
:id="dropdownItemIdAttribute(dropdownItem)"
|
|
215
|
+
ref="dropdownItems"
|
|
216
|
+
:key="dropdownItem.id"
|
|
217
|
+
:data-dropdown-item-id="dropdownItem.id"
|
|
218
|
+
:active="dropdownItemIsFocused(dropdownItem)"
|
|
219
|
+
active-class="is-focused"
|
|
220
|
+
tabindex="-1"
|
|
221
|
+
@click="handleDropdownItemClick(dropdownItem)"
|
|
222
|
+
>
|
|
223
|
+
<div class="-gl-mx-4 -gl-my-3 gl-px-4 gl-py-3" @mousedown="handleMousedown(dropdownItem)">
|
|
224
|
+
<slot name="dropdown-item-content" :dropdown-item="dropdownItem">
|
|
225
|
+
{{ dropdownItem.name }}
|
|
226
|
+
</slot>
|
|
227
|
+
</div>
|
|
228
|
+
</gl-dropdown-item>
|
|
229
|
+
|
|
230
|
+
<gl-dropdown-item
|
|
231
|
+
v-if="userDefinedTokenCanBeAdded"
|
|
232
|
+
:id="dropdownItemIdAttribute(userDefinedToken)"
|
|
233
|
+
:ref="userDefinedToken.id"
|
|
234
|
+
:data-dropdown-item-id="userDefinedToken.id"
|
|
235
|
+
:active="dropdownItemIsFocused(userDefinedToken)"
|
|
236
|
+
active-class="is-focused"
|
|
237
|
+
tabindex="-1"
|
|
238
|
+
@click="handleDropdownItemClick(userDefinedToken)"
|
|
239
|
+
>
|
|
240
|
+
<div
|
|
241
|
+
class="-gl-mx-4 -gl-my-3 gl-px-4 gl-py-3"
|
|
242
|
+
@mousedown="handleMousedown(userDefinedToken)"
|
|
212
243
|
>
|
|
213
|
-
<
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
244
|
+
<slot name="user-defined-token-content" :input-text="inputText">
|
|
245
|
+
Add "{{ inputText }}"
|
|
246
|
+
</slot>
|
|
247
|
+
</div>
|
|
248
|
+
</gl-dropdown-item>
|
|
249
|
+
|
|
250
|
+
<gl-dropdown-item v-else-if="!dropdownItems.length" disabled>
|
|
251
|
+
<slot name="no-results-content">No matches found</slot>
|
|
252
|
+
</gl-dropdown-item>
|
|
253
|
+
|
|
223
254
|
<slot name="dropdown-footer"></slot>
|
|
224
255
|
</ul>
|
|
225
256
|
</div>
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dark": "{color.neutral.50}"
|
|
42
42
|
},
|
|
43
43
|
"$type": "color",
|
|
44
|
-
"$description": "Used for the foreground of
|
|
44
|
+
"$description": "Used for the foreground of a neutral action in the default state."
|
|
45
45
|
},
|
|
46
46
|
"hover": {
|
|
47
47
|
"$value": "{action.neutral.foreground.color.default}",
|
|
@@ -595,7 +595,7 @@
|
|
|
595
595
|
--gl-action-confirm-foreground-color-default: var(--gl-color-blue-500); /* Used for the foreground of a confirm (positive) action in the default state. */
|
|
596
596
|
--gl-action-neutral-border-color-default: var(--gl-color-alpha-0); /* Used for the border of a neutral action in the default state. */
|
|
597
597
|
--gl-action-neutral-background-color-focus: var(--gl-action-neutral-background-color-hover); /* Used for the background of a neutral action in the focus state. */
|
|
598
|
-
--gl-action-neutral-foreground-color-default: var(--gl-color-neutral-900); /* Used for the foreground of
|
|
598
|
+
--gl-action-neutral-foreground-color-default: var(--gl-color-neutral-900); /* Used for the foreground of a neutral action in the default state. */
|
|
599
599
|
--gl-action-disabled-border-color: var(--gl-color-neutral-100); /* Used for the border of a disabled action. */
|
|
600
600
|
--gl-action-disabled-background-color: var(--gl-color-neutral-50); /* Used for the background of a disabled action. */
|
|
601
601
|
--gl-action-disabled-foreground-color: var(--gl-color-neutral-400); /* Used for the foreground of a disabled action. */
|
|
@@ -595,7 +595,7 @@
|
|
|
595
595
|
--gl-action-confirm-foreground-color-default: var(--gl-color-blue-400); /* Used for the foreground of a confirm (positive) action in the default state. */
|
|
596
596
|
--gl-action-neutral-border-color-default: var(--gl-color-alpha-0); /* Used for the border of a neutral action in the default state. */
|
|
597
597
|
--gl-action-neutral-background-color-focus: var(--gl-action-neutral-background-color-hover); /* Used for the background of a neutral action in the focus state. */
|
|
598
|
-
--gl-action-neutral-foreground-color-default: var(--gl-color-neutral-50); /* Used for the foreground of
|
|
598
|
+
--gl-action-neutral-foreground-color-default: var(--gl-color-neutral-50); /* Used for the foreground of a neutral action in the default state. */
|
|
599
599
|
--gl-action-disabled-border-color: var(--gl-color-neutral-800); /* Used for the border of a disabled action. */
|
|
600
600
|
--gl-action-disabled-background-color: var(--gl-color-neutral-900); /* Used for the background of a disabled action. */
|
|
601
601
|
--gl-action-disabled-foreground-color: var(--gl-color-neutral-500); /* Used for the foreground of a disabled action. */
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export const GL_ACTION_DISABLED_FOREGROUND_COLOR = '#737278'; // Used for the foreground of a disabled action.
|
|
7
7
|
export const GL_ACTION_DISABLED_BACKGROUND_COLOR = '#28272d'; // Used for the background of a disabled action.
|
|
8
8
|
export const GL_ACTION_DISABLED_BORDER_COLOR = '#3a383f'; // Used for the border of a disabled action.
|
|
9
|
-
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT = '#ececef'; // Used for the foreground of
|
|
9
|
+
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT = '#ececef'; // Used for the foreground of a neutral action in the default state.
|
|
10
10
|
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_HOVER = '#ececef'; // Used for the foreground of a neutral action in the hover state.
|
|
11
11
|
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_FOCUS = '#ececef'; // Used for the foreground of a neutral action in the focus state.
|
|
12
12
|
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_ACTIVE = '#ececef'; // Used for the foreground of a neutral action in the active state.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export const GL_ACTION_DISABLED_FOREGROUND_COLOR = '#89888d'; // Used for the foreground of a disabled action.
|
|
7
7
|
export const GL_ACTION_DISABLED_BACKGROUND_COLOR = '#ececef'; // Used for the background of a disabled action.
|
|
8
8
|
export const GL_ACTION_DISABLED_BORDER_COLOR = '#dcdcde'; // Used for the border of a disabled action.
|
|
9
|
-
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT = '#28272d'; // Used for the foreground of
|
|
9
|
+
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT = '#28272d'; // Used for the foreground of a neutral action in the default state.
|
|
10
10
|
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_HOVER = '#28272d'; // Used for the foreground of a neutral action in the hover state.
|
|
11
11
|
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_FOCUS = '#28272d'; // Used for the foreground of a neutral action in the focus state.
|
|
12
12
|
export const GL_ACTION_NEUTRAL_FOREGROUND_COLOR_ACTIVE = '#28272d'; // Used for the foreground of a neutral action in the active state.
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"default": {
|
|
84
84
|
"value": "#ececef",
|
|
85
85
|
"$type": "color",
|
|
86
|
-
"comment": "Used for the foreground of
|
|
86
|
+
"comment": "Used for the foreground of a neutral action in the default state.",
|
|
87
87
|
"filePath": "src/tokens/action.tokens.json",
|
|
88
88
|
"isSource": true,
|
|
89
89
|
"original": {
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"dark": "{color.neutral.50}"
|
|
93
93
|
},
|
|
94
94
|
"$type": "color",
|
|
95
|
-
"comment": "Used for the foreground of
|
|
95
|
+
"comment": "Used for the foreground of a neutral action in the default state."
|
|
96
96
|
},
|
|
97
97
|
"name": "ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT",
|
|
98
98
|
"attributes": {},
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"default": {
|
|
84
84
|
"value": "#28272d",
|
|
85
85
|
"$type": "color",
|
|
86
|
-
"comment": "Used for the foreground of
|
|
86
|
+
"comment": "Used for the foreground of a neutral action in the default state.",
|
|
87
87
|
"filePath": "src/tokens/action.tokens.json",
|
|
88
88
|
"isSource": true,
|
|
89
89
|
"original": {
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"dark": "{color.neutral.50}"
|
|
93
93
|
},
|
|
94
94
|
"$type": "color",
|
|
95
|
-
"comment": "Used for the foreground of
|
|
95
|
+
"comment": "Used for the foreground of a neutral action in the default state."
|
|
96
96
|
},
|
|
97
97
|
"name": "ACTION_NEUTRAL_FOREGROUND_COLOR_DEFAULT",
|
|
98
98
|
"attributes": {},
|
|
@@ -593,7 +593,7 @@ $gl-action-confirm-foreground-color-hover: $gl-color-blue-200; // Used for the f
|
|
|
593
593
|
$gl-action-confirm-foreground-color-default: $gl-color-blue-400; // Used for the foreground of a confirm (positive) action in the default state.
|
|
594
594
|
$gl-action-neutral-border-color-default: $gl-color-alpha-0; // Used for the border of a neutral action in the default state.
|
|
595
595
|
$gl-action-neutral-background-color-focus: $gl-action-neutral-background-color-hover; // Used for the background of a neutral action in the focus state.
|
|
596
|
-
$gl-action-neutral-foreground-color-default: $gl-color-neutral-50; // Used for the foreground of
|
|
596
|
+
$gl-action-neutral-foreground-color-default: $gl-color-neutral-50; // Used for the foreground of a neutral action in the default state.
|
|
597
597
|
$gl-action-disabled-border-color: $gl-color-neutral-800; // Used for the border of a disabled action.
|
|
598
598
|
$gl-action-disabled-background-color: $gl-color-neutral-900; // Used for the background of a disabled action.
|
|
599
599
|
$gl-action-disabled-foreground-color: $gl-color-neutral-500; // Used for the foreground of a disabled action.
|
|
@@ -593,7 +593,7 @@ $gl-action-confirm-foreground-color-hover: $gl-color-blue-700; // Used for the f
|
|
|
593
593
|
$gl-action-confirm-foreground-color-default: $gl-color-blue-500; // Used for the foreground of a confirm (positive) action in the default state.
|
|
594
594
|
$gl-action-neutral-border-color-default: $gl-color-alpha-0; // Used for the border of a neutral action in the default state.
|
|
595
595
|
$gl-action-neutral-background-color-focus: $gl-action-neutral-background-color-hover; // Used for the background of a neutral action in the focus state.
|
|
596
|
-
$gl-action-neutral-foreground-color-default: $gl-color-neutral-900; // Used for the foreground of
|
|
596
|
+
$gl-action-neutral-foreground-color-default: $gl-color-neutral-900; // Used for the foreground of a neutral action in the default state.
|
|
597
597
|
$gl-action-disabled-border-color: $gl-color-neutral-100; // Used for the border of a disabled action.
|
|
598
598
|
$gl-action-disabled-background-color: $gl-color-neutral-50; // Used for the background of a disabled action.
|
|
599
599
|
$gl-action-disabled-foreground-color: $gl-color-neutral-400; // Used for the foreground of a disabled action.
|