@gitlab/ui 43.10.0 → 43.11.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 +7 -0
- package/dist/components/base/form/form_select/form_select.js +39 -2
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/utils/constants.js +2 -8
- package/package.json +1 -1
- package/src/components/base/form/form_select/form_select.scss +17 -0
- package/src/components/base/form/form_select/form_select.spec.js +3 -3
- package/src/components/base/form/form_select/form_select.stories.js +2 -2
- package/src/components/base/form/form_select/form_select.vue +38 -1
- package/src/utils/constants.js +0 -7
package/dist/utils/constants.js
CHANGED
|
@@ -43,11 +43,6 @@ const variantCssColorMap = {
|
|
|
43
43
|
danger: 'gl-text-red-500'
|
|
44
44
|
};
|
|
45
45
|
const targetOptions = ['_self', '_blank', '_parent', '_top', null];
|
|
46
|
-
const sizeOptions = {
|
|
47
|
-
default: null,
|
|
48
|
-
sm: 'sm',
|
|
49
|
-
lg: 'lg'
|
|
50
|
-
};
|
|
51
46
|
const labelSizeOptions = {
|
|
52
47
|
default: null,
|
|
53
48
|
sm: 'sm'
|
|
@@ -200,8 +195,7 @@ const tabsButtonDefaults = {
|
|
|
200
195
|
};
|
|
201
196
|
const tokenVariants = ['default', 'search-type', 'search-value'];
|
|
202
197
|
const resizeDebounceTime = 200;
|
|
203
|
-
const variantOptionsWithNoDefault = appendDefaultOption(variantOptions);
|
|
204
|
-
const sizeOptionsWithNoDefault = appendDefaultOption(sizeOptions); // Datetime constants
|
|
198
|
+
const variantOptionsWithNoDefault = appendDefaultOption(variantOptions); // Datetime constants
|
|
205
199
|
|
|
206
200
|
const defaultDateFormat = 'YYYY-MM-DD';
|
|
207
201
|
const bannerVariants = ['promotion', 'introduction'];
|
|
@@ -250,4 +244,4 @@ const loadingIconSizes = {
|
|
|
250
244
|
'xl (64x64)': 'xl'
|
|
251
245
|
};
|
|
252
246
|
|
|
253
|
-
export { COMMA, alertVariantIconMap, alertVariantOptions, alignOptions, avatarShapeOptions, avatarSizeOptions, avatarsInlineSizeOptions, badgeForButtonOptions, badgeSizeOptions, badgeVariantOptions, bannerVariants, buttonCategoryOptions, buttonSizeOptions, buttonSizeOptionsMap, buttonVariantOptions, colorThemes, columnOptions, defaultDateFormat, drawerVariants, dropdownVariantOptions, focusableTags, formInputSizes, formStateOptions, glThemes, iconSizeOptions, keyboard, labelColorOptions, labelSizeOptions, loadingIconSizes, maxZIndex, modalButtonDefaults, modalSizeOptions, popoverPlacements, resizeDebounceTime,
|
|
247
|
+
export { COMMA, alertVariantIconMap, alertVariantOptions, alignOptions, avatarShapeOptions, avatarSizeOptions, avatarsInlineSizeOptions, badgeForButtonOptions, badgeSizeOptions, badgeVariantOptions, bannerVariants, buttonCategoryOptions, buttonSizeOptions, buttonSizeOptionsMap, buttonVariantOptions, colorThemes, columnOptions, defaultDateFormat, drawerVariants, dropdownVariantOptions, focusableTags, formInputSizes, formStateOptions, glThemes, iconSizeOptions, keyboard, labelColorOptions, labelSizeOptions, loadingIconSizes, maxZIndex, modalButtonDefaults, modalSizeOptions, popoverPlacements, resizeDebounceTime, tabsButtonDefaults, targetOptions, toggleLabelPosition, tokenVariants, tooltipActionEvents, tooltipDelay, tooltipPlacements, triggerVariantOptions, truncateOptions, variantCssColorMap, variantOptions, variantOptionsWithNoDefault, viewModeOptions };
|
package/package.json
CHANGED
|
@@ -54,4 +54,21 @@ See: https://gitlab.com/gitlab-org/gitlab/issues/30055
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
|
|
58
|
+
@each $name, $size in $gl-form-input-sizes {
|
|
59
|
+
.gl-form-select-#{$name} {
|
|
60
|
+
max-width: $size;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@each $breakpointName, $breakpointSize in $gl-form-input-sizes {
|
|
64
|
+
@if $breakpointName != xs {
|
|
65
|
+
.gl-#{$breakpointName}-form-select-#{$name} {
|
|
66
|
+
@include gl-media-breakpoint-up($breakpointName) {
|
|
67
|
+
max-width: $size;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
57
74
|
/* stylelint-enable property-no-vendor-prefix */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mount } from '@vue/test-utils';
|
|
2
|
-
import {
|
|
2
|
+
import { formStateOptions, formInputSizes } from '../../../../utils/constants';
|
|
3
3
|
import { formSelectOptions } from './constants';
|
|
4
4
|
import GlFormSelect from './form_select.vue';
|
|
5
5
|
|
|
@@ -33,13 +33,13 @@ describe('GlFormSelect', () => {
|
|
|
33
33
|
|
|
34
34
|
describe('size prop', () => {
|
|
35
35
|
// Exclude the default null value
|
|
36
|
-
const nonNullSizes = excludeDefaultNull(
|
|
36
|
+
const nonNullSizes = excludeDefaultNull(formInputSizes);
|
|
37
37
|
|
|
38
38
|
it.each(nonNullSizes)('adds correct class for size %s', (size) => {
|
|
39
39
|
createComponent({ size });
|
|
40
40
|
|
|
41
41
|
expect(wrapper.classes().sort()).toEqual(
|
|
42
|
-
[...DEFAULT_SELECT_CLASSES, `
|
|
42
|
+
[...DEFAULT_SELECT_CLASSES, `gl-form-select-${size}`].sort()
|
|
43
43
|
);
|
|
44
44
|
});
|
|
45
45
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GlFormSelect } from '../../../../index';
|
|
2
|
-
import {
|
|
2
|
+
import { formStateOptions, formInputSizes } from '../../../../utils/constants';
|
|
3
3
|
import { formSelectOptions } from './constants';
|
|
4
4
|
import readme from './form_select.md';
|
|
5
5
|
|
|
@@ -90,7 +90,7 @@ export default {
|
|
|
90
90
|
},
|
|
91
91
|
argTypes: {
|
|
92
92
|
size: {
|
|
93
|
-
options:
|
|
93
|
+
options: formInputSizes,
|
|
94
94
|
control: 'select',
|
|
95
95
|
},
|
|
96
96
|
state: {
|
|
@@ -1,15 +1,52 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { BFormSelect } from 'bootstrap-vue';
|
|
3
|
+
import { isObject } from 'lodash';
|
|
4
|
+
import { formInputSizes } from '../../../../utils/constants';
|
|
3
5
|
|
|
4
6
|
export default {
|
|
5
7
|
components: {
|
|
6
8
|
BFormSelect,
|
|
7
9
|
},
|
|
8
10
|
inheritAttrs: false,
|
|
11
|
+
props: {
|
|
12
|
+
/**
|
|
13
|
+
* Maximum width of the Select
|
|
14
|
+
*/
|
|
15
|
+
size: {
|
|
16
|
+
type: [String, Object],
|
|
17
|
+
required: false,
|
|
18
|
+
default: null,
|
|
19
|
+
validator: (value) => {
|
|
20
|
+
const sizes = isObject(value) ? Object.values(value) : [value];
|
|
21
|
+
|
|
22
|
+
return sizes.every((size) => Object.values(formInputSizes).includes(size));
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
computed: {
|
|
27
|
+
cssClasses() {
|
|
28
|
+
if (this.size === null) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (isObject(this.size)) {
|
|
33
|
+
const { default: defaultSize, ...nonDefaultSizes } = this.size;
|
|
34
|
+
|
|
35
|
+
return [
|
|
36
|
+
...(defaultSize ? [`gl-form-select-${defaultSize}`] : []),
|
|
37
|
+
...Object.entries(nonDefaultSizes).map(
|
|
38
|
+
([breakpoint, size]) => `gl-${breakpoint}-form-select-${size}`
|
|
39
|
+
),
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return [`gl-form-select-${this.size}`];
|
|
44
|
+
},
|
|
45
|
+
},
|
|
9
46
|
};
|
|
10
47
|
</script>
|
|
11
48
|
<template>
|
|
12
|
-
<b-form-select class="gl-form-select" v-bind="$attrs" v-on="$listeners">
|
|
49
|
+
<b-form-select class="gl-form-select" v-bind="$attrs" :class="cssClasses" v-on="$listeners">
|
|
13
50
|
<!-- eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots -->
|
|
14
51
|
<template v-for="slot in Object.keys($slots)" #[slot]>
|
|
15
52
|
<slot :name="slot"></slot>
|
package/src/utils/constants.js
CHANGED
|
@@ -48,12 +48,6 @@ export const variantCssColorMap = {
|
|
|
48
48
|
|
|
49
49
|
export const targetOptions = ['_self', '_blank', '_parent', '_top', null];
|
|
50
50
|
|
|
51
|
-
export const sizeOptions = {
|
|
52
|
-
default: null,
|
|
53
|
-
sm: 'sm',
|
|
54
|
-
lg: 'lg',
|
|
55
|
-
};
|
|
56
|
-
|
|
57
51
|
export const labelSizeOptions = {
|
|
58
52
|
default: null,
|
|
59
53
|
sm: 'sm',
|
|
@@ -234,7 +228,6 @@ export const tokenVariants = ['default', 'search-type', 'search-value'];
|
|
|
234
228
|
export const resizeDebounceTime = 200;
|
|
235
229
|
|
|
236
230
|
export const variantOptionsWithNoDefault = appendDefaultOption(variantOptions);
|
|
237
|
-
export const sizeOptionsWithNoDefault = appendDefaultOption(sizeOptions);
|
|
238
231
|
|
|
239
232
|
// Datetime constants
|
|
240
233
|
export const defaultDateFormat = 'YYYY-MM-DD';
|