@gitlab/ui 70.0.1 → 71.0.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 CHANGED
@@ -1,3 +1,16 @@
1
+ # [71.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v70.0.1...v71.0.0) (2023-11-22)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlFormInput, GlFormSelect, GlDatepicker:** remove deprecated props ([72ff245](https://gitlab.com/gitlab-org/gitlab-ui/commit/72ff245417250b78514b60fb0a85fbde64a5d7c7))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * **GlFormInput, GlFormSelect, GlDatepicker:** Removes the legacy property "size" from GlFormInput,
12
+ GlFormSelect & GlDatepicker.
13
+
1
14
  ## [70.0.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v70.0.0...v70.0.1) (2023-11-21)
2
15
 
3
16
 
@@ -1,6 +1,6 @@
1
1
  import isString from 'lodash/isString';
2
2
  import Pikaday from 'pikaday';
3
- import { defaultDateFormat, datepickerWidthOptionsMap, datepickerSizeOptionsMap } from '../../../utils/constants';
3
+ import { defaultDateFormat, datepickerWidthOptionsMap } from '../../../utils/constants';
4
4
  import { areDatesEqual } from '../../../utils/datetime_utility';
5
5
  import GlButton from '../button/button';
6
6
  import GlFormInput from '../form/form_input/form_input';
@@ -181,20 +181,6 @@ var script = {
181
181
  required: false,
182
182
  default: null,
183
183
  validator: value => Object.keys(datepickerWidthOptionsMap).includes(value)
184
- },
185
- /**
186
- * ⚠️ DEPRECATED:
187
- *
188
- * Will be replaced by the
189
- * property width
190
- *
191
- * Maximum width of the Datepicker
192
- */
193
- size: {
194
- type: String,
195
- required: false,
196
- default: null,
197
- validator: value => Object.keys(datepickerSizeOptionsMap).includes(value)
198
184
  }
199
185
  },
