@vxe-ui/core 4.4.12 → 4.4.14

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 (64) hide show
  1. package/LICENSE +21 -21
  2. package/README.en.md +43 -43
  3. package/README.md +43 -43
  4. package/README.zh-TW.md +43 -43
  5. package/dist/all.esm.js +920 -0
  6. package/es/src/core.js +1 -1
  7. package/es/src/log.js +1 -1
  8. package/lib/index.umd.js +173 -73
  9. package/lib/index.umd.min.js +1 -1
  10. package/lib/src/core.js +1 -1
  11. package/lib/src/core.min.js +1 -1
  12. package/lib/src/log.js +1 -1
  13. package/lib/src/log.min.js +1 -1
  14. package/package.json +82 -79
  15. package/packages/index.ts +149 -149
  16. package/packages/src/clipboard.ts +56 -56
  17. package/packages/src/commands.ts +56 -56
  18. package/packages/src/config.ts +30 -30
  19. package/packages/src/configStore.ts +8 -8
  20. package/packages/src/core.ts +11 -11
  21. package/packages/src/dataStore.ts +4 -4
  22. package/packages/src/event.ts +160 -160
  23. package/packages/src/formats.ts +56 -56
  24. package/packages/src/hooks.ts +5 -5
  25. package/packages/src/i18n.ts +63 -63
  26. package/packages/src/i18nStore.ts +11 -11
  27. package/packages/src/icon.ts +32 -32
  28. package/packages/src/iconStore.ts +3 -3
  29. package/packages/src/interceptor.ts +64 -64
  30. package/packages/src/log.ts +19 -19
  31. package/packages/src/menus.ts +56 -56
  32. package/packages/src/permission.ts +61 -61
  33. package/packages/src/renderer.ts +48 -48
  34. package/packages/src/resize.ts +89 -89
  35. package/packages/src/store.ts +47 -47
  36. package/packages/src/theme.ts +20 -20
  37. package/packages/src/themeStore.ts +7 -7
  38. package/packages/src/useFns.ts +34 -34
  39. package/packages/src/validators.ts +7 -7
  40. package/packages/src/vm.ts +10 -10
  41. package/types/core/clipboard.d.ts +22 -22
  42. package/types/core/commands.d.ts +19 -19
  43. package/types/core/components.d.ts +5 -5
  44. package/types/core/formats.d.ts +19 -19
  45. package/types/core/global-config.d.ts +70 -70
  46. package/types/core/global-data.d.ts +7 -7
  47. package/types/core/global-event.d.ts +47 -47
  48. package/types/core/global-icon.d.ts +10 -10
  49. package/types/core/global-lang.d.ts +27 -27
  50. package/types/core/global-resize.d.ts +3 -3
  51. package/types/core/global-theme.d.ts +1 -1
  52. package/types/core/hooks.d.ts +14 -14
  53. package/types/core/index.d.ts +294 -294
  54. package/types/core/interceptor.d.ts +22 -22
  55. package/types/core/log.d.ts +8 -8
  56. package/types/core/menus.d.ts +19 -19
  57. package/types/core/permission.d.ts +10 -10
  58. package/types/core/renderer.d.ts +14 -14
  59. package/types/core/useFn.d.ts +27 -27
  60. package/types/core/validators.d.ts +19 -19
  61. package/types/index.d.ts +13 -13
  62. package/types/tool/common.d.ts +150 -150
  63. package/types/tool/index.d.ts +2 -2
  64. package/types/tool/util.d.ts +4 -4
