1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var core = require('@vueuse/core');
require('../../../utils/index.js');
require('../../../hooks/index.js');
var token = require('./token.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-namespace/index.js');
var lodashUnified = require('lodash-unified');
const _sfc_main = vue.defineComponent({
name: "ElOptionGroup",
componentName: "ElOptionGroup",
props: {
label: String,
disabled: Boolean
},
setup(props) {
const ns = index.useNamespace("select");
const groupRef = vue.ref(null);
const instance = vue.getCurrentInstance();
const children = vue.ref([]);
vue.provide(token.selectGroupKey, vue.reactive({
...vue.toRefs(props)
}));
const visible = vue.computed(() => children.value.some((option) => option.visible === true));
const isOption = (node) => {
var _a, _b;
return ((_a = node.type) == null ? void 0 : _a.name) === "ElOption" && !!((_b = node.component) == null ? void 0 : _b.proxy);
};
const flattedChildren = (node) => {
const Nodes = lodashUnified.castArray(node);
const children2 = [];
Nodes.forEach((child) => {
var _a, _b;
if (isOption(child)) {
children2.push(child.component.proxy);
} else if ((_a = child.children) == null ? void 0 : _a.length) {
children2.push(...flattedChildren(child.children));
} else if ((_b = child.component) == null ? void 0 : _b.subTree) {
children2.push(...flattedChildren(child.component.subTree));
}
});
return children2;
};
const updateChildren = () => {
children.value = flattedChildren(instance.subTree);
};
vue.onMounted(() => {
updateChildren();
});
core.useMutationObserver(groupRef, updateChildren, {
attributes: true,
subtree: true,
childList: true
});
return {
groupRef,
visible,
ns
};
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return vue.withDirectives((vue.openBlock(), vue.createElementBlock("ul", {
ref: "groupRef",
class: vue.normalizeClass(_ctx.ns.be("group", "wrap"))
}, [
vue.createElementVNode("li", {
class: vue.normalizeClass(_ctx.ns.be("group", "title"))
}, vue.toDisplayString(_ctx.label), 3),
vue.createElementVNode("li", null, [
vue.createElementVNode("ul", {
class: vue.normalizeClass(_ctx.ns.b("group"))
}, [
vue.renderSlot(_ctx.$slots, "default")
], 2)
])
], 2)), [
[vue.vShow, _ctx.visible]
]);
}
var OptionGroup = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render], ["__file", "option-group.vue"]]);
exports["default"] = OptionGroup;
//# sourceMappingURL=option-group.js.map