@gitlab/ui 37.4.1 → 37.4.2
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 +7 -0
- package/dist/components/base/filtered_search/filtered_search_term.js +6 -1
- package/dist/components/base/filtered_search/filtered_search_token_segment.js +10 -1
- package/package.json +1 -1
- package/src/components/base/filtered_search/filtered_search.spec.js +12 -0
- package/src/components/base/filtered_search/filtered_search_term.spec.js +8 -2
- package/src/components/base/filtered_search/filtered_search_term.vue +6 -0
- package/src/components/base/filtered_search/filtered_search_token_segment.spec.js +46 -37
- package/src/components/base/filtered_search/filtered_search_token_segment.vue +14 -1
- package/src/components/base/form/form_select/form_select.spec.js +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [37.4.2](https://gitlab.com/gitlab-org/gitlab-ui/compare/v37.4.1...v37.4.2) (2022-03-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **GlFilteredSearch:** fix duplicate input attributes ([ea498b9](https://gitlab.com/gitlab-org/gitlab-ui/commit/ea498b9d114c86804d2885b645770ce53d178f4d))
|
|
7
|
+
|
|
1
8
|
## [37.4.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v37.4.0...v37.4.1) (2022-03-07)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -39,6 +39,11 @@ var script = {
|
|
|
39
39
|
type: Boolean,
|
|
40
40
|
required: false,
|
|
41
41
|
default: false
|
|
42
|
+
},
|
|
43
|
+
currentValue: {
|
|
44
|
+
type: Array,
|
|
45
|
+
required: false,
|
|
46
|
+
default: () => []
|
|
42
47
|
}
|
|
43
48
|
},
|
|
44
49
|
computed: {
|
|
@@ -65,7 +70,7 @@ var script = {
|
|
|
65
70
|
const __vue_script__ = script;
|
|
66
71
|
|
|
67
72
|
/* template */
|
|
68
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-h-auto gl-filtered-search-term"},[_c('gl-filtered-search-token-segment',{staticClass:"gl-filtered-search-term-token",class:{ 'gl-w-full': _vm.placeholder },attrs:{"active":_vm.active,"search-input-attributes":_vm.searchInputAttributes,"is-last-token":_vm.isLastToken},on:{"activate":function($event){return _vm.$emit('activate')},"deactivate":function($event){return _vm.$emit('deactivate')},"complete":function($event){return _vm.$emit('replace', { type: $event })},"backspace":function($event){return _vm.$emit('destroy')},"submit":function($event){return _vm.$emit('submit')},"split":function($event){return _vm.$emit('split', $event)}},scopedSlots:_vm._u([{key:"suggestions",fn:function(){return _vm._l((_vm.suggestedTokens),function(item,idx){return _c('gl-filtered-search-suggestion',{key:idx,attrs:{"value":item.type,"icon-name":item.icon}},[_vm._v("\n "+_vm._s(item.title)+"\n ")])})},proxy:true},{key:"view",fn:function(){return [(_vm.placeholder)?_c('input',_vm._b({staticClass:"gl-filtered-search-term-input",attrs:{"placeholder":_vm.placeholder,"aria-label":_vm.placeholder}},'input',_vm.searchInputAttributes,false)):[_vm._v(_vm._s(_vm.value.data))]]},proxy:true}]),model:{value:(_vm.internalValue),callback:function ($$v) {_vm.internalValue=$$v;},expression:"internalValue"}})],1)};
|
|
73
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-h-auto gl-filtered-search-term"},[_c('gl-filtered-search-token-segment',{staticClass:"gl-filtered-search-term-token",class:{ 'gl-w-full': _vm.placeholder },attrs:{"active":_vm.active,"search-input-attributes":_vm.searchInputAttributes,"is-last-token":_vm.isLastToken,"current-value":_vm.currentValue},on:{"activate":function($event){return _vm.$emit('activate')},"deactivate":function($event){return _vm.$emit('deactivate')},"complete":function($event){return _vm.$emit('replace', { type: $event })},"backspace":function($event){return _vm.$emit('destroy')},"submit":function($event){return _vm.$emit('submit')},"split":function($event){return _vm.$emit('split', $event)}},scopedSlots:_vm._u([{key:"suggestions",fn:function(){return _vm._l((_vm.suggestedTokens),function(item,idx){return _c('gl-filtered-search-suggestion',{key:idx,attrs:{"value":item.type,"icon-name":item.icon}},[_vm._v("\n "+_vm._s(item.title)+"\n ")])})},proxy:true},{key:"view",fn:function(){return [(_vm.placeholder)?_c('input',_vm._b({staticClass:"gl-filtered-search-term-input",attrs:{"placeholder":_vm.placeholder,"aria-label":_vm.placeholder}},'input',_vm.searchInputAttributes,false)):[_vm._v(_vm._s(_vm.value.data))]]},proxy:true}]),model:{value:(_vm.internalValue),callback:function ($$v) {_vm.internalValue=$$v;},expression:"internalValue"}})],1)};
|
|
69
74
|
var __vue_staticRenderFns__ = [];
|
|
70
75
|
|
|
71
76
|
/* style */
|
|
@@ -58,6 +58,11 @@ var script = {
|
|
|
58
58
|
type: Boolean,
|
|
59
59
|
required: false,
|
|
60
60
|
default: false
|
|
61
|
+
},
|
|
62
|
+
currentValue: {
|
|
63
|
+
type: Array,
|
|
64
|
+
required: false,
|
|
65
|
+
default: () => []
|
|
61
66
|
}
|
|
62
67
|
},
|
|
63
68
|
|
|
@@ -113,6 +118,10 @@ var script = {
|
|
|
113
118
|
|
|
114
119
|
const defaultSuggestion = this.options.find(op => op.default);
|
|
115
120
|
return (_ref = defaultSuggestion !== null && defaultSuggestion !== void 0 ? defaultSuggestion : this.options[0]) === null || _ref === void 0 ? void 0 : _ref.value;
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
containerAttributes() {
|
|
124
|
+
return this.isLastToken && !this.active && this.currentValue.length > 1 && this.searchInputAttributes;
|
|
116
125
|
}
|
|
117
126
|
|
|
118
127
|
},
|
|
@@ -284,7 +293,7 @@ var script = {
|
|
|
284
293
|
const __vue_script__ = script;
|
|
285
294
|
|
|
286
295
|
/* template */
|
|
287
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',_vm._b({staticClass:"gl-filtered-search-token-segment",class:{ 'gl-filtered-search-token-segment-active': _vm.active },attrs:{"data-testid":"filtered-search-token-segment"},on:{"mousedown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"left",37,$event.key,["Left","ArrowLeft"])){ return null; }if('button' in $event && $event.button !== 0){ return null; }return _vm.emitIfInactive($event)}}},'div',_vm.
|
|
296
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',_vm._b({staticClass:"gl-filtered-search-token-segment",class:{ 'gl-filtered-search-token-segment-active': _vm.active },attrs:{"data-testid":"filtered-search-token-segment"},on:{"mousedown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"left",37,$event.key,["Left","ArrowLeft"])){ return null; }if('button' in $event && $event.button !== 0){ return null; }return _vm.emitIfInactive($event)}}},'div',_vm.containerAttributes,false),[(_vm.active)?[(((_vm.searchInputAttributes).type)==='checkbox')?_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",attrs:{"aria-label":_vm.label,"type":"checkbox"},domProps:{"checked":Array.isArray(_vm.inputValue)?_vm._i(_vm.inputValue,null)>-1:(_vm.inputValue)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"change":function($event){var $$a=_vm.inputValue,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=null,$$i=_vm._i($$a,$$v);if($$el.checked){$$i<0&&(_vm.inputValue=$$a.concat([$$v]));}else {$$i>-1&&(_vm.inputValue=$$a.slice(0,$$i).concat($$a.slice($$i+1)));}}else {_vm.inputValue=$$c;}}}},'input',_vm.searchInputAttributes,false)):(((_vm.searchInputAttributes).type)==='radio')?_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",attrs:{"aria-label":_vm.label,"type":"radio"},domProps:{"checked":_vm._q(_vm.inputValue,null)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"change":function($event){_vm.inputValue=null;}}},'input',_vm.searchInputAttributes,false)):_c('input',_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",staticClass:"gl-filtered-search-token-segment-input",attrs:{"aria-label":_vm.label,"type":(_vm.searchInputAttributes).type},domProps:{"value":(_vm.inputValue)},on:{"keydown":_vm.handleInputKeydown,"blur":_vm.handleBlur,"input":function($event){if($event.target.composing){ return; }_vm.inputValue=$event.target.value;}}},'input',_vm.searchInputAttributes,false)),_vm._v(" "),_c('portal',{key:("operator-" + _vm._uid),attrs:{"to":_vm.portalName}},[(_vm.hasOptionsOrSuggestions)?_c('gl-filtered-search-suggestion-list',{key:("operator-" + _vm._uid),ref:"suggestions",attrs:{"initial-value":_vm.defaultSuggestedValue},on:{"suggestion":_vm.applySuggestion}},[(_vm.options)?_vm._l((_vm.options),function(option,idx){return _c('gl-filtered-search-suggestion',{key:((option.value) + "-" + idx),attrs:{"value":option.value,"icon-name":option.icon}},[_vm._t("option",[_vm._v("\n "+_vm._s(option[_vm.optionTextField])+"\n ")],null,{ option: option })],2)}):_vm._t("suggestions")],2):_vm._e()],1)]:_vm._t("view",[_vm._v(_vm._s(_vm.inputValue))],null,{ inputValue: _vm.inputValue })],2)};
|
|
288
297
|
var __vue_staticRenderFns__ = [];
|
|
289
298
|
|
|
290
299
|
/* style */
|
package/package.json
CHANGED
|
@@ -378,6 +378,18 @@ describe('Filtered search', () => {
|
|
|
378
378
|
expect(filteredSearchTerms.at(0).props('isLastToken')).toBe(false);
|
|
379
379
|
expect(filteredSearchTerms.at(1).props('isLastToken')).toBe(true);
|
|
380
380
|
});
|
|
381
|
+
|
|
382
|
+
it('passes `currentValue` prop to search terms', async () => {
|
|
383
|
+
createComponent({
|
|
384
|
+
value: ['one'],
|
|
385
|
+
});
|
|
386
|
+
await nextTick();
|
|
387
|
+
|
|
388
|
+
expect(wrapper.findComponent(GlFilteredSearchTerm).props('currentValue')).toEqual([
|
|
389
|
+
{ type: 'filtered-search-term', value: { data: 'one' } },
|
|
390
|
+
{ type: 'filtered-search-term', value: { data: '' } },
|
|
391
|
+
]);
|
|
392
|
+
});
|
|
381
393
|
});
|
|
382
394
|
|
|
383
395
|
describe('Filtered search integration tests', () => {
|
|
@@ -21,7 +21,7 @@ describe('Filtered search term', () => {
|
|
|
21
21
|
const segmentStub = {
|
|
22
22
|
name: 'gl-filtered-search-token-segment-stub',
|
|
23
23
|
template: '<div><slot name="view"></slot><slot name="suggestions"></slot></div>',
|
|
24
|
-
props: ['searchInputAttributes', 'isLastToken'],
|
|
24
|
+
props: ['searchInputAttributes', 'isLastToken', 'currentValue'],
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
const createComponent = (props) => {
|
|
@@ -79,18 +79,24 @@ describe('Filtered search term', () => {
|
|
|
79
79
|
}
|
|
80
80
|
);
|
|
81
81
|
|
|
82
|
-
it('passes `searchInputAttributes` and `
|
|
82
|
+
it('passes `searchInputAttributes`, `isLastToken`, and `currentValue` props to `GlFilteredSearchTokenSegment`', () => {
|
|
83
83
|
const isLastToken = true;
|
|
84
|
+
const currentValue = [
|
|
85
|
+
{ type: 'filtered-search-term', value: { data: 'something' } },
|
|
86
|
+
{ type: 'filtered-search-term', value: { data: '' } },
|
|
87
|
+
];
|
|
84
88
|
|
|
85
89
|
createComponent({
|
|
86
90
|
value: { data: 'something' },
|
|
87
91
|
searchInputAttributes,
|
|
88
92
|
isLastToken,
|
|
93
|
+
currentValue,
|
|
89
94
|
});
|
|
90
95
|
|
|
91
96
|
expect(findTokenSegmentComponent().props()).toEqual({
|
|
92
97
|
searchInputAttributes,
|
|
93
98
|
isLastToken,
|
|
99
|
+
currentValue,
|
|
94
100
|
});
|
|
95
101
|
});
|
|
96
102
|
|
|
@@ -38,6 +38,11 @@ export default {
|
|
|
38
38
|
required: false,
|
|
39
39
|
default: false,
|
|
40
40
|
},
|
|
41
|
+
currentValue: {
|
|
42
|
+
type: Array,
|
|
43
|
+
required: false,
|
|
44
|
+
default: () => [],
|
|
45
|
+
},
|
|
41
46
|
},
|
|
42
47
|
computed: {
|
|
43
48
|
suggestedTokens() {
|
|
@@ -66,6 +71,7 @@ export default {
|
|
|
66
71
|
:class="{ 'gl-w-full': placeholder }"
|
|
67
72
|
:search-input-attributes="searchInputAttributes"
|
|
68
73
|
:is-last-token="isLastToken"
|
|
74
|
+
:current-value="currentValue"
|
|
69
75
|
@activate="$emit('activate')"
|
|
70
76
|
@deactivate="$emit('deactivate')"
|
|
71
77
|
@complete="$emit('replace', { type: $event })"
|
|
@@ -254,54 +254,63 @@ describe('Filtered search token segment', () => {
|
|
|
254
254
|
});
|
|
255
255
|
});
|
|
256
256
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
const currentValueNoTokens = [{ type: 'filtered-search-term', value: { data: '' } }];
|
|
258
|
+
const currentValueOneToken = [
|
|
259
|
+
{ type: 'filtered-search-term', value: { data: 'one' } },
|
|
260
|
+
{ type: 'filtered-search-term', value: { data: '' } },
|
|
261
|
+
];
|
|
262
|
+
|
|
263
|
+
describe.each`
|
|
264
|
+
active | isLastToken | currentValue
|
|
265
|
+
${true} | ${true} | ${currentValueNoTokens}
|
|
266
|
+
${true} | ${false} | ${currentValueNoTokens}
|
|
267
|
+
${false} | ${true} | ${currentValueNoTokens}
|
|
268
|
+
${true} | ${true} | ${currentValueOneToken}
|
|
269
|
+
${true} | ${false} | ${currentValueOneToken}
|
|
270
|
+
`(
|
|
271
|
+
'when `active` is `$active`, `isLastToken` is `$isLastToken` and `currentValue` is `$currentValue`',
|
|
272
|
+
({ active, isLastToken, currentValue }) => {
|
|
273
|
+
beforeEach(() => {
|
|
274
|
+
createComponent({
|
|
275
|
+
value: 'something',
|
|
276
|
+
active,
|
|
277
|
+
isLastToken,
|
|
278
|
+
currentValue,
|
|
279
|
+
searchInputAttributes,
|
|
280
|
+
});
|
|
281
|
+
});
|
|
260
282
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
);
|
|
264
|
-
}
|
|
283
|
+
it('does not add `searchInputAttributes` prop to search token segment', () => {
|
|
284
|
+
expect(wrapper.attributes('data-qa-selector')).toBe(undefined);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
);
|
|
265
288
|
|
|
266
|
-
|
|
289
|
+
describe('when `active` is `false`, `isLastToken` is `true` and there is one or more tokens', () => {
|
|
290
|
+
beforeEach(() => {
|
|
267
291
|
createComponent({
|
|
268
|
-
active: true,
|
|
269
292
|
value: 'something',
|
|
270
|
-
|
|
293
|
+
active: false,
|
|
271
294
|
isLastToken: true,
|
|
295
|
+
currentValue: currentValueOneToken,
|
|
296
|
+
searchInputAttributes,
|
|
272
297
|
});
|
|
273
|
-
|
|
274
|
-
expect(wrapper.attributes('data-qa-selector')).toBe(undefined);
|
|
275
298
|
});
|
|
276
|
-
});
|
|
277
299
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
active: false,
|
|
283
|
-
value: 'something',
|
|
284
|
-
searchInputAttributes,
|
|
285
|
-
isLastToken: true,
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
expect(wrapper.attributes('data-qa-selector')).toBe(
|
|
289
|
-
searchInputAttributes['data-qa-selector']
|
|
290
|
-
);
|
|
291
|
-
});
|
|
300
|
+
it('adds `searchInputAttributes` prop to search token segment', () => {
|
|
301
|
+
expect(wrapper.attributes('data-qa-selector')).toBe(
|
|
302
|
+
searchInputAttributes['data-qa-selector']
|
|
303
|
+
);
|
|
292
304
|
});
|
|
305
|
+
});
|
|
293
306
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
active: false,
|
|
298
|
-
value: 'something',
|
|
299
|
-
searchInputAttributes,
|
|
300
|
-
isLastToken: false,
|
|
301
|
-
});
|
|
307
|
+
describe('when input is active', () => {
|
|
308
|
+
it('adds `searchInputAttributes` prop to search token segment input', () => {
|
|
309
|
+
createComponent({ active: true, value: 'something', searchInputAttributes });
|
|
302
310
|
|
|
303
|
-
|
|
304
|
-
|
|
311
|
+
expect(wrapper.find('input').attributes('data-qa-selector')).toBe(
|
|
312
|
+
searchInputAttributes['data-qa-selector']
|
|
313
|
+
);
|
|
305
314
|
});
|
|
306
315
|
});
|
|
307
316
|
});
|
|
@@ -59,6 +59,11 @@ export default {
|
|
|
59
59
|
required: false,
|
|
60
60
|
default: false,
|
|
61
61
|
},
|
|
62
|
+
currentValue: {
|
|
63
|
+
type: Array,
|
|
64
|
+
required: false,
|
|
65
|
+
default: () => [],
|
|
66
|
+
},
|
|
62
67
|
},
|
|
63
68
|
|
|
64
69
|
data() {
|
|
@@ -106,6 +111,14 @@ export default {
|
|
|
106
111
|
const defaultSuggestion = this.options.find((op) => op.default);
|
|
107
112
|
return (defaultSuggestion ?? this.options[0])?.value;
|
|
108
113
|
},
|
|
114
|
+
containerAttributes() {
|
|
115
|
+
return (
|
|
116
|
+
this.isLastToken &&
|
|
117
|
+
!this.active &&
|
|
118
|
+
this.currentValue.length > 1 &&
|
|
119
|
+
this.searchInputAttributes
|
|
120
|
+
);
|
|
121
|
+
},
|
|
109
122
|
},
|
|
110
123
|
|
|
111
124
|
watch: {
|
|
@@ -254,7 +267,7 @@ export default {
|
|
|
254
267
|
|
|
255
268
|
<template>
|
|
256
269
|
<div
|
|
257
|
-
v-bind="
|
|
270
|
+
v-bind="containerAttributes"
|
|
258
271
|
class="gl-filtered-search-token-segment"
|
|
259
272
|
:class="{ 'gl-filtered-search-token-segment-active': active }"
|
|
260
273
|
data-testid="filtered-search-token-segment"
|
|
@@ -25,7 +25,9 @@ describe('GlFormSelect', () => {
|
|
|
25
25
|
`('adds $expectedClass class for state $state', ({ state, expectedClasses }) => {
|
|
26
26
|
createComponent({ state });
|
|
27
27
|
|
|
28
|
-
expect(wrapper.classes()).toEqual(
|
|
28
|
+
expect(wrapper.classes().sort()).toEqual(
|
|
29
|
+
[...DEFAULT_SELECT_CLASSES, ...expectedClasses].sort()
|
|
30
|
+
);
|
|
29
31
|
});
|
|
30
32
|
});
|
|
31
33
|
|
|
@@ -36,19 +38,21 @@ describe('GlFormSelect', () => {
|
|
|
36
38
|
it.each(nonNullSizes)('adds correct class for size %s', (size) => {
|
|
37
39
|
createComponent({ size });
|
|
38
40
|
|
|
39
|
-
expect(wrapper.classes()).toEqual(
|
|
41
|
+
expect(wrapper.classes().sort()).toEqual(
|
|
42
|
+
[...DEFAULT_SELECT_CLASSES, `custom-select-${size}`].sort()
|
|
43
|
+
);
|
|
40
44
|
});
|
|
41
45
|
|
|
42
46
|
it('does not add a size class if not given the size prop', () => {
|
|
43
47
|
createComponent();
|
|
44
48
|
|
|
45
|
-
expect(wrapper.classes()).toEqual([...DEFAULT_SELECT_CLASSES]);
|
|
49
|
+
expect(wrapper.classes().sort()).toEqual([...DEFAULT_SELECT_CLASSES].sort());
|
|
46
50
|
});
|
|
47
51
|
|
|
48
52
|
it('does not add a size class if passed null', () => {
|
|
49
53
|
createComponent({ size: null });
|
|
50
54
|
|
|
51
|
-
expect(wrapper.classes()).toEqual([...DEFAULT_SELECT_CLASSES]);
|
|
55
|
+
expect(wrapper.classes().sort()).toEqual([...DEFAULT_SELECT_CLASSES].sort());
|
|
52
56
|
});
|
|
53
57
|
});
|
|
54
58
|
|