@gitlab/ui 115.0.0 → 115.0.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/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +15 -3
- package/dist/components/base/new_dropdowns/constants.js +5 -2
- package/package.json +4 -4
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.vue +19 -2
- package/src/components/base/new_dropdowns/constants.js +4 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import uniqueId from 'lodash/uniqueId';
|
|
2
2
|
import { offset, autoPlacement, shift, arrow, size, autoUpdate, computePosition } from '@floating-ui/dom';
|
|
3
3
|
import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions, dropdownPlacements, dropdownAllowedAutoPlacements } from '../../../../utils/constants';
|
|
4
|
-
import { POSITION_ABSOLUTE, POSITION_FIXED, GL_DROPDOWN_CONTENTS_CLASS, GL_DROPDOWN_BEFORE_CLOSE, GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, ENTER, SPACE, ARROW_DOWN, GL_DROPDOWN_FOCUS_CONTENT } from '../constants';
|
|
5
|
-
import { logWarning, isElementFocusable, isElementTabbable } from '../../../../utils/utils';
|
|
4
|
+
import { POSITION_ABSOLUTE, POSITION_FIXED, GL_DROPDOWN_CONTENTS_CLASS, GL_DROPDOWN_BEFORE_CLOSE, GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, KEY_CODE_ESCAPE, ENTER, SPACE, ARROW_DOWN, GL_DROPDOWN_FOCUS_CONTENT } from '../constants';
|
|
5
|
+
import { logWarning, isElementFocusable, isElementTabbable, stopEvent } from '../../../../utils/utils';
|
|
6
6
|
import { OutsideDirective } from '../../../../directives/outside/outside';
|
|
7
7
|
import GlButton from '../../button/button';
|
|
8
8
|
import GlIcon from '../../icon/icon';
|
|
@@ -461,11 +461,23 @@ var script = {
|
|
|
461
461
|
},
|
|
462
462
|
onKeydown(event) {
|
|
463
463
|
const {
|
|
464
|
+
keyCode,
|
|
464
465
|
code,
|
|
465
466
|
target: {
|
|
466
467
|
tagName
|
|
467
468
|
}
|
|
468
469
|
} = event;
|
|
470
|
+
|
|
471
|
+
// Use keyCode because @vue/test-utils doesn't correctly set the
|
|
472
|
+
// `code` and `key` KeyboardEvent properties. This is only needed in this case because:
|
|
473
|
+
// - We are not using the @keydown.esc template syntax, which under Vue 2 checks against `keyCode` anyway.
|
|
474
|
+
// - The `.trigger('keydown.esc')` shorthand @vue/test-utils provides is useful.
|
|
475
|
+
// See https://github.com/vuejs/vue-test-utils/issues/2096
|
|
476
|
+
if (keyCode === KEY_CODE_ESCAPE && this.visible) {
|
|
477
|
+
stopEvent(event);
|
|
478
|
+
this.close();
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
469
481
|
let toggleOnEnter = true;
|
|
470
482
|
let toggleOnSpace = true;
|
|
471
483
|
if (tagName === 'BUTTON') {
|
|
@@ -496,7 +508,7 @@ var script = {
|
|
|
496
508
|
const __vue_script__ = script;
|
|
497
509
|
|
|
498
510
|
/* template */
|
|
499
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:"outside",rawName:"v-outside.click.focusin",value:(_vm.close),expression:"close",modifiers:{"click":true,"focusin":true}}],class:[_vm.$options.BASE_DROPDOWN_CLASS, { '!gl-block': _vm.block }]},[_c(_vm.toggleComponent,_vm._g(_vm._b({ref:"toggle",tag:"component",attrs:{"id":_vm.toggleId,"data-testid":"base-dropdown-toggle"}
|
|
511
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:"outside",rawName:"v-outside.click.focusin",value:(_vm.close),expression:"close",modifiers:{"click":true,"focusin":true}}],class:[_vm.$options.BASE_DROPDOWN_CLASS, { '!gl-block': _vm.block }]},[_c(_vm.toggleComponent,_vm._g(_vm._b({ref:"toggle",tag:"component",attrs:{"id":_vm.toggleId,"data-testid":"base-dropdown-toggle"}},'component',_vm.toggleAttributes,false),_vm.toggleListeners),[_vm._t("toggle",function(){return [_c('span',{staticClass:"gl-new-dropdown-button-text",class:{ 'gl-sr-only': _vm.textSrOnly }},[_vm._v("\n "+_vm._s(_vm.toggleText)+"\n ")]),_vm._v(" "),(!_vm.noCaret)?_c('gl-icon',{staticClass:"gl-button-icon gl-new-dropdown-chevron",attrs:{"name":"chevron-down"}}):_vm._e()]})],2),_vm._v(" "),_c('div',{ref:"content",staticClass:"gl-new-dropdown-panel",class:_vm.panelClasses,attrs:{"id":_vm.baseDropdownId,"data-testid":"base-dropdown-menu"},on:{"keydown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"esc",27,$event.key,["Esc","Escape"])){ return null; }$event.stopPropagation();$event.preventDefault();return _vm.closeAndFocus.apply(null, arguments)}}},[_c('div',{ref:"dropdownArrow",staticClass:"gl-new-dropdown-arrow"}),_vm._v(" "),_c('div',{staticClass:"gl-new-dropdown-inner"},[_vm._t("default",null,{"visible":_vm.visible})],2)])],1)};
|
|
500
512
|
var __vue_staticRenderFns__ = [];
|
|
501
513
|
|
|
502
514
|
/* style */
|
|
@@ -4,7 +4,7 @@ const GL_DROPDOWN_HIDDEN = 'hidden';
|
|
|
4
4
|
const GL_DROPDOWN_BEFORE_CLOSE = 'beforeClose';
|
|
5
5
|
const GL_DROPDOWN_FOCUS_CONTENT = 'focusContent';
|
|
6
6
|
|
|
7
|
-
//
|
|
7
|
+
// KeyboardEvent.code values
|
|
8
8
|
const ARROW_DOWN = 'ArrowDown';
|
|
9
9
|
const ARROW_UP = 'ArrowUp';
|
|
10
10
|
const END = 'End';
|
|
@@ -12,10 +12,13 @@ const ENTER = 'Enter';
|
|
|
12
12
|
const HOME = 'Home';
|
|
13
13
|
const SPACE = 'Space';
|
|
14
14
|
|
|
15
|
+
// KeyboardEvent.keyCode values
|
|
16
|
+
const KEY_CODE_ESCAPE = 27;
|
|
17
|
+
|
|
15
18
|
// Positioning strategies
|
|
16
19
|
// https://floating-ui.com/docs/computePosition#strategy
|
|
17
20
|
const POSITION_ABSOLUTE = 'absolute';
|
|
18
21
|
const POSITION_FIXED = 'fixed';
|
|
19
22
|
const GL_DROPDOWN_CONTENTS_CLASS = 'gl-new-dropdown-contents';
|
|
20
23
|
|
|
21
|
-
export { ARROW_DOWN, ARROW_UP, END, ENTER, GL_DROPDOWN_BEFORE_CLOSE, GL_DROPDOWN_CONTENTS_CLASS, GL_DROPDOWN_FOCUS_CONTENT, GL_DROPDOWN_HIDDEN, GL_DROPDOWN_SHOWN, HOME, POSITION_ABSOLUTE, POSITION_FIXED, SPACE };
|
|
24
|
+
export { ARROW_DOWN, ARROW_UP, END, ENTER, GL_DROPDOWN_BEFORE_CLOSE, GL_DROPDOWN_CONTENTS_CLASS, GL_DROPDOWN_FOCUS_CONTENT, GL_DROPDOWN_HIDDEN, GL_DROPDOWN_SHOWN, HOME, KEY_CODE_ESCAPE, POSITION_ABSOLUTE, POSITION_FIXED, SPACE };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "115.0.
|
|
3
|
+
"version": "115.0.1",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"chokidar": "^3.6.0",
|
|
101
101
|
"sane": "^5.0.1",
|
|
102
102
|
"jackspeak": "2.1.1",
|
|
103
|
-
"postcss": "8.5.
|
|
103
|
+
"postcss": "8.5.6",
|
|
104
104
|
"json5": "2.2.3",
|
|
105
105
|
"rollup-plugin-vue/@vue/component-compiler/postcss-modules-sync/generic-names/loader-utils": "1.4.2",
|
|
106
106
|
"eslint-plugin-import": "2.32.0"
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"@jest/test-sequencer": "^30.0.2",
|
|
122
122
|
"@rollup/plugin-commonjs": "^21.1.0",
|
|
123
123
|
"@rollup/plugin-node-resolve": "^9.0.0",
|
|
124
|
-
"@rollup/plugin-replace": "^
|
|
124
|
+
"@rollup/plugin-replace": "^3.1.0",
|
|
125
125
|
"@storybook/addon-a11y": "^7.6.20",
|
|
126
126
|
"@storybook/addon-docs": "^7.6.20",
|
|
127
127
|
"@storybook/addon-essentials": "^7.6.20",
|
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
"pikaday": "^1.8.0",
|
|
182
182
|
"playwright": "^1.53.1",
|
|
183
183
|
"playwright-core": "^1.53.1",
|
|
184
|
-
"postcss": "8.5.
|
|
184
|
+
"postcss": "8.5.6",
|
|
185
185
|
"postcss-loader": "8.1.1",
|
|
186
186
|
"postcss-scss": "4.0.9",
|
|
187
187
|
"prettier": "3.5.3",
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
GL_DROPDOWN_HIDDEN,
|
|
22
22
|
GL_DROPDOWN_BEFORE_CLOSE,
|
|
23
23
|
GL_DROPDOWN_FOCUS_CONTENT,
|
|
24
|
+
KEY_CODE_ESCAPE,
|
|
24
25
|
ENTER,
|
|
25
26
|
SPACE,
|
|
26
27
|
ARROW_DOWN,
|
|
@@ -28,7 +29,12 @@ import {
|
|
|
28
29
|
POSITION_ABSOLUTE,
|
|
29
30
|
POSITION_FIXED,
|
|
30
31
|
} from '../constants';
|
|
31
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
logWarning,
|
|
34
|
+
isElementTabbable,
|
|
35
|
+
isElementFocusable,
|
|
36
|
+
stopEvent,
|
|
37
|
+
} from '../../../../utils/utils';
|
|
32
38
|
import { OutsideDirective } from '../../../../directives/outside/outside';
|
|
33
39
|
import GlButton from '../../button/button.vue';
|
|
34
40
|
import GlIcon from '../../icon/icon.vue';
|
|
@@ -500,10 +506,22 @@ export default {
|
|
|
500
506
|
},
|
|
501
507
|
onKeydown(event) {
|
|
502
508
|
const {
|
|
509
|
+
keyCode,
|
|
503
510
|
code,
|
|
504
511
|
target: { tagName },
|
|
505
512
|
} = event;
|
|
506
513
|
|
|
514
|
+
// Use keyCode because @vue/test-utils doesn't correctly set the
|
|
515
|
+
// `code` and `key` KeyboardEvent properties. This is only needed in this case because:
|
|
516
|
+
// - We are not using the @keydown.esc template syntax, which under Vue 2 checks against `keyCode` anyway.
|
|
517
|
+
// - The `.trigger('keydown.esc')` shorthand @vue/test-utils provides is useful.
|
|
518
|
+
// See https://github.com/vuejs/vue-test-utils/issues/2096
|
|
519
|
+
if (keyCode === KEY_CODE_ESCAPE && this.visible) {
|
|
520
|
+
stopEvent(event);
|
|
521
|
+
this.close();
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
|
|
507
525
|
let toggleOnEnter = true;
|
|
508
526
|
let toggleOnSpace = true;
|
|
509
527
|
|
|
@@ -547,7 +565,6 @@ export default {
|
|
|
547
565
|
ref="toggle"
|
|
548
566
|
data-testid="base-dropdown-toggle"
|
|
549
567
|
v-on="toggleListeners"
|
|
550
|
-
@keydown.esc.stop.prevent="close"
|
|
551
568
|
>
|
|
552
569
|
<!-- @slot Custom toggle button content -->
|
|
553
570
|
<slot name="toggle">
|
|
@@ -4,7 +4,7 @@ export const GL_DROPDOWN_HIDDEN = 'hidden';
|
|
|
4
4
|
export const GL_DROPDOWN_BEFORE_CLOSE = 'beforeClose';
|
|
5
5
|
export const GL_DROPDOWN_FOCUS_CONTENT = 'focusContent';
|
|
6
6
|
|
|
7
|
-
//
|
|
7
|
+
// KeyboardEvent.code values
|
|
8
8
|
export const ARROW_DOWN = 'ArrowDown';
|
|
9
9
|
export const ARROW_UP = 'ArrowUp';
|
|
10
10
|
export const END = 'End';
|
|
@@ -12,6 +12,9 @@ export const ENTER = 'Enter';
|
|
|
12
12
|
export const HOME = 'Home';
|
|
13
13
|
export const SPACE = 'Space';
|
|
14
14
|
|
|
15
|
+
// KeyboardEvent.keyCode values
|
|
16
|
+
export const KEY_CODE_ESCAPE = 27;
|
|
17
|
+
|
|
15
18
|
// Positioning strategies
|
|
16
19
|
// https://floating-ui.com/docs/computePosition#strategy
|
|
17
20
|
export const POSITION_ABSOLUTE = 'absolute';
|