@gitlab/ui 47.0.0 → 47.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/CHANGELOG.md +7 -0
- package/dist/components/base/dropdown/dropdown.js +20 -3
- package/dist/components/base/sorting/sorting_item.js +9 -2
- package/package.json +1 -1
- package/src/components/base/dropdown/dropdown.spec.js +37 -0
- package/src/components/base/dropdown/dropdown.stories.js +24 -1
- package/src/components/base/dropdown/dropdown.vue +19 -0
- package/src/components/base/sorting/sorting_item.spec.js +3 -1
- package/src/components/base/sorting/sorting_item.vue +9 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [47.0.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v47.0.0...v47.0.1) (2022-10-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **GlDropdown:** Fix GlDropdown not auto flipping horizontally ([635eca3](https://gitlab.com/gitlab-org/gitlab-ui/commit/635eca3eea58f6ee1d2fd01a17a1db3401657647))
|
|
7
|
+
|
|
1
8
|
# [47.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v46.1.0...v47.0.0) (2022-10-17)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _merge from 'lodash/merge';
|
|
1
2
|
import Vue from 'vue';
|
|
2
3
|
import { BDropdown } from 'bootstrap-vue/esm/index.js';
|
|
3
4
|
import { selectAll, isVisible } from 'bootstrap-vue/esm/utils/dom';
|
|
@@ -9,8 +10,6 @@ import GlLoadingIcon from '../loading_icon/loading_icon';
|
|
|
9
10
|
import GlDropdownDivider from './dropdown_divider';
|
|
10
11
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
11
12
|
|
|
12
|
-
//
|
|
13
|
-
|
|
14
13
|
function filterVisible(els) {
|
|
15
14
|
return (els || []).filter(isVisible);
|
|
16
15
|
}
|
|
@@ -27,6 +26,14 @@ const ExtendedBDropdown = Vue.extend(BDropdown, {
|
|
|
27
26
|
|
|
28
27
|
}
|
|
29
28
|
});
|
|
29
|
+
const DefaultPopperOptions = {
|
|
30
|
+
modifiers: {
|
|
31
|
+
flip: {
|
|
32
|
+
flipVariationsByContent: true,
|
|
33
|
+
padding: 28
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
30
37
|
var script = {
|
|
31
38
|
components: {
|
|
32
39
|
BDropdown: ExtendedBDropdown,
|
|
@@ -139,6 +146,11 @@ var script = {
|
|
|
139
146
|
type: Boolean,
|
|
140
147
|
required: false,
|
|
141
148
|
default: false
|
|
149
|
+
},
|
|
150
|
+
popperOpts: {
|
|
151
|
+
type: Object,
|
|
152
|
+
required: false,
|
|
153
|
+
default: null
|
|
142
154
|
}
|
|
143
155
|
},
|
|
144
156
|
computed: {
|
|
@@ -188,6 +200,10 @@ var script = {
|
|
|
188
200
|
|
|
189
201
|
hasHighlightedItemsOrClearAll() {
|
|
190
202
|
return this.hasHighlightedItemsContent && this.showHighlightedItemsTitle || this.showClearAll;
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
popperOptions() {
|
|
206
|
+
return _merge({}, DefaultPopperOptions, this.popperOpts);
|
|
191
207
|
}
|
|
192
208
|
|
|
193
209
|
},
|
|
@@ -212,7 +228,7 @@ var script = {
|
|
|
212
228
|
const __vue_script__ = script;
|
|
213
229
|
|
|
214
230
|
/* template */
|
|
215
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-dropdown',_vm._g(_vm._b({ref:"dropdown",staticClass:"gl-new-dropdown",attrs:{"split":_vm.split,"variant":_vm.variant,"size":_vm.buttonSize,"toggle-class":[_vm.toggleButtonClasses],"split-class":_vm.splitButtonClasses,"block":_vm.block,"disabled":_vm.disabled || _vm.loading,"right":_vm.right},scopedSlots:_vm._u([{key:"button-content",fn:function(){return [_vm._t("button-content",function(){return [(_vm.loading)?_c('gl-loading-icon',{class:{ 'gl-mr-2': !_vm.isIconOnly }}):_vm._e(),_vm._v(" "),(_vm.icon && !(_vm.isIconOnly && _vm.loading))?_c('gl-icon',{staticClass:"dropdown-icon",attrs:{"name":_vm.icon}}):_vm._e(),_vm._v(" "),_c('span',{staticClass:"gl-new-dropdown-button-text",class:{ 'gl-sr-only': _vm.textSrOnly }},[_vm._t("button-text",function(){return [_vm._v(_vm._s(_vm.buttonText))]})],2),_vm._v(" "),(_vm.renderCaret)?_c('gl-icon',{staticClass:"gl-button-icon dropdown-chevron",attrs:{"name":"chevron-down"}}):_vm._e()]})]},proxy:true}],null,true)},'b-dropdown',_vm.$attrs,false),_vm.$listeners),[_c('div',{staticClass:"gl-new-dropdown-inner"},[(_vm.hasSlotContents('header') || _vm.headerText)?_c('div',{staticClass:"gl-new-dropdown-header",class:{ 'gl-border-b-0!': _vm.hideHeaderBorder }},[(_vm.headerText)?_c('p',{staticClass:"gl-new-dropdown-header-top"},[_vm._v("\n "+_vm._s(_vm.headerText)+"\n ")]):_vm._e(),_vm._v(" "),_vm._t("header")],2):_vm._e(),_vm._v(" "),(_vm.hasHighlightedItemsOrClearAll)?_c('div',{staticClass:"gl-display-flex gl-flex-direction-row gl-justify-content-space-between gl-align-items-center"},[(_vm.hasHighlightedItemsContent && _vm.showHighlightedItemsTitle)?_c('div',{staticClass:"gl-display-flex gl-flex-grow-1 gl-justify-content-flex-start",class:_vm.highlightedItemsTitleClass},[_c('span',{staticClass:"gl-font-weight-bold",attrs:{"data-testid":"highlighted-items-title"}},[_vm._v(_vm._s(_vm.highlightedItemsTitle))])]):_vm._e(),_vm._v(" "),(_vm.showClearAll)?_c('div',{staticClass:"gl-display-flex gl-flex-grow-1 gl-justify-content-end",class:_vm.clearAllTextClass},[_c('gl-button',{attrs:{"size":"small","category":"tertiary","variant":"link","data-testid":"clear-all-button"},on:{"click":function($event){return _vm.$emit('clear-all', $event)}}},[_vm._v(_vm._s(_vm.clearAllText))])],1):_vm._e()]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-new-dropdown-contents"},[(_vm.hasHighlightedItemsContent)?_c('div',{staticClass:"gl-overflow-visible",attrs:{"data-testid":"highlighted-items"}},[_vm._t("highlighted-items"),_vm._v(" "),_c('gl-dropdown-divider')],2):_vm._e(),_vm._v(" "),_vm._t("default")],2),_vm._v(" "),(_vm.hasSlotContents('footer'))?_c('div',{staticClass:"gl-new-dropdown-footer"},[_vm._t("footer")],2):_vm._e()])])};
|
|
231
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-dropdown',_vm._g(_vm._b({ref:"dropdown",staticClass:"gl-new-dropdown",attrs:{"split":_vm.split,"variant":_vm.variant,"size":_vm.buttonSize,"toggle-class":[_vm.toggleButtonClasses],"split-class":_vm.splitButtonClasses,"block":_vm.block,"disabled":_vm.disabled || _vm.loading,"right":_vm.right,"popper-opts":_vm.popperOptions},scopedSlots:_vm._u([{key:"button-content",fn:function(){return [_vm._t("button-content",function(){return [(_vm.loading)?_c('gl-loading-icon',{class:{ 'gl-mr-2': !_vm.isIconOnly }}):_vm._e(),_vm._v(" "),(_vm.icon && !(_vm.isIconOnly && _vm.loading))?_c('gl-icon',{staticClass:"dropdown-icon",attrs:{"name":_vm.icon}}):_vm._e(),_vm._v(" "),_c('span',{staticClass:"gl-new-dropdown-button-text",class:{ 'gl-sr-only': _vm.textSrOnly }},[_vm._t("button-text",function(){return [_vm._v(_vm._s(_vm.buttonText))]})],2),_vm._v(" "),(_vm.renderCaret)?_c('gl-icon',{staticClass:"gl-button-icon dropdown-chevron",attrs:{"name":"chevron-down"}}):_vm._e()]})]},proxy:true}],null,true)},'b-dropdown',_vm.$attrs,false),_vm.$listeners),[_c('div',{staticClass:"gl-new-dropdown-inner"},[(_vm.hasSlotContents('header') || _vm.headerText)?_c('div',{staticClass:"gl-new-dropdown-header",class:{ 'gl-border-b-0!': _vm.hideHeaderBorder }},[(_vm.headerText)?_c('p',{staticClass:"gl-new-dropdown-header-top"},[_vm._v("\n "+_vm._s(_vm.headerText)+"\n ")]):_vm._e(),_vm._v(" "),_vm._t("header")],2):_vm._e(),_vm._v(" "),(_vm.hasHighlightedItemsOrClearAll)?_c('div',{staticClass:"gl-display-flex gl-flex-direction-row gl-justify-content-space-between gl-align-items-center"},[(_vm.hasHighlightedItemsContent && _vm.showHighlightedItemsTitle)?_c('div',{staticClass:"gl-display-flex gl-flex-grow-1 gl-justify-content-flex-start",class:_vm.highlightedItemsTitleClass},[_c('span',{staticClass:"gl-font-weight-bold",attrs:{"data-testid":"highlighted-items-title"}},[_vm._v(_vm._s(_vm.highlightedItemsTitle))])]):_vm._e(),_vm._v(" "),(_vm.showClearAll)?_c('div',{staticClass:"gl-display-flex gl-flex-grow-1 gl-justify-content-end",class:_vm.clearAllTextClass},[_c('gl-button',{attrs:{"size":"small","category":"tertiary","variant":"link","data-testid":"clear-all-button"},on:{"click":function($event){return _vm.$emit('clear-all', $event)}}},[_vm._v(_vm._s(_vm.clearAllText))])],1):_vm._e()]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-new-dropdown-contents"},[(_vm.hasHighlightedItemsContent)?_c('div',{staticClass:"gl-overflow-visible",attrs:{"data-testid":"highlighted-items"}},[_vm._t("highlighted-items"),_vm._v(" "),_c('gl-dropdown-divider')],2):_vm._e(),_vm._v(" "),_vm._t("default")],2),_vm._v(" "),(_vm.hasSlotContents('footer'))?_c('div',{staticClass:"gl-new-dropdown-footer"},[_vm._t("footer")],2):_vm._e()])])};
|
|
216
232
|
var __vue_staticRenderFns__ = [];
|
|
217
233
|
|
|
218
234
|
/* style */
|
|
@@ -245,3 +261,4 @@ var __vue_staticRenderFns__ = [];
|
|
|
245
261
|
);
|
|
246
262
|
|
|
247
263
|
export default __vue_component__;
|
|
264
|
+
export { DefaultPopperOptions };
|
|
@@ -43,7 +43,7 @@ var script = {
|
|
|
43
43
|
*/
|
|
44
44
|
render(createElement, _ref) {
|
|
45
45
|
let {
|
|
46
|
-
|
|
46
|
+
scopedSlots,
|
|
47
47
|
data,
|
|
48
48
|
props = {}
|
|
49
49
|
} = _ref;
|
|
@@ -58,8 +58,15 @@ var script = {
|
|
|
58
58
|
});
|
|
59
59
|
return createElement(GlDropdownItem, { ...data,
|
|
60
60
|
attrs: { ...props
|
|
61
|
+
},
|
|
62
|
+
scopedSlots: {
|
|
63
|
+
default: () => {
|
|
64
|
+
var _scopedSlots$default;
|
|
65
|
+
|
|
66
|
+
return [icon, (_scopedSlots$default = scopedSlots.default) === null || _scopedSlots$default === void 0 ? void 0 : _scopedSlots$default.call(scopedSlots)];
|
|
67
|
+
}
|
|
61
68
|
}
|
|
62
|
-
}
|
|
69
|
+
});
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mount } from '@vue/test-utils';
|
|
2
2
|
|
|
3
|
+
import { BDropdown } from 'bootstrap-vue';
|
|
3
4
|
import { dropdownVariantOptions } from '../../../utils/constants';
|
|
4
5
|
import GlLoadingIcon from '../loading_icon/loading_icon.vue';
|
|
5
6
|
import GlDropdown from './dropdown.vue';
|
|
@@ -34,6 +35,7 @@ describe('new dropdown', () => {
|
|
|
34
35
|
const findClearAll = () => findByTestId('clear-all-button');
|
|
35
36
|
const findHighlightedItemsTitle = () => findByTestId('highlighted-items-title');
|
|
36
37
|
const findHighlightedItems = () => findByTestId('highlighted-items');
|
|
38
|
+
const findDropdown = () => wrapper.findComponent(BDropdown);
|
|
37
39
|
|
|
38
40
|
it('renders when text is null', () => {
|
|
39
41
|
buildWrapper({ text: null });
|
|
@@ -417,4 +419,39 @@ describe('new dropdown', () => {
|
|
|
417
419
|
});
|
|
418
420
|
});
|
|
419
421
|
});
|
|
422
|
+
|
|
423
|
+
describe('popperOpts prop', () => {
|
|
424
|
+
it('combines the passed in popperOpts with the default popperOpts', () => {
|
|
425
|
+
const popperOpts = {
|
|
426
|
+
modifiers: {
|
|
427
|
+
flip: {
|
|
428
|
+
flipVariationsByContent: false,
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
};
|
|
432
|
+
buildWrapper({ popperOpts });
|
|
433
|
+
|
|
434
|
+
expect(findDropdown().props('popperOpts')).toEqual({
|
|
435
|
+
modifiers: {
|
|
436
|
+
flip: {
|
|
437
|
+
flipVariationsByContent: false,
|
|
438
|
+
padding: 28,
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
});
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
it('uses the default popperOpts prop', () => {
|
|
445
|
+
buildWrapper();
|
|
446
|
+
|
|
447
|
+
expect(findDropdown().props('popperOpts')).toEqual({
|
|
448
|
+
modifiers: {
|
|
449
|
+
flip: {
|
|
450
|
+
flipVariationsByContent: true,
|
|
451
|
+
padding: 28,
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
});
|
|
420
457
|
});
|
|
@@ -84,7 +84,7 @@ const withContainer = (template, containerHeight = 150) => `
|
|
|
84
84
|
${template}
|
|
85
85
|
</div>`;
|
|
86
86
|
|
|
87
|
-
function wrap(template, containerHeight) {
|
|
87
|
+
function wrap(template, containerHeight, cssClass) {
|
|
88
88
|
return withContainer(
|
|
89
89
|
`
|
|
90
90
|
<gl-dropdown
|
|
@@ -109,6 +109,7 @@ function wrap(template, containerHeight) {
|
|
|
109
109
|
:highlighted-items-title-class="highlightedItemsTitleClass"
|
|
110
110
|
:loading="loading"
|
|
111
111
|
:right="right"
|
|
112
|
+
class="${cssClass}"
|
|
112
113
|
>
|
|
113
114
|
${template}
|
|
114
115
|
</gl-dropdown>`,
|
|
@@ -514,6 +515,28 @@ WithHighlightedItems.args = generateProps({
|
|
|
514
515
|
highlightedItemsTitleClass: 'gl-px-5',
|
|
515
516
|
});
|
|
516
517
|
|
|
518
|
+
export const OnRightEdge = (args, { argTypes }) => ({
|
|
519
|
+
props: Object.keys(argTypes),
|
|
520
|
+
components,
|
|
521
|
+
template: wrap(
|
|
522
|
+
`
|
|
523
|
+
<gl-dropdown-item>First item</gl-dropdown-item>
|
|
524
|
+
<gl-dropdown-item>Second item</gl-dropdown-item>
|
|
525
|
+
<gl-dropdown-item>Third item</gl-dropdown-item>
|
|
526
|
+
<gl-dropdown-item>Fourth item</gl-dropdown-item>
|
|
527
|
+
`,
|
|
528
|
+
200,
|
|
529
|
+
'gl-display-block gl-text-right'
|
|
530
|
+
),
|
|
531
|
+
mounted() {
|
|
532
|
+
clickDropdown(this);
|
|
533
|
+
},
|
|
534
|
+
updated() {
|
|
535
|
+
addClass(this);
|
|
536
|
+
},
|
|
537
|
+
});
|
|
538
|
+
OnRightEdge.args = generateProps({ text: 'Some dropdown' });
|
|
539
|
+
|
|
517
540
|
export default {
|
|
518
541
|
title: 'base/dropdown',
|
|
519
542
|
component: GlDropdown,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import Vue from 'vue';
|
|
4
4
|
import { BDropdown } from 'bootstrap-vue';
|
|
5
5
|
import { isVisible, selectAll } from 'bootstrap-vue/src/utils/dom';
|
|
6
|
+
import { merge } from 'lodash';
|
|
6
7
|
import {
|
|
7
8
|
buttonCategoryOptions,
|
|
8
9
|
buttonSizeOptions,
|
|
@@ -33,6 +34,15 @@ const ExtendedBDropdown = Vue.extend(BDropdown, {
|
|
|
33
34
|
},
|
|
34
35
|
});
|
|
35
36
|
|
|
37
|
+
export const DefaultPopperOptions = {
|
|
38
|
+
modifiers: {
|
|
39
|
+
flip: {
|
|
40
|
+
flipVariationsByContent: true,
|
|
41
|
+
padding: 28,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
36
46
|
export default {
|
|
37
47
|
components: {
|
|
38
48
|
BDropdown: ExtendedBDropdown,
|
|
@@ -146,6 +156,11 @@ export default {
|
|
|
146
156
|
required: false,
|
|
147
157
|
default: false,
|
|
148
158
|
},
|
|
159
|
+
popperOpts: {
|
|
160
|
+
type: Object,
|
|
161
|
+
required: false,
|
|
162
|
+
default: null,
|
|
163
|
+
},
|
|
149
164
|
},
|
|
150
165
|
computed: {
|
|
151
166
|
renderCaret() {
|
|
@@ -199,6 +214,9 @@ export default {
|
|
|
199
214
|
(this.hasHighlightedItemsContent && this.showHighlightedItemsTitle) || this.showClearAll
|
|
200
215
|
);
|
|
201
216
|
},
|
|
217
|
+
popperOptions() {
|
|
218
|
+
return merge({}, DefaultPopperOptions, this.popperOpts);
|
|
219
|
+
},
|
|
202
220
|
},
|
|
203
221
|
methods: {
|
|
204
222
|
hasSlotContents(slotName) {
|
|
@@ -227,6 +245,7 @@ export default {
|
|
|
227
245
|
:block="block"
|
|
228
246
|
:disabled="disabled || loading"
|
|
229
247
|
:right="right"
|
|
248
|
+
:popper-opts="popperOptions"
|
|
230
249
|
v-on="$listeners"
|
|
231
250
|
>
|
|
232
251
|
<div class="gl-new-dropdown-inner">
|
|
@@ -15,12 +15,14 @@ describe('sorting item component', () => {
|
|
|
15
15
|
const createComponent = (propsData) => {
|
|
16
16
|
wrapper = shallowMount(GlSortingItem, {
|
|
17
17
|
context: {
|
|
18
|
-
children: [sortingItemText],
|
|
19
18
|
props: {
|
|
20
19
|
...defaultProps,
|
|
21
20
|
...propsData,
|
|
22
21
|
},
|
|
23
22
|
},
|
|
23
|
+
slots: {
|
|
24
|
+
default: sortingItemText,
|
|
25
|
+
},
|
|
24
26
|
stubs: {
|
|
25
27
|
GlDropdownItem,
|
|
26
28
|
},
|
|
@@ -39,7 +39,7 @@ export default {
|
|
|
39
39
|
* The content of the item.
|
|
40
40
|
* @slot default
|
|
41
41
|
*/
|
|
42
|
-
render(createElement, {
|
|
42
|
+
render(createElement, { scopedSlots, data, props = {} }) {
|
|
43
43
|
const classNames = `gl-sorting-item js-active-icon gl-flex-shrink-0 gl-mr-2 ${
|
|
44
44
|
props.active ? '' : 'inactive gl-visibility-hidden'
|
|
45
45
|
}`;
|
|
@@ -52,16 +52,15 @@ export default {
|
|
|
52
52
|
},
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
return createElement(
|
|
56
|
-
|
|
57
|
-
{
|
|
58
|
-
...
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
return createElement(GlDropdownItem, {
|
|
56
|
+
...data,
|
|
57
|
+
attrs: {
|
|
58
|
+
...props,
|
|
59
|
+
},
|
|
60
|
+
scopedSlots: {
|
|
61
|
+
default: () => [icon, scopedSlots.default?.()],
|
|
62
62
|
},
|
|
63
|
-
|
|
64
|
-
);
|
|
63
|
+
});
|
|
65
64
|
},
|
|
66
65
|
};
|
|
67
66
|
</script>
|