Skip to content

Commit 0edfb39

Browse files
committed
types: use more precise typings for event handlers, update peer deps for echarts
1 parent ed4bd39 commit 0edfb39

File tree

6 files changed

+57
-60
lines changed

6 files changed

+57
-60
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 6.5.0
2+
3+
* Use more precise typings for all event params.
4+
* Updated peer deps for `echarts` to `^5.4.1`.
5+
16
## 6.4.1
27

38
* Improve typings for mouse event params.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ Drop `<script>` inside your HTML file and access the component via `window.VueEC
227227
```html
228228
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
229229
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
230-
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.4.1"></script>
230+
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.5.0"></script>
231231
```
232232
<!-- vue3Scripts:end -->
233233

@@ -247,7 +247,7 @@ app.component('v-chart', VueECharts)
247247
```html
248248
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
249249
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
250-
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.4.1"></script>
250+
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.5.0"></script>
251251
```
252252
<!-- vue2Scripts:end -->
253253

README.zh-Hans.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ import "echarts";
225225
```html
226226
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
227227
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
228-
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.4.1"></script>
228+
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.5.0"></script>
229229
```
230230
<!-- vue3Scripts:end -->
231231

@@ -245,7 +245,7 @@ app.component('v-chart', VueECharts)
245245
```html
246246
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
247247
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
248-
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.4.1"></script>
248+
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.5.0"></script>
249249
```
250250
<!-- vue2Scripts:end -->
251251

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-echarts",
3-
"version": "6.4.1",
3+
"version": "6.5.0",
44
"description": "Vue.js component for Apache ECharts.",
55
"author": "GU Yiling <[email protected]>",
66
"scripts": {
@@ -40,7 +40,7 @@
4040
"@vue/eslint-config-typescript": "^10.0.0",
4141
"comment-mark": "^1.0.0",
4242
"core-js": "^3.23.0",
43-
"echarts": "^5.3.2",
43+
"echarts": "^5.4.1",
4444
"echarts-liquidfill": "^3.1.0",
4545
"eslint": "^7.20.0",
4646
"eslint-plugin-prettier": "^3.3.1",
@@ -67,7 +67,7 @@
6767
},
6868
"peerDependencies": {
6969
"@vue/composition-api": "^1.0.5",
70-
"echarts": "^5.1.2",
70+
"echarts": "^5.4.1",
7171
"vue": "^2.6.12 || ^3.1.1"
7272
},
7373
"jsdelivr": "dist/index.umd.min.js",

pnpm-lock.yaml

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/types.ts

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { init, type SetOptionOpts } from "echarts/core";
1+
import {
2+
init,
3+
type SetOptionOpts,
4+
type ECElementEvent,
5+
type ElementEvent
6+
} from "echarts/core";
27
import type { Ref } from "vue";
38

49
export type Injection<T> = T | null | Ref<T | null> | { value: T | null };
@@ -20,17 +25,28 @@ export type EventTarget = EChartsType | ZRenderType;
2025
type SetOptionType = EChartsType["setOption"];
2126
export type Option = Parameters<SetOptionType>[0];
2227

23-
type EChartsMouseEventName =
28+
type ElementEventName =
2429
| "click"
2530
| "dblclick"
31+
| "mousewheel"
32+
| "mouseout"
33+
| "mouseover"
34+
| "mouseup"
2635
| "mousedown"
2736
| "mousemove"
28-
| "mouseup"
29-
| "mouseover"
30-
| "mouseout"
31-
| "globalout"
32-
| "contextmenu";
33-
type EChartsOtherEventName =
37+
| "contextmenu"
38+
| "drag"
39+
| "dragstart"
40+
| "dragend"
41+
| "dragenter"
42+
| "dragleave"
43+
| "dragover"
44+
| "drop"
45+
| "globalout";
46+
47+
type ZRenderEventName = `zr:${ElementEventName}`;
48+
49+
type OtherEventName =
3450
| "highlight"
3551
| "downplay"
3652
| "selectchanged"
@@ -57,46 +73,22 @@ type EChartsOtherEventName =
5773
| "brush"
5874
| "brushEnd"
5975
| "brushselected"
60-
| "globalcursortaken"
61-
| "rendered"
62-
| "finished";
63-
type ZRenderEventName =
64-
| "click"
65-
| "dblclick"
66-
| "mousewheel"
67-
| "mouseout"
68-
| "mouseover"
69-
| "mouseup"
70-
| "mousedown"
71-
| "mousemove"
72-
| "contextmenu"
73-
| "drag"
74-
| "dragstart"
75-
| "dragend"
76-
| "dragenter"
77-
| "dragleave"
78-
| "dragover"
79-
| "drop"
80-
| "globalout";
81-
type OtherEventName = EChartsOtherEventName | `zr:${ZRenderEventName}`;
76+
| "globalcursortaken";
8277

83-
// See https://echarts.apache.org/en/api.html#events.Mouse%20events
84-
interface MouseEventParams {
85-
componentType: string;
86-
seriesType: string;
87-
seriesIndex: number;
88-
seriesName: string;
89-
name: string;
90-
dataIndex: number;
91-
color: string;
92-
}
78+
type ElementEmits = {
79+
[key in ElementEventName]: (params: ECElementEvent) => boolean;
80+
};
9381

94-
type MouseEmits = {
95-
[k in EChartsMouseEventName]: (params: MouseEventParams) => boolean;
82+
type ZRenderEmits = {
83+
[key in ZRenderEventName]: (params: ElementEvent) => boolean;
9684
};
9785

9886
type OtherEmits = {
9987
[key in OtherEventName]: null;
10088
};
10189

102-
export type Emits = MouseEmits & OtherEmits;
90+
export type Emits = ElementEmits &
91+
OtherEmits & {
92+
rendered: (params: { elapsedTime: number }) => boolean;
93+
finished: () => boolean;
94+
} & ZRenderEmits;

0 commit comments

Comments
 (0)