@gitlab/ui 53.1.0 → 53.2.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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [53.2.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v53.1.0...v53.2.0) (2023-01-23)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlDisclosureDropdown:** Allow to provide custom item template for groups ([c3034b8](https://gitlab.com/gitlab-org/gitlab-ui/commit/c3034b87ae093daae7b0817a2535abefa0a7dcad))
7
+
1
8
  # [53.1.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v53.0.1...v53.1.0) (2023-01-23)
2
9
 
3
10
 
@@ -257,7 +257,7 @@ var script = {
257
257
  const __vue_script__ = script;
258
258
 
259
259
  /* template */
260
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-base-dropdown',{ref:"baseDropdown",staticClass:"gl-disclosure-dropdown",attrs:{"aria-labelledby":_vm.toggleAriaLabelledBy,"toggle-id":_vm.toggleId,"toggle-text":_vm.toggleText,"toggle-class":_vm.toggleClass,"text-sr-only":_vm.textSrOnly,"category":_vm.category,"variant":_vm.variant,"size":_vm.size,"icon":_vm.icon,"disabled":_vm.disabled,"loading":_vm.loading,"no-caret":_vm.noCaret,"placement":_vm.placement},on:_vm._d({},[_vm.$options.events.GL_DROPDOWN_SHOWN,_vm.onShow,_vm.$options.events.GL_DROPDOWN_HIDDEN,_vm.onHide]),scopedSlots:_vm._u([(_vm.hasCustomToggle)?{key:"toggle",fn:function(){return [_vm._t("toggle")]},proxy:true}:null],null,true)},[_vm._v(" "),_vm._t("header"),_vm._v(" "),_c(_vm.disclosureOptions.tag,{ref:"content",tag:"component",staticClass:"gl-dropdown-contents gl-list-style-none gl-pl-0 gl-mb-0",attrs:{"id":_vm.disclosureId,"role":_vm.disclosureOptions.role,"aria-labelledby":_vm.listAriaLabelledBy || _vm.toggleId,"data-testid":"disclosure-content","tabindex":"-1"},on:{"keydown":_vm.onKeydown}},[_vm._t("default",function(){return [_vm._l((_vm.items),function(item,index){return [(_vm.isItem(item))?[_c('gl-disclosure-dropdown-item',{key:item.text,attrs:{"item":item},on:{"action":_vm.handleAction}},[_vm._t("list-item",null,{"item":item})],2)]:[_c('gl-disclosure-dropdown-group',{key:item.name,attrs:{"bordered":index !== 0,"group":item},on:{"action":_vm.handleAction},scopedSlots:_vm._u([(_vm.$scopedSlots['group-label'])?{key:"group-label",fn:function(){return [_vm._t("group-label",null,{"group":item})]},proxy:true}:null,{key:"list-item",fn:function(){return [_vm._t("list-item")]},proxy:true}],null,true)})]]})]})],2),_vm._v(" "),_vm._t("footer")],2)};
260
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-base-dropdown',{ref:"baseDropdown",staticClass:"gl-disclosure-dropdown",attrs:{"aria-labelledby":_vm.toggleAriaLabelledBy,"toggle-id":_vm.toggleId,"toggle-text":_vm.toggleText,"toggle-class":_vm.toggleClass,"text-sr-only":_vm.textSrOnly,"category":_vm.category,"variant":_vm.variant,"size":_vm.size,"icon":_vm.icon,"disabled":_vm.disabled,"loading":_vm.loading,"no-caret":_vm.noCaret,"placement":_vm.placement},on:_vm._d({},[_vm.$options.events.GL_DROPDOWN_SHOWN,_vm.onShow,_vm.$options.events.GL_DROPDOWN_HIDDEN,_vm.onHide]),scopedSlots:_vm._u([(_vm.hasCustomToggle)?{key:"toggle",fn:function(){return [_vm._t("toggle")]},proxy:true}:null],null,true)},[_vm._v(" "),_vm._t("header"),_vm._v(" "),_c(_vm.disclosureOptions.tag,{ref:"content",tag:"component",staticClass:"gl-dropdown-contents gl-list-style-none gl-pl-0 gl-mb-0",attrs:{"id":_vm.disclosureId,"role":_vm.disclosureOptions.role,"aria-labelledby":_vm.listAriaLabelledBy || _vm.toggleId,"data-testid":"disclosure-content","tabindex":"-1"},on:{"keydown":_vm.onKeydown}},[_vm._t("default",function(){return [_vm._l((_vm.items),function(item,index){return [(_vm.isItem(item))?[_c('gl-disclosure-dropdown-item',{key:item.text,attrs:{"item":item},on:{"action":_vm.handleAction}},[_vm._t("list-item",null,{"item":item})],2)]:[_c('gl-disclosure-dropdown-group',{key:item.name,attrs:{"bordered":index !== 0,"group":item},on:{"action":_vm.handleAction},scopedSlots:_vm._u([(_vm.$scopedSlots['group-label'])?{key:"group-label",fn:function(){return [_vm._t("group-label",null,{"group":item})]},proxy:true}:null],null,true)},[_vm._v(" "),(_vm.$scopedSlots['list-item'])?_vm._l((item.items),function(groupItem){return _c('gl-disclosure-dropdown-item',{key:groupItem.text,on:{"action":_vm.handleAction}},[_vm._t("list-item",null,{"item":groupItem})],2)}):_vm._e()],2)]]})]})],2),_vm._v(" "),_vm._t("footer")],2)};
261
261
  var __vue_staticRenderFns__ = [];
262
262
 
263
263
  /* style */
@@ -42,6 +42,18 @@ const mockItemsCustomItem = [{
42
42
  rel: 'nofollow'
43
43
  }
44
44
  }];
45
+ const mockGroupsCustomItem = [{
46
+ name: 'Merge requests',
47
+ items: [{
48
+ text: 'Assigned to you',
49
+ href: 'https://gitlab.com/dashboard/merge_requests?assignee_username=root',
50
+ count: 1
51
+ }, {
52
+ text: 'Review requests from you',
53
+ href: 'https://gitlab.com/dashboard/merge_requests?reviewer_username=root',
54
+ count: 4
55
+ }]
56
+ }];
45
57
  const mockGroups = [{
46
58
  name: 'This project',
47
59
  items: [{
@@ -125,4 +137,4 @@ const mockProfileGroups = [{
125
137
  }]
126
138
  }];
127
139
 
128
- export { mockGroups, mockItems, mockItemsCustomItem, mockProfileGroups };
140
+ export { mockGroups, mockGroupsCustomItem, mockItems, mockItemsCustomItem, mockProfileGroups };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "53.1.0",
3
+ "version": "53.2.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -16,7 +16,13 @@ import {
16
16
  } from '../../../../index';
17
17
  import { makeContainer } from '../../../../utils/story_decorators/container';
18
18
  import readme from './disclosure_dropdown.md';
19
- import { mockItems, mockItemsCustomItem, mockGroups, mockProfileGroups } from './mock_data';
19
+ import {
20
+ mockItems,
21
+ mockItemsCustomItem,
22
+ mockGroups,
23
+ mockProfileGroups,
24
+ mockGroupsCustomItem,
25
+ } from './mock_data';
20
26
 
21
27
  const defaultValue = (prop) => GlDisclosureDropdown.props[prop].default;
22
28
 
@@ -185,6 +191,51 @@ Groups.args = generateProps({
185
191
  textSrOnly: true,
186
192
  });
187
193
 
194
+ export const CustomGroupsAndItems = (args, { argTypes }) => ({
195
+ props: Object.keys(argTypes),
196
+ components: {
197
+ GlDisclosureDropdown,
198
+ GlBadge,
199
+ },
200
+ mounted() {
201
+ if (this.startOpened) {
202
+ openDisclosure(this);
203
+ }
204
+ },
205
+ methods: {
206
+ navigate() {
207
+ this.$refs.link.click();
208
+ },
209
+ getTotalMrs(items) {
210
+ return items.reduce((acc, item) => acc + item.count, 0);
211
+ },
212
+ },
213
+ template: template(
214
+ `
215
+ <template #group-label="{ group }">
216
+ {{ group.name }} <gl-badge size="sm">{{ getTotalMrs(group.items) }}</gl-badge>
217
+ </template>
218
+ <template #list-item="{ item }">
219
+ <a ref="link" class="gl-display-flex gl-align-items-center gl-justify-content-space-between gl-hover-text-gray-900 gl-hover-text-decoration-none gl-text-gray-900" :href="item.href" v-bind="item.extraAttrs">
220
+ {{item.text}}
221
+ <gl-badge pill size="sm" v-if="item.count">{{item.count}}</gl-badge>
222
+ </a>
223
+ </template>
224
+ `,
225
+ {
226
+ bindingOverrides: {
227
+ '@action': 'navigate',
228
+ },
229
+ }
230
+ ),
231
+ });
232
+
233
+ CustomGroupsAndItems.args = generateProps({
234
+ items: mockGroupsCustomItem,
235
+ toggleText: 'Merge requests',
236
+ });
237
+ CustomGroupsAndItems.decorators = [makeContainer({ height: '200px' })];
238
+
188
239
  export const CustomGroupsItemsAndToggle = makeGroupedExample({
189
240
  template: template(`
190
241
  <template #toggle>
@@ -328,9 +328,15 @@ export default {
328
328
  <slot name="group-label" :group="item"></slot>
329
329
  </template>
330
330
 
331
- <template #list-item>
332
- <!-- @slot Custom template of the disclosure dropdown item -->
333
- <slot name="list-item"></slot>
331
+ <template v-if="$scopedSlots['list-item']">
332
+ <gl-disclosure-dropdown-item
333
+ v-for="groupItem in item.items"
334
+ :key="groupItem.text"
335
+ @action="handleAction"
336
+ >
337
+ <!-- @slot Custom template of the disclosure dropdown item -->
338
+ <slot name="list-item" :item="groupItem"></slot>
339
+ </gl-disclosure-dropdown-item>
334
340
  </template>
335
341
  </gl-disclosure-dropdown-group>
336
342
  </template>
@@ -51,6 +51,24 @@ export const mockItemsCustomItem = [
51
51
  },
52
52
  ];
53
53
 
54
+ export const mockGroupsCustomItem = [
55
+ {
56
+ name: 'Merge requests',
57
+ items: [
58
+ {
59
+ text: 'Assigned to you',
60
+ href: 'https://gitlab.com/dashboard/merge_requests?assignee_username=root',
61
+ count: 1,
62
+ },
63
+ {
64
+ text: 'Review requests from you',
65
+ href: 'https://gitlab.com/dashboard/merge_requests?reviewer_username=root',
66
+ count: 4,
67
+ },
68
+ ],
69
+ },
70
+ ];
71
+
54
72
  export const mockGroups = [
55
73
  {
56
74
  name: 'This project',