@gitlab/ui 38.2.0 → 38.4.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 +13 -20
- package/dist/components/base/filtered_search/filtered_search_suggestion.js +1 -1
- package/dist/components/base/filtered_search/filtered_search_token.js +3 -7
- package/dist/components/base/filtered_search/filtered_search_utils.js +42 -9
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/package.json +10 -10
- package/src/components/base/filtered_search/filtered_search.spec.js +37 -12
- package/src/components/base/filtered_search/filtered_search.stories.js +13 -6
- package/src/components/base/filtered_search/filtered_search.vue +12 -14
- package/src/components/base/filtered_search/filtered_search_suggestion.vue +1 -0
- package/src/components/base/filtered_search/filtered_search_token.spec.js +9 -1
- package/src/components/base/filtered_search/filtered_search_token.vue +3 -2
- package/src/components/base/filtered_search/filtered_search_utils.js +38 -5
- package/src/components/base/skeleton_loader/skeleton_loader.stories.js +67 -21
- package/src/scss/utilities.scss +34 -0
- package/src/scss/utility-mixins/display.scss +12 -0
- package/src/scss/utility-mixins/spacing.scss +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
# [38.4.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v38.3.0...v38.4.0) (2022-04-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **css:** Add gl-sm-ml-auto util class ([3d9b37e](https://gitlab.com/gitlab-org/gitlab-ui/commit/3d9b37e2c39ece4ffabfcef08b7e82b93c0f7af1))
|
|
7
|
+
|
|
8
|
+
# [38.3.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v38.2.1...v38.3.0) (2022-04-04)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **css:** Add responsive display inline classes ([21a6358](https://gitlab.com/gitlab-org/gitlab-ui/commit/21a6358266f0183f4b3b0c8b90dc379f3ab8d3a3))
|
|
14
|
+
|
|
15
|
+
## [38.2.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v38.2.0...v38.2.1) (2022-04-01)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **GlFilteredSearch:** Generate stable token keys ([88dccde](https://gitlab.com/gitlab-org/gitlab-ui/commit/88dccde9f4df1352a7e06e831de8baced4a8d18f))
|
|
21
|
+
|
|
1
22
|
# [38.2.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v38.1.0...v38.2.0) (2022-03-31)
|
|
2
23
|
|
|
3
24
|
|
|
@@ -5,22 +5,12 @@ import { GlTooltipDirective } from '../../../directives/tooltip';
|
|
|
5
5
|
import GlIcon from '../icon/icon';
|
|
6
6
|
import GlSearchBoxByClick from '../search_box_by_click/search_box_by_click';
|
|
7
7
|
import GlFilteredSearchTerm from './filtered_search_term';
|
|
8
|
-
import {
|
|
8
|
+
import { createTerm, needDenormalization, denormalizeTokens, isEmptyTerm, INTENT_ACTIVATE_PREVIOUS, ensureTokenId, normalizeTokens } from './filtered_search_utils';
|
|
9
9
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
10
10
|
|
|
11
11
|
Vue.use(PortalVue);
|
|
12
12
|
let portalUuid = 0;
|
|
13
13
|
|
|
14
|
-
function createTerm() {
|
|
15
|
-
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
16
|
-
return {
|
|
17
|
-
type: TERM_TOKEN_TYPE,
|
|
18
|
-
value: {
|
|
19
|
-
data
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
14
|
function initialState() {
|
|
25
15
|
return [createTerm()];
|
|
26
16
|
}
|
|
@@ -172,6 +162,14 @@ var script = {
|
|
|
172
162
|
watch: {
|
|
173
163
|
tokens: {
|
|
174
164
|
handler() {
|
|
165
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
166
|
+
const invalidToken = this.tokens.find(token => !token.id);
|
|
167
|
+
|
|
168
|
+
if (invalidToken) {
|
|
169
|
+
throw new Error(`Token does not have an id:\n${JSON.stringify(invalidToken)}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
175
173
|
if (this.tokens.length === 0 || !this.isLastTokenEmpty()) {
|
|
176
174
|
this.tokens.push(createTerm());
|
|
177
175
|
}
|
|
@@ -278,12 +276,12 @@ var script = {
|
|
|
278
276
|
},
|
|
279
277
|
|
|
280
278
|
replaceToken(idx, token) {
|
|
281
|
-
this.$set(this.tokens, idx, { ...token,
|
|
279
|
+
this.$set(this.tokens, idx, ensureTokenId({ ...token,
|
|
282
280
|
value: {
|
|
283
281
|
data: '',
|
|
284
282
|
...token.value
|
|
285
283
|
}
|
|
286
|
-
});
|
|
284
|
+
}));
|
|
287
285
|
this.activeTokenIdx = idx;
|
|
288
286
|
},
|
|
289
287
|
|
|
@@ -295,12 +293,7 @@ var script = {
|
|
|
295
293
|
return;
|
|
296
294
|
}
|
|
297
295
|
|
|
298
|
-
const newTokens = newStrings.map(data => (
|
|
299
|
-
type: TERM_TOKEN_TYPE,
|
|
300
|
-
value: {
|
|
301
|
-
data
|
|
302
|
-
}
|
|
303
|
-
}));
|
|
296
|
+
const newTokens = newStrings.map(data => createTerm(data));
|
|
304
297
|
this.tokens.splice(idx + 1, 0, ...newTokens);
|
|
305
298
|
this.activeTokenIdx = idx + newStrings.length;
|
|
306
299
|
},
|
|
@@ -333,7 +326,7 @@ var script = {
|
|
|
333
326
|
const __vue_script__ = script;
|
|
334
327
|
|
|
335
328
|
/* template */
|
|
336
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-search-box-by-click',_vm._b({attrs:{"value":_vm.tokens,"history-items":_vm.historyItems,"clearable":_vm.hasValue,"search-button-attributes":_vm.searchButtonAttributes,"data-testid":"filtered-search-input"},on:{"submit":_vm.submit,"input":_vm.applyNewValue,"history-item-selected":function($event){return _vm.$emit('history-item-selected', $event)},"clear":function($event){return _vm.$emit('clear')},"clear-history":function($event){return _vm.$emit('clear-history')}},scopedSlots:_vm._u([{key:"history-item",fn:function(slotScope){return [_vm._t("history-item",null,null,slotScope)]}},{key:"input",fn:function(){return [_c('div',{staticClass:"gl-filtered-search-scrollable"},[_vm._l((_vm.tokens),function(token,idx){return [_c(_vm.getTokenComponent(token.type),{key:
|
|
329
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-search-box-by-click',_vm._b({attrs:{"value":_vm.tokens,"history-items":_vm.historyItems,"clearable":_vm.hasValue,"search-button-attributes":_vm.searchButtonAttributes,"data-testid":"filtered-search-input"},on:{"submit":_vm.submit,"input":_vm.applyNewValue,"history-item-selected":function($event){return _vm.$emit('history-item-selected', $event)},"clear":function($event){return _vm.$emit('clear')},"clear-history":function($event){return _vm.$emit('clear-history')}},scopedSlots:_vm._u([{key:"history-item",fn:function(slotScope){return [_vm._t("history-item",null,null,slotScope)]}},{key:"input",fn:function(){return [_c('div',{staticClass:"gl-filtered-search-scrollable"},[_vm._l((_vm.tokens),function(token,idx){return [_c(_vm.getTokenComponent(token.type),{key:token.id,ref:"tokens",refInFor:true,tag:"component",staticClass:"gl-filtered-search-item",class:{
|
|
337
330
|
'gl-filtered-search-last-item': _vm.isLastToken(idx),
|
|
338
331
|
},attrs:{"config":_vm.getTokenEntry(token.type),"active":_vm.activeTokenIdx === idx,"available-tokens":_vm.currentAvailableTokens,"current-value":_vm.tokens,"index":idx,"placeholder":_vm.termPlaceholder,"show-friendly-text":_vm.showFriendlyText,"search-input-attributes":_vm.searchInputAttributes,"is-last-token":_vm.isLastToken(idx)},on:{"activate":function($event){return _vm.activate(idx)},"deactivate":function($event){return _vm.deactivate(token)},"destroy":function($event){return _vm.destroyToken(idx, $event)},"replace":function($event){return _vm.replaceToken(idx, $event)},"complete":_vm.completeToken,"submit":_vm.submit,"split":function($event){return _vm.createTokens(idx, $event)}},model:{value:(token.value),callback:function ($$v) {_vm.$set(token, "value", $$v);},expression:"token.value"}})]})],2),_vm._v(" "),_c('portal-target',{key:_vm.activeTokenIdx,ref:"menu",style:(_vm.suggestionsStyle),attrs:{"name":_vm.portalName,"slim":""}})]},proxy:true}],null,true)},'gl-search-box-by-click',_vm.$attrs,false))};
|
|
339
332
|
var __vue_staticRenderFns__ = [];
|
|
@@ -59,7 +59,7 @@ var script = {
|
|
|
59
59
|
const __vue_script__ = script;
|
|
60
60
|
|
|
61
61
|
/* template */
|
|
62
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-dropdown-item',_vm._b({ref:"item",staticClass:"gl-filtered-search-suggestion",class:{ 'gl-filtered-search-suggestion-active': _vm.isActive },attrs:{"href":"#"},nativeOn:{"mousedown":function($event){$event.preventDefault();return _vm.emitValue($event)}}},'gl-dropdown-item',_vm.$attrs,false),[_vm._t("default")],2)};
|
|
62
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-dropdown-item',_vm._b({ref:"item",staticClass:"gl-filtered-search-suggestion",class:{ 'gl-filtered-search-suggestion-active': _vm.isActive },attrs:{"data-testid":"filtered-search-suggestion","href":"#"},nativeOn:{"mousedown":function($event){$event.preventDefault();return _vm.emitValue($event)}}},'gl-dropdown-item',_vm.$attrs,false),[_vm._t("default")],2)};
|
|
63
63
|
var __vue_staticRenderFns__ = [];
|
|
64
64
|
|
|
65
65
|
/* style */
|
|
@@ -2,7 +2,7 @@ import _cloneDeep from 'lodash/cloneDeep';
|
|
|
2
2
|
import { COMMA } from '../../../utils/constants';
|
|
3
3
|
import GlToken from '../token/token';
|
|
4
4
|
import GlFilteredSearchTokenSegment from './filtered_search_token_segment';
|
|
5
|
-
import {
|
|
5
|
+
import { createTerm } from './filtered_search_utils';
|
|
6
6
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
7
7
|
|
|
8
8
|
const SEGMENT_TITLE = 'TYPE';
|
|
@@ -203,12 +203,7 @@ var script = {
|
|
|
203
203
|
* Emitted when this token is converted to another type
|
|
204
204
|
* @property {object} token Replacement token configuration
|
|
205
205
|
*/
|
|
206
|
-
this.$emit('replace',
|
|
207
|
-
type: TERM_TOKEN_TYPE,
|
|
208
|
-
value: {
|
|
209
|
-
data: this.config.title
|
|
210
|
-
}
|
|
211
|
-
});
|
|
206
|
+
this.$emit('replace', createTerm(this.config.title));
|
|
212
207
|
}
|
|
213
208
|
},
|
|
214
209
|
|
|
@@ -298,6 +293,7 @@ var script = {
|
|
|
298
293
|
destroyByClose(event) {
|
|
299
294
|
if (event.target.closest(TOKEN_CLOSE_SELECTOR)) {
|
|
300
295
|
event.preventDefault();
|
|
296
|
+
event.stopPropagation();
|
|
301
297
|
this.$emit('destroy');
|
|
302
298
|
}
|
|
303
299
|
}
|
|
@@ -38,7 +38,45 @@ function needDenormalization(tokens) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
assertValidTokens(tokens);
|
|
41
|
-
return tokens.some(t => typeof t === 'string');
|
|
41
|
+
return tokens.some(t => typeof t === 'string' || !t.id);
|
|
42
|
+
}
|
|
43
|
+
let tokenIdCounter = 0;
|
|
44
|
+
|
|
45
|
+
const getTokenId = () => {
|
|
46
|
+
const tokenId = `token-${tokenIdCounter}`;
|
|
47
|
+
tokenIdCounter += 1;
|
|
48
|
+
return tokenId;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Ensure the given token has an `id` property, which `GlFilteredSearch` relies
|
|
52
|
+
* on as a unique key for the token.
|
|
53
|
+
*
|
|
54
|
+
* If the given token does not have an `id`, it returns a shallow copy of the
|
|
55
|
+
* token with an `id`. Otherwise, it returns the given token.
|
|
56
|
+
*
|
|
57
|
+
* @param {object} token The token to check.
|
|
58
|
+
* @returns {object} A token with an `id`.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
function ensureTokenId(token) {
|
|
63
|
+
if (!token.id) {
|
|
64
|
+
return { ...token,
|
|
65
|
+
id: getTokenId()
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return token;
|
|
70
|
+
}
|
|
71
|
+
function createTerm() {
|
|
72
|
+
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
73
|
+
return {
|
|
74
|
+
id: getTokenId(),
|
|
75
|
+
type: TERM_TOKEN_TYPE,
|
|
76
|
+
value: {
|
|
77
|
+
data
|
|
78
|
+
}
|
|
79
|
+
};
|
|
42
80
|
}
|
|
43
81
|
function denormalizeTokens(inputTokens) {
|
|
44
82
|
assertValidTokens(inputTokens);
|
|
@@ -47,14 +85,9 @@ function denormalizeTokens(inputTokens) {
|
|
|
47
85
|
tokens.forEach(t => {
|
|
48
86
|
if (typeof t === 'string') {
|
|
49
87
|
const stringTokens = t.split(' ').filter(Boolean);
|
|
50
|
-
stringTokens.forEach(strToken => result.push(
|
|
51
|
-
type: TERM_TOKEN_TYPE,
|
|
52
|
-
value: {
|
|
53
|
-
data: strToken
|
|
54
|
-
}
|
|
55
|
-
}));
|
|
88
|
+
stringTokens.forEach(strToken => result.push(createTerm(strToken)));
|
|
56
89
|
} else {
|
|
57
|
-
result.push(t);
|
|
90
|
+
result.push(ensureTokenId(t));
|
|
58
91
|
}
|
|
59
92
|
});
|
|
60
93
|
return result;
|
|
@@ -135,4 +168,4 @@ function wrapTokenInQuotes(token) {
|
|
|
135
168
|
return `"${token}"`;
|
|
136
169
|
}
|
|
137
170
|
|
|
138
|
-
export { INTENT_ACTIVATE_PREVIOUS, TERM_TOKEN_TYPE, denormalizeTokens, isEmptyTerm, needDenormalization, normalizeTokens, splitOnQuotes, wrapTokenInQuotes };
|
|
171
|
+
export { INTENT_ACTIVATE_PREVIOUS, TERM_TOKEN_TYPE, createTerm, denormalizeTokens, ensureTokenId, isEmptyTerm, needDenormalization, normalizeTokens, splitOnQuotes, wrapTokenInQuotes };
|