infographic-for-react 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 lyw405
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,227 @@
1
+ # infographic-for-react
2
+
3
+ > React components for @antv/infographic - a declarative, component-based wrapper for infographic generation.
4
+
5
+ [中文文档](./README.zh-CN.md)
6
+
7
+ [![npm version](https://img.shields.io/npm/v/infographic-for-react.svg)](https://www.npmjs.com/package/infographic-for-react)
8
+
9
+ ## Features
10
+
11
+ - **🎯 Declarative API** - Use React components to render infographics with familiar patterns
12
+ - **⚡ Lightweight** - Thin wrapper around the core infographic engine with minimal overhead
13
+ - **🔧 Customizable** - Override DSL values with path-based API, apply themes and palettes
14
+ - **🪝 Extensible** - `beforeRender` / `afterRender` hooks for custom preprocessing/postprocessing
15
+ - **📦 Export Ready** - Built-in export to SVG/PNG data URLs
16
+ - **🛡️ Error Handling** - Built-in error boundaries and error recovery
17
+ - **🎨 Fully Typed** - Full TypeScript support with type-safe APIs
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ # Install infographic-for-react and its peer dependency @antv/infographic
23
+ npm install infographic-for-react @antv/infographic
24
+ ```
25
+
26
+ > **Note**: `@antv/infographic` is a peer dependency and must be installed separately. If you use npm v7+, it will be installed automatically, but we recommend explicitly installing it to ensure compatibility.
27
+
28
+ ## Quick Start
29
+
30
+ ### Basic Usage
31
+
32
+ The simplest way to use `Infographic` is to pass a `dsl` prop with the template name and data configuration.
33
+
34
+ ```tsx
35
+ import { Infographic } from 'infographic-for-react';
36
+
37
+ function App() {
38
+ return (
39
+ <Infographic
40
+ dsl={{
41
+ template: 'template-name',
42
+ theme: 'light',
43
+ palette: 'antv',
44
+ data: {
45
+ title: 'My Infographic',
46
+ desc: 'Optional description',
47
+ items: [
48
+ {
49
+ label: 'Item 1',
50
+ value: 100,
51
+ desc: 'Item description',
52
+ icon: 'mingcute/diamond-2-fill',
53
+ illus: 'creative-experiment',
54
+ time: '2021',
55
+ children: [
56
+ ...,
57
+ ],
58
+ },
59
+ ...,
60
+ ],
61
+ },
62
+ }}
63
+ width={600}
64
+ height={400}
65
+ />
66
+ );
67
+ }
68
+ ```
69
+
70
+ ### DSL Overrides
71
+
72
+ Use the `overrides` prop to selectively modify DSL values by path without recreating the entire DSL object. This is useful for dynamic updates or theming.
73
+
74
+ ```tsx
75
+ import { Infographic } from 'infographic-for-react';
76
+
77
+ function App() {
78
+ const overrides = [
79
+ { path: 'data.items[0].value', value: 200 },
80
+ ];
81
+
82
+ return (
83
+ <Infographic
84
+ dsl={{
85
+ template: 'template-name',
86
+ theme: 'light',
87
+ palette: 'antv',
88
+ data: {
89
+ title: 'My Infographic',
90
+ desc: 'Optional description',
91
+ items: [
92
+ {
93
+ label: 'Item 1',
94
+ value: 100,
95
+ desc: 'Item description',
96
+ icon: 'mingcute/diamond-2-fill',
97
+ illus: 'creative-experiment',
98
+ time: '2021',
99
+ children: [
100
+ ...,
101
+ ],
102
+ },
103
+ { label: 'Item 2', value: 200 },
104
+ ],
105
+ },
106
+ }}
107
+ overrides={overrides}
108
+ width={600}
109
+ height={400}
110
+ />
111
+ );
112
+ }
113
+ ```
114
+
115
+ ### Using Hooks
116
+
117
+ ```tsx
118
+ import { useInfographic } from 'infographic-for-react';
119
+ import { useRef } from 'react';
120
+
121
+ function App() {
122
+ const containerRef = useRef<HTMLDivElement>(null);
123
+
124
+ const infographic = useInfographic(containerRef, {
125
+ dsl: {
126
+ data: {
127
+ title: 'My Infographic',
128
+ items: [
129
+ { label: 'Item 1', value: 100 },
130
+ ],
131
+ },
132
+ },
133
+ onRender: (result) => console.log('Rendered:', result),
134
+ });
135
+
136
+ const handleExport = async () => {
137
+ const dataURL = await infographic.toDataURL({ type: 'svg' });
138
+ const link = document.createElement('a');
139
+ link.href = dataURL;
140
+ link.download = 'infographic.svg';
141
+ link.click();
142
+ };
143
+
144
+ return (
145
+ <div>
146
+ <button onClick={handleExport}>Export SVG</button>
147
+ <div ref={containerRef} style={{ width: 600, height: 400 }} />
148
+ </div>
149
+ );
150
+ }
151
+ ```
152
+
153
+ ### Pre/Post Render Hooks
154
+
155
+ Use `beforeRender` to preprocess the DSL before rendering, and `afterRender` to perform actions after the infographic is rendered (e.g., logging, analytics, custom post-processing).
156
+
157
+ ```tsx
158
+ import { Infographic } from 'infographic-for-react';
159
+ import type { DSLObject } from 'infographic-for-react';
160
+
161
+ function App() {
162
+ const beforeRender = (dsl: DSLObject): DSLObject => {
163
+ return {
164
+ ...dsl,
165
+ title: 'Processed: ' + dsl.title,
166
+ };
167
+ };
168
+
169
+ const afterRender = async (result) => {
170
+ console.log('Rendered element:', result.node);
171
+ console.log('Element count:', result.node.children.length);
172
+ };
173
+
174
+ return (
175
+ <Infographic
176
+ dsl={{
177
+ data: {
178
+ title: 'My Infographic',
179
+ items: [{ label: 'Item 1', value: 100 }],
180
+ },
181
+ }}
182
+ beforeRender={beforeRender}
183
+ afterRender={afterRender}
184
+ />
185
+ );
186
+ }
187
+ ```
188
+
189
+ ## API Reference
190
+
191
+ See [API.md](./docs/API.md) for detailed API documentation.
192
+
193
+ [中文文档](./docs/API.zh-CN.md) is also available.
194
+
195
+ ## Development
196
+
197
+ ```bash
198
+ # Install dependencies
199
+ npm install
200
+
201
+ # Build
202
+ npm run build
203
+
204
+ # Run tests
205
+ npm test
206
+
207
+ # Type check
208
+ npm run typecheck
209
+
210
+ # Lint
211
+ npm run lint
212
+
213
+ # Format code
214
+ npm run format
215
+ ```
216
+
217
+ ## Contributing
218
+
219
+ Contributions are welcome! Please read our contributing guidelines before submitting PRs.
220
+
221
+ ## License
222
+
223
+ [MIT](LICENSE) © lyw405
224
+
225
+ ## Repository
226
+
227
+ [GitHub](https://github.com/lyw405/infographic-for-react)
@@ -0,0 +1,228 @@
1
+ # infographic-for-react
2
+
3
+ > React 组件库 for @antv/infographic - 基于组件化的声明式信息图表生成封装。
4
+
5
+ [English documentation](./README.md)
6
+
7
+ [![npm version](https://img.shields.io/npm/v/infographic-for-react.svg)](https://www.npmjs.com/package/infographic-for-react)
8
+
9
+ ## 特性
10
+
11
+ - **🎯 声明式 API** - 使用熟悉的 React 组件模式渲染信息图表
12
+ - **⚡ 轻量级** - 核心信息图表引擎的轻量级封装,开销最小
13
+ - **🔧 可定制** - 基于路径的 API 覆盖 DSL 值,应用主题和调色板
14
+ - **🪝 可扩展** - `beforeRender` / `afterRender` 钩子用于自定义预处理/后处理
15
+ - **📦 导出就绪** - 内置导出为 SVG/PNG 数据 URL
16
+ - **🛡️ 错误处理** - 内置错误边界和错误恢复
17
+ - **🎨 完整类型** - 完整的 TypeScript 支持和类型安全 API
18
+
19
+ ## 安装
20
+
21
+ ```bash
22
+ # 安装 infographic-for-react 及其 peer dependency @antv/infographic
23
+ npm install infographic-for-react @antv/infographic
24
+ ```
25
+
26
+ > **注意**:`@antv/infographic` 是 peer dependency,需要单独安装。如果你使用 npm v7+,它会自动安装,但我们建议显式安装以确保兼容性。
27
+
28
+ ## 快速开始
29
+
30
+ ### 基础用法
31
+
32
+ 使用 `Infographic` 最简单的方式是传入包含模板名称和数据配置的 `dsl` 属性。
33
+
34
+ ```tsx
35
+ import { Infographic } from 'infographic-for-react';
36
+
37
+ function App() {
38
+ return (
39
+ <Infographic
40
+ dsl={{
41
+ template: '模板名称',
42
+ theme: 'light',
43
+ palette: 'antv',
44
+ data: {
45
+ title: '我的信息图表',
46
+ desc: '可选描述',
47
+ items: [
48
+ {
49
+ label: '项目 1',
50
+ value: 100,
51
+ desc: '项目描述',
52
+ icon: 'mingcute/diamond-2-fill',
53
+ illus: 'creative-experiment',
54
+ time: '2021',
55
+ children: [
56
+ ...
57
+ ],
58
+ },
59
+ { label: '项目 2', value: 200 },
60
+ ],
61
+ },
62
+ }}
63
+ width={600}
64
+ height={400}
65
+ />
66
+ );
67
+ }
68
+ ```
69
+
70
+ ### DSL 覆盖
71
+
72
+ 使用 `overrides` 属性可以通过路径选择性地修改 DSL 值,而无需重新创建整个 DSL 对象。这对于动态更新或主题切换非常有用。
73
+
74
+ ```tsx
75
+ import { Infographic } from 'infographic-for-react';
76
+
77
+ function App() {
78
+ const overrides = [
79
+ { path: 'data.items[0].value', value: 200 },
80
+ ];
81
+
82
+ return (
83
+ <Infographic
84
+ dsl={{
85
+ template: '模板名称',
86
+ theme: 'light',
87
+ palette: 'antv',
88
+ data: {
89
+ title: '我的信息图表',
90
+ desc: '可选描述',
91
+ items: [
92
+ {
93
+ label: '项目 1',
94
+ value: 100,
95
+ desc: '项目描述',
96
+ icon: 'mingcute/diamond-2-fill',
97
+ illus: 'creative-experiment',
98
+ time: '2021',
99
+ children: [
100
+ ...,
101
+ ],
102
+ },
103
+ { label: '项目 2', value: 200 },
104
+ ],
105
+ },
106
+ }}
107
+ overrides={overrides}
108
+ width={600}
109
+ height={400}
110
+ />
111
+ );
112
+ }
113
+ ```
114
+
115
+ ### 使用 Hooks
116
+
117
+ ```tsx
118
+ import { useInfographic } from 'infographic-for-react';
119
+ import { useRef } from 'react';
120
+
121
+ function App() {
122
+ const containerRef = useRef<HTMLDivElement>(null);
123
+
124
+ const infographic = useInfographic(containerRef, {
125
+ dsl: {
126
+ data: {
127
+ title: '我的信息图表',
128
+ items: [
129
+ { label: '项目 1', value: 100 },
130
+ ],
131
+ },
132
+ },
133
+ onRender: (result) => console.log('已渲染:', result),
134
+ });
135
+
136
+ const handleExport = async () => {
137
+ const dataURL = await infographic.toDataURL({ type: 'svg' });
138
+ const link = document.createElement('a');
139
+ link.href = dataURL;
140
+ link.download = 'infographic.svg';
141
+ link.click();
142
+ };
143
+
144
+ return (
145
+ <div>
146
+ <button onClick={handleExport}>导出 SVG</button>
147
+ <div ref={containerRef} style={{ width: 600, height: 400 }} />
148
+ </div>
149
+ );
150
+ }
151
+ ```
152
+
153
+ ### 渲染前/后钩子
154
+
155
+ 使用 `beforeRender` 在渲染前预处理 DSL,使用 `afterRender` 在信息图表渲染后执行操作(如日志记录、分析、自定义后处理)。
156
+
157
+ ```tsx
158
+ import { Infographic } from 'infographic-for-react';
159
+ import type { DSLObject } from 'infographic-for-react';
160
+
161
+ function App() {
162
+ const beforeRender = (dsl: DSLObject): DSLObject => {
163
+ return {
164
+ ...dsl,
165
+ title: '已处理: ' + dsl.title,
166
+ };
167
+ };
168
+
169
+ const afterRender = async (result) => {
170
+ console.log('渲染的元素:', result.node);
171
+ console.log('元素数量:', result.node.children.length);
172
+ };
173
+
174
+ return (
175
+ <Infographic
176
+ dsl={{
177
+ title: '我的信息图表',
178
+ data: {
179
+ title: '数据标题',
180
+ items: [{ label: '项目 1', value: 100 }],
181
+ },
182
+ }}
183
+ beforeRender={beforeRender}
184
+ afterRender={afterRender}
185
+ />
186
+ );
187
+ }
188
+ ```
189
+
190
+ ## API 参考
191
+
192
+ 详细 API 文档请参阅 [API.zh-CN.md](./docs/API.zh-CN.md)。
193
+
194
+ [English documentation](./docs/API.md) is also available.
195
+
196
+ ## 开发
197
+
198
+ ```bash
199
+ # 安装依赖
200
+ npm install
201
+
202
+ # 构建
203
+ npm run build
204
+
205
+ # 运行测试
206
+ npm test
207
+
208
+ # 类型检查
209
+ npm run typecheck
210
+
211
+ # 代码检查
212
+ npm run lint
213
+
214
+ # 格式化代码
215
+ npm run format
216
+ ```
217
+
218
+ ## 贡献
219
+
220
+ 欢迎贡献!提交 PR 之前请阅读我们的贡献指南。
221
+
222
+ ## 许可证
223
+
224
+ [MIT](LICENSE) © lyw405
225
+
226
+ ## 仓库地址
227
+
228
+ [GitHub](https://github.com/lyw405/infographic-for-react)
@@ -0,0 +1,119 @@
1
+ import React$1, { Component, ReactNode, ErrorInfo } from 'react';
2
+ import { InfographicOptions, Palette, ThemeConfig, ExportOptions } from '@antv/infographic';
3
+ export { ExportOptions, InfographicOptions, Palette, SyntaxError, ThemeConfig } from '@antv/infographic';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
+
6
+ interface DSLItem {
7
+ label: string;
8
+ desc?: string;
9
+ icon?: string;
10
+ illus?: string;
11
+ value?: number;
12
+ time?: string;
13
+ children?: DSLItem[];
14
+ }
15
+ interface DSLData {
16
+ title: string;
17
+ desc?: string;
18
+ items: DSLItem[];
19
+ }
20
+ interface DSLTheme {
21
+ name: string;
22
+ palette: string;
23
+ }
24
+ interface DSLObject extends Partial<InfographicOptions> {
25
+ data: DSLData;
26
+ palette?: Palette;
27
+ themeConfig?: ThemeConfig;
28
+ }
29
+ type DSLInput = DSLObject;
30
+ interface DSLOverride {
31
+ path: string;
32
+ value: unknown;
33
+ }
34
+ type PreRenderHook = (dsl: DSLObject) => DSLObject | Promise<DSLObject>;
35
+ interface InfographicRenderResult {
36
+ node: SVGSVGElement;
37
+ options: Partial<InfographicOptions>;
38
+ }
39
+ interface InfographicError {
40
+ type: 'syntax' | 'render' | 'runtime';
41
+ message: string;
42
+ dsl?: string;
43
+ details?: string | Error | unknown;
44
+ }
45
+ type PostRenderHook = (result: InfographicRenderResult) => void | Promise<void>;
46
+ interface ComposeTemplateOptions {
47
+ templates: DSLObject[];
48
+ overrides?: DSLOverride[];
49
+ }
50
+ interface InfographicProps {
51
+ dsl?: DSLInput;
52
+ overrides?: DSLOverride[];
53
+ theme?: string;
54
+ palette?: Palette;
55
+ width?: number | string;
56
+ height?: number | string;
57
+ className?: string;
58
+ editable?: boolean;
59
+ beforeRender?: PreRenderHook;
60
+ afterRender?: PostRenderHook;
61
+ onRender?: (result: InfographicRenderResult) => void;
62
+ onError?: (error: InfographicError) => void;
63
+ onLoad?: (result: InfographicRenderResult) => void;
64
+ }
65
+ interface InfographicRef {
66
+ toDataURL: (options?: ExportOptions) => Promise<string>;
67
+ getTypes: () => string | undefined;
68
+ update: (options: DSLInput) => Promise<void>;
69
+ destroy: () => void;
70
+ }
71
+ interface RendererInstance {
72
+ render: (options?: Partial<InfographicOptions>) => void;
73
+ update: (options: Partial<InfographicOptions>) => void;
74
+ toDataURL: (options?: ExportOptions) => Promise<string>;
75
+ getTypes: () => string | undefined;
76
+ destroy: () => void;
77
+ on: (event: string, listener: (...args: any[]) => void) => void;
78
+ off: (event: string, listener: (...args: any[]) => void) => void;
79
+ }
80
+
81
+ declare const Infographic: React$1.ForwardRefExoticComponent<InfographicProps & React$1.RefAttributes<InfographicRef>>;
82
+
83
+ interface ErrorBoundaryProps {
84
+ children: ReactNode;
85
+ fallback?: ReactNode | ((error: Error, errorInfo: ErrorInfo) => ReactNode);
86
+ onError?: (error: Error, errorInfo: ErrorInfo) => void;
87
+ }
88
+ interface ErrorBoundaryState {
89
+ hasError: boolean;
90
+ error?: Error;
91
+ errorInfo?: ErrorInfo;
92
+ }
93
+ declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
94
+ constructor(props: ErrorBoundaryProps);
95
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
96
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
97
+ handleReset: () => void;
98
+ render(): string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<ReactNode> | null | undefined;
99
+ }
100
+
101
+ declare function useRenderer(containerRef: React.RefObject<HTMLElement>): {
102
+ render: (options: Partial<InfographicOptions>) => Promise<void>;
103
+ update: (options: Partial<InfographicOptions>) => void;
104
+ toDataURL: (options?: ExportOptions) => Promise<string>;
105
+ getTypes: () => string | undefined;
106
+ destroy: () => void;
107
+ on: (event: string, listener: (...args: any[]) => void) => void;
108
+ off: (event: string, listener: (...args: any[]) => void) => void;
109
+ isReady: boolean;
110
+ };
111
+
112
+ declare function useInfographic(containerRef: React.RefObject<HTMLElement>, props: InfographicProps): InfographicRef;
113
+
114
+ declare function applyOverrides(base: DSLObject, overrides: DSLOverride[]): DSLObject;
115
+ declare function mergeDSL(dsl1: DSLObject, dsl2: DSLObject): DSLObject;
116
+
117
+ declare function composeTemplates(options: ComposeTemplateOptions): DSLObject;
118
+
119
+ export { type ComposeTemplateOptions, type DSLData, type DSLInput, type DSLItem, type DSLObject, type DSLOverride, type DSLTheme, ErrorBoundary, Infographic, type InfographicError, type InfographicProps, type InfographicRef, type InfographicRenderResult, type PostRenderHook, type PreRenderHook, type RendererInstance, applyOverrides, composeTemplates, mergeDSL, useInfographic, useRenderer };
@@ -0,0 +1,119 @@
1
+ import React$1, { Component, ReactNode, ErrorInfo } from 'react';
2
+ import { InfographicOptions, Palette, ThemeConfig, ExportOptions } from '@antv/infographic';
3
+ export { ExportOptions, InfographicOptions, Palette, SyntaxError, ThemeConfig } from '@antv/infographic';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
+
6
+ interface DSLItem {
7
+ label: string;
8
+ desc?: string;
9
+ icon?: string;
10
+ illus?: string;
11
+ value?: number;
12
+ time?: string;
13
+ children?: DSLItem[];
14
+ }
15
+ interface DSLData {
16
+ title: string;
17
+ desc?: string;
18
+ items: DSLItem[];
19
+ }
20
+ interface DSLTheme {
21
+ name: string;
22
+ palette: string;
23
+ }
24
+ interface DSLObject extends Partial<InfographicOptions> {
25
+ data: DSLData;
26
+ palette?: Palette;
27
+ themeConfig?: ThemeConfig;
28
+ }
29
+ type DSLInput = DSLObject;
30
+ interface DSLOverride {
31
+ path: string;
32
+ value: unknown;
33
+ }
34
+ type PreRenderHook = (dsl: DSLObject) => DSLObject | Promise<DSLObject>;
35
+ interface InfographicRenderResult {
36
+ node: SVGSVGElement;
37
+ options: Partial<InfographicOptions>;
38
+ }
39
+ interface InfographicError {
40
+ type: 'syntax' | 'render' | 'runtime';
41
+ message: string;
42
+ dsl?: string;
43
+ details?: string | Error | unknown;
44
+ }
45
+ type PostRenderHook = (result: InfographicRenderResult) => void | Promise<void>;
46
+ interface ComposeTemplateOptions {
47
+ templates: DSLObject[];
48
+ overrides?: DSLOverride[];
49
+ }
50
+ interface InfographicProps {
51
+ dsl?: DSLInput;
52
+ overrides?: DSLOverride[];
53
+ theme?: string;
54
+ palette?: Palette;
55
+ width?: number | string;
56
+ height?: number | string;
57
+ className?: string;
58
+ editable?: boolean;
59
+ beforeRender?: PreRenderHook;
60
+ afterRender?: PostRenderHook;
61
+ onRender?: (result: InfographicRenderResult) => void;
62
+ onError?: (error: InfographicError) => void;
63
+ onLoad?: (result: InfographicRenderResult) => void;
64
+ }
65
+ interface InfographicRef {
66
+ toDataURL: (options?: ExportOptions) => Promise<string>;
67
+ getTypes: () => string | undefined;
68
+ update: (options: DSLInput) => Promise<void>;
69
+ destroy: () => void;
70
+ }
71
+ interface RendererInstance {
72
+ render: (options?: Partial<InfographicOptions>) => void;
73
+ update: (options: Partial<InfographicOptions>) => void;
74
+ toDataURL: (options?: ExportOptions) => Promise<string>;
75
+ getTypes: () => string | undefined;
76
+ destroy: () => void;
77
+ on: (event: string, listener: (...args: any[]) => void) => void;
78
+ off: (event: string, listener: (...args: any[]) => void) => void;
79
+ }
80
+
81
+ declare const Infographic: React$1.ForwardRefExoticComponent<InfographicProps & React$1.RefAttributes<InfographicRef>>;
82
+
83
+ interface ErrorBoundaryProps {
84
+ children: ReactNode;
85
+ fallback?: ReactNode | ((error: Error, errorInfo: ErrorInfo) => ReactNode);
86
+ onError?: (error: Error, errorInfo: ErrorInfo) => void;
87
+ }
88
+ interface ErrorBoundaryState {
89
+ hasError: boolean;
90
+ error?: Error;
91
+ errorInfo?: ErrorInfo;
92
+ }
93
+ declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
94
+ constructor(props: ErrorBoundaryProps);
95
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
96
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
97
+ handleReset: () => void;
98
+ render(): string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<ReactNode> | null | undefined;
99
+ }
100
+
101
+ declare function useRenderer(containerRef: React.RefObject<HTMLElement>): {
102
+ render: (options: Partial<InfographicOptions>) => Promise<void>;
103
+ update: (options: Partial<InfographicOptions>) => void;
104
+ toDataURL: (options?: ExportOptions) => Promise<string>;
105
+ getTypes: () => string | undefined;
106
+ destroy: () => void;
107
+ on: (event: string, listener: (...args: any[]) => void) => void;
108
+ off: (event: string, listener: (...args: any[]) => void) => void;
109
+ isReady: boolean;
110
+ };
111
+
112
+ declare function useInfographic(containerRef: React.RefObject<HTMLElement>, props: InfographicProps): InfographicRef;
113
+
114
+ declare function applyOverrides(base: DSLObject, overrides: DSLOverride[]): DSLObject;
115
+ declare function mergeDSL(dsl1: DSLObject, dsl2: DSLObject): DSLObject;
116
+
117
+ declare function composeTemplates(options: ComposeTemplateOptions): DSLObject;
118
+
119
+ export { type ComposeTemplateOptions, type DSLData, type DSLInput, type DSLItem, type DSLObject, type DSLOverride, type DSLTheme, ErrorBoundary, Infographic, type InfographicError, type InfographicProps, type InfographicRef, type InfographicRenderResult, type PostRenderHook, type PreRenderHook, type RendererInstance, applyOverrides, composeTemplates, mergeDSL, useInfographic, useRenderer };