@gitlab/ui 80.1.0 → 80.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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Fri, 03 May 2024 04:11:25 GMT
3
+ * Generated on Mon, 06 May 2024 09:58:06 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Fri, 03 May 2024 04:11:25 GMT
3
+ * Generated on Mon, 06 May 2024 09:58:06 GMT
4
4
  */
5
5
 
6
6
  :root.gl-dark {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Fri, 03 May 2024 04:11:25 GMT
3
+ * Generated on Mon, 06 May 2024 09:58:06 GMT
4
4
  */
5
5
 
6
6
  export const DATA_VIZ_GREEN_50 = "#133a03";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Fri, 03 May 2024 04:11:25 GMT
3
+ * Generated on Mon, 06 May 2024 09:58:06 GMT
4
4
  */
5
5
 
6
6
  export const DATA_VIZ_GREEN_50 = "#ddfab7";
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Fri, 03 May 2024 04:11:26 GMT
3
+ // Generated on Mon, 06 May 2024 09:58:06 GMT
4
4
 
5
5
  $gl-text-color-disabled: #89888d !default; // Used for disabled text.
6
6
  $gl-text-color-link: #63a6e9 !default; // Used for default text links.
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Fri, 03 May 2024 04:11:25 GMT
3
+ // Generated on Mon, 06 May 2024 09:58:06 GMT
4
4
 
5
5
  $gl-text-color-disabled: #89888d !default; // Used for disabled text.
6
6
  $gl-text-color-success: #217645 !default; // Used for text indicating success or validity.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "80.1.0",
3
+ "version": "80.3.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -25,6 +25,11 @@ const FakeToken = avoidReactivity({
25
25
  render: (h) => h('div'),
26
26
  });
27
27
 
28
+ const AppliedTokensTestFakeToken = avoidReactivity({
29
+ props: ['appliedTokens'],
30
+ render: (h) => h('div'),
31
+ });
32
+
28
33
  Vue.directive('GlTooltip', () => {});
29
34
 
30
35
  let wrapper;
@@ -475,6 +480,20 @@ describe('Filtered search', () => {
475
480
  );
476
481
  });
477
482
 
