@paprize/core 0.0.11 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -1
- package/README.md +76 -2
- package/dist/paprize-core.d.ts +0 -699
- package/dist/paprize-core.js +1067 -1411
- package/dist/paprize-core.js.map +1 -1
- package/dist/paprize-core.umd.cjs +11 -11
- package/dist/paprize-core.umd.cjs.map +1 -1
- package/package.json +5 -5
package/dist/paprize-core.d.ts
CHANGED
|
@@ -1,702 +1,3 @@
|
|
|
1
|
-
import type * as CSS_2 from 'csstype';
|
|
2
|
-
import { default as default_2 } from 'loglevel';
|
|
3
|
-
|
|
4
|
-
export declare function adjustPageSize(size: PageSize, orientation?: PageOrientation): PageSize;
|
|
5
|
-
|
|
6
|
-
export declare const attributePrefix = "data-pz-";
|
|
7
|
-
|
|
8
|
-
export declare function buildPageId(sectionId: string, pageIndex: number): string;
|
|
9
|
-
|
|
10
|
-
export declare function callPluginHook<T extends PluginHookNames>(plugins: PaginationPlugin[], hookName: T, ...args: Parameters<NonNullable<PaginationPlugin[T]>>): void;
|
|
11
|
-
|
|
12
|
-
export declare function cloneComponents(components: SectionComponents): SectionComponents;
|
|
13
|
-
|
|
14
|
-
export declare function createLoremIpsumParagraph(wordCount: number, seed: number): string;
|
|
15
|
-
|
|
16
|
-
export declare type CSSProperties = CSS_2.Properties<string | number>;
|
|
17
|
-
|
|
18
|
-
export declare const currentElementClassName = "pz-current-element";
|
|
19
|
-
|
|
20
|
-
export declare const currentTextClassName = "pz-current-text";
|
|
21
|
-
|
|
22
|
-
export declare const debugPlugin: PaginationPlugin;
|
|
23
|
-
|
|
24
|
-
export declare const defaultPlugins: PaginationPlugin[];
|
|
25
|
-
|
|
26
|
-
export declare class DomState {
|
|
27
|
-
private readonly _transaction;
|
|
28
|
-
private readonly _treeWalker;
|
|
29
|
-
private readonly _config;
|
|
30
|
-
private _completed;
|
|
31
|
-
private _currentNode;
|
|
32
|
-
private _previousNode;
|
|
33
|
-
constructor(root: Element, transaction: Transaction, config: PaginationOptions);
|
|
34
|
-
get completed(): boolean;
|
|
35
|
-
get currentNode(): PageNode | null;
|
|
36
|
-
get previousNode(): PageNode | null;
|
|
37
|
-
goToNextNode(): void;
|
|
38
|
-
goToNextSiblingOrParentSibling(): {
|
|
39
|
-
parentsTraversed: number;
|
|
40
|
-
};
|
|
41
|
-
goToFirstChildOrNextNode(): {
|
|
42
|
-
parentsTraversed: number;
|
|
43
|
-
};
|
|
44
|
-
private setState;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export declare const enableDebugMode: () => void;
|
|
48
|
-
|
|
49
|
-
export declare class EventDispatcher<TEvents> {
|
|
50
|
-
private registry;
|
|
51
|
-
addEventListener<T extends keyof TEvents>(name: T, handler: EventHandler<T, TEvents>): () => void;
|
|
52
|
-
removeEventListener<T extends keyof TEvents>(name: T, handler: EventHandler<T, TEvents>): void;
|
|
53
|
-
dispatch<T extends keyof TEvents>(name: T, ...args: Parameters<EventHandler<T, TEvents>>): Promise<void>;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
declare type EventHandler<TKey extends keyof TEvents, TEvents> = TEvents[TKey] extends (...args: infer TArgs) => infer TReturn ? (...args: TArgs) => TReturn : never;
|
|
57
|
-
|
|
58
|
-
export declare function getNodeLayoutOptionsFromAttribute(node: Node | null): Partial<LayoutOptions>;
|
|
59
|
-
|
|
60
|
-
export declare function getVisibleHeight(element: Element): number;
|
|
61
|
-
|
|
62
|
-
export declare const globalStyle = "\n html {\n box-sizing: border-box;\n }\n\n *,\n *:before,\n *:after {\n box-sizing: inherit;\n }\n\n :root {\n --paprize-page-background-color: #ffffff;\n --paprize-page-box-shadow: rgb(142 138 138) -1px 3px 5px 2px;\n --paprize-section-margin-bottom: 10px;\n --paprize-preview-background-color: rgb(218 220 224);\n --paprize-preview-padding: 30px 10px;\n }\n\n body {\n margin: 0;\n }\n \n @media screen {\n .pz-preview {\n min-height: 100vh;\n display: flex;\n flex-direction: column;\n align-items: center;\n background-color: var(--paprize-preview-background-color);\n padding: var(--paprize-preview-padding);\n }\n\n .pz-page {\n box-shadow: var(--paprize-page-box-shadow);\n background-color: var(--paprize-page-background-color);\n }\n\n .pz-section {\n margin-bottom: var(--paprize-section-margin-bottom);\n }\n }\n\n @media print {\n html:has(.pz-preview) *:not(.pz-preview):not(.pz-preview *):not(:has(.pz-preview)) {\n display: none !important;\n }\n } \n ";
|
|
63
|
-
|
|
64
|
-
export declare const globalStyleId = "paprize-global-style";
|
|
65
|
-
|
|
66
|
-
export declare const ignoredElementClassName = "pz-ignored-element";
|
|
67
|
-
|
|
68
|
-
export declare const ignoredTextClassName = "pz-ignored-text";
|
|
69
|
-
|
|
70
|
-
export declare const isDebugMode: () => boolean;
|
|
71
|
-
|
|
72
|
-
export declare function isElement(node: Node): node is Element;
|
|
73
|
-
|
|
74
|
-
export declare function isTextNode(node: Node): node is Text;
|
|
75
|
-
|
|
76
|
-
export declare const layoutOptionHyphenationDisabledAttribute = "data-pz-hyphenation-disabled";
|
|
77
|
-
|
|
78
|
-
export declare const layoutOptionHyphenAttribute = "data-pz-hyphen";
|
|
79
|
-
|
|
80
|
-
export declare const layoutOptionKeepOnSamePageAttribute = "data-pz-keep-on-same-page";
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Layout options for the pagination engine
|
|
84
|
-
*/
|
|
85
|
-
export declare interface LayoutOptions {
|
|
86
|
-
/**
|
|
87
|
-
* Specifies the character used for hyphenation when a word is broken across lines.
|
|
88
|
-
* @defaultValue "-"
|
|
89
|
-
*/
|
|
90
|
-
hyphen?: string;
|
|
91
|
-
/**
|
|
92
|
-
* Prevents an element from being split across pages.
|
|
93
|
-
* If an element does not fit in the available space on the current page,
|
|
94
|
-
* it will be moved entirely to the next page. If it still does not fit on an empty page,
|
|
95
|
-
* it will be skipped and not rendered.
|
|
96
|
-
* @defaultValue false
|
|
97
|
-
*/
|
|
98
|
-
keepOnSamePage?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Disables automatic word hyphenation.
|
|
101
|
-
* When disabled, if a word (a sequence of text without whitespace) does not fit
|
|
102
|
-
* on the current page, it will move to the next page instead of being split
|
|
103
|
-
* with a hyphen character.
|
|
104
|
-
* @defaultValue false
|
|
105
|
-
*/
|
|
106
|
-
hyphenationDisabled?: boolean;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export declare function layoutOptionsToAttributes(config: LayoutOptions): Record<string, string>;
|
|
110
|
-
|
|
111
|
-
export declare const logger: default_2.Logger;
|
|
112
|
-
|
|
113
|
-
export declare const loggerName = "paprize";
|
|
114
|
-
|
|
115
|
-
export declare type Monitor<TEvents> = Omit<EventDispatcher<TEvents>, 'dispatch'>;
|
|
116
|
-
|
|
117
|
-
export declare function moveOffscreen(element: HTMLDivElement): void;
|
|
118
|
-
|
|
119
|
-
export declare const pageBreakAttributeName = "data-pz-page-break";
|
|
120
|
-
|
|
121
|
-
export declare class PageBreakPlugin implements PaginationPlugin {
|
|
122
|
-
name: string;
|
|
123
|
-
order: number;
|
|
124
|
-
onVisitElement: (_id: string, domState: DomState & {
|
|
125
|
-
currentNode: PageElement;
|
|
126
|
-
}, pageManager: PageManager, context: VisitContext) => void;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export declare const pageClassName = "pz-page";
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Context information for a paginated page.
|
|
133
|
-
*/
|
|
134
|
-
export declare interface PageContext {
|
|
135
|
-
/**
|
|
136
|
-
* Index of the section to which this page belongs
|
|
137
|
-
*/
|
|
138
|
-
sectionId: string;
|
|
139
|
-
/**
|
|
140
|
-
* Index of this page within its section.
|
|
141
|
-
*/
|
|
142
|
-
pageIndex: number;
|
|
143
|
-
/**
|
|
144
|
-
* Total number of pages in the section that contains this page.
|
|
145
|
-
*/
|
|
146
|
-
totalPages: number;
|
|
147
|
-
/**
|
|
148
|
-
* HTML string representing the paginated content of this page.
|
|
149
|
-
*/
|
|
150
|
-
pageContentHtml: string;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
declare class PageElement {
|
|
154
|
-
private readonly _node;
|
|
155
|
-
config: PaginationOptions;
|
|
156
|
-
readonly type: 'element';
|
|
157
|
-
readonly transaction: Transaction;
|
|
158
|
-
readonly clonedFrom?: PageElement;
|
|
159
|
-
readonly cloneCount: number;
|
|
160
|
-
constructor(element: Element, transaction: Transaction, config: PaginationOptions, clonedFrom?: PageElement);
|
|
161
|
-
getOriginalNode(): Node | undefined;
|
|
162
|
-
appendChild(node: PageNode): void;
|
|
163
|
-
clone(withChildren?: boolean): PageElement;
|
|
164
|
-
getHeight(): number;
|
|
165
|
-
remove(): void;
|
|
166
|
-
isEmpty(): boolean;
|
|
167
|
-
getChildrenCount(): number;
|
|
168
|
-
getNode(): SafeElement;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
declare class PageManager {
|
|
172
|
-
private _pageState;
|
|
173
|
-
private readonly _transaction;
|
|
174
|
-
private readonly _tempContainer;
|
|
175
|
-
private readonly _config;
|
|
176
|
-
constructor(tempContainer: Element, pageSize: RealizedPageSize, transaction: Transaction, config: PaginationOptions);
|
|
177
|
-
nextPage(): void;
|
|
178
|
-
private cloneParentStackToNewPage;
|
|
179
|
-
private cleanupEmptyParent;
|
|
180
|
-
enterElement(): void;
|
|
181
|
-
leaveElement(): void;
|
|
182
|
-
private static createPageHtmlElement;
|
|
183
|
-
private createNewPage;
|
|
184
|
-
startTransaction(): {
|
|
185
|
-
rollback: () => void;
|
|
186
|
-
commit: () => void;
|
|
187
|
-
};
|
|
188
|
-
hasEmptySpace(elementHeight?: number): boolean;
|
|
189
|
-
isOverFlow(): boolean;
|
|
190
|
-
markPageAsFull(): void;
|
|
191
|
-
appendChild(node: PageElement, withChildren: boolean): PageElement;
|
|
192
|
-
addTextNode(text: string): PageText;
|
|
193
|
-
getPageState(): PageState;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Represents the margin sizes for a page.
|
|
198
|
-
* All values should be valid CSS size strings (e.g., '10mm', '1in').
|
|
199
|
-
*
|
|
200
|
-
* Common presets are available in {@link pageMargin}
|
|
201
|
-
*/
|
|
202
|
-
export declare interface PageMargin {
|
|
203
|
-
/** @public */
|
|
204
|
-
top: string;
|
|
205
|
-
/** @public */
|
|
206
|
-
right: string;
|
|
207
|
-
/** @public */
|
|
208
|
-
bottom: string;
|
|
209
|
-
/** @public */
|
|
210
|
-
left: string;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Predefined values for commonly used {@link PageMargin}
|
|
215
|
-
* @privateRemarks
|
|
216
|
-
* Type casting is only for cleaner TypeDoc output
|
|
217
|
-
*/
|
|
218
|
-
export declare const pageMargin: {
|
|
219
|
-
/** Top, Right, Bottom, Left: 1in */
|
|
220
|
-
readonly Normal: PageMargin;
|
|
221
|
-
/** Top: 0.4in, Right, Bottom, Left: 0.6in */
|
|
222
|
-
readonly Narrow: PageMargin;
|
|
223
|
-
/** Top, Bottom: 0.5in, Right, Left: 2in */
|
|
224
|
-
readonly Wide: PageMargin;
|
|
225
|
-
/** Top, Right, Bottom, Left: 0 */
|
|
226
|
-
readonly None: PageMargin;
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
declare type PageNode = PageElement | PageText;
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Describes the page orientation.
|
|
233
|
-
*
|
|
234
|
-
* - 'portrait' (default): the page is taller than it is wide. Use the provided
|
|
235
|
-
* width and height as-is.
|
|
236
|
-
* - 'landscape': the page is wider than it is tall. When applying landscape,
|
|
237
|
-
* swap the width and height.
|
|
238
|
-
*/
|
|
239
|
-
export declare type PageOrientation = 'portrait' | 'landscape';
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Represents the dimensions of a page.
|
|
243
|
-
* All values should be valid CSS size strings (e.g., '210mm', '8.5in').
|
|
244
|
-
*
|
|
245
|
-
* Common presets are available in {@link pageSize}
|
|
246
|
-
*/
|
|
247
|
-
export declare interface PageSize {
|
|
248
|
-
/** @public */
|
|
249
|
-
height: string;
|
|
250
|
-
/** @public */
|
|
251
|
-
width: string;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Predefined values for commonly used {@link PageSize}
|
|
256
|
-
* @privateRemarks
|
|
257
|
-
* Type casting is only for cleaner TypeDoc output
|
|
258
|
-
*/
|
|
259
|
-
export declare const pageSize: {
|
|
260
|
-
/** 841mm x 594mm */
|
|
261
|
-
readonly A1: PageSize;
|
|
262
|
-
/** 594mm x 420mm */
|
|
263
|
-
readonly A2: PageSize;
|
|
264
|
-
/** 420mm x 297mm */
|
|
265
|
-
readonly A3: PageSize;
|
|
266
|
-
/** 297mm x 210mm */
|
|
267
|
-
readonly A4: PageSize;
|
|
268
|
-
/** 210mm x 148mm */
|
|
269
|
-
readonly A5: PageSize;
|
|
270
|
-
/** 148mm x 105mm */
|
|
271
|
-
readonly A6: PageSize;
|
|
272
|
-
/** 500mm x 353mm */
|
|
273
|
-
readonly B3: PageSize;
|
|
274
|
-
/** 353mm x 250mm */
|
|
275
|
-
readonly B4: PageSize;
|
|
276
|
-
/** 250mm x 176mm */
|
|
277
|
-
readonly B5: PageSize;
|
|
278
|
-
/** 8.5in x 11in */
|
|
279
|
-
readonly Letter: PageSize;
|
|
280
|
-
/** 11in x 8.5in */
|
|
281
|
-
readonly Legal: PageSize;
|
|
282
|
-
/** 11in x 17in */
|
|
283
|
-
readonly Tabloid: PageSize;
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
declare class PageState {
|
|
287
|
-
currentPage: PageElement;
|
|
288
|
-
activeElement: PageNode | null;
|
|
289
|
-
currentElement: PageElement;
|
|
290
|
-
parentStack: PageElement[];
|
|
291
|
-
pageIsFull: boolean;
|
|
292
|
-
pageIndex: number;
|
|
293
|
-
pageHeight: number;
|
|
294
|
-
constructor(currentPage: PageElement, activeElement: PageNode | null, currentElement: PageElement, parentStack: PageElement[], pageIsFull: boolean, pageIndex: number, pageHeight: number);
|
|
295
|
-
static create(currentPage: PageElement, parentStack: PageElement[], pageIndex: number, pageHeight: number): PageState;
|
|
296
|
-
clone: () => PageState;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
declare class PageText {
|
|
300
|
-
private readonly _node;
|
|
301
|
-
readonly type: 'text';
|
|
302
|
-
readonly transaction: Transaction;
|
|
303
|
-
config: PaginationOptions;
|
|
304
|
-
constructor(text: Text, transaction: Transaction, config: PaginationOptions);
|
|
305
|
-
get textContent(): string;
|
|
306
|
-
set textContent(value: string);
|
|
307
|
-
remove(): void;
|
|
308
|
-
getNode(): SafeText;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
export declare type PaginateResult = string[];
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Context information for pagination cycle.
|
|
315
|
-
*/
|
|
316
|
-
export declare interface PaginationCycleCompleted {
|
|
317
|
-
/**
|
|
318
|
-
* All paginated section within the report.
|
|
319
|
-
*/
|
|
320
|
-
sections: SectionContext[];
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Pagination options
|
|
325
|
-
* @interface
|
|
326
|
-
* @inlineType LayoutOptions
|
|
327
|
-
*/
|
|
328
|
-
export declare type PaginationOptions = Required<LayoutOptions> & {
|
|
329
|
-
/**
|
|
330
|
-
* Unique id of the pagination.
|
|
331
|
-
*/
|
|
332
|
-
id: string;
|
|
333
|
-
/**
|
|
334
|
-
* List of plugins to use during pagination.
|
|
335
|
-
*/
|
|
336
|
-
plugins: PaginationPlugin[];
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
export declare interface PaginationPlugin {
|
|
340
|
-
readonly name: string;
|
|
341
|
-
readonly order: number;
|
|
342
|
-
onVisitText?: (id: string, domState: DomState & {
|
|
343
|
-
currentNode: PageText;
|
|
344
|
-
}, pageManager: PageManager, context: VisitContext) => void;
|
|
345
|
-
onVisitElement?: (id: string, domState: DomState & {
|
|
346
|
-
currentNode: PageElement;
|
|
347
|
-
}, pageManager: PageManager, context: VisitContext) => void;
|
|
348
|
-
afterVisitNode?: (id: string, result: SplitResult, domState: DomState, pageManager: PageManager) => void;
|
|
349
|
-
onNewPage?: (id: string, pageManager: PageManager) => void;
|
|
350
|
-
onClone?: (id: string, source: Element, cloned: PageElement) => void;
|
|
351
|
-
afterPagination?: (id: string, domState: DomState, pageManager: PageManager) => void;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
export declare class Paginator {
|
|
355
|
-
private readonly _domState;
|
|
356
|
-
private readonly _pageManager;
|
|
357
|
-
private readonly _transaction;
|
|
358
|
-
private readonly _tempContainer;
|
|
359
|
-
private readonly _config;
|
|
360
|
-
private constructor();
|
|
361
|
-
private static createTempContainer;
|
|
362
|
-
static paginate(root: Element, pageSize: RealizedPageSize, config?: Partial<PaginationOptions>): PaginateResult;
|
|
363
|
-
private processAllNodes;
|
|
364
|
-
private handleNodeSkipped;
|
|
365
|
-
private handleFullNodePlaced;
|
|
366
|
-
private handleChildrenSplit;
|
|
367
|
-
private processCurrentNode;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
export declare const paprize_isInitialized = "__PAPRIZE_IS_INITIALIZED";
|
|
371
|
-
|
|
372
|
-
export declare const paprize_isReady = "__PAPRIZE_IS_READY";
|
|
373
|
-
|
|
374
|
-
export declare const paprize_readJsonDataFile = "__PAPRIZE_READ_JSON_DATA_FILE";
|
|
375
|
-
|
|
376
|
-
declare type PluginHookNames = NonNullable<PluginKeys>;
|
|
377
|
-
|
|
378
|
-
declare type PluginKeys = {
|
|
379
|
-
[K in keyof PaginationPlugin]: PaginationPlugin[K] extends ((...args: never[]) => unknown) | undefined ? K : never;
|
|
380
|
-
}[keyof PaginationPlugin];
|
|
381
|
-
|
|
382
|
-
export declare const previewClassName = "pz-preview";
|
|
383
|
-
|
|
384
|
-
export declare interface RealizedPageSize {
|
|
385
|
-
width: number;
|
|
386
|
-
height: number;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* The report builder class that contains the logic for handling pagination
|
|
391
|
-
* and managing the report layout.
|
|
392
|
-
*/
|
|
393
|
-
export declare class ReportBuilder {
|
|
394
|
-
private readonly _sections;
|
|
395
|
-
private readonly _monitor;
|
|
396
|
-
private _paginationInProgress;
|
|
397
|
-
private _pendingPaginateResolvers;
|
|
398
|
-
private _currentAbortController;
|
|
399
|
-
constructor();
|
|
400
|
-
/**
|
|
401
|
-
* Monitor instance used to subscribe to pagination events.
|
|
402
|
-
* See {@link ReportBuilderEvents} for available event types.
|
|
403
|
-
*/
|
|
404
|
-
get monitor(): Monitor<ReportBuilderEvents>;
|
|
405
|
-
/**
|
|
406
|
-
* Removes a section from the registered sections, if it has already been registered in the report.
|
|
407
|
-
*/
|
|
408
|
-
removeSection(sectionId: string): void;
|
|
409
|
-
/**
|
|
410
|
-
* Registers a section by its ID, specifying the page size, margins, and other options.
|
|
411
|
-
*
|
|
412
|
-
* @param options - Configuration options for the section.
|
|
413
|
-
* @param components - The DOM components associated with the section.
|
|
414
|
-
* @param onPaginationCompleted - Callback invoked when pagination for the section is completed.
|
|
415
|
-
* @returns `true` if the section was added to the report’s section list, or `false` if it already exists.
|
|
416
|
-
*/
|
|
417
|
-
tryAddSection(options: SectionOptions, components: SectionComponents, onPaginationCompleted: SectionState['onPaginationCompleted']): Promise<boolean>;
|
|
418
|
-
/**
|
|
419
|
-
* Schedules a pagination operation.
|
|
420
|
-
*
|
|
421
|
-
* It is not possible to schedule multiple pagination operations in parallel,
|
|
422
|
-
* as the process involves DOM manipulation, and concurrent modifications
|
|
423
|
-
* could cause conflicts and unexpected results.
|
|
424
|
-
* Each newly scheduled operation is queued and executed sequentially.
|
|
425
|
-
* When a new pagination is scheduled, any ongoing or pending operations
|
|
426
|
-
* will be aborted, and the new pagination will start immediately afterward.
|
|
427
|
-
*
|
|
428
|
-
* @returns A promise that resolves when the first pagination cycle is completed.
|
|
429
|
-
* It does not wait for suspended sections to resolve and be paginated.
|
|
430
|
-
* To wait for all sections to complete pagination, use the
|
|
431
|
-
* `suspension` property of the returned result object.
|
|
432
|
-
*/
|
|
433
|
-
schedulePagination(): Promise<ScheduleResult>;
|
|
434
|
-
/**
|
|
435
|
-
* Retrieves JSON data injected by **@paprize/puppeteer** during server-side rendering (SSR).
|
|
436
|
-
*
|
|
437
|
-
* If no injected data is available, the function returns the provided `defaultData`, or `null` if none is given.
|
|
438
|
-
*
|
|
439
|
-
* ⚠️ **Important Notes:**
|
|
440
|
-
* - This function is **not type-safe** — it performs **no runtime type validation** on the returned data.
|
|
441
|
-
* - It is available **only during server-side rendering** when using **@paprize/puppeteer**.
|
|
442
|
-
* - When used in **client-side rendering** or **development** mode, you should provide a `defaultData` value for testing purposes.
|
|
443
|
-
*
|
|
444
|
-
* @template T - The expected type of the injected JSON data.
|
|
445
|
-
* @param defaultData - Optional fallback value to return if no injected data is found.
|
|
446
|
-
* @returns A promise resolving to the injected JSON data if available, otherwise the provided default value or `null`.
|
|
447
|
-
*/
|
|
448
|
-
getJsonData<T>(defaultData?: T): Promise<T | null>;
|
|
449
|
-
private _lazyJsonDataReader;
|
|
450
|
-
private _executePagination;
|
|
451
|
-
private _processPendingPagination;
|
|
452
|
-
private _injectStyle;
|
|
453
|
-
private _paginateSection;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* Available events that can be subscribed to, during the pagination process.
|
|
458
|
-
*/
|
|
459
|
-
export declare interface ReportBuilderEvents {
|
|
460
|
-
/**
|
|
461
|
-
* Triggered when a page has been fully paginated.
|
|
462
|
-
* event: {@link PageContext}
|
|
463
|
-
*/
|
|
464
|
-
pageCompleted: (event: PageContext) => void;
|
|
465
|
-
/**
|
|
466
|
-
* Triggered when a section has been fully paginated.
|
|
467
|
-
* event: {@link SectionContext}
|
|
468
|
-
*/
|
|
469
|
-
sectionCompleted: (event: SectionContext) => void;
|
|
470
|
-
/**
|
|
471
|
-
* Triggered when a new section is created.
|
|
472
|
-
* event: {@link SectionContext}
|
|
473
|
-
*/
|
|
474
|
-
sectionCreated: (event: SectionContext) => void;
|
|
475
|
-
/**
|
|
476
|
-
* Triggered when an entire pagination cycle is completed.
|
|
477
|
-
* event: {@link PaginationCycleCompleted}
|
|
478
|
-
*/
|
|
479
|
-
paginationCycleCompleted: (event: PaginationCycleCompleted) => void;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
export declare const reportStyles: {
|
|
483
|
-
globalStyle: string;
|
|
484
|
-
component: CSSProperties;
|
|
485
|
-
outOfScreen: CSSProperties;
|
|
486
|
-
page: (pageSize: PageSize, pageMargin: PageMargin) => CSSProperties;
|
|
487
|
-
overlay: CSSProperties;
|
|
488
|
-
pageContent: CSSProperties;
|
|
489
|
-
sectionPageMedia: typeof sectionPageMedia;
|
|
490
|
-
section: (sectionId: string) => CSSProperties;
|
|
491
|
-
};
|
|
492
|
-
|
|
493
|
-
declare type SafeElement = Omit<Element, 'removeChild' | 'appendChild' | 'replaceChild' | 'remove'>;
|
|
494
|
-
|
|
495
|
-
declare type SafeText = Omit<Text, 'remove'>;
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* Represents the result of a scheduled pagination process.
|
|
499
|
-
*/
|
|
500
|
-
export declare interface ScheduleResult {
|
|
501
|
-
/**
|
|
502
|
-
* List of all registered sections.
|
|
503
|
-
*/
|
|
504
|
-
sections: SectionContext[];
|
|
505
|
-
/**
|
|
506
|
-
* If there are any suspended sections, this Promise tracks their state
|
|
507
|
-
* and resolves only after all suspended sections have been resumed
|
|
508
|
-
* and paginated.
|
|
509
|
-
*/
|
|
510
|
-
suspension: Promise<void>;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
export declare const sectionClassName = "pz-section";
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* Represents the collection of DOM elements generated by
|
|
517
|
-
* the pagination engine from the report components on the current page.
|
|
518
|
-
*/
|
|
519
|
-
export declare interface SectionComponents {
|
|
520
|
-
/**
|
|
521
|
-
* The HTML element that serves as the header for the entire section.
|
|
522
|
-
* `null` if the section has no section header.
|
|
523
|
-
*/
|
|
524
|
-
sectionHeader: HTMLElement | null;
|
|
525
|
-
/**
|
|
526
|
-
* The HTML element that serves as the footer for the entire section.
|
|
527
|
-
* `null` if the section has no section footer.
|
|
528
|
-
*/
|
|
529
|
-
sectionFooter: HTMLElement | null;
|
|
530
|
-
/**
|
|
531
|
-
* The HTML element that serves as the header for this page.
|
|
532
|
-
* `null` if the page has no header.
|
|
533
|
-
*/
|
|
534
|
-
pageHeader: HTMLElement | null;
|
|
535
|
-
/**
|
|
536
|
-
* The HTML element that serves as the footer for this page.
|
|
537
|
-
* `null` if the page has no footer.
|
|
538
|
-
*/
|
|
539
|
-
pageFooter: HTMLElement | null;
|
|
540
|
-
/**
|
|
541
|
-
* The main HTML element for the this page content
|
|
542
|
-
* This property is always defined.
|
|
543
|
-
*/
|
|
544
|
-
pageContent: HTMLElement;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
* Context information for a paginated section.
|
|
549
|
-
*/
|
|
550
|
-
export declare interface SectionContext {
|
|
551
|
-
/**
|
|
552
|
-
* Index of the section within the report.
|
|
553
|
-
*/
|
|
554
|
-
sectionIndex: number;
|
|
555
|
-
/**
|
|
556
|
-
* Unique identifier of the section.
|
|
557
|
-
*/
|
|
558
|
-
sectionId: string;
|
|
559
|
-
/**
|
|
560
|
-
* Indicates whether pagination for this section is suspended
|
|
561
|
-
* and waiting for the suspension to be resolved.
|
|
562
|
-
*/
|
|
563
|
-
isSuspended: boolean;
|
|
564
|
-
/**
|
|
565
|
-
* Indicates whether pagination for this section has completed.
|
|
566
|
-
*/
|
|
567
|
-
isPaginated: boolean;
|
|
568
|
-
/**
|
|
569
|
-
* All paginated pages that belong to this section.
|
|
570
|
-
*/
|
|
571
|
-
pages: PageContext[];
|
|
572
|
-
/**
|
|
573
|
-
* Options used for paginating this section.
|
|
574
|
-
*
|
|
575
|
-
* @remarks
|
|
576
|
-
* Options may differ from the original {@link SectionOptions}
|
|
577
|
-
* provided during section creation, as some values may be
|
|
578
|
-
*/
|
|
579
|
-
options: SectionOptions;
|
|
580
|
-
/**
|
|
581
|
-
* Components used in this section.
|
|
582
|
-
*/
|
|
583
|
-
components: SectionComponents;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
* Configuration options for a section.
|
|
588
|
-
* @inlineType PaginationConfig
|
|
589
|
-
*/
|
|
590
|
-
export declare interface SectionOptions extends Partial<Omit<PaginationOptions, 'id'>> {
|
|
591
|
-
/**
|
|
592
|
-
* Unique id of the section within the report.
|
|
593
|
-
*/
|
|
594
|
-
readonly id: string;
|
|
595
|
-
/**
|
|
596
|
-
* Page size used for this section.
|
|
597
|
-
*/
|
|
598
|
-
readonly size: PageSize;
|
|
599
|
-
/**
|
|
600
|
-
* Page orientation used for this section.
|
|
601
|
-
* @inlineType PageOrientation
|
|
602
|
-
* @default portrait
|
|
603
|
-
*/
|
|
604
|
-
readonly orientation?: PageOrientation;
|
|
605
|
-
/**
|
|
606
|
-
* Page margins for this section.
|
|
607
|
-
*/
|
|
608
|
-
readonly margin?: PageMargin;
|
|
609
|
-
/**
|
|
610
|
-
* A list of promises that must be resolved before the section can be paginated.
|
|
611
|
-
*/
|
|
612
|
-
readonly suspense?: Promise<unknown>[];
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
declare function sectionPageMedia(sectionId: string, size: PageSize): string;
|
|
616
|
-
|
|
617
|
-
export declare interface SectionState {
|
|
618
|
-
context: SectionContext;
|
|
619
|
-
onPaginationCompleted: (context: SectionContext) => Promise<unknown> | void;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
export declare const sectionTocName = "sectionToc";
|
|
623
|
-
|
|
624
|
-
export declare class SectionTocPlugin implements PaginationPlugin {
|
|
625
|
-
readonly name = "sectionToc";
|
|
626
|
-
readonly order = 1;
|
|
627
|
-
private _state;
|
|
628
|
-
getContentList: () => SectionTocState[];
|
|
629
|
-
onVisitElement: (id: string, domState: DomState & {
|
|
630
|
-
currentNode: PageElement;
|
|
631
|
-
}, pageManager: PageManager) => void;
|
|
632
|
-
getHeadingLevel(node: SafeElement): number | null;
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
export declare type SectionTocState = {
|
|
636
|
-
sectionId: string;
|
|
637
|
-
pageIndex: number;
|
|
638
|
-
title: string;
|
|
639
|
-
level: number;
|
|
640
|
-
};
|
|
641
|
-
|
|
642
|
-
export declare const SplitResult: {
|
|
643
|
-
readonly None: 0;
|
|
644
|
-
readonly FullNodePlaced: 1;
|
|
645
|
-
readonly SplitChildren: 2;
|
|
646
|
-
};
|
|
647
|
-
|
|
648
|
-
export declare type SplitResult = (typeof SplitResult)[keyof typeof SplitResult];
|
|
649
|
-
|
|
650
|
-
export declare class TablePlugin implements PaginationPlugin {
|
|
651
|
-
private readonly _options;
|
|
652
|
-
name: string;
|
|
653
|
-
order: number;
|
|
654
|
-
constructor(options?: TablePluginOptions);
|
|
655
|
-
onNewPage: (_id: string, pageManager: PageManager) => void;
|
|
656
|
-
onVisitElement: (_id: string, domState: DomState & {
|
|
657
|
-
currentNode: PageElement;
|
|
658
|
-
}, _pageManager: PageManager, context: VisitContext) => void;
|
|
659
|
-
onClone: (_id: string, source: Element, cloned: PageElement) => void;
|
|
660
|
-
private _isTable;
|
|
661
|
-
private _isTableBodyEmpty;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
/**
|
|
665
|
-
* Table plugin options
|
|
666
|
-
*/
|
|
667
|
-
export declare interface TablePluginOptions {
|
|
668
|
-
/**
|
|
669
|
-
* If true, the table header (thead) will be cloned on each page.
|
|
670
|
-
*/
|
|
671
|
-
cloneHeader?: boolean;
|
|
672
|
-
/**
|
|
673
|
-
* If true, the table footer (tfoot) will be cloned on each page.
|
|
674
|
-
*/
|
|
675
|
-
cloneFooter?: boolean;
|
|
676
|
-
/**
|
|
677
|
-
* When true, tables containing only a header (no body rows) will not be removed.
|
|
678
|
-
*/
|
|
679
|
-
includeHeaderOnlyTables?: boolean;
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
export declare const tempContainerClassName = "pz-temp-container";
|
|
683
|
-
|
|
684
|
-
declare class Transaction {
|
|
685
|
-
private _onRollback;
|
|
686
|
-
private _onCommit;
|
|
687
|
-
isActive: boolean;
|
|
688
|
-
constructor();
|
|
689
|
-
start: () => void;
|
|
690
|
-
addRollbackCallback: (callback: () => void) => void;
|
|
691
|
-
addCommitCallback: (callback: () => void) => void;
|
|
692
|
-
rollback: () => void;
|
|
693
|
-
commit: () => void;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
export declare interface VisitContext {
|
|
697
|
-
result?: SplitResult;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
1
|
export { }
|
|
701
2
|
|
|
702
3
|
|