ats-form-react-pdf-renderer 4.3.2

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.
@@ -0,0 +1,692 @@
1
+ /* eslint-disable max-classes-per-file */
2
+
3
+ import * as React from 'react';
4
+ import {
5
+ Style,
6
+ PageSize,
7
+ FontStore,
8
+ PDFVersion,
9
+ Orientation,
10
+ SourceObject,
11
+ HyphenationCallback,
12
+ SVGPresentationAttributes,
13
+ Bookmark,
14
+ PageLayout,
15
+ PageMode,
16
+ } from '@react-pdf/types';
17
+
18
+ declare class ReactPDF {
19
+ static default: typeof ReactPDF;
20
+ }
21
+
22
+ export = ReactPDF;
23
+
24
+ declare namespace ReactPDF {
25
+ interface Styles {
26
+ [key: string]: Style;
27
+ }
28
+ interface OnRenderProps {
29
+ blob?: Blob;
30
+ }
31
+
32
+ interface DocumentProps {
33
+ style?: Style | Style[];
34
+ title?: string;
35
+ author?: string;
36
+ subject?: string;
37
+ creator?: string;
38
+ keywords?: string;
39
+ producer?: string;
40
+ language?: string;
41
+ creationDate?: Date;
42
+ modificationDate?: Date;
43
+ pdfVersion?: PDFVersion;
44
+ pageMode?: PageMode;
45
+ pageLayout?: PageLayout;
46
+ onRender?: (props: OnRenderProps) => any;
47
+ }
48
+
49
+ /**
50
+ * This component represent the PDF document itself. It must be the root
51
+ * of your tree element structure, and under no circumstances should it be
52
+ * used as children of another react-pdf component. In addition, it should
53
+ * only have childs of type <Page />.
54
+ */
55
+ export class Document extends React.Component<
56
+ React.PropsWithChildren<DocumentProps>
57
+ > {}
58
+
59
+ interface NodeProps {
60
+ id?: string;
61
+ style?: Style | Style[];
62
+ /**
63
+ * Render component in all wrapped pages.
64
+ * @see https://react-pdf.org/advanced#fixed-components
65
+ */
66
+ fixed?: boolean;
67
+ /**
68
+ * Force the wrapping algorithm to start a new page when rendering the
69
+ * element.
70
+ * @see https://react-pdf.org/advanced#page-breaks
71
+ */
72
+ break?: boolean;
73
+ /**
74
+ * Hint that no page wrapping should occur between all sibling elements following the element within n points
75
+ * @see https://react-pdf.org/advanced#orphan-&-widow-protection
76
+ */
77
+ minPresenceAhead?: number;
78
+ }
79
+
80
+ interface PageProps extends NodeProps {
81
+ /**
82
+ * Enable page wrapping for this page.
83
+ * @see https://react-pdf.org/components#page-wrapping
84
+ */
85
+ wrap?: boolean;
86
+ /**
87
+ * Enables debug mode on page bounding box.
88
+ * @see https://react-pdf.org/advanced#debugging
89
+ */
90
+ debug?: boolean;
91
+ size?: PageSize;
92
+ orientation?: Orientation;
93
+ dpi?: number;
94
+ bookmark?: Bookmark;
95
+ }
96
+
97
+ /**
98
+ * Represents single page inside the PDF document, or a subset of them if
99
+ * using the wrapping feature. A <Document /> can contain as many pages as
100
+ * you want, but ensure not rendering a page inside any component besides
101
+ * Document.
102
+ */
103
+ export class Page extends React.Component<
104
+ React.PropsWithChildren<PageProps>
105
+ > {}
106
+
107
+ interface ViewProps extends NodeProps {
108
+ id?: string;
109
+ /**
110
+ * Enable/disable page wrapping for element.
111
+ * @see https://react-pdf.org/components#page-wrapping
112
+ */
113
+ wrap?: boolean;
114
+ /**
115
+ * Enables debug mode on page bounding box.
116
+ * @see https://react-pdf.org/advanced#debugging
117
+ */
118
+ debug?: boolean;
119
+ render?: (props: {
120
+ pageNumber: number;
121
+ subPageNumber: number;
122
+ }) => React.ReactNode;
123
+ }
124
+
125
+ /**
126
+ * The most fundamental component for building a UI and is designed to be
127
+ * nested inside other views and can have 0 to many children.
128
+ */
129
+ export class View extends React.Component<
130
+ React.PropsWithChildren<ViewProps>
131
+ > {}
132
+
133
+ interface BaseImageProps extends NodeProps {
134
+ /**
135
+ * Enables debug mode on page bounding box.
136
+ * @see https://react-pdf.org/advanced#debugging
137
+ */
138
+ debug?: boolean;
139
+ cache?: boolean;
140
+ }
141
+
142
+ interface ImageWithSrcProp extends BaseImageProps {
143
+ src: SourceObject;
144
+ }
145
+
146
+ interface ImageWithSourceProp extends BaseImageProps {
147
+ source: SourceObject;
148
+ }
149
+
150
+ type ImageProps = ImageWithSrcProp | ImageWithSourceProp;
151
+
152
+ /**
153
+ * A React component for displaying network or local (Node only) JPG or
154
+ * PNG images, as well as base64 encoded image strings.
155
+ */
156
+ export class Image extends React.Component<ImageProps> {}
157
+
158
+ interface TextProps extends NodeProps {
159
+ id?: string;
160
+ /**
161
+ * Enable/disable page wrapping for element.
162
+ * @see https://react-pdf.org/components#page-wrapping
163
+ */
164
+ wrap?: boolean;
165
+ /**
166
+ * Enables debug mode on page bounding box.
167
+ * @see https://react-pdf.org/advanced#debugging
168
+ */
169
+ debug?: boolean;
170
+ render?: (props: {
171
+ pageNumber: number;
172
+ totalPages: number;
173
+ subPageNumber: number;
174
+ subPageTotalPages: number;
175
+ }) => React.ReactNode;
176
+ /**
177
+ * Override the default hyphenation-callback
178
+ * @see https://react-pdf.org/fonts#registerhyphenationcallback
179
+ */
180
+ hyphenationCallback?: HyphenationCallback;
181
+ /**
182
+ * Specifies the minimum number of lines in a text element that must be shown at the bottom of a page or its container.
183
+ * @see https://react-pdf.org/advanced#orphan-&-widow-protection
184
+ */
185
+ orphans?: number;
186
+ /**
187
+ * Specifies the minimum number of lines in a text element that must be shown at the top of a page or its container..
188
+ * @see https://react-pdf.org/advanced#orphan-&-widow-protection
189
+ */
190
+ widows?: number;
191
+ }
192
+
193
+ interface SVGTextProps extends SVGPresentationAttributes {
194
+ style?: SVGPresentationAttributes;
195
+ x: string | number;
196
+ y: string | number;
197
+ /**
198
+ * Override the default hyphenation-callback
199
+ * @see https://react-pdf.org/fonts#registerhyphenationcallback
200
+ */
201
+ hyphenationCallback?: HyphenationCallback;
202
+ }
203
+
204
+ /**
205
+ * A React component for displaying text. Text supports nesting of other
206
+ * Text or Link components to create inline styling.
207
+ */
208
+ export class Text extends React.Component<
209
+ React.PropsWithChildren<TextProps> | SVGTextProps
210
+ > {}
211
+
212
+ interface LinkProps extends NodeProps {
213
+ /**
214
+ * Enable/disable page wrapping for element.
215
+ * @see https://react-pdf.org/components#page-wrapping
216
+ */
217
+ wrap?: boolean;
218
+ /**
219
+ * Enables debug mode on page bounding box.
220
+ * @see https://react-pdf.org/advanced#debugging
221
+ */
222
+ debug?: boolean;
223
+ href?: string;
224
+ src?: string;
225
+ }
226
+
227
+ /**
228
+ * A React component for displaying a hyperlink. Link’s can be nested
229
+ * inside a Text component, or being inside any other valid primitive.
230
+ */
231
+ export class Link extends React.Component<
232
+ React.PropsWithChildren<LinkProps>
233
+ > {}
234
+
235
+ interface FormCommonProps extends NodeProps {
236
+ name?: string;
237
+ required?: boolean;
238
+ noExport?: boolean;
239
+ readOnly?: boolean;
240
+ value?: number | string;
241
+ defaultValue?: number | string;
242
+ }
243
+
244
+ interface FieldSetProps extends NodeProps {
245
+ name: string;
246
+ }
247
+
248
+ export class FieldSet extends React.Component<
249
+ React.PropsWithChildren<FieldSetProps>
250
+ > {}
251
+
252
+ // see http://pdfkit.org/docs/forms.html#text_field_formatting
253
+ interface TextInputFormatting {
254
+ type:
255
+ | 'date'
256
+ | 'time'
257
+ | 'percent'
258
+ | 'number'
259
+ | 'zip'
260
+ | 'zipPlus4'
261
+ | 'phone'
262
+ | 'ssn';
263
+ param?: string;
264
+ nDec?: number;
265
+ sepComma?: boolean;
266
+ negStyle?: 'MinusBlack' | 'Red' | 'ParensBlack' | 'ParensRed';
267
+ currency?: string;
268
+ currencyPrepend?: boolean;
269
+ }
270
+
271
+ // see http://pdfkit.org/docs/forms.html#text_field_formatting
272
+ interface TextInputProps extends FormCommonProps {
273
+ align?: 'left' | 'center' | 'right';
274
+ multiline?: boolean;
275
+ /**
276
+ * The text will be masked (e.g. with asterisks).
277
+ */
278
+ password?: boolean;
279
+ /**
280
+ * If set, text entered in the field is not spell-checked
281
+ */
282
+ noSpell?: boolean;
283
+ format?: TextInputFormatting;
284
+ /**
285
+ * Sets the fontSize (default or 0 means auto sizing)
286
+ */
287
+ fontSize?: number;
288
+ /**
289
+ * Sets the maximum length (characters) of the text in the field
290
+ */
291
+ maxLength?: number;
292
+ }
293
+
294
+ export class TextInput extends React.Component<TextInputProps> {}
295
+
296
+ interface CheckboxProps extends FormCommonProps {
297
+ backgroundColor?: string;
298
+ borderColor?: string;
299
+ checked?: boolean;
300
+ onState?: string;
301
+ offState?: string;
302
+ xMark?: boolean;
303
+ }
304
+
305
+ export class Checkbox extends React.Component<CheckboxProps> {}
306
+
307
+ interface SelectAndListPropsBase extends FormCommonProps {
308
+ sort?: boolean;
309
+ edit?: boolean;
310
+ multiSelect?: boolean;
311
+ noSpell?: boolean;
312
+ select?: string[];
313
+ }
314
+
315
+ type SelectAndListPropsWithEdit = SelectAndListPropsBase & {
316
+ edit: true | false;
317
+ noSpell: boolean;
318
+ };
319
+
320
+ type SelectAndListPropsWithNoSpell = SelectAndListPropsBase & {
321
+ edit: boolean;
322
+ noSpell: true | false;
323
+ };
324
+
325
+ type SelectAndListProps =
326
+ | SelectAndListPropsWithEdit
327
+ | SelectAndListPropsWithNoSpell;
328
+
329
+ export class Select extends React.Component<SelectAndListProps> {}
330
+
331
+ export class List extends React.Component<SelectAndListProps> {}
332
+
333
+ interface NoteProps extends NodeProps {
334
+ children: string;
335
+ }
336
+
337
+ export class Note extends React.Component<NoteProps> {}
338
+
339
+ interface CanvasProps extends NodeProps {
340
+ /**
341
+ * Enables debug mode on page bounding box.
342
+ * @see https://react-pdf.org/advanced#debugging
343
+ */
344
+ debug?: boolean;
345
+ paint: (
346
+ painter: any,
347
+ availableWidth: number,
348
+ availableHeight: number,
349
+ ) => null;
350
+ }
351
+
352
+ export class Canvas extends React.Component<CanvasProps> {}
353
+
354
+ interface SVGProps extends NodeProps, SVGPresentationAttributes {
355
+ /**
356
+ * Enables debug mode on page bounding box.
357
+ * @see https://react-pdf.org/advanced#debugging
358
+ */
359
+ debug?: boolean;
360
+ width?: string | number;
361
+ height?: string | number;
362
+ viewBox?: string;
363
+ preserveAspectRatio?: string;
364
+ }
365
+
366
+ /**
367
+ * The <SVG /> element is a container that defines a new coordinate system and viewport. It is used as the outermost element of SVG documents.
368
+ */
369
+ export class Svg extends React.Component<React.PropsWithChildren<SVGProps>> {}
370
+
371
+ interface LineProps extends SVGPresentationAttributes {
372
+ style?: SVGPresentationAttributes;
373
+ x1: string | number;
374
+ x2: string | number;
375
+ y1: string | number;
376
+ y2: string | number;
377
+ }
378
+
379
+ /**
380
+ * The <Line /> element is used to create a line.
381
+ */
382
+ export class Line extends React.Component<
383
+ React.PropsWithChildren<LineProps>
384
+ > {}
385
+
386
+ interface PolylineProps extends SVGPresentationAttributes {
387
+ style?: SVGPresentationAttributes;
388
+ points: string;
389
+ }
390
+
391
+ /**
392
+ * The <Polyline /> element is used to create any shape that consists of only straight lines (that is connected at several points).
393
+ */
394
+ export class Polyline extends React.Component<
395
+ React.PropsWithChildren<PolylineProps>
396
+ > {}
397
+
398
+ interface PolygonProps extends SVGPresentationAttributes {
399
+ style?: SVGPresentationAttributes;
400
+ points: string;
401
+ }
402
+
403
+ /**
404
+ * The <Polygon /> element is used to create a graphic that contains at least three sides.
405
+ * Polygons are made of straight lines, and the shape is "closed" (all the lines connect up).
406
+ */
407
+ export class Polygon extends React.Component<
408
+ React.PropsWithChildren<PolygonProps>
409
+ > {}
410
+
411
+ interface PathProps extends SVGPresentationAttributes {
412
+ style?: SVGPresentationAttributes;
413
+ d: string;
414
+ }
415
+
416
+ /**
417
+ * The <Path /> element is the most powerful element in the SVG library of basic shapes. It can be used to create lines, curves, arcs, and more.
418
+ */
419
+ export class Path extends React.Component<
420
+ React.PropsWithChildren<PathProps>
421
+ > {}
422
+
423
+ interface RectProps extends SVGPresentationAttributes {
424
+ style?: SVGPresentationAttributes;
425
+ x?: string | number;
426
+ y?: string | number;
427
+ width: string | number;
428
+ height: string | number;
429
+ rx?: string | number;
430
+ ry?: string | number;
431
+ }
432
+
433
+ /**
434
+ * The <Rect /> element is used to create a rectangle and variations of a rectangle shape.
435
+ */
436
+ export class Rect extends React.Component<
437
+ React.PropsWithChildren<RectProps>
438
+ > {}
439
+
440
+ interface CircleProps extends SVGPresentationAttributes {
441
+ style?: SVGPresentationAttributes;
442
+ cx?: string | number;
443
+ cy?: string | number;
444
+ r: string | number;
445
+ }
446
+
447
+ /**
448
+ * The <Circle /> element is used to create a circle.
449
+ */
450
+ export class Circle extends React.Component<
451
+ React.PropsWithChildren<CircleProps>
452
+ > {}
453
+
454
+ interface EllipseProps extends SVGPresentationAttributes {
455
+ style?: SVGPresentationAttributes;
456
+ cx?: string | number;
457
+ cy?: string | number;
458
+ rx: string | number;
459
+ ry: string | number;
460
+ }
461
+
462
+ /**
463
+ * The <Ellipse /> element is used to create an ellipse.
464
+ * An ellipse is closely related to a circle. The difference is that an ellipse has an x and a y radius that differs from each other, while a circle has equal x and y radius.
465
+ */
466
+ export class Ellipse extends React.Component<
467
+ React.PropsWithChildren<EllipseProps>
468
+ > {}
469
+
470
+ interface TspanProps extends SVGPresentationAttributes {
471
+ x?: string | number;
472
+ y?: string | number;
473
+ }
474
+
475
+ /**
476
+ * The <Tspan /> element defines a subtext within a <Text /> element or another <Tspan /> element.
477
+ * It allows for adjustment of the style and/or position of that subtext as needed.
478
+ */
479
+ export class Tspan extends React.Component<
480
+ React.PropsWithChildren<TspanProps>
481
+ > {}
482
+
483
+ interface GProps extends SVGPresentationAttributes {
484
+ style?: Style;
485
+ }
486
+
487
+ /**
488
+ * The <G /> SVG element is a container used to group other SVG elements.
489
+ * Transformations applied to the <G /> element are performed on its child elements, and its attributes are inherited by its children.
490
+ */
491
+ export class G extends React.Component<React.PropsWithChildren<GProps>> {}
492
+
493
+ interface StopProps {
494
+ offset: string | number;
495
+ stopColor: string;
496
+ stopOpacity?: string | number;
497
+ }
498
+
499
+ /**
500
+ * The SVG <Stop /> element defines a color and its position to use on a gradient. This element is always a child of a <LinearGradient /> or <RadialGradient /> element
501
+ */
502
+ export class Stop extends React.Component<
503
+ React.PropsWithChildren<StopProps>
504
+ > {}
505
+
506
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
507
+ interface DefsProps {}
508
+
509
+ /**
510
+ * The <Defs /> element is used to store graphical objects that will be used at a later time. Objects created inside a <Defs /> element are not rendered directly. To display them you have to reference them
511
+ */
512
+ export class Defs extends React.Component<
513
+ React.PropsWithChildren<DefsProps>
514
+ > {}
515
+
516
+ interface ClipPathProps {
517
+ id?: string;
518
+ }
519
+
520
+ /**
521
+ * The <ClipPath /> SVG element defines a clipping path, to be used by the clipPath property.
522
+ * A clipping path restricts the region to which paint can be applied. Conceptually, parts of the drawing that lie outside of the region bounded by the clipping path are not drawn.
523
+ */
524
+ export class ClipPath extends React.Component<
525
+ React.PropsWithChildren<ClipPathProps>
526
+ > {}
527
+
528
+ interface LinearGradientProps {
529
+ id: string;
530
+ x1?: string | number;
531
+ x2?: string | number;
532
+ y1?: string | number;
533
+ y2?: string | number;
534
+ xlinkHref?: string;
535
+ gradientTransform?: string;
536
+ gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox';
537
+ }
538
+
539
+ /**
540
+ * The <LinearGradient /> element lets authors define linear gradients that can be applied to fill or stroke of graphical elements.
541
+ */
542
+ export class LinearGradient extends React.Component<
543
+ React.PropsWithChildren<LinearGradientProps>
544
+ > {}
545
+
546
+ interface RadialGradientProps {
547
+ id: string;
548
+ cx?: string | number;
549
+ cy?: string | number;
550
+ r?: string | number;
551
+ fx?: string | number;
552
+ fy?: string | number;
553
+ xlinkHref?: string;
554
+ gradientTransform?: string;
555
+ gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox';
556
+ }
557
+
558
+ /**
559
+ * The <RadialGradient /> element lets authors define radial gradients that can be applied to fill or stroke of graphical elements.
560
+ */
561
+ export class RadialGradient extends React.Component<
562
+ React.PropsWithChildren<RadialGradientProps>
563
+ > {}
564
+
565
+ interface BlobProviderParams {
566
+ blob: Blob | null;
567
+ url: string | null;
568
+ loading: boolean;
569
+ error: Error | null;
570
+ }
571
+ interface BlobProviderProps {
572
+ document: React.ReactElement<DocumentProps>;
573
+ children: (params: BlobProviderParams) => React.ReactNode;
574
+ }
575
+
576
+ /**
577
+ * Easy and declarative way of getting document's blob data without
578
+ * showing it on screen.
579
+ * @see https://react-pdf.org/advanced#on-the-fly-rendering
580
+ * @platform web
581
+ */
582
+ export class BlobProvider extends React.Component<BlobProviderProps> {}
583
+
584
+ interface PDFViewerProps {
585
+ width?: number | string;
586
+ height?: number | string;
587
+ style?: Style | Style[];
588
+ className?: string;
589
+ children?: React.ReactElement<DocumentProps>;
590
+ innerRef?: React.Ref<HTMLIFrameElement>;
591
+ showToolbar?: boolean;
592
+ }
593
+
594
+ /**
595
+ * Iframe PDF viewer for client-side generated documents.
596
+ * @platform web
597
+ */
598
+ export class PDFViewer extends React.Component<PDFViewerProps> {}
599
+
600
+ interface PDFDownloadLinkProps
601
+ extends Omit<
602
+ React.AnchorHTMLAttributes<HTMLAnchorElement>,
603
+ 'href' | 'children'
604
+ > {
605
+ /** PDF filename. Alias for anchor tag `download` attribute. */
606
+ fileName?: string;
607
+ document: React.ReactElement<DocumentProps>;
608
+ children?: React.ReactNode | React.FC<BlobProviderParams>;
609
+ onClick?: React.AnchorHTMLAttributes<HTMLAnchorElement>['onClick'] &
610
+ ((
611
+ event: React.MouseEvent<HTMLAnchorElement, MouseEvent>,
612
+ instance: UsePDFInstance,
613
+ ) => void);
614
+ ref?: React.Ref<HTMLAnchorElement> | undefined;
615
+ }
616
+
617
+ /**
618
+ * Anchor tag to enable generate and download PDF documents on the fly.
619
+ * @see https://react-pdf.org/advanced#on-the-fly-rendering
620
+ * @platform web
621
+ */
622
+ export class PDFDownloadLink extends React.Component<PDFDownloadLinkProps> {}
623
+
624
+ interface UsePDFInstance {
625
+ loading: boolean;
626
+ blob: Blob | null;
627
+ url: string | null;
628
+ error: string | null;
629
+ }
630
+
631
+ /**
632
+ * React hook for creating and updating a PDF document instance
633
+ * @platform web
634
+ */
635
+ export function usePDF(options?: {
636
+ document?: React.ReactElement<DocumentProps>;
637
+ }): [
638
+ UsePDFInstance,
639
+ (newDocument: React.ReactElement<DocumentProps>) => void,
640
+ ];
641
+
642
+ export const Font: FontStore;
643
+
644
+ export const StyleSheet: {
645
+ create: <T extends Styles>(styles: T) => T;
646
+ };
647
+
648
+ export const version: any;
649
+
650
+ export const PDFRenderer: any;
651
+
652
+ export const pdf: (initialValue?: React.ReactElement<DocumentProps>) => {
653
+ container: any;
654
+ isDirty: () => boolean;
655
+ toString: () => string;
656
+ toBlob: () => Promise<Blob>;
657
+ toBuffer: () => Promise<NodeJS.ReadableStream>;
658
+ on: (event: 'change', callback: () => void) => void;
659
+ updateContainer: (
660
+ document: React.ReactElement<any>,
661
+ callback?: () => void,
662
+ ) => void;
663
+ removeListener: (event: 'change', callback: () => void) => void;
664
+ };
665
+
666
+ export const renderToStream: (
667
+ document: React.ReactElement<DocumentProps>,
668
+ ) => Promise<NodeJS.ReadableStream>;
669
+
670
+ /**
671
+ * @deprecated use the `renderToBuffer` method
672
+ */
673
+ export const renderToString: (
674
+ document: React.ReactElement<DocumentProps>,
675
+ ) => Promise<string>;
676
+
677
+ export const renderToFile: (
678
+ document: React.ReactElement<DocumentProps>,
679
+ filePath: string,
680
+ callback?: (output: NodeJS.ReadableStream, _filePath: string) => any,
681
+ ) => Promise<NodeJS.ReadableStream>;
682
+
683
+ const render: typeof renderToFile;
684
+
685
+ /**
686
+ * Render document into a nodejs buffer
687
+ * @platform node
688
+ */
689
+ export const renderToBuffer: (
690
+ document: React.ReactElement<ReactPDF.DocumentProps>,
691
+ ) => Promise<Buffer>;
692
+ }