@gitlab/ui 58.2.1 → 58.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "58.2.1",
3
+ "version": "58.4.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -19,7 +19,9 @@ export const glSpacingScale26 = '13rem'
19
19
  export const glSpacingScale28 = '14rem'
20
20
  export const glSpacingScale30 = '15rem'
21
21
  export const glSpacingScale34 = '17rem'
22
+ export const glSpacingScale48 = '24rem'
22
23
  export const glSpacingScale62 = '31rem'
24
+ export const glSpacingScale75 = '37.5rem'
23
25
  export const glSpacingScale80 = '40rem'
24
26
  export const breakpointSm = '576px'
25
27
  export const breakpointMd = '768px'
@@ -253,6 +255,7 @@ export const glFontWeightNormal = '400'
253
255
  export const glFontWeightSemibold = '500'
254
256
  export const glFontWeightBold = '600'
255
257
  export const glFontWeights = '("normal": 400, "bold": 600)'
258
+ export const glLineHeight12 = '0.75rem'
256
259
  export const glLineHeight16 = '1rem'
257
260
  export const glLineHeight20 = '1.25rem'
258
261
  export const glLineHeight24 = '1.5rem'
@@ -263,6 +266,7 @@ export const glLineHeight42 = '2.625rem'
263
266
  export const glLineHeight44 = '2.75rem'
264
267
  export const glLineHeight52 = '3.25rem'
265
268
  export const glFontSize = '0.875rem'
269
+ export const glFontSizeXs = '0.625rem'
266
270
  export const glFontSizeSm = '0.75rem'
267
271
  export const glFontSizeLg = '1rem'
268
272
  export const glFontSizeHDisplay = '1.75rem'
@@ -105,11 +105,21 @@
105
105
  "value": "34 * $grid-size",
106
106
  "compiledValue": "17rem"
107
107
  },
108
+ {
109
+ "name": "$gl-spacing-scale-48",
110
+ "value": "48 * $grid-size",
111
+ "compiledValue": "24rem"
112
+ },
108
113
  {
109
114
  "name": "$gl-spacing-scale-62",
110
115
  "value": "62 * $grid-size",
111
116
  "compiledValue": "31rem"
112
117
  },
118
+ {
119
+ "name": "$gl-spacing-scale-75",
120
+ "value": "75 * $grid-size",
121
+ "compiledValue": "37.5rem"
122
+ },
113
123
  {
114
124
  "name": "$gl-spacing-scale-80",
115
125
  "value": "80 * $grid-size",
@@ -1314,6 +1324,11 @@
1314
1324
  ],
1315
1325
  "compiledValue": "(\"normal\": 400, \"bold\": 600)"
1316
1326
  },
1327
+ {
1328
+ "name": "$gl-line-height-12",
1329
+ "value": "px-to-rem(12px)",
1330
+ "compiledValue": "0.75rem"
1331
+ },
1317
1332
  {
1318
1333
  "name": "$gl-line-height-16",
1319
1334
  "value": "px-to-rem(16px)",
@@ -1364,6 +1379,11 @@
1364
1379
  "value": "px-to-rem(14px)",
1365
1380
  "compiledValue": "0.875rem"
1366
1381
  },
1382
+ {
1383
+ "name": "$gl-font-size-xs",
1384
+ "value": "px-to-rem(10px)",
1385
+ "compiledValue": "0.625rem"
1386
+ },
1367
1387
  {
1368
1388
  "name": "$gl-font-size-sm",
1369
1389
  "value": "px-to-rem(12px)",
@@ -63,6 +63,36 @@ describe('GlCollapsibleListbox', () => {
63
63
  });
64
64
  });
65
65
 
