@gitlab/ui 122.12.0 → 122.12.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 +28 -2
- package/dist/components/base/new_dropdowns/base_dropdown/dropdown_container.js +32 -0
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown.js +3 -4
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/tailwind.css.map +1 -1
- package/package.json +1 -1
- package/src/components/base/form/form_group/form_group.scss +1 -1
- package/src/components/base/new_dropdowns/base_dropdown/base_dropdown.vue +54 -17
- package/src/components/base/new_dropdowns/base_dropdown/dropdown_container.js +34 -0
- package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.vue +2 -3
- package/src/components/base/new_dropdowns/dropdown.scss +51 -48
|
@@ -6,14 +6,19 @@ import { logWarning, isElementFocusable, isElementTabbable, stopEvent } from '..
|
|
|
6
6
|
import { OutsideDirective } from '../../../../directives/outside/outside';
|
|
7
7
|
import GlButton from '../../button/button';
|
|
8
8
|
import GlIcon from '../../icon/icon';
|
|
9
|
+
import DropdownContainer from './dropdown_container';
|
|
9
10
|
import { DEFAULT_OFFSET, FIXED_WIDTH_CLASS, ARROW_X_MINIMUM } from './constants';
|
|
10
11
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
11
12
|
|
|
12
13
|
const BASE_DROPDOWN_CLASS = 'gl-new-dropdown';
|
|
14
|
+
const DROPDOWN_CONTAINER_CLASS = 'gl-new-dropdown-container';
|
|
13
15
|
var script = {
|
|
14
16
|
name: 'BaseDropdown',
|
|
17
|
+
expose: ['open', 'close', 'closeAndFocus', 'containsElement'],
|
|
15
18
|
BASE_DROPDOWN_CLASS,
|
|
19
|
+
DROPDOWN_CONTAINER_CLASS,
|
|
16
20
|
components: {
|
|
21
|
+
DropdownContainer,
|
|
17
22
|
GlButton,
|
|
18
23
|
GlIcon
|
|
19
24
|
},
|
|
@@ -437,6 +442,17 @@ var script = {
|
|
|
437
442
|
}
|
|
438
443
|
this.toggle(event);
|
|
439
444
|
},
|
|
445
|
+
clickedToggle(event) {
|
|
446
|
+
var _this$$refs$toggle$co, _this$$refs$toggle2, _this$$refs$toggle$$e, _this$$refs$toggle$$e2;
|
|
447
|
+
return ((_this$$refs$toggle$co = (_this$$refs$toggle2 = this.$refs.toggle).contains) === null || _this$$refs$toggle$co === void 0 ? void 0 : _this$$refs$toggle$co.call(_this$$refs$toggle2, event.target)) || ((_this$$refs$toggle$$e = this.$refs.toggle.$el) === null || _this$$refs$toggle$$e === void 0 ? void 0 : (_this$$refs$toggle$$e2 = _this$$refs$toggle$$e.contains) === null || _this$$refs$toggle$$e2 === void 0 ? void 0 : _this$$refs$toggle$$e2.call(_this$$refs$toggle$$e, event.target));
|
|
448
|
+
},
|
|
449
|
+
handleClickOutside(event) {
|
|
450
|
+
// Ignore "click outside" events if the toggle was clicked
|
|
451
|
+
if (this.clickedToggle(event)) {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
this.close(event);
|
|
455
|
+
},
|
|
440
456
|
/**
|
|
441
457
|
* Closes the dropdown and returns the focus to the toggle unless it has has moved outside
|
|
442
458
|
* of the dropdown, meaning that the consumer needed to put some other element in focus.
|
|
@@ -500,6 +516,16 @@ var script = {
|
|
|
500
516
|
const floatingElementBoundingBox = this.$refs.content.getBoundingClientRect();
|
|
501
517
|
const scrollableAreaBoundingBox = scrollableArea.getBoundingClientRect();
|
|
502
518
|
this.nonScrollableContentHeight = floatingElementBoundingBox.height - scrollableAreaBoundingBox.height;
|
|
519
|
+
},
|
|
520
|
+
/**
|
|
521
|
+
* Public method which returns `true` if the given element is in the DOM tree of this component,
|
|
522
|
+
* and `false` otherwise.
|
|
523
|
+
*
|
|
524
|
+
* Useful for checking whether an event was dispatched against something in this dropdown,
|
|
525
|
+
* e.g., pressing <kbd>Esc</kbd>.
|
|
526
|
+
*/
|
|
527
|
+
containsElement(element) {
|
|
528
|
+
return element.closest(`.${BASE_DROPDOWN_CLASS}`) === this.$el || element.closest(`.${DROPDOWN_CONTAINER_CLASS}`) === this.$refs.dropdownContainer;
|
|
503
529
|
}
|
|
504
530
|
}
|
|
505
531
|
};
|
|
@@ -508,7 +534,7 @@ var script = {
|
|
|
508
534
|
const __vue_script__ = script;
|
|
509
535
|
|
|
510
536
|
/* template */
|
|
511
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{
|
|
537
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{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('dropdown-container',{attrs:{"positioning-strategy":_vm.positioningStrategy}},[_c('div',{directives:[{name:"outside",rawName:"v-outside.click.focusin",value:(_vm.handleClickOutside),expression:"handleClickOutside",modifiers:{"click":true,"focusin":true}}],ref:"dropdownContainer",class:_vm.$options.DROPDOWN_CONTAINER_CLASS},[_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)};
|
|
512
538
|
var __vue_staticRenderFns__ = [];
|
|
513
539
|
|
|
514
540
|
/* style */
|
|
@@ -540,4 +566,4 @@ var __vue_staticRenderFns__ = [];
|
|
|
540
566
|
undefined
|
|
541
567
|
);
|
|
542
568
|
|
|
543
|
-
export {
|
|
569
|
+
export { __vue_component__ as default };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MountingPortal } from 'portal-vue';
|
|
2
|
+
import { POSITION_ABSOLUTE, POSITION_FIXED } from '../constants';
|
|
3
|
+
|
|
4
|
+
/* eslint-disable import/no-default-export */
|
|
5
|
+
var dropdown_container = {
|
|
6
|
+
props: {
|
|
7
|
+
/**
|
|
8
|
+
* Strategy to be applied by computePosition. If this is set to fixed, the dropdown's position
|
|
9
|
+
* needs to be set to fixed in CSS as well.
|
|
10
|
+
* https://floating-ui.com/docs/computePosition#strategy
|
|
11
|
+
*/
|
|
12
|
+
positioningStrategy: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: false,
|
|
15
|
+
default: POSITION_ABSOLUTE,
|
|
16
|
+
validator: strategy => [POSITION_ABSOLUTE, POSITION_FIXED].includes(strategy)
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
render(createElement) {
|
|
20
|
+
if (this.positioningStrategy === POSITION_FIXED) {
|
|
21
|
+
return createElement(MountingPortal, {
|
|
22
|
+
props: {
|
|
23
|
+
mountTo: 'body',
|
|
24
|
+
append: true
|
|
25
|
+
}
|
|
26
|
+
}, [this.$scopedSlots.default()]);
|
|
27
|
+
}
|
|
28
|
+
return this.$scopedSlots.default();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { dropdown_container as default };
|
|
@@ -3,7 +3,7 @@ import uniqueId from 'lodash/uniqueId';
|
|
|
3
3
|
import { stopEvent, filterVisible } from '../../../../utils/utils';
|
|
4
4
|
import { GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, GL_DROPDOWN_BEFORE_CLOSE, GL_DROPDOWN_FOCUS_CONTENT, POSITION_ABSOLUTE, POSITION_FIXED, HOME, END, ARROW_UP, ARROW_DOWN, ENTER, SPACE, GL_DROPDOWN_CONTENTS_CLASS } from '../constants';
|
|
5
5
|
import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions, dropdownPlacements } from '../../../../utils/constants';
|
|
6
|
-
import GlBaseDropdown
|
|
6
|
+
import GlBaseDropdown from '../base_dropdown/base_dropdown';
|
|
7
7
|
import GlDisclosureDropdownItem, { ITEM_CLASS } from './disclosure_dropdown_item';
|
|
8
8
|
import GlDisclosureDropdownGroup from './disclosure_dropdown_group';
|
|
9
9
|
import { itemsValidator, hasOnlyListItems, isItem } from './utils';
|
|
@@ -11,7 +11,6 @@ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
|
11
11
|
|
|
12
12
|
//
|
|
13
13
|
|
|
14
|
-
const DROPDOWN_SELECTOR = `.${BASE_DROPDOWN_CLASS}`;
|
|
15
14
|
const ITEM_SELECTOR = `.${ITEM_CLASS}`;
|
|
16
15
|
var script = {
|
|
17
16
|
name: 'GlDisclosureDropdown',
|
|
@@ -325,7 +324,7 @@ var script = {
|
|
|
325
324
|
});
|
|
326
325
|
},
|
|
327
326
|
handleAutoClose(e) {
|
|
328
|
-
if (this.autoClose && e.target.closest(ITEM_SELECTOR) &&
|
|
327
|
+
if (this.autoClose && e.target.closest(ITEM_SELECTOR) && this.$refs.baseDropdown.containsElement(e.target)) {
|
|
329
328
|
this.closeAndFocus();
|
|
330
329
|
}
|
|
331
330
|
},
|
|
@@ -373,4 +372,4 @@ var __vue_staticRenderFns__ = [];
|
|
|
373
372
|
undefined
|
|
374
373
|
);
|
|
375
374
|
|
|
376
|
-
export {
|
|
375
|
+
export { ITEM_SELECTOR, __vue_component__ as default };
|