@fanciers/echarts-react 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,15 @@
1
1
  import { CanvasRenderer, SVGRenderer } from "echarts/renderers";
2
2
  import React from "react";
3
- import { LineSeriesOption, PieSeriesOption } from "echarts/charts";
4
3
  import * as echarts from "echarts/core";
5
- import { BarSeriesOption, BrushComponentOption, CalendarComponentOption, ComposeOption, DataZoomComponentOption, DatasetComponentOption, EffectScatterSeriesOption, GeoComponentOption, GraphSeriesOption, GraphicComponentOption, GridComponentOption, HeatmapSeriesOption, LegendComponentOption, MarkAreaComponentOption, MarkLineComponentOption, MarkPointComponentOption, MatrixComponentOption, PolarComponentOption, ScatterSeriesOption, SingleAxisComponentOption, TimelineComponentOption, TitleComponentOption, ToolboxComponentOption, TooltipComponentOption, VisualMapComponentOption } from "echarts";
4
+ import { BarSeriesOption, BrushComponentOption, CalendarComponentOption, ComposeOption, DataZoomComponentOption, DatasetComponentOption, EffectScatterSeriesOption, GeoComponentOption, GraphSeriesOption, GraphicComponentOption, GridComponentOption, HeatmapSeriesOption, LegendComponentOption, LineSeriesOption, MarkAreaComponentOption, MarkLineComponentOption, MarkPointComponentOption, MatrixComponentOption, PieSeriesOption, PolarComponentOption, ScatterSeriesOption, SingleAxisComponentOption, SunburstSeriesOption, TimelineComponentOption, TitleComponentOption, ToolboxComponentOption, TooltipComponentOption, VisualMapComponentOption } from "echarts";
6
5
  import { ComponentOption } from "echarts/types/src/util/types.js";
7
6
 
8
7
  //#region src/shared.d.ts
9
-
10
8
  type EChartExt = Parameters<(typeof echarts)['use']>[0];
11
9
  type Simplify<T> = { [K in keyof T]: T[K] } & {};
12
10
  //#endregion
13
11
  //#region src/charts.d.ts
