@gitlab/ui 43.12.0 → 43.15.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ # [43.15.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v43.14.0...v43.15.0) (2022-09-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * **Banner:** Update banner spec ([488b01d](https://gitlab.com/gitlab-org/gitlab-ui/commit/488b01d941d1166b47070ffe04a7c617e0bc82a3))
7
+ * **Banner:** Update heading level ([c4c4373](https://gitlab.com/gitlab-org/gitlab-ui/commit/c4c437375596b4157968c88ff16e59bef95a1f36))
8
+
9
+ # [43.14.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v43.13.0...v43.14.0) (2022-09-08)
10
+
11
+
12
+ ### Features
13
+
14
+ * **GlListbox:** Add support for grouping ([c6ec8f1](https://gitlab.com/gitlab-org/gitlab-ui/commit/c6ec8f1a53eb4fad9a3ec077a762b23e67ef0245))
15
+
16
+ # [43.13.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v43.12.0...v43.13.0) (2022-09-06)
17
+
18
+
19
+ ### Features
20
+
21
+ * **css:** Adds align items center from sm up ([2f59188](https://gitlab.com/gitlab-org/gitlab-ui/commit/2f5918849f390ad4ee8a6a0a1040923fe4a82e00))
22
+
1
23
  # [43.12.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v43.11.0...v43.12.0) (2022-09-02)
2
24
 
3
25
 
@@ -101,7 +101,7 @@ var script = {
101
101
  const __vue_script__ = script;
102
102
 
103
103
  /* template */
104
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-card',{staticClass:"gl-px-8 gl-py-6 gl-line-height-20",class:{ 'gl-banner-introduction': _vm.isIntroducing, 'gl-border-none!': _vm.embedded },attrs:{"body-class":"gl-display-flex gl-p-0!"}},[(_vm.svgPath)?_c('div',{staticClass:"gl-banner-illustration"},[_c('img',{attrs:{"src":_vm.svgPath,"alt":"","role":"presentation"}})]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-banner-content"},[_c('h1',{staticClass:"gl-banner-title"},[_vm._v(_vm._s(_vm.title))]),_vm._v(" "),_vm._t("default"),_vm._v(" "),_c('gl-button',{attrs:{"variant":"confirm","category":"primary","data-testid":"gl-banner-primary-button","href":_vm.buttonLink},on:{"click":_vm.primaryButtonClicked}},[_vm._v(_vm._s(_vm.buttonText))]),_vm._v(" "),_vm._t("actions")],2),_vm._v(" "),_c('gl-button',{staticClass:"gl-banner-close",attrs:{"variant":_vm.isIntroducing ? 'confirm' : 'default',"category":"tertiary","size":"small","icon":"close","aria-label":"Close banner"},on:{"click":_vm.handleClose}})],1)};
104
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-card',{staticClass:"gl-px-8 gl-py-6 gl-line-height-20",class:{ 'gl-banner-introduction': _vm.isIntroducing, 'gl-border-none!': _vm.embedded },attrs:{"body-class":"gl-display-flex gl-p-0!"}},[(_vm.svgPath)?_c('div',{staticClass:"gl-banner-illustration"},[_c('img',{attrs:{"src":_vm.svgPath,"alt":"","role":"presentation"}})]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-banner-content"},[_c('h2',{staticClass:"gl-banner-title"},[_vm._v(_vm._s(_vm.title))]),_vm._v(" "),_vm._t("default"),_vm._v(" "),_c('gl-button',{attrs:{"variant":"confirm","category":"primary","data-testid":"gl-banner-primary-button","href":_vm.buttonLink},on:{"click":_vm.primaryButtonClicked}},[_vm._v(_vm._s(_vm.buttonText))]),_vm._v(" "),_vm._t("actions")],2),_vm._v(" "),_c('gl-button',{staticClass:"gl-banner-close",attrs:{"variant":_vm.isIntroducing ? 'confirm' : 'default',"category":"tertiary","size":"small","icon":"close","aria-label":"Close banner"},on:{"click":_vm.handleClose}})],1)};
105
105
  var __vue_staticRenderFns__ = [];
106
106
 
107
107
  /* style */
@@ -5,9 +5,12 @@ import { GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, HOME, END, ARROW_UP, ARROW_DOWN
5
5
  import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions } from '../../../../utils/constants';
6
6
  import GlBaseDropdown from '../base_dropdown/base_dropdown';
7
7
  import GlListboxItem from './listbox_item';
8
+ import GlListboxGroup from './listbox_group';
9
+ import { itemsValidator, isOption, flattenedOptions } from './utils';
8
10
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
9
11
 
10
12
  const ITEM_SELECTOR = '[role="option"]';
13
+ const GROUP_TOP_BORDER_CLASSES = ['gl-border-t', 'gl-pt-3', 'gl-mt-3'];
11
14
  var script = {
12
15
  events: {
13
16
  GL_DROPDOWN_SHOWN,
@@ -15,7 +18,8 @@ var script = {
15
18
  },
16
19
  components: {
17
20
  GlBaseDropdown,
18
- GlListboxItem
21
+ GlListboxItem,
22
+ GlListboxGroup
19
23
  },
20
24
  model: {
21
25
  prop: 'selected',
@@ -29,14 +33,7 @@ var script = {
29
33
  type: Array,
30
34
  required: false,
31
35
  default: () => [],
32
- validator: items => {
33
- return items.every(_ref => {
34
- let {
35
- value
36
- } = _ref;
37
- return typeof value === 'string';
38
- });
39
- }
36
+ validator: itemsValidator
40
37
  },
41
38
 
42
39
  /**
@@ -187,17 +184,26 @@ var script = {
187
184
  },
188
185
 
189
186
  computed: {
187
+ listboxTag() {
188
+ if (this.items.length === 0 || isOption(this.items[0])) return 'ul';
189
+ return 'div';
190
+ },
191
+
192
+ flattenedOptions() {
193
+ return flattenedOptions(this.items);
194
+ },
195
+
190
196
  listboxToggleText() {
191
197
  if (!this.toggleText) {
192
198
  if (!this.multiple && this.selectedValues.length) {
193
- var _this$items$find;
199
+ var _this$flattenedOption;
194
200
 
195
- return (_this$items$find = this.items.find(_ref2 => {
201
+ return (_this$flattenedOption = this.flattenedOptions.find(_ref => {
196
202
  let {
197
203
  value
198
- } = _ref2;
204
+ } = _ref;
199
205
  return value === this.selectedValues[0];
200
- })) === null || _this$items$find === void 0 ? void 0 : _this$items$find.text;
206
+ })) === null || _this$flattenedOption === void 0 ? void 0 : _this$flattenedOption.text;
201
207
  }
202
208
 
203
209
  return '';
@@ -207,10 +213,10 @@ var script = {
207
213
  },
208
214
 
209
215
  selectedIndices() {
210
- return this.selectedValues.map(selected => this.items.findIndex(_ref3 => {
216
+ return this.selectedValues.map(selected => this.flattenedOptions.findIndex(_ref2 => {
211
217
  let {
212
218
  value
213
- } = _ref3;
219
+ } = _ref2;
214
220
  return value === selected;
215
221
  })).sort();
216
222
  }
@@ -235,6 +241,10 @@ var script = {
235
241
  }
236
242
  },
237
243
  methods: {
244
+ groupClasses(index) {
245
+ return index === 0 ? null : GROUP_TOP_BORDER_CLASSES;
246
+ },
247
+
238
248
  onShow() {
239
249
  this.$nextTick(() => {
240
250
  var _this$selectedIndices;
@@ -310,10 +320,10 @@ var script = {
310
320
  });
311
321
  },
312
322
 
313
- onSelect(_ref4, isSelected) {
323
+ onSelect(_ref3, isSelected) {
314
324
  let {
315
325
  value
316
- } = _ref4;
326
+ } = _ref3;
317
327
 
318
328
  if (this.multiple) {
319
329
  this.onMultiSelect(value, isSelected);
@@ -326,6 +336,10 @@ var script = {
326
336
  return this.selectedValues.some(value => value === item.value);
327
337
  },
328
338
 
339
+ isFocused(item) {
340
+ return this.nextFocusedItemIndex === this.flattenedOptions.indexOf(item);
341
+ },
342
+
329
343
  onSingleSelect(value, isSelected) {
330
344
  if (isSelected) {
331
345
  /**
@@ -345,8 +359,9 @@ var script = {
345
359
  } else {
346
360
  this.$emit('select', this.selectedValues.filter(selectedValue => selectedValue !== value));
347
361
  }
348
- }
362
+ },
349
363
 
364
+ isOption
350
365
  }
351
366
  };
352
367
 
@@ -354,7 +369,7 @@ var script = {
354
369
  const __vue_script__ = script;
355
370
 
356
371
  /* template */
357
- 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.ariaLabelledby,"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])},[_vm._t("header"),_vm._v(" "),_c('ul',{ref:"list",staticClass:"gl-new-dropdown-contents gl-list-style-none gl-pl-0 gl-mb-0",attrs:{"aria-labelledby":_vm.toggleId,"role":"listbox","tabindex":"-1"},on:{"keydown":_vm.onKeydown}},_vm._l((_vm.items),function(item,index){return _c('gl-listbox-item',{key:item.value,attrs:{"is-selected":_vm.isSelected(item),"is-focused":_vm.nextFocusedItemIndex === index,"is-check-centered":_vm.isCheckCentered},on:{"select":function($event){return _vm.onSelect(item, $event)}}},[_vm._t("list-item",function(){return [_vm._v("\n "+_vm._s(item.text)+"\n ")]},{"item":item})],2)}),1),_vm._v(" "),_vm._t("footer")],2)};
372
+ 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.ariaLabelledby,"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])},[_vm._t("header"),_vm._v(" "),_c(_vm.listboxTag,{ref:"list",tag:"component",staticClass:"gl-new-dropdown-contents gl-list-style-none gl-pl-0 gl-mb-0",attrs:{"aria-labelledby":_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',{key:item.value,attrs:{"is-selected":_vm.isSelected(item),"is-focused":_vm.isFocused(item),"is-check-centered":_vm.isCheckCentered},on:{"select":function($event){return _vm.onSelect(item, $event)}}},[_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:{"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)]]})],2),_vm._v(" "),_vm._t("footer")],2)};
358
373
  var __vue_staticRenderFns__ = [];
