@gitlab/ui 32.41.0 → 32.43.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 +28 -0
- package/dist/components/base/form/form_group/examples/form_group/form_group.validation.example.js +3 -3
- package/dist/components/base/token_selector/token_selector.documentation.js +2 -106
- package/dist/components/base/token_selector/token_selector.js +85 -1
- package/dist/components/base/tooltip/tooltip.documentation.js +2 -6
- package/dist/components/charts/area/area.js +1 -1
- package/dist/components/charts/discrete_scatter/discrete_scatter.js +1 -1
- package/dist/components/charts/line/line.js +1 -1
- package/dist/components/regions/empty_state/empty_state.js +1 -1
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/documentation/documented_stories.js +2 -0
- package/package.json +13 -13
- package/src/components/base/accordion/accordion.spec.js +0 -4
- package/src/components/base/accordion/accordion_item.spec.js +0 -4
- package/src/components/base/alert/alert.spec.js +0 -4
- package/src/components/base/avatar_labeled/avatar_labeled.spec.js +0 -2
- package/src/components/base/avatars_inline/avatars_inline.spec.js +0 -2
- package/src/components/base/badge/badge.spec.js +0 -2
- package/src/components/base/broadcast_message/broadcast_message.spec.js +0 -4
- package/src/components/base/button/button.spec.js +0 -5
- package/src/components/base/card/card.spec.js +0 -5
- package/src/components/base/carousel/carousel.spec.js +0 -4
- package/src/components/base/collapse/collapse.spec.js +0 -4
- package/src/components/base/datepicker/datepicker.spec.js +0 -4
- package/src/components/base/daterange_picker/daterange_picker.spec.js +0 -5
- package/src/components/base/drawer/drawer.spec.js +0 -4
- package/src/components/base/dropdown/dropdown.spec.js +0 -2
- package/src/components/base/dropdown/dropdown_item.spec.js +0 -2
- package/src/components/base/filtered_search/filtered_search.spec.js +0 -10
- package/src/components/base/filtered_search/filtered_search_suggestion.spec.js +0 -5
- package/src/components/base/filtered_search/filtered_search_suggestion_list.spec.js +0 -5
- package/src/components/base/filtered_search/filtered_search_term.spec.js +0 -5
- package/src/components/base/filtered_search/filtered_search_token.spec.js +0 -5
- package/src/components/base/form/form_checkbox_tree/form_checkbox_tree.spec.js +0 -5
- package/src/components/base/form/form_combobox/form_combobox.spec.js +0 -4
- package/src/components/base/form/form_group/examples/form_group/form_group.validation.example.vue +3 -3
- package/src/components/base/form/form_group/form_group.stories.js +3 -3
- package/src/components/base/form/form_input/form_input.spec.js +0 -5
- package/src/components/base/form/form_input_group/form_input_group.spec.js +0 -4
- package/src/components/base/form/form_radio/form_radio.spec.js +0 -4
- package/src/components/base/form/form_radio_group/form_radio_group.spec.js +0 -4
- package/src/components/base/form/form_select/form_select.spec.js +0 -5
- package/src/components/base/form/form_textarea/form_textarea.spec.js +0 -5
- package/src/components/base/icon/icon.spec.js +0 -2
- package/src/components/base/infinite_scroll/infinite_scroll.spec.js +0 -1
- package/src/components/base/keyset_pagination/keyset_pagination.spec.js +0 -5
- package/src/components/base/label/label.spec.js +0 -4
- package/src/components/base/link/link.spec.js +0 -5
- package/src/components/base/loading_icon/loading_icon.spec.js +0 -4
- package/src/components/base/modal/modal.spec.js +0 -1
- package/src/components/base/nav/nav.spec.js +0 -4
- package/src/components/base/nav/nav_item.spec.js +0 -4
- package/src/components/base/nav/nav_item_dropdown.spec.js +0 -4
- package/src/components/base/paginated_list/paginated_list.spec.js +0 -6
- package/src/components/base/pagination/pagination.spec.js +0 -1
- package/src/components/base/path/path.spec.js +0 -5
- package/src/components/base/popover/popover.spec.js +0 -5
- package/src/components/base/search_box_by_click/search_box_by_click.spec.js +0 -4
- package/src/components/base/search_box_by_type/search_box_by_type.spec.js +0 -5
- package/src/components/base/segmented_control/segmented_control.spec.js +0 -4
- package/src/components/base/skeleton_loader/skeleton_loader.spec.js +0 -5
- package/src/components/base/sorting/sorting.spec.js +0 -4
- package/src/components/base/sorting/sorting_item.spec.js +0 -4
- package/src/components/base/tabs/tabs/scrollable_tabs.spec.js +0 -5
- package/src/components/base/toggle/toggle.spec.js +0 -4
- package/src/components/base/token/token.spec.js +0 -4
- package/src/components/base/token_selector/token_container.spec.js +0 -2
- package/src/components/base/token_selector/token_selector.documentation.js +0 -137
- package/src/components/base/token_selector/token_selector.md +0 -6
- package/src/components/base/token_selector/token_selector.spec.js +0 -5
- package/src/components/base/token_selector/token_selector.stories.js +96 -113
- package/src/components/base/token_selector/token_selector.vue +89 -1
- package/src/components/base/token_selector/token_selector_dropdown.spec.js +0 -5
- package/src/components/base/tooltip/tooltip.documentation.js +0 -3
- package/src/components/base/tooltip/tooltip.md +3 -5
- package/src/components/base/tooltip/tooltip.spec.js +0 -5
- package/src/components/base/tooltip/tooltip.stories.js +49 -25
- package/src/components/base/tooltip/tooltip.vue +1 -0
- package/src/components/charts/area/area.spec.js +8 -24
- package/src/components/charts/area/area.vue +9 -12
- package/src/components/charts/bar/bar.spec.js +4 -11
- package/src/components/charts/chart/chart.spec.js +0 -4
- package/src/components/charts/column/column_chart.spec.js +0 -4
- package/src/components/charts/discrete_scatter/discrete_scatter.stories.js +1 -0
- package/src/components/charts/discrete_scatter/discrete_scatter.vue +5 -8
- package/src/components/charts/gauge/gauge.spec.js +2 -24
- package/src/components/charts/heatmap/heatmap.spec.js +6 -23
- package/src/components/charts/legend/legend.spec.js +8 -14
- package/src/components/charts/line/line.spec.js +19 -30
- package/src/components/charts/line/line.vue +3 -2
- package/src/components/charts/single_stat/single_stat.spec.js +0 -4
- package/src/components/charts/sparkline/sparkline.spec.js +9 -15
- package/src/components/charts/stacked_column/stacked_column.spec.js +0 -1
- package/src/components/regions/empty_state/empty_state.vue +8 -2
- package/src/components/shared_components/clear_icon_button/clear_icon_button.spec.js +0 -4
- package/src/components/shared_components/close_button/close_button.spec.js +0 -4
- package/src/components/utilities/friendly_wrap/friendly_wrap.spec.js +0 -4
- package/src/components/utilities/intersection_observer/intersection_observer.spec.js +1 -1
- package/src/components/utilities/sprintf/sprintf.spec.js +0 -4
- package/src/components/utilities/truncate/truncate.spec.js +10 -15
- package/src/directives/hover_load/hover_load.spec.js +0 -1
- package/src/directives/outside/outside.spec.js +0 -4
- package/src/directives/resize_observer/resize_observer.spec.js +0 -4
- package/src/directives/safe_html/safe_html.spec.js +0 -4
- package/src/directives/safe_link/safe_link.spec.js +0 -5
- package/src/scss/utilities.scss +26 -0
- package/src/scss/utility-mixins/sizing.scss +6 -0
- package/src/scss/utility-mixins/spacing.scss +4 -0
- package/src/scss/utility-mixins/z-index.scss +4 -0
- package/dist/components/base/token_selector/examples/index.js +0 -19
- package/dist/components/base/token_selector/examples/token_selector.user_defined_tokens.example.js +0 -48
- package/dist/components/base/token_selector/examples/token_selector.users.example.js +0 -202
- package/dist/components/base/tooltip/examples/index.js +0 -31
- package/dist/components/base/tooltip/examples/tooltip.directive_bottom.example.js +0 -38
- package/dist/components/base/tooltip/examples/tooltip.directive_default.example.js +0 -38
- package/dist/components/base/tooltip/examples/tooltip.directive_left.example.js +0 -38
- package/dist/components/base/tooltip/examples/tooltip.directive_right.example.js +0 -38
- package/src/components/base/token_selector/examples/index.js +0 -22
- package/src/components/base/token_selector/examples/token_selector.user_defined_tokens.example.vue +0 -17
- package/src/components/base/token_selector/examples/token_selector.users.example.vue +0 -212
- package/src/components/base/tooltip/examples/index.js +0 -36
- package/src/components/base/tooltip/examples/tooltip.directive_bottom.example.vue +0 -7
- package/src/components/base/tooltip/examples/tooltip.directive_default.example.vue +0 -5
- package/src/components/base/tooltip/examples/tooltip.directive_left.example.vue +0 -7
- package/src/components/base/tooltip/examples/tooltip.directive_right.example.vue +0 -7
|
@@ -14,6 +14,9 @@ export default {
|
|
|
14
14
|
event: 'input',
|
|
15
15
|
},
|
|
16
16
|
props: {
|
|
17
|
+
/**
|
|
18
|
+
* Items to display in dropdown
|
|
19
|
+
*/
|
|
17
20
|
dropdownItems: {
|
|
18
21
|
type: Array,
|
|
19
22
|
// All items need to have an `id` key
|
|
@@ -21,57 +24,89 @@ export default {
|
|
|
21
24
|
required: false,
|
|
22
25
|
default: () => [],
|
|
23
26
|
},
|
|
27
|
+
/**
|
|
28
|
+
* Should users be allowed to add tokens that are not in `dropdown-items`
|
|
29
|
+
*/
|
|
24
30
|
allowUserDefinedTokens: {
|
|
25
31
|
type: Boolean,
|
|
26
32
|
required: false,
|
|
27
33
|
default: false,
|
|
28
34
|
},
|
|
35
|
+
/**
|
|
36
|
+
* Dropdown items are loading, can be used when requesting new dropdown items
|
|
37
|
+
*/
|
|
29
38
|
loading: {
|
|
30
39
|
type: Boolean,
|
|
31
40
|
required: false,
|
|
32
41
|
default: false,
|
|
33
42
|
},
|
|
43
|
+
/**
|
|
44
|
+
* Hide the dropdown if `dropdown-items` is empty. Will show `no-results-content` slot if this is `false`
|
|
45
|
+
*/
|
|
34
46
|
hideDropdownWithNoItems: {
|
|
35
47
|
type: Boolean,
|
|
36
48
|
required: false,
|
|
37
49
|
default: false,
|
|
38
50
|
},
|
|
51
|
+
/**
|
|
52
|
+
* CSS classes to add to the main token selector container (`.gl-token-selector`)
|
|
53
|
+
*/
|
|
39
54
|
containerClass: {
|
|
40
55
|
type: String,
|
|
41
56
|
required: false,
|
|
42
57
|
default: '',
|
|
43
58
|
},
|
|
59
|
+
/**
|
|
60
|
+
* CSS classes to add to dropdown menu `ul` element
|
|
61
|
+
*/
|
|
44
62
|
menuClass: {
|
|
45
63
|
type: [String, Array, Object],
|
|
46
64
|
required: false,
|
|
47
65
|
default: '',
|
|
48
66
|
},
|
|
67
|
+
/**
|
|
68
|
+
* The autocomplete attribute value for the underlying `input` element
|
|
69
|
+
*/
|
|
49
70
|
autocomplete: {
|
|
50
71
|
type: String,
|
|
51
72
|
required: false,
|
|
52
73
|
default: 'off',
|
|
53
74
|
},
|
|
75
|
+
/**
|
|
76
|
+
* The `aria-labelledby` attribute value for the underlying `input` element
|
|
77
|
+
*/
|
|
54
78
|
ariaLabelledby: {
|
|
55
79
|
type: String,
|
|
56
80
|
required: false,
|
|
57
81
|
default: null,
|
|
58
82
|
},
|
|
83
|
+
/**
|
|
84
|
+
* The `placeholder` attribute value for the underlying `input` element
|
|
85
|
+
*/
|
|
59
86
|
placeholder: {
|
|
60
87
|
type: String,
|
|
61
88
|
required: false,
|
|
62
89
|
default: null,
|
|
63
90
|
},
|
|
91
|
+
/**
|
|
92
|
+
* HTML attributes to add to the text input. Helpful for adding `data-testid` and `data-qa-selector` attributes
|
|
93
|
+
*/
|
|
64
94
|
textInputAttrs: {
|
|
65
95
|
type: Object,
|
|
66
96
|
required: false,
|
|
67
97
|
default: null,
|
|
68
98
|
},
|
|
99
|
+
/**
|
|
100
|
+
* Controls the validation state appearance of the component. `true` for valid, `false` for invalid, or `null` for no validation state
|
|
101
|
+
*/
|
|
69
102
|
state: {
|
|
70
103
|
type: Boolean,
|
|
71
104
|
required: false,
|
|
72
105
|
default: null,
|
|
73
106
|
},
|
|
74
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Tokens that are selected. This prop will automatically be added when using `v-model`
|
|
109
|
+
*/
|
|
75
110
|
selectedTokens: {
|
|
76
111
|
type: Array,
|
|
77
112
|
// All tokens need to have an `id` key
|
|
@@ -134,6 +169,11 @@ export default {
|
|
|
134
169
|
watch: {
|
|
135
170
|
inputText(newValue, oldValue) {
|
|
136
171
|
if (newValue !== oldValue) {
|
|
172
|
+
/**
|
|
173
|
+
* Fired when user types in the token selector
|
|
174
|
+
*
|
|
175
|
+
* @property {string} inputText
|
|
176
|
+
*/
|
|
137
177
|
this.$emit('text-input', newValue);
|
|
138
178
|
|
|
139
179
|
this.resetFocusedDropdownItem();
|
|
@@ -159,6 +199,11 @@ export default {
|
|
|
159
199
|
},
|
|
160
200
|
methods: {
|
|
161
201
|
handleFocus(event) {
|
|
202
|
+
/**
|
|
203
|
+
* Fired when the token selector is focused
|
|
204
|
+
*
|
|
205
|
+
* @property {FocusEvent} event
|
|
206
|
+
*/
|
|
162
207
|
this.$emit('focus', event);
|
|
163
208
|
|
|
164
209
|
this.openDropdown();
|
|
@@ -170,6 +215,11 @@ export default {
|
|
|
170
215
|
}
|
|
171
216
|
},
|
|
172
217
|
handleBlur(event) {
|
|
218
|
+
/**
|
|
219
|
+
* Fired when the token selector is blurred
|
|
220
|
+
*
|
|
221
|
+
* @property {FocusEvent} event
|
|
222
|
+
*/
|
|
173
223
|
this.$emit('blur', event);
|
|
174
224
|
|
|
175
225
|
this.inputFocused = false;
|
|
@@ -234,18 +284,38 @@ export default {
|
|
|
234
284
|
name: this.inputText,
|
|
235
285
|
};
|
|
236
286
|
|
|
287
|
+
/**
|
|
288
|
+
* Fired when a token is added or removed
|
|
289
|
+
*
|
|
290
|
+
* @property {array} selectedTokens
|
|
291
|
+
*/
|
|
237
292
|
this.$emit('input', [...this.selectedTokens, token]);
|
|
238
293
|
|
|
239
294
|
this.inputText = '';
|
|
240
295
|
this.closeDropdown();
|
|
241
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Fired when a token is added
|
|
299
|
+
*
|
|
300
|
+
* @property {object} token
|
|
301
|
+
*/
|
|
242
302
|
this.$emit('token-add', token);
|
|
243
303
|
},
|
|
244
304
|
removeToken(token) {
|
|
305
|
+
/**
|
|
306
|
+
* Fired when user types in the token selector
|
|
307
|
+
*
|
|
308
|
+
* @property {string} inputText
|
|
309
|
+
*/
|
|
245
310
|
this.$emit(
|
|
246
311
|
'input',
|
|
247
312
|
this.selectedTokens.filter((selectedToken) => selectedToken.id !== token.id)
|
|
248
313
|
);
|
|
314
|
+
/**
|
|
315
|
+
* Fired when a token is removed
|
|
316
|
+
*
|
|
317
|
+
* @property {object} token
|
|
318
|
+
*/
|
|
249
319
|
this.$emit('token-remove', token);
|
|
250
320
|
},
|
|
251
321
|
cancelTokenFocus() {
|
|
@@ -296,6 +366,10 @@ export default {
|
|
|
296
366
|
@cancel-focus="cancelTokenFocus"
|
|
297
367
|
>
|
|
298
368
|
<template #token-content="{ token }">
|
|
369
|
+
<!-- @slot Content to pass to the token component slot. Can be used
|
|
370
|
+
to add an avatar to the token. Default content is "{{ token.name }}".
|
|
371
|
+
@binding {object} token
|
|
372
|
+
-->
|
|
299
373
|
<slot name="token-content" :token="token"></slot>
|
|
300
374
|
</template>
|
|
301
375
|
<template #text-input>
|
|
@@ -342,18 +416,32 @@ export default {
|
|
|
342
416
|
@show="openDropdown"
|
|
343
417
|
>
|
|
344
418
|
<template #loading-content>
|
|
419
|
+
<!-- @slot Content to display when `loading` prop is `true`. Default
|
|
420
|
+
content is "Searching..." -->
|
|
345
421
|
<slot name="loading-content"></slot>
|
|
346
422
|
</template>
|
|
347
423
|
<template #user-defined-token-content>
|
|
424
|
+
<!-- @slot Content to display when adding a user defined token. Default content is 'Add "{{ inputText }}"'.
|
|
425
|
+
@binding {string} inputText
|
|
426
|
+
-->
|
|
348
427
|
<slot name="user-defined-token-content" :input-text="inputText"></slot>
|
|
349
428
|
</template>
|
|
350
429
|
<template #no-results-content>
|
|
430
|
+
<!-- @slot Content to display when `dropdown-items` is empty and
|
|
431
|
+
`allow-user-defined-tokens` is `false`. Default content is "No matches found". -->
|
|
351
432
|
<slot name="no-results-content"></slot>
|
|
352
433
|
</template>
|
|
353
434
|
<template #dropdown-item-content="{ dropdownItem }">
|
|
435
|
+
<!-- @slot Dropdown item content. Default content is "{{ dropdownItem.name }}".
|
|
436
|
+
@binding {object} dropdownItem
|
|
437
|
+
-->
|
|
354
438
|
<slot name="dropdown-item-content" :dropdown-item="dropdownItem"></slot>
|
|
355
439
|
</template>
|
|
356
440
|
<template #dropdown-footer>
|
|
441
|
+
<!-- @slot Content to add to the bottom of the dropdown.
|
|
442
|
+
Can be used in conjunction with `gl-intersection-observer` to load
|
|
443
|
+
more items as the user scrolls.
|
|
444
|
+
-->
|
|
357
445
|
<slot name="dropdown-footer"></slot>
|
|
358
446
|
</template>
|
|
359
447
|
</gl-token-selector-dropdown>
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
## Usage
|
|
2
|
-
|
|
3
1
|
Using the tooltip component is recommended if you have HTML content.
|
|
4
2
|
It is also currently required if the tooltip content needs to change while it's visible
|
|
5
|
-
(see [this upstream issue]). In all other cases, please use the directive.
|
|
3
|
+
(see [this upstream issue][this upstream issue]). In all other cases, please use the directive.
|
|
6
4
|
|
|
7
5
|
[this upstream issue]: https://github.com/bootstrap-vue/bootstrap-vue/issues/2142
|
|
8
6
|
|
|
@@ -43,11 +41,11 @@ export default {
|
|
|
43
41
|
|
|
44
42
|
## Directive attributes
|
|
45
43
|
|
|
46
|
-
`v-gl-tooltip` directive uses the same attributes as [`v-b-tooltip`].
|
|
44
|
+
`v-gl-tooltip` directive uses the same attributes as [`v-b-tooltip`][`v-b-tooltip`].
|
|
47
45
|
|
|
48
46
|
## Under the hood
|
|
49
47
|
|
|
50
|
-
Tooltip uses [`<b-tooltip>`] and [`v-b-tooltip`] internally.
|
|
48
|
+
Tooltip uses [`<b-tooltip>`][`<b-tooltip>`] and [`v-b-tooltip`][`v-b-tooltip`] internally.
|
|
51
49
|
|
|
52
50
|
[`<b-tooltip>`]: https://bootstrap-vue.org/docs/components/tooltip
|
|
53
51
|
|
|
@@ -19,11 +19,6 @@ describe('GlTooltip', () => {
|
|
|
19
19
|
createWrapper();
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
afterEach(() => {
|
|
23
|
-
wrapper.destroy();
|
|
24
|
-
wrapper = null;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
22
|
it.each(tooltipActionEvents)('passes through the %s event to the bvTooltip instance', (event) => {
|
|
28
23
|
wrapper.vm.$emit(event);
|
|
29
24
|
|
|
@@ -1,34 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { documentedStoriesOf } from '../../../../documentation/documented_stories';
|
|
3
|
-
import { GlTooltipDirective } from '../../../../index';
|
|
1
|
+
import { GlTooltip, GlTooltipDirective } from '../../../../index';
|
|
4
2
|
import readme from './tooltip.md';
|
|
5
3
|
|
|
6
|
-
const directives = {
|
|
7
|
-
GlTooltip: GlTooltipDirective,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
4
|
function makeTooltip(modifier = '') {
|
|
11
|
-
return
|
|
12
|
-
directives
|
|
5
|
+
return {
|
|
6
|
+
directives: {
|
|
7
|
+
GlTooltip: GlTooltipDirective,
|
|
8
|
+
},
|
|
13
9
|
template: `
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
<div class="gl-display-flex gl-align-items-center gl-justify-content-center gl-p-7 gl-m-7">
|
|
11
|
+
<gl-button
|
|
12
|
+
v-gl-tooltip${modifier}
|
|
13
|
+
title="some tooltip text"
|
|
14
|
+
>
|
|
15
|
+
Tooltip
|
|
16
|
+
</gl-button>
|
|
17
|
+
</div>
|
|
18
|
+
`,
|
|
23
19
|
mounted() {
|
|
24
20
|
this.$nextTick(() => this.$el.querySelector('button').focus());
|
|
25
21
|
},
|
|
26
|
-
}
|
|
22
|
+
};
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
export const TopDefault = (args, argTypes) => ({
|
|
26
|
+
...makeTooltip(),
|
|
27
|
+
props: Object.keys(argTypes),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const Right = (args, argTypes) => ({
|
|
31
|
+
...makeTooltip('.right'),
|
|
32
|
+
props: Object.keys(argTypes),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const Bottom = (args, argTypes) => ({
|
|
36
|
+
...makeTooltip('.bottom'),
|
|
37
|
+
props: Object.keys(argTypes),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const Left = (args, argTypes) => ({
|
|
41
|
+
...makeTooltip('.left'),
|
|
42
|
+
props: Object.keys(argTypes),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// A default export contains higher-level info about the component and the stories' settings.
|
|
46
|
+
export default {
|
|
47
|
+
title: 'base/tooltip',
|
|
48
|
+
component: GlTooltip,
|
|
49
|
+
parameters: {
|
|
50
|
+
bootstrapComponent: 'b-tooltip',
|
|
51
|
+
knobs: { disable: true },
|
|
52
|
+
docs: {
|
|
53
|
+
description: {
|
|
54
|
+
component: readme,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -5,6 +5,7 @@ import ChartLegend from '../legend/legend.vue';
|
|
|
5
5
|
import AreaChart from './area.vue';
|
|
6
6
|
|
|
7
7
|
import { LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE } from '~/utils/charts/constants';
|
|
8
|
+
import { createMockChartInstance, ChartTooltipStub } from '~helpers/chart_stubs';
|
|
8
9
|
|
|
9
10
|
let mockChartInstance;
|
|
10
11
|
|
|
@@ -14,7 +15,6 @@ jest.mock('echarts', () => ({
|
|
|
14
15
|
|
|
15
16
|
describe('area component', () => {
|
|
16
17
|
let wrapper;
|
|
17
|
-
let option;
|
|
18
18
|
|
|
19
19
|
const findChart = () => wrapper.findComponent(Chart);
|
|
20
20
|
const findLegend = () => wrapper.findComponent(ChartLegend);
|
|
@@ -24,33 +24,17 @@ describe('area component', () => {
|
|
|
24
24
|
const emitChartCreated = () => findChart().vm.$emit('created', mockChartInstance);
|
|
25
25
|
|
|
26
26
|
const createShallowWrapper = (props = {}) => {
|
|
27
|
-
wrapper = shallowMount(AreaChart, {
|
|
27
|
+
wrapper = shallowMount(AreaChart, {
|
|
28
|
+
propsData: { option: { series: [] }, data: [], ...props },
|
|
29
|
+
stubs: {
|
|
30
|
+
'chart-tooltip': ChartTooltipStub,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
28
33
|
emitChartCreated();
|
|
29
34
|
};
|
|
30
35
|
|
|
31
36
|
beforeEach(() => {
|
|
32
|
-
|
|
33
|
-
series: [],
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
mockChartInstance = {
|
|
37
|
-
getDom: () => {
|
|
38
|
-
return {
|
|
39
|
-
addEventListener: jest.fn(),
|
|
40
|
-
removeEventListener: jest.fn(),
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
on: jest.fn(),
|
|
44
|
-
off: jest.fn(),
|
|
45
|
-
convertToPixel: jest.fn(),
|
|
46
|
-
getOption: () => {
|
|
47
|
-
return option;
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
afterEach(() => {
|
|
53
|
-
wrapper.destroy();
|
|
37
|
+
mockChartInstance = createMockChartInstance();
|
|
54
38
|
});
|
|
55
39
|
|
|
56
40
|
it('emits `created`, with the chart instance', async () => {
|
|
@@ -345,8 +345,9 @@ export default {
|
|
|
345
345
|
:left="annotationsTooltipPosition.left"
|
|
346
346
|
placement="bottom"
|
|
347
347
|
>
|
|
348
|
-
|
|
349
|
-
|
|
348
|
+
<template #title>
|
|
349
|
+
<div>{{ annotationsTooltipTitle }}</div>
|
|
350
|
+
</template>
|
|
350
351
|
<div>{{ annotationsTooltipContent }}</div>
|
|
351
352
|
</chart-tooltip>
|
|
352
353
|
<chart-tooltip
|
|
@@ -359,19 +360,15 @@ export default {
|
|
|
359
360
|
:top="dataTooltipPosition.top"
|
|
360
361
|
:left="dataTooltipPosition.left"
|
|
361
362
|
>
|
|
362
|
-
<template
|
|
363
|
-
|
|
364
|
-
<
|
|
365
|
-
<slot name="tooltip-content"></slot>
|
|
366
|
-
</template>
|
|
367
|
-
<template v-else>
|
|
368
|
-
<!-- eslint-disable-next-line vue/no-deprecated-slot-attribute -->
|
|
369
|
-
<div slot="title">
|
|
363
|
+
<template #title>
|
|
364
|
+
<slot v-if="formatTooltipText" name="tooltip-title"></slot>
|
|
365
|
+
<template v-else>
|
|
370
366
|
{{ dataTooltipTitle }}
|
|
371
367
|
<template v-if="options.xAxis.name">({{ options.xAxis.name }})</template>
|
|
372
|
-
</
|
|
373
|
-
<tooltip-default-format :tooltip-content="dataTooltipContent" />
|
|
368
|
+
</template>
|
|
374
369
|
</template>
|
|
370
|
+
<slot v-if="formatTooltipText" name="tooltip-content"></slot>
|
|
371
|
+
<tooltip-default-format v-else :tooltip-content="dataTooltipContent" />
|
|
375
372
|
</chart-tooltip>
|
|
376
373
|
<chart-legend
|
|
377
374
|
v-if="compiledOptions"
|
|
@@ -2,16 +2,9 @@ import { shallowMount } from '@vue/test-utils';
|
|
|
2
2
|
import Chart from '../chart/chart.vue';
|
|
3
3
|
import BarChart from './bar.vue';
|
|
4
4
|
import TooltipDefaultFormat from '~/components/shared_components/charts/tooltip_default_format.vue';
|
|
5
|
+
import { createMockChartInstance } from '~helpers/chart_stubs';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
getDom: () => {
|
|
8
|
-
return {
|
|
9
|
-
addEventListener: jest.fn(),
|
|
10
|
-
removeEventListener: jest.fn(),
|
|
11
|
-
};
|
|
12
|
-
},
|
|
13
|
-
convertToPixel: jest.fn(),
|
|
14
|
-
};
|
|
7
|
+
let mockChartInstance;
|
|
15
8
|
|
|
16
9
|
jest.mock('echarts', () => ({
|
|
17
10
|
getInstanceByDom: () => mockChartInstance,
|
|
@@ -45,8 +38,8 @@ describe('Bar chart component', () => {
|
|
|
45
38
|
});
|
|
46
39
|
};
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
mockChartInstance = createMockChartInstance();
|
|
50
43
|
});
|
|
51
44
|
|
|
52
45
|
describe('when mounted', () => {
|
|
@@ -25,10 +25,6 @@ describe('chart component', () => {
|
|
|
25
25
|
wrapper = shallowMount(...mountArgs);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
afterEach(() => {
|
|
29
|
-
wrapper.destroy();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
28
|
it('initializes chart using $refs.chart', () => {
|
|
33
29
|
expect(echarts.init).toHaveBeenCalledWith(
|
|
34
30
|
wrapper.findComponent({ ref: 'chart' }).element,
|
|
@@ -174,16 +174,13 @@ export default {
|
|
|
174
174
|
:top="tooltipPosition.top"
|
|
175
175
|
:left="tooltipPosition.left"
|
|
176
176
|
>
|
|
177
|
-
<template
|
|
178
|
-
|
|
179
|
-
<slot slot="title" name="tooltip-title"></slot>
|
|
180
|
-
<slot name="tooltip-content"></slot>
|
|
177
|
+
<template #title>
|
|
178
|
+
<slot name="tooltip-title">{{ tooltipTitle }} ({{ xAxisTitle }})</slot>
|
|
181
179
|
</template>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
<div slot="title">{{ tooltipTitle }} ({{ xAxisTitle }})</div>
|
|
180
|
+
|
|
181
|
+
<slot name="tooltip-content">
|
|
185
182
|
<tooltip-default-format :tooltip-content="tooltipContent" />
|
|
186
|
-
</
|
|
183
|
+
</slot>
|
|
187
184
|
</chart-tooltip>
|
|
188
185
|
</div>
|
|
189
186
|
</template>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
-
|
|
3
2
|
import { gaugeSafeHues, gaugeWarningHue } from '../../../utils/charts/theme';
|
|
4
3
|
import Chart from '../chart/chart.vue';
|
|
5
4
|
import GlGauge from './gauge.vue';
|
|
5
|
+
import { createMockChartInstance } from '~helpers/chart_stubs';
|
|
6
6
|
|
|
7
7
|
const placeholder = '--';
|
|
8
8
|
|
|
@@ -20,7 +20,6 @@ jest.mock('echarts', () => ({
|
|
|
20
20
|
|
|
21
21
|
describe('gauge component', () => {
|
|
22
22
|
let wrapper;
|
|
23
|
-
let options;
|
|
24
23
|
|
|
25
24
|
const findChart = () => wrapper.findComponent(Chart);
|
|
26
25
|
const findChartOptions = () => findChart().props('options');
|
|
@@ -38,28 +37,7 @@ describe('gauge component', () => {
|
|
|
38
37
|
};
|
|
39
38
|
|
|
40
39
|
beforeEach(() => {
|
|
41
|
-
|
|
42
|
-
series: [],
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
mockChartInstance = {
|
|
46
|
-
getDom: () => {
|
|
47
|
-
return {
|
|
48
|
-
addEventListener: jest.fn(),
|
|
49
|
-
removeEventListener: jest.fn(),
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
on: jest.fn(),
|
|
53
|
-
off: jest.fn(),
|
|
54
|
-
convertToPixel: jest.fn(),
|
|
55
|
-
getOption: () => {
|
|
56
|
-
return options;
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
afterEach(() => {
|
|
62
|
-
wrapper.destroy();
|
|
40
|
+
mockChartInstance = createMockChartInstance();
|
|
63
41
|
});
|
|
64
42
|
|
|
65
43
|
it('emits `created`, with the chart instance', () => {
|
|
@@ -4,6 +4,7 @@ import Chart from '../chart/chart.vue';
|
|
|
4
4
|
import ChartTooltip from '../tooltip/tooltip.vue';
|
|
5
5
|
import HeatMapChart from './heatmap.vue';
|
|
6
6
|
import { TOOLTIP_LEFT_OFFSET } from '~/utils/charts/constants';
|
|
7
|
+
import { createMockChartInstance } from '~helpers/chart_stubs';
|
|
7
8
|
|
|
8
9
|
let mockChartInstance;
|
|
9
10
|
|
|
@@ -13,7 +14,6 @@ jest.mock('echarts', () => ({
|
|
|
13
14
|
|
|
14
15
|
describe('heatmap component', () => {
|
|
15
16
|
let wrapper;
|
|
16
|
-
let options;
|
|
17
17
|
|
|
18
18
|
const findChart = () => wrapper.findComponent(Chart);
|
|
19
19
|
const findChartTooltip = () => wrapper.findComponent(ChartTooltip);
|
|
@@ -22,33 +22,16 @@ describe('heatmap component', () => {
|
|
|
22
22
|
const emitChartCreated = () => findChart().vm.$emit('created', mockChartInstance);
|
|
23
23
|
|
|
24
24
|
beforeEach(() => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
getDom: () => {
|
|
31
|
-
return {
|
|
32
|
-
addEventListener: jest.fn(),
|
|
33
|
-
removeEventListener: jest.fn(),
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
convertToPixel: jest.fn(),
|
|
37
|
-
getOption: () => {
|
|
38
|
-
return options;
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
wrapper = shallowMount(HeatMapChart, { propsData: { options, dataSeries: [] } });
|
|
25
|
+
mockChartInstance = createMockChartInstance();
|
|
26
|
+
|
|
27
|
+
wrapper = shallowMount(HeatMapChart, {
|
|
28
|
+
propsData: { options: { series: [] }, dataSeries: [] },
|
|
29
|
+
});
|
|
43
30
|
emitChartCreated();
|
|
44
31
|
|
|
45
32
|
return wrapper.vm.$nextTick();
|
|
46
33
|
});
|
|
47
34
|
|
|
48
|
-
afterEach(() => {
|
|
49
|
-
wrapper.destroy();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
35
|
it('emits `created`, with the chart instance', () => {
|
|
53
36
|
expect(wrapper.emitted('created').length).toBe(1);
|
|
54
37
|
expect(wrapper.emitted('created')[0][0]).toBe(mockChartInstance);
|