@fanciers/echarts-react 0.0.4 → 0.0.5

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, 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;
@@ -5,7 +5,6 @@ import { BrushComponent, CalendarComponent, DataZoomComponent, DatasetComponent,
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,20 @@ 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]);
87
84
  //#endregion
88
85
  //#region src/components.tsx
89
86
  function defineComponent(ext) {
90
87
  return function ChartComponent(props) {
91
88
  const ctx = useChartContext();
92
- useRegister((echarts$1) => {
93
- echarts$1.use(ext);
89
+ useRegister((echarts) => {
90
+ echarts.use(ext);
94
91
  });
95
92
  React.useLayoutEffect(() => {
96
93
  ctx.options.push(props);
@@ -98,33 +95,31 @@ function defineComponent(ext) {
98
95
  return null;
99
96
  };
100
97
  }
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
-
98
+ const Brush = /*#__PURE__*/ defineComponent([BrushComponent]);
99
+ const Calendar = /*#__PURE__*/ defineComponent([CalendarComponent]);
100
+ const Dataset = /*#__PURE__*/ defineComponent([DatasetComponent, TransformComponent]);
101
+ const DataZoom = /*#__PURE__*/ defineComponent([DataZoomComponent]);
102
+ const Geo = /*#__PURE__*/ defineComponent([GeoComponent]);
103
+ const Graphic = /*#__PURE__*/ defineComponent([GraphicComponent]);
104
+ const Legend = /*#__PURE__*/ defineComponent(LegendComponent);
105
+ const MarkArea = /*#__PURE__*/ defineComponent(MarkAreaComponent);
106
+ const MarkLine = /*#__PURE__*/ defineComponent(MarkLineComponent);
107
+ const MarkPoint = /*#__PURE__*/ defineComponent(MarkPointComponent);
108
+ const Matrix = /*#__PURE__*/ defineComponent(MatrixComponent);
109
+ const Polar = /*#__PURE__*/ defineComponent(PolarComponent);
110
+ const SingleAxis = /*#__PURE__*/ defineComponent(SingleAxisComponent);
111
+ const Timeline = /*#__PURE__*/ defineComponent(TimelineComponent);
112
+ const Title = /*#__PURE__*/ defineComponent(TitleComponent);
113
+ const Toolbox = /*#__PURE__*/ defineComponent(ToolboxComponent);
114
+ const Tooltip = /*#__PURE__*/ defineComponent(TooltipComponent);
115
+ const VisualMap = /*#__PURE__*/ defineComponent(VisualMapComponent);
120
116
  //#endregion
121
117
  //#region src/features.tsx
122
118
  function AxisBreak() {
123
- useRegister((echarts$1) => {
124
- echarts$1.use(AxisBreak$1);
119
+ useRegister((echarts) => {
120
+ echarts.use(AxisBreak$1);
125
121
  });
126
122
  return null;
127
123
  }
128
-
129
124
  //#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 };
125
+ 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 };
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.5",
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
  }