@oxog/printkit 1.0.0 → 1.1.1

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/dist/react.d.cts CHANGED
@@ -1,92 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { ReactNode, RefObject, CSSProperties, ButtonHTMLAttributes } from 'react';
3
-
4
- type PageSizeName = 'A3' | 'A4' | 'A5' | 'Letter' | 'Legal' | 'Tabloid';
5
- interface CustomSize {
6
- width: number | string;
7
- height: number | string;
8
- }
9
- type PageSize = PageSizeName | CustomSize;
10
- type Orientation = 'portrait' | 'landscape';
11
- interface MarginOptions {
12
- top?: number | string;
13
- right?: number | string;
14
- bottom?: number | string;
15
- left?: number | string;
16
- }
17
- interface PageInfo {
18
- pageNumber: number;
19
- totalPages: number;
20
- title: string;
21
- date: Date;
22
- }
23
- type HeaderFooterFn = (info: PageInfo) => string;
24
- interface PrintOptions {
25
- title?: string;
26
- pageSize?: PageSize;
27
- orientation?: Orientation;
28
- margin?: number | MarginOptions;
29
- header?: string | HeaderFooterFn;
30
- footer?: string | HeaderFooterFn;
31
- styles?: string | string[];
32
- styleSheets?: string[];
33
- copyStyles?: boolean;
34
- pageBreakBefore?: string;
35
- pageBreakAfter?: string;
36
- avoidBreakInside?: string;
37
- removeAfterPrint?: boolean;
38
- printBackground?: boolean;
39
- onBeforePrint?: () => void | Promise<void>;
40
- onAfterPrint?: () => void;
41
- onError?: (error: PrintError$1) => void;
42
- }
43
- type PrintTarget = HTMLElement | string | HTMLElement[] | string[];
44
- interface PreviewOptions extends PrintOptions {
45
- modal?: ModalOptions;
46
- toolbar?: ToolbarOptions;
47
- onPrint?: () => void;
48
- onDownload?: () => void;
49
- onClose?: () => void;
50
- }
51
- interface ModalOptions {
52
- width?: string | number;
53
- height?: string | number;
54
- showToolbar?: boolean;
55
- showPageNumbers?: boolean;
56
- zoom?: number;
57
- className?: string;
58
- }
59
- interface ToolbarOptions {
60
- print?: boolean;
61
- download?: boolean;
62
- zoom?: boolean;
63
- navigation?: boolean;
64
- close?: boolean;
65
- }
66
- interface PDFOptions extends PrintOptions {
67
- quality?: number;
68
- scale?: number;
69
- metadata?: PDFMetadata;
70
- onProgress?: (progress: number) => void;
71
- }
72
- interface PDFMetadata {
73
- title?: string;
74
- author?: string;
75
- subject?: string;
76
- keywords?: string[];
77
- creator?: string;
78
- creationDate?: Date;
79
- }
80
- interface TableData {
81
- headers: string[];
82
- rows: (string | number)[][];
83
- caption?: string;
84
- }
85
- type PrintErrorCode = 'PRINT_NOT_SUPPORTED' | 'ELEMENT_NOT_FOUND' | 'IFRAME_LOAD_FAILED' | 'PDF_EXPORT_FAILED' | 'STYLE_LOAD_FAILED' | 'CANCELLED' | 'UNKNOWN';
86
- interface PrintError$1 extends Error {
87
- code: PrintErrorCode;
88
- target?: PrintTarget | undefined;
89
- }
3
+ import { P as PrintOptions, b as PrintTarget, u as PrintError, c as PreviewOptions, z as PDFOptions } from './errors-COjJm-gl.cjs';
4
+ export { A as AVOID_BREAK_CLASS, t as BREAK_AFTER_CLASS, B as BREAK_BEFORE_CLASS, O as Orientation, r as PRINT_HIDE_CLASS, s as PRINT_ONLY_CLASS, g as PageSize, K as TableData, w as isPrintError } from './errors-COjJm-gl.cjs';
90
5
 
91
6
  /**
92
7
  * PrintProvider props
@@ -122,15 +37,6 @@ declare const PrintContext: React.Context<PrintContextValue | null>;
122
37
  */
123
38
  declare function usePrintContext(): PrintContextValue;
124
39
 
125
- /**
126
- * Custom error class for print operations
127
- */
128
- declare class PrintError extends Error implements PrintError$1 {
129
- readonly code: PrintErrorCode;
130
- readonly target: PrintTarget | undefined;
131
- constructor(code: PrintErrorCode, message: string, target?: PrintTarget | undefined);
132
- }
133
-
134
40
  /**
135
41
  * usePrint hook result
136
42
  */
