feat: add basic types for events

This commit is contained in:
Justineo
2022-12-18 19:38:04 +08:00
parent 5f57d3fb1c
commit 0bb1839392
7 changed files with 93 additions and 16 deletions

View File

@ -27,7 +27,8 @@ import type {
InitOptions,
InitOptionsInjection,
UpdateOptions,
UpdateOptionsInjection
UpdateOptionsInjection,
Emits
} from "./types";
import {
usePublicAPI,
@ -66,6 +67,7 @@ export default defineComponent({
...autoresizeProps,
...loadingProps
},
emits: [] as unknown as Emits,
inheritAttrs: false,
setup(props, { attrs }) {
const root = shallowRef<HTMLElement>();

13
src/index.vue2.d.ts vendored
View File

@ -1,6 +1,12 @@
/* eslint-disable @typescript-eslint/ban-types */
import type { Ref, DefineComponent } from "vue-demi";
import type { Option, InitOptions, UpdateOptions, EChartsType } from "./types";
import type {
Option,
InitOptions,
UpdateOptions,
EChartsType,
Emits
} from "./types";
declare const LOADING_OPTIONS_KEY = "ecLoadingOptions";
declare const THEME_KEY = "ecTheme";
@ -47,7 +53,10 @@ declare const Chart: DefineComponent<
},
{},
{},
ChartMethods
ChartMethods,
{},
{},
Emits
>;
export default Chart;

View File

@ -19,3 +19,65 @@ type ZRenderType = ReturnType<EChartsType["getZr"]>;
export type EventTarget = EChartsType | ZRenderType;
type SetOptionType = EChartsType["setOption"];
export type Option = Parameters<SetOptionType>[0];
type EChartsEventName =
| "click"
| "dblclick"
| "mousedown"
| "mousemove"
| "mouseup"
| "mouseover"
| "mouseout"
| "globalout"
| "contextmenu"
| "highlight"
| "downplay"
| "selectchanged"
| "legendselectchanged"
| "legendselected"
| "legendunselected"
| "legendselectall"
| "legendinverseselect"
| "legendscroll"
| "datazoom"
| "datarangeselected"
| "graphroam"
| "georoam"
| "treeroam"
| "timelinechanged"
| "timelineplaychanged"
| "restore"
| "dataviewchanged"
| "magictypechanged"
| "geoselectchanged"
| "geoselected"
| "geounselected"
| "axisareaselected"
| "brush"
| "brushEnd"
| "brushselected"
| "globalcursortaken"
| "rendered"
| "finished";
type ZRenderEventName =
| "click"
| "dblclick"
| "mousewheel"
| "mouseout"
| "mouseover"
| "mouseup"
| "mousedown"
| "mousemove"
| "contextmenu"
| "drag"
| "dragstart"
| "dragend"
| "dragenter"
| "dragleave"
| "dragover"
| "drop"
| "globalout";
type EventName = EChartsEventName | `zr:${ZRenderEventName}`;
export type Emits = {
[key in EventName]: null;
};