@gitlab/ui 52.13.1 → 53.0.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,24 @@
1
+ ## [53.0.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v53.0.0...v53.0.1) (2023-01-23)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **GlDisclosureDropdown:** Always set button type ([595d6a2](https://gitlab.com/gitlab-org/gitlab-ui/commit/595d6a25835a42425f3a3b68080d70dcf24fbd08))
7
+
8
+ # [53.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v52.13.1...v53.0.0) (2023-01-20)
9
+
10
+
11
+ ### Features
12
+
13
+ * **GlDisclosureDropdown:** Add support for a placement prop ([06e789c](https://gitlab.com/gitlab-org/gitlab-ui/commit/06e789cdfd1f41a32c19a4ce19305cd4029777dd))
14
+
15
+
16
+ ### BREAKING CHANGES
17
+
18
+ * **GlDisclosureDropdown:** `right` boolean prop replaced with `placement` string
19
+ prop on base_dropdown.vue used by `GlCollapsibleListbox` and
20
+ `GlDisclosureDropdown`
21
+
1
22
  ## [52.13.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v52.13.0...v52.13.1) (2023-01-19)
2
23
 
3
24
 
@@ -1,6 +1,6 @@
1
1
  import _uniqueId from 'lodash/uniqueId';
2
2
  import { createPopper } from '@popperjs/core';
3
- import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions } from '../../../../utils/constants';
3
+ import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions, dropdownPlacements } from '../../../../utils/constants';
4
4
  import { POPPER_CONFIG, GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, ENTER, SPACE } from '../constants';
5
5
  import GlButton from '../../button/button';
6
6
  import GlIcon from '../../icon/icon';
@@ -74,13 +74,11 @@ var script = {
74
74
  required: false,
75
75
  default: false
76
76
  },
77
- /**
78
- * Right align dropdown menu with respect to the toggle button
79
- */
80
- right: {
81
- type: Boolean,
77
+ placement: {
78
+ type: String,
82
79
  required: false,
83
- default: false
80
+ default: 'left',
81
+ validator: value => Object.keys(dropdownPlacements).includes(value)
84
82
  },
85
83
  // ARIA props
86
84
  ariaHaspopup: {
@@ -174,7 +172,7 @@ var script = {
174
172
  },
175
173
  popperConfig() {
176
174
  return {
177
- placement: this.right ? 'bottom-end' : 'bottom-start',
175
+ placement: dropdownPlacements[this.placement],
178
176
  ...POPPER_CONFIG
179
177
  };
180
178
  }
@@ -2,7 +2,7 @@ import _uniqueId from 'lodash/uniqueId';
2
2
  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
- import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions } from '../../../../utils/constants';
5
+ import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions, dropdownPlacements } from '../../../../utils/constants';
6
6
  import GlBaseDropdown from '../base_dropdown/base_dropdown';
7
7
  import GlDisclosureDropdownItem, { ITEM_CLASS } from './disclosure_dropdown_item';
8
8
  import GlDisclosureDropdownGroup from './disclosure_dropdown_group';
@@ -114,12 +114,13 @@ var script = {
114
114
  default: false
115
115
  },
116
116
  /**
117
- * Right align disclosure dropdown with respect to the toggle button
117
+ * Align disclosure dropdown with respect to the toggle button
118
118
  */
119
- right: {
120
- type: Boolean,
119
+ placement: {
120
+ type: String,
121
121
  required: false,
122
- default: false
122
+ default: 'left',
123
+ validator: value => Object.keys(dropdownPlacements).includes(value)
123
124
  },
124
125
  /**
125
126
  * The `aria-labelledby` attribute value for the toggle button
@@ -256,7 +257,7 @@ var script = {
256
257
  const __vue_script__ = script;
257
258
 
258
259
  /* template */
259
- 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,"right":_vm.right},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,{key:"list-item",fn:function(){return [_vm._t("list-item")]},proxy:true}],null,true)})]]})]})],2),_vm._v(" "),_vm._t("footer")],2)};
260
261
  var __vue_staticRenderFns__ = [];
261
262
 
262
263
  /* style */