@@ -233,7 +139,7 @@ interface UsePrintPreviewResult {
233
139
  /**
234
140
  * Hook for print preview functionality
235
141
  */
236
- declare function usePrintPreview(ref: RefObject<HTMLElement>, options?: PreviewOptions): UsePrintPreviewResult;
142
+ declare function usePrintPreview(ref: RefObject<HTMLElement | null>, options?: PreviewOptions): UsePrintPreviewResult;
237
143
 
238
144
  /**
239
145
  * usePDF hook result
@@ -335,7 +241,7 @@ interface PrintButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>,
335
241
  /**
336
242
  * Reference to the target element
337
243
  */
338
- targetRef?: RefObject<HTMLElement>;
244
+ targetRef?: RefObject<HTMLElement | null>;
339
245
  /**
340
246
  * Print options
341
247
  */
@@ -371,13 +277,14 @@ declare function PrintButton({ target, targetRef, options, children, render, onP
371
277
  */
372
278
  interface PrintPreviewProps extends PreviewOptions {
373
279
  /**
374
- * Target element or selector to preview
280
+ * Target element or selector to preview (`targetRef` takes precedence).
281
+ * Arrays are not supported here; use `createPrintPreview` for several elements.
375
282
  */
376
283
  target?: PrintTarget;
377
284
  /**
378
285
  * Reference to the target element
379
286
  */
380
- targetRef?: RefObject<HTMLElement>;
287
+ targetRef?: RefObject<HTMLElement | null>;
381
288
  /**
382
289
  * Trigger element that opens the preview
383
290
  */
@@ -437,7 +344,7 @@ interface PrintOnlyProps {
437
344
  /**
438
345
  * HTML tag to use
439
346
  */
440
- as?: keyof JSX.IntrinsicElements;
347
+ as?: keyof React__default.JSX.IntrinsicElements;
441
348
  }
442
349
  /**
443
350
  * Component that shows content only when printing
@@ -463,33 +370,11 @@ interface NoPrintProps {
463
370
  /**
464
371
  * HTML tag to use
465
372
  */
466
- as?: keyof JSX.IntrinsicElements;
373
+ as?: keyof React__default.JSX.IntrinsicElements;
467
374
  }
468
375
  /**
469
376
  * Component that hides content when printing
470
377
  */
471
378
  declare function NoPrint({ children, className, style, as: Component, }: NoPrintProps): React__default.JSX.Element;
472
379
 
473
- /**
474
- * CSS class to hide elements when printing
475
- */
476
- declare const PRINT_HIDE_CLASS = "print-hide";
477
- /**
478
- * CSS class to show elements only when printing
479
- */
480
- declare const PRINT_ONLY_CLASS = "print-only";
481
-
482
- /**
483
- * CSS class for page break before
484
- */
485
- declare const BREAK_BEFORE_CLASS = "print-break-before";
486
- /**
487
- * CSS class for page break after
488
- */
489
- declare const BREAK_AFTER_CLASS = "print-break-after";
490
- /**
491
- * CSS class to avoid break inside
492
- */
493
- declare const AVOID_BREAK_CLASS = "print-avoid-break";
494
-
495
- export { AVOID_BREAK_CLASS, BREAK_AFTER_CLASS, BREAK_BEFORE_CLASS, NoPrint, type NoPrintProps, type Orientation, type PDFOptions, PRINT_HIDE_CLASS, PRINT_ONLY_CLASS, PageBreak, type PageBreakProps, type PageSize, type PreviewOptions, PrintButton, type PrintButtonProps, type PrintButtonRenderProps, PrintContext, type PrintContextValue, PrintOnly, type PrintOnlyProps, type PrintOptions, PrintPreview, type PrintPreviewProps, PrintProvider, type PrintProviderProps, type PrintTarget, Printable, type PrintableProps, type PrintableRef, type TableData, type UsePDFResult, type UsePrintPreviewResult, type UsePrintResult, usePDF, usePrint, usePrintContext, usePrintPreview };
380
+ export { NoPrint, type NoPrintProps, PDFOptions, PageBreak, type PageBreakProps, PreviewOptions, PrintButton, type PrintButtonProps, type PrintButtonRenderProps, PrintContext, type PrintContextValue, PrintError, PrintOnly, type PrintOnlyProps, PrintOptions, PrintPreview, type PrintPreviewProps, PrintProvider, type PrintProviderProps, PrintTarget, Printable, type PrintableProps, type PrintableRef, type UsePDFResult, type UsePrintPreviewResult, type UsePrintResult, usePDF, usePrint, usePrintContext, usePrintPreview };
package/dist/react.d.ts CHANGED
@@ -1,92 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { ReactNode, RefObject, CSSProperties, ButtonHTMLAttributes } from 'react';
3
-
4
- type PageSizeName = 'A3' | 'A4' | 'A5' | 'Letter' | 'Legal' | 'Tabloid';
5
- interface CustomSize {
6
- width: number | string;
7
- height: number | string;
8
- }
9
- type PageSize = PageSizeName | CustomSize;
10
- type Orientation = 'portrait' | 'landscape';
11
- interface MarginOptions {
12
- top?: number | string;
13
- right?: number | string;
14
- bottom?: number | string;
15
- left?: number | string;
16
- }
17
- interface PageInfo {
18
- pageNumber: number;
19
- totalPages: number;
20
- title: string;
21
- date: Date;
22
- }
23
- type HeaderFooterFn = (info: PageInfo) => string;
24
- interface PrintOptions {
25
- title?: string;
26
- pageSize?: PageSize;
27
- orientation?: Orientation;
28
- margin?: number | MarginOptions;
29
- header?: string | HeaderFooterFn;
30
- footer?: string | HeaderFooterFn;
31
- styles?: string | string[];
32
- styleSheets?: string[];
33
- copyStyles?: boolean;
34
- pageBreakBefore?: string;
35
- pageBreakAfter?: string;
36
- avoidBreakInside?: string;
37
- removeAfterPrint?: boolean;
38
- printBackground?: boolean;
39
- onBeforePrint?: () => void | Promise<void>;
40
- onAfterPrint?: () => void;
41
- onError?: (error: PrintError$1) => void;
42
- }
43
- type PrintTarget = HTMLElement | string | HTMLElement[] | string[];
44
- interface PreviewOptions extends PrintOptions {
45
- modal?: ModalOptions;
46
- toolbar?: ToolbarOptions;
47
- onPrint?: () => void;
48
- onDownload?: () => void;
49
- onClose?: () => void;
50
- }
51
- interface ModalOptions {
52
- width?: string | number;
53
- height?: string | number;
54
- showToolbar?: boolean;
55
- showPageNumbers?: boolean;
56
- zoom?: number;
57
- className?: string;
58
- }
59
- interface ToolbarOptions {
60
- print?: boolean;
61
- download?: boolean;
62
- zoom?: boolean;
63
- navigation?: boolean;
64
- close?: boolean;
65
- }
66
- interface PDFOptions extends PrintOptions {
67
- quality?: number;
68
- scale?: number;
69
- metadata?: PDFMetadata;
70
- onProgress?: (progress: number) => void;
71
- }
72
- interface PDFMetadata {
73
- title?: string;
74
- author?: string;
75
- subject?: string;
76
- keywords?: string[];
77
- creator?: string;
78
- creationDate?: Date;
79
- }
80
- interface TableData {
81
- headers: string[];
82
- rows: (string | number)[][];
83
- caption?: string;
84
- }
85
- type PrintErrorCode = 'PRINT_NOT_SUPPORTED' | 'ELEMENT_NOT_FOUND' | 'IFRAME_LOAD_FAILED' | 'PDF_EXPORT_FAILED' | 'STYLE_LOAD_FAILED' | 'CANCELLED' | 'UNKNOWN';
86
- interface PrintError$1 extends Error {
87
- code: PrintErrorCode;
88
- target?: PrintTarget | undefined;
89
- }
3
+ import { P as PrintOptions, b as PrintTarget, u as PrintError, c as PreviewOptions, z as PDFOptions } from './errors-COjJm-gl.js';
4
+ export { A as AVOID_BREAK_CLASS, t as BREAK_AFTER_CLASS, B as BREAK_BEFORE_CLASS, O as Orientation, r as PRINT_HIDE_CLASS, s as PRINT_ONLY_CLASS, g as PageSize, K as TableData, w as isPrintError } from './errors-COjJm-gl.js';
90
5
 
91
6
  /**
92
7
  * PrintProvider props
@@ -122,15 +37,6 @@ declare const PrintContext: React.Context<PrintContextValue | null>;
122
37
  */
123
38
  declare function usePrintContext(): PrintContextValue;
124
39
 
125
- /**
126
- * Custom error class for print operations
127
- */
128
- declare class PrintError extends Error implements PrintError$1 {
129
- readonly code: PrintErrorCode;
130
- readonly target: PrintTarget | undefined;
131
- constructor(code: PrintErrorCode, message: string, target?: PrintTarget | undefined);
132
- }
133
-
134
40
  /**
135
41
  * usePrint hook result
136
42
  */
@@ -233,7 +139,7 @@ interface UsePrintPreviewResult {
233
139
  /**
234
140
  * Hook for print preview functionality
235
141
  */
236
- declare function usePrintPreview(ref: RefObject<HTMLElement>, options?: PreviewOptions): UsePrintPreviewResult;
142
+ declare function usePrintPreview(ref: RefObject<HTMLElement | null>, options?: PreviewOptions): UsePrintPreviewResult;
237
143
 
238
144
  /**
239
145
  * usePDF hook result
@@ -335,7 +241,7 @@ interface PrintButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>,
335
241
  /**
336
242
  * Reference to the target element
337
243
  */
338
- targetRef?: RefObject<HTMLElement>;
244
+ targetRef?: RefObject<HTMLElement | null>;
339
245
  /**
340
246
  * Print options
341
247
  */
@@ -371,13 +277,14 @@ declare function PrintButton({ target, targetRef, options, children, render, onP
371
277
  */
372
278
  interface PrintPreviewProps extends PreviewOptions {
373
279
  /**
374
- * Target element or selector to preview
280
+ * Target element or selector to preview (`targetRef` takes precedence).
281
+ * Arrays are not supported here; use `createPrintPreview` for several elements.
375
282
  */
376
283
  target?: PrintTarget;
377
284
  /**
378
285
  * Reference to the target element
379
286
  */
380
- targetRef?: RefObject<HTMLElement>;
287
+ targetRef?: RefObject<HTMLElement | null>;
381
288
  /**
382
289
  * Trigger element that opens the preview
383
290
  */
@@ -437,7 +344,7 @@ interface PrintOnlyProps {
437
344
  /**
438
345
  * HTML tag to use
439
346
  */
440
- as?: keyof JSX.IntrinsicElements;
347
+ as?: keyof React__default.JSX.IntrinsicElements;
441
348
  }
442
349
  /**
443
350
  * Component that shows content only when printing
@@ -463,33 +370,11 @@ interface NoPrintProps {
463
370
  /**
464
371
  * HTML tag to use
465
372
  */
466
- as?: keyof JSX.IntrinsicElements;
373
+ as?: keyof React__default.JSX.IntrinsicElements;
467
374
  }
468
375
  /**
469
376
  * Component that hides content when printing
470
377
  */
471
378
  declare function NoPrint({ children, className, style, as: Component, }: NoPrintProps): React__default.JSX.Element;
472
379
 
473
- /**
474
- * CSS class to hide elements when printing
475
- */
476
- declare const PRINT_HIDE_CLASS = "print-hide";
477
- /**
478
- * CSS class to show elements only when printing
479
- */
480
- declare const PRINT_ONLY_CLASS = "print-only";
481
-
482
- /**
483
- * CSS class for page break before
484
- */
485
- declare const BREAK_BEFORE_CLASS = "print-break-before";
486
- /**
487
- * CSS class for page break after
488
- */
489
- declare const BREAK_AFTER_CLASS = "print-break-after";
490
- /**
491
- * CSS class to avoid break inside
492
- */
493
- declare const AVOID_BREAK_CLASS = "print-avoid-break";
494
-
495
- export { AVOID_BREAK_CLASS, BREAK_AFTER_CLASS, BREAK_BEFORE_CLASS, NoPrint, type NoPrintProps, type Orientation, type PDFOptions, PRINT_HIDE_CLASS, PRINT_ONLY_CLASS, PageBreak, type PageBreakProps, type PageSize, type PreviewOptions, PrintButton, type PrintButtonProps, type PrintButtonRenderProps, PrintContext, type PrintContextValue, PrintOnly, type PrintOnlyProps, type PrintOptions, PrintPreview, type PrintPreviewProps, PrintProvider, type PrintProviderProps, type PrintTarget, Printable, type PrintableProps, type PrintableRef, type TableData, type UsePDFResult, type UsePrintPreviewResult, type UsePrintResult, usePDF, usePrint, usePrintContext, usePrintPreview };
380
+ export { NoPrint, type NoPrintProps, PDFOptions, PageBreak, type PageBreakProps, PreviewOptions, PrintButton, type PrintButtonProps, type PrintButtonRenderProps, PrintContext, type PrintContextValue, PrintError, PrintOnly, type PrintOnlyProps, PrintOptions, PrintPreview, type PrintPreviewProps, PrintProvider, type PrintProviderProps, PrintTarget, Printable, type PrintableProps, type PrintableRef, type UsePDFResult, type UsePrintPreviewResult, type UsePrintResult, usePDF, usePrint, usePrintContext, usePrintPreview };