@gitlab/ui 80.0.0 → 80.1.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,17 @@
1
+ # [80.1.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v80.0.1...v80.1.0) (2024-05-03)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlDrawer:** Fix alignment of close button ([8bd418a](https://gitlab.com/gitlab-org/gitlab-ui/commit/8bd418ad69b7ca9588d8eeb0fe21ca290a730a7f))
7
+
8
+ ## [80.0.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v80.0.0...v80.0.1) (2024-05-02)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **Dropdown:** Fix disclosure dropdown a11y issues ([34d2c4d](https://gitlab.com/gitlab-org/gitlab-ui/commit/34d2c4d496f66c2c9e9129793e6a0c4189d77ec9))
14
+
1
15
  # [80.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v79.4.1...v80.0.0) (2024-05-01)
2
16
 
3
17
 
@@ -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 };