mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-10-29 07:56:12 +08:00
feat: improve typings for mouse events
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
## 6.4.1
|
||||
|
||||
* Improve typings for mouse event params.
|
||||
|
||||
## 6.4.0
|
||||
|
||||
* Delay the disposal of the ECharts instance to the moment the element is disconnected from the DOM if possible (#433).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-echarts",
|
||||
"version": "6.4.0",
|
||||
"version": "6.4.1",
|
||||
"description": "Vue.js component for Apache ECharts.",
|
||||
"author": "GU Yiling <justice360@gmail.com>",
|
||||
"scripts": {
|
||||
|
||||
29
src/types.ts
29
src/types.ts
@ -20,7 +20,7 @@ export type EventTarget = EChartsType | ZRenderType;
|
||||
type SetOptionType = EChartsType["setOption"];
|
||||
export type Option = Parameters<SetOptionType>[0];
|
||||
|
||||
type EChartsEventName =
|
||||
type EChartsMouseEventName =
|
||||
| "click"
|
||||
| "dblclick"
|
||||
| "mousedown"
|
||||
@ -29,7 +29,8 @@ type EChartsEventName =
|
||||
| "mouseover"
|
||||
| "mouseout"
|
||||
| "globalout"
|
||||
| "contextmenu"
|
||||
| "contextmenu";
|
||||
type EChartsOtherEventName =
|
||||
| "highlight"
|
||||
| "downplay"
|
||||
| "selectchanged"
|
||||
@ -77,7 +78,25 @@ type ZRenderEventName =
|
||||
| "dragover"
|
||||
| "drop"
|
||||
| "globalout";
|
||||
type EventName = EChartsEventName | `zr:${ZRenderEventName}`;
|
||||
export type Emits = {
|
||||
[key in EventName]: null;
|
||||
type OtherEventName = EChartsOtherEventName | `zr:${ZRenderEventName}`;
|
||||
|
||||
// See https://echarts.apache.org/en/api.html#events.Mouse%20events
|
||||
interface MouseEventParams {
|
||||
componentType: string;
|
||||
seriesType: string;
|
||||
seriesIndex: number;
|
||||
seriesName: string;
|
||||
name: string;
|
||||
dataIndex: number;
|
||||
color: string;
|
||||
}
|
||||
|
||||
type MouseEmits = {
|
||||
[k in EChartsMouseEventName]: (params: MouseEventParams) => boolean;
|
||||
};
|
||||
|
||||
type OtherEmits = {
|
||||
[key in OtherEventName]: null;
|
||||
};
|
||||
|
||||
export type Emits = MouseEmits & OtherEmits;
|
||||
|
||||
Reference in New Issue
Block a user