@gitlab/ui 58.2.1 → 58.3.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.3.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -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"
@@ -1743,6 +1743,16 @@
1743
1743
  border-bottom-right-radius: 0 !important;
1744
1744
  }
1745
1745
 
1746
+ .gl-rounded-bottom-base {
1747
+ border-bottom-left-radius: $gl-border-radius-base;
1748
+ border-bottom-right-radius: $gl-border-radius-base;
1749
+ }
1750
+
1751
+ .gl-rounded-bottom-base\! {
1752
+ border-bottom-left-radius: $gl-border-radius-base !important;
1753
+ border-bottom-right-radius: $gl-border-radius-base !important;
1754
+ }
1755
+
1746
1756
  .gl-rounded-top-left-small {
1747
1757
  border-top-left-radius: $gl-border-radius-small;
1748
1758
  }
@@ -421,6 +421,11 @@
421
421
  border-bottom-right-radius: 0;
422
422
  }
423
423
 
424
+ @mixin gl-rounded-bottom-base {
425
+ border-bottom-left-radius: $gl-border-radius-base;
426
+ border-bottom-right-radius: $gl-border-radius-base;
427
+ }
428
+
424
429
  @mixin gl-rounded-top-left-small {
425
430
  border-top-left-radius: $gl-border-radius-small;
426
431
  }