@veztraa/report-designer 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/dist/ReportDesigner.d.ts +35 -0
- package/dist/canvas/Canvas.d.ts +2 -0
- package/dist/canvas/CanvasElement.d.ts +9 -0
- package/dist/components/Collapse.d.ts +4 -0
- package/dist/components/Popup.d.ts +5 -0
- package/dist/elements/ElementViews.d.ts +15 -0
- package/dist/icons.d.ts +56 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10261 -0
- package/dist/panels/ComponentPalette.d.ts +15 -0
- package/dist/panels/DataVariablesModal.d.ts +1 -0
- package/dist/panels/DataVariablesPanel.d.ts +9 -0
- package/dist/panels/DocumentProperties.d.ts +1 -0
- package/dist/panels/LayersPanel.d.ts +1 -0
- package/dist/panels/LeftSidebar.d.ts +11 -0
- package/dist/panels/PropertiesPanel.d.ts +1 -0
- package/dist/preview/PdfPreview.d.ts +3 -0
- package/dist/store/useAlignGuides.d.ts +18 -0
- package/dist/store/useReportStore.d.ts +45 -0
- package/dist/templates.d.ts +19 -0
- package/dist/toolbar/Toolbar.d.ts +53 -0
- package/package.json +50 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReportElement } from '@veztraa/report-core';
|
|
2
|
+
/** Every element type the designer can create. */
|
|
3
|
+
export type ElementType = ReportElement["type"];
|
|
4
|
+
/** Controls which elements a user can add from the palette. */
|
|
5
|
+
export interface ElementsConfig {
|
|
6
|
+
/** Hide the entire Elements palette tab. */
|
|
7
|
+
hidden?: boolean;
|
|
8
|
+
/** Whitelist — only these types appear, in this order. */
|
|
9
|
+
include?: ElementType[];
|
|
10
|
+
/** Blacklist — hide these types from the palette. */
|
|
11
|
+
exclude?: ElementType[];
|
|
12
|
+
}
|
|
13
|
+
export declare function ComponentPalette({ config }?: {
|
|
14
|
+
config?: ElementsConfig;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function DataVariablesModal(): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function JsonModal({ title, subtitle, jsonText, jsonError, onClose, onChange }: {
|
|
2
|
+
title: string;
|
|
3
|
+
subtitle?: string;
|
|
4
|
+
jsonText: string;
|
|
5
|
+
jsonError: string;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
onChange: (v: string) => void;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
export declare function DataVariablesPanel(): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function DocumentProperties(): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function LayersPanel(): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ElementsConfig } from './ComponentPalette';
|
|
2
|
+
import { SidebarTab } from '../store/useReportStore';
|
|
3
|
+
declare const ALL_TABS: {
|
|
4
|
+
id: SidebarTab;
|
|
5
|
+
label: string;
|
|
6
|
+
icon: React.ReactNode;
|
|
7
|
+
}[];
|
|
8
|
+
export { ALL_TABS };
|
|
9
|
+
export declare function LeftSidebar({ elements }?: {
|
|
10
|
+
elements?: ElementsConfig;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PropertiesPanel(): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface AlignGuide {
|
|
2
|
+
axis: "h" | "v";
|
|
3
|
+
pos: number;
|
|
4
|
+
}
|
|
5
|
+
export interface ElBounds {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
w: number;
|
|
9
|
+
h: number;
|
|
10
|
+
}
|
|
11
|
+
interface GuidesStore {
|
|
12
|
+
guides: AlignGuide[];
|
|
13
|
+
elBounds: ElBounds | null;
|
|
14
|
+
set: (guides: AlignGuide[], elBounds: ElBounds) => void;
|
|
15
|
+
clear: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const useAlignGuides: import('zustand').UseBoundStore<import('zustand').StoreApi<GuidesStore>>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Template, ReportElement } from '@veztraa/report-core';
|
|
2
|
+
export type SidebarTab = "components" | "layers" | "data" | "document";
|
|
3
|
+
interface ReportStore {
|
|
4
|
+
template: Template;
|
|
5
|
+
selectedId: string | null;
|
|
6
|
+
history: Template[];
|
|
7
|
+
future: Template[];
|
|
8
|
+
zoom: number;
|
|
9
|
+
activeSection: "header" | "body" | "footer";
|
|
10
|
+
sidebarTab: SidebarTab;
|
|
11
|
+
showPreview: boolean;
|
|
12
|
+
showDataPanel: boolean;
|
|
13
|
+
previewData: string;
|
|
14
|
+
fieldTypes: Record<string, string>;
|
|
15
|
+
theme: "dark" | "light";
|
|
16
|
+
selectElement: (id: string | null) => void;
|
|
17
|
+
toggleTheme: () => void;
|
|
18
|
+
setTheme: (theme: "dark" | "light") => void;
|
|
19
|
+
addElement: (el: ReportElement) => void;
|
|
20
|
+
updateElement: (id: string, patch: Partial<ReportElement>) => void;
|
|
21
|
+
deleteSelected: () => void;
|
|
22
|
+
duplicateSelected: () => void;
|
|
23
|
+
undo: () => void;
|
|
24
|
+
redo: () => void;
|
|
25
|
+
setTemplateName: (name: string) => void;
|
|
26
|
+
loadTemplate: (t: Template) => void;
|
|
27
|
+
getTemplate: () => Template;
|
|
28
|
+
updatePage: (patch: Partial<NonNullable<Template["page"]>>) => void;
|
|
29
|
+
updateMargin: (side: "top" | "right" | "bottom" | "left", v: number) => void;
|
|
30
|
+
updateHeaderHeight: (h: number) => void;
|
|
31
|
+
updateFooterHeight: (h: number) => void;
|
|
32
|
+
updateHeaderEnabled: (v: boolean) => void;
|
|
33
|
+
updateFooterEnabled: (v: boolean) => void;
|
|
34
|
+
updateHeaderDisplay: (v: string) => void;
|
|
35
|
+
updateFooterDisplay: (v: string) => void;
|
|
36
|
+
setZoom: (z: number) => void;
|
|
37
|
+
setActiveSection: (s: "header" | "body" | "footer") => void;
|
|
38
|
+
setSidebarTab: (tab: SidebarTab) => void;
|
|
39
|
+
togglePreview: () => void;
|
|
40
|
+
toggleDataPanel: () => void;
|
|
41
|
+
setPreviewData: (data: string) => void;
|
|
42
|
+
setFieldTypes: (types: Record<string, string>) => void;
|
|
43
|
+
}
|
|
44
|
+
export declare const useReportStore: import('zustand').UseBoundStore<import('zustand').StoreApi<ReportStore>>;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Template } from '@veztraa/report-core';
|
|
2
|
+
export declare const BLANK_TEMPLATE: Template;
|
|
3
|
+
export declare const BLANK_DATA = "{}";
|
|
4
|
+
export declare const INVOICE_TEMPLATE: Template;
|
|
5
|
+
export declare const INVOICE_DATA: string;
|
|
6
|
+
export declare const ALL_ELEMENTS_TEMPLATE: Template;
|
|
7
|
+
export declare const ALL_ELEMENTS_DATA: string;
|
|
8
|
+
export declare const TABLE_CLEAN_TEMPLATE: Template;
|
|
9
|
+
export declare const TABLE_CLEAN_DATA: string;
|
|
10
|
+
export declare const TABLE_STRIPED_TEMPLATE: Template;
|
|
11
|
+
export declare const TABLE_STRIPED_DATA: string;
|
|
12
|
+
export declare const TABLE_FINANCIAL_TEMPLATE: Template;
|
|
13
|
+
export declare const TABLE_FINANCIAL_DATA: string;
|
|
14
|
+
export declare const CHART_BAR_TEMPLATE: Template;
|
|
15
|
+
export declare const CHART_BAR_DATA: string;
|
|
16
|
+
export declare const CHART_LINE_TEMPLATE: Template;
|
|
17
|
+
export declare const CHART_LINE_DATA: string;
|
|
18
|
+
export declare const CHART_PIE_TEMPLATE: Template;
|
|
19
|
+
export declare const CHART_PIE_DATA: string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ElementsConfig } from '../panels/ComponentPalette';
|
|
3
|
+
import { Template } from '@veztraa/report-core';
|
|
4
|
+
/** A host-supplied custom button injected into the toolbar. */
|
|
5
|
+
export interface ToolbarAction {
|
|
6
|
+
/** Unique identifier for the action button. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Button text label (shown next to the icon). */
|
|
9
|
+
label?: string;
|
|
10
|
+
/** Tooltip text shown on hover. */
|
|
11
|
+
title?: string;
|
|
12
|
+
/** Icon node (e.g. a Lucide icon). */
|
|
13
|
+
icon?: ReactNode;
|
|
14
|
+
/** Called when the button is clicked. Receives the current template JSON. */
|
|
15
|
+
onClick: (template: Template) => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Controls the designer's top navbar. Every built-in action defaults to visible;
|
|
19
|
+
* set a flag to `false` to hide it. Provide `onSave`/`onLoad` to replace the
|
|
20
|
+
* default download/file-picker behavior, and `actions` to add your own buttons.
|
|
21
|
+
*/
|
|
22
|
+
export interface ToolbarConfig {
|
|
23
|
+
/** Hide the entire toolbar. */
|
|
24
|
+
hidden?: boolean;
|
|
25
|
+
/** Show the Load (open JSON file) button. Default `true`. */
|
|
26
|
+
load?: boolean;
|
|
27
|
+
/** Show the Save button. Default `true`. Pair with `onSave` to override the default download. */
|
|
28
|
+
save?: boolean;
|
|
29
|
+
/** Show the Undo / Redo buttons. Default `true`. */
|
|
30
|
+
history?: boolean;
|
|
31
|
+
/** Show the Duplicate button. Default `true`. */
|
|
32
|
+
duplicate?: boolean;
|
|
33
|
+
/** Show the Delete button. Default `true`. */
|
|
34
|
+
delete?: boolean;
|
|
35
|
+
/** Show the Header / Body / Footer section switcher. Default `true`. */
|
|
36
|
+
sections?: boolean;
|
|
37
|
+
/** Show the Preview PDF button. Default `true`. */
|
|
38
|
+
preview?: boolean;
|
|
39
|
+
/** Show the light/dark theme toggle. Default `true`. */
|
|
40
|
+
theme?: boolean;
|
|
41
|
+
/** Show the zoom controls. Default `true`. */
|
|
42
|
+
zoom?: boolean;
|
|
43
|
+
/** Replace the built-in "Save" (download JSON). Receives the current template. */
|
|
44
|
+
onSave?: (template: Template) => void;
|
|
45
|
+
/** Replace the built-in "Load" (file picker). */
|
|
46
|
+
onLoad?: () => void;
|
|
47
|
+
/** Extra buttons rendered just before the Preview button. */
|
|
48
|
+
actions?: ToolbarAction[];
|
|
49
|
+
}
|
|
50
|
+
export declare function Toolbar({ config, elements }?: {
|
|
51
|
+
config?: ToolbarConfig;
|
|
52
|
+
elements?: ElementsConfig;
|
|
53
|
+
}): import("react").JSX.Element | null;
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@veztraa/report-designer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Embeddable React PDF report designer component",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./style.css": "./dist/style.css"
|
|
16
|
+
},
|
|
17
|
+
"files": ["dist"],
|
|
18
|
+
"publishConfig": { "access": "public" },
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "vite build",
|
|
21
|
+
"dev": "vite build --watch",
|
|
22
|
+
"clean": "rm -rf dist"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
26
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@veztraa/report-core": "workspace:*",
|
|
30
|
+
"@veztraa/report-renderer": "workspace:*",
|
|
31
|
+
"zustand": "^5.0.2"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@react-pdf/renderer": "^4.1.6",
|
|
35
|
+
"@types/qrcode": "^1.5.6",
|
|
36
|
+
"@types/react": "^18.3.12",
|
|
37
|
+
"@types/react-dom": "^18.3.1",
|
|
38
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
39
|
+
"autoprefixer": "^10.4.20",
|
|
40
|
+
"jsbarcode": "^3.12.3",
|
|
41
|
+
"postcss": "^8.4.49",
|
|
42
|
+
"qrcode": "^1.5.4",
|
|
43
|
+
"react": "^18.3.1",
|
|
44
|
+
"react-dom": "^18.3.1",
|
|
45
|
+
"tailwindcss": "^3.4.17",
|
|
46
|
+
"typescript": "^5.7.2",
|
|
47
|
+
"vite": "^6.0.5",
|
|
48
|
+
"vite-plugin-dts": "^4.3.0"
|
|
49
|
+
}
|
|
50
|
+
}
|