@vxe-ui/core 1.0.6 → 1.0.8

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 (74) hide show
  1. package/LICENSE +21 -21
  2. package/README.en.md +31 -31
  3. package/README.md +31 -31
  4. package/README.zh-TW.md +31 -31
  5. package/es/src/core.js +1 -1
  6. package/es/src/interceptor.js +21 -4
  7. package/es/src/log.js +1 -1
  8. package/lib/index.umd.js +40 -26
  9. package/lib/index.umd.min.js +1 -1
  10. package/lib/src/clipboard.min.js +1 -1
  11. package/lib/src/commands.min.js +1 -1
  12. package/lib/src/core.js +1 -1
  13. package/lib/src/core.min.js +1 -1
  14. package/lib/src/event.min.js +1 -1
  15. package/lib/src/formats.min.js +1 -1
  16. package/lib/src/globalStore.min.js +1 -1
  17. package/lib/src/hooks.min.js +1 -1
  18. package/lib/src/i18n.min.js +1 -1
  19. package/lib/src/i18nStore.min.js +1 -1
  20. package/lib/src/iconStore.min.js +1 -1
  21. package/lib/src/interceptor.js +21 -4
  22. package/lib/src/interceptor.min.js +1 -1
  23. package/lib/src/log.js +1 -1
  24. package/lib/src/log.min.js +1 -1
  25. package/lib/src/menus.min.js +1 -1
  26. package/lib/src/renderer.min.js +1 -1
  27. package/lib/src/resize.min.js +1 -1
  28. package/lib/src/store.min.js +1 -1
  29. package/lib/src/themeStore.min.js +1 -1
  30. package/lib/src/useFns.min.js +1 -1
  31. package/lib/src/validators.min.js +1 -1
  32. package/package.json +78 -78
  33. package/packages/index.ts +4 -4
  34. package/packages/src/clipboard.ts +53 -53
  35. package/packages/src/commands.ts +62 -62
  36. package/packages/src/core.ts +163 -163
  37. package/packages/src/event.ts +113 -113
  38. package/packages/src/formats.ts +62 -62
  39. package/packages/src/globalStore.ts +8 -8
  40. package/packages/src/hooks.ts +5 -5
  41. package/packages/src/i18n.ts +14 -14
  42. package/packages/src/i18nStore.ts +11 -11
  43. package/packages/src/iconStore.ts +3 -3
  44. package/packages/src/interceptor.ts +65 -46
  45. package/packages/src/log.ts +19 -19
  46. package/packages/src/menus.ts +62 -62
  47. package/packages/src/renderer.ts +50 -50
  48. package/packages/src/resize.ts +89 -89
  49. package/packages/src/store.ts +49 -49
  50. package/packages/src/themeStore.ts +7 -7
  51. package/packages/src/useFns.ts +18 -18
  52. package/packages/src/validators.ts +9 -9
  53. package/types/core/clipboard.d.ts +13 -13
  54. package/types/core/commands.d.ts +19 -24
  55. package/types/core/components.d.ts +4 -4
  56. package/types/core/formats.d.ts +19 -22
  57. package/types/core/global-config.d.ts +49 -49
  58. package/types/core/global-event.d.ts +39 -39
  59. package/types/core/global-icon.d.ts +6 -6
  60. package/types/core/global-lang.d.ts +1 -1
  61. package/types/core/global-resize.d.ts +3 -3
  62. package/types/core/global-theme.d.ts +1 -1
  63. package/types/core/hooks.d.ts +14 -14
  64. package/types/core/index.d.ts +211 -211
  65. package/types/core/interceptor.d.ts +22 -18
  66. package/types/core/log.d.ts +8 -8
  67. package/types/core/menus.d.ts +19 -24
  68. package/types/core/renderer.d.ts +14 -14
  69. package/types/core/useFn.d.ts +17 -17
  70. package/types/core/validators.d.ts +19 -20
  71. package/types/index.d.ts +10 -10
  72. package/types/tool/common.d.ts +70 -70
  73. package/types/tool/index.d.ts +2 -2
  74. package/types/tool/util.d.ts +4 -4