@@ -1,56 +1,56 @@
1
- import XEUtils from 'xe-utils'
2
- import { log } from './log'
3
-
4
- import { VxeGlobalCommands } from '../../types'
5
-
6
- class VXECommandsStore {
7
- private store: any = {}
8
-
9
- mixin (options: any): VXECommandsStore {
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): VXECommandsStore {
25
- const conf = this.store[name]
26
- // 兼容
27
- if (XEUtils.isFunction(render)) {
28
- log.warn('vxe.error.delProp', ['commands -> callback', 'commandMethod'])
29
- render = {
30
- commandMethod: render
31
- }
32
- }
33
-
34
- // 检测是否覆盖
35
- const confKeys = XEUtils.keys(conf)
36
- XEUtils.each(render, (item, key) => {
37
- if (confKeys.includes(key)) {
38
- log.warn('vxe.error.coverProp', [name, key])
39
- }
40
- })
41
- this.store[name] = conf ? XEUtils.merge(conf, render) : render
42
- return this
43
- }
44
-
45
- delete (name: string): void {
46
- delete this.store[name]
47
- }
48
-
49
- forEach (callback: any): void {
50
- XEUtils.objectEach(this.store, callback)
51
- }
52
- }
53
-
54
- export const commands = new VXECommandsStore() as VxeGlobalCommands
55
-
56
- Object.assign(commands, { _name: 'Commands' })
1
+ import XEUtils from 'xe-utils'
2
+ import { log } from './log'
3
+
4
+ import { VxeGlobalCommands } from '../../types'
5
+
6
+ class VXECommandsStore {
7
+ private store: any = {}
8
+
9
+ mixin (options: any): VXECommandsStore {
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): VXECommandsStore {
25
+ const conf = this.store[name]
26
+ // 兼容
27
+ if (XEUtils.isFunction(render)) {
28
+ log.warn('vxe.error.delProp', ['commands -> callback', 'commandMethod'])
29
+ render = {
30
+ commandMethod: render
31
+ }
32
+ }
33
+
34
+ // 检测是否覆盖
35
+ const confKeys = XEUtils.keys(conf)
36
+ XEUtils.each(render, (item, key) => {
37
+ if (confKeys.includes(key)) {
38
+ log.warn('vxe.error.coverProp', [name, key])
39
+ }
40
+ })
41
+ this.store[name] = conf ? XEUtils.merge(conf, render) : render
42
+ return this
43
+ }
44
+
45
+ delete (name: string): void {
46
+ delete this.store[name]
47
+ }
48
+
49
+ forEach (callback: any): void {
50
+ XEUtils.objectEach(this.store, callback)
51
+ }
52
+ }
53
+
54
+ export const commands = new VXECommandsStore() as VxeGlobalCommands
55
+
56
+ Object.assign(commands, { _name: 'Commands' })
@@ -1,30 +1,30 @@
1
- import XEUtils from 'xe-utils'
2
- import DomZIndex from 'dom-zindex'
3
- import { VxeCore } from './core'
4
- import { globalConfigStore } from './configStore'
5
- import { setTheme } from './theme'
6
-
7
- import { VxeGlobalConfig } from '../../types'
8
-
9
- /**
10
- * 全局参数设置
11
- */
12
- export function setConfig (options?: VxeGlobalConfig) {
13
- if (options) {
14
- if (options.zIndex) {
15
- DomZIndex.setCurrent(options.zIndex)
16
- }
17
- if (options.theme) {
18
- setTheme(options.theme)
19
- }
20
- XEUtils.merge(globalConfigStore, options)
21
- }
22
- return VxeCore
23
- }
24
-
25
- /**
26
- * 获取全局参数
27
- */
28
- export function getConfig (key: keyof VxeGlobalConfig, defaultValue?: any) {
29
- return arguments.length ? XEUtils.get(globalConfigStore, key, defaultValue) : globalConfigStore
30
- }
1
+ import XEUtils from 'xe-utils'
2
+ import DomZIndex from 'dom-zindex'
3
+ import { VxeCore } from './core'
4
+ import { globalConfigStore } from './configStore'
5
+ import { setTheme } from './theme'
6
+
7
+ import { VxeGlobalConfig } from '../../types'
8
+
9
+ /**
10
+ * 全局参数设置
11
+ */
12
+ export function setConfig (options?: VxeGlobalConfig) {
13
+ if (options) {
14
+ if (options.zIndex) {
15
+ DomZIndex.setCurrent(options.zIndex)
16
+ }
17
+ if (options.theme) {
18
+ setTheme(options.theme)
19
+ }
20
+ XEUtils.merge(globalConfigStore, options)
21
+ }
22
+ return VxeCore
23
+ }
24
+
25
+ /**
26
+ * 获取全局参数
27
+ */
28
+ export function getConfig (key: keyof VxeGlobalConfig, defaultValue?: any) {
29
+ return arguments.length ? XEUtils.get(globalConfigStore, key, defaultValue) : globalConfigStore
30
+ }
@@ -1,8 +1,8 @@
1
- import { VxeGlobalConfig } from '../../types'
2
-
3
- export const globalConfigStore: VxeGlobalConfig = {
4
- size: '',
5
- version: 1,
6
- zIndex: 999,
7
- resizeInterval: 500
8
- }
1
+ import { VxeGlobalConfig } from '../../types'
2
+
3
+ export const globalConfigStore: VxeGlobalConfig = {
4
+ size: '',
5
+ version: 1,
6
+ zIndex: 999,
7
+ resizeInterval: 500
8
+ }
@@ -1,11 +1,11 @@
1
- import { VxeUIExport } from '../../types'
2
-
3
- export const coreVersion = process.env.VUE_APP_VXE_VERSION as string
4
-
5
- export const VxeCore = {
6
- coreVersion,
7
- uiVersion: '',
8
- tableVersion: '',
9
- designVersion: '',
10
- ganttVersion: ''
11
- } as VxeUIExport
1
+ import { VxeUIExport } from '../../types'
2
+
3
+ export const coreVersion = process.env.VUE_APP_VXE_VERSION as string
4
+
5
+ export const VxeCore = {
6
+ coreVersion,
7
+ uiVersion: '',
8
+ tableVersion: '',
9
+ designVersion: '',
10
+ ganttVersion: ''
11
+ } as VxeUIExport
@@ -1,4 +1,4 @@
1
- import { VxeGlobalData } from '../../types'
2
-
3
- export const globalStore: VxeGlobalData = {
4
- }
1
+ import { VxeGlobalData } from '../../types'
2
+
3
+ export const globalStore: VxeGlobalData = {
4
+ }
@@ -1,160 +1,160 @@
1
- import XEUtils from 'xe-utils'
2
-
3
- import type { VxeGlobalEvents, VxeComponentBaseOptions, VxeGlobalCreateEventMethod, VxeGlobalEventKey } from '../../types'
4
-
5
- export const GLOBAL_EVENT_KEYS: VxeGlobalEventKey = {
6
- F2: 'F2',
7
- F10: 'F10',
8
- TAB: 'Tab',
9
- ESCAPE: 'Escape',
10
- ENTER: 'Enter',
11
- DELETE: 'Delete',
12
- BACKSPACE: 'Backspace',
13
- SPACEBAR: ' ',
14
- CONTEXT_MENU: 'ContextMenu',
15
- ARROW_UP: 'ArrowUp',
16
- ARROW_DOWN: 'ArrowDown',
17
- ARROW_LEFT: 'ArrowLeft',
18
- ARROW_RIGHT: 'ArrowRight',
19
- PAGE_UP: 'PageUp',
20
- PAGE_DOWN: 'PageDown',
21
- HOME: 'Home',
22
- END: 'End',
23
- A: 'A',
24
- X: 'X',
25
- C: 'C',
26
- V: 'V',
27
- D: 'D',
28
- F: 'F',
29
- H: 'H',
30
- M: 'M',
31
- Y: 'Y',
32
- Z: 'Z',
33
- R: 'R',
34
- P: 'P'
35
- }
36
-
37
- const browse = XEUtils.browse()
38
-
39
- const convertEventKeys: { [key: string]: string } = {
40
- ' ': 'Spacebar',
41
- Apps: GLOBAL_EVENT_KEYS.CONTEXT_MENU,
42
- Del: GLOBAL_EVENT_KEYS.DELETE,
43
- Up: GLOBAL_EVENT_KEYS.ARROW_UP,
44
- Down: GLOBAL_EVENT_KEYS.ARROW_DOWN,
45
- Left: GLOBAL_EVENT_KEYS.ARROW_LEFT,
46
- Right: GLOBAL_EVENT_KEYS.ARROW_RIGHT
47
- }
48
-
49
- // 监听全局事件
50
- const wheelName = browse.firefox ? 'DOMMouseScroll' : 'mousewheel'
51
- const eventStore: {
52
- comp: VxeComponentBaseOptions;
53
- type: string;
54
- cb: (evnt: Event) => void;
55
- }[] = []
56
-
57
- function triggerEvent (evnt: Event) {
58
- const isWheel = evnt.type === wheelName
59
- eventStore.forEach(({ type, cb }) => {
60
- // 如果被取消冒泡,不再执行
61
- if (!evnt.cancelBubble) {
62
- if (type === evnt.type || (isWheel && type === 'mousewheel')) {
63
- cb(evnt)
64
- }
65
- }
66
- })
67
- }
68
-
69
- class VxeComponentEvent {
70
- $event: Event
71
- type = ''
72
- key = ''
73
- code = ''
74
- constructor (evnt: Event, params1: any, params2?: any) {
75
- this.$event = evnt
76
- if (evnt) {
77
- if ((evnt as KeyboardEvent).type) {
78
- this.type = (evnt as KeyboardEvent).type
79
- }
80
- if ((evnt as KeyboardEvent).key) {
81
- this.key = (evnt as KeyboardEvent).key
82
- }
83
- if ((evnt as KeyboardEvent).code) {
84
- this.code = (evnt as KeyboardEvent).code
85
- }
86
- }
87
- Object.assign(this, params1)
88
- XEUtils.objectEach(params2, (val, key) => {
89
- if (XEUtils.isFunction(val)) {
90
- let rest: any = null
91
- let isRun = false
92
- Object.defineProperty(this, key, {
93
- get () {
94
- if (!isRun) {
95
- isRun = true
96
- rest = val()
97
- }
98
- return rest
99
- }
100
- })
101
- } else {
102
- (this as any)[key] = val
103
- }
104
- })
105
- }
106
-
107
- stopPropagation () {
108
- const evnt = this.$event
109
- if (evnt) {
110
- evnt.stopPropagation()
111
- }
112
- }
113
-
114
- preventDefault () {
115
- const evnt = this.$event
116
- if (evnt) {
117
- evnt.preventDefault()
118
- }
119
- }
120
- }
121
-
122
- export const createEvent: VxeGlobalCreateEventMethod = (evnt, params1, params2) => {
123
- if (evnt instanceof VxeComponentEvent) {
124
- evnt = evnt.$event
125
- }
126
- return new VxeComponentEvent(evnt as Event, params1, params2)
127
- }
128
-
129
- export const globalEvents: VxeGlobalEvents = {
130
- on (comp, type, cb) {
131
- eventStore.push({ comp, type, cb })
132
- },
133
- off (comp, type) {
134
- XEUtils.remove(eventStore, item => item.comp === comp && item.type === type)
135
- },
136
- hasKey (evnt, targetKey) {
137
- if (!targetKey) {
138
- return false
139
- }
140
- const { key } = evnt
141
- targetKey = targetKey.toLowerCase()
142
- return key ? (targetKey === key.toLowerCase() || !!(convertEventKeys[key] && convertEventKeys[key].toLowerCase() === targetKey)) : false
143
- }
144
- }
145
-
146
- if (browse.isDoc) {
147
- if (!browse.msie) {
148
- window.addEventListener('copy', triggerEvent, false)
149
- window.addEventListener('cut', triggerEvent, false)
150
- window.addEventListener('paste', triggerEvent, false)
151
- }
152
- document.addEventListener('scroll', triggerEvent, true)
153
- document.addEventListener('keydown', triggerEvent, false)
154
- document.addEventListener('contextmenu', triggerEvent, false)
155
- window.addEventListener('mousedown', triggerEvent, false)
156
- window.addEventListener('click', triggerEvent, false)
157
- window.addEventListener('blur', triggerEvent, false)
158
- window.addEventListener('resize', triggerEvent, false)
159
- window.addEventListener(wheelName, XEUtils.throttle(triggerEvent, 100, { leading: true, trailing: false }), { passive: true, capture: false })
160
- }
1
+ import XEUtils from 'xe-utils'
2
+
3
+ import type { VxeGlobalEvents, VxeComponentBaseOptions, VxeGlobalCreateEventMethod, VxeGlobalEventKey } from '../../types'
4
+
5
+ export const GLOBAL_EVENT_KEYS: VxeGlobalEventKey = {
6
+ F2: 'F2',
7
+ F10: 'F10',
8
+ TAB: 'Tab',
9
+ ESCAPE: 'Escape',
10
+ ENTER: 'Enter',
11
+ DELETE: 'Delete',
12
+ BACKSPACE: 'Backspace',
13
+ SPACEBAR: ' ',
14
+ CONTEXT_MENU: 'ContextMenu',
15
+ ARROW_UP: 'ArrowUp',
16
+ ARROW_DOWN: 'ArrowDown',
17
+ ARROW_LEFT: 'ArrowLeft',
18
+ ARROW_RIGHT: 'ArrowRight',
19
+ PAGE_UP: 'PageUp',
20
+ PAGE_DOWN: 'PageDown',
21
+ HOME: 'Home',
22
+ END: 'End',
23
+ A: 'A',
24
+ X: 'X',
25
+ C: 'C',
26
+ V: 'V',
27
+ D: 'D',
28
+ F: 'F',
29
+ H: 'H',
30
+ M: 'M',
31
+ Y: 'Y',
32
+ Z: 'Z',
33
+ R: 'R',
34
+ P: 'P'
35
+ }
36
+
37
+ const browse = XEUtils.browse()
38
+
39
+ const convertEventKeys: { [key: string]: string } = {
40
+ ' ': 'Spacebar',
41
+ Apps: GLOBAL_EVENT_KEYS.CONTEXT_MENU,
42
+ Del: GLOBAL_EVENT_KEYS.DELETE,
43
+ Up: GLOBAL_EVENT_KEYS.ARROW_UP,
44
+ Down: GLOBAL_EVENT_KEYS.ARROW_DOWN,
45
+ Left: GLOBAL_EVENT_KEYS.ARROW_LEFT,
46
+ Right: GLOBAL_EVENT_KEYS.ARROW_RIGHT
47
+ }
48
+
49
+ // 监听全局事件
50
+ const wheelName = browse.firefox ? 'DOMMouseScroll' : 'mousewheel'
51
+ const eventStore: {
52
+ comp: VxeComponentBaseOptions;
53
+ type: string;
54
+ cb: (evnt: Event) => void;
55
+ }[] = []
56
+
57
+ function triggerEvent (evnt: Event) {
58
+ const isWheel = evnt.type === wheelName
59
+ eventStore.forEach(({ type, cb }) => {
60
+ // 如果被取消冒泡,不再执行
61
+ if (!evnt.cancelBubble) {
62
+ if (type === evnt.type || (isWheel && type === 'mousewheel')) {
63
+ cb(evnt)
64
+ }
65
+ }
66
+ })
67
+ }
68
+
69
+ class VxeComponentEvent {
70
+ $event: Event
71
+ type = ''
72
+ key = ''
73
+ code = ''
74
+ constructor (evnt: Event, params1: any, params2?: any) {
75
+ this.$event = evnt
76
+ if (evnt) {
77
+ if ((evnt as KeyboardEvent).type) {
78
+ this.type = (evnt as KeyboardEvent).type
79
+ }
80
+ if ((evnt as KeyboardEvent).key) {
81
+ this.key = (evnt as KeyboardEvent).key
82
+ }
83
+ if ((evnt as KeyboardEvent).code) {
84
+ this.code = (evnt as KeyboardEvent).code
85
+ }
86
+ }
87
+ Object.assign(this, params1)
88
+ XEUtils.objectEach(params2, (val, key) => {
89
+ if (XEUtils.isFunction(val)) {
90
+ let rest: any = null
91
+ let isRun = false
92
+ Object.defineProperty(this, key, {
93
+ get () {
94
+ if (!isRun) {
95
+ isRun = true
96
+ rest = val()
97
+ }
98
+ return rest
99
+ }
100
+ })
101
+ } else {
102
+ (this as any)[key] = val
103
+ }
104
+ })
105
+ }
106
+
107
+ stopPropagation () {
108
+ const evnt = this.$event
109
+ if (evnt) {
110
+ evnt.stopPropagation()
111
+ }
112
+ }
113
+
114
+ preventDefault () {
115
+ const evnt = this.$event
116
+ if (evnt) {
117
+ evnt.preventDefault()
118
+ }
119
+ }
120
+ }
121
+
122
+ export const createEvent: VxeGlobalCreateEventMethod = (evnt, params1, params2) => {
123
+ if (evnt instanceof VxeComponentEvent) {
124
+ evnt = evnt.$event
125
+ }
126
+ return new VxeComponentEvent(evnt as Event, params1, params2)
127
+ }
128
+
129
+ export const globalEvents: VxeGlobalEvents = {
130
+ on (comp, type, cb) {
131
+ eventStore.push({ comp, type, cb })
132
+ },
133
+ off (comp, type) {
134
+ XEUtils.remove(eventStore, item => item.comp === comp && item.type === type)
135
+ },
136
+ hasKey (evnt, targetKey) {
137
+ if (!targetKey) {
138
+ return false
139
+ }
140
+ const { key } = evnt
141
+ targetKey = targetKey.toLowerCase()
142
+ return key ? (targetKey === key.toLowerCase() || !!(convertEventKeys[key] && convertEventKeys[key].toLowerCase() === targetKey)) : false
143
+ }
144
+ }
145
+
146
+ if (browse.isDoc) {
147
+ if (!browse.msie) {
148
+ window.addEventListener('copy', triggerEvent, false)
149
+ window.addEventListener('cut', triggerEvent, false)
150
+ window.addEventListener('paste', triggerEvent, false)
151
+ }
152
+ document.addEventListener('scroll', triggerEvent, true)
153
+ document.addEventListener('keydown', triggerEvent, false)
154
+ document.addEventListener('contextmenu', triggerEvent, false)
155
+ window.addEventListener('mousedown', triggerEvent, false)
156
+ window.addEventListener('click', triggerEvent, false)
157
+ window.addEventListener('blur', triggerEvent, false)
158
+ window.addEventListener('resize', triggerEvent, false)
159
+ window.addEventListener(wheelName, XEUtils.throttle(triggerEvent, 100, { leading: true, trailing: false }), { passive: true, capture: false })
160
+ }
@@ -1,56 +1,56 @@
1
- import XEUtils from 'xe-utils'
2
- import { log } 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
- log.warn('vxe.error.delProp', ['formats -> callback', 'cellFormatMethod'])
29
- render = {
30
- cellFormatMethod: render
31
- }
32
- }
33
-
34
- // 检测是否覆盖
35
- const confKeys = XEUtils.keys(conf)
36
- XEUtils.each(render, (item, key) => {
37
- if (confKeys.includes(key)) {
38
- log.warn('vxe.error.coverProp', [name, key])
39
- }
40
- })
41
- this.store[name] = conf ? XEUtils.merge(conf, render) : render
42
- return this
43
- }
44
-
45
- delete (name: string): void {
46
- delete this.store[name]
47
- }
48
-
49
- forEach (callback: any): void {
50
- XEUtils.objectEach(this.store, callback)
51
- }
52
- }
53
-
54
- export const formats = new VXEFormatsStore() as VxeGlobalFormats
55
-
56
- Object.assign(formats, { _name: 'Formats' })
1
+ import XEUtils from 'xe-utils'
2
+ import { log } 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
+ log.warn('vxe.error.delProp', ['formats -> callback', 'cellFormatMethod'])
29
+ render = {
30
+ cellFormatMethod: render
31
+ }
32
+ }
33
+
34
+ // 检测是否覆盖
35
+ const confKeys = XEUtils.keys(conf)
36
+ XEUtils.each(render, (item, key) => {
37
+ if (confKeys.includes(key)) {
38
+ log.warn('vxe.error.coverProp', [name, key])
39
+ }
40
+ })
41
+ this.store[name] = conf ? XEUtils.merge(conf, render) : render
42
+ return this
43
+ }
44
+
45
+ delete (name: string): void {
46
+ delete this.store[name]
47
+ }
48
+
49
+ forEach (callback: any): void {
50
+ XEUtils.objectEach(this.store, callback)
51
+ }
52
+ }
53
+
54
+ export const formats = new VXEFormatsStore() as VxeGlobalFormats
55
+
56
+ Object.assign(formats, { _name: 'Formats' })
@@ -1,5 +1,5 @@
1
- import VXEStore from './store'
2
-
3
- import { VxeGlobalHooks } from '../../types'
4
-
5
- export const hooks = new VXEStore() as VxeGlobalHooks
1
+ import VXEStore from './store'
2
+
3
+ import { VxeGlobalHooks } from '../../types'
4
+
5
+ export const hooks = new VXEStore() as VxeGlobalHooks