Skip to content

Commit da0109b

Browse files
committed
refactor: improve import statements
1 parent 7e5c062 commit da0109b

File tree

6 files changed

+31
-33
lines changed

6 files changed

+31
-33
lines changed

src/ECharts.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,21 @@ import {
1313
nextTick,
1414
watchEffect,
1515
getCurrentInstance,
16-
Vue2,
17-
type PropType,
18-
type InjectionKey
16+
Vue2
1917
} from "vue-demi";
2018
import { init as initChart } from "echarts/core";
19+
20+
import {
21+
usePublicAPI,
22+
useAutoresize,
23+
autoresizeProps,
24+
useLoading,
25+
loadingProps
26+
} from "./composables";
27+
import { isOn, omitOn, unwrapInjected } from "./utils";
28+
import { register, TAG_NAME } from "./wc";
29+
30+
import type { PropType, InjectionKey } from "vue-demi";
2131
import type {
2232
EChartsType,
2333
EventTarget,
@@ -30,15 +40,8 @@ import type {
3040
UpdateOptionsInjection,
3141
Emits
3242
} from "./types";
33-
import {
34-
usePublicAPI,
35-
useAutoresize,
36-
autoresizeProps,
37-
useLoading,
38-
loadingProps
39-
} from "./composables";
40-
import { isOn, omitOn, unwrapInjected } from "./utils";
41-
import { register, TAG_NAME, type EChartsElement } from "./wc";
43+
import type { EChartsElement } from "./wc";
44+
4245
import "./style.css";
4346

4447
const __CSP__ = false;
@@ -75,7 +78,6 @@ export default defineComponent({
7578
inheritAttrs: false,
7679
setup(props, { attrs }) {
7780
const root = shallowRef<EChartsElement>();
78-
const inner = shallowRef<HTMLElement>();
7981
const chart = shallowRef<EChartsType>();
8082
const manualOption = shallowRef<Option>();
8183
const defaultTheme = inject(THEME_KEY, null);
@@ -155,12 +157,12 @@ export default defineComponent({
155157
}
156158

157159
function init(option?: Option) {
158-
if (!inner.value) {
160+
if (!root.value) {
159161
return;
160162
}
161163

162164
const instance = (chart.value = initChart(
163-
inner.value,
165+
root.value,
164166
realTheme.value,
165167
realInitOptions.value
166168
));
@@ -306,7 +308,7 @@ export default defineComponent({
306308

307309
useLoading(chart, loading, loadingOptions);
308310

309-
useAutoresize(chart, autoresize, inner);
311+
useAutoresize(chart, autoresize, root);
310312

311313
onMounted(() => {
312314
init();
@@ -327,7 +329,6 @@ export default defineComponent({
327329
return {
328330
chart,
329331
root,
330-
inner,
331332
setOption,
332333
nonEventAttrs,
333334
nativeListeners,
@@ -344,8 +345,6 @@ export default defineComponent({
344345
) as any;
345346
attrs.ref = "root";
346347
attrs.class = attrs.class ? ["echarts"].concat(attrs.class) : "echarts";
347-
return h(TAG_NAME, attrs, [
348-
h("div", { ref: "inner", class: "vue-echarts-inner" })
349-
]);
348+
return h(TAG_NAME, attrs);
350349
}
351350
});

src/composables/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
import { Ref } from "vue-demi";
3-
import { EChartsType } from "../types";
2+
import type { Ref } from "vue-demi";
3+
import type { EChartsType } from "../types";
44

55
const METHOD_NAMES = [
66
"getWidth",

src/composables/autoresize.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { watch, type Ref, type PropType } from "vue-demi";
1+
import { watch } from "vue-demi";
22
import { throttle } from "echarts/core";
3-
import { type EChartsType } from "../types";
3+
4+
import type { Ref, PropType } from "vue-demi";
5+
import type { EChartsType } from "../types";
46

57
type AutoresizeProp =
68
| boolean

src/composables/loading.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import { unwrapInjected } from "../utils";
2-
import {
3-
inject,
4-
computed,
5-
watchEffect,
6-
type Ref,
7-
type InjectionKey,
8-
type PropType
9-
} from "vue-demi";
2+
import { inject, computed, watchEffect } from "vue-demi";
3+
4+
import type { Ref, InjectionKey, PropType } from "vue-demi";
105
import type { EChartsType, LoadingOptions } from "../types";
116

127
export const LOADING_OPTIONS_KEY =

src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { init } from "echarts/core";
2+
23
import type { SetOptionOpts, ECElementEvent, ElementEvent } from "echarts";
3-
import type { Ref } from "vue";
4+
import type { Ref } from "vue-demi";
45

56
export type Injection<T> = T | null | Ref<T | null> | { value: T | null };
67

src/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { unref, isRef } from "vue-demi";
2+
23
import type { Injection } from "./types";
34

45
type Attrs = {

0 commit comments

Comments
 (0)