@revolist/react-charts 0.0.0-stage → 3.0.2

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 CHANGED
@@ -1,3 +1,108 @@
1
- # Temporary Holding Version
1
+ # RevoGrid React Charts
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ One generic `RevoChart` component backed by the standalone chart engine.
4
+
5
+ ## Installation: public wrapper, private engine
6
+
7
+ The four wrapper packages are configured for public npm publishing. `@revolist/charts` remains a
8
+ private commercial package on GitHub Packages; you need licensed access to
9
+ install and use it. The wrapper imports the engine and does not bundle it.
10
+
11
+ ### Before the first release
12
+
13
+ The wrappers are not published yet; registry install commands below apply after
14
+ publication. In this monorepo, replace `your-app` with your consumer workspace
15
+ name and use the local package:
16
+
17
+ ```sh
18
+ pnpm --filter your-app add "@revolist/react-charts@workspace:*" "@revolist/charts@workspace:*"
19
+ pnpm build
20
+ ```
21
+
22
+ Source: `packages/charts/packages/react-charts`. The public import name is unchanged.
23
+
24
+ ### Registry installation after publication
25
+
26
+ Configure your project's `.npmrc` for the engine, keeping credentials in your
27
+ environment:
28
+
29
+ ```ini
30
+ @revolist:registry=https://npm.pkg.github.com/
31
+ //npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES_TOKEN}
32
+ ```
33
+
34
+ Both registries use the `@revolist` scope. Install the public wrapper by its
35
+ explicit npm tarball URL so the scope mapping continues to send the engine to
36
+ GitHub Packages. A plain `pnpm add @revolist/react-charts` with that mapping
37
+ would look for the wrapper on GitHub instead. Changing only the default
38
+ `--registry` does not override the scope mapping.
39
+
40
+ ```sh
41
+ pnpm add @revolist/charts@3.0.0
42
+ pnpm add https://registry.npmjs.org/@revolist/react-charts/-/react-charts-3.0.0.tgz
43
+ ```
44
+
45
+ Use matching released wrapper and engine versions; replace `3.0.0` in these
46
+ examples when upgrading. Commit your lockfile so CI retains both registries'
47
+ resolved tarball URLs, and provide `GITHUB_PACKAGES_TOKEN` during CI installs.
48
+ Missing or unauthorized engine access causes installation to fail. No separate
49
+ wrapper trial package is published.
50
+
51
+ Define your chart configuration:
52
+
53
+ ```ts
54
+ const options = {
55
+ chartType: 'line',
56
+ data: [{ month: 'Jan', revenue: 120 }, { month: 'Feb', revenue: 180 }],
57
+ mapping: {
58
+ category: { field: 'month' },
59
+ series: [{ field: 'revenue', label: 'Revenue' }],
60
+ },
61
+ } satisfies ChartComponentOptions;
62
+ ```
63
+
64
+ ```tsx
65
+ import { RevoChart, type ChartComponentOptions } from '@revolist/react-charts';
66
+ // Use the options above in your component:
67
+ <RevoChart options={options} onReady={chart => console.log(chart.model)}
68
+ style={{ height: 400 }} className="sales-chart" />
69
+ ```
70
+
71
+ ## Updates and lifecycle
72
+
73
+ `options` has type `Omit<ChartOptions, 'container'>`. It accepts the same rows and
74
+ mapping, dataset, saved model, renderer, data source and chart settings as
75
+ `@revolist/charts`. Existing callbacks such as `onNodeClick`, `onChange` and
76
+ `onError` belong inside `options`. Callback replacements take effect without
77
+ recreating a chart.
78
+
79
+ Replace `options` and changed nested values to update the chart; do not mutate
80
+ nested objects in place. In Vue, replace the ref value; in Svelte, prefer
81
+ `$state.raw` for chart configuration. Ordinary data/settings changes update the
82
+ current chart. Source replacements use `setDataSource`. Initialization settings,
83
+ input-mode changes and removed settings recreate it to restore engine defaults.
84
+
85
+ The host defaults to width `100%` and height `300px`. Override its dimensions with
86
+ framework styles. The engine observes resizing. No stylesheet, element
87
+ registration or manual mount call is needed.
88
+
89
+ The readiness callback/event receives `ChartRef` for `download`, `getCSV`,
90
+ `getImageDataURL`, selection and transactions. It fires again after recreation;
91
+ replace any stored ref on each readiness event. The component owns destruction,
92
+ so do not destroy its ref yourself.
93
+
94
+ Creation and updates are asynchronous. Pending work is cancelled on unmount or
95
+ superseding configuration, and stale results are destroyed. Failures call
96
+ `options.onError`, or `console.error` when no error handler is supplied. Server
97
+ rendering produces an empty host; chart creation starts after client mounting.
98
+
99
+ ## Building and distribution
100
+
101
+ The package compiles with the monorepo's root `pnpm build`. Framework runtimes and
102
+ `@revolist/charts` stay external. Install the framework peers listed in
103
+ `package.json`; the engine version follows the wrapper version.
104
+
105
+ The normal charts release publishes this wrapper to public npmjs using the
106
+ repository's `NPM_TOKEN` secret. The private engine is published separately to
107
+ GitHub Packages using GitHub credentials. No wrapper `build:trial` or trial
108
+ publication is needed.
@@ -0,0 +1,9 @@
1
+ import type { HTMLAttributes, ReactElement } from 'react';
2
+ import type { ChartComponentOptions } from '@revolist/charts/framework';
3
+ import type { ChartRef } from '@revolist/charts';
4
+ export type { ChartComponentOptions, ChartRef };
5
+ export interface RevoChartProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
6
+ options: ChartComponentOptions;
7
+ onReady?: (chart: ChartRef) => void;
8
+ }
9
+ export declare function RevoChart({ options, onReady, style, ...attributes }: RevoChartProps): ReactElement;
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ import { createElement, useEffect, useRef } from 'react';
2
+ import { createChartComponentController } from '@revolist/charts/framework';
3
+ export function RevoChart({ options, onReady, style, ...attributes }) {
4
+ const host = useRef(null);
5
+ const controller = useRef(undefined);
6
+ const ready = useRef(onReady);
7
+ // Update callbacks only after commit; abandoned concurrent renders stay invisible.
8
+ useEffect(() => { ready.current = onReady; }, [onReady]);
9
+ useEffect(() => {
10
+ const instance = createChartComponentController(host.current, chart => ready.current?.(chart));
11
+ controller.current = instance;
12
+ return () => {
13
+ instance.destroy();
14
+ controller.current = undefined;
15
+ };
16
+ }, []);
17
+ useEffect(() => { void controller.current?.setOptions(options); }, [options]);
18
+ return createElement('div', { ...attributes, ref: host, style: { width: '100%', height: '300px', ...style } });
19
+ }
package/package.json CHANGED
@@ -1,6 +1,48 @@
1
1
  {
2
2
  "name": "@revolist/react-charts",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "3.0.2",
4
+ "description": "React components for RevoGrid Charts",
5
+ "type": "module",
6
+ "license": "Commercial",
7
+ "files": [
8
+ "dist",
9
+ "README.md"
10
+ ],
11
+ "sideEffects": false,
12
+ "module": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js"
18
+ }
19
+ },
20
+ "dependencies": {
21
+ "@revolist/charts": "3.0.2"
22
+ },
23
+ "peerDependencies": {
24
+ "react": "^19.2.0",
25
+ "react-dom": "^19.2.0"
26
+ },
27
+ "devDependencies": {
28
+ "react": "^19.2.0",
29
+ "react-dom": "^19.2.0",
30
+ "typescript": "~6.0.3",
31
+ "@types/react": "^19.2.2",
32
+ "@types/react-dom": "^19.2.1"
33
+ },
34
+ "publishConfig": {
35
+ "registry": "https://registry.npmjs.org/",
36
+ "access": "public"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/revolist/revogrid-pro.git",
41
+ "directory": "packages/charts/packages/react-charts"
42
+ },
43
+ "scripts": {
44
+ "build": "tsc -p tsconfig.json",
45
+ "lint": "tsc -p tsconfig.json --noEmit",
46
+ "test": "node --test --test-name-pattern=\"^react charts\" ../../../../.github/workflows/chart-frameworks.test.mjs"
47
+ }
6
48
  }