@gitlab/ui 109.0.0 → 109.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "109.0.0",
3
+ "version": "109.2.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -144,7 +144,7 @@
144
144
  "axe-playwright": "^2.1.0",
145
145
  "babel-jest": "29.0.1",
146
146
  "babel-loader": "^8.0.5",
147
- "cypress": "14.0.2",
147
+ "cypress": "14.1.0",
148
148
  "cypress-axe": "^1.4.0",
149
149
  "cypress-real-events": "^1.11.0",
150
150
  "dompurify": "^3.1.2",
@@ -93,6 +93,13 @@
93
93
  }
94
94
  }
95
95
 
96
+ // Used in Listbox to visually highlight the first item after search
97
+ &.gl-new-dropdown-item-highlighted .gl-new-dropdown-item-content {
98
+ color: var(--gl-dropdown-option-text-color-focus);
99
+ background-color: var(--gl-dropdown-option-background-color-unselected-focus);
100
+ @include gl-focus($inset: true);
101
+ }
102
+
96
103
  .gl-new-dropdown-item-content {
97
104
  @apply gl-rounded-base;
98
105
  @apply gl-border-0;
@@ -7,6 +7,7 @@ import { stopEvent } from '../../../../utils/utils';
7
7
  import {
8
8
  GL_DROPDOWN_SHOWN,
9
9
  GL_DROPDOWN_HIDDEN,
10
+ ENTER,
10
11
  HOME,
11
12
  END,
12
13
  ARROW_DOWN,
@@ -389,6 +390,9 @@ export default {
389
390
  flattenedOptions() {
390
391
  return flattenedOptions(this.items);
391
392
  },
393
+ searchHasOptions() {
394
+ return this.flattenedOptions.length > 0 && this.searchStr;
395
+ },
392
396
  hasItems() {
393
397
  return this.items.length > 0;
394
398
  },
@@ -503,6 +507,16 @@ export default {
503
507
  /* Every time the list of items changes (on search),
504
508
  * the observed elements are recreated, thus we need to start obesrving them again */
505
509
  this.observeScroll();
510
+
511
+ /**
512
+ * Every time the list of items changes, and there is a search string,
513
+ * we want to visually highlight the first item
514
+ */
515
+ if (this.searchHasOptions) {
516
+ this.nextFocusedItemIndex = 0;
517
+ } else {
518
+ this.nextFocusedItemIndex = null;
519
+ }
506
520
  });
507
521
  },
508
522
  },
@@ -564,6 +578,13 @@ export default {
564
578
  onShow() {
565
579
  if (this.searchable) {
566
580
  this.focusSearchInput();
581
+
582
+ /**
583
+ * If the search string is not empty, highlight the first item
584
+ */
585
+ if (this.searchHasOptions) {
586
+ this.nextFocusedItemIndex = 0;
587
+ }
567
588
  } else {
568
589
  this.focusItem(this.selectedIndices[0] ?? 0, this.getFocusableListItemElements());
569
590
  }
@@ -608,6 +629,9 @@ export default {
608
629
  }
609
630
  if (this.searchable && elements.indexOf(target) === 0) {
610
631
  this.focusSearchInput();
632
+ if (!this.searchHasOptions) {
633
+ this.nextFocusedItemIndex = null;
634
+ }
611
635
  } else {
612
636
  this.focusNextItem(event, elements, -1);
613
637
  }
@@ -617,6 +641,11 @@ export default {
617
641
  } else {
618
642
  this.focusNextItem(event, elements, 1);
619
643
  }
644
+ } else if (code === ENTER && isSearchInput) {
645
+ if (this.searchHasOptions && elements.length > 0) {
646
+ this.onSelect(this.flattenedOptions[0], true);
647
+ }
648
+ stop = true;
620
649
  } else {
621
650
  stop = false;
622
651
  }
@@ -651,6 +680,9 @@ export default {
651
680
  this.onSingleSelect(item.value, isSelected);
652
681
  }
653
682
  },
683
+ isHighlighted(item) {
684
+ return this.nextFocusedItemIndex === this.flattenedOptions.indexOf(item);
685
+ },
654
686
  isSelected(item) {
655
687
  return this.selectedValues.some((value) => value === item.value);
656
688
  },
@@ -666,7 +698,6 @@ export default {
666
698
  */
667
699
  this.$emit('select', value);
668
700
  }
669
-
670
701
  this.closeAndFocus();
671
702
  },
672
703
  onMultiSelect(value, isSelected) {
@@ -866,6 +897,7 @@ export default {
866
897
  <gl-listbox-item
867
898
  :key="item.value"
868
899
  :data-testid="`listbox-item-${item.value}`"
900
+ :is-highlighted="isHighlighted(item)"
869
901
  :is-selected="isSelected(item)"
870
902
  :is-focused="isFocused(item)"
871
903
  :is-check-centered="isCheckCentered"
@@ -895,6 +927,7 @@ export default {
895
927
  v-for="option in item.options"
896
928
  :key="option.value"
897
929
  :data-testid="`listbox-item-${option.value}`"
930
+ :is-highlighted="isHighlighted(option)"
898
931
  :is-selected="isSelected(option)"
899
932
  :is-focused="isFocused(option)"
900
933
  :is-check-centered="isCheckCentered"
@@ -24,6 +24,11 @@ export default {
24
24
  required: false,
25
25
  default: false,
26
26
  },
27
+ isHighlighted: {
28
+ type: Boolean,
29
+ default: false,
30
+ required: false,
31
+ },
27
32
  },
28
33
  computed: {
29
34
  checkedClasses() {
@@ -52,7 +57,7 @@ export default {
52
57
 
53
58
  <template>
54
59
  <li
55
- class="gl-new-dropdown-item"
60
+ :class="['gl-new-dropdown-item', { 'gl-new-dropdown-item-highlighted': isHighlighted }]"
56
61
  role="option"
57
62
  :tabindex="isFocused ? 0 : -1"
58
63
  :aria-selected="isSelected"
@@ -41,16 +41,6 @@ export default {
41
41
  type: Object,
42
42
  required: true,
43
43
  },
44
- /**
45
- * Warning: this prop is deprecated and will soon be removed
46
- * Please do not utilize `disableTheme` for formatting
47
- * Use the `options` prop to set desired echarts formatting
48
- */
49
- disableTheme: {
50
- type: Boolean,
51
- required: false,
52
- default: false,
53
- },
54
44
  width: {
55
45
  type: [Number, String],
56
46
  required: false,
@@ -120,14 +110,12 @@ export default {
120
110
  },
121
111
  },
122
112
  created() {
123
- if (!this.disableTheme) {
124
- echarts.registerTheme(themeName, createTheme(this.options));
125
- }
113
+ echarts.registerTheme(themeName, createTheme(this.options));
126
114
  },
127
115
  async mounted() {
128
116
  await this.$nextTick();
129
117
 
130
- const chart = echarts.init(this.$refs.chart, this.disableTheme ? null : themeName, {
118
+ const chart = echarts.init(this.$refs.chart, themeName, {
131
119
  renderer: this.renderer,
132
120
  width: defaultWidth,
133
121
  height: defaultHeight,