vxe-pc-ui 4.11.30 → 4.11.32

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.
Files changed (202) hide show
  1. package/es/backtop/src/backtop.js +1 -3
  2. package/es/button/src/button.js +21 -12
  3. package/es/components.js +3 -0
  4. package/es/context-menu/index.js +46 -0
  5. package/es/context-menu/src/context-menu.js +343 -0
  6. package/es/context-menu/style.css +112 -0
  7. package/es/context-menu/style.min.css +1 -0
  8. package/es/dynamics/index.js +29 -3
  9. package/es/icon/style.css +1 -1
  10. package/es/language/ar-EG.js +3 -0
  11. package/es/language/de-DE.js +3 -0
  12. package/es/language/en-US.js +3 -0
  13. package/es/language/es-ES.js +3 -0
  14. package/es/language/fr-FR.js +3 -0
  15. package/es/language/hu-HU.js +3 -0
  16. package/es/language/hy-AM.js +4 -1
  17. package/es/language/id-ID.js +3 -0
  18. package/es/language/it-IT.js +3 -0
  19. package/es/language/ja-JP.js +3 -0
  20. package/es/language/ko-KR.js +3 -0
  21. package/es/language/ms-MY.js +3 -0
  22. package/es/language/nb-NO.js +3 -0
  23. package/es/language/pt-BR.js +3 -0
  24. package/es/language/ru-RU.js +3 -0
  25. package/es/language/th-TH.js +3 -0
  26. package/es/language/ug-CN.js +3 -0
  27. package/es/language/uk-UA.js +3 -0
  28. package/es/language/uz-UZ.js +3 -0
  29. package/es/language/vi-VN.js +3 -0
  30. package/es/language/zh-CHT.js +3 -0
  31. package/es/language/zh-CN.js +4 -1
  32. package/es/print/src/print.js +24 -1
  33. package/es/print/src/util.js +8 -1
  34. package/es/style.css +1 -1
  35. package/es/style.min.css +1 -1
  36. package/es/tree/src/tree.js +69 -21
  37. package/es/ui/index.js +8 -3
  38. package/es/ui/src/log.js +1 -1
  39. package/es/vxe-context-menu/index.js +3 -0
  40. package/es/vxe-context-menu/style.css +112 -0
  41. package/es/vxe-context-menu/style.min.css +1 -0
  42. package/lib/backtop/src/backtop.js +0 -2
  43. package/lib/backtop/src/backtop.min.js +1 -1
  44. package/lib/button/src/button.js +12 -6
  45. package/lib/button/src/button.min.js +1 -1
  46. package/lib/components.js +13 -1
  47. package/lib/components.min.js +1 -1
  48. package/lib/context-menu/index.js +56 -0
  49. package/lib/context-menu/index.min.js +1 -0
  50. package/lib/context-menu/src/context-menu.js +362 -0
  51. package/lib/context-menu/src/context-menu.min.js +1 -0
  52. package/lib/context-menu/style/index.js +1 -0
  53. package/lib/context-menu/style/style.css +112 -0
  54. package/lib/context-menu/style/style.min.css +1 -0
  55. package/lib/dynamics/index.js +33 -3
  56. package/lib/dynamics/index.min.js +1 -1
  57. package/lib/icon/style/style.css +1 -1
  58. package/lib/icon/style/style.min.css +1 -1
  59. package/lib/index.umd.js +603 -40
  60. package/lib/index.umd.min.js +1 -1
  61. package/lib/language/ar-EG.js +3 -0
  62. package/lib/language/ar-EG.min.js +1 -1
  63. package/lib/language/ar-EG.umd.js +3 -0
  64. package/lib/language/de-DE.js +3 -0
  65. package/lib/language/de-DE.min.js +1 -1
  66. package/lib/language/de-DE.umd.js +3 -0
  67. package/lib/language/en-US.js +3 -0
  68. package/lib/language/en-US.min.js +1 -1
  69. package/lib/language/en-US.umd.js +3 -0
  70. package/lib/language/es-ES.js +3 -0
  71. package/lib/language/es-ES.min.js +1 -1
  72. package/lib/language/es-ES.umd.js +3 -0
  73. package/lib/language/fr-FR.js +3 -0
  74. package/lib/language/fr-FR.min.js +1 -1
  75. package/lib/language/fr-FR.umd.js +3 -0
  76. package/lib/language/hu-HU.js +3 -0
  77. package/lib/language/hu-HU.min.js +1 -1
  78. package/lib/language/hu-HU.umd.js +3 -0
  79. package/lib/language/hy-AM.js +4 -1
  80. package/lib/language/hy-AM.min.js +1 -1
  81. package/lib/language/hy-AM.umd.js +4 -1
  82. package/lib/language/id-ID.js +3 -0
  83. package/lib/language/id-ID.min.js +1 -1
  84. package/lib/language/id-ID.umd.js +3 -0
  85. package/lib/language/it-IT.js +3 -0
  86. package/lib/language/it-IT.min.js +1 -1
  87. package/lib/language/it-IT.umd.js +3 -0
  88. package/lib/language/ja-JP.js +3 -0
  89. package/lib/language/ja-JP.min.js +1 -1
  90. package/lib/language/ja-JP.umd.js +3 -0
  91. package/lib/language/ko-KR.js +3 -0
  92. package/lib/language/ko-KR.min.js +1 -1
  93. package/lib/language/ko-KR.umd.js +3 -0
  94. package/lib/language/ms-MY.js +3 -0
  95. package/lib/language/ms-MY.min.js +1 -1
  96. package/lib/language/ms-MY.umd.js +3 -0
  97. package/lib/language/nb-NO.js +3 -0
  98. package/lib/language/nb-NO.min.js +1 -1
  99. package/lib/language/nb-NO.umd.js +3 -0
  100. package/lib/language/pt-BR.js +3 -0
  101. package/lib/language/pt-BR.min.js +1 -1
  102. package/lib/language/pt-BR.umd.js +3 -0
  103. package/lib/language/ru-RU.js +3 -0
  104. package/lib/language/ru-RU.min.js +1 -1
  105. package/lib/language/ru-RU.umd.js +3 -0
  106. package/lib/language/th-TH.js +3 -0
  107. package/lib/language/th-TH.min.js +1 -1
  108. package/lib/language/th-TH.umd.js +3 -0
  109. package/lib/language/ug-CN.js +3 -0
  110. package/lib/language/ug-CN.min.js +1 -1
  111. package/lib/language/ug-CN.umd.js +3 -0
  112. package/lib/language/uk-UA.js +3 -0
  113. package/lib/language/uk-UA.min.js +1 -1
  114. package/lib/language/uk-UA.umd.js +3 -0
  115. package/lib/language/uz-UZ.js +3 -0
  116. package/lib/language/uz-UZ.min.js +1 -1
  117. package/lib/language/uz-UZ.umd.js +3 -0
  118. package/lib/language/vi-VN.js +3 -0
  119. package/lib/language/vi-VN.min.js +1 -1
  120. package/lib/language/vi-VN.umd.js +3 -0
  121. package/lib/language/zh-CHT.js +3 -0
  122. package/lib/language/zh-CHT.min.js +1 -1
  123. package/lib/language/zh-CHT.umd.js +3 -0
  124. package/lib/language/zh-CN.js +4 -1
  125. package/lib/language/zh-CN.min.js +1 -1
  126. package/lib/language/zh-CN.umd.js +4 -1
  127. package/lib/print/src/print.js +42 -1
  128. package/lib/print/src/print.min.js +1 -1
  129. package/lib/print/src/util.js +9 -2
  130. package/lib/print/src/util.min.js +1 -1
  131. package/lib/style.css +1 -1
  132. package/lib/style.min.css +1 -1
  133. package/lib/tree/src/tree.js +78 -20
  134. package/lib/tree/src/tree.min.js +1 -1
  135. package/lib/ui/index.js +8 -3
  136. package/lib/ui/index.min.js +1 -1
  137. package/lib/ui/src/log.js +1 -1
  138. package/lib/ui/src/log.min.js +1 -1
  139. package/lib/vxe-context-menu/index.js +22 -0
  140. package/lib/vxe-context-menu/index.min.js +1 -0
  141. package/lib/vxe-context-menu/style/index.js +1 -0
  142. package/lib/vxe-context-menu/style/style.css +112 -0
  143. package/lib/vxe-context-menu/style/style.min.css +1 -0
  144. package/package.json +1 -1
  145. package/packages/backtop/src/backtop.ts +1 -4
  146. package/packages/button/src/button.ts +22 -13
  147. package/packages/components.ts +3 -0
  148. package/packages/context-menu/index.ts +54 -0
  149. package/packages/context-menu/src/context-menu.ts +388 -0
  150. package/packages/dynamics/index.ts +36 -9
  151. package/packages/language/ar-EG.ts +3 -0
  152. package/packages/language/de-DE.ts +3 -0
  153. package/packages/language/en-US.ts +3 -0
  154. package/packages/language/es-ES.ts +3 -0
  155. package/packages/language/fr-FR.ts +3 -0
  156. package/packages/language/hu-HU.ts +3 -0
  157. package/packages/language/hy-AM.ts +4 -1
  158. package/packages/language/id-ID.ts +3 -0
  159. package/packages/language/it-IT.ts +3 -0
  160. package/packages/language/ja-JP.ts +3 -0
  161. package/packages/language/ko-KR.ts +3 -0
  162. package/packages/language/ms-MY.ts +3 -0
  163. package/packages/language/nb-NO.ts +3 -0
  164. package/packages/language/pt-BR.ts +3 -0
  165. package/packages/language/ru-RU.ts +3 -0
  166. package/packages/language/th-TH.ts +3 -0
  167. package/packages/language/ug-CN.ts +3 -0
  168. package/packages/language/uk-UA.ts +3 -0
  169. package/packages/language/uz-UZ.ts +3 -0
  170. package/packages/language/vi-VN.ts +3 -0
  171. package/packages/language/zh-CHT.ts +3 -0
  172. package/packages/language/zh-CN.ts +4 -1
  173. package/packages/print/src/print.ts +24 -1
  174. package/packages/print/src/util.ts +9 -1
  175. package/packages/tree/src/tree.ts +73 -22
  176. package/packages/ui/index.ts +8 -2
  177. package/styles/all.scss +1 -0
  178. package/styles/components/backtop.scss +1 -1
  179. package/styles/components/context-menu.scss +113 -0
  180. package/styles/theme/base.scss +3 -0
  181. package/types/all.d.ts +3 -0
  182. package/types/components/button.d.ts +3 -1
  183. package/types/components/context-menu.d.ts +286 -0
  184. package/types/components/password-input.d.ts +2 -0
  185. package/types/components/print.d.ts +8 -0
  186. package/types/components/table.d.ts +8 -0
  187. package/types/components/tree.d.ts +46 -1
  188. package/types/ui/global-config.d.ts +2 -0
  189. package/types/ui/global-icon.d.ts +4 -0
  190. package/types/ui/index.d.ts +3 -0
  191. /package/es/icon/{iconfont.1767491587367.ttf → iconfont.1767614230277.ttf} +0 -0
  192. /package/es/icon/{iconfont.1767491587367.woff → iconfont.1767614230277.woff} +0 -0
  193. /package/es/icon/{iconfont.1767491587367.woff2 → iconfont.1767614230277.woff2} +0 -0
  194. /package/es/{iconfont.1767491587367.ttf → iconfont.1767614230277.ttf} +0 -0
  195. /package/es/{iconfont.1767491587367.woff → iconfont.1767614230277.woff} +0 -0
  196. /package/es/{iconfont.1767491587367.woff2 → iconfont.1767614230277.woff2} +0 -0
  197. /package/lib/icon/style/{iconfont.1767491587367.ttf → iconfont.1767614230277.ttf} +0 -0
  198. /package/lib/icon/style/{iconfont.1767491587367.woff → iconfont.1767614230277.woff} +0 -0
  199. /package/lib/icon/style/{iconfont.1767491587367.woff2 → iconfont.1767614230277.woff2} +0 -0
  200. /package/lib/{iconfont.1767491587367.ttf → iconfont.1767614230277.ttf} +0 -0
  201. /package/lib/{iconfont.1767491587367.woff → iconfont.1767614230277.woff} +0 -0
  202. /package/lib/{iconfont.1767491587367.woff2 → iconfont.1767614230277.woff2} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vxe-pc-ui",
