@vxe-ui/plugin-render-antd 3.3.0 → 3.4.0

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/src/index.ts CHANGED
@@ -1,109 +1,109 @@
1
- import { defineTableRender } from './table'
2
- import { defineFormRender } from './form'
3
- import { componentMaps } from './store'
4
- import XEUtils from 'xe-utils'
5
-
6
- import type { VxeUIPluginObject, VxeGlobalInterceptorHandles } from 'vxe-pc-ui'
7
- import type { VxeUIPluginRenderAntdOptions } from '../types'
8
-
9
- function getEventTarget (evnt: Event) {
10
- const target = evnt.target as HTMLElement | null
11
- if (target && (target as any).shadowRoot && evnt.composed) {
12
- return evnt.composedPath()[0] as HTMLElement || target
13
- }
14
- return target
15
- }
16
-
17
- /**
18
- * 检查触发源是否属于目标节点
19
- */
20
- function getEventTargetNode (evnt: any, container: HTMLElement, className: string) {
21
- let targetElem
22
- let target = getEventTarget(evnt)
23
- const rootEl = document.documentElement || document.querySelector('html')
24
- while (target && target.nodeType && target !== rootEl) {
25
- if (className && target.className && target.className.split && target.className.split(' ').indexOf(className) > -1) {
26
- targetElem = target
27
- } else if (target === container) {
28
- return { flag: className ? !!targetElem : true, container, targetElem: targetElem }
29
- }
30
- target = target.parentElement
31
- }
32
- return { flag: false }
33
- }
34
-
35
- function toComponentName (name: string) {
36
- if (name) {
37
- return name.slice(0, 1).toUpperCase() + name.slice(1)
38
- }
39
- return name
40
- }
41
-
42
- export const VxeUIPluginRenderAntd: VxeUIPluginObject = {
43
- component (comp: any) {
44
- if (comp && comp.name) {
45
- const kcName = XEUtils.kebabCase(comp.name)
46
- const ccName = toComponentName(XEUtils.camelCase(comp.name))
47
- componentMaps[kcName] = comp
48
- componentMaps[ccName] = comp
49
- } else {
50
- console.error('[VUE_APP_VXE_PLUGIN_VERSION] error component.', comp)
51
- }
52
- },
53
- install (VxeUI, options?: VxeUIPluginRenderAntdOptions) {
54
- const pluginOpts = Object.assign({}, options)
55
-
56
- // 检查版本
57
- if (VxeUI.checkVersion) {
58
- const pVersion = 3
59
- const sVersion = 13
60
- if (!VxeUI.checkVersion(VxeUI.tableVersion, pVersion, sVersion)) {
61
- console.error(`[VUE_APP_VXE_PLUGIN_VERSION] ${VxeUI.getI18n('vxe.error.errorVersion', [`vxe-table@${VxeUI.tableVersion || '?'}`, `vxe-table v${pVersion}.${sVersion}+`])}`)
62
- }
63
- } else {
64
- if (!/^(3)\./.test(VxeUI.uiVersion || VxeUI.tableVersion)) {
65
- console.error('[VUE_APP_VXE_PLUGIN_VERSION] Requires VUE_APP_VXE_TABLE_VERSION+ version. VUE_APP_VXE_PLUGIN_DESCRIBE')
66
- }
67
- }
68
-
69
- /**
70
- * 事件兼容性处理
71
- */
72
- const handleClearEvent = (params: VxeGlobalInterceptorHandles.InterceptorClearFilterParams | VxeGlobalInterceptorHandles.InterceptorClearEditParams | VxeGlobalInterceptorHandles.InterceptorClearAreasParams) => {
73
- const { $event } = params
74
- const bodyElem = document.body
75
- const prefixCls = `${pluginOpts.prefixCls || 'ant'}`.replace(/-$/, '')
76
- if (
77
- // 下拉框
78
- getEventTargetNode($event, bodyElem, `${prefixCls}-select-dropdown`).flag ||
79
- // 级联
80
- getEventTargetNode($event, bodyElem, `${prefixCls}-cascader-menus`).flag ||
81
- // 日期
82
- getEventTargetNode($event, bodyElem, `${prefixCls}-picker-dropdown`).flag ||
83
- getEventTargetNode($event, bodyElem, `${prefixCls}-calendar-picker-container`).flag ||
84
- // 时间选择
85
- getEventTargetNode($event, bodyElem, `${prefixCls}-time-picker-panel`).flag
86
- ) {
87
- return false
88
- }
89
- }
90
-
91
- defineTableRender(VxeUI)
92
- defineFormRender(VxeUI)
93
-
94
- VxeUI.interceptor.add('event.clearFilter', handleClearEvent)
95
- VxeUI.interceptor.add('event.clearEdit', handleClearEvent)
96
- VxeUI.interceptor.add('event.clearAreas', handleClearEvent)
97
-
98
- // 兼容老版本
99
- VxeUI.interceptor.add('event.clearActived', handleClearEvent)
100
- }
101
- }
102
-
103
- if (typeof window !== 'undefined') {
104
- if (window.VxeUI && window.VxeUI.use) {
105
- window.VxeUI.use(VxeUIPluginRenderAntd)
106
- }
107
- }
108
-
109
- export default VxeUIPluginRenderAntd
1
+ import { defineTableRender } from './table'
2
+ import { defineFormRender } from './form'
3
+ import { componentMaps } from './store'
4
+ import XEUtils from 'xe-utils'
5
+
6
+ import type { VxeUIPluginObject, VxeGlobalInterceptorHandles } from 'vxe-pc-ui'
7
+ import type { VxeUIPluginRenderAntdOptions } from '../types'
8
+
9
+ function getEventTarget (evnt: Event) {
10
+ const target = evnt.target as HTMLElement | null
11
+ if (target && (target as any).shadowRoot && evnt.composed) {
12
+ return evnt.composedPath()[0] as HTMLElement || target
13
+ }
14
+ return target
15
+ }
16
+
17
+ /**
18
+ * 检查触发源是否属于目标节点
19
+ */
20
+ function getEventTargetNode (evnt: any, container: HTMLElement, className: string) {
21
+ let targetElem
22
+ let target = getEventTarget(evnt)
23
+ const rootEl = document.documentElement || document.querySelector('html')
24
+ while (target && target.nodeType && target !== rootEl) {
25
+ if (className && target.className && target.className.split && target.className.split(' ').indexOf(className) > -1) {
26
+ targetElem = target
27
+ } else if (target === container) {
28
+ return { flag: className ? !!targetElem : true, container, targetElem: targetElem }
29
+ }
30
+ target = target.parentElement
31
+ }
32
+ return { flag: false }
33
+ }
34
+
35
+ function toComponentName (name: string) {
36
+ if (name) {
37
+ return name.slice(0, 1).toUpperCase() + name.slice(1)
38
+ }
39
+ return name
40
+ }
41
+
42
+ export const VxeUIPluginRenderAntd: VxeUIPluginObject = {
43
+ component (comp: any) {
44
+ if (comp && comp.name) {
45
+ const kcName = XEUtils.kebabCase(comp.name)
46
+ const ccName = toComponentName(XEUtils.camelCase(comp.name))
47
+ componentMaps[kcName] = comp
48
+ componentMaps[ccName] = comp
49
+ } else {
50
+ console.error('[VUE_APP_VXE_PLUGIN_VERSION] error component.', comp)
51
+ }
52
+ },
53
+ install (VxeUI, options?: VxeUIPluginRenderAntdOptions) {
54
+ const pluginOpts = Object.assign({}, options)
55
+
56
+ // 检查版本
57
+ if (VxeUI.checkVersion) {
58
+ const pVersion = 3
59
+ const sVersion = 13
60
+ if (!VxeUI.checkVersion(VxeUI.tableVersion, pVersion, sVersion)) {
61
+ console.error(`[VUE_APP_VXE_PLUGIN_VERSION] ${VxeUI.getI18n('vxe.error.errorVersion', [`vxe-table@${VxeUI.tableVersion || '?'}`, `vxe-table v${pVersion}.${sVersion}+`])}`)
62
+ }
63
+ } else {
64
+ if (!/^(3)\./.test(VxeUI.uiVersion || VxeUI.tableVersion)) {
65
+ console.error('[VUE_APP_VXE_PLUGIN_VERSION] Requires VUE_APP_VXE_TABLE_VERSION+ version. VUE_APP_VXE_PLUGIN_DESCRIBE')
66
+ }
67
+ }
68
+
69
+ /**
70
+ * 事件兼容性处理
71
+ */
72
+ const handleClearEvent = (params: VxeGlobalInterceptorHandles.InterceptorClearFilterParams | VxeGlobalInterceptorHandles.InterceptorClearEditParams | VxeGlobalInterceptorHandles.InterceptorClearAreasParams) => {
73
+ const { $event } = params
74
+ const bodyElem = document.body
75
+ const prefixCls = `${pluginOpts.prefixCls || 'ant'}`.replace(/-$/, '')
76
+ if (
77
+ // 下拉框
78
+ getEventTargetNode($event, bodyElem, `${prefixCls}-select-dropdown`).flag ||
79
+ // 级联
80
+ getEventTargetNode($event, bodyElem, `${prefixCls}-cascader-menus`).flag ||
81
+ // 日期
82
+ getEventTargetNode($event, bodyElem, `${prefixCls}-picker-dropdown`).flag ||
83
+ getEventTargetNode($event, bodyElem, `${prefixCls}-calendar-picker-container`).flag ||
84
+ // 时间选择
85
+ getEventTargetNode($event, bodyElem, `${prefixCls}-time-picker-panel`).flag
86
+ ) {
87
+ return false
88
+ }
89
+ }
90
+
91
+ defineTableRender(VxeUI)
92
+ defineFormRender(VxeUI)
93
+
94
+ VxeUI.interceptor.add('event.clearFilter', handleClearEvent)
95
+ VxeUI.interceptor.add('event.clearEdit', handleClearEvent)
96
+ VxeUI.interceptor.add('event.clearAreas', handleClearEvent)
97
+
98
+ // 兼容老版本
99
+ VxeUI.interceptor.add('event.clearActived', handleClearEvent)
100
+ }
101
+ }
102
+
103
+ if (typeof window !== 'undefined') {
104
+ if (window.VxeUI && window.VxeUI.use) {
105
+ window.VxeUI.use(VxeUIPluginRenderAntd)
106
+ }
107
+ }
108
+
109
+ export default VxeUIPluginRenderAntd
@@ -1,3 +1,3 @@
1
- import type { ComponentOptions } from 'vue'
2
-
3
- export const componentMaps: Record<string, ComponentOptions<any>> = {}
1
+ import type { ComponentOptions } from 'vue'
2
+
3
+ export const componentMaps: Record<string, ComponentOptions<any>> = {}