vxe-pc-ui 4.11.33 → 4.11.35
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/es/button/src/button-group.js +11 -5
- package/es/button/src/button.js +12 -4
- package/es/context-menu/index.js +2 -2
- package/es/context-menu/src/context-menu.js +287 -14
- package/es/context-menu/style.css +2 -8
- package/es/context-menu/style.min.css +1 -1
- package/es/dynamics/index.js +1 -1
- package/es/icon/style.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/ui/index.js +4 -2
- package/es/ui/src/log.js +1 -1
- package/es/vxe-context-menu/style.css +2 -8
- package/es/vxe-context-menu/style.min.css +1 -1
- package/lib/button/src/button-group.js +12 -7
- package/lib/button/src/button-group.min.js +1 -1
- package/lib/button/src/button.js +11 -4
- package/lib/button/src/button.min.js +1 -1
- package/lib/context-menu/index.js +2 -2
- package/lib/context-menu/index.min.js +1 -1
- package/lib/context-menu/src/context-menu.js +299 -13
- package/lib/context-menu/src/context-menu.min.js +1 -1
- package/lib/context-menu/style/style.css +2 -8
- package/lib/context-menu/style/style.min.css +1 -1
- package/lib/dynamics/index.js +2 -0
- package/lib/dynamics/index.min.js +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.umd.js +331 -29
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/ui/index.js +4 -2
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/vxe-context-menu/style/style.css +2 -8
- package/lib/vxe-context-menu/style/style.min.css +1 -1
- package/package.json +1 -1
- package/packages/button/src/button-group.ts +14 -6
- package/packages/button/src/button.ts +13 -4
- package/packages/context-menu/index.ts +2 -2
- package/packages/context-menu/src/context-menu.ts +290 -15
- package/packages/dynamics/index.ts +1 -1
- package/packages/ui/index.ts +3 -1
- package/styles/components/context-menu.scss +2 -12
- package/types/components/button-group.d.ts +9 -1
- package/types/components/button.d.ts +9 -1
- package/types/components/context-menu.d.ts +3 -1
- package/types/components/table-module/filter.d.ts +4 -0
- /package/es/icon/{iconfont.1767617712062.ttf → iconfont.1767779770584.ttf} +0 -0
- /package/es/icon/{iconfont.1767617712062.woff → iconfont.1767779770584.woff} +0 -0
- /package/es/icon/{iconfont.1767617712062.woff2 → iconfont.1767779770584.woff2} +0 -0
- /package/es/{iconfont.1767617712062.ttf → iconfont.1767779770584.ttf} +0 -0
- /package/es/{iconfont.1767617712062.woff → iconfont.1767779770584.woff} +0 -0
- /package/es/{iconfont.1767617712062.woff2 → iconfont.1767779770584.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1767617712062.ttf → iconfont.1767779770584.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1767617712062.woff → iconfont.1767779770584.woff} +0 -0
- /package/lib/icon/style/{iconfont.1767617712062.woff2 → iconfont.1767779770584.woff2} +0 -0
- /package/lib/{iconfont.1767617712062.ttf → iconfont.1767779770584.ttf} +0 -0
- /package/lib/{iconfont.1767617712062.woff → iconfont.1767779770584.woff} +0 -0
- /package/lib/{iconfont.1767617712062.woff2 → iconfont.1767779770584.woff2} +0 -0
|
@@ -22,7 +22,8 @@ export default defineVxeComponent({
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
emits: [
|
|
25
|
-
'click'
|
|
25
|
+
'click',
|
|
26
|
+
'contextmenu'
|
|
26
27
|
],
|
|
27
28
|
setup(props, context) {
|
|
28
29
|
const { slots, emit } = context;
|
|
@@ -38,10 +39,11 @@ export default defineVxeComponent({
|
|
|
38
39
|
};
|
|
39
40
|
useSize(props);
|
|
40
41
|
const { computePermissionInfo } = usePermission(props);
|
|
42
|
+
const dispatchEvent = (type, params, evnt) => {
|
|
43
|
+
emit(type, createEvent(evnt, { $buttonGroup: $xeButtonGroup }, params));
|
|
44
|
+
};
|
|
41
45
|
const buttonGroupMethods = {
|
|
42
|
-
dispatchEvent
|
|
43
|
-
emit(type, createEvent(evnt, { $buttonGroup: $xeButtonGroup }, params));
|
|
44
|
-
}
|
|
46
|
+
dispatchEvent
|
|
45
47
|
};
|
|
46
48
|
const buttonGroupPrivateMethods = {
|
|
47
49
|
handleClick(params, evnt) {
|
|
@@ -51,6 +53,9 @@ export default defineVxeComponent({
|
|
|
51
53
|
buttonGroupMethods.dispatchEvent('click', Object.assign(Object.assign({}, params), { option }), evnt);
|
|
52
54
|
}
|
|
53
55
|
};
|
|
56
|
+
const contextmenuEvent = (evnt) => {
|
|
57
|
+
dispatchEvent('contextmenu', {}, evnt);
|
|
58
|
+
};
|
|
54
59
|
Object.assign($xeButtonGroup, buttonGroupMethods, buttonGroupPrivateMethods);
|
|
55
60
|
const renderVN = () => {
|
|
56
61
|
const { className, options, vertical } = props;
|
|
@@ -62,7 +67,8 @@ export default defineVxeComponent({
|
|
|
62
67
|
return h('div', {
|
|
63
68
|
class: ['vxe-button-group', className ? (XEUtils.isFunction(className) ? className({ $buttonGroup: $xeButtonGroup }) : className) : '', {
|
|
64
69
|
'is--vertical': vertical
|
|
65
|
-
}]
|
|
70
|
+
}],
|
|
71
|
+
onContextmenu: contextmenuEvent
|
|
66
72
|
}, defaultSlot
|
|
67
73
|
? defaultSlot({})
|
|
68
74
|
: (options
|
package/es/button/src/button.js
CHANGED
|
@@ -113,7 +113,8 @@ const VxeButtonComponent = defineVxeComponent({
|
|
|
113
113
|
'mouseenter',
|
|
114
114
|
'mouseleave',
|
|
115
115
|
'dropdown-click',
|
|
116
|
-
'dropdownClick'
|
|
116
|
+
'dropdownClick',
|
|
117
|
+
'contextmenu'
|
|
117
118
|
],
|
|
118
119
|
setup(props, context) {
|
|
119
120
|
const { slots, emit } = context;
|
|
@@ -342,6 +343,9 @@ const VxeButtonComponent = defineVxeComponent({
|
|
|
342
343
|
const mouseleaveEvent = (evnt) => {
|
|
343
344
|
dispatchEvent('mouseleave', {}, evnt);
|
|
344
345
|
};
|
|
346
|
+
const contextmenuEvent = (evnt) => {
|
|
347
|
+
dispatchEvent('contextmenu', {}, evnt);
|
|
348
|
+
};
|
|
345
349
|
const clickTargetEvent = (evnt) => {
|
|
346
350
|
const { loading, trigger } = props;
|
|
347
351
|
const btnDisabled = computeBtnDisabled.value;
|
|
@@ -552,7 +556,9 @@ const VxeButtonComponent = defineVxeComponent({
|
|
|
552
556
|
return renderEmptyElement($xeButton);
|
|
553
557
|
}
|
|
554
558
|
if (dropdownsSlot || downBtnList.length) {
|
|
555
|
-
const btnOns = {
|
|
559
|
+
const btnOns = {
|
|
560
|
+
onContextmenu: contextmenuEvent
|
|
561
|
+
};
|
|
556
562
|
const panelOns = {};
|
|
557
563
|
if (trigger === 'hover') {
|
|
558
564
|
// hover 触发
|
|
@@ -670,7 +676,8 @@ const VxeButtonComponent = defineVxeComponent({
|
|
|
670
676
|
to: routerLink,
|
|
671
677
|
onClick: clickEvent,
|
|
672
678
|
onMouseenter: mouseenterEvent,
|
|
673
|
-
onMouseleave: mouseleaveEvent
|
|
679
|
+
onMouseleave: mouseleaveEvent,
|
|
680
|
+
onContextmenu: contextmenuEvent
|
|
674
681
|
}, {
|
|
675
682
|
default() {
|
|
676
683
|
return renderContent();
|
|
@@ -693,7 +700,8 @@ const VxeButtonComponent = defineVxeComponent({
|
|
|
693
700
|
disabled: btnDisabled || loading,
|
|
694
701
|
onClick: clickEvent,
|
|
695
702
|
onMouseenter: mouseenterEvent,
|
|
696
|
-
onMouseleave: mouseleaveEvent
|
|
703
|
+
onMouseleave: mouseleaveEvent,
|
|
704
|
+
onContextmenu: contextmenuEvent
|
|
697
705
|
}, renderContent());
|
|
698
706
|
};
|
|
699
707
|
$xeButton.renderVN = renderVN;
|
package/es/context-menu/index.js
CHANGED
|
@@ -31,8 +31,8 @@ export const ContextMenuController = {
|
|
|
31
31
|
evnt.preventDefault();
|
|
32
32
|
evnt.stopPropagation();
|
|
33
33
|
const opts = Object.assign({}, options);
|
|
34
|
-
const x = evnt.clientX;
|
|
35
|
-
const y = evnt.clientY;
|
|
34
|
+
const x = evnt.clientX + 1;
|
|
35
|
+
const y = evnt.clientY + 1;
|
|
36
36
|
openMenu(opts, x, y);
|
|
37
37
|
},
|
|
38
38
|
close() {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ref, h, reactive, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue';
|
|
2
2
|
import { defineVxeComponent } from '../../ui/src/comp';
|
|
3
3
|
import XEUtils from 'xe-utils';
|
|
4
|
-
import { getConfig, getIcon, getI18n, createEvent, useSize, globalEvents, renderEmptyElement } from '../../ui';
|
|
4
|
+
import { getConfig, getIcon, getI18n, createEvent, useSize, globalEvents, renderEmptyElement, GLOBAL_EVENT_KEYS } from '../../ui';
|
|
5
5
|
import { getLastZIndex, nextSubZIndex, nextZIndex, getFuncText } from '../../ui/src/utils';
|
|
6
|
-
import { getEventTargetNode, toCssUnit } from '../../ui/src/dom';
|
|
6
|
+
import { getDomNode, getEventTargetNode, toCssUnit } from '../../ui/src/dom';
|
|
7
7
|
import { getSlotVNs } from '../../ui/src/vn';
|
|
8
8
|
function createInternalData() {
|
|
9
9
|
return {};
|
|
@@ -18,7 +18,7 @@ function createReactData() {
|
|
|
18
18
|
left: '',
|
|
19
19
|
zIndex: 0
|
|
20
20
|
},
|
|
21
|
-
|
|
21
|
+
childOffsetX: 0
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
export default defineVxeComponent({
|
|
@@ -33,6 +33,10 @@ export default defineVxeComponent({
|
|
|
33
33
|
options: Array,
|
|
34
34
|
x: [Number, String],
|
|
35
35
|
y: [Number, String],
|
|
36
|
+
autoLocate: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: () => getConfig().contextMenu.autoLocate
|
|
39
|
+
},
|
|
36
40
|
zIndex: [Number, String],
|
|
37
41
|
position: {
|
|
38
42
|
type: String,
|
|
@@ -68,6 +72,20 @@ export default defineVxeComponent({
|
|
|
68
72
|
const { options } = props;
|
|
69
73
|
return options || [];
|
|
70
74
|
});
|
|
75
|
+
const computeAllFirstMenuList = computed(() => {
|
|
76
|
+
const menuGroups = computeMenuGroups.value;
|
|
77
|
+
const firstList = [];
|
|
78
|
+
for (let i = 0; i < menuGroups.length; i++) {
|
|
79
|
+
const list = menuGroups[i];
|
|
80
|
+
for (let j = 0; j < list.length; j++) {
|
|
81
|
+
const firstItem = list[j];
|
|
82
|
+
if (hasValidItem(firstItem)) {
|
|
83
|
+
firstList.push(firstItem);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return firstList;
|
|
88
|
+
});
|
|
71
89
|
const computeTopAndLeft = computed(() => {
|
|
72
90
|
const { x, y } = props;
|
|
73
91
|
return `${x}${y}`;
|
|
@@ -92,7 +110,7 @@ export default defineVxeComponent({
|
|
|
92
110
|
const { visible } = reactData;
|
|
93
111
|
const value = true;
|
|
94
112
|
reactData.visible = value;
|
|
95
|
-
|
|
113
|
+
handleLocate();
|
|
96
114
|
updateZindex();
|
|
97
115
|
if (modelValue !== value) {
|
|
98
116
|
emitModel(value);
|
|
@@ -101,7 +119,9 @@ export default defineVxeComponent({
|
|
|
101
119
|
if (visible !== value) {
|
|
102
120
|
dispatchEvent('show', { visible: value }, null);
|
|
103
121
|
}
|
|
104
|
-
return nextTick()
|
|
122
|
+
return nextTick().then(() => {
|
|
123
|
+
updateLocate();
|
|
124
|
+
});
|
|
105
125
|
};
|
|
106
126
|
const close = () => {
|
|
107
127
|
const { modelValue } = props;
|
|
@@ -117,11 +137,12 @@ export default defineVxeComponent({
|
|
|
117
137
|
}
|
|
118
138
|
return nextTick();
|
|
119
139
|
};
|
|
120
|
-
const
|
|
140
|
+
const handleLocate = () => {
|
|
121
141
|
const { x, y } = props;
|
|
122
142
|
const { popupStyle } = reactData;
|
|
123
143
|
popupStyle.left = toCssUnit(x || 0);
|
|
124
144
|
popupStyle.top = toCssUnit(y || 0);
|
|
145
|
+
updateLocate();
|
|
125
146
|
};
|
|
126
147
|
const updateZindex = () => {
|
|
127
148
|
const { zIndex, transfer } = props;
|
|
@@ -136,6 +157,59 @@ export default defineVxeComponent({
|
|
|
136
157
|
}
|
|
137
158
|
}
|
|
138
159
|
};
|
|
160
|
+
const updateLocate = () => {
|
|
161
|
+
const { autoLocate, position } = props;
|
|
162
|
+
const { popupStyle } = reactData;
|
|
163
|
+
if (autoLocate) {
|
|
164
|
+
const wrapperEl = refElem.value;
|
|
165
|
+
if (wrapperEl) {
|
|
166
|
+
const { visibleWidth, visibleHeight } = getDomNode();
|
|
167
|
+
const wrapperStyle = getComputedStyle(wrapperEl);
|
|
168
|
+
const offsetTop = XEUtils.toNumber(wrapperStyle.top);
|
|
169
|
+
const offsetLeft = XEUtils.toNumber(wrapperStyle.left);
|
|
170
|
+
const wrapperWidth = wrapperEl.offsetWidth;
|
|
171
|
+
const wrapperHeight = wrapperEl.offsetHeight;
|
|
172
|
+
if (position === 'absolute') {
|
|
173
|
+
//
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
if (offsetTop + wrapperHeight > visibleHeight) {
|
|
177
|
+
popupStyle.top = `${Math.max(0, offsetTop - wrapperHeight)}px`;
|
|
178
|
+
}
|
|
179
|
+
if (offsetLeft + wrapperWidth > visibleWidth) {
|
|
180
|
+
popupStyle.left = `${Math.max(0, offsetLeft - wrapperWidth)}px`;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
updateChildLocate();
|
|
186
|
+
};
|
|
187
|
+
const updateChildLocate = () => {
|
|
188
|
+
const wrapperEl = refElem.value;
|
|
189
|
+
if (wrapperEl) {
|
|
190
|
+
const { visibleWidth } = getDomNode();
|
|
191
|
+
const owSize = 2;
|
|
192
|
+
const handleStyle = () => {
|
|
193
|
+
const wrapperStyle = getComputedStyle(wrapperEl);
|
|
194
|
+
const offsetLeft = XEUtils.toNumber(wrapperStyle.left);
|
|
195
|
+
const wrapperWidth = wrapperEl.offsetWidth;
|
|
196
|
+
const childEl = wrapperEl.querySelector('.vxe-context-menu--children-wrapper');
|
|
197
|
+
const childWidth = childEl ? childEl.offsetWidth : wrapperWidth;
|
|
198
|
+
if ((offsetLeft + wrapperWidth) > (visibleWidth - childWidth)) {
|
|
199
|
+
// 往左
|
|
200
|
+
reactData.childOffsetX = -childWidth + owSize;
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
// 往右
|
|
204
|
+
reactData.childOffsetX = wrapperWidth - owSize;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
handleStyle();
|
|
208
|
+
nextTick(() => {
|
|
209
|
+
handleStyle();
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
};
|
|
139
213
|
const handleVisible = () => {
|
|
140
214
|
const { modelValue } = props;
|
|
141
215
|
if (modelValue) {
|
|
@@ -162,12 +236,190 @@ export default defineVxeComponent({
|
|
|
162
236
|
};
|
|
163
237
|
const handleItemMouseenterEvent = (evnt, item, parentitem) => {
|
|
164
238
|
reactData.activeOption = parentitem || item;
|
|
165
|
-
|
|
239
|
+
if (parentitem) {
|
|
240
|
+
reactData.activeOption = parentitem;
|
|
241
|
+
reactData.activeChildOption = item;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
reactData.activeOption = item;
|
|
245
|
+
if (hasChildMenu(item)) {
|
|
246
|
+
reactData.activeChildOption = findFirstChildItem(item);
|
|
247
|
+
nextTick(() => {
|
|
248
|
+
updateChildLocate();
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
reactData.activeChildOption = null;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
166
255
|
};
|
|
167
256
|
const handleItemMouseleaveEvent = () => {
|
|
168
257
|
reactData.activeOption = null;
|
|
169
258
|
reactData.activeChildOption = null;
|
|
170
259
|
};
|
|
260
|
+
const hasValidItem = (item) => {
|
|
261
|
+
return !item.loading && !item.disabled && item.visible !== false;
|
|
262
|
+
};
|
|
263
|
+
const findNextFirstItem = (allFirstList, firstItem) => {
|
|
264
|
+
for (let i = 0; i < allFirstList.length; i++) {
|
|
265
|
+
const item = allFirstList[i];
|
|
266
|
+
if (firstItem === item) {
|
|
267
|
+
const nextItem = allFirstList[i + 1];
|
|
268
|
+
if (nextItem) {
|
|
269
|
+
return nextItem;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return XEUtils.first(allFirstList);
|
|
274
|
+
};
|
|
275
|
+
const findPrevFirstItem = (allFirstList, firstItem) => {
|
|
276
|
+
for (let i = 0; i < allFirstList.length; i++) {
|
|
277
|
+
const item = allFirstList[i];
|
|
278
|
+
if (firstItem === item) {
|
|
279
|
+
if (i > 0) {
|
|
280
|
+
return allFirstList[i - 1];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return XEUtils.last(allFirstList);
|
|
285
|
+
};
|
|
286
|
+
const findFirstChildItem = (firstItem) => {
|
|
287
|
+
const { children } = firstItem;
|
|
288
|
+
if (children) {
|
|
289
|
+
for (let i = 0; i < children.length; i++) {
|
|
290
|
+
const item = children[i];
|
|
291
|
+
if (hasValidItem(item)) {
|
|
292
|
+
return item;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return null;
|
|
297
|
+
};
|
|
298
|
+
const findPrevChildItem = (firstItem, childItem) => {
|
|
299
|
+
const { children } = firstItem;
|
|
300
|
+
let prevValidItem = null;
|
|
301
|
+
if (children) {
|
|
302
|
+
for (let i = 0; i < children.length; i++) {
|
|
303
|
+
const item = children[i];
|
|
304
|
+
if (childItem === item) {
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
if (hasValidItem(item)) {
|
|
308
|
+
prevValidItem = item;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (!prevValidItem) {
|
|
312
|
+
for (let len = children.length - 1; len >= 0; len--) {
|
|
313
|
+
const item = children[len];
|
|
314
|
+
if (hasValidItem(item)) {
|
|
315
|
+
return item;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return prevValidItem;
|
|
321
|
+
};
|
|
322
|
+
const findNextChildItem = (firstItem, childItem) => {
|
|
323
|
+
const { children } = firstItem;
|
|
324
|
+
let firstValidItem = null;
|
|
325
|
+
if (children) {
|
|
326
|
+
let isMetch = false;
|
|
327
|
+
for (let i = 0; i < children.length; i++) {
|
|
328
|
+
const item = children[i];
|
|
329
|
+
if (!firstValidItem) {
|
|
330
|
+
if (hasValidItem(item)) {
|
|
331
|
+
firstValidItem = item;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if (isMetch) {
|
|
335
|
+
if (hasValidItem(item)) {
|
|
336
|
+
return item;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
isMetch = childItem === item;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return firstValidItem;
|
|
345
|
+
};
|
|
346
|
+
const handleGlobalMousewheelEvent = (evnt) => {
|
|
347
|
+
const { visible } = reactData;
|
|
348
|
+
if (visible) {
|
|
349
|
+
const el = refElem.value;
|
|
350
|
+
if (!getEventTargetNode(evnt, el, '').flag) {
|
|
351
|
+
close();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
const handleGlobalKeydownEvent = (evnt) => {
|
|
356
|
+
const { visible, activeOption, activeChildOption } = reactData;
|
|
357
|
+
const allFirstMenuList = computeAllFirstMenuList.value;
|
|
358
|
+
if (visible) {
|
|
359
|
+
const isUpArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_UP);
|
|
360
|
+
const isDwArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_DOWN);
|
|
361
|
+
const isLeftArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_LEFT);
|
|
362
|
+
const isRightArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_RIGHT);
|
|
363
|
+
const isEnter = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ENTER);
|
|
364
|
+
const isEsc = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ESCAPE);
|
|
365
|
+
if (isEsc) {
|
|
366
|
+
close();
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
// 回车选中
|
|
370
|
+
if (isEnter) {
|
|
371
|
+
if (activeOption || activeChildOption) {
|
|
372
|
+
evnt.preventDefault();
|
|
373
|
+
evnt.stopPropagation();
|
|
374
|
+
if (!activeChildOption && hasChildMenu(activeOption)) {
|
|
375
|
+
reactData.activeChildOption = findFirstChildItem(activeOption);
|
|
376
|
+
updateChildLocate();
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
handleItemClickEvent(evnt, activeChildOption || activeOption);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
// 方向键操作
|
|
384
|
+
if (activeChildOption) {
|
|
385
|
+
if (isUpArrow) {
|
|
386
|
+
evnt.preventDefault();
|
|
387
|
+
reactData.activeChildOption = findPrevChildItem(activeOption, activeChildOption);
|
|
388
|
+
updateChildLocate();
|
|
389
|
+
}
|
|
390
|
+
else if (isDwArrow) {
|
|
391
|
+
evnt.preventDefault();
|
|
392
|
+
reactData.activeChildOption = findNextChildItem(activeOption, activeChildOption);
|
|
393
|
+
updateChildLocate();
|
|
394
|
+
}
|
|
395
|
+
else if (isLeftArrow) {
|
|
396
|
+
evnt.preventDefault();
|
|
397
|
+
reactData.activeChildOption = null;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
else if (activeOption) {
|
|
401
|
+
evnt.preventDefault();
|
|
402
|
+
if (isUpArrow) {
|
|
403
|
+
reactData.activeOption = findPrevFirstItem(allFirstMenuList, activeOption);
|
|
404
|
+
}
|
|
405
|
+
else if (isDwArrow) {
|
|
406
|
+
reactData.activeOption = findNextFirstItem(allFirstMenuList, activeOption);
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
if (hasChildMenu(activeOption)) {
|
|
410
|
+
if (isRightArrow) {
|
|
411
|
+
reactData.activeChildOption = findFirstChildItem(activeOption);
|
|
412
|
+
updateChildLocate();
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
evnt.preventDefault();
|
|
419
|
+
reactData.activeOption = XEUtils.first(allFirstMenuList);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
};
|
|
171
423
|
const handleGlobalMousedownEvent = (evnt) => {
|
|
172
424
|
const { visible } = reactData;
|
|
173
425
|
if (visible) {
|
|
@@ -177,6 +429,12 @@ export default defineVxeComponent({
|
|
|
177
429
|
}
|
|
178
430
|
}
|
|
179
431
|
};
|
|
432
|
+
const handleGlobalBlurEvent = () => {
|
|
433
|
+
const { visible } = reactData;
|
|
434
|
+
if (visible) {
|
|
435
|
+
close();
|
|
436
|
+
}
|
|
437
|
+
};
|
|
180
438
|
const tagPrivateMethods = {};
|
|
181
439
|
Object.assign($xeContextMenu, tagMethods, tagPrivateMethods);
|
|
182
440
|
const renderMenuItem = (item, parentItem, hasChildMenus) => {
|
|
@@ -269,7 +527,7 @@ export default defineVxeComponent({
|
|
|
269
527
|
]);
|
|
270
528
|
};
|
|
271
529
|
const renderMenus = () => {
|
|
272
|
-
const { activeOption, activeChildOption } = reactData;
|
|
530
|
+
const { activeOption, activeChildOption, childOffsetX } = reactData;
|
|
273
531
|
const menuGroups = computeMenuGroups.value;
|
|
274
532
|
const mgVNs = [];
|
|
275
533
|
menuGroups.forEach((menuList, gIndex) => {
|
|
@@ -277,15 +535,21 @@ export default defineVxeComponent({
|
|
|
277
535
|
menuList.forEach((firstItem, i) => {
|
|
278
536
|
const { children } = firstItem;
|
|
279
537
|
const hasChildMenus = children && children.some((child) => child.visible !== false);
|
|
538
|
+
const isActiveFirst = activeOption === firstItem;
|
|
539
|
+
const showChild = isActiveFirst && !!activeChildOption;
|
|
280
540
|
moVNs.push(h('div', {
|
|
281
541
|
key: `${gIndex}_${i}`,
|
|
282
542
|
class: ['vxe-context-menu--item-wrapper vxe-context-menu--first-item', firstItem.className || '', {
|
|
283
|
-
'is--active':
|
|
543
|
+
'is--active': isActiveFirst,
|
|
544
|
+
'is--subactive': isActiveFirst && !!activeChildOption
|
|
284
545
|
}]
|
|
285
546
|
}, [
|
|
286
|
-
hasChildMenus
|
|
547
|
+
hasChildMenus && showChild
|
|
287
548
|
? h('div', {
|
|
288
|
-
class: 'vxe-context-menu--children-wrapper'
|
|
549
|
+
class: 'vxe-context-menu--children-wrapper',
|
|
550
|
+
style: {
|
|
551
|
+
transform: `translate(${childOffsetX}px, -5px)`
|
|
552
|
+
}
|
|
289
553
|
}, children.map(twoItem => {
|
|
290
554
|
return h('div', {
|
|
291
555
|
class: ['vxe-context-menu--item-wrapper vxe-context-menu--child-item', twoItem.className || '', {
|
|
@@ -308,11 +572,11 @@ export default defineVxeComponent({
|
|
|
308
572
|
};
|
|
309
573
|
const renderVN = () => {
|
|
310
574
|
const { className, position, destroyOnClose } = props;
|
|
311
|
-
const { visible, popupStyle
|
|
575
|
+
const { visible, popupStyle } = reactData;
|
|
312
576
|
const vSize = computeSize.value;
|
|
313
577
|
return h('div', {
|
|
314
578
|
ref: refElem,
|
|
315
|
-
class: ['vxe-context-menu vxe-context-menu--wrapper', position === 'absolute' ? ('is--' + position) : 'is--fixed',
|
|
579
|
+
class: ['vxe-context-menu vxe-context-menu--wrapper', position === 'absolute' ? ('is--' + position) : 'is--fixed', className || '', {
|
|
316
580
|
[`size--${vSize}`]: vSize,
|
|
317
581
|
'is--visible': visible
|
|
318
582
|
}],
|
|
@@ -320,17 +584,26 @@ export default defineVxeComponent({
|
|
|
320
584
|
}, (destroyOnClose ? visible : true) ? renderMenus() : []);
|
|
321
585
|
};
|
|
322
586
|
watch(computeTopAndLeft, () => {
|
|
323
|
-
|
|
587
|
+
handleLocate();
|
|
588
|
+
nextTick(() => {
|
|
589
|
+
updateLocate();
|
|
590
|
+
});
|
|
324
591
|
});
|
|
325
592
|
watch(() => props.modelValue, () => {
|
|
326
593
|
handleVisible();
|
|
327
594
|
});
|
|
328
595
|
handleVisible();
|
|
329
596
|
onMounted(() => {
|
|
597
|
+
globalEvents.on($xeContextMenu, 'mousewheel', handleGlobalMousewheelEvent);
|
|
598
|
+
globalEvents.on($xeContextMenu, 'keydown', handleGlobalKeydownEvent);
|
|
330
599
|
globalEvents.on($xeContextMenu, 'mousedown', handleGlobalMousedownEvent);
|
|
600
|
+
globalEvents.on($xeContextMenu, 'blur', handleGlobalBlurEvent);
|
|
331
601
|
});
|
|
332
602
|
onBeforeUnmount(() => {
|
|
603
|
+
globalEvents.off($xeContextMenu, 'mousewheel');
|
|
604
|
+
globalEvents.off($xeContextMenu, 'keydown');
|
|
333
605
|
globalEvents.off($xeContextMenu, 'mousedown');
|
|
606
|
+
globalEvents.off($xeContextMenu, 'blur');
|
|
334
607
|
XEUtils.assign(reactData, createReactData());
|
|
335
608
|
XEUtils.assign(internalData, createInternalData());
|
|
336
609
|
});
|
|
@@ -15,12 +15,6 @@
|
|
|
15
15
|
.vxe-context-menu.is--absolute {
|
|
16
16
|
position: absolute;
|
|
17
17
|
}
|
|
18
|
-
.vxe-context-menu.cp--left .vxe-context-menu--children-wrapper {
|
|
19
|
-
left: calc(-100% + 2px);
|
|
20
|
-
}
|
|
21
|
-
.vxe-context-menu.cp--right .vxe-context-menu--children-wrapper {
|
|
22
|
-
left: calc(100% - 2px);
|
|
23
|
-
}
|
|
24
18
|
|
|
25
19
|
.vxe-context-menu--group-wrapper {
|
|
26
20
|
border-top: 1px solid var(--vxe-ui-base-popup-border-color);
|
|
@@ -43,7 +37,7 @@
|
|
|
43
37
|
.vxe-context-menu--children-wrapper {
|
|
44
38
|
display: none;
|
|
45
39
|
position: absolute;
|
|
46
|
-
transform:
|
|
40
|
+
transform: translate(0, -5px);
|
|
47
41
|
}
|
|
48
42
|
|
|
49
43
|
.vxe-context-menu--item-wrapper {
|
|
@@ -58,7 +52,7 @@
|
|
|
58
52
|
background-color: rgba(0, 0, 0, 0.1);
|
|
59
53
|
}
|
|
60
54
|
|
|
61
|
-
.vxe-context-menu--first-item.is--
|
|
55
|
+
.vxe-context-menu--first-item.is--subactive .vxe-context-menu--children-wrapper {
|
|
62
56
|
display: block;
|
|
63
57
|
}
|
|
64
58
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.vxe-context-menu{display:none;top:0;left:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.vxe-context-menu.is--visible{display:block}.vxe-context-menu.is--fixed{position:fixed}.vxe-context-menu.is--absolute{position:absolute}.vxe-context-menu
|
|
1
|
+
.vxe-context-menu{display:none;top:0;left:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.vxe-context-menu.is--visible{display:block}.vxe-context-menu.is--fixed{position:fixed}.vxe-context-menu.is--absolute{position:absolute}.vxe-context-menu--group-wrapper{border-top:1px solid var(--vxe-ui-base-popup-border-color)}.vxe-context-menu--group-wrapper:first-child{border:0}.vxe-context-menu--children-wrapper,.vxe-context-menu--wrapper{padding:0;color:var(--vxe-ui-font-color);font-family:var(--vxe-ui-font-family);border:1px solid var(--vxe-ui-base-popup-border-color);background-color:var(--vxe-ui-layout-background-color);border-radius:var(--vxe-ui-base-border-radius);box-shadow:0 0 12px 0 rgba(0,0,0,.3)}.vxe-context-menu--children-wrapper{display:none;position:absolute;transform:translate(0,-5px)}.vxe-context-menu--item-wrapper{position:relative;min-width:12em;max-width:20em;-webkit-user-select:none;-moz-user-select:none;user-select:none}.vxe-context-menu--item-wrapper.is--active{background-color:rgba(0,0,0,.1)}.vxe-context-menu--first-item.is--subactive .vxe-context-menu--children-wrapper{display:block}.vxe-context-menu--item-inner{height:var(--vxe-ui-context-menu-option-height);display:flex;align-items:center;padding:0 .8em;cursor:pointer}.vxe-context-menu--item-inner.is--loading{opacity:.5;cursor:progress}.vxe-context-menu--item-inner.is--disabled{color:var(--vxe-ui-font-disabled-color);cursor:no-drop}.vxe-context-menu--item-prefix{min-width:1em;text-align:center}.vxe-context-menu--item-prefix,.vxe-context-menu--item-suffix{flex-shrink:0;font-size:.9em}.vxe-context-menu--item-label{font-size:.9em;padding:0 .5em;flex-grow:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vxe-context-menu{font-size:var(--vxe-ui-font-size-default)}.vxe-context-menu.size--medium{font-size:var(--vxe-ui-font-size-medium)}.vxe-context-menu.size--small{font-size:var(--vxe-ui-font-size-small)}.vxe-context-menu.size--mini{font-size:var(--vxe-ui-font-size-mini)}
|