483
+ it('passes appliedTokens prop to the token component', async () => {
484
+ const value = [{ type: 'faketoken', value: 'foo' }];
485
+ const expectedAppliedTokens = [{ type: 'faketoken', value: 'foo', id: expect.anything() }];
486
+ createComponent({
487
+ value,
488
+ availableTokens: [{ type: 'faketoken', token: AppliedTokensTestFakeToken }],
489
+ });
490
+ await nextTick();
491
+
492
+ const fakeTokenInstance = wrapper.findComponent(AppliedTokensTestFakeToken);
493
+ expect(fakeTokenInstance.exists()).toBe(true);
494
+ expect(fakeTokenInstance.props('appliedTokens')).toEqual(expectedAppliedTokens);
495
+ });
496
+
478
497
  it('passes `searchButtonAttributes` prop to `GlSearchBoxByClick`', () => {
479
498
  const searchButtonAttributes = { 'data-prop': 'foo-bar' };
480
499
 
@@ -471,11 +471,9 @@ export const WithHistoryItems = () => ({
471
471
  });
472
472
  WithHistoryItems.play = async ({ canvasElement }) => {
473
473
  const canvas = within(canvasElement);
474
- const button = canvas.getByRole('button', { name: 'Toggle history' });
474
+ const button = canvas.getByTestId('base-dropdown-toggle');
475
475
  await userEvent.click(button);
476
- await waitFor(() =>
477
- expect(within(document).getByRole('menu', { name: 'Toggle history' })).toBeVisible()
478
- );
476
+ await waitFor(() => expect(within(document).getByTestId('base-dropdown-menu')).toBeVisible());
479
477
  };
480
478
 
481
479
  export const WithFriendlyText = () => ({
@@ -183,6 +183,9 @@ export default {
183
183
  activeToken() {
184
184
  return this.tokens[this.activeTokenIdx];
185
185
  },
186
+ appliedTokens() {
187
+ return this.tokens.filter((token) => !isEmptyTerm(token));
188
+ },
186
189
  lastTokenIdx() {
187
190
  return this.tokens.length - 1;
188
191
  },
@@ -433,6 +436,7 @@ export default {
433
436
  :is-last-token="isLastToken(idx)"
434
437
  :class="getTokenClassList(idx)"
435
438
  :search-text-option-label="searchTextOptionLabel"
439
+ :applied-tokens="appliedTokens"
436
440
  @activate="activate(idx)"
437
441
  @deactivate="deactivate(token)"
438
442
  @destroy="destroyToken(idx, $event)"
@@ -1,55 +1,17 @@
1
1
  .gl-search-box-by-click {
2
2
  @include gl-font-base;
3
3
 
4
- .gl-search-box-by-click-history {
5
- > button {
6
- @include gl-p-3;
7
- @include gl-border-none;
8
- @include gl-inset-border-1-gray-400;
9
- }
10
-
11
- .gl-search-box-by-click-history-icon {
12
- @include gl-mr-2;
13
- @include gl-text-gray-500;
14
- }
15
-
16
- .gl-search-box-by-click-history-icon-chevron {
17
- @include gl-text-gray-500;
18
- @include gl-mr-0;
19
- }
20
-
21
- .gl-search-box-by-click-close-history-button {
22
- position: absolute;
23
- top: 0;
24
- right: $gl-spacing-scale-2;
25
- @include gl-line-height-0;
26
- @include gl-shadow-none;
27
- @include gl-w-auto;
28
- }
29
-
30
- .gl-search-box-by-click-history-header {
31
- @include gl-text-center;
32
- }
33
-
34
- .gl-search-box-by-click-history-no-searches {
35
- @include gl-text-center;
36
- @include gl-text-gray-500;
37
-
38
- .gl-dropdown-text {
39
- @include gl-font-weight-normal;
40
- }
41
- }
42
- }
43
-
44
- &.input-group {
45
- > .input-group-prepend,
46
- > .input-group-append {
47
- @include gl-bg-white;
48
- }
4
+ .gl-search-box-by-click-history > button {
5
+ padding-left: $gl-spacing-scale-4 !important;
6
+ padding-right: $gl-spacing-scale-3 !important;
7
+ @include gl-border-none;
8
+ border-top-right-radius: 0;
9
+ border-bottom-right-radius: 0;
10
+ @include gl-inset-border-1-gray-400;
49
11
  }
50
12
 
51
13
  .gl-search-box-by-click-search-button {
52
- @include gl-text-gray-500;
14
+ @include gl-text-secondary;
53
15
  @include gl-inset-border-1-gray-400;
54
16
  }
55
17
 
@@ -66,19 +28,14 @@
66
28
  @include gl-mr-2;
67
29
  @include gl-z-index-3;
68
30
  }
69
-
70
- .gl-search-box-by-click-menu {
71
- @include gl-font-base;
72
- width: $gl-dropdown-width-wide;
73
- }
74
31
  }
75
32
 
76
33
  .gl-search-box-by-click-with-search-button {
77
34
  .gl-search-box-by-click-input {
78
35
  @include gl-pr-7;
79
36
  }
80
-
37
+
81
38
  .gl-search-box-by-click-clear-button {
82
39
  right: $gl-spacing-scale-7;
83
40
  }
84
- }
41
+ }
@@ -1,6 +1,7 @@
1
1
  import { shallowMount } from '@vue/test-utils';
2
2
  import ClearIcon from '~/components/shared_components/clear_icon_button/clear_icon_button.vue';
3
- import GlDropdownItem from '../dropdown/dropdown_item.vue';
3
+ import GlDisclosureDropdown from '../new_dropdowns/disclosure/disclosure_dropdown.vue';
4
+ import GlDisclosureDropdownItem from '../new_dropdowns/disclosure/disclosure_dropdown_item.vue';
4
5
  import GlFormInput from '../form/form_input/form_input.vue';
5
6
  import SearchBoxByClick from './search_box_by_click.vue';
6
7
 
@@ -20,7 +21,10 @@ describe('search box by click component', () => {
20
21
  const createComponent = (propsData) => {
21
22
  wrapper = shallowMount(SearchBoxByClick, {
22
23
  propsData,
23
- stubs: { GlFormInputGroup: GlFormInputGroupStub },
24
+ stubs: {
25
+ GlDisclosureDropdown,
26
+ GlFormInputGroup: GlFormInputGroupStub,
27
+ },
24
28
  });
25
29
  };
26
30
 
@@ -91,14 +95,6 @@ describe('search box by click component', () => {
91
95
  expect(wrapper.findComponent({ ref: 'historyDropdown' }).exists()).toBe(true);
92
96
  });
93
97
 
94
- it('hides dropdown when close buton is clicked', () => {
95
- wrapper.vm.$refs.historyDropdown.hide = jest.fn();
96
-
97
- wrapper.findComponent({ ref: 'closeHistory' }).vm.$emit('click');
98
-
99
- expect(wrapper.vm.$refs.historyDropdown.hide).toHaveBeenCalled();
100
- });
101
-
102
98
  it('emits clear-history event when clear button is clicked', () => {
103
99
  wrapper.findComponent({ ref: 'clearHistory' }).vm.$emit('click');
104
100
 
@@ -106,7 +102,7 @@ describe('search box by click component', () => {
106
102
  });
107
103
 
108
104
  it('emits proper events when history item is clicked', async () => {
109
- wrapper.findComponent(GlDropdownItem).vm.$emit('click');
105
+ wrapper.findComponent(GlDisclosureDropdownItem).vm.$emit('action');
110
106
 
111
107
  await wrapper.vm.$nextTick();
112
108
  expect(wrapper.emitted('input')[0]).toEqual(['one']);
@@ -2,25 +2,19 @@
2
2
  import { GlTooltipDirective } from '../../../directives/tooltip';
3
3
  import GlClearIconButton from '../../shared_components/clear_icon_button/clear_icon_button.vue';
4
4
  import GlButton from '../button/button.vue';
5
- import GlDropdown from '../dropdown/dropdown.vue';
6
- import GlDropdownDivider from '../dropdown/dropdown_divider.vue';
7
- import GlDropdownItem from '../dropdown/dropdown_item.vue';
8
- import GlDropdownText from '../dropdown/dropdown_text.vue';
5
+ import GlDisclosureDropdown from '../new_dropdowns/disclosure/disclosure_dropdown.vue';
6
+ import GlDisclosureDropdownItem from '../new_dropdowns/disclosure/disclosure_dropdown_item.vue';
9
7
  import GlFormInput from '../form/form_input/form_input.vue';
10
8
  import GlFormInputGroup from '../form/form_input_group/form_input_group.vue';
11
- import GlIcon from '../icon/icon.vue';
12
9
 
13
10
  export default {
14
11
  name: 'GlSearchboxByClick',
15
12
  components: {
16
13
  GlClearIconButton,
17
- GlIcon,
18
14
  GlButton,
19
15
  GlFormInput,
20
- GlDropdown,
21
- GlDropdownText,
22
- GlDropdownItem,
23
- GlDropdownDivider,
16
+ GlDisclosureDropdown,
17
+ GlDisclosureDropdownItem,
24
18
  GlFormInputGroup,
25
19
  },
26
20
  directives: {
@@ -169,9 +163,6 @@ export default {
169
163
  },
170
164
  },
171
165
  methods: {
172
- closeHistoryDropdown() {
173
- this.$refs.historyDropdown.hide();
174
- },
175
166
  search(value) {
176
167
  /**
177
168
  * Emitted when search is submitted
@@ -217,52 +208,55 @@ export default {
217
208
  :class="{ 'gl-search-box-by-click-with-search-button': showSearchButton }"
218
209
  >
219
210
  <template v-if="historyItems" #prepend>
220
- <gl-dropdown
211
+ <gl-disclosure-dropdown
221
212
  ref="historyDropdown"
222
213
  class="gl-search-box-by-click-history"
223
- menu-class="gl-search-box-by-click-menu"
224
- category="secondary"
214
+ icon="history"
215
+ toggle-text="Toggle history"
216
+ text-sr-only
217
+ fluid-width
225
218
  :disabled="disabled"
226
219
  >
227
- <template #button-content>
228
- <gl-icon name="history" class="gl-search-box-by-click-history-icon" />
229
- <gl-icon name="chevron-down" class="gl-search-box-by-click-history-icon-chevron" />
230
- <span class="gl-sr-only">Toggle history</span>
220
+ <template #header>
221
+ <div
222
+ class="gl-search-box-by-click-history-header gl-display-flex gl-align-items-center gl-p-4! gl-min-h-8 gl-border-b-1 gl-border-b-solid gl-border-b-gray-200 gl-flex-grow-1 gl-font-weight-bold gl-font-sm"
223
+ >
224
+ {{ recentSearchesHeader }}
225
+ </div>
231
226
  </template>
232
- <gl-dropdown-text class="gl-search-box-by-click-history-header">
233
- {{ recentSearchesHeader }}
234
- <gl-button
235
- ref="closeHistory"
236
- v-gl-tooltip.hover="{ container: tooltipContainer }"
237
- :title="closeButtonTitle"
238
- :aria-label="closeButtonTitle"
239
- category="tertiary"
240
- class="gl-search-box-by-click-close-history-button"
241
- name="close"
242
- icon="close"
243
- @click="closeHistoryDropdown"
244
- />
245
- </gl-dropdown-text>
246
- <gl-dropdown-divider />
227
+
247
228
  <template v-if="historyItems.length">
248
- <gl-dropdown-item
229
+ <gl-disclosure-dropdown-item
249
230
  v-for="(item, idx) in historyItems"
250
231
  :key="idx"
251
232
  class="gl-search-box-by-click-history-item"
252
- @click="selectHistoryItem(item)"
233
+ @action="selectHistoryItem(item)"
234
+ >
235
+ <template #list-item>
236
+ <!-- @slot Slot to customize history item in history dropdown. Used only with history-items prop -->
237
+ <slot name="history-item" :history-item="item">{{ item }}</slot>
238
+ </template>
239
+ </gl-disclosure-dropdown-item>
240
+ </template>
241
+ <div v-else class="gl-font-sm gl-text-secondary gl-py-2 gl-px-4">
242
+ {{ noRecentSearchesText }}
243
+ </div>
244
+
245
+ <template v-if="historyItems.length" #footer>
246
+ <div
247
+ class="gl-border-t-solid gl-border-t-1 gl-border-t-gray-200 gl-display-flex gl-flex-direction-column gl-p-2"
253
248
  >
254
- <!-- @slot Slot to customize history item in history dropdown. Used only with history-items prop -->
255
- <slot name="history-item" :history-item="item">{{ item }}</slot>
256
- </gl-dropdown-item>
257
- <gl-dropdown-divider />
258
- <gl-dropdown-item ref="clearHistory" @click="emitClearHistory">{{
259
- clearRecentSearchesText
260
- }}</gl-dropdown-item>
249
+ <gl-button
250
+ ref="clearHistory"
251
+ category="tertiary"
252
+ class="gl-justify-content-start!"
253
+ @click="emitClearHistory"
254
+ >
255
+ {{ clearRecentSearchesText }}
256
+ </gl-button>
257
+ </div>
261
258
  </template>
262
- <gl-dropdown-text v-else class="gl-search-box-by-click-history-no-searches">{{
263
- noRecentSearchesText
264
- }}</gl-dropdown-text>
265
- </gl-dropdown>
259
+ </gl-disclosure-dropdown>
266
260
  </template>
267
261
  <slot name="input">
268
262
  <gl-form-input