200
186
  data() {
@@ -233,9 +219,6 @@ var script = {
233
219
  computedWidth() {
234
220
  if (this.width) {
235
221
  return this.width;
236
- // eslint-disable-next-line no-else-return
237
- } else if (this.size) {
238
- return datepickerSizeOptionsMap[this.size];
239
222
  }
240
223
  return 'md';
241
224
  }
@@ -1,6 +1,6 @@
1
1
  import isObject from 'lodash/isObject';
2
2
  import { BFormInput } from 'bootstrap-vue/esm/index.js';
3
- import { formInputSizes } from '../../../../utils/constants';
3
+ import { formInputWidths } from '../../../../utils/constants';
4
4
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
5
5
 
6
6
  const MODEL_PROP = 'value';
@@ -25,46 +25,26 @@ var script = {
25
25
  default: null,
26
26
  validator: value => {
27
27
  const widths = isObject(value) ? Object.values(value) : [value];
28
- return widths.every(width => Object.values(formInputSizes).includes(width));
29
- }
30
- },
31
- /**
32
- * ⚠️ DEPRECATED:
33
- *
34
- * Will be replaced by the
35
- * property width
36
- *
37
- * Maximum width of the input
38
- */
39
- size: {
40
- type: [String, Object],
41
- required: false,
42
- default: null,
43
- validator: value => {
44
- const sizes = isObject(value) ? Object.values(value) : [value];
45
- return sizes.every(size => Object.values(formInputSizes).includes(size));
28
+ return widths.every(width => Object.values(formInputWidths).includes(width));
46
29
  }
47
30
  }
48
31
  },
49
32
  computed: {
50
- computedWidth() {
51
- return this.width ? this.width : this.size;
52
- },
53
33
  cssClasses() {
54
- if (this.computedWidth === null) {
34
+ if (this.width === null) {
55
35
  return [];
56
36
  }
57
- if (isObject(this.computedWidth)) {
37
+ if (isObject(this.width)) {
58
38
  const {
59
- default: defaultSize,
60
- ...nonDefaultSizes
61
- } = this.computedWidth;
62
- return [...(defaultSize ? [`gl-form-input-${defaultSize}`] : []), ...Object.entries(nonDefaultSizes).map(_ref => {
63
- let [breakpoint, size] = _ref;
64
- return `gl-${breakpoint}-form-input-${size}`;
39
+ default: defaultWidth,
40
+ ...nonDefaultWidths
41
+ } = this.width;
42
+ return [...(defaultWidth ? [`gl-form-input-${defaultWidth}`] : []), ...Object.entries(nonDefaultWidths).map(_ref => {
43
+ let [breakpoint, width] = _ref;
44
+ return `gl-${breakpoint}-form-input-${width}`;
65
45
  })];
66
46
  }
67
- return [`gl-form-input-${this.computedWidth}`];
47
+ return [`gl-form-input-${this.width}`];
68
48
  },
69
49
  listeners() {
70
50
  var _this = this;
@@ -1,6 +1,6 @@
1
1
  import { BFormSelect } from 'bootstrap-vue/esm/index.js';
2
2
  import isObject from 'lodash/isObject';
3
- import { formInputSizes } from '../../../../utils/constants';
3
+ import { formInputWidths } from '../../../../utils/constants';
4
4
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
5
5
 
6
6
  var script = {
@@ -19,46 +19,26 @@ var script = {
19
19
  default: null,
20
20
  validator: value => {
21
21
  const widths = isObject(value) ? Object.values(value) : [value];
22
- return widths.every(width => Object.values(formInputSizes).includes(width));
23
- }
24
- },
25
- /**
26
- * ⚠️ DEPRECATED:
27
- *
28
- * Will be replaced by the
29
- * property width
30
- *
31
- * Maximum width of the Select
32
- */
33
- size: {
34
- type: [String, Object],
35
- required: false,
36
- default: null,
37
- validator: value => {
38
- const sizes = isObject(value) ? Object.values(value) : [value];
39
- return sizes.every(size => Object.values(formInputSizes).includes(size));
22
+ return widths.every(width => Object.values(formInputWidths).includes(width));
40
23
  }
41
24
  }
42
25
  },
43
26
  computed: {
44
- computedWidth() {
45
- return this.width ? this.width : this.size;
46
- },
47
27
  cssClasses() {
48
- if (this.computedWidth === null) {
28
+ if (this.width === null) {
49
29
  return [];
50
30
  }
51
- if (isObject(this.computedWidth)) {
31
+ if (isObject(this.width)) {
52
32
  const {
53
- default: defaultSize,
54
- ...nonDefaultSizes
55
- } = this.computedWidth;
56
- return [...(defaultSize ? [`gl-form-select-${defaultSize}`] : []), ...Object.entries(nonDefaultSizes).map(_ref => {
57
- let [breakpoint, size] = _ref;
58
- return `gl-${breakpoint}-form-select-${size}`;
33
+ default: defaultWidth,
34
+ ...nonDefaultWidths
35
+ } = this.width;
36
+ return [...(defaultWidth ? [`gl-form-select-${defaultWidth}`] : []), ...Object.entries(nonDefaultWidths).map(_ref => {
37
+ let [breakpoint, width] = _ref;
38
+ return `gl-${breakpoint}-form-select-${width}`;
59
39
  })];
60
40
  }
61
- return [`gl-form-select-${this.computedWidth}`];
41
+ return [`gl-form-select-${this.width}`];
62
42
  }
63
43
  }
64
44
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Tue, 21 Nov 2023 13:00:27 GMT
3
+ * Generated on Wed, 22 Nov 2023 16:02:43 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Tue, 21 Nov 2023 13:00:27 GMT
3
+ * Generated on Wed, 22 Nov 2023 16:02:43 GMT
4
4
  */
5
5
 
6
6
  :root.gl-dark {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Tue, 21 Nov 2023 13:00:27 GMT
3
+ * Generated on Wed, 22 Nov 2023 16:02:43 GMT
4
4
  */
5
5
 
6
6
  export const BLACK = "#fff";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Tue, 21 Nov 2023 13:00:27 GMT
3
+ * Generated on Wed, 22 Nov 2023 16:02:43 GMT
4
4
  */
5
5
 
6
6
  export const DATA_VIZ_GREEN_50 = "#ddfab7";
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Tue, 21 Nov 2023 13:00:27 GMT
3
+ // Generated on Wed, 22 Nov 2023 16:02:43 GMT
4
4
 
5
5
  $red-950: #fff4f3;
6
6
  $red-900: #fcf1ef;
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Tue, 21 Nov 2023 13:00:27 GMT
3
+ // Generated on Wed, 22 Nov 2023 16:02:43 GMT
4
4
 
5
5
  $gl-line-height-52: 3.25rem;
6
6
  $gl-line-height-44: 2.75rem;
@@ -117,10 +117,6 @@ const buttonSizeOptions = {
117
117
  small: 'sm',
118
118
  medium: 'md'
119
119
  };
120
- const datepickerSizeOptionsMap = {
121
- small: 'sm',
122
- medium: 'md'
123
- };
124
120
  const datepickerWidthOptionsMap = {
125
121
  sm: 'sm',
126
122
  md: 'md',
@@ -242,7 +238,7 @@ const keyboard = {
242
238
  tab: 'Tab'
243
239
  };
244
240
  const truncateOptions = POSITION;
245
- const formInputSizes = {
241
+ const formInputWidths = {
246
242
  xs: 'xs',
247
243
  sm: 'sm',
248
244
  md: 'md',
@@ -271,4 +267,4 @@ const loadingIconVariants = {
271
267
  dots: 'dots'
272
268
  };
273
269
 
274
- export { COMMA, LEFT_MOUSE_BUTTON, alertVariantIconMap, alertVariantOptions, alignOptions, avatarShapeOptions, avatarSizeOptions, avatarsInlineSizeOptions, badgeForButtonOptions, badgeIconSizeOptions, badgeSizeOptions, badgeVariantOptions, bannerVariants, buttonCategoryOptions, buttonSizeOptions, buttonVariantOptions, colorThemes, columnOptions, datepickerSizeOptionsMap, datepickerWidthOptionsMap, defaultDateFormat, drawerVariants, dropdownAllowedAutoPlacements, dropdownPlacements, dropdownVariantOptions, focusableTags, formInputSizes, formStateOptions, glThemes, iconSizeOptions, keyboard, labelColorOptions, labelSizeOptions, loadingIconSizes, loadingIconVariants, maxZIndex, modalButtonDefaults, modalSizeOptions, popoverPlacements, resizeDebounceTime, tabsButtonDefaults, targetOptions, toggleLabelPosition, tokenVariants, tooltipActionEvents, tooltipDelay, tooltipPlacements, triggerVariantOptions, truncateOptions, variantCssColorMap, variantOptions, variantOptionsWithNoDefault, viewModeOptions };
270
+ export { COMMA, LEFT_MOUSE_BUTTON, alertVariantIconMap, alertVariantOptions, alignOptions, avatarShapeOptions, avatarSizeOptions, avatarsInlineSizeOptions, badgeForButtonOptions, badgeIconSizeOptions, badgeSizeOptions, badgeVariantOptions, bannerVariants, buttonCategoryOptions, buttonSizeOptions, buttonVariantOptions, colorThemes, columnOptions, datepickerWidthOptionsMap, defaultDateFormat, drawerVariants, dropdownAllowedAutoPlacements, dropdownPlacements, dropdownVariantOptions, focusableTags, formInputWidths, formStateOptions, glThemes, iconSizeOptions, keyboard, labelColorOptions, labelSizeOptions, loadingIconSizes, loadingIconVariants, maxZIndex, modalButtonDefaults, modalSizeOptions, popoverPlacements, resizeDebounceTime, tabsButtonDefaults, targetOptions, toggleLabelPosition, tokenVariants, tooltipActionEvents, tooltipDelay, tooltipPlacements, triggerVariantOptions, truncateOptions, variantCssColorMap, variantOptions, variantOptionsWithNoDefault, viewModeOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "70.0.1",
3
+ "version": "71.0.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "storybook-static": "yarn storybook-prep && storybook build -c .storybook -o storybook",
38
38
  "pretest:unit": "yarn build-tokens",
39
39
  "test": "run-s test:unit test:visual",
40
- "test:integration": "NODE_ENV=test start-server-and-test start http://${STORYBOOK_HOST:-localhost}:9001/iframe.html 'yarn cy:run && yarn cy:a11y'",
40
+ "test:integration": "NODE_ENV=test start-server-and-test start http://${STORYBOOK_HOST:-localhost}:9001/iframe.html 'yarn cy:run && yarn cy:edge && yarn cy:a11y'",
41
41
  "test:unit": "NODE_ENV=test jest --testPathIgnorePatterns storyshots.spec.js",
42
42
  "test:unit:watch": "yarn test:unit --watch",
43
43
  "test:unit:debug": "NODE_ENV=test node --inspect node_modules/.bin/jest --testPathIgnorePatterns storyshot.spec.js --watch --runInBand",
@@ -412,21 +412,6 @@ describe('datepicker component', () => {
412
412
  expect(config.parse(dateString)).toEqual(parsedDate);
413
413
  });
414
414
 
415
- it.each`
416
- size | expectedClass
417
- ${undefined} | ${'gl-form-input-md'}
418
- ${'small'} | ${'gl-form-input-sm'}
419
- ${'medium'} | ${'gl-form-input-md'}
420
- `('applies $expectedClass class when size is $size', ({ size, expectedClass }) => {
421
- const wrapper = mountWithOptions({
422
- propsData: {
423
- size,
424
- },
425
- });
426
-
427
- expect(wrapper.classes()).toContain(expectedClass);
428
- });
429
-
430
415
  it.each`
431
416
  width | expectedClass
432
417
  ${undefined} | ${'gl-form-input-md'}
@@ -1,5 +1,5 @@
1
1
  import GlFormGroup from '../form/form_group/form_group.vue';
2
- import { datepickerWidthOptionsMap, datepickerSizeOptionsMap } from '../../../utils/constants';
2
+ import { datepickerWidthOptionsMap } from '../../../utils/constants';
3
3
  import { disableControls } from '../../../utils/stories_utils';
4
4
  import { useFakeDate } from '../../../utils/use_fake_date';
5
5
  import { makeContainer } from '../../../utils/story_decorators/container';
@@ -65,7 +65,7 @@ export const WithClearButton = (_args, { argTypes }) => ({
65
65
  });
66
66
  WithClearButton.args = generateProps();
67
67
 
68
- export const DifferentSizes = (_args, { argTypes }) => ({
68
+ export const Widths = (_args, { argTypes }) => ({
69
69
  ...defaults,
70
70
  props: Object.keys(argTypes),
71
71
  data() {
@@ -91,7 +91,7 @@ export const DifferentSizes = (_args, { argTypes }) => ({
91
91
  </div>
92
92
  `,
93
93
  });
94
- DifferentSizes.args = generateProps();
94
+ Widths.args = generateProps();
95
95
 
96
96
  export default {
97
97
  title: 'base/datepicker',
@@ -137,9 +137,5 @@ export default {
137
137
  options: datepickerWidthOptionsMap,
138
138
  control: 'select',
139
139
  },
140
- size: {
141
- options: datepickerSizeOptionsMap,
142
- control: 'select',
143
- },
144
140
  },
145
141
  };
@@ -2,11 +2,7 @@
2
2
  <script>
3
3
  import isString from 'lodash/isString';
4
4
  import Pikaday from 'pikaday';
5
- import {
6
- defaultDateFormat,
7
- datepickerWidthOptionsMap,
8
- datepickerSizeOptionsMap,
9
- } from '../../../utils/constants';
5
+ import { defaultDateFormat, datepickerWidthOptionsMap } from '../../../utils/constants';
10
6
  import { areDatesEqual } from '../../../utils/datetime_utility';
11
7
  import GlButton from '../button/button.vue';
12
8
  import GlFormInput from '../form/form_input/form_input.vue';
@@ -185,20 +181,6 @@ export default {
185
181
  default: null,
186
182
  validator: (value) => Object.keys(datepickerWidthOptionsMap).includes(value),
187
183
  },
188
- /**
189
- * ⚠️ DEPRECATED:
190
- *
191
- * Will be replaced by the
192
- * property width
193
- *
194
- * Maximum width of the Datepicker
195
- */
196
- size: {
197
- type: String,
198
- required: false,
199
- default: null,
200
- validator: (value) => Object.keys(datepickerSizeOptionsMap).includes(value),
201
- },
202
184
  },
203
185
  data() {
204
186
  return {
@@ -243,9 +225,6 @@ export default {
243
225
  computedWidth() {
244
226
  if (this.width) {
245
227
  return this.width;
246
- // eslint-disable-next-line no-else-return
247
- } else if (this.size) {
248
- return datepickerSizeOptionsMap[this.size];
249
228
  }
250
229
 
251
230
  return 'md';
@@ -1,5 +1,5 @@
1
1
  import { mount, shallowMount } from '@vue/test-utils';
2
- import { formInputSizes } from '../../../../utils/constants';
2
+ import { formInputWidths } from '../../../../utils/constants';
3
3
  import GlFormInput from './form_input.vue';
4
4
 
5
5
  const modelEvent = GlFormInput.model.event;
@@ -14,62 +14,10 @@ describe('GlFormInput', () => {
14
14
  });
15
15
  };
16
16
 
17
- describe('size prop', () => {
18
- describe('when number is passed', () => {
19
- // Exclude the default null value
20
- const sizes = Object.values(formInputSizes).filter(Boolean);
21
-
22
- it.each(sizes)('adds correct class for size %s', (size) => {
23
- createComponent({ size });
24
-
25
- expect(wrapper.classes()).toEqual(['gl-form-input', `gl-form-input-${size}`]);
26
- });
27
-
28
- it('does not add a size class if not given the size prop', () => {
29
- createComponent();
30
-
31
- expect(wrapper.classes()).toEqual(['gl-form-input']);
32
- });
33
-
34
- it('does not add a size class if passed null', () => {
35
- createComponent({ size: null });
36
-
37
- expect(wrapper.classes()).toEqual(['gl-form-input']);
38
- });
39
- });
40
-
41
- describe('when object is passed', () => {
42
- describe('when `default` key is provided', () => {
43
- it('adds responsive CSS classes and base class', () => {
44
- createComponent({ size: { default: 'md', md: 'lg', lg: 'xl' } });
45
-
46
- expect(wrapper.classes()).toEqual([
47
- 'gl-form-input',
48
- 'gl-form-input-md',
49
- 'gl-md-form-input-lg',
50
- 'gl-lg-form-input-xl',
51
- ]);
52
- });
53
- });
54
-
55
- describe('when `default` key is not provided', () => {
56
- it('adds responsive CSS classes', () => {
57
- createComponent({ size: { md: 'lg', lg: 'xl' } });
58
-
59
- expect(wrapper.classes()).toEqual([
60
- 'gl-form-input',
61
- 'gl-md-form-input-lg',
62
- 'gl-lg-form-input-xl',
63
- ]);
64
- });
65
- });
66
- });
67
- });
68
-
69
17
  describe('width prop', () => {
70
18
  describe('when number is passed', () => {
71
19
  // Exclude the default null value
72
- const widths = Object.values(formInputSizes).filter(Boolean);
20
+ const widths = Object.values(formInputWidths).filter(Boolean);
73
21
 
74
22
  it.each(widths)('adds correct class for width %s', (width) => {
75
23
  createComponent({ width });
@@ -1,4 +1,4 @@
1
- import { formInputSizes } from '../../../../utils/constants';
1
+ import { formInputWidths } from '../../../../utils/constants';
2
2
  import GlFormInput from './form_input.vue';
3
3
  import readme from './form_input.md';
4
4
 
@@ -9,18 +9,15 @@ const template = `
9
9
  :disabled="disabled"
10
10
  :value="value"
11
11
  :width="width"
12
- :size="size"
13
12
  />`;
14
13
 
15
14
  const generateProps = ({
16
- width = GlFormInput.props.size.default,
17
- size = GlFormInput.props.size.default,
15
+ width = GlFormInput.props.width.default,
18
16
  value = '',
19
17
  disabled = false,
20
18
  readonly = false,
21
19
  } = {}) => ({
22
20
  width,
23
- size,
24
21
  value,
25
22
  disabled,
26
23
  readonly,
@@ -41,46 +38,44 @@ Disabled.args = generateProps({ value: 'some text', disabled: true });
41
38
  export const Readonly = Template.bind({});
42
39
  Readonly.args = generateProps({ value: 'readonly text', readonly: true });
43
40
 
44
- export const Sizes = (args, { argTypes }) => ({
41
+ export const Widths = (args, { argTypes }) => ({
45
42
  components: { GlFormInput },
46
43
  props: Object.keys(argTypes),
47
44
  data: () => ({
48
- formInputSizes,
45
+ formInputWidths,
49
46
  }),
50
47
  template: `
51
48
  <div>
52
49
  <gl-form-input
53
- v-for="(size, name) in formInputSizes"
54
- :key="size"
50
+ v-for="(width, name) in formInputWidths"
51
+ :key="width"
55
52
  :width="width"
56
- :size="size"
57
53
  :value="name"
54
+ class="gl-mb-4"
58
55
  />
59
56
  </div>
60
57
  `,
61
58
  });
62
- Sizes.args = {};
59
+ Widths.args = {};
63
60
 
64
- export const ResponsiveSizes = (args, { argTypes }) => ({
61
+ export const ResponsiveWidths = (args, { argTypes }) => ({
65
62
  components: { GlFormInput },
66
63
  props: Object.keys(argTypes),
67
64
  template: `
68
65
  <div>
69
66
  <gl-form-input
70
67
  :width="{ default: 'md', md: 'lg', lg: 'xl' }"
71
- :size="{ default: 'md', md: 'lg', lg: 'xl' }"
72
68
  value="With \`default\` key"
69
+ class="gl-mb-4"
73
70
  />
74
71
  <gl-form-input
75
- class="gl-mt-4"
76
72
  :width="{ md: 'lg', lg: 'xl' }"
77
- :size="{ md: 'lg', lg: 'xl' }"
78
73
  value="Without \`default\` key"
79
74
  />
80
75
  </div>
81
76
  `,
82
77
  });
83
- ResponsiveSizes.args = {};
78
+ ResponsiveWidths.args = {};
84
79
 
85
80
  export default {
86
81
  title: 'base/form/form-input',
@@ -95,11 +90,7 @@ export default {
95
90
  },
96
91
  argTypes: {
97
92
  width: {
98
- options: formInputSizes,
99
- control: 'select',
100
- },
101
- size: {
102
- options: formInputSizes,
93
+ options: formInputWidths,
103
94
  control: 'select',
104
95
  },
105
96
  },
@@ -2,7 +2,7 @@
2
2
  import isObject from 'lodash/isObject';
3
3
  import { BFormInput } from 'bootstrap-vue';
4
4
 
5
- import { formInputSizes } from '../../../../utils/constants';
5
+ import { formInputWidths } from '../../../../utils/constants';
6
6
 
7
7
  const MODEL_PROP = 'value';
8
8
  const MODEL_EVENT = 'input';
@@ -28,49 +28,28 @@ export default {
28
28
  validator: (value) => {
29
29
  const widths = isObject(value) ? Object.values(value) : [value];
30
30
 
31
- return widths.every((width) => Object.values(formInputSizes).includes(width));
32
- },
33
- },
34
- /**
35
- * ⚠️ DEPRECATED:
36
- *
37
- * Will be replaced by the
38
- * property width
39
- *
40
- * Maximum width of the input
41
- */
42
- size: {
43
- type: [String, Object],
44
- required: false,
45
- default: null,
46
- validator: (value) => {
47
- const sizes = isObject(value) ? Object.values(value) : [value];
48
-
49
- return sizes.every((size) => Object.values(formInputSizes).includes(size));
31
+ return widths.every((width) => Object.values(formInputWidths).includes(width));
50
32
  },
51
33
  },
52
34
  },
53
35
  computed: {
54
- computedWidth() {
55
- return this.width ? this.width : this.size;
56
- },
57
36
  cssClasses() {
58
- if (this.computedWidth === null) {
37
+ if (this.width === null) {
59
38
  return [];
60
39
  }
61
40
 
62
- if (isObject(this.computedWidth)) {
63
- const { default: defaultSize, ...nonDefaultSizes } = this.computedWidth;
41
+ if (isObject(this.width)) {
42
+ const { default: defaultWidth, ...nonDefaultWidths } = this.width;
64
43
 
65
44
  return [
66
- ...(defaultSize ? [`gl-form-input-${defaultSize}`] : []),
67
- ...Object.entries(nonDefaultSizes).map(
68
- ([breakpoint, size]) => `gl-${breakpoint}-form-input-${size}`
45
+ ...(defaultWidth ? [`gl-form-input-${defaultWidth}`] : []),
46
+ ...Object.entries(nonDefaultWidths).map(
47
+ ([breakpoint, width]) => `gl-${breakpoint}-form-input-${width}`
69
48
  ),
70
49
  ];
71
50
  }
72
51
 
73
- return [`gl-form-input-${this.computedWidth}`];
52
+ return [`gl-form-input-${this.width}`];
74
53
  },
75
54
  listeners() {
76
55
  return {
@@ -1,5 +1,5 @@
1
1
  import { mount } from '@vue/test-utils';
2
- import { formStateOptions, formInputSizes } from '../../../../utils/constants';
2
+ import { formStateOptions, formInputWidths } from '../../../../utils/constants';
3
3
  import { formSelectOptions } from './constants';
4
4
  import GlFormSelect from './form_select.vue';
5
5
 
@@ -31,36 +31,11 @@ describe('GlFormSelect', () => {
31
31
  });
32
32
  });
33
33
 
34
- describe('size prop', () => {
35
- // Exclude the default null value
36
- const nonNullSizes = excludeDefaultNull(formInputSizes);
37
-
38
- it.each(nonNullSizes)('adds correct class for size %s', (size) => {
39
- createComponent({ size });
40
-
41
- expect(wrapper.classes().sort()).toEqual(
42
- [...DEFAULT_SELECT_CLASSES, `gl-form-select-${size}`].sort()
43
- );
44
- });
45
-
46
- it('does not add a size class if not given the size prop', () => {
47
- createComponent();
48
-
49
- expect(wrapper.classes().sort()).toEqual([...DEFAULT_SELECT_CLASSES].sort());
50
- });
51
-
52
- it('does not add a size class if passed null', () => {
53
- createComponent({ size: null });
54
-
55
- expect(wrapper.classes().sort()).toEqual([...DEFAULT_SELECT_CLASSES].sort());
56
- });
57
- });
58
-
59
34
  describe('width prop', () => {
60
35
  // Exclude the default null value
61
- const nonNullSizes = excludeDefaultNull(formInputSizes);
36
+ const nonNullWidths = excludeDefaultNull(formInputWidths);
62
37
 
63
- it.each(nonNullSizes)('adds correct class for width %s', (width) => {
38
+ it.each(nonNullWidths)('adds correct class for width %s', (width) => {
64
39
  createComponent({ width });
65
40
 
66
41
  expect(wrapper.classes().sort()).toEqual(
@@ -1,4 +1,4 @@
1
- import { formStateOptions, formInputSizes } from '../../../../utils/constants';
1
+ import { formStateOptions, formInputWidths } from '../../../../utils/constants';
2
2
  import GlFormSelect from './form_select.vue';
3
3
  import { formSelectOptions } from './constants';
4
4
  import readme from './form_select.md';
@@ -11,7 +11,6 @@ const template = `
11
11
  <gl-form-select
12
12
  v-model="selected"
13
13
  :width="width"
14
- :size="size"
15
14
  :disabled="disabled"
16
15
  :state="state"
17
16
  :multiple="multiple"
@@ -22,7 +21,6 @@ const template = `
22
21
 
23
22
  const generateProps = ({
24
23
  width = null,
25
- size = null,
26
24
  state = null,
27
25
  disabled = false,
28
26
  multiple = false,
@@ -30,7 +28,6 @@ const generateProps = ({
30
28
  options = formSelectOptions,
31
29
  } = {}) => ({
32
30
  width,
33
- size,
34
31
  disabled,
35
32
  state,
36
33
  multiple,
@@ -80,6 +77,27 @@ WithTruncation.args = generateProps({
80
77
  ],
81
78
  });
82
79
 
80
+ export const Widths = (args, { argTypes }) => ({
81
+ components: { GlFormSelect },
82
+ props: Object.keys(argTypes),
83
+ data() {
84
+ return {
85
+ formInputWidths,
86
+ };
87
+ },
88
+ template: `
89
+ <div>
90
+ <div v-for="(width, name) in formInputWidths" :key="width" class="gl-mb-4">
91
+ <gl-form-select
92
+ v-model="name"
93
+ :width="width"
94
+ :options="[{ value: name, text: name }]">
95
+ </gl-form-select>
96
+ </div>
97
+ </div>`,
98
+ });
99
+ Widths.args = generateProps();
100
+
83
101
  export default {
84
102
  title: 'base/form/form-select',
85
103
  component: GlFormSelect,
@@ -93,11 +111,7 @@ export default {
93
111
  },
94
112
  argTypes: {
95
113
  width: {
96
- options: formInputSizes,
97
- control: 'select',
98
- },
99
- size: {
100
- options: formInputSizes,
114
+ options: formInputWidths,
101
115
  control: 'select',
102
116
  },
103
117
  state: {
@@ -1,7 +1,7 @@
1
1
  <script>
2
2
  import { BFormSelect } from 'bootstrap-vue';
3
3
  import isObject from 'lodash/isObject';
4
- import { formInputSizes } from '../../../../utils/constants';
4
+ import { formInputWidths } from '../../../../utils/constants';
5
5
 
6
6
  export default {
7
7
  name: 'GlFormSelect',
@@ -20,49 +20,28 @@ export default {
20
20
  validator: (value) => {
21
21
  const widths = isObject(value) ? Object.values(value) : [value];
22
22
 
23
- return widths.every((width) => Object.values(formInputSizes).includes(width));
24
- },
25
- },
26
- /**
27
- * ⚠️ DEPRECATED:
28
- *
29
- * Will be replaced by the
30
- * property width
31
- *
32
- * Maximum width of the Select
33
- */
34
- size: {
35
- type: [String, Object],
36
- required: false,
37
- default: null,
38
- validator: (value) => {
39
- const sizes = isObject(value) ? Object.values(value) : [value];
40
-
41
- return sizes.every((size) => Object.values(formInputSizes).includes(size));
23
+ return widths.every((width) => Object.values(formInputWidths).includes(width));
42
24
  },
43
25
  },
44
26
  },
45
27
  computed: {
46
- computedWidth() {
47
- return this.width ? this.width : this.size;
48
- },
49
28
  cssClasses() {
50
- if (this.computedWidth === null) {
29
+ if (this.width === null) {
51
30
  return [];
52
31
  }
53
32
 
54
- if (isObject(this.computedWidth)) {
55
- const { default: defaultSize, ...nonDefaultSizes } = this.computedWidth;
33
+ if (isObject(this.width)) {
34
+ const { default: defaultWidth, ...nonDefaultWidths } = this.width;
56
35
 
57
36
  return [
58
- ...(defaultSize ? [`gl-form-select-${defaultSize}`] : []),
59
- ...Object.entries(nonDefaultSizes).map(
60
- ([breakpoint, size]) => `gl-${breakpoint}-form-select-${size}`
37
+ ...(defaultWidth ? [`gl-form-select-${defaultWidth}`] : []),
38
+ ...Object.entries(nonDefaultWidths).map(
39
+ ([breakpoint, width]) => `gl-${breakpoint}-form-select-${width}`
61
40
  ),
62
41
  ];
63
42
  }
64
43
 
65
- return [`gl-form-select-${this.computedWidth}`];
44
+ return [`gl-form-select-${this.width}`];
66
45
  },
67
46
  },
68
47
  };
@@ -144,11 +144,6 @@ export const buttonSizeOptions = {
144
144
  medium: 'md',
145
145
  };
146
146
 
147
- export const datepickerSizeOptionsMap = {
148
- small: 'sm',
149
- medium: 'md',
150
- };
151
-
152
147
  export const datepickerWidthOptionsMap = {
153
148
  sm: 'sm',
154
149
  md: 'md',
@@ -290,7 +285,7 @@ export const keyboard = {
290
285
 
291
286
  export const truncateOptions = POSITION;
292
287
 
293
- export const formInputSizes = {
288
+ export const formInputWidths = {
294
289
  xs: 'xs',
295
290
  sm: 'sm',
296
291
  md: 'md',