359
374
 
360
375
  /* style */
@@ -0,0 +1,54 @@
1
+ import _uniqueId from 'lodash/uniqueId';
2
+ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
3
+
4
+ var script = {
5
+ props: {
6
+ name: {
7
+ type: String,
8
+ required: true
9
+ }
10
+ },
11
+
12
+ created() {
13
+ this.nameId = _uniqueId('gl-listbox-group-');
14
+ }
15
+
16
+ };
17
+
18
+ /* script */
19
+ const __vue_script__ = script;
20
+
21
+ /* template */
22
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('ul',{staticClass:"gl-mb-0 gl-pl-0 gl-list-style-none",attrs:{"role":"group","aria-labelledby":_vm.nameId}},[_c('li',{staticClass:"gl-pl-5! gl-py-2! gl-font-base gl-font-weight-bold",attrs:{"id":_vm.nameId,"role":"presentation"}},[_vm._t("group-label",function(){return [_vm._v(_vm._s(_vm.name))]})],2),_vm._v(" "),_vm._t("default")],2)};
23
+ var __vue_staticRenderFns__ = [];
24
+
25
+ /* style */
26
+ const __vue_inject_styles__ = undefined;
27
+ /* scoped */
28
+ const __vue_scope_id__ = undefined;
29
+ /* module identifier */
30
+ const __vue_module_identifier__ = undefined;
31
+ /* functional template */
32
+ const __vue_is_functional_template__ = false;
33
+ /* style inject */
34
+
35
+ /* style inject SSR */
36
+
37
+ /* style inject shadow dom */
38
+
39
+
40
+
41
+ const __vue_component__ = __vue_normalize__(
42
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
43
+ __vue_inject_styles__,
44
+ __vue_script__,
45
+ __vue_scope_id__,
46
+ __vue_is_functional_template__,
47
+ __vue_module_identifier__,
48
+ false,
49
+ undefined,
50
+ undefined,
51
+ undefined
52
+ );
53
+
54
+ export default __vue_component__;
@@ -0,0 +1,61 @@
1
+ const mockOptions = [{
2
+ value: 'prod',
3
+ text: 'Product'
4
+ }, {
5
+ value: 'ppl',
6
+ text: 'People'
7
+ }, {
8
+ value: 'fin',
9
+ text: 'Finance'
10
+ }, {
11
+ value: 'leg',
12
+ text: 'Legal'
13
+ }, {
14
+ value: 'eng',
15
+ text: 'Engineering'
16
+ }, {
17
+ value: 'sales',
18
+ text: 'Sales'
19
+ }, {
20
+ value: 'marketing',
21
+ text: 'Marketing'
22
+ }, {
23
+ value: 'acc',
24
+ text: 'Accounting'
25
+ }, {
26
+ value: 'hr',
27
+ text: 'Human Resource Management'
28
+ }, {
29
+ value: 'rnd',
30
+ text: 'Research and Development'
31
+ }, {
32
+ value: 'cust',
33
+ text: 'Customer Service'
34
+ }, {
35
+ value: 'sup',
36
+ text: 'Support'
37
+ }];
38
+ const mockGroups = [{
39
+ text: 'Branches',
40
+ options: [{
41
+ text: 'main',
42
+ value: 'main'
43
+ }, {
44
+ text: 'feature-123',
45
+ value: 'feature-123'
46
+ }]
47
+ }, {
48
+ text: 'Tags',
49
+ options: [{
50
+ text: 'v1.0',
51
+ value: 'v1.0'
52
+ }, {
53
+ text: 'v2.0',
54
+ value: 'v2.0'
55
+ }, {
56
+ text: 'v2.1',
57
+ value: 'v2.1'
58
+ }]
59
+ }];
60
+
61
+ export { mockGroups, mockOptions };
@@ -0,0 +1,34 @@
1
+ import _isString from 'lodash/isString';
2
+
3
+ const isOption = item => Boolean(item) && _isString(item.value);
4
+
5
+ const isGroup = function () {
6
+ let {
7
+ options
8
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9
+ return Array.isArray(options) && options.every(isOption);
10
+ };
11
+
12
+ const hasNoDuplicates = array => array.length === new Set(array).size;
13
+
14
+ const flattenedOptions = items => items.flatMap(item => isOption(item) ? item : item.options);
15
+
16
+ const isAllOptionsOrAllGroups = items => items.every(isOption) || items.every(isGroup);
17
+
18
+ const hasUniqueValues = items => hasNoDuplicates(flattenedOptions(items).map(_ref => {
19
+ let {
20
+ value
21
+ } = _ref;
22
+ return value;
23
+ }));
24
+
25
+ const hasUniqueGroups = items => hasNoDuplicates(items.filter(isGroup).map(_ref2 => {
26
+ let {
27
+ text
28
+ } = _ref2;
29
+ return text;
30
+ }));
31
+
32
+ const itemsValidator = items => isAllOptionsOrAllGroups(items) && hasUniqueValues(items) && hasUniqueGroups(items);
33
+
34
+ export { flattenedOptions, isOption, itemsValidator };