@vxe-ui/core 3.4.41 → 3.5.0
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/es/index.d.ts +121 -0
- package/es/index.esm.js +132 -122
- package/es/index.js +144 -0
- package/es/src/base-utils.d.ts +2 -0
- package/es/src/base-utils.js +40 -37
- package/es/src/clipboard.d.ts +2 -0
- package/es/src/clipboard.js +48 -45
- package/es/src/commands.d.ts +2 -0
- package/es/src/commands.js +47 -48
- package/es/src/config.d.ts +13 -0
- package/es/src/config.js +21 -23
- package/es/src/configStore.d.ts +2 -0
- package/es/src/configStore.js +8 -5
- package/es/src/core.d.ts +3 -0
- package/es/src/core.js +11 -7
- package/es/src/dataStore.d.ts +2 -0
- package/es/src/dataStore.js +4 -1
- package/es/src/dom-utils.d.ts +2 -0
- package/es/src/dom-utils.js +65 -68
- package/es/src/event.d.ts +4 -0
- package/es/src/event.js +133 -147
- package/es/src/formats.d.ts +2 -0
- package/es/src/formats.js +47 -48
- package/es/src/i18n.d.ts +6 -0
- package/es/src/i18n.js +54 -47
- package/es/src/i18nStore.d.ts +5 -0
- package/es/src/i18nStore.js +11 -8
- package/es/src/icon.d.ts +6 -0
- package/es/src/icon.js +27 -21
- package/es/src/iconStore.d.ts +2 -0
- package/es/src/iconStore.js +4 -1
- package/es/src/interceptor.d.ts +2 -0
- package/es/src/interceptor.js +52 -54
- package/es/src/log.d.ts +2 -0
- package/es/src/log.js +14 -11
- package/es/src/menus.d.ts +2 -0
- package/es/src/menus.js +47 -48
- package/es/src/mixins.d.ts +36 -0
- package/es/src/mixins.js +229 -236
- package/es/src/permission.d.ts +3 -0
- package/es/src/permission.js +57 -55
- package/es/src/popper-utils.d.ts +2 -0
- package/es/src/popper-utils.js +159 -179
- package/es/src/renderer.d.ts +5 -0
- package/es/src/renderer.js +37 -42
- package/es/src/resize.d.ts +2 -0
- package/es/src/resize.js +60 -70
- package/es/src/scrollbar-utils.d.ts +2 -0
- package/es/src/scrollbar-utils.js +57 -54
- package/es/src/store.d.ts +13 -0
- package/es/src/store.js +43 -45
- package/es/src/theme.d.ts +3 -0
- package/es/src/theme.js +17 -13
- package/es/src/themeStore.d.ts +4 -0
- package/es/src/themeStore.js +5 -2
- package/es/src/validators.d.ts +2 -0
- package/es/src/validators.js +6 -3
- package/es/src/vm.d.ts +2 -0
- package/es/src/vm.js +9 -6
- package/es/src/z-index.d.ts +2 -0
- package/es/src/z-index.js +29 -26
- package/lib/index.common.js +129 -353
- package/lib/index.js +175 -0
- package/lib/index.umd.js +560 -3304
- package/lib/index.umd.min.js +1 -1
- package/lib/src/base-utils.js +39 -13
- package/lib/src/clipboard.js +50 -23
- package/lib/src/commands.js +46 -27
- package/lib/src/config.js +43 -23
- package/lib/src/configStore.js +24 -7
- package/lib/src/core.js +29 -11
- package/lib/src/dataStore.js +22 -5
- package/lib/src/dom-utils.js +40 -20
- package/lib/src/event.js +95 -102
- package/lib/src/formats.js +46 -27
- package/lib/src/i18n.js +54 -41
- package/lib/src/i18nStore.js +35 -9
- package/lib/src/icon.js +45 -21
- package/lib/src/iconStore.js +22 -5
- package/lib/src/interceptor.js +40 -18
- package/lib/src/log.js +29 -12
- package/lib/src/menus.js +46 -27
- package/lib/src/mixins.js +67 -83
- package/lib/src/permission.js +40 -17
- package/lib/src/popper-utils.js +71 -71
- package/lib/src/renderer.js +40 -21
- package/lib/src/resize.js +48 -42
- package/lib/src/scrollbar-utils.js +23 -6
- package/lib/src/store.js +44 -25
- package/lib/src/theme.js +31 -14
- package/lib/src/themeStore.js +24 -7
- package/lib/src/validators.js +34 -10
- package/lib/src/vm.js +34 -8
- package/lib/src/z-index.js +38 -12
- package/package.json +17 -3
- package/packages/index.ts +166 -166
- package/packages/src/base-utils.ts +42 -43
- package/packages/src/clipboard.ts +56 -56
- package/packages/src/commands.ts +56 -56
- package/packages/src/config.ts +30 -30
- package/packages/src/configStore.ts +8 -8
- package/packages/src/core.ts +11 -11
- package/packages/src/dataStore.ts +3 -4
- package/packages/src/dom-utils.ts +86 -87
- package/packages/src/event.ts +161 -161
- package/packages/src/formats.ts +56 -56
- package/packages/src/i18n.ts +66 -66
- package/packages/src/i18nStore.ts +16 -16
- package/packages/src/icon.ts +32 -32
- package/packages/src/iconStore.ts +3 -3
- package/packages/src/interceptor.ts +64 -64
- package/packages/src/log.ts +19 -19
- package/packages/src/menus.ts +56 -56
- package/packages/src/mixins.ts +284 -292
- package/packages/src/permission.ts +61 -61
- package/packages/src/popper-utils.ts +197 -194
- package/packages/src/renderer.ts +50 -50
- package/packages/src/resize.ts +89 -89
- package/packages/src/scrollbar-utils.ts +58 -58
- package/packages/src/store.ts +47 -47
- package/packages/src/theme.ts +20 -20
- package/packages/src/themeStore.ts +7 -7
- package/packages/src/validators.ts +7 -7
- package/packages/src/vm.ts +10 -10
- package/packages/src/z-index.ts +30 -30
- package/types/core/index.d.ts +2 -0
- package/lib/src/base-utils.min.js +0 -1
- package/lib/src/clipboard.min.js +0 -1
- package/lib/src/commands.min.js +0 -1
- package/lib/src/config.min.js +0 -1
- package/lib/src/configStore.min.js +0 -1
- package/lib/src/core.min.js +0 -1
- package/lib/src/dataStore.min.js +0 -1
- package/lib/src/dom-utils.min.js +0 -1
- package/lib/src/event.min.js +0 -1
- package/lib/src/formats.min.js +0 -1
- package/lib/src/i18n.min.js +0 -1
- package/lib/src/i18nStore.min.js +0 -1
- package/lib/src/icon.min.js +0 -1
- package/lib/src/iconStore.min.js +0 -1
- package/lib/src/interceptor.min.js +0 -1
- package/lib/src/log.min.js +0 -1
- package/lib/src/menus.min.js +0 -1
- package/lib/src/mixins.min.js +0 -1
- package/lib/src/permission.min.js +0 -1
- package/lib/src/popper-utils.min.js +0 -1
- package/lib/src/renderer.min.js +0 -1
- package/lib/src/resize.min.js +0 -1
- package/lib/src/scrollbar-utils.min.js +0 -1
- package/lib/src/store.min.js +0 -1
- package/lib/src/theme.min.js +0 -1
- package/lib/src/themeStore.min.js +0 -1
- package/lib/src/validators.min.js +0 -1
- package/lib/src/vm.min.js +0 -1
- package/lib/src/z-index.min.js +0 -1
package/es/src/event.js
CHANGED
|
@@ -1,165 +1,151 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import XEUtils from "xe-utils";
|
|
5
|
+
const GLOBAL_EVENT_KEYS = {
|
|
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"
|
|
33
36
|
};
|
|
34
37
|
const browse = XEUtils.browse();
|
|
35
38
|
const convertEventKeys = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
" ": "Spacebar",
|
|
40
|
+
Apps: GLOBAL_EVENT_KEYS.CONTEXT_MENU,
|
|
41
|
+
Del: GLOBAL_EVENT_KEYS.DELETE,
|
|
42
|
+
Up: GLOBAL_EVENT_KEYS.ARROW_UP,
|
|
43
|
+
Down: GLOBAL_EVENT_KEYS.ARROW_DOWN,
|
|
44
|
+
Left: GLOBAL_EVENT_KEYS.ARROW_LEFT,
|
|
45
|
+
Right: GLOBAL_EVENT_KEYS.ARROW_RIGHT
|
|
43
46
|
};
|
|
44
|
-
|
|
45
|
-
const wheelName = browse.firefox ? 'DOMMouseScroll' : 'mousewheel';
|
|
47
|
+
const wheelName = browse.firefox ? "DOMMouseScroll" : "mousewheel";
|
|
46
48
|
const eventStore = [];
|
|
47
49
|
function triggerEvent(evnt) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
50
|
+
const isWheel = evnt.type === wheelName;
|
|
51
|
+
eventStore.forEach(({ type, cb }) => {
|
|
52
|
+
if (!evnt.cancelBubble) {
|
|
53
|
+
if (type === evnt.type || isWheel && type === "mousewheel") {
|
|
54
|
+
cb(evnt);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
57
58
|
}
|
|
58
59
|
class VxeComponentEvent {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (evnt.type) {
|
|
87
|
-
this.type = evnt.type;
|
|
88
|
-
}
|
|
89
|
-
if (evnt.key) {
|
|
90
|
-
this.key = evnt.key;
|
|
91
|
-
}
|
|
92
|
-
if (evnt.code) {
|
|
93
|
-
this.code = evnt.code;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
Object.assign(this, params1);
|
|
97
|
-
XEUtils.objectEach(params2, (val, key) => {
|
|
98
|
-
if (XEUtils.isFunction(val)) {
|
|
99
|
-
let rest = null;
|
|
100
|
-
let isRun = false;
|
|
101
|
-
Object.defineProperty(this, key, {
|
|
102
|
-
get() {
|
|
103
|
-
if (!isRun) {
|
|
104
|
-
isRun = true;
|
|
105
|
-
rest = val();
|
|
106
|
-
}
|
|
107
|
-
return rest;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
this[key] = val;
|
|
60
|
+
constructor(evnt, params1, params2) {
|
|
61
|
+
__publicField(this, "$event");
|
|
62
|
+
__publicField(this, "type", "");
|
|
63
|
+
__publicField(this, "key", "");
|
|
64
|
+
__publicField(this, "code", "");
|
|
65
|
+
this.$event = evnt;
|
|
66
|
+
if (evnt) {
|
|
67
|
+
if (evnt.type) {
|
|
68
|
+
this.type = evnt.type;
|
|
69
|
+
}
|
|
70
|
+
if (evnt.key) {
|
|
71
|
+
this.key = evnt.key;
|
|
72
|
+
}
|
|
73
|
+
if (evnt.code) {
|
|
74
|
+
this.code = evnt.code;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
Object.assign(this, params1);
|
|
78
|
+
XEUtils.objectEach(params2, (val, key) => {
|
|
79
|
+
if (XEUtils.isFunction(val)) {
|
|
80
|
+
let rest = null;
|
|
81
|
+
let isRun = false;
|
|
82
|
+
Object.defineProperty(this, key, {
|
|
83
|
+
get() {
|
|
84
|
+
if (!isRun) {
|
|
85
|
+
isRun = true;
|
|
86
|
+
rest = val();
|
|
113
87
|
}
|
|
88
|
+
return rest;
|
|
89
|
+
}
|
|
114
90
|
});
|
|
91
|
+
} else {
|
|
92
|
+
;
|
|
93
|
+
this[key] = val;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
stopPropagation() {
|
|
98
|
+
const evnt = this.$event;
|
|
99
|
+
if (evnt) {
|
|
100
|
+
evnt.stopPropagation();
|
|
115
101
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
preventDefault() {
|
|
123
|
-
const evnt = this.$event;
|
|
124
|
-
if (evnt) {
|
|
125
|
-
evnt.preventDefault();
|
|
126
|
-
}
|
|
102
|
+
}
|
|
103
|
+
preventDefault() {
|
|
104
|
+
const evnt = this.$event;
|
|
105
|
+
if (evnt) {
|
|
106
|
+
evnt.preventDefault();
|
|
127
107
|
}
|
|
108
|
+
}
|
|
128
109
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
110
|
+
const createEvent = (evnt, params1, params2) => {
|
|
111
|
+
if (evnt instanceof VxeComponentEvent) {
|
|
112
|
+
evnt = evnt.$event;
|
|
113
|
+
}
|
|
114
|
+
return new VxeComponentEvent(evnt, params1, params2);
|
|
134
115
|
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
const { key } = evnt;
|
|
147
|
-
targetKey = targetKey.toLowerCase();
|
|
148
|
-
return key ? (targetKey === key.toLowerCase() || !!(convertEventKeys[key] && convertEventKeys[key].toLowerCase() === targetKey)) : false;
|
|
116
|
+
const globalEvents = {
|
|
117
|
+
on(comp, type, cb) {
|
|
118
|
+
eventStore.push({ comp, type, cb });
|
|
119
|
+
},
|
|
120
|
+
off(comp, type) {
|
|
121
|
+
XEUtils.remove(eventStore, (item) => item.comp === comp && item.type === type);
|
|
122
|
+
},
|
|
123
|
+
hasKey(evnt, targetKey) {
|
|
124
|
+
if (!targetKey) {
|
|
125
|
+
return false;
|
|
149
126
|
}
|
|
127
|
+
const { key } = evnt;
|
|
128
|
+
targetKey = targetKey.toLowerCase();
|
|
129
|
+
return key ? targetKey === key.toLowerCase() || !!(convertEventKeys[key] && convertEventKeys[key].toLowerCase() === targetKey) : false;
|
|
130
|
+
}
|
|
150
131
|
};
|
|
151
132
|
if (browse.isDoc) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
133
|
+
if (!browse.msie) {
|
|
134
|
+
window.addEventListener("copy", triggerEvent, false);
|
|
135
|
+
window.addEventListener("cut", triggerEvent, false);
|
|
136
|
+
window.addEventListener("paste", triggerEvent, false);
|
|
137
|
+
}
|
|
138
|
+
document.addEventListener("scroll", triggerEvent, true);
|
|
139
|
+
document.addEventListener("keydown", triggerEvent, false);
|
|
140
|
+
document.addEventListener("contextmenu", triggerEvent, false);
|
|
141
|
+
window.addEventListener("click", triggerEvent, false);
|
|
142
|
+
window.addEventListener("mousedown", triggerEvent, false);
|
|
143
|
+
window.addEventListener("blur", triggerEvent, false);
|
|
144
|
+
window.addEventListener("resize", triggerEvent, false);
|
|
145
|
+
window.addEventListener(wheelName, XEUtils.throttle(triggerEvent, 100, { leading: true, trailing: false }), { passive: true, capture: false });
|
|
165
146
|
}
|
|
147
|
+
export {
|
|
148
|
+
GLOBAL_EVENT_KEYS,
|
|
149
|
+
createEvent,
|
|
150
|
+
globalEvents
|
|
151
|
+
};
|
package/es/src/formats.js
CHANGED
|
@@ -1,51 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import XEUtils from "xe-utils";
|
|
5
|
+
import { log } from "./log";
|
|
3
6
|
class VXEFormatsStore {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// 兼容
|
|
27
|
-
if (XEUtils.isFunction(render)) {
|
|
28
|
-
log.warn('vxe.error.delProp', ['formats -> callback', 'cellFormatMethod']);
|
|
29
|
-
render = {
|
|
30
|
-
cellFormatMethod: render
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
// 检测是否覆盖
|
|
34
|
-
const confKeys = XEUtils.keys(conf);
|
|
35
|
-
XEUtils.each(render, (item, key) => {
|
|
36
|
-
if (confKeys.includes(key)) {
|
|
37
|
-
log.warn('vxe.error.coverProp', [name, key]);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
this.store[name] = conf ? XEUtils.merge(conf, render) : render;
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
delete(name) {
|
|
44
|
-
delete this.store[name];
|
|
45
|
-
}
|
|
46
|
-
forEach(callback) {
|
|
47
|
-
XEUtils.objectEach(this.store, callback);
|
|
7
|
+
constructor() {
|
|
8
|
+
__publicField(this, "store", {});
|
|
9
|
+
}
|
|
10
|
+
mixin(options) {
|
|
11
|
+
XEUtils.each(options, (item, key) => {
|
|
12
|
+
this.add(key, item);
|
|
13
|
+
});
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
has(name) {
|
|
17
|
+
return !!this.get(name);
|
|
18
|
+
}
|
|
19
|
+
get(name) {
|
|
20
|
+
return this.store[name];
|
|
21
|
+
}
|
|
22
|
+
add(name, render) {
|
|
23
|
+
const conf = this.store[name];
|
|
24
|
+
if (XEUtils.isFunction(render)) {
|
|
25
|
+
log.warn("vxe.error.delProp", ["formats -> callback", "cellFormatMethod"]);
|
|
26
|
+
render = {
|
|
27
|
+
cellFormatMethod: render
|
|
28
|
+
};
|
|
48
29
|
}
|
|
30
|
+
const confKeys = XEUtils.keys(conf);
|
|
31
|
+
XEUtils.each(render, (item, key) => {
|
|
32
|
+
if (confKeys.includes(key)) {
|
|
33
|
+
log.warn("vxe.error.coverProp", [name, key]);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
this.store[name] = conf ? XEUtils.merge(conf, render) : render;
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
delete(name) {
|
|
40
|
+
delete this.store[name];
|
|
41
|
+
}
|
|
42
|
+
forEach(callback) {
|
|
43
|
+
XEUtils.objectEach(this.store, callback);
|
|
44
|
+
}
|
|
49
45
|
}
|
|
50
|
-
|
|
51
|
-
Object.assign(formats, { _name:
|
|
46
|
+
const formats = new VXEFormatsStore();
|
|
47
|
+
Object.assign(formats, { _name: "Formats" });
|
|
48
|
+
export {
|
|
49
|
+
formats
|
|
50
|
+
};
|
package/es/src/i18n.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { VxeGlobalI18nLocale } from '../../types';
|
|
2
|
+
export declare function getI18n(key: string, args?: any): string;
|
|
3
|
+
export declare function setLanguage(locale: VxeGlobalI18nLocale): import("../../types").VxeUIExport;
|
|
4
|
+
export declare function setI18n(locale: VxeGlobalI18nLocale, data: Record<string, any>): import("../../types").VxeUIExport;
|
|
5
|
+
export declare function hasLanguage(language: VxeGlobalI18nLocale): boolean;
|
|
6
|
+
export declare function getLanguage(): VxeGlobalI18nLocale;
|
package/es/src/i18n.js
CHANGED
|
@@ -1,57 +1,64 @@
|
|
|
1
|
-
import XEUtils from
|
|
2
|
-
import { VxeCore } from
|
|
3
|
-
import { i18nConfigStore } from
|
|
4
|
-
import { globalConfigStore } from
|
|
1
|
+
import XEUtils from "xe-utils";
|
|
2
|
+
import { VxeCore } from "./core";
|
|
3
|
+
import { i18nConfigStore } from "./i18nStore";
|
|
4
|
+
import { globalConfigStore } from "./configStore";
|
|
5
5
|
let checkInstall = false;
|
|
6
6
|
let cacheMaps = {};
|
|
7
7
|
function getDefaultExport(mod) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
if (mod && mod.__esModule) {
|
|
9
|
+
return mod.default;
|
|
10
|
+
}
|
|
11
|
+
return mod;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
checkInstall = true;
|
|
24
|
-
}
|
|
25
|
-
if (!args && cacheMaps[key]) {
|
|
26
|
-
return cacheMaps[key];
|
|
13
|
+
function getI18n(key, args) {
|
|
14
|
+
const { langMaps, language } = i18nConfigStore;
|
|
15
|
+
const { i18n } = globalConfigStore;
|
|
16
|
+
if (i18n) {
|
|
17
|
+
return `${i18n(key, args) || ""}`;
|
|
18
|
+
}
|
|
19
|
+
if (!checkInstall) {
|
|
20
|
+
if (!langMaps[language]) {
|
|
21
|
+
console.error(`[vxe core] 语言包未安装。Language not installed. https://${VxeCore.uiVersion ? "vxeui.com" : "vxetable.cn"}/#/start/i18n`);
|
|
27
22
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
checkInstall = true;
|
|
24
|
+
}
|
|
25
|
+
if (!args && cacheMaps[key]) {
|
|
26
|
+
return cacheMaps[key];
|
|
27
|
+
}
|
|
28
|
+
const i18nLabel = XEUtils.toFormatString(XEUtils.get(langMaps[language], key, key), args);
|
|
29
|
+
if (!args) {
|
|
30
|
+
cacheMaps[key] = i18nLabel;
|
|
31
|
+
}
|
|
32
|
+
return i18nLabel;
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
function setLanguage(locale) {
|
|
35
|
+
const { language } = i18nConfigStore;
|
|
36
|
+
const targetlang = locale || "zh-CN";
|
|
37
|
+
if (language !== targetlang) {
|
|
38
|
+
i18nConfigStore.language = targetlang;
|
|
39
|
+
cacheMaps = {};
|
|
40
|
+
}
|
|
41
|
+
return VxeCore;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
function setI18n(locale, data) {
|
|
44
|
+
const { langMaps } = i18nConfigStore;
|
|
45
|
+
i18nConfigStore.langMaps = Object.assign({}, langMaps, {
|
|
46
|
+
[locale]: Object.assign({}, getDefaultExport(data))
|
|
47
|
+
});
|
|
48
|
+
return VxeCore;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
function hasLanguage(language) {
|
|
51
|
+
const { langMaps } = i18nConfigStore;
|
|
52
|
+
return !!langMaps[language];
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
function getLanguage() {
|
|
55
|
+
const { language } = i18nConfigStore;
|
|
56
|
+
return language;
|
|
57
57
|
}
|
|
58
|
+
export {
|
|
59
|
+
getI18n,
|
|
60
|
+
getLanguage,
|
|
61
|
+
hasLanguage,
|
|
62
|
+
setI18n,
|
|
63
|
+
setLanguage
|
|
64
|
+
};
|
package/es/src/i18nStore.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import Vue from
|
|
1
|
+
import Vue from "vue";
|
|
2
2
|
const I18nStore = Vue.extend({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
data() {
|
|
4
|
+
return {
|
|
5
|
+
language: "",
|
|
6
|
+
langMaps: {}
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
9
|
});
|
|
10
|
-
|
|
10
|
+
const i18nConfigStore = new I18nStore();
|
|
11
|
+
export {
|
|
12
|
+
i18nConfigStore
|
|
13
|
+
};
|
package/es/src/icon.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CreateElement } from 'vue';
|
|
2
|
+
import { VxeGlobalIcon, VxeGlobalIconConfig } from '../../types';
|
|
3
|
+
export declare function setIcon(options?: VxeGlobalIcon): import("../../types").VxeUIExport;
|
|
4
|
+
export declare function getIcon(key: keyof VxeGlobalIcon): VxeGlobalIconConfig | VxeGlobalIcon | undefined;
|
|
5
|
+
export declare function renderGlobalIcon(h: CreateElement, name: keyof VxeGlobalIcon): import("vue").VNode;
|
|
6
|
+
export declare function renderCustomIcon(h: CreateElement, icon: VxeGlobalIconConfig, name: string): import("vue").VNode;
|
package/es/src/icon.js
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
|
-
import XEUtils from
|
|
2
|
-
import { VxeCore } from
|
|
3
|
-
import { iconConfigStore } from
|
|
4
|
-
import { getSlotVNs } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import XEUtils from "xe-utils";
|
|
2
|
+
import { VxeCore } from "./core";
|
|
3
|
+
import { iconConfigStore } from "./iconStore";
|
|
4
|
+
import { getSlotVNs } from "./vm";
|
|
5
|
+
function setIcon(options) {
|
|
6
|
+
if (options) {
|
|
7
|
+
Object.assign(iconConfigStore, options);
|
|
8
|
+
}
|
|
9
|
+
return VxeCore;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
function getIcon(key) {
|
|
12
|
+
return arguments.length ? XEUtils.get(iconConfigStore, key) : iconConfigStore;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
function renderGlobalIcon(h, name) {
|
|
15
|
+
const icon = getIcon(name);
|
|
16
|
+
return renderCustomIcon(h, icon, name);
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
function renderCustomIcon(h, icon, name) {
|
|
19
|
+
if (XEUtils.isFunction(icon)) {
|
|
20
|
+
return h("span", {}, getSlotVNs(icon({ name })));
|
|
21
|
+
}
|
|
22
|
+
return h("i", {
|
|
23
|
+
class: icon
|
|
24
|
+
});
|
|
25
25
|
}
|
|
26
|
+
export {
|
|
27
|
+
getIcon,
|
|
28
|
+
renderCustomIcon,
|
|
29
|
+
renderGlobalIcon,
|
|
30
|
+
setIcon
|
|
31
|
+
};
|
package/es/src/iconStore.js
CHANGED