@veztraa/report-designer 0.1.4 → 0.2.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/README.md +53 -60
- package/dist/index.js +425 -432
- package/package.json +4 -3
- package/dist/index.css +0 -1
package/README.md
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
# @veztraa/report-designer
|
|
2
2
|
|
|
3
|
+
**[Documentation & Live Demo →](https://report-forge.veztraa.com)**
|
|
4
|
+
|
|
3
5
|
Embeddable React PDF report designer component for ReportForge. Drop `<ReportDesigner />` into any React app and give your users a full visual report builder — drag-and-drop canvas, live PDF preview, undo/redo, dark mode, and more.
|
|
4
6
|
|
|
7
|
+
Styles auto-inject on mount — no CSS import required.
|
|
8
|
+
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
7
11
|
```bash
|
|
8
|
-
npm install @veztraa/report-designer
|
|
12
|
+
npm install @veztraa/report-designer
|
|
9
13
|
```
|
|
10
14
|
|
|
11
15
|
## Usage
|
|
12
16
|
|
|
13
17
|
```tsx
|
|
14
18
|
import { ReportDesigner } from "@veztraa/report-designer";
|
|
15
|
-
import
|
|
19
|
+
// No CSS import needed — styles inject automatically.
|
|
16
20
|
|
|
17
21
|
export default function App() {
|
|
18
22
|
return (
|
|
19
23
|
<div style={{ height: "100vh" }}>
|
|
20
24
|
<ReportDesigner
|
|
21
25
|
theme="light"
|
|
22
|
-
|
|
23
|
-
onChange={(template) => console.log(template)}
|
|
26
|
+
onTemplateChange={(template) => console.log(template)}
|
|
24
27
|
/>
|
|
25
28
|
</div>
|
|
26
29
|
);
|
|
@@ -29,68 +32,42 @@ export default function App() {
|
|
|
29
32
|
|
|
30
33
|
> The designer fills its parent container — set a `height` on the parent (e.g. `100vh` or a fixed px value).
|
|
31
34
|
|
|
32
|
-
## Props
|
|
33
|
-
|
|
34
|
-
| Prop | Type | Description |
|
|
35
|
-
|---|---|---|
|
|
36
|
-
| `report` | `Template` | Load a template into the designer. Updates when the prop changes. |
|
|
37
|
-
| `data` | `string \| object` | Sample data for `{{field}}` preview bindings. |
|
|
38
|
-
| `onDataChange` | `(data: string) => void` | Called when the user edits data inside the designer. |
|
|
39
|
-
| `theme` | `"light" \| "dark"` | Controlled color theme. |
|
|
40
|
-
| `onThemeChange` | `(theme: string) => void` | Called when the user clicks the theme toggle. |
|
|
41
|
-
| `accentColor` | `string` | Primary accent color (6-digit hex, e.g. `"#6c63ff"`). |
|
|
42
|
-
| `defaultZoom` | `number` | Initial zoom level (0.25–2.0). Default: `1`. |
|
|
43
|
-
| `toolbar` | `ToolbarConfig` | Show/hide or override toolbar actions. |
|
|
44
|
-
| `elements` | `ElementsConfig` | Whitelist or blacklist element types in the palette. |
|
|
45
|
-
| `style` | `CSSProperties` | Inline styles on the root container. |
|
|
46
|
-
| `className` | `string` | Extra CSS classes on the root container. |
|
|
47
|
-
|
|
48
35
|
## Controlled Template
|
|
49
36
|
|
|
50
|
-
|
|
51
|
-
const [template, setTemplate] = useState(initialTemplate);
|
|
52
|
-
|
|
53
|
-
<ReportDesigner
|
|
54
|
-
report={template}
|
|
55
|
-
onChange={setTemplate}
|
|
56
|
-
/>
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Toolbar Customization
|
|
37
|
+
Load an existing template and receive updates whenever the user makes a change:
|
|
60
38
|
|
|
61
39
|
```tsx
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
actions: {
|
|
65
|
-
save: {
|
|
66
|
-
label: "Save",
|
|
67
|
-
onClick: () => saveToServer(template),
|
|
68
|
-
},
|
|
69
|
-
load: false, // hide the Load button
|
|
70
|
-
},
|
|
71
|
-
}}
|
|
72
|
-
/>
|
|
73
|
-
```
|
|
40
|
+
import { ReportDesigner } from "@veztraa/report-designer";
|
|
41
|
+
import type { Template } from "@veztraa/report-core";
|
|
74
42
|
|
|
75
|
-
|
|
43
|
+
export default function ReportEditor({ saved }: { saved: Template }) {
|
|
44
|
+
const handleSave = async (template: Template) => {
|
|
45
|
+
await fetch("/api/templates/save", {
|
|
46
|
+
method: "POST",
|
|
47
|
+
headers: { "Content-Type": "application/json" },
|
|
48
|
+
body: JSON.stringify(template),
|
|
49
|
+
});
|
|
50
|
+
};
|
|
76
51
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<ReportDesigner
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
52
|
+
return (
|
|
53
|
+
<div style={{ height: "100vh" }}>
|
|
54
|
+
<ReportDesigner
|
|
55
|
+
initialTemplate={saved}
|
|
56
|
+
theme="light"
|
|
57
|
+
onTemplateChange={handleSave}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
83
62
|
```
|
|
84
63
|
|
|
85
|
-
##
|
|
86
|
-
|
|
87
|
-
```tsx
|
|
88
|
-
import { render } from "@veztraa/report-renderer";
|
|
64
|
+
## Props
|
|
89
65
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
66
|
+
| Prop | Type | Default | Description |
|
|
67
|
+
|---|---|---|---|
|
|
68
|
+
| `initialTemplate` | `Template` | blank A4 | Pre-load an existing template into the designer |
|
|
69
|
+
| `theme` | `"light" \| "dark"` | `"light"` | Color scheme — flips all CSS custom properties |
|
|
70
|
+
| `onTemplateChange` | `(t: Template) => void` | — | Called on every element add / move / resize / property change |
|
|
94
71
|
|
|
95
72
|
## Features
|
|
96
73
|
|
|
@@ -98,13 +75,29 @@ window.open(URL.createObjectURL(blob));
|
|
|
98
75
|
- Snap-to-grid with alignment guides
|
|
99
76
|
- Resize handles on all 8 corners/edges
|
|
100
77
|
- 50-step undo/redo
|
|
101
|
-
- Live PDF preview panel
|
|
78
|
+
- Live PDF preview panel (debounced 400ms)
|
|
102
79
|
- Dark / light theme
|
|
103
80
|
- Header, body, footer sections
|
|
104
81
|
- Layers panel with lock/hide/reorder
|
|
105
82
|
- Data panel for `{{field}}` preview bindings
|
|
106
|
-
|
|
83
|
+
|
|
84
|
+
## Keyboard Shortcuts
|
|
85
|
+
|
|
86
|
+
| Shortcut | Action |
|
|
87
|
+
|---|---|
|
|
88
|
+
| `Del` / `Backspace` | Delete selected element |
|
|
89
|
+
| `Ctrl+Z` | Undo |
|
|
90
|
+
| `Ctrl+Y` | Redo |
|
|
91
|
+
| `Ctrl+D` | Duplicate selected element |
|
|
92
|
+
| Arrow keys | Nudge 1px |
|
|
93
|
+
| `Shift+Arrows` | Nudge 10px |
|
|
94
|
+
| `Ctrl+Scroll` | Zoom in / out |
|
|
95
|
+
| `Space+Drag` | Pan canvas |
|
|
96
|
+
|
|
97
|
+
## Template Format
|
|
98
|
+
|
|
99
|
+
See [`@veztraa/report-core`](https://www.npmjs.com/package/@veztraa/report-core) for the full template schema and expression syntax.
|
|
107
100
|
|
|
108
101
|
## License
|
|
109
102
|
|
|
110
|
-
MIT © [Veztraa
|
|
103
|
+
MIT © [Veztraa Solutions](https://www.veztraa.com)
|