@gitlab/ui 43.10.0 → 43.13.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.
@@ -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, sizeOptions, sizeOptionsWithNoDefault, tabsButtonDefaults, targetOptions, toggleLabelPosition, tokenVariants, tooltipActionEvents, tooltipDelay, tooltipPlacements, triggerVariantOptions, truncateOptions, variantCssColorMap, variantOptions, variantOptionsWithNoDefault, viewModeOptions };
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "43.10.0",
3
+ "version": "43.13.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -102,7 +102,7 @@
102
102
  "babel-plugin-require-context-hook": "^1.0.0",
103
103
  "babel-preset-vue": "^2.0.2",
104
104
  "bootstrap": "4.5.3",
105
- "cypress": "^10.6.0",
105
+ "cypress": "^10.7.0",
106
106
  "emoji-regex": "^10.0.0",
107
107
  "eslint": "8.22.0",
108
108
  "eslint-import-resolver-jest": "3.0.2",
@@ -112,9 +112,9 @@
112
112
  "glob": "^7.2.0",
113
113
  "identity-obj-proxy": "^3.0.0",
114
114
  "inquirer-select-directory": "^1.2.0",
115
- "jest": "^29.0.1",
116
- "jest-circus": "29.0.1",
117
- "jest-environment-jsdom": "29.0.1",
115
+ "jest": "^29.0.2",
116
+ "jest-circus": "29.0.2",
117
+ "jest-environment-jsdom": "29.0.2",
118
118
  "jest-serializer-vue": "^2.0.2",
119
119
  "markdownlint-cli": "^0.29.0",
120
120
  "mockdate": "^2.0.5",
@@ -26,6 +26,7 @@ export const breakpointLg = '992px'
26
26
  export const breakpointXl = '1200px'
27
27
  export const breakpoints = '(xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)'
28
28
  export const limitedLayoutWidth = '990px'
29
+ export const containerXl = '1280px'
29
30
  export const black = '#000'
30
31
  export const blackNormal = '#333'
31
32
  export const white = '#fff'
@@ -167,6 +167,11 @@
167
167
  "value": "990px",
168
168
  "compiledValue": "990px"
169
169
  },
170
+ {
171
+ "name": "$container-xl",
172
+ "value": "1280px",
173
+ "compiledValue": "1280px"
174
+ },
170
175
  {
171
176
  "name": "$black",
172
177
  "value": "#000",
@@ -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 { sizeOptions, formStateOptions } from '../../../../utils/constants';
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(sizeOptions);
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, `custom-select-${size}`].sort()
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 { sizeOptions, formStateOptions } from '../../../../utils/constants';
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: sizeOptions,
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>
@@ -79,6 +79,7 @@ const generateProps = ({
79
79
  textSrOnly = defaultValue('textSrOnly'),
80
80
  icon = '',
81
81
  multiple = defaultValue('multiple'),
82
+ isCheckCentered = defaultValue('isCheckCentered'),
82
83
  ariaLabelledby,
83
84
  startOpened = true,
84
85
  } = {}) => ({
@@ -94,6 +95,7 @@ const generateProps = ({
94
95
  textSrOnly,
95
96
  icon,
96
97
  multiple,
98
+ isCheckCentered,
97
99
  ariaLabelledby,
98
100
  startOpened,
99
101
  });
@@ -120,6 +122,7 @@ const template = (content, label = '') => `
120
122
  :text-sr-only="textSrOnly"
121
123
  :icon="icon"
122
124
  :multiple="multiple"
125
+ :is-check-centered="isCheckCentered"
123
126
  :aria-labelledby="ariaLabelledby"
124
127
  >
125
128
  ${content}
@@ -183,7 +186,10 @@ export const HeaderAndFooter = (args, { argTypes }) => ({
183
186
  </div>
184
187
  </template>`),
185
188
  });
186
- HeaderAndFooter.args = generateProps({ toggleText: 'Header and Footer', multiple: true });
189
+ HeaderAndFooter.args = generateProps({
190
+ toggleText: 'Header and Footer',
191
+ multiple: true,
192
+ });
187
193
  HeaderAndFooter.decorators = [makeContainer({ height: '370px' })];
188
194
 
