@paprize/react 0.0.6 → 0.0.7

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.
@@ -7,8 +7,6 @@ import { ReactNode } from 'react';
7
7
  import { SectionContext } from '@paprize/core';
8
8
  import { SectionOptions } from '@paprize/core';
9
9
 
10
- export declare const jsonData: () => Promise<unknown>;
11
-
12
10
  export declare function Layout({ children, ...attributes }: LayoutProps): JSX.Element;
13
11
 
14
12
  export declare interface LayoutProps extends LayoutOptions {
@@ -149,7 +147,10 @@ export declare interface SectionSuspension {
149
147
  reset: () => void;
150
148
  }
151
149
 
152
- export declare function useJsonData<DataModel>(defaultValue?: DataModel): DataModel | undefined;
150
+ /**
151
+ * {@inheritDoc @paprize/core!ReportBuilder.getJsonData}
152
+ */
153
+ export declare function useJsonData<DataModel>(defaultValue?: DataModel): DataModel | null;
153
154
 
154
155
  /**
155
156
  * React hook that returns information about the current page.
@@ -1,153 +1,153 @@
1
- import { jsx as r, Fragment as d, jsxs as x } from "react/jsx-runtime";
2
- import { previewClassName as O, ReportBuilder as J, reportStyles as a, pageClassName as V, pageMargin as A, adjustPageSize as M, sectionClassName as q, pageBreakAttributeName as G, layoutOptionsToAttributes as K, paprize_readJsonDataFile as R } from "@paprize/core";
3
- import { createContext as C, useContext as p, useMemo as u, useEffect as g, useRef as c, Children as Q, isValidElement as U, useState as W, useSyncExternalStore as b } from "react";
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
4
  import { createPortal as X } from "react-dom";
5
- function pe({ children: e }) {
6
- return /* @__PURE__ */ r("div", { className: O, children: e });
5
+ function le({ children: e }) {
6
+ return /* @__PURE__ */ r("div", { className: _, children: e });
7
7
  }
8
- const H = C(null);
9
- function h() {
10
- const e = p(H);
8
+ const F = I(null);
9
+ function m() {
10
+ const e = g(F);
11
11
  if (!e)
12
12
  throw new Error(
13
13
  "ReportRoot is missing. Please wrap your component tree with ReportRoot component."
14
14
  );
15
15
  return e;
16
16
  }
17
- function fe({ children: e }) {
18
- const n = u(() => new J(), []);
19
- return g(() => {
20
- n.schedulePagination();
21
- }, [n]), /* @__PURE__ */ r(H, { value: n, children: e });
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
22
  }
23
- function z({ children: e }) {
24
- const n = h(), o = c(!1);
25
- return g(() => {
26
- const t = n.monitor.addEventListener(
23
+ function B({ children: e }) {
24
+ const t = m(), o = u(!1);
25
+ return d(() => {
26
+ const n = t.monitor.addEventListener(
27
27
  "paginationCycleCompleted",
28
28
  () => {
29
29
  o.current = !0;
30
30
  }
31
31
  );
32
- return () => t();
33
- }, [n.monitor]), g(() => {
34
- o.current && n.schedulePagination();
35
- }, [e, n]), /* @__PURE__ */ r(d, { children: e });
36
- }
37
- function B({ children: e }) {
38
- return /* @__PURE__ */ r(d, { children: e });
32
+ return () => n();
33
+ }, [t.monitor]), d(() => {
34
+ o.current && t.schedulePagination();
35
+ }, [e, t]), /* @__PURE__ */ r(p, { children: e });
39
36
  }
40
- function N({ children: e }) {
41
- return /* @__PURE__ */ r(d, { children: e });
37
+ function H({ children: e }) {
38
+ return /* @__PURE__ */ r(p, { children: e });
42
39
  }
43
40
  function k({ children: e }) {
44
- return /* @__PURE__ */ r(d, { children: e });
41
+ return /* @__PURE__ */ r(p, { children: e });
42
+ }
43
+ function N({ children: e }) {
44
+ return /* @__PURE__ */ r(p, { children: e });
45
45
  }
46
- function T({ children: e }) {
47
- return /* @__PURE__ */ r(d, { children: e });
46
+ function z({ children: e }) {
47
+ return /* @__PURE__ */ r(p, { children: e });
48
48
  }
49
49
  function L({ children: e }) {
50
- return /* @__PURE__ */ r(d, { children: e });
50
+ return /* @__PURE__ */ r(p, { children: e });
51
51
  }
52
- const E = [
53
- z,
54
- N,
52
+ const w = [
55
53
  B,
54
+ k,
55
+ H,
56
56
  L,
57
- T,
58
- k
57
+ z,
58
+ N
59
59
  ];
60
60
  function Y(e) {
61
- let n = null;
61
+ let t = null;
62
62
  const o = {};
63
- if (Q.forEach(e, (t) => {
64
- if (!U(t))
63
+ if (Q.forEach(e, (n) => {
64
+ if (!U(n))
65
65
  throw new Error(
66
- `Invalid React element found in children: ${t}`,
66
+ `Invalid React element found in children: ${n}`,
67
67
  {
68
- cause: { child: t }
68
+ cause: { child: n }
69
69
  }
70
70
  );
71
- const s = E.find((i) => i === t.type);
71
+ const s = w.find((i) => i === n.type);
72
72
  if (!s)
73
73
  throw Error(
74
- `Component "${t.type}" is not valid as a child for Section, Expected one of: ${E.map((i) => i.name).join(",")}`
74
+ `Component "${n.type}" is not valid as a child for Section, Expected one of: ${w.map((i) => i.name).join(",")}`
75
75
  );
76
76
  switch (s) {
77
- case T:
78
- o.sectionHeader = t;
79
- break;
80
- case k:
81
- o.sectionFooter = t;
82
- break;
83
77
  case z:
84
- n = t;
78
+ o.sectionHeader = n;
85
79
  break;
86
80
  case N:
87
- o.header = t;
81
+ o.sectionFooter = n;
88
82
  break;
89
83
  case B:
90
- o.footer = t;
84
+ t = n;
85
+ break;
86
+ case k:
87
+ o.header = n;
88
+ break;
89
+ case H:
90
+ o.footer = n;
91
91
  break;
92
92
  case L:
93
- o.overlay = t;
93
+ o.overlay = n;
94
94
  break;
95
95
  }
96
- }), !n)
96
+ }), !t)
97
97
  throw Error("PageContent component is a required child for Section");
98
- return { ...o, content: n };
98
+ return { ...o, content: t };
99
99
  }
100
- const I = C(""), _ = C({
100
+ const h = I(""), T = I({
101
101
  pageIndex: 0,
102
102
  totalPages: 0
103
103
  });
104
- function F({
104
+ function E({
105
105
  elements: e,
106
- size: n,
106
+ size: t,
107
107
  margin: o,
108
- pageIndex: t,
108
+ pageIndex: n,
109
109
  totalPages: s,
110
110
  ref: i,
111
- sectionHeaderRef: w,
112
- sectionFooterRef: m,
113
- pageHeaderRef: S,
111
+ sectionHeaderRef: x,
112
+ sectionFooterRef: S,
113
+ pageHeaderRef: P,
114
114
  pageFooterRef: y,
115
- contentRef: P
115
+ contentRef: v
116
116
  }) {
117
- const f = p(I), v = u(
118
- () => ({ pageIndex: t, totalPages: s }),
119
- [t, s]
117
+ const f = g(h), C = a(
118
+ () => ({ pageIndex: n, totalPages: s }),
119
+ [n, s]
120
120
  );
121
- return /* @__PURE__ */ r(_, { value: v, children: /* @__PURE__ */ x(
121
+ return /* @__PURE__ */ r(T, { value: C, children: /* @__PURE__ */ R(
122
122
  "div",
123
123
  {
124
- id: `${f}-${t}`,
125
- className: V,
124
+ id: `${f}-${n}`,
125
+ className: M,
126
126
  ref: i,
127
- style: a.page(n, o ?? A.None),
127
+ style: c.page(t, o ?? D.None),
128
128
  children: [
129
- e.sectionHeader && t === 0 && /* @__PURE__ */ r("div", { style: a.component, ref: w, children: e.sectionHeader }),
130
- e.header && /* @__PURE__ */ r("div", { style: a.component, ref: S, children: e.header }),
131
- /* @__PURE__ */ r("div", { style: a.pageContent, ref: P, children: e.content }),
132
- e.overlay && /* @__PURE__ */ r("div", { style: a.overlay, children: e.overlay }),
133
- (e.footer || e.sectionFooter) && /* @__PURE__ */ x(
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
134
  "div",
135
135
  {
136
- style: { ...a.component, marginTop: "auto" },
136
+ style: { ...c.component, marginTop: "auto" },
137
137
  children: [
138
138
  e.footer && /* @__PURE__ */ r(
139
139
  "div",
140
140
  {
141
- style: a.component,
141
+ style: c.component,
142
142
  ref: y,
143
143
  children: e.footer
144
144
  }
145
145
  ),
146
- e.sectionFooter && t === s - 1 && /* @__PURE__ */ r(
146
+ e.sectionFooter && n === s - 1 && /* @__PURE__ */ r(
147
147
  "div",
148
148
  {
149
- style: a.component,
150
- ref: m,
149
+ style: c.component,
150
+ ref: S,
151
151
  children: e.sectionFooter
152
152
  }
153
153
  )
@@ -158,7 +158,7 @@ function F({
158
158
  }
159
159
  ) });
160
160
  }
161
- const $ = C({
161
+ const $ = I({
162
162
  addPlugin: () => {
163
163
  throw new Error("addPlugin must be used within a Section");
164
164
  },
@@ -167,68 +167,68 @@ const $ = C({
167
167
  }
168
168
  });
169
169
  function Z(e) {
170
- const n = u(
170
+ const t = a(
171
171
  () => ({
172
172
  plugins: e ?? [],
173
173
  suspense: []
174
174
  }),
175
175
  [e]
176
- ), o = u(
176
+ ), o = a(
177
177
  () => ({
178
- addPlugin: (t) => {
179
- n.plugins.push(t);
178
+ addPlugin: (n) => {
179
+ t.plugins.push(n);
180
180
  },
181
- addSuspense: (t) => {
182
- n.suspense.push(t);
181
+ addSuspense: (n) => {
182
+ t.suspense.push(n);
183
183
  }
184
184
  }),
185
- [n]
185
+ [t]
186
186
  );
187
187
  return {
188
- controllerState: n,
188
+ controllerState: t,
189
189
  controllerValue: o
190
190
  };
191
191
  }
192
- function ee({ elements: e, options: n }) {
193
- const o = p(I), { controllerState: t, controllerValue: s } = Z(
194
- n?.plugins
195
- ), i = h(), w = c(null), m = c(null), S = c(null), y = c(null), P = c(null), f = c(null), v = u(
196
- () => M(n.size, n.orientation),
197
- [n.orientation, n.size]
198
- ), [j, D] = W(
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
199
  null
200
200
  );
201
- return g(() => {
201
+ return d(() => {
202
202
  if (f.current)
203
203
  return i.tryAddSection(
204
204
  {
205
- ...n,
205
+ ...t,
206
206
  id: o,
207
- plugins: t.plugins,
208
- suspense: t.suspense
207
+ plugins: n.plugins,
208
+ suspense: n.suspense
209
209
  },
210
210
  {
211
211
  pageContent: f.current,
212
- sectionHeader: m.current,
213
- sectionFooter: S.current,
214
- pageFooter: P.current,
212
+ sectionHeader: S.current,
213
+ sectionFooter: P.current,
214
+ pageFooter: v.current,
215
215
  pageHeader: y.current
216
216
  },
217
217
  (l) => {
218
- D(l);
218
+ O(l);
219
219
  }
220
- ), () => {
220
+ ).catch((l) => V.error(l)), () => {
221
221
  i.removeSection(o);
222
222
  };
223
223
  }, [
224
- t.plugins,
225
- t.suspense,
226
- n,
224
+ n.plugins,
225
+ n.suspense,
226
+ t,
227
227
  i,
228
228
  o
229
- ]), /* @__PURE__ */ x($, { value: s, children: [
229
+ ]), /* @__PURE__ */ R($, { value: s, children: [
230
230
  j?.map((l) => /* @__PURE__ */ r(
231
- F,
231
+ E,
232
232
  {
233
233
  elements: {
234
234
  ...e,
@@ -242,27 +242,27 @@ function ee({ elements: e, options: n }) {
242
242
  }
243
243
  )
244
244
  },
245
- size: v,
246
- margin: n.margin,
245
+ size: C,
246
+ margin: t.margin,
247
247
  pageIndex: l.pageIndex,
248
248
  totalPages: l.totalPages
249
249
  },
250
250
  l.pageIndex
251
251
  )),
252
252
  X(
253
- /* @__PURE__ */ r("div", { style: a.outOfScreen, children: /* @__PURE__ */ r(
254
- F,
253
+ /* @__PURE__ */ r("div", { style: c.outOfScreen, children: /* @__PURE__ */ r(
254
+ E,
255
255
  {
256
256
  elements: e,
257
- size: v,
258
- margin: n.margin,
257
+ size: C,
258
+ margin: t.margin,
259
259
  pageIndex: 0,
260
260
  totalPages: 1,
261
- ref: w,
262
- sectionHeaderRef: m,
263
- sectionFooterRef: S,
261
+ ref: x,
262
+ sectionHeaderRef: S,
263
+ sectionFooterRef: P,
264
264
  pageHeaderRef: y,
265
- pageFooterRef: P,
265
+ pageFooterRef: v,
266
266
  contentRef: f
267
267
  }
268
268
  ) }),
@@ -270,53 +270,53 @@ function ee({ elements: e, options: n }) {
270
270
  )
271
271
  ] });
272
272
  }
273
- let ne = 1;
274
- function ge({ children: e, id: n, ...o }) {
275
- const t = u(() => n ?? `__000${ne++}`, [n]), s = u(() => Y(e), [e]), i = u(
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
276
  () => ({
277
277
  ...o,
278
- id: t
278
+ id: n
279
279
  }),
280
- [o, t]
280
+ [o, n]
281
281
  );
282
282
  return /* @__PURE__ */ r(
283
283
  "section",
284
284
  {
285
285
  className: q,
286
- id: t,
287
- style: a.section(t),
288
- children: /* @__PURE__ */ r(I, { value: t, children: /* @__PURE__ */ r(ee, { elements: s, options: i }) })
286
+ id: n,
287
+ style: c.section(n),
288
+ children: /* @__PURE__ */ r(h, { value: n, children: /* @__PURE__ */ r(ee, { elements: s, options: i }) })
289
289
  }
290
290
  );
291
291
  }
292
- function me() {
292
+ function ge() {
293
293
  return /* @__PURE__ */ r("span", { [G]: "true" });
294
294
  }
295
- function Se({ children: e, ...n }) {
295
+ function fe({ children: e, ...t }) {
296
296
  return /* @__PURE__ */ r(
297
297
  "div",
298
298
  {
299
299
  style: { display: "contents" },
300
- ...K(n),
300
+ ...K(t),
301
301
  children: e
302
302
  }
303
303
  );
304
304
  }
305
- const ye = () => {
306
- const e = p(_);
305
+ const me = () => {
306
+ const e = g(T);
307
307
  return {
308
308
  pageIndex: e.pageIndex,
309
309
  totalPages: e.totalPages
310
310
  };
311
- }, Pe = () => {
312
- const e = p(I), n = h(), o = c({
311
+ }, Se = () => {
312
+ const e = g(h), t = m(), o = u({
313
313
  pages: [],
314
314
  isPaginated: !1,
315
315
  isSuspended: !1,
316
316
  sectionIndex: -1,
317
317
  sectionId: e
318
- }), t = b(
319
- (s) => n.monitor.addEventListener(
318
+ }), n = b(
319
+ (s) => t.monitor.addEventListener(
320
320
  "sectionCompleted",
321
321
  (i) => {
322
322
  i.sectionId === e && (o.current = i, s());
@@ -326,16 +326,16 @@ const ye = () => {
326
326
  );
327
327
  return {
328
328
  sectionId: e,
329
- sectionIndex: t.sectionIndex,
330
- isSuspended: t.isSuspended,
331
- isPaginated: t.isPaginated,
332
- pages: t.pages.map((s) => ({
329
+ sectionIndex: n.sectionIndex,
330
+ isSuspended: n.isSuspended,
331
+ isPaginated: n.isPaginated,
332
+ pages: n.pages.map((s) => ({
333
333
  pageIndex: s.pageIndex,
334
334
  totalPages: s.totalPages
335
335
  }))
336
336
  };
337
337
  };
338
- function te(e) {
338
+ function ne(e) {
339
339
  return {
340
340
  pageIndex: e.pageIndex,
341
341
  totalPages: e.totalPages
@@ -347,7 +347,7 @@ function oe(e) {
347
347
  sectionIndex: e.sectionIndex,
348
348
  isPaginated: e.isPaginated,
349
349
  isSuspended: e.isSuspended,
350
- pages: e.pages.map(te)
350
+ pages: e.pages.map(ne)
351
351
  };
352
352
  }
353
353
  function re(e) {
@@ -355,78 +355,76 @@ function re(e) {
355
355
  sections: e.sections.map(oe)
356
356
  };
357
357
  }
358
- function ve() {
359
- const e = h(), n = c({
358
+ function Pe() {
359
+ const e = m(), t = u({
360
360
  sections: []
361
361
  }), o = b(
362
- (t) => e.monitor.addEventListener(
362
+ (n) => e.monitor.addEventListener(
363
363
  "paginationCycleCompleted",
364
364
  (s) => {
365
- n.current = s, t();
365
+ t.current = s, n();
366
366
  }
367
367
  ),
368
- () => n.current
368
+ () => t.current
369
369
  );
370
370
  return re(o);
371
371
  }
372
372
  function se(e) {
373
- const n = c(null), { addSuspense: o } = p($);
374
- return g(() => {
375
- if (n.current)
373
+ const t = u(null), { addSuspense: o } = g($);
374
+ return d(() => {
375
+ if (t.current)
376
376
  return;
377
- const t = e ?? new Promise((s) => {
378
- n.current = s;
377
+ const n = e ?? new Promise((s) => {
378
+ t.current = s;
379
379
  });
380
- n.current ||= () => {
381
- }, o(t);
382
- }, [o, e]), u(
380
+ t.current ||= () => {
381
+ }, o(n);
382
+ }, [o, e]), a(
383
383
  () => ({
384
384
  reset: () => {
385
- n.current || o(
386
- new Promise((t) => {
387
- n.current = t;
385
+ t.current || o(
386
+ new Promise((n) => {
387
+ t.current = n;
388
388
  })
389
389
  );
390
390
  },
391
391
  release: () => {
392
- n.current?.(), n.current = null;
392
+ t.current?.(), t.current = null;
393
393
  }
394
394
  }),
395
395
  [o]
396
396
  );
397
397
  }
398
- function ie(e) {
399
- let n = null;
400
- return () => (n || (n = e()), n);
401
- }
402
- const ae = ie(async () => {
403
- if (!(R in window))
404
- throw new Error(
405
- "The function paprize_readJsonDataFile is not available in the current environment."
406
- );
407
- const e = await window[R]?.();
408
- return e ? JSON.parse(e) : null;
409
- });
410
- function Ce(e) {
411
- return se(ae().catch(() => e));
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;
412
411
  }
413
412
  export {
414
- Se as Layout,
415
- me as PageBreak,
416
- z as PageContent,
417
- B as PageFooter,
418
- N as PageHeader,
413
+ fe as Layout,
414
+ ge as PageBreak,
415
+ B as PageContent,
416
+ H as PageFooter,
417
+ k as PageHeader,
419
418
  L as PageOverlay,
420
- pe as ReportPreview,
421
- fe as ReportRoot,
422
- ge as Section,
423
- k as SectionFooter,
424
- T as SectionHeader,
425
- ae as jsonData,
426
- Ce as useJsonData,
427
- ye as usePageInfo,
428
- ve as useReportInfo,
429
- Pe as useSectionInfo,
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,
430
428
  se as useSectionSuspension
431
429
  };
432
430
  //# sourceMappingURL=paprize-react.js.map
@@ -1 +1 @@
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 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.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\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 { paprize_readJsonDataFile } from '@paprize/core/src';\nimport { useSectionSuspension } from './useSectionSuspension';\n\nfunction lazy<T>(factory: () => Promise<T>): () => Promise<T> {\n let promise: Promise<T> | null = null;\n\n return () => {\n if (!promise) {\n promise = factory();\n }\n return promise;\n };\n}\n\n// the function is not available in browser, and in puppeteer it is injected before anything else but we\n// still need to delay the call\nexport const jsonData = lazy(async () => {\n if (!(paprize_readJsonDataFile in window)) {\n throw new Error(\n 'The function paprize_readJsonDataFile is not available in the current environment.'\n );\n }\n\n const strData = await window[paprize_readJsonDataFile]?.();\n return strData ? (JSON.parse(strData) as unknown) : null;\n});\n\nexport function useJsonData<DataModel>(\n defaultValue?: DataModel\n): DataModel | undefined {\n return useSectionSuspension(jsonData().catch(() => defaultValue)) as\n | DataModel\n | undefined;\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","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","lazy","factory","jsonData","paprize_readJsonDataFile","strData","useJsonData","defaultValue"],"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,EAAU,MAAM;AACZ,IAAIE,EAAsB,WACtBL,EAAc,mBAAA;AAAA,EAEtB,GAAG,CAACT,GAAUS,CAAa,CAAC,0BAElB,UAAAT,GAAS;AACvB;AC5BO,SAASiB,EAAW,EAAE,UAAAjB,KAA2C;AACpE,gCAAU,UAAAA,GAAS;AACvB;ACAO,SAASkB,EAAW,EAAE,UAAAlB,KA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ACD,GAAaF,CAAO,CAAC,GAElBtF;AAAA,IACH,OAAO;AAAA,MACH,OAAO,MAAM;AACT,QAAIuF,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;ACvEA,SAASG,GAAQC,GAA6C;AAC1D,MAAIN,IAA6B;AAEjC,SAAO,OACEA,MACDA,IAAUM,EAAA,IAEPN;AAEf;AAIO,MAAMO,KAAWF,GAAK,YAAY;AACrC,MAAI,EAAEG,KAA4B;AAC9B,UAAM,IAAI;AAAA,MACN;AAAA,IAAA;AAIR,QAAMC,IAAU,MAAM,OAAOD,CAAwB,IAAA;AACrD,SAAOC,IAAW,KAAK,MAAMA,CAAO,IAAgB;AACxD,CAAC;AAEM,SAASC,GACZC,GACqB;AACrB,SAAOZ,GAAqBQ,GAAA,EAAW,MAAM,MAAMI,CAAY,CAAC;AAGpE;"}
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,EAA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ZA,EAAM,WAAWD,KAAgB;AAC5C;"}
@@ -1,2 +1,2 @@
1
- (function(a,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):(a=typeof globalThis<"u"?globalThis:a||self,r(a["paprize-react"]={},a.jsxRuntime,a.PaprizeCore,a.React,a.ReactDOM))})(this,(function(a,r,i,o,k){"use strict";function D({children:e}){return r.jsx("div",{className:i.previewClassName,children:e})}const x=o.createContext(null);function f(){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 i.ReportBuilder,[]);return o.useEffect(()=>{n.schedulePagination()},[n]),r.jsx(x,{value:n,children:e})}function v({children:e}){const n=f(),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 h({children:e}){return r.jsx(r.Fragment,{children:e})}function I({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 F({children:e}){return r.jsx(r.Fragment,{children:e})}const z=[v,I,h,F,w,m];function O(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=z.find(c=>c===t.type);if(!u)throw Error(`Component "${t.type}" is not valid as a child for Section, Expected one of: ${z.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 I:s.header=t;break;case h:s.footer=t;break;case F:s.overlay=t;break}}),!n)throw Error("PageContent component is a required child for Section");return{...s,content:n}}const p=o.createContext(""),b=o.createContext({pageIndex:0,totalPages:0});function H({elements:e,size:n,margin:s,pageIndex:t,totalPages:u,ref:c,sectionHeaderRef:E,sectionFooterRef:g,pageHeaderRef:S,pageFooterRef:y,contentRef:P}){const l=o.useContext(p),C=o.useMemo(()=>({pageIndex:t,totalPages:u}),[t,u]);return r.jsx(b,{value:C,children:r.jsxs("div",{id:`${l}-${t}`,className:i.pageClassName,ref:c,style:i.reportStyles.page(n,s??i.pageMargin.None),children:[e.sectionHeader&&t===0&&r.jsx("div",{style:i.reportStyles.component,ref:E,children:e.sectionHeader}),e.header&&r.jsx("div",{style:i.reportStyles.component,ref:S,children:e.header}),r.jsx("div",{style:i.reportStyles.pageContent,ref:P,children:e.content}),e.overlay&&r.jsx("div",{style:i.reportStyles.overlay,children:e.overlay}),(e.footer||e.sectionFooter)&&r.jsxs("div",{style:{...i.reportStyles.component,marginTop:"auto"},children:[e.footer&&r.jsx("div",{style:i.reportStyles.component,ref:y,children:e.footer}),e.sectionFooter&&t===u-1&&r.jsx("div",{style:i.reportStyles.component,ref:g,children:e.sectionFooter})]})]})})}const M=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 L(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 _({elements:e,options:n}){const s=o.useContext(p),{controllerState:t,controllerValue:u}=L(n?.plugins),c=f(),E=o.useRef(null),g=o.useRef(null),S=o.useRef(null),y=o.useRef(null),P=o.useRef(null),l=o.useRef(null),C=o.useMemo(()=>i.adjustPageSize(n.size,n.orientation),[n.orientation,n.size]),[X,Y]=o.useState(null);return o.useEffect(()=>{if(l.current)return c.tryAddSection({...n,id:s,plugins:t.plugins,suspense:t.suspense},{pageContent:l.current,sectionHeader:g.current,sectionFooter:S.current,pageFooter:P.current,pageHeader:y.current},d=>{Y(d)}),()=>{c.removeSection(s)}},[t.plugins,t.suspense,n,c,s]),r.jsxs(M,{value:u,children:[X?.map(d=>r.jsx(H,{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:i.reportStyles.outOfScreen,children:r.jsx(H,{elements:e,size:C,margin:n.margin,pageIndex:0,totalPages:1,ref:E,sectionHeaderRef:g,sectionFooterRef:S,pageHeaderRef:y,pageFooterRef:P,contentRef:l})}),document.body)]})}let J=1;function R({children:e,id:n,...s}){const t=o.useMemo(()=>n??`__000${J++}`,[n]),u=o.useMemo(()=>O(e),[e]),c=o.useMemo(()=>({...s,id:t}),[s,t]);return r.jsx("section",{className:i.sectionClassName,id:t,style:i.reportStyles.section(t),children:r.jsx(p,{value:t,children:r.jsx(_,{elements:u,options:c})})})}function $(){return r.jsx("span",{[i.pageBreakAttributeName]:"true"})}function q({children:e,...n}){return r.jsx("div",{style:{display:"contents"},...i.layoutOptionsToAttributes(n),children:e})}const j=()=>{const e=o.useContext(b);return{pageIndex:e.pageIndex,totalPages:e.totalPages}},V=()=>{const e=o.useContext(p),n=f(),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 A(e){return{pageIndex:e.pageIndex,totalPages:e.totalPages}}function G(e){return{sectionId:e.sectionId,sectionIndex:e.sectionIndex,isPaginated:e.isPaginated,isSuspended:e.isSuspended,pages:e.pages.map(A)}}function K(e){return{sections:e.sections.map(G)}}function Q(){const e=f(),n=o.useRef({sections:[]}),s=o.useSyncExternalStore(t=>e.monitor.addEventListener("paginationCycleCompleted",u=>{n.current=u,t()}),()=>n.current);return K(s)}function B(e){const n=o.useRef(null),{addSuspense:s}=o.useContext(M);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 U(e){let n=null;return()=>(n||(n=e()),n)}const T=U(async()=>{if(!(i.paprize_readJsonDataFile in window))throw new Error("The function paprize_readJsonDataFile is not available in the current environment.");const e=await window[i.paprize_readJsonDataFile]?.();return e?JSON.parse(e):null});function W(e){return B(T().catch(()=>e))}a.Layout=q,a.PageBreak=$,a.PageContent=v,a.PageFooter=h,a.PageHeader=I,a.PageOverlay=F,a.ReportPreview=D,a.ReportRoot=N,a.Section=R,a.SectionFooter=m,a.SectionHeader=w,a.jsonData=T,a.useJsonData=W,a.usePageInfo=j,a.useReportInfo=Q,a.useSectionInfo=V,a.useSectionSuspension=B,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
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
2
  //# sourceMappingURL=paprize-react.umd.cjs.map
@@ -1 +1 @@
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 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.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\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 { paprize_readJsonDataFile } from '@paprize/core/src';\nimport { useSectionSuspension } from './useSectionSuspension';\n\nfunction lazy<T>(factory: () => Promise<T>): () => Promise<T> {\n let promise: Promise<T> | null = null;\n\n return () => {\n if (!promise) {\n promise = factory();\n }\n return promise;\n };\n}\n\n// the function is not available in browser, and in puppeteer it is injected before anything else but we\n// still need to delay the call\nexport const jsonData = lazy(async () => {\n if (!(paprize_readJsonDataFile in window)) {\n throw new Error(\n 'The function paprize_readJsonDataFile is not available in the current environment.'\n );\n }\n\n const strData = await window[paprize_readJsonDataFile]?.();\n return strData ? (JSON.parse(strData) as unknown) : null;\n});\n\nexport function useJsonData<DataModel>(\n defaultValue?: DataModel\n): DataModel | undefined {\n return useSectionSuspension(jsonData().catch(() => defaultValue)) as\n | DataModel\n | undefined;\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","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","lazy","factory","jsonData","paprize_readJsonDataFile","strData","useJsonData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ET,EACA,QAAS,IAAM,CACXH,EAAU,UAAA,EACVA,EAAU,QAAU,IACxB,CAAA,GAEJ,CAACC,CAAW,CAAA,CAEpB,CCvEA,SAASG,EAAQC,EAA6C,CAC1D,IAAIN,EAA6B,KAEjC,MAAO,KACEA,IACDA,EAAUM,EAAA,GAEPN,EAEf,CAIO,MAAMO,EAAWF,EAAK,SAAY,CACrC,GAAI,EAAEG,EAAAA,4BAA4B,QAC9B,MAAM,IAAI,MACN,oFAAA,EAIR,MAAMC,EAAU,MAAM,OAAOD,EAAAA,wBAAwB,IAAA,EACrD,OAAOC,EAAW,KAAK,MAAMA,CAAO,EAAgB,IACxD,CAAC,EAEM,SAASC,EACZC,EACqB,CACrB,OAAOZ,EAAqBQ,EAAA,EAAW,MAAM,IAAMI,CAAY,CAAC,CAGpE"}
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,EAAAA,UAAU,IAAM,CACRE,EAAsB,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AA,WAAW4C,CAAwB,EAE3DvC,OAAAA,EAAAA,UAAU,IAAM,CACZ,GAAIuF,EAAU,QACV,OAGJ,MAAME,EACFH,GACA,IAAI,QAAeI,GAAY,CAC3BH,EAAU,QAAUG,CACxB,CAAC,EACLH,EAAU,UAAY,IAAM,CAAC,EAE7BC,EAAYC,CAAmB,CACnC,EAAG,CAACD,EAAaF,CAAO,CAAC,EAElBxF,EAAAA,QACH,KAAO,CACH,MAAO,IAAM,CACLyF,EAAU,SAEdC,EACI,IAAI,QAAeE,GAAY,CAC3BH,EAAU,QAAUG,CACxB,CAAC,CAAA,CAET,EACA,QAAS,IAAM,CACXH,EAAU,UAAA,EACVA,EAAU,QAAU,IACxB,CAAA,GAEJ,CAACC,CAAW,CAAA,CAEpB,CCnEO,SAASG,EACZC,EACgB,CAChB,MAAM/F,EAAgBJ,EAAA,EAChBoG,EAAQ/F,EAAAA,QACV,KAAO,CACH,QAAS,IAAA,GAEb,CAAA,CAAC,EAGCwF,EAAUxF,EAAAA,QACZ,IAAMD,EAAc,YAAY+F,CAAY,EAC5C,CAACA,EAAc/F,CAAa,CAAA,EAGhC,OAAAwF,EAAqBC,CAAO,EAE5BtF,EAAAA,UAAU,IAAM,CACZsF,EAAQ,KAAMQ,GAAOD,EAAM,QAAUC,CAAE,CAC3C,EAAG,CAACR,EAASO,CAAK,CAAC,EAEZA,EAAM,SAAWD,GAAgB,IAC5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paprize/react",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "React library for creating professional, print-ready reports",
5
5
  "type": "module",
6
6
  "files": [