@paprize/react 0.0.8 → 0.0.9
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/LICENSE +201 -0
- package/package.json +56 -57
- package/dist/paprize-react.d.ts +0 -183
- package/dist/paprize-react.js +0 -430
- package/dist/paprize-react.js.map +0 -1
- package/dist/paprize-react.umd.cjs +0 -2
- package/dist/paprize-react.umd.cjs.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/package.json
CHANGED
|
@@ -1,60 +1,59 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"paper",
|
|
20
|
-
"print",
|
|
21
|
-
"report",
|
|
22
|
-
"pdf",
|
|
23
|
-
"html2pdf",
|
|
24
|
-
"react"
|
|
25
|
-
],
|
|
26
|
-
"homepage": "https://github.com/PejmanNik/paprize#readme",
|
|
27
|
-
"bugs": {
|
|
28
|
-
"url": "https://github.com/PejmanNik/paprize/issues"
|
|
29
|
-
},
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "git+https://github.com/PejmanNik/paprize.git"
|
|
33
|
-
},
|
|
34
|
-
"license": "Apache-2.0",
|
|
35
|
-
"author": "PejmanNikram",
|
|
36
|
-
"scripts": {
|
|
37
|
-
"dev": "vite",
|
|
38
|
-
"build": "tsc -b && vite build",
|
|
39
|
-
"lint": "eslint .",
|
|
40
|
-
"preview": "vite preview",
|
|
41
|
-
"prepack": "node ../../scripts/prepack.mjs"
|
|
42
|
-
},
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"@paprize/core": "*"
|
|
45
|
-
},
|
|
46
|
-
"peerDependencies": {
|
|
47
|
-
"react": ">=17.0.0",
|
|
48
|
-
"react-dom": ">=17.0.0"
|
|
49
|
-
},
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"@paprize/config": "*",
|
|
52
|
-
"@types/react": "^19.2.0",
|
|
53
|
-
"@types/react-dom": "^19.2.0",
|
|
54
|
-
"@vitejs/plugin-react-swc": "^4.1.0",
|
|
55
|
-
"react": "^19.2.0",
|
|
56
|
-
"react-dom": "^19.2.0",
|
|
57
|
-
"typescript": "~5.9.3",
|
|
58
|
-
"vite": "^7.1.9"
|
|
2
|
+
"name": "@paprize/react",
|
|
3
|
+
"version": "0.0.9",
|
|
4
|
+
"description": "React library for creating professional, print-ready reports",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"main": "./dist/paprize-react.umd.cjs",
|
|
10
|
+
"module": "./dist/paprize-react.js",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/paprize-react.d.ts",
|
|
14
|
+
"import": "./dist/paprize-react.js",
|
|
15
|
+
"require": "./dist/paprize-core.umd.cjs"
|
|
59
16
|
}
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"paper",
|
|
20
|
+
"print",
|
|
21
|
+
"report",
|
|
22
|
+
"pdf",
|
|
23
|
+
"html2pdf",
|
|
24
|
+
"react"
|
|
25
|
+
],
|
|
26
|
+
"homepage": "https://github.com/PejmanNik/paprize#readme",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/PejmanNik/paprize/issues"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/PejmanNik/paprize.git"
|
|
33
|
+
},
|
|
34
|
+
"license": "Apache-2.0",
|
|
35
|
+
"author": "PejmanNikram",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@paprize/core": "0.0.9"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"react": ">=17.0.0",
|
|
41
|
+
"react-dom": ">=17.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/react": "^19.2.0",
|
|
45
|
+
"@types/react-dom": "^19.2.0",
|
|
46
|
+
"@vitejs/plugin-react-swc": "^4.1.0",
|
|
47
|
+
"react": "^19.2.0",
|
|
48
|
+
"react-dom": "^19.2.0",
|
|
49
|
+
"typescript": "~5.9.3",
|
|
50
|
+
"vite": "^7.1.9",
|
|
51
|
+
"@paprize/config": "0.0.1"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"dev": "vite",
|
|
55
|
+
"build": "tsc -b && vite build",
|
|
56
|
+
"lint": "eslint .",
|
|
57
|
+
"preview": "vite preview"
|
|
58
|
+
}
|
|
60
59
|
}
|
package/dist/paprize-react.d.ts
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
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
|
-
export { }
|
package/dist/paprize-react.js
DELETED
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
import { jsx as r, Fragment as p, jsxs as R } from "react/jsx-runtime";
|
|
2
|
-
import { previewClassName as _, ReportBuilder as A, reportStyles as c, pageClassName as M, pageMargin as D, adjustPageSize as J, logger as V, sectionClassName as q, pageBreakAttributeName as G, layoutOptionsToAttributes as K } from "@paprize/core";
|
|
3
|
-
import { createContext as I, useContext as g, useMemo as a, useEffect as d, useRef as u, Children as Q, isValidElement as U, useState as W, useSyncExternalStore as b } from "react";
|
|
4
|
-
import { createPortal as X } from "react-dom";
|
|
5
|
-
function le({ children: e }) {
|
|
6
|
-
return /* @__PURE__ */ r("div", { className: _, children: e });
|
|
7
|
-
}
|
|
8
|
-
const F = I(null);
|
|
9
|
-
function m() {
|
|
10
|
-
const e = g(F);
|
|
11
|
-
if (!e)
|
|
12
|
-
throw new Error(
|
|
13
|
-
"ReportRoot is missing. Please wrap your component tree with ReportRoot component."
|
|
14
|
-
);
|
|
15
|
-
return e;
|
|
16
|
-
}
|
|
17
|
-
function de({ children: e }) {
|
|
18
|
-
const t = a(() => new A(), []);
|
|
19
|
-
return d(() => {
|
|
20
|
-
t.schedulePagination();
|
|
21
|
-
}, [t]), /* @__PURE__ */ r(F, { value: t, children: e });
|
|
22
|
-
}
|
|
23
|
-
function B({ children: e }) {
|
|
24
|
-
const t = m(), o = u(!1);
|
|
25
|
-
return d(() => {
|
|
26
|
-
const n = t.monitor.addEventListener(
|
|
27
|
-
"paginationCycleCompleted",
|
|
28
|
-
() => {
|
|
29
|
-
o.current = !0;
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
return () => n();
|
|
33
|
-
}, [t.monitor]), d(() => {
|
|
34
|
-
o.current && t.schedulePagination();
|
|
35
|
-
}, [e, t]), /* @__PURE__ */ r(p, { children: e });
|
|
36
|
-
}
|
|
37
|
-
function H({ children: e }) {
|
|
38
|
-
return /* @__PURE__ */ r(p, { children: e });
|
|
39
|
-
}
|
|
40
|
-
function k({ children: e }) {
|
|
41
|
-
return /* @__PURE__ */ r(p, { children: e });
|
|
42
|
-
}
|
|
43
|
-
function N({ children: e }) {
|
|
44
|
-
return /* @__PURE__ */ r(p, { children: e });
|
|
45
|
-
}
|
|
46
|
-
function z({ children: e }) {
|
|
47
|
-
return /* @__PURE__ */ r(p, { children: e });
|
|
48
|
-
}
|
|
49
|
-
function L({ children: e }) {
|
|
50
|
-
return /* @__PURE__ */ r(p, { children: e });
|
|
51
|
-
}
|
|
52
|
-
const w = [
|
|
53
|
-
B,
|
|
54
|
-
k,
|
|
55
|
-
H,
|
|
56
|
-
L,
|
|
57
|
-
z,
|
|
58
|
-
N
|
|
59
|
-
];
|
|
60
|
-
function Y(e) {
|
|
61
|
-
let t = null;
|
|
62
|
-
const o = {};
|
|
63
|
-
if (Q.forEach(e, (n) => {
|
|
64
|
-
if (!U(n))
|
|
65
|
-
throw new Error(
|
|
66
|
-
`Invalid React element found in children: ${n}`,
|
|
67
|
-
{
|
|
68
|
-
cause: { child: n }
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
const s = w.find((i) => i === n.type);
|
|
72
|
-
if (!s)
|
|
73
|
-
throw Error(
|
|
74
|
-
`Component "${n.type}" is not valid as a child for Section, Expected one of: ${w.map((i) => i.name).join(",")}`
|
|
75
|
-
);
|
|
76
|
-
switch (s) {
|
|
77
|
-
case z:
|
|
78
|
-
o.sectionHeader = n;
|
|
79
|
-
break;
|
|
80
|
-
case N:
|
|
81
|
-
o.sectionFooter = n;
|
|
82
|
-
break;
|
|
83
|
-
case B:
|
|
84
|
-
t = n;
|
|
85
|
-
break;
|
|
86
|
-
case k:
|
|
87
|
-
o.header = n;
|
|
88
|
-
break;
|
|
89
|
-
case H:
|
|
90
|
-
o.footer = n;
|
|
91
|
-
break;
|
|
92
|
-
case L:
|
|
93
|
-
o.overlay = n;
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
}), !t)
|
|
97
|
-
throw Error("PageContent component is a required child for Section");
|
|
98
|
-
return { ...o, content: t };
|
|
99
|
-
}
|
|
100
|
-
const h = I(""), T = I({
|
|
101
|
-
pageIndex: 0,
|
|
102
|
-
totalPages: 0
|
|
103
|
-
});
|
|
104
|
-
function E({
|
|
105
|
-
elements: e,
|
|
106
|
-
size: t,
|
|
107
|
-
margin: o,
|
|
108
|
-
pageIndex: n,
|
|
109
|
-
totalPages: s,
|
|
110
|
-
ref: i,
|
|
111
|
-
sectionHeaderRef: x,
|
|
112
|
-
sectionFooterRef: S,
|
|
113
|
-
pageHeaderRef: P,
|
|
114
|
-
pageFooterRef: y,
|
|
115
|
-
contentRef: v
|
|
116
|
-
}) {
|
|
117
|
-
const f = g(h), C = a(
|
|
118
|
-
() => ({ pageIndex: n, totalPages: s }),
|
|
119
|
-
[n, s]
|
|
120
|
-
);
|
|
121
|
-
return /* @__PURE__ */ r(T, { value: C, children: /* @__PURE__ */ R(
|
|
122
|
-
"div",
|
|
123
|
-
{
|
|
124
|
-
id: `${f}-${n}`,
|
|
125
|
-
className: M,
|
|
126
|
-
ref: i,
|
|
127
|
-
style: c.page(t, o ?? D.None),
|
|
128
|
-
children: [
|
|
129
|
-
e.sectionHeader && n === 0 && /* @__PURE__ */ r("div", { style: c.component, ref: x, children: e.sectionHeader }),
|
|
130
|
-
e.header && /* @__PURE__ */ r("div", { style: c.component, ref: P, children: e.header }),
|
|
131
|
-
/* @__PURE__ */ r("div", { style: c.pageContent, ref: v, children: e.content }),
|
|
132
|
-
e.overlay && /* @__PURE__ */ r("div", { style: c.overlay, children: e.overlay }),
|
|
133
|
-
(e.footer || e.sectionFooter) && /* @__PURE__ */ R(
|
|
134
|
-
"div",
|
|
135
|
-
{
|
|
136
|
-
style: { ...c.component, marginTop: "auto" },
|
|
137
|
-
children: [
|
|
138
|
-
e.footer && /* @__PURE__ */ r(
|
|
139
|
-
"div",
|
|
140
|
-
{
|
|
141
|
-
style: c.component,
|
|
142
|
-
ref: y,
|
|
143
|
-
children: e.footer
|
|
144
|
-
}
|
|
145
|
-
),
|
|
146
|
-
e.sectionFooter && n === s - 1 && /* @__PURE__ */ r(
|
|
147
|
-
"div",
|
|
148
|
-
{
|
|
149
|
-
style: c.component,
|
|
150
|
-
ref: S,
|
|
151
|
-
children: e.sectionFooter
|
|
152
|
-
}
|
|
153
|
-
)
|
|
154
|
-
]
|
|
155
|
-
}
|
|
156
|
-
)
|
|
157
|
-
]
|
|
158
|
-
}
|
|
159
|
-
) });
|
|
160
|
-
}
|
|
161
|
-
const $ = I({
|
|
162
|
-
addPlugin: () => {
|
|
163
|
-
throw new Error("addPlugin must be used within a Section");
|
|
164
|
-
},
|
|
165
|
-
addSuspense: () => {
|
|
166
|
-
throw new Error("addSuspense must be used within a Section");
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
function Z(e) {
|
|
170
|
-
const t = a(
|
|
171
|
-
() => ({
|
|
172
|
-
plugins: e ?? [],
|
|
173
|
-
suspense: []
|
|
174
|
-
}),
|
|
175
|
-
[e]
|
|
176
|
-
), o = a(
|
|
177
|
-
() => ({
|
|
178
|
-
addPlugin: (n) => {
|
|
179
|
-
t.plugins.push(n);
|
|
180
|
-
},
|
|
181
|
-
addSuspense: (n) => {
|
|
182
|
-
t.suspense.push(n);
|
|
183
|
-
}
|
|
184
|
-
}),
|
|
185
|
-
[t]
|
|
186
|
-
);
|
|
187
|
-
return {
|
|
188
|
-
controllerState: t,
|
|
189
|
-
controllerValue: o
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
function ee({ elements: e, options: t }) {
|
|
193
|
-
const o = g(h), { controllerState: n, controllerValue: s } = Z(
|
|
194
|
-
t?.plugins
|
|
195
|
-
), i = m(), x = u(null), S = u(null), P = u(null), y = u(null), v = u(null), f = u(null), C = a(
|
|
196
|
-
() => J(t.size, t.orientation),
|
|
197
|
-
[t.orientation, t.size]
|
|
198
|
-
), [j, O] = W(
|
|
199
|
-
null
|
|
200
|
-
);
|
|
201
|
-
return d(() => {
|
|
202
|
-
if (f.current)
|
|
203
|
-
return i.tryAddSection(
|
|
204
|
-
{
|
|
205
|
-
...t,
|
|
206
|
-
id: o,
|
|
207
|
-
plugins: n.plugins,
|
|
208
|
-
suspense: n.suspense
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
pageContent: f.current,
|
|
212
|
-
sectionHeader: S.current,
|
|
213
|
-
sectionFooter: P.current,
|
|
214
|
-
pageFooter: v.current,
|
|
215
|
-
pageHeader: y.current
|
|
216
|
-
},
|
|
217
|
-
(l) => {
|
|
218
|
-
O(l);
|
|
219
|
-
}
|
|
220
|
-
).catch((l) => V.error(l)), () => {
|
|
221
|
-
i.removeSection(o);
|
|
222
|
-
};
|
|
223
|
-
}, [
|
|
224
|
-
n.plugins,
|
|
225
|
-
n.suspense,
|
|
226
|
-
t,
|
|
227
|
-
i,
|
|
228
|
-
o
|
|
229
|
-
]), /* @__PURE__ */ R($, { value: s, children: [
|
|
230
|
-
j?.map((l) => /* @__PURE__ */ r(
|
|
231
|
-
E,
|
|
232
|
-
{
|
|
233
|
-
elements: {
|
|
234
|
-
...e,
|
|
235
|
-
content: /* @__PURE__ */ r(
|
|
236
|
-
"div",
|
|
237
|
-
{
|
|
238
|
-
style: { display: "contents" },
|
|
239
|
-
dangerouslySetInnerHTML: {
|
|
240
|
-
__html: l.pageContentHtml
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
)
|
|
244
|
-
},
|
|
245
|
-
size: C,
|
|
246
|
-
margin: t.margin,
|
|
247
|
-
pageIndex: l.pageIndex,
|
|
248
|
-
totalPages: l.totalPages
|
|
249
|
-
},
|
|
250
|
-
l.pageIndex
|
|
251
|
-
)),
|
|
252
|
-
X(
|
|
253
|
-
/* @__PURE__ */ r("div", { style: c.outOfScreen, children: /* @__PURE__ */ r(
|
|
254
|
-
E,
|
|
255
|
-
{
|
|
256
|
-
elements: e,
|
|
257
|
-
size: C,
|
|
258
|
-
margin: t.margin,
|
|
259
|
-
pageIndex: 0,
|
|
260
|
-
totalPages: 1,
|
|
261
|
-
ref: x,
|
|
262
|
-
sectionHeaderRef: S,
|
|
263
|
-
sectionFooterRef: P,
|
|
264
|
-
pageHeaderRef: y,
|
|
265
|
-
pageFooterRef: v,
|
|
266
|
-
contentRef: f
|
|
267
|
-
}
|
|
268
|
-
) }),
|
|
269
|
-
document.body
|
|
270
|
-
)
|
|
271
|
-
] });
|
|
272
|
-
}
|
|
273
|
-
let te = 1;
|
|
274
|
-
function pe({ children: e, id: t, ...o }) {
|
|
275
|
-
const n = a(() => t ?? `__000${te++}`, [t]), s = a(() => Y(e), [e]), i = a(
|
|
276
|
-
() => ({
|
|
277
|
-
...o,
|
|
278
|
-
id: n
|
|
279
|
-
}),
|
|
280
|
-
[o, n]
|
|
281
|
-
);
|
|
282
|
-
return /* @__PURE__ */ r(
|
|
283
|
-
"section",
|
|
284
|
-
{
|
|
285
|
-
className: q,
|
|
286
|
-
id: n,
|
|
287
|
-
style: c.section(n),
|
|
288
|
-
children: /* @__PURE__ */ r(h, { value: n, children: /* @__PURE__ */ r(ee, { elements: s, options: i }) })
|
|
289
|
-
}
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
function ge() {
|
|
293
|
-
return /* @__PURE__ */ r("span", { [G]: "true" });
|
|
294
|
-
}
|
|
295
|
-
function fe({ children: e, ...t }) {
|
|
296
|
-
return /* @__PURE__ */ r(
|
|
297
|
-
"div",
|
|
298
|
-
{
|
|
299
|
-
style: { display: "contents" },
|
|
300
|
-
...K(t),
|
|
301
|
-
children: e
|
|
302
|
-
}
|
|
303
|
-
);
|
|
304
|
-
}
|
|
305
|
-
const me = () => {
|
|
306
|
-
const e = g(T);
|
|
307
|
-
return {
|
|
308
|
-
pageIndex: e.pageIndex,
|
|
309
|
-
totalPages: e.totalPages
|
|
310
|
-
};
|
|
311
|
-
}, Se = () => {
|
|
312
|
-
const e = g(h), t = m(), o = u({
|
|
313
|
-
pages: [],
|
|
314
|
-
isPaginated: !1,
|
|
315
|
-
isSuspended: !1,
|
|
316
|
-
sectionIndex: -1,
|
|
317
|
-
sectionId: e
|
|
318
|
-
}), n = b(
|
|
319
|
-
(s) => t.monitor.addEventListener(
|
|
320
|
-
"sectionCompleted",
|
|
321
|
-
(i) => {
|
|
322
|
-
i.sectionId === e && (o.current = i, s());
|
|
323
|
-
}
|
|
324
|
-
),
|
|
325
|
-
() => o.current
|
|
326
|
-
);
|
|
327
|
-
return {
|
|
328
|
-
sectionId: e,
|
|
329
|
-
sectionIndex: n.sectionIndex,
|
|
330
|
-
isSuspended: n.isSuspended,
|
|
331
|
-
isPaginated: n.isPaginated,
|
|
332
|
-
pages: n.pages.map((s) => ({
|
|
333
|
-
pageIndex: s.pageIndex,
|
|
334
|
-
totalPages: s.totalPages
|
|
335
|
-
}))
|
|
336
|
-
};
|
|
337
|
-
};
|
|
338
|
-
function ne(e) {
|
|
339
|
-
return {
|
|
340
|
-
pageIndex: e.pageIndex,
|
|
341
|
-
totalPages: e.totalPages
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
function oe(e) {
|
|
345
|
-
return {
|
|
346
|
-
sectionId: e.sectionId,
|
|
347
|
-
sectionIndex: e.sectionIndex,
|
|
348
|
-
isPaginated: e.isPaginated,
|
|
349
|
-
isSuspended: e.isSuspended,
|
|
350
|
-
pages: e.pages.map(ne)
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
function re(e) {
|
|
354
|
-
return {
|
|
355
|
-
sections: e.sections.map(oe)
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
function Pe() {
|
|
359
|
-
const e = m(), t = u({
|
|
360
|
-
sections: []
|
|
361
|
-
}), o = b(
|
|
362
|
-
(n) => e.monitor.addEventListener(
|
|
363
|
-
"paginationCycleCompleted",
|
|
364
|
-
(s) => {
|
|
365
|
-
t.current = s, n();
|
|
366
|
-
}
|
|
367
|
-
),
|
|
368
|
-
() => t.current
|
|
369
|
-
);
|
|
370
|
-
return re(o);
|
|
371
|
-
}
|
|
372
|
-
function se(e) {
|
|
373
|
-
const t = u(null), { addSuspense: o } = g($);
|
|
374
|
-
return d(() => {
|
|
375
|
-
if (t.current)
|
|
376
|
-
return;
|
|
377
|
-
const n = e ?? new Promise((s) => {
|
|
378
|
-
t.current = s;
|
|
379
|
-
});
|
|
380
|
-
t.current ||= () => {
|
|
381
|
-
}, o(n);
|
|
382
|
-
}, [o, e]), a(
|
|
383
|
-
() => ({
|
|
384
|
-
reset: () => {
|
|
385
|
-
t.current || o(
|
|
386
|
-
new Promise((n) => {
|
|
387
|
-
t.current = n;
|
|
388
|
-
})
|
|
389
|
-
);
|
|
390
|
-
},
|
|
391
|
-
release: () => {
|
|
392
|
-
t.current?.(), t.current = null;
|
|
393
|
-
}
|
|
394
|
-
}),
|
|
395
|
-
[o]
|
|
396
|
-
);
|
|
397
|
-
}
|
|
398
|
-
function ye(e) {
|
|
399
|
-
const t = m(), o = a(
|
|
400
|
-
() => ({
|
|
401
|
-
current: null
|
|
402
|
-
}),
|
|
403
|
-
[]
|
|
404
|
-
), n = a(
|
|
405
|
-
() => t.getJsonData(e),
|
|
406
|
-
[e, t]
|
|
407
|
-
);
|
|
408
|
-
return se(n), d(() => {
|
|
409
|
-
n.then((s) => o.current = s);
|
|
410
|
-
}, [n, o]), o.current ?? e ?? null;
|
|
411
|
-
}
|
|
412
|
-
export {
|
|
413
|
-
fe as Layout,
|
|
414
|
-
ge as PageBreak,
|
|
415
|
-
B as PageContent,
|
|
416
|
-
H as PageFooter,
|
|
417
|
-
k as PageHeader,
|
|
418
|
-
L as PageOverlay,
|
|
419
|
-
le as ReportPreview,
|
|
420
|
-
de as ReportRoot,
|
|
421
|
-
pe as Section,
|
|
422
|
-
N as SectionFooter,
|
|
423
|
-
z as SectionHeader,
|
|
424
|
-
ye as useJsonData,
|
|
425
|
-
me as usePageInfo,
|
|
426
|
-
Pe as useReportInfo,
|
|
427
|
-
Se as useSectionInfo,
|
|
428
|
-
se as useSectionSuspension
|
|
429
|
-
};
|
|
430
|
-
//# sourceMappingURL=paprize-react.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paprize-react.js","sources":["../src/components/ReportPreview.tsx","../src/internal/useReportBuilder.ts","../src/components/ReportRoot.tsx","../src/components/PageContent.tsx","../src/components/PageFooter.tsx","../src/components/PageHeader.tsx","../src/components/SectionFooter.tsx","../src/components/SectionHeader.tsx","../src/components/PageOverlay.tsx","../src/internal/parseSectionChildren.ts","../src/internal/SectionIdContext.ts","../src/internal/PageInfoContext.ts","../src/components/Page.tsx","../src/internal/SectionControllerContext.ts","../src/internal/useSectionControllerState.tsx","../src/internal/SectionLayout.tsx","../src/components/Section.tsx","../src/components/PageBreak.tsx","../src/components/Layout.tsx","../src/components/usePageInfo.ts","../src/components/useSectionInfo.ts","../src/internal/eventHelper.ts","../src/components/useReportInfo.ts","../src/components/useSectionSuspension.ts","../src/components/useJsonData.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { previewClassName } from '@paprize/core/src';\n\nexport function ReportPreview({ children }: { children: ReactNode }) {\n return <div className={previewClassName}>{children}</div>;\n}\n","import type { ReportBuilder } from '@paprize/core/src';\nimport { createContext, useContext } from 'react';\n\nexport const ReportBuilderContext = createContext<ReportBuilder | null>(null);\n\nexport function useReportBuilder() {\n const context = useContext(ReportBuilderContext);\n if (!context) {\n throw new Error(\n 'ReportRoot is missing. Please wrap your component tree with ReportRoot component.'\n );\n }\n\n return context;\n}\n","import { useEffect, useMemo, type ReactNode } from 'react';\nimport { ReportBuilder } from '@paprize/core/src';\nimport { ReportBuilderContext } from '../internal/useReportBuilder';\n\nexport interface ReportRootProps {\n children: ReactNode;\n}\n\nexport function ReportRoot({ children }: ReportRootProps) {\n const reportBuilder = useMemo(() => new ReportBuilder(), []);\n\n useEffect(() => {\n reportBuilder.schedulePagination();\n }, [reportBuilder]);\n\n return (\n <ReportBuilderContext value={reportBuilder}>\n {children}\n </ReportBuilderContext>\n );\n}\n","import { useEffect, useRef, type ReactNode } from 'react';\nimport { useReportBuilder } from '../internal/useReportBuilder';\n\nexport function PageContent({ children }: { children: ReactNode }) {\n const reportBuilder = useReportBuilder();\n const isFirstCycleCompleted = useRef(false);\n\n useEffect(() => {\n const unsubscribe = reportBuilder.monitor.addEventListener(\n 'paginationCycleCompleted',\n () => {\n isFirstCycleCompleted.current = true;\n }\n );\n\n return () => unsubscribe();\n }, [reportBuilder.monitor]);\n\n // If the children change after the first pagination cycle, we need to re-paginate\n // this can happen if the content is dynamic or loaded asynchronously\n // if we don't do this, the new content will be ignored in the pagination\n useEffect(() => {\n if (isFirstCycleCompleted.current) {\n reportBuilder.schedulePagination();\n }\n }, [children, reportBuilder]);\n\n return <>{children}</>;\n}\n","export function PageFooter({ children }: { children: React.ReactNode }) {\n return <>{children}</>;\n}\n","import type { ReactNode } from 'react';\n\nexport function PageHeader({ children }: { children: ReactNode }) {\n return <>{children}</>;\n}\n","export function SectionFooter({ children }: { children: React.ReactNode }) {\n return <>{children}</>;\n}\n","export function SectionHeader({ children }: { children: React.ReactNode }) {\n return <>{children}</>;\n}\n","import type { ReactNode } from 'react';\n\nexport function PageOverlay({ children }: { children: ReactNode }) {\n return <>{children}</>;\n}\n","import {\n Children,\n isValidElement,\n type FC,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { PageContent } from '../components/PageContent';\nimport { PageFooter } from '../components/PageFooter';\nimport { PageHeader } from '../components/PageHeader';\nimport { SectionFooter } from '../components/SectionFooter';\nimport { SectionHeader } from '../components/SectionHeader';\nimport { PageOverlay } from '../components/PageOverlay';\n\nconst validChildren: FC<{ children: ReactNode }>[] = [\n PageContent,\n PageHeader,\n PageFooter,\n PageOverlay,\n SectionHeader,\n SectionFooter,\n];\n\nexport interface PageElements {\n content: ReactElement;\n header?: ReactElement;\n footer?: ReactElement;\n overlay?: ReactElement;\n sectionHeader?: ReactElement;\n sectionFooter?: ReactElement;\n}\n\nfunction parseSectionChildren(children: ReactNode): PageElements {\n let content: ReactElement | null = null;\n const pageElements: Partial<PageElements> = {};\n\n Children.forEach(children, (child) => {\n if (!isValidElement(child)) {\n throw new Error(\n `Invalid React element found in children: ${child}`,\n {\n cause: { child },\n }\n );\n }\n\n const component = validChildren.find((x) => x === child.type);\n if (!component) {\n throw Error(\n `Component \"${child.type}\" is not valid as a child for Section, Expected one of: ${validChildren\n .map((x) => x.name)\n .join(',')}`\n );\n }\n\n switch (component) {\n case SectionHeader:\n pageElements.sectionHeader = child;\n break;\n\n case SectionFooter:\n pageElements.sectionFooter = child;\n break;\n\n case PageContent:\n content = child;\n break;\n\n case PageHeader:\n pageElements.header = child;\n break;\n\n case PageFooter:\n pageElements.footer = child;\n break;\n\n case PageOverlay:\n pageElements.overlay = child;\n break;\n }\n });\n\n if (!content) {\n throw Error('PageContent component is a required child for Section');\n }\n\n return { ...pageElements, content: content };\n}\n\nexport default parseSectionChildren;\n","import { createContext } from 'react';\n\nexport const SectionIdContext = createContext<string>('');\n","import { createContext } from 'react';\n\nexport const PageInfoContext = createContext<{\n pageIndex: number;\n totalPages: number;\n}>({\n pageIndex: 0,\n totalPages: 0,\n});\n","import { useContext, useMemo, type Ref } from 'react';\nimport { type PageElements } from '../internal/parseSectionChildren';\nimport { PageInfoContext } from '../internal/PageInfoContext';\nimport { SectionIdContext } from '../internal/SectionIdContext';\nimport {\n pageClassName,\n pageMargin,\n reportStyles,\n type PageSize,\n type PageMargin,\n} from '@paprize/core/src';\n\nexport interface PageProps {\n elements: PageElements;\n size: PageSize;\n margin?: PageMargin;\n pageIndex: number;\n totalPages: number;\n ref?: Ref<HTMLDivElement>;\n sectionHeaderRef?: Ref<HTMLDivElement>;\n sectionFooterRef?: Ref<HTMLDivElement>;\n pageHeaderRef?: Ref<HTMLDivElement>;\n pageFooterRef?: Ref<HTMLDivElement>;\n contentRef?: Ref<HTMLDivElement>;\n}\n\nexport function Page({\n elements,\n size,\n margin,\n pageIndex,\n totalPages,\n ref,\n sectionHeaderRef,\n sectionFooterRef,\n pageHeaderRef,\n pageFooterRef,\n contentRef,\n}: PageProps) {\n const sectionId = useContext(SectionIdContext);\n const contextValue = useMemo(\n () => ({ pageIndex, totalPages }),\n [pageIndex, totalPages]\n );\n\n return (\n <PageInfoContext value={contextValue}>\n <div\n id={`${sectionId}-${pageIndex}`}\n className={pageClassName}\n ref={ref}\n style={reportStyles.page(size, margin ?? pageMargin.None)}\n >\n {elements.sectionHeader && pageIndex === 0 && (\n <div style={reportStyles.component} ref={sectionHeaderRef}>\n {elements.sectionHeader}\n </div>\n )}\n {elements.header && (\n <div style={reportStyles.component} ref={pageHeaderRef}>\n {elements.header}\n </div>\n )}\n\n <div style={reportStyles.pageContent} ref={contentRef}>\n {elements.content}\n </div>\n\n {elements.overlay && (\n <div style={reportStyles.overlay}>{elements.overlay}</div>\n )}\n\n {(elements.footer || elements.sectionFooter) && (\n <div\n style={{ ...reportStyles.component, marginTop: 'auto' }}\n >\n {elements.footer && (\n <div\n style={reportStyles.component}\n ref={pageFooterRef}\n >\n {elements.footer}\n </div>\n )}\n {elements.sectionFooter &&\n pageIndex === totalPages - 1 && (\n <div\n style={reportStyles.component}\n ref={sectionFooterRef}\n >\n {elements.sectionFooter}\n </div>\n )}\n </div>\n )}\n </div>\n </PageInfoContext>\n );\n}\n","import type { PaginationPlugin } from '@paprize/core/src';\nimport { createContext } from 'react';\n\nexport interface SectionController {\n addPlugin: (plugin: PaginationPlugin) => void;\n addSuspense: (suspense: Promise<void>) => void;\n}\n\nexport const SectionControllerContext = createContext<SectionController>({\n addPlugin: () => {\n throw new Error('addPlugin must be used within a Section');\n },\n addSuspense: () => {\n throw new Error('addSuspense must be used within a Section');\n },\n});\n","import { useMemo } from 'react';\nimport { type SectionController } from './SectionControllerContext';\nimport type { PaginationPlugin } from '@paprize/core/src';\n\nexport function useSectionControllerState(plugins?: PaginationPlugin[]) {\n const state = useMemo(\n () => ({\n plugins: plugins ?? ([] as PaginationPlugin[]),\n suspense: [] as Promise<void>[],\n }),\n [plugins]\n );\n\n const sectionController: SectionController = useMemo(\n () => ({\n addPlugin: (plugin: PaginationPlugin) => {\n state.plugins.push(plugin);\n },\n addSuspense: (suspense: Promise<void>) => {\n state.suspense.push(suspense);\n },\n }),\n [state]\n );\n\n return {\n controllerState: state,\n controllerValue: sectionController,\n };\n}\n","import {\n adjustPageSize,\n logger,\n reportStyles,\n type PageContext,\n type SectionOptions,\n} from '@paprize/core/src';\nimport { useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Page } from '../components/Page';\nimport { useReportBuilder } from './useReportBuilder';\nimport { SectionIdContext } from './SectionIdContext';\nimport type { PageElements } from './parseSectionChildren';\nimport { useSectionControllerState } from './useSectionControllerState';\nimport { SectionControllerContext } from './SectionControllerContext';\n\nexport interface SectionLayoutProps {\n elements: PageElements;\n options: SectionOptions;\n}\n\nexport function SectionLayout({ elements, options }: SectionLayoutProps) {\n const sectionId = useContext(SectionIdContext);\n const { controllerState, controllerValue } = useSectionControllerState(\n options?.plugins\n );\n const reportBuilder = useReportBuilder();\n const pageRef = useRef<HTMLDivElement>(null);\n const sectionHeaderRef = useRef<HTMLDivElement>(null);\n const sectionFooterRef = useRef<HTMLDivElement>(null);\n const pageHeaderRef = useRef<HTMLDivElement>(null);\n const pageFooterRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const realizedSize = useMemo(\n () => adjustPageSize(options.size, options.orientation),\n [options.orientation, options.size]\n );\n const [pageContexts, setPageContexts] = useState<PageContext[] | null>(\n null\n );\n\n useEffect(() => {\n if (!contentRef.current) {\n return;\n }\n\n reportBuilder\n .tryAddSection(\n {\n ...options,\n id: sectionId,\n plugins: controllerState.plugins,\n suspense: controllerState.suspense,\n },\n {\n pageContent: contentRef.current,\n sectionHeader: sectionHeaderRef.current,\n sectionFooter: sectionFooterRef.current,\n pageFooter: pageFooterRef.current,\n pageHeader: pageHeaderRef.current,\n },\n (pages) => {\n setPageContexts(pages);\n }\n )\n .catch((e) => logger.error(e));\n\n return () => {\n reportBuilder.removeSection(sectionId);\n };\n }, [\n controllerState.plugins,\n controllerState.suspense,\n options,\n reportBuilder,\n sectionId,\n ]);\n\n return (\n <SectionControllerContext value={controllerValue}>\n {pageContexts?.map((pageContext) => (\n <Page\n key={pageContext.pageIndex}\n elements={{\n ...elements,\n content: (\n <div\n style={{ display: 'contents' }}\n dangerouslySetInnerHTML={{\n __html: pageContext.pageContentHtml,\n }}\n />\n ),\n }}\n size={realizedSize}\n margin={options.margin}\n pageIndex={pageContext.pageIndex}\n totalPages={pageContext.totalPages}\n />\n ))}\n\n {createPortal(\n <div style={reportStyles.outOfScreen}>\n <Page\n elements={elements}\n size={realizedSize}\n margin={options.margin}\n pageIndex={0}\n totalPages={1}\n ref={pageRef}\n sectionHeaderRef={sectionHeaderRef}\n sectionFooterRef={sectionFooterRef}\n pageHeaderRef={pageHeaderRef}\n pageFooterRef={pageFooterRef}\n contentRef={contentRef}\n />\n </div>,\n document.body\n )}\n </SectionControllerContext>\n );\n}\n","import { useMemo, type ReactNode } from 'react';\nimport parseSectionChildren from '../internal/parseSectionChildren';\nimport { SectionIdContext } from '../internal/SectionIdContext';\nimport {\n reportStyles,\n sectionClassName,\n type SectionOptions,\n} from '@paprize/core/src';\nimport { SectionLayout } from '../internal/SectionLayout';\n\n/**\n * Configuration options for a section.\n * @inlineType SectionOptions\n */\nexport interface SectionProps extends Omit<SectionOptions, 'id' | 'suspense'> {\n children: ReactNode;\n /**\n * Unique id of the section within the report. If not set, a random id will be used.\n */\n id?: string;\n}\n\nlet sectionIdCounter = 1;\n\nexport function Section({ children, id, ...options }: SectionProps) {\n const sectionId = useMemo(() => id ?? `__000${sectionIdCounter++}`, [id]);\n const elements = useMemo(() => parseSectionChildren(children), [children]);\n const sectionOptions = useMemo(\n () => ({\n ...options,\n id: sectionId,\n }),\n [options, sectionId]\n );\n\n return (\n <section\n className={sectionClassName}\n id={sectionId}\n style={reportStyles.section(sectionId)}\n >\n <SectionIdContext value={sectionId}>\n <SectionLayout elements={elements} options={sectionOptions} />\n </SectionIdContext>\n </section>\n );\n}\n","import { pageBreakAttributeName } from '@paprize/core/src';\n\nexport function PageBreak() {\n return <span {...{ [pageBreakAttributeName]: 'true' }} />;\n}\n","import {\n layoutOptionsToAttributes,\n type LayoutOptions,\n} from '@paprize/core/src';\n\nexport interface LayoutProps extends LayoutOptions {\n children: React.ReactNode;\n}\n\nexport function Layout({ children, ...attributes }: LayoutProps) {\n return (\n <div\n style={{ display: 'contents' }}\n {...layoutOptionsToAttributes(attributes)}\n >\n {children}\n </div>\n );\n}\n","import { useContext } from 'react';\nimport { PageInfoContext } from '../internal/PageInfoContext';\nimport type { PageInfo } from '../internal/eventHelper';\n\n/**\n * React hook that returns information about the current page.\n */\nexport const usePageInfo = (): PageInfo => {\n const pageContext = useContext(PageInfoContext);\n\n return {\n pageIndex: pageContext.pageIndex,\n totalPages: pageContext.totalPages,\n };\n};\n","import { useContext, useRef, useSyncExternalStore } from 'react';\nimport type { SectionContext } from '@paprize/core/src';\nimport { useReportBuilder } from '../internal/useReportBuilder';\nimport { SectionIdContext } from '../internal/SectionIdContext';\nimport type { SectionInfo } from '../internal/eventHelper';\n\n/**\n * React hook that returns information about the current section.\n */\nexport const useSectionInfo = (): SectionInfo => {\n const sectionId = useContext(SectionIdContext);\n const reportBuilder = useReportBuilder();\n const stateRef = useRef<SectionContext>({\n pages: [],\n isPaginated: false,\n isSuspended: false,\n sectionIndex: -1,\n sectionId: sectionId,\n });\n\n const state = useSyncExternalStore(\n (callback) => {\n return reportBuilder.monitor.addEventListener(\n 'sectionCompleted',\n (sc) => {\n if (sc.sectionId !== sectionId) return;\n stateRef.current = sc;\n callback();\n }\n );\n },\n () => stateRef.current\n );\n\n return {\n sectionId: sectionId,\n sectionIndex: state.sectionIndex,\n isSuspended: state.isSuspended,\n isPaginated: state.isPaginated,\n pages: state.pages.map((p) => ({\n pageIndex: p.pageIndex,\n totalPages: p.totalPages,\n })),\n };\n};\n","import type {\n PaginationCycleCompleted,\n SectionContext,\n} from '@paprize/core/src';\n\n/**\n * {@inheritDoc @paprize/core!PageContext}\n */\nexport interface PageInfo {\n /**\n * {@inheritDoc @paprize/core!PageContext.pageIndex}\n */\n pageIndex: number;\n /**\n * {@inheritDoc @paprize/core!PageContext.totalPages}\n */\n totalPages: number;\n}\n\n/**\n * {@inheritDoc @paprize/core!SectionContext}\n */\nexport interface SectionInfo {\n /**\n * {@inheritDoc @paprize/core!SectionContext.sectionId}\n */\n sectionId: string;\n /**\n * {@inheritDoc @paprize/core!SectionContext.sectionIndex}\n */\n sectionIndex: number;\n /**\n * {@inheritDoc @paprize/core!SectionContext.isPaginated}\n */\n isPaginated: boolean;\n /**\n * {@inheritDoc @paprize/core!SectionContext.isSuspended}\n */\n isSuspended: boolean;\n /**\n * {@inheritDoc @paprize/core!SectionContext.pages}\n */\n pages: PageInfo[];\n}\n\n/**\n * {@inheritDoc @paprize/core!PaginationCycleCompleted}\n */\n\nexport interface ReportInfo {\n /**\n * {@inheritDoc @paprize/core!PaginationCycleCompleted.sections}\n */\n sections: SectionInfo[];\n}\n\nexport function pageContextToPageInfo(pc: {\n pageIndex: number;\n totalPages: number;\n}): PageInfo {\n return {\n pageIndex: pc.pageIndex,\n totalPages: pc.totalPages,\n };\n}\n\nexport function sectionContextToSectionInfo(sc: SectionContext): SectionInfo {\n return {\n sectionId: sc.sectionId,\n sectionIndex: sc.sectionIndex,\n isPaginated: sc.isPaginated,\n isSuspended: sc.isSuspended,\n pages: sc.pages.map(pageContextToPageInfo),\n };\n}\n\nexport function paginationCycleToReportInfo(\n rc: PaginationCycleCompleted\n): ReportInfo {\n return {\n sections: rc.sections.map(sectionContextToSectionInfo),\n };\n}\n","import { useRef, useSyncExternalStore } from 'react';\nimport { useReportBuilder } from '../internal/useReportBuilder';\nimport type { PaginationCycleCompleted } from '@paprize/core/src';\nimport {\n paginationCycleToReportInfo,\n type ReportInfo,\n} from '../internal/eventHelper';\n\n/**\n * React hook that returns information about the report.\n */\nexport function useReportInfo(): ReportInfo {\n const reportBuilder = useReportBuilder();\n const stateRef = useRef<PaginationCycleCompleted>({\n sections: [],\n });\n\n const state = useSyncExternalStore(\n (callback) => {\n return reportBuilder.monitor.addEventListener(\n 'paginationCycleCompleted',\n (pg) => {\n stateRef.current = pg;\n callback();\n }\n );\n },\n () => stateRef.current\n );\n\n return paginationCycleToReportInfo(state);\n}\n","import { useContext, useEffect, useMemo, useRef } from 'react';\nimport { SectionControllerContext } from '../internal/SectionControllerContext';\n\n/**\n * Controls the section suspension.\n * @inline\n */\nexport interface SectionSuspension {\n /**\n * Releases the suspension. The pagination engine will paginate this section immediately.\n */\n release: () => void;\n\n /**\n * Marks the suspension as pending again if it was previously resolved.\n * During the next pagination cycle (for example, if pagination is retriggered\n * by changes to the page content), this section will not be paginated\n * until `release` is called again.\n */\n reset: () => void;\n}\n\n/**\n * Suspends pagination for this section.\n * @param promise The suspension is tied to this promise. Once the promise is resolved,\n * the suspension is released and the pagination engine will paginate this section.\n */\nexport function useSectionSuspension(\n promise: Promise<void> | Promise<unknown>\n): void;\n/**\n * Suspends pagination for this section. You need to call the `release` method\n * of the returned value; otherwise, the pagination engine will never paginate this section.\n */\nexport function useSectionSuspension(): SectionSuspension;\nexport function useSectionSuspension(\n promise?: Promise<void> | Promise<unknown>\n) {\n const resolveFn = useRef<() => void | null>(null);\n const { addSuspense } = useContext(SectionControllerContext);\n\n useEffect(() => {\n if (resolveFn.current) {\n return;\n }\n\n const pr =\n promise ??\n new Promise<void>((resolve) => {\n resolveFn.current = resolve;\n });\n resolveFn.current ||= () => {};\n\n addSuspense(pr as Promise<void>);\n }, [addSuspense, promise]);\n\n return useMemo(\n () => ({\n reset: () => {\n if (resolveFn.current) return;\n\n addSuspense(\n new Promise<void>((resolve) => {\n resolveFn.current = resolve;\n })\n );\n },\n release: () => {\n resolveFn.current?.();\n resolveFn.current = null;\n },\n }),\n [addSuspense]\n );\n}\n","import { useSectionSuspension } from './useSectionSuspension';\nimport { useReportBuilder } from '../internal/useReportBuilder';\nimport { useEffect, useMemo } from 'react';\n\n/**\n * {@inheritDoc @paprize/core!ReportBuilder.getJsonData}\n */\nexport function useJsonData<DataModel>(\n defaultValue?: DataModel\n): DataModel | null {\n const reportBuilder = useReportBuilder();\n const value = useMemo(\n () => ({\n current: null as DataModel | null,\n }),\n []\n );\n\n const promise = useMemo(\n () => reportBuilder.getJsonData(defaultValue),\n [defaultValue, reportBuilder]\n );\n\n useSectionSuspension(promise);\n\n useEffect(() => {\n promise.then((v) => (value.current = v));\n }, [promise, value]);\n\n return value.current ?? defaultValue ?? null;\n}\n"],"names":["ReportPreview","children","jsx","previewClassName","ReportBuilderContext","createContext","useReportBuilder","context","useContext","ReportRoot","reportBuilder","useMemo","ReportBuilder","useEffect","PageContent","isFirstCycleCompleted","useRef","unsubscribe","PageFooter","PageHeader","SectionFooter","SectionHeader","PageOverlay","validChildren","parseSectionChildren","content","pageElements","Children","child","isValidElement","component","x","SectionIdContext","PageInfoContext","Page","elements","size","margin","pageIndex","totalPages","ref","sectionHeaderRef","sectionFooterRef","pageHeaderRef","pageFooterRef","contentRef","sectionId","contextValue","jsxs","pageClassName","reportStyles","pageMargin","SectionControllerContext","useSectionControllerState","plugins","state","sectionController","plugin","suspense","SectionLayout","options","controllerState","controllerValue","pageRef","realizedSize","adjustPageSize","pageContexts","setPageContexts","useState","pages","e","logger","pageContext","createPortal","sectionIdCounter","Section","id","sectionOptions","sectionClassName","PageBreak","pageBreakAttributeName","Layout","attributes","layoutOptionsToAttributes","usePageInfo","useSectionInfo","stateRef","useSyncExternalStore","callback","sc","p","pageContextToPageInfo","pc","sectionContextToSectionInfo","paginationCycleToReportInfo","rc","useReportInfo","pg","useSectionSuspension","promise","resolveFn","addSuspense","pr","resolve","useJsonData","defaultValue","value","v"],"mappings":";;;;AAGO,SAASA,GAAc,EAAE,UAAAC,KAAqC;AACjE,SAAO,gBAAAC,EAAC,OAAA,EAAI,WAAWC,GAAmB,UAAAF,EAAA,CAAS;AACvD;ACFO,MAAMG,IAAuBC,EAAoC,IAAI;AAErE,SAASC,IAAmB;AAC/B,QAAMC,IAAUC,EAAWJ,CAAoB;AAC/C,MAAI,CAACG;AACD,UAAM,IAAI;AAAA,MACN;AAAA,IAAA;AAIR,SAAOA;AACX;ACNO,SAASE,GAAW,EAAE,UAAAR,KAA6B;AACtD,QAAMS,IAAgBC,EAAQ,MAAM,IAAIC,EAAA,GAAiB,CAAA,CAAE;AAE3D,SAAAC,EAAU,MAAM;AACZ,IAAAH,EAAc,mBAAA;AAAA,EAClB,GAAG,CAACA,CAAa,CAAC,GAGd,gBAAAR,EAACE,GAAA,EAAqB,OAAOM,GACxB,UAAAT,EAAA,CACL;AAER;ACjBO,SAASa,EAAY,EAAE,UAAAb,KAAqC;AAC/D,QAAMS,IAAgBJ,EAAA,GAChBS,IAAwBC,EAAO,EAAK;AAE1C,SAAAH,EAAU,MAAM;AACZ,UAAMI,IAAcP,EAAc,QAAQ;AAAA,MACtC;AAAA,MACA,MAAM;AACF,QAAAK,EAAsB,UAAU;AAAA,MACpC;AAAA,IAAA;AAGJ,WAAO,MAAME,EAAA;AAAA,EACjB,GAAG,CAACP,EAAc,OAAO,CAAC,GAK1BG,E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AI,GAC1C,EAAE,aAAAqF,EAAA,IAAgB7F,EAAW4C,CAAwB;AAE3D,SAAAvC,EAAU,MAAM;AACZ,QAAIuF,EAAU;AACV;AAGJ,UAAME,IACFH,KACA,IAAI,QAAc,CAACI,MAAY;AAC3B,MAAAH,EAAU,UAAUG;AAAA,IACxB,CAAC;AACL,IAAAH,EAAU,YAAY,MAAM;AAAA,IAAC,GAE7BC,EAAYC,CAAmB;AAAA,EACnC,GAAG,CAACD,GAAaF,CAAO,CAAC,GAElBxF;AAAA,IACH,OAAO;AAAA,MACH,OAAO,MAAM;AACT,QAAIyF,EAAU,WAEdC;AAAA,UACI,IAAI,QAAc,CAACE,MAAY;AAC3B,YAAAH,EAAU,UAAUG;AAAA,UACxB,CAAC;AAAA,QAAA;AAAA,MAET;AAAA,MACA,SAAS,MAAM;AACX,QAAAH,EAAU,UAAA,GACVA,EAAU,UAAU;AAAA,MACxB;AAAA,IAAA;AAAA,IAEJ,CAACC,CAAW;AAAA,EAAA;AAEpB;ACnEO,SAASG,GACZC,GACgB;AAChB,QAAM/F,IAAgBJ,EAAA,GAChBoG,IAAQ/F;AAAA,IACV,OAAO;AAAA,MACH,SAAS;AAAA,IAAA;AAAA,IAEb,CAAA;AAAA,EAAC,GAGCwF,IAAUxF;AAAA,IACZ,MAAMD,EAAc,YAAY+F,CAAY;AAAA,IAC5C,CAACA,GAAc/F,CAAa;AAAA,EAAA;AAGhC,SAAAwF,GAAqBC,CAAO,GAE5BtF,EAAU,MAAM;AACZ,IAAAsF,EAAQ,KAAK,CAACQ,MAAOD,EAAM,UAAUC,CAAE;AAAA,EAC3C,GAAG,CAACR,GAASO,CAAK,CAAC,GAEZA,EAAM,WAAWD,KAAgB;AAC5C;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(function(i,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("react/jsx-runtime"),require("@paprize/core"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@paprize/core","react","react-dom"],r):(i=typeof globalThis<"u"?globalThis:i||self,r(i["paprize-react"]={},i.jsxRuntime,i.PaprizeCore,i.React,i.ReactDOM))})(this,(function(i,r,a,o,k){"use strict";function T({children:e}){return r.jsx("div",{className:a.previewClassName,children:e})}const x=o.createContext(null);function l(){const e=o.useContext(x);if(!e)throw new Error("ReportRoot is missing. Please wrap your component tree with ReportRoot component.");return e}function N({children:e}){const n=o.useMemo(()=>new a.ReportBuilder,[]);return o.useEffect(()=>{n.schedulePagination()},[n]),r.jsx(x,{value:n,children:e})}function v({children:e}){const n=l(),s=o.useRef(!1);return o.useEffect(()=>{const t=n.monitor.addEventListener("paginationCycleCompleted",()=>{s.current=!0});return()=>t()},[n.monitor]),o.useEffect(()=>{s.current&&n.schedulePagination()},[e,n]),r.jsx(r.Fragment,{children:e})}function I({children:e}){return r.jsx(r.Fragment,{children:e})}function h({children:e}){return r.jsx(r.Fragment,{children:e})}function m({children:e}){return r.jsx(r.Fragment,{children:e})}function w({children:e}){return r.jsx(r.Fragment,{children:e})}function E({children:e}){return r.jsx(r.Fragment,{children:e})}const M=[v,h,I,E,w,m];function L(e){let n=null;const s={};if(o.Children.forEach(e,t=>{if(!o.isValidElement(t))throw new Error(`Invalid React element found in children: ${t}`,{cause:{child:t}});const u=M.find(c=>c===t.type);if(!u)throw Error(`Component "${t.type}" is not valid as a child for Section, Expected one of: ${M.map(c=>c.name).join(",")}`);switch(u){case w:s.sectionHeader=t;break;case m:s.sectionFooter=t;break;case v:n=t;break;case h:s.header=t;break;case I:s.footer=t;break;case E:s.overlay=t;break}}),!n)throw Error("PageContent component is a required child for Section");return{...s,content:n}}const p=o.createContext(""),H=o.createContext({pageIndex:0,totalPages:0});function b({elements:e,size:n,margin:s,pageIndex:t,totalPages:u,ref:c,sectionHeaderRef:F,sectionFooterRef:g,pageHeaderRef:S,pageFooterRef:y,contentRef:P}){const f=o.useContext(p),C=o.useMemo(()=>({pageIndex:t,totalPages:u}),[t,u]);return r.jsx(H,{value:C,children:r.jsxs("div",{id:`${f}-${t}`,className:a.pageClassName,ref:c,style:a.reportStyles.page(n,s??a.pageMargin.None),children:[e.sectionHeader&&t===0&&r.jsx("div",{style:a.reportStyles.component,ref:F,children:e.sectionHeader}),e.header&&r.jsx("div",{style:a.reportStyles.component,ref:S,children:e.header}),r.jsx("div",{style:a.reportStyles.pageContent,ref:P,children:e.content}),e.overlay&&r.jsx("div",{style:a.reportStyles.overlay,children:e.overlay}),(e.footer||e.sectionFooter)&&r.jsxs("div",{style:{...a.reportStyles.component,marginTop:"auto"},children:[e.footer&&r.jsx("div",{style:a.reportStyles.component,ref:y,children:e.footer}),e.sectionFooter&&t===u-1&&r.jsx("div",{style:a.reportStyles.component,ref:g,children:e.sectionFooter})]})]})})}const B=o.createContext({addPlugin:()=>{throw new Error("addPlugin must be used within a Section")},addSuspense:()=>{throw new Error("addSuspense must be used within a Section")}});function O(e){const n=o.useMemo(()=>({plugins:e??[],suspense:[]}),[e]),s=o.useMemo(()=>({addPlugin:t=>{n.plugins.push(t)},addSuspense:t=>{n.suspense.push(t)}}),[n]);return{controllerState:n,controllerValue:s}}function R({elements:e,options:n}){const s=o.useContext(p),{controllerState:t,controllerValue:u}=O(n?.plugins),c=l(),F=o.useRef(null),g=o.useRef(null),S=o.useRef(null),y=o.useRef(null),P=o.useRef(null),f=o.useRef(null),C=o.useMemo(()=>a.adjustPageSize(n.size,n.orientation),[n.orientation,n.size]),[U,W]=o.useState(null);return o.useEffect(()=>{if(f.current)return c.tryAddSection({...n,id:s,plugins:t.plugins,suspense:t.suspense},{pageContent:f.current,sectionHeader:g.current,sectionFooter:S.current,pageFooter:P.current,pageHeader:y.current},d=>{W(d)}).catch(d=>a.logger.error(d)),()=>{c.removeSection(s)}},[t.plugins,t.suspense,n,c,s]),r.jsxs(B,{value:u,children:[U?.map(d=>r.jsx(b,{elements:{...e,content:r.jsx("div",{style:{display:"contents"},dangerouslySetInnerHTML:{__html:d.pageContentHtml}})},size:C,margin:n.margin,pageIndex:d.pageIndex,totalPages:d.totalPages},d.pageIndex)),k.createPortal(r.jsx("div",{style:a.reportStyles.outOfScreen,children:r.jsx(b,{elements:e,size:C,margin:n.margin,pageIndex:0,totalPages:1,ref:F,sectionHeaderRef:g,sectionFooterRef:S,pageHeaderRef:y,pageFooterRef:P,contentRef:f})}),document.body)]})}let $=1;function q({children:e,id:n,...s}){const t=o.useMemo(()=>n??`__000${$++}`,[n]),u=o.useMemo(()=>L(e),[e]),c=o.useMemo(()=>({...s,id:t}),[s,t]);return r.jsx("section",{className:a.sectionClassName,id:t,style:a.reportStyles.section(t),children:r.jsx(p,{value:t,children:r.jsx(R,{elements:u,options:c})})})}function D(){return r.jsx("span",{[a.pageBreakAttributeName]:"true"})}function _({children:e,...n}){return r.jsx("div",{style:{display:"contents"},...a.layoutOptionsToAttributes(n),children:e})}const A=()=>{const e=o.useContext(H);return{pageIndex:e.pageIndex,totalPages:e.totalPages}},J=()=>{const e=o.useContext(p),n=l(),s=o.useRef({pages:[],isPaginated:!1,isSuspended:!1,sectionIndex:-1,sectionId:e}),t=o.useSyncExternalStore(u=>n.monitor.addEventListener("sectionCompleted",c=>{c.sectionId===e&&(s.current=c,u())}),()=>s.current);return{sectionId:e,sectionIndex:t.sectionIndex,isSuspended:t.isSuspended,isPaginated:t.isPaginated,pages:t.pages.map(u=>({pageIndex:u.pageIndex,totalPages:u.totalPages}))}};function j(e){return{pageIndex:e.pageIndex,totalPages:e.totalPages}}function V(e){return{sectionId:e.sectionId,sectionIndex:e.sectionIndex,isPaginated:e.isPaginated,isSuspended:e.isSuspended,pages:e.pages.map(j)}}function G(e){return{sections:e.sections.map(V)}}function K(){const e=l(),n=o.useRef({sections:[]}),s=o.useSyncExternalStore(t=>e.monitor.addEventListener("paginationCycleCompleted",u=>{n.current=u,t()}),()=>n.current);return G(s)}function z(e){const n=o.useRef(null),{addSuspense:s}=o.useContext(B);return o.useEffect(()=>{if(n.current)return;const t=e??new Promise(u=>{n.current=u});n.current||=()=>{},s(t)},[s,e]),o.useMemo(()=>({reset:()=>{n.current||s(new Promise(t=>{n.current=t}))},release:()=>{n.current?.(),n.current=null}}),[s])}function Q(e){const n=l(),s=o.useMemo(()=>({current:null}),[]),t=o.useMemo(()=>n.getJsonData(e),[e,n]);return z(t),o.useEffect(()=>{t.then(u=>s.current=u)},[t,s]),s.current??e??null}i.Layout=_,i.PageBreak=D,i.PageContent=v,i.PageFooter=I,i.PageHeader=h,i.PageOverlay=E,i.ReportPreview=T,i.ReportRoot=N,i.Section=q,i.SectionFooter=m,i.SectionHeader=w,i.useJsonData=Q,i.usePageInfo=A,i.useReportInfo=K,i.useSectionInfo=J,i.useSectionSuspension=z,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
|
2
|
-
//# sourceMappingURL=paprize-react.umd.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paprize-react.umd.cjs","sources":["../src/components/ReportPreview.tsx","../src/internal/useReportBuilder.ts","../src/components/ReportRoot.tsx","../src/components/PageContent.tsx","../src/components/PageFooter.tsx","../src/components/PageHeader.tsx","../src/components/SectionFooter.tsx","../src/components/SectionHeader.tsx","../src/components/PageOverlay.tsx","../src/internal/parseSectionChildren.ts","../src/internal/SectionIdContext.ts","../src/internal/PageInfoContext.ts","../src/components/Page.tsx","../src/internal/SectionControllerContext.ts","../src/internal/useSectionControllerState.tsx","../src/internal/SectionLayout.tsx","../src/components/Section.tsx","../src/components/PageBreak.tsx","../src/components/Layout.tsx","../src/components/usePageInfo.ts","../src/components/useSectionInfo.ts","../src/internal/eventHelper.ts","../src/components/useReportInfo.ts","../src/components/useSectionSuspension.ts","../src/components/useJsonData.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { previewClassName } from '@paprize/core/src';\n\nexport function ReportPreview({ children }: { children: ReactNode }) {\n return <div className={previewClassName}>{children}</div>;\n}\n","import type { ReportBuilder } from '@paprize/core/src';\nimport { createContext, useContext } from 'react';\n\nexport const ReportBuilderContext = createContext<ReportBuilder | null>(null);\n\nexport function useReportBuilder() {\n const context = useContext(ReportBuilderContext);\n if (!context) {\n throw new Error(\n 'ReportRoot is missing. Please wrap your component tree with ReportRoot component.'\n );\n }\n\n return context;\n}\n","import { useEffect, useMemo, type ReactNode } from 'react';\nimport { ReportBuilder } from '@paprize/core/src';\nimport { ReportBuilderContext } from '../internal/useReportBuilder';\n\nexport interface ReportRootProps {\n children: ReactNode;\n}\n\nexport function ReportRoot({ children }: ReportRootProps) {\n const reportBuilder = useMemo(() => new ReportBuilder(), []);\n\n useEffect(() => {\n reportBuilder.schedulePagination();\n }, [reportBuilder]);\n\n return (\n <ReportBuilderContext value={reportBuilder}>\n {children}\n </ReportBuilderContext>\n );\n}\n","import { useEffect, useRef, type ReactNode } from 'react';\nimport { useReportBuilder } from '../internal/useReportBuilder';\n\nexport function PageContent({ children }: { children: ReactNode }) {\n const reportBuilder = useReportBuilder();\n const isFirstCycleCompleted = useRef(false);\n\n useEffect(() => {\n const unsubscribe = reportBuilder.monitor.addEventListener(\n 'paginationCycleCompleted',\n () => {\n isFirstCycleCompleted.current = true;\n }\n );\n\n return () => unsubscribe();\n }, [reportBuilder.monitor]);\n\n // If the children change after the first pagination cycle, we need to re-paginate\n // this can happen if the content is dynamic or loaded asynchronously\n // if we don't do this, the new content will be ignored in the pagination\n useEffect(() => {\n if (isFirstCycleCompleted.current) {\n reportBuilder.schedulePagination();\n }\n }, [children, reportBuilder]);\n\n return <>{children}</>;\n}\n","export function PageFooter({ children }: { children: React.ReactNode }) {\n return <>{children}</>;\n}\n","import type { ReactNode } from 'react';\n\nexport function PageHeader({ children }: { children: ReactNode }) {\n return <>{children}</>;\n}\n","export function SectionFooter({ children }: { children: React.ReactNode }) {\n return <>{children}</>;\n}\n","export function SectionHeader({ children }: { children: React.ReactNode }) {\n return <>{children}</>;\n}\n","import type { ReactNode } from 'react';\n\nexport function PageOverlay({ children }: { children: ReactNode }) {\n return <>{children}</>;\n}\n","import {\n Children,\n isValidElement,\n type FC,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { PageContent } from '../components/PageContent';\nimport { PageFooter } from '../components/PageFooter';\nimport { PageHeader } from '../components/PageHeader';\nimport { SectionFooter } from '../components/SectionFooter';\nimport { SectionHeader } from '../components/SectionHeader';\nimport { PageOverlay } from '../components/PageOverlay';\n\nconst validChildren: FC<{ children: ReactNode }>[] = [\n PageContent,\n PageHeader,\n PageFooter,\n PageOverlay,\n SectionHeader,\n SectionFooter,\n];\n\nexport interface PageElements {\n content: ReactElement;\n header?: ReactElement;\n footer?: ReactElement;\n overlay?: ReactElement;\n sectionHeader?: ReactElement;\n sectionFooter?: ReactElement;\n}\n\nfunction parseSectionChildren(children: ReactNode): PageElements {\n let content: ReactElement | null = null;\n const pageElements: Partial<PageElements> = {};\n\n Children.forEach(children, (child) => {\n if (!isValidElement(child)) {\n throw new Error(\n `Invalid React element found in children: ${child}`,\n {\n cause: { child },\n }\n );\n }\n\n const component = validChildren.find((x) => x === child.type);\n if (!component) {\n throw Error(\n `Component \"${child.type}\" is not valid as a child for Section, Expected one of: ${validChildren\n .map((x) => x.name)\n .join(',')}`\n );\n }\n\n switch (component) {\n case SectionHeader:\n pageElements.sectionHeader = child;\n break;\n\n case SectionFooter:\n pageElements.sectionFooter = child;\n break;\n\n case PageContent:\n content = child;\n break;\n\n case PageHeader:\n pageElements.header = child;\n break;\n\n case PageFooter:\n pageElements.footer = child;\n break;\n\n case PageOverlay:\n pageElements.overlay = child;\n break;\n }\n });\n\n if (!content) {\n throw Error('PageContent component is a required child for Section');\n }\n\n return { ...pageElements, content: content };\n}\n\nexport default parseSectionChildren;\n","import { createContext } from 'react';\n\nexport const SectionIdContext = createContext<string>('');\n","import { createContext } from 'react';\n\nexport const PageInfoContext = createContext<{\n pageIndex: number;\n totalPages: number;\n}>({\n pageIndex: 0,\n totalPages: 0,\n});\n","import { useContext, useMemo, type Ref } from 'react';\nimport { type PageElements } from '../internal/parseSectionChildren';\nimport { PageInfoContext } from '../internal/PageInfoContext';\nimport { SectionIdContext } from '../internal/SectionIdContext';\nimport {\n pageClassName,\n pageMargin,\n reportStyles,\n type PageSize,\n type PageMargin,\n} from '@paprize/core/src';\n\nexport interface PageProps {\n elements: PageElements;\n size: PageSize;\n margin?: PageMargin;\n pageIndex: number;\n totalPages: number;\n ref?: Ref<HTMLDivElement>;\n sectionHeaderRef?: Ref<HTMLDivElement>;\n sectionFooterRef?: Ref<HTMLDivElement>;\n pageHeaderRef?: Ref<HTMLDivElement>;\n pageFooterRef?: Ref<HTMLDivElement>;\n contentRef?: Ref<HTMLDivElement>;\n}\n\nexport function Page({\n elements,\n size,\n margin,\n pageIndex,\n totalPages,\n ref,\n sectionHeaderRef,\n sectionFooterRef,\n pageHeaderRef,\n pageFooterRef,\n contentRef,\n}: PageProps) {\n const sectionId = useContext(SectionIdContext);\n const contextValue = useMemo(\n () => ({ pageIndex, totalPages }),\n [pageIndex, totalPages]\n );\n\n return (\n <PageInfoContext value={contextValue}>\n <div\n id={`${sectionId}-${pageIndex}`}\n className={pageClassName}\n ref={ref}\n style={reportStyles.page(size, margin ?? pageMargin.None)}\n >\n {elements.sectionHeader && pageIndex === 0 && (\n <div style={reportStyles.component} ref={sectionHeaderRef}>\n {elements.sectionHeader}\n </div>\n )}\n {elements.header && (\n <div style={reportStyles.component} ref={pageHeaderRef}>\n {elements.header}\n </div>\n )}\n\n <div style={reportStyles.pageContent} ref={contentRef}>\n {elements.content}\n </div>\n\n {elements.overlay && (\n <div style={reportStyles.overlay}>{elements.overlay}</div>\n )}\n\n {(elements.footer || elements.sectionFooter) && (\n <div\n style={{ ...reportStyles.component, marginTop: 'auto' }}\n >\n {elements.footer && (\n <div\n style={reportStyles.component}\n ref={pageFooterRef}\n >\n {elements.footer}\n </div>\n )}\n {elements.sectionFooter &&\n pageIndex === totalPages - 1 && (\n <div\n style={reportStyles.component}\n ref={sectionFooterRef}\n >\n {elements.sectionFooter}\n </div>\n )}\n </div>\n )}\n </div>\n </PageInfoContext>\n );\n}\n","import type { PaginationPlugin } from '@paprize/core/src';\nimport { createContext } from 'react';\n\nexport interface SectionController {\n addPlugin: (plugin: PaginationPlugin) => void;\n addSuspense: (suspense: Promise<void>) => void;\n}\n\nexport const SectionControllerContext = createContext<SectionController>({\n addPlugin: () => {\n throw new Error('addPlugin must be used within a Section');\n },\n addSuspense: () => {\n throw new Error('addSuspense must be used within a Section');\n },\n});\n","import { useMemo } from 'react';\nimport { type SectionController } from './SectionControllerContext';\nimport type { PaginationPlugin } from '@paprize/core/src';\n\nexport function useSectionControllerState(plugins?: PaginationPlugin[]) {\n const state = useMemo(\n () => ({\n plugins: plugins ?? ([] as PaginationPlugin[]),\n suspense: [] as Promise<void>[],\n }),\n [plugins]\n );\n\n const sectionController: SectionController = useMemo(\n () => ({\n addPlugin: (plugin: PaginationPlugin) => {\n state.plugins.push(plugin);\n },\n addSuspense: (suspense: Promise<void>) => {\n state.suspense.push(suspense);\n },\n }),\n [state]\n );\n\n return {\n controllerState: state,\n controllerValue: sectionController,\n };\n}\n","import {\n adjustPageSize,\n logger,\n reportStyles,\n type PageContext,\n type SectionOptions,\n} from '@paprize/core/src';\nimport { useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Page } from '../components/Page';\nimport { useReportBuilder } from './useReportBuilder';\nimport { SectionIdContext } from './SectionIdContext';\nimport type { PageElements } from './parseSectionChildren';\nimport { useSectionControllerState } from './useSectionControllerState';\nimport { SectionControllerContext } from './SectionControllerContext';\n\nexport interface SectionLayoutProps {\n elements: PageElements;\n options: SectionOptions;\n}\n\nexport function SectionLayout({ elements, options }: SectionLayoutProps) {\n const sectionId = useContext(SectionIdContext);\n const { controllerState, controllerValue } = useSectionControllerState(\n options?.plugins\n );\n const reportBuilder = useReportBuilder();\n const pageRef = useRef<HTMLDivElement>(null);\n const sectionHeaderRef = useRef<HTMLDivElement>(null);\n const sectionFooterRef = useRef<HTMLDivElement>(null);\n const pageHeaderRef = useRef<HTMLDivElement>(null);\n const pageFooterRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const realizedSize = useMemo(\n () => adjustPageSize(options.size, options.orientation),\n [options.orientation, options.size]\n );\n const [pageContexts, setPageContexts] = useState<PageContext[] | null>(\n null\n );\n\n useEffect(() => {\n if (!contentRef.current) {\n return;\n }\n\n reportBuilder\n .tryAddSection(\n {\n ...options,\n id: sectionId,\n plugins: controllerState.plugins,\n suspense: controllerState.suspense,\n },\n {\n pageContent: contentRef.current,\n sectionHeader: sectionHeaderRef.current,\n sectionFooter: sectionFooterRef.current,\n pageFooter: pageFooterRef.current,\n pageHeader: pageHeaderRef.current,\n },\n (pages) => {\n setPageContexts(pages);\n }\n )\n .catch((e) => logger.error(e));\n\n return () => {\n reportBuilder.removeSection(sectionId);\n };\n }, [\n controllerState.plugins,\n controllerState.suspense,\n options,\n reportBuilder,\n sectionId,\n ]);\n\n return (\n <SectionControllerContext value={controllerValue}>\n {pageContexts?.map((pageContext) => (\n <Page\n key={pageContext.pageIndex}\n elements={{\n ...elements,\n content: (\n <div\n style={{ display: 'contents' }}\n dangerouslySetInnerHTML={{\n __html: pageContext.pageContentHtml,\n }}\n />\n ),\n }}\n size={realizedSize}\n margin={options.margin}\n pageIndex={pageContext.pageIndex}\n totalPages={pageContext.totalPages}\n />\n ))}\n\n {createPortal(\n <div style={reportStyles.outOfScreen}>\n <Page\n elements={elements}\n size={realizedSize}\n margin={options.margin}\n pageIndex={0}\n totalPages={1}\n ref={pageRef}\n sectionHeaderRef={sectionHeaderRef}\n sectionFooterRef={sectionFooterRef}\n pageHeaderRef={pageHeaderRef}\n pageFooterRef={pageFooterRef}\n contentRef={contentRef}\n />\n </div>,\n document.body\n )}\n </SectionControllerContext>\n );\n}\n","import { useMemo, type ReactNode } from 'react';\nimport parseSectionChildren from '../internal/parseSectionChildren';\nimport { SectionIdContext } from '../internal/SectionIdContext';\nimport {\n reportStyles,\n sectionClassName,\n type SectionOptions,\n} from '@paprize/core/src';\nimport { SectionLayout } from '../internal/SectionLayout';\n\n/**\n * Configuration options for a section.\n * @inlineType SectionOptions\n */\nexport interface SectionProps extends Omit<SectionOptions, 'id' | 'suspense'> {\n children: ReactNode;\n /**\n * Unique id of the section within the report. If not set, a random id will be used.\n */\n id?: string;\n}\n\nlet sectionIdCounter = 1;\n\nexport function Section({ children, id, ...options }: SectionProps) {\n const sectionId = useMemo(() => id ?? `__000${sectionIdCounter++}`, [id]);\n const elements = useMemo(() => parseSectionChildren(children), [children]);\n const sectionOptions = useMemo(\n () => ({\n ...options,\n id: sectionId,\n }),\n [options, sectionId]\n );\n\n return (\n <section\n className={sectionClassName}\n id={sectionId}\n style={reportStyles.section(sectionId)}\n >\n <SectionIdContext value={sectionId}>\n <SectionLayout elements={elements} options={sectionOptions} />\n </SectionIdContext>\n </section>\n );\n}\n","import { pageBreakAttributeName } from '@paprize/core/src';\n\nexport function PageBreak() {\n return <span {...{ [pageBreakAttributeName]: 'true' }} />;\n}\n","import {\n layoutOptionsToAttributes,\n type LayoutOptions,\n} from '@paprize/core/src';\n\nexport interface LayoutProps extends LayoutOptions {\n children: React.ReactNode;\n}\n\nexport function Layout({ children, ...attributes }: LayoutProps) {\n return (\n <div\n style={{ display: 'contents' }}\n {...layoutOptionsToAttributes(attributes)}\n >\n {children}\n </div>\n );\n}\n","import { useContext } from 'react';\nimport { PageInfoContext } from '../internal/PageInfoContext';\nimport type { PageInfo } from '../internal/eventHelper';\n\n/**\n * React hook that returns information about the current page.\n */\nexport const usePageInfo = (): PageInfo => {\n const pageContext = useContext(PageInfoContext);\n\n return {\n pageIndex: pageContext.pageIndex,\n totalPages: pageContext.totalPages,\n };\n};\n","import { useContext, useRef, useSyncExternalStore } from 'react';\nimport type { SectionContext } from '@paprize/core/src';\nimport { useReportBuilder } from '../internal/useReportBuilder';\nimport { SectionIdContext } from '../internal/SectionIdContext';\nimport type { SectionInfo } from '../internal/eventHelper';\n\n/**\n * React hook that returns information about the current section.\n */\nexport const useSectionInfo = (): SectionInfo => {\n const sectionId = useContext(SectionIdContext);\n const reportBuilder = useReportBuilder();\n const stateRef = useRef<SectionContext>({\n pages: [],\n isPaginated: false,\n isSuspended: false,\n sectionIndex: -1,\n sectionId: sectionId,\n });\n\n const state = useSyncExternalStore(\n (callback) => {\n return reportBuilder.monitor.addEventListener(\n 'sectionCompleted',\n (sc) => {\n if (sc.sectionId !== sectionId) return;\n stateRef.current = sc;\n callback();\n }\n );\n },\n () => stateRef.current\n );\n\n return {\n sectionId: sectionId,\n sectionIndex: state.sectionIndex,\n isSuspended: state.isSuspended,\n isPaginated: state.isPaginated,\n pages: state.pages.map((p) => ({\n pageIndex: p.pageIndex,\n totalPages: p.totalPages,\n })),\n };\n};\n","import type {\n PaginationCycleCompleted,\n SectionContext,\n} from '@paprize/core/src';\n\n/**\n * {@inheritDoc @paprize/core!PageContext}\n */\nexport interface PageInfo {\n /**\n * {@inheritDoc @paprize/core!PageContext.pageIndex}\n */\n pageIndex: number;\n /**\n * {@inheritDoc @paprize/core!PageContext.totalPages}\n */\n totalPages: number;\n}\n\n/**\n * {@inheritDoc @paprize/core!SectionContext}\n */\nexport interface SectionInfo {\n /**\n * {@inheritDoc @paprize/core!SectionContext.sectionId}\n */\n sectionId: string;\n /**\n * {@inheritDoc @paprize/core!SectionContext.sectionIndex}\n */\n sectionIndex: number;\n /**\n * {@inheritDoc @paprize/core!SectionContext.isPaginated}\n */\n isPaginated: boolean;\n /**\n * {@inheritDoc @paprize/core!SectionContext.isSuspended}\n */\n isSuspended: boolean;\n /**\n * {@inheritDoc @paprize/core!SectionContext.pages}\n */\n pages: PageInfo[];\n}\n\n/**\n * {@inheritDoc @paprize/core!PaginationCycleCompleted}\n */\n\nexport interface ReportInfo {\n /**\n * {@inheritDoc @paprize/core!PaginationCycleCompleted.sections}\n */\n sections: SectionInfo[];\n}\n\nexport function pageContextToPageInfo(pc: {\n pageIndex: number;\n totalPages: number;\n}): PageInfo {\n return {\n pageIndex: pc.pageIndex,\n totalPages: pc.totalPages,\n };\n}\n\nexport function sectionContextToSectionInfo(sc: SectionContext): SectionInfo {\n return {\n sectionId: sc.sectionId,\n sectionIndex: sc.sectionIndex,\n isPaginated: sc.isPaginated,\n isSuspended: sc.isSuspended,\n pages: sc.pages.map(pageContextToPageInfo),\n };\n}\n\nexport function paginationCycleToReportInfo(\n rc: PaginationCycleCompleted\n): ReportInfo {\n return {\n sections: rc.sections.map(sectionContextToSectionInfo),\n };\n}\n","import { useRef, useSyncExternalStore } from 'react';\nimport { useReportBuilder } from '../internal/useReportBuilder';\nimport type { PaginationCycleCompleted } from '@paprize/core/src';\nimport {\n paginationCycleToReportInfo,\n type ReportInfo,\n} from '../internal/eventHelper';\n\n/**\n * React hook that returns information about the report.\n */\nexport function useReportInfo(): ReportInfo {\n const reportBuilder = useReportBuilder();\n const stateRef = useRef<PaginationCycleCompleted>({\n sections: [],\n });\n\n const state = useSyncExternalStore(\n (callback) => {\n return reportBuilder.monitor.addEventListener(\n 'paginationCycleCompleted',\n (pg) => {\n stateRef.current = pg;\n callback();\n }\n );\n },\n () => stateRef.current\n );\n\n return paginationCycleToReportInfo(state);\n}\n","import { useContext, useEffect, useMemo, useRef } from 'react';\nimport { SectionControllerContext } from '../internal/SectionControllerContext';\n\n/**\n * Controls the section suspension.\n * @inline\n */\nexport interface SectionSuspension {\n /**\n * Releases the suspension. The pagination engine will paginate this section immediately.\n */\n release: () => void;\n\n /**\n * Marks the suspension as pending again if it was previously resolved.\n * During the next pagination cycle (for example, if pagination is retriggered\n * by changes to the page content), this section will not be paginated\n * until `release` is called again.\n */\n reset: () => void;\n}\n\n/**\n * Suspends pagination for this section.\n * @param promise The suspension is tied to this promise. Once the promise is resolved,\n * the suspension is released and the pagination engine will paginate this section.\n */\nexport function useSectionSuspension(\n promise: Promise<void> | Promise<unknown>\n): void;\n/**\n * Suspends pagination for this section. You need to call the `release` method\n * of the returned value; otherwise, the pagination engine will never paginate this section.\n */\nexport function useSectionSuspension(): SectionSuspension;\nexport function useSectionSuspension(\n promise?: Promise<void> | Promise<unknown>\n) {\n const resolveFn = useRef<() => void | null>(null);\n const { addSuspense } = useContext(SectionControllerContext);\n\n useEffect(() => {\n if (resolveFn.current) {\n return;\n }\n\n const pr =\n promise ??\n new Promise<void>((resolve) => {\n resolveFn.current = resolve;\n });\n resolveFn.current ||= () => {};\n\n addSuspense(pr as Promise<void>);\n }, [addSuspense, promise]);\n\n return useMemo(\n () => ({\n reset: () => {\n if (resolveFn.current) return;\n\n addSuspense(\n new Promise<void>((resolve) => {\n resolveFn.current = resolve;\n })\n );\n },\n release: () => {\n resolveFn.current?.();\n resolveFn.current = null;\n },\n }),\n [addSuspense]\n );\n}\n","import { useSectionSuspension } from './useSectionSuspension';\nimport { useReportBuilder } from '../internal/useReportBuilder';\nimport { useEffect, useMemo } from 'react';\n\n/**\n * {@inheritDoc @paprize/core!ReportBuilder.getJsonData}\n */\nexport function useJsonData<DataModel>(\n defaultValue?: DataModel\n): DataModel | null {\n const reportBuilder = useReportBuilder();\n const value = useMemo(\n () => ({\n current: null as DataModel | null,\n }),\n []\n );\n\n const promise = useMemo(\n () => reportBuilder.getJsonData(defaultValue),\n [defaultValue, reportBuilder]\n );\n\n useSectionSuspension(promise);\n\n useEffect(() => {\n promise.then((v) => (value.current = v));\n }, [promise, value]);\n\n return value.current ?? defaultValue ?? null;\n}\n"],"names":["ReportPreview","children","jsx","previewClassName","ReportBuilderContext","createContext","useReportBuilder","context","useContext","ReportRoot","reportBuilder","useMemo","ReportBuilder","useEffect","PageContent","isFirstCycleCompleted","useRef","unsubscribe","PageFooter","PageHeader","SectionFooter","SectionHeader","PageOverlay","validChildren","parseSectionChildren","content","pageElements","Children","child","isValidElement","component","x","SectionIdContext","PageInfoContext","Page","elements","size","margin","pageIndex","totalPages","ref","sectionHeaderRef","sectionFooterRef","pageHeaderRef","pageFooterRef","contentRef","sectionId","contextValue","jsxs","pageClassName","reportStyles","pageMargin","SectionControllerContext","useSectionControllerState","plugins","state","sectionController","plugin","suspense","SectionLayout","options","controllerState","controllerValue","pageRef","realizedSize","adjustPageSize","pageContexts","setPageContexts","useState","pages","e","logger","pageContext","createPortal","sectionIdCounter","Section","id","sectionOptions","sectionClassName","PageBreak","pageBreakAttributeName","Layout","attributes","layoutOptionsToAttributes","usePageInfo","useSectionInfo","stateRef","useSyncExternalStore","callback","sc","p","pageContextToPageInfo","pc","sectionContextToSectionInfo","paginationCycleToReportInfo","rc","useReportInfo","pg","useSectionSuspension","promise","resolveFn","addSuspense","pr","resolve","useJsonData","defaultValue","value","v"],"mappings":"mbAGO,SAASA,EAAc,CAAE,SAAAC,GAAqC,CACjE,OAAOC,EAAAA,IAAC,MAAA,CAAI,UAAWC,EAAAA,iBAAmB,SAAAF,CAAA,CAAS,CACvD,CCFO,MAAMG,EAAuBC,EAAAA,cAAoC,IAAI,EAErE,SAASC,GAAmB,CAC/B,MAAMC,EAAUC,EAAAA,WAAWJ,CAAoB,EAC/C,GAAI,CAACG,EACD,MAAM,IAAI,MACN,mFAAA,EAIR,OAAOA,CACX,CCNO,SAASE,EAAW,CAAE,SAAAR,GAA6B,CACtD,MAAMS,EAAgBC,EAAAA,QAAQ,IAAM,IAAIC,EAAAA,cAAiB,CAAA,CAAE,EAE3DC,OAAAA,EAAAA,UAAU,IAAM,CACZH,EAAc,mBAAA,CAClB,EAAG,CAACA,CAAa,CAAC,EAGdR,EAAAA,IAACE,EAAA,CAAqB,MAAOM,EACxB,SAAAT,CAAA,CACL,CAER,CCjBO,SAASa,EAAY,CAAE,SAAAb,GAAqC,CAC/D,MAAMS,EAAgBJ,EAAA,EAChBS,EAAwBC,EAAAA,OAAO,EAAK,EAE1CH,OAAAA,EAAAA,UAAU,IAAM,CACZ,MAAMI,EAAcP,EAAc,QAAQ,iBACtC,2BACA,IAAM,CACFK,EAAsB,QAAU,EACpC,CAAA,EAGJ,MAAO,IAAME,EAAA,CACjB,EAAG,CAACP,EAAc,OAAO,CAAC,EAK1BG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