@revolist/react-charts 3.0.2 → 3.0.4
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 +3 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +9 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -94,7 +94,9 @@ so do not destroy its ref yourself.
|
|
|
94
94
|
Creation and updates are asynchronous. Pending work is cancelled on unmount or
|
|
95
95
|
superseding configuration, and stale results are destroyed. Failures call
|
|
96
96
|
`options.onError`, or `console.error` when no error handler is supplied. Server
|
|
97
|
-
rendering produces an empty host
|
|
97
|
+
rendering produces an empty host by default. Pass the optional `serverRender`
|
|
98
|
+
result from `renderChartToSVG` to include initial SVG and hydrate it on mounting.
|
|
99
|
+
See the engine's [server rendering guide](../../docs/server-rendering.md).
|
|
98
100
|
|
|
99
101
|
## Building and distribution
|
|
100
102
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { HTMLAttributes, ReactElement } from 'react';
|
|
2
2
|
import type { ChartComponentOptions } from '@revolist/charts/framework';
|
|
3
|
-
import type { ChartRef } from '@revolist/charts';
|
|
3
|
+
import type { ChartRef, ChartServerRender } from '@revolist/charts';
|
|
4
4
|
export type { ChartComponentOptions, ChartRef };
|
|
5
5
|
export interface RevoChartProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
6
6
|
options: ChartComponentOptions;
|
|
7
7
|
onReady?: (chart: ChartRef) => void;
|
|
8
|
+
/** Initial trusted output from @revolist/charts/server. */
|
|
9
|
+
serverRender?: ChartServerRender;
|
|
8
10
|
}
|
|
9
|
-
export declare function RevoChart({ options, onReady, style, ...attributes }: RevoChartProps): ReactElement;
|
|
11
|
+
export declare function RevoChart({ options, onReady, serverRender, style, ...attributes }: RevoChartProps): ReactElement;
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { createElement, useEffect, useRef } from 'react';
|
|
2
3
|
import { createChartComponentController } from '@revolist/charts/framework';
|
|
3
|
-
export function RevoChart({ options, onReady, style, ...attributes }) {
|
|
4
|
+
export function RevoChart({ options, onReady, serverRender, style, ...attributes }) {
|
|
4
5
|
const host = useRef(null);
|
|
5
6
|
const controller = useRef(undefined);
|
|
6
7
|
const ready = useRef(onReady);
|
|
8
|
+
const initial = useRef(serverRender);
|
|
9
|
+
const markup = useRef(serverRender ? { __html: serverRender.svg } : undefined);
|
|
7
10
|
// Update callbacks only after commit; abandoned concurrent renders stay invisible.
|
|
8
11
|
useEffect(() => { ready.current = onReady; }, [onReady]);
|
|
9
12
|
useEffect(() => {
|
|
10
|
-
const instance = createChartComponentController(host.current, chart => ready.current?.(chart));
|
|
13
|
+
const instance = createChartComponentController(host.current, chart => ready.current?.(chart), !!initial.current);
|
|
11
14
|
controller.current = instance;
|
|
12
15
|
return () => {
|
|
13
16
|
instance.destroy();
|
|
@@ -15,5 +18,8 @@ export function RevoChart({ options, onReady, style, ...attributes }) {
|
|
|
15
18
|
};
|
|
16
19
|
}, []);
|
|
17
20
|
useEffect(() => { void controller.current?.setOptions(options); }, [options]);
|
|
18
|
-
return createElement('div', { ...attributes, ref: host,
|
|
21
|
+
return createElement('div', { ...attributes, ref: host,
|
|
22
|
+
...(markup.current ? { dangerouslySetInnerHTML: markup.current } : {}),
|
|
23
|
+
style: { width: '100%', height: `${initial.current?.height ?? 300}px`, ...style },
|
|
24
|
+
});
|
|
19
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revolist/react-charts",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"description": "React components for RevoGrid Charts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Commercial",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@revolist/charts": "3.0.
|
|
21
|
+
"@revolist/charts": "3.0.4"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "^19.2.0",
|