@gitlab/ui 32.10.2 → 32.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/CHANGELOG.md +7 -0
- package/dist/components/base/dropdown/dropdown.js +26 -1
- package/dist/components/base/dropdown/examples/dropdown.with_highlighted_items.example.js +38 -0
- package/dist/components/base/dropdown/examples/index.js +6 -0
- package/package.json +2 -2
- package/src/components/base/dropdown/dropdown.spec.js +83 -1
- package/src/components/base/dropdown/dropdown.stories.js +42 -0
- package/src/components/base/dropdown/dropdown.vue +55 -10
- package/src/components/base/dropdown/examples/dropdown.with_highlighted_items.example.vue +9 -0
- package/src/components/base/dropdown/examples/index.js +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [32.11.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v32.10.2...v32.11.0) (2021-09-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **GlDropdown:** Adds highlighted items slot ([3ac35ed](https://gitlab.com/gitlab-org/gitlab-ui/commit/3ac35edcc307963a2695602567027b6c9019c7d5))
|
|
7
|
+
|
|
1
8
|
## [32.10.2](https://gitlab.com/gitlab-org/gitlab-ui/compare/v32.10.1...v32.10.2) (2021-09-15)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -5,6 +5,7 @@ import ButtonMixin from '../../mixins/button_mixin';
|
|
|
5
5
|
import GlButton from '../button/button';
|
|
6
6
|
import GlIcon from '../icon/icon';
|
|
7
7
|
import GlLoadingIcon from '../loading_icon/loading_icon';
|
|
8
|
+
import GlDropdownDivider from './dropdown_divider';
|
|
8
9
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
9
10
|
|
|
10
11
|
function filterVisible(els) {
|
|
@@ -28,6 +29,7 @@ var script = {
|
|
|
28
29
|
components: {
|
|
29
30
|
BDropdown: ExtendedBDropdown,
|
|
30
31
|
GlButton,
|
|
32
|
+
GlDropdownDivider,
|
|
31
33
|
GlIcon,
|
|
32
34
|
GlLoadingIcon
|
|
33
35
|
},
|
|
@@ -58,6 +60,21 @@ var script = {
|
|
|
58
60
|
required: false,
|
|
59
61
|
default: ''
|
|
60
62
|
},
|
|
63
|
+
showHighlightedItemsTitle: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
required: false,
|
|
66
|
+
default: true
|
|
67
|
+
},
|
|
68
|
+
highlightedItemsTitle: {
|
|
69
|
+
type: String,
|
|
70
|
+
required: false,
|
|
71
|
+
default: 'Selected'
|
|
72
|
+
},
|
|
73
|
+
highlightedItemsTitleClass: {
|
|
74
|
+
type: String,
|
|
75
|
+
required: false,
|
|
76
|
+
default: 'gl-px-5'
|
|
77
|
+
},
|
|
61
78
|
textSrOnly: {
|
|
62
79
|
type: Boolean,
|
|
63
80
|
required: false,
|
|
@@ -156,6 +173,14 @@ var script = {
|
|
|
156
173
|
|
|
157
174
|
buttonText() {
|
|
158
175
|
return this.split && this.icon ? null : this.text;
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
hasHighlightedItemsContent() {
|
|
179
|
+
return this.hasSlotContents('highlighted-items');
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
hasHighlightedItemsOrClearAll() {
|
|
183
|
+
return this.showHighlightedItemsTitle || this.showClearAll;
|
|
159
184
|
}
|
|
160
185
|
|
|
161
186
|
},
|
|
@@ -179,7 +204,7 @@ var script = {
|
|
|
179
204
|
const __vue_script__ = script;
|
|
180
205
|
|
|
181
206
|
/* template */
|
|
182
|
-
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",[(_vm.loading)?_c('gl-loading-icon',{staticClass:"gl-mr-2"}):_vm._e(),_vm._v(" "),(_vm.icon)?_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",[_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.
|
|
207
|
+
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",[(_vm.loading)?_c('gl-loading-icon',{staticClass:"gl-mr-2"}):_vm._e(),_vm._v(" "),(_vm.icon)?_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",[_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",class:_vm.highlightedItemsTitleClass},[_c('div',{staticClass:"gl-display-flex"},[(_vm.hasHighlightedItemsContent && _vm.showHighlightedItemsTitle)?_c('span',{staticClass:"gl-font-weight-bold",attrs:{"data-testid":"highlighted-items-title"}},[_vm._v(_vm._s(_vm.highlightedItemsTitle))]):_vm._e()]),_vm._v(" "),_c('div',{staticClass:"gl-display-flex"},[(_vm.showClearAll)?_c('gl-button',{attrs:{"size":"small","category":"tertiary","variant":"link","data-testid":"clear-all-button"},on:{"click":function($event){return _vm.$emit('clear-all')}}},[_vm._v(_vm._s(_vm.clearAllText))]):_vm._e()],1)]):_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()])])};
|
|
183
208
|
var __vue_staticRenderFns__ = [];
|
|
184
209
|
|
|
185
210
|
/* style */
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
2
|
+
|
|
3
|
+
/* script */
|
|
4
|
+
|
|
5
|
+
/* template */
|
|
6
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-dropdown',{attrs:{"text":"Some dropdown"},scopedSlots:_vm._u([{key:"highlighted-items",fn:function(){return [_c('gl-dropdown-item',[_vm._v("First item")]),_vm._v(" "),_c('gl-dropdown-item',[_vm._v("Second item")])]},proxy:true}])},[_vm._v(" "),_c('gl-dropdown-item',[_vm._v("Last item")])],1)};
|
|
7
|
+
var __vue_staticRenderFns__ = [];
|
|
8
|
+
|
|
9
|
+
/* style */
|
|
10
|
+
const __vue_inject_styles__ = undefined;
|
|
11
|
+
/* scoped */
|
|
12
|
+
const __vue_scope_id__ = undefined;
|
|
13
|
+
/* module identifier */
|
|
14
|
+
const __vue_module_identifier__ = undefined;
|
|
15
|
+
/* functional template */
|
|
16
|
+
const __vue_is_functional_template__ = false;
|
|
17
|
+
/* style inject */
|
|
18
|
+
|
|
19
|
+
/* style inject SSR */
|
|
20
|
+
|
|
21
|
+
/* style inject shadow dom */
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const __vue_component__ = __vue_normalize__(
|
|
26
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
27
|
+
__vue_inject_styles__,
|
|
28
|
+
{},
|
|
29
|
+
__vue_scope_id__,
|
|
30
|
+
__vue_is_functional_template__,
|
|
31
|
+
__vue_module_identifier__,
|
|
32
|
+
false,
|
|
33
|
+
undefined,
|
|
34
|
+
undefined,
|
|
35
|
+
undefined
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export default __vue_component__;
|
|
@@ -6,6 +6,7 @@ import DropdownClearAllExample from './dropdown.with_clear_all.example';
|
|
|
6
6
|
import DropdownWithDividerExample from './dropdown.with_divider.example';
|
|
7
7
|
import DropdownWithFormExample from './dropdown.with_form.example';
|
|
8
8
|
import DropdownWithHeaderExample from './dropdown.with_header.example';
|
|
9
|
+
import DropdownWithHighlightedItemsExample from './dropdown.with_highlighted_items.example';
|
|
9
10
|
import DropdownWithIcons from './dropdown.with_icons.example';
|
|
10
11
|
import DropdownWithRightAlignExample from './dropdown.with_right_align.example';
|
|
11
12
|
import DropdownWithSearchExample from './dropdown.with_search.example';
|
|
@@ -33,6 +34,11 @@ var index = [{
|
|
|
33
34
|
name: 'With Header',
|
|
34
35
|
description: 'Dropdown with section header',
|
|
35
36
|
component: DropdownWithHeaderExample
|
|
37
|
+
}, {
|
|
38
|
+
id: 'new-dropdown-with-highlighted-items',
|
|
39
|
+
name: 'With Highlighted items',
|
|
40
|
+
description: 'Dropdown with highlighted items',
|
|
41
|
+
component: DropdownWithHighlightedItemsExample
|
|
36
42
|
}, {
|
|
37
43
|
id: 'new-dropdown-with-section-headers',
|
|
38
44
|
name: 'With Section Headers',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.11.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@babel/standalone": "^7.0.0",
|
|
61
61
|
"bootstrap-vue": "2.18.1",
|
|
62
62
|
"copy-to-clipboard": "^3.0.8",
|
|
63
|
-
"dompurify": "^2.3.
|
|
63
|
+
"dompurify": "^2.3.2",
|
|
64
64
|
"echarts": "^4.9.0",
|
|
65
65
|
"highlight.js": "^10.6.0",
|
|
66
66
|
"js-beautify": "^1.8.8",
|
|
@@ -26,11 +26,16 @@ describe('new dropdown', () => {
|
|
|
26
26
|
|
|
27
27
|
afterEach(() => wrapper.destroy());
|
|
28
28
|
|
|
29
|
+
const findByTestId = (testId) => wrapper.find(`[data-testid="${testId}"]`);
|
|
30
|
+
|
|
29
31
|
const findSplitButton = () => wrapper.find('.btn:not(.gl-dropdown-toggle)');
|
|
30
32
|
const findDropdownToggle = () => wrapper.find('.btn.gl-dropdown-toggle');
|
|
31
33
|
const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
|
|
32
34
|
const findIcon = () => wrapper.find('.dropdown-icon');
|
|
33
35
|
const findCaret = () => wrapper.find('.dropdown-chevron');
|
|
36
|
+
const findClearAll = () => findByTestId('clear-all-button');
|
|
37
|
+
const findHighlightedItemsTitle = () => findByTestId('highlighted-items-title');
|
|
38
|
+
const findHighlightedItems = () => findByTestId('highlighted-items');
|
|
34
39
|
|
|
35
40
|
it('renders when text is null', () => {
|
|
36
41
|
buildWrapper({ text: null });
|
|
@@ -225,6 +230,84 @@ describe('new dropdown', () => {
|
|
|
225
230
|
});
|
|
226
231
|
});
|
|
227
232
|
|
|
233
|
+
describe('Highlighted items', () => {
|
|
234
|
+
describe('with slot content', () => {
|
|
235
|
+
const slotContent = '<li>Highlighted items Content</li>';
|
|
236
|
+
const slots = { 'highlighted-items': slotContent };
|
|
237
|
+
|
|
238
|
+
beforeEach(() => {
|
|
239
|
+
buildWrapper({}, slots);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('renders the highlighted items', () => {
|
|
243
|
+
expect(findHighlightedItems().exists()).toBe(true);
|
|
244
|
+
expect(findHighlightedItems().html()).toContain(slotContent);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('renders the default highlighted items title', () => {
|
|
248
|
+
expect(findHighlightedItemsTitle().exists()).toBe(true);
|
|
249
|
+
expect(findHighlightedItemsTitle().html()).toContain('Selected');
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
describe('with showHighlightedItemsTitle=false', () => {
|
|
253
|
+
beforeEach(() => {
|
|
254
|
+
buildWrapper({ showHighlightedItemsTitle: false }, slots);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('does not render the highlighted items header', () => {
|
|
258
|
+
expect(findHighlightedItemsTitle().exists()).toBe(false);
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
describe('with showClearAll=true and showHighlightedItemsTitle=false', () => {
|
|
263
|
+
beforeEach(() => {
|
|
264
|
+
buildWrapper({ showHighlightedItemsTitle: false, showClearAll: true }, slots);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it('renders the clear all button and does not render the highlighted items title', () => {
|
|
268
|
+
expect(findClearAll().exists()).toBe(true);
|
|
269
|
+
expect(findHighlightedItemsTitle().exists()).toBe(false);
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
describe('with showClearAll=true and showHighlightedItemsTitle=true', () => {
|
|
274
|
+
beforeEach(() => {
|
|
275
|
+
buildWrapper({ showHighlightedItemsTitle: true, showClearAll: true }, slots);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('renders the clear all button and the highlighted items title', () => {
|
|
279
|
+
expect(findClearAll().exists()).toBe(true);
|
|
280
|
+
expect(findHighlightedItemsTitle().exists()).toBe(true);
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
describe('with highlightedItemsTitle set', () => {
|
|
285
|
+
const highlightedItemsTitle = 'Cool heading';
|
|
286
|
+
beforeEach(() => {
|
|
287
|
+
buildWrapper({ highlightedItemsTitle }, slots);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('sets the highlighted items title', () => {
|
|
291
|
+
expect(findHighlightedItemsTitle().exists()).toBe(true);
|
|
292
|
+
expect(findHighlightedItemsTitle().text()).not.toContain('Selected');
|
|
293
|
+
expect(findHighlightedItemsTitle().text()).toContain(highlightedItemsTitle);
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
describe('with no slot content', () => {
|
|
299
|
+
beforeEach(() => {
|
|
300
|
+
buildWrapper();
|
|
301
|
+
});
|
|
302
|
+
it('does not render the highlighted items content', () => {
|
|
303
|
+
expect(findHighlightedItems().exists()).toBe(false);
|
|
304
|
+
});
|
|
305
|
+
it('does not render the highlighted items title', () => {
|
|
306
|
+
expect(findHighlightedItemsTitle().exists()).toBe(false);
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
|
|
228
311
|
describe('button content templates', () => {
|
|
229
312
|
const mockComponent = {
|
|
230
313
|
template: '<span>mock</span>',
|
|
@@ -250,7 +333,6 @@ describe('new dropdown', () => {
|
|
|
250
333
|
});
|
|
251
334
|
|
|
252
335
|
describe('Clear all button', () => {
|
|
253
|
-
const findClearAll = () => wrapper.find('[data-testid="clear-all-button"]');
|
|
254
336
|
it('is not visible by default', () => {
|
|
255
337
|
buildWrapper({});
|
|
256
338
|
|
|
@@ -45,6 +45,9 @@ function generateProps({
|
|
|
45
45
|
hideHeaderBorder = true,
|
|
46
46
|
showClearAll = false,
|
|
47
47
|
clearAllText = '',
|
|
48
|
+
showHighlightedItemsTitle = false,
|
|
49
|
+
highlightedItemsTitle = '',
|
|
50
|
+
highlightedItemsTitleClass = '',
|
|
48
51
|
} = {}) {
|
|
49
52
|
const props = {
|
|
50
53
|
category: {
|
|
@@ -107,6 +110,18 @@ function generateProps({
|
|
|
107
110
|
type: String,
|
|
108
111
|
default: textKnob('clear all text', clearAllText),
|
|
109
112
|
},
|
|
113
|
+
showHighlightedItemsTitle: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
default: boolean('show highlighted items title', showHighlightedItemsTitle),
|
|
116
|
+
},
|
|
117
|
+
highlightedItemsTitle: {
|
|
118
|
+
type: String,
|
|
119
|
+
default: textKnob('highlighted items title', highlightedItemsTitle),
|
|
120
|
+
},
|
|
121
|
+
highlightedItemsTitleClass: {
|
|
122
|
+
type: String,
|
|
123
|
+
default: textKnob('highlighted items title class', highlightedItemsTitleClass),
|
|
124
|
+
},
|
|
110
125
|
right: {
|
|
111
126
|
type: Boolean,
|
|
112
127
|
default: boolean('right', false),
|
|
@@ -134,6 +149,9 @@ function wrap([template]) {
|
|
|
134
149
|
:hide-header-border="hideHeaderBorder"
|
|
135
150
|
:show-clear-all="showClearAll"
|
|
136
151
|
:clear-all-text="clearAllText"
|
|
152
|
+
:show-highlighted-items-title="showHighlightedItemsTitle"
|
|
153
|
+
:highlighted-items-title="highlightedItemsTitle"
|
|
154
|
+
:highlighted-items-title-class="highlightedItemsTitleClass"
|
|
137
155
|
:loading="loading"
|
|
138
156
|
:right="right"
|
|
139
157
|
>
|
|
@@ -445,6 +463,7 @@ documentedStoriesOf('base/dropdown', readme)
|
|
|
445
463
|
text: 'Some dropdown',
|
|
446
464
|
showClearAll: true,
|
|
447
465
|
clearAllText: 'Clear all',
|
|
466
|
+
highlightedItemsTitleClass: 'gl-px-5',
|
|
448
467
|
}),
|
|
449
468
|
components,
|
|
450
469
|
template: wrap`
|
|
@@ -457,4 +476,27 @@ documentedStoriesOf('base/dropdown', readme)
|
|
|
457
476
|
updated() {
|
|
458
477
|
addClass(this);
|
|
459
478
|
},
|
|
479
|
+
}))
|
|
480
|
+
.add('with highlighted items', () => ({
|
|
481
|
+
props: generateProps({
|
|
482
|
+
text: 'Some dropdown',
|
|
483
|
+
showHighlightedItemsTitle: true,
|
|
484
|
+
highlightedItemsTitle: 'Highlights',
|
|
485
|
+
highlightedItemsTitleClass: 'gl-px-5',
|
|
486
|
+
}),
|
|
487
|
+
components,
|
|
488
|
+
template: wrap`
|
|
489
|
+
<template #highlighted-items>
|
|
490
|
+
<gl-dropdown-item :is-check-item="true" :is-checked="true">First item</gl-dropdown-item>
|
|
491
|
+
<gl-dropdown-item :is-check-item="true" :is-checked="true">Second item</gl-dropdown-item>
|
|
492
|
+
</template>
|
|
493
|
+
<gl-dropdown-item>Third item</gl-dropdown-item>
|
|
494
|
+
<gl-dropdown-item>Fourth item</gl-dropdown-item>
|
|
495
|
+
`,
|
|
496
|
+
mounted() {
|
|
497
|
+
clickDropdown(this);
|
|
498
|
+
},
|
|
499
|
+
updated() {
|
|
500
|
+
addClass(this);
|
|
501
|
+
},
|
|
460
502
|
}));
|
|
@@ -10,6 +10,7 @@ import ButtonMixin from '../../mixins/button_mixin';
|
|
|
10
10
|
import GlButton from '../button/button.vue';
|
|
11
11
|
import GlIcon from '../icon/icon.vue';
|
|
12
12
|
import GlLoadingIcon from '../loading_icon/loading_icon.vue';
|
|
13
|
+
import GlDropdownDivider from './dropdown_divider.vue';
|
|
13
14
|
|
|
14
15
|
// Return an Array of visible items
|
|
15
16
|
function filterVisible(els) {
|
|
@@ -35,6 +36,7 @@ export default {
|
|
|
35
36
|
components: {
|
|
36
37
|
BDropdown: ExtendedBDropdown,
|
|
37
38
|
GlButton,
|
|
39
|
+
GlDropdownDivider,
|
|
38
40
|
GlIcon,
|
|
39
41
|
GlLoadingIcon,
|
|
40
42
|
},
|
|
@@ -65,6 +67,21 @@ export default {
|
|
|
65
67
|
required: false,
|
|
66
68
|
default: '',
|
|
67
69
|
},
|
|
70
|
+
showHighlightedItemsTitle: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
required: false,
|
|
73
|
+
default: true,
|
|
74
|
+
},
|
|
75
|
+
highlightedItemsTitle: {
|
|
76
|
+
type: String,
|
|
77
|
+
required: false,
|
|
78
|
+
default: 'Selected',
|
|
79
|
+
},
|
|
80
|
+
highlightedItemsTitleClass: {
|
|
81
|
+
type: String,
|
|
82
|
+
required: false,
|
|
83
|
+
default: 'gl-px-5',
|
|
84
|
+
},
|
|
68
85
|
textSrOnly: {
|
|
69
86
|
type: Boolean,
|
|
70
87
|
required: false,
|
|
@@ -166,6 +183,12 @@ export default {
|
|
|
166
183
|
buttonText() {
|
|
167
184
|
return this.split && this.icon ? null : this.text;
|
|
168
185
|
},
|
|
186
|
+
hasHighlightedItemsContent() {
|
|
187
|
+
return this.hasSlotContents('highlighted-items');
|
|
188
|
+
},
|
|
189
|
+
hasHighlightedItemsOrClearAll() {
|
|
190
|
+
return this.showHighlightedItemsTitle || this.showClearAll;
|
|
191
|
+
},
|
|
169
192
|
},
|
|
170
193
|
methods: {
|
|
171
194
|
hasSlotContents(slotName) {
|
|
@@ -180,7 +203,6 @@ export default {
|
|
|
180
203
|
},
|
|
181
204
|
};
|
|
182
205
|
</script>
|
|
183
|
-
|
|
184
206
|
<template>
|
|
185
207
|
<b-dropdown
|
|
186
208
|
ref="dropdown"
|
|
@@ -207,17 +229,40 @@ export default {
|
|
|
207
229
|
</p>
|
|
208
230
|
<slot name="header"></slot>
|
|
209
231
|
</div>
|
|
210
|
-
<div
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
232
|
+
<div
|
|
233
|
+
v-if="hasHighlightedItemsOrClearAll"
|
|
234
|
+
class="gl-display-flex gl-flex-direction-row gl-justify-content-space-between gl-align-items-center"
|
|
235
|
+
:class="highlightedItemsTitleClass"
|
|
236
|
+
>
|
|
237
|
+
<div class="gl-display-flex">
|
|
238
|
+
<span
|
|
239
|
+
v-if="hasHighlightedItemsContent && showHighlightedItemsTitle"
|
|
240
|
+
class="gl-font-weight-bold"
|
|
241
|
+
data-testid="highlighted-items-title"
|
|
242
|
+
>{{ highlightedItemsTitle }}</span
|
|
243
|
+
>
|
|
244
|
+
</div>
|
|
245
|
+
<div class="gl-display-flex">
|
|
246
|
+
<gl-button
|
|
247
|
+
v-if="showClearAll"
|
|
248
|
+
size="small"
|
|
249
|
+
category="tertiary"
|
|
250
|
+
variant="link"
|
|
251
|
+
data-testid="clear-all-button"
|
|
252
|
+
@click="$emit('clear-all')"
|
|
253
|
+
>{{ clearAllText }}</gl-button
|
|
254
|
+
>
|
|
255
|
+
</div>
|
|
219
256
|
</div>
|
|
220
257
|
<div class="gl-new-dropdown-contents">
|
|
258
|
+
<div
|
|
259
|
+
v-if="hasHighlightedItemsContent"
|
|
260
|
+
class="gl-overflow-visible"
|
|
261
|
+
data-testid="highlighted-items"
|
|
262
|
+
>
|
|
263
|
+
<slot name="highlighted-items"></slot>
|
|
264
|
+
<gl-dropdown-divider />
|
|
265
|
+
</div>
|
|
221
266
|
<slot></slot>
|
|
222
267
|
</div>
|
|
223
268
|
<div v-if="hasSlotContents('footer')" class="gl-new-dropdown-footer">
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<gl-dropdown text="Some dropdown">
|
|
3
|
+
<template #highlighted-items>
|
|
4
|
+
<gl-dropdown-item>First item</gl-dropdown-item>
|
|
5
|
+
<gl-dropdown-item>Second item</gl-dropdown-item>
|
|
6
|
+
</template>
|
|
7
|
+
<gl-dropdown-item>Last item</gl-dropdown-item>
|
|
8
|
+
</gl-dropdown>
|
|
9
|
+
</template>
|
|
@@ -6,6 +6,7 @@ import DropdownClearAllExample from './dropdown.with_clear_all.example.vue';
|
|
|
6
6
|
import DropdownWithDividerExample from './dropdown.with_divider.example.vue';
|
|
7
7
|
import DropdownWithFormExample from './dropdown.with_form.example.vue';
|
|
8
8
|
import DropdownWithHeaderExample from './dropdown.with_header.example.vue';
|
|
9
|
+
import DropdownWithHighlightedItemsExample from './dropdown.with_highlighted_items.example.vue';
|
|
9
10
|
import DropdownWithIcons from './dropdown.with_icons.example.vue';
|
|
10
11
|
import DropdownWithRightAlignExample from './dropdown.with_right_align.example.vue';
|
|
11
12
|
import DropdownWithSearchExample from './dropdown.with_search.example.vue';
|
|
@@ -39,6 +40,12 @@ export default [
|
|
|
39
40
|
description: 'Dropdown with section header',
|
|
40
41
|
component: DropdownWithHeaderExample,
|
|
41
42
|
},
|
|
43
|
+
{
|
|
44
|
+
id: 'new-dropdown-with-highlighted-items',
|
|
45
|
+
name: 'With Highlighted items',
|
|
46
|
+
description: 'Dropdown with highlighted items',
|
|
47
|
+
component: DropdownWithHighlightedItemsExample,
|
|
48
|
+
},
|
|
42
49
|
{
|
|
43
50
|
id: 'new-dropdown-with-section-headers',
|
|
44
51
|
name: 'With Section Headers',
|