Skip to content

Commit 58e7b13

Browse files
committed
feat: improve typings for mouse events
1 parent 0a4601b commit 58e7b13

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 6.4.1
2+
3+
* Improve typings for mouse event params.
4+
15
## 6.4.0
26

37
* Delay the disposal of the ECharts instance to the moment the element is disconnected from the DOM if possible (#433).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-echarts",
3-
"version": "6.4.0",
3+
"version": "6.4.1",
44
"description": "Vue.js component for Apache ECharts.",
55
"author": "GU Yiling <[email protected]>",
66
"scripts": {

src/types.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export type EventTarget = EChartsType | ZRenderType;
2020
type SetOptionType = EChartsType["setOption"];
2121
export type Option = Parameters<SetOptionType>[0];
2222

23-
type EChartsEventName =
23+
type EChartsMouseEventName =
2424
| "click"
2525
| "dblclick"
2626
| "mousedown"
@@ -29,7 +29,8 @@ type EChartsEventName =
2929
| "mouseover"
3030
| "mouseout"
3131
| "globalout"
32-
| "contextmenu"
32+
| "contextmenu";
33+
type EChartsOtherEventName =
3334
| "highlight"
3435
| "downplay"
3536
| "selectchanged"
@@ -77,7 +78,25 @@ type ZRenderEventName =
7778
| "dragover"
7879
| "drop"
7980
| "globalout";
80-
type EventName = EChartsEventName | `zr:${ZRenderEventName}`;
81-
export type Emits = {
82-
[key in EventName]: null;
81+
type OtherEventName = EChartsOtherEventName | `zr:${ZRenderEventName}`;
82+
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+
}
93+
94+
type MouseEmits = {
95+
[k in EChartsMouseEventName]: (params: MouseEventParams) => boolean;
8396
};
97+
98+
type OtherEmits = {
99+
[key in OtherEventName]: null;
100+
};
101+
102+
export type Emits = MouseEmits & OtherEmits;

0 commit comments

Comments
 (0)