@vxe-ui/core 0.0.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 +21 -0
- package/README.en.md +31 -0
- package/README.md +31 -0
- package/README.zh-TW.md +31 -0
- package/es/index.esm.js +9 -0
- package/es/language/en-US.d.ts +2 -0
- package/es/language/en-US.js +480 -0
- package/es/language/es-ES.d.ts +2 -0
- package/es/language/es-ES.js +480 -0
- package/es/language/ja-JP.d.ts +2 -0
- package/es/language/ja-JP.js +480 -0
- package/es/language/pt-BR.d.ts +2 -0
- package/es/language/pt-BR.js +480 -0
- package/es/language/zh-CN.d.ts +2 -0
- package/es/language/zh-CN.js +480 -0
- package/es/language/zh-HK.d.ts +2 -0
- package/es/language/zh-HK.js +2 -0
- package/es/language/zh-MO.d.ts +2 -0
- package/es/language/zh-MO.js +2 -0
- package/es/language/zh-TC.d.ts +2 -0
- package/es/language/zh-TC.js +480 -0
- package/es/language/zh-TW.d.ts +2 -0
- package/es/language/zh-TW.js +2 -0
- package/es/src/clipboard.js +35 -0
- package/es/src/commands.js +57 -0
- package/es/src/core.js +71 -0
- package/es/src/event.js +75 -0
- package/es/src/formats.js +57 -0
- package/es/src/globalStore.js +9 -0
- package/es/src/hooks.js +2 -0
- package/es/src/i18n.js +7 -0
- package/es/src/iconStore.js +2 -0
- package/es/src/interceptor.js +41 -0
- package/es/src/log.js +13 -0
- package/es/src/menus.js +57 -0
- package/es/src/renderer.js +46 -0
- package/es/src/resize.js +81 -0
- package/es/src/store.js +48 -0
- package/es/src/theme.js +10 -0
- package/es/src/validators.js +5 -0
- package/lib/index.common.js +29 -0
- package/lib/index.umd.js +2824 -0
- package/lib/index.umd.min.js +1 -0
- package/lib/language/en-US.d.ts +2 -0
- package/lib/language/en-US.js +486 -0
- package/lib/language/en-US.min.js +1 -0
- package/lib/language/en-US.umd.js +500 -0
- package/lib/language/es-ES.d.ts +2 -0
- package/lib/language/es-ES.js +486 -0
- package/lib/language/es-ES.min.js +1 -0
- package/lib/language/es-ES.umd.js +500 -0
- package/lib/language/ja-JP.d.ts +2 -0
- package/lib/language/ja-JP.js +486 -0
- package/lib/language/ja-JP.min.js +1 -0
- package/lib/language/ja-JP.umd.js +500 -0
- package/lib/language/pt-BR.d.ts +2 -0
- package/lib/language/pt-BR.js +486 -0
- package/lib/language/pt-BR.min.js +1 -0
- package/lib/language/pt-BR.umd.js +500 -0
- package/lib/language/zh-CN.d.ts +2 -0
- package/lib/language/zh-CN.js +486 -0
- package/lib/language/zh-CN.min.js +1 -0
- package/lib/language/zh-CN.umd.js +500 -0
- package/lib/language/zh-HK.d.ts +2 -0
- package/lib/language/zh-HK.js +9 -0
- package/lib/language/zh-HK.min.js +1 -0
- package/lib/language/zh-HK.umd.js +500 -0
- package/lib/language/zh-MO.d.ts +2 -0
- package/lib/language/zh-MO.js +9 -0
- package/lib/language/zh-MO.min.js +1 -0
- package/lib/language/zh-MO.umd.js +500 -0
- package/lib/language/zh-TC.d.ts +2 -0
- package/lib/language/zh-TC.js +486 -0
- package/lib/language/zh-TC.min.js +1 -0
- package/lib/language/zh-TC.umd.js +500 -0
- package/lib/language/zh-TW.d.ts +2 -0
- package/lib/language/zh-TW.js +9 -0
- package/lib/language/zh-TW.min.js +1 -0
- package/lib/language/zh-TW.umd.js +500 -0
- package/lib/src/clipboard.js +40 -0
- package/lib/src/clipboard.min.js +1 -0
- package/lib/src/commands.js +66 -0
- package/lib/src/commands.min.js +1 -0
- package/lib/src/core.js +170 -0
- package/lib/src/core.min.js +1 -0
- package/lib/src/event.js +100 -0
- package/lib/src/event.min.js +1 -0
- package/lib/src/formats.js +66 -0
- package/lib/src/formats.min.js +1 -0
- package/lib/src/globalStore.js +15 -0
- package/lib/src/globalStore.min.js +1 -0
- package/lib/src/hooks.js +9 -0
- package/lib/src/hooks.min.js +1 -0
- package/lib/src/i18n.js +14 -0
- package/lib/src/i18n.min.js +1 -0
- package/lib/src/iconStore.js +8 -0
- package/lib/src/iconStore.min.js +1 -0
- package/lib/src/interceptor.js +47 -0
- package/lib/src/interceptor.min.js +1 -0
- package/lib/src/log.js +21 -0
- package/lib/src/log.min.js +1 -0
- package/lib/src/menus.js +66 -0
- package/lib/src/menus.min.js +1 -0
- package/lib/src/renderer.js +52 -0
- package/lib/src/renderer.min.js +1 -0
- package/lib/src/resize.js +96 -0
- package/lib/src/resize.min.js +1 -0
- package/lib/src/store.js +56 -0
- package/lib/src/store.min.js +1 -0
- package/lib/src/theme.js +17 -0
- package/lib/src/theme.min.js +1 -0
- package/lib/src/validators.js +14 -0
- package/lib/src/validators.min.js +1 -0
- package/package.json +75 -0
- package/packages/index.ts +11 -0
- package/packages/language/en-US.ts +482 -0
- package/packages/language/es-ES.ts +482 -0
- package/packages/language/ja-JP.ts +482 -0
- package/packages/language/pt-BR.ts +482 -0
- package/packages/language/zh-CN.ts +482 -0
- package/packages/language/zh-HK.ts +3 -0
- package/packages/language/zh-MO.ts +3 -0
- package/packages/language/zh-TC.ts +482 -0
- package/packages/language/zh-TW.ts +3 -0
- package/packages/src/clipboard.ts +38 -0
- package/packages/src/commands.ts +62 -0
- package/packages/src/core.ts +83 -0
- package/packages/src/event.ts +89 -0
- package/packages/src/formats.ts +62 -0
- package/packages/src/globalStore.ts +13 -0
- package/packages/src/hooks.ts +5 -0
- package/packages/src/i18n.ts +8 -0
- package/packages/src/iconStore.ts +5 -0
- package/packages/src/interceptor.ts +46 -0
- package/packages/src/log.ts +16 -0
- package/packages/src/menus.ts +62 -0
- package/packages/src/renderer.ts +50 -0
- package/packages/src/resize.ts +85 -0
- package/packages/src/store.ts +49 -0
- package/packages/src/theme.ts +13 -0
- package/packages/src/validators.ts +9 -0
- package/types/core/clipboard.d.ts +6 -0
- package/types/core/commands.d.ts +25 -0
- package/types/core/formats.d.ts +23 -0
- package/types/core/global-config.d.ts +14 -0
- package/types/core/global-icon.d.ts +4 -0
- package/types/core/hooks.d.ts +14 -0
- package/types/core/index.d.ts +115 -0
- package/types/core/interceptor.d.ts +18 -0
- package/types/core/menus.d.ts +25 -0
- package/types/core/renderer.d.ts +26 -0
- package/types/core/validators.d.ts +22 -0
- package/types/index.d.ts +10 -0
- package/types/tool/common.d.ts +61 -0
- package/types/tool/index.d.ts +2 -0
- package/types/tool/util.d.ts +4 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
|
|
3
|
+
import { VxeComponentBase } from '../../types'
|
|
4
|
+
|
|
5
|
+
export const EVENT_KEYS = {
|
|
6
|
+
F2: 'F2',
|
|
7
|
+
ESCAPE: 'Escape',
|
|
8
|
+
ENTER: 'Enter',
|
|
9
|
+
TAB: 'Tab',
|
|
10
|
+
DELETE: 'Delete',
|
|
11
|
+
BACKSPACE: 'Backspace',
|
|
12
|
+
SPACEBAR: ' ',
|
|
13
|
+
CONTEXT_MENU: 'ContextMenu',
|
|
14
|
+
ARROW_UP: 'ArrowUp',
|
|
15
|
+
ARROW_DOWN: 'ArrowDown',
|
|
16
|
+
ARROW_LEFT: 'ArrowLeft',
|
|
17
|
+
ARROW_RIGHT: 'ArrowRight',
|
|
18
|
+
PAGE_UP: 'PageUp',
|
|
19
|
+
PAGE_DOWN: 'PageDown'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const browse = XEUtils.browse()
|
|
23
|
+
|
|
24
|
+
const convertEventKeys: { [key: string]: string } = {
|
|
25
|
+
' ': 'Spacebar',
|
|
26
|
+
Apps: EVENT_KEYS.CONTEXT_MENU,
|
|
27
|
+
Del: EVENT_KEYS.DELETE,
|
|
28
|
+
Up: EVENT_KEYS.ARROW_UP,
|
|
29
|
+
Down: EVENT_KEYS.ARROW_DOWN,
|
|
30
|
+
Left: EVENT_KEYS.ARROW_LEFT,
|
|
31
|
+
Right: EVENT_KEYS.ARROW_RIGHT
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 监听全局事件
|
|
35
|
+
const wheelName = browse.firefox ? 'DOMMouseScroll' : 'mousewheel'
|
|
36
|
+
const eventStore: {
|
|
37
|
+
comp: VxeComponentBase;
|
|
38
|
+
type: string;
|
|
39
|
+
cb: (evnt: Event) => void;
|
|
40
|
+
}[] = []
|
|
41
|
+
|
|
42
|
+
export const hasEventKey = (evnt: KeyboardEvent, targetKey: string) => {
|
|
43
|
+
const { key } = evnt
|
|
44
|
+
targetKey = targetKey.toLowerCase()
|
|
45
|
+
return key ? (targetKey === key.toLowerCase() || !!(convertEventKeys[key] && convertEventKeys[key].toLowerCase() === targetKey)) : false
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function triggerEvent (evnt: Event) {
|
|
49
|
+
const isWheel = evnt.type === wheelName
|
|
50
|
+
eventStore.forEach(({ type, cb }) => {
|
|
51
|
+
// 如果被取消冒泡,不再执行
|
|
52
|
+
if (!evnt.cancelBubble) {
|
|
53
|
+
if (type === evnt.type || (isWheel && type === 'mousewheel')) {
|
|
54
|
+
cb(evnt)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const GlobalEvent = {
|
|
61
|
+
on (comp: VxeComponentBase, type: string, cb: (evnt: any) => void) {
|
|
62
|
+
eventStore.push({ comp, type, cb })
|
|
63
|
+
},
|
|
64
|
+
off (comp: VxeComponentBase, type: string) {
|
|
65
|
+
XEUtils.remove(eventStore, item => item.comp === comp && item.type === type)
|
|
66
|
+
},
|
|
67
|
+
trigger: triggerEvent,
|
|
68
|
+
eqKeypad (evnt: KeyboardEvent, keyVal: string) {
|
|
69
|
+
const { key } = evnt
|
|
70
|
+
if (keyVal.toLowerCase() === key.toLowerCase()) {
|
|
71
|
+
return true
|
|
72
|
+
}
|
|
73
|
+
return false
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (browse.isDoc) {
|
|
78
|
+
if (!browse.msie) {
|
|
79
|
+
window.addEventListener('copy', triggerEvent, false)
|
|
80
|
+
window.addEventListener('cut', triggerEvent, false)
|
|
81
|
+
window.addEventListener('paste', triggerEvent, false)
|
|
82
|
+
}
|
|
83
|
+
document.addEventListener('keydown', triggerEvent, false)
|
|
84
|
+
document.addEventListener('contextmenu', triggerEvent, false)
|
|
85
|
+
window.addEventListener('mousedown', triggerEvent, false)
|
|
86
|
+
window.addEventListener('blur', triggerEvent, false)
|
|
87
|
+
window.addEventListener('resize', triggerEvent, false)
|
|
88
|
+
window.addEventListener(wheelName, XEUtils.throttle(triggerEvent, 100, { leading: true, trailing: false }), { passive: true, capture: false })
|
|
89
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
import { warnLog } from './log'
|
|
3
|
+
|
|
4
|
+
import { VxeGlobalFormats } from '../../types'
|
|
5
|
+
|
|
6
|
+
class VXEFormatsStore {
|
|
7
|
+
private store: any = {}
|
|
8
|
+
|
|
9
|
+
mixin (options: any): VXEFormatsStore {
|
|
10
|
+
XEUtils.each(options, (item, key) => {
|
|
11
|
+
this.add(key, item)
|
|
12
|
+
})
|
|
13
|
+
return this
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
has (name: string): boolean {
|
|
17
|
+
return !!this.get(name)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get (name: string): any {
|
|
21
|
+
return this.store[name]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
add (name: string, render: any): VXEFormatsStore {
|
|
25
|
+
const conf = this.store[name]
|
|
26
|
+
// 兼容
|
|
27
|
+
if (XEUtils.isFunction(render)) {
|
|
28
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
29
|
+
warnLog('vxe.error.delProp', ['formats -> callback', 'cellFormatMethod'])
|
|
30
|
+
}
|
|
31
|
+
render = {
|
|
32
|
+
cellFormatMethod: render
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// 检测是否覆盖
|
|
37
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
38
|
+
const confKeys = XEUtils.keys(conf)
|
|
39
|
+
XEUtils.each(render, (item, key) => {
|
|
40
|
+
if (confKeys.includes(key)) {
|
|
41
|
+
warnLog('vxe.error.coverProp', [name, key])
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
this.store[name] = conf ? XEUtils.merge(conf, render) : render
|
|
46
|
+
return this
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
delete (name: string): void {
|
|
50
|
+
delete this.store[name]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
forEach (callback: any): void {
|
|
54
|
+
XEUtils.objectEach(this.store, callback)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const formats = new VXEFormatsStore() as VxeGlobalFormats
|
|
59
|
+
|
|
60
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
61
|
+
Object.assign(formats, { _name: 'Formats' })
|
|
62
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { VxeGlobalConfig } from '../../types'
|
|
2
|
+
|
|
3
|
+
const globalConfigStore: Required<VxeGlobalConfig> = {
|
|
4
|
+
size: '',
|
|
5
|
+
theme: '',
|
|
6
|
+
version: 1,
|
|
7
|
+
zIndex: 999,
|
|
8
|
+
resizeInterval: 500,
|
|
9
|
+
|
|
10
|
+
i18n: (key: string) => key
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default globalConfigStore
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
import { warnLog } from './log'
|
|
3
|
+
|
|
4
|
+
import { VxeGlobalInterceptor, VxeGlobalInterceptorHandles } from '../../types'
|
|
5
|
+
|
|
6
|
+
const storeMap: { [type: string]: VxeGlobalInterceptorHandles.InterceptorCallback[] } = {}
|
|
7
|
+
|
|
8
|
+
export const interceptor: VxeGlobalInterceptor = {
|
|
9
|
+
mixin (options) {
|
|
10
|
+
XEUtils.each(options, (callback: VxeGlobalInterceptorHandles.InterceptorCallback, type) => {
|
|
11
|
+
interceptor.add(type, callback)
|
|
12
|
+
})
|
|
13
|
+
return interceptor
|
|
14
|
+
},
|
|
15
|
+
get (type) {
|
|
16
|
+
return storeMap[type] || []
|
|
17
|
+
},
|
|
18
|
+
add (type, callback) {
|
|
19
|
+
if (callback) {
|
|
20
|
+
let eList = storeMap[type]
|
|
21
|
+
if (!eList) {
|
|
22
|
+
eList = storeMap[type] = []
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 检测重复
|
|
26
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
27
|
+
if (eList.indexOf(callback) > -1) {
|
|
28
|
+
warnLog('vxe.error.coverProp', ['Interceptor', type])
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
eList.push(callback)
|
|
33
|
+
}
|
|
34
|
+
return interceptor
|
|
35
|
+
},
|
|
36
|
+
delete (type, callback) {
|
|
37
|
+
const eList = storeMap[type]
|
|
38
|
+
if (eList) {
|
|
39
|
+
if (callback) {
|
|
40
|
+
XEUtils.remove(eList, fn => fn === callback)
|
|
41
|
+
} else {
|
|
42
|
+
delete storeMap[type]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getI18n } from './i18n'
|
|
2
|
+
|
|
3
|
+
export function getLog (message: string, params?: any) {
|
|
4
|
+
return `[vxe-table v${process.env.VUE_APP_VXE_TABLE_VERSION}] ${getI18n(message, params)}`
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function outLog (type: 'log' | 'warn' | 'error') {
|
|
8
|
+
return function (message: string, params?: any) {
|
|
9
|
+
const msg = getLog(message, params)
|
|
10
|
+
console[type](msg)
|
|
11
|
+
return msg
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const warnLog = outLog('warn')
|
|
16
|
+
export const errLog = outLog('error')
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
import { warnLog } from './log'
|
|
3
|
+
|
|
4
|
+
import { VxeGlobalMenus } from '../../types'
|
|
5
|
+
|
|
6
|
+
class VXEMenusStore {
|
|
7
|
+
private store: any = {}
|
|
8
|
+
|
|
9
|
+
mixin (options: any): VXEMenusStore {
|
|
10
|
+
XEUtils.each(options, (item, key) => {
|
|
11
|
+
this.add(key, item)
|
|
12
|
+
})
|
|
13
|
+
return this
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
has (name: string): boolean {
|
|
17
|
+
return !!this.get(name)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get (name: string): any {
|
|
21
|
+
return this.store[name]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
add (name: string, render: any): VXEMenusStore {
|
|
25
|
+
const conf = this.store[name]
|
|
26
|
+
// 兼容
|
|
27
|
+
if (XEUtils.isFunction(render)) {
|
|
28
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
29
|
+
warnLog('vxe.error.delProp', ['menus -> callback', 'menuMethod'])
|
|
30
|
+
}
|
|
31
|
+
render = {
|
|
32
|
+
menuMethod: render
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// 检测是否覆盖
|
|
37
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
38
|
+
const confKeys = XEUtils.keys(conf)
|
|
39
|
+
XEUtils.each(render, (item, key) => {
|
|
40
|
+
if (confKeys.includes(key)) {
|
|
41
|
+
warnLog('vxe.error.coverProp', [name, key])
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
this.store[name] = conf ? XEUtils.merge(conf, render) : render
|
|
46
|
+
return this
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
delete (name: string): void {
|
|
50
|
+
delete this.store[name]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
forEach (callback: any): void {
|
|
54
|
+
XEUtils.objectEach(this.store, callback)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const menus = new VXEMenusStore() as VxeGlobalMenus
|
|
59
|
+
|
|
60
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
61
|
+
Object.assign(menus, { _name: 'Menus' })
|
|
62
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
import { warnLog } from './log'
|
|
3
|
+
|
|
4
|
+
import { VxeGlobalRenderer, RendererOptions } from '../../types'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 内置的组件渲染
|
|
8
|
+
*/
|
|
9
|
+
const renderMap: Record<string, RendererOptions> = {}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 全局渲染器
|
|
13
|
+
*/
|
|
14
|
+
export const renderer: VxeGlobalRenderer = {
|
|
15
|
+
mixin (opts) {
|
|
16
|
+
XEUtils.each(opts, (options, name) => renderer.add(name, options))
|
|
17
|
+
return renderer
|
|
18
|
+
},
|
|
19
|
+
get (name: string) {
|
|
20
|
+
return renderMap[name] || null
|
|
21
|
+
},
|
|
22
|
+
add (name, options) {
|
|
23
|
+
if (name && options) {
|
|
24
|
+
const renders: any = renderMap[name]
|
|
25
|
+
if (renders) {
|
|
26
|
+
// 检测是否覆盖
|
|
27
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
28
|
+
XEUtils.each(options, (val, key) => {
|
|
29
|
+
if (!XEUtils.eqNull(renders[key]) && renders[key] !== val) {
|
|
30
|
+
warnLog('vxe.error.coverProp', [`Renderer.${name}`, key])
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Object.assign(renders, options)
|
|
36
|
+
} else {
|
|
37
|
+
renderMap[name] = options
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return renderer
|
|
41
|
+
},
|
|
42
|
+
forEach (callback) {
|
|
43
|
+
XEUtils.objectEach(renderMap, callback)
|
|
44
|
+
return renderer
|
|
45
|
+
},
|
|
46
|
+
delete (name) {
|
|
47
|
+
delete renderMap[name]
|
|
48
|
+
return renderer
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
import globalConfigStore from './globalStore'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 监听 resize 事件
|
|
6
|
+
* 如果项目中已使用了 resize-observer-polyfill,那么只需要将方法定义全局,该组件就会自动使用
|
|
7
|
+
*/
|
|
8
|
+
let resizeTimeout: any
|
|
9
|
+
/* eslint-disable no-use-before-define */
|
|
10
|
+
const eventStore: XEResizeObserver[] = []
|
|
11
|
+
const defaultInterval = 500
|
|
12
|
+
|
|
13
|
+
function eventHandle () {
|
|
14
|
+
if (eventStore.length) {
|
|
15
|
+
eventStore.forEach((item) => {
|
|
16
|
+
item.tarList.forEach((observer) => {
|
|
17
|
+
const { target, width, heighe } = observer
|
|
18
|
+
const clientWidth = target.clientWidth
|
|
19
|
+
const clientHeight = target.clientHeight
|
|
20
|
+
const rWidth = clientWidth && width !== clientWidth
|
|
21
|
+
const rHeight = clientHeight && heighe !== clientHeight
|
|
22
|
+
if (rWidth || rHeight) {
|
|
23
|
+
observer.width = clientWidth
|
|
24
|
+
observer.heighe = clientHeight
|
|
25
|
+
setTimeout(item.callback)
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
30
|
+
eventListener()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function eventListener () {
|
|
35
|
+
clearTimeout(resizeTimeout)
|
|
36
|
+
resizeTimeout = setTimeout(eventHandle, globalConfigStore.resizeInterval || defaultInterval)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class XEResizeObserver {
|
|
40
|
+
tarList: {
|
|
41
|
+
target: Element;
|
|
42
|
+
width: number;
|
|
43
|
+
heighe: number;
|
|
44
|
+
}[] = []
|
|
45
|
+
|
|
46
|
+
callback: (...args: any[]) => void
|
|
47
|
+
|
|
48
|
+
constructor (callback: (...args: any[]) => void) {
|
|
49
|
+
this.callback = callback
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
observe (target: Element): void {
|
|
53
|
+
if (target) {
|
|
54
|
+
const { tarList } = this
|
|
55
|
+
if (!tarList.some(observer => observer.target === target)) {
|
|
56
|
+
tarList.push({
|
|
57
|
+
target,
|
|
58
|
+
width: target.clientWidth,
|
|
59
|
+
heighe: target.clientHeight
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
if (!eventStore.length) {
|
|
63
|
+
eventListener()
|
|
64
|
+
}
|
|
65
|
+
if (!eventStore.some((item) => item === this)) {
|
|
66
|
+
eventStore.push(this)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
unobserve (target: Element): void {
|
|
72
|
+
XEUtils.remove(eventStore, item => item.tarList.some(observer => observer.target === target))
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
disconnect (): void {
|
|
76
|
+
XEUtils.remove(eventStore, item => item === this)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function createResizeEvent (callback: (...args: any[]) => void): any {
|
|
81
|
+
if (window.ResizeObserver) {
|
|
82
|
+
return new window.ResizeObserver(callback)
|
|
83
|
+
}
|
|
84
|
+
return new XEResizeObserver(callback)
|
|
85
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { warnLog } from './log'
|
|
2
|
+
import XEUtils from 'xe-utils'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 创建数据仓库
|
|
6
|
+
*/
|
|
7
|
+
export class Store {
|
|
8
|
+
private store: any = {}
|
|
9
|
+
|
|
10
|
+
mixin (options: any): Store {
|
|
11
|
+
XEUtils.each(options, (item, key) => {
|
|
12
|
+
this.add(key, item)
|
|
13
|
+
})
|
|
14
|
+
return this
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
has (name: string): boolean {
|
|
18
|
+
return !!this.get(name)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get (name: string): any {
|
|
22
|
+
return this.store[name]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
add (name: string, options: any): Store {
|
|
26
|
+
const conf = this.store[name]
|
|
27
|
+
// 检测是否覆盖
|
|
28
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
29
|
+
const confKeys = XEUtils.keys(conf)
|
|
30
|
+
XEUtils.each(options, (item, key) => {
|
|
31
|
+
if (confKeys.includes(key)) {
|
|
32
|
+
warnLog('vxe.error.coverProp', [name, key])
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
this.store[name] = conf ? XEUtils.merge(conf, options) : options
|
|
37
|
+
return this
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
delete (name: string): void {
|
|
41
|
+
delete this.store[name]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
forEach (callback: any): void {
|
|
45
|
+
XEUtils.objectEach(this.store, callback)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default Store
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import globalConfigStore from './globalStore'
|
|
2
|
+
|
|
3
|
+
import { VxeGlobalConfig } from '../../types'
|
|
4
|
+
|
|
5
|
+
export default function setTheme (options?: VxeGlobalConfig) {
|
|
6
|
+
const theme = (options ? options.theme : null) || globalConfigStore.theme || 'default'
|
|
7
|
+
if (typeof document !== 'undefined') {
|
|
8
|
+
const documentElement = document.documentElement
|
|
9
|
+
if (documentElement) {
|
|
10
|
+
documentElement.setAttribute('data-vxe-theme', theme)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import VXEStore from './store'
|
|
2
|
+
|
|
3
|
+
import { VxeGlobalValidators } from '../../types'
|
|
4
|
+
|
|
5
|
+
export const validators = new VXEStore() as VxeGlobalValidators
|
|
6
|
+
|
|
7
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
8
|
+
Object.assign(validators, { _name: 'Validators' })
|
|
9
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* eslint-disable no-use-before-define */
|
|
2
|
+
|
|
3
|
+
export namespace VxeGlobalCommandsHandles {
|
|
4
|
+
export interface CommandsOptions {
|
|
5
|
+
commandMethod?: (params: CommandMethodParams, ...args: any[]) => void
|
|
6
|
+
}
|
|
7
|
+
export interface CommandMethodParams {
|
|
8
|
+
code: string
|
|
9
|
+
button?: any
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 全局格式化
|
|
15
|
+
*/
|
|
16
|
+
export interface VxeGlobalCommands {
|
|
17
|
+
mixin(opts: {
|
|
18
|
+
[name: string]: VxeGlobalCommandsHandles.CommandsOptions | ((params: VxeGlobalCommandsHandles.CommandMethodParams, ...args: any[]) => void)
|
|
19
|
+
}): VxeGlobalCommands
|
|
20
|
+
has(name: string): boolean
|
|
21
|
+
get(name: string): VxeGlobalCommandsHandles.CommandsOptions
|
|
22
|
+
add(name: string, options: VxeGlobalCommandsHandles.CommandsOptions | ((params: VxeGlobalCommandsHandles.CommandMethodParams, ...args: any[]) => void)): VxeGlobalCommands
|
|
23
|
+
delete(name: string): void
|
|
24
|
+
forEach(callback: (options: VxeGlobalCommandsHandles.CommandsOptions, name: string) => void): void
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* eslint-disable no-use-before-define */
|
|
2
|
+
|
|
3
|
+
export namespace VxeGlobalFormatsHandles {
|
|
4
|
+
export interface FormatsOptions {
|
|
5
|
+
cellFormatMethod?: (params: FormatMethodParams, ...args: any[]) => string | number
|
|
6
|
+
}
|
|
7
|
+
export interface FormatMethodParams {
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 全局格式化
|
|
13
|
+
*/
|
|
14
|
+
export interface VxeGlobalFormats {
|
|
15
|
+
mixin(opts: {
|
|
16
|
+
[name: string]: VxeGlobalFormatsHandles.FormatsOptions | ((params: VxeGlobalFormatsHandles.FormatMethodParams, ...args: any[]) => string | number)
|
|
17
|
+
}): VxeGlobalFormats
|
|
18
|
+
has(name: string): boolean
|
|
19
|
+
get(name: string): VxeGlobalFormatsHandles.FormatsOptions
|
|
20
|
+
add(name: string, options: VxeGlobalFormatsHandles.FormatsOptions | ((params: VxeGlobalFormatsHandles.FormatMethodParams, ...args: any[]) => string | number)): VxeGlobalFormats
|
|
21
|
+
delete(name: string): void
|
|
22
|
+
forEach(callback: (options: VxeGlobalFormatsHandles.FormatsOptions, name: string) => void): void
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { VxeComponentSize } from '../tool'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 全局参数对象
|
|
5
|
+
*/
|
|
6
|
+
export interface VxeGlobalConfig {
|
|
7
|
+
zIndex?: number
|
|
8
|
+
size?: VxeComponentSize
|
|
9
|
+
version?: string | number
|
|
10
|
+
theme?: null | '' | 'default' | 'dark'
|
|
11
|
+
resizeInterval?: number
|
|
12
|
+
|
|
13
|
+
i18n?(key: string, args?: any): string
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export namespace VxeGlobalHooksHandles {
|
|
2
|
+
export interface HookOptions {}
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface VxeGlobalHooks {
|
|
6
|
+
mixin(options: {
|
|
7
|
+
[type: string]: VxeGlobalHooksHandles.HookOptions
|
|
8
|
+
}): VxeGlobalHooks
|
|
9
|
+
has(type: string): boolean
|
|
10
|
+
get(type: string): VxeGlobalHooksHandles.HookOptions
|
|
11
|
+
add(type: string, options: VxeGlobalHooksHandles.HookOptions): VxeGlobalHooks
|
|
12
|
+
delete(type: string): void
|
|
13
|
+
forEach(callback: (options: VxeGlobalHooksHandles.HookOptions, type: string) => void): void
|
|
14
|
+
}
|