@gitlab/ui 57.0.0 → 58.1.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 CHANGED
@@ -1,3 +1,23 @@
1
+ # [58.1.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v58.0.0...v58.1.0) (2023-03-16)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlFilteredSearch:** added title slot to GlFilteredSearch ([88d82d7](https://gitlab.com/gitlab-org/gitlab-ui/commit/88d82d77c5e93a180b97b1cd702af80452863ff2))
7
+
8
+ # [58.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v57.0.0...v58.0.0) (2023-03-15)
9
+
10
+
11
+ ### Features
12
+
13
+ * **GlCollapsibleListbox:** Remove deprecated GlListbox export ([baaade2](https://gitlab.com/gitlab-org/gitlab-ui/commit/baaade289126b05e47b015644448d7cbb0e98a21))
14
+
15
+
16
+ ### BREAKING CHANGES
17
+
18
+ * **GlCollapsibleListbox:** The deprecated GlListbox alias for GlCollapsibleListbox
19
+ has been removed.
20
+
1
21
  # [57.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v56.4.1...v57.0.0) (2023-03-15)
2
22
 
3
23
 
@@ -320,6 +320,9 @@ var script = {
320
320
  * @property {array} tokens
321
321
  */
322
322
  this.$emit('submit', normalizeTokens(cloneDeep(this.tokens)));
323
+ },
324
+ hasTitleSlot() {
325
+ return Boolean(this.$scopedSlots.title);
323
326
  }
324
327
  }
325
328
  };
@@ -328,7 +331,7 @@ var script = {
328
331
  const __vue_script__ = script;
329
332
 
330
333
  /* template */
331
- 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,"disabled":_vm.viewOnly,"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",class:{ 'gl-bg-gray-10! gl-inset-border-1-gray-100!': _vm.viewOnly }},_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:{ 'gl-filtered-search-last-item': _vm.isLastToken(idx) && !_vm.viewOnly },attrs:{"config":_vm.getTokenEntry(token.type),"active":_vm.activeTokenIdx === idx,"cursor-position":_vm.intendedCursorPosition,"available-tokens":_vm.currentAvailableTokens,"current-value":_vm.tokens,"index":idx,"placeholder":_vm.termPlaceholder,"show-friendly-text":_vm.showFriendlyText,"search-input-attributes":_vm.searchInputAttributes,"view-only":_vm.viewOnly,"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)},"previous":_vm.activatePreviousToken,"next":_vm.activateNextToken},model:{value:(token.value),callback:function ($$v) {_vm.$set(token, "value", $$v);},expression:"token.value"}})}),1),_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))};
334
+ 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,"disabled":_vm.viewOnly,"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",class:{ 'gl-bg-gray-10! gl-inset-border-1-gray-100!': _vm.viewOnly }},_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:{ 'gl-filtered-search-last-item': _vm.isLastToken(idx) && !_vm.viewOnly },attrs:{"config":_vm.getTokenEntry(token.type),"active":_vm.activeTokenIdx === idx,"cursor-position":_vm.intendedCursorPosition,"available-tokens":_vm.currentAvailableTokens,"current-value":_vm.tokens,"index":idx,"placeholder":_vm.termPlaceholder,"show-friendly-text":_vm.showFriendlyText,"search-input-attributes":_vm.searchInputAttributes,"view-only":_vm.viewOnly,"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)},"previous":_vm.activatePreviousToken,"next":_vm.activateNextToken},scopedSlots:_vm._u([(_vm.hasTitleSlot() && _vm.getTokenComponent(token.type).name === 'GlFilteredSearchTerm')?{key:"title",fn:function(title){return [_vm._t("title",null,null,title)]}}:null],null,true),model:{value:(token.value),callback:function ($$v) {_vm.$set(token, "value", $$v);},expression:"token.value"}})}),1),_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))};
332
335
  var __vue_staticRenderFns__ = [];
333
336
 
334
337
  /* style */
@@ -118,7 +118,7 @@ var script = {
118
118
  const __vue_script__ = script;
119
119
 
120
120
  /* template */
121
- 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",attrs:{"data-testid":"filtered-search-term"}},[_c('gl-filtered-search-token-segment',{ref:"segment",staticClass:"gl-filtered-search-term-token",class:{ 'gl-w-full': _vm.placeholder },attrs:{"active":_vm.active,"cursor-position":_vm.cursorPosition,"search-input-attributes":_vm.searchInputAttributes,"is-last-token":_vm.isLastToken,"current-value":_vm.currentValue,"view-only":_vm.viewOnly},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":_vm.onBackspace,"submit":function($event){return _vm.$emit('submit')},"split":function($event){return _vm.$emit('split', $event)},"previous":function($event){return _vm.$emit('previous')},"next":function($event){return _vm.$emit('next')}},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",class:{ 'gl-bg-gray-10': _vm.viewOnly },attrs:{"placeholder":_vm.placeholder,"aria-label":_vm.placeholder,"readonly":_vm.viewOnly,"data-testid":"filtered-search-term-input"}},'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)};
121
+ 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",attrs:{"data-testid":"filtered-search-term"}},[_c('gl-filtered-search-token-segment',{ref:"segment",staticClass:"gl-filtered-search-term-token",class:{ 'gl-w-full': _vm.placeholder },attrs:{"active":_vm.active,"cursor-position":_vm.cursorPosition,"search-input-attributes":_vm.searchInputAttributes,"is-last-token":_vm.isLastToken,"current-value":_vm.currentValue,"view-only":_vm.viewOnly},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":_vm.onBackspace,"submit":function($event){return _vm.$emit('submit')},"split":function($event){return _vm.$emit('split', $event)},"previous":function($event){return _vm.$emit('previous')},"next":function($event){return _vm.$emit('next')}},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._t("title",function(){return [_vm._v(" "+_vm._s(item.title)+" ")]},null,{ value: item.title })],2)})},proxy:true},{key:"view",fn:function(){return [(_vm.placeholder)?_c('input',_vm._b({staticClass:"gl-filtered-search-term-input",class:{ 'gl-bg-gray-10': _vm.viewOnly },attrs:{"placeholder":_vm.placeholder,"aria-label":_vm.placeholder,"readonly":_vm.viewOnly,"data-testid":"filtered-search-term-input"}},'input',_vm.searchInputAttributes,false)):[_vm._v(_vm._s(_vm.value.data))]]},proxy:true}],null,true),model:{value:(_vm.internalValue),callback:function ($$v) {_vm.internalValue=$$v;},expression:"internalValue"}})],1)};
122
122
  var __vue_staticRenderFns__ = [];