66
+ describe('toggle classes', () => {
67
+ describe.each`
68
+ toggleClass | multiple | selected | expectedToggleClasses
69
+ ${'customClass'} | ${false} | ${mockOptions[0].value} | ${['customClass']}
70
+ ${{ customClass: true }} | ${false} | ${mockOptions[0].value} | ${[{ customClass: true }]}
71
+ ${['customClass']} | ${false} | ${mockOptions[0].value} | ${[['customClass']]}
72
+ ${'customClass'} | ${false} | ${null} | ${['customClass', 'gl-text-gray-500!']}
73
+ ${{ customClass: true }} | ${false} | ${undefined} | ${[{ customClass: true }, 'gl-text-gray-500!']}
74
+ ${['customClass']} | ${false} | ${null} | ${[['customClass'], 'gl-text-gray-500!']}
75
+ ${'customClass'} | ${true} | ${[mockOptions[0].value]} | ${['customClass']}
76
+ ${{ customClass: true }} | ${true} | ${[mockOptions[0].value]} | ${[{ customClass: true }]}
77
+ ${['customClass']} | ${true} | ${[mockOptions[0].value]} | ${[['customClass']]}
78
+ ${'customClass'} | ${true} | ${null} | ${['customClass', 'gl-text-gray-500!']}
79
+ ${{ customClass: true }} | ${true} | ${undefined} | ${[{ customClass: true }, 'gl-text-gray-500!']}
80
+ ${['customClass']} | ${true} | ${null} | ${[['customClass'], 'gl-text-gray-500!']}
81
+ `('when listbox', ({ toggleClass, multiple, selected, expectedToggleClasses }) => {
82
+ beforeEach(() => {
83
+ buildWrapper({ items: mockOptions, toggleClass, multiple, selected });
84
+ });
85
+
86
+ it(`is ${multiple ? 'multi' : 'single'}-select and ${
87
+ selected
88
+ ? 'has selected - does not set non-selected styles'
89
+ : 'does not have selected - sets the non-selected styles'
90
+ }`, () => {
91
+ expect(findBaseDropdown().props('toggleClass')).toEqual(expectedToggleClasses);
92
+ });
93
+ });
94
+ });
95
+
66
96
  describe('ARIA attributes', () => {
67
97
  it('should provide `toggleId` to the base dropdown and reference it in`aria-labelledby` attribute of the list container`', async () => {
68
98
  await buildWrapper({ items: mockOptions });
@@ -45,6 +45,7 @@ const generateProps = ({
45
45
  searchPlaceholder = defaultValue('searchPlaceholder'),
46
46
  noCaret = defaultValue('noCaret'),
47
47
  placement = defaultValue('placement'),
48
+ toggleClass,
48
49
  toggleText,
49
50
  textSrOnly = defaultValue('textSrOnly'),
50
51
  headerText = defaultValue('headerText'),
@@ -71,6 +72,7 @@ const generateProps = ({
71
72
  searchPlaceholder,
72
73
  noCaret,
73
74
  placement,
75
+ toggleClass,
74
76
  toggleText,
75
77
  textSrOnly,
76
78
  headerText,
@@ -100,6 +102,7 @@ const makeBindings = (overrides = {}) =>
100
102
  ':search-placeholder': 'searchPlaceholder',
101
103
  ':no-caret': 'noCaret',
102
104
  ':placement': 'placement',
105
+ ':toggle-class': 'toggleClass',
103
106
  ':toggle-text': 'toggleText',
104
107
  ':text-sr-only': 'textSrOnly',
105
108
  ':header-text': 'headerText',
@@ -231,9 +234,10 @@ export const CustomListItem = (args, { argTypes }) => ({
231
234
  },
232
235
  computed: {
233
236
  customToggleText() {
234
- return this.selected.length !== 1
235
- ? `${this.selected.length} assignees`
236
- : this.items.find(({ value }) => value === this.selected[0]).text;
237
+ if (this.selected.length === 0) return 'Select assignee(s)';
238
+ if (this.selected.length === 1)
239
+ return this.items.find(({ value }) => value === this.selected[0]).text;
240
+ return `${this.selected.length} assignees`;
237
241
  },
238
242
  },
239
243
  methods: {
@@ -349,6 +349,17 @@ export default {
349
349
  hasCustomToggle() {
350
350
  return Boolean(this.$scopedSlots.toggle);
351
351
  },
352
+ hasSelection() {
353
+ return Boolean(this.selectedValues.length);
354
+ },
355
+ toggleButtonClasses() {
356
+ const toggleClasses = [this.toggleClass];
357
+
358
+ if (!this.hasSelection) {
359
+ toggleClasses.push('gl-text-gray-500!');
360
+ }
361
+ return toggleClasses;
362
+ },
352
363
  },
353
364
  watch: {
354
365
  selected: {
@@ -561,7 +572,7 @@ export default {
561
572
  :block="block"
562
573
  :toggle-id="toggleId"
563
574
  :toggle-text="listboxToggleText"
564
- :toggle-class="toggleClass"
575
+ :toggle-class="toggleButtonClasses"
565
576
  :text-sr-only="textSrOnly"
566
577
  :category="category"
567
578
  :variant="variant"