nuxt-echarts 0.3.1 → 0.3.2
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/dist/module.json +1 -1
- package/dist/runtime/components/VChart.js +29 -31
- package/dist/runtime/components/VChartServer.vue +16 -16
- package/dist/runtime/composables/autoresize.js +3 -0
- package/dist/runtime/composables/loading.js +2 -2
- package/dist/runtime/types.d.ts +2 -4
- package/package.json +13 -12
package/dist/module.json
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
defineComponent,
|
|
3
3
|
shallowRef,
|
|
4
4
|
toRefs,
|
|
5
|
-
|
|
5
|
+
toValue,
|
|
6
6
|
watch,
|
|
7
7
|
computed,
|
|
8
8
|
inject,
|
|
@@ -55,36 +55,43 @@ export default defineComponent({
|
|
|
55
55
|
const realOption = computed(
|
|
56
56
|
() => manualOption.value || props.option || null
|
|
57
57
|
);
|
|
58
|
-
const realTheme = computed(() => props.theme ||
|
|
58
|
+
const realTheme = computed(() => props.theme || toValue(defaultTheme) || {});
|
|
59
59
|
const realInitOptions = computed(
|
|
60
|
-
() => props.initOptions ||
|
|
60
|
+
() => props.initOptions || toValue(defaultInitOptions) || {}
|
|
61
61
|
);
|
|
62
62
|
const realUpdateOptions = computed(
|
|
63
|
-
() => props.updateOptions ||
|
|
63
|
+
() => props.updateOptions || toValue(defaultUpdateOptions) || {}
|
|
64
64
|
);
|
|
65
65
|
const nativeListeners = shallowRef({});
|
|
66
66
|
const realAttrs = computed(() => ({
|
|
67
67
|
...omitOn(attrs),
|
|
68
68
|
...nativeListeners.value
|
|
69
69
|
}));
|
|
70
|
-
const
|
|
71
|
-
function
|
|
70
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
71
|
+
function collectListeners() {
|
|
72
72
|
const _nativeListeners = {};
|
|
73
73
|
Object.keys(attrs).filter((key) => isOn(key)).forEach((key) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const nativeKey = `on${event.charAt(7).toUpperCase()}${event.slice(
|
|
77
|
-
8
|
|
78
|
-
)}`;
|
|
74
|
+
if (key.indexOf("Native:") === 2) {
|
|
75
|
+
const nativeKey = `on${key.charAt(9).toUpperCase()}${key.slice(10)}`;
|
|
79
76
|
_nativeListeners[nativeKey] = attrs[key];
|
|
80
77
|
return;
|
|
81
78
|
}
|
|
79
|
+
let event = key.charAt(2).toLowerCase() + key.slice(3);
|
|
80
|
+
let zr;
|
|
81
|
+
if (event.indexOf("zr:") === 0) {
|
|
82
|
+
zr = true;
|
|
83
|
+
event = event.substring(3);
|
|
84
|
+
}
|
|
85
|
+
let once;
|
|
82
86
|
if (event.substring(event.length - 4) === "Once") {
|
|
83
|
-
|
|
87
|
+
once = true;
|
|
88
|
+
event = event.substring(0, event.length - 4);
|
|
84
89
|
}
|
|
85
|
-
|
|
90
|
+
listeners.set({ event, zr, once }, attrs[key]);
|
|
86
91
|
});
|
|
87
92
|
nativeListeners.value = _nativeListeners;
|
|
93
|
+
}
|
|
94
|
+
function init(option) {
|
|
88
95
|
if (!root.value) {
|
|
89
96
|
return;
|
|
90
97
|
}
|
|
@@ -96,23 +103,12 @@ export default defineComponent({
|
|
|
96
103
|
if (props.group) {
|
|
97
104
|
instance.group = props.group;
|
|
98
105
|
}
|
|
99
|
-
|
|
100
|
-
let handler = realListeners[key];
|
|
106
|
+
listeners.forEach((handler, { zr, once, event }) => {
|
|
101
107
|
if (!handler) {
|
|
102
108
|
return;
|
|
103
109
|
}
|
|
104
|
-
|
|
105
|
-
if (
|
|
106
|
-
event = event.substring(1);
|
|
107
|
-
handler.__once__ = true;
|
|
108
|
-
}
|
|
109
|
-
let target = instance;
|
|
110
|
-
if (event.indexOf("zr:") === 0) {
|
|
111
|
-
target = instance.getZr();
|
|
112
|
-
event = event.substring(3);
|
|
113
|
-
}
|
|
114
|
-
if (handler.__once__) {
|
|
115
|
-
delete handler.__once__;
|
|
110
|
+
const target = zr ? instance.getZr() : instance;
|
|
111
|
+
if (once) {
|
|
116
112
|
const raw = handler;
|
|
117
113
|
handler = (...args) => {
|
|
118
114
|
raw(...args);
|
|
@@ -210,6 +206,7 @@ export default defineComponent({
|
|
|
210
206
|
useLoading(chart, loading, loadingOptions);
|
|
211
207
|
useAutoresize(chart, autoresize, root);
|
|
212
208
|
onMounted(async () => {
|
|
209
|
+
collectListeners();
|
|
213
210
|
if (!root.value) await nextTick();
|
|
214
211
|
init();
|
|
215
212
|
});
|
|
@@ -230,9 +227,10 @@ export default defineComponent({
|
|
|
230
227
|
};
|
|
231
228
|
},
|
|
232
229
|
render() {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
230
|
+
return h(TAG_NAME, {
|
|
231
|
+
...this.realAttrs,
|
|
232
|
+
ref: "root",
|
|
233
|
+
class: ["echarts", ...this.realAttrs.class || []]
|
|
234
|
+
});
|
|
237
235
|
}
|
|
238
236
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed,
|
|
2
|
+
import { computed, inject, ref, toValue } from "vue";
|
|
3
3
|
import { THEME_KEY, INIT_OPTIONS_KEY } from "../utils/injection";
|
|
4
4
|
const defaultTheme = inject(THEME_KEY, null);
|
|
5
5
|
const defaultInitOptions = inject(INIT_OPTIONS_KEY, null);
|
|
@@ -9,9 +9,9 @@ const props = defineProps({
|
|
|
9
9
|
initOptions: { type: null, required: false }
|
|
10
10
|
});
|
|
11
11
|
const emits = defineEmits(["error"]);
|
|
12
|
-
const realTheme = computed(() => props.theme ||
|
|
12
|
+
const realTheme = computed(() => props.theme || toValue(defaultTheme) || {});
|
|
13
13
|
const realInitOptions = computed(
|
|
14
|
-
() => props.initOptions ||
|
|
14
|
+
() => props.initOptions || toValue(defaultInitOptions) || {}
|
|
15
15
|
);
|
|
16
16
|
function onError(e) {
|
|
17
17
|
if (e instanceof TypeError && e.message === "Cannot read properties of undefined (reading 'link')") {
|
|
@@ -23,17 +23,17 @@ const root = ref(null);
|
|
|
23
23
|
</script>
|
|
24
24
|
|
|
25
25
|
<template>
|
|
26
|
-
<div class="vue-echarts-server">
|
|
27
|
-
<VChartIsland
|
|
28
|
-
ref="root"
|
|
29
|
-
:theme="realTheme"
|
|
30
|
-
:option="option"
|
|
31
|
-
:init-options="realInitOptions"
|
|
32
|
-
@error="onError"
|
|
33
|
-
>
|
|
34
|
-
<template #fallback>
|
|
35
|
-
<slot name="fallback" />
|
|
36
|
-
</template>
|
|
37
|
-
</VChartIsland>
|
|
38
|
-
</div>
|
|
26
|
+
<div class="vue-echarts-server">
|
|
27
|
+
<VChartIsland
|
|
28
|
+
ref="root"
|
|
29
|
+
:theme="realTheme"
|
|
30
|
+
:option="option"
|
|
31
|
+
:init-options="realInitOptions"
|
|
32
|
+
@error="onError"
|
|
33
|
+
>
|
|
34
|
+
<template #fallback>
|
|
35
|
+
<slot name="fallback" />
|
|
36
|
+
</template>
|
|
37
|
+
</VChartIsland>
|
|
38
|
+
</div>
|
|
39
39
|
</template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
toValue,
|
|
3
3
|
inject,
|
|
4
4
|
computed,
|
|
5
5
|
watchEffect
|
|
@@ -8,7 +8,7 @@ export const LOADING_OPTIONS_KEY = "ecLoadingOptions";
|
|
|
8
8
|
export function useLoading(chart, loading, loadingOptions) {
|
|
9
9
|
const defaultLoadingOptions = inject(LOADING_OPTIONS_KEY, {});
|
|
10
10
|
const realLoadingOptions = computed(() => ({
|
|
11
|
-
...
|
|
11
|
+
...toValue(defaultLoadingOptions) || {},
|
|
12
12
|
...loadingOptions?.value
|
|
13
13
|
}));
|
|
14
14
|
watchEffect(() => {
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { init, SetOptionOpts, ECElementEvent, ElementEvent } from 'echarts/core';
|
|
2
|
-
import type {
|
|
3
|
-
export type Injection<T> =
|
|
2
|
+
import type { MaybeRefOrGetter } from 'vue';
|
|
3
|
+
export type Injection<T> = MaybeRefOrGetter<T | null>;
|
|
4
4
|
type InitType = typeof init;
|
|
5
5
|
export type InitParameters = Parameters<InitType>;
|
|
6
6
|
export type Theme = NonNullable<InitParameters[1]>;
|
|
@@ -10,8 +10,6 @@ export type InitOptionsInjection = Injection<InitOptions>;
|
|
|
10
10
|
export type UpdateOptions = SetOptionOpts;
|
|
11
11
|
export type UpdateOptionsInjection = Injection<UpdateOptions>;
|
|
12
12
|
export type EChartsType = ReturnType<InitType>;
|
|
13
|
-
type ZRenderType = ReturnType<EChartsType['getZr']>;
|
|
14
|
-
export type EventTarget = EChartsType | ZRenderType;
|
|
15
13
|
type SetOptionType = EChartsType['setOption'];
|
|
16
14
|
export type Option = Parameters<SetOptionType>[0];
|
|
17
15
|
export type LoadingOptions = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-echarts",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Nuxt Module for Apache ECharts™",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"repository": "kingyue737/nuxt-echarts",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"type": "module",
|
|
17
|
-
"packageManager": "pnpm@10.
|
|
17
|
+
"packageManager": "pnpm@10.11.0",
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
20
|
"types": "./dist/types.d.mts",
|
|
@@ -43,23 +43,24 @@
|
|
|
43
43
|
"test:types": "vue-tsc --noEmit && nuxi typecheck playground"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@nuxt/kit": "^3.17.
|
|
47
|
-
"echarts": "^5.6.0"
|
|
46
|
+
"@nuxt/kit": "^3.17.4"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
|
-
"@nuxt/eslint-config": "^1.
|
|
49
|
+
"@nuxt/eslint-config": "^1.4.1",
|
|
51
50
|
"@nuxt/module-builder": "^1.0.1",
|
|
52
|
-
"@nuxt/schema": "^3.17.
|
|
53
|
-
"@nuxt/test-utils": "^3.
|
|
54
|
-
"@types/node": "^22.15.
|
|
51
|
+
"@nuxt/schema": "^3.17.4",
|
|
52
|
+
"@nuxt/test-utils": "^3.19.1",
|
|
53
|
+
"@types/node": "^22.15.21",
|
|
55
54
|
"changelogen": "^0.6.1",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
55
|
+
"echarts": "^5.6.0",
|
|
56
|
+
"echarts-gl": "^2.0.9",
|
|
57
|
+
"eslint": "^9.27.0",
|
|
58
|
+
"nuxt": "^3.17.4",
|
|
58
59
|
"prettier": "^3.5.3",
|
|
59
60
|
"prettier-plugin-tailwindcss": "^0.6.11",
|
|
60
61
|
"typescript": "^5.8.3",
|
|
61
62
|
"vite": "^6.3.5",
|
|
62
|
-
"vitest": "^3.1.
|
|
63
|
+
"vitest": "^3.1.4",
|
|
63
64
|
"vue-tsc": "^2.2.10"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|
|
@@ -68,4 +69,4 @@
|
|
|
68
69
|
"stackblitz": {
|
|
69
70
|
"startCommand": "pnpm run dev:prepare && pnpm run dev"
|
|
70
71
|
}
|
|
71
|
-
}
|
|
72
|
+
}
|