@gitlab/ui 37.1.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 +22 -0
- package/dist/components/base/form/form_group/form_group.documentation.js +2 -6
- package/dist/components/base/form/form_input_group/form_input_group.documentation.js +2 -26
- package/dist/components/base/form/form_input_group/form_input_group.js +7 -0
- package/dist/components/base/loading_icon/loading_icon.js +1 -1
- package/dist/components/base/pagination/pagination.js +22 -2
- package/dist/components/base/path/path.js +9 -3
- 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/directives/safe_html/safe_html.documentation.js +1 -1
- package/dist/directives/safe_link/safe_link.documentation.js +2 -3
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/documentation/documented_stories.js +8 -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/form/form_input_group/form_input_group.documentation.js +0 -28
- package/src/components/base/form/form_input_group/form_input_group.md +0 -4
- package/src/components/base/form/form_input_group/form_input_group.stories.js +84 -62
- package/src/components/base/form/form_input_group/form_input_group.vue +9 -0
- package/src/components/base/loading_icon/loading_icon.vue +1 -1
- package/src/components/base/pagination/pagination.spec.js +9 -2
- package/src/components/base/pagination/pagination.vue +22 -6
- package/src/components/base/path/path.spec.js +12 -0
- package/src/components/base/path/path.vue +8 -3
- 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/components/base/tabs/tabs/tabs.stories.js +2 -4
- 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/src/directives/safe_html/safe_html.md +0 -4
- package/src/directives/safe_html/safe_html.stories.js +53 -44
- package/src/directives/safe_link/safe_link.documentation.js +0 -1
- package/src/directives/safe_link/safe_link.md +0 -4
- package/src/directives/safe_link/safe_link.stories.js +31 -30
- package/src/scss/utilities.scss +8 -0
- package/src/scss/utility-mixins/background.scss +4 -0
- 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/form/form_input_group/examples/form_input_group.basic.example.js +0 -38
- package/dist/components/base/form/form_input_group/examples/form_input_group.predefined_options.example.js +0 -54
- package/dist/components/base/form/form_input_group/examples/form_input_group.predefined_reactive.example.js +0 -55
- package/dist/components/base/form/form_input_group/examples/form_input_group.reactive.example.js +0 -48
- package/dist/components/base/form/form_input_group/examples/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/form/form_input_group/examples/form_input_group.basic.example.vue +0 -10
- package/src/components/base/form/form_input_group/examples/form_input_group.predefined_options.example.vue +0 -25
- package/src/components/base/form/form_input_group/examples/form_input_group.predefined_reactive.example.vue +0 -32
- package/src/components/base/form/form_input_group/examples/form_input_group.reactive.example.vue +0 -25
- package/src/components/base/form/form_input_group/examples/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
|
@@ -77,6 +77,7 @@ export const setupStorybookReadme = () =>
|
|
|
77
77
|
'GlSorting',
|
|
78
78
|
'GlSortingItem',
|
|
79
79
|
'GlIcon',
|
|
80
|
+
'GlSafeLinkDirective',
|
|
80
81
|
'GlDashboardSkeleton',
|
|
81
82
|
'GlToggle',
|
|
82
83
|
'GlNavbar',
|
|
@@ -92,6 +93,7 @@ export const setupStorybookReadme = () =>
|
|
|
92
93
|
'GlIntersperse',
|
|
93
94
|
'GlFormSelect',
|
|
94
95
|
'GlDaterangePicker',
|
|
96
|
+
'GlFormGroup',
|
|
95
97
|
'GlAvatarLabeled',
|
|
96
98
|
'GlBarChart',
|
|
97
99
|
'GlCarousel',
|
|
@@ -107,12 +109,15 @@ export const setupStorybookReadme = () =>
|
|
|
107
109
|
'GlPagination',
|
|
108
110
|
'GlSkeletonLoader',
|
|
109
111
|
'GlLabel',
|
|
112
|
+
'GlHoverLoadDirective',
|
|
110
113
|
'GlStackedColumnChart',
|
|
111
114
|
'GlDiscreteScatterChart',
|
|
115
|
+
'GlResizeObserverDirective',
|
|
112
116
|
'GlFormCombobox',
|
|
113
117
|
'GlChartTooltip',
|
|
114
118
|
'GlInputGroupText',
|
|
115
119
|
'GlGaugeChart',
|
|
120
|
+
'GlSafeHtmlDirective',
|
|
116
121
|
'GlFormRadio',
|
|
117
122
|
'GlModal',
|
|
118
123
|
'GlKeysetPagination',
|
|
@@ -127,6 +132,7 @@ export const setupStorybookReadme = () =>
|
|
|
127
132
|
'GlColumnChart',
|
|
128
133
|
'GlTruncate',
|
|
129
134
|
'GlNav',
|
|
135
|
+
'GlSearchBoxByType',
|
|
130
136
|
'GlNavItem',
|
|
131
137
|
'GlNavItemDropdown',
|
|
132
138
|
'GlPopover',
|
|
@@ -137,6 +143,8 @@ export const setupStorybookReadme = () =>
|
|
|
137
143
|
'GlChartSeriesLabel',
|
|
138
144
|
'GlAreaChart',
|
|
139
145
|
'GlLineChart',
|
|
146
|
+
'GlFormInputGroup',
|
|
147
|
+
'GlSearchBoxByClick',
|
|
140
148
|
],
|
|
141
149
|
components: {
|
|
142
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,34 +1,6 @@
|
|
|
1
|
-
import examples from './examples';
|
|
2
1
|
import description from './form_input_group.md';
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
4
|
followsDesignSystem: false,
|
|
6
5
|
description,
|
|
7
|
-
examples,
|
|
8
|
-
bootstrapComponent: 'b-form-input',
|
|
9
|
-
propsInfo: {
|
|
10
|
-
'select-on-click': {
|
|
11
|
-
type: Boolean,
|
|
12
|
-
additionalInfo: 'Automatically selects the content of the input field on click',
|
|
13
|
-
},
|
|
14
|
-
'predefined-options': {
|
|
15
|
-
type: Array,
|
|
16
|
-
additionalInfo:
|
|
17
|
-
'Array of options. Each option should have `name` and `value` information: {name: "Foo", value: "Bar"})',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
slots: [
|
|
21
|
-
{
|
|
22
|
-
name: 'default',
|
|
23
|
-
description: 'Allows replacement of default input field.',
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: 'prepend',
|
|
27
|
-
description: 'Is rendered in front of the input field.',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: 'append',
|
|
31
|
-
description: 'Is rendered after the input field.',
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
6
|
};
|
|
@@ -1,73 +1,95 @@
|
|
|
1
|
-
import { withKnobs, boolean, object, text } from '@storybook/addon-knobs';
|
|
2
|
-
import { documentedStoriesOf } from '../../../../../documentation/documented_stories';
|
|
3
1
|
import { GlFormInputGroup, GlInputGroupText } from '../../../../index';
|
|
2
|
+
import { disableControls } from '../../../../utils/stories_utils';
|
|
4
3
|
import readme from './form_input_group.md';
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
const template = `
|
|
6
|
+
<gl-form-input-group
|
|
7
|
+
:readonly="readonly"
|
|
8
|
+
:select-on-click="selectOnClick"
|
|
9
|
+
:predefined-options="predefinedOptions"
|
|
10
|
+
:label="label"
|
|
11
|
+
:inputClass="inputClass">
|
|
12
|
+
<template #prepend v-if="prepend">
|
|
13
|
+
<gl-input-group-text>{{prepend}}</gl-input-group-text>
|
|
14
|
+
</template>
|
|
15
|
+
<template #append v-if="append">
|
|
16
|
+
<gl-input-group-text>{{append}}</gl-input-group-text>
|
|
17
|
+
</template>
|
|
18
|
+
</gl-form-input-group>
|
|
19
|
+
`;
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
const defaultValue = (prop) => GlFormInputGroup.props[prop].default;
|
|
22
|
+
|
|
23
|
+
const generateProps = ({
|
|
24
|
+
prepend = 'Username',
|
|
25
|
+
append = 'Add',
|
|
26
|
+
readonly = false,
|
|
27
|
+
selectOnClick = false,
|
|
28
|
+
predefinedOptions = defaultValue('predefinedOptions')(),
|
|
29
|
+
label = '',
|
|
30
|
+
inputClass = '',
|
|
31
|
+
} = {}) => ({
|
|
32
|
+
prepend,
|
|
33
|
+
append,
|
|
34
|
+
readonly,
|
|
35
|
+
selectOnClick,
|
|
36
|
+
predefinedOptions,
|
|
37
|
+
label,
|
|
38
|
+
inputClass,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const Template = (args, { argTypes }) => ({
|
|
42
|
+
components: { GlFormInputGroup, GlInputGroupText },
|
|
43
|
+
props: Object.keys(argTypes),
|
|
44
|
+
template,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const Default = Template.bind({});
|
|
48
|
+
Default.args = generateProps();
|
|
49
|
+
|
|
50
|
+
export const PredefinedOptions = Template.bind({});
|
|
51
|
+
PredefinedOptions.args = generateProps({
|
|
52
|
+
prepend: '',
|
|
53
|
+
predefinedOptions: [
|
|
54
|
+
{ name: 'Embed', value: 'https://embed.com' },
|
|
55
|
+
{ name: 'Share', value: 'https://share.org' },
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export default {
|
|
60
|
+
title: 'base/form/form-input-group',
|
|
61
|
+
component: GlFormInputGroup,
|
|
62
|
+
knobs: { disabled: true },
|
|
63
|
+
parameters: {
|
|
64
|
+
bootstrapComponent: 'b-form-input',
|
|
65
|
+
docs: {
|
|
66
|
+
description: {
|
|
67
|
+
component: readme,
|
|
31
68
|
},
|
|
32
69
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
</template>
|
|
41
|
-
</gl-form-input-group>
|
|
42
|
-
`,
|
|
43
|
-
}))
|
|
44
|
-
.add('with predefined options', () => ({
|
|
45
|
-
components,
|
|
46
|
-
props: {
|
|
47
|
-
prepend: {
|
|
48
|
-
default: text('Prepend text', ''),
|
|
70
|
+
knobs: { disabled: true },
|
|
71
|
+
},
|
|
72
|
+
argTypes: {
|
|
73
|
+
...disableControls(['value']),
|
|
74
|
+
prepend: {
|
|
75
|
+
control: {
|
|
76
|
+
type: 'text',
|
|
49
77
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
default: boolean('Readonly', false),
|
|
78
|
+
},
|
|
79
|
+
append: {
|
|
80
|
+
control: {
|
|
81
|
+
type: 'text',
|
|
55
82
|
},
|
|
56
|
-
|
|
57
|
-
|
|
83
|
+
},
|
|
84
|
+
inputClass: {
|
|
85
|
+
control: {
|
|
86
|
+
type: 'text',
|
|
58
87
|
},
|
|
59
|
-
|
|
60
|
-
|
|
88
|
+
},
|
|
89
|
+
label: {
|
|
90
|
+
control: {
|
|
91
|
+
type: 'text',
|
|
61
92
|
},
|
|
62
93
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
<template #prepend v-if="prepend">
|
|
66
|
-
<gl-input-group-text>{{prepend}}</gl-input-group-text>
|
|
67
|
-
</template>
|
|
68
|
-
<template #append v-if="append">
|
|
69
|
-
<gl-input-group-text>{{append}}</gl-input-group-text>
|
|
70
|
-
</template>
|
|
71
|
-
</gl-form-input-group>
|
|
72
|
-
`,
|
|
73
|
-
}));
|
|
94
|
+
},
|
|
95
|
+
};
|
|
@@ -16,11 +16,17 @@ export default {
|
|
|
16
16
|
},
|
|
17
17
|
mixins: [InputGroupMixin],
|
|
18
18
|
props: {
|
|
19
|
+
/**
|
|
20
|
+
* Automatically selects the content of the input field on click.
|
|
21
|
+
*/
|
|
19
22
|
selectOnClick: {
|
|
20
23
|
type: Boolean,
|
|
21
24
|
required: false,
|
|
22
25
|
default: false,
|
|
23
26
|
},
|
|
27
|
+
/**
|
|
28
|
+
* Array of options. Each option should have `name` and `value` information: {name: "Foo", value: "Bar"})
|
|
29
|
+
*/
|
|
24
30
|
predefinedOptions: {
|
|
25
31
|
type: Array,
|
|
26
32
|
required: false,
|
|
@@ -61,6 +67,7 @@ export default {
|
|
|
61
67
|
<div>
|
|
62
68
|
<b-input-group>
|
|
63
69
|
<b-input-group-prepend v-if="activeOption || $scopedSlots.prepend">
|
|
70
|
+
<!-- @slot Is rendered in front of the input field. -->
|
|
64
71
|
<slot name="prepend"></slot>
|
|
65
72
|
<gl-dropdown v-if="activeOption" :text="activeOption">
|
|
66
73
|
<gl-dropdown-item
|
|
@@ -74,6 +81,7 @@ export default {
|
|
|
74
81
|
</gl-dropdown-item>
|
|
75
82
|
</gl-dropdown>
|
|
76
83
|
</b-input-group-prepend>
|
|
84
|
+
<!-- @slot Allows replacement of default input field. -->
|
|
77
85
|
<slot>
|
|
78
86
|
<b-form-input
|
|
79
87
|
ref="input"
|
|
@@ -86,6 +94,7 @@ export default {
|
|
|
86
94
|
/>
|
|
87
95
|
</slot>
|
|
88
96
|
<b-input-group-append v-if="$scopedSlots.append">
|
|
97
|
+
<!-- @slot Is rendered after the input field. -->
|
|
89
98
|
<slot name="append"></slot>
|
|
90
99
|
</b-input-group-append>
|
|
91
100
|
</b-input-group>
|
|
@@ -64,6 +64,6 @@ export default {
|
|
|
64
64
|
</script>
|
|
65
65
|
<template>
|
|
66
66
|
<component :is="rootElementType" class="gl-spinner-container" role="status">
|
|
67
|
-
<span :class="cssClasses" class="align-text-bottom" :aria-label="label"></span>
|
|
67
|
+
<span :class="cssClasses" class="gl-vertical-align-text-bottom!" :aria-label="label"></span>
|
|
68
68
|
</component>
|
|
69
69
|
</template>
|
|
@@ -16,6 +16,7 @@ const mockResizeWidth = (width) => {
|
|
|
16
16
|
describe('pagination component', () => {
|
|
17
17
|
let wrapper;
|
|
18
18
|
const findButtons = () => wrapper.findAll('.page-link');
|
|
19
|
+
const findItems = () => wrapper.findAll('.page-item');
|
|
19
20
|
const propsData = {
|
|
20
21
|
value: 3,
|
|
21
22
|
perPage: 5,
|
|
@@ -375,9 +376,12 @@ describe('pagination component', () => {
|
|
|
375
376
|
value: 1,
|
|
376
377
|
nextPage: 2,
|
|
377
378
|
});
|
|
379
|
+
const prevItem = findItems().at(0);
|
|
380
|
+
expect(prevItem.attributes('aria-hidden')).toBe('true');
|
|
378
381
|
const prevButton = findButtons().at(0);
|
|
379
382
|
expect(prevButton.element.tagName).toBe('SPAN');
|
|
380
|
-
expect(prevButton.attributes('
|
|
383
|
+
expect(prevButton.attributes('href')).toBeUndefined();
|
|
384
|
+
expect(prevButton.attributes('aria-label')).toBeUndefined();
|
|
381
385
|
});
|
|
382
386
|
|
|
383
387
|
it('disables next button when on last page', () => {
|
|
@@ -386,9 +390,12 @@ describe('pagination component', () => {
|
|
|
386
390
|
value: 2,
|
|
387
391
|
prevPage: 1,
|
|
388
392
|
});
|
|
393
|
+
const nextItem = findItems().at(1);
|
|
394
|
+
expect(nextItem.attributes('aria-hidden')).toBe('true');
|
|
389
395
|
const nextButton = findButtons().at(1);
|
|
390
396
|
expect(nextButton.element.tagName).toBe('SPAN');
|
|
391
|
-
expect(nextButton.attributes('
|
|
397
|
+
expect(nextButton.attributes('href')).toBeUndefined();
|
|
398
|
+
expect(nextButton.attributes('aria-label')).toBeUndefined();
|
|
392
399
|
});
|
|
393
400
|
});
|
|
394
401
|
});
|