@gitlab/ui 122.12.1 → 122.13.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.
@@ -16,6 +16,11 @@ var script = {
16
16
  validator: tokensValidator,
17
17
  required: true
18
18
  },
19
+ state: {
20
+ type: Boolean,
21
+ required: false,
22
+ default: null
23
+ },
19
24
  registerFocusOnToken: {
20
25
  type: Function,
21
26
  required: true
@@ -125,7 +130,7 @@ var script = {
125
130
  const __vue_script__ = script;
126
131
 
127
132
  /* template */
128
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-flex gl-w-full gl-flex-nowrap gl-items-start"},[_c('div',{staticClass:"gl-flex gl-grow gl-flex-wrap gl-items-start"},[_c('div',{ref:"tokenContainer",staticClass:"-gl-mx-1 -gl-my-1 gl-flex gl-w-auto gl-list-none gl-flex-wrap gl-items-center gl-p-0",on:{"keydown":[function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"left",37,$event.key,["Left","ArrowLeft"])){ return null; }if('button' in $event && $event.button !== 0){ return null; }return _vm.handleLeftArrow.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"right",39,$event.key,["Right","ArrowRight"])){ return null; }if('button' in $event && $event.button !== 2){ return null; }return _vm.handleRightArrow.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"home",undefined,$event.key,undefined)){ return null; }return _vm.handleHome.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"end",undefined,$event.key,undefined)){ return null; }return _vm.handleEnd.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"])){ return null; }return _vm.handleDelete.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"esc",27,$event.key,["Esc","Escape"])){ return null; }return _vm.handleEscape.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"tab",9,$event.key,"Tab")){ return null; }if($event.ctrlKey||$event.shiftKey||$event.altKey||$event.metaKey){ return null; }$event.preventDefault();return _vm.handleTab.apply(null, arguments)}]}},_vm._l((_vm.tokens),function(token,index){return _c('div',{key:token.id,ref:"tokens",refInFor:true,staticClass:"gl-token-selector-token-container gl-px-1 gl-py-2 gl-outline-none",attrs:{"data-token-id":token.id,"data-testid":"gl-token-selector-tokens","tabindex":"-1"},on:{"focus":function($event){_vm.bindFocusEvent ? _vm.handleTokenFocus(index) : null;}}},[_c('gl-token',{staticClass:"gl-cursor-default",class:token.class,style:(token.style),attrs:{"view-only":_vm.viewOnly},on:{"close":function($event){return _vm.handleClose(token)}}},[_vm._t("token-content",function(){return [_c('span',[_vm._v("\n "+_vm._s(token.name)+"\n ")])]},{"token":token})],2)],1)}),0),_vm._v(" "),_vm._t("text-input")],2),_vm._v(" "),(_vm.showClearAllButton)?_c('div',{staticClass:"gl-ml-3 gl-p-1"},[_c('gl-button',{attrs:{"size":"small","aria-label":"Clear all","icon":"clear","category":"tertiary","data-testid":"clear-all-button"},on:{"click":function($event){$event.stopPropagation();return _vm.$emit('clear-all')}}})],1):_vm._e()])};
133
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-flex gl-w-full gl-flex-nowrap gl-items-start"},[_c('div',{staticClass:"gl-flex gl-grow gl-flex-wrap gl-items-start"},[_c('div',{ref:"tokenContainer",staticClass:"-gl-mx-1 -gl-my-1 gl-flex gl-w-auto gl-list-none gl-flex-wrap gl-items-center gl-p-0",attrs:{"role":"listbox","aria-multiselectable":"false","aria-orientation":"horizontal","aria-invalid":_vm.state === false && 'true',"aria-label":"token list"},on:{"keydown":[function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"left",37,$event.key,["Left","ArrowLeft"])){ return null; }if('button' in $event && $event.button !== 0){ return null; }return _vm.handleLeftArrow.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"right",39,$event.key,["Right","ArrowRight"])){ return null; }if('button' in $event && $event.button !== 2){ return null; }return _vm.handleRightArrow.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"home",undefined,$event.key,undefined)){ return null; }return _vm.handleHome.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"end",undefined,$event.key,undefined)){ return null; }return _vm.handleEnd.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"])){ return null; }return _vm.handleDelete.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"esc",27,$event.key,["Esc","Escape"])){ return null; }return _vm.handleEscape.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"tab",9,$event.key,"Tab")){ return null; }if($event.ctrlKey||$event.shiftKey||$event.altKey||$event.metaKey){ return null; }$event.preventDefault();return _vm.handleTab.apply(null, arguments)}]}},_vm._l((_vm.tokens),function(token,index){return _c('div',{key:token.id,ref:"tokens",refInFor:true,staticClass:"gl-token-selector-token-container gl-px-1 gl-py-2 gl-outline-none",attrs:{"data-token-id":token.id,"role":"option","tabindex":"-1"},on:{"focus":function($event){_vm.bindFocusEvent ? _vm.handleTokenFocus(index) : null;}}},[_c('gl-token',{staticClass:"gl-cursor-default",class:token.class,style:(token.style),attrs:{"view-only":_vm.viewOnly},on:{"close":function($event){return _vm.handleClose(token)}}},[_vm._t("token-content",function(){return [_c('span',[_vm._v("\n "+_vm._s(token.name)+"\n ")])]},{"token":token})],2)],1)}),0),_vm._v(" "),_vm._t("text-input")],2),_vm._v(" "),(_vm.showClearAllButton)?_c('div',{staticClass:"gl-ml-3 gl-p-1"},[_c('gl-button',{attrs:{"size":"small","aria-label":"Clear all","icon":"clear","category":"tertiary","data-testid":"clear-all-button"},on:{"click":function($event){$event.stopPropagation();return _vm.$emit('clear-all')}}})],1):_vm._e()])};
129
134
  var __vue_staticRenderFns__ = [];
