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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ref, h, reactive, PropType, computed, VNode, 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
|
|
|
9
9
|
import type { ContextMenuInternalData, ContextMenuReactData, VxeContextMenuPropTypes, VxeContextMenuDefines, ContextMenuPrivateRef, VxeContextMenuEmits, VxeContextMenuPrivateComputed, ContextMenuMethods, ContextMenuPrivateMethods, VxeContextMenuConstructor, VxeContextMenuPrivateMethods, ValueOf } from '../../../types'
|
|
@@ -23,7 +23,7 @@ function createReactData (): ContextMenuReactData {
|
|
|
23
23
|
left: '',
|
|
24
24
|
zIndex: 0
|
|
25
25
|
},
|
|
26
|
-
|
|
26
|
+
childOffsetX: 0
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -39,6 +39,10 @@ export default defineVxeComponent({
|
|
|
39
39
|
options: Array as PropType<VxeContextMenuPropTypes.Options>,
|
|
40
40
|
x: [Number, String] as PropType<VxeContextMenuPropTypes.X>,
|
|
41
41
|
y: [Number, String] as PropType<VxeContextMenuPropTypes.Y>,
|
|
42
|
+
autoLocate: {
|
|
43
|
+
type: Boolean as PropType<VxeContextMenuPropTypes.AutoLocate>,
|
|
44
|
+
default: () => getConfig().contextMenu.autoLocate
|
|
45
|
+
},
|
|
42
46
|
zIndex: [Number, String] as PropType<VxeContextMenuPropTypes.ZIndex>,
|
|
43
47
|
position: {
|
|
44
48
|
type: String as PropType<VxeContextMenuPropTypes.Position>,
|
|
@@ -81,6 +85,21 @@ export default defineVxeComponent({
|
|
|
81
85
|
return options || []
|
|
82
86
|
})
|
|
83
87
|
|
|
88
|
+
const computeAllFirstMenuList = computed(() => {
|
|
89
|
+
const menuGroups: VxeContextMenuDefines.MenuFirstOption[] = computeMenuGroups.value
|
|
90
|
+
const firstList = []
|
|
91
|
+
for (let i = 0; i < menuGroups.length; i++) {
|
|
92
|
+
const list = menuGroups[i]
|
|
93
|
+
for (let j = 0; j < list.length; j++) {
|
|
94
|
+
const firstItem = list[j]
|
|
95
|
+
if (hasValidItem(firstItem)) {
|
|
96
|
+
firstList.push(firstItem)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return firstList
|
|
101
|
+
})
|
|
102
|
+
|
|
84
103
|
const computeTopAndLeft = computed(() => {
|
|
85
104
|
const { x, y } = props
|
|
86
105
|
return `${x}${y}`
|
|
@@ -112,7 +131,7 @@ export default defineVxeComponent({
|
|
|
112
131
|
const { visible } = reactData
|
|
113
132
|
const value = true
|
|
114
133
|
reactData.visible = value
|
|
115
|
-
|
|
134
|
+
handleLocate()
|
|
116
135
|
updateZindex()
|
|
117
136
|
if (modelValue !== value) {
|
|
118
137
|
emitModel(value)
|
|
@@ -121,7 +140,9 @@ export default defineVxeComponent({
|
|
|
121
140
|
if (visible !== value) {
|
|
122
141
|
dispatchEvent('show', { visible: value }, null)
|
|
123
142
|
}
|
|
124
|
-
return nextTick()
|
|
143
|
+
return nextTick().then(() => {
|
|
144
|
+
updateLocate()
|
|
145
|
+
})
|
|
125
146
|
}
|
|
126
147
|
|
|
127
148
|
const close = () => {
|
|
@@ -139,11 +160,12 @@ export default defineVxeComponent({
|
|
|
139
160
|
return nextTick()
|
|
140
161
|
}
|
|
141
162
|
|
|
142
|
-
const
|
|
163
|
+
const handleLocate = () => {
|
|
143
164
|
const { x, y } = props
|
|
144
165
|
const { popupStyle } = reactData
|
|
145
166
|
popupStyle.left = toCssUnit(x || 0)
|
|
146
167
|
popupStyle.top = toCssUnit(y || 0)
|
|
168
|
+
updateLocate()
|
|
147
169
|
}
|
|
148
170
|
|
|
149
171
|
const updateZindex = () => {
|
|
@@ -159,6 +181,60 @@ export default defineVxeComponent({
|
|
|
159
181
|
}
|
|
160
182
|
}
|
|
161
183
|
|
|
184
|
+
const updateLocate = () => {
|
|
185
|
+
const { autoLocate, position } = props
|
|
186
|
+
const { popupStyle } = reactData
|
|
187
|
+
if (autoLocate) {
|
|
188
|
+
const wrapperEl = refElem.value
|
|
189
|
+
if (wrapperEl) {
|
|
190
|
+
const { visibleWidth, visibleHeight } = getDomNode()
|
|
191
|
+
const wrapperStyle = getComputedStyle(wrapperEl)
|
|
192
|
+
const offsetTop = XEUtils.toNumber(wrapperStyle.top)
|
|
193
|
+
const offsetLeft = XEUtils.toNumber(wrapperStyle.left)
|
|
194
|
+
const wrapperWidth = wrapperEl.offsetWidth
|
|
195
|
+
const wrapperHeight = wrapperEl.offsetHeight
|
|
196
|
+
if (position === 'absolute') {
|
|
197
|
+
//
|
|
198
|
+
} else {
|
|
199
|
+
if (offsetTop + wrapperHeight > visibleHeight) {
|
|
200
|
+
popupStyle.top = `${Math.max(0, offsetTop - wrapperHeight)}px`
|
|
201
|
+
}
|
|
202
|
+
if (offsetLeft + wrapperWidth > visibleWidth) {
|
|
203
|
+
popupStyle.left = `${Math.max(0, offsetLeft - wrapperWidth)}px`
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
updateChildLocate()
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const updateChildLocate = () => {
|
|
212
|
+
const wrapperEl = refElem.value
|
|
213
|
+
if (wrapperEl) {
|
|
214
|
+
const { visibleWidth } = getDomNode()
|
|
215
|
+
const owSize = 2
|
|
216
|
+
|
|
217
|
+
const handleStyle = () => {
|
|
218
|
+
const wrapperStyle = getComputedStyle(wrapperEl)
|
|
219
|
+
const offsetLeft = XEUtils.toNumber(wrapperStyle.left)
|
|
220
|
+
const wrapperWidth = wrapperEl.offsetWidth
|
|
221
|
+
const childEl = wrapperEl.querySelector<HTMLDivElement>('.vxe-context-menu--children-wrapper')
|
|
222
|
+
const childWidth = childEl ? childEl.offsetWidth : wrapperWidth
|
|
223
|
+
if ((offsetLeft + wrapperWidth) > (visibleWidth - childWidth)) {
|
|
224
|
+
// 往左
|
|
225
|
+
reactData.childOffsetX = -childWidth + owSize
|
|
226
|
+
} else {
|
|
227
|
+
// 往右
|
|
228
|
+
reactData.childOffsetX = wrapperWidth - owSize
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
handleStyle()
|
|
232
|
+
nextTick(() => {
|
|
233
|
+
handleStyle()
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
162
238
|
const handleVisible = () => {
|
|
163
239
|
const { modelValue } = props
|
|
164
240
|
if (modelValue) {
|
|
@@ -179,7 +255,7 @@ export default defineVxeComponent({
|
|
|
179
255
|
return children && children.some((child) => child.visible !== false)
|
|
180
256
|
}
|
|
181
257
|
|
|
182
|
-
const handleItemClickEvent = (evnt: MouseEvent, item: VxeContextMenuDefines.MenuFirstOption | VxeContextMenuDefines.MenuChildOption) => {
|
|
258
|
+
const handleItemClickEvent = (evnt: MouseEvent | KeyboardEvent, item: VxeContextMenuDefines.MenuFirstOption | VxeContextMenuDefines.MenuChildOption) => {
|
|
183
259
|
if (!hasChildMenu(item)) {
|
|
184
260
|
dispatchEvent('option-click', { option: item }, evnt)
|
|
185
261
|
close()
|
|
@@ -188,7 +264,20 @@ export default defineVxeComponent({
|
|
|
188
264
|
|
|
189
265
|
const handleItemMouseenterEvent = (evnt: MouseEvent, item: VxeContextMenuDefines.MenuFirstOption | VxeContextMenuDefines.MenuChildOption, parentitem?: VxeContextMenuDefines.MenuFirstOption | null) => {
|
|
190
266
|
reactData.activeOption = parentitem || item
|
|
191
|
-
|
|
267
|
+
if (parentitem) {
|
|
268
|
+
reactData.activeOption = parentitem
|
|
269
|
+
reactData.activeChildOption = item
|
|
270
|
+
} else {
|
|
271
|
+
reactData.activeOption = item
|
|
272
|
+
if (hasChildMenu(item)) {
|
|
273
|
+
reactData.activeChildOption = findFirstChildItem(item)
|
|
274
|
+
nextTick(() => {
|
|
275
|
+
updateChildLocate()
|
|
276
|
+
})
|
|
277
|
+
} else {
|
|
278
|
+
reactData.activeChildOption = null
|
|
279
|
+
}
|
|
280
|
+
}
|
|
192
281
|
}
|
|
193
282
|
|
|
194
283
|
const handleItemMouseleaveEvent = () => {
|
|
@@ -196,6 +285,170 @@ export default defineVxeComponent({
|
|
|
196
285
|
reactData.activeChildOption = null
|
|
197
286
|
}
|
|
198
287
|
|
|
288
|
+
const hasValidItem = (item: VxeContextMenuDefines.MenuFirstOption | VxeContextMenuDefines.MenuChildOption) => {
|
|
289
|
+
return !item.loading && !item.disabled && item.visible !== false
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const findNextFirstItem = (allFirstList: VxeContextMenuDefines.MenuFirstOption[], firstItem: VxeContextMenuDefines.MenuFirstOption) => {
|
|
293
|
+
for (let i = 0; i < allFirstList.length; i++) {
|
|
294
|
+
const item = allFirstList[i]
|
|
295
|
+
if (firstItem === item) {
|
|
296
|
+
const nextItem = allFirstList[i + 1]
|
|
297
|
+
if (nextItem) {
|
|
298
|
+
return nextItem
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return XEUtils.first(allFirstList)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const findPrevFirstItem = (allFirstList: VxeContextMenuDefines.MenuFirstOption[], firstItem: VxeContextMenuDefines.MenuFirstOption) => {
|
|
306
|
+
for (let i = 0; i < allFirstList.length; i++) {
|
|
307
|
+
const item = allFirstList[i]
|
|
308
|
+
if (firstItem === item) {
|
|
309
|
+
if (i > 0) {
|
|
310
|
+
return allFirstList[i - 1]
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return XEUtils.last(allFirstList)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const findFirstChildItem = (firstItem: VxeContextMenuDefines.MenuFirstOption) => {
|
|
318
|
+
const { children } = firstItem
|
|
319
|
+
if (children) {
|
|
320
|
+
for (let i = 0; i < children.length; i++) {
|
|
321
|
+
const item = children[i]
|
|
322
|
+
if (hasValidItem(item)) {
|
|
323
|
+
return item
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return null
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const findPrevChildItem = (firstItem: VxeContextMenuDefines.MenuFirstOption, childItem: VxeContextMenuDefines.MenuChildOption) => {
|
|
331
|
+
const { children } = firstItem
|
|
332
|
+
let prevValidItem = null
|
|
333
|
+
if (children) {
|
|
334
|
+
for (let i = 0; i < children.length; i++) {
|
|
335
|
+
const item = children[i]
|
|
336
|
+
if (childItem === item) {
|
|
337
|
+
break
|
|
338
|
+
}
|
|
339
|
+
if (hasValidItem(item)) {
|
|
340
|
+
prevValidItem = item
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (!prevValidItem) {
|
|
344
|
+
for (let len = children.length - 1; len >= 0; len--) {
|
|
345
|
+
const item = children[len]
|
|
346
|
+
if (hasValidItem(item)) {
|
|
347
|
+
return item
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return prevValidItem
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const findNextChildItem = (firstItem: VxeContextMenuDefines.MenuFirstOption, childItem: VxeContextMenuDefines.MenuChildOption) => {
|
|
356
|
+
const { children } = firstItem
|
|
357
|
+
let firstValidItem = null
|
|
358
|
+
if (children) {
|
|
359
|
+
let isMetch = false
|
|
360
|
+
for (let i = 0; i < children.length; i++) {
|
|
361
|
+
const item = children[i]
|
|
362
|
+
if (!firstValidItem) {
|
|
363
|
+
if (hasValidItem(item)) {
|
|
364
|
+
firstValidItem = item
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (isMetch) {
|
|
368
|
+
if (hasValidItem(item)) {
|
|
369
|
+
return item
|
|
370
|
+
}
|
|
371
|
+
} else {
|
|
372
|
+
isMetch = childItem === item
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return firstValidItem
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const handleGlobalMousewheelEvent = (evnt: MouseEvent) => {
|
|
380
|
+
const { visible } = reactData
|
|
381
|
+
if (visible) {
|
|
382
|
+
const el = refElem.value
|
|
383
|
+
if (!getEventTargetNode(evnt, el, '').flag) {
|
|
384
|
+
close()
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const handleGlobalKeydownEvent = (evnt: KeyboardEvent) => {
|
|
390
|
+
const { visible, activeOption, activeChildOption } = reactData
|
|
391
|
+
const allFirstMenuList = computeAllFirstMenuList.value
|
|
392
|
+
if (visible) {
|
|
393
|
+
const isUpArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_UP)
|
|
394
|
+
const isDwArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_DOWN)
|
|
395
|
+
const isLeftArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_LEFT)
|
|
396
|
+
const isRightArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_RIGHT)
|
|
397
|
+
const isEnter = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ENTER)
|
|
398
|
+
const isEsc = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ESCAPE)
|
|
399
|
+
if (isEsc) {
|
|
400
|
+
close()
|
|
401
|
+
return
|
|
402
|
+
}
|
|
403
|
+
// 回车选中
|
|
404
|
+
if (isEnter) {
|
|
405
|
+
if (activeOption || activeChildOption) {
|
|
406
|
+
evnt.preventDefault()
|
|
407
|
+
evnt.stopPropagation()
|
|
408
|
+
if (!activeChildOption && hasChildMenu(activeOption)) {
|
|
409
|
+
reactData.activeChildOption = findFirstChildItem(activeOption)
|
|
410
|
+
updateChildLocate()
|
|
411
|
+
return
|
|
412
|
+
}
|
|
413
|
+
handleItemClickEvent(evnt, activeChildOption || activeOption)
|
|
414
|
+
return
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
// 方向键操作
|
|
418
|
+
if (activeChildOption) {
|
|
419
|
+
if (isUpArrow) {
|
|
420
|
+
evnt.preventDefault()
|
|
421
|
+
reactData.activeChildOption = findPrevChildItem(activeOption, activeChildOption)
|
|
422
|
+
updateChildLocate()
|
|
423
|
+
} else if (isDwArrow) {
|
|
424
|
+
evnt.preventDefault()
|
|
425
|
+
reactData.activeChildOption = findNextChildItem(activeOption, activeChildOption)
|
|
426
|
+
updateChildLocate()
|
|
427
|
+
} else if (isLeftArrow) {
|
|
428
|
+
evnt.preventDefault()
|
|
429
|
+
reactData.activeChildOption = null
|
|
430
|
+
}
|
|
431
|
+
} else if (activeOption) {
|
|
432
|
+
evnt.preventDefault()
|
|
433
|
+
if (isUpArrow) {
|
|
434
|
+
reactData.activeOption = findPrevFirstItem(allFirstMenuList, activeOption)
|
|
435
|
+
} else if (isDwArrow) {
|
|
436
|
+
reactData.activeOption = findNextFirstItem(allFirstMenuList, activeOption)
|
|
437
|
+
} else {
|
|
438
|
+
if (hasChildMenu(activeOption)) {
|
|
439
|
+
if (isRightArrow) {
|
|
440
|
+
reactData.activeChildOption = findFirstChildItem(activeOption)
|
|
441
|
+
updateChildLocate()
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
} else {
|
|
446
|
+
evnt.preventDefault()
|
|
447
|
+
reactData.activeOption = XEUtils.first(allFirstMenuList)
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
199
452
|
const handleGlobalMousedownEvent = (evnt: MouseEvent) => {
|
|
200
453
|
const { visible } = reactData
|
|
201
454
|
if (visible) {
|
|
@@ -206,6 +459,13 @@ export default defineVxeComponent({
|
|
|
206
459
|
}
|
|
207
460
|
}
|
|
208
461
|
|
|
462
|
+
const handleGlobalBlurEvent = () => {
|
|
463
|
+
const { visible } = reactData
|
|
464
|
+
if (visible) {
|
|
465
|
+
close()
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
209
469
|
const tagPrivateMethods: ContextMenuPrivateMethods = {
|
|
210
470
|
}
|
|
211
471
|
|
|
@@ -302,7 +562,7 @@ export default defineVxeComponent({
|
|
|
302
562
|
}
|
|
303
563
|
|
|
304
564
|
const renderMenus = () => {
|
|
305
|
-
const { activeOption, activeChildOption } = reactData
|
|
565
|
+
const { activeOption, activeChildOption, childOffsetX } = reactData
|
|
306
566
|
const menuGroups = computeMenuGroups.value
|
|
307
567
|
const mgVNs: VNode[] = []
|
|
308
568
|
menuGroups.forEach((menuList, gIndex) => {
|
|
@@ -310,16 +570,22 @@ export default defineVxeComponent({
|
|
|
310
570
|
menuList.forEach((firstItem, i) => {
|
|
311
571
|
const { children } = firstItem
|
|
312
572
|
const hasChildMenus = children && children.some((child) => child.visible !== false)
|
|
573
|
+
const isActiveFirst = activeOption === firstItem
|
|
574
|
+
const showChild = isActiveFirst && !!activeChildOption
|
|
313
575
|
moVNs.push(
|
|
314
576
|
h('div', {
|
|
315
577
|
key: `${gIndex}_${i}`,
|
|
316
578
|
class: ['vxe-context-menu--item-wrapper vxe-context-menu--first-item', firstItem.className || '', {
|
|
317
|
-
'is--active':
|
|
579
|
+
'is--active': isActiveFirst,
|
|
580
|
+
'is--subactive': isActiveFirst && !!activeChildOption
|
|
318
581
|
}]
|
|
319
582
|
}, [
|
|
320
|
-
hasChildMenus
|
|
583
|
+
hasChildMenus && showChild
|
|
321
584
|
? h('div', {
|
|
322
|
-
class: 'vxe-context-menu--children-wrapper'
|
|
585
|
+
class: 'vxe-context-menu--children-wrapper',
|
|
586
|
+
style: {
|
|
587
|
+
transform: `translate(${childOffsetX}px, -5px)`
|
|
588
|
+
}
|
|
323
589
|
}, children.map(twoItem => {
|
|
324
590
|
return h('div', {
|
|
325
591
|
class: ['vxe-context-menu--item-wrapper vxe-context-menu--child-item', twoItem.className || '', {
|
|
@@ -346,11 +612,11 @@ export default defineVxeComponent({
|
|
|
346
612
|
|
|
347
613
|
const renderVN = () => {
|
|
348
614
|
const { className, position, destroyOnClose } = props
|
|
349
|
-
const { visible, popupStyle
|
|
615
|
+
const { visible, popupStyle } = reactData
|
|
350
616
|
const vSize = computeSize.value
|
|
351
617
|
return h('div', {
|
|
352
618
|
ref: refElem,
|
|
353
|
-
class: ['vxe-context-menu vxe-context-menu--wrapper', position === 'absolute' ? ('is--' + position) : 'is--fixed',
|
|
619
|
+
class: ['vxe-context-menu vxe-context-menu--wrapper', position === 'absolute' ? ('is--' + position) : 'is--fixed', className || '', {
|
|
354
620
|
[`size--${vSize}`]: vSize,
|
|
355
621
|
'is--visible': visible
|
|
356
622
|
}],
|
|
@@ -359,7 +625,10 @@ export default defineVxeComponent({
|
|
|
359
625
|
}
|
|
360
626
|
|
|
361
627
|
watch(computeTopAndLeft, () => {
|
|
362
|
-
|
|
628
|
+
handleLocate()
|
|
629
|
+
nextTick(() => {
|
|
630
|
+
updateLocate()
|
|
631
|
+
})
|
|
363
632
|
})
|
|
364
633
|
|
|
365
634
|
watch(() => props.modelValue, () => {
|
|
@@ -369,11 +638,17 @@ export default defineVxeComponent({
|
|
|
369
638
|
handleVisible()
|
|
370
639
|
|
|
371
640
|
onMounted(() => {
|
|
641
|
+
globalEvents.on($xeContextMenu, 'mousewheel', handleGlobalMousewheelEvent)
|
|
642
|
+
globalEvents.on($xeContextMenu, 'keydown', handleGlobalKeydownEvent)
|
|
372
643
|
globalEvents.on($xeContextMenu, 'mousedown', handleGlobalMousedownEvent)
|
|
644
|
+
globalEvents.on($xeContextMenu, 'blur', handleGlobalBlurEvent)
|
|
373
645
|
})
|
|
374
646
|
|
|
375
647
|
onBeforeUnmount(() => {
|
|
648
|
+
globalEvents.off($xeContextMenu, 'mousewheel')
|
|
649
|
+
globalEvents.off($xeContextMenu, 'keydown')
|
|
376
650
|
globalEvents.off($xeContextMenu, 'mousedown')
|
|
651
|
+
globalEvents.off($xeContextMenu, 'blur')
|
|
377
652
|
XEUtils.assign(reactData, createReactData())
|
|
378
653
|
XEUtils.assign(internalData, createInternalData())
|
|
379
654
|
})
|
package/packages/ui/index.ts
CHANGED
|
@@ -12,16 +12,6 @@
|
|
|
12
12
|
&.is--absolute {
|
|
13
13
|
position: absolute;
|
|
14
14
|
}
|
|
15
|
-
&.cp--left {
|
|
16
|
-
.vxe-context-menu--children-wrapper {
|
|
17
|
-
left: calc(-100% + 2px);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
&.cp--right {
|
|
21
|
-
.vxe-context-menu--children-wrapper {
|
|
22
|
-
left: calc(100% - 2px);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
15
|
}
|
|
26
16
|
|
|
27
17
|
.vxe-context-menu--group-wrapper {
|
|
@@ -45,7 +35,7 @@
|
|
|
45
35
|
.vxe-context-menu--children-wrapper {
|
|
46
36
|
display: none;
|
|
47
37
|
position: absolute;
|
|
48
|
-
transform:
|
|
38
|
+
transform: translate(0, -5px);
|
|
49
39
|
}
|
|
50
40
|
|
|
51
41
|
.vxe-context-menu--item-wrapper {
|
|
@@ -58,7 +48,7 @@
|
|
|
58
48
|
}
|
|
59
49
|
}
|
|
60
50
|
.vxe-context-menu--first-item {
|
|
61
|
-
&.is--
|
|
51
|
+
&.is--subactive {
|
|
62
52
|
.vxe-context-menu--children-wrapper {
|
|
63
53
|
display: block;
|
|
64
54
|
}
|
|
@@ -74,7 +74,8 @@ export interface ButtonGroupPrivateMethods {
|
|
|
74
74
|
export interface VxeButtonGroupPrivateMethods extends ButtonGroupPrivateMethods { }
|
|
75
75
|
|
|
76
76
|
export type VxeButtonGroupEmits = [
|
|
77
|
-
'click'
|
|
77
|
+
'click',
|
|
78
|
+
'contextmenu'
|
|
78
79
|
]
|
|
79
80
|
|
|
80
81
|
export namespace VxeButtonGroupDefines {
|
|
@@ -86,18 +87,25 @@ export namespace VxeButtonGroupDefines {
|
|
|
86
87
|
name: VxeButtonPropTypes.Name
|
|
87
88
|
option: VxeButtonProps & Record<string, any>
|
|
88
89
|
}
|
|
90
|
+
|
|
91
|
+
export interface ContextmenuParams extends ButtonGroupEventParams {
|
|
92
|
+
$event: MouseEvent
|
|
93
|
+
}
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
export type VxeButtonGroupEventProps = {
|
|
92
97
|
onClick?: VxeButtonGroupEvents.Click
|
|
98
|
+
onContextmenu?: VxeButtonGroupEvents.Contextmenu
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
export interface VxeButtonGroupListeners {
|
|
96
102
|
click?: VxeButtonGroupEvents.Click
|
|
103
|
+
contextmenu?: VxeButtonGroupEvents.Contextmenu
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
export namespace VxeButtonGroupEvents {
|
|
100
107
|
export type Click = (params: VxeButtonGroupDefines.ClickEventParams) => void
|
|
108
|
+
export type Contextmenu = (params: VxeButtonGroupDefines.ContextmenuParams) => void
|
|
101
109
|
}
|
|
102
110
|
|
|
103
111
|
export namespace VxeButtonGroupSlotTypes {
|
|
@@ -213,7 +213,8 @@ export type VxeButtonEmits = [
|
|
|
213
213
|
'mouseenter',
|
|
214
214
|
'mouseleave',
|
|
215
215
|
'dropdown-click',
|
|
216
|
-
'dropdownClick'
|
|
216
|
+
'dropdownClick',
|
|
217
|
+
'contextmenu'
|
|
217
218
|
]
|
|
218
219
|
|
|
219
220
|
export namespace VxeButtonDefines {
|
|
@@ -239,6 +240,10 @@ export namespace VxeButtonDefines {
|
|
|
239
240
|
option: VxeButtonDefines.DownButtonOption | null
|
|
240
241
|
}
|
|
241
242
|
export interface DropdownClickEventParams extends ButtonEventParams, DropdownClickParams { }
|
|
243
|
+
|
|
244
|
+
export interface ContextmenuParams extends ButtonEventParams {
|
|
245
|
+
$event: MouseEvent
|
|
246
|
+
}
|
|
242
247
|
}
|
|
243
248
|
|
|
244
249
|
export type VxeButtonEventProps = {
|
|
@@ -246,6 +251,7 @@ export type VxeButtonEventProps = {
|
|
|
246
251
|
onMouseenter?: VxeButtonEvents.Mouseenter
|
|
247
252
|
onMouseleave?: VxeButtonEvents.Mouseleave
|
|
248
253
|
onDropdownClick?: VxeButtonEvents.DropdownClick
|
|
254
|
+
onContextmenu?: VxeButtonEvents.Contextmenu
|
|
249
255
|
}
|
|
250
256
|
|
|
251
257
|
export interface VxeButtonListeners {
|
|
@@ -253,6 +259,7 @@ export interface VxeButtonListeners {
|
|
|
253
259
|
mouseenter?: VxeButtonEvents.Mouseenter
|
|
254
260
|
mouseleave?: VxeButtonEvents.Mouseleave
|
|
255
261
|
dropdownClick?: VxeButtonEvents.DropdownClick
|
|
262
|
+
contextmenu?: VxeButtonEvents.Contextmenu
|
|
256
263
|
}
|
|
257
264
|
|
|
258
265
|
export namespace VxeButtonEvents {
|
|
@@ -260,6 +267,7 @@ export namespace VxeButtonEvents {
|
|
|
260
267
|
export type Mouseenter = (params: VxeButtonDefines.MouseenterEventParams) => void
|
|
261
268
|
export type Mouseleave = (params: VxeButtonDefines.MouseleaveEventParams) => void
|
|
262
269
|
export type DropdownClick = (params: VxeButtonDefines.DropdownClickParams) => void
|
|
270
|
+
export type Contextmenu = (params: VxeButtonDefines.ContextmenuParams) => void
|
|
263
271
|
}
|
|
264
272
|
|
|
265
273
|
export namespace VxeButtonSlotTypes {
|
|
@@ -31,6 +31,7 @@ export namespace VxeContextMenuPropTypes {
|
|
|
31
31
|
export type Size = VxeComponentSizeType
|
|
32
32
|
export type Options = VxeContextMenuDefines.MenuFirstOption[][]
|
|
33
33
|
export type Position = null | '' | 'absolute' | 'fixed'
|
|
34
|
+
export type AutoLocate = boolean
|
|
34
35
|
export type ZIndex = string | number
|
|
35
36
|
export type DestroyOnClose = boolean
|
|
36
37
|
export type Transfer = boolean
|
|
@@ -44,6 +45,7 @@ export type VxeContextMenuProps = {
|
|
|
44
45
|
size?: VxeContextMenuPropTypes.Size
|
|
45
46
|
options?: VxeContextMenuPropTypes.Options
|
|
46
47
|
position?: VxeContextMenuPropTypes.Position
|
|
48
|
+
autoLocate?: VxeContextMenuPropTypes.AutoLocate
|
|
47
49
|
zIndex?: VxeContextMenuPropTypes.ZIndex
|
|
48
50
|
destroyOnClose?: VxeContextMenuPropTypes.DestroyOnClose
|
|
49
51
|
transfer?: VxeContextMenuPropTypes.Transfer
|
|
@@ -65,7 +67,7 @@ export interface ContextMenuReactData {
|
|
|
65
67
|
left: string
|
|
66
68
|
zIndex: number
|
|
67
69
|
}
|
|
68
|
-
|
|
70
|
+
childOffsetX: number
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
export interface ContextMenuMethods {
|
|
@@ -96,6 +96,10 @@ export interface TableFilterPrivateMethods<D = any> {
|
|
|
96
96
|
* @private
|
|
97
97
|
*/
|
|
98
98
|
triggerFilterEvent(evnt: any, column: any, params: any): void
|
|
99
|
+
/**
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
handleOpenFilterColumn(evnt: any, btnEl: HTMLElement | null, cellEl: HTMLElement, column: any, params: any): void
|
|
99
103
|
/**
|
|
100
104
|
* @private
|
|
101
105
|
*/
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|