@@ -1,163 +1,163 @@
1
- import XEUtils from 'xe-utils'
2
- import DomZIndex from 'dom-zindex'
3
- import { globalConfigStore } from './globalStore'
4
- import { iconConfigStore } from './iconStore'
5
- import { themeConfigStore } from './themeStore'
6
- import { i18nConfigStore } from './i18nStore'
7
- import { globalEvents, GLOBAL_EVENT_KEYS, createEvent } from './event'
8
- import { globalResize } from './resize'
9
- import { getI18n, hasLanguage } from './i18n'
10
- import { renderer } from './renderer'
11
- import { validators } from './validators'
12
- import { menus } from './menus'
13
- import { formats } from './formats'
14
- import { commands } from './commands'
15
- import { interceptor } from './interceptor'
16
- import { clipboard } from './clipboard'
17
- import { log } from './log'
18
- import { hooks } from './hooks'
19
- import { useFns } from './useFns'
20
-
21
- import { VxeUIExport, VxeGlobalConfig, VxeGlobalThemeName, VxeGlobalComponents, VxeGlobalIcon, VxeUIPluginObject, VxeGlobalI18nLocale } from '../../types'
22
-
23
- export function setTheme (name?: VxeGlobalThemeName) {
24
- const theme = !name || name === 'default' ? 'light' : name
25
- themeConfigStore.theme = theme
26
- if (typeof document !== 'undefined') {
27
- const documentElement = document.documentElement
28
- if (documentElement) {
29
- documentElement.setAttribute('data-vxe-ui-theme', theme)
30
- }
31
- }
32
- return VxeUI
33
- }
34
-
35
- export function getTheme () {
36
- return themeConfigStore.theme
37
- }
38
-
39
- export function setLanguage (locale: VxeGlobalI18nLocale) {
40
- i18nConfigStore.language = locale || 'zh-CN'
41
- return VxeUI
42
- }
43
-
44
- export function setI18n (locale: VxeGlobalI18nLocale, data: Record<string, any>) {
45
- i18nConfigStore.langMaps[locale] = Object.assign({}, data)
46
- return VxeUI
47
- }
48
-
49
- /**
50
- * 全局参数设置
51
- */
52
- export function setConfig (options?: VxeGlobalConfig) {
53
- if (options) {
54
- if (options.zIndex) {
55
- DomZIndex.setCurrent(options.zIndex)
56
- }
57
- if (options.theme) {
58
- setTheme(options.theme)
59
- }
60
- XEUtils.merge(globalConfigStore, options)
61
- }
62
- return VxeUI
63
- }
64
-
65
- /**
66
- * 获取全局参数
67
- */
68
- export function getConfig (key: keyof VxeGlobalConfig, defaultValue?: any) {
69
- return arguments.length ? XEUtils.get(globalConfigStore, key, defaultValue) : globalConfigStore
70
- }
71
-
72
- export function setIcon (options?: VxeGlobalIcon) {
73
- if (options) {
74
- Object.assign(iconConfigStore, options)
75
- }
76
- return VxeUI
77
- }
78
-
79
- export function getIcon (key: keyof VxeGlobalIcon) {
80
- return arguments.length ? XEUtils.get(iconConfigStore, key) : iconConfigStore
81
- }
82
-
83
- export const coreVersion = process.env.VUE_APP_VXE_VERSION as string
84
-
85
- const installedPlugins: VxeUIPluginObject[] = []
86
-
87
- export function use (Plugin: VxeUIPluginObject, options: any[]) {
88
- if (Plugin && Plugin.install) {
89
- if (installedPlugins.indexOf(Plugin) === -1) {
90
- Plugin.install(VxeUI, options)
91
- installedPlugins.push(Plugin)
92
- }
93
- }
94
- return VxeUI
95
- }
96
-
97
- const components: Record<string, any> = {}
98
-
99
- export function getComponent (name: keyof VxeGlobalComponents) {
100
- return components[name] || null
101
- }
102
-
103
- export function component (comp: any) {
104
- if (comp && comp.name) {
105
- components[comp.name] = comp
106
- }
107
- }
108
-
109
- export const VxeUI: VxeUIExport = {
110
- coreVersion,
111
-
112
- setTheme,
113
- getTheme,
114
- setConfig,
115
- getConfig: getConfig as any,
116
- setIcon,
117
- getIcon: getIcon as any,
118
- setLanguage,
119
- hasLanguage,
120
- setI18n,
121
- getI18n,
122
-
123
- globalEvents,
124
- GLOBAL_EVENT_KEYS,
125
- createEvent,
126
-
127
- globalResize,
128
- renderer,
129
- validators,
130
- menus,
131
- formats,
132
- commands,
133
- interceptor,
134
- clipboard,
135
- log,
136
-
137
- hooks,
138
- component,
139
- getComponent,
140
- useFns,
141
-
142
- use
143
- }
144
-
145
- setTheme()
146
-
147
- export * from './event'
148
- export * from './resize'
149
-
150
- export * from './i18n'
151
- export * from './renderer'
152
- export * from './validators'
153
- export * from './menus'
154
- export * from './formats'
155
- export * from './commands'
156
- export * from './interceptor'
157
- export * from './clipboard'
158
-
159
- export * from './useFns'
160
- export * from './log'
161
- export * from './hooks'
162
-
163
- export default VxeUI
1
+ import XEUtils from 'xe-utils'
2
+ import DomZIndex from 'dom-zindex'
3
+ import { globalConfigStore } from './globalStore'
4
+ import { iconConfigStore } from './iconStore'
5
+ import { themeConfigStore } from './themeStore'
6
+ import { i18nConfigStore } from './i18nStore'
7
+ import { globalEvents, GLOBAL_EVENT_KEYS, createEvent } from './event'
8
+ import { globalResize } from './resize'
9
+ import { getI18n, hasLanguage } from './i18n'
10
+ import { renderer } from './renderer'
11
+ import { validators } from './validators'
12
+ import { menus } from './menus'
13
+ import { formats } from './formats'
14
+ import { commands } from './commands'
15
+ import { interceptor } from './interceptor'
16
+ import { clipboard } from './clipboard'
17
+ import { log } from './log'
18
+ import { hooks } from './hooks'
19
+ import { useFns } from './useFns'
20
+
21
+ import { VxeUIExport, VxeGlobalConfig, VxeGlobalThemeName, VxeGlobalComponents, VxeGlobalIcon, VxeUIPluginObject, VxeGlobalI18nLocale } from '../../types'
22
+
23
+ export function setTheme (name?: VxeGlobalThemeName) {
24
+ const theme = !name || name === 'default' ? 'light' : name
25
+ themeConfigStore.theme = theme
26
+ if (typeof document !== 'undefined') {
27
+ const documentElement = document.documentElement
28
+ if (documentElement) {
29
+ documentElement.setAttribute('data-vxe-ui-theme', theme)
30
+ }
31
+ }
32
+ return VxeUI
33
+ }
34
+
35
+ export function getTheme () {
36
+ return themeConfigStore.theme
37
+ }
38
+
39
+ export function setLanguage (locale: VxeGlobalI18nLocale) {
40
+ i18nConfigStore.language = locale || 'zh-CN'
41
+ return VxeUI
42
+ }
43
+
44
+ export function setI18n (locale: VxeGlobalI18nLocale, data: Record<string, any>) {
45
+ i18nConfigStore.langMaps[locale] = Object.assign({}, data)
46
+ return VxeUI
47
+ }
48
+
49
+ /**
50
+ * 全局参数设置
51
+ */
52
+ export function setConfig (options?: VxeGlobalConfig) {
53
+ if (options) {
54
+ if (options.zIndex) {
55
+ DomZIndex.setCurrent(options.zIndex)
56
+ }
57
+ if (options.theme) {
58
+ setTheme(options.theme)
59
+ }
60
+ XEUtils.merge(globalConfigStore, options)
61
+ }
62
+ return VxeUI
63
+ }
64
+
65
+ /**
66
+ * 获取全局参数
67
+ */
68
+ export function getConfig (key: keyof VxeGlobalConfig, defaultValue?: any) {
69
+ return arguments.length ? XEUtils.get(globalConfigStore, key, defaultValue) : globalConfigStore
70
+ }
71
+
72
+ export function setIcon (options?: VxeGlobalIcon) {
73
+ if (options) {
74
+ Object.assign(iconConfigStore, options)
75
+ }
76
+ return VxeUI
77
+ }
78
+
79
+ export function getIcon (key: keyof VxeGlobalIcon) {
80
+ return arguments.length ? XEUtils.get(iconConfigStore, key) : iconConfigStore
81
+ }
82
+
83
+ export const coreVersion = process.env.VUE_APP_VXE_VERSION as string
84
+
85
+ const installedPlugins: VxeUIPluginObject[] = []
86
+
87
+ export function use (Plugin: VxeUIPluginObject, options: any[]) {
88
+ if (Plugin && Plugin.install) {
89
+ if (installedPlugins.indexOf(Plugin) === -1) {
90
+ Plugin.install(VxeUI, options)
91
+ installedPlugins.push(Plugin)
92
+ }
93
+ }
94
+ return VxeUI
95
+ }
96
+
97
+ const components: Record<string, any> = {}
98
+
99
+ export function getComponent (name: keyof VxeGlobalComponents) {
100
+ return components[name] || null
101
+ }
102
+
103
+ export function component (comp: any) {
104
+ if (comp && comp.name) {
105
+ components[comp.name] = comp
106
+ }
107
+ }
108
+
109
+ export const VxeUI: VxeUIExport = {
110
+ coreVersion,
111
+
112
+ setTheme,
113
+ getTheme,
114
+ setConfig,
115
+ getConfig: getConfig as any,
116
+ setIcon,
117
+ getIcon: getIcon as any,
118
+ setLanguage,
119
+ hasLanguage,
120
+ setI18n,
121
+ getI18n,
122
+
123
+ globalEvents,
124
+ GLOBAL_EVENT_KEYS,
125
+ createEvent,
126
+
127
+ globalResize,
128
+ renderer,
129
+ validators,
130
+ menus,
131
+ formats,
132
+ commands,
133
+ interceptor,
134
+ clipboard,
135
+ log,
136
+
137
+ hooks,
138
+ component,
139
+ getComponent,
140
+ useFns,
141
+
142
+ use
143
+ }
144
+
145
+ setTheme()
146
+
147
+ export * from './event'
148
+ export * from './resize'
149
+
150
+ export * from './i18n'
151
+ export * from './renderer'
152
+ export * from './validators'
153
+ export * from './menus'
154
+ export * from './formats'
155
+ export * from './commands'
156
+ export * from './interceptor'
157
+ export * from './clipboard'
158
+
159
+ export * from './useFns'
160
+ export * from './log'
161
+ export * from './hooks'
162
+
163
+ export default VxeUI
@@ -1,113 +1,113 @@
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
- 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
- R: 'R',
21
- P: 'P',
22
- Z: 'Z',
23
- X: 'X',
24
- C: 'C',
25
- V: 'V',
26
- M: 'M'
27
- }
28
-
29
- const browse = XEUtils.browse()
30
-
31
- const convertEventKeys: { [key: string]: string } = {
32
- ' ': 'Spacebar',
33
- Apps: GLOBAL_EVENT_KEYS.CONTEXT_MENU,
34
- Del: GLOBAL_EVENT_KEYS.DELETE,
35
- Up: GLOBAL_EVENT_KEYS.ARROW_UP,
36
- Down: GLOBAL_EVENT_KEYS.ARROW_DOWN,
37
- Left: GLOBAL_EVENT_KEYS.ARROW_LEFT,
38
- Right: GLOBAL_EVENT_KEYS.ARROW_RIGHT
39
- }
40
-
41
- // 监听全局事件
42
- const wheelName = browse.firefox ? 'DOMMouseScroll' : 'mousewheel'
43
- const eventStore: {
44
- comp: VxeComponentBaseOptions;
45
- type: string;
46
- cb: (evnt: Event) => void;
47
- }[] = []
48
-
49
- function triggerEvent (evnt: Event) {
50
- const isWheel = evnt.type === wheelName
51
- eventStore.forEach(({ type, cb }) => {
52
- // 如果被取消冒泡,不再执行
53
- if (!evnt.cancelBubble) {
54
- if (type === evnt.type || (isWheel && type === 'mousewheel')) {
55
- cb(evnt)
56
- }
57
- }
58
- })
59
- }
60
-
61
- class VxeComponentEvent {
62
- $event: Event
63
- constructor (evnt: Event, params1: any, params2?: any) {
64
- this.$event = evnt
65
- Object.assign(this, params1, params2)
66
- }
67
-
68
- stopPropagation () {
69
- const evnt = this.$event
70
- if (evnt) {
71
- evnt.stopPropagation()
72
- }
73
- }
74
-
75
- preventDefault () {
76
- const evnt = this.$event
77
- if (evnt) {
78
- evnt.preventDefault()
79
- }
80
- }
81
- }
82
-
83
- export const createEvent: VxeGlobalCreateEventMethod = (evnt, params1, params2) => {
84
- return new VxeComponentEvent(evnt as Event, params1, params2)
85
- }
86
-
87
- export const globalEvents: VxeGlobalEvents = {
88
- on (comp, type, cb) {
89
- eventStore.push({ comp, type, cb })
90
- },
91
- off (comp, type) {
92
- XEUtils.remove(eventStore, item => item.comp === comp && item.type === type)
93
- },
94
- hasKey (evnt, targetKey) {
95
- const { key } = evnt
96
- targetKey = targetKey.toLowerCase()
97
- return key ? (targetKey === key.toLowerCase() || !!(convertEventKeys[key] && convertEventKeys[key].toLowerCase() === targetKey)) : false
98
- }
99
- }
100
-
101
- if (browse.isDoc) {
102
- if (!browse.msie) {
103
- window.addEventListener('copy', triggerEvent, false)
104
- window.addEventListener('cut', triggerEvent, false)
105
- window.addEventListener('paste', triggerEvent, false)
106
- }
107
- document.addEventListener('keydown', triggerEvent, false)
108
- document.addEventListener('contextmenu', triggerEvent, false)
109
- window.addEventListener('mousedown', triggerEvent, false)
110
- window.addEventListener('blur', triggerEvent, false)
111
- window.addEventListener('resize', triggerEvent, false)
112
- window.addEventListener(wheelName, XEUtils.throttle(triggerEvent, 100, { leading: true, trailing: false }), { passive: true, capture: false })
113
- }
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
+ 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
+ R: 'R',
21
+ P: 'P',
22
+ Z: 'Z',
23
+ X: 'X',
24
+ C: 'C',
25
+ V: 'V',
26
+ M: 'M'
27
+ }
28
+
29
+ const browse = XEUtils.browse()
30
+
31
+ const convertEventKeys: { [key: string]: string } = {
32
+ ' ': 'Spacebar',
33
+ Apps: GLOBAL_EVENT_KEYS.CONTEXT_MENU,
34
+ Del: GLOBAL_EVENT_KEYS.DELETE,
35
+ Up: GLOBAL_EVENT_KEYS.ARROW_UP,
36
+ Down: GLOBAL_EVENT_KEYS.ARROW_DOWN,
37
+ Left: GLOBAL_EVENT_KEYS.ARROW_LEFT,
38
+ Right: GLOBAL_EVENT_KEYS.ARROW_RIGHT
39
+ }
40
+
41
+ // 监听全局事件
42
+ const wheelName = browse.firefox ? 'DOMMouseScroll' : 'mousewheel'
43
+ const eventStore: {
44
+ comp: VxeComponentBaseOptions;
45
+ type: string;
46
+ cb: (evnt: Event) => void;
47
+ }[] = []
48
+
49
+ function triggerEvent (evnt: Event) {
50
+ const isWheel = evnt.type === wheelName
51
+ eventStore.forEach(({ type, cb }) => {
52
+ // 如果被取消冒泡,不再执行
53
+ if (!evnt.cancelBubble) {
54
+ if (type === evnt.type || (isWheel && type === 'mousewheel')) {
55
+ cb(evnt)
56
+ }
57
+ }
58
+ })
59
+ }
60
+
61
+ class VxeComponentEvent {
62
+ $event: Event
63
+ constructor (evnt: Event, params1: any, params2?: any) {
64
+ this.$event = evnt
65
+ Object.assign(this, params1, params2)
66
+ }
67
+
68
+ stopPropagation () {
69
+ const evnt = this.$event
70
+ if (evnt) {
71
+ evnt.stopPropagation()
72
+ }
73
+ }
74
+
75
+ preventDefault () {
76
+ const evnt = this.$event
77
+ if (evnt) {
78
+ evnt.preventDefault()
79
+ }
80
+ }
81
+ }
82
+
83
+ export const createEvent: VxeGlobalCreateEventMethod = (evnt, params1, params2) => {
84
+ return new VxeComponentEvent(evnt as Event, params1, params2)
85
+ }
86
+
87
+ export const globalEvents: VxeGlobalEvents = {
88
+ on (comp, type, cb) {
89
+ eventStore.push({ comp, type, cb })
90
+ },
91
+ off (comp, type) {
92
+ XEUtils.remove(eventStore, item => item.comp === comp && item.type === type)
93
+ },
94
+ hasKey (evnt, targetKey) {
95
+ const { key } = evnt
96
+ targetKey = targetKey.toLowerCase()
97
+ return key ? (targetKey === key.toLowerCase() || !!(convertEventKeys[key] && convertEventKeys[key].toLowerCase() === targetKey)) : false
98
+ }
99
+ }
100
+
101
+ if (browse.isDoc) {
102
+ if (!browse.msie) {
103
+ window.addEventListener('copy', triggerEvent, false)
104
+ window.addEventListener('cut', triggerEvent, false)
105
+ window.addEventListener('paste', triggerEvent, false)
106
+ }
107
+ document.addEventListener('keydown', triggerEvent, false)
108
+ document.addEventListener('contextmenu', triggerEvent, false)
109
+ window.addEventListener('mousedown', triggerEvent, false)
110
+ window.addEventListener('blur', triggerEvent, false)
111
+ window.addEventListener('resize', triggerEvent, false)
112
+ window.addEventListener(wheelName, XEUtils.throttle(triggerEvent, 100, { leading: true, trailing: false }), { passive: true, capture: false })
113
+ }
@@ -1,62 +1,62 @@
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
- if (process.env.VUE_APP_VXE_ENV === 'development') {
29
- log.warn('vxe.error.delProp', ['formats -> callback', 'cellFormatMethod'])
30
- }
31
- render = {
32
- cellFormatMethod: render
33
- }
34
- }
35
-
36
- // 检测是否覆盖
37
- if (process.env.VUE_APP_VXE_ENV === 'development') {
38
- const confKeys = XEUtils.keys(conf)
39
- XEUtils.each(render, (item, key) => {
40
- if (confKeys.includes(key)) {
41
- log.warn('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_ENV === 'development') {
61
- Object.assign(formats, { _name: 'Formats' })
62
- }
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
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
29
+ log.warn('vxe.error.delProp', ['formats -> callback', 'cellFormatMethod'])
30
+ }
31
+ render = {
32
+ cellFormatMethod: render
33
+ }
34
+ }
35
+
36
+ // 检测是否覆盖
37
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
38
+ const confKeys = XEUtils.keys(conf)
39
+ XEUtils.each(render, (item, key) => {
40
+ if (confKeys.includes(key)) {
41
+ log.warn('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_ENV === 'development') {
61
+ Object.assign(formats, { _name: 'Formats' })
62
+ }