@gitlab/ui 37.3.0 → 37.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/components/base/form/form_group/form_group.documentation.js +2 -6
- package/dist/components/base/search_box_by_click/search_box_by_click.documentation.js +2 -80
- package/dist/components/base/search_box_by_click/search_box_by_click.js +60 -1
- package/dist/components/base/search_box_by_type/search_box_by_type.documentation.js +2 -20
- package/dist/components/base/search_box_by_type/search_box_by_type.js +19 -5
- package/dist/directives/hover_load/hover_load.documentation.js +1 -1
- package/dist/directives/resize_observer/resize_observer.documentation.js +2 -5
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/documentation/documented_stories.js +5 -0
- package/package.json +1 -1
- package/src/components/base/button/button.scss +5 -9
- package/src/components/base/form/form_group/form_group.documentation.js +0 -3
- package/src/components/base/form/form_group/form_group.md +0 -2
- package/src/components/base/form/form_group/form_group.stories.js +106 -145
- package/src/components/base/search_box_by_click/search_box_by_click.documentation.js +0 -90
- package/src/components/base/search_box_by_click/search_box_by_click.md +0 -2
- package/src/components/base/search_box_by_click/search_box_by_click.stories.js +91 -48
- package/src/components/base/search_box_by_click/search_box_by_click.vue +50 -1
- package/src/components/base/search_box_by_type/search_box_by_type.documentation.js +0 -18
- package/src/components/base/search_box_by_type/search_box_by_type.md +0 -2
- package/src/components/base/search_box_by_type/search_box_by_type.stories.js +49 -43
- package/src/components/base/search_box_by_type/search_box_by_type.vue +16 -6
- package/src/directives/hover_load/hover_load.md +0 -2
- package/src/directives/hover_load/hover_load.stories.js +39 -34
- package/src/directives/resize_observer/resize_observer.documentation.js +0 -2
- package/src/directives/resize_observer/resize_observer.md +0 -6
- package/src/directives/resize_observer/resize_observer.stories.js +70 -51
- package/dist/components/base/form/form_group/examples/form_group/form_group.basic.example.js +0 -38
- package/dist/components/base/form/form_group/examples/form_group/form_group.disabled.example.js +0 -48
- package/dist/components/base/form/form_group/examples/form_group/form_group.textarea.example.js +0 -48
- package/dist/components/base/form/form_group/examples/form_group/form_group.validation.example.js +0 -66
- package/dist/components/base/form/form_group/examples/form_group/index.js +0 -27
- package/dist/components/base/search_box_by_click/examples/index.js +0 -22
- package/dist/components/base/search_box_by_click/examples/search_box_by_click.default.example.js +0 -48
- package/dist/components/base/search_box_by_click/examples/search_box_by_click.history.example.js +0 -51
- package/dist/components/base/search_box_by_click/examples/search_box_by_click.v_model.example.js +0 -54
- package/dist/components/base/search_box_by_type/examples/index.js +0 -17
- package/dist/components/base/search_box_by_type/examples/search_box_by_type.default.example.js +0 -48
- package/dist/components/base/search_box_by_type/examples/search_box_by_type.loading.example.js +0 -65
- package/dist/directives/resize_observer/examples/index.js +0 -12
- package/dist/directives/resize_observer/examples/resize_observer.basic.example.js +0 -62
- package/src/components/base/form/form_group/examples/form_group/form_group.basic.example.vue +0 -11
- package/src/components/base/form/form_group/examples/form_group/form_group.disabled.example.vue +0 -21
- package/src/components/base/form/form_group/examples/form_group/form_group.textarea.example.vue +0 -15
- package/src/components/base/form/form_group/examples/form_group/form_group.validation.example.vue +0 -36
- package/src/components/base/form/form_group/examples/form_group/index.js +0 -32
- package/src/components/base/search_box_by_click/examples/index.js +0 -26
- package/src/components/base/search_box_by_click/examples/search_box_by_click.default.example.vue +0 -14
- package/src/components/base/search_box_by_click/examples/search_box_by_click.history.example.vue +0 -23
- package/src/components/base/search_box_by_click/examples/search_box_by_click.v_model.example.vue +0 -23
- package/src/components/base/search_box_by_type/examples/index.js +0 -20
- package/src/components/base/search_box_by_type/examples/search_box_by_type.default.example.vue +0 -14
- package/src/components/base/search_box_by_type/examples/search_box_by_type.loading.example.vue +0 -34
- package/src/directives/resize_observer/examples/index.js +0 -14
- package/src/directives/resize_observer/examples/resize_observer.basic.example.vue +0 -21
|
@@ -93,6 +93,7 @@ export const setupStorybookReadme = () =>
|
|
|
93
93
|
'GlIntersperse',
|
|
94
94
|
'GlFormSelect',
|
|
95
95
|
'GlDaterangePicker',
|
|
96
|
+
'GlFormGroup',
|
|
96
97
|
'GlAvatarLabeled',
|
|
97
98
|
'GlBarChart',
|
|
98
99
|
'GlCarousel',
|
|
@@ -108,8 +109,10 @@ export const setupStorybookReadme = () =>
|
|
|
108
109
|
'GlPagination',
|
|
109
110
|
'GlSkeletonLoader',
|
|
110
111
|
'GlLabel',
|
|
112
|
+
'GlHoverLoadDirective',
|
|
111
113
|
'GlStackedColumnChart',
|
|
112
114
|
'GlDiscreteScatterChart',
|
|
115
|
+
'GlResizeObserverDirective',
|
|
113
116
|
'GlFormCombobox',
|
|
114
117
|
'GlChartTooltip',
|
|
115
118
|
'GlInputGroupText',
|
|
@@ -129,6 +132,7 @@ export const setupStorybookReadme = () =>
|
|
|
129
132
|
'GlColumnChart',
|
|
130
133
|
'GlTruncate',
|
|
131
134
|
'GlNav',
|
|
135
|
+
'GlSearchBoxByType',
|
|
132
136
|
'GlNavItem',
|
|
133
137
|
'GlNavItemDropdown',
|
|
134
138
|
'GlPopover',
|
|
@@ -140,6 +144,7 @@ export const setupStorybookReadme = () =>
|
|
|
140
144
|
'GlAreaChart',
|
|
141
145
|
'GlLineChart',
|
|
142
146
|
'GlFormInputGroup',
|
|
147
|
+
'GlSearchBoxByClick',
|
|
143
148
|
],
|
|
144
149
|
components: {
|
|
145
150
|
GlComponentDocumentation,
|
package/package.json
CHANGED
|
@@ -108,9 +108,8 @@
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
&.selected {
|
|
111
|
-
@include gl-bg-
|
|
112
|
-
box-shadow: inset 0 0 0 $gl-border-size-
|
|
113
|
-
inset 0 $gl-border-size-2 $gl-border-size-4 $gray-200;
|
|
111
|
+
@include gl-bg-white;
|
|
112
|
+
box-shadow: inset 0 0 0 $gl-border-size-2 $gray-300;
|
|
114
113
|
|
|
115
114
|
&:hover,
|
|
116
115
|
&:focus {
|
|
@@ -118,20 +117,17 @@
|
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
&:hover {
|
|
121
|
-
box-shadow: inset 0 0 0 $gl-border-size-2 $gray-400
|
|
122
|
-
inset 0 $gl-border-size-4 $gl-border-size-4 $gray-200;
|
|
120
|
+
box-shadow: inset 0 0 0 $gl-border-size-2 $gray-400;
|
|
123
121
|
}
|
|
124
122
|
|
|
125
123
|
&:focus {
|
|
126
|
-
box-shadow: inset 0 0 0 $gl-border-size-2 $gray-400,
|
|
127
|
-
inset 0 $gl-border-size-4 $gl-border-size-4 $gray-200, $focus-ring;
|
|
124
|
+
box-shadow: inset 0 0 0 $gl-border-size-2 $gray-400, $focus-ring;
|
|
128
125
|
}
|
|
129
126
|
|
|
130
127
|
&:active,
|
|
131
128
|
&:active:focus {
|
|
132
129
|
@include gl-bg-gray-100;
|
|
133
|
-
box-shadow: inset 0 0 0 $gl-border-size-2 $gray-600,
|
|
134
|
-
inset 0 $gl-border-size-4 $gl-border-size-4 $gray-200, $focus-ring;
|
|
130
|
+
box-shadow: inset 0 0 0 $gl-border-size-2 $gray-600, $focus-ring;
|
|
135
131
|
}
|
|
136
132
|
}
|
|
137
133
|
|
|
@@ -1,164 +1,125 @@
|
|
|
1
|
-
import { withKnobs, text, select, boolean } from '@storybook/addon-knobs';
|
|
2
|
-
import { documentedStoriesOf } from '../../../../../documentation/documented_stories';
|
|
3
1
|
import { GlFormGroup, GlFormInput, GlFormTextarea } from '../../../../index';
|
|
4
|
-
import {
|
|
2
|
+
import { disableControls } from '../../../../utils/stories_utils';
|
|
5
3
|
import readme from './form_group.md';
|
|
6
4
|
|
|
7
5
|
const components = {
|
|
8
6
|
GlFormGroup,
|
|
9
7
|
};
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
const generateProps = ({
|
|
12
10
|
id = 'group-1',
|
|
13
11
|
label = 'Label Name',
|
|
14
12
|
description = 'form group description',
|
|
15
|
-
labelDescription = '
|
|
13
|
+
labelDescription = '',
|
|
16
14
|
optional = GlFormGroup.props.optional.default,
|
|
17
15
|
optionalText = GlFormGroup.props.optionalText.default,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
16
|
+
} = {}) => ({
|
|
17
|
+
id,
|
|
18
|
+
label,
|
|
19
|
+
labelDescription,
|
|
20
|
+
optional,
|
|
21
|
+
optionalText,
|
|
22
|
+
description,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const wrap = (template, bindings = '') => `
|
|
26
|
+
<gl-form-group
|
|
27
|
+
:id="id + '_group'"
|
|
28
|
+
:label="label"
|
|
29
|
+
:label-description="labelDescription"
|
|
30
|
+
:optional="optional"
|
|
31
|
+
:optional-text="optionalText"
|
|
32
|
+
:description="description"
|
|
33
|
+
${bindings}
|
|
34
|
+
:label-for="id">
|
|
35
|
+
${template}
|
|
36
|
+
</gl-form-group>
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
export const Default = (_args, { argTypes }) => ({
|
|
40
|
+
props: Object.keys(argTypes),
|
|
41
|
+
components: { ...components, GlFormInput },
|
|
42
|
+
template: wrap('<gl-form-input :id="id" />'),
|
|
43
|
+
});
|
|
44
|
+
Default.args = generateProps();
|
|
45
|
+
|
|
46
|
+
export const Disabled = (_args, { argTypes }) => ({
|
|
47
|
+
props: Object.keys(argTypes),
|
|
48
|
+
components: { ...components, GlFormInput },
|
|
49
|
+
template: wrap('<gl-form-input :id="id" type="text" value="Disabled" disabled />'),
|
|
50
|
+
});
|
|
51
|
+
Disabled.args = generateProps({ description: 'This feature is disabled' });
|
|
52
|
+
|
|
53
|
+
export const WithTextarea = (_args, { argTypes }) => ({
|
|
54
|
+
props: Object.keys(argTypes),
|
|
55
|
+
components: { ...components, GlFormTextarea },
|
|
56
|
+
template: wrap('<gl-form-textarea :id="id" placeholder="Enter something" />'),
|
|
57
|
+
});
|
|
58
|
+
WithTextarea.args = generateProps({
|
|
59
|
+
id: 'textarea2',
|
|
60
|
+
optional: true,
|
|
61
|
+
description: '',
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const WithLabelDescription = (_args, { argTypes }) => ({
|
|
65
|
+
props: Object.keys(argTypes),
|
|
66
|
+
components: { ...components, GlFormInput },
|
|
67
|
+
template: wrap('<gl-form-input :id="id" />'),
|
|
68
|
+
});
|
|
69
|
+
WithLabelDescription.args = generateProps({
|
|
70
|
+
optional: true,
|
|
71
|
+
labelDescription: 'form label description',
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export const WithValidations = (_args, { argTypes }) => ({
|
|
75
|
+
props: Object.keys(argTypes),
|
|
76
|
+
components: { ...components, GlFormInput },
|
|
77
|
+
computed: {
|
|
78
|
+
state() {
|
|
79
|
+
return this.name.length >= 4;
|
|
52
80
|
},
|
|
53
|
-
|
|
54
|
-
|
|
81
|
+
invalidFeedback() {
|
|
82
|
+
let feedbackText = 'This field is required.';
|
|
55
83
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
template: `
|
|
62
|
-
<gl-form-group
|
|
63
|
-
:id="id"
|
|
64
|
-
:label="label"
|
|
65
|
-
:label-size="labelSize"
|
|
66
|
-
:optional="optional"
|
|
67
|
-
:optional-text="optionalText"
|
|
68
|
-
:description="description"
|
|
69
|
-
:horizontal="horizontal"
|
|
70
|
-
label-for="label1"
|
|
71
|
-
>
|
|
72
|
-
<gl-form-input id="input1" />
|
|
73
|
-
</gl-form-group>
|
|
74
|
-
`,
|
|
75
|
-
}))
|
|
76
|
-
.add('disabled', () => ({
|
|
77
|
-
props: generateProps(),
|
|
78
|
-
components: { ...components, GlFormInput },
|
|
79
|
-
template: `
|
|
80
|
-
<gl-form-group
|
|
81
|
-
id="group-id"
|
|
82
|
-
label="Label Name"
|
|
83
|
-
label-size="sm"
|
|
84
|
-
:optional="optional"
|
|
85
|
-
:optional-text="optionalText"
|
|
86
|
-
description="This feature is disabled"
|
|
87
|
-
label-for="input1"
|
|
88
|
-
>
|
|
89
|
-
<gl-form-input id="input1" type="text" :disabled="true" value="Disabled" />
|
|
90
|
-
</gl-form-group>
|
|
91
|
-
`,
|
|
92
|
-
}))
|
|
93
|
-
.add('with textarea', () => ({
|
|
94
|
-
components: { ...components, GlFormTextarea },
|
|
95
|
-
props: generateProps({ optional: true }),
|
|
96
|
-
template: `
|
|
97
|
-
<gl-form-group
|
|
98
|
-
id="group-id-textarea2"
|
|
99
|
-
label="Label Name"
|
|
100
|
-
label-for="textarea2"
|
|
101
|
-
:optional="optional"
|
|
102
|
-
:optional-text="optionalText"
|
|
103
|
-
>
|
|
104
|
-
<gl-form-textarea id="textarea2" placeholder="Enter something" />
|
|
105
|
-
</gl-form-group>
|
|
106
|
-
`,
|
|
107
|
-
}))
|
|
108
|
-
.add('with label description', () => ({
|
|
109
|
-
props: generateProps({ optional: true }),
|
|
110
|
-
components: { ...components, GlFormInput },
|
|
111
|
-
template: `
|
|
112
|
-
<gl-form-group
|
|
113
|
-
:id="id"
|
|
114
|
-
:label="label"
|
|
115
|
-
:label-size="labelSize"
|
|
116
|
-
:description="description"
|
|
117
|
-
:label-description="labelDescription"
|
|
118
|
-
:optional="optional"
|
|
119
|
-
:optional-text="optionalText"
|
|
120
|
-
:horizontal="horizontal"
|
|
121
|
-
label-for="label1"
|
|
122
|
-
>
|
|
123
|
-
<gl-form-input id="input1" />
|
|
124
|
-
</gl-form-group>
|
|
125
|
-
`,
|
|
126
|
-
}))
|
|
127
|
-
.add('with validations', () => ({
|
|
128
|
-
props: generateProps({ label: 'Name', description: 'Enter a first and last name.' }),
|
|
129
|
-
components: { ...components, GlFormInput },
|
|
130
|
-
computed: {
|
|
131
|
-
state() {
|
|
132
|
-
return this.name.length >= 4;
|
|
133
|
-
},
|
|
134
|
-
invalidFeedback() {
|
|
135
|
-
let feedbackText = 'This field is required.';
|
|
84
|
+
if (this.name.length > 4) {
|
|
85
|
+
feedbackText = '';
|
|
86
|
+
} else if (this.name.length > 0) {
|
|
87
|
+
feedbackText = 'Enter at least 4 characters.';
|
|
88
|
+
}
|
|
136
89
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
90
|
+
return feedbackText;
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
data() {
|
|
94
|
+
return {
|
|
95
|
+
name: '',
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
template: wrap(
|
|
99
|
+
'<gl-form-input :id="id" :state="state" v-model.trim="name" />',
|
|
100
|
+
':invalid-feedback="invalidFeedback"'
|
|
101
|
+
),
|
|
102
|
+
});
|
|
103
|
+
WithValidations.args = generateProps({
|
|
104
|
+
label: 'Name',
|
|
105
|
+
description: 'Enter a first and last name.',
|
|
106
|
+
});
|
|
142
107
|
|
|
143
|
-
|
|
108
|
+
export default {
|
|
109
|
+
title: 'base/form/form-group',
|
|
110
|
+
component: GlFormGroup,
|
|
111
|
+
parameters: {
|
|
112
|
+
bootstrapComponent: 'b-form-group',
|
|
113
|
+
docs: {
|
|
114
|
+
description: {
|
|
115
|
+
component: readme,
|
|
144
116
|
},
|
|
145
117
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
118
|
+
},
|
|
119
|
+
argTypes: {
|
|
120
|
+
...disableControls(['labelClass']),
|
|
121
|
+
label: {
|
|
122
|
+
control: { type: 'text' },
|
|
150
123
|
},
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
:id="id"
|
|
154
|
-
:label="label"
|
|
155
|
-
:label-size="labelSize"
|
|
156
|
-
:description="description"
|
|
157
|
-
:invalid-feedback="invalidFeedback"
|
|
158
|
-
:state="state"
|
|
159
|
-
label-for="label1"
|
|
160
|
-
>
|
|
161
|
-
<gl-form-input id="input1" :state="state" v-model.trim="name" />
|
|
162
|
-
</gl-form-group>
|
|
163
|
-
`,
|
|
164
|
-
}));
|
|
124
|
+
},
|
|
125
|
+
};
|
|
@@ -1,96 +1,6 @@
|
|
|
1
|
-
import examples from './examples';
|
|
2
1
|
import description from './search_box_by_click.md';
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
4
|
followsDesignSystem: true,
|
|
6
5
|
description,
|
|
7
|
-
examples,
|
|
8
|
-
propsInfo: {
|
|
9
|
-
value: {
|
|
10
|
-
additionalInfo: 'If provided, used as value of search input',
|
|
11
|
-
},
|
|
12
|
-
historyItems: {
|
|
13
|
-
type: Array,
|
|
14
|
-
required: false,
|
|
15
|
-
additionalInfo: 'If provided, used as history items for this component',
|
|
16
|
-
},
|
|
17
|
-
placeholder: {
|
|
18
|
-
type: String,
|
|
19
|
-
required: false,
|
|
20
|
-
additionalInfo: 'If provided, used as history items for this component',
|
|
21
|
-
},
|
|
22
|
-
disabled: {
|
|
23
|
-
type: Boolean,
|
|
24
|
-
required: false,
|
|
25
|
-
additionalInfo: 'If provided and true, disables the input and controls',
|
|
26
|
-
},
|
|
27
|
-
recentSearchesHeader: {
|
|
28
|
-
type: String,
|
|
29
|
-
required: false,
|
|
30
|
-
default: 'Recent searches',
|
|
31
|
-
additionalInfo: 'i18n for recent searches title within history dropdown',
|
|
32
|
-
},
|
|
33
|
-
clearButtonTitle: {
|
|
34
|
-
type: String,
|
|
35
|
-
required: false,
|
|
36
|
-
default: 'Clear',
|
|
37
|
-
additionalInfo: 'i18n for clear button title',
|
|
38
|
-
},
|
|
39
|
-
closeButtonTitle: {
|
|
40
|
-
type: String,
|
|
41
|
-
required: false,
|
|
42
|
-
default: 'Close',
|
|
43
|
-
additionalInfo: 'i18n for close button title within history dropdown',
|
|
44
|
-
},
|
|
45
|
-
clearRecentSearchesText: {
|
|
46
|
-
type: String,
|
|
47
|
-
required: false,
|
|
48
|
-
default: 'Clear recent searches',
|
|
49
|
-
additionalInfo: 'i18n for recent searches clear text',
|
|
50
|
-
},
|
|
51
|
-
tooltipContainer: {
|
|
52
|
-
additionalInfo:
|
|
53
|
-
'Container for tooltip. Valid values: DOM node, selector string or `false` for default',
|
|
54
|
-
},
|
|
55
|
-
searchButtonAttributes: {
|
|
56
|
-
additionalInfo: 'HTML attributes to add to the search button',
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
events: [
|
|
60
|
-
{
|
|
61
|
-
event: 'clear',
|
|
62
|
-
description: 'Emitted when search is cleared',
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
event: 'submit',
|
|
66
|
-
args: [
|
|
67
|
-
{
|
|
68
|
-
arg: 'value',
|
|
69
|
-
description: 'Search value',
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
description: 'Emitted when search is submitted',
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
event: 'history-item-selected',
|
|
76
|
-
args: [
|
|
77
|
-
{
|
|
78
|
-
arg: 'value',
|
|
79
|
-
description: 'History item',
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
description: 'Emitted when item from history is selected',
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
event: 'clear-history',
|
|
86
|
-
description: 'Emitted when clear history button is clicked',
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
slots: [
|
|
90
|
-
{
|
|
91
|
-
name: 'history-item',
|
|
92
|
-
description:
|
|
93
|
-
'Slot to customize history item in history dropdown. Used only with history-items prop',
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
6
|
};
|
|
@@ -1,57 +1,100 @@
|
|
|
1
|
-
import { withKnobs, boolean, text } from '@storybook/addon-knobs';
|
|
2
|
-
import { documentedStoriesOf } from '../../../../documentation/documented_stories';
|
|
3
1
|
import { GlSearchBoxByClick } from '../../../index';
|
|
2
|
+
import { disableControls } from '../../../utils/stories_utils';
|
|
4
3
|
import readme from './search_box_by_click.md';
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const template = `
|
|
6
|
+
<gl-search-box-by-click
|
|
7
|
+
:value="value"
|
|
8
|
+
:disabled="disabled"
|
|
9
|
+
:placeholder="placeholder"
|
|
10
|
+
:history-items="currentHistoryItems"
|
|
11
|
+
:clearable="clearable"
|
|
12
|
+
:recent-searches-header="recentSearchesHeader"
|
|
13
|
+
:clear-button-title="clearButtonTitle"
|
|
14
|
+
:close-button-title="closeButtonTitle"
|
|
15
|
+
:clear-recent-searches-text="clearRecentSearchesText"
|
|
16
|
+
:no-recent-searches-text="noRecentSearchesText"
|
|
17
|
+
:search-button-attributes="searchButtonAttributes"
|
|
18
|
+
@clear-history="clearCurrentHistory"
|
|
19
|
+
/>
|
|
20
|
+
`;
|
|
9
21
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
const defaultValue = (prop) => GlSearchBoxByClick.props[prop].default;
|
|
23
|
+
|
|
24
|
+
const generateProps = ({
|
|
25
|
+
disabled = defaultValue('disabled'),
|
|
26
|
+
value = defaultValue('value'),
|
|
27
|
+
placeholder = defaultValue('placeholder'),
|
|
28
|
+
historyItems = defaultValue('historyItems'),
|
|
29
|
+
clearable = defaultValue('clearable'),
|
|
30
|
+
recentSearchesHeader = defaultValue('recentSearchesHeader'),
|
|
31
|
+
clearButtonTitle = defaultValue('clearButtonTitle'),
|
|
32
|
+
closeButtonTitle = defaultValue('closeButtonTitle'),
|
|
33
|
+
clearRecentSearchesText = defaultValue('clearRecentSearchesText'),
|
|
34
|
+
noRecentSearchesText = defaultValue('noRecentSearchesText'),
|
|
35
|
+
searchButtonAttributes = defaultValue('searchButtonAttributes')(),
|
|
36
|
+
} = {}) => ({
|
|
37
|
+
disabled,
|
|
38
|
+
value,
|
|
39
|
+
placeholder,
|
|
40
|
+
historyItems,
|
|
41
|
+
clearable,
|
|
42
|
+
recentSearchesHeader,
|
|
43
|
+
clearButtonTitle,
|
|
44
|
+
closeButtonTitle,
|
|
45
|
+
clearRecentSearchesText,
|
|
46
|
+
noRecentSearchesText,
|
|
47
|
+
searchButtonAttributes,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const Template = (args, { argTypes }) => ({
|
|
51
|
+
components: {
|
|
52
|
+
GlSearchBoxByClick,
|
|
53
|
+
},
|
|
54
|
+
props: Object.keys(argTypes),
|
|
55
|
+
template,
|
|
56
|
+
data() {
|
|
57
|
+
return {
|
|
58
|
+
currentHistoryItems: this.historyItems,
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
watch: {
|
|
62
|
+
historyItems(historyItems) {
|
|
63
|
+
this.currentHistoryItems = historyItems;
|
|
19
64
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
65
|
+
},
|
|
66
|
+
methods: {
|
|
67
|
+
clearCurrentHistory() {
|
|
68
|
+
this.currentHistoryItems = [];
|
|
23
69
|
},
|
|
24
|
-
}
|
|
25
|
-
}
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export const Default = Template.bind({});
|
|
74
|
+
Default.args = generateProps();
|
|
26
75
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
76
|
+
export const History = Template.bind({});
|
|
77
|
+
History.args = generateProps({
|
|
78
|
+
historyItems: ['author:@admin', 'assignee:@admin milestone:%12.5', 'label:~test'],
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export default {
|
|
82
|
+
title: 'base/search-box-by-click',
|
|
83
|
+
component: GlSearchBoxByClick,
|
|
84
|
+
parameters: {
|
|
85
|
+
knobs: { disable: true },
|
|
86
|
+
docs: {
|
|
87
|
+
description: {
|
|
88
|
+
component: readme,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
argTypes: {
|
|
93
|
+
...disableControls(['tooltipContainer']),
|
|
94
|
+
historyItems: {
|
|
95
|
+
control: {
|
|
96
|
+
type: 'object',
|
|
46
97
|
},
|
|
47
98
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<gl-search-box-by-click
|
|
51
|
-
:value="value"
|
|
52
|
-
:disabled="disabled"
|
|
53
|
-
:placeholder="placeholder"
|
|
54
|
-
:history-items="history"
|
|
55
|
-
/>
|
|
56
|
-
`,
|
|
57
|
-
}));
|
|
99
|
+
},
|
|
100
|
+
};
|