react-use-echarts 0.0.7 → 0.0.9
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.
- package/README.md +1 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.es.js +28 -28
- package/dist/index.umd.js +1 -1
- package/package.json +19 -19
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-use-echarts
|
|
3
|
-
* A React hook library for Apache ECharts with TypeScript support
|
|
4
|
-
* 基于 TypeScript 的 Apache ECharts React Hook 库
|
|
5
|
-
*
|
|
6
|
-
* @packageDocumentation
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
1
|
import { ECharts } from 'echarts';
|
|
10
2
|
import { EChartsOption } from 'echarts';
|
|
11
3
|
import { SetOptionOpts } from 'echarts';
|
package/dist/index.es.js
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import { useRef as z, useCallback as
|
|
1
|
+
import { useRef as z, useCallback as f, useEffect as C } from "react";
|
|
2
2
|
import * as R from "echarts";
|
|
3
|
-
const
|
|
3
|
+
const w = ({
|
|
4
4
|
/** Chart configuration */
|
|
5
|
-
option:
|
|
5
|
+
option: a,
|
|
6
6
|
/** Theme name */
|
|
7
7
|
theme: i,
|
|
8
8
|
/** Skip merging with previous options */
|
|
9
|
-
notMerge:
|
|
9
|
+
notMerge: d = !1,
|
|
10
10
|
/** Enable lazy update mode */
|
|
11
|
-
lazyUpdate:
|
|
11
|
+
lazyUpdate: l = !1,
|
|
12
12
|
/** Display loading animation */
|
|
13
|
-
showLoading:
|
|
13
|
+
showLoading: p = !1,
|
|
14
14
|
/** Loading animation config */
|
|
15
15
|
loadingOption: O,
|
|
16
16
|
/** Event handlers map */
|
|
17
17
|
onEvents: c
|
|
18
18
|
}) => {
|
|
19
|
-
const s = z(null),
|
|
20
|
-
option:
|
|
19
|
+
const s = z(null), n = z(void 0), k = () => n.current, b = f(() => ({
|
|
20
|
+
option: a,
|
|
21
21
|
theme: i,
|
|
22
|
-
notMerge:
|
|
23
|
-
lazyUpdate:
|
|
24
|
-
showLoading:
|
|
22
|
+
notMerge: d,
|
|
23
|
+
lazyUpdate: l,
|
|
24
|
+
showLoading: p,
|
|
25
25
|
loadingOption: O,
|
|
26
26
|
onEvents: c
|
|
27
27
|
}), [
|
|
28
|
-
|
|
28
|
+
a,
|
|
29
29
|
i,
|
|
30
|
+
d,
|
|
30
31
|
l,
|
|
31
32
|
p,
|
|
32
|
-
d,
|
|
33
33
|
O,
|
|
34
34
|
c
|
|
35
|
-
]), o =
|
|
36
|
-
if (s.current && !
|
|
35
|
+
]), o = f(() => {
|
|
36
|
+
if (s.current && !n.current) {
|
|
37
37
|
const e = R.init(s.current, i);
|
|
38
|
-
|
|
38
|
+
n.current = e;
|
|
39
39
|
const r = b();
|
|
40
40
|
return r.onEvents && Object.entries(r.onEvents).forEach(
|
|
41
|
-
([
|
|
42
|
-
g ? e.on(
|
|
41
|
+
([t, { handler: u, query: g, context: h }]) => {
|
|
42
|
+
g ? e.on(t, g, u, h) : e.on(t, u, h);
|
|
43
43
|
}
|
|
44
44
|
), r.showLoading ? e.showLoading(r.loadingOption) : e.hideLoading(), e.setOption(r.option, {
|
|
45
45
|
notMerge: r.notMerge,
|
|
46
46
|
lazyUpdate: r.lazyUpdate
|
|
47
47
|
}), e;
|
|
48
48
|
}
|
|
49
|
-
return
|
|
50
|
-
}, [b, i]), M =
|
|
49
|
+
return n.current;
|
|
50
|
+
}, [b, i]), M = f(
|
|
51
51
|
(e, r) => {
|
|
52
52
|
queueMicrotask(() => {
|
|
53
|
-
const
|
|
54
|
-
|
|
53
|
+
const t = n.current || o();
|
|
54
|
+
t && t.setOption(e, r);
|
|
55
55
|
});
|
|
56
56
|
},
|
|
57
57
|
[o]
|
|
58
58
|
);
|
|
59
59
|
return C(() => {
|
|
60
|
-
const e =
|
|
60
|
+
const e = n.current;
|
|
61
61
|
if (!e) return;
|
|
62
62
|
const r = new ResizeObserver(() => {
|
|
63
63
|
e.resize();
|
|
64
64
|
});
|
|
65
65
|
return r.observe(s.current), () => {
|
|
66
|
-
r.disconnect(), c && e && Object.entries(c).forEach(([
|
|
67
|
-
e.off(
|
|
68
|
-
}), e.dispose(),
|
|
66
|
+
r.disconnect(), c && e && Object.entries(c).forEach(([t, { handler: u }]) => {
|
|
67
|
+
e.off(t, u);
|
|
68
|
+
}), e.dispose(), n.current = void 0;
|
|
69
69
|
};
|
|
70
|
-
}, [
|
|
70
|
+
}, [n, c]), C(() => {
|
|
71
71
|
s.current && queueMicrotask(o);
|
|
72
72
|
}, [s, o]), {
|
|
73
73
|
chartRef: s,
|
|
@@ -76,5 +76,5 @@ const v = ({
|
|
|
76
76
|
};
|
|
77
77
|
};
|
|
78
78
|
export {
|
|
79
|
-
|
|
79
|
+
w as useEcharts
|
|
80
80
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(r,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react"),require("echarts")):typeof define=="function"&&define.amd?define(["exports","react","echarts"],n):(r=typeof globalThis<"u"?globalThis:r||self,n(r["react-use-echarts"]={},r.React,r.echarts))})(this,function(r,n,y){"use strict";function k(s){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const
|
|
1
|
+
(function(r,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react"),require("echarts")):typeof define=="function"&&define.amd?define(["exports","react","echarts"],n):(r=typeof globalThis<"u"?globalThis:r||self,n(r["react-use-echarts"]={},r.React,r.echarts))})(this,function(r,n,y){"use strict";function k(s){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const u in s)if(u!=="default"){const a=Object.getOwnPropertyDescriptor(s,u);Object.defineProperty(c,u,a.get?a:{enumerable:!0,get:()=>s[u]})}}return c.default=s,Object.freeze(c)}const C=k(y),z=({option:s,theme:c,notMerge:u=!1,lazyUpdate:a=!1,showLoading:b=!1,loadingOption:h,onEvents:d})=>{const f=n.useRef(null),i=n.useRef(void 0),M=()=>i.current,O=n.useCallback(()=>({option:s,theme:c,notMerge:u,lazyUpdate:a,showLoading:b,loadingOption:h,onEvents:d}),[s,c,u,a,b,h,d]),l=n.useCallback(()=>{if(f.current&&!i.current){const e=C.init(f.current,c);i.current=e;const t=O();return t.onEvents&&Object.entries(t.onEvents).forEach(([o,{handler:p,query:g,context:j}])=>{g?e.on(o,g,p,j):e.on(o,p,j)}),t.showLoading?e.showLoading(t.loadingOption):e.hideLoading(),e.setOption(t.option,{notMerge:t.notMerge,lazyUpdate:t.lazyUpdate}),e}return i.current},[O,c]),R=n.useCallback((e,t)=>{queueMicrotask(()=>{const o=i.current||l();o&&o.setOption(e,t)})},[l]);return n.useEffect(()=>{const e=i.current;if(!e)return;const t=new ResizeObserver(()=>{e.resize()});return t.observe(f.current),()=>{t.disconnect(),d&&e&&Object.entries(d).forEach(([o,{handler:p}])=>{e.off(o,p)}),e.dispose(),i.current=void 0}},[i,d]),n.useEffect(()=>{f.current&&queueMicrotask(l)},[f,l]),{chartRef:f,setOption:R,getInstance:M}};r.useEcharts=z,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-use-echarts",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.9",
|
|
5
5
|
"description": "A powerful React hooks library for Apache ECharts",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"react",
|
|
@@ -41,26 +41,26 @@
|
|
|
41
41
|
"dist"
|
|
42
42
|
],
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@eslint/js": "^9.
|
|
45
|
-
"@testing-library/react": "^16.
|
|
46
|
-
"@types/node": "^22.10
|
|
47
|
-
"@types/react": "^19.0.
|
|
48
|
-
"@types/react-dom": "^19.0.
|
|
49
|
-
"@vitejs/plugin-react-swc": "^3.
|
|
50
|
-
"@vitest/coverage-v8": "
|
|
51
|
-
"echarts": "^5.
|
|
52
|
-
"eslint": "^9.
|
|
53
|
-
"eslint-plugin-react-hooks": "^5.
|
|
54
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
55
|
-
"globals": "^
|
|
56
|
-
"jsdom": "^
|
|
44
|
+
"@eslint/js": "^9.22.0",
|
|
45
|
+
"@testing-library/react": "^16.2.0",
|
|
46
|
+
"@types/node": "^22.13.10",
|
|
47
|
+
"@types/react": "^19.0.10",
|
|
48
|
+
"@types/react-dom": "^19.0.4",
|
|
49
|
+
"@vitejs/plugin-react-swc": "^3.8.0",
|
|
50
|
+
"@vitest/coverage-v8": "3.0.8",
|
|
51
|
+
"echarts": "^5.6.0",
|
|
52
|
+
"eslint": "^9.22.0",
|
|
53
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
54
|
+
"eslint-plugin-react-refresh": "^0.4.19",
|
|
55
|
+
"globals": "^16.0.0",
|
|
56
|
+
"jsdom": "^26.0.0",
|
|
57
57
|
"react": "^19.0.0",
|
|
58
58
|
"react-dom": "^19.0.0",
|
|
59
|
-
"typescript": "~5.
|
|
60
|
-
"typescript-eslint": "^8.
|
|
61
|
-
"vite": "^6.
|
|
62
|
-
"vite-plugin-dts": "^4.3
|
|
63
|
-
"vitest": "^
|
|
59
|
+
"typescript": "~5.8.2",
|
|
60
|
+
"typescript-eslint": "^8.26.1",
|
|
61
|
+
"vite": "^6.2.1",
|
|
62
|
+
"vite-plugin-dts": "^4.5.3",
|
|
63
|
+
"vitest": "^3.0.8"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"echarts": "^5.5.1",
|