130
135
 
131
136
  /* style */
@@ -1,4 +1,4 @@
1
- import { GlUniqueId } from '../../../utils/unique_id';
1
+ import uniqueId from 'lodash/uniqueId';
2
2
  import { tokensValidator } from './helpers';
3
3
  import GlTokenContainer from './token_container';
4
4
  import GlTokenSelectorDropdown from './token_selector_dropdown';
@@ -6,7 +6,7 @@ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
6
6
 
7
7
  var script = {
8
8
  name: 'GlTokenSelector',
9
- componentId: `token-selector-${GlUniqueId()}`,
9
+ componentId: uniqueId('token-selector'),
10
10
  components: {
11
11
  GlTokenContainer,
12
12
  GlTokenSelectorDropdown
@@ -75,7 +75,7 @@ var script = {
75
75
  default: ''
76
76
  },
77
77
  /**
78
- * The HTML5 autocomplete attribute value for the underlying `input` element.
78
+ * The autocomplete attribute value for the underlying `input` element
79
79
  */
80
80
  autocomplete: {
81
81
  type: String,
@@ -83,21 +83,7 @@ var script = {
83
83
  default: 'off'
84
84
  },
85
85
  /**
86
- * The `aria-label` attribute value for the underlying `input` element.
87
- * Input must have an aria-label or aria-labelledby prop or it will be inaccessible.
88
- *
89
- * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label
90
- */
91
- ariaLabel: {
92
- type: String,
93
- required: false,
94
- default: null
95
- },
96
- /**
97
- * The `aria-labelledby` attribute value for the underlying `input` element.
98
- * String must match the unique ID on a text element to create an accessible label.
99
- *
100
- * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-labelledby
86
+ * The `aria-labelledby` attribute value for the underlying `input` element
101
87
  */
102
88
  ariaLabelledby: {
103
89
  type: String,
@@ -378,15 +364,6 @@ var script = {
378
364
  clearAll() {
379
365
  this.$emit('input', []);
380
366
  this.focusTextInput();
381
- },
382
- handleAriaInvalid() {
383
- const {
384
- state
385
- } = this;
386
- return state === false ? 'true' : null;
387
- },
388
- handleAriaActiveDescendent(value) {
389
- return value ? `${this.$options.componentId}-dropdown-item-${value.id}` : null;
390
367
  }
391
368
  }
392
369
  };
@@ -403,7 +380,7 @@ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=
403
380
  _vm.containerClass,
404
381
  _vm.stateClass ],on:{"click":_vm.handleContainerClick}},[(_vm.showEmptyPlaceholder)?_vm._t("empty-placeholder"):_vm._e(),_vm._v(" "),_c('gl-token-container',{attrs:{"tokens":_vm.selectedTokens,"state":_vm.state,"register-focus-on-token":_vm.registerFocusOnToken,"view-only":_vm.viewOnly,"show-clear-all-button":_vm.showClearAllButton},on:{"token-remove":_vm.removeToken,"cancel-focus":_vm.cancelTokenFocus,"clear-all":_vm.clearAll},scopedSlots:_vm._u([{key:"token-content",fn:function(ref){
405
382
  var token = ref.token;
406
- return [_vm._t("token-content",null,{"token":token})]}},{key:"text-input",fn:function(){return [_c('input',_vm._b({ref:"textInput",staticClass:"gl-token-selector-input gl-h-auto gl-w-4/10 gl-grow gl-border-none gl-bg-transparent gl-px-1 gl-font-regular gl-text-base gl-leading-normal gl-text-default gl-outline-none",attrs:{"type":"text","aria-activedescendant":_vm.handleAriaActiveDescendent(_vm.focusedDropdownItem),"autocomplete":_vm.autocomplete,"aria-controls":_vm.$options.componentId,"aria-expanded":_vm.dropdownIsOpen.toString(),"aria-invalid":_vm.handleAriaInvalid(),"aria-label":_vm.ariaLabelledby ? null : _vm.ariaLabel,"aria-labelledby":_vm.ariaLabelledby,"placeholder":_vm.placeholder,"disabled":_vm.viewOnly,"aria-autocomplete":"list","role":"combobox"},domProps:{"value":_vm.inputText},on:{"input":function($event){_vm.inputText = $event.target.value;},"focus":_vm.handleFocus,"blur":_vm.handleBlur,"keydown":[function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }return _vm.handleEnter.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"esc",27,$event.key,["Esc","Escape"])){ return null; }return _vm.handleEscape.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"])){ return null; }return _vm.handleBackspace.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){ return null; }$event.preventDefault();return _vm.dropdownEventHandlers.handleUpArrow.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){ return null; }$event.preventDefault();return _vm.dropdownEventHandlers.handleDownArrow.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"home",undefined,$event.key,undefined)){ return null; }return _vm.dropdownEventHandlers.handleHomeKey.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"end",undefined,$event.key,undefined)){ return null; }return _vm.dropdownEventHandlers.handleEndKey.apply(null, arguments)},function($event){$event.stopPropagation();return _vm.$emit('keydown', $event)}],"click":_vm.handleInputClick}},'input',_vm.textInputAttrs,false))]},proxy:true}],null,true)})],2),_vm._v(" "),_c('gl-token-selector-dropdown',{attrs:{"menu-class":_vm.menuClass,"show":_vm.dropdownIsOpen,"loading":_vm.loading,"dropdown-items":_vm.filteredDropdownItems,"selected-tokens":_vm.selectedTokens,"input-text":_vm.inputText,"user-defined-token-can-be-added":_vm.userDefinedTokenCanBeAdded,"component-id":_vm.$options.componentId,"register-dropdown-event-handlers":_vm.registerDropdownEventHandlers,"register-reset-focused-dropdown-item":_vm.registerResetFocusedDropdownItem},on:{"dropdown-item-click":_vm.addToken,"input":_vm.handleAriaActiveDescendent,"show":_vm.openDropdown},scopedSlots:_vm._u([{key:"loading-content",fn:function(){return [_vm._t("loading-content")]},proxy:true},{key:"user-defined-token-content",fn:function(){return [_vm._t("user-defined-token-content",null,{"inputText":_vm.inputText})]},proxy:true},{key:"no-results-content",fn:function(){return [_vm._t("no-results-content")]},proxy:true},{key:"dropdown-item-content",fn:function(ref){
383
+ return [_vm._t("token-content",null,{"token":token})]}},{key:"text-input",fn:function(){return [_c('input',_vm._b({ref:"textInput",staticClass:"gl-token-selector-input gl-h-auto gl-w-4/10 gl-grow gl-border-none gl-bg-transparent gl-px-1 gl-font-regular gl-text-base gl-leading-normal gl-text-default gl-outline-none",attrs:{"type":"text","autocomplete":_vm.autocomplete,"aria-labelledby":_vm.ariaLabelledby,"placeholder":_vm.placeholder,"disabled":_vm.viewOnly},domProps:{"value":_vm.inputText},on:{"input":function($event){_vm.inputText = $event.target.value;},"focus":_vm.handleFocus,"blur":_vm.handleBlur,"keydown":[function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }return _vm.handleEnter.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"esc",27,$event.key,["Esc","Escape"])){ return null; }return _vm.handleEscape.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"])){ return null; }return _vm.handleBackspace.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){ return null; }$event.preventDefault();return _vm.dropdownEventHandlers.handleUpArrow.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){ return null; }$event.preventDefault();return _vm.dropdownEventHandlers.handleDownArrow.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"home",undefined,$event.key,undefined)){ return null; }return _vm.dropdownEventHandlers.handleHomeKey.apply(null, arguments)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"end",undefined,$event.key,undefined)){ return null; }return _vm.dropdownEventHandlers.handleEndKey.apply(null, arguments)},function($event){$event.stopPropagation();return _vm.$emit('keydown', $event)}],"click":_vm.handleInputClick}},'input',_vm.textInputAttrs,false))]},proxy:true}],null,true)})],2),_vm._v(" "),_c('gl-token-selector-dropdown',{attrs:{"menu-class":_vm.menuClass,"show":_vm.dropdownIsOpen,"loading":_vm.loading,"dropdown-items":_vm.filteredDropdownItems,"selected-tokens":_vm.selectedTokens,"input-text":_vm.inputText,"user-defined-token-can-be-added":_vm.userDefinedTokenCanBeAdded,"component-id":_vm.$options.componentId,"register-dropdown-event-handlers":_vm.registerDropdownEventHandlers,"register-reset-focused-dropdown-item":_vm.registerResetFocusedDropdownItem},on:{"dropdown-item-click":_vm.addToken,"show":_vm.openDropdown},scopedSlots:_vm._u([{key:"loading-content",fn:function(){return [_vm._t("loading-content")]},proxy:true},{key:"user-defined-token-content",fn:function(){return [_vm._t("user-defined-token-content",null,{"inputText":_vm.inputText})]},proxy:true},{key:"no-results-content",fn:function(){return [_vm._t("no-results-content")]},proxy:true},{key:"dropdown-item-content",fn:function(ref){
407
384
  var dropdownItem = ref.dropdownItem;
408
385
  return [_vm._t("dropdown-item-content",null,{"dropdownItem":dropdownItem})]}},{key:"dropdown-footer",fn:function(){return [_vm._t("dropdown-footer")]},proxy:true}],null,true),model:{value:(_vm.focusedDropdownItem),callback:function ($$v) {_vm.focusedDropdownItem=$$v;},expression:"focusedDropdownItem"}})],1)};
409
386
  var __vue_staticRenderFns__ = [];
@@ -188,7 +188,7 @@ var script = {
188
188
  const __vue_script__ = script;
189
189
 
190
190
  /* template */
191
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"dropdown b-dropdown gl-dropdown gl-relative",class:{ show: _vm.show }},[_c('ul',{ref:"dropdownMenu",staticClass:"dropdown-menu gl-absolute",class:[{ show: _vm.show }, _vm.menuClass],attrs:{"id":_vm.componentId,"role":"listbox"}},[(_vm.loading)?_c('gl-dropdown-item',{attrs:{"disabled":""}},[_vm._t("loading-content",function(){return [_vm._v("Searching...")]})],2):_vm._e(),_vm._v(" "),_vm._l((_vm.dropdownItems),function(dropdownItem){return _c('gl-dropdown-item',{key:dropdownItem.id,ref:"dropdownItems",refInFor:true,attrs:{"id":_vm.dropdownItemIdAttribute(dropdownItem),"data-dropdown-item-id":dropdownItem.id,"active":_vm.dropdownItemIsFocused(dropdownItem),"aria-selected":_vm.dropdownItemIsFocused(dropdownItem).toString(),"active-class":"is-focused","role":"option","tabindex":"-1"},on:{"click":function($event){return _vm.handleDropdownItemClick(dropdownItem)}}},[_c('div',{staticClass:"-gl-mx-4 -gl-my-3 gl-px-4 gl-py-3",on:{"mousedown":function($event){return _vm.handleMousedown(dropdownItem)}}},[_vm._t("dropdown-item-content",function(){return [_vm._v("\n "+_vm._s(dropdownItem.name)+"\n ")]},{"dropdownItem":dropdownItem})],2)])}),_vm._v(" "),(_vm.userDefinedTokenCanBeAdded)?_c('gl-dropdown-item',{ref:_vm.userDefinedToken.id,attrs:{"id":_vm.dropdownItemIdAttribute(_vm.userDefinedToken),"data-dropdown-item-id":_vm.userDefinedToken.id,"active":_vm.dropdownItemIsFocused(_vm.userDefinedToken),"active-class":"is-focused","tabindex":"-1"},on:{"click":function($event){return _vm.handleDropdownItemClick(_vm.userDefinedToken)}}},[_c('div',{staticClass:"-gl-mx-4 -gl-my-3 gl-px-4 gl-py-3",on:{"mousedown":function($event){return _vm.handleMousedown(_vm.userDefinedToken)}}},[_vm._t("user-defined-token-content",function(){return [_vm._v("\n Add \""+_vm._s(_vm.inputText)+"\"\n ")]},{"inputText":_vm.inputText})],2)]):(!_vm.dropdownItems.length)?_c('gl-dropdown-item',{attrs:{"disabled":""}},[_vm._t("no-results-content",function(){return [_vm._v("No matches found")]})],2):_vm._e(),_vm._v(" "),_vm._t("dropdown-footer")],2)])};
191
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"dropdown b-dropdown gl-dropdown gl-relative",class:{ show: _vm.show }},[_c('ul',{ref:"dropdownMenu",staticClass:"dropdown-menu gl-absolute",class:[{ show: _vm.show }, _vm.menuClass],attrs:{"role":"menu","aria-activedescendant":_vm.dropdownItemIdAttribute(_vm.focusedDropdownItem)}},[(_vm.loading)?_c('gl-dropdown-item',{attrs:{"disabled":""}},[_vm._t("loading-content",function(){return [_vm._v("Searching...")]})],2):_vm._e(),_vm._v(" "),_vm._l((_vm.dropdownItems),function(dropdownItem){return _c('gl-dropdown-item',{key:dropdownItem.id,ref:"dropdownItems",refInFor:true,attrs:{"id":_vm.dropdownItemIdAttribute(dropdownItem),"data-dropdown-item-id":dropdownItem.id,"active":_vm.dropdownItemIsFocused(dropdownItem),"active-class":"is-focused","tabindex":"-1"},on:{"click":function($event){return _vm.handleDropdownItemClick(dropdownItem)}}},[_c('div',{staticClass:"-gl-mx-4 -gl-my-3 gl-px-4 gl-py-3",on:{"mousedown":function($event){return _vm.handleMousedown(dropdownItem)}}},[_vm._t("dropdown-item-content",function(){return [_vm._v("\n "+_vm._s(dropdownItem.name)+"\n ")]},{"dropdownItem":dropdownItem})],2)])}),_vm._v(" "),(_vm.userDefinedTokenCanBeAdded)?_c('gl-dropdown-item',{ref:_vm.userDefinedToken.id,attrs:{"id":_vm.dropdownItemIdAttribute(_vm.userDefinedToken),"data-dropdown-item-id":_vm.userDefinedToken.id,"active":_vm.dropdownItemIsFocused(_vm.userDefinedToken),"active-class":"is-focused","tabindex":"-1"},on:{"click":function($event){return _vm.handleDropdownItemClick(_vm.userDefinedToken)}}},[_c('div',{staticClass:"-gl-mx-4 -gl-my-3 gl-px-4 gl-py-3",on:{"mousedown":function($event){return _vm.handleMousedown(_vm.userDefinedToken)}}},[_vm._t("user-defined-token-content",function(){return [_vm._v("\n Add \""+_vm._s(_vm.inputText)+"\"\n ")]},{"inputText":_vm.inputText})],2)]):(!_vm.dropdownItems.length)?_c('gl-dropdown-item',{attrs:{"disabled":""}},[_vm._t("no-results-content",function(){return [_vm._v("No matches found")]})],2):_vm._e(),_vm._v(" "),_vm._t("dropdown-footer")],2)])};
192
192
  var __vue_staticRenderFns__ = [];
