@gitlab/ui 137.3.0 → 137.3.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.
@@ -227,8 +227,9 @@ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=
227
227
  { 'gl-alert-sticky': _vm.sticky },
228
228
  { 'gl-alert-not-dismissible': !_vm.dismissible },
229
229
  { 'gl-alert-has-title': !!_vm.title },
230
+ { 'gl-alert-has-actions': _vm.shouldRenderActions },
230
231
  { '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)};
232
+ _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",attrs:{"size":"small"}},'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)};
232
233
  var __vue_staticRenderFns__ = [];
233
234
 
234
235
  /* style */
@@ -345,6 +345,9 @@ var script = {
345
345
  this.closeAndFocus();
346
346
  }
347
347
  },
348
+ isDisabled(item) {
349
+ return item.disabled;
350
+ },
348
351
  uniqueItemId() {
349
352
  return uniqueId(`disclosure-item-`);
350
353
  },
@@ -357,7 +360,7 @@ var script = {
357
360
  const __vue_script__ = script;
358
361
 
359
362
  /* template */
360
- 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,"aria-label":_vm.toggleAriaLabelledBy ? undefined : _vm.toggleAriaLabel,"arrow-element":_vm.$refs.disclosureArrow,"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,"block":_vm.block,"offset":_vm.dropdownOffset,"fluid-width":_vm.fluidWidth,"positioning-strategy":_vm.positioningStrategy,"is-disclosure":""},on:_vm._d({},[_vm.$options.events.GL_DROPDOWN_SHOWN,_vm.onShow,_vm.$options.events.GL_DROPDOWN_HIDDEN,_vm.onHide,_vm.$options.events.GL_DROPDOWN_BEFORE_CLOSE,_vm.onBeforeClose,_vm.$options.events.GL_DROPDOWN_FOCUS_CONTENT,_vm.onKeydown]),scopedSlots:_vm._u([(_vm.hasCustomToggle)?{key:"toggle",fn:function(slotProps){return [_vm._t("toggle",null,null,slotProps)]}}:null],null,true)},[_vm._v(" "),_vm._t("header"),_vm._v(" "),_c(_vm.disclosureTag,{ref:"content",tag:"component",class:_vm.$options.GL_DROPDOWN_CONTENTS_CLASS,attrs:{"id":_vm.disclosureId,"aria-labelledby":_vm.listAriaLabelledBy || _vm.toggleId,"data-testid":"disclosure-content","tabindex":"-1"},on:{"keydown":_vm.onKeydown,"click":_vm.handleAutoClose}},[_vm._t("default",function(){return [_vm._l((_vm.items),function(item,index){return [(_vm.isItem(item))?[_c('gl-disclosure-dropdown-item',{key:_vm.uniqueItemId(),attrs:{"siblings-have-icons":_vm.siblingsHaveIcons,"item":item},on:{"action":_vm.handleAction},scopedSlots:_vm._u([('list-item' in _vm.$scopedSlots)?{key:"list-item",fn:function(){return [_vm._t("list-item",null,{"item":item})]},proxy:true}:null],null,true)})]:[_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,(_vm.$scopedSlots['list-item'])?{key:"default",fn:function(){return _vm._l((item.items),function(groupItem){return _c('gl-disclosure-dropdown-item',{key:_vm.uniqueItemId(),attrs:{"siblings-have-icons":_vm.doSomeItemsHaveIcon(item.items),"item":groupItem},on:{"action":_vm.handleAction},scopedSlots:_vm._u([{key:"list-item",fn:function(){return [_vm._t("list-item",null,{"item":groupItem})]},proxy:true}],null,true)})})},proxy:true}:null],null,true)})]]})]})],2),_vm._v(" "),_vm._t("footer")],2)};
363
+ 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,"aria-label":_vm.toggleAriaLabelledBy ? undefined : _vm.toggleAriaLabel,"arrow-element":_vm.$refs.disclosureArrow,"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,"block":_vm.block,"offset":_vm.dropdownOffset,"fluid-width":_vm.fluidWidth,"positioning-strategy":_vm.positioningStrategy,"is-disclosure":""},on:_vm._d({},[_vm.$options.events.GL_DROPDOWN_SHOWN,_vm.onShow,_vm.$options.events.GL_DROPDOWN_HIDDEN,_vm.onHide,_vm.$options.events.GL_DROPDOWN_BEFORE_CLOSE,_vm.onBeforeClose,_vm.$options.events.GL_DROPDOWN_FOCUS_CONTENT,_vm.onKeydown]),scopedSlots:_vm._u([(_vm.hasCustomToggle)?{key:"toggle",fn:function(slotProps){return [_vm._t("toggle",null,null,slotProps)]}}:null],null,true)},[_vm._v(" "),_vm._t("header"),_vm._v(" "),_c(_vm.disclosureTag,{ref:"content",tag:"component",class:_vm.$options.GL_DROPDOWN_CONTENTS_CLASS,attrs:{"id":_vm.disclosureId,"aria-labelledby":_vm.listAriaLabelledBy || _vm.toggleId,"data-testid":"disclosure-content","tabindex":"-1"},on:{"keydown":_vm.onKeydown,"click":_vm.handleAutoClose}},[_vm._t("default",function(){return [_vm._l((_vm.items),function(item,index){return [(_vm.isItem(item))?[_c('gl-disclosure-dropdown-item',{key:_vm.uniqueItemId(),attrs:{"siblings-have-icons":_vm.siblingsHaveIcons,"item":item,"disabled":_vm.isDisabled(item)},on:{"action":_vm.handleAction},scopedSlots:_vm._u([('list-item' in _vm.$scopedSlots)?{key:"list-item",fn:function(){return [_vm._t("list-item",null,{"item":item})]},proxy:true}:null],null,true)})]:[_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,(_vm.$scopedSlots['list-item'])?{key:"default",fn:function(){return _vm._l((item.items),function(groupItem){return _c('gl-disclosure-dropdown-item',{key:_vm.uniqueItemId(),attrs:{"siblings-have-icons":_vm.doSomeItemsHaveIcon(item.items),"item":groupItem},on:{"action":_vm.handleAction},scopedSlots:_vm._u([{key:"list-item",fn:function(){return [_vm._t("list-item",null,{"item":groupItem})]},proxy:true}],null,true)})})},proxy:true}:null],null,true)})]]})]})],2),_vm._v(" "),_vm._t("footer")],2)};
361
364
  var __vue_staticRenderFns__ = [];
362
365
 
363
366
  /* style */
@@ -51,6 +51,14 @@ var script = {
51
51
  type: Boolean,
52
52
  default: false,
53
53
  required: false
54
+ },
55
+ /**
56
+ * Is the item able to be selected
57
+ */
58
+ disabled: {
59
+ type: Boolean,
60
+ default: false,
61
+ required: false
54
62
  }
55
63
  },