123
123
 
124
124
  /* style */
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ export { default as GlDropdownSectionHeader } from './components/base/dropdown/d
44
44
  export { default as GlDropdownDivider } from './components/base/dropdown/dropdown_divider';
45
45
  export { default as GlDropdownText } from './components/base/dropdown/dropdown_text';
46
46
  export { default as GlDropdown } from './components/base/dropdown/dropdown';
47
- export { default as GlCollapsibleListbox, default as GlListbox } from './components/base/new_dropdowns/listbox/listbox';
47
+ export { default as GlCollapsibleListbox } from './components/base/new_dropdowns/listbox/listbox';
48
48
  export { default as GlListboxItem } from './components/base/new_dropdowns/listbox/listbox_item';
49
49
  export { default as GlDisclosureDropdown } from './components/base/new_dropdowns/disclosure/disclosure_dropdown';
50
50
  export { default as GlDisclosureDropdownItem } from './components/base/new_dropdowns/disclosure/disclosure_dropdown_item';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "57.0.0",
3
+ "version": "58.1.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -117,7 +117,7 @@
117
117
  "bootstrap-vue-vue3": "npm:bootstrap-vue@2.23.1",
118
118
  "cypress": "^11.2.0",
119
119
  "emoji-regex": "^10.0.0",
120
- "eslint": "8.35.0",
120
+ "eslint": "8.36.0",
121
121
  "eslint-import-resolver-jest": "3.0.2",
122
122
  "eslint-plugin-cypress": "2.12.1",
123
123
  "eslint-plugin-storybook": "0.6.11",
@@ -29,7 +29,7 @@ Prepare array of available token configurations with the following fields:
29
29
  Each token for filtered search is a Vue component with the following props:
30
30
 
31
31
  - `value`: an object with a `data` property containing the current value, and optionally an
32
- `operator` value containing the operator value
32
+ `operator` value containing the operator value
33
33
  - `active`: indicates if the token is currently active. It's the token's responsibility
34
34
  to render proper control for editing (for example input).
35
35
  - `current-value`: current tokens of the filtered search.
@@ -60,6 +60,5 @@ Pass the list of tokens to the search component. Optionally, you can use `v-mode
60
60
  realtime updates:
61
61
 
62
62
  ```html
63
-
64
63
  <gl-filtered-search :available-tokens="tokens" v-model="value" />