193
193
 
194
194
  /* style */
@@ -86,6 +86,14 @@ var script = {
86
86
  required: false,
87
87
  default: () => ({})
88
88
  },
89
+ /**
90
+ * CSS classes to apply to the title popover (gets passed to the `css-classes` prop of the `GlPopover` component).
91
+ */
92
+ titlePopoverClasses: {
93
+ type: Array,
94
+ required: false,
95
+ default: () => []
96
+ },
89
97
  /**
90
98
  * Set to `true` to show the loading state.
91
99
  */
@@ -182,7 +190,7 @@ var script = {
182
190
  const __vue_script__ = script;
183
191
 
184
192
  /* template */
185
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-border gl-h-full !gl-overflow-visible gl-rounded-lg gl-bg-white gl-p-5",class:_vm.containerClasses,attrs:{"id":_vm.panelId}},[_c('div',{staticClass:"gl-flex gl-h-full gl-flex-col"},[_c('div',{staticClass:"gl-flex gl-items-start gl-justify-between",attrs:{"data-testid":"panel-title"}},[_c('div',{staticClass:"gl-flex gl-items-center gl-overflow-hidden gl-pb-3"},[(_vm.hasTitleIcon)?_c('gl-icon',{staticClass:"gl-mr-2",class:_vm.titleIconClass,attrs:{"name":_vm.titleIcon,"data-testid":"panel-title-icon"}}):_vm._e(),_vm._v(" "),(_vm.hasTitle)?_c('gl-truncate',{staticClass:"gl-min-w-0 gl-font-bold gl-text-default",attrs:{"text":_vm.title,"with-tooltip":""}}):_vm._e(),_vm._v(" "),(_vm.hasTitlePopover)?[_c('gl-icon',{staticClass:"gl-ml-2 gl-min-w-5",attrs:{"id":_vm.titlePopoverId,"data-testid":"panel-title-popover-icon","name":"information-o","variant":"info"}}),_vm._v(" "),_c('gl-popover',{attrs:{"data-testid":"panel-title-popover","boundary":"viewport","target":_vm.titlePopoverId},scopedSlots:_vm._u([(_vm.hasInfoPopoverTitleSlot)?{key:"title",fn:function(){return [_vm._t("info-popover-title")]},proxy:true}:null],null,true)},[_vm._v(" "),(_vm.hasInfoPopoverContentSlot)?[_vm._t("info-popover-content")]:_vm._e(),_vm._v(" "),(!_vm.hasInfoPopoverContentSlot)?[(_vm.hasTitlePopoverLink)?_c('gl-sprintf',{attrs:{"message":_vm.titlePopover.description},scopedSlots:_vm._u([{key:"link",fn:function(ref){
193
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-border gl-h-full !gl-overflow-visible gl-rounded-lg gl-bg-white gl-p-5",class:_vm.containerClasses,attrs:{"id":_vm.panelId}},[_c('div',{staticClass:"gl-flex gl-h-full gl-flex-col"},[_c('div',{staticClass:"gl-flex gl-items-start gl-justify-between",attrs:{"data-testid":"panel-title"}},[_c('div',{staticClass:"gl-flex gl-items-center gl-overflow-hidden gl-pb-3"},[(_vm.hasTitleIcon)?_c('gl-icon',{staticClass:"gl-mr-2",class:_vm.titleIconClass,attrs:{"name":_vm.titleIcon,"data-testid":"panel-title-icon"}}):_vm._e(),_vm._v(" "),(_vm.hasTitle)?_c('gl-truncate',{staticClass:"gl-min-w-0 gl-font-bold gl-text-default",attrs:{"text":_vm.title,"with-tooltip":""}}):_vm._e(),_vm._v(" "),(_vm.hasTitlePopover)?[_c('gl-icon',{staticClass:"gl-ml-2 gl-min-w-5",attrs:{"id":_vm.titlePopoverId,"data-testid":"panel-title-popover-icon","name":"information-o","variant":"info"}}),_vm._v(" "),_c('gl-popover',{attrs:{"data-testid":"panel-title-popover","boundary":"viewport","target":_vm.titlePopoverId,"css-classes":_vm.titlePopoverClasses},scopedSlots:_vm._u([(_vm.hasInfoPopoverTitleSlot)?{key:"title",fn:function(){return [_vm._t("info-popover-title")]},proxy:true}:null],null,true)},[_vm._v(" "),(_vm.hasInfoPopoverContentSlot)?[_vm._t("info-popover-content")]:_vm._e(),_vm._v(" "),(!_vm.hasInfoPopoverContentSlot)?[(_vm.hasTitlePopoverLink)?_c('gl-sprintf',{attrs:{"message":_vm.titlePopover.description},scopedSlots:_vm._u([{key:"link",fn:function(ref){
186
194
  var content = ref.content;
187
195
  return [_c('gl-link',{staticClass:"gl-text-sm",attrs:{"href":_vm.titlePopover.descriptionLink}},[_vm._v(_vm._s(content))])]}}],null,false,3051540671)}):[_vm._v(" "+_vm._s(_vm.titlePopover.description)+" ")]]:_vm._e()],2)]:_vm._e()],2),_vm._v(" "),(_vm.shouldShowActions || _vm.$scopedSlots.filters)?_c('div',{staticClass:"gl-flex gl-flex-col gl-items-end gl-gap-2",attrs:{"data-testid":"panel-actions-filters-container"}},[(_vm.shouldShowActions)?_c('gl-disclosure-dropdown',{attrs:{"items":_vm.actions,"icon":"ellipsis_v","toggle-text":_vm.actionsToggleText,"text-sr-only":"","no-caret":"","placement":"bottom-end","fluid-width":"","toggle-class":"gl-ml-1","category":"tertiary","positioning-strategy":"fixed","size":"small"},on:{"shown":function($event){return _vm.$emit('dropdownOpen')},"hidden":function($event){return _vm.$emit('dropdownClosed')}},scopedSlots:_vm._u([{key:"list-item",fn:function(ref){
188
196
  var item = ref.item;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "122.12.1",
3
+ "version": "122.13.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -13,6 +13,11 @@ export default {
13
13
  validator: tokensValidator,
14
14
  required: true,
15
15
  },
16
+ state: {
17
+ type: Boolean,
18
+ required: false,
19
+ default: null,
20
+ },
16
21
  registerFocusOnToken: {
17
22
  type: Function,
18
23
  required: true,
@@ -128,6 +133,11 @@ export default {
128
133
  <div
129
134
  ref="tokenContainer"
130
135
  class="-gl-mx-1 -gl-my-1 gl-flex gl-w-auto gl-list-none gl-flex-wrap gl-items-center gl-p-0"
136
+ role="listbox"
137
+ aria-multiselectable="false"
138
+ aria-orientation="horizontal"
139
+ :aria-invalid="state === false && 'true'"
140
+ aria-label="token list"
131
141
  @keydown.left="handleLeftArrow"
132
142
  @keydown.right="handleRightArrow"
133
143
  @keydown.home="handleHome"
@@ -142,7 +152,7 @@ export default {
142
152
  :key="token.id"
143
153
  :data-token-id="token.id"
144
154
  class="gl-token-selector-token-container gl-px-1 gl-py-2 gl-outline-none"
145
- data-testid="gl-token-selector-tokens"
155
+ role="option"
146
156
  tabindex="-1"
147
157
  @focus="bindFocusEvent ? handleTokenFocus(index) : null"
148
158
  >
@@ -1,12 +1,12 @@
1
1
  <script>
2
- import { GlUniqueId } from '../../../utils/unique_id';
2
+ import uniqueId from 'lodash/uniqueId';
3
3
  import { tokensValidator } from './helpers';
4
4
  import GlTokenContainer from './token_container.vue';
5
5
  import GlTokenSelectorDropdown from './token_selector_dropdown.vue';
6
6
 
7
7
  export default {
8
8
  name: 'GlTokenSelector',
9
- componentId: `token-selector-${GlUniqueId()}`,
9
+ componentId: uniqueId('token-selector'),
10
10
  components: {
11
11
  GlTokenContainer,
12
12
  GlTokenSelectorDropdown,
@@ -75,7 +75,7 @@ export default {
75
75
  default: '',
76
76
  },
77
77
  /**
78
- * The HTML5 autocomplete attribute value for the underlying `input` element.
78
+ * The autocomplete attribute value for the underlying `input` element
79
79
  */
80
80
  autocomplete: {
81
81
  type: String,
@@ -83,21 +83,7 @@ export default {
83
83
  default: 'off',
84
84
  },
85
85
  /**
86
- * The `aria-label` attribute value for the underlying `input` element.
87
- * Input must have an aria-label or aria-labelledby prop or it will be inaccessible.
88
- *
89
- * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label
90
- */
91
- ariaLabel: {
92
- type: String,
93
- required: false,
94
- default: null,
95
- },
96
- /**
97
- * The `aria-labelledby` attribute value for the underlying `input` element.
98
- * String must match the unique ID on a text element to create an accessible label.
99
- *
100
- * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-labelledby
86
+ * The `aria-labelledby` attribute value for the underlying `input` element
101
87
  */
102
88
  ariaLabelledby: {
103
89
  type: String,
@@ -396,13 +382,6 @@ export default {
396
382
  this.$emit('input', []);
397
383
  this.focusTextInput();
398
384
  },
399
- handleAriaInvalid() {
400
- const { state } = this;
401
- return state === false ? 'true' : null;
402
- },
403
- handleAriaActiveDescendent(value) {
404
- return value ? `${this.$options.componentId}-dropdown-item-${value.id}` : null;
405
- },
406
385
  },
407
386
  };
408
387
  </script>
@@ -449,17 +428,10 @@ export default {
449
428
  type="text"
450
429
  class="gl-token-selector-input gl-h-auto gl-w-4/10 gl-grow gl-border-none gl-bg-transparent gl-px-1 gl-font-regular gl-text-base gl-leading-normal gl-text-default gl-outline-none"
451
430
  :value="inputText"
452
- :aria-activedescendant="handleAriaActiveDescendent(focusedDropdownItem)"
453
431
  :autocomplete="autocomplete"
454
- :aria-controls="$options.componentId"
455
- :aria-expanded="dropdownIsOpen.toString()"
456
- :aria-invalid="handleAriaInvalid()"
457
- :aria-label="ariaLabelledby ? null : ariaLabel"
458
432
  :aria-labelledby="ariaLabelledby"
459
433
  :placeholder="placeholder"
460
434
  :disabled="viewOnly"
461
- aria-autocomplete="list"
462
- role="combobox"
463
435
  v-bind="textInputAttrs"
464
436
  @input="inputText = $event.target.value"
465
437
  @focus="handleFocus"
@@ -490,7 +462,6 @@ export default {
490
462
  :register-dropdown-event-handlers="registerDropdownEventHandlers"
491
463
  :register-reset-focused-dropdown-item="registerResetFocusedDropdownItem"
492
464
  @dropdown-item-click="addToken"
493
- @input="handleAriaActiveDescendent"
494
465
  @show="openDropdown"
495
466
  >
496
467
  <template #loading-content
@@ -199,10 +199,10 @@ export default {
199
199
  <template>
200
200
  <div class="dropdown b-dropdown gl-dropdown gl-relative" :class="{ show }">
201
201
  <ul
202
- :id="componentId"
203
202
  ref="dropdownMenu"
204
- role="listbox"
203
+ role="menu"
205
204
  class="dropdown-menu gl-absolute"
205
+ :aria-activedescendant="dropdownItemIdAttribute(focusedDropdownItem)"
206
206
  :class="[{ show }, menuClass]"
207
207
  >
208
208
  <gl-dropdown-item v-if="loading" disabled>
@@ -216,9 +216,7 @@ export default {
216
216
  :key="dropdownItem.id"
217
217
  :data-dropdown-item-id="dropdownItem.id"
218
218
  :active="dropdownItemIsFocused(dropdownItem)"
219
- :aria-selected="dropdownItemIsFocused(dropdownItem).toString()"
220
219
  active-class="is-focused"
221
- role="option"
222
220
  tabindex="-1"
223
221
  @click="handleDropdownItemClick(dropdownItem)"
224
222
  >
@@ -86,6 +86,14 @@ export default {
86
86
  required: false,
87
87
  default: () => ({}),
88
88
  },
89
+ /**
90
+ * CSS classes to apply to the title popover (gets passed to the `css-classes` prop of the `GlPopover` component).
91
+ */
92
+ titlePopoverClasses: {
93
+ type: Array,
94
+ required: false,
95
+ default: () => [],
96
+ },
89
97
  /**
90
98
  * Set to `true` to show the loading state.
91
99
  */
@@ -218,6 +226,7 @@ export default {
218
226
  data-testid="panel-title-popover"
219
227
  boundary="viewport"
220
228
  :target="titlePopoverId"
229
+ :css-classes="titlePopoverClasses"
221
230
  >
222
231
  <!-- @slot The title of the info popover. -->
223
232
  <template v-if="hasInfoPopoverTitleSlot" #title>
@@ -1,18 +0,0 @@
1
- /**
2
- * Function uses browser native crypto to return a sixteen
3
- * character base16 encoded string. It is often used to
4
- * generate collision-resistant IDs for aria markup such
5
- * as aria-activedescendant and aria-controls.
6
- *
7
- * @returns String
8
- */
9
- const GlUniqueId = () => {
10
- if (typeof window !== 'undefined' && window.crypto) {
11
- const arr32 = new Uint32Array(2);
12
- window.crypto.getRandomValues(arr32);
13
- return Array.from(arr32, id => id.toString(16)).join('');
14
- }
15
- throw new Error('Cannot generate a unique ID');
16
- };
17
-
18
- export { GlUniqueId };
@@ -1,17 +0,0 @@
1
- /**
2
- * Function uses browser native crypto to return a sixteen
3
- * character base16 encoded string. It is often used to
4
- * generate collision-resistant IDs for aria markup such
5
- * as aria-activedescendant and aria-controls.
6
- *
7
- * @returns String
8
- */
9
- export const GlUniqueId = () => {
10
- if (typeof window !== 'undefined' && window.crypto) {
11
- const arr32 = new Uint32Array(2);
12
- window.crypto.getRandomValues(arr32);
13
- return Array.from(arr32, (id) => id.toString(16)).join('');
14
- }
15
-
16
- throw new Error('Cannot generate a unique ID');
17
- };