@vxe-ui/core 4.4.42 → 4.5.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.
Files changed (195) hide show
  1. package/dist/all.esm.js +1594 -1389
  2. package/dist/all.esm.min.js +1 -0
  3. package/es/index.d.ts +138 -0
  4. package/es/index.esm.js +138 -125
  5. package/es/index.js +150 -0
  6. package/es/src/base-utils.d.ts +2 -0
  7. package/es/src/base-utils.js +40 -37
  8. package/es/src/clipboard.d.ts +2 -0
  9. package/es/src/clipboard.js +48 -45
  10. package/es/src/commands.d.ts +2 -0
  11. package/es/src/commands.js +47 -48
  12. package/es/src/config.d.ts +13 -0
  13. package/es/src/config.js +21 -23
  14. package/es/src/configStore.d.ts +2 -0
  15. package/es/src/configStore.js +8 -5
  16. package/es/src/core.d.ts +3 -0
  17. package/es/src/core.js +11 -7
  18. package/es/src/dataStore.d.ts +2 -0
  19. package/es/src/dataStore.js +4 -1
  20. package/es/src/db-utils.d.ts +2 -0
  21. package/es/src/db-utils.js +234 -0
  22. package/es/src/dom-utils.d.ts +2 -0
  23. package/es/src/dom-utils.js +65 -68
  24. package/es/src/event.d.ts +4 -0
  25. package/es/src/event.js +133 -147
  26. package/es/src/formats.d.ts +2 -0
  27. package/es/src/formats.js +47 -48
  28. package/es/src/hooks.d.ts +2 -0
  29. package/es/src/hooks.js +5 -2
  30. package/es/src/i18n.d.ts +6 -0
  31. package/es/src/i18n.js +51 -44
  32. package/es/src/i18nStore.d.ts +5 -0
  33. package/es/src/i18nStore.js +7 -4
  34. package/es/src/icon.d.ts +9 -0
  35. package/es/src/icon.js +28 -22
  36. package/es/src/iconStore.d.ts +2 -0
  37. package/es/src/iconStore.js +4 -1
  38. package/es/src/interceptor.d.ts +2 -0
  39. package/es/src/interceptor.js +52 -54
  40. package/es/src/log.d.ts +2 -0
  41. package/es/src/log.js +14 -11
  42. package/es/src/menus.d.ts +2 -0
  43. package/es/src/menus.js +47 -48
  44. package/es/src/permission.d.ts +3 -0
  45. package/es/src/permission.js +57 -55
  46. package/es/src/popper-utils.d.ts +2 -0
  47. package/es/src/popper-utils.js +159 -179
  48. package/es/src/renderer.d.ts +5 -0
  49. package/es/src/renderer.js +37 -42
  50. package/es/src/resize.d.ts +2 -0
  51. package/es/src/resize.js +60 -70
  52. package/es/src/scrollbar-utils.d.ts +2 -0
  53. package/es/src/scrollbar-utils.js +57 -54
  54. package/es/src/store.d.ts +13 -0
  55. package/es/src/store.js +43 -45
  56. package/es/src/theme.d.ts +3 -0
  57. package/es/src/theme.js +17 -13
  58. package/es/src/themeStore.d.ts +4 -0
  59. package/es/src/themeStore.js +5 -2
  60. package/es/src/useFns.d.ts +40 -0
  61. package/es/src/useFns.js +212 -231
  62. package/es/src/validators.d.ts +2 -0
  63. package/es/src/validators.js +6 -3
  64. package/es/src/vm.d.ts +2 -0
  65. package/es/src/vm.js +9 -6
  66. package/es/src/z-index.d.ts +2 -0
  67. package/es/src/z-index.js +29 -26
  68. package/lib/index.common.js +136 -365
  69. package/lib/index.js +181 -0
  70. package/lib/index.umd.js +819 -3343
  71. package/lib/index.umd.min.js +1 -1
  72. package/lib/src/base-utils.js +39 -13
  73. package/lib/src/clipboard.js +50 -23
  74. package/lib/src/commands.js +46 -27
  75. package/lib/src/config.js +43 -23
  76. package/lib/src/configStore.js +24 -7
  77. package/lib/src/core.js +29 -11
  78. package/lib/src/dataStore.js +22 -5
  79. package/lib/src/db-utils.js +263 -0
  80. package/lib/src/dom-utils.js +40 -20
  81. package/lib/src/event.js +95 -102
  82. package/lib/src/formats.js +46 -27
  83. package/lib/src/hooks.js +33 -7
  84. package/lib/src/i18n.js +53 -38
  85. package/lib/src/i18nStore.js +25 -8
  86. package/lib/src/icon.js +46 -22
  87. package/lib/src/iconStore.js +22 -5
  88. package/lib/src/interceptor.js +40 -18
  89. package/lib/src/log.js +29 -12
  90. package/lib/src/menus.js +46 -27
  91. package/lib/src/permission.js +40 -17
  92. package/lib/src/popper-utils.js +71 -71
  93. package/lib/src/renderer.js +40 -21
  94. package/lib/src/resize.js +48 -42
  95. package/lib/src/scrollbar-utils.js +23 -6
  96. package/lib/src/store.js +44 -25
  97. package/lib/src/theme.js +31 -14
  98. package/lib/src/themeStore.js +24 -7
  99. package/lib/src/useFns.js +87 -124
  100. package/lib/src/validators.js +34 -10
  101. package/lib/src/vm.js +34 -8
  102. package/lib/src/z-index.js +38 -12
  103. package/package.json +14 -3
  104. package/packages/index.ts +171 -168
  105. package/packages/src/base-utils.ts +42 -43
  106. package/packages/src/clipboard.ts +56 -56
  107. package/packages/src/commands.ts +56 -56
  108. package/packages/src/config.ts +30 -30
  109. package/packages/src/configStore.ts +8 -8
  110. package/packages/src/core.ts +11 -11
  111. package/packages/src/dataStore.ts +3 -4
  112. package/packages/src/db-utils.ts +267 -0
  113. package/packages/src/dom-utils.ts +86 -87
  114. package/packages/src/event.ts +161 -161
  115. package/packages/src/formats.ts +56 -56
  116. package/packages/src/hooks.ts +5 -5
  117. package/packages/src/i18n.ts +63 -63
  118. package/packages/src/i18nStore.ts +11 -11
  119. package/packages/src/icon.ts +32 -32
  120. package/packages/src/iconStore.ts +3 -3
  121. package/packages/src/interceptor.ts +64 -64
  122. package/packages/src/log.ts +19 -19
  123. package/packages/src/menus.ts +56 -56
  124. package/packages/src/permission.ts +61 -61
  125. package/packages/src/popper-utils.ts +197 -194
  126. package/packages/src/renderer.ts +50 -50
  127. package/packages/src/resize.ts +89 -89
  128. package/packages/src/scrollbar-utils.ts +58 -58
  129. package/packages/src/store.ts +47 -47
  130. package/packages/src/theme.ts +20 -20
  131. package/packages/src/themeStore.ts +7 -7
  132. package/packages/src/useFns.ts +270 -275
  133. package/packages/src/validators.ts +7 -7
  134. package/packages/src/vm.ts +10 -10
  135. package/packages/src/z-index.ts +30 -30
  136. package/types/core/base-utils.d.ts +39 -40
  137. package/types/core/clipboard.d.ts +22 -22
  138. package/types/core/commands.d.ts +17 -19
  139. package/types/core/components.d.ts +5 -5
  140. package/types/core/db-utils.d.ts +44 -0
  141. package/types/core/dom-utils.d.ts +36 -37
  142. package/types/core/formats.d.ts +17 -19
  143. package/types/core/global-config.d.ts +67 -74
  144. package/types/core/global-data.d.ts +7 -7
  145. package/types/core/global-event.d.ts +48 -48
  146. package/types/core/global-icon.d.ts +10 -10
  147. package/types/core/global-lang.d.ts +28 -27
  148. package/types/core/global-resize.d.ts +3 -3
  149. package/types/core/global-theme.d.ts +1 -1
  150. package/types/core/hooks.d.ts +12 -14
  151. package/types/core/index.d.ts +343 -336
  152. package/types/core/interceptor.d.ts +20 -22
  153. package/types/core/log.d.ts +8 -8
  154. package/types/core/menus.d.ts +17 -19
  155. package/types/core/permission.d.ts +10 -10
  156. package/types/core/popper-utils.d.ts +44 -44
  157. package/types/core/renderer.d.ts +14 -14
  158. package/types/core/scrollbar-utils.d.ts +37 -38
  159. package/types/core/useFn.d.ts +121 -126
  160. package/types/core/validators.d.ts +17 -19
  161. package/types/core/z-index.d.ts +18 -18
  162. package/types/index.d.ts +13 -13
  163. package/types/tool/common.d.ts +146 -155
  164. package/types/tool/index.d.ts +2 -2
  165. package/types/tool/util.d.ts +4 -4
  166. package/lib/src/base-utils.min.js +0 -1
  167. package/lib/src/clipboard.min.js +0 -1
  168. package/lib/src/commands.min.js +0 -1
  169. package/lib/src/config.min.js +0 -1
  170. package/lib/src/configStore.min.js +0 -1
  171. package/lib/src/core.min.js +0 -1
  172. package/lib/src/dataStore.min.js +0 -1
  173. package/lib/src/dom-utils.min.js +0 -1
  174. package/lib/src/event.min.js +0 -1
  175. package/lib/src/formats.min.js +0 -1
  176. package/lib/src/hooks.min.js +0 -1
  177. package/lib/src/i18n.min.js +0 -1
  178. package/lib/src/i18nStore.min.js +0 -1
  179. package/lib/src/icon.min.js +0 -1
  180. package/lib/src/iconStore.min.js +0 -1
  181. package/lib/src/interceptor.min.js +0 -1
  182. package/lib/src/log.min.js +0 -1
  183. package/lib/src/menus.min.js +0 -1
  184. package/lib/src/permission.min.js +0 -1
  185. package/lib/src/popper-utils.min.js +0 -1
  186. package/lib/src/renderer.min.js +0 -1
  187. package/lib/src/resize.min.js +0 -1
  188. package/lib/src/scrollbar-utils.min.js +0 -1
  189. package/lib/src/store.min.js +0 -1
  190. package/lib/src/theme.min.js +0 -1
  191. package/lib/src/themeStore.min.js +0 -1
  192. package/lib/src/useFns.min.js +0 -1
  193. package/lib/src/validators.min.js +0 -1
  194. package/lib/src/vm.min.js +0 -1
  195. package/lib/src/z-index.min.js +0 -1
