feat: make it possible to dynamically change provide values for Vue 2

This commit is contained in:
Justineo
2022-12-17 01:23:29 +08:00
parent 9491a904a0
commit ec124f4bf7
10 changed files with 106 additions and 42 deletions

View File

@ -1,21 +1,21 @@
import { init, SetOptionOpts } from "echarts/core";
import { Ref } from "vue";
import { init, type SetOptionOpts } from "echarts/core";
import type { Ref } from "vue";
export type Injection<T> = T | null | Ref<T | null> | { value: T | null };
type InitType = typeof init;
export type InitParameters = Parameters<InitType>;
export type Theme = NonNullable<InitParameters[1]>;
export type ThemeInjection = Theme | null | Ref<Theme | null>;
export type ThemeInjection = Injection<Theme>;
export type InitOptions = NonNullable<InitParameters[2]>;
export type InitOptionsInjection = InitOptions | null | Ref<InitOptions | null>;
export type InitOptionsInjection = Injection<InitOptions>;
export type UpdateOptions = SetOptionOpts;
export type UpdateOptionsInjection = Injection<UpdateOptions>;
export type EChartsType = ReturnType<InitType>;
type ZRenderType = ReturnType<EChartsType["getZr"]>;
export type EventTarget = EChartsType | ZRenderType;
type SetOptionType = EChartsType["setOption"];
export type Option = Parameters<SetOptionType>[0];
export type UpdateOptions = SetOptionOpts;
export type UpdateOptionsInjection =
| UpdateOptions
| null
| Ref<UpdateOptions | null>;