@veztraa/report-designer 0.2.9 → 0.2.11

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  **[Documentation & Live Demo →](https://report-forge.veztraa.com)**
4
4
 
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.
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
- ## Usage
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 container — set a `height` on the parent (e.g. `100vh` or a fixed px value).
30
+ > The designer fills its parent — give the parent a `height` (e.g. `100vh` or a fixed px value).
34
31
 
35
- ## Controlled Template
32
+ ## Load and save templates
36
33
 
37
- Load an existing template and receive updates whenever the user makes a change:
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/save", {
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
- initialTemplate={saved}
52
+ report={saved}
53
+ data={{ company: { name: "Acme Corp" }, items: [] }}
56
54
  theme="light"
57
- onTemplateChange={handleSave}
55
+ accentColor="#6c63ff"
56
+ toolbar={{ onSave: handleSave }}
58
57
  />
59
58
  </div>
60
59
  );
@@ -63,48 +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
- | `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 |
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 (div-based, no Fabric.js)
75
- - Snap-to-grid with alignment guides
76
- - Resize handles on all 8 corners/edges
77
- - 50-step undo/redo
78
- - **Live PDF preview rendered off the main thread** (Web Worker) — debounced
79
- 400ms, with an adaptive loading UI, so even large multi-hundred-page reports
80
- never freeze the tab
81
- - Repeating containers (data-bound bands) with automatic pagination — tables,
82
- rich text, and bands flow across pages, keeping items together where they fit
83
- - Dark / light theme
84
- - Header, body, footer sections
85
- - 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
86
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`
87
121
 
88
- ## Keyboard Shortcuts
122
+ ## Keyboard shortcuts
89
123
 
90
124
  | Shortcut | Action |
91
125
  |---|---|
92
126
  | `Del` / `Backspace` | Delete selected element |
93
- | `Ctrl+Z` | Undo |
94
- | `Ctrl+Y` | Redo |
95
- | `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 |
96
130
  | Arrow keys | Nudge 1px |
97
- | `Shift+Arrows` | Nudge 10px |
98
- | `Ctrl+Scroll` | Zoom in / out |
99
- | `Space+Drag` | Pan canvas |
100
-
101
- ## Template Format
102
-
103
- 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 |
104
133
 
105
- ## Keywords
134
+ ## Template format
106
135
 
107
- `pdf` `pdf-designer` `report-designer` `react` `react-component` `drag-and-drop` `pdf-editor` `report-builder` `embeddable` `canvas` `undo-redo` `dark-mode` `live-preview` `reportforge`
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).
108
137
 
109
138
  ## License
110
139