@gitlab/ui 54.4.1 → 55.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "54.4.1",
3
+ "version": "55.0.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -87,7 +87,7 @@
87
87
  "@gitlab/eslint-plugin": "18.1.0",
88
88
  "@gitlab/fonts": "^1.2.0",
89
89
  "@gitlab/stylelint-config": "4.1.0",
90
- "@gitlab/svgs": "3.18.0",
90
+ "@gitlab/svgs": "3.19.0",
91
91
  "@rollup/plugin-commonjs": "^11.1.0",
92
92
  "@rollup/plugin-node-resolve": "^7.1.3",
93
93
  "@rollup/plugin-replace": "^2.3.2",
@@ -36,7 +36,7 @@ const generateProps = ({
36
36
  loading = defaultValue('loading'),
37
37
  noCaret = defaultValue('noCaret'),
38
38
  placement = defaultValue('placement'),
39
- toggleId = defaultValue('toggleId'),
39
+ toggleId = defaultValue('toggleId')(),
40
40
  toggleText,
41
41
  textSrOnly = defaultValue('textSrOnly'),
42
42
  icon = '',
@@ -111,12 +111,12 @@ export default {
111
111
  },
112
112
  /**
113
113
  * Custom toggle id.
114
- * Fot instance, it can be referenced by tooltip or popover
114
+ * For instance, it can be referenced by tooltip or popover
115
115
  */
116
116
  toggleId: {
117
117
  type: String,
118
118
  required: false,
119
- default: uniqueId('dropdown-toggle-btn-'),
119
+ default: () => uniqueId('dropdown-toggle-btn-'),
120
120
  },
121
121
  /**
122
122
  * Additional CSS classes to customize toggle appearance
@@ -57,22 +57,30 @@ describe('search box by type component', () => {
57
57
  expect(wrapper.emitted('input')).toEqual([['']]);
58
58
  });
59
59
 
60
- it('emits clearButtonFocus when focused', () => {
61
- findClearIcon().vm.$emit('focus', { stopPropagation: jest.fn() });
60
+ it('emits `focusin` event when focus inside the component', () => {
61
+ findInput().vm.$emit('focusin', { preventDefault: jest.fn() });
62
62
 
63
- expect(wrapper.emitted('clearButtonFocus')).toHaveLength(1);
63
+ expect(wrapper.emitted('focus')).toBe(undefined);
64
+ expect(wrapper.emitted('focusin')).toHaveLength(1);
64
65
  });
66
+ it('emits `focusout` event when focus moves outside the component', () => {
67
+ findInput().vm.$emit('focusout', { preventDefault: jest.fn() });
68
+ expect(wrapper.emitted('blur')).toBe(undefined);
65
69
 
66
- it('emits clearButtonBlur when blur', () => {
67
- findClearIcon().vm.$emit('blur', { stopPropagation: jest.fn() });
68
-
69
- expect(wrapper.emitted('clearButtonBlur')).toHaveLength(1);
70
+ expect(wrapper.emitted('focusout')).toHaveLength(1);
70
71
  });
71
72
 
72
- it('emits clearButtonRelease when released', () => {
73
- findClearIcon().vm.$emit('release', { stopPropagation: jest.fn() });
73
+ it('does NOT emit `focusout` event when tabbing inside the component back and forth', () => {
74
+ findInput().vm.$emit('focusout', {
75
+ preventDefault: jest.fn(),
76
+ relatedTarget: wrapper.vm.$refs.input.$el,
77
+ });
78
+ findClearIcon().vm.$emit('focusout', {
79
+ preventDefault: jest.fn(),
80
+ relatedTarget: wrapper.vm.$refs.clearButton.$el,
81
+ });
74
82
 
75
- expect(wrapper.emitted('clearButtonRelease')).toHaveLength(1);
83
+ expect(wrapper.emitted('focusout')).toBe(undefined);
76
84
  });
77
85
  });
78
86
 
@@ -81,9 +81,9 @@ export default {
81
81
  inputListeners() {
82
82
  return {
83
83
  ...this.$listeners,
84
- input: (value) => {
85
- this.$emit('input', value);
86
- },
84
+ input: this.onInput,
85
+ focusin: this.onFocusin,
86
+ focusout: this.onFocusout,
87
87
  };
88
88
  },
89
89
  showClearButton() {
@@ -91,21 +91,36 @@ export default {
91
91
  },
92
92
  },
93
93
  methods: {
94
+ isInputOrClearButton(element) {
95
+ return element === this.$refs.input?.$el || element === this.$refs.clearButton?.$el;
96
+ },
94
97
  clearInput() {
95
- this.$emit('input', '');
98
+ this.onInput('');
96
99
  this.focusInput();
97
100
  },
98
101
  focusInput() {
99
102
  this.$refs.input.$el.focus();
100
103
  },
101
- onClearButtonFocus() {
102
- this.$emit('clearButtonFocus');
104
+ onInput(value) {
105
+ this.$emit('input', value);
103
106
  },
104
- onClearButtonBlur() {
105
- this.$emit('clearButtonBlur');
107
+ onFocusout(event) {
108
+ const { relatedTarget } = event;
109
+
110
+ if (this.isInputOrClearButton(relatedTarget)) {
111
+ return;
112
+ }
113
+
114
+ this.$emit('focusout', event);
106
115
  },
107
- onClearButtonRelease() {
108
- this.$emit('clearButtonRelease');
116
+ onFocusin(event) {
117
+ const { relatedTarget } = event;
118
+
119
+ if (this.isInputOrClearButton(relatedTarget)) {
120
+ return;
121
+ }
122
+
123
+ this.$emit('focusin', event);
109
124
  },
110
125
  },
111
126
  };
@@ -129,13 +144,13 @@ export default {
129
144
  <gl-loading-icon v-if="isLoading" class="gl-search-box-by-type-loading-icon" />
130
145
  <gl-clear-icon-button
131
146
  v-if="showClearButton"
147
+ ref="clearButton"
132
148
  :title="clearButtonTitle"
133
149
  :tooltip-container="tooltipContainer"
134
150
  class="gl-search-box-by-type-clear gl-clear-icon-button"
135
151
  @click.stop="clearInput"
136
- @focus="onClearButtonFocus"
137
- @blur="onClearButtonBlur"
138
- @release="onClearButtonRelease"
152
+ @focusin="onFocusin"
153
+ @focusout="onFocusout"
139
154
  />
140
155
  </div>
141
156
  </div>
@@ -219,11 +219,11 @@
219
219
  }
220
220
 
221
221
  .gl-bg-gray-500 {
222
- background-color: $gray-600
222
+ background-color: $gray-500
223
223
  }
224
224
 
225
225
  .gl-bg-gray-500\! {
226
- background-color: $gray-600 !important
226
+ background-color: $gray-500 !important
227
227
  }
228
228
 
229
229
  .gl-bg-gray-600 {
@@ -51,7 +51,7 @@
51
51
  }
52
52
 
53
53
  @mixin gl-bg-gray-500 {
54
- background-color: $gray-600;
54
+ background-color: $gray-500;
55
55
  }
56
56
 
57
57
  @mixin gl-bg-gray-600 {