@gitlab/ui 52.6.0 → 52.7.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,17 @@
1
+ # [52.7.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v52.6.1...v52.7.0) (2022-12-20)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlListbox:** Add infinite scroll to listbox ([d42c9e6](https://gitlab.com/gitlab-org/gitlab-ui/commit/d42c9e64745fdc0ee65e1d612712a1aaf61a2228))
7
+
8
+ ## [52.6.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v52.6.0...v52.6.1) (2022-12-20)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **css:** Disables ligatures for monospaced fonts ([50e208c](https://gitlab.com/gitlab-org/gitlab-ui/commit/50e208c8d0d49acbc2dd21393364bcc02094cbac))
14
+
1
15
  # [52.6.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v52.5.0...v52.6.0) (2022-12-16)
2
16
 
3
17
 
@@ -20,32 +20,32 @@ var script = {
20
20
  event: 'input'
21
21
  },
22
22
  props: {
23
- /*
24
- Used to set the title of accordion link
25
- */
23
+ /**
24
+ * Used to set the title of accordion link
25
+ */
26
26
  title: {
27
27
  type: String,
28
28
  required: true
29
29
  },
30
- /*
31
- Used to set the title of accordion link when the content is visible
32
- */
30
+ /**
31
+ * Used to set the title of accordion link when the content is visible
32
+ * */
33
33
  titleVisible: {
34
34
  type: String,
35
35
  default: null,
36
36
  required: false
37
37
  },
38
- /*
39
- When set, it will ensure the accordion item is initially visible
40
- */
38
+ /**
39
+ * When set, it will ensure the accordion item is initially visible
40
+ */
41
41
  visible: {
42
42
  type: Boolean,
43
43
  default: false,
44
44
  required: false
45
45
  },
46
- /*
47
- The header tag used in the accordion (h1/h2/h3/h4/h5/h6). This overrides the value provided by GlAccordion. For accessibility this should be set to an appropriate value in the context where the accordion is used.,
48
- */
46
+ /**
47
+ * The header tag used in the accordion (h1/h2/h3/h4/h5/h6). This overrides the value provided by GlAccordion. For accessibility this should be set to an appropriate value in the context where the accordion is used.,
48
+ */
49
49
  headerLevel: {
50
50
  type: Number,
51
51
  required: false,
@@ -55,7 +55,7 @@ var script = {
55
55
  }
56
56
  },
57
57
  /**
58
- * Additional CSS class(es) to be applied to the header.
58
+ * Additional CSS class(es) to be applied to the header
59
59
  */
60
60
  headerClass: {
61
61
  type: [String, Object, Array],
@@ -5,6 +5,7 @@ import { GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, HOME, END, ARROW_UP, ARROW_DOWN
5
5
  import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions } from '../../../../utils/constants';
6
6
  import GlButton from '../../button/button';
7
7
  import GlLoadingIcon from '../../loading_icon/loading_icon';
8
+ import GlIntersectionObserver from '../../../utilities/intersection_observer/intersection_observer';
8
9
  import GlSearchBoxByType from '../../search_box_by_type/search_box_by_type';
9
10
  import GlBaseDropdown from '../base_dropdown/base_dropdown';
10
11
  import GlListboxItem from './listbox_item';
@@ -30,7 +31,8 @@ var script = {
30
31
  GlButton,
31
32
  GlSearchBoxByType,
32
33
  GlListboxSearchInput,
33
- GlLoadingIcon
34
+ GlLoadingIcon,
35
+ GlIntersectionObserver
34
36
  },
35
37
  model: {
36
38
  prop: 'selected',
@@ -203,6 +205,37 @@ var script = {
203
205
  required: false,
204
206
  default: false
205
207
  },
208
+ /**
209
+ * Enables infinite scroll.
210
+ * When set to `true`, the `@bottom-reached` event will be fired when
211
+ * the bottom of the listbox is scrolled to.
212
+ * Does not support groups.
213
+ */
214
+ infiniteScroll: {
215
+ type: Boolean,
216
+ required: false,
217
+ default: false
218
+ },
219
+ /**
220
+ * This prop is used for infinite scroll.
221
+ * It represents the total number of items that exist,
222
+ * even if they have not yet been loaded.
223
+ * Do not set this prop if the total number of items is unknown.
224
+ */
225
+ totalItems: {
226
+ type: Number,
227
+ required: false,
228
+ default: null
229
+ },
230
+ /**
231
+ * This prop is used for infinite scroll.
232
+ * Set to `true` when more items are being loaded.
233
+ */
234
+ infiniteScrollLoading: {
235
+ type: Boolean,
236
+ required: false,
237
+ default: false
238
+ },
206
239
  /**
207
240
  * Message to be displayed when filtering produced no results
208
241
  */
@@ -291,6 +324,9 @@ var script = {
291
324
  return this.selected.length > 0;
292
325
  }
293
326
  return Boolean(this.selected);
327
+ },
328
+ showIntersectionObserver() {
329
+ return this.infiniteScroll && !this.infiniteScrollLoading && !this.loading && !this.searching;
294
330
  }
295
331
  },
296
332
  watch: {
@@ -316,6 +352,11 @@ var script = {
316
352
  }
317
353
  }
318
354
  },
355
+ created() {
356
+ if (process.env.NODE_ENV !== 'production' && this.infiniteScroll && this.items.some(item => !isOption(item))) {
357
+ throw new Error('Infinite scroll does not support groups. Please set the "infiniteScroll" prop to "false"');
358
+ }
359
+ },
319
360
  methods: {
320
361
  open() {
321
362
  this.$refs.baseDropdown.open();
@@ -457,6 +498,24 @@ var script = {
457
498
  closeAndFocus() {
458
499
  this.$refs.baseDropdown.closeAndFocus();
459
500
  },
501
+ onIntersectionObserverAppear() {
502
+ /**
503
+ * Emitted when bottom of listbox has been scrolled to.
504
+ * Used for infinite scroll.
505
+ *
506
+ * @event bottom-reached
507
+ */
508
+ this.$emit('bottom-reached');
509
+ },
510
+ listboxItemMoreItemsAriaAttributes(index) {
511
+ if (this.totalItems === null) {
512
+ return {};
513
+ }
514
+ return {
515
+ 'aria-setsize': this.totalItems,
516
+ 'aria-posinset': index + 1
517
+ };
518
+ },
460
519
  isOption
461
520
  }
462
521
  };
@@ -465,7 +524,7 @@ var script = {
465
524
  const __vue_script__ = script;
466
525
 
467
526
  /* template */
468
- 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-4! 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-listbox-search-input',{ref:"searchBox",attrs:{"aria-owns":_vm.listboxId,"data-testid":"listbox-search-input","placeholder":_vm.searchPlaceholder},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-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)};
527
+ 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-4! 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-listbox-search-input',{ref:"searchBox",attrs:{"aria-owns":_vm.listboxId,"data-testid":"listbox-search-input","placeholder":_vm.searchPlaceholder},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-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',_vm._b({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)}}},'gl-listbox-item',_vm.listboxItemMoreItemsAriaAttributes(index),false),[_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)]]}),_vm._v(" "),(_vm.showIntersectionObserver)?_c('gl-intersection-observer',{on:{"appear":_vm.onIntersectionObserverAppear}}):_vm._e()],2):_vm._e(),_vm._v(" "),(_vm.infiniteScrollLoading)?_c('gl-loading-icon',{staticClass:"gl-my-3",attrs:{"data-testid":"listbox-infinite-scroll-loader","size":"md"}}):_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)};
469
528
  var __vue_staticRenderFns__ = [];
470
529
 
471
530
  /* style */