@veztraa/report-designer 0.2.8 → 0.2.10
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 +69 -36
- package/dist/assets/pdf.worker-DWXs1kay.js +102507 -0
- package/dist/canvas/CanvasElement.d.ts +2 -1
- package/dist/elements/ElementViews.d.ts +1 -0
- package/dist/icons.d.ts +1 -0
- package/dist/index.js +4075 -3591
- package/dist/preview/pdf.worker.d.ts +0 -0
- package/dist/preview/worker-globals.d.ts +1 -0
- package/dist/store/useReportStore.d.ts +8 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**[Documentation & Live Demo →](https://report-forge.veztraa.com)**
|
|
4
4
|
|
|
5
|
-
Embeddable React PDF report designer
|
|
5
|
+
Embeddable React drag-and-drop PDF report designer — a visual report builder you can drop into any React app. Give your users a Figma-like canvas for data-driven PDFs: drag-and-drop elements, live preview, undo/redo, dark mode, and `{{field}}` data bindings.
|
|
6
6
|
|
|
7
7
|
Styles auto-inject on mount — no CSS import required.
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ Styles auto-inject on mount — no CSS import required.
|
|
|
12
12
|
npm install @veztraa/report-designer
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## Quick start
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
18
|
import { ReportDesigner } from "@veztraa/report-designer";
|
|
@@ -21,20 +21,17 @@ import { ReportDesigner } from "@veztraa/report-designer";
|
|
|
21
21
|
export default function App() {
|
|
22
22
|
return (
|
|
23
23
|
<div style={{ height: "100vh" }}>
|
|
24
|
-
<ReportDesigner
|
|
25
|
-
theme="light"
|
|
26
|
-
onTemplateChange={(template) => console.log(template)}
|
|
27
|
-
/>
|
|
24
|
+
<ReportDesigner />
|
|
28
25
|
</div>
|
|
29
26
|
);
|
|
30
27
|
}
|
|
31
28
|
```
|
|
32
29
|
|
|
33
|
-
> The designer fills its parent
|
|
30
|
+
> The designer fills its parent — give the parent a `height` (e.g. `100vh` or a fixed px value).
|
|
34
31
|
|
|
35
|
-
##
|
|
32
|
+
## Load and save templates
|
|
36
33
|
|
|
37
|
-
|
|
34
|
+
Pass an existing template via `report` (the designer reloads whenever it changes), and capture the user's work via `toolbar.onSave`, which receives the current template when they click **Save**:
|
|
38
35
|
|
|
39
36
|
```tsx
|
|
40
37
|
import { ReportDesigner } from "@veztraa/report-designer";
|
|
@@ -42,7 +39,7 @@ import type { Template } from "@veztraa/report-core";
|
|
|
42
39
|
|
|
43
40
|
export default function ReportEditor({ saved }: { saved: Template }) {
|
|
44
41
|
const handleSave = async (template: Template) => {
|
|
45
|
-
await fetch("/api/templates
|
|
42
|
+
await fetch("/api/templates", {
|
|
46
43
|
method: "POST",
|
|
47
44
|
headers: { "Content-Type": "application/json" },
|
|
48
45
|
body: JSON.stringify(template),
|
|
@@ -52,9 +49,11 @@ export default function ReportEditor({ saved }: { saved: Template }) {
|
|
|
52
49
|
return (
|
|
53
50
|
<div style={{ height: "100vh" }}>
|
|
54
51
|
<ReportDesigner
|
|
55
|
-
|
|
52
|
+
report={saved}
|
|
53
|
+
data={{ company: { name: "Acme Corp" }, items: [] }}
|
|
56
54
|
theme="light"
|
|
57
|
-
|
|
55
|
+
accentColor="#6c63ff"
|
|
56
|
+
toolbar={{ onSave: handleSave }}
|
|
58
57
|
/>
|
|
59
58
|
</div>
|
|
60
59
|
);
|
|
@@ -63,44 +62,78 @@ export default function ReportEditor({ saved }: { saved: Template }) {
|
|
|
63
62
|
|
|
64
63
|
## Props
|
|
65
64
|
|
|
65
|
+
Every prop is optional — `<ReportDesigner />` is fully functional with none.
|
|
66
|
+
|
|
66
67
|
| Prop | Type | Default | Description |
|
|
67
68
|
|---|---|---|---|
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
69
|
+
| `report` | `Template` | blank A4 | Template JSON to load. Reloads the designer whenever it changes. |
|
|
70
|
+
| `data` | `string \| object` | `"{}"` | Preview data for `{{field}}` bindings — JSON string or plain object. |
|
|
71
|
+
| `onDataChange` | `(data: string) => void` | — | Fires when the user edits preview data inside the designer. |
|
|
72
|
+
| `theme` | `"light" \| "dark"` | `"light"` | Controlled color theme. Sync with your app's theme toggle. |
|
|
73
|
+
| `onThemeChange` | `(t: "light" \| "dark") => void` | — | Fires when the user toggles the theme inside the designer. |
|
|
74
|
+
| `accentColor` | `string` | `"#6c63ff"` | Primary accent (6-digit hex). All buttons, rings, and indicators derive from it. |
|
|
75
|
+
| `defaultZoom` | `number` | `1` | Initial canvas zoom (0.25–2.0). Applied once on mount. |
|
|
76
|
+
| `toolbar` | `ToolbarConfig` | show all | Hide built-in actions, override Save / Load, or add custom buttons. |
|
|
77
|
+
| `elements` | `ElementsConfig` | all types | Whitelist or blacklist which element types appear in the palette. |
|
|
78
|
+
| `style` | `CSSProperties` | — | Inline styles for the root container. |
|
|
79
|
+
| `className` | `string` | — | Extra class names for the root container. |
|
|
80
|
+
|
|
81
|
+
### ToolbarConfig
|
|
82
|
+
|
|
83
|
+
Passed as the `toolbar` prop. Every boolean defaults to `true` (visible).
|
|
84
|
+
|
|
85
|
+
| Field | Type | Description |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| `hidden` | `boolean` | Hide the entire toolbar. |
|
|
88
|
+
| `load` / `save` | `boolean` | Show the Load / Save buttons. |
|
|
89
|
+
| `history` | `boolean` | Show Undo / Redo. |
|
|
90
|
+
| `duplicate` / `delete` | `boolean` | Show Duplicate / Delete. |
|
|
91
|
+
| `sections` | `boolean` | Show the Header / Body / Footer switcher. |
|
|
92
|
+
| `preview` | `boolean` | Show the Preview PDF button. |
|
|
93
|
+
| `theme` / `zoom` | `boolean` | Show the theme toggle / zoom controls. |
|
|
94
|
+
| `onSave` | `(t: Template) => void` | Override Save — receives the current template instead of downloading JSON. |
|
|
95
|
+
| `onLoad` | `() => void` | Override Load — the default opens a JSON file picker. |
|
|
96
|
+
| `actions` | `ToolbarAction[]` | Custom buttons injected before the Preview button. |
|
|
97
|
+
|
|
98
|
+
### ElementsConfig
|
|
99
|
+
|
|
100
|
+
Passed as the `elements` prop. Use `include` (whitelist) **or** `exclude` (blacklist), not both.
|
|
101
|
+
|
|
102
|
+
| Field | Type | Description |
|
|
103
|
+
|---|---|---|
|
|
104
|
+
| `hidden` | `boolean` | Hide the Elements palette entirely. |
|
|
105
|
+
| `include` | `ElementType[]` | Only these types appear, in this order. |
|
|
106
|
+
| `exclude` | `ElementType[]` | Hide these types (ignored when `include` is set). |
|
|
107
|
+
|
|
108
|
+
`ElementType` is one of: `text`, `richtext`, `table`, `container`, `image`, `chart`, `barcode`, `qrcode`, `rectangle`, `line`, `pagebreak`.
|
|
71
109
|
|
|
72
110
|
## Features
|
|
73
111
|
|
|
74
|
-
- Drag-and-drop canvas
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
- 50-step undo/redo
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
- Layers panel with lock/hide/reorder
|
|
112
|
+
- **Drag-and-drop canvas** — snap-to-grid with alignment guides, 8-handle resize, arrow-key nudge
|
|
113
|
+
- **Live PDF preview rendered off the main thread** (Web Worker) — debounced 400ms with an adaptive loading UI, so even large multi-hundred-page reports never freeze the tab
|
|
114
|
+
- **Repeating containers** (data-bound bands) with **automatic pagination** — tables, rich text, and bands flow across pages, keeping items together where they fit
|
|
115
|
+
- **50-step undo / redo**
|
|
116
|
+
- **Light / dark theme** and a fully customizable accent color
|
|
117
|
+
- Header, body, and footer sections
|
|
118
|
+
- Layers panel with lock / hide / reorder
|
|
82
119
|
- Data panel for `{{field}}` preview bindings
|
|
120
|
+
- **JSON-first** — the designer is a visual editor for a plain `Template` object; load with `report`, save with `toolbar.onSave`
|
|
83
121
|
|
|
84
|
-
## Keyboard
|
|
122
|
+
## Keyboard shortcuts
|
|
85
123
|
|
|
86
124
|
| Shortcut | Action |
|
|
87
125
|
|---|---|
|
|
88
126
|
| `Del` / `Backspace` | Delete selected element |
|
|
89
|
-
| `Ctrl+Z` | Undo |
|
|
90
|
-
| `Ctrl+Y` | Redo |
|
|
91
|
-
| `Ctrl+D` | Duplicate selected element |
|
|
127
|
+
| `Ctrl/Cmd + Z` | Undo |
|
|
128
|
+
| `Ctrl/Cmd + Y` (or `Ctrl/Cmd + Shift + Z`) | Redo |
|
|
129
|
+
| `Ctrl/Cmd + D` | Duplicate selected element |
|
|
92
130
|
| Arrow keys | Nudge 1px |
|
|
93
|
-
| `Shift+Arrows` | Nudge 10px |
|
|
94
|
-
| `
|
|
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.
|
|
131
|
+
| `Shift + Arrows` | Nudge 10px |
|
|
132
|
+
| `Esc` | Close the PDF preview |
|
|
100
133
|
|
|
101
|
-
##
|
|
134
|
+
## Template format
|
|
102
135
|
|
|
103
|
-
|
|
136
|
+
See [`@veztraa/report-core`](https://www.npmjs.com/package/@veztraa/report-core) for the full template schema, element types, and expression syntax. Generate PDFs from a template on the server or in the browser with [`@veztraa/report-renderer`](https://www.npmjs.com/package/@veztraa/report-renderer).
|
|
104
137
|
|
|
105
138
|
## License
|
|
106
139
|
|