paged-react 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 +173 -0
- package/dist/components/context.d.ts +4 -0
- package/dist/components/context.d.ts.map +1 -0
- package/dist/components/context.js +3 -0
- package/dist/components/context.js.map +1 -0
- package/dist/components/document.d.ts +25 -0
- package/dist/components/document.d.ts.map +1 -0
- package/dist/components/document.js +77 -0
- package/dist/components/document.js.map +1 -0
- package/dist/components/page-break.d.ts +2 -0
- package/dist/components/page-break.d.ts.map +1 -0
- package/dist/components/page-break.js +6 -0
- package/dist/components/page-break.js.map +1 -0
- package/dist/components/watermark.d.ts +7 -0
- package/dist/components/watermark.d.ts.map +1 -0
- package/dist/components/watermark.js +45 -0
- package/dist/components/watermark.js.map +1 -0
- package/dist/core/avoid-break.d.ts +2 -0
- package/dist/core/avoid-break.d.ts.map +1 -0
- package/dist/core/avoid-break.js +30 -0
- package/dist/core/avoid-break.js.map +1 -0
- package/dist/core/computed-style.d.ts +19 -0
- package/dist/core/computed-style.d.ts.map +1 -0
- package/dist/core/computed-style.js +16 -0
- package/dist/core/computed-style.js.map +1 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/layout-ready.d.ts +2 -0
- package/dist/core/layout-ready.d.ts.map +1 -0
- package/dist/core/layout-ready.js +23 -0
- package/dist/core/layout-ready.js.map +1 -0
- package/dist/core/page-break.d.ts +2 -0
- package/dist/core/page-break.d.ts.map +1 -0
- package/dist/core/page-break.js +25 -0
- package/dist/core/page-break.js.map +1 -0
- package/dist/core/paginate.d.ts +8 -0
- package/dist/core/paginate.d.ts.map +1 -0
- package/dist/core/paginate.js +241 -0
- package/dist/core/paginate.js.map +1 -0
- package/dist/core/text-break.d.ts +5 -0
- package/dist/core/text-break.d.ts.map +1 -0
- package/dist/core/text-break.js +65 -0
- package/dist/core/text-break.js.map +1 -0
- package/dist/core/utils.d.ts +41 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/core/utils.js +90 -0
- package/dist/core/utils.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/page-sizes.d.ts +67 -0
- package/dist/page-sizes.d.ts.map +1 -0
- package/dist/page-sizes.js +19 -0
- package/dist/page-sizes.js.map +1 -0
- package/dist/styles.css +46 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/page-size.d.ts +3 -0
- package/dist/utils/page-size.d.ts.map +1 -0
- package/dist/utils/page-size.js +8 -0
- package/dist/utils/page-size.js.map +1 -0
- package/package.json +70 -0
package/README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# paged-react
|
|
2
|
+
|
|
3
|
+
React components for building print-ready documents with automatic pagination.
|
|
4
|
+
|
|
5
|
+
The examples below use the expected npm package name:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install paged-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
Import the components and the package stylesheet once in your app.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Document, PageBreak, pageSizes } from "paged-react";
|
|
17
|
+
import "paged-react/styles.css";
|
|
18
|
+
// The package imports its base CSS from the main entry. If your bundler does not load library CSS side effects, import `paged-react/styles.css` manually.
|
|
19
|
+
|
|
20
|
+
export function Report() {
|
|
21
|
+
return (
|
|
22
|
+
<Document>
|
|
23
|
+
<Document.Segment pageSize={pageSizes.A4} className="report-page">
|
|
24
|
+
<Document.Header>
|
|
25
|
+
<h1>Monthly Report</h1>
|
|
26
|
+
</Document.Header>
|
|
27
|
+
|
|
28
|
+
<Document.Body>
|
|
29
|
+
<p>This content will be split into pages when it gets too long.</p>
|
|
30
|
+
<PageBreak />
|
|
31
|
+
<p>This starts on the next page.</p>
|
|
32
|
+
</Document.Body>
|
|
33
|
+
|
|
34
|
+
<Document.Footer>
|
|
35
|
+
<span>Company footer</span>
|
|
36
|
+
</Document.Footer>
|
|
37
|
+
</Document.Segment>
|
|
38
|
+
</Document>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`Document.Segment` must receive a `pageSize`. Use a built-in size such as `pageSizes.A4`, `pageSizes.Letter`, or pass your own size object:
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
<Document.Segment pageSize={{ width: "210mm", height: "297mm" }}>
|
|
47
|
+
{/* header, body, and footer */}
|
|
48
|
+
</Document.Segment>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Printing
|
|
52
|
+
|
|
53
|
+
`paged-react` creates the paginated DOM. Use `react-to-print` to open the browser print dialog.
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { useRef } from "react";
|
|
57
|
+
import { useReactToPrint } from "react-to-print"; // npm i react-to-print
|
|
58
|
+
import { Document, pageSizes } from "paged-react";
|
|
59
|
+
import "paged-react/styles.css";
|
|
60
|
+
|
|
61
|
+
export function PrintableReport() {
|
|
62
|
+
const contentRef = useRef<HTMLDivElement>(null);
|
|
63
|
+
const print = useReactToPrint({ contentRef });
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
<button type="button" onClick={print}>
|
|
68
|
+
Print
|
|
69
|
+
</button>
|
|
70
|
+
|
|
71
|
+
<Document ref={contentRef}>
|
|
72
|
+
<Document.Segment pageSize={pageSizes.A4}>
|
|
73
|
+
<Document.Header>Header</Document.Header>
|
|
74
|
+
<Document.Body>Report content</Document.Body>
|
|
75
|
+
<Document.Footer>Footer</Document.Footer>
|
|
76
|
+
</Document.Segment>
|
|
77
|
+
</Document>
|
|
78
|
+
</>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Optional Screen Preview CSS
|
|
84
|
+
|
|
85
|
+
The package CSS handles the document structure. Add this optional CSS in your app to make pages look nicer on screen before printing:
|
|
86
|
+
|
|
87
|
+
```css
|
|
88
|
+
@media screen {
|
|
89
|
+
[data-paged-react-pages] {
|
|
90
|
+
gap: 24px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[data-paged-react-page] {
|
|
94
|
+
border: 1px solid gray;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Main Pieces
|
|
100
|
+
|
|
101
|
+
- `Document`: the root component. Attach your print ref here.
|
|
102
|
+
- `Document.Segment`: one paginated section with its own page size.
|
|
103
|
+
- `Document.Header`: repeated at the top of every generated page in the segment.
|
|
104
|
+
- `Document.Body`: the content that gets split across pages.
|
|
105
|
+
- `Document.Footer`: repeated at the bottom of every generated page in the segment.
|
|
106
|
+
- `PageBreak`: starts following content on a new page.
|
|
107
|
+
- `Watermark`: renders a watermark inside the document.
|
|
108
|
+
- `pageSizes`: built-in page sizes, including A-series, B4, B5, Letter, Legal, and Ledger.
|
|
109
|
+
|
|
110
|
+
Slots accept normal `div` props such as `className`, `style`, `id`, `data-*`, and `aria-*`.
|
|
111
|
+
|
|
112
|
+
## Watermark
|
|
113
|
+
|
|
114
|
+
Use `Watermark` inside `Document`. It receives a render function with the current zero-based `pageIndex` and the generated `pages` array. The `Watermark` component gets copied over and rendered to every-single page.
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
<Document>
|
|
118
|
+
<Document.Segment pageSize={pageSizes.A4}>
|
|
119
|
+
<Document.Body>Report content</Document.Body>
|
|
120
|
+
</Document.Segment>
|
|
121
|
+
|
|
122
|
+
<Watermark>
|
|
123
|
+
{({ pageIndex, pages }) => (
|
|
124
|
+
<div>
|
|
125
|
+
Draft - page {pageIndex + 1} of {pages.length}
|
|
126
|
+
</div>
|
|
127
|
+
)}
|
|
128
|
+
</Watermark>
|
|
129
|
+
</Document>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The rendered watermark is portaled into each generated page.
|
|
133
|
+
|
|
134
|
+
## Tables
|
|
135
|
+
|
|
136
|
+
Direct child `<table>` elements inside `Document.Body` can be split by row when they overflow a page.
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
<Document.Segment pageSize={pageSizes.A4} repeatTableHeader>
|
|
140
|
+
<Document.Body>
|
|
141
|
+
<table>{/* rows */}</table>
|
|
142
|
+
</Document.Body>
|
|
143
|
+
</Document.Segment>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
If a table has a `<thead>`, the first table fragment keeps that header even when `repeatTableHeader` is not set. Use `repeatTableHeader` on `Document.Segment` when continuation pages should also repeat the original `<thead>`.
|
|
147
|
+
|
|
148
|
+
## Page Breaks
|
|
149
|
+
|
|
150
|
+
Use `PageBreak` for an explicit new page. This is the supported way to force a page break.
|
|
151
|
+
|
|
152
|
+
`page-break-inside: avoid` is supported as a keep-together hint. Use it when a block should move to the next page instead of being split across pages.
|
|
153
|
+
|
|
154
|
+
`break-before`, `page-break-before`, `break-after`, and `page-break-after` are intentionally ignored. Use `PageBreak` so there is only one explicit way to force a new page.
|
|
155
|
+
|
|
156
|
+
## Limitations
|
|
157
|
+
|
|
158
|
+
- This is not a full browser print engine. It uses DOM measurement and cloning to build pages.
|
|
159
|
+
- Pagination runs in the browser, so output can vary slightly between browsers, fonts, zoom levels, and loaded assets.
|
|
160
|
+
- Very complex layouts can be difficult to split perfectly, especially grids, flex-heavy layouts, positioned elements, transforms, and deeply nested components.
|
|
161
|
+
- If an item cannot be broken down and does not fit in one page, it stays on a single generated page and is clipped.
|
|
162
|
+
- Tables are best supported when the table is a direct child of `Document.Body`.
|
|
163
|
+
- Images and custom fonts should be loaded before printing for the most reliable result.
|
|
164
|
+
- Server-side rendering cannot know final page breaks because pagination depends on browser layout measurement.
|
|
165
|
+
|
|
166
|
+
## Styling Hooks
|
|
167
|
+
|
|
168
|
+
- `[data-paged-react-document]`: root container
|
|
169
|
+
- `[data-paged-react-pages]`: generated pages wrapper
|
|
170
|
+
- `[data-paged-react-page]`: generated page
|
|
171
|
+
- `[data-paged-react-page-header]`: rendered header slot
|
|
172
|
+
- `[data-paged-react-page-body]`: rendered body slot
|
|
173
|
+
- `[data-paged-react-page-footer]`: rendered footer slot
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/components/context.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO;WAA0B,WAAW,EAAE,GAAG,IAAI;SAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/components/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAyC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import type { DocumentProps } from "../types.js";
|
|
3
|
+
type DocumentComponent = ReturnType<typeof forwardRef<HTMLDivElement, DocumentProps>> & {
|
|
4
|
+
Segment: typeof DocumentSegment;
|
|
5
|
+
Header: typeof DocumentHeader;
|
|
6
|
+
Body: typeof DocumentBody;
|
|
7
|
+
Footer: typeof DocumentFooter;
|
|
8
|
+
};
|
|
9
|
+
export declare const DocumentSegment: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
10
|
+
children: import("react").ReactNode;
|
|
11
|
+
pageSize: import("../types.js").PageSize;
|
|
12
|
+
repeatTableHeader?: boolean;
|
|
13
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export declare const DocumentHeader: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
15
|
+
children: import("react").ReactNode;
|
|
16
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
17
|
+
export declare const DocumentBody: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
18
|
+
children: import("react").ReactNode;
|
|
19
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
20
|
+
export declare const DocumentFooter: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
21
|
+
children: import("react").ReactNode;
|
|
22
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
23
|
+
export declare const Document: DocumentComponent;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/components/document.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwC,MAAM,OAAO,CAAC;AAGzE,OAAO,KAAK,EAIV,aAAa,EAEd,MAAM,aAAa,CAAC;AAGrB,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,GAAG;IACtF,OAAO,EAAE,OAAO,eAAe,CAAC;IAChC,MAAM,EAAE,OAAO,cAAc,CAAC;IAC9B,IAAI,EAAE,OAAO,YAAY,CAAC;IAC1B,MAAM,EAAE,OAAO,cAAc,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;kDAsB3B,CAAC;AAEF,eAAO,MAAM,cAAc;;kDAQ1B,CAAC;AAEF,eAAO,MAAM,YAAY;;kDASvB,CAAC;AAEH,eAAO,MAAM,cAAc;;kDAQ1B,CAAC;AA4EF,eAAO,MAAM,QAAQ,EAKf,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { paginateDocument } from "../core/paginate.js";
|
|
4
|
+
import { resolvePageSize } from "../utils/page-size.js";
|
|
5
|
+
import { context } from "./context.js";
|
|
6
|
+
export const DocumentSegment = forwardRef(function DocumentSegment({ children, pageSize, repeatTableHeader, style, ...props }, ref) {
|
|
7
|
+
const resolvedPageSize = resolvePageSize(pageSize);
|
|
8
|
+
return (_jsx("div", { ...props, ref: ref, "data-paged-react-repeat-table-header": String(repeatTableHeader === true), "data-paged-react-page-height": resolvedPageSize.height, "data-paged-react-page-width": resolvedPageSize.width, "data-paged-react-segment-source": "", style: {
|
|
9
|
+
...style,
|
|
10
|
+
minHeight: resolvedPageSize.height,
|
|
11
|
+
width: resolvedPageSize.width,
|
|
12
|
+
}, children: children }));
|
|
13
|
+
});
|
|
14
|
+
export const DocumentHeader = forwardRef(function DocumentHeader({ children, ...props }, ref) {
|
|
15
|
+
return (_jsx("div", { ...props, ref: ref, "data-paged-react-header-source": "", children: children }));
|
|
16
|
+
});
|
|
17
|
+
export const DocumentBody = forwardRef(function DocumentBody({ children, ...props }, ref) {
|
|
18
|
+
return (_jsx("div", { ...props, ref: ref, "data-paged-react-body-source": "", children: children }));
|
|
19
|
+
});
|
|
20
|
+
export const DocumentFooter = forwardRef(function DocumentFooter({ children, ...props }, ref) {
|
|
21
|
+
return (_jsx("div", { ...props, ref: ref, "data-paged-react-footer-source": "", children: children }));
|
|
22
|
+
});
|
|
23
|
+
const DocumentRoot = forwardRef(function Document({ children, ...props }, ref) {
|
|
24
|
+
const sourceRef = useRef(null);
|
|
25
|
+
const pagesRef = useRef(null);
|
|
26
|
+
const [pages, setPages] = useState(null);
|
|
27
|
+
const mergedRef = useMemo(() => {
|
|
28
|
+
return (node) => {
|
|
29
|
+
pagesRef.current = node;
|
|
30
|
+
if (typeof ref === "function") {
|
|
31
|
+
ref(node);
|
|
32
|
+
}
|
|
33
|
+
else if (ref) {
|
|
34
|
+
ref.current = node;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}, [ref]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const sourceRoot = sourceRef.current;
|
|
40
|
+
const pagesRoot = pagesRef.current;
|
|
41
|
+
if (!sourceRoot) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!pagesRoot) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const abortController = new AbortController();
|
|
48
|
+
setPages(null);
|
|
49
|
+
void paginateDocument({
|
|
50
|
+
sourceRoot,
|
|
51
|
+
pagesRoot,
|
|
52
|
+
signal: abortController.signal,
|
|
53
|
+
}).then((generatedPages) => {
|
|
54
|
+
if (abortController.signal.aborted) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
setPages(generatedPages);
|
|
58
|
+
});
|
|
59
|
+
return () => {
|
|
60
|
+
abortController.abort();
|
|
61
|
+
};
|
|
62
|
+
}, [children]);
|
|
63
|
+
return (_jsx(context.Provider, { value: { pages }, children: _jsxs("div", { "data-paged-react-document-source": true, style: { display: "contents" }, children: [_jsx("div", { "data-paged-react-root-source": true, ref: sourceRef, style: {
|
|
64
|
+
left: "-100000px",
|
|
65
|
+
pointerEvents: "none",
|
|
66
|
+
position: "absolute",
|
|
67
|
+
visibility: "hidden",
|
|
68
|
+
top: 0,
|
|
69
|
+
}, children: children }), _jsx("div", { "data-paged-react-pages": true, ref: mergedRef, ...props })] }) }));
|
|
70
|
+
});
|
|
71
|
+
export const Document = Object.assign(DocumentRoot, {
|
|
72
|
+
Segment: DocumentSegment,
|
|
73
|
+
Header: DocumentHeader,
|
|
74
|
+
Body: DocumentBody,
|
|
75
|
+
Footer: DocumentFooter,
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL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export declare const PageBreak: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
2
|
+
//# sourceMappingURL=page-break.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-break.d.ts","sourceRoot":"","sources":["../../src/components/page-break.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,8MAUrB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
export const PageBreak = forwardRef(function PageBreak(props, ref) {
|
|
4
|
+
return (_jsx("span", { ...props, ref: ref, "data-paged-react-page-break": "" }));
|
|
5
|
+
});
|
|
6
|
+
//# sourceMappingURL=page-break.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-break.js","sourceRoot":"","sources":["../../src/components/page-break.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGnC,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CACjC,SAAS,SAAS,CAAC,KAAK,EAAE,GAAG;IAC3B,OAAO,CACL,kBACM,KAAK,EACT,GAAG,EAAE,GAAG,iCACoB,EAAE,GAC9B,CACH,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watermark.d.ts","sourceRoot":"","sources":["../../src/components/watermark.tsx"],"names":[],"mappings":"AAIA,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAC/B,QAAQ,EAAE,CAAC,GAAG,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,WAAW,EAAE,CAAA;KAAE,KAAK,KAAK,CAAC,SAAS,CAAC;CACjF,wCAkDA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useContext, useEffect, useMemo } from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
import { context } from "./context.js";
|
|
4
|
+
export function Watermark(props) {
|
|
5
|
+
const { children } = props;
|
|
6
|
+
const ctx = useContext(context);
|
|
7
|
+
if (ctx === null) {
|
|
8
|
+
throw "Watermark component must be used within a Document component";
|
|
9
|
+
}
|
|
10
|
+
const { pages } = ctx;
|
|
11
|
+
const wrappers = useMemo(() => {
|
|
12
|
+
if (pages === null) {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
return pages.map(() => {
|
|
16
|
+
const wrapper = document.createElement("div");
|
|
17
|
+
wrapper.setAttribute("data-paged-react-watermark", "");
|
|
18
|
+
return wrapper;
|
|
19
|
+
});
|
|
20
|
+
}, [pages]);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (pages === null) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
for (const [pageIndex, page] of pages.entries()) {
|
|
26
|
+
const wrapper = wrappers[pageIndex];
|
|
27
|
+
if (wrapper === undefined) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
page.appendChild(wrapper);
|
|
31
|
+
}
|
|
32
|
+
return () => {
|
|
33
|
+
for (const wrapper of wrappers) {
|
|
34
|
+
wrapper.remove();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}, [pages, wrappers]);
|
|
38
|
+
if (pages === null) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return wrappers.map((wrapper, pageIndex) => {
|
|
42
|
+
return createPortal(children({ pageIndex, pages }), wrapper, String(pageIndex));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=watermark.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watermark.js","sourceRoot":"","sources":["../../src/components/watermark.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,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EAAE,CAAC;gBAC/B,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEtB,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE;QACzC,OAAO,YAAY,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avoid-break.d.ts","sourceRoot":"","sources":["../../src/core/avoid-break.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAoCzD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function canBreakElement(element) {
|
|
2
|
+
if (!(element instanceof HTMLElement)) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
const tagName = element.tagName.toUpperCase();
|
|
6
|
+
if ([
|
|
7
|
+
"SVG",
|
|
8
|
+
"IMG",
|
|
9
|
+
"CANVAS",
|
|
10
|
+
"VIDEO",
|
|
11
|
+
"IFRAME",
|
|
12
|
+
"OBJECT",
|
|
13
|
+
"EMBED",
|
|
14
|
+
"INPUT",
|
|
15
|
+
"TEXTAREA",
|
|
16
|
+
"SELECT",
|
|
17
|
+
"BUTTON",
|
|
18
|
+
].includes(tagName)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const computedStyle = getComputedStyle(element);
|
|
22
|
+
if (["avoid", "avoid-page", "avoid-column"].includes(computedStyle.breakInside)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (computedStyle.pageBreakInside === "avoid") {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=avoid-break.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avoid-break.js","sourceRoot":"","sources":["../../src/core/avoid-break.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,IAAI,CAAC,CAAC,OAAO,YAAY,WAAW,CAAC,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IAE9C,IACE;QACE,KAAK;QACL,KAAK;QACL,QAAQ;QACR,OAAO;QACP,QAAQ;QACR,QAAQ;QACR,OAAO;QACP,OAAO;QACP,UAAU;QACV,QAAQ;QACR,QAAQ;KACT,CAAC,QAAQ,CAAC,OAAO,CAAC,EACnB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAEhD,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;QAChF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,aAAa,CAAC,eAAe,KAAK,OAAO,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type BoxStyle = {
|
|
2
|
+
borderTopWidth: number;
|
|
3
|
+
borderBottomWidth: number;
|
|
4
|
+
marginTop: number;
|
|
5
|
+
marginBottom: number;
|
|
6
|
+
paddingTop: number;
|
|
7
|
+
paddingBottom: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function createComputedStyleCache(): {
|
|
10
|
+
get(element: Element): {
|
|
11
|
+
borderBottomWidth: number;
|
|
12
|
+
borderTopWidth: number;
|
|
13
|
+
marginBottom: number;
|
|
14
|
+
marginTop: number;
|
|
15
|
+
paddingBottom: number;
|
|
16
|
+
paddingTop: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=computed-style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed-style.d.ts","sourceRoot":"","sources":["../../src/core/computed-style.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAgB,wBAAwB;iBAIvB,OAAO;;;;;;;;EAavB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getBoxStyle } from "./utils.js";
|
|
2
|
+
export function createComputedStyleCache() {
|
|
3
|
+
const styles = new WeakMap();
|
|
4
|
+
return {
|
|
5
|
+
get(element) {
|
|
6
|
+
const cachedStyle = styles.get(element);
|
|
7
|
+
if (cachedStyle) {
|
|
8
|
+
return cachedStyle;
|
|
9
|
+
}
|
|
10
|
+
const boxStyle = getBoxStyle(element);
|
|
11
|
+
styles.set(element, boxStyle);
|
|
12
|
+
return boxStyle;
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=computed-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed-style.js","sourceRoot":"","sources":["../../src/core/computed-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAWzC,MAAM,UAAU,wBAAwB;IACtC,MAAM,MAAM,GAAG,IAAI,OAAO,EAAqB,CAAC;IAEhD,OAAO;QACL,GAAG,CAAC,OAAgB;YAClB,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAExC,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,WAAW,CAAC;YACrB,CAAC;YAED,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;YAEtC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC9B,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout-ready.d.ts","sourceRoot":"","sources":["../../src/core/layout-ready.ts"],"names":[],"mappings":"AAqBA,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,WAAW,iBAOzD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
async function waitForImages(root) {
|
|
2
|
+
const images = Array.from(root.querySelectorAll("img"));
|
|
3
|
+
if (!images.length) {
|
|
4
|
+
return Promise.resolve();
|
|
5
|
+
}
|
|
6
|
+
return Promise.all(images.map((img) => {
|
|
7
|
+
if (img.complete) {
|
|
8
|
+
return Promise.resolve();
|
|
9
|
+
}
|
|
10
|
+
return new Promise((resolve) => {
|
|
11
|
+
img.addEventListener("load", () => resolve(), { once: true });
|
|
12
|
+
img.addEventListener("error", () => resolve(), { once: true });
|
|
13
|
+
});
|
|
14
|
+
})).then(() => undefined);
|
|
15
|
+
}
|
|
16
|
+
export async function waitForLayoutReady(root) {
|
|
17
|
+
if (document.fonts && "ready" in document.fonts) {
|
|
18
|
+
await document.fonts.ready;
|
|
19
|
+
}
|
|
20
|
+
await waitForImages(root);
|
|
21
|
+
await new Promise((resolve) => requestAnimationFrame(() => resolve()));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=layout-ready.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout-ready.js","sourceRoot":"","sources":["../../src/core/layout-ready.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,aAAa,CAAC,IAAiB;IAC5C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IAExD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACnB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACjB,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;YACjB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;QAED,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACnC,GAAG,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9D,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CACH,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAiB;IACxD,IAAI,QAAQ,CAAC,KAAK,IAAI,OAAO,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QAChD,MAAM,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED,MAAM,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1B,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,qBAAqB,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-break.d.ts","sourceRoot":"","sources":["../../src/core/page-break.ts"],"names":[],"mappings":"AAAA,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,WAAW,EAAE,CA+BnF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function splitBodyOnPageBreakMarkers(body) {
|
|
2
|
+
const bodySlices = [];
|
|
3
|
+
if (!body) {
|
|
4
|
+
return bodySlices;
|
|
5
|
+
}
|
|
6
|
+
let hasPageBreakMarker = false;
|
|
7
|
+
let bodySlice = body.cloneNode(false);
|
|
8
|
+
for (const target of Array.from(body.childNodes)) {
|
|
9
|
+
if (target instanceof HTMLElement && target.hasAttribute("data-paged-react-page-break")) {
|
|
10
|
+
hasPageBreakMarker = true;
|
|
11
|
+
bodySlices.push(bodySlice);
|
|
12
|
+
bodySlice = body.cloneNode(false);
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
bodySlice.appendChild(target.cloneNode(true));
|
|
16
|
+
}
|
|
17
|
+
if (!hasPageBreakMarker) {
|
|
18
|
+
bodySlices.push(body);
|
|
19
|
+
return bodySlices;
|
|
20
|
+
}
|
|
21
|
+
// Push the last slice if it has content
|
|
22
|
+
bodySlices.push(bodySlice);
|
|
23
|
+
return bodySlices;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=page-break.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-break.js","sourceRoot":"","sources":["../../src/core/page-break.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,2BAA2B,CAAC,IAAwB;IAClE,MAAM,UAAU,GAAkB,EAAE,CAAC;IAErC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAC/B,IAAI,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAgB,CAAC;IAErD,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACjD,IAAI,MAAM,YAAY,WAAW,IAAI,MAAM,CAAC,YAAY,CAAC,6BAA6B,CAAC,EAAE,CAAC;YACxF,kBAAkB,GAAG,IAAI,CAAC;YAC1B,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAE3B,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAgB,CAAC;YACjD,SAAS;QACX,CAAC;QAED,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,wCAAwC;IACxC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAE3B,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginate.d.ts","sourceRoot":"","sources":["../../src/core/paginate.ts"],"names":[],"mappings":"AAeA,KAAK,iBAAiB,GAAG;IACvB,UAAU,EAAE,cAAc,CAAC;IAC3B,SAAS,EAAE,cAAc,CAAC;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,iBAAiB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