65
64
  ```
@@ -346,6 +346,9 @@ export default {
346
346
  */
347
347
  this.$emit('submit', normalizeTokens(cloneDeep(this.tokens)));
348
348
  },
349
+ hasTitleSlot() {
350
+ return Boolean(this.$scopedSlots.title);
351
+ },
349
352
  },
350
353
  };
351
354
  </script>
@@ -402,7 +405,14 @@ export default {
402
405
  @split="createTokens(idx, $event)"
403
406
  @previous="activatePreviousToken"
404
407
  @next="activateNextToken"
405
- />
408
+ >
409
+ <template
410
+ v-if="hasTitleSlot() && getTokenComponent(token.type).name === 'GlFilteredSearchTerm'"
411
+ #title="title"
412
+ >
413
+ <slot name="title" v-bind="title"></slot>
414
+ </template>
415
+ </component>
406
416
  </div>
407
417
  <portal-target
408
418
  ref="menu"
@@ -26,18 +26,36 @@ describe('Filtered search term', () => {
26
26
  props: ['searchInputAttributes', 'isLastToken', 'currentValue', 'viewOnly'],
27
27
  };
28
28
 
29
- const createComponent = (props) => {
29
+ const createComponent = (props, options = {}) => {
30
30
  wrapper = shallowMount(FilteredSearchTerm, {
31
31
  propsData: { ...defaultProps, ...props },
32
32
  stubs: {
33
33
  'gl-filtered-search-token-segment': segmentStub,
34
34
  },
35
+ ...options,
35
36
  });
36
37
  };
37
38
 
38
39
  const findSearchInput = () => wrapper.find('input');
39
40
  const findTokenSegmentComponent = () => wrapper.findComponent(segmentStub);
40
41
 
42
+ it('renders title slot', async () => {
43
+ createComponent(
44
+ { availableTokens, active: true, value: { data: 'test1' } },
45
+ {
46
+ scopedSlots: {
47
+ title: '<div slot-scope="{ value }">New {{value}}</div>',
48
+ },
49
+ }
50
+ );
51
+
52
+ await nextTick();
53
+
54
+ expect(wrapper.findAllComponents(GlFilteredSearchSuggestion).at(0).text()).toBe(
55
+ 'New test1-foo'
56
+ );
57
+ });
58
+
41
59
  it('renders value in inactive mode', () => {
42
60
  createComponent({ value: { data: 'test-value' } });
43
61
  expect(wrapper.html()).toMatchSnapshot();
@@ -167,7 +167,7 @@ export default {
167
167
  :value="item.type"
168
168
  :icon-name="item.icon"
169
169
  >
170
- {{ item.title }}
170
+ <slot name="title" v-bind="{ value: item.title }"> {{ item.title }} </slot>
171
171
  </gl-filtered-search-suggestion>
172
172
  </template>
173
173
 
@@ -10,15 +10,14 @@ This component is not intended to be used outside of the `GlFilteredSearch` comp
10
10
  Make sure to pass `$listeners` to `gl-filtered-search-token`, or route events properly:
11
11
 
12
12
  ```html
13
- <gl-filtered-search-token
14
- title="Confidential"
15
- :active="active"
16
- :value="value"
17
- v-on="$listeners"
18
- >
13
+ <gl-filtered-search-token title="Confidential" :active="active" :value="value" v-on="$listeners">
19
14
  <template #suggestions>
20
- <gl-filtered-search-suggestion value="Yes"><gl-icon name="eye-slash" :size="16"/> Yes</gl-filtered-search-suggestion>
21
- <gl-filtered-search-suggestion value="No"><gl-icon name="eye" :size="16"/> No</gl-filtered-search-suggestion>
15
+ <gl-filtered-search-suggestion value="Yes"
16
+ ><gl-icon name="eye-slash" :size="16" /> Yes</gl-filtered-search-suggestion
17
+ >
18
+ <gl-filtered-search-suggestion value="No"
19
+ ><gl-icon name="eye" :size="16" /> No</gl-filtered-search-suggestion
20
+ >
22
21
  </template>
23
22
  </gl-filtered-search-token>
24
23
  ```
package/src/index.js CHANGED
@@ -52,10 +52,7 @@ export { default as GlDropdownDivider } from './components/base/dropdown/dropdow
52
52
  export { default as GlDropdownText } from './components/base/dropdown/dropdown_text.vue';
53
53
  export { default as GlDropdown } from './components/base/dropdown/dropdown.vue';
54
54
  // new components aiming to replace GlDropdown - start
55
- export {
56
- default as GlListbox,
57
- default as GlCollapsibleListbox,
58
- } from './components/base/new_dropdowns/listbox/listbox.vue';
55
+ export { default as GlCollapsibleListbox } from './components/base/new_dropdowns/listbox/listbox.vue';
59
56
  export { default as GlListboxItem } from './components/base/new_dropdowns/listbox/listbox_item.vue';
60
57
  export { default as GlDisclosureDropdown } from './components/base/new_dropdowns/disclosure/disclosure_dropdown.vue';
61
58
  export { default as GlDisclosureDropdownItem } from './components/base/new_dropdowns/disclosure/disclosure_dropdown_item.vue';