@gitlab/ui 32.40.0 → 32.43.1
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/search_box_by_click/search_box_by_click.js +1 -0
- package/dist/components/base/search_box_by_type/search_box_by_type.js +1 -1
- 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/column/column.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_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_click/search_box_by_click.vue +1 -0
- package/src/components/base/search_box_by_type/search_box_by_type.spec.js +0 -5
- package/src/components/base/search_box_by_type/search_box_by_type.vue +1 -1
- 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.vue +3 -2
- package/src/components/charts/column/column_chart.spec.js +35 -19
- 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 +2 -30
- 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
|
@@ -11,11 +11,6 @@ describe('GlSkeletonLoader', () => {
|
|
|
11
11
|
wrapper = shallowMount(GlSkeletonLoader, options);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
afterEach(() => {
|
|
15
|
-
wrapper.destroy();
|
|
16
|
-
wrapper = null;
|
|
17
|
-
});
|
|
18
|
-
|
|
19
14
|
describe('when default skeleton is used', () => {
|
|
20
15
|
it('adds `gl-w-full` and `gl-h-full` CSS classes', () => {
|
|
21
16
|
createComponent();
|
|
@@ -32,11 +32,6 @@ describe('GlScrollableTabs', () => {
|
|
|
32
32
|
inputSpy = jest.fn();
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
afterEach(() => {
|
|
36
|
-
wrapper.destroy();
|
|
37
|
-
wrapper = null;
|
|
38
|
-
});
|
|
39
|
-
|
|
40
35
|
const findScrollRightButton = () => wrapper.find('[aria-label="Scroll right"]');
|
|
41
36
|
const findScrollLeftButton = () => wrapper.find('[aria-label="Scroll left"]');
|
|
42
37
|
const findNav = () => wrapper.find(`.${NAV_CLASS}`);
|
|
@@ -22,10 +22,6 @@ describe('toggle', () => {
|
|
|
22
22
|
const findButton = () => wrapper.find('button');
|
|
23
23
|
const findHelpElement = () => wrapper.find('[data-testid="toggle-help"]');
|
|
24
24
|
|
|
25
|
-
afterEach(() => {
|
|
26
|
-
wrapper.destroy();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
25
|
it('has role=switch', () => {
|
|
30
26
|
createWrapper();
|
|
31
27
|
|
|
@@ -1,142 +1,5 @@
|
|
|
1
|
-
import examples from './examples';
|
|
2
1
|
import * as description from './token_selector.md';
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
4
|
description,
|
|
6
|
-
examples,
|
|
7
|
-
propsInfo: {
|
|
8
|
-
dropdownItems: {
|
|
9
|
-
additionalInfo: 'Items to display in dropdown',
|
|
10
|
-
},
|
|
11
|
-
selectedTokens: {
|
|
12
|
-
additionalInfo:
|
|
13
|
-
'Tokens that are selected. This prop will automatically be added when using `v-model`',
|
|
14
|
-
},
|
|
15
|
-
allowUserDefinedTokens: {
|
|
16
|
-
additionalInfo: 'Should users be allowed to add tokens that are not in `dropdown-items`',
|
|
17
|
-
},
|
|
18
|
-
loading: {
|
|
19
|
-
additionalInfo: 'Dropdown items are loading, can be used when requesting new dropdown items',
|
|
20
|
-
},
|
|
21
|
-
hideDropdownWithNoItems: {
|
|
22
|
-
additionalInfo:
|
|
23
|
-
'Hide the dropdown if `dropdown-items` is empty. Will show `no-results-content` slot if this is `false`',
|
|
24
|
-
},
|
|
25
|
-
containerClass: {
|
|
26
|
-
additionalInfo:
|
|
27
|
-
'CSS classes to add to the main token selector container (`.gl-token-selector`)',
|
|
28
|
-
},
|
|
29
|
-
menuClass: {
|
|
30
|
-
additionalInfo: 'CSS classes to add to dropdown menu `ul` element',
|
|
31
|
-
},
|
|
32
|
-
textInputAttrs: {
|
|
33
|
-
additionalInfo:
|
|
34
|
-
'HTML attributes to add to the text input. Helpful for adding `data-testid` and `data-qa-selector` attributes',
|
|
35
|
-
},
|
|
36
|
-
state: {
|
|
37
|
-
additionalInfo:
|
|
38
|
-
'Controls the validation state appearance of the component. `true` for valid, `false` for invalid, or `null` for no validation state',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
slots: [
|
|
42
|
-
{
|
|
43
|
-
name: 'no-results-content',
|
|
44
|
-
description:
|
|
45
|
-
'Content to display when `dropdown-items` is empty and `allow-user-defined-tokens` is `false`',
|
|
46
|
-
default: 'No matches found',
|
|
47
|
-
scopedProps: '',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: 'user-defined-token-content',
|
|
51
|
-
description: 'Content to display when adding a user defined token',
|
|
52
|
-
default: 'Add "{{ inputText }}"',
|
|
53
|
-
scopedProps: 'inputText (String)',
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'token-content',
|
|
57
|
-
description:
|
|
58
|
-
'Content to pass to the token component slot. Can be used to add an avatar to the token',
|
|
59
|
-
default: '{{ token.name }}',
|
|
60
|
-
scopedProps: 'token (Object)',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: 'dropdown-item-content',
|
|
64
|
-
description: 'Dropdown item content',
|
|
65
|
-
default: '{{ dropdownItem.name }}',
|
|
66
|
-
scopedProps: 'dropdownItem (Object)',
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: 'dropdown-footer',
|
|
70
|
-
description:
|
|
71
|
-
'Content to add to the bottom of the dropdown. Can be used in conjunction with `gl-intersection-observer` to load more items as the user scrolls',
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
name: 'loading-content',
|
|
75
|
-
description: 'Content to display when `loading` prop is `true`',
|
|
76
|
-
default: 'Searching...',
|
|
77
|
-
scopedProps: '',
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
events: [
|
|
81
|
-
{
|
|
82
|
-
event: 'text-input',
|
|
83
|
-
args: [
|
|
84
|
-
{
|
|
85
|
-
arg: 'inputText',
|
|
86
|
-
description: '(String)',
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
description: 'Fired when user types in the token selector',
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
event: 'input',
|
|
93
|
-
args: [
|
|
94
|
-
{
|
|
95
|
-
arg: 'selectedTokens',
|
|
96
|
-
description: '(Array)',
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
description: 'Fired when a token is added or removed',
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
event: 'focus',
|
|
103
|
-
args: [
|
|
104
|
-
{
|
|
105
|
-
arg: 'event',
|
|
106
|
-
description: '(FocusEvent)',
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
description: 'Fired when the token selector is focused',
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
event: 'blur',
|
|
113
|
-
args: [
|
|
114
|
-
{
|
|
115
|
-
arg: 'event',
|
|
116
|
-
description: '(FocusEvent)',
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
description: 'Fired when the token selector is blurred',
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
event: 'token-add',
|
|
123
|
-
args: [
|
|
124
|
-
{
|
|
125
|
-
arg: 'token',
|
|
126
|
-
description: '(Object)',
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
description: 'Fired when a token is added',
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
event: 'token-remove',
|
|
133
|
-
args: [
|
|
134
|
-
{
|
|
135
|
-
arg: 'token',
|
|
136
|
-
description: '(Object)',
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
description: 'Fired when a token is removed',
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
5
|
};
|
|
@@ -1,130 +1,113 @@
|
|
|
1
|
-
import { withKnobs, object, boolean, radios } from '@storybook/addon-knobs';
|
|
2
|
-
import { documentedStoriesOf } from '../../../../documentation/documented_stories';
|
|
3
1
|
import readme from './token_selector.md';
|
|
4
2
|
import GlTokenSelector from './token_selector.vue';
|
|
5
3
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return true;
|
|
17
|
-
case 'false':
|
|
18
|
-
return false;
|
|
19
|
-
default:
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
4
|
+
const template = `
|
|
5
|
+
<div>
|
|
6
|
+
<gl-token-selector
|
|
7
|
+
v-model="selectedTokens"
|
|
8
|
+
v-bind="$props"
|
|
9
|
+
@text-input="handleTextInput"
|
|
10
|
+
@focus="handleFocus" />
|
|
11
|
+
{{ selectedTokens }}
|
|
12
|
+
</div>
|
|
13
|
+
`;
|
|
23
14
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
name: 'Vue.js',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
id: 2,
|
|
33
|
-
name: 'Ruby On Rails',
|
|
34
|
-
class: 'gl-text-white! gl-bg-data-viz-magenta-950!',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
id: 3,
|
|
38
|
-
name: 'GraphQL',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
id: 4,
|
|
42
|
-
name: 'Redis',
|
|
43
|
-
class: 'gl-text-white! gl-bg-data-viz-green-700!',
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
id: 5,
|
|
47
|
-
name: 'CSS',
|
|
48
|
-
class: 'gl-text-red-500!',
|
|
49
|
-
style: { backgroundColor: '#97acff' },
|
|
50
|
-
},
|
|
51
|
-
]),
|
|
15
|
+
const generateProps = () => ({
|
|
16
|
+
dropdownItems: [
|
|
17
|
+
{
|
|
18
|
+
id: 1,
|
|
19
|
+
name: 'Vue.js',
|
|
52
20
|
},
|
|
53
|
-
|
|
54
|
-
|
|
21
|
+
{
|
|
22
|
+
id: 2,
|
|
23
|
+
name: 'Ruby On Rails',
|
|
24
|
+
class: 'gl-text-white! gl-bg-data-viz-magenta-950!',
|
|
55
25
|
},
|
|
56
|
-
|
|
57
|
-
|
|
26
|
+
{
|
|
27
|
+
id: 3,
|
|
28
|
+
name: 'GraphQL',
|
|
58
29
|
},
|
|
59
|
-
|
|
60
|
-
|
|
30
|
+
{
|
|
31
|
+
id: 4,
|
|
32
|
+
name: 'Redis',
|
|
33
|
+
class: 'gl-text-white! gl-bg-data-viz-green-700!',
|
|
61
34
|
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
35
|
+
{
|
|
36
|
+
id: 5,
|
|
37
|
+
name: 'CSS',
|
|
38
|
+
class: 'gl-text-red-500!',
|
|
39
|
+
style: { backgroundColor: '#97acff' },
|
|
66
40
|
},
|
|
67
|
-
|
|
68
|
-
};
|
|
41
|
+
],
|
|
42
|
+
});
|
|
69
43
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
handleTextInput(value) {
|
|
93
|
-
this.inputText = value;
|
|
44
|
+
const Template = (args, { argTypes }) => ({
|
|
45
|
+
components: { GlTokenSelector },
|
|
46
|
+
props: Object.keys(argTypes),
|
|
47
|
+
template,
|
|
48
|
+
mounted() {
|
|
49
|
+
document.querySelector('.gl-token-selector input[type="text"]').focus();
|
|
50
|
+
},
|
|
51
|
+
data() {
|
|
52
|
+
return {
|
|
53
|
+
filteredDropdownItems: [],
|
|
54
|
+
inputText: '',
|
|
55
|
+
selectedTokens: [
|
|
56
|
+
{
|
|
57
|
+
id: 1,
|
|
58
|
+
name: 'Vue.js',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
methods: {
|
|
64
|
+
handleTextInput(value) {
|
|
65
|
+
this.inputText = value;
|
|
94
66
|
|
|
95
|
-
|
|
96
|
-
|
|
67
|
+
if (this.inputText === '') {
|
|
68
|
+
this.filteredDropdownItems = this.dropdownItems;
|
|
97
69
|
|
|
98
|
-
|
|
99
|
-
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
100
72
|
|
|
73
|
+
this.filterDropdownItems();
|
|
74
|
+
},
|
|
75
|
+
handleFocus() {
|
|
76
|
+
if (this.inputText !== '') {
|
|
101
77
|
this.filterDropdownItems();
|
|
78
|
+
} else {
|
|
79
|
+
this.filteredDropdownItems = this.dropdownItems;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
filterDropdownItems() {
|
|
83
|
+
this.filteredDropdownItems = this.dropdownItems.filter((dropdownItem) => {
|
|
84
|
+
return dropdownItem.name.toLowerCase().includes(this.inputText.toLowerCase());
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
export const Default = Template.bind({});
|
|
91
|
+
Default.parameters = { storyshots: { disable: true } };
|
|
92
|
+
Default.args = generateProps();
|
|
93
|
+
|
|
94
|
+
export default {
|
|
95
|
+
title: 'base/token_selector',
|
|
96
|
+
component: GlTokenSelector,
|
|
97
|
+
parameters: {
|
|
98
|
+
knobs: { disable: true },
|
|
99
|
+
docs: {
|
|
100
|
+
description: {
|
|
101
|
+
component: readme,
|
|
102
102
|
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
filterDropdownItems() {
|
|
111
|
-
this.filteredDropdownItems = this.dropdownItems.filter((dropdownItem) => {
|
|
112
|
-
return dropdownItem.name.toLowerCase().includes(this.inputText.toLowerCase());
|
|
113
|
-
});
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
argTypes: {
|
|
106
|
+
state: {
|
|
107
|
+
control: {
|
|
108
|
+
type: 'radio',
|
|
109
|
+
options: [true, false, null],
|
|
114
110
|
},
|
|
115
111
|
},
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
<gl-token-selector
|
|
119
|
-
v-model="selectedTokens"
|
|
120
|
-
:dropdown-items="filteredDropdownItems"
|
|
121
|
-
:allow-user-defined-tokens="allowUserDefinedTokens"
|
|
122
|
-
:loading="loading"
|
|
123
|
-
:hide-dropdown-with-no-items="hideDropdownWithNoItems"
|
|
124
|
-
:state="state"
|
|
125
|
-
@text-input="handleTextInput"
|
|
126
|
-
@focus="handleFocus" />
|
|
127
|
-
{{ selectedTokens }}
|
|
128
|
-
</div>
|
|
129
|
-
`,
|
|
130
|
-
}));
|
|
112
|
+
},
|
|
113
|
+
};
|
|
@@ -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>
|