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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var index$1 = require('../../scrollbar/index.js');
require('../../../hooks/index.js');
var iconsVue = require('@element-plus/icons-vue');
var index = require('../../icon/index.js');
var node = require('./node2.js');
var types = require('./types.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index$2 = require('../../../hooks/use-namespace/index.js');
var index$3 = require('../../../hooks/use-locale/index.js');
var index$4 = require('../../../hooks/use-id/index.js');
const _sfc_main = vue.defineComponent({
name: "ElCascaderMenu",
components: {
Loading: iconsVue.Loading,
ElIcon: index.ElIcon,
ElScrollbar: index$1.ElScrollbar,
ElCascaderNode: node["default"]
},
props: {
nodes: {
type: Array,
required: true
},
index: {
type: Number,
required: true
}
},
setup(props) {
const instance = vue.getCurrentInstance();
const ns = index$2.useNamespace("cascader-menu");
const { t } = index$3.useLocale();
const id = index$4.useId();
let activeNode = null;
let hoverTimer = null;
const panel = vue.inject(types.CASCADER_PANEL_INJECTION_KEY);
const hoverZone = vue.ref(null);
const isEmpty = vue.computed(() => !props.nodes.length);
const isLoading = vue.computed(() => !panel.initialLoaded);
const menuId = vue.computed(() => `${id.value}-${props.index}`);
const handleExpand = (e) => {
activeNode = e.target;
};
const handleMouseMove = (e) => {
if (!panel.isHoverMenu || !activeNode || !hoverZone.value)
return;
if (activeNode.contains(e.target)) {
clearHoverTimer();
const el = instance.vnode.el;
const { left } = el.getBoundingClientRect();
const { offsetWidth, offsetHeight } = el;
const startX = e.clientX - left;
const top = activeNode.offsetTop;
const bottom = top + activeNode.offsetHeight;
hoverZone.value.innerHTML = `
<path style="pointer-events: auto;" fill="transparent" d="M${startX} ${top} L${offsetWidth} 0 V${top} Z" />
<path style="pointer-events: auto;" fill="transparent" d="M${startX} ${bottom} L${offsetWidth} ${offsetHeight} V${bottom} Z" />
`;
} else if (!hoverTimer) {
hoverTimer = window.setTimeout(clearHoverZone, panel.config.hoverThreshold);
}
};
const clearHoverTimer = () => {
if (!hoverTimer)
return;
clearTimeout(hoverTimer);
hoverTimer = null;
};
const clearHoverZone = () => {
if (!hoverZone.value)
return;
hoverZone.value.innerHTML = "";
clearHoverTimer();
};
return {
ns,
panel,
hoverZone,
isEmpty,
isLoading,
menuId,
t,
handleExpand,
handleMouseMove,
clearHoverZone
};
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_el_cascader_node = vue.resolveComponent("el-cascader-node");
const _component_loading = vue.resolveComponent("loading");
const _component_el_icon = vue.resolveComponent("el-icon");
const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
return vue.openBlock(), vue.createBlock(_component_el_scrollbar, {
key: _ctx.menuId,
tag: "ul",
role: "menu",
class: vue.normalizeClass(_ctx.ns.b()),
"wrap-class": _ctx.ns.e("wrap"),
"view-class": [_ctx.ns.e("list"), _ctx.ns.is("empty", _ctx.isEmpty)],
onMousemove: _ctx.handleMouseMove,
onMouseleave: _ctx.clearHoverZone
}, {
default: vue.withCtx(() => {
var _a;
return [
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.nodes, (node) => {
return vue.openBlock(), vue.createBlock(_component_el_cascader_node, {
key: node.uid,
node,
"menu-id": _ctx.menuId,
onExpand: _ctx.handleExpand
}, null, 8, ["node", "menu-id", "onExpand"]);
}), 128)),
_ctx.isLoading ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: vue.normalizeClass(_ctx.ns.e("empty-text"))
}, [
vue.createVNode(_component_el_icon, {
size: "14",
class: vue.normalizeClass(_ctx.ns.is("loading"))
}, {
default: vue.withCtx(() => [
vue.createVNode(_component_loading)
]),
_: 1
}, 8, ["class"]),
vue.createTextVNode(" " + vue.toDisplayString(_ctx.t("el.cascader.loading")), 1)
], 2)) : _ctx.isEmpty ? (vue.openBlock(), vue.createElementBlock("div", {
key: 1,
class: vue.normalizeClass(_ctx.ns.e("empty-text"))
}, vue.toDisplayString(_ctx.t("el.cascader.noData")), 3)) : ((_a = _ctx.panel) == null ? void 0 : _a.isHoverMenu) ? (vue.openBlock(), vue.createElementBlock("svg", {
key: 2,
ref: "hoverZone",
class: vue.normalizeClass(_ctx.ns.e("hover-zone"))
}, null, 2)) : vue.createCommentVNode("v-if", true)
];
}),
_: 1
}, 8, ["class", "wrap-class", "view-class", "onMousemove", "onMouseleave"]);
}
var ElCascaderMenu = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render], ["__file", "menu.vue"]]);
exports["default"] = ElCascaderMenu;
//# sourceMappingURL=menu.js.map