@gitlab/ui 122.9.0 → 122.11.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/dist/components/base/banner/banner.js +12 -2
- package/dist/components/base/token_selector/token_container.js +1 -6
- package/dist/components/base/token_selector/token_selector.js +28 -5
- package/dist/components/base/token_selector/token_selector_dropdown.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/utils/unique_id.js +18 -0
- package/package.json +5 -5
- package/src/components/base/banner/banner.vue +13 -2
- package/src/components/base/modal/modal.scss +2 -0
- package/src/components/base/token_selector/token_container.vue +1 -11
- package/src/components/base/token_selector/token_selector.vue +33 -4
- package/src/components/base/token_selector/token_selector_dropdown.vue +4 -2
- package/src/utils/unique_id.js +17 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function uses browser native crypto to return a sixteen
|
|
3
|
+
* character base16 encoded string. It is often used to
|
|
4
|
+
* generate collision-resistant IDs for aria markup such
|
|
5
|
+
* as aria-activedescendant and aria-controls.
|
|
6
|
+
*
|
|
7
|
+
* @returns String
|
|
8
|
+
*/
|
|
9
|
+
const GlUniqueId = () => {
|
|
10
|
+
if (typeof window !== 'undefined' && window.crypto) {
|
|
11
|
+
const arr32 = new Uint32Array(2);
|
|
12
|
+
window.crypto.getRandomValues(arr32);
|
|
13
|
+
return Array.from(arr32, id => id.toString(16)).join('');
|
|
14
|
+
}
|
|
15
|
+
throw new Error('Cannot generate a unique ID');
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { GlUniqueId };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "122.
|
|
3
|
+
"version": "122.11.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"@babel/preset-react": "^7.27.1",
|
|
104
104
|
"@cypress/grep": "^4.1.1",
|
|
105
105
|
"@gitlab/fonts": "^1.3.1",
|
|
106
|
-
"@gitlab/svgs": "3.
|
|
106
|
+
"@gitlab/svgs": "3.147.0",
|
|
107
107
|
"@jest/test-sequencer": "30.1.3",
|
|
108
108
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
109
109
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"cypress-real-events": "^1.15.0",
|
|
140
140
|
"dompurify": "^3.1.2",
|
|
141
141
|
"emoji-regex": "^10.5.0",
|
|
142
|
-
"esbuild": "^0.25.
|
|
142
|
+
"esbuild": "^0.25.10",
|
|
143
143
|
"gitlab-api-async-iterator": "^1.3.1",
|
|
144
144
|
"glob": "11.0.3",
|
|
145
145
|
"globby": "^14.1.0",
|
|
@@ -165,10 +165,10 @@
|
|
|
165
165
|
"rollup-plugin-string": "^3.0.0",
|
|
166
166
|
"rollup-plugin-svg": "^2.0.0",
|
|
167
167
|
"rollup-plugin-vue": "^5.1.9",
|
|
168
|
-
"sass": "^1.
|
|
168
|
+
"sass": "^1.93.0",
|
|
169
169
|
"sass-loader": "^10.5.2",
|
|
170
170
|
"sass-true": "^9",
|
|
171
|
-
"start-server-and-test": "^2.1.
|
|
171
|
+
"start-server-and-test": "^2.1.2",
|
|
172
172
|
"storybook": "^7.6.20",
|
|
173
173
|
"storybook-dark-mode": "4.0.2",
|
|
174
174
|
"style-dictionary": "^5.0.4",
|
|
@@ -4,6 +4,7 @@ import { translate } from '../../../utils/i18n';
|
|
|
4
4
|
import CloseButton from '../../shared_components/close_button/close_button.vue';
|
|
5
5
|
import GlButton from '../button/button.vue';
|
|
6
6
|
import GlCard from '../card/card.vue';
|
|
7
|
+
import GlIllustration from '../illustration/illustration.vue';
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
10
|
name: 'GlBanner',
|
|
@@ -11,6 +12,7 @@ export default {
|
|
|
11
12
|
CloseButton,
|
|
12
13
|
GlButton,
|
|
13
14
|
GlCard,
|
|
15
|
+
GlIllustration,
|
|
14
16
|
},
|
|
15
17
|
props: {
|
|
16
18
|
/**
|
|
@@ -43,6 +45,14 @@ export default {
|
|
|
43
45
|
required: false,
|
|
44
46
|
default: null,
|
|
45
47
|
},
|
|
48
|
+
/**
|
|
49
|
+
* The illustration's name.
|
|
50
|
+
*/
|
|
51
|
+
illustrationName: {
|
|
52
|
+
type: String,
|
|
53
|
+
required: false,
|
|
54
|
+
default: null,
|
|
55
|
+
},
|
|
46
56
|
/**
|
|
47
57
|
* The illustration's URL.
|
|
48
58
|
*/
|
|
@@ -107,8 +117,9 @@ export default {
|
|
|
107
117
|
}"
|
|
108
118
|
body-class="gl-flex !gl-p-0"
|
|
109
119
|
>
|
|
110
|
-
<div v-if="svgPath" class="gl-banner-illustration">
|
|
111
|
-
<
|
|
120
|
+
<div v-if="svgPath || illustrationName" class="gl-banner-illustration">
|
|
121
|
+
<gl-illustration v-if="illustrationName" :name="illustrationName" />
|
|
122
|
+
<img v-else-if="svgPath" :src="svgPath" alt="" />
|
|
112
123
|
</div>
|
|
113
124
|
<div class="gl-banner-content">
|
|
114
125
|
<h2 class="gl-banner-title">{{ title }}</h2>
|
|
@@ -13,11 +13,6 @@ export default {
|
|
|
13
13
|
validator: tokensValidator,
|
|
14
14
|
required: true,
|
|
15
15
|
},
|
|
16
|
-
state: {
|
|
17
|
-
type: Boolean,
|
|
18
|
-
required: false,
|
|
19
|
-
default: null,
|
|
20
|
-
},
|
|
21
16
|
registerFocusOnToken: {
|
|
22
17
|
type: Function,
|
|
23
18
|
required: true,
|
|
@@ -133,11 +128,6 @@ export default {
|
|
|
133
128
|
<div
|
|
134
129
|
ref="tokenContainer"
|
|
135
130
|
class="-gl-mx-1 -gl-my-1 gl-flex gl-w-auto gl-list-none gl-flex-wrap gl-items-center gl-p-0"
|
|
136
|
-
role="listbox"
|
|
137
|
-
aria-multiselectable="false"
|
|
138
|
-
aria-orientation="horizontal"
|
|
139
|
-
:aria-invalid="state === false && 'true'"
|
|
140
|
-
aria-label="token list"
|
|
141
131
|
@keydown.left="handleLeftArrow"
|
|
142
132
|
@keydown.right="handleRightArrow"
|
|
143
133
|
@keydown.home="handleHome"
|
|
@@ -152,7 +142,7 @@ export default {
|
|
|
152
142
|
:key="token.id"
|
|
153
143
|
:data-token-id="token.id"
|
|
154
144
|
class="gl-token-selector-token-container gl-px-1 gl-py-2 gl-outline-none"
|
|
155
|
-
|
|
145
|
+
data-testid="gl-token-selector-tokens"
|
|
156
146
|
tabindex="-1"
|
|
157
147
|
@focus="bindFocusEvent ? handleTokenFocus(index) : null"
|
|
158
148
|
>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import
|
|
2
|
+
import { GlUniqueId } from '../../../utils/unique_id';
|
|
3
3
|
import { tokensValidator } from './helpers';
|
|
4
4
|
import GlTokenContainer from './token_container.vue';
|
|
5
5
|
import GlTokenSelectorDropdown from './token_selector_dropdown.vue';
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
8
|
name: 'GlTokenSelector',
|
|
9
|
-
componentId:
|
|
9
|
+
componentId: `token-selector-${GlUniqueId()}`,
|
|
10
10
|
components: {
|
|
11
11
|
GlTokenContainer,
|
|
12
12
|
GlTokenSelectorDropdown,
|
|
@@ -75,7 +75,7 @@ export default {
|
|
|
75
75
|
default: '',
|
|
76
76
|
},
|
|
77
77
|
/**
|
|
78
|
-
* The autocomplete attribute value for the underlying `input` element
|
|
78
|
+
* The HTML5 autocomplete attribute value for the underlying `input` element.
|
|
79
79
|
*/
|
|
80
80
|
autocomplete: {
|
|
81
81
|
type: String,
|
|
@@ -83,7 +83,21 @@ export default {
|
|
|
83
83
|
default: 'off',
|
|
84
84
|
},
|
|
85
85
|
/**
|
|
86
|
-
* The `aria-
|
|
86
|
+
* The `aria-label` attribute value for the underlying `input` element.
|
|
87
|
+
* Input must have an aria-label or aria-labelledby prop or it will be inaccessible.
|
|
88
|
+
*
|
|
89
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label
|
|
90
|
+
*/
|
|
91
|
+
ariaLabel: {
|
|
92
|
+
type: String,
|
|
93
|
+
required: false,
|
|
94
|
+
default: null,
|
|
95
|
+
},
|
|
96
|
+
/**
|
|
97
|
+
* The `aria-labelledby` attribute value for the underlying `input` element.
|
|
98
|
+
* String must match the unique ID on a text element to create an accessible label.
|
|
99
|
+
*
|
|
100
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-labelledby
|
|
87
101
|
*/
|
|
88
102
|
ariaLabelledby: {
|
|
89
103
|
type: String,
|
|
@@ -382,6 +396,13 @@ export default {
|
|
|
382
396
|
this.$emit('input', []);
|
|
383
397
|
this.focusTextInput();
|
|
384
398
|
},
|
|
399
|
+
handleAriaInvalid() {
|
|
400
|
+
const { state } = this;
|
|
401
|
+
return state === false ? 'true' : null;
|
|
402
|
+
},
|
|
403
|
+
handleAriaActiveDescendent(value) {
|
|
404
|
+
return value ? `${this.$options.componentId}-dropdown-item-${value.id}` : null;
|
|
405
|
+
},
|
|
385
406
|
},
|
|
386
407
|
};
|
|
387
408
|
</script>
|
|
@@ -428,10 +449,17 @@ export default {
|
|
|
428
449
|
type="text"
|
|
429
450
|
class="gl-token-selector-input gl-h-auto gl-w-4/10 gl-grow gl-border-none gl-bg-transparent gl-px-1 gl-font-regular gl-text-base gl-leading-normal gl-text-default gl-outline-none"
|
|
430
451
|
:value="inputText"
|
|
452
|
+
:aria-activedescendant="handleAriaActiveDescendent(focusedDropdownItem)"
|
|
431
453
|
:autocomplete="autocomplete"
|
|
454
|
+
:aria-controls="$options.componentId"
|
|
455
|
+
:aria-expanded="dropdownIsOpen.toString()"
|
|
456
|
+
:aria-invalid="handleAriaInvalid()"
|
|
457
|
+
:aria-label="ariaLabelledby ? null : ariaLabel"
|
|
432
458
|
:aria-labelledby="ariaLabelledby"
|
|
433
459
|
:placeholder="placeholder"
|
|
434
460
|
:disabled="viewOnly"
|
|
461
|
+
aria-autocomplete="list"
|
|
462
|
+
role="combobox"
|
|
435
463
|
v-bind="textInputAttrs"
|
|
436
464
|
@input="inputText = $event.target.value"
|
|
437
465
|
@focus="handleFocus"
|
|
@@ -462,6 +490,7 @@ export default {
|
|
|
462
490
|
:register-dropdown-event-handlers="registerDropdownEventHandlers"
|
|
463
491
|
:register-reset-focused-dropdown-item="registerResetFocusedDropdownItem"
|
|
464
492
|
@dropdown-item-click="addToken"
|
|
493
|
+
@input="handleAriaActiveDescendent"
|
|
465
494
|
@show="openDropdown"
|
|
466
495
|
>
|
|
467
496
|
<template #loading-content
|
|
@@ -199,10 +199,10 @@ export default {
|
|
|
199
199
|
<template>
|
|
200
200
|
<div class="dropdown b-dropdown gl-dropdown gl-relative" :class="{ show }">
|
|
201
201
|
<ul
|
|
202
|
+
:id="componentId"
|
|
202
203
|
ref="dropdownMenu"
|
|
203
|
-
role="
|
|
204
|
+
role="listbox"
|
|
204
205
|
class="dropdown-menu gl-absolute"
|
|
205
|
-
:aria-activedescendant="dropdownItemIdAttribute(focusedDropdownItem)"
|
|
206
206
|
:class="[{ show }, menuClass]"
|
|
207
207
|
>
|
|
208
208
|
<gl-dropdown-item v-if="loading" disabled>
|
|
@@ -216,7 +216,9 @@ export default {
|
|
|
216
216
|
:key="dropdownItem.id"
|
|
217
217
|
:data-dropdown-item-id="dropdownItem.id"
|
|
218
218
|
:active="dropdownItemIsFocused(dropdownItem)"
|
|
219
|
+
:aria-selected="dropdownItemIsFocused(dropdownItem).toString()"
|
|
219
220
|
active-class="is-focused"
|
|
221
|
+
role="option"
|
|
220
222
|
tabindex="-1"
|
|
221
223
|
@click="handleDropdownItemClick(dropdownItem)"
|
|
222
224
|
>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function uses browser native crypto to return a sixteen
|
|
3
|
+
* character base16 encoded string. It is often used to
|
|
4
|
+
* generate collision-resistant IDs for aria markup such
|
|
5
|
+
* as aria-activedescendant and aria-controls.
|
|
6
|
+
*
|
|
7
|
+
* @returns String
|
|
8
|
+
*/
|
|
9
|
+
export const GlUniqueId = () => {
|
|
10
|
+
if (typeof window !== 'undefined' && window.crypto) {
|
|
11
|
+
const arr32 = new Uint32Array(2);
|
|
12
|
+
window.crypto.getRandomValues(arr32);
|
|
13
|
+
return Array.from(arr32, (id) => id.toString(16)).join('');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
throw new Error('Cannot generate a unique ID');
|
|
17
|
+
};
|