@gitlab/ui 37.5.1 → 37.7.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 +21 -0
- package/dist/components/base/filtered_search/filtered_search.js +24 -8
- package/dist/components/base/filtered_search/filtered_search_term.js +10 -1
- package/dist/components/base/filtered_search/filtered_search_utils.js +2 -1
- package/dist/components/regions/empty_state/empty_state.js +6 -1
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/package.json +2 -2
- package/src/components/base/filtered_search/filtered_search.spec.js +106 -12
- package/src/components/base/filtered_search/filtered_search.stories.js +3 -0
- package/src/components/base/filtered_search/filtered_search.vue +21 -6
- package/src/components/base/filtered_search/filtered_search_term.spec.js +14 -9
- package/src/components/base/filtered_search/filtered_search_term.vue +7 -1
- package/src/components/base/filtered_search/filtered_search_utils.js +2 -0
- package/src/components/regions/empty_state/empty_state.vue +13 -1
- package/src/scss/utilities.scss +20 -0
- package/src/scss/utility-mixins/box-shadow.scss +4 -0
- package/src/scss/utility-mixins/color.scss +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "37.
|
|
3
|
+
"version": "37.7.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@arkweid/lefthook": "^0.7.6",
|
|
84
84
|
"@babel/core": "^7.10.2",
|
|
85
85
|
"@babel/preset-env": "^7.10.2",
|
|
86
|
-
"@gitlab/eslint-plugin": "
|
|
86
|
+
"@gitlab/eslint-plugin": "11.0.0",
|
|
87
87
|
"@gitlab/stylelint-config": "4.0.0",
|
|
88
88
|
"@gitlab/svgs": "2.6.0",
|
|
89
89
|
"@rollup/plugin-commonjs": "^11.1.0",
|
|
@@ -5,7 +5,7 @@ import GlFilteredSearchSuggestion from './filtered_search_suggestion.vue';
|
|
|
5
5
|
import GlFilteredSearchSuggestionList from './filtered_search_suggestion_list.vue';
|
|
6
6
|
import GlFilteredSearchTerm from './filtered_search_term.vue';
|
|
7
7
|
import GlFilteredSearchToken from './filtered_search_token.vue';
|
|
8
|
-
import { TERM_TOKEN_TYPE } from './filtered_search_utils';
|
|
8
|
+
import { TERM_TOKEN_TYPE, INTENT_ACTIVATE_PREVIOUS } from './filtered_search_utils';
|
|
9
9
|
|
|
10
10
|
jest.mock('~/directives/tooltip');
|
|
11
11
|
|
|
@@ -196,9 +196,99 @@ describe('Filtered search', () => {
|
|
|
196
196
|
]);
|
|
197
197
|
});
|
|
198
198
|
|
|
199
|
-
it('
|
|
199
|
+
it('makes previous token active if user intends it on token destruction', async () => {
|
|
200
200
|
createComponent({
|
|
201
|
-
value: [
|
|
201
|
+
value: [{ type: 'faketoken', value: '' }, ''],
|
|
202
|
+
});
|
|
203
|
+
await nextTick();
|
|
204
|
+
|
|
205
|
+
wrapper
|
|
206
|
+
.findComponent(GlFilteredSearchTerm)
|
|
207
|
+
.vm.$emit('destroy', { intent: INTENT_ACTIVATE_PREVIOUS });
|
|
208
|
+
|
|
209
|
+
await nextTick();
|
|
210
|
+
|
|
211
|
+
expect(wrapper.findComponent(FakeToken).props('active')).toBe(true);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('makes no token active if user intends it on first token destruction', async () => {
|
|
215
|
+
createComponent({
|
|
216
|
+
value: ['foo', { type: 'faketoken', value: '' }],
|
|
217
|
+
});
|
|
218
|
+
await nextTick();
|
|
219
|
+
wrapper.findComponent(FakeToken).vm.$emit('activate');
|
|
220
|
+
await nextTick();
|
|
221
|
+
|
|
222
|
+
expect(wrapper.findComponent(FakeToken).props('active')).toBe(true);
|
|
223
|
+
|
|
224
|
+
wrapper
|
|
225
|
+
.findAllComponents(GlFilteredSearchTerm)
|
|
226
|
+
.at(0)
|
|
227
|
+
.vm.$emit('destroy', { intent: INTENT_ACTIVATE_PREVIOUS });
|
|
228
|
+
|
|
229
|
+
await nextTick();
|
|
230
|
+
|
|
231
|
+
expect(wrapper.findComponent(FakeToken).props('active')).toBe(false);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('keeps active token active if later one destroyed', async () => {
|
|
235
|
+
createComponent({
|
|
236
|
+
value: [
|
|
237
|
+
{ type: 'faketoken', value: '' },
|
|
238
|
+
{ type: 'faketoken', value: '' },
|
|
239
|
+
{ type: 'faketoken', value: '' },
|
|
240
|
+
],
|
|
241
|
+
});
|
|
242
|
+
await nextTick();
|
|
243
|
+
wrapper.findAllComponents(FakeToken).at(0).vm.$emit('activate');
|
|
244
|
+
await nextTick();
|
|
245
|
+
|
|
246
|
+
wrapper.findAllComponents(FakeToken).at(2).vm.$emit('destroy');
|
|
247
|
+
|
|
248
|
+
await nextTick();
|
|
249
|
+
|
|
250
|
+
expect(wrapper.findAllComponents(FakeToken).at(0).props('active')).toBe(true);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('keeps active token active if earlier one destroyed', async () => {
|
|
254
|
+
createComponent({
|
|
255
|
+
value: [
|
|
256
|
+
{ type: 'faketoken', value: '' },
|
|
257
|
+
{ type: 'faketoken', value: '' },
|
|
258
|
+
{ type: 'faketoken', value: '' },
|
|
259
|
+
],
|
|
260
|
+
});
|
|
261
|
+
await nextTick();
|
|
262
|
+
wrapper.findAllComponents(FakeToken).at(2).vm.$emit('activate');
|
|
263
|
+
await nextTick();
|
|
264
|
+
|
|
265
|
+
wrapper.findAllComponents(FakeToken).at(0).vm.$emit('destroy');
|
|
266
|
+
|
|
267
|
+
await nextTick();
|
|
268
|
+
|
|
269
|
+
expect(wrapper.findAllComponents(FakeToken).at(1).props('active')).toBe(true);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it('makes no token active if current is destroyed', async () => {
|
|
273
|
+
createComponent({
|
|
274
|
+
value: ['one', { type: 'faketoken', value: '' }],
|
|
275
|
+
});
|
|
276
|
+
await nextTick();
|
|
277
|
+
wrapper.findComponent(FakeToken).vm.$emit('activate');
|
|
278
|
+
await nextTick();
|
|
279
|
+
|
|
280
|
+
wrapper.findComponent(FakeToken).vm.$emit('destroy');
|
|
281
|
+
|
|
282
|
+
await nextTick();
|
|
283
|
+
|
|
284
|
+
wrapper.findAllComponents(GlFilteredSearchTerm).wrappers.forEach((searchTermWrapper) => {
|
|
285
|
+
expect(searchTermWrapper.props('active')).toBe(false);
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('keeps no token active if one was destroyed when none were active', async () => {
|
|
290
|
+
createComponent({
|
|
291
|
+
value: ['one', { type: 'faketoken', value: '' }],
|
|
202
292
|
});
|
|
203
293
|
await nextTick();
|
|
204
294
|
|
|
@@ -206,7 +296,7 @@ describe('Filtered search', () => {
|
|
|
206
296
|
|
|
207
297
|
await nextTick();
|
|
208
298
|
|
|
209
|
-
expect(wrapper.findComponent(GlFilteredSearchTerm).props('active')).toBe(
|
|
299
|
+
expect(wrapper.findComponent(GlFilteredSearchTerm).props('active')).toBe(false);
|
|
210
300
|
});
|
|
211
301
|
|
|
212
302
|
it('does not destroy last token', async () => {
|
|
@@ -580,22 +670,26 @@ describe('Filtered search integration tests', () => {
|
|
|
580
670
|
expect(wrapper.findAllComponents(GlFilteredSearchTerm).at(1).find('input').exists()).toBe(true);
|
|
581
671
|
});
|
|
582
672
|
|
|
583
|
-
it('
|
|
584
|
-
mountComponent({ value: ['one
|
|
673
|
+
it('activates previous token when backspacing on empty search term', async () => {
|
|
674
|
+
mountComponent({ value: ['zero one two'] });
|
|
585
675
|
await nextTick();
|
|
586
676
|
|
|
587
677
|
activate(1);
|
|
588
678
|
|
|
589
679
|
await nextTick();
|
|
590
680
|
|
|
591
|
-
//
|
|
592
|
-
wrapper.
|
|
681
|
+
// Make sure we have the expected search term
|
|
682
|
+
const inputWrapper = wrapper.find('input');
|
|
683
|
+
expect(inputWrapper.element.value).toBe('one');
|
|
593
684
|
|
|
594
|
-
|
|
685
|
+
// Mimic backspace behavior for jsdom
|
|
686
|
+
await inputWrapper.setValue('');
|
|
687
|
+
await inputWrapper.trigger('keydown', { key: 'Backspace' });
|
|
595
688
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
);
|
|
689
|
+
// Make sure the previous token/search term is now active
|
|
690
|
+
const input = wrapper.find('input').element;
|
|
691
|
+
expect(input.value).toBe('zero');
|
|
692
|
+
expect(document.activeElement).toBe(input);
|
|
599
693
|
});
|
|
600
694
|
|
|
601
695
|
it('clicking clear button clears component input', async () => {
|
|
@@ -36,6 +36,7 @@ const fakeLabels = [
|
|
|
36
36
|
];
|
|
37
37
|
|
|
38
38
|
const UserToken = {
|
|
39
|
+
name: 'UserToken',
|
|
39
40
|
components: { GlFilteredSearchToken, GlFilteredSearchSuggestion, GlLoadingIcon, GlAvatar },
|
|
40
41
|
props: ['value', 'active'],
|
|
41
42
|
inheritAttrs: false,
|
|
@@ -112,6 +113,7 @@ const UserToken = {
|
|
|
112
113
|
};
|
|
113
114
|
|
|
114
115
|
const MilestoneToken = {
|
|
116
|
+
name: 'MilestoneToken',
|
|
115
117
|
components: { GlFilteredSearchToken, GlFilteredSearchSuggestion, GlLoadingIcon },
|
|
116
118
|
props: ['value', 'active'],
|
|
117
119
|
inheritAttrs: false,
|
|
@@ -172,6 +174,7 @@ const MilestoneToken = {
|
|
|
172
174
|
};
|
|
173
175
|
|
|
174
176
|
const LabelToken = {
|
|
177
|
+
name: 'LabelToken',
|
|
175
178
|
components: { GlFilteredSearchToken, GlFilteredSearchSuggestion, GlLoadingIcon, GlToken },
|
|
176
179
|
props: ['value', 'active'],
|
|
177
180
|
inheritAttrs: false,
|
|
@@ -9,6 +9,7 @@ import GlFilteredSearchTerm from './filtered_search_term.vue';
|
|
|
9
9
|
import {
|
|
10
10
|
isEmptyTerm,
|
|
11
11
|
TERM_TOKEN_TYPE,
|
|
12
|
+
INTENT_ACTIVATE_PREVIOUS,
|
|
12
13
|
normalizeTokens,
|
|
13
14
|
denormalizeTokens,
|
|
14
15
|
needDenormalization,
|
|
@@ -173,8 +174,8 @@ export default {
|
|
|
173
174
|
return this.getTokenEntry(type)?.token || GlFilteredSearchTerm;
|
|
174
175
|
},
|
|
175
176
|
|
|
176
|
-
activate(
|
|
177
|
-
this.activeTokenIdx =
|
|
177
|
+
activate(idx) {
|
|
178
|
+
this.activeTokenIdx = idx;
|
|
178
179
|
},
|
|
179
180
|
|
|
180
181
|
alignSuggestions(ref) {
|
|
@@ -201,15 +202,29 @@ export default {
|
|
|
201
202
|
this.activeTokenIdx = null;
|
|
202
203
|
},
|
|
203
204
|
|
|
204
|
-
destroyToken(idx) {
|
|
205
|
+
destroyToken(idx, { intent } = {}) {
|
|
205
206
|
if (this.tokens.length === 1) {
|
|
206
207
|
return;
|
|
207
208
|
}
|
|
208
209
|
|
|
209
210
|
this.tokens.splice(idx, 1);
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
|
|
212
|
+
// First, attempt to honor the user's activation intent behind the
|
|
213
|
+
// destruction of the token, if any. Otherwise, try to maintain the
|
|
214
|
+
// active state for the token that was active at the time. If that's not
|
|
215
|
+
// possible, make sure no token is active.
|
|
216
|
+
if (intent === INTENT_ACTIVATE_PREVIOUS) {
|
|
217
|
+
// If there is a previous token, activate it; else, deactivate all tokens
|
|
218
|
+
this.activeTokenIdx = idx > 0 ? idx - 1 : null;
|
|
219
|
+
} else if (idx < this.activeTokenIdx) {
|
|
220
|
+
// Preserve the active token's active status (it shifted down one index)
|
|
221
|
+
this.activeTokenIdx -= 1;
|
|
222
|
+
} else if (idx === this.activeTokenIdx) {
|
|
223
|
+
// User destroyed the active token; don't activate another one.
|
|
224
|
+
this.activeTokenIdx = null;
|
|
212
225
|
}
|
|
226
|
+
// Do nothing if there was no active token, or if idx > this.activeTokenIdx,
|
|
227
|
+
// to preserve the active state of the remaining tokens.
|
|
213
228
|
},
|
|
214
229
|
|
|
215
230
|
replaceToken(idx, token) {
|
|
@@ -297,7 +312,7 @@ export default {
|
|
|
297
312
|
}"
|
|
298
313
|
@activate="activate(idx)"
|
|
299
314
|
@deactivate="deactivate(token)"
|
|
300
|
-
@destroy="destroyToken(idx)"
|
|
315
|
+
@destroy="destroyToken(idx, $event)"
|
|
301
316
|
@replace="replaceToken(idx, $event)"
|
|
302
317
|
@complete="completeToken"
|
|
303
318
|
@submit="submit"
|
|
@@ -2,6 +2,7 @@ import { nextTick } from 'vue';
|
|
|
2
2
|
import { shallowMount } from '@vue/test-utils';
|
|
3
3
|
import GlFilteredSearchSuggestion from './filtered_search_suggestion.vue';
|
|
4
4
|
import FilteredSearchTerm from './filtered_search_term.vue';
|
|
5
|
+
import { INTENT_ACTIVATE_PREVIOUS } from './filtered_search_utils';
|
|
5
6
|
|
|
6
7
|
const availableTokens = [
|
|
7
8
|
{ type: 'foo', title: 'test1-foo', token: 'stub', icon: 'eye' },
|
|
@@ -59,23 +60,27 @@ describe('Filtered search term', () => {
|
|
|
59
60
|
});
|
|
60
61
|
|
|
61
62
|
it.each`
|
|
62
|
-
originalEvent | emittedEvent
|
|
63
|
-
${'activate'} | ${'activate'}
|
|
64
|
-
${'deactivate'} | ${'deactivate'}
|
|
65
|
-
${'split'} | ${'split'}
|
|
66
|
-
${'submit'} | ${'submit'}
|
|
67
|
-
${'complete'} | ${'replace'}
|
|
68
|
-
${'backspace'} | ${'destroy'}
|
|
63
|
+
originalEvent | emittedEvent | payload
|
|
64
|
+
${'activate'} | ${'activate'} | ${undefined}
|
|
65
|
+
${'deactivate'} | ${'deactivate'} | ${undefined}
|
|
66
|
+
${'split'} | ${'split'} | ${undefined}
|
|
67
|
+
${'submit'} | ${'submit'} | ${undefined}
|
|
68
|
+
${'complete'} | ${'replace'} | ${{ type: undefined }}
|
|
69
|
+
${'backspace'} | ${'destroy'} | ${{ intent: INTENT_ACTIVATE_PREVIOUS }}
|
|
69
70
|
`(
|
|
70
71
|
'emits $emittedEvent when token segment emits $originalEvent',
|
|
71
|
-
async ({ originalEvent, emittedEvent }) => {
|
|
72
|
+
async ({ originalEvent, emittedEvent, payload }) => {
|
|
72
73
|
createComponent({ active: true, value: { data: 'something' } });
|
|
73
74
|
|
|
74
75
|
findTokenSegmentComponent().vm.$emit(originalEvent);
|
|
75
76
|
|
|
76
77
|
await nextTick();
|
|
77
78
|
|
|
78
|
-
expect(wrapper.emitted(
|
|
79
|
+
expect(wrapper.emitted(emittedEvent)).toHaveLength(1);
|
|
80
|
+
|
|
81
|
+
if (payload !== undefined) {
|
|
82
|
+
expect(wrapper.emitted(emittedEvent)[0][0]).toEqual(payload);
|
|
83
|
+
}
|
|
79
84
|
}
|
|
80
85
|
);
|
|
81
86
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import GlFilteredSearchSuggestion from './filtered_search_suggestion.vue';
|
|
3
3
|
import GlFilteredSearchTokenSegment from './filtered_search_token_segment.vue';
|
|
4
|
+
import { INTENT_ACTIVATE_PREVIOUS } from './filtered_search_utils';
|
|
4
5
|
|
|
5
6
|
export default {
|
|
6
7
|
components: {
|
|
@@ -59,6 +60,11 @@ export default {
|
|
|
59
60
|
},
|
|
60
61
|
},
|
|
61
62
|
},
|
|
63
|
+
methods: {
|
|
64
|
+
onBackspace() {
|
|
65
|
+
this.$emit('destroy', { intent: INTENT_ACTIVATE_PREVIOUS });
|
|
66
|
+
},
|
|
67
|
+
},
|
|
62
68
|
};
|
|
63
69
|
</script>
|
|
64
70
|
|
|
@@ -75,7 +81,7 @@ export default {
|
|
|
75
81
|
@activate="$emit('activate')"
|
|
76
82
|
@deactivate="$emit('deactivate')"
|
|
77
83
|
@complete="$emit('replace', { type: $event })"
|
|
78
|
-
@backspace="
|
|
84
|
+
@backspace="onBackspace"
|
|
79
85
|
@submit="$emit('submit')"
|
|
80
86
|
@split="$emit('split', $event)"
|
|
81
87
|
>
|
|
@@ -2,6 +2,8 @@ import { first, last, isString } from 'lodash';
|
|
|
2
2
|
|
|
3
3
|
export const TERM_TOKEN_TYPE = 'filtered-search-term';
|
|
4
4
|
|
|
5
|
+
export const INTENT_ACTIVATE_PREVIOUS = 'intent-activate-previous';
|
|
6
|
+
|
|
5
7
|
export function isEmptyTerm(token) {
|
|
6
8
|
return token.type === TERM_TOKEN_TYPE && token.value.data.trim() === '';
|
|
7
9
|
}
|
|
@@ -78,6 +78,11 @@ export default {
|
|
|
78
78
|
required: false,
|
|
79
79
|
default: false,
|
|
80
80
|
},
|
|
81
|
+
invertInDarkMode: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
required: false,
|
|
84
|
+
default: true,
|
|
85
|
+
},
|
|
81
86
|
},
|
|
82
87
|
computed: {
|
|
83
88
|
height() {
|
|
@@ -108,7 +113,14 @@ export default {
|
|
|
108
113
|
:class="{ 'gl-display-none gl-sm-display-block gl-px-4': compact, 'gl-max-w-full': !compact }"
|
|
109
114
|
>
|
|
110
115
|
<div v-if="svgPath" :class="{ 'svg-content': !compact }" class="svg-250">
|
|
111
|
-
<img
|
|
116
|
+
<img
|
|
117
|
+
:src="svgPath"
|
|
118
|
+
alt=""
|
|
119
|
+
role="img"
|
|
120
|
+
:class="{ 'gl-dark-invert-keep-hue': invertInDarkMode }"
|
|
121
|
+
class="gl-max-w-full"
|
|
122
|
+
:height="height"
|
|
123
|
+
/>
|
|
112
124
|
</div>
|
|
113
125
|
</div>
|
|
114
126
|
<div :class="compact ? 'gl-flex-grow-1 gl-flex-basis-0 gl-px-4' : 'gl-max-w-full gl-m-auto'">
|
package/src/scss/utilities.scss
CHANGED
|
@@ -1896,6 +1896,14 @@
|
|
|
1896
1896
|
box-shadow: inset 0 0 0 $gl-border-size-1 $red-600 !important
|
|
1897
1897
|
}
|
|
1898
1898
|
|
|
1899
|
+
.gl-inset-border-l-3-red-600 {
|
|
1900
|
+
box-shadow: inset $gl-border-size-3 0 0 0 $red-600
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
.gl-inset-border-l-3-red-600\! {
|
|
1904
|
+
box-shadow: inset $gl-border-size-3 0 0 0 $red-600 !important
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1899
1907
|
.gl-inset-border-b-2-theme-accent {
|
|
1900
1908
|
box-shadow: inset 0 -#{$gl-border-size-2} 0 0 var(--gl-theme-accent, $theme-indigo-500)
|
|
1901
1909
|
}
|
|
@@ -2448,6 +2456,18 @@
|
|
|
2448
2456
|
.gl-text-theme-indigo-900\! {
|
|
2449
2457
|
color: $theme-indigo-900 !important;
|
|
2450
2458
|
}
|
|
2459
|
+
|
|
2460
|
+
.gl-dark-invert-keep-hue {
|
|
2461
|
+
.gl-dark & {
|
|
2462
|
+
filter: invert(0.8) hue-rotate(180deg);
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
.gl-dark-invert-keep-hue\! {
|
|
2467
|
+
.gl-dark & {
|
|
2468
|
+
filter: invert(0.8) hue-rotate(180deg) !important;
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2451
2471
|
.gl-content-empty {
|
|
2452
2472
|
content: ''
|
|
2453
2473
|
}
|
|
@@ -104,6 +104,10 @@
|
|
|
104
104
|
box-shadow: inset 0 0 0 $gl-border-size-1 $red-600;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
@mixin gl-inset-border-l-3-red-600 {
|
|
108
|
+
box-shadow: inset $gl-border-size-3 0 0 0 $red-600;
|
|
109
|
+
}
|
|
110
|
+
|
|
107
111
|
@mixin gl-inset-border-b-2-theme-accent {
|
|
108
112
|
box-shadow: inset 0 -#{$gl-border-size-2} 0 0 var(--gl-theme-accent, $theme-indigo-500);
|
|
109
113
|
}
|