14
- interface ChartBaseProps<T extends readonly ChartComponentType<any>[]> {
12
+ interface ChartBaseProps<T extends readonly ChartComponentType[]> {
15
13
  className?: string;
16
14
  style?: React.CSSProperties;
17
15
  containerProps?: React.HTMLAttributes<HTMLDivElement>;
@@ -19,9 +17,9 @@ interface ChartBaseProps<T extends readonly ChartComponentType<any>[]> {
19
17
  use?: EChartExt;
20
18
  children?: React.ReactNode;
21
19
  }
22
- type InferChartComponentOption<T extends readonly ChartComponentType<any>[], U = T[number]> = U extends ChartComponentType<infer P> ? P : never;
23
- interface ChartComponentType<T extends ComponentOption> {
24
- <U extends readonly ChartComponentType<any>[] = []>(props: ChartBaseProps<U> & echarts.EChartsCoreOption & Simplify<ComposeOption<T | InferChartComponentOption<U>>> & {
20
+ type ResolveComponentOption<T extends ComponentOption | ChartComponentType> = T extends ComponentOption ? T : T extends ChartComponentType<infer P> ? P : never;
21
+ interface ChartComponentType<in T extends ComponentOption = any> {
22
+ <U extends readonly ChartComponentType[] = []>(props: ChartBaseProps<U> & echarts.EChartsCoreOption & Simplify<ComposeOption<ResolveComponentOption<T | U[number]>>> & {
25
23
  ref?: React.Ref<echarts.ECharts>;
26
24
  }): React.JSX.Element;
27
25
  ext: EChartExt;
@@ -33,6 +31,7 @@ declare const HeatmapChart: ChartComponentType<HeatmapSeriesOption>;
33
31
  declare const LineChart: ChartComponentType<GridComponentOption | LineSeriesOption>;
34
32
  declare const PieChart: ChartComponentType<PieSeriesOption>;
35
33
  declare const ScatterChart: ChartComponentType<GridComponentOption | ScatterSeriesOption>;
34
+ declare const SunburstChart: ChartComponentType<SunburstSeriesOption>;
36
35
  //#endregion
37
36
  //#region src/components.d.ts
38
37
  declare const Brush: (props: ComposeOption<BrushComponentOption>) => null;
@@ -57,4 +56,4 @@ declare const VisualMap: (props: ComposeOption<VisualMapComponentOption>) => nul
57
56
  //#region src/features.d.ts
58
57
  declare function AxisBreak(): null;
59
58
  //#endregion
60
- export { AxisBreak, BarChart, Brush, Calendar, CanvasRenderer, DataZoom, Dataset, EffectScatterChart, Geo, GraphChart, Graphic, HeatmapChart, Legend, LineChart, MarkArea, MarkLine, MarkPoint, Matrix, PieChart, Polar, SVGRenderer, ScatterChart, SingleAxis, Timeline, Title, Toolbox, Tooltip, VisualMap, echarts };
59
+ export { AxisBreak, BarChart, Brush, Calendar, CanvasRenderer, DataZoom, Dataset, EffectScatterChart, Geo, GraphChart, Graphic, HeatmapChart, Legend, LineChart, MarkArea, MarkLine, MarkPoint, Matrix, PieChart, Polar, SVGRenderer, ScatterChart, SingleAxis, SunburstChart, Timeline, Title, Toolbox, Tooltip, VisualMap, echarts };
@@ -1,11 +1,10 @@
1
1
  import { CanvasRenderer, SVGRenderer } from "echarts/renderers";
2
2
  import React from "react";
3
- import { BarChart as BarChart$1, EffectScatterChart as EffectScatterChart$1, GraphChart as GraphChart$1, HeatmapChart as HeatmapChart$1, LineChart as LineChart$1, PieChart as PieChart$1, ScatterChart as ScatterChart$1 } from "echarts/charts";
3
+ import { BarChart as BarChart$1, EffectScatterChart as EffectScatterChart$1, GraphChart as GraphChart$1, HeatmapChart as HeatmapChart$1, LineChart as LineChart$1, PieChart as PieChart$1, ScatterChart as ScatterChart$1, SunburstChart as SunburstChart$1 } from "echarts/charts";
4
4
  import { BrushComponent, CalendarComponent, DataZoomComponent, DatasetComponent, GeoComponent, GraphicComponent, GridComponent, LegendComponent, MarkAreaComponent, MarkLineComponent, MarkPointComponent, MatrixComponent, PolarComponent, SingleAxisComponent, TimelineComponent, TitleComponent, ToolboxComponent, TooltipComponent, TransformComponent, VisualMapComponent } from "echarts/components";
5
5
  import * as echarts from "echarts/core";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { AxisBreak as AxisBreak$1 } from "echarts/features";
8
-
9
8
  //#region src/shared.tsx
10
9
  const defaultSetOptionOpt = {
11
10
  notMerge: false,
@@ -27,7 +26,6 @@ function useRegister(fn) {
27
26
  isExecuted.current = true;
28
27
  fn(echarts);
29
28
  }
30
-
31
29
  //#endregion
32
30
  //#region src/charts.tsx
33
31
  function assignForwardedRef(ref, value) {
@@ -36,12 +34,12 @@ function assignForwardedRef(ref, value) {
36
34
  else ref.current = value;
37
35
  }
38
36
  function defineChart(ext) {
39
- const ChartComponent = React.forwardRef(({ className, style, containerProps, compose, use, children,...props }, ref) => {
37
+ const ChartComponent = React.forwardRef(({ className, style, containerProps, compose, use, children, ...props }, ref) => {
40
38
  const containerRef = React.useRef(null);
41
39
  const chartRef = React.useRef(null);
42
40
  const ctx = useInitialChartContext();
43
- useRegister((echarts$1) => {
44
- echarts$1.use([
41
+ useRegister((echarts) => {
42
+ echarts.use([
45
43
  ext,
46
44
  use,
47
45
  compose?.map((comp) => comp.ext).flat() || []
@@ -76,21 +74,21 @@ function defineChart(ext) {
76
74
  ChartComponent.ext = ext;
77
75
  return ChartComponent;
78
76
  }
79
- const BarChart = /* @__PURE__ */ defineChart([BarChart$1, GridComponent]);
80
- const EffectScatterChart = /* @__PURE__ */ defineChart([EffectScatterChart$1, GridComponent]);
81
- const GraphChart = /* @__PURE__ */ defineChart([GraphChart$1]);
82
- const HeatmapChart = /* @__PURE__ */ defineChart([HeatmapChart$1]);
83
- const LineChart = /* @__PURE__ */ defineChart([LineChart$1, GridComponent]);
84
- const PieChart = /* @__PURE__ */ defineChart([PieChart$1]);
85
- const ScatterChart = /* @__PURE__ */ defineChart([ScatterChart$1, GridComponent]);
86
-
77
+ const BarChart = /*#__PURE__*/ defineChart([BarChart$1, GridComponent]);
78
+ const EffectScatterChart = /*#__PURE__*/ defineChart([EffectScatterChart$1, GridComponent]);
79
+ const GraphChart = /*#__PURE__*/ defineChart([GraphChart$1]);
80
+ const HeatmapChart = /*#__PURE__*/ defineChart([HeatmapChart$1]);
81
+ const LineChart = /*#__PURE__*/ defineChart([LineChart$1, GridComponent]);
82
+ const PieChart = /*#__PURE__*/ defineChart([PieChart$1]);
83
+ const ScatterChart = /*#__PURE__*/ defineChart([ScatterChart$1, GridComponent]);
84
+ const SunburstChart = /*#__PURE__*/ defineChart([SunburstChart$1]);
87
85
  //#endregion
88
86
  //#region src/components.tsx
89
87
  function defineComponent(ext) {
90
88
  return function ChartComponent(props) {
91
89
  const ctx = useChartContext();
92
- useRegister((echarts$1) => {
93
- echarts$1.use(ext);
90
+ useRegister((echarts) => {
91
+ echarts.use(ext);
94
92
  });
95
93
  React.useLayoutEffect(() => {
96
94
  ctx.options.push(props);
@@ -98,33 +96,31 @@ function defineComponent(ext) {
98
96
  return null;
99
97
  };
100
98
  }
101
- const Brush = /* @__PURE__ */ defineComponent([BrushComponent]);
102
- const Calendar = /* @__PURE__ */ defineComponent([CalendarComponent]);
103
- const Dataset = /* @__PURE__ */ defineComponent([DatasetComponent, TransformComponent]);
104
- const DataZoom = /* @__PURE__ */ defineComponent([DataZoomComponent]);
105
- const Geo = /* @__PURE__ */ defineComponent([GeoComponent]);
106
- const Graphic = /* @__PURE__ */ defineComponent([GraphicComponent]);
107
- const Legend = /* @__PURE__ */ defineComponent(LegendComponent);
108
- const MarkArea = /* @__PURE__ */ defineComponent(MarkAreaComponent);
109
- const MarkLine = /* @__PURE__ */ defineComponent(MarkLineComponent);
110
- const MarkPoint = /* @__PURE__ */ defineComponent(MarkPointComponent);
111
- const Matrix = /* @__PURE__ */ defineComponent(MatrixComponent);
112
- const Polar = /* @__PURE__ */ defineComponent(PolarComponent);
113
- const SingleAxis = /* @__PURE__ */ defineComponent(SingleAxisComponent);
114
- const Timeline = /* @__PURE__ */ defineComponent(TimelineComponent);
115
- const Title = /* @__PURE__ */ defineComponent(TitleComponent);
116
- const Toolbox = /* @__PURE__ */ defineComponent(ToolboxComponent);
117
- const Tooltip = /* @__PURE__ */ defineComponent(TooltipComponent);
118
- const VisualMap = /* @__PURE__ */ defineComponent(VisualMapComponent);
119
-
99
+ const Brush = /*#__PURE__*/ defineComponent([BrushComponent]);
100
+ const Calendar = /*#__PURE__*/ defineComponent([CalendarComponent]);
101
+ const Dataset = /*#__PURE__*/ defineComponent([DatasetComponent, TransformComponent]);
102
+ const DataZoom = /*#__PURE__*/ defineComponent([DataZoomComponent]);
103
+ const Geo = /*#__PURE__*/ defineComponent([GeoComponent]);
104
+ const Graphic = /*#__PURE__*/ defineComponent([GraphicComponent]);
105
+ const Legend = /*#__PURE__*/ defineComponent(LegendComponent);
106
+ const MarkArea = /*#__PURE__*/ defineComponent(MarkAreaComponent);
107
+ const MarkLine = /*#__PURE__*/ defineComponent(MarkLineComponent);
108
+ const MarkPoint = /*#__PURE__*/ defineComponent(MarkPointComponent);
109
+ const Matrix = /*#__PURE__*/ defineComponent(MatrixComponent);
110
+ const Polar = /*#__PURE__*/ defineComponent(PolarComponent);
111
+ const SingleAxis = /*#__PURE__*/ defineComponent(SingleAxisComponent);
112
+ const Timeline = /*#__PURE__*/ defineComponent(TimelineComponent);
113
+ const Title = /*#__PURE__*/ defineComponent(TitleComponent);
114
+ const Toolbox = /*#__PURE__*/ defineComponent(ToolboxComponent);
115
+ const Tooltip = /*#__PURE__*/ defineComponent(TooltipComponent);
116
+ const VisualMap = /*#__PURE__*/ defineComponent(VisualMapComponent);
120
117
  //#endregion
121
118
  //#region src/features.tsx
122
119
  function AxisBreak() {
123
- useRegister((echarts$1) => {
124
- echarts$1.use(AxisBreak$1);
120
+ useRegister((echarts) => {
121
+ echarts.use(AxisBreak$1);
125
122
  });
126
123
  return null;
127
124
  }
128
-
129
125
  //#endregion
130
- export { AxisBreak, BarChart, Brush, Calendar, CanvasRenderer, DataZoom, Dataset, EffectScatterChart, Geo, GraphChart, Graphic, HeatmapChart, Legend, LineChart, MarkArea, MarkLine, MarkPoint, Matrix, PieChart, Polar, SVGRenderer, ScatterChart, SingleAxis, Timeline, Title, Toolbox, Tooltip, VisualMap, echarts };
126
+ export { AxisBreak, BarChart, Brush, Calendar, CanvasRenderer, DataZoom, Dataset, EffectScatterChart, Geo, GraphChart, Graphic, HeatmapChart, Legend, LineChart, MarkArea, MarkLine, MarkPoint, Matrix, PieChart, Polar, SVGRenderer, ScatterChart, SingleAxis, SunburstChart, Timeline, Title, Toolbox, Tooltip, VisualMap, echarts };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fanciers/echarts-react",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "ECharts <3 React",
5
5
  "author": "Tmk <i@tmk.im>",
6
6
  "keywords": [
@@ -18,38 +18,42 @@
18
18
  ],
19
19
  "exports": {
20
20
  ".": {
21
- "types": "./dist/index.d.ts",
22
- "default": "./dist/index.js"
21
+ "types": "./dist/index.d.mts",
22
+ "default": "./dist/index.mjs"
23
23
  }
24
24
  },
25
- "typings": "./dist/index.d.ts",
25
+ "main": "./dist/index.mjs",
26
+ "typings": "./dist/index.d.mts",
27
+ "homepage": "https://tmkx.github.io/echarts-react",
26
28
  "repository": {
27
29
  "url": "https://github.com/tmkx/echarts-react.git"
28
30
  },
31
+ "dependencies": {
32
+ "echarts": "^6.1.0"
33
+ },
29
34
  "devDependencies": {
30
- "@rsbuild/core": "^1.5.4",
31
- "@rsbuild/plugin-react": "^1.4.0",
32
- "@storybook/addon-docs": "^9.1.5",
33
- "@storybook/react": "^9.1.5",
34
- "@types/node": "^24.3.1",
35
- "@types/react": "^19.1.12",
36
- "@types/react-dom": "^19.1.9",
37
- "echarts": "^6.0.0",
38
- "react": "^19.1.1",
39
- "react-dom": "^19.1.1",
40
- "storybook": "^9.1.5",
41
- "storybook-react-rsbuild": "^2.1.0",
42
- "swr": "^2.3.6",
43
- "tsdown": "^0.14.2",
44
- "typescript": "^5.9.2"
35
+ "@storybook/addon-docs": "10.4.3",
36
+ "@storybook/react": "10.4.3",
37
+ "@storybook/react-vite": "10.4.3",
38
+ "@types/node": "^25.9.2",
39
+ "@types/react": "^19.2.17",
40
+ "@types/react-dom": "^19.2.3",
41
+ "react": "^19.2.7",
42
+ "react-dom": "^19.2.7",
43
+ "storybook": "10.4.3",
44
+ "swr": "^2.4.1",
45
+ "tsdown": "^0.22.2",
46
+ "typescript": "^6.0.3",
47
+ "vite": "8.0.16",
48
+ "vitest": "^4.1.8"
45
49
  },
46
50
  "peerDependencies": {
47
- "echarts": "^6.0.0",
48
51
  "react": ">=18.0.0",
49
52
  "react-dom": ">=18.0.0"
50
53
  },
51
54
  "scripts": {
52
55
  "dev": "storybook dev",
56
+ "test": "vitest",
53
57
  "lint": "tsc --noEmit"
54
58
  }
55
59
  }