@gitlab/ui 32.48.0 → 32.51.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/form/form.documentation.js +1 -5
- package/dist/components/base/form/form_radio/form_radio.documentation.js +2 -33
- package/dist/components/base/form/form_radio/form_radio.js +15 -2
- package/dist/components/base/form/form_select/form_select.documentation.js +2 -17
- package/dist/components/base/keyset_pagination/keyset_pagination.documentation.js +2 -84
- package/dist/components/base/keyset_pagination/keyset_pagination.js +42 -0
- package/dist/components/base/modal/modal.documentation.js +2 -32
- package/dist/components/base/modal/modal.js +15 -1
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/dist/utils/string_utils.js +6 -2
- package/documentation/documented_stories.js +5 -0
- package/package.json +5 -3
- package/scss_to_js/scss_variables.js +2 -0
- package/scss_to_js/scss_variables.json +10 -0
- package/src/components/base/form/form.documentation.js +0 -3
- package/src/components/base/form/form.stories.js +99 -14
- package/src/components/base/form/form_radio/form_radio.documentation.js +0 -31
- package/src/components/base/form/form_radio/form_radio.md +7 -14
- package/src/components/base/form/form_radio/form_radio.stories.js +40 -28
- package/src/components/base/form/form_radio/form_radio.vue +26 -1
- package/src/components/base/form/form_select/form_select.documentation.js +0 -19
- package/src/components/base/form/form_select/form_select.md +0 -2
- package/src/components/base/form/form_select/form_select.stories.js +98 -80
- package/src/components/base/keyset_pagination/keyset_pagination.documentation.js +0 -99
- package/src/components/base/keyset_pagination/keyset_pagination.md +0 -2
- package/src/components/base/keyset_pagination/keyset_pagination.stories.js +60 -58
- package/src/components/base/keyset_pagination/keyset_pagination.vue +35 -1
- package/src/components/base/modal/modal.documentation.js +0 -42
- package/src/components/base/modal/modal.md +2 -7
- package/src/components/base/modal/modal.stories.js +107 -85
- package/src/components/base/modal/modal.vue +73 -32
- package/src/scss/utilities.scss +16 -0
- package/src/scss/utility-mixins/sizing.scss +8 -0
- package/src/scss/variables.scss +2 -0
- package/src/utils/string_utils.js +6 -2
- package/src/utils/string_utils.spec.js +8 -0
- package/dist/components/base/form/examples/form.basic.example.js +0 -76
- package/dist/components/base/form/examples/form.edit.example.js +0 -66
- package/dist/components/base/form/examples/form.inline.example.js +0 -62
- package/dist/components/base/form/examples/form.novalidate.example.js +0 -61
- package/dist/components/base/form/examples/index.js +0 -27
- package/dist/components/base/form/form_radio/examples/form_radio.basic.example.js +0 -48
- package/dist/components/base/form/form_radio/examples/form_radio.checked_disabled.example.js +0 -48
- package/dist/components/base/form/form_radio/examples/index.js +0 -19
- package/dist/components/base/form/form_select/examples/form_select.basic.example.js +0 -55
- package/dist/components/base/form/form_select/examples/form_select.disabled.example.js +0 -55
- package/dist/components/base/form/form_select/examples/form_select.manual_options.example.js +0 -48
- package/dist/components/base/form/form_select/examples/form_select.mixed_options.example.js +0 -55
- package/dist/components/base/form/form_select/examples/index.js +0 -27
- package/dist/components/base/keyset_pagination/examples/index.js +0 -37
- package/dist/components/base/keyset_pagination/examples/keyset_pagination.basic.example.js +0 -51
- package/dist/components/base/keyset_pagination/examples/keyset_pagination.events.example.js +0 -64
- package/dist/components/base/keyset_pagination/examples/keyset_pagination.internationalization.example.js +0 -59
- package/dist/components/base/keyset_pagination/examples/keyset_pagination.links.example.js +0 -51
- package/dist/components/base/keyset_pagination/examples/keyset_pagination.slots.example.js +0 -51
- package/dist/components/base/modal/examples/index.js +0 -31
- package/dist/components/base/modal/examples/modal.basic.example.js +0 -62
- package/dist/components/base/modal/examples/modal.disabled.example.js +0 -89
- package/dist/components/base/modal/examples/modal.sizes.example.js +0 -62
- package/src/components/base/form/examples/form.basic.example.vue +0 -73
- package/src/components/base/form/examples/form.edit.example.vue +0 -37
- package/src/components/base/form/examples/form.inline.example.vue +0 -36
- package/src/components/base/form/examples/form.novalidate.example.vue +0 -30
- package/src/components/base/form/examples/index.js +0 -32
- package/src/components/base/form/form_radio/examples/form_radio.basic.example.vue +0 -16
- package/src/components/base/form/form_radio/examples/form_radio.checked_disabled.example.vue +0 -13
- package/src/components/base/form/form_radio/examples/index.js +0 -22
- package/src/components/base/form/form_select/examples/form_select.basic.example.vue +0 -17
- package/src/components/base/form/form_select/examples/form_select.disabled.example.vue +0 -17
- package/src/components/base/form/form_select/examples/form_select.manual_options.example.vue +0 -17
- package/src/components/base/form/form_select/examples/form_select.mixed_options.example.vue +0 -21
- package/src/components/base/form/form_select/examples/index.js +0 -32
- package/src/components/base/keyset_pagination/examples/index.js +0 -43
- package/src/components/base/keyset_pagination/examples/keyset_pagination.basic.example.vue +0 -16
- package/src/components/base/keyset_pagination/examples/keyset_pagination.events.example.vue +0 -29
- package/src/components/base/keyset_pagination/examples/keyset_pagination.internationalization.example.vue +0 -23
- package/src/components/base/keyset_pagination/examples/keyset_pagination.links.example.vue +0 -20
- package/src/components/base/keyset_pagination/examples/keyset_pagination.slots.example.vue +0 -23
- package/src/components/base/modal/examples/index.js +0 -39
- package/src/components/base/modal/examples/modal.basic.example.vue +0 -39
- package/src/components/base/modal/examples/modal.disabled.example.vue +0 -58
- package/src/components/base/modal/examples/modal.sizes.example.vue +0 -61
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import emojiRegexFactory from 'emoji-regex';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Split the given string after each occurrence of each of the given symbols.
|
|
3
5
|
*
|
|
@@ -16,6 +18,7 @@
|
|
|
16
18
|
* @param {string} string The string to split.
|
|
17
19
|
* @returns {string[]} The resulting strings.
|
|
18
20
|
*/
|
|
21
|
+
|
|
19
22
|
const splitAfterSymbols = (symbols, string) => {
|
|
20
23
|
const textParts = [];
|
|
21
24
|
let textPartStartIndex = 0;
|
|
@@ -60,10 +63,11 @@ const splitAfterSymbols = (symbols, string) => {
|
|
|
60
63
|
|
|
61
64
|
return textParts;
|
|
62
65
|
};
|
|
66
|
+
const startsWithEmojiRegex = `^(${emojiRegexFactory().source})`;
|
|
63
67
|
const getAvatarChar = name => {
|
|
64
68
|
if (name) {
|
|
65
|
-
// Check if
|
|
66
|
-
const match = name.match(
|
|
69
|
+
// Check if string starts with an emoji (which could be multiple characters and zero-width joined)
|
|
70
|
+
const match = name.match(startsWithEmojiRegex);
|
|
67
71
|
|
|
68
72
|
if (match) {
|
|
69
73
|
// Return the first match
|
|
@@ -90,6 +90,7 @@ export const setupStorybookReadme = () =>
|
|
|
90
90
|
'GlAccordion',
|
|
91
91
|
'GlAccordionItem',
|
|
92
92
|
'GlIntersperse',
|
|
93
|
+
'GlFormSelect',
|
|
93
94
|
'GlDaterangePicker',
|
|
94
95
|
'GlAvatarLabeled',
|
|
95
96
|
'GlBarChart',
|
|
@@ -111,6 +112,10 @@ export const setupStorybookReadme = () =>
|
|
|
111
112
|
'GlChartTooltip',
|
|
112
113
|
'GlInputGroupText',
|
|
113
114
|
'GlGaugeChart',
|
|
115
|
+
'GlFormRadio',
|
|
116
|
+
'GlModal',
|
|
117
|
+
'GlKeysetPagination',
|
|
118
|
+
'GlForm',
|
|
114
119
|
],
|
|
115
120
|
components: {
|
|
116
121
|
GlComponentDocumentation,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.51.1",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -71,7 +71,8 @@
|
|
|
71
71
|
"vue-runtime-helpers": "^1.1.2"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@gitlab/svgs": "^1.116.0",
|
|
74
|
+
"@gitlab/svgs": "^1.116.0 || ^2.0.0",
|
|
75
|
+
"emoji-regex": ">=10.0.0",
|
|
75
76
|
"bootstrap": "4.5.3",
|
|
76
77
|
"pikaday": "^1.8.0",
|
|
77
78
|
"vue": "^2.6.10"
|
|
@@ -85,7 +86,7 @@
|
|
|
85
86
|
"@babel/preset-env": "^7.10.2",
|
|
86
87
|
"@gitlab/eslint-plugin": "10.0.0",
|
|
87
88
|
"@gitlab/stylelint-config": "2.6.0",
|
|
88
|
-
"@gitlab/svgs": "
|
|
89
|
+
"@gitlab/svgs": "2.0.0",
|
|
89
90
|
"@rollup/plugin-commonjs": "^11.1.0",
|
|
90
91
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
91
92
|
"@rollup/plugin-replace": "^2.3.2",
|
|
@@ -107,6 +108,7 @@
|
|
|
107
108
|
"babel-preset-vue": "^2.0.2",
|
|
108
109
|
"bootstrap": "4.5.3",
|
|
109
110
|
"cypress": "^6.6.0",
|
|
111
|
+
"emoji-regex": "^10.0.0",
|
|
110
112
|
"eslint": "7.32.0",
|
|
111
113
|
"eslint-import-resolver-jest": "3.0.2",
|
|
112
114
|
"eslint-plugin-cypress": "2.12.1",
|
|
@@ -15,6 +15,8 @@ export const glSpacingScale12 = '5rem'
|
|
|
15
15
|
export const glSpacingScale13 = '6rem'
|
|
16
16
|
export const glSpacingScale15 = '7.5rem'
|
|
17
17
|
export const glSpacingScale20 = '10rem'
|
|
18
|
+
export const glSpacingScale26 = '13rem'
|
|
19
|
+
export const glSpacingScale62 = '31rem'
|
|
18
20
|
export const breakpointSm = '576px'
|
|
19
21
|
export const breakpointMd = '768px'
|
|
20
22
|
export const breakpointLg = '992px'
|
|
@@ -85,6 +85,16 @@
|
|
|
85
85
|
"value": "20 * $grid-size",
|
|
86
86
|
"compiledValue": "10rem"
|
|
87
87
|
},
|
|
88
|
+
{
|
|
89
|
+
"name": "$gl-spacing-scale-26",
|
|
90
|
+
"value": "26 * $grid-size",
|
|
91
|
+
"compiledValue": "13rem"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "$gl-spacing-scale-62",
|
|
95
|
+
"value": "62 * $grid-size",
|
|
96
|
+
"compiledValue": "31rem"
|
|
97
|
+
},
|
|
88
98
|
{
|
|
89
99
|
"name": "$breakpoint-sm",
|
|
90
100
|
"value": "576px",
|
|
@@ -1,17 +1,102 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
GlForm,
|
|
3
|
+
GlFormGroup,
|
|
4
|
+
GlFormInput,
|
|
5
|
+
GlFormSelect,
|
|
6
|
+
GlFormCheckbox,
|
|
7
|
+
GlButton,
|
|
8
|
+
} from '../../../../index';
|
|
9
|
+
import { setStoryTimeout } from '../../../utils/test_utils';
|
|
4
10
|
import readme from './form.md';
|
|
5
11
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
export const Default = (args) => ({
|
|
13
|
+
components: {
|
|
14
|
+
GlForm,
|
|
15
|
+
GlFormGroup,
|
|
16
|
+
GlFormInput,
|
|
17
|
+
GlFormSelect,
|
|
18
|
+
GlFormCheckbox,
|
|
19
|
+
GlButton,
|
|
20
|
+
},
|
|
21
|
+
props: Object.keys(args),
|
|
22
|
+
data() {
|
|
23
|
+
return {
|
|
24
|
+
form: {
|
|
25
|
+
submitDisabled: false,
|
|
26
|
+
email: '',
|
|
27
|
+
name: '',
|
|
28
|
+
mergeState: null,
|
|
29
|
+
checked: [],
|
|
30
|
+
},
|
|
31
|
+
states: [{ text: 'Select One', value: null }, 'Open', 'Resolved', 'Closed', 'Blocked'],
|
|
32
|
+
show: true,
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
methods: {
|
|
36
|
+
onReset() {
|
|
37
|
+
this.form.name = '';
|
|
38
|
+
this.form.submitDisabled = false;
|
|
39
|
+
},
|
|
40
|
+
onSubmit(evt) {
|
|
41
|
+
evt.preventDefault();
|
|
42
|
+
this.form.submitDisabled = true;
|
|
43
|
+
setStoryTimeout(() => {
|
|
44
|
+
this.form.submitDisabled = false;
|
|
45
|
+
// eslint-disable-next-line no-alert
|
|
46
|
+
alert(JSON.stringify(this.form));
|
|
47
|
+
}, 1000);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
template: `
|
|
51
|
+
<gl-form @submit="onSubmit" @reset="onReset">
|
|
52
|
+
<gl-form-group
|
|
53
|
+
id="input-group-1"
|
|
54
|
+
label="Email address:"
|
|
55
|
+
label-for="input-1"
|
|
56
|
+
description="We'll never share your email with anyone else."
|
|
57
|
+
>
|
|
58
|
+
<gl-form-input
|
|
59
|
+
id="input-1"
|
|
60
|
+
v-model="form.email"
|
|
61
|
+
type="email"
|
|
62
|
+
required
|
|
63
|
+
placeholder="Enter email"
|
|
64
|
+
/>
|
|
65
|
+
</gl-form-group>
|
|
66
|
+
|
|
67
|
+
<gl-form-group id="input-group-2" label="Your Name:" label-for="input-2">
|
|
68
|
+
<gl-form-input id="input-2" v-model="form.name" required placeholder="Enter name" />
|
|
69
|
+
</gl-form-group>
|
|
9
70
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
71
|
+
<gl-form-group id="input-group-3" label="Merge State:" label-for="input-3">
|
|
72
|
+
<gl-form-select id="input-3" v-model="form.mergeState" :options="states" required />
|
|
73
|
+
</gl-form-group>
|
|
74
|
+
|
|
75
|
+
<gl-form-group id="input-group-4">
|
|
76
|
+
<gl-form-checkbox-group id="checkboxes-4" v-model="form.checked">
|
|
77
|
+
<gl-form-checkbox value="squash">Squash Commits</gl-form-checkbox>
|
|
78
|
+
<gl-form-checkbox value="new">Create New Issue</gl-form-checkbox>
|
|
79
|
+
</gl-form-checkbox-group>
|
|
80
|
+
</gl-form-group>
|
|
81
|
+
|
|
82
|
+
<div class="gl-display-flex gl-justify-content-end">
|
|
83
|
+
<gl-button type="reset" class="gl-mr-3">Cancel</gl-button>
|
|
84
|
+
<gl-button type="submit" variant="confirm">Submit</gl-button>
|
|
85
|
+
</div>
|
|
86
|
+
</gl-form>
|
|
87
|
+
`,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
export default {
|
|
91
|
+
title: 'base/form/form',
|
|
92
|
+
component: GlForm,
|
|
93
|
+
parameters: {
|
|
94
|
+
bootstrapComponent: 'b-form',
|
|
95
|
+
knobs: { disable: true },
|
|
96
|
+
docs: {
|
|
97
|
+
description: {
|
|
98
|
+
component: readme,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
};
|
|
@@ -1,37 +1,6 @@
|
|
|
1
|
-
import examples from './examples';
|
|
2
1
|
import description from './form_radio.md';
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
4
|
description,
|
|
6
|
-
examples,
|
|
7
5
|
followsDesignSystem: true,
|
|
8
|
-
bootstrapComponent: 'b-form-radio',
|
|
9
|
-
propsInfo: {
|
|
10
|
-
checked: {
|
|
11
|
-
additionalInfo: 'The current value of the radio(s)',
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
events: [
|
|
15
|
-
{
|
|
16
|
-
event: 'input',
|
|
17
|
-
args: [{ arg: 'checked', description: 'current selected value of radio group' }],
|
|
18
|
-
description: 'Emitted when the selected value is changed',
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
event: 'change',
|
|
22
|
-
args: [{ arg: 'checked', description: 'current selected value of radio group' }],
|
|
23
|
-
description: 'Emitted when the selected value is changed due to user interaction',
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
slots: [
|
|
27
|
-
{
|
|
28
|
-
name: 'help',
|
|
29
|
-
description:
|
|
30
|
-
'Content provided here will be shown beneath the radio. Typically used for help or descriptive text.',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: 'default',
|
|
34
|
-
description: 'Content to use for the label',
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
6
|
};
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
# GlFormRadio
|
|
2
|
-
|
|
3
|
-
A radio button typically represents a single option in a group of related
|
|
4
|
-
choices. Each radio button is boolean and only one can be selected at a time.
|
|
5
|
-
|
|
6
|
-
## Usage
|
|
7
|
-
|
|
8
1
|
`GlFormRadio` components can be used directly, or via a `GlFormRadioGroup`.
|
|
9
2
|
|
|
10
3
|
Below is an example which demonstrates the direct approach. For examples using
|
|
@@ -12,13 +5,13 @@ Below is an example which demonstrates the direct approach. For examples using
|
|
|
12
5
|
|
|
13
6
|
```html
|
|
14
7
|
<script>
|
|
15
|
-
export default {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
8
|
+
export default {
|
|
9
|
+
data() {
|
|
10
|
+
return {
|
|
11
|
+
selected: 'yes',
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
};
|
|
22
15
|
</script>
|
|
23
16
|
|
|
24
17
|
<template>
|
|
@@ -1,48 +1,60 @@
|
|
|
1
|
-
import { withKnobs, text } from '@storybook/addon-knobs';
|
|
2
|
-
import { documentedStoriesOf } from '../../../../../documentation/documented_stories';
|
|
3
1
|
import { GlFormRadio } from '../../../../../index';
|
|
4
2
|
import readme from './form_radio.md';
|
|
5
3
|
|
|
6
|
-
const components = {
|
|
7
|
-
GlFormRadio,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
4
|
const defaultOptions = [
|
|
11
5
|
{ value: 'Pizza', text: 'Pizza' },
|
|
12
6
|
{ value: 'Tacos', text: 'Tacos' },
|
|
13
7
|
{ value: 'Burger', text: 'Burger', disabled: true },
|
|
14
8
|
];
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
default: text('name', name),
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
}
|
|
10
|
+
const generateProps = ({ name = 'radio-group-name', checked = defaultOptions[0].value } = {}) => ({
|
|
11
|
+
name,
|
|
12
|
+
checked,
|
|
13
|
+
});
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.
|
|
28
|
-
|
|
29
|
-
props: generateProps(),
|
|
30
|
-
data() {
|
|
31
|
-
return {
|
|
32
|
-
selected: defaultOptions[0].value,
|
|
33
|
-
options: defaultOptions,
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
template: `
|
|
15
|
+
const Template = (args) => ({
|
|
16
|
+
components: { GlFormRadio },
|
|
17
|
+
props: Object.keys(args),
|
|
18
|
+
template: `
|
|
37
19
|
<div>
|
|
38
20
|
<gl-form-radio
|
|
39
21
|
v-for="option in options"
|
|
40
22
|
:key="option.value"
|
|
41
|
-
|
|
23
|
+
:checked="checked"
|
|
42
24
|
:value="option.value"
|
|
43
25
|
:disabled="option.disabled"
|
|
44
26
|
:name="name"
|
|
45
27
|
>{{ option.text }}</gl-form-radio>
|
|
46
28
|
</div>
|
|
47
29
|
`,
|
|
48
|
-
|
|
30
|
+
data() {
|
|
31
|
+
return {
|
|
32
|
+
options: defaultOptions,
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const Default = Template.bind({});
|
|
38
|
+
Default.args = generateProps();
|
|
39
|
+
|
|
40
|
+
export default {
|
|
41
|
+
title: 'base/form/form-radio',
|
|
42
|
+
component: GlFormRadio,
|
|
43
|
+
parameters: {
|
|
44
|
+
bootstrapComponent: 'b-form-radio',
|
|
45
|
+
knobs: { disable: true },
|
|
46
|
+
docs: {
|
|
47
|
+
description: {
|
|
48
|
+
component: readme,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
argTypes: {
|
|
53
|
+
checked: {
|
|
54
|
+
options: defaultOptions.map(({ value }) => value),
|
|
55
|
+
control: {
|
|
56
|
+
type: 'select',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -7,20 +7,45 @@ export default {
|
|
|
7
7
|
name: 'GlFormRadio',
|
|
8
8
|
components: { BFormRadio },
|
|
9
9
|
inheritAttrs: false,
|
|
10
|
-
model
|
|
10
|
+
model: {
|
|
11
|
+
prop: model.prop,
|
|
12
|
+
event: model.event,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
/**
|
|
16
|
+
* Whether the radio is checked
|
|
17
|
+
*/
|
|
18
|
+
checked: {
|
|
19
|
+
type: [String, Number, Boolean, Object],
|
|
20
|
+
required: false,
|
|
21
|
+
default: false,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
11
24
|
};
|
|
12
25
|
</script>
|
|
13
26
|
|
|
14
27
|
<template>
|
|
28
|
+
<!--
|
|
29
|
+
Emitted when the selected value is changed
|
|
30
|
+
@event input
|
|
31
|
+
@type {boolean} current selected value of radio group
|
|
32
|
+
|
|
33
|
+
Emitted when the selected value is changed due to user interaction
|
|
34
|
+
@event change
|
|
35
|
+
@type {boolean} current selected value of radio group
|
|
36
|
+
-->
|
|
15
37
|
<b-form-radio
|
|
16
38
|
class="gl-form-radio"
|
|
39
|
+
:checked="checked"
|
|
17
40
|
v-bind="$attrs"
|
|
18
41
|
v-on="$listeners"
|
|
19
42
|
@input="$emit('input', $event)"
|
|
20
43
|
@change="$emit('change', $event)"
|
|
21
44
|
>
|
|
45
|
+
<!-- @slot Content to use for the label -->
|
|
22
46
|
<slot></slot>
|
|
23
47
|
<p v-if="$scopedSlots.help" class="help-text">
|
|
48
|
+
<!-- @slot Content provided here will be shown beneath the radio. Typically used for help or descriptive text. -->
|
|
24
49
|
<slot name="help"></slot>
|
|
25
50
|
</p>
|
|
26
51
|
</b-form-radio>
|
|
@@ -1,25 +1,6 @@
|
|
|
1
|
-
import examples from './examples';
|
|
2
1
|
import description from './form_select.md';
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
4
|
description,
|
|
6
|
-
examples,
|
|
7
5
|
followDesignSystem: true,
|
|
8
|
-
bootstrapComponent: 'b-form-select',
|
|
9
|
-
events: [
|
|
10
|
-
{
|
|
11
|
-
event: 'change',
|
|
12
|
-
description: 'Emitted with the select value changes via user interaction.',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
event: 'input',
|
|
16
|
-
description: 'Emitted with the select value changes.',
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
slots: [
|
|
20
|
-
{
|
|
21
|
-
name: 'first',
|
|
22
|
-
description: 'Slot to place option tags above options provided via options prop',
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
6
|
};
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import { withKnobs, boolean, select, number, object } from '@storybook/addon-knobs';
|
|
2
|
-
import { documentedStoriesOf } from '../../../../../documentation/documented_stories';
|
|
3
1
|
import { GlFormSelect } from '../../../../../index';
|
|
4
2
|
import { sizeOptions, formStateOptions } from '../../../../utils/constants';
|
|
5
3
|
import { formSelectOptions } from './constants';
|
|
6
4
|
import readme from './form_select.md';
|
|
7
5
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const data = () => {
|
|
13
|
-
return {
|
|
14
|
-
selected: 'Pizza',
|
|
15
|
-
};
|
|
16
|
-
};
|
|
6
|
+
const data = () => ({
|
|
7
|
+
selected: 'Pizza',
|
|
8
|
+
});
|
|
17
9
|
|
|
18
10
|
const template = `
|
|
19
11
|
<gl-form-select
|
|
@@ -27,86 +19,112 @@ const template = `
|
|
|
27
19
|
</gl-form-select>
|
|
28
20
|
`;
|
|
29
21
|
|
|
30
|
-
|
|
22
|
+
const generateProps = ({
|
|
31
23
|
size = null,
|
|
32
24
|
state = null,
|
|
33
25
|
disabled = false,
|
|
34
26
|
multiple = false,
|
|
35
27
|
selectSize = 1,
|
|
36
28
|
options = formSelectOptions,
|
|
37
|
-
} = {}) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
} = {}) => ({
|
|
30
|
+
size,
|
|
31
|
+
disabled,
|
|
32
|
+
state,
|
|
33
|
+
multiple,
|
|
34
|
+
selectSize,
|
|
35
|
+
options,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const Template = (args) => ({
|
|
39
|
+
components: { GlFormSelect },
|
|
40
|
+
props: Object.keys(args),
|
|
41
|
+
data,
|
|
42
|
+
template,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const Default = Template.bind({});
|
|
46
|
+
Default.args = generateProps();
|
|
47
|
+
|
|
48
|
+
export const Disabled = Template.bind({});
|
|
49
|
+
Disabled.args = generateProps({ disabled: true });
|
|
50
|
+
|
|
51
|
+
export const ValidState = Template.bind({});
|
|
52
|
+
ValidState.args = generateProps({ state: true });
|
|
53
|
+
|
|
54
|
+
export const InvalidState = Template.bind({});
|
|
55
|
+
InvalidState.args = generateProps({ state: false });
|
|
56
|
+
|
|
57
|
+
export const WithTruncation = (args, { argTypes }) => ({
|
|
58
|
+
components: { GlFormSelect },
|
|
59
|
+
props: Object.keys(argTypes),
|
|
60
|
+
data() {
|
|
61
|
+
return {
|
|
62
|
+
selected: 1,
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
template: `
|
|
66
|
+
<div style="max-width: 300px;">
|
|
67
|
+
${template}
|
|
68
|
+
</div>
|
|
69
|
+
`,
|
|
70
|
+
});
|
|
71
|
+
WithTruncation.args = generateProps({
|
|
72
|
+
options: [
|
|
73
|
+
{
|
|
74
|
+
value: 1,
|
|
75
|
+
text: 'A form select option with a very looooooooong label',
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export default {
|
|
81
|
+
title: 'base/form/form-select',
|
|
82
|
+
component: GlFormSelect,
|
|
83
|
+
parameters: {
|
|
84
|
+
bootstrapComponent: 'b-form-select',
|
|
85
|
+
knobs: { disable: true },
|
|
86
|
+
docs: {
|
|
87
|
+
description: {
|
|
88
|
+
component: readme,
|
|
89
|
+
},
|
|
42
90
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
91
|
+
},
|
|
92
|
+
argTypes: {
|
|
93
|
+
size: {
|
|
94
|
+
control: {
|
|
95
|
+
type: 'select',
|
|
96
|
+
options: sizeOptions,
|
|
97
|
+
},
|
|
46
98
|
},
|
|
47
99
|
state: {
|
|
48
|
-
|
|
49
|
-
|
|
100
|
+
control: {
|
|
101
|
+
type: 'select',
|
|
102
|
+
options: formStateOptions,
|
|
103
|
+
},
|
|
50
104
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
105
|
+
input: {
|
|
106
|
+
description: 'Emitted with the select value changes.',
|
|
107
|
+
table: {
|
|
108
|
+
category: 'events',
|
|
109
|
+
},
|
|
54
110
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
111
|
+
change: {
|
|
112
|
+
description: 'Emitted with the select value changes via user interaction.',
|
|
113
|
+
table: {
|
|
114
|
+
category: 'events',
|
|
115
|
+
},
|
|
58
116
|
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
117
|
+
first: {
|
|
118
|
+
description: 'Slot to place option tags above options provided via options prop.',
|
|
119
|
+
table: {
|
|
120
|
+
category: 'slots',
|
|
121
|
+
},
|
|
62
122
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
.add('default', () => ({
|
|
69
|
-
components,
|
|
70
|
-
props: generateProps(),
|
|
71
|
-
data,
|
|
72
|
-
template,
|
|
73
|
-
}))
|
|
74
|
-
.add('disabled', () => ({
|
|
75
|
-
components,
|
|
76
|
-
props: generateProps({ disabled: true }),
|
|
77
|
-
data,
|
|
78
|
-
template,
|
|
79
|
-
}))
|
|
80
|
-
.add('valid state', () => ({
|
|
81
|
-
components,
|
|
82
|
-
props: generateProps({ state: true }),
|
|
83
|
-
data,
|
|
84
|
-
template,
|
|
85
|
-
}))
|
|
86
|
-
.add('invalid state', () => ({
|
|
87
|
-
components,
|
|
88
|
-
props: generateProps({ state: false }),
|
|
89
|
-
data,
|
|
90
|
-
template,
|
|
91
|
-
}))
|
|
92
|
-
.add('with truncation', () => ({
|
|
93
|
-
components,
|
|
94
|
-
props: generateProps({
|
|
95
|
-
options: [
|
|
96
|
-
{
|
|
97
|
-
value: 1,
|
|
98
|
-
text: 'A form select option with a very looooooooong label',
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
}),
|
|
102
|
-
data() {
|
|
103
|
-
return {
|
|
104
|
-
selected: 1,
|
|
105
|
-
};
|
|
123
|
+
default: {
|
|
124
|
+
description: 'Slot to place explicit option tags.',
|
|
125
|
+
table: {
|
|
126
|
+
category: 'slots',
|
|
127
|
+
},
|
|
106
128
|
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
${template}
|
|
110
|
-
</div>
|
|
111
|
-
`,
|
|
112
|
-
}));
|
|
129
|
+
},
|
|
130
|
+
};
|