3
- "version": "4.11.30",
3
+ "version": "4.11.32",
4
4
  "description": "A vue based PC component library",
5
5
  "scripts": {
6
6
  "update": "npm install --legacy-peer-deps",
@@ -1,4 +1,4 @@
1
- import { ref, h, reactive, PropType, watch, onMounted, nextTick, computed, onBeforeUnmount, onUnmounted } from 'vue'
1
+ import { ref, h, reactive, PropType, watch, onMounted, nextTick, computed, onBeforeUnmount } from 'vue'
2
2
  import { defineVxeComponent } from '../../ui/src/comp'
3
3
  import XEUtils from 'xe-utils'
4
4
  import { getConfig, getIcon, createEvent, useSize, renderEmptyElement } from '../../ui'
@@ -248,9 +248,6 @@ export default defineVxeComponent({
248
248
  onBeforeUnmount(() => {
249
249
  removeScrollEvent()
250
250
  XEUtils.assign(reactData, createReactData())
251
- })
252
-
253
- onUnmounted(() => {
254
251
  XEUtils.assign(internalData, createInternalData())
255
252
  })
256
253
 
@@ -8,7 +8,7 @@ import { getSlotVNs } from '../../ui/src/vn'
8
8
  import { warnLog } from '../../ui/src/log'
9
9
  import VxeTooltipComponent from '../../tooltip/src/tooltip'
10
10
 
11
- import type { VxeButtonConstructor, VxeButtonPropTypes, VxeButtonEmits, ButtonReactData, ButtonMethods, VxeButtonDefines, ButtonPrivateRef, ButtonInternalData, VxeButtonGroupConstructor, VxeButtonGroupPrivateMethods, VxeDrawerConstructor, VxeDrawerMethods, VxeFormConstructor, VxeFormPrivateMethods, VxeModalConstructor, VxeModalMethods, ValueOf } from '../../../types'
11
+ import type { VxeButtonConstructor, VxeButtonPropTypes, VxeButtonEmits, ButtonReactData, ButtonMethods, VxeButtonDefines, ButtonPrivateRef, ButtonInternalData, VxeButtonGroupConstructor, VxeButtonGroupPrivateMethods, VxeDrawerConstructor, VxeDrawerMethods, VxeFormConstructor, VxeFormPrivateMethods, VxeModalConstructor, VxeModalMethods, ValueOf, VxeTreeConstructor, VxeTreePrivateMethods } from '../../../types'
12
12
  import type { VxeTableConstructor, VxeTablePrivateMethods } from '../../../types/components/table'
13
13
 
14
14
  const VxeButtonComponent = defineVxeComponent({
@@ -93,6 +93,10 @@ const VxeButtonComponent = defineVxeComponent({
93
93
  prefixTooltip: Object as PropType<VxeButtonPropTypes.PrefixTooltip>,
94
94
  suffixTooltip: Object as PropType<VxeButtonPropTypes.SuffixTooltip>,
95
95
  options: Array as PropType<VxeButtonPropTypes.Options>,
96
+ showDropdownIcon: {
97
+ type: Boolean,
98
+ default: () => getConfig().button.showDropdownIcon
99
+ },
96
100
  /**
97
101
  * 在下拉面板关闭时销毁内容
98
102
  */
@@ -121,6 +125,7 @@ const VxeButtonComponent = defineVxeComponent({
121
125
  const $xeModal = inject<(VxeModalConstructor & VxeModalMethods)| null>('$xeModal', null)
122
126
  const $xeDrawer = inject<(VxeDrawerConstructor & VxeDrawerMethods) | null>('$xeDrawer', null)
123
127
  const $xeTable = inject<(VxeTableConstructor & VxeTablePrivateMethods) | null>('$xeTable', null)
128
+ const $xeTree = inject<(VxeTreeConstructor & VxeTreePrivateMethods) | null>('$xeTree', null)
124
129
  const $xeForm = inject<(VxeFormConstructor & VxeFormPrivateMethods)| null>('$xeForm', null)
125
130
  const $xeButtonGroup = inject<(VxeButtonGroupConstructor & VxeButtonGroupPrivateMethods) | null>('$xeButtonGroup', null)
126
131
 
@@ -171,7 +176,7 @@ const VxeButtonComponent = defineVxeComponent({
171
176
  if (XEUtils.isBoolean(globalTransfer)) {
172
177
  return globalTransfer
173
178
  }
174
- if ($xeTable || $xeModal || $xeDrawer || $xeForm) {
179
+ if ($xeTable || $xeTree || $xeModal || $xeDrawer || $xeForm) {
175
180
  return true
176
181
  }
177
182
  }
@@ -592,7 +597,7 @@ const VxeButtonComponent = defineVxeComponent({
592
597
  Object.assign($xeButton, buttonMethods)
593
598
 
594
599
  const renderVN = () => {
595
- const { className, popupClassName, trigger, title, routerLink, type, destroyOnClose, name, loading } = props
600
+ const { className, popupClassName, trigger, title, routerLink, type, destroyOnClose, name, loading, showDropdownIcon } = props
596
601
  const { initialized, isAniVisible, visiblePanel } = reactData
597
602
  const isFormBtn = computeIsFormBtn.value
598
603
  const btnMode = computeBtnMode.value
@@ -648,11 +653,13 @@ const VxeButtonComponent = defineVxeComponent({
648
653
  ...btnOns
649
654
  }, {
650
655
  default () {
651
- return renderContent().concat([
652
- h('i', {
653
- class: `vxe-button--dropdown-arrow ${getIcon().BUTTON_DROPDOWN}`
654
- })
655
- ])
656
+ return renderContent().concat(showDropdownIcon
657
+ ? [
658
+ h('i', {
659
+ class: `vxe-button--dropdown-arrow ${getIcon().BUTTON_DROPDOWN}`
660
+ })
661
+ ]
662
+ : [])
656
663
  }
657
664
  })
658
665
  : h('button', {
@@ -671,11 +678,13 @@ const VxeButtonComponent = defineVxeComponent({
671
678
  disabled: btnDisabled || loading,
672
679
  onClick: clickTargetEvent,
673
680
  ...btnOns
674
- }, renderContent().concat([
675
- h('i', {
676
- class: `vxe-button--dropdown-arrow ${getIcon().BUTTON_DROPDOWN}`
677
- })
678
- ])),
681
+ }, renderContent().concat(showDropdownIcon
682
+ ? [
683
+ h('i', {
684
+ class: `vxe-button--dropdown-arrow ${getIcon().BUTTON_DROPDOWN}`
685
+ })
686
+ ]
687
+ : [])),
679
688
  h(Teleport, {
680
689
  to: 'body',
681
690
  disabled: btnTransfer ? !initialized : true
@@ -25,6 +25,7 @@ import VxeCol from './col'
25
25
  import VxeCollapse from './collapse'
26
26
  import VxeCollapsePane from './collapse-pane'
27
27
  import VxeColorPicker from './color-picker'
28
+ import VxeContextMenu from './context-menu'
28
29
  import VxeCountdown from './countdown'
29
30
  import VxeDatePanel from './date-panel'
30
31
  import VxeDatePicker from './date-picker'
@@ -122,6 +123,7 @@ const components = [
122
123
  VxeCollapse,
123
124
  VxeCollapsePane,
124
125
  VxeColorPicker,
126
+ VxeContextMenu,
125
127
  VxeCountdown,
126
128
  VxeDatePanel,
127
129
  VxeDatePicker,
@@ -236,6 +238,7 @@ export * from './col'
236
238
  export * from './collapse'
237
239
  export * from './collapse-pane'
238
240
  export * from './color-picker'
241
+ export * from './context-menu'
239
242
  export * from './countdown'
240
243
  export * from './date-panel'
241
244
  export * from './date-picker'
@@ -0,0 +1,54 @@
1
+ import { App } from 'vue'
2
+ import { VxeUI } from '@vxe-ui/core'
3
+ import VxeContextMenuComponent from './src/context-menu'
4
+ import { dynamicApp, dynamicStore, checkDynamic } from '../dynamics'
5
+
6
+ import type { VxeContextMenuDefines } from '../../types'
7
+
8
+ export const VxeContextMenu = Object.assign({}, VxeContextMenuComponent, {
9
+ install (app: App) {
10
+ app.component(VxeContextMenuComponent.name as string, VxeContextMenuComponent)
11
+ }
12
+ })
13
+
14
+ function openMenu (opts: VxeContextMenuDefines.ContextMenuOpenOptions, x: number, y :number) {
15
+ dynamicStore.globalContextMenu = {
16
+ modelValue: true,
17
+ options: opts.options,
18
+ className: opts.className,
19
+ size: opts.size,
20
+ zIndex: opts.zIndex,
21
+ x,
22
+ y,
23
+ position: 'fixed',
24
+ destroyOnClose: true,
25
+ transfer: false,
26
+ events: opts.events
27
+ }
28
+ checkDynamic()
29
+ }
30
+
31
+ export const ContextMenuController = {
32
+ open (options: VxeContextMenuDefines.ContextMenuOpenOptions) {
33
+ const opts = Object.assign({ x: 0, y: 0 }, options)
34
+ openMenu(opts, opts.x, opts.y)
35
+ },
36
+ openByEvent (evnt: MouseEvent, options: VxeContextMenuDefines.ContextMenuEventOpenOptions) {
37
+ evnt.preventDefault()
38
+ evnt.stopPropagation()
39
+ const opts = Object.assign({}, options)
40
+ const x = evnt.clientX
41
+ const y = evnt.clientY
42
+ openMenu(opts, x, y)
43
+ },
44
+ close () {
45
+ dynamicStore.globalContextMenu = null
46
+ }
47
+ }
48
+
49
+ dynamicApp.use(VxeContextMenu)
50
+ VxeUI.component(VxeContextMenuComponent)
51
+ VxeUI.contextMenu = ContextMenuController
52
+
53
+ export const ContextMenu = VxeContextMenu
54
+ export default VxeContextMenu
@@ -0,0 +1,388 @@
1
+ import { ref, h, reactive, PropType, computed, VNode, watch, onMounted, onBeforeUnmount, nextTick } from 'vue'
2
+ import { defineVxeComponent } from '../../ui/src/comp'
3
+ import XEUtils from 'xe-utils'
4
+ import { getConfig, getIcon, getI18n, createEvent, useSize, globalEvents, renderEmptyElement } from '../../ui'
5
+ import { getLastZIndex, nextSubZIndex, nextZIndex, getFuncText } from '../../ui/src/utils'
6
+ import { getEventTargetNode, toCssUnit } from '../../ui/src/dom'
7
+ import { getSlotVNs } from '../../ui/src/vn'
8
+
9
+ import type { ContextMenuInternalData, ContextMenuReactData, VxeContextMenuPropTypes, VxeContextMenuDefines, ContextMenuPrivateRef, VxeContextMenuEmits, VxeContextMenuPrivateComputed, ContextMenuMethods, ContextMenuPrivateMethods, VxeContextMenuConstructor, VxeContextMenuPrivateMethods, ValueOf } from '../../../types'
10
+
11
+ function createInternalData (): ContextMenuInternalData {
12
+ return {
13
+ }
14
+ }
15
+
16
+ function createReactData (): ContextMenuReactData {
17
+ return {
18
+ visible: false,
19
+ activeOption: null,
20
+ activeChildOption: null,
21
+ popupStyle: {
22
+ top: '',
23
+ left: '',
24
+ zIndex: 0
25
+ },
26
+ childPos: ''
27
+ }
28
+ }
29
+
30
+ export default defineVxeComponent({
31
+ name: 'VxeContextMenu',
32
+ props: {
33
+ modelValue: Boolean as PropType<VxeContextMenuPropTypes.ModelValue>,
34
+ className: String as PropType<VxeContextMenuPropTypes.ClassName>,
35
+ size: {
36
+ type: String as PropType<VxeContextMenuPropTypes.Size>,
37
+ default: () => getConfig().contextMenu.size || getConfig().size
38
+ },
39
+ options: Array as PropType<VxeContextMenuPropTypes.Options>,
40
+ x: [Number, String] as PropType<VxeContextMenuPropTypes.X>,
41
+ y: [Number, String] as PropType<VxeContextMenuPropTypes.Y>,
42
+ zIndex: [Number, String] as PropType<VxeContextMenuPropTypes.ZIndex>,
43
+ position: {
44
+ type: String as PropType<VxeContextMenuPropTypes.Position>,
45
+ default: () => getConfig().contextMenu.position
46
+ },
47
+ destroyOnClose: {
48
+ type: Boolean as PropType<VxeContextMenuPropTypes.DestroyOnClose>,
49
+ default: () => getConfig().contextMenu.destroyOnClose
50
+ },
51
+ transfer: {
52
+ type: Boolean as PropType<VxeContextMenuPropTypes.Transfer>,
53
+ default: () => getConfig().contextMenu.transfer
54
+ }
55
+ },
56
+ emits: [
57
+ 'update:modelValue',
58
+ 'option-click',
59
+ 'change',
60
+ 'show',
61
+ 'hide'
62
+ ] as VxeContextMenuEmits,
63
+ setup (props, context) {
64
+ const { emit } = context
65
+
66
+ const xID = XEUtils.uniqueId()
67
+
68
+ const refElem = ref<HTMLDivElement>()
69
+
70
+ const { computeSize } = useSize(props)
71
+
72
+ const internalData = createInternalData()
73
+ const reactData = reactive(createReactData())
74
+
75
+ const refMaps: ContextMenuPrivateRef = {
76
+ refElem
77
+ }
78
+
79
+ const computeMenuGroups = computed(() => {
80
+ const { options } = props
81
+ return options || []
82
+ })
83
+
84
+ const computeTopAndLeft = computed(() => {
85
+ const { x, y } = props
86
+ return `${x}${y}`
87
+ })
88
+
89
+ const computeMaps: VxeContextMenuPrivateComputed = {
90
+ }
91
+
92
+ const $xeContextMenu = {
93
+ xID,
94
+ props,
95
+ context,
96
+ reactData,
97
+
98
+ getRefMaps: () => refMaps,
99
+ getComputeMaps: () => computeMaps
100
+ } as unknown as VxeContextMenuConstructor & VxeContextMenuPrivateMethods
101
+
102
+ const dispatchEvent = (type: ValueOf<VxeContextMenuEmits>, params: Record<string, any>, evnt: Event | null) => {
103
+ emit(type, createEvent(evnt, { $contextMenu: $xeContextMenu }, params))
104
+ }
105
+
106
+ const emitModel = (value: any) => {
107
+ emit('update:modelValue', value)
108
+ }
109
+
110
+ const open = () => {
111
+ const { modelValue } = props
112
+ const { visible } = reactData
113
+ const value = true
114
+ reactData.visible = value
115
+ updateLocate()
116
+ updateZindex()
117
+ if (modelValue !== value) {
118
+ emitModel(value)
119
+ dispatchEvent('change', { value }, null)
120
+ }
121
+ if (visible !== value) {
122
+ dispatchEvent('show', { visible: value }, null)
123
+ }
124
+ return nextTick()
125
+ }
126
+
127
+ const close = () => {
128
+ const { modelValue } = props
129
+ const { visible } = reactData
130
+ const value = false
131
+ reactData.visible = value
132
+ if (modelValue !== value) {
133
+ emitModel(value)
134
+ dispatchEvent('change', { value }, null)
135
+ }
136
+ if (visible !== value) {
137
+ dispatchEvent('hide', { visible: value }, null)
138
+ }
139
+ return nextTick()
140
+ }
141
+
142
+ const updateLocate = () => {
143
+ const { x, y } = props
144
+ const { popupStyle } = reactData
145
+ popupStyle.left = toCssUnit(x || 0)
146
+ popupStyle.top = toCssUnit(y || 0)
147
+ }
148
+
149
+ const updateZindex = () => {
150
+ const { zIndex, transfer } = props
151
+ const { popupStyle } = reactData
152
+ const menuZIndex = popupStyle.zIndex
153
+ if (zIndex) {
154
+ popupStyle.zIndex = XEUtils.toNumber(zIndex)
155
+ } else {
156
+ if (menuZIndex < getLastZIndex()) {
157
+ popupStyle.zIndex = transfer ? nextSubZIndex() : nextZIndex()
158
+ }
159
+ }
160
+ }
161
+
162
+ const handleVisible = () => {
163
+ const { modelValue } = props
164
+ if (modelValue) {
165
+ open()
166
+ } else {
167
+ close()
168
+ }
169
+ }
170
+
171
+ const tagMethods: ContextMenuMethods = {
172
+ dispatchEvent,
173
+ open,
174
+ close
175
+ }
176
+
177
+ const hasChildMenu = (item: VxeContextMenuDefines.MenuFirstOption | VxeContextMenuDefines.MenuChildOption) => {
178
+ const { children } = item as VxeContextMenuDefines.MenuFirstOption
179
+ return children && children.some((child) => child.visible !== false)
180
+ }
181
+
182
+ const handleItemClickEvent = (evnt: MouseEvent, item: VxeContextMenuDefines.MenuFirstOption | VxeContextMenuDefines.MenuChildOption) => {
183
+ if (!hasChildMenu(item)) {
184
+ dispatchEvent('option-click', { option: item }, evnt)
185
+ close()
186
+ }
187
+ }
188
+
189
+ const handleItemMouseenterEvent = (evnt: MouseEvent, item: VxeContextMenuDefines.MenuFirstOption | VxeContextMenuDefines.MenuChildOption, parentitem?: VxeContextMenuDefines.MenuFirstOption | null) => {
190
+ reactData.activeOption = parentitem || item
191
+ reactData.activeChildOption = parentitem ? item : null
192
+ }
193
+
194
+ const handleItemMouseleaveEvent = () => {
195
+ reactData.activeOption = null
196
+ reactData.activeChildOption = null
197
+ }
198
+
199
+ const handleGlobalMousedownEvent = (evnt: MouseEvent) => {
200
+ const { visible } = reactData
201
+ if (visible) {
202
+ const el = refElem.value
203
+ if (!getEventTargetNode(evnt, el, '').flag) {
204
+ close()
205
+ }
206
+ }
207
+ }
208
+
209
+ const tagPrivateMethods: ContextMenuPrivateMethods = {
210
+ }
211
+
212
+ Object.assign($xeContextMenu, tagMethods, tagPrivateMethods)
213
+
214
+ const renderMenuItem = (item: VxeContextMenuDefines.MenuFirstOption | VxeContextMenuDefines.MenuChildOption, parentItem: VxeContextMenuDefines.MenuFirstOption | VxeContextMenuDefines.MenuChildOption | null, hasChildMenus?: boolean) => {
215
+ const { visible, disabled, loading } = item
216
+ if (visible === false) {
217
+ return renderEmptyElement($xeContextMenu)
218
+ }
219
+ const prefixOpts = Object.assign({}, item.prefixConfig)
220
+ const prefixIcon = prefixOpts.icon || item.prefixIcon
221
+ const suffixOpts = Object.assign({}, item.suffixConfig)
222
+ const suffixIcon = suffixOpts.icon || item.suffixIcon
223
+ const menuContent = loading ? getI18n('vxe.contextMenu.loadingText') : getFuncText(item.name)
224
+ return h('div', {
225
+ class: ['vxe-context-menu--item-inner', {
226
+ 'is--disabled': disabled,
227
+ 'is--loading': loading
228
+ }],
229
+ onClick (evnt) {
230
+ handleItemClickEvent(evnt, item)
231
+ },
232
+ onMouseenter (evnt) {
233
+ handleItemMouseenterEvent(evnt, item, parentItem)
234
+ },
235
+ onMouseleave: handleItemMouseleaveEvent
236
+ }, [
237
+ h('div', {
238
+ class: ['vxe-context-menu--item-prefix', prefixOpts.className || '']
239
+ }, loading
240
+ ? [
241
+ h('span', {
242
+ key: '1'
243
+ }, [
244
+ h('i', {
245
+ class: getIcon().CONTEXT_MENU_OPTION_LOADING
246
+ })
247
+ ])
248
+ ]
249
+ : [
250
+ prefixIcon && XEUtils.isFunction(prefixIcon)
251
+ ? h('span', {
252
+ key: '2'
253
+ }, getSlotVNs(prefixIcon({})))
254
+ : h('span', {
255
+ key: '3'
256
+ }, [
257
+ h('i', {
258
+ class: prefixIcon
259
+ })
260
+ ]),
261
+ prefixOpts.content
262
+ ? h('span', {
263
+ key: '4'
264
+ }, `${prefixOpts.content || ''}`)
265
+ : renderEmptyElement($xeContextMenu)
266
+ ]),
267
+ h('div', {
268
+ class: 'vxe-context-menu--item-label'
269
+ }, menuContent),
270
+ !loading && (suffixIcon || suffixOpts.content)
271
+ ? h('div', {
272
+ class: ['vxe-context-menu--item-suffix', suffixOpts.className || '']
273
+ }, [
274
+ suffixIcon && XEUtils.isFunction(suffixIcon)
275
+ ? h('span', {
276
+ key: '2'
277
+ }, getSlotVNs(suffixIcon({})))
278
+ : h('span', {
279
+ key: '3'
280
+ }, [
281
+ h('i', {
282
+ class: suffixIcon
283
+ })
284
+ ]),
285
+ suffixOpts.content
286
+ ? h('span', {
287
+ key: '4'
288
+ }, `${suffixOpts.content || ''}`)
289
+ : renderEmptyElement($xeContextMenu)
290
+ ])
291
+ : renderEmptyElement($xeContextMenu),
292
+ hasChildMenus
293
+ ? h('div', {
294
+ class: 'vxe-context-menu--item-subicon'
295
+ }, [
296
+ h('i', {
297
+ class: getIcon().CONTEXT_MENU_CHILDREN
298
+ })
299
+ ])
300
+ : renderEmptyElement($xeContextMenu)
301
+ ])
302
+ }
303
+
304
+ const renderMenus = () => {
305
+ const { activeOption, activeChildOption } = reactData
306
+ const menuGroups = computeMenuGroups.value
307
+ const mgVNs: VNode[] = []
308
+ menuGroups.forEach((menuList, gIndex) => {
309
+ const moVNs: VNode[] = []
310
+ menuList.forEach((firstItem, i) => {
311
+ const { children } = firstItem
312
+ const hasChildMenus = children && children.some((child) => child.visible !== false)
313
+ moVNs.push(
314
+ h('div', {
315
+ key: `${gIndex}_${i}`,
316
+ class: ['vxe-context-menu--item-wrapper vxe-context-menu--first-item', firstItem.className || '', {
317
+ 'is--active': activeOption === firstItem
318
+ }]
319
+ }, [
320
+ hasChildMenus
321
+ ? h('div', {
322
+ class: 'vxe-context-menu--children-wrapper'
323
+ }, children.map(twoItem => {
324
+ return h('div', {
325
+ class: ['vxe-context-menu--item-wrapper vxe-context-menu--child-item', twoItem.className || '', {
326
+ 'is--active': activeChildOption === twoItem
327
+ }]
328
+ }, [
329
+ renderMenuItem(twoItem, firstItem)
330
+ ])
331
+ }))
332
+ : renderEmptyElement($xeContextMenu),
333
+ renderMenuItem(firstItem, null, hasChildMenus)
334
+ ])
335
+ )
336
+ })
337
+ mgVNs.push(
338
+ h('div', {
339
+ key: gIndex,
340
+ class: 'vxe-context-menu--group-wrapper'
341
+ }, moVNs)
342
+ )
343
+ })
344
+ return mgVNs
345
+ }
346
+
347
+ const renderVN = () => {
348
+ const { className, position, destroyOnClose } = props
349
+ const { visible, popupStyle, childPos } = reactData
350
+ const vSize = computeSize.value
351
+ return h('div', {
352
+ ref: refElem,
353
+ class: ['vxe-context-menu vxe-context-menu--wrapper', position === 'absolute' ? ('is--' + position) : 'is--fixed', `cp--${childPos === 'left' ? childPos : 'right'}`, className || '', {
354
+ [`size--${vSize}`]: vSize,
355
+ 'is--visible': visible
356
+ }],
357
+ style: popupStyle
358
+ }, (destroyOnClose ? visible : true) ? renderMenus() : [])
359
+ }
360
+
361
+ watch(computeTopAndLeft, () => {
362
+ updateLocate()
363
+ })
364
+
365
+ watch(() => props.modelValue, () => {
366
+ handleVisible()
367
+ })
368
+
369
+ handleVisible()
370
+
371
+ onMounted(() => {
372
+ globalEvents.on($xeContextMenu, 'mousedown', handleGlobalMousedownEvent)
373
+ })
374
+
375
+ onBeforeUnmount(() => {
376
+ globalEvents.off($xeContextMenu, 'mousedown')
377
+ XEUtils.assign(reactData, createReactData())
378
+ XEUtils.assign(internalData, createInternalData())
379
+ })
380
+
381
+ $xeContextMenu.renderVN = renderVN
382
+
383
+ return $xeContextMenu
384
+ },
385
+ render () {
386
+ return this.renderVN()
387
+ }
388
+ })
@@ -2,7 +2,7 @@ import { h, createApp, reactive, createCommentVNode } from 'vue'
2
2
  import { defineVxeComponent } from '../ui/src/comp'
3
3
  import { VxeUI } from '@vxe-ui/core'
4
4
 
5
- import type { VxeModalDefines, VxeDrawerDefines, VxeLoadingProps, VxeWatermarkProps } from '../../types'
5
+ import type { VxeModalDefines, VxeDrawerDefines, VxeLoadingProps, VxeWatermarkProps, VxeContextMenuProps, VxeContextMenuDefines, VxeContextMenuEventProps } from '../../types'
6
6
 
7
7
  let dynamicContainerElem: HTMLElement
8
8
 
@@ -11,12 +11,14 @@ export const dynamicStore = reactive<{
11
11
  drawers: VxeDrawerDefines.DrawerOptions[]
12
12
  globalLoading: null | VxeLoadingProps
13
13
  globalWatermark: null | VxeWatermarkProps
14
- }>({
15
- modals: [],
16
- drawers: [],
17
- globalLoading: null,
18
- globalWatermark: null
19
- })
14
+ globalContextMenu: null |(VxeContextMenuProps & VxeContextMenuDefines.ContextMenuOpenOptions)
15
+ }>({
16
+ modals: [],
17
+ drawers: [],
18
+ globalLoading: null,
19
+ globalWatermark: null,
20
+ globalContextMenu: null
21
+ })
20
22
 
21
23
  /**
22
24
  * 动态组件
@@ -27,9 +29,33 @@ const VxeDynamics = defineVxeComponent({
27
29
  const VxeUIDrawerComponent = VxeUI.getComponent('vxe-drawer')
28
30
  const VxeUILoadingComponent = VxeUI.getComponent('vxe-loading')
29
31
  const VxeUIWatermarkComponent = VxeUI.getComponent('vxe-watermark')
32
+ const VxeUIContextMenuComponent = VxeUI.getComponent('vxe-context-menu')
30
33
 
31
34
  return () => {
32
- const { modals, drawers, globalWatermark, globalLoading } = dynamicStore
35
+ const { modals, drawers, globalWatermark, globalLoading, globalContextMenu } = dynamicStore
36
+ let cmOpts: (VxeContextMenuProps & VxeContextMenuEventProps) | null = globalContextMenu
37
+ if (globalContextMenu) {
38
+ const events = globalContextMenu.events || {}
39
+ const { optionClick, show, hide } = events
40
+ cmOpts = Object.assign({}, globalContextMenu, {
41
+ onShow (params: VxeContextMenuDefines.ShowEventParams) {
42
+ if (show) {
43
+ show(params)
44
+ }
45
+ },
46
+ onHide (params: VxeContextMenuDefines.HideEventParams) {
47
+ if (hide) {
48
+ hide(params)
49
+ }
50
+ dynamicStore.globalContextMenu = null
51
+ },
52
+ onOptionClick (params: VxeContextMenuDefines.OptionClickEventParams) {
53
+ if (optionClick) {
54
+ optionClick(params)
55
+ }
56
+ }
57
+ })
58
+ }
33
59
  return [
34
60
  modals.length
35
61
  ? h('div', {
@@ -44,7 +70,8 @@ const VxeDynamics = defineVxeComponent({
44
70
  }, drawers.map((item) => h(VxeUIDrawerComponent, item)))
45
71
  : createCommentVNode(),
46
72
  globalWatermark ? h(VxeUIWatermarkComponent, globalWatermark) : createCommentVNode(),
47
- globalLoading ? h(VxeUILoadingComponent, globalLoading) : createCommentVNode()
73
+ globalLoading ? h(VxeUILoadingComponent, globalLoading) : createCommentVNode(),
74
+ globalContextMenu ? h(VxeUIContextMenuComponent, cmOpts) : createCommentVNode()
48
75
  ]
49
76
  }
50
77
  }
@@ -539,6 +539,9 @@ export default {
539
539
  ss: 'ثانية'
540
540
  }
541
541
  },
542
+ contextMenu: {
543
+ loadingText: '加载中...'
544
+ },
542
545
  gantt: {
543
546
  tFullFormat: {
544
547
  year: '{yyyy}年',
@@ -539,6 +539,9 @@ export default {
539
539
  ss: 'Zweite'
540
540
  }
541
541
  },
542
+ contextMenu: {
543
+ loadingText: '加载中...'
544
+ },
542
545
  gantt: {
543
546
  tFullFormat: {
544
547
  year: '{yyyy}年',
@@ -539,6 +539,9 @@ export default {
539
539
  ss: 'Second'
540
540
  }
541
541
  },
542
+ contextMenu: {
543
+ loadingText: 'Loading'
544
+ },
542
545
  gantt: {
543
546
  tFullFormat: {
544
547
  year: '{yyyy}年',
@@ -539,6 +539,9 @@ export default {
539
539
  ss: 'Segundo'
540
540
  }
541
541
  },
542
+ contextMenu: {
543
+ loadingText: '加载中...'
544
+ },
542
545
  gantt: {
543
546
  tFullFormat: {
544
547
  year: '{yyyy}年',