@gitlab/ui 80.0.0 → 80.0.1

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,10 @@
1
+ ## [80.0.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v80.0.0...v80.0.1) (2024-05-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **Dropdown:** Fix disclosure dropdown a11y issues ([34d2c4d](https://gitlab.com/gitlab-org/gitlab-ui/commit/34d2c4d496f66c2c9e9129793e6a0c4189d77ec9))
7
+
1
8
  # [80.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v79.4.1...v80.0.0) (2024-05-01)
2
9
 
3
10
 
@@ -218,7 +218,9 @@ var script = {
218
218
  computed: {
219
219
  disclosureTag() {
220
220
  var _this$items;
221
- if ((_this$items = this.items) !== null && _this$items !== void 0 && _this$items.length || hasOnlyListItems(this.$scopedSlots)) {
221
+ if ((_this$items = this.items) !== null && _this$items !== void 0 && _this$items.length ||
222
+ // eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
223
+ hasOnlyListItems(this.$scopedSlots.default || this.$slots.default)) {
222
224
  return 'ul';
223
225
  }
224
226
  return 'div';
@@ -1,4 +1,6 @@
1
+ import Vue from 'vue';
1
2
  import isFunction from 'lodash/isFunction';
3
+ import isString from 'lodash/isString';
2
4
  import { DISCLOSURE_DROPDOWN_ITEM_NAME, DISCLOSURE_DROPDOWN_GROUP_NAME } from './constants';
3
5
 
4
6
  const itemValidator = item => {
@@ -17,23 +19,34 @@ const isValidSlotTagVue2 = vNode => {
17
19
  var _vNode$componentOptio;
18
20
  return Boolean(vNode) && isListItem(((_vNode$componentOptio = vNode.componentOptions) === null || _vNode$componentOptio === void 0 ? void 0 : _vNode$componentOptio.tag) || vNode.tag);
19
21
  };
20
- const isValidSlotTag = vNode => {
22
+ const isValidSlotTagVue3 = vNode => {
21
23
  var _vNode$type;
22
24
  return [DISCLOSURE_DROPDOWN_ITEM_NAME, DISCLOSURE_DROPDOWN_GROUP_NAME].includes((_vNode$type = vNode.type) === null || _vNode$type === void 0 ? void 0 : _vNode$type.name) || vNode.type === 'li';
23
25
  };
24
- const hasOnlyListItems = _ref => {
25
- let {
26
- default: defaultSlot
27
- } = _ref;
28
- if (!isFunction(defaultSlot)) {
29
- return false;
30
- }
26
+ const hasOnlyListItemsVue2 = defaultSlot => {
31
27
  const nodes = defaultSlot();
32
28
  if (!Array.isArray(nodes)) {
33
29
  return false;
34
30
  }
35
31
  const tags = nodes.filter(vNode => vNode.tag);
36
- return tags.length && tags.every(tag => isValidSlotTag(tag) || isValidSlotTagVue2(tag));
32
+ return tags.length && tags.every(tag => isValidSlotTagVue2(tag));
33
+ };
34
+ const hasOnlyListItemsVue3 = defaultSlot => {
35
+ const nodes = defaultSlot();
36
+ const fragment = nodes.find(node => Array.isArray(node.children) && node.children.length);
37
+ const targetNodes = fragment ? fragment.children : nodes;
38
+ return targetNodes
39
+ // Remove empty text vNodes
40
+ .filter(vNode => !isString(vNode.text) || vNode.text.trim().length > 0).every(vNode => isValidSlotTagVue3(vNode));
41
+ };
42
+ const hasOnlyListItems = defaultSlot => {
43
+ if (!isFunction(defaultSlot)) {
44
+ return false;
45
+ }
46
+ if (Vue.version.startsWith('3')) {
47
+ return hasOnlyListItemsVue3(defaultSlot);
48
+ }
49
+ return hasOnlyListItemsVue2(defaultSlot);
37
50
  };
38
51
 
39
52
  export { hasOnlyListItems, isGroup, isItem, itemsValidator };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Wed, 01 May 2024 16:11:38 GMT
3
+ * Generated on Thu, 02 May 2024 10:07:41 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Wed, 01 May 2024 16:11:38 GMT
3
+ * Generated on Thu, 02 May 2024 10:07:41 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 Wed, 01 May 2024 16:11:38 GMT
3
+ * Generated on Thu, 02 May 2024 10:07:41 GMT
4
4
  */
5
5
 
6
6
  export const DATA_VIZ_GREEN_50 = "#133a03";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Wed, 01 May 2024 16:11:38 GMT
3
+ * Generated on Thu, 02 May 2024 10:07:41 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 Wed, 01 May 2024 16:11:38 GMT
3
+ // Generated on Thu, 02 May 2024 10:07:41 GMT
4
4
 
5
5
  $gl-text-color-disabled: #89888d !default; // Used for disabled text.
6
6
  $gl-text-color-link: #63a6e9 !default; // Used for default text links.
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Wed, 01 May 2024 16:11:38 GMT
3
+ // Generated on Thu, 02 May 2024 10:07:41 GMT
4
4
 
5
5
  $gl-text-color-disabled: #89888d !default; // Used for disabled text.
6
6
  $gl-text-color-success: #217645 !default; // Used for text indicating success or validity.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "80.0.0",
3
+ "version": "80.0.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -131,7 +131,7 @@
131
131
  "babel-jest": "29.0.1",
132
132
  "babel-loader": "^8.0.5",
133
133
  "bootstrap": "4.6.2",
134
- "cypress": "13.8.0",
134
+ "cypress": "13.8.1",
135
135
  "cypress-axe": "^1.4.0",
136
136
  "cypress-real-events": "^1.11.0",
137
137
  "dompurify": "^3.0.0",
@@ -1,25 +1,32 @@
1
- import { formStateOptions, formInputWidths } from '../../../../utils/constants';
2
- import GlFormSelect from './form_select.vue';
1
+ import uniqueId from 'lodash/uniqueId';
2
+ import { formInputWidths, formStateOptions } from '../../../../utils/constants';
3
+ import GlFormGroup from '../form_group/form_group.vue';
3
4
  import { formSelectOptions } from './constants';
4
5
  import readme from './form_select.md';
6
+ import GlFormSelect from './form_select.vue';
5
7
 
6
8
  const data = () => ({
7
9
  selected: 'Pizza',
8
10
  });
9
11
 
10
12
  const template = `
11
- <gl-form-select
12
- v-model="selected"
13
- :width="width"
14
- :disabled="disabled"
15
- :state="state"
16
- :multiple="multiple"
17
- :selectSize="selectSize"
18
- :options="options">
19
- </gl-form-select>
13
+ <gl-form-group :label="labelText" :label-for="inputId">
14
+ <gl-form-select
15
+ :id="inputId"
16
+ v-model="selected"
17
+ :width="width"
18
+ :disabled="disabled"
19
+ :state="state"
20
+ :multiple="multiple"
21
+ :selectSize="selectSize"
22
+ :options="options">
23
+ </gl-form-select>
24
+ </gl-form-group>
20
25
  `;
21
26
 
22
27
  const generateProps = ({
28
+ inputId = uniqueId('input-'),
29
+ labelText = 'Label',
23
30
  width = null,
24
31
  state = null,
25
32
  disabled = false,
@@ -27,6 +34,8 @@ const generateProps = ({
27
34
  selectSize = 1,
28
35
  options = formSelectOptions,
29
36
  } = {}) => ({
37
+ inputId,
38
+ labelText,
30
39
  width,
31
40
  disabled,
32
41
  state,
@@ -36,7 +45,7 @@ const generateProps = ({
36
45
  });
37
46
 
38
47
  const Template = (args) => ({
39
- components: { GlFormSelect },
48
+ components: { GlFormSelect, GlFormGroup },
40
49
  props: Object.keys(args),
41
50
  data,
42
51
  template,
@@ -55,7 +64,7 @@ export const InvalidState = Template.bind({});
55
64
  InvalidState.args = generateProps({ state: false });
56
65
 
57
66
  export const WithTruncation = (args, { argTypes }) => ({
58
- components: { GlFormSelect },
67
+ components: { GlFormSelect, GlFormGroup },
59
68
  props: Object.keys(argTypes),
60
69
  data() {
61
70
  return {
@@ -78,7 +87,7 @@ WithTruncation.args = generateProps({
78
87
  });
79
88
 
80
89
  export const Widths = (args, { argTypes }) => ({
81
- components: { GlFormSelect },
90
+ components: { GlFormSelect, GlFormGroup },
82
91
  props: Object.keys(argTypes),
83
92
  data() {
84
93
  return {
@@ -87,13 +96,14 @@ export const Widths = (args, { argTypes }) => ({
87
96
  },
88
97
  template: `
89
98
  <div>
90
- <div v-for="(width, name) in formInputWidths" :key="width" class="gl-mb-4">
99
+ <gl-form-group v-for="(width, name) in formInputWidths" :key="width" :label="name" :label-for="'width-' + width">
91
100
  <gl-form-select
101
+ :id="'width-' + width"
92
102
  v-model="name"
93
103
  :width="width"
94
104
  :options="[{ value: name, text: name }]">
95
105
  </gl-form-select>
96
- </div>
106
+ </gl-form-group>
97
107
  </div>`,
98
108
  });
99
109
  Widths.args = generateProps();
@@ -201,7 +201,7 @@ export const CustomGroupsItemsAndToggle = makeGroupedExample({
201
201
  <template #list-item>
202
202
  <span class="gl-display-flex gl-flex-direction-column">
203
203
  <span class="gl-font-weight-bold gl-white-space-nowrap">Orange Fox</span>
204
- <span class="gl-text-gray-400">@thefox</span>
204
+ <span class="gl-text-gray-600">@thefox</span>
205
205
  </span>
206
206
  </template>
207
207
  </gl-disclosure-dropdown-item>
@@ -237,7 +237,11 @@ export default {
237
237
  },
238
238
  computed: {
239
239
  disclosureTag() {
240
- if (this.items?.length || hasOnlyListItems(this.$scopedSlots)) {
240
+ if (
241
+ this.items?.length ||
242
+ // eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots
243
+ hasOnlyListItems(this.$scopedSlots.default || this.$slots.default)
244
+ ) {
241
245
  return 'ul';
242
246
  }
243
247
  return 'div';
@@ -1,4 +1,6 @@
1
+ import Vue from 'vue';
1
2
  import isFunction from 'lodash/isFunction';
3
+ import isString from 'lodash/isString';
2
4
  import { DISCLOSURE_DROPDOWN_ITEM_NAME, DISCLOSURE_DROPDOWN_GROUP_NAME } from './constants';
3
5
 
4
6
  const itemValidator = (item) => item?.text?.length > 0 && !Array.isArray(item?.items);
@@ -21,17 +23,14 @@ const isListItem = (tag) =>
21
23
  const isValidSlotTagVue2 = (vNode) =>
22
24
  Boolean(vNode) && isListItem(vNode.componentOptions?.tag || vNode.tag);
23
25
 
24
- const isValidSlotTag = (vNode) => {
26
+ const isValidSlotTagVue3 = (vNode) => {
25
27
  return (
26
28
  [DISCLOSURE_DROPDOWN_ITEM_NAME, DISCLOSURE_DROPDOWN_GROUP_NAME].includes(vNode.type?.name) ||
27
29
  vNode.type === 'li'
28
30
  );
29
31
  };
30
32
 
31
- const hasOnlyListItems = ({ default: defaultSlot }) => {
32
- if (!isFunction(defaultSlot)) {
33
- return false;
34
- }
33
+ const hasOnlyListItemsVue2 = (defaultSlot) => {
35
34
  const nodes = defaultSlot();
36
35
 
37
36
  if (!Array.isArray(nodes)) {
@@ -40,7 +39,32 @@ const hasOnlyListItems = ({ default: defaultSlot }) => {
40
39
 
41
40
  const tags = nodes.filter((vNode) => vNode.tag);
42
41
 
43
- return tags.length && tags.every((tag) => isValidSlotTag(tag) || isValidSlotTagVue2(tag));
42
+ return tags.length && tags.every((tag) => isValidSlotTagVue2(tag));
43
+ };
44
+
45
+ const hasOnlyListItemsVue3 = (defaultSlot) => {
46
+ const nodes = defaultSlot();
47
+ const fragment = nodes.find((node) => Array.isArray(node.children) && node.children.length);
48
+ const targetNodes = fragment ? fragment.children : nodes;
49
+
50
+ return (
51
+ targetNodes
52
+ // Remove empty text vNodes
53
+ .filter((vNode) => !isString(vNode.text) || vNode.text.trim().length > 0)
54
+ .every((vNode) => isValidSlotTagVue3(vNode))
55
+ );
56
+ };
57
+
58
+ const hasOnlyListItems = (defaultSlot) => {
59
+ if (!isFunction(defaultSlot)) {
60
+ return false;
61
+ }
62
+
63
+ if (Vue.version.startsWith('3')) {
64
+ return hasOnlyListItemsVue3(defaultSlot);
65
+ }
66
+
67
+ return hasOnlyListItemsVue2(defaultSlot);
44
68
  };
45
69
 
46
70
  export { itemsValidator, isItem, isGroup, hasOnlyListItems };
@@ -27,13 +27,13 @@ pagination, use `GlTableLite` which offers a subset of `GlTable` features.
27
27
  fields: [
28
28
  {
29
29
  key: 'column_one',
30
- label: __('Column One'),
30
+ label: __('First column'),
31
31
  thClass: 'w-60p',
32
32
  tdClass: 'table-col d-flex'
33
33
  },
34
34
  {
35
35
  key: 'col_2',
36
- label: __('Column 2'),
36
+ label: __('Second column'),
37
37
  thClass: 'w-15p',
38
38
  tdClass: 'table-col d-flex'
39
39
  },
@@ -43,7 +43,7 @@ pagination, use `GlTableLite` which offers a subset of `GlTable` features.
43
43
  <template>
44
44
  <gl-table :items="items" :fields="$options.fields">
45
45
  <template #head(column_one)>
46
- <div>Column One</div>
46
+ <div>First column</div>
47
47
  <!-- This is the column head for the first object in `fields` -->
48
48
  </template>
49
49
 
@@ -63,20 +63,20 @@ export const Default = (args, { argTypes }) => ({
63
63
  fields: [
64
64
  {
65
65
  key: 'column_one',
66
- label: 'Column One',
66
+ label: 'First column',
67
67
  variant: 'secondary',
68
68
  sortable: true,
69
69
  isRowHeader: false,
70
70
  },
71
71
  {
72
72
  key: 'col_2',
73
- label: 'Column 2',
73
+ label: 'Second column',
74
74
  formatter: (value) => value,
75
75
  },
76
76
  {
77
77
  key: 'col_three',
78
78
  sortable: true,
79
- label: 'Column 2',
79
+ label: 'Third column',
80
80
  formatter: (value) => value,
81
81
  thClass: 'gl-text-right',
82
82
  tdClass: 'gl-text-right',
@@ -37,13 +37,13 @@ export default {
37
37
  fields: [
38
38
  {
39
39
  key: 'column_one',
40
- label: __('Column One'),
40
+ label: __('First column'),
41
41
  thClass: 'w-60p',
42
42
  tdClass: 'table-col d-flex'
43
43
  },
44
44
  {
45
45
  key: 'col_2',
46
- label: __('Column 2'),
46
+ label: __('Second column'),
47
47
  thClass: 'w-15p',
48
48
  tdClass: 'table-col d-flex'
49
49
  },
@@ -56,7 +56,7 @@ export default {
56
56
  :fields="$options.fields"
57
57
  >
58
58
  <template #head(column_one)>
59
- <div>Column One</div><!-- This is the column head for the first object in `fields` -->
59
+ <div>First column</div><!-- This is the column head for the first object in `fields` -->
60
60
  </template>
61
61
 
62
62
  <template #cell(column_one)>
@@ -4,13 +4,13 @@ import GlTableLite from './table_lite.vue';
4
4
  const fieldsMock = [
5
5
  {
6
6
  key: 'column_one',
7
- label: 'Column One',
7
+ label: 'First column',
8
8
  thClass: 'w-60p',
9
9
  tdClass: 'table-col',
10
10
  },
11
11
  {
12
12
  key: 'column_two',
13
- label: 'Column Two',
13
+ label: 'Second column',
14
14
  thClass: 'w-60p',
15
15
  tdClass: 'table-col',
16
16
  },