@gitlab/ui 128.5.0 → 128.6.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.
@@ -232,9 +232,6 @@ var script = {
232
232
  hasIconOnly() {
233
233
  return isSlotEmpty(this, 'default') && this.hasIcon && this.count == null;
234
234
  },
235
- isButtonDisabled() {
236
- return this.disabled;
237
- },
238
235
  isButtonAriaDisabled() {
239
236
  return this.isButton && this.loading;
240
237
  },
@@ -291,7 +288,7 @@ var script = {
291
288
  // Type only used for "real" buttons
292
289
  type: this.isButton ? this.type : null,
293
290
  // Disabled only set on "real" buttons
294
- disabled: this.isButton ? this.isButtonDisabled : null,
291
+ disabled: this.isButton ? this.disabled : null,
295
292
  // We add a role of button when the tag is not a link or button or when link has `href` of `#`
296
293
  role: this.isNonStandardTag || this.isHashLink ? 'button' : (_this$$attrs = this.$attrs) === null || _this$$attrs === void 0 ? void 0 : _this$$attrs.role,
297
294
  // We set the `aria-disabled` state for non-standard tags
@@ -166,6 +166,14 @@ var script = {
166
166
  required: false,
167
167
  default: false
168
168
  },
169
+ /**
170
+ * Allows the dropdown panel to match the width of the trigger element
171
+ */
172
+ panelMatchTriggerWidth: {
173
+ type: Boolean,
174
+ required: false,
175
+ default: false
176
+ },
169
177
  /**
170
178
  * Strategy to be applied by computePosition. If this is set to fixed, the dropdown's position
171
179
  * needs to be set to fixed in CSS as well.
@@ -333,7 +341,8 @@ var script = {
333
341
  panelClasses() {
334
342
  return {
335
343
  '!gl-block': this.visible,
336
- [FIXED_WIDTH_CLASS]: !this.fluidWidth,
344
+ [FIXED_WIDTH_CLASS]: !this.fluidWidth && !this.panelMatchTriggerWidth,
345
+ 'gl-new-dropdown-panel-fluid-width': this.fluidWidth && !this.panelMatchTriggerWidth,
337
346
  'gl-fixed': this.openedYet && this.isFixed,
338
347
  'gl-absolute': this.openedYet && !this.isFixed
339
348
  };
@@ -366,9 +375,12 @@ var script = {
366
375
  const maxWidth = this.fluidWidth ? {
367
376
  maxWidth: `${Math.max(0, availableWidth)}px`
368
377
  } : {};
378
+ const triggerWidth = this.panelMatchTriggerWidth ? {
379
+ minWidth: `${this.toggleElement.getBoundingClientRect().width}px`
380
+ } : {};
369
381
  Object.assign(contentsEl.style, {
370
382
  maxHeight: `${Math.max(contentsAvailableHeight, 0)}px`
371
- }, maxWidth);
383
+ }, maxWidth, triggerWidth);
372
384
  }
373
385
  })]
374
386
  };
@@ -318,6 +318,14 @@ var script = {
318
318
  required: false,
319
319
  default: false
320
320
  },
321
+ /**
322
+ * Allows the dropdown panel to match the width of the trigger element
323
+ */
324
+ panelMatchTriggerWidth: {
325
+ type: Boolean,
326
+ required: false,
327
+ default: false
328
+ },
321
329
  /**
322
330
  * Strategy to be applied by computePosition. If the dropdown's container is too short for it to
323
331
  * fit in, setting this to fixed will let it position itself above its container.
@@ -911,7 +919,7 @@ var script = {
911
919
  const __vue_script__ = script;
912
920
 
913
921
  /* template */
914
- 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","active-item-id":_vm.activeItemId,"aria-labelledby":_vm.toggleAriaLabelledBy,"block":_vm.block,"has-searchable-listbox":_vm.searchable,"has-external-label":_vm.isInFormGroup,"listbox-id":_vm.listboxIdComputed,"toggle-id":_vm.toggleIdComputed,"toggle-text":_vm.listboxToggleText,"toggle-class":_vm.toggleButtonClasses,"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_FOCUS_CONTENT,_vm.onFocusContent,_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(slotProps){return [_vm._t("toggle",null,null,slotProps)]}}:null,{key:"default",fn:function(ref){
922
+ 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","active-item-id":_vm.activeItemId,"aria-labelledby":_vm.toggleAriaLabelledBy,"block":_vm.block,"has-searchable-listbox":_vm.searchable,"has-external-label":_vm.isInFormGroup,"listbox-id":_vm.listboxIdComputed,"toggle-id":_vm.toggleIdComputed,"toggle-text":_vm.listboxToggleText,"toggle-class":_vm.toggleButtonClasses,"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,"panel-match-trigger-width":_vm.panelMatchTriggerWidth,"positioning-strategy":_vm.positioningStrategy},on:_vm._d({},[_vm.$options.events.GL_DROPDOWN_FOCUS_CONTENT,_vm.onFocusContent,_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(slotProps){return [_vm._t("toggle",null,null,slotProps)]}}:null,{key:"default",fn:function(ref){
915
923
  var visible = ref.visible;
916
924
  return [(_vm.headerText)?_c('div',{staticClass:"gl-flex gl-min-h-8 gl-items-center !gl-p-4",class:_vm.$options.HEADER_ITEMS_BORDER_CLASSES},[_c('div',{staticClass:"gl-grow gl-pr-2 gl-text-sm gl-font-bold gl-text-strong",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-m-0 !gl-w-auto gl-max-w-1/2 gl-flex-shrink-0 gl-text-ellipsis !gl-px-2 !gl-text-sm focus:!gl-focus-inset",attrs:{"category":"tertiary","size":"small","data-testid":"listbox-reset-button"},on:{"click":_vm.onResetButtonClicked}},[_vm._v("\n "+_vm._s(_vm.resetButtonLabel)+"\n ")]):_vm._e(),_vm._v(" "),(_vm.showSelectAllButton)?_c('gl-button',{staticClass:"!gl-m-0 !gl-w-auto gl-max-w-1/2 gl-flex-shrink-0 gl-text-ellipsis !gl-px-2 !gl-text-sm focus:!gl-focus-inset",attrs:{"category":"tertiary","size":"small","data-testid":"listbox-select-all-button"},on:{"click":_vm.onSelectAllButtonClicked}},[_vm._v("\n "+_vm._s(_vm.showSelectAllButtonLabel)+"\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",class:{ 'gl-listbox-topmost': !_vm.headerText },attrs:{"id":_vm.searchInputId,"data-testid":"listbox-search-input","role":"combobox","aria-expanded":String(visible),"aria-controls":_vm.listboxId,"aria-activedescendant":_vm.activeItemId,"aria-haspopup":"listbox","placeholder":_vm.searchPlaceholder},on:{"input":_vm.search,"keydown":[function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }$event.preventDefault();},_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-new-dropdown-contents-with-scrim-overlay",class:_vm.listboxClasses,attrs:{"id":_vm.listboxId,"aria-busy":_vm.isBusy,"aria-labelledby":_vm.listboxAriaLabelledByID,"aria-multiselectable":_vm.multiple ? 'true' : undefined,"role":"listbox","tabindex":"0"},on:{"keydown":_vm.onKeydown}},[_c(_vm.itemTag,{tag:"component",staticClass:"top-scrim-wrapper",attrs:{"aria-hidden":"true","data-testid":"top-scrim"}},[_c('div',{staticClass:"top-scrim",class:{ 'top-scrim-light': !_vm.hasHeader, 'top-scrim-dark': _vm.hasHeader }})]),_vm._v(" "),_c(_vm.itemTag,{ref:"top-boundary",tag:"component",attrs:{"aria-hidden":"true"}}),_vm._v(" "),_vm._l((_vm.items),function(item,index){return [(_vm.isOption(item))?[_c('gl-listbox-item',_vm._b({key:_vm.listboxItemKey(item),attrs:{"id":_vm.generateItemId(item),"data-testid":("listbox-item-" + (item.value)),"is-highlighted":_vm.isHighlighted(item),"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,"text-sr-only":item.textSrOnly},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:_vm.listboxItemKey(option),attrs:{"id":_vm.generateItemId(option),"data-testid":("listbox-item-" + (option.value)),"is-highlighted":_vm.isHighlighted(option),"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.infiniteScrollLoading)?_c(_vm.itemTag,{tag:"component"},[_c('gl-loading-icon',{staticClass:"gl-my-3",attrs:{"data-testid":"listbox-infinite-scroll-loader","size":"md"}})],1):_vm._e(),_vm._v(" "),(_vm.showIntersectionObserver)?_c('gl-intersection-observer',{on:{"appear":_vm.onIntersectionObserverAppear}}):_vm._e(),_vm._v(" "),_c(_vm.itemTag,{ref:"bottom-boundary",tag:"component",attrs:{"aria-hidden":"true"}}),_vm._v(" "),_c(_vm.itemTag,{tag:"component",staticClass:"bottom-scrim-wrapper",attrs:{"aria-hidden":"true","data-testid":"bottom-scrim"}},[_c('div',{staticClass:"bottom-scrim",class:{ '!gl-rounded-none': _vm.hasFooter }})])],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",function(){return [_vm._v("\n "+_vm._s(_vm.srOnlyResultsLabel(_vm.flattenedOptions.length))+"\n ")]})],2):_vm._e(),_vm._v(" "),(_vm.isBusy)?_c('span',{staticClass:"gl-sr-only",attrs:{"aria-live":"polite","data-testid":"listbox-loading-announcement"}},[_vm._v("\n "+_vm._s(_vm.loadingAnnouncementText)+"\n ")]):(_vm.showNoResultsText)?_c('div',{staticClass:"gl-py-3 gl-pl-7 gl-pr-5 gl-text-base gl-text-subtle",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")]}}],null,true)})};
917
925
  var __vue_staticRenderFns__ = [];
@@ -1,12 +1,9 @@
1
1
  import Vue from 'vue';
2
- import compose from 'lodash/fp/compose';
3
- import fill from 'lodash/fp/fill';
4
- import filter from 'lodash/fp/filter';
5
- import { insert, intersperse } from '../../../utils/data_utils';
2
+ import { intersperse, insert } from '../../../utils/data_utils';
6
3
  import { isVnodeEmpty } from '../../../utils/is_slot_empty';
7
4
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
8
5
 
9
- const filterEmptyNodesVue2 = filter(vNode => typeof vNode.tag === 'string' || vNode.text.trim() !== '');
6
+ const filterEmptyNodesVue2 = vNodes => vNodes.filter(vNode => typeof vNode.tag === 'string' || vNode.text.trim() !== '');
10
7
  const {
11
8
  Fragment
12
9
  } = Vue;
@@ -21,17 +18,22 @@ const filterEmptyNodesVue3 = vNode => {
21
18
  }, []).filter(node => !isVnodeEmpty(node));
22
19
  };
23
20
  const filterEmptyNodes = Vue.version.startsWith('3') ? filterEmptyNodesVue3 : filterEmptyNodesVue2;
24
- const insertAfterSecondLastItem = insert(-1);
25
- const replaceSecondLastItem = fill(-2, -1);
26
21
 
27
22
  // handles the addition of the lastSeparator in these two cases:
28
23
  // item1, item2, item3 => item1, item2, and item3
29
24
  // item1, item2 => item1 and item2
30
- const addLastSeparator = lastSeparator => items => {
25
+ const addLastSeparator = (lastSeparator, items) => {
31
26
  if (!lastSeparator) {
32
27
  return items;
33
28
  }
34
- return items.length > 3 ? insertAfterSecondLastItem(lastSeparator, items) : replaceSecondLastItem(lastSeparator, items);
29
+ if (items.length > 3) {
30
+ return insert(-1, lastSeparator, items);
31
+ }
32
+
33
+ // Replace the second-to-last item with lastSeparator
34
+ const result = [...items];
35
+ result[result.length - 2] = lastSeparator;
36
+ return result;
35
37
  };
36
38
  var script = {
37
39
  name: 'GlIntersperse',
@@ -57,8 +59,11 @@ var script = {
57
59
  slots,
58
60
  data
59
61
  } = context;
60
- const filterAndSeparate = compose(addLastSeparator(lastSeparator), intersperse(separator), filterEmptyNodes);
61
- return createElement('span', data, filterAndSeparate(slots().default));
62
+ const slotContent = slots().default || [];
63
+ const filtered = filterEmptyNodes(slotContent);
64
+ const separated = intersperse(separator, filtered);
65
+ const withLastSeparator = addLastSeparator(lastSeparator, separated);
66
+ return createElement('span', data, withLastSeparator);
62
67
  }
63
68
  };
64
69