@vxe-ui/plugin-render-antd 3.0.0 → 3.0.2

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,69 +1,69 @@
1
- import { defineTableRender } from './table'
2
- import { defineFormRender } from './form'
3
-
4
- import type { VxeUIPluginObject, VxeGlobalInterceptorHandles } from 'vxe-pc-ui'
5
-
6
- /**
7
- * 检查触发源是否属于目标节点
8
- */
9
- function getEventTargetNode (evnt: any, container: HTMLElement, className: string) {
10
- let targetElem
11
- let target = evnt.target
12
- while (target && target.nodeType && target !== document) {
13
- if (className && target.className && target.className.split && target.className.split(' ').indexOf(className) > -1) {
14
- targetElem = target
15
- } else if (target === container) {
16
- return { flag: className ? !!targetElem : true, container, targetElem: targetElem }
17
- }
18
- target = target.parentNode
19
- }
20
- return { flag: false }
21
- }
22
-
23
- /**
24
- * 事件兼容性处理
25
- */
26
- function handleClearEvent (params: VxeGlobalInterceptorHandles.InterceptorClearFilterParams | VxeGlobalInterceptorHandles.InterceptorClearEditParams | VxeGlobalInterceptorHandles.InterceptorClearAreasParams) {
27
- const { $event } = params
28
- const bodyElem = document.body
29
- if (
30
- // 下拉框
31
- getEventTargetNode($event, bodyElem, 'ant-select-dropdown').flag ||
32
- // 级联
33
- getEventTargetNode($event, bodyElem, 'ant-cascader-menus').flag ||
34
- // 日期
35
- getEventTargetNode($event, bodyElem, 'ant-picker-dropdown').flag ||
36
- getEventTargetNode($event, bodyElem, 'ant-calendar-picker-container').flag ||
37
- // 时间选择
38
- getEventTargetNode($event, bodyElem, 'ant-time-picker-panel').flag
39
- ) {
40
- return false
41
- }
42
- }
43
-
44
- export const VxeUIPluginRenderAntd: VxeUIPluginObject = {
45
- install (VxeUI, options?: {
46
- Antd?: any
47
- }) {
48
- // 检查版本
49
- if (!/^(3)\./.test(VxeUI.uiVersion)) {
50
- console.error('[plugin-render-antd 3.x] Version 3.x is required')
51
- }
52
-
53
- defineTableRender(VxeUI)
54
- defineFormRender(VxeUI)
55
-
56
- VxeUI.interceptor.add('event.clearFilter', handleClearEvent)
57
- VxeUI.interceptor.add('event.clearEdit', handleClearEvent)
58
- VxeUI.interceptor.add('event.clearAreas', handleClearEvent)
59
-
60
- // 兼容老版本
61
- VxeUI.interceptor.add('event.clearActived', handleClearEvent)
62
- }
63
- }
64
-
65
- if (typeof window !== 'undefined' && window.VxeUI && window.VxeUI.use) {
66
- window.VxeUI.use(VxeUIPluginRenderAntd)
67
- }
68
-
69
- export default VxeUIPluginRenderAntd
1
+ import { defineTableRender } from './table'
2
+ import { defineFormRender } from './form'
3
+
4
+ import type { VxeUIPluginObject, VxeGlobalInterceptorHandles } from 'vxe-pc-ui'
5
+
6
+ /**
7
+ * 检查触发源是否属于目标节点
8
+ */
9
+ function getEventTargetNode (evnt: any, container: HTMLElement, className: string) {
10
+ let targetElem
11
+ let target = evnt.target
12
+ while (target && target.nodeType && target !== document) {
13
+ if (className && target.className && target.className.split && target.className.split(' ').indexOf(className) > -1) {
14
+ targetElem = target
15
+ } else if (target === container) {
16
+ return { flag: className ? !!targetElem : true, container, targetElem: targetElem }
17
+ }
18
+ target = target.parentNode
19
+ }
20
+ return { flag: false }
21
+ }
22
+
23
+ /**
24
+ * 事件兼容性处理
25
+ */
26
+ function handleClearEvent (params: VxeGlobalInterceptorHandles.InterceptorClearFilterParams | VxeGlobalInterceptorHandles.InterceptorClearEditParams | VxeGlobalInterceptorHandles.InterceptorClearAreasParams) {
27
+ const { $event } = params
28
+ const bodyElem = document.body
29
+ if (
30
+ // 下拉框
31
+ getEventTargetNode($event, bodyElem, 'ant-select-dropdown').flag ||
32
+ // 级联
33
+ getEventTargetNode($event, bodyElem, 'ant-cascader-menus').flag ||
34
+ // 日期
35
+ getEventTargetNode($event, bodyElem, 'ant-picker-dropdown').flag ||
36
+ getEventTargetNode($event, bodyElem, 'ant-calendar-picker-container').flag ||
37
+ // 时间选择
38
+ getEventTargetNode($event, bodyElem, 'ant-time-picker-panel').flag
39
+ ) {
40
+ return false
41
+ }
42
+ }
43
+
44
+ export const VxeUIPluginRenderAntd: VxeUIPluginObject = {
45
+ install (VxeUI, options?: {
46
+ Antd?: any
47
+ }) {
48
+ // 检查版本
49
+ if (!/^(3)\./.test(VxeUI.uiVersion)) {
50
+ console.error('[VUE_APP_VXE_PLUGIN_VERSION] Requires VUE_APP_VXE_TABLE_VERSION+ version. VUE_APP_VXE_PLUGIN_DESCRIBE')
51
+ }
52
+
53
+ defineTableRender(VxeUI)
54
+ defineFormRender(VxeUI)
55
+
56
+ VxeUI.interceptor.add('event.clearFilter', handleClearEvent)
57
+ VxeUI.interceptor.add('event.clearEdit', handleClearEvent)
58
+ VxeUI.interceptor.add('event.clearAreas', handleClearEvent)
59
+
60
+ // 兼容老版本
61
+ VxeUI.interceptor.add('event.clearActived', handleClearEvent)
62
+ }
63
+ }
64
+
65
+ if (typeof window !== 'undefined' && window.VxeUI && window.VxeUI.use) {
66
+ window.VxeUI.use(VxeUIPluginRenderAntd)
67
+ }
68
+
69
+ export default VxeUIPluginRenderAntd