@gitlab/ui 129.3.2 → 129.5.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.
@@ -12,6 +12,7 @@ var script = {
12
12
  CloseButton,
13
13
  GlButton
14
14
  },
15
+ expose: ['focus'],
15
16
  props: {
16
17
  /**
17
18
  * The title text to display in the alert header.
@@ -116,6 +117,11 @@ var script = {
116
117
  }
117
118
  }
118
119
  },
120
+ data() {
121
+ return {
122
+ hasProgrammaticFocus: false
123
+ };
124
+ },
119
125
  computed: {
120
126
  headingComponent() {
121
127
  return `h${this.headerLevel}`;
@@ -175,6 +181,13 @@ var script = {
175
181
  }
176
182
  },
177
183
  methods: {
184
+ /**
185
+ * Focus the alert.
186
+ */
187
+ focus() {
188
+ this.$el.focus();
189
+ this.hasProgrammaticFocus = true;
190
+ },
178
191
  primaryButtonClicked(event) {
179
192
  /**
180
193
  * Emitted when the primary action button is clicked.
@@ -214,7 +227,8 @@ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=
214
227
  { 'gl-alert-sticky': _vm.sticky },
215
228
  { 'gl-alert-not-dismissible': !_vm.dismissible },
216
229
  { 'gl-alert-has-title': !!_vm.title },
217
- _vm.variantClass ],attrs:{"role":_vm.role,"aria-live":_vm.politeness}},[_c('div',{staticClass:"gl-alert-icon-container"},[_c('gl-icon',{staticClass:"gl-alert-icon",attrs:{"name":_vm.iconName}})],1),_vm._v(" "),_c('div',{staticClass:"gl-alert-content"},[(_vm.title)?_c(_vm.headingComponent,{tag:"component",staticClass:"gl-alert-title"},[_vm._v(_vm._s(_vm.title))]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-alert-body"},[_vm._t("default")],2),_vm._v(" "),(_vm.shouldRenderActions)?_c('div',{staticClass:"gl-alert-actions"},[_vm._t("actions",function(){return _vm._l((_vm.actionButtons),function(actionButton,index){return _c('gl-button',_vm._g(_vm._b({key:index,staticClass:"gl-alert-action"},'gl-button',actionButton.attrs,false),actionButton.listeners),[_vm._v("\n "+_vm._s(actionButton.text)+"\n ")])})})],2):_vm._e()],1),_vm._v(" "),(_vm.dismissible)?_c('close-button',{ref:"dismiss",staticClass:"gl-dismiss-btn",attrs:{"label":_vm.dismissLabel},on:{"click":_vm.onDismiss}}):_vm._e()],1)};
230
+ { 'gl-focus': _vm.hasProgrammaticFocus },
231
+ _vm.variantClass ],attrs:{"role":_vm.role,"aria-live":_vm.politeness,"tabindex":"-1"},on:{"blur":function($event){_vm.hasProgrammaticFocus = false;}}},[_c('div',{staticClass:"gl-alert-icon-container"},[_c('gl-icon',{staticClass:"gl-alert-icon",attrs:{"name":_vm.iconName}})],1),_vm._v(" "),_c('div',{staticClass:"gl-alert-content"},[(_vm.title)?_c(_vm.headingComponent,{tag:"component",staticClass:"gl-alert-title"},[_vm._v(_vm._s(_vm.title))]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-alert-body"},[_vm._t("default")],2),_vm._v(" "),(_vm.shouldRenderActions)?_c('div',{staticClass:"gl-alert-actions"},[_vm._t("actions",function(){return _vm._l((_vm.actionButtons),function(actionButton,index){return _c('gl-button',_vm._g(_vm._b({key:index,staticClass:"gl-alert-action"},'gl-button',actionButton.attrs,false),actionButton.listeners),[_vm._v("\n "+_vm._s(actionButton.text)+"\n ")])})})],2):_vm._e()],1),_vm._v(" "),(_vm.dismissible)?_c('close-button',{ref:"dismiss",staticClass:"gl-dismiss-btn",attrs:{"label":_vm.dismissLabel},on:{"click":_vm.onDismiss}}):_vm._e()],1)};
218
232
  var __vue_staticRenderFns__ = [];
219
233
 
220
234
  /* style */
@@ -247,7 +247,7 @@ var script = {
247
247
  const __vue_script__ = script;
248
248
 
249
249
  /* template */
250
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('nav',{staticClass:"gl-breadcrumbs",style:(_vm.breadcrumbStyle),attrs:{"aria-label":_vm.ariaLabel}},[_c('ol',_vm._g(_vm._b({staticClass:"gl-breadcrumb-list breadcrumb"},'ol',_vm.$attrs,false),_vm.$listeners),[(_vm.hasCollapsible || !_vm.resizeDone)?_c('li',{ref:"dropdown",class:("gl-breadcrumb-item gl-breadcrumb-item-" + _vm.size)},[_c('gl-disclosure-dropdown',{attrs:{"items":_vm.overflowingItems,"toggle-text":_vm.showMoreLabel,"fluid-width":"","text-sr-only":"","no-caret":"","icon":"ellipsis_h","size":_vm.dropdownSize}})],1):_vm._e(),_vm._v(" "),_vm._l((_vm.fittingItems),function(item,index){return _c('gl-breadcrumb-item',{key:index,ref:"breadcrumbs",refInFor:true,class:_vm.itemClass,attrs:{"text":item.text,"href":item.href,"to":item.to,"size":_vm.size,"aria-current":_vm.getAriaCurrentAttr(index)},scopedSlots:_vm._u([{key:"default",fn:function(){return [(item.avatarPath)?_c('gl-avatar',{staticClass:"gl-breadcrumb-avatar-tile gl-border gl-mr-2 !gl-rounded-default",attrs:{"src":item.avatarPath,"size":_vm.avatarSize,"aria-hidden":"true","shape":"rect","data-testid":"avatar"}}):_vm._e(),_c('span',{staticClass:"gl-align-middle"},[_vm._v(_vm._s(item.text))])]},proxy:true}],null,true)})}),_vm._v(" "),(_vm.showClipboardButton)?_c('li',{staticClass:"gl-breadcrumb-clipboard-button"},[_c('clipboard-button',_vm._b({ref:"clipboardButton",staticClass:"gl-ml-2",attrs:{"data-testid":"copy-to-clipboard-button","text":_vm.clipboardButtonText,"size":_vm.dropdownSize}},'clipboard-button',_vm.clipboardTooltipText ? { title: _vm.clipboardTooltipText } : {},false))],1):_vm._e()],2)])};
250
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('nav',{staticClass:"gl-breadcrumbs",style:(_vm.breadcrumbStyle),attrs:{"aria-label":_vm.ariaLabel}},[_c('ol',_vm._g(_vm._b({staticClass:"gl-breadcrumb-list breadcrumb"},'ol',_vm.$attrs,false),_vm.$listeners),[(_vm.hasCollapsible || !_vm.resizeDone)?_c('li',{ref:"dropdown",class:("gl-breadcrumb-item gl-breadcrumb-item-" + _vm.size)},[_c('gl-disclosure-dropdown',{attrs:{"items":_vm.overflowingItems,"toggle-text":_vm.showMoreLabel,"fluid-width":"","text-sr-only":"","no-caret":"","icon":"ellipsis_h","size":_vm.dropdownSize}})],1):_vm._e(),_vm._v(" "),_vm._l((_vm.fittingItems),function(item,index){return _c('gl-breadcrumb-item',{key:index,ref:"breadcrumbs",refInFor:true,class:_vm.itemClass,attrs:{"text":item.text,"href":item.href,"to":item.to,"size":_vm.size,"aria-current":_vm.getAriaCurrentAttr(index)},scopedSlots:_vm._u([{key:"default",fn:function(){return [(item.avatarPath)?_c('gl-avatar',{staticClass:"gl-breadcrumb-avatar-tile gl-border gl-mr-2",attrs:{"src":item.avatarPath,"size":_vm.avatarSize,"aria-hidden":"true","shape":"rect","data-testid":"avatar"}}):_vm._e(),_c('span',{staticClass:"gl-align-middle"},[_vm._v(_vm._s(item.text))])]},proxy:true}],null,true)})}),_vm._v(" "),(_vm.showClipboardButton)?_c('li',{staticClass:"gl-breadcrumb-clipboard-button"},[_c('clipboard-button',_vm._b({ref:"clipboardButton",staticClass:"gl-ml-2",attrs:{"data-testid":"copy-to-clipboard-button","text":_vm.clipboardButtonText,"size":_vm.dropdownSize}},'clipboard-button',_vm.clipboardTooltipText ? { title: _vm.clipboardTooltipText } : {},false))],1):_vm._e()],2)])};
251
251
  var __vue_staticRenderFns__ = [];
252
252
 
253
253
  /* style */
@@ -1,4 +1,5 @@
1
1
  import { uniqueId } from 'lodash-es';
2
+ import { logWarning } from '../../../utils/utils';
2
3
  import { tokensValidator } from './helpers';
3
4
  import GlTokenContainer from './token_container';
4
5
  import GlTokenSelectorDropdown from './token_selector_dropdown';
@@ -34,7 +35,7 @@ var script = {
34
35
  default: false
35
36
  },
36
37
  /**
37
- * Shows 'Add new token option' in dropdown even if results are present, requires allowUserDefinedTokens to be true
38
+ * Shows "Add new token option" in dropdown even if results are present. Requires `allowUserDefinedTokens` to be `true`.
38
39
  */
39
40
  showAddNewAlways: {
40
41
  type: Boolean,
@@ -83,7 +84,7 @@ var script = {
83
84
  },
84
85
  /**
85
86
  * The `aria-label` attribute value for the underlying `input` element.
86
- * Input must have an aria-label or aria-labelledby prop or it will be inaccessible.
87
+ * Input must have an `aria-label` or `aria-labelledby` prop or it will be inaccessible.
87
88
  *
88
89
  * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label
89
90
  */
@@ -112,7 +113,8 @@ var script = {
112
113
  default: null
113
114
  },
114
115
  /**
115
- * HTML attributes to add to the text input. Helpful for adding `data-testid` attributes
116
+ * HTML attributes to add to the text input. Helpful for adding `data-testid` and similar attributes.
117
+ * Do not pass `aria-label` or `aria-labelledby` into this object. Use `ariaLabel` or `ariaLabelledby` prop instead.
116
118
  */
117
119
  textInputAttrs: {
118
120
  type: Object,
@@ -246,6 +248,15 @@ var script = {
246
248
  // Each instance must have a unique ID for proper ARIA relationships
247
249
  this.uniqueId = uniqueId('token-selector-');
248
250
  },
251
+ mounted() {
252
+ var _this$textInputAttrs;
253
+ const hasLabel = this.ariaLabel || ((_this$textInputAttrs = this.textInputAttrs) === null || _this$textInputAttrs === void 0 ? void 0 : _this$textInputAttrs['aria-label']) || this.ariaLabelledby;
254
+ if (!hasLabel) {
255
+ logWarning('The text input needs an accessible label. ' + 'Provide an `id` and a sibling `<label>` with a `for` attribute. Or add an `aria-labelledby` or `aria-label` prop to ensure the component is accessible. ' + 'See https://design.gitlab.com/components/token/#accessibility', {
256
+ name: 'GlTokenSelector'
257
+ });
258
+ }
259
+ },
249
260
  methods: {
250
261
  handleFocus(event) {
251
262
  /**