@@ -26,7 +26,8 @@ var script = {
26
26
  if (this.isActionItem) return {
27
27
  is: 'button',
28
28
  attrs: {
29
- ...this.item.extraAttrs
29
+ ...this.item.extraAttrs,
30
+ type: 'button'
30
31
  },
31
32
  listeners: {
32
33
  click: () => this.item.action()
@@ -2,7 +2,7 @@ import _uniqueId from 'lodash/uniqueId';
2
2
  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
- import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions } from '../../../../utils/constants';
5
+ import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions, dropdownPlacements } from '../../../../utils/constants';
6
6
  import GlButton from '../../button/button';
7
7
  import GlLoadingIcon from '../../loading_icon/loading_icon';
8
8
  import GlIntersectionObserver from '../../../utilities/intersection_observer/intersection_observer';
@@ -155,12 +155,13 @@ var script = {
155
155
  default: false
156
156
  },
157
157
  /**
158
- * Right align listbox menu with respect to the toggle button
158
+ * Align listbox menu with respect to the toggle button
159
159
  */
160
- right: {
161
- type: Boolean,
160
+ placement: {
161
+ type: String,
162
162
  required: false,
163
- default: false
163
+ default: 'left',
164
+ validator: value => Object.keys(dropdownPlacements).includes(value)
164
165
  },
165
166
  /**
166
167
  * Center selected item checkmark
@@ -535,7 +536,7 @@ var script = {
535
536
  const __vue_script__ = script;
536
537
 
537
538
  /* template */
538
- 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,"block":_vm.block,"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]),scopedSlots:_vm._u([(_vm.hasCustomToggle)?{key:"toggle",fn:function(){return [_vm._t("toggle")]},proxy:true}:null],null,true)},[_vm._v(" "),(_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":_vm.listboxId,"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:{"data-testid":("listbox-item-" + (item.value)),"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:{"data-testid":("listbox-item-" + (option.value)),"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.listboxTag === 'ul' ? 'li' : 'div',{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()],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)};
539
+ 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,"block":_vm.block,"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,"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.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":_vm.listboxId,"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:{"data-testid":("listbox-item-" + (item.value)),"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:{"data-testid":("listbox-item-" + (option.value)),"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.listboxTag === 'ul' ? 'li' : 'div',{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()],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)};
539
540
  var __vue_staticRenderFns__ = [];
540
541
 
541
542
  /* style */
@@ -104,6 +104,11 @@ const dropdownVariantOptions = {
104
104
  danger: 'danger',
105
105
  link: 'link'
106
106
  };
107
+ const dropdownPlacements = {
108
+ left: 'bottom-start',
109
+ center: 'bottom',
110
+ right: 'bottom-end'
111
+ };
107
112
  const buttonSizeOptions = {
108
113
  small: 'sm',
109
114
  medium: 'md'
@@ -252,4 +257,4 @@ const loadingIconSizes = {
252
257
  'xl (64x64)': 'xl'
253
258
  };
254
259
 
255
- export { COMMA, LEFT_MOUSE_BUTTON, alertVariantIconMap, alertVariantOptions, alignOptions, avatarShapeOptions, avatarSizeOptions, avatarsInlineSizeOptions, badgeForButtonOptions, badgeIconSizeOptions, badgeSizeOptions, badgeVariantOptions, bannerVariants, buttonCategoryOptions, buttonSizeOptions, buttonVariantOptions, colorThemes, columnOptions, datepickerSizeOptionsMap, defaultDateFormat, drawerVariants, dropdownVariantOptions, focusableTags, formInputSizes, formStateOptions, glThemes, iconSizeOptions, keyboard, labelColorOptions, labelSizeOptions, loadingIconSizes, maxZIndex, modalButtonDefaults, modalSizeOptions, popoverPlacements, resizeDebounceTime, tabsButtonDefaults, targetOptions, toggleLabelPosition, tokenVariants, tooltipActionEvents, tooltipDelay, tooltipPlacements, triggerVariantOptions, truncateOptions, variantCssColorMap, variantOptions, variantOptionsWithNoDefault, viewModeOptions };
260
+ export { COMMA, LEFT_MOUSE_BUTTON, alertVariantIconMap, alertVariantOptions, alignOptions, avatarShapeOptions, avatarSizeOptions, avatarsInlineSizeOptions, badgeForButtonOptions, badgeIconSizeOptions, badgeSizeOptions, badgeVariantOptions, bannerVariants, buttonCategoryOptions, buttonSizeOptions, buttonVariantOptions, colorThemes, columnOptions, datepickerSizeOptionsMap, defaultDateFormat, drawerVariants, dropdownPlacements, dropdownVariantOptions, focusableTags, formInputSizes, formStateOptions, glThemes, iconSizeOptions, keyboard, labelColorOptions, labelSizeOptions, loadingIconSizes, maxZIndex, modalButtonDefaults, modalSizeOptions, popoverPlacements, resizeDebounceTime, tabsButtonDefaults, targetOptions, toggleLabelPosition, tokenVariants, tooltipActionEvents, tooltipDelay, tooltipPlacements, triggerVariantOptions, truncateOptions, variantCssColorMap, variantOptions, variantOptionsWithNoDefault, viewModeOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "52.13.1",
3
+ "version": "53.0.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -87,7 +87,7 @@
87
87
  "@gitlab/eslint-plugin": "18.1.0",
88
88
  "@gitlab/fonts": "^1.1.0",
89
89
  "@gitlab/stylelint-config": "4.1.0",
90
- "@gitlab/svgs": "3.16.0",
90
+ "@gitlab/svgs": "3.17.0",
91
91
  "@rollup/plugin-commonjs": "^11.1.0",
92
92
  "@rollup/plugin-node-resolve": "^7.1.3",
93
93
  "@rollup/plugin-replace": "^2.3.2",
@@ -57,8 +57,17 @@ describe('base dropdown', () => {
57
57
  );
58
58
  });
59
59
 
60
+ it('should initialize popper.js instance with toggle and menu elements and config for center-aligned menu', async () => {
61
+ await buildWrapper({ placement: 'center' });
62
+ expect(mockCreatePopper).toHaveBeenCalledWith(
63
+ findDefaultDropdownToggle().element,
64
+ findDropdownMenu().element,
65
+ { ...POPPER_CONFIG, placement: 'bottom' }
66
+ );
67
+ });
68
+
60
69
  it('should initialize popper.js instance with toggle and menu elements and config for right-aligned menu', async () => {
61
- await buildWrapper({ right: true });
70
+ await buildWrapper({ placement: 'right' });
62
71
  expect(mockCreatePopper).toHaveBeenCalledWith(
63
72
  findDefaultDropdownToggle().element,
64
73
  findDropdownMenu().element,
@@ -4,6 +4,7 @@ import { createPopper } from '@popperjs/core';
4
4
  import {
5
5
  buttonCategoryOptions,
6
6
  buttonSizeOptions,
7
+ dropdownPlacements,
7
8
  dropdownVariantOptions,
8
9
  } from '../../../../utils/constants';
9
10
  import { POPPER_CONFIG, GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, ENTER, SPACE } from '../constants';
@@ -77,13 +78,11 @@ export default {
77
78
  required: false,
78
79
  default: false,
79
80
  },
80
- /**
81
- * Right align dropdown menu with respect to the toggle button
82
- */
83
- right: {
84
- type: Boolean,
81
+ placement: {
82
+ type: String,
85
83
  required: false,
86
- default: false,
84
+ default: 'left',
85
+ validator: (value) => Object.keys(dropdownPlacements).includes(value),
87
86
  },
88
87
  // ARIA props
89
88
  ariaHaspopup: {
@@ -179,7 +178,7 @@ export default {
179
178
  },
180
179
  popperConfig() {
181
180
  return {
182
- placement: this.right ? 'bottom-end' : 'bottom-start',
181
+ placement: dropdownPlacements[this.placement],
183
182
  ...POPPER_CONFIG,
184
183
  };
185
184
  },
@@ -45,7 +45,12 @@ After closing, `GlDisclosureDropdown` emits a `hidden` event.
45
45
  ### Setting disclosure dropdown items
46
46
 
47
47
  Use the `items` prop to provide actions/links to the disclosure dropdown. Each item can be
48
- either an item or a group. Below are the expected shapes of these objects:
48
+ either an item or a group. For `Item`s, either the `href` or the `action` may be null, but not both.
49
+ A <!-- markdownlint-disable-next-line line-length -->
50
+ [validation error](https://gitlab.com/gitlab-org/gitlab-ui/-/blob/6cbff4f908b429cc01f17a4cc2868e881db1aa31/src/components/base/new_dropdowns/disclosure/utils.js#L1)
51
+ will be triggered if neither field is set.
52
+
53
+ Below are the expected shapes of these objects:
49
54
 
50
55
  ```typescript
51
56
  type Item = {
@@ -2,6 +2,7 @@ import {
2
2
  buttonCategoryOptions,
3
3
  buttonSizeOptions,
4
4
  buttonVariantOptions,
5
+ dropdownPlacements,
5
6
  } from '../../../../utils/constants';
6
7
  import {
7
8
  GlDisclosureDropdown,
@@ -27,7 +28,7 @@ const generateProps = ({
27
28
  disabled = defaultValue('disabled'),
28
29
  loading = defaultValue('loading'),
29
30
  noCaret = defaultValue('noCaret'),
30
- right = defaultValue('right'),
31
+ placement = defaultValue('placement'),
31
32
  toggleText,
32
33
  textSrOnly = defaultValue('textSrOnly'),
33
34
  icon = '',
@@ -42,7 +43,7 @@ const generateProps = ({
42
43
  disabled,
43
44
  loading,
44
45
  noCaret,
45
- right,
46
+ placement,
46
47
  toggleText,
47
48
  textSrOnly,
48
49
  icon,
@@ -60,7 +61,7 @@ const makeBindings = (overrides = {}) =>
60
61
  ':disabled': 'disabled',
61
62
  ':loading': 'loading',
62
63
  ':no-caret': 'noCaret',
63
- ':right': 'right',
64
+ ':placement': 'placement',
64
65
  ':toggle-text': 'toggleText',
65
66
  ':text-sr-only': 'textSrOnly',
66
67
  ':icon': 'icon',
@@ -127,19 +128,24 @@ export const CustomListItem = (args, { argTypes }) => ({
127
128
  <template #list-item="{ item }">
128
129
  <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">
129
130
  {{item.text}}
130
- <gl-badge pill variant="info" v-if="item.count">{{item.count}}</gl-badge>
131
+ <gl-badge v-if="item.count" pill size="sm">{{item.count}}</gl-badge>
131
132
  </a>
132
133
  </template>
133
134
  `,
134
135
  {
135
136
  bindingOverrides: {
136
137
  '@action': 'navigate',
138
+ class: 'gl-display-block gl-text-center',
137
139
  },
138
140
  }
139
141
  ),
140
142
  });
141
143
 
142
- CustomListItem.args = generateProps({ items: mockItemsCustomItem, toggleText: 'Merge requests' });
144
+ CustomListItem.args = generateProps({
145
+ items: mockItemsCustomItem,
146
+ toggleText: 'Merge requests',
147
+ placement: 'center',
148
+ });
143
149
  CustomListItem.decorators = [makeContainer({ height: '200px' })];
144
150
 
145
151
  const makeGroupedExample = (changes) => {
@@ -302,5 +308,11 @@ export default {
302
308
  options: Object.keys(buttonSizeOptions),
303
309
  },
304
310
  },
311
+ placement: {
312
+ control: {
313
+ type: 'select',
314
+ options: Object.keys(dropdownPlacements),
315
+ },
316
+ },
305
317
  },
306
318
  };
@@ -13,6 +13,7 @@ import {
13
13
  import {
14
14
  buttonCategoryOptions,
15
15
  buttonSizeOptions,
16
+ dropdownPlacements,
16
17
  dropdownVariantOptions,
17
18
  } from '../../../../utils/constants';
18
19
  import GlBaseDropdown from '../base_dropdown/base_dropdown.vue';
@@ -125,12 +126,13 @@ export default {
125
126
  default: false,
126
127
  },
127
128
  /**
128
- * Right align disclosure dropdown with respect to the toggle button
129
+ * Align disclosure dropdown with respect to the toggle button
129
130
  */
130
- right: {
131
- type: Boolean,
131
+ placement: {
132
+ type: String,
132
133
  required: false,
133
- default: false,
134
+ default: 'left',
135
+ validator: (value) => Object.keys(dropdownPlacements).includes(value),
134
136
  },
135
137
  /**
136
138
  * The `aria-labelledby` attribute value for the toggle button
@@ -281,7 +283,7 @@ export default {
281
283
  :disabled="disabled"
282
284
  :loading="loading"
283
285
  :no-caret="noCaret"
284
- :right="right"
286
+ :placement="placement"
285
287
  class="gl-disclosure-dropdown"
286
288
  @[$options.events.GL_DROPDOWN_SHOWN]="onShow"
287
289
  @[$options.events.GL_DROPDOWN_HIDDEN]="onHide"
@@ -62,7 +62,7 @@ describe('GlDisclosureDropdownItem', () => {
62
62
  action.mockClear();
63
63
  });
64
64
 
65
- const findButton = () => wrapper.find('button.dropdown-item');
65
+ const findButton = () => wrapper.find('button[type="button"].dropdown-item');
66
66
 
67
67
  it('should render a button', () => {
68
68
  expect(findButton().exists()).toBe(true);
@@ -28,6 +28,7 @@ export default {
28
28
  is: 'button',
29
29
  attrs: {
30
30
  ...this.item.extraAttrs,
31
+ type: 'button',
31
32
  },
32
33
  listeners: {
33
34
  click: () => this.item.action(),
@@ -2,6 +2,7 @@ import {
2
2
  buttonCategoryOptions,
3
3
  buttonSizeOptions,
4
4
  buttonVariantOptions,
5
+ dropdownPlacements,
5
6
  } from '../../../../utils/constants';
6
7
  import {
7
8
  GlIcon,
@@ -43,7 +44,7 @@ const generateProps = ({
43
44
  noResultsText = defaultValue('noResultsText'),
44
45
  searchPlaceholder = defaultValue('searchPlaceholder'),
45
46
  noCaret = defaultValue('noCaret'),
46
- right = defaultValue('right'),
47
+ placement = defaultValue('placement'),
47
48
  toggleText,
48
49
  textSrOnly = defaultValue('textSrOnly'),
49
50
  headerText = defaultValue('headerText'),
@@ -69,7 +70,7 @@ const generateProps = ({
69
70
  noResultsText,
70
71
  searchPlaceholder,
71
72
  noCaret,
72
- right,
73
+ placement,
73
74
  toggleText,
74
75
  textSrOnly,
75
76
  headerText,
@@ -98,7 +99,7 @@ const makeBindings = (overrides = {}) =>
98
99
  ':no-results-text': 'noResultsText',
99
100
  ':search-placeholder': 'searchPlaceholder',
100
101
  ':no-caret': 'noCaret',
101
- ':right': 'right',
102
+ ':placement': 'placement',
102
103
  ':toggle-text': 'toggleText',
103
104
  ':text-sr-only': 'textSrOnly',
104
105
  ':header-text': 'headerText',
@@ -429,12 +430,21 @@ export default {
429
430
  subcategory: ARG_TYPE_SUBCATEGORY_LOOK_AND_FEEL,
430
431
  },
431
432
  },
433
+ block: {
434
+ table: {
435
+ subcategory: ARG_TYPE_SUBCATEGORY_LOOK_AND_FEEL,
436
+ },
437
+ },
432
438
  noCaret: {
433
439
  table: {
434
440
  subcategory: ARG_TYPE_SUBCATEGORY_LOOK_AND_FEEL,
435
441
  },
436
442
  },
437
- right: {
443
+ placement: {
444
+ control: {
445
+ type: 'select',
446
+ options: Object.keys(dropdownPlacements),
447
+ },
438
448
  table: {
439
449
  subcategory: ARG_TYPE_SUBCATEGORY_LOOK_AND_FEEL,
440
450
  },
@@ -13,6 +13,7 @@ import {
13
13
  import {
14
14
  buttonCategoryOptions,
15
15
  buttonSizeOptions,
16
+ dropdownPlacements,
16
17
  dropdownVariantOptions,
17
18
  } from '../../../../utils/constants';
18
19
  import GlButton from '../../button/button.vue';
@@ -167,12 +168,13 @@ export default {
167
168
  default: false,
168
169
  },
169
170
  /**
170
- * Right align listbox menu with respect to the toggle button
171
+ * Align listbox menu with respect to the toggle button
171
172
  */
172
- right: {
173
- type: Boolean,
173
+ placement: {
174
+ type: String,
174
175
  required: false,
175
- default: false,
176
+ default: 'left',
177
+ validator: (value) => Object.keys(dropdownPlacements).includes(value),
176
178
  },
177
179
  /**
178
180
  * Center selected item checkmark
@@ -566,7 +568,7 @@ export default {
566
568
  :disabled="disabled"
567
569
  :loading="loading"
568
570
  :no-caret="noCaret"
569
- :right="right"
571
+ :placement="placement"
570
572
  @[$options.events.GL_DROPDOWN_SHOWN]="onShow"
571
573
  @[$options.events.GL_DROPDOWN_HIDDEN]="onHide"
572
574
  >
@@ -122,6 +122,12 @@ export const dropdownVariantOptions = {
122
122
  link: 'link',
123
123
  };
124
124
 
125
+ export const dropdownPlacements = {
126
+ left: 'bottom-start',
127
+ center: 'bottom',
128
+ right: 'bottom-end',
129
+ };
130
+
125
131
  export const buttonSizeOptions = {
126
132
  small: 'sm',
127
133
  medium: 'md',