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