@paprize/react 0.0.12 → 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/README.md +76 -2
- package/dist/paprize-react.d.ts +0 -182
- package/dist/paprize-react.js +355 -403
- package/dist/paprize-react.js.map +1 -1
- package/dist/paprize-react.umd.cjs +2 -2
- package/dist/paprize-react.umd.cjs.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
1
|
# Paprize
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Build clean, print-ready reports with familiar web tools.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Paprize is a report-generation toolkit that lets you design pages with JavaScript/TypeScript, React, and CSS. Mark your layout with Paprize components, then let its pagination engine split content into polished, printable pages.
|
|
6
|
+
|
|
7
|
+
## Documentation
|
|
8
|
+
|
|
9
|
+
For guides, API references, and full examples, visit [paprize.page](https://paprize.page).
|
|
10
|
+
|
|
11
|
+
## Why Paprize
|
|
12
|
+
|
|
13
|
+
- **Web-native authoring**: Build reports with standard HTML and CSS.
|
|
14
|
+
- **Automatic pagination**: Split long content into pages without manual slicing.
|
|
15
|
+
- **Composable layout primitives**: Structure reports with sections, headers, footers, and content wrappers.
|
|
16
|
+
- **Print-ready output**: Configure A4, Letter, or custom sizes and margins.
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
## Packages
|
|
21
|
+
|
|
22
|
+
- `@paprize/react`: React components for report layout and pagination.
|
|
23
|
+
- `@paprize/vanilla`: Framework-agnostic DOM API.
|
|
24
|
+
- `@paprize/puppeteer`: PDF rendering adapter for server-side generation.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
Choose one UI package (`react` or `vanilla`), and if you need server-side PDF generation, pair it with the Puppeteer adapter.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# React
|
|
32
|
+
npm install @paprize/react @paprize/puppeteer
|
|
33
|
+
|
|
34
|
+
# Vanilla JavaScript/TypeScript
|
|
35
|
+
npm install @paprize/vanilla @paprize/puppeteer
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
### Vanilla HTML
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<div data-pz-preview>
|
|
44
|
+
<div data-pz-section>
|
|
45
|
+
<div data-pz-page-header>
|
|
46
|
+
<h2>Page <span data-pz-v-page-number></span></h2>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<div data-pz-page-content>...</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### React
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
function App() {
|
|
58
|
+
return (
|
|
59
|
+
<ReportRoot>
|
|
60
|
+
<ReportPreview>
|
|
61
|
+
<Section size={pageSize.A4}>
|
|
62
|
+
<PageHeader>
|
|
63
|
+
<Header />
|
|
64
|
+
</PageHeader>
|
|
65
|
+
|
|
66
|
+
<PageContent>
|
|
67
|
+
<Finance />
|
|
68
|
+
<Business />
|
|
69
|
+
</PageContent>
|
|
70
|
+
|
|
71
|
+
<PageFooter>
|
|
72
|
+
<Footer />
|
|
73
|
+
</PageFooter>
|
|
74
|
+
</Section>
|
|
75
|
+
</ReportPreview>
|
|
76
|
+
</ReportRoot>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
package/dist/paprize-react.d.ts
CHANGED
|
@@ -1,183 +1 @@
|
|
|
1
|
-
import { Context } from 'react';
|
|
2
|
-
import { JSX } from 'react/jsx-runtime';
|
|
3
|
-
import { LayoutOptions } from '@paprize/core';
|
|
4
|
-
import { PaginationCycleCompleted } from '@paprize/core';
|
|
5
|
-
import { PaginationPlugin } from '@paprize/core';
|
|
6
|
-
import { ReactNode } from 'react';
|
|
7
|
-
import { SectionContext } from '@paprize/core';
|
|
8
|
-
import { SectionOptions } from '@paprize/core';
|
|
9
|
-
|
|
10
|
-
export declare function Layout({ children, ...attributes }: LayoutProps): JSX.Element;
|
|
11
|
-
|
|
12
|
-
export declare interface LayoutProps extends LayoutOptions {
|
|
13
|
-
children: React.ReactNode;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export declare function PageBreak(): JSX.Element;
|
|
17
|
-
|
|
18
|
-
export declare function PageContent({ children }: {
|
|
19
|
-
children: ReactNode;
|
|
20
|
-
}): JSX.Element;
|
|
21
|
-
|
|
22
|
-
export declare function pageContextToPageInfo(pc: {
|
|
23
|
-
pageIndex: number;
|
|
24
|
-
totalPages: number;
|
|
25
|
-
}): PageInfo;
|
|
26
|
-
|
|
27
|
-
export declare function PageFooter({ children }: {
|
|
28
|
-
children: React.ReactNode;
|
|
29
|
-
}): JSX.Element;
|
|
30
|
-
|
|
31
|
-
export declare function PageHeader({ children }: {
|
|
32
|
-
children: ReactNode;
|
|
33
|
-
}): JSX.Element;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* {@inheritDoc @paprize/core!PageContext}
|
|
37
|
-
*/
|
|
38
|
-
export declare interface PageInfo {
|
|
39
|
-
/**
|
|
40
|
-
* {@inheritDoc @paprize/core!PageContext.pageIndex}
|
|
41
|
-
*/
|
|
42
|
-
pageIndex: number;
|
|
43
|
-
/**
|
|
44
|
-
* {@inheritDoc @paprize/core!PageContext.totalPages}
|
|
45
|
-
*/
|
|
46
|
-
totalPages: number;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export declare function PageOverlay({ children }: {
|
|
50
|
-
children: ReactNode;
|
|
51
|
-
}): JSX.Element;
|
|
52
|
-
|
|
53
|
-
export declare function paginationCycleToReportInfo(rc: PaginationCycleCompleted): ReportInfo;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* {@inheritDoc @paprize/core!PaginationCycleCompleted}
|
|
57
|
-
*/
|
|
58
|
-
export declare interface ReportInfo {
|
|
59
|
-
/**
|
|
60
|
-
* {@inheritDoc @paprize/core!PaginationCycleCompleted.sections}
|
|
61
|
-
*/
|
|
62
|
-
sections: SectionInfo[];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export declare function ReportPreview({ children }: {
|
|
66
|
-
children: ReactNode;
|
|
67
|
-
}): JSX.Element;
|
|
68
|
-
|
|
69
|
-
export declare function ReportRoot({ children }: ReportRootProps): JSX.Element;
|
|
70
|
-
|
|
71
|
-
export declare interface ReportRootProps {
|
|
72
|
-
children: ReactNode;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export declare function Section({ children, id, ...options }: SectionProps): JSX.Element;
|
|
76
|
-
|
|
77
|
-
export declare function sectionContextToSectionInfo(sc: SectionContext): SectionInfo;
|
|
78
|
-
|
|
79
|
-
export declare interface SectionController {
|
|
80
|
-
addPlugin: (plugin: PaginationPlugin) => void;
|
|
81
|
-
addSuspense: (suspense: Promise<void>) => void;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export declare const SectionControllerContext: Context<SectionController>;
|
|
85
|
-
|
|
86
|
-
export declare function SectionFooter({ children }: {
|
|
87
|
-
children: React.ReactNode;
|
|
88
|
-
}): JSX.Element;
|
|
89
|
-
|
|
90
|
-
export declare function SectionHeader({ children }: {
|
|
91
|
-
children: React.ReactNode;
|
|
92
|
-
}): JSX.Element;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* {@inheritDoc @paprize/core!SectionContext}
|
|
96
|
-
*/
|
|
97
|
-
export declare interface SectionInfo {
|
|
98
|
-
/**
|
|
99
|
-
* {@inheritDoc @paprize/core!SectionContext.sectionId}
|
|
100
|
-
*/
|
|
101
|
-
sectionId: string;
|
|
102
|
-
/**
|
|
103
|
-
* {@inheritDoc @paprize/core!SectionContext.sectionIndex}
|
|
104
|
-
*/
|
|
105
|
-
sectionIndex: number;
|
|
106
|
-
/**
|
|
107
|
-
* {@inheritDoc @paprize/core!SectionContext.isPaginated}
|
|
108
|
-
*/
|
|
109
|
-
isPaginated: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* {@inheritDoc @paprize/core!SectionContext.isSuspended}
|
|
112
|
-
*/
|
|
113
|
-
isSuspended: boolean;
|
|
114
|
-
/**
|
|
115
|
-
* {@inheritDoc @paprize/core!SectionContext.pages}
|
|
116
|
-
*/
|
|
117
|
-
pages: PageInfo[];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Configuration options for a section.
|
|
122
|
-
* @inlineType SectionOptions
|
|
123
|
-
*/
|
|
124
|
-
export declare interface SectionProps extends Omit<SectionOptions, 'id' | 'suspense'> {
|
|
125
|
-
children: ReactNode;
|
|
126
|
-
/**
|
|
127
|
-
* Unique id of the section within the report. If not set, a random id will be used.
|
|
128
|
-
*/
|
|
129
|
-
id?: string;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Controls the section suspension.
|
|
134
|
-
* @inline
|
|
135
|
-
*/
|
|
136
|
-
export declare interface SectionSuspension {
|
|
137
|
-
/**
|
|
138
|
-
* Releases the suspension. The pagination engine will paginate this section immediately.
|
|
139
|
-
*/
|
|
140
|
-
release: () => void;
|
|
141
|
-
/**
|
|
142
|
-
* Marks the suspension as pending again if it was previously resolved.
|
|
143
|
-
* During the next pagination cycle (for example, if pagination is retriggered
|
|
144
|
-
* by changes to the page content), this section will not be paginated
|
|
145
|
-
* until `release` is called again.
|
|
146
|
-
*/
|
|
147
|
-
reset: () => void;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* {@inheritDoc @paprize/core!ReportBuilder.getJsonData}
|
|
152
|
-
*/
|
|
153
|
-
export declare function useJsonData<DataModel>(defaultValue?: DataModel): DataModel | null;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* React hook that returns information about the current page.
|
|
157
|
-
*/
|
|
158
|
-
export declare const usePageInfo: () => PageInfo;
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* React hook that returns information about the report.
|
|
162
|
-
*/
|
|
163
|
-
export declare function useReportInfo(): ReportInfo;
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* React hook that returns information about the current section.
|
|
167
|
-
*/
|
|
168
|
-
export declare const useSectionInfo: () => SectionInfo;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Suspends pagination for this section.
|
|
172
|
-
* @param promise The suspension is tied to this promise. Once the promise is resolved,
|
|
173
|
-
* the suspension is released and the pagination engine will paginate this section.
|
|
174
|
-
*/
|
|
175
|
-
export declare function useSectionSuspension(promise: Promise<void> | Promise<unknown>): void;
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Suspends pagination for this section. You need to call the `release` method
|
|
179
|
-
* of the returned value; otherwise, the pagination engine will never paginate this section.
|
|
180
|
-
*/
|
|
181
|
-
export declare function useSectionSuspension(): SectionSuspension;
|
|
182
|
-
|
|
183
1
|
export { }
|