@gitlab/ui 49.1.0 → 49.2.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,18 @@
1
+ ## [49.2.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v49.2.0...v49.2.1) (2022-10-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **datepicker:** Render empty string instead of false ([678b225](https://gitlab.com/gitlab-org/gitlab-ui/commit/678b22572edbd306e859d4017055a6041c24eb4f))
7
+
8
+ # [49.2.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v49.1.0...v49.2.0) (2022-10-28)
9
+
10
+
11
+ ### Features
12
+
13
+ * **GlBadge:** add 12px icon variant ([bf47618](https://gitlab.com/gitlab-org/gitlab-ui/commit/bf476189b298b348b029fb63a6785b3d063cc1d1))
14
+ * **GlListbox:** add ability to reset selection ([68bd63f](https://gitlab.com/gitlab-org/gitlab-ui/commit/68bd63f4f9e04df94b205f21b5d4d35de34040f7))
15
+
1
16
  # [49.1.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v49.0.3...v49.1.0) (2022-10-27)
2
17
 
3
18
 
@@ -1,5 +1,5 @@
1
1
  import { BBadge } from 'bootstrap-vue/esm/index.js';
2
- import { badgeSizeOptions, badgeVariantOptions } from '../../../utils/constants';
2
+ import { badgeSizeOptions, badgeVariantOptions, badgeIconSizeOptions } from '../../../utils/constants';
3
3
  import GlIcon from '../icon/icon';
4
4
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
5
5
 
@@ -40,6 +40,15 @@ var script = {
40
40
  type: String,
41
41
  required: false,
42
42
  default: null
43
+ },
44
+ /**
45
+ * The size of the icon 16 or 12
46
+ */
47
+ iconSize: {
48
+ type: String,
49
+ default: 'md',
50
+ validator: value => Object.keys(badgeIconSizeOptions).includes(value),
51
+ required: false
43
52
  }
44
53
  },
45
54
  computed: {
@@ -49,6 +58,9 @@ var script = {
49
58
  },
50
59
  role() {
51
60
  return this.hasIconOnly ? 'img' : undefined;
61
+ },
62
+ iconSizeComputed() {
63
+ return badgeIconSizeOptions[this.iconSize];
52
64
  }
53
65
  }
54
66
  };
@@ -57,7 +69,7 @@ var script = {
57
69
  const __vue_script__ = script;
58
70
 
59
71
  /* template */
60
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-badge',_vm._b({class:['gl-badge', _vm.size],attrs:{"variant":_vm.variant,"role":_vm.role,"pill":""}},'b-badge',_vm.$attrs,false),[(_vm.icon)?_c('gl-icon',{staticClass:"gl-badge-icon",class:{ 'gl-mr-2': !_vm.hasIconOnly },attrs:{"name":_vm.icon}}):_vm._e(),_vm._v(" "),_vm._t("default")],2)};
72
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-badge',_vm._b({class:['gl-badge', _vm.size],attrs:{"variant":_vm.variant,"role":_vm.role,"pill":""}},'b-badge',_vm.$attrs,false),[(_vm.icon)?_c('gl-icon',{staticClass:"gl-badge-icon",class:{ 'gl-mr-2': !_vm.hasIconOnly },attrs:{"size":_vm.iconSizeComputed,"name":_vm.icon}}):_vm._e(),_vm._v(" "),_vm._t("default")],2)};
61
73
  var __vue_staticRenderFns__ = [];
62
74
 
63
75
  /* style */
@@ -179,7 +179,7 @@ var script = {
179
179
  },
180
180
  computed: {
181
181
  formattedDate() {
182
- return 'calendar' in this && this.calendar.toString();
182
+ return 'calendar' in this ? this.calendar.toString() : '';
183
183
  },
184
184
  customTrigger() {
185
185
  return _isString(this.target) && this.target !== '';
@@ -3,6 +3,7 @@ import _clamp from 'lodash/clamp';
3
3
  import { stopEvent } from '../../../../utils/utils';
4
4
  import { GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, HOME, END, ARROW_UP, ARROW_DOWN } from '../constants';
5
5
  import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions } from '../../../../utils/constants';
6
+ import GlButton from '../../button/button';
6
7
  import GlLoadingIcon from '../../loading_icon/loading_icon';
7
8
  import GlSearchBoxByType from '../../search_box_by_type/search_box_by_type';
8
9
  import GlBaseDropdown from '../base_dropdown/base_dropdown';
@@ -25,6 +26,7 @@ var script = {
25
26
  GlBaseDropdown,
26
27
  GlListboxItem,
27
28
  GlListboxGroup,
29
+ GlButton,
28
30
  GlSearchBoxByType,
29
31
  GlLoadingIcon
30
32
  },
@@ -206,6 +208,17 @@ var script = {
206
208
  type: String,
207
209
  required: false,
208
210
  default: 'No results found'
211
+ },
212
+ /**
213
+ * The reset button's label, to be rendered in the header. If this is omitted, the button is not
214
+ * rendered.
215
+ * The reset button requires a header to be set, so this prop should be used in conjunction with
216
+ * headerText.
217
+ */
218
+ resetButtonLabel: {
219
+ type: String,
220
+ required: false,
221
+ default: ''
209
222
  }
210
223
  },
211
224
  data() {
@@ -259,6 +272,15 @@ var script = {
259
272
  },
260
273
  headerId() {
261
274
  return this.headerText && _uniqueId('listbox-header-');
275
+ },
276
+ showResetButton() {
277
+ if (!this.resetButtonLabel) {
278
+ return false;
279
+ }
280
+ if (this.multiple) {
281
+ return this.selected.length > 0;
282
+ }
283
+ return Boolean(this.selected);
262
284
  }
263
285
  },
264
286
  watch: {
@@ -276,6 +298,11 @@ var script = {
276
298
  }
277
299
  }
278
300
  },
301
+ mounted() {
302
+ if (process.env.NODE_ENV !== 'production' && this.resetButtonLabel && !this.headerText) {
303
+ throw new Error('The reset button cannot be rendered without a header. Either provide a header via the headerText prop, or do not provide the resetButtonLabel prop.');
304
+ }
305
+ },
279
306
  methods: {
280
307
  open() {
281
308
  this.$refs.baseDropdown.open();
@@ -387,7 +414,7 @@ var script = {
387
414
  */
388
415
  this.$emit('select', value);
389
416
  }
390
- this.$refs.baseDropdown.closeAndFocus();
417
+ this.closeAndFocus();
391
418
  },
392
419
  onMultiSelect(value, isSelected) {
393
420
  if (isSelected) {
@@ -405,6 +432,18 @@ var script = {
405
432
  */
406
433
  this.$emit('search', searchTerm);
407
434
  },
435
+ onResetButtonClicked() {
436
+ /**
437
+ * Emitted when the reset button is clicked
438
+ *
439
+ * @event reset
440
+ */
441
+ this.$emit('reset');
442
+ this.closeAndFocus();
443
+ },
444
+ closeAndFocus() {
445
+ this.$refs.baseDropdown.closeAndFocus();
446
+ },
408
447
  isOption
409
448
  }
410
449
  };
@@ -413,7 +452,7 @@ var script = {
413
452
  const __vue_script__ = script;
414
453
 
415
454
  /* template */
416
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-base-dropdown',{ref:"baseDropdown",attrs:{"aria-haspopup":"listbox","aria-labelledby":_vm.toggleAriaLabelledBy,"toggle-id":_vm.toggleId,"toggle-text":_vm.listboxToggleText,"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,"right":_vm.right},on:_vm._d({},[_vm.$options.events.GL_DROPDOWN_SHOWN,_vm.onShow,_vm.$options.events.GL_DROPDOWN_HIDDEN,_vm.onHide])},[(_vm.headerText)?_c('div',{staticClass:"gl-display-flex gl-align-items-center gl-p-3",class:_vm.$options.HEADER_ITEMS_BORDER_CLASSES},[_c('div',{staticClass:"gl-flex-grow-1 gl-font-weight-bold gl-font-sm",attrs:{"id":_vm.headerId,"data-testid":"listbox-header-text"}},[_vm._v("\n "+_vm._s(_vm.headerText)+"\n ")])]):_vm._e(),_vm._v(" "),(_vm.searchable)?_c('div',{class:_vm.$options.HEADER_ITEMS_BORDER_CLASSES},[_c('gl-search-box-by-type',{ref:"searchBox",attrs:{"aria-owns":_vm.listboxId,"data-testid":"listbox-search-input"},on:{"input":_vm.search,"keydown":_vm.onKeydown},model:{value:(_vm.searchStr),callback:function ($$v) {_vm.searchStr=$$v;},expression:"searchStr"}}),_vm._v(" "),(_vm.searching)?_c('gl-loading-icon',{staticClass:"gl-my-3",attrs:{"data-testid":"listbox-search-loader","size":"md"}}):_vm._e()],1):_vm._e(),_vm._v(" "),(_vm.showList)?_c(_vm.listboxTag,{ref:"list",tag:"component",staticClass:"gl-new-dropdown-contents gl-list-style-none gl-pl-0 gl-mb-0",attrs:{"id":"listbox","aria-labelledby":_vm.listAriaLabelledBy || _vm.headerId || _vm.toggleId,"role":"listbox","tabindex":"-1"},on:{"keydown":_vm.onKeydown}},[_vm._l((_vm.items),function(item,index){return [(_vm.isOption(item))?[_c('gl-listbox-item',{key:item.value,attrs:{"is-selected":_vm.isSelected(item),"is-focused":_vm.isFocused(item),"is-check-centered":_vm.isCheckCentered},on:{"select":function($event){return _vm.onSelect(item, $event)}}},[_vm._t("list-item",function(){return [_vm._v("\n "+_vm._s(item.text)+"\n ")]},{"item":item})],2)]:[_c('gl-listbox-group',{key:item.text,class:_vm.groupClasses(index),attrs:{"name":item.text},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._l((item.options),function(option){return _c('gl-listbox-item',{key:option.value,attrs:{"is-selected":_vm.isSelected(option),"is-focused":_vm.isFocused(option),"is-check-centered":_vm.isCheckCentered},on:{"select":function($event){return _vm.onSelect(option, $event)}}},[_vm._t("list-item",function(){return [_vm._v("\n "+_vm._s(option.text)+"\n ")]},{"item":option})],2)})],2)]]})],2):_vm._e(),_vm._v(" "),(_vm.announceSRSearchResults)?_c('span',{staticClass:"gl-sr-only",attrs:{"data-testid":"listbox-number-of-results","aria-live":"assertive"}},[_vm._t("search-summary-sr-only")],2):(_vm.showNoResultsText)?_c('div',{staticClass:"gl-pl-7 gl-pr-5 gl-pt-3 gl-font-base gl-text-gray-600",attrs:{"aria-live":"assertive","data-testid":"listbox-no-results-text"}},[_vm._v("\n "+_vm._s(_vm.noResultsText)+"\n ")]):_vm._e(),_vm._v(" "),_vm._t("footer")],2)};
455
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-base-dropdown',{ref:"baseDropdown",attrs:{"aria-haspopup":"listbox","aria-labelledby":_vm.toggleAriaLabelledBy,"toggle-id":_vm.toggleId,"toggle-text":_vm.listboxToggleText,"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,"right":_vm.right},on:_vm._d({},[_vm.$options.events.GL_DROPDOWN_SHOWN,_vm.onShow,_vm.$options.events.GL_DROPDOWN_HIDDEN,_vm.onHide])},[(_vm.headerText)?_c('div',{staticClass:"gl-display-flex gl-align-items-center gl-px-3 gl-py-2! gl-min-h-8",class:_vm.$options.HEADER_ITEMS_BORDER_CLASSES},[_c('div',{staticClass:"gl-flex-grow-1 gl-font-weight-bold gl-font-sm gl-pr-2",attrs:{"id":_vm.headerId,"data-testid":"listbox-header-text"}},[_vm._v("\n "+_vm._s(_vm.headerText)+"\n ")]),_vm._v(" "),(_vm.showResetButton)?_c('gl-button',{staticClass:"gl-focus-inset-border-2-blue-400! gl-flex-shrink-0 gl-font-sm! gl-px-2! gl-py-2!",attrs:{"category":"tertiary","data-testid":"listbox-reset-button"},on:{"click":_vm.onResetButtonClicked}},[_vm._v("\n "+_vm._s(_vm.resetButtonLabel)+"\n ")]):_vm._e()],1):_vm._e(),_vm._v(" "),(_vm.searchable)?_c('div',{class:_vm.$options.HEADER_ITEMS_BORDER_CLASSES},[_c('gl-search-box-by-type',{ref:"searchBox",attrs:{"aria-owns":_vm.listboxId,"data-testid":"listbox-search-input"},on:{"input":_vm.search,"keydown":_vm.onKeydown},model:{value:(_vm.searchStr),callback:function ($$v) {_vm.searchStr=$$v;},expression:"searchStr"}}),_vm._v(" "),(_vm.searching)?_c('gl-loading-icon',{staticClass:"gl-my-3",attrs:{"data-testid":"listbox-search-loader","size":"md"}}):_vm._e()],1):_vm._e(),_vm._v(" "),(_vm.showList)?_c(_vm.listboxTag,{ref:"list",tag:"component",staticClass:"gl-new-dropdown-contents gl-list-style-none gl-pl-0 gl-mb-0",attrs:{"id":"listbox","aria-labelledby":_vm.listAriaLabelledBy || _vm.headerId || _vm.toggleId,"role":"listbox","tabindex":"-1"},on:{"keydown":_vm.onKeydown}},[_vm._l((_vm.items),function(item,index){return [(_vm.isOption(item))?[_c('gl-listbox-item',{key:item.value,attrs:{"is-selected":_vm.isSelected(item),"is-focused":_vm.isFocused(item),"is-check-centered":_vm.isCheckCentered},on:{"select":function($event){return _vm.onSelect(item, $event)}}},[_vm._t("list-item",function(){return [_vm._v("\n "+_vm._s(item.text)+"\n ")]},{"item":item})],2)]:[_c('gl-listbox-group',{key:item.text,class:_vm.groupClasses(index),attrs:{"name":item.text},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._l((item.options),function(option){return _c('gl-listbox-item',{key:option.value,attrs:{"is-selected":_vm.isSelected(option),"is-focused":_vm.isFocused(option),"is-check-centered":_vm.isCheckCentered},on:{"select":function($event){return _vm.onSelect(option, $event)}}},[_vm._t("list-item",function(){return [_vm._v("\n "+_vm._s(option.text)+"\n ")]},{"item":option})],2)})],2)]]})],2):_vm._e(),_vm._v(" "),(_vm.announceSRSearchResults)?_c('span',{staticClass:"gl-sr-only",attrs:{"data-testid":"listbox-number-of-results","aria-live":"assertive"}},[_vm._t("search-summary-sr-only")],2):(_vm.showNoResultsText)?_c('div',{staticClass:"gl-pl-7 gl-pr-5 gl-pt-3 gl-font-base gl-text-gray-600",attrs:{"aria-live":"assertive","data-testid":"listbox-no-results-text"}},[_vm._v("\n "+_vm._s(_vm.noResultsText)+"\n ")]):_vm._e(),_vm._v(" "),_vm._t("footer")],2)};
417
456
  var __vue_staticRenderFns__ = [];
418
457
 
419
458
  /* style */