@@ -1,161 +1,161 @@
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
- PROCESS: 'Process',
24
- A: 'A',
25
- X: 'X',
26
- C: 'C',
27
- V: 'V',
28
- D: 'D',
29
- F: 'F',
30
- H: 'H',
31
- M: 'M',
32
- Y: 'Y',
33
- Z: 'Z',
34
- R: 'R',
35
- P: 'P'
36
- }
37
-
38
- const browse = XEUtils.browse()
39
-
40
- const convertEventKeys: { [key: string]: string } = {
41
- ' ': 'Spacebar',
42
- Apps: GLOBAL_EVENT_KEYS.CONTEXT_MENU,
43
- Del: GLOBAL_EVENT_KEYS.DELETE,
44
- Up: GLOBAL_EVENT_KEYS.ARROW_UP,
45
- Down: GLOBAL_EVENT_KEYS.ARROW_DOWN,
46
- Left: GLOBAL_EVENT_KEYS.ARROW_LEFT,
47
- Right: GLOBAL_EVENT_KEYS.ARROW_RIGHT
48
- }
49
-
50
- // 监听全局事件
51
- const wheelName = browse.firefox ? 'DOMMouseScroll' : 'mousewheel'
52
- const eventStore: {
53
- comp: VxeComponentBaseOptions;
54
- type: string;
55
- cb: (evnt: Event) => void;
56
- }[] = []
57
-
58
- function triggerEvent (evnt: Event) {
59
- const isWheel = evnt.type === wheelName
60
- eventStore.forEach(({ type, cb }) => {
61
- // 如果被取消冒泡,不再执行
62
- if (!evnt.cancelBubble) {
63
- if (type === evnt.type || (isWheel && type === 'mousewheel')) {
64
- cb(evnt)
65
- }
66
- }
67
- })
68
- }
69
-
70
- class VxeComponentEvent {
71
- $event: Event
72
- type = ''
73
- key = ''
74
- code = ''
75
- constructor (evnt: Event, params1: any, params2?: any) {
76
- this.$event = evnt
77
- if (evnt) {
78
- if ((evnt as KeyboardEvent).type) {
79
- this.type = (evnt as KeyboardEvent).type
80
- }
81
- if ((evnt as KeyboardEvent).key) {
82
- this.key = (evnt as KeyboardEvent).key
83
- }
84
- if ((evnt as KeyboardEvent).code) {
85
- this.code = (evnt as KeyboardEvent).code
86
- }
87
- }
88
- Object.assign(this, params1)
89
- XEUtils.objectEach(params2, (val, key) => {
90
- if (XEUtils.isFunction(val)) {
91
- let rest: any = null
92
- let isRun = false
93
- Object.defineProperty(this, key, {
94
- get () {
95
- if (!isRun) {
96
- isRun = true
97
- rest = val()
98
- }
99
- return rest
100
- }
101
- })
102
- } else {
103
- (this as any)[key] = val
104
- }
105
- })
106
- }
107
-
108
- stopPropagation () {
109
- const evnt = this.$event
110
- if (evnt) {
111
- evnt.stopPropagation()
112
- }
113
- }
114
-
115
- preventDefault () {
116
- const evnt = this.$event
117
- if (evnt) {
118
- evnt.preventDefault()
119
- }
120
- }
121
- }
122
-
123
- export const createEvent: VxeGlobalCreateEventMethod = (evnt, params1, params2) => {
124
- if (evnt instanceof VxeComponentEvent) {
125
- evnt = evnt.$event
126
- }
127
- return new VxeComponentEvent(evnt as Event, params1, params2)
128
- }
129
-
130
- export const globalEvents: VxeGlobalEvents = {
131
- on (comp, type, cb) {
132
- eventStore.push({ comp, type, cb })
133
- },
134
- off (comp, type) {
135
- XEUtils.remove(eventStore, item => item.comp === comp && item.type === type)
136
- },
137
- hasKey (evnt, targetKey) {
138
- if (!targetKey) {
139
- return false
140
- }
141
- const { key } = evnt
142
- targetKey = targetKey.toLowerCase()
143
- return key ? (targetKey === key.toLowerCase() || !!(convertEventKeys[key] && convertEventKeys[key].toLowerCase() === targetKey)) : false
144
- }
145
- }
146
-
147
- if (browse.isDoc) {
148
- if (!browse.msie) {
149
- window.addEventListener('copy', triggerEvent, false)
150
- window.addEventListener('cut', triggerEvent, false)
151
- window.addEventListener('paste', triggerEvent, false)
152
- }
153
- document.addEventListener('scroll', triggerEvent, true)
154
- document.addEventListener('keydown', triggerEvent, false)
155
- document.addEventListener('contextmenu', triggerEvent, false)
156
- window.addEventListener('mousedown', triggerEvent, false)
157
- window.addEventListener('click', triggerEvent, false)
158
- window.addEventListener('blur', triggerEvent, false)
159
- window.addEventListener('resize', triggerEvent, false)
160
- window.addEventListener(wheelName, XEUtils.throttle(triggerEvent, 100, { leading: true, trailing: false }), { passive: true, capture: false })
161
- }
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
+ PROCESS: 'Process',
24
+ A: 'A',
25
+ X: 'X',
26
+ C: 'C',
27
+ V: 'V',
28
+ D: 'D',
29
+ F: 'F',
30
+ H: 'H',
31
+ M: 'M',
32
+ Y: 'Y',
33
+ Z: 'Z',
34
+ R: 'R',
35
+ P: 'P'
36
+ }
37
+
38
+ const browse = XEUtils.browse()
39
+
40
+ const convertEventKeys: { [key: string]: string } = {
41
+ ' ': 'Spacebar',
42
+ Apps: GLOBAL_EVENT_KEYS.CONTEXT_MENU,
43
+ Del: GLOBAL_EVENT_KEYS.DELETE,
44
+ Up: GLOBAL_EVENT_KEYS.ARROW_UP,
45
+ Down: GLOBAL_EVENT_KEYS.ARROW_DOWN,
46
+ Left: GLOBAL_EVENT_KEYS.ARROW_LEFT,
47
+ Right: GLOBAL_EVENT_KEYS.ARROW_RIGHT
48
+ }
49
+
50
+ // 监听全局事件
51
+ const wheelName = browse.firefox ? 'DOMMouseScroll' : 'mousewheel'
52
+ const eventStore: {
53
+ comp: VxeComponentBaseOptions
54
+ type: string
55
+ cb: (evnt: Event) => void
56
+ }[] = []
57
+
58
+ function triggerEvent(evnt: Event) {
59
+ const isWheel = evnt.type === wheelName
60
+ eventStore.forEach(({ type, cb }) => {
61
+ // 如果被取消冒泡,不再执行
62
+ if (!evnt.cancelBubble) {
63
+ if (type === evnt.type || (isWheel && type === 'mousewheel')) {
64
+ cb(evnt)
65
+ }
66
+ }
67
+ })
68
+ }
69
+
70
+ class VxeComponentEvent {
71
+ $event: Event
72
+ type = ''
73
+ key = ''
74
+ code = ''
75
+ constructor(evnt: Event, params1: any, params2?: any) {
76
+ this.$event = evnt
77
+ if (evnt) {
78
+ if ((evnt as KeyboardEvent).type) {
79
+ this.type = (evnt as KeyboardEvent).type
80
+ }
81
+ if ((evnt as KeyboardEvent).key) {
82
+ this.key = (evnt as KeyboardEvent).key
83
+ }
84
+ if ((evnt as KeyboardEvent).code) {
85
+ this.code = (evnt as KeyboardEvent).code
86
+ }
87
+ }
88
+ Object.assign(this, params1)
89
+ XEUtils.objectEach(params2, (val, key) => {
90
+ if (XEUtils.isFunction(val)) {
91
+ let rest: any = null
92
+ let isRun = false
93
+ Object.defineProperty(this, key, {
94
+ get() {
95
+ if (!isRun) {
96
+ isRun = true
97
+ rest = val()
98
+ }
99
+ return rest
100
+ }
101
+ })
102
+ } else {
103
+ ;(this as any)[key] = val
104
+ }
105
+ })
106
+ }
107
+
108
+ stopPropagation() {
109
+ const evnt = this.$event
110
+ if (evnt) {
111
+ evnt.stopPropagation()
112
+ }
113
+ }
114
+
115
+ preventDefault() {
116
+ const evnt = this.$event
117
+ if (evnt) {
118
+ evnt.preventDefault()
119
+ }
120
+ }
121
+ }
122
+
123
+ export const createEvent: VxeGlobalCreateEventMethod = (evnt, params1, params2) => {
124
+ if (evnt instanceof VxeComponentEvent) {
125
+ evnt = evnt.$event
126
+ }
127
+ return new VxeComponentEvent(evnt as Event, params1, params2)
128
+ }
129
+
130
+ export const globalEvents: VxeGlobalEvents = {
131
+ on(comp, type, cb) {
132
+ eventStore.push({ comp, type, cb })
133
+ },
134
+ off(comp, type) {
135
+ XEUtils.remove(eventStore, (item) => item.comp === comp && item.type === type)
136
+ },
137
+ hasKey(evnt, targetKey) {
138
+ if (!targetKey) {
139
+ return false
140
+ }
141
+ const { key } = evnt
142
+ targetKey = targetKey.toLowerCase()
143
+ return key ? targetKey === key.toLowerCase() || !!(convertEventKeys[key] && convertEventKeys[key].toLowerCase() === targetKey) : false
144
+ }
145
+ }
146
+
147
+ if (browse.isDoc) {
148
+ if (!browse.msie) {
149
+ window.addEventListener('copy', triggerEvent, false)
150
+ window.addEventListener('cut', triggerEvent, false)
151
+ window.addEventListener('paste', triggerEvent, false)
152
+ }
153
+ document.addEventListener('scroll', triggerEvent, true)
154
+ document.addEventListener('keydown', triggerEvent, false)
155
+ document.addEventListener('contextmenu', triggerEvent, false)
156
+ window.addEventListener('mousedown', triggerEvent, false)
157
+ window.addEventListener('click', triggerEvent, false)
158
+ window.addEventListener('blur', triggerEvent, false)
159
+ window.addEventListener('resize', triggerEvent, false)
160
+ window.addEventListener(wheelName, XEUtils.throttle(triggerEvent, 100, { leading: true, trailing: false }), { passive: true, capture: false })
161
+ }
@@ -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
@@ -1,63 +1,63 @@
1
- import XEUtils from 'xe-utils'
2
- import { VxeCore } from './core'
3
- import { i18nConfigStore } from './i18nStore'
4
- import { globalConfigStore } from './configStore'
5
-
6
- import { VxeGlobalI18nLocale } from '../../types'
7
-
8
- let checkInstall = false
9
- let cacheMaps: Record<string, string> = {}
10
-
11
- function getDefaultExport (mod: any) {
12
- if (mod && mod.__esModule) {
13
- return mod.default
14
- }
15
- return mod
16
- }
17
-
18
- export function getI18n (key: string, args?: any) {
19
- const { langMaps, language } = i18nConfigStore
20
- const { i18n } = globalConfigStore
21
- if (i18n) {
22
- return `${i18n(key, args) || ''}`
23
- }
24
- if (!checkInstall) {
25
- if (!langMaps[language]) {
26
- console.error(`[vxe core] 语言包未安装。Language not installed. https://${VxeCore.uiVersion ? 'vxeui.com' : 'vxetable.cn'}/#/start/i18n`)
27
- }
28
- checkInstall = true
29
- }
30
- if (!args && cacheMaps[key]) {
31
- return cacheMaps[key]
32
- }
33
- const i18nLabel = XEUtils.toFormatString(XEUtils.get(langMaps[language], key, key), args)
34
- if (!args) {
35
- cacheMaps[key] = i18nLabel
36
- }
37
- return i18nLabel
38
- }
39
-
40
- export function setLanguage (locale: VxeGlobalI18nLocale) {
41
- const { language } = i18nConfigStore
42
- const targetlang = locale || 'zh-CN'
43
- if (language !== targetlang) {
44
- i18nConfigStore.language = targetlang
45
- cacheMaps = {}
46
- }
47
- return VxeCore
48
- }
49
-
50
- export function setI18n (locale: VxeGlobalI18nLocale, data: Record<string, any>) {
51
- i18nConfigStore.langMaps[locale] = Object.assign({}, getDefaultExport(data))
52
- return VxeCore
53
- }
54
-
55
- export function hasLanguage (language: VxeGlobalI18nLocale) {
56
- const { langMaps } = i18nConfigStore
57
- return !!langMaps[language]
58
- }
59
-
60
- export function getLanguage () {
61
- const { language } = i18nConfigStore
62
- return language
63
- }
1
+ import XEUtils from 'xe-utils'
2
+ import { VxeCore } from './core'
3
+ import { i18nConfigStore } from './i18nStore'
4
+ import { globalConfigStore } from './configStore'
5
+
6
+ import { VxeGlobalI18nLocale } from '../../types'
7
+
8
+ let checkInstall = false
9
+ let cacheMaps: Record<string, string> = {}
10
+
11
+ function getDefaultExport(mod: any) {
12
+ if (mod && mod.__esModule) {
13
+ return mod.default
14
+ }
15
+ return mod
16
+ }
17
+
18
+ export function getI18n(key: string, args?: any) {
19
+ const { langMaps, language } = i18nConfigStore
20
+ const { i18n } = globalConfigStore
21
+ if (i18n) {
22
+ return `${i18n(key, args) || ''}`
23
+ }
24
+ if (!checkInstall) {
25
+ if (!langMaps[language]) {
26
+ console.error(`[vxe core] 语言包未安装。Language not installed. https://${VxeCore.uiVersion ? 'vxeui.com' : 'vxetable.cn'}/#/start/i18n`)
27
+ }
28
+ checkInstall = true
29
+ }
30
+ if (!args && cacheMaps[key]) {
31
+ return cacheMaps[key]
32
+ }
33
+ const i18nLabel = XEUtils.toFormatString(XEUtils.get(langMaps[language], key, key), args)
34
+ if (!args) {
35
+ cacheMaps[key] = i18nLabel
36
+ }
37
+ return i18nLabel
38
+ }
39
+
40
+ export function setLanguage(locale: VxeGlobalI18nLocale) {
41
+ const { language } = i18nConfigStore
42
+ const targetlang = locale || 'zh-CN'
43
+ if (language !== targetlang) {
44
+ i18nConfigStore.language = targetlang
45
+ cacheMaps = {}
46
+ }
47
+ return VxeCore
48
+ }
49
+
50
+ export function setI18n(locale: VxeGlobalI18nLocale, data: Record<string, any>) {
51
+ i18nConfigStore.langMaps[locale] = Object.assign({}, getDefaultExport(data))
52
+ return VxeCore
53
+ }
54
+
55
+ export function hasLanguage(language: VxeGlobalI18nLocale) {
56
+ const { langMaps } = i18nConfigStore
57
+ return !!langMaps[language]
58
+ }
59
+
60
+ export function getLanguage() {
61
+ const { language } = i18nConfigStore
62
+ return language
63
+ }
@@ -1,11 +1,11 @@
1
- import { reactive } from 'vue'
2
-
3
- import { VxeGlobalI18nLocale } from '../../types'
4
-
5
- export const i18nConfigStore: {
6
- language: VxeGlobalI18nLocale,
7
- langMaps: Partial<Record<VxeGlobalI18nLocale, any>>
8
- } = reactive({
9
- language: '',
10
- langMaps: {}
11
- })
1
+ import { reactive } from 'vue'
2
+
3
+ import { VxeGlobalI18nLocale } from '../../types'
4
+
5
+ export const i18nConfigStore: {
6
+ language: VxeGlobalI18nLocale
7
+ langMaps: Partial<Record<VxeGlobalI18nLocale, any>>
8
+ } = reactive({
9
+ language: '',
10
+ langMaps: {}
11
+ })
@@ -1,32 +1,32 @@
1
- import { h } from 'vue'
2
- import XEUtils from 'xe-utils'
3
- import { VxeCore } from './core'
4
- import { iconConfigStore } from './iconStore'
5
- import { getSlotVNs } from './vm'
6
-
7
- import { VxeGlobalIcon, VxeGlobalIconConfig } from '../../types'
8
-
9
- export function setIcon (options?: VxeGlobalIcon) {
10
- if (options) {
11
- Object.assign(iconConfigStore, options)
12
- }
13
- return VxeCore
14
- }
15
-
16
- export function getIcon (key: keyof VxeGlobalIcon) {
17
- return arguments.length ? XEUtils.get(iconConfigStore, key) : iconConfigStore
18
- }
19
-
20
- export function renderGlobalIcon (name: keyof VxeGlobalIcon) {
21
- const icon = getIcon(name) as VxeGlobalIconConfig
22
- return renderCustomIcon(icon, name)
23
- }
24
-
25
- export function renderCustomIcon (icon: VxeGlobalIconConfig, name: string) {
26
- if (XEUtils.isFunction(icon)) {
27
- return h('span', {}, getSlotVNs(icon({ name })))
28
- }
29
- return h('i', {
30
- class: icon
31
- })
32
- }
1
+ import { h } from 'vue'
2
+ import XEUtils from 'xe-utils'
3
+ import { VxeCore } from './core'
4
+ import { iconConfigStore } from './iconStore'
5
+ import { getSlotVNs } from './vm'
6
+
7
+ import { VxeGlobalIcon, VxeGlobalIconConfig } from '../../types'
8
+
9
+ export function setIcon(options?: VxeGlobalIcon) {
10
+ if (options) {
11
+ Object.assign(iconConfigStore, options)
12
+ }
13
+ return VxeCore
14
+ }
15
+
16
+ export function getIcon(key: keyof VxeGlobalIcon) {
17
+ return arguments.length ? XEUtils.get(iconConfigStore, key) : iconConfigStore
18
+ }
19
+
20
+ export function renderGlobalIcon(name: keyof VxeGlobalIcon) {
21
+ const icon = getIcon(name) as VxeGlobalIconConfig
22
+ return renderCustomIcon(icon, name)
23
+ }
24
+
25
+ export function renderCustomIcon(icon: VxeGlobalIconConfig, name: string) {
26
+ if (XEUtils.isFunction(icon)) {
27
+ return h('span', {}, getSlotVNs(icon({ name })))
28
+ }
29
+ return h('i', {
30
+ class: icon
31
+ })
32
+ }
@@ -1,3 +1,3 @@
1
- import { VxeGlobalIcon } from '../../types'
2
-
3
- export const iconConfigStore: VxeGlobalIcon = {}
1
+ import { VxeGlobalIcon } from '../../types'
2
+
3
+ export const iconConfigStore: VxeGlobalIcon = {}