@gitlab/ui 128.2.2 → 128.3.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.
@@ -27,11 +27,12 @@ var script = {
27
27
  *
28
28
  * @typedef {object} FieldDefinition
29
29
  * @template TValue=string
30
- * @property {string} label - Label text to show for this field.
30
+ * @property {string | null | undefined} label - Label text to show for this field. When explicitly set to null, the label is suppressed. When undefined or not provided, the field name is used as the label.
31
31
  * @property {undefined | Object} groupAttrs - Properties that are passed to the group wrapping this field.
32
32
  * @property {undefined | Object} inputAttrs - Properties that are passed to the actual input for this field.
33
33
  * @property {undefined | function(string): TValue} mapValue - Function that maps the inputted string value to the field's actual value (e.g. a Number).
34
34
  * @property {undefined | Array<function(TValue): string | undefined>=} validators - Collection of validator functions.
35
+ * @property {undefined | boolean} fieldset - When true, renders the form group as a fieldset with legend instead of div with label.
35
36
  *
36
37
  * @type {{ [key: string]: FieldDefinition }}
37
38
  */
@@ -130,7 +131,7 @@ var script = {
130
131
  return {
131
132
  ...field,
132
133
  id,
133
- label: field.label || fieldName,
134
+ label: this.getFieldLabel(field, fieldName),
134
135
  inputSlot,
135
136
  groupPassthroughSlots,
136
137
  afterSlotName
@@ -168,6 +169,10 @@ var script = {
168
169
  await this.$nextTick();
169
170
  return this.hasAllFieldsValid();
170
171
  },
172
+ getFieldLabel(field, fieldName) {
173
+ if (field.label === null) return undefined;
174
+ return field.label || fieldName;
175
+ },
171
176
  getMappedValue(fieldName, val) {
172
177
  const field = this.fields[fieldName];
173
178
  if (isFunction(field === null || field === void 0 ? void 0 : field.mapValue)) {
@@ -248,7 +253,7 @@ const __vue_script__ = script;
248
253
  var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-form-fields-loop',{attrs:{"fields":_vm.fieldsToRender},scopedSlots:_vm._u([{key:"default",fn:function(ref){
249
254
  var field = ref.field;
250
255
  var fieldName = ref.fieldName;
251
- return [_c('gl-form-group',_vm._b({key:field.id,attrs:{"label":field.label,"label-for":field.id,"invalid-feedback":_vm.fieldValidationProps[fieldName].invalidFeedback,"state":_vm.fieldValidationProps[fieldName].state},scopedSlots:_vm._u([_vm._l((field.groupPassthroughSlots),function(ref){
256
+ return [_c('gl-form-group',_vm._b({key:field.id,attrs:{"label":field.label,"label-for":field.fieldset ? undefined : field.id,"invalid-feedback":_vm.fieldValidationProps[fieldName].invalidFeedback,"state":_vm.fieldValidationProps[fieldName].state},scopedSlots:_vm._u([_vm._l((field.groupPassthroughSlots),function(ref){
252
257
  var slotName = ref.slotName;
253
258
  var childSlotName = ref.childSlotName;
254
259
  return {key:childSlotName,fn:function(){return [_vm._t(slotName)]},proxy:true}})],null,true)},'gl-form-group',field.groupAttrs,false),[_c('gl-form-field-validator',{attrs:{"value":_vm.fieldValues[fieldName],"validators":field.validators,"should-validate":_vm.fieldDirtyStatuses[fieldName]},on:{"update":function($event){return _vm.onFieldValidationUpdate(fieldName, $event)}}}),_vm._v(" "),_vm._v(" "),_vm._t(field.inputSlot.slotName,function(){return [_c('gl-form-input',_vm._b({attrs:{"id":field.id,"value":_vm.fieldValues[fieldName],"state":_vm.fieldValidationProps[fieldName].state},on:{"input":function($event){return _vm.onFieldInput(fieldName, $event)},"blur":function($event){return _vm.onFieldBlur(fieldName)}}},'gl-form-input',field.inputAttrs,false))]},null,field.inputSlot.attrs)],2),_vm._v(" "),_vm._t(field.afterSlotName)]}}],null,true)})};
@@ -77,7 +77,7 @@ var script = {
77
77
  const __vue_script__ = script;
78
78
 
79
79
  /* template */
80
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-form-group',_vm._b({staticClass:"gl-form-group",attrs:{"label-class":_vm.actualLabelClass},scopedSlots:_vm._u([{key:"label",fn:function(){return [_vm._t("label",function(){return [_vm._v("\n "+_vm._s(_vm.$attrs.label)+"\n "),(_vm.optional)?_c('span',{staticClass:"optional-label",attrs:{"data-testid":"optional-label"}},[_vm._v(_vm._s(_vm.optionalText))]):_vm._e()]}),_vm._v(" "),(_vm.hasLabelDescription)?_c('div',{staticClass:"label-description",attrs:{"data-testid":"label-description"}},[_vm._t("label-description",function(){return [_vm._v(_vm._s(_vm.labelDescription))]})],2):_vm._e()]},proxy:true},_vm._l((Object.keys(_vm.$slots)),function(slot){return {key:slot,fn:function(){return [_vm._t(slot)]},proxy:true}})],null,true)},'b-form-group',_vm.$attrs,false))};
80
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-form-group',_vm._b({staticClass:"gl-form-group",attrs:{"label-class":_vm.actualLabelClass},scopedSlots:_vm._u([(_vm.$attrs.label || _vm.$scopedSlots.label)?{key:"label",fn:function(){return [_vm._t("label",function(){return [_vm._v("\n "+_vm._s(_vm.$attrs.label)+"\n "),(_vm.optional)?_c('span',{staticClass:"optional-label",attrs:{"data-testid":"optional-label"}},[_vm._v(_vm._s(_vm.optionalText))]):_vm._e()]}),_vm._v(" "),(_vm.hasLabelDescription)?_c('div',{staticClass:"label-description",attrs:{"data-testid":"label-description"}},[_vm._t("label-description",function(){return [_vm._v(_vm._s(_vm.labelDescription))]})],2):_vm._e()]},proxy:true}:null,_vm._l((Object.keys(_vm.$slots)),function(slot){return {key:slot,fn:function(){return [_vm._t(slot)]},proxy:true}})],null,true)},'b-form-group',_vm.$attrs,false))};
81
81
  var __vue_staticRenderFns__ = [];
82
82
 
83
83
  /* style */
@@ -92,8 +92,8 @@ var script = {
92
92
  }
93
93
  return [];
94
94
  },
95
- close(e) {
96
- this.$refs[popoverRefName].doClose();
95
+ closePopover(e) {
96
+ this.$refs[popoverRefName].close();
97
97
  /**
98
98
  * Emitted when the close button is clicked (requires showCloseButton to be `true`).
99
99
  */
@@ -107,7 +107,7 @@ var script = {
107
107
  const __vue_script__ = script;
108
108
 
109
109
  /* template */
110
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-popover',_vm._g(_vm._b({ref:_vm.$options.popoverRefName,attrs:{"custom-class":_vm.customClass,"triggers":_vm.triggers,"title":_vm.title,"placement":_vm.placement,"boundary-padding":_vm.boundaryPadding},scopedSlots:_vm._u([(_vm.shouldShowTitle)?{key:"title",fn:function(){return [_vm._t("title",function(){return [_vm._v("\n "+_vm._s(_vm.title)+"\n ")]}),_vm._v(" "),(_vm.showCloseButton)?_c('div',{staticClass:"-gl-mr-3 -gl-mt-2 gl-ml-3 gl-h-0"},[_c('close-button',{class:{ 'gl-float-right gl-mt-2': !_vm.hasTitle },attrs:{"data-testid":"close-button"},on:{"click":_vm.close}})],1):_vm._e()]},proxy:true}:null,(_vm.$scopedSlots.default)?{key:"default",fn:function(){return [_vm._t("default")]},proxy:true}:null],null,true)},'b-popover',_vm.$attrs,false),_vm.$listeners))};
110
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-popover',_vm._g(_vm._b({ref:_vm.$options.popoverRefName,attrs:{"custom-class":_vm.customClass,"triggers":_vm.triggers,"title":_vm.title,"placement":_vm.placement,"boundary-padding":_vm.boundaryPadding},scopedSlots:_vm._u([(_vm.shouldShowTitle)?{key:"title",fn:function(){return [_vm._t("title",function(){return [_vm._v("\n "+_vm._s(_vm.title)+"\n ")]}),_vm._v(" "),(_vm.showCloseButton)?_c('div',{staticClass:"-gl-mr-3 -gl-mt-2 gl-ml-3 gl-h-0"},[_c('close-button',{class:{ 'gl-float-right gl-mt-2': !_vm.hasTitle },attrs:{"data-testid":"close-button"},on:{"click":_vm.closePopover}})],1):_vm._e()]},proxy:true}:null,(_vm.$scopedSlots.default)?{key:"default",fn:function(){return [_vm._t("default")]},proxy:true}:null],null,true)},'b-popover',_vm.$attrs,false),_vm.$listeners))};
111
111
  var __vue_staticRenderFns__ = [];
112
112
 
113
113
  /* 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';
@@ -244,7 +244,7 @@ var script = {
244
244
  },
245
245
  created() {
246
246
  // Each instance must have a unique ID for proper ARIA relationships
247
- this.uniqueId = `token-selector-${GlUniqueId()}`;
247
+ this.uniqueId = uniqueId('token-selector-');
248
248
  },
249
249
  methods: {
250
250
  handleFocus(event) {
@@ -11,7 +11,7 @@ var tooltip_mixin = tooltipRefName => ({
11
11
  * https://bootstrap-vue.org/docs/components/popover#programmatically-show-and-hide-popover
12
12
  * https://bootstrap-vue.org/docs/components/tooltip#programmatically-show-and-hide-tooltip
13
13
  */
14
- tooltipActionEvents.forEach(event => this.$on(event, () => this.$refs[tooltipRefName].$emit(event)));
14
+ tooltipActionEvents.forEach(event => this.$on(event, () => this.$refs[tooltipRefName][event]()));
15
15
  },
16
16
  beforeDestroy() {
17
17
  tooltipActionEvents.forEach(event => this.$off(event));