@gitlab/ui 37.4.2 → 37.5.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 +26 -0
- package/dist/components/base/accordion/accordion_item.js +14 -1
- package/dist/components/base/datepicker/datepicker.documentation.js +2 -47
- package/dist/components/base/datepicker/datepicker.js +37 -1
- package/dist/components/base/dropdown/dropdown.js +2 -2
- 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/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/documentation/documented_stories.js +1 -0
- package/package.json +2 -2
- package/src/components/base/accordion/accordion_item.spec.js +12 -0
- package/src/components/base/accordion/accordion_item.stories.js +4 -2
- package/src/components/base/accordion/accordion_item.vue +12 -1
- package/src/components/base/datepicker/datepicker.documentation.js +0 -59
- package/src/components/base/datepicker/datepicker.md +0 -6
- package/src/components/base/datepicker/datepicker.stories.js +97 -71
- package/src/components/base/datepicker/datepicker.vue +36 -1
- package/src/components/base/dropdown/dropdown.spec.js +29 -0
- package/src/components/base/dropdown/dropdown.stories.js +4 -1
- package/src/components/base/dropdown/dropdown.vue +5 -3
- package/src/components/base/dropdown/dropdown_section_header.scss +1 -0
- 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/dist/components/base/datepicker/examples/datepicker.basic.example.js +0 -48
- package/dist/components/base/datepicker/examples/datepicker.custom_input.example.js +0 -48
- package/dist/components/base/datepicker/examples/datepicker.disabled.example.js +0 -48
- package/dist/components/base/datepicker/examples/datepicker.open_on_focus.example.js +0 -48
- package/dist/components/base/datepicker/examples/datepicker.with_clear_button.example.js +0 -48
- package/dist/components/base/datepicker/examples/index.js +0 -32
- package/src/components/base/datepicker/examples/datepicker.basic.example.vue +0 -12
- package/src/components/base/datepicker/examples/datepicker.custom_input.example.vue +0 -21
- package/src/components/base/datepicker/examples/datepicker.disabled.example.vue +0 -12
- package/src/components/base/datepicker/examples/datepicker.open_on_focus.example.vue +0 -12
- package/src/components/base/datepicker/examples/datepicker.with_clear_button.example.vue +0 -12
- package/src/components/base/datepicker/examples/index.js +0 -38
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## [37.5.2](https://gitlab.com/gitlab-org/gitlab-ui/compare/v37.5.1...v37.5.2) (2022-03-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **GlFilteredSearch:** Token activation after destruction ([40b0513](https://gitlab.com/gitlab-org/gitlab-ui/commit/40b051307065ff29fea53ad65457d6b99f116c92))
|
|
7
|
+
|
|
8
|
+
## [37.5.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v37.5.0...v37.5.1) (2022-03-10)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **GlDropdown:** spinner replaces icon when icon dropdown is loading ([027a8a7](https://gitlab.com/gitlab-org/gitlab-ui/commit/027a8a7011c336b7c2562e4e839d4d8b4f7a4fe9))
|
|
14
|
+
|
|
15
|
+
# [37.5.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v37.4.2...v37.5.0) (2022-03-10)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **GlDropdown:** Wrap text in dropdown section header ([1408742](https://gitlab.com/gitlab-org/gitlab-ui/commit/140874226a351da03522b7b45ef4428443162a79))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* **GlAccordionItem:** Add titleVisible property ([f8626aa](https://gitlab.com/gitlab-org/gitlab-ui/commit/f8626aa2a343d4159efddf6aacbdbaad6593eb27))
|
|
26
|
+
|
|
1
27
|
## [37.4.2](https://gitlab.com/gitlab-org/gitlab-ui/compare/v37.4.1...v37.4.2) (2022-03-09)
|
|
2
28
|
|
|
3
29
|
|
|
@@ -24,6 +24,15 @@ var script = {
|
|
|
24
24
|
required: true
|
|
25
25
|
},
|
|
26
26
|
|
|
27
|
+
/*
|
|
28
|
+
Used to set the title of accordion link when the content is visible
|
|
29
|
+
*/
|
|
30
|
+
titleVisible: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: null,
|
|
33
|
+
required: false
|
|
34
|
+
},
|
|
35
|
+
|
|
27
36
|
/*
|
|
28
37
|
When set, it will ensure the accordion item is initially visible
|
|
29
38
|
*/
|
|
@@ -67,6 +76,10 @@ var script = {
|
|
|
67
76
|
|
|
68
77
|
icon() {
|
|
69
78
|
return this.isVisible ? 'chevron-down' : 'chevron-right';
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
buttonTitle() {
|
|
82
|
+
return this.isVisible && this.titleVisible ? this.titleVisible : this.title;
|
|
70
83
|
}
|
|
71
84
|
|
|
72
85
|
}
|
|
@@ -76,7 +89,7 @@ var script = {
|
|
|
76
89
|
const __vue_script__ = script;
|
|
77
90
|
|
|
78
91
|
/* template */
|
|
79
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-accordion-item"},[_c(_vm.headerComponent,{tag:"component",staticClass:"gl-accordion-item-header"},[_c('gl-button',{directives:[{name:"gl-collapse-toggle",rawName:"v-gl-collapse-toggle",value:(_vm.accordionItemId),expression:"accordionItemId"}],attrs:{"variant":"link","button-text-classes":"gl-display-flex","icon":_vm.icon}},[_vm._v("\n "+_vm._s(_vm.
|
|
92
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-accordion-item"},[_c(_vm.headerComponent,{tag:"component",staticClass:"gl-accordion-item-header"},[_c('gl-button',{directives:[{name:"gl-collapse-toggle",rawName:"v-gl-collapse-toggle",value:(_vm.accordionItemId),expression:"accordionItemId"}],attrs:{"variant":"link","button-text-classes":"gl-display-flex","icon":_vm.icon}},[_vm._v("\n "+_vm._s(_vm.buttonTitle)+"\n ")])],1),_vm._v(" "),_c('b-collapse',{staticClass:"gl-mt-3 gl-font-base",attrs:{"id":_vm.accordionItemId,"visible":_vm.isVisible,"accordion":_vm.accordion,"data-testid":("accordion-item-collapse-" + _vm.accordionItemId)},model:{value:(_vm.isVisible),callback:function ($$v) {_vm.isVisible=$$v;},expression:"isVisible"}},[_vm._t("default")],2)],1)};
|
|
80
93
|
var __vue_staticRenderFns__ = [];
|
|
81
94
|
|
|
82
95
|
/* style */
|
|
@@ -1,52 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var description = "# Datepicker\n\n<!-- STORY -->\n\n## Usage\n\nDate picker allows users to choose and input a date by manually typing the date into the input field\nor by using a calendar-like dropdown.\n\n### Warning\n\nBe careful when binding a date value using `value` prop. `value` is a watched property and Date\npicker will emit `input` event on _initial load_. Alternatively, use `defaultDate` to set the\ninitial date then receive updated date values through `input` events.\n";
|
|
1
|
+
var description = "Date picker allows users to choose and input a date by manually typing the date into the input field\nor by using a calendar-like dropdown.\n\n### Warning\n\nBe careful when binding a date value using `value` prop. `value` is a watched property and Date\npicker will emit `input` event on _initial load_. Alternatively, use `defaultDate` to set the\ninitial date then receive updated date values through `input` events.\n";
|
|
4
2
|
|
|
5
3
|
var datepicker_documentation = {
|
|
6
|
-
description
|
|
7
|
-
examples,
|
|
8
|
-
propsInfo: {
|
|
9
|
-
target: {
|
|
10
|
-
additionalInfo: 'Selector of element that triggers the datepicker. Defaults to the calendar icon. Pass `null` to trigger on input focus.'
|
|
11
|
-
},
|
|
12
|
-
container: {
|
|
13
|
-
additionalInfo: 'DOM node to render calendar into. Defaults to the datepicker container. Pass `null` to use Pikaday default.'
|
|
14
|
-
},
|
|
15
|
-
disableDayFn: {
|
|
16
|
-
additionalInfo: 'Accepts a function that accepts a date as argument and returns true if the date is disabled.'
|
|
17
|
-
},
|
|
18
|
-
autocomplete: {
|
|
19
|
-
additionalInfo: 'Defaults to `off` when datepicker opens on focus, otherwise defaults to `null`.'
|
|
20
|
-
},
|
|
21
|
-
defaultDate: {
|
|
22
|
-
additionalInfo: 'Use this prop to set the initial date for the datepicker.'
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
events: [{
|
|
26
|
-
event: 'input',
|
|
27
|
-
description: 'Emitted when a new date has been selected.',
|
|
28
|
-
args: [{
|
|
29
|
-
arg: 'date',
|
|
30
|
-
description: 'The selected date'
|
|
31
|
-
}]
|
|
32
|
-
}, {
|
|
33
|
-
event: 'close',
|
|
34
|
-
description: 'Emitted when the datepicker is hidden.'
|
|
35
|
-
}, {
|
|
36
|
-
event: 'open',
|
|
37
|
-
description: 'Emitted when the datepicker becomes visible.'
|
|
38
|
-
}, {
|
|
39
|
-
event: 'draw',
|
|
40
|
-
description: 'Emitted when the datepicker draws a new month.'
|
|
41
|
-
}, {
|
|
42
|
-
event: 'clear',
|
|
43
|
-
description: 'Emitted when the clear button is clicked.'
|
|
44
|
-
}],
|
|
45
|
-
slots: [{
|
|
46
|
-
name: 'default',
|
|
47
|
-
description: '(optional) Input to display and bind the datepicker to. Defaults to `<gl-form-input />`',
|
|
48
|
-
scopedProps: `{ formattedDate: string }`
|
|
49
|
-
}]
|
|
4
|
+
description
|
|
50
5
|
};
|
|
51
6
|
|
|
52
7
|
export default datepicker_documentation;
|
|
@@ -50,11 +50,18 @@ var script = {
|
|
|
50
50
|
GlButton
|
|
51
51
|
},
|
|
52
52
|
props: {
|
|
53
|
+
/**
|
|
54
|
+
* Selector of element that triggers the datepicker. Defaults to the calendar icon. Pass `null` to trigger on input focus.
|
|
55
|
+
*/
|
|
53
56
|
target: {
|
|
54
57
|
type: String,
|
|
55
58
|
required: false,
|
|
56
59
|
default: ''
|
|
57
60
|
},
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* DOM node to render calendar into. Defaults to the datepicker container. Pass `null` to use Pikaday default.
|
|
64
|
+
*/
|
|
58
65
|
container: {
|
|
59
66
|
type: String,
|
|
60
67
|
required: false,
|
|
@@ -85,6 +92,10 @@ var script = {
|
|
|
85
92
|
required: false,
|
|
86
93
|
default: null
|
|
87
94
|
},
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Accepts a function that accepts a date as argument and returns true if the date is disabled.
|
|
98
|
+
*/
|
|
88
99
|
disableDayFn: {
|
|
89
100
|
type: Function,
|
|
90
101
|
required: false,
|
|
@@ -105,6 +116,10 @@ var script = {
|
|
|
105
116
|
required: false,
|
|
106
117
|
default: defaultDateFormat
|
|
107
118
|
},
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Defaults to `off` when datepicker opens on focus, otherwise defaults to `null`.
|
|
122
|
+
*/
|
|
108
123
|
autocomplete: {
|
|
109
124
|
type: String,
|
|
110
125
|
required: false,
|
|
@@ -125,6 +140,10 @@ var script = {
|
|
|
125
140
|
required: false,
|
|
126
141
|
default: false
|
|
127
142
|
},
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Use this prop to set the initial date for the datepicker.
|
|
146
|
+
*/
|
|
128
147
|
defaultDate: {
|
|
129
148
|
type: Date,
|
|
130
149
|
required: false,
|
|
@@ -289,23 +308,40 @@ var script = {
|
|
|
289
308
|
|
|
290
309
|
methods: {
|
|
291
310
|
selected(date) {
|
|
311
|
+
/**
|
|
312
|
+
* Emitted when a new date has been selected.
|
|
313
|
+
* @property {Date} date The selected date
|
|
314
|
+
*/
|
|
292
315
|
this.$emit('input', date);
|
|
293
316
|
},
|
|
294
317
|
|
|
295
318
|
closed() {
|
|
319
|
+
/**
|
|
320
|
+
* Emitted when the datepicker is hidden.
|
|
321
|
+
*/
|
|
296
322
|
this.$emit('close');
|
|
297
323
|
},
|
|
298
324
|
|
|
299
325
|
opened() {
|
|
326
|
+
/**
|
|
327
|
+
* Emitted when the datepicker becomes visible.
|
|
328
|
+
*/
|
|
300
329
|
this.$emit('open');
|
|
301
330
|
},
|
|
302
331
|
|
|
303
332
|
cleared() {
|
|
304
333
|
this.textInput = '';
|
|
334
|
+
/**
|
|
335
|
+
* Emitted when the clear button is clicked.
|
|
336
|
+
*/
|
|
337
|
+
|
|
305
338
|
this.$emit('clear');
|
|
306
339
|
},
|
|
307
340
|
|
|
308
341
|
draw() {
|
|
342
|
+
/**
|
|
343
|
+
* Emitted when the datepicker draws a new month.
|
|
344
|
+
*/
|
|
309
345
|
this.$emit('monthChange');
|
|
310
346
|
},
|
|
311
347
|
|
|
@@ -324,7 +360,7 @@ var script = {
|
|
|
324
360
|
const __vue_script__ = script;
|
|
325
361
|
|
|
326
362
|
/* template */
|
|
327
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-datepicker d-inline-block"},[(_vm.showDefaultField)?_c('div',{staticClass:"
|
|
363
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-datepicker d-inline-block"},[(_vm.showDefaultField)?_c('div',{staticClass:"gl-relative"},[_vm._t("default",[_c('gl-form-input',{staticClass:"gl-datepicker-input",class:_vm.renderClearButton ? 'gl-pr-9!' : 'gl-pr-7!',attrs:{"id":_vm.inputId,"name":_vm.inputName,"data-testid":"gl-datepicker-input","value":_vm.formattedDate,"placeholder":_vm.placeholder,"autocomplete":_vm.inputAutocomplete,"disabled":_vm.disabled,"aria-label":_vm.inputLabel},on:{"keydown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }return _vm.onKeydown($event)}},model:{value:(_vm.textInput),callback:function ($$v) {_vm.textInput=$$v;},expression:"textInput"}})],{"formattedDate":_vm.formattedDate}),_vm._v(" "),_c('div',{staticClass:"gl-datepicker-actions"},[(_vm.renderClearButton)?_c('gl-button',{staticClass:"gl-pointer-events-auto",attrs:{"data-testid":"clear-button","aria-label":"Clear date","category":"tertiary","size":"small","icon":"clear"},on:{"click":_vm.cleared}}):_vm._e(),_vm._v(" "),(_vm.triggerOnFocus || _vm.disabled)?_c('span',{staticClass:"gl-px-2",class:_vm.disabled ? 'gl-text-gray-400' : 'gl-text-gray-500',attrs:{"data-testid":"datepicker-calendar-icon"}},[_c('gl-icon',{staticClass:"gl-display-block",attrs:{"name":"calendar","size":16}})],1):_c('gl-button',{ref:"calendarTriggerBtn",staticClass:"gl-pointer-events-auto",attrs:{"aria-label":"Open datepicker","category":"tertiary","size":"small","icon":"calendar"}})],1)],2):_vm._t("default",null,{"formattedDate":_vm.formattedDate})],2)};
|
|
328
364
|
var __vue_staticRenderFns__ = [];
|
|
329
365
|
|
|
330
366
|
/* style */
|
|
@@ -147,7 +147,7 @@ var script = {
|
|
|
147
147
|
isIconOnly() {
|
|
148
148
|
var _this$text;
|
|
149
149
|
|
|
150
|
-
return Boolean(this.icon && (!((_this$text = this.text) !== null && _this$text !== void 0 && _this$text.length) || this.textSrOnly));
|
|
150
|
+
return Boolean(this.icon && (!((_this$text = this.text) !== null && _this$text !== void 0 && _this$text.length) || this.textSrOnly) && !this.hasSlotContents('button-text'));
|
|
151
151
|
},
|
|
152
152
|
|
|
153
153
|
isIconWithText() {
|
|
@@ -209,7 +209,7 @@ var script = {
|
|
|
209
209
|
const __vue_script__ = script;
|
|
210
210
|
|
|
211
211
|
/* template */
|
|
212
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-dropdown',_vm._g(_vm._b({ref:"dropdown",staticClass:"gl-new-dropdown",attrs:{"split":_vm.split,"variant":_vm.variant,"size":_vm.buttonSize,"toggle-class":[_vm.toggleButtonClasses],"split-class":_vm.splitButtonClasses,"block":_vm.block,"disabled":_vm.disabled || _vm.loading,"right":_vm.right},scopedSlots:_vm._u([{key:"button-content",fn:function(){return [_vm._t("button-content",[(_vm.loading)?_c('gl-loading-icon',{
|
|
212
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-dropdown',_vm._g(_vm._b({ref:"dropdown",staticClass:"gl-new-dropdown",attrs:{"split":_vm.split,"variant":_vm.variant,"size":_vm.buttonSize,"toggle-class":[_vm.toggleButtonClasses],"split-class":_vm.splitButtonClasses,"block":_vm.block,"disabled":_vm.disabled || _vm.loading,"right":_vm.right},scopedSlots:_vm._u([{key:"button-content",fn:function(){return [_vm._t("button-content",[(_vm.loading)?_c('gl-loading-icon',{class:{ 'gl-mr-2': !_vm.isIconOnly }}):_vm._e(),_vm._v(" "),(_vm.icon && !(_vm.isIconOnly && _vm.loading))?_c('gl-icon',{staticClass:"dropdown-icon",attrs:{"name":_vm.icon}}):_vm._e(),_vm._v(" "),_c('span',{staticClass:"gl-new-dropdown-button-text",class:{ 'gl-sr-only': _vm.textSrOnly }},[_vm._t("button-text",[_vm._v(_vm._s(_vm.buttonText))])],2),_vm._v(" "),(_vm.renderCaret)?_c('gl-icon',{staticClass:"gl-button-icon dropdown-chevron",attrs:{"name":"chevron-down"}}):_vm._e()])]},proxy:true}],null,true)},'b-dropdown',_vm.$attrs,false),_vm.$listeners),[_c('div',{staticClass:"gl-new-dropdown-inner"},[(_vm.hasSlotContents('header') || _vm.headerText)?_c('div',{staticClass:"gl-new-dropdown-header",class:{ 'gl-border-b-0!': _vm.hideHeaderBorder }},[(_vm.headerText)?_c('p',{staticClass:"gl-new-dropdown-header-top"},[_vm._v("\n "+_vm._s(_vm.headerText)+"\n ")]):_vm._e(),_vm._v(" "),_vm._t("header")],2):_vm._e(),_vm._v(" "),(_vm.hasHighlightedItemsOrClearAll)?_c('div',{staticClass:"gl-display-flex gl-flex-direction-row gl-justify-content-space-between gl-align-items-center"},[(_vm.hasHighlightedItemsContent && _vm.showHighlightedItemsTitle)?_c('div',{staticClass:"gl-display-flex gl-flex-grow-1 gl-justify-content-flex-start",class:_vm.highlightedItemsTitleClass},[_c('span',{staticClass:"gl-font-weight-bold",attrs:{"data-testid":"highlighted-items-title"}},[_vm._v(_vm._s(_vm.highlightedItemsTitle))])]):_vm._e(),_vm._v(" "),(_vm.showClearAll)?_c('div',{staticClass:"gl-display-flex gl-flex-grow-1 gl-justify-content-end",class:_vm.clearAllTextClass},[_c('gl-button',{attrs:{"size":"small","category":"tertiary","variant":"link","data-testid":"clear-all-button"},on:{"click":function($event){return _vm.$emit('clear-all', $event)}}},[_vm._v(_vm._s(_vm.clearAllText))])],1):_vm._e()]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-new-dropdown-contents"},[(_vm.hasHighlightedItemsContent)?_c('div',{staticClass:"gl-overflow-visible",attrs:{"data-testid":"highlighted-items"}},[_vm._t("highlighted-items"),_vm._v(" "),_c('gl-dropdown-divider')],2):_vm._e(),_vm._v(" "),_vm._t("default")],2),_vm._v(" "),(_vm.hasSlotContents('footer'))?_c('div',{staticClass:"gl-new-dropdown-footer"},[_vm._t("footer")],2):_vm._e()])])};
|
|
213
213
|
var __vue_staticRenderFns__ = [];
|
|
214
214
|
|
|
215
215
|
/* style */
|
|
@@ -5,7 +5,7 @@ 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 { TERM_TOKEN_TYPE, needDenormalization, denormalizeTokens, isEmptyTerm, normalizeTokens } from './filtered_search_utils';
|
|
8
|
+
import { TERM_TOKEN_TYPE, needDenormalization, denormalizeTokens, isEmptyTerm, INTENT_ACTIVATE_PREVIOUS, 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);
|
|
@@ -184,8 +184,8 @@ var script = {
|
|
|
184
184
|
return ((_this$getTokenEntry = this.getTokenEntry(type)) === null || _this$getTokenEntry === void 0 ? void 0 : _this$getTokenEntry.token) || GlFilteredSearchTerm;
|
|
185
185
|
},
|
|
186
186
|
|
|
187
|
-
activate(
|
|
188
|
-
this.activeTokenIdx =
|
|
187
|
+
activate(idx) {
|
|
188
|
+
this.activeTokenIdx = idx;
|
|
189
189
|
},
|
|
190
190
|
|
|
191
191
|
alignSuggestions(ref) {
|
|
@@ -216,15 +216,31 @@ var script = {
|
|
|
216
216
|
},
|
|
217
217
|
|
|
218
218
|
destroyToken(idx) {
|
|
219
|
+
let {
|
|
220
|
+
intent
|
|
221
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
222
|
+
|
|
219
223
|
if (this.tokens.length === 1) {
|
|
220
224
|
return;
|
|
221
225
|
}
|
|
222
226
|
|
|
223
|
-
this.tokens.splice(idx, 1);
|
|
227
|
+
this.tokens.splice(idx, 1); // First, attempt to honor the user's activation intent behind the
|
|
228
|
+
// destruction of the token, if any. Otherwise, try to maintain the
|
|
229
|
+
// active state for the token that was active at the time. If that's not
|
|
230
|
+
// possible, make sure no token is active.
|
|
231
|
+
|
|
232
|
+
if (intent === INTENT_ACTIVATE_PREVIOUS) {
|
|
233
|
+
// If there is a previous token, activate it; else, deactivate all tokens
|
|
234
|
+
this.activeTokenIdx = idx > 0 ? idx - 1 : null;
|
|
235
|
+
} else if (idx < this.activeTokenIdx) {
|
|
236
|
+
// Preserve the active token's active status (it shifted down one index)
|
|
237
|
+
this.activeTokenIdx -= 1;
|
|
238
|
+
} else if (idx === this.activeTokenIdx) {
|
|
239
|
+
// User destroyed the active token; don't activate another one.
|
|
240
|
+
this.activeTokenIdx = null;
|
|
241
|
+
} // Do nothing if there was no active token, or if idx > this.activeTokenIdx,
|
|
242
|
+
// to preserve the active state of the remaining tokens.
|
|
224
243
|
|
|
225
|
-
if (idx !== 0) {
|
|
226
|
-
this.activeTokenIdx = idx - 1;
|
|
227
|
-
}
|
|
228
244
|
},
|
|
229
245
|
|
|
230
246
|
replaceToken(idx, token) {
|
|
@@ -281,7 +297,7 @@ const __vue_script__ = script;
|
|
|
281
297
|
/* template */
|
|
282
298
|
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.type) + "-" + idx),ref:"tokens",refInFor:true,tag:"component",staticClass:"gl-filtered-search-item",class:{
|
|
283
299
|
'gl-filtered-search-last-item': _vm.isLastToken(idx),
|
|
284
|
-
},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)},"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))};
|
|
300
|
+
},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))};
|
|
285
301
|
var __vue_staticRenderFns__ = [];
|
|
286
302
|
|
|
287
303
|
/* style */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import GlFilteredSearchSuggestion from './filtered_search_suggestion';
|
|
2
2
|
import GlFilteredSearchTokenSegment from './filtered_search_token_segment';
|
|
3
|
+
import { INTENT_ACTIVATE_PREVIOUS } from './filtered_search_utils';
|
|
3
4
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
4
5
|
|
|
5
6
|
var script = {
|
|
@@ -63,6 +64,14 @@ var script = {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
}
|
|
67
|
+
},
|
|
68
|
+
methods: {
|
|
69
|
+
onBackspace() {
|
|
70
|
+
this.$emit('destroy', {
|
|
71
|
+
intent: INTENT_ACTIVATE_PREVIOUS
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
66
75
|
}
|
|
67
76
|
};
|
|
68
77
|
|
|
@@ -70,7 +79,7 @@ var script = {
|
|
|
70
79
|
const __vue_script__ = script;
|
|
71
80
|
|
|
72
81
|
/* template */
|
|
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":
|
|
82
|
+
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":_vm.onBackspace,"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)};
|
|
74
83
|
var __vue_staticRenderFns__ = [];
|
|
75
84
|
|
|
76
85
|
/* style */
|
|
@@ -3,6 +3,7 @@ import _last from 'lodash/last';
|
|
|
3
3
|
import _first from 'lodash/first';
|
|
4
4
|
|
|
5
5
|
const TERM_TOKEN_TYPE = 'filtered-search-term';
|
|
6
|
+
const INTENT_ACTIVATE_PREVIOUS = 'intent-activate-previous';
|
|
6
7
|
function isEmptyTerm(token) {
|
|
7
8
|
return token.type === TERM_TOKEN_TYPE && token.value.data.trim() === '';
|
|
8
9
|
}
|
|
@@ -134,4 +135,4 @@ function wrapTokenInQuotes(token) {
|
|
|
134
135
|
return `"${token}"`;
|
|
135
136
|
}
|
|
136
137
|
|
|
137
|
-
export { TERM_TOKEN_TYPE, denormalizeTokens, isEmptyTerm, needDenormalization, normalizeTokens, splitOnQuotes, wrapTokenInQuotes };
|
|
138
|
+
export { INTENT_ACTIVATE_PREVIOUS, TERM_TOKEN_TYPE, denormalizeTokens, isEmptyTerm, needDenormalization, normalizeTokens, splitOnQuotes, wrapTokenInQuotes };
|