189
195
  export const CustomListItem = (args, { argTypes }) => ({
@@ -225,6 +231,7 @@ export const CustomListItem = (args, { argTypes }) => ({
225
231
  :text-sr-only="textSrOnly"
226
232
  :icon="icon"
227
233
  :multiple="multiple"
234
+ :is-check-centered="isCheckCentered"
228
235
  :aria-labelledby="ariaLabelledby"
229
236
  >
230
237
  <template #list-item="{ item }">
@@ -247,6 +254,7 @@ CustomListItem.args = generateProps({
247
254
  { value: 'markian', text: 'Mark Florian', secondaryText: '@markian', icon: 'bin' },
248
255
  ],
249
256
  multiple: true,
257
+ isCheckCentered: true,
250
258
  });
251
259
  CustomListItem.decorators = [makeContainer({ height: '200px' })];
252
260
 
@@ -152,6 +152,14 @@ export default {
152
152
  required: false,
153
153
  default: false,
154
154
  },
155
+ /**
156
+ * Center selected item checkmark
157
+ */
158
+ isCheckCentered: {
159
+ type: Boolean,
160
+ required: false,
161
+ default: false,
162
+ },
155
163
  /**
156
164
  * The `aria-labelledby` attribute value for the toggle button
157
165
  */
@@ -335,6 +343,7 @@ export default {
335
343
  :key="item.value"
336
344
  :is-selected="isSelected(item)"
337
345
  :is-focused="nextFocusedItemIndex === index"
346
+ :is-check-centered="isCheckCentered"
338
347
  @select="onSelect(item, $event)"
339
348
  >
340
349
  <!-- @slot Custom template of the listbox item -->
@@ -80,6 +80,31 @@ describe('GlListboxItem', () => {
80
80
  });
81
81
  });
82
82
 
83
+ describe('checkbox', () => {
84
+ describe('is NOT centered', () => {
85
+ beforeEach(() => {
86
+ buildWrapper({ isSelected: true });
87
+ });
88
+
89
+ it('should not center check icon by default', () => {
90
+ expect(findCheckIcon().classes()).toEqual(
91
+ expect.arrayContaining(['gl-mt-3', 'gl-align-self-start'])
92
+ );
93
+ });
94
+ });
95
+
96
+ describe('is centered', () => {
97
+ beforeEach(() => {
98
+ buildWrapper({ isSelected: true, isCheckCentered: true });
99
+ });
100
+ it('should center the check icon', () => {
101
+ expect(findCheckIcon().classes()).not.toEqual(
102
+ expect.arrayContaining(['gl-mt-3', 'gl-align-self-start'])
103
+ );
104
+ });
105
+ });
106
+ });
107
+
83
108
  describe('tabindex', () => {
84
109
  it('should set tabindex to `-1` when item is not focused', () => {
85
110
  buildWrapper({ isFocused: false });
@@ -18,6 +18,20 @@ export default {
18
18
  default: false,
19
19
  required: false,
20
20
  },
21
+ isCheckCentered: {
22
+ type: Boolean,
23
+ required: false,
24
+ default: false,
25
+ },
26
+ },
27
+ computed: {
28
+ checkedClasses() {
29
+ if (this.isCheckCentered) {
30
+ return '';
31
+ }
32
+
33
+ return 'gl-mt-3 gl-align-self-start';
34
+ },
21
35
  },
22
36
  methods: {
23
37
  toggleSelection() {
@@ -48,8 +62,11 @@ export default {
48
62
  <gl-icon
49
63
  name="mobile-issue-close"
50
64
  data-testid="dropdown-item-checkbox"
51
- class="gl-mt-3 gl-align-self-start"
52
- :class="['gl-new-dropdown-item-check-icon', { 'gl-visibility-hidden': !isSelected }]"
65
+ :class="[
66
+ 'gl-new-dropdown-item-check-icon',
67
+ { 'gl-visibility-hidden': !isSelected },
68
+ checkedClasses,
69
+ ]"
53
70
  />
54
71
  <span class="gl-new-dropdown-item-text-wrapper">
55
72
  <slot></slot>
@@ -1,5 +1,3 @@
1
- # Toggle
2
-
3
1
  ## Usage
4
2
 
5
3
  The toggle component must have a `label` prop to give the toggle button an accessible name.
@@ -3112,6 +3112,18 @@
3112
3112
  }
3113
3113
  }
3114
3114
 
3115
+ .gl-sm-align-items-center {
3116
+ @include gl-media-breakpoint-up(sm) {
3117
+ align-items: center;
3118
+ }
3119
+ }
3120
+
3121
+ .gl-sm-align-items-center\! {
3122
+ @include gl-media-breakpoint-up(sm) {
3123
+ align-items: center !important;
3124
+ }
3125
+ }
3126
+
3115
3127
  .gl-md-align-items-center {
3116
3128
  @include gl-media-breakpoint-up(md) {
3117
3129
  align-items: center;
@@ -4559,6 +4571,14 @@
4559
4571
  max-width: $limited-layout-width !important;
4560
4572
  }
4561
4573
 
4574
+ .gl-max-w-container-xl {
4575
+ max-width: $container-xl;
4576
+ }
4577
+
4578
+ .gl-max-w-container-xl\! {
4579
+ max-width: $container-xl !important;
4580
+ }
4581
+
4562
4582
  .gl-h-auto {
4563
4583
  height: auto;
4564
4584
  }
@@ -36,6 +36,12 @@
36
36
  }
37
37
  }
38
38
 
39
+ @mixin gl-sm-align-items-center {
40
+ @include gl-media-breakpoint-up(sm) {
41
+ @include gl-align-items-center;
42
+ }
43
+ }
44
+
39
45
  @mixin gl-md-align-items-center {
40
46
  @include gl-media-breakpoint-up(md) {
41
47
  @include gl-align-items-center;
@@ -155,6 +155,10 @@
155
155
  max-width: $limited-layout-width;
156
156
  }
157
157
 
158
+ @mixin gl-max-w-container-xl {
159
+ max-width: $container-xl;
160
+ }
161
+
158
162
  @mixin gl-h-auto {
159
163
  height: auto;
160
164
  }
@@ -41,6 +41,7 @@ $breakpoints: (
41
41
 
42
42
  // Max widths
43
43
  $limited-layout-width: 990px !default;
44
+ $container-xl: 1280px !default;
44
45
 
45
46
  // Color schema
46
47
  $black: #000 !default;
@@ -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';