@gitlab/ui 64.5.0 → 64.6.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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [64.6.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.6.0...v64.6.1) (2023-06-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **GlChart:** ResizeObserver loop limit exceeded on responsive charts ([7952ae8](https://gitlab.com/gitlab-org/gitlab-ui/commit/7952ae86a22e200ff2bc4f9f8cf172de8e30b6f2))
7
+
8
+ # [64.6.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.5.0...v64.6.0) (2023-06-08)
9
+
10
+
11
+ ### Features
12
+
13
+ * **GlDisclosureDropdown:** add `block` prop ([39f3a3d](https://gitlab.com/gitlab-org/gitlab-ui/commit/39f3a3db2892fe10bcc91819727ef2da59bcdd45))
14
+
1
15
  # [64.5.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.4.0...v64.5.0) (2023-06-07)
2
16
 
3
17
 
@@ -153,6 +153,14 @@ var script = {
153
153
  required: false,
154
154
  default: null
155
155
  },
156
+ /**
157
+ * Render the toggle button as a block element
158
+ */
159
+ block: {
160
+ type: Boolean,
161
+ required: false,
162
+ default: false
163
+ },
156
164
  /**
157
165
  * Custom offset to be applied to Floating UI's offset middleware.
158
166
  * https://floating-ui.com/docs/offset
@@ -303,7 +311,7 @@ var script = {
303
311
  const __vue_script__ = script;
304
312
 
305
313
  /* template */
306
- 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,"offset":_vm.dropdownOffset,"fluid-width":_vm.fluidWidth,"positioning-strategy":_vm.positioningStrategy},on:_vm._d({},[_vm.$options.events.GL_DROPDOWN_SHOWN,_vm.onShow,_vm.$options.events.GL_DROPDOWN_HIDDEN,_vm.onHide,_vm.$options.events.GL_DROPDOWN_FOCUS_CONTENT,_vm.onKeydown]),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.disclosureTag,{ref:"content",tag:"component",class:_vm.$options.GL_DROPDOWN_CONTENTS_CLASS,attrs:{"id":_vm.disclosureId,"aria-labelledby":_vm.listAriaLabelledBy || _vm.toggleId,"data-testid":"disclosure-content","tabindex":"-1"},on:{"keydown":_vm.onKeydown,"click":_vm.handleAutoClose}},[_vm._t("default",function(){return [_vm._l((_vm.items),function(item,index){return [(_vm.isItem(item))?[_c('gl-disclosure-dropdown-item',{key:_vm.uniqueItemId(),attrs:{"item":item},on:{"action":_vm.handleAction},scopedSlots:_vm._u([{key:"list-item",fn:function(){return [_vm._t("list-item",null,{"item":item})]},proxy:true}],null,true)})]:[_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:_vm.uniqueItemId(),attrs:{"item":groupItem},on:{"action":_vm.handleAction},scopedSlots:_vm._u([{key:"list-item",fn:function(){return [_vm._t("list-item",null,{"item":groupItem})]},proxy:true}],null,true)})}):_vm._e()],2)]]})]})],2),_vm._v(" "),_vm._t("footer")],2)};
314
+ 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,"block":_vm.block,"offset":_vm.dropdownOffset,"fluid-width":_vm.fluidWidth,"positioning-strategy":_vm.positioningStrategy},on:_vm._d({},[_vm.$options.events.GL_DROPDOWN_SHOWN,_vm.onShow,_vm.$options.events.GL_DROPDOWN_HIDDEN,_vm.onHide,_vm.$options.events.GL_DROPDOWN_FOCUS_CONTENT,_vm.onKeydown]),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.disclosureTag,{ref:"content",tag:"component",class:_vm.$options.GL_DROPDOWN_CONTENTS_CLASS,attrs:{"id":_vm.disclosureId,"aria-labelledby":_vm.listAriaLabelledBy || _vm.toggleId,"data-testid":"disclosure-content","tabindex":"-1"},on:{"keydown":_vm.onKeydown,"click":_vm.handleAutoClose}},[_vm._t("default",function(){return [_vm._l((_vm.items),function(item,index){return [(_vm.isItem(item))?[_c('gl-disclosure-dropdown-item',{key:_vm.uniqueItemId(),attrs:{"item":item},on:{"action":_vm.handleAction},scopedSlots:_vm._u([{key:"list-item",fn:function(){return [_vm._t("list-item",null,{"item":item})]},proxy:true}],null,true)})]:[_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:_vm.uniqueItemId(),attrs:{"item":groupItem},on:{"action":_vm.handleAction},scopedSlots:_vm._u([{key:"list-item",fn:function(){return [_vm._t("list-item",null,{"item":groupItem})]},proxy:true}],null,true)})}):_vm._e()],2)]]})]})],2),_vm._v(" "),_vm._t("footer")],2)};
307
315
  var __vue_staticRenderFns__ = [];
308
316
 
309
317
  /* style */
@@ -2,6 +2,7 @@ import * as echarts from 'echarts';
2
2
  import { validRenderers, defaultWidth, defaultHeight, toolboxHeight } from '../../../utils/charts/config';
3
3
  import { themeName, createTheme } from '../../../utils/charts/theme';
4
4
  import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
5
+ import { debounceByAnimationFrame } from '../../../utils/utils';
5
6
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
6
7
 
7
8
  //
@@ -90,7 +91,8 @@ var script = {
90
91
  },
91
92
  data() {
92
93
  return {
93
- chart: null
94
+ chart: null,
95
+ debouncedHandleResize: debounceByAnimationFrame(this.handleResize)
94
96
  };
95
97
  },
96
98
  computed: {
@@ -169,7 +171,7 @@ var script = {
169
171
  });