56
64
  computed: {
@@ -109,7 +117,7 @@ var script = {
109
117
  // It just so happens this class has the same prefix `gl-`.
110
118
  this.itemVariant && this.itemVariant !== 'default' ?
111
119
  // eslint-disable-next-line @gitlab/tailwind-no-interpolation
112
- `gl-new-dropdown-item-${this.itemVariant}` : ''];
120
+ `gl-new-dropdown-item-${this.itemVariant}` : '', this.disabled ? 'disabled' : ''];
113
121
  },
114
122
  iconName() {
115
123
  var _this$item7;
@@ -127,31 +135,38 @@ var script = {
127
135
  },
128
136
  methods: {
129
137
  onKeydown(event) {
130
- const code = event.code;
131
- if (code === ENTER || code === SPACE) {
132
- if (this.isCustomContent) {
133
- this.action();
134
- } else {
135
- stopEvent(event);
136
- /** Instead of simply navigating or calling the action, we want
137
- * the `a/button` to be the target of the event as it might have additional attributes.
138
- * E.g. `a` might have `target` attribute.
139
- */
140
- const e = new MouseEvent('click', {
141
- bubbles: true,
142
- cancelable: true
143
- });
144
- if (this.isLink) {
145
- this.$refs.item.$el.dispatchEvent(e);
138
+ if (!this.disabled) {
139
+ const code = event.code;
140
+ if (code === ENTER || code === SPACE) {
141
+ if (this.isCustomContent) {
142
+ this.action();
146
143
  } else {
147
- var _this$$refs$item;
148
- (_this$$refs$item = this.$refs.item) === null || _this$$refs$item === void 0 ? void 0 : _this$$refs$item.dispatchEvent(e);
144
+ stopEvent(event);
145
+ /** Instead of simply navigating or calling the action, we want
146
+ * the `a/button` to be the target of the event as it might have additional attributes.
147
+ * E.g. `a` might have `target` attribute.
148
+ */
149
+ const e = new MouseEvent('click', {
150
+ bubbles: true,
151
+ cancelable: true
152
+ });
153
+ if (this.isLink) {
154
+ this.$refs.item.$el.dispatchEvent(e);
155
+ } else {
156
+ var _this$$refs$item;
157
+ (_this$$refs$item = this.$refs.item) === null || _this$$refs$item === void 0 ? void 0 : _this$$refs$item.dispatchEvent(e);
158
+ }
149
159
  }
150
160
  }
151
161
  }
152
162
  },
153
163
  action() {
154
164
  this.$emit('action', this.item);
165
+ },
166
+ handleClick(event) {
167
+ if (this.disabled) {
168
+ stopEvent(event);
169
+ }
155
170
  }
156
171
  }
157
172
  };
@@ -160,7 +175,7 @@ var script = {
160
175
  const __vue_script__ = script;
161
176
 
162
177
  /* template */
163
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('li',_vm._g({class:_vm.classes,attrs:{"tabindex":_vm.listIndex,"data-testid":"disclosure-dropdown-item"}},_vm.wrapperListeners),[_vm._t("default",function(){return [_c(_vm.itemComponent.is,_vm._g(_vm._b({ref:"item",tag:"component",staticClass:"gl-new-dropdown-item-content",attrs:{"tabindex":_vm.componentIndex}},'component',_vm.itemComponent.attrs,false),_vm.itemComponent.listeners),[_c('span',{staticClass:"gl-new-dropdown-item-text-wrapper"},[_vm._t("list-item",function(){return [(_vm.iconName || _vm.siblingsHaveIcons)?_c('span',{staticClass:"gl-new-dropdown-item-icon"},[(_vm.iconName)?_c('gl-icon',{attrs:{"name":_vm.iconName,"variant":"current"}}):_vm._e()],1):_vm._e(),_vm._v("\n "+_vm._s(_vm.item.text)+"\n ")]})],2)])]})],2)};
178
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('li',_vm._g({class:_vm.classes,attrs:{"tabindex":_vm.listIndex,"data-testid":"disclosure-dropdown-item","aria-disabled":_vm.disabled}},_vm.wrapperListeners),[_vm._t("default",function(){return [_c(_vm.itemComponent.is,_vm._g(_vm._b({ref:"item",tag:"component",staticClass:"gl-new-dropdown-item-content",attrs:{"tabindex":_vm.componentIndex},on:{"click":_vm.handleClick}},'component',_vm.itemComponent.attrs,false),_vm.itemComponent.listeners),[_c('span',{staticClass:"gl-new-dropdown-item-text-wrapper"},[_vm._t("list-item",function(){return [(_vm.iconName || _vm.siblingsHaveIcons)?_c('span',{staticClass:"gl-new-dropdown-item-icon"},[(_vm.iconName)?_c('gl-icon',{attrs:{"name":_vm.iconName,"variant":"current"}}):_vm._e()],1):_vm._e(),_vm._v("\n "+_vm._s(_vm.item.text)+"\n ")]})],2)])]})],2)};
164
179
  var __vue_staticRenderFns__ = [];
165
180
 
166
181
  /* style */