170
172
  },
171
173
  handleResize() {
172
- if (this.responsive) this.chart.resize();
174
+ this.chart.resize();
173
175
  }
174
176
  }
175
177
  };
@@ -178,7 +180,7 @@ var script = {
178
180
  const __vue_script__ = script;
179
181
 
180
182
  /* template */
181
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:"resize-observer",rawName:"v-resize-observer",value:(_vm.handleResize),expression:"handleResize"}],ref:"chart"})};
183
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:"resize-observer",rawName:"v-resize-observer:[responsive]",value:(_vm.debouncedHandleResize),expression:"debouncedHandleResize",arg:_vm.responsive}],ref:"chart"})};
182
184
  var __vue_staticRenderFns__ = [];
183
185
 
184
186
  /* style */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "64.5.0",
3
+ "version": "64.6.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -318,6 +318,20 @@ describe('GlDisclosureDropdown', () => {
318
318
  });
319
319
  });
320
320
 
321
+ describe('block prop', () => {
322
+ it('is disabled by default', () => {
323
+ buildWrapper();
324
+
325
+ expect(findBaseDropdown().props('block')).toBe(false);
326
+ });
327
+
328
+ it('is enabled when `block` is `true`', () => {
329
+ buildWrapper({ block: true });
330
+
331
+ expect(findBaseDropdown().props('block')).toBe(true);
332
+ });
333
+ });
334
+
321
335
  describe('fluid width', () => {
322
336
  it('is disabled by default', () => {
323
337
  buildWrapper();
@@ -39,6 +39,7 @@ const makeBindings = (overrides = {}) =>
39
39
  ':icon': 'icon',
40
40
  ':toggle-aria-labelled-by': 'toggleAriaLabelledBy',
41
41
  ':list-aria-labelled-by': 'listAriaLabelledBy',
42
+ ':block': 'block',
42
43
  ':fluid-width': 'fluidWidth',
43
44
  ':auto-close': 'autoClose',
44
45
  ':positioning-strategy': 'positioningStrategy',
@@ -203,6 +204,7 @@ export const CustomGroupsAndItems = (args, { argTypes }) => ({
203
204
  CustomGroupsAndItems.args = {
204
205
  items: mockGroupsCustomItem,
205
206
  toggleText: 'Merge requests',
207
+ block: true,
206
208
  };
207
209
  CustomGroupsAndItems.decorators = [makeContainer({ height: '200px' })];
208
210
 
@@ -172,6 +172,14 @@ export default {
172
172
  required: false,
173
173
  default: null,
174
174
  },
175
+ /**
176
+ * Render the toggle button as a block element
177
+ */
178
+ block: {
179
+ type: Boolean,
180
+ required: false,
181
+ default: false,
182
+ },
175
183
  /**
176
184
  * Custom offset to be applied to Floating UI's offset middleware.
177
185
  * https://floating-ui.com/docs/offset
@@ -334,6 +342,7 @@ export default {
334
342
  :loading="loading"
335
343
  :no-caret="noCaret"
336
344
  :placement="placement"
345
+ :block="block"
337
346
  :offset="dropdownOffset"
338
347
  :fluid-width="fluidWidth"
339
348
  :positioning-strategy="positioningStrategy"
@@ -2,6 +2,7 @@ import { shallowMount } from '@vue/test-utils';
2
2
  import * as echarts from 'echarts';
3
3
  import { toolboxHeight } from '~/utils/charts/config';
4
4
  import { createTheme } from '~/utils/charts/theme';
5
+ import { waitForAnimationFrame } from '~/utils/test_utils';
5
6
  import { useMockResizeObserver } from '~helpers/mock_dom_observer';
6
7
  import Chart from './chart.vue';
7
8
 
@@ -47,15 +48,19 @@ describe('chart component', () => {
47
48
  expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(1);
48
49
 
49
50
  triggerResize(wrapper.element);
51
+ await waitForAnimationFrame();
52
+
50
53
  expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(1);
51
54
  });
52
55
 
53
- it('resizes the chart when responsive = true', async () => {
56
+ it('resizes the chart only once per animation frame when responsive = true', async () => {
54
57
  wrapper = shallowMount(Chart, { propsData: { options: {}, responsive: true } });
55
58
  await wrapper.vm.$nextTick();
56
59
  expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(1);
57
60
 
58
61
  triggerResize(wrapper.element);
62
+ triggerResize(wrapper.element);
63
+ await waitForAnimationFrame();
59
64
 
60
65
  expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(2);
61
66
  });
@@ -9,6 +9,7 @@ import {
9
9
  } from '../../../utils/charts/config';
10
10
  import { createTheme, themeName } from '../../../utils/charts/theme';
11
11
  import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
12
+ import { debounceByAnimationFrame } from '../../../utils/utils';
12
13
 
13
14
  /**
14
15
  * Allowed values by eCharts
@@ -95,6 +96,7 @@ export default {
95
96
  data() {
96
97
  return {
97
98
  chart: null,
99
+ debouncedHandleResize: debounceByAnimationFrame(this.handleResize),
98
100
  };
99
101
  },
100
102
  computed: {
@@ -175,12 +177,12 @@ export default {
175
177
  this.$emit('chartItemClicked', { chart: this.chart, params });
176
178
  },
177
179
  handleResize() {
178
- if (this.responsive) this.chart.resize();
180
+ this.chart.resize();
179
181
  },
180
182
  },
181
183
  };
182
184
  </script>
183
185
 
184
186
  <template>
185
- <div ref="chart" v-resize-observer="handleResize"></div>
187
+ <div ref="chart" v-resize-observer:[responsive]="debouncedHandleResize"></div>
186
188
  </template>